@yuriai/web 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AssistantView-aO1htuC0.js → AssistantView-D4pGrXQ2.js} +3 -3
- package/dist/assets/{DiagramView-DbtzXUOC.js → DiagramView-ClqTTADy.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-BPp8BN0a.js → ImageLoadingPlaceholder-CGHGcrEo.js} +1 -1
- package/dist/assets/{LoadingImage-DvtPqFRw.js → LoadingImage-BG9q4Tm_.js} +1 -1
- package/dist/assets/{MarkdownRenderer-BlDd-zTg.js → MarkdownRenderer-CnHu4XPA.js} +2 -2
- package/dist/assets/{MarkdownRendererImpl-O4nzQKpI.js → MarkdownRendererImpl-BsnfVIC9.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-B8USZU8R.js → MarkstreamRendererImpl-Cmzb7xFE.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-D8f__4GE.js → MobileDetailNavigation-OWYq5ZOS.js} +1 -1
- package/dist/assets/{MobileShareBridge-z70r79hc.js → MobileShareBridge-DukiyCpU.js} +1 -1
- package/dist/assets/MobileTabPageHeader-Cp_gk7cy.js +2 -0
- package/dist/assets/{MultiRunWindow-F9XbZPCH.js → MultiRunWindow-kOpD2Th8.js} +1 -1
- package/dist/assets/{SettingsView-B-AWwURS.js → SettingsView-CNxbrxjd.js} +12 -12
- package/dist/assets/{SettingsWindow-UFwLu7_8.js → SettingsWindow-B_Fgbas9.js} +1 -1
- package/dist/assets/{TerminalView-Cj9xXSXJ.js → TerminalView-Cz3XX-pa.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DIr7gmhc.js → ToolOutputDialog-Ck3maV4e.js} +1 -1
- package/dist/assets/{appThemeRegistry-BttGHPXa.js → appThemeRegistry-8PNdkIWO.js} +1 -1
- package/dist/assets/{capgoAdapter-KNLHDj7G.js → capgoAdapter-CnsewE-n.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-BFSbKBHy.js → fileMentionTouchSelection-CRG8r4mq.js} +1 -1
- package/dist/assets/{gitApi-CT2gHl-y.js → gitApi-2OimpBnB.js} +1 -1
- package/dist/assets/{image-loading-CVq5GLEY.js → image-loading-23c-W-bq.js} +1 -1
- package/dist/assets/{insertionBoundaries-D3e6uOkH.js → insertionBoundaries-DEY-uxCq.js} +1 -1
- package/dist/assets/{main-BujKFYwj.js → main-D_ttGvxI.js} +22 -22
- package/dist/assets/{main-BXcvTyKT.js → main-y7Aekp2v.js} +2 -2
- package/dist/assets/{mcpQueries-DpgzW70K.js → mcpQueries-Qx_eVfxx.js} +1 -1
- package/dist/assets/{miniChat-5qOrHHEA.js → miniChat-DcATvJc9.js} +2 -2
- package/dist/assets/{mobile-BefkgomZ.js → mobile-CfPAWSXr.js} +2 -2
- package/dist/assets/{mobileBackNavigation-DOPWc25L.js → mobileBackNavigation-B_aT7hZA.js} +1 -1
- package/dist/assets/{multirun-Dzh_Fsid.js → multirun-B2GaFlNf.js} +1 -1
- package/dist/assets/native-config-Cu2rtzKa.js +1 -0
- package/dist/assets/{projectMeta-O4wg5jiy.js → projectMeta-CfvCStpj.js} +1 -1
- package/dist/assets/renderElectronMiniChatApp-D0v1rp6C.js +2 -0
- package/dist/assets/{renderMobileApp-D4M59yMR.js → renderMobileApp-1NEaEWn6.js} +6 -6
- package/dist/assets/runtimeConfig-CE0t2CEh.js +2 -0
- package/dist/assets/{runtimeEndpointReset-DCy2sHAD.js → runtimeEndpointReset-BPBRlu2g.js} +5 -5
- package/dist/assets/{sessionChangeSummary-D3G985mf.js → sessionChangeSummary-C8fjiAIl.js} +1 -1
- package/dist/assets/{sessionLookup-BhaDgtSq.js → sessionLookup-CxeDvyRN.js} +1 -1
- package/dist/assets/{speechSettingsQueries-C3wBvjjw.js → speechSettingsQueries-L-IonKwV.js} +1 -1
- package/dist/assets/src-CmermOKP.css +2 -0
- package/dist/assets/types-0GGhodUf.js +2 -0
- package/dist/assets/{useAppFontEffects-Dp_Rk9nw.js → useAppFontEffects-BzvaFRBa.js} +6 -6
- package/dist/assets/{useDesktopWindowControlsLayout-Jt77zqdp.js → useDesktopWindowControlsLayout-B7YLipUA.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-aQIIxV4x.js → useEffectiveDirectory-BkXDzQaJ.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-CO6CAp4i.js → useMobileNavigationStore-CjhF9j5V.js} +3 -3
- package/dist/assets/{useWorkerHighlightedLines-DDXiS_7t.js → useWorkerHighlightedLines-C-BpvG5l.js} +1 -1
- package/dist/index.html +13 -12
- package/dist/mini-chat.html +7 -6
- package/dist/mobile.html +9 -8
- package/package.json +1 -1
- package/server/lib/notifications/APNS.md +13 -0
- package/server/lib/notifications/DOCUMENTATION.md +4 -0
- package/server/lib/notifications/apns-runtime.js +45 -24
- package/server/lib/notifications/apns-runtime.test.js +57 -1
- package/server/lib/notifications/routes.js +6 -2
- package/server/lib/opencode/DOCUMENTATION.md +2 -0
- package/server/lib/opencode/pwa-manifest-routes.js +2 -2
- package/server/lib/opencode/settings-runtime.js +1 -1
- package/server/lib/opencode/settings-runtime.test.js +15 -0
- package/server/lib/opencode/static-routes-runtime.js +6 -6
- package/dist/assets/MobileTabPageHeader-yWc9DWuc.js +0 -2
- package/dist/assets/renderElectronMiniChatApp-C5KLkJSM.js +0 -2
- package/dist/assets/runtimeConfig-BDh3gBH4.js +0 -2
- package/dist/assets/src-BEVRKYT8.css +0 -2
- package/dist/assets/types-BuiqMmh_.js +0 -1
|
@@ -47,6 +47,7 @@ This module provides OpenCode server integration utilities for the web server ru
|
|
|
47
47
|
- `packages/web/server/lib/opencode/shutdown-runtime.js`: graceful shutdown orchestration runtime for watcher/session/terminal/process/server teardown.
|
|
48
48
|
- `packages/web/server/lib/opencode/server-startup-runtime.js`: server listen/startup flow and process/signal handler orchestration runtime.
|
|
49
49
|
- `packages/web/server/lib/opencode/static-routes-runtime.js`: static asset/SPA fallback route registration and manifest route wiring. The SPA fallback sends `index.html` relative to `root`, so deep links keep working when the install lives under a dot directory.
|
|
50
|
+
- The API-only dark fallback and both server/client PWA manifest defaults use the Cursor surface (`#1a1a1a`) and primary (`#4c9df3`).
|
|
50
51
|
- `packages/web/server/lib/opencode/feature-routes-runtime.js`: feature route composition runtime for dynamic import-backed config/skill/provider route registration.
|
|
51
52
|
- `packages/web/server/lib/conversations/`: combined create-session-and-prompt orchestration (Yuri-owned, registered before generic proxy).
|
|
52
53
|
- `packages/web/server/lib/browser-provider/`: host for an installed extension that declares `browser`. Lists reachable providers, sends one agent browser action to the selected provider, and refuses when none is selected. Does not drive the in-app browser pane. See `browser-provider/DOCUMENTATION.md`.
|
|
@@ -61,6 +62,7 @@ This module provides OpenCode server integration utilities for the web server ru
|
|
|
61
62
|
- `packages/web/server/lib/opencode/project-icon-routes.js`: project icon upload/read/discovery route registration and icon storage orchestration.
|
|
62
63
|
- `packages/web/server/lib/opencode/skill-routes.js`: route registration for skill config CRUD, supporting files, and skills catalog scan/install flows.
|
|
63
64
|
- `packages/web/server/lib/opencode/settings-runtime.js`: Settings persistence runtime (disk IO, migrations, normalization, project validation, and persisted update serialization).
|
|
65
|
+
- Missing theme preferences use `carbonfox-light` / `cursor-dark`, matching the shared UI defaults. Existing per-variant IDs and legacy explicitly selected theme IDs remain authoritative; changing the default does not rewrite a user's saved theme.
|
|
64
66
|
- Project registry order and `projectSortOrder` are shared Host authority. After a successful changed write, `onProjectOrderChanged` emits `yuri:project-order-changed` on the existing Yuri SSE channel. Clients GET settings on initial mount, tip, and reconnect. Unchanged and failed writes emit no tip; older settings without a sort mode use `manual`.
|
|
65
67
|
- `packages/web/server/lib/opencode/settings-helpers.js`: Settings payload sanitization/format helpers runtime for response shaping and persisted merge prep.
|
|
66
68
|
- `packages/web/server/lib/opencode/settings-normalization-runtime.js`: path/settings normalization and sanitization helpers runtime used by settings/routes/config wiring.
|
|
@@ -223,8 +223,8 @@ export const registerPwaManifestRoute = (app, dependencies) => {
|
|
|
223
223
|
scope: '/',
|
|
224
224
|
display: 'standalone',
|
|
225
225
|
display_override: ['window-controls-overlay'],
|
|
226
|
-
background_color: '#
|
|
227
|
-
theme_color: '#
|
|
226
|
+
background_color: '#1a1a1a',
|
|
227
|
+
theme_color: '#4c9df3',
|
|
228
228
|
...(manifestOrientation ? { orientation: manifestOrientation } : {}),
|
|
229
229
|
icons: [
|
|
230
230
|
{ src: '/pwa-192.png', sizes: '192x192', type: 'image/png', purpose: 'any' },
|
|
@@ -668,7 +668,7 @@ export const createSettingsRuntime = (deps) => {
|
|
|
668
668
|
}
|
|
669
669
|
|
|
670
670
|
const defaultLight = 'carbonfox-light';
|
|
671
|
-
const defaultDark = '
|
|
671
|
+
const defaultDark = 'cursor-dark';
|
|
672
672
|
|
|
673
673
|
let nextLightThemeId = hasLight ? settings.lightThemeId : undefined;
|
|
674
674
|
let nextDarkThemeId = hasDark ? settings.darkThemeId : undefined;
|
|
@@ -36,6 +36,21 @@ const createRuntime = async (overrides = {}) => {
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
describe('settings runtime', () => {
|
|
39
|
+
it.each([
|
|
40
|
+
[{}, 'cursor-dark'],
|
|
41
|
+
[{ darkThemeId: 'vitesse-dark-dark' }, 'vitesse-dark-dark'],
|
|
42
|
+
[{ themeId: 'nord-dark', themeVariant: 'dark' }, 'nord-dark'],
|
|
43
|
+
])('fills missing theme variants without replacing a saved selection: %j', async (stored, expectedDark) => {
|
|
44
|
+
const { runtime, settingsFilePath, cleanup } = await createRuntime();
|
|
45
|
+
try {
|
|
46
|
+
await fsPromises.writeFile(settingsFilePath, JSON.stringify(stored));
|
|
47
|
+
const settings = await runtime.readSettingsFromDiskMigrated();
|
|
48
|
+
expect(settings.darkThemeId).toBe(expectedDark);
|
|
49
|
+
expect(settings.lightThemeId).toBe('carbonfox-light');
|
|
50
|
+
expect((await runtime.readSettingsFromDiskMigrated()).darkThemeId).toBe(expectedDark);
|
|
51
|
+
} finally { await cleanup(); }
|
|
52
|
+
});
|
|
53
|
+
|
|
39
54
|
it('notifies other clients only after project order commits and never on failed writes', async () => {
|
|
40
55
|
let tips = 0;
|
|
41
56
|
let fail = false;
|
|
@@ -75,12 +75,12 @@ export const createStaticRoutesRuntime = (dependencies) => {
|
|
|
75
75
|
<style>
|
|
76
76
|
:root {
|
|
77
77
|
color-scheme: dark;
|
|
78
|
-
--surface-background: #
|
|
79
|
-
--surface-elevated: #
|
|
80
|
-
--surface-foreground: #
|
|
81
|
-
--surface-muted-foreground: #
|
|
82
|
-
--interactive-border:
|
|
83
|
-
--primary-base: #
|
|
78
|
+
--surface-background: #1a1a1a;
|
|
79
|
+
--surface-elevated: #141414;
|
|
80
|
+
--surface-foreground: #cccccc;
|
|
81
|
+
--surface-muted-foreground: #848484;
|
|
82
|
+
--interactive-border: #8484841f;
|
|
83
|
+
--primary-base: #4c9df3;
|
|
84
84
|
}
|
|
85
85
|
@media (prefers-color-scheme: light) {
|
|
86
86
|
:root {
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-capacitor-app-B5H_XtmE.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,o as r}from"./runtime-switch-CAZiOV2G.js";import{a as i,o as a,r as o,s,t as c,u as l}from"./queryRuntime-DKGLQtb9.js";import{$t as u,Bt as d,an as f,d as p,en as m,et as h,gn as g,i as _,in as v,on as y,rn as b,tn as x,tt as S,zt as C}from"./persistence-Dzooc9Xg.js";import{a as w,i as T,r as E}from"./vendor-zustand-o69pgTEK.js";import{it as D,nt as O,rt as k}from"./vendor-base-ui-CdzJ6My_.js";import{Ct as A,Nt as j,Vt as M,n as N,t as P}from"./platform-7bX6qtBV.js";import{b as F,n as I}from"./useUIStore-NMQx_cnG.js";import{n as L}from"./vendor-react-BP2cRVqX.js";import{o as R}from"./vendor-tanstack-react-query-CdqCAt40.js";import{o as z}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{t as ee}from"./types-BuiqMmh_.js";import{$ as te,A as ne,B,G as re,H as V,J as ie,L as ae,P as oe,T as se,U as ce,W as le,X as ue,Y as de,a as fe,at as H,dt as pe,f as me,ft as he,g as ge,l as _e,pt as ve,st as ye,z as U}from"./vendor-codemirror-autocomplete-7c2L_4dM.js";import{c as be,o as W,r as xe}from"./vendor-codemirror-lang-angular-DXOgWEVj.js";import{n as Se,r as Ce}from"./vendor-codemirror-lang-json-mLulNbwB.js";import{n as we}from"./vendor-codemirror-lang-markdown-CV1IO6Qs.js";import{n as Te}from"./vendor-codemirror-lang-python-YM2WVLHF.js";import{O as Ee}from"./vendor-codemirror-legacy-modes-DwltVFbT.js";import{n as De}from"./vendor-reactuses-core-BpfIZ1tg.js";import{a as Oe,d as ke,f as G,p as Ae,r as K,t as q}from"./button-C3292Ee6.js";import{Pr as je,Rr as J,bi as Me,d as Ne,er as Pe,fo as Fe,hi as Ie,ir as Le,jr as Re,nr as ze,or as Be,rr as Ve,so as He,sr as Ue,vn as We,wr as Ge}from"./useMobileNavigationStore-CO6CAp4i.js";import{n as Ke}from"./useThemeSystem-8jhE4Zyk.js";import{n as Y}from"./Icon-jsQQXouE.js";import{a as qe,n as Je,o as Ye,r as Xe,t as Ze}from"./dialog-DrgcVFLG.js";import{L as Qe,_ as $e,b as et,c as tt,n as nt,s as rt,u as it}from"./gitApi-CT2gHl-y.js";import{A as at,_ as ot,a as st,b as ct,c as lt,h as ut,m as dt,n as ft,r as pt,t as mt,x as ht}from"./projectMeta-O4wg5jiy.js";import{t as gt}from"./input-DaOOTCQd.js";import{i as _t,n as vt,t as yt}from"./tooltip-DGUZtHif.js";import{$t as bt,F as xt,G as St,Gt as Ct,J as wt,Jt as Tt,Kt as Et,M as Dt,P as Ot,U as kt,W as At,Xt as jt,Yt as Mt,a as Nt,in as Pt,it as Ft,k as It,q as Lt,qt as Rt,rt as zt,ut as Bt,v as Vt}from"./speechSettingsQueries-C3wBvjjw.js";import{i as Ht,n as Ut}from"./OverlayScrollbar-C4VUlRzo.js";import{n as Wt,t as Gt}from"./textarea-BcA4uouw.js";import{n as Kt}from"./MarkdownRenderer-BlDd-zTg.js";import{a as qt}from"./url-Be8VCT8M.js";import{r as Jt}from"./markdown-worker-CkO3sT4Y.js";import{i as Yt,n as Xt,o as Zt}from"./mcpQueries-DpgzW70K.js";import{n as Qt,r as $t,t as en}from"./collapsible-B0yvtXQR.js";import{a as tn,d as nn,o as rn,s as an}from"./vendor-codemirror-commands-B8KrBQ9B.js";import{a as on,c as sn,i as cn,o as ln,r as un,s as dn}from"./vendor-codemirror-search-ZqtrPLjU.js";import{n as fn,t as pn}from"./vendor-replit-codemirror-vim-DDj0dSVY.js";import{t as mn}from"./vendor-codemirror-language-data-Ctd4WxgW.js";import{i as hn,n as gn,r as _n,t as vn}from"./projectActions-BX0cjZoq.js";var yn=[{id:`claude`,name:`Claude`},{id:`codex`,name:`Codex`},{id:`cursor`,name:`Cursor`},{id:`github-copilot`,name:`GitHub Copilot`},{id:`google`,name:`Google`},{id:`kimi-for-coding`,name:`Kimi for Coding`},{id:`nano-gpt`,name:`NanoGPT`},{id:`openrouter`,name:`OpenRouter`},{id:`zai-coding-plan`,name:`z.ai`},{id:`zhipuai-coding-plan`,name:`Zhipu AI Coding Plan`},{id:`minimax-cn-coding-plan`,name:`MiniMax Coding Plan (minimaxi.com)`},{id:`minimax-coding-plan`,name:`MiniMax Coding Plan (minimax.io)`},{id:`ollama-cloud`,name:`Ollama Cloud`},{id:`wafer`,name:`Wafer.ai`},{id:`opencode-go`,name:`OpenCode Go`},{id:`xai`,name:`Grok`}],bn=e=>[...yn,...e.filter(e=>e.source===`magpie`).map(e=>({id:e.providerId,name:e.providerName}))],X=L(),Z=k();function xn(e){let t=(0,X.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`path`,{d:`M15.688 2.343a2.588 2.588 0 00-3.61 0l-9.626 9.44a.863.863 0 01-1.203 0 .823.823 0 010-1.18l9.626-9.44a4.313 4.313 0 016.016 0 4.116 4.116 0 011.204 3.54 4.3 4.3 0 013.609 1.18l.05.05a4.115 4.115 0 010 5.9l-8.706 8.537a.274.274 0 000 .393l1.788 1.754a.823.823 0 010 1.18.863.863 0 01-1.203 0l-1.788-1.753a1.92 1.92 0 010-2.754l8.706-8.538a2.47 2.47 0 000-3.54l-.05-.049a2.588 2.588 0 00-3.607-.003l-7.172 7.034-.002.002-.098.097a.863.863 0 01-1.204 0 .823.823 0 010-1.18l7.273-7.133a2.47 2.47 0 00-.003-3.537z`}),r=(0,Z.jsx)(`path`,{d:`M14.485 4.703a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a4.115 4.115 0 000 5.9 4.314 4.314 0 006.016 0l7.12-6.982a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a2.588 2.588 0 01-3.61 0 2.47 2.47 0 010-3.54l7.12-6.982z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,Z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,fill:`currentColor`,stroke:`currentColor`,strokeWidth:`0.5`,fillRule:`evenodd`,viewBox:`-0.5 -0.5 25 25`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}var Sn={},Cn=(e,t=n())=>JSON.stringify([t,Xt(e)]),wn=(e,t,n)=>{if(!e[t]?.[n])return e;let r={...e[t]};return delete r[n],{...e,[t]:r}},Tn=e=>{let t=Xt(e);return t?j.getScopedApiClient(t):j.getApiClient()},En=e=>e?{location:{directory:e}}:void 0,Dn=e=>Xt(e===void 0?A.getState().currentDirectory:e),On=w()(E((e,t)=>({diagnosticsByDirectory:{},getDiagnosticForDirectory:e=>{let n=Cn(Dn(e));return t().diagnosticsByDirectory[n]??Sn},clearDiagnostic:(t,n,r)=>{let i=Cn(Dn(n),r);e(e=>({diagnosticsByDirectory:wn(e.diagnosticsByDirectory,i,t)}))},connect:async(t,r)=>{let a=Dn(r),o=n(),s=Cn(a,o),c=Tn(a);try{await c.mcp.connect({server:t,...En(a)})}catch(n){let r=n instanceof Error?n.message:`Connection failed`;throw e(e=>({diagnosticsByDirectory:{...e.diagnosticsByDirectory,[s]:{...e.diagnosticsByDirectory[s]??{},[t]:{status:`failed`,error:r}}}})),n}await Zt(i,a,o),e(e=>({diagnosticsByDirectory:wn(e.diagnosticsByDirectory,s,t)}))},disconnect:async(t,r)=>{let a=Dn(r),o=n(),s=Cn(a,o);await Tn(a).mcp.disconnect({server:t,...En(a)}),await Zt(i,a,o),e(e=>({diagnosticsByDirectory:wn(e.diagnosticsByDirectory,s,t)}))},startAuth:async(e,t)=>{throw M(`mcp.auth`)},completeAuth:async(e,t,n)=>{throw M(`mcp.auth`)},clearAuth:async(e,t)=>{throw M(`mcp.auth`)},testConnection:async(t,r)=>{let a=Dn(r),o=n(),s=Cn(a,o),c=Tn(a),l=Yt(i,a,o)[t]?.status===`connected`,u,d;try{await c.mcp.connect({server:t,...En(a)})}catch(n){u=n instanceof Error?n.message:`Connection failed`,e(e=>({diagnosticsByDirectory:{...e.diagnosticsByDirectory,[s]:{...e.diagnosticsByDirectory[s]??{},[t]:{status:`failed`,error:u??`Connection failed`}}}}))}let f=(await Zt(i,a,o))[t],p=f;if(!l&&f?.status===`connected`){try{await c.mcp.disconnect({server:t,...En(a)})}catch(e){d=`Connection test succeeded, but cleanup disconnect failed: ${e instanceof Error?e.message:`Disconnect failed`}`}await Zt(i,a,o)}return u||e(e=>({diagnosticsByDirectory:wn(e.diagnosticsByDirectory,s,t)})),{status:p??Yt(i,a,o)[t],error:u,warning:d}}}))),Q=e(D(),1),kn=e=>typeof e==`string`&&e.trim().length>0?e.trim():null,An=()=>kn(`0.1.2`),jn=(e,t)=>kn(t)||kn(e),Mn=(e,t)=>{let n=kn(e);return n?typeof t!=`number`||!Number.isFinite(t)?n:`${n} (${t})`:null},Nn=async()=>{let e=An();if(!N())return e;try{let{App:t}=await z(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2]));return jn((await t.getInfo()).version,e)}catch{return e}},Pn=async()=>{if(!N())return null;try{let{App:e}=await z(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2])),t=await e.getInfo(),n=typeof t.build==`string`?t.build.trim():``;if(n.length===0)return null;let r=Number.parseInt(n,10);return Number.isFinite(r)?r:null}catch{return null}},Fn=`https://yuri-updates.xiaobe.top/v1/update/check`,In=`https://yuri-origin.xiaobe.top/v1/update/check`,Ln=`https://github.com/yee94/yuri/releases/latest`,Rn=`https://github.com/yee94/yuri/releases`,zn=`https://testflight.apple.com/join/pN5SSHeg`,Bn=1e4;function Vn(e){let t=String(e||``).replace(/^v/,``).split(`+`)[0]??``,n=t.indexOf(`-`);return{parts:(n>=0?t.slice(0,n):t).split(`.`).map(e=>{let t=Number.parseInt(e||`0`,10);return Number.isFinite(t)?t:0}),prerelease:n>=0}}function Hn(e,t){let n=Vn(e),r=Vn(t),i=Math.max(n.parts.length,r.parts.length);for(let e=0;e<i;e+=1){let t=(n.parts[e]||0)-(r.parts[e]||0);if(t!==0)return t}return n.prerelease===r.prerelease?0:n.prerelease?-1:1}function Un(){return[Fn,In]}function Wn(e,t,n=Date.now){let r=e-n();return r<=0||t<=0?null:Math.max(1,Math.ceil(r/t))}function Gn(e){return{appType:`mobile-capacitor`,deviceClass:e.deviceClass||`mobile`,platform:e.platform===`ios`||e.platform===`android`?e.platform:`android`,arch:e.arch||`unknown`,channel:`stable`,currentVersion:e.currentVersion,instanceMode:`remote`,reportUsage:e.reportUsage===!0}}async function Kn(e,t,n,r){try{if(N())try{let{CapacitorHttp:r}=await z(async()=>{let{CapacitorHttp:e}=await import(`./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js`).then(e=>e.i);return{CapacitorHttp:e}},__vite__mapDeps([2,1])),i=Object.fromEntries(new Headers(t.headers).entries()),a;if(typeof t.body==`string`)try{a=JSON.parse(t.body)}catch{a=t.body}let o=await Promise.race([r.request({url:e,method:t.method||`GET`,headers:i,data:a,connectTimeout:n,readTimeout:n}),new Promise(e=>{window.setTimeout(()=>e(null),n)})]);return o?{ok:o.status>=200&&o.status<300,status:o.status,url:typeof o.url==`string`?o.url:e,json:async()=>{if(typeof o.data==`string`)try{return JSON.parse(o.data)}catch{return o.data}return o.data}}:null}catch{}let i=await r(e,{...t,signal:AbortSignal.timeout(n)});return{ok:i.ok,status:i.status,url:i.url,json:()=>i.json()}}catch{return null}}function qn(e,t){return e===`ios`?zn:`${Rn}/download/v${t}/app-release.apk`}function Jn(e,t,n){if(typeof e.latestVersion!=`string`||e.latestVersion.trim().length===0)return null;let r=e.latestVersion.trim(),i=Hn(r,t);if(i<0)return null;let a=typeof e.releaseNotesUrl==`string`&&e.releaseNotesUrl.trim().length>0?e.releaseNotesUrl.trim():`${Rn}/tag/v${r}`,o=typeof e.downloadUrl==`string`&&e.downloadUrl.trim().length>0?e.downloadUrl.trim():typeof e.download?.url==`string`&&e.download.url.trim().length>0?e.download.url.trim():qn(n,r);return{available:!!e.updateAvailable&&i>0,version:r,currentVersion:t,body:typeof e.releaseNotes==`string`?e.releaseNotes:void 0,releaseUrl:a,downloadUrl:o,nextSuggestedCheckInSec:typeof e.nextSuggestedCheckInSec==`number`&&Number.isFinite(e.nextSuggestedCheckInSec)?e.nextSuggestedCheckInSec:void 0}}async function Yn(e,t,n,r){let i=await Kn(e,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify(Gn(t))},n,r);if(!i?.ok)return null;let a;try{a=await i.json()}catch{return null}return Jn(a,t.currentVersion,t.platform)}async function Xn(e,t,n,r){let i=await Kn(Ln,{method:`GET`,headers:{Accept:`text/html`},redirect:`follow`},n,r);if(!i?.ok)return null;let a=typeof i.url==`string`&&i.url.length>0?i.url:Ln,o=null;try{o=new URL(a).pathname.match(/\/releases\/tag\/v(\d+\.\d+\.\d+(?:-[\w.]+)?)/)}catch{return null}if(!o?.[1])return null;let s=o[1],c=Hn(s,e),l=`${Rn}/tag/v${s}`;return{available:c>0,version:s,currentVersion:e,releaseUrl:l,downloadUrl:qn(t,s)}}async function Zn(e){let t=e.currentVersion?.trim()||`unknown`;if(t===`unknown`)return{available:!1,currentVersion:t,error:`Unable to check for mobile updates`};let n=e.fetchImpl??fetch,r=e.now??Date.now,i=Un(),a=r()+Bn;for(let[t,o]of i.entries()){let s=Wn(a,i.length-t+1,r);if(s===null)break;let c=await Yn(o,e,s,n);if(c)return c}let o=Wn(a,1,r);if(o!==null){let r=await Xn(t,e.platform,o,n);if(r)return r}return{available:!1,currentVersion:t,error:`Unable to check for mobile updates`}}function Qn(){if(typeof window>`u`)return`unknown`;try{let{deviceType:e}=Ut();return e}catch{return`unknown`}}function $n(){let e=typeof window<`u`?window.__VSCODE_CONFIG__?.arch?.toLowerCase?.():void 0;if(e===`arm64`||e===`aarch64`)return`arm64`;if(e===`x64`||e===`amd64`||e===`x86_64`)return`x64`;let t=(typeof navigator<`u`?navigator.userAgentData:void 0)?.architecture?.toLowerCase?.();if(t===`arm`||t===`arm64`||t===`aarch64`)return`arm64`;if(t===`x86`||t===`x64`||t===`amd64`)return`x64`;let n=typeof navigator<`u`?navigator.userAgent.toLowerCase():``;return n.includes(`aarch64`)||n.includes(`arm64`)||n.includes(`armv`)?`arm64`:n.includes(`x86_64`)||n.includes(`x64`)||n.includes(`amd64`)||n.includes(`win64`)?`x64`:`unknown`}function er(){let e=P();if(e===`android`||e===`ios`)return e;if(typeof navigator>`u`)return`web`;let t=(navigator.platform||``).toLowerCase();return t.includes(`mac`)?`macos`:t.includes(`win`)?`windows`:t.includes(`linux`)?`linux`:`web`}function tr(e){let t=I.getState().reportUsage,n=new URLSearchParams({reportUsage:t?`true`:`false`});return n.set(`deviceClass`,Qn()),n.set(`arch`,$n()),n.set(`platform`,er()),e===`desktop`?(n.set(`appType`,`desktop-electron`),n.set(`instanceMode`,u()?`local`:`remote`),n):e===`vscode`?(n.set(`appType`,`vscode`),n.set(`instanceMode`,`local`),n):e===`mobile`?(n.set(`appType`,`mobile-capacitor`),n.set(`instanceMode`,`remote`),n):(n.set(`appType`,`web`),n.set(`instanceMode`,`unknown`),n)}async function nr(e,t){let n=t??`unknown`;try{let r=tr(e),i=typeof window<`u`?window.__VSCODE_CONFIG__?.extensionVersion:void 0;t?r.set(`currentVersion`,t):e===`vscode`&&i&&r.set(`currentVersion`,i);let a=await l(`/api/yuri/update-check?${r.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),o=null;try{o=await a.json()}catch{o=null}if(!a.ok)return{available:!1,currentVersion:n,error:typeof o?.error==`string`&&o.error.trim().length>0?o.error.trim():`Server responded with ${a.status}`};if(!o)return{available:!1,currentVersion:n,error:`Update check returned an invalid response`};let s=typeof o.error==`string`&&o.error.trim().length>0?o.error.trim():void 0;return{available:o.available===!0,version:typeof o.version==`string`?o.version:void 0,currentVersion:typeof o.currentVersion==`string`?o.currentVersion:n,body:typeof o.body==`string`?o.body:void 0,releaseUrl:typeof o.releaseUrl==`string`?o.releaseUrl:void 0,downloadUrl:typeof o.downloadUrl==`string`?o.downloadUrl:void 0,nextSuggestedCheckInSec:typeof o.nextSuggestedCheckInSec==`number`&&Number.isFinite(o.nextSuggestedCheckInSec)?o.nextSuggestedCheckInSec:void 0,packageManager:typeof o.packageManager==`string`?o.packageManager:void 0,updateCommand:typeof o.updateCommand==`string`?o.updateCommand:void 0,error:s}}catch(e){return console.warn(`Failed to check for updates:`,e),{available:!1,currentVersion:n,error:e instanceof Error?e.message:`Failed to check for updates`}}}function rr(){return N()?`mobile`:x()?`desktop`:b()?`vscode`:v()?`web`:null}var ir={checking:!1,available:!1,downloading:!1,downloaded:!1,info:null,progress:null,error:null,runtimeType:null,lastChecked:null,nextCheckInSec:null,otaDecision:null,otaPhase:`idle`,otaDownloadSkipped:!1,lastOtaChannelOverride:null};function ar(e,t){let n=e.isChannelRollback===!0?{isChannelRollback:!0}:{};return e.primaryAction===`apply_ota`&&e.ota.bundle?e.ota.bundle.releaseVersion===t?{available:!1,otaPhase:`idle`,info:{available:!1,currentVersion:t,nextSuggestedCheckInSec:e.nextCheckInSec,...n}}:{available:!0,otaPhase:`available`,info:{available:!0,version:e.ota.bundle.releaseVersion,currentVersion:t,downloadUrl:e.ota.bundle.url,nextSuggestedCheckInSec:e.nextCheckInSec,inAppApply:!0,...e.releaseNotes?{body:e.releaseNotes}:{},...n}}:e.primaryAction===`install_native_required`?{available:e.native.state===`required`||e.native.state===`available`,otaPhase:`idle`,info:{available:e.native.state===`required`||e.native.state===`available`,version:e.native.version,currentVersion:t,downloadUrl:e.native.installUrl,nextSuggestedCheckInSec:e.nextCheckInSec,manualUpdate:!0,...e.releaseNotes?{body:e.releaseNotes}:{},...n}}:{available:!1,otaPhase:`idle`,info:{available:!1,currentVersion:t,nextSuggestedCheckInSec:e.nextCheckInSec,...n}}}var or=0,sr=w()((e,t)=>({...ir,checkForUpdates:async()=>{let n=rr();if(!n)return null;let r=++or;e({checking:!0,error:null,runtimeType:n});try{let i=null,a=null;if(n===`desktop`){let n=I.getState().otaChannelOverride;t().lastOtaChannelOverride!==n&&e({downloaded:!1,downloading:!1,available:!1,info:null,otaDecision:null,progress:null,otaPhase:`checking`});let i=await C(n);if(r!==or||I.getState().otaChannelOverride!==n)return null;let a=i?.downloaded===!0;return e({checking:!1,available:i?.available??!1,downloaded:a,...a?{downloading:!1,progress:null}:{},info:i,error:null,lastChecked:Date.now(),nextCheckInSec:i?.nextSuggestedCheckInSec??null,otaDecision:i?.otaDecision??null,otaPhase:a?`pending_restart`:i?.inAppApply?`available`:`idle`,lastOtaChannelOverride:n}),i?.nextSuggestedCheckInSec??null}if(n===`web`)i=await nr(`web`),a=i?.nextSuggestedCheckInSec??null;else if(n===`vscode`)a=(await nr(`vscode`))?.nextSuggestedCheckInSec??null;else if(n===`mobile`){let n=await Nn()??`unknown`,r=N()?s()?.mobileUpdates:void 0,o=I.getState().otaChannelOverride;if(r)try{let i=t().lastOtaChannelOverride!==o;e(i?{otaDecision:null,otaPhase:`checking`,downloaded:!1,otaDownloadSkipped:!1,progress:null,available:!1,info:null}:{otaPhase:`checking`});let a=await r.checkForOtaUpdate(o===`beta`||o===`stable`?{channelOverride:o}:void 0),s=ar(a,n),c=(i?void 0:t().otaDecision?.ota.bundle?.bundleId)!==a.ota.bundle?.bundleId,l=!i&&t().downloaded&&!c;return e({checking:!1,available:s.available,info:s.info,error:s.info.error??null,lastChecked:Date.now(),nextCheckInSec:a.nextCheckInSec,otaDecision:a,otaPhase:l?`pending_restart`:s.otaPhase,lastOtaChannelOverride:o,...c||i?{downloaded:!1,otaDownloadSkipped:!1,progress:null}:{}}),a.nextCheckInSec}catch(t){if(!(t instanceof ee)){let r=t instanceof Error?t.message:`Mobile OTA check failed`;return e({checking:!1,available:!1,info:{available:!1,currentVersion:n},error:r,lastChecked:Date.now(),otaDecision:null,otaPhase:`error`,lastOtaChannelOverride:o}),null}}return i=await Zn({currentVersion:n,platform:er()===`ios`?`ios`:`android`,deviceClass:Qn(),arch:$n(),reportUsage:I.getState().reportUsage}),a=i?.nextSuggestedCheckInSec??null,e({checking:!1,available:i?.available??!1,info:i,error:i?.error??null,lastChecked:Date.now(),nextCheckInSec:a,otaDecision:null,otaPhase:`idle`}),a}return e({checking:!1,available:n===`vscode`?!1:i?.available??!1,info:n===`vscode`?null:i,error:n===`vscode`?null:i?.error??null,lastChecked:Date.now(),nextCheckInSec:a}),a}catch(i){return r===or&&e({checking:!1,error:i instanceof Error?i.message:`Failed to check for updates`,...n===`desktop`&&!t().downloaded?{otaPhase:`error`}:{}}),null}},downloadUpdate:async()=>{let{available:n,runtimeType:r,otaDecision:i,downloading:a,downloaded:o}=t();if(r===`mobile`&&i?.primaryAction===`apply_ota`&&i.ota.bundle){if(a||o)return;let t=s()?.mobileUpdates;if(!t){e({error:`Mobile OTA updates are unavailable in this runtime`,otaPhase:`error`});return}e({downloading:!0,error:null,progress:null,otaPhase:`downloading`,otaDownloadSkipped:!1});try{let{skipped:n}=await t.downloadOtaUpdate(i.ota.bundle);await t.queueOtaUpdateForNextLaunch(),e({downloading:!1,downloaded:!0,progress:null,otaPhase:`pending_restart`,otaDownloadSkipped:n})}catch(t){e({downloading:!1,error:t instanceof Error?t.message:`Failed to download update`,otaPhase:`error`})}return}if(!(r!==`desktop`||!n)){e({downloading:!0,error:null,progress:null});try{let n=I.getState().otaChannelOverride,r=await C(n);if(n!==I.getState().otaChannelOverride)throw Error(`OTA channel changed`);if(!r?.available||r.manualUpdate)throw Error(`Update detected, but desktop package is not ready yet. Retry in a moment.`);if(e(e=>({info:e.info?{...e.info,...r,body:r.body||e.info.body,available:e.info.available}:r})),r.downloaded||t().downloaded){e({downloading:!1,downloaded:!0,progress:null});return}if(r.downloading&&e({downloading:!0,progress:r.progress??{downloaded:0}}),!await d(t=>{e({progress:t})}))throw Error(`Failed to download update`);e({downloading:!1,downloaded:!0,progress:null,otaPhase:`pending_restart`})}catch(t){e({downloading:!1,error:t instanceof Error?t.message:`Failed to download update`})}}},subscribeDesktopUpdateEvents:async()=>{if(!x())return()=>{};let n=[],r=await f(n=>{let r=n.event,i=n.data??null;if(r===`Started`){if(!t().downloading)return;e({error:null,progress:{downloaded:0,total:typeof i?.contentLength==`number`?i.contentLength:void 0}});return}if(r===`Progress`){if(!t().downloading)return;e({progress:{downloaded:typeof i?.downloaded==`number`?i.downloaded:0,total:typeof i?.total==`number`?i.total:void 0}});return}r===`Finished`&&e({downloading:!1,downloaded:!0,progress:null})});r&&n.push(r);let i=await y(t=>{t.downloaded&&e({downloading:!1,downloaded:!0,available:!0,progress:null})});return i&&n.push(i),async()=>{for(let e of n)try{let t=e();t instanceof Promise&&await t}catch{}}},restartToUpdate:async()=>{let{downloaded:n,runtimeType:r,otaDecision:i}=t();if(r===`mobile`&&i?.primaryAction===`apply_ota`){if(!n)return;let t=s()?.mobileUpdates;if(!t){e({error:`Mobile OTA updates are unavailable in this runtime`,otaPhase:`error`});return}try{await t.applyOtaUpdateNow()}catch(t){e({error:t instanceof Error?t.message:`Failed to restart`,otaPhase:`error`})}return}if(!(r!==`desktop`||!n))try{if(!await g())throw Error(`Failed to restart`)}catch(t){e({error:t instanceof Error?t.message:`Failed to restart`})}},setOtaPhase:(t,n=null)=>{e({otaPhase:t,...n===void 0?{}:{error:n}})},setOtaDownloadPercent:n=>{if(!Number.isFinite(n)||n<0||n>100)return;let r=t();if(!r.downloading)return;let i=Math.round(n);if((r.progress?.total?Math.round(r.progress.downloaded/r.progress.total*100):null)===i)return;let a=r.otaDecision?.ota.bundle?.size;if(typeof a==`number`&&Number.isFinite(a)&&a>0){e({progress:{downloaded:Math.round(a*n/100),total:a}});return}e({progress:{downloaded:n,total:100}})},setOtaDownloadFailed:t=>{e({downloading:!1,downloaded:!1,error:t??`Failed to download update`,otaPhase:`error`})},dismiss:()=>{t().otaPhase!==`pending_restart`&&e({available:!1,downloaded:!1,info:null,otaDecision:null,otaPhase:`idle`,otaDownloadSkipped:!1})},reset:()=>{e(ir)}})),cr=`https://github.com/yee94/yuri/releases`;function lr(e){let t=new Date(`${e}T00:00:00`);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(Ae(),{year:`numeric`,month:`short`,day:`numeric`}).format(t)}function ur(e){return e.replace(/^## \[[^\]]+\] - \d{4}-\d{2}-\d{2}\s*\n?/,``).trim()}function dr(e){return e.replace(/(^|[^a-zA-Z0-9])@([a-zA-Z0-9-]+)/g,`$1[@$2](https://github.com/$2)`)}function fr(e,t){let n=e.split(`.`).map(e=>Number.parseInt(e,10)),r=t.split(`.`).map(e=>Number.parseInt(e,10));for(let e=0;e<3;e+=1){let t=Number.isFinite(n[e])?n[e]:0,i=Number.isFinite(r[e])?r[e]:0;if(t!==i)return i-t}return 0}function pr(e){let t=/^## \[(\d+\.\d+\.\d+)\] - (\d{4}-\d{2}-\d{2})\s*$/gm,n=[],r;for(;(r=t.exec(e))!==null;)n.push({version:r[1]??``,date:r[2]??``,start:r.index});return n.length===0?[]:n.map((t,r)=>{let i=n[r+1]?.start??e.length,a=e.slice(t.start,i).trim();return{version:t.version,date:t.date,start:t.start,end:i,raw:a}})}var mr=2e3,hr=6e5;async function gr(){try{let e=await l(`/api/yuri/update-install`,{method:`POST`,headers:{"Content-Type":`application/json`}});return e.ok?{success:!0,autoRestart:(await e.json().catch(()=>({}))).autoRestart!==!1}:{success:!1,error:(await e.json().catch(()=>({}))).error||`Server error: ${e.status}`}}catch(e){return{success:!1,error:e instanceof Error?e.message:void 0}}}async function _r(){try{return(await l(`/health`,{method:`GET`,headers:{Accept:`application/json`}})).ok}catch{return!1}}async function vr(e,t=Math.ceil(hr/mr),n=mr){for(let r=0;r<t;r++){try{let t=await l(`/api/yuri/update-check`,{method:`GET`,headers:{Accept:`application/json`}});if(t.ok){let n=await t.json().catch(()=>null);if(n&&n.available===!1||n&&typeof n.currentVersion==`string`&&typeof e==`string`&&n.currentVersion!==e)return!0}else if((t.status===401||t.status===403)&&await _r())return!0}catch{}await new Promise(e=>setTimeout(e,n))}return!1}var yr=({open:e,onOpenChange:t,info:n,downloading:r,downloaded:i,progress:a,error:o,onDownload:s,onRestart:c,runtimeType:l=`desktop`})=>{let{t:u}=G(),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(`idle`),[h,g]=(0,Q.useState)(null),_=sr(e=>e.otaDownloadSkipped),v=n?.releaseUrl||(n?.version?`${cr}/tag/v${n.version}`:cr),y=n?.downloadUrl,b=a?.total?Math.round(a.downloaded/a.total*100):0,x=l===`web`,S=l===`mobile`,C=S&&n?.manualUpdate===!0&&!!y,w=S&&n?.inAppApply===!0,T=l===`desktop`&&n?.manualUpdate===!0,E=n?.updateCommand||`yuri update`,D=De(e=>{!e&&w&&i&&sr.getState().dismiss(),t(e)}),O=De(()=>{sr.getState().dismiss(),t(!1)});(0,Q.useEffect)(()=>{e||(m(`idle`),g(null))},[e]);let k=async()=>{(await ke(E)).ok&&(f(!0),setTimeout(()=>f(!1),2e3))},A=(0,Q.useCallback)(async e=>{await qt(e)},[]),j=(0,Q.useCallback)(async()=>{m(`updating`),g(null);let e=await gr();if(!e.success){m(`error`),g(e.error||u(`updateDialog.error.updateFailed`));return}e.autoRestart&&(m(`restarting`),await new Promise(e=>setTimeout(e,2e3))),m(`reconnecting`),await vr(n?.currentVersion)?window.location.reload():(m(`error`),g(u(`updateDialog.error.takingLonger`)))},[n?.currentVersion,u]),M=(0,Q.useCallback)(()=>{y&&A(y)},[A,y]),N=p!==`idle`&&p!==`error`,P=(0,Q.useMemo)(()=>{if(!n?.body)return null;let e=n.body.trim();if(!e)return null;let t=pr(e);if(t.length===0)return{kind:`raw`,title:u(`updateDialog.changelog.title`),content:dr(e)};let r=[...t].sort((e,t)=>fr(e.version,t.version));return{kind:`sections`,title:u(`updateDialog.changelog.title`),sections:r.map(t=>({version:t.version,dateLabel:lr(t.date),content:dr(ur(t.raw)||e)}))}},[n?.body,u]);return(0,Z.jsx)(Ze,{open:e,onOpenChange:N?void 0:D,children:(0,Z.jsxs)(Je,{className:`max-w-4xl gap-0 p-4 sm:p-5 bg-background border-[var(--interactive-border)]`,showCloseButton:!0,children:[(0,Z.jsxs)(`div`,{className:`mb-3 pr-8 sm:mb-4`,children:[(0,Z.jsxs)(Ye,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Y,{name:`download-cloud`,className:`h-5 w-5 text-[var(--primary-base)]`}),(0,Z.jsx)(`span`,{className:`font-semibold text-foreground`,children:u(p===`restarting`||p===`reconnecting`?`updateDialog.header.updating`:`updateDialog.header.updateAvailable`)})]}),(n?.currentVersion||n?.version)&&(0,Z.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5 pl-7 font-mono text-[11px] leading-4 tracking-[-0.01em] tabular-nums sm:text-xs`,children:[n?.currentVersion&&(0,Z.jsx)(`span`,{className:`text-muted-foreground/75`,children:n.currentVersion}),n?.currentVersion&&n?.version&&(0,Z.jsx)(`span`,{className:`text-muted-foreground/40`,children:`→`}),n?.version&&(0,Z.jsx)(`span`,{className:`font-medium text-[var(--primary-base)]`,children:n.version})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[x&&N&&(0,Z.jsxs)(`div`,{className:`rounded-lg bg-[var(--surface-elevated)]/30 p-5 border border-[var(--surface-subtle)]`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(Y,{name:`loader`,className:`h-5 w-5 animate-spin text-[var(--primary-base)]`}),(0,Z.jsxs)(`div`,{className:`typography-ui-label text-foreground`,children:[p===`updating`&&u(`updateDialog.status.installingUpdate`),p===`restarting`&&u(`updateDialog.status.serverRestarting`),p===`reconnecting`&&u(`updateDialog.status.waitingForServer`)]})]}),(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:u(`updateDialog.status.autoReloadHint`)})]}),P&&!N&&(0,Z.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--surface-subtle)] px-3.5 py-2.5 sm:px-4 sm:py-3`,children:[(0,Z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--primary-base)]`,"aria-hidden":`true`}),(0,Z.jsx)(`h3`,{className:`typography-ui-caption font-medium text-muted-foreground`,children:P.title})]}),(0,Z.jsx)(Wt,{className:`max-h-[min(42dvh,22rem)] p-0 sm:max-h-[400px]`,fillContainer:!1,children:P.kind===`raw`?(0,Z.jsx)(`div`,{className:`break-words p-3.5 text-[13px] leading-[1.65] text-foreground sm:p-4 sm:text-sm [&_.markdown-content]:leading-[1.65] [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline`,onClickCapture:e=>{let t=e.target.closest(`a`);t&&t.href&&(e.preventDefault(),e.stopPropagation(),A(t.href))},children:(0,Z.jsx)(Kt,{content:P.content,disableLinkSafety:!0,enableFileReferences:!1})}):(0,Z.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:P.sections.map(e=>(0,Z.jsxs)(`div`,{className:`p-3.5 sm:p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-center gap-x-2 gap-y-1 sm:mb-3`,children:[(0,Z.jsxs)(`span`,{className:`rounded-md bg-[var(--primary-base)]/10 px-1.5 py-0.5 font-mono text-[11px] font-medium leading-4 text-[var(--primary-base)] tabular-nums sm:text-xs`,children:[`v`,e.version]}),(0,Z.jsx)(`span`,{className:`text-[11px] leading-4 text-muted-foreground/75 sm:text-xs`,children:e.dateLabel})]}),(0,Z.jsx)(`div`,{className:`break-words text-[13px] leading-[1.65] text-foreground sm:text-sm [&_.markdown-content]:leading-[1.65] [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline`,onClickCapture:e=>{let t=e.target.closest(`a`);t&&t.href&&(e.preventDefault(),e.stopPropagation(),A(t.href))},children:(0,Z.jsx)(Kt,{content:e.content,disableLinkSafety:!0,enableFileReferences:!1})})]},e.version))})})]}),x&&p===`error`&&(0,Z.jsxs)(`div`,{className:`space-y-2 mt-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 typography-meta text-muted-foreground`,children:[(0,Z.jsx)(Y,{name:`terminal`,className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:u(`updateDialog.fallback.updateViaTerminal`)})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 p-1 pl-3 bg-[var(--surface-elevated)]/50 rounded-md border border-[var(--surface-subtle)]`,children:[(0,Z.jsx)(`code`,{className:`flex-1 font-mono text-sm text-foreground overflow-x-auto whitespace-nowrap`,children:E}),(0,Z.jsx)(`button`,{onClick:k,className:K(`flex items-center justify-center p-2 rounded`,`text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]`,`transition-colors`,d&&`text-[var(--status-success)]`),title:u(d?`updateDialog.actions.copied`:`updateDialog.actions.copyCommand`),children:d?(0,Z.jsx)(Y,{name:`check`,className:`h-4 w-4`}):(0,Z.jsx)(Y,{name:`clipboard`,className:`h-4 w-4`})})]})]}),!x&&(!S||w)&&r&&(0,Z.jsxs)(`div`,{className:`mt-3 space-y-2 rounded-lg border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20 px-3.5 py-3 sm:mt-4 sm:px-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground sm:text-[13px]`,children:u(`updateDialog.status.downloadingPayload`)}),(0,Z.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] leading-4 text-foreground tabular-nums sm:text-xs`,children:[b,`%`]})]}),(0,Z.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-[var(--surface-subtle)] sm:h-1.5`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-[var(--primary-base)] transition-all duration-300`,style:{width:`${b}%`}})})]}),(o||h)&&(0,Z.jsx)(`div`,{className:`p-3 mt-4 bg-[var(--status-error-background)] border border-[var(--status-error-border)] rounded-lg`,children:(0,Z.jsx)(`p`,{className:`text-sm text-[var(--status-error)]`,children:o||h})})]}),w&&i&&_&&(0,Z.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg border border-[var(--status-success-border)] bg-[var(--status-success-background)] px-3 py-2.5 text-sm text-[var(--status-success)]`,children:[(0,Z.jsx)(Y,{name:`check`,className:`h-4 w-4 shrink-0`}),(0,Z.jsx)(`span`,{children:u(`updateDialog.status.otaBundleReused`)})]}),(0,Z.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-4`,children:[!S||C?(0,Z.jsxs)(`a`,{href:S?y:v,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground hover:text-foreground transition-colors shrink-0`,children:[(0,Z.jsx)(Y,{name:`external-link`,className:`h-4 w-4`}),`GitHub`]}):(0,Z.jsx)(`span`,{}),(0,Z.jsxs)(`div`,{className:`flex-1 flex justify-end`,children:[!x&&(!S||w)&&!T&&!i&&!r&&(0,Z.jsxs)(q,{onClick:s,size:`default`,children:[(0,Z.jsx)(Y,{name:`download`,className:`h-4 w-4`}),u(w?`updateDialog.actions.applyOtaNow`:`updateDialog.actions.downloadUpdate`)]}),!x&&!S&&T&&!i&&!r&&(0,Z.jsxs)(q,{onClick:()=>void A(v),size:`default`,children:[(0,Z.jsx)(Y,{name:`external-link`,className:`h-4 w-4`}),u(`updateDialog.actions.openMobileUpdate`)]}),!x&&(!S||w)&&r&&(0,Z.jsxs)(q,{disabled:!0,size:`default`,children:[(0,Z.jsx)(Y,{name:`loader`,className:`h-4 w-4 animate-spin`}),u(`updateDialog.status.downloading`)]}),!x&&(!S||w)&&i&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[w&&(0,Z.jsx)(q,{onClick:O,variant:`ghost`,size:`default`,children:u(`updateDialog.actions.later`)}),(0,Z.jsxs)(q,{onClick:c,size:`default`,children:[(0,Z.jsx)(Y,{name:`restart`,className:`h-4 w-4`}),u(`updateDialog.actions.restartToUpdate`)]})]}),S&&!w&&C&&(0,Z.jsxs)(q,{onClick:M,size:`default`,children:[(0,Z.jsx)(Y,{name:`external-link`,className:`h-4 w-4`}),u(`updateDialog.actions.openMobileUpdate`)]}),x&&!N&&(0,Z.jsxs)(q,{onClick:j,size:`default`,children:[(0,Z.jsx)(Y,{name:`download`,className:`h-4 w-4`}),u(`updateDialog.actions.updateNow`)]}),x&&N&&(0,Z.jsxs)(q,{disabled:!0,size:`default`,children:[(0,Z.jsx)(Y,{name:`loader`,className:`h-4 w-4 animate-spin`}),u(`updateDialog.status.updating`)]})]})]})]})})},br=e(O(),1);function xr(e){let t=(0,X.c)(20),{label:n,children:r,description:i,itemId:a,ariaLabel:o,className:s,cardClassName:c,cardId:l}=e,u=typeof n==`string`&&/^[\p{Script=Latin}\p{Number}\p{Punctuation}\p{Separator}]+$/u.test(n)?`latin`:void 0,d;t[0]===s?d=t[1]:(d=K(`yuri-settings-group`,s),t[0]=s,t[1]=d);let f;t[2]!==n||t[3]!==u?(f=n?(0,Z.jsx)(`div`,{className:`yuri-settings-group-label`,"data-settings-label-script":u,children:n}):null,t[2]=n,t[3]=u,t[4]=f):f=t[4];let p;t[5]===c?p=t[6]:(p=K(`yuri-settings-group-card`,c),t[5]=c,t[6]=p);let m;t[7]!==l||t[8]!==r||t[9]!==a||t[10]!==p?(m=(0,Z.jsx)(`div`,{id:l,"data-settings-item":a,className:p,children:r}),t[7]=l,t[8]=r,t[9]=a,t[10]=p,t[11]=m):m=t[11];let h;t[12]===i?h=t[13]:(h=i?(0,Z.jsx)(`p`,{className:`yuri-settings-group-description text-muted-foreground`,children:i}):null,t[12]=i,t[13]=h);let g;return t[14]!==o||t[15]!==d||t[16]!==f||t[17]!==m||t[18]!==h?(g=(0,Z.jsxs)(`section`,{className:d,"aria-label":o,children:[f,m,h]}),t[14]=o,t[15]=d,t[16]=f,t[17]=m,t[18]=h,t[19]=g):g=t[19],g}function Sr(e){let t=(0,X.c)(20),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({label:s,description:a,descriptionPlacement:l,ariaLabel:n,groupClassName:o,cardClassName:r,children:i,...c}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u=l===void 0?`inside`:l,d=u===`outside`?a:void 0,f=u===`inside`?a:void 0,p;t[9]!==i||t[10]!==s||t[11]!==c||t[12]!==f?(p=(0,Z.jsx)(Cr,{label:s,description:f,...c,children:i}),t[9]=i,t[10]=s,t[11]=c,t[12]=f,t[13]=p):p=t[13];let m;return t[14]!==n||t[15]!==r||t[16]!==o||t[17]!==d||t[18]!==p?(m=(0,Z.jsx)(xr,{ariaLabel:n,className:o,cardClassName:r,description:d,children:p}),t[14]=n,t[15]=r,t[16]=o,t[17]=d,t[18]=p,t[19]=m):m=t[19],m}function Cr(e){let t=(0,X.c)(22),{label:n,children:r,description:i,itemId:a,className:o,copyClassName:s,controlClassName:c}=e,l;t[0]===o?l=t[1]:(l=K(`yuri-settings-group-row yuri-settings-split-row`,o),t[0]=o,t[1]=l);let u;t[2]===s?u=t[3]:(u=K(`yuri-settings-split-row-copy`,s),t[2]=s,t[3]=u);let d;t[4]===n?d=t[5]:(d=n?(0,Z.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:n}):null,t[4]=n,t[5]=d);let f;t[6]===i?f=t[7]:(f=i?(0,Z.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:i}):null,t[6]=i,t[7]=f);let p;t[8]!==u||t[9]!==d||t[10]!==f?(p=(0,Z.jsxs)(`div`,{className:u,children:[d,f]}),t[8]=u,t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===c?m=t[13]:(m=K(`yuri-settings-split-row-control`,c),t[12]=c,t[13]=m);let h;t[14]!==r||t[15]!==m?(h=(0,Z.jsx)(`div`,{"data-settings-value":``,className:m,children:r}),t[14]=r,t[15]=m,t[16]=h):h=t[16];let g;return t[17]!==a||t[18]!==l||t[19]!==p||t[20]!==h?(g=(0,Z.jsxs)(`div`,{"data-settings-item":a,className:l,children:[p,h]}),t[17]=a,t[18]=l,t[19]=p,t[20]=h,t[21]=g):g=t[21],g}function wr(e){let t=(0,X.c)(32),{checked:n,onChange:r,label:i,ariaLabel:a,description:o,itemId:s,disabled:c,className:l}=e,u=c!==void 0&&c,d;t[0]!==n||t[1]!==u||t[2]!==r?(d=()=>{u||r(!n)},t[0]=n,t[1]=u,t[2]=r,t[3]=d):d=t[3];let f=d,p=Tr,m=u?`cursor-not-allowed`:`cursor-pointer`,h;t[4]!==l||t[5]!==m?(h=K(`yuri-settings-group-row yuri-settings-split-row group`,m,l),t[4]=l,t[5]=m,t[6]=h):h=t[6];let g=u?-1:0,_=u||void 0,v,y;t[7]===f?(v=t[8],y=t[9]):(v=e=>{p(e.target)||f()},y=e=>{p(e.target)||(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),f())},t[7]=f,t[8]=v,t[9]=y);let b;t[10]===i?b=t[11]:(b=(0,Z.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i}),t[10]=i,t[11]=b);let x;t[12]===o?x=t[13]:(x=o?(0,Z.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:o}):null,t[12]=o,t[13]=x);let S;t[14]!==x||t[15]!==b?(S=(0,Z.jsxs)(`div`,{className:`yuri-settings-split-row-copy`,children:[b,x]}),t[14]=x,t[15]=b,t[16]=S):S=t[16];let C;t[17]!==a||t[18]!==n||t[19]!==u||t[20]!==r?(C=(0,Z.jsx)(`div`,{"data-settings-value":``,className:`yuri-settings-split-row-control`,children:(0,Z.jsx)(at,{checked:n,onChange:r,disabled:u,ariaLabel:a})}),t[17]=a,t[18]=n,t[19]=u,t[20]=r,t[21]=C):C=t[21];let w;return t[22]!==n||t[23]!==s||t[24]!==S||t[25]!==C||t[26]!==h||t[27]!==g||t[28]!==_||t[29]!==v||t[30]!==y?(w=(0,Z.jsxs)(`div`,{"data-settings-item":s,className:h,role:`button`,tabIndex:g,"aria-pressed":n,"aria-disabled":_,onClick:v,onKeyDown:y,children:[S,C]}),t[22]=n,t[23]=s,t[24]=S,t[25]=C,t[26]=h,t[27]=g,t[28]=_,t[29]=v,t[30]=y,t[31]=w):w=t[31],w}function Tr(e){return e instanceof HTMLElement&&e.closest(`button, a, input, select, textarea`)!==null}var Er=`/mcp/oauth/callback`,Dr=e=>{if(typeof window>`u`)return null;try{let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t.length%4==0?``:`=`.repeat(4-t.length%4),r=window.atob(t+n),i=Uint8Array.from(r,e=>e.charCodeAt(0));return new TextDecoder().decode(i)}catch{return null}},Or=e=>{let t=Ar(e.get(`state`));if(t)return t;let n=e.get(`server`);if(typeof n!=`string`||!n.trim())return null;let r=e.get(`directory`);return{name:n.trim(),directory:typeof r==`string`&&r.trim()?r.trim():null}},kr=e=>{let t=e.get(`state`);return typeof t==`string`&&t.trim()||null},Ar=e=>{if(typeof e!=`string`||!e.trim())return null;let t=Dr(e.trim());if(!t)return null;try{let e=JSON.parse(t);return e?.v!==1||typeof e.n!=`string`||!e.n.trim()?null:{name:e.n.trim(),directory:typeof e.d==`string`&&e.d.trim()?e.d.trim():null}}catch{return null}},jr=e=>typeof e==`object`&&!!e&&`updateStatus`in e&&typeof e.updateStatus==`function`,Mr=e=>{let t=document.createElement(`div`);t.className=`cm-vim-panel`;let n=pn(e);if(!n)return{top:!1,dom:t};n.state.statusbar=t;let r=n.state.vimPlugin;return jr(r)&&r.updateStatus(),{top:!1,dom:t,destroy(){n.state.statusbar===t&&(n.state.statusbar=null)}}};function Nr(e){return e?[fn(),te.of(Mr),re()]:[]}var Pr={next:`Next match`,prev:`Previous match`,select:`Select all matches`,replace:`Replace`,replaceAll:`Replace all`,close:`Close`},Fr={case:`Match case`,re:`Regular expression`,word:`Match whole word`};function Ir(e){let t=e.querySelector(`.cm-search`);if(t){for(let[e,n]of Object.entries(Pr)){let r=t.querySelector(`button[name="${e}"]`);r&&!r.title&&(r.title=n)}for(let[e,n]of Object.entries(Fr)){let r=t.querySelector(`input[name="${e}"]`)?.parentElement;r&&!r.title&&(r.title=n)}}}var Lr=new WeakMap;function Rr(e,t){let n=cn(e.state);if(!n.valid)return Lr.delete(e),0;let r=Lr.get(e);if(!t&&r?.doc===e.state.doc&&r.query.eq(n))return r.total;let i=n.getCursor(e.state),a=0;for(let e=i.next();!e.done;e=i.next())a+=1;return Lr.set(e,{query:n,doc:e.state.doc,total:a}),a}function zr(e){let t=cn(e.state);if(!t.valid)return 0;let n=e.state.selection.main,r=t.getCursor(e.state),i=0,a=0;for(let e=r.next();!e.done;e=r.next()){let t=e.value;if(i+=1,a===0&&(a=i),n.from===t.from&&n.to===t.to||n.from<t.to&&n.to>t.from||t.from>=n.head)return i}return a}function Br(e,t,n=!1){let r=e.querySelector(`.cm-search`);if(!r)return;let i=r.querySelector(`.cm-search-message`);if(!i){i=document.createElement(`span`),i.className=`cm-search-message`,i.setAttribute(`aria-live`,`polite`);let e=r.querySelector(`button[name="next"]`),t=e?.parentNode===r?e:r.firstChild;r.insertBefore(i,t)}let a=Rr(t,n),o=a===0?0:zr(t);i.textContent=a===0?``:`${o}/${a}`}var Vr=new H,Hr=new H,Ur=new H,Wr=new H,Gr=new H,Kr=new H,qr=new H,Jr=e=>e,Yr=se,Xr=on,Zr=un,Qr=class extends le{id;containerMap;constructor(e,t){super(),this.id=e,this.containerMap=t}toDOM(){let e=this.containerMap.get(this.id);return e||(e=document.createElement(`div`),e.className=`yuri-block-widget`,e.dataset.widgetId=this.id,this.containerMap.set(this.id,e)),e}eq(e){return e.id===this.id}destroy(){}},$r=(e,t)=>!e||e.length===0?[]:ve.define({create(n){let r=new pe,i=[...e].sort((e,t)=>e.afterLine-t.afterLine);for(let e of i){let i=n.doc.lines;if(e.afterLine>i)continue;let a=n.doc.line(e.afterLine);r.add(a.to,a.to,B.widget({widget:new Qr(e.id,t),block:!0,side:1}))}return r.finish()},update(e,t){return e.map(t.changes)},provide:e=>V.decorations.from(e)}),ei=e=>{if(!e)return[];let t=Math.max(1,e.start),n=Math.max(t,e.end);return ce.fromClass(class{decorations;constructor(e){this.decorations=this.build(e)}update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=this.build(e.view))}build(e){let r=new pe;for(let i=t;i<=n&&i<=e.state.doc.lines;i+=1){let t=e.state.doc.line(i);r.add(t.from,t.from,B.line({class:`yuri-cm-selected-line`}))}return r.finish()}},{decorations:e=>e.decorations})};function ti({value:e,onChange:t,extensions:n,className:r,readOnly:i,lineNumbersConfig:a,highlightLines:o,onViewReady:s,onViewDestroy:c,blockWidgets:l,enableSearch:u,searchOpen:d,onSearchOpenChange:f,vimMode:p}){let m=Q.useRef(null),h=Q.useRef(null),g=Q.useRef(e),_=Q.useRef(t),v=Q.useRef(s),y=Q.useRef(c),b=Q.useRef(f),x=Q.useRef(l),S=Q.useRef(p),C=Q.useRef(new Map),[w,T]=Q.useState([]),E=Q.useCallback(e=>{let t=(e??[]).map(e=>{let t=C.current.get(e.id);return t?{id:e.id,content:e.content,container:t}:null}).filter(e=>e!==null);T(e=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return e.id===r.id&&e.content===r.content&&e.container===r.container})?e:t)},[]),D=Q.useCallback(e=>{let t=m.current,n=e??h.current;if(!t||!n)return;let r=n.dom.querySelector(`.cm-gutters`),i=r instanceof HTMLElement?r.getBoundingClientRect().width:0;t.style.setProperty(`--yuri-editor-gutter-width`,`${i}px`)},[]);return Q.useEffect(()=>{g.current=e},[e]),Q.useEffect(()=>{_.current=t},[t]),Q.useEffect(()=>{v.current=s,y.current=c},[s,c]),Q.useEffect(()=>{b.current=f},[f]),Q.useEffect(()=>{x.current=l,E(l)},[l,E]),Q.useEffect(()=>{if(!m.current)return;let e=(()=>{if(typeof document>`u`)return null;let e=document.querySelector(`meta[name="csp-nonce"]`)?.getAttribute(`content`);if(e)return e;let t=window.__YURI_CSP_NONCE__;return typeof t==`string`&&t.length>0?t:null})(),t=ye.create({doc:g.current,extensions:[...e?[V.cspNonce.of(e)]:[],ie({fixed:!0}),Vr.of(ue(a)),rn(),ne.of(` `),qr.of(Nr(p)),de.of([nn,...tn,...an]),V.updateListener.of(e=>{D(e.view),(e.viewportChanged||e.geometryChanged)&&E(x.current);let t=sn(e.startState),n=sn(e.state);t!==n&&b.current?.(n);let r=!cn(e.startState).eq(cn(e.state));if(n&&(t!==n||r||e.docChanged||e.selectionSet)&&Br(e.view.dom,e.view,t!==n||r||e.docChanged),!e.docChanged)return;let i=e.state.doc.toString();g.current=i,_.current(i),E(x.current)}),Hr.of(V.editable.of(!i)),Ur.of(n??[]),Wr.of(ei(o)),Gr.of($r(l,C.current)),Kr.of(u?[ln({top:!0}),de.of(Jr(dn))]:[])]});return h.current=new V({state:t,parent:m.current}),Yr(h.current,h.current.state.doc.length,200),h.current.requestMeasure(),requestAnimationFrame(()=>{D(h.current),E(x.current)}),h.current&&v.current?.(h.current),()=>{y.current?.(),h.current?.destroy(),h.current=null,T([])}},[x,D,E]),Q.useEffect(()=>{let e=h.current;e&&(e.dispatch({effects:[Vr.reconfigure(ue(a)),Hr.reconfigure(V.editable.of(!i)),Ur.reconfigure(n??[]),Wr.reconfigure(ei(o)),Gr.reconfigure($r(l,C.current)),Kr.reconfigure(u?[ln({top:!0}),de.of(Jr(dn))]:[])]}),Yr(e,e.state.doc.length,200),e.requestMeasure(),requestAnimationFrame(()=>{D(e),E(x.current)}))},[n,o,a,i,l,u,D,E]),Q.useEffect(()=>{let e=h.current;if(!e){S.current=p;return}S.current!==p&&(S.current=p,e.dispatch({effects:qr.reconfigure(Nr(p))}))},[p]),Q.useEffect(()=>{let e=h.current;!e||u===!1||(d?(Xr(e),requestAnimationFrame(()=>{Ir(e.dom),Br(e.dom,e,!0)})):Zr(e))},[d,u]),Q.useEffect(()=>{let t=h.current;if(!t)return;let n=t.state.doc.toString();n!==e&&(t.dispatch({changes:{from:0,to:n.length,insert:e}}),Yr(t,t.state.doc.length,300),t.requestMeasure(),requestAnimationFrame(()=>D(t)))},[e,D]),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{ref:m,className:K(`h-full w-full`,`[&_.cm-editor]:h-full [&_.cm-editor]:w-full`,`[&_.cm-scroller]:font-mono [&_.cm-scroller]:text-[var(--text-code)] [&_.cm-scroller]:leading-6`,`[&_.cm-lineNumbers]:text-[var(--tools-edit-line-number)]`,r)}),w.map(e=>(0,br.createPortal)(e.content,e.container,e.id))]})}var ni=me.define(Ee),ri=Ce.data.of({commentTokens:{line:`//`,block:{open:`/*`,close:`*/`}}});function ii(e){let t=e.trim().toLowerCase();switch(t){case`bash`:case`sh`:case`zsh`:case`shell`:case`shellsession`:case`console`:return ni;case`json`:case`jsonc`:case`json5`:return Se().language;case`js`:case`javascript`:return W().language;case`jsx`:return W({jsx:!0}).language;case`ts`:case`typescript`:return W({typescript:!0}).language;case`tsx`:return W({typescript:!0,jsx:!0}).language;case`html`:return xe().language;case`css`:return be().language;case`py`:case`python`:return Te().language;case`md`:case`markdown`:case`mdown`:case`mkd`:return we().language;case`heex`:case`eex`:case`leex`:return xe().language;default:return _e.matchLanguageName(mn,t,!0)}}var ai=e=>e.split(`/`).pop()?.toLowerCase()??``,oi=e=>{let t=ai(e);return t?_e.matchFilename(mn,t):null},si=()=>oe(fe.define([{tag:[U.heading1,U.heading2,U.heading3,U.heading4,U.heading5,U.heading6],fontWeight:`600`},{tag:U.strong,fontWeight:`600`},{tag:U.emphasis,fontStyle:`italic`},{tag:U.strikethrough,textDecoration:`line-through`},{tag:[U.link,U.url],color:`var(--markdown-link, currentColor)`,textDecoration:`underline`},{tag:U.monospace,color:`var(--markdown-inline-code, currentColor)`,backgroundColor:`var(--markdown-inline-code-bg, transparent)`},{tag:U.quote,color:`var(--markdown-blockquote, currentColor)`,fontStyle:`italic`},{tag:U.list,color:`color-mix(in srgb, var(--muted-foreground) 40%, var(--foreground) 60%)`},{tag:U.heading,color:`var(--markdown-heading1, currentColor)`}]));function ci(e){let t=e.toLowerCase();switch(ai(t)){case`makefile`:case`gnumakefile`:return ni}let n=t.lastIndexOf(`.`),r=n>=0?t.slice(n+1):``;switch(r){case`ts`:case`tsx`:case`mts`:case`cts`:return W({typescript:!0,jsx:r===`tsx`});case`js`:case`jsx`:case`mjs`:case`cjs`:return W({typescript:!1,jsx:r===`jsx`});case`jsonc`:case`json5`:return[Se(),ri];case`json`:case`jsonl`:case`ndjson`:case`geojson`:return Se();case`css`:case`scss`:case`sass`:case`less`:return be();case`html`:case`htm`:case`xml`:case`drawio`:case`dio`:return xe();case`md`:case`mdx`:case`markdown`:case`mdown`:case`mkd`:return[we({codeLanguages:ii}),si()];case`sh`:case`bash`:case`zsh`:case`fish`:case`env`:return ni;case`py`:case`pyw`:case`pyi`:return Te();default:return null}}async function li(e){let t=oi(e);if(!t)return null;if(t.support)return t.support;try{return await t.load()}catch{return null}}function ui(e,t){let n=e.metadata.variant===`dark`,r=e.config?.fonts?.mono||`monospace`,i=e.colors.syntax.highlights||{},a=e.colors.syntax.tokens||{},o=t?.fontSize?`${t.fontSize}px`:`var(--text-code)`,s=V.theme({"&":{backgroundColor:`var(--background)`,color:e.colors.syntax.base.foreground,fontSize:o,lineHeight:`1.5`,position:`relative`},".cm-scroller":{fontFamily:r,backgroundColor:`var(--background)`},".cm-comment":{color:e.colors.syntax.base.comment},".cm-keyword":{color:e.colors.syntax.base.keyword},".cm-string":{color:e.colors.syntax.base.string},".cm-string-2":{color:a.stringEscape||e.colors.syntax.base.string},".cm-number":{color:e.colors.syntax.base.number},".cm-operator":{color:e.colors.syntax.base.operator},".cm-punctuation":{color:a.punctuation||e.colors.syntax.base.comment},".cm-atom":{color:a.boolean||e.colors.syntax.base.number},".cm-builtin":{color:a.functionCall||e.colors.syntax.base.function},".cm-def":{color:a.variableGlobal||e.colors.syntax.base.variable},".cm-attribute":{color:a.variableOther||a.variableProperty||e.colors.syntax.base.operator},".cm-meta":{color:e.colors.syntax.base.comment},".cm-property":{color:a.variableProperty||e.colors.syntax.base.keyword},".cm-variable":{color:e.colors.syntax.base.variable},".cm-variable-2":{color:a.variableOther||e.colors.syntax.base.function},".cm-variable-3":{color:a.variableGlobal||e.colors.syntax.base.type},".cm-tag":{color:a.tag||e.colors.syntax.base.keyword},".cm-link":{color:a.url||e.colors.syntax.base.keyword,textDecoration:`underline`},".cm-content":{caretColor:e.colors.interactive.cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:e.colors.interactive.cursor},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e.colors.interactive.selection},".cm-gutters":{backgroundColor:`var(--background)`,color:i.lineNumber||e.colors.syntax.base.comment,borderRight:`1px solid ${e.colors.interactive.border}`,position:`sticky`,paddingRight:`8px`,left:0,zIndex:2,boxShadow:`0 0 0 var(--background)`},".cm-gutter":{backgroundColor:`var(--background)`},".cm-gutterElement":{backgroundColor:`var(--background)`},".cm-lineNumbers":{backgroundColor:`var(--background)`},".cm-lineNumbers .cm-gutterElement":{paddingLeft:`8px`,paddingRight:`8px`,minWidth:`42px`},".cm-activeLineGutter":{color:i.lineNumberActive||e.colors.syntax.base.foreground},".cm-activeLine":{backgroundColor:e.colors.surface.overlay},".cm-panels":{backgroundColor:`transparent`,color:e.colors.surface.foreground,position:`absolute`,top:`0`,right:`0`,left:`auto`,width:`auto`,zIndex:10,pointerEvents:`none`},".cm-panels-top":{borderBottom:`none`,position:`absolute`,top:`6px`,right:`14px`,left:`auto`,width:`auto`},".cm-panels-bottom":{position:`static`,width:`100%`,pointerEvents:`auto`},".cm-panels-bottom .cm-vim-panel":{borderTop:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.elevated,color:e.colors.surface.mutedForeground,fontFamily:`var(--font-mono)`,fontSize:`12px`,minHeight:`22px`,padding:`2px 8px`},".cm-panel.cm-search":{pointerEvents:`auto`,padding:`4px`,backgroundColor:`color-mix(in srgb, ${e.colors.surface.elevated} 85%, transparent)`,border:`1px solid ${e.colors.interactive.border}`,borderRadius:`10px`,boxShadow:`0 2px 8px color-mix(in srgb, ${e.colors.surface.background} 60%, transparent)`,width:`auto`,minWidth:`360px`,maxWidth:`480px`},".cm-search":{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:`0`,width:`100%`,color:e.colors.surface.foreground,fontFamily:`inherit`,fontSize:`13px`,lineHeight:`1`},".cm-search br":{display:`none`},".cm-search .cm-textfield":{appearance:`none`,height:`26px`,margin:0,padding:`0 8px`,borderRadius:`6px !important`,border:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.background,color:e.colors.surface.foreground,fontFamily:`inherit`,fontSize:`12px`,lineHeight:`1`,outline:`none`,transition:`border-color 150ms ease`},".cm-search .cm-textfield::placeholder":{color:e.colors.surface.mutedForeground,opacity:1},".cm-search .cm-textfield:focus":{borderColor:e.colors.primary.base},'.cm-search .cm-textfield[name="search"]':{order:1,flex:`1 1 120px`,maxWidth:`calc(100% - 142px)`,minWidth:`100px`},".cm-search label":{order:2,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:0,marginLeft:`1px`,padding:0,borderRadius:`4px`,border:`1px solid transparent`,backgroundColor:`transparent`,color:`transparent`,cursor:`pointer`,userSelect:`none`,fontSize:`1px`,lineHeight:`0`,overflow:`hidden`,position:`relative`,transition:`background-color 120ms ease, border-color 120ms ease`},".cm-search label:hover":{backgroundColor:e.colors.interactive.hover},'.cm-search label:has(input[type="checkbox"]:checked)':{backgroundColor:e.colors.interactive.hover,borderColor:e.colors.interactive.border},'.cm-search [type="checkbox"]':{appearance:`none`,WebkitAppearance:`none`,width:`0`,height:`0`,margin:`0`,padding:`0`,border:`none`,position:`absolute`,opacity:`0`,pointerEvents:`none`},".cm-search label::after":{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,fontSize:`13px`,fontWeight:`600`,lineHeight:`1`,fontFamily:`inherit`,color:e.colors.surface.mutedForeground,pointerEvents:`none`},".cm-search label:hover::after":{color:e.colors.surface.foreground},'.cm-search label:has(input[type="checkbox"]:checked)::after':{color:e.colors.surface.foreground},'.cm-search label:has(input[name="case"])::after':{content:`"Aa"`,fontSize:`12px`,letterSpacing:`-0.5px`},'.cm-search label:has(input[name="re"])::after':{content:`".*"`,fontSize:`13px`,fontFamily:`monospace`},'.cm-search label:has(input[name="word"])::after':{content:`"ab"`,fontSize:`12px`,textDecoration:`underline`,textUnderlineOffset:`2px`},".cm-search .cm-search-message":{order:3,color:e.colors.surface.mutedForeground,backgroundColor:`transparent`,border:`none`,borderRadius:`0`,padding:`0 6px`,fontSize:`11px`,whiteSpace:`nowrap`,lineHeight:`26px`},".cm-search .cm-button":{appearance:`none`,WebkitAppearance:`none`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:0,marginLeft:`1px`,padding:0,borderRadius:`4px`,border:`none`,backgroundColor:`transparent`,backgroundImage:`none`,color:`transparent`,cursor:`pointer`,fontSize:`1px`,fontWeight:`400`,lineHeight:`0`,overflow:`hidden`,position:`relative`,boxShadow:`none`,transition:`background-color 120ms ease`},".cm-search .cm-button::after":{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,fontSize:`15px`,lineHeight:`1`,color:e.colors.surface.mutedForeground,pointerEvents:`none`},".cm-search .cm-button:hover":{backgroundColor:e.colors.interactive.hover},".cm-search .cm-button:hover::after":{color:e.colors.surface.foreground},".cm-search .cm-button:active":{backgroundColor:e.colors.interactive.active},".cm-search .cm-button:focus-visible":{outline:`none`,boxShadow:`0 0 0 1px ${e.colors.interactive.focusRing}`},".cm-search .cm-button:disabled":{opacity:.4,cursor:`default`,pointerEvents:`none`},'.cm-search .cm-button[name="prev"]':{order:21,marginTop:`2px`},'.cm-search .cm-button[name="prev"]::after':{content:`"↑"`},'.cm-search .cm-button[name="next"]':{order:22,marginTop:`2px`},'.cm-search .cm-button[name="next"]::after':{content:`"↓"`},'.cm-search .cm-button[name="select"]':{order:23,marginTop:`2px`},'.cm-search .cm-button[name="select"]::after':{content:`"≡"`,fontSize:`17px`},'.cm-panel.cm-search button[name="close"]':{order:5,appearance:`none`,WebkitAppearance:`none`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:`0 0 0 auto`,padding:`0`,borderRadius:`4px`,border:`none`,backgroundColor:`transparent`,backgroundImage:`none`,color:e.colors.surface.mutedForeground,cursor:`pointer`,fontSize:`16px`,lineHeight:`1`,boxShadow:`none`,position:`relative`,overflow:`visible`,transition:`background-color 120ms ease, color 120ms ease`},'.cm-panel.cm-search button[name="close"]:hover':{backgroundColor:e.colors.interactive.hover,color:e.colors.surface.foreground},'.cm-search .cm-button[name="replace"]':{order:24,marginTop:`2px`},'.cm-search .cm-button[name="replace"]::after':{content:`"⇄"`},'.cm-search .cm-button[name="replaceAll"], .cm-search .cm-button[name="replace-all"]':{order:25,marginTop:`2px`},'.cm-search .cm-button[name="replaceAll"]::after, .cm-search .cm-button[name="replace-all"]::after':{content:`"⇉"`},'.cm-search .cm-textfield[name="replace"]':{order:20,flex:`1 1 100%`,maxWidth:`calc(100% - 142px)`,minWidth:`80px`,marginTop:`2px`},".cm-searchMatch":{backgroundColor:e.colors.status.infoBackground,boxShadow:`inset 0 0 0 1px ${e.colors.status.infoBorder}`,borderRadius:`2px`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:e.colors.interactive.selection,color:e.colors.interactive.selectionForeground,boxShadow:`inset 0 0 0 1px ${e.colors.interactive.borderFocus}`},"&.cm-focused":{outline:`none`}},{dark:n}),c=fe.define([{tag:[U.comment,U.docComment,U.meta,U.documentMeta],class:`cm-comment`},{tag:[U.keyword,U.controlKeyword,U.moduleKeyword,U.definitionKeyword,U.modifier],class:`cm-keyword`},{tag:[U.operatorKeyword,U.operator,U.derefOperator,U.updateOperator,U.definitionOperator,U.typeOperator,U.controlOperator,U.logicOperator,U.bitwiseOperator,U.arithmeticOperator,U.compareOperator],class:`cm-operator`},{tag:[U.punctuation,U.separator,U.bracket,U.paren,U.brace,U.squareBracket,U.angleBracket],class:`cm-punctuation`},{tag:[U.string,U.regexp,U.attributeValue,U.special(U.string),U.monospace],class:`cm-string`},{tag:U.escape,class:`cm-string-2`},{tag:[U.number,U.bool,U.atom,U.null,U.self],class:`cm-number`},{tag:[U.function(U.variableName),U.function(U.definition(U.variableName)),U.function(U.propertyName),U.standard(U.variableName),U.special(U.variableName)],class:`cm-builtin`},{tag:U.definition(U.variableName),class:`cm-def`},{tag:[U.variableName,U.local(U.variableName),U.constant(U.variableName),U.literal],class:`cm-variable`},{tag:U.propertyName,class:`cm-property`},{tag:U.attributeName,class:`cm-attribute`},{tag:[U.className,U.typeName,U.namespace],class:`cm-variable-3`},{tag:[U.tagName,U.labelName,U.annotation,U.macroName],class:`cm-tag`},{tag:U.link,class:`cm-link`},{tag:[U.heading,U.heading1,U.heading2,U.heading3,U.heading4,U.heading5,U.heading6],class:`cm-keyword`}]),l=fe.define([{tag:[U.comment,U.docComment,U.meta,U.documentMeta],color:e.colors.syntax.base.comment},{tag:[U.keyword,U.controlKeyword,U.moduleKeyword,U.definitionKeyword,U.modifier],color:e.colors.syntax.base.keyword},{tag:[U.operatorKeyword,U.operator,U.derefOperator,U.updateOperator,U.definitionOperator,U.typeOperator,U.controlOperator,U.logicOperator,U.bitwiseOperator,U.arithmeticOperator,U.compareOperator],color:e.colors.syntax.base.operator},{tag:[U.string,U.regexp,U.attributeValue,U.special(U.string),U.monospace],color:e.colors.syntax.base.string},{tag:U.escape,color:a.stringEscape||e.colors.syntax.base.string},{tag:[U.number,U.bool,U.atom,U.null,U.self],color:e.colors.syntax.base.number},{tag:[U.function(U.variableName),U.function(U.definition(U.variableName)),U.function(U.propertyName),U.standard(U.variableName),U.special(U.variableName)],color:e.colors.syntax.base.function},{tag:U.definition(U.variableName),color:a.variableGlobal||e.colors.syntax.base.variable},{tag:[U.variableName,U.local(U.variableName),U.constant(U.variableName),U.literal],color:e.colors.syntax.base.variable},{tag:U.propertyName,color:a.variableProperty||e.colors.syntax.base.variable},{tag:U.attributeName,color:a.variableOther||e.colors.syntax.base.variable},{tag:[U.className,U.typeName,U.namespace],color:e.colors.syntax.base.type},{tag:[U.tagName,U.labelName,U.annotation,U.macroName],color:a.tag||e.colors.syntax.base.keyword},{tag:U.link,color:a.url||e.colors.syntax.base.function,textDecoration:`underline`},{tag:[U.punctuation,U.separator,U.bracket,U.paren,U.brace,U.squareBracket,U.angleBracket],color:a.punctuation||e.colors.syntax.base.comment}]);return t?.syntaxColors===!1?[s]:[s,oe(ge,{fallback:!0}),oe(ae),oe(c),oe(l)]}var di=180,fi=he.define(),pi=1,mi=2,hi=4,gi=new Map,_i=(e,t)=>{let n=`${e}|${t}`,r=gi.get(n);if(r)return r;let i=``;e&&(i+=`color:${e};`),t&pi&&(i+=`font-style:italic;`),t&mi&&(i+=`font-weight:bold;`),t&hi&&(i+=`text-decoration:underline;`);let a=B.mark({attributes:{style:i}});return gi.set(n,a),a},vi=(e,t)=>{let n=new pe,r=e.state.doc,i=Math.min(t.length,r.lines);for(let e=0;e<i;e+=1){let i=t[e];if(!i||i.length===0)continue;let a=r.line(e+1),o=a.from;for(let[e,t,r]of i){if(e<=0)continue;let i=o,s=Math.min(o+e,a.to);o+=e,!(s<=i)&&(!t&&!r||n.add(i,s,_i(t,r)))}}return n.finish()},yi=ve.define({create(){return B.none},update(e,t){let n=e.map(t.changes);for(let e of t.effects)e.is(fi)&&(n=e.value);return n},provide:e=>V.decorations.from(e)}),bi=e=>ce.fromClass(class{timer;generation=0;abortController;constructor(e){this.tokenize(e)}update(e){e.docChanged&&this.schedule(e.view)}schedule(e){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.tokenize(e)},di)}async tokenize(t){let n=++this.generation;this.abortController?.abort();let r=new AbortController;this.abortController=r;let i=t.state.doc.toString(),a=await Jt(i,e.language,e.themeName,e.theme,{signal:r.signal,priority:`visible`});a&&(r.signal.aborted||n===this.generation&&t.state.doc.length===i.length&&t.dispatch({effects:fi.of(vi(t,a))}))}destroy(){this.timer&&clearTimeout(this.timer),this.abortController?.abort(),this.abortController=void 0}}),xi=e=>[yi,bi(e)],Si=e=>{let t=(0,X.c)(11),{currentMode:n,onToggle:r}=e,i=n===`preview`,a=i?`Switch to edit mode`:`Switch to preview mode`,o=i?`Edit`:`Preview`,s;t[0]===i?s=t[1]:(s=i?(0,Z.jsx)(Y,{name:`eye`,className:`size-4`,"aria-hidden":`true`}):(0,Z.jsx)(Y,{name:`eye-off`,className:`size-4`,"aria-hidden":`true`}),t[0]=i,t[1]=s);let c;t[2]!==a||t[3]!==r||t[4]!==s?(c=(0,Z.jsx)(_t,{asChild:!0,children:(0,Z.jsx)(q,{variant:`ghost`,size:`sm`,onClick:r,"aria-label":a,className:`h-5 w-5 p-0`,children:s})}),t[2]=a,t[3]=r,t[4]=s,t[5]=c):c=t[5];let l;t[6]===o?l=t[7]:(l=(0,Z.jsx)(vt,{sideOffset:8,children:o}),t[6]=o,t[7]=l);let u;return t[8]!==c||t[9]!==l?(u=(0,Z.jsxs)(yt,{children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10],u},Ci=w()(E(T((e,t)=>({selectedProfileId:null,defaultGitIdentityId:null,profiles:[],globalIdentity:null,discoveredCredentials:[],isLoading:!1,setSelectedProfile:t=>{e({selectedProfileId:t})},loadProfiles:async()=>{e({isLoading:!0});let n=t().profiles;try{return e({profiles:await $e(),isLoading:!1}),!0}catch(t){return console.error(`Failed to load git identity profiles:`,t),e({profiles:n,isLoading:!1}),!1}},loadGlobalIdentity:async()=>{try{let t=await et();return t&&t.userName&&t.userEmail?e({globalIdentity:{id:`global`,name:`Global Identity`,userName:t.userName,userEmail:t.userEmail,authType:t.sshCommand?`ssh`:void 0,sshKey:t.sshCommand?t.sshCommand.replace(`ssh -i `,``):null,color:`info`,icon:`house`}}):e({globalIdentity:null}),!0}catch(t){return console.error(`Failed to load global git identity:`,t),e({globalIdentity:null}),!1}},loadDiscoveredCredentials:async()=>{try{return e({discoveredCredentials:await it()}),!0}catch(t){return console.error(`Failed to discover git credentials:`,t),e({discoveredCredentials:[]}),!1}},loadDefaultGitIdentityId:async()=>{let t=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null};try{let n=null;if(n===null){let e=s()?.settings;if(e)try{n=t(((await e.load())?.settings||{}).defaultGitIdentityId)}catch{}}if(n===null)try{let e=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});e.ok&&(n=t((await e.json().catch(()=>null))?.defaultGitIdentityId))}catch{}return e({defaultGitIdentityId:n}),!0}catch(e){return console.error(`Failed to load default git identity setting:`,e),!1}},setDefaultGitIdentityId:async t=>{try{let n=typeof t==`string`?t.trim():``,r=n.length>0?n:``;return await _({defaultGitIdentityId:r}),e({defaultGitIdentityId:r.length>0?r:null}),!0}catch(e){return console.error(`Failed to save default git identity setting:`,e),!1}},createProfile:async e=>{try{let n={...e,id:e.id||`profile-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,color:e.color||`keyword`,icon:e.icon||`branch`};return await rt(n),await t().loadProfiles(),!0}catch(e){return console.error(`Failed to create git identity profile:`,e),!1}},updateProfile:async(e,n)=>{try{let r=t().profiles.find(t=>t.id===e);if(!r)throw Error(`Profile not found`);let i={...r,...n};return await Qe(e,i),await t().loadProfiles(),!0}catch(e){return console.error(`Failed to update git identity profile:`,e),!1}},deleteProfile:async n=>{try{return await tt(n),t().selectedProfileId===n&&e({selectedProfileId:null}),await t().loadProfiles(),!0}catch(e){return console.error(`Failed to delete git identity profile:`,e),!1}},getProfileById:e=>{let{profiles:n,globalIdentity:r}=t();return e===`global`?r||void 0:n.find(t=>t.id===e)},getUnimportedCredentials:()=>{let{profiles:e,discoveredCredentials:n}=t();return n.filter(t=>!e.some(e=>e.authType===`token`&&e.host===t.host))}}),{name:`git-identities-store`,storage:F(),partialize:e=>({selectedProfileId:e.selectedProfileId})}),{name:`git-identities-store`}));typeof window<`u`&&(window.__zustand_git_identities_store__=Ci);var wi=`w-full max-w-[30rem]`,Ti=e=>{let t=(0,X.c)(23),{title:n,description:r,settingsItem:i,titleAccessory:a,headerAction:o,children:s,className:c,contentClassName:l}=e,u;t[0]===n?u=t[1]:(u=(0,Z.jsx)(`span`,{className:`truncate`,children:n}),t[0]=n,t[1]=u);let d;t[2]!==u||t[3]!==a?(d=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[u,a]}),t[2]=u,t[3]=a,t[4]=d):d=t[4];let f;t[5]===o?f=t[6]:(f=o?(0,Z.jsx)(`div`,{className:`shrink-0`,children:o}):null,t[5]=o,t[6]=f);let p;t[7]!==d||t[8]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[d,f]}),t[7]=d,t[8]=f,t[9]=p):p=t[9];let m;t[10]===l?m=t[11]:(m=K(`yuri-settings-group-row`,l),t[10]=l,t[11]=m);let h;t[12]!==s||t[13]!==m?(h=(0,Z.jsx)(`div`,{className:m,children:s}),t[12]=s,t[13]=m,t[14]=h):h=t[14];let g;t[15]!==r||t[16]!==p||t[17]!==h?(g=(0,Z.jsx)(xr,{className:`yuri-settings-detail-group`,label:p,description:r,children:h}),t[15]=r,t[16]=p,t[17]=h,t[18]=g):g=t[18];let _;return t[19]!==c||t[20]!==i||t[21]!==g?(_=(0,Z.jsx)(`div`,{"data-settings-item":i,className:c,children:g}),t[19]=c,t[20]=i,t[21]=g,t[22]=_):_=t[22],_},Ei=450,Di=({projectRef:e=null})=>{let{t}=G(),{isMobile:n,isTablet:r}=Ht(),i=n||r,a=Fe(e=>e.getActiveProject()),o=e?.path??a?.path??null,s=Ne(e=>e.getWorktreeMetadata),c=We(),l=A(e=>e.homeDirectory),[u,d]=Q.useState([]),[f,p]=Q.useState(!1),[m,h]=Q.useState(!1),[g,_]=Q.useState(null),[v,y]=Q.useState(null),[b,x]=Q.useState([]),[S,C]=Q.useState(!1),w=Q.useRef(!1),T=Q.useMemo(()=>e?.id&&e?.path?{id:e.id,path:e.path}:!a?.id||!o?null:{id:a.id,path:o},[a?.id,o,e?.id,e?.path]),E=Q.useCallback(async()=>{if(!(!T||v===!1))try{let e=await lt(T);x(e)}catch{}},[T,v]);Q.useEffect(()=>{if(!o)return;let e=!1;return y(null),(async()=>{try{let t=await nt(o);if(e)return;y(t)}catch{}})(),()=>{e=!0}},[o]),Q.useEffect(()=>{if(!T){x([]),C(!1);return}if(v===!1){x([]),C(!1);return}let e=!1;return C(!0),x([]),(async()=>{try{let t=await lt(T);if(e)return;x(t)}catch{}finally{e||C(!1)}})(),()=>{e=!0}},[T,v]),Q.useEffect(()=>{if(!T)return;let e=!1;return h(!0),(async()=>{try{let[t,n]=await Promise.all([ze(T),Ve(T)]);if(!e){let e=t.length>0?t:[``];d(e),_(JSON.stringify(e)),p(n)}}catch{e||(d([``]),_(JSON.stringify([``])),p(!1))}finally{e||h(!1)}})(),()=>{e=!0}},[T]);let D=Q.useCallback(async e=>{if(!T)return!1;let n=e.filter(e=>e.trim().length>0);try{return await Be(T,n)?(_(JSON.stringify(e)),!0):(J.error(t(`settings.yuri.worktrees.setup.toast.saveFailed`)),!1)}catch{return J.error(t(`settings.yuri.worktrees.setup.toast.saveFailed`)),!1}},[T,t]),O=Q.useMemo(()=>g!==null&&g!==JSON.stringify(u),[g,u]);Q.useEffect(()=>{if(!O||m||w.current)return;let e=window.setTimeout(()=>{w.current||(w.current=!0,(async()=>{try{await D(u)}finally{w.current=!1}})())},Ei);return()=>{window.clearTimeout(e)}},[O,m,D,u]);let k=Q.useCallback((e,t)=>{d(n=>{let r=[...n];return r[e]=t,r})},[]),j=Q.useCallback(()=>{d(e=>[...e,``])},[]),M=Q.useCallback(e=>{d(t=>{let n=t.filter((t,n)=>n!==e);return n.length>0?n:[``]})},[]),N=Q.useCallback(()=>{!O||w.current||(w.current=!0,(async()=>{try{await D(u)}finally{w.current=!1}})())},[O,D,u]),P=Q.useCallback(e=>{p(e),T&&Ue(T,e)},[T]),F=Q.useCallback(e=>{let t=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),n=t(e.path),r=c.filter(e=>{let r=s(e.id);if(r?.path&&t(r.path)===n)return!0;let i=e.directory;return!!(i&&t(i)===n)}),i=new Set(r.map(e=>e.id)),a=[...je.getState().activeSessions,...je.getState().archivedSessions],o=e=>{let t=a.filter(t=>{let n=t.parentID;return n&&e.has(n)});if(t.length===0)return[];let n=new Set(t.map(e=>e.id));return[...t,...o(n)]},l=o(i),u=new Set,d=[...r,...l].filter(e=>!u.has(e.id)&&(u.add(e.id),!0));Me.requestDelete({sessions:d,mode:`worktree`,worktree:e})},[c,s]),I=Q.useMemo(()=>c.map(e=>e.id).join(`,`),[c]);Q.useEffect(()=>{v&&o&&E()},[I,v,o,E]);let L=(0,Z.jsxs)(yt,{children:[(0,Z.jsx)(_t,{asChild:!0,children:(0,Z.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,Z.jsxs)(vt,{sideOffset:8,className:`max-w-xs`,children:[t(`settings.yuri.worktrees.setup.tooltipPrefix`),` `,(0,Z.jsx)(`code`,{className:`font-mono text-xs bg-sidebar-accent/50 px-1 rounded`,children:`$ROOT_PROJECT_PATH`}),` `,t(`settings.yuri.worktrees.setup.tooltipSuffix`)]})]}),R=(0,Z.jsxs)(yt,{children:[(0,Z.jsx)(_t,{asChild:!0,children:(0,Z.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,Z.jsx)(vt,{sideOffset:8,className:`max-w-xs`,children:t(`settings.yuri.worktrees.list.tooltip`)})]});return o?v===!1?(0,Z.jsx)(Ti,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.worktrees.state.gitOnly`)})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ti,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,titleAccessory:L,children:m?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.worktrees.setup.loading`)}):(0,Z.jsxs)(`div`,{className:K(`flex flex-col gap-2`,wi),children:[u.map((e,n)=>(0,Z.jsxs)(`div`,{className:`yuri-settings-group-row flex w-full items-center gap-2`,children:[(0,Z.jsx)(gt,{value:e,onChange:e=>k(n,e.target.value),onBlur:N,placeholder:t(`settings.yuri.worktrees.setup.commandPlaceholder`),className:`min-w-0 flex-1 font-mono text-xs`}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>M(n),className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":t(`settings.yuri.worktrees.setup.removeCommandAria`),children:(0,Z.jsx)(Y,{name:`close`,className:`h-4 w-4`})})]},n)),(0,Z.jsxs)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:j,children:[(0,Z.jsx)(Y,{name:`add`,className:`h-3.5 w-3.5`}),t(`settings.yuri.worktrees.setup.addCommand`)]}),(0,Z.jsxs)(`label`,{"data-settings-item":`projects.worktree.setup.wait`,className:`flex cursor-pointer items-center gap-2 py-1`,children:[(0,Z.jsx)(at,{checked:f,onChange:P,ariaLabel:t(`settings.yuri.worktrees.setup.waitForCommandsAria`)}),(0,Z.jsx)(`span`,{className:K(`typography-ui-label font-normal`,f?`text-foreground`:`text-foreground/60`),children:t(`settings.yuri.worktrees.setup.waitForCommands`)})]})]})}),(0,Z.jsx)(Ti,{title:t(`settings.yuri.worktrees.list.title`),titleAccessory:R,children:S?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.worktrees.list.loading`)}):b.length===0?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground/70`,children:t(`settings.yuri.worktrees.list.empty`)}):(0,Z.jsx)(`div`,{className:K(`space-y-1`,wi),children:b.map(e=>(0,Z.jsxs)(`div`,{className:`group flex w-full items-center gap-2 py-1.5`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`p`,{className:`typography-meta min-w-0 truncate text-foreground`,children:e.label||e.branch||t(`settings.yuri.worktrees.list.detachedHead`)}),(0,Z.jsx)(`span`,{className:`typography-micro flex-shrink-0 self-center rounded bg-sidebar-accent/40 px-1.5 py-[1px] leading-none text-muted-foreground/60`,children:`OpenCode`})]}),(0,Z.jsx)(`p`,{className:`typography-micro truncate text-muted-foreground/60`,children:Oe(e.path,l)})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>F(e),className:K(`flex h-7 w-7 shrink-0 items-center justify-center rounded text-muted-foreground/50 transition-opacity hover:bg-destructive/10 hover:text-destructive focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,i?`opacity-100`:`opacity-0 group-hover:opacity-100`),"aria-label":t(`settings.yuri.worktrees.list.deleteWorktreeAria`,{name:e.branch||e.label||e.path}),children:(0,Z.jsx)(Y,{name:`delete-bin`,className:`h-4 w-4`})})]},e.path))})})]}):(0,Z.jsx)(Ti,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.worktrees.state.selectProject`)})})},Oi=(e,t)=>t.updatedAtMs-e.updatedAtMs,ki=w((e,t)=>({instances:[],statusesById:{},importCandidates:[],isLoading:!1,isSaving:!1,isImportsLoading:!1,initialized:!1,listenerReady:!1,error:null,load:async()=>{if(!t().isLoading){e({isLoading:!0,error:null});try{let[n,r]=await Promise.all([Mt(),bt()]),i={};for(let e of r.sort(Oi))i[e.id]=e;t().listenerReady||await Pt(t=>{e(e=>({statusesById:{...e.statusesById,[t.id]:t}}))}),e({instances:n.instances,statusesById:i,isLoading:!1,initialized:!0,listenerReady:!0})}catch(t){e({isLoading:!1,error:t instanceof Error?t.message:String(t)})}}},loadImports:async()=>{if(!t().isImportsLoading){e({isImportsLoading:!0,error:null});try{e({importCandidates:await Tt(),isImportsLoading:!1})}catch(t){e({isImportsLoading:!1,error:t instanceof Error?t.message:String(t)})}}},refreshStatuses:async()=>{try{let t=await bt(),n={};for(let e of t.sort(Oi))n[e.id]=e;e({statusesById:n})}catch(t){e({error:t instanceof Error?t.message:String(t)})}},setInstances:async n=>{e({isSaving:!0,error:null});try{await jt({instances:n}),e({instances:n,isSaving:!1}),await t().refreshStatuses()}catch(t){throw e({isSaving:!1,error:t instanceof Error?t.message:String(t)}),t}},upsertInstance:async e=>{let n=t().instances,r=n.some(t=>t.id===e.id)?n.map(t=>t.id===e.id?e:t):[e,...n];await t().setInstances(r)},createFromCommand:async(e,n,r)=>{let i=Ct(e,n);r&&r.trim()&&(i.nickname=r.trim()),await t().upsertInstance(i)},removeInstance:async n=>{await Rt(n).catch(()=>void 0);let r=t().instances.filter(e=>e.id!==n);await t().setInstances(r),e(e=>{let t={...e.statusesById};return delete t[n],{statusesById:t}})},connect:async n=>{e({error:null});try{await Et(n),await t().refreshStatuses()}catch(t){throw e({error:t instanceof Error?t.message:String(t)}),t}},disconnect:async n=>{e({error:null});try{await Rt(n),await t().refreshStatuses()}catch(t){throw e({error:t instanceof Error?t.message:String(t)}),t}},retry:async e=>{await t().connect(e)},getStatus:e=>t().statusesById[e]||null,clearError:()=>e({error:null})})),Ai=450,ji=()=>S(),Mi=()=>({id:ji(),name:``,command:``,icon:`play`}),Ni=({projectRef:e})=>{let{t}=G(),n=Q.useMemo(()=>m(),[]),r=ki(e=>e.instances),i=ki(e=>e.load),[a,o]=Q.useState([]),[s,c]=Q.useState(!1),[l,u]=Q.useState(null),[d,f]=Q.useState({}),p=Q.useRef(!1),h=Q.useRef(null);Q.useEffect(()=>{n&&i().catch(()=>void 0)},[n,i]),Q.useEffect(()=>{let t=!1;return c(!0),(async()=>{try{let n=await Pe(e);if(t)return;o(n.actions),u(JSON.stringify({actions:n.actions}))}catch{if(t)return;o([]),u(JSON.stringify({actions:[]}))}finally{t||c(!1)}})(),()=>{t=!0}},[e]);let g=Q.useMemo(()=>n?hn(r):[],[r,n]),_=Q.useMemo(()=>a.some(e=>e.name.trim().length===0||e.command.trim().length===0)?t(`settings.projects.actions.validation.fillNameAndCommand`):null,[a,t]),v=Q.useMemo(()=>l!==null&&l!==JSON.stringify({actions:a}),[a,l]),y=Q.useCallback(async n=>await Le(e,{actions:n,primaryActionId:null})?(u(JSON.stringify({actions:n})),typeof window<`u`&&window.dispatchEvent(new CustomEvent(vn,{detail:{projectId:e.id}})),!0):(J.error(t(`settings.projects.actions.toast.saveFailed`)),!1),[e,t]);Q.useEffect(()=>{if(!v||s||_||p.current)return;let e=window.setTimeout(()=>{p.current||(p.current=!0,(async()=>{try{await y(a)}finally{p.current=!1}})())},Ai);return()=>{window.clearTimeout(e)}},[a,v,s,y,_]),Q.useEffect(()=>{if(!v||!_||s){_||(h.current=null);return}let e=window.setTimeout(()=>{h.current!==_&&(h.current=_,J.error(_))},1e3);return()=>{window.clearTimeout(e)}},[v,s,_]);let b=Q.useCallback(()=>{let e=Mi();o(t=>[...t,e]),f(t=>({...t,[e.id]:!0}))},[]),x=Q.useCallback(e=>{o(t=>t.filter(t=>t.id!==e)),f(t=>{let n={...t};return delete n[e],n})},[]),S=Q.useCallback((e,t)=>{o(n=>n.map(n=>n.id===e?t(n):n))},[]);return(0,Z.jsxs)(Ti,{title:t(`settings.projects.actions.title`),description:t(`settings.projects.actions.description`),settingsItem:`projects.actions`,headerAction:(0,Z.jsxs)(q,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:b,children:[(0,Z.jsx)(Y,{name:`add`,className:`h-3.5 w-3.5`}),t(`settings.projects.actions.actions.add`)]}),contentClassName:`space-y-0`,children:[s?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.loading`)}):a.length===0?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.empty`)}):(0,Z.jsx)(`div`,{className:K(`space-y-0`,wi),children:a.map(e=>{let r=e.icon||`play`,i=_n[r]||`play`,a=d[e.id]??!1,o=e.name.trim()||t(`settings.projects.actions.state.untitled`);return(0,Z.jsxs)(en,{open:a,onOpenChange:t=>{f(n=>({...n,[e.id]:t}))},className:`py-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsxs)($t,{className:`group flex-1 justify-start gap-2 rounded-md px-0 pr-1 py-1 hover:bg-[var(--interactive-hover)] focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,children:[a?(0,Z.jsx)(Y,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground`}):(0,Z.jsx)(Y,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground`}),(0,Z.jsx)(Y,{name:i,className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:o})})]}),(0,Z.jsx)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal h-7 w-7 px-0 text-muted-foreground hover:text-[var(--status-error)]`,onClick:()=>x(e.id),children:(0,Z.jsx)(Y,{name:`delete-bin`,className:`h-3.5 w-3.5`})})]}),(0,Z.jsx)(Qt,{className:`pt-1.5`,children:(0,Z.jsxs)(`div`,{className:`space-y-2 pb-4 pl-3 pr-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,Z.jsxs)(zt,{children:[(0,Z.jsx)(Bt,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-[var(--interactive-border)] text-foreground hover:bg-[var(--interactive-hover)]`,"aria-label":t(`settings.projects.actions.field.selectIconAria`),children:(0,Z.jsx)(Y,{name:i,className:`h-4 w-4`})})}),(0,Z.jsx)(Ft,{align:`start`,className:`w-56 p-2`,children:(0,Z.jsx)(`div`,{className:`grid grid-cols-6 gap-1`,children:gn.map(n=>{let r=n.Icon,i=(e.icon||`play`)===n.key;return(0,Z.jsx)(`button`,{type:`button`,onClick:()=>S(e.id,e=>({...e,icon:n.key})),className:K(`inline-flex h-8 w-8 items-center justify-center rounded-md border border-transparent text-foreground hover:bg-[var(--interactive-hover)]`,i&&`border-[var(--primary-base)] bg-[var(--primary-base)]/10 text-[var(--primary-base)]`),"aria-label":t(`settings.projects.actions.field.iconAria`,{icon:n.label}),children:(0,Z.jsx)(Y,{name:r,className:`h-4 w-4`})},n.key)})})})]}),(0,Z.jsx)(gt,{value:e.name,onChange:t=>S(e.id,e=>({...e,name:t.target.value})),placeholder:t(`settings.projects.actions.field.actionNamePlaceholder`),className:`h-7 flex-1 min-w-0`})]}),(0,Z.jsxs)(`div`,{className:`py-1`,children:[(0,Z.jsx)(`p`,{className:`typography-meta mb-0.5 text-muted-foreground`,children:t(`settings.projects.actions.field.command`)}),(0,Z.jsx)(Gt,{embedded:!0,value:e.command,onChange:t=>S(e.id,e=>({...e,command:t.target.value})),placeholder:t(`settings.projects.actions.field.commandPlaceholder`),className:`min-h-[88px] w-full font-mono text-xs`})]}),(0,Z.jsxs)(`div`,{className:`py-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Z.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:t(`settings.projects.actions.field.autoOpenUrl`)}),(0,Z.jsxs)(`div`,{className:`group flex cursor-pointer items-center gap-2`,role:`button`,tabIndex:0,"aria-pressed":e.autoOpenUrl===!0,onClick:()=>S(e.id,e=>({...e,...e.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})),onKeyDown:t=>{(t.key===` `||t.key===`Enter`)&&(t.preventDefault(),S(e.id,e=>({...e,...e.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})))},children:[(0,Z.jsx)(at,{checked:e.autoOpenUrl===!0,onChange:t=>S(e.id,e=>({...e,...t?{autoOpenUrl:!0}:{autoOpenUrl:void 0}})),ariaLabel:t(`settings.projects.actions.field.autoOpenUrlForAria`,{title:o})}),(0,Z.jsx)(`span`,{className:`typography-ui-label font-normal text-foreground/80`,children:t(`settings.projects.actions.field.autoOpenUrlDescription`)})]})]}),e.autoOpenUrl===!0?(0,Z.jsxs)(`div`,{className:`mt-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(gt,{value:e.openUrl||``,onChange:t=>S(e.id,e=>({...e,openUrl:t.target.value})),placeholder:t(`settings.projects.actions.field.overrideUrlPlaceholder`),className:`h-7 w-full max-w-[24rem]`}),(0,Z.jsxs)(yt,{children:[(0,Z.jsx)(_t,{asChild:!0,children:(0,Z.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/60 cursor-help`})}),(0,Z.jsx)(vt,{sideOffset:8,className:`max-w-xs`,children:t(`settings.projects.actions.field.overrideUrlTooltip`)})]})]}),n?(0,Z.jsxs)(`div`,{className:`mt-2`,children:[(0,Z.jsx)(`p`,{className:`typography-meta mb-0.5 text-muted-foreground`,children:t(`settings.projects.actions.field.desktopSshForward`)}),g.length>0?(0,Z.jsxs)(dt,{value:e.desktopOpenSshForward&&g.some(t=>t.id===e.desktopOpenSshForward)?e.desktopOpenSshForward:`__none__`,onValueChange:t=>{S(e.id,e=>({...e,...t===`__none__`?{desktopOpenSshForward:void 0}:{desktopOpenSshForward:t}}))},children:[(0,Z.jsx)(ct,{className:`h-7 w-full`,children:(0,Z.jsx)(ht,{placeholder:t(`settings.projects.actions.field.useOutputManualUrl`)})}),(0,Z.jsxs)(ut,{children:[(0,Z.jsx)(ot,{value:`__none__`,children:t(`settings.projects.actions.field.useOutputManualUrl`)}),g.map(e=>(0,Z.jsx)(ot,{value:e.id,children:e.label},e.id))]})]}):(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.noDesktopSshForwards`)})]}):null]}):null]})]})})]},e.id)})}),_&&a.length>0?(0,Z.jsx)(`p`,{className:`typography-meta text-[var(--status-warning)]`,children:_}):null]})},Pi=e=>{let t=(0,X.c)(123),{form:n}=e,{t:r}=G(),{currentTheme:i}=Ke(),{name:a,setName:o,icon:s,setIcon:c,color:l,setColor:u,iconBackground:d,setIconBackground:f,parsedDefaultModel:p,handleDefaultModelChange:m,isUploadingIcon:h,isRemovingCustomIcon:g,isDiscoveringIcon:_,pendingRemoveImageIcon:v,setPendingRemoveImageIcon:y,pendingUploadIconPreviewUrl:b,setPreviewImageFailed:x,hasPendingUploadImageIcon:S,hasCustomIcon:C,effectiveHasImageIcon:w,hasRemovableImageIcon:T,showImagePreview:E,fileInputRef:D,handleUploadIcon:O,handleRemoveImageIcon:k,handleDiscoverIcon:A,currentIconImage:j,project:M}=n;if(!M)return null;let N=l?ft[l]??null:null,P;t[0]===r?P=t[1]:(P=r(`settings.projects.page.field.projectName`),t[0]=r,t[1]=P);let F;t[2]===o?F=t[3]:(F=e=>o(e.target.value),t[2]=o,t[3]=F);let I;t[4]===r?I=t[5]:(I=r(`settings.projects.page.field.projectNamePlaceholder`),t[4]=r,t[5]=I);let L;t[6]!==a||t[7]!==F||t[8]!==I?(L=(0,Z.jsx)(gt,{value:a,onChange:F,placeholder:I}),t[6]=a,t[7]=F,t[8]=I,t[9]=L):L=t[9];let R;t[10]!==P||t[11]!==L?(R=(0,Z.jsx)(Sr,{label:P,itemId:`projects.name`,children:L}),t[10]=P,t[11]=L,t[12]=R):R=t[12];let z;t[13]===r?z=t[14]:(z=r(`settings.projects.page.field.defaultModel`),t[13]=r,t[14]=z);let ee;t[15]===r?ee=t[16]:(ee=r(`settings.projects.page.field.defaultModelDescription`),t[15]=r,t[16]=ee);let te;t[17]!==m||t[18]!==p.modelId||t[19]!==p.providerId?(te=(0,Z.jsx)(wt,{providerId:p.providerId,modelId:p.modelId,onChange:m,className:`yuri-settings-inline-value`}),t[17]=m,t[18]=p.modelId,t[19]=p.providerId,t[20]=te):te=t[20];let ne;t[21]!==z||t[22]!==ee||t[23]!==te?(ne=(0,Z.jsx)(Sr,{label:z,description:ee,descriptionPlacement:`outside`,itemId:`projects.default-model`,children:te}),t[21]=z,t[22]=ee,t[23]=te,t[24]=ne):ne=t[24];let B;t[25]===r?B=t[26]:(B=r(`settings.projects.page.field.accentColor`),t[25]=r,t[26]=B);let re;t[27]===u?re=t[28]:(re=()=>u(null),t[27]=u,t[28]=re);let V=l===null?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-border/40 hover:border-border hover:bg-[var(--surface-muted)]`,ie;t[29]===V?ie=t[30]:(ie=K(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,V),t[29]=V,t[30]=ie);let ae;t[31]===r?ae=t[32]:(ae=r(`settings.projects.page.field.none`),t[31]=r,t[32]=ae);let oe;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,Z.jsx)(Y,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[33]=oe):oe=t[33];let se;t[34]!==re||t[35]!==ie||t[36]!==ae?(se=(0,Z.jsx)(`button`,{type:`button`,onClick:re,className:ie,title:ae,children:oe}),t[34]=re,t[35]=ie,t[36]=ae,t[37]=se):se=t[37];let ce;t[38]!==l||t[39]!==u?(ce=mt.map(e=>(0,Z.jsx)(`button`,{type:`button`,onClick:()=>u(e.key),className:K(`h-7 w-7 rounded-md border transition-colors`,l===e.key?`border-2 border-foreground ring-1 ring-[var(--primary-base)]/40`:`border-transparent hover:border-border/70`),style:{backgroundColor:e.cssVar},title:e.label},e.key)),t[38]=l,t[39]=u,t[40]=ce):ce=t[40];let le;t[41]!==se||t[42]!==ce?(le=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[se,ce]}),t[41]=se,t[42]=ce,t[43]=le):le=t[43];let ue;t[44]!==B||t[45]!==le?(ue=(0,Z.jsx)(Sr,{label:B,itemId:`projects.accent-color`,children:le}),t[44]=B,t[45]=le,t[46]=ue):ue=t[46];let de;t[47]===r?de=t[48]:(de=r(`settings.projects.page.field.projectIcon`),t[47]=r,t[48]=de);let fe;t[49]===O?fe=t[50]:(fe=e=>{let t=e.target.files?.[0]??null;O(t),e.currentTarget.value=``},t[49]=O,t[50]=fe);let H;t[51]!==D||t[52]!==fe?(H=(0,Z.jsx)(`input`,{ref:D,type:`file`,accept:`image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg`,className:`hidden`,onChange:fe}),t[51]=D,t[52]=fe,t[53]=H):H=t[53];let pe;t[54]===c?pe=t[55]:(pe=()=>c(null),t[54]=c,t[55]=pe);let me=s===null?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-border/40 hover:border-border hover:bg-[var(--surface-muted)]`,he;t[56]===me?he=t[57]:(he=K(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,me),t[56]=me,t[57]=he);let ge;t[58]===r?ge=t[59]:(ge=r(`settings.projects.page.field.none`),t[58]=r,t[59]=ge);let _e;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,Z.jsx)(Y,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[60]=_e):_e=t[60];let ve;t[61]!==pe||t[62]!==he||t[63]!==ge?(ve=(0,Z.jsx)(`button`,{type:`button`,onClick:pe,className:he,title:ge,children:_e}),t[61]=pe,t[62]=he,t[63]=ge,t[64]=ve):ve=t[64];let ye;t[65]!==N||t[66]!==s||t[67]!==c?(ye=pt.map(e=>{let t=e.Icon;return(0,Z.jsx)(`button`,{type:`button`,onClick:()=>c(e.key),className:K(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,s===e.key?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-transparent hover:border-border hover:bg-[var(--surface-muted)]`),title:e.label,children:(0,Z.jsx)(Y,{name:t,className:`w-4 h-4`,style:N&&s===e.key?{color:N}:void 0})},e.key)}),t[65]=N,t[66]=s,t[67]=c,t[68]=ye):ye=t[68];let U;t[69]!==ve||t[70]!==ye?(U=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[ve,ye]}),t[69]=ve,t[70]=ye,t[71]=U):U=t[71];let be;t[72]!==j||t[73]!==i||t[74]!==w||t[75]!==S||t[76]!==d||t[77]!==b||t[78]!==M||t[79]!==x||t[80]!==E||t[81]!==r?(be=w&&E&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Z.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:r(`settings.projects.page.field.preview`)}),(0,Z.jsx)(`span`,{className:`inline-flex h-7 w-7 items-center justify-center rounded-md border border-border/60 bg-[var(--surface-elevated)] p-1`,children:(0,Z.jsx)(`span`,{className:`inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]`,style:d?{backgroundColor:d}:void 0,children:S&&b?(0,Z.jsx)(`img`,{src:b,alt:``,className:`h-full w-full object-contain`,draggable:!1,onError:()=>x(!0)}):(0,Z.jsx)(st,{project:{...M,iconImage:j??M.iconImage},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:`h-full w-full object-contain`,onError:()=>x(!0)})})})]}),t[72]=j,t[73]=i,t[74]=w,t[75]=S,t[76]=d,t[77]=b,t[78]=M,t[79]=x,t[80]=E,t[81]=r,t[82]=be):be=t[82];let W;t[83]!==w||t[84]!==d||t[85]!==f||t[86]!==r?(W=w&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,Z.jsx)(`input`,{type:`color`,value:d??`#000000`,onChange:e=>f(e.target.value),className:`h-7 w-9 cursor-pointer rounded border border-border bg-transparent p-1`,"aria-label":r(`settings.projects.page.field.projectIconBackgroundAria`)}),(0,Z.jsx)(gt,{value:d??``,onChange:e=>f(e.target.value),placeholder:`#000000`,className:`h-7 w-[8rem]`}),(0,Z.jsx)(q,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>f(null),className:`h-7 w-7 p-0`,"aria-label":r(`settings.projects.page.field.clearIconBackgroundAria`),title:r(`settings.projects.page.field.clearBackground`),disabled:!d,children:(0,Z.jsx)(Y,{name:`close`,className:`h-3.5 w-3.5`})})]}),t[83]=w,t[84]=d,t[85]=f,t[86]=r,t[87]=W):W=t[87];let xe;t[88]!==D||t[89]!==A||t[90]!==C||t[91]!==_||t[92]!==h||t[93]!==r?(xe=!C&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(q,{size:`xs`,className:`h-6 !font-normal`,onClick:()=>D.current?.click(),disabled:h,children:r(h?`settings.projects.page.actions.uploading`:`settings.projects.page.actions.uploadIcon`)}),(0,Z.jsx)(q,{size:`xs`,className:`h-6 !font-normal`,variant:`outline`,onClick:()=>void A(),disabled:_,children:r(_?`settings.projects.page.actions.discovering`:`settings.projects.page.actions.discoverFavicon`)})]}),t[88]=D,t[89]=A,t[90]=C,t[91]=_,t[92]=h,t[93]=r,t[94]=xe):xe=t[94];let Se;t[95]!==k||t[96]!==T||t[97]!==g||t[98]!==r?(Se=T&&(0,Z.jsx)(q,{size:`xs`,className:`!font-normal`,variant:`outline`,onClick:()=>void k(),disabled:g,children:r(g?`settings.projects.page.actions.removing`:`settings.projects.page.actions.removeProjectIcon`)}),t[95]=k,t[96]=T,t[97]=g,t[98]=r,t[99]=Se):Se=t[99];let Ce;t[100]!==g||t[101]!==v||t[102]!==y||t[103]!==r?(Ce=v&&(0,Z.jsx)(q,{size:`xs`,className:`!font-normal`,variant:`outline`,onClick:()=>y(!1),disabled:g,children:r(`settings.projects.page.actions.undoRemove`)}),t[100]=g,t[101]=v,t[102]=y,t[103]=r,t[104]=Ce):Ce=t[104];let we;t[105]!==xe||t[106]!==Se||t[107]!==Ce?(we=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[xe,Se,Ce]}),t[105]=xe,t[106]=Se,t[107]=Ce,t[108]=we):we=t[108];let Te;t[109]!==H||t[110]!==U||t[111]!==be||t[112]!==W||t[113]!==we?(Te=(0,Z.jsxs)(`div`,{className:`flex w-full flex-col items-end gap-2`,children:[H,U,be,W,we]}),t[109]=H,t[110]=U,t[111]=be,t[112]=W,t[113]=we,t[114]=Te):Te=t[114];let Ee;t[115]!==de||t[116]!==Te?(Ee=(0,Z.jsx)(Sr,{label:de,itemId:`projects.icon`,children:Te}),t[115]=de,t[116]=Te,t[117]=Ee):Ee=t[117];let De;return t[118]!==ue||t[119]!==Ee||t[120]!==R||t[121]!==ne?(De=(0,Z.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[R,ne,ue,Ee]}),t[118]=ue,t[119]=Ee,t[120]=R,t[121]=ne,t[122]=De):De=t[122],De},Fi=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,Ii=e=>{if(!e)return null;let t=e.trim();return t&&Fi.test(t)?t.toLowerCase():null},Li=e=>{let{t}=G(),n=Fe(e=>e.uploadProjectIcon),r=Fe(e=>e.removeProjectIcon),i=Fe(e=>e.discoverProjectIcon),a=Fe(t=>e?t.projects.find(t=>t.id===e.id)?.iconImage??null:null),[o,s]=Q.useState(``),[c,l]=Q.useState(null),[u,d]=Q.useState(null),[f,p]=Q.useState(null),[m,h]=Q.useState(void 0),[g,_]=Q.useState(!1),[v,y]=Q.useState(!1),[b,x]=Q.useState(!1),[S,C]=Q.useState(!1),[w,T]=Q.useState(null),[E,D]=Q.useState(null),[O,k]=Q.useState(!1),A=Q.useRef(null),j=Q.useCallback(()=>{T(null),D(e=>(e&&URL.revokeObjectURL(e),null))},[]),M=e?.id??null;Q.useEffect(()=>{if(!e){s(``),l(null),d(null),p(null),h(void 0);return}s(e.label??``),l(e.icon??null),d(e.color??null),p(e.iconBackground??null),h(e.defaultModel),C(!1),j(),k(!1)},[e,j]),Q.useEffect(()=>()=>{j()},[j]);let N=Q.useMemo(()=>He(m)??{providerId:``,modelId:``},[m]),P=!!e?.iconImage,F=!!(w&&E),I=e?.iconImage?.source===`custom`,L=P&&!S||F,R=L,z=!!(e&&P&&!S),ee=!O&&(F||z),te=!!e&&(o.trim()!==(e?.label??``).trim()||c!==(e?.icon??null)||u!==(e?.color??null)||f!==(e?.iconBackground??null)||(m??void 0)!==(e?.defaultModel??void 0)||S||!!w),ne=Q.useCallback((e,t)=>{h(e&&t?`${e}/${t}`:void 0)},[]),B=Q.useCallback(t=>{!e||!t||g||(C(!1),k(!1),T(t),D(e=>(e&&URL.revokeObjectURL(e),URL.createObjectURL(t))))},[g,e]),re=Q.useCallback(()=>{!e||!R||v||(F&&j(),C(!!P),k(!1))},[j,F,R,P,v,e]),V=Q.useCallback(async()=>{if(!(!e||b)){j(),C(!1),k(!1),x(!0);try{let n=await i(e.id);if(!n.ok){J.error(n.error||t(`settings.projects.page.toast.discoverIconFailed`));return}if(n.skipped){J.success(t(`settings.projects.page.toast.customIconAlreadySet`));return}J.success(t(`settings.projects.page.toast.iconDiscovered`))}finally{x(!1)}}},[j,i,b,e,t]),ie=Q.useCallback(async i=>{let a=i?.silent===!0;if(!e)return null;let s=o.trim();if(!s)return null;if(w){_(!0);let r=await n(e.id,w);if(_(!1),!r.ok)return J.error(r.error||t(`settings.projects.page.toast.uploadIconFailed`)),null;a||J.success(t(`settings.projects.page.toast.iconUpdated`)),j(),C(!1)}let l=S&&!!e.iconImage;if(l){y(!0);let n=await r(e.id);if(y(!1),!n.ok)return J.error(n.error||t(`settings.projects.page.toast.removeIconFailed`)),null;a||J.success(t(`settings.projects.page.toast.iconRemoved`)),C(!1),p(null)}return{label:s,icon:c,color:u,iconBackground:Ii(l?null:f),defaultModel:m??null}},[j,u,m,c,f,o,S,w,e,r,t,n]);return Q.useEffect(()=>{k(!1)},[M,a?.updatedAt]),{name:o,setName:s,icon:c,setIcon:l,color:u,setColor:d,iconBackground:f,setIconBackground:p,defaultModel:m,parsedDefaultModel:N,handleDefaultModelChange:ne,isUploadingIcon:g,isRemovingCustomIcon:v,isDiscoveringIcon:b,pendingRemoveImageIcon:S,setPendingRemoveImageIcon:C,pendingUploadIconFile:w,pendingUploadIconPreviewUrl:E,previewImageFailed:O,setPreviewImageFailed:k,hasStoredImageIcon:P,hasPendingUploadImageIcon:F,hasCustomIcon:I,effectiveHasImageIcon:L,hasRemovableImageIcon:R,showStoredImagePreview:z,showImagePreview:ee,fileInputRef:A,clearPendingUploadIcon:j,handleUploadIcon:B,handleRemoveImageIcon:re,handleDiscoverIcon:V,hasChanges:te,prepareSaveData:ie,currentIconImage:a,project:e}},Ri=450,zi=(e,t)=>{let{t:n}=G(),{hasChanges:r,name:i,icon:a,color:o,iconBackground:s,defaultModel:c,pendingRemoveImageIcon:l,pendingUploadIconFile:u,isUploadingIcon:d,isRemovingCustomIcon:f,prepareSaveData:p}=e,m=Q.useRef(!1);Q.useEffect(()=>{if(!r||!i.trim()||d||f||m.current)return;let e=window.setTimeout(()=>{m.current||(m.current=!0,(async()=>{try{let e=await p({silent:!0});if(e)try{await t(e)}catch{J.error(n(`settings.projects.page.toast.saveFailed`))}}finally{m.current=!1}})())},Ri);return()=>{window.clearTimeout(e)}},[o,c,r,a,s,f,d,i,t,l,u,p,n])},Bi=e=>{let t=(0,X.c)(25),{project:n,onIdentitySave:r}=e,{t:i}=G(),a=Li(n),o;bb0:{if(!n){o=null;break bb0}let e;t[0]!==n.id||t[1]!==n.path?(e={id:n.id,path:n.path},t[0]=n.id,t[1]=n.path,t[2]=e):e=t[2],o=e}let s=o,c;if(t[3]===r?c=t[4]:(c=async e=>{await r(e)},t[3]=r,t[4]=c),zi(a,c),!n||!s)return null;let l;t[5]!==n.path||t[6]!==i?(l=n.path.split(/[\\/]/).filter(Boolean).at(-1)??i(`settings.projects.page.title.default`),t[5]=n.path,t[6]=i,t[7]=l):l=t[7];let u=l,d;t[8]===u?d=t[9]:(d=(0,Z.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:u}),t[8]=u,t[9]=d);let f;t[10]===n.path?f=t[11]:(f=(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,title:n.path,children:n.path}),t[10]=n.path,t[11]=f);let p;t[12]!==d||t[13]!==f?(p=(0,Z.jsxs)(`div`,{className:`px-1`,children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;t[15]===a?m=t[16]:(m=(0,Z.jsx)(Pi,{form:a}),t[15]=a,t[16]=m);let h,g;t[17]===s?(h=t[18],g=t[19]):(h=(0,Z.jsx)(Ni,{projectRef:s}),g=(0,Z.jsx)(Di,{projectRef:s}),t[17]=s,t[18]=h,t[19]=g);let _;return t[20]!==p||t[21]!==m||t[22]!==h||t[23]!==g?(_=(0,Z.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[p,m,h,g]}),t[20]=p,t[21]=m,t[22]=h,t[23]=g,t[24]=_):_=t[24],_};function Vi(e,t,n){return Math.min(n,Math.max(t,e))}function Hi(e){if(!Number.isFinite(e))return 0;let t=String(e);if(t.includes(`e-`)){let[,e]=t.split(`e-`);return Number(e)||0}let n=t.split(`.`);return n.length===2?n[1].length:0}function Ui(e,t){let n=Hi(t);return n<=0?e:Number(e.toFixed(n))}var Wi=Q.forwardRef(({value:e,onValueChange:t,min:n=-1/0,max:r=1/0,step:i=1,className:a,containerClassName:o,onBlur:s,disabled:c,fallbackValue:l,onClear:u,emptyLabel:d=`—`,...f},p)=>{let{t:m}=G(),[h,g]=Q.useState(()=>e===void 0?``:String(e)),{isMobile:_}=Ht(),v=Q.useRef(!1),y=Q.useRef(null),b=Q.useCallback(()=>{if(typeof document>`u`||typeof window>`u`)return;y.current?.();let e=e=>{e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation?.(),y.current?.()},t=window.setTimeout(()=>{y.current?.()},700);y.current=()=>{window.clearTimeout(t),document.removeEventListener(`click`,e,!0),y.current=null},document.addEventListener(`click`,e,!0)},[]);Q.useEffect(()=>()=>{y.current?.()},[]),Q.useEffect(()=>{g(e===void 0?``:String(e))},[e]);let x=Q.useMemo(()=>e===void 0?l===void 0?Number.isFinite(n)?n:0:l:e,[l,n,e]),S=Q.useRef(x);Q.useEffect(()=>{S.current=x},[x]);let C=Q.useCallback(e=>{let a=Ui(Vi(e,n,r),i);S.current=a,t(a)},[r,n,t,i]),w=Q.useCallback(e=>{let t=e.target.value;if(g(t),t.trim()===``){u?.();return}let n=Number(t);Number.isFinite(n)&&C(n)},[C,u]),T=Q.useCallback(t=>{if(h.trim()===``){u||g(e===void 0?``:String(e)),s?.(t);return}let a=Number(h);if(!Number.isFinite(a))g(e===void 0?``:String(e));else{let t=Ui(Vi(a,n,r),i);t===e?S.current=t:C(a),g(String(t))}s?.(t)},[C,h,r,n,s,u,i,e]),E=!!(c||x>=r),D=!!(c||x<=n),O=()=>{D||C(S.current-i)},k=()=>{E||C(S.current+i)},A=e=>t=>{t.preventDefault(),t.stopPropagation(),v.current=!0,b(),e()},j=e=>t=>{if(v.current){v.current=!1,t.preventDefault(),t.stopPropagation();return}e()};return _?(0,Z.jsxs)(`div`,{"data-slot":`number-input`,className:K(`flex h-9 shrink-0 items-stretch overflow-x-hidden overflow-y-hidden rounded-lg border border-border bg-transparent select-none overscroll-contain`,`[-webkit-user-select:none] [-webkit-touch-callout:none]`,`disabled:pointer-events-none disabled:opacity-50`,o),children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.decreaseAria`),disabled:D,onTouchStart:A(O),onClick:j(O),className:K(`grid h-full min-h-0 w-9 place-items-center overflow-x-hidden overflow-y-hidden border-r border-border p-0 leading-none touch-none`,`text-muted-foreground`,`disabled:pointer-events-none disabled:opacity-50`,!D&&`active:bg-interactive-hover`),children:(0,Z.jsx)(Y,{name:`subtract`,className:`block h-4 w-4`})}),(0,Z.jsx)(`div`,{"data-slot":`number-input-value`,className:K(`flex h-full min-w-0 w-14 items-center justify-center bg-transparent px-1.5`,`text-center text-[16px] leading-none text-foreground [font-variant-numeric:tabular-nums]`,a),"aria-live":`polite`,children:e===void 0?d:h}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.increaseAria`),disabled:E,onTouchStart:A(k),onClick:j(k),className:K(`grid h-full min-h-0 w-9 place-items-center overflow-x-hidden overflow-y-hidden border-l border-border p-0 leading-none touch-none`,`text-muted-foreground`,`disabled:pointer-events-none disabled:opacity-50`,!E&&`active:bg-interactive-hover`),children:(0,Z.jsx)(Y,{name:`add`,className:`block h-4 w-4`})})]}):(0,Z.jsxs)(`div`,{"data-slot":`number-input`,className:K(`flex h-7 shrink-0 items-stretch overflow-x-hidden overflow-y-hidden rounded-lg border border-border bg-transparent`,`disabled:pointer-events-none disabled:opacity-50`,o),children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.decreaseAria`),disabled:D,onClick:()=>C(S.current-i),className:K(`flex h-full w-7 items-center justify-center overflow-x-hidden overflow-y-hidden border-r border-border p-0 leading-none touch-manipulation`,`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`,`disabled:pointer-events-none disabled:opacity-50`),children:(0,Z.jsx)(Y,{name:`subtract`,className:`block h-3.5 w-3.5`})}),(0,Z.jsx)(`input`,{...f,"data-slot":`number-input-value`,ref:p,type:`text`,inputMode:f.inputMode??`numeric`,value:h,onChange:w,onBlur:T,disabled:c,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,className:K(`h-full min-w-0 w-14 bg-transparent px-1.5 text-center typography-ui-label leading-none text-foreground [font-variant-numeric:tabular-nums]`,`placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground`,`appearance-none outline-none [appearance:textfield] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,`disabled:pointer-events-none disabled:cursor-not-allowed`,a)}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.increaseAria`),disabled:E,onClick:()=>C(S.current+i),className:K(`flex h-full w-7 items-center justify-center overflow-x-hidden overflow-y-hidden border-l border-border p-0 leading-none touch-manipulation`,`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`,`disabled:pointer-events-none disabled:opacity-50`),children:(0,Z.jsx)(Y,{name:`add`,className:`block h-3.5 w-3.5`})})]})});Wi.displayName=`NumberInput`;function Gi(e){let t=e.indexOf(`/`);if(t!==-1){let n=e.substring(0,t);if(n===`gemini`||n===`antigravity`)return e.substring(t+1)}return e}var Ki={google:[{id:`gemini-auth`,label:`Gemini`,matcher:e=>e.startsWith(`gemini/`),order:1},{id:`antigravity-auth`,label:`Antigravity`,matcher:e=>e.startsWith(`antigravity/`),order:2}]};function qi(e,t){let n=Ki[t]??[];for(let t of n)if(t.matcher(e))return t;return null}function Ji(e){return Ki[e]??[]}function Yi(e){return[...e].sort((e,t)=>e.order-t.order)}function Xi(e,t){let n=new Map;for(let r of Object.keys(e)){let e=qi(r,t)?.id??null;n.has(e)||n.set(e,[]),n.get(e).push(r)}return n}function Zi(e,t,n){let r=new Map;for(let i of e){let e=qi(t(i),n)?.id??null;r.has(e)||r.set(e,[]),r.get(e).push(i)}return r}function Qi(e,t){return t.filter(e=>{let t=e.toLowerCase(),n=t.includes(`/`)?t.split(`/`)[1]:t;return!!(n.startsWith(`gemini-3-`)||n.startsWith(`claude-`))})}var $i=(e,t=``,n=!1)=>R({queryKey:a.scoped(`magpie-quotas`,e,t,n),staleTime:0,retry:!1,queryFn:async({signal:t})=>{let r=await l(`/api/quota/magpie`,{signal:t,query:{...e?{directory:e}:{},...n?{refresh:`1`}:{}}});if(!r.ok)throw Error(`Unable to discover Magpie quota sources`);let i=await r.json();if(!i||!Array.isArray(i.sources)||!i.sources.every(e=>e&&typeof e.id==`string`&&typeof e.name==`string`&&Array.isArray(e.results)&&e.results.every(t=>o(t)&&t.source===`magpie`&&t.sourceId===e.id&&t.providerId.startsWith(`magpie:${e.id}:`))))throw Error(`Invalid Magpie quota response`);return i}}),ea=6e4,ta=0,$=0,na,ra=0,ia=0,aa=0,oa=new Map,sa=e=>{let t=yn.map(e=>e.id),n=typeof e?.usageAutoRefresh==`boolean`&&e.usageAutoRefresh,r=typeof e?.usageRefreshIntervalMs==`number`&&Number.isFinite(e.usageRefreshIntervalMs)?Math.max(3e4,Math.min(3e5,Math.round(e.usageRefreshIntervalMs))):ea,i=e?.usageDisplayMode===`remaining`?`remaining`:`usage`,a=typeof e?.usageShowPredValues==`boolean`&&e.usageShowPredValues,o=Array.isArray(e?.usageDropdownProviders)?e?.usageDropdownProviders:null,s=o?o.filter(e=>typeof e==`string`&&(e.startsWith(`magpie:`)||t.includes(e))):t,c={},l=e?.usageSelectedModels;if(l&&typeof l==`object`)for(let[e,t]of Object.entries(l))Array.isArray(t)&&(c[e]=t.filter(e=>typeof e==`string`));let u={},d=e?.usageExpandedFamilies;if(d&&typeof d==`object`)for(let[e,t]of Object.entries(d))Array.isArray(t)&&(u[e]=t.filter(e=>typeof e==`string`));return{magpieUsageUrl:typeof e?.magpieUsageUrl==`string`?e.magpieUsageUrl:``,magpieHiddenProviders:Array.isArray(e?.magpieHiddenProviders)?e.magpieHiddenProviders.filter(e=>typeof e==`string`&&e.startsWith(`magpie:`)):[],autoRefresh:n,refreshIntervalMs:r,displayMode:i,showPredValues:a,dropdownProviderIds:s,selectedModels:c,expandedFamilies:u}},ca=async()=>{let e=s()?.settings;if(e)try{let t=(await e.load())?.settings;return sa(t??null)}catch{}if(!b()){let e=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(e.ok)return sa(await e.json().catch(()=>null))}return{magpieUsageUrl:``,magpieHiddenProviders:[],autoRefresh:!1,refreshIntervalMs:ea,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:yn.map(e=>e.id),selectedModels:{},expandedFamilies:{}}},la=(e,t,n)=>{let r=e.filter(e=>e?.providerId&&e.providerId!==t);return o(n)&&r.push(n),r},ua=async(e,t)=>{let n=$;oa.set(e,(oa.get(e)??0)+1),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:!0}}));try{let r=await i.fetchQuery({queryKey:a.quota(e),queryFn:({signal:t})=>c(e,t),staleTime:0,retry:!1});if(n!==$)return{providerId:e,stale:!0};if(!o(r))throw Error(`Invalid quota response`);return t(t=>({results:la(t.results,e,r)})),{providerId:e,result:r}}catch(r){return n===$?(t(e=>e.results.every(e=>e?.providerId)?{}:{results:e.results.filter(e=>e?.providerId)}),{providerId:e,error:r instanceof Error?r.message:`Failed to fetch quota`}):{providerId:e,stale:!0}}finally{if(n===$){let n=(oa.get(e)??1)-1;n>0?oa.set(e,n):oa.delete(e),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:n>0}}))}}},da=()=>{na=void 0,ra+=1,$+=1,ta+=1,oa.clear(),fa.setState({magpieUsageUrl:``,magpieHiddenProviders:[],magpieSources:[],magpieError:null,results:[],isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null})},fa=w()(E((e,t)=>({magpieSources:[],magpieError:null,magpieHiddenProviders:[],magpieUsageUrl:``,results:[],selectedProviderId:null,isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null,autoRefresh:!1,refreshIntervalMs:ea,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:yn.map(e=>e.id),selectedModels:{},expandedFamilies:{},loadSettings:async()=>{let t=$;try{let n=await ca();if(t!==$)return;e(e=>({...n,dropdownProviderIds:[...n.dropdownProviderIds.filter(e=>!e.startsWith(`magpie:`)),...e.results.filter(e=>e.source===`magpie`&&!n.magpieHiddenProviders.includes(e.providerId)).map(e=>e.providerId)]}))}catch(e){console.warn(`Failed to load usage settings:`,e)}},fetchAllQuotas:async()=>{let n=++ta;e({isLoading:!0,error:null});let r=yn.map(e=>e.id),[i]=await Promise.all([Promise.all(r.map(t=>ua(t,e))),t().fetchMagpieQuotas(!0)]);if(n===ta){let t=i.find(e=>`error`in e);e({isLoading:!1,...i.some(e=>`result`in e)?{lastUpdated:Date.now()}:{},error:t?.error??null})}},fetchProviderQuota:async n=>{if(n.startsWith(`magpie:`))return t().fetchMagpieQuotas(!0);let r=await ua(n,e);`stale`in r||e({error:`error`in r?r.error:null})},fetchMagpieQuotas:async(n=!1)=>{let r=$,a=A.getState().currentDirectory,o=t().magpieUsageUrl,s=JSON.stringify([a,o]);na!==s&&(na=s,ra+=1,e(e=>({results:e.results.filter(e=>e?.source!==`magpie`),magpieSources:[],magpieError:null})));let c=ra,l=++ia;try{let{sources:s,incomplete:u}=await i.fetchQuery($i(a,o,n));if(r!==$||c!==ra||l<aa||a!==A.getState().currentDirectory||o!==t().magpieUsageUrl)return;aa=l,e(e=>{let t=new Map(s.filter(e=>e.error&&!e.clearPrevious&&e.results.length===0).map(e=>[e.id,e.error]));if(u){let n=new Set(s.map(e=>e.id));for(let r of e.results)r.sourceId&&!n.has(r.sourceId)&&t.set(r.sourceId,`Magpie discovery is incomplete`)}let n=e.results.filter(e=>e?.providerId&&(e.source!==`magpie`||t.has(e.sourceId??``))).map(e=>e.source===`magpie`&&t.has(e.sourceId??``)?{...e,ok:!1,error:t.get(e.sourceId??``)}:e);n.push(...s.flatMap(e=>e.results));let r=n.filter(e=>e.source===`magpie`).map(e=>e.providerId);return{results:n,magpieSources:s,magpieError:null,dropdownProviderIds:[...e.dropdownProviderIds.filter(e=>!e.startsWith(`magpie:`)),...r.filter(t=>!e.magpieHiddenProviders.includes(t))]}})}catch(n){if(r!==$||c!==ra||l<aa||a!==A.getState().currentDirectory||o!==t().magpieUsageUrl)return;aa=l,e({magpieError:n instanceof Error?n.message:`Unable to read Magpie quotas`})}},setSelectedProvider:t=>e({selectedProviderId:t}),setAutoRefresh:t=>e({autoRefresh:t}),setRefreshInterval:t=>{e({refreshIntervalMs:Math.max(3e4,Math.min(3e5,Math.round(t)))})},setDisplayMode:t=>e({displayMode:t}),setShowPredValues:t=>e({showPredValues:t}),setDropdownProviderIds:n=>{let r=t().results.filter(e=>e.source===`magpie`),i=new Set(r.map(e=>e.providerId));e({dropdownProviderIds:n,magpieHiddenProviders:[...t().magpieHiddenProviders.filter(e=>!i.has(e)),...r.filter(e=>!n.includes(e.providerId)).map(e=>e.providerId)]})},setSelectedModels:(t,n)=>{e(e=>({selectedModels:{...e.selectedModels,[t]:n}}))},toggleModelSelected:(t,n)=>{e(e=>{let r=e.selectedModels[t]??[],i=r.includes(n)?r.filter(e=>e!==n):[...r,n];return{selectedModels:{...e.selectedModels,[t]:i}}})},setExpandedFamilies:(n,r)=>{e(e=>({expandedFamilies:{...e.expandedFamilies,[n]:r}})),_({usageExpandedFamilies:t().expandedFamilies})},toggleFamilyExpanded:(n,r)=>{e(e=>{let t=e.expandedFamilies[n]??[],i=t.includes(r)?t.filter(e=>e!==r):[...t,r];return{expandedFamilies:{...e.expandedFamilies,[n]:i}}}),_({usageExpandedFamilies:t().expandedFamilies})},applyDefaultSelections:(n,r)=>{if((t().selectedModels[n]?.length??0)>0)return;let i=Qi(n,r);i.length!==0&&(e(e=>({selectedModels:{...e.selectedModels,[n]:i}})),_({usageSelectedModels:t().selectedModels}))}}),{name:`quota-store`})),pa=()=>{let e=(0,X.c)(11),t=A(ma),n=fa(ha),r=fa(ga),i;e[0]===r?i=e[1]:(i=()=>{r()},e[0]=r,e[1]=i);let a;e[2]!==t||e[3]!==r||e[4]!==n?(a=[t,n,r],e[2]=t,e[3]=r,e[4]=n,e[5]=a):a=e[5],Q.useEffect(i,a);let o=fa(_a),s=fa(va),c=fa(ya),l,u;e[6]!==o||e[7]!==c||e[8]!==s?(l=()=>{if(!o)return;let e=window.setInterval(()=>{c()},s);return()=>window.clearInterval(e)},u=[o,s,c],e[6]=o,e[7]=c,e[8]=s,e[9]=l,e[10]=u):(l=e[9],u=e[10]),Q.useEffect(l,u)};function ma(e){return e.currentDirectory}function ha(e){return e.magpieUsageUrl}function ga(e){return e.fetchMagpieQuotas}function _a(e){return e.autoRefresh}function va(e){return e.refreshIntervalMs}function ya(e){return e.fetchAllQuotas}var ba=e=>{let t=(0,X.c)(20),{percent:n,tonePercent:r,className:i,expectedMarkerPercent:a}=e,o;t[0]===n?o=t[1]:(o=It(n)??0,t[0]=n,t[1]=o);let s=o,c=r??n,l;t[2]===c?l=t[3]:(l=xt(c),t[2]=c,t[3]=l);let u=l,d=a==null?null:Math.max(0,Math.min(100,a)),f;t[4]===u?f=t[5]:(f=u===`critical`?{backgroundColor:`var(--status-error)`}:u===`warn`?{backgroundColor:`var(--status-warning)`}:{backgroundColor:`var(--status-success)`},t[4]=u,t[5]=f);let p=f,m;t[6]===i?m=t[7]:(m=K(`relative h-2.5 rounded-full bg-[var(--interactive-border)] overflow-hidden`,i),t[6]=i,t[7]=m);let h=`${s}%`,g;t[8]!==p||t[9]!==h?(g={...p,width:h},t[8]=p,t[9]=h,t[10]=g):g=t[10];let _;t[11]!==s||t[12]!==g?(_=(0,Z.jsx)(`div`,{className:`h-full transition-all duration-300`,style:g,role:`progressbar`,"aria-valuenow":s,"aria-valuemin":0,"aria-valuemax":100}),t[11]=s,t[12]=g,t[13]=_):_=t[13];let v;t[14]===d?v=t[15]:(v=d!=null&&d>0&&d<100&&(0,Z.jsx)(`div`,{className:`absolute top-0 h-full w-0.5 bg-foreground`,style:{left:`${d}%`},title:`Expected usage if spread evenly: ${Math.round(d)}% of quota`,"aria-hidden":`true`}),t[14]=d,t[15]=v);let y;return t[16]!==m||t[17]!==_||t[18]!==v?(y=(0,Z.jsxs)(`div`,{className:m,children:[_,v]}),t[16]=m,t[17]=_,t[18]=v,t[19]=y):y=t[19],y},xa=e=>{let t=(0,X.c)(67),{paceInfo:n,className:r,compact:i}=e,a=i!==void 0&&i,{t:o}=G(),s;t[0]===n.status?s=t[1]:(s=Ot(n.status),t[0]=n.status,t[1]=s);let c=s,l;bb0:{switch(n.status){case`on-track`:{let e;t[2]===o?e=t[3]:(e=o(`settings.usage.pace.status.onTrack`),t[2]=o,t[3]=e),l=e;break bb0}case`slightly-fast`:{let e;t[4]===o?e=t[5]:(e=o(`settings.usage.pace.status.slightlyFast`),t[4]=o,t[5]=e),l=e;break bb0}case`too-fast`:{let e;t[6]===o?e=t[7]:(e=o(`settings.usage.pace.status.tooFast`),t[6]=o,t[7]=e),l=e;break bb0}case`exhausted`:{let e;t[8]===o?e=t[9]:(e=o(`settings.usage.pace.status.usedUp`),t[8]=o,t[9]=e),l=e;break bb0}}l=void 0}let u=l,d;t[10]!==n.predictText||t[11]!==o?(d=o(`settings.usage.pace.predictionTooltip`,{prediction:n.predictText}),t[10]=n.predictText,t[11]=o,t[12]=d):d=t[12];let f=d;if(a){let e;t[13]===r?e=t[14]:(e=K(`flex items-center gap-1.5`,r),t[13]=r,t[14]=e);let i;t[15]===c?i=t[16]:(i={backgroundColor:c},t[15]=c,t[16]=i);let a;t[17]!==u||t[18]!==i?(a=(0,Z.jsx)(`div`,{className:`h-2 w-2 rounded-full flex-shrink-0`,style:i,title:u}),t[17]=u,t[18]=i,t[19]=a):a=t[19];let s;t[20]===c?s=t[21]:(s={color:c},t[20]=c,t[21]=s);let l=n.isExhausted?void 0:f,d;t[22]!==n.isExhausted||t[23]!==n.predictText||t[24]!==n.remainingSeconds||t[25]!==o?(d=n.isExhausted?(0,Z.jsx)(Z.Fragment,{children:o(`settings.usage.pace.wait`,{duration:Dt(n.remainingSeconds)})}):(0,Z.jsx)(Z.Fragment,{children:o(`settings.usage.pace.prediction`,{prediction:n.predictText})}),t[22]=n.isExhausted,t[23]=n.predictText,t[24]=n.remainingSeconds,t[25]=o,t[26]=d):d=t[26];let p;t[27]!==d||t[28]!==s||t[29]!==l?(p=(0,Z.jsx)(`span`,{className:`typography-micro tabular-nums`,style:s,title:l,children:d}),t[27]=d,t[28]=s,t[29]=l,t[30]=p):p=t[30];let m;return t[31]!==p||t[32]!==e||t[33]!==a?(m=(0,Z.jsxs)(`div`,{className:e,children:[a,p]}),t[31]=p,t[32]=e,t[33]=a,t[34]=m):m=t[34],m}let p;t[35]===r?p=t[36]:(p=K(`flex items-center justify-between gap-2`,r),t[35]=r,t[36]=p);let m;t[37]!==n.isExhausted||t[38]!==n.paceRateText||t[39]!==o?(m=!n.isExhausted&&(0,Z.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:o(`settings.usage.pace.rate`,{rate:n.paceRateText})}),t[37]=n.isExhausted,t[38]=n.paceRateText,t[39]=o,t[40]=m):m=t[40];let h;t[41]===m?h=t[42]:(h=(0,Z.jsx)(`div`,{className:`flex items-center gap-1.5`,children:m}),t[41]=m,t[42]=h);let g;t[43]===c?g=t[44]:(g={color:c},t[43]=c,t[44]=g);let _;t[45]!==n.isExhausted||t[46]!==n.predictText||t[47]!==n.remainingSeconds||t[48]!==f||t[49]!==u||t[50]!==o?(_=n.isExhausted?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:u}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.waitSeparator`)}),(0,Z.jsx)(`span`,{className:`font-medium`,children:Dt(n.remainingSeconds)})]}):(0,Z.jsxs)(`span`,{title:f,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.predictionLabel`)}),(0,Z.jsx)(`span`,{className:`font-medium`,children:n.predictText})]}),t[45]=n.isExhausted,t[46]=n.predictText,t[47]=n.remainingSeconds,t[48]=f,t[49]=u,t[50]=o,t[51]=_):_=t[51];let v;t[52]!==g||t[53]!==_?(v=(0,Z.jsx)(`span`,{className:`typography-micro tabular-nums`,style:g,children:_}),t[52]=g,t[53]=_,t[54]=v):v=t[54];let y;t[55]===c?y=t[56]:(y={backgroundColor:c},t[55]=c,t[56]=y);let b;t[57]!==u||t[58]!==y?(b=(0,Z.jsx)(`div`,{className:`h-2 w-2 rounded-full flex-shrink-0`,style:y,title:u}),t[57]=u,t[58]=y,t[59]=b):b=t[59];let x;t[60]!==v||t[61]!==b?(x=(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[v,b]}),t[60]=v,t[61]=b,t[62]=x):x=t[62];let S;return t[63]!==x||t[64]!==p||t[65]!==h?(S=(0,Z.jsxs)(`div`,{className:p,children:[h,x]}),t[63]=x,t[64]=p,t[65]=h,t[66]=S):S=t[66],S},Sa=e=>e instanceof Error&&e.name===`CancelledError`,Ca=w(()=>({setStatus:e=>St(i,e),refreshStatus:async(e,t)=>{let r=n();t?.force&&await i.cancelQueries({queryKey:a.github.auth(r),exact:!0});try{return await At(i,e,r)}catch(e){if(Sa(e))return kt(i,r);throw e}}})),wa={displayMode:`browser`,installed:!1,browserTab:!0},Ta=new Set,Ea=wa,Da=!1,Oa,ka=()=>{let e=Nt();return{displayMode:e,installed:e!==`browser`,browserTab:e===`browser`}},Aa=()=>(!Da&&typeof window<`u`&&(Ea=ka(),Da=!0),Ea),ja=()=>{let e=ka();Da=!0,e.displayMode!==Ea.displayMode&&(Ea=e,Ta.forEach(e=>e()))},Ma=()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=[window.matchMedia(`(display-mode: standalone)`),window.matchMedia(`(display-mode: minimal-ui)`),window.matchMedia(`(display-mode: fullscreen)`),window.matchMedia(`(display-mode: window-controls-overlay)`)];for(let t of e)typeof t.addEventListener==`function`?t.addEventListener(`change`,ja):typeof t.addListener==`function`&&t.addListener(ja);return window.addEventListener(`appinstalled`,ja),window.addEventListener(`focus`,ja),()=>{for(let t of e)typeof t.removeEventListener==`function`?t.removeEventListener(`change`,ja):typeof t.removeListener==`function`&&t.removeListener(ja);window.removeEventListener(`appinstalled`,ja),window.removeEventListener(`focus`,ja)}},Na=e=>(Ta.add(e),Oa??=Ma(),ja(),()=>{Ta.delete(e),Ta.size===0&&(Oa?.(),Oa=void 0)}),Pa=()=>Q.useSyncExternalStore(Na,Aa,Fa);function Fa(){return wa}var Ia=`Yuri`,La=w()(T(e=>({sidebarBrandName:Ia,setSidebarBrandName:t=>{let n=t.slice(0,64);e(e=>e.sidebarBrandName===n?e:{sidebarBrandName:n})}}),{name:`sidebar-brand-store`,storage:p(),version:3,migrate:(e,t)=>{if(!e||typeof e!=`object`)return e;let n={...e};return t<1&&n.sidebarBrandName===`YEE CODE`&&(n.sidebarBrandName=Ia),t<2&&n.sidebarBrandName===`Open Chamber`&&(n.sidebarBrandName=Ia),t<3&&(n.sidebarBrandName===`OPEN CHAMBER`||n.sidebarBrandName===`Open Chamber`)&&(n.sidebarBrandName=Ia),n}}));typeof window<`u`&&t(e=>{r(e)&&La.persist.rehydrate()});var Ra=(e,t)=>e?t.kind===e.kind?t.projectRoot.length===e.projectRoot.length?t.projectId.localeCompare(e.projectId)<0:t.projectRoot.length>e.projectRoot.length:t.kind===`project`:!0,za=(e,t,n)=>{Ra(e.get(t),n)&&e.set(t,n)},Ba=e=>{let t=e;return h(t.directory)??h(t.project?.worktree)},Va=e=>{if(e===`/`||/^[A-Z]:$/.test(e))return null;let t=e.lastIndexOf(`/`);return t<0?null:t===0?`/`:t===2&&/^[A-Z]:\//.test(e)?e.slice(0,2):e.slice(0,t)},Ha=(e,t,n,r,i=[])=>{let a=new Map,o=new Map;for(let e of t){let t=h(e.normalizedPath);if(!t)continue;let n=o.get(t);(!n||e.id.localeCompare(n.id)<0)&&o.set(t,e),za(a,t,{projectId:e.id,projectRoot:t,scopeDirectory:t,kind:`project`})}if(!r)for(let[e,t]of n){let n=h(e),r=n?o.get(n):void 0;if(!(!r||!n))for(let e of t){let t=h(e.path);t&&za(a,t,{projectId:r.id,projectRoot:n,scopeDirectory:t,kind:`worktree`})}}let s=new Map,c=new Map,l=new Map,u=new Map,d=new Map,f=e=>{if(!e)return null;if(s.has(e))return s.get(e)??null;if(r){let t=a.get(e)??null;return s.set(e,t),t}let t=[],n=e,i=null;for(;n;){if(s.has(n)){i=s.get(n)??null;break}if(t.push(n),i=a.get(n)??null,i)break;n=Va(n)}for(let e of t)s.set(e,i);return i},p=(e,t,n)=>{for(let r of e){let e=f(Ba(r));if(!e)continue;c.set(r.id,e);let i=t.get(e.projectId);if(i?i.push(r):t.set(e.projectId,[r]),!n)continue;let a=n.get(e.scopeDirectory);a?a.add(r.id):n.set(e.scopeDirectory,new Set([r.id]))}};return p(e,l,d),p(i,u),{bySessionId:c,sessionsByProject:l,archivedSessionsByProject:u,sessionsByScope:d,directoryResolutions:s.size}},Ua=`__other__`;function Wa(e){return e.time?.updated??e.time?.archived??e.time?.created??0}function Ga({mode:e=`dialog`}){let{t}=G(),{isMobile:n,isTablet:r,hasTouchInput:i}=Ht(),a=n||r||i,o=e===`page`,s=I(e=>e.isArchivedSessionsDialogOpen),c=I(e=>e.setArchivedSessionsDialogOpen),l=o||s,u=Fe(e=>e.projects),d=je(e=>e.archivedSessions),f=Ne(e=>e.setCurrentSession),p=I(e=>e.setSettingsDialogOpen),[m,h]=Q.useState(!1),[g,_]=Q.useState(null),[v,y]=Q.useState(null);Q.useEffect(()=>{if(!l){_(null),y(null);return}let e=!1;return h(!0),Ge().catch(()=>{e||J.error(t(`settings.yuri.archivedSessions.toast.loadFailed`))}).finally(()=>{e||h(!1)}),()=>{e=!0}},[l,t]);let x=Q.useMemo(()=>{let e=Ha([],u.map(e=>({id:e.id,normalizedPath:e.path})),new Map,b(),d),n=new Map;for(let[t,r]of e.archivedSessionsByProject)n.set(t,[...r].sort((e,t)=>Wa(t)-Wa(e)));let r=new Set;for(let e of n.values())for(let t of e)r.add(t.id);let i=d.filter(e=>!r.has(e.id)).sort((e,t)=>Wa(t)-Wa(e));i.length>0&&n.set(Ua,i);let a=[];for(let e of u){let t=n.get(e.id)??[];t.length!==0&&a.push({projectId:e.id,label:e.label||e.path,path:e.path,sessions:t})}let o=n.get(Ua);return o&&o.length>0&&a.push({projectId:Ua,label:t(`settings.yuri.archivedSessions.otherProjects`),path:null,sessions:o}),a.sort((e,t)=>t.sessions.length-e.sessions.length||e.label.localeCompare(t.label)),a},[d,u,t]),S=d.length,C=g?x.find(e=>e.projectId===g)??null:null,w=Q.useCallback(async e=>{y(e.id);try{await Ie(e.id)?J.success(t(`settings.yuri.archivedSessions.toast.restored`)):J.error(t(`settings.yuri.archivedSessions.toast.restoreFailed`))}finally{y(null)}},[t]),T=Q.useCallback(e=>{let t=Re(e);f(e.id,t),c(!1),p(!1)},[f,c,p]),E=C?C.label:t(`settings.yuri.archivedSessions.dialog.title`),D=C?C.sessions.length===1?t(`settings.yuri.archivedSessions.dialog.sessionCountSingle`,{count:C.sessions.length}):t(`settings.yuri.archivedSessions.dialog.sessionCountPlural`,{count:C.sessions.length}):t(`settings.yuri.archivedSessions.dialog.description`),O=(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[C?(0,Z.jsxs)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`!h-7 !px-2 !font-normal text-muted-foreground`,onClick:()=>_(null),children:[(0,Z.jsx)(Y,{name:`arrow-left-s`,className:`mr-1 h-4 w-4`}),t(`settings.yuri.archivedSessions.dialog.backToProjects`)]}):null,m?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 typography-meta text-muted-foreground py-6`,children:[(0,Z.jsx)(Y,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),t(`settings.yuri.archivedSessions.dialog.loading`)]}):C?C.sessions.length===0?(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:t(`settings.yuri.archivedSessions.dialog.emptyProject`)}):(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:C.sessions.map(e=>{let n=Re(e),r=Wa(e),i=v===e.id;return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-border/60 px-3 py-2.5 sm:flex-row sm:items-center sm:gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`typography-ui-label font-medium text-foreground truncate`,children:e.title||t(`sessions.sidebar.session.untitled`)}),(0,Z.jsxs)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:[r>0?Vt(r):null,r>0&&n?` · `:null,n?Oe(n):null]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,Z.jsx)(q,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,disabled:i,onClick:()=>T(e),children:t(`settings.yuri.archivedSessions.actions.preview`)}),(0,Z.jsxs)(q,{type:`button`,variant:`default`,size:`xs`,className:`!font-normal`,disabled:i,onClick:()=>void w(e),children:[i?(0,Z.jsx)(Y,{name:`loader-4`,className:`mr-1 h-3.5 w-3.5 animate-spin`}):(0,Z.jsx)(Y,{name:`inbox-unarchive`,className:`mr-1 h-3.5 w-3.5`}),t(`settings.yuri.archivedSessions.actions.restore`)]})]})]},e.id)})}):x.length===0?(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:t(`settings.yuri.archivedSessions.dialog.empty`)}):(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:x.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>_(e.projectId),className:K(`flex w-full items-center gap-3 rounded-lg border border-border/60 px-3 py-2.5 text-left`,`hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`),children:[(0,Z.jsx)(Y,{name:`folder`,className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`typography-ui-label font-medium text-foreground truncate`,children:e.label}),e.path?(0,Z.jsx)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:Oe(e.path)}):null]}),(0,Z.jsx)(`span`,{className:`typography-meta tabular-nums text-muted-foreground shrink-0`,children:e.sessions.length===1?t(`settings.yuri.archivedSessions.dialog.sessionCountSingle`,{count:e.sessions.length}):t(`settings.yuri.archivedSessions.dialog.sessionCountPlural`,{count:e.sessions.length})}),(0,Z.jsx)(Y,{name:`arrow-right-s`,className:`h-4 w-4 shrink-0 text-muted-foreground`})]},e.projectId))}),!C&&!m&&S>0?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(S===1?`settings.yuri.archivedSessions.summarySingle`:`settings.yuri.archivedSessions.summaryPlural`,{count:S})}):null]});return o?(0,Z.jsxs)(`div`,{"data-settings-item":`archived-sessions.manage`,className:`yuri-settings-section-stack`,children:[(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.archivedSessions.description`)}),O]}):a?(0,Z.jsx)(Lt,{open:s,title:E,onClose:()=>c(!1),contentMaxHeightClassName:`max-h-[min(80vh,640px)]`,renderHeader:e=>(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border/40 px-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:E}),e]}),(0,Z.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:D})]}),children:O}):(0,Z.jsx)(Ze,{open:s,onOpenChange:c,children:(0,Z.jsxs)(Je,{className:`max-h-[85vh] max-w-2xl overflow-y-auto`,children:[(0,Z.jsxs)(qe,{children:[(0,Z.jsx)(Ye,{children:E}),(0,Z.jsx)(Xe,{children:D})]}),O]})})}function Ka(){let e=(0,X.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(Ga,{mode:`dialog`}),e[0]=t):t=e[0],t}var qa=48;function Ja({title:e,eyebrow:t,trailing:n,className:r}){let i=(0,Q.useRef)(null),a=(0,Q.useRef)(null),o=(0,Q.useRef)(null),s=(0,Q.useRef)(null),c=(0,Q.useRef)(null),l=De(()=>{s.current=null;let e=i.current,t=a.current;if(!e||!t)return;let n=Math.min(1,Math.max(0,t.scrollTop/qa)),r=o.current?.matches?Number(n>=.5):n;c.current!==null&&Math.abs(c.current-r)<.001||(c.current=r,e.style.setProperty(`--yuri-mobile-title-collapse`,r.toFixed(4)))}),u=De(()=>{s.current===null&&(s.current=window.requestAnimationFrame(l))});return(0,Q.useEffect)(()=>{let e=i.current;if(!e)return;let t=e.closest(`.yuri-mobile-settings-root-surface, [role="tabpanel"]`);if(!t)return;let n=window.matchMedia(`(prefers-reduced-motion: reduce)`);return a.current=t,o.current=n,c.current=null,t.addEventListener(`scroll`,u,{passive:!0}),n.addEventListener(`change`,u),l(),()=>{t.removeEventListener(`scroll`,u),n.removeEventListener(`change`,u),s.current!==null&&window.cancelAnimationFrame(s.current),s.current=null,a.current=null,o.current=null,c.current=null}},[]),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`header`,{ref:i,className:K(`yuri-mobile-collapsing-header flex shrink-0 items-start gap-4`,r),children:(0,Z.jsxs)(`div`,{className:`yuri-mobile-collapsing-header-inner`,children:[(0,Z.jsxs)(`div`,{className:`yuri-mobile-collapsing-header-title-block min-w-0 flex-1`,children:[t?(0,Z.jsx)(`p`,{className:`yuri-mobile-collapsing-header-eyebrow truncate typography-micro font-medium text-muted-foreground`,children:t}):null,(0,Z.jsx)(`h1`,{className:`yuri-mobile-root-page-title truncate font-semibold text-foreground`,children:e})]}),n?(0,Z.jsx)(`div`,{className:`yuri-mobile-collapsing-header-trailing flex min-h-10 shrink-0 items-center gap-3.5`,children:n}):null]})}),(0,Z.jsx)(`div`,{className:`yuri-mobile-collapsing-header-spacer`,"aria-hidden":`true`})]})}export{kr as A,On as B,xi as C,ti as D,li as E,yr as F,yn as H,sr as I,Mn as L,xr as M,Cr as N,Er as O,wr as P,Pn as R,Si as S,ci as T,bn as U,xn as V,Yi as _,La as a,ki as b,xa as c,pa as d,fa as f,Zi as g,Xi as h,Ha as i,Sr as j,Or as k,ba as l,Gi as m,Ka as n,Pa as o,Ji as p,Ga as r,Ca as s,Ja as t,da as u,Wi as v,ui as w,Ci as x,Bi as y,Nn as z};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/gitApi-CT2gHl-y.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-switch-CAZiOV2G.js","assets/runtime-auth-ef9W7A43.js","assets/queryRuntime-DKGLQtb9.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/platform-7bX6qtBV.js","assets/persistence-Dzooc9Xg.js","assets/vendor-zustand-o69pgTEK.js","assets/vendor-base-ui-CdzJ6My_.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/useUIStore-NMQx_cnG.js","assets/vendor-react-BP2cRVqX.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-opencode-client-MF2GBrFx.js","assets/runtime-file-resource-C1k5nbWb.js","assets/vendor-tanstack-react-query-CdqCAt40.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/useMobileNavigationStore-CO6CAp4i.js","assets/vendor-sonner-ZS8XIOVl.js","assets/vendor-reactuses-core-BpfIZ1tg.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/button-C3292Ee6.js","assets/store-CZu30-QE.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/useAssistantUIStore-D7JZlg_Q.js","assets/vendor-zod-Dzk5kdUU.js","assets/vendor-fuse.js-DB5wDJbI.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t}from"./queryRuntime-DKGLQtb9.js";import{Rt as n,Zt as r,r as i,t as a,tn as o}from"./persistence-Dzooc9Xg.js";import{it as s,rt as c}from"./vendor-base-ui-CdzJ6My_.js";import{Ct as l,Nt as u}from"./platform-7bX6qtBV.js";import{n as d}from"./useUIStore-NMQx_cnG.js";import{n as f,t as p}from"./vendor-react-BP2cRVqX.js";import{A as m}from"./runtime-file-resource-C1k5nbWb.js";import{o as h}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";/* empty css */import{n as g,s as _}from"./vendor-reactuses-core-BpfIZ1tg.js";import{f as v,h as y,r as b,t as x}from"./button-C3292Ee6.js";import{n as ee}from"./store-CZu30-QE.js";import{Aa as te,Mt as ne,S as re,cn as ie,d as S,fo as ae,tn as oe,vn as se,wa as C}from"./useMobileNavigationStore-CO6CAp4i.js";import{n as ce}from"./Icon-jsQQXouE.js";import{At as le,C as ue,Ct as de,Dt as w,Et as fe,Lt as T,Mt as pe,Ot as me,S as he,St as E,Tt as ge,i as _e,jt as ve,kt as D,lt as O,t as ye,wt as be,x as xe,xt as Se}from"./useAppFontEffects-Dp_Rk9nw.js";import{s as Ce}from"./projectMeta-O4wg5jiy.js";import{r as we}from"./tooltip-DGUZtHif.js";import{Ct as Te,ft as k,gt as Ee}from"./speechSettingsQueries-C3wBvjjw.js";import{d as De,y as Oe}from"./insertionBoundaries-D3e6uOkH.js";import{i as ke,n as Ae,r as je,t as Me}from"./useDesktopWindowControlsLayout-Jt77zqdp.js";var Ne=p(),A=f(),j=e(s(),1),M=c(),Pe=e=>{let t=(0,A.c)(3),{mode:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,M.jsx)(O.Provider,{value:n,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i},Fe=e=>{let t=typeof e==`string`?e.trim():``;if(!t)return``;let n=typeof window<`u`?window.__YURI_HOME__:``;if(n&&t===n)return`~`;if(n&&t.startsWith(`${n}/`))return`~/${t.slice(n.length+1)}`;let r=t.split(`/`).filter(Boolean);return r.length<=3?t:`.../${r.slice(-3).join(`/`)}`},N=e=>{let t=typeof e==`string`?e.trim():``;if(!t)return``;let n=t.replace(/\\/g,`/`);return n===`/`?`/`:n.replace(/\/+$/,``)},P=e=>{let t=(0,A.c)(117),{mode:n}=e,{t:i}=v(),a=S(Le),s=S(Re),c=S(ze),u=l(Be),d=ae(Ve),f=ae(He),p=C(Ue),h=C(We),g=se(),_=ie(a??``),y=m(),ee=Oe(Ge),te;t[0]===a?te=t[1]:(te=e=>a?e.worktreeMetadata.get(a)?.path??``:``,t[0]=a,t[1]=te);let ne=S(te),le;t[2]===a?le=t[3]:(le=e=>a?e.worktreeMetadata.get(a)?.branch?.trim()??null:null,t[2]=a,t[3]=le);let ue=S(le),de;t[4]===a?de=t[5]:(de=e=>a?e.getAttachment(a):void 0,t[4]=a,t[5]=de);let w=re(de),fe=S(Ke),[T,pe]=j.useState(!1),me=typeof window<`u`?window.__YURI_MACOS_MAJOR__??0:0,he=Number.isFinite(me)&&me>0,{usesFramelessChrome:E,side:ge}=Me(),_e=he?me>=26?`h-12`:me<=15?`h-14`:``:``,ve;t[6]!==a||t[7]!==g?(ve=a?g.find(e=>e.id===a)??null:null,t[6]=a,t[7]=g,t[8]=ve):ve=t[8];let D=ve,O=D?.worktreeMetadata??null,ye,be;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(ye=()=>{o()&&r(`desktop_get_window_pinned`).then(e=>{typeof e?.pinned==`boolean`&&pe(e.pinned)})},be=[],t[9]=ye,t[10]=be):(ye=t[9],be=t[10]),j.useEffect(ye,be);let xe;t[11]!==s||t[12]!==n||t[13]!==D?.title||t[14]!==i?(xe=D?.title?.trim()||i(s||n===`draft`?`miniChat.header.newSession`:`miniChat.header.session`),t[11]=s,t[12]=n,t[13]=D?.title,t[14]=i,t[15]=xe):xe=t[15];let Se=xe,Ce=D?.directory??null,we;t[16]===Ce?we=t[17]:(we=N(Ce),t[16]=Ce,t[17]=we);let Te=we,k=ne||O?.path||w?.cwd||w?.worktreeRoot||``,Ee;t[18]===k?Ee=t[19]:(Ee=N(k),t[18]=k,t[19]=Ee);let Ne=Ee,Pe;t[20]===u?Pe=t[21]:(Pe=N(u),t[20]=u,t[21]=Pe);let P=Ne||Te||fe||Pe,Ie;t[22]===P?Ie=t[23]:(Ie=Fe(P),t[22]=P,t[23]=Ie);let $e=Ie,et;t[24]!==Te||t[25]!==Ne?(et=e=>{let t=N(Ne||Te||``);if(!t)return null;for(let n of e.availableWorktreesByProject.values()){let e=n.find(e=>N(e.path)===t)?.branch?.trim();if(e)return e}return null},t[24]=Te,t[25]=Ne,t[26]=et):et=t[26];let tt=S(et),nt,rt;t[27]!==ee||t[28]!==P||t[29]!==y.git?(nt=()=>{P&&ee(P,y.git).catch(qe)},rt=[ee,P,y.git],t[27]=ee,t[28]=P,t[29]=y.git,t[30]=nt,t[31]=rt):(nt=t[30],rt=t[31]),j.useEffect(nt,rt),O?.projectDirectory,w?.worktreeRoot;let it;bb0:{let e=O?.projectDirectory??w?.worktreeRoot??null,n;t[32]===e?n=t[33]:(n=N(e),t[32]=e,t[33]=n);let r=n||P;if(!r){it=null;break bb0}let i;t[34]!==r||t[35]!==d?(i=d.map(Je).filter(e=>e.normalizedPath&&(e.normalizedPath===r||r.startsWith(`${e.normalizedPath}/`))).sort(Ye)[0]??null,t[34]=r,t[35]=d,t[36]=i):i=t[36],it=i}let at=it,ot;bb1:{let e=at??f;if(!e){ot=$e||`Yuri`;break bb1}let n;t[37]===e.path?n=t[38]:(n=e.path.split(/[\\/]/).filter(Boolean).at(-1)??e.path,t[37]=e.path,t[38]=n),ot=n}let st=ot,ct=De(P||null),lt;t[39]!==tt||t[40]!==ct||t[41]!==O?.branch||t[42]!==w?.branch||t[43]!==ue?(lt=ct||ue||O?.branch?.trim()||w?.branch?.trim()||tt,t[39]=tt,t[40]=ct,t[41]=O?.branch,t[42]=w?.branch,t[43]=ue,t[44]=lt):lt=t[44];let ut=lt,dt=ut&&ut!==`HEAD`?ut:null,ft;t[45]===p?ft=t[46]:(ft=p(),t[45]=p,t[46]=ft);let pt=ft,mt;bb2:{for(let e=_.length-1;e>=0;--e){let t=_[e];if(t.role!==`assistant`||typeof t.providerID!=`string`||typeof t.modelID!=`string`)continue;let n=h.find(e=>e.id===t.providerID)?.models.find(e=>e.id===t.modelID);if(n){mt=n;break bb2}}mt=void 0}let ht=mt,gt=pt?.limit?pt:ht,F=gt&&typeof gt.limit==`object`&>.limit!==null?gt.limit:null,_t=F&&typeof F.context==`number`?F.context:0,vt=F&&typeof F.output==`number`?F.output:0,I=oe(a??``,_t,vt),[L,yt]=j.useState(null),bt;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(bt={WebkitAppRegion:`drag`},t[47]=bt):bt=t[47];let xt=bt,St;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(St={WebkitAppRegion:`no-drag`},t[48]=St):St=t[48];let Ct=St,wt,Tt;t[49]!==I||t[50]!==a?(wt=()=>{if(!a){yt(Xe);return}if(I){yt(e=>e&&e.pending===I.pending&&e.totalTokens===I.totalTokens&&e.percentage===I.percentage&&e.contextLimit===I.contextLimit&&(e.outputLimit??0)===(I.outputLimit??0)&&(e.normalizedOutput??0)===(I.normalizedOutput??0)&&e.thresholdLimit===I.thresholdLimit&&e.lastMessageId===I.lastMessageId?e:I);return}yt(Ze)},Tt=[I,a],t[49]=I,t[50]=a,t[51]=wt,t[52]=Tt):(wt=t[51],Tt=t[52]),j.useEffect(wt,Tt);let Et=L&&L.contextLimit>0?Math.min(999,L.totalTokens/L.contextLimit*100):0,Dt;t[53]===T?Dt=t[54]:(Dt=()=>{let e=!T;pe(e),r(`desktop_set_window_pinned`,{pinned:e}).catch(()=>{pe(!e)})},t[53]=T,t[54]=Dt);let Ot=Dt,kt;t[55]!==u||t[56]!==a||t[57]!==c||t[58]!==P||t[59]!==D?(kt=()=>{let e=a?{sessionId:a,directory:D?.directory??u??``}:{mode:`draft`,directory:P||u||``,projectId:c};r(`desktop_focus_main_window`,e).then(Qe)},t[55]=u,t[56]=a,t[57]=c,t[58]=P,t[59]=D,t[60]=kt):kt=t[60];let At=kt,jt=E?`h-12`:_e||`min-h-14`,R;t[61]===jt?R=t[62]:(R=b(`flex items-center gap-3 bg-background pr-3`,he?`pl-[5.5rem]`:`pl-3`,jt),t[61]=jt,t[62]=R);let z;t[63]!==E||t[64]!==ge?(z=E&&ge===`left`?(0,M.jsx)(je,{visible:!0,position:`left`}):null,t[63]=E,t[64]=ge,t[65]=z):z=t[65];let B;t[66]===i?B=t[67]:(B=i(`sessions.switcher.openAria`),t[66]=i,t[67]=B);let V;t[68]===Se?V=t[69]:(V=(0,M.jsx)(`span`,{className:`truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full`,children:Se}),t[68]=Se,t[69]=V);let H;t[70]===st?H=t[71]:(H=(0,M.jsx)(`span`,{className:`truncate`,children:st}),t[70]=st,t[71]=H);let U;t[72]===dt?U=t[73]:(U=dt?(0,M.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-0.5`,children:[(0,M.jsx)(ce,{name:`git-branch`,className:`h-3 w-3 flex-shrink-0 text-muted-foreground/70`}),(0,M.jsx)(`span`,{className:`truncate`,children:dt})]}):null,t[72]=dt,t[73]=U);let W;t[74]!==H||t[75]!==U?(W=(0,M.jsxs)(`span`,{className:`flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75`,children:[H,U]}),t[74]=H,t[75]=U,t[76]=W):W=t[76];let G;t[77]!==B||t[78]!==V||t[79]!==W?(G=(0,M.jsx)(Ae,{children:(0,M.jsxs)(`button`,{type:`button`,"aria-label":B,style:Ct,className:`flex min-w-0 max-w-full flex-col items-start rounded-md px-1 py-0.5 text-left transition-colors hover:bg-interactive-hover/60 focus-visible:outline-none focus-visible:bg-interactive-hover/60`,children:[V,W]})}),t[77]=B,t[78]=V,t[79]=W,t[80]=G):G=t[80];let Mt;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(Mt=(0,M.jsx)(`div`,{className:`min-w-0 flex-1`}),t[81]=Mt):Mt=t[81];let K;t[82]!==Et||t[83]!==L?(K=L?(0,M.jsx)(ke,{pending:L.pending,totalTokens:L.totalTokens,percentage:Et,colorPercentage:L.percentage,contextLimit:L.contextLimit,outputLimit:L.outputLimit??0,className:`h-9 shrink-0 pl-1 pr-1 typography-ui-label`,valueClassName:`font-semibold leading-none`,hideIcon:!0,showPercentIcon:!0,percentIconClassName:`h-4.5 w-4.5`}):null,t[82]=Et,t[83]=L,t[84]=K):K=t[84];let q;t[85]!==T||t[86]!==i?(q=i(T?`miniChat.actions.unpinAria`:`miniChat.actions.pinAria`),t[85]=T,t[86]=i,t[87]=q):q=t[87];let J;t[88]!==T||t[89]!==i?(J=i(T?`miniChat.actions.unpin`:`miniChat.actions.pin`),t[88]=T,t[89]=i,t[90]=J):J=t[90];let Y;t[91]===T?Y=t[92]:(Y=T?(0,M.jsx)(ce,{name:`pushpin-2-fill`,className:`h-4 w-4`}):(0,M.jsx)(ce,{name:`pushpin-2`,className:`h-4 w-4`}),t[91]=T,t[92]=Y);let X;t[93]!==Ot||t[94]!==q||t[95]!==J||t[96]!==Y?(X=(0,M.jsx)(x,{type:`button`,variant:`ghost`,size:`icon`,onClick:Ot,"aria-label":q,title:J,style:Ct,children:Y}),t[93]=Ot,t[94]=q,t[95]=J,t[96]=Y,t[97]=X):X=t[97];let Z;t[98]===i?Z=t[99]:(Z=i(`miniChat.actions.openMainAria`),t[98]=i,t[99]=Z);let Q;t[100]===i?Q=t[101]:(Q=i(`miniChat.actions.openMain`),t[100]=i,t[101]=Q);let Nt;t[102]===Symbol.for(`react.memo_cache_sentinel`)?(Nt=(0,M.jsx)(ce,{name:`external-link`,className:`h-4 w-4`}),t[102]=Nt):Nt=t[102];let Pt;t[103]!==At||t[104]!==Z||t[105]!==Q?(Pt=(0,M.jsx)(x,{type:`button`,variant:`ghost`,size:`icon`,onClick:At,"aria-label":Z,title:Q,style:Ct,children:Nt}),t[103]=At,t[104]=Z,t[105]=Q,t[106]=Pt):Pt=t[106];let Ft=E&&ge===`right`,$;t[107]===Ft?$=t[108]:($=(0,M.jsx)(je,{visible:Ft,position:`right`}),t[107]=Ft,t[108]=$);let It;return t[109]!==R||t[110]!==z||t[111]!==G||t[112]!==K||t[113]!==X||t[114]!==Pt||t[115]!==$?(It=(0,M.jsxs)(`header`,{className:R,style:xt,children:[z,G,Mt,K,X,Pt,$]}),t[109]=R,t[110]=z,t[111]=G,t[112]=K,t[113]=X,t[114]=Pt,t[115]=$,t[116]=It):It=t[116],It},Ie=e=>{let t=(0,A.c)(9),{mode:n,autoOpenDraft:r,unavailable:i}=e,a=r!==void 0&&r,o=i!==void 0&&i,{t:s}=v(),c;t[0]===n?c=t[1]:(c=(0,M.jsx)(P,{mode:n}),t[0]=n,t[1]=c);let l;t[2]!==a||t[3]!==s||t[4]!==o?(l=(0,M.jsx)(`main`,{className:`min-h-0 flex-1`,children:o?(0,M.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center typography-ui-label text-muted-foreground`,children:(0,M.jsxs)(`div`,{className:`max-w-sm rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-4 py-3`,children:[(0,M.jsx)(`div`,{className:`font-medium text-foreground`,children:s(`miniChat.unavailable.title`)}),(0,M.jsx)(`div`,{className:`mt-1 typography-small text-muted-foreground`,children:s(`miniChat.unavailable.description`)})]})}):(0,M.jsx)(Pe,{mode:`mini-chat`,children:(0,M.jsx)(ue,{autoOpenDraft:a})})}),t[2]=a,t[3]=s,t[4]=o,t[5]=l):l=t[5];let u;return t[6]!==c||t[7]!==l?(u=(0,M.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background text-foreground`,children:[c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8],u};function Le(e){return e.currentSessionId}function Re(e){return!!e.newSessionDraft?.open}function ze(e){return e.newSessionDraft?.selectedProjectId??null}function Be(e){return e.currentDirectory}function Ve(e){return e.projects}function He(e){return e.getActiveProject()}function Ue(e){return e.getCurrentModel}function We(e){return e.providers}function Ge(e){return e.ensureStatus}function Ke(e){return e.newSessionDraft?.open?N(e.newSessionDraft.bootstrapPendingDirectory??e.newSessionDraft.directoryOverride??``):``}function qe(){}function Je(e){return{...e,normalizedPath:N(e.path)}}function Ye(e,t){return t.path.length-e.path.length}function Xe(e){return e===null?e:null}function Ze(e){return e===null?e:null}function Qe(e){return e?.focused===!0?r(`desktop_close_current_window`):null}var $e=()=>{document.querySelector(`textarea[data-chat-input="true"]`)?.focus()},et=()=>{let e=d(e=>e.shortcutOverrides),t=l(e=>e.currentDirectory),i=ae(e=>e.getActiveProject()),a=S(e=>e.openNewSessionDraft);j.useEffect(()=>{let o=t=>Ee(t,e),s=e=>{if(k(e,o(`focus_input`))){e.preventDefault(),$e();return}if(n()&&k(e,o(`close_context_panel_tab`))){e.preventDefault(),r(`desktop_close_current_window`).catch(e=>{console.warn(`[mini-chat-shortcuts] failed to close current window`,e)});return}if(n()&&k(e,o(`new_mini_chat`))){e.preventDefault(),r(`desktop_open_draft_mini_chat_window`,{directory:t||i?.path||``,projectId:i?.id??null})?.catch(e=>{console.warn(`[mini-chat-shortcuts] failed to open draft mini chat window`,e)});return}if(k(e,o(`new_chat`))){e.preventDefault(),a({selectedProjectId:i?.id??null,directoryOverride:t||i?.path||null,preserveDirectoryOverride:!!(t||i?.path)}),$e();return}if(k(e,o(`open_model_selector`))){e.preventDefault();let{isModelSelectorOpen:t,setModelSelectorOpen:n}=d.getState();n(!t,{instant:!0});return}if(k(e,o(`cycle_thinking_variant`))){let t=C.getState();if(t.getCurrentModelVariants().length===0)return;e.preventDefault(),t.cycleCurrentVariant();let n=C.getState().currentVariant,r=S.getState().currentSessionId,i=C.getState().currentAgentName,a=C.getState().currentProviderId,o=C.getState().currentModelId;r&&i&&a&&o&&te.getState().saveAgentModelVariantForSession(r,i,a,o,n),i&&a&&o&&C.getState().saveAgentModelSelection(i,a,o,n);return}let s=k(e,o(`cycle_favorite_model_forward`)),c=k(e,o(`cycle_favorite_model_backward`));if(s||c){let{favoriteModels:t,addRecentModel:n}=d.getState();if(t.length===0)return;e.preventDefault();let{currentProviderId:r,currentModelId:i,providers:a,setProvider:o,setModel:c,setCurrentVariant:l}=C.getState(),u=t[(t.findIndex(e=>e.providerID===r&&e.modelID===i)+(s?1:-1)+t.length)%t.length];o(u.providerID),c(u.modelID);let f=a.find(e=>e.id===u.providerID)?.models?.find(e=>e.id===u.modelID),p=f?.variants?Object.keys(f.variants):[],m=u.variant!==void 0&&p.includes(u.variant)?u.variant:void 0;l(m),n(u.providerID,u.modelID,m)}};return window.addEventListener(`keydown`,s),()=>window.removeEventListener(`keydown`,s)},[i?.id,i?.path,t,a,e])},tt=`yuri:mini-chat-presence`,nt=()=>{let e=typeof window<`u`?new URLSearchParams(window.location.search):new URLSearchParams;return{mode:e.get(`mode`)===`session`?`session`:`draft`,sessionId:e.get(`sessionId`)?.trim()||null,directory:e.get(`directory`)?.trim()||null,projectId:e.get(`projectId`)?.trim()||null}},rt=({config:e})=>{let t=se(),n=l(e=>e.currentDirectory),r=l(e=>e.setDirectory),i=ae(e=>e.projects),a=S(e=>e.currentSessionId),o=S(e=>!!e.newSessionDraft?.open),s=S(e=>e.newSessionDraft?.open?e.newSessionDraft.bootstrapPendingDirectory??e.newSessionDraft.directoryOverride??``:``),c=S(e=>e.setCurrentSession),u=S(e=>e.openNewSessionDraft),d=C(e=>e.initializeApp),f=C(e=>e.isInitialized),p=Se();j.useEffect(()=>{d()},[d]),j.useEffect(()=>{if(f)return;let e=!0,t=0,n=window.setInterval(()=>{if(e){if(t+=1,t>10){window.clearInterval(n);return}C.getState().isInitialized||C.getState().initializeApp()}},1e3);return()=>{e=!1,window.clearInterval(n)}},[f]);let m=j.useRef(!1);j.useEffect(()=>{if(!m.current&&e.mode===`session`&&e.directory){if(n===e.directory){m.current=!0;return}r(e.directory,{showOverlay:!1}),m.current=!0}},[e.directory,e.mode,n,r]),j.useEffect(()=>{e.mode!==`draft`||!o||a||!s||n===s||r(s,{showOverlay:!1})},[e.mode,n,a,s,o,r]),be({enabled:!0,source:`electronMiniChat:recovery`});let v=j.useRef(!1);j.useEffect(()=>{if(v.current||e.mode!==`session`||!e.sessionId)return;if(a===e.sessionId){v.current=!0;return}if(a){v.current=!0;return}let n=t.find(t=>t.id===e.sessionId);if(!n){p.ensureSessionRenderable(e.sessionId);return}let r=n.directory??e.directory;c(e.sessionId,r),v.current=!0},[e,a,t,c,p]);let y=_(t),b=g(e=>{let t=e.detail,n=typeof t?.sessionId==`string`?t.sessionId.trim():``;if(!n||S.getState().currentSessionId===n)return;let r=typeof t?.directory==`string`&&t.directory.trim().length>0?t.directory.trim():y.current.find(e=>e.id===n)?.directory??null;p.ensureSessionRenderable(n),c(n,r),v.current=!0});j.useEffect(()=>(window.addEventListener(`yuri:open-session`,b),()=>window.removeEventListener(`yuri:open-session`,b)),[b]),j.useEffect(()=>{e.mode!==`draft`||o||a||u({selectedProjectId:e.projectId,directoryOverride:e.directory,preserveDirectoryOverride:!!e.directory})},[e,a,o,u]),j.useEffect(()=>{if(i.length===0)return;let e=!1;return(async()=>{await Promise.all(i.map(async t=>{let n=t.path.replace(/\\/g,`/`).replace(/\/+$/,``);if(n)try{if(!(Oe.getState().directories.get(n)?.isGitRepo??await h(()=>import(`./gitApi-CT2gHl-y.js`).then(e=>e.S).then(e=>e.checkIsGitRepository(n)),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30])))||e)return;await Ce({id:t.id,path:n},{isCurrent:()=>!e})}catch{}}))})(),()=>{e=!0}},[i]);let x=j.useRef(!1);return j.useEffect(()=>{if(x.current||!f)return;let t=()=>{if(x.current)return;x.current=!0;let e=typeof document<`u`?document.getElementById(`initial-loading`):null;e&&(e.classList.add(`fade-out`),window.setTimeout(()=>e.remove(),300))},n=e.mode===`session`?a===e.sessionId:o,r=window.setTimeout(t,n?100:1500);return()=>window.clearTimeout(r)},[f,e.mode,e.sessionId,a,o]),null},it=()=>{let e=(0,A.c)(4),t=S(ft),n=l(pt),r,i;return e[0]!==n||e[1]!==t?(r=()=>{if(!t||!n||typeof BroadcastChannel>`u`)return;let e=new BroadcastChannel(tt),r=r=>{e.postMessage({type:`mini-chat-session-presence`,sessionId:t,directory:n,viewed:r})};r(!0);let i=window.setInterval(()=>r(!0),5e3),a=()=>r(!1);return window.addEventListener(`beforeunload`,a),()=>{window.clearInterval(i),window.removeEventListener(`beforeunload`,a),r(!1),e.close()}},i=[n,t],e[0]=n,e[1]=t,e[2]=r,e[3]=i):(r=e[2],i=e[3]),j.useEffect(r,i),null},at=e=>{let t=(0,A.c)(6),n=se(),r=S(mt),[i,a]=j.useState(!1),o,s;return t[0]!==e.mode||t[1]!==e.sessionId||t[2]!==r||t[3]!==n?(o=()=>{if(e.mode!==`session`||!e.sessionId||r===e.sessionId){a(!1);return}if(n.some(t=>t.id===e.sessionId)){a(!1);return}let t=window.setTimeout(()=>a(!0),5e3);return()=>window.clearTimeout(t)},s=[e.mode,e.sessionId,r,n],t[0]=e.mode,t[1]=e.sessionId,t[2]=r,t[3]=n,t[4]=o,t[5]=s):(o=t[4],s=t[5]),j.useEffect(o,s),i};function ot(e){let n=(0,A.c)(16),{apis:r}=e,i;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=nt(),n[0]=i):i=n[0];let a=i,o=l(ut),s=S(lt),c=S(ct),d,f;n[1]===o?(d=n[2],f=n[3]):(d=()=>{u.setDirectory(o||a.directory||void 0)},f=[a.directory,o],n[1]=o,n[2]=d,n[3]=f),j.useEffect(d,f);let p,m;n[4]===r?(p=n[5],m=n[6]):(p=()=>(t(r),st),m=[r],n[4]=r,n[5]=p,n[6]=m),j.useEffect(p,m),ye(),et();let h;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(h={enabled:!0},n[7]=h):h=n[7],he(h),xe();let g;n[8]===Symbol.for(`react.memo_cache_sentinel`)?(g=u.getSdkClient(),n[8]=g):g=n[8];let _=o||a.directory||``,v=!(c&&s===null),y;n[9]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,M.jsx)(we,{delayDuration:300,skipDelayDuration:150,children:(0,M.jsxs)(`div`,{className:`h-full text-foreground bg-background`,children:[(0,M.jsx)(dt,{config:a}),(0,M.jsx)(E,{})]})}),n[9]=y):y=n[9];let b;n[10]===r?b=n[11]:(b=(0,M.jsx)(de,{apis:r,children:y}),n[10]=r,n[11]=b);let x;return n[12]!==b||n[13]!==_||n[14]!==v?(x=(0,M.jsx)(Te,{children:(0,M.jsx)(ne,{sdk:g,directory:_,bootstrapDirectory:v,children:b})}),n[12]=b,n[13]=_,n[14]=v,n[15]=x):x=n[15],x}function st(){return t(null)}function ct(e){return!!e.newSessionDraft?.open}function lt(e){return e.currentSessionId}function ut(e){return e.currentDirectory}var dt=e=>{let t=(0,A.c)(11),{config:n}=e,r=at(n),i;t[0]===n?i=t[1]:(i=(0,M.jsx)(rt,{config:n}),t[0]=n,t[1]=i);let a,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,M.jsx)(it,{}),o=(0,M.jsx)(_e,{embeddedBackgroundWorkEnabled:!0}),t[2]=a,t[3]=o):(a=t[2],o=t[3]);let s=n.mode===`draft`,c;t[4]!==n.mode||t[5]!==r||t[6]!==s?(c=(0,M.jsx)(Ie,{mode:n.mode,autoOpenDraft:s,unavailable:r}),t[4]=n.mode,t[5]=r,t[6]=s,t[7]=c):c=t[7];let l;return t[8]!==i||t[9]!==c?(l=(0,M.jsxs)(M.Fragment,{children:[i,a,o,c]}),t[8]=i,t[9]=c,t[10]=l):l=t[10],l};function ft(e){return e.currentSessionId}function pt(e){return e.currentDirectory}function mt(e){return e.currentSessionId}var ht=()=>{ee(),a().then(()=>{Promise.all([i(),T()]).catch(e=>{console.error(`[mini-chat-main] settings init failed:`,e)}),me(),w(),fe()}).catch(e=>{console.error(`[mini-chat-main] appearance init failed:`,e)})};function gt(e){ht();let t=document.getElementById(`root`);if(!t)throw Error(`Root element not found`);(0,Ne.createRoot)(t).render((0,M.jsx)(j.StrictMode,{children:(0,M.jsx)(ge,{children:(0,M.jsx)(y,{children:(0,M.jsx)(D,{children:(0,M.jsx)(le,{children:(0,M.jsx)(ve,{children:(0,M.jsx)(pe,{children:(0,M.jsx)(ot,{apis:e})})})})})})})}))}export{gt as renderElectronMiniChatApp};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-capacitor-app-B5H_XtmE.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{f as e,g as t,h as n,l as r,p as i}from"./runtime-auth-ef9W7A43.js";import{a,d as o,f as s,p as c,u as l}from"./runtime-switch-CAZiOV2G.js";import{l as u,u as d}from"./queryRuntime-DKGLQtb9.js";import{tt as f}from"./persistence-Dzooc9Xg.js";import{t as ee}from"./desktopRelayRestore-C_23nlKD.js";import{$ as te,A as ne,B as re,Ct as ie,D as ae,E as oe,F as se,H as ce,I as le,J as ue,L as de,M as fe,N as pe,P as me,Q as he,R as ge,S as _e,T as ve,U as ye,V as be,W as xe,X as Se,Y as p,Z as Ce,_ as we,_t as Te,a as Ee,at as De,b as Oe,bt as ke,c as Ae,ct as je,d as Me,dt as Ne,et as Pe,f as Fe,ft as Ie,g as Le,gt as Re,h as ze,ht as Be,i as Ve,j as He,k as Ue,l as We,lt as Ge,m as Ke,mt as qe,n as m,nt as Je,o as Ye,ot as Xe,p as Ze,pt as Qe,q as $e,s as et,st as tt,t as nt,tt as rt,u as it,ut as at,v as h,vt as ot,x as g,y as st,yt as _}from"./platform-7bX6qtBV.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{s as ct}from"./runtime-file-resource-C1k5nbWb.js";import{n as v,o as y}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{a as lt,c as ut,l as dt,n as ft,r as pt,s as mt,t as ht}from"./terminalApi-BHXvha-U.js";import{t as gt}from"./runtime-file-download-DAOam_oV.js";import{t as b}from"./types-BuiqMmh_.js";import{n as x,t as S}from"./capgoAdapter-KNLHDj7G.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var _t=e=>{let t=e?.retry;return{maxRetries:t?.maxRetries??3,initialRetryDelay:t?.initialDelayMs??1e3,maxRetryDelay:t?.maxDelayMs??8e3,connectionTimeout:e?.connectionTimeoutMs??1e4}},vt=()=>({async createSession(e){return pt(e)},connect(e,t,n){let r=ft(e,t.onEvent,t.onError,_t(n));return{close:()=>r()}},async sendInput(e,t){await dt(e,t)},async resize(e){await mt(e.sessionId,e.cols,e.rows)},async close(e){await ht(e)},async restartSession(e,t){return ut(e,{cwd:t.cwd??``,cols:t.cols,rows:t.rows})},async forceKill(e){await lt(e)}}),yt=()=>({checkIsGitRepository:Ae,getGitStatus:de,getGitDiff:pe,getGitFileDiff:me,revertGitFile:Xe,stageGitFile:Ge,stageGitFiles:at,unstageGitFile:Be,unstageGitFiles:Re,stageGitHunk:Ne,unstageGitHunk:Te,revertGitHunk:tt,isLinkedWorktree:$e,getGitBranches:fe,deleteGitBranch:st,deleteRemoteBranch:_e,removeRemote:Pe,generateCommitMessage:oe,generatePullRequestDescription:ae,listGitWorktrees:p,validateGitWorktree:_,createGitWorktree:h,deleteGitWorktree:g,validateWorktreeDirectory:ke,canonicalizeWorktreeState:et,createGitCommit(e,t,n){return Le(e,t,n)},gitPush:ye,gitPull:ce,gitFetch:be,listGitStashes:ue,countGitStashFiles:Ke,stashGitChanges:Qe,applyGitStash:Ye,popGitStash:Ce,dropGitStash:ve,checkoutBranch:We,createBranch:ze,renameBranch:rt,getGitLog(e,t){return le(e,t)},getCommitFiles:Ue,getCurrentGitIdentity:He,hasLocalIdentity:xe,setGitIdentity:je,getGitIdentities:se,createGitIdentity:we,updateGitIdentity:ot,deleteGitIdentity:Oe,getRemotes:re,rebase:te,abortRebase:Ee,continueRebase:Ze,merge:Se,abortMerge:Ve,continueMerge:Fe,checkoutCommit:it,cherryPick:Me,revertCommit:De,resetToCommit:Je,stash:Ie,stashPop:qe,getConflictDetails:ne,worktree:{list:p,validate:_,bootstrapStatus:ge,preview:he,create:h,remove:g}}),C=e=>e.replace(/\\/g,`/`),bt=(e,t)=>({directory:C(t?.directory||t?.path||e),entries:(Array.isArray(t?.entries)?t.entries:[]).filter(e=>!!(e&&typeof e.name==`string`&&typeof e.path==`string`)).map(e=>({name:e.name,path:C(e.path),isDirectory:!!e.isDirectory}))}),w=(e,t)=>{let n=t||e?.();return n?{"x-opencode-directory":n}:void 0},xt=({getDirectory:e})=>({async listDirectory(t,n){let r=C(t),i=new URLSearchParams;r&&i.set(`path`,r),n?.respectGitignore&&i.set(`respectGitignore`,`true`);let a=await d(`/api/fs/list`,{query:i,headers:w(e)});if(!a.ok){let e=await a.json().catch(()=>({error:a.statusText}));throw Error(e.error||`Failed to list directory`)}return bt(r,await a.json())},async search(t){let n=new URLSearchParams,r=C(t.directory);r&&n.set(`directory`,r),n.set(`query`,t.query),n.set(`dirs`,`false`),n.set(`type`,`file`),typeof t.maxResults==`number`&&Number.isFinite(t.maxResults)&&n.set(`limit`,String(t.maxResults));let i=await d(`/api/find/file`,{query:n,headers:w(e)});if(!i.ok){let e=await i.json().catch(()=>({error:i.statusText}));throw Error(e.error||`Failed to search files`)}let a=await i.json();return(Array.isArray(a)?a:[]).map(e=>({path:C(`${r}/${e}`),preview:[C(e)]}))},async createDirectory(t){let n=C(t),r=await d(`/api/fs/mkdir`,{method:`POST`,headers:{"Content-Type":`application/json`,...w(e)},body:JSON.stringify({path:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to create directory`)}let i=await r.json();return{success:!!i?.success,path:typeof i?.path==`string`?C(i.path):n}},async statFile(t,n){let r=C(t),i=new URLSearchParams({path:r});n?.fingerprint&&i.set(`fingerprint`,`true`),n?.allowOutsideWorkspace&&i.set(`allowOutsideWorkspace`,`true`),n?.outsideFileGrant&&i.set(`outsideFileGrant`,n.outsideFileGrant);let a=await d(`/api/fs/stat`,{query:i,headers:w(e,n?.directory)});if(!a.ok){let e=await a.json().catch(()=>({error:a.statusText}));throw Error(e.error||`Failed to stat file`)}let o=await a.json().catch(()=>({}));return{path:typeof o.path==`string`?C(o.path):r,isFile:!!o.isFile,size:typeof o.size==`number`?o.size:0,mtimeMs:typeof o.mtimeMs==`number`?o.mtimeMs:void 0,sha256:typeof o.sha256==`string`?o.sha256:void 0,mimeType:typeof o.mimeType==`string`?o.mimeType:void 0,filename:typeof o.filename==`string`?o.filename:void 0,isBinary:typeof o.isBinary==`boolean`?o.isBinary:void 0}},async readFile(t,n){let r=C(t);if(!n?.optional)return{content:await(await ct({path:r,...n,directory:n?.directory??e?.()})).text(),path:r,exists:!0};let i=new URLSearchParams({path:r});n?.allowOutsideWorkspace&&i.set(`allowOutsideWorkspace`,`true`),n?.outsideFileGrant&&i.set(`outsideFileGrant`,n.outsideFileGrant),n?.optional&&i.set(`optional`,`true`);let a=await d(`/api/fs/read`,{query:i,cache:n?.optional?`no-store`:`default`,headers:w(e,n?.directory)});if(!a.ok){let e=await a.json().catch(()=>({error:a.statusText}));throw Error(e.error||`Failed to read file`)}let o=await a.text();if(n?.optional){let e=a.headers.get(`x-yuri-file-exists`);if(e!==`true`&&e!==`false`)throw Error(`Optional file read requires an existence response header`);return{content:o,path:r,exists:e===`true`}}return{content:o,path:r,exists:!0}},async writeFile(t,n){let r=C(t),i=await d(`/api/fs/write`,{method:`POST`,headers:{"Content-Type":`application/json`,...w(e)},body:JSON.stringify({path:r,content:n})});if(!i.ok){let e=await i.json().catch(()=>({error:i.statusText}));throw Error(e.error||`Failed to write file`)}let a=await i.json().catch(()=>({}));return{success:!!a.success,path:typeof a.path==`string`?C(a.path):r}},async delete(t){let n=C(t),r=await d(`/api/fs/delete`,{method:`POST`,headers:{"Content-Type":`application/json`,...w(e)},body:JSON.stringify({path:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to delete file`)}return{success:!!(await r.json().catch(()=>({}))).success}},async rename(t,n){let r=await d(`/api/fs/rename`,{method:`POST`,headers:{"Content-Type":`application/json`,...w(e)},body:JSON.stringify({oldPath:t,newPath:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to rename file`)}let i=await r.json().catch(()=>({}));return{success:!!i.success,path:typeof i.path==`string`?C(i.path):n}},async revealPath(t){let n=await d(`/api/fs/reveal`,{method:`POST`,headers:{"Content-Type":`application/json`,...w(e)},body:JSON.stringify({path:C(t)})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to reveal path`)}return{success:!!(await n.json().catch(()=>({}))).success}},async downloadFile(t){let n=C(t);await gt({path:n,directory:e?.()})}}),T=`/api/config/settings`,St=`/api/config/reload`,E=e=>!e||typeof e!=`object`?{}:e,Ct=()=>({async load(){let e=await d(T,{method:`GET`,headers:{Accept:`application/json`}});if(!e.ok)throw Error(`Failed to load settings: ${e.statusText}`);return{settings:E(await e.json().catch(()=>({}))),source:`web`}},async save(e){let t=await d(T,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to save settings`)}return E(await t.json().catch(()=>({})))},async restartOpenCode(){let e=await d(St,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({error:e.statusText}));throw Error(t.error||`Failed to restart OpenCode`)}return{restarted:!0}}}),wt=()=>({async requestDirectoryAccess(e){return{success:!0,path:e.path}},async startAccessingDirectory(e){return{success:!0}},async stopAccessingDirectory(e){return{success:!0}}}),Tt=1500,D=5e3,Et=`yuri-notification-claim:`,O=new Map,Dt=()=>typeof document>`u`||document.visibilityState===`visible`&&document.hasFocus(),Ot=e=>(typeof e?.tag==`string`?e.tag.trim():``)||[e?.sessionId,e?.kind,e?.title,e?.body].filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).join(`|`),kt=e=>{for(let[t,n]of O)e-n>D&&O.delete(t)},At=e=>{let t=Ot(e);if(!t)return!0;let n=Date.now();if(kt(n),n-(O.get(t)??0)<D)return!1;try{if(typeof window<`u`&&window.localStorage){let e=`${Et}${t}`,r=Number(window.localStorage.getItem(e)??`0`);if(Number.isFinite(r)&&n-r<D)return O.set(t,r),!1;Number.isFinite(r)&&r>0&&window.localStorage.removeItem(e),window.localStorage.setItem(e,String(n))}}catch{}return O.set(t,n),!0},k=async()=>{if(typeof navigator>`u`||!(`serviceWorker`in navigator))return null;let e=null;try{e=await navigator.serviceWorker.getRegistration()??null}catch{e=null}if(e?.active)return e;if(!e)return null;try{return await Promise.race([navigator.serviceWorker.ready,new Promise(e=>{setTimeout(()=>e(null),Tt)})])??e}catch{return e}},jt=async e=>{let t=await k();if(!t||typeof t.showNotification!=`function`)return!1;try{return await t.showNotification(e?.title??`Yuri`,{body:e?.body,tag:e?.tag}),!0}catch(e){return console.warn(`Failed to send notification via service worker`,e),!1}},Mt=async()=>{let e=await k();if(!e||!(`pushManager`in e)||!e.pushManager)return!1;try{return!!await e.pushManager.getSubscription()}catch{return!1}},Nt=async e=>{if(e?.requireHidden&&typeof document<`u`&&document.hasFocus())return!0;if(typeof Notification>`u`)return!1;if(Notification.permission==="default"&&await Notification.requestPermission()!==`granted`||Notification.permission!==`granted`)return console.warn(`Notification permission not granted`),!1;if(!Dt()&&await Mt()||!At(e))return!0;try{return await jt(e)||new Notification(e?.title??`Yuri`,{body:e?.body,tag:e?.tag}),!0}catch(e){return console.warn(`Failed to send notification`,e),!1}},Pt=async e=>{if(typeof window>`u`)return!1;let t=window.__YURI_DESKTOP__;if(!t?.invoke)return!1;try{return await t.invoke(`desktop_notify`,{payload:{title:e?.title,body:e?.body,tag:e?.tag,kind:e?.kind,sessionId:e?.sessionId,directory:e?.directory,requireHidden:e?.requireHidden}}),!0}catch(e){return console.warn(`Failed to send native notification (desktop)`,e),!1}},Ft=()=>({async notifyAgentCompletion(e){return await Pt(e)||await Nt(e)},canNotify:()=>typeof window<`u`&&window.__YURI_DESKTOP__?.invoke?!0:typeof Notification<`u`&&Notification.permission===`granted`}),It=()=>({async getAvailableTools(){let e=await d(`/api/experimental/tool/ids`);if(!e.ok)throw Error(`Tools API returned ${e.status} ${e.statusText}`);let t=await e.json();if(!Array.isArray(t))throw Error(`Tools API returned invalid data format`);return t.filter(e=>typeof e==`string`&&e!==`invalid`).sort()}}),A=async(e,t)=>{try{let n=await d(e,{...t,credentials:`include`,headers:{Accept:`application/json`,...t?.headers??{}}});return n.ok?await n.json():null}catch{return null}},Lt=()=>({async getVapidPublicKey(){return A(`/api/push/vapid-public-key`)},async subscribe(e){return A(`/api/push/subscribe`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async unsubscribe(e){return A(`/api/push/subscribe`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async setVisibility(e){return A(`/api/push/visibility`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),keepalive:!0})},async registerApnsToken(e){return A(`/api/push/apns-token`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async unregisterApnsToken(e){return A(`/api/push/apns-token`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async registerLiveActivityToken(e){return A(`/api/push/live-activity-token`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async unregisterLiveActivityToken(e){return A(`/api/push/live-activity-token`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})}}),j=async e=>await e.json().catch(()=>null),Rt=({urls:e})=>({async authStatus(){let e=await d(`/api/github/auth/status`,{method:`GET`,headers:{Accept:`application/json`}}),t=await j(e);if(!e.ok||!t)throw Error(t?.error||e.statusText||`Failed to load GitHub status`);return t},async authStart(){let e=await d(`/api/github/auth/start`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({})}),t=await j(e);if(!e.ok||!t||!(`deviceCode`in t))throw Error(t?.error||e.statusText||`Failed to start GitHub auth`);return t},async authComplete(e){let t=await d(`/api/github/auth/complete`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({deviceCode:e})}),n=await j(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to complete GitHub auth`);return n},async authDisconnect(){let e=await d(`/api/github/auth`,{method:`DELETE`,headers:{Accept:`application/json`}}),t=await j(e);if(!e.ok)throw Error(t?.error||e.statusText||`Failed to disconnect GitHub`);return{removed:!!t?.removed}},async authActivate(e){let t=await d(`/api/github/auth/activate`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({accountId:e})}),n=await j(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to activate GitHub account`);return n},async authSetGhCliDisabled(e){let t=await d(`/api/github/auth/gh-cli`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({disabled:e})}),n=await j(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to update gh CLI setting`);return{disabled:!!n.disabled}},async me(){let e=await d(`/api/github/me`,{method:`GET`,headers:{Accept:`application/json`}}),t=await j(e);if(!e.ok||!t)throw Error(t?.error||e.statusText||`Failed to fetch GitHub user`);return t},async prStatus(e,t,n,r){let i=new URLSearchParams({directory:e,branch:t,...n?{remote:n}:{},...r?.force?{force:`true`}:{}}),a=await d(`/api/github/pr/status?${i.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),o=await j(a);if(!a.ok||!o)throw Error(o?.error||a.statusText||`Failed to load PR status`);return o},async prCreate(e){let t=await d(`/api/github/pr/create`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)}),n=await j(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to create PR`);return n},async prUpdate(e){let t=await d(`/api/github/pr/update`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)}),n=await j(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to update PR`);return n},async prMerge(e){let t=await d(`/api/github/pr/merge`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)}),n=await j(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to merge PR`);return n},async prReady(e){let t=await d(`/api/github/pr/ready`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)}),n=await j(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to mark PR ready`);return n},async repoUpstream(e){let t=await d(`/api/github/repo/upstream?directory=${encodeURIComponent(e)}`,{method:`GET`,headers:{Accept:`application/json`}}),n=await j(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to detect upstream repo`);return n},async repoBranches(e,t){let n=await d(`/api/github/repo/branches?owner=${encodeURIComponent(e)}&repo=${encodeURIComponent(t)}`,{method:`GET`,headers:{Accept:`application/json`}}),r=await j(n);if(!n.ok||!r)throw Error(r?.error||n.statusText||`Failed to fetch repo branches`);return r.branches??[]},async prsList(e,t){let n=t?.page??1,r=new URLSearchParams({directory:e,page:String(n)});t?.query&&r.set(`query`,t.query);let i=await d(`/api/github/pulls/list?${r.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),a=await j(i);if(!i.ok||!a)throw Error(a?.error||i.statusText||`Failed to load pull requests`);return a},async prContext(t,n,r){let i=new URLSearchParams({directory:t,number:String(n)});r?.includeDiff&&i.set(`diff`,`1`),r?.includeCheckDetails&&i.set(`checkDetails`,`1`),r?.sourceRepo?.owner&&r.sourceRepo.repo&&(i.set(`owner`,r.sourceRepo.owner),i.set(`repo`,r.sourceRepo.repo));let a=await d(e.api(`/api/github/pulls/context`,i),{method:`GET`,headers:{Accept:`application/json`}}),o=await j(a);if(!a.ok||!o)throw Error(o?.error||a.statusText||`Failed to load pull request context`);return o},async issuesList(e,t){let n=t?.page??1,r=new URLSearchParams({directory:e,page:String(n)});t?.query&&r.set(`query`,t.query);let i=await d(`/api/github/issues/list?${r.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),a=await j(i);if(!i.ok||!a)throw Error(a?.error||i.statusText||`Failed to load issues`);return a},async issueGet(t,n,r){let i=new URLSearchParams({directory:t,number:String(n)});r?.sourceRepo?.owner&&r.sourceRepo.repo&&(i.set(`owner`,r.sourceRepo.owner),i.set(`repo`,r.sourceRepo.repo));let a=await d(e.api(`/api/github/issues/get`,i),{method:`GET`,headers:{Accept:`application/json`}}),o=await j(a);if(!a.ok||!o)throw Error(o?.error||a.statusText||`Failed to load issue`);return o},async issueComments(t,n,r){let i=new URLSearchParams({directory:t,number:String(n)});r?.sourceRepo?.owner&&r.sourceRepo.repo&&(i.set(`owner`,r.sourceRepo.owner),i.set(`repo`,r.sourceRepo.repo));let a=await d(e.api(`/api/github/issues/comments`,i),{method:`GET`,headers:{Accept:`application/json`}}),o=await j(a);if(!a.ok||!o)throw Error(o?.error||a.statusText||`Failed to load issue comments`);return o}}),M=async e=>await e.json().catch(()=>null),zt=()=>({async listClients(){let e=await d(`/api/client-auth/clients`,{method:`GET`,headers:{Accept:`application/json`}}),t=await M(e);if(!e.ok||!t)throw Error(t?.error||e.statusText||`Failed to load remote clients`);return Array.isArray(t.clients)?t.clients:[]},async createClient(e={}){let t=await d(`/api/client-auth/clients`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({label:e.label??``})}),n=await M(t);if(!t.ok||!n?.client||typeof n.token!=`string`)throw Error(n?.error||t.statusText||`Failed to create remote client token`);return n},async createPairingSession(e={}){let t=await d(`/api/client-auth/pairing/sessions`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({label:e.label??``,...e.allowedClientKinds?{allowedClientKinds:e.allowedClientKinds}:{},...e.serverUrl?{serverUrl:e.serverUrl}:{},...typeof e.includeRelay==`boolean`?{includeRelay:e.includeRelay}:{},...typeof e.includeDirect==`boolean`?{includeDirect:e.includeDirect}:{},...e.relayUrl?{relayUrl:e.relayUrl}:{}})}),n=await M(t);if(!t.ok||typeof n?.pairing?.secret!=`string`||!n?.server)throw Error(n?.error||t.statusText||`Failed to create pairing session`);return n},async listPendingPairings(){let e=await d(`/api/client-auth/pairing/sessions`,{method:`GET`,headers:{Accept:`application/json`}}),t=await M(e);if(!e.ok||!t)throw Error(t?.error||e.statusText||`Failed to load pending pairings`);return Array.isArray(t.pending)?t.pending:[]},async getPairingTransports(){let e=await d(`/api/client-auth/pairing/transports`,{method:`GET`,headers:{Accept:`application/json`}}),t=await M(e);if(!e.ok||!t)throw Error(t?.error||e.statusText||`Failed to load pairing transports`);return{...typeof t.serverName==`string`?{serverName:t.serverName}:{},local:t.local??null,lan:t.lan??null,relayAvailable:t.relayAvailable===!0,...typeof t.relayUrl==`string`?{relayUrl:t.relayUrl}:{},...typeof t.relayUrlLocked==`boolean`?{relayUrlLocked:t.relayUrlLocked}:{}}},async cancelPairing(e){let t=await d(`/api/client-auth/pairing/sessions/${encodeURIComponent(e)}`,{method:`DELETE`,headers:{Accept:`application/json`}}),n=await M(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to cancel pairing`);return{cancelled:n.cancelled===!0}},async renameClient(e,t){let n=await d(`/api/client-auth/clients/${encodeURIComponent(e)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({label:t})}),r=await M(n);if(!n.ok||!r?.client)throw Error(r?.error||n.statusText||`Failed to rename remote client`);return r.client},async revokeClient(e){let t=await d(`/api/client-auth/clients/${encodeURIComponent(e)}`,{method:`DELETE`,headers:{Accept:`application/json`}}),n=await M(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to revoke remote client`);return n},async purgeRevokedClients(){let e=await d(`/api/client-auth/clients`,{method:`DELETE`,headers:{Accept:`application/json`}}),t=await M(e);if(!e.ok||!t)throw Error(t?.error||e.statusText||`Failed to clear revoked clients`);return t}}),N=e=>typeof e==`object`&&!!e&&!Array.isArray(e),P=e=>typeof e==`number`&&Number.isFinite(e),Bt=e=>{if(!N(e)||typeof e.ok!=`boolean`)return!1;if(e.ok===!0)return N(e.session)&&typeof e.session.id==`string`&&typeof e.messageID==`string`;let t=e.phase;if(typeof t!=`string`)return!1;switch(t){case`validate`:return typeof e.error==`string`&&Array.isArray(e.errors)&&e.errors.every(e=>typeof e==`string`);case`create`:return!(typeof e.error!=`string`||`status`in e&&e.status!==void 0&&!P(e.status));case`prompt`:return N(e.session)&&typeof e.session.id==`string`&&typeof e.messageID==`string`&&typeof e.ambiguous==`boolean`&&typeof e.error==`string`&&(!(`status`in e)||e.status===void 0||P(e.status));case`conflict`:return typeof e.error==`string`;case`unavailable`:return typeof e.error==`string`;case`internal`:return typeof e.error==`string`;default:return!1}},Vt=()=>({async createWithPrompt(e,t){let n;try{n=await d(`/api/yuri/conversations`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),signal:t})}catch{throw Error(`Conversation request failed`)}let r;try{r=await n.json()}catch{throw Error(`Unexpected server response: invalid JSON`)}if(!Bt(r))throw Error(`Unexpected server response: result shape mismatch`);return r}}),Ht=`https://yuri-updates.xiaobe.top/v1/mobile/update/check`,Ut=`https://yuri-origin.xiaobe.top/v1/mobile/update/check`,Wt=1e4,F=`com.yee94.yuri`,I=`yuri.mobile-ota.device-id.v1`,L=e=>typeof e==`string`&&e.trim().length>0?e.trim():null,R=()=>{try{let e=v;return((typeof e.getConfig==`function`?e.getConfig():void 0)??e.config)?.YuriOTA??{}}catch{return{}}},z=e=>e===`beta`||e===`stable`?e:R().channel===`stable`?`stable`:`beta`,B=()=>{let e=R().shellApiVersion;return typeof e==`number`&&Number.isFinite(e)&&e>0?Math.floor(e):1},V=()=>{let e=nt();if(e===`ios`||e===`android`)return e;try{let e=v.getPlatform();if(e===`ios`||e===`android`)return e}catch{}return`android`},Gt=()=>{if(typeof window>`u`)return null;try{return L(window.localStorage.getItem(I))}catch{return null}},H=e=>{if(!(typeof window>`u`))try{window.localStorage.setItem(I,e)}catch{}},U=async e=>{if(e)try{let t=L((await e.getDeviceId()).deviceId);if(t)return H(t),t}catch{}let t=Gt();if(t)return t;let n=f();return H(n),n},W=async()=>{let e=L(`0.1.2`);if(m())try{let{App:t}=await y(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2])),n=await t.getInfo(),r=L(n.version)??e??`0.0.0`,i=L(n.build),a=i?Number.parseInt(i,10):0;return{applicationId:L(n.id)??void 0,version:r,build:Number.isFinite(a)?a:0}}catch{}return{version:e??`0.0.0`,build:0}},G=(e,t,n)=>{let r=L(e?.version),i=L(t);if(n===`beta`&&i)return i;if(r&&r!==`builtin`)return i&&i!==r&&i.startsWith(`${r}-`)?i:r;let a=L(e?.id);return a&&a!==`builtin`?a:i??`builtin`},Kt=()=>L(`0.1.2`),K=e=>{let t=e?.trim().match(/^v?(\d+)\.\d+\.\d+(?:-beta\.\d+)?$/i),n=t?Number(t[1]):void 0;return n!==void 0&&Number.isSafeInteger(n)?n:void 0},q=async(e,t)=>{let n=Kt();if(!e)return G(null,n,t);try{return G((await e.current()).bundle,n,t)}catch{return G(null,n,t)}},qt=()=>[Ht,Ut],Jt=(e,t,n)=>{let r=e-n();return r<=0||t<=0?null:Math.max(1,Math.ceil(r/t))};async function Yt(e,t,n,r){try{if(m())try{let{CapacitorHttp:r}=await y(async()=>{let{CapacitorHttp:e}=await import(`./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js`).then(e=>e.i);return{CapacitorHttp:e}},__vite__mapDeps([2,1])),i=Object.fromEntries(new Headers(t.headers).entries()),a;if(typeof t.body==`string`)try{a=JSON.parse(t.body)}catch{a=t.body}let o=await Promise.race([r.request({url:e,method:t.method||`GET`,headers:i,data:a,connectTimeout:n,readTimeout:n}),new Promise(e=>{window.setTimeout(()=>e(null),n)})]);return o?{ok:o.status>=200&&o.status<300,status:o.status,json:async()=>{if(typeof o.data==`string`)try{return JSON.parse(o.data)}catch{return o.data}return o.data}}:null}catch{}let i=await r(e,{...t,signal:AbortSignal.timeout(n)});return{ok:i.ok,status:i.status,json:()=>i.json()}}catch{return null}}var Xt=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return!(t.status!==`ok`||t.primaryAction!==`none`&&t.primaryAction!==`apply_ota`&&t.primaryAction!==`install_native_required`||!t.ota||typeof t.ota!=`object`||!t.native||typeof t.native!=`object`||typeof t.nextCheckInSec!=`number`||!Number.isFinite(t.nextCheckInSec))},Zt=e=>{let t=e;return t.isChannelRollback===!0||t.is_channel_rollback===!0?{...e,isChannelRollback:!0}:e};async function Qt(e,t,n,r){let i=await Yt(e,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify(t)},n,r);if(!i?.ok)return null;let a;try{a=await i.json()}catch{return null}if(!Xt(a))return null;if(a.primaryAction===`apply_ota`&&t.applicationId!==F)throw Error(`Yuri OTA requires the Yuri native application`);if(a.primaryAction===`apply_ota`&&(t.releaseMajor===void 0||K(a.ota.bundle?.releaseVersion)!==t.releaseMajor))throw Error(`OTA release major mismatch`);return Zt(a)}async function $t(e={}){let t=e.updater===void 0?await S():e.updater;if(!t&&!m())throw new b;let n=e.fetchImpl??fetch,r=e.now??Date.now,i=z(e.channelOverride),[a,o,s]=await Promise.all([U(t),W(),q(t,i)]),c={channel:i,platform:V(),applicationId:o.applicationId,deviceId:a,nativeVersion:o.version,nativeBuild:o.build,shellApiVersion:B(),currentBundleId:s,releaseMajor:K(s)??K(o.version)},l=qt(),u=r()+Wt,d=null;for(let[e,t]of l.entries()){let i=Jt(u,l.length-e,r);if(i===null)break;try{let e=await Qt(t,c,i,n);if(e)return e;d=Error(`Mobile OTA check failed at ${t}`)}catch(e){d=e instanceof Error?e:Error(`Mobile OTA check failed`)}}throw d??Error(`Unable to check for mobile OTA updates`)}async function en(e){let t=await S();if(!t)return null;let n=await J({updater:t});if(n.applicationId!==F)throw Error(`Yuri OTA requires the Yuri native application`);if(n.releaseMajor===void 0||K(e.releaseVersion)!==n.releaseMajor)throw Error(`OTA release major mismatch`);try{let{bundles:n}=await t.list();return n.find(t=>t.checksum===e.checksum&&t.version===e.releaseVersion&&(t.status===`success`||t.status===`pending`))?.id??null}catch{return null}}async function tn(e){let t=await S();if(!t)throw new b;let n=await J({updater:t});if(n.applicationId!==F)throw Error(`Yuri OTA requires the Yuri native application`);if(n.releaseMajor===void 0||K(e.releaseVersion)!==n.releaseMajor)throw Error(`OTA release major mismatch`);return(await t.download({url:e.url,version:e.releaseVersion,checksum:e.checksum,...e.sessionKey?{sessionKey:e.sessionKey}:{}})).id}async function nn(){let e=await S();if(!e)throw new b;await e.reload()}async function rn(e){let t=await S();if(!t)throw new b;await t.next({id:e})}async function J(e={}){let t=e.updater===void 0?await S():e.updater,n=z(e.channelOverride),[r,i,a]=await Promise.all([U(t),W(),q(t,n)]);return{channel:n,platform:V(),applicationId:i.applicationId,deviceId:r,nativeVersion:i.version,nativeBuild:i.build,shellApiVersion:B(),currentBundleId:a,releaseMajor:K(a)??K(i.version)}}var Y=null,X=e=>typeof e==`string`&&e.trim().length>0?e.trim():null,Z=async()=>{let e=X(`0.1.2`);try{if(v.isNativePlatform()){let{App:t}=await y(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2]));return X((await t.getInfo()).version)??e??`unknown`}}catch{}return e??`unknown`},an=()=>({async checkForOtaUpdate(e){if(!x()&&!v.isNativePlatform())throw new b;return $t(e?.channelOverride?{channelOverride:e.channelOverride}:{})},async downloadOtaUpdate(e){if(!x())throw new b;let t=await en(e);return t?(Y=t,{skipped:!0}):(Y=await tn(e),{skipped:!1})},async applyOtaUpdateNow(){if(!x())throw new b;await nn()},async queueOtaUpdateForNextLaunch(){if(!x())throw new b;let e=Y;if(!e)throw Error(`No downloaded OTA bundle to queue`);await rn(e)},async getOtaStatus(){if(!x())return{supported:!1,currentBundleId:`builtin`,nativeVersion:await Z()};let e=await S();if(!e)return{supported:!1,currentBundleId:`builtin`,nativeVersion:await Z()};try{let[t,n]=await Promise.all([e.current(),Z()]);return{supported:!0,currentBundleId:X(t.bundle?.id)||`builtin`,nativeVersion:n}}catch{return{supported:!0,currentBundleId:`builtin`,nativeVersion:await Z()}}}}),on=()=>({api:(...e)=>s().api(...e),authenticatedAsset:(...e)=>s().authenticatedAsset(...e),auth:(...e)=>s().auth(...e),health:(...e)=>s().health(...e),rawFile:(...e)=>s().rawFile(...e),sse:(...e)=>s().sse(...e),websocket:(...e)=>s().websocket(...e)}),sn=(e={})=>{let t=e.urls??o();c(t);let n=on();return{runtime:{platform:`web`,isDesktop:!1,isVSCode:!1,label:`web`},terminal:vt(),git:yt(),files:xt({urls:n,getDirectory:()=>ie.getState().currentDirectory}),settings:Ct(),permissions:wt(),notifications:Ft(),github:Rt({urls:n}),push:Lt(),mobileUpdates:an(),clientAuth:zt(),tools:It(),conversations:Vt()}},Q=(e,t)=>{if(!e||!t)return!1;try{return new URL(e).origin===new URL(t).origin}catch{return!1}},$=Promise.resolve(),cn=()=>$,ln=()=>{let o=typeof window.__YURI_API_BASE_URL__==`string`?window.__YURI_API_BASE_URL__.trim():``,s=typeof window.__YURI_CLIENT_TOKEN__==`string`?window.__YURI_CLIENT_TOKEN__.trim():``,c=typeof window.__YURI_LOCAL_ORIGIN__==`string`?window.__YURI_LOCAL_ORIGIN__.trim():``,d=l({apiBaseUrl:o||void 0,realtimeBaseUrl:o||void 0});a({apiBaseUrl:o,runtimeKey:Q(o,c)?`local`:null}),n(s||null),t(window.__YURI_RUNTIME_HEADERS__||null),i(o||void 0).catch(()=>{}),c&&!Q(o,c)&&Object.keys(r()).length>0&&e(c).catch(()=>{}),u();let f=window.__YURI_RELAY_HOST_ID__;return $=Promise.race([ee(typeof f==`string`&&f?f:void 0).catch(()=>{}),new Promise(e=>{window.setTimeout(e,1e4)})]),sn({urls:d})};export{cn as n,ln as t};
|