@yuriai/web 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/assets/{AssistantView-BJyGm9Js.js → AssistantView-D4pGrXQ2.js} +3 -3
  2. package/dist/assets/{DiagramView-BRK8rzVX.js → DiagramView-ClqTTADy.js} +1 -1
  3. package/dist/assets/{MarkdownRenderer-D4Ba9SUF.js → MarkdownRenderer-CnHu4XPA.js} +2 -2
  4. package/dist/assets/{MarkdownRendererImpl-Dt0t56Yx.js → MarkdownRendererImpl-BsnfVIC9.js} +1 -1
  5. package/dist/assets/{MarkstreamRendererImpl-rGcpWsHj.js → MarkstreamRendererImpl-Cmzb7xFE.js} +1 -1
  6. package/dist/assets/{MobileDetailNavigation-Cyp_3Hha.js → MobileDetailNavigation-OWYq5ZOS.js} +1 -1
  7. package/dist/assets/{MobileShareBridge-BQnwoSB3.js → MobileShareBridge-DukiyCpU.js} +1 -1
  8. package/dist/assets/MobileTabPageHeader-Cp_gk7cy.js +2 -0
  9. package/dist/assets/{MultiRunWindow-rggd5jvJ.js → MultiRunWindow-kOpD2Th8.js} +1 -1
  10. package/dist/assets/{SettingsView-DWeiBwOG.js → SettingsView-CNxbrxjd.js} +11 -11
  11. package/dist/assets/{SettingsWindow-1csE2lF6.js → SettingsWindow-B_Fgbas9.js} +1 -1
  12. package/dist/assets/{TerminalView-mF-mbAzo.js → TerminalView-Cz3XX-pa.js} +1 -1
  13. package/dist/assets/{ToolOutputDialog-BvgdBVst.js → ToolOutputDialog-Ck3maV4e.js} +1 -1
  14. package/dist/assets/{appThemeRegistry-CiQ61T5d.js → appThemeRegistry-8PNdkIWO.js} +1 -1
  15. package/dist/assets/{capgoAdapter-DLi2tcmI.js → capgoAdapter-CnsewE-n.js} +1 -1
  16. package/dist/assets/{fileMentionTouchSelection-C9jpvVUn.js → fileMentionTouchSelection-CRG8r4mq.js} +1 -1
  17. package/dist/assets/{gitApi-nArpJO6q.js → gitApi-2OimpBnB.js} +1 -1
  18. package/dist/assets/{insertionBoundaries-BgHgsc1p.js → insertionBoundaries-DEY-uxCq.js} +1 -1
  19. package/dist/assets/{main-D5JkjH8k.js → main-D_ttGvxI.js} +4 -4
  20. package/dist/assets/{main-R2wbcT-3.js → main-y7Aekp2v.js} +2 -2
  21. package/dist/assets/{mcpQueries-W-LFzCOw.js → mcpQueries-Qx_eVfxx.js} +1 -1
  22. package/dist/assets/{miniChat-ChGISVuo.js → miniChat-DcATvJc9.js} +2 -2
  23. package/dist/assets/{mobile-Dv3wbcd9.js → mobile-CfPAWSXr.js} +2 -2
  24. package/dist/assets/{mobileBackNavigation-BnipJtFo.js → mobileBackNavigation-B_aT7hZA.js} +1 -1
  25. package/dist/assets/{multirun-DvSn-icg.js → multirun-B2GaFlNf.js} +1 -1
  26. package/dist/assets/native-config-Cu2rtzKa.js +1 -0
  27. package/dist/assets/{projectMeta-Cm0n6vtB.js → projectMeta-CfvCStpj.js} +1 -1
  28. package/dist/assets/{renderElectronMiniChatApp-BjQyp-u8.js → renderElectronMiniChatApp-D0v1rp6C.js} +2 -2
  29. package/dist/assets/{renderMobileApp-BEkWDH7L.js → renderMobileApp-1NEaEWn6.js} +4 -4
  30. package/dist/assets/runtimeConfig-CE0t2CEh.js +2 -0
  31. package/dist/assets/{runtimeEndpointReset-BYn28E2A.js → runtimeEndpointReset-BPBRlu2g.js} +1 -1
  32. package/dist/assets/{sessionChangeSummary-DXpoQiGE.js → sessionChangeSummary-C8fjiAIl.js} +1 -1
  33. package/dist/assets/{sessionLookup-BYycaYEQ.js → sessionLookup-CxeDvyRN.js} +1 -1
  34. package/dist/assets/{speechSettingsQueries-Bv08BFlI.js → speechSettingsQueries-L-IonKwV.js} +1 -1
  35. package/dist/assets/{types-Q_utERET.js → types-0GGhodUf.js} +1 -1
  36. package/dist/assets/{useAppFontEffects-HYIeI-xf.js → useAppFontEffects-BzvaFRBa.js} +5 -5
  37. package/dist/assets/{useDesktopWindowControlsLayout-Cc-2uuN5.js → useDesktopWindowControlsLayout-B7YLipUA.js} +1 -1
  38. package/dist/assets/{useEffectiveDirectory-BBb97raM.js → useEffectiveDirectory-BkXDzQaJ.js} +1 -1
  39. package/dist/assets/{useMobileNavigationStore-CEVJSNnR.js → useMobileNavigationStore-CjhF9j5V.js} +3 -3
  40. package/dist/assets/{useWorkerHighlightedLines-D8JkeSuf.js → useWorkerHighlightedLines-C-BpvG5l.js} +1 -1
  41. package/dist/index.html +5 -4
  42. package/dist/mini-chat.html +5 -4
  43. package/dist/mobile.html +5 -4
  44. package/package.json +1 -1
  45. package/dist/assets/MobileTabPageHeader-CDFE4Ws4.js +0 -2
  46. package/dist/assets/runtimeConfig-D3moXtPz.js +0 -2
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{it as t,rt as n}from"./vendor-base-ui-CdzJ6My_.js";import{v as r}from"./useUIStore-NMQx_cnG.js";import{n as i}from"./vendor-react-BP2cRVqX.js";import{f as a,r as o,t as s}from"./button-C3292Ee6.js";import{n as c}from"./useThemeSystem-8jhE4Zyk.js";import{n as l}from"./Icon-jsQQXouE.js";import{i as u,n as d,t as f}from"./tooltip-DGUZtHif.js";import{n as p}from"./MarkdownRenderer-D4Ba9SUF.js";import{n as m,o as h,s as g,t as _}from"./markdown-worker-CkO3sT4Y.js";import{t as v}from"./vendor-tanstack-react-virtual-B_EO--9t.js";import{n as y}from"./markdownTheme-DHoKvD6O.js";var b=e(t(),1),x=i(),S=n(),C=`w-[min(30rem,calc(100cqw-1rem))] min-w-[280px] max-w-full overflow-hidden rounded-xl shadow-[inset_0_1px_0_0_rgba(255,255,255,0.8),inset_0_0_0_1px_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.10),0_1px_2px_-0.5px_rgba(0,0,0,0.08),0_4px_8px_-2px_rgba(0,0,0,0.08),0_12px_20px_-4px_rgba(0,0,0,0.08)] dark:shadow-[inset_0_1px_0_0_rgba(255,255,255,0.12),inset_0_0_0_1px_rgba(255,255,255,0.08),0_0_0_1px_rgba(0,0,0,0.36),0_1px_1px_-0.5px_rgba(0,0,0,0.22),0_3px_3px_-1.5px_rgba(0,0,0,0.20),0_6px_6px_-3px_rgba(0,0,0,0.16)]`,w={maxWidth:`min(28rem, calc(100cqw - 4ch))`,backgroundColor:`var(--surface-elevated)`,color:`var(--surface-elevated-foreground)`},T=`flex items-center justify-between gap-3 border-b border-[var(--surface-subtle)] px-3 py-2.5`,E=`text-xs font-medium leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,D=`text-xs tabular-nums leading-4 text-muted-foreground md:text-[0.8125rem] md:leading-5`,O=`m-0 list-none divide-y divide-[var(--surface-subtle)] p-0`,k=`${O} max-h-[min(22rem,50vh)] overflow-y-auto`,A=`${O} w-full`,ee={className:`p-0 rounded-none`,maxHeightClass:`max-h-[46vh]`,disableHorizontal:!0},j=`px-2.5 py-1.5 text-xs leading-4 md:py-2 md:text-[0.8125rem] md:leading-5`,M=`flex min-w-0 items-center gap-1 text-xs leading-4 text-muted-foreground md:gap-1.5 md:text-[0.8125rem] md:leading-5`,te=`min-w-0 truncate text-xs leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,ne=`inline-flex shrink-0 items-center gap-1 text-xs leading-4 tabular-nums text-muted-foreground md:text-[0.8125rem] md:leading-5`,re=`h-3 w-3 shrink-0 md:h-3.5 md:w-3.5`,ie={in_progress:`text-foreground`,pending:`text-foreground`,completed:`text-muted-foreground line-through`,cancelled:`text-muted-foreground line-through`},ae={in_progress:`chat.statusRow.todo.status.inProgress`,pending:`chat.statusRow.todo.status.pending`,completed:`chat.statusRow.todo.status.completed`,cancelled:`chat.statusRow.todo.status.cancelled`},N=e=>{let t=(0,x.c)(26),{todo:n,isActive:r,activeRef:i}=e,{t:s}=a(),c=oe.has(n.status)?n.status:`pending`,p=ae[c],m;t[0]!==s||t[1]!==p?(m=s(p),t[0]=s,t[1]=p,t[2]=m):m=t[2];let h=m,g;t[3]===c?g=t[4]:(g=c===`in_progress`?(0,S.jsx)(l,{name:`record-circle`,className:`h-3.5 w-3.5 text-[var(--status-info)]`,"aria-hidden":`true`}):c===`completed`?(0,S.jsx)(l,{name:`checkbox-circle`,className:`h-3.5 w-3.5 text-[var(--status-success)]`,"aria-hidden":`true`}):(0,S.jsx)(l,{name:`time`,className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":`true`}),t[3]=c,t[4]=g);let _=g,v=r?`step`:void 0,y=r&&`bg-[var(--surface-muted)] before:absolute before:inset-y-2 before:left-0 before:w-0.5 before:rounded-full before:bg-[var(--status-info)]`,b;t[5]===y?b=t[6]:(b=o(`group relative grid min-w-0 grid-cols-[1rem_minmax(0,1fr)] items-start gap-2.5`,j,y),t[5]=y,t[6]=b);let C;t[7]!==_||t[8]!==h?(C=(0,S.jsx)(u,{asChild:!0,children:(0,S.jsx)(`span`,{className:`flex size-4 items-center justify-center`,"aria-label":h,children:_})}),t[7]=_,t[8]=h,t[9]=C):C=t[9];let w;t[10]===h?w=t[11]:(w=(0,S.jsx)(d,{side:`left`,sideOffset:6,children:h}),t[10]=h,t[11]=w);let T;t[12]!==C||t[13]!==w?(T=(0,S.jsxs)(f,{children:[C,w]}),t[12]=C,t[13]=w,t[14]=T):T=t[14];let E=ie[c],D;t[15]===E?D=t[16]:(D=o(`block whitespace-normal break-words`,E),t[15]=E,t[16]=D);let O;t[17]!==D||t[18]!==n.content?(O=(0,S.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,S.jsx)(`span`,{className:D,children:n.content})}),t[17]=D,t[18]=n.content,t[19]=O):O=t[19];let k;return t[20]!==i||t[21]!==O||t[22]!==v||t[23]!==b||t[24]!==T?(k=(0,S.jsxs)(`li`,{ref:i,"aria-current":v,className:b,children:[T,O]}),t[20]=i,t[21]=O,t[22]=v,t[23]=b,t[24]=T,t[25]=k):k=t[25],k},oe=new Set([`in_progress`,`pending`,`completed`,`cancelled`]),P=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`),F=e=>e?Object.entries(e).map(([e,t])=>t==null?``:`${e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}:${typeof t==`number`?`${t}px`:t};`).join(``):``,I=(e,t,n)=>{let r=e.querySelector(`pre`);r&&(r.style.margin=`0`,r.style.background=`transparent`,r.style.whiteSpace=t?`pre-wrap`:`pre`,t&&(r.style.wordBreak=`break-word`,r.style.overflowWrap=`break-word`));let i=e.querySelector(`code`);if(i){let e=F(n);e&&i.setAttribute(`style`,`${i.getAttribute(`style`)??``}${e}`)}},L=e=>`<pre><code>${P(e)}</code></pre>`,R=e=>{let t=(0,x.c)(21),{code:n,language:r,className:i,style:a,codeStyle:s,wrap:l}=e,u=l!==void 0&&l,{currentTheme:d}=c(),f=b.useRef(null),p;t[0]===d?p=t[1]:(p=y(d),t[0]=d,t[1]=p);let m=p,h,g;t[2]!==n||t[3]!==s||t[4]!==u?(h=()=>{let e=f.current;e&&(e.innerHTML=L(n),I(e,u,s))},g=[n,u,s],t[2]=n,t[3]=s,t[4]=u,t[5]=h,t[6]=g):(h=t[5],g=t[6]),b.useLayoutEffect(h,g);let v,C;t[7]!==n||t[8]!==s||t[9]!==r||t[10]!==u?(v=()=>{let e=f.current;if(!e)return;let t=!0,i=new AbortController;return _(n,(r||`text`).toLowerCase(),{signal:i.signal,priority:`visible`}).then(n=>{!t||!e||!n||(e.innerHTML=n,I(e,u,s))}),()=>{t=!1,i.abort()}},C=[n,r,u,s],t[7]=n,t[8]=s,t[9]=r,t[10]=u,t[11]=v,t[12]=C):(v=t[11],C=t[12]),b.useEffect(v,C);let w;t[13]===i?w=t[14]:(w=o(`typography-code`,i),t[13]=i,t[14]=w);let T=m,E;t[15]!==a||t[16]!==T?(E={...T,...a},t[15]=a,t[16]=T,t[17]=E):E=t[17];let D;return t[18]!==w||t[19]!==E?(D=(0,S.jsx)(`div`,{ref:f,className:w,style:E}),t[18]=w,t[19]=E,t[20]=D):D=t[20],D},z=e=>{let t=e.replace(/^<file>\s*\n?/,``).replace(/\n?<\/file>\s*$/,``);return t=t.replace(/^\s*\d{5}\|\s?/gm,``),t.trim()},B=(e,t=``)=>{if(typeof e==`string`)return e;if(e==null)return t;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return JSON.stringify(e)}catch{return t}},V=e=>e?e.includes(`<diagnostics`)||e.includes(`<file_diagnostics>`)||e.includes(`LSP errors detected`)||e.includes(`This file has errors`):!1,H=e=>e?e.replace(/\n{0,2}LSP errors detected[\s\S]*?<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/\n{0,2}This file has errors[\s\S]*?<\/file_diagnostics>/g,``).replace(/<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/<file_diagnostics>[\s\S]*?<\/file_diagnostics>/g,``).trim():``,U=(e,t)=>!e||typeof e!=`object`?String(e):g(e,t||``),W=e=>{if(typeof e==`string`){let t=e.trim();return t.length>0?t:void 0}if(e&&typeof e==`object`){let t=e.patch;if(typeof t==`string`){let e=t.trim();return e.length>0?e:void 0}}},G=e=>{if(!e||typeof e!=`object`)return;let t=W(e.patch)??W(e.diff);if(t)return t;let n=Array.isArray(e.files)?e.files:[];for(let e of n){if(!e||typeof e!=`object`)continue;let t=W(e.patch)??W(e.diff);if(t)return t}},K=e=>{if(!e||typeof e!=`string`)return{data:null,isJson:!1};let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`)||!t.endsWith(`}`)&&!t.endsWith(`]`)||t.length<2)return{data:null,isJson:!1};try{let e=JSON.parse(t);return typeof e==`object`&&e?{data:e,isJson:!0}:{data:null,isJson:!1}}catch{return{data:null,isJson:!1}}},q=(e,t,n)=>{let r=z(e);if((t===`edit`||t===`multiedit`||t===`write`||t===`apply_patch`)&&V(r)&&(r=H(r)),(t===`edit`||t===`multiedit`||t===`apply_patch`)&&r.trim().length===0){let e=G(n);if(e)return e}return r},se=e=>{let t=e.match(/<type>(file|directory)<\/type>/i)?.[1]?.toLowerCase()??`unknown`,n=(e.match(/<content>([\s\S]*?)<\/content>/i)?.[1]??e).replace(/\r\n/g,`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{it as t,rt as n}from"./vendor-base-ui-CdzJ6My_.js";import{v as r}from"./useUIStore-NMQx_cnG.js";import{n as i}from"./vendor-react-BP2cRVqX.js";import{f as a,r as o,t as s}from"./button-C3292Ee6.js";import{n as c}from"./useThemeSystem-8jhE4Zyk.js";import{n as l}from"./Icon-jsQQXouE.js";import{i as u,n as d,t as f}from"./tooltip-DGUZtHif.js";import{n as p}from"./MarkdownRenderer-CnHu4XPA.js";import{n as m,o as h,s as g,t as _}from"./markdown-worker-CkO3sT4Y.js";import{t as v}from"./vendor-tanstack-react-virtual-B_EO--9t.js";import{n as y}from"./markdownTheme-DHoKvD6O.js";var b=e(t(),1),x=i(),S=n(),C=`w-[min(30rem,calc(100cqw-1rem))] min-w-[280px] max-w-full overflow-hidden rounded-xl shadow-[inset_0_1px_0_0_rgba(255,255,255,0.8),inset_0_0_0_1px_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.10),0_1px_2px_-0.5px_rgba(0,0,0,0.08),0_4px_8px_-2px_rgba(0,0,0,0.08),0_12px_20px_-4px_rgba(0,0,0,0.08)] dark:shadow-[inset_0_1px_0_0_rgba(255,255,255,0.12),inset_0_0_0_1px_rgba(255,255,255,0.08),0_0_0_1px_rgba(0,0,0,0.36),0_1px_1px_-0.5px_rgba(0,0,0,0.22),0_3px_3px_-1.5px_rgba(0,0,0,0.20),0_6px_6px_-3px_rgba(0,0,0,0.16)]`,w={maxWidth:`min(28rem, calc(100cqw - 4ch))`,backgroundColor:`var(--surface-elevated)`,color:`var(--surface-elevated-foreground)`},T=`flex items-center justify-between gap-3 border-b border-[var(--surface-subtle)] px-3 py-2.5`,E=`text-xs font-medium leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,D=`text-xs tabular-nums leading-4 text-muted-foreground md:text-[0.8125rem] md:leading-5`,O=`m-0 list-none divide-y divide-[var(--surface-subtle)] p-0`,k=`${O} max-h-[min(22rem,50vh)] overflow-y-auto`,A=`${O} w-full`,ee={className:`p-0 rounded-none`,maxHeightClass:`max-h-[46vh]`,disableHorizontal:!0},j=`px-2.5 py-1.5 text-xs leading-4 md:py-2 md:text-[0.8125rem] md:leading-5`,M=`flex min-w-0 items-center gap-1 text-xs leading-4 text-muted-foreground md:gap-1.5 md:text-[0.8125rem] md:leading-5`,te=`min-w-0 truncate text-xs leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,ne=`inline-flex shrink-0 items-center gap-1 text-xs leading-4 tabular-nums text-muted-foreground md:text-[0.8125rem] md:leading-5`,re=`h-3 w-3 shrink-0 md:h-3.5 md:w-3.5`,ie={in_progress:`text-foreground`,pending:`text-foreground`,completed:`text-muted-foreground line-through`,cancelled:`text-muted-foreground line-through`},ae={in_progress:`chat.statusRow.todo.status.inProgress`,pending:`chat.statusRow.todo.status.pending`,completed:`chat.statusRow.todo.status.completed`,cancelled:`chat.statusRow.todo.status.cancelled`},N=e=>{let t=(0,x.c)(26),{todo:n,isActive:r,activeRef:i}=e,{t:s}=a(),c=oe.has(n.status)?n.status:`pending`,p=ae[c],m;t[0]!==s||t[1]!==p?(m=s(p),t[0]=s,t[1]=p,t[2]=m):m=t[2];let h=m,g;t[3]===c?g=t[4]:(g=c===`in_progress`?(0,S.jsx)(l,{name:`record-circle`,className:`h-3.5 w-3.5 text-[var(--status-info)]`,"aria-hidden":`true`}):c===`completed`?(0,S.jsx)(l,{name:`checkbox-circle`,className:`h-3.5 w-3.5 text-[var(--status-success)]`,"aria-hidden":`true`}):(0,S.jsx)(l,{name:`time`,className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":`true`}),t[3]=c,t[4]=g);let _=g,v=r?`step`:void 0,y=r&&`bg-[var(--surface-muted)] before:absolute before:inset-y-2 before:left-0 before:w-0.5 before:rounded-full before:bg-[var(--status-info)]`,b;t[5]===y?b=t[6]:(b=o(`group relative grid min-w-0 grid-cols-[1rem_minmax(0,1fr)] items-start gap-2.5`,j,y),t[5]=y,t[6]=b);let C;t[7]!==_||t[8]!==h?(C=(0,S.jsx)(u,{asChild:!0,children:(0,S.jsx)(`span`,{className:`flex size-4 items-center justify-center`,"aria-label":h,children:_})}),t[7]=_,t[8]=h,t[9]=C):C=t[9];let w;t[10]===h?w=t[11]:(w=(0,S.jsx)(d,{side:`left`,sideOffset:6,children:h}),t[10]=h,t[11]=w);let T;t[12]!==C||t[13]!==w?(T=(0,S.jsxs)(f,{children:[C,w]}),t[12]=C,t[13]=w,t[14]=T):T=t[14];let E=ie[c],D;t[15]===E?D=t[16]:(D=o(`block whitespace-normal break-words`,E),t[15]=E,t[16]=D);let O;t[17]!==D||t[18]!==n.content?(O=(0,S.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,S.jsx)(`span`,{className:D,children:n.content})}),t[17]=D,t[18]=n.content,t[19]=O):O=t[19];let k;return t[20]!==i||t[21]!==O||t[22]!==v||t[23]!==b||t[24]!==T?(k=(0,S.jsxs)(`li`,{ref:i,"aria-current":v,className:b,children:[T,O]}),t[20]=i,t[21]=O,t[22]=v,t[23]=b,t[24]=T,t[25]=k):k=t[25],k},oe=new Set([`in_progress`,`pending`,`completed`,`cancelled`]),P=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`),F=e=>e?Object.entries(e).map(([e,t])=>t==null?``:`${e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}:${typeof t==`number`?`${t}px`:t};`).join(``):``,I=(e,t,n)=>{let r=e.querySelector(`pre`);r&&(r.style.margin=`0`,r.style.background=`transparent`,r.style.whiteSpace=t?`pre-wrap`:`pre`,t&&(r.style.wordBreak=`break-word`,r.style.overflowWrap=`break-word`));let i=e.querySelector(`code`);if(i){let e=F(n);e&&i.setAttribute(`style`,`${i.getAttribute(`style`)??``}${e}`)}},L=e=>`<pre><code>${P(e)}</code></pre>`,R=e=>{let t=(0,x.c)(21),{code:n,language:r,className:i,style:a,codeStyle:s,wrap:l}=e,u=l!==void 0&&l,{currentTheme:d}=c(),f=b.useRef(null),p;t[0]===d?p=t[1]:(p=y(d),t[0]=d,t[1]=p);let m=p,h,g;t[2]!==n||t[3]!==s||t[4]!==u?(h=()=>{let e=f.current;e&&(e.innerHTML=L(n),I(e,u,s))},g=[n,u,s],t[2]=n,t[3]=s,t[4]=u,t[5]=h,t[6]=g):(h=t[5],g=t[6]),b.useLayoutEffect(h,g);let v,C;t[7]!==n||t[8]!==s||t[9]!==r||t[10]!==u?(v=()=>{let e=f.current;if(!e)return;let t=!0,i=new AbortController;return _(n,(r||`text`).toLowerCase(),{signal:i.signal,priority:`visible`}).then(n=>{!t||!e||!n||(e.innerHTML=n,I(e,u,s))}),()=>{t=!1,i.abort()}},C=[n,r,u,s],t[7]=n,t[8]=s,t[9]=r,t[10]=u,t[11]=v,t[12]=C):(v=t[11],C=t[12]),b.useEffect(v,C);let w;t[13]===i?w=t[14]:(w=o(`typography-code`,i),t[13]=i,t[14]=w);let T=m,E;t[15]!==a||t[16]!==T?(E={...T,...a},t[15]=a,t[16]=T,t[17]=E):E=t[17];let D;return t[18]!==w||t[19]!==E?(D=(0,S.jsx)(`div`,{ref:f,className:w,style:E}),t[18]=w,t[19]=E,t[20]=D):D=t[20],D},z=e=>{let t=e.replace(/^<file>\s*\n?/,``).replace(/\n?<\/file>\s*$/,``);return t=t.replace(/^\s*\d{5}\|\s?/gm,``),t.trim()},B=(e,t=``)=>{if(typeof e==`string`)return e;if(e==null)return t;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return JSON.stringify(e)}catch{return t}},V=e=>e?e.includes(`<diagnostics`)||e.includes(`<file_diagnostics>`)||e.includes(`LSP errors detected`)||e.includes(`This file has errors`):!1,H=e=>e?e.replace(/\n{0,2}LSP errors detected[\s\S]*?<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/\n{0,2}This file has errors[\s\S]*?<\/file_diagnostics>/g,``).replace(/<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/<file_diagnostics>[\s\S]*?<\/file_diagnostics>/g,``).trim():``,U=(e,t)=>!e||typeof e!=`object`?String(e):g(e,t||``),W=e=>{if(typeof e==`string`){let t=e.trim();return t.length>0?t:void 0}if(e&&typeof e==`object`){let t=e.patch;if(typeof t==`string`){let e=t.trim();return e.length>0?e:void 0}}},G=e=>{if(!e||typeof e!=`object`)return;let t=W(e.patch)??W(e.diff);if(t)return t;let n=Array.isArray(e.files)?e.files:[];for(let e of n){if(!e||typeof e!=`object`)continue;let t=W(e.patch)??W(e.diff);if(t)return t}},K=e=>{if(!e||typeof e!=`string`)return{data:null,isJson:!1};let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`)||!t.endsWith(`}`)&&!t.endsWith(`]`)||t.length<2)return{data:null,isJson:!1};try{let e=JSON.parse(t);return typeof e==`object`&&e?{data:e,isJson:!0}:{data:null,isJson:!1}}catch{return{data:null,isJson:!1}}},q=(e,t,n)=>{let r=z(e);if((t===`edit`||t===`multiedit`||t===`write`||t===`apply_patch`)&&V(r)&&(r=H(r)),(t===`edit`||t===`multiedit`||t===`apply_patch`)&&r.trim().length===0){let e=G(n);if(e)return e}return r},se=e=>{let t=e.match(/<type>(file|directory)<\/type>/i)?.[1]?.toLowerCase()??`unknown`,n=(e.match(/<content>([\s\S]*?)<\/content>/i)?.[1]??e).replace(/\r\n/g,`
2
2
  `).split(`
3
3
  `),r=e=>/\(\s*File has more lines\..*offset.*\)/i.test(e.trim());return{type:t,lines:n.map(e=>{let n=e.trim(),i=n.startsWith(`(`)&&n.endsWith(`)`)||r(n);if(t!==`directory`){let t=e.match(/^(\d+):\s?(.*)$/);if(t){let e=t[2],n=e.trim(),i=n.startsWith(`(`)&&n.endsWith(`)`)||r(n);return{lineNumber:i?null:Number(t[1]),text:e,isInfo:i}}}return{lineNumber:null,text:e,isInfo:i}}).filter((e,t,n)=>{if(e.text.trim().length>0)return!0;let r=n[t-1],i=n[t+1],a=!!(r?.isInfo||i?.isInfo),o=e.lineNumber!==null;return!(a&&o)})}},ce=(e,t)=>{try{let n=e.trim().split(`
4
4
  `).filter(Boolean);if(n.length===0)return null;let i=[];return n.forEach(e=>{let t=e.match(/^(\s*)(.+)$/);if(t){let[,e,n]=t,r=Math.floor(e.length/2),a=!n.endsWith(`/`);i.push({name:n.replace(/\/$/,``),depth:r,isFile:a})}}),(0,S.jsx)(`div`,{className:o(`w-full min-w-0 font-mono space-y-0.5`,t?.unstyled?null:`p-3 bg-muted/20 rounded-xl border border-border/30`),style:r.tool.popup,children:i.map((e,t)=>(0,S.jsx)(`div`,{className:`min-w-0`,style:{paddingLeft:`${e.depth*20}px`},children:e.isFile?(0,S.jsx)(`span`,{className:`text-foreground/90 block truncate`,children:e.name}):(0,S.jsxs)(`span`,{className:`font-semibold text-foreground block truncate`,children:[e.name,`/`]})},t))})}catch{return null}},le={backgroundColor:`var(--status-info)`,opacity:.6},ue=(e,t,n)=>{try{let i=e.trim().split(`
package/dist/index.html CHANGED
@@ -552,7 +552,7 @@
552
552
  opacity: 0.72;
553
553
  }
554
554
  </style>
555
- <script type="module" crossorigin src="/assets/main-R2wbcT-3.js"></script>
555
+ <script type="module" crossorigin src="/assets/main-y7Aekp2v.js"></script>
556
556
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
557
557
  <link rel="modulepreload" crossorigin href="/assets/runtime-auth-ef9W7A43.js">
558
558
  <link rel="modulepreload" crossorigin href="/assets/runtime-switch-CAZiOV2G.js">
@@ -575,9 +575,10 @@
575
575
  <link rel="modulepreload" crossorigin href="/assets/platform-7bX6qtBV.js">
576
576
  <link rel="modulepreload" crossorigin href="/assets/terminalApi-BHXvha-U.js">
577
577
  <link rel="modulepreload" crossorigin href="/assets/runtime-file-download-DAOam_oV.js">
578
- <link rel="modulepreload" crossorigin href="/assets/types-Q_utERET.js">
579
- <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DLi2tcmI.js">
580
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-D3moXtPz.js">
578
+ <link rel="modulepreload" crossorigin href="/assets/types-0GGhodUf.js">
579
+ <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-CnsewE-n.js">
580
+ <link rel="modulepreload" crossorigin href="/assets/native-config-Cu2rtzKa.js">
581
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-CE0t2CEh.js">
581
582
  <link rel="stylesheet" crossorigin href="/assets/src-CmermOKP.css">
582
583
  </head>
583
584
  <body class="h-full bg-background text-foreground">
@@ -74,7 +74,7 @@
74
74
  }
75
75
  </style>
76
76
 
77
- <script type="module" crossorigin src="/assets/miniChat-ChGISVuo.js"></script>
77
+ <script type="module" crossorigin src="/assets/miniChat-DcATvJc9.js"></script>
78
78
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
79
79
  <link rel="modulepreload" crossorigin href="/assets/runtime-auth-ef9W7A43.js">
80
80
  <link rel="modulepreload" crossorigin href="/assets/runtime-switch-CAZiOV2G.js">
@@ -97,9 +97,10 @@
97
97
  <link rel="modulepreload" crossorigin href="/assets/platform-7bX6qtBV.js">
98
98
  <link rel="modulepreload" crossorigin href="/assets/terminalApi-BHXvha-U.js">
99
99
  <link rel="modulepreload" crossorigin href="/assets/runtime-file-download-DAOam_oV.js">
100
- <link rel="modulepreload" crossorigin href="/assets/types-Q_utERET.js">
101
- <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DLi2tcmI.js">
102
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-D3moXtPz.js">
100
+ <link rel="modulepreload" crossorigin href="/assets/types-0GGhodUf.js">
101
+ <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-CnsewE-n.js">
102
+ <link rel="modulepreload" crossorigin href="/assets/native-config-Cu2rtzKa.js">
103
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-CE0t2CEh.js">
103
104
  <link rel="stylesheet" crossorigin href="/assets/src-CmermOKP.css">
104
105
  </head>
105
106
  <body class="h-full bg-background text-foreground">
package/dist/mobile.html CHANGED
@@ -63,7 +63,7 @@
63
63
  })();
64
64
  </script>
65
65
 
66
- <script type="module" crossorigin src="/assets/mobile-Dv3wbcd9.js"></script>
66
+ <script type="module" crossorigin src="/assets/mobile-CfPAWSXr.js"></script>
67
67
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
68
68
  <link rel="modulepreload" crossorigin href="/assets/runtime-auth-ef9W7A43.js">
69
69
  <link rel="modulepreload" crossorigin href="/assets/runtime-switch-CAZiOV2G.js">
@@ -86,9 +86,10 @@
86
86
  <link rel="modulepreload" crossorigin href="/assets/platform-7bX6qtBV.js">
87
87
  <link rel="modulepreload" crossorigin href="/assets/terminalApi-BHXvha-U.js">
88
88
  <link rel="modulepreload" crossorigin href="/assets/runtime-file-download-DAOam_oV.js">
89
- <link rel="modulepreload" crossorigin href="/assets/types-Q_utERET.js">
90
- <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DLi2tcmI.js">
91
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-D3moXtPz.js">
89
+ <link rel="modulepreload" crossorigin href="/assets/types-0GGhodUf.js">
90
+ <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-CnsewE-n.js">
91
+ <link rel="modulepreload" crossorigin href="/assets/native-config-Cu2rtzKa.js">
92
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-CE0t2CEh.js">
92
93
  <link rel="stylesheet" crossorigin href="/assets/src-CmermOKP.css">
93
94
  </head>
94
95
  <body class="h-full bg-background text-foreground">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuriai/web",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./server/index.js",
@@ -1,2 +0,0 @@
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,o as r}from"./runtime-switch-CAZiOV2G.js";import{a as i,o as a,r as o,s,t as c,u as l}from"./queryRuntime-DKGLQtb9.js";import{$t as u,Bt as d,an as f,d as p,en as m,et as h,gn as g,i as _,in as v,on as y,rn as b,tn as x,tt as S,zt as C}from"./persistence-Dzooc9Xg.js";import{a as w,i as T,r as E}from"./vendor-zustand-o69pgTEK.js";import{it as D,nt as O,rt as k}from"./vendor-base-ui-CdzJ6My_.js";import{Ct as A,Nt as j,Vt as M,n as N,t as P}from"./platform-7bX6qtBV.js";import{b as F,n as I}from"./useUIStore-NMQx_cnG.js";import{n as L}from"./vendor-react-BP2cRVqX.js";import{o as R}from"./vendor-tanstack-react-query-CdqCAt40.js";import{o as ee}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{a as te,t as ne}from"./types-Q_utERET.js";import{$ as re,A as ie,B as z,G as ae,H as B,J as oe,L as se,P as V,T as ce,U as le,W as ue,X as de,Y as fe,a as pe,at as H,dt as me,f as he,ft as ge,g as _e,l as ve,pt as ye,st as be,z as U}from"./vendor-codemirror-autocomplete-7c2L_4dM.js";import{c as xe,o as W,r as Se}from"./vendor-codemirror-lang-angular-DXOgWEVj.js";import{n as Ce,r as we}from"./vendor-codemirror-lang-json-mLulNbwB.js";import{n as Te}from"./vendor-codemirror-lang-markdown-CV1IO6Qs.js";import{n as Ee}from"./vendor-codemirror-lang-python-YM2WVLHF.js";import{O as De}from"./vendor-codemirror-legacy-modes-DwltVFbT.js";import{n as Oe}from"./vendor-reactuses-core-BpfIZ1tg.js";import{a as ke,d as Ae,f as G,p as je,r as K,t as q}from"./button-C3292Ee6.js";import{Pr as Me,Rr as J,bi as Ne,d as Pe,er as Fe,fo as Ie,hi as Le,ir as Re,jr as ze,nr as Be,or as Ve,rr as He,so as Ue,sr as We,vn as Ge,wr as Ke}from"./useMobileNavigationStore-CEVJSNnR.js";import{n as qe}from"./useThemeSystem-8jhE4Zyk.js";import{n as Y}from"./Icon-jsQQXouE.js";import{a as Je,n as Ye,o as Xe,r as Ze,t as Qe}from"./dialog-DrgcVFLG.js";import{L as $e,_ as et,b as tt,c as nt,n as rt,s as it,u as at}from"./gitApi-nArpJO6q.js";import{A as ot,_ as st,a as ct,b as lt,c as ut,h as dt,m as ft,n as pt,r as mt,t as ht,x as gt}from"./projectMeta-Cm0n6vtB.js";import{t as _t}from"./input-DaOOTCQd.js";import{i as vt,n as yt,t as bt}from"./tooltip-DGUZtHif.js";import{$t as xt,F as St,G as Ct,Gt as wt,J as Tt,Jt as Et,Kt as Dt,M as Ot,P as kt,U as At,W as jt,Xt as Mt,Yt as Nt,a as Pt,in as Ft,it as It,k as Lt,q as Rt,qt as zt,rt as Bt,ut as Vt,v as Ht}from"./speechSettingsQueries-Bv08BFlI.js";import{i as Ut,n as Wt}from"./OverlayScrollbar-C4VUlRzo.js";import{n as Gt,t as Kt}from"./textarea-BcA4uouw.js";import{n as qt}from"./MarkdownRenderer-D4Ba9SUF.js";import{a as Jt}from"./url-Be8VCT8M.js";import{r as Yt}from"./markdown-worker-CkO3sT4Y.js";import{i as Xt,n as Zt,o as Qt}from"./mcpQueries-W-LFzCOw.js";import{n as $t,r as en,t as tn}from"./collapsible-B0yvtXQR.js";import{a as nn,d as rn,o as an,s as on}from"./vendor-codemirror-commands-B8KrBQ9B.js";import{a as sn,c as cn,i as ln,o as un,r as dn,s as fn}from"./vendor-codemirror-search-ZqtrPLjU.js";import{n as pn,t as mn}from"./vendor-replit-codemirror-vim-DDj0dSVY.js";import{t as hn}from"./vendor-codemirror-language-data-Ctd4WxgW.js";import{i as gn,n as _n,r as vn,t as yn}from"./projectActions-BX0cjZoq.js";var bn=[{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`}],xn=e=>[...bn,...e.filter(e=>e.source===`magpie`).map(e=>({id:e.providerId,name:e.providerName}))],X=L(),Z=k();function Sn(e){let t=(0,X.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`path`,{d:`M15.688 2.343a2.588 2.588 0 00-3.61 0l-9.626 9.44a.863.863 0 01-1.203 0 .823.823 0 010-1.18l9.626-9.44a4.313 4.313 0 016.016 0 4.116 4.116 0 011.204 3.54 4.3 4.3 0 013.609 1.18l.05.05a4.115 4.115 0 010 5.9l-8.706 8.537a.274.274 0 000 .393l1.788 1.754a.823.823 0 010 1.18.863.863 0 01-1.203 0l-1.788-1.753a1.92 1.92 0 010-2.754l8.706-8.538a2.47 2.47 0 000-3.54l-.05-.049a2.588 2.588 0 00-3.607-.003l-7.172 7.034-.002.002-.098.097a.863.863 0 01-1.204 0 .823.823 0 010-1.18l7.273-7.133a2.47 2.47 0 00-.003-3.537z`}),r=(0,Z.jsx)(`path`,{d:`M14.485 4.703a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a4.115 4.115 0 000 5.9 4.314 4.314 0 006.016 0l7.12-6.982a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a2.588 2.588 0 01-3.61 0 2.47 2.47 0 010-3.54l7.12-6.982z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,Z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,fill:`currentColor`,stroke:`currentColor`,strokeWidth:`0.5`,fillRule:`evenodd`,viewBox:`-0.5 -0.5 25 25`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}var Cn={},wn=(e,t=n())=>JSON.stringify([t,Zt(e)]),Tn=(e,t,n)=>{if(!e[t]?.[n])return e;let r={...e[t]};return delete r[n],{...e,[t]:r}},En=e=>{let t=Zt(e);return t?j.getScopedApiClient(t):j.getApiClient()},Dn=e=>e?{location:{directory:e}}:void 0,On=e=>Zt(e===void 0?A.getState().currentDirectory:e),kn=w()(E((e,t)=>({diagnosticsByDirectory:{},getDiagnosticForDirectory:e=>{let n=wn(On(e));return t().diagnosticsByDirectory[n]??Cn},clearDiagnostic:(t,n,r)=>{let i=wn(On(n),r);e(e=>({diagnosticsByDirectory:Tn(e.diagnosticsByDirectory,i,t)}))},connect:async(t,r)=>{let a=On(r),o=n(),s=wn(a,o),c=En(a);try{await c.mcp.connect({server:t,...Dn(a)})}catch(n){let r=n instanceof Error?n.message:`Connection failed`;throw e(e=>({diagnosticsByDirectory:{...e.diagnosticsByDirectory,[s]:{...e.diagnosticsByDirectory[s]??{},[t]:{status:`failed`,error:r}}}})),n}await Qt(i,a,o),e(e=>({diagnosticsByDirectory:Tn(e.diagnosticsByDirectory,s,t)}))},disconnect:async(t,r)=>{let a=On(r),o=n(),s=wn(a,o);await En(a).mcp.disconnect({server:t,...Dn(a)}),await Qt(i,a,o),e(e=>({diagnosticsByDirectory:Tn(e.diagnosticsByDirectory,s,t)}))},startAuth:async(e,t)=>{throw M(`mcp.auth`)},completeAuth:async(e,t,n)=>{throw M(`mcp.auth`)},clearAuth:async(e,t)=>{throw M(`mcp.auth`)},testConnection:async(t,r)=>{let a=On(r),o=n(),s=wn(a,o),c=En(a),l=Xt(i,a,o)[t]?.status===`connected`,u,d;try{await c.mcp.connect({server:t,...Dn(a)})}catch(n){u=n instanceof Error?n.message:`Connection failed`,e(e=>({diagnosticsByDirectory:{...e.diagnosticsByDirectory,[s]:{...e.diagnosticsByDirectory[s]??{},[t]:{status:`failed`,error:u??`Connection failed`}}}}))}let f=(await Qt(i,a,o))[t],p=f;if(!l&&f?.status===`connected`){try{await c.mcp.disconnect({server:t,...Dn(a)})}catch(e){d=`Connection test succeeded, but cleanup disconnect failed: ${e instanceof Error?e.message:`Disconnect failed`}`}await Qt(i,a,o)}return u||e(e=>({diagnosticsByDirectory:Tn(e.diagnosticsByDirectory,s,t)})),{status:p??Xt(i,a,o)[t],error:u,warning:d}}}))),Q=e(D(),1),An=`https://yuri-updates.xiaobe.top/v1/update/check`,jn=`https://yuri-origin.xiaobe.top/v1/update/check`,Mn=`https://github.com/yee94/yuri/releases/latest`,Nn=`https://github.com/yee94/yuri/releases`,Pn=`https://testflight.apple.com/join/pN5SSHeg`,Fn=1e4;function In(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 Ln(e,t){let n=In(e),r=In(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 Rn(){return[An,jn]}function zn(e,t,n=Date.now){let r=e-n();return r<=0||t<=0?null:Math.max(1,Math.ceil(r/t))}function Bn(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 Vn(e,t,n,r){try{if(N())try{let{CapacitorHttp:r}=await ee(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 Hn(e,t){return e===`ios`?Pn:`${Nn}/download/v${t}/app-release.apk`}function Un(e,t,n){if(typeof e.latestVersion!=`string`||e.latestVersion.trim().length===0)return null;let r=e.latestVersion.trim(),i=Ln(r,t);if(i<0)return null;let a=typeof e.releaseNotesUrl==`string`&&e.releaseNotesUrl.trim().length>0?e.releaseNotesUrl.trim():`${Nn}/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():Hn(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 Wn(e,t,n,r){let i=await Vn(e,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify(Bn(t))},n,r);if(!i?.ok)return null;let a;try{a=await i.json()}catch{return null}return Un(a,t.currentVersion,t.platform)}async function Gn(e,t,n,r){let i=await Vn(Mn,{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:Mn,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=Ln(s,e),l=`${Nn}/tag/v${s}`;return{available:c>0,version:s,currentVersion:e,releaseUrl:l,downloadUrl:Hn(t,s)}}async function Kn(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=Rn(),a=r()+Fn;for(let[t,o]of i.entries()){let s=zn(a,i.length-t+1,r);if(s===null)break;let c=await Wn(o,e,s,n);if(c)return c}let o=zn(a,1,r);if(o!==null){let r=await Gn(t,e.platform,o,n);if(r)return r}return{available:!1,currentVersion:t,error:`Unable to check for mobile updates`}}function qn(){if(typeof window>`u`)return`unknown`;try{let{deviceType:e}=Wt();return e}catch{return`unknown`}}function Jn(){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 Yn(){let e=P();if(e===`android`||e===`ios`)return e;if(typeof navigator>`u`)return`web`;let t=(navigator.platform||``).toLowerCase();return t.includes(`mac`)?`macos`:t.includes(`win`)?`windows`:t.includes(`linux`)?`linux`:`web`}function Xn(e){let t=I.getState().reportUsage,n=new URLSearchParams({reportUsage:t?`true`:`false`});return n.set(`deviceClass`,qn()),n.set(`arch`,Jn()),n.set(`platform`,Yn()),e===`desktop`?(n.set(`appType`,`desktop-electron`),n.set(`instanceMode`,u()?`local`:`remote`),n):e===`vscode`?(n.set(`appType`,`vscode`),n.set(`instanceMode`,`local`),n):e===`mobile`?(n.set(`appType`,`mobile-capacitor`),n.set(`instanceMode`,`remote`),n):(n.set(`appType`,`web`),n.set(`instanceMode`,`unknown`),n)}async function Zn(e,t){let n=t??`unknown`;try{let r=Xn(e),i=typeof window<`u`?window.__VSCODE_CONFIG__?.extensionVersion:void 0;t?r.set(`currentVersion`,t):e===`vscode`&&i&&r.set(`currentVersion`,i);let a=await l(`/api/yuri/update-check?${r.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),o=null;try{o=await a.json()}catch{o=null}if(!a.ok)return{available:!1,currentVersion:n,error:typeof o?.error==`string`&&o.error.trim().length>0?o.error.trim():`Server responded with ${a.status}`};if(!o)return{available:!1,currentVersion:n,error:`Update check returned an invalid response`};let s=typeof o.error==`string`&&o.error.trim().length>0?o.error.trim():void 0;return{available:o.available===!0,version:typeof o.version==`string`?o.version:void 0,currentVersion:typeof o.currentVersion==`string`?o.currentVersion:n,body:typeof o.body==`string`?o.body:void 0,releaseUrl:typeof o.releaseUrl==`string`?o.releaseUrl:void 0,downloadUrl:typeof o.downloadUrl==`string`?o.downloadUrl:void 0,nextSuggestedCheckInSec:typeof o.nextSuggestedCheckInSec==`number`&&Number.isFinite(o.nextSuggestedCheckInSec)?o.nextSuggestedCheckInSec:void 0,packageManager:typeof o.packageManager==`string`?o.packageManager:void 0,updateCommand:typeof o.updateCommand==`string`?o.updateCommand:void 0,error:s}}catch(e){return console.warn(`Failed to check for updates:`,e),{available:!1,currentVersion:n,error:e instanceof Error?e.message:`Failed to check for updates`}}}function Qn(){return N()?`mobile`:x()?`desktop`:b()?`vscode`:v()?`web`:null}var $n={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 er(e,t){let n=e.isChannelRollback===!0?{isChannelRollback:!0}:{};return e.primaryAction===`apply_ota`&&e.ota.bundle?e.ota.bundle.releaseVersion===t?{available:!1,otaPhase:`idle`,info:{available:!1,currentVersion:t,nextSuggestedCheckInSec:e.nextCheckInSec,...n}}:{available:!0,otaPhase:`available`,info:{available:!0,version:e.ota.bundle.releaseVersion,currentVersion:t,downloadUrl:e.ota.bundle.url,nextSuggestedCheckInSec:e.nextCheckInSec,inAppApply:!0,...e.releaseNotes?{body:e.releaseNotes}:{},...n}}:e.primaryAction===`install_native_required`?{available:e.native.state===`required`||e.native.state===`available`,otaPhase:`idle`,info:{available:e.native.state===`required`||e.native.state===`available`,version:e.native.version,currentVersion:t,downloadUrl:e.native.installUrl,nextSuggestedCheckInSec:e.nextCheckInSec,manualUpdate:!0,...e.releaseNotes?{body:e.releaseNotes}:{},...n}}:{available:!1,otaPhase:`idle`,info:{available:!1,currentVersion:t,nextSuggestedCheckInSec:e.nextCheckInSec,...n}}}var tr=0,nr=w()((e,t)=>({...$n,checkForUpdates:async()=>{let n=Qn();if(!n)return null;let r=++tr;e({checking:!0,error:null,runtimeType:n});try{let i=null,a=null;if(n===`desktop`){let n=I.getState().otaChannelOverride;t().lastOtaChannelOverride!==n&&e({downloaded:!1,downloading:!1,available:!1,info:null,otaDecision:null,progress:null,otaPhase:`checking`});let i=await C(n);if(r!==tr||I.getState().otaChannelOverride!==n)return null;let a=i?.downloaded===!0;return e({checking:!1,available:i?.available??!1,downloaded:a,...a?{downloading:!1,progress:null}:{},info:i,error:null,lastChecked:Date.now(),nextCheckInSec:i?.nextSuggestedCheckInSec??null,otaDecision:i?.otaDecision??null,otaPhase:a?`pending_restart`:i?.inAppApply?`available`:`idle`,lastOtaChannelOverride:n}),i?.nextSuggestedCheckInSec??null}if(n===`web`)i=await Zn(`web`),a=i?.nextSuggestedCheckInSec??null;else if(n===`vscode`)a=(await Zn(`vscode`))?.nextSuggestedCheckInSec??null;else if(n===`mobile`){let n=await te()??`unknown`,r=N()?s()?.mobileUpdates:void 0,o=I.getState().otaChannelOverride;if(r)try{let i=t().lastOtaChannelOverride!==o;e(i?{otaDecision:null,otaPhase:`checking`,downloaded:!1,otaDownloadSkipped:!1,progress:null,available:!1,info:null}:{otaPhase:`checking`});let a=await r.checkForOtaUpdate(o===`beta`||o===`stable`?{channelOverride:o}:void 0),s=er(a,n),c=(i?void 0:t().otaDecision?.ota.bundle?.bundleId)!==a.ota.bundle?.bundleId,l=!i&&t().downloaded&&!c;return e({checking:!1,available:s.available,info:s.info,error:s.info.error??null,lastChecked:Date.now(),nextCheckInSec:a.nextCheckInSec,otaDecision:a,otaPhase:l?`pending_restart`:s.otaPhase,lastOtaChannelOverride:o,...c||i?{downloaded:!1,otaDownloadSkipped:!1,progress:null}:{}}),a.nextCheckInSec}catch(t){if(!(t instanceof ne)){let r=t instanceof Error?t.message:`Mobile OTA check failed`;return e({checking:!1,available:!1,info:{available:!1,currentVersion:n},error:r,lastChecked:Date.now(),otaDecision:null,otaPhase:`error`,lastOtaChannelOverride:o}),null}}return i=await Kn({currentVersion:n,platform:Yn()===`ios`?`ios`:`android`,deviceClass:qn(),arch:Jn(),reportUsage:I.getState().reportUsage}),a=i?.nextSuggestedCheckInSec??null,e({checking:!1,available:i?.available??!1,info:i,error:i?.error??null,lastChecked:Date.now(),nextCheckInSec:a,otaDecision:null,otaPhase:`idle`}),a}return e({checking:!1,available:n===`vscode`?!1:i?.available??!1,info:n===`vscode`?null:i,error:n===`vscode`?null:i?.error??null,lastChecked:Date.now(),nextCheckInSec:a}),a}catch(i){return r===tr&&e({checking:!1,error:i instanceof Error?i.message:`Failed to check for updates`,...n===`desktop`&&!t().downloaded?{otaPhase:`error`}:{}}),null}},downloadUpdate:async()=>{let{available:n,runtimeType:r,otaDecision:i,downloading:a,downloaded:o}=t();if(r===`mobile`&&i?.primaryAction===`apply_ota`&&i.ota.bundle){if(a||o)return;let t=s()?.mobileUpdates;if(!t){e({error:`Mobile OTA updates are unavailable in this runtime`,otaPhase:`error`});return}e({downloading:!0,error:null,progress:null,otaPhase:`downloading`,otaDownloadSkipped:!1});try{let{skipped:n}=await t.downloadOtaUpdate(i.ota.bundle);await t.queueOtaUpdateForNextLaunch(),e({downloading:!1,downloaded:!0,progress:null,otaPhase:`pending_restart`,otaDownloadSkipped:n})}catch(t){e({downloading:!1,error:t instanceof Error?t.message:`Failed to download update`,otaPhase:`error`})}return}if(!(r!==`desktop`||!n)){e({downloading:!0,error:null,progress:null});try{let n=I.getState().otaChannelOverride,r=await C(n);if(n!==I.getState().otaChannelOverride)throw Error(`OTA channel changed`);if(!r?.available||r.manualUpdate)throw Error(`Update detected, but desktop package is not ready yet. Retry in a moment.`);if(e(e=>({info:e.info?{...e.info,...r,body:r.body||e.info.body,available:e.info.available}:r})),r.downloaded||t().downloaded){e({downloading:!1,downloaded:!0,progress:null});return}if(r.downloading&&e({downloading:!0,progress:r.progress??{downloaded:0}}),!await d(t=>{e({progress:t})}))throw Error(`Failed to download update`);e({downloading:!1,downloaded:!0,progress:null,otaPhase:`pending_restart`})}catch(t){e({downloading:!1,error:t instanceof Error?t.message:`Failed to download update`})}}},subscribeDesktopUpdateEvents:async()=>{if(!x())return()=>{};let n=[],r=await f(n=>{let r=n.event,i=n.data??null;if(r===`Started`){if(!t().downloading)return;e({error:null,progress:{downloaded:0,total:typeof i?.contentLength==`number`?i.contentLength:void 0}});return}if(r===`Progress`){if(!t().downloading)return;e({progress:{downloaded:typeof i?.downloaded==`number`?i.downloaded:0,total:typeof i?.total==`number`?i.total:void 0}});return}r===`Finished`&&e({downloading:!1,downloaded:!0,progress:null})});r&&n.push(r);let i=await y(t=>{t.downloaded&&e({downloading:!1,downloaded:!0,available:!0,progress:null})});return i&&n.push(i),async()=>{for(let e of n)try{let t=e();t instanceof Promise&&await t}catch{}}},restartToUpdate:async()=>{let{downloaded:n,runtimeType:r,otaDecision:i}=t();if(r===`mobile`&&i?.primaryAction===`apply_ota`){if(!n)return;let t=s()?.mobileUpdates;if(!t){e({error:`Mobile OTA updates are unavailable in this runtime`,otaPhase:`error`});return}try{await t.applyOtaUpdateNow()}catch(t){e({error:t instanceof Error?t.message:`Failed to restart`,otaPhase:`error`})}return}if(!(r!==`desktop`||!n))try{if(!await g())throw Error(`Failed to restart`)}catch(t){e({error:t instanceof Error?t.message:`Failed to restart`})}},setOtaPhase:(t,n=null)=>{e({otaPhase:t,...n===void 0?{}:{error:n}})},setOtaDownloadPercent:n=>{if(!Number.isFinite(n)||n<0||n>100)return;let r=t();if(!r.downloading)return;let i=Math.round(n);if((r.progress?.total?Math.round(r.progress.downloaded/r.progress.total*100):null)===i)return;let a=r.otaDecision?.ota.bundle?.size;if(typeof a==`number`&&Number.isFinite(a)&&a>0){e({progress:{downloaded:Math.round(a*n/100),total:a}});return}e({progress:{downloaded:n,total:100}})},setOtaDownloadFailed:t=>{e({downloading:!1,downloaded:!1,error:t??`Failed to download update`,otaPhase:`error`})},dismiss:()=>{t().otaPhase!==`pending_restart`&&e({available:!1,downloaded:!1,info:null,otaDecision:null,otaPhase:`idle`,otaDownloadSkipped:!1})},reset:()=>{e($n)}})),rr=`https://github.com/yee94/yuri/releases`;function ir(e){let t=new Date(`${e}T00:00:00`);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(je(),{year:`numeric`,month:`short`,day:`numeric`}).format(t)}function ar(e){return e.replace(/^## \[[^\]]+\] - \d{4}-\d{2}-\d{2}\s*\n?/,``).trim()}function or(e){return e.replace(/(^|[^a-zA-Z0-9])@([a-zA-Z0-9-]+)/g,`$1[@$2](https://github.com/$2)`)}function sr(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 cr(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 lr=2e3,ur=6e5;async function dr(){try{let e=await l(`/api/yuri/update-install`,{method:`POST`,headers:{"Content-Type":`application/json`}});return e.ok?{success:!0,autoRestart:(await e.json().catch(()=>({}))).autoRestart!==!1}:{success:!1,error:(await e.json().catch(()=>({}))).error||`Server error: ${e.status}`}}catch(e){return{success:!1,error:e instanceof Error?e.message:void 0}}}async function fr(){try{return(await l(`/health`,{method:`GET`,headers:{Accept:`application/json`}})).ok}catch{return!1}}async function pr(e,t=Math.ceil(ur/lr),n=lr){for(let r=0;r<t;r++){try{let t=await l(`/api/yuri/update-check`,{method:`GET`,headers:{Accept:`application/json`}});if(t.ok){let n=await t.json().catch(()=>null);if(n&&n.available===!1||n&&typeof n.currentVersion==`string`&&typeof e==`string`&&n.currentVersion!==e)return!0}else if((t.status===401||t.status===403)&&await fr())return!0}catch{}await new Promise(e=>setTimeout(e,n))}return!1}var mr=({open:e,onOpenChange:t,info:n,downloading:r,downloaded:i,progress:a,error:o,onDownload:s,onRestart:c,runtimeType:l=`desktop`})=>{let{t:u}=G(),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(`idle`),[h,g]=(0,Q.useState)(null),_=nr(e=>e.otaDownloadSkipped),v=n?.releaseUrl||(n?.version?`${rr}/tag/v${n.version}`:rr),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=Oe(e=>{!e&&w&&i&&nr.getState().dismiss(),t(e)}),O=Oe(()=>{nr.getState().dismiss(),t(!1)});(0,Q.useEffect)(()=>{e||(m(`idle`),g(null))},[e]);let k=async()=>{(await Ae(E)).ok&&(f(!0),setTimeout(()=>f(!1),2e3))},A=(0,Q.useCallback)(async e=>{await Jt(e)},[]),j=(0,Q.useCallback)(async()=>{m(`updating`),g(null);let e=await dr();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 pr(n?.currentVersion)?window.location.reload():(m(`error`),g(u(`updateDialog.error.takingLonger`)))},[n?.currentVersion,u]),M=(0,Q.useCallback)(()=>{y&&A(y)},[A,y]),N=p!==`idle`&&p!==`error`,P=(0,Q.useMemo)(()=>{if(!n?.body)return null;let e=n.body.trim();if(!e)return null;let t=cr(e);if(t.length===0)return{kind:`raw`,title:u(`updateDialog.changelog.title`),content:or(e)};let r=[...t].sort((e,t)=>sr(e.version,t.version));return{kind:`sections`,title:u(`updateDialog.changelog.title`),sections:r.map(t=>({version:t.version,dateLabel:ir(t.date),content:or(ar(t.raw)||e)}))}},[n?.body,u]);return(0,Z.jsx)(Qe,{open:e,onOpenChange:N?void 0:D,children:(0,Z.jsxs)(Ye,{className:`max-w-4xl gap-0 p-4 sm:p-5 bg-background border-[var(--interactive-border)]`,showCloseButton:!0,children:[(0,Z.jsxs)(`div`,{className:`mb-3 pr-8 sm:mb-4`,children:[(0,Z.jsxs)(Xe,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Y,{name:`download-cloud`,className:`h-5 w-5 text-[var(--primary-base)]`}),(0,Z.jsx)(`span`,{className:`font-semibold text-foreground`,children:u(p===`restarting`||p===`reconnecting`?`updateDialog.header.updating`:`updateDialog.header.updateAvailable`)})]}),(n?.currentVersion||n?.version)&&(0,Z.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5 pl-7 font-mono text-[11px] leading-4 tracking-[-0.01em] tabular-nums sm:text-xs`,children:[n?.currentVersion&&(0,Z.jsx)(`span`,{className:`text-muted-foreground/75`,children:n.currentVersion}),n?.currentVersion&&n?.version&&(0,Z.jsx)(`span`,{className:`text-muted-foreground/40`,children:`→`}),n?.version&&(0,Z.jsx)(`span`,{className:`font-medium text-[var(--primary-base)]`,children:n.version})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[x&&N&&(0,Z.jsxs)(`div`,{className:`rounded-lg bg-[var(--surface-elevated)]/30 p-5 border border-[var(--surface-subtle)]`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(Y,{name:`loader`,className:`h-5 w-5 animate-spin text-[var(--primary-base)]`}),(0,Z.jsxs)(`div`,{className:`typography-ui-label text-foreground`,children:[p===`updating`&&u(`updateDialog.status.installingUpdate`),p===`restarting`&&u(`updateDialog.status.serverRestarting`),p===`reconnecting`&&u(`updateDialog.status.waitingForServer`)]})]}),(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:u(`updateDialog.status.autoReloadHint`)})]}),P&&!N&&(0,Z.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--surface-subtle)] px-3.5 py-2.5 sm:px-4 sm:py-3`,children:[(0,Z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--primary-base)]`,"aria-hidden":`true`}),(0,Z.jsx)(`h3`,{className:`typography-ui-caption font-medium text-muted-foreground`,children:P.title})]}),(0,Z.jsx)(Gt,{className:`max-h-[min(42dvh,22rem)] p-0 sm:max-h-[400px]`,fillContainer:!1,children:P.kind===`raw`?(0,Z.jsx)(`div`,{className:`break-words p-3.5 text-[13px] leading-[1.65] text-foreground sm:p-4 sm:text-sm [&_.markdown-content]:leading-[1.65] [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline`,onClickCapture:e=>{let t=e.target.closest(`a`);t&&t.href&&(e.preventDefault(),e.stopPropagation(),A(t.href))},children:(0,Z.jsx)(qt,{content:P.content,disableLinkSafety:!0,enableFileReferences:!1})}):(0,Z.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:P.sections.map(e=>(0,Z.jsxs)(`div`,{className:`p-3.5 sm:p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-center gap-x-2 gap-y-1 sm:mb-3`,children:[(0,Z.jsxs)(`span`,{className:`rounded-md bg-[var(--primary-base)]/10 px-1.5 py-0.5 font-mono text-[11px] font-medium leading-4 text-[var(--primary-base)] tabular-nums sm:text-xs`,children:[`v`,e.version]}),(0,Z.jsx)(`span`,{className:`text-[11px] leading-4 text-muted-foreground/75 sm:text-xs`,children:e.dateLabel})]}),(0,Z.jsx)(`div`,{className:`break-words text-[13px] leading-[1.65] text-foreground sm:text-sm [&_.markdown-content]:leading-[1.65] [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline`,onClickCapture:e=>{let t=e.target.closest(`a`);t&&t.href&&(e.preventDefault(),e.stopPropagation(),A(t.href))},children:(0,Z.jsx)(qt,{content:e.content,disableLinkSafety:!0,enableFileReferences:!1})})]},e.version))})})]}),x&&p===`error`&&(0,Z.jsxs)(`div`,{className:`space-y-2 mt-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 typography-meta text-muted-foreground`,children:[(0,Z.jsx)(Y,{name:`terminal`,className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:u(`updateDialog.fallback.updateViaTerminal`)})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 p-1 pl-3 bg-[var(--surface-elevated)]/50 rounded-md border border-[var(--surface-subtle)]`,children:[(0,Z.jsx)(`code`,{className:`flex-1 font-mono text-sm text-foreground overflow-x-auto whitespace-nowrap`,children:E}),(0,Z.jsx)(`button`,{onClick:k,className:K(`flex items-center justify-center p-2 rounded`,`text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]`,`transition-colors`,d&&`text-[var(--status-success)]`),title:u(d?`updateDialog.actions.copied`:`updateDialog.actions.copyCommand`),children:d?(0,Z.jsx)(Y,{name:`check`,className:`h-4 w-4`}):(0,Z.jsx)(Y,{name:`clipboard`,className:`h-4 w-4`})})]})]}),!x&&(!S||w)&&r&&(0,Z.jsxs)(`div`,{className:`mt-3 space-y-2 rounded-lg border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20 px-3.5 py-3 sm:mt-4 sm:px-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground sm:text-[13px]`,children:u(`updateDialog.status.downloadingPayload`)}),(0,Z.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] leading-4 text-foreground tabular-nums sm:text-xs`,children:[b,`%`]})]}),(0,Z.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-[var(--surface-subtle)] sm:h-1.5`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-[var(--primary-base)] transition-all duration-300`,style:{width:`${b}%`}})})]}),(o||h)&&(0,Z.jsx)(`div`,{className:`p-3 mt-4 bg-[var(--status-error-background)] border border-[var(--status-error-border)] rounded-lg`,children:(0,Z.jsx)(`p`,{className:`text-sm text-[var(--status-error)]`,children:o||h})})]}),w&&i&&_&&(0,Z.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg border border-[var(--status-success-border)] bg-[var(--status-success-background)] px-3 py-2.5 text-sm text-[var(--status-success)]`,children:[(0,Z.jsx)(Y,{name:`check`,className:`h-4 w-4 shrink-0`}),(0,Z.jsx)(`span`,{children:u(`updateDialog.status.otaBundleReused`)})]}),(0,Z.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-4`,children:[!S||C?(0,Z.jsxs)(`a`,{href:S?y:v,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground hover:text-foreground transition-colors shrink-0`,children:[(0,Z.jsx)(Y,{name:`external-link`,className:`h-4 w-4`}),`GitHub`]}):(0,Z.jsx)(`span`,{}),(0,Z.jsxs)(`div`,{className:`flex-1 flex justify-end`,children:[!x&&(!S||w)&&!T&&!i&&!r&&(0,Z.jsxs)(q,{onClick:s,size:`default`,children:[(0,Z.jsx)(Y,{name:`download`,className:`h-4 w-4`}),u(w?`updateDialog.actions.applyOtaNow`:`updateDialog.actions.downloadUpdate`)]}),!x&&!S&&T&&!i&&!r&&(0,Z.jsxs)(q,{onClick:()=>void A(v),size:`default`,children:[(0,Z.jsx)(Y,{name:`external-link`,className:`h-4 w-4`}),u(`updateDialog.actions.openMobileUpdate`)]}),!x&&(!S||w)&&r&&(0,Z.jsxs)(q,{disabled:!0,size:`default`,children:[(0,Z.jsx)(Y,{name:`loader`,className:`h-4 w-4 animate-spin`}),u(`updateDialog.status.downloading`)]}),!x&&(!S||w)&&i&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[w&&(0,Z.jsx)(q,{onClick:O,variant:`ghost`,size:`default`,children:u(`updateDialog.actions.later`)}),(0,Z.jsxs)(q,{onClick:c,size:`default`,children:[(0,Z.jsx)(Y,{name:`restart`,className:`h-4 w-4`}),u(`updateDialog.actions.restartToUpdate`)]})]}),S&&!w&&C&&(0,Z.jsxs)(q,{onClick:M,size:`default`,children:[(0,Z.jsx)(Y,{name:`external-link`,className:`h-4 w-4`}),u(`updateDialog.actions.openMobileUpdate`)]}),x&&!N&&(0,Z.jsxs)(q,{onClick:j,size:`default`,children:[(0,Z.jsx)(Y,{name:`download`,className:`h-4 w-4`}),u(`updateDialog.actions.updateNow`)]}),x&&N&&(0,Z.jsxs)(q,{disabled:!0,size:`default`,children:[(0,Z.jsx)(Y,{name:`loader`,className:`h-4 w-4 animate-spin`}),u(`updateDialog.status.updating`)]})]})]})]})})},hr=e(O(),1);function gr(e){let t=(0,X.c)(20),{label:n,children:r,description:i,itemId:a,ariaLabel:o,className:s,cardClassName:c,cardId:l}=e,u=typeof n==`string`&&/^[\p{Script=Latin}\p{Number}\p{Punctuation}\p{Separator}]+$/u.test(n)?`latin`:void 0,d;t[0]===s?d=t[1]:(d=K(`yuri-settings-group`,s),t[0]=s,t[1]=d);let f;t[2]!==n||t[3]!==u?(f=n?(0,Z.jsx)(`div`,{className:`yuri-settings-group-label`,"data-settings-label-script":u,children:n}):null,t[2]=n,t[3]=u,t[4]=f):f=t[4];let p;t[5]===c?p=t[6]:(p=K(`yuri-settings-group-card`,c),t[5]=c,t[6]=p);let m;t[7]!==l||t[8]!==r||t[9]!==a||t[10]!==p?(m=(0,Z.jsx)(`div`,{id:l,"data-settings-item":a,className:p,children:r}),t[7]=l,t[8]=r,t[9]=a,t[10]=p,t[11]=m):m=t[11];let h;t[12]===i?h=t[13]:(h=i?(0,Z.jsx)(`p`,{className:`yuri-settings-group-description text-muted-foreground`,children:i}):null,t[12]=i,t[13]=h);let g;return t[14]!==o||t[15]!==d||t[16]!==f||t[17]!==m||t[18]!==h?(g=(0,Z.jsxs)(`section`,{className:d,"aria-label":o,children:[f,m,h]}),t[14]=o,t[15]=d,t[16]=f,t[17]=m,t[18]=h,t[19]=g):g=t[19],g}function _r(e){let t=(0,X.c)(20),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({label:s,description:a,descriptionPlacement:l,ariaLabel:n,groupClassName:o,cardClassName:r,children:i,...c}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u=l===void 0?`inside`:l,d=u===`outside`?a:void 0,f=u===`inside`?a:void 0,p;t[9]!==i||t[10]!==s||t[11]!==c||t[12]!==f?(p=(0,Z.jsx)(vr,{label:s,description:f,...c,children:i}),t[9]=i,t[10]=s,t[11]=c,t[12]=f,t[13]=p):p=t[13];let m;return t[14]!==n||t[15]!==r||t[16]!==o||t[17]!==d||t[18]!==p?(m=(0,Z.jsx)(gr,{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 vr(e){let t=(0,X.c)(22),{label:n,children:r,description:i,itemId:a,className:o,copyClassName:s,controlClassName:c}=e,l;t[0]===o?l=t[1]:(l=K(`yuri-settings-group-row yuri-settings-split-row`,o),t[0]=o,t[1]=l);let u;t[2]===s?u=t[3]:(u=K(`yuri-settings-split-row-copy`,s),t[2]=s,t[3]=u);let d;t[4]===n?d=t[5]:(d=n?(0,Z.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:n}):null,t[4]=n,t[5]=d);let f;t[6]===i?f=t[7]:(f=i?(0,Z.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:i}):null,t[6]=i,t[7]=f);let p;t[8]!==u||t[9]!==d||t[10]!==f?(p=(0,Z.jsxs)(`div`,{className:u,children:[d,f]}),t[8]=u,t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===c?m=t[13]:(m=K(`yuri-settings-split-row-control`,c),t[12]=c,t[13]=m);let h;t[14]!==r||t[15]!==m?(h=(0,Z.jsx)(`div`,{"data-settings-value":``,className:m,children:r}),t[14]=r,t[15]=m,t[16]=h):h=t[16];let g;return t[17]!==a||t[18]!==l||t[19]!==p||t[20]!==h?(g=(0,Z.jsxs)(`div`,{"data-settings-item":a,className:l,children:[p,h]}),t[17]=a,t[18]=l,t[19]=p,t[20]=h,t[21]=g):g=t[21],g}function yr(e){let t=(0,X.c)(32),{checked:n,onChange:r,label:i,ariaLabel:a,description:o,itemId:s,disabled:c,className:l}=e,u=c!==void 0&&c,d;t[0]!==n||t[1]!==u||t[2]!==r?(d=()=>{u||r(!n)},t[0]=n,t[1]=u,t[2]=r,t[3]=d):d=t[3];let f=d,p=br,m=u?`cursor-not-allowed`:`cursor-pointer`,h;t[4]!==l||t[5]!==m?(h=K(`yuri-settings-group-row yuri-settings-split-row group`,m,l),t[4]=l,t[5]=m,t[6]=h):h=t[6];let g=u?-1:0,_=u||void 0,v,y;t[7]===f?(v=t[8],y=t[9]):(v=e=>{p(e.target)||f()},y=e=>{p(e.target)||(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),f())},t[7]=f,t[8]=v,t[9]=y);let b;t[10]===i?b=t[11]:(b=(0,Z.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i}),t[10]=i,t[11]=b);let x;t[12]===o?x=t[13]:(x=o?(0,Z.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:o}):null,t[12]=o,t[13]=x);let S;t[14]!==x||t[15]!==b?(S=(0,Z.jsxs)(`div`,{className:`yuri-settings-split-row-copy`,children:[b,x]}),t[14]=x,t[15]=b,t[16]=S):S=t[16];let C;t[17]!==a||t[18]!==n||t[19]!==u||t[20]!==r?(C=(0,Z.jsx)(`div`,{"data-settings-value":``,className:`yuri-settings-split-row-control`,children:(0,Z.jsx)(ot,{checked:n,onChange:r,disabled:u,ariaLabel:a})}),t[17]=a,t[18]=n,t[19]=u,t[20]=r,t[21]=C):C=t[21];let w;return t[22]!==n||t[23]!==s||t[24]!==S||t[25]!==C||t[26]!==h||t[27]!==g||t[28]!==_||t[29]!==v||t[30]!==y?(w=(0,Z.jsxs)(`div`,{"data-settings-item":s,className:h,role:`button`,tabIndex:g,"aria-pressed":n,"aria-disabled":_,onClick:v,onKeyDown:y,children:[S,C]}),t[22]=n,t[23]=s,t[24]=S,t[25]=C,t[26]=h,t[27]=g,t[28]=_,t[29]=v,t[30]=y,t[31]=w):w=t[31],w}function br(e){return e instanceof HTMLElement&&e.closest(`button, a, input, select, textarea`)!==null}var xr=`/mcp/oauth/callback`,Sr=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}},Cr=e=>{let t=Tr(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}},wr=e=>{let t=e.get(`state`);return typeof t==`string`&&t.trim()||null},Tr=e=>{if(typeof e!=`string`||!e.trim())return null;let t=Sr(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}},Er=e=>typeof e==`object`&&!!e&&`updateStatus`in e&&typeof e.updateStatus==`function`,Dr=e=>{let t=document.createElement(`div`);t.className=`cm-vim-panel`;let n=mn(e);if(!n)return{top:!1,dom:t};n.state.statusbar=t;let r=n.state.vimPlugin;return Er(r)&&r.updateStatus(),{top:!1,dom:t,destroy(){n.state.statusbar===t&&(n.state.statusbar=null)}}};function Or(e){return e?[pn(),re.of(Dr),ae()]:[]}var kr={next:`Next match`,prev:`Previous match`,select:`Select all matches`,replace:`Replace`,replaceAll:`Replace all`,close:`Close`},Ar={case:`Match case`,re:`Regular expression`,word:`Match whole word`};function jr(e){let t=e.querySelector(`.cm-search`);if(t){for(let[e,n]of Object.entries(kr)){let r=t.querySelector(`button[name="${e}"]`);r&&!r.title&&(r.title=n)}for(let[e,n]of Object.entries(Ar)){let r=t.querySelector(`input[name="${e}"]`)?.parentElement;r&&!r.title&&(r.title=n)}}}var Mr=new WeakMap;function Nr(e,t){let n=ln(e.state);if(!n.valid)return Mr.delete(e),0;let r=Mr.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 Mr.set(e,{query:n,doc:e.state.doc,total:a}),a}function Pr(e){let t=ln(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 Fr(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=Nr(t,n),o=a===0?0:Pr(t);i.textContent=a===0?``:`${o}/${a}`}var Ir=new H,Lr=new H,Rr=new H,zr=new H,Br=new H,Vr=new H,Hr=new H,Ur=e=>e,Wr=ce,Gr=sn,Kr=dn,qr=class extends ue{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(){}},Jr=(e,t)=>!e||e.length===0?[]:ye.define({create(n){let r=new me,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,z.widget({widget:new qr(e.id,t),block:!0,side:1}))}return r.finish()},update(e,t){return e.map(t.changes)},provide:e=>B.decorations.from(e)}),Yr=e=>{if(!e)return[];let t=Math.max(1,e.start),n=Math.max(t,e.end);return le.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 me;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,z.line({class:`yuri-cm-selected-line`}))}return r.finish()}},{decorations:e=>e.decorations})};function Xr({value:e,onChange:t,extensions:n,className:r,readOnly:i,lineNumbersConfig:a,highlightLines:o,onViewReady:s,onViewDestroy:c,blockWidgets:l,enableSearch:u,searchOpen:d,onSearchOpenChange:f,vimMode:p}){let m=Q.useRef(null),h=Q.useRef(null),g=Q.useRef(e),_=Q.useRef(t),v=Q.useRef(s),y=Q.useRef(c),b=Q.useRef(f),x=Q.useRef(l),S=Q.useRef(p),C=Q.useRef(new Map),[w,T]=Q.useState([]),E=Q.useCallback(e=>{let t=(e??[]).map(e=>{let t=C.current.get(e.id);return t?{id:e.id,content:e.content,container:t}:null}).filter(e=>e!==null);T(e=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return e.id===r.id&&e.content===r.content&&e.container===r.container})?e:t)},[]),D=Q.useCallback(e=>{let t=m.current,n=e??h.current;if(!t||!n)return;let r=n.dom.querySelector(`.cm-gutters`),i=r instanceof HTMLElement?r.getBoundingClientRect().width:0;t.style.setProperty(`--yuri-editor-gutter-width`,`${i}px`)},[]);return Q.useEffect(()=>{g.current=e},[e]),Q.useEffect(()=>{_.current=t},[t]),Q.useEffect(()=>{v.current=s,y.current=c},[s,c]),Q.useEffect(()=>{b.current=f},[f]),Q.useEffect(()=>{x.current=l,E(l)},[l,E]),Q.useEffect(()=>{if(!m.current)return;let e=(()=>{if(typeof document>`u`)return null;let e=document.querySelector(`meta[name="csp-nonce"]`)?.getAttribute(`content`);if(e)return e;let t=window.__YURI_CSP_NONCE__;return typeof t==`string`&&t.length>0?t:null})(),t=be.create({doc:g.current,extensions:[...e?[B.cspNonce.of(e)]:[],oe({fixed:!0}),Ir.of(de(a)),an(),ie.of(` `),Hr.of(Or(p)),fe.of([rn,...nn,...on]),B.updateListener.of(e=>{D(e.view),(e.viewportChanged||e.geometryChanged)&&E(x.current);let t=cn(e.startState),n=cn(e.state);t!==n&&b.current?.(n);let r=!ln(e.startState).eq(ln(e.state));if(n&&(t!==n||r||e.docChanged||e.selectionSet)&&Fr(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)}),Lr.of(B.editable.of(!i)),Rr.of(n??[]),zr.of(Yr(o)),Br.of(Jr(l,C.current)),Vr.of(u?[un({top:!0}),fe.of(Ur(fn))]:[])]});return h.current=new B({state:t,parent:m.current}),Wr(h.current,h.current.state.doc.length,200),h.current.requestMeasure(),requestAnimationFrame(()=>{D(h.current),E(x.current)}),h.current&&v.current?.(h.current),()=>{y.current?.(),h.current?.destroy(),h.current=null,T([])}},[x,D,E]),Q.useEffect(()=>{let e=h.current;e&&(e.dispatch({effects:[Ir.reconfigure(de(a)),Lr.reconfigure(B.editable.of(!i)),Rr.reconfigure(n??[]),zr.reconfigure(Yr(o)),Br.reconfigure(Jr(l,C.current)),Vr.reconfigure(u?[un({top:!0}),fe.of(Ur(fn))]:[])]}),Wr(e,e.state.doc.length,200),e.requestMeasure(),requestAnimationFrame(()=>{D(e),E(x.current)}))},[n,o,a,i,l,u,D,E]),Q.useEffect(()=>{let e=h.current;if(!e){S.current=p;return}S.current!==p&&(S.current=p,e.dispatch({effects:Hr.reconfigure(Or(p))}))},[p]),Q.useEffect(()=>{let e=h.current;!e||u===!1||(d?(Gr(e),requestAnimationFrame(()=>{jr(e.dom),Fr(e.dom,e,!0)})):Kr(e))},[d,u]),Q.useEffect(()=>{let t=h.current;if(!t)return;let n=t.state.doc.toString();n!==e&&(t.dispatch({changes:{from:0,to:n.length,insert:e}}),Wr(t,t.state.doc.length,300),t.requestMeasure(),requestAnimationFrame(()=>D(t)))},[e,D]),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{ref:m,className:K(`h-full w-full`,`[&_.cm-editor]:h-full [&_.cm-editor]:w-full`,`[&_.cm-scroller]:font-mono [&_.cm-scroller]:text-[var(--text-code)] [&_.cm-scroller]:leading-6`,`[&_.cm-lineNumbers]:text-[var(--tools-edit-line-number)]`,r)}),w.map(e=>(0,hr.createPortal)(e.content,e.container,e.id))]})}var Zr=he.define(De),Qr=we.data.of({commentTokens:{line:`//`,block:{open:`/*`,close:`*/`}}});function $r(e){let t=e.trim().toLowerCase();switch(t){case`bash`:case`sh`:case`zsh`:case`shell`:case`shellsession`:case`console`:return Zr;case`json`:case`jsonc`:case`json5`:return Ce().language;case`js`:case`javascript`:return W().language;case`jsx`:return W({jsx:!0}).language;case`ts`:case`typescript`:return W({typescript:!0}).language;case`tsx`:return W({typescript:!0,jsx:!0}).language;case`html`:return Se().language;case`css`:return xe().language;case`py`:case`python`:return Ee().language;case`md`:case`markdown`:case`mdown`:case`mkd`:return Te().language;case`heex`:case`eex`:case`leex`:return Se().language;default:return ve.matchLanguageName(hn,t,!0)}}var ei=e=>e.split(`/`).pop()?.toLowerCase()??``,ti=e=>{let t=ei(e);return t?ve.matchFilename(hn,t):null},ni=()=>V(pe.define([{tag:[U.heading1,U.heading2,U.heading3,U.heading4,U.heading5,U.heading6],fontWeight:`600`},{tag:U.strong,fontWeight:`600`},{tag:U.emphasis,fontStyle:`italic`},{tag:U.strikethrough,textDecoration:`line-through`},{tag:[U.link,U.url],color:`var(--markdown-link, currentColor)`,textDecoration:`underline`},{tag:U.monospace,color:`var(--markdown-inline-code, currentColor)`,backgroundColor:`var(--markdown-inline-code-bg, transparent)`},{tag:U.quote,color:`var(--markdown-blockquote, currentColor)`,fontStyle:`italic`},{tag:U.list,color:`color-mix(in srgb, var(--muted-foreground) 40%, var(--foreground) 60%)`},{tag:U.heading,color:`var(--markdown-heading1, currentColor)`}]));function ri(e){let t=e.toLowerCase();switch(ei(t)){case`makefile`:case`gnumakefile`:return Zr}let n=t.lastIndexOf(`.`),r=n>=0?t.slice(n+1):``;switch(r){case`ts`:case`tsx`:case`mts`:case`cts`:return W({typescript:!0,jsx:r===`tsx`});case`js`:case`jsx`:case`mjs`:case`cjs`:return W({typescript:!1,jsx:r===`jsx`});case`jsonc`:case`json5`:return[Ce(),Qr];case`json`:case`jsonl`:case`ndjson`:case`geojson`:return Ce();case`css`:case`scss`:case`sass`:case`less`:return xe();case`html`:case`htm`:case`xml`:case`drawio`:case`dio`:return Se();case`md`:case`mdx`:case`markdown`:case`mdown`:case`mkd`:return[Te({codeLanguages:$r}),ni()];case`sh`:case`bash`:case`zsh`:case`fish`:case`env`:return Zr;case`py`:case`pyw`:case`pyi`:return Ee();default:return null}}async function ii(e){let t=ti(e);if(!t)return null;if(t.support)return t.support;try{return await t.load()}catch{return null}}function ai(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=B.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=pe.define([{tag:[U.comment,U.docComment,U.meta,U.documentMeta],class:`cm-comment`},{tag:[U.keyword,U.controlKeyword,U.moduleKeyword,U.definitionKeyword,U.modifier],class:`cm-keyword`},{tag:[U.operatorKeyword,U.operator,U.derefOperator,U.updateOperator,U.definitionOperator,U.typeOperator,U.controlOperator,U.logicOperator,U.bitwiseOperator,U.arithmeticOperator,U.compareOperator],class:`cm-operator`},{tag:[U.punctuation,U.separator,U.bracket,U.paren,U.brace,U.squareBracket,U.angleBracket],class:`cm-punctuation`},{tag:[U.string,U.regexp,U.attributeValue,U.special(U.string),U.monospace],class:`cm-string`},{tag:U.escape,class:`cm-string-2`},{tag:[U.number,U.bool,U.atom,U.null,U.self],class:`cm-number`},{tag:[U.function(U.variableName),U.function(U.definition(U.variableName)),U.function(U.propertyName),U.standard(U.variableName),U.special(U.variableName)],class:`cm-builtin`},{tag:U.definition(U.variableName),class:`cm-def`},{tag:[U.variableName,U.local(U.variableName),U.constant(U.variableName),U.literal],class:`cm-variable`},{tag:U.propertyName,class:`cm-property`},{tag:U.attributeName,class:`cm-attribute`},{tag:[U.className,U.typeName,U.namespace],class:`cm-variable-3`},{tag:[U.tagName,U.labelName,U.annotation,U.macroName],class:`cm-tag`},{tag:U.link,class:`cm-link`},{tag:[U.heading,U.heading1,U.heading2,U.heading3,U.heading4,U.heading5,U.heading6],class:`cm-keyword`}]),l=pe.define([{tag:[U.comment,U.docComment,U.meta,U.documentMeta],color:e.colors.syntax.base.comment},{tag:[U.keyword,U.controlKeyword,U.moduleKeyword,U.definitionKeyword,U.modifier],color:e.colors.syntax.base.keyword},{tag:[U.operatorKeyword,U.operator,U.derefOperator,U.updateOperator,U.definitionOperator,U.typeOperator,U.controlOperator,U.logicOperator,U.bitwiseOperator,U.arithmeticOperator,U.compareOperator],color:e.colors.syntax.base.operator},{tag:[U.string,U.regexp,U.attributeValue,U.special(U.string),U.monospace],color:e.colors.syntax.base.string},{tag:U.escape,color:a.stringEscape||e.colors.syntax.base.string},{tag:[U.number,U.bool,U.atom,U.null,U.self],color:e.colors.syntax.base.number},{tag:[U.function(U.variableName),U.function(U.definition(U.variableName)),U.function(U.propertyName),U.standard(U.variableName),U.special(U.variableName)],color:e.colors.syntax.base.function},{tag:U.definition(U.variableName),color:a.variableGlobal||e.colors.syntax.base.variable},{tag:[U.variableName,U.local(U.variableName),U.constant(U.variableName),U.literal],color:e.colors.syntax.base.variable},{tag:U.propertyName,color:a.variableProperty||e.colors.syntax.base.variable},{tag:U.attributeName,color:a.variableOther||e.colors.syntax.base.variable},{tag:[U.className,U.typeName,U.namespace],color:e.colors.syntax.base.type},{tag:[U.tagName,U.labelName,U.annotation,U.macroName],color:a.tag||e.colors.syntax.base.keyword},{tag:U.link,color:a.url||e.colors.syntax.base.function,textDecoration:`underline`},{tag:[U.punctuation,U.separator,U.bracket,U.paren,U.brace,U.squareBracket,U.angleBracket],color:a.punctuation||e.colors.syntax.base.comment}]);return t?.syntaxColors===!1?[s]:[s,V(_e,{fallback:!0}),V(se),V(c),V(l)]}var oi=180,si=ge.define(),ci=1,li=2,ui=4,di=new Map,fi=(e,t)=>{let n=`${e}|${t}`,r=di.get(n);if(r)return r;let i=``;e&&(i+=`color:${e};`),t&ci&&(i+=`font-style:italic;`),t&li&&(i+=`font-weight:bold;`),t&ui&&(i+=`text-decoration:underline;`);let a=z.mark({attributes:{style:i}});return di.set(n,a),a},pi=(e,t)=>{let n=new me,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,fi(t,r)))}}return n.finish()},mi=ye.define({create(){return z.none},update(e,t){let n=e.map(t.changes);for(let e of t.effects)e.is(si)&&(n=e.value);return n},provide:e=>B.decorations.from(e)}),hi=e=>le.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)},oi)}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 Yt(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:si.of(pi(t,a))}))}destroy(){this.timer&&clearTimeout(this.timer),this.abortController?.abort(),this.abortController=void 0}}),gi=e=>[mi,hi(e)],_i=e=>{let t=(0,X.c)(11),{currentMode:n,onToggle:r}=e,i=n===`preview`,a=i?`Switch to edit mode`:`Switch to preview mode`,o=i?`Edit`:`Preview`,s;t[0]===i?s=t[1]:(s=i?(0,Z.jsx)(Y,{name:`eye`,className:`size-4`,"aria-hidden":`true`}):(0,Z.jsx)(Y,{name:`eye-off`,className:`size-4`,"aria-hidden":`true`}),t[0]=i,t[1]=s);let c;t[2]!==a||t[3]!==r||t[4]!==s?(c=(0,Z.jsx)(vt,{asChild:!0,children:(0,Z.jsx)(q,{variant:`ghost`,size:`sm`,onClick:r,"aria-label":a,className:`h-5 w-5 p-0`,children:s})}),t[2]=a,t[3]=r,t[4]=s,t[5]=c):c=t[5];let l;t[6]===o?l=t[7]:(l=(0,Z.jsx)(yt,{sideOffset:8,children:o}),t[6]=o,t[7]=l);let u;return t[8]!==c||t[9]!==l?(u=(0,Z.jsxs)(bt,{children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10],u},vi=w()(E(T((e,t)=>({selectedProfileId:null,defaultGitIdentityId:null,profiles:[],globalIdentity:null,discoveredCredentials:[],isLoading:!1,setSelectedProfile:t=>{e({selectedProfileId:t})},loadProfiles:async()=>{e({isLoading:!0});let n=t().profiles;try{return e({profiles:await et(),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 tt();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 at()}),!0}catch(t){return console.error(`Failed to discover git credentials:`,t),e({discoveredCredentials:[]}),!1}},loadDefaultGitIdentityId:async()=>{let t=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null};try{let n=null;if(n===null){let e=s()?.settings;if(e)try{n=t(((await e.load())?.settings||{}).defaultGitIdentityId)}catch{}}if(n===null)try{let e=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});e.ok&&(n=t((await e.json().catch(()=>null))?.defaultGitIdentityId))}catch{}return e({defaultGitIdentityId:n}),!0}catch(e){return console.error(`Failed to load default git identity setting:`,e),!1}},setDefaultGitIdentityId:async t=>{try{let n=typeof t==`string`?t.trim():``,r=n.length>0?n:``;return await _({defaultGitIdentityId:r}),e({defaultGitIdentityId:r.length>0?r:null}),!0}catch(e){return console.error(`Failed to save default git identity setting:`,e),!1}},createProfile:async e=>{try{let n={...e,id:e.id||`profile-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,color:e.color||`keyword`,icon:e.icon||`branch`};return await it(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 $e(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 nt(n),t().selectedProfileId===n&&e({selectedProfileId:null}),await t().loadProfiles(),!0}catch(e){return console.error(`Failed to delete git identity profile:`,e),!1}},getProfileById:e=>{let{profiles:n,globalIdentity:r}=t();return e===`global`?r||void 0:n.find(t=>t.id===e)},getUnimportedCredentials:()=>{let{profiles:e,discoveredCredentials:n}=t();return n.filter(t=>!e.some(e=>e.authType===`token`&&e.host===t.host))}}),{name:`git-identities-store`,storage:F(),partialize:e=>({selectedProfileId:e.selectedProfileId})}),{name:`git-identities-store`}));typeof window<`u`&&(window.__zustand_git_identities_store__=vi);var yi=`w-full max-w-[30rem]`,bi=e=>{let t=(0,X.c)(23),{title:n,description:r,settingsItem:i,titleAccessory:a,headerAction:o,children:s,className:c,contentClassName:l}=e,u;t[0]===n?u=t[1]:(u=(0,Z.jsx)(`span`,{className:`truncate`,children:n}),t[0]=n,t[1]=u);let d;t[2]!==u||t[3]!==a?(d=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[u,a]}),t[2]=u,t[3]=a,t[4]=d):d=t[4];let f;t[5]===o?f=t[6]:(f=o?(0,Z.jsx)(`div`,{className:`shrink-0`,children:o}):null,t[5]=o,t[6]=f);let p;t[7]!==d||t[8]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[d,f]}),t[7]=d,t[8]=f,t[9]=p):p=t[9];let m;t[10]===l?m=t[11]:(m=K(`yuri-settings-group-row`,l),t[10]=l,t[11]=m);let h;t[12]!==s||t[13]!==m?(h=(0,Z.jsx)(`div`,{className:m,children:s}),t[12]=s,t[13]=m,t[14]=h):h=t[14];let g;t[15]!==r||t[16]!==p||t[17]!==h?(g=(0,Z.jsx)(gr,{className:`yuri-settings-detail-group`,label:p,description:r,children:h}),t[15]=r,t[16]=p,t[17]=h,t[18]=g):g=t[18];let _;return t[19]!==c||t[20]!==i||t[21]!==g?(_=(0,Z.jsx)(`div`,{"data-settings-item":i,className:c,children:g}),t[19]=c,t[20]=i,t[21]=g,t[22]=_):_=t[22],_},xi=450,Si=({projectRef:e=null})=>{let{t}=G(),{isMobile:n,isTablet:r}=Ut(),i=n||r,a=Ie(e=>e.getActiveProject()),o=e?.path??a?.path??null,s=Pe(e=>e.getWorktreeMetadata),c=Ge(),l=A(e=>e.homeDirectory),[u,d]=Q.useState([]),[f,p]=Q.useState(!1),[m,h]=Q.useState(!1),[g,_]=Q.useState(null),[v,y]=Q.useState(null),[b,x]=Q.useState([]),[S,C]=Q.useState(!1),w=Q.useRef(!1),T=Q.useMemo(()=>e?.id&&e?.path?{id:e.id,path:e.path}:!a?.id||!o?null:{id:a.id,path:o},[a?.id,o,e?.id,e?.path]),E=Q.useCallback(async()=>{if(!(!T||v===!1))try{let e=await ut(T);x(e)}catch{}},[T,v]);Q.useEffect(()=>{if(!o)return;let e=!1;return y(null),(async()=>{try{let t=await rt(o);if(e)return;y(t)}catch{}})(),()=>{e=!0}},[o]),Q.useEffect(()=>{if(!T){x([]),C(!1);return}if(v===!1){x([]),C(!1);return}let e=!1;return C(!0),x([]),(async()=>{try{let t=await ut(T);if(e)return;x(t)}catch{}finally{e||C(!1)}})(),()=>{e=!0}},[T,v]),Q.useEffect(()=>{if(!T)return;let e=!1;return h(!0),(async()=>{try{let[t,n]=await Promise.all([Be(T),He(T)]);if(!e){let e=t.length>0?t:[``];d(e),_(JSON.stringify(e)),p(n)}}catch{e||(d([``]),_(JSON.stringify([``])),p(!1))}finally{e||h(!1)}})(),()=>{e=!0}},[T]);let D=Q.useCallback(async e=>{if(!T)return!1;let n=e.filter(e=>e.trim().length>0);try{return await Ve(T,n)?(_(JSON.stringify(e)),!0):(J.error(t(`settings.yuri.worktrees.setup.toast.saveFailed`)),!1)}catch{return J.error(t(`settings.yuri.worktrees.setup.toast.saveFailed`)),!1}},[T,t]),O=Q.useMemo(()=>g!==null&&g!==JSON.stringify(u),[g,u]);Q.useEffect(()=>{if(!O||m||w.current)return;let e=window.setTimeout(()=>{w.current||(w.current=!0,(async()=>{try{await D(u)}finally{w.current=!1}})())},xi);return()=>{window.clearTimeout(e)}},[O,m,D,u]);let k=Q.useCallback((e,t)=>{d(n=>{let r=[...n];return r[e]=t,r})},[]),j=Q.useCallback(()=>{d(e=>[...e,``])},[]),M=Q.useCallback(e=>{d(t=>{let n=t.filter((t,n)=>n!==e);return n.length>0?n:[``]})},[]),N=Q.useCallback(()=>{!O||w.current||(w.current=!0,(async()=>{try{await D(u)}finally{w.current=!1}})())},[O,D,u]),P=Q.useCallback(e=>{p(e),T&&We(T,e)},[T]),F=Q.useCallback(e=>{let t=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),n=t(e.path),r=c.filter(e=>{let r=s(e.id);if(r?.path&&t(r.path)===n)return!0;let i=e.directory;return!!(i&&t(i)===n)}),i=new Set(r.map(e=>e.id)),a=[...Me.getState().activeSessions,...Me.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));Ne.requestDelete({sessions:d,mode:`worktree`,worktree:e})},[c,s]),I=Q.useMemo(()=>c.map(e=>e.id).join(`,`),[c]);Q.useEffect(()=>{v&&o&&E()},[I,v,o,E]);let L=(0,Z.jsxs)(bt,{children:[(0,Z.jsx)(vt,{asChild:!0,children:(0,Z.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,Z.jsxs)(yt,{sideOffset:8,className:`max-w-xs`,children:[t(`settings.yuri.worktrees.setup.tooltipPrefix`),` `,(0,Z.jsx)(`code`,{className:`font-mono text-xs bg-sidebar-accent/50 px-1 rounded`,children:`$ROOT_PROJECT_PATH`}),` `,t(`settings.yuri.worktrees.setup.tooltipSuffix`)]})]}),R=(0,Z.jsxs)(bt,{children:[(0,Z.jsx)(vt,{asChild:!0,children:(0,Z.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,Z.jsx)(yt,{sideOffset:8,className:`max-w-xs`,children:t(`settings.yuri.worktrees.list.tooltip`)})]});return o?v===!1?(0,Z.jsx)(bi,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.worktrees.state.gitOnly`)})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(bi,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,titleAccessory:L,children:m?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.worktrees.setup.loading`)}):(0,Z.jsxs)(`div`,{className:K(`flex flex-col gap-2`,yi),children:[u.map((e,n)=>(0,Z.jsxs)(`div`,{className:`yuri-settings-group-row flex w-full items-center gap-2`,children:[(0,Z.jsx)(_t,{value:e,onChange:e=>k(n,e.target.value),onBlur:N,placeholder:t(`settings.yuri.worktrees.setup.commandPlaceholder`),className:`min-w-0 flex-1 font-mono text-xs`}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>M(n),className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":t(`settings.yuri.worktrees.setup.removeCommandAria`),children:(0,Z.jsx)(Y,{name:`close`,className:`h-4 w-4`})})]},n)),(0,Z.jsxs)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:j,children:[(0,Z.jsx)(Y,{name:`add`,className:`h-3.5 w-3.5`}),t(`settings.yuri.worktrees.setup.addCommand`)]}),(0,Z.jsxs)(`label`,{"data-settings-item":`projects.worktree.setup.wait`,className:`flex cursor-pointer items-center gap-2 py-1`,children:[(0,Z.jsx)(ot,{checked:f,onChange:P,ariaLabel:t(`settings.yuri.worktrees.setup.waitForCommandsAria`)}),(0,Z.jsx)(`span`,{className:K(`typography-ui-label font-normal`,f?`text-foreground`:`text-foreground/60`),children:t(`settings.yuri.worktrees.setup.waitForCommands`)})]})]})}),(0,Z.jsx)(bi,{title:t(`settings.yuri.worktrees.list.title`),titleAccessory:R,children:S?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.worktrees.list.loading`)}):b.length===0?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground/70`,children:t(`settings.yuri.worktrees.list.empty`)}):(0,Z.jsx)(`div`,{className:K(`space-y-1`,yi),children:b.map(e=>(0,Z.jsxs)(`div`,{className:`group flex w-full items-center gap-2 py-1.5`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`p`,{className:`typography-meta min-w-0 truncate text-foreground`,children:e.label||e.branch||t(`settings.yuri.worktrees.list.detachedHead`)}),(0,Z.jsx)(`span`,{className:`typography-micro flex-shrink-0 self-center rounded bg-sidebar-accent/40 px-1.5 py-[1px] leading-none text-muted-foreground/60`,children:`OpenCode`})]}),(0,Z.jsx)(`p`,{className:`typography-micro truncate text-muted-foreground/60`,children:ke(e.path,l)})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>F(e),className:K(`flex h-7 w-7 shrink-0 items-center justify-center rounded text-muted-foreground/50 transition-opacity hover:bg-destructive/10 hover:text-destructive focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,i?`opacity-100`:`opacity-0 group-hover:opacity-100`),"aria-label":t(`settings.yuri.worktrees.list.deleteWorktreeAria`,{name:e.branch||e.label||e.path}),children:(0,Z.jsx)(Y,{name:`delete-bin`,className:`h-4 w-4`})})]},e.path))})})]}):(0,Z.jsx)(bi,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.worktrees.state.selectProject`)})})},Ci=(e,t)=>t.updatedAtMs-e.updatedAtMs,wi=w((e,t)=>({instances:[],statusesById:{},importCandidates:[],isLoading:!1,isSaving:!1,isImportsLoading:!1,initialized:!1,listenerReady:!1,error:null,load:async()=>{if(!t().isLoading){e({isLoading:!0,error:null});try{let[n,r]=await Promise.all([Nt(),xt()]),i={};for(let e of r.sort(Ci))i[e.id]=e;t().listenerReady||await Ft(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 Et(),isImportsLoading:!1})}catch(t){e({isImportsLoading:!1,error:t instanceof Error?t.message:String(t)})}}},refreshStatuses:async()=>{try{let t=await xt(),n={};for(let e of t.sort(Ci))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 Mt({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=wt(e,n);r&&r.trim()&&(i.nickname=r.trim()),await t().upsertInstance(i)},removeInstance:async n=>{await zt(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 Dt(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 zt(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})})),Ti=450,Ei=()=>S(),Di=()=>({id:Ei(),name:``,command:``,icon:`play`}),Oi=({projectRef:e})=>{let{t}=G(),n=Q.useMemo(()=>m(),[]),r=wi(e=>e.instances),i=wi(e=>e.load),[a,o]=Q.useState([]),[s,c]=Q.useState(!1),[l,u]=Q.useState(null),[d,f]=Q.useState({}),p=Q.useRef(!1),h=Q.useRef(null);Q.useEffect(()=>{n&&i().catch(()=>void 0)},[n,i]),Q.useEffect(()=>{let t=!1;return c(!0),(async()=>{try{let n=await Fe(e);if(t)return;o(n.actions),u(JSON.stringify({actions:n.actions}))}catch{if(t)return;o([]),u(JSON.stringify({actions:[]}))}finally{t||c(!1)}})(),()=>{t=!0}},[e]);let g=Q.useMemo(()=>n?gn(r):[],[r,n]),_=Q.useMemo(()=>a.some(e=>e.name.trim().length===0||e.command.trim().length===0)?t(`settings.projects.actions.validation.fillNameAndCommand`):null,[a,t]),v=Q.useMemo(()=>l!==null&&l!==JSON.stringify({actions:a}),[a,l]),y=Q.useCallback(async n=>await Re(e,{actions:n,primaryActionId:null})?(u(JSON.stringify({actions:n})),typeof window<`u`&&window.dispatchEvent(new CustomEvent(yn,{detail:{projectId:e.id}})),!0):(J.error(t(`settings.projects.actions.toast.saveFailed`)),!1),[e,t]);Q.useEffect(()=>{if(!v||s||_||p.current)return;let e=window.setTimeout(()=>{p.current||(p.current=!0,(async()=>{try{await y(a)}finally{p.current=!1}})())},Ti);return()=>{window.clearTimeout(e)}},[a,v,s,y,_]),Q.useEffect(()=>{if(!v||!_||s){_||(h.current=null);return}let e=window.setTimeout(()=>{h.current!==_&&(h.current=_,J.error(_))},1e3);return()=>{window.clearTimeout(e)}},[v,s,_]);let b=Q.useCallback(()=>{let e=Di();o(t=>[...t,e]),f(t=>({...t,[e.id]:!0}))},[]),x=Q.useCallback(e=>{o(t=>t.filter(t=>t.id!==e)),f(t=>{let n={...t};return delete n[e],n})},[]),S=Q.useCallback((e,t)=>{o(n=>n.map(n=>n.id===e?t(n):n))},[]);return(0,Z.jsxs)(bi,{title:t(`settings.projects.actions.title`),description:t(`settings.projects.actions.description`),settingsItem:`projects.actions`,headerAction:(0,Z.jsxs)(q,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:b,children:[(0,Z.jsx)(Y,{name:`add`,className:`h-3.5 w-3.5`}),t(`settings.projects.actions.actions.add`)]}),contentClassName:`space-y-0`,children:[s?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.loading`)}):a.length===0?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.empty`)}):(0,Z.jsx)(`div`,{className:K(`space-y-0`,yi),children:a.map(e=>{let r=e.icon||`play`,i=vn[r]||`play`,a=d[e.id]??!1,o=e.name.trim()||t(`settings.projects.actions.state.untitled`);return(0,Z.jsxs)(tn,{open:a,onOpenChange:t=>{f(n=>({...n,[e.id]:t}))},className:`py-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsxs)(en,{className:`group flex-1 justify-start gap-2 rounded-md px-0 pr-1 py-1 hover:bg-[var(--interactive-hover)] focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,children:[a?(0,Z.jsx)(Y,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground`}):(0,Z.jsx)(Y,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground`}),(0,Z.jsx)(Y,{name:i,className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:o})})]}),(0,Z.jsx)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal h-7 w-7 px-0 text-muted-foreground hover:text-[var(--status-error)]`,onClick:()=>x(e.id),children:(0,Z.jsx)(Y,{name:`delete-bin`,className:`h-3.5 w-3.5`})})]}),(0,Z.jsx)($t,{className:`pt-1.5`,children:(0,Z.jsxs)(`div`,{className:`space-y-2 pb-4 pl-3 pr-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,Z.jsxs)(Bt,{children:[(0,Z.jsx)(Vt,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-[var(--interactive-border)] text-foreground hover:bg-[var(--interactive-hover)]`,"aria-label":t(`settings.projects.actions.field.selectIconAria`),children:(0,Z.jsx)(Y,{name:i,className:`h-4 w-4`})})}),(0,Z.jsx)(It,{align:`start`,className:`w-56 p-2`,children:(0,Z.jsx)(`div`,{className:`grid grid-cols-6 gap-1`,children:_n.map(n=>{let r=n.Icon,i=(e.icon||`play`)===n.key;return(0,Z.jsx)(`button`,{type:`button`,onClick:()=>S(e.id,e=>({...e,icon:n.key})),className:K(`inline-flex h-8 w-8 items-center justify-center rounded-md border border-transparent text-foreground hover:bg-[var(--interactive-hover)]`,i&&`border-[var(--primary-base)] bg-[var(--primary-base)]/10 text-[var(--primary-base)]`),"aria-label":t(`settings.projects.actions.field.iconAria`,{icon:n.label}),children:(0,Z.jsx)(Y,{name:r,className:`h-4 w-4`})},n.key)})})})]}),(0,Z.jsx)(_t,{value:e.name,onChange:t=>S(e.id,e=>({...e,name:t.target.value})),placeholder:t(`settings.projects.actions.field.actionNamePlaceholder`),className:`h-7 flex-1 min-w-0`})]}),(0,Z.jsxs)(`div`,{className:`py-1`,children:[(0,Z.jsx)(`p`,{className:`typography-meta mb-0.5 text-muted-foreground`,children:t(`settings.projects.actions.field.command`)}),(0,Z.jsx)(Kt,{embedded:!0,value:e.command,onChange:t=>S(e.id,e=>({...e,command:t.target.value})),placeholder:t(`settings.projects.actions.field.commandPlaceholder`),className:`min-h-[88px] w-full font-mono text-xs`})]}),(0,Z.jsxs)(`div`,{className:`py-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Z.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:t(`settings.projects.actions.field.autoOpenUrl`)}),(0,Z.jsxs)(`div`,{className:`group flex cursor-pointer items-center gap-2`,role:`button`,tabIndex:0,"aria-pressed":e.autoOpenUrl===!0,onClick:()=>S(e.id,e=>({...e,...e.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})),onKeyDown:t=>{(t.key===` `||t.key===`Enter`)&&(t.preventDefault(),S(e.id,e=>({...e,...e.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})))},children:[(0,Z.jsx)(ot,{checked:e.autoOpenUrl===!0,onChange:t=>S(e.id,e=>({...e,...t?{autoOpenUrl:!0}:{autoOpenUrl:void 0}})),ariaLabel:t(`settings.projects.actions.field.autoOpenUrlForAria`,{title:o})}),(0,Z.jsx)(`span`,{className:`typography-ui-label font-normal text-foreground/80`,children:t(`settings.projects.actions.field.autoOpenUrlDescription`)})]})]}),e.autoOpenUrl===!0?(0,Z.jsxs)(`div`,{className:`mt-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(_t,{value:e.openUrl||``,onChange:t=>S(e.id,e=>({...e,openUrl:t.target.value})),placeholder:t(`settings.projects.actions.field.overrideUrlPlaceholder`),className:`h-7 w-full max-w-[24rem]`}),(0,Z.jsxs)(bt,{children:[(0,Z.jsx)(vt,{asChild:!0,children:(0,Z.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/60 cursor-help`})}),(0,Z.jsx)(yt,{sideOffset:8,className:`max-w-xs`,children:t(`settings.projects.actions.field.overrideUrlTooltip`)})]})]}),n?(0,Z.jsxs)(`div`,{className:`mt-2`,children:[(0,Z.jsx)(`p`,{className:`typography-meta mb-0.5 text-muted-foreground`,children:t(`settings.projects.actions.field.desktopSshForward`)}),g.length>0?(0,Z.jsxs)(ft,{value:e.desktopOpenSshForward&&g.some(t=>t.id===e.desktopOpenSshForward)?e.desktopOpenSshForward:`__none__`,onValueChange:t=>{S(e.id,e=>({...e,...t===`__none__`?{desktopOpenSshForward:void 0}:{desktopOpenSshForward:t}}))},children:[(0,Z.jsx)(lt,{className:`h-7 w-full`,children:(0,Z.jsx)(gt,{placeholder:t(`settings.projects.actions.field.useOutputManualUrl`)})}),(0,Z.jsxs)(dt,{children:[(0,Z.jsx)(st,{value:`__none__`,children:t(`settings.projects.actions.field.useOutputManualUrl`)}),g.map(e=>(0,Z.jsx)(st,{value:e.id,children:e.label},e.id))]})]}):(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.noDesktopSshForwards`)})]}):null]}):null]})]})})]},e.id)})}),_&&a.length>0?(0,Z.jsx)(`p`,{className:`typography-meta text-[var(--status-warning)]`,children:_}):null]})},ki=e=>{let t=(0,X.c)(123),{form:n}=e,{t:r}=G(),{currentTheme:i}=qe(),{name:a,setName:o,icon:s,setIcon:c,color:l,setColor:u,iconBackground:d,setIconBackground:f,parsedDefaultModel:p,handleDefaultModelChange:m,isUploadingIcon:h,isRemovingCustomIcon:g,isDiscoveringIcon:_,pendingRemoveImageIcon:v,setPendingRemoveImageIcon:y,pendingUploadIconPreviewUrl:b,setPreviewImageFailed:x,hasPendingUploadImageIcon:S,hasCustomIcon:C,effectiveHasImageIcon:w,hasRemovableImageIcon:T,showImagePreview:E,fileInputRef:D,handleUploadIcon:O,handleRemoveImageIcon:k,handleDiscoverIcon:A,currentIconImage:j,project:M}=n;if(!M)return null;let N=l?pt[l]??null:null,P;t[0]===r?P=t[1]:(P=r(`settings.projects.page.field.projectName`),t[0]=r,t[1]=P);let F;t[2]===o?F=t[3]:(F=e=>o(e.target.value),t[2]=o,t[3]=F);let I;t[4]===r?I=t[5]:(I=r(`settings.projects.page.field.projectNamePlaceholder`),t[4]=r,t[5]=I);let L;t[6]!==a||t[7]!==F||t[8]!==I?(L=(0,Z.jsx)(_t,{value:a,onChange:F,placeholder:I}),t[6]=a,t[7]=F,t[8]=I,t[9]=L):L=t[9];let R;t[10]!==P||t[11]!==L?(R=(0,Z.jsx)(_r,{label:P,itemId:`projects.name`,children:L}),t[10]=P,t[11]=L,t[12]=R):R=t[12];let ee;t[13]===r?ee=t[14]:(ee=r(`settings.projects.page.field.defaultModel`),t[13]=r,t[14]=ee);let te;t[15]===r?te=t[16]:(te=r(`settings.projects.page.field.defaultModelDescription`),t[15]=r,t[16]=te);let ne;t[17]!==m||t[18]!==p.modelId||t[19]!==p.providerId?(ne=(0,Z.jsx)(Tt,{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]=ne):ne=t[20];let re;t[21]!==ee||t[22]!==te||t[23]!==ne?(re=(0,Z.jsx)(_r,{label:ee,description:te,descriptionPlacement:`outside`,itemId:`projects.default-model`,children:ne}),t[21]=ee,t[22]=te,t[23]=ne,t[24]=re):re=t[24];let ie;t[25]===r?ie=t[26]:(ie=r(`settings.projects.page.field.accentColor`),t[25]=r,t[26]=ie);let z;t[27]===u?z=t[28]:(z=()=>u(null),t[27]=u,t[28]=z);let ae=l===null?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-border/40 hover:border-border hover:bg-[var(--surface-muted)]`,B;t[29]===ae?B=t[30]:(B=K(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,ae),t[29]=ae,t[30]=B);let oe;t[31]===r?oe=t[32]:(oe=r(`settings.projects.page.field.none`),t[31]=r,t[32]=oe);let se;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,Z.jsx)(Y,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[33]=se):se=t[33];let V;t[34]!==z||t[35]!==B||t[36]!==oe?(V=(0,Z.jsx)(`button`,{type:`button`,onClick:z,className:B,title:oe,children:se}),t[34]=z,t[35]=B,t[36]=oe,t[37]=V):V=t[37];let ce;t[38]!==l||t[39]!==u?(ce=ht.map(e=>(0,Z.jsx)(`button`,{type:`button`,onClick:()=>u(e.key),className:K(`h-7 w-7 rounded-md border transition-colors`,l===e.key?`border-2 border-foreground ring-1 ring-[var(--primary-base)]/40`:`border-transparent hover:border-border/70`),style:{backgroundColor:e.cssVar},title:e.label},e.key)),t[38]=l,t[39]=u,t[40]=ce):ce=t[40];let le;t[41]!==V||t[42]!==ce?(le=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[V,ce]}),t[41]=V,t[42]=ce,t[43]=le):le=t[43];let ue;t[44]!==ie||t[45]!==le?(ue=(0,Z.jsx)(_r,{label:ie,itemId:`projects.accent-color`,children:le}),t[44]=ie,t[45]=le,t[46]=ue):ue=t[46];let de;t[47]===r?de=t[48]:(de=r(`settings.projects.page.field.projectIcon`),t[47]=r,t[48]=de);let fe;t[49]===O?fe=t[50]:(fe=e=>{let t=e.target.files?.[0]??null;O(t),e.currentTarget.value=``},t[49]=O,t[50]=fe);let pe;t[51]!==D||t[52]!==fe?(pe=(0,Z.jsx)(`input`,{ref:D,type:`file`,accept:`image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg`,className:`hidden`,onChange:fe}),t[51]=D,t[52]=fe,t[53]=pe):pe=t[53];let H;t[54]===c?H=t[55]:(H=()=>c(null),t[54]=c,t[55]=H);let me=s===null?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-border/40 hover:border-border hover:bg-[var(--surface-muted)]`,he;t[56]===me?he=t[57]:(he=K(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,me),t[56]=me,t[57]=he);let ge;t[58]===r?ge=t[59]:(ge=r(`settings.projects.page.field.none`),t[58]=r,t[59]=ge);let _e;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,Z.jsx)(Y,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[60]=_e):_e=t[60];let ve;t[61]!==H||t[62]!==he||t[63]!==ge?(ve=(0,Z.jsx)(`button`,{type:`button`,onClick:H,className:he,title:ge,children:_e}),t[61]=H,t[62]=he,t[63]=ge,t[64]=ve):ve=t[64];let ye;t[65]!==N||t[66]!==s||t[67]!==c?(ye=mt.map(e=>{let t=e.Icon;return(0,Z.jsx)(`button`,{type:`button`,onClick:()=>c(e.key),className:K(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,s===e.key?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-transparent hover:border-border hover:bg-[var(--surface-muted)]`),title:e.label,children:(0,Z.jsx)(Y,{name:t,className:`w-4 h-4`,style:N&&s===e.key?{color:N}:void 0})},e.key)}),t[65]=N,t[66]=s,t[67]=c,t[68]=ye):ye=t[68];let be;t[69]!==ve||t[70]!==ye?(be=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[ve,ye]}),t[69]=ve,t[70]=ye,t[71]=be):be=t[71];let U;t[72]!==j||t[73]!==i||t[74]!==w||t[75]!==S||t[76]!==d||t[77]!==b||t[78]!==M||t[79]!==x||t[80]!==E||t[81]!==r?(U=w&&E&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Z.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:r(`settings.projects.page.field.preview`)}),(0,Z.jsx)(`span`,{className:`inline-flex h-7 w-7 items-center justify-center rounded-md border border-border/60 bg-[var(--surface-elevated)] p-1`,children:(0,Z.jsx)(`span`,{className:`inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]`,style:d?{backgroundColor:d}:void 0,children:S&&b?(0,Z.jsx)(`img`,{src:b,alt:``,className:`h-full w-full object-contain`,draggable:!1,onError:()=>x(!0)}):(0,Z.jsx)(ct,{project:{...M,iconImage:j??M.iconImage},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:`h-full w-full object-contain`,onError:()=>x(!0)})})})]}),t[72]=j,t[73]=i,t[74]=w,t[75]=S,t[76]=d,t[77]=b,t[78]=M,t[79]=x,t[80]=E,t[81]=r,t[82]=U):U=t[82];let xe;t[83]!==w||t[84]!==d||t[85]!==f||t[86]!==r?(xe=w&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,Z.jsx)(`input`,{type:`color`,value:d??`#000000`,onChange:e=>f(e.target.value),className:`h-7 w-9 cursor-pointer rounded border border-border bg-transparent p-1`,"aria-label":r(`settings.projects.page.field.projectIconBackgroundAria`)}),(0,Z.jsx)(_t,{value:d??``,onChange:e=>f(e.target.value),placeholder:`#000000`,className:`h-7 w-[8rem]`}),(0,Z.jsx)(q,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>f(null),className:`h-7 w-7 p-0`,"aria-label":r(`settings.projects.page.field.clearIconBackgroundAria`),title:r(`settings.projects.page.field.clearBackground`),disabled:!d,children:(0,Z.jsx)(Y,{name:`close`,className:`h-3.5 w-3.5`})})]}),t[83]=w,t[84]=d,t[85]=f,t[86]=r,t[87]=xe):xe=t[87];let W;t[88]!==D||t[89]!==A||t[90]!==C||t[91]!==_||t[92]!==h||t[93]!==r?(W=!C&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(q,{size:`xs`,className:`h-6 !font-normal`,onClick:()=>D.current?.click(),disabled:h,children:r(h?`settings.projects.page.actions.uploading`:`settings.projects.page.actions.uploadIcon`)}),(0,Z.jsx)(q,{size:`xs`,className:`h-6 !font-normal`,variant:`outline`,onClick:()=>void A(),disabled:_,children:r(_?`settings.projects.page.actions.discovering`:`settings.projects.page.actions.discoverFavicon`)})]}),t[88]=D,t[89]=A,t[90]=C,t[91]=_,t[92]=h,t[93]=r,t[94]=W):W=t[94];let Se;t[95]!==k||t[96]!==T||t[97]!==g||t[98]!==r?(Se=T&&(0,Z.jsx)(q,{size:`xs`,className:`!font-normal`,variant:`outline`,onClick:()=>void k(),disabled:g,children:r(g?`settings.projects.page.actions.removing`:`settings.projects.page.actions.removeProjectIcon`)}),t[95]=k,t[96]=T,t[97]=g,t[98]=r,t[99]=Se):Se=t[99];let Ce;t[100]!==g||t[101]!==v||t[102]!==y||t[103]!==r?(Ce=v&&(0,Z.jsx)(q,{size:`xs`,className:`!font-normal`,variant:`outline`,onClick:()=>y(!1),disabled:g,children:r(`settings.projects.page.actions.undoRemove`)}),t[100]=g,t[101]=v,t[102]=y,t[103]=r,t[104]=Ce):Ce=t[104];let we;t[105]!==W||t[106]!==Se||t[107]!==Ce?(we=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[W,Se,Ce]}),t[105]=W,t[106]=Se,t[107]=Ce,t[108]=we):we=t[108];let Te;t[109]!==pe||t[110]!==be||t[111]!==U||t[112]!==xe||t[113]!==we?(Te=(0,Z.jsxs)(`div`,{className:`flex w-full flex-col items-end gap-2`,children:[pe,be,U,xe,we]}),t[109]=pe,t[110]=be,t[111]=U,t[112]=xe,t[113]=we,t[114]=Te):Te=t[114];let Ee;t[115]!==de||t[116]!==Te?(Ee=(0,Z.jsx)(_r,{label:de,itemId:`projects.icon`,children:Te}),t[115]=de,t[116]=Te,t[117]=Ee):Ee=t[117];let De;return t[118]!==ue||t[119]!==Ee||t[120]!==R||t[121]!==re?(De=(0,Z.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[R,re,ue,Ee]}),t[118]=ue,t[119]=Ee,t[120]=R,t[121]=re,t[122]=De):De=t[122],De},Ai=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,ji=e=>{if(!e)return null;let t=e.trim();return t&&Ai.test(t)?t.toLowerCase():null},Mi=e=>{let{t}=G(),n=Ie(e=>e.uploadProjectIcon),r=Ie(e=>e.removeProjectIcon),i=Ie(e=>e.discoverProjectIcon),a=Ie(t=>e?t.projects.find(t=>t.id===e.id)?.iconImage??null:null),[o,s]=Q.useState(``),[c,l]=Q.useState(null),[u,d]=Q.useState(null),[f,p]=Q.useState(null),[m,h]=Q.useState(void 0),[g,_]=Q.useState(!1),[v,y]=Q.useState(!1),[b,x]=Q.useState(!1),[S,C]=Q.useState(!1),[w,T]=Q.useState(null),[E,D]=Q.useState(null),[O,k]=Q.useState(!1),A=Q.useRef(null),j=Q.useCallback(()=>{T(null),D(e=>(e&&URL.revokeObjectURL(e),null))},[]),M=e?.id??null;Q.useEffect(()=>{if(!e){s(``),l(null),d(null),p(null),h(void 0);return}s(e.label??``),l(e.icon??null),d(e.color??null),p(e.iconBackground??null),h(e.defaultModel),C(!1),j(),k(!1)},[e,j]),Q.useEffect(()=>()=>{j()},[j]);let N=Q.useMemo(()=>Ue(m)??{providerId:``,modelId:``},[m]),P=!!e?.iconImage,F=!!(w&&E),I=e?.iconImage?.source===`custom`,L=P&&!S||F,R=L,ee=!!(e&&P&&!S),te=!O&&(F||ee),ne=!!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),re=Q.useCallback((e,t)=>{h(e&&t?`${e}/${t}`:void 0)},[]),ie=Q.useCallback(t=>{!e||!t||g||(C(!1),k(!1),T(t),D(e=>(e&&URL.revokeObjectURL(e),URL.createObjectURL(t))))},[g,e]),z=Q.useCallback(()=>{!e||!R||v||(F&&j(),C(!!P),k(!1))},[j,F,R,P,v,e]),ae=Q.useCallback(async()=>{if(!(!e||b)){j(),C(!1),k(!1),x(!0);try{let n=await i(e.id);if(!n.ok){J.error(n.error||t(`settings.projects.page.toast.discoverIconFailed`));return}if(n.skipped){J.success(t(`settings.projects.page.toast.customIconAlreadySet`));return}J.success(t(`settings.projects.page.toast.iconDiscovered`))}finally{x(!1)}}},[j,i,b,e,t]),B=Q.useCallback(async i=>{let a=i?.silent===!0;if(!e)return null;let s=o.trim();if(!s)return null;if(w){_(!0);let r=await n(e.id,w);if(_(!1),!r.ok)return J.error(r.error||t(`settings.projects.page.toast.uploadIconFailed`)),null;a||J.success(t(`settings.projects.page.toast.iconUpdated`)),j(),C(!1)}let l=S&&!!e.iconImage;if(l){y(!0);let n=await r(e.id);if(y(!1),!n.ok)return J.error(n.error||t(`settings.projects.page.toast.removeIconFailed`)),null;a||J.success(t(`settings.projects.page.toast.iconRemoved`)),C(!1),p(null)}return{label:s,icon:c,color:u,iconBackground:ji(l?null:f),defaultModel:m??null}},[j,u,m,c,f,o,S,w,e,r,t,n]);return Q.useEffect(()=>{k(!1)},[M,a?.updatedAt]),{name:o,setName:s,icon:c,setIcon:l,color:u,setColor:d,iconBackground:f,setIconBackground:p,defaultModel:m,parsedDefaultModel:N,handleDefaultModelChange:re,isUploadingIcon:g,isRemovingCustomIcon:v,isDiscoveringIcon:b,pendingRemoveImageIcon:S,setPendingRemoveImageIcon:C,pendingUploadIconFile:w,pendingUploadIconPreviewUrl:E,previewImageFailed:O,setPreviewImageFailed:k,hasStoredImageIcon:P,hasPendingUploadImageIcon:F,hasCustomIcon:I,effectiveHasImageIcon:L,hasRemovableImageIcon:R,showStoredImagePreview:ee,showImagePreview:te,fileInputRef:A,clearPendingUploadIcon:j,handleUploadIcon:ie,handleRemoveImageIcon:z,handleDiscoverIcon:ae,hasChanges:ne,prepareSaveData:B,currentIconImage:a,project:e}},Ni=450,Pi=(e,t)=>{let{t:n}=G(),{hasChanges:r,name:i,icon:a,color:o,iconBackground:s,defaultModel:c,pendingRemoveImageIcon:l,pendingUploadIconFile:u,isUploadingIcon:d,isRemovingCustomIcon:f,prepareSaveData:p}=e,m=Q.useRef(!1);Q.useEffect(()=>{if(!r||!i.trim()||d||f||m.current)return;let e=window.setTimeout(()=>{m.current||(m.current=!0,(async()=>{try{let e=await p({silent:!0});if(e)try{await t(e)}catch{J.error(n(`settings.projects.page.toast.saveFailed`))}}finally{m.current=!1}})())},Ni);return()=>{window.clearTimeout(e)}},[o,c,r,a,s,f,d,i,t,l,u,p,n])},Fi=e=>{let t=(0,X.c)(25),{project:n,onIdentitySave:r}=e,{t:i}=G(),a=Mi(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),Pi(a,c),!n||!s)return null;let l;t[5]!==n.path||t[6]!==i?(l=n.path.split(/[\\/]/).filter(Boolean).at(-1)??i(`settings.projects.page.title.default`),t[5]=n.path,t[6]=i,t[7]=l):l=t[7];let u=l,d;t[8]===u?d=t[9]:(d=(0,Z.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:u}),t[8]=u,t[9]=d);let f;t[10]===n.path?f=t[11]:(f=(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,title:n.path,children:n.path}),t[10]=n.path,t[11]=f);let p;t[12]!==d||t[13]!==f?(p=(0,Z.jsxs)(`div`,{className:`px-1`,children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;t[15]===a?m=t[16]:(m=(0,Z.jsx)(ki,{form:a}),t[15]=a,t[16]=m);let h,g;t[17]===s?(h=t[18],g=t[19]):(h=(0,Z.jsx)(Oi,{projectRef:s}),g=(0,Z.jsx)(Si,{projectRef:s}),t[17]=s,t[18]=h,t[19]=g);let _;return t[20]!==p||t[21]!==m||t[22]!==h||t[23]!==g?(_=(0,Z.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[p,m,h,g]}),t[20]=p,t[21]=m,t[22]=h,t[23]=g,t[24]=_):_=t[24],_};function Ii(e,t,n){return Math.min(n,Math.max(t,e))}function Li(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 Ri(e,t){let n=Li(t);return n<=0?e:Number(e.toFixed(n))}var zi=Q.forwardRef(({value:e,onValueChange:t,min:n=-1/0,max:r=1/0,step:i=1,className:a,containerClassName:o,onBlur:s,disabled:c,fallbackValue:l,onClear:u,emptyLabel:d=`—`,...f},p)=>{let{t:m}=G(),[h,g]=Q.useState(()=>e===void 0?``:String(e)),{isMobile:_}=Ut(),v=Q.useRef(!1),y=Q.useRef(null),b=Q.useCallback(()=>{if(typeof document>`u`||typeof window>`u`)return;y.current?.();let e=e=>{e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation?.(),y.current?.()},t=window.setTimeout(()=>{y.current?.()},700);y.current=()=>{window.clearTimeout(t),document.removeEventListener(`click`,e,!0),y.current=null},document.addEventListener(`click`,e,!0)},[]);Q.useEffect(()=>()=>{y.current?.()},[]),Q.useEffect(()=>{g(e===void 0?``:String(e))},[e]);let x=Q.useMemo(()=>e===void 0?l===void 0?Number.isFinite(n)?n:0:l:e,[l,n,e]),S=Q.useRef(x);Q.useEffect(()=>{S.current=x},[x]);let C=Q.useCallback(e=>{let a=Ri(Ii(e,n,r),i);S.current=a,t(a)},[r,n,t,i]),w=Q.useCallback(e=>{let t=e.target.value;if(g(t),t.trim()===``){u?.();return}let n=Number(t);Number.isFinite(n)&&C(n)},[C,u]),T=Q.useCallback(t=>{if(h.trim()===``){u||g(e===void 0?``:String(e)),s?.(t);return}let a=Number(h);if(!Number.isFinite(a))g(e===void 0?``:String(e));else{let t=Ri(Ii(a,n,r),i);t===e?S.current=t:C(a),g(String(t))}s?.(t)},[C,h,r,n,s,u,i,e]),E=!!(c||x>=r),D=!!(c||x<=n),O=()=>{D||C(S.current-i)},k=()=>{E||C(S.current+i)},A=e=>t=>{t.preventDefault(),t.stopPropagation(),v.current=!0,b(),e()},j=e=>t=>{if(v.current){v.current=!1,t.preventDefault(),t.stopPropagation();return}e()};return _?(0,Z.jsxs)(`div`,{"data-slot":`number-input`,className:K(`flex h-9 shrink-0 items-stretch overflow-x-hidden overflow-y-hidden rounded-lg border border-border bg-transparent select-none overscroll-contain`,`[-webkit-user-select:none] [-webkit-touch-callout:none]`,`disabled:pointer-events-none disabled:opacity-50`,o),children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.decreaseAria`),disabled:D,onTouchStart:A(O),onClick:j(O),className:K(`grid h-full min-h-0 w-9 place-items-center overflow-x-hidden overflow-y-hidden border-r border-border p-0 leading-none touch-none`,`text-muted-foreground`,`disabled:pointer-events-none disabled:opacity-50`,!D&&`active:bg-interactive-hover`),children:(0,Z.jsx)(Y,{name:`subtract`,className:`block h-4 w-4`})}),(0,Z.jsx)(`div`,{"data-slot":`number-input-value`,className:K(`flex h-full min-w-0 w-14 items-center justify-center bg-transparent px-1.5`,`text-center text-[16px] leading-none text-foreground [font-variant-numeric:tabular-nums]`,a),"aria-live":`polite`,children:e===void 0?d:h}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.increaseAria`),disabled:E,onTouchStart:A(k),onClick:j(k),className:K(`grid h-full min-h-0 w-9 place-items-center overflow-x-hidden overflow-y-hidden border-l border-border p-0 leading-none touch-none`,`text-muted-foreground`,`disabled:pointer-events-none disabled:opacity-50`,!E&&`active:bg-interactive-hover`),children:(0,Z.jsx)(Y,{name:`add`,className:`block h-4 w-4`})})]}):(0,Z.jsxs)(`div`,{"data-slot":`number-input`,className:K(`flex h-7 shrink-0 items-stretch overflow-x-hidden overflow-y-hidden rounded-lg border border-border bg-transparent`,`disabled:pointer-events-none disabled:opacity-50`,o),children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.decreaseAria`),disabled:D,onClick:()=>C(S.current-i),className:K(`flex h-full w-7 items-center justify-center overflow-x-hidden overflow-y-hidden border-r border-border p-0 leading-none touch-manipulation`,`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`,`disabled:pointer-events-none disabled:opacity-50`),children:(0,Z.jsx)(Y,{name:`subtract`,className:`block h-3.5 w-3.5`})}),(0,Z.jsx)(`input`,{...f,"data-slot":`number-input-value`,ref:p,type:`text`,inputMode:f.inputMode??`numeric`,value:h,onChange:w,onBlur:T,disabled:c,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,className:K(`h-full min-w-0 w-14 bg-transparent px-1.5 text-center typography-ui-label leading-none text-foreground [font-variant-numeric:tabular-nums]`,`placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground`,`appearance-none outline-none [appearance:textfield] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,`disabled:pointer-events-none disabled:cursor-not-allowed`,a)}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.increaseAria`),disabled:E,onClick:()=>C(S.current+i),className:K(`flex h-full w-7 items-center justify-center overflow-x-hidden overflow-y-hidden border-l border-border p-0 leading-none touch-manipulation`,`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`,`disabled:pointer-events-none disabled:opacity-50`),children:(0,Z.jsx)(Y,{name:`add`,className:`block h-3.5 w-3.5`})})]})});zi.displayName=`NumberInput`;function Bi(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 Vi={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 Hi(e,t){let n=Vi[t]??[];for(let t of n)if(t.matcher(e))return t;return null}function Ui(e){return Vi[e]??[]}function Wi(e){return[...e].sort((e,t)=>e.order-t.order)}function Gi(e,t){let n=new Map;for(let r of Object.keys(e)){let e=Hi(r,t)?.id??null;n.has(e)||n.set(e,[]),n.get(e).push(r)}return n}function Ki(e,t,n){let r=new Map;for(let i of e){let e=Hi(t(i),n)?.id??null;r.has(e)||r.set(e,[]),r.get(e).push(i)}return r}function qi(e,t){return t.filter(e=>{let t=e.toLowerCase(),n=t.includes(`/`)?t.split(`/`)[1]:t;return!!(n.startsWith(`gemini-3-`)||n.startsWith(`claude-`))})}var Ji=(e,t=``,n=!1)=>R({queryKey:a.scoped(`magpie-quotas`,e,t,n),staleTime:0,retry:!1,queryFn:async({signal:t})=>{let r=await l(`/api/quota/magpie`,{signal:t,query:{...e?{directory:e}:{},...n?{refresh:`1`}:{}}});if(!r.ok)throw Error(`Unable to discover Magpie quota sources`);let i=await r.json();if(!i||!Array.isArray(i.sources)||!i.sources.every(e=>e&&typeof e.id==`string`&&typeof e.name==`string`&&Array.isArray(e.results)&&e.results.every(t=>o(t)&&t.source===`magpie`&&t.sourceId===e.id&&t.providerId.startsWith(`magpie:${e.id}:`))))throw Error(`Invalid Magpie quota response`);return i}}),Yi=6e4,Xi=0,$=0,Zi,Qi=0,$i=0,ea=0,ta=new Map,na=e=>{let t=bn.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))):Yi,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}},ra=async()=>{let e=s()?.settings;if(e)try{let t=(await e.load())?.settings;return na(t??null)}catch{}if(!b()){let e=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(e.ok)return na(await e.json().catch(()=>null))}return{magpieUsageUrl:``,magpieHiddenProviders:[],autoRefresh:!1,refreshIntervalMs:Yi,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:bn.map(e=>e.id),selectedModels:{},expandedFamilies:{}}},ia=(e,t,n)=>{let r=e.filter(e=>e?.providerId&&e.providerId!==t);return o(n)&&r.push(n),r},aa=async(e,t)=>{let n=$;ta.set(e,(ta.get(e)??0)+1),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:!0}}));try{let r=await i.fetchQuery({queryKey:a.quota(e),queryFn:({signal:t})=>c(e,t),staleTime:0,retry:!1});if(n!==$)return{providerId:e,stale:!0};if(!o(r))throw Error(`Invalid quota response`);return t(t=>({results:ia(t.results,e,r)})),{providerId:e,result:r}}catch(r){return n===$?(t(e=>e.results.every(e=>e?.providerId)?{}:{results:e.results.filter(e=>e?.providerId)}),{providerId:e,error:r instanceof Error?r.message:`Failed to fetch quota`}):{providerId:e,stale:!0}}finally{if(n===$){let n=(ta.get(e)??1)-1;n>0?ta.set(e,n):ta.delete(e),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:n>0}}))}}},oa=()=>{Zi=void 0,Qi+=1,$+=1,Xi+=1,ta.clear(),sa.setState({magpieUsageUrl:``,magpieHiddenProviders:[],magpieSources:[],magpieError:null,results:[],isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null})},sa=w()(E((e,t)=>({magpieSources:[],magpieError:null,magpieHiddenProviders:[],magpieUsageUrl:``,results:[],selectedProviderId:null,isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null,autoRefresh:!1,refreshIntervalMs:Yi,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:bn.map(e=>e.id),selectedModels:{},expandedFamilies:{},loadSettings:async()=>{let t=$;try{let n=await ra();if(t!==$)return;e(e=>({...n,dropdownProviderIds:[...n.dropdownProviderIds.filter(e=>!e.startsWith(`magpie:`)),...e.results.filter(e=>e.source===`magpie`&&!n.magpieHiddenProviders.includes(e.providerId)).map(e=>e.providerId)]}))}catch(e){console.warn(`Failed to load usage settings:`,e)}},fetchAllQuotas:async()=>{let n=++Xi;e({isLoading:!0,error:null});let r=bn.map(e=>e.id),[i]=await Promise.all([Promise.all(r.map(t=>aa(t,e))),t().fetchMagpieQuotas(!0)]);if(n===Xi){let t=i.find(e=>`error`in e);e({isLoading:!1,...i.some(e=>`result`in e)?{lastUpdated:Date.now()}:{},error:t?.error??null})}},fetchProviderQuota:async n=>{if(n.startsWith(`magpie:`))return t().fetchMagpieQuotas(!0);let r=await aa(n,e);`stale`in r||e({error:`error`in r?r.error:null})},fetchMagpieQuotas:async(n=!1)=>{let r=$,a=A.getState().currentDirectory,o=t().magpieUsageUrl,s=JSON.stringify([a,o]);Zi!==s&&(Zi=s,Qi+=1,e(e=>({results:e.results.filter(e=>e?.source!==`magpie`),magpieSources:[],magpieError:null})));let c=Qi,l=++$i;try{let{sources:s,incomplete:u}=await i.fetchQuery(Ji(a,o,n));if(r!==$||c!==Qi||l<ea||a!==A.getState().currentDirectory||o!==t().magpieUsageUrl)return;ea=l,e(e=>{let t=new Map(s.filter(e=>e.error&&!e.clearPrevious&&e.results.length===0).map(e=>[e.id,e.error]));if(u){let n=new Set(s.map(e=>e.id));for(let r of e.results)r.sourceId&&!n.has(r.sourceId)&&t.set(r.sourceId,`Magpie discovery is incomplete`)}let n=e.results.filter(e=>e?.providerId&&(e.source!==`magpie`||t.has(e.sourceId??``))).map(e=>e.source===`magpie`&&t.has(e.sourceId??``)?{...e,ok:!1,error:t.get(e.sourceId??``)}:e);n.push(...s.flatMap(e=>e.results));let r=n.filter(e=>e.source===`magpie`).map(e=>e.providerId);return{results:n,magpieSources:s,magpieError:null,dropdownProviderIds:[...e.dropdownProviderIds.filter(e=>!e.startsWith(`magpie:`)),...r.filter(t=>!e.magpieHiddenProviders.includes(t))]}})}catch(n){if(r!==$||c!==Qi||l<ea||a!==A.getState().currentDirectory||o!==t().magpieUsageUrl)return;ea=l,e({magpieError:n instanceof Error?n.message:`Unable to read Magpie quotas`})}},setSelectedProvider:t=>e({selectedProviderId:t}),setAutoRefresh:t=>e({autoRefresh:t}),setRefreshInterval:t=>{e({refreshIntervalMs:Math.max(3e4,Math.min(3e5,Math.round(t)))})},setDisplayMode:t=>e({displayMode:t}),setShowPredValues:t=>e({showPredValues:t}),setDropdownProviderIds:n=>{let r=t().results.filter(e=>e.source===`magpie`),i=new Set(r.map(e=>e.providerId));e({dropdownProviderIds:n,magpieHiddenProviders:[...t().magpieHiddenProviders.filter(e=>!i.has(e)),...r.filter(e=>!n.includes(e.providerId)).map(e=>e.providerId)]})},setSelectedModels:(t,n)=>{e(e=>({selectedModels:{...e.selectedModels,[t]:n}}))},toggleModelSelected:(t,n)=>{e(e=>{let r=e.selectedModels[t]??[],i=r.includes(n)?r.filter(e=>e!==n):[...r,n];return{selectedModels:{...e.selectedModels,[t]:i}}})},setExpandedFamilies:(n,r)=>{e(e=>({expandedFamilies:{...e.expandedFamilies,[n]:r}})),_({usageExpandedFamilies:t().expandedFamilies})},toggleFamilyExpanded:(n,r)=>{e(e=>{let t=e.expandedFamilies[n]??[],i=t.includes(r)?t.filter(e=>e!==r):[...t,r];return{expandedFamilies:{...e.expandedFamilies,[n]:i}}}),_({usageExpandedFamilies:t().expandedFamilies})},applyDefaultSelections:(n,r)=>{if((t().selectedModels[n]?.length??0)>0)return;let i=qi(n,r);i.length!==0&&(e(e=>({selectedModels:{...e.selectedModels,[n]:i}})),_({usageSelectedModels:t().selectedModels}))}}),{name:`quota-store`})),ca=()=>{let e=(0,X.c)(11),t=A(la),n=sa(ua),r=sa(da),i;e[0]===r?i=e[1]:(i=()=>{r()},e[0]=r,e[1]=i);let a;e[2]!==t||e[3]!==r||e[4]!==n?(a=[t,n,r],e[2]=t,e[3]=r,e[4]=n,e[5]=a):a=e[5],Q.useEffect(i,a);let o=sa(fa),s=sa(pa),c=sa(ma),l,u;e[6]!==o||e[7]!==c||e[8]!==s?(l=()=>{if(!o)return;let e=window.setInterval(()=>{c()},s);return()=>window.clearInterval(e)},u=[o,s,c],e[6]=o,e[7]=c,e[8]=s,e[9]=l,e[10]=u):(l=e[9],u=e[10]),Q.useEffect(l,u)};function la(e){return e.currentDirectory}function ua(e){return e.magpieUsageUrl}function da(e){return e.fetchMagpieQuotas}function fa(e){return e.autoRefresh}function pa(e){return e.refreshIntervalMs}function ma(e){return e.fetchAllQuotas}var ha=e=>{let t=(0,X.c)(20),{percent:n,tonePercent:r,className:i,expectedMarkerPercent:a}=e,o;t[0]===n?o=t[1]:(o=Lt(n)??0,t[0]=n,t[1]=o);let s=o,c=r??n,l;t[2]===c?l=t[3]:(l=St(c),t[2]=c,t[3]=l);let u=l,d=a==null?null:Math.max(0,Math.min(100,a)),f;t[4]===u?f=t[5]:(f=u===`critical`?{backgroundColor:`var(--status-error)`}:u===`warn`?{backgroundColor:`var(--status-warning)`}:{backgroundColor:`var(--status-success)`},t[4]=u,t[5]=f);let p=f,m;t[6]===i?m=t[7]:(m=K(`relative h-2.5 rounded-full bg-[var(--interactive-border)] overflow-hidden`,i),t[6]=i,t[7]=m);let h=`${s}%`,g;t[8]!==p||t[9]!==h?(g={...p,width:h},t[8]=p,t[9]=h,t[10]=g):g=t[10];let _;t[11]!==s||t[12]!==g?(_=(0,Z.jsx)(`div`,{className:`h-full transition-all duration-300`,style:g,role:`progressbar`,"aria-valuenow":s,"aria-valuemin":0,"aria-valuemax":100}),t[11]=s,t[12]=g,t[13]=_):_=t[13];let v;t[14]===d?v=t[15]:(v=d!=null&&d>0&&d<100&&(0,Z.jsx)(`div`,{className:`absolute top-0 h-full w-0.5 bg-foreground`,style:{left:`${d}%`},title:`Expected usage if spread evenly: ${Math.round(d)}% of quota`,"aria-hidden":`true`}),t[14]=d,t[15]=v);let y;return t[16]!==m||t[17]!==_||t[18]!==v?(y=(0,Z.jsxs)(`div`,{className:m,children:[_,v]}),t[16]=m,t[17]=_,t[18]=v,t[19]=y):y=t[19],y},ga=e=>{let t=(0,X.c)(67),{paceInfo:n,className:r,compact:i}=e,a=i!==void 0&&i,{t:o}=G(),s;t[0]===n.status?s=t[1]:(s=kt(n.status),t[0]=n.status,t[1]=s);let c=s,l;bb0:{switch(n.status){case`on-track`:{let e;t[2]===o?e=t[3]:(e=o(`settings.usage.pace.status.onTrack`),t[2]=o,t[3]=e),l=e;break bb0}case`slightly-fast`:{let e;t[4]===o?e=t[5]:(e=o(`settings.usage.pace.status.slightlyFast`),t[4]=o,t[5]=e),l=e;break bb0}case`too-fast`:{let e;t[6]===o?e=t[7]:(e=o(`settings.usage.pace.status.tooFast`),t[6]=o,t[7]=e),l=e;break bb0}case`exhausted`:{let e;t[8]===o?e=t[9]:(e=o(`settings.usage.pace.status.usedUp`),t[8]=o,t[9]=e),l=e;break bb0}}l=void 0}let u=l,d;t[10]!==n.predictText||t[11]!==o?(d=o(`settings.usage.pace.predictionTooltip`,{prediction:n.predictText}),t[10]=n.predictText,t[11]=o,t[12]=d):d=t[12];let f=d;if(a){let e;t[13]===r?e=t[14]:(e=K(`flex items-center gap-1.5`,r),t[13]=r,t[14]=e);let i;t[15]===c?i=t[16]:(i={backgroundColor:c},t[15]=c,t[16]=i);let a;t[17]!==u||t[18]!==i?(a=(0,Z.jsx)(`div`,{className:`h-2 w-2 rounded-full flex-shrink-0`,style:i,title:u}),t[17]=u,t[18]=i,t[19]=a):a=t[19];let s;t[20]===c?s=t[21]:(s={color:c},t[20]=c,t[21]=s);let l=n.isExhausted?void 0:f,d;t[22]!==n.isExhausted||t[23]!==n.predictText||t[24]!==n.remainingSeconds||t[25]!==o?(d=n.isExhausted?(0,Z.jsx)(Z.Fragment,{children:o(`settings.usage.pace.wait`,{duration:Ot(n.remainingSeconds)})}):(0,Z.jsx)(Z.Fragment,{children:o(`settings.usage.pace.prediction`,{prediction:n.predictText})}),t[22]=n.isExhausted,t[23]=n.predictText,t[24]=n.remainingSeconds,t[25]=o,t[26]=d):d=t[26];let p;t[27]!==d||t[28]!==s||t[29]!==l?(p=(0,Z.jsx)(`span`,{className:`typography-micro tabular-nums`,style:s,title:l,children:d}),t[27]=d,t[28]=s,t[29]=l,t[30]=p):p=t[30];let m;return t[31]!==p||t[32]!==e||t[33]!==a?(m=(0,Z.jsxs)(`div`,{className:e,children:[a,p]}),t[31]=p,t[32]=e,t[33]=a,t[34]=m):m=t[34],m}let p;t[35]===r?p=t[36]:(p=K(`flex items-center justify-between gap-2`,r),t[35]=r,t[36]=p);let m;t[37]!==n.isExhausted||t[38]!==n.paceRateText||t[39]!==o?(m=!n.isExhausted&&(0,Z.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:o(`settings.usage.pace.rate`,{rate:n.paceRateText})}),t[37]=n.isExhausted,t[38]=n.paceRateText,t[39]=o,t[40]=m):m=t[40];let h;t[41]===m?h=t[42]:(h=(0,Z.jsx)(`div`,{className:`flex items-center gap-1.5`,children:m}),t[41]=m,t[42]=h);let g;t[43]===c?g=t[44]:(g={color:c},t[43]=c,t[44]=g);let _;t[45]!==n.isExhausted||t[46]!==n.predictText||t[47]!==n.remainingSeconds||t[48]!==f||t[49]!==u||t[50]!==o?(_=n.isExhausted?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:u}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.waitSeparator`)}),(0,Z.jsx)(`span`,{className:`font-medium`,children:Ot(n.remainingSeconds)})]}):(0,Z.jsxs)(`span`,{title:f,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.predictionLabel`)}),(0,Z.jsx)(`span`,{className:`font-medium`,children:n.predictText})]}),t[45]=n.isExhausted,t[46]=n.predictText,t[47]=n.remainingSeconds,t[48]=f,t[49]=u,t[50]=o,t[51]=_):_=t[51];let v;t[52]!==g||t[53]!==_?(v=(0,Z.jsx)(`span`,{className:`typography-micro tabular-nums`,style:g,children:_}),t[52]=g,t[53]=_,t[54]=v):v=t[54];let y;t[55]===c?y=t[56]:(y={backgroundColor:c},t[55]=c,t[56]=y);let b;t[57]!==u||t[58]!==y?(b=(0,Z.jsx)(`div`,{className:`h-2 w-2 rounded-full flex-shrink-0`,style:y,title:u}),t[57]=u,t[58]=y,t[59]=b):b=t[59];let x;t[60]!==v||t[61]!==b?(x=(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[v,b]}),t[60]=v,t[61]=b,t[62]=x):x=t[62];let S;return t[63]!==x||t[64]!==p||t[65]!==h?(S=(0,Z.jsxs)(`div`,{className:p,children:[h,x]}),t[63]=x,t[64]=p,t[65]=h,t[66]=S):S=t[66],S},_a=e=>e instanceof Error&&e.name===`CancelledError`,va=w(()=>({setStatus:e=>Ct(i,e),refreshStatus:async(e,t)=>{let r=n();t?.force&&await i.cancelQueries({queryKey:a.github.auth(r),exact:!0});try{return await jt(i,e,r)}catch(e){if(_a(e))return At(i,r);throw e}}})),ya={displayMode:`browser`,installed:!1,browserTab:!0},ba=new Set,xa=ya,Sa=!1,Ca,wa=()=>{let e=Pt();return{displayMode:e,installed:e!==`browser`,browserTab:e===`browser`}},Ta=()=>(!Sa&&typeof window<`u`&&(xa=wa(),Sa=!0),xa),Ea=()=>{let e=wa();Sa=!0,e.displayMode!==xa.displayMode&&(xa=e,ba.forEach(e=>e()))},Da=()=>{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`,Ea):typeof t.addListener==`function`&&t.addListener(Ea);return window.addEventListener(`appinstalled`,Ea),window.addEventListener(`focus`,Ea),()=>{for(let t of e)typeof t.removeEventListener==`function`?t.removeEventListener(`change`,Ea):typeof t.removeListener==`function`&&t.removeListener(Ea);window.removeEventListener(`appinstalled`,Ea),window.removeEventListener(`focus`,Ea)}},Oa=e=>(ba.add(e),Ca??=Da(),Ea(),()=>{ba.delete(e),ba.size===0&&(Ca?.(),Ca=void 0)}),ka=()=>Q.useSyncExternalStore(Oa,Ta,Aa);function Aa(){return ya}var ja=`Yuri`,Ma=w()(T(e=>({sidebarBrandName:ja,setSidebarBrandName:t=>{let n=t.slice(0,64);e(e=>e.sidebarBrandName===n?e:{sidebarBrandName:n})}}),{name:`sidebar-brand-store`,storage:p(),version:3,migrate:(e,t)=>{if(!e||typeof e!=`object`)return e;let n={...e};return t<1&&n.sidebarBrandName===`YEE CODE`&&(n.sidebarBrandName=ja),t<2&&n.sidebarBrandName===`Open Chamber`&&(n.sidebarBrandName=ja),t<3&&(n.sidebarBrandName===`OPEN CHAMBER`||n.sidebarBrandName===`Open Chamber`)&&(n.sidebarBrandName=ja),n}}));typeof window<`u`&&t(e=>{r(e)&&Ma.persist.rehydrate()});var Na=(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,Pa=(e,t,n)=>{Na(e.get(t),n)&&e.set(t,n)},Fa=e=>{let t=e;return h(t.directory)??h(t.project?.worktree)},Ia=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)},La=(e,t,n,r,i=[])=>{let a=new Map,o=new Map;for(let e of t){let t=h(e.normalizedPath);if(!t)continue;let n=o.get(t);(!n||e.id.localeCompare(n.id)<0)&&o.set(t,e),Pa(a,t,{projectId:e.id,projectRoot:t,scopeDirectory:t,kind:`project`})}if(!r)for(let[e,t]of n){let n=h(e),r=n?o.get(n):void 0;if(!(!r||!n))for(let e of t){let t=h(e.path);t&&Pa(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=Ia(n)}for(let e of t)s.set(e,i);return i},p=(e,t,n)=>{for(let r of e){let e=f(Fa(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}},Ra=`__other__`;function za(e){return e.time?.updated??e.time?.archived??e.time?.created??0}function Ba({mode:e=`dialog`}){let{t}=G(),{isMobile:n,isTablet:r,hasTouchInput:i}=Ut(),a=n||r||i,o=e===`page`,s=I(e=>e.isArchivedSessionsDialogOpen),c=I(e=>e.setArchivedSessionsDialogOpen),l=o||s,u=Ie(e=>e.projects),d=Me(e=>e.archivedSessions),f=Pe(e=>e.setCurrentSession),p=I(e=>e.setSettingsDialogOpen),[m,h]=Q.useState(!1),[g,_]=Q.useState(null),[v,y]=Q.useState(null);Q.useEffect(()=>{if(!l){_(null),y(null);return}let e=!1;return h(!0),Ke().catch(()=>{e||J.error(t(`settings.yuri.archivedSessions.toast.loadFailed`))}).finally(()=>{e||h(!1)}),()=>{e=!0}},[l,t]);let x=Q.useMemo(()=>{let e=La([],u.map(e=>({id:e.id,normalizedPath:e.path})),new Map,b(),d),n=new Map;for(let[t,r]of e.archivedSessionsByProject)n.set(t,[...r].sort((e,t)=>za(t)-za(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)=>za(t)-za(e));i.length>0&&n.set(Ra,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(Ra);return o&&o.length>0&&a.push({projectId:Ra,label:t(`settings.yuri.archivedSessions.otherProjects`),path:null,sessions:o}),a.sort((e,t)=>t.sessions.length-e.sessions.length||e.label.localeCompare(t.label)),a},[d,u,t]),S=d.length,C=g?x.find(e=>e.projectId===g)??null:null,w=Q.useCallback(async e=>{y(e.id);try{await Le(e.id)?J.success(t(`settings.yuri.archivedSessions.toast.restored`)):J.error(t(`settings.yuri.archivedSessions.toast.restoreFailed`))}finally{y(null)}},[t]),T=Q.useCallback(e=>{let t=ze(e);f(e.id,t),c(!1),p(!1)},[f,c,p]),E=C?C.label:t(`settings.yuri.archivedSessions.dialog.title`),D=C?C.sessions.length===1?t(`settings.yuri.archivedSessions.dialog.sessionCountSingle`,{count:C.sessions.length}):t(`settings.yuri.archivedSessions.dialog.sessionCountPlural`,{count:C.sessions.length}):t(`settings.yuri.archivedSessions.dialog.description`),O=(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[C?(0,Z.jsxs)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`!h-7 !px-2 !font-normal text-muted-foreground`,onClick:()=>_(null),children:[(0,Z.jsx)(Y,{name:`arrow-left-s`,className:`mr-1 h-4 w-4`}),t(`settings.yuri.archivedSessions.dialog.backToProjects`)]}):null,m?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 typography-meta text-muted-foreground py-6`,children:[(0,Z.jsx)(Y,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),t(`settings.yuri.archivedSessions.dialog.loading`)]}):C?C.sessions.length===0?(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:t(`settings.yuri.archivedSessions.dialog.emptyProject`)}):(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:C.sessions.map(e=>{let n=ze(e),r=za(e),i=v===e.id;return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-border/60 px-3 py-2.5 sm:flex-row sm:items-center sm:gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`typography-ui-label font-medium text-foreground truncate`,children:e.title||t(`sessions.sidebar.session.untitled`)}),(0,Z.jsxs)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:[r>0?Ht(r):null,r>0&&n?` · `:null,n?ke(n):null]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,Z.jsx)(q,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,disabled:i,onClick:()=>T(e),children:t(`settings.yuri.archivedSessions.actions.preview`)}),(0,Z.jsxs)(q,{type:`button`,variant:`default`,size:`xs`,className:`!font-normal`,disabled:i,onClick:()=>void w(e),children:[i?(0,Z.jsx)(Y,{name:`loader-4`,className:`mr-1 h-3.5 w-3.5 animate-spin`}):(0,Z.jsx)(Y,{name:`inbox-unarchive`,className:`mr-1 h-3.5 w-3.5`}),t(`settings.yuri.archivedSessions.actions.restore`)]})]})]},e.id)})}):x.length===0?(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:t(`settings.yuri.archivedSessions.dialog.empty`)}):(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:x.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>_(e.projectId),className:K(`flex w-full items-center gap-3 rounded-lg border border-border/60 px-3 py-2.5 text-left`,`hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`),children:[(0,Z.jsx)(Y,{name:`folder`,className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`typography-ui-label font-medium text-foreground truncate`,children:e.label}),e.path?(0,Z.jsx)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:ke(e.path)}):null]}),(0,Z.jsx)(`span`,{className:`typography-meta tabular-nums text-muted-foreground shrink-0`,children:e.sessions.length===1?t(`settings.yuri.archivedSessions.dialog.sessionCountSingle`,{count:e.sessions.length}):t(`settings.yuri.archivedSessions.dialog.sessionCountPlural`,{count:e.sessions.length})}),(0,Z.jsx)(Y,{name:`arrow-right-s`,className:`h-4 w-4 shrink-0 text-muted-foreground`})]},e.projectId))}),!C&&!m&&S>0?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(S===1?`settings.yuri.archivedSessions.summarySingle`:`settings.yuri.archivedSessions.summaryPlural`,{count:S})}):null]});return o?(0,Z.jsxs)(`div`,{"data-settings-item":`archived-sessions.manage`,className:`yuri-settings-section-stack`,children:[(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.archivedSessions.description`)}),O]}):a?(0,Z.jsx)(Rt,{open:s,title:E,onClose:()=>c(!1),contentMaxHeightClassName:`max-h-[min(80vh,640px)]`,renderHeader:e=>(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border/40 px-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:E}),e]}),(0,Z.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:D})]}),children:O}):(0,Z.jsx)(Qe,{open:s,onOpenChange:c,children:(0,Z.jsxs)(Ye,{className:`max-h-[85vh] max-w-2xl overflow-y-auto`,children:[(0,Z.jsxs)(Je,{children:[(0,Z.jsx)(Xe,{children:E}),(0,Z.jsx)(Ze,{children:D})]}),O]})})}function Va(){let e=(0,X.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(Ba,{mode:`dialog`}),e[0]=t):t=e[0],t}var Ha=48;function Ua({title:e,eyebrow:t,trailing:n,className:r}){let i=(0,Q.useRef)(null),a=(0,Q.useRef)(null),o=(0,Q.useRef)(null),s=(0,Q.useRef)(null),c=(0,Q.useRef)(null),l=Oe(()=>{s.current=null;let e=i.current,t=a.current;if(!e||!t)return;let n=Math.min(1,Math.max(0,t.scrollTop/Ha)),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=Oe(()=>{s.current===null&&(s.current=window.requestAnimationFrame(l))});return(0,Q.useEffect)(()=>{let e=i.current;if(!e)return;let t=e.closest(`.yuri-mobile-settings-root-surface, [role="tabpanel"]`);if(!t)return;let n=window.matchMedia(`(prefers-reduced-motion: reduce)`);return a.current=t,o.current=n,c.current=null,t.addEventListener(`scroll`,u,{passive:!0}),n.addEventListener(`change`,u),l(),()=>{t.removeEventListener(`scroll`,u),n.removeEventListener(`change`,u),s.current!==null&&window.cancelAnimationFrame(s.current),s.current=null,a.current=null,o.current=null,c.current=null}},[]),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`header`,{ref:i,className:K(`yuri-mobile-collapsing-header flex shrink-0 items-start gap-4`,r),children:(0,Z.jsxs)(`div`,{className:`yuri-mobile-collapsing-header-inner`,children:[(0,Z.jsxs)(`div`,{className:`yuri-mobile-collapsing-header-title-block min-w-0 flex-1`,children:[t?(0,Z.jsx)(`p`,{className:`yuri-mobile-collapsing-header-eyebrow truncate typography-micro font-medium text-muted-foreground`,children:t}):null,(0,Z.jsx)(`h1`,{className:`yuri-mobile-root-page-title truncate font-semibold text-foreground`,children:e})]}),n?(0,Z.jsx)(`div`,{className:`yuri-mobile-collapsing-header-trailing flex min-h-10 shrink-0 items-center gap-3.5`,children:n}):null]})}),(0,Z.jsx)(`div`,{className:`yuri-mobile-collapsing-header-spacer`,"aria-hidden":`true`})]})}export{wr as A,xn as B,gi as C,Xr as D,ii as E,mr as F,nr as I,kn as L,gr as M,vr as N,xr as O,yr as P,Sn as R,_i as S,ri as T,Wi as _,Ma as a,wi as b,ga as c,ca as d,sa as f,Ki as g,Gi as h,La as i,_r as j,Cr as k,ha as l,Bi as m,Va as n,ka as o,Ui as p,Ba as r,va as s,Ua as t,oa as u,zi as v,ai as w,vi as x,Fi as y,bn as z};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-capacitor-app-B5H_XtmE.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js"])))=>i.map(i=>d[i]);
2
- import{f as e,g as t,h as n,l as r,p as i}from"./runtime-auth-ef9W7A43.js";import{a,d as o,f as s,i as c,p as l,u}from"./runtime-switch-CAZiOV2G.js";import{l as d,u as f}from"./queryRuntime-DKGLQtb9.js";import{tt as ee}from"./persistence-Dzooc9Xg.js";import{t as te}from"./desktopRelayRestore-C_23nlKD.js";import{$ as ne,A as re,B as ie,Ct as ae,D as oe,E as se,F as ce,H as le,I as ue,J as de,L as fe,M as pe,N as me,P as he,Q as ge,R as _e,S as ve,T as ye,U as be,V as xe,W as Se,X as Ce,Y as p,Z as we,_ as Te,_t as Ee,a as De,at as Oe,b as ke,bt as Ae,c as je,ct as Me,d as Ne,dt as Pe,et as Fe,f as Ie,ft as Le,g as Re,gt as ze,h as Be,ht as Ve,i as He,j as Ue,k as We,l as Ge,lt as Ke,m as qe,mt as Je,n as m,nt as Ye,o as Xe,ot as Ze,p as Qe,pt as $e,q as et,s as tt,st as nt,t as rt,tt as it,u as at,ut as ot,v as h,vt as st,x as g,y as ct,yt as _}from"./platform-7bX6qtBV.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{s as lt}from"./runtime-file-resource-C1k5nbWb.js";import{n as v,o as y}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{a as ut,c as dt,l as ft,n as pt,r as mt,s as ht,t as gt}from"./terminalApi-BHXvha-U.js";import{t as _t}from"./runtime-file-download-DAOam_oV.js";import{r as vt,t as b}from"./types-Q_utERET.js";import{n as x,t as S}from"./capgoAdapter-DLi2tcmI.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var yt=e=>{let t=e?.retry;return{maxRetries:t?.maxRetries??3,initialRetryDelay:t?.initialDelayMs??1e3,maxRetryDelay:t?.maxDelayMs??8e3,connectionTimeout:e?.connectionTimeoutMs??1e4}},bt=()=>({async createSession(e){return mt(e)},connect(e,t,n){let r=pt(e,t.onEvent,t.onError,yt(n));return{close:()=>r()}},async sendInput(e,t){await ft(e,t)},async resize(e){await ht(e.sessionId,e.cols,e.rows)},async close(e){await gt(e)},async restartSession(e,t){return dt(e,{cwd:t.cwd??``,cols:t.cols,rows:t.rows})},async forceKill(e){await ut(e)}}),xt=()=>({checkIsGitRepository:je,getGitStatus:fe,getGitDiff:me,getGitFileDiff:he,revertGitFile:Ze,stageGitFile:Ke,stageGitFiles:ot,unstageGitFile:Ve,unstageGitFiles:ze,stageGitHunk:Pe,unstageGitHunk:Ee,revertGitHunk:nt,isLinkedWorktree:et,getGitBranches:pe,deleteGitBranch:ct,deleteRemoteBranch:ve,removeRemote:Fe,generateCommitMessage:se,generatePullRequestDescription:oe,listGitWorktrees:p,validateGitWorktree:_,createGitWorktree:h,deleteGitWorktree:g,validateWorktreeDirectory:Ae,canonicalizeWorktreeState:tt,createGitCommit(e,t,n){return Re(e,t,n)},gitPush:be,gitPull:le,gitFetch:xe,listGitStashes:de,countGitStashFiles:qe,stashGitChanges:$e,applyGitStash:Xe,popGitStash:we,dropGitStash:ye,checkoutBranch:Ge,createBranch:Be,renameBranch:it,getGitLog(e,t){return ue(e,t)},getCommitFiles:We,getCurrentGitIdentity:Ue,hasLocalIdentity:Se,setGitIdentity:Me,getGitIdentities:ce,createGitIdentity:Te,updateGitIdentity:st,deleteGitIdentity:ke,getRemotes:ie,rebase:ne,abortRebase:De,continueRebase:Qe,merge:Ce,abortMerge:He,continueMerge:Ie,checkoutCommit:at,cherryPick:Ne,revertCommit:Oe,resetToCommit:Ye,stash:Le,stashPop:Je,getConflictDetails:re,worktree:{list:p,validate:_,bootstrapStatus:_e,preview:ge,create:h,remove:g}}),C=e=>e.replace(/\\/g,`/`),St=(e,t)=>({directory:C(t?.directory||t?.path||e),entries:(Array.isArray(t?.entries)?t.entries:[]).filter(e=>!!(e&&typeof e.name==`string`&&typeof e.path==`string`)).map(e=>({name:e.name,path:C(e.path),isDirectory:!!e.isDirectory}))}),w=(e,t)=>{let n=t||e?.();return n?{"x-opencode-directory":n}:void 0},Ct=({getDirectory:e})=>({async listDirectory(t,n){let r=C(t),i=new URLSearchParams;r&&i.set(`path`,r),n?.respectGitignore&&i.set(`respectGitignore`,`true`);let a=await f(`/api/fs/list`,{query:i,headers:w(e)});if(!a.ok){let e=await a.json().catch(()=>({error:a.statusText}));throw Error(e.error||`Failed to list directory`)}return St(r,await a.json())},async search(t){let n=new URLSearchParams,r=C(t.directory);r&&n.set(`directory`,r),n.set(`query`,t.query),n.set(`dirs`,`false`),n.set(`type`,`file`),typeof t.maxResults==`number`&&Number.isFinite(t.maxResults)&&n.set(`limit`,String(t.maxResults));let i=await f(`/api/find/file`,{query:n,headers:w(e)});if(!i.ok){let e=await i.json().catch(()=>({error:i.statusText}));throw Error(e.error||`Failed to search files`)}let a=await i.json();return(Array.isArray(a)?a:[]).map(e=>({path:C(`${r}/${e}`),preview:[C(e)]}))},async createDirectory(t){let n=C(t),r=await f(`/api/fs/mkdir`,{method:`POST`,headers:{"Content-Type":`application/json`,...w(e)},body:JSON.stringify({path:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to create directory`)}let i=await r.json();return{success:!!i?.success,path:typeof i?.path==`string`?C(i.path):n}},async statFile(t,n){let r=C(t),i=new URLSearchParams({path:r});n?.fingerprint&&i.set(`fingerprint`,`true`),n?.allowOutsideWorkspace&&i.set(`allowOutsideWorkspace`,`true`),n?.outsideFileGrant&&i.set(`outsideFileGrant`,n.outsideFileGrant);let a=await f(`/api/fs/stat`,{query:i,headers:w(e,n?.directory)});if(!a.ok){let e=await a.json().catch(()=>({error:a.statusText}));throw Error(e.error||`Failed to stat file`)}let o=await a.json().catch(()=>({}));return{path:typeof o.path==`string`?C(o.path):r,isFile:!!o.isFile,size:typeof o.size==`number`?o.size:0,mtimeMs:typeof o.mtimeMs==`number`?o.mtimeMs:void 0,sha256:typeof o.sha256==`string`?o.sha256:void 0,mimeType:typeof o.mimeType==`string`?o.mimeType:void 0,filename:typeof o.filename==`string`?o.filename:void 0,isBinary:typeof o.isBinary==`boolean`?o.isBinary:void 0}},async readFile(t,n){let r=C(t);if(!n?.optional)return{content:await(await lt({path:r,...n,directory:n?.directory??e?.()})).text(),path:r,exists:!0};let i=new URLSearchParams({path:r});n?.allowOutsideWorkspace&&i.set(`allowOutsideWorkspace`,`true`),n?.outsideFileGrant&&i.set(`outsideFileGrant`,n.outsideFileGrant),n?.optional&&i.set(`optional`,`true`);let a=await f(`/api/fs/read`,{query:i,cache:n?.optional?`no-store`:`default`,headers:w(e,n?.directory)});if(!a.ok){let e=await a.json().catch(()=>({error:a.statusText}));throw Error(e.error||`Failed to read file`)}let o=await a.text();if(n?.optional){let e=a.headers.get(`x-yuri-file-exists`);if(e!==`true`&&e!==`false`)throw Error(`Optional file read requires an existence response header`);return{content:o,path:r,exists:e===`true`}}return{content:o,path:r,exists:!0}},async writeFile(t,n){let r=C(t),i=await f(`/api/fs/write`,{method:`POST`,headers:{"Content-Type":`application/json`,...w(e)},body:JSON.stringify({path:r,content:n})});if(!i.ok){let e=await i.json().catch(()=>({error:i.statusText}));throw Error(e.error||`Failed to write file`)}let a=await i.json().catch(()=>({}));return{success:!!a.success,path:typeof a.path==`string`?C(a.path):r}},async delete(t){let n=C(t),r=await f(`/api/fs/delete`,{method:`POST`,headers:{"Content-Type":`application/json`,...w(e)},body:JSON.stringify({path:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to delete file`)}return{success:!!(await r.json().catch(()=>({}))).success}},async rename(t,n){let r=await f(`/api/fs/rename`,{method:`POST`,headers:{"Content-Type":`application/json`,...w(e)},body:JSON.stringify({oldPath:t,newPath:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to rename file`)}let i=await r.json().catch(()=>({}));return{success:!!i.success,path:typeof i.path==`string`?C(i.path):n}},async revealPath(t){let n=await f(`/api/fs/reveal`,{method:`POST`,headers:{"Content-Type":`application/json`,...w(e)},body:JSON.stringify({path:C(t)})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to reveal path`)}return{success:!!(await n.json().catch(()=>({}))).success}},async downloadFile(t){let n=C(t);await _t({path:n,directory:e?.()})}}),T=`/api/config/settings`,wt=`/api/config/reload`,E=e=>!e||typeof e!=`object`?{}:e,Tt=()=>({async load(){let e=await f(T,{method:`GET`,headers:{Accept:`application/json`}});if(!e.ok)throw Error(`Failed to load settings: ${e.statusText}`);return{settings:E(await e.json().catch(()=>({}))),source:`web`}},async save(e){let t=await f(T,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to save settings`)}return E(await t.json().catch(()=>({})))},async restartOpenCode(){let e=await f(wt,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({error:e.statusText}));throw Error(t.error||`Failed to restart OpenCode`)}return{restarted:!0}}}),Et=()=>({async requestDirectoryAccess(e){return{success:!0,path:e.path}},async startAccessingDirectory(e){return{success:!0}},async stopAccessingDirectory(e){return{success:!0}}}),Dt=1500,D=5e3,Ot=`yuri-notification-claim:`,O=new Map,kt=()=>typeof document>`u`||document.visibilityState===`visible`&&document.hasFocus(),At=e=>(typeof e?.tag==`string`?e.tag.trim():``)||[e?.sessionId,e?.kind,e?.title,e?.body].filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).join(`|`),jt=e=>{for(let[t,n]of O)e-n>D&&O.delete(t)},Mt=e=>{let t=At(e);if(!t)return!0;let n=Date.now();if(jt(n),n-(O.get(t)??0)<D)return!1;try{if(typeof window<`u`&&window.localStorage){let e=`${Ot}${t}`,r=Number(window.localStorage.getItem(e)??`0`);if(Number.isFinite(r)&&n-r<D)return O.set(t,r),!1;Number.isFinite(r)&&r>0&&window.localStorage.removeItem(e),window.localStorage.setItem(e,String(n))}}catch{}return O.set(t,n),!0},k=async()=>{if(typeof navigator>`u`||!(`serviceWorker`in navigator))return null;let e=null;try{e=await navigator.serviceWorker.getRegistration()??null}catch{e=null}if(e?.active)return e;if(!e)return null;try{return await Promise.race([navigator.serviceWorker.ready,new Promise(e=>{setTimeout(()=>e(null),Dt)})])??e}catch{return e}},Nt=async e=>{let t=await k();if(!t||typeof t.showNotification!=`function`)return!1;try{return await t.showNotification(e?.title??`Yuri`,{body:e?.body,tag:e?.tag}),!0}catch(e){return console.warn(`Failed to send notification via service worker`,e),!1}},Pt=async()=>{let e=await k();if(!e||!(`pushManager`in e)||!e.pushManager)return!1;try{return!!await e.pushManager.getSubscription()}catch{return!1}},Ft=async e=>{if(e?.requireHidden&&typeof document<`u`&&document.hasFocus())return!0;if(typeof Notification>`u`)return!1;if(Notification.permission==="default"&&await Notification.requestPermission()!==`granted`||Notification.permission!==`granted`)return console.warn(`Notification permission not granted`),!1;if(!kt()&&await Pt()||!Mt(e))return!0;try{return await Nt(e)||new Notification(e?.title??`Yuri`,{body:e?.body,tag:e?.tag}),!0}catch(e){return console.warn(`Failed to send notification`,e),!1}},It=async e=>{if(typeof window>`u`)return!1;let t=window.__YURI_DESKTOP__;if(!t?.invoke)return!1;try{return await t.invoke(`desktop_notify`,{payload:{title:e?.title,body:e?.body,tag:e?.tag,kind:e?.kind,sessionId:e?.sessionId,directory:e?.directory,requireHidden:e?.requireHidden}}),!0}catch(e){return console.warn(`Failed to send native notification (desktop)`,e),!1}},Lt=()=>({async notifyAgentCompletion(e){return await It(e)||await Ft(e)},canNotify:()=>typeof window<`u`&&window.__YURI_DESKTOP__?.invoke?!0:typeof Notification<`u`&&Notification.permission===`granted`}),Rt=()=>({async getAvailableTools(){let e=await f(`/api/experimental/tool/ids`);if(!e.ok)throw Error(`Tools API returned ${e.status} ${e.statusText}`);let t=await e.json();if(!Array.isArray(t))throw Error(`Tools API returned invalid data format`);return t.filter(e=>typeof e==`string`&&e!==`invalid`).sort()}}),A=async(e,t)=>{let n=c();try{let r=await vt();return c()===n?j(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t,...r?{bundleId:r}:{}})}):null}catch{return null}},j=async(e,t)=>{try{let n=await f(e,{...t,credentials:`include`,headers:{Accept:`application/json`,...t?.headers??{}}});return n.ok?await n.json():null}catch{return null}},zt=()=>({async getVapidPublicKey(){return j(`/api/push/vapid-public-key`)},async subscribe(e){return j(`/api/push/subscribe`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async unsubscribe(e){return j(`/api/push/subscribe`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async setVisibility(e){return j(`/api/push/visibility`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),keepalive:!0})},async registerApnsToken(e){return A(`/api/push/apns-token`,e)},async unregisterApnsToken(e){return j(`/api/push/apns-token`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async registerLiveActivityToken(e){return A(`/api/push/live-activity-token`,e)},async unregisterLiveActivityToken(e){return j(`/api/push/live-activity-token`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})}}),M=async e=>await e.json().catch(()=>null),Bt=({urls:e})=>({async authStatus(){let e=await f(`/api/github/auth/status`,{method:`GET`,headers:{Accept:`application/json`}}),t=await M(e);if(!e.ok||!t)throw Error(t?.error||e.statusText||`Failed to load GitHub status`);return t},async authStart(){let e=await f(`/api/github/auth/start`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({})}),t=await M(e);if(!e.ok||!t||!(`deviceCode`in t))throw Error(t?.error||e.statusText||`Failed to start GitHub auth`);return t},async authComplete(e){let t=await f(`/api/github/auth/complete`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({deviceCode:e})}),n=await M(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to complete GitHub auth`);return n},async authDisconnect(){let e=await f(`/api/github/auth`,{method:`DELETE`,headers:{Accept:`application/json`}}),t=await M(e);if(!e.ok)throw Error(t?.error||e.statusText||`Failed to disconnect GitHub`);return{removed:!!t?.removed}},async authActivate(e){let t=await f(`/api/github/auth/activate`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({accountId:e})}),n=await M(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to activate GitHub account`);return n},async authSetGhCliDisabled(e){let t=await f(`/api/github/auth/gh-cli`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({disabled:e})}),n=await M(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to update gh CLI setting`);return{disabled:!!n.disabled}},async me(){let e=await f(`/api/github/me`,{method:`GET`,headers:{Accept:`application/json`}}),t=await M(e);if(!e.ok||!t)throw Error(t?.error||e.statusText||`Failed to fetch GitHub user`);return t},async prStatus(e,t,n,r){let i=new URLSearchParams({directory:e,branch:t,...n?{remote:n}:{},...r?.force?{force:`true`}:{}}),a=await f(`/api/github/pr/status?${i.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),o=await M(a);if(!a.ok||!o)throw Error(o?.error||a.statusText||`Failed to load PR status`);return o},async prCreate(e){let t=await f(`/api/github/pr/create`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)}),n=await M(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to create PR`);return n},async prUpdate(e){let t=await f(`/api/github/pr/update`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)}),n=await M(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to update PR`);return n},async prMerge(e){let t=await f(`/api/github/pr/merge`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)}),n=await M(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to merge PR`);return n},async prReady(e){let t=await f(`/api/github/pr/ready`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)}),n=await M(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to mark PR ready`);return n},async repoUpstream(e){let t=await f(`/api/github/repo/upstream?directory=${encodeURIComponent(e)}`,{method:`GET`,headers:{Accept:`application/json`}}),n=await M(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to detect upstream repo`);return n},async repoBranches(e,t){let n=await f(`/api/github/repo/branches?owner=${encodeURIComponent(e)}&repo=${encodeURIComponent(t)}`,{method:`GET`,headers:{Accept:`application/json`}}),r=await M(n);if(!n.ok||!r)throw Error(r?.error||n.statusText||`Failed to fetch repo branches`);return r.branches??[]},async prsList(e,t){let n=t?.page??1,r=new URLSearchParams({directory:e,page:String(n)});t?.query&&r.set(`query`,t.query);let i=await f(`/api/github/pulls/list?${r.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),a=await M(i);if(!i.ok||!a)throw Error(a?.error||i.statusText||`Failed to load pull requests`);return a},async prContext(t,n,r){let i=new URLSearchParams({directory:t,number:String(n)});r?.includeDiff&&i.set(`diff`,`1`),r?.includeCheckDetails&&i.set(`checkDetails`,`1`),r?.sourceRepo?.owner&&r.sourceRepo.repo&&(i.set(`owner`,r.sourceRepo.owner),i.set(`repo`,r.sourceRepo.repo));let a=await f(e.api(`/api/github/pulls/context`,i),{method:`GET`,headers:{Accept:`application/json`}}),o=await M(a);if(!a.ok||!o)throw Error(o?.error||a.statusText||`Failed to load pull request context`);return o},async issuesList(e,t){let n=t?.page??1,r=new URLSearchParams({directory:e,page:String(n)});t?.query&&r.set(`query`,t.query);let i=await f(`/api/github/issues/list?${r.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),a=await M(i);if(!i.ok||!a)throw Error(a?.error||i.statusText||`Failed to load issues`);return a},async issueGet(t,n,r){let i=new URLSearchParams({directory:t,number:String(n)});r?.sourceRepo?.owner&&r.sourceRepo.repo&&(i.set(`owner`,r.sourceRepo.owner),i.set(`repo`,r.sourceRepo.repo));let a=await f(e.api(`/api/github/issues/get`,i),{method:`GET`,headers:{Accept:`application/json`}}),o=await M(a);if(!a.ok||!o)throw Error(o?.error||a.statusText||`Failed to load issue`);return o},async issueComments(t,n,r){let i=new URLSearchParams({directory:t,number:String(n)});r?.sourceRepo?.owner&&r.sourceRepo.repo&&(i.set(`owner`,r.sourceRepo.owner),i.set(`repo`,r.sourceRepo.repo));let a=await f(e.api(`/api/github/issues/comments`,i),{method:`GET`,headers:{Accept:`application/json`}}),o=await M(a);if(!a.ok||!o)throw Error(o?.error||a.statusText||`Failed to load issue comments`);return o}}),N=async e=>await e.json().catch(()=>null),Vt=()=>({async listClients(){let e=await f(`/api/client-auth/clients`,{method:`GET`,headers:{Accept:`application/json`}}),t=await N(e);if(!e.ok||!t)throw Error(t?.error||e.statusText||`Failed to load remote clients`);return Array.isArray(t.clients)?t.clients:[]},async createClient(e={}){let t=await f(`/api/client-auth/clients`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({label:e.label??``})}),n=await N(t);if(!t.ok||!n?.client||typeof n.token!=`string`)throw Error(n?.error||t.statusText||`Failed to create remote client token`);return n},async createPairingSession(e={}){let t=await f(`/api/client-auth/pairing/sessions`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({label:e.label??``,...e.allowedClientKinds?{allowedClientKinds:e.allowedClientKinds}:{},...e.serverUrl?{serverUrl:e.serverUrl}:{},...typeof e.includeRelay==`boolean`?{includeRelay:e.includeRelay}:{},...typeof e.includeDirect==`boolean`?{includeDirect:e.includeDirect}:{},...e.relayUrl?{relayUrl:e.relayUrl}:{}})}),n=await N(t);if(!t.ok||typeof n?.pairing?.secret!=`string`||!n?.server)throw Error(n?.error||t.statusText||`Failed to create pairing session`);return n},async listPendingPairings(){let e=await f(`/api/client-auth/pairing/sessions`,{method:`GET`,headers:{Accept:`application/json`}}),t=await N(e);if(!e.ok||!t)throw Error(t?.error||e.statusText||`Failed to load pending pairings`);return Array.isArray(t.pending)?t.pending:[]},async getPairingTransports(){let e=await f(`/api/client-auth/pairing/transports`,{method:`GET`,headers:{Accept:`application/json`}}),t=await N(e);if(!e.ok||!t)throw Error(t?.error||e.statusText||`Failed to load pairing transports`);return{...typeof t.serverName==`string`?{serverName:t.serverName}:{},local:t.local??null,lan:t.lan??null,relayAvailable:t.relayAvailable===!0,...typeof t.relayUrl==`string`?{relayUrl:t.relayUrl}:{},...typeof t.relayUrlLocked==`boolean`?{relayUrlLocked:t.relayUrlLocked}:{}}},async cancelPairing(e){let t=await f(`/api/client-auth/pairing/sessions/${encodeURIComponent(e)}`,{method:`DELETE`,headers:{Accept:`application/json`}}),n=await N(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to cancel pairing`);return{cancelled:n.cancelled===!0}},async renameClient(e,t){let n=await f(`/api/client-auth/clients/${encodeURIComponent(e)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({label:t})}),r=await N(n);if(!n.ok||!r?.client)throw Error(r?.error||n.statusText||`Failed to rename remote client`);return r.client},async revokeClient(e){let t=await f(`/api/client-auth/clients/${encodeURIComponent(e)}`,{method:`DELETE`,headers:{Accept:`application/json`}}),n=await N(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to revoke remote client`);return n},async purgeRevokedClients(){let e=await f(`/api/client-auth/clients`,{method:`DELETE`,headers:{Accept:`application/json`}}),t=await N(e);if(!e.ok||!t)throw Error(t?.error||e.statusText||`Failed to clear revoked clients`);return t}}),P=e=>typeof e==`object`&&!!e&&!Array.isArray(e),F=e=>typeof e==`number`&&Number.isFinite(e),Ht=e=>{if(!P(e)||typeof e.ok!=`boolean`)return!1;if(e.ok===!0)return P(e.session)&&typeof e.session.id==`string`&&typeof e.messageID==`string`;let t=e.phase;if(typeof t!=`string`)return!1;switch(t){case`validate`:return typeof e.error==`string`&&Array.isArray(e.errors)&&e.errors.every(e=>typeof e==`string`);case`create`:return!(typeof e.error!=`string`||`status`in e&&e.status!==void 0&&!F(e.status));case`prompt`:return P(e.session)&&typeof e.session.id==`string`&&typeof e.messageID==`string`&&typeof e.ambiguous==`boolean`&&typeof e.error==`string`&&(!(`status`in e)||e.status===void 0||F(e.status));case`conflict`:return typeof e.error==`string`;case`unavailable`:return typeof e.error==`string`;case`internal`:return typeof e.error==`string`;default:return!1}},Ut=()=>({async createWithPrompt(e,t){let n;try{n=await f(`/api/yuri/conversations`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),signal:t})}catch{throw Error(`Conversation request failed`)}let r;try{r=await n.json()}catch{throw Error(`Unexpected server response: invalid JSON`)}if(!Ht(r))throw Error(`Unexpected server response: result shape mismatch`);return r}}),Wt=`https://yuri-updates.xiaobe.top/v1/mobile/update/check`,Gt=`https://yuri-origin.xiaobe.top/v1/mobile/update/check`,Kt=1e4,I=`com.yee94.yuri`,L=`yuri.mobile-ota.device-id.v1`,R=e=>typeof e==`string`&&e.trim().length>0?e.trim():null,z=()=>{try{let e=v;return((typeof e.getConfig==`function`?e.getConfig():void 0)??e.config)?.YuriOTA??{}}catch{return{}}},B=e=>e===`beta`||e===`stable`?e:z().channel===`stable`?`stable`:`beta`,V=()=>{let e=z().shellApiVersion;return typeof e==`number`&&Number.isFinite(e)&&e>0?Math.floor(e):1},H=()=>{let e=rt();if(e===`ios`||e===`android`)return e;try{let e=v.getPlatform();if(e===`ios`||e===`android`)return e}catch{}return`android`},qt=()=>{if(typeof window>`u`)return null;try{return R(window.localStorage.getItem(L))}catch{return null}},U=e=>{if(!(typeof window>`u`))try{window.localStorage.setItem(L,e)}catch{}},W=async e=>{if(e)try{let t=R((await e.getDeviceId()).deviceId);if(t)return U(t),t}catch{}let t=qt();if(t)return t;let n=ee();return U(n),n},G=async()=>{let e=R(`0.1.3`);if(m())try{let{App:t}=await y(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2])),n=await t.getInfo(),r=R(n.version)??e??`0.0.0`,i=R(n.build),a=i?Number.parseInt(i,10):0;return{applicationId:R(n.id)??void 0,version:r,build:Number.isFinite(a)?a:0}}catch{}return{version:e??`0.0.0`,build:0}},K=(e,t,n)=>{let r=R(e?.version),i=R(t);if(n===`beta`&&i)return i;if(r&&r!==`builtin`)return i&&i!==r&&i.startsWith(`${r}-`)?i:r;let a=R(e?.id);return a&&a!==`builtin`?a:i??`builtin`},Jt=()=>R(`0.1.3`),q=e=>{let t=e?.trim().match(/^v?(\d+)\.\d+\.\d+(?:-beta\.\d+)?$/i),n=t?Number(t[1]):void 0;return n!==void 0&&Number.isSafeInteger(n)?n:void 0},J=async(e,t)=>{let n=Jt();if(!e)return K(null,n,t);try{return K((await e.current()).bundle,n,t)}catch{return K(null,n,t)}},Yt=()=>[Wt,Gt],Xt=(e,t,n)=>{let r=e-n();return r<=0||t<=0?null:Math.max(1,Math.ceil(r/t))};async function Zt(e,t,n,r){try{if(m())try{let{CapacitorHttp:r}=await y(async()=>{let{CapacitorHttp:e}=await import(`./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js`).then(e=>e.i);return{CapacitorHttp:e}},__vite__mapDeps([2,1])),i=Object.fromEntries(new Headers(t.headers).entries()),a;if(typeof t.body==`string`)try{a=JSON.parse(t.body)}catch{a=t.body}let o=await Promise.race([r.request({url:e,method:t.method||`GET`,headers:i,data:a,connectTimeout:n,readTimeout:n}),new Promise(e=>{window.setTimeout(()=>e(null),n)})]);return o?{ok:o.status>=200&&o.status<300,status:o.status,json:async()=>{if(typeof o.data==`string`)try{return JSON.parse(o.data)}catch{return o.data}return o.data}}:null}catch{}let i=await r(e,{...t,signal:AbortSignal.timeout(n)});return{ok:i.ok,status:i.status,json:()=>i.json()}}catch{return null}}var Qt=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return!(t.status!==`ok`||t.primaryAction!==`none`&&t.primaryAction!==`apply_ota`&&t.primaryAction!==`install_native_required`||!t.ota||typeof t.ota!=`object`||!t.native||typeof t.native!=`object`||typeof t.nextCheckInSec!=`number`||!Number.isFinite(t.nextCheckInSec))},$t=e=>{let t=e;return t.isChannelRollback===!0||t.is_channel_rollback===!0?{...e,isChannelRollback:!0}:e};async function en(e,t,n,r){let i=await Zt(e,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify(t)},n,r);if(!i?.ok)return null;let a;try{a=await i.json()}catch{return null}if(!Qt(a))return null;if(a.primaryAction===`apply_ota`&&t.applicationId!==I)throw Error(`Yuri OTA requires the Yuri native application`);if(a.primaryAction===`apply_ota`&&(t.releaseMajor===void 0||q(a.ota.bundle?.releaseVersion)!==t.releaseMajor))throw Error(`OTA release major mismatch`);return $t(a)}async function tn(e={}){let t=e.updater===void 0?await S():e.updater;if(!t&&!m())throw new b;let n=e.fetchImpl??fetch,r=e.now??Date.now,i=B(e.channelOverride),[a,o,s]=await Promise.all([W(t),G(),J(t,i)]),c={channel:i,platform:H(),applicationId:o.applicationId,deviceId:a,nativeVersion:o.version,nativeBuild:o.build,shellApiVersion:V(),currentBundleId:s,releaseMajor:q(s)??q(o.version)},l=Yt(),u=r()+Kt,d=null;for(let[e,t]of l.entries()){let i=Xt(u,l.length-e,r);if(i===null)break;try{let e=await en(t,c,i,n);if(e)return e;d=Error(`Mobile OTA check failed at ${t}`)}catch(e){d=e instanceof Error?e:Error(`Mobile OTA check failed`)}}throw d??Error(`Unable to check for mobile OTA updates`)}async function nn(e){let t=await S();if(!t)return null;let n=await Y({updater:t});if(n.applicationId!==I)throw Error(`Yuri OTA requires the Yuri native application`);if(n.releaseMajor===void 0||q(e.releaseVersion)!==n.releaseMajor)throw Error(`OTA release major mismatch`);try{let{bundles:n}=await t.list();return n.find(t=>t.checksum===e.checksum&&t.version===e.releaseVersion&&(t.status===`success`||t.status===`pending`))?.id??null}catch{return null}}async function rn(e){let t=await S();if(!t)throw new b;let n=await Y({updater:t});if(n.applicationId!==I)throw Error(`Yuri OTA requires the Yuri native application`);if(n.releaseMajor===void 0||q(e.releaseVersion)!==n.releaseMajor)throw Error(`OTA release major mismatch`);return(await t.download({url:e.url,version:e.releaseVersion,checksum:e.checksum,...e.sessionKey?{sessionKey:e.sessionKey}:{}})).id}async function an(){let e=await S();if(!e)throw new b;await e.reload()}async function on(e){let t=await S();if(!t)throw new b;await t.next({id:e})}async function Y(e={}){let t=e.updater===void 0?await S():e.updater,n=B(e.channelOverride),[r,i,a]=await Promise.all([W(t),G(),J(t,n)]);return{channel:n,platform:H(),applicationId:i.applicationId,deviceId:r,nativeVersion:i.version,nativeBuild:i.build,shellApiVersion:V(),currentBundleId:a,releaseMajor:q(a)??q(i.version)}}var X=null,Z=e=>typeof e==`string`&&e.trim().length>0?e.trim():null,Q=async()=>{let e=Z(`0.1.3`);try{if(v.isNativePlatform()){let{App:t}=await y(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2]));return Z((await t.getInfo()).version)??e??`unknown`}}catch{}return e??`unknown`},sn=()=>({async checkForOtaUpdate(e){if(!x()&&!v.isNativePlatform())throw new b;return tn(e?.channelOverride?{channelOverride:e.channelOverride}:{})},async downloadOtaUpdate(e){if(!x())throw new b;let t=await nn(e);return t?(X=t,{skipped:!0}):(X=await rn(e),{skipped:!1})},async applyOtaUpdateNow(){if(!x())throw new b;await an()},async queueOtaUpdateForNextLaunch(){if(!x())throw new b;let e=X;if(!e)throw Error(`No downloaded OTA bundle to queue`);await on(e)},async getOtaStatus(){if(!x())return{supported:!1,currentBundleId:`builtin`,nativeVersion:await Q()};let e=await S();if(!e)return{supported:!1,currentBundleId:`builtin`,nativeVersion:await Q()};try{let[t,n]=await Promise.all([e.current(),Q()]);return{supported:!0,currentBundleId:Z(t.bundle?.id)||`builtin`,nativeVersion:n}}catch{return{supported:!0,currentBundleId:`builtin`,nativeVersion:await Q()}}}}),cn=()=>({api:(...e)=>s().api(...e),authenticatedAsset:(...e)=>s().authenticatedAsset(...e),auth:(...e)=>s().auth(...e),health:(...e)=>s().health(...e),rawFile:(...e)=>s().rawFile(...e),sse:(...e)=>s().sse(...e),websocket:(...e)=>s().websocket(...e)}),ln=(e={})=>{let t=e.urls??o();l(t);let n=cn();return{runtime:{platform:`web`,isDesktop:!1,isVSCode:!1,label:`web`},terminal:bt(),git:xt(),files:Ct({urls:n,getDirectory:()=>ae.getState().currentDirectory}),settings:Tt(),permissions:Et(),notifications:Lt(),github:Bt({urls:n}),push:zt(),mobileUpdates:sn(),clientAuth:Vt(),tools:Rt(),conversations:Ut()}},$=(e,t)=>{if(!e||!t)return!1;try{return new URL(e).origin===new URL(t).origin}catch{return!1}},un=Promise.resolve(),dn=()=>un,fn=()=>{let o=typeof window.__YURI_API_BASE_URL__==`string`?window.__YURI_API_BASE_URL__.trim():``,s=typeof window.__YURI_CLIENT_TOKEN__==`string`?window.__YURI_CLIENT_TOKEN__.trim():``,c=typeof window.__YURI_LOCAL_ORIGIN__==`string`?window.__YURI_LOCAL_ORIGIN__.trim():``,l=u({apiBaseUrl:o||void 0,realtimeBaseUrl:o||void 0});a({apiBaseUrl:o,runtimeKey:$(o,c)?`local`:null}),n(s||null),t(window.__YURI_RUNTIME_HEADERS__||null),i(o||void 0).catch(()=>{}),c&&!$(o,c)&&Object.keys(r()).length>0&&e(c).catch(()=>{}),d();let f=window.__YURI_RELAY_HOST_ID__;return un=Promise.race([te(typeof f==`string`&&f?f:void 0).catch(()=>{}),new Promise(e=>{window.setTimeout(e,1e4)})]),ln({urls:l})};export{dn as n,fn as t};