@yuriai/web 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/README.md +3 -1
  2. package/dist/assets/{AgentAvatar-D6H7fWWf.js → AgentAvatar-BVnp9gE9.js} +1 -1
  3. package/dist/assets/AssistantView-BkMKCN9c.js +3 -0
  4. package/dist/assets/{DiagramView-TX1QZ1-S.js → DiagramView-B7_hOmVC.js} +1 -1
  5. package/dist/assets/{FadeInOnReveal-eVZbrwte.js → FadeInOnReveal-CzC5UKnq.js} +1 -1
  6. package/dist/assets/{Icon-2cKLcXGe.js → Icon-BXTZRnIO.js} +1 -1
  7. package/dist/assets/{ImageLoadingPlaceholder-DmCEIw55.js → ImageLoadingPlaceholder-Cv6IaJar.js} +1 -1
  8. package/dist/assets/{LoadingImage-B-cD_lfU.js → LoadingImage-NxtWlewi.js} +1 -1
  9. package/dist/assets/{MarkdownRenderer-DGUI8EIG.js → MarkdownRenderer-Va7Wdk98.js} +2 -2
  10. package/dist/assets/{MarkdownRendererImpl-DndseLUT.js → MarkdownRendererImpl-CsjvA5I5.js} +1 -1
  11. package/dist/assets/{MarkstreamRendererImpl-Ehxwt6MS.js → MarkstreamRendererImpl-Du38HKce.js} +1 -1
  12. package/dist/assets/{MobileDetailNavigation-D7uM40jU.js → MobileDetailNavigation-B_PYZ9xi.js} +1 -1
  13. package/dist/assets/MobileShareBridge-BbbQ15B3.js +4 -0
  14. package/dist/assets/MobileTabPageHeader-tiWNRKWN.js +2 -0
  15. package/dist/assets/{MultiRunWindow-CVI6D2LM.js → MultiRunWindow-CFFrKEHW.js} +1 -1
  16. package/dist/assets/{OnboardingScreen-CG2xI_UT.js → OnboardingScreen-BxS5LEOm.js} +1 -1
  17. package/dist/assets/{OverlayScrollbar-piA-chKb.js → OverlayScrollbar-CbWvRXm6.js} +1 -1
  18. package/dist/assets/SettingsView-CKn54R1o.js +26 -0
  19. package/dist/assets/{SettingsWindow-Cj6sYyvK.js → SettingsWindow-BKatx9Q_.js} +1 -1
  20. package/dist/assets/{TerminalView-DW4OxMaM.js → TerminalView-h15pBKLx.js} +2 -2
  21. package/dist/assets/{ToolOutputDialog-DxKGYhQ6.js → ToolOutputDialog-Bj-TWElC.js} +1 -1
  22. package/dist/assets/{appThemeRegistry-DlEr4DLc.js → appThemeRegistry-nntgbF9E.js} +1 -1
  23. package/dist/assets/button-D_HdP1Oy.js +1 -0
  24. package/dist/assets/{capgoAdapter-Onw1miMh.js → capgoAdapter-BV5kJq2r.js} +1 -1
  25. package/dist/assets/{collapsible-BRKOX_ML.js → collapsible-sUU_ORMe.js} +1 -1
  26. package/dist/assets/{diagram-C9F3kAJt.js → diagram-BE50CEiR.js} +1 -1
  27. package/dist/assets/{dialog-NsOVcGdh.js → dialog-B_87Teec.js} +1 -1
  28. package/dist/assets/{dropdown-menu.styles-CjPDePJF.js → dropdown-menu.styles-C_b80jxk.js} +1 -1
  29. package/dist/assets/{fileMentionTouchSelection-B26MejYr.js → fileMentionTouchSelection-Bx6vWiqF.js} +1 -1
  30. package/dist/assets/{gitApi-BXhXdWkh.js → gitApi-B1arMnHR.js} +1 -1
  31. package/dist/assets/{input-BI3Ya8O_.js → input-DDfJnn8e.js} +1 -1
  32. package/dist/assets/{insertionBoundaries-BxSGE3B7.js → insertionBoundaries-B8UdVMC9.js} +1 -1
  33. package/dist/assets/{main-BdV8Awp-.js → main-BLSF9qdf.js} +2 -2
  34. package/dist/assets/{main-CGpFMQTy.js → main-DJwLyPc3.js} +12 -12
  35. package/dist/assets/{markdownHeightCache-CHFSvA8u.js → markdownHeightCache-Cbd62oWw.js} +1 -1
  36. package/dist/assets/{mcpQueries-uZJFBhGj.js → mcpQueries-BxbbmYAd.js} +1 -1
  37. package/dist/assets/{miniChat-B1aBBLiq.js → miniChat-D_cBND3Z.js} +2 -2
  38. package/dist/assets/{mobile-B8U8FARq.js → mobile-CZNFYieO.js} +2 -2
  39. package/dist/assets/{mobileBackNavigation-D2yUxPpG.js → mobileBackNavigation-f8AMDP0N.js} +1 -1
  40. package/dist/assets/{multirun-DKsVtdZX.js → multirun-Cvl4FMPo.js} +1 -1
  41. package/dist/assets/{native-config-Bpk4DOW1.js → native-config-DLJCZcXh.js} +1 -1
  42. package/dist/assets/{projectMeta-yox5XHhN.js → projectMeta-D3cfkJyk.js} +1 -1
  43. package/dist/assets/{renderElectronMiniChatApp-CdEZXhzq.js → renderElectronMiniChatApp-_n69Pa_v.js} +2 -2
  44. package/dist/assets/renderMobileApp-DUiUPyd7.js +28 -0
  45. package/dist/assets/{runtimeConfig-B8s9sTX_.js → runtimeConfig-DwFJL5bm.js} +1 -1
  46. package/dist/assets/runtimeEndpointReset-C_1daihM.js +149 -0
  47. package/dist/assets/{scheduledTaskNavigation-DUskP6qh.js → scheduledTaskNavigation-DvSpMLdG.js} +1 -1
  48. package/dist/assets/sessionChangeSummary-evl_LmRN.js +1 -0
  49. package/dist/assets/sessionLookup-CJ8mXxHt.js +1 -0
  50. package/dist/assets/{sortable-tabs-strip-Benojjgi.js → sortable-tabs-strip-CrjW2aQk.js} +1 -1
  51. package/dist/assets/{speechSettingsQueries-CjTT-adl.js → speechSettingsQueries-xWFTnUfF.js} +1 -1
  52. package/dist/assets/src-omVWmz3o.css +2 -0
  53. package/dist/assets/{textarea-C5vjnZcE.js → textarea-BkOdxUN0.js} +1 -1
  54. package/dist/assets/{tooltip-C73L9gDf.js → tooltip-BQQoK7L_.js} +1 -1
  55. package/dist/assets/{types-Bu1xM0fS.js → types-BzF7Dhzq.js} +1 -1
  56. package/dist/assets/{useAppFontEffects-D6yauGdg.js → useAppFontEffects-lmtncXsi.js} +7 -7
  57. package/dist/assets/{useDesktopWindowControlsLayout-SKHaFoVu.js → useDesktopWindowControlsLayout-BY0_whx0.js} +1 -1
  58. package/dist/assets/{useEffectiveDirectory-D6GwXhDS.js → useEffectiveDirectory-CqkTJqRg.js} +1 -1
  59. package/dist/assets/{useMobileNavigationStore-ByrZJd5L.js → useMobileNavigationStore-BURkCJuM.js} +4 -4
  60. package/dist/assets/{useWorkerHighlightedLines-CwC34Jql.js → useWorkerHighlightedLines-Bla356tF.js} +1 -1
  61. package/dist/index.html +6 -6
  62. package/dist/mini-chat.html +6 -6
  63. package/dist/mobile.html +6 -6
  64. package/package.json +1 -1
  65. package/server/lib/assistants/DOCUMENTATION.md +13 -2
  66. package/server/lib/assistants/contact-store.js +2 -1
  67. package/server/lib/assistants/contact-store.test.js +13 -3
  68. package/server/lib/assistants/routes.js +2 -1
  69. package/server/lib/assistants/service.js +54 -7
  70. package/server/lib/assistants/service.test.js +59 -10
  71. package/server/lib/content-search/DOCUMENTATION.md +5 -1
  72. package/server/lib/opencode/DOCUMENTATION.md +8 -7
  73. package/server/lib/opencode/config-entity-routes.js +5 -1
  74. package/server/lib/opencode/config-entity-routes.test.js +23 -0
  75. package/server/lib/opencode/ensure-cli.js +48 -11
  76. package/server/lib/opencode/ensure-cli.test.js +53 -1
  77. package/server/lib/opencode/env-runtime.js +5 -5
  78. package/server/lib/opencode/feature-routes-runtime.js +1 -1
  79. package/server/lib/opencode/terminal-path.js +67 -0
  80. package/server/lib/opencode/terminal-path.test.js +68 -0
  81. package/server/lib/relay/DOCUMENTATION.md +2 -0
  82. package/server/lib/relay/service.js +1 -1
  83. package/server/lib/relay/service.test.js +3 -3
  84. package/dist/assets/AssistantView-D3j8FlaF.js +0 -3
  85. package/dist/assets/MobileShareBridge-BMQKnoEb.js +0 -4
  86. package/dist/assets/MobileTabPageHeader-Cco8ToA6.js +0 -2
  87. package/dist/assets/SettingsView-Bx-5WRtO.js +0 -26
  88. package/dist/assets/button-_ReBqWzC.js +0 -1
  89. package/dist/assets/renderMobileApp-BoV5wjPF.js +0 -28
  90. package/dist/assets/runtimeEndpointReset-BswmG9Bb.js +0 -149
  91. package/dist/assets/sessionChangeSummary-BGbmGpQw.js +0 -1
  92. package/dist/assets/sessionLookup-CGJA6W7O.js +0 -1
  93. package/dist/assets/src-CmermOKP.css +0 -2
@@ -0,0 +1,2 @@
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{a,o,r as s,s as c,t as l,u}from"./queryRuntime-DKGLQtb9.js";import{$t as d,Bt as f,an as p,d as m,en as h,et as g,gn as _,i as v,in as y,on as b,rn as x,tn as S,tt as C,zt as w}from"./persistence-Dzooc9Xg.js";import{a as T,i as E,r as D}from"./vendor-zustand-o69pgTEK.js";import{it as O,nt as k,rt as A}from"./vendor-base-ui-CdzJ6My_.js";import{Ct as j,Nt as ee,n as M,t as N}from"./platform-7bX6qtBV.js";import{b as P,n as F}from"./useUIStore-NMQx_cnG.js";import{n as te}from"./vendor-react-BP2cRVqX.js";import{o as I}from"./vendor-tanstack-react-query-CdqCAt40.js";import{o as ne}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{a as re,t as ie}from"./types-BzF7Dhzq.js";import{$ as ae,A as oe,B as L,G as se,H as R,J as ce,L as le,P as z,T as ue,U as de,W as fe,X as pe,Y as me,a as he,at as B,dt as ge,f as _e,ft as ve,g as ye,l as be,pt as xe,st as Se,z as V}from"./vendor-codemirror-autocomplete-7c2L_4dM.js";import{c as Ce,o as H,r as we}from"./vendor-codemirror-lang-angular-DXOgWEVj.js";import{n as Te,r as Ee}from"./vendor-codemirror-lang-json-mLulNbwB.js";import{n as De}from"./vendor-codemirror-lang-markdown-CV1IO6Qs.js";import{n as Oe}from"./vendor-codemirror-lang-python-YM2WVLHF.js";import{O as ke}from"./vendor-codemirror-legacy-modes-DwltVFbT.js";import{n as Ae}from"./vendor-reactuses-core-BpfIZ1tg.js";import{a as je,d as Me,f as U,p as Ne,r as W,t as G}from"./button-D_HdP1Oy.js";import{Pr as Pe,Rr as K,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-BURkCJuM.js";import{n as Ye}from"./useThemeSystem-8jhE4Zyk.js";import{n as q}from"./Icon-BXTZRnIO.js";import{a as Xe,n as Ze,o as Qe,r as $e,t as et}from"./dialog-B_87Teec.js";import{L as tt,_ as nt,b as rt,c as it,n as at,s as ot,u as st}from"./gitApi-B1arMnHR.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-D3cfkJyk.js";import{t as yt}from"./input-DDfJnn8e.js";import{i as bt,n as xt,t as St}from"./tooltip-BQQoK7L_.js";import{$t as Ct,F as wt,G as Tt,Gt as Et,J as Dt,Jt as Ot,Kt as kt,M as At,P as jt,U as Mt,W as Nt,Xt as Pt,Yt as Ft,a as It,in as Lt,it as Rt,k as zt,q as Bt,qt as Vt,rt as Ht,ut as Ut,v as Wt}from"./speechSettingsQueries-xWFTnUfF.js";import{i as Gt,n as Kt}from"./OverlayScrollbar-CbWvRXm6.js";import{n as qt,t as Jt}from"./textarea-BkOdxUN0.js";import{n as Yt}from"./MarkdownRenderer-Va7Wdk98.js";import{a as Xt}from"./url-Be8VCT8M.js";import{r as Zt}from"./markdown-worker-CkO3sT4Y.js";import{i as Qt,n as $t,o as en}from"./mcpQueries-BxbbmYAd.js";import{n as tn,r as nn,t as rn}from"./collapsible-sUU_ORMe.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}))],J=te(),Y=A();function wn(e){let t=(0,J.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Y.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,Y.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,Y.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?ee.getScopedApiClient(t):ee.getApiClient()},X=e=>e?{location:{directory:e}}:void 0,Z=new Map,Q=(e,t)=>JSON.stringify([r(),En(t),e]),kn=async(e,t,n)=>{let r=(await e.mcp.list(X(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,...X(n)})).data},An=e=>$t(e===void 0?j.getState().currentDirectory:e),jn=T()(D((e,t)=>({diagnosticsByDirectory:{},getDiagnosticForDirectory:e=>{let n=En(An(e));return t().diagnosticsByDirectory[n]??Tn},clearDiagnostic:(t,n,r)=>{let i=En(An(n),r);e(e=>({diagnosticsByDirectory:Dn(e.diagnosticsByDirectory,i,t)}))},connect:async(t,r)=>{let i=An(r),o=n(),s=En(i,o),c=On(i);try{await c.mcp.connect({server:t,...X(i)})}catch(n){let r=n instanceof Error?n.message:`Connection failed`;throw e(e=>({diagnosticsByDirectory:{...e.diagnosticsByDirectory,[s]:{...e.diagnosticsByDirectory[s]??{},[t]:{status:`failed`,error:r}}}})),n}await en(a,i,o),e(e=>({diagnosticsByDirectory:Dn(e.diagnosticsByDirectory,s,t)}))},disconnect:async(t,r)=>{let i=An(r),o=n(),s=En(i,o);await On(i).mcp.disconnect({server:t,...X(i)}),await en(a,i,o),e(e=>({diagnosticsByDirectory:Dn(e.diagnosticsByDirectory,s,t)}))},startAuth:async(e,t)=>{let n=An(t),r=Q(e,n),i=On(n),a=await kn(i,e,n),o=a.methods.find(e=>e.type===`oauth`);if(!o)throw Error(`MCP server "${e}" has no OAuth method`);if(r!==Q(e,n))throw Error(`MCP authorization runtime changed`);let s=Z.get(r);if(s&&(await i.integration.oauth.cancel({integrationID:s.integrationID,attemptID:s.attempt.attemptID,...X(n)}),Z.delete(r)),r!==Q(e,n))throw Error(`MCP authorization runtime changed`);let{data:c}=await i.integration.oauth.connect({integrationID:a.id,methodID:o.id,...X(n)});if(r!==Q(e,n))throw Error(`MCP authorization runtime changed`);for(let[e,t]of Z)t.attempt.time.expires<=Date.now()&&Z.delete(e);return Z.set(r,{integrationID:a.id,attempt:c}),c},authStatus:async(e,t)=>{let n=An(t),r=Q(e,n),i=Z.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,...X(n)});if(r!==Q(e,n))throw Error(`MCP authorization runtime changed`);return a.status!==`pending`&&Z.get(r)===i&&Z.delete(r),a},completeAuth:async(e,t,r)=>{let i=An(r),o=n(),s=Q(e,i),c=Z.get(s);if(!c||c.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:c.integrationID,attemptID:c.attempt.attemptID,code:t.trim(),...X(i)}),Z.get(s)===c&&Z.delete(s),s!==Q(e,i))throw Error(`MCP authorization runtime changed`);await en(a,i,o)},clearAuth:async(e,t)=>{let r=An(t),i=n(),o=Q(e,r),s=On(r),c=await kn(s,e,r);if(o!==Q(e,r))throw Error(`MCP authorization runtime changed`);let l=Z.get(o);l&&(await s.integration.oauth.cancel({integrationID:l.integrationID,attemptID:l.attempt.attemptID,...X(r)}),Z.delete(o));let u=new Set(c.connections.flatMap(e=>e.type===`credential`?[e.id]:[]));for(let t of u){if(o!==Q(e,r))throw Error(`MCP authorization runtime changed`);await s.credential.remove({credentialID:t})}if(o!==Q(e,r))throw Error(`MCP authorization runtime changed`);await en(a,r,i)},testConnection:async(t,r)=>{let i=An(r),o=n(),s=En(i,o),c=On(i),l=Qt(a,i,o)[t]?.status===`connected`,u,d;try{await c.mcp.connect({server:t,...X(i)})}catch(n){u=n instanceof Error?n.message:`Connection failed`,e(e=>({diagnosticsByDirectory:{...e.diagnosticsByDirectory,[s]:{...e.diagnosticsByDirectory[s]??{},[t]:{status:`failed`,error:u??`Connection failed`}}}}))}let f=(await en(a,i,o))[t],p=f;if(!l&&f?.status===`connected`){try{await c.mcp.disconnect({server:t,...X(i)})}catch(e){d=`Connection test succeeded, but cleanup disconnect failed: ${e instanceof Error?e.message:`Disconnect failed`}`}await en(a,i,o)}return u||e(e=>({diagnosticsByDirectory:Dn(e.diagnosticsByDirectory,s,t)})),{status:p??Qt(a,i,o)[t],error:u,warning:d}}}))),$=e(O(),1),Mn=`https://yuri-updates.xiaobe.top/v1/update/check`,Nn=`https://yuri-origin.xiaobe.top/v1/update/check`,Pn=`https://github.com/yee94/yuri/releases/latest`,Fn=`https://github.com/yee94/yuri/releases`,In=`https://testflight.apple.com/join/pN5SSHeg`,Ln=1e4;function Rn(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 zn(e,t){let n=Rn(e),r=Rn(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 Bn(){return[Mn,Nn]}function Vn(e,t,n=Date.now){let r=e-n();return r<=0||t<=0?null:Math.max(1,Math.ceil(r/t))}function Hn(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 Un(e,t,n,r){try{if(M())try{let{CapacitorHttp:r}=await ne(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 Wn(e,t){return e===`ios`?In:`${Fn}/download/v${t}/app-release.apk`}function Gn(e,t,n){if(typeof e.latestVersion!=`string`||e.latestVersion.trim().length===0)return null;let r=e.latestVersion.trim(),i=zn(r,t);if(i<0)return null;let a=typeof e.releaseNotesUrl==`string`&&e.releaseNotesUrl.trim().length>0?e.releaseNotesUrl.trim():`${Fn}/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():Wn(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 Kn(e,t,n,r){let i=await Un(e,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify(Hn(t))},n,r);if(!i?.ok)return null;let a;try{a=await i.json()}catch{return null}return Gn(a,t.currentVersion,t.platform)}async function qn(e,t,n,r){let i=await Un(Pn,{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:Pn,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=zn(s,e),l=`${Fn}/tag/v${s}`;return{available:c>0,version:s,currentVersion:e,releaseUrl:l,downloadUrl:Wn(t,s)}}async function Jn(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=Bn(),a=r()+Ln;for(let[t,o]of i.entries()){let s=Vn(a,i.length-t+1,r);if(s===null)break;let c=await Kn(o,e,s,n);if(c)return c}let o=Vn(a,1,r);if(o!==null){let r=await qn(t,e.platform,o,n);if(r)return r}return{available:!1,currentVersion:t,error:`Unable to check for mobile updates`}}function Yn(){if(typeof window>`u`)return`unknown`;try{let{deviceType:e}=Kt();return e}catch{return`unknown`}}function Xn(){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 Zn(){let e=N();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 Qn(e){let t=F.getState().reportUsage,n=new URLSearchParams({reportUsage:t?`true`:`false`});return n.set(`deviceClass`,Yn()),n.set(`arch`,Xn()),n.set(`platform`,Zn()),e===`desktop`?(n.set(`appType`,`desktop-electron`),n.set(`instanceMode`,d()?`local`:`remote`),n):e===`vscode`?(n.set(`appType`,`vscode`),n.set(`instanceMode`,`local`),n):e===`mobile`?(n.set(`appType`,`mobile-capacitor`),n.set(`instanceMode`,`remote`),n):(n.set(`appType`,`web`),n.set(`instanceMode`,`unknown`),n)}async function $n(e,t){let n=t??`unknown`;try{let r=Qn(e),i=typeof window<`u`?window.__VSCODE_CONFIG__?.extensionVersion:void 0;t?r.set(`currentVersion`,t):e===`vscode`&&i&&r.set(`currentVersion`,i);let a=await u(`/api/yuri/update-check?${r.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),o=null;try{o=await a.json()}catch{o=null}if(!a.ok)return{available:!1,currentVersion:n,error:typeof o?.error==`string`&&o.error.trim().length>0?o.error.trim():`Server responded with ${a.status}`};if(!o)return{available:!1,currentVersion:n,error:`Update check returned an invalid response`};let s=typeof o.error==`string`&&o.error.trim().length>0?o.error.trim():void 0;return{available:o.available===!0,version:typeof o.version==`string`?o.version:void 0,currentVersion:typeof o.currentVersion==`string`?o.currentVersion:n,body:typeof o.body==`string`?o.body:void 0,releaseUrl:typeof o.releaseUrl==`string`?o.releaseUrl:void 0,downloadUrl:typeof o.downloadUrl==`string`?o.downloadUrl:void 0,nextSuggestedCheckInSec:typeof o.nextSuggestedCheckInSec==`number`&&Number.isFinite(o.nextSuggestedCheckInSec)?o.nextSuggestedCheckInSec:void 0,packageManager:typeof o.packageManager==`string`?o.packageManager:void 0,updateCommand:typeof o.updateCommand==`string`?o.updateCommand:void 0,error:s}}catch(e){return console.warn(`Failed to check for updates:`,e),{available:!1,currentVersion:n,error:e instanceof Error?e.message:`Failed to check for updates`}}}function er(){return M()?`mobile`:S()?`desktop`:x()?`vscode`:y()?`web`:null}var tr={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 nr(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 rr=0,ir=T()((e,t)=>({...tr,checkForUpdates:async()=>{let n=er();if(!n)return null;let r=++rr;e({checking:!0,error:null,runtimeType:n});try{let i=null,a=null;if(n===`desktop`){let n=F.getState().otaChannelOverride;t().lastOtaChannelOverride!==n&&e({downloaded:!1,downloading:!1,available:!1,info:null,otaDecision:null,progress:null,otaPhase:`checking`});let i=await w(n);if(r!==rr||F.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 $n(`web`),a=i?.nextSuggestedCheckInSec??null;else if(n===`vscode`)a=(await $n(`vscode`))?.nextSuggestedCheckInSec??null;else if(n===`mobile`){let n=await re()??`unknown`,r=M()?c()?.mobileUpdates:void 0,o=F.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=nr(a,n),c=(i?void 0:t().otaDecision?.ota.bundle?.bundleId)!==a.ota.bundle?.bundleId,l=!i&&t().downloaded&&!c;return e({checking:!1,available:s.available,info:s.info,error:s.info.error??null,lastChecked:Date.now(),nextCheckInSec:a.nextCheckInSec,otaDecision:a,otaPhase:l?`pending_restart`:s.otaPhase,lastOtaChannelOverride:o,...c||i?{downloaded:!1,otaDownloadSkipped:!1,progress:null}:{}}),a.nextCheckInSec}catch(t){if(!(t instanceof ie)){let r=t instanceof Error?t.message:`Mobile OTA check failed`;return e({checking:!1,available:!1,info:{available:!1,currentVersion:n},error:r,lastChecked:Date.now(),otaDecision:null,otaPhase:`error`,lastOtaChannelOverride:o}),null}}return i=await Jn({currentVersion:n,platform:Zn()===`ios`?`ios`:`android`,deviceClass:Yn(),arch:Xn(),reportUsage:F.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===rr&&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=c()?.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=F.getState().otaChannelOverride,r=await w(n);if(n!==F.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(!S())return()=>{};let n=[],r=await p(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 b(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=c()?.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 _())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(tr)}})),ar=`https://github.com/yee94/yuri/releases`;function or(e){let t=new Date(`${e}T00:00:00`);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(Ne(),{year:`numeric`,month:`short`,day:`numeric`}).format(t)}function sr(e){return e.replace(/^## \[[^\]]+\] - \d{4}-\d{2}-\d{2}\s*\n?/,``).trim()}function cr(e){return e.replace(/(^|[^a-zA-Z0-9])@([a-zA-Z0-9-]+)/g,`$1[@$2](https://github.com/$2)`)}function lr(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 ur(e){let t=/^## \[(\d+\.\d+\.\d+)\] - (\d{4}-\d{2}-\d{2})\s*$/gm,n=[],r;for(;(r=t.exec(e))!==null;)n.push({version:r[1]??``,date:r[2]??``,start:r.index});return n.length===0?[]:n.map((t,r)=>{let i=n[r+1]?.start??e.length,a=e.slice(t.start,i).trim();return{version:t.version,date:t.date,start:t.start,end:i,raw:a}})}var dr=2e3,fr=6e5;async function pr(){try{let e=await u(`/api/yuri/update-install`,{method:`POST`,headers:{"Content-Type":`application/json`}});return e.ok?{success:!0,autoRestart:(await e.json().catch(()=>({}))).autoRestart!==!1}:{success:!1,error:(await e.json().catch(()=>({}))).error||`Server error: ${e.status}`}}catch(e){return{success:!1,error:e instanceof Error?e.message:void 0}}}async function mr(){try{return(await u(`/health`,{method:`GET`,headers:{Accept:`application/json`}})).ok}catch{return!1}}async function hr(e,t=Math.ceil(fr/dr),n=dr){for(let r=0;r<t;r++){try{let t=await u(`/api/yuri/update-check`,{method:`GET`,headers:{Accept:`application/json`}});if(t.ok){let n=await t.json().catch(()=>null);if(n&&n.available===!1||n&&typeof n.currentVersion==`string`&&typeof e==`string`&&n.currentVersion!==e)return!0}else if((t.status===401||t.status===403)&&await mr())return!0}catch{}await new Promise(e=>setTimeout(e,n))}return!1}var gr=({open:e,onOpenChange:t,info:n,downloading:r,downloaded:i,progress:a,error:o,onDownload:s,onRestart:c,runtimeType:l=`desktop`})=>{let{t:u}=U(),[d,f]=(0,$.useState)(!1),[p,m]=(0,$.useState)(`idle`),[h,g]=(0,$.useState)(null),_=ir(e=>e.otaDownloadSkipped),v=n?.releaseUrl||(n?.version?`${ar}/tag/v${n.version}`:ar),y=n?.downloadUrl,b=a?.total?Math.round(a.downloaded/a.total*100):0,x=l===`web`,S=l===`mobile`,C=S&&n?.manualUpdate===!0&&!!y,w=S&&n?.inAppApply===!0,T=l===`desktop`&&n?.manualUpdate===!0,E=n?.updateCommand||`yuri update`,D=Ae(e=>{!e&&w&&i&&ir.getState().dismiss(),t(e)}),O=Ae(()=>{ir.getState().dismiss(),t(!1)});(0,$.useEffect)(()=>{e||(m(`idle`),g(null))},[e]);let k=async()=>{(await Me(E)).ok&&(f(!0),setTimeout(()=>f(!1),2e3))},A=(0,$.useCallback)(async e=>{await Xt(e)},[]),j=(0,$.useCallback)(async()=>{m(`updating`),g(null);let e=await pr();if(!e.success){m(`error`),g(e.error||u(`updateDialog.error.updateFailed`));return}e.autoRestart&&(m(`restarting`),await new Promise(e=>setTimeout(e,2e3))),m(`reconnecting`),await hr(n?.currentVersion)?window.location.reload():(m(`error`),g(u(`updateDialog.error.takingLonger`)))},[n?.currentVersion,u]),ee=(0,$.useCallback)(()=>{y&&A(y)},[A,y]),M=p!==`idle`&&p!==`error`,N=(0,$.useMemo)(()=>{if(!n?.body)return null;let e=n.body.trim();if(!e)return null;let t=ur(e);if(t.length===0)return{kind:`raw`,title:u(`updateDialog.changelog.title`),content:cr(e)};let r=[...t].sort((e,t)=>lr(e.version,t.version));return{kind:`sections`,title:u(`updateDialog.changelog.title`),sections:r.map(t=>({version:t.version,dateLabel:or(t.date),content:cr(sr(t.raw)||e)}))}},[n?.body,u]);return(0,Y.jsx)(et,{open:e,onOpenChange:M?void 0:D,children:(0,Y.jsxs)(Ze,{className:`max-w-4xl gap-0 p-4 sm:p-5 bg-background border-[var(--interactive-border)]`,showCloseButton:!0,children:[(0,Y.jsxs)(`div`,{className:`mb-3 pr-8 sm:mb-4`,children:[(0,Y.jsxs)(Qe,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(q,{name:`download-cloud`,className:`h-5 w-5 text-[var(--primary-base)]`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:u(p===`restarting`||p===`reconnecting`?`updateDialog.header.updating`:`updateDialog.header.updateAvailable`)})]}),(n?.currentVersion||n?.version)&&(0,Y.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5 pl-7 font-mono text-[11px] leading-4 tracking-[-0.01em] tabular-nums sm:text-xs`,children:[n?.currentVersion&&(0,Y.jsx)(`span`,{className:`text-muted-foreground/75`,children:n.currentVersion}),n?.currentVersion&&n?.version&&(0,Y.jsx)(`span`,{className:`text-muted-foreground/40`,children:`→`}),n?.version&&(0,Y.jsx)(`span`,{className:`font-medium text-[var(--primary-base)]`,children:n.version})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[x&&M&&(0,Y.jsxs)(`div`,{className:`rounded-lg bg-[var(--surface-elevated)]/30 p-5 border border-[var(--surface-subtle)]`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(q,{name:`loader`,className:`h-5 w-5 animate-spin text-[var(--primary-base)]`}),(0,Y.jsxs)(`div`,{className:`typography-ui-label text-foreground`,children:[p===`updating`&&u(`updateDialog.status.installingUpdate`),p===`restarting`&&u(`updateDialog.status.serverRestarting`),p===`reconnecting`&&u(`updateDialog.status.waitingForServer`)]})]}),(0,Y.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:u(`updateDialog.status.autoReloadHint`)})]}),N&&!M&&(0,Y.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20`,children:[(0,Y.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,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--primary-base)]`,"aria-hidden":`true`}),(0,Y.jsx)(`h3`,{className:`typography-ui-caption font-medium text-muted-foreground`,children:N.title})]}),(0,Y.jsx)(qt,{className:`max-h-[min(42dvh,22rem)] p-0 sm:max-h-[400px]`,fillContainer:!1,children:N.kind===`raw`?(0,Y.jsx)(`div`,{className:`break-words p-3.5 text-[13px] leading-[1.65] text-foreground sm:p-4 sm:text-sm [&_.markdown-content]:leading-[1.65] [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline`,onClickCapture:e=>{let t=e.target.closest(`a`);t&&t.href&&(e.preventDefault(),e.stopPropagation(),A(t.href))},children:(0,Y.jsx)(Yt,{content:N.content,disableLinkSafety:!0,enableFileReferences:!1})}):(0,Y.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:N.sections.map(e=>(0,Y.jsxs)(`div`,{className:`p-3.5 sm:p-4`,children:[(0,Y.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-center gap-x-2 gap-y-1 sm:mb-3`,children:[(0,Y.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,Y.jsx)(`span`,{className:`text-[11px] leading-4 text-muted-foreground/75 sm:text-xs`,children:e.dateLabel})]}),(0,Y.jsx)(`div`,{className:`break-words text-[13px] leading-[1.65] text-foreground sm:text-sm [&_.markdown-content]:leading-[1.65] [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline`,onClickCapture:e=>{let t=e.target.closest(`a`);t&&t.href&&(e.preventDefault(),e.stopPropagation(),A(t.href))},children:(0,Y.jsx)(Yt,{content:e.content,disableLinkSafety:!0,enableFileReferences:!1})})]},e.version))})})]}),x&&p===`error`&&(0,Y.jsxs)(`div`,{className:`space-y-2 mt-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 typography-meta text-muted-foreground`,children:[(0,Y.jsx)(q,{name:`terminal`,className:`h-4 w-4`}),(0,Y.jsx)(`span`,{children:u(`updateDialog.fallback.updateViaTerminal`)})]}),(0,Y.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,Y.jsx)(`code`,{className:`flex-1 font-mono text-sm text-foreground overflow-x-auto whitespace-nowrap`,children:E}),(0,Y.jsx)(`button`,{onClick:k,className:W(`flex items-center justify-center p-2 rounded`,`text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]`,`transition-colors`,d&&`text-[var(--status-success)]`),title:u(d?`updateDialog.actions.copied`:`updateDialog.actions.copyCommand`),children:d?(0,Y.jsx)(q,{name:`check`,className:`h-4 w-4`}):(0,Y.jsx)(q,{name:`clipboard`,className:`h-4 w-4`})})]})]}),!x&&(!S||w)&&r&&(0,Y.jsxs)(`div`,{className:`mt-3 space-y-2 rounded-lg border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20 px-3.5 py-3 sm:mt-4 sm:px-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground sm:text-[13px]`,children:u(`updateDialog.status.downloadingPayload`)}),(0,Y.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] leading-4 text-foreground tabular-nums sm:text-xs`,children:[b,`%`]})]}),(0,Y.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-[var(--surface-subtle)] sm:h-1.5`,children:(0,Y.jsx)(`div`,{className:`h-full rounded-full bg-[var(--primary-base)] transition-all duration-300`,style:{width:`${b}%`}})})]}),(o||h)&&(0,Y.jsx)(`div`,{className:`p-3 mt-4 bg-[var(--status-error-background)] border border-[var(--status-error-border)] rounded-lg`,children:(0,Y.jsx)(`p`,{className:`text-sm text-[var(--status-error)]`,children:o||h})})]}),w&&i&&_&&(0,Y.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,Y.jsx)(q,{name:`check`,className:`h-4 w-4 shrink-0`}),(0,Y.jsx)(`span`,{children:u(`updateDialog.status.otaBundleReused`)})]}),(0,Y.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-4`,children:[!S||C?(0,Y.jsxs)(`a`,{href:S?y:v,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground hover:text-foreground transition-colors shrink-0`,children:[(0,Y.jsx)(q,{name:`external-link`,className:`h-4 w-4`}),`GitHub`]}):(0,Y.jsx)(`span`,{}),(0,Y.jsxs)(`div`,{className:`flex-1 flex justify-end`,children:[!x&&(!S||w)&&!T&&!i&&!r&&(0,Y.jsxs)(G,{onClick:s,size:`default`,children:[(0,Y.jsx)(q,{name:`download`,className:`h-4 w-4`}),u(w?`updateDialog.actions.applyOtaNow`:`updateDialog.actions.downloadUpdate`)]}),!x&&!S&&T&&!i&&!r&&(0,Y.jsxs)(G,{onClick:()=>void A(v),size:`default`,children:[(0,Y.jsx)(q,{name:`external-link`,className:`h-4 w-4`}),u(`updateDialog.actions.openMobileUpdate`)]}),!x&&(!S||w)&&r&&(0,Y.jsxs)(G,{disabled:!0,size:`default`,children:[(0,Y.jsx)(q,{name:`loader`,className:`h-4 w-4 animate-spin`}),u(`updateDialog.status.downloading`)]}),!x&&(!S||w)&&i&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[w&&(0,Y.jsx)(G,{onClick:O,variant:`ghost`,size:`default`,children:u(`updateDialog.actions.later`)}),(0,Y.jsxs)(G,{onClick:c,size:`default`,children:[(0,Y.jsx)(q,{name:`restart`,className:`h-4 w-4`}),u(`updateDialog.actions.restartToUpdate`)]})]}),S&&!w&&C&&(0,Y.jsxs)(G,{onClick:ee,size:`default`,children:[(0,Y.jsx)(q,{name:`external-link`,className:`h-4 w-4`}),u(`updateDialog.actions.openMobileUpdate`)]}),x&&!M&&(0,Y.jsxs)(G,{onClick:j,size:`default`,children:[(0,Y.jsx)(q,{name:`download`,className:`h-4 w-4`}),u(`updateDialog.actions.updateNow`)]}),x&&M&&(0,Y.jsxs)(G,{disabled:!0,size:`default`,children:[(0,Y.jsx)(q,{name:`loader`,className:`h-4 w-4 animate-spin`}),u(`updateDialog.status.updating`)]})]})]})]})})},_r=e(k(),1);function vr(e){let t=(0,J.c)(10),{children:n,actions:r,className:i}=e,a;t[0]===i?a=t[1]:(a=W(`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,Y.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,Y.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,Y.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 yr(e){let t=(0,J.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=W(`yuri-settings-group`,c),t[0]=c,t[1]=f);let p;t[2]!==r||t[3]!==n||t[4]!==d?(p=r?(0,Y.jsx)(vr,{actions:r,children:n?(0,Y.jsx)(`div`,{className:`yuri-settings-group-label`,"data-settings-label-script":d,children:n}):null}):n?(0,Y.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=W(`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,Y.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,Y.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,Y.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 br(e){let t=(0,J.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,Y.jsx)(xr,{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,Y.jsx)(yr,{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 xr(e){let t=(0,J.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=W(`yuri-settings-group-row yuri-settings-split-row`,o),t[0]=o,t[1]=l);let u;t[2]===s?u=t[3]:(u=W(`yuri-settings-split-row-copy`,s),t[2]=s,t[3]=u);let d;t[4]===n?d=t[5]:(d=n?(0,Y.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,Y.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,Y.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=W(`yuri-settings-split-row-control`,c),t[12]=c,t[13]=m);let h;t[14]!==r||t[15]!==m?(h=(0,Y.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,Y.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 Sr(e){let t=(0,J.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=Cr,m=u?`cursor-not-allowed`:`cursor-pointer`,h;t[4]!==l||t[5]!==m?(h=W(`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,Y.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,Y.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,Y.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,Y.jsx)(`div`,{"data-settings-value":``,className:`yuri-settings-split-row-control`,children:(0,Y.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,Y.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 Cr(e){return e instanceof HTMLElement&&e.closest(`button, a, input, select, textarea`)!==null}var wr=`/mcp/oauth/callback`,Tr=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}},Er=e=>{let t=Or(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}},Dr=e=>{let t=e.get(`state`);return typeof t==`string`&&t.trim()||null},Or=e=>{if(typeof e!=`string`||!e.trim())return null;let t=Tr(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}},kr=e=>typeof e==`object`&&!!e&&`updateStatus`in e&&typeof e.updateStatus==`function`,Ar=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 kr(r)&&r.updateStatus(),{top:!1,dom:t,destroy(){n.state.statusbar===t&&(n.state.statusbar=null)}}};function jr(e){return e?[hn(),ae.of(Ar),se()]:[]}var Mr={next:`Next match`,prev:`Previous match`,select:`Select all matches`,replace:`Replace`,replaceAll:`Replace all`,close:`Close`},Nr={case:`Match case`,re:`Regular expression`,word:`Match whole word`};function Pr(e){let t=e.querySelector(`.cm-search`);if(t){for(let[e,n]of Object.entries(Mr)){let r=t.querySelector(`button[name="${e}"]`);r&&!r.title&&(r.title=n)}for(let[e,n]of Object.entries(Nr)){let r=t.querySelector(`input[name="${e}"]`)?.parentElement;r&&!r.title&&(r.title=n)}}}var Fr=new WeakMap;function Ir(e,t){let n=dn(e.state);if(!n.valid)return Fr.delete(e),0;let r=Fr.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 Fr.set(e,{query:n,doc:e.state.doc,total:a}),a}function Lr(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 Rr(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=Ir(t,n),o=a===0?0:Lr(t);i.textContent=a===0?``:`${o}/${a}`}var zr=new B,Br=new B,Vr=new B,Hr=new B,Ur=new B,Wr=new B,Gr=new B,Kr=e=>e,qr=ue,Jr=ln,Yr=pn,Xr=class extends fe{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(){}},Zr=(e,t)=>!e||e.length===0?[]:xe.define({create(n){let r=new ge,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,L.widget({widget:new Xr(e.id,t),block:!0,side:1}))}return r.finish()},update(e,t){return e.map(t.changes)},provide:e=>R.decorations.from(e)}),Qr=e=>{if(!e)return[];let t=Math.max(1,e.start),n=Math.max(t,e.end);return de.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 ge;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,L.line({class:`yuri-cm-selected-line`}))}return r.finish()}},{decorations:e=>e.decorations})};function $r({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=Se.create({doc:g.current,extensions:[...e?[R.cspNonce.of(e)]:[],ce({fixed:!0}),zr.of(pe(a)),sn(),oe.of(` `),Gr.of(jr(p)),me.of([on,...an,...cn]),R.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)&&Rr(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)}),Br.of(R.editable.of(!i)),Vr.of(n??[]),Hr.of(Qr(o)),Ur.of(Zr(l,C.current)),Wr.of(u?[fn({top:!0}),me.of(Kr(mn))]:[])]});return h.current=new R({state:t,parent:m.current}),qr(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:[zr.reconfigure(pe(a)),Br.reconfigure(R.editable.of(!i)),Vr.reconfigure(n??[]),Hr.reconfigure(Qr(o)),Ur.reconfigure(Zr(l,C.current)),Wr.reconfigure(u?[fn({top:!0}),me.of(Kr(mn))]:[])]}),qr(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:Gr.reconfigure(jr(p))}))},[p]),$.useEffect(()=>{let e=h.current;!e||u===!1||(d?(Jr(e),requestAnimationFrame(()=>{Pr(e.dom),Rr(e.dom,e,!0)})):Yr(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}}),qr(t,t.state.doc.length,300),t.requestMeasure(),requestAnimationFrame(()=>D(t)))},[e,D]),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{ref:m,className:W(`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,_r.createPortal)(e.content,e.container,e.id))]})}var ei=_e.define(ke),ti=Ee.data.of({commentTokens:{line:`//`,block:{open:`/*`,close:`*/`}}});function ni(e){let t=e.trim().toLowerCase();switch(t){case`bash`:case`sh`:case`zsh`:case`shell`:case`shellsession`:case`console`:return ei;case`json`:case`jsonc`:case`json5`:return Te().language;case`js`:case`javascript`:return H().language;case`jsx`:return H({jsx:!0}).language;case`ts`:case`typescript`:return H({typescript:!0}).language;case`tsx`:return H({typescript:!0,jsx:!0}).language;case`html`:return we().language;case`css`:return Ce().language;case`py`:case`python`:return Oe().language;case`md`:case`markdown`:case`mdown`:case`mkd`:return De().language;case`heex`:case`eex`:case`leex`:return we().language;default:return be.matchLanguageName(_n,t,!0)}}var ri=e=>e.split(`/`).pop()?.toLowerCase()??``,ii=e=>{let t=ri(e);return t?be.matchFilename(_n,t):null},ai=()=>z(he.define([{tag:[V.heading1,V.heading2,V.heading3,V.heading4,V.heading5,V.heading6],fontWeight:`600`},{tag:V.strong,fontWeight:`600`},{tag:V.emphasis,fontStyle:`italic`},{tag:V.strikethrough,textDecoration:`line-through`},{tag:[V.link,V.url],color:`var(--markdown-link, currentColor)`,textDecoration:`underline`},{tag:V.monospace,color:`var(--markdown-inline-code, currentColor)`,backgroundColor:`var(--markdown-inline-code-bg, transparent)`},{tag:V.quote,color:`var(--markdown-blockquote, currentColor)`,fontStyle:`italic`},{tag:V.list,color:`color-mix(in srgb, var(--muted-foreground) 40%, var(--foreground) 60%)`},{tag:V.heading,color:`var(--markdown-heading1, currentColor)`}]));function oi(e){let t=e.toLowerCase();switch(ri(t)){case`makefile`:case`gnumakefile`:return ei}let n=t.lastIndexOf(`.`),r=n>=0?t.slice(n+1):``;switch(r){case`ts`:case`tsx`:case`mts`:case`cts`:return H({typescript:!0,jsx:r===`tsx`});case`js`:case`jsx`:case`mjs`:case`cjs`:return H({typescript:!1,jsx:r===`jsx`});case`jsonc`:case`json5`:return[Te(),ti];case`json`:case`jsonl`:case`ndjson`:case`geojson`:return Te();case`css`:case`scss`:case`sass`:case`less`:return Ce();case`html`:case`htm`:case`xml`:case`drawio`:case`dio`:return we();case`md`:case`mdx`:case`markdown`:case`mdown`:case`mkd`:return[De({codeLanguages:ni}),ai()];case`sh`:case`bash`:case`zsh`:case`fish`:case`env`:return ei;case`py`:case`pyw`:case`pyi`:return Oe();default:return null}}async function si(e){let t=ii(e);if(!t)return null;if(t.support)return t.support;try{return await t.load()}catch{return null}}function ci(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=R.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=he.define([{tag:[V.comment,V.docComment,V.meta,V.documentMeta],class:`cm-comment`},{tag:[V.keyword,V.controlKeyword,V.moduleKeyword,V.definitionKeyword,V.modifier],class:`cm-keyword`},{tag:[V.operatorKeyword,V.operator,V.derefOperator,V.updateOperator,V.definitionOperator,V.typeOperator,V.controlOperator,V.logicOperator,V.bitwiseOperator,V.arithmeticOperator,V.compareOperator],class:`cm-operator`},{tag:[V.punctuation,V.separator,V.bracket,V.paren,V.brace,V.squareBracket,V.angleBracket],class:`cm-punctuation`},{tag:[V.string,V.regexp,V.attributeValue,V.special(V.string),V.monospace],class:`cm-string`},{tag:V.escape,class:`cm-string-2`},{tag:[V.number,V.bool,V.atom,V.null,V.self],class:`cm-number`},{tag:[V.function(V.variableName),V.function(V.definition(V.variableName)),V.function(V.propertyName),V.standard(V.variableName),V.special(V.variableName)],class:`cm-builtin`},{tag:V.definition(V.variableName),class:`cm-def`},{tag:[V.variableName,V.local(V.variableName),V.constant(V.variableName),V.literal],class:`cm-variable`},{tag:V.propertyName,class:`cm-property`},{tag:V.attributeName,class:`cm-attribute`},{tag:[V.className,V.typeName,V.namespace],class:`cm-variable-3`},{tag:[V.tagName,V.labelName,V.annotation,V.macroName],class:`cm-tag`},{tag:V.link,class:`cm-link`},{tag:[V.heading,V.heading1,V.heading2,V.heading3,V.heading4,V.heading5,V.heading6],class:`cm-keyword`}]),l=he.define([{tag:[V.comment,V.docComment,V.meta,V.documentMeta],color:e.colors.syntax.base.comment},{tag:[V.keyword,V.controlKeyword,V.moduleKeyword,V.definitionKeyword,V.modifier],color:e.colors.syntax.base.keyword},{tag:[V.operatorKeyword,V.operator,V.derefOperator,V.updateOperator,V.definitionOperator,V.typeOperator,V.controlOperator,V.logicOperator,V.bitwiseOperator,V.arithmeticOperator,V.compareOperator],color:e.colors.syntax.base.operator},{tag:[V.string,V.regexp,V.attributeValue,V.special(V.string),V.monospace],color:e.colors.syntax.base.string},{tag:V.escape,color:a.stringEscape||e.colors.syntax.base.string},{tag:[V.number,V.bool,V.atom,V.null,V.self],color:e.colors.syntax.base.number},{tag:[V.function(V.variableName),V.function(V.definition(V.variableName)),V.function(V.propertyName),V.standard(V.variableName),V.special(V.variableName)],color:e.colors.syntax.base.function},{tag:V.definition(V.variableName),color:a.variableGlobal||e.colors.syntax.base.variable},{tag:[V.variableName,V.local(V.variableName),V.constant(V.variableName),V.literal],color:e.colors.syntax.base.variable},{tag:V.propertyName,color:a.variableProperty||e.colors.syntax.base.variable},{tag:V.attributeName,color:a.variableOther||e.colors.syntax.base.variable},{tag:[V.className,V.typeName,V.namespace],color:e.colors.syntax.base.type},{tag:[V.tagName,V.labelName,V.annotation,V.macroName],color:a.tag||e.colors.syntax.base.keyword},{tag:V.link,color:a.url||e.colors.syntax.base.function,textDecoration:`underline`},{tag:[V.punctuation,V.separator,V.bracket,V.paren,V.brace,V.squareBracket,V.angleBracket],color:a.punctuation||e.colors.syntax.base.comment}]);return t?.syntaxColors===!1?[s]:[s,z(ye,{fallback:!0}),z(le),z(c),z(l)]}var li=180,ui=ve.define(),di=1,fi=2,pi=4,mi=new Map,hi=(e,t)=>{let n=`${e}|${t}`,r=mi.get(n);if(r)return r;let i=``;e&&(i+=`color:${e};`),t&di&&(i+=`font-style:italic;`),t&fi&&(i+=`font-weight:bold;`),t&pi&&(i+=`text-decoration:underline;`);let a=L.mark({attributes:{style:i}});return mi.set(n,a),a},gi=(e,t)=>{let n=new ge,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,hi(t,r)))}}return n.finish()},_i=xe.define({create(){return L.none},update(e,t){let n=e.map(t.changes);for(let e of t.effects)e.is(ui)&&(n=e.value);return n},provide:e=>R.decorations.from(e)}),vi=e=>de.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)},li)}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:ui.of(gi(t,a))}))}destroy(){this.timer&&clearTimeout(this.timer),this.abortController?.abort(),this.abortController=void 0}}),yi=e=>[_i,vi(e)],bi=e=>{let t=(0,J.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,Y.jsx)(q,{name:`eye`,className:`size-4`,"aria-hidden":`true`}):(0,Y.jsx)(q,{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,Y.jsx)(bt,{asChild:!0,children:(0,Y.jsx)(G,{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,Y.jsx)(xt,{sideOffset:8,children:o}),t[6]=o,t[7]=l);let u;return t[8]!==c||t[9]!==l?(u=(0,Y.jsxs)(St,{children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10],u},xi=T()(D(E((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=c()?.settings;if(e)try{n=t(((await e.load())?.settings||{}).defaultGitIdentityId)}catch{}}if(n===null)try{let e=await u(`/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 v({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:P(),partialize:e=>({selectedProfileId:e.selectedProfileId})}),{name:`git-identities-store`}));typeof window<`u`&&(window.__zustand_git_identities_store__=xi);var Si=`w-full max-w-[30rem]`,Ci=e=>{let t=(0,J.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,Y.jsx)(`span`,{className:`truncate`,children:n}),t[0]=n,t[1]=u);let d;t[2]!==u||t[3]!==a?(d=(0,Y.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,Y.jsx)(`div`,{className:`shrink-0`,children:o}):null,t[5]=o,t[6]=f);let p;t[7]!==d||t[8]!==f?(p=(0,Y.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=W(`yuri-settings-group-row`,l),t[10]=l,t[11]=m);let h;t[12]!==s||t[13]!==m?(h=(0,Y.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,Y.jsx)(yr,{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,Y.jsx)(`div`,{"data-settings-item":i,className:c,children:g}),t[19]=c,t[20]=i,t[21]=g,t[22]=_):_=t[22],_},wi=450,Ti=({projectRef:e=null})=>{let{t}=U(),{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=j(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,C]=$.useState(!1),w=$.useRef(!1),T=$.useMemo(()=>e?.id&&e?.path?{id:e.id,path:e.path}:!a?.id||!o?null:{id:a.id,path:o},[a?.id,o,e?.id,e?.path]),E=$.useCallback(async()=>{if(!(!T||v===!1))try{let e=await ft(T);x(e)}catch{}},[T,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(!T){x([]),C(!1);return}if(v===!1){x([]),C(!1);return}let e=!1;return C(!0),x([]),(async()=>{try{let t=await ft(T);if(e)return;x(t)}catch{}finally{e||C(!1)}})(),()=>{e=!0}},[T,v]),$.useEffect(()=>{if(!T)return;let e=!1;return h(!0),(async()=>{try{let[t,n]=await Promise.all([He(T),We(T)]);if(!e){let e=t.length>0?t:[``];d(e),_(JSON.stringify(e)),p(n)}}catch{e||(d([``]),_(JSON.stringify([``])),p(!1))}finally{e||h(!1)}})(),()=>{e=!0}},[T]);let D=$.useCallback(async e=>{if(!T)return!1;let n=e.filter(e=>e.trim().length>0);try{return await Ue(T,n)?(_(JSON.stringify(e)),!0):(K.error(t(`settings.yuri.worktrees.setup.toast.saveFailed`)),!1)}catch{return K.error(t(`settings.yuri.worktrees.setup.toast.saveFailed`)),!1}},[T,t]),O=$.useMemo(()=>g!==null&&g!==JSON.stringify(u),[g,u]);$.useEffect(()=>{if(!O||m||w.current)return;let e=window.setTimeout(()=>{w.current||(w.current=!0,(async()=>{try{await D(u)}finally{w.current=!1}})())},wi);return()=>{window.clearTimeout(e)}},[O,m,D,u]);let k=$.useCallback((e,t)=>{d(n=>{let r=[...n];return r[e]=t,r})},[]),A=$.useCallback(()=>{d(e=>[...e,``])},[]),ee=$.useCallback(e=>{d(t=>{let n=t.filter((t,n)=>n!==e);return n.length>0?n:[``]})},[]),M=$.useCallback(()=>{!O||w.current||(w.current=!0,(async()=>{try{await D(u)}finally{w.current=!1}})())},[O,D,u]),N=$.useCallback(e=>{p(e),T&&Ke(T,e)},[T]),P=$.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=[...Pe.getState().activeSessions,...Pe.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]),F=$.useMemo(()=>c.map(e=>e.id).join(`,`),[c]);$.useEffect(()=>{v&&o&&E()},[F,v,o,E]);let te=(0,Y.jsxs)(St,{children:[(0,Y.jsx)(bt,{asChild:!0,children:(0,Y.jsx)(q,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,Y.jsxs)(xt,{sideOffset:8,className:`max-w-xs`,children:[t(`settings.yuri.worktrees.setup.tooltipPrefix`),` `,(0,Y.jsx)(`code`,{className:`font-mono text-xs bg-sidebar-accent/50 px-1 rounded`,children:`$ROOT_PROJECT_PATH`}),` `,t(`settings.yuri.worktrees.setup.tooltipSuffix`)]})]}),I=(0,Y.jsxs)(St,{children:[(0,Y.jsx)(bt,{asChild:!0,children:(0,Y.jsx)(q,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,Y.jsx)(xt,{sideOffset:8,className:`max-w-xs`,children:t(`settings.yuri.worktrees.list.tooltip`)})]});return o?v===!1?(0,Y.jsx)(Ci,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Y.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.worktrees.state.gitOnly`)})}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Ci,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,titleAccessory:te,children:m?(0,Y.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.worktrees.setup.loading`)}):(0,Y.jsxs)(`div`,{className:W(`flex flex-col gap-2`,Si),children:[u.map((e,n)=>(0,Y.jsxs)(`div`,{className:`yuri-settings-group-row flex w-full items-center gap-2`,children:[(0,Y.jsx)(yt,{value:e,onChange:e=>k(n,e.target.value),onBlur:M,placeholder:t(`settings.yuri.worktrees.setup.commandPlaceholder`),className:`min-w-0 flex-1 font-mono text-xs`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>ee(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,Y.jsx)(q,{name:`close`,className:`h-4 w-4`})})]},n)),(0,Y.jsxs)(G,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:A,children:[(0,Y.jsx)(q,{name:`add`,className:`h-3.5 w-3.5`}),t(`settings.yuri.worktrees.setup.addCommand`)]}),(0,Y.jsxs)(`label`,{"data-settings-item":`projects.worktree.setup.wait`,className:`flex cursor-pointer items-center gap-2 py-1`,children:[(0,Y.jsx)(ct,{checked:f,onChange:N,ariaLabel:t(`settings.yuri.worktrees.setup.waitForCommandsAria`)}),(0,Y.jsx)(`span`,{className:W(`typography-ui-label font-normal`,f?`text-foreground`:`text-foreground/60`),children:t(`settings.yuri.worktrees.setup.waitForCommands`)})]})]})}),(0,Y.jsx)(Ci,{title:t(`settings.yuri.worktrees.list.title`),titleAccessory:I,children:S?(0,Y.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.worktrees.list.loading`)}):b.length===0?(0,Y.jsx)(`p`,{className:`typography-meta text-muted-foreground/70`,children:t(`settings.yuri.worktrees.list.empty`)}):(0,Y.jsx)(`div`,{className:W(`space-y-1`,Si),children:b.map(e=>(0,Y.jsxs)(`div`,{className:`group flex w-full items-center gap-2 py-1.5`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`p`,{className:`typography-meta min-w-0 truncate text-foreground`,children:e.label||e.branch||t(`settings.yuri.worktrees.list.detachedHead`)}),(0,Y.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,Y.jsx)(`p`,{className:`typography-micro truncate text-muted-foreground/60`,children:je(e.path,l)})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>P(e),className:W(`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,Y.jsx)(q,{name:`delete-bin`,className:`h-4 w-4`})})]},e.path))})})]}):(0,Y.jsx)(Ci,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Y.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.worktrees.state.selectProject`)})})},Ei=(e,t)=>t.updatedAtMs-e.updatedAtMs,Di=T((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([Ft(),Ct()]),i={};for(let e of r.sort(Ei))i[e.id]=e;t().listenerReady||await Lt(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 Ot(),isImportsLoading:!1})}catch(t){e({isImportsLoading:!1,error:t instanceof Error?t.message:String(t)})}}},refreshStatuses:async()=>{try{let t=await Ct(),n={};for(let e of t.sort(Ei))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 Pt({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=Et(e,n);r&&r.trim()&&(i.nickname=r.trim()),await t().upsertInstance(i)},removeInstance:async n=>{await Vt(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 kt(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 Vt(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})})),Oi=450,ki=()=>C(),Ai=()=>({id:ki(),name:``,command:``,icon:`play`}),ji=({projectRef:e})=>{let{t}=U(),n=$.useMemo(()=>h(),[]),r=Di(e=>e.instances),i=Di(e=>e.load),[a,o]=$.useState([]),[s,c]=$.useState(!1),[l,u]=$.useState(null),[d,f]=$.useState({}),p=$.useRef(!1),m=$.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),u(JSON.stringify({actions:n.actions}))}catch{if(t)return;o([]),u(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})?(u(JSON.stringify({actions:n})),typeof window<`u`&&window.dispatchEvent(new CustomEvent(xn,{detail:{projectId:e.id}})),!0):(K.error(t(`settings.projects.actions.toast.saveFailed`)),!1),[e,t]);$.useEffect(()=>{if(!v||s||_||p.current)return;let e=window.setTimeout(()=>{p.current||(p.current=!0,(async()=>{try{await y(a)}finally{p.current=!1}})())},Oi);return()=>{window.clearTimeout(e)}},[a,v,s,y,_]),$.useEffect(()=>{if(!v||!_||s){_||(m.current=null);return}let e=window.setTimeout(()=>{m.current!==_&&(m.current=_,K.error(_))},1e3);return()=>{window.clearTimeout(e)}},[v,s,_]);let b=$.useCallback(()=>{let e=Ai();o(t=>[...t,e]),f(t=>({...t,[e.id]:!0}))},[]),x=$.useCallback(e=>{o(t=>t.filter(t=>t.id!==e)),f(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,Y.jsxs)(Ci,{title:t(`settings.projects.actions.title`),description:t(`settings.projects.actions.description`),settingsItem:`projects.actions`,headerAction:(0,Y.jsxs)(G,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:b,children:[(0,Y.jsx)(q,{name:`add`,className:`h-3.5 w-3.5`}),t(`settings.projects.actions.actions.add`)]}),contentClassName:`space-y-0`,children:[s?(0,Y.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.loading`)}):a.length===0?(0,Y.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.empty`)}):(0,Y.jsx)(`div`,{className:W(`space-y-0`,Si),children:a.map(e=>{let r=e.icon||`play`,i=bn[r]||`play`,a=d[e.id]??!1,o=e.name.trim()||t(`settings.projects.actions.state.untitled`);return(0,Y.jsxs)(rn,{open:a,onOpenChange:t=>{f(n=>({...n,[e.id]:t}))},className:`py-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Y.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,Y.jsx)(q,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground`}):(0,Y.jsx)(q,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground`}),(0,Y.jsx)(q,{name:i,className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}),(0,Y.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Y.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:o})})]}),(0,Y.jsx)(G,{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,Y.jsx)(q,{name:`delete-bin`,className:`h-3.5 w-3.5`})})]}),(0,Y.jsx)(tn,{className:`pt-1.5`,children:(0,Y.jsxs)(`div`,{className:`space-y-2 pb-4 pl-3 pr-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,Y.jsxs)(Ht,{children:[(0,Y.jsx)(Ut,{asChild:!0,children:(0,Y.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,Y.jsx)(q,{name:i,className:`h-4 w-4`})})}),(0,Y.jsx)(Rt,{align:`start`,className:`w-56 p-2`,children:(0,Y.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,Y.jsx)(`button`,{type:`button`,onClick:()=>S(e.id,e=>({...e,icon:n.key})),className:W(`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,Y.jsx)(q,{name:r,className:`h-4 w-4`})},n.key)})})})]}),(0,Y.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,Y.jsxs)(`div`,{className:`py-1`,children:[(0,Y.jsx)(`p`,{className:`typography-meta mb-0.5 text-muted-foreground`,children:t(`settings.projects.actions.field.command`)}),(0,Y.jsx)(Jt,{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,Y.jsxs)(`div`,{className:`py-1`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Y.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:t(`settings.projects.actions.field.autoOpenUrl`)}),(0,Y.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,Y.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,Y.jsx)(`span`,{className:`typography-ui-label font-normal text-foreground/80`,children:t(`settings.projects.actions.field.autoOpenUrlDescription`)})]})]}),e.autoOpenUrl===!0?(0,Y.jsxs)(`div`,{className:`mt-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.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,Y.jsxs)(St,{children:[(0,Y.jsx)(bt,{asChild:!0,children:(0,Y.jsx)(q,{name:`information`,className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/60 cursor-help`})}),(0,Y.jsx)(xt,{sideOffset:8,className:`max-w-xs`,children:t(`settings.projects.actions.field.overrideUrlTooltip`)})]})]}),n?(0,Y.jsxs)(`div`,{className:`mt-2`,children:[(0,Y.jsx)(`p`,{className:`typography-meta mb-0.5 text-muted-foreground`,children:t(`settings.projects.actions.field.desktopSshForward`)}),g.length>0?(0,Y.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,Y.jsx)(dt,{className:`h-7 w-full`,children:(0,Y.jsx)(vt,{placeholder:t(`settings.projects.actions.field.useOutputManualUrl`)})}),(0,Y.jsxs)(pt,{children:[(0,Y.jsx)(lt,{value:`__none__`,children:t(`settings.projects.actions.field.useOutputManualUrl`)}),g.map(e=>(0,Y.jsx)(lt,{value:e.id,children:e.label},e.id))]})]}):(0,Y.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.noDesktopSshForwards`)})]}):null]}):null]})]})})]},e.id)})}),_&&a.length>0?(0,Y.jsx)(`p`,{className:`typography-meta text-[var(--status-warning)]`,children:_}):null]})},Mi=e=>{let t=(0,J.c)(123),{form:n}=e,{t:r}=U(),{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:ee}=n;if(!ee)return null;let M=l?ht[l]??null:null,N;t[0]===r?N=t[1]:(N=r(`settings.projects.page.field.projectName`),t[0]=r,t[1]=N);let P;t[2]===o?P=t[3]:(P=e=>o(e.target.value),t[2]=o,t[3]=P);let F;t[4]===r?F=t[5]:(F=r(`settings.projects.page.field.projectNamePlaceholder`),t[4]=r,t[5]=F);let te;t[6]!==a||t[7]!==P||t[8]!==F?(te=(0,Y.jsx)(yt,{value:a,onChange:P,placeholder:F}),t[6]=a,t[7]=P,t[8]=F,t[9]=te):te=t[9];let I;t[10]!==N||t[11]!==te?(I=(0,Y.jsx)(br,{label:N,itemId:`projects.name`,children:te}),t[10]=N,t[11]=te,t[12]=I):I=t[12];let ne;t[13]===r?ne=t[14]:(ne=r(`settings.projects.page.field.defaultModel`),t[13]=r,t[14]=ne);let re;t[15]===r?re=t[16]:(re=r(`settings.projects.page.field.defaultModelDescription`),t[15]=r,t[16]=re);let ie;t[17]!==m||t[18]!==p.modelId||t[19]!==p.providerId?(ie=(0,Y.jsx)(Dt,{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]=ie):ie=t[20];let ae;t[21]!==ne||t[22]!==re||t[23]!==ie?(ae=(0,Y.jsx)(br,{label:ne,description:re,descriptionPlacement:`outside`,itemId:`projects.default-model`,children:ie}),t[21]=ne,t[22]=re,t[23]=ie,t[24]=ae):ae=t[24];let oe;t[25]===r?oe=t[26]:(oe=r(`settings.projects.page.field.accentColor`),t[25]=r,t[26]=oe);let L;t[27]===u?L=t[28]:(L=()=>u(null),t[27]=u,t[28]=L);let se=l===null?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-border/40 hover:border-border hover:bg-[var(--surface-muted)]`,R;t[29]===se?R=t[30]:(R=W(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,se),t[29]=se,t[30]=R);let ce;t[31]===r?ce=t[32]:(ce=r(`settings.projects.page.field.none`),t[31]=r,t[32]=ce);let le;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,Y.jsx)(q,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[33]=le):le=t[33];let z;t[34]!==L||t[35]!==R||t[36]!==ce?(z=(0,Y.jsx)(`button`,{type:`button`,onClick:L,className:R,title:ce,children:le}),t[34]=L,t[35]=R,t[36]=ce,t[37]=z):z=t[37];let ue;t[38]!==l||t[39]!==u?(ue=_t.map(e=>(0,Y.jsx)(`button`,{type:`button`,onClick:()=>u(e.key),className:W(`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]=ue):ue=t[40];let de;t[41]!==z||t[42]!==ue?(de=(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[z,ue]}),t[41]=z,t[42]=ue,t[43]=de):de=t[43];let fe;t[44]!==oe||t[45]!==de?(fe=(0,Y.jsx)(br,{label:oe,itemId:`projects.accent-color`,children:de}),t[44]=oe,t[45]=de,t[46]=fe):fe=t[46];let pe;t[47]===r?pe=t[48]:(pe=r(`settings.projects.page.field.projectIcon`),t[47]=r,t[48]=pe);let me;t[49]===O?me=t[50]:(me=e=>{let t=e.target.files?.[0]??null;O(t),e.currentTarget.value=``},t[49]=O,t[50]=me);let he;t[51]!==D||t[52]!==me?(he=(0,Y.jsx)(`input`,{ref:D,type:`file`,accept:`image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg`,className:`hidden`,onChange:me}),t[51]=D,t[52]=me,t[53]=he):he=t[53];let B;t[54]===c?B=t[55]:(B=()=>c(null),t[54]=c,t[55]=B);let ge=s===null?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-border/40 hover:border-border hover:bg-[var(--surface-muted)]`,_e;t[56]===ge?_e=t[57]:(_e=W(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,ge),t[56]=ge,t[57]=_e);let ve;t[58]===r?ve=t[59]:(ve=r(`settings.projects.page.field.none`),t[58]=r,t[59]=ve);let ye;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,Y.jsx)(q,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[60]=ye):ye=t[60];let be;t[61]!==B||t[62]!==_e||t[63]!==ve?(be=(0,Y.jsx)(`button`,{type:`button`,onClick:B,className:_e,title:ve,children:ye}),t[61]=B,t[62]=_e,t[63]=ve,t[64]=be):be=t[64];let xe;t[65]!==M||t[66]!==s||t[67]!==c?(xe=gt.map(e=>{let t=e.Icon;return(0,Y.jsx)(`button`,{type:`button`,onClick:()=>c(e.key),className:W(`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,Y.jsx)(q,{name:t,className:`w-4 h-4`,style:M&&s===e.key?{color:M}:void 0})},e.key)}),t[65]=M,t[66]=s,t[67]=c,t[68]=xe):xe=t[68];let Se;t[69]!==be||t[70]!==xe?(Se=(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[be,xe]}),t[69]=be,t[70]=xe,t[71]=Se):Se=t[71];let V;t[72]!==j||t[73]!==i||t[74]!==w||t[75]!==S||t[76]!==d||t[77]!==b||t[78]!==ee||t[79]!==x||t[80]!==E||t[81]!==r?(V=w&&E&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Y.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:r(`settings.projects.page.field.preview`)}),(0,Y.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,Y.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,Y.jsx)(`img`,{src:b,alt:``,className:`h-full w-full object-contain`,draggable:!1,onError:()=>x(!0)}):(0,Y.jsx)(ut,{project:{...ee,iconImage:j??ee.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]=ee,t[79]=x,t[80]=E,t[81]=r,t[82]=V):V=t[82];let Ce;t[83]!==w||t[84]!==d||t[85]!==f||t[86]!==r?(Ce=w&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,Y.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,Y.jsx)(yt,{value:d??``,onChange:e=>f(e.target.value),placeholder:`#000000`,className:`h-7 w-[8rem]`}),(0,Y.jsx)(G,{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,Y.jsx)(q,{name:`close`,className:`h-3.5 w-3.5`})})]}),t[83]=w,t[84]=d,t[85]=f,t[86]=r,t[87]=Ce):Ce=t[87];let H;t[88]!==D||t[89]!==A||t[90]!==C||t[91]!==_||t[92]!==h||t[93]!==r?(H=!C&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(G,{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,Y.jsx)(G,{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]=H):H=t[94];let we;t[95]!==k||t[96]!==T||t[97]!==g||t[98]!==r?(we=T&&(0,Y.jsx)(G,{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]=we):we=t[99];let Te;t[100]!==g||t[101]!==v||t[102]!==y||t[103]!==r?(Te=v&&(0,Y.jsx)(G,{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]=Te):Te=t[104];let Ee;t[105]!==H||t[106]!==we||t[107]!==Te?(Ee=(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[H,we,Te]}),t[105]=H,t[106]=we,t[107]=Te,t[108]=Ee):Ee=t[108];let De;t[109]!==he||t[110]!==Se||t[111]!==V||t[112]!==Ce||t[113]!==Ee?(De=(0,Y.jsxs)(`div`,{className:`flex w-full flex-col items-end gap-2`,children:[he,Se,V,Ce,Ee]}),t[109]=he,t[110]=Se,t[111]=V,t[112]=Ce,t[113]=Ee,t[114]=De):De=t[114];let Oe;t[115]!==pe||t[116]!==De?(Oe=(0,Y.jsx)(br,{label:pe,itemId:`projects.icon`,children:De}),t[115]=pe,t[116]=De,t[117]=Oe):Oe=t[117];let ke;return t[118]!==fe||t[119]!==Oe||t[120]!==I||t[121]!==ae?(ke=(0,Y.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[I,ae,fe,Oe]}),t[118]=fe,t[119]=Oe,t[120]=I,t[121]=ae,t[122]=ke):ke=t[122],ke},Ni=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,Pi=e=>{if(!e)return null;let t=e.trim();return t&&Ni.test(t)?t.toLowerCase():null},Fi=e=>{let{t}=U(),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))},[]),ee=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 M=$.useMemo(()=>Ge(m)??{providerId:``,modelId:``},[m]),N=!!e?.iconImage,P=!!(w&&E),F=e?.iconImage?.source===`custom`,te=N&&!S||P,I=te,ne=!!(e&&N&&!S),re=!O&&(P||ne),ie=!!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),ae=$.useCallback((e,t)=>{h(e&&t?`${e}/${t}`:void 0)},[]),oe=$.useCallback(t=>{!e||!t||g||(C(!1),k(!1),T(t),D(e=>(e&&URL.revokeObjectURL(e),URL.createObjectURL(t))))},[g,e]),L=$.useCallback(()=>{!e||!I||v||(P&&j(),C(!!N),k(!1))},[j,P,I,N,v,e]),se=$.useCallback(async()=>{if(!(!e||b)){j(),C(!1),k(!1),x(!0);try{let n=await i(e.id);if(!n.ok){K.error(n.error||t(`settings.projects.page.toast.discoverIconFailed`));return}if(n.skipped){K.success(t(`settings.projects.page.toast.customIconAlreadySet`));return}K.success(t(`settings.projects.page.toast.iconDiscovered`))}finally{x(!1)}}},[j,i,b,e,t]),R=$.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 K.error(r.error||t(`settings.projects.page.toast.uploadIconFailed`)),null;a||K.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 K.error(n.error||t(`settings.projects.page.toast.removeIconFailed`)),null;a||K.success(t(`settings.projects.page.toast.iconRemoved`)),C(!1),p(null)}return{label:s,icon:c,color:u,iconBackground:Pi(l?null:f),defaultModel:m??null}},[j,u,m,c,f,o,S,w,e,r,t,n]);return $.useEffect(()=>{k(!1)},[ee,a?.updatedAt]),{name:o,setName:s,icon:c,setIcon:l,color:u,setColor:d,iconBackground:f,setIconBackground:p,defaultModel:m,parsedDefaultModel:M,handleDefaultModelChange:ae,isUploadingIcon:g,isRemovingCustomIcon:v,isDiscoveringIcon:b,pendingRemoveImageIcon:S,setPendingRemoveImageIcon:C,pendingUploadIconFile:w,pendingUploadIconPreviewUrl:E,previewImageFailed:O,setPreviewImageFailed:k,hasStoredImageIcon:N,hasPendingUploadImageIcon:P,hasCustomIcon:F,effectiveHasImageIcon:te,hasRemovableImageIcon:I,showStoredImagePreview:ne,showImagePreview:re,fileInputRef:A,clearPendingUploadIcon:j,handleUploadIcon:oe,handleRemoveImageIcon:L,handleDiscoverIcon:se,hasChanges:ie,prepareSaveData:R,currentIconImage:a,project:e}},Ii=450,Li=(e,t)=>{let{t:n}=U(),{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{K.error(n(`settings.projects.page.toast.saveFailed`))}}finally{m.current=!1}})())},Ii);return()=>{window.clearTimeout(e)}},[o,c,r,a,s,f,d,i,t,l,u,p,n])},Ri=e=>{let t=(0,J.c)(25),{project:n,onIdentitySave:r}=e,{t:i}=U(),a=Fi(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),Li(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,Y.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,Y.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,Y.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,Y.jsx)(Mi,{form:a}),t[15]=a,t[16]=m);let h,g;t[17]===s?(h=t[18],g=t[19]):(h=(0,Y.jsx)(ji,{projectRef:s}),g=(0,Y.jsx)(Ti,{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,Y.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 zi(e,t,n){return Math.min(n,Math.max(t,e))}function Bi(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 Vi(e,t){let n=Bi(t);return n<=0?e:Number(e.toFixed(n))}var Hi=$.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}=U(),[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=Vi(zi(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=Vi(zi(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,Y.jsxs)(`div`,{"data-slot":`number-input`,className:W(`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,Y.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.decreaseAria`),disabled:D,onTouchStart:A(O),onClick:j(O),className:W(`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,Y.jsx)(q,{name:`subtract`,className:`block h-4 w-4`})}),(0,Y.jsx)(`div`,{"data-slot":`number-input-value`,className:W(`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,Y.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.increaseAria`),disabled:E,onTouchStart:A(k),onClick:j(k),className:W(`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,Y.jsx)(q,{name:`add`,className:`block h-4 w-4`})})]}):(0,Y.jsxs)(`div`,{"data-slot":`number-input`,className:W(`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,Y.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.decreaseAria`),disabled:D,onClick:()=>C(S.current-i),className:W(`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,Y.jsx)(q,{name:`subtract`,className:`block h-3.5 w-3.5`})}),(0,Y.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:W(`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,Y.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.increaseAria`),disabled:E,onClick:()=>C(S.current+i),className:W(`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,Y.jsx)(q,{name:`add`,className:`block h-3.5 w-3.5`})})]})});Hi.displayName=`NumberInput`;function Ui(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 Wi={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 Gi(e,t){let n=Wi[t]??[];for(let t of n)if(t.matcher(e))return t;return null}function Ki(e){return Wi[e]??[]}function qi(e){return[...e].sort((e,t)=>e.order-t.order)}function Ji(e,t){let n=new Map;for(let r of Object.keys(e)){let e=Gi(r,t)?.id??null;n.has(e)||n.set(e,[]),n.get(e).push(r)}return n}function Yi(e,t,n){let r=new Map;for(let i of e){let e=Gi(t(i),n)?.id??null;r.has(e)||r.set(e,[]),r.get(e).push(i)}return r}function Xi(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 Zi=(e,t=``,n=!1)=>I({queryKey:o.scoped(`magpie-quotas`,e,t,n),staleTime:0,retry:!1,queryFn:async({signal:t})=>{let r=await u(`/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=>s(t)&&t.source===`magpie`&&t.sourceId===e.id&&t.providerId.startsWith(`magpie:${e.id}:`))))throw Error(`Invalid Magpie quota response`);return i}}),Qi=6e4,$i=0,ea=0,ta,na=0,ra=0,ia=0,aa=new Map,oa=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))):Qi,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}},sa=async()=>{let e=c()?.settings;if(e)try{let t=(await e.load())?.settings;return oa(t??null)}catch{}if(!x()){let e=await u(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(e.ok)return oa(await e.json().catch(()=>null))}return{magpieUsageUrl:``,magpieHiddenProviders:[],autoRefresh:!1,refreshIntervalMs:Qi,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:Sn.map(e=>e.id),selectedModels:{},expandedFamilies:{}}},ca=(e,t,n)=>{let r=e.filter(e=>e?.providerId&&e.providerId!==t);return s(n)&&r.push(n),r},la=async(e,t)=>{let n=ea;aa.set(e,(aa.get(e)??0)+1),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:!0}}));try{let r=await a.fetchQuery({queryKey:o.quota(e),queryFn:({signal:t})=>l(e,t),staleTime:0,retry:!1});if(n!==ea)return{providerId:e,stale:!0};if(!s(r))throw Error(`Invalid quota response`);return t(t=>({results:ca(t.results,e,r)})),{providerId:e,result:r}}catch(r){return n===ea?(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===ea){let n=(aa.get(e)??1)-1;n>0?aa.set(e,n):aa.delete(e),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:n>0}}))}}},ua=()=>{ta=void 0,na+=1,ea+=1,$i+=1,aa.clear(),da.setState({magpieUsageUrl:``,magpieHiddenProviders:[],magpieSources:[],magpieError:null,results:[],isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null})},da=T()(D((e,t)=>({magpieSources:[],magpieError:null,magpieHiddenProviders:[],magpieUsageUrl:``,results:[],selectedProviderId:null,isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null,autoRefresh:!1,refreshIntervalMs:Qi,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:Sn.map(e=>e.id),selectedModels:{},expandedFamilies:{},loadSettings:async()=>{let t=ea;try{let n=await sa();if(t!==ea)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=++$i;e({isLoading:!0,error:null});let r=Sn.map(e=>e.id),[i]=await Promise.all([Promise.all(r.map(t=>la(t,e))),t().fetchMagpieQuotas(!0)]);if(n===$i){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 la(n,e);`stale`in r||e({error:`error`in r?r.error:null})},fetchMagpieQuotas:async(n=!1)=>{let r=ea,i=j.getState().currentDirectory,o=t().magpieUsageUrl,s=JSON.stringify([i,o]);ta!==s&&(ta=s,na+=1,e(e=>({results:e.results.filter(e=>e?.source!==`magpie`),magpieSources:[],magpieError:null})));let c=na,l=++ra;try{let{sources:s,incomplete:u}=await a.fetchQuery(Zi(i,o,n));if(r!==ea||c!==na||l<ia||i!==j.getState().currentDirectory||o!==t().magpieUsageUrl)return;ia=l,e(e=>{let t=new Map(s.filter(e=>e.error&&!e.clearPrevious&&e.results.length===0).map(e=>[e.id,e.error]));if(u){let n=new Set(s.map(e=>e.id));for(let r of e.results)r.sourceId&&!n.has(r.sourceId)&&t.set(r.sourceId,`Magpie discovery is incomplete`)}let n=e.results.filter(e=>e?.providerId&&(e.source!==`magpie`||t.has(e.sourceId??``))).map(e=>e.source===`magpie`&&t.has(e.sourceId??``)?{...e,ok:!1,error:t.get(e.sourceId??``)}:e);n.push(...s.flatMap(e=>e.results));let r=n.filter(e=>e.source===`magpie`).map(e=>e.providerId);return{results:n,magpieSources:s,magpieError:null,dropdownProviderIds:[...e.dropdownProviderIds.filter(e=>!e.startsWith(`magpie:`)),...r.filter(t=>!e.magpieHiddenProviders.includes(t))]}})}catch(n){if(r!==ea||c!==na||l<ia||i!==j.getState().currentDirectory||o!==t().magpieUsageUrl)return;ia=l,e({magpieError:n instanceof Error?n.message:`Unable to read Magpie quotas`})}},setSelectedProvider:t=>e({selectedProviderId:t}),setAutoRefresh:t=>e({autoRefresh:t}),setRefreshInterval:t=>{e({refreshIntervalMs:Math.max(3e4,Math.min(3e5,Math.round(t)))})},setDisplayMode:t=>e({displayMode:t}),setShowPredValues:t=>e({showPredValues:t}),setDropdownProviderIds:n=>{let r=t().results.filter(e=>e.source===`magpie`),i=new Set(r.map(e=>e.providerId));e({dropdownProviderIds:n,magpieHiddenProviders:[...t().magpieHiddenProviders.filter(e=>!i.has(e)),...r.filter(e=>!n.includes(e.providerId)).map(e=>e.providerId)]})},setSelectedModels:(t,n)=>{e(e=>({selectedModels:{...e.selectedModels,[t]:n}}))},toggleModelSelected:(t,n)=>{e(e=>{let r=e.selectedModels[t]??[],i=r.includes(n)?r.filter(e=>e!==n):[...r,n];return{selectedModels:{...e.selectedModels,[t]:i}}})},setExpandedFamilies:(n,r)=>{e(e=>({expandedFamilies:{...e.expandedFamilies,[n]:r}})),v({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}}}),v({usageExpandedFamilies:t().expandedFamilies})},applyDefaultSelections:(n,r)=>{if((t().selectedModels[n]?.length??0)>0)return;let i=Xi(n,r);i.length!==0&&(e(e=>({selectedModels:{...e.selectedModels,[n]:i}})),v({usageSelectedModels:t().selectedModels}))}}),{name:`quota-store`})),fa=()=>{let e=(0,J.c)(11),t=j(pa),n=da(ma),r=da(ha),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=da(ga),s=da(_a),c=da(va),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 ma(e){return e.magpieUsageUrl}function ha(e){return e.fetchMagpieQuotas}function ga(e){return e.autoRefresh}function _a(e){return e.refreshIntervalMs}function va(e){return e.fetchAllQuotas}var ya=e=>{let t=(0,J.c)(20),{percent:n,tonePercent:r,className:i,expectedMarkerPercent:a}=e,o;t[0]===n?o=t[1]:(o=zt(n)??0,t[0]=n,t[1]=o);let s=o,c=r??n,l;t[2]===c?l=t[3]:(l=wt(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=W(`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,Y.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,Y.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,Y.jsxs)(`div`,{className:m,children:[_,v]}),t[16]=m,t[17]=_,t[18]=v,t[19]=y):y=t[19],y},ba=e=>{let t=(0,J.c)(67),{paceInfo:n,className:r,compact:i}=e,a=i!==void 0&&i,{t:o}=U(),s;t[0]===n.status?s=t[1]:(s=jt(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=W(`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,Y.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,Y.jsx)(Y.Fragment,{children:o(`settings.usage.pace.wait`,{duration:At(n.remainingSeconds)})}):(0,Y.jsx)(Y.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,Y.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,Y.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=W(`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,Y.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,Y.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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:u}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.waitSeparator`)}),(0,Y.jsx)(`span`,{className:`font-medium`,children:At(n.remainingSeconds)})]}):(0,Y.jsxs)(`span`,{title:f,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.predictionLabel`)}),(0,Y.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,Y.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,Y.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,Y.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,Y.jsxs)(`div`,{className:p,children:[h,x]}),t[63]=x,t[64]=p,t[65]=h,t[66]=S):S=t[66],S},xa=e=>e instanceof Error&&e.name===`CancelledError`,Sa=T(()=>({setStatus:e=>Tt(a,e),refreshStatus:async(e,t)=>{let r=n();t?.force&&await a.cancelQueries({queryKey:o.github.auth(r),exact:!0});try{return await Nt(a,e,r)}catch(e){if(xa(e))return Mt(a,r);throw e}}})),Ca={displayMode:`browser`,installed:!1,browserTab:!0},wa=new Set,Ta=Ca,Ea=!1,Da,Oa=()=>{let e=It();return{displayMode:e,installed:e!==`browser`,browserTab:e===`browser`}},ka=()=>(!Ea&&typeof window<`u`&&(Ta=Oa(),Ea=!0),Ta),Aa=()=>{let e=Oa();Ea=!0,e.displayMode!==Ta.displayMode&&(Ta=e,wa.forEach(e=>e()))},ja=()=>{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`,Aa):typeof t.addListener==`function`&&t.addListener(Aa);return window.addEventListener(`appinstalled`,Aa),window.addEventListener(`focus`,Aa),()=>{for(let t of e)typeof t.removeEventListener==`function`?t.removeEventListener(`change`,Aa):typeof t.removeListener==`function`&&t.removeListener(Aa);window.removeEventListener(`appinstalled`,Aa),window.removeEventListener(`focus`,Aa)}},Ma=e=>(wa.add(e),Da??=ja(),Aa(),()=>{wa.delete(e),wa.size===0&&(Da?.(),Da=void 0)}),Na=()=>$.useSyncExternalStore(Ma,ka,Pa);function Pa(){return Ca}var Fa=`Yuri`,Ia=T()(E(e=>({sidebarBrandName:Fa,setSidebarBrandName:t=>{let n=t.slice(0,64);e(e=>e.sidebarBrandName===n?e:{sidebarBrandName:n})}}),{name:`sidebar-brand-store`,storage:m(),version:3,migrate:(e,t)=>{if(!e||typeof e!=`object`)return e;let n={...e};return t<1&&n.sidebarBrandName===`YEE CODE`&&(n.sidebarBrandName=Fa),t<2&&n.sidebarBrandName===`Open Chamber`&&(n.sidebarBrandName=Fa),t<3&&(n.sidebarBrandName===`OPEN CHAMBER`||n.sidebarBrandName===`Open Chamber`)&&(n.sidebarBrandName=Fa),n}}));typeof window<`u`&&t(e=>{i(e)&&Ia.persist.rehydrate()});var La=(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,Ra=(e,t,n)=>{La(e.get(t),n)&&e.set(t,n)},za=e=>{let t=e;return g(t.directory)??g(t.project?.worktree)},Ba=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)},Va=(e,t,n,r,i=[])=>{let a=new Map,o=new Map;for(let e of t){let t=g(e.normalizedPath);if(!t)continue;let n=o.get(t);(!n||e.id.localeCompare(n.id)<0)&&o.set(t,e),Ra(a,t,{projectId:e.id,projectRoot:t,scopeDirectory:t,kind:`project`})}if(!r)for(let[e,t]of n){let n=g(e),r=n?o.get(n):void 0;if(!(!r||!n))for(let e of t){let t=g(e.path);t&&Ra(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=Ba(n)}for(let e of t)s.set(e,i);return i},p=(e,t,n)=>{for(let r of e){let e=f(za(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}},Ha=`__other__`;function Ua(e){return e.time?.updated??e.time?.archived??e.time?.created??0}function Wa({mode:e=`dialog`}){let{t}=U(),{isMobile:n,isTablet:r,hasTouchInput:i}=Gt(),a=n||r||i,o=e===`page`,s=F(e=>e.isArchivedSessionsDialogOpen),c=F(e=>e.setArchivedSessionsDialogOpen),l=o||s,u=Re(e=>e.projects),d=Pe(e=>e.archivedSessions),f=Ie(e=>e.setCurrentSession),p=F(e=>e.setSettingsDialogOpen),[m,h]=$.useState(!1),[g,_]=$.useState(null),[v,y]=$.useState(null);$.useEffect(()=>{if(!l){_(null),y(null);return}let e=!1;return h(!0),Je().catch(()=>{e||K.error(t(`settings.yuri.archivedSessions.toast.loadFailed`))}).finally(()=>{e||h(!1)}),()=>{e=!0}},[l,t]);let b=$.useMemo(()=>{let e=Va([],u.map(e=>({id:e.id,normalizedPath:e.path})),new Map,x(),d),n=new Map;for(let[t,r]of e.archivedSessionsByProject)n.set(t,[...r].sort((e,t)=>Ua(t)-Ua(e)));let r=new Set;for(let e of n.values())for(let t of e)r.add(t.id);let i=d.filter(e=>!r.has(e.id)).sort((e,t)=>Ua(t)-Ua(e));i.length>0&&n.set(Ha,i);let a=[];for(let e of u){let t=n.get(e.id)??[];t.length!==0&&a.push({projectId:e.id,label:e.label||e.path,path:e.path,sessions:t})}let o=n.get(Ha);return o&&o.length>0&&a.push({projectId:Ha,label:t(`settings.yuri.archivedSessions.otherProjects`),path:null,sessions:o}),a.sort((e,t)=>t.sessions.length-e.sessions.length||e.label.localeCompare(t.label)),a},[d,u,t]),S=d.length,C=g?b.find(e=>e.projectId===g)??null:null,w=$.useCallback(async e=>{y(e.id);try{await ze(e.id)?K.success(t(`settings.yuri.archivedSessions.toast.restored`)):K.error(t(`settings.yuri.archivedSessions.toast.restoreFailed`))}finally{y(null)}},[t]),T=$.useCallback(e=>{let t=Ve(e);f(e.id,t),c(!1),p(!1)},[f,c,p]),E=C?C.label:t(`settings.yuri.archivedSessions.dialog.title`),D=C?C.sessions.length===1?t(`settings.yuri.archivedSessions.dialog.sessionCountSingle`,{count:C.sessions.length}):t(`settings.yuri.archivedSessions.dialog.sessionCountPlural`,{count:C.sessions.length}):t(`settings.yuri.archivedSessions.dialog.description`),O=(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[C?(0,Y.jsxs)(G,{type:`button`,variant:`ghost`,size:`sm`,className:`!h-7 !px-2 !font-normal text-muted-foreground`,onClick:()=>_(null),children:[(0,Y.jsx)(q,{name:`arrow-left-s`,className:`mr-1 h-4 w-4`}),t(`settings.yuri.archivedSessions.dialog.backToProjects`)]}):null,m?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 typography-meta text-muted-foreground py-6`,children:[(0,Y.jsx)(q,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),t(`settings.yuri.archivedSessions.dialog.loading`)]}):C?C.sessions.length===0?(0,Y.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,Y.jsx)(`div`,{className:`space-y-1.5`,children:C.sessions.map(e=>{let n=Ve(e),r=Ua(e),i=v===e.id;return(0,Y.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,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`typography-ui-label font-medium text-foreground truncate`,children:e.title||t(`sessions.sidebar.session.untitled`)}),(0,Y.jsxs)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:[r>0?Wt(r):null,r>0&&n?` · `:null,n?je(n):null]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,Y.jsx)(G,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,disabled:i,onClick:()=>T(e),children:t(`settings.yuri.archivedSessions.actions.preview`)}),(0,Y.jsxs)(G,{type:`button`,variant:`default`,size:`xs`,className:`!font-normal`,disabled:i,onClick:()=>void w(e),children:[i?(0,Y.jsx)(q,{name:`loader-4`,className:`mr-1 h-3.5 w-3.5 animate-spin`}):(0,Y.jsx)(q,{name:`inbox-unarchive`,className:`mr-1 h-3.5 w-3.5`}),t(`settings.yuri.archivedSessions.actions.restore`)]})]})]},e.id)})}):b.length===0?(0,Y.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,Y.jsx)(`div`,{className:`space-y-1.5`,children:b.map(e=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>_(e.projectId),className:W(`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,Y.jsx)(q,{name:`folder`,className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`typography-ui-label font-medium text-foreground truncate`,children:e.label}),e.path?(0,Y.jsx)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:je(e.path)}):null]}),(0,Y.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,Y.jsx)(q,{name:`arrow-right-s`,className:`h-4 w-4 shrink-0 text-muted-foreground`})]},e.projectId))}),!C&&!m&&S>0?(0,Y.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(S===1?`settings.yuri.archivedSessions.summarySingle`:`settings.yuri.archivedSessions.summaryPlural`,{count:S})}):null]});return o?(0,Y.jsxs)(`div`,{"data-settings-item":`archived-sessions.manage`,className:`yuri-settings-section-stack`,children:[(0,Y.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.archivedSessions.description`)}),O]}):a?(0,Y.jsx)(Bt,{open:s,title:E,onClose:()=>c(!1),contentMaxHeightClassName:`max-h-[min(80vh,640px)]`,renderHeader:e=>(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border/40 px-3 py-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:E}),e]}),(0,Y.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:D})]}),children:O}):(0,Y.jsx)(et,{open:s,onOpenChange:c,children:(0,Y.jsxs)(Ze,{className:`max-h-[85vh] max-w-2xl overflow-y-auto`,children:[(0,Y.jsxs)(Xe,{children:[(0,Y.jsx)(Qe,{children:E}),(0,Y.jsx)($e,{children:D})]}),O]})})}function Ga(){let e=(0,J.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Y.jsx)(Wa,{mode:`dialog`}),e[0]=t):t=e[0],t}var Ka=48;function qa({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=Ae(()=>{s.current=null;let e=i.current,t=a.current;if(!e||!t)return;let n=Math.min(1,Math.max(0,t.scrollTop/Ka)),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=Ae(()=>{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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`header`,{ref:i,className:W(`yuri-mobile-collapsing-header flex shrink-0 items-start gap-4`,r),children:(0,Y.jsxs)(`div`,{className:`yuri-mobile-collapsing-header-inner`,children:[(0,Y.jsxs)(`div`,{className:`yuri-mobile-collapsing-header-title-block min-w-0 flex-1`,children:[t?(0,Y.jsx)(`p`,{className:`yuri-mobile-collapsing-header-eyebrow truncate typography-micro font-medium text-muted-foreground`,children:t}):null,(0,Y.jsx)(`h1`,{className:`yuri-mobile-root-page-title truncate font-semibold text-foreground`,children:e})]}),n?(0,Y.jsx)(`div`,{className:`yuri-mobile-collapsing-header-trailing flex min-h-10 shrink-0 items-center gap-3.5`,children:n}):null]})}),(0,Y.jsx)(`div`,{className:`yuri-mobile-collapsing-header-spacer`,"aria-hidden":`true`})]})}export{Dr as A,Sn as B,yi as C,$r as D,si as E,vr as F,gr as I,ir as L,yr as M,xr as N,wr as O,Sr as P,jn as R,bi as S,oi as T,Cn as V,qi as _,Ia as a,Di as b,ba as c,fa as d,da as f,Yi as g,Ji as h,Va as i,br as j,Er as k,ya as l,Ui as m,Ga as n,Na as o,Ki as p,Wa as r,Sa as s,qa as t,ua as u,Hi as v,ci as w,xi as x,Ri as y,wn as z};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Q as t,X as n,Y as r,Z as i,et as a,it as o,rt as s}from"./vendor-base-ui-CdzJ6My_.js";import{n as c}from"./vendor-react-BP2cRVqX.js";import{f as l,r as u}from"./button-_ReBqWzC.js";import{n as d}from"./Icon-2cKLcXGe.js";import{t as f}from"./multirun-DKsVtdZX.js";var p=c(),m=e(o(),1),h=s(),g=e=>{let o=(0,p.c)(33),{open:s,onOpenChange:c,initialPrompt:g}=e,v=m.useId(),{t:y}=l(),b=_,x;o[0]===c?x=o[1]:(x=e=>{!e&&b()||c(e)},o[0]=c,o[1]=x);let S;o[2]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,h.jsx)(a,{className:u(`fixed inset-0 z-50 bg-black/50 dark:bg-black/75`,`transition-opacity duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[ending-style]:opacity-0`)}),o[2]=S):S=o[2];let C;o[3]===Symbol.for(`react.memo_cache_sentinel`)?(C=u(`relative pointer-events-auto`,`w-[90vw] max-w-[720px] h-[680px] max-h-[85vh]`,`flex flex-col rounded-xl border shadow-none overflow-hidden origin-center`,`bg-background`,`transition-all duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]`,`data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]`),o[3]=C):C=o[3];let w;o[4]===c?w=o[5]:(w=()=>c(!1),o[4]=c,o[5]=w);let T;o[6]===y?T=o[7]:(T=y(`multiRun.window.actions.closeAria`),o[6]=y,o[7]=T);let E;o[8]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,h.jsx)(d,{name:`close`,className:`h-5 w-5`}),o[8]=E):E=o[8];let D;o[9]!==w||o[10]!==T?(D=(0,h.jsx)(`div`,{className:`absolute right-0.5 top-0.5 z-50`,children:(0,h.jsx)(`button`,{type:`button`,onClick:w,"aria-label":T,className:`inline-flex h-7 w-7 items-center justify-center rounded-md p-0.5 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:E})}),o[9]=w,o[10]=T,o[11]=D):D=o[11];let O;o[12]===y?O=o[13]:(O=y(`multiRun.window.description`),o[12]=y,o[13]=O);let k;o[14]!==v||o[15]!==O?(k=(0,h.jsx)(t,{id:v,className:`sr-only`,children:O}),o[14]=v,o[15]=O,o[16]=k):k=o[16];let A,j;o[17]===c?(A=o[18],j=o[19]):(A=()=>c(!1),j=()=>c(!1),o[17]=c,o[18]=A,o[19]=j);let M;o[20]!==g||o[21]!==A||o[22]!==j?(M=(0,h.jsx)(f,{initialPrompt:g,onCreated:A,onCancel:j,isWindowed:!0}),o[20]=g,o[21]=A,o[22]=j,o[23]=M):M=o[23];let N;o[24]!==v||o[25]!==M||o[26]!==D||o[27]!==k?(N=(0,h.jsxs)(n,{children:[S,(0,h.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center pointer-events-none`,children:(0,h.jsxs)(i,{"aria-describedby":v,className:C,children:[D,k,M]})})]}),o[24]=v,o[25]=M,o[26]=D,o[27]=k,o[28]=N):N=o[28];let P;return o[29]!==s||o[30]!==x||o[31]!==N?(P=(0,h.jsx)(r,{open:s,onOpenChange:x,children:N}),o[29]=s,o[30]=x,o[31]=N,o[32]=P):P=o[32],P};function _(){return typeof document>`u`?!1:!!document.querySelector(`[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]`)}export{g as MultiRunWindow};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Q as t,X as n,Y as r,Z as i,et as a,it as o,rt as s}from"./vendor-base-ui-CdzJ6My_.js";import{n as c}from"./vendor-react-BP2cRVqX.js";import{f as l,r as u}from"./button-D_HdP1Oy.js";import{n as d}from"./Icon-BXTZRnIO.js";import{t as f}from"./multirun-Cvl4FMPo.js";var p=c(),m=e(o(),1),h=s(),g=e=>{let o=(0,p.c)(33),{open:s,onOpenChange:c,initialPrompt:g}=e,v=m.useId(),{t:y}=l(),b=_,x;o[0]===c?x=o[1]:(x=e=>{!e&&b()||c(e)},o[0]=c,o[1]=x);let S;o[2]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,h.jsx)(a,{className:u(`fixed inset-0 z-50 bg-black/50 dark:bg-black/75`,`transition-opacity duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[ending-style]:opacity-0`)}),o[2]=S):S=o[2];let C;o[3]===Symbol.for(`react.memo_cache_sentinel`)?(C=u(`relative pointer-events-auto`,`w-[90vw] max-w-[720px] h-[680px] max-h-[85vh]`,`flex flex-col rounded-xl border shadow-none overflow-hidden origin-center`,`bg-background`,`transition-all duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]`,`data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]`),o[3]=C):C=o[3];let w;o[4]===c?w=o[5]:(w=()=>c(!1),o[4]=c,o[5]=w);let T;o[6]===y?T=o[7]:(T=y(`multiRun.window.actions.closeAria`),o[6]=y,o[7]=T);let E;o[8]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,h.jsx)(d,{name:`close`,className:`h-5 w-5`}),o[8]=E):E=o[8];let D;o[9]!==w||o[10]!==T?(D=(0,h.jsx)(`div`,{className:`absolute right-0.5 top-0.5 z-50`,children:(0,h.jsx)(`button`,{type:`button`,onClick:w,"aria-label":T,className:`inline-flex h-7 w-7 items-center justify-center rounded-md p-0.5 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:E})}),o[9]=w,o[10]=T,o[11]=D):D=o[11];let O;o[12]===y?O=o[13]:(O=y(`multiRun.window.description`),o[12]=y,o[13]=O);let k;o[14]!==v||o[15]!==O?(k=(0,h.jsx)(t,{id:v,className:`sr-only`,children:O}),o[14]=v,o[15]=O,o[16]=k):k=o[16];let A,j;o[17]===c?(A=o[18],j=o[19]):(A=()=>c(!1),j=()=>c(!1),o[17]=c,o[18]=A,o[19]=j);let M;o[20]!==g||o[21]!==A||o[22]!==j?(M=(0,h.jsx)(f,{initialPrompt:g,onCreated:A,onCancel:j,isWindowed:!0}),o[20]=g,o[21]=A,o[22]=j,o[23]=M):M=o[23];let N;o[24]!==v||o[25]!==M||o[26]!==D||o[27]!==k?(N=(0,h.jsxs)(n,{children:[S,(0,h.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center pointer-events-none`,children:(0,h.jsxs)(i,{"aria-describedby":v,className:C,children:[D,k,M]})})]}),o[24]=v,o[25]=M,o[26]=D,o[27]=k,o[28]=N):N=o[28];let P;return o[29]!==s||o[30]!==x||o[31]!==N?(P=(0,h.jsx)(r,{open:s,onOpenChange:x,children:N}),o[29]=s,o[30]=x,o[31]=N,o[32]=P):P=o[32],P};function _(){return typeof document>`u`?!1:!!document.querySelector(`[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]`)}export{g as MultiRunWindow};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{u as t}from"./queryRuntime-DKGLQtb9.js";import{Cn as n,en as r,hn as i,i as a,pn as o}from"./persistence-Dzooc9Xg.js";import{_ as s,h as c,i as l,n as u,r as d}from"./desktopHosts-BDyl2P7W.js";import{it as f,rt as p}from"./vendor-base-ui-CdzJ6My_.js";import{n as m}from"./vendor-react-BP2cRVqX.js";import{d as h,f as g,r as _,t as v}from"./button-_ReBqWzC.js";import{n as y}from"./Icon-2cKLcXGe.js";import{o as b,r as x}from"./dialog-NsOVcGdh.js";import{t as S}from"./input-BI3Ya8O_.js";var C=m(),w=e(f(),1),T=p();function E(e){switch(e){case`ok`:return null;case`auth`:return`onboarding.remoteConnection.probe.authMessage`;case`update-recommended`:return`onboarding.remoteConnection.probe.updateRecommendedMessage`;case`incompatible`:return`onboarding.remoteConnection.probe.incompatibleMessage`;case`wrong-service`:return`onboarding.remoteConnection.probe.wrongServiceMessage`;case`unreachable`:return`onboarding.remoteConnection.probe.unreachableMessage`;default:return null}}function D(e){return e===`wrong-service`||e===`unreachable`||e===`incompatible`}function O({onBack:e,showBackButton:t=!0,initialUrl:n=``,initialLabel:a=``,isRecoveryMode:o=!1,onConnect:c,onSwitchToLocal:f}){let{t:p}=g(),[m,h]=(0,w.useState)(n),[_,y]=(0,w.useState)(a),[b,x]=(0,w.useState)(`idle`),[C,O]=(0,w.useState)(null),[k,A]=(0,w.useState)(``),j=s(m),M=j?.persistedUrl??null,N=(0,w.useCallback)(e=>{h(e.target.value),x(`idle`),O(null),A(``)},[]),P=(0,w.useCallback)(e=>{y(e.target.value)},[]),F=(0,w.useCallback)(async()=>{if(M){x(`testing`),O(null),A(``);try{let e=await u(M);O(e),x(e.status===`ok`||e.status===`update-recommended`?`success`:`error`)}catch(e){A(e instanceof Error?e.message:p(`onboarding.remoteConnection.errors.connectionTestFailed`)),x(`error`)}}},[M,p]),I=(0,w.useCallback)(async()=>{if(!j)return;let e=j.persistedUrl;x(`testing`),O(null),A(``);try{let t=await u(e);if(O(t),D(t.status)){x(`error`);return}let n=await d(),a=_.trim()||e,o=n.hosts.find(t=>t.url===e),s=o?o.id:`host-${Date.now().toString(16)}`,f={id:s,label:a,url:e,apiUrl:e},p=o?n.hosts.map(e=>e.id===s?f:e):[...n.hosts,f];if(await l({hosts:p,defaultHostId:s,initialHostChoiceCompleted:!0}),c?.(),j.redeemUrl){window.location.assign(j.redeemUrl);return}r()&&await i()}catch(e){A(e instanceof Error?e.message:p(`onboarding.remoteConnection.errors.failedToSaveConnection`)),x(`error`)}},[j,_,c,p]),L=b===`testing`,R=M!==null&&!L,z=M!==null&&!L&&!D(C?.status??null),B=E(C?.status??null),V=C?.status===`ok`,H=C?.status===`update-recommended`,U=C?.status===`auth`,W=D(C?.status??null);return(0,T.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-8`,children:(0,T.jsxs)(`div`,{className:`w-full max-w-md space-y-6`,children:[t&&(0,T.jsx)(`div`,{className:`flex items-center`,children:(0,T.jsx)(v,{variant:`ghost`,onClick:e,className:`p-0 text-muted-foreground hover:text-foreground`,children:p(`onboarding.common.actions.back`)})}),(0,T.jsxs)(`div`,{className:`space-y-2 text-center`,children:[(0,T.jsx)(`h1`,{className:`typography-ui-header text-xl font-semibold text-foreground`,children:p(o?`onboarding.remoteConnection.titleRecovery`:`onboarding.remoteConnection.title`)}),(0,T.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:p(`onboarding.remoteConnection.description`)})]}),(0,T.jsxs)(`div`,{className:`space-y-4`,children:[(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(`label`,{htmlFor:`remote-url`,className:`text-sm text-foreground`,children:p(`onboarding.remoteConnection.field.serverAddress`)}),(0,T.jsx)(S,{id:`remote-url`,type:`url`,value:m,onChange:N,placeholder:p(`onboarding.remoteConnection.field.serverAddressPlaceholder`),disabled:L})]}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(`label`,{htmlFor:`remote-label`,className:`text-sm text-foreground`,children:p(`onboarding.remoteConnection.field.nameOptional`)}),(0,T.jsx)(S,{id:`remote-label`,type:`text`,value:_,onChange:P,placeholder:p(`onboarding.remoteConnection.field.namePlaceholder`),disabled:L})]})]}),C&&V&&(0,T.jsx)(`div`,{className:`rounded-lg border p-3 text-sm`,style:{borderColor:`var(--status-success)`,color:`var(--status-success)`},children:p(`onboarding.remoteConnection.status.connectedSuccessfully`,{latencyMs:C.latencyMs})}),C&&U&&(0,T.jsx)(`div`,{className:`rounded-lg border p-3 text-sm`,style:{borderColor:`var(--status-warning)`,color:`var(--status-warning)`},children:p(`onboarding.remoteConnection.status.authWarning`)}),C&&H&&(0,T.jsx)(`div`,{className:`rounded-lg border p-3 text-sm`,style:{borderColor:`var(--status-warning)`,color:`var(--status-warning)`},children:B?p(B):null}),C&&W&&(0,T.jsxs)(`div`,{className:`rounded-lg border p-3 text-sm space-y-3`,style:{borderColor:`var(--status-error)`,color:`var(--status-error)`},children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`font-semibold mb-1`,children:p(`onboarding.remoteConnection.status.connectionFailed`)}),(0,T.jsx)(`div`,{className:`opacity-90`,children:B?p(B):null})]}),(0,T.jsx)(`div`,{className:`text-xs opacity-80`,children:C.status===`unreachable`?p(`onboarding.remoteConnection.status.suggestionsUnreachable`):p(`onboarding.remoteConnection.status.suggestionsWrongService`)})]}),k&&(0,T.jsx)(`div`,{className:`rounded-lg border p-3 text-sm`,style:{borderColor:`var(--status-error)`,color:`var(--status-error)`},children:k}),(0,T.jsxs)(`div`,{className:`flex gap-3`,children:[(0,T.jsx)(v,{variant:`outline`,onClick:F,disabled:!R,children:p(L?`onboarding.remoteConnection.actions.testing`:`onboarding.remoteConnection.actions.testConnection`)}),(0,T.jsx)(v,{onClick:I,disabled:!z,children:p(`onboarding.remoteConnection.actions.connectAndRestart`)})]}),W&&(0,T.jsxs)(`div`,{className:`flex flex-col gap-2 pt-2 border-t border-border`,children:[(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground text-center`,children:p(`onboarding.remoteConnection.actions.whatToDo`)}),(0,T.jsxs)(`div`,{className:`flex gap-2`,children:[(0,T.jsx)(v,{variant:`outline`,size:`sm`,onClick:e,className:`flex-1`,children:p(`onboarding.remoteConnection.actions.chooseDifferentServer`)}),!o&&f&&(0,T.jsx)(v,{variant:`outline`,size:`sm`,onClick:f,className:`flex-1`,children:p(`onboarding.remoteConnection.actions.useLocalInstead`)})]})]})]})})}async function k(){let e=await t(`/health`);if(!e.ok)return!1;let n=await e.json().catch(()=>null);return n?.openCodeRunning===!0||n?.isOpenCodeReady===!0}async function A(){return(await t(`/api/opencode/retry`,{method:`POST`})).ok?k():!1}var j=`curl -fsSL https://opencode.ai/v2/install | bash`,M=`https://opencode.ai/docs`,N=2500,P=1e4;function F(e){let t=(0,C.c)(5),{onCopy:n,copyTitle:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,T.jsxs)(`code`,{className:`flex-1 text-left overflow-x-auto whitespace-nowrap`,children:[(0,T.jsx)(`span`,{style:{color:`var(--syntax-keyword)`},children:`curl`}),(0,T.jsx)(`span`,{className:`text-muted-foreground`,children:` -fsSL `}),(0,T.jsx)(`span`,{style:{color:`var(--syntax-string)`},children:`https://opencode.ai/v2/install`}),(0,T.jsx)(`span`,{className:`text-muted-foreground`,children:` | `}),(0,T.jsx)(`span`,{style:{color:`var(--syntax-keyword)`},children:`bash`})]}),t[0]=i):i=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,T.jsx)(y,{name:`file-copy`,className:`h-4 w-4`}),t[1]=a):a=t[1];let o;return t[2]!==r||t[3]!==n?(o=(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3 w-full`,children:[i,(0,T.jsx)(`button`,{onClick:n,className:`inline-flex items-center text-muted-foreground hover:text-foreground transition-colors shrink-0`,title:r,"aria-label":r,children:a})]}),t[2]=r,t[3]=n,t[4]=o):o=t[4],o}function I({onCliAvailable:e}){let{t:s}=g(),[c,u]=w.useState(!1),[f,p]=w.useState(!1),[m,b]=w.useState(!1),[x,C]=w.useState(!1),[E,D]=w.useState(``),[I,L]=w.useState(`unknown`),[R,z]=w.useState(`local`),[B,V]=w.useState(!1),[H,U]=w.useState(!1),[W,G]=w.useState(null),K=w.useRef(!1);w.useEffect(()=>{p(r())},[]),w.useEffect(()=>{if(typeof navigator>`u`){L(`unknown`);return}let e=navigator.userAgent||``;/Windows/i.test(e)?L(`windows`):/Macintosh|Mac OS X/i.test(e)?L(`macos`):/Linux/i.test(e)?L(`linux`):L(`unknown`)},[]),w.useEffect(()=>{let e=!1;return(async()=>{try{let n=await t(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(!n.ok)return;let r=await n.json().catch(()=>null);if(!r||e)return;let i=typeof r.opencodeBinary==`string`?r.opencodeBinary.trim():``;i&&D(i)}catch{}})(),()=>{e=!0}},[]);let q=w.useCallback(async e=>{let t=e.target;t.closest(`.app-region-no-drag`)||t.closest(`button, a, input, select, textarea, code, summary, details`)||e.button===0&&f&&await n()},[f]),J=w.useCallback(async e=>{if(!f)return;let t=await d();await l({...t,...e===`local`?{defaultHostId:`local`}:{},initialHostChoiceCompleted:!0})},[f]),Y=w.useCallback(async()=>{if(!K.current){K.current=!0;try{f&&await J(`local`),await e?.()}catch(e){throw K.current=!1,e}}},[f,e,J]);w.useEffect(()=>{if(R!==`local`)return;let e=!1,t=null,n=0,r=async()=>{if(!e){try{let t=await k(),r=Date.now();if(!t&&r-n>=P&&(n=r,t=await A()),e)return;if(t){await Y();return}}catch{}e||(t=setTimeout(r,N))}};return t=setTimeout(r,N),()=>{e=!0,t&&clearTimeout(t)}},[R,Y]);let X=w.useCallback(async()=>{C(!0),G(null);try{let e=await k();e||=await A(),e?await Y():G(s(`onboarding.localSetup.errors.cliNotReady`))}catch{G(s(`onboarding.localSetup.errors.detectionFailed`))}finally{C(!1)}},[Y,s]),Z=w.useCallback(async()=>{if(!(typeof window>`u`)&&f)try{let e=await o();e.success&&e.path&&e.path.trim().length>0&&D(e.path.trim())}catch{}},[f]),Q=w.useCallback(async()=>{b(!0);try{if(await a({opencodeBinary:E.trim()}),f){await J(`local`),await i();return}await t(`/api/config/reload`,{method:`POST`})}finally{setTimeout(()=>b(!1),1e3)}},[f,E,J]),$=w.useCallback(async()=>{let e=await h(j);e.ok?(u(!0),setTimeout(()=>u(!1),2e3)):console.error(`Failed to copy:`,e.error)},[]),ee=M,te=I===`windows`?`C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd`:I===`linux`?`/home/you/.bun/bin/opencode`:`/Users/you/.bun/bin/opencode`,ne=!f||R===`local`;return(0,T.jsx)(`div`,{className:`app-region-drag h-full flex items-center justify-center bg-transparent p-8 cursor-default select-none overflow-y-auto`,onMouseDown:q,children:(0,T.jsxs)(`div`,{className:`w-full max-w-md space-y-7`,children:[(0,T.jsxs)(`header`,{className:`text-center space-y-1.5`,children:[(0,T.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-foreground`,children:s(`onboarding.chooser.title`)}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s(`onboarding.chooser.description`)})]}),f&&(0,T.jsxs)(`div`,{className:`app-region-no-drag flex gap-1.5`,children:[(0,T.jsx)(`button`,{type:`button`,className:_(`flex-1 px-4 py-2 rounded-lg border transition-colors text-sm`,R===`local`?`border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10`:`border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground`),onClick:()=>z(`local`),children:s(`onboarding.chooser.tabs.localInstall`)}),(0,T.jsx)(`button`,{type:`button`,className:_(`flex-1 px-4 py-2 rounded-lg border transition-colors text-sm`,R===`remote`?`border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10`:`border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground`),onClick:()=>z(`remote`),children:s(`onboarding.chooser.tabs.connectRemote`)})]}),f&&R===`remote`?(0,T.jsx)(`div`,{className:`app-region-no-drag`,children:(0,T.jsx)(O,{onBack:()=>z(`local`),showBackButton:!1,onSwitchToLocal:()=>z(`local`)})}):null,ne&&(0,T.jsxs)(`div`,{className:`space-y-4`,children:[I===`windows`&&(0,T.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/50 p-4`,children:[(0,T.jsx)(`div`,{className:`text-sm text-foreground`,children:s(`onboarding.localSetup.windows.title`)}),(0,T.jsxs)(`ol`,{className:`mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground`,children:[(0,T.jsx)(`li`,{children:s(`onboarding.localSetup.windows.stepRunInstallInWsl`)}),(0,T.jsx)(`li`,{children:s(`onboarding.localSetup.windows.stepSetBinaryPath`)})]})]}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground text-center leading-relaxed`,children:s(`onboarding.localSetup.intro`)}),(0,T.jsx)(`div`,{className:`app-region-no-drag rounded-lg border border-border bg-background/60 backdrop-blur-sm px-4 py-3 font-mono text-sm`,children:c?(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,style:{color:`var(--status-success)`},children:[(0,T.jsx)(y,{name:`check`,className:`h-4 w-4`}),s(`onboarding.common.status.copiedToClipboard`)]}):(0,T.jsx)(F,{onCopy:$,copyTitle:s(`onboarding.common.copyToClipboard`)})}),(0,T.jsxs)(`div`,{className:`app-region-no-drag flex items-center justify-between`,children:[(0,T.jsxs)(`a`,{href:ee,target:`_blank`,rel:`noopener noreferrer`,className:`text-xs text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1`,children:[s(I===`windows`?`onboarding.localSetup.docs.windows`:`onboarding.localSetup.docs.default`),(0,T.jsx)(y,{name:`external-link`,className:`h-3 w-3`})]}),(0,T.jsx)(`button`,{type:`button`,onClick:X,disabled:x,className:`text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,children:s(x?`onboarding.localSetup.actions.checking`:`onboarding.localSetup.actions.checkNow`)})]}),W&&(0,T.jsx)(`p`,{role:`alert`,className:`text-center text-xs text-[var(--status-error-foreground)]`,children:W}),(0,T.jsxs)(`div`,{className:`rounded-lg border px-4 py-3 flex items-center gap-3`,style:{borderColor:`color-mix(in srgb, var(--primary-base) 20%, transparent)`,backgroundColor:`color-mix(in srgb, var(--primary-base) 6%, transparent)`},role:`status`,"aria-live":`polite`,children:[(0,T.jsxs)(`span`,{className:`relative inline-flex h-2.5 w-2.5 shrink-0`,"aria-hidden":!0,children:[(0,T.jsx)(`span`,{className:`absolute inset-0 rounded-full`,style:{backgroundColor:`var(--primary-base)`,animation:`pulse-opacity 1.6s ease-in-out infinite`}}),(0,T.jsx)(`span`,{className:`absolute inset-[-4px] rounded-full`,style:{backgroundColor:`var(--primary-base)`,animation:`pulse-opacity-dim 1.6s ease-in-out infinite`,opacity:0}})]}),(0,T.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,T.jsx)(`div`,{className:`text-sm text-foreground leading-tight`,children:s(`onboarding.localSetup.status.watching`)}),(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground leading-tight mt-0.5`,children:s(`onboarding.localSetup.status.autoContinue`)})]})]}),(0,T.jsxs)(`details`,{className:`app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors`,open:B,onToggle:e=>V(e.currentTarget.open),children:[(0,T.jsxs)(`summary`,{className:`flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden`,children:[(0,T.jsx)(`span`,{children:s(`onboarding.localSetup.advanced.title`)}),(0,T.jsx)(y,{name:`arrow-down-s`,className:`h-4 w-4 transition-transform group-open:rotate-180`})]}),(0,T.jsxs)(`div`,{className:`pb-4 space-y-2`,children:[(0,T.jsxs)(`div`,{className:`flex gap-2`,children:[(0,T.jsx)(S,{value:E,onChange:e=>D(e.target.value),placeholder:te,disabled:m,className:`flex-1 font-mono text-xs`}),(0,T.jsx)(v,{type:`button`,variant:`secondary`,size:`sm`,onClick:Z,disabled:m||!f,children:s(`onboarding.localSetup.actions.browse`)}),(0,T.jsx)(v,{type:`button`,size:`sm`,onClick:Q,disabled:m||!E.trim(),children:s(`onboarding.localSetup.actions.apply`)})]}),(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground/70`,children:s(`onboarding.localSetup.helper.saveAndReload`)})]})]}),(0,T.jsxs)(`details`,{className:`app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors`,open:H,onToggle:e=>U(e.currentTarget.open),children:[(0,T.jsxs)(`summary`,{className:`flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden`,children:[(0,T.jsx)(`span`,{children:s(`onboarding.localSetup.troubleshoot.title`)}),(0,T.jsx)(y,{name:`arrow-down-s`,className:`h-4 w-4 transition-transform group-open:rotate-180`})]}),(0,T.jsx)(`ul`,{className:`pb-4 space-y-1.5 text-xs text-muted-foreground list-disc pl-4`,children:I===`windows`?(0,T.jsx)(T.Fragment,{children:(0,T.jsx)(`li`,{children:s(`onboarding.localSetup.windows.hintDetectionFailed`)})}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`li`,{children:s(`onboarding.localSetup.hint.ensurePath`)}),(0,T.jsx)(`li`,{children:s(`onboarding.localSetup.hint.setEnv`)}),(0,T.jsx)(`li`,{children:s(`onboarding.localSetup.hint.missingRuntime`)})]})})]})]})]})})}var L=`curl -fsSL https://opencode.ai/v2/install | bash`,R=`https://opencode.ai/docs`;function z(e){let t=(0,C.c)(5),{onCopy:n,copyTitle:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,T.jsxs)(`code`,{children:[(0,T.jsx)(`span`,{style:{color:`var(--syntax-keyword)`},children:`curl`}),(0,T.jsx)(`span`,{className:`text-muted-foreground`,children:` -fsSL `}),(0,T.jsx)(`span`,{style:{color:`var(--syntax-string)`},children:`https://opencode.ai/v2/install`}),(0,T.jsx)(`span`,{className:`text-muted-foreground`,children:` | `}),(0,T.jsx)(`span`,{style:{color:`var(--syntax-keyword)`},children:`bash`})]}),t[0]=i):i=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,T.jsx)(y,{name:`file-copy`,className:`h-4 w-4`}),t[1]=a):a=t[1];let o;return t[2]!==r||t[3]!==n?(o=(0,T.jsxs)(`div`,{className:`flex items-center justify-center gap-3`,children:[i,(0,T.jsx)(`button`,{onClick:n,className:`inline-flex items-center text-muted-foreground hover:text-foreground transition-colors`,title:r,children:a})]}),t[2]=r,t[3]=n,t[4]=o):o=t[4],o}var B=3e4;function V({onBack:e,onCliAvailable:s,isFromRecovery:c=!1,onSwitchToRemote:l}){let{t:u}=g(),[d,f]=w.useState(!1),[p,m]=w.useState(!1),[_,b]=w.useState(!1),[x,C]=w.useState(!1),[E,D]=w.useState(!1),[O,j]=w.useState(null),[M,N]=w.useState(``),[P,F]=w.useState(`unknown`);w.useEffect(()=>{let e=setTimeout(()=>m(!0),B);return()=>clearTimeout(e)},[]),w.useEffect(()=>{b(r())},[]),w.useEffect(()=>{if(typeof navigator>`u`){F(`unknown`);return}let e=navigator.userAgent||``;if(/Windows/i.test(e)){F(`windows`);return}if(/Macintosh|Mac OS X/i.test(e)){F(`macos`);return}if(/Linux/i.test(e)){F(`linux`);return}F(`unknown`)},[]),w.useEffect(()=>{let e=!1;return(async()=>{try{let n=await t(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(!n.ok)return;let r=await n.json().catch(()=>null);if(!r||e)return;let i=typeof r.opencodeBinary==`string`?r.opencodeBinary.trim():``;i&&N(i)}catch{}})(),()=>{e=!0}},[]);let I=w.useCallback(async e=>{e.target.closest(`button, a, input, select, textarea, code`)||e.button===0&&_&&await n()},[_]),V=w.useCallback(async()=>{if(!(typeof window>`u`)&&_)try{let e=await o();e.success&&e.path&&e.path.trim().length>0&&N(e.path.trim())}catch{}},[_]),H=w.useCallback(async()=>{C(!0);try{if(await a({opencodeBinary:M.trim()}),_){await i();return}await t(`/api/config/reload`,{method:`POST`})}finally{setTimeout(()=>C(!1),1e3)}},[_,M]),U=w.useCallback(async()=>{let e=await h(L);e.ok?(f(!0),setTimeout(()=>f(!1),2e3)):console.error(`Failed to copy:`,e.error)},[]),W=w.useCallback(async()=>{D(!0),j(null);try{let e=await k();e||=await A(),e?s?.():j(u(`onboarding.localSetup.errors.cliNotReady`))}catch(e){j(e instanceof Error?e.message:u(`onboarding.localSetup.errors.detectionFailed`))}finally{D(!1)}},[s,u]),G=R,K=P===`windows`?`C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd`:P===`linux`?`/home/you/.bun/bin/opencode`:`/Users/you/.bun/bin/opencode`;return(0,T.jsxs)(`div`,{className:`h-full flex items-center justify-center bg-transparent p-8 relative cursor-default select-none`,onMouseDown:I,children:[(0,T.jsxs)(`div`,{className:`w-full max-w-lg space-y-4 text-center`,children:[(0,T.jsx)(`div`,{className:`flex items-center`,children:(0,T.jsx)(v,{variant:`ghost`,onClick:e,className:`p-0 text-muted-foreground hover:text-foreground`,children:u(`onboarding.common.actions.back`)})}),(0,T.jsxs)(`div`,{className:`space-y-4`,children:[(0,T.jsx)(`h1`,{className:`text-3xl font-semibold tracking-tight text-foreground`,children:u(`onboarding.localSetup.title`)}),(0,T.jsx)(`p`,{className:`text-muted-foreground`,children:u(`onboarding.localSetup.description`)})]}),P===`windows`&&(0,T.jsxs)(`div`,{className:`mx-auto max-w-2xl rounded-lg border border-border bg-background/50 p-4 text-left`,children:[(0,T.jsx)(`div`,{className:`text-sm text-foreground`,children:u(`onboarding.localSetup.windows.title`)}),(0,T.jsxs)(`ol`,{className:`mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground`,children:[(0,T.jsx)(`li`,{children:u(`onboarding.localSetup.windows.stepRunInstallInWsl`)}),(0,T.jsx)(`li`,{children:u(`onboarding.localSetup.windows.stepSetBinaryPath`)})]})]}),(0,T.jsx)(`div`,{className:`flex justify-center`,children:(0,T.jsx)(`div`,{className:`bg-background/60 backdrop-blur-sm border border-border rounded-lg px-5 py-3 font-mono text-sm w-fit`,children:d?(0,T.jsxs)(`div`,{className:`flex items-center justify-center gap-2`,style:{color:`var(--status-success)`},children:[(0,T.jsx)(y,{name:`check`,className:`h-4 w-4`}),u(`onboarding.common.status.copiedToClipboard`)]}):(0,T.jsx)(z,{onCopy:U,copyTitle:u(`onboarding.common.copyToClipboard`)})})}),(0,T.jsxs)(`a`,{href:G,target:`_blank`,rel:`noopener noreferrer`,className:`text-sm text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1 justify-center`,children:[u(P===`windows`?`onboarding.localSetup.docs.windows`:`onboarding.localSetup.docs.default`),(0,T.jsx)(y,{name:`external-link`,className:`h-3 w-3`})]}),O&&(0,T.jsx)(`div`,{className:`mx-auto max-w-md rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive`,children:O}),(0,T.jsxs)(`div`,{className:`space-y-3`,children:[(0,T.jsx)(v,{type:`button`,onClick:W,disabled:E,className:`w-full max-w-xs`,size:`lg`,children:u(E?`onboarding.localSetup.actions.checking`:`onboarding.localSetup.actions.checkAndContinue`)}),(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`onboarding.localSetup.helper.checkAndContinue`)})]}),(0,T.jsx)(`div`,{className:`mx-auto w-full max-w-xl pt-4`,children:(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:u(`onboarding.localSetup.field.alreadyInstalled`)}),(0,T.jsxs)(`div`,{className:`flex gap-2`,children:[(0,T.jsx)(S,{value:M,onChange:e=>N(e.target.value),placeholder:K,disabled:x,className:`flex-1 font-mono text-xs`}),(0,T.jsx)(v,{type:`button`,variant:`secondary`,onClick:V,disabled:x||!_,children:u(`onboarding.localSetup.actions.browse`)}),(0,T.jsx)(v,{type:`button`,onClick:H,disabled:x,children:u(`onboarding.localSetup.actions.apply`)})]}),(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground/70`,children:u(`onboarding.localSetup.helper.saveAndReload`)})]})}),c&&l&&(0,T.jsxs)(`div`,{className:`text-center pt-4`,children:[(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground mb-2`,children:u(`onboarding.localSetup.remotePreference`)}),(0,T.jsx)(v,{variant:`link`,onClick:l,children:u(`onboarding.localSetup.actions.connectRemoteServer`)})]})]}),p&&(0,T.jsx)(`div`,{className:`absolute bottom-8 left-0 right-0 text-center space-y-1`,children:P===`windows`?(0,T.jsx)(T.Fragment,{children:(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground/70`,children:u(`onboarding.localSetup.windows.hintDetectionFailed`)})}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground/70`,children:u(`onboarding.localSetup.hint.ensurePath`)}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground/70`,children:u(`onboarding.localSetup.hint.setEnv`)}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground/70`,children:u(`onboarding.localSetup.hint.missingRuntime`)})]})})]})}function H(e,t){if(e?.trim())return c(e.trim());if(t)return c(t)}function U(e,t,n){switch(e){case`local-unavailable`:return{title:`Local OpenCode Unavailable`,description:`OpenCode CLI could not be started or is not installed. Install OpenCode or connect to a remote server instead.`,titleKey:`onboarding.desktopRecovery.localUnavailable.title`,descriptionKey:`onboarding.desktopRecovery.localUnavailable.description`,iconKey:`local`,showRetry:!0,retryLabel:`Retry Local`,retryLabelKey:`onboarding.desktopRecovery.localUnavailable.retry`,showUseLocal:!0,showUseRemote:!0,useLocalLabel:`Set Up Local`,useLocalLabelKey:`onboarding.desktopRecovery.localUnavailable.useLocal`,useRemoteLabel:`Use Remote`,useRemoteLabelKey:`onboarding.desktopRecovery.common.useRemote`};case`remote-missing`:return{title:`No Default Connection`,description:`Your saved default connection could not be found. Choose how you want to connect.`,titleKey:`onboarding.desktopRecovery.noDefaultConnection.title`,descriptionKey:`onboarding.desktopRecovery.noDefaultConnection.description`,iconKey:`local`,showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:`Use Local`,useLocalLabelKey:`onboarding.desktopRecovery.common.useLocal`,useRemoteLabel:`Use Remote`,useRemoteLabelKey:`onboarding.desktopRecovery.common.useRemote`};case`remote-unreachable`:{let e=H(t,n);return{title:`Remote Server Unreachable`,description:`Could not connect to "${e||`the remote server`}". Check your network connection and verify the server address.`,titleKey:`onboarding.desktopRecovery.remoteUnreachable.title`,descriptionKey:`onboarding.desktopRecovery.remoteUnreachable.description`,descriptionParams:e?{host:e}:void 0,iconKey:`remote`,showRetry:!0,retryLabel:`Retry Connection`,retryLabelKey:`onboarding.desktopRecovery.remoteUnreachable.retry`,showUseLocal:!0,showUseRemote:!0,useLocalLabel:`Use Local`,useLocalLabelKey:`onboarding.desktopRecovery.common.useLocal`,useRemoteLabel:`Use Remote`,useRemoteLabelKey:`onboarding.desktopRecovery.common.useRemote`}}case`remote-wrong-service`:{let e=H(t,n);return{title:`Incompatible Server`,description:`The server at "${e||`unknown`}" is not running Yuri. Verify the address points to an Yuri server.`,titleKey:`onboarding.desktopRecovery.incompatibleServer.title`,descriptionKey:`onboarding.desktopRecovery.incompatibleServer.description`,descriptionParams:e?{host:e}:void 0,iconKey:`remote`,showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:`Use Local`,useLocalLabelKey:`onboarding.desktopRecovery.common.useLocal`,useRemoteLabel:`Use Remote`,useRemoteLabelKey:`onboarding.desktopRecovery.common.useRemote`}}case`remote-incompatible`:{let e=H(t,n);return{title:`Server Update Required`,description:`The Yuri server at "${e||`unknown`}" is not compatible with this app version. Update Yuri on the server, then try again.`,titleKey:`onboarding.desktopRecovery.remoteIncompatible.title`,descriptionKey:`onboarding.desktopRecovery.remoteIncompatible.description`,descriptionParams:e?{host:e}:void 0,iconKey:`remote`,showRetry:!0,retryLabel:`Retry Connection`,retryLabelKey:`onboarding.desktopRecovery.remoteUnreachable.retry`,showUseLocal:!0,showUseRemote:!0,useLocalLabel:`Use Local`,useLocalLabelKey:`onboarding.desktopRecovery.common.useLocal`,useRemoteLabel:`Use Remote`,useRemoteLabelKey:`onboarding.desktopRecovery.common.useRemote`}}case`missing-default-host`:return{title:`No Default Connection`,description:`Your saved default connection could not be found. Choose how you want to connect.`,titleKey:`onboarding.desktopRecovery.noDefaultConnection.title`,descriptionKey:`onboarding.desktopRecovery.noDefaultConnection.description`,iconKey:`local`,showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:`Use Local`,useLocalLabelKey:`onboarding.desktopRecovery.common.useLocal`,useRemoteLabel:`Use Remote`,useRemoteLabelKey:`onboarding.desktopRecovery.common.useRemote`};default:throw Error(`Unknown recovery variant: ${e}`)}}function W(e){switch(e){case`local`:return(0,T.jsx)(y,{name:`macbook`,className:`h-8 w-8`});case`remote`:return(0,T.jsx)(y,{name:`server`,className:`h-8 w-8`})}}function G({variant:e,hostLabel:t,hostUrl:n,onRetry:r,onUseLocal:i,onUseRemote:a,isRetrying:o=!1}){let{t:s}=g(),l=U(e,t,n),u=l.retryLabelKey??`onboarding.desktopRecovery.actions.retryConnection`,d=w.useMemo(()=>{if(l.descriptionParams?.host)return l.descriptionParams;if(e===`remote-unreachable`)return{host:s(`onboarding.desktopRecovery.placeholders.remoteServer`)};if(e===`remote-wrong-service`||e===`remote-incompatible`)return{host:s(`onboarding.desktopRecovery.placeholders.unknownServer`)}},[l.descriptionParams,s,e]);return(0,T.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-8`,children:(0,T.jsxs)(`div`,{className:`w-full max-w-md space-y-6`,children:[(0,T.jsxs)(`div`,{className:`flex flex-col items-center space-y-3 text-center`,children:[(0,T.jsx)(`div`,{className:`p-3 rounded-full`,style:{backgroundColor:`var(--status-warning)`,opacity:.15},children:(0,T.jsx)(`div`,{style:{color:`var(--status-warning)`},children:W(l.iconKey)})}),(0,T.jsx)(`h1`,{className:`typography-ui-header text-xl font-semibold text-foreground`,children:s(l.titleKey)}),(0,T.jsx)(`p`,{className:`text-muted-foreground text-sm max-w-sm`,children:s(l.descriptionKey,d)})]}),n&&(e===`remote-unreachable`||e===`remote-wrong-service`||e===`remote-incompatible`)&&(0,T.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/50 p-3`,children:[(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:s(`onboarding.remoteConnection.field.serverAddress`)}),(0,T.jsx)(`div`,{className:`font-mono text-sm text-foreground truncate`,children:c(n)})]}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[l.showRetry&&r&&(0,T.jsxs)(v,{onClick:r,disabled:o,className:`w-full`,children:[(0,T.jsx)(y,{name:`refresh`,className:_(`h-4 w-4`,o&&`animate-spin`)}),s(o?`onboarding.desktopRecovery.actions.retrying`:u)]}),(0,T.jsxs)(`div`,{className:`flex gap-2`,children:[l.showUseLocal&&i&&(0,T.jsxs)(v,{variant:`outline`,onClick:i,disabled:o,className:`flex-1`,children:[(0,T.jsx)(y,{name:`macbook`,className:`h-4 w-4`}),s(l.useLocalLabelKey)]}),l.showUseRemote&&a&&(0,T.jsxs)(v,{variant:`outline`,onClick:a,disabled:o,className:`flex-1`,children:[(0,T.jsx)(y,{name:`server`,className:`h-4 w-4`}),s(l.useRemoteLabelKey)]})]})]})]})})}function K(e,t){if(t===`use-remote`)return{kind:`remote-form`};switch(e){case`local-unavailable`:return{kind:`local-setup`};case`remote-unreachable`:case`remote-incompatible`:case`remote-wrong-service`:case`remote-missing`:case`missing-default-host`:return{kind:`switch-default-to-local`};default:throw Error(`Unhandled RecoveryVariant: ${e}`)}}function q(e){let n=(0,C.c)(27),{variant:a,hostUrl:o,hostLabel:s,onRetry:c,onChooseRemote:l,showRemoteForm:u,onCloseRemoteForm:d,onSwitchToLocalFromRemote:f,onEnterLocalSetup:p,isRetrying:m}=e,h=u!==void 0&&u,g=m!==void 0&&m,_=J,v;n[0]===c?v=n[1]:(v=async()=>{if(r()){await i();return}await t(`/api/config/reload`,{method:`POST`}),c?.()},n[0]=c,n[1]=v);let y=v,b;n[2]!==p||n[3]!==a?(b=async()=>{if(K(a,`use-local`).kind===`local-setup`){p?.();return}if(await _(`local`),r()){await i();return}window.location.reload()},n[2]=p,n[3]=a,n[4]=b):b=n[4];let x=b,S;n[5]!==l||n[6]!==a?(S=()=>{K(a,`use-remote`).kind===`remote-form`&&l?.()},n[5]=l,n[6]=a,n[7]=S):S=n[7];let w=S;if(h){let e=a===`remote-wrong-service`?``:o||``,t=a===`remote-wrong-service`?``:s||``,c;n[8]!==l||n[9]!==d?(c=d||(()=>l?.()),n[8]=l,n[9]=d,n[10]=c):c=n[10];let u;n[11]!==p||n[12]!==f?(u=f||(()=>{_(`local`).then(()=>{r()?i():p?.()})}),n[11]=p,n[12]=f,n[13]=u):u=n[13];let m;return n[14]!==t||n[15]!==e||n[16]!==c||n[17]!==u?(m=(0,T.jsx)(O,{onBack:c,initialUrl:e,initialLabel:t,isRecoveryMode:!0,onSwitchToLocal:u}),n[14]=t,n[15]=e,n[16]=c,n[17]=u,n[18]=m):m=n[18],m}let E;return n[19]!==y||n[20]!==x||n[21]!==w||n[22]!==s||n[23]!==o||n[24]!==g||n[25]!==a?(E=(0,T.jsx)(G,{variant:a,hostLabel:s,hostUrl:o,onRetry:y,onUseLocal:x,onUseRemote:w,isRetrying:g}),n[19]=y,n[20]=x,n[21]=w,n[22]=s,n[23]=o,n[24]=g,n[25]=a,n[26]=E):E=n[26],E}async function J(e){if(!r())return;let t=await d();await l({...t,...e===`local`?{defaultHostId:`local`}:{},initialHostChoiceCompleted:!0})}function Y(e){let t=(0,C.c)(47),{status:n,statusError:r,onContinueInBackground:i}=e,{t:a,locale:o}=g(),s=n?.total??0,c=n?.completed??0,l=r||n?.phase===`partial`||n?.phase===`error`,u=s>0?Math.min(1,Math.max(0,c/s)):null,d;t[0]===a?d=t[1]:(d=a(`onboarding.index.title`),t[0]=a,t[1]=d);let f=Math.max(s,1),p=s>0?c:void 0,m;t[2]!==c||t[3]!==a||t[4]!==s?(m=a(`commandPalette.index.progress`,{completed:c,total:s}),t[2]=c,t[3]=a,t[4]=s,t[5]=m):m=t[5];let h=`absolute inset-0 size-full -rotate-90 ${u===null&&!l?`motion-safe:animate-spin motion-safe:[animation-duration:3s]`:``}`,_;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,T.jsx)(`circle`,{cx:`96`,cy:`96`,r:`84`,stroke:`currentColor`,strokeWidth:`1.5`,className:`text-border`}),t[6]=_):_=t[6];let y=100-(u??.22)*100,S;t[7]===y?S=t[8]:(S=(0,T.jsx)(`circle`,{cx:`96`,cy:`96`,r:`84`,pathLength:`100`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeDasharray:`100`,strokeDashoffset:y,className:`text-foreground/80 motion-safe:transition-[stroke-dashoffset] motion-safe:duration-700`}),t[7]=y,t[8]=S);let w;t[9]===u?w=t[10]:(w=u!==null&&u>0&&u<1&&(0,T.jsx)(`g`,{style:{transform:`rotate(${u*360}deg)`,transformOrigin:`96px 96px`},className:`motion-safe:transition-transform motion-safe:duration-700`,children:(0,T.jsx)(`circle`,{cx:`180`,cy:`96`,r:`3`,fill:`currentColor`,className:`text-foreground`})}),t[9]=u,t[10]=w);let E;t[11]!==h||t[12]!==S||t[13]!==w?(E=(0,T.jsxs)(`svg`,{viewBox:`0 0 192 192`,fill:`none`,"aria-hidden":`true`,className:h,children:[_,S,w]}),t[11]=h,t[12]=S,t[13]=w,t[14]=E):E=t[14];let D;t[15]!==o||t[16]!==u?(D=u!==null&&(0,T.jsx)(`span`,{"aria-hidden":`true`,className:`text-[2.5rem] font-light tabular-nums tracking-[-0.05em] text-foreground`,children:new Intl.NumberFormat(o,{style:`percent`,maximumFractionDigits:0}).format(u)}),t[15]=o,t[16]=u,t[17]=D):D=t[17];let O;t[18]!==d||t[19]!==E||t[20]!==D||t[21]!==f||t[22]!==p||t[23]!==m?(O=(0,T.jsxs)(`div`,{role:`progressbar`,"aria-label":d,"aria-valuemin":0,"aria-valuemax":f,"aria-valuenow":p,"aria-valuetext":m,className:`relative mb-9 flex size-40 items-center justify-center sm:size-44`,children:[E,D]}),t[18]=d,t[19]=E,t[20]=D,t[21]=f,t[22]=p,t[23]=m,t[24]=O):O=t[24];let k;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(k={fontSize:`1.0625rem`,fontWeight:450},t[25]=k):k=t[25];let A;t[26]===a?A=t[27]:(A=a(`onboarding.index.title`),t[26]=a,t[27]=A);let j;t[28]===A?j=t[29]:(j=(0,T.jsx)(b,{className:`tracking-tight`,style:k,children:A}),t[28]=A,t[29]=j);let M;t[30]!==l||t[31]!==a?(M=a(l?`onboarding.index.retrying`:`onboarding.index.description`),t[30]=l,t[31]=a,t[32]=M):M=t[32];let N;t[33]===M?N=t[34]:(N=(0,T.jsx)(x,{className:`text-xs text-muted-foreground`,children:M}),t[33]=M,t[34]=N);let P;t[35]!==j||t[36]!==N?(P=(0,T.jsxs)(`header`,{className:`space-y-2.5`,role:`status`,"aria-live":`polite`,children:[j,N]}),t[35]=j,t[36]=N,t[37]=P):P=t[37];let F;t[38]===a?F=t[39]:(F=a(`onboarding.index.background`),t[38]=a,t[39]=F);let I;t[40]!==i||t[41]!==F?(I=(0,T.jsx)(v,{variant:`ghost`,size:`sm`,className:`mt-8 text-xs font-normal text-muted-foreground`,onClick:i,children:F}),t[40]=i,t[41]=F,t[42]=I):I=t[42];let L;return t[43]!==O||t[44]!==P||t[45]!==I?(L=(0,T.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,"data-content-index-onboarding":!0,children:(0,T.jsxs)(`div`,{className:`flex w-full max-w-sm flex-col items-center text-center`,children:[O,P,I]})}),t[43]=O,t[44]=P,t[45]=I,t[46]=L):L=t[46],L}function X(e){let t=(0,C.c)(30),{onBack:n,onCliAvailable:r,mode:i,recoveryVariant:a,recoveryHostUrl:o,recoveryHostLabel:s,onEnterLocalSetup:c,indexStatus:l,indexStatusError:u,onContinueInBackground:d}=e,f=i===void 0?`first-launch`:i,p=a===void 0?`missing-default-host`:a,[m,h]=w.useState(!1),[g,_]=w.useState(!1),v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=()=>{_(!1),h(!1)},t[0]=v):v=t[0];let y;t[1]!==f||t[2]!==s||t[3]!==o||t[4]!==p?(y=[f,p,o,s],t[1]=f,t[2]=s,t[3]=o,t[4]=p,t[5]=y):y=t[5],w.useEffect(v,y);let b=g?`local-setup`:f;if(b===`content-index`){let e;return t[6]!==l||t[7]!==u||t[8]!==d?(e=(0,T.jsx)(Y,{status:l,statusError:u,onContinueInBackground:d}),t[6]=l,t[7]=u,t[8]=d,t[9]=e):e=t[9],e}if(b===`recovery`){let e,n;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>h(!1),n=()=>{h(!1),_(!0)},t[10]=e,t[11]=n):(e=t[10],n=t[11]);let r;t[12]===c?r=t[13]:(r=()=>{_(!0),c?.()},t[12]=c,t[13]=r);let i;return t[14]!==s||t[15]!==o||t[16]!==p||t[17]!==m||t[18]!==r?(i=(0,T.jsx)(q,{variant:p,hostUrl:o,hostLabel:s,showRemoteForm:m,onCloseRemoteForm:e,onSwitchToLocalFromRemote:n,onEnterLocalSetup:r}),t[14]=s,t[15]=o,t[16]=p,t[17]=m,t[18]=r,t[19]=i):i=t[19],i}if(b===`local-setup`){let e;t[20]!==n||t[21]!==g?(e=()=>{g?_(!1):n?.()},t[20]=n,t[21]=g,t[22]=e):e=t[22];let i;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>h(!0),t[23]=i):i=t[23];let a;return t[24]!==r||t[25]!==g||t[26]!==e?(a=(0,T.jsx)(V,{onBack:e,onCliAvailable:r,isFromRecovery:g,onSwitchToRemote:i}),t[24]=r,t[25]=g,t[26]=e,t[27]=a):a=t[27],a}let x;return t[28]===r?x=t[29]:(x=(0,T.jsx)(I,{onCliAvailable:r}),t[28]=r,t[29]=x),x}export{X as OnboardingScreen};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{u as t}from"./queryRuntime-DKGLQtb9.js";import{Cn as n,en as r,hn as i,i as a,pn as o}from"./persistence-Dzooc9Xg.js";import{_ as s,h as c,i as l,n as u,r as d}from"./desktopHosts-BDyl2P7W.js";import{it as f,rt as p}from"./vendor-base-ui-CdzJ6My_.js";import{n as m}from"./vendor-react-BP2cRVqX.js";import{d as h,f as g,r as _,t as v}from"./button-D_HdP1Oy.js";import{n as y}from"./Icon-BXTZRnIO.js";import{o as b,r as x}from"./dialog-B_87Teec.js";import{t as S}from"./input-DDfJnn8e.js";var C=m(),w=e(f(),1),T=p();function E(e){switch(e){case`ok`:return null;case`auth`:return`onboarding.remoteConnection.probe.authMessage`;case`update-recommended`:return`onboarding.remoteConnection.probe.updateRecommendedMessage`;case`incompatible`:return`onboarding.remoteConnection.probe.incompatibleMessage`;case`wrong-service`:return`onboarding.remoteConnection.probe.wrongServiceMessage`;case`unreachable`:return`onboarding.remoteConnection.probe.unreachableMessage`;default:return null}}function D(e){return e===`wrong-service`||e===`unreachable`||e===`incompatible`}function O({onBack:e,showBackButton:t=!0,initialUrl:n=``,initialLabel:a=``,isRecoveryMode:o=!1,onConnect:c,onSwitchToLocal:f}){let{t:p}=g(),[m,h]=(0,w.useState)(n),[_,y]=(0,w.useState)(a),[b,x]=(0,w.useState)(`idle`),[C,O]=(0,w.useState)(null),[k,A]=(0,w.useState)(``),j=s(m),M=j?.persistedUrl??null,N=(0,w.useCallback)(e=>{h(e.target.value),x(`idle`),O(null),A(``)},[]),P=(0,w.useCallback)(e=>{y(e.target.value)},[]),F=(0,w.useCallback)(async()=>{if(M){x(`testing`),O(null),A(``);try{let e=await u(M);O(e),x(e.status===`ok`||e.status===`update-recommended`?`success`:`error`)}catch(e){A(e instanceof Error?e.message:p(`onboarding.remoteConnection.errors.connectionTestFailed`)),x(`error`)}}},[M,p]),I=(0,w.useCallback)(async()=>{if(!j)return;let e=j.persistedUrl;x(`testing`),O(null),A(``);try{let t=await u(e);if(O(t),D(t.status)){x(`error`);return}let n=await d(),a=_.trim()||e,o=n.hosts.find(t=>t.url===e),s=o?o.id:`host-${Date.now().toString(16)}`,f={id:s,label:a,url:e,apiUrl:e},p=o?n.hosts.map(e=>e.id===s?f:e):[...n.hosts,f];if(await l({hosts:p,defaultHostId:s,initialHostChoiceCompleted:!0}),c?.(),j.redeemUrl){window.location.assign(j.redeemUrl);return}r()&&await i()}catch(e){A(e instanceof Error?e.message:p(`onboarding.remoteConnection.errors.failedToSaveConnection`)),x(`error`)}},[j,_,c,p]),L=b===`testing`,R=M!==null&&!L,z=M!==null&&!L&&!D(C?.status??null),B=E(C?.status??null),V=C?.status===`ok`,H=C?.status===`update-recommended`,U=C?.status===`auth`,W=D(C?.status??null);return(0,T.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-8`,children:(0,T.jsxs)(`div`,{className:`w-full max-w-md space-y-6`,children:[t&&(0,T.jsx)(`div`,{className:`flex items-center`,children:(0,T.jsx)(v,{variant:`ghost`,onClick:e,className:`p-0 text-muted-foreground hover:text-foreground`,children:p(`onboarding.common.actions.back`)})}),(0,T.jsxs)(`div`,{className:`space-y-2 text-center`,children:[(0,T.jsx)(`h1`,{className:`typography-ui-header text-xl font-semibold text-foreground`,children:p(o?`onboarding.remoteConnection.titleRecovery`:`onboarding.remoteConnection.title`)}),(0,T.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:p(`onboarding.remoteConnection.description`)})]}),(0,T.jsxs)(`div`,{className:`space-y-4`,children:[(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(`label`,{htmlFor:`remote-url`,className:`text-sm text-foreground`,children:p(`onboarding.remoteConnection.field.serverAddress`)}),(0,T.jsx)(S,{id:`remote-url`,type:`url`,value:m,onChange:N,placeholder:p(`onboarding.remoteConnection.field.serverAddressPlaceholder`),disabled:L})]}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(`label`,{htmlFor:`remote-label`,className:`text-sm text-foreground`,children:p(`onboarding.remoteConnection.field.nameOptional`)}),(0,T.jsx)(S,{id:`remote-label`,type:`text`,value:_,onChange:P,placeholder:p(`onboarding.remoteConnection.field.namePlaceholder`),disabled:L})]})]}),C&&V&&(0,T.jsx)(`div`,{className:`rounded-lg border p-3 text-sm`,style:{borderColor:`var(--status-success)`,color:`var(--status-success)`},children:p(`onboarding.remoteConnection.status.connectedSuccessfully`,{latencyMs:C.latencyMs})}),C&&U&&(0,T.jsx)(`div`,{className:`rounded-lg border p-3 text-sm`,style:{borderColor:`var(--status-warning)`,color:`var(--status-warning)`},children:p(`onboarding.remoteConnection.status.authWarning`)}),C&&H&&(0,T.jsx)(`div`,{className:`rounded-lg border p-3 text-sm`,style:{borderColor:`var(--status-warning)`,color:`var(--status-warning)`},children:B?p(B):null}),C&&W&&(0,T.jsxs)(`div`,{className:`rounded-lg border p-3 text-sm space-y-3`,style:{borderColor:`var(--status-error)`,color:`var(--status-error)`},children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`font-semibold mb-1`,children:p(`onboarding.remoteConnection.status.connectionFailed`)}),(0,T.jsx)(`div`,{className:`opacity-90`,children:B?p(B):null})]}),(0,T.jsx)(`div`,{className:`text-xs opacity-80`,children:C.status===`unreachable`?p(`onboarding.remoteConnection.status.suggestionsUnreachable`):p(`onboarding.remoteConnection.status.suggestionsWrongService`)})]}),k&&(0,T.jsx)(`div`,{className:`rounded-lg border p-3 text-sm`,style:{borderColor:`var(--status-error)`,color:`var(--status-error)`},children:k}),(0,T.jsxs)(`div`,{className:`flex gap-3`,children:[(0,T.jsx)(v,{variant:`outline`,onClick:F,disabled:!R,children:p(L?`onboarding.remoteConnection.actions.testing`:`onboarding.remoteConnection.actions.testConnection`)}),(0,T.jsx)(v,{onClick:I,disabled:!z,children:p(`onboarding.remoteConnection.actions.connectAndRestart`)})]}),W&&(0,T.jsxs)(`div`,{className:`flex flex-col gap-2 pt-2 border-t border-border`,children:[(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground text-center`,children:p(`onboarding.remoteConnection.actions.whatToDo`)}),(0,T.jsxs)(`div`,{className:`flex gap-2`,children:[(0,T.jsx)(v,{variant:`outline`,size:`sm`,onClick:e,className:`flex-1`,children:p(`onboarding.remoteConnection.actions.chooseDifferentServer`)}),!o&&f&&(0,T.jsx)(v,{variant:`outline`,size:`sm`,onClick:f,className:`flex-1`,children:p(`onboarding.remoteConnection.actions.useLocalInstead`)})]})]})]})})}async function k(){let e=await t(`/health`);if(!e.ok)return!1;let n=await e.json().catch(()=>null);return n?.openCodeRunning===!0||n?.isOpenCodeReady===!0}async function A(){return(await t(`/api/opencode/retry`,{method:`POST`})).ok?k():!1}var j=`curl -fsSL https://opencode.ai/v2/install | bash`,M=`https://opencode.ai/docs`,N=2500,P=1e4;function F(e){let t=(0,C.c)(5),{onCopy:n,copyTitle:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,T.jsxs)(`code`,{className:`flex-1 text-left overflow-x-auto whitespace-nowrap`,children:[(0,T.jsx)(`span`,{style:{color:`var(--syntax-keyword)`},children:`curl`}),(0,T.jsx)(`span`,{className:`text-muted-foreground`,children:` -fsSL `}),(0,T.jsx)(`span`,{style:{color:`var(--syntax-string)`},children:`https://opencode.ai/v2/install`}),(0,T.jsx)(`span`,{className:`text-muted-foreground`,children:` | `}),(0,T.jsx)(`span`,{style:{color:`var(--syntax-keyword)`},children:`bash`})]}),t[0]=i):i=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,T.jsx)(y,{name:`file-copy`,className:`h-4 w-4`}),t[1]=a):a=t[1];let o;return t[2]!==r||t[3]!==n?(o=(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3 w-full`,children:[i,(0,T.jsx)(`button`,{onClick:n,className:`inline-flex items-center text-muted-foreground hover:text-foreground transition-colors shrink-0`,title:r,"aria-label":r,children:a})]}),t[2]=r,t[3]=n,t[4]=o):o=t[4],o}function I({onCliAvailable:e}){let{t:s}=g(),[c,u]=w.useState(!1),[f,p]=w.useState(!1),[m,b]=w.useState(!1),[x,C]=w.useState(!1),[E,D]=w.useState(``),[I,L]=w.useState(`unknown`),[R,z]=w.useState(`local`),[B,V]=w.useState(!1),[H,U]=w.useState(!1),[W,G]=w.useState(null),K=w.useRef(!1);w.useEffect(()=>{p(r())},[]),w.useEffect(()=>{if(typeof navigator>`u`){L(`unknown`);return}let e=navigator.userAgent||``;/Windows/i.test(e)?L(`windows`):/Macintosh|Mac OS X/i.test(e)?L(`macos`):/Linux/i.test(e)?L(`linux`):L(`unknown`)},[]),w.useEffect(()=>{let e=!1;return(async()=>{try{let n=await t(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(!n.ok)return;let r=await n.json().catch(()=>null);if(!r||e)return;let i=typeof r.opencodeBinary==`string`?r.opencodeBinary.trim():``;i&&D(i)}catch{}})(),()=>{e=!0}},[]);let q=w.useCallback(async e=>{let t=e.target;t.closest(`.app-region-no-drag`)||t.closest(`button, a, input, select, textarea, code, summary, details`)||e.button===0&&f&&await n()},[f]),J=w.useCallback(async e=>{if(!f)return;let t=await d();await l({...t,...e===`local`?{defaultHostId:`local`}:{},initialHostChoiceCompleted:!0})},[f]),Y=w.useCallback(async()=>{if(!K.current){K.current=!0;try{f&&await J(`local`),await e?.()}catch(e){throw K.current=!1,e}}},[f,e,J]);w.useEffect(()=>{if(R!==`local`)return;let e=!1,t=null,n=0,r=async()=>{if(!e){try{let t=await k(),r=Date.now();if(!t&&r-n>=P&&(n=r,t=await A()),e)return;if(t){await Y();return}}catch{}e||(t=setTimeout(r,N))}};return t=setTimeout(r,N),()=>{e=!0,t&&clearTimeout(t)}},[R,Y]);let X=w.useCallback(async()=>{C(!0),G(null);try{let e=await k();e||=await A(),e?await Y():G(s(`onboarding.localSetup.errors.cliNotReady`))}catch{G(s(`onboarding.localSetup.errors.detectionFailed`))}finally{C(!1)}},[Y,s]),Z=w.useCallback(async()=>{if(!(typeof window>`u`)&&f)try{let e=await o();e.success&&e.path&&e.path.trim().length>0&&D(e.path.trim())}catch{}},[f]),Q=w.useCallback(async()=>{b(!0);try{if(await a({opencodeBinary:E.trim()}),f){await J(`local`),await i();return}await t(`/api/config/reload`,{method:`POST`})}finally{setTimeout(()=>b(!1),1e3)}},[f,E,J]),$=w.useCallback(async()=>{let e=await h(j);e.ok?(u(!0),setTimeout(()=>u(!1),2e3)):console.error(`Failed to copy:`,e.error)},[]),ee=M,te=I===`windows`?`C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd`:I===`linux`?`/home/you/.bun/bin/opencode`:`/Users/you/.bun/bin/opencode`,ne=!f||R===`local`;return(0,T.jsx)(`div`,{className:`app-region-drag h-full flex items-center justify-center bg-transparent p-8 cursor-default select-none overflow-y-auto`,onMouseDown:q,children:(0,T.jsxs)(`div`,{className:`w-full max-w-md space-y-7`,children:[(0,T.jsxs)(`header`,{className:`text-center space-y-1.5`,children:[(0,T.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-foreground`,children:s(`onboarding.chooser.title`)}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s(`onboarding.chooser.description`)})]}),f&&(0,T.jsxs)(`div`,{className:`app-region-no-drag flex gap-1.5`,children:[(0,T.jsx)(`button`,{type:`button`,className:_(`flex-1 px-4 py-2 rounded-lg border transition-colors text-sm`,R===`local`?`border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10`:`border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground`),onClick:()=>z(`local`),children:s(`onboarding.chooser.tabs.localInstall`)}),(0,T.jsx)(`button`,{type:`button`,className:_(`flex-1 px-4 py-2 rounded-lg border transition-colors text-sm`,R===`remote`?`border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10`:`border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground`),onClick:()=>z(`remote`),children:s(`onboarding.chooser.tabs.connectRemote`)})]}),f&&R===`remote`?(0,T.jsx)(`div`,{className:`app-region-no-drag`,children:(0,T.jsx)(O,{onBack:()=>z(`local`),showBackButton:!1,onSwitchToLocal:()=>z(`local`)})}):null,ne&&(0,T.jsxs)(`div`,{className:`space-y-4`,children:[I===`windows`&&(0,T.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/50 p-4`,children:[(0,T.jsx)(`div`,{className:`text-sm text-foreground`,children:s(`onboarding.localSetup.windows.title`)}),(0,T.jsxs)(`ol`,{className:`mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground`,children:[(0,T.jsx)(`li`,{children:s(`onboarding.localSetup.windows.stepRunInstallInWsl`)}),(0,T.jsx)(`li`,{children:s(`onboarding.localSetup.windows.stepSetBinaryPath`)})]})]}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground text-center leading-relaxed`,children:s(`onboarding.localSetup.intro`)}),(0,T.jsx)(`div`,{className:`app-region-no-drag rounded-lg border border-border bg-background/60 backdrop-blur-sm px-4 py-3 font-mono text-sm`,children:c?(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,style:{color:`var(--status-success)`},children:[(0,T.jsx)(y,{name:`check`,className:`h-4 w-4`}),s(`onboarding.common.status.copiedToClipboard`)]}):(0,T.jsx)(F,{onCopy:$,copyTitle:s(`onboarding.common.copyToClipboard`)})}),(0,T.jsxs)(`div`,{className:`app-region-no-drag flex items-center justify-between`,children:[(0,T.jsxs)(`a`,{href:ee,target:`_blank`,rel:`noopener noreferrer`,className:`text-xs text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1`,children:[s(I===`windows`?`onboarding.localSetup.docs.windows`:`onboarding.localSetup.docs.default`),(0,T.jsx)(y,{name:`external-link`,className:`h-3 w-3`})]}),(0,T.jsx)(`button`,{type:`button`,onClick:X,disabled:x,className:`text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,children:s(x?`onboarding.localSetup.actions.checking`:`onboarding.localSetup.actions.checkNow`)})]}),W&&(0,T.jsx)(`p`,{role:`alert`,className:`text-center text-xs text-[var(--status-error-foreground)]`,children:W}),(0,T.jsxs)(`div`,{className:`rounded-lg border px-4 py-3 flex items-center gap-3`,style:{borderColor:`color-mix(in srgb, var(--primary-base) 20%, transparent)`,backgroundColor:`color-mix(in srgb, var(--primary-base) 6%, transparent)`},role:`status`,"aria-live":`polite`,children:[(0,T.jsxs)(`span`,{className:`relative inline-flex h-2.5 w-2.5 shrink-0`,"aria-hidden":!0,children:[(0,T.jsx)(`span`,{className:`absolute inset-0 rounded-full`,style:{backgroundColor:`var(--primary-base)`,animation:`pulse-opacity 1.6s ease-in-out infinite`}}),(0,T.jsx)(`span`,{className:`absolute inset-[-4px] rounded-full`,style:{backgroundColor:`var(--primary-base)`,animation:`pulse-opacity-dim 1.6s ease-in-out infinite`,opacity:0}})]}),(0,T.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,T.jsx)(`div`,{className:`text-sm text-foreground leading-tight`,children:s(`onboarding.localSetup.status.watching`)}),(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground leading-tight mt-0.5`,children:s(`onboarding.localSetup.status.autoContinue`)})]})]}),(0,T.jsxs)(`details`,{className:`app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors`,open:B,onToggle:e=>V(e.currentTarget.open),children:[(0,T.jsxs)(`summary`,{className:`flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden`,children:[(0,T.jsx)(`span`,{children:s(`onboarding.localSetup.advanced.title`)}),(0,T.jsx)(y,{name:`arrow-down-s`,className:`h-4 w-4 transition-transform group-open:rotate-180`})]}),(0,T.jsxs)(`div`,{className:`pb-4 space-y-2`,children:[(0,T.jsxs)(`div`,{className:`flex gap-2`,children:[(0,T.jsx)(S,{value:E,onChange:e=>D(e.target.value),placeholder:te,disabled:m,className:`flex-1 font-mono text-xs`}),(0,T.jsx)(v,{type:`button`,variant:`secondary`,size:`sm`,onClick:Z,disabled:m||!f,children:s(`onboarding.localSetup.actions.browse`)}),(0,T.jsx)(v,{type:`button`,size:`sm`,onClick:Q,disabled:m||!E.trim(),children:s(`onboarding.localSetup.actions.apply`)})]}),(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground/70`,children:s(`onboarding.localSetup.helper.saveAndReload`)})]})]}),(0,T.jsxs)(`details`,{className:`app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors`,open:H,onToggle:e=>U(e.currentTarget.open),children:[(0,T.jsxs)(`summary`,{className:`flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden`,children:[(0,T.jsx)(`span`,{children:s(`onboarding.localSetup.troubleshoot.title`)}),(0,T.jsx)(y,{name:`arrow-down-s`,className:`h-4 w-4 transition-transform group-open:rotate-180`})]}),(0,T.jsx)(`ul`,{className:`pb-4 space-y-1.5 text-xs text-muted-foreground list-disc pl-4`,children:I===`windows`?(0,T.jsx)(T.Fragment,{children:(0,T.jsx)(`li`,{children:s(`onboarding.localSetup.windows.hintDetectionFailed`)})}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`li`,{children:s(`onboarding.localSetup.hint.ensurePath`)}),(0,T.jsx)(`li`,{children:s(`onboarding.localSetup.hint.setEnv`)}),(0,T.jsx)(`li`,{children:s(`onboarding.localSetup.hint.missingRuntime`)})]})})]})]})]})})}var L=`curl -fsSL https://opencode.ai/v2/install | bash`,R=`https://opencode.ai/docs`;function z(e){let t=(0,C.c)(5),{onCopy:n,copyTitle:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,T.jsxs)(`code`,{children:[(0,T.jsx)(`span`,{style:{color:`var(--syntax-keyword)`},children:`curl`}),(0,T.jsx)(`span`,{className:`text-muted-foreground`,children:` -fsSL `}),(0,T.jsx)(`span`,{style:{color:`var(--syntax-string)`},children:`https://opencode.ai/v2/install`}),(0,T.jsx)(`span`,{className:`text-muted-foreground`,children:` | `}),(0,T.jsx)(`span`,{style:{color:`var(--syntax-keyword)`},children:`bash`})]}),t[0]=i):i=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,T.jsx)(y,{name:`file-copy`,className:`h-4 w-4`}),t[1]=a):a=t[1];let o;return t[2]!==r||t[3]!==n?(o=(0,T.jsxs)(`div`,{className:`flex items-center justify-center gap-3`,children:[i,(0,T.jsx)(`button`,{onClick:n,className:`inline-flex items-center text-muted-foreground hover:text-foreground transition-colors`,title:r,children:a})]}),t[2]=r,t[3]=n,t[4]=o):o=t[4],o}var B=3e4;function V({onBack:e,onCliAvailable:s,isFromRecovery:c=!1,onSwitchToRemote:l}){let{t:u}=g(),[d,f]=w.useState(!1),[p,m]=w.useState(!1),[_,b]=w.useState(!1),[x,C]=w.useState(!1),[E,D]=w.useState(!1),[O,j]=w.useState(null),[M,N]=w.useState(``),[P,F]=w.useState(`unknown`);w.useEffect(()=>{let e=setTimeout(()=>m(!0),B);return()=>clearTimeout(e)},[]),w.useEffect(()=>{b(r())},[]),w.useEffect(()=>{if(typeof navigator>`u`){F(`unknown`);return}let e=navigator.userAgent||``;if(/Windows/i.test(e)){F(`windows`);return}if(/Macintosh|Mac OS X/i.test(e)){F(`macos`);return}if(/Linux/i.test(e)){F(`linux`);return}F(`unknown`)},[]),w.useEffect(()=>{let e=!1;return(async()=>{try{let n=await t(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(!n.ok)return;let r=await n.json().catch(()=>null);if(!r||e)return;let i=typeof r.opencodeBinary==`string`?r.opencodeBinary.trim():``;i&&N(i)}catch{}})(),()=>{e=!0}},[]);let I=w.useCallback(async e=>{e.target.closest(`button, a, input, select, textarea, code`)||e.button===0&&_&&await n()},[_]),V=w.useCallback(async()=>{if(!(typeof window>`u`)&&_)try{let e=await o();e.success&&e.path&&e.path.trim().length>0&&N(e.path.trim())}catch{}},[_]),H=w.useCallback(async()=>{C(!0);try{if(await a({opencodeBinary:M.trim()}),_){await i();return}await t(`/api/config/reload`,{method:`POST`})}finally{setTimeout(()=>C(!1),1e3)}},[_,M]),U=w.useCallback(async()=>{let e=await h(L);e.ok?(f(!0),setTimeout(()=>f(!1),2e3)):console.error(`Failed to copy:`,e.error)},[]),W=w.useCallback(async()=>{D(!0),j(null);try{let e=await k();e||=await A(),e?s?.():j(u(`onboarding.localSetup.errors.cliNotReady`))}catch(e){j(e instanceof Error?e.message:u(`onboarding.localSetup.errors.detectionFailed`))}finally{D(!1)}},[s,u]),G=R,K=P===`windows`?`C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd`:P===`linux`?`/home/you/.bun/bin/opencode`:`/Users/you/.bun/bin/opencode`;return(0,T.jsxs)(`div`,{className:`h-full flex items-center justify-center bg-transparent p-8 relative cursor-default select-none`,onMouseDown:I,children:[(0,T.jsxs)(`div`,{className:`w-full max-w-lg space-y-4 text-center`,children:[(0,T.jsx)(`div`,{className:`flex items-center`,children:(0,T.jsx)(v,{variant:`ghost`,onClick:e,className:`p-0 text-muted-foreground hover:text-foreground`,children:u(`onboarding.common.actions.back`)})}),(0,T.jsxs)(`div`,{className:`space-y-4`,children:[(0,T.jsx)(`h1`,{className:`text-3xl font-semibold tracking-tight text-foreground`,children:u(`onboarding.localSetup.title`)}),(0,T.jsx)(`p`,{className:`text-muted-foreground`,children:u(`onboarding.localSetup.description`)})]}),P===`windows`&&(0,T.jsxs)(`div`,{className:`mx-auto max-w-2xl rounded-lg border border-border bg-background/50 p-4 text-left`,children:[(0,T.jsx)(`div`,{className:`text-sm text-foreground`,children:u(`onboarding.localSetup.windows.title`)}),(0,T.jsxs)(`ol`,{className:`mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground`,children:[(0,T.jsx)(`li`,{children:u(`onboarding.localSetup.windows.stepRunInstallInWsl`)}),(0,T.jsx)(`li`,{children:u(`onboarding.localSetup.windows.stepSetBinaryPath`)})]})]}),(0,T.jsx)(`div`,{className:`flex justify-center`,children:(0,T.jsx)(`div`,{className:`bg-background/60 backdrop-blur-sm border border-border rounded-lg px-5 py-3 font-mono text-sm w-fit`,children:d?(0,T.jsxs)(`div`,{className:`flex items-center justify-center gap-2`,style:{color:`var(--status-success)`},children:[(0,T.jsx)(y,{name:`check`,className:`h-4 w-4`}),u(`onboarding.common.status.copiedToClipboard`)]}):(0,T.jsx)(z,{onCopy:U,copyTitle:u(`onboarding.common.copyToClipboard`)})})}),(0,T.jsxs)(`a`,{href:G,target:`_blank`,rel:`noopener noreferrer`,className:`text-sm text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1 justify-center`,children:[u(P===`windows`?`onboarding.localSetup.docs.windows`:`onboarding.localSetup.docs.default`),(0,T.jsx)(y,{name:`external-link`,className:`h-3 w-3`})]}),O&&(0,T.jsx)(`div`,{className:`mx-auto max-w-md rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive`,children:O}),(0,T.jsxs)(`div`,{className:`space-y-3`,children:[(0,T.jsx)(v,{type:`button`,onClick:W,disabled:E,className:`w-full max-w-xs`,size:`lg`,children:u(E?`onboarding.localSetup.actions.checking`:`onboarding.localSetup.actions.checkAndContinue`)}),(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`onboarding.localSetup.helper.checkAndContinue`)})]}),(0,T.jsx)(`div`,{className:`mx-auto w-full max-w-xl pt-4`,children:(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:u(`onboarding.localSetup.field.alreadyInstalled`)}),(0,T.jsxs)(`div`,{className:`flex gap-2`,children:[(0,T.jsx)(S,{value:M,onChange:e=>N(e.target.value),placeholder:K,disabled:x,className:`flex-1 font-mono text-xs`}),(0,T.jsx)(v,{type:`button`,variant:`secondary`,onClick:V,disabled:x||!_,children:u(`onboarding.localSetup.actions.browse`)}),(0,T.jsx)(v,{type:`button`,onClick:H,disabled:x,children:u(`onboarding.localSetup.actions.apply`)})]}),(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground/70`,children:u(`onboarding.localSetup.helper.saveAndReload`)})]})}),c&&l&&(0,T.jsxs)(`div`,{className:`text-center pt-4`,children:[(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground mb-2`,children:u(`onboarding.localSetup.remotePreference`)}),(0,T.jsx)(v,{variant:`link`,onClick:l,children:u(`onboarding.localSetup.actions.connectRemoteServer`)})]})]}),p&&(0,T.jsx)(`div`,{className:`absolute bottom-8 left-0 right-0 text-center space-y-1`,children:P===`windows`?(0,T.jsx)(T.Fragment,{children:(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground/70`,children:u(`onboarding.localSetup.windows.hintDetectionFailed`)})}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground/70`,children:u(`onboarding.localSetup.hint.ensurePath`)}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground/70`,children:u(`onboarding.localSetup.hint.setEnv`)}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground/70`,children:u(`onboarding.localSetup.hint.missingRuntime`)})]})})]})}function H(e,t){if(e?.trim())return c(e.trim());if(t)return c(t)}function U(e,t,n){switch(e){case`local-unavailable`:return{title:`Local OpenCode Unavailable`,description:`OpenCode CLI could not be started or is not installed. Install OpenCode or connect to a remote server instead.`,titleKey:`onboarding.desktopRecovery.localUnavailable.title`,descriptionKey:`onboarding.desktopRecovery.localUnavailable.description`,iconKey:`local`,showRetry:!0,retryLabel:`Retry Local`,retryLabelKey:`onboarding.desktopRecovery.localUnavailable.retry`,showUseLocal:!0,showUseRemote:!0,useLocalLabel:`Set Up Local`,useLocalLabelKey:`onboarding.desktopRecovery.localUnavailable.useLocal`,useRemoteLabel:`Use Remote`,useRemoteLabelKey:`onboarding.desktopRecovery.common.useRemote`};case`remote-missing`:return{title:`No Default Connection`,description:`Your saved default connection could not be found. Choose how you want to connect.`,titleKey:`onboarding.desktopRecovery.noDefaultConnection.title`,descriptionKey:`onboarding.desktopRecovery.noDefaultConnection.description`,iconKey:`local`,showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:`Use Local`,useLocalLabelKey:`onboarding.desktopRecovery.common.useLocal`,useRemoteLabel:`Use Remote`,useRemoteLabelKey:`onboarding.desktopRecovery.common.useRemote`};case`remote-unreachable`:{let e=H(t,n);return{title:`Remote Server Unreachable`,description:`Could not connect to "${e||`the remote server`}". Check your network connection and verify the server address.`,titleKey:`onboarding.desktopRecovery.remoteUnreachable.title`,descriptionKey:`onboarding.desktopRecovery.remoteUnreachable.description`,descriptionParams:e?{host:e}:void 0,iconKey:`remote`,showRetry:!0,retryLabel:`Retry Connection`,retryLabelKey:`onboarding.desktopRecovery.remoteUnreachable.retry`,showUseLocal:!0,showUseRemote:!0,useLocalLabel:`Use Local`,useLocalLabelKey:`onboarding.desktopRecovery.common.useLocal`,useRemoteLabel:`Use Remote`,useRemoteLabelKey:`onboarding.desktopRecovery.common.useRemote`}}case`remote-wrong-service`:{let e=H(t,n);return{title:`Incompatible Server`,description:`The server at "${e||`unknown`}" is not running Yuri. Verify the address points to an Yuri server.`,titleKey:`onboarding.desktopRecovery.incompatibleServer.title`,descriptionKey:`onboarding.desktopRecovery.incompatibleServer.description`,descriptionParams:e?{host:e}:void 0,iconKey:`remote`,showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:`Use Local`,useLocalLabelKey:`onboarding.desktopRecovery.common.useLocal`,useRemoteLabel:`Use Remote`,useRemoteLabelKey:`onboarding.desktopRecovery.common.useRemote`}}case`remote-incompatible`:{let e=H(t,n);return{title:`Server Update Required`,description:`The Yuri server at "${e||`unknown`}" is not compatible with this app version. Update Yuri on the server, then try again.`,titleKey:`onboarding.desktopRecovery.remoteIncompatible.title`,descriptionKey:`onboarding.desktopRecovery.remoteIncompatible.description`,descriptionParams:e?{host:e}:void 0,iconKey:`remote`,showRetry:!0,retryLabel:`Retry Connection`,retryLabelKey:`onboarding.desktopRecovery.remoteUnreachable.retry`,showUseLocal:!0,showUseRemote:!0,useLocalLabel:`Use Local`,useLocalLabelKey:`onboarding.desktopRecovery.common.useLocal`,useRemoteLabel:`Use Remote`,useRemoteLabelKey:`onboarding.desktopRecovery.common.useRemote`}}case`missing-default-host`:return{title:`No Default Connection`,description:`Your saved default connection could not be found. Choose how you want to connect.`,titleKey:`onboarding.desktopRecovery.noDefaultConnection.title`,descriptionKey:`onboarding.desktopRecovery.noDefaultConnection.description`,iconKey:`local`,showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:`Use Local`,useLocalLabelKey:`onboarding.desktopRecovery.common.useLocal`,useRemoteLabel:`Use Remote`,useRemoteLabelKey:`onboarding.desktopRecovery.common.useRemote`};default:throw Error(`Unknown recovery variant: ${e}`)}}function W(e){switch(e){case`local`:return(0,T.jsx)(y,{name:`macbook`,className:`h-8 w-8`});case`remote`:return(0,T.jsx)(y,{name:`server`,className:`h-8 w-8`})}}function G({variant:e,hostLabel:t,hostUrl:n,onRetry:r,onUseLocal:i,onUseRemote:a,isRetrying:o=!1}){let{t:s}=g(),l=U(e,t,n),u=l.retryLabelKey??`onboarding.desktopRecovery.actions.retryConnection`,d=w.useMemo(()=>{if(l.descriptionParams?.host)return l.descriptionParams;if(e===`remote-unreachable`)return{host:s(`onboarding.desktopRecovery.placeholders.remoteServer`)};if(e===`remote-wrong-service`||e===`remote-incompatible`)return{host:s(`onboarding.desktopRecovery.placeholders.unknownServer`)}},[l.descriptionParams,s,e]);return(0,T.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-8`,children:(0,T.jsxs)(`div`,{className:`w-full max-w-md space-y-6`,children:[(0,T.jsxs)(`div`,{className:`flex flex-col items-center space-y-3 text-center`,children:[(0,T.jsx)(`div`,{className:`p-3 rounded-full`,style:{backgroundColor:`var(--status-warning)`,opacity:.15},children:(0,T.jsx)(`div`,{style:{color:`var(--status-warning)`},children:W(l.iconKey)})}),(0,T.jsx)(`h1`,{className:`typography-ui-header text-xl font-semibold text-foreground`,children:s(l.titleKey)}),(0,T.jsx)(`p`,{className:`text-muted-foreground text-sm max-w-sm`,children:s(l.descriptionKey,d)})]}),n&&(e===`remote-unreachable`||e===`remote-wrong-service`||e===`remote-incompatible`)&&(0,T.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/50 p-3`,children:[(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:s(`onboarding.remoteConnection.field.serverAddress`)}),(0,T.jsx)(`div`,{className:`font-mono text-sm text-foreground truncate`,children:c(n)})]}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[l.showRetry&&r&&(0,T.jsxs)(v,{onClick:r,disabled:o,className:`w-full`,children:[(0,T.jsx)(y,{name:`refresh`,className:_(`h-4 w-4`,o&&`animate-spin`)}),s(o?`onboarding.desktopRecovery.actions.retrying`:u)]}),(0,T.jsxs)(`div`,{className:`flex gap-2`,children:[l.showUseLocal&&i&&(0,T.jsxs)(v,{variant:`outline`,onClick:i,disabled:o,className:`flex-1`,children:[(0,T.jsx)(y,{name:`macbook`,className:`h-4 w-4`}),s(l.useLocalLabelKey)]}),l.showUseRemote&&a&&(0,T.jsxs)(v,{variant:`outline`,onClick:a,disabled:o,className:`flex-1`,children:[(0,T.jsx)(y,{name:`server`,className:`h-4 w-4`}),s(l.useRemoteLabelKey)]})]})]})]})})}function K(e,t){if(t===`use-remote`)return{kind:`remote-form`};switch(e){case`local-unavailable`:return{kind:`local-setup`};case`remote-unreachable`:case`remote-incompatible`:case`remote-wrong-service`:case`remote-missing`:case`missing-default-host`:return{kind:`switch-default-to-local`};default:throw Error(`Unhandled RecoveryVariant: ${e}`)}}function q(e){let n=(0,C.c)(27),{variant:a,hostUrl:o,hostLabel:s,onRetry:c,onChooseRemote:l,showRemoteForm:u,onCloseRemoteForm:d,onSwitchToLocalFromRemote:f,onEnterLocalSetup:p,isRetrying:m}=e,h=u!==void 0&&u,g=m!==void 0&&m,_=J,v;n[0]===c?v=n[1]:(v=async()=>{if(r()){await i();return}await t(`/api/config/reload`,{method:`POST`}),c?.()},n[0]=c,n[1]=v);let y=v,b;n[2]!==p||n[3]!==a?(b=async()=>{if(K(a,`use-local`).kind===`local-setup`){p?.();return}if(await _(`local`),r()){await i();return}window.location.reload()},n[2]=p,n[3]=a,n[4]=b):b=n[4];let x=b,S;n[5]!==l||n[6]!==a?(S=()=>{K(a,`use-remote`).kind===`remote-form`&&l?.()},n[5]=l,n[6]=a,n[7]=S):S=n[7];let w=S;if(h){let e=a===`remote-wrong-service`?``:o||``,t=a===`remote-wrong-service`?``:s||``,c;n[8]!==l||n[9]!==d?(c=d||(()=>l?.()),n[8]=l,n[9]=d,n[10]=c):c=n[10];let u;n[11]!==p||n[12]!==f?(u=f||(()=>{_(`local`).then(()=>{r()?i():p?.()})}),n[11]=p,n[12]=f,n[13]=u):u=n[13];let m;return n[14]!==t||n[15]!==e||n[16]!==c||n[17]!==u?(m=(0,T.jsx)(O,{onBack:c,initialUrl:e,initialLabel:t,isRecoveryMode:!0,onSwitchToLocal:u}),n[14]=t,n[15]=e,n[16]=c,n[17]=u,n[18]=m):m=n[18],m}let E;return n[19]!==y||n[20]!==x||n[21]!==w||n[22]!==s||n[23]!==o||n[24]!==g||n[25]!==a?(E=(0,T.jsx)(G,{variant:a,hostLabel:s,hostUrl:o,onRetry:y,onUseLocal:x,onUseRemote:w,isRetrying:g}),n[19]=y,n[20]=x,n[21]=w,n[22]=s,n[23]=o,n[24]=g,n[25]=a,n[26]=E):E=n[26],E}async function J(e){if(!r())return;let t=await d();await l({...t,...e===`local`?{defaultHostId:`local`}:{},initialHostChoiceCompleted:!0})}function Y(e){let t=(0,C.c)(47),{status:n,statusError:r,onContinueInBackground:i}=e,{t:a,locale:o}=g(),s=n?.total??0,c=n?.completed??0,l=r||n?.phase===`partial`||n?.phase===`error`,u=s>0?Math.min(1,Math.max(0,c/s)):null,d;t[0]===a?d=t[1]:(d=a(`onboarding.index.title`),t[0]=a,t[1]=d);let f=Math.max(s,1),p=s>0?c:void 0,m;t[2]!==c||t[3]!==a||t[4]!==s?(m=a(`commandPalette.index.progress`,{completed:c,total:s}),t[2]=c,t[3]=a,t[4]=s,t[5]=m):m=t[5];let h=`absolute inset-0 size-full -rotate-90 ${u===null&&!l?`motion-safe:animate-spin motion-safe:[animation-duration:3s]`:``}`,_;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,T.jsx)(`circle`,{cx:`96`,cy:`96`,r:`84`,stroke:`currentColor`,strokeWidth:`1.5`,className:`text-border`}),t[6]=_):_=t[6];let y=100-(u??.22)*100,S;t[7]===y?S=t[8]:(S=(0,T.jsx)(`circle`,{cx:`96`,cy:`96`,r:`84`,pathLength:`100`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeDasharray:`100`,strokeDashoffset:y,className:`text-foreground/80 motion-safe:transition-[stroke-dashoffset] motion-safe:duration-700`}),t[7]=y,t[8]=S);let w;t[9]===u?w=t[10]:(w=u!==null&&u>0&&u<1&&(0,T.jsx)(`g`,{style:{transform:`rotate(${u*360}deg)`,transformOrigin:`96px 96px`},className:`motion-safe:transition-transform motion-safe:duration-700`,children:(0,T.jsx)(`circle`,{cx:`180`,cy:`96`,r:`3`,fill:`currentColor`,className:`text-foreground`})}),t[9]=u,t[10]=w);let E;t[11]!==h||t[12]!==S||t[13]!==w?(E=(0,T.jsxs)(`svg`,{viewBox:`0 0 192 192`,fill:`none`,"aria-hidden":`true`,className:h,children:[_,S,w]}),t[11]=h,t[12]=S,t[13]=w,t[14]=E):E=t[14];let D;t[15]!==o||t[16]!==u?(D=u!==null&&(0,T.jsx)(`span`,{"aria-hidden":`true`,className:`text-[2.5rem] font-light tabular-nums tracking-[-0.05em] text-foreground`,children:new Intl.NumberFormat(o,{style:`percent`,maximumFractionDigits:0}).format(u)}),t[15]=o,t[16]=u,t[17]=D):D=t[17];let O;t[18]!==d||t[19]!==E||t[20]!==D||t[21]!==f||t[22]!==p||t[23]!==m?(O=(0,T.jsxs)(`div`,{role:`progressbar`,"aria-label":d,"aria-valuemin":0,"aria-valuemax":f,"aria-valuenow":p,"aria-valuetext":m,className:`relative mb-9 flex size-40 items-center justify-center sm:size-44`,children:[E,D]}),t[18]=d,t[19]=E,t[20]=D,t[21]=f,t[22]=p,t[23]=m,t[24]=O):O=t[24];let k;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(k={fontSize:`1.0625rem`,fontWeight:450},t[25]=k):k=t[25];let A;t[26]===a?A=t[27]:(A=a(`onboarding.index.title`),t[26]=a,t[27]=A);let j;t[28]===A?j=t[29]:(j=(0,T.jsx)(b,{className:`tracking-tight`,style:k,children:A}),t[28]=A,t[29]=j);let M;t[30]!==l||t[31]!==a?(M=a(l?`onboarding.index.retrying`:`onboarding.index.description`),t[30]=l,t[31]=a,t[32]=M):M=t[32];let N;t[33]===M?N=t[34]:(N=(0,T.jsx)(x,{className:`text-xs text-muted-foreground`,children:M}),t[33]=M,t[34]=N);let P;t[35]!==j||t[36]!==N?(P=(0,T.jsxs)(`header`,{className:`space-y-2.5`,role:`status`,"aria-live":`polite`,children:[j,N]}),t[35]=j,t[36]=N,t[37]=P):P=t[37];let F;t[38]===a?F=t[39]:(F=a(`onboarding.index.background`),t[38]=a,t[39]=F);let I;t[40]!==i||t[41]!==F?(I=(0,T.jsx)(v,{variant:`ghost`,size:`sm`,className:`mt-8 text-xs font-normal text-muted-foreground`,onClick:i,children:F}),t[40]=i,t[41]=F,t[42]=I):I=t[42];let L;return t[43]!==O||t[44]!==P||t[45]!==I?(L=(0,T.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,"data-content-index-onboarding":!0,children:(0,T.jsxs)(`div`,{className:`flex w-full max-w-sm flex-col items-center text-center`,children:[O,P,I]})}),t[43]=O,t[44]=P,t[45]=I,t[46]=L):L=t[46],L}function X(e){let t=(0,C.c)(30),{onBack:n,onCliAvailable:r,mode:i,recoveryVariant:a,recoveryHostUrl:o,recoveryHostLabel:s,onEnterLocalSetup:c,indexStatus:l,indexStatusError:u,onContinueInBackground:d}=e,f=i===void 0?`first-launch`:i,p=a===void 0?`missing-default-host`:a,[m,h]=w.useState(!1),[g,_]=w.useState(!1),v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=()=>{_(!1),h(!1)},t[0]=v):v=t[0];let y;t[1]!==f||t[2]!==s||t[3]!==o||t[4]!==p?(y=[f,p,o,s],t[1]=f,t[2]=s,t[3]=o,t[4]=p,t[5]=y):y=t[5],w.useEffect(v,y);let b=g?`local-setup`:f;if(b===`content-index`){let e;return t[6]!==l||t[7]!==u||t[8]!==d?(e=(0,T.jsx)(Y,{status:l,statusError:u,onContinueInBackground:d}),t[6]=l,t[7]=u,t[8]=d,t[9]=e):e=t[9],e}if(b===`recovery`){let e,n;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>h(!1),n=()=>{h(!1),_(!0)},t[10]=e,t[11]=n):(e=t[10],n=t[11]);let r;t[12]===c?r=t[13]:(r=()=>{_(!0),c?.()},t[12]=c,t[13]=r);let i;return t[14]!==s||t[15]!==o||t[16]!==p||t[17]!==m||t[18]!==r?(i=(0,T.jsx)(q,{variant:p,hostUrl:o,hostLabel:s,showRemoteForm:m,onCloseRemoteForm:e,onSwitchToLocalFromRemote:n,onEnterLocalSetup:r}),t[14]=s,t[15]=o,t[16]=p,t[17]=m,t[18]=r,t[19]=i):i=t[19],i}if(b===`local-setup`){let e;t[20]!==n||t[21]!==g?(e=()=>{g?_(!1):n?.()},t[20]=n,t[21]=g,t[22]=e):e=t[22];let i;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>h(!0),t[23]=i):i=t[23];let a;return t[24]!==r||t[25]!==g||t[26]!==e?(a=(0,T.jsx)(V,{onBack:e,onCliAvailable:r,isFromRecovery:g,onSwitchToRemote:i}),t[24]=r,t[25]=g,t[26]=e,t[27]=a):a=t[27],a}let x;return t[28]===r?x=t[29]:(x=(0,T.jsx)(I,{onCliAvailable:r}),t[28]=r,t[29]=x),x}export{X as OnboardingScreen};
@@ -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{en as t,rn as n}from"./persistence-Dzooc9Xg.js";import{it as r,rt as i}from"./vendor-base-ui-CdzJ6My_.js";import{n as a}from"./platform-7bX6qtBV.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as o}from"./vendor-react-BP2cRVqX.js";import{o as s}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{r as c}from"./button-_ReBqWzC.js";var l=e(r(),1),ee=o(),te=.85,u=1.2,d=10/9,f=.9,p=.98,m=p/f,h=`yuri.designPtScale.v8`;function g(e){return!Number.isFinite(e)||e<=0?1:Math.min(u,Math.max(te,e))}function _(e){if(!e)return p;let t=e.density,n=(e.xdpi+e.ydpi)/2;if(!(t>0)||!(n>=50)||n>800)return p;let r=g(n/t/163);return Math.min(p,r*m)}function v(){if(typeof window>`u`)return 1;try{let e=Number.parseFloat(window.localStorage.getItem(`yuri.designPtScale.v8`)??``),t=window.Capacitor?.getPlatform?.();return t===`android`?Math.min(p,g(e)):t===`ios`?d:g(e)}catch{return 1}}function y(e){if(!(typeof window>`u`))try{window.localStorage.setItem(h,String(e))}catch{}}function b(e,t=document.documentElement){let n=g(e);t.style.setProperty(`--dpt`,`${n}px`),t.style.setProperty(`--dpt-n`,String(n))}async function ne(){if(typeof document>`u`)return 1;b(v());let{Capacitor:e,registerPlugin:t}=await s(async()=>{let{Capacitor:e,registerPlugin:t}=await import(`./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js`).then(e=>e.i);return{Capacitor:e,registerPlugin:t}},__vite__mapDeps([0,1]));if(!e.isNativePlatform())return b(1),1;if(e.getPlatform()===`ios`)return b(d),y(d),d;if(e.getPlatform()!==`android`)return b(1),1;if(!e.isPluginAvailable(`YuriPhysicalScale`))return b(p),y(p),p;try{let e=_(await t(`YuriPhysicalScale`).getMetrics());return y(e),b(e),e}catch{return b(p),y(p),p}}var x={xs:0,sm:640,md:768,lg:1024,xl:1280,"2xl":1536},S={isMobile:!1,isTablet:!1,isDesktop:!0,deviceType:`desktop`,screenWidth:1024,breakpoint:`lg`,hasTouchInput:!1,hasTouchOnlyPointer:!1},re=()=>typeof window>`u`?!1:new URLSearchParams(window.location.search).get(`surface`)===`desktop`,C=e=>{if(typeof navigator>`u`)return{isExplicitTablet:!1};let t=navigator.userAgent||``,n=navigator.platform||``,r=/iPad/i.test(t)||(/Macintosh|MacIntel/i.test(t)||/MacIntel/i.test(n))&&e>1,i=/Android/i.test(t)&&!/Mobile/i.test(t),a=/Tablet/i.test(t);return{isExplicitTablet:r||i||a}},w=(e,t,n)=>{if(typeof window>`u`)return;let r=document.documentElement,i=t===`mobile`,a=t===`tablet`;r.classList.remove(`device-mobile`,`device-tablet`,`device-desktop`),r.classList.add(t===`mobile`?`device-mobile`:t===`tablet`?`device-tablet`:`device-desktop`),e?(r.classList.add(`desktop-runtime`),r.style.setProperty(`--is-mobile`,`0`),r.style.setProperty(`--device-type`,`desktop`),r.style.setProperty(`--font-scale`,`1`),r.style.setProperty(`--has-coarse-pointer`,`0`),r.style.setProperty(`--has-touch-input`,`0`),r.classList.remove(`mobile-pointer`)):(r.classList.remove(`desktop-runtime`),r.style.setProperty(`--is-mobile`,i?`1`:`0`),r.style.setProperty(`--device-type`,t),r.style.setProperty(`--font-scale`,i?`0.9`:a?`0.95`:`1`),r.style.setProperty(`--has-coarse-pointer`,n?`1`:`0`),r.style.setProperty(`--has-touch-input`,n?`1`:`0`),n?r.classList.add(`mobile-pointer`):r.classList.remove(`mobile-pointer`)),b(e?1:v(),r)};function T(){let e=window.innerWidth,r=typeof window.matchMedia==`function`,i=r?window.matchMedia(`(pointer: coarse)`):null,o=r?window.matchMedia(`(hover: none)`):null,s=i?.matches??!1,c=o?.matches??!1,l=typeof navigator<`u`?navigator.maxTouchPoints??0:0,ee=t()||n()||re(),{isExplicitTablet:te}=C(l),u=s||c||l>0,d=s||c,f=e>x.md&&e<=x.lg,p=e<=x.md,m=u&&p,h=u&&!m&&(f||te),g=!u||!h&&e>x.lg,_=`desktop`;ee?(m=!1,h=!1,g=!0,_=`desktop`):a()?(m=!0,h=!1,g=!1,_=`mobile`):m?_=`mobile`:h?_=`tablet`:(g=!0,_=`desktop`),w(ee,_,u);let v=`xs`;for(let[t,n]of Object.entries(x))e>=n&&(v=t);return{isMobile:m,isTablet:h,isDesktop:g,deviceType:_,screenWidth:e,breakpoint:v,hasTouchInput:u,hasTouchOnlyPointer:d}}var E=(e,t)=>e.isMobile===t.isMobile&&e.isTablet===t.isTablet&&e.isDesktop===t.isDesktop&&e.deviceType===t.deviceType&&e.screenWidth===t.screenWidth&&e.breakpoint===t.breakpoint&&e.hasTouchInput===t.hasTouchInput&&e.hasTouchOnlyPointer===t.hasTouchOnlyPointer,D=new Set,O=null,k,A=null,ie=()=>typeof window>`u`?S:(O||=T(),O),j=()=>{for(let e of D)e()},M=()=>{k=void 0;let e=T();O&&E(O,e)||(O=e,j())},N=()=>{typeof window>`u`||k!==void 0||(k=window.requestAnimationFrame(M))},P=(e,t)=>e?typeof e.addEventListener==`function`?(e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)):typeof e.addListener==`function`?(e.addListener(t),()=>e.removeListener(t)):()=>{}:()=>{},F=()=>{if(typeof window>`u`)return()=>{};O=T(),window.addEventListener(`resize`,N);let e=typeof window.matchMedia==`function`?window.matchMedia(`(pointer: coarse)`):null,t=typeof window.matchMedia==`function`?window.matchMedia(`(hover: none)`):null,n=P(e,N),r=P(t,N);return()=>{window.removeEventListener(`resize`,N),n(),r(),k!==void 0&&(window.cancelAnimationFrame(k),k=void 0)}},I=e=>typeof window>`u`?()=>{}:(D.add(e),A||=F(),()=>{D.delete(e),D.size===0&&A&&(A(),A=null,O=null)});function L(){if(typeof window>`u`||typeof window<`u`&&t())return!1;let e=document.documentElement,n=e.style.getPropertyValue(`--is-mobile`)||getComputedStyle(e).getPropertyValue(`--is-mobile`);return n===`1`||n===`true`}var ae=()=>typeof window>`u`?!1:!!(navigator.standalone===!0||window.matchMedia?.(`(display-mode: standalone)`)?.matches||window.matchMedia?.(`(display-mode: fullscreen)`)?.matches),R=()=>{if(typeof window>`u`||t())return!1;let e=typeof navigator<`u`?navigator.maxTouchPoints??0:0;return ae()&&e>0&&window.innerWidth>x.md};function z(){let e=(0,ee.c)(2),[t,n]=l.useState(B),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{if(typeof window>`u`)return;let e=()=>n(R()),t=window.matchMedia?.(`(display-mode: standalone)`),r=window.matchMedia?.(`(display-mode: fullscreen)`);e(),window.addEventListener(`resize`,e),window.addEventListener(`focus`,e);let i=t=>{t&&(typeof t.addEventListener==`function`?t.addEventListener(`change`,e):typeof t.addListener==`function`&&t.addListener(e))},a=t=>{t&&(typeof t.removeEventListener==`function`?t.removeEventListener(`change`,e):typeof t.removeListener==`function`&&t.removeListener(e))};return i(t),i(r),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`focus`,e),a(t),a(r)}},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),l.useEffect(r,i),t}function B(){return R()}var V=()=>typeof window>`u`?`portrait`:window.matchMedia?.(`(orientation: landscape)`)?.matches?`landscape`:`portrait`;function H(){let e=(0,ee.c)(2),[t,n]=l.useState(V),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(orientation: landscape)`),t=()=>n(e.matches?`landscape`:`portrait`);return t(),P(e,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),l.useEffect(r,i),t}function U(){return l.useSyncExternalStore(I,ie,oe)}function oe(){return S}var se=i(),ce=1e3,W=.5,le={length:0,offset:0},ue=(e,t)=>Math.abs(e.length-t.length)<W&&Math.abs(e.offset-t.offset)<W,G=e=>{let t=(0,ee.c)(66),{containerRef:n,minThumbSize:r,hideDelayMs:i,className:a,disableHorizontal:o,observeMutations:s,suppressVisibility:te,userIntentOnly:u}=e,d=r===void 0?32:r,f=i===void 0?1e3:i,p=o!==void 0&&o,m=s===void 0||s,h=te!==void 0&&te,g=u!==void 0&&u,[_,v]=l.useState(!1),y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(y={length:0,offset:0},t[0]=y):y=t[0];let[b,ne]=l.useState(y),x;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(x={length:0,offset:0},t[1]=x):x=t[1];let[S,re]=l.useState(x),C=l.useRef(null),w=l.useRef(null),T=l.useRef(null),E=l.useRef(!1),D=l.useRef(!1),O=l.useRef(0),k;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(k={pointerX:0,pointerY:0,scrollTop:0,scrollLeft:0},t[2]=k):k=t[2];let A=l.useRef(k),ie=l.useRef(null),j;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(j=new Set,t[3]=j):j=t[3];let M=l.useRef(j),N;t[4]!==n||t[5]!==p||t[6]!==d?(N=()=>{let e=n.current;if(!e)return;let{scrollHeight:t,clientHeight:r,scrollTop:i,scrollWidth:a,clientWidth:o,scrollLeft:s}=e,c=le;if(t>r){let e=Math.max(r-16,0),n=r/t*e,a=Math.max(d,Math.min(e,n)),o=Math.max(e-a,0);c={length:a,offset:i/Math.max(t-r,1)*o}}ne(e=>ue(e,c)?e:c);let l=le;if(!p&&a>o){let e=Math.max(o-16,0),t=o/a*e,n=Math.max(d,Math.min(e,t)),r=Math.max(e-n,0);l={length:n,offset:s/Math.max(a-o,1)*r}}re(e=>ue(e,l)?e:l)},t[4]=n,t[5]=p,t[6]=d,t[7]=N):N=t[7];let P=N,F;t[8]===P?F=t[9]:(F=()=>{T.current===null&&(T.current=requestAnimationFrame(()=>{T.current=null,P()}))},t[8]=P,t[9]=F);let I=F,L;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(L=(e,t)=>{if(!t){M.current.clear();return}let n=new Set;n.add(e),Array.from(e.children).forEach(e=>{n.add(e)}),M.current.forEach(e=>{n.has(e)||t.unobserve(e)}),n.forEach(e=>{M.current.has(e)||t.observe(e)}),M.current=n},t[10]=L):L=t[10];let ae=L,R;t[11]===f?R=t[12]:(R=()=>{C.current&&clearTimeout(C.current),!D.current&&(C.current=setTimeout(()=>v(!1),f))},t[11]=f,t[12]=R);let z=R,B;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(B=()=>{O.current=Date.now()},t[13]=B):B=t[13];let V=B,H;t[14]!==z||t[15]!==h||t[16]!==P||t[17]!==g?(H=()=>{w.current&&cancelAnimationFrame(w.current),w.current=requestAnimationFrame(()=>{if(P(),h&&!E.current){v(!1);return}if(g&&!E.current&&!(Date.now()-O.current<=ce)){v(!1);return}v(!0),z()})},t[14]=z,t[15]=h,t[16]=P,t[17]=g,t[18]=H):H=t[18];let U=H,oe,W;t[19]!==n||t[20]!==U||t[21]!==m||t[22]!==I||t[23]!==P||t[24]!==g?(oe=()=>{let e=n.current;if(!e)return;P(),v(!1);let t=()=>U(),r=e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`PageUp`||e.key===`PageDown`||e.key===`Home`||e.key===`End`||e.key===` `)&&V()};e.addEventListener(`scroll`,t,{passive:!0}),g&&(e.addEventListener(`wheel`,V,{passive:!0}),e.addEventListener(`touchstart`,V,{passive:!0}),e.addEventListener(`touchmove`,V,{passive:!0}),e.addEventListener(`keydown`,r));let i=typeof ResizeObserver<`u`?new ResizeObserver(()=>{I()}):null;ae(e,i);let a=m&&typeof MutationObserver<`u`?new MutationObserver(()=>{ae(e,i),I()}):null;a?.observe(e,{childList:!0});let o=()=>I(),s=()=>I();return e.addEventListener(`input`,o,!0),e.addEventListener(`load`,s,!0),()=>{e.removeEventListener(`scroll`,t),e.removeEventListener(`input`,o,!0),e.removeEventListener(`load`,s,!0),g&&(e.removeEventListener(`wheel`,V),e.removeEventListener(`touchstart`,V),e.removeEventListener(`touchmove`,V),e.removeEventListener(`keydown`,r)),i?.disconnect(),a?.disconnect(),M.current.clear(),C.current&&clearTimeout(C.current),w.current&&cancelAnimationFrame(w.current),T.current&&cancelAnimationFrame(T.current)}},W=[n,U,V,m,I,ae,P,g],t[19]=n,t[20]=U,t[21]=m,t[22]=I,t[23]=P,t[24]=g,t[25]=oe,t[26]=W):(oe=t[25],W=t[26]),l.useEffect(oe,W);let G,de;t[27]===h?(G=t[28],de=t[29]):(G=()=>{h&&(E.current||(v(!1),C.current&&=(clearTimeout(C.current),null)))},de=[h],t[27]=h,t[28]=G,t[29]=de),l.useEffect(G,de);let fe;t[30]===n?fe=t[31]:(fe=(e,t)=>{let r=n.current;r&&(E.current=!0,A.current={pointerX:e.clientX,pointerY:e.clientY,scrollTop:r.scrollTop,scrollLeft:r.scrollLeft},ie.current=t,V(),v(!0),C.current&&clearTimeout(C.current),e.currentTarget.setPointerCapture(e.pointerId))},t[30]=n,t[31]=fe);let K=fe,pe;t[32]!==n||t[33]!==S.length||t[34]!==b.length?(pe=e=>{if(!E.current)return;let t=n.current;if(!t)return;let r=ie.current;if(r===`vertical`){let{pointerY:n,scrollTop:r}=A.current,i=e.clientY-n,a=t.clientHeight,o=Math.max(a-b.length,1),s=Math.max(t.scrollHeight-t.clientHeight,1);t.scrollTop=r+i/o*s}else if(r===`horizontal`){let{pointerX:n,scrollLeft:r}=A.current,i=e.clientX-n,a=t.clientWidth,o=Math.max(a-S.length,1),s=Math.max(t.scrollWidth-t.clientWidth,1);t.scrollLeft=r+i/o*s}},t[32]=n,t[33]=S.length,t[34]=b.length,t[35]=pe):pe=t[35];let q=pe,me;t[36]===z?me=t[37]:(me=e=>{E.current&&(E.current=!1,e.currentTarget.releasePointerCapture(e.pointerId),z())},t[36]=z,t[37]=me);let J=me,he;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(he=()=>{D.current=!0,C.current&&=(clearTimeout(C.current),null)},t[38]=he):he=t[38];let ge=he,_e;t[39]===z?_e=t[40]:(_e=()=>{D.current=!1,z()},t[39]=z,t[40]=_e);let Y=_e,ve=b.length>0,ye=S.length>0;if(!ve&&!ye)return null;let X;t[41]===a?X=t[42]:(X=c(`overlay-scrollbar`,a),t[41]=a,t[42]=X);let be=+!!_,Z;t[43]===be?Z=t[44]:(Z={opacity:be},t[43]=be,t[44]=Z);let Q;t[45]!==K||t[46]!==q||t[47]!==J||t[48]!==Y||t[49]!==ve||t[50]!==b.length||t[51]!==b.offset?(Q=ve&&(0,se.jsx)(`div`,{className:`overlay-scrollbar__thumb overlay-scrollbar__thumb--vertical`,"data-overlay-scrollbar-thumb":`vertical`,style:{height:`${b.length}px`,top:`${8+b.offset}px`,right:`4px`},onPointerDown:e=>K(e,`vertical`),onPointerMove:q,onPointerUp:J,onPointerCancel:J,onMouseEnter:ge,onMouseLeave:Y}),t[45]=K,t[46]=q,t[47]=J,t[48]=Y,t[49]=ve,t[50]=b.length,t[51]=b.offset,t[52]=Q):Q=t[52];let $;t[53]!==K||t[54]!==q||t[55]!==J||t[56]!==Y||t[57]!==S.length||t[58]!==S.offset||t[59]!==ye?($=ye&&(0,se.jsx)(`div`,{className:`overlay-scrollbar__thumb overlay-scrollbar__thumb--horizontal`,"data-overlay-scrollbar-thumb":`horizontal`,style:{width:`${S.length}px`,left:`${8+S.offset}px`,bottom:`4px`},onPointerDown:e=>K(e,`horizontal`),onPointerMove:q,onPointerUp:J,onPointerCancel:J,onMouseEnter:ge,onMouseLeave:Y}),t[53]=K,t[54]=q,t[55]=J,t[56]=Y,t[57]=S.length,t[58]=S.offset,t[59]=ye,t[60]=$):$=t[60];let xe;return t[61]!==X||t[62]!==Z||t[63]!==Q||t[64]!==$?(xe=(0,se.jsxs)(`div`,{className:X,"aria-hidden":`true`,style:Z,children:[Q,$]}),t[61]=X,t[62]=Z,t[63]=Q,t[64]=$,t[65]=xe):xe=t[65],xe};G.displayName=`OverlayScrollbar`;var de=G;export{H as a,U as i,T as n,z as o,L as r,ne as s,de as t};
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{en as t,rn as n}from"./persistence-Dzooc9Xg.js";import{it as r,rt as i}from"./vendor-base-ui-CdzJ6My_.js";import{n as a}from"./platform-7bX6qtBV.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as o}from"./vendor-react-BP2cRVqX.js";import{o as s}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{r as c}from"./button-D_HdP1Oy.js";var l=e(r(),1),ee=o(),te=.85,u=1.2,d=10/9,f=.9,p=.98,m=p/f,h=`yuri.designPtScale.v8`;function g(e){return!Number.isFinite(e)||e<=0?1:Math.min(u,Math.max(te,e))}function _(e){if(!e)return p;let t=e.density,n=(e.xdpi+e.ydpi)/2;if(!(t>0)||!(n>=50)||n>800)return p;let r=g(n/t/163);return Math.min(p,r*m)}function v(){if(typeof window>`u`)return 1;try{let e=Number.parseFloat(window.localStorage.getItem(`yuri.designPtScale.v8`)??``),t=window.Capacitor?.getPlatform?.();return t===`android`?Math.min(p,g(e)):t===`ios`?d:g(e)}catch{return 1}}function y(e){if(!(typeof window>`u`))try{window.localStorage.setItem(h,String(e))}catch{}}function b(e,t=document.documentElement){let n=g(e);t.style.setProperty(`--dpt`,`${n}px`),t.style.setProperty(`--dpt-n`,String(n))}async function ne(){if(typeof document>`u`)return 1;b(v());let{Capacitor:e,registerPlugin:t}=await s(async()=>{let{Capacitor:e,registerPlugin:t}=await import(`./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js`).then(e=>e.i);return{Capacitor:e,registerPlugin:t}},__vite__mapDeps([0,1]));if(!e.isNativePlatform())return b(1),1;if(e.getPlatform()===`ios`)return b(d),y(d),d;if(e.getPlatform()!==`android`)return b(1),1;if(!e.isPluginAvailable(`YuriPhysicalScale`))return b(p),y(p),p;try{let e=_(await t(`YuriPhysicalScale`).getMetrics());return y(e),b(e),e}catch{return b(p),y(p),p}}var x={xs:0,sm:640,md:768,lg:1024,xl:1280,"2xl":1536},S={isMobile:!1,isTablet:!1,isDesktop:!0,deviceType:`desktop`,screenWidth:1024,breakpoint:`lg`,hasTouchInput:!1,hasTouchOnlyPointer:!1},re=()=>typeof window>`u`?!1:new URLSearchParams(window.location.search).get(`surface`)===`desktop`,C=e=>{if(typeof navigator>`u`)return{isExplicitTablet:!1};let t=navigator.userAgent||``,n=navigator.platform||``,r=/iPad/i.test(t)||(/Macintosh|MacIntel/i.test(t)||/MacIntel/i.test(n))&&e>1,i=/Android/i.test(t)&&!/Mobile/i.test(t),a=/Tablet/i.test(t);return{isExplicitTablet:r||i||a}},w=(e,t,n)=>{if(typeof window>`u`)return;let r=document.documentElement,i=t===`mobile`,a=t===`tablet`;r.classList.remove(`device-mobile`,`device-tablet`,`device-desktop`),r.classList.add(t===`mobile`?`device-mobile`:t===`tablet`?`device-tablet`:`device-desktop`),e?(r.classList.add(`desktop-runtime`),r.style.setProperty(`--is-mobile`,`0`),r.style.setProperty(`--device-type`,`desktop`),r.style.setProperty(`--font-scale`,`1`),r.style.setProperty(`--has-coarse-pointer`,`0`),r.style.setProperty(`--has-touch-input`,`0`),r.classList.remove(`mobile-pointer`)):(r.classList.remove(`desktop-runtime`),r.style.setProperty(`--is-mobile`,i?`1`:`0`),r.style.setProperty(`--device-type`,t),r.style.setProperty(`--font-scale`,i?`0.9`:a?`0.95`:`1`),r.style.setProperty(`--has-coarse-pointer`,n?`1`:`0`),r.style.setProperty(`--has-touch-input`,n?`1`:`0`),n?r.classList.add(`mobile-pointer`):r.classList.remove(`mobile-pointer`)),b(e?1:v(),r)};function T(){let e=window.innerWidth,r=typeof window.matchMedia==`function`,i=r?window.matchMedia(`(pointer: coarse)`):null,o=r?window.matchMedia(`(hover: none)`):null,s=i?.matches??!1,c=o?.matches??!1,l=typeof navigator<`u`?navigator.maxTouchPoints??0:0,ee=t()||n()||re(),{isExplicitTablet:te}=C(l),u=s||c||l>0,d=s||c,f=e>x.md&&e<=x.lg,p=e<=x.md,m=u&&p,h=u&&!m&&(f||te),g=!u||!h&&e>x.lg,_=`desktop`;ee?(m=!1,h=!1,g=!0,_=`desktop`):a()?(m=!0,h=!1,g=!1,_=`mobile`):m?_=`mobile`:h?_=`tablet`:(g=!0,_=`desktop`),w(ee,_,u);let v=`xs`;for(let[t,n]of Object.entries(x))e>=n&&(v=t);return{isMobile:m,isTablet:h,isDesktop:g,deviceType:_,screenWidth:e,breakpoint:v,hasTouchInput:u,hasTouchOnlyPointer:d}}var E=(e,t)=>e.isMobile===t.isMobile&&e.isTablet===t.isTablet&&e.isDesktop===t.isDesktop&&e.deviceType===t.deviceType&&e.screenWidth===t.screenWidth&&e.breakpoint===t.breakpoint&&e.hasTouchInput===t.hasTouchInput&&e.hasTouchOnlyPointer===t.hasTouchOnlyPointer,D=new Set,O=null,k,A=null,ie=()=>typeof window>`u`?S:(O||=T(),O),j=()=>{for(let e of D)e()},M=()=>{k=void 0;let e=T();O&&E(O,e)||(O=e,j())},N=()=>{typeof window>`u`||k!==void 0||(k=window.requestAnimationFrame(M))},P=(e,t)=>e?typeof e.addEventListener==`function`?(e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)):typeof e.addListener==`function`?(e.addListener(t),()=>e.removeListener(t)):()=>{}:()=>{},F=()=>{if(typeof window>`u`)return()=>{};O=T(),window.addEventListener(`resize`,N);let e=typeof window.matchMedia==`function`?window.matchMedia(`(pointer: coarse)`):null,t=typeof window.matchMedia==`function`?window.matchMedia(`(hover: none)`):null,n=P(e,N),r=P(t,N);return()=>{window.removeEventListener(`resize`,N),n(),r(),k!==void 0&&(window.cancelAnimationFrame(k),k=void 0)}},I=e=>typeof window>`u`?()=>{}:(D.add(e),A||=F(),()=>{D.delete(e),D.size===0&&A&&(A(),A=null,O=null)});function L(){if(typeof window>`u`||typeof window<`u`&&t())return!1;let e=document.documentElement,n=e.style.getPropertyValue(`--is-mobile`)||getComputedStyle(e).getPropertyValue(`--is-mobile`);return n===`1`||n===`true`}var ae=()=>typeof window>`u`?!1:!!(navigator.standalone===!0||window.matchMedia?.(`(display-mode: standalone)`)?.matches||window.matchMedia?.(`(display-mode: fullscreen)`)?.matches),R=()=>{if(typeof window>`u`||t())return!1;let e=typeof navigator<`u`?navigator.maxTouchPoints??0:0;return ae()&&e>0&&window.innerWidth>x.md};function z(){let e=(0,ee.c)(2),[t,n]=l.useState(B),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{if(typeof window>`u`)return;let e=()=>n(R()),t=window.matchMedia?.(`(display-mode: standalone)`),r=window.matchMedia?.(`(display-mode: fullscreen)`);e(),window.addEventListener(`resize`,e),window.addEventListener(`focus`,e);let i=t=>{t&&(typeof t.addEventListener==`function`?t.addEventListener(`change`,e):typeof t.addListener==`function`&&t.addListener(e))},a=t=>{t&&(typeof t.removeEventListener==`function`?t.removeEventListener(`change`,e):typeof t.removeListener==`function`&&t.removeListener(e))};return i(t),i(r),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`focus`,e),a(t),a(r)}},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),l.useEffect(r,i),t}function B(){return R()}var V=()=>typeof window>`u`?`portrait`:window.matchMedia?.(`(orientation: landscape)`)?.matches?`landscape`:`portrait`;function H(){let e=(0,ee.c)(2),[t,n]=l.useState(V),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(orientation: landscape)`),t=()=>n(e.matches?`landscape`:`portrait`);return t(),P(e,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),l.useEffect(r,i),t}function U(){return l.useSyncExternalStore(I,ie,oe)}function oe(){return S}var se=i(),ce=1e3,W=.5,le={length:0,offset:0},ue=(e,t)=>Math.abs(e.length-t.length)<W&&Math.abs(e.offset-t.offset)<W,G=e=>{let t=(0,ee.c)(66),{containerRef:n,minThumbSize:r,hideDelayMs:i,className:a,disableHorizontal:o,observeMutations:s,suppressVisibility:te,userIntentOnly:u}=e,d=r===void 0?32:r,f=i===void 0?1e3:i,p=o!==void 0&&o,m=s===void 0||s,h=te!==void 0&&te,g=u!==void 0&&u,[_,v]=l.useState(!1),y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(y={length:0,offset:0},t[0]=y):y=t[0];let[b,ne]=l.useState(y),x;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(x={length:0,offset:0},t[1]=x):x=t[1];let[S,re]=l.useState(x),C=l.useRef(null),w=l.useRef(null),T=l.useRef(null),E=l.useRef(!1),D=l.useRef(!1),O=l.useRef(0),k;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(k={pointerX:0,pointerY:0,scrollTop:0,scrollLeft:0},t[2]=k):k=t[2];let A=l.useRef(k),ie=l.useRef(null),j;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(j=new Set,t[3]=j):j=t[3];let M=l.useRef(j),N;t[4]!==n||t[5]!==p||t[6]!==d?(N=()=>{let e=n.current;if(!e)return;let{scrollHeight:t,clientHeight:r,scrollTop:i,scrollWidth:a,clientWidth:o,scrollLeft:s}=e,c=le;if(t>r){let e=Math.max(r-16,0),n=r/t*e,a=Math.max(d,Math.min(e,n)),o=Math.max(e-a,0);c={length:a,offset:i/Math.max(t-r,1)*o}}ne(e=>ue(e,c)?e:c);let l=le;if(!p&&a>o){let e=Math.max(o-16,0),t=o/a*e,n=Math.max(d,Math.min(e,t)),r=Math.max(e-n,0);l={length:n,offset:s/Math.max(a-o,1)*r}}re(e=>ue(e,l)?e:l)},t[4]=n,t[5]=p,t[6]=d,t[7]=N):N=t[7];let P=N,F;t[8]===P?F=t[9]:(F=()=>{T.current===null&&(T.current=requestAnimationFrame(()=>{T.current=null,P()}))},t[8]=P,t[9]=F);let I=F,L;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(L=(e,t)=>{if(!t){M.current.clear();return}let n=new Set;n.add(e),Array.from(e.children).forEach(e=>{n.add(e)}),M.current.forEach(e=>{n.has(e)||t.unobserve(e)}),n.forEach(e=>{M.current.has(e)||t.observe(e)}),M.current=n},t[10]=L):L=t[10];let ae=L,R;t[11]===f?R=t[12]:(R=()=>{C.current&&clearTimeout(C.current),!D.current&&(C.current=setTimeout(()=>v(!1),f))},t[11]=f,t[12]=R);let z=R,B;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(B=()=>{O.current=Date.now()},t[13]=B):B=t[13];let V=B,H;t[14]!==z||t[15]!==h||t[16]!==P||t[17]!==g?(H=()=>{w.current&&cancelAnimationFrame(w.current),w.current=requestAnimationFrame(()=>{if(P(),h&&!E.current){v(!1);return}if(g&&!E.current&&!(Date.now()-O.current<=ce)){v(!1);return}v(!0),z()})},t[14]=z,t[15]=h,t[16]=P,t[17]=g,t[18]=H):H=t[18];let U=H,oe,W;t[19]!==n||t[20]!==U||t[21]!==m||t[22]!==I||t[23]!==P||t[24]!==g?(oe=()=>{let e=n.current;if(!e)return;P(),v(!1);let t=()=>U(),r=e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`PageUp`||e.key===`PageDown`||e.key===`Home`||e.key===`End`||e.key===` `)&&V()};e.addEventListener(`scroll`,t,{passive:!0}),g&&(e.addEventListener(`wheel`,V,{passive:!0}),e.addEventListener(`touchstart`,V,{passive:!0}),e.addEventListener(`touchmove`,V,{passive:!0}),e.addEventListener(`keydown`,r));let i=typeof ResizeObserver<`u`?new ResizeObserver(()=>{I()}):null;ae(e,i);let a=m&&typeof MutationObserver<`u`?new MutationObserver(()=>{ae(e,i),I()}):null;a?.observe(e,{childList:!0});let o=()=>I(),s=()=>I();return e.addEventListener(`input`,o,!0),e.addEventListener(`load`,s,!0),()=>{e.removeEventListener(`scroll`,t),e.removeEventListener(`input`,o,!0),e.removeEventListener(`load`,s,!0),g&&(e.removeEventListener(`wheel`,V),e.removeEventListener(`touchstart`,V),e.removeEventListener(`touchmove`,V),e.removeEventListener(`keydown`,r)),i?.disconnect(),a?.disconnect(),M.current.clear(),C.current&&clearTimeout(C.current),w.current&&cancelAnimationFrame(w.current),T.current&&cancelAnimationFrame(T.current)}},W=[n,U,V,m,I,ae,P,g],t[19]=n,t[20]=U,t[21]=m,t[22]=I,t[23]=P,t[24]=g,t[25]=oe,t[26]=W):(oe=t[25],W=t[26]),l.useEffect(oe,W);let G,de;t[27]===h?(G=t[28],de=t[29]):(G=()=>{h&&(E.current||(v(!1),C.current&&=(clearTimeout(C.current),null)))},de=[h],t[27]=h,t[28]=G,t[29]=de),l.useEffect(G,de);let fe;t[30]===n?fe=t[31]:(fe=(e,t)=>{let r=n.current;r&&(E.current=!0,A.current={pointerX:e.clientX,pointerY:e.clientY,scrollTop:r.scrollTop,scrollLeft:r.scrollLeft},ie.current=t,V(),v(!0),C.current&&clearTimeout(C.current),e.currentTarget.setPointerCapture(e.pointerId))},t[30]=n,t[31]=fe);let K=fe,pe;t[32]!==n||t[33]!==S.length||t[34]!==b.length?(pe=e=>{if(!E.current)return;let t=n.current;if(!t)return;let r=ie.current;if(r===`vertical`){let{pointerY:n,scrollTop:r}=A.current,i=e.clientY-n,a=t.clientHeight,o=Math.max(a-b.length,1),s=Math.max(t.scrollHeight-t.clientHeight,1);t.scrollTop=r+i/o*s}else if(r===`horizontal`){let{pointerX:n,scrollLeft:r}=A.current,i=e.clientX-n,a=t.clientWidth,o=Math.max(a-S.length,1),s=Math.max(t.scrollWidth-t.clientWidth,1);t.scrollLeft=r+i/o*s}},t[32]=n,t[33]=S.length,t[34]=b.length,t[35]=pe):pe=t[35];let q=pe,me;t[36]===z?me=t[37]:(me=e=>{E.current&&(E.current=!1,e.currentTarget.releasePointerCapture(e.pointerId),z())},t[36]=z,t[37]=me);let J=me,he;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(he=()=>{D.current=!0,C.current&&=(clearTimeout(C.current),null)},t[38]=he):he=t[38];let ge=he,_e;t[39]===z?_e=t[40]:(_e=()=>{D.current=!1,z()},t[39]=z,t[40]=_e);let Y=_e,ve=b.length>0,ye=S.length>0;if(!ve&&!ye)return null;let X;t[41]===a?X=t[42]:(X=c(`overlay-scrollbar`,a),t[41]=a,t[42]=X);let be=+!!_,Z;t[43]===be?Z=t[44]:(Z={opacity:be},t[43]=be,t[44]=Z);let Q;t[45]!==K||t[46]!==q||t[47]!==J||t[48]!==Y||t[49]!==ve||t[50]!==b.length||t[51]!==b.offset?(Q=ve&&(0,se.jsx)(`div`,{className:`overlay-scrollbar__thumb overlay-scrollbar__thumb--vertical`,"data-overlay-scrollbar-thumb":`vertical`,style:{height:`${b.length}px`,top:`${8+b.offset}px`,right:`4px`},onPointerDown:e=>K(e,`vertical`),onPointerMove:q,onPointerUp:J,onPointerCancel:J,onMouseEnter:ge,onMouseLeave:Y}),t[45]=K,t[46]=q,t[47]=J,t[48]=Y,t[49]=ve,t[50]=b.length,t[51]=b.offset,t[52]=Q):Q=t[52];let $;t[53]!==K||t[54]!==q||t[55]!==J||t[56]!==Y||t[57]!==S.length||t[58]!==S.offset||t[59]!==ye?($=ye&&(0,se.jsx)(`div`,{className:`overlay-scrollbar__thumb overlay-scrollbar__thumb--horizontal`,"data-overlay-scrollbar-thumb":`horizontal`,style:{width:`${S.length}px`,left:`${8+S.offset}px`,bottom:`4px`},onPointerDown:e=>K(e,`horizontal`),onPointerMove:q,onPointerUp:J,onPointerCancel:J,onMouseEnter:ge,onMouseLeave:Y}),t[53]=K,t[54]=q,t[55]=J,t[56]=Y,t[57]=S.length,t[58]=S.offset,t[59]=ye,t[60]=$):$=t[60];let xe;return t[61]!==X||t[62]!==Z||t[63]!==Q||t[64]!==$?(xe=(0,se.jsxs)(`div`,{className:X,"aria-hidden":`true`,style:Z,children:[Q,$]}),t[61]=X,t[62]=Z,t[63]=Q,t[64]=$,t[65]=xe):xe=t[65],xe};G.displayName=`OverlayScrollbar`;var de=G;export{H as a,U as i,T as n,z as o,L as r,ne as s,de as t};