@yuriai/web 0.2.6 → 0.2.8-beta.1

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.
Files changed (73) hide show
  1. package/README.md +7 -0
  2. package/dist/assets/{AssistantView-Ct7V8lpF.js → AssistantView-Df-G2DX8.js} +3 -3
  3. package/dist/assets/{DiagramView-Ch2D2gUQ.js → DiagramView-BoVqJRQb.js} +1 -1
  4. package/dist/assets/{GuiPluginSurface-sdtt33qQ.js → GuiPluginSurface-DxLoeTDb.js} +1 -1
  5. package/dist/assets/MarkdownRenderer-DYi_qpYy.js +2 -0
  6. package/dist/assets/{MarkdownRendererImpl-CtfnAdo-.js → MarkdownRendererImpl-CMxRMFqp.js} +1 -1
  7. package/dist/assets/{MarkstreamRendererImpl-CWtvbZSX.js → MarkstreamRendererImpl-DQ4urBZW.js} +1 -1
  8. package/dist/assets/{MobileDetailNavigation-CUx-H4fe.js → MobileDetailNavigation-C4fJlKdu.js} +1 -1
  9. package/dist/assets/{MobileShareBridge-DUwPWQNz.js → MobileShareBridge-DLC-TdRy.js} +1 -1
  10. package/dist/assets/{MobileTabPageHeader-BtLdnDa3.js → MobileTabPageHeader-CMbbtHh7.js} +1 -1
  11. package/dist/assets/{MultiRunWindow-Gs-5PM3Z.js → MultiRunWindow-Cwp8-_Wh.js} +1 -1
  12. package/dist/assets/{SettingsView-BJy3bKbz.js → SettingsView-CYDk0wpN.js} +1 -1
  13. package/dist/assets/{SettingsWindow-w3K1Dbo1.js → SettingsWindow-Vuzphf9b.js} +1 -1
  14. package/dist/assets/{TerminalView-DnmN2KHj.js → TerminalView-Dhalx6_Z.js} +1 -1
  15. package/dist/assets/{ToolOutputDialog-Ctr_rqwb.js → ToolOutputDialog-DBxSxWNh.js} +1 -1
  16. package/dist/assets/{appThemeRegistry-3MgV1x6f.js → appThemeRegistry-JEhMXHGF.js} +1 -1
  17. package/dist/assets/{capgoAdapter-CpthNQYY.js → capgoAdapter-BgD0wyhC.js} +1 -1
  18. package/dist/assets/{fileMentionTouchSelection-1havvnZN.js → fileMentionTouchSelection-BQdfRBkk.js} +1 -1
  19. package/dist/assets/{gitApi-Bw4AQDuA.js → gitApi-DhDVqj9b.js} +1 -1
  20. package/dist/assets/{insertionBoundaries-_8AmjaTs.js → insertionBoundaries-BMe1F3uB.js} +1 -1
  21. package/dist/assets/{main-C09TKUe7.js → main-CfOYzhn0.js} +4 -4
  22. package/dist/assets/{main-C5PgzX4P.js → main-DXlMu2LF.js} +2 -2
  23. package/dist/assets/{mcpQueries-B-cYFZaO.js → mcpQueries-vxcQAIGB.js} +1 -1
  24. package/dist/assets/{miniChat-C_az-fSk.js → miniChat-D48iGEEW.js} +2 -2
  25. package/dist/assets/{mobile-CnXTR6QC.js → mobile-Cy5qSiDY.js} +2 -2
  26. package/dist/assets/{mobileBackNavigation-DSDlOhh6.js → mobileBackNavigation-QtBK9OSb.js} +1 -1
  27. package/dist/assets/{multirun-DgLVkagL.js → multirun-BR9a6EBo.js} +1 -1
  28. package/dist/assets/{native-config-w5ntuSb5.js → native-config-CHySeHif.js} +1 -1
  29. package/dist/assets/{projectMeta-OMvGIxob.js → projectMeta-Bn2vBNDe.js} +1 -1
  30. package/dist/assets/{readiness-6XMJtgLY.js → readiness-BAssoNVf.js} +1 -1
  31. package/dist/assets/{renderElectronMiniChatApp-rvO-rcnc.js → renderElectronMiniChatApp-B9Kci_8q.js} +2 -2
  32. package/dist/assets/{renderMobileApp-DheZQr5N.js → renderMobileApp-CBivL8Ps.js} +4 -4
  33. package/dist/assets/{runtimeConfig-cAbdKbv6.js → runtimeConfig-COdEwlK-.js} +1 -1
  34. package/dist/assets/{runtimeEndpointReset-CPsJLvK2.js → runtimeEndpointReset-D3x76Qpf.js} +3 -3
  35. package/dist/assets/{sessionChangeSummary-BEB6JZpN.js → sessionChangeSummary-Dtgq0CWg.js} +1 -1
  36. package/dist/assets/{sessionLookup-BI5wTzCJ.js → sessionLookup--Wlr3e8X.js} +1 -1
  37. package/dist/assets/{speechSettingsQueries-DZ9a20QR.js → speechSettingsQueries-D3fc_4Iy.js} +1 -1
  38. package/dist/assets/types-D8_26ZKT.js +2 -0
  39. package/dist/assets/{useAppFontEffects-CKCYZ3VJ.js → useAppFontEffects-DLT9jVl1.js} +6 -6
  40. package/dist/assets/{useDesktopWindowControlsLayout-CloJ_VZ3.js → useDesktopWindowControlsLayout-BNAZWH9L.js} +1 -1
  41. package/dist/assets/{useEffectiveDirectory-CuajC8G4.js → useEffectiveDirectory-D2_-KCB7.js} +1 -1
  42. package/dist/assets/{useMobileNavigationStore-07uYrwvK.js → useMobileNavigationStore-DJwk64Po.js} +3 -3
  43. package/dist/assets/{useWorkerHighlightedLines-2Vw7Hzud.js → useWorkerHighlightedLines-k48txabk.js} +1 -1
  44. package/dist/index.html +5 -5
  45. package/dist/mini-chat.html +5 -5
  46. package/dist/mobile.html +5 -5
  47. package/package.json +9 -4
  48. package/server/index.js +3 -3
  49. package/server/lib/assistants/DOCUMENTATION.md +12 -1
  50. package/server/lib/assistants/contact-tools.js +2 -2
  51. package/server/lib/assistants/harness.js +21 -17
  52. package/server/lib/assistants/harness.test.js +19 -23
  53. package/server/lib/assistants/memory.http.test.js +2 -2
  54. package/server/lib/assistants/routes.js +1 -3
  55. package/server/lib/llm/DOCUMENTATION.md +116 -161
  56. package/server/lib/llm/bridge-client.js +60 -0
  57. package/server/lib/llm/bridge-client.test.js +35 -0
  58. package/server/lib/llm/bridge-contract.js +24 -0
  59. package/server/lib/llm/bridge-plugin.bundle.js +1136 -0
  60. package/server/lib/llm/bridge-plugin.js +127 -0
  61. package/server/lib/llm/bridge-plugin.test.js +164 -0
  62. package/server/lib/llm/completions.js +42 -18
  63. package/server/lib/llm/completions.test.js +8 -4
  64. package/server/lib/llm/generate.js +43 -728
  65. package/server/lib/llm/generate.test.js +62 -1063
  66. package/server/lib/llm/routes.js +0 -2
  67. package/server/lib/package-manager.js +1 -1
  68. package/server/lib/small-model/DOCUMENTATION.md +11 -17
  69. package/server/lib/small-model/index.js +5 -4
  70. package/dist/assets/MarkdownRenderer-C1giOHSB.js +0 -2
  71. package/dist/assets/types-BihDq7ZW.js +0 -2
  72. package/server/lib/llm/temp-directory.js +0 -58
  73. package/server/lib/llm/temp-directory.test.js +0 -57
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/rolldown-runtime-hePW80VL.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,n as r,o as i}from"./runtime-switch-CAZiOV2G.js";import{n as a}from"./runtime-fetch-BAN5Gnnp.js";import{C as o,E as s,I as c,T as l,b as u,n as d,r as f,w as p,x as m,y as h}from"./desktop-dp2Z0toS.js";import{t as g}from"./runtimeAPIRegistry-C2VogTny.js";import{a as _,i as v,r as y}from"./vendor-zustand-o69pgTEK.js";import{it as b,nt as x,rt as S}from"./vendor-base-ui-CdzJ6My_.js";import{Ct as C,Nt as w,n as T,t as E}from"./platform-DXeTzJHG.js";import{b as D,n as O}from"./useUIStore-NMQx_cnG.js";import{$ as k,d as A,i as j}from"./persistence-BfjCXjLZ.js";import{n as M}from"./vendor-react-BP2cRVqX.js";import{l as N,n as P,o as F,s as I}from"./vendor-tanstack-react-query-CdqCAt40.js";import{a as L,o as R,r as z,t as B}from"./queryRuntime-BuRnpVtK.js";import{o as V}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{n as H}from"./pathNormalization-ewtPqJWn.js";import{a as U,t as ee}from"./types-BihDq7ZW.js";import{$ as te,A as W,B as G,G as K,H as q,J as ne,L as re,P as ie,T as ae,U as oe,W as se,X as ce,Y as le,a as ue,at as de,dt as fe,f as pe,ft as me,g as he,l as ge,pt as _e,st as ve,z as J}from"./vendor-codemirror-autocomplete-7c2L_4dM.js";import{c as ye,o as be,r as xe}from"./vendor-codemirror-lang-angular-DXOgWEVj.js";import{n as Se,r as Ce}from"./vendor-codemirror-lang-json-mLulNbwB.js";import{n as we}from"./vendor-codemirror-lang-markdown-CV1IO6Qs.js";import{n as Te}from"./vendor-codemirror-lang-python-YM2WVLHF.js";import{O as Ee}from"./vendor-codemirror-legacy-modes-DwltVFbT.js";import{n as De}from"./vendor-reactuses-core-BpfIZ1tg.js";import{a as Oe,d as ke,f as Ae,p as je,r as Y,t as Me}from"./button-BSFWH-Ok.js";import{Pr as Ne,Rr as Pe,bi as Fe,d as Ie,er as Le,fo as Re,hi as ze,ir as Be,jr as Ve,nr as He,or as Ue,rr as We,so as Ge,sr as Ke,vn as qe,wr as Je}from"./useMobileNavigationStore-07uYrwvK.js";import{n as Ye}from"./useThemeSystem-8jhE4Zyk.js";import{n as X}from"./Icon-BjiyvtB2.js";import{a as Xe,n as Ze,o as Qe,r as $e,t as et}from"./dialog-D1pXn_b9.js";import{L as tt,_ as nt,b as rt,c as it,n as at,s as ot,u as st}from"./gitApi-Bw4AQDuA.js";import{A as ct,_ as lt,a as ut,b as dt,c as ft,h as pt,m as mt,n as ht,r as gt,t as _t,x as vt}from"./projectMeta-OMvGIxob.js";import{t as yt}from"./input-BhHXFla6.js";import{i as bt,n as xt,t as St}from"./tooltip-DygQ-2xe.js";import{F as Ct,G as wt,Gt as Tt,J as Et,Jt as Dt,Kt as Ot,M as kt,P as At,Qt as jt,U as Mt,W as Nt,Wt as Pt,Yt as Ft,a as It,it as Lt,k as Rt,q as zt,qt as Bt,rn as Vt,rt as Ht,ut as Ut,v as Wt}from"./speechSettingsQueries-DZ9a20QR.js";import{r as Gt,t as Kt}from"./device-B7GyZCPd.js";import{n as qt}from"./MarkdownRenderer-C1giOHSB.js";import{n as Jt,t as Yt}from"./textarea-Deh9E1KP.js";import{a as Xt}from"./url-MRa-FtQa.js";import{r as Zt}from"./markdown-worker-oBGEB9Eg.js";import{i as Qt,n as $t,o as en}from"./mcpQueries-B-cYFZaO.js";import{n as tn,r as nn,t as rn}from"./collapsible-DaevjAvt.js";import{a as an,d as on,o as sn,s as cn}from"./vendor-codemirror-commands-B8KrBQ9B.js";import{a as ln,c as un,i as dn,o as fn,r as pn,s as mn}from"./vendor-codemirror-search-ZqtrPLjU.js";import{n as hn,t as gn}from"./vendor-replit-codemirror-vim-DDj0dSVY.js";import{t as _n}from"./vendor-codemirror-language-data-Ctd4WxgW.js";import{i as vn,n as yn,r as bn,t as xn}from"./projectActions-BX0cjZoq.js";var Sn=[{id:`claude`,name:`Claude`},{id:`codex`,name:`Codex`},{id:`cursor`,name:`Cursor`},{id:`github-copilot`,name:`GitHub Copilot`},{id:`google`,name:`Google`},{id:`kimi-for-coding`,name:`Kimi for Coding`},{id:`nano-gpt`,name:`NanoGPT`},{id:`openrouter`,name:`OpenRouter`},{id:`zai-coding-plan`,name:`z.ai`},{id:`zhipuai-coding-plan`,name:`Zhipu AI Coding Plan`},{id:`minimax-cn-coding-plan`,name:`MiniMax Coding Plan (minimaxi.com)`},{id:`minimax-coding-plan`,name:`MiniMax Coding Plan (minimax.io)`},{id:`ollama-cloud`,name:`Ollama Cloud`},{id:`wafer`,name:`Wafer.ai`},{id:`opencode-go`,name:`OpenCode Go`},{id:`xai`,name:`Grok`}],Cn=e=>[...Sn,...e.filter(e=>e.source===`magpie`).map(e=>({id:e.providerId,name:e.providerName}))],Z=M(),Q=S();function wn(e){let t=(0,Z.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.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,Q.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,Q.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 Tn={},En=(e,t=n())=>JSON.stringify([t,$t(e)]),Dn=(e,t,n)=>{if(!e[t]?.[n])return e;let r={...e[t]};return delete r[n],{...e,[t]:r}},On=e=>{let t=$t(e);return t?w.getScopedApiClient(t):w.getApiClient()},kn=e=>e?{location:{directory:e}}:void 0,An=new Map,jn=(e,t)=>JSON.stringify([r(),En(t),e]),Mn=async(e,t,n)=>{let r=(await e.mcp.list(kn(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,...kn(n)})).data},Nn=e=>$t(e===void 0?C.getState().currentDirectory:e),Pn=_()(y((e,t)=>({diagnosticsByDirectory:{},getDiagnosticForDirectory:e=>{let n=En(Nn(e));return t().diagnosticsByDirectory[n]??Tn},clearDiagnostic:(t,n,r)=>{let i=En(Nn(n),r);e(e=>({diagnosticsByDirectory:Dn(e.diagnosticsByDirectory,i,t)}))},connect:async(t,r)=>{let i=Nn(r),a=n(),o=En(i,a),s=On(i);try{await s.mcp.connect({server:t,...kn(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 en(L,i,a),e(e=>({diagnosticsByDirectory:Dn(e.diagnosticsByDirectory,o,t)}))},disconnect:async(t,r)=>{let i=Nn(r),a=n(),o=En(i,a);await On(i).mcp.disconnect({server:t,...kn(i)}),await en(L,i,a),e(e=>({diagnosticsByDirectory:Dn(e.diagnosticsByDirectory,o,t)}))},startAuth:async(e,t)=>{let n=Nn(t),r=jn(e,n),i=On(n),a=await Mn(i,e,n),o=a.methods.find(e=>e.type===`oauth`);if(!o)throw Error(`MCP server "${e}" has no OAuth method`);if(r!==jn(e,n))throw Error(`MCP authorization runtime changed`);let s=An.get(r);if(s&&(await i.integration.oauth.cancel({integrationID:s.integrationID,attemptID:s.attempt.attemptID,...kn(n)}),An.delete(r)),r!==jn(e,n))throw Error(`MCP authorization runtime changed`);let{data:c}=await i.integration.oauth.connect({integrationID:a.id,methodID:o.id,...kn(n)});if(r!==jn(e,n))throw Error(`MCP authorization runtime changed`);for(let[e,t]of An)t.attempt.time.expires<=Date.now()&&An.delete(e);return An.set(r,{integrationID:a.id,attempt:c}),c},authStatus:async(e,t)=>{let n=Nn(t),r=jn(e,n),i=An.get(r);if(!i)throw Error(`MCP authorization attempt not found`);let{data:a}=await On(n).integration.oauth.status({integrationID:i.integrationID,attemptID:i.attempt.attemptID,...kn(n)});if(r!==jn(e,n))throw Error(`MCP authorization runtime changed`);return a.status!==`pending`&&An.get(r)===i&&An.delete(r),a},completeAuth:async(e,t,r)=>{let i=Nn(r),a=n(),o=jn(e,i),s=An.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 On(i).integration.oauth.complete({integrationID:s.integrationID,attemptID:s.attempt.attemptID,code:t.trim(),...kn(i)}),An.get(o)===s&&An.delete(o),o!==jn(e,i))throw Error(`MCP authorization runtime changed`);await en(L,i,a)},clearAuth:async(e,t)=>{let r=Nn(t),i=n(),a=jn(e,r),o=On(r),s=await Mn(o,e,r);if(a!==jn(e,r))throw Error(`MCP authorization runtime changed`);let c=An.get(a);c&&(await o.integration.oauth.cancel({integrationID:c.integrationID,attemptID:c.attempt.attemptID,...kn(r)}),An.delete(a));let l=new Set(s.connections.flatMap(e=>e.type===`credential`?[e.id]:[]));for(let t of l){if(a!==jn(e,r))throw Error(`MCP authorization runtime changed`);await o.credential.remove({credentialID:t})}if(a!==jn(e,r))throw Error(`MCP authorization runtime changed`);await en(L,r,i)},testConnection:async(t,r)=>{let i=Nn(r),a=n(),o=En(i,a),s=On(i),c=Qt(L,i,a)[t]?.status===`connected`,l,u;try{await s.mcp.connect({server:t,...kn(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 en(L,i,a))[t],f=d;if(!c&&d?.status===`connected`){try{await s.mcp.disconnect({server:t,...kn(i)})}catch(e){u=`Connection test succeeded, but cleanup disconnect failed: ${e instanceof Error?e.message:`Disconnect failed`}`}await en(L,i,a)}return l||e(e=>({diagnosticsByDirectory:Dn(e.diagnosticsByDirectory,o,t)})),{status:f??Qt(L,i,a)[t],error:l,warning:u}}}))),$=e(b(),1),Fn=`https://yuri-updates.xiaobe.top/v1/update/check`,In=`https://yuri-origin.xiaobe.top/v1/update/check`,Ln=`https://github.com/yee94/yuri/releases/latest`,Rn=`https://github.com/yee94/yuri/releases`,zn=`https://testflight.apple.com/join/pN5SSHeg`,Bn=1e4;function Vn(e){let t=String(e||``).replace(/^v/,``).split(`+`)[0]??``,n=t.indexOf(`-`);return{parts:(n>=0?t.slice(0,n):t).split(`.`).map(e=>{let t=Number.parseInt(e||`0`,10);return Number.isFinite(t)?t:0}),prerelease:n>=0}}function Hn(e,t){let n=Vn(e),r=Vn(t),i=Math.max(n.parts.length,r.parts.length);for(let e=0;e<i;e+=1){let t=(n.parts[e]||0)-(r.parts[e]||0);if(t!==0)return t}return n.prerelease===r.prerelease?0:n.prerelease?-1:1}function Un(){return[Fn,In]}function Wn(e,t,n=Date.now){let r=e-n();return r<=0||t<=0?null:Math.max(1,Math.ceil(r/t))}function Gn(e){return{appType:`mobile-capacitor`,deviceClass:e.deviceClass||`mobile`,platform:e.platform===`ios`||e.platform===`android`?e.platform:`android`,arch:e.arch||`unknown`,channel:`stable`,currentVersion:e.currentVersion,instanceMode:`remote`,reportUsage:e.reportUsage===!0}}async function Kn(e,t,n,r){try{if(T())try{let{CapacitorHttp:r}=await V(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 qn(e,t){return e===`ios`?zn:`${Rn}/download/v${t}/app-release.apk`}function Jn(e,t,n){if(typeof e.latestVersion!=`string`||e.latestVersion.trim().length===0)return null;let r=e.latestVersion.trim(),i=Hn(r,t);if(i<0)return null;let a=typeof e.releaseNotesUrl==`string`&&e.releaseNotesUrl.trim().length>0?e.releaseNotesUrl.trim():`${Rn}/tag/v${r}`,o=typeof e.downloadUrl==`string`&&e.downloadUrl.trim().length>0?e.downloadUrl.trim():typeof e.download?.url==`string`&&e.download.url.trim().length>0?e.download.url.trim():qn(n,r);return{available:!!e.updateAvailable&&i>0,version:r,currentVersion:t,body:typeof e.releaseNotes==`string`?e.releaseNotes:void 0,releaseUrl:a,downloadUrl:o,nextSuggestedCheckInSec:typeof e.nextSuggestedCheckInSec==`number`&&Number.isFinite(e.nextSuggestedCheckInSec)?e.nextSuggestedCheckInSec:void 0}}async function Yn(e,t,n,r){let i=await Kn(e,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify(Gn(t))},n,r);if(!i?.ok)return null;let a;try{a=await i.json()}catch{return null}return Jn(a,t.currentVersion,t.platform)}async function Xn(e,t,n,r){let i=await Kn(Ln,{method:`GET`,headers:{Accept:`text/html`},redirect:`follow`},n,r);if(!i?.ok)return null;let a=typeof i.url==`string`&&i.url.length>0?i.url:Ln,o=null;try{o=new URL(a).pathname.match(/\/releases\/tag\/v(\d+\.\d+\.\d+(?:-[\w.]+)?)/)}catch{return null}if(!o?.[1])return null;let s=o[1],c=Hn(s,e),l=`${Rn}/tag/v${s}`;return{available:c>0,version:s,currentVersion:e,releaseUrl:l,downloadUrl:qn(t,s)}}async function Zn(e){let t=e.currentVersion?.trim()||`unknown`;if(t===`unknown`)return{available:!1,currentVersion:t,error:`Unable to check for mobile updates`};let n=e.fetchImpl??fetch,r=e.now??Date.now,i=Un(),a=r()+Bn;for(let[t,o]of i.entries()){let s=Wn(a,i.length-t+1,r);if(s===null)break;let c=await Yn(o,e,s,n);if(c)return c}let o=Wn(a,1,r);if(o!==null){let r=await Xn(t,e.platform,o,n);if(r)return r}return{available:!1,currentVersion:t,error:`Unable to check for mobile updates`}}function Qn(){if(typeof window>`u`)return`unknown`;try{let{deviceType:e}=Kt();return e}catch{return`unknown`}}function $n(){let e=typeof window<`u`?window.__VSCODE_CONFIG__?.arch?.toLowerCase?.():void 0;if(e===`arm64`||e===`aarch64`)return`arm64`;if(e===`x64`||e===`amd64`||e===`x86_64`)return`x64`;let t=(typeof navigator<`u`?navigator.userAgentData:void 0)?.architecture?.toLowerCase?.();if(t===`arm`||t===`arm64`||t===`aarch64`)return`arm64`;if(t===`x86`||t===`x64`||t===`amd64`)return`x64`;let n=typeof navigator<`u`?navigator.userAgent.toLowerCase():``;return n.includes(`aarch64`)||n.includes(`arm64`)||n.includes(`armv`)?`arm64`:n.includes(`x86_64`)||n.includes(`x64`)||n.includes(`amd64`)||n.includes(`win64`)?`x64`:`unknown`}function er(){let e=E();if(e===`android`||e===`ios`)return e;if(typeof navigator>`u`)return`web`;let t=(navigator.platform||``).toLowerCase();return t.includes(`mac`)?`macos`:t.includes(`win`)?`windows`:t.includes(`linux`)?`linux`:`web`}function tr(e){let t=O.getState().reportUsage,n=new URLSearchParams({reportUsage:t?`true`:`false`});return n.set(`deviceClass`,Qn()),n.set(`arch`,$n()),n.set(`platform`,er()),e===`desktop`?(n.set(`appType`,`desktop-electron`),n.set(`instanceMode`,h()?`local`:`remote`),n):e===`vscode`?(n.set(`appType`,`vscode`),n.set(`instanceMode`,`local`),n):e===`mobile`?(n.set(`appType`,`mobile-capacitor`),n.set(`instanceMode`,`remote`),n):(n.set(`appType`,`web`),n.set(`instanceMode`,`unknown`),n)}async function nr(e,t){let n=t??`unknown`;try{let r=tr(e),i=typeof window<`u`?window.__VSCODE_CONFIG__?.extensionVersion:void 0;t?r.set(`currentVersion`,t):e===`vscode`&&i&&r.set(`currentVersion`,i);let o=await a(`/api/yuri/update-check?${r.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),s=null;try{s=await o.json()}catch{s=null}if(!o.ok)return{available:!1,currentVersion:n,error:typeof s?.error==`string`&&s.error.trim().length>0?s.error.trim():`Server responded with ${o.status}`};if(!s)return{available:!1,currentVersion:n,error:`Update check returned an invalid response`};let c=typeof s.error==`string`&&s.error.trim().length>0?s.error.trim():void 0;return{available:s.available===!0,version:typeof s.version==`string`?s.version:void 0,currentVersion:typeof s.currentVersion==`string`?s.currentVersion:n,body:typeof s.body==`string`?s.body:void 0,releaseUrl:typeof s.releaseUrl==`string`?s.releaseUrl:void 0,downloadUrl:typeof s.downloadUrl==`string`?s.downloadUrl:void 0,nextSuggestedCheckInSec:typeof s.nextSuggestedCheckInSec==`number`&&Number.isFinite(s.nextSuggestedCheckInSec)?s.nextSuggestedCheckInSec:void 0,packageManager:typeof s.packageManager==`string`?s.packageManager:void 0,updateCommand:typeof s.updateCommand==`string`?s.updateCommand:void 0,error:c}}catch(e){return console.warn(`Failed to check for updates:`,e),{available:!1,currentVersion:n,error:e instanceof Error?e.message:`Failed to check for updates`}}}function rr(){return T()?`mobile`:m()?`desktop`:o()?`vscode`:p()?`web`:null}var ir={checking:!1,available:!1,downloading:!1,downloaded:!1,info:null,progress:null,error:null,runtimeType:null,lastChecked:null,nextCheckInSec:null,otaDecision:null,otaPhase:`idle`,otaDownloadSkipped:!1,lastOtaChannelOverride:null};function ar(e,t){let n=e.isChannelRollback===!0?{isChannelRollback:!0}:{};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 or=0,sr=_()((e,t)=>({...ir,checkForUpdates:async()=>{let n=rr();if(!n)return null;let r=++or;e({checking:!0,error:null,runtimeType:n});try{let i=null,a=null;if(n===`desktop`){let n=O.getState().otaChannelOverride;t().lastOtaChannelOverride!==n&&e({downloaded:!1,downloading:!1,available:!1,info:null,otaDecision:null,progress:null,otaPhase:`checking`});let i=await d(n);if(r!==or||O.getState().otaChannelOverride!==n)return null;let a=i?.downloaded===!0;return e({checking:!1,available:i?.available??!1,downloaded:a,...a?{downloading:!1,progress:null}:{},info:i,error:null,lastChecked:Date.now(),nextCheckInSec:i?.nextSuggestedCheckInSec??null,otaDecision:i?.otaDecision??null,otaPhase:a?`pending_restart`:i?.inAppApply?`available`:`idle`,lastOtaChannelOverride:n}),i?.nextSuggestedCheckInSec??null}if(n===`web`)i=await nr(`web`),a=i?.nextSuggestedCheckInSec??null;else if(n===`vscode`)a=(await nr(`vscode`))?.nextSuggestedCheckInSec??null;else if(n===`mobile`){let n=await U()??`unknown`,r=T()?g()?.mobileUpdates:void 0,o=O.getState().otaChannelOverride;if(r)try{let i=t().lastOtaChannelOverride!==o;e(i?{otaDecision:null,otaPhase:`checking`,downloaded:!1,otaDownloadSkipped:!1,progress:null,available:!1,info:null}:{otaPhase:`checking`});let a=await r.checkForOtaUpdate(o===`beta`||o===`stable`?{channelOverride:o}:void 0),s=ar(a,n),c=(i?void 0:t().otaDecision?.ota.bundle?.bundleId)!==a.ota.bundle?.bundleId,l=!i&&t().downloaded&&!c;return e({checking:!1,available:s.available,info:s.info,error:s.info.error??null,lastChecked:Date.now(),nextCheckInSec:a.nextCheckInSec,otaDecision:a,otaPhase:l?`pending_restart`:s.otaPhase,lastOtaChannelOverride:o,...c||i?{downloaded:!1,otaDownloadSkipped:!1,progress:null}:{}}),a.nextCheckInSec}catch(t){if(!(t instanceof ee)){let r=t instanceof Error?t.message:`Mobile OTA check failed`;return e({checking:!1,available:!1,info:{available:!1,currentVersion:n},error:r,lastChecked:Date.now(),otaDecision:null,otaPhase:`error`,lastOtaChannelOverride:o}),null}}return i=await Zn({currentVersion:n,platform:er()===`ios`?`ios`:`android`,deviceClass:Qn(),arch:$n(),reportUsage:O.getState().reportUsage}),a=i?.nextSuggestedCheckInSec??null,e({checking:!1,available:i?.available??!1,info:i,error:i?.error??null,lastChecked:Date.now(),nextCheckInSec:a,otaDecision:null,otaPhase:`idle`}),a}return e({checking:!1,available:n===`vscode`?!1:i?.available??!1,info:n===`vscode`?null:i,error:n===`vscode`?null:i?.error??null,lastChecked:Date.now(),nextCheckInSec:a}),a}catch(i){return r===or&&e({checking:!1,error:i instanceof Error?i.message:`Failed to check for updates`,...n===`desktop`&&!t().downloaded?{otaPhase:`error`}:{}}),null}},downloadUpdate:async()=>{let{available:n,runtimeType:r,otaDecision:i,downloading:a,downloaded:o}=t();if(r===`mobile`&&i?.primaryAction===`apply_ota`&&i.ota.bundle){if(a||o)return;let t=g()?.mobileUpdates;if(!t){e({error:`Mobile OTA updates are unavailable in this runtime`,otaPhase:`error`});return}e({downloading:!0,error:null,progress:null,otaPhase:`downloading`,otaDownloadSkipped:!1});try{let{skipped:n}=await t.downloadOtaUpdate(i.ota.bundle);await t.queueOtaUpdateForNextLaunch(),e({downloading:!1,downloaded:!0,progress:null,otaPhase:`pending_restart`,otaDownloadSkipped:n})}catch(t){e({downloading:!1,error:t instanceof Error?t.message:`Failed to download update`,otaPhase:`error`})}return}if(!(r!==`desktop`||!n)){e({downloading:!0,error:null,progress:null});try{let n=O.getState().otaChannelOverride,r=await d(n);if(n!==O.getState().otaChannelOverride)throw Error(`OTA channel changed`);if(!r?.available||r.manualUpdate)throw Error(`Update detected, but desktop package is not ready yet. Retry in a moment.`);if(e(e=>({info:e.info?{...e.info,...r,body:r.body||e.info.body,available:e.info.available}:r})),r.downloaded||t().downloaded){e({downloading:!1,downloaded:!0,progress:null});return}if(r.downloading&&e({downloading:!0,progress:r.progress??{downloaded:0}}),!await f(t=>{e({progress:t})}))throw Error(`Failed to download update`);e({downloading:!1,downloaded:!0,progress:null,otaPhase:`pending_restart`})}catch(t){e({downloading:!1,error:t instanceof Error?t.message:`Failed to download update`})}}},subscribeDesktopUpdateEvents:async()=>{if(!m())return()=>{};let n=[],r=await l(n=>{let r=n.event,i=n.data??null;if(r===`Started`){if(!t().downloading)return;e({error:null,progress:{downloaded:0,total:typeof i?.contentLength==`number`?i.contentLength:void 0}});return}if(r===`Progress`){if(!t().downloading)return;e({progress:{downloaded:typeof i?.downloaded==`number`?i.downloaded:0,total:typeof i?.total==`number`?i.total:void 0}});return}r===`Finished`&&e({downloading:!1,downloaded:!0,progress:null})});r&&n.push(r);let i=await s(t=>{t.downloaded&&e({downloading:!1,downloaded:!0,available:!0,progress:null})});return i&&n.push(i),async()=>{for(let e of n)try{let t=e();t instanceof Promise&&await t}catch{}}},restartToUpdate:async()=>{let{downloaded:n,runtimeType:r,otaDecision:i}=t();if(r===`mobile`&&i?.primaryAction===`apply_ota`){if(!n)return;let t=g()?.mobileUpdates;if(!t){e({error:`Mobile OTA updates are unavailable in this runtime`,otaPhase:`error`});return}try{await t.applyOtaUpdateNow()}catch(t){e({error:t instanceof Error?t.message:`Failed to restart`,otaPhase:`error`})}return}if(!(r!==`desktop`||!n))try{if(!await c())throw Error(`Failed to restart`)}catch(t){e({error:t instanceof Error?t.message:`Failed to restart`})}},setOtaPhase:(t,n=null)=>{e({otaPhase:t,...n===void 0?{}:{error:n}})},setOtaDownloadPercent:n=>{if(!Number.isFinite(n)||n<0||n>100)return;let r=t();if(!r.downloading)return;let i=Math.round(n);if((r.progress?.total?Math.round(r.progress.downloaded/r.progress.total*100):null)===i)return;let a=r.otaDecision?.ota.bundle?.size;if(typeof a==`number`&&Number.isFinite(a)&&a>0){e({progress:{downloaded:Math.round(a*n/100),total:a}});return}e({progress:{downloaded:n,total:100}})},setOtaDownloadFailed:t=>{e({downloading:!1,downloaded:!1,error:t??`Failed to download update`,otaPhase:`error`})},dismiss:()=>{t().otaPhase!==`pending_restart`&&e({available:!1,downloaded:!1,info:null,otaDecision:null,otaPhase:`idle`,otaDownloadSkipped:!1})},reset:()=>{e(ir)}})),cr=e=>!!(e&&![`succeeded`,`failed`].includes(e.status));function lr(e,t){if(e!==n()||t!==r())throw Error(`Stale update runtime`)}var ur=(e=n(),t=r(),i)=>({queryKey:[e,`host-update`,t,i??`current`],queryFn:async({signal:n})=>{lr(e,t);let r=await a(`/api/system/update${i?`?channel=${i}`:``}`,{headers:{Accept:`application/json`},signal:n});if([404,501].includes(r.status))throw Error(`host_update_unsupported`);let o=await r.json();if(lr(e,t),!r.ok&&r.status!==502||typeof o.serverId!=`string`||typeof o.supported!=`boolean`||![`cli`,`electron`].includes(o.host))throw Error(`Host update check failed`);return o},staleTime:6e4,retry:!1}),dr=(e=n(),t=r(),i)=>L.getQueryData(ur(e,t,i).queryKey),fr=(e=n(),t=r(),i)=>{let a=dr(e,t,i);return L.fetchQuery({...ur(e,t,i),staleTime:a?.checkError||cr(a?.operation)?0:6e4})},pr=(e=n(),t=r(),i)=>L.fetchQuery({...ur(e,t,i),staleTime:0}),mr=(e,t,n)=>{let r=(0,Z.c)(6),i;r[0]!==n||r[1]!==t||r[2]!==e?(i=ur(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:gr,refetchIntervalInBackground:!1},r[4]=i,r[5]=a),I(a)};async function hr(e,t,n){if(lr(t,n),!e.update)throw Error(`No update plan`);let r=await a(`/api/system/update`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({version:e.update.version,channel:e.channel,planId:e.update.planId,allowDowngrade:e.update.rollback===!0})});if(lr(t,n),!r.ok)throw Error(`Host update was not accepted`);let i=await r.json();if(typeof i.operation?.id!=`string`)throw Error(`Invalid update operation`);return i.operation}function gr(e){return e.state.error?.message===`host_update_unsupported`?!1:e.state.error?15e3:cr(e.state.data?.operation)?2e3:3e5}function _r(e){let t=new Date(`${e}T00:00:00`);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(je(),{year:`numeric`,month:`short`,day:`numeric`}).format(t)}function vr(e){return e.replace(/^## \[[^\]]+\] - \d{4}-\d{2}-\d{2}\s*\n?/,``).trim()}function yr(e){return e.replace(/(^|[^a-zA-Z0-9])@([a-zA-Z0-9-]+)/g,`$1[@$2](https://github.com/$2)`)}function br(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 xr(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 Sr(e){let t=(0,Z.c)(72),{open:n,onOpenChange:r,model:i,onAction:a}=e,{t:o}=Ae(),[s,c]=(0,$.useState)(!1),l=De(wr),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=De(u),f;t[2]===i.fallbackCommand?f=t[3]:(f=async()=>{i.fallbackCommand&&(await ke(i.fallbackCommand)).ok&&(c(!0),setTimeout(()=>c(!1),2e3))},t[2]=i.fallbackCommand,t[3]=f);let p=De(f),m;if(t[4]!==i.body||t[5]!==o){bb0:{let e=i.body?.trim();if(!e){m=null;break bb0}let n=xr(e);if(!n.length){m={kind:`raw`,title:o(`updateDialog.changelog.title`),content:yr(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(Cr).map(t=>({version:t.version,dateLabel:_r(t.date),content:yr(vr(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,_;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(X,{name:`download-cloud`,className:`h-5 w-5 text-[var(--primary-base)]`}),t[9]=_):_=t[9];let v;t[10]===i.title?v=t[11]:(v=(0,Q.jsxs)(Qe,{className:`flex items-center gap-2`,children:[_,(0,Q.jsx)(`span`,{className:`font-semibold text-foreground`,children:i.title})]}),t[10]=i.title,t[11]=v);let y;t[12]!==i.currentVersion||t[13]!==i.methodLabel||t[14]!==i.version?(y=(i.currentVersion||i.version)&&(0,Q.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,Q.jsx)(`span`,{className:`text-muted-foreground/75`,children:i.currentVersion}),i.currentVersion&&i.version&&(0,Q.jsx)(`span`,{className:`text-muted-foreground/40`,children:`→`}),i.version&&(0,Q.jsx)(`span`,{className:`font-medium text-[var(--primary-base)]`,children:i.version}),i.methodLabel&&(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· `,i.methodLabel]})]}),t[12]=i.currentVersion,t[13]=i.methodLabel,t[14]=i.version,t[15]=y):y=t[15];let b;t[16]===i.description?b=t[17]:(b=i.description&&(0,Q.jsx)($e,{className:`mt-2`,children:i.description}),t[16]=i.description,t[17]=b);let x;t[18]!==v||t[19]!==y||t[20]!==b?(x=(0,Q.jsxs)(`div`,{className:`mb-3 pr-8 sm:mb-4`,children:[v,y,b]}),t[18]=v,t[19]=y,t[20]=b,t[21]=x):x=t[21];let S;t[22]===i.message?S=t[23]:(S=i.message&&(0,Q.jsx)(`p`,{role:`status`,className:`typography-ui-label text-muted-foreground`,children:i.message}),t[22]=i.message,t[23]=S);let C;t[24]===i.warning?C=t[25]:(C=i.warning&&(0,Q.jsx)(`p`,{className:`typography-meta text-[var(--status-warning)]`,children:i.warning}),t[24]=i.warning,t[25]=C);let w;t[26]===i.status?w=t[27]:(w=i.status?.kind===`activity`&&(0,Q.jsxs)(`div`,{role:`status`,className:`rounded-lg bg-[var(--surface-elevated)]/30 p-5 border border-[var(--surface-subtle)]`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(X,{name:`loader`,className:`h-5 w-5 animate-spin text-[var(--primary-base)]`}),(0,Q.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:i.status.label})]}),i.status.detail&&(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:i.status.detail})]}),t[26]=i.status,t[27]=w);let T;t[28]!==h||t[29]!==d||t[30]!==i.hideChangelog?(T=h&&!i.hideChangelog&&(0,Q.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--surface-subtle)] px-3.5 py-2.5 sm:px-4 sm:py-3`,children:[(0,Q.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--primary-base)]`,"aria-hidden":`true`}),(0,Q.jsx)(`h3`,{className:`typography-ui-caption font-medium text-muted-foreground`,children:h.title})]}),(0,Q.jsx)(Jt,{className:`max-h-[min(42dvh,22rem)] p-0 sm:max-h-[400px]`,fillContainer:!1,children:h.kind===`raw`?(0,Q.jsx)(`div`,{className:`break-words p-3.5 text-[13px] leading-[1.65] text-foreground sm:p-4 sm:text-sm [&_.markdown-content]:leading-[1.65] [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline`,onClickCapture:d,children:(0,Q.jsx)(qt,{content:h.content,disableLinkSafety:!0,enableFileReferences:!1})}):(0,Q.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:h.sections.map(e=>(0,Q.jsxs)(`div`,{className:`p-3.5 sm:p-4`,children:[(0,Q.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-center gap-x-2 gap-y-1 sm:mb-3`,children:[(0,Q.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,Q.jsx)(`span`,{className:`text-[11px] leading-4 text-muted-foreground/75 sm:text-xs`,children:e.dateLabel})]}),(0,Q.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,Q.jsx)(qt,{content:e.content,disableLinkSafety:!0,enableFileReferences:!1})})]},e.version))})})]}),t[28]=h,t[29]=d,t[30]=i.hideChangelog,t[31]=T):T=t[31];let E;t[32]!==s||t[33]!==p||t[34]!==i.fallbackCommand||t[35]!==o?(E=i.fallbackCommand&&(0,Q.jsxs)(`div`,{className:`space-y-2 mt-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 typography-meta text-muted-foreground`,children:[(0,Q.jsx)(X,{name:`terminal`,className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:o(`updateDialog.fallback.updateViaTerminal`)})]}),(0,Q.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,Q.jsx)(`code`,{className:`flex-1 font-mono text-sm text-foreground overflow-x-auto whitespace-nowrap`,children:i.fallbackCommand}),(0,Q.jsx)(`button`,{onClick:p,className:Y(`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,Q.jsx)(X,{name:s?`check`:`clipboard`,className:`h-4 w-4`})})]})]}),t[32]=s,t[33]=p,t[34]=i.fallbackCommand,t[35]=o,t[36]=E):E=t[36];let D;t[37]===i.status?D=t[38]:(D=i.status?.kind===`download`&&(0,Q.jsxs)(`div`,{role:`status`,className:`mt-3 space-y-2 rounded-lg border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20 px-3.5 py-3 sm:mt-4 sm:px-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground sm:text-[13px]`,children:i.status.label}),i.status.progress!=null&&(0,Q.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] leading-4 text-foreground tabular-nums sm:text-xs`,children:[Math.round(i.status.progress),`%`]})]}),i.status.progress!=null&&(0,Q.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-[var(--surface-subtle)] sm:h-1.5`,children:(0,Q.jsx)(`div`,{className:`h-full rounded-full bg-[var(--primary-base)] transition-all duration-300`,style:{width:`${i.status.progress}%`}})}),i.status.detail&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i.status.detail})]}),t[37]=i.status,t[38]=D);let O;t[39]===i.error?O=t[40]:(O=i.error&&(0,Q.jsx)(`div`,{role:`alert`,className:`p-3 mt-4 bg-[var(--status-error-background)] border border-[var(--status-error-border)] rounded-lg`,children:(0,Q.jsx)(`p`,{className:`text-sm text-[var(--status-error)]`,children:i.error})}),t[39]=i.error,t[40]=O);let k;t[41]!==S||t[42]!==C||t[43]!==w||t[44]!==T||t[45]!==E||t[46]!==D||t[47]!==O?(k=(0,Q.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[S,C,w,T,E,D,O]}),t[41]=S,t[42]=C,t[43]=w,t[44]=T,t[45]=E,t[46]=D,t[47]=O,t[48]=k):k=t[48];let A;t[49]===i.notice?A=t[50]:(A=i.notice&&(0,Q.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,Q.jsx)(X,{name:`check`,className:`h-4 w-4 shrink-0`}),(0,Q.jsx)(`span`,{children:i.notice})]}),t[49]=i.notice,t[50]=A);let j;t[51]===i.releaseLink?j=t[52]:(j=i.releaseLink?(0,Q.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,Q.jsx)(X,{name:`external-link`,className:`h-4 w-4`}),i.releaseLink.label]}):(0,Q.jsx)(`span`,{}),t[51]=i.releaseLink,t[52]=j);let M;if(t[53]!==i.actions||t[54]!==a){let e;t[56]===a?e=t[57]:(e=e=>(0,Q.jsxs)(Me,{onClick:()=>a(e.id),disabled:e.disabled,variant:e.variant??`default`,size:`default`,children:[e.icon&&(0,Q.jsx)(X,{name:e.icon,className:Y(`h-4 w-4`,e.loading&&`animate-spin`)}),e.label]},e.id),t[56]=a,t[57]=e),M=i.actions.map(e),t[53]=i.actions,t[54]=a,t[55]=M}else M=t[55];let N;t[58]===M?N=t[59]:(N=(0,Q.jsx)(`div`,{className:`flex flex-1 flex-wrap items-center justify-end gap-2`,children:M}),t[58]=M,t[59]=N);let P;t[60]!==j||t[61]!==N?(P=(0,Q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-4`,children:[j,N]}),t[60]=j,t[61]=N,t[62]=P):P=t[62];let F;t[63]!==k||t[64]!==A||t[65]!==P||t[66]!==x?(F=(0,Q.jsxs)(Ze,{className:`max-w-4xl gap-0 p-4 sm:p-5 bg-background border-[var(--interactive-border)]`,showCloseButton:!0,children:[x,k,A,P]}),t[63]=k,t[64]=A,t[65]=P,t[66]=x,t[67]=F):F=t[67];let I;return t[68]!==n||t[69]!==F||t[70]!==g?(I=(0,Q.jsx)(et,{open:n,onOpenChange:g,children:F}),t[68]=n,t[69]=F,t[70]=g,t[71]=I):I=t[71],I}function Cr(e,t){return br(e.version,t.version)}function wr(e){Xt(e)}var Tr=`https://github.com/yee94/yuri/releases`,Er=2e3,Dr=6e5,Or=e=>e.transport===n()&&e.generation===r();async function kr(e,t){try{if(!Or(t))return{success:!1};let n=await fr(t.transport,t.generation);return!Or(t)||!e||!n.supported||n.update?.version!==e||n.update.rollback?{success:!1}:(await hr(n,t.transport,t.generation),{success:!0,autoRestart:!0})}catch(e){return{success:!1,error:e instanceof Error?e.message:void 0}}}async function Ar(e,t,n=Math.ceil(Dr/Er),r=Er){for(let i=0;i<n;i++){if(!Or(t))return!1;try{let n=await pr(t.transport,t.generation);if(n.operation?.status===`failed`)return!1;if(n.currentVersion===e&&n.operation?.status===`succeeded`&&Or(t))return!0}catch{}await new Promise(e=>setTimeout(e,r))}return!1}var jr=e=>{let t=(0,Z.c)(108),{open:i,onOpenChange:a,info:o,downloading:s,downloaded:c,progress:l,error:u,onDownload:d,onRestart:f,runtimeType:p}=e,m=p===void 0?`desktop`:p,{t:h}=Ae(),[g,_]=(0,$.useState)(`idle`),[v,y]=(0,$.useState)(null),b=sr(Mr),x=o?.releaseUrl||(o?.version?`${Tr}/tag/v${o.version}`:Tr),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&&sr.getState().dismiss(),a(e)},t[0]=c,t[1]=E,t[2]=a,t[3]=A):A=t[3];let j=De(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,$.useEffect)(M,N);let P;t[7]!==o?.version||t[8]!==h?(P=async()=>{let e={transport:n(),generation:r()};_(`updating`),y(null);let t=await kr(o?.version,e);if(!Or(e))return;if(!t.success){_(`error`),y(t.error||h(`updateDialog.error.updateFailed`));return}t.autoRestart&&(_(`restarting`),await new Promise(Nr)),_(`reconnecting`);let i=await Ar(o?.version,e);Or(e)&&(i?window.location.reload():(_(`error`),y(h(`updateDialog.error.takingLonger`))))},t[7]=o?.version,t[8]=h,t[9]=P):P=t[9];let F=De(P),I;t[10]!==F||t[11]!==w||t[12]!==d||t[13]!==a||t[14]!==f||t[15]!==S||t[16]!==x||t[17]!==m?(I=e=>{bb107:switch(e){case`download`:d(),m===`desktop`&&a(!1);break bb107;case`restart`:f();break bb107;case`later`:sr.getState().dismiss(),a(!1);break bb107;case`open-external`:{let e=w?S:x;e&&Xt(e);break bb107}case`web-update`:F()}},t[10]=F,t[11]=w,t[12]=d,t[13]=a,t[14]=f,t[15]=S,t[16]=x,t[17]=m,t[18]=I):I=t[18];let L=De(I),R;if(t[19]!==c||t[20]!==s||t[21]!==E||t[22]!==D||t[23]!==w||t[24]!==C||t[25]!==O||t[26]!==T||t[27]!==h){if(R=[],!C&&(!w||E)){if(!D&&!c&&!s){let e;t[29]!==E||t[30]!==h?(e=h(E?`updateDialog.actions.applyOtaNow`:`updateDialog.actions.downloadUpdate`),t[29]=E,t[30]=h,t[31]=e):e=t[31];let n;t[32]===e?n=t[33]:(n={id:`download`,icon:`download`,label:e},t[32]=e,t[33]=n),R.push(n)}if(D&&!c&&!s){let e;t[34]===h?e=t[35]:(e=h(`updateDialog.actions.openMobileUpdate`),t[34]=h,t[35]=e);let n;t[36]===e?n=t[37]:(n={id:`open-external`,icon:`external-link`,label:e},t[36]=e,t[37]=n),R.push(n)}if(s){let e;t[38]===h?e=t[39]:(e=h(`updateDialog.status.downloading`),t[38]=h,t[39]=e);let n;t[40]===e?n=t[41]:(n={id:`downloading`,icon:`loader`,loading:!0,disabled:!0,label:e},t[40]=e,t[41]=n),R.push(n)}if(c){if(E){let e;t[42]===h?e=t[43]:(e=h(`updateDialog.actions.later`),t[42]=h,t[43]=e);let n;t[44]===e?n=t[45]:(n={id:`later`,variant:`ghost`,label:e},t[44]=e,t[45]=n),R.push(n)}let e;t[46]===h?e=t[47]:(e=h(`updateDialog.actions.restartToUpdate`),t[46]=h,t[47]=e);let n;t[48]===e?n=t[49]:(n={id:`restart`,icon:`restart`,label:e},t[48]=e,t[49]=n),R.push(n)}}if(w&&!E&&T){let e;t[50]===h?e=t[51]:(e=h(`updateDialog.actions.openMobileUpdate`),t[50]=h,t[51]=e);let n;t[52]===e?n=t[53]:(n={id:`open-external`,icon:`external-link`,label:e},t[52]=e,t[53]=n),R.push(n)}if(C){let e;t[54]!==O||t[55]!==h?(e=O?{id:`updating`,icon:`loader`,loading:!0,disabled:!0,label:h(`updateDialog.status.updating`)}:{id:`web-update`,icon:`download`,label:h(`updateDialog.actions.updateNow`)},t[54]=O,t[55]=h,t[56]=e):e=t[56],R.push(e)}t[19]=c,t[20]=s,t[21]=E,t[22]=D,t[23]=w,t[24]=C,t[25]=O,t[26]=T,t[27]=h,t[28]=R}else R=t[28];let z;t[57]!==h||t[58]!==g?(z=h(g===`restarting`||g===`reconnecting`?`updateDialog.header.updating`:`updateDialog.header.updateAvailable`),t[57]=h,t[58]=g,t[59]=z):z=t[59];let B=o?.currentVersion,V=o?.version,H=o?.body,U=!O,ee=u||v,te=C&&g===`error`?o?.updateCommand||`yuri update`:void 0,W;t[60]!==c||t[61]!==E||t[62]!==b||t[63]!==h?(W=E&&c&&b?h(`updateDialog.status.otaBundleReused`):void 0,t[60]=c,t[61]=E,t[62]=b,t[63]=h,t[64]=W):W=t[64];let G;t[65]!==w||t[66]!==k||t[67]!==T?(G=(!w||T)&&k?{url:k,label:`GitHub`}:void 0,t[65]=w,t[66]=k,t[67]=T,t[68]=G):G=t[68];let K;if(t[69]!==R||t[70]!==s||t[71]!==E||t[72]!==w||t[73]!==C||t[74]!==O||t[75]!==l||t[76]!==h||t[77]!==H||t[78]!==U||t[79]!==ee||t[80]!==te||t[81]!==W||t[82]!==G||t[83]!==z||t[84]!==B||t[85]!==V||t[86]!==g){if(K={title:z,currentVersion:B,version:V,body:H,hideChangelog:O,dismissible:U,error:ee,fallbackCommand:te,notice:W,releaseLink:G,actions:R},C&&O){let e;t[88]!==h||t[89]!==g?(e=h(g===`updating`?`updateDialog.status.installingUpdate`:g===`restarting`?`updateDialog.status.serverRestarting`:`updateDialog.status.waitingForServer`),t[88]=h,t[89]=g,t[90]=e):e=t[90];let n;t[91]===h?n=t[92]:(n=h(`updateDialog.status.autoReloadHint`),t[91]=h,t[92]=n);let r;t[93]!==e||t[94]!==n?(r={kind:`activity`,label:e,detail:n},t[93]=e,t[94]=n,t[95]=r):r=t[95],K.status=r}if(!C&&(!w||E)&&s){let e;t[96]===h?e=t[97]:(e=h(`updateDialog.status.downloadingPayload`),t[96]=h,t[97]=e);let n;t[98]===l?n=t[99]:(n=l?.total?Math.round(l.downloaded/l.total*100):0,t[98]=l,t[99]=n);let r;t[100]!==e||t[101]!==n?(r={kind:`download`,label:e,progress:n},t[100]=e,t[101]=n,t[102]=r):r=t[102],K.status=r}t[69]=R,t[70]=s,t[71]=E,t[72]=w,t[73]=C,t[74]=O,t[75]=l,t[76]=h,t[77]=H,t[78]=U,t[79]=ee,t[80]=te,t[81]=W,t[82]=G,t[83]=z,t[84]=B,t[85]=V,t[86]=g,t[87]=K}else K=t[87];let q;return t[103]!==L||t[104]!==j||t[105]!==K||t[106]!==i?(q=(0,Q.jsx)(Sr,{open:i,onOpenChange:j,model:K,onAction:L}),t[103]=L,t[104]=j,t[105]=K,t[106]=i,t[107]=q):q=t[107],q};function Mr(e){return e.otaDownloadSkipped}function Nr(e){return setTimeout(e,2e3)}var Pr=e(x(),1);function Fr(e){let t=(0,Z.c)(10),{children:n,actions:r,className:i}=e,a;t[0]===i?a=t[1]:(a=Y(`sticky top-0 z-10 flex shrink-0 items-center justify-between gap-3 bg-background py-3`,i),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,Q.jsx)(`div`,{className:`min-w-0 flex-1`,children:n}),t[2]=n,t[3]=o);let s;t[4]===r?s=t[5]:(s=(0,Q.jsx)(`div`,{className:`flex max-w-[70%] shrink-0 flex-wrap items-center justify-end gap-2 [&_button]:max-w-full [&_button]:whitespace-normal`,children:r}),t[4]=r,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,Q.jsxs)(`header`,{"data-settings-action-header":``,className:a,children:[o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function Ir(e){let t=(0,Z.c)(21),{label:n,actions:r,children:i,description:a,itemId:o,ariaLabel:s,className:c,cardClassName:l,cardId:u}=e,d=typeof n==`string`&&/^[\p{Script=Latin}\p{Number}\p{Punctuation}\p{Separator}]+$/u.test(n)?`latin`:void 0,f;t[0]===c?f=t[1]:(f=Y(`yuri-settings-group`,c),t[0]=c,t[1]=f);let p;t[2]!==r||t[3]!==n||t[4]!==d?(p=r?(0,Q.jsx)(Fr,{actions:r,children:n?(0,Q.jsx)(`div`,{className:`yuri-settings-group-label`,"data-settings-label-script":d,children:n}):null}):n?(0,Q.jsx)(`div`,{className:`yuri-settings-group-label`,"data-settings-label-script":d,children:n}):null,t[2]=r,t[3]=n,t[4]=d,t[5]=p):p=t[5];let m;t[6]===l?m=t[7]:(m=Y(`yuri-settings-group-card`,l),t[6]=l,t[7]=m);let h;t[8]!==u||t[9]!==i||t[10]!==o||t[11]!==m?(h=(0,Q.jsx)(`div`,{id:u,"data-settings-item":o,className:m,children:i}),t[8]=u,t[9]=i,t[10]=o,t[11]=m,t[12]=h):h=t[12];let g;t[13]===a?g=t[14]:(g=a?(0,Q.jsx)(`p`,{className:`yuri-settings-group-description text-muted-foreground`,children:a}):null,t[13]=a,t[14]=g);let _;return t[15]!==s||t[16]!==f||t[17]!==p||t[18]!==h||t[19]!==g?(_=(0,Q.jsxs)(`section`,{className:f,"aria-label":s,children:[p,h,g]}),t[15]=s,t[16]=f,t[17]=p,t[18]=h,t[19]=g,t[20]=_):_=t[20],_}function Lr(e){let t=(0,Z.c)(20),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({label:s,description:a,descriptionPlacement:l,ariaLabel:n,groupClassName:o,cardClassName:r,children:i,...c}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u=l===void 0?`inside`:l,d=u===`outside`?a:void 0,f=u===`inside`?a:void 0,p;t[9]!==i||t[10]!==s||t[11]!==c||t[12]!==f?(p=(0,Q.jsx)(Rr,{label:s,description:f,...c,children:i}),t[9]=i,t[10]=s,t[11]=c,t[12]=f,t[13]=p):p=t[13];let m;return t[14]!==n||t[15]!==r||t[16]!==o||t[17]!==d||t[18]!==p?(m=(0,Q.jsx)(Ir,{ariaLabel:n,className:o,cardClassName:r,description:d,children:p}),t[14]=n,t[15]=r,t[16]=o,t[17]=d,t[18]=p,t[19]=m):m=t[19],m}function Rr(e){let t=(0,Z.c)(22),{label:n,children:r,description:i,itemId:a,className:o,copyClassName:s,controlClassName:c}=e,l;t[0]===o?l=t[1]:(l=Y(`yuri-settings-group-row yuri-settings-split-row`,o),t[0]=o,t[1]=l);let u;t[2]===s?u=t[3]:(u=Y(`yuri-settings-split-row-copy`,s),t[2]=s,t[3]=u);let d;t[4]===n?d=t[5]:(d=n?(0,Q.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:n}):null,t[4]=n,t[5]=d);let f;t[6]===i?f=t[7]:(f=i?(0,Q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:i}):null,t[6]=i,t[7]=f);let p;t[8]!==u||t[9]!==d||t[10]!==f?(p=(0,Q.jsxs)(`div`,{className:u,children:[d,f]}),t[8]=u,t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===c?m=t[13]:(m=Y(`yuri-settings-split-row-control`,c),t[12]=c,t[13]=m);let h;t[14]!==r||t[15]!==m?(h=(0,Q.jsx)(`div`,{"data-settings-value":``,className:m,children:r}),t[14]=r,t[15]=m,t[16]=h):h=t[16];let g;return t[17]!==a||t[18]!==l||t[19]!==p||t[20]!==h?(g=(0,Q.jsxs)(`div`,{"data-settings-item":a,className:l,children:[p,h]}),t[17]=a,t[18]=l,t[19]=p,t[20]=h,t[21]=g):g=t[21],g}function zr(e){let t=(0,Z.c)(32),{checked:n,onChange:r,label:i,ariaLabel:a,description:o,itemId:s,disabled:c,className:l}=e,u=c!==void 0&&c,d;t[0]!==n||t[1]!==u||t[2]!==r?(d=()=>{u||r(!n)},t[0]=n,t[1]=u,t[2]=r,t[3]=d):d=t[3];let f=d,p=Br,m=u?`cursor-not-allowed`:`cursor-pointer`,h;t[4]!==l||t[5]!==m?(h=Y(`yuri-settings-group-row yuri-settings-split-row group`,m,l),t[4]=l,t[5]=m,t[6]=h):h=t[6];let g=u?-1:0,_=u||void 0,v,y;t[7]===f?(v=t[8],y=t[9]):(v=e=>{p(e.target)||f()},y=e=>{p(e.target)||(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),f())},t[7]=f,t[8]=v,t[9]=y);let b;t[10]===i?b=t[11]:(b=(0,Q.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i}),t[10]=i,t[11]=b);let x;t[12]===o?x=t[13]:(x=o?(0,Q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:o}):null,t[12]=o,t[13]=x);let S;t[14]!==x||t[15]!==b?(S=(0,Q.jsxs)(`div`,{className:`yuri-settings-split-row-copy`,children:[b,x]}),t[14]=x,t[15]=b,t[16]=S):S=t[16];let C;t[17]!==a||t[18]!==n||t[19]!==u||t[20]!==r?(C=(0,Q.jsx)(`div`,{"data-settings-value":``,className:`yuri-settings-split-row-control`,children:(0,Q.jsx)(ct,{checked:n,onChange:r,disabled:u,ariaLabel:a})}),t[17]=a,t[18]=n,t[19]=u,t[20]=r,t[21]=C):C=t[21];let w;return t[22]!==n||t[23]!==s||t[24]!==S||t[25]!==C||t[26]!==h||t[27]!==g||t[28]!==_||t[29]!==v||t[30]!==y?(w=(0,Q.jsxs)(`div`,{"data-settings-item":s,className:h,role:`button`,tabIndex:g,"aria-pressed":n,"aria-disabled":_,onClick:v,onKeyDown:y,children:[S,C]}),t[22]=n,t[23]=s,t[24]=S,t[25]=C,t[26]=h,t[27]=g,t[28]=_,t[29]=v,t[30]=y,t[31]=w):w=t[31],w}function Br(e){return e instanceof HTMLElement&&e.closest(`button, a, input, select, textarea`)!==null}function Vr(e,t,n){let r=e?.operation,i=e?.update,a=cr(r),o=e?.supported===!1||t.failure===`unsupported`,s={title:n(`settings.yuri.about.hostUpdate.title`),description:n(`settings.yuri.about.hostUpdate.description`),currentVersion:e?.currentVersion??t.versionFallback,version:i?.version??r?.version,methodLabel:i?n(`settings.yuri.about.hostUpdate.kind.${i.kind}`):void 0,body:i?i.releaseNotes||n(`settings.yuri.about.hostUpdate.noNotes`):void 0,warning:!a&&i?.rollback?n(`settings.yuri.about.hostUpdate.downgrade`):void 0,actions:[{id:`check`,variant:`ghost`,label:n(`settings.yuri.about.actions.checkForUpdates`),disabled:!!t.checking},{id:`confirm`,icon:a||t.submitting?`loader`:`download`,loading:a||t.submitting,label:n(`settings.yuri.about.hostUpdate.confirm`),disabled:!i||!e?.supported||a||t.submitting||!!t.failure||!!t.checking}]};return a&&r?s.status={kind:r.status===`downloading`?`download`:`activity`,label:n(`settings.yuri.about.hostUpdate.status.${r.status}`),progress:r.progress,detail:t.failure===`disconnected`?n(`settings.yuri.about.hostUpdate.reconnecting`):void 0}:t.checking===`initial`||t.submitting?s.status={kind:`activity`,label:n(`settings.yuri.about.state.checking`)}:o?s.message=n(`settings.yuri.about.hostUpdate.unsupported`):t.failure?s.error=n(t.failure===`disconnected`?`settings.yuri.about.hostUpdate.reconnecting`:`settings.yuri.about.toast.checkFailed`):!i&&e?.supported&&(s.message=r?.status===`succeeded`?n(`settings.yuri.about.hostUpdate.status.succeeded`):n(`settings.yuri.about.toast.latestVersion`)),r?.status===`failed`&&(s.error=n(`settings.yuri.about.hostUpdate.status.failed`)),s}function Hr(){let e=(0,Z.c)(7),{t:i}=Ae(),a=$.useSyncExternalStore(t,n,n),o=$.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,Q.jsx)(Ur,{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 Ur(e){let t=(0,Z.c)(58),{version:i,transport:a,generation:o,itemId:s,channel:c}=e,{t:l}=Ae(),u=N(),[d,f]=$.useState(!1),p=O(Wr),m=c??p??void 0,h=mr(a,o,m),g=h.data,_=g?.operation,v;t[0]===_?v=t[1]:(v=cr(_),t[0]=_,t[1]=v);let y=v,b;t[2]!==o||t[3]!==a?(b=e=>{let{plan:t}=e;return hr(t,a,o)},t[2]=o,t[3]=a,t[4]=b):b=t[4];let x,S;t[5]!==u||t[6]!==o||t[7]!==a?(x=(e,t)=>{a===n()&&o===r()&&u.setQueryData(ur(a,o,t.channel).queryKey,t=>t&&{...t,operation:e})},S=(e,t,i)=>{a===n()&&o===r()&&u.invalidateQueries({queryKey:ur(a,o,i.channel).queryKey,exact:!0})},t[5]=u,t[6]=o,t[7]=a,t[8]=x,t[9]=S):(x=t[8],S=t[9]);let C;t[10]!==b||t[11]!==x||t[12]!==S?(C={mutationFn:b,onSuccess:x,onSettled:S},t[10]=b,t[11]=x,t[12]=S,t[13]=C):C=t[13];let w=P(C),T;t[14]===h?T=t[15]:(T=()=>{f(!0),h.refetch()},t[14]=h,t[15]=T);let E=De(T),D=g?.supported===!1||h.error?.message===`host_update_unsupported`,k=h.isError||!!g?.checkError,A=w.isError&&w.variables?.channel===m,j=h.isPending?`initial`:h.isFetching?`refresh`:!1,M=D?`unsupported`:h.isError&&(y||A)?`disconnected`:k||A?`check`:null,F;t[16]!==w.isPending||t[17]!==g||t[18]!==l||t[19]!==j||t[20]!==M||t[21]!==i?(F=Vr(g,{versionFallback:i,checking:j,submitting:w.isPending,failure:M},l),t[16]=w.isPending,t[17]=g,t[18]=l,t[19]=j,t[20]=M,t[21]=i,t[22]=F):F=t[22];let I=F,L;t[23]!==m||t[24]!==w||t[25]!==h||t[26]!==g?(L=e=>{e===`check`&&h.refetch(),e===`confirm`&&g?.update&&w.mutate({plan:g,channel:m})},t[23]=m,t[24]=w,t[25]=h,t[26]=g,t[27]=L):L=t[27];let R=De(L),z=g?.currentVersion??i,B;t[28]!==y||t[29]!==g?.update||t[30]!==l?(B=g?.update&&!y&&(0,Q.jsx)(`span`,{"aria-label":l(`settings.yuri.about.hostUpdate.available`),className:`absolute -right-1.5 -top-0.5 size-1.5 rounded-full bg-[var(--status-error)]`}),t[28]=y,t[29]=g?.update,t[30]=l,t[31]=B):B=t[31];let V;t[32]!==z||t[33]!==B?(V=(0,Q.jsxs)(`span`,{className:`relative typography-ui-label font-mono text-foreground text-right`,children:[z,B]}),t[32]=z,t[33]=B,t[34]=V):V=t[34];let H;t[35]===l?H=t[36]:(H=l(`settings.yuri.about.hostUpdate.title`),t[35]=l,t[36]=H);let U;t[37]===l?U=t[38]:(U=l(`settings.yuri.about.hostUpdate.title`),t[37]=l,t[38]=U);let ee=y||h.isFetching?`loader`:g?.update?`download`:`refresh`,te=y||h.isFetching?`size-4 animate-spin`:`size-4`,W;t[39]!==ee||t[40]!==te?(W=(0,Q.jsx)(X,{name:ee,className:te}),t[39]=ee,t[40]=te,t[41]=W):W=t[41];let G;t[42]!==E||t[43]!==H||t[44]!==U||t[45]!==W?(G=(0,Q.jsx)(Me,{type:`button`,size:`icon`,variant:`ghost`,onClick:E,"aria-label":H,title:U,children:W}),t[42]=E,t[43]=H,t[44]=U,t[45]=W,t[46]=G):G=t[46];let K;t[47]!==s||t[48]!==V||t[49]!==G?(K=(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,"data-settings-item":s,children:[V,G]}),t[47]=s,t[48]=V,t[49]=G,t[50]=K):K=t[50];let q;t[51]!==R||t[52]!==I||t[53]!==d?(q=(0,Q.jsx)(Sr,{open:d,onOpenChange:f,model:I,onAction:R}),t[51]=R,t[52]=I,t[53]=d,t[54]=q):q=t[54];let ne;return t[55]!==K||t[56]!==q?(ne=(0,Q.jsxs)(Q.Fragment,{children:[K,q]}),t[55]=K,t[56]=q,t[57]=ne):ne=t[57],ne}function Wr(e){return e.otaChannelOverride}var Gr=`/mcp/oauth/callback`,Kr=e=>{if(typeof window>`u`)return null;try{let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t.length%4==0?``:`=`.repeat(4-t.length%4),r=window.atob(t+n),i=Uint8Array.from(r,e=>e.charCodeAt(0));return new TextDecoder().decode(i)}catch{return null}},qr=e=>{let t=Yr(e.get(`state`));if(t)return t;let n=e.get(`server`);if(typeof n!=`string`||!n.trim())return null;let r=e.get(`directory`);return{name:n.trim(),directory:typeof r==`string`&&r.trim()?r.trim():null}},Jr=e=>{let t=e.get(`state`);return typeof t==`string`&&t.trim()||null},Yr=e=>{if(typeof e!=`string`||!e.trim())return null;let t=Kr(e.trim());if(!t)return null;try{let e=JSON.parse(t);return e?.v!==1||typeof e.n!=`string`||!e.n.trim()?null:{name:e.n.trim(),directory:typeof e.d==`string`&&e.d.trim()?e.d.trim():null}}catch{return null}},Xr=e=>typeof e==`object`&&!!e&&`updateStatus`in e&&typeof e.updateStatus==`function`,Zr=e=>{let t=document.createElement(`div`);t.className=`cm-vim-panel`;let n=gn(e);if(!n)return{top:!1,dom:t};n.state.statusbar=t;let r=n.state.vimPlugin;return Xr(r)&&r.updateStatus(),{top:!1,dom:t,destroy(){n.state.statusbar===t&&(n.state.statusbar=null)}}};function Qr(e){return e?[hn(),te.of(Zr),K()]:[]}var $r={next:`Next match`,prev:`Previous match`,select:`Select all matches`,replace:`Replace`,replaceAll:`Replace all`,close:`Close`},ei={case:`Match case`,re:`Regular expression`,word:`Match whole word`};function ti(e){let t=e.querySelector(`.cm-search`);if(t){for(let[e,n]of Object.entries($r)){let r=t.querySelector(`button[name="${e}"]`);r&&!r.title&&(r.title=n)}for(let[e,n]of Object.entries(ei)){let r=t.querySelector(`input[name="${e}"]`)?.parentElement;r&&!r.title&&(r.title=n)}}}var ni=new WeakMap;function ri(e,t){let n=dn(e.state);if(!n.valid)return ni.delete(e),0;let r=ni.get(e);if(!t&&r?.doc===e.state.doc&&r.query.eq(n))return r.total;let i=n.getCursor(e.state),a=0;for(let e=i.next();!e.done;e=i.next())a+=1;return ni.set(e,{query:n,doc:e.state.doc,total:a}),a}function ii(e){let t=dn(e.state);if(!t.valid)return 0;let n=e.state.selection.main,r=t.getCursor(e.state),i=0,a=0;for(let e=r.next();!e.done;e=r.next()){let t=e.value;if(i+=1,a===0&&(a=i),n.from===t.from&&n.to===t.to||n.from<t.to&&n.to>t.from||t.from>=n.head)return i}return a}function ai(e,t,n=!1){let r=e.querySelector(`.cm-search`);if(!r)return;let i=r.querySelector(`.cm-search-message`);if(!i){i=document.createElement(`span`),i.className=`cm-search-message`,i.setAttribute(`aria-live`,`polite`);let e=r.querySelector(`button[name="next"]`),t=e?.parentNode===r?e:r.firstChild;r.insertBefore(i,t)}let a=ri(t,n),o=a===0?0:ii(t);i.textContent=a===0?``:`${o}/${a}`}var oi=new de,si=new de,ci=new de,li=new de,ui=new de,di=new de,fi=new de,pi=e=>e,mi=ae,hi=ln,gi=pn,_i=class extends se{id;containerMap;constructor(e,t){super(),this.id=e,this.containerMap=t}toDOM(){let e=this.containerMap.get(this.id);return e||(e=document.createElement(`div`),e.className=`yuri-block-widget`,e.dataset.widgetId=this.id,this.containerMap.set(this.id,e)),e}eq(e){return e.id===this.id}destroy(){}},vi=(e,t)=>!e||e.length===0?[]:_e.define({create(n){let r=new fe,i=[...e].sort((e,t)=>e.afterLine-t.afterLine);for(let e of i){let i=n.doc.lines;if(e.afterLine>i)continue;let a=n.doc.line(e.afterLine);r.add(a.to,a.to,G.widget({widget:new _i(e.id,t),block:!0,side:1}))}return r.finish()},update(e,t){return e.map(t.changes)},provide:e=>q.decorations.from(e)}),yi=e=>{if(!e)return[];let t=Math.max(1,e.start),n=Math.max(t,e.end);return oe.fromClass(class{decorations;constructor(e){this.decorations=this.build(e)}update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=this.build(e.view))}build(e){let r=new fe;for(let i=t;i<=n&&i<=e.state.doc.lines;i+=1){let t=e.state.doc.line(i);r.add(t.from,t.from,G.line({class:`yuri-cm-selected-line`}))}return r.finish()}},{decorations:e=>e.decorations})};function bi({value:e,onChange:t,extensions:n,className:r,readOnly:i,lineNumbersConfig:a,highlightLines:o,onViewReady:s,onViewDestroy:c,blockWidgets:l,enableSearch:u,searchOpen:d,onSearchOpenChange:f,vimMode:p}){let m=$.useRef(null),h=$.useRef(null),g=$.useRef(e),_=$.useRef(t),v=$.useRef(s),y=$.useRef(c),b=$.useRef(f),x=$.useRef(l),S=$.useRef(p),C=$.useRef(new Map),[w,T]=$.useState([]),E=$.useCallback(e=>{let t=(e??[]).map(e=>{let t=C.current.get(e.id);return t?{id:e.id,content:e.content,container:t}:null}).filter(e=>e!==null);T(e=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return e.id===r.id&&e.content===r.content&&e.container===r.container})?e:t)},[]),D=$.useCallback(e=>{let t=m.current,n=e??h.current;if(!t||!n)return;let r=n.dom.querySelector(`.cm-gutters`),i=r instanceof HTMLElement?r.getBoundingClientRect().width:0;t.style.setProperty(`--yuri-editor-gutter-width`,`${i}px`)},[]);return $.useEffect(()=>{g.current=e},[e]),$.useEffect(()=>{_.current=t},[t]),$.useEffect(()=>{v.current=s,y.current=c},[s,c]),$.useEffect(()=>{b.current=f},[f]),$.useEffect(()=>{x.current=l,E(l)},[l,E]),$.useEffect(()=>{if(!m.current)return;let e=(()=>{if(typeof document>`u`)return null;let e=document.querySelector(`meta[name="csp-nonce"]`)?.getAttribute(`content`);if(e)return e;let t=window.__YURI_CSP_NONCE__;return typeof t==`string`&&t.length>0?t:null})(),t=ve.create({doc:g.current,extensions:[...e?[q.cspNonce.of(e)]:[],ne({fixed:!0}),oi.of(ce(a)),sn(),W.of(` `),fi.of(Qr(p)),le.of([on,...an,...cn]),q.updateListener.of(e=>{D(e.view),(e.viewportChanged||e.geometryChanged)&&E(x.current);let t=un(e.startState),n=un(e.state);t!==n&&b.current?.(n);let r=!dn(e.startState).eq(dn(e.state));if(n&&(t!==n||r||e.docChanged||e.selectionSet)&&ai(e.view.dom,e.view,t!==n||r||e.docChanged),!e.docChanged)return;let i=e.state.doc.toString();g.current=i,_.current(i),E(x.current)}),si.of(q.editable.of(!i)),ci.of(n??[]),li.of(yi(o)),ui.of(vi(l,C.current)),di.of(u?[fn({top:!0}),le.of(pi(mn))]:[])]});return h.current=new q({state:t,parent:m.current}),mi(h.current,h.current.state.doc.length,200),h.current.requestMeasure(),requestAnimationFrame(()=>{D(h.current),E(x.current)}),h.current&&v.current?.(h.current),()=>{y.current?.(),h.current?.destroy(),h.current=null,T([])}},[x,D,E]),$.useEffect(()=>{let e=h.current;e&&(e.dispatch({effects:[oi.reconfigure(ce(a)),si.reconfigure(q.editable.of(!i)),ci.reconfigure(n??[]),li.reconfigure(yi(o)),ui.reconfigure(vi(l,C.current)),di.reconfigure(u?[fn({top:!0}),le.of(pi(mn))]:[])]}),mi(e,e.state.doc.length,200),e.requestMeasure(),requestAnimationFrame(()=>{D(e),E(x.current)}))},[n,o,a,i,l,u,D,E]),$.useEffect(()=>{let e=h.current;if(!e){S.current=p;return}S.current!==p&&(S.current=p,e.dispatch({effects:fi.reconfigure(Qr(p))}))},[p]),$.useEffect(()=>{let e=h.current;!e||u===!1||(d?(hi(e),requestAnimationFrame(()=>{ti(e.dom),ai(e.dom,e,!0)})):gi(e))},[d,u]),$.useEffect(()=>{let t=h.current;if(!t)return;let n=t.state.doc.toString();n!==e&&(t.dispatch({changes:{from:0,to:n.length,insert:e}}),mi(t,t.state.doc.length,300),t.requestMeasure(),requestAnimationFrame(()=>D(t)))},[e,D]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{ref:m,className:Y(`h-full w-full`,`[&_.cm-editor]:h-full [&_.cm-editor]:w-full`,`[&_.cm-scroller]:font-mono [&_.cm-scroller]:text-[var(--text-code)] [&_.cm-scroller]:leading-6`,`[&_.cm-lineNumbers]:text-[var(--tools-edit-line-number)]`,r)}),w.map(e=>(0,Pr.createPortal)(e.content,e.container,e.id))]})}var xi=pe.define(Ee),Si=Ce.data.of({commentTokens:{line:`//`,block:{open:`/*`,close:`*/`}}});function Ci(e){let t=e.trim().toLowerCase();switch(t){case`bash`:case`sh`:case`zsh`:case`shell`:case`shellsession`:case`console`:return xi;case`json`:case`jsonc`:case`json5`:return Se().language;case`js`:case`javascript`:return be().language;case`jsx`:return be({jsx:!0}).language;case`ts`:case`typescript`:return be({typescript:!0}).language;case`tsx`:return be({typescript:!0,jsx:!0}).language;case`html`:return xe().language;case`css`:return ye().language;case`py`:case`python`:return Te().language;case`md`:case`markdown`:case`mdown`:case`mkd`:return we().language;case`heex`:case`eex`:case`leex`:return xe().language;default:return ge.matchLanguageName(_n,t,!0)}}var wi=e=>e.split(`/`).pop()?.toLowerCase()??``,Ti=e=>{let t=wi(e);return t?ge.matchFilename(_n,t):null},Ei=()=>ie(ue.define([{tag:[J.heading1,J.heading2,J.heading3,J.heading4,J.heading5,J.heading6],fontWeight:`600`},{tag:J.strong,fontWeight:`600`},{tag:J.emphasis,fontStyle:`italic`},{tag:J.strikethrough,textDecoration:`line-through`},{tag:[J.link,J.url],color:`var(--markdown-link, currentColor)`,textDecoration:`underline`},{tag:J.monospace,color:`var(--markdown-inline-code, currentColor)`,backgroundColor:`var(--markdown-inline-code-bg, transparent)`},{tag:J.quote,color:`var(--markdown-blockquote, currentColor)`,fontStyle:`italic`},{tag:J.list,color:`color-mix(in srgb, var(--muted-foreground) 40%, var(--foreground) 60%)`},{tag:J.heading,color:`var(--markdown-heading1, currentColor)`}]));function Di(e){let t=e.toLowerCase();switch(wi(t)){case`makefile`:case`gnumakefile`:return xi}let n=t.lastIndexOf(`.`),r=n>=0?t.slice(n+1):``;switch(r){case`ts`:case`tsx`:case`mts`:case`cts`:return be({typescript:!0,jsx:r===`tsx`});case`js`:case`jsx`:case`mjs`:case`cjs`:return be({typescript:!1,jsx:r===`jsx`});case`jsonc`:case`json5`:return[Se(),Si];case`json`:case`jsonl`:case`ndjson`:case`geojson`:return Se();case`css`:case`scss`:case`sass`:case`less`:return ye();case`html`:case`htm`:case`xml`:case`drawio`:case`dio`:return xe();case`md`:case`mdx`:case`markdown`:case`mdown`:case`mkd`:return[we({codeLanguages:Ci}),Ei()];case`sh`:case`bash`:case`zsh`:case`fish`:case`env`:return xi;case`py`:case`pyw`:case`pyi`:return Te();default:return null}}async function Oi(e){let t=Ti(e);if(!t)return null;if(t.support)return t.support;try{return await t.load()}catch{return null}}function ki(e,t){let n=e.metadata.variant===`dark`,r=e.config?.fonts?.mono||`monospace`,i=e.colors.syntax.highlights||{},a=e.colors.syntax.tokens||{},o=t?.fontSize?`${t.fontSize}px`:`var(--text-code)`,s=q.theme({"&":{backgroundColor:`var(--background)`,color:e.colors.syntax.base.foreground,fontSize:o,lineHeight:`1.5`,position:`relative`},".cm-scroller":{fontFamily:r,backgroundColor:`var(--background)`},".cm-comment":{color:e.colors.syntax.base.comment},".cm-keyword":{color:e.colors.syntax.base.keyword},".cm-string":{color:e.colors.syntax.base.string},".cm-string-2":{color:a.stringEscape||e.colors.syntax.base.string},".cm-number":{color:e.colors.syntax.base.number},".cm-operator":{color:e.colors.syntax.base.operator},".cm-punctuation":{color:a.punctuation||e.colors.syntax.base.comment},".cm-atom":{color:a.boolean||e.colors.syntax.base.number},".cm-builtin":{color:a.functionCall||e.colors.syntax.base.function},".cm-def":{color:a.variableGlobal||e.colors.syntax.base.variable},".cm-attribute":{color:a.variableOther||a.variableProperty||e.colors.syntax.base.operator},".cm-meta":{color:e.colors.syntax.base.comment},".cm-property":{color:a.variableProperty||e.colors.syntax.base.keyword},".cm-variable":{color:e.colors.syntax.base.variable},".cm-variable-2":{color:a.variableOther||e.colors.syntax.base.function},".cm-variable-3":{color:a.variableGlobal||e.colors.syntax.base.type},".cm-tag":{color:a.tag||e.colors.syntax.base.keyword},".cm-link":{color:a.url||e.colors.syntax.base.keyword,textDecoration:`underline`},".cm-content":{caretColor:e.colors.interactive.cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:e.colors.interactive.cursor},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e.colors.interactive.selection},".cm-gutters":{backgroundColor:`var(--background)`,color:i.lineNumber||e.colors.syntax.base.comment,borderRight:`1px solid ${e.colors.interactive.border}`,position:`sticky`,paddingRight:`8px`,left:0,zIndex:2,boxShadow:`0 0 0 var(--background)`},".cm-gutter":{backgroundColor:`var(--background)`},".cm-gutterElement":{backgroundColor:`var(--background)`},".cm-lineNumbers":{backgroundColor:`var(--background)`},".cm-lineNumbers .cm-gutterElement":{paddingLeft:`8px`,paddingRight:`8px`,minWidth:`42px`},".cm-activeLineGutter":{color:i.lineNumberActive||e.colors.syntax.base.foreground},".cm-activeLine":{backgroundColor:e.colors.surface.overlay},".cm-panels":{backgroundColor:`transparent`,color:e.colors.surface.foreground,position:`absolute`,top:`0`,right:`0`,left:`auto`,width:`auto`,zIndex:10,pointerEvents:`none`},".cm-panels-top":{borderBottom:`none`,position:`absolute`,top:`6px`,right:`14px`,left:`auto`,width:`auto`},".cm-panels-bottom":{position:`static`,width:`100%`,pointerEvents:`auto`},".cm-panels-bottom .cm-vim-panel":{borderTop:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.elevated,color:e.colors.surface.mutedForeground,fontFamily:`var(--font-mono)`,fontSize:`12px`,minHeight:`22px`,padding:`2px 8px`},".cm-panel.cm-search":{pointerEvents:`auto`,padding:`4px`,backgroundColor:`color-mix(in srgb, ${e.colors.surface.elevated} 85%, transparent)`,border:`1px solid ${e.colors.interactive.border}`,borderRadius:`10px`,boxShadow:`0 2px 8px color-mix(in srgb, ${e.colors.surface.background} 60%, transparent)`,width:`auto`,minWidth:`360px`,maxWidth:`480px`},".cm-search":{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:`0`,width:`100%`,color:e.colors.surface.foreground,fontFamily:`inherit`,fontSize:`13px`,lineHeight:`1`},".cm-search br":{display:`none`},".cm-search .cm-textfield":{appearance:`none`,height:`26px`,margin:0,padding:`0 8px`,borderRadius:`6px !important`,border:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.background,color:e.colors.surface.foreground,fontFamily:`inherit`,fontSize:`12px`,lineHeight:`1`,outline:`none`,transition:`border-color 150ms ease`},".cm-search .cm-textfield::placeholder":{color:e.colors.surface.mutedForeground,opacity:1},".cm-search .cm-textfield:focus":{borderColor:e.colors.primary.base},'.cm-search .cm-textfield[name="search"]':{order:1,flex:`1 1 120px`,maxWidth:`calc(100% - 142px)`,minWidth:`100px`},".cm-search label":{order:2,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:0,marginLeft:`1px`,padding:0,borderRadius:`4px`,border:`1px solid transparent`,backgroundColor:`transparent`,color:`transparent`,cursor:`pointer`,userSelect:`none`,fontSize:`1px`,lineHeight:`0`,overflow:`hidden`,position:`relative`,transition:`background-color 120ms ease, border-color 120ms ease`},".cm-search label:hover":{backgroundColor:e.colors.interactive.hover},'.cm-search label:has(input[type="checkbox"]:checked)':{backgroundColor:e.colors.interactive.hover,borderColor:e.colors.interactive.border},'.cm-search [type="checkbox"]':{appearance:`none`,WebkitAppearance:`none`,width:`0`,height:`0`,margin:`0`,padding:`0`,border:`none`,position:`absolute`,opacity:`0`,pointerEvents:`none`},".cm-search label::after":{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,fontSize:`13px`,fontWeight:`600`,lineHeight:`1`,fontFamily:`inherit`,color:e.colors.surface.mutedForeground,pointerEvents:`none`},".cm-search label:hover::after":{color:e.colors.surface.foreground},'.cm-search label:has(input[type="checkbox"]:checked)::after':{color:e.colors.surface.foreground},'.cm-search label:has(input[name="case"])::after':{content:`"Aa"`,fontSize:`12px`,letterSpacing:`-0.5px`},'.cm-search label:has(input[name="re"])::after':{content:`".*"`,fontSize:`13px`,fontFamily:`monospace`},'.cm-search label:has(input[name="word"])::after':{content:`"ab"`,fontSize:`12px`,textDecoration:`underline`,textUnderlineOffset:`2px`},".cm-search .cm-search-message":{order:3,color:e.colors.surface.mutedForeground,backgroundColor:`transparent`,border:`none`,borderRadius:`0`,padding:`0 6px`,fontSize:`11px`,whiteSpace:`nowrap`,lineHeight:`26px`},".cm-search .cm-button":{appearance:`none`,WebkitAppearance:`none`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:0,marginLeft:`1px`,padding:0,borderRadius:`4px`,border:`none`,backgroundColor:`transparent`,backgroundImage:`none`,color:`transparent`,cursor:`pointer`,fontSize:`1px`,fontWeight:`400`,lineHeight:`0`,overflow:`hidden`,position:`relative`,boxShadow:`none`,transition:`background-color 120ms ease`},".cm-search .cm-button::after":{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,fontSize:`15px`,lineHeight:`1`,color:e.colors.surface.mutedForeground,pointerEvents:`none`},".cm-search .cm-button:hover":{backgroundColor:e.colors.interactive.hover},".cm-search .cm-button:hover::after":{color:e.colors.surface.foreground},".cm-search .cm-button:active":{backgroundColor:e.colors.interactive.active},".cm-search .cm-button:focus-visible":{outline:`none`,boxShadow:`0 0 0 1px ${e.colors.interactive.focusRing}`},".cm-search .cm-button:disabled":{opacity:.4,cursor:`default`,pointerEvents:`none`},'.cm-search .cm-button[name="prev"]':{order:21,marginTop:`2px`},'.cm-search .cm-button[name="prev"]::after':{content:`"↑"`},'.cm-search .cm-button[name="next"]':{order:22,marginTop:`2px`},'.cm-search .cm-button[name="next"]::after':{content:`"↓"`},'.cm-search .cm-button[name="select"]':{order:23,marginTop:`2px`},'.cm-search .cm-button[name="select"]::after':{content:`"≡"`,fontSize:`17px`},'.cm-panel.cm-search button[name="close"]':{order:5,appearance:`none`,WebkitAppearance:`none`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:`0 0 0 auto`,padding:`0`,borderRadius:`4px`,border:`none`,backgroundColor:`transparent`,backgroundImage:`none`,color:e.colors.surface.mutedForeground,cursor:`pointer`,fontSize:`16px`,lineHeight:`1`,boxShadow:`none`,position:`relative`,overflow:`visible`,transition:`background-color 120ms ease, color 120ms ease`},'.cm-panel.cm-search button[name="close"]:hover':{backgroundColor:e.colors.interactive.hover,color:e.colors.surface.foreground},'.cm-search .cm-button[name="replace"]':{order:24,marginTop:`2px`},'.cm-search .cm-button[name="replace"]::after':{content:`"⇄"`},'.cm-search .cm-button[name="replaceAll"], .cm-search .cm-button[name="replace-all"]':{order:25,marginTop:`2px`},'.cm-search .cm-button[name="replaceAll"]::after, .cm-search .cm-button[name="replace-all"]::after':{content:`"⇉"`},'.cm-search .cm-textfield[name="replace"]':{order:20,flex:`1 1 100%`,maxWidth:`calc(100% - 142px)`,minWidth:`80px`,marginTop:`2px`},".cm-searchMatch":{backgroundColor:e.colors.status.infoBackground,boxShadow:`inset 0 0 0 1px ${e.colors.status.infoBorder}`,borderRadius:`2px`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:e.colors.interactive.selection,color:e.colors.interactive.selectionForeground,boxShadow:`inset 0 0 0 1px ${e.colors.interactive.borderFocus}`},"&.cm-focused":{outline:`none`}},{dark:n}),c=ue.define([{tag:[J.comment,J.docComment,J.meta,J.documentMeta],class:`cm-comment`},{tag:[J.keyword,J.controlKeyword,J.moduleKeyword,J.definitionKeyword,J.modifier],class:`cm-keyword`},{tag:[J.operatorKeyword,J.operator,J.derefOperator,J.updateOperator,J.definitionOperator,J.typeOperator,J.controlOperator,J.logicOperator,J.bitwiseOperator,J.arithmeticOperator,J.compareOperator],class:`cm-operator`},{tag:[J.punctuation,J.separator,J.bracket,J.paren,J.brace,J.squareBracket,J.angleBracket],class:`cm-punctuation`},{tag:[J.string,J.regexp,J.attributeValue,J.special(J.string),J.monospace],class:`cm-string`},{tag:J.escape,class:`cm-string-2`},{tag:[J.number,J.bool,J.atom,J.null,J.self],class:`cm-number`},{tag:[J.function(J.variableName),J.function(J.definition(J.variableName)),J.function(J.propertyName),J.standard(J.variableName),J.special(J.variableName)],class:`cm-builtin`},{tag:J.definition(J.variableName),class:`cm-def`},{tag:[J.variableName,J.local(J.variableName),J.constant(J.variableName),J.literal],class:`cm-variable`},{tag:J.propertyName,class:`cm-property`},{tag:J.attributeName,class:`cm-attribute`},{tag:[J.className,J.typeName,J.namespace],class:`cm-variable-3`},{tag:[J.tagName,J.labelName,J.annotation,J.macroName],class:`cm-tag`},{tag:J.link,class:`cm-link`},{tag:[J.heading,J.heading1,J.heading2,J.heading3,J.heading4,J.heading5,J.heading6],class:`cm-keyword`}]),l=ue.define([{tag:[J.comment,J.docComment,J.meta,J.documentMeta],color:e.colors.syntax.base.comment},{tag:[J.keyword,J.controlKeyword,J.moduleKeyword,J.definitionKeyword,J.modifier],color:e.colors.syntax.base.keyword},{tag:[J.operatorKeyword,J.operator,J.derefOperator,J.updateOperator,J.definitionOperator,J.typeOperator,J.controlOperator,J.logicOperator,J.bitwiseOperator,J.arithmeticOperator,J.compareOperator],color:e.colors.syntax.base.operator},{tag:[J.string,J.regexp,J.attributeValue,J.special(J.string),J.monospace],color:e.colors.syntax.base.string},{tag:J.escape,color:a.stringEscape||e.colors.syntax.base.string},{tag:[J.number,J.bool,J.atom,J.null,J.self],color:e.colors.syntax.base.number},{tag:[J.function(J.variableName),J.function(J.definition(J.variableName)),J.function(J.propertyName),J.standard(J.variableName),J.special(J.variableName)],color:e.colors.syntax.base.function},{tag:J.definition(J.variableName),color:a.variableGlobal||e.colors.syntax.base.variable},{tag:[J.variableName,J.local(J.variableName),J.constant(J.variableName),J.literal],color:e.colors.syntax.base.variable},{tag:J.propertyName,color:a.variableProperty||e.colors.syntax.base.variable},{tag:J.attributeName,color:a.variableOther||e.colors.syntax.base.variable},{tag:[J.className,J.typeName,J.namespace],color:e.colors.syntax.base.type},{tag:[J.tagName,J.labelName,J.annotation,J.macroName],color:a.tag||e.colors.syntax.base.keyword},{tag:J.link,color:a.url||e.colors.syntax.base.function,textDecoration:`underline`},{tag:[J.punctuation,J.separator,J.bracket,J.paren,J.brace,J.squareBracket,J.angleBracket],color:a.punctuation||e.colors.syntax.base.comment}]);return t?.syntaxColors===!1?[s]:[s,ie(he,{fallback:!0}),ie(re),ie(c),ie(l)]}var Ai=180,ji=me.define(),Mi=1,Ni=2,Pi=4,Fi=new Map,Ii=(e,t)=>{let n=`${e}|${t}`,r=Fi.get(n);if(r)return r;let i=``;e&&(i+=`color:${e};`),t&Mi&&(i+=`font-style:italic;`),t&Ni&&(i+=`font-weight:bold;`),t&Pi&&(i+=`text-decoration:underline;`);let a=G.mark({attributes:{style:i}});return Fi.set(n,a),a},Li=(e,t)=>{let n=new fe,r=e.state.doc,i=Math.min(t.length,r.lines);for(let e=0;e<i;e+=1){let i=t[e];if(!i||i.length===0)continue;let a=r.line(e+1),o=a.from;for(let[e,t,r]of i){if(e<=0)continue;let i=o,s=Math.min(o+e,a.to);o+=e,!(s<=i)&&(!t&&!r||n.add(i,s,Ii(t,r)))}}return n.finish()},Ri=_e.define({create(){return G.none},update(e,t){let n=e.map(t.changes);for(let e of t.effects)e.is(ji)&&(n=e.value);return n},provide:e=>q.decorations.from(e)}),zi=e=>oe.fromClass(class{timer;generation=0;abortController;constructor(e){this.tokenize(e)}update(e){e.docChanged&&this.schedule(e.view)}schedule(e){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.tokenize(e)},Ai)}async tokenize(t){let n=++this.generation;this.abortController?.abort();let r=new AbortController;this.abortController=r;let i=t.state.doc.toString(),a=await Zt(i,e.language,e.themeName,e.theme,{signal:r.signal,priority:`visible`});a&&(r.signal.aborted||n===this.generation&&t.state.doc.length===i.length&&t.dispatch({effects:ji.of(Li(t,a))}))}destroy(){this.timer&&clearTimeout(this.timer),this.abortController?.abort(),this.abortController=void 0}}),Bi=e=>[Ri,zi(e)],Vi=e=>{let t=(0,Z.c)(11),{currentMode:n,onToggle:r}=e,i=n===`preview`,a=i?`Switch to edit mode`:`Switch to preview mode`,o=i?`Edit`:`Preview`,s;t[0]===i?s=t[1]:(s=i?(0,Q.jsx)(X,{name:`eye`,className:`size-4`,"aria-hidden":`true`}):(0,Q.jsx)(X,{name:`eye-off`,className:`size-4`,"aria-hidden":`true`}),t[0]=i,t[1]=s);let c;t[2]!==a||t[3]!==r||t[4]!==s?(c=(0,Q.jsx)(bt,{asChild:!0,children:(0,Q.jsx)(Me,{variant:`ghost`,size:`sm`,onClick:r,"aria-label":a,className:`h-5 w-5 p-0`,children:s})}),t[2]=a,t[3]=r,t[4]=s,t[5]=c):c=t[5];let l;t[6]===o?l=t[7]:(l=(0,Q.jsx)(xt,{sideOffset:8,children:o}),t[6]=o,t[7]=l);let u;return t[8]!==c||t[9]!==l?(u=(0,Q.jsxs)(St,{children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10],u},Hi=_()(y(v((e,t)=>({selectedProfileId:null,defaultGitIdentityId:null,profiles:[],globalIdentity:null,discoveredCredentials:[],isLoading:!1,setSelectedProfile:t=>{e({selectedProfileId:t})},loadProfiles:async()=>{e({isLoading:!0});let n=t().profiles;try{return e({profiles:await nt(),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 rt();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 st()}),!0}catch(t){return console.error(`Failed to discover git credentials:`,t),e({discoveredCredentials:[]}),!1}},loadDefaultGitIdentityId:async()=>{let t=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null};try{let n=null;if(n===null){let e=g()?.settings;if(e)try{n=t(((await e.load())?.settings||{}).defaultGitIdentityId)}catch{}}if(n===null)try{let e=await a(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});e.ok&&(n=t((await e.json().catch(()=>null))?.defaultGitIdentityId))}catch{}return e({defaultGitIdentityId:n}),!0}catch(e){return console.error(`Failed to load default git identity setting:`,e),!1}},setDefaultGitIdentityId:async t=>{try{let n=typeof t==`string`?t.trim():``,r=n.length>0?n:``;return await j({defaultGitIdentityId:r}),e({defaultGitIdentityId:r.length>0?r:null}),!0}catch(e){return console.error(`Failed to save default git identity setting:`,e),!1}},createProfile:async e=>{try{let n={...e,id:e.id||`profile-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,color:e.color||`keyword`,icon:e.icon||`branch`};return await ot(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 tt(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 it(n),t().selectedProfileId===n&&e({selectedProfileId:null}),await t().loadProfiles(),!0}catch(e){return console.error(`Failed to delete git identity profile:`,e),!1}},getProfileById:e=>{let{profiles:n,globalIdentity:r}=t();return e===`global`?r||void 0:n.find(t=>t.id===e)},getUnimportedCredentials:()=>{let{profiles:e,discoveredCredentials:n}=t();return n.filter(t=>!e.some(e=>e.authType===`token`&&e.host===t.host))}}),{name:`git-identities-store`,storage:D(),partialize:e=>({selectedProfileId:e.selectedProfileId})}),{name:`git-identities-store`}));typeof window<`u`&&(window.__zustand_git_identities_store__=Hi);var Ui=`w-full max-w-[30rem]`,Wi=e=>{let t=(0,Z.c)(23),{title:n,description:r,settingsItem:i,titleAccessory:a,headerAction:o,children:s,className:c,contentClassName:l}=e,u;t[0]===n?u=t[1]:(u=(0,Q.jsx)(`span`,{className:`truncate`,children:n}),t[0]=n,t[1]=u);let d;t[2]!==u||t[3]!==a?(d=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[u,a]}),t[2]=u,t[3]=a,t[4]=d):d=t[4];let f;t[5]===o?f=t[6]:(f=o?(0,Q.jsx)(`div`,{className:`shrink-0`,children:o}):null,t[5]=o,t[6]=f);let p;t[7]!==d||t[8]!==f?(p=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[d,f]}),t[7]=d,t[8]=f,t[9]=p):p=t[9];let m;t[10]===l?m=t[11]:(m=Y(`yuri-settings-group-row`,l),t[10]=l,t[11]=m);let h;t[12]!==s||t[13]!==m?(h=(0,Q.jsx)(`div`,{className:m,children:s}),t[12]=s,t[13]=m,t[14]=h):h=t[14];let g;t[15]!==r||t[16]!==p||t[17]!==h?(g=(0,Q.jsx)(Ir,{className:`yuri-settings-detail-group`,label:p,description:r,children:h}),t[15]=r,t[16]=p,t[17]=h,t[18]=g):g=t[18];let _;return t[19]!==c||t[20]!==i||t[21]!==g?(_=(0,Q.jsx)(`div`,{"data-settings-item":i,className:c,children:g}),t[19]=c,t[20]=i,t[21]=g,t[22]=_):_=t[22],_},Gi=450,Ki=({projectRef:e=null})=>{let{t}=Ae(),{isMobile:n,isTablet:r}=Gt(),i=n||r,a=Re(e=>e.getActiveProject()),o=e?.path??a?.path??null,s=Ie(e=>e.getWorktreeMetadata),c=qe(),l=C(e=>e.homeDirectory),[u,d]=$.useState([]),[f,p]=$.useState(!1),[m,h]=$.useState(!1),[g,_]=$.useState(null),[v,y]=$.useState(null),[b,x]=$.useState([]),[S,w]=$.useState(!1),T=$.useRef(!1),E=$.useMemo(()=>e?.id&&e?.path?{id:e.id,path:e.path}:!a?.id||!o?null:{id:a.id,path:o},[a?.id,o,e?.id,e?.path]),D=$.useCallback(async()=>{if(!(!E||v===!1))try{let e=await ft(E);x(e)}catch{}},[E,v]);$.useEffect(()=>{if(!o)return;let e=!1;return y(null),(async()=>{try{let t=await at(o);if(e)return;y(t)}catch{}})(),()=>{e=!0}},[o]),$.useEffect(()=>{if(!E){x([]),w(!1);return}if(v===!1){x([]),w(!1);return}let e=!1;return w(!0),x([]),(async()=>{try{let t=await ft(E);if(e)return;x(t)}catch{}finally{e||w(!1)}})(),()=>{e=!0}},[E,v]),$.useEffect(()=>{if(!E)return;let e=!1;return h(!0),(async()=>{try{let[t,n]=await Promise.all([He(E),We(E)]);if(!e){let e=t.length>0?t:[``];d(e),_(JSON.stringify(e)),p(n)}}catch{e||(d([``]),_(JSON.stringify([``])),p(!1))}finally{e||h(!1)}})(),()=>{e=!0}},[E]);let O=$.useCallback(async e=>{if(!E)return!1;let n=e.filter(e=>e.trim().length>0);try{return await Ue(E,n)?(_(JSON.stringify(e)),!0):(Pe.error(t(`settings.yuri.worktrees.setup.toast.saveFailed`)),!1)}catch{return Pe.error(t(`settings.yuri.worktrees.setup.toast.saveFailed`)),!1}},[E,t]),k=$.useMemo(()=>g!==null&&g!==JSON.stringify(u),[g,u]);$.useEffect(()=>{if(!k||m||T.current)return;let e=window.setTimeout(()=>{T.current||(T.current=!0,(async()=>{try{await O(u)}finally{T.current=!1}})())},Gi);return()=>{window.clearTimeout(e)}},[k,m,O,u]);let A=$.useCallback((e,t)=>{d(n=>{let r=[...n];return r[e]=t,r})},[]),j=$.useCallback(()=>{d(e=>[...e,``])},[]),M=$.useCallback(e=>{d(t=>{let n=t.filter((t,n)=>n!==e);return n.length>0?n:[``]})},[]),N=$.useCallback(()=>{!k||T.current||(T.current=!0,(async()=>{try{await O(u)}finally{T.current=!1}})())},[k,O,u]),P=$.useCallback(e=>{p(e),E&&Ke(E,e)},[E]),F=$.useCallback(e=>{let t=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),n=t(e.path),r=c.filter(e=>{let r=s(e.id);if(r?.path&&t(r.path)===n)return!0;let i=e.directory;return!!(i&&t(i)===n)}),i=new Set(r.map(e=>e.id)),a=[...Ne.getState().activeSessions,...Ne.getState().archivedSessions],o=e=>{let t=a.filter(t=>{let n=t.parentID;return n&&e.has(n)});if(t.length===0)return[];let n=new Set(t.map(e=>e.id));return[...t,...o(n)]},l=o(i),u=new Set,d=[...r,...l].filter(e=>!u.has(e.id)&&(u.add(e.id),!0));Fe.requestDelete({sessions:d,mode:`worktree`,worktree:e})},[c,s]),I=$.useMemo(()=>c.map(e=>e.id).join(`,`),[c]);$.useEffect(()=>{v&&o&&D()},[I,v,o,D]);let L=(0,Q.jsxs)(St,{children:[(0,Q.jsx)(bt,{asChild:!0,children:(0,Q.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,Q.jsxs)(xt,{sideOffset:8,className:`max-w-xs`,children:[t(`settings.yuri.worktrees.setup.tooltipPrefix`),` `,(0,Q.jsx)(`code`,{className:`font-mono text-xs bg-sidebar-accent/50 px-1 rounded`,children:`$ROOT_PROJECT_PATH`}),` `,t(`settings.yuri.worktrees.setup.tooltipSuffix`)]})]}),R=(0,Q.jsxs)(St,{children:[(0,Q.jsx)(bt,{asChild:!0,children:(0,Q.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,Q.jsx)(xt,{sideOffset:8,className:`max-w-xs`,children:t(`settings.yuri.worktrees.list.tooltip`)})]});return o?v===!1?(0,Q.jsx)(Wi,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.worktrees.state.gitOnly`)})}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Wi,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,titleAccessory:L,children:m?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.worktrees.setup.loading`)}):(0,Q.jsxs)(`div`,{className:Y(`flex flex-col gap-2`,Ui),children:[u.map((e,n)=>(0,Q.jsxs)(`div`,{className:`yuri-settings-group-row flex w-full items-center gap-2`,children:[(0,Q.jsx)(yt,{value:e,onChange:e=>A(n,e.target.value),onBlur:N,placeholder:t(`settings.yuri.worktrees.setup.commandPlaceholder`),className:`min-w-0 flex-1 font-mono text-xs`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>M(n),className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":t(`settings.yuri.worktrees.setup.removeCommandAria`),children:(0,Q.jsx)(X,{name:`close`,className:`h-4 w-4`})})]},n)),(0,Q.jsxs)(Me,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:j,children:[(0,Q.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),t(`settings.yuri.worktrees.setup.addCommand`)]}),(0,Q.jsxs)(`label`,{"data-settings-item":`projects.worktree.setup.wait`,className:`flex cursor-pointer items-center gap-2 py-1`,children:[(0,Q.jsx)(ct,{checked:f,onChange:P,ariaLabel:t(`settings.yuri.worktrees.setup.waitForCommandsAria`)}),(0,Q.jsx)(`span`,{className:Y(`typography-ui-label font-normal`,f?`text-foreground`:`text-foreground/60`),children:t(`settings.yuri.worktrees.setup.waitForCommands`)})]})]})}),(0,Q.jsx)(Wi,{title:t(`settings.yuri.worktrees.list.title`),titleAccessory:R,children:S?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.worktrees.list.loading`)}):b.length===0?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground/70`,children:t(`settings.yuri.worktrees.list.empty`)}):(0,Q.jsx)(`div`,{className:Y(`space-y-1`,Ui),children:b.map(e=>(0,Q.jsxs)(`div`,{className:`group flex w-full items-center gap-2 py-1.5`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`p`,{className:`typography-meta min-w-0 truncate text-foreground`,children:e.label||e.branch||t(`settings.yuri.worktrees.list.detachedHead`)}),(0,Q.jsx)(`span`,{className:`typography-micro flex-shrink-0 self-center rounded bg-sidebar-accent/40 px-1.5 py-[1px] leading-none text-muted-foreground/60`,children:`OpenCode`})]}),(0,Q.jsx)(`p`,{className:`typography-micro truncate text-muted-foreground/60`,children:Oe(e.path,l)})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>F(e),className:Y(`flex h-7 w-7 shrink-0 items-center justify-center rounded text-muted-foreground/50 transition-opacity hover:bg-destructive/10 hover:text-destructive focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,i?`opacity-100`:`opacity-0 group-hover:opacity-100`),"aria-label":t(`settings.yuri.worktrees.list.deleteWorktreeAria`,{name:e.branch||e.label||e.path}),children:(0,Q.jsx)(X,{name:`delete-bin`,className:`h-4 w-4`})})]},e.path))})})]}):(0,Q.jsx)(Wi,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.worktrees.state.selectProject`)})})},qi=(e,t)=>t.updatedAtMs-e.updatedAtMs,Ji=_((e,t)=>({instances:[],statusesById:{},importCandidates:[],isLoading:!1,isSaving:!1,isImportsLoading:!1,initialized:!1,listenerReady:!1,error:null,load:async()=>{if(!t().isLoading){e({isLoading:!0,error:null});try{let[n,r]=await Promise.all([Dt(),jt()]),i={};for(let e of r.sort(qi))i[e.id]=e;t().listenerReady||await Vt(t=>{e(e=>({statusesById:{...e.statusesById,[t.id]:t}}))}),e({instances:n.instances,statusesById:i,isLoading:!1,initialized:!0,listenerReady:!0})}catch(t){e({isLoading:!1,error:t instanceof Error?t.message:String(t)})}}},loadImports:async()=>{if(!t().isImportsLoading){e({isImportsLoading:!0,error:null});try{e({importCandidates:await Bt(),isImportsLoading:!1})}catch(t){e({isImportsLoading:!1,error:t instanceof Error?t.message:String(t)})}}},refreshStatuses:async()=>{try{let t=await jt(),n={};for(let e of t.sort(qi))n[e.id]=e;e({statusesById:n})}catch(t){e({error:t instanceof Error?t.message:String(t)})}},setInstances:async n=>{e({isSaving:!0,error:null});try{await Ft({instances:n}),e({instances:n,isSaving:!1}),await t().refreshStatuses()}catch(t){throw e({isSaving:!1,error:t instanceof Error?t.message:String(t)}),t}},upsertInstance:async e=>{let n=t().instances,r=n.some(t=>t.id===e.id)?n.map(t=>t.id===e.id?e:t):[e,...n];await t().setInstances(r)},createFromCommand:async(e,n,r)=>{let i=Pt(e,n);r&&r.trim()&&(i.nickname=r.trim()),await t().upsertInstance(i)},removeInstance:async n=>{await Ot(n).catch(()=>void 0);let r=t().instances.filter(e=>e.id!==n);await t().setInstances(r),e(e=>{let t={...e.statusesById};return delete t[n],{statusesById:t}})},connect:async n=>{e({error:null});try{await Tt(n),await t().refreshStatuses()}catch(t){throw e({error:t instanceof Error?t.message:String(t)}),t}},disconnect:async n=>{e({error:null});try{await Ot(n),await t().refreshStatuses()}catch(t){throw e({error:t instanceof Error?t.message:String(t)}),t}},retry:async e=>{await t().connect(e)},getStatus:e=>t().statusesById[e]||null,clearError:()=>e({error:null})})),Yi=450,Xi=()=>k(),Zi=()=>({id:Xi(),name:``,command:``,icon:`play`}),Qi=({projectRef:e})=>{let{t}=Ae(),n=$.useMemo(()=>u(),[]),r=Ji(e=>e.instances),i=Ji(e=>e.load),[a,o]=$.useState([]),[s,c]=$.useState(!1),[l,d]=$.useState(null),[f,p]=$.useState({}),m=$.useRef(!1),h=$.useRef(null);$.useEffect(()=>{n&&i().catch(()=>void 0)},[n,i]),$.useEffect(()=>{let t=!1;return c(!0),(async()=>{try{let n=await Le(e);if(t)return;o(n.actions),d(JSON.stringify({actions:n.actions}))}catch{if(t)return;o([]),d(JSON.stringify({actions:[]}))}finally{t||c(!1)}})(),()=>{t=!0}},[e]);let g=$.useMemo(()=>n?vn(r):[],[r,n]),_=$.useMemo(()=>a.some(e=>e.name.trim().length===0||e.command.trim().length===0)?t(`settings.projects.actions.validation.fillNameAndCommand`):null,[a,t]),v=$.useMemo(()=>l!==null&&l!==JSON.stringify({actions:a}),[a,l]),y=$.useCallback(async n=>await Be(e,{actions:n,primaryActionId:null})?(d(JSON.stringify({actions:n})),typeof window<`u`&&window.dispatchEvent(new CustomEvent(xn,{detail:{projectId:e.id}})),!0):(Pe.error(t(`settings.projects.actions.toast.saveFailed`)),!1),[e,t]);$.useEffect(()=>{if(!v||s||_||m.current)return;let e=window.setTimeout(()=>{m.current||(m.current=!0,(async()=>{try{await y(a)}finally{m.current=!1}})())},Yi);return()=>{window.clearTimeout(e)}},[a,v,s,y,_]),$.useEffect(()=>{if(!v||!_||s){_||(h.current=null);return}let e=window.setTimeout(()=>{h.current!==_&&(h.current=_,Pe.error(_))},1e3);return()=>{window.clearTimeout(e)}},[v,s,_]);let b=$.useCallback(()=>{let e=Zi();o(t=>[...t,e]),p(t=>({...t,[e.id]:!0}))},[]),x=$.useCallback(e=>{o(t=>t.filter(t=>t.id!==e)),p(t=>{let n={...t};return delete n[e],n})},[]),S=$.useCallback((e,t)=>{o(n=>n.map(n=>n.id===e?t(n):n))},[]);return(0,Q.jsxs)(Wi,{title:t(`settings.projects.actions.title`),description:t(`settings.projects.actions.description`),settingsItem:`projects.actions`,headerAction:(0,Q.jsxs)(Me,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:b,children:[(0,Q.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),t(`settings.projects.actions.actions.add`)]}),contentClassName:`space-y-0`,children:[s?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.loading`)}):a.length===0?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.empty`)}):(0,Q.jsx)(`div`,{className:Y(`space-y-0`,Ui),children:a.map(e=>{let r=e.icon||`play`,i=bn[r]||`play`,a=f[e.id]??!1,o=e.name.trim()||t(`settings.projects.actions.state.untitled`);return(0,Q.jsxs)(rn,{open:a,onOpenChange:t=>{p(n=>({...n,[e.id]:t}))},className:`py-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsxs)(nn,{className:`group flex-1 justify-start gap-2 rounded-md px-0 pr-1 py-1 hover:bg-[var(--interactive-hover)] focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,children:[a?(0,Q.jsx)(X,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground`}):(0,Q.jsx)(X,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground`}),(0,Q.jsx)(X,{name:i,className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}),(0,Q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Q.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:o})})]}),(0,Q.jsx)(Me,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal h-7 w-7 px-0 text-muted-foreground hover:text-[var(--status-error)]`,onClick:()=>x(e.id),children:(0,Q.jsx)(X,{name:`delete-bin`,className:`h-3.5 w-3.5`})})]}),(0,Q.jsx)(tn,{className:`pt-1.5`,children:(0,Q.jsxs)(`div`,{className:`space-y-2 pb-4 pl-3 pr-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,Q.jsxs)(Ht,{children:[(0,Q.jsx)(Ut,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-[var(--interactive-border)] text-foreground hover:bg-[var(--interactive-hover)]`,"aria-label":t(`settings.projects.actions.field.selectIconAria`),children:(0,Q.jsx)(X,{name:i,className:`h-4 w-4`})})}),(0,Q.jsx)(Lt,{align:`start`,className:`w-56 p-2`,children:(0,Q.jsx)(`div`,{className:`grid grid-cols-6 gap-1`,children:yn.map(n=>{let r=n.Icon,i=(e.icon||`play`)===n.key;return(0,Q.jsx)(`button`,{type:`button`,onClick:()=>S(e.id,e=>({...e,icon:n.key})),className:Y(`inline-flex h-8 w-8 items-center justify-center rounded-md border border-transparent text-foreground hover:bg-[var(--interactive-hover)]`,i&&`border-[var(--primary-base)] bg-[var(--primary-base)]/10 text-[var(--primary-base)]`),"aria-label":t(`settings.projects.actions.field.iconAria`,{icon:n.label}),children:(0,Q.jsx)(X,{name:r,className:`h-4 w-4`})},n.key)})})})]}),(0,Q.jsx)(yt,{value:e.name,onChange:t=>S(e.id,e=>({...e,name:t.target.value})),placeholder:t(`settings.projects.actions.field.actionNamePlaceholder`),className:`h-7 flex-1 min-w-0`})]}),(0,Q.jsxs)(`div`,{className:`py-1`,children:[(0,Q.jsx)(`p`,{className:`typography-meta mb-0.5 text-muted-foreground`,children:t(`settings.projects.actions.field.command`)}),(0,Q.jsx)(Yt,{embedded:!0,value:e.command,onChange:t=>S(e.id,e=>({...e,command:t.target.value})),placeholder:t(`settings.projects.actions.field.commandPlaceholder`),className:`min-h-[88px] w-full font-mono text-xs`})]}),(0,Q.jsxs)(`div`,{className:`py-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Q.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:t(`settings.projects.actions.field.autoOpenUrl`)}),(0,Q.jsxs)(`div`,{className:`group flex cursor-pointer items-center gap-2`,role:`button`,tabIndex:0,"aria-pressed":e.autoOpenUrl===!0,onClick:()=>S(e.id,e=>({...e,...e.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})),onKeyDown:t=>{(t.key===` `||t.key===`Enter`)&&(t.preventDefault(),S(e.id,e=>({...e,...e.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})))},children:[(0,Q.jsx)(ct,{checked:e.autoOpenUrl===!0,onChange:t=>S(e.id,e=>({...e,...t?{autoOpenUrl:!0}:{autoOpenUrl:void 0}})),ariaLabel:t(`settings.projects.actions.field.autoOpenUrlForAria`,{title:o})}),(0,Q.jsx)(`span`,{className:`typography-ui-label font-normal text-foreground/80`,children:t(`settings.projects.actions.field.autoOpenUrlDescription`)})]})]}),e.autoOpenUrl===!0?(0,Q.jsxs)(`div`,{className:`mt-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(yt,{value:e.openUrl||``,onChange:t=>S(e.id,e=>({...e,openUrl:t.target.value})),placeholder:t(`settings.projects.actions.field.overrideUrlPlaceholder`),className:`h-7 w-full max-w-[24rem]`}),(0,Q.jsxs)(St,{children:[(0,Q.jsx)(bt,{asChild:!0,children:(0,Q.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/60 cursor-help`})}),(0,Q.jsx)(xt,{sideOffset:8,className:`max-w-xs`,children:t(`settings.projects.actions.field.overrideUrlTooltip`)})]})]}),n?(0,Q.jsxs)(`div`,{className:`mt-2`,children:[(0,Q.jsx)(`p`,{className:`typography-meta mb-0.5 text-muted-foreground`,children:t(`settings.projects.actions.field.desktopSshForward`)}),g.length>0?(0,Q.jsxs)(mt,{value:e.desktopOpenSshForward&&g.some(t=>t.id===e.desktopOpenSshForward)?e.desktopOpenSshForward:`__none__`,onValueChange:t=>{S(e.id,e=>({...e,...t===`__none__`?{desktopOpenSshForward:void 0}:{desktopOpenSshForward:t}}))},children:[(0,Q.jsx)(dt,{className:`h-7 w-full`,children:(0,Q.jsx)(vt,{placeholder:t(`settings.projects.actions.field.useOutputManualUrl`)})}),(0,Q.jsxs)(pt,{children:[(0,Q.jsx)(lt,{value:`__none__`,children:t(`settings.projects.actions.field.useOutputManualUrl`)}),g.map(e=>(0,Q.jsx)(lt,{value:e.id,children:e.label},e.id))]})]}):(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.noDesktopSshForwards`)})]}):null]}):null]})]})})]},e.id)})}),_&&a.length>0?(0,Q.jsx)(`p`,{className:`typography-meta text-[var(--status-warning)]`,children:_}):null]})},$i=e=>{let t=(0,Z.c)(123),{form:n}=e,{t:r}=Ae(),{currentTheme:i}=Ye(),{name:a,setName:o,icon:s,setIcon:c,color:l,setColor:u,iconBackground:d,setIconBackground:f,parsedDefaultModel:p,handleDefaultModelChange:m,isUploadingIcon:h,isRemovingCustomIcon:g,isDiscoveringIcon:_,pendingRemoveImageIcon:v,setPendingRemoveImageIcon:y,pendingUploadIconPreviewUrl:b,setPreviewImageFailed:x,hasPendingUploadImageIcon:S,hasCustomIcon:C,effectiveHasImageIcon:w,hasRemovableImageIcon:T,showImagePreview:E,fileInputRef:D,handleUploadIcon:O,handleRemoveImageIcon:k,handleDiscoverIcon:A,currentIconImage:j,project:M}=n;if(!M)return null;let N=l?ht[l]??null:null,P;t[0]===r?P=t[1]:(P=r(`settings.projects.page.field.projectName`),t[0]=r,t[1]=P);let F;t[2]===o?F=t[3]:(F=e=>o(e.target.value),t[2]=o,t[3]=F);let I;t[4]===r?I=t[5]:(I=r(`settings.projects.page.field.projectNamePlaceholder`),t[4]=r,t[5]=I);let L;t[6]!==a||t[7]!==F||t[8]!==I?(L=(0,Q.jsx)(yt,{value:a,onChange:F,placeholder:I}),t[6]=a,t[7]=F,t[8]=I,t[9]=L):L=t[9];let R;t[10]!==P||t[11]!==L?(R=(0,Q.jsx)(Lr,{label:P,itemId:`projects.name`,children:L}),t[10]=P,t[11]=L,t[12]=R):R=t[12];let z;t[13]===r?z=t[14]:(z=r(`settings.projects.page.field.defaultModel`),t[13]=r,t[14]=z);let B;t[15]===r?B=t[16]:(B=r(`settings.projects.page.field.defaultModelDescription`),t[15]=r,t[16]=B);let V;t[17]!==m||t[18]!==p.modelId||t[19]!==p.providerId?(V=(0,Q.jsx)(Et,{providerId:p.providerId,modelId:p.modelId,onChange:m,className:`yuri-settings-inline-value`}),t[17]=m,t[18]=p.modelId,t[19]=p.providerId,t[20]=V):V=t[20];let H;t[21]!==z||t[22]!==B||t[23]!==V?(H=(0,Q.jsx)(Lr,{label:z,description:B,descriptionPlacement:`outside`,itemId:`projects.default-model`,children:V}),t[21]=z,t[22]=B,t[23]=V,t[24]=H):H=t[24];let U;t[25]===r?U=t[26]:(U=r(`settings.projects.page.field.accentColor`),t[25]=r,t[26]=U);let ee;t[27]===u?ee=t[28]:(ee=()=>u(null),t[27]=u,t[28]=ee);let te=l===null?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-border/40 hover:border-border hover:bg-[var(--surface-muted)]`,W;t[29]===te?W=t[30]:(W=Y(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,te),t[29]=te,t[30]=W);let G;t[31]===r?G=t[32]:(G=r(`settings.projects.page.field.none`),t[31]=r,t[32]=G);let K;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,Q.jsx)(X,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[33]=K):K=t[33];let q;t[34]!==ee||t[35]!==W||t[36]!==G?(q=(0,Q.jsx)(`button`,{type:`button`,onClick:ee,className:W,title:G,children:K}),t[34]=ee,t[35]=W,t[36]=G,t[37]=q):q=t[37];let ne;t[38]!==l||t[39]!==u?(ne=_t.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>u(e.key),className:Y(`h-7 w-7 rounded-md border transition-colors`,l===e.key?`border-2 border-foreground ring-1 ring-[var(--primary-base)]/40`:`border-transparent hover:border-border/70`),style:{backgroundColor:e.cssVar},title:e.label},e.key)),t[38]=l,t[39]=u,t[40]=ne):ne=t[40];let re;t[41]!==q||t[42]!==ne?(re=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[q,ne]}),t[41]=q,t[42]=ne,t[43]=re):re=t[43];let ie;t[44]!==U||t[45]!==re?(ie=(0,Q.jsx)(Lr,{label:U,itemId:`projects.accent-color`,children:re}),t[44]=U,t[45]=re,t[46]=ie):ie=t[46];let ae;t[47]===r?ae=t[48]:(ae=r(`settings.projects.page.field.projectIcon`),t[47]=r,t[48]=ae);let oe;t[49]===O?oe=t[50]:(oe=e=>{let t=e.target.files?.[0]??null;O(t),e.currentTarget.value=``},t[49]=O,t[50]=oe);let se;t[51]!==D||t[52]!==oe?(se=(0,Q.jsx)(`input`,{ref:D,type:`file`,accept:`image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg`,className:`hidden`,onChange:oe}),t[51]=D,t[52]=oe,t[53]=se):se=t[53];let ce;t[54]===c?ce=t[55]:(ce=()=>c(null),t[54]=c,t[55]=ce);let le=s===null?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-border/40 hover:border-border hover:bg-[var(--surface-muted)]`,ue;t[56]===le?ue=t[57]:(ue=Y(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,le),t[56]=le,t[57]=ue);let de;t[58]===r?de=t[59]:(de=r(`settings.projects.page.field.none`),t[58]=r,t[59]=de);let fe;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,Q.jsx)(X,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[60]=fe):fe=t[60];let pe;t[61]!==ce||t[62]!==ue||t[63]!==de?(pe=(0,Q.jsx)(`button`,{type:`button`,onClick:ce,className:ue,title:de,children:fe}),t[61]=ce,t[62]=ue,t[63]=de,t[64]=pe):pe=t[64];let me;t[65]!==N||t[66]!==s||t[67]!==c?(me=gt.map(e=>{let t=e.Icon;return(0,Q.jsx)(`button`,{type:`button`,onClick:()=>c(e.key),className:Y(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,s===e.key?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-transparent hover:border-border hover:bg-[var(--surface-muted)]`),title:e.label,children:(0,Q.jsx)(X,{name:t,className:`w-4 h-4`,style:N&&s===e.key?{color:N}:void 0})},e.key)}),t[65]=N,t[66]=s,t[67]=c,t[68]=me):me=t[68];let he;t[69]!==pe||t[70]!==me?(he=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[pe,me]}),t[69]=pe,t[70]=me,t[71]=he):he=t[71];let ge;t[72]!==j||t[73]!==i||t[74]!==w||t[75]!==S||t[76]!==d||t[77]!==b||t[78]!==M||t[79]!==x||t[80]!==E||t[81]!==r?(ge=w&&E&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:r(`settings.projects.page.field.preview`)}),(0,Q.jsx)(`span`,{className:`inline-flex h-7 w-7 items-center justify-center rounded-md border border-border/60 bg-[var(--surface-elevated)] p-1`,children:(0,Q.jsx)(`span`,{className:`inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]`,style:d?{backgroundColor:d}:void 0,children:S&&b?(0,Q.jsx)(`img`,{src:b,alt:``,className:`h-full w-full object-contain`,draggable:!1,onError:()=>x(!0)}):(0,Q.jsx)(ut,{project:{...M,iconImage:j??M.iconImage},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:`h-full w-full object-contain`,onError:()=>x(!0)})})})]}),t[72]=j,t[73]=i,t[74]=w,t[75]=S,t[76]=d,t[77]=b,t[78]=M,t[79]=x,t[80]=E,t[81]=r,t[82]=ge):ge=t[82];let _e;t[83]!==w||t[84]!==d||t[85]!==f||t[86]!==r?(_e=w&&(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,Q.jsx)(`input`,{type:`color`,value:d??`#000000`,onChange:e=>f(e.target.value),className:`h-7 w-9 cursor-pointer rounded border border-border bg-transparent p-1`,"aria-label":r(`settings.projects.page.field.projectIconBackgroundAria`)}),(0,Q.jsx)(yt,{value:d??``,onChange:e=>f(e.target.value),placeholder:`#000000`,className:`h-7 w-[8rem]`}),(0,Q.jsx)(Me,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>f(null),className:`h-7 w-7 p-0`,"aria-label":r(`settings.projects.page.field.clearIconBackgroundAria`),title:r(`settings.projects.page.field.clearBackground`),disabled:!d,children:(0,Q.jsx)(X,{name:`close`,className:`h-3.5 w-3.5`})})]}),t[83]=w,t[84]=d,t[85]=f,t[86]=r,t[87]=_e):_e=t[87];let ve;t[88]!==D||t[89]!==A||t[90]!==C||t[91]!==_||t[92]!==h||t[93]!==r?(ve=!C&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Me,{size:`xs`,className:`h-6 !font-normal`,onClick:()=>D.current?.click(),disabled:h,children:r(h?`settings.projects.page.actions.uploading`:`settings.projects.page.actions.uploadIcon`)}),(0,Q.jsx)(Me,{size:`xs`,className:`h-6 !font-normal`,variant:`outline`,onClick:()=>void A(),disabled:_,children:r(_?`settings.projects.page.actions.discovering`:`settings.projects.page.actions.discoverFavicon`)})]}),t[88]=D,t[89]=A,t[90]=C,t[91]=_,t[92]=h,t[93]=r,t[94]=ve):ve=t[94];let J;t[95]!==k||t[96]!==T||t[97]!==g||t[98]!==r?(J=T&&(0,Q.jsx)(Me,{size:`xs`,className:`!font-normal`,variant:`outline`,onClick:()=>void k(),disabled:g,children:r(g?`settings.projects.page.actions.removing`:`settings.projects.page.actions.removeProjectIcon`)}),t[95]=k,t[96]=T,t[97]=g,t[98]=r,t[99]=J):J=t[99];let ye;t[100]!==g||t[101]!==v||t[102]!==y||t[103]!==r?(ye=v&&(0,Q.jsx)(Me,{size:`xs`,className:`!font-normal`,variant:`outline`,onClick:()=>y(!1),disabled:g,children:r(`settings.projects.page.actions.undoRemove`)}),t[100]=g,t[101]=v,t[102]=y,t[103]=r,t[104]=ye):ye=t[104];let be;t[105]!==ve||t[106]!==J||t[107]!==ye?(be=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[ve,J,ye]}),t[105]=ve,t[106]=J,t[107]=ye,t[108]=be):be=t[108];let xe;t[109]!==se||t[110]!==he||t[111]!==ge||t[112]!==_e||t[113]!==be?(xe=(0,Q.jsxs)(`div`,{className:`flex w-full flex-col items-end gap-2`,children:[se,he,ge,_e,be]}),t[109]=se,t[110]=he,t[111]=ge,t[112]=_e,t[113]=be,t[114]=xe):xe=t[114];let Se;t[115]!==ae||t[116]!==xe?(Se=(0,Q.jsx)(Lr,{label:ae,itemId:`projects.icon`,children:xe}),t[115]=ae,t[116]=xe,t[117]=Se):Se=t[117];let Ce;return t[118]!==ie||t[119]!==Se||t[120]!==R||t[121]!==H?(Ce=(0,Q.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[R,H,ie,Se]}),t[118]=ie,t[119]=Se,t[120]=R,t[121]=H,t[122]=Ce):Ce=t[122],Ce},ea=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,ta=e=>{if(!e)return null;let t=e.trim();return t&&ea.test(t)?t.toLowerCase():null},na=e=>{let{t}=Ae(),n=Re(e=>e.uploadProjectIcon),r=Re(e=>e.removeProjectIcon),i=Re(e=>e.discoverProjectIcon),a=Re(t=>e?t.projects.find(t=>t.id===e.id)?.iconImage??null:null),[o,s]=$.useState(``),[c,l]=$.useState(null),[u,d]=$.useState(null),[f,p]=$.useState(null),[m,h]=$.useState(void 0),[g,_]=$.useState(!1),[v,y]=$.useState(!1),[b,x]=$.useState(!1),[S,C]=$.useState(!1),[w,T]=$.useState(null),[E,D]=$.useState(null),[O,k]=$.useState(!1),A=$.useRef(null),j=$.useCallback(()=>{T(null),D(e=>(e&&URL.revokeObjectURL(e),null))},[]),M=e?.id??null;$.useEffect(()=>{if(!e){s(``),l(null),d(null),p(null),h(void 0);return}s(e.label??``),l(e.icon??null),d(e.color??null),p(e.iconBackground??null),h(e.defaultModel),C(!1),j(),k(!1)},[e,j]),$.useEffect(()=>()=>{j()},[j]);let N=$.useMemo(()=>Ge(m)??{providerId:``,modelId:``},[m]),P=!!e?.iconImage,F=!!(w&&E),I=e?.iconImage?.source===`custom`,L=P&&!S||F,R=L,z=!!(e&&P&&!S),B=!O&&(F||z),V=!!e&&(o.trim()!==(e?.label??``).trim()||c!==(e?.icon??null)||u!==(e?.color??null)||f!==(e?.iconBackground??null)||(m??void 0)!==(e?.defaultModel??void 0)||S||!!w),H=$.useCallback((e,t)=>{h(e&&t?`${e}/${t}`:void 0)},[]),U=$.useCallback(t=>{!e||!t||g||(C(!1),k(!1),T(t),D(e=>(e&&URL.revokeObjectURL(e),URL.createObjectURL(t))))},[g,e]),ee=$.useCallback(()=>{!e||!R||v||(F&&j(),C(!!P),k(!1))},[j,F,R,P,v,e]),te=$.useCallback(async()=>{if(!(!e||b)){j(),C(!1),k(!1),x(!0);try{let n=await i(e.id);if(!n.ok){Pe.error(n.error||t(`settings.projects.page.toast.discoverIconFailed`));return}if(n.skipped){Pe.success(t(`settings.projects.page.toast.customIconAlreadySet`));return}Pe.success(t(`settings.projects.page.toast.iconDiscovered`))}finally{x(!1)}}},[j,i,b,e,t]),W=$.useCallback(async i=>{let a=i?.silent===!0;if(!e)return null;let s=o.trim();if(!s)return null;if(w){_(!0);let r=await n(e.id,w);if(_(!1),!r.ok)return Pe.error(r.error||t(`settings.projects.page.toast.uploadIconFailed`)),null;a||Pe.success(t(`settings.projects.page.toast.iconUpdated`)),j(),C(!1)}let l=S&&!!e.iconImage;if(l){y(!0);let n=await r(e.id);if(y(!1),!n.ok)return Pe.error(n.error||t(`settings.projects.page.toast.removeIconFailed`)),null;a||Pe.success(t(`settings.projects.page.toast.iconRemoved`)),C(!1),p(null)}return{label:s,icon:c,color:u,iconBackground:ta(l?null:f),defaultModel:m??null}},[j,u,m,c,f,o,S,w,e,r,t,n]);return $.useEffect(()=>{k(!1)},[M,a?.updatedAt]),{name:o,setName:s,icon:c,setIcon:l,color:u,setColor:d,iconBackground:f,setIconBackground:p,defaultModel:m,parsedDefaultModel:N,handleDefaultModelChange:H,isUploadingIcon:g,isRemovingCustomIcon:v,isDiscoveringIcon:b,pendingRemoveImageIcon:S,setPendingRemoveImageIcon:C,pendingUploadIconFile:w,pendingUploadIconPreviewUrl:E,previewImageFailed:O,setPreviewImageFailed:k,hasStoredImageIcon:P,hasPendingUploadImageIcon:F,hasCustomIcon:I,effectiveHasImageIcon:L,hasRemovableImageIcon:R,showStoredImagePreview:z,showImagePreview:B,fileInputRef:A,clearPendingUploadIcon:j,handleUploadIcon:U,handleRemoveImageIcon:ee,handleDiscoverIcon:te,hasChanges:V,prepareSaveData:W,currentIconImage:a,project:e}},ra=450,ia=(e,t)=>{let{t:n}=Ae(),{hasChanges:r,name:i,icon:a,color:o,iconBackground:s,defaultModel:c,pendingRemoveImageIcon:l,pendingUploadIconFile:u,isUploadingIcon:d,isRemovingCustomIcon:f,prepareSaveData:p}=e,m=$.useRef(!1);$.useEffect(()=>{if(!r||!i.trim()||d||f||m.current)return;let e=window.setTimeout(()=>{m.current||(m.current=!0,(async()=>{try{let e=await p({silent:!0});if(e)try{await t(e)}catch{Pe.error(n(`settings.projects.page.toast.saveFailed`))}}finally{m.current=!1}})())},ra);return()=>{window.clearTimeout(e)}},[o,c,r,a,s,f,d,i,t,l,u,p,n])},aa=e=>{let t=(0,Z.c)(25),{project:n,onIdentitySave:r}=e,{t:i}=Ae(),a=na(n),o;bb0:{if(!n){o=null;break bb0}let e;t[0]!==n.id||t[1]!==n.path?(e={id:n.id,path:n.path},t[0]=n.id,t[1]=n.path,t[2]=e):e=t[2],o=e}let s=o,c;if(t[3]===r?c=t[4]:(c=async e=>{await r(e)},t[3]=r,t[4]=c),ia(a,c),!n||!s)return null;let l;t[5]!==n.path||t[6]!==i?(l=n.path.split(/[\\/]/).filter(Boolean).at(-1)??i(`settings.projects.page.title.default`),t[5]=n.path,t[6]=i,t[7]=l):l=t[7];let u=l,d;t[8]===u?d=t[9]:(d=(0,Q.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:u}),t[8]=u,t[9]=d);let f;t[10]===n.path?f=t[11]:(f=(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,title:n.path,children:n.path}),t[10]=n.path,t[11]=f);let p;t[12]!==d||t[13]!==f?(p=(0,Q.jsxs)(`div`,{className:`px-1`,children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;t[15]===a?m=t[16]:(m=(0,Q.jsx)($i,{form:a}),t[15]=a,t[16]=m);let h,g;t[17]===s?(h=t[18],g=t[19]):(h=(0,Q.jsx)(Qi,{projectRef:s}),g=(0,Q.jsx)(Ki,{projectRef:s}),t[17]=s,t[18]=h,t[19]=g);let _;return t[20]!==p||t[21]!==m||t[22]!==h||t[23]!==g?(_=(0,Q.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[p,m,h,g]}),t[20]=p,t[21]=m,t[22]=h,t[23]=g,t[24]=_):_=t[24],_};function oa(e,t,n){return Math.min(n,Math.max(t,e))}function sa(e){if(!Number.isFinite(e))return 0;let t=String(e);if(t.includes(`e-`)){let[,e]=t.split(`e-`);return Number(e)||0}let n=t.split(`.`);return n.length===2?n[1].length:0}function ca(e,t){let n=sa(t);return n<=0?e:Number(e.toFixed(n))}var la=$.forwardRef(({value:e,onValueChange:t,min:n=-1/0,max:r=1/0,step:i=1,className:a,containerClassName:o,onBlur:s,disabled:c,fallbackValue:l,onClear:u,emptyLabel:d=`—`,...f},p)=>{let{t:m}=Ae(),[h,g]=$.useState(()=>e===void 0?``:String(e)),{isMobile:_}=Gt(),v=$.useRef(!1),y=$.useRef(null),b=$.useCallback(()=>{if(typeof document>`u`||typeof window>`u`)return;y.current?.();let e=e=>{e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation?.(),y.current?.()},t=window.setTimeout(()=>{y.current?.()},700);y.current=()=>{window.clearTimeout(t),document.removeEventListener(`click`,e,!0),y.current=null},document.addEventListener(`click`,e,!0)},[]);$.useEffect(()=>()=>{y.current?.()},[]),$.useEffect(()=>{g(e===void 0?``:String(e))},[e]);let x=$.useMemo(()=>e===void 0?l===void 0?Number.isFinite(n)?n:0:l:e,[l,n,e]),S=$.useRef(x);$.useEffect(()=>{S.current=x},[x]);let C=$.useCallback(e=>{let a=ca(oa(e,n,r),i);S.current=a,t(a)},[r,n,t,i]),w=$.useCallback(e=>{let t=e.target.value;if(g(t),t.trim()===``){u?.();return}let n=Number(t);Number.isFinite(n)&&C(n)},[C,u]),T=$.useCallback(t=>{if(h.trim()===``){u||g(e===void 0?``:String(e)),s?.(t);return}let a=Number(h);if(!Number.isFinite(a))g(e===void 0?``:String(e));else{let t=ca(oa(a,n,r),i);t===e?S.current=t:C(a),g(String(t))}s?.(t)},[C,h,r,n,s,u,i,e]),E=!!(c||x>=r),D=!!(c||x<=n),O=()=>{D||C(S.current-i)},k=()=>{E||C(S.current+i)},A=e=>t=>{t.preventDefault(),t.stopPropagation(),v.current=!0,b(),e()},j=e=>t=>{if(v.current){v.current=!1,t.preventDefault(),t.stopPropagation();return}e()};return _?(0,Q.jsxs)(`div`,{"data-slot":`number-input`,className:Y(`flex h-9 shrink-0 items-stretch overflow-x-hidden overflow-y-hidden rounded-lg border border-border bg-transparent select-none overscroll-contain`,`[-webkit-user-select:none] [-webkit-touch-callout:none]`,`disabled:pointer-events-none disabled:opacity-50`,o),children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.decreaseAria`),disabled:D,onTouchStart:A(O),onClick:j(O),className:Y(`grid h-full min-h-0 w-9 place-items-center overflow-x-hidden overflow-y-hidden border-r border-border p-0 leading-none touch-none`,`text-muted-foreground`,`disabled:pointer-events-none disabled:opacity-50`,!D&&`active:bg-interactive-hover`),children:(0,Q.jsx)(X,{name:`subtract`,className:`block h-4 w-4`})}),(0,Q.jsx)(`div`,{"data-slot":`number-input-value`,className:Y(`flex h-full min-w-0 w-14 items-center justify-center bg-transparent px-1.5`,`text-center text-[16px] leading-none text-foreground [font-variant-numeric:tabular-nums]`,a),"aria-live":`polite`,children:e===void 0?d:h}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.increaseAria`),disabled:E,onTouchStart:A(k),onClick:j(k),className:Y(`grid h-full min-h-0 w-9 place-items-center overflow-x-hidden overflow-y-hidden border-l border-border p-0 leading-none touch-none`,`text-muted-foreground`,`disabled:pointer-events-none disabled:opacity-50`,!E&&`active:bg-interactive-hover`),children:(0,Q.jsx)(X,{name:`add`,className:`block h-4 w-4`})})]}):(0,Q.jsxs)(`div`,{"data-slot":`number-input`,className:Y(`flex h-7 shrink-0 items-stretch overflow-x-hidden overflow-y-hidden rounded-lg border border-border bg-transparent`,`disabled:pointer-events-none disabled:opacity-50`,o),children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.decreaseAria`),disabled:D,onClick:()=>C(S.current-i),className:Y(`flex h-full w-7 items-center justify-center overflow-x-hidden overflow-y-hidden border-r border-border p-0 leading-none touch-manipulation`,`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`,`disabled:pointer-events-none disabled:opacity-50`),children:(0,Q.jsx)(X,{name:`subtract`,className:`block h-3.5 w-3.5`})}),(0,Q.jsx)(`input`,{...f,"data-slot":`number-input-value`,ref:p,type:`text`,inputMode:f.inputMode??`numeric`,value:h,onChange:w,onBlur:T,disabled:c,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,className:Y(`h-full min-w-0 w-14 bg-transparent px-1.5 text-center typography-ui-label leading-none text-foreground [font-variant-numeric:tabular-nums]`,`placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground`,`appearance-none outline-none [appearance:textfield] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,`disabled:pointer-events-none disabled:cursor-not-allowed`,a)}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.increaseAria`),disabled:E,onClick:()=>C(S.current+i),className:Y(`flex h-full w-7 items-center justify-center overflow-x-hidden overflow-y-hidden border-l border-border p-0 leading-none touch-manipulation`,`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`,`disabled:pointer-events-none disabled:opacity-50`),children:(0,Q.jsx)(X,{name:`add`,className:`block h-3.5 w-3.5`})})]})});la.displayName=`NumberInput`;function ua(e){let t=e.indexOf(`/`);if(t!==-1){let n=e.substring(0,t);if(n===`gemini`||n===`antigravity`)return e.substring(t+1)}return e}var da={google:[{id:`gemini-auth`,label:`Gemini`,matcher:e=>e.startsWith(`gemini/`),order:1},{id:`antigravity-auth`,label:`Antigravity`,matcher:e=>e.startsWith(`antigravity/`),order:2}]};function fa(e,t){let n=da[t]??[];for(let t of n)if(t.matcher(e))return t;return null}function pa(e){return da[e]??[]}function ma(e){return[...e].sort((e,t)=>e.order-t.order)}function ha(e,t){let n=new Map;for(let r of Object.keys(e)){let e=fa(r,t)?.id??null;n.has(e)||n.set(e,[]),n.get(e).push(r)}return n}function ga(e,t,n){let r=new Map;for(let i of e){let e=fa(t(i),n)?.id??null;r.has(e)||r.set(e,[]),r.get(e).push(i)}return r}function _a(e,t){return t.filter(e=>{let t=e.toLowerCase(),n=t.includes(`/`)?t.split(`/`)[1]:t;return!!(n.startsWith(`gemini-3-`)||n.startsWith(`claude-`))})}var va=(e,t=``,n=!1)=>F({queryKey:R.scoped(`magpie-quotas`,e,t,n),staleTime:0,retry:!1,queryFn:async({signal:t})=>{let r=await a(`/api/quota/magpie`,{signal:t,query:{...e?{directory:e}:{},...n?{refresh:`1`}:{}}});if(!r.ok)throw Error(`Unable to discover Magpie quota sources`);let i=await r.json();if(!i||!Array.isArray(i.sources)||!i.sources.every(e=>e&&typeof e.id==`string`&&typeof e.name==`string`&&Array.isArray(e.results)&&e.results.every(t=>z(t)&&t.source===`magpie`&&t.sourceId===e.id&&t.providerId.startsWith(`magpie:${e.id}:`))))throw Error(`Invalid Magpie quota response`);return i}}),ya=6e4,ba=0,xa=0,Sa,Ca=0,wa=0,Ta=0,Ea=new Map,Da=e=>{let t=Sn.map(e=>e.id),n=typeof e?.usageAutoRefresh==`boolean`&&e.usageAutoRefresh,r=typeof e?.usageRefreshIntervalMs==`number`&&Number.isFinite(e.usageRefreshIntervalMs)?Math.max(3e4,Math.min(3e5,Math.round(e.usageRefreshIntervalMs))):ya,i=e?.usageDisplayMode===`remaining`?`remaining`:`usage`,a=typeof e?.usageShowPredValues==`boolean`&&e.usageShowPredValues,o=Array.isArray(e?.usageDropdownProviders)?e?.usageDropdownProviders:null,s=o?o.filter(e=>typeof e==`string`&&(e.startsWith(`magpie:`)||t.includes(e))):t,c={},l=e?.usageSelectedModels;if(l&&typeof l==`object`)for(let[e,t]of Object.entries(l))Array.isArray(t)&&(c[e]=t.filter(e=>typeof e==`string`));let u={},d=e?.usageExpandedFamilies;if(d&&typeof d==`object`)for(let[e,t]of Object.entries(d))Array.isArray(t)&&(u[e]=t.filter(e=>typeof e==`string`));return{magpieUsageUrl:typeof e?.magpieUsageUrl==`string`?e.magpieUsageUrl:``,magpieHiddenProviders:Array.isArray(e?.magpieHiddenProviders)?e.magpieHiddenProviders.filter(e=>typeof e==`string`&&e.startsWith(`magpie:`)):[],autoRefresh:n,refreshIntervalMs:r,displayMode:i,showPredValues:a,dropdownProviderIds:s,selectedModels:c,expandedFamilies:u}},Oa=async()=>{let e=g()?.settings;if(e)try{let t=(await e.load())?.settings;return Da(t??null)}catch{}if(!o()){let e=await a(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(e.ok)return Da(await e.json().catch(()=>null))}return{magpieUsageUrl:``,magpieHiddenProviders:[],autoRefresh:!1,refreshIntervalMs:ya,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:Sn.map(e=>e.id),selectedModels:{},expandedFamilies:{}}},ka=(e,t,n)=>{let r=e.filter(e=>e?.providerId&&e.providerId!==t);return z(n)&&r.push(n),r},Aa=async(e,t)=>{let n=xa;Ea.set(e,(Ea.get(e)??0)+1),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:!0}}));try{let r=await L.fetchQuery({queryKey:R.quota(e),queryFn:({signal:t})=>B(e,t),staleTime:0,retry:!1});if(n!==xa)return{providerId:e,stale:!0};if(!z(r))throw Error(`Invalid quota response`);return t(t=>({results:ka(t.results,e,r)})),{providerId:e,result:r}}catch(r){return n===xa?(t(e=>e.results.every(e=>e?.providerId)?{}:{results:e.results.filter(e=>e?.providerId)}),{providerId:e,error:r instanceof Error?r.message:`Failed to fetch quota`}):{providerId:e,stale:!0}}finally{if(n===xa){let n=(Ea.get(e)??1)-1;n>0?Ea.set(e,n):Ea.delete(e),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:n>0}}))}}},ja=()=>{Sa=void 0,Ca+=1,xa+=1,ba+=1,Ea.clear(),Ma.setState({magpieUsageUrl:``,magpieHiddenProviders:[],magpieSources:[],magpieError:null,results:[],isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null})},Ma=_()(y((e,t)=>({magpieSources:[],magpieError:null,magpieHiddenProviders:[],magpieUsageUrl:``,results:[],selectedProviderId:null,isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null,autoRefresh:!1,refreshIntervalMs:ya,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:Sn.map(e=>e.id),selectedModels:{},expandedFamilies:{},loadSettings:async()=>{let t=xa;try{let n=await Oa();if(t!==xa)return;e(e=>({...n,dropdownProviderIds:[...n.dropdownProviderIds.filter(e=>!e.startsWith(`magpie:`)),...e.results.filter(e=>e.source===`magpie`&&!n.magpieHiddenProviders.includes(e.providerId)).map(e=>e.providerId)]}))}catch(e){console.warn(`Failed to load usage settings:`,e)}},fetchAllQuotas:async()=>{let n=++ba;e({isLoading:!0,error:null});let r=Sn.map(e=>e.id),[i]=await Promise.all([Promise.all(r.map(t=>Aa(t,e))),t().fetchMagpieQuotas(!0)]);if(n===ba){let t=i.find(e=>`error`in e);e({isLoading:!1,...i.some(e=>`result`in e)?{lastUpdated:Date.now()}:{},error:t?.error??null})}},fetchProviderQuota:async n=>{if(n.startsWith(`magpie:`))return t().fetchMagpieQuotas(!0);let r=await Aa(n,e);`stale`in r||e({error:`error`in r?r.error:null})},fetchMagpieQuotas:async(n=!1)=>{let r=xa,i=C.getState().currentDirectory,a=t().magpieUsageUrl,o=JSON.stringify([i,a]);Sa!==o&&(Sa=o,Ca+=1,e(e=>({results:e.results.filter(e=>e?.source!==`magpie`),magpieSources:[],magpieError:null})));let s=Ca,c=++wa;try{let{sources:o,incomplete:l}=await L.fetchQuery(va(i,a,n));if(r!==xa||s!==Ca||c<Ta||i!==C.getState().currentDirectory||a!==t().magpieUsageUrl)return;Ta=c,e(e=>{let t=new Map(o.filter(e=>e.error&&!e.clearPrevious&&e.results.length===0).map(e=>[e.id,e.error]));if(l){let n=new Set(o.map(e=>e.id));for(let r of e.results)r.sourceId&&!n.has(r.sourceId)&&t.set(r.sourceId,`Magpie discovery is incomplete`)}let n=e.results.filter(e=>e?.providerId&&(e.source!==`magpie`||t.has(e.sourceId??``))).map(e=>e.source===`magpie`&&t.has(e.sourceId??``)?{...e,ok:!1,error:t.get(e.sourceId??``)}:e);n.push(...o.flatMap(e=>e.results));let r=n.filter(e=>e.source===`magpie`).map(e=>e.providerId);return{results:n,magpieSources:o,magpieError:null,dropdownProviderIds:[...e.dropdownProviderIds.filter(e=>!e.startsWith(`magpie:`)),...r.filter(t=>!e.magpieHiddenProviders.includes(t))]}})}catch(n){if(r!==xa||s!==Ca||c<Ta||i!==C.getState().currentDirectory||a!==t().magpieUsageUrl)return;Ta=c,e({magpieError:n instanceof Error?n.message:`Unable to read Magpie quotas`})}},setSelectedProvider:t=>e({selectedProviderId:t}),setAutoRefresh:t=>e({autoRefresh:t}),setRefreshInterval:t=>{e({refreshIntervalMs:Math.max(3e4,Math.min(3e5,Math.round(t)))})},setDisplayMode:t=>e({displayMode:t}),setShowPredValues:t=>e({showPredValues:t}),setDropdownProviderIds:n=>{let r=t().results.filter(e=>e.source===`magpie`),i=new Set(r.map(e=>e.providerId));e({dropdownProviderIds:n,magpieHiddenProviders:[...t().magpieHiddenProviders.filter(e=>!i.has(e)),...r.filter(e=>!n.includes(e.providerId)).map(e=>e.providerId)]})},setSelectedModels:(t,n)=>{e(e=>({selectedModels:{...e.selectedModels,[t]:n}}))},toggleModelSelected:(t,n)=>{e(e=>{let r=e.selectedModels[t]??[],i=r.includes(n)?r.filter(e=>e!==n):[...r,n];return{selectedModels:{...e.selectedModels,[t]:i}}})},setExpandedFamilies:(n,r)=>{e(e=>({expandedFamilies:{...e.expandedFamilies,[n]:r}})),j({usageExpandedFamilies:t().expandedFamilies})},toggleFamilyExpanded:(n,r)=>{e(e=>{let t=e.expandedFamilies[n]??[],i=t.includes(r)?t.filter(e=>e!==r):[...t,r];return{expandedFamilies:{...e.expandedFamilies,[n]:i}}}),j({usageExpandedFamilies:t().expandedFamilies})},applyDefaultSelections:(n,r)=>{if((t().selectedModels[n]?.length??0)>0)return;let i=_a(n,r);i.length!==0&&(e(e=>({selectedModels:{...e.selectedModels,[n]:i}})),j({usageSelectedModels:t().selectedModels}))}}),{name:`quota-store`})),Na=()=>{let e=(0,Z.c)(11),t=C(Pa),n=Ma(Fa),r=Ma(Ia),i;e[0]===r?i=e[1]:(i=()=>{r()},e[0]=r,e[1]=i);let a;e[2]!==t||e[3]!==r||e[4]!==n?(a=[t,n,r],e[2]=t,e[3]=r,e[4]=n,e[5]=a):a=e[5],$.useEffect(i,a);let o=Ma(La),s=Ma(Ra),c=Ma(za),l,u;e[6]!==o||e[7]!==c||e[8]!==s?(l=()=>{if(!o)return;let e=window.setInterval(()=>{c()},s);return()=>window.clearInterval(e)},u=[o,s,c],e[6]=o,e[7]=c,e[8]=s,e[9]=l,e[10]=u):(l=e[9],u=e[10]),$.useEffect(l,u)};function Pa(e){return e.currentDirectory}function Fa(e){return e.magpieUsageUrl}function Ia(e){return e.fetchMagpieQuotas}function La(e){return e.autoRefresh}function Ra(e){return e.refreshIntervalMs}function za(e){return e.fetchAllQuotas}var Ba=e=>{let t=(0,Z.c)(20),{percent:n,tonePercent:r,className:i,expectedMarkerPercent:a}=e,o;t[0]===n?o=t[1]:(o=Rt(n)??0,t[0]=n,t[1]=o);let s=o,c=r??n,l;t[2]===c?l=t[3]:(l=Ct(c),t[2]=c,t[3]=l);let u=l,d=a==null?null:Math.max(0,Math.min(100,a)),f;t[4]===u?f=t[5]:(f=u===`critical`?{backgroundColor:`var(--status-error)`}:u===`warn`?{backgroundColor:`var(--status-warning)`}:{backgroundColor:`var(--status-success)`},t[4]=u,t[5]=f);let p=f,m;t[6]===i?m=t[7]:(m=Y(`relative h-2.5 rounded-full bg-[var(--interactive-border)] overflow-hidden`,i),t[6]=i,t[7]=m);let h=`${s}%`,g;t[8]!==p||t[9]!==h?(g={...p,width:h},t[8]=p,t[9]=h,t[10]=g):g=t[10];let _;t[11]!==s||t[12]!==g?(_=(0,Q.jsx)(`div`,{className:`h-full transition-all duration-300`,style:g,role:`progressbar`,"aria-valuenow":s,"aria-valuemin":0,"aria-valuemax":100}),t[11]=s,t[12]=g,t[13]=_):_=t[13];let v;t[14]===d?v=t[15]:(v=d!=null&&d>0&&d<100&&(0,Q.jsx)(`div`,{className:`absolute top-0 h-full w-0.5 bg-foreground`,style:{left:`${d}%`},title:`Expected usage if spread evenly: ${Math.round(d)}% of quota`,"aria-hidden":`true`}),t[14]=d,t[15]=v);let y;return t[16]!==m||t[17]!==_||t[18]!==v?(y=(0,Q.jsxs)(`div`,{className:m,children:[_,v]}),t[16]=m,t[17]=_,t[18]=v,t[19]=y):y=t[19],y},Va=e=>{let t=(0,Z.c)(67),{paceInfo:n,className:r,compact:i}=e,a=i!==void 0&&i,{t:o}=Ae(),s;t[0]===n.status?s=t[1]:(s=At(n.status),t[0]=n.status,t[1]=s);let c=s,l;bb0:{switch(n.status){case`on-track`:{let e;t[2]===o?e=t[3]:(e=o(`settings.usage.pace.status.onTrack`),t[2]=o,t[3]=e),l=e;break bb0}case`slightly-fast`:{let e;t[4]===o?e=t[5]:(e=o(`settings.usage.pace.status.slightlyFast`),t[4]=o,t[5]=e),l=e;break bb0}case`too-fast`:{let e;t[6]===o?e=t[7]:(e=o(`settings.usage.pace.status.tooFast`),t[6]=o,t[7]=e),l=e;break bb0}case`exhausted`:{let e;t[8]===o?e=t[9]:(e=o(`settings.usage.pace.status.usedUp`),t[8]=o,t[9]=e),l=e;break bb0}}l=void 0}let u=l,d;t[10]!==n.predictText||t[11]!==o?(d=o(`settings.usage.pace.predictionTooltip`,{prediction:n.predictText}),t[10]=n.predictText,t[11]=o,t[12]=d):d=t[12];let f=d;if(a){let e;t[13]===r?e=t[14]:(e=Y(`flex items-center gap-1.5`,r),t[13]=r,t[14]=e);let i;t[15]===c?i=t[16]:(i={backgroundColor:c},t[15]=c,t[16]=i);let a;t[17]!==u||t[18]!==i?(a=(0,Q.jsx)(`div`,{className:`h-2 w-2 rounded-full flex-shrink-0`,style:i,title:u}),t[17]=u,t[18]=i,t[19]=a):a=t[19];let s;t[20]===c?s=t[21]:(s={color:c},t[20]=c,t[21]=s);let l=n.isExhausted?void 0:f,d;t[22]!==n.isExhausted||t[23]!==n.predictText||t[24]!==n.remainingSeconds||t[25]!==o?(d=n.isExhausted?(0,Q.jsx)(Q.Fragment,{children:o(`settings.usage.pace.wait`,{duration:kt(n.remainingSeconds)})}):(0,Q.jsx)(Q.Fragment,{children:o(`settings.usage.pace.prediction`,{prediction:n.predictText})}),t[22]=n.isExhausted,t[23]=n.predictText,t[24]=n.remainingSeconds,t[25]=o,t[26]=d):d=t[26];let p;t[27]!==d||t[28]!==s||t[29]!==l?(p=(0,Q.jsx)(`span`,{className:`typography-micro tabular-nums`,style:s,title:l,children:d}),t[27]=d,t[28]=s,t[29]=l,t[30]=p):p=t[30];let m;return t[31]!==p||t[32]!==e||t[33]!==a?(m=(0,Q.jsxs)(`div`,{className:e,children:[a,p]}),t[31]=p,t[32]=e,t[33]=a,t[34]=m):m=t[34],m}let p;t[35]===r?p=t[36]:(p=Y(`flex items-center justify-between gap-2`,r),t[35]=r,t[36]=p);let m;t[37]!==n.isExhausted||t[38]!==n.paceRateText||t[39]!==o?(m=!n.isExhausted&&(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:o(`settings.usage.pace.rate`,{rate:n.paceRateText})}),t[37]=n.isExhausted,t[38]=n.paceRateText,t[39]=o,t[40]=m):m=t[40];let h;t[41]===m?h=t[42]:(h=(0,Q.jsx)(`div`,{className:`flex items-center gap-1.5`,children:m}),t[41]=m,t[42]=h);let g;t[43]===c?g=t[44]:(g={color:c},t[43]=c,t[44]=g);let _;t[45]!==n.isExhausted||t[46]!==n.predictText||t[47]!==n.remainingSeconds||t[48]!==f||t[49]!==u||t[50]!==o?(_=n.isExhausted?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:u}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.waitSeparator`)}),(0,Q.jsx)(`span`,{className:`font-medium`,children:kt(n.remainingSeconds)})]}):(0,Q.jsxs)(`span`,{title:f,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.predictionLabel`)}),(0,Q.jsx)(`span`,{className:`font-medium`,children:n.predictText})]}),t[45]=n.isExhausted,t[46]=n.predictText,t[47]=n.remainingSeconds,t[48]=f,t[49]=u,t[50]=o,t[51]=_):_=t[51];let v;t[52]!==g||t[53]!==_?(v=(0,Q.jsx)(`span`,{className:`typography-micro tabular-nums`,style:g,children:_}),t[52]=g,t[53]=_,t[54]=v):v=t[54];let y;t[55]===c?y=t[56]:(y={backgroundColor:c},t[55]=c,t[56]=y);let b;t[57]!==u||t[58]!==y?(b=(0,Q.jsx)(`div`,{className:`h-2 w-2 rounded-full flex-shrink-0`,style:y,title:u}),t[57]=u,t[58]=y,t[59]=b):b=t[59];let x;t[60]!==v||t[61]!==b?(x=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[v,b]}),t[60]=v,t[61]=b,t[62]=x):x=t[62];let S;return t[63]!==x||t[64]!==p||t[65]!==h?(S=(0,Q.jsxs)(`div`,{className:p,children:[h,x]}),t[63]=x,t[64]=p,t[65]=h,t[66]=S):S=t[66],S},Ha=e=>e instanceof Error&&e.name===`CancelledError`,Ua=_(()=>({setStatus:e=>wt(L,e),refreshStatus:async(e,t)=>{let r=n();t?.force&&await L.cancelQueries({queryKey:R.github.auth(r),exact:!0});try{return await Nt(L,e,r)}catch(e){if(Ha(e))return Mt(L,r);throw e}}})),Wa={displayMode:`browser`,installed:!1,browserTab:!0},Ga=new Set,Ka=Wa,qa=!1,Ja,Ya=()=>{let e=It();return{displayMode:e,installed:e!==`browser`,browserTab:e===`browser`}},Xa=()=>(!qa&&typeof window<`u`&&(Ka=Ya(),qa=!0),Ka),Za=()=>{let e=Ya();qa=!0,e.displayMode!==Ka.displayMode&&(Ka=e,Ga.forEach(e=>e()))},Qa=()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=[window.matchMedia(`(display-mode: standalone)`),window.matchMedia(`(display-mode: minimal-ui)`),window.matchMedia(`(display-mode: fullscreen)`),window.matchMedia(`(display-mode: window-controls-overlay)`)];for(let t of e)typeof t.addEventListener==`function`?t.addEventListener(`change`,Za):typeof t.addListener==`function`&&t.addListener(Za);return window.addEventListener(`appinstalled`,Za),window.addEventListener(`focus`,Za),()=>{for(let t of e)typeof t.removeEventListener==`function`?t.removeEventListener(`change`,Za):typeof t.removeListener==`function`&&t.removeListener(Za);window.removeEventListener(`appinstalled`,Za),window.removeEventListener(`focus`,Za)}},$a=e=>(Ga.add(e),Ja??=Qa(),Za(),()=>{Ga.delete(e),Ga.size===0&&(Ja?.(),Ja=void 0)}),eo=()=>$.useSyncExternalStore($a,Xa,to);function to(){return Wa}var no=`Yuri`,ro=_()(v(e=>({sidebarBrandName:no,setSidebarBrandName:t=>{let n=t.slice(0,64);e(e=>e.sidebarBrandName===n?e:{sidebarBrandName:n})}}),{name:`sidebar-brand-store`,storage:A(),version:3,migrate:(e,t)=>{if(!e||typeof e!=`object`)return e;let n={...e};return t<1&&n.sidebarBrandName===`YEE CODE`&&(n.sidebarBrandName=no),t<2&&n.sidebarBrandName===`Open Chamber`&&(n.sidebarBrandName=no),t<3&&(n.sidebarBrandName===`OPEN CHAMBER`||n.sidebarBrandName===`Open Chamber`)&&(n.sidebarBrandName=no),n}}));typeof window<`u`&&t(e=>{i(e)&&ro.persist.rehydrate()});var io=(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,ao=(e,t,n)=>{io(e.get(t),n)&&e.set(t,n)},oo=e=>{let t=e;return H(t.directory)??H(t.project?.worktree)},so=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)},co=(e,t,n,r,i=[])=>{let a=new Map,o=new Map;for(let e of t){let t=H(e.normalizedPath);if(!t)continue;let n=o.get(t);(!n||e.id.localeCompare(n.id)<0)&&o.set(t,e),ao(a,t,{projectId:e.id,projectRoot:t,scopeDirectory:t,kind:`project`})}if(!r)for(let[e,t]of n){let n=H(e),r=n?o.get(n):void 0;if(!(!r||!n))for(let e of t){let t=H(e.path);t&&ao(a,t,{projectId:r.id,projectRoot:n,scopeDirectory:t,kind:`worktree`})}}let s=new Map,c=new Map,l=new Map,u=new Map,d=new Map,f=e=>{if(!e)return null;if(s.has(e))return s.get(e)??null;if(r){let t=a.get(e)??null;return s.set(e,t),t}let t=[],n=e,i=null;for(;n;){if(s.has(n)){i=s.get(n)??null;break}if(t.push(n),i=a.get(n)??null,i)break;n=so(n)}for(let e of t)s.set(e,i);return i},p=(e,t,n)=>{for(let r of e){let e=f(oo(r));if(!e)continue;c.set(r.id,e);let i=t.get(e.projectId);if(i?i.push(r):t.set(e.projectId,[r]),!n)continue;let a=n.get(e.scopeDirectory);a?a.add(r.id):n.set(e.scopeDirectory,new Set([r.id]))}};return p(e,l,d),p(i,u),{bySessionId:c,sessionsByProject:l,archivedSessionsByProject:u,sessionsByScope:d,directoryResolutions:s.size}},lo=`__other__`;function uo(e){return e.time?.updated??e.time?.archived??e.time?.created??0}function fo({mode:e=`dialog`}){let{t}=Ae(),{isMobile:n,isTablet:r,hasTouchInput:i}=Gt(),a=n||r||i,s=e===`page`,c=O(e=>e.isArchivedSessionsDialogOpen),l=O(e=>e.setArchivedSessionsDialogOpen),u=s||c,d=Re(e=>e.projects),f=Ne(e=>e.archivedSessions),p=Ie(e=>e.setCurrentSession),m=O(e=>e.setSettingsDialogOpen),[h,g]=$.useState(!1),[_,v]=$.useState(null),[y,b]=$.useState(null);$.useEffect(()=>{if(!u){v(null),b(null);return}let e=!1;return g(!0),Je().catch(()=>{e||Pe.error(t(`settings.yuri.archivedSessions.toast.loadFailed`))}).finally(()=>{e||g(!1)}),()=>{e=!0}},[u,t]);let x=$.useMemo(()=>{let e=co([],d.map(e=>({id:e.id,normalizedPath:e.path})),new Map,o(),f),n=new Map;for(let[t,r]of e.archivedSessionsByProject)n.set(t,[...r].sort((e,t)=>uo(t)-uo(e)));let r=new Set;for(let e of n.values())for(let t of e)r.add(t.id);let i=f.filter(e=>!r.has(e.id)).sort((e,t)=>uo(t)-uo(e));i.length>0&&n.set(lo,i);let a=[];for(let e of d){let t=n.get(e.id)??[];t.length!==0&&a.push({projectId:e.id,label:e.label||e.path,path:e.path,sessions:t})}let s=n.get(lo);return s&&s.length>0&&a.push({projectId:lo,label:t(`settings.yuri.archivedSessions.otherProjects`),path:null,sessions:s}),a.sort((e,t)=>t.sessions.length-e.sessions.length||e.label.localeCompare(t.label)),a},[f,d,t]),S=f.length,C=_?x.find(e=>e.projectId===_)??null:null,w=$.useCallback(async e=>{b(e.id);try{await ze(e.id)?Pe.success(t(`settings.yuri.archivedSessions.toast.restored`)):Pe.error(t(`settings.yuri.archivedSessions.toast.restoreFailed`))}finally{b(null)}},[t]),T=$.useCallback(e=>{let t=Ve(e);p(e.id,t),l(!1),m(!1)},[p,l,m]),E=C?C.label:t(`settings.yuri.archivedSessions.dialog.title`),D=C?C.sessions.length===1?t(`settings.yuri.archivedSessions.dialog.sessionCountSingle`,{count:C.sessions.length}):t(`settings.yuri.archivedSessions.dialog.sessionCountPlural`,{count:C.sessions.length}):t(`settings.yuri.archivedSessions.dialog.description`),k=(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[C?(0,Q.jsxs)(Me,{type:`button`,variant:`ghost`,size:`sm`,className:`!h-7 !px-2 !font-normal text-muted-foreground`,onClick:()=>v(null),children:[(0,Q.jsx)(X,{name:`arrow-left-s`,className:`mr-1 h-4 w-4`}),t(`settings.yuri.archivedSessions.dialog.backToProjects`)]}):null,h?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 typography-meta text-muted-foreground py-6`,children:[(0,Q.jsx)(X,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),t(`settings.yuri.archivedSessions.dialog.loading`)]}):C?C.sessions.length===0?(0,Q.jsx)(`div`,{className:`rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:t(`settings.yuri.archivedSessions.dialog.emptyProject`)}):(0,Q.jsx)(`div`,{className:`space-y-1.5`,children:C.sessions.map(e=>{let n=Ve(e),r=uo(e),i=y===e.id;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-border/60 px-3 py-2.5 sm:flex-row sm:items-center sm:gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`typography-ui-label font-medium text-foreground truncate`,children:e.title||t(`sessions.sidebar.session.untitled`)}),(0,Q.jsxs)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:[r>0?Wt(r):null,r>0&&n?` · `:null,n?Oe(n):null]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,Q.jsx)(Me,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,disabled:i,onClick:()=>T(e),children:t(`settings.yuri.archivedSessions.actions.preview`)}),(0,Q.jsxs)(Me,{type:`button`,variant:`default`,size:`xs`,className:`!font-normal`,disabled:i,onClick:()=>void w(e),children:[i?(0,Q.jsx)(X,{name:`loader-4`,className:`mr-1 h-3.5 w-3.5 animate-spin`}):(0,Q.jsx)(X,{name:`inbox-unarchive`,className:`mr-1 h-3.5 w-3.5`}),t(`settings.yuri.archivedSessions.actions.restore`)]})]})]},e.id)})}):x.length===0?(0,Q.jsx)(`div`,{className:`rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:t(`settings.yuri.archivedSessions.dialog.empty`)}):(0,Q.jsx)(`div`,{className:`space-y-1.5`,children:x.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>v(e.projectId),className:Y(`flex w-full items-center gap-3 rounded-lg border border-border/60 px-3 py-2.5 text-left`,`hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`),children:[(0,Q.jsx)(X,{name:`folder`,className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`typography-ui-label font-medium text-foreground truncate`,children:e.label}),e.path?(0,Q.jsx)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:Oe(e.path)}):null]}),(0,Q.jsx)(`span`,{className:`typography-meta tabular-nums text-muted-foreground shrink-0`,children:e.sessions.length===1?t(`settings.yuri.archivedSessions.dialog.sessionCountSingle`,{count:e.sessions.length}):t(`settings.yuri.archivedSessions.dialog.sessionCountPlural`,{count:e.sessions.length})}),(0,Q.jsx)(X,{name:`arrow-right-s`,className:`h-4 w-4 shrink-0 text-muted-foreground`})]},e.projectId))}),!C&&!h&&S>0?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(S===1?`settings.yuri.archivedSessions.summarySingle`:`settings.yuri.archivedSessions.summaryPlural`,{count:S})}):null]});return s?(0,Q.jsxs)(`div`,{"data-settings-item":`archived-sessions.manage`,className:`yuri-settings-section-stack`,children:[(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.archivedSessions.description`)}),k]}):a?(0,Q.jsx)(zt,{open:c,title:E,onClose:()=>l(!1),contentMaxHeightClassName:`max-h-[min(80vh,640px)]`,renderHeader:e=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border/40 px-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:E}),e]}),(0,Q.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:D})]}),children:k}):(0,Q.jsx)(et,{open:c,onOpenChange:l,children:(0,Q.jsxs)(Ze,{className:`max-h-[85vh] max-w-2xl overflow-y-auto`,children:[(0,Q.jsxs)(Xe,{children:[(0,Q.jsx)(Qe,{children:E}),(0,Q.jsx)($e,{children:D})]}),k]})})}function po(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(fo,{mode:`dialog`}),e[0]=t):t=e[0],t}var mo=48;function ho({title:e,eyebrow:t,trailing:n,className:r}){let i=(0,$.useRef)(null),a=(0,$.useRef)(null),o=(0,$.useRef)(null),s=(0,$.useRef)(null),c=(0,$.useRef)(null),l=De(()=>{s.current=null;let e=i.current,t=a.current;if(!e||!t)return;let n=Math.min(1,Math.max(0,t.scrollTop/mo)),r=o.current?.matches?Number(n>=.5):n;c.current!==null&&Math.abs(c.current-r)<.001||(c.current=r,e.style.setProperty(`--yuri-mobile-title-collapse`,r.toFixed(4)))}),u=De(()=>{s.current===null&&(s.current=window.requestAnimationFrame(l))});return(0,$.useEffect)(()=>{let e=i.current;if(!e)return;let t=e.closest(`.yuri-mobile-settings-root-surface, [role="tabpanel"]`);if(!t)return;let n=window.matchMedia(`(prefers-reduced-motion: reduce)`);return a.current=t,o.current=n,c.current=null,t.addEventListener(`scroll`,u,{passive:!0}),n.addEventListener(`change`,u),l(),()=>{t.removeEventListener(`scroll`,u),n.removeEventListener(`change`,u),s.current!==null&&window.cancelAnimationFrame(s.current),s.current=null,a.current=null,o.current=null,c.current=null}},[]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`header`,{ref:i,className:Y(`yuri-mobile-collapsing-header flex shrink-0 items-start gap-4`,r),children:(0,Q.jsxs)(`div`,{className:`yuri-mobile-collapsing-header-inner`,children:[(0,Q.jsxs)(`div`,{className:`yuri-mobile-collapsing-header-title-block min-w-0 flex-1`,children:[t?(0,Q.jsx)(`p`,{className:`yuri-mobile-collapsing-header-eyebrow truncate typography-micro font-medium text-muted-foreground`,children:t}):null,(0,Q.jsx)(`h1`,{className:`yuri-mobile-root-page-title truncate font-semibold text-foreground`,children:e})]}),n?(0,Q.jsx)(`div`,{className:`yuri-mobile-collapsing-header-trailing flex min-h-10 shrink-0 items-center gap-3.5`,children:n}):null]})}),(0,Q.jsx)(`div`,{className:`yuri-mobile-collapsing-header-spacer`,"aria-hidden":`true`})]})}export{Jr as A,Pn as B,Bi as C,bi as D,Oi as E,Rr as F,Sn as H,zr as I,Fr as L,Ur as M,Lr as N,Gr as O,Ir as P,jr as R,Vi as S,Di as T,Cn as U,wn as V,ma as _,ro as a,Ji as b,Va as c,Na as d,Ma as f,ga as g,ha as h,co as i,Hr as j,qr as k,Ba as l,ua as m,po as n,eo as o,pa as p,fo as r,Ua as s,ho as t,ja as u,la as v,ki as w,Hi as x,aa as y,sr as z};
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,n as r,o as i}from"./runtime-switch-CAZiOV2G.js";import{n as a}from"./runtime-fetch-BAN5Gnnp.js";import{C as o,E as s,I as c,T as l,b as u,n as d,r as f,w as p,x as m,y as h}from"./desktop-dp2Z0toS.js";import{t as g}from"./runtimeAPIRegistry-C2VogTny.js";import{a as _,i as v,r as y}from"./vendor-zustand-o69pgTEK.js";import{it as b,nt as x,rt as S}from"./vendor-base-ui-CdzJ6My_.js";import{Ct as C,Nt as w,n as T,t as E}from"./platform-DXeTzJHG.js";import{b as D,n as O}from"./useUIStore-NMQx_cnG.js";import{$ as k,d as A,i as j}from"./persistence-BfjCXjLZ.js";import{n as M}from"./vendor-react-BP2cRVqX.js";import{l as N,n as P,o as F,s as I}from"./vendor-tanstack-react-query-CdqCAt40.js";import{a as L,o as R,r as z,t as B}from"./queryRuntime-BuRnpVtK.js";import{o as V}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{n as H}from"./pathNormalization-ewtPqJWn.js";import{a as U,t as ee}from"./types-D8_26ZKT.js";import{$ as te,A as W,B as G,G as K,H as q,J as ne,L as re,P as ie,T as ae,U as oe,W as se,X as ce,Y as le,a as ue,at as de,dt as fe,f as pe,ft as me,g as he,l as ge,pt as _e,st as ve,z as J}from"./vendor-codemirror-autocomplete-7c2L_4dM.js";import{c as ye,o as be,r as xe}from"./vendor-codemirror-lang-angular-DXOgWEVj.js";import{n as Se,r as Ce}from"./vendor-codemirror-lang-json-mLulNbwB.js";import{n as we}from"./vendor-codemirror-lang-markdown-CV1IO6Qs.js";import{n as Te}from"./vendor-codemirror-lang-python-YM2WVLHF.js";import{O as Ee}from"./vendor-codemirror-legacy-modes-DwltVFbT.js";import{n as De}from"./vendor-reactuses-core-BpfIZ1tg.js";import{a as Oe,d as ke,f as Ae,p as je,r as Y,t as Me}from"./button-BSFWH-Ok.js";import{Pr as Ne,Rr as Pe,bi as Fe,d as Ie,er as Le,fo as Re,hi as ze,ir as Be,jr as Ve,nr as He,or as Ue,rr as We,so as Ge,sr as Ke,vn as qe,wr as Je}from"./useMobileNavigationStore-DJwk64Po.js";import{n as Ye}from"./useThemeSystem-8jhE4Zyk.js";import{n as X}from"./Icon-BjiyvtB2.js";import{a as Xe,n as Ze,o as Qe,r as $e,t as et}from"./dialog-D1pXn_b9.js";import{L as tt,_ as nt,b as rt,c as it,n as at,s as ot,u as st}from"./gitApi-DhDVqj9b.js";import{A as ct,_ as lt,a as ut,b as dt,c as ft,h as pt,m as mt,n as ht,r as gt,t as _t,x as vt}from"./projectMeta-Bn2vBNDe.js";import{t as yt}from"./input-BhHXFla6.js";import{i as bt,n as xt,t as St}from"./tooltip-DygQ-2xe.js";import{F as Ct,G as wt,Gt as Tt,J as Et,Jt as Dt,Kt as Ot,M as kt,P as At,Qt as jt,U as Mt,W as Nt,Wt as Pt,Yt as Ft,a as It,it as Lt,k as Rt,q as zt,qt as Bt,rn as Vt,rt as Ht,ut as Ut,v as Wt}from"./speechSettingsQueries-D3fc_4Iy.js";import{r as Gt,t as Kt}from"./device-B7GyZCPd.js";import{n as qt}from"./MarkdownRenderer-DYi_qpYy.js";import{n as Jt,t as Yt}from"./textarea-Deh9E1KP.js";import{a as Xt}from"./url-MRa-FtQa.js";import{r as Zt}from"./markdown-worker-oBGEB9Eg.js";import{i as Qt,n as $t,o as en}from"./mcpQueries-vxcQAIGB.js";import{n as tn,r as nn,t as rn}from"./collapsible-DaevjAvt.js";import{a as an,d as on,o as sn,s as cn}from"./vendor-codemirror-commands-B8KrBQ9B.js";import{a as ln,c as un,i as dn,o as fn,r as pn,s as mn}from"./vendor-codemirror-search-ZqtrPLjU.js";import{n as hn,t as gn}from"./vendor-replit-codemirror-vim-DDj0dSVY.js";import{t as _n}from"./vendor-codemirror-language-data-Ctd4WxgW.js";import{i as vn,n as yn,r as bn,t as xn}from"./projectActions-BX0cjZoq.js";var Sn=[{id:`claude`,name:`Claude`},{id:`codex`,name:`Codex`},{id:`cursor`,name:`Cursor`},{id:`github-copilot`,name:`GitHub Copilot`},{id:`google`,name:`Google`},{id:`kimi-for-coding`,name:`Kimi for Coding`},{id:`nano-gpt`,name:`NanoGPT`},{id:`openrouter`,name:`OpenRouter`},{id:`zai-coding-plan`,name:`z.ai`},{id:`zhipuai-coding-plan`,name:`Zhipu AI Coding Plan`},{id:`minimax-cn-coding-plan`,name:`MiniMax Coding Plan (minimaxi.com)`},{id:`minimax-coding-plan`,name:`MiniMax Coding Plan (minimax.io)`},{id:`ollama-cloud`,name:`Ollama Cloud`},{id:`wafer`,name:`Wafer.ai`},{id:`opencode-go`,name:`OpenCode Go`},{id:`xai`,name:`Grok`}],Cn=e=>[...Sn,...e.filter(e=>e.source===`magpie`).map(e=>({id:e.providerId,name:e.providerName}))],Z=M(),Q=S();function wn(e){let t=(0,Z.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.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,Q.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,Q.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 Tn={},En=(e,t=n())=>JSON.stringify([t,$t(e)]),Dn=(e,t,n)=>{if(!e[t]?.[n])return e;let r={...e[t]};return delete r[n],{...e,[t]:r}},On=e=>{let t=$t(e);return t?w.getScopedApiClient(t):w.getApiClient()},kn=e=>e?{location:{directory:e}}:void 0,An=new Map,jn=(e,t)=>JSON.stringify([r(),En(t),e]),Mn=async(e,t,n)=>{let r=(await e.mcp.list(kn(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,...kn(n)})).data},Nn=e=>$t(e===void 0?C.getState().currentDirectory:e),Pn=_()(y((e,t)=>({diagnosticsByDirectory:{},getDiagnosticForDirectory:e=>{let n=En(Nn(e));return t().diagnosticsByDirectory[n]??Tn},clearDiagnostic:(t,n,r)=>{let i=En(Nn(n),r);e(e=>({diagnosticsByDirectory:Dn(e.diagnosticsByDirectory,i,t)}))},connect:async(t,r)=>{let i=Nn(r),a=n(),o=En(i,a),s=On(i);try{await s.mcp.connect({server:t,...kn(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 en(L,i,a),e(e=>({diagnosticsByDirectory:Dn(e.diagnosticsByDirectory,o,t)}))},disconnect:async(t,r)=>{let i=Nn(r),a=n(),o=En(i,a);await On(i).mcp.disconnect({server:t,...kn(i)}),await en(L,i,a),e(e=>({diagnosticsByDirectory:Dn(e.diagnosticsByDirectory,o,t)}))},startAuth:async(e,t)=>{let n=Nn(t),r=jn(e,n),i=On(n),a=await Mn(i,e,n),o=a.methods.find(e=>e.type===`oauth`);if(!o)throw Error(`MCP server "${e}" has no OAuth method`);if(r!==jn(e,n))throw Error(`MCP authorization runtime changed`);let s=An.get(r);if(s&&(await i.integration.oauth.cancel({integrationID:s.integrationID,attemptID:s.attempt.attemptID,...kn(n)}),An.delete(r)),r!==jn(e,n))throw Error(`MCP authorization runtime changed`);let{data:c}=await i.integration.oauth.connect({integrationID:a.id,methodID:o.id,...kn(n)});if(r!==jn(e,n))throw Error(`MCP authorization runtime changed`);for(let[e,t]of An)t.attempt.time.expires<=Date.now()&&An.delete(e);return An.set(r,{integrationID:a.id,attempt:c}),c},authStatus:async(e,t)=>{let n=Nn(t),r=jn(e,n),i=An.get(r);if(!i)throw Error(`MCP authorization attempt not found`);let{data:a}=await On(n).integration.oauth.status({integrationID:i.integrationID,attemptID:i.attempt.attemptID,...kn(n)});if(r!==jn(e,n))throw Error(`MCP authorization runtime changed`);return a.status!==`pending`&&An.get(r)===i&&An.delete(r),a},completeAuth:async(e,t,r)=>{let i=Nn(r),a=n(),o=jn(e,i),s=An.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 On(i).integration.oauth.complete({integrationID:s.integrationID,attemptID:s.attempt.attemptID,code:t.trim(),...kn(i)}),An.get(o)===s&&An.delete(o),o!==jn(e,i))throw Error(`MCP authorization runtime changed`);await en(L,i,a)},clearAuth:async(e,t)=>{let r=Nn(t),i=n(),a=jn(e,r),o=On(r),s=await Mn(o,e,r);if(a!==jn(e,r))throw Error(`MCP authorization runtime changed`);let c=An.get(a);c&&(await o.integration.oauth.cancel({integrationID:c.integrationID,attemptID:c.attempt.attemptID,...kn(r)}),An.delete(a));let l=new Set(s.connections.flatMap(e=>e.type===`credential`?[e.id]:[]));for(let t of l){if(a!==jn(e,r))throw Error(`MCP authorization runtime changed`);await o.credential.remove({credentialID:t})}if(a!==jn(e,r))throw Error(`MCP authorization runtime changed`);await en(L,r,i)},testConnection:async(t,r)=>{let i=Nn(r),a=n(),o=En(i,a),s=On(i),c=Qt(L,i,a)[t]?.status===`connected`,l,u;try{await s.mcp.connect({server:t,...kn(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 en(L,i,a))[t],f=d;if(!c&&d?.status===`connected`){try{await s.mcp.disconnect({server:t,...kn(i)})}catch(e){u=`Connection test succeeded, but cleanup disconnect failed: ${e instanceof Error?e.message:`Disconnect failed`}`}await en(L,i,a)}return l||e(e=>({diagnosticsByDirectory:Dn(e.diagnosticsByDirectory,o,t)})),{status:f??Qt(L,i,a)[t],error:l,warning:u}}}))),$=e(b(),1),Fn=`https://yuri-updates.xiaobe.top/v1/update/check`,In=`https://yuri-origin.xiaobe.top/v1/update/check`,Ln=`https://github.com/yee94/yuri/releases/latest`,Rn=`https://github.com/yee94/yuri/releases`,zn=`https://testflight.apple.com/join/pN5SSHeg`,Bn=1e4;function Vn(e){let t=String(e||``).replace(/^v/,``).split(`+`)[0]??``,n=t.indexOf(`-`);return{parts:(n>=0?t.slice(0,n):t).split(`.`).map(e=>{let t=Number.parseInt(e||`0`,10);return Number.isFinite(t)?t:0}),prerelease:n>=0}}function Hn(e,t){let n=Vn(e),r=Vn(t),i=Math.max(n.parts.length,r.parts.length);for(let e=0;e<i;e+=1){let t=(n.parts[e]||0)-(r.parts[e]||0);if(t!==0)return t}return n.prerelease===r.prerelease?0:n.prerelease?-1:1}function Un(){return[Fn,In]}function Wn(e,t,n=Date.now){let r=e-n();return r<=0||t<=0?null:Math.max(1,Math.ceil(r/t))}function Gn(e){return{appType:`mobile-capacitor`,deviceClass:e.deviceClass||`mobile`,platform:e.platform===`ios`||e.platform===`android`?e.platform:`android`,arch:e.arch||`unknown`,channel:`stable`,currentVersion:e.currentVersion,instanceMode:`remote`,reportUsage:e.reportUsage===!0}}async function Kn(e,t,n,r){try{if(T())try{let{CapacitorHttp:r}=await V(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 qn(e,t){return e===`ios`?zn:`${Rn}/download/v${t}/app-release.apk`}function Jn(e,t,n){if(typeof e.latestVersion!=`string`||e.latestVersion.trim().length===0)return null;let r=e.latestVersion.trim(),i=Hn(r,t);if(i<0)return null;let a=typeof e.releaseNotesUrl==`string`&&e.releaseNotesUrl.trim().length>0?e.releaseNotesUrl.trim():`${Rn}/tag/v${r}`,o=typeof e.downloadUrl==`string`&&e.downloadUrl.trim().length>0?e.downloadUrl.trim():typeof e.download?.url==`string`&&e.download.url.trim().length>0?e.download.url.trim():qn(n,r);return{available:!!e.updateAvailable&&i>0,version:r,currentVersion:t,body:typeof e.releaseNotes==`string`?e.releaseNotes:void 0,releaseUrl:a,downloadUrl:o,nextSuggestedCheckInSec:typeof e.nextSuggestedCheckInSec==`number`&&Number.isFinite(e.nextSuggestedCheckInSec)?e.nextSuggestedCheckInSec:void 0}}async function Yn(e,t,n,r){let i=await Kn(e,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify(Gn(t))},n,r);if(!i?.ok)return null;let a;try{a=await i.json()}catch{return null}return Jn(a,t.currentVersion,t.platform)}async function Xn(e,t,n,r){let i=await Kn(Ln,{method:`GET`,headers:{Accept:`text/html`},redirect:`follow`},n,r);if(!i?.ok)return null;let a=typeof i.url==`string`&&i.url.length>0?i.url:Ln,o=null;try{o=new URL(a).pathname.match(/\/releases\/tag\/v(\d+\.\d+\.\d+(?:-[\w.]+)?)/)}catch{return null}if(!o?.[1])return null;let s=o[1],c=Hn(s,e),l=`${Rn}/tag/v${s}`;return{available:c>0,version:s,currentVersion:e,releaseUrl:l,downloadUrl:qn(t,s)}}async function Zn(e){let t=e.currentVersion?.trim()||`unknown`;if(t===`unknown`)return{available:!1,currentVersion:t,error:`Unable to check for mobile updates`};let n=e.fetchImpl??fetch,r=e.now??Date.now,i=Un(),a=r()+Bn;for(let[t,o]of i.entries()){let s=Wn(a,i.length-t+1,r);if(s===null)break;let c=await Yn(o,e,s,n);if(c)return c}let o=Wn(a,1,r);if(o!==null){let r=await Xn(t,e.platform,o,n);if(r)return r}return{available:!1,currentVersion:t,error:`Unable to check for mobile updates`}}function Qn(){if(typeof window>`u`)return`unknown`;try{let{deviceType:e}=Kt();return e}catch{return`unknown`}}function $n(){let e=typeof window<`u`?window.__VSCODE_CONFIG__?.arch?.toLowerCase?.():void 0;if(e===`arm64`||e===`aarch64`)return`arm64`;if(e===`x64`||e===`amd64`||e===`x86_64`)return`x64`;let t=(typeof navigator<`u`?navigator.userAgentData:void 0)?.architecture?.toLowerCase?.();if(t===`arm`||t===`arm64`||t===`aarch64`)return`arm64`;if(t===`x86`||t===`x64`||t===`amd64`)return`x64`;let n=typeof navigator<`u`?navigator.userAgent.toLowerCase():``;return n.includes(`aarch64`)||n.includes(`arm64`)||n.includes(`armv`)?`arm64`:n.includes(`x86_64`)||n.includes(`x64`)||n.includes(`amd64`)||n.includes(`win64`)?`x64`:`unknown`}function er(){let e=E();if(e===`android`||e===`ios`)return e;if(typeof navigator>`u`)return`web`;let t=(navigator.platform||``).toLowerCase();return t.includes(`mac`)?`macos`:t.includes(`win`)?`windows`:t.includes(`linux`)?`linux`:`web`}function tr(e){let t=O.getState().reportUsage,n=new URLSearchParams({reportUsage:t?`true`:`false`});return n.set(`deviceClass`,Qn()),n.set(`arch`,$n()),n.set(`platform`,er()),e===`desktop`?(n.set(`appType`,`desktop-electron`),n.set(`instanceMode`,h()?`local`:`remote`),n):e===`vscode`?(n.set(`appType`,`vscode`),n.set(`instanceMode`,`local`),n):e===`mobile`?(n.set(`appType`,`mobile-capacitor`),n.set(`instanceMode`,`remote`),n):(n.set(`appType`,`web`),n.set(`instanceMode`,`unknown`),n)}async function nr(e,t){let n=t??`unknown`;try{let r=tr(e),i=typeof window<`u`?window.__VSCODE_CONFIG__?.extensionVersion:void 0;t?r.set(`currentVersion`,t):e===`vscode`&&i&&r.set(`currentVersion`,i);let o=await a(`/api/yuri/update-check?${r.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),s=null;try{s=await o.json()}catch{s=null}if(!o.ok)return{available:!1,currentVersion:n,error:typeof s?.error==`string`&&s.error.trim().length>0?s.error.trim():`Server responded with ${o.status}`};if(!s)return{available:!1,currentVersion:n,error:`Update check returned an invalid response`};let c=typeof s.error==`string`&&s.error.trim().length>0?s.error.trim():void 0;return{available:s.available===!0,version:typeof s.version==`string`?s.version:void 0,currentVersion:typeof s.currentVersion==`string`?s.currentVersion:n,body:typeof s.body==`string`?s.body:void 0,releaseUrl:typeof s.releaseUrl==`string`?s.releaseUrl:void 0,downloadUrl:typeof s.downloadUrl==`string`?s.downloadUrl:void 0,nextSuggestedCheckInSec:typeof s.nextSuggestedCheckInSec==`number`&&Number.isFinite(s.nextSuggestedCheckInSec)?s.nextSuggestedCheckInSec:void 0,packageManager:typeof s.packageManager==`string`?s.packageManager:void 0,updateCommand:typeof s.updateCommand==`string`?s.updateCommand:void 0,error:c}}catch(e){return console.warn(`Failed to check for updates:`,e),{available:!1,currentVersion:n,error:e instanceof Error?e.message:`Failed to check for updates`}}}function rr(){return T()?`mobile`:m()?`desktop`:o()?`vscode`:p()?`web`:null}var ir={checking:!1,available:!1,downloading:!1,downloaded:!1,info:null,progress:null,error:null,runtimeType:null,lastChecked:null,nextCheckInSec:null,otaDecision:null,otaPhase:`idle`,otaDownloadSkipped:!1,lastOtaChannelOverride:null};function ar(e,t){let n=e.isChannelRollback===!0?{isChannelRollback:!0}:{};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 or=0,sr=_()((e,t)=>({...ir,checkForUpdates:async()=>{let n=rr();if(!n)return null;let r=++or;e({checking:!0,error:null,runtimeType:n});try{let i=null,a=null;if(n===`desktop`){let n=O.getState().otaChannelOverride;t().lastOtaChannelOverride!==n&&e({downloaded:!1,downloading:!1,available:!1,info:null,otaDecision:null,progress:null,otaPhase:`checking`});let i=await d(n);if(r!==or||O.getState().otaChannelOverride!==n)return null;let a=i?.downloaded===!0;return e({checking:!1,available:i?.available??!1,downloaded:a,...a?{downloading:!1,progress:null}:{},info:i,error:null,lastChecked:Date.now(),nextCheckInSec:i?.nextSuggestedCheckInSec??null,otaDecision:i?.otaDecision??null,otaPhase:a?`pending_restart`:i?.inAppApply?`available`:`idle`,lastOtaChannelOverride:n}),i?.nextSuggestedCheckInSec??null}if(n===`web`)i=await nr(`web`),a=i?.nextSuggestedCheckInSec??null;else if(n===`vscode`)a=(await nr(`vscode`))?.nextSuggestedCheckInSec??null;else if(n===`mobile`){let n=await U()??`unknown`,r=T()?g()?.mobileUpdates:void 0,o=O.getState().otaChannelOverride;if(r)try{let i=t().lastOtaChannelOverride!==o;e(i?{otaDecision:null,otaPhase:`checking`,downloaded:!1,otaDownloadSkipped:!1,progress:null,available:!1,info:null}:{otaPhase:`checking`});let a=await r.checkForOtaUpdate(o===`beta`||o===`stable`?{channelOverride:o}:void 0),s=ar(a,n),c=(i?void 0:t().otaDecision?.ota.bundle?.bundleId)!==a.ota.bundle?.bundleId,l=!i&&t().downloaded&&!c;return e({checking:!1,available:s.available,info:s.info,error:s.info.error??null,lastChecked:Date.now(),nextCheckInSec:a.nextCheckInSec,otaDecision:a,otaPhase:l?`pending_restart`:s.otaPhase,lastOtaChannelOverride:o,...c||i?{downloaded:!1,otaDownloadSkipped:!1,progress:null}:{}}),a.nextCheckInSec}catch(t){if(!(t instanceof ee)){let r=t instanceof Error?t.message:`Mobile OTA check failed`;return e({checking:!1,available:!1,info:{available:!1,currentVersion:n},error:r,lastChecked:Date.now(),otaDecision:null,otaPhase:`error`,lastOtaChannelOverride:o}),null}}return i=await Zn({currentVersion:n,platform:er()===`ios`?`ios`:`android`,deviceClass:Qn(),arch:$n(),reportUsage:O.getState().reportUsage}),a=i?.nextSuggestedCheckInSec??null,e({checking:!1,available:i?.available??!1,info:i,error:i?.error??null,lastChecked:Date.now(),nextCheckInSec:a,otaDecision:null,otaPhase:`idle`}),a}return e({checking:!1,available:n===`vscode`?!1:i?.available??!1,info:n===`vscode`?null:i,error:n===`vscode`?null:i?.error??null,lastChecked:Date.now(),nextCheckInSec:a}),a}catch(i){return r===or&&e({checking:!1,error:i instanceof Error?i.message:`Failed to check for updates`,...n===`desktop`&&!t().downloaded?{otaPhase:`error`}:{}}),null}},downloadUpdate:async()=>{let{available:n,runtimeType:r,otaDecision:i,downloading:a,downloaded:o}=t();if(r===`mobile`&&i?.primaryAction===`apply_ota`&&i.ota.bundle){if(a||o)return;let t=g()?.mobileUpdates;if(!t){e({error:`Mobile OTA updates are unavailable in this runtime`,otaPhase:`error`});return}e({downloading:!0,error:null,progress:null,otaPhase:`downloading`,otaDownloadSkipped:!1});try{let{skipped:n}=await t.downloadOtaUpdate(i.ota.bundle);await t.queueOtaUpdateForNextLaunch(),e({downloading:!1,downloaded:!0,progress:null,otaPhase:`pending_restart`,otaDownloadSkipped:n})}catch(t){e({downloading:!1,error:t instanceof Error?t.message:`Failed to download update`,otaPhase:`error`})}return}if(!(r!==`desktop`||!n)){e({downloading:!0,error:null,progress:null});try{let n=O.getState().otaChannelOverride,r=await d(n);if(n!==O.getState().otaChannelOverride)throw Error(`OTA channel changed`);if(!r?.available||r.manualUpdate)throw Error(`Update detected, but desktop package is not ready yet. Retry in a moment.`);if(e(e=>({info:e.info?{...e.info,...r,body:r.body||e.info.body,available:e.info.available}:r})),r.downloaded||t().downloaded){e({downloading:!1,downloaded:!0,progress:null});return}if(r.downloading&&e({downloading:!0,progress:r.progress??{downloaded:0}}),!await f(t=>{e({progress:t})}))throw Error(`Failed to download update`);e({downloading:!1,downloaded:!0,progress:null,otaPhase:`pending_restart`})}catch(t){e({downloading:!1,error:t instanceof Error?t.message:`Failed to download update`})}}},subscribeDesktopUpdateEvents:async()=>{if(!m())return()=>{};let n=[],r=await l(n=>{let r=n.event,i=n.data??null;if(r===`Started`){if(!t().downloading)return;e({error:null,progress:{downloaded:0,total:typeof i?.contentLength==`number`?i.contentLength:void 0}});return}if(r===`Progress`){if(!t().downloading)return;e({progress:{downloaded:typeof i?.downloaded==`number`?i.downloaded:0,total:typeof i?.total==`number`?i.total:void 0}});return}r===`Finished`&&e({downloading:!1,downloaded:!0,progress:null})});r&&n.push(r);let i=await s(t=>{t.downloaded&&e({downloading:!1,downloaded:!0,available:!0,progress:null})});return i&&n.push(i),async()=>{for(let e of n)try{let t=e();t instanceof Promise&&await t}catch{}}},restartToUpdate:async()=>{let{downloaded:n,runtimeType:r,otaDecision:i}=t();if(r===`mobile`&&i?.primaryAction===`apply_ota`){if(!n)return;let t=g()?.mobileUpdates;if(!t){e({error:`Mobile OTA updates are unavailable in this runtime`,otaPhase:`error`});return}try{await t.applyOtaUpdateNow()}catch(t){e({error:t instanceof Error?t.message:`Failed to restart`,otaPhase:`error`})}return}if(!(r!==`desktop`||!n))try{if(!await c())throw Error(`Failed to restart`)}catch(t){e({error:t instanceof Error?t.message:`Failed to restart`})}},setOtaPhase:(t,n=null)=>{e({otaPhase:t,...n===void 0?{}:{error:n}})},setOtaDownloadPercent:n=>{if(!Number.isFinite(n)||n<0||n>100)return;let r=t();if(!r.downloading)return;let i=Math.round(n);if((r.progress?.total?Math.round(r.progress.downloaded/r.progress.total*100):null)===i)return;let a=r.otaDecision?.ota.bundle?.size;if(typeof a==`number`&&Number.isFinite(a)&&a>0){e({progress:{downloaded:Math.round(a*n/100),total:a}});return}e({progress:{downloaded:n,total:100}})},setOtaDownloadFailed:t=>{e({downloading:!1,downloaded:!1,error:t??`Failed to download update`,otaPhase:`error`})},dismiss:()=>{t().otaPhase!==`pending_restart`&&e({available:!1,downloaded:!1,info:null,otaDecision:null,otaPhase:`idle`,otaDownloadSkipped:!1})},reset:()=>{e(ir)}})),cr=e=>!!(e&&![`succeeded`,`failed`].includes(e.status));function lr(e,t){if(e!==n()||t!==r())throw Error(`Stale update runtime`)}var ur=(e=n(),t=r(),i)=>({queryKey:[e,`host-update`,t,i??`current`],queryFn:async({signal:n})=>{lr(e,t);let r=await a(`/api/system/update${i?`?channel=${i}`:``}`,{headers:{Accept:`application/json`},signal:n});if([404,501].includes(r.status))throw Error(`host_update_unsupported`);let o=await r.json();if(lr(e,t),!r.ok&&r.status!==502||typeof o.serverId!=`string`||typeof o.supported!=`boolean`||![`cli`,`electron`].includes(o.host))throw Error(`Host update check failed`);return o},staleTime:6e4,retry:!1}),dr=(e=n(),t=r(),i)=>L.getQueryData(ur(e,t,i).queryKey),fr=(e=n(),t=r(),i)=>{let a=dr(e,t,i);return L.fetchQuery({...ur(e,t,i),staleTime:a?.checkError||cr(a?.operation)?0:6e4})},pr=(e=n(),t=r(),i)=>L.fetchQuery({...ur(e,t,i),staleTime:0}),mr=(e,t,n)=>{let r=(0,Z.c)(6),i;r[0]!==n||r[1]!==t||r[2]!==e?(i=ur(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:gr,refetchIntervalInBackground:!1},r[4]=i,r[5]=a),I(a)};async function hr(e,t,n){if(lr(t,n),!e.update)throw Error(`No update plan`);let r=await a(`/api/system/update`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({version:e.update.version,channel:e.channel,planId:e.update.planId,allowDowngrade:e.update.rollback===!0})});if(lr(t,n),!r.ok)throw Error(`Host update was not accepted`);let i=await r.json();if(typeof i.operation?.id!=`string`)throw Error(`Invalid update operation`);return i.operation}function gr(e){return e.state.error?.message===`host_update_unsupported`?!1:e.state.error?15e3:cr(e.state.data?.operation)?2e3:3e5}function _r(e){let t=new Date(`${e}T00:00:00`);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(je(),{year:`numeric`,month:`short`,day:`numeric`}).format(t)}function vr(e){return e.replace(/^## \[[^\]]+\] - \d{4}-\d{2}-\d{2}\s*\n?/,``).trim()}function yr(e){return e.replace(/(^|[^a-zA-Z0-9])@([a-zA-Z0-9-]+)/g,`$1[@$2](https://github.com/$2)`)}function br(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 xr(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 Sr(e){let t=(0,Z.c)(72),{open:n,onOpenChange:r,model:i,onAction:a}=e,{t:o}=Ae(),[s,c]=(0,$.useState)(!1),l=De(wr),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=De(u),f;t[2]===i.fallbackCommand?f=t[3]:(f=async()=>{i.fallbackCommand&&(await ke(i.fallbackCommand)).ok&&(c(!0),setTimeout(()=>c(!1),2e3))},t[2]=i.fallbackCommand,t[3]=f);let p=De(f),m;if(t[4]!==i.body||t[5]!==o){bb0:{let e=i.body?.trim();if(!e){m=null;break bb0}let n=xr(e);if(!n.length){m={kind:`raw`,title:o(`updateDialog.changelog.title`),content:yr(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(Cr).map(t=>({version:t.version,dateLabel:_r(t.date),content:yr(vr(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,_;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(X,{name:`download-cloud`,className:`h-5 w-5 text-[var(--primary-base)]`}),t[9]=_):_=t[9];let v;t[10]===i.title?v=t[11]:(v=(0,Q.jsxs)(Qe,{className:`flex items-center gap-2`,children:[_,(0,Q.jsx)(`span`,{className:`font-semibold text-foreground`,children:i.title})]}),t[10]=i.title,t[11]=v);let y;t[12]!==i.currentVersion||t[13]!==i.methodLabel||t[14]!==i.version?(y=(i.currentVersion||i.version)&&(0,Q.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,Q.jsx)(`span`,{className:`text-muted-foreground/75`,children:i.currentVersion}),i.currentVersion&&i.version&&(0,Q.jsx)(`span`,{className:`text-muted-foreground/40`,children:`→`}),i.version&&(0,Q.jsx)(`span`,{className:`font-medium text-[var(--primary-base)]`,children:i.version}),i.methodLabel&&(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· `,i.methodLabel]})]}),t[12]=i.currentVersion,t[13]=i.methodLabel,t[14]=i.version,t[15]=y):y=t[15];let b;t[16]===i.description?b=t[17]:(b=i.description&&(0,Q.jsx)($e,{className:`mt-2`,children:i.description}),t[16]=i.description,t[17]=b);let x;t[18]!==v||t[19]!==y||t[20]!==b?(x=(0,Q.jsxs)(`div`,{className:`mb-3 pr-8 sm:mb-4`,children:[v,y,b]}),t[18]=v,t[19]=y,t[20]=b,t[21]=x):x=t[21];let S;t[22]===i.message?S=t[23]:(S=i.message&&(0,Q.jsx)(`p`,{role:`status`,className:`typography-ui-label text-muted-foreground`,children:i.message}),t[22]=i.message,t[23]=S);let C;t[24]===i.warning?C=t[25]:(C=i.warning&&(0,Q.jsx)(`p`,{className:`typography-meta text-[var(--status-warning)]`,children:i.warning}),t[24]=i.warning,t[25]=C);let w;t[26]===i.status?w=t[27]:(w=i.status?.kind===`activity`&&(0,Q.jsxs)(`div`,{role:`status`,className:`rounded-lg bg-[var(--surface-elevated)]/30 p-5 border border-[var(--surface-subtle)]`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(X,{name:`loader`,className:`h-5 w-5 animate-spin text-[var(--primary-base)]`}),(0,Q.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:i.status.label})]}),i.status.detail&&(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:i.status.detail})]}),t[26]=i.status,t[27]=w);let T;t[28]!==h||t[29]!==d||t[30]!==i.hideChangelog?(T=h&&!i.hideChangelog&&(0,Q.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--surface-subtle)] px-3.5 py-2.5 sm:px-4 sm:py-3`,children:[(0,Q.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--primary-base)]`,"aria-hidden":`true`}),(0,Q.jsx)(`h3`,{className:`typography-ui-caption font-medium text-muted-foreground`,children:h.title})]}),(0,Q.jsx)(Jt,{className:`max-h-[min(42dvh,22rem)] p-0 sm:max-h-[400px]`,fillContainer:!1,children:h.kind===`raw`?(0,Q.jsx)(`div`,{className:`break-words p-3.5 text-[13px] leading-[1.65] text-foreground sm:p-4 sm:text-sm [&_.markdown-content]:leading-[1.65] [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline`,onClickCapture:d,children:(0,Q.jsx)(qt,{content:h.content,disableLinkSafety:!0,enableFileReferences:!1})}):(0,Q.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:h.sections.map(e=>(0,Q.jsxs)(`div`,{className:`p-3.5 sm:p-4`,children:[(0,Q.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-center gap-x-2 gap-y-1 sm:mb-3`,children:[(0,Q.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,Q.jsx)(`span`,{className:`text-[11px] leading-4 text-muted-foreground/75 sm:text-xs`,children:e.dateLabel})]}),(0,Q.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,Q.jsx)(qt,{content:e.content,disableLinkSafety:!0,enableFileReferences:!1})})]},e.version))})})]}),t[28]=h,t[29]=d,t[30]=i.hideChangelog,t[31]=T):T=t[31];let E;t[32]!==s||t[33]!==p||t[34]!==i.fallbackCommand||t[35]!==o?(E=i.fallbackCommand&&(0,Q.jsxs)(`div`,{className:`space-y-2 mt-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 typography-meta text-muted-foreground`,children:[(0,Q.jsx)(X,{name:`terminal`,className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:o(`updateDialog.fallback.updateViaTerminal`)})]}),(0,Q.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,Q.jsx)(`code`,{className:`flex-1 font-mono text-sm text-foreground overflow-x-auto whitespace-nowrap`,children:i.fallbackCommand}),(0,Q.jsx)(`button`,{onClick:p,className:Y(`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,Q.jsx)(X,{name:s?`check`:`clipboard`,className:`h-4 w-4`})})]})]}),t[32]=s,t[33]=p,t[34]=i.fallbackCommand,t[35]=o,t[36]=E):E=t[36];let D;t[37]===i.status?D=t[38]:(D=i.status?.kind===`download`&&(0,Q.jsxs)(`div`,{role:`status`,className:`mt-3 space-y-2 rounded-lg border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20 px-3.5 py-3 sm:mt-4 sm:px-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground sm:text-[13px]`,children:i.status.label}),i.status.progress!=null&&(0,Q.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] leading-4 text-foreground tabular-nums sm:text-xs`,children:[Math.round(i.status.progress),`%`]})]}),i.status.progress!=null&&(0,Q.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-[var(--surface-subtle)] sm:h-1.5`,children:(0,Q.jsx)(`div`,{className:`h-full rounded-full bg-[var(--primary-base)] transition-all duration-300`,style:{width:`${i.status.progress}%`}})}),i.status.detail&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i.status.detail})]}),t[37]=i.status,t[38]=D);let O;t[39]===i.error?O=t[40]:(O=i.error&&(0,Q.jsx)(`div`,{role:`alert`,className:`p-3 mt-4 bg-[var(--status-error-background)] border border-[var(--status-error-border)] rounded-lg`,children:(0,Q.jsx)(`p`,{className:`text-sm text-[var(--status-error)]`,children:i.error})}),t[39]=i.error,t[40]=O);let k;t[41]!==S||t[42]!==C||t[43]!==w||t[44]!==T||t[45]!==E||t[46]!==D||t[47]!==O?(k=(0,Q.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[S,C,w,T,E,D,O]}),t[41]=S,t[42]=C,t[43]=w,t[44]=T,t[45]=E,t[46]=D,t[47]=O,t[48]=k):k=t[48];let A;t[49]===i.notice?A=t[50]:(A=i.notice&&(0,Q.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,Q.jsx)(X,{name:`check`,className:`h-4 w-4 shrink-0`}),(0,Q.jsx)(`span`,{children:i.notice})]}),t[49]=i.notice,t[50]=A);let j;t[51]===i.releaseLink?j=t[52]:(j=i.releaseLink?(0,Q.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,Q.jsx)(X,{name:`external-link`,className:`h-4 w-4`}),i.releaseLink.label]}):(0,Q.jsx)(`span`,{}),t[51]=i.releaseLink,t[52]=j);let M;if(t[53]!==i.actions||t[54]!==a){let e;t[56]===a?e=t[57]:(e=e=>(0,Q.jsxs)(Me,{onClick:()=>a(e.id),disabled:e.disabled,variant:e.variant??`default`,size:`default`,children:[e.icon&&(0,Q.jsx)(X,{name:e.icon,className:Y(`h-4 w-4`,e.loading&&`animate-spin`)}),e.label]},e.id),t[56]=a,t[57]=e),M=i.actions.map(e),t[53]=i.actions,t[54]=a,t[55]=M}else M=t[55];let N;t[58]===M?N=t[59]:(N=(0,Q.jsx)(`div`,{className:`flex flex-1 flex-wrap items-center justify-end gap-2`,children:M}),t[58]=M,t[59]=N);let P;t[60]!==j||t[61]!==N?(P=(0,Q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-4`,children:[j,N]}),t[60]=j,t[61]=N,t[62]=P):P=t[62];let F;t[63]!==k||t[64]!==A||t[65]!==P||t[66]!==x?(F=(0,Q.jsxs)(Ze,{className:`max-w-4xl gap-0 p-4 sm:p-5 bg-background border-[var(--interactive-border)]`,showCloseButton:!0,children:[x,k,A,P]}),t[63]=k,t[64]=A,t[65]=P,t[66]=x,t[67]=F):F=t[67];let I;return t[68]!==n||t[69]!==F||t[70]!==g?(I=(0,Q.jsx)(et,{open:n,onOpenChange:g,children:F}),t[68]=n,t[69]=F,t[70]=g,t[71]=I):I=t[71],I}function Cr(e,t){return br(e.version,t.version)}function wr(e){Xt(e)}var Tr=`https://github.com/yee94/yuri/releases`,Er=2e3,Dr=6e5,Or=e=>e.transport===n()&&e.generation===r();async function kr(e,t){try{if(!Or(t))return{success:!1};let n=await fr(t.transport,t.generation);return!Or(t)||!e||!n.supported||n.update?.version!==e||n.update.rollback?{success:!1}:(await hr(n,t.transport,t.generation),{success:!0,autoRestart:!0})}catch(e){return{success:!1,error:e instanceof Error?e.message:void 0}}}async function Ar(e,t,n=Math.ceil(Dr/Er),r=Er){for(let i=0;i<n;i++){if(!Or(t))return!1;try{let n=await pr(t.transport,t.generation);if(n.operation?.status===`failed`)return!1;if(n.currentVersion===e&&n.operation?.status===`succeeded`&&Or(t))return!0}catch{}await new Promise(e=>setTimeout(e,r))}return!1}var jr=e=>{let t=(0,Z.c)(108),{open:i,onOpenChange:a,info:o,downloading:s,downloaded:c,progress:l,error:u,onDownload:d,onRestart:f,runtimeType:p}=e,m=p===void 0?`desktop`:p,{t:h}=Ae(),[g,_]=(0,$.useState)(`idle`),[v,y]=(0,$.useState)(null),b=sr(Mr),x=o?.releaseUrl||(o?.version?`${Tr}/tag/v${o.version}`:Tr),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&&sr.getState().dismiss(),a(e)},t[0]=c,t[1]=E,t[2]=a,t[3]=A):A=t[3];let j=De(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,$.useEffect)(M,N);let P;t[7]!==o?.version||t[8]!==h?(P=async()=>{let e={transport:n(),generation:r()};_(`updating`),y(null);let t=await kr(o?.version,e);if(!Or(e))return;if(!t.success){_(`error`),y(t.error||h(`updateDialog.error.updateFailed`));return}t.autoRestart&&(_(`restarting`),await new Promise(Nr)),_(`reconnecting`);let i=await Ar(o?.version,e);Or(e)&&(i?window.location.reload():(_(`error`),y(h(`updateDialog.error.takingLonger`))))},t[7]=o?.version,t[8]=h,t[9]=P):P=t[9];let F=De(P),I;t[10]!==F||t[11]!==w||t[12]!==d||t[13]!==a||t[14]!==f||t[15]!==S||t[16]!==x||t[17]!==m?(I=e=>{bb107:switch(e){case`download`:d(),m===`desktop`&&a(!1);break bb107;case`restart`:f();break bb107;case`later`:sr.getState().dismiss(),a(!1);break bb107;case`open-external`:{let e=w?S:x;e&&Xt(e);break bb107}case`web-update`:F()}},t[10]=F,t[11]=w,t[12]=d,t[13]=a,t[14]=f,t[15]=S,t[16]=x,t[17]=m,t[18]=I):I=t[18];let L=De(I),R;if(t[19]!==c||t[20]!==s||t[21]!==E||t[22]!==D||t[23]!==w||t[24]!==C||t[25]!==O||t[26]!==T||t[27]!==h){if(R=[],!C&&(!w||E)){if(!D&&!c&&!s){let e;t[29]!==E||t[30]!==h?(e=h(E?`updateDialog.actions.applyOtaNow`:`updateDialog.actions.downloadUpdate`),t[29]=E,t[30]=h,t[31]=e):e=t[31];let n;t[32]===e?n=t[33]:(n={id:`download`,icon:`download`,label:e},t[32]=e,t[33]=n),R.push(n)}if(D&&!c&&!s){let e;t[34]===h?e=t[35]:(e=h(`updateDialog.actions.openMobileUpdate`),t[34]=h,t[35]=e);let n;t[36]===e?n=t[37]:(n={id:`open-external`,icon:`external-link`,label:e},t[36]=e,t[37]=n),R.push(n)}if(s){let e;t[38]===h?e=t[39]:(e=h(`updateDialog.status.downloading`),t[38]=h,t[39]=e);let n;t[40]===e?n=t[41]:(n={id:`downloading`,icon:`loader`,loading:!0,disabled:!0,label:e},t[40]=e,t[41]=n),R.push(n)}if(c){if(E){let e;t[42]===h?e=t[43]:(e=h(`updateDialog.actions.later`),t[42]=h,t[43]=e);let n;t[44]===e?n=t[45]:(n={id:`later`,variant:`ghost`,label:e},t[44]=e,t[45]=n),R.push(n)}let e;t[46]===h?e=t[47]:(e=h(`updateDialog.actions.restartToUpdate`),t[46]=h,t[47]=e);let n;t[48]===e?n=t[49]:(n={id:`restart`,icon:`restart`,label:e},t[48]=e,t[49]=n),R.push(n)}}if(w&&!E&&T){let e;t[50]===h?e=t[51]:(e=h(`updateDialog.actions.openMobileUpdate`),t[50]=h,t[51]=e);let n;t[52]===e?n=t[53]:(n={id:`open-external`,icon:`external-link`,label:e},t[52]=e,t[53]=n),R.push(n)}if(C){let e;t[54]!==O||t[55]!==h?(e=O?{id:`updating`,icon:`loader`,loading:!0,disabled:!0,label:h(`updateDialog.status.updating`)}:{id:`web-update`,icon:`download`,label:h(`updateDialog.actions.updateNow`)},t[54]=O,t[55]=h,t[56]=e):e=t[56],R.push(e)}t[19]=c,t[20]=s,t[21]=E,t[22]=D,t[23]=w,t[24]=C,t[25]=O,t[26]=T,t[27]=h,t[28]=R}else R=t[28];let z;t[57]!==h||t[58]!==g?(z=h(g===`restarting`||g===`reconnecting`?`updateDialog.header.updating`:`updateDialog.header.updateAvailable`),t[57]=h,t[58]=g,t[59]=z):z=t[59];let B=o?.currentVersion,V=o?.version,H=o?.body,U=!O,ee=u||v,te=C&&g===`error`?o?.updateCommand||`yuri update`:void 0,W;t[60]!==c||t[61]!==E||t[62]!==b||t[63]!==h?(W=E&&c&&b?h(`updateDialog.status.otaBundleReused`):void 0,t[60]=c,t[61]=E,t[62]=b,t[63]=h,t[64]=W):W=t[64];let G;t[65]!==w||t[66]!==k||t[67]!==T?(G=(!w||T)&&k?{url:k,label:`GitHub`}:void 0,t[65]=w,t[66]=k,t[67]=T,t[68]=G):G=t[68];let K;if(t[69]!==R||t[70]!==s||t[71]!==E||t[72]!==w||t[73]!==C||t[74]!==O||t[75]!==l||t[76]!==h||t[77]!==H||t[78]!==U||t[79]!==ee||t[80]!==te||t[81]!==W||t[82]!==G||t[83]!==z||t[84]!==B||t[85]!==V||t[86]!==g){if(K={title:z,currentVersion:B,version:V,body:H,hideChangelog:O,dismissible:U,error:ee,fallbackCommand:te,notice:W,releaseLink:G,actions:R},C&&O){let e;t[88]!==h||t[89]!==g?(e=h(g===`updating`?`updateDialog.status.installingUpdate`:g===`restarting`?`updateDialog.status.serverRestarting`:`updateDialog.status.waitingForServer`),t[88]=h,t[89]=g,t[90]=e):e=t[90];let n;t[91]===h?n=t[92]:(n=h(`updateDialog.status.autoReloadHint`),t[91]=h,t[92]=n);let r;t[93]!==e||t[94]!==n?(r={kind:`activity`,label:e,detail:n},t[93]=e,t[94]=n,t[95]=r):r=t[95],K.status=r}if(!C&&(!w||E)&&s){let e;t[96]===h?e=t[97]:(e=h(`updateDialog.status.downloadingPayload`),t[96]=h,t[97]=e);let n;t[98]===l?n=t[99]:(n=l?.total?Math.round(l.downloaded/l.total*100):0,t[98]=l,t[99]=n);let r;t[100]!==e||t[101]!==n?(r={kind:`download`,label:e,progress:n},t[100]=e,t[101]=n,t[102]=r):r=t[102],K.status=r}t[69]=R,t[70]=s,t[71]=E,t[72]=w,t[73]=C,t[74]=O,t[75]=l,t[76]=h,t[77]=H,t[78]=U,t[79]=ee,t[80]=te,t[81]=W,t[82]=G,t[83]=z,t[84]=B,t[85]=V,t[86]=g,t[87]=K}else K=t[87];let q;return t[103]!==L||t[104]!==j||t[105]!==K||t[106]!==i?(q=(0,Q.jsx)(Sr,{open:i,onOpenChange:j,model:K,onAction:L}),t[103]=L,t[104]=j,t[105]=K,t[106]=i,t[107]=q):q=t[107],q};function Mr(e){return e.otaDownloadSkipped}function Nr(e){return setTimeout(e,2e3)}var Pr=e(x(),1);function Fr(e){let t=(0,Z.c)(10),{children:n,actions:r,className:i}=e,a;t[0]===i?a=t[1]:(a=Y(`sticky top-0 z-10 flex shrink-0 items-center justify-between gap-3 bg-background py-3`,i),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,Q.jsx)(`div`,{className:`min-w-0 flex-1`,children:n}),t[2]=n,t[3]=o);let s;t[4]===r?s=t[5]:(s=(0,Q.jsx)(`div`,{className:`flex max-w-[70%] shrink-0 flex-wrap items-center justify-end gap-2 [&_button]:max-w-full [&_button]:whitespace-normal`,children:r}),t[4]=r,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,Q.jsxs)(`header`,{"data-settings-action-header":``,className:a,children:[o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function Ir(e){let t=(0,Z.c)(21),{label:n,actions:r,children:i,description:a,itemId:o,ariaLabel:s,className:c,cardClassName:l,cardId:u}=e,d=typeof n==`string`&&/^[\p{Script=Latin}\p{Number}\p{Punctuation}\p{Separator}]+$/u.test(n)?`latin`:void 0,f;t[0]===c?f=t[1]:(f=Y(`yuri-settings-group`,c),t[0]=c,t[1]=f);let p;t[2]!==r||t[3]!==n||t[4]!==d?(p=r?(0,Q.jsx)(Fr,{actions:r,children:n?(0,Q.jsx)(`div`,{className:`yuri-settings-group-label`,"data-settings-label-script":d,children:n}):null}):n?(0,Q.jsx)(`div`,{className:`yuri-settings-group-label`,"data-settings-label-script":d,children:n}):null,t[2]=r,t[3]=n,t[4]=d,t[5]=p):p=t[5];let m;t[6]===l?m=t[7]:(m=Y(`yuri-settings-group-card`,l),t[6]=l,t[7]=m);let h;t[8]!==u||t[9]!==i||t[10]!==o||t[11]!==m?(h=(0,Q.jsx)(`div`,{id:u,"data-settings-item":o,className:m,children:i}),t[8]=u,t[9]=i,t[10]=o,t[11]=m,t[12]=h):h=t[12];let g;t[13]===a?g=t[14]:(g=a?(0,Q.jsx)(`p`,{className:`yuri-settings-group-description text-muted-foreground`,children:a}):null,t[13]=a,t[14]=g);let _;return t[15]!==s||t[16]!==f||t[17]!==p||t[18]!==h||t[19]!==g?(_=(0,Q.jsxs)(`section`,{className:f,"aria-label":s,children:[p,h,g]}),t[15]=s,t[16]=f,t[17]=p,t[18]=h,t[19]=g,t[20]=_):_=t[20],_}function Lr(e){let t=(0,Z.c)(20),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({label:s,description:a,descriptionPlacement:l,ariaLabel:n,groupClassName:o,cardClassName:r,children:i,...c}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u=l===void 0?`inside`:l,d=u===`outside`?a:void 0,f=u===`inside`?a:void 0,p;t[9]!==i||t[10]!==s||t[11]!==c||t[12]!==f?(p=(0,Q.jsx)(Rr,{label:s,description:f,...c,children:i}),t[9]=i,t[10]=s,t[11]=c,t[12]=f,t[13]=p):p=t[13];let m;return t[14]!==n||t[15]!==r||t[16]!==o||t[17]!==d||t[18]!==p?(m=(0,Q.jsx)(Ir,{ariaLabel:n,className:o,cardClassName:r,description:d,children:p}),t[14]=n,t[15]=r,t[16]=o,t[17]=d,t[18]=p,t[19]=m):m=t[19],m}function Rr(e){let t=(0,Z.c)(22),{label:n,children:r,description:i,itemId:a,className:o,copyClassName:s,controlClassName:c}=e,l;t[0]===o?l=t[1]:(l=Y(`yuri-settings-group-row yuri-settings-split-row`,o),t[0]=o,t[1]=l);let u;t[2]===s?u=t[3]:(u=Y(`yuri-settings-split-row-copy`,s),t[2]=s,t[3]=u);let d;t[4]===n?d=t[5]:(d=n?(0,Q.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:n}):null,t[4]=n,t[5]=d);let f;t[6]===i?f=t[7]:(f=i?(0,Q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:i}):null,t[6]=i,t[7]=f);let p;t[8]!==u||t[9]!==d||t[10]!==f?(p=(0,Q.jsxs)(`div`,{className:u,children:[d,f]}),t[8]=u,t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===c?m=t[13]:(m=Y(`yuri-settings-split-row-control`,c),t[12]=c,t[13]=m);let h;t[14]!==r||t[15]!==m?(h=(0,Q.jsx)(`div`,{"data-settings-value":``,className:m,children:r}),t[14]=r,t[15]=m,t[16]=h):h=t[16];let g;return t[17]!==a||t[18]!==l||t[19]!==p||t[20]!==h?(g=(0,Q.jsxs)(`div`,{"data-settings-item":a,className:l,children:[p,h]}),t[17]=a,t[18]=l,t[19]=p,t[20]=h,t[21]=g):g=t[21],g}function zr(e){let t=(0,Z.c)(32),{checked:n,onChange:r,label:i,ariaLabel:a,description:o,itemId:s,disabled:c,className:l}=e,u=c!==void 0&&c,d;t[0]!==n||t[1]!==u||t[2]!==r?(d=()=>{u||r(!n)},t[0]=n,t[1]=u,t[2]=r,t[3]=d):d=t[3];let f=d,p=Br,m=u?`cursor-not-allowed`:`cursor-pointer`,h;t[4]!==l||t[5]!==m?(h=Y(`yuri-settings-group-row yuri-settings-split-row group`,m,l),t[4]=l,t[5]=m,t[6]=h):h=t[6];let g=u?-1:0,_=u||void 0,v,y;t[7]===f?(v=t[8],y=t[9]):(v=e=>{p(e.target)||f()},y=e=>{p(e.target)||(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),f())},t[7]=f,t[8]=v,t[9]=y);let b;t[10]===i?b=t[11]:(b=(0,Q.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i}),t[10]=i,t[11]=b);let x;t[12]===o?x=t[13]:(x=o?(0,Q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:o}):null,t[12]=o,t[13]=x);let S;t[14]!==x||t[15]!==b?(S=(0,Q.jsxs)(`div`,{className:`yuri-settings-split-row-copy`,children:[b,x]}),t[14]=x,t[15]=b,t[16]=S):S=t[16];let C;t[17]!==a||t[18]!==n||t[19]!==u||t[20]!==r?(C=(0,Q.jsx)(`div`,{"data-settings-value":``,className:`yuri-settings-split-row-control`,children:(0,Q.jsx)(ct,{checked:n,onChange:r,disabled:u,ariaLabel:a})}),t[17]=a,t[18]=n,t[19]=u,t[20]=r,t[21]=C):C=t[21];let w;return t[22]!==n||t[23]!==s||t[24]!==S||t[25]!==C||t[26]!==h||t[27]!==g||t[28]!==_||t[29]!==v||t[30]!==y?(w=(0,Q.jsxs)(`div`,{"data-settings-item":s,className:h,role:`button`,tabIndex:g,"aria-pressed":n,"aria-disabled":_,onClick:v,onKeyDown:y,children:[S,C]}),t[22]=n,t[23]=s,t[24]=S,t[25]=C,t[26]=h,t[27]=g,t[28]=_,t[29]=v,t[30]=y,t[31]=w):w=t[31],w}function Br(e){return e instanceof HTMLElement&&e.closest(`button, a, input, select, textarea`)!==null}function Vr(e,t,n){let r=e?.operation,i=e?.update,a=cr(r),o=e?.supported===!1||t.failure===`unsupported`,s={title:n(`settings.yuri.about.hostUpdate.title`),description:n(`settings.yuri.about.hostUpdate.description`),currentVersion:e?.currentVersion??t.versionFallback,version:i?.version??r?.version,methodLabel:i?n(`settings.yuri.about.hostUpdate.kind.${i.kind}`):void 0,body:i?i.releaseNotes||n(`settings.yuri.about.hostUpdate.noNotes`):void 0,warning:!a&&i?.rollback?n(`settings.yuri.about.hostUpdate.downgrade`):void 0,actions:[{id:`check`,variant:`ghost`,label:n(`settings.yuri.about.actions.checkForUpdates`),disabled:!!t.checking},{id:`confirm`,icon:a||t.submitting?`loader`:`download`,loading:a||t.submitting,label:n(`settings.yuri.about.hostUpdate.confirm`),disabled:!i||!e?.supported||a||t.submitting||!!t.failure||!!t.checking}]};return a&&r?s.status={kind:r.status===`downloading`?`download`:`activity`,label:n(`settings.yuri.about.hostUpdate.status.${r.status}`),progress:r.progress,detail:t.failure===`disconnected`?n(`settings.yuri.about.hostUpdate.reconnecting`):void 0}:t.checking===`initial`||t.submitting?s.status={kind:`activity`,label:n(`settings.yuri.about.state.checking`)}:o?s.message=n(`settings.yuri.about.hostUpdate.unsupported`):t.failure?s.error=n(t.failure===`disconnected`?`settings.yuri.about.hostUpdate.reconnecting`:`settings.yuri.about.toast.checkFailed`):!i&&e?.supported&&(s.message=r?.status===`succeeded`?n(`settings.yuri.about.hostUpdate.status.succeeded`):n(`settings.yuri.about.toast.latestVersion`)),r?.status===`failed`&&(s.error=n(`settings.yuri.about.hostUpdate.status.failed`)),s}function Hr(){let e=(0,Z.c)(7),{t:i}=Ae(),a=$.useSyncExternalStore(t,n,n),o=$.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,Q.jsx)(Ur,{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 Ur(e){let t=(0,Z.c)(58),{version:i,transport:a,generation:o,itemId:s,channel:c}=e,{t:l}=Ae(),u=N(),[d,f]=$.useState(!1),p=O(Wr),m=c??p??void 0,h=mr(a,o,m),g=h.data,_=g?.operation,v;t[0]===_?v=t[1]:(v=cr(_),t[0]=_,t[1]=v);let y=v,b;t[2]!==o||t[3]!==a?(b=e=>{let{plan:t}=e;return hr(t,a,o)},t[2]=o,t[3]=a,t[4]=b):b=t[4];let x,S;t[5]!==u||t[6]!==o||t[7]!==a?(x=(e,t)=>{a===n()&&o===r()&&u.setQueryData(ur(a,o,t.channel).queryKey,t=>t&&{...t,operation:e})},S=(e,t,i)=>{a===n()&&o===r()&&u.invalidateQueries({queryKey:ur(a,o,i.channel).queryKey,exact:!0})},t[5]=u,t[6]=o,t[7]=a,t[8]=x,t[9]=S):(x=t[8],S=t[9]);let C;t[10]!==b||t[11]!==x||t[12]!==S?(C={mutationFn:b,onSuccess:x,onSettled:S},t[10]=b,t[11]=x,t[12]=S,t[13]=C):C=t[13];let w=P(C),T;t[14]===h?T=t[15]:(T=()=>{f(!0),h.refetch()},t[14]=h,t[15]=T);let E=De(T),D=g?.supported===!1||h.error?.message===`host_update_unsupported`,k=h.isError||!!g?.checkError,A=w.isError&&w.variables?.channel===m,j=h.isPending?`initial`:h.isFetching?`refresh`:!1,M=D?`unsupported`:h.isError&&(y||A)?`disconnected`:k||A?`check`:null,F;t[16]!==w.isPending||t[17]!==g||t[18]!==l||t[19]!==j||t[20]!==M||t[21]!==i?(F=Vr(g,{versionFallback:i,checking:j,submitting:w.isPending,failure:M},l),t[16]=w.isPending,t[17]=g,t[18]=l,t[19]=j,t[20]=M,t[21]=i,t[22]=F):F=t[22];let I=F,L;t[23]!==m||t[24]!==w||t[25]!==h||t[26]!==g?(L=e=>{e===`check`&&h.refetch(),e===`confirm`&&g?.update&&w.mutate({plan:g,channel:m})},t[23]=m,t[24]=w,t[25]=h,t[26]=g,t[27]=L):L=t[27];let R=De(L),z=g?.currentVersion??i,B;t[28]!==y||t[29]!==g?.update||t[30]!==l?(B=g?.update&&!y&&(0,Q.jsx)(`span`,{"aria-label":l(`settings.yuri.about.hostUpdate.available`),className:`absolute -right-1.5 -top-0.5 size-1.5 rounded-full bg-[var(--status-error)]`}),t[28]=y,t[29]=g?.update,t[30]=l,t[31]=B):B=t[31];let V;t[32]!==z||t[33]!==B?(V=(0,Q.jsxs)(`span`,{className:`relative typography-ui-label font-mono text-foreground text-right`,children:[z,B]}),t[32]=z,t[33]=B,t[34]=V):V=t[34];let H;t[35]===l?H=t[36]:(H=l(`settings.yuri.about.hostUpdate.title`),t[35]=l,t[36]=H);let U;t[37]===l?U=t[38]:(U=l(`settings.yuri.about.hostUpdate.title`),t[37]=l,t[38]=U);let ee=y||h.isFetching?`loader`:g?.update?`download`:`refresh`,te=y||h.isFetching?`size-4 animate-spin`:`size-4`,W;t[39]!==ee||t[40]!==te?(W=(0,Q.jsx)(X,{name:ee,className:te}),t[39]=ee,t[40]=te,t[41]=W):W=t[41];let G;t[42]!==E||t[43]!==H||t[44]!==U||t[45]!==W?(G=(0,Q.jsx)(Me,{type:`button`,size:`icon`,variant:`ghost`,onClick:E,"aria-label":H,title:U,children:W}),t[42]=E,t[43]=H,t[44]=U,t[45]=W,t[46]=G):G=t[46];let K;t[47]!==s||t[48]!==V||t[49]!==G?(K=(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,"data-settings-item":s,children:[V,G]}),t[47]=s,t[48]=V,t[49]=G,t[50]=K):K=t[50];let q;t[51]!==R||t[52]!==I||t[53]!==d?(q=(0,Q.jsx)(Sr,{open:d,onOpenChange:f,model:I,onAction:R}),t[51]=R,t[52]=I,t[53]=d,t[54]=q):q=t[54];let ne;return t[55]!==K||t[56]!==q?(ne=(0,Q.jsxs)(Q.Fragment,{children:[K,q]}),t[55]=K,t[56]=q,t[57]=ne):ne=t[57],ne}function Wr(e){return e.otaChannelOverride}var Gr=`/mcp/oauth/callback`,Kr=e=>{if(typeof window>`u`)return null;try{let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t.length%4==0?``:`=`.repeat(4-t.length%4),r=window.atob(t+n),i=Uint8Array.from(r,e=>e.charCodeAt(0));return new TextDecoder().decode(i)}catch{return null}},qr=e=>{let t=Yr(e.get(`state`));if(t)return t;let n=e.get(`server`);if(typeof n!=`string`||!n.trim())return null;let r=e.get(`directory`);return{name:n.trim(),directory:typeof r==`string`&&r.trim()?r.trim():null}},Jr=e=>{let t=e.get(`state`);return typeof t==`string`&&t.trim()||null},Yr=e=>{if(typeof e!=`string`||!e.trim())return null;let t=Kr(e.trim());if(!t)return null;try{let e=JSON.parse(t);return e?.v!==1||typeof e.n!=`string`||!e.n.trim()?null:{name:e.n.trim(),directory:typeof e.d==`string`&&e.d.trim()?e.d.trim():null}}catch{return null}},Xr=e=>typeof e==`object`&&!!e&&`updateStatus`in e&&typeof e.updateStatus==`function`,Zr=e=>{let t=document.createElement(`div`);t.className=`cm-vim-panel`;let n=gn(e);if(!n)return{top:!1,dom:t};n.state.statusbar=t;let r=n.state.vimPlugin;return Xr(r)&&r.updateStatus(),{top:!1,dom:t,destroy(){n.state.statusbar===t&&(n.state.statusbar=null)}}};function Qr(e){return e?[hn(),te.of(Zr),K()]:[]}var $r={next:`Next match`,prev:`Previous match`,select:`Select all matches`,replace:`Replace`,replaceAll:`Replace all`,close:`Close`},ei={case:`Match case`,re:`Regular expression`,word:`Match whole word`};function ti(e){let t=e.querySelector(`.cm-search`);if(t){for(let[e,n]of Object.entries($r)){let r=t.querySelector(`button[name="${e}"]`);r&&!r.title&&(r.title=n)}for(let[e,n]of Object.entries(ei)){let r=t.querySelector(`input[name="${e}"]`)?.parentElement;r&&!r.title&&(r.title=n)}}}var ni=new WeakMap;function ri(e,t){let n=dn(e.state);if(!n.valid)return ni.delete(e),0;let r=ni.get(e);if(!t&&r?.doc===e.state.doc&&r.query.eq(n))return r.total;let i=n.getCursor(e.state),a=0;for(let e=i.next();!e.done;e=i.next())a+=1;return ni.set(e,{query:n,doc:e.state.doc,total:a}),a}function ii(e){let t=dn(e.state);if(!t.valid)return 0;let n=e.state.selection.main,r=t.getCursor(e.state),i=0,a=0;for(let e=r.next();!e.done;e=r.next()){let t=e.value;if(i+=1,a===0&&(a=i),n.from===t.from&&n.to===t.to||n.from<t.to&&n.to>t.from||t.from>=n.head)return i}return a}function ai(e,t,n=!1){let r=e.querySelector(`.cm-search`);if(!r)return;let i=r.querySelector(`.cm-search-message`);if(!i){i=document.createElement(`span`),i.className=`cm-search-message`,i.setAttribute(`aria-live`,`polite`);let e=r.querySelector(`button[name="next"]`),t=e?.parentNode===r?e:r.firstChild;r.insertBefore(i,t)}let a=ri(t,n),o=a===0?0:ii(t);i.textContent=a===0?``:`${o}/${a}`}var oi=new de,si=new de,ci=new de,li=new de,ui=new de,di=new de,fi=new de,pi=e=>e,mi=ae,hi=ln,gi=pn,_i=class extends se{id;containerMap;constructor(e,t){super(),this.id=e,this.containerMap=t}toDOM(){let e=this.containerMap.get(this.id);return e||(e=document.createElement(`div`),e.className=`yuri-block-widget`,e.dataset.widgetId=this.id,this.containerMap.set(this.id,e)),e}eq(e){return e.id===this.id}destroy(){}},vi=(e,t)=>!e||e.length===0?[]:_e.define({create(n){let r=new fe,i=[...e].sort((e,t)=>e.afterLine-t.afterLine);for(let e of i){let i=n.doc.lines;if(e.afterLine>i)continue;let a=n.doc.line(e.afterLine);r.add(a.to,a.to,G.widget({widget:new _i(e.id,t),block:!0,side:1}))}return r.finish()},update(e,t){return e.map(t.changes)},provide:e=>q.decorations.from(e)}),yi=e=>{if(!e)return[];let t=Math.max(1,e.start),n=Math.max(t,e.end);return oe.fromClass(class{decorations;constructor(e){this.decorations=this.build(e)}update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=this.build(e.view))}build(e){let r=new fe;for(let i=t;i<=n&&i<=e.state.doc.lines;i+=1){let t=e.state.doc.line(i);r.add(t.from,t.from,G.line({class:`yuri-cm-selected-line`}))}return r.finish()}},{decorations:e=>e.decorations})};function bi({value:e,onChange:t,extensions:n,className:r,readOnly:i,lineNumbersConfig:a,highlightLines:o,onViewReady:s,onViewDestroy:c,blockWidgets:l,enableSearch:u,searchOpen:d,onSearchOpenChange:f,vimMode:p}){let m=$.useRef(null),h=$.useRef(null),g=$.useRef(e),_=$.useRef(t),v=$.useRef(s),y=$.useRef(c),b=$.useRef(f),x=$.useRef(l),S=$.useRef(p),C=$.useRef(new Map),[w,T]=$.useState([]),E=$.useCallback(e=>{let t=(e??[]).map(e=>{let t=C.current.get(e.id);return t?{id:e.id,content:e.content,container:t}:null}).filter(e=>e!==null);T(e=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return e.id===r.id&&e.content===r.content&&e.container===r.container})?e:t)},[]),D=$.useCallback(e=>{let t=m.current,n=e??h.current;if(!t||!n)return;let r=n.dom.querySelector(`.cm-gutters`),i=r instanceof HTMLElement?r.getBoundingClientRect().width:0;t.style.setProperty(`--yuri-editor-gutter-width`,`${i}px`)},[]);return $.useEffect(()=>{g.current=e},[e]),$.useEffect(()=>{_.current=t},[t]),$.useEffect(()=>{v.current=s,y.current=c},[s,c]),$.useEffect(()=>{b.current=f},[f]),$.useEffect(()=>{x.current=l,E(l)},[l,E]),$.useEffect(()=>{if(!m.current)return;let e=(()=>{if(typeof document>`u`)return null;let e=document.querySelector(`meta[name="csp-nonce"]`)?.getAttribute(`content`);if(e)return e;let t=window.__YURI_CSP_NONCE__;return typeof t==`string`&&t.length>0?t:null})(),t=ve.create({doc:g.current,extensions:[...e?[q.cspNonce.of(e)]:[],ne({fixed:!0}),oi.of(ce(a)),sn(),W.of(` `),fi.of(Qr(p)),le.of([on,...an,...cn]),q.updateListener.of(e=>{D(e.view),(e.viewportChanged||e.geometryChanged)&&E(x.current);let t=un(e.startState),n=un(e.state);t!==n&&b.current?.(n);let r=!dn(e.startState).eq(dn(e.state));if(n&&(t!==n||r||e.docChanged||e.selectionSet)&&ai(e.view.dom,e.view,t!==n||r||e.docChanged),!e.docChanged)return;let i=e.state.doc.toString();g.current=i,_.current(i),E(x.current)}),si.of(q.editable.of(!i)),ci.of(n??[]),li.of(yi(o)),ui.of(vi(l,C.current)),di.of(u?[fn({top:!0}),le.of(pi(mn))]:[])]});return h.current=new q({state:t,parent:m.current}),mi(h.current,h.current.state.doc.length,200),h.current.requestMeasure(),requestAnimationFrame(()=>{D(h.current),E(x.current)}),h.current&&v.current?.(h.current),()=>{y.current?.(),h.current?.destroy(),h.current=null,T([])}},[x,D,E]),$.useEffect(()=>{let e=h.current;e&&(e.dispatch({effects:[oi.reconfigure(ce(a)),si.reconfigure(q.editable.of(!i)),ci.reconfigure(n??[]),li.reconfigure(yi(o)),ui.reconfigure(vi(l,C.current)),di.reconfigure(u?[fn({top:!0}),le.of(pi(mn))]:[])]}),mi(e,e.state.doc.length,200),e.requestMeasure(),requestAnimationFrame(()=>{D(e),E(x.current)}))},[n,o,a,i,l,u,D,E]),$.useEffect(()=>{let e=h.current;if(!e){S.current=p;return}S.current!==p&&(S.current=p,e.dispatch({effects:fi.reconfigure(Qr(p))}))},[p]),$.useEffect(()=>{let e=h.current;!e||u===!1||(d?(hi(e),requestAnimationFrame(()=>{ti(e.dom),ai(e.dom,e,!0)})):gi(e))},[d,u]),$.useEffect(()=>{let t=h.current;if(!t)return;let n=t.state.doc.toString();n!==e&&(t.dispatch({changes:{from:0,to:n.length,insert:e}}),mi(t,t.state.doc.length,300),t.requestMeasure(),requestAnimationFrame(()=>D(t)))},[e,D]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{ref:m,className:Y(`h-full w-full`,`[&_.cm-editor]:h-full [&_.cm-editor]:w-full`,`[&_.cm-scroller]:font-mono [&_.cm-scroller]:text-[var(--text-code)] [&_.cm-scroller]:leading-6`,`[&_.cm-lineNumbers]:text-[var(--tools-edit-line-number)]`,r)}),w.map(e=>(0,Pr.createPortal)(e.content,e.container,e.id))]})}var xi=pe.define(Ee),Si=Ce.data.of({commentTokens:{line:`//`,block:{open:`/*`,close:`*/`}}});function Ci(e){let t=e.trim().toLowerCase();switch(t){case`bash`:case`sh`:case`zsh`:case`shell`:case`shellsession`:case`console`:return xi;case`json`:case`jsonc`:case`json5`:return Se().language;case`js`:case`javascript`:return be().language;case`jsx`:return be({jsx:!0}).language;case`ts`:case`typescript`:return be({typescript:!0}).language;case`tsx`:return be({typescript:!0,jsx:!0}).language;case`html`:return xe().language;case`css`:return ye().language;case`py`:case`python`:return Te().language;case`md`:case`markdown`:case`mdown`:case`mkd`:return we().language;case`heex`:case`eex`:case`leex`:return xe().language;default:return ge.matchLanguageName(_n,t,!0)}}var wi=e=>e.split(`/`).pop()?.toLowerCase()??``,Ti=e=>{let t=wi(e);return t?ge.matchFilename(_n,t):null},Ei=()=>ie(ue.define([{tag:[J.heading1,J.heading2,J.heading3,J.heading4,J.heading5,J.heading6],fontWeight:`600`},{tag:J.strong,fontWeight:`600`},{tag:J.emphasis,fontStyle:`italic`},{tag:J.strikethrough,textDecoration:`line-through`},{tag:[J.link,J.url],color:`var(--markdown-link, currentColor)`,textDecoration:`underline`},{tag:J.monospace,color:`var(--markdown-inline-code, currentColor)`,backgroundColor:`var(--markdown-inline-code-bg, transparent)`},{tag:J.quote,color:`var(--markdown-blockquote, currentColor)`,fontStyle:`italic`},{tag:J.list,color:`color-mix(in srgb, var(--muted-foreground) 40%, var(--foreground) 60%)`},{tag:J.heading,color:`var(--markdown-heading1, currentColor)`}]));function Di(e){let t=e.toLowerCase();switch(wi(t)){case`makefile`:case`gnumakefile`:return xi}let n=t.lastIndexOf(`.`),r=n>=0?t.slice(n+1):``;switch(r){case`ts`:case`tsx`:case`mts`:case`cts`:return be({typescript:!0,jsx:r===`tsx`});case`js`:case`jsx`:case`mjs`:case`cjs`:return be({typescript:!1,jsx:r===`jsx`});case`jsonc`:case`json5`:return[Se(),Si];case`json`:case`jsonl`:case`ndjson`:case`geojson`:return Se();case`css`:case`scss`:case`sass`:case`less`:return ye();case`html`:case`htm`:case`xml`:case`drawio`:case`dio`:return xe();case`md`:case`mdx`:case`markdown`:case`mdown`:case`mkd`:return[we({codeLanguages:Ci}),Ei()];case`sh`:case`bash`:case`zsh`:case`fish`:case`env`:return xi;case`py`:case`pyw`:case`pyi`:return Te();default:return null}}async function Oi(e){let t=Ti(e);if(!t)return null;if(t.support)return t.support;try{return await t.load()}catch{return null}}function ki(e,t){let n=e.metadata.variant===`dark`,r=e.config?.fonts?.mono||`monospace`,i=e.colors.syntax.highlights||{},a=e.colors.syntax.tokens||{},o=t?.fontSize?`${t.fontSize}px`:`var(--text-code)`,s=q.theme({"&":{backgroundColor:`var(--background)`,color:e.colors.syntax.base.foreground,fontSize:o,lineHeight:`1.5`,position:`relative`},".cm-scroller":{fontFamily:r,backgroundColor:`var(--background)`},".cm-comment":{color:e.colors.syntax.base.comment},".cm-keyword":{color:e.colors.syntax.base.keyword},".cm-string":{color:e.colors.syntax.base.string},".cm-string-2":{color:a.stringEscape||e.colors.syntax.base.string},".cm-number":{color:e.colors.syntax.base.number},".cm-operator":{color:e.colors.syntax.base.operator},".cm-punctuation":{color:a.punctuation||e.colors.syntax.base.comment},".cm-atom":{color:a.boolean||e.colors.syntax.base.number},".cm-builtin":{color:a.functionCall||e.colors.syntax.base.function},".cm-def":{color:a.variableGlobal||e.colors.syntax.base.variable},".cm-attribute":{color:a.variableOther||a.variableProperty||e.colors.syntax.base.operator},".cm-meta":{color:e.colors.syntax.base.comment},".cm-property":{color:a.variableProperty||e.colors.syntax.base.keyword},".cm-variable":{color:e.colors.syntax.base.variable},".cm-variable-2":{color:a.variableOther||e.colors.syntax.base.function},".cm-variable-3":{color:a.variableGlobal||e.colors.syntax.base.type},".cm-tag":{color:a.tag||e.colors.syntax.base.keyword},".cm-link":{color:a.url||e.colors.syntax.base.keyword,textDecoration:`underline`},".cm-content":{caretColor:e.colors.interactive.cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:e.colors.interactive.cursor},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e.colors.interactive.selection},".cm-gutters":{backgroundColor:`var(--background)`,color:i.lineNumber||e.colors.syntax.base.comment,borderRight:`1px solid ${e.colors.interactive.border}`,position:`sticky`,paddingRight:`8px`,left:0,zIndex:2,boxShadow:`0 0 0 var(--background)`},".cm-gutter":{backgroundColor:`var(--background)`},".cm-gutterElement":{backgroundColor:`var(--background)`},".cm-lineNumbers":{backgroundColor:`var(--background)`},".cm-lineNumbers .cm-gutterElement":{paddingLeft:`8px`,paddingRight:`8px`,minWidth:`42px`},".cm-activeLineGutter":{color:i.lineNumberActive||e.colors.syntax.base.foreground},".cm-activeLine":{backgroundColor:e.colors.surface.overlay},".cm-panels":{backgroundColor:`transparent`,color:e.colors.surface.foreground,position:`absolute`,top:`0`,right:`0`,left:`auto`,width:`auto`,zIndex:10,pointerEvents:`none`},".cm-panels-top":{borderBottom:`none`,position:`absolute`,top:`6px`,right:`14px`,left:`auto`,width:`auto`},".cm-panels-bottom":{position:`static`,width:`100%`,pointerEvents:`auto`},".cm-panels-bottom .cm-vim-panel":{borderTop:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.elevated,color:e.colors.surface.mutedForeground,fontFamily:`var(--font-mono)`,fontSize:`12px`,minHeight:`22px`,padding:`2px 8px`},".cm-panel.cm-search":{pointerEvents:`auto`,padding:`4px`,backgroundColor:`color-mix(in srgb, ${e.colors.surface.elevated} 85%, transparent)`,border:`1px solid ${e.colors.interactive.border}`,borderRadius:`10px`,boxShadow:`0 2px 8px color-mix(in srgb, ${e.colors.surface.background} 60%, transparent)`,width:`auto`,minWidth:`360px`,maxWidth:`480px`},".cm-search":{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:`0`,width:`100%`,color:e.colors.surface.foreground,fontFamily:`inherit`,fontSize:`13px`,lineHeight:`1`},".cm-search br":{display:`none`},".cm-search .cm-textfield":{appearance:`none`,height:`26px`,margin:0,padding:`0 8px`,borderRadius:`6px !important`,border:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.background,color:e.colors.surface.foreground,fontFamily:`inherit`,fontSize:`12px`,lineHeight:`1`,outline:`none`,transition:`border-color 150ms ease`},".cm-search .cm-textfield::placeholder":{color:e.colors.surface.mutedForeground,opacity:1},".cm-search .cm-textfield:focus":{borderColor:e.colors.primary.base},'.cm-search .cm-textfield[name="search"]':{order:1,flex:`1 1 120px`,maxWidth:`calc(100% - 142px)`,minWidth:`100px`},".cm-search label":{order:2,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:0,marginLeft:`1px`,padding:0,borderRadius:`4px`,border:`1px solid transparent`,backgroundColor:`transparent`,color:`transparent`,cursor:`pointer`,userSelect:`none`,fontSize:`1px`,lineHeight:`0`,overflow:`hidden`,position:`relative`,transition:`background-color 120ms ease, border-color 120ms ease`},".cm-search label:hover":{backgroundColor:e.colors.interactive.hover},'.cm-search label:has(input[type="checkbox"]:checked)':{backgroundColor:e.colors.interactive.hover,borderColor:e.colors.interactive.border},'.cm-search [type="checkbox"]':{appearance:`none`,WebkitAppearance:`none`,width:`0`,height:`0`,margin:`0`,padding:`0`,border:`none`,position:`absolute`,opacity:`0`,pointerEvents:`none`},".cm-search label::after":{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,fontSize:`13px`,fontWeight:`600`,lineHeight:`1`,fontFamily:`inherit`,color:e.colors.surface.mutedForeground,pointerEvents:`none`},".cm-search label:hover::after":{color:e.colors.surface.foreground},'.cm-search label:has(input[type="checkbox"]:checked)::after':{color:e.colors.surface.foreground},'.cm-search label:has(input[name="case"])::after':{content:`"Aa"`,fontSize:`12px`,letterSpacing:`-0.5px`},'.cm-search label:has(input[name="re"])::after':{content:`".*"`,fontSize:`13px`,fontFamily:`monospace`},'.cm-search label:has(input[name="word"])::after':{content:`"ab"`,fontSize:`12px`,textDecoration:`underline`,textUnderlineOffset:`2px`},".cm-search .cm-search-message":{order:3,color:e.colors.surface.mutedForeground,backgroundColor:`transparent`,border:`none`,borderRadius:`0`,padding:`0 6px`,fontSize:`11px`,whiteSpace:`nowrap`,lineHeight:`26px`},".cm-search .cm-button":{appearance:`none`,WebkitAppearance:`none`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:0,marginLeft:`1px`,padding:0,borderRadius:`4px`,border:`none`,backgroundColor:`transparent`,backgroundImage:`none`,color:`transparent`,cursor:`pointer`,fontSize:`1px`,fontWeight:`400`,lineHeight:`0`,overflow:`hidden`,position:`relative`,boxShadow:`none`,transition:`background-color 120ms ease`},".cm-search .cm-button::after":{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,fontSize:`15px`,lineHeight:`1`,color:e.colors.surface.mutedForeground,pointerEvents:`none`},".cm-search .cm-button:hover":{backgroundColor:e.colors.interactive.hover},".cm-search .cm-button:hover::after":{color:e.colors.surface.foreground},".cm-search .cm-button:active":{backgroundColor:e.colors.interactive.active},".cm-search .cm-button:focus-visible":{outline:`none`,boxShadow:`0 0 0 1px ${e.colors.interactive.focusRing}`},".cm-search .cm-button:disabled":{opacity:.4,cursor:`default`,pointerEvents:`none`},'.cm-search .cm-button[name="prev"]':{order:21,marginTop:`2px`},'.cm-search .cm-button[name="prev"]::after':{content:`"↑"`},'.cm-search .cm-button[name="next"]':{order:22,marginTop:`2px`},'.cm-search .cm-button[name="next"]::after':{content:`"↓"`},'.cm-search .cm-button[name="select"]':{order:23,marginTop:`2px`},'.cm-search .cm-button[name="select"]::after':{content:`"≡"`,fontSize:`17px`},'.cm-panel.cm-search button[name="close"]':{order:5,appearance:`none`,WebkitAppearance:`none`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:`0 0 0 auto`,padding:`0`,borderRadius:`4px`,border:`none`,backgroundColor:`transparent`,backgroundImage:`none`,color:e.colors.surface.mutedForeground,cursor:`pointer`,fontSize:`16px`,lineHeight:`1`,boxShadow:`none`,position:`relative`,overflow:`visible`,transition:`background-color 120ms ease, color 120ms ease`},'.cm-panel.cm-search button[name="close"]:hover':{backgroundColor:e.colors.interactive.hover,color:e.colors.surface.foreground},'.cm-search .cm-button[name="replace"]':{order:24,marginTop:`2px`},'.cm-search .cm-button[name="replace"]::after':{content:`"⇄"`},'.cm-search .cm-button[name="replaceAll"], .cm-search .cm-button[name="replace-all"]':{order:25,marginTop:`2px`},'.cm-search .cm-button[name="replaceAll"]::after, .cm-search .cm-button[name="replace-all"]::after':{content:`"⇉"`},'.cm-search .cm-textfield[name="replace"]':{order:20,flex:`1 1 100%`,maxWidth:`calc(100% - 142px)`,minWidth:`80px`,marginTop:`2px`},".cm-searchMatch":{backgroundColor:e.colors.status.infoBackground,boxShadow:`inset 0 0 0 1px ${e.colors.status.infoBorder}`,borderRadius:`2px`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:e.colors.interactive.selection,color:e.colors.interactive.selectionForeground,boxShadow:`inset 0 0 0 1px ${e.colors.interactive.borderFocus}`},"&.cm-focused":{outline:`none`}},{dark:n}),c=ue.define([{tag:[J.comment,J.docComment,J.meta,J.documentMeta],class:`cm-comment`},{tag:[J.keyword,J.controlKeyword,J.moduleKeyword,J.definitionKeyword,J.modifier],class:`cm-keyword`},{tag:[J.operatorKeyword,J.operator,J.derefOperator,J.updateOperator,J.definitionOperator,J.typeOperator,J.controlOperator,J.logicOperator,J.bitwiseOperator,J.arithmeticOperator,J.compareOperator],class:`cm-operator`},{tag:[J.punctuation,J.separator,J.bracket,J.paren,J.brace,J.squareBracket,J.angleBracket],class:`cm-punctuation`},{tag:[J.string,J.regexp,J.attributeValue,J.special(J.string),J.monospace],class:`cm-string`},{tag:J.escape,class:`cm-string-2`},{tag:[J.number,J.bool,J.atom,J.null,J.self],class:`cm-number`},{tag:[J.function(J.variableName),J.function(J.definition(J.variableName)),J.function(J.propertyName),J.standard(J.variableName),J.special(J.variableName)],class:`cm-builtin`},{tag:J.definition(J.variableName),class:`cm-def`},{tag:[J.variableName,J.local(J.variableName),J.constant(J.variableName),J.literal],class:`cm-variable`},{tag:J.propertyName,class:`cm-property`},{tag:J.attributeName,class:`cm-attribute`},{tag:[J.className,J.typeName,J.namespace],class:`cm-variable-3`},{tag:[J.tagName,J.labelName,J.annotation,J.macroName],class:`cm-tag`},{tag:J.link,class:`cm-link`},{tag:[J.heading,J.heading1,J.heading2,J.heading3,J.heading4,J.heading5,J.heading6],class:`cm-keyword`}]),l=ue.define([{tag:[J.comment,J.docComment,J.meta,J.documentMeta],color:e.colors.syntax.base.comment},{tag:[J.keyword,J.controlKeyword,J.moduleKeyword,J.definitionKeyword,J.modifier],color:e.colors.syntax.base.keyword},{tag:[J.operatorKeyword,J.operator,J.derefOperator,J.updateOperator,J.definitionOperator,J.typeOperator,J.controlOperator,J.logicOperator,J.bitwiseOperator,J.arithmeticOperator,J.compareOperator],color:e.colors.syntax.base.operator},{tag:[J.string,J.regexp,J.attributeValue,J.special(J.string),J.monospace],color:e.colors.syntax.base.string},{tag:J.escape,color:a.stringEscape||e.colors.syntax.base.string},{tag:[J.number,J.bool,J.atom,J.null,J.self],color:e.colors.syntax.base.number},{tag:[J.function(J.variableName),J.function(J.definition(J.variableName)),J.function(J.propertyName),J.standard(J.variableName),J.special(J.variableName)],color:e.colors.syntax.base.function},{tag:J.definition(J.variableName),color:a.variableGlobal||e.colors.syntax.base.variable},{tag:[J.variableName,J.local(J.variableName),J.constant(J.variableName),J.literal],color:e.colors.syntax.base.variable},{tag:J.propertyName,color:a.variableProperty||e.colors.syntax.base.variable},{tag:J.attributeName,color:a.variableOther||e.colors.syntax.base.variable},{tag:[J.className,J.typeName,J.namespace],color:e.colors.syntax.base.type},{tag:[J.tagName,J.labelName,J.annotation,J.macroName],color:a.tag||e.colors.syntax.base.keyword},{tag:J.link,color:a.url||e.colors.syntax.base.function,textDecoration:`underline`},{tag:[J.punctuation,J.separator,J.bracket,J.paren,J.brace,J.squareBracket,J.angleBracket],color:a.punctuation||e.colors.syntax.base.comment}]);return t?.syntaxColors===!1?[s]:[s,ie(he,{fallback:!0}),ie(re),ie(c),ie(l)]}var Ai=180,ji=me.define(),Mi=1,Ni=2,Pi=4,Fi=new Map,Ii=(e,t)=>{let n=`${e}|${t}`,r=Fi.get(n);if(r)return r;let i=``;e&&(i+=`color:${e};`),t&Mi&&(i+=`font-style:italic;`),t&Ni&&(i+=`font-weight:bold;`),t&Pi&&(i+=`text-decoration:underline;`);let a=G.mark({attributes:{style:i}});return Fi.set(n,a),a},Li=(e,t)=>{let n=new fe,r=e.state.doc,i=Math.min(t.length,r.lines);for(let e=0;e<i;e+=1){let i=t[e];if(!i||i.length===0)continue;let a=r.line(e+1),o=a.from;for(let[e,t,r]of i){if(e<=0)continue;let i=o,s=Math.min(o+e,a.to);o+=e,!(s<=i)&&(!t&&!r||n.add(i,s,Ii(t,r)))}}return n.finish()},Ri=_e.define({create(){return G.none},update(e,t){let n=e.map(t.changes);for(let e of t.effects)e.is(ji)&&(n=e.value);return n},provide:e=>q.decorations.from(e)}),zi=e=>oe.fromClass(class{timer;generation=0;abortController;constructor(e){this.tokenize(e)}update(e){e.docChanged&&this.schedule(e.view)}schedule(e){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.tokenize(e)},Ai)}async tokenize(t){let n=++this.generation;this.abortController?.abort();let r=new AbortController;this.abortController=r;let i=t.state.doc.toString(),a=await Zt(i,e.language,e.themeName,e.theme,{signal:r.signal,priority:`visible`});a&&(r.signal.aborted||n===this.generation&&t.state.doc.length===i.length&&t.dispatch({effects:ji.of(Li(t,a))}))}destroy(){this.timer&&clearTimeout(this.timer),this.abortController?.abort(),this.abortController=void 0}}),Bi=e=>[Ri,zi(e)],Vi=e=>{let t=(0,Z.c)(11),{currentMode:n,onToggle:r}=e,i=n===`preview`,a=i?`Switch to edit mode`:`Switch to preview mode`,o=i?`Edit`:`Preview`,s;t[0]===i?s=t[1]:(s=i?(0,Q.jsx)(X,{name:`eye`,className:`size-4`,"aria-hidden":`true`}):(0,Q.jsx)(X,{name:`eye-off`,className:`size-4`,"aria-hidden":`true`}),t[0]=i,t[1]=s);let c;t[2]!==a||t[3]!==r||t[4]!==s?(c=(0,Q.jsx)(bt,{asChild:!0,children:(0,Q.jsx)(Me,{variant:`ghost`,size:`sm`,onClick:r,"aria-label":a,className:`h-5 w-5 p-0`,children:s})}),t[2]=a,t[3]=r,t[4]=s,t[5]=c):c=t[5];let l;t[6]===o?l=t[7]:(l=(0,Q.jsx)(xt,{sideOffset:8,children:o}),t[6]=o,t[7]=l);let u;return t[8]!==c||t[9]!==l?(u=(0,Q.jsxs)(St,{children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10],u},Hi=_()(y(v((e,t)=>({selectedProfileId:null,defaultGitIdentityId:null,profiles:[],globalIdentity:null,discoveredCredentials:[],isLoading:!1,setSelectedProfile:t=>{e({selectedProfileId:t})},loadProfiles:async()=>{e({isLoading:!0});let n=t().profiles;try{return e({profiles:await nt(),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 rt();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 st()}),!0}catch(t){return console.error(`Failed to discover git credentials:`,t),e({discoveredCredentials:[]}),!1}},loadDefaultGitIdentityId:async()=>{let t=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null};try{let n=null;if(n===null){let e=g()?.settings;if(e)try{n=t(((await e.load())?.settings||{}).defaultGitIdentityId)}catch{}}if(n===null)try{let e=await a(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});e.ok&&(n=t((await e.json().catch(()=>null))?.defaultGitIdentityId))}catch{}return e({defaultGitIdentityId:n}),!0}catch(e){return console.error(`Failed to load default git identity setting:`,e),!1}},setDefaultGitIdentityId:async t=>{try{let n=typeof t==`string`?t.trim():``,r=n.length>0?n:``;return await j({defaultGitIdentityId:r}),e({defaultGitIdentityId:r.length>0?r:null}),!0}catch(e){return console.error(`Failed to save default git identity setting:`,e),!1}},createProfile:async e=>{try{let n={...e,id:e.id||`profile-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,color:e.color||`keyword`,icon:e.icon||`branch`};return await ot(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 tt(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 it(n),t().selectedProfileId===n&&e({selectedProfileId:null}),await t().loadProfiles(),!0}catch(e){return console.error(`Failed to delete git identity profile:`,e),!1}},getProfileById:e=>{let{profiles:n,globalIdentity:r}=t();return e===`global`?r||void 0:n.find(t=>t.id===e)},getUnimportedCredentials:()=>{let{profiles:e,discoveredCredentials:n}=t();return n.filter(t=>!e.some(e=>e.authType===`token`&&e.host===t.host))}}),{name:`git-identities-store`,storage:D(),partialize:e=>({selectedProfileId:e.selectedProfileId})}),{name:`git-identities-store`}));typeof window<`u`&&(window.__zustand_git_identities_store__=Hi);var Ui=`w-full max-w-[30rem]`,Wi=e=>{let t=(0,Z.c)(23),{title:n,description:r,settingsItem:i,titleAccessory:a,headerAction:o,children:s,className:c,contentClassName:l}=e,u;t[0]===n?u=t[1]:(u=(0,Q.jsx)(`span`,{className:`truncate`,children:n}),t[0]=n,t[1]=u);let d;t[2]!==u||t[3]!==a?(d=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[u,a]}),t[2]=u,t[3]=a,t[4]=d):d=t[4];let f;t[5]===o?f=t[6]:(f=o?(0,Q.jsx)(`div`,{className:`shrink-0`,children:o}):null,t[5]=o,t[6]=f);let p;t[7]!==d||t[8]!==f?(p=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[d,f]}),t[7]=d,t[8]=f,t[9]=p):p=t[9];let m;t[10]===l?m=t[11]:(m=Y(`yuri-settings-group-row`,l),t[10]=l,t[11]=m);let h;t[12]!==s||t[13]!==m?(h=(0,Q.jsx)(`div`,{className:m,children:s}),t[12]=s,t[13]=m,t[14]=h):h=t[14];let g;t[15]!==r||t[16]!==p||t[17]!==h?(g=(0,Q.jsx)(Ir,{className:`yuri-settings-detail-group`,label:p,description:r,children:h}),t[15]=r,t[16]=p,t[17]=h,t[18]=g):g=t[18];let _;return t[19]!==c||t[20]!==i||t[21]!==g?(_=(0,Q.jsx)(`div`,{"data-settings-item":i,className:c,children:g}),t[19]=c,t[20]=i,t[21]=g,t[22]=_):_=t[22],_},Gi=450,Ki=({projectRef:e=null})=>{let{t}=Ae(),{isMobile:n,isTablet:r}=Gt(),i=n||r,a=Re(e=>e.getActiveProject()),o=e?.path??a?.path??null,s=Ie(e=>e.getWorktreeMetadata),c=qe(),l=C(e=>e.homeDirectory),[u,d]=$.useState([]),[f,p]=$.useState(!1),[m,h]=$.useState(!1),[g,_]=$.useState(null),[v,y]=$.useState(null),[b,x]=$.useState([]),[S,w]=$.useState(!1),T=$.useRef(!1),E=$.useMemo(()=>e?.id&&e?.path?{id:e.id,path:e.path}:!a?.id||!o?null:{id:a.id,path:o},[a?.id,o,e?.id,e?.path]),D=$.useCallback(async()=>{if(!(!E||v===!1))try{let e=await ft(E);x(e)}catch{}},[E,v]);$.useEffect(()=>{if(!o)return;let e=!1;return y(null),(async()=>{try{let t=await at(o);if(e)return;y(t)}catch{}})(),()=>{e=!0}},[o]),$.useEffect(()=>{if(!E){x([]),w(!1);return}if(v===!1){x([]),w(!1);return}let e=!1;return w(!0),x([]),(async()=>{try{let t=await ft(E);if(e)return;x(t)}catch{}finally{e||w(!1)}})(),()=>{e=!0}},[E,v]),$.useEffect(()=>{if(!E)return;let e=!1;return h(!0),(async()=>{try{let[t,n]=await Promise.all([He(E),We(E)]);if(!e){let e=t.length>0?t:[``];d(e),_(JSON.stringify(e)),p(n)}}catch{e||(d([``]),_(JSON.stringify([``])),p(!1))}finally{e||h(!1)}})(),()=>{e=!0}},[E]);let O=$.useCallback(async e=>{if(!E)return!1;let n=e.filter(e=>e.trim().length>0);try{return await Ue(E,n)?(_(JSON.stringify(e)),!0):(Pe.error(t(`settings.yuri.worktrees.setup.toast.saveFailed`)),!1)}catch{return Pe.error(t(`settings.yuri.worktrees.setup.toast.saveFailed`)),!1}},[E,t]),k=$.useMemo(()=>g!==null&&g!==JSON.stringify(u),[g,u]);$.useEffect(()=>{if(!k||m||T.current)return;let e=window.setTimeout(()=>{T.current||(T.current=!0,(async()=>{try{await O(u)}finally{T.current=!1}})())},Gi);return()=>{window.clearTimeout(e)}},[k,m,O,u]);let A=$.useCallback((e,t)=>{d(n=>{let r=[...n];return r[e]=t,r})},[]),j=$.useCallback(()=>{d(e=>[...e,``])},[]),M=$.useCallback(e=>{d(t=>{let n=t.filter((t,n)=>n!==e);return n.length>0?n:[``]})},[]),N=$.useCallback(()=>{!k||T.current||(T.current=!0,(async()=>{try{await O(u)}finally{T.current=!1}})())},[k,O,u]),P=$.useCallback(e=>{p(e),E&&Ke(E,e)},[E]),F=$.useCallback(e=>{let t=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),n=t(e.path),r=c.filter(e=>{let r=s(e.id);if(r?.path&&t(r.path)===n)return!0;let i=e.directory;return!!(i&&t(i)===n)}),i=new Set(r.map(e=>e.id)),a=[...Ne.getState().activeSessions,...Ne.getState().archivedSessions],o=e=>{let t=a.filter(t=>{let n=t.parentID;return n&&e.has(n)});if(t.length===0)return[];let n=new Set(t.map(e=>e.id));return[...t,...o(n)]},l=o(i),u=new Set,d=[...r,...l].filter(e=>!u.has(e.id)&&(u.add(e.id),!0));Fe.requestDelete({sessions:d,mode:`worktree`,worktree:e})},[c,s]),I=$.useMemo(()=>c.map(e=>e.id).join(`,`),[c]);$.useEffect(()=>{v&&o&&D()},[I,v,o,D]);let L=(0,Q.jsxs)(St,{children:[(0,Q.jsx)(bt,{asChild:!0,children:(0,Q.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,Q.jsxs)(xt,{sideOffset:8,className:`max-w-xs`,children:[t(`settings.yuri.worktrees.setup.tooltipPrefix`),` `,(0,Q.jsx)(`code`,{className:`font-mono text-xs bg-sidebar-accent/50 px-1 rounded`,children:`$ROOT_PROJECT_PATH`}),` `,t(`settings.yuri.worktrees.setup.tooltipSuffix`)]})]}),R=(0,Q.jsxs)(St,{children:[(0,Q.jsx)(bt,{asChild:!0,children:(0,Q.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,Q.jsx)(xt,{sideOffset:8,className:`max-w-xs`,children:t(`settings.yuri.worktrees.list.tooltip`)})]});return o?v===!1?(0,Q.jsx)(Wi,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.worktrees.state.gitOnly`)})}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Wi,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,titleAccessory:L,children:m?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.worktrees.setup.loading`)}):(0,Q.jsxs)(`div`,{className:Y(`flex flex-col gap-2`,Ui),children:[u.map((e,n)=>(0,Q.jsxs)(`div`,{className:`yuri-settings-group-row flex w-full items-center gap-2`,children:[(0,Q.jsx)(yt,{value:e,onChange:e=>A(n,e.target.value),onBlur:N,placeholder:t(`settings.yuri.worktrees.setup.commandPlaceholder`),className:`min-w-0 flex-1 font-mono text-xs`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>M(n),className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":t(`settings.yuri.worktrees.setup.removeCommandAria`),children:(0,Q.jsx)(X,{name:`close`,className:`h-4 w-4`})})]},n)),(0,Q.jsxs)(Me,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:j,children:[(0,Q.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),t(`settings.yuri.worktrees.setup.addCommand`)]}),(0,Q.jsxs)(`label`,{"data-settings-item":`projects.worktree.setup.wait`,className:`flex cursor-pointer items-center gap-2 py-1`,children:[(0,Q.jsx)(ct,{checked:f,onChange:P,ariaLabel:t(`settings.yuri.worktrees.setup.waitForCommandsAria`)}),(0,Q.jsx)(`span`,{className:Y(`typography-ui-label font-normal`,f?`text-foreground`:`text-foreground/60`),children:t(`settings.yuri.worktrees.setup.waitForCommands`)})]})]})}),(0,Q.jsx)(Wi,{title:t(`settings.yuri.worktrees.list.title`),titleAccessory:R,children:S?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.worktrees.list.loading`)}):b.length===0?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground/70`,children:t(`settings.yuri.worktrees.list.empty`)}):(0,Q.jsx)(`div`,{className:Y(`space-y-1`,Ui),children:b.map(e=>(0,Q.jsxs)(`div`,{className:`group flex w-full items-center gap-2 py-1.5`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`p`,{className:`typography-meta min-w-0 truncate text-foreground`,children:e.label||e.branch||t(`settings.yuri.worktrees.list.detachedHead`)}),(0,Q.jsx)(`span`,{className:`typography-micro flex-shrink-0 self-center rounded bg-sidebar-accent/40 px-1.5 py-[1px] leading-none text-muted-foreground/60`,children:`OpenCode`})]}),(0,Q.jsx)(`p`,{className:`typography-micro truncate text-muted-foreground/60`,children:Oe(e.path,l)})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>F(e),className:Y(`flex h-7 w-7 shrink-0 items-center justify-center rounded text-muted-foreground/50 transition-opacity hover:bg-destructive/10 hover:text-destructive focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,i?`opacity-100`:`opacity-0 group-hover:opacity-100`),"aria-label":t(`settings.yuri.worktrees.list.deleteWorktreeAria`,{name:e.branch||e.label||e.path}),children:(0,Q.jsx)(X,{name:`delete-bin`,className:`h-4 w-4`})})]},e.path))})})]}):(0,Q.jsx)(Wi,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.worktrees.state.selectProject`)})})},qi=(e,t)=>t.updatedAtMs-e.updatedAtMs,Ji=_((e,t)=>({instances:[],statusesById:{},importCandidates:[],isLoading:!1,isSaving:!1,isImportsLoading:!1,initialized:!1,listenerReady:!1,error:null,load:async()=>{if(!t().isLoading){e({isLoading:!0,error:null});try{let[n,r]=await Promise.all([Dt(),jt()]),i={};for(let e of r.sort(qi))i[e.id]=e;t().listenerReady||await Vt(t=>{e(e=>({statusesById:{...e.statusesById,[t.id]:t}}))}),e({instances:n.instances,statusesById:i,isLoading:!1,initialized:!0,listenerReady:!0})}catch(t){e({isLoading:!1,error:t instanceof Error?t.message:String(t)})}}},loadImports:async()=>{if(!t().isImportsLoading){e({isImportsLoading:!0,error:null});try{e({importCandidates:await Bt(),isImportsLoading:!1})}catch(t){e({isImportsLoading:!1,error:t instanceof Error?t.message:String(t)})}}},refreshStatuses:async()=>{try{let t=await jt(),n={};for(let e of t.sort(qi))n[e.id]=e;e({statusesById:n})}catch(t){e({error:t instanceof Error?t.message:String(t)})}},setInstances:async n=>{e({isSaving:!0,error:null});try{await Ft({instances:n}),e({instances:n,isSaving:!1}),await t().refreshStatuses()}catch(t){throw e({isSaving:!1,error:t instanceof Error?t.message:String(t)}),t}},upsertInstance:async e=>{let n=t().instances,r=n.some(t=>t.id===e.id)?n.map(t=>t.id===e.id?e:t):[e,...n];await t().setInstances(r)},createFromCommand:async(e,n,r)=>{let i=Pt(e,n);r&&r.trim()&&(i.nickname=r.trim()),await t().upsertInstance(i)},removeInstance:async n=>{await Ot(n).catch(()=>void 0);let r=t().instances.filter(e=>e.id!==n);await t().setInstances(r),e(e=>{let t={...e.statusesById};return delete t[n],{statusesById:t}})},connect:async n=>{e({error:null});try{await Tt(n),await t().refreshStatuses()}catch(t){throw e({error:t instanceof Error?t.message:String(t)}),t}},disconnect:async n=>{e({error:null});try{await Ot(n),await t().refreshStatuses()}catch(t){throw e({error:t instanceof Error?t.message:String(t)}),t}},retry:async e=>{await t().connect(e)},getStatus:e=>t().statusesById[e]||null,clearError:()=>e({error:null})})),Yi=450,Xi=()=>k(),Zi=()=>({id:Xi(),name:``,command:``,icon:`play`}),Qi=({projectRef:e})=>{let{t}=Ae(),n=$.useMemo(()=>u(),[]),r=Ji(e=>e.instances),i=Ji(e=>e.load),[a,o]=$.useState([]),[s,c]=$.useState(!1),[l,d]=$.useState(null),[f,p]=$.useState({}),m=$.useRef(!1),h=$.useRef(null);$.useEffect(()=>{n&&i().catch(()=>void 0)},[n,i]),$.useEffect(()=>{let t=!1;return c(!0),(async()=>{try{let n=await Le(e);if(t)return;o(n.actions),d(JSON.stringify({actions:n.actions}))}catch{if(t)return;o([]),d(JSON.stringify({actions:[]}))}finally{t||c(!1)}})(),()=>{t=!0}},[e]);let g=$.useMemo(()=>n?vn(r):[],[r,n]),_=$.useMemo(()=>a.some(e=>e.name.trim().length===0||e.command.trim().length===0)?t(`settings.projects.actions.validation.fillNameAndCommand`):null,[a,t]),v=$.useMemo(()=>l!==null&&l!==JSON.stringify({actions:a}),[a,l]),y=$.useCallback(async n=>await Be(e,{actions:n,primaryActionId:null})?(d(JSON.stringify({actions:n})),typeof window<`u`&&window.dispatchEvent(new CustomEvent(xn,{detail:{projectId:e.id}})),!0):(Pe.error(t(`settings.projects.actions.toast.saveFailed`)),!1),[e,t]);$.useEffect(()=>{if(!v||s||_||m.current)return;let e=window.setTimeout(()=>{m.current||(m.current=!0,(async()=>{try{await y(a)}finally{m.current=!1}})())},Yi);return()=>{window.clearTimeout(e)}},[a,v,s,y,_]),$.useEffect(()=>{if(!v||!_||s){_||(h.current=null);return}let e=window.setTimeout(()=>{h.current!==_&&(h.current=_,Pe.error(_))},1e3);return()=>{window.clearTimeout(e)}},[v,s,_]);let b=$.useCallback(()=>{let e=Zi();o(t=>[...t,e]),p(t=>({...t,[e.id]:!0}))},[]),x=$.useCallback(e=>{o(t=>t.filter(t=>t.id!==e)),p(t=>{let n={...t};return delete n[e],n})},[]),S=$.useCallback((e,t)=>{o(n=>n.map(n=>n.id===e?t(n):n))},[]);return(0,Q.jsxs)(Wi,{title:t(`settings.projects.actions.title`),description:t(`settings.projects.actions.description`),settingsItem:`projects.actions`,headerAction:(0,Q.jsxs)(Me,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:b,children:[(0,Q.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),t(`settings.projects.actions.actions.add`)]}),contentClassName:`space-y-0`,children:[s?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.loading`)}):a.length===0?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.empty`)}):(0,Q.jsx)(`div`,{className:Y(`space-y-0`,Ui),children:a.map(e=>{let r=e.icon||`play`,i=bn[r]||`play`,a=f[e.id]??!1,o=e.name.trim()||t(`settings.projects.actions.state.untitled`);return(0,Q.jsxs)(rn,{open:a,onOpenChange:t=>{p(n=>({...n,[e.id]:t}))},className:`py-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsxs)(nn,{className:`group flex-1 justify-start gap-2 rounded-md px-0 pr-1 py-1 hover:bg-[var(--interactive-hover)] focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,children:[a?(0,Q.jsx)(X,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground`}):(0,Q.jsx)(X,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground`}),(0,Q.jsx)(X,{name:i,className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}),(0,Q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Q.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:o})})]}),(0,Q.jsx)(Me,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal h-7 w-7 px-0 text-muted-foreground hover:text-[var(--status-error)]`,onClick:()=>x(e.id),children:(0,Q.jsx)(X,{name:`delete-bin`,className:`h-3.5 w-3.5`})})]}),(0,Q.jsx)(tn,{className:`pt-1.5`,children:(0,Q.jsxs)(`div`,{className:`space-y-2 pb-4 pl-3 pr-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,Q.jsxs)(Ht,{children:[(0,Q.jsx)(Ut,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-[var(--interactive-border)] text-foreground hover:bg-[var(--interactive-hover)]`,"aria-label":t(`settings.projects.actions.field.selectIconAria`),children:(0,Q.jsx)(X,{name:i,className:`h-4 w-4`})})}),(0,Q.jsx)(Lt,{align:`start`,className:`w-56 p-2`,children:(0,Q.jsx)(`div`,{className:`grid grid-cols-6 gap-1`,children:yn.map(n=>{let r=n.Icon,i=(e.icon||`play`)===n.key;return(0,Q.jsx)(`button`,{type:`button`,onClick:()=>S(e.id,e=>({...e,icon:n.key})),className:Y(`inline-flex h-8 w-8 items-center justify-center rounded-md border border-transparent text-foreground hover:bg-[var(--interactive-hover)]`,i&&`border-[var(--primary-base)] bg-[var(--primary-base)]/10 text-[var(--primary-base)]`),"aria-label":t(`settings.projects.actions.field.iconAria`,{icon:n.label}),children:(0,Q.jsx)(X,{name:r,className:`h-4 w-4`})},n.key)})})})]}),(0,Q.jsx)(yt,{value:e.name,onChange:t=>S(e.id,e=>({...e,name:t.target.value})),placeholder:t(`settings.projects.actions.field.actionNamePlaceholder`),className:`h-7 flex-1 min-w-0`})]}),(0,Q.jsxs)(`div`,{className:`py-1`,children:[(0,Q.jsx)(`p`,{className:`typography-meta mb-0.5 text-muted-foreground`,children:t(`settings.projects.actions.field.command`)}),(0,Q.jsx)(Yt,{embedded:!0,value:e.command,onChange:t=>S(e.id,e=>({...e,command:t.target.value})),placeholder:t(`settings.projects.actions.field.commandPlaceholder`),className:`min-h-[88px] w-full font-mono text-xs`})]}),(0,Q.jsxs)(`div`,{className:`py-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Q.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:t(`settings.projects.actions.field.autoOpenUrl`)}),(0,Q.jsxs)(`div`,{className:`group flex cursor-pointer items-center gap-2`,role:`button`,tabIndex:0,"aria-pressed":e.autoOpenUrl===!0,onClick:()=>S(e.id,e=>({...e,...e.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})),onKeyDown:t=>{(t.key===` `||t.key===`Enter`)&&(t.preventDefault(),S(e.id,e=>({...e,...e.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})))},children:[(0,Q.jsx)(ct,{checked:e.autoOpenUrl===!0,onChange:t=>S(e.id,e=>({...e,...t?{autoOpenUrl:!0}:{autoOpenUrl:void 0}})),ariaLabel:t(`settings.projects.actions.field.autoOpenUrlForAria`,{title:o})}),(0,Q.jsx)(`span`,{className:`typography-ui-label font-normal text-foreground/80`,children:t(`settings.projects.actions.field.autoOpenUrlDescription`)})]})]}),e.autoOpenUrl===!0?(0,Q.jsxs)(`div`,{className:`mt-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(yt,{value:e.openUrl||``,onChange:t=>S(e.id,e=>({...e,openUrl:t.target.value})),placeholder:t(`settings.projects.actions.field.overrideUrlPlaceholder`),className:`h-7 w-full max-w-[24rem]`}),(0,Q.jsxs)(St,{children:[(0,Q.jsx)(bt,{asChild:!0,children:(0,Q.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/60 cursor-help`})}),(0,Q.jsx)(xt,{sideOffset:8,className:`max-w-xs`,children:t(`settings.projects.actions.field.overrideUrlTooltip`)})]})]}),n?(0,Q.jsxs)(`div`,{className:`mt-2`,children:[(0,Q.jsx)(`p`,{className:`typography-meta mb-0.5 text-muted-foreground`,children:t(`settings.projects.actions.field.desktopSshForward`)}),g.length>0?(0,Q.jsxs)(mt,{value:e.desktopOpenSshForward&&g.some(t=>t.id===e.desktopOpenSshForward)?e.desktopOpenSshForward:`__none__`,onValueChange:t=>{S(e.id,e=>({...e,...t===`__none__`?{desktopOpenSshForward:void 0}:{desktopOpenSshForward:t}}))},children:[(0,Q.jsx)(dt,{className:`h-7 w-full`,children:(0,Q.jsx)(vt,{placeholder:t(`settings.projects.actions.field.useOutputManualUrl`)})}),(0,Q.jsxs)(pt,{children:[(0,Q.jsx)(lt,{value:`__none__`,children:t(`settings.projects.actions.field.useOutputManualUrl`)}),g.map(e=>(0,Q.jsx)(lt,{value:e.id,children:e.label},e.id))]})]}):(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.noDesktopSshForwards`)})]}):null]}):null]})]})})]},e.id)})}),_&&a.length>0?(0,Q.jsx)(`p`,{className:`typography-meta text-[var(--status-warning)]`,children:_}):null]})},$i=e=>{let t=(0,Z.c)(123),{form:n}=e,{t:r}=Ae(),{currentTheme:i}=Ye(),{name:a,setName:o,icon:s,setIcon:c,color:l,setColor:u,iconBackground:d,setIconBackground:f,parsedDefaultModel:p,handleDefaultModelChange:m,isUploadingIcon:h,isRemovingCustomIcon:g,isDiscoveringIcon:_,pendingRemoveImageIcon:v,setPendingRemoveImageIcon:y,pendingUploadIconPreviewUrl:b,setPreviewImageFailed:x,hasPendingUploadImageIcon:S,hasCustomIcon:C,effectiveHasImageIcon:w,hasRemovableImageIcon:T,showImagePreview:E,fileInputRef:D,handleUploadIcon:O,handleRemoveImageIcon:k,handleDiscoverIcon:A,currentIconImage:j,project:M}=n;if(!M)return null;let N=l?ht[l]??null:null,P;t[0]===r?P=t[1]:(P=r(`settings.projects.page.field.projectName`),t[0]=r,t[1]=P);let F;t[2]===o?F=t[3]:(F=e=>o(e.target.value),t[2]=o,t[3]=F);let I;t[4]===r?I=t[5]:(I=r(`settings.projects.page.field.projectNamePlaceholder`),t[4]=r,t[5]=I);let L;t[6]!==a||t[7]!==F||t[8]!==I?(L=(0,Q.jsx)(yt,{value:a,onChange:F,placeholder:I}),t[6]=a,t[7]=F,t[8]=I,t[9]=L):L=t[9];let R;t[10]!==P||t[11]!==L?(R=(0,Q.jsx)(Lr,{label:P,itemId:`projects.name`,children:L}),t[10]=P,t[11]=L,t[12]=R):R=t[12];let z;t[13]===r?z=t[14]:(z=r(`settings.projects.page.field.defaultModel`),t[13]=r,t[14]=z);let B;t[15]===r?B=t[16]:(B=r(`settings.projects.page.field.defaultModelDescription`),t[15]=r,t[16]=B);let V;t[17]!==m||t[18]!==p.modelId||t[19]!==p.providerId?(V=(0,Q.jsx)(Et,{providerId:p.providerId,modelId:p.modelId,onChange:m,className:`yuri-settings-inline-value`}),t[17]=m,t[18]=p.modelId,t[19]=p.providerId,t[20]=V):V=t[20];let H;t[21]!==z||t[22]!==B||t[23]!==V?(H=(0,Q.jsx)(Lr,{label:z,description:B,descriptionPlacement:`outside`,itemId:`projects.default-model`,children:V}),t[21]=z,t[22]=B,t[23]=V,t[24]=H):H=t[24];let U;t[25]===r?U=t[26]:(U=r(`settings.projects.page.field.accentColor`),t[25]=r,t[26]=U);let ee;t[27]===u?ee=t[28]:(ee=()=>u(null),t[27]=u,t[28]=ee);let te=l===null?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-border/40 hover:border-border hover:bg-[var(--surface-muted)]`,W;t[29]===te?W=t[30]:(W=Y(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,te),t[29]=te,t[30]=W);let G;t[31]===r?G=t[32]:(G=r(`settings.projects.page.field.none`),t[31]=r,t[32]=G);let K;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,Q.jsx)(X,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[33]=K):K=t[33];let q;t[34]!==ee||t[35]!==W||t[36]!==G?(q=(0,Q.jsx)(`button`,{type:`button`,onClick:ee,className:W,title:G,children:K}),t[34]=ee,t[35]=W,t[36]=G,t[37]=q):q=t[37];let ne;t[38]!==l||t[39]!==u?(ne=_t.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>u(e.key),className:Y(`h-7 w-7 rounded-md border transition-colors`,l===e.key?`border-2 border-foreground ring-1 ring-[var(--primary-base)]/40`:`border-transparent hover:border-border/70`),style:{backgroundColor:e.cssVar},title:e.label},e.key)),t[38]=l,t[39]=u,t[40]=ne):ne=t[40];let re;t[41]!==q||t[42]!==ne?(re=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[q,ne]}),t[41]=q,t[42]=ne,t[43]=re):re=t[43];let ie;t[44]!==U||t[45]!==re?(ie=(0,Q.jsx)(Lr,{label:U,itemId:`projects.accent-color`,children:re}),t[44]=U,t[45]=re,t[46]=ie):ie=t[46];let ae;t[47]===r?ae=t[48]:(ae=r(`settings.projects.page.field.projectIcon`),t[47]=r,t[48]=ae);let oe;t[49]===O?oe=t[50]:(oe=e=>{let t=e.target.files?.[0]??null;O(t),e.currentTarget.value=``},t[49]=O,t[50]=oe);let se;t[51]!==D||t[52]!==oe?(se=(0,Q.jsx)(`input`,{ref:D,type:`file`,accept:`image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg`,className:`hidden`,onChange:oe}),t[51]=D,t[52]=oe,t[53]=se):se=t[53];let ce;t[54]===c?ce=t[55]:(ce=()=>c(null),t[54]=c,t[55]=ce);let le=s===null?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-border/40 hover:border-border hover:bg-[var(--surface-muted)]`,ue;t[56]===le?ue=t[57]:(ue=Y(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,le),t[56]=le,t[57]=ue);let de;t[58]===r?de=t[59]:(de=r(`settings.projects.page.field.none`),t[58]=r,t[59]=de);let fe;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,Q.jsx)(X,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[60]=fe):fe=t[60];let pe;t[61]!==ce||t[62]!==ue||t[63]!==de?(pe=(0,Q.jsx)(`button`,{type:`button`,onClick:ce,className:ue,title:de,children:fe}),t[61]=ce,t[62]=ue,t[63]=de,t[64]=pe):pe=t[64];let me;t[65]!==N||t[66]!==s||t[67]!==c?(me=gt.map(e=>{let t=e.Icon;return(0,Q.jsx)(`button`,{type:`button`,onClick:()=>c(e.key),className:Y(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,s===e.key?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-transparent hover:border-border hover:bg-[var(--surface-muted)]`),title:e.label,children:(0,Q.jsx)(X,{name:t,className:`w-4 h-4`,style:N&&s===e.key?{color:N}:void 0})},e.key)}),t[65]=N,t[66]=s,t[67]=c,t[68]=me):me=t[68];let he;t[69]!==pe||t[70]!==me?(he=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[pe,me]}),t[69]=pe,t[70]=me,t[71]=he):he=t[71];let ge;t[72]!==j||t[73]!==i||t[74]!==w||t[75]!==S||t[76]!==d||t[77]!==b||t[78]!==M||t[79]!==x||t[80]!==E||t[81]!==r?(ge=w&&E&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:r(`settings.projects.page.field.preview`)}),(0,Q.jsx)(`span`,{className:`inline-flex h-7 w-7 items-center justify-center rounded-md border border-border/60 bg-[var(--surface-elevated)] p-1`,children:(0,Q.jsx)(`span`,{className:`inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]`,style:d?{backgroundColor:d}:void 0,children:S&&b?(0,Q.jsx)(`img`,{src:b,alt:``,className:`h-full w-full object-contain`,draggable:!1,onError:()=>x(!0)}):(0,Q.jsx)(ut,{project:{...M,iconImage:j??M.iconImage},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:`h-full w-full object-contain`,onError:()=>x(!0)})})})]}),t[72]=j,t[73]=i,t[74]=w,t[75]=S,t[76]=d,t[77]=b,t[78]=M,t[79]=x,t[80]=E,t[81]=r,t[82]=ge):ge=t[82];let _e;t[83]!==w||t[84]!==d||t[85]!==f||t[86]!==r?(_e=w&&(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,Q.jsx)(`input`,{type:`color`,value:d??`#000000`,onChange:e=>f(e.target.value),className:`h-7 w-9 cursor-pointer rounded border border-border bg-transparent p-1`,"aria-label":r(`settings.projects.page.field.projectIconBackgroundAria`)}),(0,Q.jsx)(yt,{value:d??``,onChange:e=>f(e.target.value),placeholder:`#000000`,className:`h-7 w-[8rem]`}),(0,Q.jsx)(Me,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>f(null),className:`h-7 w-7 p-0`,"aria-label":r(`settings.projects.page.field.clearIconBackgroundAria`),title:r(`settings.projects.page.field.clearBackground`),disabled:!d,children:(0,Q.jsx)(X,{name:`close`,className:`h-3.5 w-3.5`})})]}),t[83]=w,t[84]=d,t[85]=f,t[86]=r,t[87]=_e):_e=t[87];let ve;t[88]!==D||t[89]!==A||t[90]!==C||t[91]!==_||t[92]!==h||t[93]!==r?(ve=!C&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Me,{size:`xs`,className:`h-6 !font-normal`,onClick:()=>D.current?.click(),disabled:h,children:r(h?`settings.projects.page.actions.uploading`:`settings.projects.page.actions.uploadIcon`)}),(0,Q.jsx)(Me,{size:`xs`,className:`h-6 !font-normal`,variant:`outline`,onClick:()=>void A(),disabled:_,children:r(_?`settings.projects.page.actions.discovering`:`settings.projects.page.actions.discoverFavicon`)})]}),t[88]=D,t[89]=A,t[90]=C,t[91]=_,t[92]=h,t[93]=r,t[94]=ve):ve=t[94];let J;t[95]!==k||t[96]!==T||t[97]!==g||t[98]!==r?(J=T&&(0,Q.jsx)(Me,{size:`xs`,className:`!font-normal`,variant:`outline`,onClick:()=>void k(),disabled:g,children:r(g?`settings.projects.page.actions.removing`:`settings.projects.page.actions.removeProjectIcon`)}),t[95]=k,t[96]=T,t[97]=g,t[98]=r,t[99]=J):J=t[99];let ye;t[100]!==g||t[101]!==v||t[102]!==y||t[103]!==r?(ye=v&&(0,Q.jsx)(Me,{size:`xs`,className:`!font-normal`,variant:`outline`,onClick:()=>y(!1),disabled:g,children:r(`settings.projects.page.actions.undoRemove`)}),t[100]=g,t[101]=v,t[102]=y,t[103]=r,t[104]=ye):ye=t[104];let be;t[105]!==ve||t[106]!==J||t[107]!==ye?(be=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[ve,J,ye]}),t[105]=ve,t[106]=J,t[107]=ye,t[108]=be):be=t[108];let xe;t[109]!==se||t[110]!==he||t[111]!==ge||t[112]!==_e||t[113]!==be?(xe=(0,Q.jsxs)(`div`,{className:`flex w-full flex-col items-end gap-2`,children:[se,he,ge,_e,be]}),t[109]=se,t[110]=he,t[111]=ge,t[112]=_e,t[113]=be,t[114]=xe):xe=t[114];let Se;t[115]!==ae||t[116]!==xe?(Se=(0,Q.jsx)(Lr,{label:ae,itemId:`projects.icon`,children:xe}),t[115]=ae,t[116]=xe,t[117]=Se):Se=t[117];let Ce;return t[118]!==ie||t[119]!==Se||t[120]!==R||t[121]!==H?(Ce=(0,Q.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[R,H,ie,Se]}),t[118]=ie,t[119]=Se,t[120]=R,t[121]=H,t[122]=Ce):Ce=t[122],Ce},ea=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,ta=e=>{if(!e)return null;let t=e.trim();return t&&ea.test(t)?t.toLowerCase():null},na=e=>{let{t}=Ae(),n=Re(e=>e.uploadProjectIcon),r=Re(e=>e.removeProjectIcon),i=Re(e=>e.discoverProjectIcon),a=Re(t=>e?t.projects.find(t=>t.id===e.id)?.iconImage??null:null),[o,s]=$.useState(``),[c,l]=$.useState(null),[u,d]=$.useState(null),[f,p]=$.useState(null),[m,h]=$.useState(void 0),[g,_]=$.useState(!1),[v,y]=$.useState(!1),[b,x]=$.useState(!1),[S,C]=$.useState(!1),[w,T]=$.useState(null),[E,D]=$.useState(null),[O,k]=$.useState(!1),A=$.useRef(null),j=$.useCallback(()=>{T(null),D(e=>(e&&URL.revokeObjectURL(e),null))},[]),M=e?.id??null;$.useEffect(()=>{if(!e){s(``),l(null),d(null),p(null),h(void 0);return}s(e.label??``),l(e.icon??null),d(e.color??null),p(e.iconBackground??null),h(e.defaultModel),C(!1),j(),k(!1)},[e,j]),$.useEffect(()=>()=>{j()},[j]);let N=$.useMemo(()=>Ge(m)??{providerId:``,modelId:``},[m]),P=!!e?.iconImage,F=!!(w&&E),I=e?.iconImage?.source===`custom`,L=P&&!S||F,R=L,z=!!(e&&P&&!S),B=!O&&(F||z),V=!!e&&(o.trim()!==(e?.label??``).trim()||c!==(e?.icon??null)||u!==(e?.color??null)||f!==(e?.iconBackground??null)||(m??void 0)!==(e?.defaultModel??void 0)||S||!!w),H=$.useCallback((e,t)=>{h(e&&t?`${e}/${t}`:void 0)},[]),U=$.useCallback(t=>{!e||!t||g||(C(!1),k(!1),T(t),D(e=>(e&&URL.revokeObjectURL(e),URL.createObjectURL(t))))},[g,e]),ee=$.useCallback(()=>{!e||!R||v||(F&&j(),C(!!P),k(!1))},[j,F,R,P,v,e]),te=$.useCallback(async()=>{if(!(!e||b)){j(),C(!1),k(!1),x(!0);try{let n=await i(e.id);if(!n.ok){Pe.error(n.error||t(`settings.projects.page.toast.discoverIconFailed`));return}if(n.skipped){Pe.success(t(`settings.projects.page.toast.customIconAlreadySet`));return}Pe.success(t(`settings.projects.page.toast.iconDiscovered`))}finally{x(!1)}}},[j,i,b,e,t]),W=$.useCallback(async i=>{let a=i?.silent===!0;if(!e)return null;let s=o.trim();if(!s)return null;if(w){_(!0);let r=await n(e.id,w);if(_(!1),!r.ok)return Pe.error(r.error||t(`settings.projects.page.toast.uploadIconFailed`)),null;a||Pe.success(t(`settings.projects.page.toast.iconUpdated`)),j(),C(!1)}let l=S&&!!e.iconImage;if(l){y(!0);let n=await r(e.id);if(y(!1),!n.ok)return Pe.error(n.error||t(`settings.projects.page.toast.removeIconFailed`)),null;a||Pe.success(t(`settings.projects.page.toast.iconRemoved`)),C(!1),p(null)}return{label:s,icon:c,color:u,iconBackground:ta(l?null:f),defaultModel:m??null}},[j,u,m,c,f,o,S,w,e,r,t,n]);return $.useEffect(()=>{k(!1)},[M,a?.updatedAt]),{name:o,setName:s,icon:c,setIcon:l,color:u,setColor:d,iconBackground:f,setIconBackground:p,defaultModel:m,parsedDefaultModel:N,handleDefaultModelChange:H,isUploadingIcon:g,isRemovingCustomIcon:v,isDiscoveringIcon:b,pendingRemoveImageIcon:S,setPendingRemoveImageIcon:C,pendingUploadIconFile:w,pendingUploadIconPreviewUrl:E,previewImageFailed:O,setPreviewImageFailed:k,hasStoredImageIcon:P,hasPendingUploadImageIcon:F,hasCustomIcon:I,effectiveHasImageIcon:L,hasRemovableImageIcon:R,showStoredImagePreview:z,showImagePreview:B,fileInputRef:A,clearPendingUploadIcon:j,handleUploadIcon:U,handleRemoveImageIcon:ee,handleDiscoverIcon:te,hasChanges:V,prepareSaveData:W,currentIconImage:a,project:e}},ra=450,ia=(e,t)=>{let{t:n}=Ae(),{hasChanges:r,name:i,icon:a,color:o,iconBackground:s,defaultModel:c,pendingRemoveImageIcon:l,pendingUploadIconFile:u,isUploadingIcon:d,isRemovingCustomIcon:f,prepareSaveData:p}=e,m=$.useRef(!1);$.useEffect(()=>{if(!r||!i.trim()||d||f||m.current)return;let e=window.setTimeout(()=>{m.current||(m.current=!0,(async()=>{try{let e=await p({silent:!0});if(e)try{await t(e)}catch{Pe.error(n(`settings.projects.page.toast.saveFailed`))}}finally{m.current=!1}})())},ra);return()=>{window.clearTimeout(e)}},[o,c,r,a,s,f,d,i,t,l,u,p,n])},aa=e=>{let t=(0,Z.c)(25),{project:n,onIdentitySave:r}=e,{t:i}=Ae(),a=na(n),o;bb0:{if(!n){o=null;break bb0}let e;t[0]!==n.id||t[1]!==n.path?(e={id:n.id,path:n.path},t[0]=n.id,t[1]=n.path,t[2]=e):e=t[2],o=e}let s=o,c;if(t[3]===r?c=t[4]:(c=async e=>{await r(e)},t[3]=r,t[4]=c),ia(a,c),!n||!s)return null;let l;t[5]!==n.path||t[6]!==i?(l=n.path.split(/[\\/]/).filter(Boolean).at(-1)??i(`settings.projects.page.title.default`),t[5]=n.path,t[6]=i,t[7]=l):l=t[7];let u=l,d;t[8]===u?d=t[9]:(d=(0,Q.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:u}),t[8]=u,t[9]=d);let f;t[10]===n.path?f=t[11]:(f=(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,title:n.path,children:n.path}),t[10]=n.path,t[11]=f);let p;t[12]!==d||t[13]!==f?(p=(0,Q.jsxs)(`div`,{className:`px-1`,children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;t[15]===a?m=t[16]:(m=(0,Q.jsx)($i,{form:a}),t[15]=a,t[16]=m);let h,g;t[17]===s?(h=t[18],g=t[19]):(h=(0,Q.jsx)(Qi,{projectRef:s}),g=(0,Q.jsx)(Ki,{projectRef:s}),t[17]=s,t[18]=h,t[19]=g);let _;return t[20]!==p||t[21]!==m||t[22]!==h||t[23]!==g?(_=(0,Q.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[p,m,h,g]}),t[20]=p,t[21]=m,t[22]=h,t[23]=g,t[24]=_):_=t[24],_};function oa(e,t,n){return Math.min(n,Math.max(t,e))}function sa(e){if(!Number.isFinite(e))return 0;let t=String(e);if(t.includes(`e-`)){let[,e]=t.split(`e-`);return Number(e)||0}let n=t.split(`.`);return n.length===2?n[1].length:0}function ca(e,t){let n=sa(t);return n<=0?e:Number(e.toFixed(n))}var la=$.forwardRef(({value:e,onValueChange:t,min:n=-1/0,max:r=1/0,step:i=1,className:a,containerClassName:o,onBlur:s,disabled:c,fallbackValue:l,onClear:u,emptyLabel:d=`—`,...f},p)=>{let{t:m}=Ae(),[h,g]=$.useState(()=>e===void 0?``:String(e)),{isMobile:_}=Gt(),v=$.useRef(!1),y=$.useRef(null),b=$.useCallback(()=>{if(typeof document>`u`||typeof window>`u`)return;y.current?.();let e=e=>{e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation?.(),y.current?.()},t=window.setTimeout(()=>{y.current?.()},700);y.current=()=>{window.clearTimeout(t),document.removeEventListener(`click`,e,!0),y.current=null},document.addEventListener(`click`,e,!0)},[]);$.useEffect(()=>()=>{y.current?.()},[]),$.useEffect(()=>{g(e===void 0?``:String(e))},[e]);let x=$.useMemo(()=>e===void 0?l===void 0?Number.isFinite(n)?n:0:l:e,[l,n,e]),S=$.useRef(x);$.useEffect(()=>{S.current=x},[x]);let C=$.useCallback(e=>{let a=ca(oa(e,n,r),i);S.current=a,t(a)},[r,n,t,i]),w=$.useCallback(e=>{let t=e.target.value;if(g(t),t.trim()===``){u?.();return}let n=Number(t);Number.isFinite(n)&&C(n)},[C,u]),T=$.useCallback(t=>{if(h.trim()===``){u||g(e===void 0?``:String(e)),s?.(t);return}let a=Number(h);if(!Number.isFinite(a))g(e===void 0?``:String(e));else{let t=ca(oa(a,n,r),i);t===e?S.current=t:C(a),g(String(t))}s?.(t)},[C,h,r,n,s,u,i,e]),E=!!(c||x>=r),D=!!(c||x<=n),O=()=>{D||C(S.current-i)},k=()=>{E||C(S.current+i)},A=e=>t=>{t.preventDefault(),t.stopPropagation(),v.current=!0,b(),e()},j=e=>t=>{if(v.current){v.current=!1,t.preventDefault(),t.stopPropagation();return}e()};return _?(0,Q.jsxs)(`div`,{"data-slot":`number-input`,className:Y(`flex h-9 shrink-0 items-stretch overflow-x-hidden overflow-y-hidden rounded-lg border border-border bg-transparent select-none overscroll-contain`,`[-webkit-user-select:none] [-webkit-touch-callout:none]`,`disabled:pointer-events-none disabled:opacity-50`,o),children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.decreaseAria`),disabled:D,onTouchStart:A(O),onClick:j(O),className:Y(`grid h-full min-h-0 w-9 place-items-center overflow-x-hidden overflow-y-hidden border-r border-border p-0 leading-none touch-none`,`text-muted-foreground`,`disabled:pointer-events-none disabled:opacity-50`,!D&&`active:bg-interactive-hover`),children:(0,Q.jsx)(X,{name:`subtract`,className:`block h-4 w-4`})}),(0,Q.jsx)(`div`,{"data-slot":`number-input-value`,className:Y(`flex h-full min-w-0 w-14 items-center justify-center bg-transparent px-1.5`,`text-center text-[16px] leading-none text-foreground [font-variant-numeric:tabular-nums]`,a),"aria-live":`polite`,children:e===void 0?d:h}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.increaseAria`),disabled:E,onTouchStart:A(k),onClick:j(k),className:Y(`grid h-full min-h-0 w-9 place-items-center overflow-x-hidden overflow-y-hidden border-l border-border p-0 leading-none touch-none`,`text-muted-foreground`,`disabled:pointer-events-none disabled:opacity-50`,!E&&`active:bg-interactive-hover`),children:(0,Q.jsx)(X,{name:`add`,className:`block h-4 w-4`})})]}):(0,Q.jsxs)(`div`,{"data-slot":`number-input`,className:Y(`flex h-7 shrink-0 items-stretch overflow-x-hidden overflow-y-hidden rounded-lg border border-border bg-transparent`,`disabled:pointer-events-none disabled:opacity-50`,o),children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.decreaseAria`),disabled:D,onClick:()=>C(S.current-i),className:Y(`flex h-full w-7 items-center justify-center overflow-x-hidden overflow-y-hidden border-r border-border p-0 leading-none touch-manipulation`,`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`,`disabled:pointer-events-none disabled:opacity-50`),children:(0,Q.jsx)(X,{name:`subtract`,className:`block h-3.5 w-3.5`})}),(0,Q.jsx)(`input`,{...f,"data-slot":`number-input-value`,ref:p,type:`text`,inputMode:f.inputMode??`numeric`,value:h,onChange:w,onBlur:T,disabled:c,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,className:Y(`h-full min-w-0 w-14 bg-transparent px-1.5 text-center typography-ui-label leading-none text-foreground [font-variant-numeric:tabular-nums]`,`placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground`,`appearance-none outline-none [appearance:textfield] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,`disabled:pointer-events-none disabled:cursor-not-allowed`,a)}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.increaseAria`),disabled:E,onClick:()=>C(S.current+i),className:Y(`flex h-full w-7 items-center justify-center overflow-x-hidden overflow-y-hidden border-l border-border p-0 leading-none touch-manipulation`,`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`,`disabled:pointer-events-none disabled:opacity-50`),children:(0,Q.jsx)(X,{name:`add`,className:`block h-3.5 w-3.5`})})]})});la.displayName=`NumberInput`;function ua(e){let t=e.indexOf(`/`);if(t!==-1){let n=e.substring(0,t);if(n===`gemini`||n===`antigravity`)return e.substring(t+1)}return e}var da={google:[{id:`gemini-auth`,label:`Gemini`,matcher:e=>e.startsWith(`gemini/`),order:1},{id:`antigravity-auth`,label:`Antigravity`,matcher:e=>e.startsWith(`antigravity/`),order:2}]};function fa(e,t){let n=da[t]??[];for(let t of n)if(t.matcher(e))return t;return null}function pa(e){return da[e]??[]}function ma(e){return[...e].sort((e,t)=>e.order-t.order)}function ha(e,t){let n=new Map;for(let r of Object.keys(e)){let e=fa(r,t)?.id??null;n.has(e)||n.set(e,[]),n.get(e).push(r)}return n}function ga(e,t,n){let r=new Map;for(let i of e){let e=fa(t(i),n)?.id??null;r.has(e)||r.set(e,[]),r.get(e).push(i)}return r}function _a(e,t){return t.filter(e=>{let t=e.toLowerCase(),n=t.includes(`/`)?t.split(`/`)[1]:t;return!!(n.startsWith(`gemini-3-`)||n.startsWith(`claude-`))})}var va=(e,t=``,n=!1)=>F({queryKey:R.scoped(`magpie-quotas`,e,t,n),staleTime:0,retry:!1,queryFn:async({signal:t})=>{let r=await a(`/api/quota/magpie`,{signal:t,query:{...e?{directory:e}:{},...n?{refresh:`1`}:{}}});if(!r.ok)throw Error(`Unable to discover Magpie quota sources`);let i=await r.json();if(!i||!Array.isArray(i.sources)||!i.sources.every(e=>e&&typeof e.id==`string`&&typeof e.name==`string`&&Array.isArray(e.results)&&e.results.every(t=>z(t)&&t.source===`magpie`&&t.sourceId===e.id&&t.providerId.startsWith(`magpie:${e.id}:`))))throw Error(`Invalid Magpie quota response`);return i}}),ya=6e4,ba=0,xa=0,Sa,Ca=0,wa=0,Ta=0,Ea=new Map,Da=e=>{let t=Sn.map(e=>e.id),n=typeof e?.usageAutoRefresh==`boolean`&&e.usageAutoRefresh,r=typeof e?.usageRefreshIntervalMs==`number`&&Number.isFinite(e.usageRefreshIntervalMs)?Math.max(3e4,Math.min(3e5,Math.round(e.usageRefreshIntervalMs))):ya,i=e?.usageDisplayMode===`remaining`?`remaining`:`usage`,a=typeof e?.usageShowPredValues==`boolean`&&e.usageShowPredValues,o=Array.isArray(e?.usageDropdownProviders)?e?.usageDropdownProviders:null,s=o?o.filter(e=>typeof e==`string`&&(e.startsWith(`magpie:`)||t.includes(e))):t,c={},l=e?.usageSelectedModels;if(l&&typeof l==`object`)for(let[e,t]of Object.entries(l))Array.isArray(t)&&(c[e]=t.filter(e=>typeof e==`string`));let u={},d=e?.usageExpandedFamilies;if(d&&typeof d==`object`)for(let[e,t]of Object.entries(d))Array.isArray(t)&&(u[e]=t.filter(e=>typeof e==`string`));return{magpieUsageUrl:typeof e?.magpieUsageUrl==`string`?e.magpieUsageUrl:``,magpieHiddenProviders:Array.isArray(e?.magpieHiddenProviders)?e.magpieHiddenProviders.filter(e=>typeof e==`string`&&e.startsWith(`magpie:`)):[],autoRefresh:n,refreshIntervalMs:r,displayMode:i,showPredValues:a,dropdownProviderIds:s,selectedModels:c,expandedFamilies:u}},Oa=async()=>{let e=g()?.settings;if(e)try{let t=(await e.load())?.settings;return Da(t??null)}catch{}if(!o()){let e=await a(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(e.ok)return Da(await e.json().catch(()=>null))}return{magpieUsageUrl:``,magpieHiddenProviders:[],autoRefresh:!1,refreshIntervalMs:ya,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:Sn.map(e=>e.id),selectedModels:{},expandedFamilies:{}}},ka=(e,t,n)=>{let r=e.filter(e=>e?.providerId&&e.providerId!==t);return z(n)&&r.push(n),r},Aa=async(e,t)=>{let n=xa;Ea.set(e,(Ea.get(e)??0)+1),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:!0}}));try{let r=await L.fetchQuery({queryKey:R.quota(e),queryFn:({signal:t})=>B(e,t),staleTime:0,retry:!1});if(n!==xa)return{providerId:e,stale:!0};if(!z(r))throw Error(`Invalid quota response`);return t(t=>({results:ka(t.results,e,r)})),{providerId:e,result:r}}catch(r){return n===xa?(t(e=>e.results.every(e=>e?.providerId)?{}:{results:e.results.filter(e=>e?.providerId)}),{providerId:e,error:r instanceof Error?r.message:`Failed to fetch quota`}):{providerId:e,stale:!0}}finally{if(n===xa){let n=(Ea.get(e)??1)-1;n>0?Ea.set(e,n):Ea.delete(e),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:n>0}}))}}},ja=()=>{Sa=void 0,Ca+=1,xa+=1,ba+=1,Ea.clear(),Ma.setState({magpieUsageUrl:``,magpieHiddenProviders:[],magpieSources:[],magpieError:null,results:[],isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null})},Ma=_()(y((e,t)=>({magpieSources:[],magpieError:null,magpieHiddenProviders:[],magpieUsageUrl:``,results:[],selectedProviderId:null,isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null,autoRefresh:!1,refreshIntervalMs:ya,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:Sn.map(e=>e.id),selectedModels:{},expandedFamilies:{},loadSettings:async()=>{let t=xa;try{let n=await Oa();if(t!==xa)return;e(e=>({...n,dropdownProviderIds:[...n.dropdownProviderIds.filter(e=>!e.startsWith(`magpie:`)),...e.results.filter(e=>e.source===`magpie`&&!n.magpieHiddenProviders.includes(e.providerId)).map(e=>e.providerId)]}))}catch(e){console.warn(`Failed to load usage settings:`,e)}},fetchAllQuotas:async()=>{let n=++ba;e({isLoading:!0,error:null});let r=Sn.map(e=>e.id),[i]=await Promise.all([Promise.all(r.map(t=>Aa(t,e))),t().fetchMagpieQuotas(!0)]);if(n===ba){let t=i.find(e=>`error`in e);e({isLoading:!1,...i.some(e=>`result`in e)?{lastUpdated:Date.now()}:{},error:t?.error??null})}},fetchProviderQuota:async n=>{if(n.startsWith(`magpie:`))return t().fetchMagpieQuotas(!0);let r=await Aa(n,e);`stale`in r||e({error:`error`in r?r.error:null})},fetchMagpieQuotas:async(n=!1)=>{let r=xa,i=C.getState().currentDirectory,a=t().magpieUsageUrl,o=JSON.stringify([i,a]);Sa!==o&&(Sa=o,Ca+=1,e(e=>({results:e.results.filter(e=>e?.source!==`magpie`),magpieSources:[],magpieError:null})));let s=Ca,c=++wa;try{let{sources:o,incomplete:l}=await L.fetchQuery(va(i,a,n));if(r!==xa||s!==Ca||c<Ta||i!==C.getState().currentDirectory||a!==t().magpieUsageUrl)return;Ta=c,e(e=>{let t=new Map(o.filter(e=>e.error&&!e.clearPrevious&&e.results.length===0).map(e=>[e.id,e.error]));if(l){let n=new Set(o.map(e=>e.id));for(let r of e.results)r.sourceId&&!n.has(r.sourceId)&&t.set(r.sourceId,`Magpie discovery is incomplete`)}let n=e.results.filter(e=>e?.providerId&&(e.source!==`magpie`||t.has(e.sourceId??``))).map(e=>e.source===`magpie`&&t.has(e.sourceId??``)?{...e,ok:!1,error:t.get(e.sourceId??``)}:e);n.push(...o.flatMap(e=>e.results));let r=n.filter(e=>e.source===`magpie`).map(e=>e.providerId);return{results:n,magpieSources:o,magpieError:null,dropdownProviderIds:[...e.dropdownProviderIds.filter(e=>!e.startsWith(`magpie:`)),...r.filter(t=>!e.magpieHiddenProviders.includes(t))]}})}catch(n){if(r!==xa||s!==Ca||c<Ta||i!==C.getState().currentDirectory||a!==t().magpieUsageUrl)return;Ta=c,e({magpieError:n instanceof Error?n.message:`Unable to read Magpie quotas`})}},setSelectedProvider:t=>e({selectedProviderId:t}),setAutoRefresh:t=>e({autoRefresh:t}),setRefreshInterval:t=>{e({refreshIntervalMs:Math.max(3e4,Math.min(3e5,Math.round(t)))})},setDisplayMode:t=>e({displayMode:t}),setShowPredValues:t=>e({showPredValues:t}),setDropdownProviderIds:n=>{let r=t().results.filter(e=>e.source===`magpie`),i=new Set(r.map(e=>e.providerId));e({dropdownProviderIds:n,magpieHiddenProviders:[...t().magpieHiddenProviders.filter(e=>!i.has(e)),...r.filter(e=>!n.includes(e.providerId)).map(e=>e.providerId)]})},setSelectedModels:(t,n)=>{e(e=>({selectedModels:{...e.selectedModels,[t]:n}}))},toggleModelSelected:(t,n)=>{e(e=>{let r=e.selectedModels[t]??[],i=r.includes(n)?r.filter(e=>e!==n):[...r,n];return{selectedModels:{...e.selectedModels,[t]:i}}})},setExpandedFamilies:(n,r)=>{e(e=>({expandedFamilies:{...e.expandedFamilies,[n]:r}})),j({usageExpandedFamilies:t().expandedFamilies})},toggleFamilyExpanded:(n,r)=>{e(e=>{let t=e.expandedFamilies[n]??[],i=t.includes(r)?t.filter(e=>e!==r):[...t,r];return{expandedFamilies:{...e.expandedFamilies,[n]:i}}}),j({usageExpandedFamilies:t().expandedFamilies})},applyDefaultSelections:(n,r)=>{if((t().selectedModels[n]?.length??0)>0)return;let i=_a(n,r);i.length!==0&&(e(e=>({selectedModels:{...e.selectedModels,[n]:i}})),j({usageSelectedModels:t().selectedModels}))}}),{name:`quota-store`})),Na=()=>{let e=(0,Z.c)(11),t=C(Pa),n=Ma(Fa),r=Ma(Ia),i;e[0]===r?i=e[1]:(i=()=>{r()},e[0]=r,e[1]=i);let a;e[2]!==t||e[3]!==r||e[4]!==n?(a=[t,n,r],e[2]=t,e[3]=r,e[4]=n,e[5]=a):a=e[5],$.useEffect(i,a);let o=Ma(La),s=Ma(Ra),c=Ma(za),l,u;e[6]!==o||e[7]!==c||e[8]!==s?(l=()=>{if(!o)return;let e=window.setInterval(()=>{c()},s);return()=>window.clearInterval(e)},u=[o,s,c],e[6]=o,e[7]=c,e[8]=s,e[9]=l,e[10]=u):(l=e[9],u=e[10]),$.useEffect(l,u)};function Pa(e){return e.currentDirectory}function Fa(e){return e.magpieUsageUrl}function Ia(e){return e.fetchMagpieQuotas}function La(e){return e.autoRefresh}function Ra(e){return e.refreshIntervalMs}function za(e){return e.fetchAllQuotas}var Ba=e=>{let t=(0,Z.c)(20),{percent:n,tonePercent:r,className:i,expectedMarkerPercent:a}=e,o;t[0]===n?o=t[1]:(o=Rt(n)??0,t[0]=n,t[1]=o);let s=o,c=r??n,l;t[2]===c?l=t[3]:(l=Ct(c),t[2]=c,t[3]=l);let u=l,d=a==null?null:Math.max(0,Math.min(100,a)),f;t[4]===u?f=t[5]:(f=u===`critical`?{backgroundColor:`var(--status-error)`}:u===`warn`?{backgroundColor:`var(--status-warning)`}:{backgroundColor:`var(--status-success)`},t[4]=u,t[5]=f);let p=f,m;t[6]===i?m=t[7]:(m=Y(`relative h-2.5 rounded-full bg-[var(--interactive-border)] overflow-hidden`,i),t[6]=i,t[7]=m);let h=`${s}%`,g;t[8]!==p||t[9]!==h?(g={...p,width:h},t[8]=p,t[9]=h,t[10]=g):g=t[10];let _;t[11]!==s||t[12]!==g?(_=(0,Q.jsx)(`div`,{className:`h-full transition-all duration-300`,style:g,role:`progressbar`,"aria-valuenow":s,"aria-valuemin":0,"aria-valuemax":100}),t[11]=s,t[12]=g,t[13]=_):_=t[13];let v;t[14]===d?v=t[15]:(v=d!=null&&d>0&&d<100&&(0,Q.jsx)(`div`,{className:`absolute top-0 h-full w-0.5 bg-foreground`,style:{left:`${d}%`},title:`Expected usage if spread evenly: ${Math.round(d)}% of quota`,"aria-hidden":`true`}),t[14]=d,t[15]=v);let y;return t[16]!==m||t[17]!==_||t[18]!==v?(y=(0,Q.jsxs)(`div`,{className:m,children:[_,v]}),t[16]=m,t[17]=_,t[18]=v,t[19]=y):y=t[19],y},Va=e=>{let t=(0,Z.c)(67),{paceInfo:n,className:r,compact:i}=e,a=i!==void 0&&i,{t:o}=Ae(),s;t[0]===n.status?s=t[1]:(s=At(n.status),t[0]=n.status,t[1]=s);let c=s,l;bb0:{switch(n.status){case`on-track`:{let e;t[2]===o?e=t[3]:(e=o(`settings.usage.pace.status.onTrack`),t[2]=o,t[3]=e),l=e;break bb0}case`slightly-fast`:{let e;t[4]===o?e=t[5]:(e=o(`settings.usage.pace.status.slightlyFast`),t[4]=o,t[5]=e),l=e;break bb0}case`too-fast`:{let e;t[6]===o?e=t[7]:(e=o(`settings.usage.pace.status.tooFast`),t[6]=o,t[7]=e),l=e;break bb0}case`exhausted`:{let e;t[8]===o?e=t[9]:(e=o(`settings.usage.pace.status.usedUp`),t[8]=o,t[9]=e),l=e;break bb0}}l=void 0}let u=l,d;t[10]!==n.predictText||t[11]!==o?(d=o(`settings.usage.pace.predictionTooltip`,{prediction:n.predictText}),t[10]=n.predictText,t[11]=o,t[12]=d):d=t[12];let f=d;if(a){let e;t[13]===r?e=t[14]:(e=Y(`flex items-center gap-1.5`,r),t[13]=r,t[14]=e);let i;t[15]===c?i=t[16]:(i={backgroundColor:c},t[15]=c,t[16]=i);let a;t[17]!==u||t[18]!==i?(a=(0,Q.jsx)(`div`,{className:`h-2 w-2 rounded-full flex-shrink-0`,style:i,title:u}),t[17]=u,t[18]=i,t[19]=a):a=t[19];let s;t[20]===c?s=t[21]:(s={color:c},t[20]=c,t[21]=s);let l=n.isExhausted?void 0:f,d;t[22]!==n.isExhausted||t[23]!==n.predictText||t[24]!==n.remainingSeconds||t[25]!==o?(d=n.isExhausted?(0,Q.jsx)(Q.Fragment,{children:o(`settings.usage.pace.wait`,{duration:kt(n.remainingSeconds)})}):(0,Q.jsx)(Q.Fragment,{children:o(`settings.usage.pace.prediction`,{prediction:n.predictText})}),t[22]=n.isExhausted,t[23]=n.predictText,t[24]=n.remainingSeconds,t[25]=o,t[26]=d):d=t[26];let p;t[27]!==d||t[28]!==s||t[29]!==l?(p=(0,Q.jsx)(`span`,{className:`typography-micro tabular-nums`,style:s,title:l,children:d}),t[27]=d,t[28]=s,t[29]=l,t[30]=p):p=t[30];let m;return t[31]!==p||t[32]!==e||t[33]!==a?(m=(0,Q.jsxs)(`div`,{className:e,children:[a,p]}),t[31]=p,t[32]=e,t[33]=a,t[34]=m):m=t[34],m}let p;t[35]===r?p=t[36]:(p=Y(`flex items-center justify-between gap-2`,r),t[35]=r,t[36]=p);let m;t[37]!==n.isExhausted||t[38]!==n.paceRateText||t[39]!==o?(m=!n.isExhausted&&(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:o(`settings.usage.pace.rate`,{rate:n.paceRateText})}),t[37]=n.isExhausted,t[38]=n.paceRateText,t[39]=o,t[40]=m):m=t[40];let h;t[41]===m?h=t[42]:(h=(0,Q.jsx)(`div`,{className:`flex items-center gap-1.5`,children:m}),t[41]=m,t[42]=h);let g;t[43]===c?g=t[44]:(g={color:c},t[43]=c,t[44]=g);let _;t[45]!==n.isExhausted||t[46]!==n.predictText||t[47]!==n.remainingSeconds||t[48]!==f||t[49]!==u||t[50]!==o?(_=n.isExhausted?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:u}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.waitSeparator`)}),(0,Q.jsx)(`span`,{className:`font-medium`,children:kt(n.remainingSeconds)})]}):(0,Q.jsxs)(`span`,{title:f,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.predictionLabel`)}),(0,Q.jsx)(`span`,{className:`font-medium`,children:n.predictText})]}),t[45]=n.isExhausted,t[46]=n.predictText,t[47]=n.remainingSeconds,t[48]=f,t[49]=u,t[50]=o,t[51]=_):_=t[51];let v;t[52]!==g||t[53]!==_?(v=(0,Q.jsx)(`span`,{className:`typography-micro tabular-nums`,style:g,children:_}),t[52]=g,t[53]=_,t[54]=v):v=t[54];let y;t[55]===c?y=t[56]:(y={backgroundColor:c},t[55]=c,t[56]=y);let b;t[57]!==u||t[58]!==y?(b=(0,Q.jsx)(`div`,{className:`h-2 w-2 rounded-full flex-shrink-0`,style:y,title:u}),t[57]=u,t[58]=y,t[59]=b):b=t[59];let x;t[60]!==v||t[61]!==b?(x=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[v,b]}),t[60]=v,t[61]=b,t[62]=x):x=t[62];let S;return t[63]!==x||t[64]!==p||t[65]!==h?(S=(0,Q.jsxs)(`div`,{className:p,children:[h,x]}),t[63]=x,t[64]=p,t[65]=h,t[66]=S):S=t[66],S},Ha=e=>e instanceof Error&&e.name===`CancelledError`,Ua=_(()=>({setStatus:e=>wt(L,e),refreshStatus:async(e,t)=>{let r=n();t?.force&&await L.cancelQueries({queryKey:R.github.auth(r),exact:!0});try{return await Nt(L,e,r)}catch(e){if(Ha(e))return Mt(L,r);throw e}}})),Wa={displayMode:`browser`,installed:!1,browserTab:!0},Ga=new Set,Ka=Wa,qa=!1,Ja,Ya=()=>{let e=It();return{displayMode:e,installed:e!==`browser`,browserTab:e===`browser`}},Xa=()=>(!qa&&typeof window<`u`&&(Ka=Ya(),qa=!0),Ka),Za=()=>{let e=Ya();qa=!0,e.displayMode!==Ka.displayMode&&(Ka=e,Ga.forEach(e=>e()))},Qa=()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=[window.matchMedia(`(display-mode: standalone)`),window.matchMedia(`(display-mode: minimal-ui)`),window.matchMedia(`(display-mode: fullscreen)`),window.matchMedia(`(display-mode: window-controls-overlay)`)];for(let t of e)typeof t.addEventListener==`function`?t.addEventListener(`change`,Za):typeof t.addListener==`function`&&t.addListener(Za);return window.addEventListener(`appinstalled`,Za),window.addEventListener(`focus`,Za),()=>{for(let t of e)typeof t.removeEventListener==`function`?t.removeEventListener(`change`,Za):typeof t.removeListener==`function`&&t.removeListener(Za);window.removeEventListener(`appinstalled`,Za),window.removeEventListener(`focus`,Za)}},$a=e=>(Ga.add(e),Ja??=Qa(),Za(),()=>{Ga.delete(e),Ga.size===0&&(Ja?.(),Ja=void 0)}),eo=()=>$.useSyncExternalStore($a,Xa,to);function to(){return Wa}var no=`Yuri`,ro=_()(v(e=>({sidebarBrandName:no,setSidebarBrandName:t=>{let n=t.slice(0,64);e(e=>e.sidebarBrandName===n?e:{sidebarBrandName:n})}}),{name:`sidebar-brand-store`,storage:A(),version:3,migrate:(e,t)=>{if(!e||typeof e!=`object`)return e;let n={...e};return t<1&&n.sidebarBrandName===`YEE CODE`&&(n.sidebarBrandName=no),t<2&&n.sidebarBrandName===`Open Chamber`&&(n.sidebarBrandName=no),t<3&&(n.sidebarBrandName===`OPEN CHAMBER`||n.sidebarBrandName===`Open Chamber`)&&(n.sidebarBrandName=no),n}}));typeof window<`u`&&t(e=>{i(e)&&ro.persist.rehydrate()});var io=(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,ao=(e,t,n)=>{io(e.get(t),n)&&e.set(t,n)},oo=e=>{let t=e;return H(t.directory)??H(t.project?.worktree)},so=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)},co=(e,t,n,r,i=[])=>{let a=new Map,o=new Map;for(let e of t){let t=H(e.normalizedPath);if(!t)continue;let n=o.get(t);(!n||e.id.localeCompare(n.id)<0)&&o.set(t,e),ao(a,t,{projectId:e.id,projectRoot:t,scopeDirectory:t,kind:`project`})}if(!r)for(let[e,t]of n){let n=H(e),r=n?o.get(n):void 0;if(!(!r||!n))for(let e of t){let t=H(e.path);t&&ao(a,t,{projectId:r.id,projectRoot:n,scopeDirectory:t,kind:`worktree`})}}let s=new Map,c=new Map,l=new Map,u=new Map,d=new Map,f=e=>{if(!e)return null;if(s.has(e))return s.get(e)??null;if(r){let t=a.get(e)??null;return s.set(e,t),t}let t=[],n=e,i=null;for(;n;){if(s.has(n)){i=s.get(n)??null;break}if(t.push(n),i=a.get(n)??null,i)break;n=so(n)}for(let e of t)s.set(e,i);return i},p=(e,t,n)=>{for(let r of e){let e=f(oo(r));if(!e)continue;c.set(r.id,e);let i=t.get(e.projectId);if(i?i.push(r):t.set(e.projectId,[r]),!n)continue;let a=n.get(e.scopeDirectory);a?a.add(r.id):n.set(e.scopeDirectory,new Set([r.id]))}};return p(e,l,d),p(i,u),{bySessionId:c,sessionsByProject:l,archivedSessionsByProject:u,sessionsByScope:d,directoryResolutions:s.size}},lo=`__other__`;function uo(e){return e.time?.updated??e.time?.archived??e.time?.created??0}function fo({mode:e=`dialog`}){let{t}=Ae(),{isMobile:n,isTablet:r,hasTouchInput:i}=Gt(),a=n||r||i,s=e===`page`,c=O(e=>e.isArchivedSessionsDialogOpen),l=O(e=>e.setArchivedSessionsDialogOpen),u=s||c,d=Re(e=>e.projects),f=Ne(e=>e.archivedSessions),p=Ie(e=>e.setCurrentSession),m=O(e=>e.setSettingsDialogOpen),[h,g]=$.useState(!1),[_,v]=$.useState(null),[y,b]=$.useState(null);$.useEffect(()=>{if(!u){v(null),b(null);return}let e=!1;return g(!0),Je().catch(()=>{e||Pe.error(t(`settings.yuri.archivedSessions.toast.loadFailed`))}).finally(()=>{e||g(!1)}),()=>{e=!0}},[u,t]);let x=$.useMemo(()=>{let e=co([],d.map(e=>({id:e.id,normalizedPath:e.path})),new Map,o(),f),n=new Map;for(let[t,r]of e.archivedSessionsByProject)n.set(t,[...r].sort((e,t)=>uo(t)-uo(e)));let r=new Set;for(let e of n.values())for(let t of e)r.add(t.id);let i=f.filter(e=>!r.has(e.id)).sort((e,t)=>uo(t)-uo(e));i.length>0&&n.set(lo,i);let a=[];for(let e of d){let t=n.get(e.id)??[];t.length!==0&&a.push({projectId:e.id,label:e.label||e.path,path:e.path,sessions:t})}let s=n.get(lo);return s&&s.length>0&&a.push({projectId:lo,label:t(`settings.yuri.archivedSessions.otherProjects`),path:null,sessions:s}),a.sort((e,t)=>t.sessions.length-e.sessions.length||e.label.localeCompare(t.label)),a},[f,d,t]),S=f.length,C=_?x.find(e=>e.projectId===_)??null:null,w=$.useCallback(async e=>{b(e.id);try{await ze(e.id)?Pe.success(t(`settings.yuri.archivedSessions.toast.restored`)):Pe.error(t(`settings.yuri.archivedSessions.toast.restoreFailed`))}finally{b(null)}},[t]),T=$.useCallback(e=>{let t=Ve(e);p(e.id,t),l(!1),m(!1)},[p,l,m]),E=C?C.label:t(`settings.yuri.archivedSessions.dialog.title`),D=C?C.sessions.length===1?t(`settings.yuri.archivedSessions.dialog.sessionCountSingle`,{count:C.sessions.length}):t(`settings.yuri.archivedSessions.dialog.sessionCountPlural`,{count:C.sessions.length}):t(`settings.yuri.archivedSessions.dialog.description`),k=(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[C?(0,Q.jsxs)(Me,{type:`button`,variant:`ghost`,size:`sm`,className:`!h-7 !px-2 !font-normal text-muted-foreground`,onClick:()=>v(null),children:[(0,Q.jsx)(X,{name:`arrow-left-s`,className:`mr-1 h-4 w-4`}),t(`settings.yuri.archivedSessions.dialog.backToProjects`)]}):null,h?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 typography-meta text-muted-foreground py-6`,children:[(0,Q.jsx)(X,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),t(`settings.yuri.archivedSessions.dialog.loading`)]}):C?C.sessions.length===0?(0,Q.jsx)(`div`,{className:`rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:t(`settings.yuri.archivedSessions.dialog.emptyProject`)}):(0,Q.jsx)(`div`,{className:`space-y-1.5`,children:C.sessions.map(e=>{let n=Ve(e),r=uo(e),i=y===e.id;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-border/60 px-3 py-2.5 sm:flex-row sm:items-center sm:gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`typography-ui-label font-medium text-foreground truncate`,children:e.title||t(`sessions.sidebar.session.untitled`)}),(0,Q.jsxs)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:[r>0?Wt(r):null,r>0&&n?` · `:null,n?Oe(n):null]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,Q.jsx)(Me,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,disabled:i,onClick:()=>T(e),children:t(`settings.yuri.archivedSessions.actions.preview`)}),(0,Q.jsxs)(Me,{type:`button`,variant:`default`,size:`xs`,className:`!font-normal`,disabled:i,onClick:()=>void w(e),children:[i?(0,Q.jsx)(X,{name:`loader-4`,className:`mr-1 h-3.5 w-3.5 animate-spin`}):(0,Q.jsx)(X,{name:`inbox-unarchive`,className:`mr-1 h-3.5 w-3.5`}),t(`settings.yuri.archivedSessions.actions.restore`)]})]})]},e.id)})}):x.length===0?(0,Q.jsx)(`div`,{className:`rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:t(`settings.yuri.archivedSessions.dialog.empty`)}):(0,Q.jsx)(`div`,{className:`space-y-1.5`,children:x.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>v(e.projectId),className:Y(`flex w-full items-center gap-3 rounded-lg border border-border/60 px-3 py-2.5 text-left`,`hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`),children:[(0,Q.jsx)(X,{name:`folder`,className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`typography-ui-label font-medium text-foreground truncate`,children:e.label}),e.path?(0,Q.jsx)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:Oe(e.path)}):null]}),(0,Q.jsx)(`span`,{className:`typography-meta tabular-nums text-muted-foreground shrink-0`,children:e.sessions.length===1?t(`settings.yuri.archivedSessions.dialog.sessionCountSingle`,{count:e.sessions.length}):t(`settings.yuri.archivedSessions.dialog.sessionCountPlural`,{count:e.sessions.length})}),(0,Q.jsx)(X,{name:`arrow-right-s`,className:`h-4 w-4 shrink-0 text-muted-foreground`})]},e.projectId))}),!C&&!h&&S>0?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(S===1?`settings.yuri.archivedSessions.summarySingle`:`settings.yuri.archivedSessions.summaryPlural`,{count:S})}):null]});return s?(0,Q.jsxs)(`div`,{"data-settings-item":`archived-sessions.manage`,className:`yuri-settings-section-stack`,children:[(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.archivedSessions.description`)}),k]}):a?(0,Q.jsx)(zt,{open:c,title:E,onClose:()=>l(!1),contentMaxHeightClassName:`max-h-[min(80vh,640px)]`,renderHeader:e=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border/40 px-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:E}),e]}),(0,Q.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:D})]}),children:k}):(0,Q.jsx)(et,{open:c,onOpenChange:l,children:(0,Q.jsxs)(Ze,{className:`max-h-[85vh] max-w-2xl overflow-y-auto`,children:[(0,Q.jsxs)(Xe,{children:[(0,Q.jsx)(Qe,{children:E}),(0,Q.jsx)($e,{children:D})]}),k]})})}function po(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(fo,{mode:`dialog`}),e[0]=t):t=e[0],t}var mo=48;function ho({title:e,eyebrow:t,trailing:n,className:r}){let i=(0,$.useRef)(null),a=(0,$.useRef)(null),o=(0,$.useRef)(null),s=(0,$.useRef)(null),c=(0,$.useRef)(null),l=De(()=>{s.current=null;let e=i.current,t=a.current;if(!e||!t)return;let n=Math.min(1,Math.max(0,t.scrollTop/mo)),r=o.current?.matches?Number(n>=.5):n;c.current!==null&&Math.abs(c.current-r)<.001||(c.current=r,e.style.setProperty(`--yuri-mobile-title-collapse`,r.toFixed(4)))}),u=De(()=>{s.current===null&&(s.current=window.requestAnimationFrame(l))});return(0,$.useEffect)(()=>{let e=i.current;if(!e)return;let t=e.closest(`.yuri-mobile-settings-root-surface, [role="tabpanel"]`);if(!t)return;let n=window.matchMedia(`(prefers-reduced-motion: reduce)`);return a.current=t,o.current=n,c.current=null,t.addEventListener(`scroll`,u,{passive:!0}),n.addEventListener(`change`,u),l(),()=>{t.removeEventListener(`scroll`,u),n.removeEventListener(`change`,u),s.current!==null&&window.cancelAnimationFrame(s.current),s.current=null,a.current=null,o.current=null,c.current=null}},[]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`header`,{ref:i,className:Y(`yuri-mobile-collapsing-header flex shrink-0 items-start gap-4`,r),children:(0,Q.jsxs)(`div`,{className:`yuri-mobile-collapsing-header-inner`,children:[(0,Q.jsxs)(`div`,{className:`yuri-mobile-collapsing-header-title-block min-w-0 flex-1`,children:[t?(0,Q.jsx)(`p`,{className:`yuri-mobile-collapsing-header-eyebrow truncate typography-micro font-medium text-muted-foreground`,children:t}):null,(0,Q.jsx)(`h1`,{className:`yuri-mobile-root-page-title truncate font-semibold text-foreground`,children:e})]}),n?(0,Q.jsx)(`div`,{className:`yuri-mobile-collapsing-header-trailing flex min-h-10 shrink-0 items-center gap-3.5`,children:n}):null]})}),(0,Q.jsx)(`div`,{className:`yuri-mobile-collapsing-header-spacer`,"aria-hidden":`true`})]})}export{Jr as A,Pn as B,Bi as C,bi as D,Oi as E,Rr as F,Sn as H,zr as I,Fr as L,Ur as M,Lr as N,Gr as O,Ir as P,jr as R,Vi as S,Di as T,Cn as U,wn as V,ma as _,ro as a,Ji as b,Va as c,Na as d,Ma as f,ga as g,ha as h,co as i,Hr as j,qr as k,Ba as l,ua as m,po as n,eo as o,pa as p,fo as r,Ua as s,ho as t,ja as u,la as v,ki as w,Hi as x,aa as y,sr as z};