@yuriai/web 0.3.6 → 0.3.7-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentAvatar-BOvjZ-DI.js → AgentAvatar-uZt0-TOc.js} +1 -1
- package/dist/assets/{AgentSelector-Dl_zIOMk.js → AgentSelector-5iXNLoIx.js} +1 -1
- package/dist/assets/{ArchivedSessionsDialog-Cr9Ji-RY.js → ArchivedSessionsDialog-BvaC7Izk.js} +1 -1
- package/dist/assets/{AssistantConversationSurface-CLdjNFeJ.js → AssistantConversationSurface-ltD21S9d.js} +3 -3
- package/dist/assets/{AssistantSessionCard-BufyrOfo.js → AssistantSessionCard-BQVPnkZz.js} +2 -2
- package/dist/assets/{AssistantUnreadBadge-Dn9HAEDr.js → AssistantUnreadBadge-BSVpexQe.js} +1 -1
- package/dist/assets/{AssistantView-Cg0wPomu.js → AssistantView-Cn3wym_C.js} +1 -1
- package/dist/assets/{AssistantWorkingAvatar-1KNjr2A2.js → AssistantWorkingAvatar-3IFgfMI5.js} +1 -1
- package/dist/assets/{AssistantsSettingsPage-DeYfZAYH.js → AssistantsSettingsPage-B52Fwaza.js} +1 -1
- package/dist/assets/{BinaryFileFallback-DfD02fS_.js → BinaryFileFallback-CqaGa-BI.js} +1 -1
- package/dist/assets/{BtwPanel-B_2w8P0X.js → BtwPanel-grnSijXt.js} +1 -1
- package/dist/assets/{BusyDots-CAv4ygIO.js → BusyDots-43VHGWaC.js} +1 -1
- package/dist/assets/{ChatContainer-Dgv075jT.js → ChatContainer-Hwe0YX5J.js} +4 -4
- package/dist/assets/{ChatView-Cr71C0ZB.js → ChatView-Ei6tfxCe.js} +1 -1
- package/dist/assets/{DiagramView-CTnpBsWU.js → DiagramView-BvRz7w00.js} +1 -1
- package/dist/assets/{DiffView-j_yWF1Mz.js → DiffView-X_cPRpka.js} +1 -1
- package/dist/assets/{DiffViewToggle-CYusbmY5.js → DiffViewToggle-Kt7NTh6a.js} +1 -1
- package/dist/assets/{ErrorBoundary-yr_JeVdx.js → ErrorBoundary-DMpwAWMc.js} +1 -1
- package/dist/assets/{FadeInOnReveal-C56koblQ.js → FadeInOnReveal-CawaWXLd.js} +1 -1
- package/dist/assets/{GuiPluginMount-CBJiLdzR.js → GuiPluginMount-DCZZ6cEG.js} +1 -1
- package/dist/assets/{GuiPluginPage-DJa8gFLk.js → GuiPluginPage-D5uAYpR9.js} +1 -1
- package/dist/assets/{GuiPluginSurface-Cc7q80jp.js → GuiPluginSurface-CBjXvIos.js} +1 -1
- package/dist/assets/{GuiPluginTitlebarItems-rbK3leaL.js → GuiPluginTitlebarItems-C36UkPLK.js} +1 -1
- package/dist/assets/{GuiPluginWindow-Cpg2HYWe.js → GuiPluginWindow-DI08lit_.js} +1 -1
- package/dist/assets/{Icon-C1rjS64C.js → Icon-B4V3WArH.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-2hMqBtYh.js → ImageLoadingPlaceholder-DMofO0Vg.js} +1 -1
- package/dist/assets/{LoadingImage-Bs-621ZL.js → LoadingImage-BBXprBjU.js} +1 -1
- package/dist/assets/MarkdownRenderer-CspY638V.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-DiCCNjDr.js → MarkdownRendererImpl-Be--gMMr.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-Bzz3OZlX.js → MarkstreamRendererImpl-CYdjvap_.js} +1 -1
- package/dist/assets/{MobileAssistantSettingsPage-pBhJR2t6.js → MobileAssistantSettingsPage-CkwFKVXY.js} +1 -1
- package/dist/assets/{MobileAssistantTab-Ceo442NF.js → MobileAssistantTab-B3veLes8.js} +1 -1
- package/dist/assets/{MobileBtwPage-DPPmDMA6.js → MobileBtwPage-B3XErURE.js} +1 -1
- package/dist/assets/{MobileChangesSurface-DfDoSkTS.js → MobileChangesSurface-CRfHLy0W.js} +1 -1
- package/dist/assets/{MobileChatScreen-DHTbrnAr.js → MobileChatScreen-CFiiK55S.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-e1u1y59T.js → MobileDetailNavigation-fIpP3zJ9.js} +1 -1
- package/dist/assets/{MobileFilesSurface-CJoqR3By.js → MobileFilesSurface-0u8kdqVE.js} +2 -2
- package/dist/assets/{MobileHtmlNetworkBoundary-GBhYVYvu.js → MobileHtmlNetworkBoundary-C3w-rvNJ.js} +2 -2
- package/dist/assets/{MobileOverlayPanel-DzKTKeZX.js → MobileOverlayPanel-DqVr7HoM.js} +1 -1
- package/dist/assets/{MobileResizableSheet-CkA7qhco.js → MobileResizableSheet-CmMITCRX.js} +1 -1
- package/dist/assets/{MobileSettingsTab-Bv0HsXFH.js → MobileSettingsTab-Bfoj6oZ9.js} +1 -1
- package/dist/assets/{MobileShareBridge-B-co2UPE.js → MobileShareBridge-DRywmiRN.js} +1 -1
- package/dist/assets/{MobileSurface-D63k27t5.js → MobileSurface-BveBoewm.js} +1 -1
- package/dist/assets/{MobileTabPageHeader-FmtbGhwq.js → MobileTabPageHeader-BKkxpg00.js} +1 -1
- package/dist/assets/{ModelLogo-CMnp5fyy.js → ModelLogo-BSDCUld6.js} +1 -1
- package/dist/assets/{ModelSelector-BF4wYwaz.js → ModelSelector-DcIUMkrC.js} +1 -1
- package/dist/assets/{MultiRunWindow-D0OU63re.js → MultiRunWindow-CC0gEHEt.js} +1 -1
- package/dist/assets/{OnboardingScreen-CDHtDQ0k.js → OnboardingScreen-CgYmkOnG.js} +1 -1
- package/dist/assets/{OverlayScrollbar-m1EAqRES.js → OverlayScrollbar-TqUMJujL.js} +1 -1
- package/dist/assets/{PierreDiffViewer-CZk1tZ3K.js → PierreDiffViewer-D5Q_DJ23.js} +1 -1
- package/dist/assets/{ProviderLogo-BqQTME35.js → ProviderLogo-Dh2oKu37.js} +1 -1
- package/dist/assets/{RemoteAssistantSessionCard-CrbCVhqD.js → RemoteAssistantSessionCard-BvR2QPyd.js} +1 -1
- package/dist/assets/{RemoteDesktopPanel-BzLmzmjb.js → RemoteDesktopPanel-CP_NZRqB.js} +1 -1
- package/dist/assets/{ScheduledTasksDialog-DmtcDZHc.js → ScheduledTasksDialog-BI5Y_mbe.js} +1 -1
- package/dist/assets/{ScrollableOverlay-CEglrXfm.js → ScrollableOverlay-DNBsKLrs.js} +1 -1
- package/dist/assets/SettingsGroup-DBUgdYyK.js +1 -0
- package/dist/assets/{SettingsView-CYEjDYWC.js → SettingsView-yDGWdErX.js} +5 -5
- package/dist/assets/{SettingsWindow-CvJsxUyu.js → SettingsWindow-tYCzlPbh.js} +1 -1
- package/dist/assets/{SetupTourDialog-DWaVtkY0.js → SetupTourDialog-DmVwOlaa.js} +1 -1
- package/dist/assets/{SyncActions-C0gph0P8.js → SyncActions-CIiH2YAa.js} +1 -1
- package/dist/assets/{TerminalView-Cm8Ts51w.js → TerminalView-s8qzyQ1U.js} +1 -1
- package/dist/assets/{TextSelectionMenu-Dcv_PdES.js → TextSelectionMenu-DV6-bozc.js} +1 -1
- package/dist/assets/{ToolOutputDialog-QJpQjmqK.js → ToolOutputDialog-AQRtLxWE.js} +1 -1
- package/dist/assets/{YuriLogo-BbS_Wj4g.js → YuriLogo-1yVZFnVN.js} +1 -1
- package/dist/assets/{assistantMessagePreview-wmP-d_oa.js → assistantMessagePreview-B1M5pz20.js} +1 -1
- package/dist/assets/{assistantQueries-Dpxq78yP.js → assistantQueries-CKIDS7If.js} +1 -1
- package/dist/assets/{auto-read-context-aRn5yhDb.js → auto-read-context-m-DSqlLf.js} +1 -1
- package/dist/assets/{capgoAdapter-BSnmtwX8.js → capgoAdapter-DSPS3fL5.js} +1 -1
- package/dist/assets/{card-aoveY4I3.js → card-DKTuTAht.js} +1 -1
- package/dist/assets/{chatUpwardIntent-WxxmOppY.js → chatUpwardIntent-D2Ay65Ri.js} +1 -1
- package/dist/assets/{checkbox-CljLXON1.js → checkbox-BDifu847.js} +1 -1
- package/dist/assets/{collapsible-DkeWKEAb.js → collapsible-Cv0Ew8UR.js} +1 -1
- package/dist/assets/{connection-hint-DsKyICgn.js → connection-hint-Dk_9Oxi7.js} +1 -1
- package/dist/assets/{context-menu-XuMa5TsA.js → context-menu-BjSM4m3u.js} +1 -1
- package/dist/assets/{diagram-DFv7Lh0h.js → diagram-Re1b4Drg.js} +1 -1
- package/dist/assets/{dialog-Cx20I73q.js → dialog-CSek_Z3q.js} +1 -1
- package/dist/assets/{dropdown-menu-XdfySbu2.js → dropdown-menu-D_C8_7Xw.js} +1 -1
- package/dist/assets/{es-CLAEdHpc.js → es-C1spVk4O.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-pXNTKHAc.js → fileMentionTouchSelection-DySVh4tf.js} +1 -1
- package/dist/assets/{fr-BOB0gfdQ.js → fr-yyP7Hlty.js} +1 -1
- package/dist/assets/{gitApi-LXGRaDt8.js → gitApi-Bz38D_S1.js} +1 -1
- package/dist/assets/{i18n-iu4pzqPi.js → i18n-Sh2Qk9nD.js} +1 -1
- package/dist/assets/{icons-BWijARKS.js → icons-Du1K-vJd.js} +1 -1
- package/dist/assets/{input-BMYgp87Q.js → input-C5gthyYl.js} +1 -1
- package/dist/assets/{insertionBoundaries-bmxIeFzH.js → insertionBoundaries-DYPFjCrm.js} +1 -1
- package/dist/assets/{ja-CfM9jZ6u.js → ja-ChftrfCh.js} +1 -1
- package/dist/assets/{kbd-6RW-BxuR.js → kbd-DzULFVDy.js} +1 -1
- package/dist/assets/{ko-DZOSVPHB.js → ko-BrLgX_6B.js} +1 -1
- package/dist/assets/{main-BLBAaohb.js → main-BKOh3bz9.js} +2 -2
- package/dist/assets/{main-B-Wdp6An.js → main-BXPRoPV7.js} +4 -4
- package/dist/assets/{markdownHeightCache-ojT5txMS.js → markdownHeightCache-DO3GzWD0.js} +1 -1
- package/dist/assets/{mcpQueries-BRuytwhB.js → mcpQueries-CCcPl38n.js} +1 -1
- package/dist/assets/{miniChat-BsrHy2rU.js → miniChat-ChjBS5lx.js} +2 -2
- package/dist/assets/{mobile-B8SHiXyq.js → mobile-B9Y1NmBW.js} +2 -2
- package/dist/assets/{mobileBackNavigation-CVrR_jtn.js → mobileBackNavigation-DbRzQPwl.js} +1 -1
- package/dist/assets/{mobileConnections-iSUwFNqu.js → mobileConnections-BtrjKVQ8.js} +2 -2
- package/dist/assets/{multirun-Y3K5yS-8.js → multirun-0sGmTbAW.js} +1 -1
- package/dist/assets/{native-config-tvqKHwCC.js → native-config-Di2EbpNU.js} +1 -1
- package/dist/assets/{nativeComposerCover-5rYz1E3W.js → nativeComposerCover-BQvSzlay.js} +1 -1
- package/dist/assets/{navigation-DFmCAq2g.js → navigation-By33kYra.js} +1 -1
- package/dist/assets/{openRemoteProjectSession-CeSahDtQ.js → openRemoteProjectSession-CtDnPbHy.js} +1 -1
- package/dist/assets/{openSessionFromDeepLink-DsZnNy4W.js → openSessionFromDeepLink-BI3ok38A.js} +2 -2
- package/dist/assets/{pl-CaT81Sz8.js → pl-DlKDQDhl.js} +1 -1
- package/dist/assets/{pluginPresentation-rls1AMJN.js → pluginPresentation-CWDQXAGY.js} +1 -1
- package/dist/assets/{pt-BR-9p1IKCEF.js → pt-BR-BldJPFQ5.js} +1 -1
- package/dist/assets/{pwa-BrLPfcLk.js → pwa-DY4ywKCC.js} +1 -1
- package/dist/assets/{queue-abort-optimistic-CXKdQu_T.js → queue-abort-optimistic-Deyot0Nr.js} +1 -1
- package/dist/assets/{quota-BhdKv_Wc.js → quota-jMPnmJTS.js} +1 -1
- package/dist/assets/{reference-history-Bzn-aPYg.js → reference-history-CH-irHvl.js} +1 -1
- package/dist/assets/{remoteSessionReference-DORvqUYQ.js → remoteSessionReference-BqNn5Ng9.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-DXKgwBat.js → renderElectronMiniChatApp-DdDxtINC.js} +2 -2
- package/dist/assets/{renderMobileApp-CKN6rWxR.js → renderMobileApp-B3MU9lvz.js} +4 -4
- package/dist/assets/{runtimeConfig-BqUZF6Wt.js → runtimeConfig-Cq1eathE.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-Bu02gAs3.js → runtimeEndpointReset-7jsAdYmA.js} +2 -2
- package/dist/assets/{select-BPIsJWhM.js → select-BXiRJQfM.js} +1 -1
- package/dist/assets/{sessionLookup-DZhrkKRI.js → sessionLookup-EXBDKdL9.js} +1 -1
- package/dist/assets/{sessionOwnership-LoUNVeuJ.js → sessionOwnership-DGgtXHNT.js} +1 -1
- package/dist/assets/{shortcuts-DMupfl7l.js → shortcuts-BF4EX_Rx.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-1bKw81VO.js → sortable-tabs-strip-CmCxOwOO.js} +1 -1
- package/dist/assets/{speechSettingsQueries-C3JgzCqy.js → speechSettingsQueries-ClTsMdAi.js} +1 -1
- package/dist/assets/src-B7qham90.css +2 -0
- package/dist/assets/{store-BgsgBTwJ.js → store-BGuutgkJ.js} +3 -3
- package/dist/assets/{switch-B4-v9kvg.js → switch-DaczlfD6.js} +1 -1
- package/dist/assets/{textarea-DExmj0ZR.js → textarea-BMiRyX6F.js} +1 -1
- package/dist/assets/{timeFormat-BlSO2-ws.js → timeFormat-BaiPCZgf.js} +1 -1
- package/dist/assets/{tooltip-Di-WRJUZ.js → tooltip-D5wqtxlx.js} +1 -1
- package/dist/assets/{truncated-path-nKzykV5p.js → truncated-path-DwHONVyA.js} +1 -1
- package/dist/assets/types-BjDNwP80.js +2 -0
- package/dist/assets/{ui-BCYkB585.js → ui-B57gL0cH.js} +6 -6
- package/dist/assets/{uk-BUSl_Y_1.js → uk-Cw2L_unr.js} +1 -1
- package/dist/assets/{useAppFontEffects-BCJPQstm.js → useAppFontEffects-C1DyabMJ.js} +2 -2
- package/dist/assets/{useDesktopWindowControlsLayout-BtpyMlOS.js → useDesktopWindowControlsLayout-BS_7xRdK.js} +1 -1
- package/dist/assets/{useDictation-4HBMkISY.js → useDictation-83-qDgkn.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-BYswRwIv.js → useEffectiveDirectory-BVSvX0gR.js} +1 -1
- package/dist/assets/{useGitStore-DqBPgmf-.js → useGitStore-D5j-CYlL.js} +1 -1
- package/dist/assets/{useInlineCommentDraftStore-CGJ6dM8d.js → useInlineCommentDraftStore-CvSDMS3T.js} +1 -1
- package/dist/assets/{useMcpConfigStore-DEcxFuzW.js → useMcpConfigStore-BCol_XdF.js} +1 -1
- package/dist/assets/{useMobileSwipeActions-DqlR4X-T.js → useMobileSwipeActions-Clqu20Uf.js} +1 -1
- package/dist/assets/{useMobileTranscriptSyncHint-BDKcqtq_.js → useMobileTranscriptSyncHint-DkwUC5sr.js} +1 -1
- package/dist/assets/{useModelLists-DsFTBlMr.js → useModelLists-BfC2IQwO.js} +1 -1
- package/dist/assets/{useOpenCodeReadiness-CHybAoBh.js → useOpenCodeReadiness-BHY0hseI.js} +1 -1
- package/dist/assets/{usePluginsStore-BIBHPK4A.js → usePluginsStore-CP3eeHCz.js} +1 -1
- package/dist/assets/{useProjectGitActions-DeFcqi_O.js → useProjectGitActions-B8Frm8fF.js} +1 -1
- package/dist/assets/{useProjectGitStore-JGZk-NCk.js → useProjectGitStore-CqjQngOX.js} +1 -1
- package/dist/assets/{useProjectRuntimeAPIs-BMBBtJB-.js → useProjectRuntimeAPIs-Co1VAzSK.js} +1 -1
- package/dist/assets/{useQuotaStore-C3qJTiD7.js → useQuotaStore-CHxR2ZkD.js} +1 -1
- package/dist/assets/{useSessionBtwStore-D7P-pknd.js → useSessionBtwStore-CZ0QND4b.js} +1 -1
- package/dist/assets/{useStreamingTextThrottle-CjWAE0oQ.js → useStreamingTextThrottle-D19Dm3W6.js} +1 -1
- package/dist/assets/{worktreeManager-pRvX5dQT.js → worktreeManager-nlQu_BbV.js} +1 -1
- package/dist/assets/{worktreeSourceBranchPreference-B7d3RYcc.js → worktreeSourceBranchPreference-BGrLknHI.js} +1 -1
- package/dist/assets/{zh-CN-BGKgQtWd.js → zh-CN-BQXjCmNe.js} +1 -1
- package/dist/assets/{zh-TW-jM5lIKfe.js → zh-TW-Y0lErpEY.js} +1 -1
- package/dist/index.html +6 -6
- package/dist/mini-chat.html +6 -6
- package/dist/mobile.html +2 -2
- package/package.json +1 -1
- package/server/lib/relay/DOCUMENTATION.md +1 -1
- package/server/lib/relay/relay-server.e2e.test.ts +12 -0
- package/server/lib/ui-auth/DOCUMENTATION.md +1 -1
- package/server/lib/ui-auth/ui-auth.js +2 -0
- package/server/lib/ui-auth/ui-auth.test.js +20 -1
- package/dist/assets/MarkdownRenderer-BZl_T1ng.js +0 -2
- package/dist/assets/SettingsGroup-Bm-l3IIs.js +0 -1
- package/dist/assets/src-BacdFOCS.css +0 -2
- package/dist/assets/types-4xeqxklF.js +0 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToolOutputDialog-
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,c as n,i as r,p as i,t as a,v as o,w as s}from"./runtime-auth-DA-qfGHk.js";import{c,f as l,i as u,n as d,o as f,r as p,s as m,t as h}from"./runtime-switch-DEPKHgdL.js";import{n as g}from"./runtime-fetch-V-iMWR8t.js";import{$ as _,A as v,B as y,E as b,F as x,G as S,I as C,K as w,L as T,R as E,U as D,W as O,Z as k,a as A,at as j,c as M,ct as N,d as P,dt as F,et as I,f as L,ft as R,g as z,j as ee,k as B,l as V,lt as te,s as ne,u as re,ut as ie,z as ae}from"./platform-B2ylz14u.js";import{n as H,t as U}from"./runtimeAPIRegistry-C2VogTny.js";import{d as oe,h as W,m as se,r as ce,v as le}from"./desktopHosts-COI-czjF.js";import{a as ue,i as de,t as fe}from"./vendor-zustand-CTekDqaS.js";import{A as pe,B as me,C as he,H as ge,M as _e,P as ve,S as ye,V as be,b as xe,it as Se,j as Ce,k as we,ot as Te,st as Ee,v as De,x as Oe,y as ke,z as Ae}from"./vendor-base-ui-wXsskyKm.js";import{Ct as je,Et as Me,Ft as Ne,Mt as Pe,Pt as Fe,St as G,Tt as Ie,an as Le,jt as Re,on as ze,wt as Be,xt as Ve}from"./gitApiHttp-ZjM4HkSo.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as He,r as Ue,t as We}from"./safeStorage-DTOhKN0V.js";import{B as Ge,H as Ke,Jt as qe,Rt as Je,St as Ye,Xt as Xe,Zt as Ze,an as Qe,ft as $e,ht as et,mt as tt,n as nt,on as rt,qt as it,rn as at,tn as ot,vr as st,zt as ct}from"./client-CmtAKi5B.js";import{P as lt,d as ut,z as dt}from"./prompt-attachment-upload-BzYqZdzd.js";import{n as ft}from"./pathNormalization-ewtPqJWn.js";import{n as pt,t as mt}from"./vendor-react-BkccXcWz.js";import{f as ht,u as gt}from"./vendor-tanstack-query-core-BSjXNgF_.js";import{n as _t,o as vt,s as yt}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{E as bt,I as xt,O as St,P as Ct,R as wt,W as Tt,c as Et,r as Dt,s as Ot,t as kt,y as At,z as jt}from"./runtime-file-resource-BGZ4tGr5.js";import{a as Mt,n as Nt}from"./path-utils-jGozTg9d.js";import{h as Pt,m as Ft,r as K}from"./vendor-reactuses-core-DjKFMfz7.js";import{r as It}from"./summaries-BQMyJaaw.js";import{o as Lt}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{a as Rt,i as zt,o as Bt,r as q,s as Vt,t as Ht}from"./useUIStore-68ZPpgYA.js";import{o as Ut}from"./useMobileHtmlPreviewStore-BYunNOBo.js";import{n as Wt,r as Gt}from"./terminalApi-wdwb9MVG.js";import{a as Kt}from"./types-4xeqxklF.js";import{t as qt}from"./bootstrap-eLlfzqAI.js";/* empty css */import{U as Jt}from"./vendor-codemirror-autocomplete-C0FrlFqZ.js";import{n as Yt}from"./vendor-pierre-diffs-B0OmIhMO.js";import{$r as Xt,A as Zt,Ai as Qt,Bi as $t,Ci as en,Et as tn,F as nn,Fa as rn,Fi as an,Fn as on,Ga as sn,Gr as cn,H as ln,Ha as un,Hr as dn,I as fn,Ii as pn,Kr as mn,Mi as hn,Ni as gn,Oi as _n,R as vn,S as yn,St as bn,Tt as xn,U as Sn,Ur as Cn,Vi as wn,Vr as Tn,W as En,Wa as Dn,Xi as On,Xn as J,Yi as kn,Yr as An,Zi as jn,Zr as Mn,_n as Nn,an as Pn,ao as Fn,at as In,b as Ln,br as Rn,bt as zn,ci as Bn,co as Vn,ct as Hn,da as Un,dn as Wn,ei as Gn,f as Kn,ft as qn,gt as Jn,h as Yn,ht as Xn,io as Y,ji as Zn,k as Qn,lo as $n,lt as er,mi as tr,mt as nr,nt as rr,o as ir,on as ar,oo as or,or as sr,p as cr,qt as lr,ra as ur,ro as dr,so as fr,st as pr,t as X,tt as mr,ui as hr,uo as gr,ut as _r,v as vr,wt as yr,x as br,xr,xt as Sr,y as Cr}from"./ui-BCYkB585.js";import{n as Z,t as wr}from"./Icon-C1rjS64C.js";import{d as Tr,h as Er,m as Dr,p as Or}from"./remoteProjectQueries-BQzoY_Y9.js";import{a as kr,i as Ar,n as jr,r as Mr,t as Nr}from"./i18n-iu4pzqPi.js";import{n as Pr}from"./store-BgsgBTwJ.js";import{n as Fr}from"./input-store-CzG_3qFv.js";import{a as Ir,c as Lr,i as Rr,l as zr,o as Br,s as Vr}from"./toolHelpers-iEHVHQ9p.js";import{n as Hr}from"./useAssistantUIStore-BUWPTwNV.js";import{n as Ur,t as Wr}from"./ScrollableOverlay-CEglrXfm.js";import{n as Gr,o as Kr}from"./vendor-framer-motion-D5NyyC73.js";import{a as qr,i as Jr,n as Yr,o as Xr,r as Zr,t as Qr}from"./dialog-Cx20I73q.js";import{i as $r,n as ei,r as ti,t as ni}from"./tooltip-Di-WRJUZ.js";import{n as ri,t as ii}from"./useInlineCommentDraftStore-CGJ6dM8d.js";import{n as ai}from"./useThemeSystem-BIXghnHj.js";import{a as oi,i as si,n as ci,r as li,t as ui}from"./useProjectGitActions-DeFcqi_O.js";import{a as di,r as fi}from"./device-TCHW5U2y.js";import{t as pi}from"./SyncActions-C0gph0P8.js";import{i as mi,n as hi,r as gi,t as _i}from"./dropdown-menu.styles-BDla58Rm.js";import{c as vi,i as yi,n as bi,r as xi,s as Si,t as Ci}from"./dropdown-menu-XdfySbu2.js";import{a as wi,i as Ti,n as Ei,r as Di,t as Oi}from"./context-menu-XuMa5TsA.js";import{n as ki,r as Ai,t as ji}from"./collapsible-DkeWKEAb.js";import{a as Mi,i as Ni,n as Pi,o as Fi,r as Ii}from"./PierreDiffViewer-CZk1tZ3K.js";import{n as Li,t as Ri}from"./kbd-6RW-BxuR.js";import{t as zi}from"./DiffWorkerProvider-VFPkag9y.js";import{n as Bi,t as Vi}from"./appThemeRegistry-BdjrGBQ4.js";import{r as Hi}from"./themes-BgDJcxRc.js";import{n as Ui,t as Wi}from"./useEffectiveDirectory-BYswRwIv.js";import{n as Gi,t as Ki}from"./useProjectRuntimeAPIs-BMBBtJB-.js";import{b as qi,h as Ji,m as Yi}from"./gitApi-LXGRaDt8.js";import{a as Xi,o as Zi,s as Qi}from"./useGitStore-DqBPgmf-.js";import{a as $i,i as ea,n as ta,o as na,r as ra,s as ia,t as aa}from"./useProjectGitStore-JGZk-NCk.js";import{i as oa,n as sa,r as ca}from"./MobileHtmlNetworkBoundary-GBhYVYvu.js";import{n as la,t as ua}from"./relay-preview-frame-src-BPyz3nXA.js";import{a as da,i as fa,n as pa,r as ma,t as ha}from"./BinaryFileFallback-DfD02fS_.js";import{t as ga}from"./ImageLoadingPlaceholder-2hMqBtYh.js";import{t as _a}from"./LoadingImage-Bs-621ZL.js";import{t as va}from"./input-BMYgp87Q.js";import{n as ya,o as ba}from"./MarkdownRenderer-BZl_T1ng.js";import{c as xa,i as Sa,l as Ca,n as wa,o as Ta,s as Ea}from"./shortcuts-DMupfl7l.js";import{n as Da,r as Oa}from"./SessionSurfaceContext-BP4NCKp6.js";import{o as ka}from"./useSessionBtwStore-D7P-pknd.js";import{t as Aa}from"./useDebouncedValue-BHlMPqY8.js";import{m as ja,x as Ma,y as Na}from"./assistantQueries-Dpxq78yP.js";import{A as Pa,C as Fa,D as Ia,E as La,F as Ra,I as za,M as Ba,N as Va,O as Ha,P as Ua,R as Wa,S as Ga,T as Ka,_ as qa,b as Ja,c as Ya,d as Xa,f as Za,g as Qa,h as $a,i as eo,j as to,k as no,l as ro,m as io,n as ao,p as oo,s as so,t as co,u as lo,v as uo,w as fo,x as po,y as mo,z as ho}from"./useAppFontEffects-BCJPQstm.js";import{D as go,E as _o,J as vo,S as yo,_ as bo,b as xo,c as So,d as Co,f as wo,it as To,m as Eo,u as Do,v as Oo,x as ko,y as Ao}from"./pwa-BrLPfcLk.js";import{t as jo}from"./YuriLogo-BbS_Wj4g.js";import{t as Mo}from"./card-aoveY4I3.js";import{t as No}from"./ErrorBoundary-yr_JeVdx.js";import{a as Po,n as Fo,o as Io,r as Lo}from"./contextPanelEmbeddedChat-Dm5R_b5X.js";import{i as Ro,r as zo}from"./connection-hint-DsKyICgn.js";import{u as Bo}from"./insertionBoundaries-bmxIeFzH.js";import{t as Vo}from"./ModelLogo-CMnp5fyy.js";import{_ as Ho,a as Uo,c as Wo,d as Go,f as Ko,i as qo,l as Jo,n as Yo,o as Xo,p as Zo,r as Qo,s as $o,u as es,y as ts}from"./ChatContainer-Dgv075jT.js";import{C as ns,i as rs,n as is,r as as}from"./BtwPanel-B_2w8P0X.js";import{A as os,D as ss,E as cs,M as ls,O as us,P as ds,T as fs,X as ps,j as ms,k as hs}from"./BusyDots-CAv4ygIO.js";import{_ as gs,i as _s,l as vs,n as ys,s as bs,t as xs,v as Ss}from"./vendor-dnd-kit-core-qy5stxu5.js";import{a as Cs,n as ws,s as Ts,t as Es}from"./vendor-dnd-kit-sortable-CiTIuX4o.js";import{t as Ds}from"./MobileOverlayPanel-DzKTKeZX.js";import{t as Os}from"./ProviderLogo-BqQTME35.js";import{d as ks}from"./ToolOutputDialog-QJpQjmqK.js";import{t as As}from"./vendor-motion-vLNN8EMu.js";import{c as js,i as Ms,n as Ns,s as Ps,t as Fs}from"./select-BPIsJWhM.js";import{a as Is}from"./githubAuthQueries-3AJp5LD5.js";import{c as Ls,i as Rs,n as zs,s as Bs}from"./worktreeManager-pRvX5dQT.js";import{t as Vs}from"./sortable-tabs-strip-1bKw81VO.js";import{i as Hs}from"./auto-read-context-aRn5yhDb.js";import{n as Us,t as Ws}from"./timeFormat-BlSO2-ws.js";import{a as Gs,c as Ks,i as qs,n as Js,o as Ys,r as Xs,u as Zs}from"./useQuotaStore-C3qJTiD7.js";import{a as Qs,i as $s,n as ec,s as tc,t as nc}from"./quota-BhdKv_Wc.js";import{i as rc,n as ic,r as ac,t as oc}from"./useDesktopWindowControlsLayout-BtpyMlOS.js";import{n as sc,t as cc}from"./sessionChangeSummary-BCF9VwAA.js";import{n as lc,t as uc}from"./openRemoteProjectSession-CeSahDtQ.js";import{t as dc}from"./useTerminalStore-C_QzSEgP.js";import{$ as fc,A as pc,At as mc,B as hc,Bt as gc,Ct as _c,D as vc,Dt as yc,E as bc,F as xc,Ft as Sc,G as Cc,H as wc,Ht as Tc,I as Ec,It as Dc,J as Oc,K as kc,L as Ac,Lt as jc,M as Mc,Mt as Nc,N as Pc,Nt as Fc,O as Ic,Ot as Lc,P as Rc,Pt as zc,Q as Bc,R as Vc,Rt as Hc,S as Uc,St as Wc,U as Gc,Vt as Kc,W as qc,Y as Jc,Z as Yc,a as Xc,at as Zc,b as Qc,bt as $c,et as el,g as tl,i as nl,it as rl,j as il,jt as al,k as ol,kt as sl,n as cl,nt as ll,o as ul,ot as dl,q as fl,r as pl,rt as ml,s as hl,tt as gl,v as _l,vt as vl,w as yl,x as bl,xt as xl,y as Sl,yt as Cl,z as wl,zt as Tl}from"./runtimeEndpointReset-Bu02gAs3.js";import{t as El}from"./YuriWordmark-CqkcfAJl.js";import{_ as Dl,d as Ol,g as kl,h as Al,m as jl,p as Ml,r as Nl,t as Pl,v as Fl,y as Il}from"./sessionOwnership-LoUNVeuJ.js";import{i as Ll,n as Rl}from"./icons-BWijARKS.js";import{r as zl,t as Bl}from"./navigation-DFmCAq2g.js";import{t as Vl}from"./AssistantUnreadBadge-Dn9HAEDr.js";import{n as Hl,t as Ul}from"./GuiPluginPage-DJa8gFLk.js";import{d as Wl,i as Gl,n as Kl,r as ql,u as Jl}from"./historyImportQueries-B_mfphxe.js";import{n as Yl}from"./ScheduledTasksDialog-DmtcDZHc.js";import{t as Xl}from"./ChatView-Cr71C0ZB.js";import{t as Zl}from"./diagram-DFv7Lh0h.js";import{t as Ql}from"./DiffView-j_yWF1Mz.js";import{a as $l,i as eu,n as tu,o as nu,r as ru,t as iu}from"./multirun-Y3K5yS-8.js";import{_ as au,a as ou,c as su,d as cu,f as lu,g as uu,h as du,i as fu,l as pu,m as mu,o as hu,p as gu,r as _u,s as vu,t as yu,u as bu}from"./ArchivedSessionsDialog-Cr9Ji-RY.js";import{a as xu,i as Su,n as Cu,r as wu,t as Tu}from"./projectActions-B11KAI3f.js";import{t as Eu}from"./GuiPluginTitlebarItems-rbK3leaL.js";import{t as Du}from"./vendor-zumer-snapdom-yq9vlCKr.js";import{n as Ou,t as ku}from"./vendor-html-to-image-BDMm2v6d.js";var Q=e(Ee(),1),Au=mt(),ju=pt(),$=Te();function Mu(e){let t=(0,ju.c)(14),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({size:i,className:n,style:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=typeof i==`number`?`${i}px`:i,s=typeof i==`number`?`${i}px`:i,c;t[5]!==a||t[6]!==o||t[7]!==s?(c={width:o,height:s,...a},t[5]=a,t[6]=o,t[7]=s,t[8]=c):c=t[8];let l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`path`,{d:`M112,148a12,12,0,0,0-12,12v19L69.17,148.2A4,4,0,0,1,68,145.37V97.94a36,36,0,1,0-24,0v47.43a27.81,27.81,0,0,0,8.2,19.8L83,196H64a12,12,0,0,0,0,24h48a12,12,0,0,0,12-12V160A12,12,0,0,0,112,148ZM56,52A12,12,0,1,1,44,64,12,12,0,0,1,56,52ZM212,158.06V110.63a27.81,27.81,0,0,0-8.2-19.8L173,60h19a12,12,0,0,0,0-24H144a12,12,0,0,0-12,12V96a12,12,0,0,0,24,0V77l30.83,30.83a4,4,0,0,1,1.17,2.83v47.43a36,36,0,1,0,24,0ZM200,204a12,12,0,1,1,12-12A12,12,0,0,1,200,204Z`}),t[9]=l):l=t[9];let u;return t[10]!==n||t[11]!==r||t[12]!==c?(u=(0,$.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 256 256`,fill:`currentColor`,className:n,style:c,...r,children:l}),t[10]=n,t[11]=r,t[12]=c,t[13]=u):u=t[13],u}var Nu=!1,Pu=0,Fu=new Set,Iu=async()=>{let e=++Pu;try{let t=await ee(`desktop_is_window_fullscreen`);if(e!==Pu||t===Nu)return;Nu=t===!0,Fu.forEach(e=>e())}catch{}},Lu=e=>C()?(Fu.add(e),Fu.size===1&&(window.addEventListener(`yuri:window-resized`,Iu),Iu()),()=>{Fu.delete(e),Fu.size===0&&(window.removeEventListener(`yuri:window-resized`,Iu),Pu++,Nu=!1)}):()=>{};function Ru(){return(0,Q.useSyncExternalStore)(Lu,Bu,zu)}function zu(){return!1}function Bu(){return Nu}function Vu(){let e=(0,ju.c)(19),{t}=Nr(),n=q(Ku),r=q(Gu),i=q(Wu),a=q(Uu),o=q(Hu),s=n&&r||i,c;e[0]!==n||e[1]!==r||e[2]!==i||e[3]!==a||e[4]!==o?(c=()=>{if(!r){n||a(!0),o(!i);return}a(!n)},e[0]=n,e[1]=r,e[2]=i,e[3]=a,e[4]=o,e[5]=c):c=e[5];let l=K(c),u;e[6]===t?u=e[7]:(u=t(`header.workStatusPanel.toggleAria`),e[6]=t,e[7]=u);let d;e[8]===t?d=e[9]:(d=t(`header.workStatusPanel.toggleAria`),e[8]=t,e[9]=d);let f=s?`text-foreground`:`text-muted-foreground/50`,p;e[10]===f?p=e[11]:(p=Y(`app-region-no-drag size-7`,f),e[10]=f,e[11]=p);let m;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(Z,{name:`settings-2`,className:`size-4`}),e[12]=m):m=e[12];let h;return e[13]!==s||e[14]!==u||e[15]!==d||e[16]!==p||e[17]!==l?(h=(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,"data-work-status-toggle":`true`,"aria-pressed":s,"aria-label":u,title:d,onClick:l,className:p,children:m}),e[13]=s,e[14]=u,e[15]=d,e[16]=p,e[17]=l,e[18]=h):h=e[18],h}function Hu(e){return e.setWorkStatusOverlayOpen}function Uu(e){return e.setWorkStatusPanelEnabled}function Wu(e){return e.workStatusOverlayOpen}function Gu(e){return e.workStatusPanelFits}function Ku(e){return e.workStatusPanelEnabled}var qu=(e,t,n)=>vt({queryKey:[`desktop-host-inventory`,e],queryFn:async({signal:e})=>{let r=await ce(),i=new Set(r.sshHostIds??[]);if(r.sshHostIds===void 0&&P()){let e=await vo();for(let t of e.instances)i.add(t.id)}return e.throwIfAborted(),{hosts:r.hosts.filter(e=>se(e,i)||t===`host:${e.id}`||!!(n&&W(n,oe(e)))),sshIds:i}}});function Ju(e){let t=(0,ju.c)(18),{onClick:n,open:r}=e,{t:i}=Nr(),a=Q.useSyncExternalStore(c,u,u),o=q(Yu),s=p(),l=h(),d=x(),{data:f}=yt({...qu(a,s,l),enabled:!o}),m=s.startsWith(`host:`)?s.slice(5):null,g=f?.hosts.find(e=>m?e.id===m:!!(l&&W(l,oe(e))));if(d&&!f?.hosts.length&&!f?.sshIds.size)return null;let _=g?le(g.label):i(d?`desktopHostSwitcher.instance.local`:`desktopHostSwitcher.title`),v=Ra({isLocal:d,isSsh:!!(g&&f?.sshIds.has(g.id)),isRelay:a.startsWith(`relay:`)}),y=ni,b=$r,S=J,C=i(`header.actions.sessionMenu.servicesWithInstance`,{current:_}),w;t[0]===v?w=t[1]:(w=(0,$.jsx)(`span`,{className:`inline-flex h-full w-7 items-center justify-center`,children:(0,$.jsx)(Z,{name:v,className:`size-5`})}),t[0]=v,t[1]=w);let T;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(`span`,{className:`inline-flex h-full w-3 items-center justify-center`,children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`size-2.5`})}),t[2]=T):T=t[2];let E;t[3]!==S||t[4]!==n||t[5]!==r||t[6]!==C||t[7]!==w?(E=(0,$.jsxs)(S,{variant:`ghost`,size:`sm`,className:`app-region-no-drag h-7 w-12 gap-0 self-center rounded-md border border-border/40 px-1 py-0 text-muted-foreground hover:text-foreground`,"aria-label":C,"aria-expanded":r,"aria-haspopup":`menu`,onClick:n,children:[w,T]}),t[3]=S,t[4]=n,t[5]=r,t[6]=C,t[7]=w,t[8]=E):E=t[8];let D;t[9]!==b||t[10]!==E?(D=(0,$.jsx)(b,{asChild:!0,children:E}),t[9]=b,t[10]=E,t[11]=D):D=t[11];let O;t[12]===_?O=t[13]:(O=(0,$.jsx)(ei,{children:_}),t[12]=_,t[13]=O);let k;return t[14]!==y||t[15]!==O||t[16]!==D?(k=(0,$.jsxs)(y,{children:[D,O]}),t[14]=y,t[15]=O,t[16]=D,t[17]=k):k=t[17],k}function Yu(e){return e.isSettingsDialogOpen}var Xu=[{id:`finder`,label:`Finder`,appName:`Finder`},{id:`terminal`,label:`Terminal`,appName:`Terminal`},{id:`iterm2`,label:`iTerm2`,appName:`iTerm`},{id:`ghostty`,label:`Ghostty`,appName:`Ghostty`},{id:`vscode`,label:`VS Code`,appName:`Visual Studio Code`},{id:`vscode-insiders`,label:`VS Code Insiders`,appName:`Visual Studio Code - Insiders`},{id:`intellij`,label:`IntelliJ`,appName:`IntelliJ IDEA`},{id:`visual-studio`,label:`Visual Studio`,appName:`Visual Studio`},{id:`cursor`,label:`Cursor`,appName:`Cursor`},{id:`android-studio`,label:`Android Studio`,appName:`Android Studio`},{id:`pycharm`,label:`PyCharm`,appName:`PyCharm`},{id:`xcode`,label:`Xcode`,appName:`Xcode`},{id:`sublime-text`,label:`Sublime`,appName:`Sublime Text`},{id:`webstorm`,label:`WebStorm`,appName:`WebStorm`},{id:`rider`,label:`Rider`,appName:`Rider`},{id:`zed`,label:`Zed`,appName:`Zed`},{id:`wu`,label:`Wu`,appName:`Wu`},{id:`phpstorm`,label:`PhpStorm`,appName:`PhpStorm`},{id:`eclipse`,label:`Eclipse`,appName:`Eclipse`},{id:`windsurf`,label:`Windsurf`,appName:`Windsurf`},{id:`vscodium`,label:`VSCodium`,appName:`VSCodium`},{id:`rustrover`,label:`RustRover`,appName:`RustRover`},{id:`kiro`,label:`Kiro`,appName:`Kiro`},{id:`antigravity`,label:`Antigravity`,appName:`Antigravity`},{id:`trae`,label:`Trae`,appName:`Trae`}],Zu=`finder`,Qu=new Set([`finder`,`terminal`]),$u=e=>typeof window<`u`&&window.__YURI_PLATFORM__===`win32`&&e.id===`finder`?{...e,label:`Explorer`,appName:`File Explorer`}:e,ed=e=>{if(!e)return null;let t=Xu.find(t=>t.id===e)??null;return t?$u(t):null},td=()=>Xu.filter(e=>Qu.has(e.id)).map(e=>({...$u(e)})),nd=e=>{let t=new Map(e.map(e=>[e.name,e]));return Xu.filter(e=>t.has(e.appName)||Qu.has(e.id)).map(e=>{let n=t.get(e.appName);return{...$u(e),...e.id===`terminal`&&n?.appName&&n.label?{appName:n.appName,label:n.label}:{},iconDataUrl:n?.iconDataUrl??void 0}})},rd=()=>{if(typeof window>`u`)return Zu;let e=window.localStorage.getItem(`openInAppId`);return e&&ed(e)?e:Zu},id=!1,ad=!1,od=!1,sd=0,cd=null,ld=()=>{cd&&=(clearTimeout(cd),null)},ud=ue()((e,t)=>({selectedAppId:rd(),availableApps:td(),hasLoadedApps:!1,isCacheStale:!1,isScanning:!1,initialize:()=>{if(id||typeof window>`u`)return;id=!0;let n=(t,n=!0)=>{if(!Array.isArray(t)||t.length===0){e({availableApps:td(),hasLoadedApps:n});return}e({availableApps:nd(t),hasLoadedApps:!0})},r=async i=>{if(!C()||ad||t().hasLoadedApps&&!i)return;let a=Xu.map(e=>e.appName);ld(),i&&e({hasLoadedApps:!1}),ad=!0,od=!1,e({isScanning:!0});try{let{apps:t,success:o,hasCache:s,isCacheStale:c}=await z(a,i),l=o&&!s&&t.length===0&&sd<3;if(e({isCacheStale:s?c:!1}),n(t,o?!l:!1),o){if(l){let e=[800,1600,3200][sd]??3200;sd+=1,od=!0,cd=setTimeout(()=>{r()},e);return}sd=0,od=!1;return}if(sd<3){let e=[1e3,3e3,7e3][sd]??7e3;sd+=1,od=!0,cd=setTimeout(()=>{r()},e)}}finally{ad=!1,od||e({isScanning:!1})}};r(),window.addEventListener(`yuri:settings-synced`,t=>{let n=t.detail,r=n&&typeof n.openInAppId==`string`&&n.openInAppId.length>0&&ed(n.openInAppId)?n.openInAppId:null;r&&(window.localStorage.setItem(`openInAppId`,r),e({selectedAppId:r}))}),window.addEventListener(`yuri:app-ready`,()=>{r()}),window.addEventListener(`yuri:installed-apps-updated`,t=>{let r=t.detail;Array.isArray(r)&&(sd=3,od=!1,e({isScanning:!1,isCacheStale:!1}),n(r))}),window.__yuriAppReady&&r(),window.setTimeout(()=>{t().hasLoadedApps||r()},5e3)},loadInstalledApps:async n=>{if(id||t().initialize(),!C()||ad||t().hasLoadedApps&&!n)return;let r=Xu.map(e=>e.appName);ld(),n&&e({hasLoadedApps:!1}),ad=!0,od=!1,e({isScanning:!0});try{let{apps:t,hasCache:i,isCacheStale:a}=await z(r,n),o=nd(t);e({availableApps:o.length>0?o:td(),hasLoadedApps:o.length>0,isCacheStale:i?a:!1})}finally{ad=!1,od||e({isScanning:!1})}},selectApp:async t=>{ed(t)&&(e({selectedAppId:t}),typeof window<`u`&&window.localStorage.setItem(`openInAppId`,t),await Ne({openInAppId:t}))}})),dd=(e=p(),t=u())=>{let n=e.startsWith(`host:`)?e.slice(5):null;return{queryKey:[t,`ssh-editor-apps`,n],enabled:C()&&v()&&n!==null,queryFn:async({signal:e})=>{let t=await ee(`desktop_ssh_editor_apps`,{hostId:n});return e.throwIfAborted(),t?{hostId:n,appIds:t.appIds}:null}}},fd=()=>{let e=(0,ju.c)(3),t=(0,Q.useSyncExternalStore)(c,p,pd),n=(0,Q.useSyncExternalStore)(c,u,md),r;return e[0]!==t||e[1]!==n?(r=dd(t,n),e[0]=t,e[1]=n,e[2]=r):r=e[2],yt(r)};function pd(){return``}function md(){return``}var hd=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAXaSURBVFgJ7VddbBRVFP5mdme6dOnu2tZawOAPjfxU+bGQYCRAsvw8qNGEQPTRJ0I0amL0wfjgA/HBR8KLD8YgDxJEUkVFxSYYTSRii6DQQCMGIQqlW7p0u+zMzo/fuTuzO9Nt0Td94CRn7pl7z5zznZ977y5wh/7jDGiz+T979qD5Ujbfd90xlll+stOF1uI40B1+4HhkjnZk9CgLQ9iXp2/BdcbgVc/h0sAgduywudJEMwLY9Of4ugtW5p3CpL7W1jTN88VmjdQYvnDKF1mczkYuNZLeCVg3X8fa9u+nqzUB2HRpdN2pSseRQknPoUL1Jo2ICTrPGcCzdwPdHENcAnicKRqcAk7cpL5J1r0JlAtPYV1XDETM/FtH3m19r+f5by+XjNX/xnmCX3/cCzydi4CKiC7lw+PArhGgoPPFq/6E0+9vwM6d5VBNpuv03cLNfeNTRh9KnJIiV2/PvSngycC5RD+dE5zb3g7s6QESzAZc2l6wuY9SnWIAxv10r81uU85Vt1FvtpEtlc/SMFUkUofeZ2IBta0DWDmXgkfbyTRz1qAYAMczOz3p1elOxYPyEllj421hdELViPO6Kudk3ia3UGe5ABDbvtnJZ52SdYmCZ3stdeexBabFdeAbYopEowtagVUZqFapBrtAGqpiVaFrGgyjZlrmTD5yEqoEJj4iFMuA62i6L3WPZkAiuHgarZ/vbWSBkTzO2rfTR4XOJVJhjfX44MBn+OTocVWbcF5MalxXPeVL6zYonoGo44YOtDI7qHC1lkL5nHnOc+tJRi3K6iygLNGMjt1A1XVV6iUzOvVtAvMlS2I/yBYlRf8MgA6szmXQ1jDfKhSgjft6DRtrkgarAiAw5nI9v2WDSn+Zxfd9DawGxIlPPQUg0A2HGABfEIYlCDU4+q0d8O+jRzHCCFYy+nu4BaeYAoksBCDrPYsXQQ6iitgiSQaS1FHHtMzFil4DpxTl4UhORSn4WOaaiGsbu4iFRkMnYQlEV0oSJQGQ4FyYgSRDjpqPZcCR6EOOWonIEsBqArAIQOMLzw0VXRRERF2VoA6Atk1+MzsASekMJYgaFEeHR4Cr85lNGntYzgKCYd/NSNIDCXr0ZJ2jwTsjSvEMzFQCCVmKHBRahn2DNb4rDRx8pnbXOOIg0JELLMHOF1AUkaRj1V8c2TookkMS83WK9QCVpRwtf5wCykQWRKDyJ44Ytc452QUV6inmN9IDIv/6y2+YLDuqTywBEHxv8rsoxQC4Fpf4cZ2pbJ4/huxXr0EvFmoRCrAIVymLQ3Eid0GJYPsPfISBLwdwi79YQnCqBNS7LQDP5qYSAKEDypOrX4WVWYLsFy+i9cwh6CUmUKIJI2Gq5cSbnLLw849D2Ld3L4olC1u3P0c1ow5Ozgixa3puWChONG1D3eLZUQOglvng+Vp5dBfseesx5/yHyI4cBTL3wsssRGs2g6/ppHijiMLoNSSMNHofy6Nn6SPsAR02nUoTtrDTSrdoi8CTni55rlOsCf1ypaDxlFMNU1epCV5XL6Y6dmOq+BeS48NIlq7Anpjg5dOFbPdDWLQyj/aubnUKSkMKi3NhkUd4kieYtbRbYS0bFAOQKI8NO363z1RJHmamtnlwhGksxV2w/gl29WRtm8kWtWUnRShLnQvXgDOXmLg2HzlvbDiyHD8Y517YP2i4FtueFPbB9FFqKcyobk4A5y7zquUFa7IXojyHoeXmAFcY755vaI6A56Xsofm/7+cmblBTpOldQ5vs3PJDVS+RVSAaus2SpJTO80t4NTNSOQfCDrtFkBevA0ME6HGvPdDpFlekzm7rf3nFQNRQEwBZTL9warObWfx21Uv1+fx1ERqVNampGoOHpF1tsdp07RnoGMxK1vT97rbK4IP6+Tc+fWXVsahaYGL6VO09d//GXHXr7jVeqmuppqU6ff4x0RO6lqRxgxHJpWKSlcw5eWfjq5rq/CdhaL5l6JWxjDc6bP7w5sn+/uMs2B36H2bgb6v9raK0+o9IAAAAAElFTkSuQmCC`,gd=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAQzSURBVFgJ7VZNbBNHFH67Xv9RxwnBDqlUoQglcZK6qSIEJIQWAYJQoVY9IE5RTzn20FMvqdpDesq9B24+NdwthAJCkZChJg1JSOXYQIwQKQIaBdtENbs73t2+N8miGWOcpFHUHniyd97OvJ9v3nv7ZgDe038cAeVd/jOZjC94sKdfU+Bj24G9igpexwYPyiu2bauKqqqirkOTqmrjnIOyFsoyUKDocSCj/7mU7ujoMER5l68JYOFZ4YSiwPjd9O0jjx7ch1KhAJZVAcdx0LxDv3XetYKjggr4I4bzHo8G4aYmONjZBYf6+2dUzfd9PNowJajUZmef/PX5zcWl0rmvvnbQHrra+f/M+S+dqYXs2t3Hz09Ve5UicCmZ3NPb1Zv66btv+65dSULA64WGxkbw+Xx8V9XK9d4pWowxeFUqgW6acHroC/j5l0sLD/PZY98MDf3t6mouQ+On3X1H7/2e7rtOztHpgbY2+CAUgperq+D3+7cNgtLSEA7D0+VluDF5FS7cSff2HT56DF1dd/3KhQTWJ/lclsc8jIrk9IfRURgZGQEvRqNSWa8D2t1W/liXXK8Ro0i0lF0ExaPEXec0SgAqhrm3VCzwdS9GQNd1GBsbg0AgAIlEAlpbW7EYLVF/U56AagieiGwbuhERlSQApmEE8c/XKXxU0fF4HNowFfPz81Aul7edBjLGbeHITANsZga4g42HVAM2Y74KM/kSIQ/izgcHB2FiYgJmZmZ4MZpYULRG5PF4+Bx/2cLDxuhhYUqFLwGoWCaQEBGhNjAa4+Pj/J3SQA6pHpqbm/kcNitIJpOgaZIZvlbrQbZNJvcjSZOZDKhwRKLic4l2Pjc3B8FgkE+trKxAVUN0RWuOZNtCHyJJACj/bgREIZcnA9PT029SQM63unuywSOwUWOuTQmAhfmnlluPxIjUk6u1RrbJh0jyV0Ap2OZnJhrbjOcRqEqBBMDCAtltAORDJAkAVj2mWS5CUXinPDUx+oxFkgBYjO0qANu2wKoqQgkAfgW7C4AiYMmfoQSgwpjj7GYRUh/Q66SAmdisNxql227FfP1bXrRlVExdtCNHwDRLdPkgwmi8OUREhe3y1NLJFpEfbWMNvBRtSI2o+KqYi+zbx4NQwptMCO8E1HjEHYjKm/HknG5FZIsCG4lEoLS2lhP1JAB3bt1KH//s+GJPd3dPJpvlN5kwXiYIhHukisr1eAItXsm6YzGItrTcn5+dvS3qSQBSqVQhFouNnj039CsaCC7mcqDjgbNT6op1AtrU8Wo3Ojk5KaVAOptdR8PDwxf3t7SMvXjxvJNOPP31a35Krt8CXKl3j2SUDip/IAjRaBRaP9z/cHW18GMikbhcrVUTAAm1t7d/NDAwcDIUCvVqmtqkyLe3ajtvvTtg4x3SLpbLa3+kUr9N5fP55beE3k/8HyLwDx2/HIx7q3WfAAAAAElFTkSuQmCC`,_d=e=>({...e,fallbackIconDataUrl:e.id===`finder`&&window.__YURI_PLATFORM__!==`win32`?hd:e.id===`terminal`&&e.label===`Terminal`?gd:void 0}),vd=e=>{let t=(0,ju.c)(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:i}=e,[a,o]=Q.useState(!1),s;t[0]===n?s=t[1]:(s=n.trim().slice(0,1).toUpperCase()||`?`,t[0]=n,t[1]=s);let c=s,l=r||i;if(l&&!a){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>o(!0),t[2]=e):e=t[2];let n;return t[3]===l?n=t[4]:(n=(0,$.jsx)(`img`,{src:l,alt:``,className:`h-4 w-4 rounded-sm`,onError:e}),t[3]=l,t[4]=n),n}let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=Y(`h-4 w-4 rounded-sm flex items-center justify-center`,`bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground`),t[5]=u):u=t[5];let d;return t[6]===c?d=t[7]:(d=(0,$.jsx)(`span`,{className:u,children:c}),t[6]=c,t[7]=d),d},yd=({directory:e,className:t})=>{let{t:n}=Nr(),r=ud(e=>e.selectedAppId),i=ud(e=>e.availableApps),a=ud(e=>e.isCacheStale),o=ud(e=>e.isScanning),s=ud(e=>e.initialize),c=ud(e=>e.loadInstalledApps),l=ud(e=>e.selectApp),{data:u}=fd(),d=Q.useMemo(()=>u?i.filter(e=>u.appIds.includes(e.id)):i,[i,u]);Q.useEffect(()=>{s()},[s]);let f=C()&&x(),p=Q.useMemo(()=>{let e=d.find(e=>e.id===r)??d.find(e=>e.id===`finder`)??d[0];return e?_d(e):null},[d,r]);if(!f&&!u||!e)return null;let m=async t=>{try{let r=await w(e,t.id,t.appName,u?.hostId);!r&&!u?await S(e,t.appName):r||X.error(n(`filesView.toast.openInAppFailed`,{app:t.label}))}catch(e){X.error(n(String(e).includes(`SSH_EDITOR_CONFIG_REQUIRED`)?`openInApp.errors.sshConfigRequired`:`filesView.toast.openInAppFailed`,{app:t.label}))}},h=async e=>{await l(e.id),await m(e)},g=async()=>{await dr(e)};return(0,$.jsxs)(`div`,{className:Y(`app-region-no-drag inline-flex h-7 w-12 items-center self-center overflow-hidden rounded-md border border-border/40 px-1`,`hover:bg-interactive-hover transition-colors`,t),children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>void(p?m(p):g()),className:Y(`inline-flex h-full w-7 items-center justify-center typography-ui-label font-medium`,`text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary`,o&&`animate-pulse`),"aria-label":p?n(`openInApp.actions.openInAria`,{app:p.label}):n(`openInApp.actions.copyPath`),children:p?(0,$.jsx)(vd,{label:p.label,iconDataUrl:p.iconDataUrl,fallbackIconDataUrl:p.fallbackIconDataUrl}):(0,$.jsx)(Z,{name:`file-copy`,className:`h-4 w-4`})}),(0,$.jsxs)(Ci,{children:[(0,$.jsx)(vi,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`inline-flex h-full w-3 items-center justify-center text-muted-foreground`,`hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary`),"aria-label":n(`openInApp.actions.chooseAppAria`),children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`size-2.5`})})}),(0,$.jsxs)(bi,{align:`end`,className:`w-56 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>void g(),children:[(0,$.jsx)(Z,{name:`file-copy`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:n(`openInApp.actions.copyPath`)})]}),(0,$.jsx)(Si,{}),d.map(e=>{let t=_d(e);return(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>void h(e),children:[(0,$.jsx)(vd,{label:e.label,iconDataUrl:e.iconDataUrl,fallbackIconDataUrl:t.fallbackIconDataUrl}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e.label}),p?.id===e.id?(0,$.jsx)(Z,{name:`check`,className:`ml-auto h-4 w-4 text-primary`}):null]},e.id)}),a?(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>void c(!0),children:[(0,$.jsx)(Z,{name:`refresh`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:n(`openInApp.actions.refreshApps`)})]}):null]})]})]})},bd=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],xd=[`dev`,`start`,`preview`,`serve`];async function Sd(e,t,n,r){if(!e)return null;let i=Td(t);if(i)return{command:i.command,label:i.name||`Start Preview`,actionId:i.id};if(n){let t=Ed(n);if(t){let n=await Dd(e,r);return{command:`${n===`npm`?`npm run`:n===`yarn`?`yarn`:n===`pnpm`?`pnpm`:n===`bun`?`bun run --shell=bun`:`npm run`} ${t}`,label:`Start (${t})`}}}if(await Cd(e,r)){let e=await wd(r),t=typeof e==`number`&&Number.isFinite(e)&&e>0?e:8e3;return{command:`python3 -m http.server ${t}`,label:`Static preview`,previewUrlHint:`http://127.0.0.1:${t}/`}}return null}async function Cd(e,t){let n=await Od(`${e}/index.html`,e,t);return typeof n==`string`&&n.trim().length>0}async function wd(e){if(e){let t=await xt(e).json(`/api/system/free-port`,{cache:`no-store`});if(!Number.isInteger(t.port)||t.port<1||t.port>65535)throw Error(`Invalid Host preview port`);return t.port}try{let e=await g(`/api/system/free-port`,{cache:`no-store`});if(!e.ok)return null;let t=await e.json().catch(()=>null),n=typeof t?.port==`number`?t.port:null;return n&&Number.isFinite(n)?n:null}catch{return null}}function Td(e){for(let t of e){let e=`${t.name} ${t.command}`.toLowerCase();if(xd.some(t=>e.includes(t)))return t}return null}function Ed(e){for(let{pattern:t}of bd)for(let n of Object.keys(e))if(t.test(n))return n;return null}async function Dd(e,t){let n=await Od(`${e}/package.json`,e,t);if(n)try{let e=JSON.parse(n),t=typeof e.packageManager==`string`?e.packageManager.toLowerCase():``;if(t.startsWith(`bun@`))return`bun`;if(t.startsWith(`pnpm@`))return`pnpm`;if(t.startsWith(`yarn@`))return`yarn`;if(t.startsWith(`npm@`))return`npm`}catch{}for(let[n,r]of[[`bun.lock`,`bun`],[`bun.lockb`,`bun`],[`pnpm-lock.yaml`,`pnpm`],[`yarn.lock`,`yarn`],[`package-lock.json`,`npm`]]){let i=await Od(`${e}/${n}`,e,t);if(typeof i==`string`&&i.trim().length>0)return r}return`npm`}async function Od(e,t,n){if(n){let r=xt(n),i=await r.fetch(`/api/fs/read`,{query:{path:e,directory:t,optional:`true`},cache:`no-store`});if(i.status===404)return null;if(!i.ok)throw Error(`Failed to read Host preview file (${i.status})`);let a=await i.text();return r.assertCurrent(),i.headers.get(`x-yuri-file-exists`)===`false`?null:a}if(t?.trim())try{let n=new URLSearchParams({path:e,directory:t,optional:`true`}),r=await g(`/api/fs/read?${n.toString()}`,{cache:`no-store`});if(r.ok)return r.text()}catch{}let r=U()?.files;if(r?.readFile)try{let t=await r.readFile(e,{optional:!0});return typeof t?.content==`string`?t.content:null}catch{return null}try{let t=await g(`/api/fs/read?path=${encodeURIComponent(e)}&optional=true`,{cache:`no-store`});return t.ok?t.text():null}catch{return null}}async function kd(e,t){try{let n=await Od(`${e}/package.json`,e,t);if(n==null)return null;let r=JSON.parse(n).scripts;return r&&typeof r==`object`&&!Array.isArray(r)?r:null}catch(e){if(t)throw e;return null}}var Ad=e=>new Promise(t=>{window.setTimeout(t,e)}),jd=RegExp(`\x1B\\[[0-9;?]*[ -/]*[@-~]`,`g`),Md=/https?:\/\/[^\s<>'"`]+/gi,Nd=`__yuri_auto_discover_preview__`,Pd=15e3,Fd=e=>{let t=``;for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);r>=0&&r<=8||r===11||r===12||r>=14&&r<=31||r===127||(t+=e[n])}return t},Id=e=>{let t=(e||``).trim();if(!t)return null;let n=/^https?:\/\//i.test(t)?t:`http://${t}`;try{let e=new URL(n);return e.protocol!==`http:`&&e.protocol!==`https:`?null:e.toString()}catch{return null}},Ld=e=>{let t=e.replace(jd,``).match(Md);if(!t||t.length===0)return null;let n=t.map(e=>e.replace(/[),.;]+$/,``)).filter(Boolean);if(n.length===0)return null;let r=[];for(let e of n)try{let t=new URL(e);t.port&&t.port.length>0&&r.push({raw:e,parsed:t})}catch{}if(r.length>0){let e=e=>{let{parsed:t}=e,n=t.hostname.toLowerCase(),r=n===`localhost`||n===`127.0.0.1`||n===`0.0.0.0`||n===`::1`,i=t.pathname||`/`,a=i.split(`/`).filter(Boolean).length,o=i===`/`||i===``,s=!!(t.search||t.hash),c=0;return r&&(c+=50),o&&(c+=30),c-=Math.min(a*5,20),s&&(c-=10),c};return r.sort((t,n)=>e(n)-e(t)),r[0]?.parsed.origin??r[0]?.raw??null}return n[0]??null},Rd=e=>{let t=(0,ju.c)(19),n=!!e.projectRef?.hostId,{registry:r}=Dr(n&&!e.scope),i=e.projectRef?.hostId,a;t[0]!==i||t[1]!==r?(a={subscribe:e=>r&&i?r.subscribeHost(i,e):Bd,snapshot:()=>r&&i?r.getHost(i):void 0},t[0]=i,t[1]=r,t[2]=a):a=t[2];let o=a;Q.useSyncExternalStore(o.subscribe,o.snapshot,o.snapshot);let s=e.directory||e.projectRef?.path||``,c;t[3]!==s||t[4]!==e.projectRef||t[5]!==e.scope||t[6]!==r||t[7]!==n?(c=e.scope?r?.hubId===e.scope.location.hubId?r.resolve(e.scope.location):e.scope:n&&r&&r.hubId===e.projectRef?.hubId?r.resolve({hubId:r.hubId,hostId:e.projectRef.hostId,directory:s}):void 0,t[3]=s,t[4]=e.projectRef,t[5]=e.scope,t[6]=r,t[7]=n,t[8]=c):c=t[8];let l=c,u;t[9]!==s||t[10]!==l||t[11]!==e.projectRef?.hostId||t[12]!==e.projectRef?.hubId||t[13]!==n?(u=l?`${l.key}:${l.connectionGeneration}`:n?JSON.stringify([e.projectRef?.hubId,e.projectRef?.hostId,s]):s,t[9]=s,t[10]=l,t[11]=e.projectRef?.hostId,t[12]=e.projectRef?.hubId,t[13]=n,t[14]=u):u=t[14];let d=u,f;return t[15]!==l||t[16]!==d||t[17]!==e?(f=(0,$.jsx)(zd,{...e,scope:l},d),t[15]=l,t[16]=d,t[17]=e,t[18]=f):f=t[18],f},zd=({projectRef:e,directory:t,className:n,compact:r=!1,allowMobile:i=!1,scope:a})=>{let{t:o}=Nr(),{terminal:s,runtime:c}=wt(),l=Q.useRef(null),u=Q.useRef(!0),d=()=>{if(!u.current)throw new DOMException(`Project action scope superseded`,`AbortError`);if(e?.hostId&&(!a||a.location.hostId!==e.hostId||a.location.hubId!==e.hubId)||a&&a.location.directory!==(t||e?.path||``))throw Error(o(`remoteProjects.host-unavailable`));a&&xt(a).assertCurrent()},f=K(()=>{if(d(),!a)throw Error(o(`remoteProjects.host-unavailable`));return l.current??=Gt(a)}),p=Q.useMemo(()=>a||e?.hostId?{createSession:e=>f().createTerminalSession(e),sendInput:(e,t)=>f().sendTerminalInput(e,t),close:e=>f().closeTerminal(e)}:s,[a,e?.hostId,s,f]),{isMobile:m}=fi(),h=Q.useMemo(()=>C(),[]),g=vu(e=>e.instances),_=vu(e=>e.load),v=q(e=>e.setBottomTerminalOpen),y=q(e=>e.setActiveMainTab),b=q(e=>e.setSettingsPage),x=q(e=>e.setSettingsDialogOpen),S=q(e=>e.setSettingsProjectsSelectedId),w=q(e=>e.openContextPreview),T=dc(e=>e.sessions),E=dc(e=>e.ensureDirectory),D=dc(e=>e.setTabLabel),O=dc(e=>e.setTabIconKey),k=dc(e=>e.setActiveTab),A=dc(e=>e.setConnecting),j=dc(e=>e.setTabSessionId),M=dc(e=>e.setTabPreviewUrl),N=dc(e=>e.projectActionRuns),P=dc(e=>e.setProjectActionRun),F=dc(e=>e.updateProjectActionRunStatus),I=dc(e=>e.removeProjectActionRun),[L,R]=Q.useState([]),[z,ee]=Q.useState(null),[B,te]=Q.useState(!1),re=Q.useRef({}),ie=Q.useRef({}),ae=Q.useRef({}),H=Q.useRef({}),U=Q.useRef(0),oe=Q.useRef(new Set),W=e?.id??null,se=e?.path??``,ce=Q.useMemo(()=>W?{id:W,path:se,hostId:e?.hostId,hubId:e?.hubId}:null,[W,se,e?.hostId,e?.hubId]);Q.useEffect(()=>{u.current=!0;let e=ae.current,t=H.current;return()=>{u.current=!1,U.current+=1,Object.values(e).forEach(e=>e()),Object.values(t).forEach(e=>window.clearTimeout(e)),l.current?.dispose(),l.current=null}},[a]),Q.useEffect(()=>{!h||a||e?.hostId||_().catch(()=>void 0)},[h,_,a,e?.hostId]);let le=K(async e=>{await Ut(e)}),ue=K(async()=>{if(!ce)return;let e=U.current+1;U.current=e,te(!0);try{d();let t=await Gn(ce,a);if(U.current!==e)return;let n=t.actions;R(n),ee(e=>e===Nd||e&&n.some(t=>t.id===e)?e:null)}catch{if(U.current!==e)return}finally{U.current===e&&te(!1)}}),de=t||ce?.path||``,fe=Q.useMemo(()=>a?V(ne({...a.location,directory:de})):ce?.hostId?ce.hubId?V(ne({hubId:ce.hubId,hostId:ce.hostId,directory:de})):``:wu(de),[de,ce,a]),pe=Q.useMemo(()=>z?L.find(e=>e.id===z)??null:null,[L,z]),me=Q.useMemo(()=>({id:Nd,name:o(`projectActions.actions.autoDiscover`),command:``,icon:`search`,autoOpenUrl:!0}),[o]),he=!m,ge=Q.useMemo(()=>he?[me,...L]:L,[L,me,he]);Q.useEffect(()=>{ue()},[ue,ce,a]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail;W&&(t?.projectId&&t.projectId!==W||ue())};return window.addEventListener(Tu,e),()=>{window.removeEventListener(Tu,e)}},[ue,W]),Q.useEffect(()=>{z&&(z===Nd&&he||L.some(e=>e.id===z)||ee(null))},[L,he,z]),Q.useEffect(()=>{for(let[e,t]of Object.entries(N)){if(t.directory!==fe)continue;let n=T.get(t.directory)?.tabs.find(e=>e.id===t.tabId);(!n||n.terminalSessionId!==t.sessionId)&&I(e)}},[fe,N,I,T]),Q.useEffect(()=>{for(let[e,t]of Object.entries(N)){if(t.directory!==fe)continue;let n=ie.current[e]??{lastSeenChunkId:null,openedUrl:!1,tail:``,openInPreview:!1};ie.current[e]=n;let r=ge.find(e=>e.id===t.actionId);if(!r)continue;let i=T.get(t.directory)?.tabs.find(e=>e.id===t.tabId);if(!i||!Array.isArray(i.bufferChunks)||i.bufferChunks.length===0)continue;let s=i.bufferChunks.filter(e=>n.lastSeenChunkId===null||e.id>n.lastSeenChunkId);if(s.length===0)continue;let c=s.map(e=>e.data).join(``),l=`${n.tail}${c}`,u=!n.openedUrl&&r.autoOpenUrl===!0?Ld(l):null;if(n.lastSeenChunkId=s[s.length-1]?.id??n.lastSeenChunkId,n.tail=l.slice(-512),u)if(n.openedUrl=!0,n.openInPreview){let t=N[e];t&&(M(t.directory,t.tabId,u,{locked:!1,autoOpened:!1}),t.status===`waiting-for-preview`&&F(e,`running`),window.clearTimeout(H.current[e]),delete H.current[e],w(t.directory,u))}else a||ce?.hostId?(M(t.directory,t.tabId,u,{locked:!1,autoOpened:!0}),w(t.directory,u)):(le(u),X.success(o(`projectActions.toast.openedUrlFromOutput`)));ie.current[e]=n}for(let e of Object.keys(ie.current))N[e]||(delete ie.current[e],window.clearTimeout(H.current[e]),delete H.current[e])},[fe,a,ce?.hostId,ge,w,le,N,M,o,T,F]);let _e=K(async(e,t={})=>{if(!fe)throw Error(o(`projectActions.error.noActiveDirectory`));let n=xu(fe,e.id);E(fe);let r=dc.getState(),i=r.getDirectoryState(fe),a=re.current[n]||null,s=a?!!i?.tabs.some(e=>e.id===a):!1;(!a||!s)&&(a=r.createTab(fe),re.current[n]=a),D(fe,a,`Action: ${e.name}`),O(fe,a,e.icon||`play`),t.revealTerminal!==!1&&(k(fe,a),v(!0),y(`terminal`));let c=dc.getState().getDirectoryState(fe)?.tabs.find(e=>e.id===a);return{key:n,tabId:a,sessionId:c?.terminalSessionId??null}}),ve=K(async e=>{if(c.isVSCode||!i&&m)return;if(!fe){X.error(o(`projectActions.error.noActiveDirectoryForAction`));return}let t=xu(fe,e.id),n=N[t];if(!(n&&n.status===`running`)&&!oe.current.has(t)){oe.current.add(t);try{d();let t=e.id===Nd?await(async()=>{let[e,t]=await Promise.all([Gn({...ce,id:ce?.id??``,path:de},a),kd(de,a)]),n=await Sd(de,e.actions,t,a);if(!n)throw Error(o(`contextPanel.preview.noDevServer`));return{id:Nd,name:o(`projectActions.actions.autoDiscover`),command:n.command,icon:`search`,autoOpenUrl:!0,openUrl:n.previewUrlHint||``}})():e,n=t.autoOpenUrl===!0&&(t.openUrl||``).trim().length>0;d();let{key:r,tabId:i,sessionId:s}=await _e(t,{revealTerminal:!n&&e.id!==Nd}),c=s,l=!1;if(!c){A(fe,i,!0);try{let e=await p.createSession({cwd:de});d(),c=e.sessionId,l=!0,j(fe,i,c)}finally{A(fe,i,!1)}}if(!c)throw Error(o(`projectActions.error.failedToCreateTerminalSession`));l&&await Ad(350),d(),t.id===Nd&&(ae.current[r]?.(),A(fe,i,!0),ae.current[r]=(a?f().connectTerminalStream:Wt)(c,e=>{if(u.current){try{d()}catch{return}e.type===`data`&&typeof e.data==`string`&&e.data.length>0&&dc.getState().appendToBuffer(fe,i,e.data),e.type===`exit`&&(dc.getState().setTabLifecycle(fe,i,`exited`),dc.getState().setConnecting(fe,i,!1),dc.getState().removeProjectActionRun(r),delete ie.current[r],ae.current[r]?.(),delete ae.current[r],window.clearTimeout(H.current[r]),delete H.current[r])}},()=>{u.current&&dc.getState().setConnecting(fe,i,!1)},{maxRetries:60,initialRetryDelay:250,maxRetryDelay:2e3,connectionTimeout:5e3}));let m=t.autoOpenUrl===!0&&!a&&h&&(t.desktopOpenSshForward||``).trim().length>0,_=t.autoOpenUrl?Id(t.openUrl):null,v=t.autoOpenUrl&&h&&!a?Su(t.desktopOpenSshForward,g):null;P({key:r,directory:fe,actionId:t.id,tabId:i,sessionId:c,status:t.id===Nd&&!_?`waiting-for-preview`:`running`}),window.clearTimeout(H.current[r]),delete H.current[r],t.id===Nd&&!_&&(H.current[r]=window.setTimeout(()=>{dc.getState().updateProjectActionRunStatus(r,`running`),delete H.current[r]},Pd)),v?(M(fe,i,null,{locked:!0}),le(v),X.success(o(`projectActions.toast.openedForwardedUrl`))):_?(M(fe,i,_,{locked:!0,autoOpened:!0}),w(fe,_),X.success(o(`projectActions.toast.openedActionUrl`))):n?(M(fe,i,null,{locked:!0}),X.error(o(`projectActions.error.invalidCustomUrlFormat`))):m?(M(fe,i,null,{locked:!0}),X.error(o(`projectActions.error.selectedDesktopSshForwardUnavailable`))):M(fe,i,null,{locked:!1,autoOpened:!1}),ie.current[r]={lastSeenChunkId:null,openedUrl:!!v||!!_||n,tail:``,openInPreview:t.id===Nd};let y=Fd(t.command.trim().replace(/\r\n|\r/g,`
|
|
3
|
-
`));d(),await p.sendInput(c,`${y}\r`)}catch(e){I(t),delete ie.current[t],ae.current[t]?.(),delete ae.current[t],window.clearTimeout(H.current[t]),delete H.current[t],X.error(e instanceof Error?e.message:o(`projectActions.error.failedToRunAction`))}finally{oe.current.delete(t)}}}),ye=K(async e=>{let t=xu(fe,e.id),n=N[t];if(n){F(t,`stopping`);try{await p.sendInput(n.sessionId,``)}catch(e){if(a||ce?.hostId){F(t,`running`),X.error(e instanceof Error?e.message:o(`projectActions.error.failedToRunAction`));return}}if(await new Promise(e=>{window.setTimeout(e,1e3)}),dc.getState().getDirectoryState(n.directory)?.tabs.find(e=>e.id===n.tabId)?.terminalSessionId===n.sessionId)if(a||ce?.hostId){try{d(),await p.close(n.sessionId)}catch(e){F(t,`running`),X.error(e instanceof Error?e.message:o(`projectActions.error.failedToRunAction`));return}j(n.directory,n.tabId,null)}else{if(typeof p.forceKill==`function`)try{await p.forceKill({sessionId:n.sessionId})}catch{}else try{await p.close(n.sessionId)}catch{}j(n.directory,n.tabId,null)}I(t),delete ie.current[t],ae.current[t]?.(),delete ae.current[t],window.clearTimeout(H.current[t]),delete H.current[t]}}),be=K(()=>{let e=pe??ge[0];if(!e)return;let t=xu(fe,e.id),n=N[t];if(n?.status!==`stopping`){if(n){ye(e);return}ve(e)}}),xe=K((e,t=!1)=>{if(ee(e.id),!t){ve(e);return}let n=xu(fe,e.id),r=N[n];if(r?.status!==`stopping`){if(r){ye(e);return}ve(e)}}),Se=K(()=>{if(ce?.id){if(a||ce.hostId){X.info(o(`remoteProjects.configurationReadOnly`)),b(`remoteInstances`),x(!0);return}S(ce.id),b(`projects`),x(!0)}});if(c.isVSCode||!i&&m||!ce||!fe)return null;let Ce=pe??ge[0]??null;if(!Ce)return null;let we=Ce.icon||`play`,Te=Ce.id===Nd?`search`:Cu[we]||`play`,Ee=N[xu(fe,Ce.id)],De=Ee?.status===`stopping`,Oe=Ee?.status===`waiting-for-preview`,ke=Ee?T.get(Ee.directory)?.tabs.find(e=>e.id===Ee.tabId)?.previewUrl??null:null,Ae=!!(Ee&&ke),je=()=>{!Ee||!ke||w(Ee.directory,ke)};return r?(0,$.jsxs)(`div`,{className:`inline-flex items-center`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:B||De,className:Y(`app-region-no-drag inline-flex h-9 w-9 items-center justify-center rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] p-2`,`typography-ui-label font-medium text-muted-foreground hover:bg-interactive-hover hover:text-foreground transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,`disabled:cursor-not-allowed`,n),onClick:be,"aria-label":o(Ee?`projectActions.actions.stopNamedAria`:`projectActions.actions.runNamedAria`,{name:Ce.name}),children:De||Oe?(0,$.jsx)(Z,{name:`loader-4`,className:`h-5 w-5 animate-spin text-[var(--status-warning)]`}):Ee?(0,$.jsx)(Z,{name:`stop`,className:`h-5 w-5 text-[var(--status-warning)]`}):(0,$.jsx)(Z,{name:Te,className:`h-5 w-5`})}),Ae?(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`app-region-no-drag -ml-1 inline-flex h-9 w-7 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":o(`projectActions.actions.openPreview`),onClick:je,children:(0,$.jsx)(Z,{name:`global`,className:`h-4 w-4`})})}),(0,$.jsx)(ei,{sideOffset:6,children:o(`projectActions.actions.openPreview`)})]}):null,(0,$.jsxs)(Ci,{children:[(0,$.jsx)(vi,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`app-region-no-drag -ml-1 inline-flex h-9 w-5 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":o(`projectActions.actions.chooseActionAria`),children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-3.5 w-3.5`})})}),(0,$.jsxs)(bi,{align:`end`,className:`w-52 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:Se,children:[(0,$.jsx)(Z,{name:`add`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`projectActions.actions.addNewAction`)})]}),(0,$.jsx)(Si,{}),ge.map(e=>{let t=e.icon||`play`,n=e.id===Nd?`search`:Cu[t]||`play`,r=xu(fe,e.id),i=N[r],a=!!i,o=i?.status===`stopping`;return(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>{xe(e,!0)},children:[(0,$.jsx)(Z,{name:n,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:e.name}),o||i?.status===`waiting-for-preview`?(0,$.jsx)(Z,{name:`loader-4`,className:`ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]`}):a?(0,$.jsx)(Z,{name:`stop`,className:`ml-auto h-4 w-4 text-[var(--status-warning)]`}):null]},e.id)})]})]})]}):(0,$.jsxs)(`div`,{className:Y(`app-region-no-drag inline-flex shrink-0 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]`,`bg-[var(--surface-elevated)] overflow-hidden`,`border border-border/60`,r?`h-9`:`h-7`,n),children:[(0,$.jsx)(`button`,{type:`button`,onClick:be,disabled:B||De,className:Y(`inline-flex h-full items-center justify-center typography-ui-label font-medium text-foreground hover:bg-interactive-hover`,r?`w-9 px-0`:`px-2.5`,`transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed`),"aria-label":o(Ee?`projectActions.actions.stopNamedAria`:`projectActions.actions.runNamedAria`,{name:Ce.name}),children:(0,$.jsx)(`span`,{className:`inline-flex h-4 w-4 shrink-0 items-center justify-center`,children:De||Oe?(0,$.jsx)(Z,{name:`loader-4`,className:`h-4 w-4 animate-spin text-[var(--status-warning)]`}):Ee?(0,$.jsx)(Z,{name:`stop`,className:`h-4 w-4 text-[var(--status-warning)]`}):(0,$.jsx)(Z,{name:Te,className:`h-4 w-4`})})}),Ae?(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:je,className:Y(r?`inline-flex h-full w-8 items-center justify-center`:`inline-flex h-full w-7 items-center justify-center`,`border-l border-[var(--interactive-border)] text-foreground`,`hover:bg-interactive-hover transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),"aria-label":o(`projectActions.actions.openPreview`),children:(0,$.jsx)(Z,{name:`global`,className:`h-4 w-4`})})}),(0,$.jsx)(ei,{sideOffset:6,children:o(`projectActions.actions.openPreview`)})]}):null,(0,$.jsxs)(Ci,{children:[(0,$.jsx)(vi,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(r?`inline-flex h-full w-8 items-center justify-center`:`inline-flex h-full w-7 items-center justify-center`,`border-l border-[var(--interactive-border)] text-muted-foreground`,`hover:bg-interactive-hover hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),"aria-label":o(`projectActions.actions.chooseActionAria`),children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-4 w-4`})})}),(0,$.jsxs)(bi,{align:`start`,className:`w-52 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:Se,children:[(0,$.jsx)(Z,{name:`add`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`projectActions.actions.addNewAction`)})]}),(0,$.jsx)(Si,{}),ge.map(e=>{let t=e.icon||`play`,n=e.id===Nd?`search`:Cu[t]||`play`,r=xu(fe,e.id),i=N[r],a=!!i,o=i?.status===`stopping`;return(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>{xe(e,!0)},children:[(0,$.jsx)(Z,{name:n,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:e.name}),o||i?.status===`waiting-for-preview`?(0,$.jsx)(Z,{name:`loader-4`,className:`ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]`}):a?(0,$.jsx)(Z,{name:`stop`,className:`ml-auto h-4 w-4 text-[var(--status-warning)]`}):null]},e.id)})]})]})]})};function Bd(){}function Vd(e){return e.isOpen&&e.activeTab===e.targetTab?{open:!1,tab:e.activeTab}:{open:!0,tab:e.targetTab}}var Hd=`app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50 hover:bg-interactive-hover transition-colors`,Ud=`app-region-no-drag inline-flex h-9 w-9 items-center justify-center gap-2 p-2 rounded-md typography-ui-label font-medium text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50 hover:text-foreground hover:bg-interactive-hover transition-colors`,Wd=Q.memo(function(e){let t=(0,ju.c)(17),{visible:n,title:r,ariaLabel:i,onClick:a,className:o,Icon:s,iconClassName:c,pressed:l}=e,u=n===void 0||n,d=l!==void 0&&l;if(!u)return null;let f=o??Hd,p=d&&`bg-interactive-selection text-interactive-selection-foreground`,m;t[0]!==f||t[1]!==p?(m=Y(f,p),t[0]=f,t[1]=p,t[2]=m):m=t[2];let h=c??`h-[18px] w-[18px]`,g;t[3]!==s||t[4]!==h?(g=(0,$.jsx)(Z,{name:s,className:h}),t[3]=s,t[4]=h,t[5]=g):g=t[5];let _;t[6]!==i||t[7]!==a||t[8]!==d||t[9]!==m||t[10]!==g?(_=(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:a,"aria-label":i,"aria-pressed":d,className:m,children:g})}),t[6]=i,t[7]=a,t[8]=d,t[9]=m,t[10]=g,t[11]=_):_=t[11];let v;t[12]===r?v=t[13]:(v=(0,$.jsx)(ei,{children:(0,$.jsx)(`p`,{children:r})}),t[12]=r,t[13]=v);let y;return t[14]!==_||t[15]!==v?(y=(0,$.jsxs)(ni,{children:[_,v]}),t[14]=_,t[15]=v,t[16]=y):y=t[16],y}),Gd=Q.memo(function(e){let t=(0,ju.c)(42),{isMobile:n,githubAuthStatus:r,githubAccounts:i,githubAvatarUrl:a,githubLogin:o,isSwitchingGitHubAccount:s,handleGitHubAccountSwitch:c}=e,{t:l}=Nr();if(!r?.connected||n)return null;if(i.length>1){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=Y(Hd,`h-6 w-6 overflow-hidden rounded-full border border-border/60 bg-muted/80 p-0`),t[0]=e):e=t[0];let n;t[1]!==o||t[2]!==l?(n=o?l(`header.github.connectedWithLogin`,{login:o}):l(`header.github.connected`),t[1]=o,t[2]=l,t[3]=n):n=t[3];let r;t[4]!==a||t[5]!==o||t[6]!==l?(r=a?(0,$.jsx)(`img`,{src:a,alt:o?l(`header.github.avatarWithLogin`,{login:o}):l(`header.github.avatar`),className:`h-full w-full object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(Z,{name:`github-fill`,className:`h-3.5 w-3.5 text-foreground`}),t[4]=a,t[5]=o,t[6]=l,t[7]=r):r=t[7];let u;t[8]!==s||t[9]!==n||t[10]!==r?(u=(0,$.jsx)(vi,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:e,title:n,disabled:s,children:r})}),t[8]=s,t[9]=n,t[10]=r,t[11]=u):u=t[11];let d;t[12]===l?d=t[13]:(d=l(`header.github.accountsTitle`),t[12]=l,t[13]=d);let f;t[14]===d?f=t[15]:(f=(0,$.jsx)(yi,{className:`typography-ui-header font-semibold text-foreground`,children:d}),t[14]=d,t[15]=f);let p;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(Si,{}),t[16]=p):p=t[16];let m;if(t[17]!==i||t[18]!==c||t[19]!==s||t[20]!==l){let e;t[22]!==c||t[23]!==s||t[24]!==l?(e=e=>{let t=e.user,n=!!e.current,r=e.source===`gh-cli`?l(`header.github.accountSource.cli`):l(`header.github.accountSource.oauth`);return(0,$.jsxs)(xi,{className:`gap-2`,disabled:s,onSelect:()=>{n||c(e.id)},children:[t?.avatarUrl?(0,$.jsx)(`img`,{src:t.avatarUrl,alt:t.login?l(`header.github.avatarWithLogin`,{login:t.login}):l(`header.github.avatar`),className:`h-6 w-6 rounded-full border border-border/60 bg-muted object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(`div`,{className:`flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-muted`,children:(0,$.jsx)(Z,{name:`github-fill`,className:`h-3 w-3 text-muted-foreground`})}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-foreground`,children:t?.name?.trim()||t?.login||`GitHub`}),t?.login?(0,$.jsxs)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`font-mono`,children:t.login}),(0,$.jsx)(`span`,{className:`mx-1 opacity-50`,children:`·`}),(0,$.jsx)(`span`,{children:r})]}):null]}),n?(0,$.jsx)(Z,{name:`check`,className:`h-4 w-4 text-primary`}):null]},e.id)},t[22]=c,t[23]=s,t[24]=l,t[25]=e):e=t[25],m=i.map(e),t[17]=i,t[18]=c,t[19]=s,t[20]=l,t[21]=m}else m=t[21];let h;t[26]!==f||t[27]!==m?(h=(0,$.jsxs)(bi,{align:`end`,className:`w-64`,children:[f,p,m]}),t[26]=f,t[27]=m,t[28]=h):h=t[28];let g;return t[29]!==u||t[30]!==h?(g=(0,$.jsxs)(Ci,{children:[u,h]}),t[29]=u,t[30]=h,t[31]=g):g=t[31],g}let u;t[32]!==o||t[33]!==l?(u=o?l(`header.github.connectedWithLogin`,{login:o}):l(`header.github.connected`),t[32]=o,t[33]=l,t[34]=u):u=t[34];let d;t[35]!==a||t[36]!==o||t[37]!==l?(d=a?(0,$.jsx)(`img`,{src:a,alt:o?l(`header.github.avatarWithLogin`,{login:o}):l(`header.github.avatar`),className:`h-full w-full object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(Z,{name:`github-fill`,className:`h-3.5 w-3.5 text-foreground`}),t[35]=a,t[36]=o,t[37]=l,t[38]=d):d=t[38];let f;return t[39]!==u||t[40]!==d?(f=(0,$.jsx)(`div`,{className:`app-region-no-drag flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80`,title:u,children:d}),t[39]=u,t[40]=d,t[41]=f):f=t[41],f}),Kd=Q.memo(function(e){let t=(0,ju.c)(52),{isDesktopApp:n,currentInstanceSupportsUpdate:r,isDesktopServicesOpen:i,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:o,desktopServicesTab:s,setDesktopServicesTab:c,fetchAllQuotas:l,servicesTabItems:u,quotaLastUpdated:d,quotaDisplayMode:f,quotaDisplayTabItems:p,handleDisplayModeChange:m,handleUsageRefresh:h,isQuotaLoading:g,isUsageRefreshSpinning:_,hasRateLimits:v,rateLimitGroups:y,expandedFamilies:b,toggleFamilyExpanded:x,showPredValues:S,timeFormatPreference:C,anchorRef:w}=e,{t:T}=Nr(),E=Q.useRef(!1),D;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(D=e=>{E.current=e},t[0]=D):D=t[0];let O=K(D),k;t[1]!==s||t[2]!==l||t[3]!==d||t[4]!==o||t[5]!==a?(k=(e,t)=>{if(!e&&(t.reason===`trigger-hover`||t.reason===`focus-out`||E.current)){t.cancel();return}a(e),e&&(o(),s===`usage`&&d===null&&l())},t[1]=s,t[2]=l,t[3]=d,t[4]=o,t[5]=a,t[6]=k):k=t[6];let A;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(vi,{asChild:!0,openOnHover:!1,children:(0,$.jsx)(`button`,{type:`button`,"aria-hidden":!0,tabIndex:-1,className:`pointer-events-none absolute h-px w-px overflow-hidden opacity-0`})}),t[7]=A):A=t[7];let j;t[8]!==l||t[9]!==d||t[10]!==c?(j=e=>{if(E.current)return;let t=e;c(t),t===`usage`&&d===null&&l()},t[8]=l,t[9]=d,t[10]=c,t[11]=j):j=t[11];let M;t[12]!==s||t[13]!==u||t[14]!==j?(M=(0,$.jsx)(`div`,{className:`sticky top-0 z-20 bg-[var(--surface-elevated)]/60 px-2 pt-1.5 pb-1.5 backdrop-blur-xl backdrop-saturate-150`,children:(0,$.jsx)(`div`,{className:`h-9`,children:(0,$.jsx)(Vs,{items:u,activeId:s,onSelect:j,layoutMode:`fit`,variant:`active-pill`,activePillInsetClassName:`gap-0.5 px-px py-0`,activePillButtonClassName:`h-8`,className:`h-full`})})}),t[12]=s,t[13]=u,t[14]=j,t[15]=M):M=t[15];let N;t[16]!==r||t[17]!==s||t[18]!==O||t[19]!==n||t[20]!==i||t[21]!==a?(N=n&&s===`instance`?(0,$.jsxs)(`div`,{children:[r&&i?(0,$.jsx)(`div`,{className:`border-b border-[var(--interactive-border)] px-4 py-2.5`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label font-medium text-foreground`,children:`Yuri`}),(0,$.jsx)(Ol,{})]})}):null,(0,$.jsx)(Ua,{embedded:!0,open:i&&s===`instance`,onOpenChange:nf,onHostSwitched:()=>a(!1),onBusyChange:O})]}):null,t[16]=r,t[17]=s,t[18]=O,t[19]=n,t[20]=i,t[21]=a,t[22]=N):N=t[22];let P;t[23]!==s||t[24]!==i?(P=s===`mcp`?(0,$.jsx)(Hc,{active:i&&s===`mcp`}):null,t[23]=s,t[24]=i,t[25]=P):P=t[25];let F;t[26]!==s||t[27]!==b||t[28]!==m||t[29]!==h||t[30]!==v||t[31]!==g||t[32]!==_||t[33]!==f||t[34]!==p||t[35]!==d||t[36]!==y||t[37]!==S||t[38]!==T||t[39]!==C||t[40]!==x?(F=s===`usage`?(0,$.jsxs)(`div`,{className:`overflow-x-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-[var(--interactive-border)] px-4 py-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-header font-semibold text-foreground`,children:T(`header.services.rateLimits`)}),(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Jd(d,C)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`div`,{className:`h-7 w-[10.5rem]`,children:(0,$.jsx)(Vs,{items:p,activeId:f,onSelect:e=>void m(e),layoutMode:`fit`,variant:`active-pill`,activePillInsetClassName:`gap-0.5 px-px py-0`,className:`h-full`})}),(0,$.jsx)(`button`,{type:`button`,className:Y(`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors`,`hover:text-foreground hover:bg-interactive-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),onClick:h,disabled:g||_,"aria-label":T(`header.services.refreshRateLimitsAria`),children:(0,$.jsx)(Z,{name:`refresh`,className:Y(`h-4 w-4`,_&&`animate-spin`)})})]})]}),v?null:(0,$.jsx)(`div`,{className:`px-4 py-5 text-center`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:T(`header.services.noRateLimits`)})}),(0,$.jsx)(`div`,{className:`space-y-2 px-3 py-2.5`,children:y.map(e=>{let t=b[e.providerId]??[];return(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pb-2`,children:[(0,$.jsx)(Os,{providerId:e.providerId,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:e.providerName})]}),e.entries.length===0&&(!e.modelFamilies||e.modelFamilies.length===0)?(0,$.jsx)(`div`,{children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:e.error??T(`header.services.noRateLimitsReported`)})}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[e.entries.map((t,n)=>{let[r,i]=t,a=Rl(e.entries,n),o=f===`remaining`?i.remainingPercent:i.usedPercent,s=i.disablePace?null:ec(i.usedPercent,i.resetAt,i.windowSeconds,r),c=s?.dailyAllocationPercent==null?null:f===`remaining`?100-nc(s.elapsedRatio):nc(s.elapsedRatio),l=Qs(i.valueLabel,o),u=$s(i.resetAt,i.resetAfterFormatted??i.resetAtFormatted,C);return(0,$.jsxs)(Q.Fragment,{children:[a?(0,$.jsx)(`div`,{className:Y(`typography-micro font-medium uppercase tracking-wide text-muted-foreground`,n>0&&`mt-5 border-t border-[var(--surface-subtle)] pt-3`),children:a}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground break-words`,children:tc(i.label??r)}),u?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:u}):null]}),(0,$.jsx)(`span`,{className:`min-w-0 max-w-[55%] shrink-0 break-words text-right typography-ui-label tabular-nums text-foreground`,children:l===`-`?``:l})]}),(0,$.jsx)(hu,{percent:o,tonePercent:i.usedPercent,className:`h-1.5`,expectedMarkerPercent:c}),s&&S?(0,$.jsx)(ou,{paceInfo:s,compact:!0}):null]})]},`${e.providerId}-${r}`)}),e.modelFamilies&&e.modelFamilies.length>0?(0,$.jsx)(`div`,{className:`space-y-0.5`,children:e.modelFamilies.map(n=>{let r=n.familyId??`other`,i=t.includes(r);return(0,$.jsxs)(ji,{open:i,onOpenChange:()=>x(e.providerId,r),children:[(0,$.jsxs)(Ai,{className:`flex w-full items-center justify-between rounded-md px-1 py-1.5 text-left hover:bg-[var(--interactive-hover)]/50 transition-colors`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:n.familyLabel}),i?(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground`}):(0,$.jsx)(Z,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground`})]}),(0,$.jsx)(ki,{children:(0,$.jsx)(`div`,{className:`space-y-2.5 pb-1 pl-1 pt-1`,children:n.models.map(t=>{let[n,r]=t,i=f===`remaining`?r.remainingPercent:r.usedPercent,a=ec(r.usedPercent,r.resetAt,r.windowSeconds),o=a?.dailyAllocationPercent==null?null:f===`remaining`?100-nc(a.elapsedRatio):nc(a.elapsedRatio),s=Qs(r.valueLabel,i);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Gs(n)}),(0,$.jsx)(`span`,{className:`typography-ui-label tabular-nums text-foreground`,children:s===`-`?``:s})]}),(0,$.jsx)(hu,{percent:i,tonePercent:r.usedPercent,className:`h-1.5`,expectedMarkerPercent:o}),a&&S?(0,$.jsx)(ou,{paceInfo:a,compact:!0}):null]},`${e.providerId}-${n}`)})})})]},r)})}):null]})]},e.providerId)})})]}):null,t[26]=s,t[27]=b,t[28]=m,t[29]=h,t[30]=v,t[31]=g,t[32]=_,t[33]=f,t[34]=p,t[35]=d,t[36]=y,t[37]=S,t[38]=T,t[39]=C,t[40]=x,t[41]=F):F=t[41];let I;t[42]!==w||t[43]!==M||t[44]!==N||t[45]!==P||t[46]!==F?(I=(0,$.jsxs)(bi,{anchor:w,align:`start`,sideOffset:6,collisionPadding:12,className:`w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto bg-[var(--surface-elevated)] p-0 [&_[role=tab]]:capitalize`,children:[M,N,P,F]}),t[42]=w,t[43]=M,t[44]=N,t[45]=P,t[46]=F,t[47]=I):I=t[47];let L;return t[48]!==i||t[49]!==k||t[50]!==I?(L=(0,$.jsxs)(Ci,{open:i,onOpenChange:k,children:[A,I]}),t[48]=i,t[49]=k,t[50]=I,t[51]=L):L=t[51],L}),qd=(e,t)=>e===t?!0:!e||!t?!1:e.totalTokens===t.totalTokens&&e.pending===t.pending&&e.percentage===t.percentage&&e.contextLimit===t.contextLimit&&(e.outputLimit??0)===(t.outputLimit??0)&&(e.normalizedOutput??0)===(t.normalizedOutput??0)&&e.thresholdLimit===t.thresholdLimit&&(e.lastMessageId??``)===(t.lastMessageId??``),Jd=(e,t)=>{if(!e)return`-`;try{return Us(e,t,{fallback:`-`})}catch{return`-`}},Yd=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+$/g,``);return r=r.replace(/\/+/g,`/`),n&&!r.startsWith(`//`)&&(r=`/${r}`),r===``?t.startsWith(`/`)?`/`:``:r},Xd=e=>!e?.isOpen||!Array.isArray(e.tabs)||e.tabs.length===0?null:(e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[e.tabs.length-1])?.mode??null,Zd=e=>{let t=(0,ju.c)(3),n=un(rf),r;return t[0]!==n||t[1]!==e?(r=n?(0,$.jsx)(Qd,{...e,hostId:n}):(0,$.jsx)(tf,{...e}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r},Qd=e=>{let t=(0,ju.c)(11),n,r;t[0]===e?(n=t[1],r=t[2]):({hostId:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i=bt(),a=Dr(!0),o=Or(a.registry,n),s;t[3]!==n||t[4]!==a.catalog?.hosts?(s=a.catalog?.hosts.find(e=>e.id===n)?.name??n,t[3]=n,t[4]=a.catalog?.hosts,t[5]=s):s=t[5];let c=s,l=i?.registry??a.registry,u;return t[6]!==c||t[7]!==r||t[8]!==o.data||t[9]!==l?(u=(0,$.jsx)(tf,{...r,remoteSummaries:o.data,remoteHostName:c,remoteRegistry:l}),t[6]=c,t[7]=r,t[8]=o.data,t[9]=l,t[10]=u):u=t[10],u},$d=Q.memo(e=>{let t=(0,ju.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:ht,enabled:!1,staleTime:1/0,gcTime:1/0,select:o},t[5]=a,t[6]=o,t[7]=s):s=t[7];let c=yt(s,Tt).data??i,l;return t[8]===c?l=t[9]:(l=(0,$.jsx)($.Fragment,{children:c}),t[8]=c,t[9]=l),l}),ef=Q.memo(e=>{let t=(0,ju.c)(39),{entry:n,sessionId:r,onClick:i,pressed:a}=e,o=n.location,s=Q.useSyncExternalStore(Qe,Ze,Ze),c;t[0]===o?c=t[1]:(c=Xe(o),t[0]=o,t[1]=c);let l=c,d;t[2]!==o||t[3]!==l||t[4]!==r?(d=l?rt(o,r):null,t[2]=o,t[3]=l,t[4]=r,t[5]=d):d=t[5];let f;t[6]!==s||t[7]!==d?(f={revision:s,scope:d},t[6]=s,t[7]=d,t[8]=f):f=t[8];let p=f.scope,m;t[9]!==l||t[10]!==p?(m=e=>l&&p?l.subscribe(p,e):af,t[9]=l,t[10]=p,t[11]=m):m=t[11];let h=m,g;t[12]!==l||t[13]!==p?(g=()=>l&&p?l.getTranscript(p):null,t[12]=l,t[13]=p,t[14]=g):g=t[14];let _=g,v=Q.useSyncExternalStore(h,_,_),y;t[15]!==n||t[16]!==o.directory?(y=rn(o.directory,u(),n),t[15]=n,t[16]=o.directory,t[17]=y):y=t[17];let b;t[18]===y?b=t[19]:(b={...y,enabled:!1,staleTime:1/0,gcTime:1/0},t[18]=y,t[19]=b);let x=yt(b,Tt),S;t[20]!==o||t[21]!==r?(S=e=>e.getSessionModelSelection(r,o),t[20]=o,t[21]=r,t[22]=S):S=t[22];let C=ur(S),w;bb0:{if(!v){w=null;break bb0}for(let e=v.messageOrder.length-1;e>=0;e--){let t=v.messagesByID[v.messageOrder[e]];if(!t)continue;let n=ct([t],e=>v.partsByMessageID[e]);if(n){w=n;break bb0}}w=null}let T=w,E=T&&`messageId`in T&&v?v.messagesByID[T.messageId]:void 0,D;if(t[23]!==T||t[24]!==E?.modelID||t[25]!==E?.providerID||t[26]!==x.data?.providers||t[27]!==C?.modelId||t[28]!==C?.providerId){let e=x.data?.providers.find(e=>e.id===(C?.providerId??E?.providerID))?.models[C?.modelId??E?.modelID??``];D=Je(T,e?.limit?.context??0,e?.limit?.output??0),t[23]=T,t[24]=E?.modelID,t[25]=E?.providerID,t[26]=x.data?.providers,t[27]=C?.modelId,t[28]=C?.providerId,t[29]=D}else D=t[29];let O=D;if(!O)return null;let k=O.contextLimit>0?Math.min(999,O.totalTokens/O.contextLimit*100):0,A=O.outputLimit??0,j;return t[30]!==i||t[31]!==a||t[32]!==k||t[33]!==A||t[34]!==O.contextLimit||t[35]!==O.pending||t[36]!==O.percentage||t[37]!==O.totalTokens?(j=(0,$.jsx)(rc,{pending:O.pending,totalTokens:O.totalTokens,percentage:k,colorPercentage:O.percentage,contextLimit:O.contextLimit,outputLimit:A,size:`compact`,appearance:`subtle`,onClick:i,pressed:a}),t[30]=i,t[31]=a,t[32]=k,t[33]=A,t[34]=O.contextLimit,t[35]=O.pending,t[36]=O.percentage,t[37]=O.totalTokens,t[38]=j):j=t[38],j}),tf=({onToggleLeftDrawer:e,onToggleRightDrawer:t,leftDrawerOpen:r,rightDrawerOpen:i,remoteSummaries:a,remoteHostName:o,remoteRegistry:s})=>{let{t:c}=Nr(),l=q(e=>e.setSessionSwitcherOpen),d=q(e=>e.toggleSidebar),f=q(e=>e.isSidebarOpen),m=q(e=>e.toggleBottomTerminal),_=q(e=>e.toggleContextPanel),v=q(e=>e.openContextOverview),y=q(e=>e.openContextBrowser),b=q(e=>e.closeContextPanel),S=q(e=>e.activeMainTab),w=q(e=>e.setActiveMainTab),T=q(e=>e.shortcutOverrides),E=q(e=>e.timeFormatPreference),D=jn(e=>e.getCurrentModel),O=wt(),k=Kn(e=>!!e.newSessionDraft?.open),A=Kn(e=>e.currentSessionId),M=un(e=>e.activeProjectId?e.projects.find(t=>t.id===e.activeProjectId)??null:null),N=!!M?.hostId,P=sn(e=>e.remoteSession),F=M?.hostId&&P?.projectId===M.id&&P.location.hostId===M.hostId&&(!M.hubId||P.location.hubId===M.hubId)?P:null,I=N?F?.sessionId??null:A,R=N?!F?.sessionId:k,z=qn(N?``:I??``),V=ln(N?null:I),te=un(e=>e.projects),re=Q.useMemo(()=>{if(!N)return V;let e=F?.location.directory??M?.path,t=M?.hubId??s?.hubId,n=M?.hostId;if(!(!e||!t||!n||It(te,t,n,e,a?.worktrees)?.id!==M?.id))return a?.directories.find(t=>t.directory===e)?.sessions.find(t=>t.id===I&&t.directory===e)},[N,V,F?.location.directory,M,s?.hubId,te,a,I]),ie=Q.useMemo(()=>{if(!M)return null;let e=M.path.split(/[\\/]/).filter(Boolean);return e[e.length-1]??null},[M]),H=Xs(e=>e.results),U=Xs(e=>e.fetchAllQuotas),se=Xs(e=>e.isLoading),ue=Xs(e=>e.lastUpdated),de=Xs(e=>e.displayMode),fe=Xs(e=>e.showPredValues),pe=Xs(e=>e.dropdownProviderIds),me=Xs(e=>e.loadSettings),he=Xs(e=>e.setDisplayMode),{isMobile:ge}=fi(),_e=Is().data??null,ve=Nl(e=>e.setStatus),ye=Q.useRef(null),[be,xe]=Q.useState(()=>typeof window>`u`?!1:C()),Se=Q.useMemo(()=>L(),[]),Ce=be&&B()===`win32`,we=di(),Te=Ru(),Ee=Q.useMemo(()=>typeof navigator>`u`?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||``),[]),{usesFramelessChrome:De,side:Oe}=oc(),ke=Q.useMemo(()=>{if(typeof window>`u`)return null;let e=window.__YURI_MACOS_MAJOR__;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return e;if(typeof navigator>`u`)return null;let t=(navigator.userAgent||``).match(/Mac OS X (\d+)[._](\d+)/);if(!t)return null;let n=Number.parseInt(t[1],10),r=Number.parseInt(t[2],10);return Number.isNaN(n)?null:n===10?r:n},[]);(0,Q.useEffect)(()=>{typeof window>`u`||xe(C())},[]);let Ae=D(),je=Ae&&typeof Ae.limit==`object`&&Ae.limit!==null?Ae.limit:null,Me=je&&typeof je.context==`number`?je.context:0,Pe=je&&typeof je.output==`number`?je.output:0,Fe=rr(N?``:I??``,Me,Pe),G=R?null:Fe,[Ie,Le]=Q.useState(null),Re=!I||z;(0,Q.useEffect)(()=>{if(!I){Le(e=>e===null?e:null);return}if(G){Le(e=>qd(e,G)?e:G);return}Re&&Le(e=>e===null?e:null)},[G,I,Re]);let ze=q(e=>e.isSessionSwitcherOpen),Be=_e?.connected?_e.user?.avatarUrl??null:null,Ve=_e?.connected?_e.user?.login??null:null,He=_e?.accounts??[],[Ue,We]=Q.useState(!1),[Ge,Ke]=Q.useState(!1),[qe,Je]=Q.useState(!1),[Ye,Xe]=Q.useState(!1),[Ze,Qe]=Q.useState(`Local`),[$e,et]=Q.useState(!1),[tt,nt]=Q.useState(be?`instance`:`usage`),[rt,it]=Q.useState(`usage`);(0,Q.useEffect)(()=>{!be&&tt===`instance`&&nt(`usage`)},[tt,be]);let at=Q.useMemo(()=>ae(),[]),ot=!at&&S===`chat`&&!!Ie,st=Ie&&Ie.contextLimit>0?Math.min(999,Ie.totalTokens/Ie.contextLimit*100):0,ct=K(async()=>{if(!(typeof window>`u`||!be))try{if(x()){Qe(`Local`),et(!1);return}let e=u(),t=await ce();if(u()!==e)return;let n=h(),r=p(),i=r.startsWith(`host:`)?r.slice(5):null,a=(i?t.hosts.find(e=>e.id===i):void 0)??t.hosts.find(e=>n?W(n,oe(e)):!1);if(h()!==n)return;if(et(!!n),a?.label?.trim()){Qe(le(a.label.trim()));return}Qe(`Instance`)}catch{Qe(`Local`),et(!1)}});(0,Q.useEffect)(()=>{ct()},[be]),Js();let lt=Xs(e=>e.selectedModels),ut=Xs(e=>e.expandedFamilies),dt=Xs(e=>e.toggleFamilyExpanded),ft=Q.useMemo(()=>{let e=[];for(let t of Zs(H)){if(!pe.includes(t.id))continue;let n=H.find(e=>e?.providerId===t.id),r=n?.usage?.windows??{},i=n?.usage?.models,a=Ll(Object.entries(r),n?.usage?.accounts),o={providerId:t.id,providerName:t.name,entries:a,error:n&&!n.ok&&n.configured?n.error:void 0};if(i&&Object.keys(i).length>0){let e=lt[t.id]??[],n=e.length>0,r=Ys(i,t.id),a=qs(t.id),s=Ks(a);o.modelFamilies=[];for(let t of s){let a=r.get(t.id)??[];if(a.length===0)continue;let s=n?a.filter(t=>e.includes(t)):a;if(s.length===0)continue;let c=[];for(let e of s){let t=i[e];if(t?.windows){let n=Object.entries(t.windows);n.length>0&&c.push([e,n[0][1]])}}c.length>0&&o.modelFamilies.push({familyId:t.id,familyLabel:t.label,models:c})}let l=r.get(null)??[],u=n?l.filter(t=>e.includes(t)):l;if(u.length>0){let e=[];for(let t of u){let n=i[t];if(n?.windows){let r=Object.entries(n.windows);r.length>0&&e.push([t,r[0][1]])}}e.length>0&&o.modelFamilies.push({familyId:null,familyLabel:c(`header.services.modelFamily.other`),models:e})}}(a.length>0||o.modelFamilies&&o.modelFamilies.length>0||o.error)&&e.push(o)}return e},[pe,H,lt,c]),pt=ft.length>0;Q.useEffect(()=>{me()},[me]);let mt=Q.useCallback(async e=>{he(e);try{await Ne({usageDisplayMode:e})}catch(e){console.warn(`Failed to update usage display mode:`,e)}},[he]),ht=Q.useCallback(()=>{if(Ye)return;Xe(!0);let e=new Promise(e=>setTimeout(e,500));Promise.all([U(),e]).finally(()=>{Xe(!1)})},[U,Ye]),gt=Kn(e=>N||!I?``:e.worktreeMetadata.get(I)?.path??``),_t=Q.useMemo(()=>Yd(gt||``),[gt]),vt=Q.useMemo(()=>Yd((typeof re?.directory==`string`?re.directory:``)||``),[re?.directory]),yt=Kn(e=>e.newSessionDraft?.open?Yd(e.newSessionDraft.bootstrapPendingDirectory??e.newSessionDraft.directoryOverride??``):``),bt=Q.useMemo(()=>N?F?.location.directory??M?.path??``:_t||vt||yt,[N,F?.location.directory,M?.path,yt,vt,_t]),xt=Ui(),St=F?ne(F.location):M?.hostId&&M.hubId?ne({hubId:M.hubId,hostId:M.hostId,directory:xt??M.path}):``,Ct=Q.useMemo(()=>N?St:Yd(xt||bt||M?.path||``),[N,St,M?.path,xt,bt]),Tt=q(e=>Ht(e,Ct)),Et=!!Tt?.isOpen,Dt=K(()=>_(Ct)),Ot=Q.useMemo(()=>{if(!I)return ie??`Yuri`;let e=re?.title?.trim();return e&&e.length>0?e:`Untitled Session`},[ie,re?.title,I]),kt=Q.useMemo(()=>N?bt:Yd(bt||M?.path||``),[N,M?.path,bt]),At=Q.useMemo(()=>M?{id:M.id,path:M.path,hostId:M.hostId,hubId:M.hubId}:null,[M]),jt=Q.useRef(null);Q.useEffect(()=>{!At||!kt||(jt.current={projectRef:At,directory:kt})},[kt,At]);let Mt=Q.useMemo(()=>At&&kt?{projectRef:At,directory:kt}:jt.current,[kt,At]),Nt=Q.useCallback(async e=>{if(!(!e||Ue)){We(!0);try{let t=O.github?await O.github.authActivate(e):await(async()=>{let t=await g(`/api/github/auth/activate`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({accountId:e})}),n=await t.json().catch(()=>null);if(!t.ok||!n)throw Error(n?.error||t.statusText);return n})();ve(t)}catch(e){console.error(`Failed to switch GitHub account:`,e)}finally{We(!1)}}},[Ue,O.github,ve]),Pt=Q.useCallback(()=>{if(typeof document>`u`)return;let e=document.activeElement;if(!e)return;let t=e.tagName;(t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||e.isContentEditable)&&e.blur()},[]),Lt=Q.useCallback(()=>{if(ge){Pt(),l(!ze);return}d()},[Pt,ge,ze,l,d]),Rt=Q.useCallback(()=>{N||ee(`desktop_open_draft_mini_chat_window`,{directory:Yd(bt||M?.path||``),projectId:M?.id??null,apiBaseUrl:h(),clientToken:n()}).catch(e=>{console.warn(`[header] failed to open draft mini chat window`,e)})},[N,M?.id,M?.path,bt]),zt=Q.useCallback(()=>{if(!N){if(R){Rt();return}I&&ee(`desktop_open_session_mini_chat_window`,{sessionId:I,directory:Yd(bt||M?.path||``),apiBaseUrl:h(),clientToken:n()}).catch(e=>{console.warn(`[header] failed to open session mini chat window`,e)})}},[N,M?.path,I,Rt,R,bt]),Bt=Q.useCallback(()=>{let e=Ct;if(e){if(Xd(Tt)===`context`){b(e);return}v(e)}},[b,Ct,Tt,v]),Vt=Q.useMemo(()=>Ct?Xd(Tt)===`context`:!1,[Ct,Tt]),Ut=Q.useCallback(()=>{let e=Ct;if(e){if(Xd(Tt)===`browser`){b(e);return}y(e)}},[b,Ct,Tt,y]),Wt=Q.useMemo(()=>Ct?Xd(Tt)===`browser`:!1,[Ct,Tt]),Gt=Hd,Kt=Ud,qt=Q.useMemo(()=>Ge?`services`:r?`sessions`:i?`git`:S,[S,Ge,r,i]),Jt=Q.useCallback(()=>{Ke(!1),r&&e&&e(),i&&t&&t(),!e&&ze&&l(!1)},[ze,r,e,t,i,l]),Yt=Q.useCallback(()=>{r||Ke(!1),e?.()},[r,e]),Xt=Q.useCallback(()=>{i||Ke(!1),t?.()},[t,i]),Zt=Q.useMemo(()=>be&&Ee&&!Te?`5.5rem`:we?`max(calc(0.75rem + var(--yuri-wco-left-inset, 0px)), 5.5rem)`:(!be||De)&&!at?`calc(0.75rem + var(--yuri-wco-left-inset, 0px))`:`0.75rem`,[be,Te,Ee,we,at,De]);(0,Q.useEffect)(()=>{typeof document>`u`||document.documentElement.style.setProperty(`--yuri-titlebar-left-inset`,Zt)},[Zt]);let Qt=f?`0.75rem`:`var(--yuri-titlebar-left-inset, 0.75rem)`,$t=f?`0px`:`calc(var(--yuri-titlebar-controls-width, 5.5rem) + 0.5rem)`,en=Q.useMemo(()=>!be||!Ee||ke===null?``:ke>=26?`h-12`:ke<=15?`h-14`:``,[be,Ee,ke]),tn=Q.useMemo(()=>{if(!(be&&!De||at))return{paddingRight:Et?`0.75rem`:`calc(0.75rem + var(--yuri-wco-right-inset, 0px))`,minHeight:`max(3rem, var(--yuri-wco-titlebar-height, 0px))`,height:`max(3rem, var(--yuri-wco-titlebar-height, 0px))`}},[be,at,Et,De]),nn=K(e=>{if(!e||typeof document>`u`)return;let t=document.documentElement.style,n=`${e}px`;t.getPropertyValue(`--yuri-header-height`)!==n&&t.setProperty(`--yuri-header-height`,n)});Ft(ye,([e])=>{e&&nn(e.borderBoxSize[0]?.blockSize??e.target.getBoundingClientRect().height)},{box:`border-box`}),Q.useLayoutEffect(()=>{nn(ye.current?.getBoundingClientRect().height)},[nn,ge,en]);let rn=Q.useCallback(async e=>{let t=e.target;t.closest(`.app-region-no-drag`)||t.closest(`button, a, input, select, textarea`)||e.button===0&&be&&await j()},[be]),an=Q.useMemo(()=>{if(ge){let e=[{id:`chat`,label:c(`layout.mainTab.chat`),icon:`chat-thread`}];return e.push({id:`diff`,label:c(`layout.mainTab.diff`),icon:`diff`},{id:`files`,label:c(`layout.mainTab.files`),icon:`folder-6`},{id:`terminal`,label:c(`layout.mainTab.terminal`),icon:`terminal-box`},{id:`diagram`,label:c(`layout.mainTab.diagram`),icon:`file`}),e}return[]},[ge,c]),on=Q.useCallback(e=>Sa(Ta(e,T)),[T]);(0,Q.useEffect)(()=>{!ge&&(S===`git`||S===`terminal`||S===`diff`||S===`files`)&&w(`chat`)},[S,ge,w]);let cn=Q.useMemo(()=>{let e=[];return be&&e.push({value:`instance`,label:c(`layout.services.instance`),icon:(0,$.jsx)(Z,{name:`connection-local`,className:`h-3.5 w-3.5`})}),e.push({value:`usage`,label:c(`layout.services.usage`),icon:(0,$.jsx)(Z,{name:`timer`,className:`h-3.5 w-3.5`})},{value:`mcp`,label:`MCP`,icon:(0,$.jsx)(Il,{className:`h-3.5 w-3.5`})}),e},[be,c]),dn=Q.useMemo(()=>cn.map(e=>({id:e.value,label:e.label,icon:e.icon})),[cn]),fn=Q.useMemo(()=>[{value:`usage`,label:c(`header.services.used`)},{value:`remaining`,label:c(`header.services.remaining`)}],[c]),pn=Q.useMemo(()=>fn.map(e=>({id:e.value,label:e.label})),[fn]),mn=Q.useMemo(()=>[{id:`usage`,label:c(`layout.services.usage`),icon:(0,$.jsx)(Z,{name:`timer`,className:`h-3.5 w-3.5`})},{id:`mcp`,label:`MCP`,icon:(0,$.jsx)(Il,{className:`h-3.5 w-3.5`})}],[c]);(0,Q.useEffect)(()=>{let e=e=>{if($n(e)&&!e.shiftKey&&!e.altKey){let t=parseInt(e.key,10);t>=1&&t<=an.length&&(e.preventDefault(),ge&&(Pt(),Jt()),w(an[t-1].id))}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Pt,Jt,ge,w,an]);let hn=K(e=>{nt(e),Je(!0),ct(),e===`usage`&&ue===null&&U()});(0,Q.useEffect)(()=>{let e=e=>{let t=Ta(`toggle_services_menu`,T);if(wa(e,t)){e.preventDefault();let t=Vd({isOpen:qe,activeTab:tt,targetTab:be?`instance`:`usage`});t.open?hn(t.tab):Je(!1);return}let n=Ta(`cycle_services_tab`,T);if(wa(e,n)){e.preventDefault();let t=cn.map(e=>e.value);if(t.length===0)return;let n=t.indexOf(tt),r=t[n===-1?0:(n+1)%t.length];nt(r),Je(!0),ct(),r===`usage`&&ue===null&&U();return}let r=Ta(`open_usage`,T);if(wa(e,r)){e.preventDefault();let t=Vd({isOpen:qe,activeTab:tt,targetTab:`usage`});t.open?hn(t.tab):Je(!1);return}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[T,be,qe,tt,cn,ue,U,ct,hn]);let gn=e=>{let t=S===e.id,n=e.icon===`diff`,r=n?null:e.icon,i=e.id===`chat`,a=e=>n?(0,$.jsx)(Mu,{size:e}):r?(0,$.jsx)(Z,{name:r,className:`h-${e/4} w-${e/4}`}):null,o=(0,$.jsxs)(`button`,{type:`button`,onClick:()=>w(e.id),className:Y(`relative flex h-8 items-center gap-2 px-3 rounded-lg typography-ui-label font-medium transition-colors`,t?`app-region-no-drag bg-interactive-selection text-interactive-selection-foreground shadow-none`:`app-region-no-drag text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,i&&!ge&&`min-w-[100px] justify-center`),"aria-label":e.label,"aria-selected":t,role:`tab`,children:[ge?a(20):(0,$.jsxs)($.Fragment,{children:[a(16),(0,$.jsx)(`span`,{className:`header-tab-label`,children:e.label})]}),e.badge!==void 0&&e.badge>0&&(0,$.jsx)(`span`,{className:`header-tab-badge typography-micro text-status-info font-medium`,children:e.badge})]});return(0,$.jsx)(Q.Fragment,{children:o},e.id)},_n=!N&&Se&&(R||!!I),vn=Q.useCallback(e=>{window.setTimeout(e,0)},[]),yn=Q.useCallback(e=>{hn(e)},[hn]),bn=Q.useRef(null),xn=(0,$.jsxs)(`div`,{className:`relative flex shrink-0 items-center`,children:[(0,$.jsx)(`div`,{ref:bn,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center`,children:(0,$.jsxs)(Ci,{children:[(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(vi,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":c(`header.actions.sessionMenuAria`),className:Y(Gt,`text-muted-foreground`),children:(0,$.jsx)(Z,{name:`more-2`,className:`h-[18px] w-[18px]`})})})}),(0,$.jsx)(ei,{children:(0,$.jsx)(`p`,{children:c(`header.actions.sessionMenu`)})})]}),(0,$.jsxs)(bi,{align:`start`,className:`min-w-[14rem]`,children:[_n?(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>vn(zt),children:[(0,$.jsx)(Z,{name:`picture-in-picture-2`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(R?`header.actions.newMiniChat`:`header.actions.openSessionMiniChat`)})]}):null,be?(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>vn(()=>yn(`instance`)),children:[(0,$.jsx)(Z,{name:`stack`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:c(`header.actions.sessionMenu.servicesWithInstance`,{current:Ze})}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:on(`toggle_services_menu`)})]}):null,(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>vn(()=>yn(`usage`)),children:[(0,$.jsx)(Z,{name:`timer`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(`header.actions.sessionMenu.viewUsage`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:on(`open_usage`)})]}),(0,$.jsx)(Si,{}),(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>vn(m),children:[(0,$.jsx)(Z,{name:`terminal-box`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(`header.actions.toggleTerminalPanel`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:on(`toggle_terminal`)})]}),(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>vn(Ut),children:[(0,$.jsx)(Z,{name:`global`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(`contextPanel.browser.open`)}),Wt?(0,$.jsx)(Z,{name:`check`,className:`h-3.5 w-3.5 text-foreground`}):null]})]})]})}),(0,$.jsx)(Kd,{isDesktopApp:be,currentInstanceSupportsUpdate:$e,isDesktopServicesOpen:qe,setIsDesktopServicesOpen:Je,refreshCurrentInstanceLabel:ct,desktopServicesTab:tt,setDesktopServicesTab:nt,fetchAllQuotas:U,servicesTabItems:dn,quotaLastUpdated:ue,quotaDisplayMode:de,showPredValues:fe,quotaDisplayTabItems:pn,handleDisplayModeChange:mt,handleUsageRefresh:ht,isQuotaLoading:se,isUsageRefreshSpinning:Ye,hasRateLimits:pt,rateLimitGroups:ft,expandedFamilies:ut,toggleFamilyExpanded:dt,timeFormatPreference:E,anchorRef:bn})]}),Sn=(0,$.jsxs)($.Fragment,{children:[!N&&!ge&&!at&&S===`chat`?(0,$.jsx)(Vu,{}):null,N?null:(0,$.jsx)(yd,{directory:kt}),be&&(0,$.jsx)(Ju,{open:qe&&tt===`instance`,onClick:()=>hn(`instance`)}),(0,$.jsx)(Wd,{title:c(`header.actions.rightSidebarWithShortcut`,{shortcut:on(`toggle_right_sidebar`)}),ariaLabel:c(`contextPanel.actions.togglePanel`),pressed:Et,onClick:Dt,className:Y(`app-region-no-drag group inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary hover:bg-interactive-hover transition-colors`,Et?`bg-interactive-selection text-interactive-selection-foreground`:`text-muted-foreground/75 hover:text-foreground`),Icon:`folder-3`,iconClassName:`size-4`}),(0,$.jsx)(Gd,{isMobile:ge,githubAuthStatus:_e,githubAccounts:He,githubAvatarUrl:Be,githubLogin:Ve,isSwitchingGitHubAccount:Ue,handleGitHubAccountSwitch:Nt})]}),Cn=()=>(0,$.jsxs)(`div`,{onMouseDown:rn,className:Y(`app-region-drag relative flex h-12 select-none items-center pr-3`,en),style:tn,role:`tablist`,"aria-label":c(`header.navigation.mainAria`),children:[(0,$.jsx)(`div`,{"aria-hidden":!0,className:`shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,style:{width:Qt}}),(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-no-drag shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,style:{width:$t}}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[(0,$.jsxs)(`div`,{className:`app-region-no-drag mr-3 flex min-w-0 items-center gap-0.5`,children:[(0,$.jsx)(ac,{scopeProjectId:N?M?.id:null,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":c(`sessions.switcher.openAria`),className:`inline-flex h-8 min-w-0 max-w-full items-center rounded-md px-2.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-primary`,children:(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground`,children:R?c(`sessions.switcher.draftTitle`):N&&s&&F?.sessionId?(0,$.jsx)($d,{entry:s.resolve(F.location),sessionId:F.sessionId,fallback:Ot},ne(F.location)):Ot})})}),N?(0,$.jsxs)(`span`,{"data-remote-header-host":M?.hostId,className:`inline-flex min-w-0 max-w-36 items-center gap-1 typography-meta text-muted-foreground`,title:o,children:[(0,$.jsx)(Z,{name:`computer`,className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:o}),s&&M?.hostId?(0,$.jsx)(zo,{registry:s,hostId:M.hostId}):null]}):null]}),an.length>0&&(0,$.jsx)(`div`,{className:`flex items-center gap-1 rounded-lg bg-[var(--surface-muted)]/50 p-1`,children:an.map(e=>gn(e))}),(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[xn,N&&!at&&S===`chat`&&s&&F?.sessionId?(0,$.jsx)(ef,{entry:s.resolve(F.location),sessionId:F.sessionId,onClick:Bt,pressed:Vt},ne(F.location)):null,ot&&Ie?(0,$.jsx)(rc,{pending:Ie.pending,totalTokens:Ie.totalTokens,percentage:st,colorPercentage:Ie.percentage,contextLimit:Ie.contextLimit,outputLimit:Ie.outputLimit??0,size:`compact`,appearance:`subtle`,onClick:Bt,pressed:Vt}):null,Sn,(0,$.jsx)(ic,{visible:De&&Oe===`right`&&!Et,position:`right`})]})]})]}),wn=()=>(0,$.jsxs)(`div`,{className:`app-region-drag relative flex items-center gap-2 px-3 py-2 select-none`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e?(0,$.jsx)(`button`,{type:`button`,onClick:Yt,className:Y(Kt,qt===`sessions`&&`bg-interactive-selection text-interactive-selection-foreground`),"aria-label":c(r?`header.actions.closeSessionsAria`:`header.actions.openSessionsAria`),children:(0,$.jsx)(Z,{name:`layout-left`,className:`h-5 w-5`})}):ze?(0,$.jsx)(`button`,{type:`button`,onClick:()=>l(!1),className:`app-region-no-drag h-9 w-9 p-2 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary rounded-md active:bg-interactive-active`,"aria-label":c(`header.actions.backAria`),children:(0,$.jsx)(Z,{name:`arrow-left-s`,className:`h-5 w-5`})}):(0,$.jsx)(`button`,{type:`button`,onClick:Lt,className:`app-region-no-drag h-9 w-9 p-2 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary rounded-md active:bg-interactive-active`,"aria-label":c(`header.actions.openSessionsAria`),children:(0,$.jsx)(Z,{name:`play-list-add`,className:`h-5 w-5`})}),!e&&ze&&(0,$.jsx)(`span`,{className:`typography-ui-label font-semibold text-foreground`,children:c(`header.sessions.title`)})]}),(!ze||!!e)&&(0,$.jsxs)($.Fragment,{children:[N?(0,$.jsxs)(`span`,{"data-remote-header-host":M?.hostId,className:`inline-flex max-w-28 shrink-0 items-center gap-1 typography-meta text-muted-foreground`,title:o,children:[(0,$.jsx)(`span`,{className:`truncate`,children:o}),s&&M?.hostId?(0,$.jsx)(zo,{registry:s,hostId:M.hostId}):null]}):null,(0,$.jsx)(`div`,{className:`app-region-no-drag flex min-w-0 flex-1 items-center`,children:(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 overflow-x-auto overflow-y-hidden scrollbar-hidden touch-pan-x overscroll-x-contain`,children:(0,$.jsx)(`div`,{className:`flex w-max items-center gap-1 pr-1`,children:(0,$.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg bg-[var(--surface-muted)]/50 p-0.5`,role:`tablist`,"aria-label":c(`header.navigation.mainAria`),children:an.map(e=>{let t=S===e.id,n=e.icon===`diff`,r=n?null:e.icon;return(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{ge&&(Pt(),Jt()),w(e.id)},"aria-label":e.label,"aria-selected":t,role:`tab`,className:Y(Kt,`relative rounded-lg`,qt===e.id&&`bg-interactive-selection text-interactive-selection-foreground`),children:[n?(0,$.jsx)(Mu,{className:`h-5 w-5`}):r?(0,$.jsx)(Z,{name:r,className:`h-5 w-5`}):null,e.badge!==void 0&&e.badge>0&&(0,$.jsx)(`span`,{className:`absolute -top-1 -right-1 text-[10px] font-semibold text-primary`,children:e.badge}),e.showDot&&(0,$.jsx)(`span`,{className:`absolute top-1.5 right-1.5 h-2 w-2 rounded-full bg-primary`,"aria-label":c(`header.changes.availableAria`)})]})}),(0,$.jsx)(ei,{children:(0,$.jsx)(`p`,{children:e.label})})]},e.id)})})})})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,$.jsx)(Eu,{mobile:!0}),Mt&&(0,$.jsx)(Rd,{projectRef:Mt.projectRef,directory:Mt.directory,compact:!0,allowMobile:!0,className:`h-9`}),(0,$.jsxs)(Ci,{open:Ge,onOpenChange:n=>{n&&(r&&e&&e(),i&&t&&t()),Ke(n),n&&ue===null&&U()},children:[(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(vi,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":c(`header.services.viewAria`),className:Y(Kt,qt===`services`&&`bg-interactive-selection text-interactive-selection-foreground`),children:(0,$.jsx)(Z,{name:`stack`,className:`h-5 w-5`})})})}),(0,$.jsx)(ei,{children:(0,$.jsx)(`p`,{children:c(`header.services.title`)})})]}),(0,$.jsx)(bi,{align:`end`,sideOffset:0,positionerClassName:`!fixed !bottom-0 !left-0 !right-0 !top-[var(--yuri-header-height,56px)] !transform-none`,className:`h-full w-screen max-h-none rounded-none border-0 p-0 pt-1 overflow-hidden`,children:(0,$.jsxs)(`div`,{className:`flex h-full flex-col bg-[var(--surface-elevated)]`,children:[(0,$.jsx)(`div`,{className:`sticky top-0 z-20 bg-[var(--surface-elevated)] px-2 py-px`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-0`,children:[(0,$.jsx)(`div`,{className:`h-10 min-w-0 flex-1`,children:(0,$.jsx)(Vs,{items:mn,activeId:rt,onSelect:e=>{let t=e;it(t),t===`usage`&&ue===null&&U()},layoutMode:`fit`,variant:`active-pill`,activePillInsetClassName:`gap-0.5 px-px py-0`,activePillButtonClassName:`h-8`,className:`h-full`})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>Ke(!1),className:`inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover`,"aria-label":c(`header.services.closeAria`),children:(0,$.jsx)(Z,{name:`close`,className:`h-5 w-5`})})]})}),rt===`mcp`&&(0,$.jsx)(Hc,{active:Ge&&rt===`mcp`}),rt===`usage`&&(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto overflow-x-hidden pb-[calc(4rem+env(safe-area-inset-bottom))]`,children:[(0,$.jsx)(`div`,{className:`border-b border-[var(--interactive-border)]`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col min-w-0 gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-header font-semibold text-foreground`,children:c(`header.services.rateLimits`)}),(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Jd(ue,E)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center h-6`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>mt(`usage`),className:Y(`typography-ui-label px-1 pb-0.5 transition-colors`,de===`usage`?`text-foreground border-b-2 border-[var(--primary-base)]`:`text-muted-foreground hover:text-foreground`),children:c(`header.services.used`)}),(0,$.jsx)(`span`,{className:`text-muted-foreground typography-ui-label px-0.5`,children:`·`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>mt(`remaining`),className:Y(`typography-ui-label px-1 pb-0.5 transition-colors`,de===`remaining`?`text-foreground border-b-2 border-[var(--primary-base)]`:`text-muted-foreground hover:text-foreground`),children:c(`header.services.remaining`)})]}),(0,$.jsx)(`button`,{type:`button`,className:Y(`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors`,`hover:text-foreground hover:bg-interactive-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),onClick:ht,disabled:se||Ye,"aria-label":c(`header.services.refreshRateLimitsAria`),children:(0,$.jsx)(Z,{name:`refresh`,className:Y(`h-4 w-4`,Ye&&`animate-spin`)})})]})]})}),!pt&&(0,$.jsx)(`div`,{className:`px-4 py-6 text-center`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:c(`header.services.noRateLimits`)})}),(0,$.jsx)(`div`,{className:`py-1`,children:ft.map((e,t)=>(0,$.jsxs)(Q.Fragment,{children:[t>0?(0,$.jsx)(`div`,{className:`mx-4 my-1 border-t border-[var(--interactive-border)]`}):null,(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2`,children:[(0,$.jsx)(Os,{providerId:e.providerId,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:e.providerName})]}),e.entries.length===0&&(!e.modelFamilies||e.modelFamilies.length===0)?(0,$.jsx)(`div`,{className:`px-4 pb-2`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:e.error??c(`header.services.noRateLimitsReported`)})}):(0,$.jsxs)(`div`,{className:`space-y-3 px-4 pb-2`,children:[e.entries.map(([t,n],r)=>{let i=Rl(e.entries,r),a=de===`remaining`?n.remainingPercent:n.usedPercent,o=n.disablePace?null:ec(n.usedPercent,n.resetAt,n.windowSeconds,t),s=o?.dailyAllocationPercent==null?null:de===`remaining`?100-nc(o.elapsedRatio):nc(o.elapsedRatio),c=Qs(n.valueLabel,a),l=$s(n.resetAt,n.resetAfterFormatted??n.resetAtFormatted,E);return(0,$.jsxs)(Q.Fragment,{children:[i?(0,$.jsx)(`div`,{className:Y(`typography-micro font-medium uppercase tracking-wide text-muted-foreground`,r>0&&`mt-5 border-t border-[var(--surface-subtle)] pt-3`),children:i}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground break-words`,children:tc(n.label??t)}),l?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:l}):null]}),(0,$.jsx)(`span`,{className:`min-w-0 max-w-[55%] shrink-0 break-words text-right typography-ui-label text-foreground tabular-nums`,children:c===`-`?``:c})]}),(0,$.jsx)(hu,{percent:a,tonePercent:n.usedPercent,className:`h-1.5`,expectedMarkerPercent:s}),o&&fe?(0,$.jsx)(ou,{paceInfo:o,compact:!0}):null]})]},`${e.providerId}-${t}`)}),e.modelFamilies&&e.modelFamilies.length>0&&(0,$.jsx)(`div`,{className:`space-y-0.5`,children:e.modelFamilies.map(t=>{let n=(ut[e.providerId]??[]).includes(t.familyId??`other`);return(0,$.jsxs)(ji,{open:n,onOpenChange:()=>dt(e.providerId,t.familyId??`other`),children:[(0,$.jsxs)(Ai,{className:`flex w-full items-center justify-between rounded-md px-1 py-1.5 text-left hover:bg-[var(--interactive-hover)]/50 transition-colors`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:t.familyLabel}),n?(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground`}):(0,$.jsx)(Z,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground`})]}),(0,$.jsx)(ki,{children:(0,$.jsx)(`div`,{className:`space-y-2.5 pb-1 pl-1 pt-1`,children:t.models.map(([t,n])=>{let r=de===`remaining`?n.remainingPercent:n.usedPercent,i=ec(n.usedPercent,n.resetAt,n.windowSeconds),a=i?.dailyAllocationPercent==null?null:de===`remaining`?100-nc(i.elapsedRatio):nc(i.elapsedRatio),o=Qs(n.valueLabel,r);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Gs(t)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground tabular-nums`,children:o===`-`?``:o})]}),(0,$.jsx)(hu,{percent:r,tonePercent:n.usedPercent,className:`h-1.5`,expectedMarkerPercent:a}),i&&fe?(0,$.jsx)(ou,{paceInfo:i,compact:!0}):null]},`${e.providerId}-${t}`)})})})]},t.familyId??`other`)})})]})]},e.providerId))})]})]})})]}),t?(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:Xt,className:Y(Kt,`relative`,qt===`git`&&`bg-interactive-selection text-interactive-selection-foreground`),"aria-label":i?`Close git sidebar`:`Open git sidebar`,children:(0,$.jsx)(Z,{name:`layout-right`,className:`h-5 w-5`})})}),(0,$.jsx)(ei,{children:(0,$.jsx)(`p`,{children:i?`Close git sidebar`:`Open git sidebar`})})]}):null]})]})]}),Tn=Y(`header-safe-area relative z-10 bg-background`,Ce&&`bg-[var(--surface-background)] backdrop-blur-none`,ge&&`yuri-layout-divider-b`);return(0,$.jsx)($.Fragment,{children:(0,$.jsx)(`header`,{ref:ye,className:Tn,style:{"--padding-scale":`1`},children:ge?wn():Cn()})})};function nf(){}function rf(e){return e.projects.find(t=>t.id===e.activeProjectId)?.hostId}function af(){}var of=180,sf=640,cf=110,lf=e=>{let t=(0,ju.c)(44),{isOpen:n,isMobile:r,children:i}=e,{t:a}=Nr(),o=q(uf),s=q(df),c=q(ff),l=q(pf),[u,d]=Q.useState(null),[f,p]=Q.useState(!1),m=Q.useRef(null),h=Q.useRef(0),g=Q.useRef(o||300),_=Math.min(sf,Math.max(of,o||300)),v,y;t[0]===n?(v=t[1],y=t[2]):(v=()=>{n||(d(null),p(!1))},y=[n],t[0]=n,t[1]=v,t[2]=y),Q.useEffect(v,y);let b,x;t[3]!==s||t[4]!==r||t[5]!==n?(b=()=>{if(r||!n||!s)return;let e=()=>{let e=m.current?.parentElement?.getBoundingClientRect().height;if(!e||e<=0)return;let t=Math.max(0,Math.round(e));d(e=>e===t?e:t)};e();let t=m.current?.parentElement;if(!t)return;let i=new ResizeObserver(e);return i.observe(t),()=>{i.disconnect()}},x=[s,r,n],t[3]=s,t[4]=r,t[5]=n,t[6]=b,t[7]=x):(b=t[6],x=t[7]),Q.useEffect(b,x);let S,C;if(t[8]!==s||t[9]!==r||t[10]!==f||t[11]!==c||t[12]!==l?(S=()=>{if(r||!f||s)return;let e=e=>{let t=h.current-e.clientY,n=Math.min(sf,Math.max(of,g.current+t));c(n)},t=()=>{p(!1),q.getState().bottomTerminalHeight<=cf&&l(!1)};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t,{once:!0}),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},C=[s,r,f,c,l],t[8]=s,t[9]=r,t[10]=f,t[11]=c,t[12]=l,t[13]=S,t[14]=C):(S=t[13],C=t[14]),Q.useEffect(S,C),r)return null;let w=n?s?Math.max(0,u??_):_:0,T=n&&s,E;t[15]!==w||t[16]!==s||t[17]!==n?(E=e=>{!n||s||(p(!0),h.current=e.clientY,g.current=w,e.preventDefault())},t[15]=w,t[16]=s,t[17]=n,t[18]=E):E=t[18];let D=E,O=T?`absolute inset-x-0 bottom-0 z-40`:`relative`,k=f?`transition-none`:`transition-[height] duration-300 ease-in-out`,A=(!n||T)&&`border-t-0`,j;t[19]!==A||t[20]!==O||t[21]!==k?(j=Y(`flex overflow-hidden border-t border-border bg-sidebar`,O,k,A),t[19]=A,t[20]=O,t[21]=k,t[22]=j):j=t[22];let M;t[23]!==w||t[24]!==T?(M=T?{top:0}:{height:`${w}px`,minHeight:`${w}px`,maxHeight:`${w}px`},t[23]=w,t[24]=T,t[25]=M):M=t[25];let N=!n||!s&&w===0,P;t[26]!==D||t[27]!==s||t[28]!==n||t[29]!==f||t[30]!==a?(P=n&&!s&&(0,$.jsx)(`div`,{className:Y(`absolute left-0 top-0 z-20 h-[3px] w-full cursor-row-resize hover:bg-[var(--interactive-border)]/80 transition-colors`,f&&`bg-[var(--interactive-border)]`),onPointerDown:D,role:`separator`,"aria-orientation":`horizontal`,"aria-label":a(`terminalView.bottomDock.resizeAria`)}),t[26]=D,t[27]=s,t[28]=n,t[29]=f,t[30]=a,t[31]=P):P=t[31];let F=!n&&`pointer-events-none select-none opacity-0`,I;t[32]===F?I=t[33]:(I=Y(`relative z-10 flex h-full min-h-0 w-full flex-col transition-opacity duration-300 ease-in-out`,F),t[32]=F,t[33]=I);let L=!n,R;t[34]!==i||t[35]!==I||t[36]!==L?(R=(0,$.jsx)(`div`,{className:I,"aria-hidden":L,children:i}),t[34]=i,t[35]=I,t[36]=L,t[37]=R):R=t[37];let z;return t[38]!==j||t[39]!==M||t[40]!==N||t[41]!==P||t[42]!==R?(z=(0,$.jsxs)(`section`,{ref:m,className:j,style:M,"aria-hidden":N,children:[P,R]}),t[38]=j,t[39]=M,t[40]=N,t[41]=P,t[42]=R,t[43]=z):z=t[43],z};function uf(e){return e.bottomTerminalHeight}function df(e){return e.isBottomTerminalExpanded}function ff(e){return e.setBottomTerminalHeight}function pf(e){return e.setBottomTerminalOpen}var mf=260,hf=260,gf=500,_f=e=>Math.min(gf,Math.max(hf,e)),vf=({isOpen:e,isMobile:t,children:n,className:r,topBar:i})=>{let{t:a}=Nr(),o=q(e=>e.sidebarWidth),s=q(e=>e.setSidebarWidth),[c,l]=Q.useState(!1),u=Q.useRef(0),d=Q.useRef(o||mf),f=Q.useRef(null),p=Q.useRef(null),m=Q.useRef(null),h=Q.useRef(null),g=K(e=>{let t=m.current;t&&(t.style.width=`${e}px`,t.style.minWidth=`${e}px`,t.style.maxWidth=`${e}px`,h.current&&(h.current.style.width=`${e}px`))});if(Q.useEffect(()=>{t&&c&&l(!1)},[t,c]),Q.useEffect(()=>{c||(f.current=null,p.current=null)},[c]),t)return null;let _=Math.min(gf,Math.max(hf,o||mf)),v=e?_:0,y=t=>{if(e){try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}p.current=t.pointerId,l(!0),u.current=t.clientX,d.current=v,f.current=v,g(v),t.preventDefault()}},b=e=>{if(t||!c||p.current!==e.pointerId)return;let n=e.clientX-u.current,r=_f(d.current+n);f.current!==r&&(f.current=r,g(r))},x=e=>{if(p.current!==e.pointerId||t)return;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}let n=_f(f.current??v);p.current=null,f.current=null,l(!1),s(n)},S=c?f.current??v:v;return(0,$.jsxs)(`aside`,{ref:m,className:Y(`relative flex h-full overflow-hidden yuri-layout-divider-r will-change-[width] motion-reduce:transition-none`,`bg-sidebar yuri-vibrancy-surface`,!e&&`border-r-0`,r),style:{width:`${S}px`,minWidth:`${S}px`,maxWidth:`${S}px`,overflowX:`clip`,transitionProperty:c?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!e||v===0,children:[e&&(0,$.jsx)(`div`,{className:Y(`absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors`,c&&`bg-[var(--interactive-border)]`),onPointerDown:y,onPointerMove:b,onPointerUp:x,onPointerCancel:x,role:`separator`,"aria-orientation":`vertical`,"aria-label":a(`sidebar.resize.leftPanelAria`)}),(0,$.jsxs)(`div`,{ref:h,className:Y(`relative z-10 flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,c&&`pointer-events-none`,!e&&`pointer-events-none select-none opacity-0`),style:{width:`${c?S:_}px`,overflowX:`hidden`},"aria-hidden":!e,children:[i,(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,$.jsx)(No,{children:n})})]})]})},yf=()=>{let e=(0,ju.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={height:`var(--yuri-header-height, 3rem)`},e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-drag shrink-0`,style:{width:`var(--yuri-titlebar-left-inset, 0.75rem)`}}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`flex shrink-0`,style:t,children:[n,(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-no-drag shrink-0`,style:{width:`calc(var(--yuri-titlebar-controls-width, 5.5rem) + 0.5rem)`}}),(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-drag flex-1`})]}),e[2]=r):r=e[2],r},bf=e=>{let t=(0,ju.c)(26),{className:n}=e,{t:r}=Nr(),i=q(xf),a=_u(Sf).trim(),o=a.split(/\s+/).filter(Boolean),s=o.includes(`Yuri`),c=o.some(Cf);if(Q.useEffect(()=>{c&&ao()},[c]),o.length===0)return null;let l;t[0]===n?l=t[1]:(l=Y(`flex min-w-0 items-center overflow-hidden pb-2 pt-1`,n),t[0]=n,t[1]=l);let u=J,d;t[2]===r?d=t[3]:(d=r(`layout.brand.editName`),t[2]=r,t[3]=d);let f;t[4]===r?f=t[5]:(f=r(`layout.brand.editName`),t[4]=r,t[5]=f);let p;t[6]===i?p=t[7]:(p=()=>i(`appearance`,`appearance.sidebar-brand`),t[6]=i,t[7]=p);let m=o.join(` `),h=a.includes(`Yuri`)?`items-center`:`items-baseline`,g;t[8]===h?g=t[9]:(g=Y(`inline-flex min-w-0 gap-[0.28em] overflow-hidden whitespace-nowrap text-foreground`,h),t[8]=h,t[9]=g);let _;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(_={fontFamily:`"Syne", var(--font-sans, system-ui, sans-serif)`,fontSize:`1.0625rem`,fontWeight:700,letterSpacing:`0.08em`,lineHeight:1},t[10]=_):_=t[10];let v=a.includes(`Yuri`)?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex shrink-0 self-center`,children:(0,$.jsx)(jo,{width:24,height:24,className:`size-6`})}):null,y=o.map((e,t)=>(0,$.jsx)(`span`,{"aria-hidden":`true`,className:Y(`inline-flex shrink-0 items-baseline`,!s&&t>0&&`text-primary`),children:e===`Yuri`?(0,$.jsx)(El,{width:`2.44814cap`}):e},t)),b;t[11]!==g||t[12]!==_||t[13]!==v||t[14]!==y||t[15]!==m?(b=(0,$.jsxs)(`span`,{role:`img`,"aria-label":m,className:g,style:_,children:[v,y]}),t[11]=g,t[12]=_,t[13]=v,t[14]=y,t[15]=m,t[16]=b):b=t[16];let x;t[17]!==u||t[18]!==b||t[19]!==d||t[20]!==f||t[21]!==p?(x=(0,$.jsx)(u,{variant:`ghost`,size:`xs`,className:`app-region-no-drag min-w-0 max-w-full justify-start`,"aria-label":d,title:f,onClick:p,children:b}),t[17]=u,t[18]=b,t[19]=d,t[20]=f,t[21]=p,t[22]=x):x=t[22];let S;return t[23]!==l||t[24]!==x?(S=(0,$.jsx)(`div`,{className:l,children:x}),t[23]=l,t[24]=x,t[25]=S):S=t[25],S};function xf(e){return e.openSettingsAtItem}function Sf(e){return e.sidebarBrandName}function Cf(e){return e!==`Yuri`}var wf=`app-region-no-drag inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/75 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary hover:bg-interactive-hover hover:text-foreground transition-colors`,Tf=()=>{let e=(0,ju.c)(50),{t}=Nr(),n=un(Ef),r=sn(Df),i=n?.hostId&&r?.projectId===n.id&&r.location.hostId===n.hostId&&(!n.hubId||r.location.hubId===n.hubId)?r:null,a;e[0]!==n||e[1]!==i?(a=i?ne(i.location):n?.hostId&&n.hubId?ne({hubId:n.hubId,hostId:n.hostId,directory:n.path}):n?.path,e[0]=n,e[1]=i,e[2]=a):a=e[2];let o=a,s=q(Of),c=q(kf),l=q(Af),u=q(jf),d=_u(Mf),f=Q.useRef(null),p=Sa(Ta(`toggle_sidebar`,u)),{usesFramelessChrome:m,side:h}=oc(),g;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=C(),e[3]=g):g=e[3];let _=g,v=!_||!s||!d,b;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(b=!ae()&&!_&&y(),e[4]=b):b=e[4];let x=b,S=Pf,w,T;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>{if(typeof document>`u`)return;let e=f.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect().width;document.documentElement.style.setProperty(`--yuri-titlebar-controls-width`,`${Math.round(t)}px`)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},T=[],e[5]=w,e[6]=T):(w=e[5],T=e[6]),Q.useEffect(w,T);let E=o||void 0,D=x&&s?`${c||260}px`:void 0,O;e[7]===D?O=e[8]:(O={height:`var(--yuri-header-height, 3rem)`,paddingLeft:`var(--yuri-titlebar-left-inset, 0.75rem)`,width:D},e[7]=D,e[8]=O);let k=x&&s&&`w-full justify-between`,A;e[9]===k?A=e[10]:(A=Y(`flex items-center gap-2`,k),e[9]=k,e[10]=A);let j;e[11]===s?j=e[12]:(j=x&&s?(0,$.jsx)(bf,{className:`flex min-w-0 items-center p-0 pl-1.5`}):null,e[11]=s,e[12]=j);let M;e[13]!==m||e[14]!==h?(M=m&&h===`left`?(0,$.jsx)(ic,{visible:!0,position:`left`}):null,e[13]=m,e[14]=h,e[15]=M):M=e[15];let N;e[16]!==t||e[17]!==m?(N=m?(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:S,"aria-label":t(`header.actions.openAppMenuAria`),className:Y(wf,`shrink-0`),children:(0,$.jsx)(Z,{name:`menu-2`,className:`h-[18px] w-[18px]`})})}),(0,$.jsx)(ei,{children:(0,$.jsx)(`p`,{children:t(`header.actions.openAppMenu`)})})]}):null,e[16]=t,e[17]=m,e[18]=N):N=e[18];let P;e[19]===v?P=e[20]:(P=v?(0,$.jsx)(ol,{}):null,e[19]=v,e[20]=P);let F=ni,I;e[21]===t?I=e[22]:(I=t(`header.actions.openSessionsAria`),e[21]=t,e[22]=I);let L,R;e[23]===Symbol.for(`react.memo_cache_sentinel`)?(L=Y(wf,`group shrink-0`),R=(0,$.jsx)(Z,{name:`layout-left-rounded`,className:`size-4 text-foreground/55 transition-colors group-hover:text-foreground group-focus-visible:text-foreground`}),e[23]=L,e[24]=R):(L=e[23],R=e[24]);let z;e[25]!==I||e[26]!==l?(z=(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:l,"aria-label":I,className:L,children:R})}),e[25]=I,e[26]=l,e[27]=z):z=e[27];let ee=ei,B=t(`header.actions.openSessionsWithShortcut`,{shortcut:p}),V;e[28]===B?V=e[29]:(V=(0,$.jsx)(`p`,{children:B}),e[28]=B,e[29]=V);let te;e[30]!==ee||e[31]!==V?(te=(0,$.jsx)(ee,{children:V}),e[30]=ee,e[31]=V,e[32]=te):te=e[32];let re;e[33]!==F||e[34]!==z||e[35]!==te?(re=(0,$.jsxs)(F,{children:[z,te]}),e[33]=F,e[34]=z,e[35]=te,e[36]=re):re=e[36];let ie;e[37]!==P||e[38]!==re?(ie=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[P,re]}),e[37]=P,e[38]=re,e[39]=ie):ie=e[39];let H;e[40]!==A||e[41]!==j||e[42]!==M||e[43]!==N||e[44]!==ie?(H=(0,$.jsxs)(`div`,{ref:f,className:A,children:[j,M,N,ie]}),e[40]=A,e[41]=j,e[42]=M,e[43]=N,e[44]=ie,e[45]=H):H=e[45];let U;return e[46]!==H||e[47]!==E||e[48]!==O?(U=(0,$.jsx)(`div`,{"data-titlebar-location":E,className:`app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2`,style:O,children:H}),e[46]=H,e[47]=E,e[48]=O,e[49]=U):U=e[49],U};function Ef(e){return e.projects.find(t=>t.id===e.activeProjectId)}function Df(e){return e.remoteSession}function Of(e){return e.isSidebarOpen}function kf(e){return e.sidebarWidth}function Af(e){return e.toggleSidebar}function jf(e){return e.shortcutOverrides}function Mf(e){return e.sidebarBrandName.trim().length>0}function Nf(e){console.warn(`[titlebar] failed to open app menu`,e)}function Pf(e){let t=e.currentTarget.getBoundingClientRect();ee(`desktop_show_app_menu`,{x:t.left,y:t.bottom}).catch(Nf)}var Ff=(e,t)=>{let n=Nt(t,e);return!n||n===`.`||n===t?0:n.split(`/`).filter(Boolean).length},If=(e,t,n=10)=>{let r=Mt(e);if(!r||n<1)return[];let i=new Set,a=[];for(let e of Object.values(t))if(e)for(let t of e){if(t.type!==`directory`)continue;let e=Mt(t.path);if(!e||i.has(e))continue;let o=Ff(r,e);o<1||o>n||(i.add(e),a.push(e))}return a},Lf=e=>e.some(e=>!!Mt(e)),Rf=(e,t)=>{let n=new Set(t.map(e=>Mt(e)).filter(Boolean));return e.filter(e=>!n.has(e))},zf=(e,t,n)=>t.length===0?e.length===0:Rf(e,t).length>0?!1:t.every(e=>n.has(Mt(e))),Bf=ba(()=>Lt(()=>import(`./ToolOutputDialog-QJpQjmqK.js`).then(e=>e.n),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,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,80,81,82,83]))),Vf=e=>{let t=Wf(e);if(!t)return``;if(t===`/`||/^[A-Za-z]:\/$/.test(t))return t;let n=t.lastIndexOf(`/`);if(n<0)return t;if(n===0)return`/`;let r=t.slice(0,n);return/^[A-Za-z]:$/.test(r)?`${r}/`:r},Hf=e=>{let t=(0,ju.c)(8),{label:n,iconDataUrl:r}=e,[i,a]=Q.useState(!1),o;t[0]===n?o=t[1]:(o=n.trim().slice(0,1).toUpperCase()||`?`,t[0]=n,t[1]=o);let s=o;if(r&&!i){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>a(!0),t[2]=e):e=t[2];let n;return t[3]===r?n=t[4]:(n=(0,$.jsx)(`img`,{src:r,alt:``,className:`size-4 rounded-sm`,onError:e}),t[3]=r,t[4]=n),n}let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=Y(`size-4 rounded-sm flex items-center justify-center`,`bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground`),t[5]=c):c=t[5];let l;return t[6]===s?l=t[7]:(l=(0,$.jsx)(`span`,{className:c,children:s}),t[6]=s,t[7]=l),l},Uf=e=>e.slice().sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1),Wf=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+/g,`/`);n&&!r.startsWith(`//`)&&(r=`/${r}`);let i=r===`/`,a=/^[A-Za-z]:\/$/.test(r);return!i&&!a&&(r=r.replace(/\/+$/,``)),r},Gf=e=>e.startsWith(`/`)||e.startsWith(`//`)||/^[A-Za-z]:\//.test(e),Kf=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,qf=(e,t)=>{let n=Wf(t),r=Wf(e);if(!n||!r)return!1;let i=Kf(n),a=Kf(r);return a===i||a.startsWith(`${i}/`)},Jf=(e,t)=>{let n=Wf(t),r=Wf(e);if(!qf(r,n))return[];let i=r.slice(n.length).replace(/^\//,``).split(`/`),a=[],o=n;for(let e=0;e<i.length-1;e++)o=o?`${o}/${i[e]}`:i[e],a.push(o);return a},Yf=(e,t)=>{if(!t)return``;let n=Wf(t);if(!e||!qf(n,e))return n;let r=n.slice(e.length);return r.startsWith(`/`)?r.slice(1):r},Xf=new Set([`node_modules`]),Zf=e=>{let t=(0,ju.c)(3),{status:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={open:`var(--status-info)`,modified:`var(--status-warning)`,"git-modified":`var(--status-warning)`,"git-added":`var(--status-success)`,"git-deleted":`var(--status-error)`},t[0]=r):r=t[0];let i=r[n],a;return t[1]===i?a=t[2]:(a=(0,$.jsx)(`span`,{className:`size-2 rounded-full`,style:{backgroundColor:i}}),t[1]=i,t[2]=a),a},Qf=e=>{let t=(0,ju.c)(11),{name:n}=e,r=Q.useRef(null),i=Q.useRef(null),[a,o]=Q.useState(!1),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=r.current,t=i.current;if(!e||!t)return;let n=()=>{o(t.scrollWidth>e.clientWidth+1)};n();let a=new ResizeObserver(n);return a.observe(e),a.observe(t),()=>{a.disconnect()}},t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=[n],t[1]=n,t[2]=c),Q.useLayoutEffect(s,c);let l;t[3]===n?l=t[4]:(l=(0,$.jsx)(`span`,{ref:i,"aria-hidden":`true`,className:`invisible absolute whitespace-nowrap`,children:n}),t[3]=n,t[4]=l);let u;t[5]!==n||t[6]!==a?(u=a?(0,$.jsxs)(`span`,{className:`open-file-name-marquee-track`,children:[(0,$.jsx)(`span`,{className:`open-file-name-marquee-item`,children:n}),(0,$.jsx)(`span`,{className:`open-file-name-marquee-item`,"aria-hidden":`true`,children:n})]}):(0,$.jsx)(`span`,{className:`block min-w-0 truncate`,children:n}),t[5]=n,t[6]=a,t[7]=u):u=t[7];let d;return t[8]!==l||t[9]!==u?(d=(0,$.jsxs)(`span`,{ref:r,className:`relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap`,children:[l,u]}),t[8]=l,t[9]=u,t[10]=d):d=t[10],d},$f=e=>Xf.has(e),ep=e=>{let t=Wf(e);return t===`node_modules`||t.endsWith(`/node_modules`)||t.includes(`/node_modules/`)},tp=e=>{let t=(e instanceof Error?e.message:String(e??``)).toLowerCase();return t.includes(`is a directory`)||t.includes(`eisdir`)},np=e=>{let t=(e instanceof Error?e.message:String(e??``)).toLowerCase();return t.includes(`file not found`)||t.includes(`enoent`)||t.includes(`no such file`)||t.includes(`does not exist`)},rp=2e5,ip=`yuri:files:auto-save-enabled`,ap=e=>{let t=0,n=0;for(let r=0;r<e.length;r+=1)e.charCodeAt(r)===10&&(r>0&&e.charCodeAt(r-1)===13?t+=1:n+=1);return t>n?`\r
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToolOutputDialog-AQRtLxWE.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-auth-DA-qfGHk.js","assets/runtime-switch-DEPKHgdL.js","assets/runtime-fetch-V-iMWR8t.js","assets/reasoning-projection-client-BEhVknv9.js","assets/platform-B2ylz14u.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/pathNormalization-ewtPqJWn.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-base-ui-wXsskyKm.js","assets/vendor-react-BkccXcWz.js","assets/vendor-tanstack-react-query-DIb_ItL-.js","assets/vendor-tanstack-query-core-BSjXNgF_.js","assets/runtime-file-resource-BGZ4tGr5.js","assets/path-utils-jGozTg9d.js","assets/vendor-reactuses-core-DjKFMfz7.js","assets/vendor-lodash-es-BS45jPoZ.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/summaries-BQMyJaaw.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/runtime-file-store-BVRgEtI-.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/useUIStore-68ZPpgYA.js","assets/vendor-zustand-CTekDqaS.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/safeStorage-DTOhKN0V.js","assets/useMobileHtmlPreviewStore-BYunNOBo.js","assets/runtime-file-download-CaeLqIEY.js","assets/vendor-pierre-diffs-B0OmIhMO.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/ui-B57gL0cH.js","assets/gitApiHttp-ZjM4HkSo.js","assets/client-CmtAKi5B.js","assets/vendor-opencode-client-BM2r1f0o.js","assets/vendor-effect-X1Hqc7ba.js","assets/prompt-attachment-upload-BzYqZdzd.js","assets/uuid-D-SDZijH.js","assets/vendor-sonner-DX3nfJx4.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/remoteProjectQueries-BQzoY_Y9.js","assets/i18n-Sh2Qk9nD.js","assets/runtime-ead7P81A.js","assets/bootstrap-eLlfzqAI.js","assets/store-BGuutgkJ.js","assets/tour-CMXP3Kif.js","assets/vendor-zod-DZzbCm1s.js","assets/vendor-opencode-schema-DWT45VBX.js","assets/input-store-CzG_3qFv.js","assets/toolHelpers-iEHVHQ9p.js","assets/useAssistantUIStore-BUWPTwNV.js","assets/Icon-B4V3WArH.js","assets/vendor-framer-motion-D5NyyC73.js","assets/MobileWindowStack-DGLdgoGr.js","assets/vendor-tanstack-react-virtual-qsd3nvZb.js","assets/dialog-CSek_Z3q.js","assets/dialog-B6B8FIrL.css","assets/tap-LkQum5bB.js","assets/useThemeSystem-BIXghnHj.js","assets/appThemeRegistry-BdjrGBQ4.js","assets/themes-BgDJcxRc.js","assets/useEffectiveDirectory-BVSvX0gR.js","assets/mobileBackNavigation-DbRzQPwl.js","assets/agentColors-DWSbQXy2.js","assets/rasterizePng-056Poix7.js","assets/ImageLoadingPlaceholder-DMofO0Vg.js","assets/image-loading-DA9JEHD8.css","assets/MarkdownRenderer-CspY638V.js","assets/markdownHeightCache-DO3GzWD0.js","assets/dualLimitLru-D8Sphgua.js","assets/imageSource-qzgDdfT4.js","assets/markdownTheme-D84XyNiT.js","assets/markdown-worker-oBGEB9Eg.js","assets/DiffViewToggle-Kt7NTh6a.js","assets/touch-gestures-DOoBxhz5.js","assets/TerminalView-s8qzyQ1U.js","assets/terminalApi-wdwb9MVG.js","assets/vendor-ghostty-web-DbBrwBII.js","assets/OverlayScrollbar-TqUMJujL.js","assets/device-TCHW5U2y.js","assets/useProjectRuntimeAPIs-Co1VAzSK.js","assets/sortable-tabs-strip-CmCxOwOO.js","assets/vendor-dnd-kit-core-qy5stxu5.js","assets/vendor-dnd-kit-accessibility-u0XSXxKq.js","assets/vendor-dnd-kit-sortable-CiTIuX4o.js","assets/useTerminalStore-C_QzSEgP.js","assets/useFontPreferences-C4dQT72k.js","assets/project-preview-yQerlKs2.js","assets/relay-preview-frame-src-BPyz3nXA.js","assets/projectActions-B11KAI3f.js","assets/DiagramView-BvRz7w00.js","assets/diagram-Re1b4Drg.js","assets/vendor-react-drawio-C9rszQEJ.js","assets/SettingsView-yDGWdErX.js","assets/desktopHosts-COI-czjF.js","assets/desktopRelayRestore-BEPNc7qb.js","assets/vendor-codemirror-autocomplete-C0FrlFqZ.js","assets/ScrollableOverlay-DNBsKLrs.js","assets/tooltip-D5wqtxlx.js","assets/react-CPBNl-S9.js","assets/dropdown-menu-D_C8_7Xw.js","assets/dropdown-menu.styles-BDla58Rm.js","assets/context-menu-BjSM4m3u.js","assets/collapsible-Cv0Ew8UR.js","assets/textarea-BMiRyX6F.js","assets/gitApi-Bz38D_S1.js","assets/GuiPluginMount-DCZZ6cEG.js","assets/MobileHtmlNetworkBoundary-C3w-rvNJ.js","assets/input-C5gthyYl.js","assets/shortcuts-BF4EX_Rx.js","assets/assistantQueries-CKIDS7If.js","assets/MobileDetailNavigation-fIpP3zJ9.js","assets/pwa-DY4ywKCC.js","assets/vendor-simplewebauthn-browser-Dwhcdg_5.js","assets/ErrorBoundary-DMpwAWMc.js","assets/card-DKTuTAht.js","assets/ProviderLogo-Dh2oKu37.js","assets/zhipuai-coding-plan-CcFj8zKy.js","assets/select-BXiRJQfM.js","assets/MobileResizableSheet-CmMITCRX.js","assets/githubAuthQueries-3AJp5LD5.js","assets/projectMeta-vIaGFaQr.js","assets/timeFormat-BaiPCZgf.js","assets/permission-rules-DoQUXKll.js","assets/useQuotaStore-CHxR2ZkD.js","assets/quota-jMPnmJTS.js","assets/router-DXUi1sBd.js","assets/contextPanelEmbeddedChat-Dm5R_b5X.js","assets/sessionOwnership-DGgtXHNT.js","assets/types-BjDNwP80.js","assets/checkbox-BDifu847.js","assets/mcpQueries-CCcPl38n.js","assets/usePluginsStore-CP3eeHCz.js","assets/switch-DaczlfD6.js","assets/SettingsGroup-DBUgdYyK.js","assets/useMcpConfigStore-BCol_XdF.js","assets/native-config-Di2EbpNU.js","assets/YuriLogo-1yVZFnVN.js","assets/MobileTabPageHeader-BKkxpg00.js","assets/MobileSurface-BveBoewm.js","assets/GuiPluginWindow-DI08lit_.js","assets/pluginPresentation-CWDQXAGY.js","assets/ModelLogo-BSDCUld6.js","assets/useDictation-83-qDgkn.js","assets/audio-session-BFWjrDbp.js","assets/browserVoiceService-x5Pci8L3.js","assets/speechSettingsQueries-ClTsMdAi.js","assets/pluginPresentation-C0HSdVvS.css","assets/ModelSelector-DcIUMkrC.js","assets/useModelLists-BfC2IQwO.js","assets/useOpenCodeReadiness-BHY0hseI.js","assets/AgentSelector-5iXNLoIx.js","assets/AgentAvatar-uZt0-TOc.js","assets/vendor-dicebear-core-CV95S5Pg.js","assets/vendor-dicebear-styles-C4OfoX7R.js","assets/AssistantsSettingsPage-B52Fwaza.js","assets/MobileShareBridge-DRywmiRN.js","assets/mobileConnections-BtrjKVQ8.js","assets/assistantPresentation-DRbsH1Ej.js","assets/scheduledTaskNavigation-r3g3DfXq.js","assets/vendor-qrcode-D7jBCyl-.js","assets/vendor-dijkstrajs-BAzPDGZM.js","assets/ArchivedSessionsDialog-BvaC7Izk.js","assets/vendor-codemirror-lang-angular-Cm7vBE3E.js","assets/vendor-codemirror-lang-json-DowyFczU.js","assets/vendor-codemirror-lang-markdown-npWBZIoE.js","assets/vendor-codemirror-lang-python-OPRdU26g.js","assets/vendor-codemirror-legacy-modes-DwltVFbT.js","assets/MobileOverlayPanel-DqVr7HoM.js","assets/worktreeManager-nlQu_BbV.js","assets/vendor-codemirror-commands-5saeUOVY.js","assets/vendor-codemirror-search-hZY-L2l8.js","assets/vendor-replit-codemirror-vim-BmQmU1lR.js","assets/vendor-codemirror-language-data-B3pLWvv-.js","assets/vendor-yaml-C9KlJAlj.js","assets/SettingsWindow-tYCzlPbh.js","assets/MultiRunWindow-CC0gEHEt.js","assets/multirun-0sGmTbAW.js","assets/useGitStore-D5j-CYlL.js","assets/insertionBoundaries-DYPFjCrm.js","assets/spacedFileMention-Ds4GtgiF.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/useDebouncedValue-BHlMPqY8.js","assets/fileMentionTouchSelection-DySVh4tf.js","assets/vendor-fuzzysort-ukaRp9PC.js","assets/fileMentionAutocompleteState-B9411b4o.js","assets/worktreeSourceBranchPreference-BGrLknHI.js","assets/AssistantView-Cn3wym_C.js","assets/mobileAppContext-BQgdTp5T.js","assets/AssistantConversationSurface-ltD21S9d.js","assets/LoadingImage-BBXprBjU.js","assets/chatUpwardIntent-D2Ay65Ri.js","assets/reference-history-CH-irHvl.js","assets/reference-history-8C8nv-EP.css","assets/vendor-motion-vLNN8EMu.js","assets/assistant-attachment-cache-CIij0OGm.js","assets/AssistantWorkingAvatar-3IFgfMI5.js","assets/AssistantSessionCard-BQVPnkZz.js","assets/sessionChangeSummary-BCF9VwAA.js","assets/sessionLookup-EXBDKdL9.js","assets/AssistantConversationSurface-B59k-lXE.css","assets/AssistantUnreadBadge-BSVpexQe.js","assets/sortAssistantContacts-CcEdm3mS.js","assets/assistantMessagePreview-B1M5pz20.js","assets/navigation-By33kYra.js","assets/OnboardingScreen-CgYmkOnG.js","assets/openSessionFromDeepLink-BI3ok38A.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,c as n,i as r,p as i,t as a,v as o,w as s}from"./runtime-auth-DA-qfGHk.js";import{c,f as l,i as u,n as d,o as f,r as p,s as m,t as h}from"./runtime-switch-DEPKHgdL.js";import{n as g}from"./runtime-fetch-V-iMWR8t.js";import{$ as _,A as v,B as y,E as b,F as x,G as S,I as C,K as w,L as T,R as E,U as D,W as O,Z as k,a as A,at as j,c as M,ct as N,d as P,dt as F,et as I,f as L,ft as R,g as z,j as ee,k as B,l as V,lt as te,s as ne,u as re,ut as ie,z as ae}from"./platform-B2ylz14u.js";import{n as H,t as U}from"./runtimeAPIRegistry-C2VogTny.js";import{d as oe,h as W,m as se,r as ce,v as le}from"./desktopHosts-COI-czjF.js";import{a as ue,i as de,t as fe}from"./vendor-zustand-CTekDqaS.js";import{A as pe,B as me,C as he,H as ge,M as _e,P as ve,S as ye,V as be,b as xe,it as Se,j as Ce,k as we,ot as Te,st as Ee,v as De,x as Oe,y as ke,z as Ae}from"./vendor-base-ui-wXsskyKm.js";import{Ct as je,Et as Me,Ft as Ne,Mt as Pe,Pt as Fe,St as G,Tt as Ie,an as Le,jt as Re,on as ze,wt as Be,xt as Ve}from"./gitApiHttp-ZjM4HkSo.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as He,r as Ue,t as We}from"./safeStorage-DTOhKN0V.js";import{B as Ge,H as Ke,Jt as qe,Rt as Je,St as Ye,Xt as Xe,Zt as Ze,an as Qe,ft as $e,ht as et,mt as tt,n as nt,on as rt,qt as it,rn as at,tn as ot,vr as st,zt as ct}from"./client-CmtAKi5B.js";import{P as lt,d as ut,z as dt}from"./prompt-attachment-upload-BzYqZdzd.js";import{n as ft}from"./pathNormalization-ewtPqJWn.js";import{n as pt,t as mt}from"./vendor-react-BkccXcWz.js";import{f as ht,u as gt}from"./vendor-tanstack-query-core-BSjXNgF_.js";import{n as _t,o as vt,s as yt}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{E as bt,I as xt,O as St,P as Ct,R as wt,W as Tt,c as Et,r as Dt,s as Ot,t as kt,y as At,z as jt}from"./runtime-file-resource-BGZ4tGr5.js";import{a as Mt,n as Nt}from"./path-utils-jGozTg9d.js";import{h as Pt,m as Ft,r as K}from"./vendor-reactuses-core-DjKFMfz7.js";import{r as It}from"./summaries-BQMyJaaw.js";import{o as Lt}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{a as Rt,i as zt,o as Bt,r as q,s as Vt,t as Ht}from"./useUIStore-68ZPpgYA.js";import{o as Ut}from"./useMobileHtmlPreviewStore-BYunNOBo.js";import{n as Wt,r as Gt}from"./terminalApi-wdwb9MVG.js";import{a as Kt}from"./types-BjDNwP80.js";import{t as qt}from"./bootstrap-eLlfzqAI.js";/* empty css */import{U as Jt}from"./vendor-codemirror-autocomplete-C0FrlFqZ.js";import{n as Yt}from"./vendor-pierre-diffs-B0OmIhMO.js";import{$r as Xt,A as Zt,Ai as Qt,Bi as $t,Ci as en,Et as tn,F as nn,Fa as rn,Fi as an,Fn as on,Ga as sn,Gr as cn,H as ln,Ha as un,Hr as dn,I as fn,Ii as pn,Kr as mn,Mi as hn,Ni as gn,Oi as _n,R as vn,S as yn,St as bn,Tt as xn,U as Sn,Ur as Cn,Vi as wn,Vr as Tn,W as En,Wa as Dn,Xi as On,Xn as J,Yi as kn,Yr as An,Zi as jn,Zr as Mn,_n as Nn,an as Pn,ao as Fn,at as In,b as Ln,br as Rn,bt as zn,ci as Bn,co as Vn,ct as Hn,da as Un,dn as Wn,ei as Gn,f as Kn,ft as qn,gt as Jn,h as Yn,ht as Xn,io as Y,ji as Zn,k as Qn,lo as $n,lt as er,mi as tr,mt as nr,nt as rr,o as ir,on as ar,oo as or,or as sr,p as cr,qt as lr,ra as ur,ro as dr,so as fr,st as pr,t as X,tt as mr,ui as hr,uo as gr,ut as _r,v as vr,wt as yr,x as br,xr,xt as Sr,y as Cr}from"./ui-B57gL0cH.js";import{n as Z,t as wr}from"./Icon-B4V3WArH.js";import{d as Tr,h as Er,m as Dr,p as Or}from"./remoteProjectQueries-BQzoY_Y9.js";import{a as kr,i as Ar,n as jr,r as Mr,t as Nr}from"./i18n-Sh2Qk9nD.js";import{n as Pr}from"./store-BGuutgkJ.js";import{n as Fr}from"./input-store-CzG_3qFv.js";import{a as Ir,c as Lr,i as Rr,l as zr,o as Br,s as Vr}from"./toolHelpers-iEHVHQ9p.js";import{n as Hr}from"./useAssistantUIStore-BUWPTwNV.js";import{n as Ur,t as Wr}from"./ScrollableOverlay-DNBsKLrs.js";import{n as Gr,o as Kr}from"./vendor-framer-motion-D5NyyC73.js";import{a as qr,i as Jr,n as Yr,o as Xr,r as Zr,t as Qr}from"./dialog-CSek_Z3q.js";import{i as $r,n as ei,r as ti,t as ni}from"./tooltip-D5wqtxlx.js";import{n as ri,t as ii}from"./useInlineCommentDraftStore-CvSDMS3T.js";import{n as ai}from"./useThemeSystem-BIXghnHj.js";import{a as oi,i as si,n as ci,r as li,t as ui}from"./useProjectGitActions-B8Frm8fF.js";import{a as di,r as fi}from"./device-TCHW5U2y.js";import{t as pi}from"./SyncActions-CIiH2YAa.js";import{i as mi,n as hi,r as gi,t as _i}from"./dropdown-menu.styles-BDla58Rm.js";import{c as vi,i as yi,n as bi,r as xi,s as Si,t as Ci}from"./dropdown-menu-D_C8_7Xw.js";import{a as wi,i as Ti,n as Ei,r as Di,t as Oi}from"./context-menu-BjSM4m3u.js";import{n as ki,r as Ai,t as ji}from"./collapsible-Cv0Ew8UR.js";import{a as Mi,i as Ni,n as Pi,o as Fi,r as Ii}from"./PierreDiffViewer-D5Q_DJ23.js";import{n as Li,t as Ri}from"./kbd-DzULFVDy.js";import{t as zi}from"./DiffWorkerProvider-VFPkag9y.js";import{n as Bi,t as Vi}from"./appThemeRegistry-BdjrGBQ4.js";import{r as Hi}from"./themes-BgDJcxRc.js";import{n as Ui,t as Wi}from"./useEffectiveDirectory-BVSvX0gR.js";import{n as Gi,t as Ki}from"./useProjectRuntimeAPIs-Co1VAzSK.js";import{b as qi,h as Ji,m as Yi}from"./gitApi-Bz38D_S1.js";import{a as Xi,o as Zi,s as Qi}from"./useGitStore-D5j-CYlL.js";import{a as $i,i as ea,n as ta,o as na,r as ra,s as ia,t as aa}from"./useProjectGitStore-CqjQngOX.js";import{i as oa,n as sa,r as ca}from"./MobileHtmlNetworkBoundary-C3w-rvNJ.js";import{n as la,t as ua}from"./relay-preview-frame-src-BPyz3nXA.js";import{a as da,i as fa,n as pa,r as ma,t as ha}from"./BinaryFileFallback-CqaGa-BI.js";import{t as ga}from"./ImageLoadingPlaceholder-DMofO0Vg.js";import{t as _a}from"./LoadingImage-BBXprBjU.js";import{t as va}from"./input-C5gthyYl.js";import{n as ya,o as ba}from"./MarkdownRenderer-CspY638V.js";import{c as xa,i as Sa,l as Ca,n as wa,o as Ta,s as Ea}from"./shortcuts-BF4EX_Rx.js";import{n as Da,r as Oa}from"./SessionSurfaceContext-BP4NCKp6.js";import{o as ka}from"./useSessionBtwStore-CZ0QND4b.js";import{t as Aa}from"./useDebouncedValue-BHlMPqY8.js";import{m as ja,x as Ma,y as Na}from"./assistantQueries-CKIDS7If.js";import{A as Pa,C as Fa,D as Ia,E as La,F as Ra,I as za,M as Ba,N as Va,O as Ha,P as Ua,R as Wa,S as Ga,T as Ka,_ as qa,b as Ja,c as Ya,d as Xa,f as Za,g as Qa,h as $a,i as eo,j as to,k as no,l as ro,m as io,n as ao,p as oo,s as so,t as co,u as lo,v as uo,w as fo,x as po,y as mo,z as ho}from"./useAppFontEffects-C1DyabMJ.js";import{D as go,E as _o,J as vo,S as yo,_ as bo,b as xo,c as So,d as Co,f as wo,it as To,m as Eo,u as Do,v as Oo,x as ko,y as Ao}from"./pwa-DY4ywKCC.js";import{t as jo}from"./YuriLogo-1yVZFnVN.js";import{t as Mo}from"./card-DKTuTAht.js";import{t as No}from"./ErrorBoundary-DMpwAWMc.js";import{a as Po,n as Fo,o as Io,r as Lo}from"./contextPanelEmbeddedChat-Dm5R_b5X.js";import{i as Ro,r as zo}from"./connection-hint-Dk_9Oxi7.js";import{u as Bo}from"./insertionBoundaries-DYPFjCrm.js";import{t as Vo}from"./ModelLogo-BSDCUld6.js";import{_ as Ho,a as Uo,c as Wo,d as Go,f as Ko,i as qo,l as Jo,n as Yo,o as Xo,p as Zo,r as Qo,s as $o,u as es,y as ts}from"./ChatContainer-Hwe0YX5J.js";import{C as ns,i as rs,n as is,r as as}from"./BtwPanel-grnSijXt.js";import{A as os,D as ss,E as cs,M as ls,O as us,P as ds,T as fs,X as ps,j as ms,k as hs}from"./BusyDots-43VHGWaC.js";import{_ as gs,i as _s,l as vs,n as ys,s as bs,t as xs,v as Ss}from"./vendor-dnd-kit-core-qy5stxu5.js";import{a as Cs,n as ws,s as Ts,t as Es}from"./vendor-dnd-kit-sortable-CiTIuX4o.js";import{t as Ds}from"./MobileOverlayPanel-DqVr7HoM.js";import{t as Os}from"./ProviderLogo-Dh2oKu37.js";import{d as ks}from"./ToolOutputDialog-AQRtLxWE.js";import{t as As}from"./vendor-motion-vLNN8EMu.js";import{c as js,i as Ms,n as Ns,s as Ps,t as Fs}from"./select-BXiRJQfM.js";import{a as Is}from"./githubAuthQueries-3AJp5LD5.js";import{c as Ls,i as Rs,n as zs,s as Bs}from"./worktreeManager-nlQu_BbV.js";import{t as Vs}from"./sortable-tabs-strip-CmCxOwOO.js";import{i as Hs}from"./auto-read-context-m-DSqlLf.js";import{n as Us,t as Ws}from"./timeFormat-BaiPCZgf.js";import{a as Gs,c as Ks,i as qs,n as Js,o as Ys,r as Xs,u as Zs}from"./useQuotaStore-CHxR2ZkD.js";import{a as Qs,i as $s,n as ec,s as tc,t as nc}from"./quota-jMPnmJTS.js";import{i as rc,n as ic,r as ac,t as oc}from"./useDesktopWindowControlsLayout-BS_7xRdK.js";import{n as sc,t as cc}from"./sessionChangeSummary-BCF9VwAA.js";import{n as lc,t as uc}from"./openRemoteProjectSession-CtDnPbHy.js";import{t as dc}from"./useTerminalStore-C_QzSEgP.js";import{$ as fc,A as pc,At as mc,B as hc,Bt as gc,Ct as _c,D as vc,Dt as yc,E as bc,F as xc,Ft as Sc,G as Cc,H as wc,Ht as Tc,I as Ec,It as Dc,J as Oc,K as kc,L as Ac,Lt as jc,M as Mc,Mt as Nc,N as Pc,Nt as Fc,O as Ic,Ot as Lc,P as Rc,Pt as zc,Q as Bc,R as Vc,Rt as Hc,S as Uc,St as Wc,U as Gc,Vt as Kc,W as qc,Y as Jc,Z as Yc,a as Xc,at as Zc,b as Qc,bt as $c,et as el,g as tl,i as nl,it as rl,j as il,jt as al,k as ol,kt as sl,n as cl,nt as ll,o as ul,ot as dl,q as fl,r as pl,rt as ml,s as hl,tt as gl,v as _l,vt as vl,w as yl,x as bl,xt as xl,y as Sl,yt as Cl,z as wl,zt as Tl}from"./runtimeEndpointReset-7jsAdYmA.js";import{t as El}from"./YuriWordmark-CqkcfAJl.js";import{_ as Dl,d as Ol,g as kl,h as Al,m as jl,p as Ml,r as Nl,t as Pl,v as Fl,y as Il}from"./sessionOwnership-DGgtXHNT.js";import{i as Ll,n as Rl}from"./icons-Du1K-vJd.js";import{r as zl,t as Bl}from"./navigation-By33kYra.js";import{t as Vl}from"./AssistantUnreadBadge-BSVpexQe.js";import{n as Hl,t as Ul}from"./GuiPluginPage-D5uAYpR9.js";import{d as Wl,i as Gl,n as Kl,r as ql,u as Jl}from"./historyImportQueries-B_mfphxe.js";import{n as Yl}from"./ScheduledTasksDialog-BI5Y_mbe.js";import{t as Xl}from"./ChatView-Ei6tfxCe.js";import{t as Zl}from"./diagram-Re1b4Drg.js";import{t as Ql}from"./DiffView-X_cPRpka.js";import{a as $l,i as eu,n as tu,o as nu,r as ru,t as iu}from"./multirun-0sGmTbAW.js";import{_ as au,a as ou,c as su,d as cu,f as lu,g as uu,h as du,i as fu,l as pu,m as mu,o as hu,p as gu,r as _u,s as vu,t as yu,u as bu}from"./ArchivedSessionsDialog-BvaC7Izk.js";import{a as xu,i as Su,n as Cu,r as wu,t as Tu}from"./projectActions-B11KAI3f.js";import{t as Eu}from"./GuiPluginTitlebarItems-C36UkPLK.js";import{t as Du}from"./vendor-zumer-snapdom-yq9vlCKr.js";import{n as Ou,t as ku}from"./vendor-html-to-image-BDMm2v6d.js";var Q=e(Ee(),1),Au=mt(),ju=pt(),$=Te();function Mu(e){let t=(0,ju.c)(14),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({size:i,className:n,style:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=typeof i==`number`?`${i}px`:i,s=typeof i==`number`?`${i}px`:i,c;t[5]!==a||t[6]!==o||t[7]!==s?(c={width:o,height:s,...a},t[5]=a,t[6]=o,t[7]=s,t[8]=c):c=t[8];let l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`path`,{d:`M112,148a12,12,0,0,0-12,12v19L69.17,148.2A4,4,0,0,1,68,145.37V97.94a36,36,0,1,0-24,0v47.43a27.81,27.81,0,0,0,8.2,19.8L83,196H64a12,12,0,0,0,0,24h48a12,12,0,0,0,12-12V160A12,12,0,0,0,112,148ZM56,52A12,12,0,1,1,44,64,12,12,0,0,1,56,52ZM212,158.06V110.63a27.81,27.81,0,0,0-8.2-19.8L173,60h19a12,12,0,0,0,0-24H144a12,12,0,0,0-12,12V96a12,12,0,0,0,24,0V77l30.83,30.83a4,4,0,0,1,1.17,2.83v47.43a36,36,0,1,0,24,0ZM200,204a12,12,0,1,1,12-12A12,12,0,0,1,200,204Z`}),t[9]=l):l=t[9];let u;return t[10]!==n||t[11]!==r||t[12]!==c?(u=(0,$.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 256 256`,fill:`currentColor`,className:n,style:c,...r,children:l}),t[10]=n,t[11]=r,t[12]=c,t[13]=u):u=t[13],u}var Nu=!1,Pu=0,Fu=new Set,Iu=async()=>{let e=++Pu;try{let t=await ee(`desktop_is_window_fullscreen`);if(e!==Pu||t===Nu)return;Nu=t===!0,Fu.forEach(e=>e())}catch{}},Lu=e=>C()?(Fu.add(e),Fu.size===1&&(window.addEventListener(`yuri:window-resized`,Iu),Iu()),()=>{Fu.delete(e),Fu.size===0&&(window.removeEventListener(`yuri:window-resized`,Iu),Pu++,Nu=!1)}):()=>{};function Ru(){return(0,Q.useSyncExternalStore)(Lu,Bu,zu)}function zu(){return!1}function Bu(){return Nu}function Vu(){let e=(0,ju.c)(19),{t}=Nr(),n=q(Ku),r=q(Gu),i=q(Wu),a=q(Uu),o=q(Hu),s=n&&r||i,c;e[0]!==n||e[1]!==r||e[2]!==i||e[3]!==a||e[4]!==o?(c=()=>{if(!r){n||a(!0),o(!i);return}a(!n)},e[0]=n,e[1]=r,e[2]=i,e[3]=a,e[4]=o,e[5]=c):c=e[5];let l=K(c),u;e[6]===t?u=e[7]:(u=t(`header.workStatusPanel.toggleAria`),e[6]=t,e[7]=u);let d;e[8]===t?d=e[9]:(d=t(`header.workStatusPanel.toggleAria`),e[8]=t,e[9]=d);let f=s?`text-foreground`:`text-muted-foreground/50`,p;e[10]===f?p=e[11]:(p=Y(`app-region-no-drag size-7`,f),e[10]=f,e[11]=p);let m;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(Z,{name:`settings-2`,className:`size-4`}),e[12]=m):m=e[12];let h;return e[13]!==s||e[14]!==u||e[15]!==d||e[16]!==p||e[17]!==l?(h=(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,"data-work-status-toggle":`true`,"aria-pressed":s,"aria-label":u,title:d,onClick:l,className:p,children:m}),e[13]=s,e[14]=u,e[15]=d,e[16]=p,e[17]=l,e[18]=h):h=e[18],h}function Hu(e){return e.setWorkStatusOverlayOpen}function Uu(e){return e.setWorkStatusPanelEnabled}function Wu(e){return e.workStatusOverlayOpen}function Gu(e){return e.workStatusPanelFits}function Ku(e){return e.workStatusPanelEnabled}var qu=(e,t,n)=>vt({queryKey:[`desktop-host-inventory`,e],queryFn:async({signal:e})=>{let r=await ce(),i=new Set(r.sshHostIds??[]);if(r.sshHostIds===void 0&&P()){let e=await vo();for(let t of e.instances)i.add(t.id)}return e.throwIfAborted(),{hosts:r.hosts.filter(e=>se(e,i)||t===`host:${e.id}`||!!(n&&W(n,oe(e)))),sshIds:i}}});function Ju(e){let t=(0,ju.c)(18),{onClick:n,open:r}=e,{t:i}=Nr(),a=Q.useSyncExternalStore(c,u,u),o=q(Yu),s=p(),l=h(),d=x(),{data:f}=yt({...qu(a,s,l),enabled:!o}),m=s.startsWith(`host:`)?s.slice(5):null,g=f?.hosts.find(e=>m?e.id===m:!!(l&&W(l,oe(e))));if(d&&!f?.hosts.length&&!f?.sshIds.size)return null;let _=g?le(g.label):i(d?`desktopHostSwitcher.instance.local`:`desktopHostSwitcher.title`),v=Ra({isLocal:d,isSsh:!!(g&&f?.sshIds.has(g.id)),isRelay:a.startsWith(`relay:`)}),y=ni,b=$r,S=J,C=i(`header.actions.sessionMenu.servicesWithInstance`,{current:_}),w;t[0]===v?w=t[1]:(w=(0,$.jsx)(`span`,{className:`inline-flex h-full w-7 items-center justify-center`,children:(0,$.jsx)(Z,{name:v,className:`size-5`})}),t[0]=v,t[1]=w);let T;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(`span`,{className:`inline-flex h-full w-3 items-center justify-center`,children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`size-2.5`})}),t[2]=T):T=t[2];let E;t[3]!==S||t[4]!==n||t[5]!==r||t[6]!==C||t[7]!==w?(E=(0,$.jsxs)(S,{variant:`ghost`,size:`sm`,className:`app-region-no-drag h-7 w-12 gap-0 self-center rounded-md border border-border/40 px-1 py-0 text-muted-foreground hover:text-foreground`,"aria-label":C,"aria-expanded":r,"aria-haspopup":`menu`,onClick:n,children:[w,T]}),t[3]=S,t[4]=n,t[5]=r,t[6]=C,t[7]=w,t[8]=E):E=t[8];let D;t[9]!==b||t[10]!==E?(D=(0,$.jsx)(b,{asChild:!0,children:E}),t[9]=b,t[10]=E,t[11]=D):D=t[11];let O;t[12]===_?O=t[13]:(O=(0,$.jsx)(ei,{children:_}),t[12]=_,t[13]=O);let k;return t[14]!==y||t[15]!==O||t[16]!==D?(k=(0,$.jsxs)(y,{children:[D,O]}),t[14]=y,t[15]=O,t[16]=D,t[17]=k):k=t[17],k}function Yu(e){return e.isSettingsDialogOpen}var Xu=[{id:`finder`,label:`Finder`,appName:`Finder`},{id:`terminal`,label:`Terminal`,appName:`Terminal`},{id:`iterm2`,label:`iTerm2`,appName:`iTerm`},{id:`ghostty`,label:`Ghostty`,appName:`Ghostty`},{id:`vscode`,label:`VS Code`,appName:`Visual Studio Code`},{id:`vscode-insiders`,label:`VS Code Insiders`,appName:`Visual Studio Code - Insiders`},{id:`intellij`,label:`IntelliJ`,appName:`IntelliJ IDEA`},{id:`visual-studio`,label:`Visual Studio`,appName:`Visual Studio`},{id:`cursor`,label:`Cursor`,appName:`Cursor`},{id:`android-studio`,label:`Android Studio`,appName:`Android Studio`},{id:`pycharm`,label:`PyCharm`,appName:`PyCharm`},{id:`xcode`,label:`Xcode`,appName:`Xcode`},{id:`sublime-text`,label:`Sublime`,appName:`Sublime Text`},{id:`webstorm`,label:`WebStorm`,appName:`WebStorm`},{id:`rider`,label:`Rider`,appName:`Rider`},{id:`zed`,label:`Zed`,appName:`Zed`},{id:`wu`,label:`Wu`,appName:`Wu`},{id:`phpstorm`,label:`PhpStorm`,appName:`PhpStorm`},{id:`eclipse`,label:`Eclipse`,appName:`Eclipse`},{id:`windsurf`,label:`Windsurf`,appName:`Windsurf`},{id:`vscodium`,label:`VSCodium`,appName:`VSCodium`},{id:`rustrover`,label:`RustRover`,appName:`RustRover`},{id:`kiro`,label:`Kiro`,appName:`Kiro`},{id:`antigravity`,label:`Antigravity`,appName:`Antigravity`},{id:`trae`,label:`Trae`,appName:`Trae`}],Zu=`finder`,Qu=new Set([`finder`,`terminal`]),$u=e=>typeof window<`u`&&window.__YURI_PLATFORM__===`win32`&&e.id===`finder`?{...e,label:`Explorer`,appName:`File Explorer`}:e,ed=e=>{if(!e)return null;let t=Xu.find(t=>t.id===e)??null;return t?$u(t):null},td=()=>Xu.filter(e=>Qu.has(e.id)).map(e=>({...$u(e)})),nd=e=>{let t=new Map(e.map(e=>[e.name,e]));return Xu.filter(e=>t.has(e.appName)||Qu.has(e.id)).map(e=>{let n=t.get(e.appName);return{...$u(e),...e.id===`terminal`&&n?.appName&&n.label?{appName:n.appName,label:n.label}:{},iconDataUrl:n?.iconDataUrl??void 0}})},rd=()=>{if(typeof window>`u`)return Zu;let e=window.localStorage.getItem(`openInAppId`);return e&&ed(e)?e:Zu},id=!1,ad=!1,od=!1,sd=0,cd=null,ld=()=>{cd&&=(clearTimeout(cd),null)},ud=ue()((e,t)=>({selectedAppId:rd(),availableApps:td(),hasLoadedApps:!1,isCacheStale:!1,isScanning:!1,initialize:()=>{if(id||typeof window>`u`)return;id=!0;let n=(t,n=!0)=>{if(!Array.isArray(t)||t.length===0){e({availableApps:td(),hasLoadedApps:n});return}e({availableApps:nd(t),hasLoadedApps:!0})},r=async i=>{if(!C()||ad||t().hasLoadedApps&&!i)return;let a=Xu.map(e=>e.appName);ld(),i&&e({hasLoadedApps:!1}),ad=!0,od=!1,e({isScanning:!0});try{let{apps:t,success:o,hasCache:s,isCacheStale:c}=await z(a,i),l=o&&!s&&t.length===0&&sd<3;if(e({isCacheStale:s?c:!1}),n(t,o?!l:!1),o){if(l){let e=[800,1600,3200][sd]??3200;sd+=1,od=!0,cd=setTimeout(()=>{r()},e);return}sd=0,od=!1;return}if(sd<3){let e=[1e3,3e3,7e3][sd]??7e3;sd+=1,od=!0,cd=setTimeout(()=>{r()},e)}}finally{ad=!1,od||e({isScanning:!1})}};r(),window.addEventListener(`yuri:settings-synced`,t=>{let n=t.detail,r=n&&typeof n.openInAppId==`string`&&n.openInAppId.length>0&&ed(n.openInAppId)?n.openInAppId:null;r&&(window.localStorage.setItem(`openInAppId`,r),e({selectedAppId:r}))}),window.addEventListener(`yuri:app-ready`,()=>{r()}),window.addEventListener(`yuri:installed-apps-updated`,t=>{let r=t.detail;Array.isArray(r)&&(sd=3,od=!1,e({isScanning:!1,isCacheStale:!1}),n(r))}),window.__yuriAppReady&&r(),window.setTimeout(()=>{t().hasLoadedApps||r()},5e3)},loadInstalledApps:async n=>{if(id||t().initialize(),!C()||ad||t().hasLoadedApps&&!n)return;let r=Xu.map(e=>e.appName);ld(),n&&e({hasLoadedApps:!1}),ad=!0,od=!1,e({isScanning:!0});try{let{apps:t,hasCache:i,isCacheStale:a}=await z(r,n),o=nd(t);e({availableApps:o.length>0?o:td(),hasLoadedApps:o.length>0,isCacheStale:i?a:!1})}finally{ad=!1,od||e({isScanning:!1})}},selectApp:async t=>{ed(t)&&(e({selectedAppId:t}),typeof window<`u`&&window.localStorage.setItem(`openInAppId`,t),await Ne({openInAppId:t}))}})),dd=(e=p(),t=u())=>{let n=e.startsWith(`host:`)?e.slice(5):null;return{queryKey:[t,`ssh-editor-apps`,n],enabled:C()&&v()&&n!==null,queryFn:async({signal:e})=>{let t=await ee(`desktop_ssh_editor_apps`,{hostId:n});return e.throwIfAborted(),t?{hostId:n,appIds:t.appIds}:null}}},fd=()=>{let e=(0,ju.c)(3),t=(0,Q.useSyncExternalStore)(c,p,pd),n=(0,Q.useSyncExternalStore)(c,u,md),r;return e[0]!==t||e[1]!==n?(r=dd(t,n),e[0]=t,e[1]=n,e[2]=r):r=e[2],yt(r)};function pd(){return``}function md(){return``}var hd=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAXaSURBVFgJ7VddbBRVFP5mdme6dOnu2tZawOAPjfxU+bGQYCRAsvw8qNGEQPTRJ0I0amL0wfjgA/HBR8KLD8YgDxJEUkVFxSYYTSRii6DQQCMGIQqlW7p0u+zMzo/fuTuzO9Nt0Td94CRn7pl7z5zznZ977y5wh/7jDGiz+T979qD5Ujbfd90xlll+stOF1uI40B1+4HhkjnZk9CgLQ9iXp2/BdcbgVc/h0sAgduywudJEMwLY9Of4ugtW5p3CpL7W1jTN88VmjdQYvnDKF1mczkYuNZLeCVg3X8fa9u+nqzUB2HRpdN2pSseRQknPoUL1Jo2ICTrPGcCzdwPdHENcAnicKRqcAk7cpL5J1r0JlAtPYV1XDETM/FtH3m19r+f5by+XjNX/xnmCX3/cCzydi4CKiC7lw+PArhGgoPPFq/6E0+9vwM6d5VBNpuv03cLNfeNTRh9KnJIiV2/PvSngycC5RD+dE5zb3g7s6QESzAZc2l6wuY9SnWIAxv10r81uU85Vt1FvtpEtlc/SMFUkUofeZ2IBta0DWDmXgkfbyTRz1qAYAMczOz3p1elOxYPyEllj421hdELViPO6Kudk3ia3UGe5ABDbvtnJZ52SdYmCZ3stdeexBabFdeAbYopEowtagVUZqFapBrtAGqpiVaFrGgyjZlrmTD5yEqoEJj4iFMuA62i6L3WPZkAiuHgarZ/vbWSBkTzO2rfTR4XOJVJhjfX44MBn+OTocVWbcF5MalxXPeVL6zYonoGo44YOtDI7qHC1lkL5nHnOc+tJRi3K6iygLNGMjt1A1XVV6iUzOvVtAvMlS2I/yBYlRf8MgA6szmXQ1jDfKhSgjft6DRtrkgarAiAw5nI9v2WDSn+Zxfd9DawGxIlPPQUg0A2HGABfEIYlCDU4+q0d8O+jRzHCCFYy+nu4BaeYAoksBCDrPYsXQQ6iitgiSQaS1FHHtMzFil4DpxTl4UhORSn4WOaaiGsbu4iFRkMnYQlEV0oSJQGQ4FyYgSRDjpqPZcCR6EOOWonIEsBqArAIQOMLzw0VXRRERF2VoA6Atk1+MzsASekMJYgaFEeHR4Cr85lNGntYzgKCYd/NSNIDCXr0ZJ2jwTsjSvEMzFQCCVmKHBRahn2DNb4rDRx8pnbXOOIg0JELLMHOF1AUkaRj1V8c2TookkMS83WK9QCVpRwtf5wCykQWRKDyJ44Ytc452QUV6inmN9IDIv/6y2+YLDuqTywBEHxv8rsoxQC4Fpf4cZ2pbJ4/huxXr0EvFmoRCrAIVymLQ3Eid0GJYPsPfISBLwdwi79YQnCqBNS7LQDP5qYSAKEDypOrX4WVWYLsFy+i9cwh6CUmUKIJI2Gq5cSbnLLw849D2Ld3L4olC1u3P0c1ow5Ozgixa3puWChONG1D3eLZUQOglvng+Vp5dBfseesx5/yHyI4cBTL3wsssRGs2g6/ppHijiMLoNSSMNHofy6Nn6SPsAR02nUoTtrDTSrdoi8CTni55rlOsCf1ypaDxlFMNU1epCV5XL6Y6dmOq+BeS48NIlq7Anpjg5dOFbPdDWLQyj/aubnUKSkMKi3NhkUd4kieYtbRbYS0bFAOQKI8NO363z1RJHmamtnlwhGksxV2w/gl29WRtm8kWtWUnRShLnQvXgDOXmLg2HzlvbDiyHD8Y517YP2i4FtueFPbB9FFqKcyobk4A5y7zquUFa7IXojyHoeXmAFcY755vaI6A56Xsofm/7+cmblBTpOldQ5vs3PJDVS+RVSAaus2SpJTO80t4NTNSOQfCDrtFkBevA0ME6HGvPdDpFlekzm7rf3nFQNRQEwBZTL9warObWfx21Uv1+fx1ERqVNampGoOHpF1tsdp07RnoGMxK1vT97rbK4IP6+Tc+fWXVsahaYGL6VO09d//GXHXr7jVeqmuppqU6ff4x0RO6lqRxgxHJpWKSlcw5eWfjq5rq/CdhaL5l6JWxjDc6bP7w5sn+/uMs2B36H2bgb6v9raK0+o9IAAAAAElFTkSuQmCC`,gd=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAQzSURBVFgJ7VZNbBNHFH67Xv9RxwnBDqlUoQglcZK6qSIEJIQWAYJQoVY9IE5RTzn20FMvqdpDesq9B24+NdwthAJCkZChJg1JSOXYQIwQKQIaBdtENbs73t2+N8miGWOcpFHUHniyd97OvJ9v3nv7ZgDe038cAeVd/jOZjC94sKdfU+Bj24G9igpexwYPyiu2bauKqqqirkOTqmrjnIOyFsoyUKDocSCj/7mU7ujoMER5l68JYOFZ4YSiwPjd9O0jjx7ch1KhAJZVAcdx0LxDv3XetYKjggr4I4bzHo8G4aYmONjZBYf6+2dUzfd9PNowJajUZmef/PX5zcWl0rmvvnbQHrra+f/M+S+dqYXs2t3Hz09Ve5UicCmZ3NPb1Zv66btv+65dSULA64WGxkbw+Xx8V9XK9d4pWowxeFUqgW6acHroC/j5l0sLD/PZY98MDf3t6mouQ+On3X1H7/2e7rtOztHpgbY2+CAUgperq+D3+7cNgtLSEA7D0+VluDF5FS7cSff2HT56DF1dd/3KhQTWJ/lclsc8jIrk9IfRURgZGQEvRqNSWa8D2t1W/liXXK8Ro0i0lF0ExaPEXec0SgAqhrm3VCzwdS9GQNd1GBsbg0AgAIlEAlpbW7EYLVF/U56AagieiGwbuhERlSQApmEE8c/XKXxU0fF4HNowFfPz81Aul7edBjLGbeHITANsZga4g42HVAM2Y74KM/kSIQ/izgcHB2FiYgJmZmZ4MZpYULRG5PF4+Bx/2cLDxuhhYUqFLwGoWCaQEBGhNjAa4+Pj/J3SQA6pHpqbm/kcNitIJpOgaZIZvlbrQbZNJvcjSZOZDKhwRKLic4l2Pjc3B8FgkE+trKxAVUN0RWuOZNtCHyJJACj/bgREIZcnA9PT029SQM63unuywSOwUWOuTQmAhfmnlluPxIjUk6u1RrbJh0jyV0Ap2OZnJhrbjOcRqEqBBMDCAtltAORDJAkAVj2mWS5CUXinPDUx+oxFkgBYjO0qANu2wKoqQgkAfgW7C4AiYMmfoQSgwpjj7GYRUh/Q66SAmdisNxql227FfP1bXrRlVExdtCNHwDRLdPkgwmi8OUREhe3y1NLJFpEfbWMNvBRtSI2o+KqYi+zbx4NQwptMCO8E1HjEHYjKm/HknG5FZIsCG4lEoLS2lhP1JAB3bt1KH//s+GJPd3dPJpvlN5kwXiYIhHukisr1eAItXsm6YzGItrTcn5+dvS3qSQBSqVQhFouNnj039CsaCC7mcqDjgbNT6op1AtrU8Wo3Ojk5KaVAOptdR8PDwxf3t7SMvXjxvJNOPP31a35Krt8CXKl3j2SUDip/IAjRaBRaP9z/cHW18GMikbhcrVUTAAm1t7d/NDAwcDIUCvVqmtqkyLe3ajtvvTtg4x3SLpbLa3+kUr9N5fP55beE3k/8HyLwDx2/HIx7q3WfAAAAAElFTkSuQmCC`,_d=e=>({...e,fallbackIconDataUrl:e.id===`finder`&&window.__YURI_PLATFORM__!==`win32`?hd:e.id===`terminal`&&e.label===`Terminal`?gd:void 0}),vd=e=>{let t=(0,ju.c)(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:i}=e,[a,o]=Q.useState(!1),s;t[0]===n?s=t[1]:(s=n.trim().slice(0,1).toUpperCase()||`?`,t[0]=n,t[1]=s);let c=s,l=r||i;if(l&&!a){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>o(!0),t[2]=e):e=t[2];let n;return t[3]===l?n=t[4]:(n=(0,$.jsx)(`img`,{src:l,alt:``,className:`h-4 w-4 rounded-sm`,onError:e}),t[3]=l,t[4]=n),n}let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=Y(`h-4 w-4 rounded-sm flex items-center justify-center`,`bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground`),t[5]=u):u=t[5];let d;return t[6]===c?d=t[7]:(d=(0,$.jsx)(`span`,{className:u,children:c}),t[6]=c,t[7]=d),d},yd=({directory:e,className:t})=>{let{t:n}=Nr(),r=ud(e=>e.selectedAppId),i=ud(e=>e.availableApps),a=ud(e=>e.isCacheStale),o=ud(e=>e.isScanning),s=ud(e=>e.initialize),c=ud(e=>e.loadInstalledApps),l=ud(e=>e.selectApp),{data:u}=fd(),d=Q.useMemo(()=>u?i.filter(e=>u.appIds.includes(e.id)):i,[i,u]);Q.useEffect(()=>{s()},[s]);let f=C()&&x(),p=Q.useMemo(()=>{let e=d.find(e=>e.id===r)??d.find(e=>e.id===`finder`)??d[0];return e?_d(e):null},[d,r]);if(!f&&!u||!e)return null;let m=async t=>{try{let r=await w(e,t.id,t.appName,u?.hostId);!r&&!u?await S(e,t.appName):r||X.error(n(`filesView.toast.openInAppFailed`,{app:t.label}))}catch(e){X.error(n(String(e).includes(`SSH_EDITOR_CONFIG_REQUIRED`)?`openInApp.errors.sshConfigRequired`:`filesView.toast.openInAppFailed`,{app:t.label}))}},h=async e=>{await l(e.id),await m(e)},g=async()=>{await dr(e)};return(0,$.jsxs)(`div`,{className:Y(`app-region-no-drag inline-flex h-7 w-12 items-center self-center overflow-hidden rounded-md border border-border/40 px-1`,`hover:bg-interactive-hover transition-colors`,t),children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>void(p?m(p):g()),className:Y(`inline-flex h-full w-7 items-center justify-center typography-ui-label font-medium`,`text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary`,o&&`animate-pulse`),"aria-label":p?n(`openInApp.actions.openInAria`,{app:p.label}):n(`openInApp.actions.copyPath`),children:p?(0,$.jsx)(vd,{label:p.label,iconDataUrl:p.iconDataUrl,fallbackIconDataUrl:p.fallbackIconDataUrl}):(0,$.jsx)(Z,{name:`file-copy`,className:`h-4 w-4`})}),(0,$.jsxs)(Ci,{children:[(0,$.jsx)(vi,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`inline-flex h-full w-3 items-center justify-center text-muted-foreground`,`hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary`),"aria-label":n(`openInApp.actions.chooseAppAria`),children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`size-2.5`})})}),(0,$.jsxs)(bi,{align:`end`,className:`w-56 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>void g(),children:[(0,$.jsx)(Z,{name:`file-copy`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:n(`openInApp.actions.copyPath`)})]}),(0,$.jsx)(Si,{}),d.map(e=>{let t=_d(e);return(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>void h(e),children:[(0,$.jsx)(vd,{label:e.label,iconDataUrl:e.iconDataUrl,fallbackIconDataUrl:t.fallbackIconDataUrl}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e.label}),p?.id===e.id?(0,$.jsx)(Z,{name:`check`,className:`ml-auto h-4 w-4 text-primary`}):null]},e.id)}),a?(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>void c(!0),children:[(0,$.jsx)(Z,{name:`refresh`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:n(`openInApp.actions.refreshApps`)})]}):null]})]})]})},bd=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],xd=[`dev`,`start`,`preview`,`serve`];async function Sd(e,t,n,r){if(!e)return null;let i=Td(t);if(i)return{command:i.command,label:i.name||`Start Preview`,actionId:i.id};if(n){let t=Ed(n);if(t){let n=await Dd(e,r);return{command:`${n===`npm`?`npm run`:n===`yarn`?`yarn`:n===`pnpm`?`pnpm`:n===`bun`?`bun run --shell=bun`:`npm run`} ${t}`,label:`Start (${t})`}}}if(await Cd(e,r)){let e=await wd(r),t=typeof e==`number`&&Number.isFinite(e)&&e>0?e:8e3;return{command:`python3 -m http.server ${t}`,label:`Static preview`,previewUrlHint:`http://127.0.0.1:${t}/`}}return null}async function Cd(e,t){let n=await Od(`${e}/index.html`,e,t);return typeof n==`string`&&n.trim().length>0}async function wd(e){if(e){let t=await xt(e).json(`/api/system/free-port`,{cache:`no-store`});if(!Number.isInteger(t.port)||t.port<1||t.port>65535)throw Error(`Invalid Host preview port`);return t.port}try{let e=await g(`/api/system/free-port`,{cache:`no-store`});if(!e.ok)return null;let t=await e.json().catch(()=>null),n=typeof t?.port==`number`?t.port:null;return n&&Number.isFinite(n)?n:null}catch{return null}}function Td(e){for(let t of e){let e=`${t.name} ${t.command}`.toLowerCase();if(xd.some(t=>e.includes(t)))return t}return null}function Ed(e){for(let{pattern:t}of bd)for(let n of Object.keys(e))if(t.test(n))return n;return null}async function Dd(e,t){let n=await Od(`${e}/package.json`,e,t);if(n)try{let e=JSON.parse(n),t=typeof e.packageManager==`string`?e.packageManager.toLowerCase():``;if(t.startsWith(`bun@`))return`bun`;if(t.startsWith(`pnpm@`))return`pnpm`;if(t.startsWith(`yarn@`))return`yarn`;if(t.startsWith(`npm@`))return`npm`}catch{}for(let[n,r]of[[`bun.lock`,`bun`],[`bun.lockb`,`bun`],[`pnpm-lock.yaml`,`pnpm`],[`yarn.lock`,`yarn`],[`package-lock.json`,`npm`]]){let i=await Od(`${e}/${n}`,e,t);if(typeof i==`string`&&i.trim().length>0)return r}return`npm`}async function Od(e,t,n){if(n){let r=xt(n),i=await r.fetch(`/api/fs/read`,{query:{path:e,directory:t,optional:`true`},cache:`no-store`});if(i.status===404)return null;if(!i.ok)throw Error(`Failed to read Host preview file (${i.status})`);let a=await i.text();return r.assertCurrent(),i.headers.get(`x-yuri-file-exists`)===`false`?null:a}if(t?.trim())try{let n=new URLSearchParams({path:e,directory:t,optional:`true`}),r=await g(`/api/fs/read?${n.toString()}`,{cache:`no-store`});if(r.ok)return r.text()}catch{}let r=U()?.files;if(r?.readFile)try{let t=await r.readFile(e,{optional:!0});return typeof t?.content==`string`?t.content:null}catch{return null}try{let t=await g(`/api/fs/read?path=${encodeURIComponent(e)}&optional=true`,{cache:`no-store`});return t.ok?t.text():null}catch{return null}}async function kd(e,t){try{let n=await Od(`${e}/package.json`,e,t);if(n==null)return null;let r=JSON.parse(n).scripts;return r&&typeof r==`object`&&!Array.isArray(r)?r:null}catch(e){if(t)throw e;return null}}var Ad=e=>new Promise(t=>{window.setTimeout(t,e)}),jd=RegExp(`\x1B\\[[0-9;?]*[ -/]*[@-~]`,`g`),Md=/https?:\/\/[^\s<>'"`]+/gi,Nd=`__yuri_auto_discover_preview__`,Pd=15e3,Fd=e=>{let t=``;for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);r>=0&&r<=8||r===11||r===12||r>=14&&r<=31||r===127||(t+=e[n])}return t},Id=e=>{let t=(e||``).trim();if(!t)return null;let n=/^https?:\/\//i.test(t)?t:`http://${t}`;try{let e=new URL(n);return e.protocol!==`http:`&&e.protocol!==`https:`?null:e.toString()}catch{return null}},Ld=e=>{let t=e.replace(jd,``).match(Md);if(!t||t.length===0)return null;let n=t.map(e=>e.replace(/[),.;]+$/,``)).filter(Boolean);if(n.length===0)return null;let r=[];for(let e of n)try{let t=new URL(e);t.port&&t.port.length>0&&r.push({raw:e,parsed:t})}catch{}if(r.length>0){let e=e=>{let{parsed:t}=e,n=t.hostname.toLowerCase(),r=n===`localhost`||n===`127.0.0.1`||n===`0.0.0.0`||n===`::1`,i=t.pathname||`/`,a=i.split(`/`).filter(Boolean).length,o=i===`/`||i===``,s=!!(t.search||t.hash),c=0;return r&&(c+=50),o&&(c+=30),c-=Math.min(a*5,20),s&&(c-=10),c};return r.sort((t,n)=>e(n)-e(t)),r[0]?.parsed.origin??r[0]?.raw??null}return n[0]??null},Rd=e=>{let t=(0,ju.c)(19),n=!!e.projectRef?.hostId,{registry:r}=Dr(n&&!e.scope),i=e.projectRef?.hostId,a;t[0]!==i||t[1]!==r?(a={subscribe:e=>r&&i?r.subscribeHost(i,e):Bd,snapshot:()=>r&&i?r.getHost(i):void 0},t[0]=i,t[1]=r,t[2]=a):a=t[2];let o=a;Q.useSyncExternalStore(o.subscribe,o.snapshot,o.snapshot);let s=e.directory||e.projectRef?.path||``,c;t[3]!==s||t[4]!==e.projectRef||t[5]!==e.scope||t[6]!==r||t[7]!==n?(c=e.scope?r?.hubId===e.scope.location.hubId?r.resolve(e.scope.location):e.scope:n&&r&&r.hubId===e.projectRef?.hubId?r.resolve({hubId:r.hubId,hostId:e.projectRef.hostId,directory:s}):void 0,t[3]=s,t[4]=e.projectRef,t[5]=e.scope,t[6]=r,t[7]=n,t[8]=c):c=t[8];let l=c,u;t[9]!==s||t[10]!==l||t[11]!==e.projectRef?.hostId||t[12]!==e.projectRef?.hubId||t[13]!==n?(u=l?`${l.key}:${l.connectionGeneration}`:n?JSON.stringify([e.projectRef?.hubId,e.projectRef?.hostId,s]):s,t[9]=s,t[10]=l,t[11]=e.projectRef?.hostId,t[12]=e.projectRef?.hubId,t[13]=n,t[14]=u):u=t[14];let d=u,f;return t[15]!==l||t[16]!==d||t[17]!==e?(f=(0,$.jsx)(zd,{...e,scope:l},d),t[15]=l,t[16]=d,t[17]=e,t[18]=f):f=t[18],f},zd=({projectRef:e,directory:t,className:n,compact:r=!1,allowMobile:i=!1,scope:a})=>{let{t:o}=Nr(),{terminal:s,runtime:c}=wt(),l=Q.useRef(null),u=Q.useRef(!0),d=()=>{if(!u.current)throw new DOMException(`Project action scope superseded`,`AbortError`);if(e?.hostId&&(!a||a.location.hostId!==e.hostId||a.location.hubId!==e.hubId)||a&&a.location.directory!==(t||e?.path||``))throw Error(o(`remoteProjects.host-unavailable`));a&&xt(a).assertCurrent()},f=K(()=>{if(d(),!a)throw Error(o(`remoteProjects.host-unavailable`));return l.current??=Gt(a)}),p=Q.useMemo(()=>a||e?.hostId?{createSession:e=>f().createTerminalSession(e),sendInput:(e,t)=>f().sendTerminalInput(e,t),close:e=>f().closeTerminal(e)}:s,[a,e?.hostId,s,f]),{isMobile:m}=fi(),h=Q.useMemo(()=>C(),[]),g=vu(e=>e.instances),_=vu(e=>e.load),v=q(e=>e.setBottomTerminalOpen),y=q(e=>e.setActiveMainTab),b=q(e=>e.setSettingsPage),x=q(e=>e.setSettingsDialogOpen),S=q(e=>e.setSettingsProjectsSelectedId),w=q(e=>e.openContextPreview),T=dc(e=>e.sessions),E=dc(e=>e.ensureDirectory),D=dc(e=>e.setTabLabel),O=dc(e=>e.setTabIconKey),k=dc(e=>e.setActiveTab),A=dc(e=>e.setConnecting),j=dc(e=>e.setTabSessionId),M=dc(e=>e.setTabPreviewUrl),N=dc(e=>e.projectActionRuns),P=dc(e=>e.setProjectActionRun),F=dc(e=>e.updateProjectActionRunStatus),I=dc(e=>e.removeProjectActionRun),[L,R]=Q.useState([]),[z,ee]=Q.useState(null),[B,te]=Q.useState(!1),re=Q.useRef({}),ie=Q.useRef({}),ae=Q.useRef({}),H=Q.useRef({}),U=Q.useRef(0),oe=Q.useRef(new Set),W=e?.id??null,se=e?.path??``,ce=Q.useMemo(()=>W?{id:W,path:se,hostId:e?.hostId,hubId:e?.hubId}:null,[W,se,e?.hostId,e?.hubId]);Q.useEffect(()=>{u.current=!0;let e=ae.current,t=H.current;return()=>{u.current=!1,U.current+=1,Object.values(e).forEach(e=>e()),Object.values(t).forEach(e=>window.clearTimeout(e)),l.current?.dispose(),l.current=null}},[a]),Q.useEffect(()=>{!h||a||e?.hostId||_().catch(()=>void 0)},[h,_,a,e?.hostId]);let le=K(async e=>{await Ut(e)}),ue=K(async()=>{if(!ce)return;let e=U.current+1;U.current=e,te(!0);try{d();let t=await Gn(ce,a);if(U.current!==e)return;let n=t.actions;R(n),ee(e=>e===Nd||e&&n.some(t=>t.id===e)?e:null)}catch{if(U.current!==e)return}finally{U.current===e&&te(!1)}}),de=t||ce?.path||``,fe=Q.useMemo(()=>a?V(ne({...a.location,directory:de})):ce?.hostId?ce.hubId?V(ne({hubId:ce.hubId,hostId:ce.hostId,directory:de})):``:wu(de),[de,ce,a]),pe=Q.useMemo(()=>z?L.find(e=>e.id===z)??null:null,[L,z]),me=Q.useMemo(()=>({id:Nd,name:o(`projectActions.actions.autoDiscover`),command:``,icon:`search`,autoOpenUrl:!0}),[o]),he=!m,ge=Q.useMemo(()=>he?[me,...L]:L,[L,me,he]);Q.useEffect(()=>{ue()},[ue,ce,a]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail;W&&(t?.projectId&&t.projectId!==W||ue())};return window.addEventListener(Tu,e),()=>{window.removeEventListener(Tu,e)}},[ue,W]),Q.useEffect(()=>{z&&(z===Nd&&he||L.some(e=>e.id===z)||ee(null))},[L,he,z]),Q.useEffect(()=>{for(let[e,t]of Object.entries(N)){if(t.directory!==fe)continue;let n=T.get(t.directory)?.tabs.find(e=>e.id===t.tabId);(!n||n.terminalSessionId!==t.sessionId)&&I(e)}},[fe,N,I,T]),Q.useEffect(()=>{for(let[e,t]of Object.entries(N)){if(t.directory!==fe)continue;let n=ie.current[e]??{lastSeenChunkId:null,openedUrl:!1,tail:``,openInPreview:!1};ie.current[e]=n;let r=ge.find(e=>e.id===t.actionId);if(!r)continue;let i=T.get(t.directory)?.tabs.find(e=>e.id===t.tabId);if(!i||!Array.isArray(i.bufferChunks)||i.bufferChunks.length===0)continue;let s=i.bufferChunks.filter(e=>n.lastSeenChunkId===null||e.id>n.lastSeenChunkId);if(s.length===0)continue;let c=s.map(e=>e.data).join(``),l=`${n.tail}${c}`,u=!n.openedUrl&&r.autoOpenUrl===!0?Ld(l):null;if(n.lastSeenChunkId=s[s.length-1]?.id??n.lastSeenChunkId,n.tail=l.slice(-512),u)if(n.openedUrl=!0,n.openInPreview){let t=N[e];t&&(M(t.directory,t.tabId,u,{locked:!1,autoOpened:!1}),t.status===`waiting-for-preview`&&F(e,`running`),window.clearTimeout(H.current[e]),delete H.current[e],w(t.directory,u))}else a||ce?.hostId?(M(t.directory,t.tabId,u,{locked:!1,autoOpened:!0}),w(t.directory,u)):(le(u),X.success(o(`projectActions.toast.openedUrlFromOutput`)));ie.current[e]=n}for(let e of Object.keys(ie.current))N[e]||(delete ie.current[e],window.clearTimeout(H.current[e]),delete H.current[e])},[fe,a,ce?.hostId,ge,w,le,N,M,o,T,F]);let _e=K(async(e,t={})=>{if(!fe)throw Error(o(`projectActions.error.noActiveDirectory`));let n=xu(fe,e.id);E(fe);let r=dc.getState(),i=r.getDirectoryState(fe),a=re.current[n]||null,s=a?!!i?.tabs.some(e=>e.id===a):!1;(!a||!s)&&(a=r.createTab(fe),re.current[n]=a),D(fe,a,`Action: ${e.name}`),O(fe,a,e.icon||`play`),t.revealTerminal!==!1&&(k(fe,a),v(!0),y(`terminal`));let c=dc.getState().getDirectoryState(fe)?.tabs.find(e=>e.id===a);return{key:n,tabId:a,sessionId:c?.terminalSessionId??null}}),ve=K(async e=>{if(c.isVSCode||!i&&m)return;if(!fe){X.error(o(`projectActions.error.noActiveDirectoryForAction`));return}let t=xu(fe,e.id),n=N[t];if(!(n&&n.status===`running`)&&!oe.current.has(t)){oe.current.add(t);try{d();let t=e.id===Nd?await(async()=>{let[e,t]=await Promise.all([Gn({...ce,id:ce?.id??``,path:de},a),kd(de,a)]),n=await Sd(de,e.actions,t,a);if(!n)throw Error(o(`contextPanel.preview.noDevServer`));return{id:Nd,name:o(`projectActions.actions.autoDiscover`),command:n.command,icon:`search`,autoOpenUrl:!0,openUrl:n.previewUrlHint||``}})():e,n=t.autoOpenUrl===!0&&(t.openUrl||``).trim().length>0;d();let{key:r,tabId:i,sessionId:s}=await _e(t,{revealTerminal:!n&&e.id!==Nd}),c=s,l=!1;if(!c){A(fe,i,!0);try{let e=await p.createSession({cwd:de});d(),c=e.sessionId,l=!0,j(fe,i,c)}finally{A(fe,i,!1)}}if(!c)throw Error(o(`projectActions.error.failedToCreateTerminalSession`));l&&await Ad(350),d(),t.id===Nd&&(ae.current[r]?.(),A(fe,i,!0),ae.current[r]=(a?f().connectTerminalStream:Wt)(c,e=>{if(u.current){try{d()}catch{return}e.type===`data`&&typeof e.data==`string`&&e.data.length>0&&dc.getState().appendToBuffer(fe,i,e.data),e.type===`exit`&&(dc.getState().setTabLifecycle(fe,i,`exited`),dc.getState().setConnecting(fe,i,!1),dc.getState().removeProjectActionRun(r),delete ie.current[r],ae.current[r]?.(),delete ae.current[r],window.clearTimeout(H.current[r]),delete H.current[r])}},()=>{u.current&&dc.getState().setConnecting(fe,i,!1)},{maxRetries:60,initialRetryDelay:250,maxRetryDelay:2e3,connectionTimeout:5e3}));let m=t.autoOpenUrl===!0&&!a&&h&&(t.desktopOpenSshForward||``).trim().length>0,_=t.autoOpenUrl?Id(t.openUrl):null,v=t.autoOpenUrl&&h&&!a?Su(t.desktopOpenSshForward,g):null;P({key:r,directory:fe,actionId:t.id,tabId:i,sessionId:c,status:t.id===Nd&&!_?`waiting-for-preview`:`running`}),window.clearTimeout(H.current[r]),delete H.current[r],t.id===Nd&&!_&&(H.current[r]=window.setTimeout(()=>{dc.getState().updateProjectActionRunStatus(r,`running`),delete H.current[r]},Pd)),v?(M(fe,i,null,{locked:!0}),le(v),X.success(o(`projectActions.toast.openedForwardedUrl`))):_?(M(fe,i,_,{locked:!0,autoOpened:!0}),w(fe,_),X.success(o(`projectActions.toast.openedActionUrl`))):n?(M(fe,i,null,{locked:!0}),X.error(o(`projectActions.error.invalidCustomUrlFormat`))):m?(M(fe,i,null,{locked:!0}),X.error(o(`projectActions.error.selectedDesktopSshForwardUnavailable`))):M(fe,i,null,{locked:!1,autoOpened:!1}),ie.current[r]={lastSeenChunkId:null,openedUrl:!!v||!!_||n,tail:``,openInPreview:t.id===Nd};let y=Fd(t.command.trim().replace(/\r\n|\r/g,`
|
|
3
|
+
`));d(),await p.sendInput(c,`${y}\r`)}catch(e){I(t),delete ie.current[t],ae.current[t]?.(),delete ae.current[t],window.clearTimeout(H.current[t]),delete H.current[t],X.error(e instanceof Error?e.message:o(`projectActions.error.failedToRunAction`))}finally{oe.current.delete(t)}}}),ye=K(async e=>{let t=xu(fe,e.id),n=N[t];if(n){F(t,`stopping`);try{await p.sendInput(n.sessionId,``)}catch(e){if(a||ce?.hostId){F(t,`running`),X.error(e instanceof Error?e.message:o(`projectActions.error.failedToRunAction`));return}}if(await new Promise(e=>{window.setTimeout(e,1e3)}),dc.getState().getDirectoryState(n.directory)?.tabs.find(e=>e.id===n.tabId)?.terminalSessionId===n.sessionId)if(a||ce?.hostId){try{d(),await p.close(n.sessionId)}catch(e){F(t,`running`),X.error(e instanceof Error?e.message:o(`projectActions.error.failedToRunAction`));return}j(n.directory,n.tabId,null)}else{if(typeof p.forceKill==`function`)try{await p.forceKill({sessionId:n.sessionId})}catch{}else try{await p.close(n.sessionId)}catch{}j(n.directory,n.tabId,null)}I(t),delete ie.current[t],ae.current[t]?.(),delete ae.current[t],window.clearTimeout(H.current[t]),delete H.current[t]}}),be=K(()=>{let e=pe??ge[0];if(!e)return;let t=xu(fe,e.id),n=N[t];if(n?.status!==`stopping`){if(n){ye(e);return}ve(e)}}),xe=K((e,t=!1)=>{if(ee(e.id),!t){ve(e);return}let n=xu(fe,e.id),r=N[n];if(r?.status!==`stopping`){if(r){ye(e);return}ve(e)}}),Se=K(()=>{if(ce?.id){if(a||ce.hostId){X.info(o(`remoteProjects.configurationReadOnly`)),b(`remoteInstances`),x(!0);return}S(ce.id),b(`projects`),x(!0)}});if(c.isVSCode||!i&&m||!ce||!fe)return null;let Ce=pe??ge[0]??null;if(!Ce)return null;let we=Ce.icon||`play`,Te=Ce.id===Nd?`search`:Cu[we]||`play`,Ee=N[xu(fe,Ce.id)],De=Ee?.status===`stopping`,Oe=Ee?.status===`waiting-for-preview`,ke=Ee?T.get(Ee.directory)?.tabs.find(e=>e.id===Ee.tabId)?.previewUrl??null:null,Ae=!!(Ee&&ke),je=()=>{!Ee||!ke||w(Ee.directory,ke)};return r?(0,$.jsxs)(`div`,{className:`inline-flex items-center`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:B||De,className:Y(`app-region-no-drag inline-flex h-9 w-9 items-center justify-center rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] p-2`,`typography-ui-label font-medium text-muted-foreground hover:bg-interactive-hover hover:text-foreground transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,`disabled:cursor-not-allowed`,n),onClick:be,"aria-label":o(Ee?`projectActions.actions.stopNamedAria`:`projectActions.actions.runNamedAria`,{name:Ce.name}),children:De||Oe?(0,$.jsx)(Z,{name:`loader-4`,className:`h-5 w-5 animate-spin text-[var(--status-warning)]`}):Ee?(0,$.jsx)(Z,{name:`stop`,className:`h-5 w-5 text-[var(--status-warning)]`}):(0,$.jsx)(Z,{name:Te,className:`h-5 w-5`})}),Ae?(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`app-region-no-drag -ml-1 inline-flex h-9 w-7 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":o(`projectActions.actions.openPreview`),onClick:je,children:(0,$.jsx)(Z,{name:`global`,className:`h-4 w-4`})})}),(0,$.jsx)(ei,{sideOffset:6,children:o(`projectActions.actions.openPreview`)})]}):null,(0,$.jsxs)(Ci,{children:[(0,$.jsx)(vi,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`app-region-no-drag -ml-1 inline-flex h-9 w-5 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":o(`projectActions.actions.chooseActionAria`),children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-3.5 w-3.5`})})}),(0,$.jsxs)(bi,{align:`end`,className:`w-52 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:Se,children:[(0,$.jsx)(Z,{name:`add`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`projectActions.actions.addNewAction`)})]}),(0,$.jsx)(Si,{}),ge.map(e=>{let t=e.icon||`play`,n=e.id===Nd?`search`:Cu[t]||`play`,r=xu(fe,e.id),i=N[r],a=!!i,o=i?.status===`stopping`;return(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>{xe(e,!0)},children:[(0,$.jsx)(Z,{name:n,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:e.name}),o||i?.status===`waiting-for-preview`?(0,$.jsx)(Z,{name:`loader-4`,className:`ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]`}):a?(0,$.jsx)(Z,{name:`stop`,className:`ml-auto h-4 w-4 text-[var(--status-warning)]`}):null]},e.id)})]})]})]}):(0,$.jsxs)(`div`,{className:Y(`app-region-no-drag inline-flex shrink-0 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]`,`bg-[var(--surface-elevated)] overflow-hidden`,`border border-border/60`,r?`h-9`:`h-7`,n),children:[(0,$.jsx)(`button`,{type:`button`,onClick:be,disabled:B||De,className:Y(`inline-flex h-full items-center justify-center typography-ui-label font-medium text-foreground hover:bg-interactive-hover`,r?`w-9 px-0`:`px-2.5`,`transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed`),"aria-label":o(Ee?`projectActions.actions.stopNamedAria`:`projectActions.actions.runNamedAria`,{name:Ce.name}),children:(0,$.jsx)(`span`,{className:`inline-flex h-4 w-4 shrink-0 items-center justify-center`,children:De||Oe?(0,$.jsx)(Z,{name:`loader-4`,className:`h-4 w-4 animate-spin text-[var(--status-warning)]`}):Ee?(0,$.jsx)(Z,{name:`stop`,className:`h-4 w-4 text-[var(--status-warning)]`}):(0,$.jsx)(Z,{name:Te,className:`h-4 w-4`})})}),Ae?(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:je,className:Y(r?`inline-flex h-full w-8 items-center justify-center`:`inline-flex h-full w-7 items-center justify-center`,`border-l border-[var(--interactive-border)] text-foreground`,`hover:bg-interactive-hover transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),"aria-label":o(`projectActions.actions.openPreview`),children:(0,$.jsx)(Z,{name:`global`,className:`h-4 w-4`})})}),(0,$.jsx)(ei,{sideOffset:6,children:o(`projectActions.actions.openPreview`)})]}):null,(0,$.jsxs)(Ci,{children:[(0,$.jsx)(vi,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(r?`inline-flex h-full w-8 items-center justify-center`:`inline-flex h-full w-7 items-center justify-center`,`border-l border-[var(--interactive-border)] text-muted-foreground`,`hover:bg-interactive-hover hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),"aria-label":o(`projectActions.actions.chooseActionAria`),children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-4 w-4`})})}),(0,$.jsxs)(bi,{align:`start`,className:`w-52 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:Se,children:[(0,$.jsx)(Z,{name:`add`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`projectActions.actions.addNewAction`)})]}),(0,$.jsx)(Si,{}),ge.map(e=>{let t=e.icon||`play`,n=e.id===Nd?`search`:Cu[t]||`play`,r=xu(fe,e.id),i=N[r],a=!!i,o=i?.status===`stopping`;return(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>{xe(e,!0)},children:[(0,$.jsx)(Z,{name:n,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:e.name}),o||i?.status===`waiting-for-preview`?(0,$.jsx)(Z,{name:`loader-4`,className:`ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]`}):a?(0,$.jsx)(Z,{name:`stop`,className:`ml-auto h-4 w-4 text-[var(--status-warning)]`}):null]},e.id)})]})]})]})};function Bd(){}function Vd(e){return e.isOpen&&e.activeTab===e.targetTab?{open:!1,tab:e.activeTab}:{open:!0,tab:e.targetTab}}var Hd=`app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50 hover:bg-interactive-hover transition-colors`,Ud=`app-region-no-drag inline-flex h-9 w-9 items-center justify-center gap-2 p-2 rounded-md typography-ui-label font-medium text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50 hover:text-foreground hover:bg-interactive-hover transition-colors`,Wd=Q.memo(function(e){let t=(0,ju.c)(17),{visible:n,title:r,ariaLabel:i,onClick:a,className:o,Icon:s,iconClassName:c,pressed:l}=e,u=n===void 0||n,d=l!==void 0&&l;if(!u)return null;let f=o??Hd,p=d&&`bg-interactive-selection text-interactive-selection-foreground`,m;t[0]!==f||t[1]!==p?(m=Y(f,p),t[0]=f,t[1]=p,t[2]=m):m=t[2];let h=c??`h-[18px] w-[18px]`,g;t[3]!==s||t[4]!==h?(g=(0,$.jsx)(Z,{name:s,className:h}),t[3]=s,t[4]=h,t[5]=g):g=t[5];let _;t[6]!==i||t[7]!==a||t[8]!==d||t[9]!==m||t[10]!==g?(_=(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:a,"aria-label":i,"aria-pressed":d,className:m,children:g})}),t[6]=i,t[7]=a,t[8]=d,t[9]=m,t[10]=g,t[11]=_):_=t[11];let v;t[12]===r?v=t[13]:(v=(0,$.jsx)(ei,{children:(0,$.jsx)(`p`,{children:r})}),t[12]=r,t[13]=v);let y;return t[14]!==_||t[15]!==v?(y=(0,$.jsxs)(ni,{children:[_,v]}),t[14]=_,t[15]=v,t[16]=y):y=t[16],y}),Gd=Q.memo(function(e){let t=(0,ju.c)(42),{isMobile:n,githubAuthStatus:r,githubAccounts:i,githubAvatarUrl:a,githubLogin:o,isSwitchingGitHubAccount:s,handleGitHubAccountSwitch:c}=e,{t:l}=Nr();if(!r?.connected||n)return null;if(i.length>1){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=Y(Hd,`h-6 w-6 overflow-hidden rounded-full border border-border/60 bg-muted/80 p-0`),t[0]=e):e=t[0];let n;t[1]!==o||t[2]!==l?(n=o?l(`header.github.connectedWithLogin`,{login:o}):l(`header.github.connected`),t[1]=o,t[2]=l,t[3]=n):n=t[3];let r;t[4]!==a||t[5]!==o||t[6]!==l?(r=a?(0,$.jsx)(`img`,{src:a,alt:o?l(`header.github.avatarWithLogin`,{login:o}):l(`header.github.avatar`),className:`h-full w-full object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(Z,{name:`github-fill`,className:`h-3.5 w-3.5 text-foreground`}),t[4]=a,t[5]=o,t[6]=l,t[7]=r):r=t[7];let u;t[8]!==s||t[9]!==n||t[10]!==r?(u=(0,$.jsx)(vi,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:e,title:n,disabled:s,children:r})}),t[8]=s,t[9]=n,t[10]=r,t[11]=u):u=t[11];let d;t[12]===l?d=t[13]:(d=l(`header.github.accountsTitle`),t[12]=l,t[13]=d);let f;t[14]===d?f=t[15]:(f=(0,$.jsx)(yi,{className:`typography-ui-header font-semibold text-foreground`,children:d}),t[14]=d,t[15]=f);let p;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(Si,{}),t[16]=p):p=t[16];let m;if(t[17]!==i||t[18]!==c||t[19]!==s||t[20]!==l){let e;t[22]!==c||t[23]!==s||t[24]!==l?(e=e=>{let t=e.user,n=!!e.current,r=e.source===`gh-cli`?l(`header.github.accountSource.cli`):l(`header.github.accountSource.oauth`);return(0,$.jsxs)(xi,{className:`gap-2`,disabled:s,onSelect:()=>{n||c(e.id)},children:[t?.avatarUrl?(0,$.jsx)(`img`,{src:t.avatarUrl,alt:t.login?l(`header.github.avatarWithLogin`,{login:t.login}):l(`header.github.avatar`),className:`h-6 w-6 rounded-full border border-border/60 bg-muted object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(`div`,{className:`flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-muted`,children:(0,$.jsx)(Z,{name:`github-fill`,className:`h-3 w-3 text-muted-foreground`})}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-foreground`,children:t?.name?.trim()||t?.login||`GitHub`}),t?.login?(0,$.jsxs)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`font-mono`,children:t.login}),(0,$.jsx)(`span`,{className:`mx-1 opacity-50`,children:`·`}),(0,$.jsx)(`span`,{children:r})]}):null]}),n?(0,$.jsx)(Z,{name:`check`,className:`h-4 w-4 text-primary`}):null]},e.id)},t[22]=c,t[23]=s,t[24]=l,t[25]=e):e=t[25],m=i.map(e),t[17]=i,t[18]=c,t[19]=s,t[20]=l,t[21]=m}else m=t[21];let h;t[26]!==f||t[27]!==m?(h=(0,$.jsxs)(bi,{align:`end`,className:`w-64`,children:[f,p,m]}),t[26]=f,t[27]=m,t[28]=h):h=t[28];let g;return t[29]!==u||t[30]!==h?(g=(0,$.jsxs)(Ci,{children:[u,h]}),t[29]=u,t[30]=h,t[31]=g):g=t[31],g}let u;t[32]!==o||t[33]!==l?(u=o?l(`header.github.connectedWithLogin`,{login:o}):l(`header.github.connected`),t[32]=o,t[33]=l,t[34]=u):u=t[34];let d;t[35]!==a||t[36]!==o||t[37]!==l?(d=a?(0,$.jsx)(`img`,{src:a,alt:o?l(`header.github.avatarWithLogin`,{login:o}):l(`header.github.avatar`),className:`h-full w-full object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(Z,{name:`github-fill`,className:`h-3.5 w-3.5 text-foreground`}),t[35]=a,t[36]=o,t[37]=l,t[38]=d):d=t[38];let f;return t[39]!==u||t[40]!==d?(f=(0,$.jsx)(`div`,{className:`app-region-no-drag flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80`,title:u,children:d}),t[39]=u,t[40]=d,t[41]=f):f=t[41],f}),Kd=Q.memo(function(e){let t=(0,ju.c)(52),{isDesktopApp:n,currentInstanceSupportsUpdate:r,isDesktopServicesOpen:i,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:o,desktopServicesTab:s,setDesktopServicesTab:c,fetchAllQuotas:l,servicesTabItems:u,quotaLastUpdated:d,quotaDisplayMode:f,quotaDisplayTabItems:p,handleDisplayModeChange:m,handleUsageRefresh:h,isQuotaLoading:g,isUsageRefreshSpinning:_,hasRateLimits:v,rateLimitGroups:y,expandedFamilies:b,toggleFamilyExpanded:x,showPredValues:S,timeFormatPreference:C,anchorRef:w}=e,{t:T}=Nr(),E=Q.useRef(!1),D;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(D=e=>{E.current=e},t[0]=D):D=t[0];let O=K(D),k;t[1]!==s||t[2]!==l||t[3]!==d||t[4]!==o||t[5]!==a?(k=(e,t)=>{if(!e&&(t.reason===`trigger-hover`||t.reason===`focus-out`||E.current)){t.cancel();return}a(e),e&&(o(),s===`usage`&&d===null&&l())},t[1]=s,t[2]=l,t[3]=d,t[4]=o,t[5]=a,t[6]=k):k=t[6];let A;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(vi,{asChild:!0,openOnHover:!1,children:(0,$.jsx)(`button`,{type:`button`,"aria-hidden":!0,tabIndex:-1,className:`pointer-events-none absolute h-px w-px overflow-hidden opacity-0`})}),t[7]=A):A=t[7];let j;t[8]!==l||t[9]!==d||t[10]!==c?(j=e=>{if(E.current)return;let t=e;c(t),t===`usage`&&d===null&&l()},t[8]=l,t[9]=d,t[10]=c,t[11]=j):j=t[11];let M;t[12]!==s||t[13]!==u||t[14]!==j?(M=(0,$.jsx)(`div`,{className:`sticky top-0 z-20 bg-[var(--surface-elevated)]/60 px-2 pt-1.5 pb-1.5 backdrop-blur-xl backdrop-saturate-150`,children:(0,$.jsx)(`div`,{className:`h-9`,children:(0,$.jsx)(Vs,{items:u,activeId:s,onSelect:j,layoutMode:`fit`,variant:`active-pill`,activePillInsetClassName:`gap-0.5 px-px py-0`,activePillButtonClassName:`h-8`,className:`h-full`})})}),t[12]=s,t[13]=u,t[14]=j,t[15]=M):M=t[15];let N;t[16]!==r||t[17]!==s||t[18]!==O||t[19]!==n||t[20]!==i||t[21]!==a?(N=n&&s===`instance`?(0,$.jsxs)(`div`,{children:[r&&i?(0,$.jsx)(`div`,{className:`border-b border-[var(--interactive-border)] px-4 py-2.5`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label font-medium text-foreground`,children:`Yuri`}),(0,$.jsx)(Ol,{})]})}):null,(0,$.jsx)(Ua,{embedded:!0,open:i&&s===`instance`,onOpenChange:nf,onHostSwitched:()=>a(!1),onBusyChange:O})]}):null,t[16]=r,t[17]=s,t[18]=O,t[19]=n,t[20]=i,t[21]=a,t[22]=N):N=t[22];let P;t[23]!==s||t[24]!==i?(P=s===`mcp`?(0,$.jsx)(Hc,{active:i&&s===`mcp`}):null,t[23]=s,t[24]=i,t[25]=P):P=t[25];let F;t[26]!==s||t[27]!==b||t[28]!==m||t[29]!==h||t[30]!==v||t[31]!==g||t[32]!==_||t[33]!==f||t[34]!==p||t[35]!==d||t[36]!==y||t[37]!==S||t[38]!==T||t[39]!==C||t[40]!==x?(F=s===`usage`?(0,$.jsxs)(`div`,{className:`overflow-x-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-[var(--interactive-border)] px-4 py-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-header font-semibold text-foreground`,children:T(`header.services.rateLimits`)}),(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Jd(d,C)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`div`,{className:`h-7 w-[10.5rem]`,children:(0,$.jsx)(Vs,{items:p,activeId:f,onSelect:e=>void m(e),layoutMode:`fit`,variant:`active-pill`,activePillInsetClassName:`gap-0.5 px-px py-0`,className:`h-full`})}),(0,$.jsx)(`button`,{type:`button`,className:Y(`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors`,`hover:text-foreground hover:bg-interactive-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),onClick:h,disabled:g||_,"aria-label":T(`header.services.refreshRateLimitsAria`),children:(0,$.jsx)(Z,{name:`refresh`,className:Y(`h-4 w-4`,_&&`animate-spin`)})})]})]}),v?null:(0,$.jsx)(`div`,{className:`px-4 py-5 text-center`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:T(`header.services.noRateLimits`)})}),(0,$.jsx)(`div`,{className:`space-y-2 px-3 py-2.5`,children:y.map(e=>{let t=b[e.providerId]??[];return(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pb-2`,children:[(0,$.jsx)(Os,{providerId:e.providerId,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:e.providerName})]}),e.entries.length===0&&(!e.modelFamilies||e.modelFamilies.length===0)?(0,$.jsx)(`div`,{children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:e.error??T(`header.services.noRateLimitsReported`)})}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[e.entries.map((t,n)=>{let[r,i]=t,a=Rl(e.entries,n),o=f===`remaining`?i.remainingPercent:i.usedPercent,s=i.disablePace?null:ec(i.usedPercent,i.resetAt,i.windowSeconds,r),c=s?.dailyAllocationPercent==null?null:f===`remaining`?100-nc(s.elapsedRatio):nc(s.elapsedRatio),l=Qs(i.valueLabel,o),u=$s(i.resetAt,i.resetAfterFormatted??i.resetAtFormatted,C);return(0,$.jsxs)(Q.Fragment,{children:[a?(0,$.jsx)(`div`,{className:Y(`typography-micro font-medium uppercase tracking-wide text-muted-foreground`,n>0&&`mt-5 border-t border-[var(--surface-subtle)] pt-3`),children:a}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground break-words`,children:tc(i.label??r)}),u?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:u}):null]}),(0,$.jsx)(`span`,{className:`min-w-0 max-w-[55%] shrink-0 break-words text-right typography-ui-label tabular-nums text-foreground`,children:l===`-`?``:l})]}),(0,$.jsx)(hu,{percent:o,tonePercent:i.usedPercent,className:`h-1.5`,expectedMarkerPercent:c}),s&&S?(0,$.jsx)(ou,{paceInfo:s,compact:!0}):null]})]},`${e.providerId}-${r}`)}),e.modelFamilies&&e.modelFamilies.length>0?(0,$.jsx)(`div`,{className:`space-y-0.5`,children:e.modelFamilies.map(n=>{let r=n.familyId??`other`,i=t.includes(r);return(0,$.jsxs)(ji,{open:i,onOpenChange:()=>x(e.providerId,r),children:[(0,$.jsxs)(Ai,{className:`flex w-full items-center justify-between rounded-md px-1 py-1.5 text-left hover:bg-[var(--interactive-hover)]/50 transition-colors`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:n.familyLabel}),i?(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground`}):(0,$.jsx)(Z,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground`})]}),(0,$.jsx)(ki,{children:(0,$.jsx)(`div`,{className:`space-y-2.5 pb-1 pl-1 pt-1`,children:n.models.map(t=>{let[n,r]=t,i=f===`remaining`?r.remainingPercent:r.usedPercent,a=ec(r.usedPercent,r.resetAt,r.windowSeconds),o=a?.dailyAllocationPercent==null?null:f===`remaining`?100-nc(a.elapsedRatio):nc(a.elapsedRatio),s=Qs(r.valueLabel,i);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Gs(n)}),(0,$.jsx)(`span`,{className:`typography-ui-label tabular-nums text-foreground`,children:s===`-`?``:s})]}),(0,$.jsx)(hu,{percent:i,tonePercent:r.usedPercent,className:`h-1.5`,expectedMarkerPercent:o}),a&&S?(0,$.jsx)(ou,{paceInfo:a,compact:!0}):null]},`${e.providerId}-${n}`)})})})]},r)})}):null]})]},e.providerId)})})]}):null,t[26]=s,t[27]=b,t[28]=m,t[29]=h,t[30]=v,t[31]=g,t[32]=_,t[33]=f,t[34]=p,t[35]=d,t[36]=y,t[37]=S,t[38]=T,t[39]=C,t[40]=x,t[41]=F):F=t[41];let I;t[42]!==w||t[43]!==M||t[44]!==N||t[45]!==P||t[46]!==F?(I=(0,$.jsxs)(bi,{anchor:w,align:`start`,sideOffset:6,collisionPadding:12,className:`w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto bg-[var(--surface-elevated)] p-0 [&_[role=tab]]:capitalize`,children:[M,N,P,F]}),t[42]=w,t[43]=M,t[44]=N,t[45]=P,t[46]=F,t[47]=I):I=t[47];let L;return t[48]!==i||t[49]!==k||t[50]!==I?(L=(0,$.jsxs)(Ci,{open:i,onOpenChange:k,children:[A,I]}),t[48]=i,t[49]=k,t[50]=I,t[51]=L):L=t[51],L}),qd=(e,t)=>e===t?!0:!e||!t?!1:e.totalTokens===t.totalTokens&&e.pending===t.pending&&e.percentage===t.percentage&&e.contextLimit===t.contextLimit&&(e.outputLimit??0)===(t.outputLimit??0)&&(e.normalizedOutput??0)===(t.normalizedOutput??0)&&e.thresholdLimit===t.thresholdLimit&&(e.lastMessageId??``)===(t.lastMessageId??``),Jd=(e,t)=>{if(!e)return`-`;try{return Us(e,t,{fallback:`-`})}catch{return`-`}},Yd=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+$/g,``);return r=r.replace(/\/+/g,`/`),n&&!r.startsWith(`//`)&&(r=`/${r}`),r===``?t.startsWith(`/`)?`/`:``:r},Xd=e=>!e?.isOpen||!Array.isArray(e.tabs)||e.tabs.length===0?null:(e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[e.tabs.length-1])?.mode??null,Zd=e=>{let t=(0,ju.c)(3),n=un(rf),r;return t[0]!==n||t[1]!==e?(r=n?(0,$.jsx)(Qd,{...e,hostId:n}):(0,$.jsx)(tf,{...e}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r},Qd=e=>{let t=(0,ju.c)(11),n,r;t[0]===e?(n=t[1],r=t[2]):({hostId:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i=bt(),a=Dr(!0),o=Or(a.registry,n),s;t[3]!==n||t[4]!==a.catalog?.hosts?(s=a.catalog?.hosts.find(e=>e.id===n)?.name??n,t[3]=n,t[4]=a.catalog?.hosts,t[5]=s):s=t[5];let c=s,l=i?.registry??a.registry,u;return t[6]!==c||t[7]!==r||t[8]!==o.data||t[9]!==l?(u=(0,$.jsx)(tf,{...r,remoteSummaries:o.data,remoteHostName:c,remoteRegistry:l}),t[6]=c,t[7]=r,t[8]=o.data,t[9]=l,t[10]=u):u=t[10],u},$d=Q.memo(e=>{let t=(0,ju.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:ht,enabled:!1,staleTime:1/0,gcTime:1/0,select:o},t[5]=a,t[6]=o,t[7]=s):s=t[7];let c=yt(s,Tt).data??i,l;return t[8]===c?l=t[9]:(l=(0,$.jsx)($.Fragment,{children:c}),t[8]=c,t[9]=l),l}),ef=Q.memo(e=>{let t=(0,ju.c)(39),{entry:n,sessionId:r,onClick:i,pressed:a}=e,o=n.location,s=Q.useSyncExternalStore(Qe,Ze,Ze),c;t[0]===o?c=t[1]:(c=Xe(o),t[0]=o,t[1]=c);let l=c,d;t[2]!==o||t[3]!==l||t[4]!==r?(d=l?rt(o,r):null,t[2]=o,t[3]=l,t[4]=r,t[5]=d):d=t[5];let f;t[6]!==s||t[7]!==d?(f={revision:s,scope:d},t[6]=s,t[7]=d,t[8]=f):f=t[8];let p=f.scope,m;t[9]!==l||t[10]!==p?(m=e=>l&&p?l.subscribe(p,e):af,t[9]=l,t[10]=p,t[11]=m):m=t[11];let h=m,g;t[12]!==l||t[13]!==p?(g=()=>l&&p?l.getTranscript(p):null,t[12]=l,t[13]=p,t[14]=g):g=t[14];let _=g,v=Q.useSyncExternalStore(h,_,_),y;t[15]!==n||t[16]!==o.directory?(y=rn(o.directory,u(),n),t[15]=n,t[16]=o.directory,t[17]=y):y=t[17];let b;t[18]===y?b=t[19]:(b={...y,enabled:!1,staleTime:1/0,gcTime:1/0},t[18]=y,t[19]=b);let x=yt(b,Tt),S;t[20]!==o||t[21]!==r?(S=e=>e.getSessionModelSelection(r,o),t[20]=o,t[21]=r,t[22]=S):S=t[22];let C=ur(S),w;bb0:{if(!v){w=null;break bb0}for(let e=v.messageOrder.length-1;e>=0;e--){let t=v.messagesByID[v.messageOrder[e]];if(!t)continue;let n=ct([t],e=>v.partsByMessageID[e]);if(n){w=n;break bb0}}w=null}let T=w,E=T&&`messageId`in T&&v?v.messagesByID[T.messageId]:void 0,D;if(t[23]!==T||t[24]!==E?.modelID||t[25]!==E?.providerID||t[26]!==x.data?.providers||t[27]!==C?.modelId||t[28]!==C?.providerId){let e=x.data?.providers.find(e=>e.id===(C?.providerId??E?.providerID))?.models[C?.modelId??E?.modelID??``];D=Je(T,e?.limit?.context??0,e?.limit?.output??0),t[23]=T,t[24]=E?.modelID,t[25]=E?.providerID,t[26]=x.data?.providers,t[27]=C?.modelId,t[28]=C?.providerId,t[29]=D}else D=t[29];let O=D;if(!O)return null;let k=O.contextLimit>0?Math.min(999,O.totalTokens/O.contextLimit*100):0,A=O.outputLimit??0,j;return t[30]!==i||t[31]!==a||t[32]!==k||t[33]!==A||t[34]!==O.contextLimit||t[35]!==O.pending||t[36]!==O.percentage||t[37]!==O.totalTokens?(j=(0,$.jsx)(rc,{pending:O.pending,totalTokens:O.totalTokens,percentage:k,colorPercentage:O.percentage,contextLimit:O.contextLimit,outputLimit:A,size:`compact`,appearance:`subtle`,onClick:i,pressed:a}),t[30]=i,t[31]=a,t[32]=k,t[33]=A,t[34]=O.contextLimit,t[35]=O.pending,t[36]=O.percentage,t[37]=O.totalTokens,t[38]=j):j=t[38],j}),tf=({onToggleLeftDrawer:e,onToggleRightDrawer:t,leftDrawerOpen:r,rightDrawerOpen:i,remoteSummaries:a,remoteHostName:o,remoteRegistry:s})=>{let{t:c}=Nr(),l=q(e=>e.setSessionSwitcherOpen),d=q(e=>e.toggleSidebar),f=q(e=>e.isSidebarOpen),m=q(e=>e.toggleBottomTerminal),_=q(e=>e.toggleContextPanel),v=q(e=>e.openContextOverview),y=q(e=>e.openContextBrowser),b=q(e=>e.closeContextPanel),S=q(e=>e.activeMainTab),w=q(e=>e.setActiveMainTab),T=q(e=>e.shortcutOverrides),E=q(e=>e.timeFormatPreference),D=jn(e=>e.getCurrentModel),O=wt(),k=Kn(e=>!!e.newSessionDraft?.open),A=Kn(e=>e.currentSessionId),M=un(e=>e.activeProjectId?e.projects.find(t=>t.id===e.activeProjectId)??null:null),N=!!M?.hostId,P=sn(e=>e.remoteSession),F=M?.hostId&&P?.projectId===M.id&&P.location.hostId===M.hostId&&(!M.hubId||P.location.hubId===M.hubId)?P:null,I=N?F?.sessionId??null:A,R=N?!F?.sessionId:k,z=qn(N?``:I??``),V=ln(N?null:I),te=un(e=>e.projects),re=Q.useMemo(()=>{if(!N)return V;let e=F?.location.directory??M?.path,t=M?.hubId??s?.hubId,n=M?.hostId;if(!(!e||!t||!n||It(te,t,n,e,a?.worktrees)?.id!==M?.id))return a?.directories.find(t=>t.directory===e)?.sessions.find(t=>t.id===I&&t.directory===e)},[N,V,F?.location.directory,M,s?.hubId,te,a,I]),ie=Q.useMemo(()=>{if(!M)return null;let e=M.path.split(/[\\/]/).filter(Boolean);return e[e.length-1]??null},[M]),H=Xs(e=>e.results),U=Xs(e=>e.fetchAllQuotas),se=Xs(e=>e.isLoading),ue=Xs(e=>e.lastUpdated),de=Xs(e=>e.displayMode),fe=Xs(e=>e.showPredValues),pe=Xs(e=>e.dropdownProviderIds),me=Xs(e=>e.loadSettings),he=Xs(e=>e.setDisplayMode),{isMobile:ge}=fi(),_e=Is().data??null,ve=Nl(e=>e.setStatus),ye=Q.useRef(null),[be,xe]=Q.useState(()=>typeof window>`u`?!1:C()),Se=Q.useMemo(()=>L(),[]),Ce=be&&B()===`win32`,we=di(),Te=Ru(),Ee=Q.useMemo(()=>typeof navigator>`u`?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||``),[]),{usesFramelessChrome:De,side:Oe}=oc(),ke=Q.useMemo(()=>{if(typeof window>`u`)return null;let e=window.__YURI_MACOS_MAJOR__;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return e;if(typeof navigator>`u`)return null;let t=(navigator.userAgent||``).match(/Mac OS X (\d+)[._](\d+)/);if(!t)return null;let n=Number.parseInt(t[1],10),r=Number.parseInt(t[2],10);return Number.isNaN(n)?null:n===10?r:n},[]);(0,Q.useEffect)(()=>{typeof window>`u`||xe(C())},[]);let Ae=D(),je=Ae&&typeof Ae.limit==`object`&&Ae.limit!==null?Ae.limit:null,Me=je&&typeof je.context==`number`?je.context:0,Pe=je&&typeof je.output==`number`?je.output:0,Fe=rr(N?``:I??``,Me,Pe),G=R?null:Fe,[Ie,Le]=Q.useState(null),Re=!I||z;(0,Q.useEffect)(()=>{if(!I){Le(e=>e===null?e:null);return}if(G){Le(e=>qd(e,G)?e:G);return}Re&&Le(e=>e===null?e:null)},[G,I,Re]);let ze=q(e=>e.isSessionSwitcherOpen),Be=_e?.connected?_e.user?.avatarUrl??null:null,Ve=_e?.connected?_e.user?.login??null:null,He=_e?.accounts??[],[Ue,We]=Q.useState(!1),[Ge,Ke]=Q.useState(!1),[qe,Je]=Q.useState(!1),[Ye,Xe]=Q.useState(!1),[Ze,Qe]=Q.useState(`Local`),[$e,et]=Q.useState(!1),[tt,nt]=Q.useState(be?`instance`:`usage`),[rt,it]=Q.useState(`usage`);(0,Q.useEffect)(()=>{!be&&tt===`instance`&&nt(`usage`)},[tt,be]);let at=Q.useMemo(()=>ae(),[]),ot=!at&&S===`chat`&&!!Ie,st=Ie&&Ie.contextLimit>0?Math.min(999,Ie.totalTokens/Ie.contextLimit*100):0,ct=K(async()=>{if(!(typeof window>`u`||!be))try{if(x()){Qe(`Local`),et(!1);return}let e=u(),t=await ce();if(u()!==e)return;let n=h(),r=p(),i=r.startsWith(`host:`)?r.slice(5):null,a=(i?t.hosts.find(e=>e.id===i):void 0)??t.hosts.find(e=>n?W(n,oe(e)):!1);if(h()!==n)return;if(et(!!n),a?.label?.trim()){Qe(le(a.label.trim()));return}Qe(`Instance`)}catch{Qe(`Local`),et(!1)}});(0,Q.useEffect)(()=>{ct()},[be]),Js();let lt=Xs(e=>e.selectedModels),ut=Xs(e=>e.expandedFamilies),dt=Xs(e=>e.toggleFamilyExpanded),ft=Q.useMemo(()=>{let e=[];for(let t of Zs(H)){if(!pe.includes(t.id))continue;let n=H.find(e=>e?.providerId===t.id),r=n?.usage?.windows??{},i=n?.usage?.models,a=Ll(Object.entries(r),n?.usage?.accounts),o={providerId:t.id,providerName:t.name,entries:a,error:n&&!n.ok&&n.configured?n.error:void 0};if(i&&Object.keys(i).length>0){let e=lt[t.id]??[],n=e.length>0,r=Ys(i,t.id),a=qs(t.id),s=Ks(a);o.modelFamilies=[];for(let t of s){let a=r.get(t.id)??[];if(a.length===0)continue;let s=n?a.filter(t=>e.includes(t)):a;if(s.length===0)continue;let c=[];for(let e of s){let t=i[e];if(t?.windows){let n=Object.entries(t.windows);n.length>0&&c.push([e,n[0][1]])}}c.length>0&&o.modelFamilies.push({familyId:t.id,familyLabel:t.label,models:c})}let l=r.get(null)??[],u=n?l.filter(t=>e.includes(t)):l;if(u.length>0){let e=[];for(let t of u){let n=i[t];if(n?.windows){let r=Object.entries(n.windows);r.length>0&&e.push([t,r[0][1]])}}e.length>0&&o.modelFamilies.push({familyId:null,familyLabel:c(`header.services.modelFamily.other`),models:e})}}(a.length>0||o.modelFamilies&&o.modelFamilies.length>0||o.error)&&e.push(o)}return e},[pe,H,lt,c]),pt=ft.length>0;Q.useEffect(()=>{me()},[me]);let mt=Q.useCallback(async e=>{he(e);try{await Ne({usageDisplayMode:e})}catch(e){console.warn(`Failed to update usage display mode:`,e)}},[he]),ht=Q.useCallback(()=>{if(Ye)return;Xe(!0);let e=new Promise(e=>setTimeout(e,500));Promise.all([U(),e]).finally(()=>{Xe(!1)})},[U,Ye]),gt=Kn(e=>N||!I?``:e.worktreeMetadata.get(I)?.path??``),_t=Q.useMemo(()=>Yd(gt||``),[gt]),vt=Q.useMemo(()=>Yd((typeof re?.directory==`string`?re.directory:``)||``),[re?.directory]),yt=Kn(e=>e.newSessionDraft?.open?Yd(e.newSessionDraft.bootstrapPendingDirectory??e.newSessionDraft.directoryOverride??``):``),bt=Q.useMemo(()=>N?F?.location.directory??M?.path??``:_t||vt||yt,[N,F?.location.directory,M?.path,yt,vt,_t]),xt=Ui(),St=F?ne(F.location):M?.hostId&&M.hubId?ne({hubId:M.hubId,hostId:M.hostId,directory:xt??M.path}):``,Ct=Q.useMemo(()=>N?St:Yd(xt||bt||M?.path||``),[N,St,M?.path,xt,bt]),Tt=q(e=>Ht(e,Ct)),Et=!!Tt?.isOpen,Dt=K(()=>_(Ct)),Ot=Q.useMemo(()=>{if(!I)return ie??`Yuri`;let e=re?.title?.trim();return e&&e.length>0?e:`Untitled Session`},[ie,re?.title,I]),kt=Q.useMemo(()=>N?bt:Yd(bt||M?.path||``),[N,M?.path,bt]),At=Q.useMemo(()=>M?{id:M.id,path:M.path,hostId:M.hostId,hubId:M.hubId}:null,[M]),jt=Q.useRef(null);Q.useEffect(()=>{!At||!kt||(jt.current={projectRef:At,directory:kt})},[kt,At]);let Mt=Q.useMemo(()=>At&&kt?{projectRef:At,directory:kt}:jt.current,[kt,At]),Nt=Q.useCallback(async e=>{if(!(!e||Ue)){We(!0);try{let t=O.github?await O.github.authActivate(e):await(async()=>{let t=await g(`/api/github/auth/activate`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({accountId:e})}),n=await t.json().catch(()=>null);if(!t.ok||!n)throw Error(n?.error||t.statusText);return n})();ve(t)}catch(e){console.error(`Failed to switch GitHub account:`,e)}finally{We(!1)}}},[Ue,O.github,ve]),Pt=Q.useCallback(()=>{if(typeof document>`u`)return;let e=document.activeElement;if(!e)return;let t=e.tagName;(t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||e.isContentEditable)&&e.blur()},[]),Lt=Q.useCallback(()=>{if(ge){Pt(),l(!ze);return}d()},[Pt,ge,ze,l,d]),Rt=Q.useCallback(()=>{N||ee(`desktop_open_draft_mini_chat_window`,{directory:Yd(bt||M?.path||``),projectId:M?.id??null,apiBaseUrl:h(),clientToken:n()}).catch(e=>{console.warn(`[header] failed to open draft mini chat window`,e)})},[N,M?.id,M?.path,bt]),zt=Q.useCallback(()=>{if(!N){if(R){Rt();return}I&&ee(`desktop_open_session_mini_chat_window`,{sessionId:I,directory:Yd(bt||M?.path||``),apiBaseUrl:h(),clientToken:n()}).catch(e=>{console.warn(`[header] failed to open session mini chat window`,e)})}},[N,M?.path,I,Rt,R,bt]),Bt=Q.useCallback(()=>{let e=Ct;if(e){if(Xd(Tt)===`context`){b(e);return}v(e)}},[b,Ct,Tt,v]),Vt=Q.useMemo(()=>Ct?Xd(Tt)===`context`:!1,[Ct,Tt]),Ut=Q.useCallback(()=>{let e=Ct;if(e){if(Xd(Tt)===`browser`){b(e);return}y(e)}},[b,Ct,Tt,y]),Wt=Q.useMemo(()=>Ct?Xd(Tt)===`browser`:!1,[Ct,Tt]),Gt=Hd,Kt=Ud,qt=Q.useMemo(()=>Ge?`services`:r?`sessions`:i?`git`:S,[S,Ge,r,i]),Jt=Q.useCallback(()=>{Ke(!1),r&&e&&e(),i&&t&&t(),!e&&ze&&l(!1)},[ze,r,e,t,i,l]),Yt=Q.useCallback(()=>{r||Ke(!1),e?.()},[r,e]),Xt=Q.useCallback(()=>{i||Ke(!1),t?.()},[t,i]),Zt=Q.useMemo(()=>be&&Ee&&!Te?`5.5rem`:we?`max(calc(0.75rem + var(--yuri-wco-left-inset, 0px)), 5.5rem)`:(!be||De)&&!at?`calc(0.75rem + var(--yuri-wco-left-inset, 0px))`:`0.75rem`,[be,Te,Ee,we,at,De]);(0,Q.useEffect)(()=>{typeof document>`u`||document.documentElement.style.setProperty(`--yuri-titlebar-left-inset`,Zt)},[Zt]);let Qt=f?`0.75rem`:`var(--yuri-titlebar-left-inset, 0.75rem)`,$t=f?`0px`:`calc(var(--yuri-titlebar-controls-width, 5.5rem) + 0.5rem)`,en=Q.useMemo(()=>!be||!Ee||ke===null?``:ke>=26?`h-12`:ke<=15?`h-14`:``,[be,Ee,ke]),tn=Q.useMemo(()=>{if(!(be&&!De||at))return{paddingRight:Et?`0.75rem`:`calc(0.75rem + var(--yuri-wco-right-inset, 0px))`,minHeight:`max(3rem, var(--yuri-wco-titlebar-height, 0px))`,height:`max(3rem, var(--yuri-wco-titlebar-height, 0px))`}},[be,at,Et,De]),nn=K(e=>{if(!e||typeof document>`u`)return;let t=document.documentElement.style,n=`${e}px`;t.getPropertyValue(`--yuri-header-height`)!==n&&t.setProperty(`--yuri-header-height`,n)});Ft(ye,([e])=>{e&&nn(e.borderBoxSize[0]?.blockSize??e.target.getBoundingClientRect().height)},{box:`border-box`}),Q.useLayoutEffect(()=>{nn(ye.current?.getBoundingClientRect().height)},[nn,ge,en]);let rn=Q.useCallback(async e=>{let t=e.target;t.closest(`.app-region-no-drag`)||t.closest(`button, a, input, select, textarea`)||e.button===0&&be&&await j()},[be]),an=Q.useMemo(()=>{if(ge){let e=[{id:`chat`,label:c(`layout.mainTab.chat`),icon:`chat-thread`}];return e.push({id:`diff`,label:c(`layout.mainTab.diff`),icon:`diff`},{id:`files`,label:c(`layout.mainTab.files`),icon:`folder-6`},{id:`terminal`,label:c(`layout.mainTab.terminal`),icon:`terminal-box`},{id:`diagram`,label:c(`layout.mainTab.diagram`),icon:`file`}),e}return[]},[ge,c]),on=Q.useCallback(e=>Sa(Ta(e,T)),[T]);(0,Q.useEffect)(()=>{!ge&&(S===`git`||S===`terminal`||S===`diff`||S===`files`)&&w(`chat`)},[S,ge,w]);let cn=Q.useMemo(()=>{let e=[];return be&&e.push({value:`instance`,label:c(`layout.services.instance`),icon:(0,$.jsx)(Z,{name:`connection-local`,className:`h-3.5 w-3.5`})}),e.push({value:`usage`,label:c(`layout.services.usage`),icon:(0,$.jsx)(Z,{name:`timer`,className:`h-3.5 w-3.5`})},{value:`mcp`,label:`MCP`,icon:(0,$.jsx)(Il,{className:`h-3.5 w-3.5`})}),e},[be,c]),dn=Q.useMemo(()=>cn.map(e=>({id:e.value,label:e.label,icon:e.icon})),[cn]),fn=Q.useMemo(()=>[{value:`usage`,label:c(`header.services.used`)},{value:`remaining`,label:c(`header.services.remaining`)}],[c]),pn=Q.useMemo(()=>fn.map(e=>({id:e.value,label:e.label})),[fn]),mn=Q.useMemo(()=>[{id:`usage`,label:c(`layout.services.usage`),icon:(0,$.jsx)(Z,{name:`timer`,className:`h-3.5 w-3.5`})},{id:`mcp`,label:`MCP`,icon:(0,$.jsx)(Il,{className:`h-3.5 w-3.5`})}],[c]);(0,Q.useEffect)(()=>{let e=e=>{if($n(e)&&!e.shiftKey&&!e.altKey){let t=parseInt(e.key,10);t>=1&&t<=an.length&&(e.preventDefault(),ge&&(Pt(),Jt()),w(an[t-1].id))}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Pt,Jt,ge,w,an]);let hn=K(e=>{nt(e),Je(!0),ct(),e===`usage`&&ue===null&&U()});(0,Q.useEffect)(()=>{let e=e=>{let t=Ta(`toggle_services_menu`,T);if(wa(e,t)){e.preventDefault();let t=Vd({isOpen:qe,activeTab:tt,targetTab:be?`instance`:`usage`});t.open?hn(t.tab):Je(!1);return}let n=Ta(`cycle_services_tab`,T);if(wa(e,n)){e.preventDefault();let t=cn.map(e=>e.value);if(t.length===0)return;let n=t.indexOf(tt),r=t[n===-1?0:(n+1)%t.length];nt(r),Je(!0),ct(),r===`usage`&&ue===null&&U();return}let r=Ta(`open_usage`,T);if(wa(e,r)){e.preventDefault();let t=Vd({isOpen:qe,activeTab:tt,targetTab:`usage`});t.open?hn(t.tab):Je(!1);return}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[T,be,qe,tt,cn,ue,U,ct,hn]);let gn=e=>{let t=S===e.id,n=e.icon===`diff`,r=n?null:e.icon,i=e.id===`chat`,a=e=>n?(0,$.jsx)(Mu,{size:e}):r?(0,$.jsx)(Z,{name:r,className:`h-${e/4} w-${e/4}`}):null,o=(0,$.jsxs)(`button`,{type:`button`,onClick:()=>w(e.id),className:Y(`relative flex h-8 items-center gap-2 px-3 rounded-lg typography-ui-label font-medium transition-colors`,t?`app-region-no-drag bg-interactive-selection text-interactive-selection-foreground shadow-none`:`app-region-no-drag text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,i&&!ge&&`min-w-[100px] justify-center`),"aria-label":e.label,"aria-selected":t,role:`tab`,children:[ge?a(20):(0,$.jsxs)($.Fragment,{children:[a(16),(0,$.jsx)(`span`,{className:`header-tab-label`,children:e.label})]}),e.badge!==void 0&&e.badge>0&&(0,$.jsx)(`span`,{className:`header-tab-badge typography-micro text-status-info font-medium`,children:e.badge})]});return(0,$.jsx)(Q.Fragment,{children:o},e.id)},_n=!N&&Se&&(R||!!I),vn=Q.useCallback(e=>{window.setTimeout(e,0)},[]),yn=Q.useCallback(e=>{hn(e)},[hn]),bn=Q.useRef(null),xn=(0,$.jsxs)(`div`,{className:`relative flex shrink-0 items-center`,children:[(0,$.jsx)(`div`,{ref:bn,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center`,children:(0,$.jsxs)(Ci,{children:[(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(vi,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":c(`header.actions.sessionMenuAria`),className:Y(Gt,`text-muted-foreground`),children:(0,$.jsx)(Z,{name:`more-2`,className:`h-[18px] w-[18px]`})})})}),(0,$.jsx)(ei,{children:(0,$.jsx)(`p`,{children:c(`header.actions.sessionMenu`)})})]}),(0,$.jsxs)(bi,{align:`start`,className:`min-w-[14rem]`,children:[_n?(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>vn(zt),children:[(0,$.jsx)(Z,{name:`picture-in-picture-2`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(R?`header.actions.newMiniChat`:`header.actions.openSessionMiniChat`)})]}):null,be?(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>vn(()=>yn(`instance`)),children:[(0,$.jsx)(Z,{name:`stack`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:c(`header.actions.sessionMenu.servicesWithInstance`,{current:Ze})}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:on(`toggle_services_menu`)})]}):null,(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>vn(()=>yn(`usage`)),children:[(0,$.jsx)(Z,{name:`timer`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(`header.actions.sessionMenu.viewUsage`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:on(`open_usage`)})]}),(0,$.jsx)(Si,{}),(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>vn(m),children:[(0,$.jsx)(Z,{name:`terminal-box`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(`header.actions.toggleTerminalPanel`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:on(`toggle_terminal`)})]}),(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>vn(Ut),children:[(0,$.jsx)(Z,{name:`global`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(`contextPanel.browser.open`)}),Wt?(0,$.jsx)(Z,{name:`check`,className:`h-3.5 w-3.5 text-foreground`}):null]})]})]})}),(0,$.jsx)(Kd,{isDesktopApp:be,currentInstanceSupportsUpdate:$e,isDesktopServicesOpen:qe,setIsDesktopServicesOpen:Je,refreshCurrentInstanceLabel:ct,desktopServicesTab:tt,setDesktopServicesTab:nt,fetchAllQuotas:U,servicesTabItems:dn,quotaLastUpdated:ue,quotaDisplayMode:de,showPredValues:fe,quotaDisplayTabItems:pn,handleDisplayModeChange:mt,handleUsageRefresh:ht,isQuotaLoading:se,isUsageRefreshSpinning:Ye,hasRateLimits:pt,rateLimitGroups:ft,expandedFamilies:ut,toggleFamilyExpanded:dt,timeFormatPreference:E,anchorRef:bn})]}),Sn=(0,$.jsxs)($.Fragment,{children:[!N&&!ge&&!at&&S===`chat`?(0,$.jsx)(Vu,{}):null,N?null:(0,$.jsx)(yd,{directory:kt}),be&&(0,$.jsx)(Ju,{open:qe&&tt===`instance`,onClick:()=>hn(`instance`)}),(0,$.jsx)(Wd,{title:c(`header.actions.rightSidebarWithShortcut`,{shortcut:on(`toggle_right_sidebar`)}),ariaLabel:c(`contextPanel.actions.togglePanel`),pressed:Et,onClick:Dt,className:Y(`app-region-no-drag group inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary hover:bg-interactive-hover transition-colors`,Et?`bg-interactive-selection text-interactive-selection-foreground`:`text-muted-foreground/75 hover:text-foreground`),Icon:`folder-3`,iconClassName:`size-4`}),(0,$.jsx)(Gd,{isMobile:ge,githubAuthStatus:_e,githubAccounts:He,githubAvatarUrl:Be,githubLogin:Ve,isSwitchingGitHubAccount:Ue,handleGitHubAccountSwitch:Nt})]}),Cn=()=>(0,$.jsxs)(`div`,{onMouseDown:rn,className:Y(`app-region-drag relative flex h-12 select-none items-center pr-3`,en),style:tn,role:`tablist`,"aria-label":c(`header.navigation.mainAria`),children:[(0,$.jsx)(`div`,{"aria-hidden":!0,className:`shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,style:{width:Qt}}),(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-no-drag shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,style:{width:$t}}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[(0,$.jsxs)(`div`,{className:`app-region-no-drag mr-3 flex min-w-0 items-center gap-0.5`,children:[(0,$.jsx)(ac,{scopeProjectId:N?M?.id:null,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":c(`sessions.switcher.openAria`),className:`inline-flex h-8 min-w-0 max-w-full items-center rounded-md px-2.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-primary`,children:(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground`,children:R?c(`sessions.switcher.draftTitle`):N&&s&&F?.sessionId?(0,$.jsx)($d,{entry:s.resolve(F.location),sessionId:F.sessionId,fallback:Ot},ne(F.location)):Ot})})}),N?(0,$.jsxs)(`span`,{"data-remote-header-host":M?.hostId,className:`inline-flex min-w-0 max-w-36 items-center gap-1 typography-meta text-muted-foreground`,title:o,children:[(0,$.jsx)(Z,{name:`computer`,className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:o}),s&&M?.hostId?(0,$.jsx)(zo,{registry:s,hostId:M.hostId}):null]}):null]}),an.length>0&&(0,$.jsx)(`div`,{className:`flex items-center gap-1 rounded-lg bg-[var(--surface-muted)]/50 p-1`,children:an.map(e=>gn(e))}),(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[xn,N&&!at&&S===`chat`&&s&&F?.sessionId?(0,$.jsx)(ef,{entry:s.resolve(F.location),sessionId:F.sessionId,onClick:Bt,pressed:Vt},ne(F.location)):null,ot&&Ie?(0,$.jsx)(rc,{pending:Ie.pending,totalTokens:Ie.totalTokens,percentage:st,colorPercentage:Ie.percentage,contextLimit:Ie.contextLimit,outputLimit:Ie.outputLimit??0,size:`compact`,appearance:`subtle`,onClick:Bt,pressed:Vt}):null,Sn,(0,$.jsx)(ic,{visible:De&&Oe===`right`&&!Et,position:`right`})]})]})]}),wn=()=>(0,$.jsxs)(`div`,{className:`app-region-drag relative flex items-center gap-2 px-3 py-2 select-none`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e?(0,$.jsx)(`button`,{type:`button`,onClick:Yt,className:Y(Kt,qt===`sessions`&&`bg-interactive-selection text-interactive-selection-foreground`),"aria-label":c(r?`header.actions.closeSessionsAria`:`header.actions.openSessionsAria`),children:(0,$.jsx)(Z,{name:`layout-left`,className:`h-5 w-5`})}):ze?(0,$.jsx)(`button`,{type:`button`,onClick:()=>l(!1),className:`app-region-no-drag h-9 w-9 p-2 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary rounded-md active:bg-interactive-active`,"aria-label":c(`header.actions.backAria`),children:(0,$.jsx)(Z,{name:`arrow-left-s`,className:`h-5 w-5`})}):(0,$.jsx)(`button`,{type:`button`,onClick:Lt,className:`app-region-no-drag h-9 w-9 p-2 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary rounded-md active:bg-interactive-active`,"aria-label":c(`header.actions.openSessionsAria`),children:(0,$.jsx)(Z,{name:`play-list-add`,className:`h-5 w-5`})}),!e&&ze&&(0,$.jsx)(`span`,{className:`typography-ui-label font-semibold text-foreground`,children:c(`header.sessions.title`)})]}),(!ze||!!e)&&(0,$.jsxs)($.Fragment,{children:[N?(0,$.jsxs)(`span`,{"data-remote-header-host":M?.hostId,className:`inline-flex max-w-28 shrink-0 items-center gap-1 typography-meta text-muted-foreground`,title:o,children:[(0,$.jsx)(`span`,{className:`truncate`,children:o}),s&&M?.hostId?(0,$.jsx)(zo,{registry:s,hostId:M.hostId}):null]}):null,(0,$.jsx)(`div`,{className:`app-region-no-drag flex min-w-0 flex-1 items-center`,children:(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 overflow-x-auto overflow-y-hidden scrollbar-hidden touch-pan-x overscroll-x-contain`,children:(0,$.jsx)(`div`,{className:`flex w-max items-center gap-1 pr-1`,children:(0,$.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg bg-[var(--surface-muted)]/50 p-0.5`,role:`tablist`,"aria-label":c(`header.navigation.mainAria`),children:an.map(e=>{let t=S===e.id,n=e.icon===`diff`,r=n?null:e.icon;return(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{ge&&(Pt(),Jt()),w(e.id)},"aria-label":e.label,"aria-selected":t,role:`tab`,className:Y(Kt,`relative rounded-lg`,qt===e.id&&`bg-interactive-selection text-interactive-selection-foreground`),children:[n?(0,$.jsx)(Mu,{className:`h-5 w-5`}):r?(0,$.jsx)(Z,{name:r,className:`h-5 w-5`}):null,e.badge!==void 0&&e.badge>0&&(0,$.jsx)(`span`,{className:`absolute -top-1 -right-1 text-[10px] font-semibold text-primary`,children:e.badge}),e.showDot&&(0,$.jsx)(`span`,{className:`absolute top-1.5 right-1.5 h-2 w-2 rounded-full bg-primary`,"aria-label":c(`header.changes.availableAria`)})]})}),(0,$.jsx)(ei,{children:(0,$.jsx)(`p`,{children:e.label})})]},e.id)})})})})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,$.jsx)(Eu,{mobile:!0}),Mt&&(0,$.jsx)(Rd,{projectRef:Mt.projectRef,directory:Mt.directory,compact:!0,allowMobile:!0,className:`h-9`}),(0,$.jsxs)(Ci,{open:Ge,onOpenChange:n=>{n&&(r&&e&&e(),i&&t&&t()),Ke(n),n&&ue===null&&U()},children:[(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(vi,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":c(`header.services.viewAria`),className:Y(Kt,qt===`services`&&`bg-interactive-selection text-interactive-selection-foreground`),children:(0,$.jsx)(Z,{name:`stack`,className:`h-5 w-5`})})})}),(0,$.jsx)(ei,{children:(0,$.jsx)(`p`,{children:c(`header.services.title`)})})]}),(0,$.jsx)(bi,{align:`end`,sideOffset:0,positionerClassName:`!fixed !bottom-0 !left-0 !right-0 !top-[var(--yuri-header-height,56px)] !transform-none`,className:`h-full w-screen max-h-none rounded-none border-0 p-0 pt-1 overflow-hidden`,children:(0,$.jsxs)(`div`,{className:`flex h-full flex-col bg-[var(--surface-elevated)]`,children:[(0,$.jsx)(`div`,{className:`sticky top-0 z-20 bg-[var(--surface-elevated)] px-2 py-px`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-0`,children:[(0,$.jsx)(`div`,{className:`h-10 min-w-0 flex-1`,children:(0,$.jsx)(Vs,{items:mn,activeId:rt,onSelect:e=>{let t=e;it(t),t===`usage`&&ue===null&&U()},layoutMode:`fit`,variant:`active-pill`,activePillInsetClassName:`gap-0.5 px-px py-0`,activePillButtonClassName:`h-8`,className:`h-full`})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>Ke(!1),className:`inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover`,"aria-label":c(`header.services.closeAria`),children:(0,$.jsx)(Z,{name:`close`,className:`h-5 w-5`})})]})}),rt===`mcp`&&(0,$.jsx)(Hc,{active:Ge&&rt===`mcp`}),rt===`usage`&&(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto overflow-x-hidden pb-[calc(4rem+env(safe-area-inset-bottom))]`,children:[(0,$.jsx)(`div`,{className:`border-b border-[var(--interactive-border)]`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col min-w-0 gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-header font-semibold text-foreground`,children:c(`header.services.rateLimits`)}),(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Jd(ue,E)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center h-6`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>mt(`usage`),className:Y(`typography-ui-label px-1 pb-0.5 transition-colors`,de===`usage`?`text-foreground border-b-2 border-[var(--primary-base)]`:`text-muted-foreground hover:text-foreground`),children:c(`header.services.used`)}),(0,$.jsx)(`span`,{className:`text-muted-foreground typography-ui-label px-0.5`,children:`·`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>mt(`remaining`),className:Y(`typography-ui-label px-1 pb-0.5 transition-colors`,de===`remaining`?`text-foreground border-b-2 border-[var(--primary-base)]`:`text-muted-foreground hover:text-foreground`),children:c(`header.services.remaining`)})]}),(0,$.jsx)(`button`,{type:`button`,className:Y(`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors`,`hover:text-foreground hover:bg-interactive-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),onClick:ht,disabled:se||Ye,"aria-label":c(`header.services.refreshRateLimitsAria`),children:(0,$.jsx)(Z,{name:`refresh`,className:Y(`h-4 w-4`,Ye&&`animate-spin`)})})]})]})}),!pt&&(0,$.jsx)(`div`,{className:`px-4 py-6 text-center`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:c(`header.services.noRateLimits`)})}),(0,$.jsx)(`div`,{className:`py-1`,children:ft.map((e,t)=>(0,$.jsxs)(Q.Fragment,{children:[t>0?(0,$.jsx)(`div`,{className:`mx-4 my-1 border-t border-[var(--interactive-border)]`}):null,(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2`,children:[(0,$.jsx)(Os,{providerId:e.providerId,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:e.providerName})]}),e.entries.length===0&&(!e.modelFamilies||e.modelFamilies.length===0)?(0,$.jsx)(`div`,{className:`px-4 pb-2`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:e.error??c(`header.services.noRateLimitsReported`)})}):(0,$.jsxs)(`div`,{className:`space-y-3 px-4 pb-2`,children:[e.entries.map(([t,n],r)=>{let i=Rl(e.entries,r),a=de===`remaining`?n.remainingPercent:n.usedPercent,o=n.disablePace?null:ec(n.usedPercent,n.resetAt,n.windowSeconds,t),s=o?.dailyAllocationPercent==null?null:de===`remaining`?100-nc(o.elapsedRatio):nc(o.elapsedRatio),c=Qs(n.valueLabel,a),l=$s(n.resetAt,n.resetAfterFormatted??n.resetAtFormatted,E);return(0,$.jsxs)(Q.Fragment,{children:[i?(0,$.jsx)(`div`,{className:Y(`typography-micro font-medium uppercase tracking-wide text-muted-foreground`,r>0&&`mt-5 border-t border-[var(--surface-subtle)] pt-3`),children:i}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground break-words`,children:tc(n.label??t)}),l?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:l}):null]}),(0,$.jsx)(`span`,{className:`min-w-0 max-w-[55%] shrink-0 break-words text-right typography-ui-label text-foreground tabular-nums`,children:c===`-`?``:c})]}),(0,$.jsx)(hu,{percent:a,tonePercent:n.usedPercent,className:`h-1.5`,expectedMarkerPercent:s}),o&&fe?(0,$.jsx)(ou,{paceInfo:o,compact:!0}):null]})]},`${e.providerId}-${t}`)}),e.modelFamilies&&e.modelFamilies.length>0&&(0,$.jsx)(`div`,{className:`space-y-0.5`,children:e.modelFamilies.map(t=>{let n=(ut[e.providerId]??[]).includes(t.familyId??`other`);return(0,$.jsxs)(ji,{open:n,onOpenChange:()=>dt(e.providerId,t.familyId??`other`),children:[(0,$.jsxs)(Ai,{className:`flex w-full items-center justify-between rounded-md px-1 py-1.5 text-left hover:bg-[var(--interactive-hover)]/50 transition-colors`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:t.familyLabel}),n?(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground`}):(0,$.jsx)(Z,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground`})]}),(0,$.jsx)(ki,{children:(0,$.jsx)(`div`,{className:`space-y-2.5 pb-1 pl-1 pt-1`,children:t.models.map(([t,n])=>{let r=de===`remaining`?n.remainingPercent:n.usedPercent,i=ec(n.usedPercent,n.resetAt,n.windowSeconds),a=i?.dailyAllocationPercent==null?null:de===`remaining`?100-nc(i.elapsedRatio):nc(i.elapsedRatio),o=Qs(n.valueLabel,r);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Gs(t)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground tabular-nums`,children:o===`-`?``:o})]}),(0,$.jsx)(hu,{percent:r,tonePercent:n.usedPercent,className:`h-1.5`,expectedMarkerPercent:a}),i&&fe?(0,$.jsx)(ou,{paceInfo:i,compact:!0}):null]},`${e.providerId}-${t}`)})})})]},t.familyId??`other`)})})]})]},e.providerId))})]})]})})]}),t?(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:Xt,className:Y(Kt,`relative`,qt===`git`&&`bg-interactive-selection text-interactive-selection-foreground`),"aria-label":i?`Close git sidebar`:`Open git sidebar`,children:(0,$.jsx)(Z,{name:`layout-right`,className:`h-5 w-5`})})}),(0,$.jsx)(ei,{children:(0,$.jsx)(`p`,{children:i?`Close git sidebar`:`Open git sidebar`})})]}):null]})]})]}),Tn=Y(`header-safe-area relative z-10 bg-background`,Ce&&`bg-[var(--surface-background)] backdrop-blur-none`,ge&&`yuri-layout-divider-b`);return(0,$.jsx)($.Fragment,{children:(0,$.jsx)(`header`,{ref:ye,className:Tn,style:{"--padding-scale":`1`},children:ge?wn():Cn()})})};function nf(){}function rf(e){return e.projects.find(t=>t.id===e.activeProjectId)?.hostId}function af(){}var of=180,sf=640,cf=110,lf=e=>{let t=(0,ju.c)(44),{isOpen:n,isMobile:r,children:i}=e,{t:a}=Nr(),o=q(uf),s=q(df),c=q(ff),l=q(pf),[u,d]=Q.useState(null),[f,p]=Q.useState(!1),m=Q.useRef(null),h=Q.useRef(0),g=Q.useRef(o||300),_=Math.min(sf,Math.max(of,o||300)),v,y;t[0]===n?(v=t[1],y=t[2]):(v=()=>{n||(d(null),p(!1))},y=[n],t[0]=n,t[1]=v,t[2]=y),Q.useEffect(v,y);let b,x;t[3]!==s||t[4]!==r||t[5]!==n?(b=()=>{if(r||!n||!s)return;let e=()=>{let e=m.current?.parentElement?.getBoundingClientRect().height;if(!e||e<=0)return;let t=Math.max(0,Math.round(e));d(e=>e===t?e:t)};e();let t=m.current?.parentElement;if(!t)return;let i=new ResizeObserver(e);return i.observe(t),()=>{i.disconnect()}},x=[s,r,n],t[3]=s,t[4]=r,t[5]=n,t[6]=b,t[7]=x):(b=t[6],x=t[7]),Q.useEffect(b,x);let S,C;if(t[8]!==s||t[9]!==r||t[10]!==f||t[11]!==c||t[12]!==l?(S=()=>{if(r||!f||s)return;let e=e=>{let t=h.current-e.clientY,n=Math.min(sf,Math.max(of,g.current+t));c(n)},t=()=>{p(!1),q.getState().bottomTerminalHeight<=cf&&l(!1)};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t,{once:!0}),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},C=[s,r,f,c,l],t[8]=s,t[9]=r,t[10]=f,t[11]=c,t[12]=l,t[13]=S,t[14]=C):(S=t[13],C=t[14]),Q.useEffect(S,C),r)return null;let w=n?s?Math.max(0,u??_):_:0,T=n&&s,E;t[15]!==w||t[16]!==s||t[17]!==n?(E=e=>{!n||s||(p(!0),h.current=e.clientY,g.current=w,e.preventDefault())},t[15]=w,t[16]=s,t[17]=n,t[18]=E):E=t[18];let D=E,O=T?`absolute inset-x-0 bottom-0 z-40`:`relative`,k=f?`transition-none`:`transition-[height] duration-300 ease-in-out`,A=(!n||T)&&`border-t-0`,j;t[19]!==A||t[20]!==O||t[21]!==k?(j=Y(`flex overflow-hidden border-t border-border bg-sidebar`,O,k,A),t[19]=A,t[20]=O,t[21]=k,t[22]=j):j=t[22];let M;t[23]!==w||t[24]!==T?(M=T?{top:0}:{height:`${w}px`,minHeight:`${w}px`,maxHeight:`${w}px`},t[23]=w,t[24]=T,t[25]=M):M=t[25];let N=!n||!s&&w===0,P;t[26]!==D||t[27]!==s||t[28]!==n||t[29]!==f||t[30]!==a?(P=n&&!s&&(0,$.jsx)(`div`,{className:Y(`absolute left-0 top-0 z-20 h-[3px] w-full cursor-row-resize hover:bg-[var(--interactive-border)]/80 transition-colors`,f&&`bg-[var(--interactive-border)]`),onPointerDown:D,role:`separator`,"aria-orientation":`horizontal`,"aria-label":a(`terminalView.bottomDock.resizeAria`)}),t[26]=D,t[27]=s,t[28]=n,t[29]=f,t[30]=a,t[31]=P):P=t[31];let F=!n&&`pointer-events-none select-none opacity-0`,I;t[32]===F?I=t[33]:(I=Y(`relative z-10 flex h-full min-h-0 w-full flex-col transition-opacity duration-300 ease-in-out`,F),t[32]=F,t[33]=I);let L=!n,R;t[34]!==i||t[35]!==I||t[36]!==L?(R=(0,$.jsx)(`div`,{className:I,"aria-hidden":L,children:i}),t[34]=i,t[35]=I,t[36]=L,t[37]=R):R=t[37];let z;return t[38]!==j||t[39]!==M||t[40]!==N||t[41]!==P||t[42]!==R?(z=(0,$.jsxs)(`section`,{ref:m,className:j,style:M,"aria-hidden":N,children:[P,R]}),t[38]=j,t[39]=M,t[40]=N,t[41]=P,t[42]=R,t[43]=z):z=t[43],z};function uf(e){return e.bottomTerminalHeight}function df(e){return e.isBottomTerminalExpanded}function ff(e){return e.setBottomTerminalHeight}function pf(e){return e.setBottomTerminalOpen}var mf=260,hf=260,gf=500,_f=e=>Math.min(gf,Math.max(hf,e)),vf=({isOpen:e,isMobile:t,children:n,className:r,topBar:i})=>{let{t:a}=Nr(),o=q(e=>e.sidebarWidth),s=q(e=>e.setSidebarWidth),[c,l]=Q.useState(!1),u=Q.useRef(0),d=Q.useRef(o||mf),f=Q.useRef(null),p=Q.useRef(null),m=Q.useRef(null),h=Q.useRef(null),g=K(e=>{let t=m.current;t&&(t.style.width=`${e}px`,t.style.minWidth=`${e}px`,t.style.maxWidth=`${e}px`,h.current&&(h.current.style.width=`${e}px`))});if(Q.useEffect(()=>{t&&c&&l(!1)},[t,c]),Q.useEffect(()=>{c||(f.current=null,p.current=null)},[c]),t)return null;let _=Math.min(gf,Math.max(hf,o||mf)),v=e?_:0,y=t=>{if(e){try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}p.current=t.pointerId,l(!0),u.current=t.clientX,d.current=v,f.current=v,g(v),t.preventDefault()}},b=e=>{if(t||!c||p.current!==e.pointerId)return;let n=e.clientX-u.current,r=_f(d.current+n);f.current!==r&&(f.current=r,g(r))},x=e=>{if(p.current!==e.pointerId||t)return;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}let n=_f(f.current??v);p.current=null,f.current=null,l(!1),s(n)},S=c?f.current??v:v;return(0,$.jsxs)(`aside`,{ref:m,className:Y(`relative flex h-full overflow-hidden yuri-layout-divider-r will-change-[width] motion-reduce:transition-none`,`bg-sidebar yuri-vibrancy-surface`,!e&&`border-r-0`,r),style:{width:`${S}px`,minWidth:`${S}px`,maxWidth:`${S}px`,overflowX:`clip`,transitionProperty:c?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!e||v===0,children:[e&&(0,$.jsx)(`div`,{className:Y(`absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors`,c&&`bg-[var(--interactive-border)]`),onPointerDown:y,onPointerMove:b,onPointerUp:x,onPointerCancel:x,role:`separator`,"aria-orientation":`vertical`,"aria-label":a(`sidebar.resize.leftPanelAria`)}),(0,$.jsxs)(`div`,{ref:h,className:Y(`relative z-10 flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,c&&`pointer-events-none`,!e&&`pointer-events-none select-none opacity-0`),style:{width:`${c?S:_}px`,overflowX:`hidden`},"aria-hidden":!e,children:[i,(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,$.jsx)(No,{children:n})})]})]})},yf=()=>{let e=(0,ju.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={height:`var(--yuri-header-height, 3rem)`},e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-drag shrink-0`,style:{width:`var(--yuri-titlebar-left-inset, 0.75rem)`}}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`flex shrink-0`,style:t,children:[n,(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-no-drag shrink-0`,style:{width:`calc(var(--yuri-titlebar-controls-width, 5.5rem) + 0.5rem)`}}),(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-drag flex-1`})]}),e[2]=r):r=e[2],r},bf=e=>{let t=(0,ju.c)(26),{className:n}=e,{t:r}=Nr(),i=q(xf),a=_u(Sf).trim(),o=a.split(/\s+/).filter(Boolean),s=o.includes(`Yuri`),c=o.some(Cf);if(Q.useEffect(()=>{c&&ao()},[c]),o.length===0)return null;let l;t[0]===n?l=t[1]:(l=Y(`flex min-w-0 items-center overflow-hidden pb-2 pt-1`,n),t[0]=n,t[1]=l);let u=J,d;t[2]===r?d=t[3]:(d=r(`layout.brand.editName`),t[2]=r,t[3]=d);let f;t[4]===r?f=t[5]:(f=r(`layout.brand.editName`),t[4]=r,t[5]=f);let p;t[6]===i?p=t[7]:(p=()=>i(`appearance`,`appearance.sidebar-brand`),t[6]=i,t[7]=p);let m=o.join(` `),h=a.includes(`Yuri`)?`items-center`:`items-baseline`,g;t[8]===h?g=t[9]:(g=Y(`inline-flex min-w-0 gap-[0.28em] overflow-hidden whitespace-nowrap text-foreground`,h),t[8]=h,t[9]=g);let _;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(_={fontFamily:`"Syne", var(--font-sans, system-ui, sans-serif)`,fontSize:`1.0625rem`,fontWeight:700,letterSpacing:`0.08em`,lineHeight:1},t[10]=_):_=t[10];let v=a.includes(`Yuri`)?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex shrink-0 self-center`,children:(0,$.jsx)(jo,{width:24,height:24,className:`size-6`})}):null,y=o.map((e,t)=>(0,$.jsx)(`span`,{"aria-hidden":`true`,className:Y(`inline-flex shrink-0 items-baseline`,!s&&t>0&&`text-primary`),children:e===`Yuri`?(0,$.jsx)(El,{width:`2.44814cap`}):e},t)),b;t[11]!==g||t[12]!==_||t[13]!==v||t[14]!==y||t[15]!==m?(b=(0,$.jsxs)(`span`,{role:`img`,"aria-label":m,className:g,style:_,children:[v,y]}),t[11]=g,t[12]=_,t[13]=v,t[14]=y,t[15]=m,t[16]=b):b=t[16];let x;t[17]!==u||t[18]!==b||t[19]!==d||t[20]!==f||t[21]!==p?(x=(0,$.jsx)(u,{variant:`ghost`,size:`xs`,className:`app-region-no-drag min-w-0 max-w-full justify-start`,"aria-label":d,title:f,onClick:p,children:b}),t[17]=u,t[18]=b,t[19]=d,t[20]=f,t[21]=p,t[22]=x):x=t[22];let S;return t[23]!==l||t[24]!==x?(S=(0,$.jsx)(`div`,{className:l,children:x}),t[23]=l,t[24]=x,t[25]=S):S=t[25],S};function xf(e){return e.openSettingsAtItem}function Sf(e){return e.sidebarBrandName}function Cf(e){return e!==`Yuri`}var wf=`app-region-no-drag inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/75 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary hover:bg-interactive-hover hover:text-foreground transition-colors`,Tf=()=>{let e=(0,ju.c)(50),{t}=Nr(),n=un(Ef),r=sn(Df),i=n?.hostId&&r?.projectId===n.id&&r.location.hostId===n.hostId&&(!n.hubId||r.location.hubId===n.hubId)?r:null,a;e[0]!==n||e[1]!==i?(a=i?ne(i.location):n?.hostId&&n.hubId?ne({hubId:n.hubId,hostId:n.hostId,directory:n.path}):n?.path,e[0]=n,e[1]=i,e[2]=a):a=e[2];let o=a,s=q(Of),c=q(kf),l=q(Af),u=q(jf),d=_u(Mf),f=Q.useRef(null),p=Sa(Ta(`toggle_sidebar`,u)),{usesFramelessChrome:m,side:h}=oc(),g;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=C(),e[3]=g):g=e[3];let _=g,v=!_||!s||!d,b;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(b=!ae()&&!_&&y(),e[4]=b):b=e[4];let x=b,S=Pf,w,T;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>{if(typeof document>`u`)return;let e=f.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect().width;document.documentElement.style.setProperty(`--yuri-titlebar-controls-width`,`${Math.round(t)}px`)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},T=[],e[5]=w,e[6]=T):(w=e[5],T=e[6]),Q.useEffect(w,T);let E=o||void 0,D=x&&s?`${c||260}px`:void 0,O;e[7]===D?O=e[8]:(O={height:`var(--yuri-header-height, 3rem)`,paddingLeft:`var(--yuri-titlebar-left-inset, 0.75rem)`,width:D},e[7]=D,e[8]=O);let k=x&&s&&`w-full justify-between`,A;e[9]===k?A=e[10]:(A=Y(`flex items-center gap-2`,k),e[9]=k,e[10]=A);let j;e[11]===s?j=e[12]:(j=x&&s?(0,$.jsx)(bf,{className:`flex min-w-0 items-center p-0 pl-1.5`}):null,e[11]=s,e[12]=j);let M;e[13]!==m||e[14]!==h?(M=m&&h===`left`?(0,$.jsx)(ic,{visible:!0,position:`left`}):null,e[13]=m,e[14]=h,e[15]=M):M=e[15];let N;e[16]!==t||e[17]!==m?(N=m?(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:S,"aria-label":t(`header.actions.openAppMenuAria`),className:Y(wf,`shrink-0`),children:(0,$.jsx)(Z,{name:`menu-2`,className:`h-[18px] w-[18px]`})})}),(0,$.jsx)(ei,{children:(0,$.jsx)(`p`,{children:t(`header.actions.openAppMenu`)})})]}):null,e[16]=t,e[17]=m,e[18]=N):N=e[18];let P;e[19]===v?P=e[20]:(P=v?(0,$.jsx)(ol,{}):null,e[19]=v,e[20]=P);let F=ni,I;e[21]===t?I=e[22]:(I=t(`header.actions.openSessionsAria`),e[21]=t,e[22]=I);let L,R;e[23]===Symbol.for(`react.memo_cache_sentinel`)?(L=Y(wf,`group shrink-0`),R=(0,$.jsx)(Z,{name:`layout-left-rounded`,className:`size-4 text-foreground/55 transition-colors group-hover:text-foreground group-focus-visible:text-foreground`}),e[23]=L,e[24]=R):(L=e[23],R=e[24]);let z;e[25]!==I||e[26]!==l?(z=(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:l,"aria-label":I,className:L,children:R})}),e[25]=I,e[26]=l,e[27]=z):z=e[27];let ee=ei,B=t(`header.actions.openSessionsWithShortcut`,{shortcut:p}),V;e[28]===B?V=e[29]:(V=(0,$.jsx)(`p`,{children:B}),e[28]=B,e[29]=V);let te;e[30]!==ee||e[31]!==V?(te=(0,$.jsx)(ee,{children:V}),e[30]=ee,e[31]=V,e[32]=te):te=e[32];let re;e[33]!==F||e[34]!==z||e[35]!==te?(re=(0,$.jsxs)(F,{children:[z,te]}),e[33]=F,e[34]=z,e[35]=te,e[36]=re):re=e[36];let ie;e[37]!==P||e[38]!==re?(ie=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[P,re]}),e[37]=P,e[38]=re,e[39]=ie):ie=e[39];let H;e[40]!==A||e[41]!==j||e[42]!==M||e[43]!==N||e[44]!==ie?(H=(0,$.jsxs)(`div`,{ref:f,className:A,children:[j,M,N,ie]}),e[40]=A,e[41]=j,e[42]=M,e[43]=N,e[44]=ie,e[45]=H):H=e[45];let U;return e[46]!==H||e[47]!==E||e[48]!==O?(U=(0,$.jsx)(`div`,{"data-titlebar-location":E,className:`app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2`,style:O,children:H}),e[46]=H,e[47]=E,e[48]=O,e[49]=U):U=e[49],U};function Ef(e){return e.projects.find(t=>t.id===e.activeProjectId)}function Df(e){return e.remoteSession}function Of(e){return e.isSidebarOpen}function kf(e){return e.sidebarWidth}function Af(e){return e.toggleSidebar}function jf(e){return e.shortcutOverrides}function Mf(e){return e.sidebarBrandName.trim().length>0}function Nf(e){console.warn(`[titlebar] failed to open app menu`,e)}function Pf(e){let t=e.currentTarget.getBoundingClientRect();ee(`desktop_show_app_menu`,{x:t.left,y:t.bottom}).catch(Nf)}var Ff=(e,t)=>{let n=Nt(t,e);return!n||n===`.`||n===t?0:n.split(`/`).filter(Boolean).length},If=(e,t,n=10)=>{let r=Mt(e);if(!r||n<1)return[];let i=new Set,a=[];for(let e of Object.values(t))if(e)for(let t of e){if(t.type!==`directory`)continue;let e=Mt(t.path);if(!e||i.has(e))continue;let o=Ff(r,e);o<1||o>n||(i.add(e),a.push(e))}return a},Lf=e=>e.some(e=>!!Mt(e)),Rf=(e,t)=>{let n=new Set(t.map(e=>Mt(e)).filter(Boolean));return e.filter(e=>!n.has(e))},zf=(e,t,n)=>t.length===0?e.length===0:Rf(e,t).length>0?!1:t.every(e=>n.has(Mt(e))),Bf=ba(()=>Lt(()=>import(`./ToolOutputDialog-AQRtLxWE.js`).then(e=>e.n),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,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,80,81,82,83]))),Vf=e=>{let t=Wf(e);if(!t)return``;if(t===`/`||/^[A-Za-z]:\/$/.test(t))return t;let n=t.lastIndexOf(`/`);if(n<0)return t;if(n===0)return`/`;let r=t.slice(0,n);return/^[A-Za-z]:$/.test(r)?`${r}/`:r},Hf=e=>{let t=(0,ju.c)(8),{label:n,iconDataUrl:r}=e,[i,a]=Q.useState(!1),o;t[0]===n?o=t[1]:(o=n.trim().slice(0,1).toUpperCase()||`?`,t[0]=n,t[1]=o);let s=o;if(r&&!i){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>a(!0),t[2]=e):e=t[2];let n;return t[3]===r?n=t[4]:(n=(0,$.jsx)(`img`,{src:r,alt:``,className:`size-4 rounded-sm`,onError:e}),t[3]=r,t[4]=n),n}let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=Y(`size-4 rounded-sm flex items-center justify-center`,`bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground`),t[5]=c):c=t[5];let l;return t[6]===s?l=t[7]:(l=(0,$.jsx)(`span`,{className:c,children:s}),t[6]=s,t[7]=l),l},Uf=e=>e.slice().sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1),Wf=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+/g,`/`);n&&!r.startsWith(`//`)&&(r=`/${r}`);let i=r===`/`,a=/^[A-Za-z]:\/$/.test(r);return!i&&!a&&(r=r.replace(/\/+$/,``)),r},Gf=e=>e.startsWith(`/`)||e.startsWith(`//`)||/^[A-Za-z]:\//.test(e),Kf=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,qf=(e,t)=>{let n=Wf(t),r=Wf(e);if(!n||!r)return!1;let i=Kf(n),a=Kf(r);return a===i||a.startsWith(`${i}/`)},Jf=(e,t)=>{let n=Wf(t),r=Wf(e);if(!qf(r,n))return[];let i=r.slice(n.length).replace(/^\//,``).split(`/`),a=[],o=n;for(let e=0;e<i.length-1;e++)o=o?`${o}/${i[e]}`:i[e],a.push(o);return a},Yf=(e,t)=>{if(!t)return``;let n=Wf(t);if(!e||!qf(n,e))return n;let r=n.slice(e.length);return r.startsWith(`/`)?r.slice(1):r},Xf=new Set([`node_modules`]),Zf=e=>{let t=(0,ju.c)(3),{status:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={open:`var(--status-info)`,modified:`var(--status-warning)`,"git-modified":`var(--status-warning)`,"git-added":`var(--status-success)`,"git-deleted":`var(--status-error)`},t[0]=r):r=t[0];let i=r[n],a;return t[1]===i?a=t[2]:(a=(0,$.jsx)(`span`,{className:`size-2 rounded-full`,style:{backgroundColor:i}}),t[1]=i,t[2]=a),a},Qf=e=>{let t=(0,ju.c)(11),{name:n}=e,r=Q.useRef(null),i=Q.useRef(null),[a,o]=Q.useState(!1),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=r.current,t=i.current;if(!e||!t)return;let n=()=>{o(t.scrollWidth>e.clientWidth+1)};n();let a=new ResizeObserver(n);return a.observe(e),a.observe(t),()=>{a.disconnect()}},t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=[n],t[1]=n,t[2]=c),Q.useLayoutEffect(s,c);let l;t[3]===n?l=t[4]:(l=(0,$.jsx)(`span`,{ref:i,"aria-hidden":`true`,className:`invisible absolute whitespace-nowrap`,children:n}),t[3]=n,t[4]=l);let u;t[5]!==n||t[6]!==a?(u=a?(0,$.jsxs)(`span`,{className:`open-file-name-marquee-track`,children:[(0,$.jsx)(`span`,{className:`open-file-name-marquee-item`,children:n}),(0,$.jsx)(`span`,{className:`open-file-name-marquee-item`,"aria-hidden":`true`,children:n})]}):(0,$.jsx)(`span`,{className:`block min-w-0 truncate`,children:n}),t[5]=n,t[6]=a,t[7]=u):u=t[7];let d;return t[8]!==l||t[9]!==u?(d=(0,$.jsxs)(`span`,{ref:r,className:`relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap`,children:[l,u]}),t[8]=l,t[9]=u,t[10]=d):d=t[10],d},$f=e=>Xf.has(e),ep=e=>{let t=Wf(e);return t===`node_modules`||t.endsWith(`/node_modules`)||t.includes(`/node_modules/`)},tp=e=>{let t=(e instanceof Error?e.message:String(e??``)).toLowerCase();return t.includes(`is a directory`)||t.includes(`eisdir`)},np=e=>{let t=(e instanceof Error?e.message:String(e??``)).toLowerCase();return t.includes(`file not found`)||t.includes(`enoent`)||t.includes(`no such file`)||t.includes(`does not exist`)},rp=2e5,ip=`yuri:files:auto-save-enabled`,ap=e=>{let t=0,n=0;for(let r=0;r<e.length;r+=1)e.charCodeAt(r)===10&&(r>0&&e.charCodeAt(r-1)===13?t+=1:n+=1);return t>n?`\r
|
|
4
4
|
`:`
|
|
5
5
|
`},op=e=>e.replace(/\r\n/g,`
|
|
6
6
|
`).replace(/\r/g,`
|
|
@@ -166,4 +166,4 @@ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,c as n,i as r,p
|
|
|
166
166
|
`+e}return r}function Fb(e,t){let n=new Blob([e],{type:`text/markdown;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=t,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}async function Ib(e,t){let n=await I(t,e);if(n)return n;if(!ae())return null;try{let n=await U()?.vscode?.saveMarkdown?.({fileName:t,content:e});if(!n||n.saved!==!0)return null;let r=typeof n.path==`string`?n.path.trim():``;return r.length>0?r:null}catch{return null}}async function Lb(e){let t=U()?.files;if(t?.revealPath)try{return!!(await t.revealPath(e))?.success}catch{return!1}return await _(e)?!0:S(e)}function Rb(){return Vn()}function zb(e){return`${(e?.trim()||`session`).normalize(`NFKC`).toLowerCase().replace(/[^\p{L}\p{N}]+/gu,`-`).replace(/^-+|-+$/g,``).slice(0,60)||`session`}-${new Date().toISOString().split(`T`)[0]}.md`}function Bb(e){let t=(0,ju.c)(35),{session:n,title:r,projectLabel:i,project:a,branch:o,directory:s,time:c}=e,{t:l}=Nr(),d;t[0]===s?d=t[1]:(d=e=>s?e.directories.get(s)?.status?.current:void 0,t[0]=s,t[1]=d);let f=Qi(d),m;t[2]!==s||t[3]!==n.model?(m=e=>{let t=n.model;return t?e.directoryScoped[On(s)]?.providers.find(e=>e.id===t.providerID)?.models.find(e=>e.id===t.id)?.name??t.id:null},t[2]=s,t[3]=n.model,t[4]=m):m=t[4];let g=jn(m),_;if(t[5]!==l){let e=Tt.getQueryData([`desktop-host-inventory`,u()]),n=p(),r=h(),i=n.startsWith(`host:`)?n.slice(5):null,a=e?.hosts.find(e=>i?e.id===i:!!(r&&W(r,oe(e))));_=a?le(a.label):x()?l(`desktopHostSwitcher.instance.local`):null,t[5]=l,t[6]=_}else _=t[6];let v=_,y=!!(o&&f&&f!==`HEAD`&&f!==o),b;t[7]===r?b=t[8]:(b=(0,$.jsx)(`div`,{className:`min-w-0 flex-1 break-words typography-ui-label font-medium text-foreground`,children:r}),t[7]=r,t[8]=b);let S;t[9]===c?S=t[10]:(S=(0,$.jsx)(`span`,{className:`shrink-0 typography-meta text-muted-foreground`,children:c}),t[9]=c,t[10]=S);let C;t[11]!==b||t[12]!==S?(C=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[b,S]}),t[11]=b,t[12]=S,t[13]=C):C=t[13];let w;t[14]!==a||t[15]!==i?(w=i?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 typography-meta text-muted-foreground`,children:[(0,$.jsx)(_l,{project:a}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:i})]}):null,t[14]=a,t[15]=i,t[16]=w):w=t[16];let T;t[17]===v?T=t[18]:(T=v?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 typography-meta text-muted-foreground`,children:[(0,$.jsx)(Z,{name:`computer`,className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:v})]}):null,t[17]=v,t[18]=T);let E;t[19]===o?E=t[20]:(E=o?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 typography-meta text-muted-foreground`,children:[(0,$.jsx)(Z,{name:`git-branch`,className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:o})]}):null,t[19]=o,t[20]=E);let D;t[21]!==f||t[22]!==y||t[23]!==l?(D=y?(0,$.jsxs)(`div`,{className:`flex items-start gap-2 typography-meta text-status-warning`,children:[(0,$.jsx)(Z,{name:`error-warning`,className:`mt-0.5 size-3.5 shrink-0`}),(0,$.jsx)(`span`,{children:l(`sessions.sidebar.session.hover.differentBranch`,{branch:f??``})})]}):null,t[21]=f,t[22]=y,t[23]=l,t[24]=D):D=t[24];let O;t[25]===g?O=t[26]:(O=g?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 typography-meta text-muted-foreground`,children:[(0,$.jsx)(Z,{name:`ai-agent`,className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:g})]}):null,t[25]=g,t[26]=O);let k;return t[27]!==n.id||t[28]!==D||t[29]!==O||t[30]!==C||t[31]!==w||t[32]!==T||t[33]!==E?(k=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 text-left`,"data-session-hover-details":n.id,children:[C,w,T,E,D,O]}),t[27]=n.id,t[28]=D,t[29]=O,t[30]=C,t[31]=w,t[32]=T,t[33]=E,t[34]=k):k=t[34],k}var Vb=(e,t)=>{if(!t)return Array.from(e);let n=[],r=new Set;for(let i of e){r.has(i)||(r.add(i),n.push(i));let e=t.get(i);if(e)for(let t of e)r.has(t)||(r.add(t),n.push(t))}return n},Hb=ue()((e,t)=>({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null,enable:()=>{t().enabled||e({enabled:!0})},disable:()=>{e({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null})},toggleMode:()=>{t().enabled?e({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null}):e({enabled:!0})},toggleSelected:(n,r,i)=>{let a=t(),o=new Set(a.selectedIds),s=a.scopeKey,c=a.anchorId;r!==null&&a.scopeKey!==null&&r!==a.scopeKey?(o.clear(),s=r,c=null):s===null&&r!==null&&(s=r);let l=i&&i.length>0?[n,...i]:[n];if(o.has(n)){for(let e of l)o.delete(e);c===n&&(c=null)}else{for(let e of l)o.add(e);c=n}o.size===0?e({selectedIds:o,scopeKey:null,anchorId:null}):e({selectedIds:o,scopeKey:s,anchorId:c})},setRange:(n,r,i,a,o)=>{let s=t();if(i.length===0)return;let c=n&&i.includes(n)?n:i[0],l=i.indexOf(c),u=i.indexOf(r);if(l<0||u<0)return;let[d,f]=l<=u?[l,u]:[u,l],p=Vb(i.slice(d,f+1),o),m=a!==null&&s.scopeKey!==null&&a!==s.scopeKey?new Set:new Set(s.selectedIds);for(let e of p)m.add(e);e({selectedIds:m,scopeKey:a??s.scopeKey,anchorId:c})},replaceAll:(t,n)=>{if(t.length===0){e({selectedIds:new Set,scopeKey:null,anchorId:null});return}e({selectedIds:new Set(t),scopeKey:n,anchorId:t[0]??null})},clear:()=>{e({selectedIds:new Set,scopeKey:null,anchorId:null})},removeMany:n=>{let r=t();if(r.selectedIds.size===0||n.length===0)return;let i=new Set(r.selectedIds);for(let e of n)i.delete(e);i.size!==r.selectedIds.size&&(i.size===0?e({selectedIds:i,scopeKey:null,anchorId:null}):e({selectedIds:i}))}})),Ub=!1,Wb=new Set,Gb=!1;function Kb(){for(let e of Wb)e()}function qb(e){Ub!==e&&(Ub=e,Kb())}function Jb(e){e.key===`Shift`&&qb(!0)}function Yb(e){e.key===`Shift`&&qb(!1)}function Xb(){qb(!1)}function Zb(){Gb||typeof window>`u`||(Gb=!0,window.addEventListener(`keydown`,Jb),window.addEventListener(`keyup`,Yb),window.addEventListener(`blur`,Xb))}function Qb(e){return Zb(),Wb.add(e),()=>{Wb.delete(e)}}function $b(){return Ub}function ex(){return!1}function tx(){return(0,Q.useSyncExternalStore)(Qb,$b,ex)}var nx=!1,rx=!1,ix=new Set;function ax(){ix.forEach(e=>e())}function ox(e){nx!==e&&(nx=e,ax())}function sx(e){return gr()?e.key===`Meta`:e.key===`Control`}var cx=(({setVisible:e,schedule:t=(e,t)=>setTimeout(e,t),cancel:n=e=>clearTimeout(e)})=>{let r=!1,i=null,a=()=>{i!==null&&(n(i),i=null)};return{press(){r||(r=!0,a(),i=t(()=>{i=null,r&&e(!0)},500))},release(){r=!1,a(),e(!1)}}})({setVisible:ox});function lx(e){sx(e)&&cx.press()}function ux(){cx.release()}function dx(e){sx(e)&&ux()}function fx(){document.visibilityState!==`visible`&&ux()}function px(){rx||typeof window>`u`||(rx=!0,window.addEventListener(`keydown`,lx),window.addEventListener(`keyup`,dx),window.addEventListener(`blur`,ux),document.addEventListener(`visibilitychange`,fx))}function mx(e){return px(),ix.add(e),()=>ix.delete(e)}function hx(){return nx}function gx(){return!1}function _x(){return(0,Q.useSyncExternalStore)(mx,hx,gx)}var vx=(e,t,n)=>{let r=e.session.title?.trim()||e.session.id;return`\n\n--- RESULT ${n+1}: ${r} ---\n${t.trim()}\n--- END RESULT ${n+1} ---`},yx=(e,t)=>Kn.getState().getWorktreeMetadata(e)?.projectDirectory??t,bx=e=>e.type===`assistant`?Zo(e.content??[]).trim():``,xx=async e=>{let t=e.directory??void 0,n=tt(e.session.id,t);if(n.length===0&&e.directory){let t=await nt.withDirectory(e.directory,()=>nt.getSdkClient().message.list({sessionID:e.session.id,limit:50})),n=Array.isArray(t.data)?t.data:[];for(let e=n.length-1;e>=0;--e){let t=bx(n[e]);if(t)return t}return``}for(let e=n.length-1;e>=0;--e){let r=n[e];if(r.role===`assistant`)return Zo(et(r.id,t)).trim()}return``};function Sx({session:e,open:t,onOpenChange:n}){let{t:r}=Nr(),i=vn(),a=pn(e=>e.activeSessions),o=pn(e=>e.archivedSessions),s=jn(e=>e.providers),c=jn(e=>e.currentProviderId),l=jn(e=>e.currentModelId),u=jn(e=>e.currentAgentName),[d,f]=Q.useState(c??``),[p,m]=Q.useState(l??``),[h,g]=Q.useState(()=>c&&l?[{providerID:c,modelID:l,instanceId:eu()}]:[]),[_,v]=Q.useState(``),[y,b]=Q.useState(u??``),[x,S]=Q.useState([]),[C,w]=Q.useState(!1),T=Q.useMemo(()=>nu(e.title),[e.title]),E=Q.useMemo(()=>{let t=new Map;for(let e of i)t.set(e.id,e);for(let e of a)t.set(e.id,e);for(let e of o)t.set(e.id,e);return e.id&&t.set(e.id,e),Array.from(t.values())},[a,o,i,e]);Q.useEffect(()=>{if(!t||!T)return;let n=Kn.getState().getDirectoryForSession(e.id),r=yx(e.id,n),i=E.map(e=>{let t=nu(e.title);if(!t||t.groupSlug!==T.groupSlug||t.fusion||(t.runGroup??null)!==(T.runGroup??null))return null;let n=Kn.getState().getDirectoryForSession(e.id)??gn(e),i=yx(e.id,n);return r&&i&&r!==i?null:{session:e,directory:n,projectDirectory:i}}).filter(e=>e!==null).sort((e,t)=>(e.session.time?.created??0)-(t.session.time?.created??0));S(i)},[E,t,T,e.id]);let D=s.find(e=>e.id===d)?.models.find(e=>e.id===p),O=D?.variants?Object.keys(D.variants):[],k=!!(T&&d&&p&&x.length>0&&!C),A=Q.useCallback(e=>{g([e]),f(e.providerID),m(e.modelID),v(``)},[]),j=h[0]?.displayName||h[0]?.modelID||r(`multirun.fusion.model.placeholder`);return(0,$.jsx)(Qr,{open:t,onOpenChange:n,children:(0,$.jsxs)(Yr,{className:`max-w-xl overflow-visible`,children:[(0,$.jsxs)(qr,{children:[(0,$.jsx)(Xr,{children:r(`multirun.fusion.title`)}),(0,$.jsx)(Zr,{children:r(`multirun.fusion.description`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`max-w-full`,children:(0,$.jsx)(ru,{selectedModels:h,onAdd:A,onUpdate:(e,t)=>A(t),onRemove:()=>{g([]),f(``),m(``),v(``)},maxModels:1,addButtonLabel:j,showChips:!1,addButtonClassName:`h-8 w-fit max-w-[min(28rem,calc(100vw-8rem))] justify-start rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] px-3 py-1.5`,dropdownSide:`bottom`,dropdownClassName:`w-[min(28rem,calc(100vw-8rem))]`,triggerIcon:d||p?(0,$.jsx)(Vo,{modelId:p,providerId:d,className:`h-3.5 w-3.5 mr-1`}):void 0})}),O.length>0?(0,$.jsxs)(Fs,{value:_||`__default__`,onValueChange:e=>v(e===`__default__`?``:e),children:[(0,$.jsxs)(Ps,{size:`lg`,className:`h-8 w-fit rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] !border-border/80 !bg-[var(--surface-subtle)] hover:!bg-[var(--interactive-hover)]/70 typography-meta font-medium text-foreground px-3 py-1.5`,children:[(0,$.jsx)(Z,{name:`brain-ai-3`,className:`h-3.5 w-3.5 text-muted-foreground`}),(0,$.jsx)(js,{children:e=>e===`__default__`?r(`multirun.modelMultiSelect.variant.default`):e})]}),(0,$.jsxs)(Ns,{fitContent:!0,portalToBody:!0,children:[(0,$.jsx)(Ms,{value:`__default__`,children:r(`multirun.modelMultiSelect.variant.default`)}),O.map(e=>(0,$.jsx)(Ms,{value:e,children:e},e))]})]}):null,(0,$.jsx)(tu,{value:y,onChange:b,portalToBody:!0,className:`h-8 rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] px-3 py-1.5`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`typography-meta font-medium text-foreground`,children:r(`multirun.fusion.sources.label`,{count:x.length})}),(0,$.jsx)(`div`,{className:`max-h-56 space-y-1 overflow-auto rounded-lg border border-[var(--interactive-border)] p-1`,children:x.map(e=>{let t=nu(e.session.title);return(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md px-2 py-1.5 typography-meta`,children:[(0,$.jsx)(Vo,{modelId:t?.modelID,providerId:t?.providerID,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.session.title||e.session.id}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>S(t=>t.filter(t=>t.session.id!==e.session.id)),className:`text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(Z,{name:`close`,className:`h-4 w-4`})})]},e.session.id)})})]}),(0,$.jsxs)(Jr,{children:[(0,$.jsx)(J,{variant:`ghost`,onClick:()=>n(!1),children:r(`multirun.fusion.actions.cancel`)}),(0,$.jsx)(J,{onClick:async()=>{if(!(!T||!d||!p)){w(!0);try{let e=await Promise.all(x.map(e=>xx(e))),t=x.map((t,n)=>({source:t,text:e[n]??``})).filter(e=>e.text.trim().length>0);if(t.length===0){X.error(r(`multirun.fusion.toast.noOutputs`));return}let i=x[0]?.projectDirectory??x[0]?.directory??null,a=$l(T.groupSlug,d,p,T.runGroup),[o,s]=await Promise.all([qi(`session.fusion.visible`),qi(`session.fusion.instructions`)]),c=await Kn.getState().createSession(a,i,null);if(!c)throw Error(`Failed to create fusion session`);Kn.getState().setCurrentSession(c.id,i),n(!1),await nt.sendMessage({id:c.id,providerID:d,modelID:p,variant:_||void 0,agent:y||void 0,text:o,additionalParts:[{text:s,synthetic:!0},...t.map((e,t)=>({text:vx(e.source,e.text,t),synthetic:!0})),{text:`
|
|
167
167
|
|
|
168
168
|
--- FUSION INPUTS END ---
|
|
169
|
-
Now write the final fused answer.`,synthetic:!0}],directory:i??nt.getDirectory()})}catch(e){console.error(`[MultiRunFusion] Failed to start fusion`,e),X.error(r(`multirun.fusion.toast.failed`))}finally{w(!1)}}},disabled:!k,children:r(C?`multirun.fusion.actions.starting`:`multirun.fusion.actions.start`)})]})]})})}function Cx(e){let t=(0,ju.c)(13),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=[`yuri-icon`,n].filter(Boolean),t[3]=n,t[4]=i);let a=i.join(` `),o,s,c,l,u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`path`,{d:`M12 4.5v6.25M12 10.75v3.5M12 10.75H7.25A3.25 3.25 0 0 0 4 14v1.25M12 10.75h4.75A3.25 3.25 0 0 1 20 14v1.25`}),s=(0,$.jsx)(`path`,{d:`M9.25 7.25 12 4.5l2.75 2.75`}),c=(0,$.jsx)(`circle`,{cx:`4`,cy:`17.25`,r:`1.55`}),l=(0,$.jsx)(`circle`,{cx:`12`,cy:`17.25`,r:`1.55`}),u=(0,$.jsx)(`circle`,{cx:`20`,cy:`17.25`,r:`1.55`}),t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=u):(o=t[5],s=t[6],c=t[7],l=t[8],u=t[9]);let d;return t[10]!==r||t[11]!==a?(d=(0,$.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:wr,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:a,...r,children:[o,s,c,l,u]}),t[10]=r,t[11]=a,t[12]=d):d=t[12],d}var wx=e(Se(),1),Tx=null,Ex=!1,Dx=(e,t=uo.getState().focus)=>e===null?null:typeof e==`string`?t?.sessionId===e?t:$a(e):e,Ox=e=>{typeof window>`u`||(e.commitFrame!==null&&window.cancelAnimationFrame(e.commitFrame),e.paintFrame!==null&&window.cancelAnimationFrame(e.paintFrame),e.fallbackTimer!==null&&window.clearTimeout(e.fallbackTimer))},kx=()=>{Tx&&=(Ox(Tx),null)},Ax=(e,t)=>{kx(),cr(!0);let n=Dx(e);if(!n)return;Ex=!0;let r;try{r=zt(n.sessionId)}finally{Ex=!1}Tx={commit:t,commitFrame:null,fallbackTimer:null,focus:n,intent:r,paintFrame:null,scheduled:!1},(0,wx.flushSync)(()=>{uo.getState().setFocus(n)}),typeof window<`u`&&(Tx.fallbackTimer=window.setTimeout(()=>{jx(n)},150))},jx=e=>{let t=Tx,n=Dx(e);if(!t||!qa(t.focus,n)||t.scheduled)return;t.scheduled=!0,typeof window<`u`&&t.fallbackTimer!==null&&(window.clearTimeout(t.fallbackTimer),t.fallbackTimer=null);let r=()=>{Tx===t&&Rt()===t.intent&&(Tx=null,Yn(),t.commit())};if(typeof window>`u`){r();return}t.commitFrame=window.requestAnimationFrame(()=>{Tx===t&&Rt()===t.intent&&(t.paintFrame=window.requestAnimationFrame(r))})},Mx=e=>{if(Tx)return;let t=uo.getState();t.setFocus(Dx(e,t.focus))};Bt(e=>{if(Ex)return;let t=Tx;if(t?.intent===e)return;t&&kx();let n=uo.getState();n.setFocus(Dx(e.sessionId,n.focus))});var Nx=e=>{let t=[],n=e=>{e.children.forEach(e=>{t.push(e.session.id),n(e)})};return n(e),t},Px=Q.memo(function(e){let t=(0,ju.c)(21),{pinned:n,pinLabel:r,buttonSizeClass:i,iconSizeClass:a,onPointerDown:o,onMouseDown:s,onPin:c}=e,l=n?`text-foreground`:`text-muted-foreground`,u;t[0]!==i||t[1]!==l?(u=Y(`inline-flex items-center justify-center rounded-md hover:text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,l,i),t[0]=i,t[1]=l,t[2]=u):u=t[2];let d=n?`pushpin-2-fill`:`pushpin-2`,f=!n&&`rotate-45`,p;t[3]!==a||t[4]!==f?(p=Y(a,f),t[3]=a,t[4]=f,t[5]=p):p=t[5];let m;t[6]!==d||t[7]!==p?(m=(0,$.jsx)(Z,{name:d,className:p}),t[6]=d,t[7]=p,t[8]=m):m=t[8];let h;t[9]!==s||t[10]!==c||t[11]!==o||t[12]!==r||t[13]!==u||t[14]!==m?(h=(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:u,"aria-label":r,onPointerDown:o,onMouseDown:s,onClick:c,onKeyDown:qx,children:m})}),t[9]=s,t[10]=c,t[11]=o,t[12]=r,t[13]=u,t[14]=m,t[15]=h):h=t[15];let g;t[16]===r?g=t[17]:(g=(0,$.jsx)(ei,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:r}),t[16]=r,t[17]=g);let _;return t[18]!==h||t[19]!==g?(_=(0,$.jsxs)(ni,{children:[h,g]}),t[18]=h,t[19]=g,t[20]=_):_=t[20],_}),Fx=Q.memo(function(e){let t=(0,ju.c)(24),{archiveLabel:n,deleteLabel:r,deleteOnly:i,restore:a,buttonSizeClass:o,iconSizeClass:s,revealClassName:c,onPointerDown:l,onMouseDown:u,onArchive:d,onDelete:f}=e,p=i!==void 0&&i,m=a!==void 0&&a,h=tx(),g=p||h,_=g?r:n,v;t[0]!==p||t[1]!==d||t[2]!==f||t[3]!==h?(v=e=>{if(p||h||e.shiftKey){f(e);return}d(e)},t[0]=p,t[1]=d,t[2]=f,t[3]=h,t[4]=v):v=t[4];let y=v,b=g?`text-destructive hover:text-destructive hover:bg-[color-mix(in_srgb,var(--status-error)_12%,transparent)]`:`text-muted-foreground hover:text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)]`,x;t[5]!==o||t[6]!==c||t[7]!==b?(x=Y(`inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,b,o,c),t[5]=o,t[6]=c,t[7]=b,t[8]=x):x=t[8];let S=g?`delete-bin`:m?`undo-2`:`inbox-archive`,C;t[9]!==s||t[10]!==S?(C=(0,$.jsx)(Z,{name:S,className:s}),t[9]=s,t[10]=S,t[11]=C):C=t[11];let w;t[12]!==y||t[13]!==_||t[14]!==u||t[15]!==l||t[16]!==x||t[17]!==C?(w=(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:x,"aria-label":_,onPointerDown:l,onMouseDown:u,onClick:y,onKeyDown:Jx,children:C})}),t[12]=y,t[13]=_,t[14]=u,t[15]=l,t[16]=x,t[17]=C,t[18]=w):w=t[18];let T;t[19]===_?T=t[20]:(T=(0,$.jsx)(ei,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:_}),t[19]=_,t[20]=T);let E;return t[21]!==w||t[22]!==T?(E=(0,$.jsxs)(ni,{children:[w,T]}),t[21]=w,t[22]=T,t[23]=E):E=t[23],E}),Ix=Q.memo(function(e){let t=(0,ju.c)(3),{number:n}=e;if(!_x())return null;let r=gr()?`⌘${n}`:`Ctrl+${n}`,i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(Ri,{"data-sidebar-shortcut-number":n,variant:`hint`,"aria-hidden":`true`,children:r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i});function Lx(e){let{t}=Nr(),{node:r,depth:i=0,groupDirectory:a,projectId:o,archivedBucket:s=!1,pinnedSessionIds:c,expandedParents:l,hasSessionSearchQuery:u,normalizedSessionSearchQuery:d,editingId:f,setEditingId:p,editTitle:m,setEditTitle:g,handleSaveEdit:_,handleCancelEdit:v,toggleParent:y,handleSessionSelect:b,togglePinnedSession:x,handleShareSession:S,copiedSessionId:C,handleCopyShareUrl:w,handleUnshareSession:T,setOpenSidebarMenuKey:E,renamingFolderId:D,getFoldersForScope:O,getSessionFolderId:k,removeSessionFromFolder:A,addSessionToFolder:j,createFolderAndStartRename:M,handleDeleteSession:N,mobileVariant:P,alwaysShowActions:F,renderSessionNode:I,secondaryMeta:R,renderContext:z=`project`,subtreeContainsActive:B,subtreeContainsEditing:V,menuOpenSessionId:te,childRenderExtrasFor:ne,liveSessionById:re,shortcutNumber:ie=null,settledSessionIds:H,setSessionSettled:U}=e,oe=!!R?.projectLabel,W=!!R?.branchLabel,se=Tn(e=>e.displayMode),ce=Q.useMemo(()=>ae(),[]),le=se===`minimal`||ce,ue=Q.useMemo(()=>L(),[]),de=Q.useContext(jt),fe=ce?`group-hover:opacity-100 group-hover:pointer-events-auto`:`group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto`,he=ce,ye=z===`pinned`&&c.has(r.session.id),xe=!ye&&!s&&!P&&!R?.slim,Se=`h-5 w-5`,Te=`h-3.5 w-3.5`,Ee=(xe||ye?1:0)+ +!!he+1,De=Ee>=3?`group-hover:pr-18 group-focus-within:pr-18`:Ee>=2?`group-hover:pr-12 group-focus-within:pr-12`:`group-hover:pr-7 group-focus-within:pr-7`,Oe=F?ce?De:Ee>=2?`pr-12`:`pr-8`:De,ke=Q.useRef(!1),je=Q.useRef(!1),[Me,Ne]=Q.useState(!1),Pe=Q.useRef(f);Pe.current=f;let Fe=Q.useRef(null),[G,Ie]=Q.useState(m),[Le,Re]=Q.useState(f===r.session.id),ze=Q.useRef(null),Be=Q.useRef(null),Ve=Q.useRef(null),He=r.session,Ue=re.get(He.id)??He,We=!!Ue.metadata?.yuri?.assistant,Ge=ft(He.directory??null)??ft(a??null),Ke=Sn(Ge??void 0,{bootstrap:!1}),qe=ps(),Je=Hb(e=>e.enabled),Ze=Hb(Q.useMemo(()=>e=>e.selectedIds.has(He.id),[He.id])),Qe=Hb(e=>e.toggleSelected),$e=Hb(e=>e.setRange),[et,tt]=Q.useState(!1),[nt,it]=Q.useState(!0),[ot,st]=Q.useState(!1),[ct,lt]=Q.useState(!1),ut=`${z}:${s?`archived`:`active`}:${He.id}`,dt=br(Q.useMemo(()=>e=>!!e.sessionMemoryState.get(yn(He.id))?.isZombie,[He.id])),pt=mr(He.id),mt=nr(He.id,Ge??void 0,{bootstrap:!1}),ht=Xn(He.id,Ge??void 0,{bootstrap:!1}),gt=Q.useMemo(()=>({scope:z,sessionId:He.id,projectId:o??null}),[o,z,He.id]),_t=Q.useMemo(()=>Qa(gt)??``,[gt]),vt=Q.useRef(null),yt=uo(Q.useMemo(()=>e=>qa(e.focus,gt),[gt]));Q.useLayoutEffect(()=>{if(!yt)return;let e=vt.current;e&&(P?e.scrollIntoView({block:`nearest`,inline:`nearest`}):_b(e)),jx(gt)},[yt,P,gt]);let bt=Ue.title||t(`sessions.sidebar.session.untitled`),xt=cc(sc(Ue)),St=Ue.metadata?.yuri?.titleRefresh,Ct=typeof St?.lastError==`string`?St.lastError:null,wt=typeof St?.failedAt==`number`?St.failedAt:null;Q.useEffect(()=>{!Ct||wt===null||console.warn(`[session-title] generation failed for ${He.id}: ${Ct}`)},[He.id,Ct,wt]);let Tt=typeof St?.generationExpiresAt==`number`&&Number.isFinite(St.generationExpiresAt)?St.generationExpiresAt:0,[Et,Dt]=Q.useState(0),Ot=Q.useMemo(()=>Math.max(0,Tt-Date.now()),[Tt]),[,kt,At]=Pt(()=>Dt(Tt),Ot,{immediate:!1}),Mt=St?.isGenerating===!0;Q.useEffect(()=>(Mt&&Tt>Date.now()&&kt(),At),[Mt,Tt,kt,At]);let Nt=r.children.length>0||!!(Ue.hasChildren??He.hasChildren),Ft=c.has(He.id),It=!!H?.has(He.id),Lt=ut,Rt=u?!0:l.has(Lt),zt=!!Ue.parentID,Bt=z===`pinned`,q=mn(He.id),Vt=q>0&&!zt,Ht=kn(Ue)||Date.now(),Ut=xo(Ht),Wt=Ao(Ht),[Gt,Kt]=Q.useState(!1),[qt,Jt]=Q.useState(!1),Yt=Gt,Xt=Q.useMemo(()=>nu(Ue.title)!==null,[Ue.title]),[Qt,$t]=Q.useState(!1),en=Q.useMemo(()=>Nx(r).length,[r]),tn=K(e=>{let t=Ge??``,n=(Xe()??at(t,Ke)).getTranscript(rt(t,e)),r=Ke.getState().session.find(t=>t.id===e)?.revert?.messageID;return Zt({sessionID:e,messages:Ye(n),parts:n.partsByMessageID,revertMessageID:r}).list}),nn=K(async e=>{let n=[],r=0;for(let i of e)try{await qe.ensureSessionRenderable(i.session.id);let e=tn(i.session.id),a=i.session.title||t(`sessions.sidebar.session.export.untitledSubagent`),o=i.session.agent,s=await nn(i.children);r+=s.skipped,n.push({title:a,agent:o,records:e,children:s.children})}catch{r+=Nx(i).length+1}return{children:n,skipped:r}}),rn=K(e=>{e<=0||X.warning(t(e===1?`sessions.sidebar.session.export.skippedSubtaskSingle`:`sessions.sidebar.session.export.skippedSubtaskMany`,{count:e}))}),an=K(async e=>{if(!Ge){X.error(t(`sessions.sidebar.session.export.nothingToExport`));return}await qe.ensureSessionRenderable(He.id);let n=tn(He.id);if(n.length===0){X.error(t(`sessions.sidebar.session.export.nothingToExport`));return}let i,a=0;if(e&&r.children.length>0){let e=await nn(r.children);i=e.children,a=e.skipped}let o=Pb(n,Ue.title??null,i),s=zb(Ue.title??null),c=await Ib(o,s);if(c){X.success(t(`sessions.sidebar.session.export.success`),{action:{label:t(Rb()),onClick:()=>{Lb(c).then(e=>{e||X.error(t(`sessions.sidebar.session.export.failedRevealPath`))})}}}),rn(a);return}Fb(o,s),X.success(t(`sessions.sidebar.session.export.success`)),rn(a)}),on=K(async()=>{if(r.children.length>0){it(!0),tt(!0);return}await an(!1)}),sn=K(()=>{Ge&&ee(`desktop_open_session_mini_chat_window`,{sessionId:He.id,directory:Ge,apiBaseUrl:h(),clientToken:n()}).catch(e=>{console.warn(`[session-sidebar] failed to open mini chat window`,e)})});Q.useLayoutEffect(()=>{if(f!==He.id){Le&&Re(!1),ze.current===He.id&&(ze.current=null);return}!Le||ze.current===He.id||(ze.current=He.id,Ie(m),queueMicrotask(()=>Ve.current?.select()))},[f,m,He.id,Le]);let cn=K(e=>{if(!e&&Fe.current){let{id:e,title:t}=Fe.current;Fe.current=null,Re(!0),p(e),g(t)}}),ln=K(e=>{Kt(e)}),un=K(e=>{e.preventDefault(),e.stopPropagation()}),fn=K(e=>{e.preventDefault(),e.stopPropagation()}),pn=K(e=>{e.preventDefault(),e.stopPropagation(),E(null),x(He.id)}),hn=!!U&&!!(R?.card||R?.slim)&&!s&&!zt,gn=K(e=>{if(e.preventDefault(),e.stopPropagation(),E(null),hn&&U){U(He.id,!It);return}N(He,{archivedBucket:s})}),_n=K(e=>{e.preventDefault(),e.stopPropagation(),E(null),N(He,{archivedBucket:s,hardDelete:!0,skipConfirm:!0})}),vn=K(e=>{e.preventDefault(),e.stopPropagation(),E(null),x(He.id)}),bn=K(()=>{!Ge||ot||(st(!0),(async()=>{try{await qe.refreshSessionTranscript(He.id,{directory:Ge}),X.success(t(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{X.error(t(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{st(!1)}})())}),xn=K(e=>{e.preventDefault(),e.stopPropagation()}),wn=K(e=>{e.preventDefault(),e.stopPropagation()}),En=K(e=>{e.preventDefault(),e.stopPropagation(),de?.vscode?.executeCommand(`yuri.openSessionInEditor`,He.id,bt)}),Dn=K(e=>{if(ke.current){ke.current=!1;return}if(Je){if(e?.preventDefault(),e?.stopPropagation(),e?.shiftKey){let e=(typeof document<`u`?Array.from(document.querySelectorAll(`[data-session-row]`)):[]).map(e=>e.getAttribute(`data-session-row`)).filter(e=>typeof e==`string`&&e.length>0),t=Hb.getState().anchorId,n=new Map;n.set(He.id,Nx(r)),$e(t,He.id,e,Ge??null,n);return}Qe(He.id,Ge??null,Nx(r));return}b(He.id,Ge,o,z)}),On=K(e=>{if(e.defaultPrevented||e.target?.closest(`button, a, input, [role="menuitem"], [role="menu"]`))return;Dn(e);let t=e.currentTarget.querySelector(`[data-session-title]`);t&&!P&&(t.focus({preventScroll:!0}),je.current=!0)}),An=K(e=>{(e.button===2||e.button===0&&e.ctrlKey&&!Je)&&(ke.current=!0)}),jn=K(e=>{je.current=e.pointerType===`mouse`,P&&e.pointerType===`touch`&&Ne(!0)}),Mn=K(e=>{P&&e.pointerType===`touch`&&Ne(!1)}),Fn=K(e=>{e.key!==`Enter`||!je.current||(e.preventDefault(),e.stopPropagation(),Re(!0),p(He.id),g(bt))}),In=K(e=>{if(Dn(e),!je.current)return;let t=e.currentTarget;window.requestAnimationFrame(()=>{je.current=!0,t.focus({preventScroll:!0})})}),Ln=K(()=>{je.current=!1}),Rn=K(()=>{!Rt&&!ct&&(lt(!0),qe.loadChildren(He.id,Ge).catch(()=>X.error(t(`sessions.sidebar.session.subsessions.loadFailed`))).finally(()=>lt(!1))),y(Lt)});if(f===He.id&&Le){let e=async()=>{v();try{await Pn(He.id)}catch(e){console.warn(`[session-sidebar] failed to request smart title:`,e)}};return(0,$.jsx)(`div`,{className:`group relative my-0.5 flex items-center rounded-lg py-1.5 pr-2`,style:{paddingLeft:yo(i)},children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0`,children:[(0,$.jsxs)(`form`,{ref:Be,className:`flex w-full items-center gap-2`,onSubmit:e=>{e.preventDefault(),_(G)},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||v()},children:[(0,$.jsx)(`input`,{ref:Ve,value:G,onChange:e=>Ie(e.target.value),className:`flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground`,autoFocus:!0,placeholder:t(`sessions.sidebar.session.menu.rename`),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Escape`){v();return}}}),(0,$.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{e()},"aria-label":t(`sessions.sidebar.session.rename.smartTitle`),title:t(`sessions.sidebar.session.rename.smartTitle`),className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(Z,{name:`ai-generate-2`,className:`size-3.5`})}),(0,$.jsx)(`button`,{type:`submit`,onMouseDown:e=>e.preventDefault(),"aria-label":t(`sessions.sidebar.session.rename.save`),title:t(`sessions.sidebar.session.rename.save`),className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(Z,{name:`check`,className:`size-3.5`})})]}),le?null:(0,$.jsx)(`div`,{className:`flex items-center justify-between gap-3 text-muted-foreground/60 min-w-0 overflow-hidden leading-tight`,style:{fontSize:`calc(var(--text-ui-label) * 0.85)`},children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 overflow-hidden`,children:[Nt&&!Bt&&!zt?(0,$.jsx)(`span`,{className:`inline-flex items-center justify-center flex-shrink-0`,children:Rt?(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-3 w-3`}):(0,$.jsx)(Z,{name:`arrow-right-s`,className:`h-3 w-3`})}):null,(0,$.jsx)(`span`,{className:`flex-shrink-0`,children:Ut}),oe?(0,$.jsx)(`span`,{className:`truncate`,children:R?.projectLabel}):null,W?(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-0.5`,children:[(0,$.jsx)(Z,{name:`git-branch`,className:`h-3 w-3 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:R?.branchLabel})]}):null]})})]})},He.id)}let zn=pt,Bn=Mt&&Tt>Date.now()&&Et!==Tt,Vn=mt.length,Hn=ht.length>0,Un=!Hn&&!zn&&Vt,Wn=!!R?.card,Gn=!!R?.slim,Kn=Hn||Vn>0,qn=!Kn&&zn,Jn=yt||Ze,Yn=Wn&&Un,Zn=!Wn&&(Hn||zn||Un),Qn=t(Hn?`sessions.sidebar.session.status.questionRequired`:`sessions.sidebar.session.status.permissionRequired`),$n=R?.runStartedAt??null,er=Kn?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium leading-none text-status-warning`,"aria-label":Qn,title:Qn,children:[(0,$.jsx)(Z,{name:Hn?`question`:`shield`,className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:Qn})]}):qn?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium leading-none tabular-nums text-status-info`,title:t(`sessions.sidebar.session.status.active`),children:[(0,$.jsx)($c,{size:10,arcColor:`var(--status-info)`}),$n===null?null:(0,$.jsx)(Sl,{startedAt:$n})]}):(0,$.jsx)(`span`,{className:Y(`text-[10px] leading-none tabular-nums`,Jn?`text-foreground/70`:`text-muted-foreground/70`),children:Wt}),tr=!F||ce,rr=tr?Y(`group-hover:invisible group-focus-within:invisible`,Yt&&`invisible`):Yt?`invisible`:``,ir=Hn?(0,$.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center`,"aria-label":t(`sessions.sidebar.session.status.questionRequired`),title:t(`sessions.sidebar.session.status.questionRequired`),children:(0,$.jsx)(Z,{name:`question`,className:`h-3.5 w-3.5 text-primary`})}):zn?(0,$.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center`,"aria-label":t(`sessions.sidebar.session.status.active`),title:t(`sessions.sidebar.session.status.active`),children:(0,$.jsx)($c,{})}):(0,$.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center`,"aria-label":t(`sessions.sidebar.session.status.unread`),title:t(`sessions.sidebar.session.status.unread`),children:(0,$.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-[var(--status-info)]`})}),ar=!Bt&&!zt&&Nt,or=ar&&!F&&!ct,sr=yo(Math.max(0,i-1)),cr=ar?(0,$.jsx)(`span`,{role:`button`,tabIndex:0,"aria-expanded":Rt,"aria-busy":ct,onClick:e=>{e.stopPropagation(),e.currentTarget.blur(),Rn()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),Rn())},style:{minWidth:14,minHeight:14,left:sr},className:Y(`absolute inline-flex h-3.5 w-3.5 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity`,le?`top-1/2 -translate-y-1/2`:`top-[14.5px] -translate-y-1/2`,or?`opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto`:``),"aria-label":t(Rt?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),children:ct?(0,$.jsx)($c,{size:12}):Rt?(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-3 w-3`}):(0,$.jsx)(Z,{name:`arrow-right-s`,className:`h-3 w-3`})}):null,lr=dt?(0,$.jsx)(Z,{name:`error-warning`,className:`h-4 w-4 text-status-warning`}):null,ur=(0,$.jsx)(me,{children:(0,$.jsx)(Ae,{className:`app-region-no-drag z-50`,children:(0,$.jsx)(be,{"data-slot":`dropdown-menu-content`,finalFocus:()=>!(D||Pe.current),style:{color:`var(--surface-elevated-foreground)`},className:Y(hi,`yuri-session-context-menu min-w-[180px]`),children:(({Item:e,Separator:n,Sub:r,SubTrigger:i,SubContent:a})=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(e,{onClick:()=>x(He.id),className:`[&>svg]:mr-1`,children:[Ft?(0,$.jsx)(Z,{name:`unpin`,className:`mr-1 h-4 w-4`}):(0,$.jsx)(Z,{name:`pushpin`,className:`mr-1 h-4 w-4`}),t(Ft?`sessions.sidebar.session.menu.unpin`:`sessions.sidebar.session.menu.pin`)]}),zt?null:(0,$.jsxs)(e,{onClick:()=>{q>0?Cn(He.id):dn(He.id,Ge||void 0).catch(()=>X.error(t(`sessions.sidebar.session.menu.markUnreadFailed`)))},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:q>0?`mail-open`:`mail`,className:`mr-1 h-4 w-4`}),t(q>0?`sessions.sidebar.session.menu.markRead`:`sessions.sidebar.session.menu.markUnread`)]}),(0,$.jsxs)(e,{onClick:()=>{Fe.current={id:He.id,title:bt}},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`pencil-ai`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.rename`)]}),Nn()&&!Ue.share?(0,$.jsxs)(e,{onClick:()=>S(Ue),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`share-2`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.share`)]}):Nn()&&Ue.share?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(e,{onClick:()=>{Ue.share?.url&&w(Ue.share.url,He.id)},className:`[&>svg]:mr-1`,children:C===He.id?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{name:`check`,className:`mr-1 h-4 w-4`,style:{color:`var(--status-success)`}}),t(`sessions.sidebar.session.menu.copied`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{name:`file-copy`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.copyLink`)]})}),(0,$.jsxs)(e,{onClick:()=>T(He.id),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`link-unlink-m`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.unshare`)]})]}):null,(0,$.jsxs)(e,{onClick:()=>{on()},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`download`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.exportMarkdown`)]}),(0,$.jsxs)(e,{disabled:!Ge||ot,onClick:()=>{bn()},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`refresh`,className:Y(`mr-1 h-4 w-4`,ot&&`animate-spin`)}),t(`sessions.sidebar.session.menu.refreshTranscript`)]}),Xt?(0,$.jsxs)(e,{onClick:()=>$t(!0),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Cx,{className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.runFusion`)]}):null,Ge&&!s?(()=>{let o=O(Ge),s=k(Ge,He.id);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(n,{}),(0,$.jsxs)(r,{children:[(0,$.jsxs)(i,{className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`folder`,className:`h-4 w-4`}),t(`sessions.sidebar.folders.moveToFolder`)]}),(0,$.jsxs)(a,{className:`min-w-[180px]`,children:[o.length===0?(0,$.jsx)(e,{disabled:!0,className:`text-muted-foreground`,children:t(`sessions.sidebar.folders.none`)}):o.map(t=>(0,$.jsxs)(e,{onClick:()=>{s===t.id?A(Ge,He.id):j(Ge,t.id,He.id)},children:[(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:t.name}),s===t.id?(0,$.jsx)(Z,{name:`check`,className:`ml-2 h-3.5 w-3.5 text-primary flex-shrink-0`}):null]},t.id)),(0,$.jsx)(n,{}),(0,$.jsxs)(e,{onClick:()=>{let e=M(Ge);e&&j(Ge,e.id,He.id)},children:[(0,$.jsx)(Z,{name:`add`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.folders.newFolderEllipsis`)]}),s?(0,$.jsxs)(e,{onClick:()=>{A(Ge,He.id)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(Z,{name:`close`,className:`mr-1 h-4 w-4 text-inherit`}),t(`sessions.sidebar.folders.removeFromFolder`)]}):null]})]})]})})():null,ue?(0,$.jsxs)(e,{disabled:!Ge,onClick:sn,className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`window`,className:`mr-1 h-4 w-4`}),(0,$.jsx)(`span`,{className:`truncate`,children:t(`sessions.sidebar.session.menu.openMiniChatWindow`)})]}):null,(0,$.jsx)(n,{}),s?null:hn&&It?(0,$.jsxs)(e,{className:`[&>svg]:mr-1`,onClick:()=>U?.(He.id,!1),children:[(0,$.jsx)(Z,{name:`undo-2`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.unsettle`)]}):(0,$.jsxs)(e,{className:`[&>svg]:mr-1`,onClick:()=>hn&&U?U(He.id,!0):N(He,{archivedBucket:s}),children:[(0,$.jsx)(Z,{name:`inbox-archive`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.bulkActions.archive`)]}),(0,$.jsxs)(e,{className:`text-destructive/80 focus:text-destructive/80 [&>svg]:mr-1`,onClick:()=>N(He,{archivedBucket:s,hardDelete:!0}),children:[(0,$.jsx)(Z,{name:`delete-bin`,className:`mr-1 h-4 w-4 text-inherit`}),t(`sessions.sidebar.bulkActions.delete`)]})]}))({Item:({className:e,...t})=>(0,$.jsx)(ge,{className:Y(_i,e),...t}),Separator:({className:e,...t})=>(0,$.jsx)(_e,{className:Y(gi,e),...t}),Sub:ve,SubTrigger:({className:e,children:t,...n})=>(0,$.jsxs)(Ce,{className:Y(mi,e),...n,children:[t,(0,$.jsx)(Z,{name:`arrow-right-s`,className:`ml-auto size-3.5`})]}),SubContent:({className:e,children:t,...n})=>(0,$.jsx)(me,{children:(0,$.jsx)(Ae,{className:`app-region-no-drag z-50`,children:(0,$.jsx)(be,{"data-slot":`dropdown-menu-sub-content`,style:{color:`var(--surface-elevated-foreground)`},className:Y(hi,`yuri-session-context-menu`,e),...n,children:t})})})})})})});return(0,$.jsxs)(Q.Fragment,{children:[(0,$.jsx)(Yc,{sessionId:He.id,sessionDirectory:Ge??null,sessionTitle:bt,children:(0,$.jsxs)(pe,{open:Gt,onOpenChange:ln,onOpenChangeComplete:cn,children:[(0,$.jsxs)(we,{render:(0,$.jsx)(qc,{ref:vt,active:yt,selected:Ze,"data-session-row":He.id,"data-session-scope":Ge??``,"data-session-focus-scope":z,"data-session-focus-key":_t,"data-session-project-id":o??``,"data-session-archived":s?`1`:`0`,"data-session-depth":i,onClick:On,className:Y(yt&&!Ze&&`bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] dark:bg-[color-mix(in_srgb,var(--surface-foreground)_11%,transparent)]`,Ze&&`bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] dark:bg-[color-mix(in_srgb,var(--surface-foreground)_11%,transparent)]`,!yt&&!Ze&&`hover:bg-[color-mix(in_srgb,var(--surface-foreground)_3.5%,transparent)] dark:hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)]`,Gn&&`py-1`)}),children:[cr,(0,$.jsx)(Gc,{depth:i,children:(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:(0,$.jsxs)(ni,{onOpenChange:Jt,children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsxs)(Cc,{type:`button`,"data-session-title":!0,onPointerDown:jn,onPointerUp:Mn,onPointerCancel:Mn,onMouseDown:An,onKeyDown:Fn,onBlur:Ln,onClick:In,onDoubleClick:e=>{e.stopPropagation(),!P&&L()&&sn()},className:Y(Me&&`bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)]`,Wn&&`gap-0.5`,!Wn&&Oe),children:[Wn?(0,$.jsxs)(`div`,{className:Y(`flex h-5 w-full min-w-0 items-center gap-1 overflow-hidden`,Oe),children:[(0,$.jsx)(_l,{project:R?.project}),Yn&&!Kn?(0,$.jsx)(Qc,{}):null,(0,$.jsx)(`span`,{className:Y(`min-w-0 flex-1 truncate typography-micro leading-4`,Jn?`text-foreground/80`:`text-muted-foreground`),children:R?.projectLabel}),(0,$.jsx)(`span`,{className:Y(`shrink-0`,rr),children:er})]}):null,(0,$.jsxs)(`div`,{className:`flex w-full items-center min-w-0 flex-1 gap-1 overflow-hidden`,children:[Gn?(0,$.jsx)(_l,{project:R?.project}):null,(0,$.jsx)(`div`,{className:Y(`block min-w-0 flex-1 truncate text-foreground`,Gn?`typography-meta`:`typography-ui-label`,Gn&&!Jn&&`text-muted-foreground`,Yn?`font-medium`:`font-normal`,Bn&&`animate-text-shimmer`),"aria-busy":Bn||void 0,children:_o(bt,d)}),xt?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro tabular-nums text-muted-foreground`,children:xt}):null,Gn?(0,$.jsx)(`span`,{className:Y(`shrink-0 text-[10px] leading-none tabular-nums text-muted-foreground/70`,rr),children:Wt}):null,We?(0,$.jsx)(Z,{name:`ai-agent`,className:`size-3 shrink-0 text-muted-foreground`,"aria-label":`Assistant`}):null,Vn>0&&!Wn?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive flex-shrink-0`,title:t(`sessions.sidebar.session.status.permissionRequired`),"aria-label":t(`sessions.sidebar.session.status.permissionRequired`),children:[(0,$.jsx)(Z,{name:`shield`,className:`h-3 w-3`}),(0,$.jsx)(`span`,{className:`leading-none`,children:Vn})]}):null,Zn?(0,$.jsx)(`span`,{className:Y(`inline-flex shrink-0 items-center justify-center transition-none`,tr?Y(`group-hover:hidden group-focus-within:hidden`,Yt?`hidden`:``):Yt?`invisible`:``),children:ir}):null,ie?(0,$.jsx)(Ix,{number:ie}):null]}),Wn?(0,$.jsxs)(`div`,{className:Y(`flex h-4 w-full min-w-0 items-center gap-1 overflow-hidden text-[10px] leading-4`,Jn?`text-foreground/60`:`text-muted-foreground/60`),children:[W?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`inline-flex size-3.5 shrink-0 items-center justify-center`,children:(0,$.jsx)(Z,{name:`git-branch`,className:`size-2.5`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:R?.branchLabel})]}):R?.branchState===`loading`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`inline-flex size-3.5 shrink-0 items-center justify-center`,children:(0,$.jsx)(Z,{name:`git-branch`,className:`size-2.5`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 animate-pulse truncate`,children:t(`common.loading`)})]}):R?.pathLabel?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`inline-flex size-3.5 shrink-0 items-center justify-center`,children:(0,$.jsx)(Z,{name:`folder-open`,className:`size-2.5`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:R.pathLabel})]}):(0,$.jsx)(`span`,{className:`flex-1`}),Ft?(0,$.jsx)(Z,{name:`pushpin-2-fill`,className:`size-2.5 shrink-0`,"aria-label":t(`sessions.sidebar.session.actions.pinned`)}):null]}):null]})}),ce?null:(0,$.jsx)(ei,{side:`right`,align:`start`,sideOffset:8,className:`w-64 max-w-[min(16rem,calc(100vw-2rem))] px-3 py-2.5 text-left shadow-md`,children:qt?(0,$.jsx)(Bb,{session:Ue,title:bt,time:Wt,projectLabel:R?.projectLabel,project:R?.project,branch:r.worktree?.branch??R?.branchLabel,directory:Ge}):null})]})})}),lr&&!P?(0,$.jsx)(`div`,{className:Y(`absolute top-1/2 -translate-y-1/2 z-10`,le?`right-0`:`right-[30px]`),children:lr}):null,(0,$.jsxs)(wc,{visible:Yt||F&&!ce,className:Y(`absolute right-1 top-1/2 z-10 flex -translate-y-1/2 items-center gap-1 transition-none group-has-[[data-sidebar-shortcut-number]]:hidden`,Yt||F&&!ce?`opacity-100`:Y(`opacity-0`,fe),Wn&&`top-1.5 translate-y-0`),children:[xe?(0,$.jsx)(Px,{pinned:Ft,pinLabel:t(Ft?`sessions.sidebar.session.menu.unpin`:`sessions.sidebar.session.menu.pin`),buttonSizeClass:Se,iconSizeClass:Te,onPointerDown:un,onMouseDown:fn,onPin:pn}):null,ye?(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`inline-flex items-center justify-center rounded-md text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,Se),"aria-label":t(`sessions.sidebar.session.actions.pinned`),onPointerDown:un,onMouseDown:fn,onClick:vn,onKeyDown:e=>e.stopPropagation(),children:(0,$.jsx)(Z,{name:`pushpin-2-fill`,className:Te})})}),(0,$.jsx)(ei,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:t(`sessions.sidebar.session.actions.pinned`)})]}):null,he?(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,Se),"aria-label":t(`sessions.sidebar.session.actions.openInEditor`),onPointerDown:xn,onMouseDown:wn,onClick:En,onKeyDown:e=>e.stopPropagation(),children:(0,$.jsx)(Z,{name:`external-link`,className:Te})})}),(0,$.jsx)(ei,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:t(`sessions.sidebar.session.actions.openInEditor`)})]}):null,(0,$.jsx)(Fx,{archiveLabel:t(hn&&It?`sessions.sidebar.session.menu.unsettle`:`sessions.sidebar.bulkActions.archive`),restore:hn&&It,deleteLabel:t(`sessions.sidebar.bulkActions.delete`),deleteOnly:s===!0,buttonSizeClass:Se,iconSizeClass:Te,revealClassName:le&&!F&&!Yt?Y(`opacity-0`,fe):`opacity-100`,onPointerDown:un,onMouseDown:fn,onArchive:gn,onDelete:_n})]})]}),ur]})}),!Bt&&Nt&&Rt?r.children.map(e=>{let t=ne?ne(e):{subtreeContainsActive:B,subtreeContainsEditing:V,menuOpenSessionId:te,nodeStructureKey:``};return I(e,i+1,Ge??a,o,s,void 0,z,t)}):null,(0,$.jsx)(Qr,{open:et,onOpenChange:tt,children:(0,$.jsxs)(Yr,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[(0,$.jsxs)(qr,{children:[(0,$.jsx)(Xr,{children:t(`sessions.sidebar.session.export.dialog.title`)}),(0,$.jsx)(Zr,{children:t(en===1?`sessions.sidebar.session.export.dialog.descriptionSingle`:`sessions.sidebar.session.export.dialog.descriptionMany`,{count:en})})]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-ui-label cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:nt,onChange:e=>it(e.target.checked),className:`h-4 w-4 rounded border-border accent-primary`}),t(`sessions.sidebar.session.export.dialog.includeSubtasks`)]}),(0,$.jsxs)(Jr,{children:[(0,$.jsx)(J,{type:`button`,onClick:()=>tt(!1),variant:`outline`,size:`sm`,children:t(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(J,{type:`button`,onClick:()=>{tt(!1),an(nt)},size:`sm`,children:t(`sessions.sidebar.session.export.dialog.confirm`)})]})]})}),Xt?(0,$.jsx)(Sx,{session:Ue,open:Qt,onOpenChange:$t}):null]},He.id)}var Rx=e=>ft(e.session.directory??null),zx=(e,t)=>(e?.projectLabel??null)===(t?.projectLabel??null)&&(e?.branchLabel??null)===(t?.branchLabel??null)&&!!e?.card==!!t?.card&&!!e?.slim==!!t?.slim&&(e?.branchState??null)===(t?.branchState??null)&&(e?.pathLabel??null)===(t?.pathLabel??null)&&(e?.project??null)===(t?.project??null)&&(e?.runStartedAt??null)===(t?.runStartedAt??null),Bx=e=>{if(!e.openSidebarMenuKey)return null;let t=e.archivedBucket?`archived`:`active`,n=`${e.renderContext??`project`}:${t}:`;return e.openSidebarMenuKey.startsWith(n)?e.openSidebarMenuKey.slice(n.length):null},Vx=e=>e.menuOpenSessionId??Bx(e),Hx=(e,t,n)=>t?n.has(e.node.session.id)?!0:Pc(e.node,t):!1,Ux=(e,t,n,r,i)=>{if(e.session.id!==t.session.id)return!0;let a=i(e);if(n.has(a)!==r.has(a)||e.children.length!==t.children.length)return!0;for(let a=0;a<e.children.length;a+=1)if(Ux(e.children[a],t.children[a],n,r,i))return!0;return!1},Wx=(e,t,n,r)=>{if(e.session.id!==t.session.id)return!0;let i=e.session.id,a=n.get(i)??e.session,o=r.get(i)??t.session;if(a!==o&&xc(a)!==xc(o)||e.children.length!==t.children.length)return!0;for(let i=0;i<e.children.length;i+=1)if(Wx(e.children[i],t.children[i],n,r))return!0;return!1},Gx=(e,t)=>{if(e.hasSessionSearchQuery||t.hasSessionSearchQuery)return!1;let n=e.archivedBucket?`archived`:`active`,r=t.archivedBucket?`archived`:`active`;return Ux(e.node,t.node,e.expandedParents,t.expandedParents,t=>`${e.renderContext??`project`}:${n}:${t.session.id}`)||Ux(e.node,t.node,e.expandedParents,t.expandedParents,e=>`${t.renderContext??`project`}:${r}:${e.session.id}`)},Kx=Q.memo(Lx,(e,t)=>{if(e.node.session.id!==t.node.session.id||e.depth!==t.depth||e.groupDirectory!==t.groupDirectory||e.projectId!==t.projectId||e.archivedBucket!==t.archivedBucket||(e.renderContext??`project`)!==(t.renderContext??`project`)||e.mobileVariant!==t.mobileVariant||e.alwaysShowActions!==t.alwaysShowActions||e.shortcutNumber!==t.shortcutNumber||e.hasSessionSearchQuery!==t.hasSessionSearchQuery||e.normalizedSessionSearchQuery!==t.normalizedSessionSearchQuery||e.notifyOnSubtasks!==t.notifyOnSubtasks||e.nodeStructureKey!==t.nodeStructureKey||e.node.session.hasChildren!==t.node.session.hasChildren||Rx(e.node)!==Rx(t.node)||!zx(e.secondaryMeta,t.secondaryMeta)||e.liveSessionById!==t.liveSessionById&&Wx(e.node,t.node,e.liveSessionById,t.liveSessionById)||e.pinnedSessionIds!==t.pinnedSessionIds&&Ux(e.node,t.node,e.pinnedSessionIds,t.pinnedSessionIds,e=>e.session.id)||e.settledSessionIds!==t.settledSessionIds&&e.settledSessionIds?.has(e.node.session.id)!==t.settledSessionIds?.has(t.node.session.id)||e.setSessionSettled!==t.setSessionSettled||e.expandedParents!==t.expandedParents&&Gx(e,t)||e.currentSessionId!==t.currentSessionId&&(Hx(e,e.currentSessionId,e.subtreeContainsActive)||Hx(t,t.currentSessionId,t.subtreeContainsActive))||e.editingId!==t.editingId&&(Hx(e,e.editingId,e.subtreeContainsEditing)||Hx(t,t.editingId,t.subtreeContainsEditing))||e.editTitle!==t.editTitle&&(Hx(e,e.editingId,e.subtreeContainsEditing)||Hx(t,t.editingId,t.subtreeContainsEditing))||e.copiedSessionId!==t.copiedSessionId&&(Pc(e.node,e.copiedSessionId)||Pc(t.node,t.copiedSessionId)))return!1;if(e.openSidebarMenuKey!==t.openSidebarMenuKey){let n=Vx(e),r=Vx(t);if(Pc(e.node,n)||Pc(t.node,r))return!1}if(e.renamingFolderId!==t.renamingFolderId){let n=Vx(e),r=Vx(t);if(Pc(e.node,n)||Pc(t.node,r))return!1}return e.setEditingId===t.setEditingId&&e.setEditTitle===t.setEditTitle&&e.handleSaveEdit===t.handleSaveEdit&&e.handleCancelEdit===t.handleCancelEdit&&e.toggleParent===t.toggleParent&&e.handleSessionSelect===t.handleSessionSelect&&e.handleSessionDoubleClick===t.handleSessionDoubleClick&&e.togglePinnedSession===t.togglePinnedSession&&e.handleShareSession===t.handleShareSession&&e.handleCopyShareUrl===t.handleCopyShareUrl&&e.handleUnshareSession===t.handleUnshareSession&&e.setOpenSidebarMenuKey===t.setOpenSidebarMenuKey&&e.getFoldersForScope===t.getFoldersForScope&&e.getSessionFolderId===t.getSessionFolderId&&e.removeSessionFromFolder===t.removeSessionFromFolder&&e.addSessionToFolder===t.addSessionToFolder&&e.createFolderAndStartRename===t.createFolderAndStartRename&&e.handleDeleteSession===t.handleDeleteSession&&e.renderSessionNode===t.renderSessionNode});function qx(e){return e.stopPropagation()}function Jx(e){return e.stopPropagation()}function Yx(e){let t=(0,ju.c)(71),{t:n}=Nr(),{value:r,setValue:i,showDeletionDialog:a,setShowDeletionDialog:o,onConfirm:s}=e,c,l,u,d,f,p,m,h,g,_;if(t[0]!==i||t[1]!==n||t[2]!==r){let e=n(`sessions.sidebar.session.untitled`);d=Qr,g=!!r,t[13]===i?_=t[14]:(_=e=>{e||i(null)},t[13]=i,t[14]=_),u=Yr,m=!1,h=`max-w-sm gap-5`,l=qr;let a;t[15]!==n||t[16]!==r?.archivedBucket?(a=r?.archivedBucket?n(`sessions.sidebar.dialogs.deleteSession.title`):n(`sessions.sidebar.dialogs.archiveSession.title`),t[15]=n,t[16]=r?.archivedBucket,t[17]=a):a=t[17],t[18]===a?p=t[19]:(p=(0,$.jsx)(Xr,{children:a}),t[18]=a,t[19]=p),c=Zr,f=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?n(`sessions.sidebar.dialogs.deleteSession.withOneSubtask`,{sessionTitle:r.session.title||e,count:r.descendantCount}):n(`sessions.sidebar.dialogs.deleteSession.withManySubtasks`,{sessionTitle:r.session.title||e,count:r.descendantCount}):r.descendantCount===1?n(`sessions.sidebar.dialogs.archiveSession.withOneSubtask`,{sessionTitle:r.session.title||e,count:r.descendantCount}):n(`sessions.sidebar.dialogs.archiveSession.withManySubtasks`,{sessionTitle:r.session.title||e,count:r.descendantCount}):r?.archivedBucket?n(`sessions.sidebar.dialogs.deleteSession.single`,{sessionTitle:r?.session.title||e}):n(`sessions.sidebar.dialogs.archiveSession.single`,{sessionTitle:r?.session.title||e}),t[0]=i,t[1]=n,t[2]=r,t[3]=c,t[4]=l,t[5]=u,t[6]=d,t[7]=f,t[8]=p,t[9]=m,t[10]=h,t[11]=g,t[12]=_}else c=t[3],l=t[4],u=t[5],d=t[6],f=t[7],p=t[8],m=t[9],h=t[10],g=t[11],_=t[12];let v;t[20]!==c||t[21]!==f?(v=(0,$.jsx)(c,{children:f}),t[20]=c,t[21]=f,t[22]=v):v=t[22];let y;t[23]!==l||t[24]!==p||t[25]!==v?(y=(0,$.jsxs)(l,{children:[p,v]}),t[23]=l,t[24]=p,t[25]=v,t[26]=y):y=t[26];let b;t[27]!==o||t[28]!==a?(b=()=>o(!a),t[27]=o,t[28]=a,t[29]=b):b=t[29];let x=!a,S;t[30]===a?S=t[31]:(S=a?(0,$.jsx)(Z,{name:`checkbox-blank`,className:`h-4 w-4`}):(0,$.jsx)(Z,{name:`checkbox`,className:`h-4 w-4 text-primary`}),t[30]=a,t[31]=S);let C;t[32]===n?C=t[33]:(C=n(`sessions.sidebar.dialogs.neverAsk`),t[32]=n,t[33]=C);let w;t[34]!==S||t[35]!==C||t[36]!==b||t[37]!==x?(w=(0,$.jsxs)(`button`,{type:`button`,onClick:b,className:`inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50`,"aria-pressed":x,children:[S,C]}),t[34]=S,t[35]=C,t[36]=b,t[37]=x,t[38]=w):w=t[38];let T;t[39]===i?T=t[40]:(T=()=>i(null),t[39]=i,t[40]=T);let E;t[41]===n?E=t[42]:(E=n(`sessions.sidebar.dialogs.cancel`),t[41]=n,t[42]=E);let D;t[43]!==T||t[44]!==E?(D=(0,$.jsx)(`button`,{type:`button`,onClick:T,className:`inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:E}),t[43]=T,t[44]=E,t[45]=D):D=t[45];let O;t[46]===s?O=t[47]:(O=()=>void s(),t[46]=s,t[47]=O);let k;t[48]!==n||t[49]!==r?.archivedBucket?(k=r?.archivedBucket?n(`sessions.sidebar.bulkActions.delete`):n(`sessions.sidebar.bulkActions.archive`),t[48]=n,t[49]=r?.archivedBucket,t[50]=k):k=t[50];let A;t[51]!==O||t[52]!==k?(A=(0,$.jsx)(`button`,{type:`button`,onClick:O,className:`inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`,children:k}),t[51]=O,t[52]=k,t[53]=A):A=t[53];let j;t[54]!==D||t[55]!==A?(j=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[D,A]}),t[54]=D,t[55]=A,t[56]=j):j=t[56];let M;t[57]!==w||t[58]!==j?(M=(0,$.jsxs)(Jr,{className:`w-full sm:items-center sm:justify-between`,children:[w,j]}),t[57]=w,t[58]=j,t[59]=M):M=t[59];let N;t[60]!==u||t[61]!==m||t[62]!==M||t[63]!==h||t[64]!==y?(N=(0,$.jsxs)(u,{showCloseButton:m,className:h,children:[y,M]}),t[60]=u,t[61]=m,t[62]=M,t[63]=h,t[64]=y,t[65]=N):N=t[65];let P;return t[66]!==d||t[67]!==N||t[68]!==g||t[69]!==_?(P=(0,$.jsx)(d,{open:g,onOpenChange:_,children:N}),t[66]=d,t[67]=N,t[68]=g,t[69]=_,t[70]=P):P=t[70],P}function Xx(e){let t=(0,ju.c)(57),{t:n}=Nr(),{value:r,setValue:i,showDeletionDialog:a,setShowDeletionDialog:o,onConfirm:s}=e,c=r?.archivedBucket===!0,l=r?.sessionCount??0,u;t[0]!==c||t[1]!==l||t[2]!==n?(u=n(c?l===1?`sessions.sidebar.dialogs.deleteSession.title`:`sessions.sidebar.dialogs.deleteSessions.title`:l===1?`sessions.sidebar.dialogs.archiveSession.title`:`sessions.sidebar.dialogs.archiveSessions.title`),t[0]=c,t[1]=l,t[2]=n,t[3]=u):u=t[3];let d=u,f;t[4]!==c||t[5]!==l||t[6]!==n?(f=n(c?l===1?`sessions.sidebar.dialogs.deleteSessions.singleDescription`:`sessions.sidebar.dialogs.deleteSessions.pluralDescription`:l===1?`sessions.sidebar.dialogs.archiveSessions.singleDescription`:`sessions.sidebar.dialogs.archiveSessions.pluralDescription`,{count:l}),t[4]=c,t[5]=l,t[6]=n,t[7]=f):f=t[7];let p=f,m=!!r,h;t[8]===i?h=t[9]:(h=e=>{e||i(null)},t[8]=i,t[9]=h);let g;t[10]===d?g=t[11]:(g=(0,$.jsx)(Xr,{children:d}),t[10]=d,t[11]=g);let _;t[12]===p?_=t[13]:(_=(0,$.jsx)(Zr,{children:p}),t[12]=p,t[13]=_);let v;t[14]!==g||t[15]!==_?(v=(0,$.jsxs)(qr,{children:[g,_]}),t[14]=g,t[15]=_,t[16]=v):v=t[16];let y;t[17]!==o||t[18]!==a?(y=()=>o(!a),t[17]=o,t[18]=a,t[19]=y):y=t[19];let b=!a,x;t[20]===a?x=t[21]:(x=a?(0,$.jsx)(Z,{name:`checkbox-blank`,className:`h-4 w-4`}):(0,$.jsx)(Z,{name:`checkbox`,className:`h-4 w-4 text-primary`}),t[20]=a,t[21]=x);let S;t[22]===n?S=t[23]:(S=n(`sessions.sidebar.dialogs.neverAsk`),t[22]=n,t[23]=S);let C;t[24]!==S||t[25]!==y||t[26]!==b||t[27]!==x?(C=(0,$.jsxs)(`button`,{type:`button`,onClick:y,className:`inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50`,"aria-pressed":b,children:[x,S]}),t[24]=S,t[25]=y,t[26]=b,t[27]=x,t[28]=C):C=t[28];let w;t[29]===i?w=t[30]:(w=()=>i(null),t[29]=i,t[30]=w);let T;t[31]===n?T=t[32]:(T=n(`sessions.sidebar.dialogs.cancel`),t[31]=n,t[32]=T);let E;t[33]!==w||t[34]!==T?(E=(0,$.jsx)(`button`,{type:`button`,onClick:w,className:`inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:T}),t[33]=w,t[34]=T,t[35]=E):E=t[35];let D;t[36]===s?D=t[37]:(D=()=>void s(),t[36]=s,t[37]=D);let O;t[38]!==c||t[39]!==n?(O=n(c?`sessions.sidebar.bulkActions.delete`:`sessions.sidebar.bulkActions.archive`),t[38]=c,t[39]=n,t[40]=O):O=t[40];let k;t[41]!==D||t[42]!==O?(k=(0,$.jsx)(`button`,{type:`button`,onClick:D,className:`inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`,children:O}),t[41]=D,t[42]=O,t[43]=k):k=t[43];let A;t[44]!==E||t[45]!==k?(A=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[E,k]}),t[44]=E,t[45]=k,t[46]=A):A=t[46];let j;t[47]!==C||t[48]!==A?(j=(0,$.jsxs)(Jr,{className:`w-full sm:items-center sm:justify-between`,children:[C,A]}),t[47]=C,t[48]=A,t[49]=j):j=t[49];let M;t[50]!==j||t[51]!==v?(M=(0,$.jsxs)(Yr,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[v,j]}),t[50]=j,t[51]=v,t[52]=M):M=t[52];let N;return t[53]!==m||t[54]!==M||t[55]!==h?(N=(0,$.jsx)(Qr,{open:m,onOpenChange:h,children:M}),t[53]=m,t[54]=M,t[55]=h,t[56]=N):N=t[56],N}function Zx(e){let t=(0,ju.c)(36),{t:n}=Nr(),{value:r,setValue:i,onConfirm:a}=e,o=!!r,s;t[0]===i?s=t[1]:(s=e=>{e||i(null)},t[0]=i,t[1]=s);let c;t[2]===n?c=t[3]:(c=n(`sessions.sidebar.dialogs.deleteFolder.title`),t[2]=n,t[3]=c);let l;t[4]===c?l=t[5]:(l=(0,$.jsx)(Xr,{children:c}),t[4]=c,t[5]=l);let u;t[6]!==n||t[7]!==r?(u=r&&(r.subFolderCount>0||r.sessionCount>0)?r.subFolderCount>0?r.subFolderCount===1?n(`sessions.sidebar.dialogs.deleteFolder.withOneSubfolder`,{folderName:r.folderName,count:r.subFolderCount}):n(`sessions.sidebar.dialogs.deleteFolder.withManySubfolders`,{folderName:r.folderName,count:r.subFolderCount}):n(`sessions.sidebar.dialogs.deleteFolder.withContentsNoSubfolders`,{folderName:r.folderName}):n(`sessions.sidebar.dialogs.deleteFolder.single`,{folderName:r?.folderName??``}),t[6]=n,t[7]=r,t[8]=u):u=t[8];let d;t[9]===u?d=t[10]:(d=(0,$.jsx)(Zr,{children:u}),t[9]=u,t[10]=d);let f;t[11]!==l||t[12]!==d?(f=(0,$.jsxs)(qr,{children:[l,d]}),t[11]=l,t[12]=d,t[13]=f):f=t[13];let p;t[14]===i?p=t[15]:(p=()=>i(null),t[14]=i,t[15]=p);let m;t[16]===n?m=t[17]:(m=n(`sessions.sidebar.dialogs.cancel`),t[16]=n,t[17]=m);let h;t[18]!==p||t[19]!==m?(h=(0,$.jsx)(`button`,{type:`button`,onClick:p,className:`inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:m}),t[18]=p,t[19]=m,t[20]=h):h=t[20];let g;t[21]===n?g=t[22]:(g=n(`sessions.sidebar.bulkActions.delete`),t[21]=n,t[22]=g);let _;t[23]!==a||t[24]!==g?(_=(0,$.jsx)(`button`,{type:`button`,onClick:a,className:`inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`,children:g}),t[23]=a,t[24]=g,t[25]=_):_=t[25];let v;t[26]!==_||t[27]!==h?(v=(0,$.jsxs)(Jr,{children:[h,_]}),t[26]=_,t[27]=h,t[28]=v):v=t[28];let y;t[29]!==v||t[30]!==f?(y=(0,$.jsxs)(Yr,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[f,v]}),t[29]=v,t[30]=f,t[31]=y):y=t[31];let b;return t[32]!==o||t[33]!==s||t[34]!==y?(b=(0,$.jsx)(Qr,{open:o,onOpenChange:s,children:y}),t[32]=o,t[33]=s,t[34]=y,t[35]=b):b=t[35],b}var Qx=e=>{let t=(0,ju.c)(46),{selectedCount:n,scopeKey:r,scopeFolders:i,archivedBucket:a,onMoveToFolder:o,onCreateFolderAndMove:s,onRemoveFromFolder:c,canRemoveFromFolder:l,onDelete:u,onDone:d}=e,{t:f}=Nr(),p=!!r&&!a,m;t[0]!==a||t[1]!==f?(m=f(a?`sessions.sidebar.bulkActions.delete`:`sessions.sidebar.bulkActions.archive`),t[0]=a,t[1]=f,t[2]=m):m=t[2];let h=m,g;t[3]!==n||t[4]!==f?(g=f(`sessions.sidebar.bulkActions.selectedCount`,{count:n}),t[3]=n,t[4]=f,t[5]=g):g=t[5];let _;t[6]===g?_=t[7]:(_=(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground whitespace-nowrap`,children:g}),t[6]=g,t[7]=_);let v;t[8]!==p||t[9]!==l||t[10]!==s||t[11]!==o||t[12]!==c||t[13]!==i||t[14]!==f?(v=p?(0,$.jsxs)(Ci,{children:[(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(vi,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":f(`sessions.sidebar.bulkActions.moveToFolder`),children:(0,$.jsx)(Z,{name:`folder`,className:`h-4 w-4`})})})}),(0,$.jsx)(ei,{side:`top`,sideOffset:4,children:(0,$.jsx)(`p`,{children:f(`sessions.sidebar.bulkActions.moveToFolder`)})})]}),(0,$.jsxs)(bi,{align:`end`,className:`min-w-[180px]`,children:[i.length===0?(0,$.jsx)(xi,{disabled:!0,className:`text-muted-foreground`,children:f(`sessions.sidebar.folders.none`)}):i.map(e=>(0,$.jsx)(xi,{onClick:()=>o(e.id),children:(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:e.name})},e.id)),(0,$.jsx)(Si,{}),(0,$.jsxs)(xi,{onClick:s,children:[(0,$.jsx)(Z,{name:`add`,className:`mr-1 h-4 w-4`}),f(`sessions.sidebar.folders.newFolderEllipsis`)]}),l?(0,$.jsxs)(xi,{onClick:c,className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(Z,{name:`close`,className:`mr-1 h-4 w-4 text-inherit`}),f(`sessions.sidebar.folders.removeFromFolder`)]}):null]})]}):null,t[8]=p,t[9]=l,t[10]=s,t[11]=o,t[12]=c,t[13]=i,t[14]=f,t[15]=v):v=t[15];let y;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(y=Y(`inline-flex h-7 w-7 items-center justify-center rounded-md text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`),t[16]=y):y=t[16];let b;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(Z,{name:`delete-bin`,className:`h-4 w-4`}),t[17]=b):b=t[17];let x;t[18]!==h||t[19]!==u?(x=(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:u,className:y,"aria-label":h,children:b})}),t[18]=h,t[19]=u,t[20]=x):x=t[20];let S;t[21]===h?S=t[22]:(S=(0,$.jsx)(ei,{side:`top`,sideOffset:4,children:(0,$.jsx)(`p`,{children:h})}),t[21]=h,t[22]=S);let C;t[23]!==x||t[24]!==S?(C=(0,$.jsxs)(ni,{children:[x,S]}),t[23]=x,t[24]=S,t[25]=C):C=t[25];let w;t[26]===f?w=t[27]:(w=f(`sessions.sidebar.header.actions.exitSelection`),t[26]=f,t[27]=w);let T;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(Z,{name:`close`,className:`h-4 w-4`}),t[28]=T):T=t[28];let E;t[29]!==d||t[30]!==w?(E=(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:d,className:`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":w,children:T})}),t[29]=d,t[30]=w,t[31]=E):E=t[31];let D;t[32]===f?D=t[33]:(D=f(`sessions.sidebar.header.actions.exitSelection`),t[32]=f,t[33]=D);let O;t[34]===D?O=t[35]:(O=(0,$.jsx)(ei,{side:`top`,sideOffset:4,children:(0,$.jsx)(`p`,{children:D})}),t[34]=D,t[35]=O);let k;t[36]!==E||t[37]!==O?(k=(0,$.jsxs)(ni,{children:[E,O]}),t[36]=E,t[37]=O,t[38]=k):k=t[38];let A;t[39]!==k||t[40]!==v||t[41]!==C?(A=(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5`,children:[v,C,k]}),t[39]=k,t[40]=v,t[41]=C,t[42]=A):A=t[42];let j;return t[43]!==A||t[44]!==_?(j=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-t border-border px-2.5 py-1.5`,children:[_,A]}),t[43]=A,t[44]=_,t[45]=j):j=t[45],j},$x=e=>{let{t}=Nr(),{isInlineEditing:n,showDeletionDialog:r,foldersMap:i,addSessionsToFolder:a,removeSessionsFromFolders:o,createFolderAndStartRename:s,archiveSessions:c,setBulkDeleteConfirm:l}=e,u=Hb(e=>e.enabled),d=Hb(e=>e.selectedIds.size),f=d>0,p=Hb(e=>e.selectedIds),m=Hb(e=>e.scopeKey),h=Q.useCallback(()=>{Hb.getState().toggleMode()},[]),g=Q.useCallback(()=>{Hb.getState().disable()},[]),_=Q.useMemo(()=>{if(!f||typeof document>`u`)return!1;let e=!1,t=!1;for(let n of p){let r=document.querySelectorAll(`[data-session-row="${CSS.escape(n)}"]`);for(let n of r)n.getAttribute(`data-session-archived`)===`1`?t=!0:e=!0}return t&&!e},[f,p]),v=Q.useMemo(()=>{if(m)return m;if(!f||typeof document>`u`)return null;for(let e of p){let t=document.querySelector(`[data-session-row="${CSS.escape(e)}"]`)?.getAttribute(`data-session-scope`);if(t&&t.length>0)return t}return null},[f,p,m]),y=Q.useMemo(()=>v?i[v]??[]:[],[i,v]),b=Q.useMemo(()=>{if(!v||!f)return!1;let e=i[v]??[];for(let t of e)for(let e of t.sessionIds)if(p.has(e))return!0;return!1},[i,v,f,p]),x=Q.useCallback(e=>{!v||!f||a(v,e,Array.from(p))},[a,p,v,f]),S=Q.useCallback(()=>{if(!v||!f)return;let e=s(v);e&&a(v,e.id,Array.from(p))},[a,s,p,v,f]),C=Q.useCallback(()=>{!v||!f||o(v,Array.from(p))},[o,p,v,f]),w=Q.useCallback(async()=>{let e=Array.from(p);if(e.length!==0){if(_)vl({sessionIds:e,message:e.length===1?t(`sessions.sidebar.bulkActions.deletedSingle`,{count:e.length}):t(`sessions.sidebar.bulkActions.deletedPlural`,{count:e.length}),undoLabel:t(`sessions.sidebar.undo`),commitFailedMessage:e.length===1?t(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:e.length}):t(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:e.length})});else{let{archivedIds:n,failedIds:r}=await c(e);n.length>0&&Cl({sessionIds:n,message:n.length===1?t(`sessions.sidebar.bulkActions.archivedSingle`,{count:n.length}):t(`sessions.sidebar.bulkActions.archivedPlural`,{count:n.length}),undoLabel:t(`sessions.sidebar.undo`),settingsLabel:t(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:n.length===1?t(`sessions.sidebar.session.archive.undoFailed`):t(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:n.length})}),r.length>0&&X.error(r.length===1?t(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:r.length}):t(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:r.length}))}Hb.getState().clear()}},[c,_,p,t]),T=Q.useCallback(()=>{if(!f)return;let e=p.size;if(!_||!r){w();return}l({sessionCount:e,archivedBucket:_})},[_,w,p,r,l,f]),E=Q.useCallback(async()=>{l(null),await w()},[w]);return Q.useEffect(()=>{if(!u)return;let e=typeof navigator<`u`&&/Macintosh|Mac OS X/.test(navigator.userAgent||``),t=t=>{if(n)return;let r=t.target;if(r&&(r.tagName===`INPUT`||r.tagName===`TEXTAREA`||r.isContentEditable))return;let i=e?t.metaKey:t.ctrlKey;if(t.key===`Escape`){t.preventDefault(),Hb.getState().disable();return}if(i&&t.key===`Backspace`){t.preventDefault(),T();return}if(i&&(t.key===`a`||t.key===`A`)){let e=typeof document<`u`?Array.from(document.querySelectorAll(`[data-session-row]`)):[];if(e.length===0)return;t.preventDefault();let n=Hb.getState().scopeKey??e[0]?.getAttribute(`data-session-scope`)??null,r=e.filter(e=>!n||e.getAttribute(`data-session-scope`)===n).map(e=>e.getAttribute(`data-session-row`)).filter(e=>typeof e==`string`&&e.length>0);if(r.length===0)return;Hb.getState().replaceAll(r,n||null)}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[T,n,u]),{selectionModeEnabled:u,hasSelection:f,selectedIdsSize:d,bulkScopeIsArchived:_,derivedSelectionScope:v,bulkScopeFolders:y,bulkCanRemoveFromFolder:b,handleToggleSelectionMode:h,handleExitSelectionMode:g,handleBulkMoveToFolder:x,handleBulkCreateFolderAndMove:S,handleBulkRemoveFromFolder:C,handleBulkDelete:T,confirmBulkDelete:E}},eS=[{id:`tasks`,icon:`list-check-2`,labelKey:`sessions.sidebar.view.tasks`},{id:`projects`,icon:`folder-tree`,labelKey:`sessions.sidebar.projectsTitle`}],tS=Q.memo(function(e){let t=(0,ju.c)(9),{value:n,onChange:r}=e,{t:i}=Nr(),a;t[0]===i?a=t[1]:(a=i(`sessions.sidebar.view.aria`),t[0]=i,t[1]=a);let o;t[2]!==r||t[3]!==i||t[4]!==n?(o=eS.map(e=>{let t=n===e.id,a=i(e.labelKey);return(0,$.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,"aria-label":a,title:a,onClick:()=>r(e.id),className:Y(`relative flex h-6 items-center rounded-full text-[12px] font-medium leading-none`,`pl-1.5 transition-[background-color,color,box-shadow,padding] duration-200 ease-out motion-reduce:transition-none`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,t?`bg-background pr-2.5 text-foreground shadow-sm`:`pr-1.5 text-muted-foreground hover:text-foreground`),children:[(0,$.jsx)(Z,{name:e.icon,className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{"aria-hidden":!t,className:Y(`grid transition-[grid-template-columns,margin,opacity] duration-200 ease-out motion-reduce:transition-none`,t?`ml-1.5 grid-cols-[1fr] opacity-100`:`ml-0 grid-cols-[0fr] opacity-0`),children:(0,$.jsx)(`span`,{className:`min-w-0 overflow-hidden whitespace-nowrap`,children:a})})]},e.id)}),t[2]=r,t[3]=i,t[4]=n,t[5]=o):o=t[5];let s;return t[6]!==a||t[7]!==o?(s=(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":a,className:`-ml-2 inline-flex h-7 items-center rounded-full bg-[color-mix(in_srgb,var(--surface-foreground)_7%,transparent)] p-0.5`,children:o}),t[6]=a,t[7]=o,t[8]=s):s=t[8],s}),nS=e=>{let t=(0,ju.c)(2),{count:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`span`,{className:`text-[12px] tabular-nums text-muted-foreground/70`,children:n}),t[0]=n,t[1]=r),r};function rS(e){let t=(0,ju.c)(20),{items:n,renderTaskRow:r,onSessionsReordered:i}=e,{t:a}=Nr(),o;t[0]===n.active?o=t[1]:(o=n.active.map(aS),t[0]=n.active,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c=new Map(s.map(iS)),t[2]=s,t[3]=c);let l=c;if(n.active.length===0){let e;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Uc,{className:`size-20`}),t[4]=e):e=t[4];let n;t[5]===a?n=t[6]:(n=a(`sessions.sidebar.task.empty`),t[5]=a,t[6]=n);let r;return t[7]===n?r=t[8]:(r=(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-1 pt-6 pb-2`,children:[e,(0,$.jsx)(`div`,{className:`${Eo} !text-center`,children:n})]}),t[7]=n,t[8]=r),r}let u;t[9]!==n.active||t[10]!==r?(u=n.active.map(r),t[9]=n.active,t[10]=r,t[11]=u):u=t[11];let d=u,f;t[12]!==l||t[13]!==n.active.length||t[14]!==i||t[15]!==d||t[16]!==s?(f=i&&n.active.length>1?(0,$.jsx)(Bc,{scopeKey:`task-active`,sessionIds:s,folderIdBySessionId:l,onSessionDroppedOnFolder:oS,onSessionsReordered:i,children:d}):d,t[12]=l,t[13]=n.active.length,t[14]=i,t[15]=d,t[16]=s,t[17]=f):f=t[17];let p;return t[18]===f?p=t[19]:(p=(0,$.jsx)(`div`,{className:`-ml-1 -mr-1 space-y-0.5`,children:f}),t[18]=f,t[19]=p),p}function iS(e){return[e,null]}function aS(e){return e.node.session.id}var oS=()=>{};function sS(e){let t=(0,ju.c)(21),{items:n,open:r,onToggle:i,onShowMore:a,renderTaskRow:o}=e,{t:s}=Nr();if(n.settledTotal===0)return null;let c=n.settledTotal-n.settled.length,l=Math.min(30,c),u;t[0]===s?u=t[1]:(u=s(`sessions.sidebar.task.shelf.settled`),t[0]=s,t[1]=u);let d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(Z,{name:`archive`,className:`-ml-1 mr-0.5 size-3.5 shrink-0 text-foreground/55`}),t[2]=d):d=t[2];let f;t[3]===n.settledTotal?f=t[4]:(f=(0,$.jsx)(nS,{count:n.settledTotal}),t[3]=n.settledTotal,t[4]=f);let p;t[5]!==i||t[6]!==r||t[7]!==u||t[8]!==f?(p=(0,$.jsx)(by,{title:u,onToggle:i,expanded:r,className:`pt-2 pb-1`,leadingIcon:d,accessory:f}),t[5]=i,t[6]=r,t[7]=u,t[8]=f,t[9]=p):p=t[9];let m;t[10]!==n.settled||t[11]!==l||t[12]!==a||t[13]!==r||t[14]!==c||t[15]!==o||t[16]!==s?(m=r?(0,$.jsxs)(`div`,{className:`-ml-1 -mr-2 max-h-[40vh] space-y-px overflow-y-auto overscroll-contain`,children:[n.settled.map(o),c>0?(0,$.jsxs)(`button`,{type:`button`,onClick:a,className:`box-border flex w-full items-center gap-[3px] rounded-md px-2 py-1.5 text-left typography-meta text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:[(0,$.jsx)(Z,{name:`arrow-down-s`,className:`-ml-0.5 size-4 shrink-0`}),s(l===1?`sessions.sidebar.group.showMoreSingle`:`sessions.sidebar.group.showMorePlural`,{count:l})]}):null]}):null,t[10]=n.settled,t[11]=l,t[12]=a,t[13]=r,t[14]=c,t[15]=o,t[16]=s,t[17]=m):m=t[17];let h;return t[18]!==p||t[19]!==m?(h=(0,$.jsxs)(`div`,{className:`shrink-0 px-3 pb-1`,children:[p,m]}),t[18]=p,t[19]=m,t[20]=h):h=t[20],h}var cS={ids:[],baseline:{}},lS=(e,t)=>e!==void 0&&t!==void 0&&e.activityAt===t.activityAt&&e.running===t.running&&e.attention===t.attention,uS=(e,t,n,r)=>{if(r.ids.length===0)return e;let i=new Map;for(let n of e)i.set(t(n),n);let a=[],o=new Set;for(let e of r.ids){let t=i.get(e);!t||o.has(e)||!lS(r.baseline[e],n(t))||(a.push(t),o.add(e))}if(a.length<2)return e;let s=0,c=e.map(e=>o.has(t(e))?a[s++]:e);return c.every((t,n)=>t===e[n])?e:c},dS=(e,t,n,r)=>{let i=e.indexOf(t),a=e.indexOf(n);if(i<0||a<0||i===a)return null;let o=[...e];o.splice(i,1),o.splice(a,0,t);let s={};for(let e of o){let t=r(e);t&&(s[e]=t)}return{ids:o,baseline:s}},fS=(e,t,n)=>{let r=[],i=new Set,a=e=>{let t=ft(e??null);!t||i.has(t)||(i.add(t),r.push(t))};if(a(e),a(n?.workspaceRoot),a(n?.currentDirectory),n?.includeWorktrees!==!1)for(let e of t)a(e.path);return r},pS=(e,t,n,r)=>{let i=e.filter(e=>e.sessionId===t);if(i.length===0)return null;if(n){let e=i.find(e=>e.projectId===n);if(e)return e}if(r){let e=i.find(e=>e.projectId===r);if(e)return e}return i[0]??null},mS=({currentSessionId:e,focus:t,pinnedFocuses:n,projectFocuses:r,fallbackProjectId:i})=>{if(!e)return null;let a=t?.sessionId===e,o=a?t.projectId:null,s=pS(r,e,o,i)??{scope:`project`,sessionId:e,projectId:i};return!a||t.scope===`project`?s:pS(n,e,o,i)??s};function hS(e,t,n=null){if(!e||e.scope!==`project`||!e.sessionId)return null;if(e.projectId){let n=t.find(t=>t.sessionId===e.sessionId&&t.projectId===e.projectId);if(n)return n}if(n){let r=t.find(t=>t.sessionId===e.sessionId&&t.projectId===n);if(r)return r}return t.find(t=>t.sessionId===e.sessionId)??null}var gS=`yuri.sessions.sidebarView`,_S=`yuri.sessions.projectCollapse`,vS=`yuri.sessions.groupOrder`,yS=`yuri.sessions.groupCollapse`,bS=`yuri.sessions.activeSessionByProject`,xS=`yuri.sessions.expandedParents.v2`,SS=`yuri.sessions.expandedParents`,CS=st(He()),wS=e=>{try{let t=CS.getItem(e);if(!t)return new Set;let n=JSON.parse(t);return new Set(Array.isArray(n)?n.filter(e=>typeof e==`string`):[])}catch{return new Set}},TS=e=>{try{let t=CS.getItem(e);if(!t)return new Map;let n=JSON.parse(t),r=new Map;return!n||typeof n!=`object`||Array.isArray(n)||Object.entries(n).forEach(([e,t])=>{typeof t==`string`&&t.length>0&&r.set(e,t)}),r}catch{return new Map}},ES=e=>{try{let t=CS.getItem(e);if(!t)return new Map;let n=JSON.parse(t),r=new Map;return!n||typeof n!=`object`||Array.isArray(n)||Object.entries(n).forEach(([e,t])=>{Array.isArray(t)&&r.set(e,t.filter(e=>typeof e==`string`))}),r}catch{return new Map}},DS=(e,t,n)=>{let r=new Set;for(let t of e){let e=ft(t.path)?.toLowerCase();e&&r.add(e)}if(n?.includeWorktrees===!1)return r;for(let e of t.values())for(let t of e){let e=ft(t.path)?.toLowerCase();e&&r.add(e)}return r},OS=(e,t,n)=>{if(e.time?.archived)return!0;let r=ft(gn(e))?.toLowerCase();return r?t.size===0?n?.allowEmptyDirectorySet??!0:t.has(r):n?.allowUnknownDirectory??!0},kS=new Set,AS=[],jS={},MS=(e,t)=>{let n=Q.useRef(e);return n.current=e,Q.useMemo(()=>(...e)=>n.current(...e),[t])},NS=Q.memo(function(e){let t=(0,ju.c)(3),{onOpenChange:n}=e,r=Dl(fe(FS)),i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(Ml,{open:!0,onOpenChange:n,...r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}),PS=Q.memo(function({mobileVariant:e=!1,onSessionSelected:t,allowReselect:n=!1,hideDirectoryControls:r=!1,showOnlyMainWorkspace:i=!1,isVisible:a=!0}){let{t:o}=Nr(),[s,l]=Q.useState(!1),[u,d]=Q.useState(!1),[f,p]=Q.useState(``),h=Q.useRef(null),g=Q.useRef(null),[_,v]=Q.useState(null),[y,b]=Q.useState(``),[x,S]=Q.useState(null),[w,T]=Q.useState(new Set),E=Q.useMemo(()=>CS,[]),[D,O]=Q.useState(new Set),[k,A]=Q.useState(new Map),[j,M]=Q.useState(new Map),N=q(e=>e.isNewWorktreeDialogOpen),P=q(e=>e.setNewWorktreeDialogOpen),[F,I]=Q.useState(null),[L,R]=Q.useState(null),[z,ee]=Q.useState(``),[B,V]=Q.useState(null),[te,ne]=Q.useState(null),[re,ie]=Q.useState(null),H=$t(),U=wn(),oe=nl(),W=Xc(),se=pl(),ce=In(),le=q(e=>e.sidebarView),ue=q(e=>e.setSidebarView);Q.useEffect(()=>{let e=He().getItem(gS);e!==null&&(He().removeItem(gS),q.getState().sidebarView===`projects`&&vc(e)!==`projects`&&ue(vc(e)))},[ue]);let[de,fe]=Q.useState({settledOpen:!1,settledLimit:30}),pe=Q.useRef(new Map),me=Q.useRef(new Map),he=K(e=>{ue(e),Ne({sidebarView:e})}),[ge,_e]=Q.useState(()=>wS(yS)),[ve,ye]=Q.useState(()=>ES(vS)),[be,xe]=Q.useState(()=>TS(bS)),Se=Q.useRef(null);Q.useEffect(()=>c(e=>{m(e)&&(Se.current=null,_e(wS(yS)),ye(ES(vS)),xe(TS(bS)),O(wS(_S)),T(wS(xS)))}),[]);let[Ce,we]=Q.useState(new Map),Te=Q.useRef(0),Ee=G(e=>e.homeDirectory),De=G(e=>e.currentDirectory),Oe=G(e=>e.setDirectory),ke=un(e=>e.projects),Ae=Q.useMemo(()=>ke.filter(e=>!e.hostId),[ke]),je=Q.useMemo(()=>ke.filter(e=>e.hostId).map(Er),[ke]),[Me,Pe]=Q.useState(()=>new Map),Fe=K((e,t)=>{Pe(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})}),Ie=Jc(a),[Le,Re]=Q.useState(new Map),ze=K((e,t)=>{Re(n=>JSON.stringify(n.get(e))===JSON.stringify(t)?n:new Map(n).set(e,t))}),Be=un(e=>e.activeProjectId),Ve=un(e=>e.removeProject),Ue=un(e=>e.setActiveProjectIdOnly),We=un(e=>e.updateProjectMeta),Ge=un(e=>e.reorderProjectsById),Ke=q(e=>e.setActiveMainTab),qe=q(e=>e.activeMainTab),Je=ja(),Ye=q(e=>e.setSettingsDialogOpen),Xe=q(e=>e.toggleHelpDialog),Ze=q(e=>e.setSessionSwitcherOpen),Qe=q(e=>e.setScheduledTasksDialogOpen),$e=q(e=>e.notifyOnSubtasks),et=q(e=>e.showDeletionDialog),tt=q(e=>e.setShowDeletionDialog),nt=Aa(f,120),rt=Q.useMemo(()=>nt.trim().toLowerCase(),[nt]),it=rt.length>0,at=Dl(e=>e.available&&(e.runtimeType===`desktop`||e.runtimeType===`web`)),ot=en(e=>e.collapsedFolderIds),st=en(e=>e.foldersMap),ct=en(e=>e.sessionOrderByScope),lt=en(e=>e.sessionOrderActivityByScope),ut=en(e=>e.getFoldersForScope),dt=en(e=>e.createFolder),pt=en(e=>e.renameFolder),mt=en(e=>e.deleteFolder),ht=en(e=>e.addSessionToFolder),gt=en(e=>e.addSessionsToFolder),_t=en(e=>e.removeSessionFromFolder),vt=en(e=>e.removeSessionsFromFolders),yt=en(e=>e.toggleFolderCollapse),bt=en(e=>e.getSessionFolderId),xt=en(e=>e.reorderSessions);sy({isSessionSearchOpen:a&&u,setIsSessionSearchOpen:d,sessionSearchInputRef:g,sessionSearchContainerRef:h});let St=Q.useMemo(()=>new Map,[]),wt=vn({enabled:a,includeChildren:!0}),Tt=yc({enabled:a}),Et=Lc({enabled:a}),Dt=cn(e=>a?e.index.session.unseenCount:jS),Ot=Q.useMemo(()=>ae(),[]),kt=pn(e=>e.status),At=pn(e=>e.activeSessions),jt=pn(e=>e.archivedSessions),Mt=pn(e=>e.loadingDirectories.size>0||e.refreshingDirectories.size>0),Nt=pn(e=>e.archivedLoadingDirectories),Pt=Q.useDeferredValue(At),Ft=Q.useDeferredValue(jt),It=Kn(e=>e.currentSessionId),Lt=sn(e=>e.remoteSession!==null)?null:It,Vt=uo(e=>e.focus),Ht=Q.useSyncExternalStore(Bt,Rt,Rt),Ut=Kn(e=>!!e.newSessionDraft?.open),Wt=Kn(e=>e.newSessionDraft?.open&&!e.currentSessionId?e.newSessionDraft.selectedProjectId??null:null),Gt=Q.useMemo(()=>!e&&qe===`chat`&&Wt&&Ht.sessionId===null?{projectId:Wt,revision:Ht.revision}:null,[e,qe,Wt,Ht]),Kt=Kn(e=>e.setCurrentSession),qt=Kn(e=>e.updateSessionTitle),Jt=Kn(e=>e.shareSession),Yt=Kn(e=>e.unshareSession),Xt=Kn(e=>e.worktreeMetadata),Zt=Kn(e=>e.availableWorktreesByProject),tn=Kn(e=>e.openNewSessionDraft),nn=K(t=>{let n=je.find(e=>e.id===(t?.selectedProjectId??un.getState().activeProjectId));if(n){uc(n,e).catch(e=>X.error(e instanceof Error?e.message:String(e)));return}sn.getState().clearRemoteSession(),tn(t),Ot&&window.dispatchEvent(new CustomEvent(`yuri:navigate`,{detail:{view:`chat`}}))}),rn=Q.useMemo(()=>DS(Ae,Zt,{includeWorktrees:!Ot}),[Zt,Ot,Ae]),on=Q.useMemo(()=>{let e=new Map(wt.map(e=>[e.id,e])),t=Pt.map(t=>{let n=e.get(t.id);return n?Qt(n,t):t}),n=new Set(t.map(e=>e.id));return wt.forEach(e=>{n.has(e.id)||t.push(e)}),t.filter(e=>OS(e,rn,{allowUnknownDirectory:!Ot,allowEmptyDirectorySet:!Ot}))},[Pt,Ot,rn,wt]),ln=Q.useMemo(()=>wt.map(e=>{let t=ft(e.directory??null)??``;return`${e.id}:${e.title??``}:${+!!e.time?.archived}:${t}`}).join(`|`),[wt]),dn=Q.useRef(wt);Q.useEffect(()=>{dn.current=wt},[ln,wt]);let fn=Q.useMemo(()=>new Map(wt.map(e=>[e.id,e])),[wt]);Q.useEffect(()=>{let e=null,t=Ct(t=>{t.type===`scheduled-task-ran`&&(e&&clearTimeout(e),e=setTimeout(()=>{let e=un.getState().projects.find(e=>e.id===t.projectId),n=ft(e?.path??null);if(!n)return;let r=[n];(Kn.getState().availableWorktreesByProject.get(n)??[]).forEach(e=>{let t=ft(e.path);t&&r.push(t)}),hn(r,dn.current)},500))});return()=>{e&&clearTimeout(e),t()}},[]);let mn=Q.useMemo(()=>C(),[]),yn=_u(e=>e.sidebarBrandName.trim().length>0),{isTablet:bn,isDesktop:xn}=fi(),Sn=e||bn,{buildGroupSearchText:Cn,filterSessionNodesForSearch:En,buildGroupedSessions:Dn}=Oc({homeDirectory:Ee,worktreeMetadata:Xt,pinnedSessionIds:H,gitBranches:St,isVSCode:Ot}),{scheduleCollapsedProjectsPersist:On,hasRestoredProjectCollapse:An}=my({isVSCode:Ot,safeStorage:E,keys:{sessionExpanded:xS,sessionExpandedLegacy:SS,projectCollapse:_S,groupOrder:vS,projectActiveSession:bS,groupCollapse:yS},groupOrderByProject:ve,activeSessionByProject:be,collapsedGroups:ge,setExpandedParents:T,setCollapsedProjects:O}),jn=Q.useMemo(()=>[...on].sort((e,t)=>bo(e,t,H)),[on,H]),Mn=Q.useMemo(()=>{let e=new Map;return jn.forEach(t=>{let n=t.parentID;if(!n)return;let r=e.get(n)??[];r.push(t),e.set(n,r)}),e.forEach(e=>e.sort((e,t)=>bo(e,t,H))),e},[jn,H]),Nn=(0,$.jsxs)(`div`,{className:`py-6 text-center text-muted-foreground`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold`,children:o(`sessions.sidebar.empty.noSessions.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1`,children:o(`sessions.sidebar.empty.noSessions.description`)})]}),Pn=Q.useMemo(()=>Ae.find(e=>e.id===x)??null,[Ae,x]),Ln=Q.useCallback(e=>{x&&We(x,{label:e.label,icon:e.icon,color:e.color,iconBackground:e.iconBackground,defaultModel:e.defaultModel??null})},[x,We]),Rn=Q.useCallback(()=>{P(!0)},[P]),zn=Q.useCallback((t,n)=>{if(Ke(`chat`),e&&Ze(!1),!n?.remote){if(n?.sessionId){Kt(n.sessionId,t);return}tn({directoryOverride:t,preserveDirectoryOverride:!0})}},[e,tn,Ke,Kt,Ze]),Bn=K(()=>{let e=Dl.getState();if(e.available&&e.info){l(!0);return}e.checkForUpdates().then(()=>{let{available:e,error:t}=Dl.getState();if(t){X.error(o(`sessions.sidebar.updateCheck.errorTitle`),{description:t});return}if(!e){X.success(o(`sessions.sidebar.updateCheck.latestVersion`));return}l(!0)})}),Vn=Q.useCallback(()=>{e&&Ze(!1),Ye(!0)},[e,Ze,Ye]),Hn=K(()=>{let t=je.find(e=>e.id===un.getState().activeProjectId);if(t){uc(t,e).catch(e=>X.error(e instanceof Error?e.message:String(e)));return}sn.getState().clearRemoteSession(),Ke(`chat`),tn(),e&&Ze(!1)}),Un=Q.useCallback(()=>{if(!e){Ke(`schedule`);return}Qe(!0),Ze(!1)},[e,Ke,Qe,Ze]),Gn=Q.useCallback(()=>{Hr(),e&&Ze(!1)},[e,Ze]),qn=Kn(e=>e.archiveSession),Jn=Kn(e=>e.archiveSessions),{copiedSessionId:Yn,handleSessionSelect:Xn,handleSessionDoubleClick:Qn,handleSaveEdit:$n,handleCancelEdit:er,handleShareSession:tr,handleCopyShareUrl:nr,handleUnshareSession:rr,handleDeleteSession:ir,confirmDeleteSession:ar}=cy({activeProjectId:Be,currentDirectory:De,currentSessionId:Lt,mobileVariant:e,allowReselect:n,onSessionSelected:t,isSessionSearchOpen:u,sessionSearchQuery:f,setSessionSearchQuery:p,setIsSessionSearchOpen:d,setActiveProjectIdOnly:Ue,setDirectory:Oe,setActiveMainTab:Ke,setSessionSwitcherOpen:Ze,setCurrentSession:Kt,updateSessionTitle:qt,shareSession:Jt,unshareSession:Yt,archiveSession:qn,archiveSessions:Jn,childrenMap:Mn,showDeletionDialog:et,setDeleteSessionConfirm:V,deleteSessionConfirm:B,setEditingId:v,setEditTitle:b,editingId:_,editTitle:y}),cr=Q.useCallback((e,t,n,r=`project`)=>{sn.getState().clearRemoteSession();let i={sessionId:e,scope:r,projectId:n??null};if(e===Lt){zt(e),Mx(i),Xn(e,t,n);return}Ax(i,()=>Xn(e,t,n))},[Xn,Lt]);Q.useEffect(()=>()=>{kx()},[]);let lr=Q.useCallback(()=>{if(!te)return;let{scopeKey:e,folderId:t}=te;ne(null),mt(e,t)},[te,mt]);Q.useEffect(()=>{if(!Lt)return;let e=on.find(e=>e.id===Lt)?.parentID;if(!e)return;let t=[`project:active:${e}`,`project:archived:${e}`,`recent:active:${e}`,`recent:archived:${e}`];T(e=>{if(t.every(t=>e.has(t)))return e;let n=new Set(e);t.forEach(e=>n.add(e));try{E.setItem(xS,JSON.stringify(Array.from(n)))}catch{}return n})},[Lt,on,E]);let ur=Q.useCallback(e=>{T(t=>{let n=new Set(t);n.has(e)?n.delete(e):n.add(e);try{E.setItem(xS,JSON.stringify(Array.from(n)))}catch{}return n})},[E]),dr=Q.useCallback((e,t)=>{if(!e)return null;t&&ot.has(t)&&yt(t);let n=dt(e,o(`sessions.sidebar.folder.newFolderName`),t);return R(n.id),ee(n.name),n},[ot,yt,dt,o]),fr=K(cr),pr=K(Qn),mr=K($n),hr=K(er),gr=K(tr),_r=K(nr),vr=K(rr),yr=K(ir),br=K(dr),xr=K((e,t,n,r)=>{let i=_c(),a=Math.max(i,n)+7;if(M(e=>{let r=Math.max(i,e.get(t)??i,n),a=new Map(e);return a.set(t,r+7),a}),e.isArchivedBucket||a<r)return;let o=ft(e.directory??null);if(!o)return;let s=pn.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&_n(o)}),Sr=K(e=>{M(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})}),Cr=K(e=>{M(t=>{let n=!1,r=new Map(t),i=`${e}:`;for(let e of r.keys())e.startsWith(i)&&(r.delete(e),n=!0);return n?r:t})}),wr=Q.useMemo(()=>e=>{let t=Ae.find(t=>t.id===e),n=ft(t?.path??null);if(!n)return[];let r=[n];return Ot||(Zt.get(n)??[]).forEach(e=>{let t=ft(e.path);t&&r.push(t)}),r},[Zt,Ot,Ae]),Tr=K(e=>{let t=wr(e);if(t.length===0)return;let n=pn.getState().loadedDirectories,r=t.filter(e=>!n.has(e));r.length!==0&&hn(r,dn.current)}),Dr=K(e=>{let t=Ae.find(t=>t.id===e);t&&(async()=>{let e=[];if(!Ot)try{e=(await zs({id:t.id,path:t.path})).worktrees}catch(n){console.warn(`[SessionSidebar] Worktree refresh before session sync failed:`,n);let r=ft(t.path);e=r?Kn.getState().availableWorktreesByProject.get(r)??[]:[]}let n=fS(t.path,e,{currentDirectory:De,workspaceRoot:t.path,includeWorktrees:!Ot});n.length!==0&&await an(n,dn.current)})()});Q.useEffect(()=>{if(!An)return;let e=pn.getState(),t=Ae.flatMap(t=>D.has(t.id)?[]:wr(t.id).filter(t=>!e.loadedDirectories.has(t)&&!e.loadingDirectories.has(t)&&!e.refreshingDirectories.has(t)));t.length>0&&hn(t,dn.current)},[D,wr,An,Ae]);let Or=K(()=>{Te.current=Date.now()+150,M(new Map),O(()=>{let e=new Set(Ae.map(e=>e.id));try{E.setItem(_S,JSON.stringify(Array.from(e)))}catch{}return Ot||On(e),e})}),kr=K(()=>{Te.current=Date.now()+150,M(new Map),O(()=>{let e=new Set;try{E.setItem(_S,JSON.stringify([]))}catch{}return Ot||On(e),e});let e=pn.getState().loadedDirectories,t=Ae.flatMap(t=>wr(t.id).filter(t=>!e.has(t)));t.length>0&&hn(t,dn.current)}),Ar=K(e=>{Te.current=Date.now()+150,Cr(e),O(t=>{let n=new Set(t);n.has(e)?(n.delete(e),queueMicrotask(()=>Tr(e))):n.add(e);try{E.setItem(_S,JSON.stringify(Array.from(n)))}catch{}return Ot||On(n),n})}),jr=K(e=>{Te.current=Date.now()+150,Tr(e),O(t=>{if(!t.has(e))return t;let n=new Set(t);n.delete(e);try{E.setItem(_S,JSON.stringify(Array.from(n)))}catch{}return Ot||On(n),n})}),Mr=Q.useMemo(()=>Ae.map(e=>({...e,normalizedPath:ft(e.path)})).filter(e=>!!e.normalizedPath),[Ae]),Pr=Q.useMemo(()=>new Map(Mr.map(e=>[e.id,Fn(e.normalizedPath)||e.normalizedPath])),[Mr]),Fr=Q.useMemo(()=>Mr.map(e=>e.normalizedPath),[Mr]),Ir=Q.useMemo(()=>{let e=new Set(Mr.map(e=>e.normalizedPath));if(!Ot)for(let t of Zt.values())for(let n of t){let t=ft(n.path);t&&e.add(t)}return[...e].sort()},[Zt,Ot,Mr]),Lr=Q.useRef(null);Q.useEffect(()=>{let e=new Set(Ir),t=Lr.current;if(Lr.current=e,!t)return;let n=Ir.filter(e=>!t.has(e));if(n.length===0)return;let r=pn.getState().loadedDirectories,i=ft(De),a=Mr.find(e=>e.id===Be)??Mr.find(e=>e.normalizedPath===i)??null,o=new Set;i&&o.add(i),a?.normalizedPath&&(o.add(a.normalizedPath),Ot||(Zt.get(a.normalizedPath)??[]).forEach(e=>{let t=ft(e.path);t&&o.add(t)}));let s=n.filter(e=>o.has(e)&&!r.has(e));s.length!==0&&hn(s,dn.current)},[Be,Zt,De,Ot,Mr,Ir]);let Rr=Xi(a?Fr:AS);gy({normalizedProjects:Mr,activeProjectId:Be,gitRepoStatus:Rr,setProjectRepoStatus:A,setProjectRootBranches:we,enabled:a});let zr=Q.useMemo(()=>Pl(on,Mr,Zt,Ot,Ft),[Ft,Zt,Ot,Mr,on]),{getSessionsForProject:Br,getArchivedSessionsForProject:Vr}=_y({ownership:zr}),Ur=Mt||kt===`idle`||kt===`loading`,Wr=Q.useRef(!1);Be&&k.has(Be)&&(Wr.current=!!k.get(Be));let Gr=Tn(e=>e.projectSortOrder),Kr=Q.useMemo(()=>tl(Mr,Gr),[Mr,Gr]),{projectSections:qr,groupSearchDataByGroup:Jr,sectionsForRender:Yr,searchMatchCount:Xr}=iy({normalizedProjects:Kr,getSessionsForProject:Br,getArchivedSessionsForProject:Vr,availableWorktreesByProject:Zt,projectRepoStatus:k,projectRootBranches:Ce,lastRepoStatus:Wr.current,buildGroupedSessions:Dn,hasSessionSearchQuery:it,normalizedSessionSearchQuery:rt,filterSessionNodesForSearch:En,buildGroupSearchText:Cn,foldersMap:st}),Zr=(0,$.jsxs)(`div`,{className:`py-6 text-center text-muted-foreground`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold`,children:o(`sessions.sidebar.empty.noMatches.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1`,children:o(`sessions.sidebar.empty.noMatches.description`)})]});ay({projectSections:qr,activeProjectId:Be,activeSessionByProject:be,setActiveSessionByProject:xe,currentSessionId:Lt,handleSessionSelect:Xn,newSessionDraftOpen:Ut,mobileVariant:e,openNewSessionDraft:tn,setActiveMainTab:Ke,setSessionSwitcherOpen:Ze});let{getOrderedGroups:Qr}=oy(ve),$r=Q.useRef(!1);Q.useEffect(()=>{if($r.current||qr.length===0)return;let e=qr.flatMap(e=>e.groups.filter(e=>e.isArchivedBucket).map(t=>`${e.project.id}:${t.id}`));e.length>0&&_e(t=>new Set([...t,...e])),$r.current=!0},[qr]);let ei=Q.useMemo(()=>{let e=new Map,t=new Map;return qr.forEach(n=>{let r=Fn(n.project.normalizedPath)||n.project.normalizedPath;n.groups.forEach(i=>{let a=i.branch&&i.branch!==`HEAD`&&i.branch!==r?i.branch:null,o={projectLabel:r,branchLabel:a},s=r=>{r.forEach(r=>{let a=n.project.normalizedPath.length;a<(t.get(r.session.id)??-1)||(e.set(r.session.id,{node:r,projectId:n.project.id,groupDirectory:i.directory,secondaryMeta:o}),t.set(r.session.id,a),r.children.length>0&&s(r.children))})};s(i.sessions)})}),e},[qr]);Q.useLayoutEffect(()=>{if(!Lt){Mx(null);return}let e=uo.getState().focus;if(e?.sessionId===Lt){e.scope===`project`&&!e.projectId&&Mx({...e,projectId:ei.get(Lt)?.projectId??null});return}Mx({scope:`project`,sessionId:Lt,projectId:ei.get(Lt)?.projectId??null})},[Lt,ei]);let ti=Q.useMemo(()=>Ot?[]:Ac(on,H,ct[Ec]),[Ot,H,on,ct]),ni=K((e,t)=>{_||xt(Ec,si.map(e=>e.node.session.id),e,t,{}).catch(()=>X.error(o(`sessions.order.saveFailed`)))}),ri=Q.useMemo(()=>it?[]:Vc(on,H,Et,Dt),[it,H,Et,on,Dt]),{pinnedItems:ii,inProgressItems:ai}=Q.useMemo(()=>{let e=e=>{let t=ei.get(e.id),n=ft(e.directory??null),r={session:e,children:[],worktree:Xt.get(e.id)??null};if(it&&En([r],rt).length===0)return null;let i=zr.bySessionId.get(e.id),a=i?Kr.find(e=>e.id===i.projectId):void 0,o=a?Fn(a.normalizedPath)||a.normalizedPath:t?.secondaryMeta?.projectLabel??null,s=hc({projectLabel:o,owner:i,sessionWorktree:Xt.get(e.id)??null,worktrees:a?Zt.get(a.normalizedPath)??[]:[],projectRootBranch:i?Ce.get(i.projectId)??(a?Rr.get(a.normalizedPath)?.branch:null)??null:null,isVSCode:Ot})??t?.secondaryMeta??null;return{node:r,projectId:i?.projectId??t?.projectId??null,groupDirectory:i?.scopeDirectory??t?.groupDirectory??n,secondaryMeta:s}},t=t=>t.map(e).filter(e=>e!==null);return{pinnedItems:Ot?[]:t(ti),inProgressItems:t(ri)}},[Zt,En,Rr,it,ri,Ot,rt,ti,Ce,zr,ei,Kr,Xt]),oi=Q.useMemo(()=>je.flatMap(e=>Me.get(e.id)??[]),[je,Me]),si=Q.useMemo(()=>wl([...ii,...oi.filter(e=>e.pinned)],e=>e.node.session.id,ct[Ec]),[ii,oi,ct]),ci=Q.useMemo(()=>[...ai,...oi.filter(e=>!e.pinned)].sort((e,t)=>kn(t.node.session)-kn(e.node.session)),[ai,oi]),li=!e&&!Ot&&!r&&!i,ui=li&&le===`tasks`&&!it,di=bl(Et,a&&li),[pi,mi]=Q.useState(cS),hi=Q.useMemo(()=>ui?yl({sessions:on,pinnedSessionIds:H,settledSessionIds:oe,indexedSessionIds:W?.indexedIds??null,settledAtBySessionId:W?.settledAtById,runningSessionIds:Et,pendingRequestSessionIds:ce,unseenBySession:Dt}):null,[ce,H,Et,on,oe,W,ui,Dt]),gi=Q.useMemo(()=>{let e=hi?.settled.filter(e=>!oe.has(e.id));return e?.length?new Set([...oe,...e.map(e=>e.id)]):oe},[hi,oe]),_i=K(e=>({activityAt:kn(e),running:Et.has(e.id),attention:Ic(e.id,ce,Dt)})),vi=Q.useMemo(()=>{if(!hi)return null;let e=uS(hi.active,e=>e.id,_i,pi);return e===hi.active?hi:{...hi,active:e}},[hi,_i,pi]),yi=K((e,t)=>{if(_||!vi)return;let n=new Map(vi.active.map(e=>[e.id,e])),r=dS(vi.active.map(e=>e.id),e,t,e=>{let t=n.get(e);return t?_i(t):void 0});r&&mi(r)}),bi=K((e,t,n)=>{if(!ui||qe!==`chat`||Lt!==e||Rt()!==n)return;let r=[...ti,...vi?.active??[]].filter(t=>t.id!==e),i=r.find(e=>e.id===t)??r[0];if(!i){kx(),Mx(null),tn();return}let a=zr.bySessionId.get(i.id);cr(i.id,a?.scopeDirectory??ft(i.directory??null),a?.projectId??null,H.has(i.id)?`pinned`:`project`)}),xi=K((e,t)=>{if(!t&&hi?.settled.some(t=>t.id===e&&t.time?.archived)){Wn(e);return}if(!t||!ui||Lt!==e){se(e,t);return}let n=[...ti,...vi?.active??[]],r=n.findIndex(t=>t.id===e),i=n[r+1]??n[r-1],a=Rt();se(e,!0,{onSuccess:()=>bi(e,i?.id??null,a)})}),Si=li?xi:void 0,Ci=Q.useMemo(()=>{if(!vi)return null;let e=o(`sessions.sidebar.task.unassigned`),t=new Map(Kr.map(e=>[e.id,Fn(e.normalizedPath)||e.normalizedPath])),n=me.current,r=new Map(Kr.map(e=>[e.id,e.normalizedPath])),i=new Map;for(let e of Kr){let t=n.get(e.id),r=t&&t.icon===e.icon&&t.color===e.color&&t.iconImage?.mime===e.iconImage?.mime&&t.iconImage?.updatedAt===e.iconImage?.updatedAt&&t.iconImage?.source===e.iconImage?.source?t:{id:e.id,icon:e.icon,color:e.color,iconImage:e.iconImage};n.set(e.id,r),i.set(e.id,r)}let a=pe.current,s=new Map,c=n=>o=>{let c=zr.bySessionId.get(o.id),l=ei.get(o.id),u=c?.projectId??l?.projectId??null,d=c?.scopeDirectory??l?.groupDirectory??ft(o.directory??null),f=c?i.get(c.projectId)??null:null,p=c&&t.get(c.projectId)||e,m=c?r.get(c.projectId)??null:null,h=m?Rr.get(m):void 0,g=Xt.get(o.id)??null,_=(l?.secondaryMeta?.branchLabel??(c?Ce.get(c.projectId):null)??h?.branch??g?.branch??null)?.trim()||null,v=_&&_!==`HEAD`&&_!==p?_:null,y=v?null:!m||h?.isGitRepo===!1?`no-git`:`loading`,b=y===`no-git`&&m?or(m,Ee):null,x=g,S=n?di.get(o.id)??null:null,C=a.get(o.id);if(C&&C.session===o&&C.card===n&&C.projectId===u&&C.groupDirectory===d&&C.projectLabel===p&&C.branchLabel===v&&C.branchState===y&&C.pathLabel===b&&C.worktree===x&&C.project===f&&C.runStartedAt===S)return s.set(o.id,C),C.item;let w={node:{session:o,children:[],worktree:x},projectId:u,groupDirectory:d,secondaryMeta:{projectLabel:p,branchLabel:v,branchState:y,pathLabel:b,card:n,slim:!n,project:f,runStartedAt:S}};return s.set(o.id,{session:o,card:n,projectId:u,groupDirectory:d,projectLabel:p,branchLabel:v,branchState:y,pathLabel:b,worktree:x,project:f,runStartedAt:S,item:w}),w},l=de.settledOpen?vi.settled.slice(0,de.settledLimit):[],u={pinned:ti.map(c(!0)),active:vi.active.map(c(!0)),settled:l.map(c(!1)),settledTotal:vi.settled.length};return pe.current=s,u},[Rr,Ee,ti,Ce,di,zr,ei,Kr,o,vi,de.settledLimit,de.settledOpen,Xt]),wi=Q.useMemo(()=>{if(!Ci)return si;let e=new Map(Ci.pinned.map(e=>[e.node.session.id,e]));return si.map(t=>e.get(t.node.session.id)??t)},[si,Ci]),Ti=Q.useMemo(()=>{if(!vi||!Ci)return[];let e=new Map([...Ci.active,...Ci.settled].map(e=>[e.node.session.id,e]));return bc(vi,de).flatMap((t,n)=>{let r=e.get(t.id);return r?[{scope:`project`,sessionId:t.id,projectId:r.projectId,directory:ft(gn(t))??r.groupDirectory??null,visibleIndex:n}]:[]})},[vi,Ci,de]),Ei=Q.useMemo(()=>Yr.map(e=>({...e,groups:e.groups.filter(e=>!e.isArchivedBucket)})),[Yr]),Di=Q.useMemo(()=>{let e=it?Ei.map(e=>({...e,groups:e.groups.map(e=>({...e,sessions:Jr.get(e)?.filteredNodes??[]}))})):Ei;if(!i)return e;let t=e.find(e=>e.project.id===Be)??e[0];if(!t)return[];let n=t.groups.find(e=>e.isMain&&e.sessions.length>0)??t.groups.find(e=>e.sessions.length>0)??t.groups.find(e=>e.isMain)??t.groups[0];return n?[{...t,groups:[n]}]:[]},[Be,Jr,it,Ei,i]),Oi=Q.useMemo(()=>xl({sections:Di,foldersMap:st,getOrderedGroups:Qr,pinnedSessionIds:H,sessionOrderByScope:ct,sessionOrderActivityByScope:lt}),[st,Qr,Di,H,lt,ct]),ki=Q.useMemo(()=>Wc({targets:Oi,collapsedProjectIds:D,collapsedGroupKeys:ge,collapsedFolderIds:ot,visibleSessionCountByGroup:j,defaultVisibleSessionCount:_c(),hasSessionSearchQuery:it,alwaysVisibleSessionIds:Tt}),[Tt,ot,ge,D,it,Oi,j]),Ai=Q.useMemo(()=>it?[]:(ui?si:[...si,...ci]).map((e,t)=>{let n=e.node.session;return{scope:`pinned`,sessionId:n.id,projectId:e.projectId,directory:ft(gn(n))??e.groupDirectory??null,visibleIndex:t}}),[it,ci,si,ui]),[ji,Mi]=Q.useState(null),Ni=Q.useCallback(e=>{Mi(t=>t&&t.length===e.length&&t.every((t,n)=>t===e[n])?t:[...e])},[]),Pi=Q.useMemo(()=>{if(!ji)return Ai;let e=new Set(ji);return Ai.filter(t=>e.has(t.sessionId))},[Ai,ji]),Fi=Q.useMemo(()=>!a&&Se.current?Se.current:{pinned:Pi,project:ui?Ti:ki},[a,Ti,ui,Pi,ki]);Q.useLayoutEffect(()=>{a&&(Se.current=Fi)},[a,Fi]);let Ii=Q.useMemo(()=>e?[]:so({pinnedTargets:Fi.pinned,projectTargets:ui?Fi.project:ke.flatMap(e=>e.hostId?Le.get(e.id)??[]:Fi.project.filter(t=>t.projectId===e.id))}),[e,ui,Fi,ke,Le]),Li=Q.useCallback(t=>{let n=je.find(e=>e.id===t.projectId);if(n&&Ie.registry){let r=Me.get(n.id)?.find(e=>e.identity===t.sessionId);lc(n,Ie.registry,r?.remoteSessionId??t.sessionId,t.directory??n.path,e);return}Ke(`chat`),Ze(!1),t.scope===`project`&&t.projectId&&Ue(t.projectId),cr(t.sessionId,t.directory,t.projectId,t.scope)},[cr,Ke,Ue,Ze,je,Ie.registry,Me,e]);Q.useLayoutEffect(()=>ro({targets:Ii,activate:Li}),[Li,Ii]);let Ri=Q.useMemo(()=>{let e=new Map;return Ii.forEach(t=>{let n=Qa({scope:t.scope,sessionId:t.sessionId,projectId:t.projectId});n&&e.set(n,Ya(Ii,t)??0)}),e},[Ii]),zi=Q.useMemo(()=>{if(!Lt||it)return[];let e=[],t=(n,r)=>{if(n.session.id===Lt){e.push({scope:`pinned`,sessionId:Lt,projectId:r});return}n.children.forEach(e=>t(e,r))};return si.forEach(e=>t(e.node,e.projectId)),ai.forEach(e=>t(e.node,e.projectId)),e},[Lt,it,ai,si]),Bi=Q.useMemo(()=>{if(!Lt)return[];let e=[],t=(n,r)=>{if(n.session.id===Lt){e.push({scope:`project`,sessionId:Lt,projectId:r});return}n.children.forEach(e=>t(e,r))};return qr.forEach(e=>{e.groups.forEach(n=>{n.sessions.forEach(n=>t(n,e.project.id))})}),e},[Lt,qr]);Q.useLayoutEffect(()=>io({pinned:Fi.pinned,project:Fi.project}),[Fi]),Q.useLayoutEffect(()=>{!a||Ur||Mx(mS({currentSessionId:Lt,focus:Vt,pinnedFocuses:zi,projectFocuses:Bi,fallbackProjectId:Lt?ei.get(Lt)?.projectId??null:null}))},[Lt,a,Ur,Bi,zi,Vt,ei]);let Vi=Q.useMemo(()=>{let e=Vt?.sessionId?ei.get(Vt.sessionId)?.projectId??null:null;return hS(Vt,Oi,e)},[Oi,Vt,ei]),Hi=Q.useRef(null),Ui=Q.useRef(null);Q.useEffect(()=>{Ui.current&&Ui.current!==Lt&&(Ui.current=null)},[Lt]),Q.useLayoutEffect(()=>{if(!Vi?.projectId)return;let e=Vi.sessionId,t=Ht.sessionId===e;if(!(!t&&Lt!==e)){if(t){if(Hi.current===Ht.revision)return;Hi.current=Ht.revision,Ui.current=e}else{if(Ui.current===e)return;Ui.current=e}if(jr(Vi.projectId),Vi.groupKey&&_e(e=>{if(!e.has(Vi.groupKey))return e;let t=new Set(e);return t.delete(Vi.groupKey),t}),Vi.folderAncestorIds?.forEach(e=>{let t=en.getState();t.collapsedFolderIds.has(e)&&t.toggleFolderCollapse(e)}),Vi.groupKey&&Vi.visibleIndex!==void 0){let e=Vi.visibleIndex+1;M(t=>{if((t.get(Vi.groupKey)??0)>=e)return t;let n=new Map(t);return n.set(Vi.groupKey,e),n})}}},[Lt,Vi,Ht]);let Wi=MS((t,n=0,r,i,a=!1,o,s=`project`,c)=>(0,$.jsx)(Kx,{node:t,depth:n,groupDirectory:r,projectId:i,archivedBucket:a,currentSessionId:Lt,pinnedSessionIds:H,settledSessionIds:gi,setSessionSettled:Si,expandedParents:w,hasSessionSearchQuery:it,normalizedSessionSearchQuery:rt,notifyOnSubtasks:$e,editingId:_,setEditingId:v,editTitle:y,setEditTitle:b,handleSaveEdit:mr,handleCancelEdit:hr,toggleParent:ur,handleSessionSelect:fr,handleSessionDoubleClick:pr,togglePinnedSession:U,handleShareSession:gr,copiedSessionId:Yn,handleCopyShareUrl:_r,handleUnshareSession:vr,openSidebarMenuKey:F,setOpenSidebarMenuKey:I,renamingFolderId:L,getFoldersForScope:ut,getSessionFolderId:bt,removeSessionFromFolder:_t,addSessionToFolder:ht,createFolderAndStartRename:br,handleDeleteSession:yr,mobileVariant:e,alwaysShowActions:Sn,renderSessionNode:Wi,secondaryMeta:o,renderContext:s,subtreeContainsActive:c?.subtreeContainsActive??kS,subtreeContainsEditing:c?.subtreeContainsEditing??kS,menuOpenSessionId:c?.menuOpenSessionId??null,nodeStructureKey:c?.nodeStructureKey??``,childRenderExtrasFor:c?.childRenderExtrasFor,liveSessionById:fn,shortcutNumber:Ri.get(Qa({scope:s,sessionId:t.session.id,projectId:i??null})??``)??null},`${s}:${i??``}:${t.session.id}`),JSON.stringify([...Ri])),Gi=Q.useCallback(e=>{Sr(e),_e(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[Sr]),Ki=Q.useCallback(e=>{let t=wr(e);if(t.length===0)return;let n=pn.getState(),r=t.filter(e=>!n.archivedLoadedDirectories.has(e));r.length>0&&Zn(r)},[wr]),qi=K((e,t,n,r,i)=>{let a=e.folderScopeKey??ft(e.directory??null);a&&xt(a,t,n,r,i).catch(()=>X.error(o(`sessions.order.saveFailed`)))}),Ji=K((e,t,n)=>{e.isArchivedBucket&&ge.has(t)&&n&&Ki(n),Gi(t)}),Yi=Q.useMemo(()=>(t,n,r,i,a,o,s)=>(0,$.jsx)(pc,{group:t,groupKey:n,isArchivedLoading:!!(t.isArchivedBucket&&r&&wr(r).some(e=>Nt.has(e))),projectId:r,projectLabel:r?Pr.get(r)??null:null,hideGroupLabel:i,compactBodyPadding:o,hasSessionSearchQuery:it,normalizedSessionSearchQuery:rt,groupSearchDataByGroup:Jr,visibleSessionCount:j.get(n),collapsedGroups:ge,collapsedFolderIds:ot,toggleFolderCollapse:yt,renameFolder:pt,deleteFolder:mt,showDeletionDialog:et,setDeleteFolderConfirm:ne,renderSessionNode:Wi,projectRepoStatus:k,lastRepoStatus:Wr.current,showMoreGroupSessions:xr,resetGroupSessionLimit:Sr,mobileVariant:e,alwaysShowActions:Sn,activeProjectId:Be,setActiveProjectIdOnly:Ue,setActiveMainTab:Ke,setSessionSwitcherOpen:Ze,openNewSessionDraft:nn,addSessionToFolder:ht,createFolderAndStartRename:br,renamingFolderId:L,renameFolderDraft:z,setRenameFolderDraft:ee,setRenamingFolderId:R,pinnedSessionIds:H,expandedParents:w,sessionOrderByScope:ct,sessionOrderActivityByScope:lt,onReorderSessions:qi,currentSessionId:Lt,shortcutTargetSessionId:Vi?.groupKey===n?Vi.sessionId:null,shortcutTargetVisibleIndex:Vi?.groupKey===n?Vi.visibleIndex??null:null,editingId:_,editTitle:y,openSidebarMenuKey:F,liveSessionById:fn,alwaysVisibleSessionIds:Tt,onToggleCollapsedGroup:Ji,dragHandleProps:a,scrollContainerRef:s}),[it,rt,Jr,Pr,Nt,wr,j,ge,ot,yt,pt,mt,et,Wi,k,xr,Sr,e,Sn,Be,Ue,Ke,Ze,nn,ht,br,L,z,H,w,ct,lt,qi,Lt,Vi,_,y,F,fn,Tt,Ji]),Zi=ui?(0,$.jsx)(J,{variant:`ghost`,size:`xs`,className:`-mr-0.5 size-6 p-0 text-muted-foreground`,"aria-label":o(`sessions.sidebar.header.actions.addProject`),title:o(`sessions.sidebar.header.actions.addProject`),onClick:sr.requestDirectoryDialog,children:(0,$.jsx)(Z,{name:`add`,className:`size-4`})}):null,Qi=li?(0,$.jsx)(tS,{value:le,onChange:he}):void 0,$i=e=>Wi(e.node,0,e.groupDirectory,e.projectId,!1,e.secondaryMeta,`project`),ea=ui&&Ci?(0,$.jsx)(rS,{items:Ci,renderTaskRow:$i,onSessionsReordered:yi}):void 0,ta=ui&&Ci?(0,$.jsx)(sS,{items:Ci,open:de.settledOpen,onToggle:()=>fe(e=>({...e,settledOpen:!e.settledOpen,settledLimit:30})),onShowMore:()=>fe(e=>({...e,settledLimit:e.settledLimit+30})),renderTaskRow:$i}):void 0,na=r?null:(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(Ay,{collapseAllProjects:Or,expandAllProjects:kr}),(0,$.jsx)(J,{variant:`ghost`,size:`xs`,className:`-mr-0.5 size-6 p-0 text-muted-foreground`,"aria-label":o(`sessions.sidebar.header.actions.addProject`),title:o(`sessions.sidebar.header.actions.addProject`),onClick:sr.requestDirectoryDialog,children:(0,$.jsx)(Z,{name:`add`,className:`size-4`})})]}),ra=mn&&yn&&!Ot&&!it?(0,$.jsx)(`div`,{className:`shrink-0 px-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(bf,{className:`min-w-0 flex-1`}),(0,$.jsx)(ol,{className:`ml-auto shrink-0`})]})}):null,ia=!Ot&&!it,aa=ia&&xn&&!e,oa=ui?[]:ci,sa=!it&&(si.length>0||oa.length>0),ca=(0,$.jsxs)(`div`,{className:`space-y-0.5 py-1`,children:[(0,$.jsxs)(J,{variant:`ghost`,size:`sm`,className:Y(`w-full justify-start px-2 font-normal`,e&&`h-11`),onClick:Hn,children:[(0,$.jsx)(Z,{name:`chat-new`,className:`size-4`}),(0,$.jsx)(`span`,{className:`truncate`,children:o(`sessions.sidebar.header.actions.newSession`)})]}),(0,$.jsxs)(J,{variant:`ghost`,size:`sm`,className:Y(`w-full justify-start px-2 font-normal`,qe===`schedule`&&`bg-interactive-selection text-interactive-selection-foreground`,e&&`h-11`),onClick:Un,children:[(0,$.jsx)(Z,{name:`time`,className:`size-4`}),(0,$.jsx)(`span`,{className:`truncate`,children:o(`sessions.sidebar.header.actions.scheduledTasks`)}),a?(0,$.jsx)(Uv,{}):null]}),Je.data?.supported&&Je.data?.enabled?(0,$.jsxs)(J,{variant:`ghost`,size:`sm`,className:Y(`w-full justify-start px-2 font-normal`,qe===`assistant`&&`bg-interactive-selection text-interactive-selection-foreground`,e&&`h-11`),onClick:Gn,children:[(0,$.jsx)(ul,{className:`size-4 shrink-0 [&[data-assistant-navigation-avatar]]:scale-125`}),(0,$.jsx)(`span`,{className:`truncate`,children:o(`assistants.title`)}),(0,$.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,$.jsx)(Vl,{className:`h-3.5 min-w-3.5 px-1 text-[10px]`}),a?(0,$.jsx)(Wv,{}):null]})]}):null,(0,$.jsx)(Eu,{sidebar:!0,mobile:e})]}),la=li&&!it,ua=sa?(0,$.jsx)(xy,{isFirst:la,hideHeader:ui,items:wi,reorderEnabled:!0,onSessionsReordered:ni,inProgressItems:oa,renderSessionNode:Wi,currentSessionId:Lt,editingId:_,openSidebarMenuKey:F,onVisibleSessionIdsChange:Ni}):null,da=ia&&!aa||sa&&!la?(0,$.jsxs)($.Fragment,{children:[ia&&!aa?(0,$.jsxs)($.Fragment,{children:[e&&yn?(0,$.jsx)(bf,{}):null,ca]}):null,la?null:ua]}):null,fa=!!(L||_||x),{selectionModeEnabled:pa,hasSelection:ma,selectedIdsSize:ha,bulkScopeIsArchived:ga,derivedSelectionScope:_a,bulkScopeFolders:va,bulkCanRemoveFromFolder:ya,handleExitSelectionMode:ba,handleBulkMoveToFolder:xa,handleBulkCreateFolderAndMove:Sa,handleBulkRemoveFromFolder:Ca,handleBulkDelete:wa,confirmBulkDelete:Ta}=$x({isInlineEditing:fa,showDeletionDialog:et,foldersMap:st,addSessionsToFolder:gt,removeSessionsFromFolders:vt,createFolderAndStartRename:dr,archiveSessions:Jn,setBulkDeleteConfirm:ie});return(0,$.jsxs)(`div`,{ref:h,className:Y(`yuri-session-sidebar relative flex h-full flex-col text-foreground overflow-x-hidden`,e?``:`bg-transparent`),children:[(0,$.jsx)(yy,{hideDirectoryControls:r,isSessionSearchOpen:u,setIsSessionSearchOpen:d,sessionSearchInputRef:g,sessionSearchQuery:f,setSessionSearchQuery:p,hasSessionSearchQuery:it,searchMatchCount:Xr}),ra,aa?(0,$.jsx)(`div`,{className:`shrink-0 px-3`,children:ca}):null,a?(0,$.jsx)(xb,{remoteProjects:je,hostRegistry:Ie.registry,projectOrderIds:tl(ke,Gr).map(e=>e.id),onRemoteActivityItems:Fe,remoteSearch:f,remoteError:Ie.catalog.error?.message,onRemoteNavigationTargets:ze,topContent:da,tabLeadingContent:la?ua:void 0,hasLeadingSection:da!==null&&!la&&(si.length>0||ai.length>0),headerAccessory:ui?Zi:na,headerSwitch:Qi,taskContent:ea,taskFooter:ta,sectionsForRender:Ei,projectSections:qr,activeProjectId:Be,projectRevealTarget:Gt,showOnlyMainWorkspace:i,hasSessionSearchQuery:it,emptyState:Nn,searchEmptyState:Zr,renderGroupSessions:Yi,homeDirectory:Ee,collapsedProjects:D,hideDirectoryControls:r,projectRepoStatus:k,mobileVariant:e,alwaysShowActions:Sn,toggleProject:Ar,setActiveProjectIdOnly:Ue,setActiveMainTab:Ke,setSessionSwitcherOpen:Ze,openNewSessionDraft:nn,openNewWorktreeDialog:Rn,syncProjectSessions:Dr,openProjectEditDialog:S,removeProject:Ve,projectReorderEnabled:Gr===`manual`,reorderProjects:Ge,projectSortOrder:Gr,getOrderedGroups:Qr,setGroupOrderByProject:ye,openSidebarMenuKey:F,setOpenSidebarMenuKey:I,isInlineEditing:fa}):null,pa&&ma?(0,$.jsx)(Qx,{selectedCount:ha,scopeKey:_a,scopeFolders:va,archivedBucket:ga,onMoveToFolder:xa,onCreateFolderAndMove:Sa,onRemoveFromFolder:Ca,canRemoveFromFolder:ya,onDelete:wa,onDone:ba}):null,(0,$.jsx)(Yv,{normalizedProjects:Mr,ownership:zr,enabled:a}),(0,$.jsx)(db,{onOpenSettings:Vn,onOpenShortcuts:Xe,onOpenUpdate:Bn,showRuntimeButtons:!Ot,showUpdateButton:at}),s?(0,$.jsx)(NS,{onOpenChange:l}):null,Pn?(0,$.jsx)(vy,{open:!0,onOpenChange:e=>{e||S(null)},project:Pn,onSave:Ln}):null,N?(0,$.jsx)(fs,{open:!0,onOpenChange:P,onWorktreeCreated:zn}):null,(0,$.jsx)(ll,{}),(0,$.jsx)(yu,{}),(0,$.jsx)(Yx,{value:B,setValue:V,showDeletionDialog:et,setShowDeletionDialog:tt,onConfirm:ar}),(0,$.jsx)(Zx,{value:te,setValue:ne,onConfirm:lr}),(0,$.jsx)(Xx,{value:re,setValue:ie,showDeletionDialog:et,setShowDeletionDialog:tt,onConfirm:Ta})]})});function FS(e){return{info:e.info,downloading:e.downloading,downloaded:e.downloaded,progress:e.progress,error:e.error,runtimeType:e.runtimeType,onDownload:e.downloadUpdate,onRestart:e.restartToUpdate}}var IS=e=>e?(0,$.jsx)(`span`,{className:`text-foreground/80 dark:text-foreground/70`,children:e}):void 0,LS=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.replace(/\/+$/,``)},RS=()=>{let{t:e}=Nr(),[t,n]=Q.useState(!1),[r,i]=Q.useState(),[a,o]=Q.useState(null),[s,c]=Q.useState([]),[l,u]=Q.useState(!1),[d,f]=Q.useState(!1),[p,m]=Q.useState(!1),[h,g]=Q.useState(!1),[_,v]=Q.useState(new Set),y=Kn(e=>e.getWorktreeMetadata),b=Kn(e=>e.newSessionDraft),x=Kn(e=>e.setNewSessionDraftTarget),S=Kn(e=>e.setDraftBootstrapPendingDirectory),C=lr,w=Kn(e=>e.archiveSessions),T=q(e=>e.showDeletionDialog),E=q(e=>e.setShowDeletionDialog),D=G(e=>e.currentDirectory),O=G(e=>e.homeDirectory),k=un(e=>e.projects),A=un(e=>e.activeProjectId),{isMobile:j,isTablet:M,hasTouchInput:N}=fi(),P=j||M||N,F=Q.useMemo(()=>LS((A?k.find(e=>e.id===A)??null:null)?.path??D),[A,D,k]),I=Q.useCallback(e=>{let t=LS(e.projectDirectory)||F;return{id:(k.find(e=>LS(e.path)===t)??null)?.id??`path:${t}`,path:t}},[F,k]),L=h&&_.size>0,R=Q.useMemo(()=>{let e=a?.worktree;return e&&typeof e.branch==`string`&&e.branch.trim().length>0?!0:s.length>0&&s.every(({metadata:e})=>typeof e.branch==`string`&&e.branch.trim().length>0)},[a?.worktree,s]),z=a?.mode===`worktree`,ee=z,B=p||!z||!R,V=p||!z,te=Q.useCallback(e=>{o({sessions:e.sessions,dateLabel:e.dateLabel,mode:e.mode??`session`,worktree:e.worktree??null})},[]),ne=Q.useCallback(()=>{o(null),c([]),u(!1),f(!1),m(!1),g(!1),v(new Set)},[]),re=Q.useCallback(t=>{if(t.sessions.length===0)return;let n=t.sessions.map(e=>e.id);vl({sessionIds:n,message:n.length===1?e(`sessions.sidebar.session.delete.success`):e(`sessions.sidebar.bulkActions.deletedPlural`,{count:n.length}),undoLabel:e(`sessions.sidebar.undo`),commitFailedMessage:n.length===1?e(`sessions.sidebar.session.delete.error`):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:n.length})})},[e]);Q.useEffect(()=>sr.onDeleteRequest(e=>{if(!T&&(e.mode??`session`)===`session`){re(e);return}te(e)}),[te,T,re]),Q.useEffect(()=>sr.onDirectoryRequest(({origin:e})=>{i(e),n(!0)}),[]),Q.useEffect(()=>{if(!a){c([]),u(!1),f(!1),g(!1),v(new Set);return}let e=a.sessions.map(e=>{let t=y(e.id);return t?{session:e,metadata:t}:null}).filter(e=>!!e);c(e),u(!1),g(!1),v(new Set);let t=new Map;if(a.worktree?.path&&t.set(LS(a.worktree.path),a.worktree),e.forEach(({metadata:e})=>{e.path&&t.set(LS(e.path),e)}),t.size===0){g(!0);return}let n=!1;return(async()=>{let e=new Map,r=new Set;await Promise.all(Array.from(t.entries()).map(async([t,n])=>{try{let i=await Ls(n.path);e.set(t,i),i?.isDirty&&r.add(t)}catch{n.status&&(e.set(t,n.status),n.status.isDirty&&r.add(t))}})).catch(e=>{console.warn(`Failed to inspect worktree status before deletion:`,e)}),!n&&(v(r),g(!0),o(t=>{if(!t?.worktree?.path)return t;let n=LS(t.worktree.path),r=e.get(n);if(!r)return t;let i=t.worktree.status;return i?.isDirty===r.isDirty&&i?.ahead===r.ahead&&i?.behind===r.behind&&i?.upstream===r.upstream?t:{...t,worktree:{...t.worktree,status:r}}}),c(t=>t.map(t=>{let n=LS(t.metadata.path),r=e.get(n);return r?{session:t.session,metadata:{...t.metadata,status:r}}:t})))})(),()=>{n=!0}},[a,y]),Q.useEffect(()=>{R||u(!1)},[R]);let ie=Q.useCallback(async(t,n)=>{let r=l&&R,i=I(t),a=LS(t.path),o=LS(i.path);try{await Rs(i,t,{deleteRemoteBranch:r,deleteLocalBranch:n});let e=LS(b?.directoryOverride);return b?.open&&a&&e===a&&o&&(S(null),x({projectId:i.id,directoryOverride:o},{force:!0})),LS(D)===a&&o&&G.getState().setDirectory(o,{showOverlay:!1}),!0}catch(t){return X.error(e(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:IS(t instanceof Error?t.message:e(`sessions.sidebar.dialogs.deleteResult.tryAgain`))}),!1}},[R,D,l,I,b?.directoryOverride,b?.open,S,x,e]),ae=Q.useCallback((t,n)=>{let r=l&&R;(async()=>{if(!await ie(t,n))return;let i=e(r?`sessions.sidebar.sessionDialogs.worktree.removedWithRemote`:`sessions.sidebar.sessionDialogs.worktree.removed`);X.success(e(`sessions.sidebar.sessionDialogs.worktree.removedTitle`),{description:IS(i)})})()},[R,l,ie,e]),H=Q.useCallback(async()=>{if(a){m(!0);try{let t=ee&&d;if(a.sessions.length===0&&z&&a.worktree){ae(a.worktree,t),ne();return}if(a.sessions.length===1){let t=a.sessions[0];if(z){if(!await C(t.id)){X.error(e(`sessions.sidebar.session.archive.error`)),m(!1);return}Cl({sessionIds:[t.id],message:e(`sessions.sidebar.session.archive.success`),undoLabel:e(`sessions.sidebar.undo`),settingsLabel:e(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:e(`sessions.sidebar.session.archive.undoFailed`)})}else vl({sessionIds:[t.id],message:e(`sessions.sidebar.session.delete.success`),undoLabel:e(`sessions.sidebar.undo`),commitFailedMessage:e(`sessions.sidebar.session.delete.error`)})}else{let n=a.sessions.map(e=>e.id),r=[],i=[];if(z){let e=await w(n);r=e.archivedIds,i=e.failedIds}else vl({sessionIds:n,message:n.length===1?e(`sessions.sidebar.bulkActions.deletedSingle`,{count:n.length}):e(`sessions.sidebar.bulkActions.deletedPlural`,{count:n.length}),undoLabel:e(`sessions.sidebar.undo`),commitFailedMessage:n.length===1?e(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:n.length}):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:n.length})}),r=n,i=[];if(z&&a.worktree&&i.length===0&&ae(a.worktree,t),z&&r.length>0&&Cl({sessionIds:r,message:r.length===1?e(`sessions.sidebar.bulkActions.archivedSingle`,{count:r.length}):e(`sessions.sidebar.bulkActions.archivedPlural`,{count:r.length}),undoLabel:e(`sessions.sidebar.undo`),settingsLabel:e(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:r.length===1?e(`sessions.sidebar.session.archive.undoFailed`):e(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:r.length})}),i.length>0&&(X.error(z?i.length===1?e(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:i.length}):e(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:i.length}):i.length===1?e(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:i.length}):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:i.length}),{description:IS(e(`sessions.sidebar.dialogs.deleteResult.tryAgain`))}),r.length===0)){m(!1);return}}z&&a.sessions.length===1&&a.worktree&&ae(a.worktree,t),ne()}finally{m(!1)}}},[a,d,C,w,ne,ee,z,ae,e]),U=a?.worktree??s[0]?.metadata??null,oe=a?a.mode===`worktree`?a.sessions.length===0?e(`sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked`):a.sessions.length===1?e(`sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked`,{count:a.sessions.length}):e(`sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked`,{count:a.sessions.length}):a.sessions.length===1?a.dateLabel?e(`sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate`,{dateLabel:a.dateLabel}):e(`sessions.sidebar.dialogs.sessionDelete.descriptionOne`):a.dateLabel?e(`sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate`,{count:a.sessions.length,dateLabel:a.dateLabel}):e(`sessions.sidebar.dialogs.sessionDelete.descriptionMany`,{count:a.sessions.length}):``,W=a?(0,$.jsxs)(`div`,{className:Y(z?`space-y-3`:`space-y-2`),children:[a.sessions.length>0&&(0,$.jsxs)(`div`,{className:Y(z?`rounded-lg bg-muted/30 p-3`:`space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3`),children:[z&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:a.sessions.length===1?e(`sessions.sidebar.sessionDialogs.linkedSessionSingle`):e(`sessions.sidebar.sessionDialogs.linkedSessionPlural`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70`,children:a.sessions.length})]}),(0,$.jsxs)(`ul`,{className:Y(z?`mt-2 space-y-1`:`space-y-0.5`),children:[a.sessions.slice(0,5).map(t=>(0,$.jsxs)(`li`,{className:Y(z?`flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground`:`typography-micro text-muted-foreground/80`),children:[(0,$.jsx)(`span`,{className:Y(!z&&`hidden`),children:`•`}),(0,$.jsx)(`span`,{className:`truncate`,children:t.title||e(`sessions.sidebar.session.untitled`)})]},t.id)),a.sessions.length>5&&(0,$.jsx)(`li`,{className:Y(z?`px-2.5 py-1 text-xs text-muted-foreground/70`:`typography-micro text-muted-foreground/70`),children:e(`sessions.sidebar.dialogs.sessionList.more`,{count:a.sessions.length-5})})]})]}),z?(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg bg-muted/30 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Z,{name:`git-branch`,className:`h-4 w-4 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:e(`sessions.sidebar.sessionDialogs.worktree.label`)}),U?.label?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70`,children:U.label}):null]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/80 break-all`,children:U?or(U.path,O):e(`sessions.sidebar.sessionDialogs.worktree.pathUnavailable`)}),L&&(0,$.jsx)(`p`,{className:`typography-micro text-status-warning`,children:e(`sessions.sidebar.sessionDialogs.worktree.uncommittedWarning`)})]}):(0,$.jsx)(`div`,{className:`rounded-xl border border-border/40 bg-sidebar/60 p-3`,children:(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground/80`,children:e(`sessions.sidebar.sessionDialogs.delete.note`)})})]}):null,se=z?R?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{B||u(e=>!e)},disabled:B,className:Y(`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors`,B?`cursor-not-allowed opacity-60`:`hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),children:[l?(0,$.jsx)(Z,{name:`checkbox`,className:`size-4 text-primary`}):(0,$.jsx)(Z,{name:`checkbox-blank`,className:`size-4`}),e(`sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch`)]}):(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground/70`,children:e(`sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable`)}):null,ce=z?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{V||f(e=>!e)},disabled:V,className:Y(`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors`,V?`cursor-not-allowed opacity-60`:`hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),children:[d?(0,$.jsx)(Z,{name:`checkbox`,className:`size-4 text-primary`}):(0,$.jsx)(Z,{name:`checkbox-blank`,className:`size-4`}),e(`sessions.sidebar.sessionDialogs.actions.deleteLocalBranch`)]}):null,le=z?(0,$.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[ce,se]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{variant:`ghost`,onClick:ne,disabled:p,children:e(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(J,{variant:`destructive`,onClick:H,disabled:p,children:e(p?`sessions.sidebar.sessionDialogs.actions.deleting`:`sessions.sidebar.sessionDialogs.actions.deleteWorktree`)})]})]}):(0,$.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>E(!T),className:`inline-flex items-center gap-1.5 typography-meta text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50`,"aria-pressed":!T,children:[T?(0,$.jsx)(Z,{name:`checkbox-blank`,className:`size-4`}):(0,$.jsx)(Z,{name:`checkbox`,className:`size-4 text-primary`}),e(`sessions.sidebar.dialogs.neverAsk`)]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{variant:`ghost`,onClick:ne,disabled:p,children:e(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(J,{variant:`destructive`,onClick:H,disabled:p,children:p?e(`sessions.sidebar.sessionDialogs.actions.deleting`):a?.sessions.length===1?e(`sessions.sidebar.dialogs.deleteSession.titleAction`):e(`sessions.sidebar.dialogs.deleteSessions.titleAction`)})]})]}),ue=z?e(`sessions.sidebar.sessionDialogs.actions.deleteWorktree`):a?.sessions.length===1?e(`sessions.sidebar.dialogs.deleteSession.titleAction`):e(`sessions.sidebar.dialogs.deleteSessions.titleAction`);return(0,$.jsxs)($.Fragment,{children:[P?(0,$.jsx)(Ds,{open:!!a,onClose:()=>{p||ne()},title:ue,footer:(0,$.jsx)(`div`,{className:`flex justify-end gap-2`,children:le}),children:(0,$.jsxs)(`div`,{className:`space-y-2 pb-2`,children:[oe&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground/80`,children:oe}),W]})}):(0,$.jsx)(Qr,{open:!!a,onOpenChange:e=>{if(!e){if(p)return;ne()}},children:(0,$.jsxs)(Yr,{className:Y(z?`max-w-xl max-h-[70vh] flex flex-col overflow-hidden gap-3`:`max-w-[min(520px,100vw-2rem)] space-y-2 pb-2`),children:[(0,$.jsxs)(qr,{children:[(0,$.jsxs)(Xr,{className:Y(z&&`flex items-center gap-2`),children:[z&&(0,$.jsx)(Z,{name:`delete-bin`,className:`h-5 w-5`}),ue]}),oe&&(0,$.jsx)(Zr,{children:oe})]}),(0,$.jsx)(`div`,{className:Y(z&&`flex-1 min-h-0 overflow-y-auto space-y-2`),children:W}),(0,$.jsx)(Jr,{className:`mt-2 gap-2 pt-1 pb-1`,children:le})]})}),(0,$.jsx)(el,{open:t,onOpenChange:n,origin:r})]})},zS=Q.createContext(null),BS=e=>{let t=(0,ju.c)(3),{children:n,value:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(zS.Provider,{value:r,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i},VS=ba(()=>Lt(()=>import(`./TerminalView-Cm8Ts51w.js`).then(e=>({default:e.TerminalView})),__vite__mapDeps([84,1,3,2,4,5,6,7,8,9,10,41,24,42,43,25,22,26,44,14,11,13,12,15,16,17,18,19,20,21,23,27,85,40,45,86,46,39,47,48,49,50,51,52,53,54,55,56,57,58,59,60,87,67,88,70,89,90,91,92,93,94,95,96,97,98]))),HS=ba(()=>Lt(()=>import(`./DiagramView-CTnpBsWU.js`).then(e=>({default:e.DiagramView})),__vite__mapDeps([99,1,3,2,10,12,13,14,4,5,6,7,8,9,11,15,16,17,18,19,20,21,22,23,24,25,26,27,46,60,39,40,41,42,43,44,45,47,48,49,50,51,52,53,54,55,56,57,58,59,70,89,85,100,101]))),US=ba(()=>Lt(()=>import(`./SettingsView-CYEjDYWC.js`).then(e=>({default:e.SettingsView})),__vite__mapDeps([102,1,2,3,4,5,6,7,8,9,103,104,24,10,40,25,22,26,41,42,43,44,14,11,13,12,15,16,17,18,19,20,21,23,27,45,105,46,39,47,48,49,50,51,52,53,54,55,56,57,58,59,60,106,87,64,65,107,67,108,88,109,110,111,112,113,68,29,30,31,32,33,34,35,36,37,38,114,71,72,73,115,116,117,76,70,77,78,118,119,120,121,122,123,124,125,126,127,128,61,62,129,130,90,91,92,93,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,63,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,81,179,180,181,182,183]))),WS=ba(()=>Lt(()=>import(`./SettingsWindow-CvJsxUyu.js`).then(e=>({default:e.SettingsWindow})),__vite__mapDeps([184,1,10,11,39,2,5,3,4,6,7,8,9,24,40,25,22,26,41,42,43,44,14,13,12,15,16,17,18,19,20,21,23,27,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,102,103,104,105,60,106,87,64,65,107,67,108,88,109,110,111,112,113,68,29,30,31,32,33,34,35,36,37,38,114,71,72,73,115,116,117,76,70,77,78,118,119,120,121,122,123,124,125,126,127,128,61,62,129,130,90,91,92,93,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,63,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,81,179,180,181,182,183]))),GS=ba(()=>Lt(()=>import(`./MultiRunWindow-D0OU63re.js`).then(e=>({default:e.MultiRunWindow})),__vite__mapDeps([185,1,10,11,39,2,5,3,4,6,7,8,9,24,40,25,22,26,41,42,43,44,14,13,12,15,16,17,18,19,20,21,23,27,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,186,106,87,107,88,112,113,114,187,117,139,188,189,190,191,161,61,67,72,78,162,163,192,193,194,151,126,158,63,91,92,93,125,127,128,62,178,195,130]))),KS=ba(()=>Lt(()=>import(`./AssistantView-Cg0wPomu.js`).then(e=>({default:e.AssistantView})),__vite__mapDeps([196,1,3,2,10,11,16,17,18,23,5,6,7,8,9,24,25,22,26,27,20,39,4,40,41,42,43,44,14,13,12,15,19,21,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,197,88,119,167,120,198,106,87,61,74,75,199,76,70,77,78,79,165,64,65,73,166,161,67,72,162,163,200,128,62,113,192,193,194,189,190,201,69,152,153,202,203,204,205,206,207,208,168,135,136,209,210,211,212,111,110]))),qS=()=>{let e=q(e=>e.isSidebarOpen),t=q(e=>e.isRightSidebarOpen),n=q(e=>e.isBottomTerminalOpen),r=q(e=>e.setRightSidebarOpen),i=q(e=>e.setBottomTerminalOpen),a=q(e=>e.activeMainTab),o=q(e=>e.setIsMobile),s=q(e=>e.isSessionSwitcherOpen),c=q(e=>e.isSettingsDialogOpen),l=q(e=>e.setSettingsDialogOpen),u=q(e=>e.isMultiRunLauncherOpen),d=q(e=>e.setMultiRunLauncherOpen),[f,p]=Q.useState(c),[m,h]=Q.useState(u);c&&!f&&p(!0),u&&!m&&h(!0);let{isMobile:g,isTablet:_}=fi(),v=Q.useRef(!1),y=Q.useRef(!1),[b,x]=Q.useState(!1),[S,C]=Q.useState(!1),[w,T]=Q.useState(!1),[E,D]=Q.useState(!1),O=Q.useCallback(e=>{x(e),q.getState().setSessionSwitcherOpen(e)},[]),k=Q.useRef(!1),A=Q.useRef(typeof window>`u`?0:window.innerWidth),j=Gr(-A.current),M=(0,Q.useRef)(0),N=Gr(A.current),P=(0,Q.useRef)(0);(0,Q.useEffect)(()=>{g&&(M.current=window.innerWidth,P.current=window.innerWidth)},[g]),(0,Q.useEffect)(()=>{if(!g){T(!1);return}b&&T(!0),Kr(j,b?0:-M.current,{type:`spring`,stiffness:400,damping:35,mass:.8})},[b,g,j]),(0,Q.useEffect)(()=>{if(!g){D(!1);return}k.current=S,S&&D(!0),Kr(N,S?0:P.current,{type:`spring`,stiffness:400,damping:35,mass:.8})},[g,S,N]),(0,Q.useEffect)(()=>{if(g)return j.on(`change`,e=>{let t=M.current||A.current,n=b||e>-t+.5;T(e=>e===n?e:n)})},[g,j,b]),(0,Q.useEffect)(()=>{if(g)return N.on(`change`,e=>{let t=P.current||A.current,n=S||e<t-.5;D(e=>e===n?e:n)})},[g,S,N]),(0,Q.useEffect)(()=>{g&&!s&&b&&O(!1)},[s,g,b,O]),(0,Q.useEffect)(()=>{if(!g){y.current=!1;return}y.current||(y.current=!0,O(!1),C(!1),q.getState().isRightSidebarOpen&&r(!1))},[g,O,r]),(0,Q.useEffect)(()=>{if(!g||a!==`chat`||b||S||c)return;let e=!1,t,n=r=>{t=window.setTimeout(()=>{if(e)return;let t=Kn.getState(),r=q.getState();if(!(r.activeMainTab!==`chat`||r.isSettingsDialogOpen||t.currentSessionId||t.newSessionDraft?.open)){if(t.isLoading){n(250);return}t.openNewSessionDraft()}},r)};return n(500),()=>{e=!0,t!==void 0&&window.clearTimeout(t)}},[a,g,c,b,S]),(0,Q.useEffect)(()=>{!g||!c||(O(!1),C(!1),t&&r(!1))},[g,c,t,O,r]),Q.useEffect(()=>{q.getState().isMobile!==g&&o(g)},[g,o]),Q.useEffect(()=>{if(typeof window>`u`)return;let e,t=()=>{e===void 0&&(e=window.requestAnimationFrame(()=>{e=void 0,q.getState().updateProportionalSidebarWidths()}))};return window.addEventListener(`resize`,t),()=>{window.removeEventListener(`resize`,t),e!==void 0&&window.cancelAnimationFrame(e)}},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e,t=()=>{let e=q.getState(),t=window.innerHeight;!g&&!_&&(t<640?e.isBottomTerminalOpen&&(i(!1),v.current=!0):t>=700&&v.current&&(i(!0),v.current=!1))},n=()=>{e===void 0&&(e=window.requestAnimationFrame(()=>{e=void 0,t()}))};return t(),window.addEventListener(`resize`,n),()=>{window.removeEventListener(`resize`,n),e!==void 0&&window.cancelAnimationFrame(e)}},[g,_,i]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=q.subscribe((e,t)=>{let n=window.innerHeight>=700;e.isBottomTerminalOpen!==t.isBottomTerminalOpen&&n&&(v.current=!1)});return()=>{e()}},[g,_,i]);let F=Q.useCallback(()=>{b&&O(!1),C(!S)},[b,S,O]),I=Q.useMemo(()=>{switch(a){case`git`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Ah,{isActive:!S})});case`diff`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Ql,{})});case`terminal`:return n?null:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(VS,{})});case`files`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(hp,{})});case`diagram`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(HS,{})});default:return null}},[a,n,S]),L=a===`schedule`,R=a===`assistant`,z=a===`plugin`,ee=L||R||z,B=a===`chat`,V=!ee&&!c;return(0,$.jsx)(zi,{children:(0,$.jsxs)(`div`,{"data-page-scroll-lock":`true`,className:Y(`main-content-safe-area`,g?`flex h-[100dvh] flex-col`:`relative flex h-[100dvh]`,`bg-background`),children:[(0,$.jsx)(al,{}),(0,$.jsx)(Fv,{}),(0,$.jsx)(zv,{}),(0,$.jsx)(RS,{}),(0,$.jsx)(Tl,{}),g?(0,$.jsxs)(BS,{value:{leftDrawerOpen:b,rightDrawerOpen:S,toggleLeftDrawer:()=>{let e=!b;S&&C(!1),O(e)},toggleRightDrawer:F,leftDrawerX:j,rightDrawerX:N,leftDrawerWidth:M,rightDrawerWidth:P,setMobileLeftDrawerOpen:O,setRightSidebarOpen:C},children:[!c&&!ee&&(0,$.jsx)(Zd,{onToggleLeftDrawer:()=>{let e=!b;S&&C(!1),O(e)},onToggleRightDrawer:()=>{F()},leftDrawerOpen:b,rightDrawerOpen:S}),(0,$.jsx)(`div`,{"data-page-scroll-lock":`true`,className:Y(`flex flex-1 overflow-hidden relative`,c&&`hidden`),children:(0,$.jsxs)(`main`,{className:`w-full h-full overflow-hidden bg-background relative`,"data-page-scroll-lock":`true`,children:[L&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(No,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Yl,{})})})}),R&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(No,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(KS,{})})})}),V&&(0,$.jsx)(`div`,{className:Y(`absolute inset-0`,!B&&`invisible`),children:(0,$.jsx)(mc,{children:(0,$.jsx)(No,{children:(0,$.jsx)(Xl,{})})})}),V&&I&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(mc,{children:(0,$.jsx)(No,{children:I})})}),u&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(No,{children:(0,$.jsx)(iu,{onCreated:()=>d(!1),onCancel:()=>d(!1)})})}),(0,$.jsx)(As.div,{className:Y(`absolute inset-0 z-20 bg-sidebar`,!w&&`pointer-events-none invisible`),"data-page-scroll-lock":`true`,style:{x:j},"aria-hidden":!b,children:(0,$.jsx)(No,{children:(0,$.jsx)(PS,{mobileVariant:!0,isVisible:w})})}),E&&(0,$.jsx)(As.div,{className:`absolute inset-0 z-20 bg-sidebar`,"data-page-scroll-lock":`true`,style:{x:N},"aria-hidden":!S,children:(0,$.jsx)(No,{children:(0,$.jsx)(mc,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Ah,{isActive:S})})})})})]})}),c&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,style:{paddingTop:`var(--yuri-safe-area-top, 0px)`},children:(0,$.jsx)(No,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(US,{onClose:()=>l(!1)})})})}),(0,$.jsx)(No,{children:(0,$.jsx)(dl,{})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Tf,{}),(0,$.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:[(0,$.jsx)(vf,{isOpen:e,isMobile:g,className:`border-border/50`,topBar:(0,$.jsx)(yf,{}),children:(0,$.jsx)(PS,{isVisible:e})}),(0,$.jsx)(`div`,{className:`relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background`,"data-page-scroll-lock":`true`,children:ee?(0,$.jsx)(`main`,{className:`flex-1 overflow-hidden bg-background`,"data-page-scroll-lock":`true`,children:(0,$.jsx)(No,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:z?(0,$.jsx)(Ul,{}):R?(0,$.jsx)(KS,{}):(0,$.jsx)(Yl,{})})})}):(0,$.jsx)(mc,{children:(0,$.jsxs)(Nv,{header:(0,$.jsx)(Zd,{}),footer:(0,$.jsx)(lf,{isOpen:n,isMobile:g,children:n?(0,$.jsx)(No,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(VS,{})})}):null}),children:[V&&(0,$.jsx)(`div`,{className:Y(`absolute inset-0`,!B&&`invisible`),children:(0,$.jsx)(No,{children:(0,$.jsx)(Xl,{})})}),V&&I&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(No,{children:I})})]})})})]}),(0,$.jsx)(Q.Suspense,{fallback:null,children:f&&(0,$.jsx)(WS,{open:c,onOpenChange:l})}),(0,$.jsx)(Q.Suspense,{fallback:null,children:m&&(0,$.jsx)(GS,{open:u,onOpenChange:d})})]})]})})},JS=9e4,YS=15e3,XS=3e5,ZS=[2e3,5e3],QS=6e4,$S=12e4,eC=3e5,tC=4,nC=432e5,rC=`yuri.github-pr-status`,iC=e=>e===`closed`||e===`merged`,aC=e=>{let t=e?.checks;return t?t.state===`pending`||t.pending>0:!1},oC=(e,t,n)=>`${e}::${t}`,sC=new Map,cC=new Map,lC=new Set,uC=new Map,dC=2,fC=0,pC=[],mC=()=>fC<dC?(fC+=1,Promise.resolve()):new Promise(e=>{pC.push(e)}),hC=()=>{let e=pC.shift();if(e){e();return}fC=Math.max(0,fC-1)},gC=()=>({status:null,isLoading:!1,error:null,isInitialStatusResolved:!1,lastRefreshAt:0,lastDiscoveryPollAt:0,watchers:0,params:null,identity:null,resolvedRemoteName:null}),_C=e=>e?.params?.directory&&e.params.branch?{directory:e.params.directory,branch:e.params.branch,remoteName:e.params.remoteName??e.resolvedRemoteName??e.identity?.remoteName??null}:!e?.identity?.directory||!e.identity.branch?null:e.identity,vC=e=>{let t=_C(e);return!t?.directory||!t.branch?null:`${t.directory}::${t.branch}`},yC=(e,t)=>Object.entries(e).filter(([,e])=>vC(e)===t).map(([e])=>e),bC=(e,t)=>{let n=t.remoteName??e.params?.remoteName??e.resolvedRemoteName??e.identity?.remoteName??null;return{...e,params:e.params?{...e.params,...t,remoteName:n}:{...t,remoteName:n},identity:{directory:t.directory,branch:t.branch,remoteName:n}}},xC=e=>!e?.params?.canShow||!e.params.github?.prStatus?null:{...e.params,remoteName:e.params.remoteName??e.resolvedRemoteName??e.identity?.remoteName??null},SC=(e,t,n)=>{let r=yC(e,t),i=r.map(t=>xC(e[t])).filter(e=>!!e);if(i.length===0)return null;let a=xC(e[n]);if(a&&vC(e[n])===t)return a;let o=r.map(t=>e[t]).find(e=>!!(e?.resolvedRemoteName&&xC(e)));return o?xC(o):i.find(e=>!!e.remoteName)||(i[0]??null)},CC=e=>({status:e.status,isInitialStatusResolved:e.isInitialStatusResolved,lastRefreshAt:e.lastRefreshAt,lastDiscoveryPollAt:e.lastDiscoveryPollAt,identity:_C(e),resolvedRemoteName:e.resolvedRemoteName??e.status?.resolvedRemoteName??null}),wC=e=>({...gC(),status:e?.status??null,isInitialStatusResolved:e?.isInitialStatusResolved??!1,lastRefreshAt:e?.lastRefreshAt??0,lastDiscoveryPollAt:e?.lastDiscoveryPollAt??0,identity:e?.identity??null,resolvedRemoteName:e?.resolvedRemoteName??e?.status?.resolvedRemoteName??null}),TC=ue()(de((e,t)=>({entries:{},activeRequestCount:0,totalRequestCount:0,ensureEntry:t=>{e(e=>e.entries[t]?e:{entries:{...e.entries,[t]:gC()}})},setParams:(t,n)=>{e(e=>{let r=e.entries[t]??gC();return{entries:{...e.entries,[t]:bC(r,n)}}})},startWatching:n=>{if(e(e=>{let t=e.entries[n]??gC();return{entries:{...e.entries,[n]:{...t,watchers:t.watchers+1}}}}),sC.has(n))return;let r=e=>{let r=window.setTimeout(()=>{if(typeof document<`u`&&document.visibilityState!==`visible`)return;let e=t().entries[n];!e||e.watchers<=0||e.status?.pr||t().refresh(n,{force:!0,silent:!0,markInitialResolved:!0})},e),i=cC.get(n)??[];i.push(r),cC.set(n,i)};t().refresh(n,{force:!0,silent:!0,markInitialResolved:!0}),ZS.forEach(e=>r(e));let i=window.setInterval(()=>{if(typeof document<`u`&&document.visibilityState!==`visible`)return;let r=t().entries[n];if(!(!r||r.watchers<=0)){if(!r.status?.pr){let i=Date.now();if(i-r.lastDiscoveryPollAt<XS)return;e(e=>{let t=e.entries[n];return t?{entries:{...e.entries,[n]:{...t,lastDiscoveryPollAt:i}}}:e}),t().refresh(n,{force:!0,silent:!0,markInitialResolved:!0});return}iC(r.status?.pr?.state)||Date.now()-r.lastRefreshAt<(aC(r.status)?QS:r.status?.checks&&r.status.checks.state!==`pending`?eC:$S)||t().refresh(n,{force:!0,onlyExistingPr:!0,silent:!0,markInitialResolved:!0})}},YS);sC.set(n,i)},stopWatching:n=>{e(e=>{let t=e.entries[n];if(!t)return e;let r=Math.max(0,t.watchers-1);return{entries:{...e.entries,[n]:{...t,watchers:r}}}});let r=t().entries[n];if(r&&r.watchers>0)return;let i=sC.get(n);typeof i==`number`&&window.clearInterval(i),sC.delete(n);let a=cC.get(n);a&&a.length>0&&a.forEach(e=>{window.clearTimeout(e)}),cC.delete(n)},refresh:async(n,r)=>{let i=t(),a=i.entries[n],o=vC(a);if(!a||!o)return;let s=yC(i.entries,o),c=s.some(e=>!!i.entries[e]?.status?.pr);if(r?.onlyExistingPr&&!c)return;let l=uC.get(o)??0;if(!r?.force&&Date.now()-l<JS||lC.has(o))return;let u=SC(i.entries,o,n);if(u){if(lC.add(o),uC.set(o,Date.now()),e(e=>{let t={...e.entries};return s.forEach(e=>{let n=t[e];n&&(t[e]={...n,lastRefreshAt:Date.now(),isLoading:!r?.silent||n.isLoading,error:null})}),{entries:t}}),u.githubAuthChecked&&u.githubConnected===!1){e(e=>{let t={...e.entries};return s.forEach(e=>{let n=t[e];n&&(t[e]={...n,status:{connected:!1},error:null,isLoading:r?.silent?n.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||n.isInitialStatusResolved})}),{entries:t}}),lC.delete(o);return}if(!u.github?.prStatus){e(e=>{let t={...e.entries};return s.forEach(e=>{let n=t[e];n&&(t[e]={...n,status:null,error:`GitHub runtime API unavailable`,isLoading:r?.silent?n.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||n.isInitialStatusResolved})}),{entries:t}}),lC.delete(o);return}try{e(e=>({...e,activeRequestCount:e.activeRequestCount+1,totalRequestCount:e.totalRequestCount+1})),await mC();let t;try{t=await u.github.prStatus(u.directory,u.branch,u.remoteName??void 0,{force:r?.force})}finally{hC()}e(e=>{let n={...e.entries};return s.forEach(e=>{let i=n[e];if(!i)return;let a=i.status?.pr,o=t.pr,s=o&&a&&o.number===a.number&&(!o.body||!o.body.trim())&&typeof a.body==`string`&&a.body.trim().length>0&&o&&a?.body?{...t,pr:{...o,body:a.body}}:t,c=s.resolvedRemoteName??i.resolvedRemoteName??u.remoteName??null,l=_C(i)??{directory:u.directory,branch:u.branch,remoteName:u.remoteName??null};n[e]={...i,status:s,error:null,isLoading:r?.silent?i.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||i.isInitialStatusResolved,resolvedRemoteName:c,identity:{...l,remoteName:c??l.remoteName??null}}}),{entries:n}})}catch(t){let n=t instanceof Error?t.message:String(t);e(e=>{let t={...e.entries};return s.forEach(e=>{let i=t[e];i&&(t[e]={...i,error:n||`Failed to load PR status`,isLoading:r?.silent?i.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||i.isInitialStatusResolved})}),{entries:t}})}finally{lC.delete(o),e(e=>({...e,activeRequestCount:Math.max(0,e.activeRequestCount-1)}))}}},refreshTargets:async(e,n)=>{await hy(Array.from(new Set(e.map(e=>{let t=e.directory.trim(),n=e.branch.trim();return!t||!n?null:oC(t,n,e.remoteName??null)}).filter(e=>!!e))),tC,e=>t().refresh(e,n))},updateStatus:(t,n)=>{e(e=>{let r=e.entries[t]??gC();return{entries:{...e.entries,[t]:{...r,status:n(r.status)}}}})}}),{name:rC,storage:We(),partialize:e=>({entries:Object.fromEntries(Object.entries(e.entries).filter(([,e])=>{let t=_C(e);if(!t?.directory||!t.branch)return!1;let n=Math.max(e.lastRefreshAt,e.lastDiscoveryPollAt);return n===0||Date.now()-n<nC}).map(([e,t])=>[e,CC(t)]))}),merge:(e,t)=>{let n=e?.entries??{};return{...t,entries:Object.fromEntries(Object.entries(n).map(([e,t])=>[e,wC(t)]))}}})),EC=e=>{if(e<1e3)return`${Math.round(e)}ms`;let t=e/1e3;return t<60?`${t.toFixed(1)}s`:`${Math.floor(t/60)}m ${Math.round(t%60)}s`},DC=e=>{let t=(0,ju.c)(8),{label:n,value:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={backgroundColor:`color-mix(in srgb, var(--surface-muted) 55%, transparent)`},t[0]=i):i=t[0];let a;t[1]===n?a=t[2]:(a=(0,$.jsx)(`div`,{className:`typography-meta text-[var(--surface-muted-foreground)]`,children:n}),t[1]=n,t[2]=a);let o;t[3]===r?o=t[4]:(o=(0,$.jsx)(`div`,{className:`typography-markdown font-semibold text-[var(--surface-foreground)]`,children:r}),t[3]=r,t[4]=o);let s;return t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`div`,{className:`rounded-md p-2`,style:i,children:[a,o]}),t[5]=a,t[6]=o,t[7]=s):s=t[7],s},OC=e=>{let t=(0,ju.c)(43),{title:n,snapshot:r,emptyLabel:i}=e,{t:a}=Nr(),o;if(t[0]!==i||t[1]!==r.durationMs||t[2]!==r.entries||t[3]!==r.lastUpdatedAt||t[4]!==r.startedAt||t[5]!==a||t[6]!==n){let e=r.entries.slice(0,12),s;t[8]===r.entries?s=t[9]:(s=r.entries.reduce(AC,0),t[8]=r.entries,t[9]=s);let c=s,l;t[10]===n?l=t[11]:(l=(0,$.jsx)(`div`,{className:`typography-ui-label font-semibold text-[var(--surface-foreground)]`,children:n}),t[10]=n,t[11]=l);let u;t[12]!==r.durationMs||t[13]!==r.startedAt||t[14]!==a?(u=r.startedAt?EC(r.durationMs):a(`memoryDebugPanel.common.idle`),t[12]=r.durationMs,t[13]=r.startedAt,t[14]=a,t[15]=u):u=t[15];let d;t[16]===u?d=t[17]:(d=(0,$.jsx)(`div`,{className:`typography-meta text-[var(--surface-muted-foreground)]`,children:u}),t[16]=u,t[17]=d);let f;t[18]!==l||t[19]!==d?(f=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[l,d]}),t[18]=l,t[19]=d,t[20]=f):f=t[20];let p;t[21]===a?p=t[22]:(p=a(`memoryDebugPanel.metric.metrics`),t[21]=a,t[22]=p);let m;t[23]!==r.entries.length||t[24]!==p?(m=(0,$.jsx)(DC,{label:p,value:r.entries.length}),t[23]=r.entries.length,t[24]=p,t[25]=m):m=t[25];let h;t[26]===a?h=t[27]:(h=a(`memoryDebugPanel.metric.samples`),t[26]=a,t[27]=h);let g;t[28]!==h||t[29]!==c?(g=(0,$.jsx)(DC,{label:h,value:c}),t[28]=h,t[29]=c,t[30]=g):g=t[30];let _;t[31]===a?_=t[32]:(_=a(`memoryDebugPanel.metric.lastUpdate`),t[31]=a,t[32]=_);let v;t[33]!==r.lastUpdatedAt||t[34]!==a?(v=r.lastUpdatedAt?a(`memoryDebugPanel.common.live`):a(`memoryDebugPanel.common.notAvailable`),t[33]=r.lastUpdatedAt,t[34]=a,t[35]=v):v=t[35];let y;t[36]!==_||t[37]!==v?(y=(0,$.jsx)(DC,{label:_,value:v}),t[36]=_,t[37]=v,t[38]=y):y=t[38];let b;t[39]!==g||t[40]!==y||t[41]!==m?(b=(0,$.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[m,g,y]}),t[39]=g,t[40]=y,t[41]=m,t[42]=b):b=t[42],o=(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0`,children:[f,b,e.length===0?(0,$.jsx)(`div`,{className:`rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]`,style:{backgroundColor:`color-mix(in srgb, var(--surface-muted) 45%, transparent)`},children:i}):(0,$.jsx)(Wr,{outerClassName:`max-h-64`,className:`pr-1`,children:(0,$.jsx)(`div`,{className:`space-y-1`,children:e.map(e=>(0,$.jsxs)(`div`,{className:`rounded-md border border-[var(--interactive-border)] p-2`,style:{backgroundColor:`color-mix(in srgb, var(--surface-elevated) 88%, transparent)`},children:[(0,$.jsx)(`div`,{className:`typography-meta font-medium text-[var(--surface-foreground)] break-all`,children:e.metric}),(0,$.jsxs)(`div`,{className:`mt-1 grid grid-cols-4 gap-2 typography-meta text-[var(--surface-muted-foreground)]`,children:[(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.countValue`,{value:e.count})}),(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.avgValue`,{value:e.avg})}),(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.maxValue`,{value:e.max})}),(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.totalValue`,{value:e.total})})]})]},e.metric))})})]}),t[0]=i,t[1]=r.durationMs,t[2]=r.entries,t[3]=r.lastUpdatedAt,t[4]=r.startedAt,t[5]=a,t[6]=n,t[7]=o}else o=t[7];return o},kC=e=>{let t=(0,ju.c)(104),{onClose:n}=e,{t:r}=Nr(),[i,a]=Q.useState(`memory`),[o,s]=Q.useState(`idle`),c=Kn(jC),l=br(MC),u=Sr(),d=bn(),[f,p]=Q.useState(NC),m,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>Qe(()=>{p(Ze())}),h=[],t[0]=m,t[1]=h):(m=t[0],h=t[1]),Q.useEffect(m,h);let g;if(t[2]!==d||t[3]!==u){bb0:{let e=Xe(),t={};if(!e){g=t;break bb0}let n=e.getCacheBudget?.(),r=n?n.listCanonical().map(PC):u.map(e=>({directory:d,sessionID:e.id}));for(let n of r){if(d&&n.directory!==d)continue;let r=e.getTranscript(rt(n.directory,n.sessionID));t[n.sessionID]=r.messageOrder.map(e=>r.messagesByID[e]).filter(FC)}g=t}t[2]=d,t[3]=u,t[4]=g}else g=t[4];let _=g,v=TC(IC),[y,b]=Q.useState(LC),[x,S]=Q.useState(RC),C;t[5]===y.entries?C=t[6]:(C=new Map,y.entries.forEach(e=>{C.set(e.metric,e.count)}),t[5]=y.entries,t[6]=C);let w;t[7]===C?w=t[8]:(w=C.get(`ui.message_list.render`)??0,t[7]=C,t[8]=w);let T;t[9]===C?T=t[10]:(T=C.get(`ui.message_list.render.streaming`)??0,t[9]=C,t[10]=T);let E;t[11]===C?E=t[12]:(E=C.get(`ui.chat_message.render`)??0,t[11]=C,t[12]=E);let D;t[13]===C?D=t[14]:(D=C.get(`ui.chat_message.render.streaming`)??0,t[13]=C,t[14]=D);let O;t[15]===C?O=t[16]:(O=C.get(`ui.chat_message.render.static_during_stream`)??0,t[15]=C,t[16]=O);let k;t[17]===C?k=t[18]:(k=C.get(`ui.chat_message.render.static_outside_active_turn_during_stream`)??0,t[17]=C,t[18]=k);let A;t[19]!==w||t[20]!==T||t[21]!==E||t[22]!==D||t[23]!==O||t[24]!==k?(A={messageListRender:w,messageListRenderStreaming:T,chatMessageRender:E,chatMessageRenderStreaming:D,chatMessageRenderStaticDuringStream:O,chatMessageRenderStaticOutsideActiveTurnDuringStream:k},t[19]=w,t[20]=T,t[21]=E,t[22]=D,t[23]=O,t[24]=k,t[25]=A):A=t[25];let j=A,M,N;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>{let e=()=>{b(je()),S(Be())};e();let t=window.setInterval(e,500);return()=>window.clearInterval(t)},N=[],t[26]=M,t[27]=N):(M=t[26],N=t[27]),Q.useEffect(M,N);let P,F;t[28]===o?(P=t[29],F=t[30]):(P=()=>{if(o===`idle`)return;let e=window.setTimeout(()=>{s(`idle`)},1500);return()=>window.clearTimeout(e)},F=[o],t[28]=o,t[29]=P,t[30]=F),Q.useEffect(P,F);let I=0,L=0,R=0;for(let e of Object.keys(_)){let t=_[e]??[];L+=t.length;for(let e of t)e.role===`user`?R+=1:e.role===`assistant`&&(I+=1)}let z;t[31]!==I||t[32]!==L||t[33]!==R?(z={assistant:I,total:L,user:R},t[31]=I,t[32]=L,t[33]=R,t[34]=z):z=t[34];let ee=z,B;if(t[35]!==c||t[36]!==_||t[37]!==l||t[38]!==u||t[39]!==r){let e;t[41]!==c||t[42]!==_||t[43]!==l||t[44]!==r?(e=e=>{let t=_[e.id]??[],n=0,i=0;for(let e of t)e.role===`user`?i+=1:e.role===`assistant`&&(n+=1);let a=l.get(e.id);return{id:e.id,title:e.title||r(`memoryDebugPanel.common.untitled`),assistantMessageCount:n,messageCount:t.length,userMessageCount:i,isStreaming:a?.isStreaming||!1,isZombie:a?.isZombie||!1,backgroundCount:a?.backgroundMessageCount||0,lastAccessed:a?.lastAccessedAt||0,isCurrent:e.id===c}},t[41]=c,t[42]=_,t[43]=l,t[44]=r,t[45]=e):e=t[45],B=u.map(e).sort(zC),t[35]=c,t[36]=_,t[37]=l,t[38]=u,t[39]=r,t[40]=B}else B=t[40];let V=B,te;t[46]===_?te=t[47]:(te=Object.keys(_),t[46]=_,t[47]=te);let ne=te.length,re;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(re=async()=>{try{let e={generatedAt:new Date().toISOString(),ui:je(),vscode:Be()};await navigator.clipboard.writeText(JSON.stringify(e,null,2)),s(`copied`)}catch{s(`error`)}},t[48]=re):re=t[48];let ie=re,ae;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(ae={backgroundColor:`color-mix(in srgb, var(--surface-background) 94%, transparent)`},t[49]=ae):ae=t[49];let H;t[50]===i?H=t[51]:(H=i===`memory`?(0,$.jsx)(Z,{name:`database-2`,className:`h-4 w-4 text-[var(--surface-foreground)]`}):(0,$.jsx)(Z,{name:`bar-chart-box`,className:`h-4 w-4 text-[var(--surface-foreground)]`}),t[50]=i,t[51]=H);let U;t[52]===r?U=t[53]:(U=r(`memoryDebugPanel.title`),t[52]=r,t[53]=U);let oe;t[54]===U?oe=t[55]:(oe=(0,$.jsx)(`h3`,{className:`typography-ui-label font-semibold text-[var(--surface-foreground)]`,children:U}),t[54]=U,t[55]=oe);let W;t[56]!==H||t[57]!==oe?(W=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[H,oe]}),t[56]=H,t[57]=oe,t[58]=W):W=t[58];let se;t[59]===i?se=t[60]:(se=i===`streaming`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(J,{size:`xs`,variant:`ghost`,onClick:ie,children:(0,$.jsx)(Z,{name:`file-copy`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(J,{size:`xs`,variant:`ghost`,onClick:()=>{Ie(),b(je()),S(Be())},children:(0,$.jsx)(Z,{name:`refresh`,className:`h-3.5 w-3.5`})})]}):null,t[59]=i,t[60]=se);let ce;t[61]===n?ce=t[62]:(ce=n?(0,$.jsx)(J,{size:`icon`,variant:`ghost`,className:`h-6 w-6`,onClick:n,children:(0,$.jsx)(Z,{name:`close`,className:`h-4 w-4`})}):null,t[61]=n,t[62]=ce);let le;t[63]!==se||t[64]!==ce?(le=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[se,ce]}),t[63]=se,t[64]=ce,t[65]=le):le=t[65];let ue;t[66]!==W||t[67]!==le?(ue=(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[W,le]}),t[66]=W,t[67]=le,t[68]=ue):ue=t[68];let de;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(de={backgroundColor:`color-mix(in srgb, var(--surface-muted) 55%, transparent)`},t[69]=de):de=t[69];let fe=i===`memory`?`secondary`:`ghost`,pe;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(pe=()=>a(`memory`),t[70]=pe):pe=t[70];let me;t[71]===r?me=t[72]:(me=r(`memoryDebugPanel.tabs.memory`),t[71]=r,t[72]=me);let he;t[73]!==fe||t[74]!==me?(he=(0,$.jsx)(J,{size:`sm`,variant:fe,className:`flex-1`,onClick:pe,children:me}),t[73]=fe,t[74]=me,t[75]=he):he=t[75];let ge=i===`streaming`?`secondary`:`ghost`,_e;t[76]===Symbol.for(`react.memo_cache_sentinel`)?(_e=()=>a(`streaming`),t[76]=_e):_e=t[76];let ve;t[77]===r?ve=t[78]:(ve=r(`memoryDebugPanel.tabs.streaming`),t[77]=r,t[78]=ve);let ye;t[79]!==ge||t[80]!==ve?(ye=(0,$.jsx)(J,{size:`sm`,variant:ge,className:`flex-1`,onClick:_e,children:ve}),t[79]=ge,t[80]=ve,t[81]=ye):ye=t[81];let be;t[82]!==he||t[83]!==ye?(be=(0,$.jsxs)(`div`,{className:`mb-3 flex gap-1 rounded-md p-1`,style:de,children:[he,ye]}),t[82]=he,t[83]=ye,t[84]=be):be=t[84];let xe;t[85]!==i||t[86]!==ne||t[87]!==o||t[88]!==c||t[89]!==_||t[90]!==ee||t[91]!==l||t[92]!==V||t[93]!==u||t[94]!==j||t[95]!==y||t[96]!==r||t[97]!==v||t[98]!==x?(xe=i===`memory`?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 typography-meta`,children:[(0,$.jsx)(DC,{label:r(`memoryDebugPanel.metric.totalMessages`),value:ee.total}),(0,$.jsx)(DC,{label:r(`memoryDebugPanel.metric.cachedSessions`),value:`${ne} / ${Uo.MAX_SESSIONS}`}),(0,$.jsx)(DC,{label:r(`memoryDebugPanel.metric.userMessages`),value:ee.user}),(0,$.jsx)(DC,{label:r(`memoryDebugPanel.metric.assistantMessages`),value:ee.assistant})]}),(0,$.jsxs)(`div`,{className:`typography-meta space-y-1 border-t border-[var(--interactive-border)] pt-2`,children:[(0,$.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.viewportWindow`)}),(0,$.jsx)(`span`,{className:`text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.metric.messagesValue`,{count:Xo()})})]}),(0,$.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.zombieTimeout`)}),(0,$.jsx)(`span`,{className:`text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.metric.minutesValue`,{count:Uo.ZOMBIE_TIMEOUT/1e3/60})})]}),(0,$.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.githubTotalRequests`)}),(0,$.jsx)(`span`,{className:`text-[var(--surface-foreground)]`,children:v})]})]}),(0,$.jsxs)(`div`,{className:`border-t border-[var(--interactive-border)] pt-2`,children:[(0,$.jsx)(`div`,{className:`mb-1 typography-meta font-semibold text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.section.sessionsInMemory`)}),(0,$.jsx)(Wr,{outerClassName:`max-h-48`,className:`space-y-1 pr-1`,children:V.map(e=>(0,$.jsxs)(`div`,{className:`typography-meta flex items-center justify-between rounded p-1.5`,style:{backgroundColor:e.isCurrent?`color-mix(in srgb, var(--interactive-selection) 22%, transparent)`:`color-mix(in srgb, var(--surface-muted) 35%, transparent)`},children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-[var(--surface-foreground)]`,children:e.title}),e.isStreaming?(0,$.jsx)(Z,{name:`pulse`,className:`h-3 w-3 animate-pulse text-[var(--status-info)]`}):null,e.isZombie?(0,$.jsx)(`span`,{className:`text-[var(--status-warning)]`,children:`!`}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.roleMsgsValue`,{assistant:e.assistantMessageCount,user:e.userMessageCount})}),(0,$.jsx)(`span`,{className:`font-mono text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.metric.msgsValue`,{count:e.messageCount})}),e.backgroundCount>0?(0,$.jsxs)(`span`,{className:`text-[var(--status-info)]`,children:[`+`,e.backgroundCount]}):null]})]},e.id))})]}),(0,$.jsx)(`div`,{className:`flex gap-2 border-t border-[var(--interactive-border)] pt-2`,children:(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(J,{size:`sm`,variant:`outline`,className:`typography-meta`,onClick:()=>{u.map(BC),Object.keys(_),V.map(VC),Object.fromEntries(l)},children:r(`memoryDebugPanel.actions.logState`)})}),(0,$.jsx)(ei,{side:`top`,children:r(`memoryDebugPanel.tooltip.logCurrentState`)})]})})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-[var(--interactive-border)] px-3 py-2 typography-meta text-[var(--surface-muted-foreground)]`,children:[(0,$.jsx)(`span`,{children:r(o===`copied`?`memoryDebugPanel.streaming.copy.copied`:o===`error`?`memoryDebugPanel.streaming.copy.failed`:`memoryDebugPanel.streaming.copy.hint`)}),(0,$.jsx)(J,{size:`xs`,variant:`outline`,onClick:ie,children:r(`memoryDebugPanel.actions.copyJson`)})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsx)(DC,{label:r(`memoryDebugPanel.metric.uiMetrics`),value:y.entries.length}),(0,$.jsx)(DC,{label:r(`memoryDebugPanel.metric.vscodeMetrics`),value:x.entries.length}),(0,$.jsx)(DC,{label:r(`memoryDebugPanel.metric.messageListRenders`),value:j.messageListRender}),(0,$.jsx)(DC,{label:r(`memoryDebugPanel.metric.messageListStreamRenders`),value:j.messageListRenderStreaming}),(0,$.jsx)(DC,{label:r(`memoryDebugPanel.metric.chatMessageRenders`),value:j.chatMessageRender}),(0,$.jsx)(DC,{label:r(`memoryDebugPanel.metric.chatMessageStreamRenders`),value:j.chatMessageRenderStreaming}),(0,$.jsx)(DC,{label:r(`memoryDebugPanel.metric.chatMessageStaticDuringStream`),value:j.chatMessageRenderStaticDuringStream}),(0,$.jsx)(DC,{label:r(`memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn`),value:j.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),(0,$.jsx)(OC,{title:r(`memoryDebugPanel.section.uiStreamingMetrics`),snapshot:y,emptyLabel:r(`memoryDebugPanel.section.noUiSamples`)}),x.entries.length>0?(0,$.jsx)(OC,{title:r(`memoryDebugPanel.section.vscodeBridgeMetrics`),snapshot:x,emptyLabel:r(`memoryDebugPanel.section.noVscodeSamples`)}):null]}),t[85]=i,t[86]=ne,t[87]=o,t[88]=c,t[89]=_,t[90]=ee,t[91]=l,t[92]=V,t[93]=u,t[94]=j,t[95]=y,t[96]=r,t[97]=v,t[98]=x,t[99]=xe):xe=t[99];let Se;return t[100]!==ue||t[101]!==be||t[102]!==xe?(Se=(0,$.jsxs)(Mo,{className:`fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area`,style:ae,children:[ue,be,xe]}),t[100]=ue,t[101]=be,t[102]=xe,t[103]=Se):Se=t[103],Se};function AC(e,t){return e+t.count}function jC(e){return e.currentSessionId}function MC(e){return e.sessionMemoryState}function NC(){return Ze()}function PC(e){return e.scope}function FC(e){return!!e}function IC(e){return e.totalRequestCount}function LC(){return je()}function RC(){return Be()}function zC(e,t){return t.lastAccessed-e.lastAccessed}function BC(e){return{id:e.id,title:e.title}}function VC(e){return{id:e.id,title:e.title,total:e.messageCount,user:e.userMessageCount,assistant:e.assistantMessageCount}}var HC=()=>{let{isMobile:e,closeActiveContextPanelTab:t}=q.getState();if(e)return;let n=Wi();n&&t(n)||L()&&ee(`desktop_close_current_window`).catch(e=>{console.warn(`[menu-actions] failed to close current window`,e)})},UC=()=>{if(typeof document>`u`)return``;let e=document.activeElement;if(e instanceof HTMLTextAreaElement)return e.value.slice(e.selectionStart??0,e.selectionEnd??0);if(e instanceof HTMLInputElement){let t=e.type?.toLowerCase()??`text`;if([`text`,`search`,`url`,`tel`,`password`].includes(t))return e.value.slice(e.selectionStart??0,e.selectionEnd??0)}return e instanceof HTMLElement&&e.isContentEditable?e.ownerDocument.defaultView?.getSelection?.()?.toString()??``:``},WC=async()=>{let e=UC()||window.getSelection()?.toString()||``;if(!e.trim())return!1;try{if(typeof navigator<`u`&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}return document.execCommand(`copy`)},GC=`yuri:menu-action`,KC=`yuri:check-for-updates`,qC=e=>typeof e?.listen==`function`?`bridge`:`dom`,JC=e=>{let t=Kn(e=>e.openNewSessionDraft),n=q(e=>e.toggleCommandPalette),r=q(e=>e.setCommandPaletteOpen),i=q(e=>e.toggleHelpDialog),a=q(e=>e.toggleSidebar),o=q(e=>e.setSessionSwitcherOpen),s=q(e=>e.setActiveMainTab),c=q(e=>e.setSettingsDialogOpen),l=q(e=>e.setSettingsPage),u=q(e=>e.setAboutDialogOpen),d=q(e=>e.toggleContextPanel),f=q(e=>e.setRightSidebarOpen),p=q(e=>e.setRightSidebarTab),m=q(e=>e.toggleBottomTerminal),h=q(e=>e.setBottomTerminalExpanded),g=Dl(e=>e.checkForUpdates),{setThemeMode:_}=ai(),{t:v}=Nr(),y=Q.useRef(!1),b=typeof window>`u`?null:window.__YURI_DESKTOP__,x=qC(b),S=Q.useCallback(()=>{y.current||(y.current=!0,g().then(()=>{let{available:e,error:t}=Dl.getState();if(t){X.error(v(`sessions.sidebar.updateCheck.errorTitle`),{description:t});return}e||X.success(v(`sessions.sidebar.updateCheck.latestVersion`))}).finally(()=>{y.current=!1}))},[g,v]),C=Q.useCallback(()=>{sr.requestDirectoryDialog()},[]),w=Q.useCallback(e=>{oo(e,Kn.getState().currentSessionId,e=>{s(`chat`),o(!1),Kn.getState().setCurrentSession(e.sessionId,e.directory)})},[s,o]),T=Q.useCallback(e=>{let{activeProjectId:t,projects:n,setActiveProject:r}=un.getState();if(n.length===0)return;let i=n.findIndex(e=>e.id===t),a=e>0?0:n.length-1;i>=0&&(a=(i+e+n.length)%n.length);let o=n[a];o&&r(o.id)},[]),E=Q.useCallback(g=>{switch(g){case`about`:u(!0);break;case`settings`:c(!0);break;case`switch-instance`:l(`remote-instances`),c(!0);break;case`command-palette`:n();break;case`quick-open`:r(!0);break;case`new-session`:s(`chat`),o(!1),t();break;case`new-worktree-session`:s(`chat`),o(!1),ds();break;case`change-workspace`:C();break;case`close-tab-or-window`:HC();break;case`toggle-right-sidebar`:{let e=Wi();e&&d(e);break}case`open-right-sidebar-git`:{let e=Wi();e&&q.getState().openContextPanel(e),f(!0),p(`git`);break}case`open-right-sidebar-files`:{let e=Wi();e&&q.getState().openContextPanel(e),f(!0),p(`files`);break}case`toggle-terminal`:m();break;case`toggle-terminal-expanded`:h(!q.getState().isBottomTerminalExpanded);break;case`copy`:{let e=new Event(`yuri:copy`,{cancelable:!0});window.dispatchEvent(e)&&WC();break}case`theme-light`:_(`light`);break;case`theme-dark`:_(`dark`);break;case`theme-system`:_(`system`);break;case`toggle-sidebar`:a();break;case`toggle-memory-debug`:e?.();break;case`zoom-in`:Xa();break;case`zoom-out`:Za();break;case`zoom-reset`:lo();break;case`go-back`:G.getState().goBack();break;case`go-forward`:G.getState().goForward();break;case`previous-session`:w(-1);break;case`next-session`:w(1);break;case`previous-project`:T(-1);break;case`next-project`:T(1);break;case`help-dialog`:i();break;case`download-logs`:mo().catch(()=>{X.error(`Failed to collect OpenCode status`)})}},[C,T,w,e,t,u,s,o,r,c,l,h,f,p,_,m,n,i,d,a]);Q.useEffect(()=>{if(x!==`dom`)return;let e=e=>{let t=e.detail;t&&E(t)},t=()=>{S()};return window.addEventListener(GC,e),window.addEventListener(KC,t),()=>{window.removeEventListener(GC,e),window.removeEventListener(KC,t)}},[E,S,x]),Q.useEffect(()=>{if(x!==`bridge`)return;let e=b?.listen;if(typeof e!=`function`)return;let t=null,n=null;return e(`yuri:menu-action`,e=>{let t=e?.payload;typeof t==`string`&&E(t)}).then(e=>{t=e}).catch(()=>{}),e(`yuri:check-for-updates`,S).then(e=>{n=e}).catch(()=>{}),()=>{(async()=>{try{let e=t?.();e instanceof Promise&&await e}catch{}try{let e=n?.();e instanceof Promise&&await e}catch{}})()}},[b,E,S,x])},YC=(e,t)=>e<t?-1:+(e>t),XC=e=>JSON.stringify([...e.entries()].map(([e,t])=>[e,[...new Set(t)].sort(YC)]).sort(([e],[t])=>YC(e,t)));async function ZC({targets:e,isReady:t,fetchStatus:n,applySnapshot:r,concurrency:i=2,isDisposed:a=()=>!1}){if(!t()||a())return;let o=[...e.entries()],s=0,c=Math.min(Math.max(1,i),o.length),l=async()=>{for(;s<o.length&&t()&&!a();){let e=o[s];if(s+=1,!e)return;let[t,i]=e,c=await n(t);c===null||a()||r(t,c,i)}};await Promise.all(Array.from({length:c},()=>l()))}var QC=`yuri:tray-action`,$C=3e4,ew=120,tw=20,nw=()=>{if(typeof window>`u`)return!1;let e=window.__YURI_PLATFORM__;return e===`darwin`||e===`win32`},rw=e=>{let t=typeof e.permission==`string`?e.permission:`Permission`,n=Array.isArray(e.patterns)?e.patterns.find(e=>typeof e==`string`&&e.trim()):``;return n?`${t}: ${n}`:t},iw=e=>{let t=Array.isArray(e.questions)?e.questions[0]:void 0;return t?.header||t?.question||`Question`},aw=e=>kn(e),ow=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n>=0?t.slice(n+1):t},sw=(e,t,n,r)=>{if(!e)return``;let i=Xt(t,n,e),a=ow(i?i.path:e),o=Mn(e),s=o&&r.get(o)||``;if(!s){for(let[e,t]of Qi.getState().directories)if(Mn(e)===o){s=t.status?.current??``;break}}if(!s)for(let e of n.values()){let t=e.find(e=>Mn(e.path)===o);if(t?.branch){s=t.branch;break}}return s?`${a} · ${s}`:a},cw=()=>{let{results:e,dropdownProviderIds:t,displayMode:n}=Xs.getState(),r=n===`remaining`?`remaining`:`usage`;if(!t.length)return{mode:r,groups:[]};let i=new Map(e.map(e=>[e?.providerId,e])),a=[];for(let n of Zs(e)){if(!t.includes(n.id))continue;let e=i.get(n.id);if(!e||e.configured!==!0)continue;let o=[];for(let[t,n]of Object.entries(e.usage?.windows??{})){let e=r===`remaining`?n.remainingPercent:n.usedPercent;o.push({label:tc(n.label??t),value:Qs(n.valueLabel,e)})}let s=!e.ok&&e.error?e.error:o.length===0?`No rate limits reported`:null;a.push({provider:n.name,rows:o,status:s})}return{mode:r,groups:a}},lw=async()=>{try{if(x())return`Local Yuri`;let e=window.__YURI_LOCAL_ORIGIN__||window.location.origin,t=h();if(t&&W(t,e))return`Local Yuri`;let n=(await ce()).hosts.find(e=>t?W(t,oe(e)):!1);return n?.label?.trim()?le(n.label.trim()):`Instance`}catch{return``}},uw=()=>{let e=new Map,t=new Map,n=[],r=new Map,i;try{i=$e()}catch{return{statusById:e,branchByDirectory:t,approvals:n,titleById:r}}for(let[a,o]of i.children.entries()){let i=o.getState(),s=typeof i.vcs?.branch==`string`?i.vcs.branch:typeof i.vcs?.branch?.current==`string`?i.vcs.branch.current:``;s&&t.set(Mn(a)??a,s);for(let e of i.session)!e?.id||!e.title||r.set(e.id,e.title);for(let[t,n]of Object.entries(i.session_status??{})){let r=n?.type,i=r===`busy`?`busy`:r===`retry`?`retry`:`idle`,a=e.get(t);(!a||a===`idle`)&&e.set(t,i)}for(let[e,t]of Object.entries(i.permission??{}))for(let r of t??[]){if(!r?.id)continue;let t=r.sessionID||e;n.push({kind:`permission`,id:r.id,sessionId:t,sessionTitle:``,label:rw(r),directory:a})}for(let[e,t]of Object.entries(i.question??{}))for(let r of t??[]){if(!r?.id)continue;let t=r.sessionID||e;n.push({kind:`question`,id:r.id,sessionId:t,sessionTitle:``,label:iw(r),directory:a})}}return{statusById:e,branchByDirectory:t,approvals:n,titleById:r}},dw=()=>{let e=pn.getState().activeSessions,t=new Set;e.filter(e=>e?.id&&!e.parentID).slice().sort((e,t)=>aw(t)-aw(e)).slice(0,tw).forEach(e=>{let n=gn(e);n&&t.add(n)});let n=new Map;for(let r of e){if(!r?.id)continue;let e=gn(r);if(!e||!t.has(e))continue;let i=n.get(e)??[];i.push(r.id),n.set(e,i)}return n},fw=e=>{let t=uw(),n=cn.getState().index.session,r=pn.getState().activeSessions,i=new Map(t.titleById),a=new Map;for(let e of r)if(e?.id&&(e.title&&i.set(e.id,e.title),e.parentID)){let t=a.get(e.parentID)??[];t.push(e.id),a.set(e.parentID,t)}let o=e=>{let t=[],n=[...a.get(e)??[]],r=new Set;for(;n.length;){let e=n.pop();r.has(e)||(r.add(e),t.push(e),n.push(...a.get(e)??[]))}return t},s=xr.getState().statusById,c=e=>{let n=t.statusById.get(e);return n&&n!==`idle`?n:s.get(e)?.status??n??`idle`},l=e=>{let t=e.map(e=>c(e));return t.includes(`busy`)?`busy`:t.includes(`retry`)?`retry`:`idle`},u=un.getState().projects,d=Kn.getState().availableWorktreesByProject,f=r.filter(e=>e?.id&&!e.parentID).slice().sort((e,t)=>aw(t)-aw(e)).slice(0,tw).map(e=>{let r=[e.id,...o(e.id)],i=gn(e)??``;return{id:e.id,title:e.title||`Untitled session`,status:l(r),branch:i?t.branchByDirectory.get(i)??``:``,unseen:n.unseenCount[e.id]??0,hasError:n.unseenHasError[e.id]??!1,directory:i,subtitle:sw(i,u,d,t.branchByDirectory)}}),p=t.approvals.map(e=>({...e,sessionTitle:i.get(e.sessionId)||``})),m=q.getState(),h=0;if(m.dockBadgeEnabled)for(let e of r)!e?.id||e.parentID||(n.unseenCount[e.id]??0)>0&&(h+=1);return{sessions:f,approvals:p,instanceName:e,usage:cw(),dockBadgeCount:h}},pw=()=>{Q.useEffect(()=>{if(!nw()||!L())return;let e=!1,t=``,n=null,r=``,i=()=>{if(e)return;let n=fw(r),i=JSON.stringify(n);i!==t&&(t=i,ee(`desktop_tray_update`,n))};lw().then(t=>{e||(r=t,i())});let a=null,o=``,s=()=>{let e=jn.getState();return e.isConnected&&e.connectionPhase===`connected`},c=()=>{if(a)return a;let t=dw();return o=XC(t),a=ZC({targets:t,isReady:s,concurrency:2,isDisposed:()=>e,fetchStatus:async()=>{try{let e=await nt.getSdkClient().session.active();if(!e||typeof e!=`object`||Array.isArray(e))return null;let t={};for(let[n,r]of Object.entries(e))r?.type===`running`&&(t[n]={type:`busy`});return t}catch{return null}},applySnapshot:(e,t,n)=>{Rn(e,t,[...n])}}).finally(()=>{a=null;let t=dw();!e&&s()&&XC(t)!==o&&c()}),a},l=()=>{e||n!==null||(n=window.setTimeout(()=>{n=null,i()},ew))},u=new Map,d=()=>{if(e)return;let t;try{t=$e()}catch{return}let n=new Set;for(let[e,r]of t.children.entries())n.add(e),u.has(e)||u.set(e,r.subscribe(()=>l()));for(let[e,t]of u)n.has(e)||(t(),u.delete(e))},f=null;try{f=$e().subscribeRegistry(()=>{d(),l()})}catch{}d();let p=cn.subscribe(()=>l()),m=pn.subscribe(()=>{l(),s()&&XC(dw())!==o&&c()}),h=un.subscribe(()=>l()),g=Kn.subscribe(()=>l()),_=Qi.subscribe(()=>l()),v=q.subscribe(()=>l()),y=xr.subscribe(()=>l()),b=s(),x=jn.subscribe(()=>{let e=s();e&&!b&&c(),b=e});b&&c();let S=Xs.subscribe(()=>l());Xs.getState().loadSettings().then(()=>{if(e)return;let{dropdownProviderIds:t,results:n}=Xs.getState();t.length>0&&t.some(e=>!n.some(t=>t?.providerId===e))&&Xs.getState().fetchAllQuotas()});let C=window.setInterval(()=>{let e=Xs.getState();e.autoRefresh&&e.dropdownProviderIds.length>0&&e.fetchAllQuotas()},Math.max(3e4,Xs.getState().refreshIntervalMs||6e4)),w=window.setInterval(()=>{d(),i()},$C);return i(),()=>{e=!0,n!==null&&window.clearTimeout(n),window.clearInterval(w),window.clearInterval(C),p(),m(),h(),g(),_(),v(),y(),x(),S(),f?.();for(let e of u.values())e();u.clear()}},[]),Q.useEffect(()=>{if(!nw()||typeof window>`u`)return;let e=window.__YURI_DESKTOP__?.listen;if(typeof e!=`function`)return;let t=e=>{e.type===`respond-permission`&&ar(e.sessionId,e.id,e.response).catch(()=>{X.error(`Failed to respond to permission request`)})},n=null;return e(QC,e=>{let n=e?.payload;!n||typeof n!=`object`||typeof n.type!=`string`||t(n)}).then(e=>{n=e}).catch(()=>{}),()=>{try{let e=n?.();e instanceof Promise&&e.catch(()=>{})}catch{}}},[])},mw=`/api/notifications/stream`,hw=()=>typeof document>`u`||document.visibilityState===`visible`&&document.hasFocus(),gw=e=>{if(!e||typeof e!=`object`)return null;let t=e,n=t.properties&&typeof t.properties==`object`?t.properties:null;return t.type!==`yuri:notification`||!n?null:{title:typeof n.title==`string`?n.title:void 0,body:typeof n.body==`string`?n.body:void 0,tag:typeof n.tag==`string`?n.tag:void 0,requireHidden:n.requireHidden===!0||n.requireHidden!==!1&&void 0}},_w=e=>{let t=(0,ju.c)(3),n=e?.enabled??!0,r,i;t[0]===n?(r=t[1],i=t[2]):(r=()=>{if(!n||C()||!y()||typeof window>`u`||typeof EventSource>`u`)return;let e=new EventSource(l().sse(mw));return e.onmessage=vw,()=>{e.close()}},i=[n],t[0]=n,t[1]=r,t[2]=i),Q.useEffect(r,i)};function vw(e){let t;try{t=JSON.parse(e.data)}catch{return}let n=q.getState();if(!n.nativeNotificationsEnabled)return;let r=gw(t);r&&((r.requireHidden??n.notificationMode!==`always`)&&hw()||U()?.notifications?.notifyAgentCompletion(r))}var yw=`pwa-install-toast-shown`,bw=`pwa-install-toast-dismissed`,xw=()=>{let e=(0,ju.c)(6),{browserTab:t}=fu(),{t:n}=Nr(),r=Q.useRef(n),i,a;e[0]===n?(i=e[1],a=e[2]):(i=()=>{r.current=n},a=[n],e[0]=n,e[1]=i,e[2]=a),Q.useEffect(i,a);let o,s;e[3]===t?(o=e[4],s=e[5]):(o=()=>{if(typeof window>`u`||!y()||!t)return;let e=null,n=null,i=()=>{n!==null&&(X.dismiss(n),n=null)},a=async()=>{if(!e)return;let t=e;e=null,i(),await t.prompt();let{outcome:n}=await t.userChoice;n===`accepted`&&X.success(r.current(`pwa.installPrompt.started`))},o=t=>{let o=t;if(typeof o.prompt!=`function`)return;o.preventDefault(),e=o;let s=He(),c=Ue();jc({dismissed:s.getItem(bw),sessionShown:c.getItem(yw),hasActiveToast:n!==null})&&(c.setItem(yw,`true`),n=X.info(r.current(`pwa.installPrompt.description`),{duration:1/0,action:{label:r.current(`pwa.installPrompt.action`),onClick:()=>{a()}},cancel:{label:r.current(`pwa.installPrompt.dismiss`),onClick:()=>{He().setItem(bw,`true`),i()}}}))},s=()=>{e=null,i(),X.success(r.current(`pwa.installPrompt.installed`))};return window.addEventListener(`beforeinstallprompt`,o),window.addEventListener(`appinstalled`,s),()=>{i(),window.removeEventListener(`beforeinstallprompt`,o),window.removeEventListener(`appinstalled`,s)}},s=[t],e[3]=t,e[4]=o,e[5]=s),Q.useEffect(o,s)},Sw=0;function Cw(e){let t=typeof e?.sessionId==`string`?e.sessionId.trim():``;if(!t)return;let n=++Sw,r=typeof e?.directory==`string`&&e.directory.trim().length>0?e.directory.trim():null;if(q.getState().setActiveMainTab(`chat`),e.hostId||e.hubId||e.instanceId){if(!e.hostId||!e.hubId||!r)return;Lt(async()=>{let{applyRemoteProjectRoute:e}=await import(`./navigation-DFmCAq2g.js`).then(e=>e.n);return{applyRemoteProjectRoute:e}},__vite__mapDeps([213,1,3,2,19,8,9,20,39,5,4,6,7,24,10,40,25,22,26,41,42,43,44,14,11,13,12,15,16,17,18,21,23,27,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59])).then(({applyRemoteProjectRoute:i})=>{if(n===Sw)return i({sessionId:t,directory:r,hostId:e.hostId,hubId:e.hubId,...e.instanceId?{instanceId:e.instanceId}:{},isNewSession:!1},()=>n===Sw)}).catch(()=>console.warn(`[remote-session] Notification navigation failed`));return}Kn.getState().setCurrentSession(t,r)}var ww=({open:e,onOpenChange:t})=>{let{t:n}=Nr(),[r,i]=Q.useState(null),[a,o]=Q.useState(null);Q.useEffect(()=>{e&&(async()=>{try{let e=await g(`/api/system/info`);if(e.ok){let t=await e.json();if(typeof t.yuriVersion==`string`&&t.yuriVersion.trim()){i(t.yuriVersion);return}}}catch{}i(await Ar())})()},[e]),Q.useEffect(()=>{if(!e)return;let t=!1;return(async()=>{try{let e=await g(`/api/opencode/upgrade-status`,{headers:{Accept:`application/json`}});if(!e.ok)return;let n=await e.json().catch(()=>null),r=typeof n?.currentVersion==`string`?n.currentVersion.trim():``;!t&&r&&o(r)}catch{}})(),()=>{t=!0}},[e]);let s=r;return(0,$.jsx)(Qr,{open:e,onOpenChange:t,children:(0,$.jsx)(Yr,{className:`max-w-xs p-5`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:[(0,$.jsx)(jo,{width:48,height:48}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Yuri`}),(0,$.jsxs)(`div`,{className:`space-y-0.5 typography-meta text-muted-foreground`,children:[s&&(0,$.jsx)(`p`,{children:n(`aboutDialog.yuriVersionLabel`,{version:s})}),a&&(0,$.jsx)(`p`,{children:n(`aboutDialog.openCodeVersionLabel`,{version:a})})]})]}),(0,$.jsx)(`div`,{className:`flex items-center justify-center`,children:(0,$.jsxs)(`a`,{href:`https://github.com/yee94/yuri`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors`,children:[(0,$.jsx)(Z,{name:`github-fill`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:`GitHub`})]})}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/60`,children:n(`aboutDialog.footerNote`)})]})})})},Tw=(e,t)=>{let n=e.get(t);return typeof n==`string`&&n.trim()||null},Ew=(e,t)=>{let n=e instanceof Error?e.message:t;return/oauth state required/i.test(n)?`Authorization session expired or was cleared during reload. Return to Yuri and click Authorize again.`:n},Dw=()=>{let e=Fl(e=>e.completeAuth),[t,n]=Q.useState(`working`),[r,i]=Q.useState(`Completing MCP authorization...`);return Q.useEffect(()=>{if(typeof window>`u`){n(`error`),i(`Browser context unavailable.`);return}let t=new URLSearchParams(window.location.search),r=Tw(t,`code`),a=uu(t),o=au(t),s=Tw(t,`error`),c=Tw(t,`error_description`);if(s){o&&g(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`,{method:`DELETE`}).catch(()=>void 0),n(`error`),i(c??s);return}(async()=>{try{if(!r)throw Error(`Missing OAuth authorization code. Start authorization again from MCP Settings or paste the returned code into Yuri manually.`);let t=a;if(!t&&o){let e=await g(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`);if(e.ok){let n=await e.json().catch(()=>null);n?.name?.trim()&&(t={name:n.name.trim(),directory:typeof n.directory==`string`&&n.directory.trim()?n.directory.trim():null})}}if(!t?.name)throw Error(`Authorization session details were not available. Start authorization again from MCP Settings or paste the returned code into Yuri manually.`);await e(t.name,r,t.directory),o&&await g(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`,{method:`DELETE`}).catch(()=>void 0),n(`success`),i(`Authorization completed. You can close this tab and return to Yuri.`)}catch(e){o&&await g(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`,{method:`DELETE`}).catch(()=>void 0),n(`error`),i(Ew(e,`Failed to complete MCP authorization.`))}})()},[e]),(0,$.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-background px-6 py-12 text-foreground`,children:(0,$.jsxs)(`div`,{className:`w-full max-w-xl rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-8 shadow-sm dark:shadow-none`,children:[(0,$.jsxs)(`div`,{className:`space-y-3 text-center`,children:[(0,$.jsx)(`div`,{className:t===`error`?`text-[var(--status-error)]`:t===`success`?`text-[var(--status-success)]`:`text-[var(--status-info)]`,children:(0,$.jsx)(`h1`,{className:`typography-hero font-semibold`,children:t===`working`?`Completing Authorization`:t===`success`?`Authorization Complete`:`Authorization Failed`})}),(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:r})]}),t!==`working`&&(0,$.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,$.jsx)(J,{type:`button`,onClick:()=>{typeof window>`u`||window.location.replace(`/`)},children:`Return to Yuri`})})]})})},Ow=()=>{let e=pn(e=>e.startupSyncProgress.active),t=pn(e=>e.startupSyncProgress.phase),n=pn(e=>e.startupSyncProgress.completed),r=pn(e=>e.startupSyncProgress.total),{locale:i,t:a}=Nr(),[o,s]=Q.useState(!0),c=qt(i).startingApi;Q.useEffect(()=>{let e=!1,t=async()=>{try{let t=await(await g(`/health`,{signal:AbortSignal.timeout(4e3)})).json().catch(()=>null);if(e)return;let n=t?.openCodeStarting===!0||t?.isOpenCodeReady!==!0&&!t?.lastOpenCodeError;s(n)}catch{e||s(!0)}};t();let n=window.setInterval(()=>{t()},750);return()=>{e=!0,window.clearInterval(n)}},[]);let l=r>0?Math.round(n/r*100):0,u=t===`restoring`?a(`common.loading`):a(`sessions.startupSync.progress`,{completed:n,total:r});return Q.useLayoutEffect(()=>{let t=document.getElementById(`startup-session-progress`),i=document.getElementById(`startup-session-progress-track`),s=document.getElementById(`startup-session-progress-fill`),d=document.getElementById(`startup-session-progress-text`);if(!(!t||!i||!s||!d)){if(e){t.hidden=!1,s.style.width=`${l}%`,i.setAttribute(`aria-label`,a(`sessions.startupSync.title`)),i.setAttribute(`aria-valuemax`,String(Math.max(r,1))),i.setAttribute(`aria-valuenow`,String(n)),i.setAttribute(`aria-valuetext`,u),d.textContent=u;return}if(o){t.hidden=!1,s.style.width=`30%`,i.setAttribute(`aria-label`,c),i.setAttribute(`aria-valuetext`,c),d.textContent=c;return}t.hidden=!0}},[e,n,o,l,u,c,a,r]),null},kw=(e,t,n,r=350)=>n?Math.max(0,r-Math.max(0,t-e)):null;function Aw(e){let t=(0,ju.c)(21),{transition:n,ready:r}=e,{t:i}=Nr(),a=To(!0),[o,s]=Q.useState(0),c=n.epoch>o,l=a||c,u,d;if(t[0]!==c||t[1]!==a||t[2]!==r||t[3]!==n.epoch||t[4]!==n.startedAt?(u=()=>{if(!c||a)return;let e=kw(n.startedAt,Date.now(),r);if(e===null)return;let t=window.setTimeout(()=>{s(e=>Math.max(e,n.epoch))},e);return()=>window.clearTimeout(t)},d=[c,a,r,n.epoch,n.startedAt],t[0]=c,t[1]=a,t[2]=r,t[3]=n.epoch,t[4]=n.startedAt,t[5]=u,t[6]=d):(u=t[5],d=t[6]),Q.useEffect(u,d),!l)return null;let f;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 opacity-70`,"aria-hidden":`true`,children:[(0,$.jsx)(`div`,{className:`absolute left-1/2 top-1/2 size-[28rem] -translate-x-1/2 -translate-y-1/2 rounded-full border border-[var(--interactive-border)]/40`}),(0,$.jsx)(`div`,{className:`absolute left-1/2 top-1/2 size-72 -translate-x-1/2 -translate-y-1/2 rounded-full bg-[var(--interactive-selection)]/10 blur-3xl`})]}),t[7]=f):f=t[7];let p;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(`div`,{className:`mb-7 flex size-28 items-center justify-center rounded-[2rem] border border-[var(--interactive-border)]/60 bg-[var(--surface-elevated)]/75 shadow-2xl shadow-background/40`,children:(0,$.jsx)(jo,{width:76,height:76,isAnimated:!0})}),t[8]=p):p=t[8];let m;t[9]===i?m=t[10]:(m=i(`desktopHostSwitcher.transition.title`),t[9]=i,t[10]=m);let h;t[11]===m?h=t[12]:(h=(0,$.jsx)(`h1`,{className:`typography-title text-foreground`,children:m}),t[11]=m,t[12]=h);let g;t[13]===i?g=t[14]:(g=i(`desktopHostSwitcher.transition.description`),t[13]=i,t[14]=g);let _;t[15]===g?_=t[16]:(_=(0,$.jsx)(`p`,{className:`mt-2 typography-body text-muted-foreground`,children:g}),t[15]=g,t[16]=_);let v;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(`div`,{className:`mt-7 h-1 w-28 overflow-hidden rounded-full bg-[var(--surface-muted)]`,"aria-hidden":`true`,children:(0,$.jsx)(`div`,{className:`h-full w-1/2 animate-pulse rounded-full bg-[var(--status-info)] motion-reduce:animate-none`})}),t[17]=v):v=t[17];let y;return t[18]!==h||t[19]!==_?(y=(0,$.jsxs)(`div`,{className:`fixed inset-0 z-[9998] flex items-center justify-center overflow-hidden bg-background/95 px-6 backdrop-blur-xl`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:[f,(0,$.jsxs)(`div`,{className:`relative flex max-w-md animate-in flex-col items-center text-center fade-in zoom-in-95 duration-300 motion-reduce:animate-none`,children:[p,h,_,v]})]}),t[18]=h,t[19]=_,t[20]=y):y=t[20],y}var jw=ba(()=>Lt(()=>import(`./OnboardingScreen-CDHtDQ0k.js`).then(e=>({default:e.OnboardingScreen})),__vite__mapDeps([214,1,4,2,5,3,6,7,8,9,103,10,40,24,25,22,26,41,42,43,44,14,11,13,12,15,16,17,18,19,20,21,23,27,45,39,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,64,65,117,146,67]))),Mw=36e5,Nw=12e5,Pw=()=>{let e=(0,ju.c)(3),t=q(Vw),n=q(Hw),r;return e[0]!==t||e[1]!==n?(r=(0,$.jsx)(ww,{open:t,onOpenChange:n}),e[0]=t,e[1]=n,e[2]=r):r=e[2],r},Fw=e=>{let t=(0,ju.c)(21),{onRetry:n,isRetrying:r}=e,{t:i}=Nr(),a;t[0]===i?a=t[1]:(a=i(`startup.initRecovery.title`),t[0]=i,t[1]=a);let o;t[2]===a?o=t[3]:(o=(0,$.jsx)(`h1`,{className:`typography-title text-foreground`,children:a}),t[2]=a,t[3]=o);let s;t[4]===i?s=t[5]:(s=i(`startup.initRecovery.description`),t[4]=i,t[5]=s);let c;t[6]===s?c=t[7]:(c=(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:s}),t[6]=s,t[7]=c);let l;t[8]!==o||t[9]!==c?(l=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[o,c]}),t[8]=o,t[9]=c,t[10]=l):l=t[10];let u;t[11]!==r||t[12]!==i?(u=i(r?`startup.initRecovery.retrying`:`startup.initRecovery.retry`),t[11]=r,t[12]=i,t[13]=u):u=t[13];let d;t[14]!==r||t[15]!==n||t[16]!==u?(d=(0,$.jsx)(J,{type:`button`,onClick:n,disabled:r,children:u}),t[14]=r,t[15]=n,t[16]=u,t[17]=d):d=t[17];let f;return t[18]!==l||t[19]!==d?(f=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center bg-background px-6 text-foreground`,children:(0,$.jsxs)(`div`,{className:`flex max-w-md flex-col items-center gap-4 text-center`,children:[l,d]})}),t[18]=l,t[19]=d,t[20]=f):f=t[20],f},Iw=e=>e?e.replace(/\\/g,`/`).replace(/\/+$/g,``):``,Lw=()=>{if(typeof window>`u`||!Io())return null;let e=new URLSearchParams(window.location.search),t=e.get(`sessionId`),n=typeof t==`string`?t.trim():``;if(!n)return null;let r=e.get(`directory`);return{sessionId:n,directory:typeof r==`string`&&r.trim().length>0?r.trim():null,readOnly:e.get(`readOnly`)===`1`||e.get(`readOnly`)===`true`}},Rw=()=>typeof window>`u`?!1:window.location.pathname===du,zw=e=>{let t=(0,ju.c)(22),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=e,a=G(Uw),o=Kn(Ww),s=Kn(Gw),c=ps(),l=Q.useRef(null),u;t[0]===n.directory?u=t[1]:(u=Iw(n.directory),t[0]=n.directory,t[1]=u);let d=u,f;t[2]===a?f=t[3]:(f=Iw(a),t[2]=a,t[3]=f);let p=f,m,h;if(t[4]!==p||t[5]!==o||t[6]!==n.directory||t[7]!==n.sessionId||t[8]!==d||t[9]!==r||t[10]!==s||t[11]!==c?(m=()=>{if(r||d&&p!==d)return;let e=`${d}\n${n.sessionId}`;l.current===e&&o||(l.current=e,s(n.sessionId,n.directory),c.ensureSessionRenderable(n.sessionId,!0))},h=[p,o,n.directory,n.sessionId,d,r,s,c],t[4]=p,t[5]=o,t[6]=n.directory,t[7]=n.sessionId,t[8]=d,t[9]=r,t[10]=s,t[11]=c,t[12]=m,t[13]=h):(m=t[12],h=t[13]),Q.useEffect(m,h),d&&p!==d)return null;let g;t[14]===i?g=t[15]:(g=(0,$.jsx)(eo,{embeddedBackgroundWorkEnabled:i}),t[14]=i,t[15]=g);let _;t[16]===n.readOnly?_=t[17]:(_=(0,$.jsx)(Xl,{readOnly:n.readOnly}),t[16]=n.readOnly,t[17]=_);let v;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(Fa,{}),t[18]=v):v=t[18];let y;return t[19]!==g||t[20]!==_?(y=(0,$.jsxs)($.Fragment,{children:[g,_,v]}),t[19]=g,t[20]=_,t[21]=y):y=t[21],y};function Bw({apis:e}){Q.useEffect(()=>{Ge(`App:mounted`),Ke()},[]),Q.useEffect(()=>ir(),[]);let t=jn(e=>e.initializeApp),n=jn(e=>e.isInitialized),r=jn(e=>e.isConnected),i=Kn(e=>e.error),a=Kn(e=>e.clearError),o=Kn(e=>!(e.newSessionDraft?.open&&e.currentSessionId===null)),s=G(e=>e.currentDirectory),l=G(e=>e.setDirectory),u=G(e=>e.isSwitchingDirectory),[d,p]=Q.useState(!1),m=Nl(e=>e.refreshStatus),[h,g]=Q.useState(()=>e.runtime.isVSCode),[_,v]=Q.useState(!1),[y,S]=Q.useState(!1),[w,T]=Q.useState(0),[O,A]=Q.useState(0),[j,M]=Q.useState({epoch:0,startedAt:0}),[P,I]=Q.useState(!1),L=Q.useRef(!1),z=q(e=>e.wideChatLayoutEnabled),B=q(e=>e.mobileKeyboardMode),V=Q.useMemo(()=>C(),[]),ne=pn(e=>e.hasCachedSessionIndex),re=pn(e=>e.hasHydratedSessionIndex),[ae,U]=Q.useState(()=>te()),[oe,W]=Q.useState(()=>{let e=ie();return e===null?null:F({isDesktopShell:!0,bootOutcome:e})}),se=Q.useRef(!1),ce=Q.useMemo(()=>Lw(),[]),le=!ce||_,ue=Q.useMemo(()=>Rw(),[]);Q.useEffect(()=>(Me(d),()=>{Me(!1)}),[d]),Q.useEffect(()=>{Vt(B)},[B]),Q.useEffect(()=>{g(e.runtime.isVSCode)},[e.runtime.isVSCode]),Q.useEffect(()=>{let e=za(e=>{f(e)&&(V&&M(e=>({epoch:e.epoch+1,startedAt:Date.now()})),cl(e),A(e=>e+1),S(!1),T(e=>e+1))}),t=c(t=>e.schedule(t));return()=>{t(),e.cancel()}},[V]),Q.useEffect(()=>(document.documentElement.classList.toggle(`wide-chat-layout`,z),()=>{document.documentElement.classList.remove(`wide-chat-layout`)}),[z]),Q.useEffect(()=>(H(e),()=>H(null)),[e]),Q.useEffect(()=>{if(ce)return;let t=!1;return tn().then(()=>{t||m(e.github,{force:!0})}),()=>{t=!0}},[e.github,ce,m]),co();let de=ae===`valid`,fe=oe?.screen===`main`,[pe,me]=Q.useState(!1);Q.useEffect(()=>{if(!le||!N({isDesktopShell:V,isInitialized:V&&fe?ne||n&&re:n,bootOutcomeKnown:de,bootViewIsMain:fe}))return;let e,t=setTimeout(()=>{let t=document.getElementById(`initial-loading`);t?(t.classList.add(`fade-out`),e=setTimeout(()=>{t.remove(),me(!0)},300)):me(!0)},150);return()=>{clearTimeout(t),e&&clearTimeout(e)}},[le,V,n,de,fe,ne,re]),Q.useEffect(()=>{if(!V||ae!==`malformed`)return;let e=document.getElementById(`initial-loading`);e&&(e.textContent=`Desktop startup failed — please restart the app.`)},[V,ae]),Q.useEffect(()=>{if(!le||V)return;let e,t=setTimeout(()=>{let t=document.getElementById(`initial-loading`);t&&!n&&(t.classList.add(`fade-out`),e=setTimeout(()=>{t.remove()},300))},5e3);return()=>{clearTimeout(t),e&&clearTimeout(e)}},[le,V,n]),Q.useEffect(()=>{if(!le||h)return;let e=!1;return tn().then(()=>{if(!e)return t()}),()=>{e=!0}},[le,t,h]),Q.useEffect(()=>{if(!le||h||n)return;let e=!0,t,r=0,i=1e3,a=async()=>{if(!e)return;if(r>=10){S(!0);return}let n=jn.getState();if(n.isInitialized){S(!1);return}if(r+=1,await tn(),!e)return;await n.initializeApp();let o=jn.getState();if(!e)return;if(o.isInitialized){S(!1);return}if(r>=10){S(!0);return}let s=Math.min(i*2**(r-1),16e3);t=setTimeout(a,s)};return t=setTimeout(a,i),()=>{e=!1,t&&clearTimeout(t)}},[le,w,n,h]),Q.useEffect(()=>{le&&n&&S(!1)},[le,n]),Q.useEffect(()=>{if(!le||!y)return;let e=document.getElementById(`initial-loading`);if(e){e.classList.add(`fade-out`);let t=setTimeout(()=>{e.remove()},300);return()=>clearTimeout(t)}},[le,y]),Ka({enabled:le&&!h,source:`startupRecovery`}),Q.useEffect(()=>{u||h||r&&nt.setDirectory(s)},[s,u,r,h]),Q.useEffect(()=>{if(!ce||typeof window>`u`)return;let e=e=>{let t=e?.visible===!0;v(t)},t=t=>{if(t.origin!==window.location.origin)return;let n=t.data;n?.type===`yuri:embedded-visibility`&&e(n.payload)},n=window;return n.__yuriSetEmbeddedVisibility=e,window.addEventListener(`message`,t),window.parent&&window.parent!==window&&window.parent.postMessage({type:Lo},window.location.origin),()=>{window.removeEventListener(`message`,t),n.__yuriSetEmbeddedVisibility===e&&delete n.__yuriSetEmbeddedVisibility}},[ce]),Q.useEffect(()=>{!ce?.directory||h||s!==ce.directory&&l(ce.directory,{showOverlay:!1})},[s,ce,h,l]),Q.useEffect(()=>{if(!ce||typeof window>`u`)return;let e=e=>{e.storageArea===window.localStorage&&e.key===`ui-store`&&q.persist.rehydrate()};return window.addEventListener(`storage`,e),()=>{window.removeEventListener(`storage`,e)}},[ce]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail;Cw(t??{})},t=e=>{let t=e.detail;Lt(async()=>{let{openSessionFromDeepLink:e}=await import(`./openSessionFromDeepLink-DsZnNy4W.js`);return{openSessionFromDeepLink:e}},__vite__mapDeps([215,20,1,23,5,3,2,6,7,8,9,24,10,25,22,26,27,39,4,40,41,42,43,44,14,11,13,12,15,16,17,18,19,21,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,208])).then(({openSessionFromDeepLink:e})=>e(t??{}))},n=b()?.handleProbe(e=>Lt(async()=>{let{probeSessionLink:e}=await import(`./openSessionFromDeepLink-DsZnNy4W.js`);return{probeSessionLink:e}},__vite__mapDeps([215,20,1,23,5,3,2,6,7,8,9,24,10,25,22,26,27,39,4,40,41,42,43,44,14,11,13,12,15,16,17,18,19,21,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,208])).then(({probeSessionLink:t})=>t(e))),r=e=>{let t=e.detail?.assistantID;typeof t==`string`&&t.trim()&&Hr(t.trim())},i=e=>{let t=e.detail,n=t?.projectID,r=t?.taskID;n&&r&&Lt(async()=>{let{openScheduledTask:e}=await import(`./scheduledTaskNavigation-r3g3DfXq.js`).then(e=>e.n);return{openScheduledTask:e}},__vite__mapDeps([168,1,23,5,3,2,6,7,8,9,24,10,25,22,26,27,20,135,136])).then(({openScheduledTask:e})=>e(n,r))};return window.addEventListener(`yuri:open-session`,e),window.addEventListener(`yuri:open-session-link`,t),window.addEventListener(`yuri:open-assistant`,r),window.addEventListener(`yuri:open-scheduled-task`,i),()=>{window.removeEventListener(`yuri:open-session`,e),window.removeEventListener(`yuri:open-session-link`,t),n?.(),window.removeEventListener(`yuri:open-assistant`,r),window.removeEventListener(`yuri:open-scheduled-task`,i)}},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=()=>{let e=G.getState().currentDirectory,{activeProjectId:t,projects:n}=un.getState(),r=n.find(e=>e.id===t)??null;ee(`desktop_open_draft_mini_chat_window`,{directory:e||r?.path||``,projectId:r?.id??null})};return window.addEventListener(`yuri:open-mini-chat`,e),()=>window.removeEventListener(`yuri:open-mini-chat`,e)},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=()=>{if(sn.getState().remoteSession)return;let e=Kn.getState().currentSessionId;e&&Cn(e)};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=0,t=t=>{let n=++e,r=t.detail,i=typeof r?.directory==`string`&&r.directory.trim().length>0?r.directory.trim():null,a=typeof r?.projectId==`string`&&r.projectId.trim().length>0?r.projectId.trim():null,o=typeof r?.initialPrompt==`string`&&r.initialPrompt.trim().length>0?r.initialPrompt.trim():void 0;q.getState().setActiveMainTab(`chat`),q.getState().setSessionSwitcherOpen(!1);let s=un.getState(),c=s.projects.find(e=>e.id===(a??(i?null:s.activeProjectId)));if(r?.hostId){let t=sn.getState().remoteSession,c=s.activeProjectId;Bl({sessionId:null,isNewSession:!0,hostId:r.hostId,hubId:r.hubId,directory:i,projectId:a},()=>n===e&&sn.getState().remoteSession===t&&un.getState().activeProjectId===c).then(async e=>{if(!e)return;let t=sn.getState().remoteSession;o&&t&&await zl(t.location,o)}).catch(e=>X.error(e instanceof Error?e.message:String(e)));return}if(c?.hostId&&c.hubId){let e={hubId:c.hubId,hostId:c.hostId,directory:c.path};s.setActiveProjectIdOnly(c.id),sn.getState().openRemoteSession(c,e,null),o&&zl(e,o).catch(e=>X.error(e instanceof Error?e.message:String(e)));return}sn.getState().clearRemoteSession(),Kn.getState().openNewSessionDraft({selectedProjectId:a,directoryOverride:i,preserveDirectoryOverride:!!i,ensureProjectForDirectory:!!i,initialPrompt:o})};return window.addEventListener(`yuri:open-draft-session`,t),()=>{e+=1,window.removeEventListener(`yuri:open-draft-session`,t)}},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail,n=typeof t?.projectPath==`string`?t.projectPath.trim():``;if(!n)return;let r=un.getState(),i=r.projects.find(e=>!e.hostId&&e.path===n);i?r.setActiveProject(i.id):r.addProject(n)};return window.addEventListener(`yuri:open-project`,e),()=>window.removeEventListener(`yuri:open-project`,e)},[]),Q.useEffect(()=>{typeof window>`u`||!le||!n||u||se.current||(se.current=!0,window.__yuriAppReady=!0,window.dispatchEvent(new Event(`yuri:app-ready`)))},[le,n,u]),Ga({enabled:le}),_w({enabled:le}),xw(),po(),rl(),JC(K(()=>{p(e=>!e)})),Q.useEffect(()=>{E()&&Kt().then(async e=>{e&&await D(e)}).catch(console.warn)},[]),Q.useEffect(()=>{if(!n||!E()||L.current)return;L.current=!0;let e=!1,t=null,r=null;Dl.getState().subscribeDesktopUpdateEvents().then(t=>{if(e){t();return}r=t});let i=()=>{let e=Dl.getState();e.checking||e.checkForUpdates()},a=n=>{t=window.setTimeout(()=>{e||(document.visibilityState===`visible`&&i(),a(Mw))},n)},o=()=>{if(e||document.visibilityState!==`visible`)return;let t=Dl.getState().lastChecked;t!=null&&Date.now()-t<Nw||i()};return a(0),window.addEventListener(`focus`,o),()=>{e=!0,t!==null&&window.clearTimeout(t),window.removeEventListener(`focus`,o),r&&r()}},[n]),pw(),Q.useEffect(()=>{if(ce)return;let e=e=>{$n(e)&&e.shiftKey&&!e.altKey&&(e.code===`KeyD`||e.key.toLowerCase()===`d`)&&(e.preventDefault(),p(e=>!e))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[ce]),Q.useEffect(()=>{ce||i&&setTimeout(()=>a(),5e3)},[a,ce,i]),Q.useEffect(()=>{if(!V||ae!==`not-injected`)return;let e=!1,t=0,n=()=>{if(e)return;t++;let r=te();if(r!==`not-injected`){if(e=!0,U(r),r===`valid`){let e=ie();e&&W(F({isDesktopShell:!0,bootOutcome:e}))}return}let i=Math.min(200*1.1**t,2e3);if(t>=50){let e=document.getElementById(`initial-loading`);e&&!e.textContent?.includes(`taking longer`)&&(e.textContent=`Desktop startup is taking longer than expected...`)}window.setTimeout(n,i)};return window.setTimeout(n,200),()=>{e=!0}},[V,ae]);let he=K(async()=>{if(R({isDesktopShell:C(),isDesktopLocalOriginActive:x()})){await k();return}window.location.reload()}),ge=K(async()=>{if(!P){S(!1),I(!0);try{await tn(),await jn.getState().initializeApp()}finally{I(!1)}jn.getState().isInitialized||T(e=>e+1)}}),_e=e=>{if(e.screen===`recovery`)return e.variant};if(V&&oe&&oe.screen!==`main`){if(oe.screen===`chooser`)return(0,$.jsx)(No,{children:(0,$.jsx)(`div`,{className:`h-full text-foreground bg-transparent`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`h-full`}),children:(0,$.jsx)(jw,{mode:`first-launch`,onCliAvailable:he,onChooseRemote:()=>{}})})})});let e=_e(oe),t=oe.screen===`recovery`&&`url`in oe?oe.url:void 0;return(0,$.jsx)(No,{children:(0,$.jsx)(`div`,{className:`h-full text-foreground bg-transparent`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`h-full`}),children:(0,$.jsx)(jw,{mode:`recovery`,recoveryVariant:e,recoveryHostUrl:t,recoveryHostLabel:void 0,onCliAvailable:he})})})})}if(ce)return xn(),(0,$.jsx)(No,{children:(0,$.jsx)(Qn,{sdk:nt.getSdkClient(),directory:s||``,bootstrapDirectory:o,children:(0,$.jsx)(fo,{apis:e,children:(0,$.jsx)(ti,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsx)(`div`,{className:`h-full text-foreground bg-background`,children:(0,$.jsx)(zw,{embeddedSessionChat:ce,isVSCodeRuntime:h,embeddedBackgroundWorkEnabled:le})})})})},O)});if(ue)return(0,$.jsx)(No,{children:(0,$.jsx)(Dw,{})});if(y&&!n&&!h&&!ce)return(0,$.jsx)(No,{children:(0,$.jsx)(Fw,{onRetry:()=>{ge()},isRetrying:P})});let ve=!n&&!V;return(0,$.jsx)(No,{children:(0,$.jsx)(Qn,{sdk:nt.getSdkClient(),directory:s||``,bootstrapDirectory:o,children:(0,$.jsx)(fo,{apis:e,children:(0,$.jsx)(Zc,{ready:pe&&n&&le,children:(0,$.jsx)(bm,{children:(0,$.jsx)(ti,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsxs)(`div`,{className:V?`h-full text-foreground bg-transparent`:`h-full text-foreground bg-background`,children:[(0,$.jsx)(eo,{embeddedBackgroundWorkEnabled:le}),(0,$.jsx)(ml,{}),(0,$.jsx)(sl,{}),(0,$.jsx)(Dc,{}),(0,$.jsx)(qS,{}),V&&(0,$.jsx)(Aw,{transition:j,ready:n&&r}),(0,$.jsx)(Ow,{}),(0,$.jsx)(Fa,{}),!ve&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(zc,{}),(0,$.jsx)(Sc,{}),(0,$.jsx)(gc,{}),(0,$.jsx)(Pw,{}),d&&(0,$.jsx)(kC,{onClose:()=>p(!1)})]})]})})})})})},O)})}function Vw(e){return e.isAboutDialogOpen}function Hw(e){return e.setAboutDialogOpen}function Uw(e){return e.currentDirectory}function Ww(e){return e.currentSessionId}function Gw(e){return e.setCurrentSession}if(typeof window<`u`&&!window.__YURI_REFRESH_DEBUG_INSTALLED__){window.__YURI_REFRESH_DEBUG_INSTALLED__=!0;let e=performance.getEntriesByType(`navigation`)[0];console.warn(`[refresh-debug] renderer-entry`,{navigationType:e?.type??`unknown`,protocol:window.location.protocol}),window.addEventListener(`beforeunload`,()=>{console.warn(`[refresh-debug] beforeunload`,{visibilityState:document.visibilityState})}),window.addEventListener(`pagehide`,e=>{console.warn(`[refresh-debug] pagehide`,{persisted:e.persisted})})}var Kw=typeof window<`u`&&window.__YURI_RUNTIME_APIS__||(()=>{throw Error(`Runtime APIs not provided for legacy UI entrypoint.`)})();Pr(),C()&&yr(),Wa({runtimeKey:p(),initializeAppearance:Pe,syncSettings:Fe,applyDirectory:ho,startWatchers:()=>{no(),Ha(),Ia()},onError:(e,t)=>{console.error(e===`appearance`?`[main] appearance init failed:`:`[main] settings init failed:`,t)}});var qw=document.getElementById(`root`);if(!qw)throw Error(`Root element not found`);(0,Au.createRoot)(qw).render((0,$.jsx)(Q.StrictMode,{children:(0,$.jsx)(La,{children:(0,$.jsx)(Mr,{children:(0,$.jsx)(Pa,{children:(0,$.jsx)(to,{children:(0,$.jsx)(Ba,{children:(0,$.jsx)(Va,{children:(0,$.jsx)(Bw,{apis:Kw})})})})})})})}));
|
|
169
|
+
Now write the final fused answer.`,synthetic:!0}],directory:i??nt.getDirectory()})}catch(e){console.error(`[MultiRunFusion] Failed to start fusion`,e),X.error(r(`multirun.fusion.toast.failed`))}finally{w(!1)}}},disabled:!k,children:r(C?`multirun.fusion.actions.starting`:`multirun.fusion.actions.start`)})]})]})})}function Cx(e){let t=(0,ju.c)(13),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=[`yuri-icon`,n].filter(Boolean),t[3]=n,t[4]=i);let a=i.join(` `),o,s,c,l,u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`path`,{d:`M12 4.5v6.25M12 10.75v3.5M12 10.75H7.25A3.25 3.25 0 0 0 4 14v1.25M12 10.75h4.75A3.25 3.25 0 0 1 20 14v1.25`}),s=(0,$.jsx)(`path`,{d:`M9.25 7.25 12 4.5l2.75 2.75`}),c=(0,$.jsx)(`circle`,{cx:`4`,cy:`17.25`,r:`1.55`}),l=(0,$.jsx)(`circle`,{cx:`12`,cy:`17.25`,r:`1.55`}),u=(0,$.jsx)(`circle`,{cx:`20`,cy:`17.25`,r:`1.55`}),t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=u):(o=t[5],s=t[6],c=t[7],l=t[8],u=t[9]);let d;return t[10]!==r||t[11]!==a?(d=(0,$.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:wr,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:a,...r,children:[o,s,c,l,u]}),t[10]=r,t[11]=a,t[12]=d):d=t[12],d}var wx=e(Se(),1),Tx=null,Ex=!1,Dx=(e,t=uo.getState().focus)=>e===null?null:typeof e==`string`?t?.sessionId===e?t:$a(e):e,Ox=e=>{typeof window>`u`||(e.commitFrame!==null&&window.cancelAnimationFrame(e.commitFrame),e.paintFrame!==null&&window.cancelAnimationFrame(e.paintFrame),e.fallbackTimer!==null&&window.clearTimeout(e.fallbackTimer))},kx=()=>{Tx&&=(Ox(Tx),null)},Ax=(e,t)=>{kx(),cr(!0);let n=Dx(e);if(!n)return;Ex=!0;let r;try{r=zt(n.sessionId)}finally{Ex=!1}Tx={commit:t,commitFrame:null,fallbackTimer:null,focus:n,intent:r,paintFrame:null,scheduled:!1},(0,wx.flushSync)(()=>{uo.getState().setFocus(n)}),typeof window<`u`&&(Tx.fallbackTimer=window.setTimeout(()=>{jx(n)},150))},jx=e=>{let t=Tx,n=Dx(e);if(!t||!qa(t.focus,n)||t.scheduled)return;t.scheduled=!0,typeof window<`u`&&t.fallbackTimer!==null&&(window.clearTimeout(t.fallbackTimer),t.fallbackTimer=null);let r=()=>{Tx===t&&Rt()===t.intent&&(Tx=null,Yn(),t.commit())};if(typeof window>`u`){r();return}t.commitFrame=window.requestAnimationFrame(()=>{Tx===t&&Rt()===t.intent&&(t.paintFrame=window.requestAnimationFrame(r))})},Mx=e=>{if(Tx)return;let t=uo.getState();t.setFocus(Dx(e,t.focus))};Bt(e=>{if(Ex)return;let t=Tx;if(t?.intent===e)return;t&&kx();let n=uo.getState();n.setFocus(Dx(e.sessionId,n.focus))});var Nx=e=>{let t=[],n=e=>{e.children.forEach(e=>{t.push(e.session.id),n(e)})};return n(e),t},Px=Q.memo(function(e){let t=(0,ju.c)(21),{pinned:n,pinLabel:r,buttonSizeClass:i,iconSizeClass:a,onPointerDown:o,onMouseDown:s,onPin:c}=e,l=n?`text-foreground`:`text-muted-foreground`,u;t[0]!==i||t[1]!==l?(u=Y(`inline-flex items-center justify-center rounded-md hover:text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,l,i),t[0]=i,t[1]=l,t[2]=u):u=t[2];let d=n?`pushpin-2-fill`:`pushpin-2`,f=!n&&`rotate-45`,p;t[3]!==a||t[4]!==f?(p=Y(a,f),t[3]=a,t[4]=f,t[5]=p):p=t[5];let m;t[6]!==d||t[7]!==p?(m=(0,$.jsx)(Z,{name:d,className:p}),t[6]=d,t[7]=p,t[8]=m):m=t[8];let h;t[9]!==s||t[10]!==c||t[11]!==o||t[12]!==r||t[13]!==u||t[14]!==m?(h=(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:u,"aria-label":r,onPointerDown:o,onMouseDown:s,onClick:c,onKeyDown:qx,children:m})}),t[9]=s,t[10]=c,t[11]=o,t[12]=r,t[13]=u,t[14]=m,t[15]=h):h=t[15];let g;t[16]===r?g=t[17]:(g=(0,$.jsx)(ei,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:r}),t[16]=r,t[17]=g);let _;return t[18]!==h||t[19]!==g?(_=(0,$.jsxs)(ni,{children:[h,g]}),t[18]=h,t[19]=g,t[20]=_):_=t[20],_}),Fx=Q.memo(function(e){let t=(0,ju.c)(24),{archiveLabel:n,deleteLabel:r,deleteOnly:i,restore:a,buttonSizeClass:o,iconSizeClass:s,revealClassName:c,onPointerDown:l,onMouseDown:u,onArchive:d,onDelete:f}=e,p=i!==void 0&&i,m=a!==void 0&&a,h=tx(),g=p||h,_=g?r:n,v;t[0]!==p||t[1]!==d||t[2]!==f||t[3]!==h?(v=e=>{if(p||h||e.shiftKey){f(e);return}d(e)},t[0]=p,t[1]=d,t[2]=f,t[3]=h,t[4]=v):v=t[4];let y=v,b=g?`text-destructive hover:text-destructive hover:bg-[color-mix(in_srgb,var(--status-error)_12%,transparent)]`:`text-muted-foreground hover:text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)]`,x;t[5]!==o||t[6]!==c||t[7]!==b?(x=Y(`inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,b,o,c),t[5]=o,t[6]=c,t[7]=b,t[8]=x):x=t[8];let S=g?`delete-bin`:m?`undo-2`:`inbox-archive`,C;t[9]!==s||t[10]!==S?(C=(0,$.jsx)(Z,{name:S,className:s}),t[9]=s,t[10]=S,t[11]=C):C=t[11];let w;t[12]!==y||t[13]!==_||t[14]!==u||t[15]!==l||t[16]!==x||t[17]!==C?(w=(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:x,"aria-label":_,onPointerDown:l,onMouseDown:u,onClick:y,onKeyDown:Jx,children:C})}),t[12]=y,t[13]=_,t[14]=u,t[15]=l,t[16]=x,t[17]=C,t[18]=w):w=t[18];let T;t[19]===_?T=t[20]:(T=(0,$.jsx)(ei,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:_}),t[19]=_,t[20]=T);let E;return t[21]!==w||t[22]!==T?(E=(0,$.jsxs)(ni,{children:[w,T]}),t[21]=w,t[22]=T,t[23]=E):E=t[23],E}),Ix=Q.memo(function(e){let t=(0,ju.c)(3),{number:n}=e;if(!_x())return null;let r=gr()?`⌘${n}`:`Ctrl+${n}`,i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(Ri,{"data-sidebar-shortcut-number":n,variant:`hint`,"aria-hidden":`true`,children:r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i});function Lx(e){let{t}=Nr(),{node:r,depth:i=0,groupDirectory:a,projectId:o,archivedBucket:s=!1,pinnedSessionIds:c,expandedParents:l,hasSessionSearchQuery:u,normalizedSessionSearchQuery:d,editingId:f,setEditingId:p,editTitle:m,setEditTitle:g,handleSaveEdit:_,handleCancelEdit:v,toggleParent:y,handleSessionSelect:b,togglePinnedSession:x,handleShareSession:S,copiedSessionId:C,handleCopyShareUrl:w,handleUnshareSession:T,setOpenSidebarMenuKey:E,renamingFolderId:D,getFoldersForScope:O,getSessionFolderId:k,removeSessionFromFolder:A,addSessionToFolder:j,createFolderAndStartRename:M,handleDeleteSession:N,mobileVariant:P,alwaysShowActions:F,renderSessionNode:I,secondaryMeta:R,renderContext:z=`project`,subtreeContainsActive:B,subtreeContainsEditing:V,menuOpenSessionId:te,childRenderExtrasFor:ne,liveSessionById:re,shortcutNumber:ie=null,settledSessionIds:H,setSessionSettled:U}=e,oe=!!R?.projectLabel,W=!!R?.branchLabel,se=Tn(e=>e.displayMode),ce=Q.useMemo(()=>ae(),[]),le=se===`minimal`||ce,ue=Q.useMemo(()=>L(),[]),de=Q.useContext(jt),fe=ce?`group-hover:opacity-100 group-hover:pointer-events-auto`:`group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto`,he=ce,ye=z===`pinned`&&c.has(r.session.id),xe=!ye&&!s&&!P&&!R?.slim,Se=`h-5 w-5`,Te=`h-3.5 w-3.5`,Ee=(xe||ye?1:0)+ +!!he+1,De=Ee>=3?`group-hover:pr-18 group-focus-within:pr-18`:Ee>=2?`group-hover:pr-12 group-focus-within:pr-12`:`group-hover:pr-7 group-focus-within:pr-7`,Oe=F?ce?De:Ee>=2?`pr-12`:`pr-8`:De,ke=Q.useRef(!1),je=Q.useRef(!1),[Me,Ne]=Q.useState(!1),Pe=Q.useRef(f);Pe.current=f;let Fe=Q.useRef(null),[G,Ie]=Q.useState(m),[Le,Re]=Q.useState(f===r.session.id),ze=Q.useRef(null),Be=Q.useRef(null),Ve=Q.useRef(null),He=r.session,Ue=re.get(He.id)??He,We=!!Ue.metadata?.yuri?.assistant,Ge=ft(He.directory??null)??ft(a??null),Ke=Sn(Ge??void 0,{bootstrap:!1}),qe=ps(),Je=Hb(e=>e.enabled),Ze=Hb(Q.useMemo(()=>e=>e.selectedIds.has(He.id),[He.id])),Qe=Hb(e=>e.toggleSelected),$e=Hb(e=>e.setRange),[et,tt]=Q.useState(!1),[nt,it]=Q.useState(!0),[ot,st]=Q.useState(!1),[ct,lt]=Q.useState(!1),ut=`${z}:${s?`archived`:`active`}:${He.id}`,dt=br(Q.useMemo(()=>e=>!!e.sessionMemoryState.get(yn(He.id))?.isZombie,[He.id])),pt=mr(He.id),mt=nr(He.id,Ge??void 0,{bootstrap:!1}),ht=Xn(He.id,Ge??void 0,{bootstrap:!1}),gt=Q.useMemo(()=>({scope:z,sessionId:He.id,projectId:o??null}),[o,z,He.id]),_t=Q.useMemo(()=>Qa(gt)??``,[gt]),vt=Q.useRef(null),yt=uo(Q.useMemo(()=>e=>qa(e.focus,gt),[gt]));Q.useLayoutEffect(()=>{if(!yt)return;let e=vt.current;e&&(P?e.scrollIntoView({block:`nearest`,inline:`nearest`}):_b(e)),jx(gt)},[yt,P,gt]);let bt=Ue.title||t(`sessions.sidebar.session.untitled`),xt=cc(sc(Ue)),St=Ue.metadata?.yuri?.titleRefresh,Ct=typeof St?.lastError==`string`?St.lastError:null,wt=typeof St?.failedAt==`number`?St.failedAt:null;Q.useEffect(()=>{!Ct||wt===null||console.warn(`[session-title] generation failed for ${He.id}: ${Ct}`)},[He.id,Ct,wt]);let Tt=typeof St?.generationExpiresAt==`number`&&Number.isFinite(St.generationExpiresAt)?St.generationExpiresAt:0,[Et,Dt]=Q.useState(0),Ot=Q.useMemo(()=>Math.max(0,Tt-Date.now()),[Tt]),[,kt,At]=Pt(()=>Dt(Tt),Ot,{immediate:!1}),Mt=St?.isGenerating===!0;Q.useEffect(()=>(Mt&&Tt>Date.now()&&kt(),At),[Mt,Tt,kt,At]);let Nt=r.children.length>0||!!(Ue.hasChildren??He.hasChildren),Ft=c.has(He.id),It=!!H?.has(He.id),Lt=ut,Rt=u?!0:l.has(Lt),zt=!!Ue.parentID,Bt=z===`pinned`,q=mn(He.id),Vt=q>0&&!zt,Ht=kn(Ue)||Date.now(),Ut=xo(Ht),Wt=Ao(Ht),[Gt,Kt]=Q.useState(!1),[qt,Jt]=Q.useState(!1),Yt=Gt,Xt=Q.useMemo(()=>nu(Ue.title)!==null,[Ue.title]),[Qt,$t]=Q.useState(!1),en=Q.useMemo(()=>Nx(r).length,[r]),tn=K(e=>{let t=Ge??``,n=(Xe()??at(t,Ke)).getTranscript(rt(t,e)),r=Ke.getState().session.find(t=>t.id===e)?.revert?.messageID;return Zt({sessionID:e,messages:Ye(n),parts:n.partsByMessageID,revertMessageID:r}).list}),nn=K(async e=>{let n=[],r=0;for(let i of e)try{await qe.ensureSessionRenderable(i.session.id);let e=tn(i.session.id),a=i.session.title||t(`sessions.sidebar.session.export.untitledSubagent`),o=i.session.agent,s=await nn(i.children);r+=s.skipped,n.push({title:a,agent:o,records:e,children:s.children})}catch{r+=Nx(i).length+1}return{children:n,skipped:r}}),rn=K(e=>{e<=0||X.warning(t(e===1?`sessions.sidebar.session.export.skippedSubtaskSingle`:`sessions.sidebar.session.export.skippedSubtaskMany`,{count:e}))}),an=K(async e=>{if(!Ge){X.error(t(`sessions.sidebar.session.export.nothingToExport`));return}await qe.ensureSessionRenderable(He.id);let n=tn(He.id);if(n.length===0){X.error(t(`sessions.sidebar.session.export.nothingToExport`));return}let i,a=0;if(e&&r.children.length>0){let e=await nn(r.children);i=e.children,a=e.skipped}let o=Pb(n,Ue.title??null,i),s=zb(Ue.title??null),c=await Ib(o,s);if(c){X.success(t(`sessions.sidebar.session.export.success`),{action:{label:t(Rb()),onClick:()=>{Lb(c).then(e=>{e||X.error(t(`sessions.sidebar.session.export.failedRevealPath`))})}}}),rn(a);return}Fb(o,s),X.success(t(`sessions.sidebar.session.export.success`)),rn(a)}),on=K(async()=>{if(r.children.length>0){it(!0),tt(!0);return}await an(!1)}),sn=K(()=>{Ge&&ee(`desktop_open_session_mini_chat_window`,{sessionId:He.id,directory:Ge,apiBaseUrl:h(),clientToken:n()}).catch(e=>{console.warn(`[session-sidebar] failed to open mini chat window`,e)})});Q.useLayoutEffect(()=>{if(f!==He.id){Le&&Re(!1),ze.current===He.id&&(ze.current=null);return}!Le||ze.current===He.id||(ze.current=He.id,Ie(m),queueMicrotask(()=>Ve.current?.select()))},[f,m,He.id,Le]);let cn=K(e=>{if(!e&&Fe.current){let{id:e,title:t}=Fe.current;Fe.current=null,Re(!0),p(e),g(t)}}),ln=K(e=>{Kt(e)}),un=K(e=>{e.preventDefault(),e.stopPropagation()}),fn=K(e=>{e.preventDefault(),e.stopPropagation()}),pn=K(e=>{e.preventDefault(),e.stopPropagation(),E(null),x(He.id)}),hn=!!U&&!!(R?.card||R?.slim)&&!s&&!zt,gn=K(e=>{if(e.preventDefault(),e.stopPropagation(),E(null),hn&&U){U(He.id,!It);return}N(He,{archivedBucket:s})}),_n=K(e=>{e.preventDefault(),e.stopPropagation(),E(null),N(He,{archivedBucket:s,hardDelete:!0,skipConfirm:!0})}),vn=K(e=>{e.preventDefault(),e.stopPropagation(),E(null),x(He.id)}),bn=K(()=>{!Ge||ot||(st(!0),(async()=>{try{await qe.refreshSessionTranscript(He.id,{directory:Ge}),X.success(t(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{X.error(t(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{st(!1)}})())}),xn=K(e=>{e.preventDefault(),e.stopPropagation()}),wn=K(e=>{e.preventDefault(),e.stopPropagation()}),En=K(e=>{e.preventDefault(),e.stopPropagation(),de?.vscode?.executeCommand(`yuri.openSessionInEditor`,He.id,bt)}),Dn=K(e=>{if(ke.current){ke.current=!1;return}if(Je){if(e?.preventDefault(),e?.stopPropagation(),e?.shiftKey){let e=(typeof document<`u`?Array.from(document.querySelectorAll(`[data-session-row]`)):[]).map(e=>e.getAttribute(`data-session-row`)).filter(e=>typeof e==`string`&&e.length>0),t=Hb.getState().anchorId,n=new Map;n.set(He.id,Nx(r)),$e(t,He.id,e,Ge??null,n);return}Qe(He.id,Ge??null,Nx(r));return}b(He.id,Ge,o,z)}),On=K(e=>{if(e.defaultPrevented||e.target?.closest(`button, a, input, [role="menuitem"], [role="menu"]`))return;Dn(e);let t=e.currentTarget.querySelector(`[data-session-title]`);t&&!P&&(t.focus({preventScroll:!0}),je.current=!0)}),An=K(e=>{(e.button===2||e.button===0&&e.ctrlKey&&!Je)&&(ke.current=!0)}),jn=K(e=>{je.current=e.pointerType===`mouse`,P&&e.pointerType===`touch`&&Ne(!0)}),Mn=K(e=>{P&&e.pointerType===`touch`&&Ne(!1)}),Fn=K(e=>{e.key!==`Enter`||!je.current||(e.preventDefault(),e.stopPropagation(),Re(!0),p(He.id),g(bt))}),In=K(e=>{if(Dn(e),!je.current)return;let t=e.currentTarget;window.requestAnimationFrame(()=>{je.current=!0,t.focus({preventScroll:!0})})}),Ln=K(()=>{je.current=!1}),Rn=K(()=>{!Rt&&!ct&&(lt(!0),qe.loadChildren(He.id,Ge).catch(()=>X.error(t(`sessions.sidebar.session.subsessions.loadFailed`))).finally(()=>lt(!1))),y(Lt)});if(f===He.id&&Le){let e=async()=>{v();try{await Pn(He.id)}catch(e){console.warn(`[session-sidebar] failed to request smart title:`,e)}};return(0,$.jsx)(`div`,{className:`group relative my-0.5 flex items-center rounded-lg py-1.5 pr-2`,style:{paddingLeft:yo(i)},children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0`,children:[(0,$.jsxs)(`form`,{ref:Be,className:`flex w-full items-center gap-2`,onSubmit:e=>{e.preventDefault(),_(G)},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||v()},children:[(0,$.jsx)(`input`,{ref:Ve,value:G,onChange:e=>Ie(e.target.value),className:`flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground`,autoFocus:!0,placeholder:t(`sessions.sidebar.session.menu.rename`),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Escape`){v();return}}}),(0,$.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{e()},"aria-label":t(`sessions.sidebar.session.rename.smartTitle`),title:t(`sessions.sidebar.session.rename.smartTitle`),className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(Z,{name:`ai-generate-2`,className:`size-3.5`})}),(0,$.jsx)(`button`,{type:`submit`,onMouseDown:e=>e.preventDefault(),"aria-label":t(`sessions.sidebar.session.rename.save`),title:t(`sessions.sidebar.session.rename.save`),className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(Z,{name:`check`,className:`size-3.5`})})]}),le?null:(0,$.jsx)(`div`,{className:`flex items-center justify-between gap-3 text-muted-foreground/60 min-w-0 overflow-hidden leading-tight`,style:{fontSize:`calc(var(--text-ui-label) * 0.85)`},children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 overflow-hidden`,children:[Nt&&!Bt&&!zt?(0,$.jsx)(`span`,{className:`inline-flex items-center justify-center flex-shrink-0`,children:Rt?(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-3 w-3`}):(0,$.jsx)(Z,{name:`arrow-right-s`,className:`h-3 w-3`})}):null,(0,$.jsx)(`span`,{className:`flex-shrink-0`,children:Ut}),oe?(0,$.jsx)(`span`,{className:`truncate`,children:R?.projectLabel}):null,W?(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-0.5`,children:[(0,$.jsx)(Z,{name:`git-branch`,className:`h-3 w-3 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:R?.branchLabel})]}):null]})})]})},He.id)}let zn=pt,Bn=Mt&&Tt>Date.now()&&Et!==Tt,Vn=mt.length,Hn=ht.length>0,Un=!Hn&&!zn&&Vt,Wn=!!R?.card,Gn=!!R?.slim,Kn=Hn||Vn>0,qn=!Kn&&zn,Jn=yt||Ze,Yn=Wn&&Un,Zn=!Wn&&(Hn||zn||Un),Qn=t(Hn?`sessions.sidebar.session.status.questionRequired`:`sessions.sidebar.session.status.permissionRequired`),$n=R?.runStartedAt??null,er=Kn?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium leading-none text-status-warning`,"aria-label":Qn,title:Qn,children:[(0,$.jsx)(Z,{name:Hn?`question`:`shield`,className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:Qn})]}):qn?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium leading-none tabular-nums text-status-info`,title:t(`sessions.sidebar.session.status.active`),children:[(0,$.jsx)($c,{size:10,arcColor:`var(--status-info)`}),$n===null?null:(0,$.jsx)(Sl,{startedAt:$n})]}):(0,$.jsx)(`span`,{className:Y(`text-[10px] leading-none tabular-nums`,Jn?`text-foreground/70`:`text-muted-foreground/70`),children:Wt}),tr=!F||ce,rr=tr?Y(`group-hover:invisible group-focus-within:invisible`,Yt&&`invisible`):Yt?`invisible`:``,ir=Hn?(0,$.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center`,"aria-label":t(`sessions.sidebar.session.status.questionRequired`),title:t(`sessions.sidebar.session.status.questionRequired`),children:(0,$.jsx)(Z,{name:`question`,className:`h-3.5 w-3.5 text-primary`})}):zn?(0,$.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center`,"aria-label":t(`sessions.sidebar.session.status.active`),title:t(`sessions.sidebar.session.status.active`),children:(0,$.jsx)($c,{})}):(0,$.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center`,"aria-label":t(`sessions.sidebar.session.status.unread`),title:t(`sessions.sidebar.session.status.unread`),children:(0,$.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-[var(--status-info)]`})}),ar=!Bt&&!zt&&Nt,or=ar&&!F&&!ct,sr=yo(Math.max(0,i-1)),cr=ar?(0,$.jsx)(`span`,{role:`button`,tabIndex:0,"aria-expanded":Rt,"aria-busy":ct,onClick:e=>{e.stopPropagation(),e.currentTarget.blur(),Rn()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),Rn())},style:{minWidth:14,minHeight:14,left:sr},className:Y(`absolute inline-flex h-3.5 w-3.5 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity`,le?`top-1/2 -translate-y-1/2`:`top-[14.5px] -translate-y-1/2`,or?`opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto`:``),"aria-label":t(Rt?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),children:ct?(0,$.jsx)($c,{size:12}):Rt?(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-3 w-3`}):(0,$.jsx)(Z,{name:`arrow-right-s`,className:`h-3 w-3`})}):null,lr=dt?(0,$.jsx)(Z,{name:`error-warning`,className:`h-4 w-4 text-status-warning`}):null,ur=(0,$.jsx)(me,{children:(0,$.jsx)(Ae,{className:`app-region-no-drag z-50`,children:(0,$.jsx)(be,{"data-slot":`dropdown-menu-content`,finalFocus:()=>!(D||Pe.current),style:{color:`var(--surface-elevated-foreground)`},className:Y(hi,`yuri-session-context-menu min-w-[180px]`),children:(({Item:e,Separator:n,Sub:r,SubTrigger:i,SubContent:a})=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(e,{onClick:()=>x(He.id),className:`[&>svg]:mr-1`,children:[Ft?(0,$.jsx)(Z,{name:`unpin`,className:`mr-1 h-4 w-4`}):(0,$.jsx)(Z,{name:`pushpin`,className:`mr-1 h-4 w-4`}),t(Ft?`sessions.sidebar.session.menu.unpin`:`sessions.sidebar.session.menu.pin`)]}),zt?null:(0,$.jsxs)(e,{onClick:()=>{q>0?Cn(He.id):dn(He.id,Ge||void 0).catch(()=>X.error(t(`sessions.sidebar.session.menu.markUnreadFailed`)))},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:q>0?`mail-open`:`mail`,className:`mr-1 h-4 w-4`}),t(q>0?`sessions.sidebar.session.menu.markRead`:`sessions.sidebar.session.menu.markUnread`)]}),(0,$.jsxs)(e,{onClick:()=>{Fe.current={id:He.id,title:bt}},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`pencil-ai`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.rename`)]}),Nn()&&!Ue.share?(0,$.jsxs)(e,{onClick:()=>S(Ue),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`share-2`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.share`)]}):Nn()&&Ue.share?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(e,{onClick:()=>{Ue.share?.url&&w(Ue.share.url,He.id)},className:`[&>svg]:mr-1`,children:C===He.id?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{name:`check`,className:`mr-1 h-4 w-4`,style:{color:`var(--status-success)`}}),t(`sessions.sidebar.session.menu.copied`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{name:`file-copy`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.copyLink`)]})}),(0,$.jsxs)(e,{onClick:()=>T(He.id),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`link-unlink-m`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.unshare`)]})]}):null,(0,$.jsxs)(e,{onClick:()=>{on()},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`download`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.exportMarkdown`)]}),(0,$.jsxs)(e,{disabled:!Ge||ot,onClick:()=>{bn()},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`refresh`,className:Y(`mr-1 h-4 w-4`,ot&&`animate-spin`)}),t(`sessions.sidebar.session.menu.refreshTranscript`)]}),Xt?(0,$.jsxs)(e,{onClick:()=>$t(!0),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Cx,{className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.runFusion`)]}):null,Ge&&!s?(()=>{let o=O(Ge),s=k(Ge,He.id);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(n,{}),(0,$.jsxs)(r,{children:[(0,$.jsxs)(i,{className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`folder`,className:`h-4 w-4`}),t(`sessions.sidebar.folders.moveToFolder`)]}),(0,$.jsxs)(a,{className:`min-w-[180px]`,children:[o.length===0?(0,$.jsx)(e,{disabled:!0,className:`text-muted-foreground`,children:t(`sessions.sidebar.folders.none`)}):o.map(t=>(0,$.jsxs)(e,{onClick:()=>{s===t.id?A(Ge,He.id):j(Ge,t.id,He.id)},children:[(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:t.name}),s===t.id?(0,$.jsx)(Z,{name:`check`,className:`ml-2 h-3.5 w-3.5 text-primary flex-shrink-0`}):null]},t.id)),(0,$.jsx)(n,{}),(0,$.jsxs)(e,{onClick:()=>{let e=M(Ge);e&&j(Ge,e.id,He.id)},children:[(0,$.jsx)(Z,{name:`add`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.folders.newFolderEllipsis`)]}),s?(0,$.jsxs)(e,{onClick:()=>{A(Ge,He.id)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(Z,{name:`close`,className:`mr-1 h-4 w-4 text-inherit`}),t(`sessions.sidebar.folders.removeFromFolder`)]}):null]})]})]})})():null,ue?(0,$.jsxs)(e,{disabled:!Ge,onClick:sn,className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`window`,className:`mr-1 h-4 w-4`}),(0,$.jsx)(`span`,{className:`truncate`,children:t(`sessions.sidebar.session.menu.openMiniChatWindow`)})]}):null,(0,$.jsx)(n,{}),s?null:hn&&It?(0,$.jsxs)(e,{className:`[&>svg]:mr-1`,onClick:()=>U?.(He.id,!1),children:[(0,$.jsx)(Z,{name:`undo-2`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.unsettle`)]}):(0,$.jsxs)(e,{className:`[&>svg]:mr-1`,onClick:()=>hn&&U?U(He.id,!0):N(He,{archivedBucket:s}),children:[(0,$.jsx)(Z,{name:`inbox-archive`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.bulkActions.archive`)]}),(0,$.jsxs)(e,{className:`text-destructive/80 focus:text-destructive/80 [&>svg]:mr-1`,onClick:()=>N(He,{archivedBucket:s,hardDelete:!0}),children:[(0,$.jsx)(Z,{name:`delete-bin`,className:`mr-1 h-4 w-4 text-inherit`}),t(`sessions.sidebar.bulkActions.delete`)]})]}))({Item:({className:e,...t})=>(0,$.jsx)(ge,{className:Y(_i,e),...t}),Separator:({className:e,...t})=>(0,$.jsx)(_e,{className:Y(gi,e),...t}),Sub:ve,SubTrigger:({className:e,children:t,...n})=>(0,$.jsxs)(Ce,{className:Y(mi,e),...n,children:[t,(0,$.jsx)(Z,{name:`arrow-right-s`,className:`ml-auto size-3.5`})]}),SubContent:({className:e,children:t,...n})=>(0,$.jsx)(me,{children:(0,$.jsx)(Ae,{className:`app-region-no-drag z-50`,children:(0,$.jsx)(be,{"data-slot":`dropdown-menu-sub-content`,style:{color:`var(--surface-elevated-foreground)`},className:Y(hi,`yuri-session-context-menu`,e),...n,children:t})})})})})})});return(0,$.jsxs)(Q.Fragment,{children:[(0,$.jsx)(Yc,{sessionId:He.id,sessionDirectory:Ge??null,sessionTitle:bt,children:(0,$.jsxs)(pe,{open:Gt,onOpenChange:ln,onOpenChangeComplete:cn,children:[(0,$.jsxs)(we,{render:(0,$.jsx)(qc,{ref:vt,active:yt,selected:Ze,"data-session-row":He.id,"data-session-scope":Ge??``,"data-session-focus-scope":z,"data-session-focus-key":_t,"data-session-project-id":o??``,"data-session-archived":s?`1`:`0`,"data-session-depth":i,onClick:On,className:Y(yt&&!Ze&&`bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] dark:bg-[color-mix(in_srgb,var(--surface-foreground)_11%,transparent)]`,Ze&&`bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] dark:bg-[color-mix(in_srgb,var(--surface-foreground)_11%,transparent)]`,!yt&&!Ze&&`hover:bg-[color-mix(in_srgb,var(--surface-foreground)_3.5%,transparent)] dark:hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)]`,Gn&&`py-1`)}),children:[cr,(0,$.jsx)(Gc,{depth:i,children:(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:(0,$.jsxs)(ni,{onOpenChange:Jt,children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsxs)(Cc,{type:`button`,"data-session-title":!0,onPointerDown:jn,onPointerUp:Mn,onPointerCancel:Mn,onMouseDown:An,onKeyDown:Fn,onBlur:Ln,onClick:In,onDoubleClick:e=>{e.stopPropagation(),!P&&L()&&sn()},className:Y(Me&&`bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)]`,Wn&&`gap-0.5`,!Wn&&Oe),children:[Wn?(0,$.jsxs)(`div`,{className:Y(`flex h-5 w-full min-w-0 items-center gap-1 overflow-hidden`,Oe),children:[(0,$.jsx)(_l,{project:R?.project}),Yn&&!Kn?(0,$.jsx)(Qc,{}):null,(0,$.jsx)(`span`,{className:Y(`min-w-0 flex-1 truncate typography-micro leading-4`,Jn?`text-foreground/80`:`text-muted-foreground`),children:R?.projectLabel}),(0,$.jsx)(`span`,{className:Y(`shrink-0`,rr),children:er})]}):null,(0,$.jsxs)(`div`,{className:`flex w-full items-center min-w-0 flex-1 gap-1 overflow-hidden`,children:[Gn?(0,$.jsx)(_l,{project:R?.project}):null,(0,$.jsx)(`div`,{className:Y(`block min-w-0 flex-1 truncate text-foreground`,Gn?`typography-meta`:`typography-ui-label`,Gn&&!Jn&&`text-muted-foreground`,Yn?`font-medium`:`font-normal`,Bn&&`animate-text-shimmer`),"aria-busy":Bn||void 0,children:_o(bt,d)}),xt?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro tabular-nums text-muted-foreground`,children:xt}):null,Gn?(0,$.jsx)(`span`,{className:Y(`shrink-0 text-[10px] leading-none tabular-nums text-muted-foreground/70`,rr),children:Wt}):null,We?(0,$.jsx)(Z,{name:`ai-agent`,className:`size-3 shrink-0 text-muted-foreground`,"aria-label":`Assistant`}):null,Vn>0&&!Wn?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive flex-shrink-0`,title:t(`sessions.sidebar.session.status.permissionRequired`),"aria-label":t(`sessions.sidebar.session.status.permissionRequired`),children:[(0,$.jsx)(Z,{name:`shield`,className:`h-3 w-3`}),(0,$.jsx)(`span`,{className:`leading-none`,children:Vn})]}):null,Zn?(0,$.jsx)(`span`,{className:Y(`inline-flex shrink-0 items-center justify-center transition-none`,tr?Y(`group-hover:hidden group-focus-within:hidden`,Yt?`hidden`:``):Yt?`invisible`:``),children:ir}):null,ie?(0,$.jsx)(Ix,{number:ie}):null]}),Wn?(0,$.jsxs)(`div`,{className:Y(`flex h-4 w-full min-w-0 items-center gap-1 overflow-hidden text-[10px] leading-4`,Jn?`text-foreground/60`:`text-muted-foreground/60`),children:[W?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`inline-flex size-3.5 shrink-0 items-center justify-center`,children:(0,$.jsx)(Z,{name:`git-branch`,className:`size-2.5`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:R?.branchLabel})]}):R?.branchState===`loading`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`inline-flex size-3.5 shrink-0 items-center justify-center`,children:(0,$.jsx)(Z,{name:`git-branch`,className:`size-2.5`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 animate-pulse truncate`,children:t(`common.loading`)})]}):R?.pathLabel?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`inline-flex size-3.5 shrink-0 items-center justify-center`,children:(0,$.jsx)(Z,{name:`folder-open`,className:`size-2.5`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:R.pathLabel})]}):(0,$.jsx)(`span`,{className:`flex-1`}),Ft?(0,$.jsx)(Z,{name:`pushpin-2-fill`,className:`size-2.5 shrink-0`,"aria-label":t(`sessions.sidebar.session.actions.pinned`)}):null]}):null]})}),ce?null:(0,$.jsx)(ei,{side:`right`,align:`start`,sideOffset:8,className:`w-64 max-w-[min(16rem,calc(100vw-2rem))] px-3 py-2.5 text-left shadow-md`,children:qt?(0,$.jsx)(Bb,{session:Ue,title:bt,time:Wt,projectLabel:R?.projectLabel,project:R?.project,branch:r.worktree?.branch??R?.branchLabel,directory:Ge}):null})]})})}),lr&&!P?(0,$.jsx)(`div`,{className:Y(`absolute top-1/2 -translate-y-1/2 z-10`,le?`right-0`:`right-[30px]`),children:lr}):null,(0,$.jsxs)(wc,{visible:Yt||F&&!ce,className:Y(`absolute right-1 top-1/2 z-10 flex -translate-y-1/2 items-center gap-1 transition-none group-has-[[data-sidebar-shortcut-number]]:hidden`,Yt||F&&!ce?`opacity-100`:Y(`opacity-0`,fe),Wn&&`top-1.5 translate-y-0`),children:[xe?(0,$.jsx)(Px,{pinned:Ft,pinLabel:t(Ft?`sessions.sidebar.session.menu.unpin`:`sessions.sidebar.session.menu.pin`),buttonSizeClass:Se,iconSizeClass:Te,onPointerDown:un,onMouseDown:fn,onPin:pn}):null,ye?(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`inline-flex items-center justify-center rounded-md text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,Se),"aria-label":t(`sessions.sidebar.session.actions.pinned`),onPointerDown:un,onMouseDown:fn,onClick:vn,onKeyDown:e=>e.stopPropagation(),children:(0,$.jsx)(Z,{name:`pushpin-2-fill`,className:Te})})}),(0,$.jsx)(ei,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:t(`sessions.sidebar.session.actions.pinned`)})]}):null,he?(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,Se),"aria-label":t(`sessions.sidebar.session.actions.openInEditor`),onPointerDown:xn,onMouseDown:wn,onClick:En,onKeyDown:e=>e.stopPropagation(),children:(0,$.jsx)(Z,{name:`external-link`,className:Te})})}),(0,$.jsx)(ei,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:t(`sessions.sidebar.session.actions.openInEditor`)})]}):null,(0,$.jsx)(Fx,{archiveLabel:t(hn&&It?`sessions.sidebar.session.menu.unsettle`:`sessions.sidebar.bulkActions.archive`),restore:hn&&It,deleteLabel:t(`sessions.sidebar.bulkActions.delete`),deleteOnly:s===!0,buttonSizeClass:Se,iconSizeClass:Te,revealClassName:le&&!F&&!Yt?Y(`opacity-0`,fe):`opacity-100`,onPointerDown:un,onMouseDown:fn,onArchive:gn,onDelete:_n})]})]}),ur]})}),!Bt&&Nt&&Rt?r.children.map(e=>{let t=ne?ne(e):{subtreeContainsActive:B,subtreeContainsEditing:V,menuOpenSessionId:te,nodeStructureKey:``};return I(e,i+1,Ge??a,o,s,void 0,z,t)}):null,(0,$.jsx)(Qr,{open:et,onOpenChange:tt,children:(0,$.jsxs)(Yr,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[(0,$.jsxs)(qr,{children:[(0,$.jsx)(Xr,{children:t(`sessions.sidebar.session.export.dialog.title`)}),(0,$.jsx)(Zr,{children:t(en===1?`sessions.sidebar.session.export.dialog.descriptionSingle`:`sessions.sidebar.session.export.dialog.descriptionMany`,{count:en})})]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-ui-label cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:nt,onChange:e=>it(e.target.checked),className:`h-4 w-4 rounded border-border accent-primary`}),t(`sessions.sidebar.session.export.dialog.includeSubtasks`)]}),(0,$.jsxs)(Jr,{children:[(0,$.jsx)(J,{type:`button`,onClick:()=>tt(!1),variant:`outline`,size:`sm`,children:t(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(J,{type:`button`,onClick:()=>{tt(!1),an(nt)},size:`sm`,children:t(`sessions.sidebar.session.export.dialog.confirm`)})]})]})}),Xt?(0,$.jsx)(Sx,{session:Ue,open:Qt,onOpenChange:$t}):null]},He.id)}var Rx=e=>ft(e.session.directory??null),zx=(e,t)=>(e?.projectLabel??null)===(t?.projectLabel??null)&&(e?.branchLabel??null)===(t?.branchLabel??null)&&!!e?.card==!!t?.card&&!!e?.slim==!!t?.slim&&(e?.branchState??null)===(t?.branchState??null)&&(e?.pathLabel??null)===(t?.pathLabel??null)&&(e?.project??null)===(t?.project??null)&&(e?.runStartedAt??null)===(t?.runStartedAt??null),Bx=e=>{if(!e.openSidebarMenuKey)return null;let t=e.archivedBucket?`archived`:`active`,n=`${e.renderContext??`project`}:${t}:`;return e.openSidebarMenuKey.startsWith(n)?e.openSidebarMenuKey.slice(n.length):null},Vx=e=>e.menuOpenSessionId??Bx(e),Hx=(e,t,n)=>t?n.has(e.node.session.id)?!0:Pc(e.node,t):!1,Ux=(e,t,n,r,i)=>{if(e.session.id!==t.session.id)return!0;let a=i(e);if(n.has(a)!==r.has(a)||e.children.length!==t.children.length)return!0;for(let a=0;a<e.children.length;a+=1)if(Ux(e.children[a],t.children[a],n,r,i))return!0;return!1},Wx=(e,t,n,r)=>{if(e.session.id!==t.session.id)return!0;let i=e.session.id,a=n.get(i)??e.session,o=r.get(i)??t.session;if(a!==o&&xc(a)!==xc(o)||e.children.length!==t.children.length)return!0;for(let i=0;i<e.children.length;i+=1)if(Wx(e.children[i],t.children[i],n,r))return!0;return!1},Gx=(e,t)=>{if(e.hasSessionSearchQuery||t.hasSessionSearchQuery)return!1;let n=e.archivedBucket?`archived`:`active`,r=t.archivedBucket?`archived`:`active`;return Ux(e.node,t.node,e.expandedParents,t.expandedParents,t=>`${e.renderContext??`project`}:${n}:${t.session.id}`)||Ux(e.node,t.node,e.expandedParents,t.expandedParents,e=>`${t.renderContext??`project`}:${r}:${e.session.id}`)},Kx=Q.memo(Lx,(e,t)=>{if(e.node.session.id!==t.node.session.id||e.depth!==t.depth||e.groupDirectory!==t.groupDirectory||e.projectId!==t.projectId||e.archivedBucket!==t.archivedBucket||(e.renderContext??`project`)!==(t.renderContext??`project`)||e.mobileVariant!==t.mobileVariant||e.alwaysShowActions!==t.alwaysShowActions||e.shortcutNumber!==t.shortcutNumber||e.hasSessionSearchQuery!==t.hasSessionSearchQuery||e.normalizedSessionSearchQuery!==t.normalizedSessionSearchQuery||e.notifyOnSubtasks!==t.notifyOnSubtasks||e.nodeStructureKey!==t.nodeStructureKey||e.node.session.hasChildren!==t.node.session.hasChildren||Rx(e.node)!==Rx(t.node)||!zx(e.secondaryMeta,t.secondaryMeta)||e.liveSessionById!==t.liveSessionById&&Wx(e.node,t.node,e.liveSessionById,t.liveSessionById)||e.pinnedSessionIds!==t.pinnedSessionIds&&Ux(e.node,t.node,e.pinnedSessionIds,t.pinnedSessionIds,e=>e.session.id)||e.settledSessionIds!==t.settledSessionIds&&e.settledSessionIds?.has(e.node.session.id)!==t.settledSessionIds?.has(t.node.session.id)||e.setSessionSettled!==t.setSessionSettled||e.expandedParents!==t.expandedParents&&Gx(e,t)||e.currentSessionId!==t.currentSessionId&&(Hx(e,e.currentSessionId,e.subtreeContainsActive)||Hx(t,t.currentSessionId,t.subtreeContainsActive))||e.editingId!==t.editingId&&(Hx(e,e.editingId,e.subtreeContainsEditing)||Hx(t,t.editingId,t.subtreeContainsEditing))||e.editTitle!==t.editTitle&&(Hx(e,e.editingId,e.subtreeContainsEditing)||Hx(t,t.editingId,t.subtreeContainsEditing))||e.copiedSessionId!==t.copiedSessionId&&(Pc(e.node,e.copiedSessionId)||Pc(t.node,t.copiedSessionId)))return!1;if(e.openSidebarMenuKey!==t.openSidebarMenuKey){let n=Vx(e),r=Vx(t);if(Pc(e.node,n)||Pc(t.node,r))return!1}if(e.renamingFolderId!==t.renamingFolderId){let n=Vx(e),r=Vx(t);if(Pc(e.node,n)||Pc(t.node,r))return!1}return e.setEditingId===t.setEditingId&&e.setEditTitle===t.setEditTitle&&e.handleSaveEdit===t.handleSaveEdit&&e.handleCancelEdit===t.handleCancelEdit&&e.toggleParent===t.toggleParent&&e.handleSessionSelect===t.handleSessionSelect&&e.handleSessionDoubleClick===t.handleSessionDoubleClick&&e.togglePinnedSession===t.togglePinnedSession&&e.handleShareSession===t.handleShareSession&&e.handleCopyShareUrl===t.handleCopyShareUrl&&e.handleUnshareSession===t.handleUnshareSession&&e.setOpenSidebarMenuKey===t.setOpenSidebarMenuKey&&e.getFoldersForScope===t.getFoldersForScope&&e.getSessionFolderId===t.getSessionFolderId&&e.removeSessionFromFolder===t.removeSessionFromFolder&&e.addSessionToFolder===t.addSessionToFolder&&e.createFolderAndStartRename===t.createFolderAndStartRename&&e.handleDeleteSession===t.handleDeleteSession&&e.renderSessionNode===t.renderSessionNode});function qx(e){return e.stopPropagation()}function Jx(e){return e.stopPropagation()}function Yx(e){let t=(0,ju.c)(71),{t:n}=Nr(),{value:r,setValue:i,showDeletionDialog:a,setShowDeletionDialog:o,onConfirm:s}=e,c,l,u,d,f,p,m,h,g,_;if(t[0]!==i||t[1]!==n||t[2]!==r){let e=n(`sessions.sidebar.session.untitled`);d=Qr,g=!!r,t[13]===i?_=t[14]:(_=e=>{e||i(null)},t[13]=i,t[14]=_),u=Yr,m=!1,h=`max-w-sm gap-5`,l=qr;let a;t[15]!==n||t[16]!==r?.archivedBucket?(a=r?.archivedBucket?n(`sessions.sidebar.dialogs.deleteSession.title`):n(`sessions.sidebar.dialogs.archiveSession.title`),t[15]=n,t[16]=r?.archivedBucket,t[17]=a):a=t[17],t[18]===a?p=t[19]:(p=(0,$.jsx)(Xr,{children:a}),t[18]=a,t[19]=p),c=Zr,f=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?n(`sessions.sidebar.dialogs.deleteSession.withOneSubtask`,{sessionTitle:r.session.title||e,count:r.descendantCount}):n(`sessions.sidebar.dialogs.deleteSession.withManySubtasks`,{sessionTitle:r.session.title||e,count:r.descendantCount}):r.descendantCount===1?n(`sessions.sidebar.dialogs.archiveSession.withOneSubtask`,{sessionTitle:r.session.title||e,count:r.descendantCount}):n(`sessions.sidebar.dialogs.archiveSession.withManySubtasks`,{sessionTitle:r.session.title||e,count:r.descendantCount}):r?.archivedBucket?n(`sessions.sidebar.dialogs.deleteSession.single`,{sessionTitle:r?.session.title||e}):n(`sessions.sidebar.dialogs.archiveSession.single`,{sessionTitle:r?.session.title||e}),t[0]=i,t[1]=n,t[2]=r,t[3]=c,t[4]=l,t[5]=u,t[6]=d,t[7]=f,t[8]=p,t[9]=m,t[10]=h,t[11]=g,t[12]=_}else c=t[3],l=t[4],u=t[5],d=t[6],f=t[7],p=t[8],m=t[9],h=t[10],g=t[11],_=t[12];let v;t[20]!==c||t[21]!==f?(v=(0,$.jsx)(c,{children:f}),t[20]=c,t[21]=f,t[22]=v):v=t[22];let y;t[23]!==l||t[24]!==p||t[25]!==v?(y=(0,$.jsxs)(l,{children:[p,v]}),t[23]=l,t[24]=p,t[25]=v,t[26]=y):y=t[26];let b;t[27]!==o||t[28]!==a?(b=()=>o(!a),t[27]=o,t[28]=a,t[29]=b):b=t[29];let x=!a,S;t[30]===a?S=t[31]:(S=a?(0,$.jsx)(Z,{name:`checkbox-blank`,className:`h-4 w-4`}):(0,$.jsx)(Z,{name:`checkbox`,className:`h-4 w-4 text-primary`}),t[30]=a,t[31]=S);let C;t[32]===n?C=t[33]:(C=n(`sessions.sidebar.dialogs.neverAsk`),t[32]=n,t[33]=C);let w;t[34]!==S||t[35]!==C||t[36]!==b||t[37]!==x?(w=(0,$.jsxs)(`button`,{type:`button`,onClick:b,className:`inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50`,"aria-pressed":x,children:[S,C]}),t[34]=S,t[35]=C,t[36]=b,t[37]=x,t[38]=w):w=t[38];let T;t[39]===i?T=t[40]:(T=()=>i(null),t[39]=i,t[40]=T);let E;t[41]===n?E=t[42]:(E=n(`sessions.sidebar.dialogs.cancel`),t[41]=n,t[42]=E);let D;t[43]!==T||t[44]!==E?(D=(0,$.jsx)(`button`,{type:`button`,onClick:T,className:`inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:E}),t[43]=T,t[44]=E,t[45]=D):D=t[45];let O;t[46]===s?O=t[47]:(O=()=>void s(),t[46]=s,t[47]=O);let k;t[48]!==n||t[49]!==r?.archivedBucket?(k=r?.archivedBucket?n(`sessions.sidebar.bulkActions.delete`):n(`sessions.sidebar.bulkActions.archive`),t[48]=n,t[49]=r?.archivedBucket,t[50]=k):k=t[50];let A;t[51]!==O||t[52]!==k?(A=(0,$.jsx)(`button`,{type:`button`,onClick:O,className:`inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`,children:k}),t[51]=O,t[52]=k,t[53]=A):A=t[53];let j;t[54]!==D||t[55]!==A?(j=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[D,A]}),t[54]=D,t[55]=A,t[56]=j):j=t[56];let M;t[57]!==w||t[58]!==j?(M=(0,$.jsxs)(Jr,{className:`w-full sm:items-center sm:justify-between`,children:[w,j]}),t[57]=w,t[58]=j,t[59]=M):M=t[59];let N;t[60]!==u||t[61]!==m||t[62]!==M||t[63]!==h||t[64]!==y?(N=(0,$.jsxs)(u,{showCloseButton:m,className:h,children:[y,M]}),t[60]=u,t[61]=m,t[62]=M,t[63]=h,t[64]=y,t[65]=N):N=t[65];let P;return t[66]!==d||t[67]!==N||t[68]!==g||t[69]!==_?(P=(0,$.jsx)(d,{open:g,onOpenChange:_,children:N}),t[66]=d,t[67]=N,t[68]=g,t[69]=_,t[70]=P):P=t[70],P}function Xx(e){let t=(0,ju.c)(57),{t:n}=Nr(),{value:r,setValue:i,showDeletionDialog:a,setShowDeletionDialog:o,onConfirm:s}=e,c=r?.archivedBucket===!0,l=r?.sessionCount??0,u;t[0]!==c||t[1]!==l||t[2]!==n?(u=n(c?l===1?`sessions.sidebar.dialogs.deleteSession.title`:`sessions.sidebar.dialogs.deleteSessions.title`:l===1?`sessions.sidebar.dialogs.archiveSession.title`:`sessions.sidebar.dialogs.archiveSessions.title`),t[0]=c,t[1]=l,t[2]=n,t[3]=u):u=t[3];let d=u,f;t[4]!==c||t[5]!==l||t[6]!==n?(f=n(c?l===1?`sessions.sidebar.dialogs.deleteSessions.singleDescription`:`sessions.sidebar.dialogs.deleteSessions.pluralDescription`:l===1?`sessions.sidebar.dialogs.archiveSessions.singleDescription`:`sessions.sidebar.dialogs.archiveSessions.pluralDescription`,{count:l}),t[4]=c,t[5]=l,t[6]=n,t[7]=f):f=t[7];let p=f,m=!!r,h;t[8]===i?h=t[9]:(h=e=>{e||i(null)},t[8]=i,t[9]=h);let g;t[10]===d?g=t[11]:(g=(0,$.jsx)(Xr,{children:d}),t[10]=d,t[11]=g);let _;t[12]===p?_=t[13]:(_=(0,$.jsx)(Zr,{children:p}),t[12]=p,t[13]=_);let v;t[14]!==g||t[15]!==_?(v=(0,$.jsxs)(qr,{children:[g,_]}),t[14]=g,t[15]=_,t[16]=v):v=t[16];let y;t[17]!==o||t[18]!==a?(y=()=>o(!a),t[17]=o,t[18]=a,t[19]=y):y=t[19];let b=!a,x;t[20]===a?x=t[21]:(x=a?(0,$.jsx)(Z,{name:`checkbox-blank`,className:`h-4 w-4`}):(0,$.jsx)(Z,{name:`checkbox`,className:`h-4 w-4 text-primary`}),t[20]=a,t[21]=x);let S;t[22]===n?S=t[23]:(S=n(`sessions.sidebar.dialogs.neverAsk`),t[22]=n,t[23]=S);let C;t[24]!==S||t[25]!==y||t[26]!==b||t[27]!==x?(C=(0,$.jsxs)(`button`,{type:`button`,onClick:y,className:`inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50`,"aria-pressed":b,children:[x,S]}),t[24]=S,t[25]=y,t[26]=b,t[27]=x,t[28]=C):C=t[28];let w;t[29]===i?w=t[30]:(w=()=>i(null),t[29]=i,t[30]=w);let T;t[31]===n?T=t[32]:(T=n(`sessions.sidebar.dialogs.cancel`),t[31]=n,t[32]=T);let E;t[33]!==w||t[34]!==T?(E=(0,$.jsx)(`button`,{type:`button`,onClick:w,className:`inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:T}),t[33]=w,t[34]=T,t[35]=E):E=t[35];let D;t[36]===s?D=t[37]:(D=()=>void s(),t[36]=s,t[37]=D);let O;t[38]!==c||t[39]!==n?(O=n(c?`sessions.sidebar.bulkActions.delete`:`sessions.sidebar.bulkActions.archive`),t[38]=c,t[39]=n,t[40]=O):O=t[40];let k;t[41]!==D||t[42]!==O?(k=(0,$.jsx)(`button`,{type:`button`,onClick:D,className:`inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`,children:O}),t[41]=D,t[42]=O,t[43]=k):k=t[43];let A;t[44]!==E||t[45]!==k?(A=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[E,k]}),t[44]=E,t[45]=k,t[46]=A):A=t[46];let j;t[47]!==C||t[48]!==A?(j=(0,$.jsxs)(Jr,{className:`w-full sm:items-center sm:justify-between`,children:[C,A]}),t[47]=C,t[48]=A,t[49]=j):j=t[49];let M;t[50]!==j||t[51]!==v?(M=(0,$.jsxs)(Yr,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[v,j]}),t[50]=j,t[51]=v,t[52]=M):M=t[52];let N;return t[53]!==m||t[54]!==M||t[55]!==h?(N=(0,$.jsx)(Qr,{open:m,onOpenChange:h,children:M}),t[53]=m,t[54]=M,t[55]=h,t[56]=N):N=t[56],N}function Zx(e){let t=(0,ju.c)(36),{t:n}=Nr(),{value:r,setValue:i,onConfirm:a}=e,o=!!r,s;t[0]===i?s=t[1]:(s=e=>{e||i(null)},t[0]=i,t[1]=s);let c;t[2]===n?c=t[3]:(c=n(`sessions.sidebar.dialogs.deleteFolder.title`),t[2]=n,t[3]=c);let l;t[4]===c?l=t[5]:(l=(0,$.jsx)(Xr,{children:c}),t[4]=c,t[5]=l);let u;t[6]!==n||t[7]!==r?(u=r&&(r.subFolderCount>0||r.sessionCount>0)?r.subFolderCount>0?r.subFolderCount===1?n(`sessions.sidebar.dialogs.deleteFolder.withOneSubfolder`,{folderName:r.folderName,count:r.subFolderCount}):n(`sessions.sidebar.dialogs.deleteFolder.withManySubfolders`,{folderName:r.folderName,count:r.subFolderCount}):n(`sessions.sidebar.dialogs.deleteFolder.withContentsNoSubfolders`,{folderName:r.folderName}):n(`sessions.sidebar.dialogs.deleteFolder.single`,{folderName:r?.folderName??``}),t[6]=n,t[7]=r,t[8]=u):u=t[8];let d;t[9]===u?d=t[10]:(d=(0,$.jsx)(Zr,{children:u}),t[9]=u,t[10]=d);let f;t[11]!==l||t[12]!==d?(f=(0,$.jsxs)(qr,{children:[l,d]}),t[11]=l,t[12]=d,t[13]=f):f=t[13];let p;t[14]===i?p=t[15]:(p=()=>i(null),t[14]=i,t[15]=p);let m;t[16]===n?m=t[17]:(m=n(`sessions.sidebar.dialogs.cancel`),t[16]=n,t[17]=m);let h;t[18]!==p||t[19]!==m?(h=(0,$.jsx)(`button`,{type:`button`,onClick:p,className:`inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:m}),t[18]=p,t[19]=m,t[20]=h):h=t[20];let g;t[21]===n?g=t[22]:(g=n(`sessions.sidebar.bulkActions.delete`),t[21]=n,t[22]=g);let _;t[23]!==a||t[24]!==g?(_=(0,$.jsx)(`button`,{type:`button`,onClick:a,className:`inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`,children:g}),t[23]=a,t[24]=g,t[25]=_):_=t[25];let v;t[26]!==_||t[27]!==h?(v=(0,$.jsxs)(Jr,{children:[h,_]}),t[26]=_,t[27]=h,t[28]=v):v=t[28];let y;t[29]!==v||t[30]!==f?(y=(0,$.jsxs)(Yr,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[f,v]}),t[29]=v,t[30]=f,t[31]=y):y=t[31];let b;return t[32]!==o||t[33]!==s||t[34]!==y?(b=(0,$.jsx)(Qr,{open:o,onOpenChange:s,children:y}),t[32]=o,t[33]=s,t[34]=y,t[35]=b):b=t[35],b}var Qx=e=>{let t=(0,ju.c)(46),{selectedCount:n,scopeKey:r,scopeFolders:i,archivedBucket:a,onMoveToFolder:o,onCreateFolderAndMove:s,onRemoveFromFolder:c,canRemoveFromFolder:l,onDelete:u,onDone:d}=e,{t:f}=Nr(),p=!!r&&!a,m;t[0]!==a||t[1]!==f?(m=f(a?`sessions.sidebar.bulkActions.delete`:`sessions.sidebar.bulkActions.archive`),t[0]=a,t[1]=f,t[2]=m):m=t[2];let h=m,g;t[3]!==n||t[4]!==f?(g=f(`sessions.sidebar.bulkActions.selectedCount`,{count:n}),t[3]=n,t[4]=f,t[5]=g):g=t[5];let _;t[6]===g?_=t[7]:(_=(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground whitespace-nowrap`,children:g}),t[6]=g,t[7]=_);let v;t[8]!==p||t[9]!==l||t[10]!==s||t[11]!==o||t[12]!==c||t[13]!==i||t[14]!==f?(v=p?(0,$.jsxs)(Ci,{children:[(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(vi,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":f(`sessions.sidebar.bulkActions.moveToFolder`),children:(0,$.jsx)(Z,{name:`folder`,className:`h-4 w-4`})})})}),(0,$.jsx)(ei,{side:`top`,sideOffset:4,children:(0,$.jsx)(`p`,{children:f(`sessions.sidebar.bulkActions.moveToFolder`)})})]}),(0,$.jsxs)(bi,{align:`end`,className:`min-w-[180px]`,children:[i.length===0?(0,$.jsx)(xi,{disabled:!0,className:`text-muted-foreground`,children:f(`sessions.sidebar.folders.none`)}):i.map(e=>(0,$.jsx)(xi,{onClick:()=>o(e.id),children:(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:e.name})},e.id)),(0,$.jsx)(Si,{}),(0,$.jsxs)(xi,{onClick:s,children:[(0,$.jsx)(Z,{name:`add`,className:`mr-1 h-4 w-4`}),f(`sessions.sidebar.folders.newFolderEllipsis`)]}),l?(0,$.jsxs)(xi,{onClick:c,className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(Z,{name:`close`,className:`mr-1 h-4 w-4 text-inherit`}),f(`sessions.sidebar.folders.removeFromFolder`)]}):null]})]}):null,t[8]=p,t[9]=l,t[10]=s,t[11]=o,t[12]=c,t[13]=i,t[14]=f,t[15]=v):v=t[15];let y;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(y=Y(`inline-flex h-7 w-7 items-center justify-center rounded-md text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`),t[16]=y):y=t[16];let b;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(Z,{name:`delete-bin`,className:`h-4 w-4`}),t[17]=b):b=t[17];let x;t[18]!==h||t[19]!==u?(x=(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:u,className:y,"aria-label":h,children:b})}),t[18]=h,t[19]=u,t[20]=x):x=t[20];let S;t[21]===h?S=t[22]:(S=(0,$.jsx)(ei,{side:`top`,sideOffset:4,children:(0,$.jsx)(`p`,{children:h})}),t[21]=h,t[22]=S);let C;t[23]!==x||t[24]!==S?(C=(0,$.jsxs)(ni,{children:[x,S]}),t[23]=x,t[24]=S,t[25]=C):C=t[25];let w;t[26]===f?w=t[27]:(w=f(`sessions.sidebar.header.actions.exitSelection`),t[26]=f,t[27]=w);let T;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(Z,{name:`close`,className:`h-4 w-4`}),t[28]=T):T=t[28];let E;t[29]!==d||t[30]!==w?(E=(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:d,className:`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":w,children:T})}),t[29]=d,t[30]=w,t[31]=E):E=t[31];let D;t[32]===f?D=t[33]:(D=f(`sessions.sidebar.header.actions.exitSelection`),t[32]=f,t[33]=D);let O;t[34]===D?O=t[35]:(O=(0,$.jsx)(ei,{side:`top`,sideOffset:4,children:(0,$.jsx)(`p`,{children:D})}),t[34]=D,t[35]=O);let k;t[36]!==E||t[37]!==O?(k=(0,$.jsxs)(ni,{children:[E,O]}),t[36]=E,t[37]=O,t[38]=k):k=t[38];let A;t[39]!==k||t[40]!==v||t[41]!==C?(A=(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5`,children:[v,C,k]}),t[39]=k,t[40]=v,t[41]=C,t[42]=A):A=t[42];let j;return t[43]!==A||t[44]!==_?(j=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-t border-border px-2.5 py-1.5`,children:[_,A]}),t[43]=A,t[44]=_,t[45]=j):j=t[45],j},$x=e=>{let{t}=Nr(),{isInlineEditing:n,showDeletionDialog:r,foldersMap:i,addSessionsToFolder:a,removeSessionsFromFolders:o,createFolderAndStartRename:s,archiveSessions:c,setBulkDeleteConfirm:l}=e,u=Hb(e=>e.enabled),d=Hb(e=>e.selectedIds.size),f=d>0,p=Hb(e=>e.selectedIds),m=Hb(e=>e.scopeKey),h=Q.useCallback(()=>{Hb.getState().toggleMode()},[]),g=Q.useCallback(()=>{Hb.getState().disable()},[]),_=Q.useMemo(()=>{if(!f||typeof document>`u`)return!1;let e=!1,t=!1;for(let n of p){let r=document.querySelectorAll(`[data-session-row="${CSS.escape(n)}"]`);for(let n of r)n.getAttribute(`data-session-archived`)===`1`?t=!0:e=!0}return t&&!e},[f,p]),v=Q.useMemo(()=>{if(m)return m;if(!f||typeof document>`u`)return null;for(let e of p){let t=document.querySelector(`[data-session-row="${CSS.escape(e)}"]`)?.getAttribute(`data-session-scope`);if(t&&t.length>0)return t}return null},[f,p,m]),y=Q.useMemo(()=>v?i[v]??[]:[],[i,v]),b=Q.useMemo(()=>{if(!v||!f)return!1;let e=i[v]??[];for(let t of e)for(let e of t.sessionIds)if(p.has(e))return!0;return!1},[i,v,f,p]),x=Q.useCallback(e=>{!v||!f||a(v,e,Array.from(p))},[a,p,v,f]),S=Q.useCallback(()=>{if(!v||!f)return;let e=s(v);e&&a(v,e.id,Array.from(p))},[a,s,p,v,f]),C=Q.useCallback(()=>{!v||!f||o(v,Array.from(p))},[o,p,v,f]),w=Q.useCallback(async()=>{let e=Array.from(p);if(e.length!==0){if(_)vl({sessionIds:e,message:e.length===1?t(`sessions.sidebar.bulkActions.deletedSingle`,{count:e.length}):t(`sessions.sidebar.bulkActions.deletedPlural`,{count:e.length}),undoLabel:t(`sessions.sidebar.undo`),commitFailedMessage:e.length===1?t(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:e.length}):t(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:e.length})});else{let{archivedIds:n,failedIds:r}=await c(e);n.length>0&&Cl({sessionIds:n,message:n.length===1?t(`sessions.sidebar.bulkActions.archivedSingle`,{count:n.length}):t(`sessions.sidebar.bulkActions.archivedPlural`,{count:n.length}),undoLabel:t(`sessions.sidebar.undo`),settingsLabel:t(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:n.length===1?t(`sessions.sidebar.session.archive.undoFailed`):t(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:n.length})}),r.length>0&&X.error(r.length===1?t(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:r.length}):t(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:r.length}))}Hb.getState().clear()}},[c,_,p,t]),T=Q.useCallback(()=>{if(!f)return;let e=p.size;if(!_||!r){w();return}l({sessionCount:e,archivedBucket:_})},[_,w,p,r,l,f]),E=Q.useCallback(async()=>{l(null),await w()},[w]);return Q.useEffect(()=>{if(!u)return;let e=typeof navigator<`u`&&/Macintosh|Mac OS X/.test(navigator.userAgent||``),t=t=>{if(n)return;let r=t.target;if(r&&(r.tagName===`INPUT`||r.tagName===`TEXTAREA`||r.isContentEditable))return;let i=e?t.metaKey:t.ctrlKey;if(t.key===`Escape`){t.preventDefault(),Hb.getState().disable();return}if(i&&t.key===`Backspace`){t.preventDefault(),T();return}if(i&&(t.key===`a`||t.key===`A`)){let e=typeof document<`u`?Array.from(document.querySelectorAll(`[data-session-row]`)):[];if(e.length===0)return;t.preventDefault();let n=Hb.getState().scopeKey??e[0]?.getAttribute(`data-session-scope`)??null,r=e.filter(e=>!n||e.getAttribute(`data-session-scope`)===n).map(e=>e.getAttribute(`data-session-row`)).filter(e=>typeof e==`string`&&e.length>0);if(r.length===0)return;Hb.getState().replaceAll(r,n||null)}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[T,n,u]),{selectionModeEnabled:u,hasSelection:f,selectedIdsSize:d,bulkScopeIsArchived:_,derivedSelectionScope:v,bulkScopeFolders:y,bulkCanRemoveFromFolder:b,handleToggleSelectionMode:h,handleExitSelectionMode:g,handleBulkMoveToFolder:x,handleBulkCreateFolderAndMove:S,handleBulkRemoveFromFolder:C,handleBulkDelete:T,confirmBulkDelete:E}},eS=[{id:`tasks`,icon:`list-check-2`,labelKey:`sessions.sidebar.view.tasks`},{id:`projects`,icon:`folder-tree`,labelKey:`sessions.sidebar.projectsTitle`}],tS=Q.memo(function(e){let t=(0,ju.c)(9),{value:n,onChange:r}=e,{t:i}=Nr(),a;t[0]===i?a=t[1]:(a=i(`sessions.sidebar.view.aria`),t[0]=i,t[1]=a);let o;t[2]!==r||t[3]!==i||t[4]!==n?(o=eS.map(e=>{let t=n===e.id,a=i(e.labelKey);return(0,$.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,"aria-label":a,title:a,onClick:()=>r(e.id),className:Y(`relative flex h-6 items-center rounded-full text-[12px] font-medium leading-none`,`pl-1.5 transition-[background-color,color,box-shadow,padding] duration-200 ease-out motion-reduce:transition-none`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,t?`bg-background pr-2.5 text-foreground shadow-sm`:`pr-1.5 text-muted-foreground hover:text-foreground`),children:[(0,$.jsx)(Z,{name:e.icon,className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{"aria-hidden":!t,className:Y(`grid transition-[grid-template-columns,margin,opacity] duration-200 ease-out motion-reduce:transition-none`,t?`ml-1.5 grid-cols-[1fr] opacity-100`:`ml-0 grid-cols-[0fr] opacity-0`),children:(0,$.jsx)(`span`,{className:`min-w-0 overflow-hidden whitespace-nowrap`,children:a})})]},e.id)}),t[2]=r,t[3]=i,t[4]=n,t[5]=o):o=t[5];let s;return t[6]!==a||t[7]!==o?(s=(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":a,className:`-ml-2 inline-flex h-7 items-center rounded-full bg-[color-mix(in_srgb,var(--surface-foreground)_7%,transparent)] p-0.5`,children:o}),t[6]=a,t[7]=o,t[8]=s):s=t[8],s}),nS=e=>{let t=(0,ju.c)(2),{count:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`span`,{className:`text-[12px] tabular-nums text-muted-foreground/70`,children:n}),t[0]=n,t[1]=r),r};function rS(e){let t=(0,ju.c)(20),{items:n,renderTaskRow:r,onSessionsReordered:i}=e,{t:a}=Nr(),o;t[0]===n.active?o=t[1]:(o=n.active.map(aS),t[0]=n.active,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c=new Map(s.map(iS)),t[2]=s,t[3]=c);let l=c;if(n.active.length===0){let e;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Uc,{className:`size-20`}),t[4]=e):e=t[4];let n;t[5]===a?n=t[6]:(n=a(`sessions.sidebar.task.empty`),t[5]=a,t[6]=n);let r;return t[7]===n?r=t[8]:(r=(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-1 pt-6 pb-2`,children:[e,(0,$.jsx)(`div`,{className:`${Eo} !text-center`,children:n})]}),t[7]=n,t[8]=r),r}let u;t[9]!==n.active||t[10]!==r?(u=n.active.map(r),t[9]=n.active,t[10]=r,t[11]=u):u=t[11];let d=u,f;t[12]!==l||t[13]!==n.active.length||t[14]!==i||t[15]!==d||t[16]!==s?(f=i&&n.active.length>1?(0,$.jsx)(Bc,{scopeKey:`task-active`,sessionIds:s,folderIdBySessionId:l,onSessionDroppedOnFolder:oS,onSessionsReordered:i,children:d}):d,t[12]=l,t[13]=n.active.length,t[14]=i,t[15]=d,t[16]=s,t[17]=f):f=t[17];let p;return t[18]===f?p=t[19]:(p=(0,$.jsx)(`div`,{className:`-ml-1 -mr-1 space-y-0.5`,children:f}),t[18]=f,t[19]=p),p}function iS(e){return[e,null]}function aS(e){return e.node.session.id}var oS=()=>{};function sS(e){let t=(0,ju.c)(21),{items:n,open:r,onToggle:i,onShowMore:a,renderTaskRow:o}=e,{t:s}=Nr();if(n.settledTotal===0)return null;let c=n.settledTotal-n.settled.length,l=Math.min(30,c),u;t[0]===s?u=t[1]:(u=s(`sessions.sidebar.task.shelf.settled`),t[0]=s,t[1]=u);let d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(Z,{name:`archive`,className:`-ml-1 mr-0.5 size-3.5 shrink-0 text-foreground/55`}),t[2]=d):d=t[2];let f;t[3]===n.settledTotal?f=t[4]:(f=(0,$.jsx)(nS,{count:n.settledTotal}),t[3]=n.settledTotal,t[4]=f);let p;t[5]!==i||t[6]!==r||t[7]!==u||t[8]!==f?(p=(0,$.jsx)(by,{title:u,onToggle:i,expanded:r,className:`pt-2 pb-1`,leadingIcon:d,accessory:f}),t[5]=i,t[6]=r,t[7]=u,t[8]=f,t[9]=p):p=t[9];let m;t[10]!==n.settled||t[11]!==l||t[12]!==a||t[13]!==r||t[14]!==c||t[15]!==o||t[16]!==s?(m=r?(0,$.jsxs)(`div`,{className:`-ml-1 -mr-2 max-h-[40vh] space-y-px overflow-y-auto overscroll-contain`,children:[n.settled.map(o),c>0?(0,$.jsxs)(`button`,{type:`button`,onClick:a,className:`box-border flex w-full items-center gap-[3px] rounded-md px-2 py-1.5 text-left typography-meta text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:[(0,$.jsx)(Z,{name:`arrow-down-s`,className:`-ml-0.5 size-4 shrink-0`}),s(l===1?`sessions.sidebar.group.showMoreSingle`:`sessions.sidebar.group.showMorePlural`,{count:l})]}):null]}):null,t[10]=n.settled,t[11]=l,t[12]=a,t[13]=r,t[14]=c,t[15]=o,t[16]=s,t[17]=m):m=t[17];let h;return t[18]!==p||t[19]!==m?(h=(0,$.jsxs)(`div`,{className:`shrink-0 px-3 pb-1`,children:[p,m]}),t[18]=p,t[19]=m,t[20]=h):h=t[20],h}var cS={ids:[],baseline:{}},lS=(e,t)=>e!==void 0&&t!==void 0&&e.activityAt===t.activityAt&&e.running===t.running&&e.attention===t.attention,uS=(e,t,n,r)=>{if(r.ids.length===0)return e;let i=new Map;for(let n of e)i.set(t(n),n);let a=[],o=new Set;for(let e of r.ids){let t=i.get(e);!t||o.has(e)||!lS(r.baseline[e],n(t))||(a.push(t),o.add(e))}if(a.length<2)return e;let s=0,c=e.map(e=>o.has(t(e))?a[s++]:e);return c.every((t,n)=>t===e[n])?e:c},dS=(e,t,n,r)=>{let i=e.indexOf(t),a=e.indexOf(n);if(i<0||a<0||i===a)return null;let o=[...e];o.splice(i,1),o.splice(a,0,t);let s={};for(let e of o){let t=r(e);t&&(s[e]=t)}return{ids:o,baseline:s}},fS=(e,t,n)=>{let r=[],i=new Set,a=e=>{let t=ft(e??null);!t||i.has(t)||(i.add(t),r.push(t))};if(a(e),a(n?.workspaceRoot),a(n?.currentDirectory),n?.includeWorktrees!==!1)for(let e of t)a(e.path);return r},pS=(e,t,n,r)=>{let i=e.filter(e=>e.sessionId===t);if(i.length===0)return null;if(n){let e=i.find(e=>e.projectId===n);if(e)return e}if(r){let e=i.find(e=>e.projectId===r);if(e)return e}return i[0]??null},mS=({currentSessionId:e,focus:t,pinnedFocuses:n,projectFocuses:r,fallbackProjectId:i})=>{if(!e)return null;let a=t?.sessionId===e,o=a?t.projectId:null,s=pS(r,e,o,i)??{scope:`project`,sessionId:e,projectId:i};return!a||t.scope===`project`?s:pS(n,e,o,i)??s};function hS(e,t,n=null){if(!e||e.scope!==`project`||!e.sessionId)return null;if(e.projectId){let n=t.find(t=>t.sessionId===e.sessionId&&t.projectId===e.projectId);if(n)return n}if(n){let r=t.find(t=>t.sessionId===e.sessionId&&t.projectId===n);if(r)return r}return t.find(t=>t.sessionId===e.sessionId)??null}var gS=`yuri.sessions.sidebarView`,_S=`yuri.sessions.projectCollapse`,vS=`yuri.sessions.groupOrder`,yS=`yuri.sessions.groupCollapse`,bS=`yuri.sessions.activeSessionByProject`,xS=`yuri.sessions.expandedParents.v2`,SS=`yuri.sessions.expandedParents`,CS=st(He()),wS=e=>{try{let t=CS.getItem(e);if(!t)return new Set;let n=JSON.parse(t);return new Set(Array.isArray(n)?n.filter(e=>typeof e==`string`):[])}catch{return new Set}},TS=e=>{try{let t=CS.getItem(e);if(!t)return new Map;let n=JSON.parse(t),r=new Map;return!n||typeof n!=`object`||Array.isArray(n)||Object.entries(n).forEach(([e,t])=>{typeof t==`string`&&t.length>0&&r.set(e,t)}),r}catch{return new Map}},ES=e=>{try{let t=CS.getItem(e);if(!t)return new Map;let n=JSON.parse(t),r=new Map;return!n||typeof n!=`object`||Array.isArray(n)||Object.entries(n).forEach(([e,t])=>{Array.isArray(t)&&r.set(e,t.filter(e=>typeof e==`string`))}),r}catch{return new Map}},DS=(e,t,n)=>{let r=new Set;for(let t of e){let e=ft(t.path)?.toLowerCase();e&&r.add(e)}if(n?.includeWorktrees===!1)return r;for(let e of t.values())for(let t of e){let e=ft(t.path)?.toLowerCase();e&&r.add(e)}return r},OS=(e,t,n)=>{if(e.time?.archived)return!0;let r=ft(gn(e))?.toLowerCase();return r?t.size===0?n?.allowEmptyDirectorySet??!0:t.has(r):n?.allowUnknownDirectory??!0},kS=new Set,AS=[],jS={},MS=(e,t)=>{let n=Q.useRef(e);return n.current=e,Q.useMemo(()=>(...e)=>n.current(...e),[t])},NS=Q.memo(function(e){let t=(0,ju.c)(3),{onOpenChange:n}=e,r=Dl(fe(FS)),i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(Ml,{open:!0,onOpenChange:n,...r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}),PS=Q.memo(function({mobileVariant:e=!1,onSessionSelected:t,allowReselect:n=!1,hideDirectoryControls:r=!1,showOnlyMainWorkspace:i=!1,isVisible:a=!0}){let{t:o}=Nr(),[s,l]=Q.useState(!1),[u,d]=Q.useState(!1),[f,p]=Q.useState(``),h=Q.useRef(null),g=Q.useRef(null),[_,v]=Q.useState(null),[y,b]=Q.useState(``),[x,S]=Q.useState(null),[w,T]=Q.useState(new Set),E=Q.useMemo(()=>CS,[]),[D,O]=Q.useState(new Set),[k,A]=Q.useState(new Map),[j,M]=Q.useState(new Map),N=q(e=>e.isNewWorktreeDialogOpen),P=q(e=>e.setNewWorktreeDialogOpen),[F,I]=Q.useState(null),[L,R]=Q.useState(null),[z,ee]=Q.useState(``),[B,V]=Q.useState(null),[te,ne]=Q.useState(null),[re,ie]=Q.useState(null),H=$t(),U=wn(),oe=nl(),W=Xc(),se=pl(),ce=In(),le=q(e=>e.sidebarView),ue=q(e=>e.setSidebarView);Q.useEffect(()=>{let e=He().getItem(gS);e!==null&&(He().removeItem(gS),q.getState().sidebarView===`projects`&&vc(e)!==`projects`&&ue(vc(e)))},[ue]);let[de,fe]=Q.useState({settledOpen:!1,settledLimit:30}),pe=Q.useRef(new Map),me=Q.useRef(new Map),he=K(e=>{ue(e),Ne({sidebarView:e})}),[ge,_e]=Q.useState(()=>wS(yS)),[ve,ye]=Q.useState(()=>ES(vS)),[be,xe]=Q.useState(()=>TS(bS)),Se=Q.useRef(null);Q.useEffect(()=>c(e=>{m(e)&&(Se.current=null,_e(wS(yS)),ye(ES(vS)),xe(TS(bS)),O(wS(_S)),T(wS(xS)))}),[]);let[Ce,we]=Q.useState(new Map),Te=Q.useRef(0),Ee=G(e=>e.homeDirectory),De=G(e=>e.currentDirectory),Oe=G(e=>e.setDirectory),ke=un(e=>e.projects),Ae=Q.useMemo(()=>ke.filter(e=>!e.hostId),[ke]),je=Q.useMemo(()=>ke.filter(e=>e.hostId).map(Er),[ke]),[Me,Pe]=Q.useState(()=>new Map),Fe=K((e,t)=>{Pe(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})}),Ie=Jc(a),[Le,Re]=Q.useState(new Map),ze=K((e,t)=>{Re(n=>JSON.stringify(n.get(e))===JSON.stringify(t)?n:new Map(n).set(e,t))}),Be=un(e=>e.activeProjectId),Ve=un(e=>e.removeProject),Ue=un(e=>e.setActiveProjectIdOnly),We=un(e=>e.updateProjectMeta),Ge=un(e=>e.reorderProjectsById),Ke=q(e=>e.setActiveMainTab),qe=q(e=>e.activeMainTab),Je=ja(),Ye=q(e=>e.setSettingsDialogOpen),Xe=q(e=>e.toggleHelpDialog),Ze=q(e=>e.setSessionSwitcherOpen),Qe=q(e=>e.setScheduledTasksDialogOpen),$e=q(e=>e.notifyOnSubtasks),et=q(e=>e.showDeletionDialog),tt=q(e=>e.setShowDeletionDialog),nt=Aa(f,120),rt=Q.useMemo(()=>nt.trim().toLowerCase(),[nt]),it=rt.length>0,at=Dl(e=>e.available&&(e.runtimeType===`desktop`||e.runtimeType===`web`)),ot=en(e=>e.collapsedFolderIds),st=en(e=>e.foldersMap),ct=en(e=>e.sessionOrderByScope),lt=en(e=>e.sessionOrderActivityByScope),ut=en(e=>e.getFoldersForScope),dt=en(e=>e.createFolder),pt=en(e=>e.renameFolder),mt=en(e=>e.deleteFolder),ht=en(e=>e.addSessionToFolder),gt=en(e=>e.addSessionsToFolder),_t=en(e=>e.removeSessionFromFolder),vt=en(e=>e.removeSessionsFromFolders),yt=en(e=>e.toggleFolderCollapse),bt=en(e=>e.getSessionFolderId),xt=en(e=>e.reorderSessions);sy({isSessionSearchOpen:a&&u,setIsSessionSearchOpen:d,sessionSearchInputRef:g,sessionSearchContainerRef:h});let St=Q.useMemo(()=>new Map,[]),wt=vn({enabled:a,includeChildren:!0}),Tt=yc({enabled:a}),Et=Lc({enabled:a}),Dt=cn(e=>a?e.index.session.unseenCount:jS),Ot=Q.useMemo(()=>ae(),[]),kt=pn(e=>e.status),At=pn(e=>e.activeSessions),jt=pn(e=>e.archivedSessions),Mt=pn(e=>e.loadingDirectories.size>0||e.refreshingDirectories.size>0),Nt=pn(e=>e.archivedLoadingDirectories),Pt=Q.useDeferredValue(At),Ft=Q.useDeferredValue(jt),It=Kn(e=>e.currentSessionId),Lt=sn(e=>e.remoteSession!==null)?null:It,Vt=uo(e=>e.focus),Ht=Q.useSyncExternalStore(Bt,Rt,Rt),Ut=Kn(e=>!!e.newSessionDraft?.open),Wt=Kn(e=>e.newSessionDraft?.open&&!e.currentSessionId?e.newSessionDraft.selectedProjectId??null:null),Gt=Q.useMemo(()=>!e&&qe===`chat`&&Wt&&Ht.sessionId===null?{projectId:Wt,revision:Ht.revision}:null,[e,qe,Wt,Ht]),Kt=Kn(e=>e.setCurrentSession),qt=Kn(e=>e.updateSessionTitle),Jt=Kn(e=>e.shareSession),Yt=Kn(e=>e.unshareSession),Xt=Kn(e=>e.worktreeMetadata),Zt=Kn(e=>e.availableWorktreesByProject),tn=Kn(e=>e.openNewSessionDraft),nn=K(t=>{let n=je.find(e=>e.id===(t?.selectedProjectId??un.getState().activeProjectId));if(n){uc(n,e).catch(e=>X.error(e instanceof Error?e.message:String(e)));return}sn.getState().clearRemoteSession(),tn(t),Ot&&window.dispatchEvent(new CustomEvent(`yuri:navigate`,{detail:{view:`chat`}}))}),rn=Q.useMemo(()=>DS(Ae,Zt,{includeWorktrees:!Ot}),[Zt,Ot,Ae]),on=Q.useMemo(()=>{let e=new Map(wt.map(e=>[e.id,e])),t=Pt.map(t=>{let n=e.get(t.id);return n?Qt(n,t):t}),n=new Set(t.map(e=>e.id));return wt.forEach(e=>{n.has(e.id)||t.push(e)}),t.filter(e=>OS(e,rn,{allowUnknownDirectory:!Ot,allowEmptyDirectorySet:!Ot}))},[Pt,Ot,rn,wt]),ln=Q.useMemo(()=>wt.map(e=>{let t=ft(e.directory??null)??``;return`${e.id}:${e.title??``}:${+!!e.time?.archived}:${t}`}).join(`|`),[wt]),dn=Q.useRef(wt);Q.useEffect(()=>{dn.current=wt},[ln,wt]);let fn=Q.useMemo(()=>new Map(wt.map(e=>[e.id,e])),[wt]);Q.useEffect(()=>{let e=null,t=Ct(t=>{t.type===`scheduled-task-ran`&&(e&&clearTimeout(e),e=setTimeout(()=>{let e=un.getState().projects.find(e=>e.id===t.projectId),n=ft(e?.path??null);if(!n)return;let r=[n];(Kn.getState().availableWorktreesByProject.get(n)??[]).forEach(e=>{let t=ft(e.path);t&&r.push(t)}),hn(r,dn.current)},500))});return()=>{e&&clearTimeout(e),t()}},[]);let mn=Q.useMemo(()=>C(),[]),yn=_u(e=>e.sidebarBrandName.trim().length>0),{isTablet:bn,isDesktop:xn}=fi(),Sn=e||bn,{buildGroupSearchText:Cn,filterSessionNodesForSearch:En,buildGroupedSessions:Dn}=Oc({homeDirectory:Ee,worktreeMetadata:Xt,pinnedSessionIds:H,gitBranches:St,isVSCode:Ot}),{scheduleCollapsedProjectsPersist:On,hasRestoredProjectCollapse:An}=my({isVSCode:Ot,safeStorage:E,keys:{sessionExpanded:xS,sessionExpandedLegacy:SS,projectCollapse:_S,groupOrder:vS,projectActiveSession:bS,groupCollapse:yS},groupOrderByProject:ve,activeSessionByProject:be,collapsedGroups:ge,setExpandedParents:T,setCollapsedProjects:O}),jn=Q.useMemo(()=>[...on].sort((e,t)=>bo(e,t,H)),[on,H]),Mn=Q.useMemo(()=>{let e=new Map;return jn.forEach(t=>{let n=t.parentID;if(!n)return;let r=e.get(n)??[];r.push(t),e.set(n,r)}),e.forEach(e=>e.sort((e,t)=>bo(e,t,H))),e},[jn,H]),Nn=(0,$.jsxs)(`div`,{className:`py-6 text-center text-muted-foreground`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold`,children:o(`sessions.sidebar.empty.noSessions.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1`,children:o(`sessions.sidebar.empty.noSessions.description`)})]}),Pn=Q.useMemo(()=>Ae.find(e=>e.id===x)??null,[Ae,x]),Ln=Q.useCallback(e=>{x&&We(x,{label:e.label,icon:e.icon,color:e.color,iconBackground:e.iconBackground,defaultModel:e.defaultModel??null})},[x,We]),Rn=Q.useCallback(()=>{P(!0)},[P]),zn=Q.useCallback((t,n)=>{if(Ke(`chat`),e&&Ze(!1),!n?.remote){if(n?.sessionId){Kt(n.sessionId,t);return}tn({directoryOverride:t,preserveDirectoryOverride:!0})}},[e,tn,Ke,Kt,Ze]),Bn=K(()=>{let e=Dl.getState();if(e.available&&e.info){l(!0);return}e.checkForUpdates().then(()=>{let{available:e,error:t}=Dl.getState();if(t){X.error(o(`sessions.sidebar.updateCheck.errorTitle`),{description:t});return}if(!e){X.success(o(`sessions.sidebar.updateCheck.latestVersion`));return}l(!0)})}),Vn=Q.useCallback(()=>{e&&Ze(!1),Ye(!0)},[e,Ze,Ye]),Hn=K(()=>{let t=je.find(e=>e.id===un.getState().activeProjectId);if(t){uc(t,e).catch(e=>X.error(e instanceof Error?e.message:String(e)));return}sn.getState().clearRemoteSession(),Ke(`chat`),tn(),e&&Ze(!1)}),Un=Q.useCallback(()=>{if(!e){Ke(`schedule`);return}Qe(!0),Ze(!1)},[e,Ke,Qe,Ze]),Gn=Q.useCallback(()=>{Hr(),e&&Ze(!1)},[e,Ze]),qn=Kn(e=>e.archiveSession),Jn=Kn(e=>e.archiveSessions),{copiedSessionId:Yn,handleSessionSelect:Xn,handleSessionDoubleClick:Qn,handleSaveEdit:$n,handleCancelEdit:er,handleShareSession:tr,handleCopyShareUrl:nr,handleUnshareSession:rr,handleDeleteSession:ir,confirmDeleteSession:ar}=cy({activeProjectId:Be,currentDirectory:De,currentSessionId:Lt,mobileVariant:e,allowReselect:n,onSessionSelected:t,isSessionSearchOpen:u,sessionSearchQuery:f,setSessionSearchQuery:p,setIsSessionSearchOpen:d,setActiveProjectIdOnly:Ue,setDirectory:Oe,setActiveMainTab:Ke,setSessionSwitcherOpen:Ze,setCurrentSession:Kt,updateSessionTitle:qt,shareSession:Jt,unshareSession:Yt,archiveSession:qn,archiveSessions:Jn,childrenMap:Mn,showDeletionDialog:et,setDeleteSessionConfirm:V,deleteSessionConfirm:B,setEditingId:v,setEditTitle:b,editingId:_,editTitle:y}),cr=Q.useCallback((e,t,n,r=`project`)=>{sn.getState().clearRemoteSession();let i={sessionId:e,scope:r,projectId:n??null};if(e===Lt){zt(e),Mx(i),Xn(e,t,n);return}Ax(i,()=>Xn(e,t,n))},[Xn,Lt]);Q.useEffect(()=>()=>{kx()},[]);let lr=Q.useCallback(()=>{if(!te)return;let{scopeKey:e,folderId:t}=te;ne(null),mt(e,t)},[te,mt]);Q.useEffect(()=>{if(!Lt)return;let e=on.find(e=>e.id===Lt)?.parentID;if(!e)return;let t=[`project:active:${e}`,`project:archived:${e}`,`recent:active:${e}`,`recent:archived:${e}`];T(e=>{if(t.every(t=>e.has(t)))return e;let n=new Set(e);t.forEach(e=>n.add(e));try{E.setItem(xS,JSON.stringify(Array.from(n)))}catch{}return n})},[Lt,on,E]);let ur=Q.useCallback(e=>{T(t=>{let n=new Set(t);n.has(e)?n.delete(e):n.add(e);try{E.setItem(xS,JSON.stringify(Array.from(n)))}catch{}return n})},[E]),dr=Q.useCallback((e,t)=>{if(!e)return null;t&&ot.has(t)&&yt(t);let n=dt(e,o(`sessions.sidebar.folder.newFolderName`),t);return R(n.id),ee(n.name),n},[ot,yt,dt,o]),fr=K(cr),pr=K(Qn),mr=K($n),hr=K(er),gr=K(tr),_r=K(nr),vr=K(rr),yr=K(ir),br=K(dr),xr=K((e,t,n,r)=>{let i=_c(),a=Math.max(i,n)+7;if(M(e=>{let r=Math.max(i,e.get(t)??i,n),a=new Map(e);return a.set(t,r+7),a}),e.isArchivedBucket||a<r)return;let o=ft(e.directory??null);if(!o)return;let s=pn.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&_n(o)}),Sr=K(e=>{M(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})}),Cr=K(e=>{M(t=>{let n=!1,r=new Map(t),i=`${e}:`;for(let e of r.keys())e.startsWith(i)&&(r.delete(e),n=!0);return n?r:t})}),wr=Q.useMemo(()=>e=>{let t=Ae.find(t=>t.id===e),n=ft(t?.path??null);if(!n)return[];let r=[n];return Ot||(Zt.get(n)??[]).forEach(e=>{let t=ft(e.path);t&&r.push(t)}),r},[Zt,Ot,Ae]),Tr=K(e=>{let t=wr(e);if(t.length===0)return;let n=pn.getState().loadedDirectories,r=t.filter(e=>!n.has(e));r.length!==0&&hn(r,dn.current)}),Dr=K(e=>{let t=Ae.find(t=>t.id===e);t&&(async()=>{let e=[];if(!Ot)try{e=(await zs({id:t.id,path:t.path})).worktrees}catch(n){console.warn(`[SessionSidebar] Worktree refresh before session sync failed:`,n);let r=ft(t.path);e=r?Kn.getState().availableWorktreesByProject.get(r)??[]:[]}let n=fS(t.path,e,{currentDirectory:De,workspaceRoot:t.path,includeWorktrees:!Ot});n.length!==0&&await an(n,dn.current)})()});Q.useEffect(()=>{if(!An)return;let e=pn.getState(),t=Ae.flatMap(t=>D.has(t.id)?[]:wr(t.id).filter(t=>!e.loadedDirectories.has(t)&&!e.loadingDirectories.has(t)&&!e.refreshingDirectories.has(t)));t.length>0&&hn(t,dn.current)},[D,wr,An,Ae]);let Or=K(()=>{Te.current=Date.now()+150,M(new Map),O(()=>{let e=new Set(Ae.map(e=>e.id));try{E.setItem(_S,JSON.stringify(Array.from(e)))}catch{}return Ot||On(e),e})}),kr=K(()=>{Te.current=Date.now()+150,M(new Map),O(()=>{let e=new Set;try{E.setItem(_S,JSON.stringify([]))}catch{}return Ot||On(e),e});let e=pn.getState().loadedDirectories,t=Ae.flatMap(t=>wr(t.id).filter(t=>!e.has(t)));t.length>0&&hn(t,dn.current)}),Ar=K(e=>{Te.current=Date.now()+150,Cr(e),O(t=>{let n=new Set(t);n.has(e)?(n.delete(e),queueMicrotask(()=>Tr(e))):n.add(e);try{E.setItem(_S,JSON.stringify(Array.from(n)))}catch{}return Ot||On(n),n})}),jr=K(e=>{Te.current=Date.now()+150,Tr(e),O(t=>{if(!t.has(e))return t;let n=new Set(t);n.delete(e);try{E.setItem(_S,JSON.stringify(Array.from(n)))}catch{}return Ot||On(n),n})}),Mr=Q.useMemo(()=>Ae.map(e=>({...e,normalizedPath:ft(e.path)})).filter(e=>!!e.normalizedPath),[Ae]),Pr=Q.useMemo(()=>new Map(Mr.map(e=>[e.id,Fn(e.normalizedPath)||e.normalizedPath])),[Mr]),Fr=Q.useMemo(()=>Mr.map(e=>e.normalizedPath),[Mr]),Ir=Q.useMemo(()=>{let e=new Set(Mr.map(e=>e.normalizedPath));if(!Ot)for(let t of Zt.values())for(let n of t){let t=ft(n.path);t&&e.add(t)}return[...e].sort()},[Zt,Ot,Mr]),Lr=Q.useRef(null);Q.useEffect(()=>{let e=new Set(Ir),t=Lr.current;if(Lr.current=e,!t)return;let n=Ir.filter(e=>!t.has(e));if(n.length===0)return;let r=pn.getState().loadedDirectories,i=ft(De),a=Mr.find(e=>e.id===Be)??Mr.find(e=>e.normalizedPath===i)??null,o=new Set;i&&o.add(i),a?.normalizedPath&&(o.add(a.normalizedPath),Ot||(Zt.get(a.normalizedPath)??[]).forEach(e=>{let t=ft(e.path);t&&o.add(t)}));let s=n.filter(e=>o.has(e)&&!r.has(e));s.length!==0&&hn(s,dn.current)},[Be,Zt,De,Ot,Mr,Ir]);let Rr=Xi(a?Fr:AS);gy({normalizedProjects:Mr,activeProjectId:Be,gitRepoStatus:Rr,setProjectRepoStatus:A,setProjectRootBranches:we,enabled:a});let zr=Q.useMemo(()=>Pl(on,Mr,Zt,Ot,Ft),[Ft,Zt,Ot,Mr,on]),{getSessionsForProject:Br,getArchivedSessionsForProject:Vr}=_y({ownership:zr}),Ur=Mt||kt===`idle`||kt===`loading`,Wr=Q.useRef(!1);Be&&k.has(Be)&&(Wr.current=!!k.get(Be));let Gr=Tn(e=>e.projectSortOrder),Kr=Q.useMemo(()=>tl(Mr,Gr),[Mr,Gr]),{projectSections:qr,groupSearchDataByGroup:Jr,sectionsForRender:Yr,searchMatchCount:Xr}=iy({normalizedProjects:Kr,getSessionsForProject:Br,getArchivedSessionsForProject:Vr,availableWorktreesByProject:Zt,projectRepoStatus:k,projectRootBranches:Ce,lastRepoStatus:Wr.current,buildGroupedSessions:Dn,hasSessionSearchQuery:it,normalizedSessionSearchQuery:rt,filterSessionNodesForSearch:En,buildGroupSearchText:Cn,foldersMap:st}),Zr=(0,$.jsxs)(`div`,{className:`py-6 text-center text-muted-foreground`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold`,children:o(`sessions.sidebar.empty.noMatches.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1`,children:o(`sessions.sidebar.empty.noMatches.description`)})]});ay({projectSections:qr,activeProjectId:Be,activeSessionByProject:be,setActiveSessionByProject:xe,currentSessionId:Lt,handleSessionSelect:Xn,newSessionDraftOpen:Ut,mobileVariant:e,openNewSessionDraft:tn,setActiveMainTab:Ke,setSessionSwitcherOpen:Ze});let{getOrderedGroups:Qr}=oy(ve),$r=Q.useRef(!1);Q.useEffect(()=>{if($r.current||qr.length===0)return;let e=qr.flatMap(e=>e.groups.filter(e=>e.isArchivedBucket).map(t=>`${e.project.id}:${t.id}`));e.length>0&&_e(t=>new Set([...t,...e])),$r.current=!0},[qr]);let ei=Q.useMemo(()=>{let e=new Map,t=new Map;return qr.forEach(n=>{let r=Fn(n.project.normalizedPath)||n.project.normalizedPath;n.groups.forEach(i=>{let a=i.branch&&i.branch!==`HEAD`&&i.branch!==r?i.branch:null,o={projectLabel:r,branchLabel:a},s=r=>{r.forEach(r=>{let a=n.project.normalizedPath.length;a<(t.get(r.session.id)??-1)||(e.set(r.session.id,{node:r,projectId:n.project.id,groupDirectory:i.directory,secondaryMeta:o}),t.set(r.session.id,a),r.children.length>0&&s(r.children))})};s(i.sessions)})}),e},[qr]);Q.useLayoutEffect(()=>{if(!Lt){Mx(null);return}let e=uo.getState().focus;if(e?.sessionId===Lt){e.scope===`project`&&!e.projectId&&Mx({...e,projectId:ei.get(Lt)?.projectId??null});return}Mx({scope:`project`,sessionId:Lt,projectId:ei.get(Lt)?.projectId??null})},[Lt,ei]);let ti=Q.useMemo(()=>Ot?[]:Ac(on,H,ct[Ec]),[Ot,H,on,ct]),ni=K((e,t)=>{_||xt(Ec,si.map(e=>e.node.session.id),e,t,{}).catch(()=>X.error(o(`sessions.order.saveFailed`)))}),ri=Q.useMemo(()=>it?[]:Vc(on,H,Et,Dt),[it,H,Et,on,Dt]),{pinnedItems:ii,inProgressItems:ai}=Q.useMemo(()=>{let e=e=>{let t=ei.get(e.id),n=ft(e.directory??null),r={session:e,children:[],worktree:Xt.get(e.id)??null};if(it&&En([r],rt).length===0)return null;let i=zr.bySessionId.get(e.id),a=i?Kr.find(e=>e.id===i.projectId):void 0,o=a?Fn(a.normalizedPath)||a.normalizedPath:t?.secondaryMeta?.projectLabel??null,s=hc({projectLabel:o,owner:i,sessionWorktree:Xt.get(e.id)??null,worktrees:a?Zt.get(a.normalizedPath)??[]:[],projectRootBranch:i?Ce.get(i.projectId)??(a?Rr.get(a.normalizedPath)?.branch:null)??null:null,isVSCode:Ot})??t?.secondaryMeta??null;return{node:r,projectId:i?.projectId??t?.projectId??null,groupDirectory:i?.scopeDirectory??t?.groupDirectory??n,secondaryMeta:s}},t=t=>t.map(e).filter(e=>e!==null);return{pinnedItems:Ot?[]:t(ti),inProgressItems:t(ri)}},[Zt,En,Rr,it,ri,Ot,rt,ti,Ce,zr,ei,Kr,Xt]),oi=Q.useMemo(()=>je.flatMap(e=>Me.get(e.id)??[]),[je,Me]),si=Q.useMemo(()=>wl([...ii,...oi.filter(e=>e.pinned)],e=>e.node.session.id,ct[Ec]),[ii,oi,ct]),ci=Q.useMemo(()=>[...ai,...oi.filter(e=>!e.pinned)].sort((e,t)=>kn(t.node.session)-kn(e.node.session)),[ai,oi]),li=!e&&!Ot&&!r&&!i,ui=li&&le===`tasks`&&!it,di=bl(Et,a&&li),[pi,mi]=Q.useState(cS),hi=Q.useMemo(()=>ui?yl({sessions:on,pinnedSessionIds:H,settledSessionIds:oe,indexedSessionIds:W?.indexedIds??null,settledAtBySessionId:W?.settledAtById,runningSessionIds:Et,pendingRequestSessionIds:ce,unseenBySession:Dt}):null,[ce,H,Et,on,oe,W,ui,Dt]),gi=Q.useMemo(()=>{let e=hi?.settled.filter(e=>!oe.has(e.id));return e?.length?new Set([...oe,...e.map(e=>e.id)]):oe},[hi,oe]),_i=K(e=>({activityAt:kn(e),running:Et.has(e.id),attention:Ic(e.id,ce,Dt)})),vi=Q.useMemo(()=>{if(!hi)return null;let e=uS(hi.active,e=>e.id,_i,pi);return e===hi.active?hi:{...hi,active:e}},[hi,_i,pi]),yi=K((e,t)=>{if(_||!vi)return;let n=new Map(vi.active.map(e=>[e.id,e])),r=dS(vi.active.map(e=>e.id),e,t,e=>{let t=n.get(e);return t?_i(t):void 0});r&&mi(r)}),bi=K((e,t,n)=>{if(!ui||qe!==`chat`||Lt!==e||Rt()!==n)return;let r=[...ti,...vi?.active??[]].filter(t=>t.id!==e),i=r.find(e=>e.id===t)??r[0];if(!i){kx(),Mx(null),tn();return}let a=zr.bySessionId.get(i.id);cr(i.id,a?.scopeDirectory??ft(i.directory??null),a?.projectId??null,H.has(i.id)?`pinned`:`project`)}),xi=K((e,t)=>{if(!t&&hi?.settled.some(t=>t.id===e&&t.time?.archived)){Wn(e);return}if(!t||!ui||Lt!==e){se(e,t);return}let n=[...ti,...vi?.active??[]],r=n.findIndex(t=>t.id===e),i=n[r+1]??n[r-1],a=Rt();se(e,!0,{onSuccess:()=>bi(e,i?.id??null,a)})}),Si=li?xi:void 0,Ci=Q.useMemo(()=>{if(!vi)return null;let e=o(`sessions.sidebar.task.unassigned`),t=new Map(Kr.map(e=>[e.id,Fn(e.normalizedPath)||e.normalizedPath])),n=me.current,r=new Map(Kr.map(e=>[e.id,e.normalizedPath])),i=new Map;for(let e of Kr){let t=n.get(e.id),r=t&&t.icon===e.icon&&t.color===e.color&&t.iconImage?.mime===e.iconImage?.mime&&t.iconImage?.updatedAt===e.iconImage?.updatedAt&&t.iconImage?.source===e.iconImage?.source?t:{id:e.id,icon:e.icon,color:e.color,iconImage:e.iconImage};n.set(e.id,r),i.set(e.id,r)}let a=pe.current,s=new Map,c=n=>o=>{let c=zr.bySessionId.get(o.id),l=ei.get(o.id),u=c?.projectId??l?.projectId??null,d=c?.scopeDirectory??l?.groupDirectory??ft(o.directory??null),f=c?i.get(c.projectId)??null:null,p=c&&t.get(c.projectId)||e,m=c?r.get(c.projectId)??null:null,h=m?Rr.get(m):void 0,g=Xt.get(o.id)??null,_=(l?.secondaryMeta?.branchLabel??(c?Ce.get(c.projectId):null)??h?.branch??g?.branch??null)?.trim()||null,v=_&&_!==`HEAD`&&_!==p?_:null,y=v?null:!m||h?.isGitRepo===!1?`no-git`:`loading`,b=y===`no-git`&&m?or(m,Ee):null,x=g,S=n?di.get(o.id)??null:null,C=a.get(o.id);if(C&&C.session===o&&C.card===n&&C.projectId===u&&C.groupDirectory===d&&C.projectLabel===p&&C.branchLabel===v&&C.branchState===y&&C.pathLabel===b&&C.worktree===x&&C.project===f&&C.runStartedAt===S)return s.set(o.id,C),C.item;let w={node:{session:o,children:[],worktree:x},projectId:u,groupDirectory:d,secondaryMeta:{projectLabel:p,branchLabel:v,branchState:y,pathLabel:b,card:n,slim:!n,project:f,runStartedAt:S}};return s.set(o.id,{session:o,card:n,projectId:u,groupDirectory:d,projectLabel:p,branchLabel:v,branchState:y,pathLabel:b,worktree:x,project:f,runStartedAt:S,item:w}),w},l=de.settledOpen?vi.settled.slice(0,de.settledLimit):[],u={pinned:ti.map(c(!0)),active:vi.active.map(c(!0)),settled:l.map(c(!1)),settledTotal:vi.settled.length};return pe.current=s,u},[Rr,Ee,ti,Ce,di,zr,ei,Kr,o,vi,de.settledLimit,de.settledOpen,Xt]),wi=Q.useMemo(()=>{if(!Ci)return si;let e=new Map(Ci.pinned.map(e=>[e.node.session.id,e]));return si.map(t=>e.get(t.node.session.id)??t)},[si,Ci]),Ti=Q.useMemo(()=>{if(!vi||!Ci)return[];let e=new Map([...Ci.active,...Ci.settled].map(e=>[e.node.session.id,e]));return bc(vi,de).flatMap((t,n)=>{let r=e.get(t.id);return r?[{scope:`project`,sessionId:t.id,projectId:r.projectId,directory:ft(gn(t))??r.groupDirectory??null,visibleIndex:n}]:[]})},[vi,Ci,de]),Ei=Q.useMemo(()=>Yr.map(e=>({...e,groups:e.groups.filter(e=>!e.isArchivedBucket)})),[Yr]),Di=Q.useMemo(()=>{let e=it?Ei.map(e=>({...e,groups:e.groups.map(e=>({...e,sessions:Jr.get(e)?.filteredNodes??[]}))})):Ei;if(!i)return e;let t=e.find(e=>e.project.id===Be)??e[0];if(!t)return[];let n=t.groups.find(e=>e.isMain&&e.sessions.length>0)??t.groups.find(e=>e.sessions.length>0)??t.groups.find(e=>e.isMain)??t.groups[0];return n?[{...t,groups:[n]}]:[]},[Be,Jr,it,Ei,i]),Oi=Q.useMemo(()=>xl({sections:Di,foldersMap:st,getOrderedGroups:Qr,pinnedSessionIds:H,sessionOrderByScope:ct,sessionOrderActivityByScope:lt}),[st,Qr,Di,H,lt,ct]),ki=Q.useMemo(()=>Wc({targets:Oi,collapsedProjectIds:D,collapsedGroupKeys:ge,collapsedFolderIds:ot,visibleSessionCountByGroup:j,defaultVisibleSessionCount:_c(),hasSessionSearchQuery:it,alwaysVisibleSessionIds:Tt}),[Tt,ot,ge,D,it,Oi,j]),Ai=Q.useMemo(()=>it?[]:(ui?si:[...si,...ci]).map((e,t)=>{let n=e.node.session;return{scope:`pinned`,sessionId:n.id,projectId:e.projectId,directory:ft(gn(n))??e.groupDirectory??null,visibleIndex:t}}),[it,ci,si,ui]),[ji,Mi]=Q.useState(null),Ni=Q.useCallback(e=>{Mi(t=>t&&t.length===e.length&&t.every((t,n)=>t===e[n])?t:[...e])},[]),Pi=Q.useMemo(()=>{if(!ji)return Ai;let e=new Set(ji);return Ai.filter(t=>e.has(t.sessionId))},[Ai,ji]),Fi=Q.useMemo(()=>!a&&Se.current?Se.current:{pinned:Pi,project:ui?Ti:ki},[a,Ti,ui,Pi,ki]);Q.useLayoutEffect(()=>{a&&(Se.current=Fi)},[a,Fi]);let Ii=Q.useMemo(()=>e?[]:so({pinnedTargets:Fi.pinned,projectTargets:ui?Fi.project:ke.flatMap(e=>e.hostId?Le.get(e.id)??[]:Fi.project.filter(t=>t.projectId===e.id))}),[e,ui,Fi,ke,Le]),Li=Q.useCallback(t=>{let n=je.find(e=>e.id===t.projectId);if(n&&Ie.registry){let r=Me.get(n.id)?.find(e=>e.identity===t.sessionId);lc(n,Ie.registry,r?.remoteSessionId??t.sessionId,t.directory??n.path,e);return}Ke(`chat`),Ze(!1),t.scope===`project`&&t.projectId&&Ue(t.projectId),cr(t.sessionId,t.directory,t.projectId,t.scope)},[cr,Ke,Ue,Ze,je,Ie.registry,Me,e]);Q.useLayoutEffect(()=>ro({targets:Ii,activate:Li}),[Li,Ii]);let Ri=Q.useMemo(()=>{let e=new Map;return Ii.forEach(t=>{let n=Qa({scope:t.scope,sessionId:t.sessionId,projectId:t.projectId});n&&e.set(n,Ya(Ii,t)??0)}),e},[Ii]),zi=Q.useMemo(()=>{if(!Lt||it)return[];let e=[],t=(n,r)=>{if(n.session.id===Lt){e.push({scope:`pinned`,sessionId:Lt,projectId:r});return}n.children.forEach(e=>t(e,r))};return si.forEach(e=>t(e.node,e.projectId)),ai.forEach(e=>t(e.node,e.projectId)),e},[Lt,it,ai,si]),Bi=Q.useMemo(()=>{if(!Lt)return[];let e=[],t=(n,r)=>{if(n.session.id===Lt){e.push({scope:`project`,sessionId:Lt,projectId:r});return}n.children.forEach(e=>t(e,r))};return qr.forEach(e=>{e.groups.forEach(n=>{n.sessions.forEach(n=>t(n,e.project.id))})}),e},[Lt,qr]);Q.useLayoutEffect(()=>io({pinned:Fi.pinned,project:Fi.project}),[Fi]),Q.useLayoutEffect(()=>{!a||Ur||Mx(mS({currentSessionId:Lt,focus:Vt,pinnedFocuses:zi,projectFocuses:Bi,fallbackProjectId:Lt?ei.get(Lt)?.projectId??null:null}))},[Lt,a,Ur,Bi,zi,Vt,ei]);let Vi=Q.useMemo(()=>{let e=Vt?.sessionId?ei.get(Vt.sessionId)?.projectId??null:null;return hS(Vt,Oi,e)},[Oi,Vt,ei]),Hi=Q.useRef(null),Ui=Q.useRef(null);Q.useEffect(()=>{Ui.current&&Ui.current!==Lt&&(Ui.current=null)},[Lt]),Q.useLayoutEffect(()=>{if(!Vi?.projectId)return;let e=Vi.sessionId,t=Ht.sessionId===e;if(!(!t&&Lt!==e)){if(t){if(Hi.current===Ht.revision)return;Hi.current=Ht.revision,Ui.current=e}else{if(Ui.current===e)return;Ui.current=e}if(jr(Vi.projectId),Vi.groupKey&&_e(e=>{if(!e.has(Vi.groupKey))return e;let t=new Set(e);return t.delete(Vi.groupKey),t}),Vi.folderAncestorIds?.forEach(e=>{let t=en.getState();t.collapsedFolderIds.has(e)&&t.toggleFolderCollapse(e)}),Vi.groupKey&&Vi.visibleIndex!==void 0){let e=Vi.visibleIndex+1;M(t=>{if((t.get(Vi.groupKey)??0)>=e)return t;let n=new Map(t);return n.set(Vi.groupKey,e),n})}}},[Lt,Vi,Ht]);let Wi=MS((t,n=0,r,i,a=!1,o,s=`project`,c)=>(0,$.jsx)(Kx,{node:t,depth:n,groupDirectory:r,projectId:i,archivedBucket:a,currentSessionId:Lt,pinnedSessionIds:H,settledSessionIds:gi,setSessionSettled:Si,expandedParents:w,hasSessionSearchQuery:it,normalizedSessionSearchQuery:rt,notifyOnSubtasks:$e,editingId:_,setEditingId:v,editTitle:y,setEditTitle:b,handleSaveEdit:mr,handleCancelEdit:hr,toggleParent:ur,handleSessionSelect:fr,handleSessionDoubleClick:pr,togglePinnedSession:U,handleShareSession:gr,copiedSessionId:Yn,handleCopyShareUrl:_r,handleUnshareSession:vr,openSidebarMenuKey:F,setOpenSidebarMenuKey:I,renamingFolderId:L,getFoldersForScope:ut,getSessionFolderId:bt,removeSessionFromFolder:_t,addSessionToFolder:ht,createFolderAndStartRename:br,handleDeleteSession:yr,mobileVariant:e,alwaysShowActions:Sn,renderSessionNode:Wi,secondaryMeta:o,renderContext:s,subtreeContainsActive:c?.subtreeContainsActive??kS,subtreeContainsEditing:c?.subtreeContainsEditing??kS,menuOpenSessionId:c?.menuOpenSessionId??null,nodeStructureKey:c?.nodeStructureKey??``,childRenderExtrasFor:c?.childRenderExtrasFor,liveSessionById:fn,shortcutNumber:Ri.get(Qa({scope:s,sessionId:t.session.id,projectId:i??null})??``)??null},`${s}:${i??``}:${t.session.id}`),JSON.stringify([...Ri])),Gi=Q.useCallback(e=>{Sr(e),_e(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[Sr]),Ki=Q.useCallback(e=>{let t=wr(e);if(t.length===0)return;let n=pn.getState(),r=t.filter(e=>!n.archivedLoadedDirectories.has(e));r.length>0&&Zn(r)},[wr]),qi=K((e,t,n,r,i)=>{let a=e.folderScopeKey??ft(e.directory??null);a&&xt(a,t,n,r,i).catch(()=>X.error(o(`sessions.order.saveFailed`)))}),Ji=K((e,t,n)=>{e.isArchivedBucket&&ge.has(t)&&n&&Ki(n),Gi(t)}),Yi=Q.useMemo(()=>(t,n,r,i,a,o,s)=>(0,$.jsx)(pc,{group:t,groupKey:n,isArchivedLoading:!!(t.isArchivedBucket&&r&&wr(r).some(e=>Nt.has(e))),projectId:r,projectLabel:r?Pr.get(r)??null:null,hideGroupLabel:i,compactBodyPadding:o,hasSessionSearchQuery:it,normalizedSessionSearchQuery:rt,groupSearchDataByGroup:Jr,visibleSessionCount:j.get(n),collapsedGroups:ge,collapsedFolderIds:ot,toggleFolderCollapse:yt,renameFolder:pt,deleteFolder:mt,showDeletionDialog:et,setDeleteFolderConfirm:ne,renderSessionNode:Wi,projectRepoStatus:k,lastRepoStatus:Wr.current,showMoreGroupSessions:xr,resetGroupSessionLimit:Sr,mobileVariant:e,alwaysShowActions:Sn,activeProjectId:Be,setActiveProjectIdOnly:Ue,setActiveMainTab:Ke,setSessionSwitcherOpen:Ze,openNewSessionDraft:nn,addSessionToFolder:ht,createFolderAndStartRename:br,renamingFolderId:L,renameFolderDraft:z,setRenameFolderDraft:ee,setRenamingFolderId:R,pinnedSessionIds:H,expandedParents:w,sessionOrderByScope:ct,sessionOrderActivityByScope:lt,onReorderSessions:qi,currentSessionId:Lt,shortcutTargetSessionId:Vi?.groupKey===n?Vi.sessionId:null,shortcutTargetVisibleIndex:Vi?.groupKey===n?Vi.visibleIndex??null:null,editingId:_,editTitle:y,openSidebarMenuKey:F,liveSessionById:fn,alwaysVisibleSessionIds:Tt,onToggleCollapsedGroup:Ji,dragHandleProps:a,scrollContainerRef:s}),[it,rt,Jr,Pr,Nt,wr,j,ge,ot,yt,pt,mt,et,Wi,k,xr,Sr,e,Sn,Be,Ue,Ke,Ze,nn,ht,br,L,z,H,w,ct,lt,qi,Lt,Vi,_,y,F,fn,Tt,Ji]),Zi=ui?(0,$.jsx)(J,{variant:`ghost`,size:`xs`,className:`-mr-0.5 size-6 p-0 text-muted-foreground`,"aria-label":o(`sessions.sidebar.header.actions.addProject`),title:o(`sessions.sidebar.header.actions.addProject`),onClick:sr.requestDirectoryDialog,children:(0,$.jsx)(Z,{name:`add`,className:`size-4`})}):null,Qi=li?(0,$.jsx)(tS,{value:le,onChange:he}):void 0,$i=e=>Wi(e.node,0,e.groupDirectory,e.projectId,!1,e.secondaryMeta,`project`),ea=ui&&Ci?(0,$.jsx)(rS,{items:Ci,renderTaskRow:$i,onSessionsReordered:yi}):void 0,ta=ui&&Ci?(0,$.jsx)(sS,{items:Ci,open:de.settledOpen,onToggle:()=>fe(e=>({...e,settledOpen:!e.settledOpen,settledLimit:30})),onShowMore:()=>fe(e=>({...e,settledLimit:e.settledLimit+30})),renderTaskRow:$i}):void 0,na=r?null:(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(Ay,{collapseAllProjects:Or,expandAllProjects:kr}),(0,$.jsx)(J,{variant:`ghost`,size:`xs`,className:`-mr-0.5 size-6 p-0 text-muted-foreground`,"aria-label":o(`sessions.sidebar.header.actions.addProject`),title:o(`sessions.sidebar.header.actions.addProject`),onClick:sr.requestDirectoryDialog,children:(0,$.jsx)(Z,{name:`add`,className:`size-4`})})]}),ra=mn&&yn&&!Ot&&!it?(0,$.jsx)(`div`,{className:`shrink-0 px-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(bf,{className:`min-w-0 flex-1`}),(0,$.jsx)(ol,{className:`ml-auto shrink-0`})]})}):null,ia=!Ot&&!it,aa=ia&&xn&&!e,oa=ui?[]:ci,sa=!it&&(si.length>0||oa.length>0),ca=(0,$.jsxs)(`div`,{className:`space-y-0.5 py-1`,children:[(0,$.jsxs)(J,{variant:`ghost`,size:`sm`,className:Y(`w-full justify-start px-2 font-normal`,e&&`h-11`),onClick:Hn,children:[(0,$.jsx)(Z,{name:`chat-new`,className:`size-4`}),(0,$.jsx)(`span`,{className:`truncate`,children:o(`sessions.sidebar.header.actions.newSession`)})]}),(0,$.jsxs)(J,{variant:`ghost`,size:`sm`,className:Y(`w-full justify-start px-2 font-normal`,qe===`schedule`&&`bg-interactive-selection text-interactive-selection-foreground`,e&&`h-11`),onClick:Un,children:[(0,$.jsx)(Z,{name:`time`,className:`size-4`}),(0,$.jsx)(`span`,{className:`truncate`,children:o(`sessions.sidebar.header.actions.scheduledTasks`)}),a?(0,$.jsx)(Uv,{}):null]}),Je.data?.supported&&Je.data?.enabled?(0,$.jsxs)(J,{variant:`ghost`,size:`sm`,className:Y(`w-full justify-start px-2 font-normal`,qe===`assistant`&&`bg-interactive-selection text-interactive-selection-foreground`,e&&`h-11`),onClick:Gn,children:[(0,$.jsx)(ul,{className:`size-4 shrink-0 [&[data-assistant-navigation-avatar]]:scale-125`}),(0,$.jsx)(`span`,{className:`truncate`,children:o(`assistants.title`)}),(0,$.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,$.jsx)(Vl,{className:`h-3.5 min-w-3.5 px-1 text-[10px]`}),a?(0,$.jsx)(Wv,{}):null]})]}):null,(0,$.jsx)(Eu,{sidebar:!0,mobile:e})]}),la=li&&!it,ua=sa?(0,$.jsx)(xy,{isFirst:la,hideHeader:ui,items:wi,reorderEnabled:!0,onSessionsReordered:ni,inProgressItems:oa,renderSessionNode:Wi,currentSessionId:Lt,editingId:_,openSidebarMenuKey:F,onVisibleSessionIdsChange:Ni}):null,da=ia&&!aa||sa&&!la?(0,$.jsxs)($.Fragment,{children:[ia&&!aa?(0,$.jsxs)($.Fragment,{children:[e&&yn?(0,$.jsx)(bf,{}):null,ca]}):null,la?null:ua]}):null,fa=!!(L||_||x),{selectionModeEnabled:pa,hasSelection:ma,selectedIdsSize:ha,bulkScopeIsArchived:ga,derivedSelectionScope:_a,bulkScopeFolders:va,bulkCanRemoveFromFolder:ya,handleExitSelectionMode:ba,handleBulkMoveToFolder:xa,handleBulkCreateFolderAndMove:Sa,handleBulkRemoveFromFolder:Ca,handleBulkDelete:wa,confirmBulkDelete:Ta}=$x({isInlineEditing:fa,showDeletionDialog:et,foldersMap:st,addSessionsToFolder:gt,removeSessionsFromFolders:vt,createFolderAndStartRename:dr,archiveSessions:Jn,setBulkDeleteConfirm:ie});return(0,$.jsxs)(`div`,{ref:h,className:Y(`yuri-session-sidebar relative flex h-full flex-col text-foreground overflow-x-hidden`,e?``:`bg-transparent`),children:[(0,$.jsx)(yy,{hideDirectoryControls:r,isSessionSearchOpen:u,setIsSessionSearchOpen:d,sessionSearchInputRef:g,sessionSearchQuery:f,setSessionSearchQuery:p,hasSessionSearchQuery:it,searchMatchCount:Xr}),ra,aa?(0,$.jsx)(`div`,{className:`shrink-0 px-3`,children:ca}):null,a?(0,$.jsx)(xb,{remoteProjects:je,hostRegistry:Ie.registry,projectOrderIds:tl(ke,Gr).map(e=>e.id),onRemoteActivityItems:Fe,remoteSearch:f,remoteError:Ie.catalog.error?.message,onRemoteNavigationTargets:ze,topContent:da,tabLeadingContent:la?ua:void 0,hasLeadingSection:da!==null&&!la&&(si.length>0||ai.length>0),headerAccessory:ui?Zi:na,headerSwitch:Qi,taskContent:ea,taskFooter:ta,sectionsForRender:Ei,projectSections:qr,activeProjectId:Be,projectRevealTarget:Gt,showOnlyMainWorkspace:i,hasSessionSearchQuery:it,emptyState:Nn,searchEmptyState:Zr,renderGroupSessions:Yi,homeDirectory:Ee,collapsedProjects:D,hideDirectoryControls:r,projectRepoStatus:k,mobileVariant:e,alwaysShowActions:Sn,toggleProject:Ar,setActiveProjectIdOnly:Ue,setActiveMainTab:Ke,setSessionSwitcherOpen:Ze,openNewSessionDraft:nn,openNewWorktreeDialog:Rn,syncProjectSessions:Dr,openProjectEditDialog:S,removeProject:Ve,projectReorderEnabled:Gr===`manual`,reorderProjects:Ge,projectSortOrder:Gr,getOrderedGroups:Qr,setGroupOrderByProject:ye,openSidebarMenuKey:F,setOpenSidebarMenuKey:I,isInlineEditing:fa}):null,pa&&ma?(0,$.jsx)(Qx,{selectedCount:ha,scopeKey:_a,scopeFolders:va,archivedBucket:ga,onMoveToFolder:xa,onCreateFolderAndMove:Sa,onRemoveFromFolder:Ca,canRemoveFromFolder:ya,onDelete:wa,onDone:ba}):null,(0,$.jsx)(Yv,{normalizedProjects:Mr,ownership:zr,enabled:a}),(0,$.jsx)(db,{onOpenSettings:Vn,onOpenShortcuts:Xe,onOpenUpdate:Bn,showRuntimeButtons:!Ot,showUpdateButton:at}),s?(0,$.jsx)(NS,{onOpenChange:l}):null,Pn?(0,$.jsx)(vy,{open:!0,onOpenChange:e=>{e||S(null)},project:Pn,onSave:Ln}):null,N?(0,$.jsx)(fs,{open:!0,onOpenChange:P,onWorktreeCreated:zn}):null,(0,$.jsx)(ll,{}),(0,$.jsx)(yu,{}),(0,$.jsx)(Yx,{value:B,setValue:V,showDeletionDialog:et,setShowDeletionDialog:tt,onConfirm:ar}),(0,$.jsx)(Zx,{value:te,setValue:ne,onConfirm:lr}),(0,$.jsx)(Xx,{value:re,setValue:ie,showDeletionDialog:et,setShowDeletionDialog:tt,onConfirm:Ta})]})});function FS(e){return{info:e.info,downloading:e.downloading,downloaded:e.downloaded,progress:e.progress,error:e.error,runtimeType:e.runtimeType,onDownload:e.downloadUpdate,onRestart:e.restartToUpdate}}var IS=e=>e?(0,$.jsx)(`span`,{className:`text-foreground/80 dark:text-foreground/70`,children:e}):void 0,LS=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.replace(/\/+$/,``)},RS=()=>{let{t:e}=Nr(),[t,n]=Q.useState(!1),[r,i]=Q.useState(),[a,o]=Q.useState(null),[s,c]=Q.useState([]),[l,u]=Q.useState(!1),[d,f]=Q.useState(!1),[p,m]=Q.useState(!1),[h,g]=Q.useState(!1),[_,v]=Q.useState(new Set),y=Kn(e=>e.getWorktreeMetadata),b=Kn(e=>e.newSessionDraft),x=Kn(e=>e.setNewSessionDraftTarget),S=Kn(e=>e.setDraftBootstrapPendingDirectory),C=lr,w=Kn(e=>e.archiveSessions),T=q(e=>e.showDeletionDialog),E=q(e=>e.setShowDeletionDialog),D=G(e=>e.currentDirectory),O=G(e=>e.homeDirectory),k=un(e=>e.projects),A=un(e=>e.activeProjectId),{isMobile:j,isTablet:M,hasTouchInput:N}=fi(),P=j||M||N,F=Q.useMemo(()=>LS((A?k.find(e=>e.id===A)??null:null)?.path??D),[A,D,k]),I=Q.useCallback(e=>{let t=LS(e.projectDirectory)||F;return{id:(k.find(e=>LS(e.path)===t)??null)?.id??`path:${t}`,path:t}},[F,k]),L=h&&_.size>0,R=Q.useMemo(()=>{let e=a?.worktree;return e&&typeof e.branch==`string`&&e.branch.trim().length>0?!0:s.length>0&&s.every(({metadata:e})=>typeof e.branch==`string`&&e.branch.trim().length>0)},[a?.worktree,s]),z=a?.mode===`worktree`,ee=z,B=p||!z||!R,V=p||!z,te=Q.useCallback(e=>{o({sessions:e.sessions,dateLabel:e.dateLabel,mode:e.mode??`session`,worktree:e.worktree??null})},[]),ne=Q.useCallback(()=>{o(null),c([]),u(!1),f(!1),m(!1),g(!1),v(new Set)},[]),re=Q.useCallback(t=>{if(t.sessions.length===0)return;let n=t.sessions.map(e=>e.id);vl({sessionIds:n,message:n.length===1?e(`sessions.sidebar.session.delete.success`):e(`sessions.sidebar.bulkActions.deletedPlural`,{count:n.length}),undoLabel:e(`sessions.sidebar.undo`),commitFailedMessage:n.length===1?e(`sessions.sidebar.session.delete.error`):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:n.length})})},[e]);Q.useEffect(()=>sr.onDeleteRequest(e=>{if(!T&&(e.mode??`session`)===`session`){re(e);return}te(e)}),[te,T,re]),Q.useEffect(()=>sr.onDirectoryRequest(({origin:e})=>{i(e),n(!0)}),[]),Q.useEffect(()=>{if(!a){c([]),u(!1),f(!1),g(!1),v(new Set);return}let e=a.sessions.map(e=>{let t=y(e.id);return t?{session:e,metadata:t}:null}).filter(e=>!!e);c(e),u(!1),g(!1),v(new Set);let t=new Map;if(a.worktree?.path&&t.set(LS(a.worktree.path),a.worktree),e.forEach(({metadata:e})=>{e.path&&t.set(LS(e.path),e)}),t.size===0){g(!0);return}let n=!1;return(async()=>{let e=new Map,r=new Set;await Promise.all(Array.from(t.entries()).map(async([t,n])=>{try{let i=await Ls(n.path);e.set(t,i),i?.isDirty&&r.add(t)}catch{n.status&&(e.set(t,n.status),n.status.isDirty&&r.add(t))}})).catch(e=>{console.warn(`Failed to inspect worktree status before deletion:`,e)}),!n&&(v(r),g(!0),o(t=>{if(!t?.worktree?.path)return t;let n=LS(t.worktree.path),r=e.get(n);if(!r)return t;let i=t.worktree.status;return i?.isDirty===r.isDirty&&i?.ahead===r.ahead&&i?.behind===r.behind&&i?.upstream===r.upstream?t:{...t,worktree:{...t.worktree,status:r}}}),c(t=>t.map(t=>{let n=LS(t.metadata.path),r=e.get(n);return r?{session:t.session,metadata:{...t.metadata,status:r}}:t})))})(),()=>{n=!0}},[a,y]),Q.useEffect(()=>{R||u(!1)},[R]);let ie=Q.useCallback(async(t,n)=>{let r=l&&R,i=I(t),a=LS(t.path),o=LS(i.path);try{await Rs(i,t,{deleteRemoteBranch:r,deleteLocalBranch:n});let e=LS(b?.directoryOverride);return b?.open&&a&&e===a&&o&&(S(null),x({projectId:i.id,directoryOverride:o},{force:!0})),LS(D)===a&&o&&G.getState().setDirectory(o,{showOverlay:!1}),!0}catch(t){return X.error(e(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:IS(t instanceof Error?t.message:e(`sessions.sidebar.dialogs.deleteResult.tryAgain`))}),!1}},[R,D,l,I,b?.directoryOverride,b?.open,S,x,e]),ae=Q.useCallback((t,n)=>{let r=l&&R;(async()=>{if(!await ie(t,n))return;let i=e(r?`sessions.sidebar.sessionDialogs.worktree.removedWithRemote`:`sessions.sidebar.sessionDialogs.worktree.removed`);X.success(e(`sessions.sidebar.sessionDialogs.worktree.removedTitle`),{description:IS(i)})})()},[R,l,ie,e]),H=Q.useCallback(async()=>{if(a){m(!0);try{let t=ee&&d;if(a.sessions.length===0&&z&&a.worktree){ae(a.worktree,t),ne();return}if(a.sessions.length===1){let t=a.sessions[0];if(z){if(!await C(t.id)){X.error(e(`sessions.sidebar.session.archive.error`)),m(!1);return}Cl({sessionIds:[t.id],message:e(`sessions.sidebar.session.archive.success`),undoLabel:e(`sessions.sidebar.undo`),settingsLabel:e(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:e(`sessions.sidebar.session.archive.undoFailed`)})}else vl({sessionIds:[t.id],message:e(`sessions.sidebar.session.delete.success`),undoLabel:e(`sessions.sidebar.undo`),commitFailedMessage:e(`sessions.sidebar.session.delete.error`)})}else{let n=a.sessions.map(e=>e.id),r=[],i=[];if(z){let e=await w(n);r=e.archivedIds,i=e.failedIds}else vl({sessionIds:n,message:n.length===1?e(`sessions.sidebar.bulkActions.deletedSingle`,{count:n.length}):e(`sessions.sidebar.bulkActions.deletedPlural`,{count:n.length}),undoLabel:e(`sessions.sidebar.undo`),commitFailedMessage:n.length===1?e(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:n.length}):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:n.length})}),r=n,i=[];if(z&&a.worktree&&i.length===0&&ae(a.worktree,t),z&&r.length>0&&Cl({sessionIds:r,message:r.length===1?e(`sessions.sidebar.bulkActions.archivedSingle`,{count:r.length}):e(`sessions.sidebar.bulkActions.archivedPlural`,{count:r.length}),undoLabel:e(`sessions.sidebar.undo`),settingsLabel:e(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:r.length===1?e(`sessions.sidebar.session.archive.undoFailed`):e(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:r.length})}),i.length>0&&(X.error(z?i.length===1?e(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:i.length}):e(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:i.length}):i.length===1?e(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:i.length}):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:i.length}),{description:IS(e(`sessions.sidebar.dialogs.deleteResult.tryAgain`))}),r.length===0)){m(!1);return}}z&&a.sessions.length===1&&a.worktree&&ae(a.worktree,t),ne()}finally{m(!1)}}},[a,d,C,w,ne,ee,z,ae,e]),U=a?.worktree??s[0]?.metadata??null,oe=a?a.mode===`worktree`?a.sessions.length===0?e(`sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked`):a.sessions.length===1?e(`sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked`,{count:a.sessions.length}):e(`sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked`,{count:a.sessions.length}):a.sessions.length===1?a.dateLabel?e(`sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate`,{dateLabel:a.dateLabel}):e(`sessions.sidebar.dialogs.sessionDelete.descriptionOne`):a.dateLabel?e(`sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate`,{count:a.sessions.length,dateLabel:a.dateLabel}):e(`sessions.sidebar.dialogs.sessionDelete.descriptionMany`,{count:a.sessions.length}):``,W=a?(0,$.jsxs)(`div`,{className:Y(z?`space-y-3`:`space-y-2`),children:[a.sessions.length>0&&(0,$.jsxs)(`div`,{className:Y(z?`rounded-lg bg-muted/30 p-3`:`space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3`),children:[z&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:a.sessions.length===1?e(`sessions.sidebar.sessionDialogs.linkedSessionSingle`):e(`sessions.sidebar.sessionDialogs.linkedSessionPlural`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70`,children:a.sessions.length})]}),(0,$.jsxs)(`ul`,{className:Y(z?`mt-2 space-y-1`:`space-y-0.5`),children:[a.sessions.slice(0,5).map(t=>(0,$.jsxs)(`li`,{className:Y(z?`flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground`:`typography-micro text-muted-foreground/80`),children:[(0,$.jsx)(`span`,{className:Y(!z&&`hidden`),children:`•`}),(0,$.jsx)(`span`,{className:`truncate`,children:t.title||e(`sessions.sidebar.session.untitled`)})]},t.id)),a.sessions.length>5&&(0,$.jsx)(`li`,{className:Y(z?`px-2.5 py-1 text-xs text-muted-foreground/70`:`typography-micro text-muted-foreground/70`),children:e(`sessions.sidebar.dialogs.sessionList.more`,{count:a.sessions.length-5})})]})]}),z?(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg bg-muted/30 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Z,{name:`git-branch`,className:`h-4 w-4 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:e(`sessions.sidebar.sessionDialogs.worktree.label`)}),U?.label?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70`,children:U.label}):null]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/80 break-all`,children:U?or(U.path,O):e(`sessions.sidebar.sessionDialogs.worktree.pathUnavailable`)}),L&&(0,$.jsx)(`p`,{className:`typography-micro text-status-warning`,children:e(`sessions.sidebar.sessionDialogs.worktree.uncommittedWarning`)})]}):(0,$.jsx)(`div`,{className:`rounded-xl border border-border/40 bg-sidebar/60 p-3`,children:(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground/80`,children:e(`sessions.sidebar.sessionDialogs.delete.note`)})})]}):null,se=z?R?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{B||u(e=>!e)},disabled:B,className:Y(`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors`,B?`cursor-not-allowed opacity-60`:`hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),children:[l?(0,$.jsx)(Z,{name:`checkbox`,className:`size-4 text-primary`}):(0,$.jsx)(Z,{name:`checkbox-blank`,className:`size-4`}),e(`sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch`)]}):(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground/70`,children:e(`sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable`)}):null,ce=z?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{V||f(e=>!e)},disabled:V,className:Y(`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors`,V?`cursor-not-allowed opacity-60`:`hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),children:[d?(0,$.jsx)(Z,{name:`checkbox`,className:`size-4 text-primary`}):(0,$.jsx)(Z,{name:`checkbox-blank`,className:`size-4`}),e(`sessions.sidebar.sessionDialogs.actions.deleteLocalBranch`)]}):null,le=z?(0,$.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[ce,se]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{variant:`ghost`,onClick:ne,disabled:p,children:e(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(J,{variant:`destructive`,onClick:H,disabled:p,children:e(p?`sessions.sidebar.sessionDialogs.actions.deleting`:`sessions.sidebar.sessionDialogs.actions.deleteWorktree`)})]})]}):(0,$.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>E(!T),className:`inline-flex items-center gap-1.5 typography-meta text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50`,"aria-pressed":!T,children:[T?(0,$.jsx)(Z,{name:`checkbox-blank`,className:`size-4`}):(0,$.jsx)(Z,{name:`checkbox`,className:`size-4 text-primary`}),e(`sessions.sidebar.dialogs.neverAsk`)]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{variant:`ghost`,onClick:ne,disabled:p,children:e(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(J,{variant:`destructive`,onClick:H,disabled:p,children:p?e(`sessions.sidebar.sessionDialogs.actions.deleting`):a?.sessions.length===1?e(`sessions.sidebar.dialogs.deleteSession.titleAction`):e(`sessions.sidebar.dialogs.deleteSessions.titleAction`)})]})]}),ue=z?e(`sessions.sidebar.sessionDialogs.actions.deleteWorktree`):a?.sessions.length===1?e(`sessions.sidebar.dialogs.deleteSession.titleAction`):e(`sessions.sidebar.dialogs.deleteSessions.titleAction`);return(0,$.jsxs)($.Fragment,{children:[P?(0,$.jsx)(Ds,{open:!!a,onClose:()=>{p||ne()},title:ue,footer:(0,$.jsx)(`div`,{className:`flex justify-end gap-2`,children:le}),children:(0,$.jsxs)(`div`,{className:`space-y-2 pb-2`,children:[oe&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground/80`,children:oe}),W]})}):(0,$.jsx)(Qr,{open:!!a,onOpenChange:e=>{if(!e){if(p)return;ne()}},children:(0,$.jsxs)(Yr,{className:Y(z?`max-w-xl max-h-[70vh] flex flex-col overflow-hidden gap-3`:`max-w-[min(520px,100vw-2rem)] space-y-2 pb-2`),children:[(0,$.jsxs)(qr,{children:[(0,$.jsxs)(Xr,{className:Y(z&&`flex items-center gap-2`),children:[z&&(0,$.jsx)(Z,{name:`delete-bin`,className:`h-5 w-5`}),ue]}),oe&&(0,$.jsx)(Zr,{children:oe})]}),(0,$.jsx)(`div`,{className:Y(z&&`flex-1 min-h-0 overflow-y-auto space-y-2`),children:W}),(0,$.jsx)(Jr,{className:`mt-2 gap-2 pt-1 pb-1`,children:le})]})}),(0,$.jsx)(el,{open:t,onOpenChange:n,origin:r})]})},zS=Q.createContext(null),BS=e=>{let t=(0,ju.c)(3),{children:n,value:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(zS.Provider,{value:r,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i},VS=ba(()=>Lt(()=>import(`./TerminalView-s8qzyQ1U.js`).then(e=>({default:e.TerminalView})),__vite__mapDeps([84,1,3,2,4,5,6,7,8,9,10,41,24,42,43,25,22,26,44,14,11,13,12,15,16,17,18,19,20,21,23,27,85,40,45,86,46,39,47,48,49,50,51,52,53,54,55,56,57,58,59,60,87,67,88,70,89,90,91,92,93,94,95,96,97,98]))),HS=ba(()=>Lt(()=>import(`./DiagramView-BvRz7w00.js`).then(e=>({default:e.DiagramView})),__vite__mapDeps([99,1,3,2,10,12,13,14,4,5,6,7,8,9,11,15,16,17,18,19,20,21,22,23,24,25,26,27,46,60,39,40,41,42,43,44,45,47,48,49,50,51,52,53,54,55,56,57,58,59,70,89,85,100,101]))),US=ba(()=>Lt(()=>import(`./SettingsView-yDGWdErX.js`).then(e=>({default:e.SettingsView})),__vite__mapDeps([102,1,2,3,4,5,6,7,8,9,103,104,24,10,40,25,22,26,41,42,43,44,14,11,13,12,15,16,17,18,19,20,21,23,27,45,105,46,39,47,48,49,50,51,52,53,54,55,56,57,58,59,60,106,87,64,65,107,67,108,88,109,110,111,112,113,68,29,30,31,32,33,34,35,36,37,38,114,71,72,73,115,116,117,76,70,77,78,118,119,120,121,122,123,124,125,126,127,128,61,62,129,130,90,91,92,93,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,63,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,81,179,180,181,182,183]))),WS=ba(()=>Lt(()=>import(`./SettingsWindow-tYCzlPbh.js`).then(e=>({default:e.SettingsWindow})),__vite__mapDeps([184,1,10,11,39,2,5,3,4,6,7,8,9,24,40,25,22,26,41,42,43,44,14,13,12,15,16,17,18,19,20,21,23,27,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,102,103,104,105,60,106,87,64,65,107,67,108,88,109,110,111,112,113,68,29,30,31,32,33,34,35,36,37,38,114,71,72,73,115,116,117,76,70,77,78,118,119,120,121,122,123,124,125,126,127,128,61,62,129,130,90,91,92,93,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,63,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,81,179,180,181,182,183]))),GS=ba(()=>Lt(()=>import(`./MultiRunWindow-CC0gEHEt.js`).then(e=>({default:e.MultiRunWindow})),__vite__mapDeps([185,1,10,11,39,2,5,3,4,6,7,8,9,24,40,25,22,26,41,42,43,44,14,13,12,15,16,17,18,19,20,21,23,27,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,186,106,87,107,88,112,113,114,187,117,139,188,189,190,191,161,61,67,72,78,162,163,192,193,194,151,126,158,63,91,92,93,125,127,128,62,178,195,130]))),KS=ba(()=>Lt(()=>import(`./AssistantView-Cn3wym_C.js`).then(e=>({default:e.AssistantView})),__vite__mapDeps([196,1,3,2,10,11,16,17,18,23,5,6,7,8,9,24,25,22,26,27,20,39,4,40,41,42,43,44,14,13,12,15,19,21,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,197,88,119,167,120,198,106,87,61,74,75,199,76,70,77,78,79,165,64,65,73,166,161,67,72,162,163,200,128,62,113,192,193,194,189,190,201,69,152,153,202,203,204,205,206,207,208,168,135,136,209,210,211,212,111,110]))),qS=()=>{let e=q(e=>e.isSidebarOpen),t=q(e=>e.isRightSidebarOpen),n=q(e=>e.isBottomTerminalOpen),r=q(e=>e.setRightSidebarOpen),i=q(e=>e.setBottomTerminalOpen),a=q(e=>e.activeMainTab),o=q(e=>e.setIsMobile),s=q(e=>e.isSessionSwitcherOpen),c=q(e=>e.isSettingsDialogOpen),l=q(e=>e.setSettingsDialogOpen),u=q(e=>e.isMultiRunLauncherOpen),d=q(e=>e.setMultiRunLauncherOpen),[f,p]=Q.useState(c),[m,h]=Q.useState(u);c&&!f&&p(!0),u&&!m&&h(!0);let{isMobile:g,isTablet:_}=fi(),v=Q.useRef(!1),y=Q.useRef(!1),[b,x]=Q.useState(!1),[S,C]=Q.useState(!1),[w,T]=Q.useState(!1),[E,D]=Q.useState(!1),O=Q.useCallback(e=>{x(e),q.getState().setSessionSwitcherOpen(e)},[]),k=Q.useRef(!1),A=Q.useRef(typeof window>`u`?0:window.innerWidth),j=Gr(-A.current),M=(0,Q.useRef)(0),N=Gr(A.current),P=(0,Q.useRef)(0);(0,Q.useEffect)(()=>{g&&(M.current=window.innerWidth,P.current=window.innerWidth)},[g]),(0,Q.useEffect)(()=>{if(!g){T(!1);return}b&&T(!0),Kr(j,b?0:-M.current,{type:`spring`,stiffness:400,damping:35,mass:.8})},[b,g,j]),(0,Q.useEffect)(()=>{if(!g){D(!1);return}k.current=S,S&&D(!0),Kr(N,S?0:P.current,{type:`spring`,stiffness:400,damping:35,mass:.8})},[g,S,N]),(0,Q.useEffect)(()=>{if(g)return j.on(`change`,e=>{let t=M.current||A.current,n=b||e>-t+.5;T(e=>e===n?e:n)})},[g,j,b]),(0,Q.useEffect)(()=>{if(g)return N.on(`change`,e=>{let t=P.current||A.current,n=S||e<t-.5;D(e=>e===n?e:n)})},[g,S,N]),(0,Q.useEffect)(()=>{g&&!s&&b&&O(!1)},[s,g,b,O]),(0,Q.useEffect)(()=>{if(!g){y.current=!1;return}y.current||(y.current=!0,O(!1),C(!1),q.getState().isRightSidebarOpen&&r(!1))},[g,O,r]),(0,Q.useEffect)(()=>{if(!g||a!==`chat`||b||S||c)return;let e=!1,t,n=r=>{t=window.setTimeout(()=>{if(e)return;let t=Kn.getState(),r=q.getState();if(!(r.activeMainTab!==`chat`||r.isSettingsDialogOpen||t.currentSessionId||t.newSessionDraft?.open)){if(t.isLoading){n(250);return}t.openNewSessionDraft()}},r)};return n(500),()=>{e=!0,t!==void 0&&window.clearTimeout(t)}},[a,g,c,b,S]),(0,Q.useEffect)(()=>{!g||!c||(O(!1),C(!1),t&&r(!1))},[g,c,t,O,r]),Q.useEffect(()=>{q.getState().isMobile!==g&&o(g)},[g,o]),Q.useEffect(()=>{if(typeof window>`u`)return;let e,t=()=>{e===void 0&&(e=window.requestAnimationFrame(()=>{e=void 0,q.getState().updateProportionalSidebarWidths()}))};return window.addEventListener(`resize`,t),()=>{window.removeEventListener(`resize`,t),e!==void 0&&window.cancelAnimationFrame(e)}},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e,t=()=>{let e=q.getState(),t=window.innerHeight;!g&&!_&&(t<640?e.isBottomTerminalOpen&&(i(!1),v.current=!0):t>=700&&v.current&&(i(!0),v.current=!1))},n=()=>{e===void 0&&(e=window.requestAnimationFrame(()=>{e=void 0,t()}))};return t(),window.addEventListener(`resize`,n),()=>{window.removeEventListener(`resize`,n),e!==void 0&&window.cancelAnimationFrame(e)}},[g,_,i]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=q.subscribe((e,t)=>{let n=window.innerHeight>=700;e.isBottomTerminalOpen!==t.isBottomTerminalOpen&&n&&(v.current=!1)});return()=>{e()}},[g,_,i]);let F=Q.useCallback(()=>{b&&O(!1),C(!S)},[b,S,O]),I=Q.useMemo(()=>{switch(a){case`git`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Ah,{isActive:!S})});case`diff`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Ql,{})});case`terminal`:return n?null:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(VS,{})});case`files`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(hp,{})});case`diagram`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(HS,{})});default:return null}},[a,n,S]),L=a===`schedule`,R=a===`assistant`,z=a===`plugin`,ee=L||R||z,B=a===`chat`,V=!ee&&!c;return(0,$.jsx)(zi,{children:(0,$.jsxs)(`div`,{"data-page-scroll-lock":`true`,className:Y(`main-content-safe-area`,g?`flex h-[100dvh] flex-col`:`relative flex h-[100dvh]`,`bg-background`),children:[(0,$.jsx)(al,{}),(0,$.jsx)(Fv,{}),(0,$.jsx)(zv,{}),(0,$.jsx)(RS,{}),(0,$.jsx)(Tl,{}),g?(0,$.jsxs)(BS,{value:{leftDrawerOpen:b,rightDrawerOpen:S,toggleLeftDrawer:()=>{let e=!b;S&&C(!1),O(e)},toggleRightDrawer:F,leftDrawerX:j,rightDrawerX:N,leftDrawerWidth:M,rightDrawerWidth:P,setMobileLeftDrawerOpen:O,setRightSidebarOpen:C},children:[!c&&!ee&&(0,$.jsx)(Zd,{onToggleLeftDrawer:()=>{let e=!b;S&&C(!1),O(e)},onToggleRightDrawer:()=>{F()},leftDrawerOpen:b,rightDrawerOpen:S}),(0,$.jsx)(`div`,{"data-page-scroll-lock":`true`,className:Y(`flex flex-1 overflow-hidden relative`,c&&`hidden`),children:(0,$.jsxs)(`main`,{className:`w-full h-full overflow-hidden bg-background relative`,"data-page-scroll-lock":`true`,children:[L&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(No,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Yl,{})})})}),R&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(No,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(KS,{})})})}),V&&(0,$.jsx)(`div`,{className:Y(`absolute inset-0`,!B&&`invisible`),children:(0,$.jsx)(mc,{children:(0,$.jsx)(No,{children:(0,$.jsx)(Xl,{})})})}),V&&I&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(mc,{children:(0,$.jsx)(No,{children:I})})}),u&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(No,{children:(0,$.jsx)(iu,{onCreated:()=>d(!1),onCancel:()=>d(!1)})})}),(0,$.jsx)(As.div,{className:Y(`absolute inset-0 z-20 bg-sidebar`,!w&&`pointer-events-none invisible`),"data-page-scroll-lock":`true`,style:{x:j},"aria-hidden":!b,children:(0,$.jsx)(No,{children:(0,$.jsx)(PS,{mobileVariant:!0,isVisible:w})})}),E&&(0,$.jsx)(As.div,{className:`absolute inset-0 z-20 bg-sidebar`,"data-page-scroll-lock":`true`,style:{x:N},"aria-hidden":!S,children:(0,$.jsx)(No,{children:(0,$.jsx)(mc,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Ah,{isActive:S})})})})})]})}),c&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,style:{paddingTop:`var(--yuri-safe-area-top, 0px)`},children:(0,$.jsx)(No,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(US,{onClose:()=>l(!1)})})})}),(0,$.jsx)(No,{children:(0,$.jsx)(dl,{})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Tf,{}),(0,$.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:[(0,$.jsx)(vf,{isOpen:e,isMobile:g,className:`border-border/50`,topBar:(0,$.jsx)(yf,{}),children:(0,$.jsx)(PS,{isVisible:e})}),(0,$.jsx)(`div`,{className:`relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background`,"data-page-scroll-lock":`true`,children:ee?(0,$.jsx)(`main`,{className:`flex-1 overflow-hidden bg-background`,"data-page-scroll-lock":`true`,children:(0,$.jsx)(No,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:z?(0,$.jsx)(Ul,{}):R?(0,$.jsx)(KS,{}):(0,$.jsx)(Yl,{})})})}):(0,$.jsx)(mc,{children:(0,$.jsxs)(Nv,{header:(0,$.jsx)(Zd,{}),footer:(0,$.jsx)(lf,{isOpen:n,isMobile:g,children:n?(0,$.jsx)(No,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(VS,{})})}):null}),children:[V&&(0,$.jsx)(`div`,{className:Y(`absolute inset-0`,!B&&`invisible`),children:(0,$.jsx)(No,{children:(0,$.jsx)(Xl,{})})}),V&&I&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(No,{children:I})})]})})})]}),(0,$.jsx)(Q.Suspense,{fallback:null,children:f&&(0,$.jsx)(WS,{open:c,onOpenChange:l})}),(0,$.jsx)(Q.Suspense,{fallback:null,children:m&&(0,$.jsx)(GS,{open:u,onOpenChange:d})})]})]})})},JS=9e4,YS=15e3,XS=3e5,ZS=[2e3,5e3],QS=6e4,$S=12e4,eC=3e5,tC=4,nC=432e5,rC=`yuri.github-pr-status`,iC=e=>e===`closed`||e===`merged`,aC=e=>{let t=e?.checks;return t?t.state===`pending`||t.pending>0:!1},oC=(e,t,n)=>`${e}::${t}`,sC=new Map,cC=new Map,lC=new Set,uC=new Map,dC=2,fC=0,pC=[],mC=()=>fC<dC?(fC+=1,Promise.resolve()):new Promise(e=>{pC.push(e)}),hC=()=>{let e=pC.shift();if(e){e();return}fC=Math.max(0,fC-1)},gC=()=>({status:null,isLoading:!1,error:null,isInitialStatusResolved:!1,lastRefreshAt:0,lastDiscoveryPollAt:0,watchers:0,params:null,identity:null,resolvedRemoteName:null}),_C=e=>e?.params?.directory&&e.params.branch?{directory:e.params.directory,branch:e.params.branch,remoteName:e.params.remoteName??e.resolvedRemoteName??e.identity?.remoteName??null}:!e?.identity?.directory||!e.identity.branch?null:e.identity,vC=e=>{let t=_C(e);return!t?.directory||!t.branch?null:`${t.directory}::${t.branch}`},yC=(e,t)=>Object.entries(e).filter(([,e])=>vC(e)===t).map(([e])=>e),bC=(e,t)=>{let n=t.remoteName??e.params?.remoteName??e.resolvedRemoteName??e.identity?.remoteName??null;return{...e,params:e.params?{...e.params,...t,remoteName:n}:{...t,remoteName:n},identity:{directory:t.directory,branch:t.branch,remoteName:n}}},xC=e=>!e?.params?.canShow||!e.params.github?.prStatus?null:{...e.params,remoteName:e.params.remoteName??e.resolvedRemoteName??e.identity?.remoteName??null},SC=(e,t,n)=>{let r=yC(e,t),i=r.map(t=>xC(e[t])).filter(e=>!!e);if(i.length===0)return null;let a=xC(e[n]);if(a&&vC(e[n])===t)return a;let o=r.map(t=>e[t]).find(e=>!!(e?.resolvedRemoteName&&xC(e)));return o?xC(o):i.find(e=>!!e.remoteName)||(i[0]??null)},CC=e=>({status:e.status,isInitialStatusResolved:e.isInitialStatusResolved,lastRefreshAt:e.lastRefreshAt,lastDiscoveryPollAt:e.lastDiscoveryPollAt,identity:_C(e),resolvedRemoteName:e.resolvedRemoteName??e.status?.resolvedRemoteName??null}),wC=e=>({...gC(),status:e?.status??null,isInitialStatusResolved:e?.isInitialStatusResolved??!1,lastRefreshAt:e?.lastRefreshAt??0,lastDiscoveryPollAt:e?.lastDiscoveryPollAt??0,identity:e?.identity??null,resolvedRemoteName:e?.resolvedRemoteName??e?.status?.resolvedRemoteName??null}),TC=ue()(de((e,t)=>({entries:{},activeRequestCount:0,totalRequestCount:0,ensureEntry:t=>{e(e=>e.entries[t]?e:{entries:{...e.entries,[t]:gC()}})},setParams:(t,n)=>{e(e=>{let r=e.entries[t]??gC();return{entries:{...e.entries,[t]:bC(r,n)}}})},startWatching:n=>{if(e(e=>{let t=e.entries[n]??gC();return{entries:{...e.entries,[n]:{...t,watchers:t.watchers+1}}}}),sC.has(n))return;let r=e=>{let r=window.setTimeout(()=>{if(typeof document<`u`&&document.visibilityState!==`visible`)return;let e=t().entries[n];!e||e.watchers<=0||e.status?.pr||t().refresh(n,{force:!0,silent:!0,markInitialResolved:!0})},e),i=cC.get(n)??[];i.push(r),cC.set(n,i)};t().refresh(n,{force:!0,silent:!0,markInitialResolved:!0}),ZS.forEach(e=>r(e));let i=window.setInterval(()=>{if(typeof document<`u`&&document.visibilityState!==`visible`)return;let r=t().entries[n];if(!(!r||r.watchers<=0)){if(!r.status?.pr){let i=Date.now();if(i-r.lastDiscoveryPollAt<XS)return;e(e=>{let t=e.entries[n];return t?{entries:{...e.entries,[n]:{...t,lastDiscoveryPollAt:i}}}:e}),t().refresh(n,{force:!0,silent:!0,markInitialResolved:!0});return}iC(r.status?.pr?.state)||Date.now()-r.lastRefreshAt<(aC(r.status)?QS:r.status?.checks&&r.status.checks.state!==`pending`?eC:$S)||t().refresh(n,{force:!0,onlyExistingPr:!0,silent:!0,markInitialResolved:!0})}},YS);sC.set(n,i)},stopWatching:n=>{e(e=>{let t=e.entries[n];if(!t)return e;let r=Math.max(0,t.watchers-1);return{entries:{...e.entries,[n]:{...t,watchers:r}}}});let r=t().entries[n];if(r&&r.watchers>0)return;let i=sC.get(n);typeof i==`number`&&window.clearInterval(i),sC.delete(n);let a=cC.get(n);a&&a.length>0&&a.forEach(e=>{window.clearTimeout(e)}),cC.delete(n)},refresh:async(n,r)=>{let i=t(),a=i.entries[n],o=vC(a);if(!a||!o)return;let s=yC(i.entries,o),c=s.some(e=>!!i.entries[e]?.status?.pr);if(r?.onlyExistingPr&&!c)return;let l=uC.get(o)??0;if(!r?.force&&Date.now()-l<JS||lC.has(o))return;let u=SC(i.entries,o,n);if(u){if(lC.add(o),uC.set(o,Date.now()),e(e=>{let t={...e.entries};return s.forEach(e=>{let n=t[e];n&&(t[e]={...n,lastRefreshAt:Date.now(),isLoading:!r?.silent||n.isLoading,error:null})}),{entries:t}}),u.githubAuthChecked&&u.githubConnected===!1){e(e=>{let t={...e.entries};return s.forEach(e=>{let n=t[e];n&&(t[e]={...n,status:{connected:!1},error:null,isLoading:r?.silent?n.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||n.isInitialStatusResolved})}),{entries:t}}),lC.delete(o);return}if(!u.github?.prStatus){e(e=>{let t={...e.entries};return s.forEach(e=>{let n=t[e];n&&(t[e]={...n,status:null,error:`GitHub runtime API unavailable`,isLoading:r?.silent?n.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||n.isInitialStatusResolved})}),{entries:t}}),lC.delete(o);return}try{e(e=>({...e,activeRequestCount:e.activeRequestCount+1,totalRequestCount:e.totalRequestCount+1})),await mC();let t;try{t=await u.github.prStatus(u.directory,u.branch,u.remoteName??void 0,{force:r?.force})}finally{hC()}e(e=>{let n={...e.entries};return s.forEach(e=>{let i=n[e];if(!i)return;let a=i.status?.pr,o=t.pr,s=o&&a&&o.number===a.number&&(!o.body||!o.body.trim())&&typeof a.body==`string`&&a.body.trim().length>0&&o&&a?.body?{...t,pr:{...o,body:a.body}}:t,c=s.resolvedRemoteName??i.resolvedRemoteName??u.remoteName??null,l=_C(i)??{directory:u.directory,branch:u.branch,remoteName:u.remoteName??null};n[e]={...i,status:s,error:null,isLoading:r?.silent?i.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||i.isInitialStatusResolved,resolvedRemoteName:c,identity:{...l,remoteName:c??l.remoteName??null}}}),{entries:n}})}catch(t){let n=t instanceof Error?t.message:String(t);e(e=>{let t={...e.entries};return s.forEach(e=>{let i=t[e];i&&(t[e]={...i,error:n||`Failed to load PR status`,isLoading:r?.silent?i.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||i.isInitialStatusResolved})}),{entries:t}})}finally{lC.delete(o),e(e=>({...e,activeRequestCount:Math.max(0,e.activeRequestCount-1)}))}}},refreshTargets:async(e,n)=>{await hy(Array.from(new Set(e.map(e=>{let t=e.directory.trim(),n=e.branch.trim();return!t||!n?null:oC(t,n,e.remoteName??null)}).filter(e=>!!e))),tC,e=>t().refresh(e,n))},updateStatus:(t,n)=>{e(e=>{let r=e.entries[t]??gC();return{entries:{...e.entries,[t]:{...r,status:n(r.status)}}}})}}),{name:rC,storage:We(),partialize:e=>({entries:Object.fromEntries(Object.entries(e.entries).filter(([,e])=>{let t=_C(e);if(!t?.directory||!t.branch)return!1;let n=Math.max(e.lastRefreshAt,e.lastDiscoveryPollAt);return n===0||Date.now()-n<nC}).map(([e,t])=>[e,CC(t)]))}),merge:(e,t)=>{let n=e?.entries??{};return{...t,entries:Object.fromEntries(Object.entries(n).map(([e,t])=>[e,wC(t)]))}}})),EC=e=>{if(e<1e3)return`${Math.round(e)}ms`;let t=e/1e3;return t<60?`${t.toFixed(1)}s`:`${Math.floor(t/60)}m ${Math.round(t%60)}s`},DC=e=>{let t=(0,ju.c)(8),{label:n,value:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={backgroundColor:`color-mix(in srgb, var(--surface-muted) 55%, transparent)`},t[0]=i):i=t[0];let a;t[1]===n?a=t[2]:(a=(0,$.jsx)(`div`,{className:`typography-meta text-[var(--surface-muted-foreground)]`,children:n}),t[1]=n,t[2]=a);let o;t[3]===r?o=t[4]:(o=(0,$.jsx)(`div`,{className:`typography-markdown font-semibold text-[var(--surface-foreground)]`,children:r}),t[3]=r,t[4]=o);let s;return t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`div`,{className:`rounded-md p-2`,style:i,children:[a,o]}),t[5]=a,t[6]=o,t[7]=s):s=t[7],s},OC=e=>{let t=(0,ju.c)(43),{title:n,snapshot:r,emptyLabel:i}=e,{t:a}=Nr(),o;if(t[0]!==i||t[1]!==r.durationMs||t[2]!==r.entries||t[3]!==r.lastUpdatedAt||t[4]!==r.startedAt||t[5]!==a||t[6]!==n){let e=r.entries.slice(0,12),s;t[8]===r.entries?s=t[9]:(s=r.entries.reduce(AC,0),t[8]=r.entries,t[9]=s);let c=s,l;t[10]===n?l=t[11]:(l=(0,$.jsx)(`div`,{className:`typography-ui-label font-semibold text-[var(--surface-foreground)]`,children:n}),t[10]=n,t[11]=l);let u;t[12]!==r.durationMs||t[13]!==r.startedAt||t[14]!==a?(u=r.startedAt?EC(r.durationMs):a(`memoryDebugPanel.common.idle`),t[12]=r.durationMs,t[13]=r.startedAt,t[14]=a,t[15]=u):u=t[15];let d;t[16]===u?d=t[17]:(d=(0,$.jsx)(`div`,{className:`typography-meta text-[var(--surface-muted-foreground)]`,children:u}),t[16]=u,t[17]=d);let f;t[18]!==l||t[19]!==d?(f=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[l,d]}),t[18]=l,t[19]=d,t[20]=f):f=t[20];let p;t[21]===a?p=t[22]:(p=a(`memoryDebugPanel.metric.metrics`),t[21]=a,t[22]=p);let m;t[23]!==r.entries.length||t[24]!==p?(m=(0,$.jsx)(DC,{label:p,value:r.entries.length}),t[23]=r.entries.length,t[24]=p,t[25]=m):m=t[25];let h;t[26]===a?h=t[27]:(h=a(`memoryDebugPanel.metric.samples`),t[26]=a,t[27]=h);let g;t[28]!==h||t[29]!==c?(g=(0,$.jsx)(DC,{label:h,value:c}),t[28]=h,t[29]=c,t[30]=g):g=t[30];let _;t[31]===a?_=t[32]:(_=a(`memoryDebugPanel.metric.lastUpdate`),t[31]=a,t[32]=_);let v;t[33]!==r.lastUpdatedAt||t[34]!==a?(v=r.lastUpdatedAt?a(`memoryDebugPanel.common.live`):a(`memoryDebugPanel.common.notAvailable`),t[33]=r.lastUpdatedAt,t[34]=a,t[35]=v):v=t[35];let y;t[36]!==_||t[37]!==v?(y=(0,$.jsx)(DC,{label:_,value:v}),t[36]=_,t[37]=v,t[38]=y):y=t[38];let b;t[39]!==g||t[40]!==y||t[41]!==m?(b=(0,$.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[m,g,y]}),t[39]=g,t[40]=y,t[41]=m,t[42]=b):b=t[42],o=(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0`,children:[f,b,e.length===0?(0,$.jsx)(`div`,{className:`rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]`,style:{backgroundColor:`color-mix(in srgb, var(--surface-muted) 45%, transparent)`},children:i}):(0,$.jsx)(Wr,{outerClassName:`max-h-64`,className:`pr-1`,children:(0,$.jsx)(`div`,{className:`space-y-1`,children:e.map(e=>(0,$.jsxs)(`div`,{className:`rounded-md border border-[var(--interactive-border)] p-2`,style:{backgroundColor:`color-mix(in srgb, var(--surface-elevated) 88%, transparent)`},children:[(0,$.jsx)(`div`,{className:`typography-meta font-medium text-[var(--surface-foreground)] break-all`,children:e.metric}),(0,$.jsxs)(`div`,{className:`mt-1 grid grid-cols-4 gap-2 typography-meta text-[var(--surface-muted-foreground)]`,children:[(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.countValue`,{value:e.count})}),(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.avgValue`,{value:e.avg})}),(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.maxValue`,{value:e.max})}),(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.totalValue`,{value:e.total})})]})]},e.metric))})})]}),t[0]=i,t[1]=r.durationMs,t[2]=r.entries,t[3]=r.lastUpdatedAt,t[4]=r.startedAt,t[5]=a,t[6]=n,t[7]=o}else o=t[7];return o},kC=e=>{let t=(0,ju.c)(104),{onClose:n}=e,{t:r}=Nr(),[i,a]=Q.useState(`memory`),[o,s]=Q.useState(`idle`),c=Kn(jC),l=br(MC),u=Sr(),d=bn(),[f,p]=Q.useState(NC),m,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>Qe(()=>{p(Ze())}),h=[],t[0]=m,t[1]=h):(m=t[0],h=t[1]),Q.useEffect(m,h);let g;if(t[2]!==d||t[3]!==u){bb0:{let e=Xe(),t={};if(!e){g=t;break bb0}let n=e.getCacheBudget?.(),r=n?n.listCanonical().map(PC):u.map(e=>({directory:d,sessionID:e.id}));for(let n of r){if(d&&n.directory!==d)continue;let r=e.getTranscript(rt(n.directory,n.sessionID));t[n.sessionID]=r.messageOrder.map(e=>r.messagesByID[e]).filter(FC)}g=t}t[2]=d,t[3]=u,t[4]=g}else g=t[4];let _=g,v=TC(IC),[y,b]=Q.useState(LC),[x,S]=Q.useState(RC),C;t[5]===y.entries?C=t[6]:(C=new Map,y.entries.forEach(e=>{C.set(e.metric,e.count)}),t[5]=y.entries,t[6]=C);let w;t[7]===C?w=t[8]:(w=C.get(`ui.message_list.render`)??0,t[7]=C,t[8]=w);let T;t[9]===C?T=t[10]:(T=C.get(`ui.message_list.render.streaming`)??0,t[9]=C,t[10]=T);let E;t[11]===C?E=t[12]:(E=C.get(`ui.chat_message.render`)??0,t[11]=C,t[12]=E);let D;t[13]===C?D=t[14]:(D=C.get(`ui.chat_message.render.streaming`)??0,t[13]=C,t[14]=D);let O;t[15]===C?O=t[16]:(O=C.get(`ui.chat_message.render.static_during_stream`)??0,t[15]=C,t[16]=O);let k;t[17]===C?k=t[18]:(k=C.get(`ui.chat_message.render.static_outside_active_turn_during_stream`)??0,t[17]=C,t[18]=k);let A;t[19]!==w||t[20]!==T||t[21]!==E||t[22]!==D||t[23]!==O||t[24]!==k?(A={messageListRender:w,messageListRenderStreaming:T,chatMessageRender:E,chatMessageRenderStreaming:D,chatMessageRenderStaticDuringStream:O,chatMessageRenderStaticOutsideActiveTurnDuringStream:k},t[19]=w,t[20]=T,t[21]=E,t[22]=D,t[23]=O,t[24]=k,t[25]=A):A=t[25];let j=A,M,N;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>{let e=()=>{b(je()),S(Be())};e();let t=window.setInterval(e,500);return()=>window.clearInterval(t)},N=[],t[26]=M,t[27]=N):(M=t[26],N=t[27]),Q.useEffect(M,N);let P,F;t[28]===o?(P=t[29],F=t[30]):(P=()=>{if(o===`idle`)return;let e=window.setTimeout(()=>{s(`idle`)},1500);return()=>window.clearTimeout(e)},F=[o],t[28]=o,t[29]=P,t[30]=F),Q.useEffect(P,F);let I=0,L=0,R=0;for(let e of Object.keys(_)){let t=_[e]??[];L+=t.length;for(let e of t)e.role===`user`?R+=1:e.role===`assistant`&&(I+=1)}let z;t[31]!==I||t[32]!==L||t[33]!==R?(z={assistant:I,total:L,user:R},t[31]=I,t[32]=L,t[33]=R,t[34]=z):z=t[34];let ee=z,B;if(t[35]!==c||t[36]!==_||t[37]!==l||t[38]!==u||t[39]!==r){let e;t[41]!==c||t[42]!==_||t[43]!==l||t[44]!==r?(e=e=>{let t=_[e.id]??[],n=0,i=0;for(let e of t)e.role===`user`?i+=1:e.role===`assistant`&&(n+=1);let a=l.get(e.id);return{id:e.id,title:e.title||r(`memoryDebugPanel.common.untitled`),assistantMessageCount:n,messageCount:t.length,userMessageCount:i,isStreaming:a?.isStreaming||!1,isZombie:a?.isZombie||!1,backgroundCount:a?.backgroundMessageCount||0,lastAccessed:a?.lastAccessedAt||0,isCurrent:e.id===c}},t[41]=c,t[42]=_,t[43]=l,t[44]=r,t[45]=e):e=t[45],B=u.map(e).sort(zC),t[35]=c,t[36]=_,t[37]=l,t[38]=u,t[39]=r,t[40]=B}else B=t[40];let V=B,te;t[46]===_?te=t[47]:(te=Object.keys(_),t[46]=_,t[47]=te);let ne=te.length,re;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(re=async()=>{try{let e={generatedAt:new Date().toISOString(),ui:je(),vscode:Be()};await navigator.clipboard.writeText(JSON.stringify(e,null,2)),s(`copied`)}catch{s(`error`)}},t[48]=re):re=t[48];let ie=re,ae;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(ae={backgroundColor:`color-mix(in srgb, var(--surface-background) 94%, transparent)`},t[49]=ae):ae=t[49];let H;t[50]===i?H=t[51]:(H=i===`memory`?(0,$.jsx)(Z,{name:`database-2`,className:`h-4 w-4 text-[var(--surface-foreground)]`}):(0,$.jsx)(Z,{name:`bar-chart-box`,className:`h-4 w-4 text-[var(--surface-foreground)]`}),t[50]=i,t[51]=H);let U;t[52]===r?U=t[53]:(U=r(`memoryDebugPanel.title`),t[52]=r,t[53]=U);let oe;t[54]===U?oe=t[55]:(oe=(0,$.jsx)(`h3`,{className:`typography-ui-label font-semibold text-[var(--surface-foreground)]`,children:U}),t[54]=U,t[55]=oe);let W;t[56]!==H||t[57]!==oe?(W=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[H,oe]}),t[56]=H,t[57]=oe,t[58]=W):W=t[58];let se;t[59]===i?se=t[60]:(se=i===`streaming`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(J,{size:`xs`,variant:`ghost`,onClick:ie,children:(0,$.jsx)(Z,{name:`file-copy`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(J,{size:`xs`,variant:`ghost`,onClick:()=>{Ie(),b(je()),S(Be())},children:(0,$.jsx)(Z,{name:`refresh`,className:`h-3.5 w-3.5`})})]}):null,t[59]=i,t[60]=se);let ce;t[61]===n?ce=t[62]:(ce=n?(0,$.jsx)(J,{size:`icon`,variant:`ghost`,className:`h-6 w-6`,onClick:n,children:(0,$.jsx)(Z,{name:`close`,className:`h-4 w-4`})}):null,t[61]=n,t[62]=ce);let le;t[63]!==se||t[64]!==ce?(le=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[se,ce]}),t[63]=se,t[64]=ce,t[65]=le):le=t[65];let ue;t[66]!==W||t[67]!==le?(ue=(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[W,le]}),t[66]=W,t[67]=le,t[68]=ue):ue=t[68];let de;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(de={backgroundColor:`color-mix(in srgb, var(--surface-muted) 55%, transparent)`},t[69]=de):de=t[69];let fe=i===`memory`?`secondary`:`ghost`,pe;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(pe=()=>a(`memory`),t[70]=pe):pe=t[70];let me;t[71]===r?me=t[72]:(me=r(`memoryDebugPanel.tabs.memory`),t[71]=r,t[72]=me);let he;t[73]!==fe||t[74]!==me?(he=(0,$.jsx)(J,{size:`sm`,variant:fe,className:`flex-1`,onClick:pe,children:me}),t[73]=fe,t[74]=me,t[75]=he):he=t[75];let ge=i===`streaming`?`secondary`:`ghost`,_e;t[76]===Symbol.for(`react.memo_cache_sentinel`)?(_e=()=>a(`streaming`),t[76]=_e):_e=t[76];let ve;t[77]===r?ve=t[78]:(ve=r(`memoryDebugPanel.tabs.streaming`),t[77]=r,t[78]=ve);let ye;t[79]!==ge||t[80]!==ve?(ye=(0,$.jsx)(J,{size:`sm`,variant:ge,className:`flex-1`,onClick:_e,children:ve}),t[79]=ge,t[80]=ve,t[81]=ye):ye=t[81];let be;t[82]!==he||t[83]!==ye?(be=(0,$.jsxs)(`div`,{className:`mb-3 flex gap-1 rounded-md p-1`,style:de,children:[he,ye]}),t[82]=he,t[83]=ye,t[84]=be):be=t[84];let xe;t[85]!==i||t[86]!==ne||t[87]!==o||t[88]!==c||t[89]!==_||t[90]!==ee||t[91]!==l||t[92]!==V||t[93]!==u||t[94]!==j||t[95]!==y||t[96]!==r||t[97]!==v||t[98]!==x?(xe=i===`memory`?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 typography-meta`,children:[(0,$.jsx)(DC,{label:r(`memoryDebugPanel.metric.totalMessages`),value:ee.total}),(0,$.jsx)(DC,{label:r(`memoryDebugPanel.metric.cachedSessions`),value:`${ne} / ${Uo.MAX_SESSIONS}`}),(0,$.jsx)(DC,{label:r(`memoryDebugPanel.metric.userMessages`),value:ee.user}),(0,$.jsx)(DC,{label:r(`memoryDebugPanel.metric.assistantMessages`),value:ee.assistant})]}),(0,$.jsxs)(`div`,{className:`typography-meta space-y-1 border-t border-[var(--interactive-border)] pt-2`,children:[(0,$.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.viewportWindow`)}),(0,$.jsx)(`span`,{className:`text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.metric.messagesValue`,{count:Xo()})})]}),(0,$.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.zombieTimeout`)}),(0,$.jsx)(`span`,{className:`text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.metric.minutesValue`,{count:Uo.ZOMBIE_TIMEOUT/1e3/60})})]}),(0,$.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.githubTotalRequests`)}),(0,$.jsx)(`span`,{className:`text-[var(--surface-foreground)]`,children:v})]})]}),(0,$.jsxs)(`div`,{className:`border-t border-[var(--interactive-border)] pt-2`,children:[(0,$.jsx)(`div`,{className:`mb-1 typography-meta font-semibold text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.section.sessionsInMemory`)}),(0,$.jsx)(Wr,{outerClassName:`max-h-48`,className:`space-y-1 pr-1`,children:V.map(e=>(0,$.jsxs)(`div`,{className:`typography-meta flex items-center justify-between rounded p-1.5`,style:{backgroundColor:e.isCurrent?`color-mix(in srgb, var(--interactive-selection) 22%, transparent)`:`color-mix(in srgb, var(--surface-muted) 35%, transparent)`},children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-[var(--surface-foreground)]`,children:e.title}),e.isStreaming?(0,$.jsx)(Z,{name:`pulse`,className:`h-3 w-3 animate-pulse text-[var(--status-info)]`}):null,e.isZombie?(0,$.jsx)(`span`,{className:`text-[var(--status-warning)]`,children:`!`}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.roleMsgsValue`,{assistant:e.assistantMessageCount,user:e.userMessageCount})}),(0,$.jsx)(`span`,{className:`font-mono text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.metric.msgsValue`,{count:e.messageCount})}),e.backgroundCount>0?(0,$.jsxs)(`span`,{className:`text-[var(--status-info)]`,children:[`+`,e.backgroundCount]}):null]})]},e.id))})]}),(0,$.jsx)(`div`,{className:`flex gap-2 border-t border-[var(--interactive-border)] pt-2`,children:(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(J,{size:`sm`,variant:`outline`,className:`typography-meta`,onClick:()=>{u.map(BC),Object.keys(_),V.map(VC),Object.fromEntries(l)},children:r(`memoryDebugPanel.actions.logState`)})}),(0,$.jsx)(ei,{side:`top`,children:r(`memoryDebugPanel.tooltip.logCurrentState`)})]})})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-[var(--interactive-border)] px-3 py-2 typography-meta text-[var(--surface-muted-foreground)]`,children:[(0,$.jsx)(`span`,{children:r(o===`copied`?`memoryDebugPanel.streaming.copy.copied`:o===`error`?`memoryDebugPanel.streaming.copy.failed`:`memoryDebugPanel.streaming.copy.hint`)}),(0,$.jsx)(J,{size:`xs`,variant:`outline`,onClick:ie,children:r(`memoryDebugPanel.actions.copyJson`)})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsx)(DC,{label:r(`memoryDebugPanel.metric.uiMetrics`),value:y.entries.length}),(0,$.jsx)(DC,{label:r(`memoryDebugPanel.metric.vscodeMetrics`),value:x.entries.length}),(0,$.jsx)(DC,{label:r(`memoryDebugPanel.metric.messageListRenders`),value:j.messageListRender}),(0,$.jsx)(DC,{label:r(`memoryDebugPanel.metric.messageListStreamRenders`),value:j.messageListRenderStreaming}),(0,$.jsx)(DC,{label:r(`memoryDebugPanel.metric.chatMessageRenders`),value:j.chatMessageRender}),(0,$.jsx)(DC,{label:r(`memoryDebugPanel.metric.chatMessageStreamRenders`),value:j.chatMessageRenderStreaming}),(0,$.jsx)(DC,{label:r(`memoryDebugPanel.metric.chatMessageStaticDuringStream`),value:j.chatMessageRenderStaticDuringStream}),(0,$.jsx)(DC,{label:r(`memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn`),value:j.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),(0,$.jsx)(OC,{title:r(`memoryDebugPanel.section.uiStreamingMetrics`),snapshot:y,emptyLabel:r(`memoryDebugPanel.section.noUiSamples`)}),x.entries.length>0?(0,$.jsx)(OC,{title:r(`memoryDebugPanel.section.vscodeBridgeMetrics`),snapshot:x,emptyLabel:r(`memoryDebugPanel.section.noVscodeSamples`)}):null]}),t[85]=i,t[86]=ne,t[87]=o,t[88]=c,t[89]=_,t[90]=ee,t[91]=l,t[92]=V,t[93]=u,t[94]=j,t[95]=y,t[96]=r,t[97]=v,t[98]=x,t[99]=xe):xe=t[99];let Se;return t[100]!==ue||t[101]!==be||t[102]!==xe?(Se=(0,$.jsxs)(Mo,{className:`fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area`,style:ae,children:[ue,be,xe]}),t[100]=ue,t[101]=be,t[102]=xe,t[103]=Se):Se=t[103],Se};function AC(e,t){return e+t.count}function jC(e){return e.currentSessionId}function MC(e){return e.sessionMemoryState}function NC(){return Ze()}function PC(e){return e.scope}function FC(e){return!!e}function IC(e){return e.totalRequestCount}function LC(){return je()}function RC(){return Be()}function zC(e,t){return t.lastAccessed-e.lastAccessed}function BC(e){return{id:e.id,title:e.title}}function VC(e){return{id:e.id,title:e.title,total:e.messageCount,user:e.userMessageCount,assistant:e.assistantMessageCount}}var HC=()=>{let{isMobile:e,closeActiveContextPanelTab:t}=q.getState();if(e)return;let n=Wi();n&&t(n)||L()&&ee(`desktop_close_current_window`).catch(e=>{console.warn(`[menu-actions] failed to close current window`,e)})},UC=()=>{if(typeof document>`u`)return``;let e=document.activeElement;if(e instanceof HTMLTextAreaElement)return e.value.slice(e.selectionStart??0,e.selectionEnd??0);if(e instanceof HTMLInputElement){let t=e.type?.toLowerCase()??`text`;if([`text`,`search`,`url`,`tel`,`password`].includes(t))return e.value.slice(e.selectionStart??0,e.selectionEnd??0)}return e instanceof HTMLElement&&e.isContentEditable?e.ownerDocument.defaultView?.getSelection?.()?.toString()??``:``},WC=async()=>{let e=UC()||window.getSelection()?.toString()||``;if(!e.trim())return!1;try{if(typeof navigator<`u`&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}return document.execCommand(`copy`)},GC=`yuri:menu-action`,KC=`yuri:check-for-updates`,qC=e=>typeof e?.listen==`function`?`bridge`:`dom`,JC=e=>{let t=Kn(e=>e.openNewSessionDraft),n=q(e=>e.toggleCommandPalette),r=q(e=>e.setCommandPaletteOpen),i=q(e=>e.toggleHelpDialog),a=q(e=>e.toggleSidebar),o=q(e=>e.setSessionSwitcherOpen),s=q(e=>e.setActiveMainTab),c=q(e=>e.setSettingsDialogOpen),l=q(e=>e.setSettingsPage),u=q(e=>e.setAboutDialogOpen),d=q(e=>e.toggleContextPanel),f=q(e=>e.setRightSidebarOpen),p=q(e=>e.setRightSidebarTab),m=q(e=>e.toggleBottomTerminal),h=q(e=>e.setBottomTerminalExpanded),g=Dl(e=>e.checkForUpdates),{setThemeMode:_}=ai(),{t:v}=Nr(),y=Q.useRef(!1),b=typeof window>`u`?null:window.__YURI_DESKTOP__,x=qC(b),S=Q.useCallback(()=>{y.current||(y.current=!0,g().then(()=>{let{available:e,error:t}=Dl.getState();if(t){X.error(v(`sessions.sidebar.updateCheck.errorTitle`),{description:t});return}e||X.success(v(`sessions.sidebar.updateCheck.latestVersion`))}).finally(()=>{y.current=!1}))},[g,v]),C=Q.useCallback(()=>{sr.requestDirectoryDialog()},[]),w=Q.useCallback(e=>{oo(e,Kn.getState().currentSessionId,e=>{s(`chat`),o(!1),Kn.getState().setCurrentSession(e.sessionId,e.directory)})},[s,o]),T=Q.useCallback(e=>{let{activeProjectId:t,projects:n,setActiveProject:r}=un.getState();if(n.length===0)return;let i=n.findIndex(e=>e.id===t),a=e>0?0:n.length-1;i>=0&&(a=(i+e+n.length)%n.length);let o=n[a];o&&r(o.id)},[]),E=Q.useCallback(g=>{switch(g){case`about`:u(!0);break;case`settings`:c(!0);break;case`switch-instance`:l(`remote-instances`),c(!0);break;case`command-palette`:n();break;case`quick-open`:r(!0);break;case`new-session`:s(`chat`),o(!1),t();break;case`new-worktree-session`:s(`chat`),o(!1),ds();break;case`change-workspace`:C();break;case`close-tab-or-window`:HC();break;case`toggle-right-sidebar`:{let e=Wi();e&&d(e);break}case`open-right-sidebar-git`:{let e=Wi();e&&q.getState().openContextPanel(e),f(!0),p(`git`);break}case`open-right-sidebar-files`:{let e=Wi();e&&q.getState().openContextPanel(e),f(!0),p(`files`);break}case`toggle-terminal`:m();break;case`toggle-terminal-expanded`:h(!q.getState().isBottomTerminalExpanded);break;case`copy`:{let e=new Event(`yuri:copy`,{cancelable:!0});window.dispatchEvent(e)&&WC();break}case`theme-light`:_(`light`);break;case`theme-dark`:_(`dark`);break;case`theme-system`:_(`system`);break;case`toggle-sidebar`:a();break;case`toggle-memory-debug`:e?.();break;case`zoom-in`:Xa();break;case`zoom-out`:Za();break;case`zoom-reset`:lo();break;case`go-back`:G.getState().goBack();break;case`go-forward`:G.getState().goForward();break;case`previous-session`:w(-1);break;case`next-session`:w(1);break;case`previous-project`:T(-1);break;case`next-project`:T(1);break;case`help-dialog`:i();break;case`download-logs`:mo().catch(()=>{X.error(`Failed to collect OpenCode status`)})}},[C,T,w,e,t,u,s,o,r,c,l,h,f,p,_,m,n,i,d,a]);Q.useEffect(()=>{if(x!==`dom`)return;let e=e=>{let t=e.detail;t&&E(t)},t=()=>{S()};return window.addEventListener(GC,e),window.addEventListener(KC,t),()=>{window.removeEventListener(GC,e),window.removeEventListener(KC,t)}},[E,S,x]),Q.useEffect(()=>{if(x!==`bridge`)return;let e=b?.listen;if(typeof e!=`function`)return;let t=null,n=null;return e(`yuri:menu-action`,e=>{let t=e?.payload;typeof t==`string`&&E(t)}).then(e=>{t=e}).catch(()=>{}),e(`yuri:check-for-updates`,S).then(e=>{n=e}).catch(()=>{}),()=>{(async()=>{try{let e=t?.();e instanceof Promise&&await e}catch{}try{let e=n?.();e instanceof Promise&&await e}catch{}})()}},[b,E,S,x])},YC=(e,t)=>e<t?-1:+(e>t),XC=e=>JSON.stringify([...e.entries()].map(([e,t])=>[e,[...new Set(t)].sort(YC)]).sort(([e],[t])=>YC(e,t)));async function ZC({targets:e,isReady:t,fetchStatus:n,applySnapshot:r,concurrency:i=2,isDisposed:a=()=>!1}){if(!t()||a())return;let o=[...e.entries()],s=0,c=Math.min(Math.max(1,i),o.length),l=async()=>{for(;s<o.length&&t()&&!a();){let e=o[s];if(s+=1,!e)return;let[t,i]=e,c=await n(t);c===null||a()||r(t,c,i)}};await Promise.all(Array.from({length:c},()=>l()))}var QC=`yuri:tray-action`,$C=3e4,ew=120,tw=20,nw=()=>{if(typeof window>`u`)return!1;let e=window.__YURI_PLATFORM__;return e===`darwin`||e===`win32`},rw=e=>{let t=typeof e.permission==`string`?e.permission:`Permission`,n=Array.isArray(e.patterns)?e.patterns.find(e=>typeof e==`string`&&e.trim()):``;return n?`${t}: ${n}`:t},iw=e=>{let t=Array.isArray(e.questions)?e.questions[0]:void 0;return t?.header||t?.question||`Question`},aw=e=>kn(e),ow=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n>=0?t.slice(n+1):t},sw=(e,t,n,r)=>{if(!e)return``;let i=Xt(t,n,e),a=ow(i?i.path:e),o=Mn(e),s=o&&r.get(o)||``;if(!s){for(let[e,t]of Qi.getState().directories)if(Mn(e)===o){s=t.status?.current??``;break}}if(!s)for(let e of n.values()){let t=e.find(e=>Mn(e.path)===o);if(t?.branch){s=t.branch;break}}return s?`${a} · ${s}`:a},cw=()=>{let{results:e,dropdownProviderIds:t,displayMode:n}=Xs.getState(),r=n===`remaining`?`remaining`:`usage`;if(!t.length)return{mode:r,groups:[]};let i=new Map(e.map(e=>[e?.providerId,e])),a=[];for(let n of Zs(e)){if(!t.includes(n.id))continue;let e=i.get(n.id);if(!e||e.configured!==!0)continue;let o=[];for(let[t,n]of Object.entries(e.usage?.windows??{})){let e=r===`remaining`?n.remainingPercent:n.usedPercent;o.push({label:tc(n.label??t),value:Qs(n.valueLabel,e)})}let s=!e.ok&&e.error?e.error:o.length===0?`No rate limits reported`:null;a.push({provider:n.name,rows:o,status:s})}return{mode:r,groups:a}},lw=async()=>{try{if(x())return`Local Yuri`;let e=window.__YURI_LOCAL_ORIGIN__||window.location.origin,t=h();if(t&&W(t,e))return`Local Yuri`;let n=(await ce()).hosts.find(e=>t?W(t,oe(e)):!1);return n?.label?.trim()?le(n.label.trim()):`Instance`}catch{return``}},uw=()=>{let e=new Map,t=new Map,n=[],r=new Map,i;try{i=$e()}catch{return{statusById:e,branchByDirectory:t,approvals:n,titleById:r}}for(let[a,o]of i.children.entries()){let i=o.getState(),s=typeof i.vcs?.branch==`string`?i.vcs.branch:typeof i.vcs?.branch?.current==`string`?i.vcs.branch.current:``;s&&t.set(Mn(a)??a,s);for(let e of i.session)!e?.id||!e.title||r.set(e.id,e.title);for(let[t,n]of Object.entries(i.session_status??{})){let r=n?.type,i=r===`busy`?`busy`:r===`retry`?`retry`:`idle`,a=e.get(t);(!a||a===`idle`)&&e.set(t,i)}for(let[e,t]of Object.entries(i.permission??{}))for(let r of t??[]){if(!r?.id)continue;let t=r.sessionID||e;n.push({kind:`permission`,id:r.id,sessionId:t,sessionTitle:``,label:rw(r),directory:a})}for(let[e,t]of Object.entries(i.question??{}))for(let r of t??[]){if(!r?.id)continue;let t=r.sessionID||e;n.push({kind:`question`,id:r.id,sessionId:t,sessionTitle:``,label:iw(r),directory:a})}}return{statusById:e,branchByDirectory:t,approvals:n,titleById:r}},dw=()=>{let e=pn.getState().activeSessions,t=new Set;e.filter(e=>e?.id&&!e.parentID).slice().sort((e,t)=>aw(t)-aw(e)).slice(0,tw).forEach(e=>{let n=gn(e);n&&t.add(n)});let n=new Map;for(let r of e){if(!r?.id)continue;let e=gn(r);if(!e||!t.has(e))continue;let i=n.get(e)??[];i.push(r.id),n.set(e,i)}return n},fw=e=>{let t=uw(),n=cn.getState().index.session,r=pn.getState().activeSessions,i=new Map(t.titleById),a=new Map;for(let e of r)if(e?.id&&(e.title&&i.set(e.id,e.title),e.parentID)){let t=a.get(e.parentID)??[];t.push(e.id),a.set(e.parentID,t)}let o=e=>{let t=[],n=[...a.get(e)??[]],r=new Set;for(;n.length;){let e=n.pop();r.has(e)||(r.add(e),t.push(e),n.push(...a.get(e)??[]))}return t},s=xr.getState().statusById,c=e=>{let n=t.statusById.get(e);return n&&n!==`idle`?n:s.get(e)?.status??n??`idle`},l=e=>{let t=e.map(e=>c(e));return t.includes(`busy`)?`busy`:t.includes(`retry`)?`retry`:`idle`},u=un.getState().projects,d=Kn.getState().availableWorktreesByProject,f=r.filter(e=>e?.id&&!e.parentID).slice().sort((e,t)=>aw(t)-aw(e)).slice(0,tw).map(e=>{let r=[e.id,...o(e.id)],i=gn(e)??``;return{id:e.id,title:e.title||`Untitled session`,status:l(r),branch:i?t.branchByDirectory.get(i)??``:``,unseen:n.unseenCount[e.id]??0,hasError:n.unseenHasError[e.id]??!1,directory:i,subtitle:sw(i,u,d,t.branchByDirectory)}}),p=t.approvals.map(e=>({...e,sessionTitle:i.get(e.sessionId)||``})),m=q.getState(),h=0;if(m.dockBadgeEnabled)for(let e of r)!e?.id||e.parentID||(n.unseenCount[e.id]??0)>0&&(h+=1);return{sessions:f,approvals:p,instanceName:e,usage:cw(),dockBadgeCount:h}},pw=()=>{Q.useEffect(()=>{if(!nw()||!L())return;let e=!1,t=``,n=null,r=``,i=()=>{if(e)return;let n=fw(r),i=JSON.stringify(n);i!==t&&(t=i,ee(`desktop_tray_update`,n))};lw().then(t=>{e||(r=t,i())});let a=null,o=``,s=()=>{let e=jn.getState();return e.isConnected&&e.connectionPhase===`connected`},c=()=>{if(a)return a;let t=dw();return o=XC(t),a=ZC({targets:t,isReady:s,concurrency:2,isDisposed:()=>e,fetchStatus:async()=>{try{let e=await nt.getSdkClient().session.active();if(!e||typeof e!=`object`||Array.isArray(e))return null;let t={};for(let[n,r]of Object.entries(e))r?.type===`running`&&(t[n]={type:`busy`});return t}catch{return null}},applySnapshot:(e,t,n)=>{Rn(e,t,[...n])}}).finally(()=>{a=null;let t=dw();!e&&s()&&XC(t)!==o&&c()}),a},l=()=>{e||n!==null||(n=window.setTimeout(()=>{n=null,i()},ew))},u=new Map,d=()=>{if(e)return;let t;try{t=$e()}catch{return}let n=new Set;for(let[e,r]of t.children.entries())n.add(e),u.has(e)||u.set(e,r.subscribe(()=>l()));for(let[e,t]of u)n.has(e)||(t(),u.delete(e))},f=null;try{f=$e().subscribeRegistry(()=>{d(),l()})}catch{}d();let p=cn.subscribe(()=>l()),m=pn.subscribe(()=>{l(),s()&&XC(dw())!==o&&c()}),h=un.subscribe(()=>l()),g=Kn.subscribe(()=>l()),_=Qi.subscribe(()=>l()),v=q.subscribe(()=>l()),y=xr.subscribe(()=>l()),b=s(),x=jn.subscribe(()=>{let e=s();e&&!b&&c(),b=e});b&&c();let S=Xs.subscribe(()=>l());Xs.getState().loadSettings().then(()=>{if(e)return;let{dropdownProviderIds:t,results:n}=Xs.getState();t.length>0&&t.some(e=>!n.some(t=>t?.providerId===e))&&Xs.getState().fetchAllQuotas()});let C=window.setInterval(()=>{let e=Xs.getState();e.autoRefresh&&e.dropdownProviderIds.length>0&&e.fetchAllQuotas()},Math.max(3e4,Xs.getState().refreshIntervalMs||6e4)),w=window.setInterval(()=>{d(),i()},$C);return i(),()=>{e=!0,n!==null&&window.clearTimeout(n),window.clearInterval(w),window.clearInterval(C),p(),m(),h(),g(),_(),v(),y(),x(),S(),f?.();for(let e of u.values())e();u.clear()}},[]),Q.useEffect(()=>{if(!nw()||typeof window>`u`)return;let e=window.__YURI_DESKTOP__?.listen;if(typeof e!=`function`)return;let t=e=>{e.type===`respond-permission`&&ar(e.sessionId,e.id,e.response).catch(()=>{X.error(`Failed to respond to permission request`)})},n=null;return e(QC,e=>{let n=e?.payload;!n||typeof n!=`object`||typeof n.type!=`string`||t(n)}).then(e=>{n=e}).catch(()=>{}),()=>{try{let e=n?.();e instanceof Promise&&e.catch(()=>{})}catch{}}},[])},mw=`/api/notifications/stream`,hw=()=>typeof document>`u`||document.visibilityState===`visible`&&document.hasFocus(),gw=e=>{if(!e||typeof e!=`object`)return null;let t=e,n=t.properties&&typeof t.properties==`object`?t.properties:null;return t.type!==`yuri:notification`||!n?null:{title:typeof n.title==`string`?n.title:void 0,body:typeof n.body==`string`?n.body:void 0,tag:typeof n.tag==`string`?n.tag:void 0,requireHidden:n.requireHidden===!0||n.requireHidden!==!1&&void 0}},_w=e=>{let t=(0,ju.c)(3),n=e?.enabled??!0,r,i;t[0]===n?(r=t[1],i=t[2]):(r=()=>{if(!n||C()||!y()||typeof window>`u`||typeof EventSource>`u`)return;let e=new EventSource(l().sse(mw));return e.onmessage=vw,()=>{e.close()}},i=[n],t[0]=n,t[1]=r,t[2]=i),Q.useEffect(r,i)};function vw(e){let t;try{t=JSON.parse(e.data)}catch{return}let n=q.getState();if(!n.nativeNotificationsEnabled)return;let r=gw(t);r&&((r.requireHidden??n.notificationMode!==`always`)&&hw()||U()?.notifications?.notifyAgentCompletion(r))}var yw=`pwa-install-toast-shown`,bw=`pwa-install-toast-dismissed`,xw=()=>{let e=(0,ju.c)(6),{browserTab:t}=fu(),{t:n}=Nr(),r=Q.useRef(n),i,a;e[0]===n?(i=e[1],a=e[2]):(i=()=>{r.current=n},a=[n],e[0]=n,e[1]=i,e[2]=a),Q.useEffect(i,a);let o,s;e[3]===t?(o=e[4],s=e[5]):(o=()=>{if(typeof window>`u`||!y()||!t)return;let e=null,n=null,i=()=>{n!==null&&(X.dismiss(n),n=null)},a=async()=>{if(!e)return;let t=e;e=null,i(),await t.prompt();let{outcome:n}=await t.userChoice;n===`accepted`&&X.success(r.current(`pwa.installPrompt.started`))},o=t=>{let o=t;if(typeof o.prompt!=`function`)return;o.preventDefault(),e=o;let s=He(),c=Ue();jc({dismissed:s.getItem(bw),sessionShown:c.getItem(yw),hasActiveToast:n!==null})&&(c.setItem(yw,`true`),n=X.info(r.current(`pwa.installPrompt.description`),{duration:1/0,action:{label:r.current(`pwa.installPrompt.action`),onClick:()=>{a()}},cancel:{label:r.current(`pwa.installPrompt.dismiss`),onClick:()=>{He().setItem(bw,`true`),i()}}}))},s=()=>{e=null,i(),X.success(r.current(`pwa.installPrompt.installed`))};return window.addEventListener(`beforeinstallprompt`,o),window.addEventListener(`appinstalled`,s),()=>{i(),window.removeEventListener(`beforeinstallprompt`,o),window.removeEventListener(`appinstalled`,s)}},s=[t],e[3]=t,e[4]=o,e[5]=s),Q.useEffect(o,s)},Sw=0;function Cw(e){let t=typeof e?.sessionId==`string`?e.sessionId.trim():``;if(!t)return;let n=++Sw,r=typeof e?.directory==`string`&&e.directory.trim().length>0?e.directory.trim():null;if(q.getState().setActiveMainTab(`chat`),e.hostId||e.hubId||e.instanceId){if(!e.hostId||!e.hubId||!r)return;Lt(async()=>{let{applyRemoteProjectRoute:e}=await import(`./navigation-By33kYra.js`).then(e=>e.n);return{applyRemoteProjectRoute:e}},__vite__mapDeps([213,1,3,2,19,8,9,20,39,5,4,6,7,24,10,40,25,22,26,41,42,43,44,14,11,13,12,15,16,17,18,21,23,27,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59])).then(({applyRemoteProjectRoute:i})=>{if(n===Sw)return i({sessionId:t,directory:r,hostId:e.hostId,hubId:e.hubId,...e.instanceId?{instanceId:e.instanceId}:{},isNewSession:!1},()=>n===Sw)}).catch(()=>console.warn(`[remote-session] Notification navigation failed`));return}Kn.getState().setCurrentSession(t,r)}var ww=({open:e,onOpenChange:t})=>{let{t:n}=Nr(),[r,i]=Q.useState(null),[a,o]=Q.useState(null);Q.useEffect(()=>{e&&(async()=>{try{let e=await g(`/api/system/info`);if(e.ok){let t=await e.json();if(typeof t.yuriVersion==`string`&&t.yuriVersion.trim()){i(t.yuriVersion);return}}}catch{}i(await Ar())})()},[e]),Q.useEffect(()=>{if(!e)return;let t=!1;return(async()=>{try{let e=await g(`/api/opencode/upgrade-status`,{headers:{Accept:`application/json`}});if(!e.ok)return;let n=await e.json().catch(()=>null),r=typeof n?.currentVersion==`string`?n.currentVersion.trim():``;!t&&r&&o(r)}catch{}})(),()=>{t=!0}},[e]);let s=r;return(0,$.jsx)(Qr,{open:e,onOpenChange:t,children:(0,$.jsx)(Yr,{className:`max-w-xs p-5`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:[(0,$.jsx)(jo,{width:48,height:48}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Yuri`}),(0,$.jsxs)(`div`,{className:`space-y-0.5 typography-meta text-muted-foreground`,children:[s&&(0,$.jsx)(`p`,{children:n(`aboutDialog.yuriVersionLabel`,{version:s})}),a&&(0,$.jsx)(`p`,{children:n(`aboutDialog.openCodeVersionLabel`,{version:a})})]})]}),(0,$.jsx)(`div`,{className:`flex items-center justify-center`,children:(0,$.jsxs)(`a`,{href:`https://github.com/yee94/yuri`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors`,children:[(0,$.jsx)(Z,{name:`github-fill`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:`GitHub`})]})}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/60`,children:n(`aboutDialog.footerNote`)})]})})})},Tw=(e,t)=>{let n=e.get(t);return typeof n==`string`&&n.trim()||null},Ew=(e,t)=>{let n=e instanceof Error?e.message:t;return/oauth state required/i.test(n)?`Authorization session expired or was cleared during reload. Return to Yuri and click Authorize again.`:n},Dw=()=>{let e=Fl(e=>e.completeAuth),[t,n]=Q.useState(`working`),[r,i]=Q.useState(`Completing MCP authorization...`);return Q.useEffect(()=>{if(typeof window>`u`){n(`error`),i(`Browser context unavailable.`);return}let t=new URLSearchParams(window.location.search),r=Tw(t,`code`),a=uu(t),o=au(t),s=Tw(t,`error`),c=Tw(t,`error_description`);if(s){o&&g(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`,{method:`DELETE`}).catch(()=>void 0),n(`error`),i(c??s);return}(async()=>{try{if(!r)throw Error(`Missing OAuth authorization code. Start authorization again from MCP Settings or paste the returned code into Yuri manually.`);let t=a;if(!t&&o){let e=await g(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`);if(e.ok){let n=await e.json().catch(()=>null);n?.name?.trim()&&(t={name:n.name.trim(),directory:typeof n.directory==`string`&&n.directory.trim()?n.directory.trim():null})}}if(!t?.name)throw Error(`Authorization session details were not available. Start authorization again from MCP Settings or paste the returned code into Yuri manually.`);await e(t.name,r,t.directory),o&&await g(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`,{method:`DELETE`}).catch(()=>void 0),n(`success`),i(`Authorization completed. You can close this tab and return to Yuri.`)}catch(e){o&&await g(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`,{method:`DELETE`}).catch(()=>void 0),n(`error`),i(Ew(e,`Failed to complete MCP authorization.`))}})()},[e]),(0,$.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-background px-6 py-12 text-foreground`,children:(0,$.jsxs)(`div`,{className:`w-full max-w-xl rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-8 shadow-sm dark:shadow-none`,children:[(0,$.jsxs)(`div`,{className:`space-y-3 text-center`,children:[(0,$.jsx)(`div`,{className:t===`error`?`text-[var(--status-error)]`:t===`success`?`text-[var(--status-success)]`:`text-[var(--status-info)]`,children:(0,$.jsx)(`h1`,{className:`typography-hero font-semibold`,children:t===`working`?`Completing Authorization`:t===`success`?`Authorization Complete`:`Authorization Failed`})}),(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:r})]}),t!==`working`&&(0,$.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,$.jsx)(J,{type:`button`,onClick:()=>{typeof window>`u`||window.location.replace(`/`)},children:`Return to Yuri`})})]})})},Ow=()=>{let e=pn(e=>e.startupSyncProgress.active),t=pn(e=>e.startupSyncProgress.phase),n=pn(e=>e.startupSyncProgress.completed),r=pn(e=>e.startupSyncProgress.total),{locale:i,t:a}=Nr(),[o,s]=Q.useState(!0),c=qt(i).startingApi;Q.useEffect(()=>{let e=!1,t=async()=>{try{let t=await(await g(`/health`,{signal:AbortSignal.timeout(4e3)})).json().catch(()=>null);if(e)return;let n=t?.openCodeStarting===!0||t?.isOpenCodeReady!==!0&&!t?.lastOpenCodeError;s(n)}catch{e||s(!0)}};t();let n=window.setInterval(()=>{t()},750);return()=>{e=!0,window.clearInterval(n)}},[]);let l=r>0?Math.round(n/r*100):0,u=t===`restoring`?a(`common.loading`):a(`sessions.startupSync.progress`,{completed:n,total:r});return Q.useLayoutEffect(()=>{let t=document.getElementById(`startup-session-progress`),i=document.getElementById(`startup-session-progress-track`),s=document.getElementById(`startup-session-progress-fill`),d=document.getElementById(`startup-session-progress-text`);if(!(!t||!i||!s||!d)){if(e){t.hidden=!1,s.style.width=`${l}%`,i.setAttribute(`aria-label`,a(`sessions.startupSync.title`)),i.setAttribute(`aria-valuemax`,String(Math.max(r,1))),i.setAttribute(`aria-valuenow`,String(n)),i.setAttribute(`aria-valuetext`,u),d.textContent=u;return}if(o){t.hidden=!1,s.style.width=`30%`,i.setAttribute(`aria-label`,c),i.setAttribute(`aria-valuetext`,c),d.textContent=c;return}t.hidden=!0}},[e,n,o,l,u,c,a,r]),null},kw=(e,t,n,r=350)=>n?Math.max(0,r-Math.max(0,t-e)):null;function Aw(e){let t=(0,ju.c)(21),{transition:n,ready:r}=e,{t:i}=Nr(),a=To(!0),[o,s]=Q.useState(0),c=n.epoch>o,l=a||c,u,d;if(t[0]!==c||t[1]!==a||t[2]!==r||t[3]!==n.epoch||t[4]!==n.startedAt?(u=()=>{if(!c||a)return;let e=kw(n.startedAt,Date.now(),r);if(e===null)return;let t=window.setTimeout(()=>{s(e=>Math.max(e,n.epoch))},e);return()=>window.clearTimeout(t)},d=[c,a,r,n.epoch,n.startedAt],t[0]=c,t[1]=a,t[2]=r,t[3]=n.epoch,t[4]=n.startedAt,t[5]=u,t[6]=d):(u=t[5],d=t[6]),Q.useEffect(u,d),!l)return null;let f;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 opacity-70`,"aria-hidden":`true`,children:[(0,$.jsx)(`div`,{className:`absolute left-1/2 top-1/2 size-[28rem] -translate-x-1/2 -translate-y-1/2 rounded-full border border-[var(--interactive-border)]/40`}),(0,$.jsx)(`div`,{className:`absolute left-1/2 top-1/2 size-72 -translate-x-1/2 -translate-y-1/2 rounded-full bg-[var(--interactive-selection)]/10 blur-3xl`})]}),t[7]=f):f=t[7];let p;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(`div`,{className:`mb-7 flex size-28 items-center justify-center rounded-[2rem] border border-[var(--interactive-border)]/60 bg-[var(--surface-elevated)]/75 shadow-2xl shadow-background/40`,children:(0,$.jsx)(jo,{width:76,height:76,isAnimated:!0})}),t[8]=p):p=t[8];let m;t[9]===i?m=t[10]:(m=i(`desktopHostSwitcher.transition.title`),t[9]=i,t[10]=m);let h;t[11]===m?h=t[12]:(h=(0,$.jsx)(`h1`,{className:`typography-title text-foreground`,children:m}),t[11]=m,t[12]=h);let g;t[13]===i?g=t[14]:(g=i(`desktopHostSwitcher.transition.description`),t[13]=i,t[14]=g);let _;t[15]===g?_=t[16]:(_=(0,$.jsx)(`p`,{className:`mt-2 typography-body text-muted-foreground`,children:g}),t[15]=g,t[16]=_);let v;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(`div`,{className:`mt-7 h-1 w-28 overflow-hidden rounded-full bg-[var(--surface-muted)]`,"aria-hidden":`true`,children:(0,$.jsx)(`div`,{className:`h-full w-1/2 animate-pulse rounded-full bg-[var(--status-info)] motion-reduce:animate-none`})}),t[17]=v):v=t[17];let y;return t[18]!==h||t[19]!==_?(y=(0,$.jsxs)(`div`,{className:`fixed inset-0 z-[9998] flex items-center justify-center overflow-hidden bg-background/95 px-6 backdrop-blur-xl`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:[f,(0,$.jsxs)(`div`,{className:`relative flex max-w-md animate-in flex-col items-center text-center fade-in zoom-in-95 duration-300 motion-reduce:animate-none`,children:[p,h,_,v]})]}),t[18]=h,t[19]=_,t[20]=y):y=t[20],y}var jw=ba(()=>Lt(()=>import(`./OnboardingScreen-CgYmkOnG.js`).then(e=>({default:e.OnboardingScreen})),__vite__mapDeps([214,1,4,2,5,3,6,7,8,9,103,10,40,24,25,22,26,41,42,43,44,14,11,13,12,15,16,17,18,19,20,21,23,27,45,39,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,64,65,117,146,67]))),Mw=36e5,Nw=12e5,Pw=()=>{let e=(0,ju.c)(3),t=q(Vw),n=q(Hw),r;return e[0]!==t||e[1]!==n?(r=(0,$.jsx)(ww,{open:t,onOpenChange:n}),e[0]=t,e[1]=n,e[2]=r):r=e[2],r},Fw=e=>{let t=(0,ju.c)(21),{onRetry:n,isRetrying:r}=e,{t:i}=Nr(),a;t[0]===i?a=t[1]:(a=i(`startup.initRecovery.title`),t[0]=i,t[1]=a);let o;t[2]===a?o=t[3]:(o=(0,$.jsx)(`h1`,{className:`typography-title text-foreground`,children:a}),t[2]=a,t[3]=o);let s;t[4]===i?s=t[5]:(s=i(`startup.initRecovery.description`),t[4]=i,t[5]=s);let c;t[6]===s?c=t[7]:(c=(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:s}),t[6]=s,t[7]=c);let l;t[8]!==o||t[9]!==c?(l=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[o,c]}),t[8]=o,t[9]=c,t[10]=l):l=t[10];let u;t[11]!==r||t[12]!==i?(u=i(r?`startup.initRecovery.retrying`:`startup.initRecovery.retry`),t[11]=r,t[12]=i,t[13]=u):u=t[13];let d;t[14]!==r||t[15]!==n||t[16]!==u?(d=(0,$.jsx)(J,{type:`button`,onClick:n,disabled:r,children:u}),t[14]=r,t[15]=n,t[16]=u,t[17]=d):d=t[17];let f;return t[18]!==l||t[19]!==d?(f=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center bg-background px-6 text-foreground`,children:(0,$.jsxs)(`div`,{className:`flex max-w-md flex-col items-center gap-4 text-center`,children:[l,d]})}),t[18]=l,t[19]=d,t[20]=f):f=t[20],f},Iw=e=>e?e.replace(/\\/g,`/`).replace(/\/+$/g,``):``,Lw=()=>{if(typeof window>`u`||!Io())return null;let e=new URLSearchParams(window.location.search),t=e.get(`sessionId`),n=typeof t==`string`?t.trim():``;if(!n)return null;let r=e.get(`directory`);return{sessionId:n,directory:typeof r==`string`&&r.trim().length>0?r.trim():null,readOnly:e.get(`readOnly`)===`1`||e.get(`readOnly`)===`true`}},Rw=()=>typeof window>`u`?!1:window.location.pathname===du,zw=e=>{let t=(0,ju.c)(22),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=e,a=G(Uw),o=Kn(Ww),s=Kn(Gw),c=ps(),l=Q.useRef(null),u;t[0]===n.directory?u=t[1]:(u=Iw(n.directory),t[0]=n.directory,t[1]=u);let d=u,f;t[2]===a?f=t[3]:(f=Iw(a),t[2]=a,t[3]=f);let p=f,m,h;if(t[4]!==p||t[5]!==o||t[6]!==n.directory||t[7]!==n.sessionId||t[8]!==d||t[9]!==r||t[10]!==s||t[11]!==c?(m=()=>{if(r||d&&p!==d)return;let e=`${d}\n${n.sessionId}`;l.current===e&&o||(l.current=e,s(n.sessionId,n.directory),c.ensureSessionRenderable(n.sessionId,!0))},h=[p,o,n.directory,n.sessionId,d,r,s,c],t[4]=p,t[5]=o,t[6]=n.directory,t[7]=n.sessionId,t[8]=d,t[9]=r,t[10]=s,t[11]=c,t[12]=m,t[13]=h):(m=t[12],h=t[13]),Q.useEffect(m,h),d&&p!==d)return null;let g;t[14]===i?g=t[15]:(g=(0,$.jsx)(eo,{embeddedBackgroundWorkEnabled:i}),t[14]=i,t[15]=g);let _;t[16]===n.readOnly?_=t[17]:(_=(0,$.jsx)(Xl,{readOnly:n.readOnly}),t[16]=n.readOnly,t[17]=_);let v;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(Fa,{}),t[18]=v):v=t[18];let y;return t[19]!==g||t[20]!==_?(y=(0,$.jsxs)($.Fragment,{children:[g,_,v]}),t[19]=g,t[20]=_,t[21]=y):y=t[21],y};function Bw({apis:e}){Q.useEffect(()=>{Ge(`App:mounted`),Ke()},[]),Q.useEffect(()=>ir(),[]);let t=jn(e=>e.initializeApp),n=jn(e=>e.isInitialized),r=jn(e=>e.isConnected),i=Kn(e=>e.error),a=Kn(e=>e.clearError),o=Kn(e=>!(e.newSessionDraft?.open&&e.currentSessionId===null)),s=G(e=>e.currentDirectory),l=G(e=>e.setDirectory),u=G(e=>e.isSwitchingDirectory),[d,p]=Q.useState(!1),m=Nl(e=>e.refreshStatus),[h,g]=Q.useState(()=>e.runtime.isVSCode),[_,v]=Q.useState(!1),[y,S]=Q.useState(!1),[w,T]=Q.useState(0),[O,A]=Q.useState(0),[j,M]=Q.useState({epoch:0,startedAt:0}),[P,I]=Q.useState(!1),L=Q.useRef(!1),z=q(e=>e.wideChatLayoutEnabled),B=q(e=>e.mobileKeyboardMode),V=Q.useMemo(()=>C(),[]),ne=pn(e=>e.hasCachedSessionIndex),re=pn(e=>e.hasHydratedSessionIndex),[ae,U]=Q.useState(()=>te()),[oe,W]=Q.useState(()=>{let e=ie();return e===null?null:F({isDesktopShell:!0,bootOutcome:e})}),se=Q.useRef(!1),ce=Q.useMemo(()=>Lw(),[]),le=!ce||_,ue=Q.useMemo(()=>Rw(),[]);Q.useEffect(()=>(Me(d),()=>{Me(!1)}),[d]),Q.useEffect(()=>{Vt(B)},[B]),Q.useEffect(()=>{g(e.runtime.isVSCode)},[e.runtime.isVSCode]),Q.useEffect(()=>{let e=za(e=>{f(e)&&(V&&M(e=>({epoch:e.epoch+1,startedAt:Date.now()})),cl(e),A(e=>e+1),S(!1),T(e=>e+1))}),t=c(t=>e.schedule(t));return()=>{t(),e.cancel()}},[V]),Q.useEffect(()=>(document.documentElement.classList.toggle(`wide-chat-layout`,z),()=>{document.documentElement.classList.remove(`wide-chat-layout`)}),[z]),Q.useEffect(()=>(H(e),()=>H(null)),[e]),Q.useEffect(()=>{if(ce)return;let t=!1;return tn().then(()=>{t||m(e.github,{force:!0})}),()=>{t=!0}},[e.github,ce,m]),co();let de=ae===`valid`,fe=oe?.screen===`main`,[pe,me]=Q.useState(!1);Q.useEffect(()=>{if(!le||!N({isDesktopShell:V,isInitialized:V&&fe?ne||n&&re:n,bootOutcomeKnown:de,bootViewIsMain:fe}))return;let e,t=setTimeout(()=>{let t=document.getElementById(`initial-loading`);t?(t.classList.add(`fade-out`),e=setTimeout(()=>{t.remove(),me(!0)},300)):me(!0)},150);return()=>{clearTimeout(t),e&&clearTimeout(e)}},[le,V,n,de,fe,ne,re]),Q.useEffect(()=>{if(!V||ae!==`malformed`)return;let e=document.getElementById(`initial-loading`);e&&(e.textContent=`Desktop startup failed — please restart the app.`)},[V,ae]),Q.useEffect(()=>{if(!le||V)return;let e,t=setTimeout(()=>{let t=document.getElementById(`initial-loading`);t&&!n&&(t.classList.add(`fade-out`),e=setTimeout(()=>{t.remove()},300))},5e3);return()=>{clearTimeout(t),e&&clearTimeout(e)}},[le,V,n]),Q.useEffect(()=>{if(!le||h)return;let e=!1;return tn().then(()=>{if(!e)return t()}),()=>{e=!0}},[le,t,h]),Q.useEffect(()=>{if(!le||h||n)return;let e=!0,t,r=0,i=1e3,a=async()=>{if(!e)return;if(r>=10){S(!0);return}let n=jn.getState();if(n.isInitialized){S(!1);return}if(r+=1,await tn(),!e)return;await n.initializeApp();let o=jn.getState();if(!e)return;if(o.isInitialized){S(!1);return}if(r>=10){S(!0);return}let s=Math.min(i*2**(r-1),16e3);t=setTimeout(a,s)};return t=setTimeout(a,i),()=>{e=!1,t&&clearTimeout(t)}},[le,w,n,h]),Q.useEffect(()=>{le&&n&&S(!1)},[le,n]),Q.useEffect(()=>{if(!le||!y)return;let e=document.getElementById(`initial-loading`);if(e){e.classList.add(`fade-out`);let t=setTimeout(()=>{e.remove()},300);return()=>clearTimeout(t)}},[le,y]),Ka({enabled:le&&!h,source:`startupRecovery`}),Q.useEffect(()=>{u||h||r&&nt.setDirectory(s)},[s,u,r,h]),Q.useEffect(()=>{if(!ce||typeof window>`u`)return;let e=e=>{let t=e?.visible===!0;v(t)},t=t=>{if(t.origin!==window.location.origin)return;let n=t.data;n?.type===`yuri:embedded-visibility`&&e(n.payload)},n=window;return n.__yuriSetEmbeddedVisibility=e,window.addEventListener(`message`,t),window.parent&&window.parent!==window&&window.parent.postMessage({type:Lo},window.location.origin),()=>{window.removeEventListener(`message`,t),n.__yuriSetEmbeddedVisibility===e&&delete n.__yuriSetEmbeddedVisibility}},[ce]),Q.useEffect(()=>{!ce?.directory||h||s!==ce.directory&&l(ce.directory,{showOverlay:!1})},[s,ce,h,l]),Q.useEffect(()=>{if(!ce||typeof window>`u`)return;let e=e=>{e.storageArea===window.localStorage&&e.key===`ui-store`&&q.persist.rehydrate()};return window.addEventListener(`storage`,e),()=>{window.removeEventListener(`storage`,e)}},[ce]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail;Cw(t??{})},t=e=>{let t=e.detail;Lt(async()=>{let{openSessionFromDeepLink:e}=await import(`./openSessionFromDeepLink-BI3ok38A.js`);return{openSessionFromDeepLink:e}},__vite__mapDeps([215,20,1,23,5,3,2,6,7,8,9,24,10,25,22,26,27,39,4,40,41,42,43,44,14,11,13,12,15,16,17,18,19,21,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,208])).then(({openSessionFromDeepLink:e})=>e(t??{}))},n=b()?.handleProbe(e=>Lt(async()=>{let{probeSessionLink:e}=await import(`./openSessionFromDeepLink-BI3ok38A.js`);return{probeSessionLink:e}},__vite__mapDeps([215,20,1,23,5,3,2,6,7,8,9,24,10,25,22,26,27,39,4,40,41,42,43,44,14,11,13,12,15,16,17,18,19,21,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,208])).then(({probeSessionLink:t})=>t(e))),r=e=>{let t=e.detail?.assistantID;typeof t==`string`&&t.trim()&&Hr(t.trim())},i=e=>{let t=e.detail,n=t?.projectID,r=t?.taskID;n&&r&&Lt(async()=>{let{openScheduledTask:e}=await import(`./scheduledTaskNavigation-r3g3DfXq.js`).then(e=>e.n);return{openScheduledTask:e}},__vite__mapDeps([168,1,23,5,3,2,6,7,8,9,24,10,25,22,26,27,20,135,136])).then(({openScheduledTask:e})=>e(n,r))};return window.addEventListener(`yuri:open-session`,e),window.addEventListener(`yuri:open-session-link`,t),window.addEventListener(`yuri:open-assistant`,r),window.addEventListener(`yuri:open-scheduled-task`,i),()=>{window.removeEventListener(`yuri:open-session`,e),window.removeEventListener(`yuri:open-session-link`,t),n?.(),window.removeEventListener(`yuri:open-assistant`,r),window.removeEventListener(`yuri:open-scheduled-task`,i)}},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=()=>{let e=G.getState().currentDirectory,{activeProjectId:t,projects:n}=un.getState(),r=n.find(e=>e.id===t)??null;ee(`desktop_open_draft_mini_chat_window`,{directory:e||r?.path||``,projectId:r?.id??null})};return window.addEventListener(`yuri:open-mini-chat`,e),()=>window.removeEventListener(`yuri:open-mini-chat`,e)},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=()=>{if(sn.getState().remoteSession)return;let e=Kn.getState().currentSessionId;e&&Cn(e)};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=0,t=t=>{let n=++e,r=t.detail,i=typeof r?.directory==`string`&&r.directory.trim().length>0?r.directory.trim():null,a=typeof r?.projectId==`string`&&r.projectId.trim().length>0?r.projectId.trim():null,o=typeof r?.initialPrompt==`string`&&r.initialPrompt.trim().length>0?r.initialPrompt.trim():void 0;q.getState().setActiveMainTab(`chat`),q.getState().setSessionSwitcherOpen(!1);let s=un.getState(),c=s.projects.find(e=>e.id===(a??(i?null:s.activeProjectId)));if(r?.hostId){let t=sn.getState().remoteSession,c=s.activeProjectId;Bl({sessionId:null,isNewSession:!0,hostId:r.hostId,hubId:r.hubId,directory:i,projectId:a},()=>n===e&&sn.getState().remoteSession===t&&un.getState().activeProjectId===c).then(async e=>{if(!e)return;let t=sn.getState().remoteSession;o&&t&&await zl(t.location,o)}).catch(e=>X.error(e instanceof Error?e.message:String(e)));return}if(c?.hostId&&c.hubId){let e={hubId:c.hubId,hostId:c.hostId,directory:c.path};s.setActiveProjectIdOnly(c.id),sn.getState().openRemoteSession(c,e,null),o&&zl(e,o).catch(e=>X.error(e instanceof Error?e.message:String(e)));return}sn.getState().clearRemoteSession(),Kn.getState().openNewSessionDraft({selectedProjectId:a,directoryOverride:i,preserveDirectoryOverride:!!i,ensureProjectForDirectory:!!i,initialPrompt:o})};return window.addEventListener(`yuri:open-draft-session`,t),()=>{e+=1,window.removeEventListener(`yuri:open-draft-session`,t)}},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail,n=typeof t?.projectPath==`string`?t.projectPath.trim():``;if(!n)return;let r=un.getState(),i=r.projects.find(e=>!e.hostId&&e.path===n);i?r.setActiveProject(i.id):r.addProject(n)};return window.addEventListener(`yuri:open-project`,e),()=>window.removeEventListener(`yuri:open-project`,e)},[]),Q.useEffect(()=>{typeof window>`u`||!le||!n||u||se.current||(se.current=!0,window.__yuriAppReady=!0,window.dispatchEvent(new Event(`yuri:app-ready`)))},[le,n,u]),Ga({enabled:le}),_w({enabled:le}),xw(),po(),rl(),JC(K(()=>{p(e=>!e)})),Q.useEffect(()=>{E()&&Kt().then(async e=>{e&&await D(e)}).catch(console.warn)},[]),Q.useEffect(()=>{if(!n||!E()||L.current)return;L.current=!0;let e=!1,t=null,r=null;Dl.getState().subscribeDesktopUpdateEvents().then(t=>{if(e){t();return}r=t});let i=()=>{let e=Dl.getState();e.checking||e.checkForUpdates()},a=n=>{t=window.setTimeout(()=>{e||(document.visibilityState===`visible`&&i(),a(Mw))},n)},o=()=>{if(e||document.visibilityState!==`visible`)return;let t=Dl.getState().lastChecked;t!=null&&Date.now()-t<Nw||i()};return a(0),window.addEventListener(`focus`,o),()=>{e=!0,t!==null&&window.clearTimeout(t),window.removeEventListener(`focus`,o),r&&r()}},[n]),pw(),Q.useEffect(()=>{if(ce)return;let e=e=>{$n(e)&&e.shiftKey&&!e.altKey&&(e.code===`KeyD`||e.key.toLowerCase()===`d`)&&(e.preventDefault(),p(e=>!e))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[ce]),Q.useEffect(()=>{ce||i&&setTimeout(()=>a(),5e3)},[a,ce,i]),Q.useEffect(()=>{if(!V||ae!==`not-injected`)return;let e=!1,t=0,n=()=>{if(e)return;t++;let r=te();if(r!==`not-injected`){if(e=!0,U(r),r===`valid`){let e=ie();e&&W(F({isDesktopShell:!0,bootOutcome:e}))}return}let i=Math.min(200*1.1**t,2e3);if(t>=50){let e=document.getElementById(`initial-loading`);e&&!e.textContent?.includes(`taking longer`)&&(e.textContent=`Desktop startup is taking longer than expected...`)}window.setTimeout(n,i)};return window.setTimeout(n,200),()=>{e=!0}},[V,ae]);let he=K(async()=>{if(R({isDesktopShell:C(),isDesktopLocalOriginActive:x()})){await k();return}window.location.reload()}),ge=K(async()=>{if(!P){S(!1),I(!0);try{await tn(),await jn.getState().initializeApp()}finally{I(!1)}jn.getState().isInitialized||T(e=>e+1)}}),_e=e=>{if(e.screen===`recovery`)return e.variant};if(V&&oe&&oe.screen!==`main`){if(oe.screen===`chooser`)return(0,$.jsx)(No,{children:(0,$.jsx)(`div`,{className:`h-full text-foreground bg-transparent`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`h-full`}),children:(0,$.jsx)(jw,{mode:`first-launch`,onCliAvailable:he,onChooseRemote:()=>{}})})})});let e=_e(oe),t=oe.screen===`recovery`&&`url`in oe?oe.url:void 0;return(0,$.jsx)(No,{children:(0,$.jsx)(`div`,{className:`h-full text-foreground bg-transparent`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`h-full`}),children:(0,$.jsx)(jw,{mode:`recovery`,recoveryVariant:e,recoveryHostUrl:t,recoveryHostLabel:void 0,onCliAvailable:he})})})})}if(ce)return xn(),(0,$.jsx)(No,{children:(0,$.jsx)(Qn,{sdk:nt.getSdkClient(),directory:s||``,bootstrapDirectory:o,children:(0,$.jsx)(fo,{apis:e,children:(0,$.jsx)(ti,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsx)(`div`,{className:`h-full text-foreground bg-background`,children:(0,$.jsx)(zw,{embeddedSessionChat:ce,isVSCodeRuntime:h,embeddedBackgroundWorkEnabled:le})})})})},O)});if(ue)return(0,$.jsx)(No,{children:(0,$.jsx)(Dw,{})});if(y&&!n&&!h&&!ce)return(0,$.jsx)(No,{children:(0,$.jsx)(Fw,{onRetry:()=>{ge()},isRetrying:P})});let ve=!n&&!V;return(0,$.jsx)(No,{children:(0,$.jsx)(Qn,{sdk:nt.getSdkClient(),directory:s||``,bootstrapDirectory:o,children:(0,$.jsx)(fo,{apis:e,children:(0,$.jsx)(Zc,{ready:pe&&n&&le,children:(0,$.jsx)(bm,{children:(0,$.jsx)(ti,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsxs)(`div`,{className:V?`h-full text-foreground bg-transparent`:`h-full text-foreground bg-background`,children:[(0,$.jsx)(eo,{embeddedBackgroundWorkEnabled:le}),(0,$.jsx)(ml,{}),(0,$.jsx)(sl,{}),(0,$.jsx)(Dc,{}),(0,$.jsx)(qS,{}),V&&(0,$.jsx)(Aw,{transition:j,ready:n&&r}),(0,$.jsx)(Ow,{}),(0,$.jsx)(Fa,{}),!ve&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(zc,{}),(0,$.jsx)(Sc,{}),(0,$.jsx)(gc,{}),(0,$.jsx)(Pw,{}),d&&(0,$.jsx)(kC,{onClose:()=>p(!1)})]})]})})})})})},O)})}function Vw(e){return e.isAboutDialogOpen}function Hw(e){return e.setAboutDialogOpen}function Uw(e){return e.currentDirectory}function Ww(e){return e.currentSessionId}function Gw(e){return e.setCurrentSession}if(typeof window<`u`&&!window.__YURI_REFRESH_DEBUG_INSTALLED__){window.__YURI_REFRESH_DEBUG_INSTALLED__=!0;let e=performance.getEntriesByType(`navigation`)[0];console.warn(`[refresh-debug] renderer-entry`,{navigationType:e?.type??`unknown`,protocol:window.location.protocol}),window.addEventListener(`beforeunload`,()=>{console.warn(`[refresh-debug] beforeunload`,{visibilityState:document.visibilityState})}),window.addEventListener(`pagehide`,e=>{console.warn(`[refresh-debug] pagehide`,{persisted:e.persisted})})}var Kw=typeof window<`u`&&window.__YURI_RUNTIME_APIS__||(()=>{throw Error(`Runtime APIs not provided for legacy UI entrypoint.`)})();Pr(),C()&&yr(),Wa({runtimeKey:p(),initializeAppearance:Pe,syncSettings:Fe,applyDirectory:ho,startWatchers:()=>{no(),Ha(),Ia()},onError:(e,t)=>{console.error(e===`appearance`?`[main] appearance init failed:`:`[main] settings init failed:`,t)}});var qw=document.getElementById(`root`);if(!qw)throw Error(`Root element not found`);(0,Au.createRoot)(qw).render((0,$.jsx)(Q.StrictMode,{children:(0,$.jsx)(La,{children:(0,$.jsx)(Mr,{children:(0,$.jsx)(Pa,{children:(0,$.jsx)(to,{children:(0,$.jsx)(Ba,{children:(0,$.jsx)(Va,{children:(0,$.jsx)(Bw,{apis:Kw})})})})})})})}));
|