@yuriai/web 0.2.24 → 0.2.25-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentAvatar-pXIw9gfD.js → AgentAvatar--wjVXk3I.js} +1 -1
- package/dist/assets/{AssistantView-C-w3bUrv.js → AssistantView-CMTUUXb3.js} +3 -3
- package/dist/assets/{DiagramView-DG3ivTxa.js → DiagramView-Bi8kuSia.js} +1 -1
- package/dist/assets/{FadeInOnReveal-DAByozhu.js → FadeInOnReveal-555z1y1N.js} +1 -1
- package/dist/assets/{GuiPluginSurface-BVnl7lAb.js → GuiPluginSurface-Bgxiz8qT.js} +1 -1
- package/dist/assets/{GuiPluginWindow-Ccm-tyo2.js → GuiPluginWindow-CAmfr79x.js} +1 -1
- package/dist/assets/{Icon-_iMMNG9-.js → Icon-Bn4Eec3Y.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-BPEqdGkV.js → ImageLoadingPlaceholder-BMsQLN_b.js} +1 -1
- package/dist/assets/{LoadingImage-COJSLMyx.js → LoadingImage-DI7sb_H_.js} +1 -1
- package/dist/assets/MarkdownRenderer-CcZcvvDG.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-BNKrdLn6.js → MarkdownRendererImpl-8O2aKY2q.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-D4UBaz2A.js → MarkstreamRendererImpl-C8eYfcfD.js} +1 -1
- package/dist/assets/MobileDetailNavigation-Czeae_oi.js +1 -0
- package/dist/assets/{MobileResizableSheet-Cp3AyvCP.js → MobileResizableSheet-_6OvPSMI.js} +1 -1
- package/dist/assets/{MobileShareBridge-BAGwzKL9.js → MobileShareBridge-D8zXaSg0.js} +2 -2
- package/dist/assets/{MobileTabPageHeader-B8XecBxj.js → MobileTabPageHeader-XmMFIKsG.js} +1 -1
- package/dist/assets/{MultiRunWindow-wzhT2t36.js → MultiRunWindow-CwZd3gtn.js} +1 -1
- package/dist/assets/{OnboardingScreen-BwQKn_88.js → OnboardingScreen-g8PDztN3.js} +1 -1
- package/dist/assets/{OverlayScrollbar-U7GvtZ-e.js → OverlayScrollbar-COv8rH_z.js} +1 -1
- package/dist/assets/{SettingsView-CUJaYbvx.js → SettingsView-BgnDwW4E.js} +1 -1
- package/dist/assets/{SettingsWindow-Bj0swB6o.js → SettingsWindow-B6tCzIeX.js} +1 -1
- package/dist/assets/{TerminalView-DxdoY20L.js → TerminalView-Hw5rX-I1.js} +1 -1
- package/dist/assets/ToolOutputDialog-B9u7aLxx.js +10 -0
- package/dist/assets/{YuriLogo-BFsNnpdF.js → YuriLogo-BP4j1iqV.js} +1 -1
- package/dist/assets/{appThemeRegistry-B8xSNJj3.js → appThemeRegistry-CmS5JA-G.js} +1 -1
- package/dist/assets/{assistant-attachment-cache-C2SmtQG7.js → assistant-attachment-cache-Cis9yYGt.js} +1 -1
- package/dist/assets/{button-K_jXf_uP.js → button-Be1cqulG.js} +1 -1
- package/dist/assets/{capgoAdapter-EJ9NoUtY.js → capgoAdapter-DukVH9cH.js} +1 -1
- package/dist/assets/{collapsible-DqW91GHI.js → collapsible-DqfguRMp.js} +1 -1
- package/dist/assets/{desktop-5DP3-Bao.js → desktop-JwYqThiw.js} +1 -1
- package/dist/assets/{desktopHosts-CrVcscUO.js → desktopHosts-CB0CTcMg.js} +1 -1
- package/dist/assets/{desktopRelayRestore-DJFLfsuw.js → desktopRelayRestore-CoLLVJw8.js} +1 -1
- package/dist/assets/{device-BKQ_0FdZ.js → device-hj359GjJ.js} +1 -1
- package/dist/assets/{diagram-Pn5Vu970.js → diagram-hEIRiKol.js} +1 -1
- package/dist/assets/{dialog-DivrqsAq.js → dialog-BS-KgM5J.js} +1 -1
- package/dist/assets/{dropdown-menu.styles-zVps2mhA.js → dropdown-menu.styles-xxM2ofOp.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-BHQaa6JY.js → fileMentionTouchSelection-DcxWoJGA.js} +1 -1
- package/dist/assets/{fileQueries-Bd-OEFmO.js → fileQueries-COS23nLq.js} +1 -1
- package/dist/assets/{fileReferenceActions-DkLLKj6A.js → fileReferenceActions-Cus9oSW7.js} +1 -1
- package/dist/assets/{gitApi-CxEKzsxG.js → gitApi-BiKfKqjS.js} +1 -1
- package/dist/assets/{gitApiHttp-Bnr4_wxy.js → gitApiHttp-BBRKl9WX.js} +1 -1
- package/dist/assets/{gui-D3wrcUs6.js → gui-BHEKelUx.js} +1 -1
- package/dist/assets/{host-DgJqhX6n.js → host-DrqLUbqt.js} +1 -1
- package/dist/assets/{image-loading-DVZlFuU5.js → image-loading-DJZLvhMd.js} +1 -1
- package/dist/assets/{input-BcXfvvm_.js → input-DTdHYZ6r.js} +1 -1
- package/dist/assets/{insertionBoundaries-BRe1eEJ8.js → insertionBoundaries-CNMKn49m.js} +1 -1
- package/dist/assets/main-ByT1ZAIL.js +2 -0
- package/dist/assets/{main-DrTZmnej.js → main-CTadqx3q.js} +4 -4
- package/dist/assets/{markdownHeightCache-BaLmCxOF.js → markdownHeightCache-DnR01ECa.js} +1 -1
- package/dist/assets/{mcpQueries-CZhOdHBy.js → mcpQueries-6sG9ZjVo.js} +1 -1
- package/dist/assets/miniChat-DNpE8CT4.js +2 -0
- package/dist/assets/mobile-beR053ko.js +2 -0
- package/dist/assets/{mobileBackNavigation-YpHutGKo.js → mobileBackNavigation-B_oVUpda.js} +1 -1
- package/dist/assets/{multirun-CMHEBqrK.js → multirun-C0Umxqba.js} +1 -1
- package/dist/assets/{native-config-BB2iYljF.js → native-config-BrA4eJeL.js} +1 -1
- package/dist/assets/{persistence-BPb2hZ3c.js → persistence-CBL0OOdj.js} +1 -1
- package/dist/assets/{platform-wGCQUVxr.js → platform-DFJEtBlo.js} +1 -1
- package/dist/assets/{projectMeta-Dg9OJmrW.js → projectMeta-BIJduxkb.js} +1 -1
- package/dist/assets/{queryRuntime-DWgXfxGx.js → queryRuntime-Dkpnq3Z1.js} +1 -1
- package/dist/assets/{readiness-jjsKReaO.js → readiness-QT6UdOZK.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-DZwB5g10.js → renderElectronMiniChatApp-CePbEhMK.js} +2 -2
- package/dist/assets/renderMobileApp-BBXjR9eG.js +28 -0
- package/dist/assets/runtime-auth-DBn9yahL.js +1 -0
- package/dist/assets/{runtime-fetch-DfALP7-b.js → runtime-fetch-D4ja813o.js} +1 -1
- package/dist/assets/{runtime-file-download-xvItwYMc.js → runtime-file-download-B_c7JBoS.js} +1 -1
- package/dist/assets/runtime-file-resource-DpTxBCsp.js +2 -0
- package/dist/assets/{runtime-switch-DhMY9eiB.js → runtime-switch-DEZ1K7qW.js} +1 -1
- package/dist/assets/{runtimeConfig-Dltne9D7.js → runtimeConfig-B2Ik6SpE.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-Cg5UpXxg.js → runtimeEndpointReset-D5Lv6CW7.js} +3 -3
- package/dist/assets/{scheduledTaskNavigation-Bk2y-IY1.js → scheduledTaskNavigation-CYozx15H.js} +1 -1
- package/dist/assets/{sessionChangeSummary-DEHSsyvw.js → sessionChangeSummary-B09ensxQ.js} +1 -1
- package/dist/assets/{sessionLookup-2R9LMoF8.js → sessionLookup-CxQNDoJj.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-DR_NRIKS.js → sortable-tabs-strip-CQZ16rbO.js} +1 -1
- package/dist/assets/{speechSettingsQueries-ozQ8Mhi0.js → speechSettingsQueries-D-pzxl8-.js} +2 -2
- package/dist/assets/src-BFsc_2gs.css +2 -0
- package/dist/assets/tap-LkQum5bB.js +1 -0
- package/dist/assets/{terminalApi-Cjd7Jry6.js → terminalApi-C0_GUlPR.js} +1 -1
- package/dist/assets/{textarea-BnV-WjE-.js → textarea-BU8JtaSQ.js} +1 -1
- package/dist/assets/{tooltip-8gf-KZqb.js → tooltip-C8DhNU1d.js} +1 -1
- package/dist/assets/touch-gestures-zegXCZEP.js +1 -0
- package/dist/assets/types-CGf-3Ixa.js +2 -0
- package/dist/assets/{useAppFontEffects-cZSrS9NV.js → useAppFontEffects-d_JuX3bW.js} +39 -39
- package/dist/assets/{useAssistantUIStore-BZt-lLlW.js → useAssistantUIStore-NlYBroMc.js} +1 -1
- package/dist/assets/{useDesktopWindowControlsLayout-BSdFqddg.js → useDesktopWindowControlsLayout-P8AXtRbB.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-e-F-XtxW.js → useEffectiveDirectory-CGxEgwHB.js} +1 -1
- package/dist/assets/{useFontPreferences-CGThMzt0.js → useFontPreferences-DQAS94Z4.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-BIYkf6Km.js → useMobileNavigationStore-DSeBetKz.js} +4 -4
- package/dist/assets/{useUIStore-CEingF2z.js → useUIStore-96W41KFb.js} +1 -1
- package/dist/assets/{useWorkerHighlightedLines-B3gQr9bJ.js → useWorkerHighlightedLines-1GoCAzkh.js} +1 -1
- package/dist/index.html +21 -21
- package/dist/mini-chat.html +21 -21
- package/dist/mobile.html +21 -21
- package/package.json +1 -1
- package/server/lib/relay/DOCUMENTATION.md +27 -0
- package/server/lib/relay/cross-compat.test.js +42 -1
- package/server/lib/relay/e2ee.js +2 -2
- package/server/lib/relay/host-client.js +5 -3
- package/server/lib/relay/relay-server.e2e.test.ts +52 -1
- package/server/lib/relay/tunnel-codec.js +6 -5
- package/server/lib/relay/tunnel-host.js +4 -4
- package/server/lib/relay/tunnel-host.test.js +21 -0
- package/server/lib/remote-desktop/DOCUMENTATION.md +8 -0
- package/dist/assets/MarkdownRenderer-BvAzySCw.js +0 -2
- package/dist/assets/MobileDetailNavigation-C2dQ4cxR.js +0 -1
- package/dist/assets/ToolOutputDialog-T7WEKBA_.js +0 -10
- package/dist/assets/main-Bx5Hr212.js +0 -2
- package/dist/assets/miniChat-B9OCzzmD.js +0 -2
- package/dist/assets/mobile-CWceFL9L.js +0 -2
- package/dist/assets/renderMobileApp-BR5Ewan-.js +0 -28
- package/dist/assets/runtime-auth-BaBM02zI.js +0 -1
- package/dist/assets/runtime-file-resource-DtsKbFf3.js +0 -2
- package/dist/assets/src-BxW5eh2m.css +0 -2
- package/dist/assets/types-DP6as8RK.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/rolldown-runtime-hePW80VL.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,n as r,o as i}from"./runtime-switch-DhMY9eiB.js";import{n as a}from"./runtime-fetch-DfALP7-b.js";import{D as o,E as s,L as c,S as l,T as u,b as d,i as f,n as p,w as m,x as h}from"./desktop-5DP3-Bao.js";import{t as g}from"./runtimeAPIRegistry-C2VogTny.js";import{a as _,i as v,r as y}from"./vendor-zustand-o69pgTEK.js";import{it as b,nt as x,o as S,rt as C,s as w}from"./vendor-base-ui-CdzJ6My_.js";import{At as T,bt as E}from"./gitApiHttp-Bnr4_wxy.js";import{b as D,n as O}from"./useUIStore-CEingF2z.js";import{$ as k,d as A,i as j}from"./persistence-BPb2hZ3c.js";import{n as M}from"./vendor-react-BP2cRVqX.js";import{l as N,n as P,o as F,s as I}from"./vendor-tanstack-react-query-CdqCAt40.js";import{a as L,i as R,o as z,r as B,t as ee}from"./queryRuntime-DWgXfxGx.js";import{o as te}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{n as V}from"./pathNormalization-ewtPqJWn.js";import{n as ne,t as re}from"./platform-wGCQUVxr.js";import{a as H,t as ie}from"./types-DP6as8RK.js";import{$ as ae,A as oe,B as se,G as ce,H as U,J as le,L as ue,P as de,T as fe,U as pe,W as me,X as he,Y as ge,a as _e,at as W,dt as ve,f as ye,ft as be,g as xe,l as Se,pt as Ce,st as we,z as G}from"./vendor-codemirror-autocomplete-7c2L_4dM.js";import{c as Te,o as Ee,r as De}from"./vendor-codemirror-lang-angular-DXOgWEVj.js";import{n as Oe,r as ke}from"./vendor-codemirror-lang-json-mLulNbwB.js";import{n as Ae}from"./vendor-codemirror-lang-markdown-CV1IO6Qs.js";import{n as je}from"./vendor-codemirror-lang-python-YM2WVLHF.js";import{O as Me}from"./vendor-codemirror-legacy-modes-DwltVFbT.js";import{r as Ne}from"./vendor-reactuses-core-BJ-jJ4YM.js";import{a as Pe,d as Fe,f as Ie,p as Le,r as K,t as q}from"./button-K_jXf_uP.js";import{Ci as Re,Dr as ze,Lr as Be,Pr as Ve,Vr as J,ar as He,d as Ue,ho as We,lr as Ge,or as Ke,po as qe,rr as Je,sr as Ye,uo as Xe,ur as Ze,vi as Qe,xn as $e}from"./useMobileNavigationStore-BIYkf6Km.js";import{n as et}from"./useThemeSystem-8jhE4Zyk.js";import{n as Y}from"./Icon-_iMMNG9-.js";import{a as tt,n as nt,o as rt,r as it,t as at}from"./dialog-DivrqsAq.js";import{L as ot,_ as st,b as ct,c as lt,n as ut,s as dt,u as ft}from"./gitApi-CxEKzsxG.js";import{A as pt,_ as mt,a as ht,b as gt,c as _t,h as vt,m as yt,n as bt,r as xt,t as St,x as Ct}from"./projectMeta-Dg9OJmrW.js";import{t as wt}from"./input-BcXfvvm_.js";import{i as Tt,n as Et,t as Dt}from"./tooltip-8gf-KZqb.js";import{F as Ot,G as kt,Gt as At,J as jt,Jt as Mt,Kt as Nt,M as Pt,P as Ft,Qt as It,U as Lt,W as Rt,Wt as zt,Yt as Bt,a as Vt,it as Ht,k as Ut,q as Wt,qt as Gt,rn as Kt,rt as qt,ut as Jt,v as Yt}from"./speechSettingsQueries-ozQ8Mhi0.js";import{r as Xt,t as Zt}from"./device-BKQ_0FdZ.js";import{n as Qt}from"./MarkdownRenderer-BvAzySCw.js";import{n as $t,t as en}from"./textarea-BnV-WjE-.js";import{a as tn}from"./url-MRa-FtQa.js";import{r as nn}from"./markdown-worker-oBGEB9Eg.js";import{i as rn,n as an,o as on}from"./mcpQueries-CZhOdHBy.js";import{n as sn,r as cn,t as ln}from"./collapsible-DqW91GHI.js";import{a as un,d as dn,o as fn,s as pn}from"./vendor-codemirror-commands-B8KrBQ9B.js";import{a as mn,c as hn,i as gn,o as _n,r as vn,s as yn}from"./vendor-codemirror-search-ZqtrPLjU.js";import{n as bn,t as xn}from"./vendor-replit-codemirror-vim-DDj0dSVY.js";import{t as Sn}from"./vendor-codemirror-language-data-Ctd4WxgW.js";import{i as Cn,n as wn,r as Tn,t as En}from"./projectActions-BX0cjZoq.js";var Dn=[{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`}],On=e=>[...Dn,...e.filter(e=>e.source===`magpie`).map(e=>({id:e.providerId,name:e.providerName}))],X=M(),Z=C();function kn(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 Q=e(b(),1),An=Q.forwardRef((e,t)=>{let n=(0,X.c)(11),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=K(`peer inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-none transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[checked]:bg-primary data-[unchecked]:bg-[var(--interactive-border)]`,r),n[3]=r,n[4]=a);let o;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(o={width:`36px`,height:`20px`,minWidth:`36px`,minHeight:`20px`},n[5]=o):o=n[5];let s;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(S,{className:K(`pointer-events-none block rounded-full bg-background shadow-none ring-0 transition-transform data-[checked]:translate-x-4 data-[unchecked]:translate-x-0`),style:{width:`16px`,height:`16px`,minWidth:`16px`,minHeight:`16px`}}),n[6]=s):s=n[6];let c;return n[7]!==i||n[8]!==t||n[9]!==a?(c=(0,Z.jsx)(w,{className:a,style:o,...i,ref:t,children:s}),n[7]=i,n[8]=t,n[9]=a,n[10]=c):c=n[10],c});An.displayName=`Switch`;var jn={},Mn=(e,t=n())=>JSON.stringify([t,an(e)]),Nn=(e,t,n)=>{if(!e[t]?.[n])return e;let r={...e[t]};return delete r[n],{...e,[t]:r}},Pn=e=>{let t=an(e);return t?T.getScopedApiClient(t):T.getApiClient()},Fn=e=>e?{location:{directory:e}}:void 0,In=new Map,Ln=(e,t)=>JSON.stringify([r(),Mn(t),e]),Rn=async(e,t,n)=>{let r=(await e.mcp.list(Fn(n))).data.find(e=>e.name===t)?.integrationID;if(!r)throw Error(`MCP server "${t}" has no authentication integration`);return(await e.integration.get({integrationID:r,...Fn(n)})).data},zn=e=>an(e===void 0?E.getState().currentDirectory:e),Bn=_()(y((e,t)=>({diagnosticsByDirectory:{},getDiagnosticForDirectory:e=>{let n=Mn(zn(e));return t().diagnosticsByDirectory[n]??jn},clearDiagnostic:(t,n,r)=>{let i=Mn(zn(n),r);e(e=>({diagnosticsByDirectory:Nn(e.diagnosticsByDirectory,i,t)}))},connect:async(t,r)=>{let i=zn(r),a=n(),o=Mn(i,a),s=Pn(i);try{await s.mcp.connect({server:t,...Fn(i)})}catch(n){let r=n instanceof Error?n.message:`Connection failed`;throw e(e=>({diagnosticsByDirectory:{...e.diagnosticsByDirectory,[o]:{...e.diagnosticsByDirectory[o]??{},[t]:{status:`failed`,error:r}}}})),n}await on(L,i,a),e(e=>({diagnosticsByDirectory:Nn(e.diagnosticsByDirectory,o,t)}))},disconnect:async(t,r)=>{let i=zn(r),a=n(),o=Mn(i,a);await Pn(i).mcp.disconnect({server:t,...Fn(i)}),await on(L,i,a),e(e=>({diagnosticsByDirectory:Nn(e.diagnosticsByDirectory,o,t)}))},startAuth:async(e,t)=>{let n=zn(t),r=Ln(e,n),i=Pn(n),a=await Rn(i,e,n),o=a.methods.find(e=>e.type===`oauth`);if(!o)throw Error(`MCP server "${e}" has no OAuth method`);if(r!==Ln(e,n))throw Error(`MCP authorization runtime changed`);let s=In.get(r);if(s&&(await i.integration.oauth.cancel({integrationID:s.integrationID,attemptID:s.attempt.attemptID,...Fn(n)}),In.delete(r)),r!==Ln(e,n))throw Error(`MCP authorization runtime changed`);let{data:c}=await i.integration.oauth.connect({integrationID:a.id,methodID:o.id,...Fn(n)});if(r!==Ln(e,n))throw Error(`MCP authorization runtime changed`);for(let[e,t]of In)t.attempt.time.expires<=Date.now()&&In.delete(e);return In.set(r,{integrationID:a.id,attempt:c}),c},authStatus:async(e,t)=>{let n=zn(t),r=Ln(e,n),i=In.get(r);if(!i)throw Error(`MCP authorization attempt not found`);let{data:a}=await Pn(n).integration.oauth.status({integrationID:i.integrationID,attemptID:i.attempt.attemptID,...Fn(n)});if(r!==Ln(e,n))throw Error(`MCP authorization runtime changed`);return a.status!==`pending`&&In.get(r)===i&&In.delete(r),a},completeAuth:async(e,t,r)=>{let i=zn(r),a=n(),o=Ln(e,i),s=In.get(o);if(!s||s.attempt.mode!==`code`)throw Error(`MCP authorization requires the browser callback`);if(!t.trim())throw Error(`MCP authorization code is empty`);if(await Pn(i).integration.oauth.complete({integrationID:s.integrationID,attemptID:s.attempt.attemptID,code:t.trim(),...Fn(i)}),In.get(o)===s&&In.delete(o),o!==Ln(e,i))throw Error(`MCP authorization runtime changed`);await on(L,i,a)},clearAuth:async(e,t)=>{let r=zn(t),i=n(),a=Ln(e,r),o=Pn(r),s=await Rn(o,e,r);if(a!==Ln(e,r))throw Error(`MCP authorization runtime changed`);let c=In.get(a);c&&(await o.integration.oauth.cancel({integrationID:c.integrationID,attemptID:c.attempt.attemptID,...Fn(r)}),In.delete(a));let l=new Set(s.connections.flatMap(e=>e.type===`credential`?[e.id]:[]));for(let t of l){if(a!==Ln(e,r))throw Error(`MCP authorization runtime changed`);await o.credential.remove({credentialID:t})}if(a!==Ln(e,r))throw Error(`MCP authorization runtime changed`);await on(L,r,i)},testConnection:async(t,r)=>{let i=zn(r),a=n(),o=Mn(i,a),s=Pn(i),c=rn(L,i,a)[t]?.status===`connected`,l,u;try{await s.mcp.connect({server:t,...Fn(i)})}catch(n){l=n instanceof Error?n.message:`Connection failed`,e(e=>({diagnosticsByDirectory:{...e.diagnosticsByDirectory,[o]:{...e.diagnosticsByDirectory[o]??{},[t]:{status:`failed`,error:l??`Connection failed`}}}}))}let d=(await on(L,i,a))[t],f=d;if(!c&&d?.status===`connected`){try{await s.mcp.disconnect({server:t,...Fn(i)})}catch(e){u=`Connection test succeeded, but cleanup disconnect failed: ${e instanceof Error?e.message:`Disconnect failed`}`}await on(L,i,a)}return l||e(e=>({diagnosticsByDirectory:Nn(e.diagnosticsByDirectory,o,t)})),{status:f??rn(L,i,a)[t],error:l,warning:u}}}))),Vn=`https://yuri-updates.xiaobe.top/v1/update/check`,Hn=`https://yuri-origin.xiaobe.top/v1/update/check`,Un=`https://github.com/yee94/yuri/releases/latest`,Wn=`https://github.com/yee94/yuri/releases`,Gn=`https://testflight.apple.com/join/pN5SSHeg`,Kn=1e4;function qn(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 Jn(e,t){let n=qn(e),r=qn(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 Yn(){return[Vn,Hn]}function Xn(e,t,n=Date.now){let r=e-n();return r<=0||t<=0?null:Math.max(1,Math.ceil(r/t))}function Zn(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 Qn(e,t,n,r){try{if(ne())try{let{CapacitorHttp:r}=await te(async()=>{let{CapacitorHttp:e}=await import(`./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js`).then(e=>e.i);return{CapacitorHttp:e}},__vite__mapDeps([0,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 $n(e,t){return e===`ios`?Gn:`${Wn}/download/v${t}/app-release.apk`}function er(e,t,n){if(typeof e.latestVersion!=`string`||e.latestVersion.trim().length===0)return null;let r=e.latestVersion.trim(),i=Jn(r,t);if(i<0)return null;let a=typeof e.releaseNotesUrl==`string`&&e.releaseNotesUrl.trim().length>0?e.releaseNotesUrl.trim():`${Wn}/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():$n(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 tr(e,t,n,r){let i=await Qn(e,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify(Zn(t))},n,r);if(!i?.ok)return null;let a;try{a=await i.json()}catch{return null}return er(a,t.currentVersion,t.platform)}async function nr(e,t,n,r){let i=await Qn(Un,{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:Un,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=Jn(s,e),l=`${Wn}/tag/v${s}`;return{available:c>0,version:s,currentVersion:e,releaseUrl:l,downloadUrl:$n(t,s)}}async function rr(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=Yn(),a=r()+Kn;for(let[t,o]of i.entries()){let s=Xn(a,i.length-t+1,r);if(s===null)break;let c=await tr(o,e,s,n);if(c)return c}let o=Xn(a,1,r);if(o!==null){let r=await nr(t,e.platform,o,n);if(r)return r}return{available:!1,currentVersion:t,error:`Unable to check for mobile updates`}}function ir(){if(typeof window>`u`)return`unknown`;try{let{deviceType:e}=Zt();return e}catch{return`unknown`}}function ar(){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 or(){let e=re();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 sr(e){let t=O.getState().reportUsage,n=new URLSearchParams({reportUsage:t?`true`:`false`});return n.set(`deviceClass`,ir()),n.set(`arch`,ar()),n.set(`platform`,or()),e===`desktop`?(n.set(`appType`,`desktop-electron`),n.set(`instanceMode`,d()?`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 cr(e,t){let n=t??`unknown`;try{let r=sr(e),i=typeof window<`u`?window.__VSCODE_CONFIG__?.extensionVersion:void 0;t?r.set(`currentVersion`,t):e===`vscode`&&i&&r.set(`currentVersion`,i);let o=await a(`/api/yuri/update-check?${r.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),s=null;try{s=await o.json()}catch{s=null}if(!o.ok)return{available:!1,currentVersion:n,error:typeof s?.error==`string`&&s.error.trim().length>0?s.error.trim():`Server responded with ${o.status}`};if(!s)return{available:!1,currentVersion:n,error:`Update check returned an invalid response`};let c=typeof s.error==`string`&&s.error.trim().length>0?s.error.trim():void 0;return{available:s.available===!0,version:typeof s.version==`string`?s.version:void 0,currentVersion:typeof s.currentVersion==`string`?s.currentVersion:n,body:typeof s.body==`string`?s.body:void 0,releaseUrl:typeof s.releaseUrl==`string`?s.releaseUrl:void 0,downloadUrl:typeof s.downloadUrl==`string`?s.downloadUrl:void 0,nextSuggestedCheckInSec:typeof s.nextSuggestedCheckInSec==`number`&&Number.isFinite(s.nextSuggestedCheckInSec)?s.nextSuggestedCheckInSec:void 0,packageManager:typeof s.packageManager==`string`?s.packageManager:void 0,updateCommand:typeof s.updateCommand==`string`?s.updateCommand:void 0,error:c}}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 lr(){return ne()?`mobile`:l()?`desktop`:m()?`vscode`:u()?`web`:null}var ur={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 dr(e,t){let n=e.isChannelRollback===!0?{isChannelRollback:!0}:{};if(e.primaryAction===`apply_ota`&&e.ota.bundle)return 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}};if(e.primaryAction===`install_native_required`){if(!e.native.version?.trim()||!e.native.installUrl?.trim())throw Error(`Native update required, but the update service supplied no complete installation target`);return{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}}}return{available:!1,otaPhase:`idle`,info:{available:!1,currentVersion:t,nextSuggestedCheckInSec:e.nextCheckInSec,...n}}}var fr=0,pr=_()((e,t)=>({...ur,checkForUpdates:async()=>{let n=lr();if(!n)return null;let r=++fr;e({checking:!0,error:null,runtimeType:n});try{let i=null,a=null;if(n===`desktop`){let n=O.getState().otaChannelOverride;t().lastOtaChannelOverride!==n&&e({downloaded:!1,downloading:!1,available:!1,info:null,otaDecision:null,progress:null,otaPhase:`checking`});let i=await p(n);if(r!==fr||O.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 cr(`web`),a=i?.nextSuggestedCheckInSec??null;else if(n===`vscode`)a=(await cr(`vscode`))?.nextSuggestedCheckInSec??null;else if(n===`mobile`){let n=await H()??`unknown`,r=ne()?g()?.mobileUpdates:void 0,o=O.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=dr(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 ie)){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 rr({currentVersion:n,platform:or()===`ios`?`ios`:`android`,deviceClass:ir(),arch:ar(),reportUsage:O.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===fr&&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=g()?.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=O.getState().otaChannelOverride,r=await p(n);if(n!==O.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 f(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(!l())return()=>{};let n=[],r=await s(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 o(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=g()?.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 c())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(ur)}})),mr=8e3,hr=e=>!!(e&&![`succeeded`,`failed`].includes(e.status));function gr(e,t){if(e!==n()||t!==r())throw Error(`Stale update runtime`)}var _r=(e=n(),t=r(),i)=>({queryKey:[e,`host-update`,t,i??`current`],queryFn:async({signal:n})=>{gr(e,t);let r=new AbortController,o=()=>r.abort();n.addEventListener(`abort`,o,{once:!0});let s;try{return await Promise.race([(async()=>{let n=await a(`/api/system/update${i?`?channel=${i}`:``}`,{headers:{Accept:`application/json`},signal:r.signal});if([404,501].includes(n.status))throw Error(`host_update_unsupported`);let o=await n.json();if(gr(e,t),!n.ok&&n.status!==502||typeof o.serverId!=`string`||typeof o.supported!=`boolean`||![`cli`,`electron`].includes(o.host))throw Error(`Host update check failed`);return o})(),new Promise((e,t)=>{s=setTimeout(()=>{r.abort(),t(Error(`host_update_timeout`))},mr)})])}finally{s!==void 0&&clearTimeout(s),n.removeEventListener(`abort`,o)}},staleTime:6e4,retry:!1}),vr=(e=n(),t=r(),i)=>L.getQueryData(_r(e,t,i).queryKey),yr=(e=n(),t=r(),i)=>{let a=vr(e,t,i);return L.fetchQuery({..._r(e,t,i),staleTime:a?.checkError||hr(a?.operation)?0:6e4})},br=(e=n(),t=r(),i)=>L.fetchQuery({..._r(e,t,i),staleTime:0}),xr=(e,t,n)=>{let r=(0,X.c)(6),i;r[0]!==n||r[1]!==t||r[2]!==e?(i=_r(e,t,n),r[0]=n,r[1]=t,r[2]=e,r[3]=i):i=r[3];let a;return r[4]===i?a=r[5]:(a={...i,refetchInterval:Cr,refetchIntervalInBackground:!1},r[4]=i,r[5]=a),I(a)};async function Sr(e,t,n){if(gr(t,n),!e.update)throw Error(`No update plan`);let r=await a(`/api/system/update`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({version:e.update.version,channel:e.channel,planId:e.update.planId,allowDowngrade:e.update.rollback===!0})});if(gr(t,n),!r.ok)throw Error(`Host update was not accepted`);let i=await r.json();if(typeof i.operation?.id!=`string`)throw Error(`Invalid update operation`);return i.operation}function Cr(e){return hr(e.state.data?.operation)?2e3:e.state.error?.message===`host_update_unsupported`?!1:e.state.error?15e3:3e5}function wr(e){let t=new Date(`${e}T00:00:00`);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(Le(),{year:`numeric`,month:`short`,day:`numeric`}).format(t)}function Tr(e){return e.replace(/^## \[[^\]]+\] - \d{4}-\d{2}-\d{2}\s*\n?/,``).trim()}function Er(e){return e.replace(/(^|[^a-zA-Z0-9])@([a-zA-Z0-9-]+)/g,`$1[@$2](https://github.com/$2)`)}function Dr(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 Or(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.map((t,r)=>{let i=n[r+1]?.start??e.length;return{version:t.version,date:t.date,start:t.start,end:i,raw:e.slice(t.start,i).trim()}})}function kr(e){let t=(0,X.c)(67),{open:n,onOpenChange:r,model:i,onAction:a}=e,{t:o}=Ie(),[s,c]=(0,Q.useState)(!1),l=Ne(jr),u;t[0]===l?u=t[1]:(u=e=>{let t=e.target.closest(`a`);t?.href&&(e.preventDefault(),e.stopPropagation(),l(t.href))},t[0]=l,t[1]=u);let d=Ne(u),f;t[2]===i.fallbackCommand?f=t[3]:(f=async()=>{i.fallbackCommand&&(await Fe(i.fallbackCommand)).ok&&(c(!0),setTimeout(()=>c(!1),2e3))},t[2]=i.fallbackCommand,t[3]=f);let p=Ne(f),m;if(t[4]!==i.body||t[5]!==o){bb0:{let e=i.body?.trim();if(!e){m=null;break bb0}let n=Or(e);if(!n.length){m={kind:`raw`,title:o(`updateDialog.changelog.title`),content:Er(e)};break bb0}let r;t[7]===o?r=t[8]:(r=o(`updateDialog.changelog.title`),t[7]=o,t[8]=r),m={kind:`sections`,title:r,sections:[...n].sort(Ar).map(t=>({version:t.version,dateLabel:wr(t.date),content:Er(Tr(t.raw)||e)}))}}t[4]=i.body,t[5]=o,t[6]=m}else m=t[6];let h=m,g=i.dismissible===!1?void 0:r,_=i.stableLayout&&`h-[min(38rem,calc(100dvh-2rem))] overflow-hidden transition-[opacity,transform,filter]`,v;t[9]===_?v=t[10]:(v=K(`max-w-4xl gap-0 p-4 sm:p-5 bg-background border-[var(--interactive-border)]`,_),t[9]=_,t[10]=v);let y;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(Y,{name:`download-cloud`,className:`h-5 w-5 text-[var(--primary-base)]`}),t[11]=y):y=t[11];let b;t[12]===i.title?b=t[13]:(b=(0,Z.jsxs)(rt,{className:`flex items-center gap-2`,children:[y,(0,Z.jsx)(`span`,{className:`font-semibold text-foreground`,children:i.title})]}),t[12]=i.title,t[13]=b);let x;t[14]!==i.currentVersion||t[15]!==i.methodLabel||t[16]!==i.version?(x=(i.currentVersion||i.version)&&(0,Z.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5 pl-7 font-mono text-[11px] leading-4 tracking-[-0.01em] tabular-nums sm:text-xs`,children:[i.currentVersion&&(0,Z.jsx)(`span`,{className:`text-muted-foreground/75`,children:i.currentVersion}),i.currentVersion&&i.version&&(0,Z.jsx)(`span`,{className:`text-muted-foreground/40`,children:`→`}),i.version&&(0,Z.jsx)(`span`,{className:`font-medium text-[var(--primary-base)]`,children:i.version}),i.methodLabel&&(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· `,i.methodLabel]})]}),t[14]=i.currentVersion,t[15]=i.methodLabel,t[16]=i.version,t[17]=x):x=t[17];let S;t[18]===i.description?S=t[19]:(S=i.description&&(0,Z.jsx)(it,{className:`mt-2`,children:i.description}),t[18]=i.description,t[19]=S);let C;t[20]!==S||t[21]!==b||t[22]!==x?(C=(0,Z.jsxs)(`div`,{className:`mb-3 shrink-0 pr-8 sm:mb-4`,children:[b,x,S]}),t[20]=S,t[21]=b,t[22]=x,t[23]=C):C=t[23];let w=i.stableLayout?`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto`:`space-y-3 sm:space-y-4`,T;t[24]===i.message?T=t[25]:(T=i.message&&(0,Z.jsx)(`p`,{role:`status`,className:`typography-ui-label text-muted-foreground`,children:i.message}),t[24]=i.message,t[25]=T);let E;t[26]===i.warning?E=t[27]:(E=i.warning&&(0,Z.jsx)(`p`,{className:`typography-meta text-[var(--status-warning)]`,children:i.warning}),t[26]=i.warning,t[27]=E);let D;t[28]!==h||t[29]!==d||t[30]!==i.hideChangelog||t[31]!==i.stableLayout?(D=h&&!i.hideChangelog&&(0,Z.jsxs)(`section`,{className:K(`overflow-hidden rounded-xl border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20`,i.stableLayout&&`flex min-h-0 flex-1 flex-col`),children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 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:h.title})]}),(0,Z.jsx)($t,{className:i.stableLayout?`p-0`:`max-h-[min(42dvh,22rem)] p-0 sm:max-h-[400px]`,outerClassName:i.stableLayout?`flex-1`:void 0,fillContainer:!!i.stableLayout,children:h.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:d,children:(0,Z.jsx)(Qt,{content:h.content,disableLinkSafety:!0,enableFileReferences:!1})}):(0,Z.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:h.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:d,children:(0,Z.jsx)(Qt,{content:e.content,disableLinkSafety:!0,enableFileReferences:!1})})]},e.version))})})]}),t[28]=h,t[29]=d,t[30]=i.hideChangelog,t[31]=i.stableLayout,t[32]=D):D=t[32];let O;t[33]!==s||t[34]!==p||t[35]!==i.fallbackCommand||t[36]!==o?(O=i.fallbackCommand&&(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:o(`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:i.fallbackCommand}),(0,Z.jsx)(`button`,{onClick:p,className:K(`flex items-center justify-center p-2 rounded`,`text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]`,`transition-colors`,s&&`text-[var(--status-success)]`),title:o(s?`updateDialog.actions.copied`:`updateDialog.actions.copyCommand`),children:(0,Z.jsx)(Y,{name:s?`check`:`clipboard`,className:`h-4 w-4`})})]})]}),t[33]=s,t[34]=p,t[35]=i.fallbackCommand,t[36]=o,t[37]=O):O=t[37];let k;t[38]!==i.stableLayout||t[39]!==i.status?(k=i.status&&(0,Z.jsxs)(`div`,{role:`status`,className:K(`space-y-2`,i.stableLayout&&`min-h-9 shrink-0`),children:[(0,Z.jsxs)(`div`,{className:`flex h-5 items-center justify-between gap-3`,children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-xs font-medium text-muted-foreground sm:text-[13px]`,children:[i.status.kind===`activity`&&(0,Z.jsx)(Y,{name:`loader`,className:`h-3.5 w-3.5 shrink-0 animate-spin text-[var(--primary-base)]`}),(0,Z.jsx)(`span`,{className:`truncate`,title:i.status.label,children:i.status.label})]}),i.status.progress!=null&&(0,Z.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] leading-4 text-foreground tabular-nums sm:text-xs`,children:[Math.round(i.status.progress),`%`]})]}),(0,Z.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-[var(--surface-subtle)] sm:h-1.5`,children:i.status.progress==null?(0,Z.jsx)(`div`,{className:`h-full w-1/3 animate-pulse rounded-full bg-[var(--primary-base)]/60`}):(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-[var(--primary-base)] transition-[width] duration-500`,style:{width:`${i.status.progress}%`}})}),i.status.detail&&(0,Z.jsx)(`p`,{className:`text-xs leading-4 text-muted-foreground`,children:i.status.detail})]}),t[38]=i.stableLayout,t[39]=i.status,t[40]=k):k=t[40];let A;t[41]===i.error?A=t[42]:(A=i.error&&(0,Z.jsx)(`div`,{role:`alert`,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:i.error})}),t[41]=i.error,t[42]=A);let j;t[43]!==w||t[44]!==T||t[45]!==E||t[46]!==D||t[47]!==O||t[48]!==k||t[49]!==A?(j=(0,Z.jsxs)(`div`,{className:w,children:[T,E,D,O,k,A]}),t[43]=w,t[44]=T,t[45]=E,t[46]=D,t[47]=O,t[48]=k,t[49]=A,t[50]=j):j=t[50];let M;t[51]===i.notice?M=t[52]:(M=i.notice&&(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:i.notice})]}),t[51]=i.notice,t[52]=M);let N;t[53]!==i.actions||t[54]!==i.releaseLink||t[55]!==a?(N=(i.releaseLink||i.actions.length>0)&&(0,Z.jsxs)(`div`,{className:`mt-4 flex shrink-0 items-center justify-between gap-4`,children:[i.releaseLink&&(0,Z.jsxs)(`a`,{href:i.releaseLink.url,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`}),i.releaseLink.label]}),(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-nowrap items-center justify-end gap-2`,children:i.actions.map(e=>(0,Z.jsxs)(q,{onClick:()=>a(e.id),disabled:e.disabled,variant:e.variant??`default`,size:`default`,className:`min-w-0 shrink`,title:e.label,children:[e.icon&&(0,Z.jsx)(Y,{name:e.icon,className:K(`h-4 w-4`,e.loading&&`animate-spin`)}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.label})]},e.id))})]}),t[53]=i.actions,t[54]=i.releaseLink,t[55]=a,t[56]=N):N=t[56];let P;t[57]!==C||t[58]!==j||t[59]!==M||t[60]!==N||t[61]!==v?(P=(0,Z.jsxs)(nt,{className:v,showCloseButton:!0,children:[C,j,M,N]}),t[57]=C,t[58]=j,t[59]=M,t[60]=N,t[61]=v,t[62]=P):P=t[62];let F;return t[63]!==n||t[64]!==P||t[65]!==g?(F=(0,Z.jsx)(at,{open:n,onOpenChange:g,children:P}),t[63]=n,t[64]=P,t[65]=g,t[66]=F):F=t[66],F}function Ar(e,t){return Dr(e.version,t.version)}function jr(e){tn(e)}var Mr=`https://github.com/yee94/yuri/releases`,Nr=2e3,Pr=6e5,Fr=e=>e.transport===n()&&e.generation===r();async function Ir(e,t){try{if(!Fr(t))return{success:!1};let n=await yr(t.transport,t.generation);return!Fr(t)||!e||!n.supported||n.update?.version!==e||n.update.rollback?{success:!1}:(await Sr(n,t.transport,t.generation),{success:!0,autoRestart:!0})}catch(e){return{success:!1,error:e instanceof Error?e.message:void 0}}}async function Lr(e,t,n=Math.ceil(Pr/Nr),r=Nr){for(let i=0;i<n;i++){if(!Fr(t))return!1;try{let n=await br(t.transport,t.generation);if(n.operation?.status===`failed`)return!1;if(n.currentVersion===e&&n.operation?.status===`succeeded`&&Fr(t))return!0}catch{}await new Promise(e=>setTimeout(e,r))}return!1}var Rr=e=>{let t=(0,X.c)(108),{open:i,onOpenChange:a,info:o,downloading:s,downloaded:c,progress:l,error:u,onDownload:d,onRestart:f,runtimeType:p}=e,m=p===void 0?`desktop`:p,{t:h}=Ie(),[g,_]=(0,Q.useState)(`idle`),[v,y]=(0,Q.useState)(null),b=pr(zr),x=o?.releaseUrl||(o?.version?`${Mr}/tag/v${o.version}`:Mr),S=o?.downloadUrl,C=m===`web`,w=m===`mobile`,T=w&&o?.manualUpdate===!0&&!!S,E=w&&o?.inAppApply===!0,D=m===`desktop`&&o?.manualUpdate===!0,O=g!==`idle`&&g!==`error`,k=w?S:x,A;t[0]!==c||t[1]!==E||t[2]!==a?(A=e=>{!e&&E&&c&&pr.getState().dismiss(),a(e)},t[0]=c,t[1]=E,t[2]=a,t[3]=A):A=t[3];let j=Ne(A),M,N;t[4]===i?(M=t[5],N=t[6]):(M=()=>{i||(_(`idle`),y(null))},N=[i],t[4]=i,t[5]=M,t[6]=N),(0,Q.useEffect)(M,N);let P;t[7]!==o?.version||t[8]!==h?(P=async()=>{let e={transport:n(),generation:r()};_(`updating`),y(null);let t=await Ir(o?.version,e);if(!Fr(e))return;if(!t.success){_(`error`),y(t.error||h(`updateDialog.error.updateFailed`));return}t.autoRestart&&(_(`restarting`),await new Promise(Br)),_(`reconnecting`);let i=await Lr(o?.version,e);Fr(e)&&(i?window.location.reload():(_(`error`),y(h(`updateDialog.error.takingLonger`))))},t[7]=o?.version,t[8]=h,t[9]=P):P=t[9];let F=Ne(P),I;t[10]!==F||t[11]!==w||t[12]!==d||t[13]!==a||t[14]!==f||t[15]!==S||t[16]!==x||t[17]!==m?(I=e=>{bb107:switch(e){case`download`:d(),m===`desktop`&&a(!1);break bb107;case`restart`:f();break bb107;case`later`:pr.getState().dismiss(),a(!1);break bb107;case`open-external`:{let e=w?S:x;e&&tn(e);break bb107}case`web-update`:F()}},t[10]=F,t[11]=w,t[12]=d,t[13]=a,t[14]=f,t[15]=S,t[16]=x,t[17]=m,t[18]=I):I=t[18];let L=Ne(I),R;if(t[19]!==c||t[20]!==s||t[21]!==E||t[22]!==D||t[23]!==w||t[24]!==C||t[25]!==O||t[26]!==T||t[27]!==h){if(R=[],!C&&(!w||E)){if(!D&&!c&&!s){let e;t[29]!==E||t[30]!==h?(e=h(E?`updateDialog.actions.applyOtaNow`:`updateDialog.actions.downloadUpdate`),t[29]=E,t[30]=h,t[31]=e):e=t[31];let n;t[32]===e?n=t[33]:(n={id:`download`,icon:`download`,label:e},t[32]=e,t[33]=n),R.push(n)}if(D&&!c&&!s){let e;t[34]===h?e=t[35]:(e=h(`updateDialog.actions.openMobileUpdate`),t[34]=h,t[35]=e);let n;t[36]===e?n=t[37]:(n={id:`open-external`,icon:`external-link`,label:e},t[36]=e,t[37]=n),R.push(n)}if(s){let e;t[38]===h?e=t[39]:(e=h(`updateDialog.status.downloading`),t[38]=h,t[39]=e);let n;t[40]===e?n=t[41]:(n={id:`downloading`,icon:`loader`,loading:!0,disabled:!0,label:e},t[40]=e,t[41]=n),R.push(n)}if(c){if(E){let e;t[42]===h?e=t[43]:(e=h(`updateDialog.actions.later`),t[42]=h,t[43]=e);let n;t[44]===e?n=t[45]:(n={id:`later`,variant:`ghost`,label:e},t[44]=e,t[45]=n),R.push(n)}let e;t[46]===h?e=t[47]:(e=h(`updateDialog.actions.restartToUpdate`),t[46]=h,t[47]=e);let n;t[48]===e?n=t[49]:(n={id:`restart`,icon:`restart`,label:e},t[48]=e,t[49]=n),R.push(n)}}if(w&&!E&&T){let e;t[50]===h?e=t[51]:(e=h(`updateDialog.actions.openMobileUpdate`),t[50]=h,t[51]=e);let n;t[52]===e?n=t[53]:(n={id:`open-external`,icon:`external-link`,label:e},t[52]=e,t[53]=n),R.push(n)}if(C){let e;t[54]!==O||t[55]!==h?(e=O?{id:`updating`,icon:`loader`,loading:!0,disabled:!0,label:h(`updateDialog.status.updating`)}:{id:`web-update`,icon:`download`,label:h(`updateDialog.actions.updateNow`)},t[54]=O,t[55]=h,t[56]=e):e=t[56],R.push(e)}t[19]=c,t[20]=s,t[21]=E,t[22]=D,t[23]=w,t[24]=C,t[25]=O,t[26]=T,t[27]=h,t[28]=R}else R=t[28];let z;t[57]!==h||t[58]!==g?(z=h(g===`restarting`||g===`reconnecting`?`updateDialog.header.updating`:`updateDialog.header.updateAvailable`),t[57]=h,t[58]=g,t[59]=z):z=t[59];let B=o?.currentVersion,ee=o?.version,te=o?.body,V=!O,ne=u||v,re=C&&g===`error`?o?.updateCommand||`yuri update`:void 0,H;t[60]!==c||t[61]!==E||t[62]!==b||t[63]!==h?(H=E&&c&&b?h(`updateDialog.status.otaBundleReused`):void 0,t[60]=c,t[61]=E,t[62]=b,t[63]=h,t[64]=H):H=t[64];let ie;t[65]!==w||t[66]!==k||t[67]!==T?(ie=(!w||T)&&k?{url:k,label:`GitHub`}:void 0,t[65]=w,t[66]=k,t[67]=T,t[68]=ie):ie=t[68];let ae;if(t[69]!==R||t[70]!==s||t[71]!==E||t[72]!==w||t[73]!==C||t[74]!==O||t[75]!==l||t[76]!==h||t[77]!==te||t[78]!==V||t[79]!==ne||t[80]!==re||t[81]!==H||t[82]!==ie||t[83]!==z||t[84]!==B||t[85]!==ee||t[86]!==g){if(ae={title:z,currentVersion:B,version:ee,body:te,hideChangelog:O,dismissible:V,error:ne,fallbackCommand:re,notice:H,releaseLink:ie,actions:R},C&&O){let e;t[88]!==h||t[89]!==g?(e=h(g===`updating`?`updateDialog.status.installingUpdate`:g===`restarting`?`updateDialog.status.serverRestarting`:`updateDialog.status.waitingForServer`),t[88]=h,t[89]=g,t[90]=e):e=t[90];let n;t[91]===h?n=t[92]:(n=h(`updateDialog.status.autoReloadHint`),t[91]=h,t[92]=n);let r;t[93]!==e||t[94]!==n?(r={kind:`activity`,label:e,detail:n},t[93]=e,t[94]=n,t[95]=r):r=t[95],ae.status=r}if(!C&&(!w||E)&&s){let e;t[96]===h?e=t[97]:(e=h(`updateDialog.status.downloadingPayload`),t[96]=h,t[97]=e);let n;t[98]===l?n=t[99]:(n=l?.total?Math.round(l.downloaded/l.total*100):0,t[98]=l,t[99]=n);let r;t[100]!==e||t[101]!==n?(r={kind:`download`,label:e,progress:n},t[100]=e,t[101]=n,t[102]=r):r=t[102],ae.status=r}t[69]=R,t[70]=s,t[71]=E,t[72]=w,t[73]=C,t[74]=O,t[75]=l,t[76]=h,t[77]=te,t[78]=V,t[79]=ne,t[80]=re,t[81]=H,t[82]=ie,t[83]=z,t[84]=B,t[85]=ee,t[86]=g,t[87]=ae}else ae=t[87];let oe;return t[103]!==L||t[104]!==j||t[105]!==ae||t[106]!==i?(oe=(0,Z.jsx)(kr,{open:i,onOpenChange:j,model:ae,onAction:L}),t[103]=L,t[104]=j,t[105]=ae,t[106]=i,t[107]=oe):oe=t[107],oe};function zr(e){return e.otaDownloadSkipped}function Br(e){return setTimeout(e,2e3)}var Vr=e(x(),1);function Hr(e){let t=(0,X.c)(10),{children:n,actions:r,className:i}=e,a;t[0]===i?a=t[1]:(a=K(`sticky top-0 z-10 flex shrink-0 items-center justify-between gap-3 bg-background py-3`,i),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:n}),t[2]=n,t[3]=o);let s;t[4]===r?s=t[5]:(s=(0,Z.jsx)(`div`,{className:`flex max-w-[70%] shrink-0 flex-wrap items-center justify-end gap-2 [&_button]:max-w-full [&_button]:whitespace-normal`,children:r}),t[4]=r,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,Z.jsxs)(`header`,{"data-settings-action-header":``,className:a,children:[o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function Ur(e){let t=(0,X.c)(21),{label:n,actions:r,children:i,description:a,itemId:o,ariaLabel:s,className:c,cardClassName:l,cardId:u}=e,d=typeof n==`string`&&/^[\p{Script=Latin}\p{Number}\p{Punctuation}\p{Separator}]+$/u.test(n)?`latin`:void 0,f;t[0]===c?f=t[1]:(f=K(`yuri-settings-group`,c),t[0]=c,t[1]=f);let p;t[2]!==r||t[3]!==n||t[4]!==d?(p=r?(0,Z.jsx)(Hr,{actions:r,children:n?(0,Z.jsx)(`div`,{className:`yuri-settings-group-label`,"data-settings-label-script":d,children:n}):null}):n?(0,Z.jsx)(`div`,{className:`yuri-settings-group-label`,"data-settings-label-script":d,children:n}):null,t[2]=r,t[3]=n,t[4]=d,t[5]=p):p=t[5];let m;t[6]===l?m=t[7]:(m=K(`yuri-settings-group-card`,l),t[6]=l,t[7]=m);let h;t[8]!==u||t[9]!==i||t[10]!==o||t[11]!==m?(h=(0,Z.jsx)(`div`,{id:u,"data-settings-item":o,className:m,children:i}),t[8]=u,t[9]=i,t[10]=o,t[11]=m,t[12]=h):h=t[12];let g;t[13]===a?g=t[14]:(g=a?(0,Z.jsx)(`p`,{className:`yuri-settings-group-description text-muted-foreground`,children:a}):null,t[13]=a,t[14]=g);let _;return t[15]!==s||t[16]!==f||t[17]!==p||t[18]!==h||t[19]!==g?(_=(0,Z.jsxs)(`section`,{className:f,"aria-label":s,children:[p,h,g]}),t[15]=s,t[16]=f,t[17]=p,t[18]=h,t[19]=g,t[20]=_):_=t[20],_}function Wr(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)(Gr,{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)(Ur,{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 Gr(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 Kr(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=qr,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)(pt,{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 qr(e){return e instanceof HTMLElement&&e.closest(`button, a, input, select, textarea`)!==null}function Jr(e,t){return e===`checking`?5:e===`downloading`?5+Math.min(Math.max(t??0,0),100)*.75:e===`installing`?85:e===`restarting`?95:100}function Yr(e,t,n){let r=e?.operation,i=e?.update,a=i??(r&&t.updateDetails&&r.planId===t.updateDetails.planId&&r.version===t.updateDetails.version?t.updateDetails:void 0),o=hr(r),s=e?.supported===!1||t.failure===`unsupported`,c={title:n(`settings.yuri.about.hostUpdate.title`),stableLayout:!0,description:n(`settings.yuri.about.hostUpdate.description`),currentVersion:e?.currentVersion??t.versionFallback,version:i?.version??r?.version,body:a||r?a?.releaseNotes||n(`settings.yuri.about.hostUpdate.noNotes`):void 0,warning:!o&&i?.rollback?n(`settings.yuri.about.hostUpdate.downgrade`):void 0,actions:o||t.submitting||t.completed||!i?[]:[{id:`confirm`,icon:`download`,label:n(`settings.yuri.about.hostUpdate.confirm`),disabled:!e?.supported||!!t.failure||!!t.checking}]};return o&&r?c.status={kind:r.status===`downloading`?`download`:`activity`,label:n(t.failure===`disconnected`?`settings.yuri.about.hostUpdate.reconnecting`:`settings.yuri.about.hostUpdate.status.${r.status}`),progress:Jr(r.status,r.progress)}:t.completed&&!i?c.status={kind:`download`,label:n(`settings.yuri.about.hostUpdate.status.succeeded`),progress:100}:t.submitting?c.status={kind:`activity`,label:n(`settings.yuri.about.state.checking`),progress:0}:t.checking===`initial`?c.status={kind:`activity`,label:n(`settings.yuri.about.state.checking`)}:s?c.message=n(`settings.yuri.about.hostUpdate.unsupported`):t.failure?c.error=n(t.failure===`disconnected`?`settings.yuri.about.hostUpdate.reconnecting`:`settings.yuri.about.toast.checkFailed`):!i&&e?.supported&&(c.message=r?.status===`succeeded`?n(`settings.yuri.about.hostUpdate.status.succeeded`):n(`settings.yuri.about.toast.latestVersion`)),r?.status===`failed`&&(c.error=n(`settings.yuri.about.hostUpdate.status.failed`)),c}function Xr(){let e=(0,X.c)(7),{t:i}=Ie(),a=Q.useSyncExternalStore(t,n,n),o=Q.useSyncExternalStore(t,r,r),s=`${a}:${o}`,c;e[0]===i?c=e[1]:(c=i(`settings.yuri.about.state.unknown`),e[0]=i,e[1]=c);let l;return e[2]!==o||e[3]!==s||e[4]!==c||e[5]!==a?(l=(0,Z.jsx)(Zr,{transport:a,generation:o,version:c},s),e[2]=o,e[3]=s,e[4]=c,e[5]=a,e[6]=l):l=e[6],l}function Zr({version:e,transport:t,generation:i,itemId:a,channel:o}){let{t:s}=Ie(),c=N(),[l,u]=Q.useState(!1),d=O(e=>e.otaChannelOverride),f=o??d??void 0,p=xr(t,i,f),m=p.data,h=m?.operation,g=hr(h),_=JSON.stringify([t,i,f??`current`]),[v,y]=Q.useState(null);m?.update&&(v?.scope!==_||v.update!==m.update)&&y({scope:_,update:m.update});let b=P({mutationFn:({plan:e})=>Sr(e,t,i),onSuccess:(e,a)=>{t===n()&&i===r()&&c.setQueryData(_r(t,i,a.channel).queryKey,t=>t&&{...t,operation:e})},onSettled:(e,a,o)=>{t===n()&&i===r()&&c.invalidateQueries({queryKey:_r(t,i,o.channel).queryKey,exact:!0})}}),[x,S]=Q.useState(null);l&&g&&h&&h.id!==x&&S(h.id);let C=h?.status===`succeeded`&&h.id===x,w=s(`settings.yuri.about.hostUpdate.status.succeeded`);Q.useEffect(()=>{!C||p.isError||t!==n()||i!==r()||(S(null),u(!1),J.success(w,{id:`host-update:${t}:${i}:${x}`}))},[C,p.isError,t,i,x,w]);let T=Q.useRef(null),E=Ne(()=>_),D=Ne(async()=>{if(g){u(!0),p.refetch({cancelRefetch:!1});return}if(T.current===_)return;let e=_;T.current=e;try{let a=await p.refetch({cancelRefetch:!1});if(e!==E()||t!==n()||i!==r())return;if(a.isError||!a.data||a.data.checkError){a.error?.message===`host_update_unsupported`?J.info(s(`settings.yuri.about.hostUpdate.unsupported`)):J.error(s(`settings.yuri.about.toast.checkFailed`));return}hr(a.data.operation)?u(!0):a.data.supported?a.data.update?u(!0):(u(!1),J.success(s(`settings.yuri.about.toast.latestVersion`))):J.info(s(`settings.yuri.about.hostUpdate.unsupported`))}finally{T.current===e&&(T.current=null)}}),k=m?.supported===!1||!g&&p.error?.message===`host_update_unsupported`,A=p.isError||!!m?.checkError,j=b.isError&&b.variables?.channel===f,M=Yr(m,{versionFallback:e,checking:p.isPending?`initial`:p.isFetching?`refresh`:!1,submitting:b.isPending,failure:k?`unsupported`:p.isError&&(g||j)?`disconnected`:A||j?`check`:null,completed:C,updateDetails:v?.scope===_?v.update:void 0},s),F=Ne(e=>{e===`confirm`&&m?.update&&b.mutate({plan:m,channel:f})});return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,"data-settings-item":a,children:[(0,Z.jsxs)(`span`,{className:`relative typography-ui-label font-mono text-foreground text-right`,children:[m?.currentVersion??e,m?.update&&!g&&(0,Z.jsx)(`span`,{"aria-label":s(`settings.yuri.about.hostUpdate.available`),className:`absolute -right-1.5 -top-0.5 size-1.5 rounded-full bg-[var(--status-error)]`})]}),(0,Z.jsx)(q,{type:`button`,size:`icon`,variant:`ghost`,onClick:D,disabled:p.isFetching&&!g,"aria-label":s(`settings.yuri.about.hostUpdate.title`),title:s(`settings.yuri.about.hostUpdate.title`),children:(0,Z.jsx)(Y,{name:g||p.isFetching?`loader`:m?.update?`download`:`refresh`,className:g||p.isFetching?`size-4 animate-spin`:`size-4`})})]}),(0,Z.jsx)(kr,{open:l,onOpenChange:u,model:M,onAction:F})]})}var Qr=e=>{let t=e?.trim();return t?{location:{directory:t}}:void 0},$r=()=>{let e=T.getSdkClient().plugin;if(!e?.list||!e.check||!e.update)throw Error(`OpenCode plugin status is not available`);return e},ei=e=>{switch(e.type){case`package`:return{kind:`package`,target:e.target,version:e.version??null,outdated:e.outdated===!0,updating:e.updating===!0};case`local`:return{kind:`local`,path:e.path};case`builtin`:case`sdk`:return{kind:`builtin`};default:throw Error(`Unexpected plugin source: ${JSON.stringify(e)}`)}},ti=e=>{if(e.status===`active`)return{kind:`active`};if(e.status===`failed`)return{kind:`failed`,error:e.error,ref:e.ref??null};throw Error(`Unexpected plugin state: ${JSON.stringify(e)}`)},ni=e=>({source:ei(e.source),state:ti(e.state)}),ri=e=>{if(!Array.isArray(e))throw Error(`OpenCode plugin status payload is invalid`);return e.map(e=>ni(e))};async function ii(e,t){return ri((await $r().list(Qr(e),t?{signal:t}:void 0))?.data)}async function ai(e,t){return ri((await $r().check(Qr(e),t?{signal:t}:void 0))?.data)}async function oi(e,t,n){let r=t.trim();if(!r)throw Error(`plugin.update requires a target`);await $r().update({...Qr(e),targets:[r]},n?{signal:n}:void 0)}function si(e){return e instanceof Error&&e.message.trim()?e.message:typeof e==`string`&&e.trim()?e:`plugin operation failed`}var ci=1500,$=e=>e?.trim()||null,li=(e,t=n())=>z.plugins.list(e,t),ui=(e,t,r=!1,i=n())=>z.plugins.registry(e,t,r,i),di=(e,t=n())=>z.plugins.runtime(e,t),fi=0,pi=()=>(fi+=1,fi),mi=()=>{fi+=1},hi=(e,t,n)=>e.getQueryData(di(t,n)),gi=(e=qe(),t=n())=>{let r=$(e);return{queryKey:li(r,t),queryFn:async({signal:e})=>{let t=await a(Di(`/api/config/plugins`,r),{headers:Ai(r),signal:e});if(!t.ok)throw Error(`Failed to load plugins`);let n=await t.json();return{entries:n.entries??[],files:n.files??[]}},staleTime:5e3,retry:2}},_i=(e,t,r=!1,i=n())=>{let o=$(e),s=R(t);return{queryKey:ui(o,s,r,i),queryFn:async({signal:e})=>{let t={};for(let n of ki(s)){let i=await a(Oi(n,r,o),{headers:Ai(o),signal:e});if(!i.ok)throw Error(`Failed to load plugin registry info`);let s=await i.json();for(let e of s.results??[])t[e.spec]=e}return t},staleTime:r?0:3e5,retry:2}},vi=(e=qe(),t=n())=>{let r=$(e);return{queryKey:di(r,t),queryFn:async({signal:e})=>{let n=pi(),i=await ii(r,e);if(n!==fi){let e=hi(L,r,t);if(e)return e;throw Error(`Stale plugin runtime read`)}return i},staleTime:5e3,retry:!1}},yi=e=>{let t=(0,X.c)(7),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let r=n,i=We(ji),a;t[2]===i?a=t[3]:(a=gi($(i)??$(T.getDirectory())),t[2]=i,t[3]=a);let o;return t[4]!==r.enabled||t[5]!==a?(o={...a,enabled:r.enabled},t[4]=r.enabled,t[5]=a,t[6]=o):o=t[6],I(o)},bi=(e,t)=>{let n=(0,X.c)(6),r=t!==void 0&&t,i=We(Mi),a;n[0]!==i||n[1]!==r||n[2]!==e?(a=_i($(i)??$(T.getDirectory()),e,r),n[0]=i,n[1]=r,n[2]=e,n[3]=a):a=n[3];let o;return n[4]===a?o=n[5]:(o={...a},n[4]=a,n[5]=o),I(o)},xi=()=>{let e=(0,X.c)(2),t=We(Ni),n;return e[0]===t?n=e[1]:(n=$(t)??$(T.getDirectory()),e[0]=t,e[1]=n),n},Si=e=>{let t=(0,X.c)(7),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let r=n,i=xi(),a;t[2]===i?a=t[3]:(a=vi(i),t[2]=i,t[3]=a);let o;return t[4]!==r.enabled||t[5]!==a?(o={...a,enabled:r.enabled},t[4]=r.enabled,t[5]=a,t[6]=o):o=t[6],I(o)},Ci=async(e,t,r)=>{let i=$(t);return n()===r?e.fetchQuery({...gi(i,r),staleTime:0}):e.getQueryData(li(i,r))??{entries:[],files:[]}},wi=async(e=L,t,r)=>{let i=$(t),a=n(),o=await _i(i,r,!0,a).queryFn({signal:new AbortController().signal});return e.setQueryData(ui(i,r,!1,a),o),o},Ti=async(e,t,r)=>{let i=$(t);if(n()!==r)return hi(e,i,r);let a=pi(),o=await ii(i);return a!==fi||n()!==r?hi(e,i,r):(e.setQueryData(di(i,r),o),o)},Ei=async(e=qe(),t=L)=>{let r=$(e),i=n(),a=await ai(r);return mi(),n()===i&&t.setQueryData(di(r,i),a),a};function Di(e,t){return`${e}${t?`?directory=${encodeURIComponent(t)}`:``}`}function Oi(e,t,n){let r=new URLSearchParams;t&&r.set(`refresh`,`true`),n&&r.set(`directory`,n);let i=r.toString();return`/api/config/plugins/registry?${`specs=${e.map(encodeURIComponent).join(`,`)}`}${i?`&${i}`:``}`}function ki(e){let t=[],n=[],r=0;for(let i of e){let e=encodeURIComponent(i),a=n.length===0?e.length:r+1+e.length;if(n.length>0&&a>ci){t.push(n),n=[i],r=e.length;continue}n.push(i),r=a}return n.length>0&&t.push(n),t}function Ai(e){return e?{"x-opencode-directory":e}:void 0}function ji(e){return e.getActiveProject?.()?.path??null}function Mi(e){return e.getActiveProject?.()?.path??null}function Ni(e){return e.getActiveProject?.()?.path??null}var Pi=()=>{try{let e=We.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();let t=T.getDirectory();if(t?.trim())return t.trim()}catch(e){console.warn(`[PluginsStore] Error resolving config directory:`,e)}return null},Fi=5e3,Ii=`__default__`,Li=new Map,Ri=new Map,zi=1500,Bi=e=>e?.trim()||Ii,Vi=e=>{Li.delete(Bi(e))},Hi=_()(y(v((e,t)=>({entries:[],files:[],selectedId:null,isLoading:!1,registryInfo:{},isLoadingRegistry:!1,draft:null,setSelected:t=>e({selectedId:t}),setDraft:t=>e({draft:t}),loadPlugins:async i=>{let a=Pi(),o=n(),s=r(),c=()=>o===n()&&s===r()&&a===Pi(),l=Bi(a),u=Date.now(),d=Li.get(l)??0,f=t().entries.length>0||t().files.length>0;if(!i?.force&&f&&u-d<Fi)return!0;let p=Ri.get(l);if(!i?.force&&p)return p;let m=(async()=>{e({isLoading:!0});try{let n=i?.force?await Ci(L,a,o):await L.fetchQuery(gi(a,o));return c()?(e({entries:n.entries??[],files:n.files??[],isLoading:!1}),Li.set(l,Date.now()),i?.force||t().loadRegistryInfo(),!0):!1}catch(t){return console.error(`[PluginsStore] Failed to load plugins:`,t),c()&&e({isLoading:!1}),!1}})();Ri.set(l,m);try{return await m}finally{Ri.delete(l)}},loadRegistryInfo:async n=>{let r=Gi(n?.specs??t().entries.map(e=>e.spec));if(r.length===0){e({isLoadingRegistry:!1});return}e({isLoadingRegistry:!0});try{let i=Pi(),o={...t().registryInfo};for(let e of Ki(r)){let t=await a(Wi(e,n?.force===!0,i),{headers:qi(i)});if(!t.ok)throw Error(`Failed to load plugin registry info`);let r=await Zi(t);for(let e of r.results??[])o[e.spec]=e}e({registryInfo:o,isLoadingRegistry:!1})}catch(t){console.error(`[PluginsStore] Failed to load plugin registry info:`,t),e({isLoadingRegistry:!1})}},updateToLatest:async e=>{let n=t().entries.find(t=>t.id===e);if(!n)return{ok:!1};let r=t().registryInfo[n.spec];return!r||r.kind!==`npm-ok`||!r.hasUpdate||!r.latestVersion?{ok:!1}:await t().updateEntry(e,{spec:`${r.name}@${r.latestVersion}`})},createEntry:async e=>{let n=await Xi(async t=>await a(Ui(`/api/config/plugins/entry`,t),{method:`POST`,headers:Ji(t),body:JSON.stringify(Yi(e))}));return n.ok&&t().loadRegistryInfo({specs:[e.spec],force:!0}),n},updateEntry:async(e,r)=>{let i=(L.getQueryData(gi(Pi(),n()).queryKey)?.entries??t().entries).find(t=>t.id===e),o=i?.spec,s=r.spec??o,c=await Xi(async t=>await a(Ui(`/api/config/plugins/entry/${encodeURIComponent(e)}`,t),{method:`PATCH`,headers:Ji(t),body:JSON.stringify(Yi(r))}),i&&s?{...i,spec:s}:void 0);return c.ok&&s&&t().loadRegistryInfo({specs:[s],force:!0}),c},deleteEntry:async n=>{let r=t().entries.find(e=>e.id===n),i=await Xi(async e=>await a(Ui(`/api/config/plugins/entry/${encodeURIComponent(n)}`,e),{method:`DELETE`,headers:qi(e)}));if(i.ok&&t().selectedId===n&&e({selectedId:null}),i.ok&&r){let n={...t().registryInfo};delete n[r.spec],e({registryInfo:n})}return i},readFile:async e=>{try{let t=Pi(),n=await a(Ui(`/api/config/plugins/file/${encodeURIComponent(e)}`,t),{headers:qi(t)});if(!n.ok)throw Error(`Failed to read plugin file`);return await Zi(n)}catch(e){return console.error(`[PluginsStore] Failed to read plugin file:`,e),null}},createFile:async e=>Xi(async t=>await a(Ui(`/api/config/plugins/file`,t),{method:`POST`,headers:Ji(t),body:JSON.stringify(e)})),updateFile:async(e,t)=>Xi(async n=>await a(Ui(`/api/config/plugins/file/${encodeURIComponent(e)}`,n),{method:`PUT`,headers:Ji(n),body:JSON.stringify(t)})),deleteFile:async n=>{let r=await Xi(async e=>await a(Ui(`/api/config/plugins/file/${encodeURIComponent(n)}`,e),{method:`DELETE`,headers:qi(e)}));return r.ok&&t().selectedId===n&&e({selectedId:null}),r},getById:e=>t().entries.find(t=>t.id===e)??t().files.find(t=>t.id===e)}),{name:`plugins-store`,storage:D(),partialize:e=>({selectedId:e.selectedId})}),{name:`plugins-store`}));function Ui(e,t){return`${e}${t?`?directory=${encodeURIComponent(t)}`:``}`}function Wi(e,t,n){let r=new URLSearchParams;t&&r.set(`refresh`,`true`),n&&r.set(`directory`,n);let i=r.toString();return`/api/config/plugins/registry?${`specs=${e.map(encodeURIComponent).join(`,`)}`}${i?`&${i}`:``}`}function Gi(e){return Array.from(new Set(e.map(e=>e.trim()).filter(Boolean)))}function Ki(e){let t=[],n=[],r=0;for(let i of e){let e=encodeURIComponent(i),a=n.length===0?e.length:r+1+e.length;n.length>0&&a>zi?(t.push(n),n=[i],r=e.length):(n.push(i),r=a)}return n.length>0&&t.push(n),t}function qi(e){return e?{"x-opencode-directory":e}:void 0}function Ji(e){return{"Content-Type":`application/json`,...e?{"x-opencode-directory":e}:{}}}function Yi(e){let t={};return e.spec!==void 0&&(t.spec=e.spec),e.options!==void 0&&(t.options=e.options),e.scope!==void 0&&(t.scope=e.scope),t}async function Xi(e,t){let i=n(),a=r();try{let o=Pi(),s=await e(o),c=await Zi(s).catch(()=>null);if(!s.ok)throw Error(c?.error||`Failed to update plugin configuration`);if(i!==n()||a!==r())return{ok:!0};Vi(o);let l=await Ci(L,o,i);if(o===Pi()&&i===n()&&a===r()){let e=t&&Hi.getState().selectedId===t.id?l.entries.find(e=>e.spec===t.spec&&e.scope===t.scope&&e.sourcePath===t.sourcePath):void 0;Hi.setState({entries:l.entries,files:l.files,...e?{selectedId:e.id}:{}}),Li.set(Bi(o),Date.now())}return{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}}catch(e){return console.error(`[PluginsStore] Failed to update plugin configuration:`,e),{ok:!1}}}async function Zi(e){return await e.json()}var Qi=e=>e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e),$i=e=>{let t=e.replace(/\\/g,`/`),n=[],[r,...i]=t.split(`/`);for(let e of i)if(e!==``&&e!==`.`){if(e===`..`){n.pop();continue}n.push(e)}return`${/^[A-Za-z]:$/.test(r)?`${r.toUpperCase()}/`:`/`}${n.join(`/`)}`},ea=e=>$i(`${e.replace(/\\/g,`/`)}/..`),ta=e=>{try{let t=decodeURIComponent(new URL(e).pathname);return/^\/[A-Za-z]:\//.test(t)?t.slice(1):t}catch{return null}};function na(e,t){if(e.startsWith(`file://`)){let t=ta(e);return t?{kind:`local`,path:$i(t)}:null}return e.startsWith(`./`)||e.startsWith(`../`)?t?{kind:`local`,path:$i(`${ea(t)}/${e}`)}:null:Qi(e)?{kind:`local`,path:$i(e)}:{kind:`package`,target:e}}function ra(e){return e?{kind:`local`,path:$i(e)}:null}var ia=(e,t)=>{if(e.kind===`package`)return t.source.kind===`package`&&t.source.target===e.target;if(t.source.kind!==`local`)return!1;let n=$i(t.source.path);return n===e.path||n.startsWith(`${e.path}/`)};function aa(e,t){return t.filter(t=>ia(e,t))}function oa(e){for(let t of e)if(t.state.kind===`active`&&t.source.kind===`package`&&t.source.version?.trim())return t.source.version.trim();return null}function sa(e){let t=e.find(e=>e.state.kind===`failed`);if(t&&t.state.kind===`failed`)return{kind:`failed`,error:t.state.error,ref:t.state.ref};let n=e[0];return n?{kind:`active`,version:n.source.kind===`package`?n.source.version:null}:{kind:`notReported`}}function ca(e){let t=e.flatMap(e=>e.source.kind===`package`?[e.source]:[]);return t.some(e=>e.updating)?`updating`:t.some(e=>e.outdated)?`available`:`none`}function la(){let e=(0,X.c)(5),t=yi(),n=Si(),r=t.data?.entries,i=t.data?.files,a=n.data,o;bb0:{if(!a){let t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],o=t;break bb0}let t;if(e[1]!==r||e[2]!==i||e[3]!==a){t=[];let n=(e,n,r)=>{if(!r)return;let i=sa(aa(r,a));i.kind===`failed`&&t.push({id:e,label:n,error:i.error})};for(let e of r??[])n(e.id,e.spec,na(e.spec,e.sourcePath));for(let e of i??[])n(e.id,e.fileName,ra(e.absolutePath));e[1]=r,e[2]=i,e[3]=a,e[4]=t}else t=e[4];o=t}return o}var ua=`/mcp/oauth/callback`,da=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}},fa=e=>{let t=ma(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}},pa=e=>{let t=e.get(`state`);return typeof t==`string`&&t.trim()||null},ma=e=>{if(typeof e!=`string`||!e.trim())return null;let t=da(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}},ha=e=>typeof e==`object`&&!!e&&`updateStatus`in e&&typeof e.updateStatus==`function`,ga=e=>{let t=document.createElement(`div`);t.className=`cm-vim-panel`;let n=xn(e);if(!n)return{top:!1,dom:t};n.state.statusbar=t;let r=n.state.vimPlugin;return ha(r)&&r.updateStatus(),{top:!1,dom:t,destroy(){n.state.statusbar===t&&(n.state.statusbar=null)}}};function _a(e){return e?[bn(),ae.of(ga),ce()]:[]}var va={next:`Next match`,prev:`Previous match`,select:`Select all matches`,replace:`Replace`,replaceAll:`Replace all`,close:`Close`},ya={case:`Match case`,re:`Regular expression`,word:`Match whole word`};function ba(e){let t=e.querySelector(`.cm-search`);if(t){for(let[e,n]of Object.entries(va)){let r=t.querySelector(`button[name="${e}"]`);r&&!r.title&&(r.title=n)}for(let[e,n]of Object.entries(ya)){let r=t.querySelector(`input[name="${e}"]`)?.parentElement;r&&!r.title&&(r.title=n)}}}var xa=new WeakMap;function Sa(e,t){let n=gn(e.state);if(!n.valid)return xa.delete(e),0;let r=xa.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 xa.set(e,{query:n,doc:e.state.doc,total:a}),a}function Ca(e){let t=gn(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 wa(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=Sa(t,n),o=a===0?0:Ca(t);i.textContent=a===0?``:`${o}/${a}`}var Ta=new W,Ea=new W,Da=new W,Oa=new W,ka=new W,Aa=new W,ja=new W,Ma=e=>e,Na=fe,Pa=mn,Fa=vn,Ia=class extends me{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(){}},La=(e,t)=>!e||e.length===0?[]:Ce.define({create(n){let r=new ve,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,se.widget({widget:new Ia(e.id,t),block:!0,side:1}))}return r.finish()},update(e,t){return e.map(t.changes)},provide:e=>U.decorations.from(e)}),Ra=e=>{if(!e)return[];let t=Math.max(1,e.start),n=Math.max(t,e.end);return pe.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 ve;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,se.line({class:`yuri-cm-selected-line`}))}return r.finish()}},{decorations:e=>e.decorations})};function za({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=we.create({doc:g.current,extensions:[...e?[U.cspNonce.of(e)]:[],le({fixed:!0}),Ta.of(he(a)),fn(),oe.of(` `),ja.of(_a(p)),ge.of([dn,...un,...pn]),U.updateListener.of(e=>{D(e.view),(e.viewportChanged||e.geometryChanged)&&E(x.current);let t=hn(e.startState),n=hn(e.state);t!==n&&b.current?.(n);let r=!gn(e.startState).eq(gn(e.state));if(n&&(t!==n||r||e.docChanged||e.selectionSet)&&wa(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)}),Ea.of(U.editable.of(!i)),Da.of(n??[]),Oa.of(Ra(o)),ka.of(La(l,C.current)),Aa.of(u?[_n({top:!0}),ge.of(Ma(yn))]:[])]});return h.current=new U({state:t,parent:m.current}),Na(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:[Ta.reconfigure(he(a)),Ea.reconfigure(U.editable.of(!i)),Da.reconfigure(n??[]),Oa.reconfigure(Ra(o)),ka.reconfigure(La(l,C.current)),Aa.reconfigure(u?[_n({top:!0}),ge.of(Ma(yn))]:[])]}),Na(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:ja.reconfigure(_a(p))}))},[p]),Q.useEffect(()=>{let e=h.current;!e||u===!1||(d?(Pa(e),requestAnimationFrame(()=>{ba(e.dom),wa(e.dom,e,!0)})):Fa(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}}),Na(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,Vr.createPortal)(e.content,e.container,e.id))]})}var Ba=ye.define(Me),Va=ke.data.of({commentTokens:{line:`//`,block:{open:`/*`,close:`*/`}}});function Ha(e){let t=e.trim().toLowerCase();switch(t){case`bash`:case`sh`:case`zsh`:case`shell`:case`shellsession`:case`console`:return Ba;case`json`:case`jsonc`:case`json5`:return Oe().language;case`js`:case`javascript`:return Ee().language;case`jsx`:return Ee({jsx:!0}).language;case`ts`:case`typescript`:return Ee({typescript:!0}).language;case`tsx`:return Ee({typescript:!0,jsx:!0}).language;case`html`:return De().language;case`css`:return Te().language;case`py`:case`python`:return je().language;case`md`:case`markdown`:case`mdown`:case`mkd`:return Ae().language;case`heex`:case`eex`:case`leex`:return De().language;default:return Se.matchLanguageName(Sn,t,!0)}}var Ua=e=>e.split(`/`).pop()?.toLowerCase()??``,Wa=e=>{let t=Ua(e);return t?Se.matchFilename(Sn,t):null},Ga=()=>de(_e.define([{tag:[G.heading1,G.heading2,G.heading3,G.heading4,G.heading5,G.heading6],fontWeight:`600`},{tag:G.strong,fontWeight:`600`},{tag:G.emphasis,fontStyle:`italic`},{tag:G.strikethrough,textDecoration:`line-through`},{tag:[G.link,G.url],color:`var(--markdown-link, currentColor)`,textDecoration:`underline`},{tag:G.monospace,color:`var(--markdown-inline-code, currentColor)`,backgroundColor:`var(--markdown-inline-code-bg, transparent)`},{tag:G.quote,color:`var(--markdown-blockquote, currentColor)`,fontStyle:`italic`},{tag:G.list,color:`color-mix(in srgb, var(--muted-foreground) 40%, var(--foreground) 60%)`},{tag:G.heading,color:`var(--markdown-heading1, currentColor)`}]));function Ka(e){let t=e.toLowerCase();switch(Ua(t)){case`makefile`:case`gnumakefile`:return Ba}let n=t.lastIndexOf(`.`),r=n>=0?t.slice(n+1):``;switch(r){case`ts`:case`tsx`:case`mts`:case`cts`:return Ee({typescript:!0,jsx:r===`tsx`});case`js`:case`jsx`:case`mjs`:case`cjs`:return Ee({typescript:!1,jsx:r===`jsx`});case`jsonc`:case`json5`:return[Oe(),Va];case`json`:case`jsonl`:case`ndjson`:case`geojson`:return Oe();case`css`:case`scss`:case`sass`:case`less`:return Te();case`html`:case`htm`:case`xml`:case`drawio`:case`dio`:return De();case`md`:case`mdx`:case`markdown`:case`mdown`:case`mkd`:return[Ae({codeLanguages:Ha}),Ga()];case`sh`:case`bash`:case`zsh`:case`fish`:case`env`:return Ba;case`py`:case`pyw`:case`pyi`:return je();default:return null}}async function qa(e){let t=Wa(e);if(!t)return null;if(t.support)return t.support;try{return await t.load()}catch{return null}}function Ja(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=U.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=_e.define([{tag:[G.comment,G.docComment,G.meta,G.documentMeta],class:`cm-comment`},{tag:[G.keyword,G.controlKeyword,G.moduleKeyword,G.definitionKeyword,G.modifier],class:`cm-keyword`},{tag:[G.operatorKeyword,G.operator,G.derefOperator,G.updateOperator,G.definitionOperator,G.typeOperator,G.controlOperator,G.logicOperator,G.bitwiseOperator,G.arithmeticOperator,G.compareOperator],class:`cm-operator`},{tag:[G.punctuation,G.separator,G.bracket,G.paren,G.brace,G.squareBracket,G.angleBracket],class:`cm-punctuation`},{tag:[G.string,G.regexp,G.attributeValue,G.special(G.string),G.monospace],class:`cm-string`},{tag:G.escape,class:`cm-string-2`},{tag:[G.number,G.bool,G.atom,G.null,G.self],class:`cm-number`},{tag:[G.function(G.variableName),G.function(G.definition(G.variableName)),G.function(G.propertyName),G.standard(G.variableName),G.special(G.variableName)],class:`cm-builtin`},{tag:G.definition(G.variableName),class:`cm-def`},{tag:[G.variableName,G.local(G.variableName),G.constant(G.variableName),G.literal],class:`cm-variable`},{tag:G.propertyName,class:`cm-property`},{tag:G.attributeName,class:`cm-attribute`},{tag:[G.className,G.typeName,G.namespace],class:`cm-variable-3`},{tag:[G.tagName,G.labelName,G.annotation,G.macroName],class:`cm-tag`},{tag:G.link,class:`cm-link`},{tag:[G.heading,G.heading1,G.heading2,G.heading3,G.heading4,G.heading5,G.heading6],class:`cm-keyword`}]),l=_e.define([{tag:[G.comment,G.docComment,G.meta,G.documentMeta],color:e.colors.syntax.base.comment},{tag:[G.keyword,G.controlKeyword,G.moduleKeyword,G.definitionKeyword,G.modifier],color:e.colors.syntax.base.keyword},{tag:[G.operatorKeyword,G.operator,G.derefOperator,G.updateOperator,G.definitionOperator,G.typeOperator,G.controlOperator,G.logicOperator,G.bitwiseOperator,G.arithmeticOperator,G.compareOperator],color:e.colors.syntax.base.operator},{tag:[G.string,G.regexp,G.attributeValue,G.special(G.string),G.monospace],color:e.colors.syntax.base.string},{tag:G.escape,color:a.stringEscape||e.colors.syntax.base.string},{tag:[G.number,G.bool,G.atom,G.null,G.self],color:e.colors.syntax.base.number},{tag:[G.function(G.variableName),G.function(G.definition(G.variableName)),G.function(G.propertyName),G.standard(G.variableName),G.special(G.variableName)],color:e.colors.syntax.base.function},{tag:G.definition(G.variableName),color:a.variableGlobal||e.colors.syntax.base.variable},{tag:[G.variableName,G.local(G.variableName),G.constant(G.variableName),G.literal],color:e.colors.syntax.base.variable},{tag:G.propertyName,color:a.variableProperty||e.colors.syntax.base.variable},{tag:G.attributeName,color:a.variableOther||e.colors.syntax.base.variable},{tag:[G.className,G.typeName,G.namespace],color:e.colors.syntax.base.type},{tag:[G.tagName,G.labelName,G.annotation,G.macroName],color:a.tag||e.colors.syntax.base.keyword},{tag:G.link,color:a.url||e.colors.syntax.base.function,textDecoration:`underline`},{tag:[G.punctuation,G.separator,G.bracket,G.paren,G.brace,G.squareBracket,G.angleBracket],color:a.punctuation||e.colors.syntax.base.comment}]);return t?.syntaxColors===!1?[s]:[s,de(xe,{fallback:!0}),de(ue),de(c),de(l)]}var Ya=180,Xa=be.define(),Za=1,Qa=2,$a=4,eo=new Map,to=(e,t)=>{let n=`${e}|${t}`,r=eo.get(n);if(r)return r;let i=``;e&&(i+=`color:${e};`),t&Za&&(i+=`font-style:italic;`),t&Qa&&(i+=`font-weight:bold;`),t&$a&&(i+=`text-decoration:underline;`);let a=se.mark({attributes:{style:i}});return eo.set(n,a),a},no=(e,t)=>{let n=new ve,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,to(t,r)))}}return n.finish()},ro=Ce.define({create(){return se.none},update(e,t){let n=e.map(t.changes);for(let e of t.effects)e.is(Xa)&&(n=e.value);return n},provide:e=>U.decorations.from(e)}),io=e=>pe.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)},Ya)}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 nn(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:Xa.of(no(t,a))}))}destroy(){this.timer&&clearTimeout(this.timer),this.abortController?.abort(),this.abortController=void 0}}),ao=e=>[ro,io(e)],oo=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)(Tt,{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)(Et,{sideOffset:8,children:o}),t[6]=o,t[7]=l);let u;return t[8]!==c||t[9]!==l?(u=(0,Z.jsxs)(Dt,{children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10],u},so=_()(y(v((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 st(),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 ct();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 ft()}),!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=g()?.settings;if(e)try{n=t(((await e.load())?.settings||{}).defaultGitIdentityId)}catch{}}if(n===null)try{let e=await a(`/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 j({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 dt(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 ot(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 lt(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:D(),partialize:e=>({selectedProfileId:e.selectedProfileId})}),{name:`git-identities-store`}));typeof window<`u`&&(window.__zustand_git_identities_store__=so);var co=`w-full max-w-[30rem]`,lo=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)(Ur,{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],_},uo=450,fo=({projectRef:e=null})=>{let{t}=Ie(),{isMobile:n,isTablet:r}=Xt(),i=n||r,a=We(e=>e.getActiveProject()),o=e?.path??a?.path??null,s=Ue(e=>e.getWorktreeMetadata),c=$e(),l=E(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]),D=Q.useCallback(async()=>{if(!(!T||v===!1))try{let e=await _t(T);x(e)}catch{}},[T,v]);Q.useEffect(()=>{if(!o)return;let e=!1;return y(null),(async()=>{try{let t=await ut(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 _t(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([He(T),Ke(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 O=Q.useCallback(async e=>{if(!T)return!1;let n=e.filter(e=>e.trim().length>0);try{return await Ge(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]),k=Q.useMemo(()=>g!==null&&g!==JSON.stringify(u),[g,u]);Q.useEffect(()=>{if(!k||m||w.current)return;let e=window.setTimeout(()=>{w.current||(w.current=!0,(async()=>{try{await O(u)}finally{w.current=!1}})())},uo);return()=>{window.clearTimeout(e)}},[k,m,O,u]);let A=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(()=>{!k||w.current||(w.current=!0,(async()=>{try{await O(u)}finally{w.current=!1}})())},[k,O,u]),P=Q.useCallback(e=>{p(e),T&&Ze(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=[...Be.getState().activeSessions,...Be.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));Re.requestDelete({sessions:d,mode:`worktree`,worktree:e})},[c,s]),I=Q.useMemo(()=>c.map(e=>e.id).join(`,`),[c]);Q.useEffect(()=>{v&&o&&D()},[I,v,o,D]);let L=(0,Z.jsxs)(Dt,{children:[(0,Z.jsx)(Tt,{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)(Et,{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)(Dt,{children:[(0,Z.jsx)(Tt,{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)(Et,{sideOffset:8,className:`max-w-xs`,children:t(`settings.yuri.worktrees.list.tooltip`)})]});return o?v===!1?(0,Z.jsx)(lo,{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)(lo,{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`,co),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)(wt,{value:e,onChange:e=>A(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)(pt,{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)(lo,{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`,co),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:Pe(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)(lo,{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`)})})},po=(e,t)=>t.updatedAtMs-e.updatedAtMs,mo=_((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(),It()]),i={};for(let e of r.sort(po))i[e.id]=e;t().listenerReady||await Kt(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 Gt(),isImportsLoading:!1})}catch(t){e({isImportsLoading:!1,error:t instanceof Error?t.message:String(t)})}}},refreshStatuses:async()=>{try{let t=await It(),n={};for(let e of t.sort(po))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 Bt({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=zt(e,n);r&&r.trim()&&(i.nickname=r.trim()),await t().upsertInstance(i)},removeInstance:async n=>{await Nt(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 At(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 Nt(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})})),ho=450,go=()=>k(),_o=()=>({id:go(),name:``,command:``,icon:`play`}),vo=({projectRef:e})=>{let{t}=Ie(),n=Q.useMemo(()=>h(),[]),r=mo(e=>e.instances),i=mo(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),m=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 Je(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?Cn(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 Ye(e,{actions:n,primaryActionId:null})?(u(JSON.stringify({actions:n})),typeof window<`u`&&window.dispatchEvent(new CustomEvent(En,{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}})())},ho);return()=>{window.clearTimeout(e)}},[a,v,s,y,_]),Q.useEffect(()=>{if(!v||!_||s){_||(m.current=null);return}let e=window.setTimeout(()=>{m.current!==_&&(m.current=_,J.error(_))},1e3);return()=>{window.clearTimeout(e)}},[v,s,_]);let b=Q.useCallback(()=>{let e=_o();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)(lo,{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`,co),children:a.map(e=>{let r=e.icon||`play`,i=Tn[r]||`play`,a=d[e.id]??!1,o=e.name.trim()||t(`settings.projects.actions.state.untitled`);return(0,Z.jsxs)(ln,{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)(cn,{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)(sn,{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)(qt,{children:[(0,Z.jsx)(Jt,{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)(Ht,{align:`start`,className:`w-56 p-2`,children:(0,Z.jsx)(`div`,{className:`grid grid-cols-6 gap-1`,children:wn.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)(wt,{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)(en,{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)(pt,{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)(wt,{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)(Dt,{children:[(0,Z.jsx)(Tt,{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)(Et,{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)(yt,{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)(gt,{className:`h-7 w-full`,children:(0,Z.jsx)(Ct,{placeholder:t(`settings.projects.actions.field.useOutputManualUrl`)})}),(0,Z.jsxs)(vt,{children:[(0,Z.jsx)(mt,{value:`__none__`,children:t(`settings.projects.actions.field.useOutputManualUrl`)}),g.map(e=>(0,Z.jsx)(mt,{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]})},yo=e=>{let t=(0,X.c)(123),{form:n}=e,{t:r}=Ie(),{currentTheme:i}=et(),{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?bt[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)(wt,{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)(Wr,{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 B;t[15]===r?B=t[16]:(B=r(`settings.projects.page.field.defaultModelDescription`),t[15]=r,t[16]=B);let ee;t[17]!==m||t[18]!==p.modelId||t[19]!==p.providerId?(ee=(0,Z.jsx)(jt,{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]=ee):ee=t[20];let te;t[21]!==z||t[22]!==B||t[23]!==ee?(te=(0,Z.jsx)(Wr,{label:z,description:B,descriptionPlacement:`outside`,itemId:`projects.default-model`,children:ee}),t[21]=z,t[22]=B,t[23]=ee,t[24]=te):te=t[24];let V;t[25]===r?V=t[26]:(V=r(`settings.projects.page.field.accentColor`),t[25]=r,t[26]=V);let ne;t[27]===u?ne=t[28]:(ne=()=>u(null),t[27]=u,t[28]=ne);let re=l===null?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-border/40 hover:border-border hover:bg-[var(--surface-muted)]`,H;t[29]===re?H=t[30]:(H=K(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,re),t[29]=re,t[30]=H);let ie;t[31]===r?ie=t[32]:(ie=r(`settings.projects.page.field.none`),t[31]=r,t[32]=ie);let ae;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,Z.jsx)(Y,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[33]=ae):ae=t[33];let oe;t[34]!==ne||t[35]!==H||t[36]!==ie?(oe=(0,Z.jsx)(`button`,{type:`button`,onClick:ne,className:H,title:ie,children:ae}),t[34]=ne,t[35]=H,t[36]=ie,t[37]=oe):oe=t[37];let se;t[38]!==l||t[39]!==u?(se=St.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]=se):se=t[40];let ce;t[41]!==oe||t[42]!==se?(ce=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[oe,se]}),t[41]=oe,t[42]=se,t[43]=ce):ce=t[43];let U;t[44]!==V||t[45]!==ce?(U=(0,Z.jsx)(Wr,{label:V,itemId:`projects.accent-color`,children:ce}),t[44]=V,t[45]=ce,t[46]=U):U=t[46];let le;t[47]===r?le=t[48]:(le=r(`settings.projects.page.field.projectIcon`),t[47]=r,t[48]=le);let ue;t[49]===O?ue=t[50]:(ue=e=>{let t=e.target.files?.[0]??null;O(t),e.currentTarget.value=``},t[49]=O,t[50]=ue);let de;t[51]!==D||t[52]!==ue?(de=(0,Z.jsx)(`input`,{ref:D,type:`file`,accept:`image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg`,className:`hidden`,onChange:ue}),t[51]=D,t[52]=ue,t[53]=de):de=t[53];let fe;t[54]===c?fe=t[55]:(fe=()=>c(null),t[54]=c,t[55]=fe);let pe=s===null?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-border/40 hover:border-border hover:bg-[var(--surface-muted)]`,me;t[56]===pe?me=t[57]:(me=K(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,pe),t[56]=pe,t[57]=me);let he;t[58]===r?he=t[59]:(he=r(`settings.projects.page.field.none`),t[58]=r,t[59]=he);let ge;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,Z.jsx)(Y,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[60]=ge):ge=t[60];let _e;t[61]!==fe||t[62]!==me||t[63]!==he?(_e=(0,Z.jsx)(`button`,{type:`button`,onClick:fe,className:me,title:he,children:ge}),t[61]=fe,t[62]=me,t[63]=he,t[64]=_e):_e=t[64];let W;t[65]!==N||t[66]!==s||t[67]!==c?(W=xt.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]=W):W=t[68];let ve;t[69]!==_e||t[70]!==W?(ve=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[_e,W]}),t[69]=_e,t[70]=W,t[71]=ve):ve=t[71];let ye;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?(ye=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)(ht,{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]=ye):ye=t[82];let be;t[83]!==w||t[84]!==d||t[85]!==f||t[86]!==r?(be=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)(wt,{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]=be):be=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 G;t[109]!==de||t[110]!==ve||t[111]!==ye||t[112]!==be||t[113]!==we?(G=(0,Z.jsxs)(`div`,{className:`flex w-full flex-col items-end gap-2`,children:[de,ve,ye,be,we]}),t[109]=de,t[110]=ve,t[111]=ye,t[112]=be,t[113]=we,t[114]=G):G=t[114];let Te;t[115]!==le||t[116]!==G?(Te=(0,Z.jsx)(Wr,{label:le,itemId:`projects.icon`,children:G}),t[115]=le,t[116]=G,t[117]=Te):Te=t[117];let Ee;return t[118]!==U||t[119]!==Te||t[120]!==R||t[121]!==te?(Ee=(0,Z.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[R,te,U,Te]}),t[118]=U,t[119]=Te,t[120]=R,t[121]=te,t[122]=Ee):Ee=t[122],Ee},bo=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,xo=e=>{if(!e)return null;let t=e.trim();return t&&bo.test(t)?t.toLowerCase():null},So=e=>{let{t}=Ie(),n=We(e=>e.uploadProjectIcon),r=We(e=>e.removeProjectIcon),i=We(e=>e.discoverProjectIcon),a=We(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(()=>Xe(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),B=!O&&(F||z),ee=!!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),te=Q.useCallback((e,t)=>{h(e&&t?`${e}/${t}`:void 0)},[]),V=Q.useCallback(t=>{!e||!t||g||(C(!1),k(!1),T(t),D(e=>(e&&URL.revokeObjectURL(e),URL.createObjectURL(t))))},[g,e]),ne=Q.useCallback(()=>{!e||!R||v||(F&&j(),C(!!P),k(!1))},[j,F,R,P,v,e]),re=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]),H=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:xo(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:te,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:B,fileInputRef:A,clearPendingUploadIcon:j,handleUploadIcon:V,handleRemoveImageIcon:ne,handleDiscoverIcon:re,hasChanges:ee,prepareSaveData:H,currentIconImage:a,project:e}},Co=450,wo=(e,t)=>{let{t:n}=Ie(),{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}})())},Co);return()=>{window.clearTimeout(e)}},[o,c,r,a,s,f,d,i,t,l,u,p,n])},To=e=>{let t=(0,X.c)(25),{project:n,onIdentitySave:r}=e,{t:i}=Ie(),a=So(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),wo(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)(yo,{form:a}),t[15]=a,t[16]=m);let h,g;t[17]===s?(h=t[18],g=t[19]):(h=(0,Z.jsx)(vo,{projectRef:s}),g=(0,Z.jsx)(fo,{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 Eo(e,t,n){return Math.min(n,Math.max(t,e))}function Do(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 Oo(e,t){let n=Do(t);return n<=0?e:Number(e.toFixed(n))}var ko=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}=Ie(),[h,g]=Q.useState(()=>e===void 0?``:String(e)),{isMobile:_}=Xt(),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=Oo(Eo(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=Oo(Eo(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`})})]})});ko.displayName=`NumberInput`;function Ao(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 jo={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 Mo(e,t){let n=jo[t]??[];for(let t of n)if(t.matcher(e))return t;return null}function No(e){return jo[e]??[]}function Po(e){return[...e].sort((e,t)=>e.order-t.order)}function Fo(e,t){let n=new Map;for(let r of Object.keys(e)){let e=Mo(r,t)?.id??null;n.has(e)||n.set(e,[]),n.get(e).push(r)}return n}function Io(e,t,n){let r=new Map;for(let i of e){let e=Mo(t(i),n)?.id??null;r.has(e)||r.set(e,[]),r.get(e).push(i)}return r}function Lo(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 Ro=(e,t=``,n=!1)=>F({queryKey:z.scoped(`magpie-quotas`,e,t,n),staleTime:0,retry:!1,queryFn:async({signal:t})=>{let r=await a(`/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=>B(t)&&t.source===`magpie`&&t.sourceId===e.id&&t.providerId.startsWith(`magpie:${e.id}:`))))throw Error(`Invalid Magpie quota response`);return i}}),zo=6e4,Bo=0,Vo=0,Ho,Uo=0,Wo=0,Go=0,Ko=new Map,qo=e=>{let t=Dn.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))):zo,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}},Jo=async()=>{let e=g()?.settings;if(e)try{let t=(await e.load())?.settings;return qo(t??null)}catch{}if(!m()){let e=await a(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(e.ok)return qo(await e.json().catch(()=>null))}return{magpieUsageUrl:``,magpieHiddenProviders:[],autoRefresh:!1,refreshIntervalMs:zo,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:Dn.map(e=>e.id),selectedModels:{},expandedFamilies:{}}},Yo=(e,t,n)=>{let r=e.filter(e=>e?.providerId&&e.providerId!==t);return B(n)&&r.push(n),r},Xo=async(e,t)=>{let n=Vo;Ko.set(e,(Ko.get(e)??0)+1),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:!0}}));try{let r=await L.fetchQuery({queryKey:z.quota(e),queryFn:({signal:t})=>ee(e,t),staleTime:0,retry:!1});if(n!==Vo)return{providerId:e,stale:!0};if(!B(r))throw Error(`Invalid quota response`);return t(t=>({results:Yo(t.results,e,r)})),{providerId:e,result:r}}catch(r){return n===Vo?(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===Vo){let n=(Ko.get(e)??1)-1;n>0?Ko.set(e,n):Ko.delete(e),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:n>0}}))}}},Zo=()=>{Ho=void 0,Uo+=1,Vo+=1,Bo+=1,Ko.clear(),Qo.setState({magpieUsageUrl:``,magpieHiddenProviders:[],magpieSources:[],magpieError:null,results:[],isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null})},Qo=_()(y((e,t)=>({magpieSources:[],magpieError:null,magpieHiddenProviders:[],magpieUsageUrl:``,results:[],selectedProviderId:null,isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null,autoRefresh:!1,refreshIntervalMs:zo,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:Dn.map(e=>e.id),selectedModels:{},expandedFamilies:{},loadSettings:async()=>{let t=Vo;try{let n=await Jo();if(t!==Vo)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=++Bo;e({isLoading:!0,error:null});let r=Dn.map(e=>e.id),[i]=await Promise.all([Promise.all(r.map(t=>Xo(t,e))),t().fetchMagpieQuotas(!0)]);if(n===Bo){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 Xo(n,e);`stale`in r||e({error:`error`in r?r.error:null})},fetchMagpieQuotas:async(n=!1)=>{let r=Vo,i=E.getState().currentDirectory,a=t().magpieUsageUrl,o=JSON.stringify([i,a]);Ho!==o&&(Ho=o,Uo+=1,e(e=>({results:e.results.filter(e=>e?.source!==`magpie`),magpieSources:[],magpieError:null})));let s=Uo,c=++Wo;try{let{sources:o,incomplete:l}=await L.fetchQuery(Ro(i,a,n));if(r!==Vo||s!==Uo||c<Go||i!==E.getState().currentDirectory||a!==t().magpieUsageUrl)return;Go=c,e(e=>{let t=new Map(o.filter(e=>e.error&&!e.clearPrevious&&e.results.length===0).map(e=>[e.id,e.error]));if(l){let n=new Set(o.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(...o.flatMap(e=>e.results));let r=n.filter(e=>e.source===`magpie`).map(e=>e.providerId);return{results:n,magpieSources:o,magpieError:null,dropdownProviderIds:[...e.dropdownProviderIds.filter(e=>!e.startsWith(`magpie:`)),...r.filter(t=>!e.magpieHiddenProviders.includes(t))]}})}catch(n){if(r!==Vo||s!==Uo||c<Go||i!==E.getState().currentDirectory||a!==t().magpieUsageUrl)return;Go=c,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}})),j({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}}}),j({usageExpandedFamilies:t().expandedFamilies})},applyDefaultSelections:(n,r)=>{if((t().selectedModels[n]?.length??0)>0)return;let i=Lo(n,r);i.length!==0&&(e(e=>({selectedModels:{...e.selectedModels,[n]:i}})),j({usageSelectedModels:t().selectedModels}))}}),{name:`quota-store`})),$o=()=>{let e=(0,X.c)(11),t=E(es),n=Qo(ts),r=Qo(ns),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=Qo(rs),s=Qo(is),c=Qo(as),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 es(e){return e.currentDirectory}function ts(e){return e.magpieUsageUrl}function ns(e){return e.fetchMagpieQuotas}function rs(e){return e.autoRefresh}function is(e){return e.refreshIntervalMs}function as(e){return e.fetchAllQuotas}var os=e=>{let t=(0,X.c)(20),{percent:n,tonePercent:r,className:i,expectedMarkerPercent:a}=e,o;t[0]===n?o=t[1]:(o=Ut(n)??0,t[0]=n,t[1]=o);let s=o,c=r??n,l;t[2]===c?l=t[3]:(l=Ot(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},ss=e=>{let t=(0,X.c)(67),{paceInfo:n,className:r,compact:i}=e,a=i!==void 0&&i,{t:o}=Ie(),s;t[0]===n.status?s=t[1]:(s=Ft(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:Pt(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:Pt(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},cs=e=>e instanceof Error&&e.name===`CancelledError`,ls=_(()=>({setStatus:e=>kt(L,e),refreshStatus:async(e,t)=>{let r=n();t?.force&&await L.cancelQueries({queryKey:z.github.auth(r),exact:!0});try{return await Rt(L,e,r)}catch(e){if(cs(e))return Lt(L,r);throw e}}})),us={displayMode:`browser`,installed:!1,browserTab:!0},ds=new Set,fs=us,ps=!1,ms,hs=()=>{let e=Vt();return{displayMode:e,installed:e!==`browser`,browserTab:e===`browser`}},gs=()=>(!ps&&typeof window<`u`&&(fs=hs(),ps=!0),fs),_s=()=>{let e=hs();ps=!0,e.displayMode!==fs.displayMode&&(fs=e,ds.forEach(e=>e()))},vs=()=>{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`,_s):typeof t.addListener==`function`&&t.addListener(_s);return window.addEventListener(`appinstalled`,_s),window.addEventListener(`focus`,_s),()=>{for(let t of e)typeof t.removeEventListener==`function`?t.removeEventListener(`change`,_s):typeof t.removeListener==`function`&&t.removeListener(_s);window.removeEventListener(`appinstalled`,_s),window.removeEventListener(`focus`,_s)}},ys=e=>(ds.add(e),ms??=vs(),_s(),()=>{ds.delete(e),ds.size===0&&(ms?.(),ms=void 0)}),bs=()=>Q.useSyncExternalStore(ys,gs,xs);function xs(){return us}var Ss=`Yuri`,Cs=_()(v(e=>({sidebarBrandName:Ss,setSidebarBrandName:t=>{let n=t.slice(0,64);e(e=>e.sidebarBrandName===n?e:{sidebarBrandName:n})}}),{name:`sidebar-brand-store`,storage:A(),version:3,migrate:(e,t)=>{if(!e||typeof e!=`object`)return e;let n={...e};return t<1&&n.sidebarBrandName===`YEE CODE`&&(n.sidebarBrandName=Ss),t<2&&n.sidebarBrandName===`Open Chamber`&&(n.sidebarBrandName=Ss),t<3&&(n.sidebarBrandName===`OPEN CHAMBER`||n.sidebarBrandName===`Open Chamber`)&&(n.sidebarBrandName=Ss),n}}));typeof window<`u`&&t(e=>{i(e)&&Cs.persist.rehydrate()});var ws=(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,Ts=(e,t,n)=>{ws(e.get(t),n)&&e.set(t,n)},Es=e=>{let t=e;return V(t.directory)??V(t.project?.worktree)},Ds=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)},Os=(e,t,n,r,i=[])=>{let a=new Map,o=new Map;for(let e of t){let t=V(e.normalizedPath);if(!t)continue;let n=o.get(t);(!n||e.id.localeCompare(n.id)<0)&&o.set(t,e),Ts(a,t,{projectId:e.id,projectRoot:t,scopeDirectory:t,kind:`project`})}if(!r)for(let[e,t]of n){let n=V(e),r=n?o.get(n):void 0;if(!(!r||!n))for(let e of t){let t=V(e.path);t&&Ts(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=Ds(n)}for(let e of t)s.set(e,i);return i},p=(e,t,n)=>{for(let r of e){let e=f(Es(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}},ks=`__other__`;function As(e){return e.time?.updated??e.time?.archived??e.time?.created??0}function js({mode:e=`dialog`}){let{t}=Ie(),{isMobile:n,isTablet:r,hasTouchInput:i}=Xt(),a=n||r||i,o=e===`page`,s=O(e=>e.isArchivedSessionsDialogOpen),c=O(e=>e.setArchivedSessionsDialogOpen),l=o||s,u=We(e=>e.projects),d=Be(e=>e.archivedSessions),f=Ue(e=>e.setCurrentSession),p=O(e=>e.setSettingsDialogOpen),[h,g]=Q.useState(!1),[_,v]=Q.useState(null),[y,b]=Q.useState(null);Q.useEffect(()=>{if(!l){v(null),b(null);return}let e=!1;return g(!0),ze().catch(()=>{e||J.error(t(`settings.yuri.archivedSessions.toast.loadFailed`))}).finally(()=>{e||g(!1)}),()=>{e=!0}},[l,t]);let x=Q.useMemo(()=>{let e=Os([],u.map(e=>({id:e.id,normalizedPath:e.path})),new Map,m(),d),n=new Map;for(let[t,r]of e.archivedSessionsByProject)n.set(t,[...r].sort((e,t)=>As(t)-As(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)=>As(t)-As(e));i.length>0&&n.set(ks,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(ks);return o&&o.length>0&&a.push({projectId:ks,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=_?x.find(e=>e.projectId===_)??null:null,w=Q.useCallback(async e=>{b(e.id);try{await Qe(e.id)?J.success(t(`settings.yuri.archivedSessions.toast.restored`)):J.error(t(`settings.yuri.archivedSessions.toast.restoreFailed`))}finally{b(null)}},[t]),T=Q.useCallback(e=>{let t=Ve(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`),k=(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:()=>v(null),children:[(0,Z.jsx)(Y,{name:`arrow-left-s`,className:`mr-1 h-4 w-4`}),t(`settings.yuri.archivedSessions.dialog.backToProjects`)]}):null,h?(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=Ve(e),r=As(e),i=y===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?Yt(r):null,r>0&&n?` · `:null,n?Pe(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:()=>v(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:Pe(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&&!h&&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`)}),k]}):a?(0,Z.jsx)(Wt,{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:k}):(0,Z.jsx)(at,{open:s,onOpenChange:c,children:(0,Z.jsxs)(nt,{className:`max-h-[85vh] max-w-2xl overflow-y-auto`,children:[(0,Z.jsxs)(tt,{children:[(0,Z.jsx)(rt,{children:E}),(0,Z.jsx)(it,{children:D})]}),k]})})}function Ms(){let e=(0,X.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(js,{mode:`dialog`}),e[0]=t):t=e[0],t}var Ns=48;function Ps({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=Ne(()=>{s.current=null;let e=i.current,t=a.current;if(!e||!t)return;let n=Math.min(1,Math.max(0,t.scrollTop/Ns)),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=Ne(()=>{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{Gr as $,pa as A,gi as B,ao as C,za as D,qa as E,oa as F,Si as G,Ti as H,sa as I,oi as J,yi as K,ca as L,na as M,aa as N,ua as O,ra as P,Ur as Q,Hi as R,oo as S,Ka as T,xi as U,wi as V,bi as W,Zr as X,Xr as Y,Wr as Z,Po as _,Cs as a,An as at,mo as b,ss as c,On as ct,$o as d,Kr as et,Qo as f,Io as g,Fo as h,Os as i,Bn as it,la as j,fa as k,os as l,Ao as m,Ms as n,Rr as nt,bs as o,kn as ot,No as p,si as q,js as r,pr as rt,ls as s,Dn as st,Ps as t,Hr as tt,Zo as u,ko as v,Ja as w,so as x,To as y,Ei as z};
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,n as r,o as i}from"./runtime-switch-DEZ1K7qW.js";import{n as a}from"./runtime-fetch-D4ja813o.js";import{D as o,E as s,L as c,S as l,T as u,b as d,i as f,n as p,w as m,x as h}from"./desktop-JwYqThiw.js";import{t as g}from"./runtimeAPIRegistry-C2VogTny.js";import{a as _,i as v,r as y}from"./vendor-zustand-o69pgTEK.js";import{it as b,nt as x,o as S,rt as C,s as w}from"./vendor-base-ui-CdzJ6My_.js";import{At as T,bt as E}from"./gitApiHttp-BBRKl9WX.js";import{b as D,n as O}from"./useUIStore-96W41KFb.js";import{$ as k,d as A,i as j}from"./persistence-CBL0OOdj.js";import{n as M}from"./vendor-react-BP2cRVqX.js";import{l as N,n as P,o as F,s as I}from"./vendor-tanstack-react-query-CdqCAt40.js";import{a as L,i as R,o as z,r as B,t as ee}from"./queryRuntime-Dkpnq3Z1.js";import{o as te}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{n as V}from"./pathNormalization-ewtPqJWn.js";import{n as ne,t as re}from"./platform-DFJEtBlo.js";import{a as H,t as ie}from"./types-CGf-3Ixa.js";import{$ as ae,A as oe,B as se,G as ce,H as U,J as le,L as ue,P as de,T as fe,U as pe,W as me,X as he,Y as ge,a as _e,at as W,dt as ve,f as ye,ft as be,g as xe,l as Se,pt as Ce,st as we,z as G}from"./vendor-codemirror-autocomplete-7c2L_4dM.js";import{c as Te,o as Ee,r as De}from"./vendor-codemirror-lang-angular-DXOgWEVj.js";import{n as Oe,r as ke}from"./vendor-codemirror-lang-json-mLulNbwB.js";import{n as Ae}from"./vendor-codemirror-lang-markdown-CV1IO6Qs.js";import{n as je}from"./vendor-codemirror-lang-python-YM2WVLHF.js";import{O as Me}from"./vendor-codemirror-legacy-modes-DwltVFbT.js";import{r as Ne}from"./vendor-reactuses-core-BJ-jJ4YM.js";import{a as Pe,d as Fe,f as Ie,p as Le,r as K,t as q}from"./button-Be1cqulG.js";import{Ci as Re,Dr as ze,Lr as Be,Pr as Ve,Vr as J,ar as He,d as Ue,ho as We,lr as Ge,or as Ke,po as qe,rr as Je,sr as Ye,uo as Xe,ur as Ze,vi as Qe,xn as $e}from"./useMobileNavigationStore-DSeBetKz.js";import{n as et}from"./useThemeSystem-8jhE4Zyk.js";import{n as Y}from"./Icon-Bn4Eec3Y.js";import{a as tt,n as nt,o as rt,r as it,t as at}from"./dialog-BS-KgM5J.js";import{L as ot,_ as st,b as ct,c as lt,n as ut,s as dt,u as ft}from"./gitApi-BiKfKqjS.js";import{A as pt,_ as mt,a as ht,b as gt,c as _t,h as vt,m as yt,n as bt,r as xt,t as St,x as Ct}from"./projectMeta-BIJduxkb.js";import{t as wt}from"./input-DTdHYZ6r.js";import{i as Tt,n as Et,t as Dt}from"./tooltip-C8DhNU1d.js";import{F as Ot,G as kt,Gt as At,J as jt,Jt as Mt,Kt as Nt,M as Pt,P as Ft,Qt as It,U as Lt,W as Rt,Wt as zt,Yt as Bt,a as Vt,it as Ht,k as Ut,q as Wt,qt as Gt,rn as Kt,rt as qt,ut as Jt,v as Yt}from"./speechSettingsQueries-D-pzxl8-.js";import{r as Xt,t as Zt}from"./device-hj359GjJ.js";import{n as Qt}from"./MarkdownRenderer-CcZcvvDG.js";import{n as $t,t as en}from"./textarea-BU8JtaSQ.js";import{a as tn}from"./url-MRa-FtQa.js";import{r as nn}from"./markdown-worker-oBGEB9Eg.js";import{i as rn,n as an,o as on}from"./mcpQueries-6sG9ZjVo.js";import{n as sn,r as cn,t as ln}from"./collapsible-DqfguRMp.js";import{a as un,d as dn,o as fn,s as pn}from"./vendor-codemirror-commands-B8KrBQ9B.js";import{a as mn,c as hn,i as gn,o as _n,r as vn,s as yn}from"./vendor-codemirror-search-ZqtrPLjU.js";import{n as bn,t as xn}from"./vendor-replit-codemirror-vim-DDj0dSVY.js";import{t as Sn}from"./vendor-codemirror-language-data-Ctd4WxgW.js";import{i as Cn,n as wn,r as Tn,t as En}from"./projectActions-BX0cjZoq.js";var Dn=[{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`}],On=e=>[...Dn,...e.filter(e=>e.source===`magpie`).map(e=>({id:e.providerId,name:e.providerName}))],X=M(),Z=C();function kn(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 Q=e(b(),1),An=Q.forwardRef((e,t)=>{let n=(0,X.c)(11),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=K(`peer inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-none transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[checked]:bg-primary data-[unchecked]:bg-[var(--interactive-border)]`,r),n[3]=r,n[4]=a);let o;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(o={width:`36px`,height:`20px`,minWidth:`36px`,minHeight:`20px`},n[5]=o):o=n[5];let s;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(S,{className:K(`pointer-events-none block rounded-full bg-background shadow-none ring-0 transition-transform data-[checked]:translate-x-4 data-[unchecked]:translate-x-0`),style:{width:`16px`,height:`16px`,minWidth:`16px`,minHeight:`16px`}}),n[6]=s):s=n[6];let c;return n[7]!==i||n[8]!==t||n[9]!==a?(c=(0,Z.jsx)(w,{className:a,style:o,...i,ref:t,children:s}),n[7]=i,n[8]=t,n[9]=a,n[10]=c):c=n[10],c});An.displayName=`Switch`;var jn={},Mn=(e,t=n())=>JSON.stringify([t,an(e)]),Nn=(e,t,n)=>{if(!e[t]?.[n])return e;let r={...e[t]};return delete r[n],{...e,[t]:r}},Pn=e=>{let t=an(e);return t?T.getScopedApiClient(t):T.getApiClient()},Fn=e=>e?{location:{directory:e}}:void 0,In=new Map,Ln=(e,t)=>JSON.stringify([r(),Mn(t),e]),Rn=async(e,t,n)=>{let r=(await e.mcp.list(Fn(n))).data.find(e=>e.name===t)?.integrationID;if(!r)throw Error(`MCP server "${t}" has no authentication integration`);return(await e.integration.get({integrationID:r,...Fn(n)})).data},zn=e=>an(e===void 0?E.getState().currentDirectory:e),Bn=_()(y((e,t)=>({diagnosticsByDirectory:{},getDiagnosticForDirectory:e=>{let n=Mn(zn(e));return t().diagnosticsByDirectory[n]??jn},clearDiagnostic:(t,n,r)=>{let i=Mn(zn(n),r);e(e=>({diagnosticsByDirectory:Nn(e.diagnosticsByDirectory,i,t)}))},connect:async(t,r)=>{let i=zn(r),a=n(),o=Mn(i,a),s=Pn(i);try{await s.mcp.connect({server:t,...Fn(i)})}catch(n){let r=n instanceof Error?n.message:`Connection failed`;throw e(e=>({diagnosticsByDirectory:{...e.diagnosticsByDirectory,[o]:{...e.diagnosticsByDirectory[o]??{},[t]:{status:`failed`,error:r}}}})),n}await on(L,i,a),e(e=>({diagnosticsByDirectory:Nn(e.diagnosticsByDirectory,o,t)}))},disconnect:async(t,r)=>{let i=zn(r),a=n(),o=Mn(i,a);await Pn(i).mcp.disconnect({server:t,...Fn(i)}),await on(L,i,a),e(e=>({diagnosticsByDirectory:Nn(e.diagnosticsByDirectory,o,t)}))},startAuth:async(e,t)=>{let n=zn(t),r=Ln(e,n),i=Pn(n),a=await Rn(i,e,n),o=a.methods.find(e=>e.type===`oauth`);if(!o)throw Error(`MCP server "${e}" has no OAuth method`);if(r!==Ln(e,n))throw Error(`MCP authorization runtime changed`);let s=In.get(r);if(s&&(await i.integration.oauth.cancel({integrationID:s.integrationID,attemptID:s.attempt.attemptID,...Fn(n)}),In.delete(r)),r!==Ln(e,n))throw Error(`MCP authorization runtime changed`);let{data:c}=await i.integration.oauth.connect({integrationID:a.id,methodID:o.id,...Fn(n)});if(r!==Ln(e,n))throw Error(`MCP authorization runtime changed`);for(let[e,t]of In)t.attempt.time.expires<=Date.now()&&In.delete(e);return In.set(r,{integrationID:a.id,attempt:c}),c},authStatus:async(e,t)=>{let n=zn(t),r=Ln(e,n),i=In.get(r);if(!i)throw Error(`MCP authorization attempt not found`);let{data:a}=await Pn(n).integration.oauth.status({integrationID:i.integrationID,attemptID:i.attempt.attemptID,...Fn(n)});if(r!==Ln(e,n))throw Error(`MCP authorization runtime changed`);return a.status!==`pending`&&In.get(r)===i&&In.delete(r),a},completeAuth:async(e,t,r)=>{let i=zn(r),a=n(),o=Ln(e,i),s=In.get(o);if(!s||s.attempt.mode!==`code`)throw Error(`MCP authorization requires the browser callback`);if(!t.trim())throw Error(`MCP authorization code is empty`);if(await Pn(i).integration.oauth.complete({integrationID:s.integrationID,attemptID:s.attempt.attemptID,code:t.trim(),...Fn(i)}),In.get(o)===s&&In.delete(o),o!==Ln(e,i))throw Error(`MCP authorization runtime changed`);await on(L,i,a)},clearAuth:async(e,t)=>{let r=zn(t),i=n(),a=Ln(e,r),o=Pn(r),s=await Rn(o,e,r);if(a!==Ln(e,r))throw Error(`MCP authorization runtime changed`);let c=In.get(a);c&&(await o.integration.oauth.cancel({integrationID:c.integrationID,attemptID:c.attempt.attemptID,...Fn(r)}),In.delete(a));let l=new Set(s.connections.flatMap(e=>e.type===`credential`?[e.id]:[]));for(let t of l){if(a!==Ln(e,r))throw Error(`MCP authorization runtime changed`);await o.credential.remove({credentialID:t})}if(a!==Ln(e,r))throw Error(`MCP authorization runtime changed`);await on(L,r,i)},testConnection:async(t,r)=>{let i=zn(r),a=n(),o=Mn(i,a),s=Pn(i),c=rn(L,i,a)[t]?.status===`connected`,l,u;try{await s.mcp.connect({server:t,...Fn(i)})}catch(n){l=n instanceof Error?n.message:`Connection failed`,e(e=>({diagnosticsByDirectory:{...e.diagnosticsByDirectory,[o]:{...e.diagnosticsByDirectory[o]??{},[t]:{status:`failed`,error:l??`Connection failed`}}}}))}let d=(await on(L,i,a))[t],f=d;if(!c&&d?.status===`connected`){try{await s.mcp.disconnect({server:t,...Fn(i)})}catch(e){u=`Connection test succeeded, but cleanup disconnect failed: ${e instanceof Error?e.message:`Disconnect failed`}`}await on(L,i,a)}return l||e(e=>({diagnosticsByDirectory:Nn(e.diagnosticsByDirectory,o,t)})),{status:f??rn(L,i,a)[t],error:l,warning:u}}}))),Vn=`https://yuri-updates.xiaobe.top/v1/update/check`,Hn=`https://yuri-origin.xiaobe.top/v1/update/check`,Un=`https://github.com/yee94/yuri/releases/latest`,Wn=`https://github.com/yee94/yuri/releases`,Gn=`https://testflight.apple.com/join/pN5SSHeg`,Kn=1e4;function qn(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 Jn(e,t){let n=qn(e),r=qn(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 Yn(){return[Vn,Hn]}function Xn(e,t,n=Date.now){let r=e-n();return r<=0||t<=0?null:Math.max(1,Math.ceil(r/t))}function Zn(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 Qn(e,t,n,r){try{if(ne())try{let{CapacitorHttp:r}=await te(async()=>{let{CapacitorHttp:e}=await import(`./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js`).then(e=>e.i);return{CapacitorHttp:e}},__vite__mapDeps([0,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 $n(e,t){return e===`ios`?Gn:`${Wn}/download/v${t}/app-release.apk`}function er(e,t,n){if(typeof e.latestVersion!=`string`||e.latestVersion.trim().length===0)return null;let r=e.latestVersion.trim(),i=Jn(r,t);if(i<0)return null;let a=typeof e.releaseNotesUrl==`string`&&e.releaseNotesUrl.trim().length>0?e.releaseNotesUrl.trim():`${Wn}/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():$n(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 tr(e,t,n,r){let i=await Qn(e,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify(Zn(t))},n,r);if(!i?.ok)return null;let a;try{a=await i.json()}catch{return null}return er(a,t.currentVersion,t.platform)}async function nr(e,t,n,r){let i=await Qn(Un,{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:Un,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=Jn(s,e),l=`${Wn}/tag/v${s}`;return{available:c>0,version:s,currentVersion:e,releaseUrl:l,downloadUrl:$n(t,s)}}async function rr(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=Yn(),a=r()+Kn;for(let[t,o]of i.entries()){let s=Xn(a,i.length-t+1,r);if(s===null)break;let c=await tr(o,e,s,n);if(c)return c}let o=Xn(a,1,r);if(o!==null){let r=await nr(t,e.platform,o,n);if(r)return r}return{available:!1,currentVersion:t,error:`Unable to check for mobile updates`}}function ir(){if(typeof window>`u`)return`unknown`;try{let{deviceType:e}=Zt();return e}catch{return`unknown`}}function ar(){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 or(){let e=re();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 sr(e){let t=O.getState().reportUsage,n=new URLSearchParams({reportUsage:t?`true`:`false`});return n.set(`deviceClass`,ir()),n.set(`arch`,ar()),n.set(`platform`,or()),e===`desktop`?(n.set(`appType`,`desktop-electron`),n.set(`instanceMode`,d()?`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 cr(e,t){let n=t??`unknown`;try{let r=sr(e),i=typeof window<`u`?window.__VSCODE_CONFIG__?.extensionVersion:void 0;t?r.set(`currentVersion`,t):e===`vscode`&&i&&r.set(`currentVersion`,i);let o=await a(`/api/yuri/update-check?${r.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),s=null;try{s=await o.json()}catch{s=null}if(!o.ok)return{available:!1,currentVersion:n,error:typeof s?.error==`string`&&s.error.trim().length>0?s.error.trim():`Server responded with ${o.status}`};if(!s)return{available:!1,currentVersion:n,error:`Update check returned an invalid response`};let c=typeof s.error==`string`&&s.error.trim().length>0?s.error.trim():void 0;return{available:s.available===!0,version:typeof s.version==`string`?s.version:void 0,currentVersion:typeof s.currentVersion==`string`?s.currentVersion:n,body:typeof s.body==`string`?s.body:void 0,releaseUrl:typeof s.releaseUrl==`string`?s.releaseUrl:void 0,downloadUrl:typeof s.downloadUrl==`string`?s.downloadUrl:void 0,nextSuggestedCheckInSec:typeof s.nextSuggestedCheckInSec==`number`&&Number.isFinite(s.nextSuggestedCheckInSec)?s.nextSuggestedCheckInSec:void 0,packageManager:typeof s.packageManager==`string`?s.packageManager:void 0,updateCommand:typeof s.updateCommand==`string`?s.updateCommand:void 0,error:c}}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 lr(){return ne()?`mobile`:l()?`desktop`:m()?`vscode`:u()?`web`:null}var ur={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 dr(e,t){let n=e.isChannelRollback===!0?{isChannelRollback:!0}:{};if(e.primaryAction===`apply_ota`&&e.ota.bundle)return 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}};if(e.primaryAction===`install_native_required`){if(!e.native.version?.trim()||!e.native.installUrl?.trim())throw Error(`Native update required, but the update service supplied no complete installation target`);return{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}}}return{available:!1,otaPhase:`idle`,info:{available:!1,currentVersion:t,nextSuggestedCheckInSec:e.nextCheckInSec,...n}}}var fr=0,pr=_()((e,t)=>({...ur,checkForUpdates:async()=>{let n=lr();if(!n)return null;let r=++fr;e({checking:!0,error:null,runtimeType:n});try{let i=null,a=null;if(n===`desktop`){let n=O.getState().otaChannelOverride;t().lastOtaChannelOverride!==n&&e({downloaded:!1,downloading:!1,available:!1,info:null,otaDecision:null,progress:null,otaPhase:`checking`});let i=await p(n);if(r!==fr||O.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 cr(`web`),a=i?.nextSuggestedCheckInSec??null;else if(n===`vscode`)a=(await cr(`vscode`))?.nextSuggestedCheckInSec??null;else if(n===`mobile`){let n=await H()??`unknown`,r=ne()?g()?.mobileUpdates:void 0,o=O.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=dr(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 ie)){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 rr({currentVersion:n,platform:or()===`ios`?`ios`:`android`,deviceClass:ir(),arch:ar(),reportUsage:O.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===fr&&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=g()?.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=O.getState().otaChannelOverride,r=await p(n);if(n!==O.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 f(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(!l())return()=>{};let n=[],r=await s(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 o(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=g()?.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 c())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(ur)}})),mr=8e3,hr=e=>!!(e&&![`succeeded`,`failed`].includes(e.status));function gr(e,t){if(e!==n()||t!==r())throw Error(`Stale update runtime`)}var _r=(e=n(),t=r(),i)=>({queryKey:[e,`host-update`,t,i??`current`],queryFn:async({signal:n})=>{gr(e,t);let r=new AbortController,o=()=>r.abort();n.addEventListener(`abort`,o,{once:!0});let s;try{return await Promise.race([(async()=>{let n=await a(`/api/system/update${i?`?channel=${i}`:``}`,{headers:{Accept:`application/json`},signal:r.signal});if([404,501].includes(n.status))throw Error(`host_update_unsupported`);let o=await n.json();if(gr(e,t),!n.ok&&n.status!==502||typeof o.serverId!=`string`||typeof o.supported!=`boolean`||![`cli`,`electron`].includes(o.host))throw Error(`Host update check failed`);return o})(),new Promise((e,t)=>{s=setTimeout(()=>{r.abort(),t(Error(`host_update_timeout`))},mr)})])}finally{s!==void 0&&clearTimeout(s),n.removeEventListener(`abort`,o)}},staleTime:6e4,retry:!1}),vr=(e=n(),t=r(),i)=>L.getQueryData(_r(e,t,i).queryKey),yr=(e=n(),t=r(),i)=>{let a=vr(e,t,i);return L.fetchQuery({..._r(e,t,i),staleTime:a?.checkError||hr(a?.operation)?0:6e4})},br=(e=n(),t=r(),i)=>L.fetchQuery({..._r(e,t,i),staleTime:0}),xr=(e,t,n)=>{let r=(0,X.c)(6),i;r[0]!==n||r[1]!==t||r[2]!==e?(i=_r(e,t,n),r[0]=n,r[1]=t,r[2]=e,r[3]=i):i=r[3];let a;return r[4]===i?a=r[5]:(a={...i,refetchInterval:Cr,refetchIntervalInBackground:!1},r[4]=i,r[5]=a),I(a)};async function Sr(e,t,n){if(gr(t,n),!e.update)throw Error(`No update plan`);let r=await a(`/api/system/update`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({version:e.update.version,channel:e.channel,planId:e.update.planId,allowDowngrade:e.update.rollback===!0})});if(gr(t,n),!r.ok)throw Error(`Host update was not accepted`);let i=await r.json();if(typeof i.operation?.id!=`string`)throw Error(`Invalid update operation`);return i.operation}function Cr(e){return hr(e.state.data?.operation)?2e3:e.state.error?.message===`host_update_unsupported`?!1:e.state.error?15e3:3e5}function wr(e){let t=new Date(`${e}T00:00:00`);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(Le(),{year:`numeric`,month:`short`,day:`numeric`}).format(t)}function Tr(e){return e.replace(/^## \[[^\]]+\] - \d{4}-\d{2}-\d{2}\s*\n?/,``).trim()}function Er(e){return e.replace(/(^|[^a-zA-Z0-9])@([a-zA-Z0-9-]+)/g,`$1[@$2](https://github.com/$2)`)}function Dr(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 Or(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.map((t,r)=>{let i=n[r+1]?.start??e.length;return{version:t.version,date:t.date,start:t.start,end:i,raw:e.slice(t.start,i).trim()}})}function kr(e){let t=(0,X.c)(67),{open:n,onOpenChange:r,model:i,onAction:a}=e,{t:o}=Ie(),[s,c]=(0,Q.useState)(!1),l=Ne(jr),u;t[0]===l?u=t[1]:(u=e=>{let t=e.target.closest(`a`);t?.href&&(e.preventDefault(),e.stopPropagation(),l(t.href))},t[0]=l,t[1]=u);let d=Ne(u),f;t[2]===i.fallbackCommand?f=t[3]:(f=async()=>{i.fallbackCommand&&(await Fe(i.fallbackCommand)).ok&&(c(!0),setTimeout(()=>c(!1),2e3))},t[2]=i.fallbackCommand,t[3]=f);let p=Ne(f),m;if(t[4]!==i.body||t[5]!==o){bb0:{let e=i.body?.trim();if(!e){m=null;break bb0}let n=Or(e);if(!n.length){m={kind:`raw`,title:o(`updateDialog.changelog.title`),content:Er(e)};break bb0}let r;t[7]===o?r=t[8]:(r=o(`updateDialog.changelog.title`),t[7]=o,t[8]=r),m={kind:`sections`,title:r,sections:[...n].sort(Ar).map(t=>({version:t.version,dateLabel:wr(t.date),content:Er(Tr(t.raw)||e)}))}}t[4]=i.body,t[5]=o,t[6]=m}else m=t[6];let h=m,g=i.dismissible===!1?void 0:r,_=i.stableLayout&&`h-[min(38rem,calc(100dvh-2rem))] overflow-hidden transition-[opacity,transform,filter]`,v;t[9]===_?v=t[10]:(v=K(`max-w-4xl gap-0 p-4 sm:p-5 bg-background border-[var(--interactive-border)]`,_),t[9]=_,t[10]=v);let y;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(Y,{name:`download-cloud`,className:`h-5 w-5 text-[var(--primary-base)]`}),t[11]=y):y=t[11];let b;t[12]===i.title?b=t[13]:(b=(0,Z.jsxs)(rt,{className:`flex items-center gap-2`,children:[y,(0,Z.jsx)(`span`,{className:`font-semibold text-foreground`,children:i.title})]}),t[12]=i.title,t[13]=b);let x;t[14]!==i.currentVersion||t[15]!==i.methodLabel||t[16]!==i.version?(x=(i.currentVersion||i.version)&&(0,Z.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5 pl-7 font-mono text-[11px] leading-4 tracking-[-0.01em] tabular-nums sm:text-xs`,children:[i.currentVersion&&(0,Z.jsx)(`span`,{className:`text-muted-foreground/75`,children:i.currentVersion}),i.currentVersion&&i.version&&(0,Z.jsx)(`span`,{className:`text-muted-foreground/40`,children:`→`}),i.version&&(0,Z.jsx)(`span`,{className:`font-medium text-[var(--primary-base)]`,children:i.version}),i.methodLabel&&(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· `,i.methodLabel]})]}),t[14]=i.currentVersion,t[15]=i.methodLabel,t[16]=i.version,t[17]=x):x=t[17];let S;t[18]===i.description?S=t[19]:(S=i.description&&(0,Z.jsx)(it,{className:`mt-2`,children:i.description}),t[18]=i.description,t[19]=S);let C;t[20]!==S||t[21]!==b||t[22]!==x?(C=(0,Z.jsxs)(`div`,{className:`mb-3 shrink-0 pr-8 sm:mb-4`,children:[b,x,S]}),t[20]=S,t[21]=b,t[22]=x,t[23]=C):C=t[23];let w=i.stableLayout?`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto`:`space-y-3 sm:space-y-4`,T;t[24]===i.message?T=t[25]:(T=i.message&&(0,Z.jsx)(`p`,{role:`status`,className:`typography-ui-label text-muted-foreground`,children:i.message}),t[24]=i.message,t[25]=T);let E;t[26]===i.warning?E=t[27]:(E=i.warning&&(0,Z.jsx)(`p`,{className:`typography-meta text-[var(--status-warning)]`,children:i.warning}),t[26]=i.warning,t[27]=E);let D;t[28]!==h||t[29]!==d||t[30]!==i.hideChangelog||t[31]!==i.stableLayout?(D=h&&!i.hideChangelog&&(0,Z.jsxs)(`section`,{className:K(`overflow-hidden rounded-xl border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20`,i.stableLayout&&`flex min-h-0 flex-1 flex-col`),children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 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:h.title})]}),(0,Z.jsx)($t,{className:i.stableLayout?`p-0`:`max-h-[min(42dvh,22rem)] p-0 sm:max-h-[400px]`,outerClassName:i.stableLayout?`flex-1`:void 0,fillContainer:!!i.stableLayout,children:h.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:d,children:(0,Z.jsx)(Qt,{content:h.content,disableLinkSafety:!0,enableFileReferences:!1})}):(0,Z.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:h.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:d,children:(0,Z.jsx)(Qt,{content:e.content,disableLinkSafety:!0,enableFileReferences:!1})})]},e.version))})})]}),t[28]=h,t[29]=d,t[30]=i.hideChangelog,t[31]=i.stableLayout,t[32]=D):D=t[32];let O;t[33]!==s||t[34]!==p||t[35]!==i.fallbackCommand||t[36]!==o?(O=i.fallbackCommand&&(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:o(`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:i.fallbackCommand}),(0,Z.jsx)(`button`,{onClick:p,className:K(`flex items-center justify-center p-2 rounded`,`text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]`,`transition-colors`,s&&`text-[var(--status-success)]`),title:o(s?`updateDialog.actions.copied`:`updateDialog.actions.copyCommand`),children:(0,Z.jsx)(Y,{name:s?`check`:`clipboard`,className:`h-4 w-4`})})]})]}),t[33]=s,t[34]=p,t[35]=i.fallbackCommand,t[36]=o,t[37]=O):O=t[37];let k;t[38]!==i.stableLayout||t[39]!==i.status?(k=i.status&&(0,Z.jsxs)(`div`,{role:`status`,className:K(`space-y-2`,i.stableLayout&&`min-h-9 shrink-0`),children:[(0,Z.jsxs)(`div`,{className:`flex h-5 items-center justify-between gap-3`,children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-xs font-medium text-muted-foreground sm:text-[13px]`,children:[i.status.kind===`activity`&&(0,Z.jsx)(Y,{name:`loader`,className:`h-3.5 w-3.5 shrink-0 animate-spin text-[var(--primary-base)]`}),(0,Z.jsx)(`span`,{className:`truncate`,title:i.status.label,children:i.status.label})]}),i.status.progress!=null&&(0,Z.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] leading-4 text-foreground tabular-nums sm:text-xs`,children:[Math.round(i.status.progress),`%`]})]}),(0,Z.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-[var(--surface-subtle)] sm:h-1.5`,children:i.status.progress==null?(0,Z.jsx)(`div`,{className:`h-full w-1/3 animate-pulse rounded-full bg-[var(--primary-base)]/60`}):(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-[var(--primary-base)] transition-[width] duration-500`,style:{width:`${i.status.progress}%`}})}),i.status.detail&&(0,Z.jsx)(`p`,{className:`text-xs leading-4 text-muted-foreground`,children:i.status.detail})]}),t[38]=i.stableLayout,t[39]=i.status,t[40]=k):k=t[40];let A;t[41]===i.error?A=t[42]:(A=i.error&&(0,Z.jsx)(`div`,{role:`alert`,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:i.error})}),t[41]=i.error,t[42]=A);let j;t[43]!==w||t[44]!==T||t[45]!==E||t[46]!==D||t[47]!==O||t[48]!==k||t[49]!==A?(j=(0,Z.jsxs)(`div`,{className:w,children:[T,E,D,O,k,A]}),t[43]=w,t[44]=T,t[45]=E,t[46]=D,t[47]=O,t[48]=k,t[49]=A,t[50]=j):j=t[50];let M;t[51]===i.notice?M=t[52]:(M=i.notice&&(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:i.notice})]}),t[51]=i.notice,t[52]=M);let N;t[53]!==i.actions||t[54]!==i.releaseLink||t[55]!==a?(N=(i.releaseLink||i.actions.length>0)&&(0,Z.jsxs)(`div`,{className:`mt-4 flex shrink-0 items-center justify-between gap-4`,children:[i.releaseLink&&(0,Z.jsxs)(`a`,{href:i.releaseLink.url,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`}),i.releaseLink.label]}),(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-nowrap items-center justify-end gap-2`,children:i.actions.map(e=>(0,Z.jsxs)(q,{onClick:()=>a(e.id),disabled:e.disabled,variant:e.variant??`default`,size:`default`,className:`min-w-0 shrink`,title:e.label,children:[e.icon&&(0,Z.jsx)(Y,{name:e.icon,className:K(`h-4 w-4`,e.loading&&`animate-spin`)}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.label})]},e.id))})]}),t[53]=i.actions,t[54]=i.releaseLink,t[55]=a,t[56]=N):N=t[56];let P;t[57]!==C||t[58]!==j||t[59]!==M||t[60]!==N||t[61]!==v?(P=(0,Z.jsxs)(nt,{className:v,showCloseButton:!0,children:[C,j,M,N]}),t[57]=C,t[58]=j,t[59]=M,t[60]=N,t[61]=v,t[62]=P):P=t[62];let F;return t[63]!==n||t[64]!==P||t[65]!==g?(F=(0,Z.jsx)(at,{open:n,onOpenChange:g,children:P}),t[63]=n,t[64]=P,t[65]=g,t[66]=F):F=t[66],F}function Ar(e,t){return Dr(e.version,t.version)}function jr(e){tn(e)}var Mr=`https://github.com/yee94/yuri/releases`,Nr=2e3,Pr=6e5,Fr=e=>e.transport===n()&&e.generation===r();async function Ir(e,t){try{if(!Fr(t))return{success:!1};let n=await yr(t.transport,t.generation);return!Fr(t)||!e||!n.supported||n.update?.version!==e||n.update.rollback?{success:!1}:(await Sr(n,t.transport,t.generation),{success:!0,autoRestart:!0})}catch(e){return{success:!1,error:e instanceof Error?e.message:void 0}}}async function Lr(e,t,n=Math.ceil(Pr/Nr),r=Nr){for(let i=0;i<n;i++){if(!Fr(t))return!1;try{let n=await br(t.transport,t.generation);if(n.operation?.status===`failed`)return!1;if(n.currentVersion===e&&n.operation?.status===`succeeded`&&Fr(t))return!0}catch{}await new Promise(e=>setTimeout(e,r))}return!1}var Rr=e=>{let t=(0,X.c)(108),{open:i,onOpenChange:a,info:o,downloading:s,downloaded:c,progress:l,error:u,onDownload:d,onRestart:f,runtimeType:p}=e,m=p===void 0?`desktop`:p,{t:h}=Ie(),[g,_]=(0,Q.useState)(`idle`),[v,y]=(0,Q.useState)(null),b=pr(zr),x=o?.releaseUrl||(o?.version?`${Mr}/tag/v${o.version}`:Mr),S=o?.downloadUrl,C=m===`web`,w=m===`mobile`,T=w&&o?.manualUpdate===!0&&!!S,E=w&&o?.inAppApply===!0,D=m===`desktop`&&o?.manualUpdate===!0,O=g!==`idle`&&g!==`error`,k=w?S:x,A;t[0]!==c||t[1]!==E||t[2]!==a?(A=e=>{!e&&E&&c&&pr.getState().dismiss(),a(e)},t[0]=c,t[1]=E,t[2]=a,t[3]=A):A=t[3];let j=Ne(A),M,N;t[4]===i?(M=t[5],N=t[6]):(M=()=>{i||(_(`idle`),y(null))},N=[i],t[4]=i,t[5]=M,t[6]=N),(0,Q.useEffect)(M,N);let P;t[7]!==o?.version||t[8]!==h?(P=async()=>{let e={transport:n(),generation:r()};_(`updating`),y(null);let t=await Ir(o?.version,e);if(!Fr(e))return;if(!t.success){_(`error`),y(t.error||h(`updateDialog.error.updateFailed`));return}t.autoRestart&&(_(`restarting`),await new Promise(Br)),_(`reconnecting`);let i=await Lr(o?.version,e);Fr(e)&&(i?window.location.reload():(_(`error`),y(h(`updateDialog.error.takingLonger`))))},t[7]=o?.version,t[8]=h,t[9]=P):P=t[9];let F=Ne(P),I;t[10]!==F||t[11]!==w||t[12]!==d||t[13]!==a||t[14]!==f||t[15]!==S||t[16]!==x||t[17]!==m?(I=e=>{bb107:switch(e){case`download`:d(),m===`desktop`&&a(!1);break bb107;case`restart`:f();break bb107;case`later`:pr.getState().dismiss(),a(!1);break bb107;case`open-external`:{let e=w?S:x;e&&tn(e);break bb107}case`web-update`:F()}},t[10]=F,t[11]=w,t[12]=d,t[13]=a,t[14]=f,t[15]=S,t[16]=x,t[17]=m,t[18]=I):I=t[18];let L=Ne(I),R;if(t[19]!==c||t[20]!==s||t[21]!==E||t[22]!==D||t[23]!==w||t[24]!==C||t[25]!==O||t[26]!==T||t[27]!==h){if(R=[],!C&&(!w||E)){if(!D&&!c&&!s){let e;t[29]!==E||t[30]!==h?(e=h(E?`updateDialog.actions.applyOtaNow`:`updateDialog.actions.downloadUpdate`),t[29]=E,t[30]=h,t[31]=e):e=t[31];let n;t[32]===e?n=t[33]:(n={id:`download`,icon:`download`,label:e},t[32]=e,t[33]=n),R.push(n)}if(D&&!c&&!s){let e;t[34]===h?e=t[35]:(e=h(`updateDialog.actions.openMobileUpdate`),t[34]=h,t[35]=e);let n;t[36]===e?n=t[37]:(n={id:`open-external`,icon:`external-link`,label:e},t[36]=e,t[37]=n),R.push(n)}if(s){let e;t[38]===h?e=t[39]:(e=h(`updateDialog.status.downloading`),t[38]=h,t[39]=e);let n;t[40]===e?n=t[41]:(n={id:`downloading`,icon:`loader`,loading:!0,disabled:!0,label:e},t[40]=e,t[41]=n),R.push(n)}if(c){if(E){let e;t[42]===h?e=t[43]:(e=h(`updateDialog.actions.later`),t[42]=h,t[43]=e);let n;t[44]===e?n=t[45]:(n={id:`later`,variant:`ghost`,label:e},t[44]=e,t[45]=n),R.push(n)}let e;t[46]===h?e=t[47]:(e=h(`updateDialog.actions.restartToUpdate`),t[46]=h,t[47]=e);let n;t[48]===e?n=t[49]:(n={id:`restart`,icon:`restart`,label:e},t[48]=e,t[49]=n),R.push(n)}}if(w&&!E&&T){let e;t[50]===h?e=t[51]:(e=h(`updateDialog.actions.openMobileUpdate`),t[50]=h,t[51]=e);let n;t[52]===e?n=t[53]:(n={id:`open-external`,icon:`external-link`,label:e},t[52]=e,t[53]=n),R.push(n)}if(C){let e;t[54]!==O||t[55]!==h?(e=O?{id:`updating`,icon:`loader`,loading:!0,disabled:!0,label:h(`updateDialog.status.updating`)}:{id:`web-update`,icon:`download`,label:h(`updateDialog.actions.updateNow`)},t[54]=O,t[55]=h,t[56]=e):e=t[56],R.push(e)}t[19]=c,t[20]=s,t[21]=E,t[22]=D,t[23]=w,t[24]=C,t[25]=O,t[26]=T,t[27]=h,t[28]=R}else R=t[28];let z;t[57]!==h||t[58]!==g?(z=h(g===`restarting`||g===`reconnecting`?`updateDialog.header.updating`:`updateDialog.header.updateAvailable`),t[57]=h,t[58]=g,t[59]=z):z=t[59];let B=o?.currentVersion,ee=o?.version,te=o?.body,V=!O,ne=u||v,re=C&&g===`error`?o?.updateCommand||`yuri update`:void 0,H;t[60]!==c||t[61]!==E||t[62]!==b||t[63]!==h?(H=E&&c&&b?h(`updateDialog.status.otaBundleReused`):void 0,t[60]=c,t[61]=E,t[62]=b,t[63]=h,t[64]=H):H=t[64];let ie;t[65]!==w||t[66]!==k||t[67]!==T?(ie=(!w||T)&&k?{url:k,label:`GitHub`}:void 0,t[65]=w,t[66]=k,t[67]=T,t[68]=ie):ie=t[68];let ae;if(t[69]!==R||t[70]!==s||t[71]!==E||t[72]!==w||t[73]!==C||t[74]!==O||t[75]!==l||t[76]!==h||t[77]!==te||t[78]!==V||t[79]!==ne||t[80]!==re||t[81]!==H||t[82]!==ie||t[83]!==z||t[84]!==B||t[85]!==ee||t[86]!==g){if(ae={title:z,currentVersion:B,version:ee,body:te,hideChangelog:O,dismissible:V,error:ne,fallbackCommand:re,notice:H,releaseLink:ie,actions:R},C&&O){let e;t[88]!==h||t[89]!==g?(e=h(g===`updating`?`updateDialog.status.installingUpdate`:g===`restarting`?`updateDialog.status.serverRestarting`:`updateDialog.status.waitingForServer`),t[88]=h,t[89]=g,t[90]=e):e=t[90];let n;t[91]===h?n=t[92]:(n=h(`updateDialog.status.autoReloadHint`),t[91]=h,t[92]=n);let r;t[93]!==e||t[94]!==n?(r={kind:`activity`,label:e,detail:n},t[93]=e,t[94]=n,t[95]=r):r=t[95],ae.status=r}if(!C&&(!w||E)&&s){let e;t[96]===h?e=t[97]:(e=h(`updateDialog.status.downloadingPayload`),t[96]=h,t[97]=e);let n;t[98]===l?n=t[99]:(n=l?.total?Math.round(l.downloaded/l.total*100):0,t[98]=l,t[99]=n);let r;t[100]!==e||t[101]!==n?(r={kind:`download`,label:e,progress:n},t[100]=e,t[101]=n,t[102]=r):r=t[102],ae.status=r}t[69]=R,t[70]=s,t[71]=E,t[72]=w,t[73]=C,t[74]=O,t[75]=l,t[76]=h,t[77]=te,t[78]=V,t[79]=ne,t[80]=re,t[81]=H,t[82]=ie,t[83]=z,t[84]=B,t[85]=ee,t[86]=g,t[87]=ae}else ae=t[87];let oe;return t[103]!==L||t[104]!==j||t[105]!==ae||t[106]!==i?(oe=(0,Z.jsx)(kr,{open:i,onOpenChange:j,model:ae,onAction:L}),t[103]=L,t[104]=j,t[105]=ae,t[106]=i,t[107]=oe):oe=t[107],oe};function zr(e){return e.otaDownloadSkipped}function Br(e){return setTimeout(e,2e3)}var Vr=e(x(),1);function Hr(e){let t=(0,X.c)(10),{children:n,actions:r,className:i}=e,a;t[0]===i?a=t[1]:(a=K(`sticky top-0 z-10 flex shrink-0 items-center justify-between gap-3 bg-background py-3`,i),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:n}),t[2]=n,t[3]=o);let s;t[4]===r?s=t[5]:(s=(0,Z.jsx)(`div`,{className:`flex max-w-[70%] shrink-0 flex-wrap items-center justify-end gap-2 [&_button]:max-w-full [&_button]:whitespace-normal`,children:r}),t[4]=r,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,Z.jsxs)(`header`,{"data-settings-action-header":``,className:a,children:[o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function Ur(e){let t=(0,X.c)(21),{label:n,actions:r,children:i,description:a,itemId:o,ariaLabel:s,className:c,cardClassName:l,cardId:u}=e,d=typeof n==`string`&&/^[\p{Script=Latin}\p{Number}\p{Punctuation}\p{Separator}]+$/u.test(n)?`latin`:void 0,f;t[0]===c?f=t[1]:(f=K(`yuri-settings-group`,c),t[0]=c,t[1]=f);let p;t[2]!==r||t[3]!==n||t[4]!==d?(p=r?(0,Z.jsx)(Hr,{actions:r,children:n?(0,Z.jsx)(`div`,{className:`yuri-settings-group-label`,"data-settings-label-script":d,children:n}):null}):n?(0,Z.jsx)(`div`,{className:`yuri-settings-group-label`,"data-settings-label-script":d,children:n}):null,t[2]=r,t[3]=n,t[4]=d,t[5]=p):p=t[5];let m;t[6]===l?m=t[7]:(m=K(`yuri-settings-group-card`,l),t[6]=l,t[7]=m);let h;t[8]!==u||t[9]!==i||t[10]!==o||t[11]!==m?(h=(0,Z.jsx)(`div`,{id:u,"data-settings-item":o,className:m,children:i}),t[8]=u,t[9]=i,t[10]=o,t[11]=m,t[12]=h):h=t[12];let g;t[13]===a?g=t[14]:(g=a?(0,Z.jsx)(`p`,{className:`yuri-settings-group-description text-muted-foreground`,children:a}):null,t[13]=a,t[14]=g);let _;return t[15]!==s||t[16]!==f||t[17]!==p||t[18]!==h||t[19]!==g?(_=(0,Z.jsxs)(`section`,{className:f,"aria-label":s,children:[p,h,g]}),t[15]=s,t[16]=f,t[17]=p,t[18]=h,t[19]=g,t[20]=_):_=t[20],_}function Wr(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)(Gr,{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)(Ur,{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 Gr(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 Kr(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=qr,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)(pt,{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 qr(e){return e instanceof HTMLElement&&e.closest(`button, a, input, select, textarea`)!==null}function Jr(e,t){return e===`checking`?5:e===`downloading`?5+Math.min(Math.max(t??0,0),100)*.75:e===`installing`?85:e===`restarting`?95:100}function Yr(e,t,n){let r=e?.operation,i=e?.update,a=i??(r&&t.updateDetails&&r.planId===t.updateDetails.planId&&r.version===t.updateDetails.version?t.updateDetails:void 0),o=hr(r),s=e?.supported===!1||t.failure===`unsupported`,c={title:n(`settings.yuri.about.hostUpdate.title`),stableLayout:!0,description:n(`settings.yuri.about.hostUpdate.description`),currentVersion:e?.currentVersion??t.versionFallback,version:i?.version??r?.version,body:a||r?a?.releaseNotes||n(`settings.yuri.about.hostUpdate.noNotes`):void 0,warning:!o&&i?.rollback?n(`settings.yuri.about.hostUpdate.downgrade`):void 0,actions:o||t.submitting||t.completed||!i?[]:[{id:`confirm`,icon:`download`,label:n(`settings.yuri.about.hostUpdate.confirm`),disabled:!e?.supported||!!t.failure||!!t.checking}]};return o&&r?c.status={kind:r.status===`downloading`?`download`:`activity`,label:n(t.failure===`disconnected`?`settings.yuri.about.hostUpdate.reconnecting`:`settings.yuri.about.hostUpdate.status.${r.status}`),progress:Jr(r.status,r.progress)}:t.completed&&!i?c.status={kind:`download`,label:n(`settings.yuri.about.hostUpdate.status.succeeded`),progress:100}:t.submitting?c.status={kind:`activity`,label:n(`settings.yuri.about.state.checking`),progress:0}:t.checking===`initial`?c.status={kind:`activity`,label:n(`settings.yuri.about.state.checking`)}:s?c.message=n(`settings.yuri.about.hostUpdate.unsupported`):t.failure?c.error=n(t.failure===`disconnected`?`settings.yuri.about.hostUpdate.reconnecting`:`settings.yuri.about.toast.checkFailed`):!i&&e?.supported&&(c.message=r?.status===`succeeded`?n(`settings.yuri.about.hostUpdate.status.succeeded`):n(`settings.yuri.about.toast.latestVersion`)),r?.status===`failed`&&(c.error=n(`settings.yuri.about.hostUpdate.status.failed`)),c}function Xr(){let e=(0,X.c)(7),{t:i}=Ie(),a=Q.useSyncExternalStore(t,n,n),o=Q.useSyncExternalStore(t,r,r),s=`${a}:${o}`,c;e[0]===i?c=e[1]:(c=i(`settings.yuri.about.state.unknown`),e[0]=i,e[1]=c);let l;return e[2]!==o||e[3]!==s||e[4]!==c||e[5]!==a?(l=(0,Z.jsx)(Zr,{transport:a,generation:o,version:c},s),e[2]=o,e[3]=s,e[4]=c,e[5]=a,e[6]=l):l=e[6],l}function Zr({version:e,transport:t,generation:i,itemId:a,channel:o}){let{t:s}=Ie(),c=N(),[l,u]=Q.useState(!1),d=O(e=>e.otaChannelOverride),f=o??d??void 0,p=xr(t,i,f),m=p.data,h=m?.operation,g=hr(h),_=JSON.stringify([t,i,f??`current`]),[v,y]=Q.useState(null);m?.update&&(v?.scope!==_||v.update!==m.update)&&y({scope:_,update:m.update});let b=P({mutationFn:({plan:e})=>Sr(e,t,i),onSuccess:(e,a)=>{t===n()&&i===r()&&c.setQueryData(_r(t,i,a.channel).queryKey,t=>t&&{...t,operation:e})},onSettled:(e,a,o)=>{t===n()&&i===r()&&c.invalidateQueries({queryKey:_r(t,i,o.channel).queryKey,exact:!0})}}),[x,S]=Q.useState(null);l&&g&&h&&h.id!==x&&S(h.id);let C=h?.status===`succeeded`&&h.id===x,w=s(`settings.yuri.about.hostUpdate.status.succeeded`);Q.useEffect(()=>{!C||p.isError||t!==n()||i!==r()||(S(null),u(!1),J.success(w,{id:`host-update:${t}:${i}:${x}`}))},[C,p.isError,t,i,x,w]);let T=Q.useRef(null),E=Ne(()=>_),D=Ne(async()=>{if(g){u(!0),p.refetch({cancelRefetch:!1});return}if(T.current===_)return;let e=_;T.current=e;try{let a=await p.refetch({cancelRefetch:!1});if(e!==E()||t!==n()||i!==r())return;if(a.isError||!a.data||a.data.checkError){a.error?.message===`host_update_unsupported`?J.info(s(`settings.yuri.about.hostUpdate.unsupported`)):J.error(s(`settings.yuri.about.toast.checkFailed`));return}hr(a.data.operation)?u(!0):a.data.supported?a.data.update?u(!0):(u(!1),J.success(s(`settings.yuri.about.toast.latestVersion`))):J.info(s(`settings.yuri.about.hostUpdate.unsupported`))}finally{T.current===e&&(T.current=null)}}),k=m?.supported===!1||!g&&p.error?.message===`host_update_unsupported`,A=p.isError||!!m?.checkError,j=b.isError&&b.variables?.channel===f,M=Yr(m,{versionFallback:e,checking:p.isPending?`initial`:p.isFetching?`refresh`:!1,submitting:b.isPending,failure:k?`unsupported`:p.isError&&(g||j)?`disconnected`:A||j?`check`:null,completed:C,updateDetails:v?.scope===_?v.update:void 0},s),F=Ne(e=>{e===`confirm`&&m?.update&&b.mutate({plan:m,channel:f})});return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,"data-settings-item":a,children:[(0,Z.jsxs)(`span`,{className:`relative typography-ui-label font-mono text-foreground text-right`,children:[m?.currentVersion??e,m?.update&&!g&&(0,Z.jsx)(`span`,{"aria-label":s(`settings.yuri.about.hostUpdate.available`),className:`absolute -right-1.5 -top-0.5 size-1.5 rounded-full bg-[var(--status-error)]`})]}),(0,Z.jsx)(q,{type:`button`,size:`icon`,variant:`ghost`,onClick:D,disabled:p.isFetching&&!g,"aria-label":s(`settings.yuri.about.hostUpdate.title`),title:s(`settings.yuri.about.hostUpdate.title`),children:(0,Z.jsx)(Y,{name:g||p.isFetching?`loader`:m?.update?`download`:`refresh`,className:g||p.isFetching?`size-4 animate-spin`:`size-4`})})]}),(0,Z.jsx)(kr,{open:l,onOpenChange:u,model:M,onAction:F})]})}var Qr=e=>{let t=e?.trim();return t?{location:{directory:t}}:void 0},$r=()=>{let e=T.getSdkClient().plugin;if(!e?.list||!e.check||!e.update)throw Error(`OpenCode plugin status is not available`);return e},ei=e=>{switch(e.type){case`package`:return{kind:`package`,target:e.target,version:e.version??null,outdated:e.outdated===!0,updating:e.updating===!0};case`local`:return{kind:`local`,path:e.path};case`builtin`:case`sdk`:return{kind:`builtin`};default:throw Error(`Unexpected plugin source: ${JSON.stringify(e)}`)}},ti=e=>{if(e.status===`active`)return{kind:`active`};if(e.status===`failed`)return{kind:`failed`,error:e.error,ref:e.ref??null};throw Error(`Unexpected plugin state: ${JSON.stringify(e)}`)},ni=e=>({source:ei(e.source),state:ti(e.state)}),ri=e=>{if(!Array.isArray(e))throw Error(`OpenCode plugin status payload is invalid`);return e.map(e=>ni(e))};async function ii(e,t){return ri((await $r().list(Qr(e),t?{signal:t}:void 0))?.data)}async function ai(e,t){return ri((await $r().check(Qr(e),t?{signal:t}:void 0))?.data)}async function oi(e,t,n){let r=t.trim();if(!r)throw Error(`plugin.update requires a target`);await $r().update({...Qr(e),targets:[r]},n?{signal:n}:void 0)}function si(e){return e instanceof Error&&e.message.trim()?e.message:typeof e==`string`&&e.trim()?e:`plugin operation failed`}var ci=1500,$=e=>e?.trim()||null,li=(e,t=n())=>z.plugins.list(e,t),ui=(e,t,r=!1,i=n())=>z.plugins.registry(e,t,r,i),di=(e,t=n())=>z.plugins.runtime(e,t),fi=0,pi=()=>(fi+=1,fi),mi=()=>{fi+=1},hi=(e,t,n)=>e.getQueryData(di(t,n)),gi=(e=qe(),t=n())=>{let r=$(e);return{queryKey:li(r,t),queryFn:async({signal:e})=>{let t=await a(Di(`/api/config/plugins`,r),{headers:Ai(r),signal:e});if(!t.ok)throw Error(`Failed to load plugins`);let n=await t.json();return{entries:n.entries??[],files:n.files??[]}},staleTime:5e3,retry:2}},_i=(e,t,r=!1,i=n())=>{let o=$(e),s=R(t);return{queryKey:ui(o,s,r,i),queryFn:async({signal:e})=>{let t={};for(let n of ki(s)){let i=await a(Oi(n,r,o),{headers:Ai(o),signal:e});if(!i.ok)throw Error(`Failed to load plugin registry info`);let s=await i.json();for(let e of s.results??[])t[e.spec]=e}return t},staleTime:r?0:3e5,retry:2}},vi=(e=qe(),t=n())=>{let r=$(e);return{queryKey:di(r,t),queryFn:async({signal:e})=>{let n=pi(),i=await ii(r,e);if(n!==fi){let e=hi(L,r,t);if(e)return e;throw Error(`Stale plugin runtime read`)}return i},staleTime:5e3,retry:!1}},yi=e=>{let t=(0,X.c)(7),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let r=n,i=We(ji),a;t[2]===i?a=t[3]:(a=gi($(i)??$(T.getDirectory())),t[2]=i,t[3]=a);let o;return t[4]!==r.enabled||t[5]!==a?(o={...a,enabled:r.enabled},t[4]=r.enabled,t[5]=a,t[6]=o):o=t[6],I(o)},bi=(e,t)=>{let n=(0,X.c)(6),r=t!==void 0&&t,i=We(Mi),a;n[0]!==i||n[1]!==r||n[2]!==e?(a=_i($(i)??$(T.getDirectory()),e,r),n[0]=i,n[1]=r,n[2]=e,n[3]=a):a=n[3];let o;return n[4]===a?o=n[5]:(o={...a},n[4]=a,n[5]=o),I(o)},xi=()=>{let e=(0,X.c)(2),t=We(Ni),n;return e[0]===t?n=e[1]:(n=$(t)??$(T.getDirectory()),e[0]=t,e[1]=n),n},Si=e=>{let t=(0,X.c)(7),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let r=n,i=xi(),a;t[2]===i?a=t[3]:(a=vi(i),t[2]=i,t[3]=a);let o;return t[4]!==r.enabled||t[5]!==a?(o={...a,enabled:r.enabled},t[4]=r.enabled,t[5]=a,t[6]=o):o=t[6],I(o)},Ci=async(e,t,r)=>{let i=$(t);return n()===r?e.fetchQuery({...gi(i,r),staleTime:0}):e.getQueryData(li(i,r))??{entries:[],files:[]}},wi=async(e=L,t,r)=>{let i=$(t),a=n(),o=await _i(i,r,!0,a).queryFn({signal:new AbortController().signal});return e.setQueryData(ui(i,r,!1,a),o),o},Ti=async(e,t,r)=>{let i=$(t);if(n()!==r)return hi(e,i,r);let a=pi(),o=await ii(i);return a!==fi||n()!==r?hi(e,i,r):(e.setQueryData(di(i,r),o),o)},Ei=async(e=qe(),t=L)=>{let r=$(e),i=n(),a=await ai(r);return mi(),n()===i&&t.setQueryData(di(r,i),a),a};function Di(e,t){return`${e}${t?`?directory=${encodeURIComponent(t)}`:``}`}function Oi(e,t,n){let r=new URLSearchParams;t&&r.set(`refresh`,`true`),n&&r.set(`directory`,n);let i=r.toString();return`/api/config/plugins/registry?${`specs=${e.map(encodeURIComponent).join(`,`)}`}${i?`&${i}`:``}`}function ki(e){let t=[],n=[],r=0;for(let i of e){let e=encodeURIComponent(i),a=n.length===0?e.length:r+1+e.length;if(n.length>0&&a>ci){t.push(n),n=[i],r=e.length;continue}n.push(i),r=a}return n.length>0&&t.push(n),t}function Ai(e){return e?{"x-opencode-directory":e}:void 0}function ji(e){return e.getActiveProject?.()?.path??null}function Mi(e){return e.getActiveProject?.()?.path??null}function Ni(e){return e.getActiveProject?.()?.path??null}var Pi=()=>{try{let e=We.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();let t=T.getDirectory();if(t?.trim())return t.trim()}catch(e){console.warn(`[PluginsStore] Error resolving config directory:`,e)}return null},Fi=5e3,Ii=`__default__`,Li=new Map,Ri=new Map,zi=1500,Bi=e=>e?.trim()||Ii,Vi=e=>{Li.delete(Bi(e))},Hi=_()(y(v((e,t)=>({entries:[],files:[],selectedId:null,isLoading:!1,registryInfo:{},isLoadingRegistry:!1,draft:null,setSelected:t=>e({selectedId:t}),setDraft:t=>e({draft:t}),loadPlugins:async i=>{let a=Pi(),o=n(),s=r(),c=()=>o===n()&&s===r()&&a===Pi(),l=Bi(a),u=Date.now(),d=Li.get(l)??0,f=t().entries.length>0||t().files.length>0;if(!i?.force&&f&&u-d<Fi)return!0;let p=Ri.get(l);if(!i?.force&&p)return p;let m=(async()=>{e({isLoading:!0});try{let n=i?.force?await Ci(L,a,o):await L.fetchQuery(gi(a,o));return c()?(e({entries:n.entries??[],files:n.files??[],isLoading:!1}),Li.set(l,Date.now()),i?.force||t().loadRegistryInfo(),!0):!1}catch(t){return console.error(`[PluginsStore] Failed to load plugins:`,t),c()&&e({isLoading:!1}),!1}})();Ri.set(l,m);try{return await m}finally{Ri.delete(l)}},loadRegistryInfo:async n=>{let r=Gi(n?.specs??t().entries.map(e=>e.spec));if(r.length===0){e({isLoadingRegistry:!1});return}e({isLoadingRegistry:!0});try{let i=Pi(),o={...t().registryInfo};for(let e of Ki(r)){let t=await a(Wi(e,n?.force===!0,i),{headers:qi(i)});if(!t.ok)throw Error(`Failed to load plugin registry info`);let r=await Zi(t);for(let e of r.results??[])o[e.spec]=e}e({registryInfo:o,isLoadingRegistry:!1})}catch(t){console.error(`[PluginsStore] Failed to load plugin registry info:`,t),e({isLoadingRegistry:!1})}},updateToLatest:async e=>{let n=t().entries.find(t=>t.id===e);if(!n)return{ok:!1};let r=t().registryInfo[n.spec];return!r||r.kind!==`npm-ok`||!r.hasUpdate||!r.latestVersion?{ok:!1}:await t().updateEntry(e,{spec:`${r.name}@${r.latestVersion}`})},createEntry:async e=>{let n=await Xi(async t=>await a(Ui(`/api/config/plugins/entry`,t),{method:`POST`,headers:Ji(t),body:JSON.stringify(Yi(e))}));return n.ok&&t().loadRegistryInfo({specs:[e.spec],force:!0}),n},updateEntry:async(e,r)=>{let i=(L.getQueryData(gi(Pi(),n()).queryKey)?.entries??t().entries).find(t=>t.id===e),o=i?.spec,s=r.spec??o,c=await Xi(async t=>await a(Ui(`/api/config/plugins/entry/${encodeURIComponent(e)}`,t),{method:`PATCH`,headers:Ji(t),body:JSON.stringify(Yi(r))}),i&&s?{...i,spec:s}:void 0);return c.ok&&s&&t().loadRegistryInfo({specs:[s],force:!0}),c},deleteEntry:async n=>{let r=t().entries.find(e=>e.id===n),i=await Xi(async e=>await a(Ui(`/api/config/plugins/entry/${encodeURIComponent(n)}`,e),{method:`DELETE`,headers:qi(e)}));if(i.ok&&t().selectedId===n&&e({selectedId:null}),i.ok&&r){let n={...t().registryInfo};delete n[r.spec],e({registryInfo:n})}return i},readFile:async e=>{try{let t=Pi(),n=await a(Ui(`/api/config/plugins/file/${encodeURIComponent(e)}`,t),{headers:qi(t)});if(!n.ok)throw Error(`Failed to read plugin file`);return await Zi(n)}catch(e){return console.error(`[PluginsStore] Failed to read plugin file:`,e),null}},createFile:async e=>Xi(async t=>await a(Ui(`/api/config/plugins/file`,t),{method:`POST`,headers:Ji(t),body:JSON.stringify(e)})),updateFile:async(e,t)=>Xi(async n=>await a(Ui(`/api/config/plugins/file/${encodeURIComponent(e)}`,n),{method:`PUT`,headers:Ji(n),body:JSON.stringify(t)})),deleteFile:async n=>{let r=await Xi(async e=>await a(Ui(`/api/config/plugins/file/${encodeURIComponent(n)}`,e),{method:`DELETE`,headers:qi(e)}));return r.ok&&t().selectedId===n&&e({selectedId:null}),r},getById:e=>t().entries.find(t=>t.id===e)??t().files.find(t=>t.id===e)}),{name:`plugins-store`,storage:D(),partialize:e=>({selectedId:e.selectedId})}),{name:`plugins-store`}));function Ui(e,t){return`${e}${t?`?directory=${encodeURIComponent(t)}`:``}`}function Wi(e,t,n){let r=new URLSearchParams;t&&r.set(`refresh`,`true`),n&&r.set(`directory`,n);let i=r.toString();return`/api/config/plugins/registry?${`specs=${e.map(encodeURIComponent).join(`,`)}`}${i?`&${i}`:``}`}function Gi(e){return Array.from(new Set(e.map(e=>e.trim()).filter(Boolean)))}function Ki(e){let t=[],n=[],r=0;for(let i of e){let e=encodeURIComponent(i),a=n.length===0?e.length:r+1+e.length;n.length>0&&a>zi?(t.push(n),n=[i],r=e.length):(n.push(i),r=a)}return n.length>0&&t.push(n),t}function qi(e){return e?{"x-opencode-directory":e}:void 0}function Ji(e){return{"Content-Type":`application/json`,...e?{"x-opencode-directory":e}:{}}}function Yi(e){let t={};return e.spec!==void 0&&(t.spec=e.spec),e.options!==void 0&&(t.options=e.options),e.scope!==void 0&&(t.scope=e.scope),t}async function Xi(e,t){let i=n(),a=r();try{let o=Pi(),s=await e(o),c=await Zi(s).catch(()=>null);if(!s.ok)throw Error(c?.error||`Failed to update plugin configuration`);if(i!==n()||a!==r())return{ok:!0};Vi(o);let l=await Ci(L,o,i);if(o===Pi()&&i===n()&&a===r()){let e=t&&Hi.getState().selectedId===t.id?l.entries.find(e=>e.spec===t.spec&&e.scope===t.scope&&e.sourcePath===t.sourcePath):void 0;Hi.setState({entries:l.entries,files:l.files,...e?{selectedId:e.id}:{}}),Li.set(Bi(o),Date.now())}return{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}}catch(e){return console.error(`[PluginsStore] Failed to update plugin configuration:`,e),{ok:!1}}}async function Zi(e){return await e.json()}var Qi=e=>e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e),$i=e=>{let t=e.replace(/\\/g,`/`),n=[],[r,...i]=t.split(`/`);for(let e of i)if(e!==``&&e!==`.`){if(e===`..`){n.pop();continue}n.push(e)}return`${/^[A-Za-z]:$/.test(r)?`${r.toUpperCase()}/`:`/`}${n.join(`/`)}`},ea=e=>$i(`${e.replace(/\\/g,`/`)}/..`),ta=e=>{try{let t=decodeURIComponent(new URL(e).pathname);return/^\/[A-Za-z]:\//.test(t)?t.slice(1):t}catch{return null}};function na(e,t){if(e.startsWith(`file://`)){let t=ta(e);return t?{kind:`local`,path:$i(t)}:null}return e.startsWith(`./`)||e.startsWith(`../`)?t?{kind:`local`,path:$i(`${ea(t)}/${e}`)}:null:Qi(e)?{kind:`local`,path:$i(e)}:{kind:`package`,target:e}}function ra(e){return e?{kind:`local`,path:$i(e)}:null}var ia=(e,t)=>{if(e.kind===`package`)return t.source.kind===`package`&&t.source.target===e.target;if(t.source.kind!==`local`)return!1;let n=$i(t.source.path);return n===e.path||n.startsWith(`${e.path}/`)};function aa(e,t){return t.filter(t=>ia(e,t))}function oa(e){for(let t of e)if(t.state.kind===`active`&&t.source.kind===`package`&&t.source.version?.trim())return t.source.version.trim();return null}function sa(e){let t=e.find(e=>e.state.kind===`failed`);if(t&&t.state.kind===`failed`)return{kind:`failed`,error:t.state.error,ref:t.state.ref};let n=e[0];return n?{kind:`active`,version:n.source.kind===`package`?n.source.version:null}:{kind:`notReported`}}function ca(e){let t=e.flatMap(e=>e.source.kind===`package`?[e.source]:[]);return t.some(e=>e.updating)?`updating`:t.some(e=>e.outdated)?`available`:`none`}function la(){let e=(0,X.c)(5),t=yi(),n=Si(),r=t.data?.entries,i=t.data?.files,a=n.data,o;bb0:{if(!a){let t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],o=t;break bb0}let t;if(e[1]!==r||e[2]!==i||e[3]!==a){t=[];let n=(e,n,r)=>{if(!r)return;let i=sa(aa(r,a));i.kind===`failed`&&t.push({id:e,label:n,error:i.error})};for(let e of r??[])n(e.id,e.spec,na(e.spec,e.sourcePath));for(let e of i??[])n(e.id,e.fileName,ra(e.absolutePath));e[1]=r,e[2]=i,e[3]=a,e[4]=t}else t=e[4];o=t}return o}var ua=`/mcp/oauth/callback`,da=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}},fa=e=>{let t=ma(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}},pa=e=>{let t=e.get(`state`);return typeof t==`string`&&t.trim()||null},ma=e=>{if(typeof e!=`string`||!e.trim())return null;let t=da(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}},ha=e=>typeof e==`object`&&!!e&&`updateStatus`in e&&typeof e.updateStatus==`function`,ga=e=>{let t=document.createElement(`div`);t.className=`cm-vim-panel`;let n=xn(e);if(!n)return{top:!1,dom:t};n.state.statusbar=t;let r=n.state.vimPlugin;return ha(r)&&r.updateStatus(),{top:!1,dom:t,destroy(){n.state.statusbar===t&&(n.state.statusbar=null)}}};function _a(e){return e?[bn(),ae.of(ga),ce()]:[]}var va={next:`Next match`,prev:`Previous match`,select:`Select all matches`,replace:`Replace`,replaceAll:`Replace all`,close:`Close`},ya={case:`Match case`,re:`Regular expression`,word:`Match whole word`};function ba(e){let t=e.querySelector(`.cm-search`);if(t){for(let[e,n]of Object.entries(va)){let r=t.querySelector(`button[name="${e}"]`);r&&!r.title&&(r.title=n)}for(let[e,n]of Object.entries(ya)){let r=t.querySelector(`input[name="${e}"]`)?.parentElement;r&&!r.title&&(r.title=n)}}}var xa=new WeakMap;function Sa(e,t){let n=gn(e.state);if(!n.valid)return xa.delete(e),0;let r=xa.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 xa.set(e,{query:n,doc:e.state.doc,total:a}),a}function Ca(e){let t=gn(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 wa(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=Sa(t,n),o=a===0?0:Ca(t);i.textContent=a===0?``:`${o}/${a}`}var Ta=new W,Ea=new W,Da=new W,Oa=new W,ka=new W,Aa=new W,ja=new W,Ma=e=>e,Na=fe,Pa=mn,Fa=vn,Ia=class extends me{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(){}},La=(e,t)=>!e||e.length===0?[]:Ce.define({create(n){let r=new ve,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,se.widget({widget:new Ia(e.id,t),block:!0,side:1}))}return r.finish()},update(e,t){return e.map(t.changes)},provide:e=>U.decorations.from(e)}),Ra=e=>{if(!e)return[];let t=Math.max(1,e.start),n=Math.max(t,e.end);return pe.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 ve;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,se.line({class:`yuri-cm-selected-line`}))}return r.finish()}},{decorations:e=>e.decorations})};function za({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=we.create({doc:g.current,extensions:[...e?[U.cspNonce.of(e)]:[],le({fixed:!0}),Ta.of(he(a)),fn(),oe.of(` `),ja.of(_a(p)),ge.of([dn,...un,...pn]),U.updateListener.of(e=>{D(e.view),(e.viewportChanged||e.geometryChanged)&&E(x.current);let t=hn(e.startState),n=hn(e.state);t!==n&&b.current?.(n);let r=!gn(e.startState).eq(gn(e.state));if(n&&(t!==n||r||e.docChanged||e.selectionSet)&&wa(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)}),Ea.of(U.editable.of(!i)),Da.of(n??[]),Oa.of(Ra(o)),ka.of(La(l,C.current)),Aa.of(u?[_n({top:!0}),ge.of(Ma(yn))]:[])]});return h.current=new U({state:t,parent:m.current}),Na(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:[Ta.reconfigure(he(a)),Ea.reconfigure(U.editable.of(!i)),Da.reconfigure(n??[]),Oa.reconfigure(Ra(o)),ka.reconfigure(La(l,C.current)),Aa.reconfigure(u?[_n({top:!0}),ge.of(Ma(yn))]:[])]}),Na(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:ja.reconfigure(_a(p))}))},[p]),Q.useEffect(()=>{let e=h.current;!e||u===!1||(d?(Pa(e),requestAnimationFrame(()=>{ba(e.dom),wa(e.dom,e,!0)})):Fa(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}}),Na(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,Vr.createPortal)(e.content,e.container,e.id))]})}var Ba=ye.define(Me),Va=ke.data.of({commentTokens:{line:`//`,block:{open:`/*`,close:`*/`}}});function Ha(e){let t=e.trim().toLowerCase();switch(t){case`bash`:case`sh`:case`zsh`:case`shell`:case`shellsession`:case`console`:return Ba;case`json`:case`jsonc`:case`json5`:return Oe().language;case`js`:case`javascript`:return Ee().language;case`jsx`:return Ee({jsx:!0}).language;case`ts`:case`typescript`:return Ee({typescript:!0}).language;case`tsx`:return Ee({typescript:!0,jsx:!0}).language;case`html`:return De().language;case`css`:return Te().language;case`py`:case`python`:return je().language;case`md`:case`markdown`:case`mdown`:case`mkd`:return Ae().language;case`heex`:case`eex`:case`leex`:return De().language;default:return Se.matchLanguageName(Sn,t,!0)}}var Ua=e=>e.split(`/`).pop()?.toLowerCase()??``,Wa=e=>{let t=Ua(e);return t?Se.matchFilename(Sn,t):null},Ga=()=>de(_e.define([{tag:[G.heading1,G.heading2,G.heading3,G.heading4,G.heading5,G.heading6],fontWeight:`600`},{tag:G.strong,fontWeight:`600`},{tag:G.emphasis,fontStyle:`italic`},{tag:G.strikethrough,textDecoration:`line-through`},{tag:[G.link,G.url],color:`var(--markdown-link, currentColor)`,textDecoration:`underline`},{tag:G.monospace,color:`var(--markdown-inline-code, currentColor)`,backgroundColor:`var(--markdown-inline-code-bg, transparent)`},{tag:G.quote,color:`var(--markdown-blockquote, currentColor)`,fontStyle:`italic`},{tag:G.list,color:`color-mix(in srgb, var(--muted-foreground) 40%, var(--foreground) 60%)`},{tag:G.heading,color:`var(--markdown-heading1, currentColor)`}]));function Ka(e){let t=e.toLowerCase();switch(Ua(t)){case`makefile`:case`gnumakefile`:return Ba}let n=t.lastIndexOf(`.`),r=n>=0?t.slice(n+1):``;switch(r){case`ts`:case`tsx`:case`mts`:case`cts`:return Ee({typescript:!0,jsx:r===`tsx`});case`js`:case`jsx`:case`mjs`:case`cjs`:return Ee({typescript:!1,jsx:r===`jsx`});case`jsonc`:case`json5`:return[Oe(),Va];case`json`:case`jsonl`:case`ndjson`:case`geojson`:return Oe();case`css`:case`scss`:case`sass`:case`less`:return Te();case`html`:case`htm`:case`xml`:case`drawio`:case`dio`:return De();case`md`:case`mdx`:case`markdown`:case`mdown`:case`mkd`:return[Ae({codeLanguages:Ha}),Ga()];case`sh`:case`bash`:case`zsh`:case`fish`:case`env`:return Ba;case`py`:case`pyw`:case`pyi`:return je();default:return null}}async function qa(e){let t=Wa(e);if(!t)return null;if(t.support)return t.support;try{return await t.load()}catch{return null}}function Ja(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=U.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=_e.define([{tag:[G.comment,G.docComment,G.meta,G.documentMeta],class:`cm-comment`},{tag:[G.keyword,G.controlKeyword,G.moduleKeyword,G.definitionKeyword,G.modifier],class:`cm-keyword`},{tag:[G.operatorKeyword,G.operator,G.derefOperator,G.updateOperator,G.definitionOperator,G.typeOperator,G.controlOperator,G.logicOperator,G.bitwiseOperator,G.arithmeticOperator,G.compareOperator],class:`cm-operator`},{tag:[G.punctuation,G.separator,G.bracket,G.paren,G.brace,G.squareBracket,G.angleBracket],class:`cm-punctuation`},{tag:[G.string,G.regexp,G.attributeValue,G.special(G.string),G.monospace],class:`cm-string`},{tag:G.escape,class:`cm-string-2`},{tag:[G.number,G.bool,G.atom,G.null,G.self],class:`cm-number`},{tag:[G.function(G.variableName),G.function(G.definition(G.variableName)),G.function(G.propertyName),G.standard(G.variableName),G.special(G.variableName)],class:`cm-builtin`},{tag:G.definition(G.variableName),class:`cm-def`},{tag:[G.variableName,G.local(G.variableName),G.constant(G.variableName),G.literal],class:`cm-variable`},{tag:G.propertyName,class:`cm-property`},{tag:G.attributeName,class:`cm-attribute`},{tag:[G.className,G.typeName,G.namespace],class:`cm-variable-3`},{tag:[G.tagName,G.labelName,G.annotation,G.macroName],class:`cm-tag`},{tag:G.link,class:`cm-link`},{tag:[G.heading,G.heading1,G.heading2,G.heading3,G.heading4,G.heading5,G.heading6],class:`cm-keyword`}]),l=_e.define([{tag:[G.comment,G.docComment,G.meta,G.documentMeta],color:e.colors.syntax.base.comment},{tag:[G.keyword,G.controlKeyword,G.moduleKeyword,G.definitionKeyword,G.modifier],color:e.colors.syntax.base.keyword},{tag:[G.operatorKeyword,G.operator,G.derefOperator,G.updateOperator,G.definitionOperator,G.typeOperator,G.controlOperator,G.logicOperator,G.bitwiseOperator,G.arithmeticOperator,G.compareOperator],color:e.colors.syntax.base.operator},{tag:[G.string,G.regexp,G.attributeValue,G.special(G.string),G.monospace],color:e.colors.syntax.base.string},{tag:G.escape,color:a.stringEscape||e.colors.syntax.base.string},{tag:[G.number,G.bool,G.atom,G.null,G.self],color:e.colors.syntax.base.number},{tag:[G.function(G.variableName),G.function(G.definition(G.variableName)),G.function(G.propertyName),G.standard(G.variableName),G.special(G.variableName)],color:e.colors.syntax.base.function},{tag:G.definition(G.variableName),color:a.variableGlobal||e.colors.syntax.base.variable},{tag:[G.variableName,G.local(G.variableName),G.constant(G.variableName),G.literal],color:e.colors.syntax.base.variable},{tag:G.propertyName,color:a.variableProperty||e.colors.syntax.base.variable},{tag:G.attributeName,color:a.variableOther||e.colors.syntax.base.variable},{tag:[G.className,G.typeName,G.namespace],color:e.colors.syntax.base.type},{tag:[G.tagName,G.labelName,G.annotation,G.macroName],color:a.tag||e.colors.syntax.base.keyword},{tag:G.link,color:a.url||e.colors.syntax.base.function,textDecoration:`underline`},{tag:[G.punctuation,G.separator,G.bracket,G.paren,G.brace,G.squareBracket,G.angleBracket],color:a.punctuation||e.colors.syntax.base.comment}]);return t?.syntaxColors===!1?[s]:[s,de(xe,{fallback:!0}),de(ue),de(c),de(l)]}var Ya=180,Xa=be.define(),Za=1,Qa=2,$a=4,eo=new Map,to=(e,t)=>{let n=`${e}|${t}`,r=eo.get(n);if(r)return r;let i=``;e&&(i+=`color:${e};`),t&Za&&(i+=`font-style:italic;`),t&Qa&&(i+=`font-weight:bold;`),t&$a&&(i+=`text-decoration:underline;`);let a=se.mark({attributes:{style:i}});return eo.set(n,a),a},no=(e,t)=>{let n=new ve,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,to(t,r)))}}return n.finish()},ro=Ce.define({create(){return se.none},update(e,t){let n=e.map(t.changes);for(let e of t.effects)e.is(Xa)&&(n=e.value);return n},provide:e=>U.decorations.from(e)}),io=e=>pe.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)},Ya)}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 nn(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:Xa.of(no(t,a))}))}destroy(){this.timer&&clearTimeout(this.timer),this.abortController?.abort(),this.abortController=void 0}}),ao=e=>[ro,io(e)],oo=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)(Tt,{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)(Et,{sideOffset:8,children:o}),t[6]=o,t[7]=l);let u;return t[8]!==c||t[9]!==l?(u=(0,Z.jsxs)(Dt,{children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10],u},so=_()(y(v((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 st(),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 ct();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 ft()}),!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=g()?.settings;if(e)try{n=t(((await e.load())?.settings||{}).defaultGitIdentityId)}catch{}}if(n===null)try{let e=await a(`/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 j({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 dt(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 ot(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 lt(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:D(),partialize:e=>({selectedProfileId:e.selectedProfileId})}),{name:`git-identities-store`}));typeof window<`u`&&(window.__zustand_git_identities_store__=so);var co=`w-full max-w-[30rem]`,lo=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)(Ur,{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],_},uo=450,fo=({projectRef:e=null})=>{let{t}=Ie(),{isMobile:n,isTablet:r}=Xt(),i=n||r,a=We(e=>e.getActiveProject()),o=e?.path??a?.path??null,s=Ue(e=>e.getWorktreeMetadata),c=$e(),l=E(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]),D=Q.useCallback(async()=>{if(!(!T||v===!1))try{let e=await _t(T);x(e)}catch{}},[T,v]);Q.useEffect(()=>{if(!o)return;let e=!1;return y(null),(async()=>{try{let t=await ut(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 _t(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([He(T),Ke(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 O=Q.useCallback(async e=>{if(!T)return!1;let n=e.filter(e=>e.trim().length>0);try{return await Ge(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]),k=Q.useMemo(()=>g!==null&&g!==JSON.stringify(u),[g,u]);Q.useEffect(()=>{if(!k||m||w.current)return;let e=window.setTimeout(()=>{w.current||(w.current=!0,(async()=>{try{await O(u)}finally{w.current=!1}})())},uo);return()=>{window.clearTimeout(e)}},[k,m,O,u]);let A=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(()=>{!k||w.current||(w.current=!0,(async()=>{try{await O(u)}finally{w.current=!1}})())},[k,O,u]),P=Q.useCallback(e=>{p(e),T&&Ze(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=[...Be.getState().activeSessions,...Be.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));Re.requestDelete({sessions:d,mode:`worktree`,worktree:e})},[c,s]),I=Q.useMemo(()=>c.map(e=>e.id).join(`,`),[c]);Q.useEffect(()=>{v&&o&&D()},[I,v,o,D]);let L=(0,Z.jsxs)(Dt,{children:[(0,Z.jsx)(Tt,{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)(Et,{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)(Dt,{children:[(0,Z.jsx)(Tt,{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)(Et,{sideOffset:8,className:`max-w-xs`,children:t(`settings.yuri.worktrees.list.tooltip`)})]});return o?v===!1?(0,Z.jsx)(lo,{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)(lo,{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`,co),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)(wt,{value:e,onChange:e=>A(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)(pt,{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)(lo,{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`,co),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:Pe(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)(lo,{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`)})})},po=(e,t)=>t.updatedAtMs-e.updatedAtMs,mo=_((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(),It()]),i={};for(let e of r.sort(po))i[e.id]=e;t().listenerReady||await Kt(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 Gt(),isImportsLoading:!1})}catch(t){e({isImportsLoading:!1,error:t instanceof Error?t.message:String(t)})}}},refreshStatuses:async()=>{try{let t=await It(),n={};for(let e of t.sort(po))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 Bt({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=zt(e,n);r&&r.trim()&&(i.nickname=r.trim()),await t().upsertInstance(i)},removeInstance:async n=>{await Nt(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 At(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 Nt(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})})),ho=450,go=()=>k(),_o=()=>({id:go(),name:``,command:``,icon:`play`}),vo=({projectRef:e})=>{let{t}=Ie(),n=Q.useMemo(()=>h(),[]),r=mo(e=>e.instances),i=mo(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),m=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 Je(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?Cn(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 Ye(e,{actions:n,primaryActionId:null})?(u(JSON.stringify({actions:n})),typeof window<`u`&&window.dispatchEvent(new CustomEvent(En,{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}})())},ho);return()=>{window.clearTimeout(e)}},[a,v,s,y,_]),Q.useEffect(()=>{if(!v||!_||s){_||(m.current=null);return}let e=window.setTimeout(()=>{m.current!==_&&(m.current=_,J.error(_))},1e3);return()=>{window.clearTimeout(e)}},[v,s,_]);let b=Q.useCallback(()=>{let e=_o();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)(lo,{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`,co),children:a.map(e=>{let r=e.icon||`play`,i=Tn[r]||`play`,a=d[e.id]??!1,o=e.name.trim()||t(`settings.projects.actions.state.untitled`);return(0,Z.jsxs)(ln,{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)(cn,{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)(sn,{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)(qt,{children:[(0,Z.jsx)(Jt,{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)(Ht,{align:`start`,className:`w-56 p-2`,children:(0,Z.jsx)(`div`,{className:`grid grid-cols-6 gap-1`,children:wn.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)(wt,{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)(en,{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)(pt,{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)(wt,{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)(Dt,{children:[(0,Z.jsx)(Tt,{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)(Et,{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)(yt,{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)(gt,{className:`h-7 w-full`,children:(0,Z.jsx)(Ct,{placeholder:t(`settings.projects.actions.field.useOutputManualUrl`)})}),(0,Z.jsxs)(vt,{children:[(0,Z.jsx)(mt,{value:`__none__`,children:t(`settings.projects.actions.field.useOutputManualUrl`)}),g.map(e=>(0,Z.jsx)(mt,{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]})},yo=e=>{let t=(0,X.c)(123),{form:n}=e,{t:r}=Ie(),{currentTheme:i}=et(),{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?bt[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)(wt,{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)(Wr,{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 B;t[15]===r?B=t[16]:(B=r(`settings.projects.page.field.defaultModelDescription`),t[15]=r,t[16]=B);let ee;t[17]!==m||t[18]!==p.modelId||t[19]!==p.providerId?(ee=(0,Z.jsx)(jt,{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]=ee):ee=t[20];let te;t[21]!==z||t[22]!==B||t[23]!==ee?(te=(0,Z.jsx)(Wr,{label:z,description:B,descriptionPlacement:`outside`,itemId:`projects.default-model`,children:ee}),t[21]=z,t[22]=B,t[23]=ee,t[24]=te):te=t[24];let V;t[25]===r?V=t[26]:(V=r(`settings.projects.page.field.accentColor`),t[25]=r,t[26]=V);let ne;t[27]===u?ne=t[28]:(ne=()=>u(null),t[27]=u,t[28]=ne);let re=l===null?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-border/40 hover:border-border hover:bg-[var(--surface-muted)]`,H;t[29]===re?H=t[30]:(H=K(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,re),t[29]=re,t[30]=H);let ie;t[31]===r?ie=t[32]:(ie=r(`settings.projects.page.field.none`),t[31]=r,t[32]=ie);let ae;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,Z.jsx)(Y,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[33]=ae):ae=t[33];let oe;t[34]!==ne||t[35]!==H||t[36]!==ie?(oe=(0,Z.jsx)(`button`,{type:`button`,onClick:ne,className:H,title:ie,children:ae}),t[34]=ne,t[35]=H,t[36]=ie,t[37]=oe):oe=t[37];let se;t[38]!==l||t[39]!==u?(se=St.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]=se):se=t[40];let ce;t[41]!==oe||t[42]!==se?(ce=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[oe,se]}),t[41]=oe,t[42]=se,t[43]=ce):ce=t[43];let U;t[44]!==V||t[45]!==ce?(U=(0,Z.jsx)(Wr,{label:V,itemId:`projects.accent-color`,children:ce}),t[44]=V,t[45]=ce,t[46]=U):U=t[46];let le;t[47]===r?le=t[48]:(le=r(`settings.projects.page.field.projectIcon`),t[47]=r,t[48]=le);let ue;t[49]===O?ue=t[50]:(ue=e=>{let t=e.target.files?.[0]??null;O(t),e.currentTarget.value=``},t[49]=O,t[50]=ue);let de;t[51]!==D||t[52]!==ue?(de=(0,Z.jsx)(`input`,{ref:D,type:`file`,accept:`image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg`,className:`hidden`,onChange:ue}),t[51]=D,t[52]=ue,t[53]=de):de=t[53];let fe;t[54]===c?fe=t[55]:(fe=()=>c(null),t[54]=c,t[55]=fe);let pe=s===null?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-border/40 hover:border-border hover:bg-[var(--surface-muted)]`,me;t[56]===pe?me=t[57]:(me=K(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,pe),t[56]=pe,t[57]=me);let he;t[58]===r?he=t[59]:(he=r(`settings.projects.page.field.none`),t[58]=r,t[59]=he);let ge;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,Z.jsx)(Y,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[60]=ge):ge=t[60];let _e;t[61]!==fe||t[62]!==me||t[63]!==he?(_e=(0,Z.jsx)(`button`,{type:`button`,onClick:fe,className:me,title:he,children:ge}),t[61]=fe,t[62]=me,t[63]=he,t[64]=_e):_e=t[64];let W;t[65]!==N||t[66]!==s||t[67]!==c?(W=xt.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]=W):W=t[68];let ve;t[69]!==_e||t[70]!==W?(ve=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[_e,W]}),t[69]=_e,t[70]=W,t[71]=ve):ve=t[71];let ye;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?(ye=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)(ht,{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]=ye):ye=t[82];let be;t[83]!==w||t[84]!==d||t[85]!==f||t[86]!==r?(be=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)(wt,{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]=be):be=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 G;t[109]!==de||t[110]!==ve||t[111]!==ye||t[112]!==be||t[113]!==we?(G=(0,Z.jsxs)(`div`,{className:`flex w-full flex-col items-end gap-2`,children:[de,ve,ye,be,we]}),t[109]=de,t[110]=ve,t[111]=ye,t[112]=be,t[113]=we,t[114]=G):G=t[114];let Te;t[115]!==le||t[116]!==G?(Te=(0,Z.jsx)(Wr,{label:le,itemId:`projects.icon`,children:G}),t[115]=le,t[116]=G,t[117]=Te):Te=t[117];let Ee;return t[118]!==U||t[119]!==Te||t[120]!==R||t[121]!==te?(Ee=(0,Z.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[R,te,U,Te]}),t[118]=U,t[119]=Te,t[120]=R,t[121]=te,t[122]=Ee):Ee=t[122],Ee},bo=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,xo=e=>{if(!e)return null;let t=e.trim();return t&&bo.test(t)?t.toLowerCase():null},So=e=>{let{t}=Ie(),n=We(e=>e.uploadProjectIcon),r=We(e=>e.removeProjectIcon),i=We(e=>e.discoverProjectIcon),a=We(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(()=>Xe(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),B=!O&&(F||z),ee=!!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),te=Q.useCallback((e,t)=>{h(e&&t?`${e}/${t}`:void 0)},[]),V=Q.useCallback(t=>{!e||!t||g||(C(!1),k(!1),T(t),D(e=>(e&&URL.revokeObjectURL(e),URL.createObjectURL(t))))},[g,e]),ne=Q.useCallback(()=>{!e||!R||v||(F&&j(),C(!!P),k(!1))},[j,F,R,P,v,e]),re=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]),H=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:xo(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:te,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:B,fileInputRef:A,clearPendingUploadIcon:j,handleUploadIcon:V,handleRemoveImageIcon:ne,handleDiscoverIcon:re,hasChanges:ee,prepareSaveData:H,currentIconImage:a,project:e}},Co=450,wo=(e,t)=>{let{t:n}=Ie(),{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}})())},Co);return()=>{window.clearTimeout(e)}},[o,c,r,a,s,f,d,i,t,l,u,p,n])},To=e=>{let t=(0,X.c)(25),{project:n,onIdentitySave:r}=e,{t:i}=Ie(),a=So(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),wo(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)(yo,{form:a}),t[15]=a,t[16]=m);let h,g;t[17]===s?(h=t[18],g=t[19]):(h=(0,Z.jsx)(vo,{projectRef:s}),g=(0,Z.jsx)(fo,{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 Eo(e,t,n){return Math.min(n,Math.max(t,e))}function Do(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 Oo(e,t){let n=Do(t);return n<=0?e:Number(e.toFixed(n))}var ko=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}=Ie(),[h,g]=Q.useState(()=>e===void 0?``:String(e)),{isMobile:_}=Xt(),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=Oo(Eo(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=Oo(Eo(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`})})]})});ko.displayName=`NumberInput`;function Ao(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 jo={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 Mo(e,t){let n=jo[t]??[];for(let t of n)if(t.matcher(e))return t;return null}function No(e){return jo[e]??[]}function Po(e){return[...e].sort((e,t)=>e.order-t.order)}function Fo(e,t){let n=new Map;for(let r of Object.keys(e)){let e=Mo(r,t)?.id??null;n.has(e)||n.set(e,[]),n.get(e).push(r)}return n}function Io(e,t,n){let r=new Map;for(let i of e){let e=Mo(t(i),n)?.id??null;r.has(e)||r.set(e,[]),r.get(e).push(i)}return r}function Lo(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 Ro=(e,t=``,n=!1)=>F({queryKey:z.scoped(`magpie-quotas`,e,t,n),staleTime:0,retry:!1,queryFn:async({signal:t})=>{let r=await a(`/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=>B(t)&&t.source===`magpie`&&t.sourceId===e.id&&t.providerId.startsWith(`magpie:${e.id}:`))))throw Error(`Invalid Magpie quota response`);return i}}),zo=6e4,Bo=0,Vo=0,Ho,Uo=0,Wo=0,Go=0,Ko=new Map,qo=e=>{let t=Dn.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))):zo,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}},Jo=async()=>{let e=g()?.settings;if(e)try{let t=(await e.load())?.settings;return qo(t??null)}catch{}if(!m()){let e=await a(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(e.ok)return qo(await e.json().catch(()=>null))}return{magpieUsageUrl:``,magpieHiddenProviders:[],autoRefresh:!1,refreshIntervalMs:zo,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:Dn.map(e=>e.id),selectedModels:{},expandedFamilies:{}}},Yo=(e,t,n)=>{let r=e.filter(e=>e?.providerId&&e.providerId!==t);return B(n)&&r.push(n),r},Xo=async(e,t)=>{let n=Vo;Ko.set(e,(Ko.get(e)??0)+1),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:!0}}));try{let r=await L.fetchQuery({queryKey:z.quota(e),queryFn:({signal:t})=>ee(e,t),staleTime:0,retry:!1});if(n!==Vo)return{providerId:e,stale:!0};if(!B(r))throw Error(`Invalid quota response`);return t(t=>({results:Yo(t.results,e,r)})),{providerId:e,result:r}}catch(r){return n===Vo?(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===Vo){let n=(Ko.get(e)??1)-1;n>0?Ko.set(e,n):Ko.delete(e),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:n>0}}))}}},Zo=()=>{Ho=void 0,Uo+=1,Vo+=1,Bo+=1,Ko.clear(),Qo.setState({magpieUsageUrl:``,magpieHiddenProviders:[],magpieSources:[],magpieError:null,results:[],isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null})},Qo=_()(y((e,t)=>({magpieSources:[],magpieError:null,magpieHiddenProviders:[],magpieUsageUrl:``,results:[],selectedProviderId:null,isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null,autoRefresh:!1,refreshIntervalMs:zo,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:Dn.map(e=>e.id),selectedModels:{},expandedFamilies:{},loadSettings:async()=>{let t=Vo;try{let n=await Jo();if(t!==Vo)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=++Bo;e({isLoading:!0,error:null});let r=Dn.map(e=>e.id),[i]=await Promise.all([Promise.all(r.map(t=>Xo(t,e))),t().fetchMagpieQuotas(!0)]);if(n===Bo){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 Xo(n,e);`stale`in r||e({error:`error`in r?r.error:null})},fetchMagpieQuotas:async(n=!1)=>{let r=Vo,i=E.getState().currentDirectory,a=t().magpieUsageUrl,o=JSON.stringify([i,a]);Ho!==o&&(Ho=o,Uo+=1,e(e=>({results:e.results.filter(e=>e?.source!==`magpie`),magpieSources:[],magpieError:null})));let s=Uo,c=++Wo;try{let{sources:o,incomplete:l}=await L.fetchQuery(Ro(i,a,n));if(r!==Vo||s!==Uo||c<Go||i!==E.getState().currentDirectory||a!==t().magpieUsageUrl)return;Go=c,e(e=>{let t=new Map(o.filter(e=>e.error&&!e.clearPrevious&&e.results.length===0).map(e=>[e.id,e.error]));if(l){let n=new Set(o.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(...o.flatMap(e=>e.results));let r=n.filter(e=>e.source===`magpie`).map(e=>e.providerId);return{results:n,magpieSources:o,magpieError:null,dropdownProviderIds:[...e.dropdownProviderIds.filter(e=>!e.startsWith(`magpie:`)),...r.filter(t=>!e.magpieHiddenProviders.includes(t))]}})}catch(n){if(r!==Vo||s!==Uo||c<Go||i!==E.getState().currentDirectory||a!==t().magpieUsageUrl)return;Go=c,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}})),j({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}}}),j({usageExpandedFamilies:t().expandedFamilies})},applyDefaultSelections:(n,r)=>{if((t().selectedModels[n]?.length??0)>0)return;let i=Lo(n,r);i.length!==0&&(e(e=>({selectedModels:{...e.selectedModels,[n]:i}})),j({usageSelectedModels:t().selectedModels}))}}),{name:`quota-store`})),$o=()=>{let e=(0,X.c)(11),t=E(es),n=Qo(ts),r=Qo(ns),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=Qo(rs),s=Qo(is),c=Qo(as),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 es(e){return e.currentDirectory}function ts(e){return e.magpieUsageUrl}function ns(e){return e.fetchMagpieQuotas}function rs(e){return e.autoRefresh}function is(e){return e.refreshIntervalMs}function as(e){return e.fetchAllQuotas}var os=e=>{let t=(0,X.c)(20),{percent:n,tonePercent:r,className:i,expectedMarkerPercent:a}=e,o;t[0]===n?o=t[1]:(o=Ut(n)??0,t[0]=n,t[1]=o);let s=o,c=r??n,l;t[2]===c?l=t[3]:(l=Ot(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},ss=e=>{let t=(0,X.c)(67),{paceInfo:n,className:r,compact:i}=e,a=i!==void 0&&i,{t:o}=Ie(),s;t[0]===n.status?s=t[1]:(s=Ft(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:Pt(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:Pt(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},cs=e=>e instanceof Error&&e.name===`CancelledError`,ls=_(()=>({setStatus:e=>kt(L,e),refreshStatus:async(e,t)=>{let r=n();t?.force&&await L.cancelQueries({queryKey:z.github.auth(r),exact:!0});try{return await Rt(L,e,r)}catch(e){if(cs(e))return Lt(L,r);throw e}}})),us={displayMode:`browser`,installed:!1,browserTab:!0},ds=new Set,fs=us,ps=!1,ms,hs=()=>{let e=Vt();return{displayMode:e,installed:e!==`browser`,browserTab:e===`browser`}},gs=()=>(!ps&&typeof window<`u`&&(fs=hs(),ps=!0),fs),_s=()=>{let e=hs();ps=!0,e.displayMode!==fs.displayMode&&(fs=e,ds.forEach(e=>e()))},vs=()=>{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`,_s):typeof t.addListener==`function`&&t.addListener(_s);return window.addEventListener(`appinstalled`,_s),window.addEventListener(`focus`,_s),()=>{for(let t of e)typeof t.removeEventListener==`function`?t.removeEventListener(`change`,_s):typeof t.removeListener==`function`&&t.removeListener(_s);window.removeEventListener(`appinstalled`,_s),window.removeEventListener(`focus`,_s)}},ys=e=>(ds.add(e),ms??=vs(),_s(),()=>{ds.delete(e),ds.size===0&&(ms?.(),ms=void 0)}),bs=()=>Q.useSyncExternalStore(ys,gs,xs);function xs(){return us}var Ss=`Yuri`,Cs=_()(v(e=>({sidebarBrandName:Ss,setSidebarBrandName:t=>{let n=t.slice(0,64);e(e=>e.sidebarBrandName===n?e:{sidebarBrandName:n})}}),{name:`sidebar-brand-store`,storage:A(),version:3,migrate:(e,t)=>{if(!e||typeof e!=`object`)return e;let n={...e};return t<1&&n.sidebarBrandName===`YEE CODE`&&(n.sidebarBrandName=Ss),t<2&&n.sidebarBrandName===`Open Chamber`&&(n.sidebarBrandName=Ss),t<3&&(n.sidebarBrandName===`OPEN CHAMBER`||n.sidebarBrandName===`Open Chamber`)&&(n.sidebarBrandName=Ss),n}}));typeof window<`u`&&t(e=>{i(e)&&Cs.persist.rehydrate()});var ws=(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,Ts=(e,t,n)=>{ws(e.get(t),n)&&e.set(t,n)},Es=e=>{let t=e;return V(t.directory)??V(t.project?.worktree)},Ds=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)},Os=(e,t,n,r,i=[])=>{let a=new Map,o=new Map;for(let e of t){let t=V(e.normalizedPath);if(!t)continue;let n=o.get(t);(!n||e.id.localeCompare(n.id)<0)&&o.set(t,e),Ts(a,t,{projectId:e.id,projectRoot:t,scopeDirectory:t,kind:`project`})}if(!r)for(let[e,t]of n){let n=V(e),r=n?o.get(n):void 0;if(!(!r||!n))for(let e of t){let t=V(e.path);t&&Ts(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=Ds(n)}for(let e of t)s.set(e,i);return i},p=(e,t,n)=>{for(let r of e){let e=f(Es(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}},ks=`__other__`;function As(e){return e.time?.updated??e.time?.archived??e.time?.created??0}function js({mode:e=`dialog`}){let{t}=Ie(),{isMobile:n,isTablet:r,hasTouchInput:i}=Xt(),a=n||r||i,o=e===`page`,s=O(e=>e.isArchivedSessionsDialogOpen),c=O(e=>e.setArchivedSessionsDialogOpen),l=o||s,u=We(e=>e.projects),d=Be(e=>e.archivedSessions),f=Ue(e=>e.setCurrentSession),p=O(e=>e.setSettingsDialogOpen),[h,g]=Q.useState(!1),[_,v]=Q.useState(null),[y,b]=Q.useState(null);Q.useEffect(()=>{if(!l){v(null),b(null);return}let e=!1;return g(!0),ze().catch(()=>{e||J.error(t(`settings.yuri.archivedSessions.toast.loadFailed`))}).finally(()=>{e||g(!1)}),()=>{e=!0}},[l,t]);let x=Q.useMemo(()=>{let e=Os([],u.map(e=>({id:e.id,normalizedPath:e.path})),new Map,m(),d),n=new Map;for(let[t,r]of e.archivedSessionsByProject)n.set(t,[...r].sort((e,t)=>As(t)-As(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)=>As(t)-As(e));i.length>0&&n.set(ks,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(ks);return o&&o.length>0&&a.push({projectId:ks,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=_?x.find(e=>e.projectId===_)??null:null,w=Q.useCallback(async e=>{b(e.id);try{await Qe(e.id)?J.success(t(`settings.yuri.archivedSessions.toast.restored`)):J.error(t(`settings.yuri.archivedSessions.toast.restoreFailed`))}finally{b(null)}},[t]),T=Q.useCallback(e=>{let t=Ve(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`),k=(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:()=>v(null),children:[(0,Z.jsx)(Y,{name:`arrow-left-s`,className:`mr-1 h-4 w-4`}),t(`settings.yuri.archivedSessions.dialog.backToProjects`)]}):null,h?(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=Ve(e),r=As(e),i=y===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?Yt(r):null,r>0&&n?` · `:null,n?Pe(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:()=>v(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:Pe(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&&!h&&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`)}),k]}):a?(0,Z.jsx)(Wt,{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:k}):(0,Z.jsx)(at,{open:s,onOpenChange:c,children:(0,Z.jsxs)(nt,{className:`max-h-[85vh] max-w-2xl overflow-y-auto`,children:[(0,Z.jsxs)(tt,{children:[(0,Z.jsx)(rt,{children:E}),(0,Z.jsx)(it,{children:D})]}),k]})})}function Ms(){let e=(0,X.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(js,{mode:`dialog`}),e[0]=t):t=e[0],t}var Ns=48;function Ps({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=Ne(()=>{s.current=null;let e=i.current,t=a.current;if(!e||!t)return;let n=Math.min(1,Math.max(0,t.scrollTop/Ns)),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=Ne(()=>{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{Gr as $,pa as A,gi as B,ao as C,za as D,qa as E,oa as F,Si as G,Ti as H,sa as I,oi as J,yi as K,ca as L,na as M,aa as N,ua as O,ra as P,Ur as Q,Hi as R,oo as S,Ka as T,xi as U,wi as V,bi as W,Zr as X,Xr as Y,Wr as Z,Po as _,Cs as a,An as at,mo as b,ss as c,On as ct,$o as d,Kr as et,Qo as f,Io as g,Fo as h,Os as i,Bn as it,la as j,fa as k,os as l,Ao as m,Ms as n,Rr as nt,bs as o,kn as ot,No as p,si as q,js as r,pr as rt,ls as s,Dn as st,Ps as t,Hr as tt,Zo as u,ko as v,Ja as w,so as x,To as y,Ei as z};
|