@yuriai/web 0.2.32-beta.1 → 0.2.32-beta.10
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/README.md +19 -0
- package/dist/assets/{AgentAvatar-DLAQkFQe.js → AgentAvatar-DLzcNrQ0.js} +1 -1
- package/dist/assets/AssistantContactStatus-Bf1yg0yx.js +3 -0
- package/dist/assets/{AssistantUnreadBadge-CBGla2En.js → AssistantUnreadBadge-BUFyxUrT.js} +1 -1
- package/dist/assets/{AssistantView-CZUjOyM_.js → AssistantView-CELFybSr.js} +1 -1
- package/dist/assets/{DiagramView-D5Gts9DG.js → DiagramView-DV4P3-Wg.js} +1 -1
- package/dist/assets/{FadeInOnReveal-C9a7XnAh.js → FadeInOnReveal-BRrU2ivL.js} +1 -1
- package/dist/assets/{GuiPluginSurface-CMSZHZPC.js → GuiPluginSurface-NOHaJGy2.js} +1 -1
- package/dist/assets/{GuiPluginWindow-Ba1HfrjQ.js → GuiPluginWindow-BykPaQeY.js} +1 -1
- package/dist/assets/Icon-OJf0qBKf.js +1 -0
- package/dist/assets/{ImageLoadingPlaceholder-Dcy5lc7F.js → ImageLoadingPlaceholder-DlQbo9CM.js} +1 -1
- package/dist/assets/{LoadingImage-BxjJ_Xyj.js → LoadingImage-sZ5omN5L.js} +1 -1
- package/dist/assets/MarkdownRenderer-BFR9FWQL.js +2 -0
- package/dist/assets/MarkdownRendererImpl-iZFUMI3M.js +10 -0
- package/dist/assets/{MarkstreamRendererImpl-EpBnVy9J.css → MarkstreamRendererImpl-C6aiJnjl.css} +1 -1
- package/dist/assets/MarkstreamRendererImpl-DjC_Y4LS.js +3 -0
- package/dist/assets/{MobileDetailNavigation-DcgWfEOt.js → MobileDetailNavigation-BOZpHdI2.js} +1 -1
- package/dist/assets/{MobileResizableSheet-sV9XR-0k.js → MobileResizableSheet-DuAi_epR.js} +1 -1
- package/dist/assets/{MobileShareBridge-DRIEJUQs.js → MobileShareBridge-D1DrqLWf.js} +1 -1
- package/dist/assets/MobileTabPageHeader-BT9gWugr.js +2 -0
- package/dist/assets/{MultiRunWindow-CACYsA-W.js → MultiRunWindow-C0GYNaUU.js} +1 -1
- package/dist/assets/{OnboardingScreen-CnkijSLE.js → OnboardingScreen-CqsI0632.js} +1 -1
- package/dist/assets/{OverlayScrollbar-CCtBTJQj.js → OverlayScrollbar-CZD1yU06.js} +1 -1
- package/dist/assets/SettingsView-BYO8LY5A.js +29 -0
- package/dist/assets/{SettingsWindow-BwzDmS7Q.js → SettingsWindow-CM0Ph9WD.js} +1 -1
- package/dist/assets/SetupTourDialog-BYlSBPKZ.js +1 -0
- package/dist/assets/SetupTourDialog-DrL_4ODI.css +1 -0
- package/dist/assets/{TerminalView-Cw608T7E.js → TerminalView-DnyEAShU.js} +1 -1
- package/dist/assets/{ToolOutputDialog-aKZQU-Zq.js → ToolOutputDialog-BWONfWze.js} +1 -1
- package/dist/assets/{VoiceSettings-CnOk5wPJ.js → VoiceSettings-Ru_0ySgM.js} +2 -2
- package/dist/assets/{YuriLogo-BA5FWp-g.js → YuriLogo-CMUoGUHc.js} +1 -1
- package/dist/assets/YuriWordmark-DHYo0FlR.js +1 -0
- package/dist/assets/{appThemeRegistry-CE2UfF-N.js → appThemeRegistry-BMlAlm0m.js} +1 -1
- package/dist/assets/{button-CBjOhOI0.js → button-C-gRcs_2.js} +1 -1
- package/dist/assets/{capgoAdapter-BMIKl_SL.js → capgoAdapter-GdNfjwXs.js} +1 -1
- package/dist/assets/checkbox-BrJBzET8.js +1 -0
- package/dist/assets/{collapsible-B0j5IQ0T.js → collapsible-B7esGYLd.js} +1 -1
- package/dist/assets/{context-menu-C4e_bpls.js → context-menu-DWn1nSZC.js} +1 -1
- package/dist/assets/desktopHosts-BLU1tGSX.js +1 -0
- package/dist/assets/{desktopRelayRestore-AE3_TnQz.js → desktopRelayRestore-2BIIs8mZ.js} +1 -1
- package/dist/assets/{diagram-WPmk0Qh6.js → diagram-Bnra5_6g.js} +1 -1
- package/dist/assets/{dialog-Dx3IT7dQ.js → dialog-3UseH0hM.js} +1 -1
- package/dist/assets/{es-JU--16Gd.js → es-J7a_sZ1u.js} +2 -2
- package/dist/assets/{fileMentionTouchSelection-Bizsisaj.js → fileMentionTouchSelection-ByaQJcTS.js} +1 -1
- package/dist/assets/{fr-BUZcRuMk.js → fr-BYxUMKWp.js} +2 -2
- package/dist/assets/{gitApi-DXj7IjmF.js → gitApi-BdwvoQFb.js} +1 -1
- package/dist/assets/historyImportQueries-C8VK9R5_.js +1 -0
- package/dist/assets/host-z9PU8q1e.js +1 -0
- package/dist/assets/{input-CEJGM-TS.js → input-CmLlZdeD.js} +1 -1
- package/dist/assets/insertionBoundaries-BpQ6nLjP.js +1 -0
- package/dist/assets/{ja-BwtVLTXD.js → ja-DCdBiJmD.js} +2 -2
- package/dist/assets/{ko--sLsRFpA.js → ko-D-Nb_RJY.js} +2 -2
- package/dist/assets/main-Dosy2jXg.js +2 -0
- package/dist/assets/main-oBh-dk5-.js +169 -0
- package/dist/assets/{markdownHeightCache-D6iSNJG2.js → markdownHeightCache-xNkQdlqi.js} +1 -1
- package/dist/assets/{mcpQueries-D_zQ6E0z.js → mcpQueries-C8zsTQqJ.js} +1 -1
- package/dist/assets/miniChat-CI8ryDGT.js +2 -0
- package/dist/assets/mobile-e_mTK3dh.js +2 -0
- package/dist/assets/{mobileBackNavigation-DC1xEUeI.js → mobileBackNavigation-sB7c0Pi4.js} +1 -1
- package/dist/assets/multirun-DbmgWrsY.js +3 -0
- package/dist/assets/{native-config-BYi6K82g.js → native-config-C_mwkFzh.js} +1 -1
- package/dist/assets/{pl-C4_4J5yA.js → pl-AmU4w3aM.js} +2 -2
- package/dist/assets/{projectMeta-wH9DMvKG.js → projectMeta-1iUbVl_M.js} +1 -1
- package/dist/assets/{pt-BR-DvNC5K1q.js → pt-BR-BI4ft-Fj.js} +2 -2
- package/dist/assets/pwa-BdUAGhLt.js +2 -0
- package/dist/assets/{queue-abort-optimistic-CWoDO6jt.js → queue-abort-optimistic-BwDsaym5.js} +1 -1
- package/dist/assets/react-a6PrrNTm.js +1 -0
- package/dist/assets/{readiness-Br_Q47uu.js → readiness-D2N0DtZF.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-BEeiGIzG.js → renderElectronMiniChatApp-DV0cNt_O.js} +2 -2
- package/dist/assets/{renderMobileApp-B-XnwUvL.js → renderMobileApp-b7--jT5z.js} +7 -7
- package/dist/assets/{runtimeConfig-DainCJ5Y.js → runtimeConfig-DxmJLWUO.js} +1 -1
- package/dist/assets/runtimeEndpointReset-jYAYa3Rh.js +149 -0
- package/dist/assets/{select-bKMw5JE8.js → select-J8r9SxHt.js} +1 -1
- package/dist/assets/sessionLookup-CUQqj2N4.js +1 -0
- package/dist/assets/{sortable-tabs-strip-3sKiA7T1.js → sortable-tabs-strip-CiP6RIQa.js} +1 -1
- package/dist/assets/{speechSettingsQueries-Bv5rjojT.js → speechSettingsQueries-B3ziGQvb.js} +1 -1
- package/dist/assets/src-GtPQ8f4o.css +2 -0
- package/dist/assets/{store-X3lU0obe.js → store-OjrIiXCx.js} +5 -5
- package/dist/assets/{textarea-EsaDD051.js → textarea-BHgcxJdC.js} +1 -1
- package/dist/assets/{tooltip-LLDL5nIZ.js → tooltip-Degmpxnd.js} +1 -1
- package/dist/assets/tour-DDI0Zg7l.js +1 -0
- package/dist/assets/types-QETHY-S7.js +2 -0
- package/dist/assets/{uk-Dvj0JjiC.js → uk-CbdByxxj.js} +2 -2
- package/dist/assets/{useAppFontEffects-Br41do6c.js → useAppFontEffects-LADr3Zl1.js} +53 -53
- package/dist/assets/useDesktopWindowControlsLayout-BVNnRHtc.js +1 -0
- package/dist/assets/{useDictation-DlEHSN6P.js → useDictation-DFVJpRbm.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-niUN5Jtq.js → useEffectiveDirectory-8tqfGdV5.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-DKI3_RxB.js → useMobileNavigationStore-CLUFv-TZ.js} +13 -13
- package/dist/assets/usePluginsStore-B_SIDwsK.js +1 -0
- package/dist/assets/useStreamingTextThrottle-VhgGU_te.js +1 -0
- package/dist/assets/{useWorkerHighlightedLines-CBUWl8le.js → useWorkerHighlightedLines-jlxakDGs.js} +1 -1
- package/dist/assets/{vendor-markstream-react-DfLaSG3W.js → vendor-markstream-react-6zxyQLCD.js} +1 -1
- package/dist/assets/{zh-CN-2Y6u8t24.js → zh-CN-ufEVDbXp.js} +2 -2
- package/dist/assets/{zh-TW-Z5wVv4Fb.js → zh-TW-DTBlZ4YC.js} +2 -2
- package/dist/index.html +8 -8
- package/dist/mini-chat.html +8 -8
- package/dist/mobile.html +8 -8
- package/package.json +1 -1
- package/server/index.js +3 -0
- package/server/lib/client-auth/pairing.js +2 -0
- package/server/lib/client-auth/pairing.test.js +29 -0
- package/server/lib/config-sync/DOCUMENTATION.md +8 -4
- package/server/lib/config-sync/index.js +1 -1
- package/server/lib/config-sync/magpie-auth.js +10 -4
- package/server/lib/config-sync/magpie-auth.test.js +4 -0
- package/server/lib/config-sync/magpie.js +28 -22
- package/server/lib/config-sync/magpie.test.js +127 -2
- package/server/lib/config-sync/plugins.js +44 -0
- package/server/lib/config-sync/plugins.test.js +64 -0
- package/server/lib/config-sync/tar.js +61 -1
- package/server/lib/content-search/DOCUMENTATION.md +9 -0
- package/server/lib/content-search/routes.js +18 -1
- package/server/lib/content-search/routes.test.js +21 -0
- package/server/lib/content-search/runtime.js +7 -3
- package/server/lib/content-search/runtime.test.js +26 -0
- package/server/lib/gui-customization/DOCUMENTATION.md +21 -1
- package/server/lib/gui-customization/session-skill.js +2 -2
- package/server/lib/gui-customization/session-skill.test.js +3 -1
- package/server/lib/gui-customization/skill/SKILL.md +5 -1
- package/server/lib/gui-customization/skill/references/global-pages.md +1 -1
- package/server/lib/gui-customization/skill/references/gui-api.md +4 -1
- package/server/lib/gui-customization/skill/references/icons.md +134 -0
- package/server/lib/gui-customization/skill/references/plugin-styles.md +112 -0
- package/server/lib/gui-customization/skill/references/ui-surfaces.md +2 -0
- package/server/lib/gui-customization/skill/references/work-status.md +110 -0
- package/server/lib/history-import/AGENT_CONNECT_LICENSE +21 -0
- package/server/lib/history-import/DOCUMENTATION.md +223 -0
- package/server/lib/history-import/dev-proxy.integration.test.js +56 -0
- package/server/lib/history-import/events.js +322 -0
- package/server/lib/history-import/events.test.js +110 -0
- package/server/lib/history-import/installations.js +39 -0
- package/server/lib/history-import/installations.test.js +24 -0
- package/server/lib/history-import/native.js +49 -0
- package/server/lib/history-import/native.test.js +42 -0
- package/server/lib/history-import/routes.js +48 -0
- package/server/lib/history-import/routes.test.js +55 -0
- package/server/lib/history-import/service.js +374 -0
- package/server/lib/history-import/service.test.js +538 -0
- package/server/lib/history-import/settings.js +146 -0
- package/server/lib/history-import/settings.test.js +88 -0
- package/server/lib/history-import/sources.js +184 -0
- package/server/lib/history-import/sources.test.js +190 -0
- package/server/lib/history-import/sqlite.js +187 -0
- package/server/lib/history-import/store.js +58 -0
- package/server/lib/history-import/store.test.js +84 -0
- package/server/lib/history-import/targets.js +24 -0
- package/server/lib/host-update/DOCUMENTATION.md +6 -0
- package/server/lib/host-update/routes.test.js +1 -1
- package/server/lib/notifications/native-stream.relay.test.js +1 -0
- package/server/lib/opencode/DOCUMENTATION.md +14 -0
- package/server/lib/opencode/core-routes.js +1 -0
- package/server/lib/opencode/feature-routes-runtime.js +11 -1
- package/server/lib/opencode/plugin-routes.test.js +1 -0
- package/server/lib/opencode/plugins.js +1 -1
- package/server/lib/opencode/plugins.test.js +3 -2
- package/server/lib/opencode/proxy.js +29 -4
- package/server/lib/opencode/proxy.test.js +85 -1
- package/server/lib/opencode/server-utils-runtime.js +2 -0
- package/server/lib/opencode/settings-runtime.js +8 -6
- package/server/lib/opencode/settings-runtime.test.js +44 -0
- package/server/lib/opencode/yuri-routes.js +1 -1
- package/server/lib/relay/DOCUMENTATION.md +1 -1
- package/server/lib/relay/host-client.js +3 -1
- package/server/lib/relay/host-client.test.js +1 -0
- package/server/lib/relay/reasoning-projection.e2e.test.ts +1 -0
- package/server/lib/relay/relay-server.e2e.test.ts +32 -17
- package/server/lib/relay/service.js +2 -0
- package/server/lib/relay/tunnel-host.js +26 -1
- package/server/lib/relay/tunnel-host.test.js +27 -3
- package/server/lib/remote-desktop/runtime.test.js +2 -2
- package/server/lib/ui-auth/DOCUMENTATION.md +3 -0
- package/server/lib/ui-auth/ui-auth.js +27 -0
- package/server/lib/ui-auth/ui-auth.test.js +42 -1
- package/server/plugin-gui-proxy.test.js +1 -1
- package/dist/assets/AssistantContactStatus-CulNHdyA.js +0 -3
- package/dist/assets/Icon-Bh3TaKoN.js +0 -1
- package/dist/assets/MarkdownRenderer-Bn5CJH5N.js +0 -2
- package/dist/assets/MarkdownRendererImpl-ChrPEd5h.js +0 -10
- package/dist/assets/MarkstreamRendererImpl-BtSSTWH7.js +0 -3
- package/dist/assets/MobileTabPageHeader-yt_scp0W.js +0 -2
- package/dist/assets/SettingsView-BC2vBzaV.js +0 -29
- package/dist/assets/SetupTourDialog-Bwzqk4Yk.js +0 -1
- package/dist/assets/SetupTourDialog-CUzqT2sw.css +0 -1
- package/dist/assets/YuriWordmark-Cr1vkcue.js +0 -1
- package/dist/assets/desktopHosts-CMglnUdS.js +0 -1
- package/dist/assets/host-CBfSyi4l.js +0 -1
- package/dist/assets/insertionBoundaries-DC6L5MKG.js +0 -1
- package/dist/assets/main-7x9dVH7f.js +0 -169
- package/dist/assets/main-CA1ut79N.js +0 -2
- package/dist/assets/miniChat-ChJCHXb0.js +0 -2
- package/dist/assets/mobile-CHxWiGaS.js +0 -2
- package/dist/assets/multirun-BrjXkPGe.js +0 -3
- package/dist/assets/pwa-D7mhAQPf.js +0 -2
- package/dist/assets/react-Bwr5-XPi.js +0 -1
- package/dist/assets/runtimeEndpointReset-CUD8K7sC.js +0 -149
- package/dist/assets/sessionLookup-DpDG5rap.js +0 -1
- package/dist/assets/src-PTWgTO6W.css +0 -2
- package/dist/assets/tour-Db44qwfs.js +0 -1
- package/dist/assets/types-DtBBksTR.js +0 -2
- package/dist/assets/useDesktopWindowControlsLayout-ownw04lY.js +0 -1
- package/dist/assets/usePluginsStore-DxXqR1MI.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-DEZ1K7qW.js";import{n as r}from"./runtime-fetch-D0YWp3FJ.js";import{t as i}from"./runtimeAPIRegistry-C2VogTny.js";import{$ as a,A as o,At as s,D as c,F as l,G as u,H as d,I as f,J as p,K as m,M as ee,P as te,S as ne,T as re,U as ie,X as ae,Y as oe,_ as se,a as ce,b as le,c as ue,d as de,et as fe,f as pe,ft as me,gt as he,h as ge,ht as _e,k as ve,m as ye,nt as be,ot as xe,pt as Se,q as Ce,r as we,s as Te,st as Ee,tt as De,ut as Oe,v as ke,vt as Ae,x as je,y as Me}from"./gitApiHttp-MWsHNHuo.js";import{
|
|
1
|
+
import{n as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-DEZ1K7qW.js";import{n as r}from"./runtime-fetch-D0YWp3FJ.js";import{t as i}from"./runtimeAPIRegistry-C2VogTny.js";import{$ as a,A as o,At as s,D as c,F as l,G as u,H as d,I as f,J as p,K as m,M as ee,P as te,S as ne,T as re,U as ie,X as ae,Y as oe,_ as se,a as ce,b as le,c as ue,d as de,et as fe,f as pe,ft as me,gt as he,h as ge,ht as _e,k as ve,m as ye,nt as be,ot as xe,pt as Se,q as Ce,r as we,s as Te,st as Ee,tt as De,ut as Oe,v as ke,vt as Ae,x as je,y as Me}from"./gitApiHttp-MWsHNHuo.js";import{ki as h,p as g,u as Ne}from"./useMobileNavigationStore-CLUFv-TZ.js";var _=`/api/magic-prompts`,Pe=new Map([{id:`git.commit.generate.visible`,title:`Commit Generation Visible Prompt`,group:`Git`,description:`Visible user message for commit message generation.`,template:`You are generating a Conventional Commits subject line from the diffs of the selected files.`},{id:`git.commit.generate.instructions`,title:`Commit Generation Instructions`,group:`Git`,description:`Hidden instructions for commit message generation.`,placeholders:[{key:`selected_files`,description:`Bullet list of currently selected file paths.`}],template:`Return exactly one JSON object and nothing else. Do not include prose, markdown, explanations, or code fences.
|
|
2
2
|
|
|
3
3
|
The JSON object must have exactly this shape:
|
|
4
4
|
{"subject": string, "highlights": string[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e,n as t}from"./runtime-switch-DEZ1K7qW.js";import{n}from"./runtime-fetch-D0YWp3FJ.js";import{n as r}from"./vendor-react-DlzBev0S.js";import{s as i}from"./vendor-tanstack-react-query-B-Wpqq5J.js";import{a}from"./queryRuntime-2dx7jbt9.js";var o=r(),s=[{id:`claude`,name:`Claude Code`},{id:`codex`,name:`Codex`},{id:`cursor`,name:`Cursor`},{id:`dsh`,name:`DeepSeek Harness`},{id:`opencode`,name:`OpenCode`}],c=e=>e.progress??{phase:`importing`,completed:e.completed,total:e.total},l=e=>e?.state===`completed`||e?.state===`partial`,u=async(r,i,a,o)=>{let s=t();if(o!==e())throw Error(`runtime_changed`);let c=await n(`/api/yuri/history-import/${r}`,{...i===void 0?{}:{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)},signal:a});if(!c.ok){let e=await c.json().catch(()=>({}));throw Error(c.status===404||c.status===501?`history_import_unsupported`:e.code??`import_failed`)}let l=await c.json();if(o!==e()||s!==t())throw Error(`runtime_changed`);return l},d=(t=e())=>({queryKey:[t,`history-import`,`job`],queryFn:({signal:e})=>u(`job`,void 0,e,t),staleTime:0,retry:1,refetchInterval:e=>e.state.data?.state===`running`&&1e3}),f=e=>{let t=(0,o.c)(3),n=e===void 0||e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=d(),t[0]=r):r=t[0];let a;return t[1]===n?a=t[2]:(a={...r,enabled:n},t[1]=n,t[2]=a),i(a)},p=(t=e())=>({queryKey:[t,`history-import`,`jobs`],queryFn:({signal:e})=>u(`jobs`,void 0,e,t),staleTime:0,retry:!1});function m(e,t){a.setQueryData(d(t).queryKey,e),a.setQueryData(p(t).queryKey,t=>l(e)?t?.filter(t=>t.id!==e.id):t?.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t??[],e])}var h=(e,t,n)=>u(`scan`,e,t,n),g=(t=e())=>({queryKey:[t,`history-import`,`sources`,`sample`,5,`counts`],queryFn:({signal:e})=>h({sources:s.map(e=>e.id),limitPerSource:5,includeCounts:!0},e,t),staleTime:6e4,gcTime:3e5,retry:!1,refetchOnWindowFocus:!1}),_=e=>{let t=(0,o.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=g(),t[0]=n):n=t[0];let r;return t[1]===e?r=t[2]:(r={...n,enabled:e},t[1]=e,t[2]=r),i(r)},v=(t,n,r,i=e())=>({queryKey:[i,`history-import`,`imported`,t,n,r],queryFn:({signal:e})=>u(`imported`,{scanID:t,directory:n},e,i),staleTime:6e4,gcTime:3e5,retry:!1,refetchOnWindowFocus:!1}),y=(e,t,n,r)=>{let a=(0,o.c)(7),s;a[0]!==t||a[1]!==n||a[2]!==e?(s=v(e,t,n),a[0]=t,a[1]=n,a[2]=e,a[3]=s):s=a[3];let c=!!e&&r,l;return a[4]!==s||a[5]!==c?(l={...s,enabled:c},a[4]=s,a[5]=c,a[6]=l):l=a[6],i(l)};async function b(e,n,r,i,a){if(a!==t())throw Error(`runtime_changed`);let o=await u(`start`,{sources:e,directory:n,confirm:!0},r,i);if(a!==t())throw Error(`runtime_changed`);return m(o,i),o}var x=(e,t,n)=>u(`cancel`,{id:e},t,n);async function S(e,n,r){if(r!==t())throw Error(`runtime_changed`);let i=await u(`resume`,{id:e,confirm:!0},new AbortController().signal,n);if(r!==t())throw Error(`runtime_changed`);return m(i,n),i}async function C(e,n,r){if(r!==t())throw Error(`runtime_changed`);let i=await u(`dismiss`,{id:e},new AbortController().signal,n);if(await Promise.all([a.cancelQueries({queryKey:p(n).queryKey,exact:!0}),a.cancelQueries({queryKey:d(n).queryKey,exact:!0})]),r!==t())throw Error(`runtime_changed`);return a.setQueryData(p(n).queryKey,e=>e?.filter(e=>e.id!==i.id)),a.setQueryData(d(n).queryKey,e=>e?.id===i.id?null:e),i}export{b as a,y as c,l as d,S as i,s as l,C as n,f as o,p as r,_ as s,x as t,c as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,D as t,I as n,L as r,M as i,O as a,P as o,S as s,T as c,_ as l,a as u,b as d,c as f,j as p,n as m,o as h,r as g,s as _,t as v,v as y,w as b,y as x}from"./vendor-opencode-client-cQ47ywrT.js";import{i as ee}from"./vendor-tanstack-query-core-Y_YoRHtC.js";import{n as te,r as ne}from"./fileQueries-C2Rs6TPz.js";import{o as re}from"./path-utils-jGozTg9d.js";import{a as ie,n as ae}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{n as oe}from"./pathNormalization-ewtPqJWn.js";import{n as se}from"./platform-sEg2IOLZ.js";import{Dt as ce,ht as le,mt as ue,y as de}from"./vendor-effect-X1Hqc7ba.js";import{t as S}from"./native-errors-06if6eu-.js";import{a as C,i as w,n as T,o as E,r as fe}from"./appearance--vFosLNi.js";import{i as pe,o as me}from"./fileReferenceParser-1HHDBUum.js";import{n as he,t as ge}from"./vendor-solid-js-D98iXT7C.js";import{a as _e,c as ve,d as ye,f as be,g as D,h as O,i as k,l as A,m as j,n as M,o as N,p as P,r as xe,s as Se,t as Ce,u as we}from"./vendor-opencode-plugin-BmdTE4Te.js";var F={"@opencode/plugin/gui":N,"@opencode/plugin/gui/main":N,"@opencode/plugin/gui/file":_e,"@opencode/plugin/gui/review":k,"@opencode/plugin/gui/browser":xe,"@opencode/plugin/rpc":Ce,"@opencode/schema/rpc":M,"@opencode/client":g,"@opencode/client/effect":m,"@opencode/client/solid":v,effect:de,"solid-js":o,"solid-js/web":he,"solid-js/store":_},I=new Set(`assert assert/strict async_hooks buffer child_process cluster console constants crypto dgram diagnostics_channel dns dns/promises domain events fs fs/promises http http2 https inspector inspector/promises module net os path path/posix path/win32 perf_hooks process punycode querystring readline readline/promises repl stream stream/consumers stream/promises stream/web string_decoder sys timers timers/promises tls trace_events tty url util util/types v8 vm wasi worker_threads zlib`.split(` `));function Te(){let e=new Proxy(function(){},{get:(t,n)=>n===`then`?void 0:n===Symbol.hasInstance?()=>!1:n===Symbol.toPrimitive||n===`toString`?()=>`[main-only module]`:e,apply:()=>e,construct:()=>e,set:()=>!0});return e}function Ee(e,t){if(e.length>16777216)throw Error(`GUI bundle exceeds 16 MiB`);let n={exports:{}};Function(`require`,`module`,`exports`,e)(e=>{if(Object.hasOwn(F,e))return F[e];if(e===`electron`||e.startsWith(`node:`)||I.has(e))return Te();throw Error(`Unsupported GUI shared module: ${e}`)},n,n.exports);let r=n.exports,i=r&&typeof r==`object`&&`default`in r?r.default:r;if(!i||typeof i!=`object`)throw Error(`GUI bundle must default-export Plugin.define`);if((!(`setup`in i)||typeof i.setup!=`function`)&&!(t&&`main`in i&&typeof i.main==`function`))throw new S(`GUI_PLUGIN_UNSUPPORTED`,`This host requires a window setup; main-only plugins are unsupported`);if(`os`in i&&i.os!==void 0){if(!t)throw new S(`GUI_PLUGIN_UNSUPPORTED`,`OS-restricted plugins require the native GUI host`);if(!Array.isArray(i.os)||!i.os.includes(t))throw new S(`GUI_PLUGIN_UNSUPPORTED`,`GUI plugin is unavailable on this OS`)}if(`main`in i&&i.main!==void 0&&typeof i.main!=`function`)throw Error(`Invalid GUI main entry`);if(`stores`in i&&i.stores!==void 0){if(!i.stores||typeof i.stores!=`object`||Array.isArray(i.stores))throw Error(`Invalid GUI stores`);for(let e of Object.values(i.stores))if(!e||typeof e!=`object`||!(`schema`in e)||!ce(e.schema)||!(`scope`in e)||![`global`,`session`].includes(String(e.scope))||!(`initial`in e))throw Error(`Invalid GUI store declaration`)}if(`i18n`in i&&i.i18n!==void 0){if(!i.i18n||typeof i.i18n!=`object`||Array.isArray(i.i18n))throw Error(`Invalid GUI locale catalog`);for(let e of Object.values(i.i18n))if(!e||typeof e!=`object`||Array.isArray(e)||Object.values(e).some(e=>typeof e!=`string`))throw Error(`GUI locales must be inline string dictionaries`)}return i}function L(e){let t=e;if(/^file:/i.test(t)){let e=new URL(t);t=`${e.hostname&&e.hostname!==`localhost`?`//${e.hostname}`:``}${decodeURIComponent(e.pathname)}`,/^\/[a-z]:\//i.test(t)&&(t=t.slice(1))}let n=oe(t)??``;return n===`.`?``:n}var R=e=>/^(?:\/|[a-z]:\/)/i.test(e),z=()=>{throw Error(`Unsupported GUI file API: tree`)},B=class extends Error{},V=e=>new TextEncoder().encode(e).byteLength,De=class{files;query;transport;root;api;ended=!1;states=new Map;inflight=new Map;watches=new Map;apiLeases=new Map;registeredOwners=new WeakSet;endedOwners=new WeakSet;leaseCount=0;rerun=new Set;selections=new Map;scrolls=new Map;subscriptions=new Map;constructor(e,t,n,r){this.files=e,this.query=t,this.transport=n,this.root=r,this.root=L(r),this.api={root:this.root,ready:()=>!this.ended,resolve:e=>this.resolve(e),absolute:R,get:e=>{let t=this.track(e,`file`);return this.states.get(t)},missing:e=>{let t=this.track(e,`missing`);return this.states.get(t)?.notFound===!0},sync:(e,t)=>{let n=a();return this.ended||n&&this.endedOwners.has(n)?Promise.resolve():(this.acquireApiLease(e),this.sync(e,t?.force))},unwatch:e=>this.releaseApiLease(a(),this.resolve(e)),exists:async e=>{try{if(this.files.statFile)return(await this.query.fetchQuery(this.statOptions(e))).isFile;let t=this.full(e);return(await this.files.listDirectory(t.slice(0,t.lastIndexOf(`/`)))).entries.some(e=>!e.isDirectory&&L(e.path)===t)}catch{return!1}},search:async(e,t)=>{if(t?.kind===`any`)throw Error(`Unsupported GUI file search: directories`);t?.signal?.throwIfAborted();let r=await this.query.fetchQuery({queryKey:[`gui-plugin-files`,n,this.root,`search`,e,t?.limit],gcTime:3e4,queryFn:async({signal:n})=>(n.throwIfAborted(),this.files.search({directory:this.root,query:e,maxResults:t?.limit??100}))});if(t?.signal?.throwIfAborted(),this.ended)throw new DOMException(`GUI file model was disposed`,`AbortError`);return r.map(e=>this.resolve(e.path))},selection:{get:e=>this.selections.get(this.track(e,`selection`)),set:(e,t)=>{let n=this.resolve(e),r=this.selections.get(n);r===t||r&&t&&r.start===t.start&&r.end===t.end&&r.side===t.side&&r.endSide===t.endSide||(this.selections.set(n,t),this.trim(this.selections,`selection`),this.changed(n,`selection`))}},scroll:{get:e=>this.scrolls.get(this.track(e,`scroll`))??{},set:(e,t)=>{let n=this.resolve(e),r=this.scrolls.get(n),i={...r,...t};(r?.top!==i.top||r?.left!==i.left)&&(this.scrolls.set(n,i),this.trim(this.scrolls,`scroll`),this.changed(n,`scroll`))}},tree:{list:z,state:z,sync:z,expand:z,collapse:z}}}resolve(e){let t=L(e);if(!R(t))return t;if(t===this.root)return``;let n=this.root.endsWith(`/`)?this.root:`${this.root}/`;return t.startsWith(n)?t.slice(n.length):t}full(e){let t=this.resolve(e);return R(t)?t:L(`${this.root}/${t}`)}input(e){return{scopeDirectory:this.root,path:this.full(e),options:{directory:this.root}}}statOptions(e){return{...ne(this.files,this.input(e),this.transport),gcTime:3e4}}track(e,n){let r=this.resolve(e),a=t();if(!a||this.ended)return r;let o=`${n}:${r}`,s=this.subscriptions.get(o);s||(s={revision:c(0),listeners:new Set},this.subscriptions.set(o,s));let l=s;return l.listeners.has(a)||(l.listeners.add(a),i(a,()=>p(()=>{l.listeners.delete(a),!l.listeners.size&&this.subscriptions.get(o)===l&&this.subscriptions.delete(o)}))),l.revision[0](),r}changed(e,t){this.ended||this.subscriptions.get(`${t}:${e}`)?.revision[1](e=>e+1)}trim(e,t){for(;e.size>64;){let n=e.keys().next().value;e.delete(n),this.changed(n,t)}}setState(e,t){let n=this.states.get(e);n?.content?.content===t.content?.content&&n?.content?.type===t.content?.type&&(t.content=n?.content),!(n&&n.loaded===t.loaded&&n.loading===t.loading&&n.error===t.error&&n.notFound===t.notFound&&n.content===t.content)&&(this.states.set(e,t),l(()=>{this.changed(e,`file`),n?.notFound===!0!=(t.notFound===!0)&&this.changed(e,`missing`)}))}acquireApiLease(e){let t=a();if(this.ended||t&&this.endedOwners.has(t)||!this.files.statFile)return;let n=this.resolve(e),r=this.apiLeases.get(t);if(r?.has(n))return;if(this.leaseCount>=256)throw Error(`GUI file consumer limit exceeded`);let i=this.watch(n);r||(r=new Map,this.apiLeases.set(t,r)),r.set(n,i),this.leaseCount++,t&&!this.registeredOwners.has(t)&&(this.registeredOwners.add(t),p(()=>{`fn`in t||this.endedOwners.add(t),this.registeredOwners.delete(t);for(let e of[...this.apiLeases.get(t)?.keys()??[]])this.releaseApiLease(t,e)}))}releaseApiLease(e,t){let n=this.apiLeases.get(e),r=n?.get(t);r&&(n.delete(t),this.leaseCount--,n.size||this.apiLeases.delete(e),r())}reserve(e){if(!this.states.has(e)){if(this.states.size>=64){let e=[...this.states.keys()].find(e=>!this.watches.has(e)&&!this.inflight.has(e));if(!e)throw Error(`GUI file cache limit exceeded`);let t=this.states.get(e)?.notFound===!0;this.states.delete(e),l(()=>{this.changed(e,`file`),t&&this.changed(e,`missing`)})}this.states.set(e,{path:e,name:e.split(`/`).at(-1)??e})}}async sync(e,t=!1){if(this.ended)return;let n=this.resolve(e);if(this.inflight.has(n))return t&&this.rerun.add(n),this.inflight.get(n);if(!t&&this.states.get(n)?.loaded&&!this.states.get(n)?.error)return;this.reserve(n);let r=this.states.get(n);this.setState(n,{...r,path:n,name:n.split(`/`).at(-1)??n,loading:!r?.loaded&&!this.watches.get(n)?.failed});let i=(async()=>{try{do{this.rerun.delete(n);let e=this.watches.get(n),r=e?.epoch;try{let i=te(this.files,this.input(n),this.transport),a=await this.query.fetchQuery({...i,gcTime:3e4,staleTime:t?0:3e4,queryFn:async()=>{if(!this.files.readFile)throw Error(`File content reads are unavailable in this runtime`);let e=await this.files.readFile(this.full(n),{directory:this.root});if(e.exists===!1)throw new B(`File does not exist`);let t=e.content;if(V(t)>131072)throw Error(`GUI file preview exceeds 128 KiB`);return t}});if(this.ended)return;if(V(a)>131072)throw Error(`GUI file preview exceeds 128 KiB`);(!e||e.epoch===r&&!e.failed)&&this.setState(n,{path:n,name:n.split(`/`).at(-1)??n,loaded:!0,loading:!1,content:{type:`text`,content:a}})}catch(t){if(this.ended)return;if((!e||e.epoch===r&&!e.failed)&&this.setState(n,{...this.states.get(n),loading:!1,...t instanceof B?{notFound:!0}:{},error:String(t)}),!this.rerun.has(n))throw t}t=!0}while(!this.ended&&this.rerun.has(n))}finally{this.inflight.delete(n),this.rerun.delete(n)}})();return this.inflight.set(n,i),i}watch(e){if(this.ended||!this.files.statFile)return()=>{};let t=this.resolve(e),n=this.watches.get(t);if(!n){if(this.watches.size>=64)throw Error(`GUI file watch limit exceeded`);this.reserve(t),n={count:0,epoch:0,failed:!1,stop:()=>{}};let e=n;this.watches.set(t,e);let r,i=new ee(this.query,{...this.statOptions(t),refetchInterval:2e3,refetchIntervalInBackground:!1}),a=i.subscribe(n=>{if(this.ended||this.watches.get(t)!==e||n.isFetching)return;if(n.isError||n.isSuccess&&!n.data.isFile){e.failed=!0,e.epoch++,this.setState(t,{...this.states.get(t),loading:!1,notFound:n.isSuccess?!0:this.states.get(t)?.notFound,error:n.isError?String(n.error):`File does not exist`});return}if(!n.data||!n.isSuccess)return;let i=`${n.data.size}:${n.data.mtimeMs??``}`,a=e.failed||r!==void 0&&i!==r;e.failed=!1,r=i,a&&(e.epoch++,this.sync(t,!0).catch(()=>{}))});e.stop=()=>{a(),i.destroy()},this.states.get(t)?.loaded&&this.sync(t,!0).catch(()=>{})}n.count++;let r=!0;return()=>{r&&(r=!1,--n.count===0&&this.watches.get(t)===n&&this.stopWatch(t))}}stopWatch(e){this.watches.get(e)?.stop(),this.watches.delete(e)}dispose(){this.ended=!0;for(let e of this.watches.values())e.stop();this.watches.clear(),this.apiLeases.clear(),this.leaseCount=0,this.rerun.clear(),this.states.clear(),this.inflight.clear(),this.selections.clear(),this.scrolls.clear(),this.subscriptions.clear()}},H=256,U=2097152,W=e=>structuredClone(f(e)),Oe=class{backend;transport;memory=new Map;resets=new Map;constructor(e,t){this.backend=e,this.transport=t}forPlugin(e,t){let n=(t,n=`global`)=>{if(typeof n==`object`&&`session`in n&&!n.session.location)throw Error(`Unsupported GUI storage: session location is unknown`);let r=n===`global`?n:`session`in n?[n.session.server.id,n.session.id,n.session.location]:[n.server,n.directory];return`yuri.gui-plugin.${JSON.stringify([this.transport,e,r,t])}`},r=e=>{if(t.aborted)throw Error(`GUI plugin has been disposed`);if(e!==void 0)throw Error(`Unsupported GUI storage migration: from`)},i=new Map;return{store:(e,a)=>{r(a.from);let o=n(e,a.scope),s=i.get(o);if(s)return s;if(i.size>=H)throw Error(`GUI plugin store limit exceeded`);let l=ue(a.schema),u=le(a.schema),d=l(u(W(a.initial)));if(JSON.stringify(u(d)).length>U)throw Error(`GUI plugin store exceeds 2 MiB`);let f=d,p=this.backend.getItem(o);if(p!==null&&p.length<=U)try{f=l(JSON.parse(p))}catch{f=d}let[m,h]=c(f),g=e=>{r();let t=JSON.stringify(u(W(e)));if(t.length>U)throw Error(`GUI plugin store exceeds 2 MiB`);let n=l(JSON.parse(t));this.backend.setItem(o,t),h(()=>n)},_={get value(){return m()},ready:()=>!0,set:g,update:e=>{let t=W(m());if(e(t)!==void 0)throw Error(`Store update must not return a replacement`);g(t)}},v=()=>h(()=>W(d)),y=this.resets.get(o)??new Set;return y.add(v),this.resets.set(o,y),t.addEventListener(`abort`,()=>{y.delete(v),y.size||this.resets.delete(o),i.clear()},{once:!0}),i.set(o,_),_},memory:(e,t)=>{r();let i=n(e),a=this.memory.get(i);if(a)return[a[0],e=>{r(),a[1](e)}];if(this.memory.size>=H)throw Error(`GUI plugin memory store limit exceeded`);if(JSON.stringify(t.initial).length>U)throw Error(`GUI plugin memory exceeds 2 MiB`);let[o,s]=u(W(t.initial)),c=[o,e=>{r();let t=W(f(o));if(e(t)!==void 0)throw Error(`Memory update must not return a replacement`);if(JSON.stringify(t).length>U)throw Error(`GUI plugin memory exceeds 2 MiB`);s(h(t))}];return this.memory.set(i,[o,e=>{let t=W(f(o));if(e(t)!==void 0)throw Error(`Memory update must not return a replacement`);if(JSON.stringify(t).length>U)throw Error(`GUI plugin memory exceeds 2 MiB`);s(h(t))}]),c},remove:(e,t)=>{r(t?.from);let i=n(e,t?.scope);this.backend.removeItem(i);for(let e of this.resets.get(i)??[])e()}}}dispose(){this.memory.clear(),this.resets.clear()}},G=e=>e===`yuri.exportPDF`||e===`yuri.exportLongImage`,ke=class{api;probe;clients=new Map;ended=!1;constructor(e){this.api=e}use(e,t){let n=this.clients.get(t),r=n?.get(e);if(r)return r.live;let[i,a]=c(this.api&&!t.aborted&&!this.ended?{status:`pending`}:{status:`inactive`,reason:`disabled`}),o=()=>{a({status:`inactive`,reason:`disabled`}),t.removeEventListener(`abort`,o),this.clients.delete(t)},s={live:D(i),stop:o};if(this.ended||t.aborted||(n||(n=new Map,this.clients.set(t,n)),n.set(e,s),t.addEventListener(`abort`,o,{once:!0}),!this.api))return s.live;let l=this.api;return this.probe??=Promise.resolve().then(()=>l.capabilities()),this.probe.then(n=>{if(this.ended||t.aborted)return;let r=e===`yuri.exportPDF`?`exportPDF`:`exportLongImage`;if(n.version!==1||!n[r]){a({status:`inactive`,reason:`disabled`});return}let o=async(e,n={})=>{if(this.ended||t.aborted||i().status!==`active`)return{status:`cancelled`};let o=AbortSignal.any([t,...n.signal?[n.signal]:[]]);try{return await l[r](e,{...n,signal:o})}catch(e){throw e&&typeof e==`object`&&`code`in e&&e.code===`EXPORT_UNSUPPORTED`&&a({status:`inactive`,reason:`failed`}),e}},s=Object.freeze(e===`yuri.exportPDF`?{version:1,limits:n.limits,exportPDF:o}:{version:1,limits:n.limits,exportLongImage:o});a({status:`active`,generation:1,value:s})}).catch(()=>{!this.ended&&!t.aborted&&a({status:`inactive`,reason:`failed`})}),s.live}dispose(){this.ended=!0;for(let e of this.clients.values())for(let t of e.values())t.stop();this.clients.clear()}};function Ae(e,t){let n=new Map,r=Object.freeze({dismiss(){}});return e.addEventListener(`abort`,()=>{for(let e of[...n.values()])e.handle.dismiss()},{once:!0}),Object.freeze({show(i){if(e.aborted)return r;if(!t)throw new S(`GUI_PLUGIN_UNSUPPORTED`,`GUI toast is unavailable`);if(!i||typeof i!=`object`)throw new S(`GUI_PLUGIN_INVALID_INPUT`,`Expected toast options`);let{title:a,description:o,variant:s=`default`,duration:c=5e3,persistent:l=!1,icon:u,actions:d}=i;if(typeof a!=`string`||o!==void 0&&typeof o!=`string`||![`default`,`success`,`error`,`loading`].includes(s)||typeof l!=`boolean`||typeof c!=`number`||!Number.isFinite(c)||c<0)throw new S(`GUI_PLUGIN_INVALID_INPUT`,`Invalid toast options`);if(u!==void 0||d!==void 0)throw new S(`GUI_PLUGIN_UNSUPPORTED`,`GUI toast icon/actions are unsupported`);if(e.aborted)return r;let f=JSON.stringify([a,o??null,s,c,l]),p=n.get(f),m=()=>{let e=n.get(f);!e||e.id!==h||(clearTimeout(e.timer),n.delete(f))},h=(s==="default"?t:t[s])(a,{id:p?.id,description:o,duration:l?1/0:c,onDismiss:m,onAutoClose:m}),g=p?.handle??Object.freeze({dismiss(){m(),t.dismiss(h)}});clearTimeout(p?.timer);let _=s===`loading`&&!l?setTimeout(()=>g.dismiss(),c):void 0;return n.set(f,{id:h,handle:g,timer:_}),g}})}var je=ie(`YuriMedia`);async function Me(e){let t=/\.html?$/i.test(e.name)?`text/html`:`text/plain`,n=new Blob([e.content],{type:t});if(se()){if(!ae.isPluginAvailable(`YuriMedia`))throw new S(`GUI_PLUGIN_UNSUPPORTED`,`Native file saving is unavailable`);if(n.size>33554432)throw new S(`GUI_PLUGIN_INVALID_INPUT`,`File exceeds maximum size`);let r=await new Promise((e,t)=>{let r=new FileReader;r.onload=()=>{if(typeof r.result!=`string`){t(Error(`Failed to encode file`));return}e(r.result.slice(r.result.indexOf(`,`)+1))},r.onerror=()=>t(r.error??Error(`Failed to encode file`)),r.readAsDataURL(n)});return!(await je.saveFile({dataBase64:r,mimeType:t,filename:e.name})).cancelled}let r=URL.createObjectURL(n),i=document.createElement(`a`);try{return i.href=r,i.download=e.name,document.body.append(i),i.click(),!0}finally{i.remove(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}}var K=d();function Ne(e){return{version:1,register(t){let n=r(K);if(!n||n.plugin!==e||n.signal.aborted||e.aborted)throw Error(`Preview actions require the owning mounted panel`);let i=new AbortController,a=AbortSignal.any([e,n.signal,i.signal]),o,s=()=>{a.removeEventListener(`abort`,s),i.abort(),o?.remove()};p(s),a.addEventListener(`abort`,s,{once:!0});try{o=t.render({element:t.element,signal:a,async snapshot(e={}){let r=AbortSignal.any([a,...e.signal?[e.signal]:[]]);if(r.throwIfAborted(),!n.content.contains(t.element)||n.target.contains(t.element))throw Error(`Preview capture region is no longer in its owning panel`);let i=await t.capture({...e,signal:r});if(r.throwIfAborted(),!n.content.contains(t.element))throw Error(`Preview capture region was replaced`);return i}}),a.throwIfAborted(),n.target.append(o)}catch(e){throw s(),e}return s}}}function q(e,t){return JSON.stringify([e,t])}function Pe(e){if(!e||typeof e!=`object`||!(`id`in e)||typeof e.id!=`string`||!e.id.trim()||e.id.length>128||!(`title`in e)||typeof e.title!=`string`||!(`render`in e)||typeof e.render!=`function`)throw Error(`Invalid yuri.page contribution`);return e}var Fe=`yuri.work-status`;function J(e,t){return e===t||!!(e&&t&&Object.keys(e).length===Object.keys(t).length&&Object.keys(e).every(n=>e[n]===t[n]))}var Y=e=>e&&Object.freeze({...e});function Ie(e,t,n){let r=new AbortController,[i,a]=c(!0),[o,s]=c(Y(e.project),{equals:J}),[u,d]=c(Y(e.worktree),{equals:J}),[f,p]=c(Object.freeze({...e.git}),{equals:J}),[m,h]=c(e.placement);return{props:Object.freeze({session:t,directory:e.directory,runtimeId:n,signal:r.signal,get active(){return i()},get project(){return o()},get worktree(){return u()},get git(){return f()},get placement(){return m()}}),matches:t=>t.sessionId===e.sessionId&&t.directory===e.directory,update(e){r.signal.aborted||l(()=>{s(Y(e.project)),d(Y(e.worktree)),p(Object.freeze({...e.git})),h(e.placement)})},dispose(){r.signal.aborted||(a(!1),r.abort())}}}var Le=class{plugins=new Map;order=new Map;snapshot=Object.freeze([]);generation=0;listeners=new Set;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.snapshot;setOrder(e){e.length===this.order.size&&e.every((e,t)=>this.order.get(e)===t)||(this.order=new Map(e.map((e,t)=>[e,t])),this.publish())}replace(e,t,n){let r=this.plugins.get(e)??[],i=new Set,a=n.map(n=>{if(!n||typeof n!=`object`||!(`id`in n)||typeof n.id!=`string`||!n.id.trim()||n.id.length>128||i.has(n.id)||!(`render`in n)||typeof n.render!=`function`||`order`in n&&n.order!==void 0&&(typeof n.order!=`number`||!Number.isFinite(n.order)))throw Error(`Invalid or duplicate yuri.work-status contribution`);i.add(n.id);let a=JSON.stringify([e,n.id]),o=`order`in n&&typeof n.order==`number`?n.order:0,s=n.render,c=r.find(e=>e.key===a),l=c&&c.revision===t&&c.render===s?c.generation:++this.generation;return c&&c.revision===t&&c.render===s&&c.order===o?c:Object.freeze({key:a,pluginId:e,revision:t,generation:l,order:o,render:s})});a.length?this.plugins.set(e,a):this.plugins.delete(e),this.publish()}contains(e){return this.plugins.get(e.pluginId)?.some(t=>t.key===e.key&&t.generation===e.generation)??!1}remove(e){this.plugins.delete(e)&&this.publish()}dispose(){this.plugins.clear(),this.publish(),this.listeners.clear()}publish(){let e=[...this.plugins.values()].flat().sort((e,t)=>e.order-t.order||(this.order.get(e.pluginId)??2**53-1)-(this.order.get(t.pluginId)??2**53-1));if(!(e.length===this.snapshot.length&&e.every((e,t)=>e===this.snapshot[t]))){this.snapshot=Object.freeze(e);for(let e of this.listeners)n(e)}}},X=e=>{throw new S(`GUI_PLUGIN_UNSUPPORTED`,`Unsupported GUI host API: ${e}`)};function Z(e,t){return new Proxy(t,{get:(t,n)=>n in t?Reflect.get(t,n):X(`${e}.${String(n)}`)})}var Q=e=>Object.freeze(e.map(e=>Object.freeze(e)));function Re(e,t){if(!e.fields||!t.fields)return!1;let n=Reflect.ownKeys(e.fields);return n.length===Reflect.ownKeys(t.fields).length&&n.every(n=>{let r=e.fields[n],i=t.fields[n];return i!==void 0&&`value`in r&&`value`in i&&Object.is(r.value,i.value)&&r.enumerable===i.enumerable&&r.configurable===i.configurable&&r.writable===i.writable})}function $(e,t){if(e){for(let n of e.owned??[])$(n,t);e.cleanups&&=e.cleanups.map(e=>()=>{try{Promise.resolve(e()).catch(t)}catch(e){t(e)}})}}var ze=class{options;fileIcons=new E;appearanceCatalog=new w;workStatus=new Le;instances=new Map;listeners=new Set;panelMounts=new Set;fileViews=new Map;changes=c(0);views=c(0);session=c();currentPage=c();appearance;layouts=new Map;files;storage;ended=!1;contracts=new Map;snapshot=Object.freeze({plugins:Object.freeze([]),commands:Object.freeze([]),titlebarItems:Object.freeze([]),panels:Object.freeze([]),pages:Object.freeze([]),settings:Object.freeze([]),menuItems:Object.freeze([]),activePanel:null});#e;viewExports;constructor(e){this.options=e,this.viewExports=new ke(e.viewExport),this.appearance=c({locale:e.locale,mode:e.mode,narrow:e.narrow}),this.storage=new Oe(e.storage,e.transport);let t=()=>(this.session[0](),this.files?.api??X(`screen.file without a session`));this.#e=Z(`screen`,{get file(){return t()}})}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.snapshot;changed(e=!1){let t=this.snapshot;this.changes[1](e=>e+1),e&&t===this.snapshot&&this.publish()}setSession(e){if(this.ended)return;let t=this.session[0]();if(t?.id===e?.id&&t?.directory===e?.directory)return;if(!e)for(let e of[...this.panelMounts])e();this.files?.dispose(),this.files=e?new De(this.options.files,this.options.queryClient,this.options.transport,e.directory):void 0;let n=e?this.sessionReference(e):void 0,r=this.snapshot;this.session[1](n),r===this.snapshot&&this.publish()}sessionReference(e){let t=Z(`session.server`,{id:this.options.transport,name:this.options.transport,client:this.options.client});return Object.freeze(Z(`session`,{id:e.id,directory:e.directory,key:`${this.options.transport}\n${e.id}`,tab:e.id,server:t,pending:!1,visit:{},location:{directory:e.directory}}))}setAppearance(e){if(this.ended)return;let t=this.appearance[0]();(t.locale!==e.locale||t.mode!==e.mode||t.narrow!==e.narrow)&&this.appearance[1]({...e})}setPage(e){this.ended||this.currentPage[1](e)}install(t,r,o){let s=this.instances.get(t);if(this.ended||s?.status===`active`&&s.revision===r.revision&&s.native?.active!==!1){o?.dispose();return}s&&(this.instances.delete(t),this.release(s));let l={id:t,native:o,revision:r.revision,controller:new AbortController,status:`active`,cleanups:new Set,contributions:new Set,iconChanges:c(0),appearanceChanges:c(0),workStatusChanges:c(0),commands:[],titlebarItems:[],panels:[],pages:[],settings:[],menus:[]};this.instances.set(t,l);try{if(t===`yuri`||t.startsWith(`yuri.`))throw Error(`The yuri namespace is reserved to the host`);let s=Ee(r.code,o?.activation.os);b(t=>{l.dispose=t,l.root=a(),y(()=>x(O.Provider,{value:l.context=this.context(l,s,r.options),get children(){l.owner=a();let e=n(()=>s.setup?.(l.context));if(typeof e==`function`)l.cleanups.add(()=>{Promise.resolve(e()).catch(e=>{l.error=String(e)})});else if(e!==void 0)throw e&&typeof e==`object`&&`then`in e&&Promise.resolve(e).catch(()=>{}),Error(`GUI setup must be synchronous and return only cleanup`);return null}}),e=>this.fail(l,e)),l.controller.signal.aborted||i(l.owner,()=>e(()=>{if(l.iconChanges[0](),!l.controller.signal.aborted)try{let e=[...l.contributions].filter(e=>e.registry===C).map(e=>e.read()).filter(e=>e!==void 0);this.fileIcons.replace(l.id,e),l.iconError!==void 0&&n(()=>{l.iconError=void 0,this.publish()})}catch(e){n(()=>{this.fileIcons.remove(l.id),l.iconError=e instanceof Error?e.message:String(e),this.publish()})}})),l.controller.signal.aborted||i(l.owner,()=>e(()=>{if(l.appearanceChanges[0](),!l.controller.signal.aborted)try{let e=e=>[...l.contributions].filter(t=>t.registry===e).map(e=>e.read()).filter(e=>e!==void 0);this.appearanceCatalog.replace(l.id,e(fe),e(T),l.native?.activation.capabilities?.dockIcon===!0)}catch(e){n(()=>this.fail(l,e))}})),l.controller.signal.aborted||i(l.owner,()=>e(()=>{if(l.workStatusChanges[0](),!l.controller.signal.aborted)try{let e=[...l.contributions].filter(e=>e.registry===Fe).map(e=>e.read()).filter(e=>e!==void 0);this.workStatus.replace(l.id,l.revision,e)}catch(e){n(()=>this.fail(l,e))}})),l.controller.signal.aborted||i(l.owner,()=>e(()=>{this.changes[0](),this.session[0](),this.appearance[0]();try{this.derive(l)}catch(e){n(()=>this.fail(l,e))}n(()=>this.publish())}))})}catch(e){this.fail(l,e)}this.changed(!0)}release(e){e.controller.abort(),e.native?.dispose();for(let t of[...e.cleanups])try{t()}catch(t){e.error??=String(t)}e.cleanups.clear(),$(e.root,t=>{e.error??=String(t)});try{e.dispose?.()}catch(t){e.error??=String(t)}e.contributions.clear(),e.commands=[],e.titlebarItems=[],e.panels=[],e.pages=[],e.settings=[],e.menus=[],this.fileIcons.remove(e.id),this.appearanceCatalog.remove(e.id),this.workStatus.remove(e.id);for(let t of this.contracts.values())t.provider===e&&(t.provider=void 0,t.live[1]({status:`inactive`,reason:e.status===`failed`?`failed`:`disabled`}))}fail(e,t){e.status!==`failed`&&this.instances.get(e.id)===e&&(e.status=`failed`,e.error=t instanceof Error?t.message:String(t),t instanceof S&&(e.errorCode=t.code),this.release(e),this.publish())}uninstall(e){let t=this.instances.get(e);if(t){this.instances.delete(e),this.release(t);for(let t of this.layouts.values())t.open=t.open.filter(t=>!t.startsWith(`${e}:`)),t.active?.startsWith(`${e}:`)&&(t.active=null);this.changed(!0)}}dispose(){this.ended||(this.ended=!0,l(()=>{for(let e of[...this.instances.keys()])this.uninstall(e)}),this.viewExports.dispose(),this.files?.dispose(),this.fileIcons.dispose(),this.appearanceCatalog.dispose(),this.workStatus.dispose(),this.storage.dispose(),this.layouts.clear(),this.fileViews.clear(),this.contracts.clear(),this.listeners.clear())}async setDockIcon(e,t){let n=this.instances.get(e),r=n?.native;if(!r?.active||!r.activation.capabilities?.dockIcon)return X(`Dock icon`);try{await r.setDockIcon(t)}catch(e){throw t!==null&&n&&this.fail(n,e),e}}own(e,t){let n=!0,i=()=>{n&&(n=!1,e.cleanups.delete(i),t())};return e.controller.signal.aborted||r(P)?.ended?(i(),i):(e.cleanups.add(i),a()&&p(i),i)}list(e){this.changes[0]();let t=[];for(let n of this.instances.values())if(n.status===`active`){for(let r of n.contributions)if(r.registry===e.id){let e=r.read();e!==void 0&&t.push(e)}}return t}context(t,i,o){let c=this.storage.forPlugin(t.id,t.controller.signal),l=Object.fromEntries(Object.entries(i.stores??{}).map(([e,t])=>[e,t.scope===`global`?c.store(e,{...t,scope:`global`}):n=>c.store(e,{...t,scope:{session:n}})])),u=(e,t)=>{let n=this.appearance[0]().locale;return(i.i18n?.[n]?.[e]??i.i18n?.[n.split(`-`)[0]]?.[e]??i.i18n?.en?.[e]??e).replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t?.[n]??e))},d=Z(`layout`,{narrow:()=>this.appearance[0]().narrow,ready:()=>!!this.session[0](),open:(e,n,r)=>{t.controller.signal.aborted||this.openPanel(e,n,r)},close:(e,n)=>{t.controller.signal.aborted||this.closeFor(e,n)},toggle:(e,t)=>d.state(e,t)===`visible`?d.close(e,t):d.open(e,t),hide:(e,n)=>{if(t.controller.signal.aborted)return;let r=this.layout(n);r.active===e&&r.shown&&(r.shown=!1,this.changed())},state:(e,t)=>{this.changes[0]();let n=this.layout(t);return n.active===e?n.shown?`visible`:`active`:n.open.includes(e)?`open`:`closed`},stored:e=>(this.changes[0](),this.layout(e).open.filter(e=>e.startsWith(`${t.id}:`)).map(e=>e.slice(t.id.length+1))),side:{opened:e=>(this.changes[0](),this.layout(e).shown),toggle:e=>{if(t.controller.signal.aborted)return;let n=this.layout(e);n.shown=!n.shown,this.changed()},menu:()=>this.list(A).filter(e=>e.menu===`session.panel`).sort((e,t)=>(e.order??0)-(t.order??0))},scroll:{get:(e,t)=>(this.changes[0](),this.layout(e).scroll.get(t)),set:(e,n,r)=>{if(t.controller.signal.aborted)return;let i=this.layout(e).scroll;if(!i.has(n)&&i.size>=128)throw Error(`GUI layout scroll limit exceeded`);i.set(n,{...r}),this.changed()}}}),f=Ne(t.controller.signal),m=D(()=>t.controller.signal.aborted?{status:`inactive`,reason:`disabled`}:{status:`active`,generation:1,value:f}),h={open:e=>t.controller.signal.aborted||this.appearance[0]().narrow||!t.pages.some(t=>t.id===e)?!1:this.options.openPage?.(q(t.id,e))??!1,current:()=>{let e=this.currentPage[0]();return t.pages.find(n=>q(t.id,n.id)===e)?.id}},g=D(()=>t.controller.signal.aborted||!this.options.openPage||this.appearance[0]().narrow?{status:`inactive`,reason:`disabled`}:{status:`active`,generation:1,value:h});return Z(`ctx`,{id:t.id,options:o,signal:t.controller.signal,client:this.options.client,storage:c,stores:l,toast:Ae(t.controller.signal,this.options.toast),app:{name:`yuri`,version:t.native?.activation.app.version??``,channel:t.native?.activation.app.packaged?`prod`:`local`,platform:t.native?`desktop`:`web`,packaged:t.native?.activation.app.packaged??!1},desktop:t.native?Z(`desktop`,{os:t.native.activation.os}):void 0,t:u,plural:(e,t,n)=>{let r=`${e}.${new Intl.PluralRules(this.appearance[0]().locale).select(t)}`;return u(r,{...n,count:t})===r?u(`${e}.other`,{...n,count:t}):u(r,{...n,count:t})},add:(i,o)=>{if(t.controller.signal.aborted||r(P)?.ended)return()=>{};if([`server`,`composer-pill`,`slot`,`file.viewer`,`menubar-item`].includes(i.id)&&X(`registry.${i.id}`),t.contributions.size>=256)throw Error(`GUI contribution limit exceeded`);let c=()=>{},l,u=b(n=>{c=n,l=a();let r=()=>typeof o==`function`?o():o,u;if(i.id===`yuri.file-icon`){let e=s(()=>{try{return{ok:!0,value:r()}}catch(e){return{ok:!1,error:e}}});u=()=>{let t=e();if(!t.ok)throw t.error;return t.value}}else u=s(r);if(i.id===`style`){let n=document.createElement(`style`);n.dataset.yuriPluginStyle=t.id,document.head.append(n),p(()=>n.remove()),e(()=>{let e=u();n.textContent=e===void 0?``:String(e)})}return{registry:i.id,read:u}},a()??t.owner);t.contributions.add(u);let d=()=>{i.id===`yuri.file-icon`&&t.iconChanges[1](e=>e+1)},f=()=>{(i.id===`yuri.theme`||i.id===`yuri.branding`)&&t.appearanceChanges[1](e=>e+1)},m=()=>{i.id===`yuri.work-status`&&t.workStatusChanges[1](e=>e+1)};return n(d),n(f),n(m),n(()=>this.changed()),this.own(t,()=>{$(l,e=>{t.error??=String(e)}),c(),t.contributions.delete(u),n(d),n(f),n(m),n(()=>this.changed())})},list:e=>this.list(e),provide:(e,n)=>{if(t.controller.signal.aborted||r(P)?.ended)return()=>{};if(G(e.id)||e.id===`yuri.previewActions`||e.id===`yuri.pages`)throw Error(`Preview/export/page contracts are provided only by the Yuri host`);if(e.kind!==`contract`||!(e.id===t.id||e.id.startsWith(`${t.id}.`)))throw Error(`Contract must belong to the providing plugin`);let i=this.contract(e.id);if(i.provider)throw Error(`Contract already provided: ${e.id}`);return i.provider=t,i.live[1]({status:`active`,value:n,generation:++i.generation}),this.own(t,()=>{i.provider===t&&(i.provider=void 0,i.live[1]({status:`inactive`,reason:t.status===`failed`?`failed`:`disabled`}))})},use:e=>e.id===`yuri.pages`?e.kind===`contract`?g:X(`pages token must be a Contract`):e.id===`yuri.previewActions`?e.kind===`contract`?m:X(`preview actions token must be a Contract`):G(e.id)?e.kind===`contract`?this.viewExports.use(e.id,t.controller.signal):X(`export token must be a Contract`):e.kind===`ipc`&&t.native?t.native.token(e).live:this.contract(e.id,e.kind===`ipc`).live[0],main:e=>{if(!(e.id===t.id||e.id.startsWith(`${t.id}.`)))throw new S(`GUI_PLUGIN_FORBIDDEN`,`IPC must belong to the plugin`);return t.native?t.native.token(e).value:new Proxy({state:()=>void 0},{get:(e,t)=>t===`state`?e.state:t===`on`?()=>{throw new S(`GUI_PLUGIN_UNSUPPORTED`)}:()=>Promise.reject(new S(`GUI_PLUGIN_UNSUPPORTED`))})},sessions:{current:this.session[0],list:()=>{let e=this.session[0]();return e?[e]:[]}},screen:{current:()=>this.session[0]()?this.#e:void 0},layout:d,appearance:{mode:()=>this.appearance[0]().mode,font:()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||`monospace`},locale:{locale:()=>this.appearance[0]().locale,direction:()=>/^(ar|fa|he|ur)(-|$)/i.test(this.appearance[0]().locale)?`rtl`:`ltr`},system:{copy:e=>navigator.clipboard.writeText(e),openExternal:e=>{let t=new URL(e);[`https:`,`http:`,`mailto:`].includes(t.protocol)||X(`system.openExternal protocol`),window.open(e,`_blank`,`noopener,noreferrer`)},save:Me},commands:{run:e=>t.controller.signal.aborted||!this.command(e)?!1:(this.runCommand(e),!0)},links:{open:e=>!t.controller.signal.aborted&&this.navigateLink(t,e),exists:e=>n(()=>{if(t.controller.signal.aborted)return!1;let n=this.linkHandler(e);try{return Promise.resolve(n?.value.exists?.(e)??!1).catch(()=>!1)}catch{return!1}})}})}contract(e,t=!1){let n=this.contracts.get(e);if(!n){if(this.contracts.size>=256)throw Error(`GUI contract limit exceeded`);let t=c({status:`inactive`,reason:`disabled`});n={live:[D(t[0]),t[1]],generation:0},this.contracts.set(e,n)}return t&&n.provider&&X(`IPC contract collision`),n}derive(e){if(e.status!==`active`)return;let t=[],r=[],i=[],a=[],o=[],s=[],c=this.session[0]();for(let n of e.contributions){if([`yuri.file-icon`,`yuri.theme`,`yuri.branding`,`yuri.work-status`].includes(n.registry))continue;let l=n.read();if(l!==void 0){if(n.registry===`yuri.page`){let e=Pe(l);if(s.some(t=>t.id===e.id))throw Error(`Duplicate yuri.page id`);s.push(e)}else if(n.registry===Se.id){let n=l;n.enabled!==!1&&t.push({key:`${e.id}.${n.id}`,pluginId:e.id,title:n.title,description:n.description,bind:n.bind,hidden:n.hidden,run:()=>this.invoke(e,()=>n.run())})}else if(n.registry===be.id){let t=l;o.push({key:JSON.stringify([e.id,t.id]),pluginId:e.id,label:t.label,title:t.title,icon:t.icon,busy:t.busy,pressed:t.pressed,actionable:!!t.run,run:t.run})}else if(n.registry===we.id&&c){let t=l,n=`${e.id}:`,i=this.layout(c).open.filter(e=>e.startsWith(n)).map(e=>e.slice(n.length));for(let n of t.list({session:c,screen:this.#e,open:i}))r.push({plugin:e,panel:t,tab:n})}else if(n.registry===ye.id){let e=l;(e.page||e.section)&&X(`SettingsPage host sections`),e.title,i.push(e)}else if(n.registry===A.id){let e=l;e.menu===`session.panel`?(e.title,a.push(e)):X(`MenuItem.${e.menu}`)}}}for(let e of r)e.tab.title;e.commands=t,e.titlebarItems=o,e.panels=r,e.pages=s,e.settings=i,e.menus=a,n(()=>this.views[1](e=>e+1))}publish(){let e=n(this.session[0]),t=e?this.layouts.get(e.key):void 0,r=[...this.instances.values()],i=r.filter(e=>e.status===`active`),a=i.flatMap(e=>e.panels.map(({tab:n})=>{let r=n.file?this.filePath(n.file):void 0;return{key:`${e.id}:${n.id}`,pluginId:e.id,title:n.title,file:r,inline:!!(r&&this.fileViews.has(r)),active:t?.shown===!0&&t.active===`${e.id}:${n.id}`}}));this.snapshot=Object.freeze({plugins:Q(r.map(({id:e,revision:t,status:n,error:r,errorCode:i,iconError:a})=>({id:e,revision:t,status:n,error:r??a,...i?{errorCode:i}:{}}))),commands:Q(i.flatMap(e=>e.commands.filter(e=>!e.hidden))),panels:Q(a),titlebarItems:Q(i.flatMap(e=>e.titlebarItems.map(({run:e,...t})=>t))),pages:Q(i.flatMap(e=>e.pages.map(t=>({key:q(e.id,t.id),pluginId:e.id,title:t.title,icon:t.icon})))),settings:Q(i.flatMap(e=>e.settings.map(t=>({key:`${e.id}:${t.id}`,pluginId:e.id,title:t.title})))),menuItems:Q(i.flatMap(e=>e.menus.map(t=>({key:`${e.id}:${t.id}`,pluginId:e.id,title:t.title,description:t.description,run:()=>{this.invoke(e,()=>t.run())}})))),activePanel:t?.shown&&a.some(e=>e.key===t.active)?t.active:null,sessionKey:e?.key});for(let e of this.listeners)e()}invoke(e,t){if(!e.controller.signal.aborted)try{let n=i(e.owner??null,t);if(n instanceof Promise)return n.catch(t=>this.fail(e,t))}catch(t){this.fail(e,t)}}command(e){return[...this.instances.values()].flatMap(e=>e.commands).find(t=>t.key===e)}runCommand(e){return this.command(e)?.run()}runTitlebarItem(e){for(let t of this.instances.values()){let n=t.titlebarItems.find(t=>t.key===e);if(n?.run&&!n.busy)return this.invoke(t,n.run)}}linkHandler(e){let t=[];for(let e of this.instances.values())for(let n of e.contributions)if(n.registry===ve.id){let r=n.read();r&&t.push({instance:e,value:r})}for(let n of t.sort((e,t)=>(t.value.priority??0)-(e.value.priority??0)))try{if(n.value.match(e))return n}catch(e){this.fail(n.instance,e)}}navigateLink(e,t){if(this.ended)return!1;let n=me(t.href);if(!n||!pe(n.path))return this.openLink(t);let r=this.session[0]();if(!r||t.session&&(t.session.key!==r.key||t.session.server.id!==r.server.id))return!1;if(!this.options.focusFile)return this.openLink(t);let i=re(t.base??r.directory,n.path),a=n.line===void 0?``:`:${n.line}${n.column===void 0?``:`:${n.column}`}`;return this.invoke(e,()=>this.options.focusFile(i+a,r.directory)),!0}openLink(e){if(this.ended)return!1;let t={...e,session:e.session??this.session[0]()},n=this.linkHandler(t);return n?(this.invoke(n.instance,()=>n.value.open(t)),!0):!1}filePath(e,t=this.session[0]()?.directory){let n=L(e);return/^(?:\/|[a-z]:\/)/i.test(n)||!t?n:L(`${t}/${n}`)}registerFileView(e,t){if(this.ended)return()=>{};let n=this.filePath(e,t),r=this.fileViews.get(n)??0;this.fileViews.set(n,r+1),r===0&&this.changed(!0);let i=!1;return()=>{if(i||this.ended)return;i=!0;let e=(this.fileViews.get(n)??1)-1;if(e){this.fileViews.set(n,e);return}{let e=this.session[0](),t=e&&this.layouts.get(e.key);t?.active&&this.snapshot.panels.some(e=>e.key===t.active&&e.file===n)&&(t.shown=!1),this.fileViews.delete(n)}this.changed(!0)}}filePanel(e,t){let n=this.filePath(e,t);return this.snapshot.panels.find(e=>e.file===n&&e.inline)}panelVisible(e){let t=this.session[0]();if(!t)return!1;let n=this.panel(e)?.tab.file;if(n&&this.fileViews.has(this.filePath(n)))return!0;let r=this.layouts.get(t.key);return!!(r?.shown&&r.active===e)}layout(e){let t=this.layouts.get(e.key);if(!t){if(this.layouts.size>=128)throw Error(`GUI session layout limit exceeded`);t={open:[],active:null,shown:!1,scroll:new Map},this.layouts.set(e.key,t)}return t}openPanel(e,t,n){if(this.ended)return;let r=this.layout(t),i=r.active,a=r.shown,o=r.open.length;if(!r.open.includes(e)){if(r.open.length>=64)throw Error(`GUI panel tab limit exceeded`);r.open=[...r.open,e]}n?.tab!==`append`&&(r.active=e,r.shown=!(this.appearance[0]().narrow&&n?.background)),(i!==r.active||a!==r.shown||o!==r.open.length)&&this.changed(!0);let s=this.panel(e);t.key===this.session[0]()?.key&&s&&n?.tab!==`append`&&this.invoke(s.plugin,()=>s.panel.focus?.({...this.props(e),restored:!1}))}selectPanel(e){let t=this.session[0]();t&&this.openPanel(e,t)}closeFor(e,t){let n=this.layout(t),r=t.key===this.session[0]()?.key?this.panel(e):void 0;if(!n.open.includes(e)||r?.tab.pinned||r?.tab.closable===!1)return;let i=this.session[0](),a=r&&i?{tab:r.tab,session:i,screen:this.#e}:void 0;n.open=n.open.filter(t=>t!==e),n.active===e&&(n.active=n.open.at(-1)??null),this.changed(!0),r&&a&&this.invoke(r.plugin,()=>r.panel.close?.(a))}closePanel(e){let t=this.session[0]();t&&this.closeFor(e,t)}hidePanel(){let e=this.session[0]();if(!e)return;let t=this.layout(e);t.shown&&(t.shown=!1,this.changed(!0))}panel(e){return[...this.instances.values()].flatMap(e=>e.panels).find(t=>`${t.plugin.id}:${t.tab.id}`===e)}props(e,t=!1){let n=this.panel(e)?.tab,r=()=>(this.views[0](),this.panel(e)?.tab??n??X(`panel no longer listed`)),i=t?s(()=>{let e=r();return{tab:e,fields:Object.getPrototypeOf(e)===Object.prototype?Object.getOwnPropertyDescriptors(e):void 0}},void 0,{equals:Re}):void 0,a=i?()=>i().tab:r,o=()=>this.session[0]()??X(`panel without session`);return{get tab(){return a()},get session(){return o()},screen:this.#e}}mountPanel(t,r,i){let a=this.panel(t);if(!a)return()=>{};let o=new AbortController,c=()=>{let c=s(()=>{this.session[0](),this.changes[0](),this.views[0]();let e=this.panel(t)?.tab.file;return e&&this.files&&this.panelVisible(t)?{model:this.files,file:e}:void 0},void 0,{equals:(e,t)=>e?.model===t?.model&&e?.file===t?.file});e(()=>{let e=c();e&&(p(e.model.watch(e.file)),e.model.sync(e.file).catch(()=>{}))});let l=()=>n(()=>a.panel.render(this.props(t,!0)));return x(K.Provider,{value:i?{plugin:a.plugin.controller.signal,signal:o.signal,content:r,target:i}:void 0,get children(){return l()}})},l=this.mount(a.plugin,r,()=>x(j.Provider,{value:{visible:()=>(this.changes[0](),this.panelVisible(t)),present:()=>(this.changes[0](),this.panelVisible(t)),placement:()=>this.appearance[0]().narrow?`mobile`:`side`,reserve:()=>!1,animate:()=>!1,sidebar:Z(`panel.sidebar`,{}),open:()=>{let e=this.session[0]();return e?a.plugin.context.layout.stored(e):[]}},get children(){return c()}})),u=()=>{this.panelMounts.delete(u),o.abort(),l()};return this.panelMounts.add(u),this.own(a.plugin,u)}mountSettings(e,t){for(let n of this.instances.values()){let r=n.settings.find(t=>`${n.id}:${t.id}`===e);if(r)return this.mount(n,t,()=>r.render({}))}return()=>{}}mountPage(e,t){if(this.appearance[0]().narrow)return()=>{};for(let n of this.instances.values()){let r=n.pages.find(t=>q(n.id,t.id)===e);if(r)return this.mount(n,t,()=>r.render())}return()=>{}}mountWorkStatus(e,t,n){let r=this.instances.get(e.pluginId);if(!r||!this.workStatus.contains(e)||this.ended)return{update(){},dispose(){}};let i=Ie(n,n.sessionId&&n.directory?this.sessionReference({id:n.sessionId,directory:n.directory}):void 0,this.options.transport),a=()=>{},o=()=>{},s=this.own(r,()=>{i.dispose(),o(),a()});return o=this.workStatus.subscribe(()=>{this.workStatus.contains(e)||s()}),a=this.mount(r,t,()=>e.render(i.props)),i.props.signal.aborted&&(o(),a()),{update:e=>{if(!i.matches(e)){s();return}i.update(e)},dispose:s}}mount(e,t,r){if(e.controller.signal.aborted)return()=>{};let i=()=>{},o,s=t=>{queueMicrotask(()=>this.fail(e,t))};try{i=ge(()=>x(O.Provider,{value:e.context,get children(){return o=a(),y(()=>n(r),s)}}),t)}catch(t){this.fail(e,t)}return this.own(e,()=>{$(o,t=>{e.error??=String(t)}),i(),t.replaceChildren()})}};export{ze as GuiPluginHost};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-hePW80VL.js";import{ot as e,st as t}from"./vendor-base-ui-CzHs0bHY.js";import{n}from"./vendor-react-DlzBev0S.js";import{r}from"./button-
|
|
1
|
+
import"./rolldown-runtime-hePW80VL.js";import{ot as e,st as t}from"./vendor-base-ui-CzHs0bHY.js";import{n}from"./vendor-react-DlzBev0S.js";import{r}from"./button-C-gRcs_2.js";var i=n();t();var a=e();function o(e){let t=(0,i.c)(23),n,o,s,c,l,u;t[0]===e?(n=t[1],o=t[2],s=t[3],c=t[4],l=t[5],u=t[6]):({className:o,type:u,bordered:n,placeholder:c,endAdornment:s,...l}=e,t[0]=e,t[1]=n,t[2]=o,t[3]=s,t[4]=c,t[5]=l,t[6]=u);let d=c||` `,f=n!==void 0&&`border border-transparent ring-0 focus:ring-0 aria-invalid:ring-1 aria-invalid:focus:ring-1`,p=n&&`border-[var(--form-surface-border)]`,m=s&&`pe-11`,h;t[7]!==o||t[8]!==f||t[9]!==p||t[10]!==m?(h=r(`text-foreground file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground bg-[var(--surface-elevated)] appearance-none flex h-9 w-full min-w-0 rounded-lg px-3 py-1 typography-markdown outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:typography-ui-label file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:typography-ui-label`,`ring-1 ring-inset ring-border/60 transition duration-200 ease-out`,`hover:[&:not(:focus)]:bg-[var(--surface-subtle)] hover:[&:not(:focus)]:ring-transparent`,`focus:ring-2 focus:ring-[var(--interactive-focus-ring)] focus-visible:outline-none`,`aria-invalid:ring-[var(--status-error)] aria-invalid:focus:ring-[var(--status-error)]`,f,p,o,m),t[7]=o,t[8]=f,t[9]=p,t[10]=m,t[11]=h):h=t[11];let g;t[12]!==n||t[13]!==l||t[14]!==d||t[15]!==h||t[16]!==u?(g=(0,a.jsx)(`input`,{type:u,"data-slot":`input`,"data-bordered":n,placeholder:d,className:h,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,...l}),t[12]=n,t[13]=l,t[14]=d,t[15]=h,t[16]=u,t[17]=g):g=t[17];let _=g;if(!s)return _;let v;t[18]===s?v=t[19]:(v=(0,a.jsx)(`div`,{"data-slot":`input-end-adornment`,className:`absolute inset-y-0 end-0 flex items-center`,children:s}),t[18]=s,t[19]=v);let y;return t[20]!==_||t[21]!==v?(y=(0,a.jsxs)(`div`,{"data-slot":`input-wrapper`,className:`relative min-w-0 w-full flex-1`,children:[_,v]}),t[20]=_,t[21]=v,t[22]=y):y=t[22],y}export{o as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n}from"./runtime-switch-DEZ1K7qW.js";import{T as r}from"./desktop-BAmoc_34.js";import{a as i,i as a,r as o}from"./vendor-zustand-vDaAPGfl.js";import{ot as s,st as c}from"./vendor-base-ui-CzHs0bHY.js";import{bt as l,kt as u}from"./gitApiHttp-MWsHNHuo.js";import{r as d,x as f}from"./useUIStore-BerIUSLP.js";import{A as p,k as m}from"./bootstrap-C8paoQ0j.js";import{n as h}from"./vendor-react-DlzBev0S.js";import{i as g}from"./vendor-reactuses-core-DWo5Wn6R.js";import{f as ee,r as _,u as te}from"./button-C-gRcs_2.js";import{$r as v,Kr as y,Qn as b,St as x,V as S,Wi as ne,Zn as C,_a as re,ea as ie,ft as ae,ki as oe,p as w,va as T,w as E,x as D}from"./useMobileNavigationStore-CLUFv-TZ.js";import{a as se,g as O,o as ce,p as le,s as ue}from"./fileMentionAutocompleteState-BZJqfgae.js";import{t as k}from"./AgentAvatar-DLzcNrQ0.js";import{n as A}from"./Icon-OJf0qBKf.js";import{g as j,v as M}from"./gitApi-BdwvoQFb.js";import{c as de,d as fe,l as pe,n as me,r as he,t as ge}from"./fileMentionTouchSelection-ByaQJcTS.js";import{n as _e}from"./textarea-BHgcxJdC.js";import{f as ve,o as N}from"./projectMeta-1iUbVl_M.js";var ye=(e,t)=>{let n=t.trim();if(!n)return[...e].sort((e,t)=>e.isBuiltIn===t.isBuiltIn?e.name.localeCompare(t.name):e.isBuiltIn?-1:1);let r=O([...e],n,e=>[e.name,e.description??``]);return r.sort((e,t)=>e.score===t.score?e.item.isBuiltIn===t.item.isBuiltIn?e.item.name.localeCompare(t.item.name):e.item.isBuiltIn?-1:1:e.score-t.score),r.map(e=>e.item)},be=(e,t)=>e===t||e.length===t.length&&e.every((e,n)=>{let r=t[n];return r!=null&&e.id===r.id&&e.title===r.title&&(e.subtitle??``)===(r.subtitle??``)&&(e.badge??``)===(r.badge??``)&&e.iconName===r.iconName&&e.agentName===r.agentName}),P=(e,t)=>e.highlightedIndex===t.highlightedIndex&&be(e.rows,t.rows),F=(e,t)=>be(e,t)?e:t.slice(),xe=(e,t,n)=>{e&&(t.current&&P(t.current,n)||(t.current=n,e(n)))},Se=(e,t)=>{t.current=null,e?.({rows:[],highlightedIndex:0})},I=e(c(),1),L=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},R=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,z=(e,t)=>{let n=L(t),r=L(e);if(!n||!r)return!1;let i=R(n),a=R(r);return a===i||a.startsWith(`${i}/`)},Ce=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t=L(e);if(!t||!r||typeof r!=`object`)continue;let i=r,a=Array.isArray(i.openPaths)?Array.from(new Set(i.openPaths.filter(e=>typeof e==`string`).map(e=>L(e)).filter(e=>z(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>L(e)).filter(e=>z(e,t)))):[],s=typeof i.selectedPath==`string`?L(i.selectedPath):null,c=s&&z(s,t)?s:a[0]??null,l=typeof i.touchedAt==`number`&&Number.isFinite(i.touchedAt)?i.touchedAt:Date.now(),u=n[t];if(u){let e=Array.from(new Set([...u.openPaths,...a])),r=Array.from(new Set([...u.expandedPaths,...o]));n[t]={openPaths:e,selectedPath:u.selectedPath??c??e[0]??null,expandedPaths:r,touchedAt:Math.max(u.touchedAt,l)};continue}n[t]={openPaths:a,selectedPath:c,expandedPaths:o,touchedAt:l}}return n},B=(e,t)=>{let n=Object.entries(e);if(n.length<=t)return e;n.sort((e,t)=>(t[1]?.touchedAt??0)-(e[1]?.touchedAt??0));let r={};for(let[e,i]of n.slice(0,t))r[e]=i;return r},V=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},we=i()(o(a((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=L((t||``).trim()),a=L((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!z(a,i)||e(e=>{let t=e.byRoot[i],n=V(t),r=n.openPaths.includes(a),o=r?n.openPaths:[...n.openPaths,a],s=n.selectedPath??a;return t&&r&&t.selectedPath===s?e:{byRoot:B({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=L((t||``).trim()),i=L((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=R(i),a=e=>R(e)===n,o=t.selectedPath?a(t.selectedPath):!1;if(!t.openPaths.some(a)&&!o)return e;let s=t.openPaths.filter(e=>!a(e)),c=o?s[0]??null:t.selectedPath;return{byRoot:B({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=L((t||``).trim()),i=L((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=R(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=R(e);return t===n||t.startsWith(a)},s=t.openPaths.filter(e=>!o(e));if(s.length===t.openPaths.length)return e;let c=t.selectedPath&&o(t.selectedPath)?s[0]??null:t.selectedPath;return{byRoot:B({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=L((t||``).trim()),i=L((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=R(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=R(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:B({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=L((t||``).trim()),a=n?L(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!z(a,i)||e(e=>{let t=e.byRoot[i],n=V(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:B({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=L((e||``).trim());if(!n)return;let r=t().byRoot[n];if(!r||r.selectedPath)return;let i=r.openPaths[0]??null;i&&t().setSelectedPath(n,i)},toggleExpandedPath:(t,n)=>{let r=L((t||``).trim()),i=L((n||``).trim());!r||!i||!z(i,r)||e(e=>{let t=e.byRoot[r],n=V(t),a=n.expandedPaths.includes(i)?n.expandedPaths.filter(e=>e!==i):[...n.expandedPaths,i];return t&&t.expandedPaths===a&&t.selectedPath===n.selectedPath&&t.openPaths===n.openPaths?e:{byRoot:B({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=L((t||``).trim()),i=L((n||``).trim());!r||!i||!z(i,r)||e(e=>{let t=e.byRoot[r],n=V(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:B({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=L((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>L((e||``).trim())).filter(e=>e&&z(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=V(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:B({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,...o]}},20)}})}}),{name:`files-view-tabs-store`,version:2,storage:f(),migrate:e=>{if(!e||typeof e!=`object`)return{byRoot:{}};let t=e.byRoot;return{byRoot:Ce(t)}},partialize:e=>({byRoot:Ce(e.byRoot)})}),{name:`files-view-tabs-store`})),H=h(),Te=(e,t)=>{let n=(0,H.c)(4),r=t===void 0?200:t,[i,a]=I.useState(e),o,s;return n[0]!==r||n[1]!==e?(o=()=>{let t=window.setTimeout(()=>{a(e)},r);return()=>{window.clearTimeout(t)}},s=[e,r],n[0]=r,n[1]=e,n[2]=o,n[3]=s):(o=n[2],s=n[3]),I.useEffect(o,s),i},Ee=()=>{let e=(0,H.c)(17),t=w(De),n=x(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=E(r),a=w(Oe),o=w(ke),s=T(Ae),c=T(je),u=l(Me);if(t){let r;e[2]===i?r=e[3]:(r=D(i),e[2]=i,e[3]=r);let o=r;if(o)return o;let s;e[4]!==t||e[5]!==a?(s=a.get(t),e[4]=t,e[5]=a,e[6]=s):s=e[6];let c=s;if(c?.path)return c.path;let l;if(e[7]!==t||e[8]!==n){let r;e[10]===t?r=e[11]:(r=e=>e.id===t,e[10]=t,e[11]=r),l=n.find(r),e[7]=t,e[8]=n,e[9]=l}else l=e[9];let u=l;if(u?.directory)return u.directory}if(o?.open&&(o.bootstrapPendingDirectory||o.directoryOverride))return(o.bootstrapPendingDirectory||o.directoryOverride)??void 0;if(s){let t;if(e[12]!==s||e[13]!==c){let n;e[15]===s?n=e[16]:(n=e=>e.id===s,e[15]=s,e[16]=n),t=c.find(n),e[12]=s,e[13]=c,e[14]=t}else t=e[14];let n=t;if(n?.path)return n.path}return u??void 0};function De(e){return e.currentSessionId}function Oe(e){return e.worktreeMetadata}function ke(e){return e.newSessionDraft}function Ae(e){return e.activeProjectId}function je(e){return e.projects}function Me(e){return e.currentDirectory}var U=s(),W=`bg-transparent font-[inherit] text-[var(--primary-base)]`,G=(e,t)=>{let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase();if(!r.includes(n))return e;let i=[],a=0,o=r.indexOf(n);for(;o!==-1;)o>a&&i.push(e.slice(a,o)),i.push((0,U.jsx)(`mark`,{className:W,children:e.slice(o,o+n.length)},`${o}-${n}`)),a=o+n.length,o=r.indexOf(n,a);return a<e.length&&i.push(e.slice(a)),i},K=I.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSkillSelect:r,onSessionSelect:i,onClose:a,style:o,onRowsChange:s},c)=>{let{t:l}=ee(),f=Ee()??``,h=w(e=>e.currentSessionId),b=v(e=>e.activeSessions),x=S({enabled:!!i}),C=T(e=>e.activeProjectId),re=T(e=>e.projects),ae=I.useMemo(()=>re.find(e=>e.id===C)?.path??null,[C,re]),E=I.useMemo(()=>{let e=ae||f;return e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null},[ae,f]),D=we(e=>E?e.byRoot[E]:void 0),O=oe(e=>e.agents),j=u(e=>e.searchFiles),M=Te(e,180),fe=p(),pe=m(),[ve,N]=I.useState([]),[ye,be]=I.useState(!1),[P,F]=I.useState(0),L=I.useRef(0),R=I.useRef({query:e,directory:f,ids:[]}),[z,Ce]=I.useState(360),[B,V]=I.useState({}),[H,De]=I.useState({}),Oe=I.useRef([]),ke=I.useRef([]),Ae=I.useRef([]),je=I.useRef(null),Me=I.useRef(null),W=I.useRef(null);W.current||=ge();let K=d(e=>e.isMobile),q=(e??``).trim(),J=ie({directory:f||null}),Ne=I.useMemo(()=>r?J.data??[]:[],[r,J.data]),Pe=I.useMemo(()=>{if(!E||!D)return[];let e=[D.selectedPath,...D.openPaths.slice().reverse()].filter(e=>typeof e==`string`&&e.length>0),t=new Set,n=[];for(let r of e){if(t.has(r))continue;t.add(r);let e=r.replace(/\\/g,`/`),i=e.split(`/`).filter(Boolean).pop()||e,a=e.startsWith(`${E}/`)?e.slice(E.length+1):e;n.push({name:i,path:e,relativePath:a,extension:i.includes(`.`)?i.split(`.`).pop()?.toLowerCase():void 0})}return ue(n,q,{limit:6})},[q,E,D]),Fe=I.useMemo(()=>n?ne(O).filter(e=>e.mode!==`primary`):[],[O,n]),Y=I.useMemo(()=>i?se({sessions:y(b,x),currentSessionId:h,searchQuery:q}):[],[b,h,x,q,i]),Ie=Pe,Le=ve,X=I.useMemo(()=>de({skills:Ne,agents:Fe,sessions:Y,recentFiles:Ie,pathHits:Le,searchQuery:q,untitledSession:l(`chat.fileMentionAutocomplete.untitledSession`),sessionBadge:l(`chat.fileMentionAutocomplete.sessionType`),skillBadge:l(`chat.commandAutocomplete.badge.skill`)}),[Ne,Fe,Y,Ie,Le,q,l]);I.useEffect(()=>{let e=e=>{let t=e.target;!t||!je.current||je.current.contains(t)||a()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[a]),I.useEffect(()=>{if(!f){N([]);return}let e=(M??``).trim(),t=le(e);if(!t){N([]);return}let n=!1;be(!0);let r={includeHidden:fe,respectGitignore:!pe};return Promise.all([j(f,t,80,{...r,type:`file`}),j(f,t,40,{...r,type:`directory`})]).then(([t,r])=>{if(n)return;let i=new Set(Pe.map(e=>e.path));N(ce({files:t,directories:r,query:e,excludePaths:i,limit:20}))}).catch(()=>{n||N([])}).finally(()=>{n||be(!1)}),()=>{n=!0}},[f,M,Pe,j,fe,pe]),I.useLayoutEffect(()=>{let t=R.current,n=t.ids[L.current],r=t.query===e&&t.directory===f?Math.max(0,X.findIndex(e=>e.id===n)):0;R.current={query:e,directory:f,ids:X.map(e=>e.id)},L.current=r,F(r)},[X,e,f]),I.useEffect(()=>{V({}),De({})},[X]),I.useEffect(()=>{Oe.current[P]?.scrollIntoView({block:`nearest`})},[P]),I.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};ke.current.forEach((n,r)=>{if(!n)return;let i=Ae.current[r]?.offsetWidth??n.scrollWidth,a=Math.max(0,i-n.clientWidth),o=a>8;if(e[r]=o,o){let e=Math.max(.6,a/110);t[r]=e}}),V(e),De(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[X]),I.useEffect(()=>{let e=ke.current[P];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&Ce(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[P]);let Re=g(e=>{t(e)}),ze=g(e=>{n?.(e)}),Be=g(e=>{i?.(e)}),Ve=g(e=>{r?.(e)}),He=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&W.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&W.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(W.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>W.current?.pointerCancel(),onClick:()=>{W.current?.click(t)},onMouseMove:()=>{L.current=e,F(e)}}),Ue=e=>{let t=X.length;if(t===0)return;let n=(e%t+t)%t,r=X[n];if(r.agentName!==void 0){ze(r.agentName);return}if(r.id.startsWith(`skill:`)){let e=Ne.find(e=>r.id===`skill:${e.name}-${e.scope}`);e&&Ve(e);return}if(r.id.startsWith(`session:`)){let e=Y.find(e=>r.id===`session:${e.id}`);e&&Be(e);return}let i=r.id.startsWith(`recent:`)?Ie.find(e=>r.id===`recent:${e.path}`):Le.find(e=>r.id===`file:${e.path}`);i&&Re(i)};I.useEffect(()=>{xe(s,Me,{rows:X,highlightedIndex:P})},[s,P,X]);let We=I.useRef(s);return We.current=s,I.useEffect(()=>()=>{Se(We.current,Me)},[]),I.useImperativeHandle(c,()=>({acceptIndex:e=>{Ue(e)},handleKeyDown:e=>{if(e===`Escape`){a();return}let t=X.length;if(t!==0){if(e===`ArrowDown`){L.current=(L.current+1)%t,F(L.current);return}if(e===`ArrowUp`){L.current=(L.current-1+t)%t,F(L.current);return}(e===`Enter`||e===`Tab`)&&Ue(L.current)}}})),(0,U.jsxs)(me,{ref:je,isMobile:K,className:`max-w-[640px] max-h-64`,style:o,children:[(0,U.jsx)(_e,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,U.jsxs)(`div`,{className:`py-1`,children:[X.map((e,t)=>{let n=e.id.startsWith(`file:`)||e.id.startsWith(`recent:`),r=n?te(e.title,{maxLength:60}):e.title,i=P===t,a=B[t]??!1,o=H[t]??2.6;return(0,U.jsxs)(`div`,{"data-mention-id":e.id,ref:e=>{Oe.current[t]=e},className:_(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,he(K,i),!K&&i&&`text-interactive-selection-foreground`),...He(t,()=>Ue(t)),children:[(0,U.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center`,children:e.agentName===void 0?(0,U.jsx)(A,{name:e.iconName,className:`size-3.5 text-current`}):(0,U.jsx)(k,{name:e.agentName,size:20})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,U.jsxs)(`span`,{ref:e=>{ke.current[t]=e},className:_(`relative block min-w-0 overflow-hidden`,n&&a&&i&&`file-mention-marquee-container`),style:i?{"--file-mention-marquee-width":`${z}px`,"--file-mention-marquee-duration":`${o}s`}:void 0,title:e.title,children:[(0,U.jsx)(`span`,{ref:e=>{Ae.current[t]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:e.title}),n&&a&&i?(0,U.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:G(e.title,q)}):(0,U.jsx)(`span`,{className:`block truncate`,children:G(r,q)})]}),e.trailingLabel?(0,U.jsx)(`span`,{className:_(`max-w-[40%] shrink-0 truncate text-muted-foreground`,K?`typography-micro`:`typography-meta`),children:e.trailingLabel}):null]}),e.subtitle?(0,U.jsx)(`div`,{className:_(`truncate text-muted-foreground`,K?`typography-micro`:`typography-meta`),children:G(e.subtitle,q)}):null]})]},e.id)}),ye&&Le.length===0?(0,U.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,U.jsx)(A,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!ye&&X.length===0&&(0,U.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:l(`chat.fileMentionAutocomplete.empty`)})]})}),!K&&(0,U.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:l(`chat.autocomplete.keyboardHint`)})]})}),q=new Set([`new`,`fork`,`compact`,`reload`,`undo`,`redo`,`model`,`btw`]),J=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&q.has(n))},Ne=(e,t)=>!e||t({name:e}),Pe=` `,Fe=(e,t)=>{let n=Math.max(0,Math.min(t,e.length)),r=n;for(;r>0&&!/\s/.test(e[r-1]);)--r;return r>=2&&e[r-1]===Pe&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},Y=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,Ie=_(Y,`bg-[color-mix(in_srgb,var(--primary-base)_12%,transparent)] text-[color-mix(in_srgb,var(--primary-base)_70%,transparent)] border-[color-mix(in_srgb,var(--primary-base)_24%,transparent)]`),Le=_(Y,`bg-[color-mix(in_srgb,var(--status-success)_12%,transparent)] text-[color-mix(in_srgb,var(--status-success)_70%,transparent)] border-[color-mix(in_srgb,var(--status-success)_24%,transparent)]`),X=_(Y,`bg-[color-mix(in_srgb,var(--status-info)_12%,transparent)] text-[color-mix(in_srgb,var(--status-info)_70%,transparent)] border-[color-mix(in_srgb,var(--status-info)_24%,transparent)]`),Re=_(Y,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),ze=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id&&e.description===t[n]?.description),Be=e=>{let t=!!e.sessionID;return{hasSession:t,canStartSessionCommand:t||e.hasNewDraft}},Ve=I.forwardRef(({searchQuery:e,onCommandSelect:t,onClose:n,directory:i,style:a,commandPolicy:o,commandContext:s,onRowsChange:c},l)=>{let{t:u}=ee(),f=d(e=>e.isMobile),p=w(e=>e.currentSessionId),m=w(e=>!!e.newSessionDraft?.open),h=w(I.useCallback(e=>p?e.getDirectoryForSession(p):void 0,[p])),g=ae(p??``,h??void 0),te=I.useMemo(()=>s??{sessionID:p??null,hasMessages:g.length>0,hasNewDraft:m},[s,p,g.length,m]),{hasSession:v,canStartSessionCommand:y}=I.useMemo(()=>Be(te),[te]),b=te.hasMessages,[x,S]=I.useState([]),[ne,C]=I.useState(!1),ie=re({directory:i}),oe=I.useMemo(()=>ie.data??[],[ie.data]),T=ie.isFetching,[E,D]=I.useState(0),se=I.useRef(0),O=I.useRef(!1),ce=I.useRef([]),le=I.useRef(null),ue=I.useRef(!1),k=I.useRef(null),j=I.useRef(!1),M=I.useRef(null);I.useEffect(()=>{let e=e=>{let t=e.target;!t||!le.current||le.current.contains(t)||n()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[n]),I.useEffect(()=>{(async()=>{C(T);try{let t=oe.flatMap((e,t)=>e.source===`skill`?[]:[{id:`opencode:${e.scope??`global`}:${e.name}:${e.agent??``}:${e.model??``}:${t}`,name:e.name,source:`opencode`,description:e.description,agent:e.agent??void 0,model:e.model??void 0,isBuiltIn:e.isBuiltIn,scope:e.scope,reference:e.reference}]),n=[{id:`yuri:new`,name:`new`,source:`yuri`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},...v&&!b?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],...v?[{id:`yuri:btw`,name:`btw`,source:`yuri`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`yuri:undo`,name:`undo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`yuri:redo`,name:`redo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`yuri:fork`,name:`fork`,source:`yuri`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`yuri:timeline`,name:`timeline`,source:`yuri`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`yuri:model`,name:`model`,source:`yuri`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`yuri:compact`,name:`compact`,source:`yuri`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...r()?[{id:`yuri:reload`,name:`reload`,source:`yuri`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],...v?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...y?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...y?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...y?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...y?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...y?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...y?[{id:`yuri:explore`,name:`explore`,source:`yuri`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isYuri:!0}]:[],...t],i=!b,a=ye(n.filter(e=>(i||e.name!==`init`)&&(o?.(e)??!0)),e);S(e=>ze(e,a)?e:a)}catch{let t=!b,n=ye([{id:`yuri:new`,name:`new`,source:`yuri`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},...v&&!b?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],...v?[{id:`yuri:btw`,name:`btw`,source:`yuri`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`yuri:undo`,name:`undo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`yuri:redo`,name:`redo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`yuri:fork`,name:`fork`,source:`yuri`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`yuri:timeline`,name:`timeline`,source:`yuri`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`yuri:model`,name:`model`,source:`yuri`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`yuri:compact`,name:`compact`,source:`yuri`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...r()?[{id:`yuri:reload`,name:`reload`,source:`yuri`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],...v?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...y?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...y?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...y?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...y?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...y?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...y?[{id:`yuri:explore`,name:`explore`,source:`yuri`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isYuri:!0}]:[]].filter(e=>(t||e.name!==`init`)&&(o?.(e)??!0)),e);S(e=>ze(e,n)?e:n)}finally{C(!1)}})()},[e,b,v,y,oe,T,u,o]),I.useEffect(()=>{D(0)},[x]),I.useEffect(()=>{se.current=E},[E]),I.useEffect(()=>{ce.current[E]?.scrollIntoView({block:`nearest`})},[E]),I.useEffect(()=>{xe(c,M,{rows:pe(x,{skill:u(`chat.commandAutocomplete.badge.skill`),command:u(`chat.commandAutocomplete.badge.command`),system:u(`chat.commandAutocomplete.badge.system`)}),highlightedIndex:E})},[x,c,E,u]);let de=I.useRef(c);de.current=c,I.useEffect(()=>()=>{Se(de.current,M)},[]),I.useImperativeHandle(l,()=>({acceptIndex:(e,n=!0)=>{let r=x[e];r&&t(r,J(r,n))},handleKeyDown:e=>{let r=x.length;if(e===`Escape`){n();return}if(r!==0){if(e===`ArrowDown`){O.current=!0,D(e=>(e+1)%r);return}if(e===`ArrowUp`){O.current=!0,D(e=>(e-1+r)%r);return}if(e===`Enter`||e===`Tab`){let n=(se.current%r+r)%r,i=x[n];i&&t(i,J(i,e===`Enter`))}}}}),[x,n,t]);let ge=e=>{let t=fe(e);switch(e.name){case`new`:return(0,U.jsx)(A,{name:t,className:`h-3.5 w-3.5`});case`init`:return(0,U.jsx)(A,{name:t,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,U.jsx)(A,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,U.jsx)(A,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:case`reload`:return(0,U.jsx)(A,{name:t,className:`h-3.5 w-3.5`});case`compact`:return(0,U.jsx)(A,{name:t,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,U.jsx)(A,{name:t,className:`h-3.5 w-3.5`});case`review`:return(0,U.jsx)(A,{name:t,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,U.jsx)(A,{name:t,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,U.jsx)(A,{name:t,className:`h-3.5 w-3.5 text-yellow-500`}):(0,U.jsx)(A,{name:t,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,U.jsxs)(me,{ref:le,isMobile:f,className:`max-w-[450px] max-h-64`,style:a,children:[(0,U.jsx)(_e,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 py-1.5`,children:ne?(0,U.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,U.jsx)(A,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,U.jsxs)(`div`,{children:[x.map((n,r)=>{let i=n.isBuiltIn,a=n.isYuri;return(0,U.jsxs)(`div`,{ref:e=>{ce.current[r]=e},className:_(`flex gap-2 px-2 py-2 cursor-pointer rounded-lg`,f?`items-center`:`items-start`,he(f,r===E),!f&&r===E&&`bg-interactive-selection/35`),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(k.current={x:e.clientX,y:e.clientY},j.current=!1)},onPointerMove:e=>{if(e.pointerType!==`touch`||!k.current)return;let t=e.clientX-k.current.x,n=e.clientY-k.current.y;Math.hypot(t,n)>6&&(j.current=!0)},onPointerUp:e=>{if(e.pointerType!==`touch`)return;let r=j.current;k.current=null,j.current=!1,!r&&(e.preventDefault(),e.stopPropagation(),ue.current=!0,t(n,J(n,f)))},onPointerCancel:()=>{k.current=null,j.current=!1},onClick:()=>{if(ue.current){ue.current=!1;return}t(n,J(n,f))},onMouseMove:()=>{O.current=!1,D(r)},children:[(0,U.jsx)(`div`,{className:_(!f&&`mt-0.5`),children:ge(n)}),(0,U.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,G(n.name,e)]}),n.isSkill?(0,U.jsx)(`span`,{className:Ie,children:u(`chat.commandAutocomplete.badge.skill`)}):(0,U.jsx)(`span`,{className:Ie,children:u(`chat.commandAutocomplete.badge.command`)}),a?(0,U.jsx)(`span`,{className:Re,children:`Yuri`}):i?(0,U.jsx)(`span`,{className:Re,children:u(`chat.commandAutocomplete.badge.system`)}):n.scope?(0,U.jsx)(`span`,{className:n.scope===`project`?X:Le,children:n.scope}):null,n.agent&&(0,U.jsx)(`span`,{className:Re,children:n.agent})]}),n.description&&!f&&(0,U.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:G(n.description,e)})]})]},n.id)}),x.length===0&&(0,U.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.commandAutocomplete.empty`)})]})}),!f&&(0,U.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})});Ve.displayName=`CommandAutocomplete`;var He=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,Ue=1e4,We=6e4,Ge=5e3,Ke=3e4,qe=6e4,Je=25,Ye=40,Xe=2,Ze=15e3,Qe=500,$e=30,et=20971520,tt=new Map,nt=new Map,rt=new Map,it=new Map,at=new Map,ot=new Map,st=new WeakMap,ct=e=>{let t=st.get(e);return t||(t=new Set(e.files.map(e=>e.path)),st.set(e,t)),t},lt=(e,t)=>`${t}:${e}`,ut=e=>nt.get(e)??0,dt=e=>{let t=ut(e)+1;return nt.set(e,t),t},ft=e=>{let t=(rt.get(e)??0)+1;return rt.set(e,t),t},pt=e=>{let t=tt.get(e);if(t)return t;let n=new Set;return tt.set(e,n),n},Z=()=>({isGitRepo:null,status:null,branches:null,branchesTransportIdentity:null,log:null,identity:null,diffCache:new Map,indexRevision:0,lastRepoCheckAt:0,lastStatusFetch:0,lastStatusChange:0,lastLogFetch:0,lastBranchesFetch:0,lastIdentityFetch:0,logMaxCount:25,isLoadingStatus:!1,isLoadingLog:!1,isLoadingBranches:!1,isLoadingIdentity:!1}),mt=(e,t=$e,n=et)=>{let r=0;for(let t of e.values())r+=(t.original?.length??0)+(t.modified?.length??0);if(e.size<=t&&r<=n)return e;let i=Array.from(e.entries()).sort((e,t)=>e[1].fetchedAt-t[1].fetchedAt),a=new Map,o=0;for(let e=i.length-1;e>=0;e--){let[r,s]=i[e],c=(s.original?.length??0)+(s.modified?.length??0);if(a.size>=t)break;o+c>n&&a.size>0||(a.set(r,s),o+=c)}return a},ht=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,gt=e=>{let t=e?.trim()??``;return t===`?`?``:t},_t=(e,t)=>{let n=new Set,r=!1,i=!e;e&&(i=e.ahead!==t.ahead||e.behind!==t.behind||e.current!==t.current||e.tracking!==t.tracking||e.isClean!==t.isClean||t.upstreamComparison!==void 0&&ht(e.upstreamComparison,t.upstreamComparison)||t.diffStats!==void 0&&e.diffStats===void 0);let a=new Map;for(let t of e?.files??[])a.set(t.path,t);for(let e of t.files??[]){let t=a.get(e.path);if(!t){n.add(e.path),gt(e.index)&&(r=!0);continue}a.delete(e.path),(t.index!==e.index||t.working_dir!==e.working_dir)&&n.add(e.path),!r&>(t.index)!==gt(e.index)&&(r=!0)}for(let[e,t]of a)n.add(e),gt(t.index)&&(r=!0);let o=t.diffStats,s=e?.diffStats;if(o!==void 0&&o!==s){let e=s??{};for(let t in o){let r=o[t],i=e[t];(!i||i.insertions!==r.insertions||i.deletions!==r.deletions)&&n.add(t)}for(let t in e)t in o||n.add(t)}return{changed:i||n.size>0,changedPaths:n,indexChanged:r}},vt=e=>!e||e.trim().length===0,yt=e=>(e||``).trim()===`U`,bt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(yt(t)||yt(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},xt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(yt(t)||yt(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},St=e=>vt(e.index)&&vt(e.working_dir),Q=i()(o((e,t)=>({directories:new Map,activeDirectory:null,setActiveDirectory:n=>{let{activeDirectory:r,directories:i}=t();if(r!==n)if(r&&dt(r),n&&dt(n),n&&!i.has(n)){let t=new Map(i);t.set(n,Z()),e({activeDirectory:n,directories:t})}else e({activeDirectory:n})},getDirectoryState:e=>t().directories.get(e)??null,fetchStatus:async(n,r,i={})=>{let a=i.mode??`full`,o=lt(n,a),s=it.get(o)??(a===`light`?it.get(lt(n,`full`)):void 0);if(s)return s;let c=(async()=>{let{silent:a=!1}=i,{directories:o}=t(),s=o.get(n);if(s||=Z(),!a){let r=new Map(t().directories),i=r.get(n)??Z();r.set(n,{...i,isLoadingStatus:!0}),e({directories:r})}let c=!1;try{let a=Date.now(),o=s.isGitRepo!==!0||a-(s.lastRepoCheckAt||0)>We,l=s.isGitRepo===!0;if(o&&(l=await r.checkIsGitRepository(n)),!l){let r=new Map(t().directories),i=r.get(n)??s;return r.set(n,{...i,isGitRepo:!1,status:null,isLoadingStatus:!1,lastRepoCheckAt:a,lastStatusFetch:a}),e({directories:r}),!1}let u=await r.getGitStatus(n,i.mode?{mode:i.mode}:void 0),d=t().directories.get(n)??Z(),f=ot.get(n),p=f?.received===u&&f.stored===d.status?null:_t(d.status,u);if(p?.changed){c=!0;let r=new Map(t().directories),i=r.get(n)??Z(),{changedPaths:s,indexChanged:l}=p,d=new Map(i.diffCache);for(let e of s)d.delete(e);let f=s.size>0;f&&dt(n);let m={...u,diffStats:u.diffStats===void 0&&i.status?.diffStats!==void 0?i.status.diffStats:u.diffStats,upstreamComparison:u.upstreamComparison===void 0?i.status?.upstreamComparison:u.upstreamComparison};r.set(n,{...i,isGitRepo:!0,status:m,diffCache:d,indexRevision:l?i.indexRevision+1:i.indexRevision,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:f?Date.now():i.lastStatusChange}),e({directories:r}),ot.set(n,{received:u,stored:m})}else{ot.set(n,{received:u,stored:d.status});let r=new Map(t().directories),i=r.get(n)??Z();r.set(n,{...i,isGitRepo:!0,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:i.lastStatusChange}),e({directories:r})}}catch(e){console.error(`Failed to fetch git status:`,e)}finally{if(!a){let r=new Map(t().directories),i=r.get(n)??Z();r.set(n,{...i,isLoadingStatus:!1}),e({directories:r})}}return c})();it.set(o,c);try{return await c}finally{it.get(o)===c&&it.delete(o)}},moveStatusPathsOptimistically:(n,r,i)=>{let a=new Set(r.map(e=>e.trim()).filter(Boolean));if(a.size===0)return null;let{directories:o}=t(),s=o.get(n),c=s?.status??null;if(!s||!c)return c;let l=!1,u=[];for(let e of c.files){if(!a.has(e.path)){u.push(e);continue}let t=i===`stage`?bt(e):xt(e);t!==e&&(l=!0),St(t)?l=!0:u.push(t)}if(!l)return c;let d=new Map(o);return d.set(n,{...s,status:{...c,files:u,isClean:u.length===0},indexRevision:s.indexRevision+1,lastStatusChange:Date.now()}),e({directories:d}),c},restoreStatus:(n,r)=>{let{directories:i}=t(),a=i.get(n);if(!a)return;let o=new Map(i);o.set(n,{...a,status:r,indexRevision:a.indexRevision+1,lastStatusChange:Date.now()}),e({directories:o})},bumpIndexRevision:n=>{let{directories:r}=t(),i=r.get(n);if(!i)return;let a=new Map(r);a.set(n,{...i,indexRevision:i.indexRevision+1}),e({directories:a})},fetchBranches:async(r,i,a={})=>{let o=n(),s=ft(r);{let n=new Map(t().directories),i=n.get(r)??Z();n.set(r,{...i,isLoadingBranches:!0}),e({directories:n})}try{let c=a.force?await b(r,i,void 0,o):await C(r,i,void 0,o);if(s!==rt.get(r)||o!==n())return;let l=new Map(t().directories),u=l.get(r)??Z();l.set(r,{...u,branches:c,branchesTransportIdentity:o,isLoadingBranches:!1,lastBranchesFetch:Date.now()}),e({directories:l})}catch(i){if(He(i)||console.error(`Failed to fetch git branches:`,i),s!==rt.get(r)||o!==n())return;let a=new Map(t().directories),c=a.get(r)??Z();a.set(r,{...c,isLoadingBranches:!1}),e({directories:a})}},fetchLog:async(n,r,i)=>{let{directories:a}=t(),o=a.get(n),s=i??o?.logMaxCount??25;{let r=new Map(t().directories),i=r.get(n)??Z();r.set(n,{...i,isLoadingLog:!0}),e({directories:r})}try{let i=await r.getGitLog(n,{maxCount:s}),a=new Map(t().directories),o=a.get(n)??Z();a.set(n,{...o,log:i,isLoadingLog:!1,lastLogFetch:Date.now(),logMaxCount:s}),e({directories:a})}catch(r){console.error(`Failed to fetch git log:`,r);let i=new Map(t().directories),a=i.get(n)??Z();i.set(n,{...a,isLoadingLog:!1}),e({directories:i})}},fetchIdentity:async(n,r)=>{{let r=new Map(t().directories),i=r.get(n)??Z();r.set(n,{...i,isLoadingIdentity:!0}),e({directories:r})}try{let i=await r.getCurrentGitIdentity(n),a=new Map(t().directories),o=a.get(n)??Z();a.set(n,{...o,identity:i,isLoadingIdentity:!1,lastIdentityFetch:Date.now()}),e({directories:a})}catch(r){console.error(`Failed to fetch git identity:`,r);let i=new Map(t().directories),a=i.get(n)??Z();i.set(n,{...a,isLoadingIdentity:!1}),e({directories:i})}},fetchAll:async(n,r,i={})=>{let{directories:a}=t(),o=a.get(n);if(!o){o=Z();let t=new Map(a);t.set(n,o),e({directories:t})}let{force:s=!1,silentIfCached:c=!1}=i,l=Date.now();await t().fetchStatus(n,r,{silent:c&&!!o?.status});let u=t().directories.get(n);if(!u?.isGitRepo)return;await t().fetchBranches(n,r,{force:s});let d=l-(u.lastLogFetch||0);(s||d>Ue||!u.log)&&await t().fetchLog(n,r),await t().fetchIdentity(n,r)},getDiff:(e,n)=>t().directories.get(e)?.diffCache.get(n)??null,setDiff:(n,r,i)=>{let a=new Map(t().directories),o=a.get(n)??Z(),s=new Map(o.diffCache);s.set(r,{...i,fetchedAt:Date.now()});let c=mt(s);a.set(n,{...o,diffCache:c}),e({directories:a})},clearDiffCache:n=>{dt(n);let r=new Map(t().directories),i=r.get(n);i&&(r.set(n,{...i,diffCache:new Map}),e({directories:r}))},fetchAllDiffs:async(e,n)=>{let r=t().directories.get(e);if(!r?.status?.files||r.status.files.length===0)return;let i=r.status.files.map(e=>e.path).slice(0,Je);await t().prefetchDiffs(e,n,i,{maxFiles:Je})},prefetchDiffs:async(n,r,i,a={})=>{let o=t().directories.get(n);if(!o?.status?.files||o.status.files.length===0||i.length===0)return;let{maxFiles:s=Ye}=a,c=Math.min(Math.max(1,s),$e),l=ct(o.status),u=o.status.diffStats,d=pt(n),f=[],p=new Set;for(let e of i){if(p.size>=c)break;if(!e||p.has(e)||!l.has(e))continue;let t=u?.[e];t&&t.insertions+t.deletions>Qe||(p.add(e),!o.diffCache.has(e)&&(d.has(e)||f.push(e)))}let m=f;if(m.length===0)return;let h=ut(n);if(typeof document<`u`&&document.hidden)return;m.forEach(e=>d.add(e));let g=0,ee=[],_=()=>{let e=g;return g+=1,e<m.length?m[e]:null},te=async e=>{let t=r.getGitFileDiff(n,{path:e}),i=new Promise((e,t)=>{setTimeout(()=>t(Error(`Timed out after ${Ze}ms`)),Ze)}),a=await Promise.race([t,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},v=async()=>{for(;;){if(h!==ut(n))return;let e=_();if(!e)return;try{ee.push(await te(e))}catch{}finally{d.delete(e)}}},y=Math.min(Xe,m.length);if(await Promise.allSettled(Array.from({length:y},()=>v())),m.forEach(e=>d.delete(e)),h!==ut(n))return;let b=new Map(t().directories),x=b.get(n);if(!x)return;let S=new Map(x.diffCache),ne=Date.now();ee.forEach(e=>{!e.diff.isBinary&&e.diff.original===``&&e.diff.modified===``||S.set(e.path,{...e.diff,fetchedAt:ne})});let C=mt(S);b.set(n,{...x,diffCache:C}),e({directories:b})},setLogMaxCount:(n,r)=>{let i=new Map(t().directories),a=i.get(n)??Z();i.set(n,{...a,logMaxCount:r}),e({directories:i})},ensureStatus:async(e,n)=>{let r=t().directories.get(e),i=Date.now();r?.status&&i-r.lastStatusFetch<Ge||await t().fetchStatus(e,n,{silent:!!r?.status})},ensureAll:(e,n)=>{let r=at.get(e);if(r)return r;let i=(async()=>{let r=t().directories.get(e),i=Date.now();(!r?.status||r.status.diffStats===void 0||i-(r?.lastStatusFetch??0)>=Ge)&&await t().fetchStatus(e,n,{silent:!!r?.status});let a=t().directories.get(e);if(!a?.isGitRepo)return;let o=[];(!a.branches||i-a.lastBranchesFetch>=Ke)&&o.push(t().fetchBranches(e,n)),(!a.log||i-a.lastLogFetch>=Ue)&&o.push(t().fetchLog(e,n)),(!a.identity||i-a.lastIdentityFetch>=qe)&&o.push(t().fetchIdentity(e,n)),o.length>0&&await Promise.all(o)})();return at.set(e,i),i.finally(()=>{at.get(e)===i&&at.delete(e)}),i},refresh:async(e,n={})=>{let{activeDirectory:r}=t();r&&await t().fetchAll(r,e,n)}}),{name:`git-store`})),Ct=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status??null:null,t[0]=e,t[1]=n),Q(n)},wt=e=>{let r=(0,H.c)(3),i=I.useSyncExternalStore(t,n,n),a;return r[0]!==e||r[1]!==i?(a=t=>{if(!e)return null;let n=t.directories.get(e);return n?.branchesTransportIdentity===i?n.branches:null},r[0]=e,r[1]=i,r[2]=a):a=r[2],Q(a)},Tt=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.log??null:null,t[0]=e,t[1]=n),Q(n)},Et=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isGitRepo??null:null,t[0]=e,t[1]=n),Q(n)},Dt=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status?.current?.trim()??null:null,t[0]=e,t[1]=n),Q(n)},Ot=e=>{let t=(0,H.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=I.useRef(n),i;return t[1]===e?i=t[2]:(i=t=>{let n=r.current,i=n.size===e.length;if(i)for(let r of e){let e=t.directories.get(r),a=n.get(r);if(!a||(e?.isGitRepo??null)!==a.isGitRepo||(e?.status?.current??null)!==a.branch){i=!1;break}}if(i)return n;let a=new Map;for(let n of e){let e=t.directories.get(n);a.set(n,{isGitRepo:e?.isGitRepo??null,branch:e?.status?.current??null})}return r.current=a,a},t[1]=e,t[2]=i),Q(i)},kt=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingStatus??!1:!1,t[0]=e,t[1]=n),Q(n)},At=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingLog??!1:!1,t[0]=e,t[1]=n),Q(n)},jt=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingBranches??!1:!1,t[0]=e,t[1]=n),Q(n)},Mt=e=>{let t=String(e||``).trim().replace(/^remotes\//,``);if(!t)return null;let n=t.indexOf(`/`);return n<=0||n>=t.length-1?null:{remote:t.slice(0,n),branch:t.slice(n+1)}},$=e=>String(e||``).trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/^remotes\//,``),Nt=e=>e.branchName?$(e.branchName):e.mode===`existing`?$(e.existingBranch||e.preferredName||``):$(e.preferredName||``),Pt=async e=>{let t=await ve(e);try{let n=Mt((await j(e)).branches?.[t]?.tracking||null);if(n?.remote)return n.remote}catch{}try{let t=Mt((await M(e)).tracking);if(t?.remote)return t.remote}catch{}return null},Ft=async(e,t)=>{let n=await Pt(e),r=$(t);return!n||!r?null:{setUpstream:!0,upstreamRemote:n,upstreamBranch:r}},It=async(e,t,n)=>{let r=Nt(t),i=n?.resolvedRootTrackingRemote,a=i===void 0?await Ft(e,r):i&&$(r)?{setUpstream:!0,upstreamRemote:i,upstreamBranch:$(r)}:null;return a?{...t,setUpstream:t.setUpstream??a.setUpstream,upstreamRemote:t.upstreamRemote||a.upstreamRemote,upstreamBranch:t.upstreamBranch||a.upstreamBranch}:t},Lt=async(e,t,n)=>{let r=await It(e.path,t,n);return N(e,r)},Rt=`yuri:lastWorktreeSourceBranch`,zt=({mode:e,sourceBranch:t,linkedPr:n,selectedBranch:r})=>e===`existing-branch`?r||null:n?null:t||null,Bt=({branches:e,savedSourceBranch:t,rootBranch:n})=>t&&e.includes(t)&&t?{sourceBranch:t,shouldClearSavedSourceBranch:!1}:{sourceBranch:n&&e.includes(n)?n:e.includes(`main`)?`main`:e.includes(`master`)?`master`:e[0]??``,shouldClearSavedSourceBranch:!!t},Vt=(e,t,n)=>{if(!e)return e;let r=t.length>0&&!/\s$/.test(t)&&!/^\s/.test(e)&&!/[([{]$/.test(t),i=n.length>0&&!/\s$/.test(e)&&!/^\s/.test(n)&&!/^[\])}.,;:!?]/.test(n);return`${r?` `:``}${e}${i?` `:``}`},Ht=(e,t,n)=>{let r=Vt(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},Ut=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=Ht(r,i,a),s=Math.max(0,o.indexOf(r)),c=i.length+s;return{text:`${i}${o}${a}`,caret:i.length+o.length,start:c,end:c+r.length}},Wt=(e,t)=>{let n=e=>`${e.kind}:${e.value}:${e.range.start}:${e.range.end}`;return new Set(e.map(n)).has(n(t))||e.some(e=>e.range.start<t.range.end&&t.range.start<e.range.end)?[...e]:[...e,t]},Gt=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{Ne as C,we as D,Te as E,F as O,Fe as S,Ee as T,Ot as _,Rt as a,Et as b,Lt as c,Dt as d,wt as f,Tt as g,kt as h,Ht as i,Pt as l,At as m,Wt as n,Bt as o,jt as p,Ut as r,zt as s,Gt as t,It as u,Ct as v,K as w,Ve as x,Q as y};
|