@yuriai/web 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentSelector-DpOQ7dyw.js → AgentSelector-uBoLtut8.js} +1 -1
- package/dist/assets/{ArchivedSessionsDialog-nqnWb-Vc.js → ArchivedSessionsDialog-DZcicxVO.js} +1 -1
- package/dist/assets/{AssistantConversationSurface-CKXgty02.js → AssistantConversationSurface-36aP0hRf.js} +3 -3
- package/dist/assets/{AssistantSessionCard-C2-2fJul.js → AssistantSessionCard-CZ-1oJiE.js} +2 -2
- package/dist/assets/{AssistantView-BR8hsjOv.js → AssistantView-8fyAae7J.js} +1 -1
- package/dist/assets/{AssistantsSettingsPage-Bwid1xE0.js → AssistantsSettingsPage-DD6spbXz.js} +1 -1
- package/dist/assets/{BinaryFileFallback-Cb3uP7y1.js → BinaryFileFallback-DgYaMG9f.js} +1 -1
- package/dist/assets/{BtwPanel-9VAdk_qa.js → BtwPanel-BkobGcf3.js} +1 -1
- package/dist/assets/{BusyDots-DeDkh4Ke.js → BusyDots-COTTwItx.js} +1 -1
- package/dist/assets/{ChatContainer-wP6o_O4K.js → ChatContainer-BfQ7RXwY.js} +8 -8
- package/dist/assets/{ChatView-DU_2-cfD.js → ChatView-ByMRjY1h.js} +1 -1
- package/dist/assets/{DiagramView-CaefmjA4.js → DiagramView-DGnmjS2b.js} +1 -1
- package/dist/assets/{DiffView-BaqthIvq.js → DiffView-Bbit6OZ8.js} +1 -1
- package/dist/assets/{ErrorBoundary-_5B1xjgZ.js → ErrorBoundary-D7QcwhmL.js} +1 -1
- package/dist/assets/{FadeInOnReveal-BYHr1gqj.js → FadeInOnReveal-B3uT04YJ.js} +1 -1
- package/dist/assets/{GuiPluginMount-Btp3mJT2.js → GuiPluginMount-TC5FELtQ.js} +1 -1
- package/dist/assets/{GuiPluginPage-DM_RLx6u.js → GuiPluginPage-BPjU8N49.js} +1 -1
- package/dist/assets/{GuiPluginSurface-KiyqqEKU.js → GuiPluginSurface-CYPH6XzX.js} +1 -1
- package/dist/assets/{MarkdownRenderer-D7p9Iflj.js → MarkdownRenderer-VvziwyJB.js} +2 -2
- package/dist/assets/{MarkdownRendererImpl-BZc_jUrV.js → MarkdownRendererImpl-D8q0FMnr.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-BUk_c3g1.js → MarkstreamRendererImpl-U_m_ZKG7.js} +1 -1
- package/dist/assets/{MobileAssistantSettingsPage-BBIiFN2g.js → MobileAssistantSettingsPage-Dgq5FMho.js} +1 -1
- package/dist/assets/{MobileBtwPage-DVZm5hrZ.js → MobileBtwPage-DQUkSO6N.js} +1 -1
- package/dist/assets/{MobileChangesSurface-CiqsGZsg.js → MobileChangesSurface-DsYNmAuM.js} +1 -1
- package/dist/assets/{MobileChatScreen-DDenVTX8.js → MobileChatScreen-p356_BCN.js} +1 -1
- package/dist/assets/{MobileFilesSurface-DIVH9aPV.js → MobileFilesSurface-CF3EW_SK.js} +2 -2
- package/dist/assets/{MobileHtmlNetworkBoundary-TBxrF4jJ.js → MobileHtmlNetworkBoundary-DlPF4iPS.js} +2 -2
- package/dist/assets/{MobileSettingsTab-MmDnxG47.js → MobileSettingsTab-DaTtRHo1.js} +1 -1
- package/dist/assets/{MobileShareBridge-DAlGSXoj.js → MobileShareBridge-CZpFYmiy.js} +1 -1
- package/dist/assets/{ModelSelector-HJmXcB3j.js → ModelSelector-EmtltPnd.js} +1 -1
- package/dist/assets/{MultiRunWindow-BmxVnblA.js → MultiRunWindow-CeSxAB8w.js} +1 -1
- package/dist/assets/{OnboardingScreen-DnEtIaxG.js → OnboardingScreen-BubjTNcy.js} +1 -1
- package/dist/assets/{PierreDiffViewer-B1e1H6br.js → PierreDiffViewer-DVKsdwJR.js} +1 -1
- package/dist/assets/{RemoteAssistantSessionCard-BgL7oxAK.js → RemoteAssistantSessionCard-DAoFvZht.js} +1 -1
- package/dist/assets/{RemoteDesktopPanel-DBrEQwpr.js → RemoteDesktopPanel-f3vRj4ZP.js} +1 -1
- package/dist/assets/{ScheduledTasksDialog-BVh0yaZR.js → ScheduledTasksDialog-D_hBP47Y.js} +1 -1
- package/dist/assets/{SettingsView-CLE6ra3s.js → SettingsView-DEU94-h1.js} +1 -1
- package/dist/assets/{SettingsWindow-DpzeOekS.js → SettingsWindow-DMVAV_el.js} +1 -1
- package/dist/assets/{SetupTourDialog-CY_CU5qU.js → SetupTourDialog-BlR7FJvd.js} +1 -1
- package/dist/assets/{TerminalView-mO5f0Axl.js → TerminalView-Xcwp3SG1.js} +1 -1
- package/dist/assets/{TextSelectionMenu-VsKriqtT.js → TextSelectionMenu-h8iUeNzE.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DqCCsC-N.js → ToolOutputDialog-DpaaQ1uZ.js} +1 -1
- package/dist/assets/{auto-read-context-DVGIDEr6.js → auto-read-context-ClBUErN2.js} +1 -1
- package/dist/assets/{capgoAdapter-94K243Zv.js → capgoAdapter-pfQJmvW2.js} +1 -1
- package/dist/assets/{chatUpwardIntent-tvLWGs9Q.js → chatUpwardIntent-B2NrGMm-.js} +1 -1
- package/dist/assets/{gitApi-BWsBS_2N.js → gitApi-CoVwjIDy.js} +1 -1
- package/dist/assets/{insertionBoundaries-BSDUOMHN.js → insertionBoundaries-Btqgsu1M.js} +1 -1
- package/dist/assets/{main-DAbyAg5_.js → main-CXH2hObl.js} +4 -4
- package/dist/assets/{main-CHO9s_kb.js → main-ClH7cLKr.js} +2 -2
- package/dist/assets/{mcpQueries-1WNtiFYh.js → mcpQueries-Rmp1BKeo.js} +1 -1
- package/dist/assets/{miniChat-BZMkNMht.js → miniChat-B_Bw6udu.js} +2 -2
- package/dist/assets/{mobile-C9XDDOHq.js → mobile-BR73yoNi.js} +2 -2
- package/dist/assets/{mobileBackNavigation-DF_uhF-i.js → mobileBackNavigation-C94n2eLT.js} +1 -1
- package/dist/assets/{mobileConnections-DjT1L-_m.js → mobileConnections-x07fHO_5.js} +2 -2
- package/dist/assets/{multirun-D34EMeEj.js → multirun-CKQymP08.js} +1 -1
- package/dist/assets/{native-config-DSpTDz3F.js → native-config-DVg8_Zx1.js} +1 -1
- package/dist/assets/{nativeComposerCover-DXFy97OQ.js → nativeComposerCover-Bhv1EKPT.js} +1 -1
- package/dist/assets/{navigation-jU0HUH9s.js → navigation-D1klsD7k.js} +1 -1
- package/dist/assets/{openRemoteProjectSession-Bm_nafYw.js → openRemoteProjectSession-DNr74gHD.js} +1 -1
- package/dist/assets/{pluginPresentation-DexqrdQ0.js → pluginPresentation-DtyC8NF2.js} +1 -1
- package/dist/assets/{pwa-BaWpUiOR.js → pwa-CtDladgB.js} +1 -1
- package/dist/assets/{queue-abort-optimistic-UwpgXn4g.js → queue-abort-optimistic-DFbWDRKT.js} +1 -1
- package/dist/assets/{reference-history-DBxnA_fF.js → reference-history-IEuzG8KC.js} +1 -1
- package/dist/assets/{remoteSessionReference-Cug8RfIG.js → remoteSessionReference-ex07CtrZ.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-CqrlQAsJ.js → renderElectronMiniChatApp-DM9y9qXo.js} +2 -2
- package/dist/assets/{renderMobileApp-CwcwGOox.js → renderMobileApp-DqpPYtZI.js} +4 -4
- package/dist/assets/{runtimeConfig-zzeYHX6k.js → runtimeConfig-CyvlrO58.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-DUD-TCLY.js → runtimeEndpointReset-C0zNrsI9.js} +3 -3
- package/dist/assets/{sessionLookup-4zOaVAuF.js → sessionLookup-DQOiycHr.js} +1 -1
- package/dist/assets/{sessionOwnership-CEkPFbS4.js → sessionOwnership-BjhXe6pi.js} +1 -1
- package/dist/assets/{speechSettingsQueries-DQnPLEf3.js → speechSettingsQueries-BmkXNn4w.js} +1 -1
- package/dist/assets/{types-s_oc_LRs.js → types-DpcA-uDW.js} +1 -1
- package/dist/assets/{ui-DrAJTWV6.js → ui-ee2iN869.js} +12 -12
- package/dist/assets/{useAppFontEffects-nvkTSYHB.js → useAppFontEffects-rbTKcF0f.js} +2 -2
- package/dist/assets/{useDesktopWindowControlsLayout-i6qqpMbd.js → useDesktopWindowControlsLayout-BOkRz-p9.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-BxolHzt4.js → useEffectiveDirectory-DiJBIfai.js} +1 -1
- package/dist/assets/{useGitStore-B641o_o0.js → useGitStore-Bv8xmXDa.js} +1 -1
- package/dist/assets/{useMcpConfigStore-BUSvv0Bl.js → useMcpConfigStore-DKTl0PvE.js} +1 -1
- package/dist/assets/{useMobileTranscriptSyncHint-86i3xO8J.js → useMobileTranscriptSyncHint-DM8WG7kz.js} +1 -1
- package/dist/assets/{useModelLists-Ca085-di.js → useModelLists-Bf60FIJu.js} +1 -1
- package/dist/assets/{useOpenCodeReadiness-CsNcdsCJ.js → useOpenCodeReadiness-Dm6BjA1T.js} +1 -1
- package/dist/assets/{usePluginsStore-ZHQOW-R5.js → usePluginsStore-Du4WlceO.js} +1 -1
- package/dist/assets/{useProjectGitActions-1QRsD7Rb.js → useProjectGitActions-D3B9ma9z.js} +1 -1
- package/dist/assets/{useProjectGitStore-C1K6WpCe.js → useProjectGitStore-DzU2pvrH.js} +1 -1
- package/dist/assets/{useProjectRuntimeAPIs-BItoD9Bt.js → useProjectRuntimeAPIs-tjGuODhu.js} +1 -1
- package/dist/assets/{useSessionBtwStore-BCHq3UOB.js → useSessionBtwStore-CwvlMabN.js} +1 -1
- package/dist/assets/{useStreamingTextThrottle-DGAjmaMZ.js → useStreamingTextThrottle-C9SaKeil.js} +1 -1
- package/dist/assets/{worktreeManager-QmahFqHc.js → worktreeManager-DGu8M01Z.js} +1 -1
- package/dist/assets/{worktreeSourceBranchPreference-B5Fldnhm.js → worktreeSourceBranchPreference-CuLKwxkx.js} +1 -1
- package/dist/index.html +5 -5
- package/dist/mini-chat.html +5 -5
- package/dist/mobile.html +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./client-B_907PBv.js";import{Oi as t,Pi as n,Ti as r}from"./ui-
|
|
1
|
+
import{n as e}from"./client-B_907PBv.js";import{Oi as t,Pi as n,Ti as r}from"./ui-ee2iN869.js";var i=e=>{if(typeof e!=`number`||!Number.isFinite(e))return;let t=Math.trunc(e);return t>=0?t:void 0},a=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e.summary;return!t||typeof t!=`object`||Array.isArray(t)?null:t},o=e=>{let t=i(e);return t!==void 0&&t>0?t:void 0};function s(e){let t=a(e);if(!t)return null;let n=o(t.additions),r=o(t.deletions),i=o(t.files)??o(t.diffCount);return n===void 0&&r===void 0&&i===void 0?null:{...n===void 0?{}:{additions:n},...r===void 0?{}:{deletions:r},...i===void 0?{}:{files:i}}}function c(e){if(!e)return null;let t=[];return e.additions!==void 0&&e.additions>0&&t.push(`+${e.additions}`),e.deletions!==void 0&&e.deletions>0&&t.push(`−${e.deletions}`),t.length>0?t.join(` `):null}function l(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=typeof t.providerID==`string`?t.providerID.trim():``,r=typeof t.modelID==`string`?t.modelID.trim():``;if(n&&r)return`${n}/${r}`;let i=t.model;if(typeof i==`string`&&i.trim())return i.trim();if(i&&typeof i==`object`&&!Array.isArray(i)){let e=i,t=typeof e.providerID==`string`?e.providerID.trim():typeof e.provider==`string`?e.provider.trim():``,n=typeof e.modelID==`string`?e.modelID.trim():typeof e.id==`string`?e.id.trim():``;if(t&&n)return`${t}/${n}`}return null}function u(e){if(!e||e.trim().length===0)return null;let n=t.getState(),i=n.activeSessions.find(t=>t.id===e)??n.archivedSessions.find(t=>t.id===e)??null;if(!i)return null;let a=r(i);return a?{sessionId:e,directory:a,session:i,fromCache:!n.hasLoaded,source:`memory`}:null}function d(e){return u(e)?.directory??null}var f=new Map;async function p(t,r){let i=t.trim();if(!i)return null;let a=u(i);if(a)return a;let o=f.get(i);if(o)return o;let s=(async()=>{let t=u(i);if(t)return t;let a=await n(i,{signal:r?.signal});if(a?.directory)return{sessionId:a.id,directory:a.directory,session:null,fromCache:!1,source:`session-index`};if(r?.trySessionGet===!1)return null;try{let t=await e.getSession(i),n=typeof t.directory==`string`&&t.directory.trim()||(typeof t.project?.worktree==`string`?t.project.worktree.trim():``)||null;return n?{sessionId:i,directory:n,session:t,fromCache:!1,source:`session-get`}:null}catch{return null}})().finally(()=>{f.get(i)===s&&f.delete(i)});return f.set(i,s),s}export{s as a,c as i,d as n,l as o,p as r,u as t};
|
|
@@ -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}from"./runtime-switch-DEPKHgdL.js";import{n as i}from"./runtime-fetch-V-iMWR8t.js";import{B as a,I as o,P as s,R as c,V as l,Z as u,_ as d,f,h as p,n as m,t as h,z as g}from"./platform-CiUKDeXd.js";import{t as _}from"./runtimeAPIRegistry-C2VogTny.js";import{a as v,i as y,r as b}from"./vendor-zustand-CTekDqaS.js";import{ot as x,st as S}from"./vendor-base-ui-wXsskyKm.js";import{Ft as C,St as w}from"./gitApiHttp-Dd-FwgCq.js";import{i as T,t as E}from"./safeStorage-DTOhKN0V.js";import{n as D}from"./client-B_907PBv.js";import{n as O}from"./vendor-react-BkccXcWz.js";import{n as k,s as A,u as j}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{c as M,l as N}from"./yuriEvents-BFrD5fMU.js";import{r as P}from"./vendor-reactuses-core-DjKFMfz7.js";import{o as F}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{r as I}from"./useUIStore-C3ewjGgP.js";import{o as ee}from"./useMobileHtmlPreviewStore-BYunNOBo.js";import{a as te,t as ne}from"./types-s_oc_LRs.js";import{i as L,o as R}from"./session-startup-barrier-DT-hIBRf.js";import{n as z}from"./Icon-DmykXZL1.js";import{Ja as re,t as B}from"./ui-DrAJTWV6.js";import{n as ie,t as ae}from"./i18n-DXc6czdR.js";import{t as oe}from"./ScrollableOverlay-stxT7gLf.js";import{n as se,o as V,r as H,t as U}from"./dialog-BeFBA6ja.js";import{t as ce}from"./device-EIfSfSWk.js";import{a as le,c as ue,g as de,n as fe,r as pe,u as me}from"./gitApi-BWsBS_2N.js";import{n as he}from"./MarkdownRenderer-D7p9Iflj.js";import{i as ge,n as _e,r as ve}from"./githubAuthQueries-DqregESf.js";import{c as ye,i as be,o as xe}from"./mcpQueries-1WNtiFYh.js";import{c as Se,s as Ce}from"./usePluginsStore-ZHQOW-R5.js";var we=O(),W=x();function Te(e){let t=(0,we.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,W.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,W.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,W.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 Ee={},De=(e,t=n())=>JSON.stringify([t,be(e)]),Oe=(e,t,n)=>{if(!e[t]?.[n])return e;let r={...e[t]};return delete r[n],{...e,[t]:r}},G=e=>{let t=be(e);return t?D.getScopedApiClient(t):D.getApiClient()},K=e=>e?{location:{directory:e}}:void 0,q=new Map,J=(e,t)=>JSON.stringify([r(),De(t),e]),ke=async(e,t,n)=>{let r=(await e.mcp.list(K(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,...K(n)})).data},Y=e=>be(e===void 0?w.getState().currentDirectory:e),Ae=v()(b((e,t)=>({diagnosticsByDirectory:{},getDiagnosticForDirectory:e=>{let n=De(Y(e));return t().diagnosticsByDirectory[n]??Ee},clearDiagnostic:(t,n,r)=>{let i=De(Y(n),r);e(e=>({diagnosticsByDirectory:Oe(e.diagnosticsByDirectory,i,t)}))},connect:async(t,r)=>{let i=Y(r),a=n(),o=De(i,a),s=G(i);try{await s.mcp.connect({server:t,...K(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 ye(M,i,a),e(e=>({diagnosticsByDirectory:Oe(e.diagnosticsByDirectory,o,t)}))},disconnect:async(t,r)=>{let i=Y(r),a=n(),o=De(i,a);await G(i).mcp.disconnect({server:t,...K(i)}),await ye(M,i,a),e(e=>({diagnosticsByDirectory:Oe(e.diagnosticsByDirectory,o,t)}))},startAuth:async(e,t)=>{let n=Y(t),r=J(e,n),i=G(n),a=await ke(i,e,n),o=a.methods.find(e=>e.type===`oauth`);if(!o)throw Error(`MCP server "${e}" has no OAuth method`);if(r!==J(e,n))throw Error(`MCP authorization runtime changed`);let s=q.get(r);if(s&&(await i.integration.oauth.cancel({integrationID:s.integrationID,attemptID:s.attempt.attemptID,...K(n)}),q.delete(r)),r!==J(e,n))throw Error(`MCP authorization runtime changed`);let{data:c}=await i.integration.oauth.connect({integrationID:a.id,methodID:o.id,...K(n)});if(r!==J(e,n))throw Error(`MCP authorization runtime changed`);for(let[e,t]of q)t.attempt.time.expires<=Date.now()&&q.delete(e);return q.set(r,{integrationID:a.id,attempt:c}),c},authStatus:async(e,t)=>{let n=Y(t),r=J(e,n),i=q.get(r);if(!i)throw Error(`MCP authorization attempt not found`);let{data:a}=await G(n).integration.oauth.status({integrationID:i.integrationID,attemptID:i.attempt.attemptID,...K(n)});if(r!==J(e,n))throw Error(`MCP authorization runtime changed`);return a.status!==`pending`&&q.get(r)===i&&q.delete(r),a},completeAuth:async(e,t,r)=>{let i=Y(r),a=n(),o=J(e,i),s=q.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 G(i).integration.oauth.complete({integrationID:s.integrationID,attemptID:s.attempt.attemptID,code:t.trim(),...K(i)}),q.get(o)===s&&q.delete(o),o!==J(e,i))throw Error(`MCP authorization runtime changed`);await ye(M,i,a)},clearAuth:async(e,t)=>{let r=Y(t),i=n(),a=J(e,r),o=G(r),s=await ke(o,e,r);if(a!==J(e,r))throw Error(`MCP authorization runtime changed`);let c=q.get(a);c&&(await o.integration.oauth.cancel({integrationID:c.integrationID,attemptID:c.attempt.attemptID,...K(r)}),q.delete(a));let l=new Set(s.connections.flatMap(e=>e.type===`credential`?[e.id]:[]));for(let t of l){if(a!==J(e,r))throw Error(`MCP authorization runtime changed`);await o.credential.remove({credentialID:t})}if(a!==J(e,r))throw Error(`MCP authorization runtime changed`);await ye(M,r,i)},testConnection:async(t,r)=>{let i=Y(r),a=n(),o=De(i,a),s=G(i),c=xe(M,i,a)[t]?.status===`connected`,l,u;try{await s.mcp.connect({server:t,...K(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 ye(M,i,a))[t],f=d;if(!c&&d?.status===`connected`){try{await s.mcp.disconnect({server:t,...K(i)})}catch(e){u=`Connection test succeeded, but cleanup disconnect failed: ${e instanceof Error?e.message:`Disconnect failed`}`}await ye(M,i,a)}return l||e(e=>({diagnosticsByDirectory:Oe(e.diagnosticsByDirectory,o,t)})),{status:f??xe(M,i,a)[t],error:l,warning:u}}}))),X=e(S(),1),je=`https://yuri-updates.xiaobe.top/v1/update/check`,Me=`https://yuri-origin.xiaobe.top/v1/update/check`,Ne=`https://github.com/yee94/yuri/releases/latest`,Pe=`https://github.com/yee94/yuri/releases`,Fe=`https://testflight.apple.com/join/pN5SSHeg`,Ie=1e4;function Le(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 Re(e,t){let n=Le(e),r=Le(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 ze(){return[je,Me]}function Be(e,t,n=Date.now){let r=e-n();return r<=0||t<=0?null:Math.max(1,Math.ceil(r/t))}function Ve(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 He(e,t,n,r){try{if(m())try{let{CapacitorHttp:r}=await F(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 Ue(e,t){return e===`ios`?Fe:`${Pe}/download/v${t}/app-release.apk`}function We(e,t,n){if(typeof e.latestVersion!=`string`||e.latestVersion.trim().length===0)return null;let r=e.latestVersion.trim(),i=Re(r,t);if(i<0)return null;let a=typeof e.releaseNotesUrl==`string`&&e.releaseNotesUrl.trim().length>0?e.releaseNotesUrl.trim():`${Pe}/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():Ue(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 Ge(e,t,n,r){let i=await He(e,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify(Ve(t))},n,r);if(!i?.ok)return null;let a;try{a=await i.json()}catch{return null}return We(a,t.currentVersion,t.platform)}async function Ke(e,t,n,r){let i=await He(Ne,{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:Ne,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=Re(s,e),l=`${Pe}/tag/v${s}`;return{available:c>0,version:s,currentVersion:e,releaseUrl:l,downloadUrl:Ue(t,s)}}async function qe(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=ze(),a=r()+Ie;for(let[t,o]of i.entries()){let s=Be(a,i.length-t+1,r);if(s===null)break;let c=await Ge(o,e,s,n);if(c)return c}let o=Be(a,1,r);if(o!==null){let r=await Ke(t,e.platform,o,n);if(r)return r}return{available:!1,currentVersion:t,error:`Unable to check for mobile updates`}}function Je(){if(typeof window>`u`)return`unknown`;try{let{deviceType:e}=ce();return e}catch{return`unknown`}}function Ye(){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 Xe(){let e=h();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 Ze(e){let t=I.getState().reportUsage,n=new URLSearchParams({reportUsage:t?`true`:`false`});return n.set(`deviceClass`,Je()),n.set(`arch`,Ye()),n.set(`platform`,Xe()),e===`desktop`?(n.set(`appType`,`desktop-electron`),n.set(`instanceMode`,s()?`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 Qe(e,t){let n=t??`unknown`;try{let r=Ze(e),a=typeof window<`u`?window.__VSCODE_CONFIG__?.extensionVersion:void 0;t?r.set(`currentVersion`,t):e===`vscode`&&a&&r.set(`currentVersion`,a);let o=await i(`/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 $e(){return m()?`mobile`:o()?`desktop`:c()?`vscode`:g()?`web`:null}var et={checking:!1,available:!1,downloading:!1,downloaded:!1,info:null,progress:null,error:null,downloadError:null,downloadVersion:null,downloadChannel:null,runtimeType:null,lastChecked:null,nextCheckInSec:null,otaDecision:null,otaPhase:`idle`,otaDownloadSkipped:!1,lastOtaChannelOverride:null},tt=`yuri-client-update-download`,nt=e=>typeof e==`string`&&/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/.test(e);function rt(){try{let e=JSON.parse(T().getItem(tt)??`null`);return!e||e.runtimeType!==$e()||![`desktop`,`mobile`].includes(e.runtimeType)||!nt(e.version)||![null,`stable`,`beta`].includes(e.channel)?{}:{runtimeType:e.runtimeType,downloadVersion:e.version,downloadChannel:e.channel,downloadError:`update_interrupted`}}catch{return{}}}function it(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 at=0,ot=v()((e,t)=>({...et,...rt(),checkForUpdates:async()=>{let n=$e();if(!n)return null;let r=++at;e({checking:!0,error:null,runtimeType:n});try{let i=null,a=null;if(n===`desktop`){let n=I.getState().otaChannelOverride;t().lastOtaChannelOverride!==n&&e({downloaded:!1,downloading:!1,available:!1,info:null,otaDecision:null,progress:null,otaPhase:`checking`});let i=await p(n);if(r!==at||I.getState().otaChannelOverride!==n)return null;let a=i?.downloaded===!0,o=!a&&i?.downloading===!0;return e({checking:!1,available:i?.available??!1,downloaded:a,...a?{downloading:!1,progress:null,downloadError:null}:o?{downloading:!0,progress:i?.progress??null}:{},info:i,error:null,lastChecked:Date.now(),nextCheckInSec:i?.nextSuggestedCheckInSec??null,otaDecision:i?.otaDecision??null,otaPhase:a?`pending_restart`:o?`downloading`:i?.inAppApply?`available`:`idle`,lastOtaChannelOverride:n}),i?.nextSuggestedCheckInSec??null}if(n===`web`)i=await Qe(`web`),a=i?.nextSuggestedCheckInSec??null;else if(n===`vscode`)a=(await Qe(`vscode`))?.nextSuggestedCheckInSec??null;else if(n===`mobile`){let n=await te()??`unknown`,r=m()?_()?.mobileUpdates:void 0,o=I.getState().otaChannelOverride;if(r)try{let i=t().lastOtaChannelOverride!==o;e(i?{otaDecision:null,otaPhase:`checking`,downloaded:!1,otaDownloadSkipped:!1,progress:null,available:!1,info:null}:{otaPhase:`checking`});let a=await r.checkForOtaUpdate(o===`beta`||o===`stable`?{channelOverride:o}:void 0),s=it(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 ne)){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 qe({currentVersion:n,platform:Xe()===`ios`?`ios`:`android`,deviceClass:Je(),arch:Ye(),reportUsage:I.getState().reportUsage}),a=i?.nextSuggestedCheckInSec??null,e({checking:!1,available:i?.available??!1,info:i,error:i?.error??null,lastChecked:Date.now(),nextCheckInSec:a,otaDecision:null,otaPhase:`idle`}),a}return e({checking:!1,available:n===`vscode`?!1:i?.available??!1,info:n===`vscode`?null:i,error:n===`vscode`?null:i?.error??null,lastChecked:Date.now(),nextCheckInSec:a}),a}catch(i){return r===at&&e({checking:!1,error:i instanceof Error?i.message:`Failed to check for updates`,...n===`desktop`&&!t().downloaded?{otaPhase:`error`}:{}}),null}},downloadUpdate:async n=>{n?.resume===!0&&!t().info&&await t().checkForUpdates();let{available:r,runtimeType:i,otaDecision:a,downloading:o,downloaded:s}=t();if(o||s)return;let c=I.getState().otaChannelOverride,l=n?.resume===!0,u=l?t().downloadVersion:t().info?.version;if(l&&(t().downloadChannel!==c||u!==t().info?.version)){e({downloadError:`update_plan_changed`,error:`update_plan_changed`});return}if(i===`mobile`&&a?.primaryAction===`apply_ota`&&a.ota.bundle){if(o||s)return;let t=_()?.mobileUpdates;if(!t){e({error:`Mobile OTA updates are unavailable in this runtime`,downloadError:`Mobile OTA updates are unavailable in this runtime`,otaPhase:`error`});return}e({downloading:!0,error:null,downloadError:null,downloadVersion:u??null,downloadChannel:c,progress:null,otaPhase:`downloading`,otaDownloadSkipped:!1});try{let{skipped:n}=await t.downloadOtaUpdate(a.ota.bundle);await t.queueOtaUpdateForNextLaunch(),e({downloading:!1,downloaded:!0,downloadError:null,progress:null,otaPhase:`pending_restart`,otaDownloadSkipped:n})}catch(t){e({downloading:!1,error:t instanceof Error?t.message:`Failed to download update`,downloadError:t instanceof Error?t.message:`Failed to download update`,otaPhase:`error`})}return}if(!(i!==`desktop`||!r)){e({downloading:!0,error:null,downloadError:null,downloadVersion:u??null,downloadChannel:c,progress:null});try{let n=I.getState().otaChannelOverride,r=await p(n);if(n!==I.getState().otaChannelOverride)throw Error(`OTA channel changed`);if(u&&r?.version!==u)throw Error(`update_plan_changed`);if(!r?.available||r.manualUpdate)throw Error(`Update detected, but desktop package is not ready yet. Retry in a moment.`);if(e(e=>({info:e.info?{...e.info,...r,body:r.body||e.info.body,available:e.info.available}:r})),r.downloaded||t().downloaded){e({downloading:!1,downloaded:!0,progress:null});return}if(r.downloading&&e({downloading:!0,progress:r.progress??{downloaded:0}}),!await d(t=>{e({progress:t})}))throw Error(`Failed to download update`);e({downloading:!1,downloaded:!0,progress:null,otaPhase:`pending_restart`})}catch(t){e({downloading:!1,error:t instanceof Error?t.message:`Failed to download update`,downloadError:t instanceof Error?t.message:`Failed to download update`})}}},subscribeDesktopUpdateEvents:async()=>{if(!o())return()=>{};let n=[],r=await a(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,downloadError:null})});r&&n.push(r);let i=await l(t=>{t.downloaded&&e({downloading:!1,downloaded:!0,available:!0,progress:null,downloadError: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=_()?.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 u())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`,downloadError:t??`Failed to download update`,otaPhase:`error`})},dismiss:()=>{let n=t();n.otaPhase===`pending_restart`||n.downloading||n.downloadError||e({available:!1,downloaded:!1,info:null,otaDecision:null,otaPhase:`idle`,otaDownloadSkipped:!1})},reset:()=>{e(et)}}));ot.subscribe((e,t)=>{if(e.downloading===t.downloading&&e.downloaded===t.downloaded&&e.downloadError===t.downloadError&&e.downloadVersion===t.downloadVersion&&e.downloadChannel===t.downloadChannel)return;let n=T();(e.downloading||e.downloadError)&&!e.downloaded&&nt(e.downloadVersion)?n.setItem(tt,JSON.stringify({version:e.downloadVersion,channel:e.downloadChannel,runtimeType:e.runtimeType})):n.removeItem(tt)});var st=8e3,Z=e=>!!(e&&![`succeeded`,`failed`].includes(e.status));function Q(e,t){if(e!==n()||t!==r())throw Error(`Stale update runtime`)}var $=(e=n(),t=r(),a)=>({queryKey:[e,`host-update`,t,a??`current`],queryFn:async({signal:n})=>{Q(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 i(`/api/system/update${a?`?channel=${a}`:``}`,{headers:{Accept:`application/json`},signal:r.signal});if([404,501].includes(n.status))throw Error(`host_update_unsupported`);let o=await n.json();if(Q(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`))},st)})])}finally{s!==void 0&&clearTimeout(s),n.removeEventListener(`abort`,o)}},staleTime:6e4,retry:!1}),ct=(e=n(),t=r(),i)=>M.getQueryData($(e,t,i).queryKey),lt=(e=n(),t=r(),i)=>{let a=ct(e,t,i);return M.fetchQuery({...$(e,t,i),staleTime:a?.checkError||Z(a?.operation)?0:6e4})},ut=(e=n(),t=r(),i)=>M.fetchQuery({...$(e,t,i),staleTime:0}),dt=(e,t,n)=>{let r=(0,we.c)(6),i;r[0]!==n||r[1]!==t||r[2]!==e?(i=$(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:mt,refetchIntervalInBackground:!1},r[4]=i,r[5]=a),A(a)};async function ft(e,t,n){if(Q(t,n),!e.update)throw Error(`No update plan`);let r=await i(`/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(Q(t,n),!r.ok)throw Error(`Host update was not accepted`);let a=await r.json();if(typeof a.operation?.id!=`string`)throw Error(`Invalid update operation`);return a.operation}async function pt(e,t,n){Q(t,n);let r=await ut(t,n,e.channel);Q(t,n);let i=r.operation;if(i?.id===e.id&&i.version===e.version&&i.channel===e.channel&&i.kind===e.kind&&(Z(i)||i.status===`succeeded`&&r.currentVersion===e.version))return M.setQueryData($(t,n).queryKey,r),i;if(r.checkError||r.update?.version!==e.version||r.update.kind!==e.kind)throw Error(`update_plan_changed`);let a=await ft(r,t,n);return Q(t,n),M.setQueryData($(t,n).queryKey,e=>({...e??r,operation:a})),a}function mt(e){return Z(e.state.data?.operation)?2e3:e.state.error?.message===`host_update_unsupported`?!1:e.state.error?15e3:3e5}function ht(e){let t=new Date(`${e}T00:00:00`);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(ie(),{year:`numeric`,month:`short`,day:`numeric`}).format(t)}function gt(e){return e.replace(/^## \[[^\]]+\] - \d{4}-\d{2}-\d{2}\s*\n?/,``).trim()}function _t(e){return e.replace(/(^|[^a-zA-Z0-9])@([a-zA-Z0-9-]+)/g,`$1[@$2](https://github.com/$2)`)}function vt(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 yt(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 bt(e){let t=(0,we.c)(67),{open:n,onOpenChange:r,model:i,onAction:a}=e,{t:o}=ae(),[s,c]=(0,X.useState)(!1),l=P(St),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=P(u),f;t[2]===i.fallbackCommand?f=t[3]:(f=async()=>{i.fallbackCommand&&(await re(i.fallbackCommand)).ok&&(c(!0),setTimeout(()=>c(!1),2e3))},t[2]=i.fallbackCommand,t[3]=f);let p=P(f),m;if(t[4]!==i.body||t[5]!==o){bb0:{let e=i.body?.trim();if(!e){m=null;break bb0}let n=yt(e);if(!n.length){m={kind:`raw`,title:o(`updateDialog.changelog.title`),content:_t(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(xt).map(t=>({version:t.version,dateLabel:ht(t.date),content:_t(gt(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=R(`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,W.jsx)(z,{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,W.jsxs)(V,{className:`flex items-center gap-2`,children:[y,(0,W.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,W.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,W.jsx)(`span`,{className:`text-muted-foreground/75`,children:i.currentVersion}),i.currentVersion&&i.version&&(0,W.jsx)(`span`,{className:`text-muted-foreground/40`,children:`→`}),i.version&&(0,W.jsx)(`span`,{className:`font-medium text-[var(--primary-base)]`,children:i.version}),i.methodLabel&&(0,W.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,W.jsx)(H,{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,W.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,W.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,W.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,W.jsxs)(`section`,{className:R(`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,W.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,W.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--primary-base)]`,"aria-hidden":`true`}),(0,W.jsx)(`h3`,{className:`typography-ui-caption font-medium text-muted-foreground`,children:h.title})]}),(0,W.jsx)(oe,{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,W.jsx)(`div`,{className:`break-words px-3.5 py-2 text-[13px] leading-[1.65] text-foreground sm:px-4 sm:text-sm [&_.markdown-content]:leading-[1.65] [&_.markdown-content>:first-child]:!mt-0 [&_.markdown-content>:first-child>:first-child]:!mt-0 [&_.markdown-content>:last-child]:!mb-0 [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline`,onClickCapture:d,children:(0,W.jsx)(he,{content:h.content,disableLinkSafety:!0,enableFileReferences:!1})}):(0,W.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:h.sections.map(e=>(0,W.jsxs)(`div`,{className:`px-3.5 py-2 sm:px-4`,children:[(0,W.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-center gap-x-2 gap-y-1 sm:mb-3`,children:[(0,W.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,W.jsx)(`span`,{className:`text-[11px] leading-4 text-muted-foreground/75 sm:text-xs`,children:e.dateLabel})]}),(0,W.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,W.jsx)(he,{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,W.jsxs)(`div`,{className:`space-y-2 mt-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 typography-meta text-muted-foreground`,children:[(0,W.jsx)(z,{name:`terminal`,className:`h-4 w-4`}),(0,W.jsx)(`span`,{children:o(`updateDialog.fallback.updateViaTerminal`)})]}),(0,W.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,W.jsx)(`code`,{className:`flex-1 font-mono text-sm text-foreground overflow-x-auto whitespace-nowrap`,children:i.fallbackCommand}),(0,W.jsx)(`button`,{onClick:p,className:R(`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,W.jsx)(z,{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,W.jsxs)(`div`,{role:`status`,className:R(`space-y-2`,i.stableLayout&&`min-h-9 shrink-0`),children:[(0,W.jsxs)(`div`,{className:`flex h-5 items-center justify-between gap-3`,children:[(0,W.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,W.jsx)(z,{name:`loader`,className:`h-3.5 w-3.5 shrink-0 animate-spin text-[var(--primary-base)]`}),(0,W.jsx)(`span`,{className:`truncate`,title:i.status.label,children:i.status.label})]}),i.status.progress!=null&&(0,W.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,W.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-[var(--surface-subtle)] sm:h-1.5`,children:i.status.progress==null?(0,W.jsx)(`div`,{className:`h-full w-1/3 animate-pulse rounded-full bg-[var(--primary-base)]/60`}):(0,W.jsx)(`div`,{className:`h-full rounded-full bg-[var(--primary-base)] transition-[width] duration-500`,style:{width:`${i.status.progress}%`}})}),i.status.detail&&(0,W.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,W.jsx)(`div`,{role:`alert`,className:`p-3 mt-4 bg-[var(--status-error-background)] border border-[var(--status-error-border)] rounded-lg`,children:(0,W.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,W.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,W.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,W.jsx)(z,{name:`check`,className:`h-4 w-4 shrink-0`}),(0,W.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,W.jsxs)(`div`,{className:`mt-4 flex shrink-0 items-center justify-between gap-4`,children:[i.releaseLink&&(0,W.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,W.jsx)(z,{name:`external-link`,className:`h-4 w-4`}),i.releaseLink.label]}),(0,W.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-nowrap items-center justify-end gap-2`,children:i.actions.map(e=>(0,W.jsxs)(L,{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,W.jsx)(z,{name:e.icon,className:R(`h-4 w-4`,e.loading&&`animate-spin`)}),(0,W.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 F;t[57]!==C||t[58]!==j||t[59]!==M||t[60]!==N||t[61]!==v?(F=(0,W.jsxs)(se,{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]=F):F=t[62];let I;return t[63]!==n||t[64]!==F||t[65]!==g?(I=(0,W.jsx)(U,{open:n,onOpenChange:g,children:F}),t[63]=n,t[64]=F,t[65]=g,t[66]=I):I=t[66],I}function xt(e,t){return vt(e.version,t.version)}function St(e){ee(e)}var Ct=`https://github.com/yee94/yuri/releases`,wt=2e3,Tt=6e5,Et=e=>e.transport===n()&&e.generation===r();async function Dt(e,t){try{if(!Et(t))return{success:!1};let n=await lt(t.transport,t.generation);return!Et(t)||!e||!n.supported||n.update?.version!==e||n.update.rollback?{success:!1}:(await ft(n,t.transport,t.generation),{success:!0,autoRestart:!0})}catch(e){return{success:!1,error:e instanceof Error?e.message:void 0}}}async function Ot(e,t,n=Math.ceil(Tt/wt),r=wt){for(let i=0;i<n;i++){if(!Et(t))return!1;try{let n=await ut(t.transport,t.generation);if(n.operation?.status===`failed`)return!1;if(n.currentVersion===e&&n.operation?.status===`succeeded`&&Et(t))return!0}catch{}await new Promise(e=>setTimeout(e,r))}return!1}var kt=e=>{let t=(0,we.c)(107),{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}=ae(),[g,_]=(0,X.useState)(`idle`),[v,y]=(0,X.useState)(null),b=ot(At),x=o?.releaseUrl||(o?.version?`${Ct}/tag/v${o.version}`:Ct),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&&ot.getState().dismiss(),a(e)},t[0]=c,t[1]=E,t[2]=a,t[3]=A):A=t[3];let j=P(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,X.useEffect)(M,N);let F;t[7]!==o?.version||t[8]!==h?(F=async()=>{let e={transport:n(),generation:r()};_(`updating`),y(null);let t=await Dt(o?.version,e);if(!Et(e))return;if(!t.success){_(`error`),y(t.error||h(`updateDialog.error.updateFailed`));return}t.autoRestart&&(_(`restarting`),await new Promise(jt)),_(`reconnecting`);let i=await Ot(o?.version,e);Et(e)&&(i?window.location.reload():(_(`error`),y(h(`updateDialog.error.takingLonger`))))},t[7]=o?.version,t[8]=h,t[9]=F):F=t[9];let I=P(F),te;t[10]!==I||t[11]!==w||t[12]!==d||t[13]!==a||t[14]!==f||t[15]!==S||t[16]!==x?(te=e=>{bb107:switch(e){case`download`:d();break bb107;case`restart`:f();break bb107;case`later`:ot.getState().dismiss(),a(!1);break bb107;case`open-external`:{let e=w?S:x;e&&ee(e);break bb107}case`web-update`:I()}},t[10]=I,t[11]=w,t[12]=d,t[13]=a,t[14]=f,t[15]=S,t[16]=x,t[17]=te):te=t[17];let ne=P(te),L;if(t[18]!==c||t[19]!==s||t[20]!==E||t[21]!==D||t[22]!==w||t[23]!==C||t[24]!==O||t[25]!==T||t[26]!==h){if(L=[],!C&&(!w||E)){if(!D&&!c&&!s){let e;t[28]!==E||t[29]!==h?(e=h(E?`updateDialog.actions.applyOtaNow`:`updateDialog.actions.downloadUpdate`),t[28]=E,t[29]=h,t[30]=e):e=t[30];let n;t[31]===e?n=t[32]:(n={id:`download`,icon:`download`,label:e},t[31]=e,t[32]=n),L.push(n)}if(D&&!c&&!s){let e;t[33]===h?e=t[34]:(e=h(`updateDialog.actions.openMobileUpdate`),t[33]=h,t[34]=e);let n;t[35]===e?n=t[36]:(n={id:`open-external`,icon:`external-link`,label:e},t[35]=e,t[36]=n),L.push(n)}if(s){let e;t[37]===h?e=t[38]:(e=h(`updateDialog.status.downloading`),t[37]=h,t[38]=e);let n;t[39]===e?n=t[40]:(n={id:`downloading`,icon:`loader`,loading:!0,disabled:!0,label:e},t[39]=e,t[40]=n),L.push(n)}if(c){if(E){let e;t[41]===h?e=t[42]:(e=h(`updateDialog.actions.later`),t[41]=h,t[42]=e);let n;t[43]===e?n=t[44]:(n={id:`later`,variant:`ghost`,label:e},t[43]=e,t[44]=n),L.push(n)}let e;t[45]===h?e=t[46]:(e=h(`updateDialog.actions.restartToUpdate`),t[45]=h,t[46]=e);let n;t[47]===e?n=t[48]:(n={id:`restart`,icon:`restart`,label:e},t[47]=e,t[48]=n),L.push(n)}}if(w&&!E&&T){let e;t[49]===h?e=t[50]:(e=h(`updateDialog.actions.openMobileUpdate`),t[49]=h,t[50]=e);let n;t[51]===e?n=t[52]:(n={id:`open-external`,icon:`external-link`,label:e},t[51]=e,t[52]=n),L.push(n)}if(C){let e;t[53]!==O||t[54]!==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[53]=O,t[54]=h,t[55]=e):e=t[55],L.push(e)}t[18]=c,t[19]=s,t[20]=E,t[21]=D,t[22]=w,t[23]=C,t[24]=O,t[25]=T,t[26]=h,t[27]=L}else L=t[27];let R;t[56]!==h||t[57]!==g?(R=h(g===`restarting`||g===`reconnecting`?`updateDialog.header.updating`:`updateDialog.header.updateAvailable`),t[56]=h,t[57]=g,t[58]=R):R=t[58];let z=o?.currentVersion,re=o?.version,B=o?.body,ie=!O,oe=u||v,se=C&&g===`error`?o?.updateCommand||`yuri update`:void 0,V;t[59]!==c||t[60]!==E||t[61]!==b||t[62]!==h?(V=E&&c&&b?h(`updateDialog.status.otaBundleReused`):void 0,t[59]=c,t[60]=E,t[61]=b,t[62]=h,t[63]=V):V=t[63];let H;t[64]!==w||t[65]!==k||t[66]!==T?(H=(!w||T)&&k?{url:k,label:`GitHub`}:void 0,t[64]=w,t[65]=k,t[66]=T,t[67]=H):H=t[67];let U;if(t[68]!==L||t[69]!==s||t[70]!==E||t[71]!==w||t[72]!==C||t[73]!==O||t[74]!==l||t[75]!==h||t[76]!==B||t[77]!==ie||t[78]!==oe||t[79]!==se||t[80]!==V||t[81]!==H||t[82]!==R||t[83]!==z||t[84]!==re||t[85]!==g){if(U={title:R,currentVersion:z,version:re,body:B,hideChangelog:O,dismissible:ie,error:oe,fallbackCommand:se,notice:V,releaseLink:H,actions:L},C&&O){let e;t[87]!==h||t[88]!==g?(e=h(g===`updating`?`updateDialog.status.installingUpdate`:g===`restarting`?`updateDialog.status.serverRestarting`:`updateDialog.status.waitingForServer`),t[87]=h,t[88]=g,t[89]=e):e=t[89];let n;t[90]===h?n=t[91]:(n=h(`updateDialog.status.autoReloadHint`),t[90]=h,t[91]=n);let r;t[92]!==e||t[93]!==n?(r={kind:`activity`,label:e,detail:n},t[92]=e,t[93]=n,t[94]=r):r=t[94],U.status=r}if(!C&&(!w||E)&&s){let e;t[95]===h?e=t[96]:(e=h(`updateDialog.status.downloadingPayload`),t[95]=h,t[96]=e);let n;t[97]===l?n=t[98]:(n=l?.total?Math.round(l.downloaded/l.total*100):0,t[97]=l,t[98]=n);let r;t[99]!==e||t[100]!==n?(r={kind:`download`,label:e,progress:n},t[99]=e,t[100]=n,t[101]=r):r=t[101],U.status=r}t[68]=L,t[69]=s,t[70]=E,t[71]=w,t[72]=C,t[73]=O,t[74]=l,t[75]=h,t[76]=B,t[77]=ie,t[78]=oe,t[79]=se,t[80]=V,t[81]=H,t[82]=R,t[83]=z,t[84]=re,t[85]=g,t[86]=U}else U=t[86];let ce;return t[102]!==ne||t[103]!==j||t[104]!==U||t[105]!==i?(ce=(0,W.jsx)(bt,{open:i,onOpenChange:j,model:U,onAction:ne}),t[102]=ne,t[103]=j,t[104]=U,t[105]=i,t[106]=ce):ce=t[106],ce};function At(e){return e.otaDownloadSkipped}function jt(e){return setTimeout(e,2e3)}function Mt(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 Nt(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=Z(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:Mt(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 Pt(){let e=(0,we.c)(7),{t:i}=ae(),a=X.useSyncExternalStore(t,n,n),o=X.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,W.jsx)(Ft,{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 Ft({version:e,transport:t,generation:i,itemId:a,channel:o}){let{t:s}=ae(),c=j(),[l,u]=X.useState(!1),d=I(e=>e.otaChannelOverride),f=o??d??void 0,p=dt(t,i,f),m=p.data,h=m?.operation,g=Z(h),_=JSON.stringify([t,i,f??`current`]),[v,y]=X.useState(null);m?.update&&(v?.scope!==_||v.update!==m.update)&&y({scope:_,update:m.update});let b=k({mutationFn:({plan:e})=>ft(e,t,i),onSuccess:(e,a)=>{t===n()&&i===r()&&c.setQueryData($(t,i,a.channel).queryKey,t=>t&&{...t,operation:e})},onSettled:(e,a,o)=>{t===n()&&i===r()&&c.invalidateQueries({queryKey:$(t,i,o.channel).queryKey,exact:!0})}}),[x,S]=X.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`);X.useEffect(()=>{!C||p.isError||t!==n()||i!==r()||(S(null),u(!1),B.success(w,{id:`host-update:${t}:${i}:${x}`}))},[C,p.isError,t,i,x,w]);let T=X.useRef(null),E=P(()=>_),D=P(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`?B.info(s(`settings.yuri.about.hostUpdate.unsupported`)):B.error(s(`settings.yuri.about.toast.checkFailed`));return}Z(a.data.operation)?u(!0):a.data.supported?a.data.update?u(!0):(u(!1),B.success(s(`settings.yuri.about.toast.latestVersion`))):B.info(s(`settings.yuri.about.hostUpdate.unsupported`))}finally{T.current===e&&(T.current=null)}}),O=m?.supported===!1||!g&&p.error?.message===`host_update_unsupported`,A=p.isError||!!m?.checkError,M=b.isError&&b.variables?.channel===f,N=Nt(m,{versionFallback:e,checking:p.isPending?`initial`:p.isFetching?`refresh`:!1,submitting:b.isPending,failure:O?`unsupported`:p.isError&&(g||M)?`disconnected`:A||M?`check`:null,completed:C,updateDetails:v?.scope===_?v.update:void 0},s),F=P(e=>{e===`confirm`&&m?.update&&b.mutate({plan:m,channel:f})});return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,"data-settings-item":a,children:[(0,W.jsxs)(`span`,{className:`relative typography-ui-label font-mono text-foreground text-right`,children:[m?.currentVersion??e,m?.update&&!g&&(0,W.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,W.jsx)(L,{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,W.jsx)(z,{name:g||p.isFetching?`loader`:m?.update?`download`:`refresh`,className:g||p.isFetching?`size-4 animate-spin`:`size-4`})})]}),(0,W.jsx)(bt,{open:l,onOpenChange:u,model:N,onAction:F})]})}var It=e=>e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e),Lt=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(`/`)}`},Rt=e=>Lt(`${e.replace(/\\/g,`/`)}/..`),zt=e=>{try{let t=decodeURIComponent(new URL(e).pathname);return/^\/[A-Za-z]:\//.test(t)?t.slice(1):t}catch{return null}};function Bt(e,t){if(e.startsWith(`file://`)){let t=zt(e);return t?{kind:`local`,path:Lt(t)}:null}return e.startsWith(`./`)||e.startsWith(`../`)?t?{kind:`local`,path:Lt(`${Rt(t)}/${e}`)}:null:It(e)?{kind:`local`,path:Lt(e)}:{kind:`package`,target:e}}function Vt(e){return e?{kind:`local`,path:Lt(e)}:null}var Ht=(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=Lt(t.source.path);return n===e.path||n.startsWith(`${e.path}/`)};function Ut(e,t){return t.filter(t=>Ht(e,t))}function Wt(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 Gt(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 Kt(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 qt(){let e=(0,we.c)(5),t=Se(),n=Ce(),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=Gt(Ut(r,a));i.kind===`failed`&&t.push({id:e,label:n,error:i.error})};for(let e of r??[])n(e.id,e.spec,Bt(e.spec,e.sourcePath));for(let e of i??[])n(e.id,e.fileName,Vt(e.absolutePath));e[1]=r,e[2]=i,e[3]=a,e[4]=t}else t=e[4];o=t}return o}var Jt=e=>e instanceof Error&&e.name===`CancelledError`,Yt=v(()=>({setStatus:e=>ge(M,e),refreshStatus:async(e,t)=>{let r=n();t?.force&&await M.cancelQueries({queryKey:N.github.auth(r),exact:!0});try{return await ve(M,e,r)}catch(e){if(Jt(e))return _e(M,r);throw e}}})),Xt=v()(b(y((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 ue(),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 me();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 le()}),!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=_()?.settings;if(e)try{n=t(((await e.load())?.settings||{}).defaultGitIdentityId)}catch{}}if(n===null)try{let e=await i(`/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 C({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 fe(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 de(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 pe(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:E(),partialize:e=>({selectedProfileId:e.selectedProfileId})}),{name:`git-identities-store`}));typeof window<`u`&&(window.__zustand_git_identities_store__=Xt);var Zt=(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,Qt=(e,t,n)=>{Zt(e.get(t),n)&&e.set(t,n)},$t=e=>{let t=e;return f(t.directory)??f(t.project?.worktree)},en=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)},tn=(e,t,n,r,i=[])=>{let a=new Map,o=new Map;for(let e of t){let t=f(e.normalizedPath);if(!t)continue;let n=o.get(t);(!n||e.id.localeCompare(n.id)<0)&&o.set(t,e),Qt(a,t,{projectId:e.id,projectRoot:t,scopeDirectory:t,kind:`project`})}if(!r)for(let[e,t]of n){let n=f(e),r=n?o.get(n):void 0;if(!(!r||!n))for(let e of t){let t=f(e.path);t&&Qt(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,p=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=en(n)}for(let e of t)s.set(e,i);return i},m=(e,t,n)=>{for(let r of e){let e=p($t(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 m(e,l,d),m(i,u),{bySessionId:c,sessionsByProject:l,archivedSessionsByProject:u,sessionsByScope:d,directoryResolutions:s.size}};export{ot as _,Bt as a,Wt as c,Pt as d,Ft as f,pt as g,Z as h,qt as i,Gt as l,$ as m,Xt as n,Ut as o,kt as p,Yt as r,Vt as s,tn as t,Kt as u,Ae as v,Te as y};
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,n as r}from"./runtime-switch-DEPKHgdL.js";import{n as i}from"./runtime-fetch-V-iMWR8t.js";import{B as a,I as o,P as s,R as c,V as l,Z as u,_ as d,f,h as p,n as m,t as h,z as g}from"./platform-CiUKDeXd.js";import{t as _}from"./runtimeAPIRegistry-C2VogTny.js";import{a as v,i as y,r as b}from"./vendor-zustand-CTekDqaS.js";import{ot as x,st as S}from"./vendor-base-ui-wXsskyKm.js";import{Ft as C,St as w}from"./gitApiHttp-Dd-FwgCq.js";import{i as T,t as E}from"./safeStorage-DTOhKN0V.js";import{n as D}from"./client-B_907PBv.js";import{n as O}from"./vendor-react-BkccXcWz.js";import{n as k,s as A,u as j}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{c as M,l as N}from"./yuriEvents-BFrD5fMU.js";import{r as P}from"./vendor-reactuses-core-DjKFMfz7.js";import{o as F}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{r as I}from"./useUIStore-C3ewjGgP.js";import{o as ee}from"./useMobileHtmlPreviewStore-BYunNOBo.js";import{a as te,t as ne}from"./types-DpcA-uDW.js";import{i as L,o as R}from"./session-startup-barrier-DT-hIBRf.js";import{n as z}from"./Icon-DmykXZL1.js";import{Ja as re,t as B}from"./ui-ee2iN869.js";import{n as ie,t as ae}from"./i18n-DXc6czdR.js";import{t as oe}from"./ScrollableOverlay-stxT7gLf.js";import{n as se,o as V,r as H,t as U}from"./dialog-BeFBA6ja.js";import{t as ce}from"./device-EIfSfSWk.js";import{a as le,c as ue,g as de,n as fe,r as pe,u as me}from"./gitApi-CoVwjIDy.js";import{n as he}from"./MarkdownRenderer-VvziwyJB.js";import{i as ge,n as _e,r as ve}from"./githubAuthQueries-DqregESf.js";import{c as ye,i as be,o as xe}from"./mcpQueries-Rmp1BKeo.js";import{c as Se,s as Ce}from"./usePluginsStore-Du4WlceO.js";var we=O(),W=x();function Te(e){let t=(0,we.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,W.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,W.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,W.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 Ee={},De=(e,t=n())=>JSON.stringify([t,be(e)]),Oe=(e,t,n)=>{if(!e[t]?.[n])return e;let r={...e[t]};return delete r[n],{...e,[t]:r}},G=e=>{let t=be(e);return t?D.getScopedApiClient(t):D.getApiClient()},K=e=>e?{location:{directory:e}}:void 0,q=new Map,J=(e,t)=>JSON.stringify([r(),De(t),e]),ke=async(e,t,n)=>{let r=(await e.mcp.list(K(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,...K(n)})).data},Y=e=>be(e===void 0?w.getState().currentDirectory:e),Ae=v()(b((e,t)=>({diagnosticsByDirectory:{},getDiagnosticForDirectory:e=>{let n=De(Y(e));return t().diagnosticsByDirectory[n]??Ee},clearDiagnostic:(t,n,r)=>{let i=De(Y(n),r);e(e=>({diagnosticsByDirectory:Oe(e.diagnosticsByDirectory,i,t)}))},connect:async(t,r)=>{let i=Y(r),a=n(),o=De(i,a),s=G(i);try{await s.mcp.connect({server:t,...K(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 ye(M,i,a),e(e=>({diagnosticsByDirectory:Oe(e.diagnosticsByDirectory,o,t)}))},disconnect:async(t,r)=>{let i=Y(r),a=n(),o=De(i,a);await G(i).mcp.disconnect({server:t,...K(i)}),await ye(M,i,a),e(e=>({diagnosticsByDirectory:Oe(e.diagnosticsByDirectory,o,t)}))},startAuth:async(e,t)=>{let n=Y(t),r=J(e,n),i=G(n),a=await ke(i,e,n),o=a.methods.find(e=>e.type===`oauth`);if(!o)throw Error(`MCP server "${e}" has no OAuth method`);if(r!==J(e,n))throw Error(`MCP authorization runtime changed`);let s=q.get(r);if(s&&(await i.integration.oauth.cancel({integrationID:s.integrationID,attemptID:s.attempt.attemptID,...K(n)}),q.delete(r)),r!==J(e,n))throw Error(`MCP authorization runtime changed`);let{data:c}=await i.integration.oauth.connect({integrationID:a.id,methodID:o.id,...K(n)});if(r!==J(e,n))throw Error(`MCP authorization runtime changed`);for(let[e,t]of q)t.attempt.time.expires<=Date.now()&&q.delete(e);return q.set(r,{integrationID:a.id,attempt:c}),c},authStatus:async(e,t)=>{let n=Y(t),r=J(e,n),i=q.get(r);if(!i)throw Error(`MCP authorization attempt not found`);let{data:a}=await G(n).integration.oauth.status({integrationID:i.integrationID,attemptID:i.attempt.attemptID,...K(n)});if(r!==J(e,n))throw Error(`MCP authorization runtime changed`);return a.status!==`pending`&&q.get(r)===i&&q.delete(r),a},completeAuth:async(e,t,r)=>{let i=Y(r),a=n(),o=J(e,i),s=q.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 G(i).integration.oauth.complete({integrationID:s.integrationID,attemptID:s.attempt.attemptID,code:t.trim(),...K(i)}),q.get(o)===s&&q.delete(o),o!==J(e,i))throw Error(`MCP authorization runtime changed`);await ye(M,i,a)},clearAuth:async(e,t)=>{let r=Y(t),i=n(),a=J(e,r),o=G(r),s=await ke(o,e,r);if(a!==J(e,r))throw Error(`MCP authorization runtime changed`);let c=q.get(a);c&&(await o.integration.oauth.cancel({integrationID:c.integrationID,attemptID:c.attempt.attemptID,...K(r)}),q.delete(a));let l=new Set(s.connections.flatMap(e=>e.type===`credential`?[e.id]:[]));for(let t of l){if(a!==J(e,r))throw Error(`MCP authorization runtime changed`);await o.credential.remove({credentialID:t})}if(a!==J(e,r))throw Error(`MCP authorization runtime changed`);await ye(M,r,i)},testConnection:async(t,r)=>{let i=Y(r),a=n(),o=De(i,a),s=G(i),c=xe(M,i,a)[t]?.status===`connected`,l,u;try{await s.mcp.connect({server:t,...K(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 ye(M,i,a))[t],f=d;if(!c&&d?.status===`connected`){try{await s.mcp.disconnect({server:t,...K(i)})}catch(e){u=`Connection test succeeded, but cleanup disconnect failed: ${e instanceof Error?e.message:`Disconnect failed`}`}await ye(M,i,a)}return l||e(e=>({diagnosticsByDirectory:Oe(e.diagnosticsByDirectory,o,t)})),{status:f??xe(M,i,a)[t],error:l,warning:u}}}))),X=e(S(),1),je=`https://yuri-updates.xiaobe.top/v1/update/check`,Me=`https://yuri-origin.xiaobe.top/v1/update/check`,Ne=`https://github.com/yee94/yuri/releases/latest`,Pe=`https://github.com/yee94/yuri/releases`,Fe=`https://testflight.apple.com/join/pN5SSHeg`,Ie=1e4;function Le(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 Re(e,t){let n=Le(e),r=Le(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 ze(){return[je,Me]}function Be(e,t,n=Date.now){let r=e-n();return r<=0||t<=0?null:Math.max(1,Math.ceil(r/t))}function Ve(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 He(e,t,n,r){try{if(m())try{let{CapacitorHttp:r}=await F(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 Ue(e,t){return e===`ios`?Fe:`${Pe}/download/v${t}/app-release.apk`}function We(e,t,n){if(typeof e.latestVersion!=`string`||e.latestVersion.trim().length===0)return null;let r=e.latestVersion.trim(),i=Re(r,t);if(i<0)return null;let a=typeof e.releaseNotesUrl==`string`&&e.releaseNotesUrl.trim().length>0?e.releaseNotesUrl.trim():`${Pe}/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():Ue(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 Ge(e,t,n,r){let i=await He(e,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify(Ve(t))},n,r);if(!i?.ok)return null;let a;try{a=await i.json()}catch{return null}return We(a,t.currentVersion,t.platform)}async function Ke(e,t,n,r){let i=await He(Ne,{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:Ne,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=Re(s,e),l=`${Pe}/tag/v${s}`;return{available:c>0,version:s,currentVersion:e,releaseUrl:l,downloadUrl:Ue(t,s)}}async function qe(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=ze(),a=r()+Ie;for(let[t,o]of i.entries()){let s=Be(a,i.length-t+1,r);if(s===null)break;let c=await Ge(o,e,s,n);if(c)return c}let o=Be(a,1,r);if(o!==null){let r=await Ke(t,e.platform,o,n);if(r)return r}return{available:!1,currentVersion:t,error:`Unable to check for mobile updates`}}function Je(){if(typeof window>`u`)return`unknown`;try{let{deviceType:e}=ce();return e}catch{return`unknown`}}function Ye(){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 Xe(){let e=h();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 Ze(e){let t=I.getState().reportUsage,n=new URLSearchParams({reportUsage:t?`true`:`false`});return n.set(`deviceClass`,Je()),n.set(`arch`,Ye()),n.set(`platform`,Xe()),e===`desktop`?(n.set(`appType`,`desktop-electron`),n.set(`instanceMode`,s()?`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 Qe(e,t){let n=t??`unknown`;try{let r=Ze(e),a=typeof window<`u`?window.__VSCODE_CONFIG__?.extensionVersion:void 0;t?r.set(`currentVersion`,t):e===`vscode`&&a&&r.set(`currentVersion`,a);let o=await i(`/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 $e(){return m()?`mobile`:o()?`desktop`:c()?`vscode`:g()?`web`:null}var et={checking:!1,available:!1,downloading:!1,downloaded:!1,info:null,progress:null,error:null,downloadError:null,downloadVersion:null,downloadChannel:null,runtimeType:null,lastChecked:null,nextCheckInSec:null,otaDecision:null,otaPhase:`idle`,otaDownloadSkipped:!1,lastOtaChannelOverride:null},tt=`yuri-client-update-download`,nt=e=>typeof e==`string`&&/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/.test(e);function rt(){try{let e=JSON.parse(T().getItem(tt)??`null`);return!e||e.runtimeType!==$e()||![`desktop`,`mobile`].includes(e.runtimeType)||!nt(e.version)||![null,`stable`,`beta`].includes(e.channel)?{}:{runtimeType:e.runtimeType,downloadVersion:e.version,downloadChannel:e.channel,downloadError:`update_interrupted`}}catch{return{}}}function it(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 at=0,ot=v()((e,t)=>({...et,...rt(),checkForUpdates:async()=>{let n=$e();if(!n)return null;let r=++at;e({checking:!0,error:null,runtimeType:n});try{let i=null,a=null;if(n===`desktop`){let n=I.getState().otaChannelOverride;t().lastOtaChannelOverride!==n&&e({downloaded:!1,downloading:!1,available:!1,info:null,otaDecision:null,progress:null,otaPhase:`checking`});let i=await p(n);if(r!==at||I.getState().otaChannelOverride!==n)return null;let a=i?.downloaded===!0,o=!a&&i?.downloading===!0;return e({checking:!1,available:i?.available??!1,downloaded:a,...a?{downloading:!1,progress:null,downloadError:null}:o?{downloading:!0,progress:i?.progress??null}:{},info:i,error:null,lastChecked:Date.now(),nextCheckInSec:i?.nextSuggestedCheckInSec??null,otaDecision:i?.otaDecision??null,otaPhase:a?`pending_restart`:o?`downloading`:i?.inAppApply?`available`:`idle`,lastOtaChannelOverride:n}),i?.nextSuggestedCheckInSec??null}if(n===`web`)i=await Qe(`web`),a=i?.nextSuggestedCheckInSec??null;else if(n===`vscode`)a=(await Qe(`vscode`))?.nextSuggestedCheckInSec??null;else if(n===`mobile`){let n=await te()??`unknown`,r=m()?_()?.mobileUpdates:void 0,o=I.getState().otaChannelOverride;if(r)try{let i=t().lastOtaChannelOverride!==o;e(i?{otaDecision:null,otaPhase:`checking`,downloaded:!1,otaDownloadSkipped:!1,progress:null,available:!1,info:null}:{otaPhase:`checking`});let a=await r.checkForOtaUpdate(o===`beta`||o===`stable`?{channelOverride:o}:void 0),s=it(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 ne)){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 qe({currentVersion:n,platform:Xe()===`ios`?`ios`:`android`,deviceClass:Je(),arch:Ye(),reportUsage:I.getState().reportUsage}),a=i?.nextSuggestedCheckInSec??null,e({checking:!1,available:i?.available??!1,info:i,error:i?.error??null,lastChecked:Date.now(),nextCheckInSec:a,otaDecision:null,otaPhase:`idle`}),a}return e({checking:!1,available:n===`vscode`?!1:i?.available??!1,info:n===`vscode`?null:i,error:n===`vscode`?null:i?.error??null,lastChecked:Date.now(),nextCheckInSec:a}),a}catch(i){return r===at&&e({checking:!1,error:i instanceof Error?i.message:`Failed to check for updates`,...n===`desktop`&&!t().downloaded?{otaPhase:`error`}:{}}),null}},downloadUpdate:async n=>{n?.resume===!0&&!t().info&&await t().checkForUpdates();let{available:r,runtimeType:i,otaDecision:a,downloading:o,downloaded:s}=t();if(o||s)return;let c=I.getState().otaChannelOverride,l=n?.resume===!0,u=l?t().downloadVersion:t().info?.version;if(l&&(t().downloadChannel!==c||u!==t().info?.version)){e({downloadError:`update_plan_changed`,error:`update_plan_changed`});return}if(i===`mobile`&&a?.primaryAction===`apply_ota`&&a.ota.bundle){if(o||s)return;let t=_()?.mobileUpdates;if(!t){e({error:`Mobile OTA updates are unavailable in this runtime`,downloadError:`Mobile OTA updates are unavailable in this runtime`,otaPhase:`error`});return}e({downloading:!0,error:null,downloadError:null,downloadVersion:u??null,downloadChannel:c,progress:null,otaPhase:`downloading`,otaDownloadSkipped:!1});try{let{skipped:n}=await t.downloadOtaUpdate(a.ota.bundle);await t.queueOtaUpdateForNextLaunch(),e({downloading:!1,downloaded:!0,downloadError:null,progress:null,otaPhase:`pending_restart`,otaDownloadSkipped:n})}catch(t){e({downloading:!1,error:t instanceof Error?t.message:`Failed to download update`,downloadError:t instanceof Error?t.message:`Failed to download update`,otaPhase:`error`})}return}if(!(i!==`desktop`||!r)){e({downloading:!0,error:null,downloadError:null,downloadVersion:u??null,downloadChannel:c,progress:null});try{let n=I.getState().otaChannelOverride,r=await p(n);if(n!==I.getState().otaChannelOverride)throw Error(`OTA channel changed`);if(u&&r?.version!==u)throw Error(`update_plan_changed`);if(!r?.available||r.manualUpdate)throw Error(`Update detected, but desktop package is not ready yet. Retry in a moment.`);if(e(e=>({info:e.info?{...e.info,...r,body:r.body||e.info.body,available:e.info.available}:r})),r.downloaded||t().downloaded){e({downloading:!1,downloaded:!0,progress:null});return}if(r.downloading&&e({downloading:!0,progress:r.progress??{downloaded:0}}),!await d(t=>{e({progress:t})}))throw Error(`Failed to download update`);e({downloading:!1,downloaded:!0,progress:null,otaPhase:`pending_restart`})}catch(t){e({downloading:!1,error:t instanceof Error?t.message:`Failed to download update`,downloadError:t instanceof Error?t.message:`Failed to download update`})}}},subscribeDesktopUpdateEvents:async()=>{if(!o())return()=>{};let n=[],r=await a(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,downloadError:null})});r&&n.push(r);let i=await l(t=>{t.downloaded&&e({downloading:!1,downloaded:!0,available:!0,progress:null,downloadError: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=_()?.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 u())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`,downloadError:t??`Failed to download update`,otaPhase:`error`})},dismiss:()=>{let n=t();n.otaPhase===`pending_restart`||n.downloading||n.downloadError||e({available:!1,downloaded:!1,info:null,otaDecision:null,otaPhase:`idle`,otaDownloadSkipped:!1})},reset:()=>{e(et)}}));ot.subscribe((e,t)=>{if(e.downloading===t.downloading&&e.downloaded===t.downloaded&&e.downloadError===t.downloadError&&e.downloadVersion===t.downloadVersion&&e.downloadChannel===t.downloadChannel)return;let n=T();(e.downloading||e.downloadError)&&!e.downloaded&&nt(e.downloadVersion)?n.setItem(tt,JSON.stringify({version:e.downloadVersion,channel:e.downloadChannel,runtimeType:e.runtimeType})):n.removeItem(tt)});var st=8e3,Z=e=>!!(e&&![`succeeded`,`failed`].includes(e.status));function Q(e,t){if(e!==n()||t!==r())throw Error(`Stale update runtime`)}var $=(e=n(),t=r(),a)=>({queryKey:[e,`host-update`,t,a??`current`],queryFn:async({signal:n})=>{Q(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 i(`/api/system/update${a?`?channel=${a}`:``}`,{headers:{Accept:`application/json`},signal:r.signal});if([404,501].includes(n.status))throw Error(`host_update_unsupported`);let o=await n.json();if(Q(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`))},st)})])}finally{s!==void 0&&clearTimeout(s),n.removeEventListener(`abort`,o)}},staleTime:6e4,retry:!1}),ct=(e=n(),t=r(),i)=>M.getQueryData($(e,t,i).queryKey),lt=(e=n(),t=r(),i)=>{let a=ct(e,t,i);return M.fetchQuery({...$(e,t,i),staleTime:a?.checkError||Z(a?.operation)?0:6e4})},ut=(e=n(),t=r(),i)=>M.fetchQuery({...$(e,t,i),staleTime:0}),dt=(e,t,n)=>{let r=(0,we.c)(6),i;r[0]!==n||r[1]!==t||r[2]!==e?(i=$(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:mt,refetchIntervalInBackground:!1},r[4]=i,r[5]=a),A(a)};async function ft(e,t,n){if(Q(t,n),!e.update)throw Error(`No update plan`);let r=await i(`/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(Q(t,n),!r.ok)throw Error(`Host update was not accepted`);let a=await r.json();if(typeof a.operation?.id!=`string`)throw Error(`Invalid update operation`);return a.operation}async function pt(e,t,n){Q(t,n);let r=await ut(t,n,e.channel);Q(t,n);let i=r.operation;if(i?.id===e.id&&i.version===e.version&&i.channel===e.channel&&i.kind===e.kind&&(Z(i)||i.status===`succeeded`&&r.currentVersion===e.version))return M.setQueryData($(t,n).queryKey,r),i;if(r.checkError||r.update?.version!==e.version||r.update.kind!==e.kind)throw Error(`update_plan_changed`);let a=await ft(r,t,n);return Q(t,n),M.setQueryData($(t,n).queryKey,e=>({...e??r,operation:a})),a}function mt(e){return Z(e.state.data?.operation)?2e3:e.state.error?.message===`host_update_unsupported`?!1:e.state.error?15e3:3e5}function ht(e){let t=new Date(`${e}T00:00:00`);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(ie(),{year:`numeric`,month:`short`,day:`numeric`}).format(t)}function gt(e){return e.replace(/^## \[[^\]]+\] - \d{4}-\d{2}-\d{2}\s*\n?/,``).trim()}function _t(e){return e.replace(/(^|[^a-zA-Z0-9])@([a-zA-Z0-9-]+)/g,`$1[@$2](https://github.com/$2)`)}function vt(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 yt(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 bt(e){let t=(0,we.c)(67),{open:n,onOpenChange:r,model:i,onAction:a}=e,{t:o}=ae(),[s,c]=(0,X.useState)(!1),l=P(St),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=P(u),f;t[2]===i.fallbackCommand?f=t[3]:(f=async()=>{i.fallbackCommand&&(await re(i.fallbackCommand)).ok&&(c(!0),setTimeout(()=>c(!1),2e3))},t[2]=i.fallbackCommand,t[3]=f);let p=P(f),m;if(t[4]!==i.body||t[5]!==o){bb0:{let e=i.body?.trim();if(!e){m=null;break bb0}let n=yt(e);if(!n.length){m={kind:`raw`,title:o(`updateDialog.changelog.title`),content:_t(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(xt).map(t=>({version:t.version,dateLabel:ht(t.date),content:_t(gt(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=R(`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,W.jsx)(z,{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,W.jsxs)(V,{className:`flex items-center gap-2`,children:[y,(0,W.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,W.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,W.jsx)(`span`,{className:`text-muted-foreground/75`,children:i.currentVersion}),i.currentVersion&&i.version&&(0,W.jsx)(`span`,{className:`text-muted-foreground/40`,children:`→`}),i.version&&(0,W.jsx)(`span`,{className:`font-medium text-[var(--primary-base)]`,children:i.version}),i.methodLabel&&(0,W.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,W.jsx)(H,{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,W.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,W.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,W.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,W.jsxs)(`section`,{className:R(`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,W.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,W.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--primary-base)]`,"aria-hidden":`true`}),(0,W.jsx)(`h3`,{className:`typography-ui-caption font-medium text-muted-foreground`,children:h.title})]}),(0,W.jsx)(oe,{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,W.jsx)(`div`,{className:`break-words px-3.5 py-2 text-[13px] leading-[1.65] text-foreground sm:px-4 sm:text-sm [&_.markdown-content]:leading-[1.65] [&_.markdown-content>:first-child]:!mt-0 [&_.markdown-content>:first-child>:first-child]:!mt-0 [&_.markdown-content>:last-child]:!mb-0 [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline`,onClickCapture:d,children:(0,W.jsx)(he,{content:h.content,disableLinkSafety:!0,enableFileReferences:!1})}):(0,W.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:h.sections.map(e=>(0,W.jsxs)(`div`,{className:`px-3.5 py-2 sm:px-4`,children:[(0,W.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-center gap-x-2 gap-y-1 sm:mb-3`,children:[(0,W.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,W.jsx)(`span`,{className:`text-[11px] leading-4 text-muted-foreground/75 sm:text-xs`,children:e.dateLabel})]}),(0,W.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,W.jsx)(he,{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,W.jsxs)(`div`,{className:`space-y-2 mt-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 typography-meta text-muted-foreground`,children:[(0,W.jsx)(z,{name:`terminal`,className:`h-4 w-4`}),(0,W.jsx)(`span`,{children:o(`updateDialog.fallback.updateViaTerminal`)})]}),(0,W.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,W.jsx)(`code`,{className:`flex-1 font-mono text-sm text-foreground overflow-x-auto whitespace-nowrap`,children:i.fallbackCommand}),(0,W.jsx)(`button`,{onClick:p,className:R(`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,W.jsx)(z,{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,W.jsxs)(`div`,{role:`status`,className:R(`space-y-2`,i.stableLayout&&`min-h-9 shrink-0`),children:[(0,W.jsxs)(`div`,{className:`flex h-5 items-center justify-between gap-3`,children:[(0,W.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,W.jsx)(z,{name:`loader`,className:`h-3.5 w-3.5 shrink-0 animate-spin text-[var(--primary-base)]`}),(0,W.jsx)(`span`,{className:`truncate`,title:i.status.label,children:i.status.label})]}),i.status.progress!=null&&(0,W.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,W.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-[var(--surface-subtle)] sm:h-1.5`,children:i.status.progress==null?(0,W.jsx)(`div`,{className:`h-full w-1/3 animate-pulse rounded-full bg-[var(--primary-base)]/60`}):(0,W.jsx)(`div`,{className:`h-full rounded-full bg-[var(--primary-base)] transition-[width] duration-500`,style:{width:`${i.status.progress}%`}})}),i.status.detail&&(0,W.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,W.jsx)(`div`,{role:`alert`,className:`p-3 mt-4 bg-[var(--status-error-background)] border border-[var(--status-error-border)] rounded-lg`,children:(0,W.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,W.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,W.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,W.jsx)(z,{name:`check`,className:`h-4 w-4 shrink-0`}),(0,W.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,W.jsxs)(`div`,{className:`mt-4 flex shrink-0 items-center justify-between gap-4`,children:[i.releaseLink&&(0,W.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,W.jsx)(z,{name:`external-link`,className:`h-4 w-4`}),i.releaseLink.label]}),(0,W.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-nowrap items-center justify-end gap-2`,children:i.actions.map(e=>(0,W.jsxs)(L,{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,W.jsx)(z,{name:e.icon,className:R(`h-4 w-4`,e.loading&&`animate-spin`)}),(0,W.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 F;t[57]!==C||t[58]!==j||t[59]!==M||t[60]!==N||t[61]!==v?(F=(0,W.jsxs)(se,{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]=F):F=t[62];let I;return t[63]!==n||t[64]!==F||t[65]!==g?(I=(0,W.jsx)(U,{open:n,onOpenChange:g,children:F}),t[63]=n,t[64]=F,t[65]=g,t[66]=I):I=t[66],I}function xt(e,t){return vt(e.version,t.version)}function St(e){ee(e)}var Ct=`https://github.com/yee94/yuri/releases`,wt=2e3,Tt=6e5,Et=e=>e.transport===n()&&e.generation===r();async function Dt(e,t){try{if(!Et(t))return{success:!1};let n=await lt(t.transport,t.generation);return!Et(t)||!e||!n.supported||n.update?.version!==e||n.update.rollback?{success:!1}:(await ft(n,t.transport,t.generation),{success:!0,autoRestart:!0})}catch(e){return{success:!1,error:e instanceof Error?e.message:void 0}}}async function Ot(e,t,n=Math.ceil(Tt/wt),r=wt){for(let i=0;i<n;i++){if(!Et(t))return!1;try{let n=await ut(t.transport,t.generation);if(n.operation?.status===`failed`)return!1;if(n.currentVersion===e&&n.operation?.status===`succeeded`&&Et(t))return!0}catch{}await new Promise(e=>setTimeout(e,r))}return!1}var kt=e=>{let t=(0,we.c)(107),{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}=ae(),[g,_]=(0,X.useState)(`idle`),[v,y]=(0,X.useState)(null),b=ot(At),x=o?.releaseUrl||(o?.version?`${Ct}/tag/v${o.version}`:Ct),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&&ot.getState().dismiss(),a(e)},t[0]=c,t[1]=E,t[2]=a,t[3]=A):A=t[3];let j=P(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,X.useEffect)(M,N);let F;t[7]!==o?.version||t[8]!==h?(F=async()=>{let e={transport:n(),generation:r()};_(`updating`),y(null);let t=await Dt(o?.version,e);if(!Et(e))return;if(!t.success){_(`error`),y(t.error||h(`updateDialog.error.updateFailed`));return}t.autoRestart&&(_(`restarting`),await new Promise(jt)),_(`reconnecting`);let i=await Ot(o?.version,e);Et(e)&&(i?window.location.reload():(_(`error`),y(h(`updateDialog.error.takingLonger`))))},t[7]=o?.version,t[8]=h,t[9]=F):F=t[9];let I=P(F),te;t[10]!==I||t[11]!==w||t[12]!==d||t[13]!==a||t[14]!==f||t[15]!==S||t[16]!==x?(te=e=>{bb107:switch(e){case`download`:d();break bb107;case`restart`:f();break bb107;case`later`:ot.getState().dismiss(),a(!1);break bb107;case`open-external`:{let e=w?S:x;e&&ee(e);break bb107}case`web-update`:I()}},t[10]=I,t[11]=w,t[12]=d,t[13]=a,t[14]=f,t[15]=S,t[16]=x,t[17]=te):te=t[17];let ne=P(te),L;if(t[18]!==c||t[19]!==s||t[20]!==E||t[21]!==D||t[22]!==w||t[23]!==C||t[24]!==O||t[25]!==T||t[26]!==h){if(L=[],!C&&(!w||E)){if(!D&&!c&&!s){let e;t[28]!==E||t[29]!==h?(e=h(E?`updateDialog.actions.applyOtaNow`:`updateDialog.actions.downloadUpdate`),t[28]=E,t[29]=h,t[30]=e):e=t[30];let n;t[31]===e?n=t[32]:(n={id:`download`,icon:`download`,label:e},t[31]=e,t[32]=n),L.push(n)}if(D&&!c&&!s){let e;t[33]===h?e=t[34]:(e=h(`updateDialog.actions.openMobileUpdate`),t[33]=h,t[34]=e);let n;t[35]===e?n=t[36]:(n={id:`open-external`,icon:`external-link`,label:e},t[35]=e,t[36]=n),L.push(n)}if(s){let e;t[37]===h?e=t[38]:(e=h(`updateDialog.status.downloading`),t[37]=h,t[38]=e);let n;t[39]===e?n=t[40]:(n={id:`downloading`,icon:`loader`,loading:!0,disabled:!0,label:e},t[39]=e,t[40]=n),L.push(n)}if(c){if(E){let e;t[41]===h?e=t[42]:(e=h(`updateDialog.actions.later`),t[41]=h,t[42]=e);let n;t[43]===e?n=t[44]:(n={id:`later`,variant:`ghost`,label:e},t[43]=e,t[44]=n),L.push(n)}let e;t[45]===h?e=t[46]:(e=h(`updateDialog.actions.restartToUpdate`),t[45]=h,t[46]=e);let n;t[47]===e?n=t[48]:(n={id:`restart`,icon:`restart`,label:e},t[47]=e,t[48]=n),L.push(n)}}if(w&&!E&&T){let e;t[49]===h?e=t[50]:(e=h(`updateDialog.actions.openMobileUpdate`),t[49]=h,t[50]=e);let n;t[51]===e?n=t[52]:(n={id:`open-external`,icon:`external-link`,label:e},t[51]=e,t[52]=n),L.push(n)}if(C){let e;t[53]!==O||t[54]!==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[53]=O,t[54]=h,t[55]=e):e=t[55],L.push(e)}t[18]=c,t[19]=s,t[20]=E,t[21]=D,t[22]=w,t[23]=C,t[24]=O,t[25]=T,t[26]=h,t[27]=L}else L=t[27];let R;t[56]!==h||t[57]!==g?(R=h(g===`restarting`||g===`reconnecting`?`updateDialog.header.updating`:`updateDialog.header.updateAvailable`),t[56]=h,t[57]=g,t[58]=R):R=t[58];let z=o?.currentVersion,re=o?.version,B=o?.body,ie=!O,oe=u||v,se=C&&g===`error`?o?.updateCommand||`yuri update`:void 0,V;t[59]!==c||t[60]!==E||t[61]!==b||t[62]!==h?(V=E&&c&&b?h(`updateDialog.status.otaBundleReused`):void 0,t[59]=c,t[60]=E,t[61]=b,t[62]=h,t[63]=V):V=t[63];let H;t[64]!==w||t[65]!==k||t[66]!==T?(H=(!w||T)&&k?{url:k,label:`GitHub`}:void 0,t[64]=w,t[65]=k,t[66]=T,t[67]=H):H=t[67];let U;if(t[68]!==L||t[69]!==s||t[70]!==E||t[71]!==w||t[72]!==C||t[73]!==O||t[74]!==l||t[75]!==h||t[76]!==B||t[77]!==ie||t[78]!==oe||t[79]!==se||t[80]!==V||t[81]!==H||t[82]!==R||t[83]!==z||t[84]!==re||t[85]!==g){if(U={title:R,currentVersion:z,version:re,body:B,hideChangelog:O,dismissible:ie,error:oe,fallbackCommand:se,notice:V,releaseLink:H,actions:L},C&&O){let e;t[87]!==h||t[88]!==g?(e=h(g===`updating`?`updateDialog.status.installingUpdate`:g===`restarting`?`updateDialog.status.serverRestarting`:`updateDialog.status.waitingForServer`),t[87]=h,t[88]=g,t[89]=e):e=t[89];let n;t[90]===h?n=t[91]:(n=h(`updateDialog.status.autoReloadHint`),t[90]=h,t[91]=n);let r;t[92]!==e||t[93]!==n?(r={kind:`activity`,label:e,detail:n},t[92]=e,t[93]=n,t[94]=r):r=t[94],U.status=r}if(!C&&(!w||E)&&s){let e;t[95]===h?e=t[96]:(e=h(`updateDialog.status.downloadingPayload`),t[95]=h,t[96]=e);let n;t[97]===l?n=t[98]:(n=l?.total?Math.round(l.downloaded/l.total*100):0,t[97]=l,t[98]=n);let r;t[99]!==e||t[100]!==n?(r={kind:`download`,label:e,progress:n},t[99]=e,t[100]=n,t[101]=r):r=t[101],U.status=r}t[68]=L,t[69]=s,t[70]=E,t[71]=w,t[72]=C,t[73]=O,t[74]=l,t[75]=h,t[76]=B,t[77]=ie,t[78]=oe,t[79]=se,t[80]=V,t[81]=H,t[82]=R,t[83]=z,t[84]=re,t[85]=g,t[86]=U}else U=t[86];let ce;return t[102]!==ne||t[103]!==j||t[104]!==U||t[105]!==i?(ce=(0,W.jsx)(bt,{open:i,onOpenChange:j,model:U,onAction:ne}),t[102]=ne,t[103]=j,t[104]=U,t[105]=i,t[106]=ce):ce=t[106],ce};function At(e){return e.otaDownloadSkipped}function jt(e){return setTimeout(e,2e3)}function Mt(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 Nt(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=Z(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:Mt(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 Pt(){let e=(0,we.c)(7),{t:i}=ae(),a=X.useSyncExternalStore(t,n,n),o=X.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,W.jsx)(Ft,{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 Ft({version:e,transport:t,generation:i,itemId:a,channel:o}){let{t:s}=ae(),c=j(),[l,u]=X.useState(!1),d=I(e=>e.otaChannelOverride),f=o??d??void 0,p=dt(t,i,f),m=p.data,h=m?.operation,g=Z(h),_=JSON.stringify([t,i,f??`current`]),[v,y]=X.useState(null);m?.update&&(v?.scope!==_||v.update!==m.update)&&y({scope:_,update:m.update});let b=k({mutationFn:({plan:e})=>ft(e,t,i),onSuccess:(e,a)=>{t===n()&&i===r()&&c.setQueryData($(t,i,a.channel).queryKey,t=>t&&{...t,operation:e})},onSettled:(e,a,o)=>{t===n()&&i===r()&&c.invalidateQueries({queryKey:$(t,i,o.channel).queryKey,exact:!0})}}),[x,S]=X.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`);X.useEffect(()=>{!C||p.isError||t!==n()||i!==r()||(S(null),u(!1),B.success(w,{id:`host-update:${t}:${i}:${x}`}))},[C,p.isError,t,i,x,w]);let T=X.useRef(null),E=P(()=>_),D=P(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`?B.info(s(`settings.yuri.about.hostUpdate.unsupported`)):B.error(s(`settings.yuri.about.toast.checkFailed`));return}Z(a.data.operation)?u(!0):a.data.supported?a.data.update?u(!0):(u(!1),B.success(s(`settings.yuri.about.toast.latestVersion`))):B.info(s(`settings.yuri.about.hostUpdate.unsupported`))}finally{T.current===e&&(T.current=null)}}),O=m?.supported===!1||!g&&p.error?.message===`host_update_unsupported`,A=p.isError||!!m?.checkError,M=b.isError&&b.variables?.channel===f,N=Nt(m,{versionFallback:e,checking:p.isPending?`initial`:p.isFetching?`refresh`:!1,submitting:b.isPending,failure:O?`unsupported`:p.isError&&(g||M)?`disconnected`:A||M?`check`:null,completed:C,updateDetails:v?.scope===_?v.update:void 0},s),F=P(e=>{e===`confirm`&&m?.update&&b.mutate({plan:m,channel:f})});return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,"data-settings-item":a,children:[(0,W.jsxs)(`span`,{className:`relative typography-ui-label font-mono text-foreground text-right`,children:[m?.currentVersion??e,m?.update&&!g&&(0,W.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,W.jsx)(L,{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,W.jsx)(z,{name:g||p.isFetching?`loader`:m?.update?`download`:`refresh`,className:g||p.isFetching?`size-4 animate-spin`:`size-4`})})]}),(0,W.jsx)(bt,{open:l,onOpenChange:u,model:N,onAction:F})]})}var It=e=>e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e),Lt=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(`/`)}`},Rt=e=>Lt(`${e.replace(/\\/g,`/`)}/..`),zt=e=>{try{let t=decodeURIComponent(new URL(e).pathname);return/^\/[A-Za-z]:\//.test(t)?t.slice(1):t}catch{return null}};function Bt(e,t){if(e.startsWith(`file://`)){let t=zt(e);return t?{kind:`local`,path:Lt(t)}:null}return e.startsWith(`./`)||e.startsWith(`../`)?t?{kind:`local`,path:Lt(`${Rt(t)}/${e}`)}:null:It(e)?{kind:`local`,path:Lt(e)}:{kind:`package`,target:e}}function Vt(e){return e?{kind:`local`,path:Lt(e)}:null}var Ht=(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=Lt(t.source.path);return n===e.path||n.startsWith(`${e.path}/`)};function Ut(e,t){return t.filter(t=>Ht(e,t))}function Wt(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 Gt(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 Kt(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 qt(){let e=(0,we.c)(5),t=Se(),n=Ce(),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=Gt(Ut(r,a));i.kind===`failed`&&t.push({id:e,label:n,error:i.error})};for(let e of r??[])n(e.id,e.spec,Bt(e.spec,e.sourcePath));for(let e of i??[])n(e.id,e.fileName,Vt(e.absolutePath));e[1]=r,e[2]=i,e[3]=a,e[4]=t}else t=e[4];o=t}return o}var Jt=e=>e instanceof Error&&e.name===`CancelledError`,Yt=v(()=>({setStatus:e=>ge(M,e),refreshStatus:async(e,t)=>{let r=n();t?.force&&await M.cancelQueries({queryKey:N.github.auth(r),exact:!0});try{return await ve(M,e,r)}catch(e){if(Jt(e))return _e(M,r);throw e}}})),Xt=v()(b(y((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 ue(),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 me();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 le()}),!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=_()?.settings;if(e)try{n=t(((await e.load())?.settings||{}).defaultGitIdentityId)}catch{}}if(n===null)try{let e=await i(`/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 C({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 fe(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 de(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 pe(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:E(),partialize:e=>({selectedProfileId:e.selectedProfileId})}),{name:`git-identities-store`}));typeof window<`u`&&(window.__zustand_git_identities_store__=Xt);var Zt=(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,Qt=(e,t,n)=>{Zt(e.get(t),n)&&e.set(t,n)},$t=e=>{let t=e;return f(t.directory)??f(t.project?.worktree)},en=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)},tn=(e,t,n,r,i=[])=>{let a=new Map,o=new Map;for(let e of t){let t=f(e.normalizedPath);if(!t)continue;let n=o.get(t);(!n||e.id.localeCompare(n.id)<0)&&o.set(t,e),Qt(a,t,{projectId:e.id,projectRoot:t,scopeDirectory:t,kind:`project`})}if(!r)for(let[e,t]of n){let n=f(e),r=n?o.get(n):void 0;if(!(!r||!n))for(let e of t){let t=f(e.path);t&&Qt(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,p=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=en(n)}for(let e of t)s.set(e,i);return i},m=(e,t,n)=>{for(let r of e){let e=p($t(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 m(e,l,d),m(i,u),{bySessionId:c,sessionsByProject:l,archivedSessionsByProject:u,sessionsByScope:d,directoryResolutions:s.size}};export{ot as _,Bt as a,Wt as c,Pt as d,Ft as f,pt as g,Z as h,qt as i,Gt as l,$ as m,Xt as n,Ut as o,kt as p,Yt as r,Vt as s,tn as t,Kt as u,Ae as v,Te as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,n as t}from"./runtime-switch-DEPKHgdL.js";import{n}from"./runtime-fetch-V-iMWR8t.js";import{Vt as r}from"./gitApiHttp-Dd-FwgCq.js";import{n as i}from"./vendor-react-BkccXcWz.js";import{s as a}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{c as o}from"./yuriEvents-BFrD5fMU.js";import{Ha as s}from"./ui-
|
|
1
|
+
import{i as e,n as t}from"./runtime-switch-DEPKHgdL.js";import{n}from"./runtime-fetch-V-iMWR8t.js";import{Vt as r}from"./gitApiHttp-Dd-FwgCq.js";import{n as i}from"./vendor-react-BkccXcWz.js";import{s as a}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{c as o}from"./yuriEvents-BFrD5fMU.js";import{Ha as s}from"./ui-ee2iN869.js";var c=i(),l=(t=e())=>({queryKey:[t,`speech`,`settings`],queryFn:({signal:e})=>r(e,async e=>{let t=await n(`/api/voice/settings`,{signal:e});if(!t.ok)throw Error(`Unable to load speech settings`);return s(await t.json())}),staleTime:3e4,networkMode:`always`,retry:1,refetchOnWindowFocus:!0}),u=()=>{let e=(0,c.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=l(),e[0]=t):t=e[0],a(t)};async function d(i,a=t(),c=e()){let{queryKey:u}=l(c);if(await o.cancelQueries({queryKey:u,exact:!0}),a!==t())throw Error(`Runtime changed`);let d=await r(new AbortController().signal,async e=>{let t=await n(`/api/voice/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i),signal:e});if(!t.ok)throw Error(`Unable to save speech settings`);return s(await t.json())});if(a!==t()||c!==e()||(await o.cancelQueries({queryKey:u,exact:!0}),a!==t()))throw Error(`Runtime changed`);return o.setQueryData(u,d),d}export{l as n,u as r,d as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-capacitor-app-B5H_XtmE.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{n as e}from"./platform-CiUKDeXd.js";import{o as t}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";var n=async()=>{if(!e())return null;let{App:n}=await t(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2])),{id:r}=await n.getInfo();if(typeof r!=`string`||!/^[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+$/.test(r))throw Error(`Native app identity unavailable`);return r},r=e=>typeof e==`string`&&e.trim().length>0?e.trim():null,i=()=>r(`0.3.
|
|
2
|
+
import{n as e}from"./platform-CiUKDeXd.js";import{o as t}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";var n=async()=>{if(!e())return null;let{App:n}=await t(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2])),{id:r}=await n.getInfo();if(typeof r!=`string`||!/^[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+$/.test(r))throw Error(`Native app identity unavailable`);return r},r=e=>typeof e==`string`&&e.trim().length>0?e.trim():null,i=()=>r(`0.3.4`),a=(e,t)=>r(t)||r(e),o=(e,t)=>{let n=r(e);return n?typeof t!=`number`||!Number.isFinite(t)?n:`${n} (${t})`:null},s=async()=>{let n=i();if(!e())return n;try{let{App:e}=await t(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2]));return a((await e.getInfo()).version,n)}catch{return n}},c=async()=>{if(!e())return null;try{let{App:e}=await t(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2])),n=await e.getInfo(),r=typeof n.build==`string`?n.build.trim():``;if(r.length===0)return null;let i=Number.parseInt(r,10);return Number.isFinite(i)?i:null}catch{return null}},l=class extends Error{code=`mobile_updates_unsupported`;constructor(e=`Mobile OTA updates are only available in the Capacitor native app`){super(e),this.name=`MobileUpdatesUnsupportedError`}};export{s as a,c as i,o as n,n as r,l as t};
|