@openchambery/web 2.0.0-beta.15 → 2.0.0-beta.17

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 (44) hide show
  1. package/dist/assets/AssistantView-DfdYRwe9.js +3 -0
  2. package/dist/assets/{DiagramView-B_axat3i.js → DiagramView-DgPSfFEr.js} +1 -1
  3. package/dist/assets/{MarkdownRenderer-Cr5OVKst.js → MarkdownRenderer-Cgoat7nw.js} +2 -2
  4. package/dist/assets/{MarkdownRendererImpl-CJUjp1Kl.js → MarkdownRendererImpl-DMhCX4I4.js} +1 -1
  5. package/dist/assets/{MarkstreamRendererImpl-xEVeK8b5.js → MarkstreamRendererImpl-BiEn8urF.js} +1 -1
  6. package/dist/assets/{MobileDetailNavigation-AxTBUyCz.js → MobileDetailNavigation-CRb0QjWl.js} +1 -1
  7. package/dist/assets/{MobileShareBridge-B3q5Bvca.js → MobileShareBridge-C1KkUsa1.js} +1 -1
  8. package/dist/assets/{MobileSurface-BnUkDsjU.js → MobileSurface-GAmsjEQX.js} +1 -1
  9. package/dist/assets/{MultiRunWindow-CPCjWcLe.js → MultiRunWindow-1J5N1_xP.js} +1 -1
  10. package/dist/assets/{SettingsView-DvHCyZ1l.js → SettingsView-BTWtI6gk.js} +6 -6
  11. package/dist/assets/{SettingsWindow-D7nv9VG2.js → SettingsWindow-5NrNotTs.js} +1 -1
  12. package/dist/assets/{TerminalView-Cukq-9MG.js → TerminalView-CNHjj_km.js} +1 -1
  13. package/dist/assets/{ToolOutputDialog-BBudjfdJ.js → ToolOutputDialog-DDVMsHzT.js} +1 -1
  14. package/dist/assets/{appThemeRegistry-B7iM6Wwn.js → appThemeRegistry-D7-4hz-r.js} +1 -1
  15. package/dist/assets/{fileMentionTouchSelection-DJnbFm0E.js → fileMentionTouchSelection-CxmALWLE.js} +1 -1
  16. package/dist/assets/{gitApi-BiPCMFjN.js → gitApi-Bx8o0qYf.js} +3 -3
  17. package/dist/assets/insertionBoundaries-B7WuxOpo.js +1 -0
  18. package/dist/assets/{main-NeJv9nvF.js → main-Df1hgMj6.js} +12 -12
  19. package/dist/assets/{main-cVprFo3G.js → main-fFwuYFwA.js} +2 -2
  20. package/dist/assets/{mcpQueries-CR7_Jav7.js → mcpQueries-5RQLxGkS.js} +1 -1
  21. package/dist/assets/{miniChat-C5tTnNNM.js → miniChat-ByXFq9Gm.js} +2 -2
  22. package/dist/assets/{mobile-D1KqMgLm.js → mobile-DzYPMFOV.js} +2 -2
  23. package/dist/assets/multirun-CbKpafUJ.js +4 -0
  24. package/dist/assets/{projectMeta-CdRGrq5D.js → projectMeta-DR8jWQPj.js} +2 -2
  25. package/dist/assets/{renderElectronMiniChatApp-BWDU5JMe.js → renderElectronMiniChatApp-BH_HOhiH.js} +2 -2
  26. package/dist/assets/renderMobileApp-CdvHmHtu.js +28 -0
  27. package/dist/assets/{runtimeConfig-D4tlo3iY.js → runtimeConfig-C2r3lwvo.js} +1 -1
  28. package/dist/assets/{runtimeEndpointReset-FgHH1wMh.js → runtimeEndpointReset-C4E7DYmZ.js} +6 -6
  29. package/dist/assets/{sessionChangeSummary-DrefB13y.js → sessionChangeSummary-BvaUzmH5.js} +1 -1
  30. package/dist/assets/{sessionLookup-CwaDQtYl.js → sessionLookup-D6SUfHqi.js} +1 -1
  31. package/dist/assets/{useAppFontEffects-BMRvJWlG.js → useAppFontEffects-DO-sih8X.js} +53 -53
  32. package/dist/assets/{useDesktopWindowControlsLayout-BYCorgSr.js → useDesktopWindowControlsLayout-DFAvkRtr.js} +1 -1
  33. package/dist/assets/{useEffectiveDirectory-Djy7IP9p.js → useEffectiveDirectory-o1wBFa-2.js} +1 -1
  34. package/dist/assets/{useMobileNavigationStore-DrdLEZXl.js → useMobileNavigationStore-Brjbv-jq.js} +9 -9
  35. package/dist/assets/{useSessionAutoCleanup-BzidHXhR.js → useSessionAutoCleanup-uEly8Hxf.js} +1 -1
  36. package/dist/assets/{useWorkerHighlightedLines-C8k8KbYV.js → useWorkerHighlightedLines-DWYhz9_o.js} +1 -1
  37. package/dist/index.html +2 -2
  38. package/dist/mini-chat.html +2 -2
  39. package/dist/mobile.html +2 -2
  40. package/package.json +1 -1
  41. package/dist/assets/AssistantView-Ck0B33VC.js +0 -3
  42. package/dist/assets/insertionBoundaries-DN60qQpt.js +0 -1
  43. package/dist/assets/multirun-Bp2dQfKE.js +0 -4
  44. package/dist/assets/renderMobileApp-OdRhHvr4.js +0 -28
@@ -1,4 +1,4 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t}from"./runtime-fetch-CiqQd__Y.js";import{En as n,in as r}from"./persistence-CMWO3jFo.js";import{nt as i,rt as a}from"./vendor-base-ui-CnHfUmDN.js";import{n as o}from"./platform-BxU3ZvQ0.js";import{v as s}from"./useUIStore-Brsa2mKs.js";import{n as c}from"./vendor-react-DLPElpoQ.js";import{a as l,n as u}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{f as d,r as f,t as p}from"./button-EzCcYrQl.js";import{n as m}from"./Icon-DKd015RD.js";import{i as h,n as g,t as _}from"./tooltip-DwUy2erJ.js";import{n as v}from"./useThemeSystem-DMzWVJaW.js";import{n as y}from"./markdownTheme-DM5h1i18.js";import{n as b}from"./MarkdownRenderer-Cr5OVKst.js";import{n as x,o as S,s as C,t as w}from"./markdown-worker-bS5OgGO3.js";import{a as T,i as E,o as D,t as ee}from"./imageSource-BpUsiwFd.js";import{t as te}from"./vendor-tanstack-react-virtual-tlDgH6PG.js";var O=e(a(),1),k=c(),A=i(),ne=`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)]`,j={maxWidth:`min(28rem, calc(100cqw - 4ch))`,backgroundColor:`var(--surface-elevated)`,color:`var(--surface-elevated-foreground)`},M=`flex items-center justify-between gap-3 border-b border-[var(--surface-subtle)] px-3 py-2.5`,N=`text-xs font-medium leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,re=`text-xs tabular-nums leading-4 text-muted-foreground md:text-[0.8125rem] md:leading-5`,P=`m-0 list-none divide-y divide-[var(--surface-subtle)] p-0`,F=`${P} max-h-[min(22rem,50vh)] overflow-y-auto`,ie=`${P} w-full`,ae={className:`p-0 rounded-none`,maxHeightClass:`max-h-[46vh]`,disableHorizontal:!0},I=`px-2.5 py-1.5 text-xs leading-4 md:py-2 md:text-[0.8125rem] md:leading-5`,oe=`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`,se=`min-w-0 truncate text-xs leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,ce=`inline-flex shrink-0 items-center gap-1 text-xs leading-4 tabular-nums text-muted-foreground md:text-[0.8125rem] md:leading-5`,le=`h-3 w-3 shrink-0 md:h-3.5 md:w-3.5`,ue={in_progress:`text-foreground`,pending:`text-foreground`,completed:`text-muted-foreground line-through`,cancelled:`text-muted-foreground line-through`},L={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`},R=e=>{let t=(0,k.c)(26),{todo:n,isActive:r,activeRef:i}=e,{t:a}=d(),o=z.has(n.status)?n.status:`pending`,s=L[o],c;t[0]!==a||t[1]!==s?(c=a(s),t[0]=a,t[1]=s,t[2]=c):c=t[2];let l=c,u;t[3]===o?u=t[4]:(u=o===`in_progress`?(0,A.jsx)(m,{name:`record-circle`,className:`h-3.5 w-3.5 text-[var(--status-info)]`,"aria-hidden":`true`}):o===`completed`?(0,A.jsx)(m,{name:`checkbox-circle`,className:`h-3.5 w-3.5 text-[var(--status-success)]`,"aria-hidden":`true`}):(0,A.jsx)(m,{name:`time`,className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":`true`}),t[3]=o,t[4]=u);let p=u,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=f(`group relative grid min-w-0 grid-cols-[1rem_minmax(0,1fr)] items-start gap-2.5`,I,y),t[5]=y,t[6]=b);let x;t[7]!==p||t[8]!==l?(x=(0,A.jsx)(h,{asChild:!0,children:(0,A.jsx)(`span`,{className:`flex size-4 items-center justify-center`,"aria-label":l,children:p})}),t[7]=p,t[8]=l,t[9]=x):x=t[9];let S;t[10]===l?S=t[11]:(S=(0,A.jsx)(g,{side:`left`,sideOffset:6,children:l}),t[10]=l,t[11]=S);let C;t[12]!==x||t[13]!==S?(C=(0,A.jsxs)(_,{children:[x,S]}),t[12]=x,t[13]=S,t[14]=C):C=t[14];let w=ue[o],T;t[15]===w?T=t[16]:(T=f(`block whitespace-normal break-words`,w),t[15]=w,t[16]=T);let E;t[17]!==T||t[18]!==n.content?(E=(0,A.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,A.jsx)(`span`,{className:T,children:n.content})}),t[17]=T,t[18]=n.content,t[19]=E):E=t[19];let D;return t[20]!==i||t[21]!==E||t[22]!==v||t[23]!==b||t[24]!==C?(D=(0,A.jsxs)(`li`,{ref:i,"aria-current":v,className:b,children:[C,E]}),t[20]=i,t[21]=E,t[22]=v,t[23]=b,t[24]=C,t[25]=D):D=t[25],D},z=new Set([`in_progress`,`pending`,`completed`,`cancelled`]),B=`image/png`,V=l(`OpenChamberMedia`),H=e=>{let t=e.toLowerCase().split(`;`)[0]?.trim()||B;if(t===`image/jpeg`||t===`image/jpg`)return`jpg`;if(t===`image/webp`)return`webp`;if(t===`image/gif`)return`gif`;if(t===`image/svg+xml`)return`svg`;if(t===`image/png`)return`png`;let n=t.split(`/`)[1];return n&&/^[a-z0-9.+-]+$/i.test(n)?n:`png`},U=(e,t)=>{let n=`image.${H(t)}`,r=(((e||``).trim()||n).split(/[\\/]/).pop()||n).replace(/[^\w.\- ()[\]]+/g,`_`).replace(/^\.+/,``);return r?/\.[a-z0-9]{1,8}$/i.test(r)?r:`${r}.${H(t)}`:n},W=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{if(typeof r.result==`string`){t(r.result);return}n(Error(`Failed to encode image`))},r.onerror=()=>n(r.error??Error(`Failed to encode image`)),r.readAsDataURL(e)}),de=async e=>{let t=await W(e),n=t.indexOf(`,`);return n>=0?t.slice(n+1):t},fe=(e,t)=>{let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.setTimeout(()=>URL.revokeObjectURL(n),1e3)},G=async(e,t)=>{let n=await fetch(e,{signal:t,cache:`no-store`});if(!n.ok)throw Error(`Image fetch failed (${n.status})`);return n.blob()},pe=async(e,t=B)=>{if(!e.naturalWidth||!e.naturalHeight)return null;let n=e.currentSrc||e.src;if(n&&(/^(?:blob:|data:|openchamber-asset:)/i.test(n)||/^https?:/i.test(n)||/^\/api(?=\/|[?#]|$)/.test(n)))try{let e=await G(n);if(e.size>0)return e}catch{}try{let n=document.createElement(`canvas`);n.width=e.naturalWidth,n.height=e.naturalHeight;let r=n.getContext(`2d`);if(!r)return null;r.drawImage(e,0,0);let i=t.startsWith(`image/`)?t:B,a=await new Promise(e=>{n.toBlob(t=>e(t),i===`image/jpg`?`image/jpeg`:i)});return a&&a.size>0?a:null}catch{return null}},me=async(e,t)=>{let n=``;try{return n=await ee(e,t??new AbortController().signal),await G(n,t)}finally{n&&T(n)}},he=async(e,n)=>{let r=e.effectiveDirectory??``,i=null;e.prefetchedBlob&&e.prefetchedBlob.size>0&&(i=e.prefetchedBlob);let a=e.displayUrl?.trim();if(!i&&a)try{i=await G(a,n)}catch{i=null}if(!i){let a=e.sourceUrl.trim();if(!a)throw Error(`Image source is empty`);if(/^(?:data|blob):/i.test(a)||/^https?:/i.test(a)||/^\/api(?=\/|[?#]|$)/.test(a))i=await G(a,n);else{let e=D(a,r);if(E(e))try{i=await me(e.path,n)}catch{let r=await t(`/api/fs/raw`,{method:`GET`,cache:`no-store`,query:{path:e.path},signal:n});if(!r.ok)throw Error(`Image source request failed with status ${r.status}`);i=await r.blob()}else i=await G(e.source,n)}}if(!i||i.size<=0)throw Error(`Image is empty`);let o=(e.mimeType||(i.type&&i.type.startsWith(`image/`)?i.type:``)||B).split(`;`)[0].trim()||B;return{blob:i,filename:U(e.filename,o),mimeType:o}},ge=()=>!o()||u===void 0?!1:u.isPluginAvailable(`OpenChamberMedia`),_e=async(e,t)=>{let{blob:i,filename:a,mimeType:o}=await he(e,t);if(ge()){let e=await de(i);return await V.saveImage({dataBase64:e,mimeType:o,filename:a}),`saved`}if(r()){let e=n()?.vscode;if(e?.saveImage){let t=await W(i);return await e.saveImage({fileName:a,dataUrl:t}),`saved`}}return fe(i,a),`downloaded`},ve=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`),ye=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(``):``,K=(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=ye(n);e&&i.setAttribute(`style`,`${i.getAttribute(`style`)??``}${e}`)}},be=e=>`<pre><code>${ve(e)}</code></pre>`,xe=e=>{let t=(0,k.c)(21),{code:n,language:r,className:i,style:a,codeStyle:o,wrap:s}=e,c=s!==void 0&&s,{currentTheme:l}=v(),u=O.useRef(null),d;t[0]===l?d=t[1]:(d=y(l),t[0]=l,t[1]=d);let p=d,m,h;t[2]!==n||t[3]!==o||t[4]!==c?(m=()=>{let e=u.current;e&&(e.innerHTML=be(n),K(e,c,o))},h=[n,c,o],t[2]=n,t[3]=o,t[4]=c,t[5]=m,t[6]=h):(m=t[5],h=t[6]),O.useLayoutEffect(m,h);let g,_;t[7]!==n||t[8]!==o||t[9]!==r||t[10]!==c?(g=()=>{let e=u.current;if(!e)return;let t=!0,i=new AbortController;return w(n,(r||`text`).toLowerCase(),{signal:i.signal,priority:`visible`}).then(n=>{!t||!e||!n||(e.innerHTML=n,K(e,c,o))}),()=>{t=!1,i.abort()}},_=[n,r,c,o],t[7]=n,t[8]=o,t[9]=r,t[10]=c,t[11]=g,t[12]=_):(g=t[11],_=t[12]),O.useEffect(g,_);let b;t[13]===i?b=t[14]:(b=f(`typography-code`,i),t[13]=i,t[14]=b);let x=p,S;t[15]!==a||t[16]!==x?(S={...x,...a},t[15]=a,t[16]=x,t[17]=S):S=t[17];let C;return t[18]!==b||t[19]!==S?(C=(0,A.jsx)(`div`,{ref:u,className:b,style:S}),t[18]=b,t[19]=S,t[20]=C):C=t[20],C},Se=e=>{let t=e.replace(/^<file>\s*\n?/,``).replace(/\n?<\/file>\s*$/,``);return t=t.replace(/^\s*\d{5}\|\s?/gm,``),t.trim()},Ce=(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}},we=e=>e?e.includes(`<diagnostics`)||e.includes(`<file_diagnostics>`)||e.includes(`LSP errors detected`)||e.includes(`This file has errors`):!1,Te=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():``,Ee=(e,t)=>!e||typeof e!=`object`?String(e):C(e,t||``),q=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}}},De=e=>{if(!e||typeof e!=`object`)return;let t=q(e.patch)??q(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=q(e.patch)??q(e.diff);if(t)return t}},Oe=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}}},ke=(e,t,n)=>{let r=Se(e);if((t===`edit`||t===`multiedit`||t===`write`||t===`apply_patch`)&&we(r)&&(r=Te(r)),(t===`edit`||t===`multiedit`||t===`apply_patch`)&&r.trim().length===0){let e=De(n);if(e)return e}return r},Ae=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{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t}from"./runtime-fetch-CiqQd__Y.js";import{En as n,in as r}from"./persistence-CMWO3jFo.js";import{nt as i,rt as a}from"./vendor-base-ui-CnHfUmDN.js";import{n as o}from"./platform-BxU3ZvQ0.js";import{v as s}from"./useUIStore-Brsa2mKs.js";import{n as c}from"./vendor-react-DLPElpoQ.js";import{a as l,n as u}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{f as d,r as f,t as p}from"./button-EzCcYrQl.js";import{n as m}from"./Icon-DKd015RD.js";import{i as h,n as g,t as _}from"./tooltip-DwUy2erJ.js";import{n as v}from"./useThemeSystem-DMzWVJaW.js";import{n as y}from"./markdownTheme-DM5h1i18.js";import{n as b}from"./MarkdownRenderer-Cgoat7nw.js";import{n as x,o as S,s as C,t as w}from"./markdown-worker-bS5OgGO3.js";import{a as T,i as E,o as D,t as ee}from"./imageSource-BpUsiwFd.js";import{t as te}from"./vendor-tanstack-react-virtual-tlDgH6PG.js";var O=e(a(),1),k=c(),A=i(),ne=`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)]`,j={maxWidth:`min(28rem, calc(100cqw - 4ch))`,backgroundColor:`var(--surface-elevated)`,color:`var(--surface-elevated-foreground)`},M=`flex items-center justify-between gap-3 border-b border-[var(--surface-subtle)] px-3 py-2.5`,N=`text-xs font-medium leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,re=`text-xs tabular-nums leading-4 text-muted-foreground md:text-[0.8125rem] md:leading-5`,P=`m-0 list-none divide-y divide-[var(--surface-subtle)] p-0`,F=`${P} max-h-[min(22rem,50vh)] overflow-y-auto`,ie=`${P} w-full`,ae={className:`p-0 rounded-none`,maxHeightClass:`max-h-[46vh]`,disableHorizontal:!0},I=`px-2.5 py-1.5 text-xs leading-4 md:py-2 md:text-[0.8125rem] md:leading-5`,oe=`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`,se=`min-w-0 truncate text-xs leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,ce=`inline-flex shrink-0 items-center gap-1 text-xs leading-4 tabular-nums text-muted-foreground md:text-[0.8125rem] md:leading-5`,le=`h-3 w-3 shrink-0 md:h-3.5 md:w-3.5`,ue={in_progress:`text-foreground`,pending:`text-foreground`,completed:`text-muted-foreground line-through`,cancelled:`text-muted-foreground line-through`},L={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`},R=e=>{let t=(0,k.c)(26),{todo:n,isActive:r,activeRef:i}=e,{t:a}=d(),o=z.has(n.status)?n.status:`pending`,s=L[o],c;t[0]!==a||t[1]!==s?(c=a(s),t[0]=a,t[1]=s,t[2]=c):c=t[2];let l=c,u;t[3]===o?u=t[4]:(u=o===`in_progress`?(0,A.jsx)(m,{name:`record-circle`,className:`h-3.5 w-3.5 text-[var(--status-info)]`,"aria-hidden":`true`}):o===`completed`?(0,A.jsx)(m,{name:`checkbox-circle`,className:`h-3.5 w-3.5 text-[var(--status-success)]`,"aria-hidden":`true`}):(0,A.jsx)(m,{name:`time`,className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":`true`}),t[3]=o,t[4]=u);let p=u,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=f(`group relative grid min-w-0 grid-cols-[1rem_minmax(0,1fr)] items-start gap-2.5`,I,y),t[5]=y,t[6]=b);let x;t[7]!==p||t[8]!==l?(x=(0,A.jsx)(h,{asChild:!0,children:(0,A.jsx)(`span`,{className:`flex size-4 items-center justify-center`,"aria-label":l,children:p})}),t[7]=p,t[8]=l,t[9]=x):x=t[9];let S;t[10]===l?S=t[11]:(S=(0,A.jsx)(g,{side:`left`,sideOffset:6,children:l}),t[10]=l,t[11]=S);let C;t[12]!==x||t[13]!==S?(C=(0,A.jsxs)(_,{children:[x,S]}),t[12]=x,t[13]=S,t[14]=C):C=t[14];let w=ue[o],T;t[15]===w?T=t[16]:(T=f(`block whitespace-normal break-words`,w),t[15]=w,t[16]=T);let E;t[17]!==T||t[18]!==n.content?(E=(0,A.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,A.jsx)(`span`,{className:T,children:n.content})}),t[17]=T,t[18]=n.content,t[19]=E):E=t[19];let D;return t[20]!==i||t[21]!==E||t[22]!==v||t[23]!==b||t[24]!==C?(D=(0,A.jsxs)(`li`,{ref:i,"aria-current":v,className:b,children:[C,E]}),t[20]=i,t[21]=E,t[22]=v,t[23]=b,t[24]=C,t[25]=D):D=t[25],D},z=new Set([`in_progress`,`pending`,`completed`,`cancelled`]),B=`image/png`,V=l(`OpenChamberMedia`),H=e=>{let t=e.toLowerCase().split(`;`)[0]?.trim()||B;if(t===`image/jpeg`||t===`image/jpg`)return`jpg`;if(t===`image/webp`)return`webp`;if(t===`image/gif`)return`gif`;if(t===`image/svg+xml`)return`svg`;if(t===`image/png`)return`png`;let n=t.split(`/`)[1];return n&&/^[a-z0-9.+-]+$/i.test(n)?n:`png`},U=(e,t)=>{let n=`image.${H(t)}`,r=(((e||``).trim()||n).split(/[\\/]/).pop()||n).replace(/[^\w.\- ()[\]]+/g,`_`).replace(/^\.+/,``);return r?/\.[a-z0-9]{1,8}$/i.test(r)?r:`${r}.${H(t)}`:n},W=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{if(typeof r.result==`string`){t(r.result);return}n(Error(`Failed to encode image`))},r.onerror=()=>n(r.error??Error(`Failed to encode image`)),r.readAsDataURL(e)}),de=async e=>{let t=await W(e),n=t.indexOf(`,`);return n>=0?t.slice(n+1):t},fe=(e,t)=>{let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.setTimeout(()=>URL.revokeObjectURL(n),1e3)},G=async(e,t)=>{let n=await fetch(e,{signal:t,cache:`no-store`});if(!n.ok)throw Error(`Image fetch failed (${n.status})`);return n.blob()},pe=async(e,t=B)=>{if(!e.naturalWidth||!e.naturalHeight)return null;let n=e.currentSrc||e.src;if(n&&(/^(?:blob:|data:|openchamber-asset:)/i.test(n)||/^https?:/i.test(n)||/^\/api(?=\/|[?#]|$)/.test(n)))try{let e=await G(n);if(e.size>0)return e}catch{}try{let n=document.createElement(`canvas`);n.width=e.naturalWidth,n.height=e.naturalHeight;let r=n.getContext(`2d`);if(!r)return null;r.drawImage(e,0,0);let i=t.startsWith(`image/`)?t:B,a=await new Promise(e=>{n.toBlob(t=>e(t),i===`image/jpg`?`image/jpeg`:i)});return a&&a.size>0?a:null}catch{return null}},me=async(e,t)=>{let n=``;try{return n=await ee(e,t??new AbortController().signal),await G(n,t)}finally{n&&T(n)}},he=async(e,n)=>{let r=e.effectiveDirectory??``,i=null;e.prefetchedBlob&&e.prefetchedBlob.size>0&&(i=e.prefetchedBlob);let a=e.displayUrl?.trim();if(!i&&a)try{i=await G(a,n)}catch{i=null}if(!i){let a=e.sourceUrl.trim();if(!a)throw Error(`Image source is empty`);if(/^(?:data|blob):/i.test(a)||/^https?:/i.test(a)||/^\/api(?=\/|[?#]|$)/.test(a))i=await G(a,n);else{let e=D(a,r);if(E(e))try{i=await me(e.path,n)}catch{let r=await t(`/api/fs/raw`,{method:`GET`,cache:`no-store`,query:{path:e.path},signal:n});if(!r.ok)throw Error(`Image source request failed with status ${r.status}`);i=await r.blob()}else i=await G(e.source,n)}}if(!i||i.size<=0)throw Error(`Image is empty`);let o=(e.mimeType||(i.type&&i.type.startsWith(`image/`)?i.type:``)||B).split(`;`)[0].trim()||B;return{blob:i,filename:U(e.filename,o),mimeType:o}},ge=()=>!o()||u===void 0?!1:u.isPluginAvailable(`OpenChamberMedia`),_e=async(e,t)=>{let{blob:i,filename:a,mimeType:o}=await he(e,t);if(ge()){let e=await de(i);return await V.saveImage({dataBase64:e,mimeType:o,filename:a}),`saved`}if(r()){let e=n()?.vscode;if(e?.saveImage){let t=await W(i);return await e.saveImage({fileName:a,dataUrl:t}),`saved`}}return fe(i,a),`downloaded`},ve=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`),ye=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(``):``,K=(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=ye(n);e&&i.setAttribute(`style`,`${i.getAttribute(`style`)??``}${e}`)}},be=e=>`<pre><code>${ve(e)}</code></pre>`,xe=e=>{let t=(0,k.c)(21),{code:n,language:r,className:i,style:a,codeStyle:o,wrap:s}=e,c=s!==void 0&&s,{currentTheme:l}=v(),u=O.useRef(null),d;t[0]===l?d=t[1]:(d=y(l),t[0]=l,t[1]=d);let p=d,m,h;t[2]!==n||t[3]!==o||t[4]!==c?(m=()=>{let e=u.current;e&&(e.innerHTML=be(n),K(e,c,o))},h=[n,c,o],t[2]=n,t[3]=o,t[4]=c,t[5]=m,t[6]=h):(m=t[5],h=t[6]),O.useLayoutEffect(m,h);let g,_;t[7]!==n||t[8]!==o||t[9]!==r||t[10]!==c?(g=()=>{let e=u.current;if(!e)return;let t=!0,i=new AbortController;return w(n,(r||`text`).toLowerCase(),{signal:i.signal,priority:`visible`}).then(n=>{!t||!e||!n||(e.innerHTML=n,K(e,c,o))}),()=>{t=!1,i.abort()}},_=[n,r,c,o],t[7]=n,t[8]=o,t[9]=r,t[10]=c,t[11]=g,t[12]=_):(g=t[11],_=t[12]),O.useEffect(g,_);let b;t[13]===i?b=t[14]:(b=f(`typography-code`,i),t[13]=i,t[14]=b);let x=p,S;t[15]!==a||t[16]!==x?(S={...x,...a},t[15]=a,t[16]=x,t[17]=S):S=t[17];let C;return t[18]!==b||t[19]!==S?(C=(0,A.jsx)(`div`,{ref:u,className:b,style:S}),t[18]=b,t[19]=S,t[20]=C):C=t[20],C},Se=e=>{let t=e.replace(/^<file>\s*\n?/,``).replace(/\n?<\/file>\s*$/,``);return t=t.replace(/^\s*\d{5}\|\s?/gm,``),t.trim()},Ce=(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}},we=e=>e?e.includes(`<diagnostics`)||e.includes(`<file_diagnostics>`)||e.includes(`LSP errors detected`)||e.includes(`This file has errors`):!1,Te=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():``,Ee=(e,t)=>!e||typeof e!=`object`?String(e):C(e,t||``),q=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}}},De=e=>{if(!e||typeof e!=`object`)return;let t=q(e.patch)??q(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=q(e.patch)??q(e.diff);if(t)return t}},Oe=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}}},ke=(e,t,n)=>{let r=Se(e);if((t===`edit`||t===`multiedit`||t===`write`||t===`apply_patch`)&&we(r)&&(r=Te(r)),(t===`edit`||t===`multiedit`||t===`apply_patch`)&&r.trim().length===0){let e=De(n);if(e)return e}return r},Ae=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)})}},je=(e,t)=>{try{let n=e.trim().split(`
4
4
  `).filter(Boolean);if(n.length===0)return null;let r=[];return n.forEach(e=>{let t=e.match(/^(\s*)(.+)$/);if(t){let[,e,n]=t,i=Math.floor(e.length/2),a=!n.endsWith(`/`);r.push({name:n.replace(/\/$/,``),depth:i,isFile:a})}}),(0,A.jsx)(`div`,{className:f(`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:s.tool.popup,children:r.map((e,t)=>(0,A.jsx)(`div`,{className:`min-w-0`,style:{paddingLeft:`${e.depth*20}px`},children:e.isFile?(0,A.jsx)(`span`,{className:`text-foreground/90 block truncate`,children:e.name}):(0,A.jsxs)(`span`,{className:`font-semibold text-foreground block truncate`,children:[e.name,`/`]})},t))})}catch{return null}},Me={backgroundColor:`var(--status-info)`,opacity:.6},Ne=(e,t,n)=>{try{let r=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-cVprFo3G.js"></script>
555
+ <script type="module" crossorigin src="/assets/main-fFwuYFwA.js"></script>
556
556
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-C0FnF6B9.js">
557
557
  <link rel="modulepreload" crossorigin href="/assets/runtime-auth-D66yq6ie.js">
558
558
  <link rel="modulepreload" crossorigin href="/assets/runtime-switch-BJM2k_uH.js">
@@ -572,7 +572,7 @@
572
572
  <link rel="modulepreload" crossorigin href="/assets/terminalApi-C6zlKnK1.js">
573
573
  <link rel="modulepreload" crossorigin href="/assets/types-BuiqMmh_.js">
574
574
  <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DCowZ2ab.js">
575
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-D4tlo3iY.js">
575
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-C2r3lwvo.js">
576
576
  <link rel="stylesheet" crossorigin href="/assets/src-iyTfdRD7.css">
577
577
  </head>
578
578
  <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-C5tTnNNM.js"></script>
77
+ <script type="module" crossorigin src="/assets/miniChat-ByXFq9Gm.js"></script>
78
78
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-C0FnF6B9.js">
79
79
  <link rel="modulepreload" crossorigin href="/assets/runtime-auth-D66yq6ie.js">
80
80
  <link rel="modulepreload" crossorigin href="/assets/runtime-switch-BJM2k_uH.js">
@@ -94,7 +94,7 @@
94
94
  <link rel="modulepreload" crossorigin href="/assets/terminalApi-C6zlKnK1.js">
95
95
  <link rel="modulepreload" crossorigin href="/assets/types-BuiqMmh_.js">
96
96
  <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DCowZ2ab.js">
97
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-D4tlo3iY.js">
97
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-C2r3lwvo.js">
98
98
  <link rel="stylesheet" crossorigin href="/assets/src-iyTfdRD7.css">
99
99
  </head>
100
100
  <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-D1KqMgLm.js"></script>
66
+ <script type="module" crossorigin src="/assets/mobile-DzYPMFOV.js"></script>
67
67
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-C0FnF6B9.js">
68
68
  <link rel="modulepreload" crossorigin href="/assets/runtime-auth-D66yq6ie.js">
69
69
  <link rel="modulepreload" crossorigin href="/assets/runtime-switch-BJM2k_uH.js">
@@ -83,7 +83,7 @@
83
83
  <link rel="modulepreload" crossorigin href="/assets/terminalApi-C6zlKnK1.js">
84
84
  <link rel="modulepreload" crossorigin href="/assets/types-BuiqMmh_.js">
85
85
  <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DCowZ2ab.js">
86
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-D4tlo3iY.js">
86
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-C2r3lwvo.js">
87
87
  <link rel="stylesheet" crossorigin href="/assets/src-iyTfdRD7.css">
88
88
  </head>
89
89
  <body class="h-full bg-background text-foreground">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openchambery/web",
3
- "version": "2.0.0-beta.15",
3
+ "version": "2.0.0-beta.17",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./server/index.js",
@@ -1,3 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToolOutputDialog-BBudjfdJ.js","assets/rolldown-runtime-C0FnF6B9.js","assets/runtime-fetch-CiqQd__Y.js","assets/runtime-auth-D66yq6ie.js","assets/runtime-switch-BJM2k_uH.js","assets/vendor-base-ui-CnHfUmDN.js","assets/useUIStore-Brsa2mKs.js","assets/vendor-zustand-B4dlGEM2.js","assets/vendor-react-DLPElpoQ.js","assets/vendor-pierre-diffs-DX7XTPG3.js","assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js","assets/vendor-hast-util-to-html-B0p1k5Xa.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-DpDied8H.js","assets/vendor-reactuses-core-Dq5ocTF8.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/button-EzCcYrQl.js","assets/persistence-CMWO3jFo.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/store-jaP79mqI.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/dialog-Cpu-rKij.js","assets/Icon-DKd015RD.js","assets/useThemeSystem-DMzWVJaW.js","assets/markdownTheme-DM5h1i18.js","assets/appThemeRegistry-B7iM6Wwn.js","assets/platform-BxU3ZvQ0.js","assets/vendor-opencode-client-C12gfjag.js","assets/useMobileNavigationStore-DrdLEZXl.js","assets/vendor-tanstack-react-query-D7pys_c9.js","assets/vendor-sonner-DVzioF3d.js","assets/useAssistantUIStore-B75cQm_z.js","assets/vendor-zod-Dzk5kdUU.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/MarkdownRenderer-Cr5OVKst.js","assets/markdownHeightCache-emzgqB2K.js","assets/dualLimitLru-D8Sphgua.js","assets/markdown-worker-bS5OgGO3.js","assets/useEffectiveDirectory-Djy7IP9p.js","assets/imageSource-BpUsiwFd.js","assets/relay-image-stream-D2XooXKZ.js","assets/useWorkerHighlightedLines-C8k8KbYV.js","assets/tooltip-DwUy2erJ.js","assets/vendor-tanstack-react-virtual-tlDgH6PG.js"])))=>i.map(i=>d[i]);
2
- import{o as e,r as t}from"./rolldown-runtime-C0FnF6B9.js";import{c as n,i as r,n as i}from"./runtime-switch-BJM2k_uH.js";import{G as a,H as o,J as s,Q as c,V as l,X as u,Y as d,dt as f,rt as p}from"./persistence-CMWO3jFo.js";import{a as m}from"./vendor-zustand-B4dlGEM2.js";import{nt as h,rt as g}from"./vendor-base-ui-CnHfUmDN.js";import{n as _,r as v}from"./platform-BxU3ZvQ0.js";import{n as y}from"./useUIStore-Brsa2mKs.js";import{n as b}from"./vendor-react-DLPElpoQ.js";import{o as x}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{s as S}from"./vendor-tanstack-react-query-D7pys_c9.js";import{r as C}from"./vendor-sonner-DVzioF3d.js";import{a as w,d as T,f as E,i as D,n as O,r as k}from"./vendor-reactuses-core-Dq5ocTF8.js";import{f as A,r as j,t as M}from"./button-EzCcYrQl.js";import{a as N,n as P}from"./MobileShareBridge-B3q5Bvca.js";import{C as F,_ as I,a as L,f as R,g as z,j as B,k as V,l as H,n as U,r as ee,s as te,t as W,u as ne,y as re}from"./MobileDetailNavigation-AxTBUyCz.js";import{br as ie,dt as ae,o as oe,oo as se,qt as ce,yn as le,yr as G}from"./useMobileNavigationStore-DrdLEZXl.js";import{i as K,n as q,r as ue}from"./useAssistantUIStore-B75cQm_z.js";import{a as de,i as J,n as Y,o as X,r as fe,t as pe}from"./dialog-Cpu-rKij.js";import{t as me}from"./AgentAvatar-Cxm7uMtK.js";import{n as Z}from"./Icon-DKd015RD.js";import{i as he}from"./OverlayScrollbar-SUdC3Pqe.js";import{n as ge}from"./textarea-B9pCxe-7.js";import{D as _e,S as ve,T as ye,a as be,c as xe,d as Se,f as Ce,i as we,l as Te,m as Ee,n as De,o as Oe,p as ke,r as Ae,t as je,u as Me}from"./sessionChangeSummary-DrefB13y.js";import{a as Ne,n as Pe,r as Fe,t as Ie}from"./fileMentionTouchSelection-DJnbFm0E.js";import{o as Le,t as Re}from"./MarkdownRenderer-Cr5OVKst.js";import{c as ze,s as Be}from"./imageSource-BpUsiwFd.js";import{a as Ve,t as He}from"./sessionLookup-CwaDQtYl.js";import{a as Ue,i as We,n as Ge,r as Ke,t as qe}from"./context-menu-DSrUbCPh.js";import{i as Je,n as Ye,r as Xe}from"./assistant-attachment-cache-sG8YQsVs.js";var Ze=b();function Qe(e){return[...e].sort((e,t)=>{let n=e.latestMessagePreview?.createdAt??-1/0,r=t.latestMessagePreview?.createdAt??-1/0;return n===r?0:r-n})}var Q=e(g(),1),$=h();function $e({snapshot:e,rowClassName:t}){let{t:n}=A(),[r,i]=Q.useState(!1),a=Q.useRef(!1),o=O(async()=>{if(!a.current){a.current=!0,i(!0);try{(await H(e)).failed&&C.error(n(`assistants.unread.markAllFailed`))}catch{C.error(n(`assistants.unread.markAllFailed`))}finally{a.current=!1,i(!1)}}});return e.assistants.some(e=>(e.unreadCount??0)>0)?(0,$.jsx)(`div`,{className:t,children:(0,$.jsx)(M,{type:`button`,variant:`ghost`,size:`xs`,onClick:o,className:`max-w-full whitespace-normal text-right`,disabled:r||!e.assistants.some(e=>(e.unreadCount??0)>0&&e.readTip),"aria-busy":r,children:n(`assistants.unread.markAll`)})}):null}var et=e=>{let t=(0,Ze.c)(17),{name:n,emoji:r,size:i,label:a,working:o,className:s}=e,c=i===void 0?24:i,l=o!==void 0&&o,{t:u}=A(),d=`calc(${c}px * var(--dpt-n, 1))`,f;t[0]===s?f=t[1]:(f=j(`relative inline-block shrink-0 align-middle leading-none`,s),t[0]=s,t[1]=f);let p;t[2]===d?p=t[3]:(p={width:d,height:d},t[2]=d,t[3]=p);let m;t[4]!==r||t[5]!==a||t[6]!==n||t[7]!==c?(m=(0,$.jsx)(me,{name:n,emoji:r,size:c,label:a,shape:`circle`}),t[4]=r,t[5]=a,t[6]=n,t[7]=c,t[8]=m):m=t[8];let h;t[9]!==u||t[10]!==l?(h=l?(0,$.jsx)(`span`,{className:`pointer-events-none absolute right-0 bottom-0 size-2.5 translate-x-0.5 translate-y-0.5 rounded-full bg-[var(--status-success)] ring-2 ring-background`,"data-assistant-working-dot":``,"aria-label":u(`assistants.contact.working`)}):null,t[9]=u,t[10]=l,t[11]=h):h=t[11];let g;return t[12]!==f||t[13]!==p||t[14]!==m||t[15]!==h?(g=(0,$.jsxs)(`span`,{className:f,style:p,"data-assistant-working-avatar":``,children:[m,h]}),t[12]=f,t[13]=p,t[14]=m,t[15]=h,t[16]=g):g=t[16],g},tt=m(e=>({workingByID:{},setWorking:(t,n)=>e(e=>({workingByID:{...e.workingByID,[t]:n}}))})),nt=({sending:e=!1,processing:t=!1,serverWorking:n=!1})=>e||t||n,rt=(e,t)=>{let n=(0,Ze.c)(5),r=t!==void 0&&t,i;n[0]===e?i=n[1]:(i=t=>!!t.workingByID[e],n[0]=e,n[1]=i);let a=tt(i),o;return n[2]!==a||n[3]!==r?(o=nt({processing:a,serverWorking:r}),n[2]=a,n[3]=r,n[4]=o):o=n[4],o};function it(e){let t=(0,Ze.c)(12),{assistantID:n,position:a}=e,o=Q.useRef(null),s=Q.useRef(!1),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={busy:!1,done:!1,retryAt:0},t[0]=c):c=t[0];let l=Q.useRef(c),[u]=Q.useState(ut),d;t[1]!==n||t[2]!==a||t[3]!==u?(d=()=>{let e=o.current;if(!e||!s.current||l.current.busy||l.current.done||Date.now()<l.current.retryAt||u.transport!==r()||u.generation!==i()||document.visibilityState!==`visible`||(_()?!document.documentElement.classList.contains(`oc-native-app-active`):!document.hasFocus())||e.parentElement?.closest(`[inert], [aria-hidden="true"]`))return;let t=e.closest(`[data-assistant-contact-transcript]`);if(!t||t.scrollHeight-t.scrollTop-t.clientHeight>2)return;let c=e.getBoundingClientRect(),d=t.getBoundingClientRect(),f=window.visualViewport,p=f?.offsetTop??0,m=p+(f?.height??window.innerHeight);c.height<=0||c.width<=0||c.bottom>Math.min(d.bottom,m)||c.top<Math.max(d.top,p)||c.right<=Math.max(d.left,0)||c.left>=Math.min(d.right,window.innerWidth)||(l.current.busy=!0,ne(n,a).then(()=>{l.current.done=!0}).catch(()=>{l.current.retryAt=Date.now()+15e3}).finally(()=>{l.current.busy=!1}))},t[1]=n,t[2]=a,t[3]=u,t[4]=d):d=t[4];let f=O(d),p;t[5]===f?p=t[6]:(p=e=>{s.current=e.some(lt),f()},t[5]=f,t[6]=p);let m;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m={threshold:1},t[7]=m):m=t[7],D(o,O(p),m),k(`visibilitychange`,f,ct),k(`focus`,f,st),k(`resize`,f,ot);let h,g;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>o.current?.closest(`[data-assistant-contact-transcript]`),g={passive:!0},t[8]=h,t[9]=g):(h=t[8],g=t[9]),k(`scroll`,f,h,g);let v;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(v={attributes:!0,attributeFilter:[`class`]},t[10]=v):v=t[10],T(f,at,v),w(f,15e3);let y;return t[11]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(`span`,{ref:o,"aria-hidden":`true`,className:`block h-px w-px shrink-0`,"data-assistant-read-marker":``}),t[11]=y):y=t[11],y}function at(){return document.documentElement}function ot(){return window.visualViewport}function st(){return window}function ct(){return document}function lt(e){return e.isIntersecting&&e.intersectionRatio===1}function ut(){return{transport:r(),generation:i()}}var dt=e=>e?.directories.flatMap(({directory:e,sessions:t})=>e?t.filter(e=>!e.time.archived).map(t=>({...t,directory:e||t.location?.directory||t.directory||``})).filter(e=>e.directory.length>0):[])??null,ft=Q.forwardRef(({query:e,isMobile:t,listId:n,onHighlightChange:r,onSelect:i,onClose:a},o)=>{let{t:s}=A(),c=ze(),l=S({...ie(c),select:dt}),u=Q.useMemo(()=>ae({sessions:l.data??[],currentSessionId:null,searchQuery:e}),[l.data,e]),[d,f]=Q.useState({query:e,index:0}),p=Math.min(d.query===e?d.index:0,Math.max(0,u.length-1)),m=Q.useRef(null),h=Q.useRef([]),g=Q.useMemo(Ie,[]);k(`pointerdown`,e=>{e.target instanceof Node&&!m.current?.contains(e.target)&&a()},void 0,{capture:!0}),Q.useLayoutEffect(()=>{h.current[p]?.scrollIntoView?.({block:`nearest`})},[p]),Q.useLayoutEffect(()=>{r(u.length?`${n}-${p}`:void 0)},[p,n,u.length,r]);let _=O(t=>{if(t===`Escape`){a();return}u.length&&(t===`ArrowDown`&&f({query:e,index:(p+1)%u.length}),t===`ArrowUp`&&f({query:e,index:(p-1+u.length)%u.length}),(t===`Enter`||t===`Tab`)&&i(u[p]))});return Q.useImperativeHandle(o,()=>({keyDown:_}),[_]),(0,$.jsxs)(Pe,{ref:m,isMobile:t,className:`max-w-[640px] max-h-64`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 px-3 py-1`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-[length:calc(var(--text-meta)*0.875)] leading-4 text-muted-foreground`,children:s(`assistants.contact.sessionMention.scope`)}),(0,$.jsx)(M,{type:`button`,size:`xs`,variant:`ghost`,"aria-label":s(`dialog.common.actions.close`),onClick:a,children:(0,$.jsx)(Z,{name:`close`,className:`size-4`})})]}),l.isPending?(0,$.jsx)(`p`,{role:`status`,className:`px-3 py-2 typography-meta text-muted-foreground`,children:s(`common.loading`)}):null,l.isError?(0,$.jsxs)(`div`,{role:`alert`,className:`px-3 py-2 typography-meta text-[var(--status-error)]`,children:[s(`assistants.contact.sessionMention.loadFailed`),(0,$.jsx)(M,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void l.refetch(),children:s(`chat.history.retry`)})]}):null,l.isSuccess&&!u.length?(0,$.jsx)(`p`,{role:`status`,className:`px-3 py-2 typography-meta text-muted-foreground`,children:s(l.data===null?`common.unavailable`:`sessions.sidebar.empty.noMatches.title`)}):null,(0,$.jsx)(ge,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,$.jsx)(`div`,{id:n,role:`listbox`,"aria-label":s(`chat.fileMentionAutocomplete.groups.sessions`),className:`p-1.5`,children:u.map((r,a)=>(0,$.jsxs)(`div`,{id:`${n}-${a}`,role:`option`,"aria-selected":a===p,ref:e=>{h.current[a]=e},className:j(`flex min-h-10 cursor-pointer items-center gap-2 rounded-md px-1.5 py-1 typography-ui-label`,Fe(t,a===p)),onMouseDown:e=>e.preventDefault(),onMouseMove:()=>f({query:e,index:a}),onPointerDown:e=>{e.pointerType===`touch`&&g.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&g.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&g.pointerUp(()=>i(r))&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>g.pointerCancel(),onClick:()=>g.click(()=>i(r)),children:[(0,$.jsx)(Z,{name:`chat-thread`,className:`size-4 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate font-medium leading-5`,title:r.title,children:r.title||s(`chat.fileMentionAutocomplete.untitledSession`)}),(0,$.jsx)(`div`,{className:`truncate text-[length:calc(var(--text-meta)*0.875)] leading-4 text-muted-foreground`,title:r.directory,children:r.directory})]})]},`${r.directory}:${r.id}`))})}),t?null:(0,$.jsx)(`div`,{className:`mx-1.5 shrink-0 border-t px-1.5 py-1 text-[length:calc(var(--text-meta)*0.875)] leading-4 text-muted-foreground`,children:s(`chat.autocomplete.keyboardHint`)})]})}),pt=e=>{let t=(0,Ze.c)(87),n,r,i,c;t[0]===e?(n=t[1],r=t[2],i=t[3],c=t[4]):({active:n,working:c,onChange:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=c);let p=c!==void 0&&c,{t:m}=A(),h;t[5]===i.value?h=t[6]:(h=()=>({canonical:i.value,document:a(i.value,new Map)}),t[5]=i.value,t[6]=h);let[g,_]=Q.useState(h),v;t[7]!==g.canonical||t[8]!==g.document||t[9]!==i.value?(v=g.canonical===i.value?g.document:a(i.value,new Map),t[7]=g.canonical,t[8]=g.document,t[9]=i.value,t[10]=v):v=t[10];let y=v,[b,x]=Q.useState(0),[S,C]=Q.useState(!0),[w,T]=Q.useState(!1),[E,D]=Q.useState(),k=Q.useRef(null),M=Q.useRef(null),N=Q.useRef(null),P=Q.useRef(null),F;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(F=Te(),t[11]=F):F=t[11];let I=Q.useRef(F),L=Q.useId(),R;t[12]!==n||t[13]!==w||t[14]!==b||t[15]!==S||t[16]!==y.text||t[17]!==i.disabled||t[18]!==i.pending?(R=n&&!i.pending&&!i.disabled&&!S&&!w?Ne({text:y.text,cursor:b}):null,t[12]=n,t[13]=w,t[14]=b,t[15]=S,t[16]=y.text,t[17]=i.disabled,t[18]=i.pending,t[19]=R):R=t[19];let z=R,B=z?.kind===`mention`?z:null,V;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(V=()=>{P.current!==null&&(k.current?.focus({preventScroll:!0}),k.current?.setSelectionRange(P.current,P.current),P.current=null)},t[20]=V):V=t[20];let H;t[21]===y?H=t[22]:(H=[y],t[21]=y,t[22]=H),Q.useLayoutEffect(V,H);let U;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(U=()=>C(!0),t[23]=U):U=t[23];let ee=O(U),te;t[24]!==w||t[25]!==b||t[26]!==y||t[27]!==r?(te=(e,t,n)=>{let i=n===void 0||n,a=u(e);a.ok&&(i&&(I.current=Me(I.current,{before:xe(y,[],{start:k.current?.selectionStart??b,end:k.current?.selectionEnd??b}),after:xe(e,[],{start:t,end:t})})),w||(P.current=t),x(t),_({canonical:a.text,document:e}),r(a.text))},t[24]=w,t[25]=b,t[26]=y,t[27]=r,t[28]=te):te=t[28];let W=O(te),ne;t[29]!==W||t[30]!==y||t[31]!==B||t[32]!==m?(ne=e=>{if(!B)return;let t=e.title||m(`chat.fileMentionAutocomplete.untitledSession`),n=o(y,B.tokenStart,B.tokenEnd,{id:`session:${e.id}:${crypto.randomUUID()}`,kind:`session`,sessionId:e.id,display:f({trigger:`@`,icon:`chat-thread`,label:t})},{inlineBoundaries:!0,padDocumentEdges:!0}),r=n.caret+ +(n.document.text[n.caret]===` `);C(!0),W(n.document,r)},t[29]=W,t[30]=y,t[31]=B,t[32]=m,t[33]=ne):ne=t[33];let re=O(ne),ie;t[34]!==W||t[35]!==y?(ie=(e,t)=>{let n=e.currentTarget;if(n.selectionStart===n.selectionEnd||!e.clipboardData||!y.references.some(e=>e.start<n.selectionEnd&&e.end>n.selectionStart))return;let r=l(n.selectionStart,n.selectionEnd,y.references)??{start:n.selectionStart,end:n.selectionEnd},i=u({text:y.text.slice(r.start,r.end),references:y.references.filter(e=>e.start>=r.start&&e.end<=r.end).map(e=>({...e,start:e.start-r.start,end:e.end-r.start}))});if(i.ok&&(e.preventDefault(),e.clipboardData.setData(`text/plain`,i.text),t)){let e=s(y,y.text.slice(0,r.start)+y.text.slice(r.end),r.start,r.start);W(e.document,e.caret)}},t[34]=W,t[35]=y,t[36]=ie):ie=t[36];let ae=O(ie),oe;t[37]!==y.references||t[38]!==y.text?(oe=Ee(y.text,y.references.map(mt))?.map(ht),t[37]=y.references,t[38]=y.text,t[39]=oe):oe=t[39];let se=oe,ce=y.text,le=i.pending||p,G=i.pending===!0,K=i.layout===`inline`?`py-3 leading-6`:`pt-4 pb-2`,q;t[40]!==i.textLayoutClassName||t[41]!==K?(q=j(`whitespace-pre-wrap break-words overflow-hidden px-3 typography-markdown md:typography-ui-label`,K,i.textLayoutClassName),t[40]=i.textLayoutClassName,t[41]=K,t[42]=q):q=t[42];let ue;t[43]!==W||t[44]!==y?(ue=(e,t)=>{let n=s(y,e,t?.target.selectionStart??e.length,t?.target.selectionEnd??e.length);W(n.document,n.caret),C(t?.nativeEvent?.inputType===`insertFromPaste`)},t[43]=W,t[44]=y,t[45]=ue):ue=t[45];let de=B?L:void 0,J=B?E:void 0,Y;t[46]===i.textareaProps?Y=t[47]:(Y=e=>{i.textareaProps?.onScroll?.(e),M.current&&(M.current.scrollTop=e.currentTarget.scrollTop,M.current.scrollLeft=e.currentTarget.scrollLeft)},t[46]=i.textareaProps,t[47]=Y);let X,fe;t[48]!==ae||t[49]!==i.textareaProps?(X=e=>{i.textareaProps?.onCopy?.(e),e.defaultPrevented||ae(e,!1)},fe=e=>{i.textareaProps?.onCut?.(e),e.defaultPrevented||ae(e,!0)},t[48]=ae,t[49]=i.textareaProps,t[50]=X,t[51]=fe):(X=t[50],fe=t[51]);let pe;t[52]===i.textareaProps?pe=t[53]:(pe=e=>{x(e.currentTarget.selectionStart),i.textareaProps?.onSelect?.(e)},t[52]=i.textareaProps,t[53]=pe);let me,Z;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(me=()=>{T(!0)},Z=e=>{T(!1),x(e.currentTarget.selectionStart)},t[54]=me,t[55]=Z):(me=t[54],Z=t[55]);let he;t[56]!==W||t[57]!==w||t[58]!==y||t[59]!==B||t[60]!==i.textareaProps?(he=e=>{if(i.textareaProps?.onKeyDown?.(e),!(e.defaultPrevented||ye(e))){if(w){e.key===`Enter`&&e.preventDefault();return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`z`){let t=e.shiftKey?Se(I.current,y):Ce(I.current,y);t&&(e.preventDefault(),I.current=t.history,W(t.snapshot.document,t.snapshot.selection.end,!1),C(!0));return}if(e.key===`Backspace`||e.key===`Delete`){let t=d(y,{key:e.key,selectionStart:e.currentTarget.selectionStart,selectionEnd:e.currentTarget.selectionEnd,altKey:e.altKey});if(t){e.preventDefault(),W(t.document,t.caret),C(!0);return}}B&&[`ArrowDown`,`ArrowUp`,`Enter`,`Tab`,`Escape`].includes(e.key)&&(e.preventDefault(),e.stopPropagation(),N.current?.keyDown(e.key))}},t[56]=W,t[57]=w,t[58]=y,t[59]=B,t[60]=i.textareaProps,t[61]=he):he=t[61];let ge;t[62]!==i.textareaProps||t[63]!==de||t[64]!==J||t[65]!==Y||t[66]!==X||t[67]!==fe||t[68]!==pe||t[69]!==he?(ge={...i.textareaProps,"aria-controls":de,"aria-activedescendant":J,"aria-autocomplete":`list`,onScroll:Y,onCopy:X,onCut:fe,onSelect:pe,onCompositionStart:me,onCompositionEnd:Z,onKeyDown:he},t[62]=i.textareaProps,t[63]=de,t[64]=J,t[65]=Y,t[66]=X,t[67]=fe,t[68]=pe,t[69]=he,t[70]=ge):ge=t[70];let _e;t[71]!==ee||t[72]!==L||t[73]!==B||t[74]!==i.isMobile||t[75]!==re?(_e=B?(0,$.jsx)(ft,{ref:N,query:B.query,isMobile:i.isMobile??!1,listId:L,onHighlightChange:D,onSelect:re,onClose:ee}):null,t[71]=ee,t[72]=L,t[73]=B,t[74]=i.isMobile,t[75]=re,t[76]=_e):_e=t[76];let be;return t[77]!==y.text||t[78]!==se||t[79]!==i||t[80]!==le||t[81]!==G||t[82]!==q||t[83]!==ue||t[84]!==ge||t[85]!==_e?(be=(0,$.jsx)(ve,{...i,value:ce,pending:le,disableInputWhilePending:G,inputRef:k,highlightedContent:se,highlightRef:M,textLayoutClassName:q,onChange:ue,textareaProps:ge,children:_e}),t[77]=y.text,t[78]=se,t[79]=i,t[80]=le,t[81]=G,t[82]=q,t[83]=ue,t[84]=ge,t[85]=_e,t[86]=be):be=t[86],be};function mt(e){return{start:e.start,end:e.end,priority:103,...c(e)}}function ht(e,t){return(0,$.jsx)(`span`,{className:e.className,children:e.visual?(0,$.jsx)(ke,{visual:e.visual,text:e.text}):e.text},`${t}-${e.text.length}`)}var gt=`max-h-72 max-w-full rounded-[1.35rem] border border-border/40 object-contain cursor-zoom-in`;function _t({assistantID:e,descriptor:t,onShowPopup:n}){let{t:r}=A(),i=ze(),{attachmentID:a,sha256:o,size:s,mime:c,filename:l}=t,u=Q.useMemo(()=>({type:`file`,attachmentID:a,sha256:o,size:s,mime:c,filename:l}),[a,o,s,c,l]),d=c.startsWith(`image/`),[f,p]=Q.useState(0),[m,h]=Q.useState(``),[g,_]=Q.useState(!1),[v,y]=Q.useState(!1),b=Q.useRef(null),x=Q.useRef([]);Q.useEffect(()=>{h(``),_(!1);let t=new AbortController,n;return d&&Xe(e,u,{signal:t.signal}).then(e=>{if(t.signal.aborted){e.release();return}n=e.release,h(e.url)}).catch(()=>{t.signal.aborted||_(!0)}),()=>{t.abort(),n?.()}},[e,u,i,d,f]),Q.useEffect(()=>()=>{b.current?.abort(),x.current.forEach(e=>URL.revokeObjectURL(e)),x.current=[]},[e,u,i]);let S=O(async()=>{if(b.current)return;let t=new AbortController;b.current=t,y(!0),_(!1);try{let n=await Ye(e,u,{signal:t.signal});if(t.signal.aborted)return;x.current.forEach(e=>URL.revokeObjectURL(e));let i=URL.createObjectURL(n);x.current=[i];let a=document.createElement(`a`);a.href=i,a.download=l||r(`assistants.contact.attachment.file`),document.body.appendChild(a),a.click(),a.remove()}catch{t.signal.aborted||_(!0)}finally{b.current===t&&(b.current=null),t.signal.aborted||y(!1)}}),C=l||r(d?`assistants.contact.attachment.image`:`assistants.contact.attachment.file`),w=O(()=>{!n||!m||n({open:!0,title:C,content:``,metadata:{tool:`image-preview`,filename:C,mime:c},image:{url:m,mimeType:c,filename:C,size:s,gallery:[{url:m,mimeType:c,filename:C,size:s}],index:0}})});return d&&m&&!g?(0,$.jsx)(`img`,{src:m,alt:C,className:gt,onError:()=>_(!0),onClick:w,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),w())},role:`button`,tabIndex:0,"data-assistant-contact-image":``}):(0,$.jsxs)(`div`,{className:`flex max-w-full flex-col gap-1 rounded-[1.25rem] bg-[var(--surface-muted)] px-3.5 py-2.5 ring-1 ring-inset ring-[var(--surface-subtle)]`,"data-assistant-contact-file":``,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,$.jsx)(Z,{name:`file-text`,className:`size-4 shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`truncate typography-ui`,children:C})]}),g?(0,$.jsx)(`p`,{role:`alert`,className:`typography-micro text-[var(--status-error)]`,children:r(`assistants.contact.attachment.loadFailed`)}):null,d&&!g||v?(0,$.jsx)(`span`,{role:`status`,className:`typography-micro text-muted-foreground`,children:r(`common.loading`)}):(0,$.jsx)(M,{type:`button`,size:`sm`,variant:`ghost`,onClick:d?()=>p(e=>e+1):()=>void S(),children:r(g?`chat.history.retry`:`assistants.contact.attachment.download`)})]})}function vt(e){let t=(0,Ze.c)(27),{part:n,onShowPopup:r}=e,{t:i}=A(),a=/^(?:https?:|data:|blob:)/i.test(n.url)?n.url:``,o=Be(a,``),[s,c]=Q.useState(!1),l;t[0]!==n.filename||t[1]!==i?(l=n.filename||i(`assistants.contact.attachment.image`),t[0]=n.filename,t[1]=i,t[2]=l):l=t[2];let u=l,d;t[3]!==u||t[4]!==r||t[5]!==o?(d=()=>{!r||!o||r({open:!0,title:u,content:``,metadata:{tool:`image-preview`,filename:u},image:{url:o,filename:u,gallery:[{url:o,filename:u}],index:0}})},t[3]=u,t[4]=r,t[5]=o,t[6]=d):d=t[6];let f=O(d);if(n.mime.startsWith(`image/`)&&o&&!s){let e;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>c(!0),t[7]=e):e=t[7];let n;t[8]===f?n=t[9]:(n=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),f())},t[8]=f,t[9]=n);let r;return t[10]!==u||t[11]!==f||t[12]!==o||t[13]!==n?(r=(0,$.jsx)(`img`,{src:o,alt:u,className:gt,onError:e,onClick:f,onKeyDown:n,role:`button`,tabIndex:0,"data-assistant-contact-image":``}),t[10]=u,t[11]=f,t[12]=o,t[13]=n,t[14]=r):r=t[14],r}let p;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(Z,{name:`file-text`,className:`size-4 shrink-0 text-muted-foreground`}),t[15]=p):p=t[15];let m;t[16]!==n.filename||t[17]!==i?(m=n.filename||i(`assistants.contact.attachment.file`),t[16]=n.filename,t[17]=i,t[18]=m):m=t[18];let h;t[19]===m?h=t[20]:(h=(0,$.jsx)(`span`,{className:`truncate typography-ui`,children:m}),t[19]=m,t[20]=h);let g;t[21]!==s||t[22]!==i?(g=s?(0,$.jsx)(M,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>c(!1),children:i(`chat.history.retry`)}):null,t[21]=s,t[22]=i,t[23]=g):g=t[23];let _;return t[24]!==h||t[25]!==g?(_=(0,$.jsxs)(`div`,{className:`flex max-w-full items-center gap-2.5 rounded-[1.25rem] bg-[var(--surface-muted)] px-3.5 py-2.5`,"data-assistant-contact-file":``,children:[p,h,g]}),t[24]=h,t[25]=g,t[26]=_):_=t[26],_}function yt(e){let t=(0,Ze.c)(5),{assistantID:n,part:r,onShowPopup:i}=e,a=ze(),o;return t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==a?(o=`attachmentID`in r?(0,$.jsx)(_t,{assistantID:n,descriptor:r,onShowPopup:i},`${a}:${n}:${r.attachmentID}:${r.sha256}`):(0,$.jsx)(vt,{part:r,onShowPopup:i},`${a}:${r.url}`),t[0]=n,t[1]=i,t[2]=r,t[3]=a,t[4]=o):o=t[4],o}var bt=[],xt=e=>e.flatMap(e=>e.type===`text`&&e.text.trim()?[e.text]:[]).join(`
3
- `),St=(e,t,n,r=Date.now())=>({assistantID:e,messageID:t,parts:n,status:`sending`,createdAt:r}),Ct=(e,t)=>{let n=e.filter(e=>e.assistantID===t);return n.length===e.length?e:n},wt=(e,t)=>{let n=e.filter(e=>e.assistantID===t);return n.length===e.length?e:n},Tt=(e,t,n,r)=>({messageID:t?`${e.turnID}:preview:${t.bubbleIndex}`:`${e.turnID}:preview:${r}`,assistantID:e.assistantID,role:`assistant`,turnID:e.turnID,bubbleIndex:t?.bubbleIndex??0,createdAt:t?.occurredAt??e.occurredAt,ordinal:n,status:r,fromAssistantID:null,fromAssistantName:null,parts:t?[{type:`text`,text:t.text}]:[],text:t?.text??``,cards:[]}),Et=(e,t,n)=>{let r=e.bubbles.filter(e=>!t.has(e.bubbleIndex)).map((t,r)=>Tt(e,t,n+r,t.done?`complete`:`streaming`));return e.status===`failed`?[...r,Tt(e,null,n+r.length,`failed`)]:e.status===`admitted`||e.status===`streaming`?[...r,Tt(e,null,n+r.length,`admitted`)]:r},Dt=(e,t,n,r=[])=>{let i=new Set(e.map(e=>e.messageID)),a=t.flatMap((t,r)=>t.assistantID!==n||i.has(t.messageID)?[]:[{messageID:t.messageID,assistantID:n,role:`user`,turnID:t.messageID,bubbleIndex:0,createdAt:t.createdAt,ordinal:e.length+r,status:t.status,fromAssistantID:null,fromAssistantName:null,parts:[...t.parts],text:xt(t.parts),cards:[]}]),o=a.length===0?e:[...e,...a],s=r.filter(e=>e.assistantID===n);if(s.length===0)return o;let c=new Map,l=new Map;o.forEach((e,t)=>{if(c.set(e.turnID,t),e.role!==`assistant`||e.messageID.includes(`:preview:`))return;let n=l.get(e.turnID)??new Set;n.add(e.bubbleIndex),l.set(e.turnID,n)});let u=new Map,d=[];for(let e of s){let t=Et(e,l.get(e.turnID)??new Set,o.length+d.length);if(t.length===0)continue;let n=c.get(e.turnID);if(n===void 0){if(e.status===`failed`&&o.some(t=>t.turnID!==e.turnID))continue;d.push(...t);continue}let r=u.get(n)??[];r.push(...t),u.set(n,r)}return u.size===0&&d.length===0?o:o.flatMap((e,t)=>[e,...u.get(t)??[]]).concat(d)},Ot=(e,t)=>{let n=new Set(t.map(e=>e.messageID)),r=e.filter(e=>!n.has(e.messageID));return r.length===e.length?e:r},kt=(e,t)=>e.map(e=>e.messageID===t?{...e,status:`admitted`}:e),At=(e,t,n,r=Date.now())=>{let i=e.filter(e=>e.assistantID!==t||e.status!==`failed`||e.turnID===n);return i.some(e=>e.assistantID===t&&e.turnID===n)?i.length===e.length?e:i:[...i,{assistantID:t,turnID:n,status:`admitted`,bubbles:[],occurredAt:r}]},jt=(e,t,n)=>!t?.turnID||!t.assistantID||n?.has(t.turnID)?e:At(e,t.assistantID,t.turnID,t.admittedAt),Mt=(e,t)=>{let n=t.assistantID,r=t.pendingSendTurnIDs??new Set,i=t.settledTurnIDs??new Set,a=typeof t.snapshotRevision==`number`&&Number.isFinite(t.snapshotRevision)?t.snapshotRevision:null,o=t.admissionRevisionByTurnID instanceof Map?t.admissionRevisionByTurnID:new Map(Object.entries(t.admissionRevisionByTurnID??{}).map(([e,t])=>[e,Number(t)])),s=t.occurredAt??Date.now(),c=t.activeContactTurn&&t.activeContactTurn.turnID?t.activeContactTurn:null,l=!!(t.serverWorking||c),u=jt(e,c?{assistantID:n,turnID:c.turnID,admittedAt:c.admittedAt}:null,i),d=Array.isArray(t.messages)?t.messages:[];for(let e of d)e.role===`assistant`&&e.status===`error`&&(r.has(e.turnID)||i.has(e.turnID)||(u=Pt(u,{assistantID:n,turnID:e.turnID,status:`error`,error:e.text||`upstream_error`,occurredAt:s})));if(u=Ft(u,d),l){let t=u.filter(e=>{if(e.assistantID!==n||e.status!==`admitted`&&e.status!==`streaming`||r.has(e.turnID)||c&&e.turnID===c.turnID)return!0;let t=o.get(e.turnID);return typeof t==`number`&&a!=null&&a<t?!0:typeof t==`number`&&a!=null&&a>=t&&e.turnID!==c?.turnID?!1:!c||e.turnID===c.turnID});return t.length===e.length&&t.every((t,n)=>t===e[n])?e:t}if(a==null)return u.length===e.length&&u.every((t,n)=>t===e[n])?e:u;let f=u.filter(e=>{if(e.assistantID!==n||e.status!==`admitted`&&e.status!==`streaming`||r.has(e.turnID))return!0;if(i.has(e.turnID))return!1;let t=o.get(e.turnID);return typeof t==`number`&&a<t});return f.length===e.length&&f.every((t,n)=>t===e[n])?e:f.length===u.length?u:f},Nt=(e,t)=>At(e,t.assistantID,t.turnID,t.occurredAt).map(e=>{if(e.assistantID!==t.assistantID||e.turnID!==t.turnID||e.status===`failed`||e.status===`complete`)return e;let n=e.bubbles.find(e=>e.bubbleIndex===t.bubbleIndex);if(n?.done)return e;let r=n?{...n,text:`${n.text}${t.delta}`,done:t.done,occurredAt:t.occurredAt}:{bubbleIndex:t.bubbleIndex,text:t.delta,done:t.done,occurredAt:t.occurredAt},i=n?e.bubbles.map(e=>e.bubbleIndex===t.bubbleIndex?r:e):[...e.bubbles,r].sort((e,t)=>e.bubbleIndex-t.bubbleIndex);return{...e,status:`streaming`,bubbles:i}}),Pt=(e,t,n={})=>n.requireExisting&&!e.some(e=>e.assistantID===t.assistantID&&e.turnID===t.turnID)?e:At(e,t.assistantID,t.turnID,t.occurredAt).map(e=>e.assistantID!==t.assistantID||e.turnID!==t.turnID||e.status===`complete`||e.status===`failed`?e:{...e,status:t.status===`error`?`failed`:`complete`,...t.error?{error:t.error}:{}}),Ft=(e,t)=>{let n=new Set(t.map(e=>e.turnID).filter(Boolean)),r=t.length>0?t[t.length-1]?.turnID??null:null,i=[...e].reverse().find(e=>e.status===`admitted`||e.status===`streaming`)?.turnID??r,a=new Set(t.flatMap(e=>e.role===`assistant`?[e.turnID]:[])),o=e.filter(e=>e.status===`admitted`||e.status===`streaming`||!(e.status===`complete`&&a.has(e.turnID)||!n.has(e.turnID)||e.status===`failed`&&(i&&i!==e.turnID||r&&r!==e.turnID)));return o.length===e.length?e:o},It=(e,t,n)=>e.map(e=>e.messageID===t?{...e,status:`failed`,error:n}:e),Lt=(e,t)=>{if(e instanceof V){if(e.code===`no_provider`)return t.noProvider;if(e.code===`admission_timeout`||e.code===`generate_timeout`)return t.timedOut;if(e.message&&e.message!==e.code)return e.message}return B(e)?t.timedOut:t.sendFailed},Rt=()=>{let e=!1;return{tryAcquire:()=>!e&&(e=!0,!0),release:()=>{e=!1}}},zt=e=>{let t=e.text.trim();if(e.sending||!t&&e.attachments.length===0||!e.gate.tryAcquire())return{ok:!1};let n=[...t?[{type:`text`,text:t}]:[],...e.attachments.map(e=>({type:`file`,mime:e.mime,url:e.url,filename:e.name}))],r=e.createMessageID();return{ok:!0,messageID:r,parts:n,turn:St(e.assistantID,r,n,e.createdAt)}},Bt=e=>e.some(e=>e.status===`sending`),Vt=e=>e.some(e=>e.status===`admitted`||e.status===`streaming`),Ht=[`cursor-pointer rounded-[1.35rem] bg-[var(--surface-elevated)] ring-1 ring-inset ring-[var(--surface-subtle)]`,`px-3.5 py-3 text-left transition-[background-color,box-shadow,transform] duration-200 ease-out motion-reduce:transition-none`,`hover:-translate-y-px hover:bg-interactive-hover/45 hover:shadow-sm active:translate-y-0 motion-reduce:hover:translate-y-0`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`].join(` `),Ut=`${Ht} w-fit min-w-0 max-w-[min(100%,15rem)]`,Wt=`${Ht} w-fit min-w-0 max-w-[min(100%,20rem)]`;function Gt(e,t){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())}var Kt=e=>{let t=(0,Ze.c)(26),{card:n}=e,{t:r}=A(),i=_e(),a;t[0]===i?a=t[1]:(a=i&&!v(),t[0]=i,t[1]=a);let o=!!a,s=n.name,c=`${n.providerID}/${n.modelID}`,l;t[2]!==n.mode||t[3]!==c?(l=[c,n.mode].filter(Boolean),t[2]=n.mode,t[3]=c,t[4]=l):l=t[4];let u=l,d;t[5]!==n.assistantID||t[6]!==o?(d=()=>{if(o){oe.getState().openAssistant(n.assistantID);return}q(n.assistantID)},t[5]=n.assistantID,t[6]=o,t[7]=d):d=t[7];let f=O(d),p;t[8]===f?p=t[9]:(p=e=>{Gt(e,f)},t[8]=f,t[9]=p);let m=O(p),h;t[10]!==r||t[11]!==s?(h=r(`assistants.contact.card.assistant.aria`,{name:s}),t[10]=r,t[11]=s,t[12]=h):h=t[12];let g;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(`span`,{className:`relative inline-block size-6 shrink-0 leading-none`,children:(0,$.jsx)(`span`,{className:`flex size-6 items-center justify-center rounded-lg bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(Z,{name:`robot-2`,className:`size-3`})})}),t[13]=g):g=t[13];let _;t[14]===s?_=t[15]:(_=(0,$.jsx)(`h3`,{className:`min-w-0 truncate typography-ui-label font-medium text-foreground`,children:s}),t[14]=s,t[15]=_);let y;t[16]===u?y=t[17]:(y=u.length>0?(0,$.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:u.join(` · `)}):null,t[16]=u,t[17]=y);let b;t[18]!==_||t[19]!==y?(b=(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[g,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[_,y]})]}),t[18]=_,t[19]=y,t[20]=b):b=t[20];let x;return t[21]!==m||t[22]!==f||t[23]!==b||t[24]!==h?(x=(0,$.jsx)(`article`,{className:Ut,role:`button`,tabIndex:0,"aria-label":h,"data-assistant-contact-card":`assistant`,onClick:f,onKeyDown:m,children:b}),t[21]=m,t[22]=f,t[23]=b,t[24]=h,t[25]=x):x=t[25],x},qt=e=>{let t=(0,Ze.c)(25),{card:n}=e,{t:r}=A(),i=n.name,a;t[0]!==n.kind||t[1]!==n.time||t[2]!==n.timezone?(a=[n.kind,n.time,n.timezone].filter(Boolean),t[0]=n.kind,t[1]=n.time,t[2]=n.timezone,t[3]=a):a=t[3];let o=a.join(` `),s;t[4]!==n.prompt||t[5]!==o?(s=o.trim()||(typeof n.prompt==`string`?n.prompt.trim():``),t[4]=n.prompt,t[5]=o,t[6]=s):s=t[6];let c=s,l=O(Jt),u;t[7]===l?u=t[8]:(u=e=>{Gt(e,l)},t[7]=l,t[8]=u);let d=O(u),f;t[9]!==r||t[10]!==i?(f=r(`assistants.contact.card.schedule.aria`,{name:i}),t[9]=r,t[10]=i,t[11]=f):f=t[11];let p;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(`span`,{className:`relative inline-block size-6 shrink-0 leading-none`,children:(0,$.jsx)(`span`,{className:`flex size-6 items-center justify-center rounded-lg bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(Z,{name:`calendar`,className:`size-3`})})}),t[12]=p):p=t[12];let m;t[13]===i?m=t[14]:(m=(0,$.jsx)(`h3`,{className:`min-w-0 truncate typography-ui-label font-medium text-foreground`,children:i}),t[13]=i,t[14]=m);let h;t[15]===c?h=t[16]:(h=c?(0,$.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:c}):null,t[15]=c,t[16]=h);let g;t[17]!==m||t[18]!==h?(g=(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[p,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[m,h]})]}),t[17]=m,t[18]=h,t[19]=g):g=t[19];let _;return t[20]!==d||t[21]!==l||t[22]!==f||t[23]!==g?(_=(0,$.jsx)(`article`,{className:Ut,role:`button`,tabIndex:0,"aria-label":f,"data-assistant-contact-card":`schedule`,onClick:l,onKeyDown:d,children:g}),t[20]=d,t[21]=l,t[22]=f,t[23]=g,t[24]=_):_=t[24],_};function Jt(){y.getState().setActiveMainTab(`schedule`),y.getState().setScheduledTasksDialogOpen(!0)}var Yt=(e,t)=>t===`cancelled`?t:e===`busy`||e===`retry`?e:t===`error`||t===`question`||t===`complete`?t:e===`idle`?`complete`:t===`busy`||t===`retry`||t===`idle`?t:t||`busy`,Xt=e=>e===`cancelled`?`assistants.contact.card.session.status.cancelled`:e===`busy`?`assistants.contact.card.session.status.busy`:e===`retry`?`assistants.contact.card.session.status.retry`:e===`idle`?`assistants.contact.card.session.status.idle`:e===`complete`?`assistants.contact.card.session.status.complete`:e===`error`?`assistants.contact.card.session.status.error`:e===`question`?`assistants.contact.card.session.status.question`:null,Zt=e=>e===`busy`?`bg-[var(--status-info)]/10 text-[var(--status-info)]`:e===`retry`||e===`question`?`bg-[var(--status-warning)]/10 text-[var(--status-warning)]`:e===`error`?`bg-[var(--status-error)]/10 text-[var(--status-error)]`:e===`idle`||e===`complete`?`bg-[var(--status-success)]/10 text-[var(--status-success)]`:`bg-[var(--surface-muted)] text-muted-foreground`,Qt=e=>e.split(/[/\\]/u).filter(Boolean).at(-1)||e,$t=e=>{let t=(0,Ze.c)(35),{card:n}=e,{t:r}=A(),i=_e(),a;t[0]===i?a=t[1]:(a=i&&!v(),t[0]=i,t[1]=a);let o=!!a,s;t[2]===n.sessionID?s=t[3]:(s=e=>e.activeSessions.find(e=>e.id===n.sessionID)??e.archivedSessions.find(e=>e.id===n.sessionID)??null,t[2]=n.sessionID,t[3]=s);let c=G(s),l=ce(n.sessionID),u=(typeof c?.title==`string`&&c.title.trim()?c.title.trim():null)||n.title||r(`assistants.contact.card.session.untitled`),d=Yt(l?.type,n.status),f=Xt(d),p=d===`busy`||d===`retry`,m=Qt(typeof c?.directory==`string`&&c.directory.trim()?c.directory.trim():n.directory),h=De(c)||n.branch,g=we(c),_=Ae(c),b=je(_),x=[m,g,h].filter(en),S;t[4]!==n.directory||t[5]!==n.sessionID||t[6]!==o?(S=()=>{let e=He(n.sessionID)?.directory||n.directory;le(n.sessionID,e,{phoneShell:o,switchToChat:!0}),o||y.getState().setActiveMainTab(`chat`)},t[4]=n.directory,t[5]=n.sessionID,t[6]=o,t[7]=S):S=t[7];let C=O(S),w;t[8]===C?w=t[9]:(w=e=>{Gt(e,C)},t[8]=C,t[9]=w);let T=O(w),E=Wt,D=r(`assistants.contact.card.session.aria`,{title:u}),k;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(`span`,{className:`flex size-6 items-center justify-center rounded-lg bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(Z,{name:`chat-3`,className:`size-3`})}),t[10]=k):k=t[10];let M;t[11]===p?M=t[12]:(M=p?(0,$.jsx)(`span`,{className:`pointer-events-none absolute right-0 bottom-0 size-2.5 translate-x-0.5 translate-y-0.5 rounded-full bg-[var(--status-success)] ring-2 ring-[var(--surface-elevated)]`,"data-assistant-working-dot":``,"aria-hidden":!0}):null,t[11]=p,t[12]=M);let N;t[13]===M?N=t[14]:(N=(0,$.jsxs)(`span`,{className:`relative inline-block size-6 shrink-0 leading-none`,children:[k,M]}),t[13]=M,t[14]=N);let P;t[15]===u?P=t[16]:(P=(0,$.jsx)(`h3`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground`,children:u}),t[15]=u,t[16]=P);let F=f?(0,$.jsx)(`span`,{className:j(`shrink-0 rounded-full px-1.5 py-0.5 typography-micro leading-none`,Zt(d)),children:r(f)}):null,I;t[17]!==P||t[18]!==F?(I=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[P,F]}),t[17]=P,t[18]=F,t[19]=I):I=t[19];let L;t[20]===x?L=t[21]:(L=x.length>0?(0,$.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:x.join(` · `)}):null,t[20]=x,t[21]=L);let R=b||_?.files!==void 0&&_.files>0?(0,$.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-1.5 typography-micro tabular-nums`,children:[_?.additions===void 0?null:(0,$.jsxs)(`span`,{className:`text-[var(--status-success)]`,children:[`+`,_.additions]}),_?.deletions===void 0?null:(0,$.jsxs)(`span`,{className:`text-[var(--status-error)]`,children:[`−`,_.deletions]}),_?.files===void 0?null:(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:_.files===1?r(`assistants.contact.card.session.changes.filesSingle`,{count:_.files}):r(`assistants.contact.card.session.changes.filesPlural`,{count:_.files})})]}):null,z;t[22]!==I||t[23]!==L||t[24]!==R?(z=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[I,L,R]}),t[22]=I,t[23]=L,t[24]=R,t[25]=z):z=t[25];let B;t[26]!==N||t[27]!==z?(B=(0,$.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[N,z]}),t[26]=N,t[27]=z,t[28]=B):B=t[28];let V;return t[29]!==T||t[30]!==C||t[31]!==B||t[32]!==E||t[33]!==D?(V=(0,$.jsx)(`article`,{className:E,role:`button`,tabIndex:0,"aria-label":D,"data-assistant-contact-card":`session`,onClick:C,onKeyDown:T,children:B}),t[29]=T,t[30]=C,t[31]=B,t[32]=E,t[33]=D,t[34]=V):V=t[34],V};function en(e){return!!(e&&e.trim())}var tn=2,nn=1500,rn=e=>({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight}),an=e=>e.scrollHeight-e.scrollTop-e.clientHeight,on=e=>an(e)<=tn,sn=(e,t)=>{let n=t instanceof Element?t:t instanceof Node?t.parentElement:null;for(;n&&n!==e;){if(n instanceof HTMLElement&&n.scrollHeight>n.clientHeight+1&&n.scrollTop+n.clientHeight<n.scrollHeight-1)return!0;n=n.parentElement}return!1},cn=e=>e.altKey||e.ctrlKey||e.metaKey?!1:e.key===`ArrowDown`||e.key===`PageDown`||e.key===`End`,ln=({active:e,assistantID:t,contentRevision:n,onLoadEarlier:r})=>{let i=Q.useRef(null),[a,o]=Q.useState(null),[s,c]=Q.useState(null),l=Q.useRef(!0),u=Q.useRef(null),d=Q.useRef(null),f=Q.useRef(null),p=Q.useRef(0),m=Q.useRef(null),h=Q.useRef(null),g=Q.useRef(e);g.current=e;let _=Q.useMemo(()=>e=>{i.current=e,o(t=>t===e?t:e)},[]),v=Q.useMemo(()=>e=>{c(t=>t===e?t:e)},[]),y=O(()=>{let e=i.current;if(!e||!g.current||l.current)return;let t=e.getBoundingClientRect().top,n=Array.from(e.querySelectorAll(`[data-message-id]`)).find(e=>e.getBoundingClientRect().bottom>t);u.current=n?{id:n.dataset.messageId,offset:n.getBoundingClientRect().top-t}:null}),b=O(()=>{let e=i.current,t=u.current;if(!e||!t||!g.current||l.current)return;if(Math.abs(e.scrollTop-p.current)>.5){p.current=e.scrollTop,y();return}let n=Array.from(e.querySelectorAll(`[data-message-id]`)).find(e=>e.dataset.messageId===t.id);if(!n){y();return}let r=n.getBoundingClientRect().top-e.getBoundingClientRect().top-t.offset;Math.abs(r)>.5&&(e.scrollTop+=r),p.current=e.scrollTop}),x=O(()=>{l.current=!1,p.current=i.current?.scrollTop??0,y()}),S=O(()=>{if(!g.current||!l.current)return!1;let e=i.current;if(!e)return!1;let t=rn(e),n=Math.min(p.current,Math.max(0,t.scrollHeight-t.clientHeight));return t.scrollTop<n-.5?(l.current=!1,p.current=t.scrollTop,y(),!1):on(t)?(p.current=t.scrollTop,!1):(e.scrollTop=e.scrollHeight,p.current=e.scrollTop,!0)}),C=O(e=>{h.current={direction:e,expiresAt:performance.now()+nn}}),w=O(()=>{let e=h.current;return e?performance.now()>e.expiresAt?(h.current=null,null):e.direction:null}),T=O(()=>{l.current=!1,y()}),D=O(()=>{if(!g.current)return;let e=i.current;if(!e)return;let t=rn(e),n=t.scrollTop>p.current,a=Math.min(p.current,Math.max(0,t.scrollHeight-t.clientHeight));if(p.current=t.scrollTop,l.current){t.scrollTop<a-.5&&T();return}let o=w();y(),t.scrollTop<=80&&o===`up`&&r?.(),n&&on(t)&&(o===`down`||o===`scrollbar`)&&(l.current=!0)}),A=O(e=>{let t=i.current;if(!(!t||e.deltaY===0)){if(e.deltaY<0){if(Oe(t,e.target))return;C(`up`),T(),t.scrollTop<=80&&r?.();return}sn(t,e.target)||C(`down`)}}),j=O(e=>{h.current=null;let t=e.touches.item(0);m.current=t?{x:t.clientX,y:t.clientY,deltaX:0,deltaY:0}:null}),M=O(e=>{let t=i.current,n=e.touches.item(0);if(!t||!n){m.current=null;return}let a=m.current;if(!a)return;let o=n.clientY-a.y,s=o*a.deltaY<0,c=(s?0:a.deltaX)+n.clientX-a.x,l=(s?0:a.deltaY)+o;if(m.current={x:n.clientX,y:n.clientY,deltaX:c,deltaY:l},!(Math.abs(c)>=Math.abs(l))){if(l>0&&Oe(t,e.target)||l<0&&sn(t,e.target)){m.current.deltaX=0,m.current.deltaY=0;return}C(l>0?`up`:`down`),l>2&&(T(),t.scrollTop<=80&&r?.())}}),N=O(()=>{m.current=null}),P=O(e=>{if(be(e)){C(`up`),T(),(i.current?.scrollTop??1/0)<=80&&r?.();return}cn(e)&&C(`down`)}),F=O(e=>{let t=i.current;e.pointerType===`mouse`&&e.target===t&&C(`scrollbar`)});Q.useLayoutEffect(()=>{let n=e?t:null,r=i.current;(d.current!==n||f.current!==r)&&(d.current=n,f.current=r,l.current=!0,u.current=null,h.current=null,m.current=null,p.current=r?.scrollTop??0),e&&(S(),b())},[e,t,n,a]);let I=Q.useMemo(()=>()=>void 0,[]),L=e&&a?a:I,R=Q.useMemo(()=>({passive:!0}),[]);k(`scroll`,D,L,R),k(`wheel`,A,L,R),k(`touchstart`,j,L,R),k(`touchmove`,M,L,R),k(`touchend`,N,L,R),k(`touchcancel`,N,L,R),k(`keydown`,P,L),k(`pointerdown`,F,L,R);let z=O(()=>{S(),b()});return E(typeof ResizeObserver<`u`&&e?s:null,z),{scrollRef:_,contentRef:v,preparePrepend:x}},un=64,dn=e=>{if(!e)return[];let t=Array.from(e.files||[]);return t.length>0?t:Array.from(e.items||[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>e instanceof File)},fn=e=>Array.from(e?.files||[]),pn=async(e,t=p)=>{let n=[],r=0;for(let i of Array.from(e||[])){if(!i||i.size<=0)continue;if(i.size>26214400){r+=1;continue}let e=URL.createObjectURL(i);n.push({id:t(),url:e,name:i.name.trim()||`attachment`,mime:i.type.trim()||`application/octet-stream`,file:i})}return{attachments:n,skippedTooLarge:r}},mn=(e,t)=>{let n=[...e,...t];for(let e of n.slice(un))e.url.startsWith(`blob:`)&&URL.revokeObjectURL(e.url);return n.slice(0,un)},hn=Le(()=>x(()=>import(`./ToolOutputDialog-BBudjfdJ.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52]))),gn=e=>e.trim().startsWith(`oc.settle.`),_n=({assistant:e,warning:t,active:n,overlayHeader:r=!1})=>{let{t:i}=A(),a=ze(),o=y(e=>e.isMobile),s=z(),c=re(),l=I(e.id,n),u=y(e=>e.isSettingsDialogOpen),d=n&&!u&&!l.hasMessageGap?F(e,l.data):null,f=N(e.name),m=f.displayName||e.name,h=(e,t)=>{let n=e?c.data?.assistants.find(t=>t.id===e):void 0;return n?N(n.name).displayName||n.name:t||i(`assistants.contact.peer.unknown`)},[g,_]=Q.useState(``),[v,b]=Q.useState([]),x=Q.useRef(null),S=Q.useRef(new Map),C=Q.useRef(new AbortController);Q.useEffect(()=>{let e=new AbortController;return C.current=e,()=>e.abort()},[e.id,a]);let w=Q.useRef(new Set);Q.useEffect(()=>{let e=new Set(v.map(e=>e.url));for(let t of w.current)e.has(t)||URL.revokeObjectURL(t);w.current=e},[v]),Q.useEffect(()=>()=>{for(let e of w.current)URL.revokeObjectURL(e)},[]);let[T,E]=Q.useState([]),[D,k]=Q.useState([]),[L,B]=Q.useState(null),[H,te]=Q.useState({open:!1,title:``,content:``}),W=y(e=>e.setImagePreviewOpen),ne=O(e=>{(e.image||e.mermaid)&&(te(e),W(!0))}),ie=O(e=>{te(t=>({...t,open:e})),W(e)});Q.useEffect(()=>()=>{W(!1)},[W]);let ae=Q.useRef(!1);Q.useEffect(()=>{S.current.clear(),x.current=null,E([]),k([]),B(null)},[a]);let oe=Q.useMemo(()=>Rt(),[]),ce=Q.useRef(new Set),le=Q.useRef(new Map),G=tt(e=>e.setWorking),K=l.data?.messages??bt,q=Ct(T,e.id),ue=wt(D,e.id),de=Dt(K,q,e.id,ue).filter(e=>{let t=Array.isArray(e.parts)?e.parts:[];return t.length===0||t.some(e=>!(e.type===`text`&&gn(e.text)))}),J=Bt(q),Y=Vt(ue),X=!!(e.working||e.activeContactTurn),fe=c.data?.revision??null,pe=ue.reduce((e,t)=>e+t.bubbles.reduce((e,t)=>e+t.text.length,0),0),me=new Map(ue.map(e=>[e.turnID,e])),he=Q.useRef(!1),ge=O(async(e=!1)=>{if(!(!n||he.current||l.isFetchingPreviousPage||l.isFillingMessageGap)&&!(e&&l.previousPageError)&&!(!l.hasPreviousPage&&!l.hasMessageGap)){he.current=!0,ye();try{l.hasMessageGap?await l.retryMessageGap():await l.fetchPreviousPage()}catch{}finally{he.current=!1}}}),{scrollRef:_e,contentRef:ve,preparePrepend:ye}=ln({active:n,assistantID:e.id,contentRevision:`${de[0]?.messageID}:${de.length}:${pe}:${l.isFetchingPreviousPage}:${l.hasPreviousPage}:${l.isFillingMessageGap}`,onLoadEarlier:()=>{ge(!0)}});Q.useEffect(()=>{B(null),ce.current.clear(),le.current=new Map,E(t=>Ct(t,e.id)),k(t=>wt(t,e.id)),te({open:!1,title:``,content:``}),W(!1)},[e.id,W]),Q.useEffect(()=>{E(e=>Ot(e,K))},[K]),Q.useEffect(()=>{let t=new Set(q.filter(e=>e.status===`sending`).map(e=>e.messageID));k(n=>Mt(n,{assistantID:e.id,activeContactTurn:e.activeContactTurn?{turnID:e.activeContactTurn.turnID,admittedAt:e.activeContactTurn.admittedAt}:null,serverWorking:X,snapshotRevision:fe,admissionRevisionByTurnID:le.current,pendingSendTurnIDs:t,messages:K,settledTurnIDs:ce.current}))},[e.activeContactTurn,e.id,K,q,X,fe]),Q.useEffect(()=>{G(e.id,J||Y||X)},[e.id,Y,J,X,G]),Q.useEffect(()=>{let t=e.id;return()=>{G(t,!1)}},[e.id,G]);let be=O(t=>{if(!(!(`assistantID`in t)||t.assistantID!==e.id)){if(t.type===`contact-turn-start`){ce.current.delete(t.turnID),k(e=>At(e,t.assistantID,t.turnID,t.occurredAt));return}if(t.type===`contact-bubble-delta`){if(ce.current.has(t.turnID))return;k(e=>Nt(e,t));return}t.type===`contact-turn-end`&&(ce.current.add(t.turnID),k(e=>Ft(Pt(e,t,{requireExisting:!0}),K)))}});Q.useEffect(()=>{if(n)return se(be)},[n,e.id]);let xe=O(async e=>{if(J)return;let t=C.current,n=await pn(e);if(t.signal.aborted){n.attachments.forEach(e=>URL.revokeObjectURL(e.url));return}n.skippedTooLarge>0&&B(i(`assistants.contact.attachment.tooLarge`)),n.attachments.length!==0&&b(e=>mn(e,n.attachments))}),Se=O(e=>{let t=dn(e.clipboardData);t.length!==0&&(e.preventDefault(),xe(t))}),Ce=O(e=>{Array.from(e.dataTransfer?.types??[]).includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)}),we=O(e=>{let t=fn(e.dataTransfer);t.length!==0&&(e.preventDefault(),xe(t))}),Te=O(async()=>{let t=C.current,n=g,r=v,a=e.id,o=x.current,c=o?.assistantID===a&&o.text===n&&o.attachments===r?o.messageID:null,l=zt({gate:oe,sending:Bt(q),text:n,attachments:r,assistantID:a,createMessageID:()=>c||`oc_contact_${p()}`});if(!l.ok)return;x.current={assistantID:a,text:n,attachments:r,messageID:l.messageID},E(e=>[...e.filter(e=>e.messageID!==l.messageID),l.turn]),B(null);let u=()=>{_(e=>e===n?``:e),b(e=>e.filter(e=>!r.includes(e))),r.forEach(e=>S.current.delete(`${a}:${e.id}`)),x.current=null};try{let e=[];for(let n of r){let r=`${a}:${n.id}`,i=S.current.get(r);if(!i){if(i=await Je(a,n.file,n.id,t.signal),t.signal.aborted)return;S.current.set(r,i)}e.push(i)}if(t.signal.aborted)return;let n=[...l.parts.filter(e=>e.type===`text`),...e];E(e=>e.map(e=>e.messageID===l.messageID?{...e,parts:n}:e));let i=await R(a,l.messageID,{parts:n});if(t.signal.aborted)return;u(),typeof i.revision==`number`&&le.current.set(l.messageID,i.revision),E(e=>kt(e,l.messageID)),ce.current.has(l.messageID)||k(e=>At(e,a,l.messageID)),s.data?.serverInstanceID&&P({serverInstanceID:s.data.serverInstanceID,assistantID:a,name:m,avatarSeed:a,...f.avatarEmoji?{avatarEmoji:f.avatarEmoji}:{}}).catch(()=>void 0)}catch(e){if(t.signal.aborted)return;if(e instanceof V&&e.code===`admission_timeout`)try{let e=await ee(a,l.messageID);if(t.signal.aborted)return;if(e){u(),typeof e.revision==`number`&&le.current.set(l.messageID,e.revision),E(e=>kt(e,l.messageID)),ce.current.has(l.messageID)||k(e=>At(e,a,l.messageID));return}}catch{}let n=Lt(e,{noProvider:i(`assistants.contact.noProvider`),sendFailed:i(`assistants.contact.sendFailed`),timedOut:i(`assistants.contact.timedOut`)});E(e=>It(e,l.messageID,n)),B(n)}finally{oe.release()}}),Ee=O(async()=>{if(ae.current)return;ae.current=!0;let t=C.current;B(null);try{await U(e.id,e)}catch(e){t.signal.aborted||B(e instanceof Error?e.message:i(`settings.mcp.page.toast.unexpectedError`))}finally{ae.current=!1}}),De=l.isError&&de.length===0,Oe=l.isSuccess&&de.length===0,ke=new Map(q.map(e=>[e.messageID,e]));return(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-background`,children:[(0,$.jsxs)(`div`,{ref:_e,className:j(`min-h-0 flex-1 overflow-x-hidden overflow-y-auto px-4 pb-9 sm:px-8 sm:pb-12`,r?`pt-[calc(max(0.625rem,var(--oc-safe-area-top,0px))+var(--oc-mobile-detail-navigation-height)+1.25rem)]`:`pt-5 sm:pt-7`),style:{overflowAnchor:`none`,overscrollBehavior:`contain`,overscrollBehaviorY:`contain`},"data-assistant-contact-transcript":``,children:[t?(0,$.jsx)(`p`,{className:`mb-3 typography-micro text-[var(--status-warning)]`,children:t}):null,De?(0,$.jsxs)(`div`,{ref:ve,className:`mx-auto flex h-full min-h-56 max-w-xs flex-col items-center justify-center pb-16 text-center`,"data-assistant-contact-error":``,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(et,{name:e.id,emoji:f.avatarEmoji,size:44,label:m}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`absolute -right-1 -bottom-1 flex size-5 items-center justify-center rounded-full bg-[var(--surface-elevated)] text-[var(--status-error)] ring-2 ring-background`,children:(0,$.jsx)(Z,{name:`error-warning`,className:`size-3`})})]}),(0,$.jsx)(`p`,{className:`mt-4 typography-ui-label font-medium text-foreground`,children:m}),(0,$.jsx)(`p`,{className:`mt-1.5 typography-ui leading-6 text-muted-foreground`,children:i(`assistants.contact.loadFailed`)}),(0,$.jsx)(M,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>void l.refetch(),children:i(`chat.history.retry`)})]}):Oe?(0,$.jsxs)(`div`,{ref:ve,className:`mx-auto flex h-full min-h-56 max-w-sm flex-col items-center justify-center pb-16 text-center`,"data-assistant-contact-empty":``,children:[(0,$.jsx)(et,{name:e.id,emoji:f.avatarEmoji,size:48,label:m,className:`opacity-90`}),(0,$.jsx)(`p`,{className:`mt-5 typography-ui-header font-medium tracking-[-0.01em] text-foreground`,children:i(`assistants.conversation.emptyTitle`,{name:m})}),(0,$.jsx)(`p`,{className:`mt-2 max-w-xs typography-ui leading-6 text-muted-foreground/80`,children:i(`assistants.contact.empty`)})]}):(0,$.jsxs)(`div`,{ref:ve,className:`mx-auto flex w-full max-w-[42rem] flex-col`,children:[l.isPending?(0,$.jsx)(`p`,{role:`status`,className:`py-3 text-center typography-micro text-muted-foreground`,children:i(`common.loading`)}):null,l.hasPreviousPage||l.hasMessageGap?(0,$.jsxs)(`div`,{className:`mb-3 flex flex-col items-center gap-1`,"data-assistant-contact-pagination":``,"aria-busy":l.isFetchingPreviousPage||l.isFillingMessageGap,children:[l.previousPageError?(0,$.jsx)(`p`,{role:`alert`,className:`typography-micro text-[var(--status-error)]`,children:i(`chat.history.loadOlderFailed`)}):null,l.hasMessageGap?(0,$.jsx)(`p`,{role:`status`,className:`typography-micro text-muted-foreground`,children:i(`assistants.contact.history.gap`)}):null,(0,$.jsx)(M,{type:`button`,size:`sm`,variant:`ghost`,disabled:l.isFetchingPreviousPage||l.isFillingMessageGap,onClick:()=>void ge(),children:i(l.isFetchingPreviousPage||l.isFillingMessageGap?`chat.history.loadingMore`:l.previousPageError||l.hasMessageGap?`chat.history.retry`:`chat.history.loadOlder`)})]}):null,de.map((t,n)=>{let r=n>0?de[n-1]:null,o=t.role===`user`,s=t.role===`peer`,l=t.role===`assistant`&&r?.role===`assistant`&&r.turnID===t.turnID,u=r?.turnID!==t.turnID,f=!o&&(s||!l),p=s?h(t.fromAssistantID,t.fromAssistantName):m,g=s&&t.fromAssistantID?c.data?.assistants.find(e=>e.id===t.fromAssistantID):e,_=g?N(g.name):null,v=ke.get(t.messageID),y=me.get(t.turnID),b=t.status===`admitted`&&t.messageID.endsWith(`:preview:admitted`),x=t.status===`failed`&&t.messageID.endsWith(`:preview:failed`);return t.status===`error`||x?(0,$.jsxs)(`div`,{"data-message-id":t.messageID,"data-assistant-contact-error":``,className:`mt-3 px-1`,children:[(0,$.jsx)(`p`,{role:`alert`,className:`whitespace-pre-wrap typography-micro text-[var(--status-error)] [overflow-wrap:anywhere]`,children:t.text||y?.error||i(`assistants.contact.sendFailed`)}),d?.messageID===t.messageID?(0,$.jsx)(it,{assistantID:e.id,position:d},`${a}:${e.id}:${d.generation}:${d.ordinal}`):null]},t.messageID):(0,$.jsxs)(`div`,{"data-message-id":t.messageID,className:j(`flex w-full`,o?`justify-end`:`justify-start`,u?`mt-6 first:mt-0`:l?`mt-1.5`:`mt-3`),"data-assistant-contact-role":t.role,"data-assistant-contact-turn-status":v?.status??t.status,"data-assistant-contact-run-start":t.role===`assistant`&&!l?``:void 0,children:[o?null:(0,$.jsx)(`div`,{className:`mr-2.5 flex w-8 shrink-0 justify-center pt-0.5`,children:f?(0,$.jsx)(et,{name:g?.id||t.fromAssistantID||e.id,emoji:_?.avatarEmoji,size:28,label:p}):(0,$.jsx)(`span`,{className:`size-7`,"aria-hidden":!0})}),(0,$.jsxs)(`div`,{className:j(`flex min-w-0 flex-col gap-1.5`,o?`max-w-[min(82%,30rem)] items-end`:`max-w-[min(84%,34rem)] items-start`),children:[s?(0,$.jsx)(`span`,{className:`mb-0.5 px-1 typography-micro text-muted-foreground/75`,children:i(`assistants.contact.peer.from`,{name:p})}):null,b?(0,$.jsxs)(`div`,{role:`status`,"aria-label":i(`assistants.contact.processing`),className:`inline-flex w-fit items-center gap-1 rounded-full bg-[var(--surface-muted)] px-3.5 py-2.5 text-muted-foreground/70`,"data-assistant-contact-processing":``,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 animate-pulse rounded-full bg-current [animation-delay:-0.45s] [animation-duration:1.4s] motion-reduce:animate-none`}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 animate-pulse rounded-full bg-current [animation-delay:-0.22s] [animation-duration:1.4s] motion-reduce:animate-none`}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 animate-pulse rounded-full bg-current [animation-duration:1.4s] motion-reduce:animate-none`})]}):null,t.parts.map((n,r)=>{if(n.type===`card`&&n.cardType===`session`)return(0,$.jsx)($t,{card:n},`${t.messageID}:card:${r}`);if(n.type===`card`&&n.cardType===`assistant`)return(0,$.jsx)(Kt,{card:n},`${t.messageID}:card:${r}`);if(n.type===`card`&&n.cardType===`schedule`)return(0,$.jsx)(qt,{card:n},`${t.messageID}:card:${r}`);if(n.type===`file`)return(0,$.jsx)(yt,{assistantID:e.id,part:n,onShowPopup:ne},`${t.messageID}:file:${r}`);if(n.type===`text`&&gn(n.text))return null;if(n.type===`text`&&(n.text.trim()||t.status===`streaming`)){let e=!o;return(0,$.jsxs)(`div`,{"aria-label":s?i(`assistants.contact.peer.aria`,{name:p}):void 0,"data-assistant-contact-text":``,className:j(`min-w-0 max-w-full [overflow-wrap:anywhere] rounded-[1.35rem] px-4 py-2.5 typography-markdown leading-6`,e?null:`whitespace-pre-wrap`,o?`rounded-[1.15rem] rounded-br-lg bg-[var(--primary-base)]/90 text-[var(--primary-foreground)]`:s?`rounded-[1.25rem] border border-dashed border-border/50 bg-[var(--surface-muted)]/70 text-foreground`:j(`bg-[var(--surface-muted)] text-foreground`,l&&`rounded-tl-lg`)),children:[e?(0,$.jsx)(Re,{content:n.text,messageId:t.messageID,isAnimated:!1,isStreaming:t.status===`streaming`,variant:`assistant`,enableFileReferences:!1,onShowPopup:ne,className:`w-full min-w-0 [overflow-wrap:anywhere]`}):n.text,t.status===`streaming`&&r===t.parts.length-1?(0,$.jsx)(`span`,{"aria-hidden":!0,className:`ml-0.5 inline-block h-[1em] w-px translate-y-[0.12em] animate-pulse bg-current opacity-45 [animation-duration:1.1s] motion-reduce:animate-none`,"data-assistant-contact-streaming-caret":``}):null]},`${t.messageID}:text:${r}`)}return null}),v?.status===`sending`?(0,$.jsx)(`p`,{className:`px-1 typography-micro text-muted-foreground/75`,children:i(`assistants.contact.sending`)}):null,v?.status===`failed`?(0,$.jsx)(`p`,{className:`px-1 typography-micro text-[var(--status-error)]`,children:v.error||i(`assistants.contact.sendFailed`)}):null,d?.messageID===t.messageID?(0,$.jsx)(it,{assistantID:e.id,position:d},`${a}:${e.id}:${d.generation}:${d.ordinal}`):null]})]},t.messageID)})]})]}),(0,$.jsxs)(`footer`,{className:`relative z-10 shrink-0 bg-background pt-1`,"data-assistant-contact-composer":``,children:[L?(0,$.jsxs)(`div`,{className:`chat-input-column mb-2 flex items-center gap-2`,children:[(0,$.jsx)(`p`,{role:`alert`,className:`typography-micro text-[var(--status-error)]`,children:L}),x.current?(0,$.jsx)(M,{type:`button`,size:`sm`,variant:`ghost`,disabled:J,onClick:()=>void Te(),children:i(`chat.history.retry`)}):null]}):null,(0,$.jsx)(`form`,{className:j(`relative w-full pt-1.5 pb-4`,o&&`bottom-safe-area oc-mobile-composer`),onSubmit:e=>{e.preventDefault(),Te()},onDragOver:Ce,onDrop:we,children:(0,$.jsx)(`div`,{className:`chat-input-column relative overflow-visible`,children:(0,$.jsx)(pt,{active:n,layout:`inline`,value:g,attachments:v,pending:J,working:Y||X,onStop:Y||X?()=>{Ee()}:void 0,stopLabel:i(`chat.chatInput.actions.stopGeneratingAria`),isMobile:o,placeholder:i(`assistants.contact.placeholder`,{name:m}),sendLabel:i(`assistants.contact.send`),addFilesLabel:i(`assistants.contact.addFiles`),removeAttachmentLabel:i(`assistants.contact.removeAttachment`),fileAccept:`*/*`,onChange:e=>_(e),onSubmit:()=>{Te()},onAddFiles:e=>{xe(e)},onRemoveAttachment:t=>{J||(S.current.delete(`${e.id}:${t}`),x.current=null,b(e=>e.filter(e=>e.id!==t)))},onPaste:Se,onDragOver:Ce,onDrop:we,className:j(`relative z-10`,o&&`oc-mobile-composer-surface`),style:{borderRadius:`1.5rem`},"data-assistant-contact-composer-surface":``,textareaProps:{"aria-label":i(`assistants.contact.placeholder`,{name:m})}},`${a}:${e.id}`)})})]}),H.open?(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(hn,{popup:H,onOpenChange:ie,isMobile:o})}):null]})};async function vn(e){await L(e);let t=K.getState().defaultShareAssistant;if(t?.assistantID!==e.id)return;let n=await te();n.serverInstanceID&&t.serverInstanceID===n.serverInstanceID&&K.getState().setDefaultShareAssistant(null)}function yn({assistant:e,open:t,onOpenChange:n,onDeleted:r}){let{t:i}=A(),[a,o]=Q.useState(!1),s=e?N(e.name).displayName||e.name:``,c=O(e=>{a&&!e||n(e)}),l=O(()=>{a||n(!1)}),u=O(async()=>{if(!(!e||a)){o(!0);try{await vn(e),r?.(e.id),n(!1),C.success(i(`assistants.settings.toast.deleted`))}catch{C.error(i(`assistants.settings.toast.deleteFailed`))}finally{o(!1)}}});return(0,$.jsx)(pe,{open:t&&e!==null,onOpenChange:c,children:(0,$.jsxs)(Y,{className:`max-w-md`,children:[(0,$.jsxs)(de,{children:[(0,$.jsx)(X,{children:i(`assistants.settings.delete`)}),(0,$.jsx)(fe,{children:i(`assistants.settings.deleteConfirm`,{name:s})})]}),(0,$.jsxs)(J,{children:[(0,$.jsx)(M,{size:`sm`,variant:`ghost`,onClick:l,disabled:a,children:i(`settings.common.actions.cancel`)}),(0,$.jsx)(M,{size:`sm`,variant:`destructive`,onClick:u,disabled:a,children:i(`settings.common.actions.delete`)})]})]})})}var bn=`line-clamp-2 min-w-0 max-w-full overflow-clip whitespace-normal [overflow-wrap:anywhere] typography-micro text-muted-foreground`,xn={image:`assistants.contact.attachment.image`,file:`assistants.contact.attachment.file`,session:`assistants.contact.card.session.untitled`,assistant:`assistants.title`,schedule:`assistants.settings.scheduledTasks.title`};function Sn(e,t){return e?.text.replace(/\s+/gu,` `).trim()||t(e?.fallbackKind?xn[e.fallbackKind]:`assistants.contact.empty`)}var Cn=e=>e.capabilityPending?`loading`:e.capabilityError||e.supported!==!0||e.capabilityEnabled!==!0?`unavailable`:e.snapshotPending?`loading`:e.snapshotEnabled===!0?e.assistantCount===0?`onboarding`:e.hasAssistant?`ready`:e.snapshotSettled?`unavailable`:`loading`:`unavailable`,wn=t({AssistantView:()=>Dn}),Tn=e=>{let t=(0,Ze.c)(22),{assistant:n,onBack:r,onOpenSettings:i}=e,{t:a}=A(),o=_e(),s;t[0]===n?s=t[1]:(s=n?N(n.name):null,t[0]=n,t[1]=s);let c=s,l=n&&c?c.displayName||n.name:``,u;t[2]!==n||t[3]!==o||t[4]!==i?(u=()=>{if(n){if(i){i(n.id);return}ue(n.id,o?{openMobileSettings:o.openSettings}:void 0)}},t[2]=n,t[3]=o,t[4]=i,t[5]=u):u=t[5];let d=O(u),f;t[6]!==n||t[7]!==l||t[8]!==c?.avatarEmoji||t[9]!==a?(f=n?(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2.5`,children:[(0,$.jsx)(et,{name:n.id,emoji:c?.avatarEmoji,size:28,label:l}),(0,$.jsx)(`span`,{className:`truncate font-medium tracking-[-0.01em]`,children:l||a(`assistants.title`)})]}):l||a(`assistants.title`),t[6]=n,t[7]=l,t[8]=c?.avatarEmoji,t[9]=a,t[10]=f):f=t[10];let p;t[11]===a?p=t[12]:(p=a(`assistants.actions.backToChat`),t[11]=a,t[12]=p);let m;t[13]!==n||t[14]!==d||t[15]!==a?(m=n?[{icon:`settings-3`,ariaLabel:a(`assistants.conversation.openSettings`),onClick:d}]:[],t[13]=n,t[14]=d,t[15]=a,t[16]=m):m=t[16];let h;return t[17]!==r||t[18]!==f||t[19]!==p||t[20]!==m?(h=(0,$.jsx)(W,{title:f,backAriaLabel:p,onBack:r,actions:m,overlay:!0}),t[17]=r,t[18]=f,t[19]=p,t[20]=m,t[21]=h):h=t[21],h},En=e=>{let t=(0,Ze.c)(50),{unreadCount:n,summary:r,assistantID:i,displayName:a,avatarEmoji:o,selected:s,enabled:c,editLabel:l,deleteLabel:u,onSelect:d,onEdit:f,onDelete:p,serverWorking:m}=e,h=rt(i,m!==void 0&&m),[g,_]=Q.useState(!1),v;t[0]===d?v=t[1]:(v=()=>d(),t[0]=d,t[1]=v);let y=O(v),b;t[2]===f?b=t[3]:(b=()=>{_(!1),f()},t[2]=f,t[3]=b);let x=O(b),S;t[4]===p?S=t[5]:(S=()=>{_(!1),p()},t[4]=p,t[5]=S);let C=O(S),w;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(w=e=>{e.preventDefault(),_(!0)},t[6]=w):w=t[6];let T=s?`border-border/50 bg-[var(--surface-elevated)]`:`border-transparent hover:bg-interactive-hover`,E=!c&&`opacity-65`,D;t[7]!==T||t[8]!==E?(D=j(`flex w-full min-h-11 items-center gap-3 rounded-xl border px-3 py-3 text-left outline-none transition-[background-color,border-color,opacity] duration-150 ease-out active:bg-interactive-active focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] motion-reduce:transition-none`,T,E),t[7]=T,t[8]=E,t[9]=D):D=t[9];let k;t[10]!==y||t[11]!==s||t[12]!==D?(k=(0,$.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":s,onClick:y,onContextMenu:w,className:D}),t[10]=y,t[11]=s,t[12]=D,t[13]=k):k=t[13];let A;t[14]!==i||t[15]!==o||t[16]!==a||t[17]!==h?(A=(0,$.jsx)(et,{name:i,emoji:o,size:24,label:a,working:h}),t[14]=i,t[15]=o,t[16]=a,t[17]=h,t[18]=A):A=t[18];let M;t[19]===a?M=t[20]:(M=(0,$.jsx)(`span`,{className:`block truncate typography-ui-label font-medium`,children:a}),t[19]=a,t[20]=M);let N;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(N=j(bn,`mt-1.5`),t[21]=N):N=t[21];let P;t[22]===r?P=t[23]:(P=(0,$.jsx)(`span`,{className:N,children:r}),t[22]=r,t[23]=P);let F;t[24]!==M||t[25]!==P?(F=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[M,P]}),t[24]=M,t[25]=P,t[26]=F):F=t[26];let I;t[27]===n?I=t[28]:(I=(0,$.jsx)(Ve,{count:n}),t[27]=n,t[28]=I);let L;t[29]!==A||t[30]!==F||t[31]!==I||t[32]!==k?(L=(0,$.jsxs)(Ue,{render:k,children:[A,F,I]}),t[29]=A,t[30]=F,t[31]=I,t[32]=k,t[33]=L):L=t[33];let R;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(Z,{name:`edit`,className:`size-4`}),t[34]=R):R=t[34];let z;t[35]!==l||t[36]!==x?(z=(0,$.jsxs)(Ke,{onClick:x,children:[R,l]}),t[35]=l,t[36]=x,t[37]=z):z=t[37];let B;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(We,{}),t[38]=B):B=t[38];let V;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(Z,{name:`delete-bin`,className:`size-4`}),t[39]=V):V=t[39];let H;t[40]!==u||t[41]!==C?(H=(0,$.jsxs)(Ke,{onClick:C,className:`text-[var(--status-error)] focus:text-[var(--status-error)] data-[highlighted]:text-[var(--status-error)] [&_svg]:text-[var(--status-error)]`,children:[V,u]}),t[40]=u,t[41]=C,t[42]=H):H=t[42];let U;t[43]!==z||t[44]!==H?(U=(0,$.jsxs)(Ge,{className:`min-w-[10rem]`,children:[z,B,H]}),t[43]=z,t[44]=H,t[45]=U):U=t[45];let ee;return t[46]!==g||t[47]!==L||t[48]!==U?(ee=(0,$.jsxs)(qe,{open:g,onOpenChange:_,children:[L,U]}),t[46]=g,t[47]=L,t[48]=U,t[49]=ee):ee=t[49],ee},Dn=e=>{let t=(0,Ze.c)(118),{activeOverride:i,onMobileBack:a,onMobileOpenSettings:o}=e,{t:s}=A(),{isMobile:c}=he(),l=_e(),u=Q.useSyncExternalStore(n,r,r),d=y(On),f=i??d,p=y(kn),m=c||p,h=z(),g=re(),_=g.data;_?.assistants;let v;t[0]===_?.assistants?v=t[1]:(v=_?.assistants??[],t[0]=_?.assistants,t[1]=v);let b;t[2]===v?b=t[3]:(b=Qe(v),t[2]=v,t[3]=b);let x=b,S;t[4]===u?S=t[5]:(S=e=>e.assistantByTransport[u]??null,t[4]=u,t[5]=S);let C=K(S),w=K(An),T=K(jn),E;t[6]!==C||t[7]!==_?.assistants?(E=_?.assistants.find(e=>e.id===C)??null,t[6]=C,t[7]=_?.assistants,t[8]=E):E=t[8];let D=E,k;t[9]!==w||t[10]!==C||t[11]!==_?(k=()=>{!C&&_?.assistants[0]&&w(_.assistants[0].id)},t[9]=w,t[10]=C,t[11]=_,t[12]=k):k=t[12];let P=_?.assistants,F;t[13]!==w||t[14]!==C||t[15]!==P?(F=[w,C,P],t[13]=w,t[14]=C,t[15]=P,t[16]=F):F=t[16],Q.useEffect(k,F);let I;t[17]!==D||t[18]!==w||t[19]!==C||t[20]!==_?.assistants||t[21]!==g.isSuccess?(I=()=>{g.isSuccess&&C&&!D&&w(_?.assistants[0]?.id??null)},t[17]=D,t[18]=w,t[19]=C,t[20]=_?.assistants,t[21]=g.isSuccess,t[22]=I):I=t[22];let L=_?.assistants,R;t[23]!==D||t[24]!==w||t[25]!==C||t[26]!==g.isSuccess||t[27]!==L?(R=[D,w,C,L,g.isSuccess],t[23]=D,t[24]=w,t[25]=C,t[26]=g.isSuccess,t[27]=L,t[28]=R):R=t[28],Q.useEffect(I,R);let B;t[29]!==l||t[30]!==T?(B=()=>{if(T(),l){l.openSettings();return}let e=y.getState();e.setSettingsPage(`assistants`),e.setSettingsDialogOpen(!0)},t[29]=l,t[30]=T,t[31]=B):B=t[31];let V=O(B),H;t[32]===l?H=t[33]:(H=e=>{ue(e,l?{openMobileSettings:l.openSettings}:void 0)},t[32]=l,t[33]=H);let U=O(H),ee;t[34]!==D||t[35]!==l?(ee=()=>{D&&ue(D.id,l?{openMobileSettings:l.openSettings}:void 0)},t[34]=D,t[35]=l,t[36]=ee):ee=t[36];let te=O(ee),[W,ne]=Q.useState(null),ie;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(ie=e=>{ne(e)},t[37]=ie):ie=t[37];let ae=O(ie),oe;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(oe=e=>{e||ne(null)},t[38]=oe):oe=t[38];let se=O(oe),ce=O(Mn),le;t[39]!==a||t[40]!==ce?(le=()=>{if(a){a();return}ce()},t[39]=a,t[40]=ce,t[41]=le):le=t[41];let G=O(le),q=Cn({capabilityPending:h.isPending,snapshotPending:g.isPending,capabilityError:h.isError,supported:h.data?.supported,capabilityEnabled:h.data?.enabled,snapshotEnabled:_?.enabled,snapshotSettled:g.isSuccess,assistantCount:_?.assistants.length??0,hasAssistant:!!D}),de;t[42]!==D||t[43]!==G||t[44]!==m||t[45]!==o?(de=(e,t,n,r)=>(0,$.jsxs)(`div`,{className:`relative flex h-full min-h-0 flex-col`,children:[m?(0,$.jsx)(Tn,{assistant:D,onBack:G,onOpenSettings:o}):null,(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center px-6 pt-[calc(max(0.25rem,var(--oc-safe-area-top,0px))+var(--oc-mobile-detail-navigation-height,3.5rem))] text-center`,children:[(0,$.jsx)(Z,{name:e,className:`size-6 text-muted-foreground`}),(0,$.jsx)(`h1`,{className:`mt-4 typography-ui-header font-semibold`,children:t}),n?(0,$.jsx)(`p`,{className:`mt-2 max-w-md typography-ui text-muted-foreground`,children:n}):null,r?(0,$.jsx)(`div`,{className:`mt-5`,children:r}):null]})]}),t[42]=D,t[43]=G,t[44]=m,t[45]=o,t[46]=de):de=t[46];let J=de;if(q===`loading`){let e;t[47]!==D||t[48]!==G||t[49]!==m||t[50]!==o?(e=m?(0,$.jsx)(Tn,{assistant:D,onBack:G,onOpenSettings:o}):null,t[47]=D,t[48]=G,t[49]=m,t[50]=o,t[51]=e):e=t[51];let n;t[52]===s?n=t[53]:(n=s(`common.loading`),t[52]=s,t[53]=n);let r;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(Z,{name:`loader-4`,className:`size-6 animate-spin text-muted-foreground`}),t[54]=r):r=t[54];let i;t[55]===n?i=t[56]:(i=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center px-6 pt-[calc(max(0.25rem,var(--oc-safe-area-top,0px))+var(--oc-mobile-detail-navigation-height,3.5rem))] text-center`,"aria-busy":`true`,"aria-label":n,"data-assistant-workspace-loading":``,children:r}),t[55]=n,t[56]=i);let a;return t[57]!==e||t[58]!==i?(a=(0,$.jsxs)(`div`,{className:`relative flex h-full min-h-0 flex-col`,children:[e,i]}),t[57]=e,t[58]=i,t[59]=a):a=t[59],a}if(q===`unavailable`){let e;return t[60]!==J||t[61]!==s?(e=J(`cloud-off`,s(`assistants.state.unavailable`)),t[60]=J,t[61]=s,t[62]=e):e=t[62],e}if(q===`onboarding`){let e;if(t[63]!==V||t[64]!==J||t[65]!==s){let n=s(`assistants.onboarding.title`),r=s(`assistants.onboarding.description`),i;t[67]===s?i=t[68]:(i=s(`assistants.onboarding.action`),t[67]=s,t[68]=i);let a;t[69]!==V||t[70]!==i?(a=(0,$.jsx)(M,{onClick:V,children:i}),t[69]=V,t[70]=i,t[71]=a):a=t[71],e=J(`ai-agent`,n,r,a),t[63]=V,t[64]=J,t[65]=s,t[66]=e}else e=t[66];return e}if(!_||!D){let e;return t[72]!==J||t[73]!==s?(e=J(`cloud-off`,s(`assistants.state.unavailable`)),t[72]=J,t[73]=s,t[74]=e):e=t[74],e}let Y;t[75]===D.name?Y=t[76]:(Y=N(D.name),t[75]=D.name,t[76]=Y);let X=Y,fe;t[77]!==D.enabled||t[78]!==g.isError||t[79]!==s?(fe=D.enabled?g.isError?s(`assistants.state.staleSnapshot`):null:s(`assistants.state.assistantDisabled`),t[77]=D.enabled,t[78]=g.isError,t[79]=s,t[80]=fe):fe=t[80];let pe=fe,me;t[81]!==x||t[82]!==m||t[83]!==V||t[84]!==U||t[85]!==ae||t[86]!==w||t[87]!==C||t[88]!==_||t[89]!==s?(me=m?null:(0,$.jsxs)(`section`,{className:`flex h-full min-h-0 w-[clamp(16rem,22vw,20rem)] shrink-0 flex-col overflow-hidden`,children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center gap-3 px-4 pb-3 pt-4 sm:px-5`,children:[(0,$.jsx)(`h1`,{className:`min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground`,children:s(`assistants.title`)}),(0,$.jsx)(M,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":s(`assistants.settings.create`),onClick:V,children:(0,$.jsx)(Z,{name:`add`,className:`size-4`})})]}),(0,$.jsx)($e,{snapshot:_,rowClassName:`flex justify-end px-4 pb-2 sm:px-5`}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 pb-4 sm:px-4`,role:`listbox`,"aria-label":s(`assistants.listAria`),children:(0,$.jsx)(`div`,{className:`flex flex-col gap-1 border-t border-border/40 pt-3`,children:x.map(e=>{let t=e.id===C,n=N(e.name);return(0,$.jsx)(En,{assistantID:e.id,unreadCount:e.unreadCount??0,summary:Sn(e.latestMessagePreview,s),displayName:n.displayName,avatarEmoji:n.avatarEmoji??void 0,selected:t,enabled:e.enabled,editLabel:s(`assistants.menu.edit`),deleteLabel:s(`assistants.settings.delete`),assignedSessionIDs:e.assignedSessionIDs,serverWorking:e.working,onSelect:()=>w(e.id),onEdit:()=>U(e.id),onDelete:()=>ae(e)},e.id)})})})]}),t[81]=x,t[82]=m,t[83]=V,t[84]=U,t[85]=ae,t[86]=w,t[87]=C,t[88]=_,t[89]=s,t[90]=me):me=t[90];let ge=W!==null,ve;t[91]!==W||t[92]!==se||t[93]!==ge?(ve=(0,$.jsx)(yn,{assistant:W,open:ge,onOpenChange:se}),t[91]=W,t[92]=se,t[93]=ge,t[94]=ve):ve=t[94];let ye=!m&&`border-l border-[var(--surface-subtle)]`,be;t[95]===ye?be=t[96]:(be=j(`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-background`,ye),t[95]=ye,t[96]=be);let xe;t[97]!==D||t[98]!==G||t[99]!==m||t[100]!==o||t[101]!==te||t[102]!==X||t[103]!==s?(xe=m?(0,$.jsx)(Tn,{assistant:D,onBack:G,onOpenSettings:o}):(0,$.jsxs)(`header`,{className:`flex h-16 shrink-0 items-center gap-3.5 border-b border-[var(--surface-subtle)]/70 px-5 sm:px-7`,children:[(0,$.jsx)(et,{name:D.id,emoji:X.avatarEmoji,size:30,label:X.displayName||D.name}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate typography-ui-label font-semibold tracking-[-0.01em] text-foreground`,children:X.displayName}),(0,$.jsx)(`div`,{className:`mt-1 truncate typography-micro leading-none text-muted-foreground/55`,children:s(`assistants.conversation.contactHint`)})]}),(0,$.jsx)(M,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8 shrink-0 rounded-full text-muted-foreground/65 transition-colors hover:text-foreground`,onClick:te,"aria-label":s(`assistants.conversation.openSettings`),children:(0,$.jsx)(Z,{name:`settings-3`,className:`size-4`})})]}),t[97]=D,t[98]=G,t[99]=m,t[100]=o,t[101]=te,t[102]=X,t[103]=s,t[104]=xe):xe=t[104];let Se;t[105]!==f||t[106]!==D||t[107]!==m||t[108]!==pe?(Se=(0,$.jsx)(_n,{assistant:D,warning:pe,active:f,overlayHeader:m}),t[105]=f,t[106]=D,t[107]=m,t[108]=pe,t[109]=Se):Se=t[109];let Ce;t[110]!==be||t[111]!==xe||t[112]!==Se?(Ce=(0,$.jsxs)(`div`,{className:be,children:[xe,Se]}),t[110]=be,t[111]=xe,t[112]=Se,t[113]=Ce):Ce=t[113];let we;return t[114]!==me||t[115]!==ve||t[116]!==Ce?(we=(0,$.jsxs)(`div`,{className:`relative flex h-full min-h-0 overflow-hidden bg-background`,"data-presentation":`workspace`,children:[me,ve,Ce]}),t[114]=me,t[115]=ve,t[116]=Ce,t[117]=we):we=t[117],we};function On(e){return e.activeMainTab===`assistant`}function kn(e){return e.isMobile}function An(e){return e.selectAssistant}function jn(e){return e.requestCreate}function Mn(){y.getState().setActiveMainTab(`chat`)}export{yn as a,$e as c,Sn as i,Qe as l,wn as n,rt as o,bn as r,et as s,Dn as t};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{c as t,i as n}from"./runtime-switch-BJM2k_uH.js";import{A as r,En as i,O as a,d as o,f as s,in as c}from"./persistence-CMWO3jFo.js";import{a as l,i as u,r as d}from"./vendor-zustand-B4dlGEM2.js";import{nt as f,rt as p}from"./vendor-base-ui-CnHfUmDN.js";import{B as m,Ct as h,M as g,Mt as _}from"./platform-BxU3ZvQ0.js";import{b as v,n as ee,x as y}from"./useUIStore-Brsa2mKs.js";import{n as b}from"./vendor-react-DLPElpoQ.js";import{s as x}from"./vendor-tanstack-react-query-D7pys_c9.js";import{n as S}from"./vendor-reactuses-core-Dq5ocTF8.js";import{f as te,r as C,u as ne}from"./button-EzCcYrQl.js";import{Bt as re,Mn as ie,Pa as ae,S as w,Xa as T,Ya as oe,aa as se,an as ce,d as E,dt as le,fr as D,ft as ue,gt as O,hn as k,mt as A,pt as j,y as M,yr as de}from"./useMobileNavigationStore-DrdLEZXl.js";import{n as N}from"./Icon-DKd015RD.js";import{g as P,v as F}from"./gitApi-BiPCMFjN.js";import{f as fe,k as pe,o as me}from"./projectMeta-CdRGrq5D.js";import{n as he}from"./textarea-B9pCxe-7.js";import{n as ge,r as _e,t as ve}from"./fileMentionTouchSelection-DJnbFm0E.js";var I=e=>{switch(e.name){case`new`:return`add`;case`init`:return`file`;case`undo`:return`arrow-go-back`;case`redo`:return`arrow-go-forward`;case`timeline`:return`time`;case`compact`:return`scissors`;case`reload`:return`refresh`;case`goal`:return`target`;case`review`:return`search-eye`;case`test`:case`build`:case`run`:return`terminal-box`;default:return e.isBuiltIn?`flashlight`:`command`}},ye=()=>`book-open`,be=e=>{if(e.isDirectory)return`folder-3-fill`;switch(e.extension?.toLowerCase()){case`ts`:case`tsx`:case`js`:case`jsx`:case`json`:return`code`;case`md`:case`mdx`:return`file`;case`png`:case`jpg`:case`jpeg`:case`gif`:case`svg`:return`file-image`;default:return`file-pdf`}},xe=()=>`ai-agent`,Se=()=>`chat-thread`,Ce=(e,t)=>e.map(e=>{let n=e.isSkill?t.skill:e.isOpenChamber?`OpenChamber`:e.isBuiltIn?t.system:e.scope||e.agent||t.command;return{id:e.id,title:`/${e.name}`,subtitle:e.description,badge:n,iconName:I(e)}}),we=({skills:e=[],agents:t,sessions:n,recentFiles:r,pathHits:i,untitledSession:a,sessionBadge:o,skillBadge:s})=>{let c=[];for(let t of e)c.push({id:`skill:${t.name}-${t.scope}`,title:`@${t.name}`,subtitle:t.description,badge:s??t.scope,iconName:ye()});for(let e of t)c.push({id:`agent:${e.name}`,title:`@${e.name}`,subtitle:e.description,iconName:xe()});for(let e of n)c.push({id:`session:${e.id}`,title:e.title||a,badge:o,iconName:Se()});for(let e of r)c.push({id:`recent:${e.path}`,title:e.relativePath||e.name,iconName:be(e)});for(let e of i)c.push({id:`file:${e.path}`,title:e.relativePath||e.name,iconName:be(e)});return c},Te=(e,t)=>{let n=t.trim();if(!n.length)return[...e].sort((e,t)=>e.scope===`project`&&t.scope!==`project`?-1:e.scope!==`project`&&t.scope===`project`?1:e.name.localeCompare(t.name));let r=ie([...e],n,e=>[e.name,e.description??``]);return r.sort((e,t)=>e.score===t.score?e.item.scope===`project`&&t.item.scope!==`project`?-1:e.item.scope!==`project`&&t.item.scope===`project`?1:e.item.name.localeCompare(t.item.name):e.score-t.score),r.map(e=>e.item)},Ee=(e,t)=>{let n=t.trim();if(!n)return[...e].sort((e,t)=>e.isBuiltIn===t.isBuiltIn?e.name.localeCompare(t.name):e.isBuiltIn?-1:1);let r=ie([...e],n,e=>[e.name,e.description??``]);return r.sort((e,t)=>e.score===t.score?e.item.isBuiltIn===t.item.isBuiltIn?e.item.name.localeCompare(t.item.name):e.item.isBuiltIn?-1:1:e.score-t.score),r.map(e=>e.item)},De=(e,t)=>e===t||e.length===t.length&&e.every((e,n)=>{let r=t[n];return r!=null&&e.id===r.id&&e.title===r.title&&(e.subtitle??``)===(r.subtitle??``)&&(e.badge??``)===(r.badge??``)&&e.iconName===r.iconName}),Oe=(e,t)=>e.highlightedIndex===t.highlightedIndex&&De(e.rows,t.rows),ke=(e,t)=>De(e,t)?e:t.slice(),Ae=(e,t,n)=>{e&&(t.current&&Oe(t.current,n)||(t.current=n,e(n)))},je=(e,t)=>{t.current=null,e?.({rows:[],highlightedIndex:0})},L=e(p(),1),R=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+/g,`/`);n&&!r.startsWith(`//`)&&(r=`/${r}`);let i=r===`/`,a=/^[A-Za-z]:\/$/.test(r);return!i&&!a&&(r=r.replace(/\/+$/,``)),r},z=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,B=(e,t)=>{let n=R(t),r=R(e);if(!n||!r)return!1;let i=z(n),a=z(r);return a===i||a.startsWith(`${i}/`)},Me=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t=R(e);if(!t||!r||typeof r!=`object`)continue;let i=r,a=Array.isArray(i.openPaths)?Array.from(new Set(i.openPaths.filter(e=>typeof e==`string`).map(e=>R(e)).filter(e=>B(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>R(e)).filter(e=>B(e,t)))):[],s=typeof i.selectedPath==`string`?R(i.selectedPath):null,c=s&&B(s,t)?s:a[0]??null,l=typeof i.touchedAt==`number`&&Number.isFinite(i.touchedAt)?i.touchedAt:Date.now(),u=n[t];if(u){let e=Array.from(new Set([...u.openPaths,...a])),r=Array.from(new Set([...u.expandedPaths,...o]));n[t]={openPaths:e,selectedPath:u.selectedPath??c??e[0]??null,expandedPaths:r,touchedAt:Math.max(u.touchedAt,l)};continue}n[t]={openPaths:a,selectedPath:c,expandedPaths:o,touchedAt:l}}return n},V=(e,t)=>{let n=Object.entries(e);if(n.length<=t)return e;n.sort((e,t)=>(t[1]?.touchedAt??0)-(e[1]?.touchedAt??0));let r={};for(let[e,i]of n.slice(0,t))r[e]=i;return r},Ne=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},Pe=l()(d(u((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=R((t||``).trim()),a=R((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!B(a,i)||e(e=>{let t=e.byRoot[i],n=Ne(t),r=n.openPaths.includes(a),o=r?n.openPaths:[...n.openPaths,a],s=n.selectedPath??a;return t&&r&&t.selectedPath===s?e:{byRoot:V({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=R((t||``).trim()),i=R((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=z(i),a=e=>z(e)===n,o=t.selectedPath?a(t.selectedPath):!1;if(!t.openPaths.some(a)&&!o)return e;let s=t.openPaths.filter(e=>!a(e)),c=o?s[0]??null:t.selectedPath;return{byRoot:V({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=R((t||``).trim()),i=R((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=z(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=z(e);return t===n||t.startsWith(a)},s=t.openPaths.filter(e=>!o(e));if(s.length===t.openPaths.length)return e;let c=t.selectedPath&&o(t.selectedPath)?s[0]??null:t.selectedPath;return{byRoot:V({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=R((t||``).trim()),i=R((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=z(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=z(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:V({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=R((t||``).trim()),a=n?R(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!B(a,i)||e(e=>{let t=e.byRoot[i],n=Ne(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:V({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=R((e||``).trim());if(!n)return;let r=t().byRoot[n];if(!r||r.selectedPath)return;let i=r.openPaths[0]??null;i&&t().setSelectedPath(n,i)},toggleExpandedPath:(t,n)=>{let r=R((t||``).trim()),i=R((n||``).trim());!r||!i||!B(i,r)||e(e=>{let t=e.byRoot[r],n=Ne(t),a=n.expandedPaths.includes(i)?n.expandedPaths.filter(e=>e!==i):[...n.expandedPaths,i];return t&&t.expandedPaths===a&&t.selectedPath===n.selectedPath&&t.openPaths===n.openPaths?e:{byRoot:V({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=R((t||``).trim()),i=R((n||``).trim());!r||!i||!B(i,r)||e(e=>{let t=e.byRoot[r],n=Ne(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:V({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=R((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>R((e||``).trim())).filter(e=>e&&B(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=Ne(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:V({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,...o]}},20)}})}}),{name:`files-view-tabs-store`,version:2,storage:v(),migrate:e=>{if(!e||typeof e!=`object`)return{byRoot:{}};let t=e.byRoot;return{byRoot:Me(t)}},partialize:e=>({byRoot:Me(e.byRoot)})}),{name:`files-view-tabs-store`})),H=b(),Fe=(e,t)=>{let n=(0,H.c)(4),r=t===void 0?200:t,[i,a]=L.useState(e),o,s;return n[0]!==r||n[1]!==e?(o=()=>{let t=window.setTimeout(()=>{a(e)},r);return()=>{window.clearTimeout(t)}},s=[e,r],n[0]=r,n[1]=e,n[2]=o,n[3]=s):(o=n[2],s=n[3]),L.useEffect(o,s),i},Ie=()=>{let e=(0,H.c)(17),t=E(U),n=k(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=w(r),a=E(W),o=E(Le),s=T(G),c=T(Re),l=h(K);if(t){let r;e[2]===i?r=e[3]:(r=M(i),e[2]=i,e[3]=r);let o=r;if(o)return o;let s;e[4]!==t||e[5]!==a?(s=a.get(t),e[4]=t,e[5]=a,e[6]=s):s=e[6];let c=s;if(c?.path)return c.path;let l;if(e[7]!==t||e[8]!==n){let r;e[10]===t?r=e[11]:(r=e=>e.id===t,e[10]=t,e[11]=r),l=n.find(r),e[7]=t,e[8]=n,e[9]=l}else l=e[9];let u=l;if(u?.directory)return u.directory}if(o?.open&&(o.bootstrapPendingDirectory||o.directoryOverride))return(o.bootstrapPendingDirectory||o.directoryOverride)??void 0;if(s){let t;if(e[12]!==s||e[13]!==c){let n;e[15]===s?n=e[16]:(n=e=>e.id===s,e[15]=s,e[16]=n),t=c.find(n),e[12]=s,e[13]=c,e[14]=t}else t=e[14];let n=t;if(n?.path)return n.path}return l??void 0};function U(e){return e.currentSessionId}function W(e){return e.worktreeMetadata}function Le(e){return e.newSessionDraft}function G(e){return e.activeProjectId}function Re(e){return e.projects}function K(e){return e.currentDirectory}var q=f(),J=`bg-transparent font-[inherit] text-[var(--primary-base)]`,Y=(e,t)=>{let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase();if(!r.includes(n))return e;let i=[],a=0,o=r.indexOf(n);for(;o!==-1;)o>a&&i.push(e.slice(a,o)),i.push((0,q.jsx)(`mark`,{className:J,children:e.slice(o,o+n.length)},`${o}-${n}`)),a=o+n.length,o=r.indexOf(n,a);return a<e.length&&i.push(e.slice(a)),i},X=L.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSkillSelect:i,onSessionSelect:o,onClose:s,style:c,onRowsChange:l},u)=>{let{t:d}=te(),f=Ie()??``,p=E(e=>e.currentSessionId),m=de(e=>e.activeSessions),h=re({enabled:!!o}),g=T(e=>e.activeProjectId),v=T(e=>e.projects),y=L.useMemo(()=>v.find(e=>e.id===g)?.path??null,[g,v]),b=L.useMemo(()=>{let e=y||f;return e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null},[y,f]),x=Pe(e=>b?e.byRoot[b]:void 0),ie=se(e=>e.getVisibleAgents),w=_(e=>e.searchFiles),oe=Fe(e,180),ce=r(),k=a(),[M,P]=L.useState([]),[F,fe]=L.useState([]),[pe,me]=L.useState(!1),[I,xe]=L.useState(0),Se=L.useRef(0),[Ce,Ee]=L.useState(360),[De,Oe]=L.useState({}),[ke,R]=L.useState({}),z=L.useRef([]),B=L.useRef([]),Me=L.useRef([]),V=L.useRef(null),Ne=L.useRef(null),H=L.useRef(null);H.current||=ve();let U=ee(e=>e.isMobile),W=(e??``).trim(),Le=ae({directory:f||null}),G=L.useMemo(()=>i?Te(Le.data??[],W):[],[W,i,Le.data]),Re=L.useMemo(()=>{if(!b||!x)return[];let e=[x.selectedPath,...x.openPaths.slice().reverse()].filter(e=>typeof e==`string`&&e.length>0),t=new Set,n=[];for(let r of e){if(t.has(r))continue;t.add(r);let e=r.replace(/\\/g,`/`),i=e.split(`/`).filter(Boolean).pop()||e,a=e.startsWith(`${b}/`)?e.slice(b.length+1):e;n.push({name:i,path:e,relativePath:a,extension:i.includes(`.`)?i.split(`.`).pop()?.toLowerCase():void 0})}return A(n,W,{limit:6})},[W,b,x]),K=L.useMemo(()=>W.length>0?F:F.slice(0,2),[F,W.length]),J=L.useMemo(()=>o?le({sessions:D(m,h),currentSessionId:p,searchQuery:W}):[],[m,p,h,W,o]),X=Re,Z=M;L.useEffect(()=>{let e=e=>{let t=e.target;!t||!V.current||V.current.contains(t)||s()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[s]),L.useEffect(()=>{if(!f){P([]);return}let e=(oe??``).trim(),t=O(e);if(!t){P([]);return}let n=!1;me(!0);let r={includeHidden:ce,respectGitignore:!k};return Promise.all([w(f,t,80,{...r,type:`file`}),w(f,t,40,{...r,type:`directory`})]).then(([t,r])=>{if(n)return;let i=new Set(Re.map(e=>e.path));P(ue({files:t,directories:r,query:e,excludePaths:i,limit:20}))}).catch(()=>{n||P([])}).finally(()=>{n||me(!1)}),()=>{n=!0}},[f,oe,Re,w,ce,k]),L.useEffect(()=>{let t=ie().filter(e=>e.mode&&e.mode!==`primary`).map(e=>({name:e.name,description:e.description,mode:e.mode}));fe(j(t,e??``))},[ie,e]),L.useEffect(()=>{xe(0),Oe({}),R({})},[Z,X.length,K.length,J.length,G.length]),L.useEffect(()=>{Se.current=I},[I]),L.useEffect(()=>{z.current[I]?.scrollIntoView({block:`nearest`})},[I]),L.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};B.current.forEach((n,r)=>{if(!n)return;let i=Me.current[r]?.offsetWidth??n.scrollWidth,a=Math.max(0,i-n.clientWidth),o=a>8;if(e[r]=o,o){let e=Math.max(.6,a/110);t[r]=e}}),Oe(e),R(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[Z,X]),L.useEffect(()=>{let e=B.current[I];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&Ee(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[I]);let ze=S(e=>{t(e)}),Be=S(e=>{n?.(e)}),Ve=S(e=>{o?.(e)}),He=S(e=>{i?.(e)}),Ue=G.length,We=Ue,Ge=We+K.length,Ke=Ge+J.length,qe=Ke+X.length,Je=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&H.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&H.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(H.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>H.current?.pointerCancel(),onClick:()=>{H.current?.click(t)},onMouseMove:()=>xe(e)}),Ye=e=>{let t=Ue+K.length+J.length+X.length+Z.length;if(t===0)return;let n=(e%t+t)%t;if(n<Ue){let e=G[n];e&&He(e);return}if(n<Ge){let e=K[n-We];e&&Be(e.name);return}if(n<Ke){let e=J[n-Ge];e&&Ve(e);return}let r=n-Ke,i=r<X.length?X[r]:Z[r-X.length];i&&ze(i)};L.useEffect(()=>{Ae(l,Ne,{rows:we({skills:G,agents:K,sessions:J,recentFiles:X,pathHits:Z,untitledSession:d(`chat.fileMentionAutocomplete.untitledSession`),sessionBadge:d(`chat.fileMentionAutocomplete.sessionType`),skillBadge:d(`chat.commandAutocomplete.badge.skill`)}),highlightedIndex:I})},[l,I,d,K,Z,X,J,G]);let Xe=L.useRef(l);Xe.current=l,L.useEffect(()=>()=>{je(Xe.current,Ne)},[]),L.useImperativeHandle(u,()=>({acceptIndex:e=>{Ye(e)},handleKeyDown:e=>{if(e===`Escape`){s();return}let t=Ue+K.length+J.length+X.length+Z.length;if(t!==0){if(e===`ArrowDown`){xe(e=>(e+1)%t);return}if(e===`ArrowUp`){xe(e=>(e-1+t)%t);return}(e===`Enter`||e===`Tab`)&&Ye(Se.current)}}}),[Ue,Z,X,K,J,G,s,ze,Be,Ve,He]);let Ze=e=>(0,q.jsx)(N,{name:be(e),className:`h-3.5 w-3.5 text-current`});return(0,q.jsxs)(ge,{ref:V,isMobile:U,className:`max-w-[640px] max-h-64`,style:c,children:[(0,q.jsx)(he,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,q.jsxs)(`div`,{className:`pb-2`,children:[G.length>0&&(0,q.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.groups.skills`)}),G.map((e,t)=>{let n=I===t;return(0,q.jsx)(`div`,{ref:e=>{z.current[t]=e},className:C(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,U&&`min-h-11`,_e(U,n),!U&&n&&`text-interactive-selection-foreground`),...Je(t,()=>He(e)),children:(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(N,{name:ye(),className:`h-3.5 w-3.5 translate-y-px flex-shrink-0 text-current`}),(0,q.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`@`,Y(e.name,W)]}),U?null:(0,q.jsx)(`span`,{className:`flex-shrink-0 typography-meta text-muted-foreground`,children:e.scope})]}),e.description?(0,q.jsx)(`div`,{className:C(`pl-5.5 truncate text-muted-foreground`,U?`typography-micro`:`typography-meta`),children:Y(e.description,W)}):null]})},`skill-${e.name}-${e.scope}`)}),K.length>0&&(0,q.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.groups.agents`)}),K.map((e,t)=>{let n=We+t,r=I===n;return(0,q.jsx)(`div`,{ref:e=>{z.current[n]=e},className:C(`flex items-start gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,U&&`min-h-11`,_e(U,r),!U&&r&&`text-interactive-selection-foreground`),...Je(n,()=>Be(e.name)),children:(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`truncate`,children:[`@`,Y(e.name,W)]}),e.description&&!U?(0,q.jsx)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:Y(e.description,W)}):null]})},`agent-${e.name}`)}),K.length===2&&W.length===0&&F.length>2&&(0,q.jsx)(`div`,{className:`px-3 py-1 typography-meta text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.searchMoreAgents`)}),J.length>0&&(0,q.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.groups.sessions`)}),J.map((e,t)=>{let n=Ge+t,r=I===n;return(0,q.jsxs)(`div`,{ref:e=>{z.current[n]=e},className:C(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,U&&`min-h-11`,_e(U,r),!U&&r&&`text-interactive-selection-foreground`),...Je(n,()=>Ve(e)),children:[(0,q.jsx)(N,{name:`chat-thread`,className:`h-4 w-4 flex-shrink-0 text-[var(--primary-base)]`}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.title||d(`chat.fileMentionAutocomplete.untitledSession`),children:Y(e.title||d(`chat.fileMentionAutocomplete.untitledSession`),W)}),U?null:(0,q.jsx)(`span`,{className:`flex-shrink-0 typography-meta text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.sessionType`)})]},`session-${e.id}`)}),X.length>0&&(0,q.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.groups.recentFiles`)}),X.map((e,t)=>{let n=Ke+t,r=e.relativePath||e.name,i=ne(r,{maxLength:60}),a=I===n,o=De[n]??!1,s=ke[n]??2.6;return(0,q.jsxs)(`div`,{ref:e=>{z.current[n]=e},className:C(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,U&&`min-h-11`,_e(U,a),!U&&a&&`text-interactive-selection-foreground`),...Je(n,()=>ze(e)),children:[Ze(e),(0,q.jsxs)(`span`,{ref:e=>{B.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${Ce}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,q.jsx)(`span`,{ref:e=>{Me.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,q.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:Y(r,W)}):(0,q.jsx)(`span`,{className:`block truncate`,children:Y(i,W)})]})]},`recent-${e.path}`)}),Z.length>0&&(0,q.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.groups.files`)}),Z.map((e,t)=>{let n=qe+t,r=e.relativePath||e.name,i=ne(r,{maxLength:60}),a=I===n,o=De[n]??!1,s=ke[n]??2.6;return(0,q.jsxs)(`div`,{ref:e=>{z.current[n]=e},className:C(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,U&&`min-h-11`,_e(U,a),!U&&a&&`text-interactive-selection-foreground`),...Je(n,()=>ze(e)),children:[Ze(e),(0,q.jsxs)(`span`,{ref:e=>{B.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${Ce}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,q.jsx)(`span`,{ref:e=>{Me.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,q.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:Y(r,W)}):(0,q.jsx)(`span`,{className:`block truncate`,children:Y(i,W)})]})]},e.path)}),pe&&Z.length===0?(0,q.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,q.jsx)(N,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!pe&&Z.length===0&&X.length===0&&K.length===0&&J.length===0&&G.length===0&&(0,q.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.empty`)})]})}),!U&&(0,q.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:d(`chat.autocomplete.keyboardHint`)})]})}),Z=new Set([`new`,`fork`,`compact`,`reload`,`undo`,`redo`,`model`,`goal`,`btw`]),ze=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&Z.has(n))},Be=(e,t)=>!e||t({name:e}),Ve=` `,He=(e,t)=>{let n=Math.max(0,Math.min(t,e.length)),r=n;for(;r>0&&!/\s/.test(e[r-1]);)--r;return r>=2&&e[r-1]===Ve&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},Ue=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,We=C(Ue,`bg-[color-mix(in_srgb,var(--primary-base)_12%,transparent)] text-[color-mix(in_srgb,var(--primary-base)_70%,transparent)] border-[color-mix(in_srgb,var(--primary-base)_24%,transparent)]`),Ge=C(Ue,`bg-[color-mix(in_srgb,var(--status-success)_12%,transparent)] text-[color-mix(in_srgb,var(--status-success)_70%,transparent)] border-[color-mix(in_srgb,var(--status-success)_24%,transparent)]`),Ke=C(Ue,`bg-[color-mix(in_srgb,var(--status-info)_12%,transparent)] text-[color-mix(in_srgb,var(--status-info)_70%,transparent)] border-[color-mix(in_srgb,var(--status-info)_24%,transparent)]`),qe=C(Ue,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),Je=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id&&e.description===t[n]?.description),Ye=(e,t)=>{let n=!!e.sessionID;return{hasSession:n,canStartSessionCommand:n||e.hasNewDraft,canUseReviewHandoffFlow:n&&!t&&!c()}},Xe=L.forwardRef(({searchQuery:e,onCommandSelect:t,onClose:n,directory:r,style:i,commandPolicy:a,commandContext:o,onRowsChange:s},l)=>{let{t:u}=te(),d=ee(e=>e.isMobile),f=E(e=>e.currentSessionId),p=E(e=>!!e.newSessionDraft?.open),m=E(L.useCallback(e=>f?e.getDirectoryForSession(f):void 0,[f])),h=ce(f??``,m??void 0),g=L.useMemo(()=>o??{sessionID:f??null,hasMessages:h.length>0,hasNewDraft:p},[o,f,h.length,p]),{hasSession:_,canStartSessionCommand:v,canUseReviewHandoffFlow:y}=L.useMemo(()=>Ye(g,d),[g,d]),b=g.hasMessages,[x,S]=L.useState([]),[ne,re]=L.useState(!1),ie=oe({directory:r}),ae=L.useMemo(()=>ie.data??[],[ie.data]),w=ie.isFetching,[T,se]=L.useState(0),le=L.useRef(0),D=L.useRef(!1),ue=L.useRef([]),O=L.useRef(null),k=L.useRef(!1),A=L.useRef(null),j=L.useRef(!1),M=L.useRef(null);L.useEffect(()=>{let e=e=>{let t=e.target;!t||!O.current||O.current.contains(t)||n()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[n]),L.useEffect(()=>{(async()=>{re(w);try{let t=ae.flatMap((e,t)=>e.source===`skill`?[]:[{id:`opencode:${e.scope??`global`}:${e.name}:${e.agent??``}:${e.model??``}:${t}`,name:e.name,source:`opencode`,description:e.description,agent:e.agent??void 0,model:e.model??void 0,isBuiltIn:e.isBuiltIn,scope:e.scope,reference:e.reference}]),n=[{id:`openchamber:new`,name:`new`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!b?[{id:`openchamber:init`,name:`init`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:btw`,name:`btw`,source:`openchamber`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`openchamber:undo`,name:`undo`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`openchamber:redo`,name:`redo`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`openchamber:fork`,name:`fork`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`openchamber:timeline`,name:`timeline`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`openchamber:model`,name:`model`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`openchamber:compact`,name:`compact`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...c()?[{id:`openchamber:reload`,name:`reload`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:summary`,name:`summary`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:workspace-review`,name:`workspace-review`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isOpenChamber:!0}]:[],...y?[{id:`openchamber:handoff-review`,name:`handoff-review`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.handoffReviewDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:craft-goal`,name:`craft-goal`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:goal`,name:`goal`,source:`openchamber`,description:u(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],...v?[{id:`openchamber:catch-up`,name:`catch-up`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:debug`,name:`debug`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.debugDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:weigh`,name:`weigh`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.weighDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:explore`,name:`explore`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isOpenChamber:!0}]:[],...t],r=!b,i=Ee(n.filter(e=>(r||e.name!==`init`)&&(a?.(e)??!0)),e);S(e=>Je(e,i)?e:i)}catch{let t=!b,n=Ee([{id:`openchamber:new`,name:`new`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!b?[{id:`openchamber:init`,name:`init`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:btw`,name:`btw`,source:`openchamber`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`openchamber:undo`,name:`undo`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`openchamber:redo`,name:`redo`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`openchamber:fork`,name:`fork`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`openchamber:timeline`,name:`timeline`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`openchamber:model`,name:`model`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`openchamber:compact`,name:`compact`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...c()?[{id:`openchamber:reload`,name:`reload`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:summary`,name:`summary`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:workspace-review`,name:`workspace-review`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isOpenChamber:!0}]:[],...y?[{id:`openchamber:handoff-review`,name:`handoff-review`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.handoffReviewDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:craft-goal`,name:`craft-goal`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:goal`,name:`goal`,source:`openchamber`,description:u(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],...v?[{id:`openchamber:catch-up`,name:`catch-up`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:debug`,name:`debug`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.debugDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:weigh`,name:`weigh`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.weighDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:explore`,name:`explore`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isOpenChamber:!0}]:[]].filter(e=>(t||e.name!==`init`)&&(a?.(e)??!0)),e);S(e=>Je(e,n)?e:n)}finally{re(!1)}})()},[e,b,_,v,y,ae,w,u,a]),L.useEffect(()=>{se(0)},[x]),L.useEffect(()=>{le.current=T},[T]),L.useEffect(()=>{ue.current[T]?.scrollIntoView({block:`nearest`})},[T]),L.useEffect(()=>{Ae(s,M,{rows:Ce(x,{skill:u(`chat.commandAutocomplete.badge.skill`),command:u(`chat.commandAutocomplete.badge.command`),system:u(`chat.commandAutocomplete.badge.system`)}),highlightedIndex:T})},[x,s,T,u]);let de=L.useRef(s);de.current=s,L.useEffect(()=>()=>{je(de.current,M)},[]),L.useImperativeHandle(l,()=>({acceptIndex:(e,n=!0)=>{let r=x[e];r&&t(r,ze(r,n))},handleKeyDown:e=>{let r=x.length;if(e===`Escape`){n();return}if(r!==0){if(e===`ArrowDown`){D.current=!0,se(e=>(e+1)%r);return}if(e===`ArrowUp`){D.current=!0,se(e=>(e-1+r)%r);return}if(e===`Enter`||e===`Tab`){let n=(le.current%r+r)%r,i=x[n];i&&t(i,ze(i,e===`Enter`))}}}}),[x,n,t]);let P=e=>{let t=I(e);switch(e.name){case`new`:return(0,q.jsx)(N,{name:t,className:`h-3.5 w-3.5`});case`init`:return(0,q.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,q.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,q.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:case`reload`:return(0,q.jsx)(N,{name:t,className:`h-3.5 w-3.5`});case`compact`:return(0,q.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,q.jsx)(N,{name:t,className:`h-3.5 w-3.5`});case`review`:return(0,q.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,q.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,q.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-yellow-500`}):(0,q.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,q.jsxs)(ge,{ref:O,isMobile:d,className:`max-w-[450px] max-h-64`,style:i,children:[(0,q.jsx)(he,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 py-1.5`,children:ne?(0,q.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,q.jsx)(N,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,q.jsxs)(`div`,{children:[x.map((n,r)=>{let i=n.isBuiltIn,a=n.isOpenChamber;return(0,q.jsxs)(`div`,{ref:e=>{ue.current[r]=e},className:C(`flex gap-2 px-2 py-2 cursor-pointer rounded-lg`,d?`items-center`:`items-start`,_e(d,r===T),!d&&r===T&&`bg-interactive-selection/35`),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(A.current={x:e.clientX,y:e.clientY},j.current=!1)},onPointerMove:e=>{if(e.pointerType!==`touch`||!A.current)return;let t=e.clientX-A.current.x,n=e.clientY-A.current.y;Math.hypot(t,n)>6&&(j.current=!0)},onPointerUp:e=>{if(e.pointerType!==`touch`)return;let r=j.current;A.current=null,j.current=!1,!r&&(e.preventDefault(),e.stopPropagation(),k.current=!0,t(n,ze(n,d)))},onPointerCancel:()=>{A.current=null,j.current=!1},onClick:()=>{if(k.current){k.current=!1;return}t(n,ze(n,d))},onMouseMove:()=>{D.current=!1,se(r)},children:[(0,q.jsx)(`div`,{className:C(!d&&`mt-0.5`),children:P(n)}),(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,Y(n.name,e)]}),n.isSkill?(0,q.jsx)(`span`,{className:We,children:u(`chat.commandAutocomplete.badge.skill`)}):(0,q.jsx)(`span`,{className:We,children:u(`chat.commandAutocomplete.badge.command`)}),a?(0,q.jsx)(`span`,{className:qe,children:`OpenChamber`}):i?(0,q.jsx)(`span`,{className:qe,children:u(`chat.commandAutocomplete.badge.system`)}):n.scope?(0,q.jsx)(`span`,{className:n.scope===`project`?Ke:Ge,children:n.scope}):null,n.agent&&(0,q.jsx)(`span`,{className:qe,children:n.agent})]}),n.description&&!d&&(0,q.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:Y(n.description,e)})]})]},n.id)}),x.length===0&&(0,q.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.commandAutocomplete.empty`)})]})}),!d&&(0,q.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})});Xe.displayName=`CommandAutocomplete`;function Ze(e){return(e.description||e.content).replace(/\s+/g,` `).trim().slice(0,120)}var Qe=L.forwardRef((e,t)=>{let n=(0,H.c)(63),{searchQuery:r,onSnippetSelect:i,onClose:a,style:o}=e,{t:s}=te(),c=L.useRef(null),l=ee($e),[u,d]=L.useState(0),f=L.useRef(0),p;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=[],n[0]=p):p=n[0];let[m,h]=L.useState(p),g;n[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=[],n[1]=g):g=n[1];let _=L.useRef(g),v=pe(et),y=pe(tt),b=pe(nt),x=pe(rt),S=ee(it),ne=ee(at),re,ae;n[2]===y?(re=n[3],ae=n[4]):(re=()=>{y()},ae=[y],n[2]=y,n[3]=re,n[4]=ae),L.useEffect(re,ae);let w,T;n[5]!==r||n[6]!==v?(w=()=>{let e=r.trim();if(!e.length){let e=[...v].sort(ot);h(e),d(+!!e.length);return}let t=ie(v,e,st);t.sort(ct);let n=t.map(lt);h(n),d(+!!n.length)},T=[r,v],n[5]=r,n[6]=v,n[7]=w,n[8]=T):(w=n[7],T=n[8]),L.useEffect(w,T);let oe,se;n[9]===u?(oe=n[10],se=n[11]):(oe=()=>{f.current=u,_.current[u]?.scrollIntoView({block:`nearest`})},se=[u],n[9]=u,n[10]=oe,n[11]=se),L.useEffect(oe,se);let ce,E;n[12]===a?(ce=n[13],E=n[14]):(E=()=>{let e=e=>{let t=e.target;t&&c.current&&!c.current.contains(t)&&a()};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},ce=[a],n[12]=a,n[13]=ce,n[14]=E),L.useEffect(E,ce);let le;n[15]!==i||n[16]!==r?(le=e=>{let t=r.trim(),n=e.aliases.includes(t)?t:e.name;i(e,n)},n[15]=i,n[16]=r,n[17]=le):le=n[17];let D=le,ue;n[18]!==a||n[19]!==x||n[20]!==S||n[21]!==ne||n[22]!==b||n[23]!==v?(ue=()=>{let e=new Set(v.map(ut)),t=`new-snippet`,n=1;for(;e.has(t);)t=`new-snippet-${n++}`;b({name:t,scope:`global`}),x(t),ne(`snippets`),S(!0),a()},n[18]=a,n[19]=x,n[20]=S,n[21]=ne,n[22]=b,n[23]=v,n[24]=ue):ue=n[24];let O=ue,k,A;n[25]!==D||n[26]!==m||n[27]!==a||n[28]!==O?(k=()=>({handleKeyDown:e=>{if(e===`Escape`){a();return}let t=m.length+1;if(e===`ArrowDown`){d(e=>(e+1)%t);return}if(e===`ArrowUp`){d(e=>(e-1+t)%t);return}if(e===`Enter`||e===`Tab`){if(f.current===0){O();return}let e=m[f.current-1];e&&D(e)}}}),A=[D,m,a,O],n[25]=D,n[26]=m,n[27]=a,n[28]=O,n[29]=k,n[30]=A):(k=n[29],A=n[30]),L.useImperativeHandle(t,k,A);let j;n[31]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>{_.current[0]=e},n[31]=j):j=n[31];let M;n[32]!==l||n[33]!==u?(M=C(`flex items-center gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label`,_e(l,u===0)),n[32]=l,n[33]=u,n[34]=M):M=n[34];let de,P;n[35]===Symbol.for(`react.memo_cache_sentinel`)?(de=()=>d(0),P=(0,q.jsx)(N,{name:`add`,className:`h-3.5 w-3.5 text-muted-foreground`}),n[35]=de,n[36]=P):(de=n[35],P=n[36]);let F;n[37]===s?F=n[38]:(F=s(`chat.snippetAutocomplete.action.addNew`),n[37]=s,n[38]=F);let fe;n[39]===F?fe=n[40]:(fe=(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:F}),n[39]=F,n[40]=fe);let me;n[41]!==O||n[42]!==M||n[43]!==fe?(me=(0,q.jsxs)(`div`,{ref:j,className:M,onClick:O,onMouseMove:de,children:[P,fe]}),n[41]=O,n[42]=M,n[43]=fe,n[44]=me):me=n[44];let ve;n[45]!==D||n[46]!==m||n[47]!==l||n[48]!==r||n[49]!==u||n[50]!==s?(ve=m.length?m.map((e,t)=>(0,q.jsx)(`div`,{ref:e=>{_.current[t+1]=e},className:C(`flex gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label`,l?`items-center`:`items-start`,_e(l,t+1===u)),onClick:()=>D(e),onMouseMove:()=>d(t+1),children:(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsxs)(`span`,{className:`truncate`,children:[`#`,Y(e.name,r)]}),(0,q.jsx)(`span`,{className:`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0 bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`,children:s(`snippets.source.${e.source}`)})]}),!l&&(0,q.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:Y(Ze(e),r)})]})},`${e.source}:${e.filePath}`)):(0,q.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:s(`chat.snippetAutocomplete.empty`)}),n[45]=D,n[46]=m,n[47]=l,n[48]=r,n[49]=u,n[50]=s,n[51]=ve):ve=n[51];let I;n[52]!==me||n[53]!==ve?(I=(0,q.jsxs)(he,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 pb-2`,children:[me,ve]}),n[52]=me,n[53]=ve,n[54]=I):I=n[54];let ye;n[55]!==l||n[56]!==s?(ye=!l&&(0,q.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:s(`chat.snippetAutocomplete.footer`)}),n[55]=l,n[56]=s,n[57]=ye):ye=n[57];let be;return n[58]!==l||n[59]!==o||n[60]!==I||n[61]!==ye?(be=(0,q.jsxs)(ge,{ref:c,isMobile:l,className:`max-w-[450px] max-h-60`,style:o,children:[I,ye]}),n[58]=l,n[59]=o,n[60]=I,n[61]=ye,n[62]=be):be=n[62],be});Qe.displayName=`SnippetAutocomplete`;function $e(e){return e.isMobile}function et(e){return e.snippets}function tt(e){return e.loadSnippets}function nt(e){return e.setSnippetDraft}function rt(e){return e.setSelectedSnippet}function it(e){return e.setSettingsDialogOpen}function at(e){return e.setSettingsPage}function ot(e,t){return e.source===`project`&&t.source!==`project`?-1:e.source!==`project`&&t.source===`project`?1:e.name.localeCompare(t.name)}function st(e){return[e.name,...e.aliases]}function ct(e,t){return e.score===t.score?e.item.source===`project`&&t.item.source!==`project`?-1:e.item.source!==`project`&&t.item.source===`project`?1:e.item.name.localeCompare(t.item.name):e.score-t.score}function lt(e){return e.item}function ut(e){return e.name}var dt=2,ft=e=>!!e&&typeof e==`object`&&!Array.isArray(e),pt=e=>{let t=e?.trim().replace(/\\/g,`/`);return t?t.length>1?t.replace(/\/+$/,``):t:null},mt=e=>ft(e)&&Array.isArray(e.all)&&e.all.every(e=>typeof e==`string`)&&typeof e.current==`string`&&ft(e.branches),ht=(e,t)=>JSON.stringify([e,t]),gt=e=>`version`in e&&e.version===dt&&ft(e.entries),_t=e=>{if(!e)return null;try{let t=JSON.parse(e);return ft(t)?t.version===dt&&ft(t.entries)?{version:dt,entries:t.entries}:t:null}catch{return null}},vt=(e,t)=>{try{e.setItem(`oc.gitBranchCache`,JSON.stringify(t))}catch{}},yt=(e,t,n)=>{let r=pt(e);if(!r||!t)return null;let i;try{i=n.getItem(`oc.gitBranchCache`)}catch{return null}let a=_t(i);if(!a)return null;if(gt(a))return mt(a.entries[ht(t,r)])?a.entries[ht(t,r)]:null;let o={};for(let[e,n]of Object.entries(a)){let r=pt(e);r&&mt(n)&&(o[ht(t,r)]=n)}return vt(n,{version:dt,entries:o}),o[ht(t,r)]??null},bt=(e,t,n,r)=>{let i=pt(e);if(!i||!t||!mt(n))return;let a=null;try{a=r.getItem(`oc.gitBranchCache`)}catch{return}let o=_t(a);vt(r,{version:dt,entries:{...o&&gt(o)?o.entries:{},[ht(t,i)]:n}})},xt=3e4,St=pt,Ct=(e,t=n())=>s.git.branches(St(e),t),wt=(e,t=n())=>s.git.remotes(St(e),t),Tt=async(e,t,n)=>{n.throwIfAborted();let r=i()?.git,a=t?.getGitBranches?await t.getGitBranches(e,{signal:n}):r?await r.getGitBranches(e,{signal:n}):await g(e,{signal:n});return n.throwIfAborted(),a},Et=async(e,t,n)=>{n.throwIfAborted();let r=i()?.git,a=t?.getRemotes?await t.getRemotes(e,{signal:n}):r?await r.getRemotes(e,{signal:n}):await m(e,{signal:n});return n.throwIfAborted(),a},Dt=(e,t,r=n(),i=y())=>{let a=St(e),o=t;return{queryKey:Ct(a,r),queryFn:async({signal:e})=>{if(!a)throw Error(`Git branches require a directory`);let t=await Tt(a,o,e);return bt(a,r,t,i),t},staleTime:xt,gcTime:1/0,initialData:()=>yt(a,r,i)??void 0,initialDataUpdatedAt:0}},Ot=(e,t,r=n())=>{let i=St(e),a=t;return{queryKey:wt(i,r),queryFn:({signal:e})=>{if(!i)throw Error(`Git remotes require a directory`);return Et(i,a,e)},staleTime:xt,gcTime:1/0}},kt=(e,r,i)=>{let a=(0,H.c)(9),o=i===void 0||i,s=L.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=St(e),u=x,l=Dt(c,r,s),a[0]=e,a[1]=r,a[2]=s,a[3]=c,a[4]=l,a[5]=u):(c=a[3],l=a[4],u=a[5]);let d=o&&!!c,f;return a[6]!==l||a[7]!==d?(f={...l,enabled:d},a[6]=l,a[7]=d,a[8]=f):f=a[8],u(f)},At=(e,r,i)=>{let a=(0,H.c)(9),o=i===void 0||i,s=L.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=St(e),u=x,l=Ot(c,r,s),a[0]=e,a[1]=r,a[2]=s,a[3]=c,a[4]=l,a[5]=u):(c=a[3],l=a[4],u=a[5]);let d=o&&!!c,f;return a[6]!==l||a[7]!==d?(f={...l,enabled:d},a[6]=l,a[7]=d,a[8]=f):f=a[8],u(f)},jt=(e,t,r=o,i=n())=>r.fetchQuery(Dt(e,t,i)),Mt=(e,t,r=o,i=n())=>r.fetchQuery({...Dt(e,t,i),staleTime:0}),Nt=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,Pt=1e4,Ft=6e4,It=5e3,Lt=3e4,Rt=6e4,zt=25,Bt=40,Vt=2,Ht=15e3,Ut=500,Wt=30,Gt=20971520,Kt=new Map,qt=new Map,Jt=new Map,Yt=new Map,Xt=new Map,Zt=(e,t)=>`${t}:${e}`,Qt=e=>qt.get(e)??0,$t=e=>{let t=Qt(e)+1;return qt.set(e,t),t},en=e=>{let t=(Jt.get(e)??0)+1;return Jt.set(e,t),t},tn=e=>{let t=Kt.get(e);if(t)return t;let n=new Set;return Kt.set(e,n),n},Q=()=>({isGitRepo:null,status:null,branches:null,branchesTransportIdentity:null,log:null,identity:null,diffCache:new Map,indexRevision:0,lastRepoCheckAt:0,lastStatusFetch:0,lastStatusChange:0,lastLogFetch:0,lastBranchesFetch:0,lastIdentityFetch:0,logMaxCount:25,isLoadingStatus:!1,isLoadingLog:!1,isLoadingBranches:!1,isLoadingIdentity:!1}),nn=(e,t=Wt,n=Gt)=>{let r=0;for(let t of e.values())r+=(t.original?.length??0)+(t.modified?.length??0);if(e.size<=t&&r<=n)return e;let i=Array.from(e.entries()).sort((e,t)=>e[1].fetchedAt-t[1].fetchedAt),a=new Map,o=0;for(let e=i.length-1;e>=0;e--){let[r,s]=i[e],c=(s.original?.length??0)+(s.modified?.length??0);if(a.size>=t)break;o+c>n&&a.size>0||(a.set(r,s),o+=c)}return a},rn=(e,t)=>{if(!e&&!t)return!1;if(!e||!t)return!0;let n=new Set([...Object.keys(e),...Object.keys(t)]);for(let r of n){let n=e[r],i=t[r];if(!(!n&&!i)&&(!n||!i||n.insertions!==i.insertions||n.deletions!==i.deletions))return!0}return!1},an=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,on=(e,t)=>{if(!e&&!t)return!1;if(!e||!t)return!0;let n=e.files??[],r=t.files??[];if(n.length!==r.length||e.ahead!==t.ahead||e.behind!==t.behind||e.current!==t.current||e.tracking!==t.tracking||e.isClean!==t.isClean||t.upstreamComparison!==void 0&&an(e.upstreamComparison,t.upstreamComparison))return!0;let i=new Set(n.map(e=>`${e.path}:${e.index}:${e.working_dir}`));for(let e of r)if(!i.has(`${e.path}:${e.index}:${e.working_dir}`))return!0;return!!(t.diffStats!==void 0&&rn(e.diffStats,t.diffStats))},sn=(e,t)=>{let n=new Set;if(!t)return n;let r=e?.files??[],i=t.files??[],a=new Map(r.map(e=>[e.path,e])),o=new Map(i.map(e=>[e.path,e])),s=new Set([...a.keys(),...o.keys()]);for(let e of s){let t=a.get(e),r=o.get(e);if(!t||!r){n.add(e);continue}if(t.index!==r.index||t.working_dir!==r.working_dir){n.add(e);continue}}if(t.diffStats!==void 0){let r=e?.diffStats??{},i=t.diffStats??{},a=new Set([...Object.keys(r),...Object.keys(i)]);for(let e of a){let t=r[e],a=i[e];if(!t||!a){n.add(e);continue}(t.insertions!==a.insertions||t.deletions!==a.deletions)&&n.add(e)}}return n},cn=(e,t)=>{if(!e&&!t)return!1;if(!e||!t)return!0;let n=e.files??[],r=t.files??[],i=e=>{let t=e?.trim()??``;return t===`?`?``:t},a=new Map(n.map(e=>[e.path,i(e.index)])),o=new Map(r.map(e=>[e.path,i(e.index)])),s=new Set([...a.keys(),...o.keys()]);for(let e of s)if((a.get(e)??``)!==(o.get(e)??``))return!0;return!1},ln=e=>!e||e.trim().length===0,un=e=>(e||``).trim()===`U`,dn=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(un(t)||un(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},fn=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(un(t)||un(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},pn=e=>ln(e.index)&&ln(e.working_dir),$=l()(d((e,t)=>({directories:new Map,activeDirectory:null,setActiveDirectory:n=>{let{activeDirectory:r,directories:i}=t();if(r!==n)if(r&&$t(r),n&&$t(n),n&&!i.has(n)){let t=new Map(i);t.set(n,Q()),e({activeDirectory:n,directories:t})}else e({activeDirectory:n})},getDirectoryState:e=>t().directories.get(e)??null,fetchStatus:async(n,r,i={})=>{let a=i.mode??`full`,o=Zt(n,a),s=Yt.get(o)??(a===`light`?Yt.get(Zt(n,`full`)):void 0);if(s)return s;let c=(async()=>{let{silent:a=!1}=i,{directories:o}=t(),s=o.get(n);if(s||=Q(),!a){let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isLoadingStatus:!0}),e({directories:r})}let c=!1;try{let a=Date.now(),o=s.isGitRepo!==!0||a-(s.lastRepoCheckAt||0)>Ft,l=s.isGitRepo===!0;if(o&&(l=await r.checkIsGitRepository(n)),!l){let r=new Map(t().directories),i=r.get(n)??s;return r.set(n,{...i,isGitRepo:!1,status:null,isLoadingStatus:!1,lastRepoCheckAt:a,lastStatusFetch:a}),e({directories:r}),!1}let u=await r.getGitStatus(n,i.mode?{mode:i.mode}:void 0);if(on(s.status,u)){c=!0;let r=new Map(t().directories),i=r.get(n)??Q(),s=sn(i.status,u),l=cn(i.status,u),d=new Set((i.status?.files??[]).map(e=>e.path)),f=new Set((u.files??[]).map(e=>e.path)),p=new Map(i.diffCache);for(let e of d)f.has(e)||p.delete(e);for(let e of s)p.delete(e);let m=s.size>0;m&&$t(n);let h={...u,diffStats:u.diffStats===void 0&&i.status?.diffStats!==void 0?i.status.diffStats:u.diffStats,upstreamComparison:u.upstreamComparison===void 0?i.status?.upstreamComparison:u.upstreamComparison};r.set(n,{...i,isGitRepo:!0,status:h,diffCache:p,indexRevision:l?i.indexRevision+1:i.indexRevision,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:m?Date.now():i.lastStatusChange}),e({directories:r})}else{let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isGitRepo:!0,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:i.lastStatusChange}),e({directories:r})}}catch(e){console.error(`Failed to fetch git status:`,e)}finally{if(!a){let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isLoadingStatus:!1}),e({directories:r})}}return c})();Yt.set(o,c);try{return await c}finally{Yt.get(o)===c&&Yt.delete(o)}},moveStatusPathsOptimistically:(n,r,i)=>{let a=new Set(r.map(e=>e.trim()).filter(Boolean));if(a.size===0)return null;let{directories:o}=t(),s=o.get(n),c=s?.status??null;if(!s||!c)return c;let l=!1,u=[];for(let e of c.files){if(!a.has(e.path)){u.push(e);continue}let t=i===`stage`?dn(e):fn(e);t!==e&&(l=!0),pn(t)?l=!0:u.push(t)}if(!l)return c;let d=new Map(o);return d.set(n,{...s,status:{...c,files:u,isClean:u.length===0},indexRevision:s.indexRevision+1,lastStatusChange:Date.now()}),e({directories:d}),c},restoreStatus:(n,r)=>{let{directories:i}=t(),a=i.get(n);if(!a)return;let o=new Map(i);o.set(n,{...a,status:r,indexRevision:a.indexRevision+1,lastStatusChange:Date.now()}),e({directories:o})},bumpIndexRevision:n=>{let{directories:r}=t(),i=r.get(n);if(!i)return;let a=new Map(r);a.set(n,{...i,indexRevision:i.indexRevision+1}),e({directories:a})},fetchBranches:async(r,i,a={})=>{let o=n(),s=en(r);{let n=new Map(t().directories),i=n.get(r)??Q();n.set(r,{...i,isLoadingBranches:!0}),e({directories:n})}try{let c=a.force?await Mt(r,i,void 0,o):await jt(r,i,void 0,o);if(s!==Jt.get(r)||o!==n())return;let l=new Map(t().directories),u=l.get(r)??Q();l.set(r,{...u,branches:c,branchesTransportIdentity:o,isLoadingBranches:!1,lastBranchesFetch:Date.now()}),e({directories:l})}catch(i){if(Nt(i)||console.error(`Failed to fetch git branches:`,i),s!==Jt.get(r)||o!==n())return;let a=new Map(t().directories),c=a.get(r)??Q();a.set(r,{...c,isLoadingBranches:!1}),e({directories:a})}},fetchLog:async(n,r,i)=>{let{directories:a}=t(),o=a.get(n),s=i??o?.logMaxCount??25;{let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isLoadingLog:!0}),e({directories:r})}try{let i=await r.getGitLog(n,{maxCount:s}),a=new Map(t().directories),o=a.get(n)??Q();a.set(n,{...o,log:i,isLoadingLog:!1,lastLogFetch:Date.now(),logMaxCount:s}),e({directories:a})}catch(r){console.error(`Failed to fetch git log:`,r);let i=new Map(t().directories),a=i.get(n)??Q();i.set(n,{...a,isLoadingLog:!1}),e({directories:i})}},fetchIdentity:async(n,r)=>{{let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isLoadingIdentity:!0}),e({directories:r})}try{let i=await r.getCurrentGitIdentity(n),a=new Map(t().directories),o=a.get(n)??Q();a.set(n,{...o,identity:i,isLoadingIdentity:!1,lastIdentityFetch:Date.now()}),e({directories:a})}catch(r){console.error(`Failed to fetch git identity:`,r);let i=new Map(t().directories),a=i.get(n)??Q();i.set(n,{...a,isLoadingIdentity:!1}),e({directories:i})}},fetchAll:async(n,r,i={})=>{let{directories:a}=t(),o=a.get(n);if(!o){o=Q();let t=new Map(a);t.set(n,o),e({directories:t})}let{force:s=!1,silentIfCached:c=!1}=i,l=Date.now();await t().fetchStatus(n,r,{silent:c&&!!o?.status});let u=t().directories.get(n);if(!u?.isGitRepo)return;await t().fetchBranches(n,r,{force:s});let d=l-(u.lastLogFetch||0);(s||d>Pt||!u.log)&&await t().fetchLog(n,r),await t().fetchIdentity(n,r)},getDiff:(e,n)=>t().directories.get(e)?.diffCache.get(n)??null,setDiff:(n,r,i)=>{let a=new Map(t().directories),o=a.get(n)??Q(),s=new Map(o.diffCache);s.set(r,{...i,fetchedAt:Date.now()});let c=nn(s);a.set(n,{...o,diffCache:c}),e({directories:a})},clearDiffCache:n=>{$t(n);let r=new Map(t().directories),i=r.get(n);i&&(r.set(n,{...i,diffCache:new Map}),e({directories:r}))},fetchAllDiffs:async(e,n)=>{let r=t().directories.get(e);if(!r?.status?.files||r.status.files.length===0)return;let i=r.status.files.map(e=>e.path).slice(0,zt);await t().prefetchDiffs(e,n,i,{maxFiles:zt})},prefetchDiffs:async(n,r,i,a={})=>{let o=t().directories.get(n);if(!o?.status?.files||o.status.files.length===0||i.length===0)return;let{maxFiles:s=Bt}=a,c=new Set(o.status.files.map(e=>e.path)),l=o.status.diffStats,u=tn(n),d=[],f=new Set;for(let e of i){if(!e||f.has(e)||(f.add(e),!c.has(e))||o.diffCache.has(e)||u.has(e))continue;let t=l?.[e];t&&t.insertions+t.deletions>Ut||d.push(e)}let p=d.slice(0,Math.max(1,s));if(p.length===0)return;let m=Qt(n);if(typeof document<`u`&&document.hidden)return;p.forEach(e=>u.add(e));let h=0,g=[],_=()=>{let e=h;return h+=1,e<p.length?p[e]:null},v=async e=>{let t=r.getGitFileDiff(n,{path:e}),i=new Promise((e,t)=>{setTimeout(()=>t(Error(`Timed out after ${Ht}ms`)),Ht)}),a=await Promise.race([t,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},ee=async()=>{for(;;){if(m!==Qt(n))return;let e=_();if(!e)return;try{g.push(await v(e))}catch{}finally{u.delete(e)}}},y=Math.min(Vt,p.length);if(await Promise.allSettled(Array.from({length:y},()=>ee())),p.forEach(e=>u.delete(e)),m!==Qt(n))return;let b=new Map(t().directories),x=b.get(n);if(!x)return;let S=new Map(x.diffCache),te=Date.now();g.forEach(e=>{!e.diff.isBinary&&e.diff.original===``&&e.diff.modified===``||S.set(e.path,{...e.diff,fetchedAt:te})});let C=nn(S);b.set(n,{...x,diffCache:C}),e({directories:b})},setLogMaxCount:(n,r)=>{let i=new Map(t().directories),a=i.get(n)??Q();i.set(n,{...a,logMaxCount:r}),e({directories:i})},ensureStatus:async(e,n)=>{let r=t().directories.get(e),i=Date.now();r?.status&&i-r.lastStatusFetch<It||await t().fetchStatus(e,n,{silent:!!r?.status})},ensureAll:(e,n)=>{let r=Xt.get(e);if(r)return r;let i=(async()=>{let r=t().directories.get(e),i=Date.now();(!r?.status||r.status.diffStats===void 0||i-(r?.lastStatusFetch??0)>=It)&&await t().fetchStatus(e,n,{silent:!!r?.status});let a=t().directories.get(e);if(!a?.isGitRepo)return;let o=[];(!a.branches||i-a.lastBranchesFetch>=Lt)&&o.push(t().fetchBranches(e,n)),(!a.log||i-a.lastLogFetch>=Pt)&&o.push(t().fetchLog(e,n)),(!a.identity||i-a.lastIdentityFetch>=Rt)&&o.push(t().fetchIdentity(e,n)),o.length>0&&await Promise.all(o)})();return Xt.set(e,i),i.finally(()=>{Xt.get(e)===i&&Xt.delete(e)}),i},refresh:async(e,n={})=>{let{activeDirectory:r}=t();r&&await t().fetchAll(r,e,n)}}),{name:`git-store`})),mn=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status??null:null,t[0]=e,t[1]=n),$(n)},hn=e=>{let r=(0,H.c)(3),i=L.useSyncExternalStore(t,n,n),a;return r[0]!==e||r[1]!==i?(a=t=>{if(!e)return null;let n=t.directories.get(e);return n?.branchesTransportIdentity===i?n.branches:null},r[0]=e,r[1]=i,r[2]=a):a=r[2],$(a)},gn=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.log??null:null,t[0]=e,t[1]=n),$(n)},_n=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isGitRepo??null:null,t[0]=e,t[1]=n),$(n)},vn=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status?.current?.trim()??null:null,t[0]=e,t[1]=n),$(n)},yn=e=>{let t=(0,H.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=L.useRef(n),i;return t[1]===e?i=t[2]:(i=t=>{let n=r.current,i=n.size===e.length;if(i)for(let r of e){let e=t.directories.get(r),a=n.get(r);if(!a||(e?.isGitRepo??null)!==a.isGitRepo||(e?.status?.current??null)!==a.branch){i=!1;break}}if(i)return n;let a=new Map;for(let n of e){let e=t.directories.get(n);a.set(n,{isGitRepo:e?.isGitRepo??null,branch:e?.status?.current??null})}return r.current=a,a},t[1]=e,t[2]=i),$(i)},bn=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingStatus??!1:!1,t[0]=e,t[1]=n),$(n)},xn=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingLog??!1:!1,t[0]=e,t[1]=n),$(n)},Sn=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingBranches??!1:!1,t[0]=e,t[1]=n),$(n)},Cn=e=>{let t=String(e||``).trim().replace(/^remotes\//,``);if(!t)return null;let n=t.indexOf(`/`);return n<=0||n>=t.length-1?null:{remote:t.slice(0,n),branch:t.slice(n+1)}},wn=e=>String(e||``).trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/^remotes\//,``),Tn=e=>e.branchName?wn(e.branchName):e.mode===`existing`?wn(e.existingBranch||e.preferredName||``):wn(e.preferredName||``),En=async e=>{let t=await fe(e);try{let n=Cn((await P(e)).branches?.[t]?.tracking||null);if(n?.remote)return n.remote}catch{}try{let t=Cn((await F(e)).tracking);if(t?.remote)return t.remote}catch{}return null},Dn=async(e,t)=>{let n=await En(e),r=wn(t);return!n||!r?null:{setUpstream:!0,upstreamRemote:n,upstreamBranch:r}},On=async(e,t,n)=>{let r=Tn(t),i=n?.resolvedRootTrackingRemote,a=i===void 0?await Dn(e,r):i&&wn(r)?{setUpstream:!0,upstreamRemote:i,upstreamBranch:wn(r)}:null;return a?{...t,setUpstream:t.setUpstream??a.setUpstream,upstreamRemote:t.upstreamRemote||a.upstreamRemote,upstreamBranch:t.upstreamBranch||a.upstreamBranch}:t},kn=async(e,t,n)=>{let r=await On(e.path,t,n);return me(e,r)},An=`oc:lastWorktreeSourceBranch`,jn=({mode:e,sourceBranch:t,linkedPr:n,selectedBranch:r})=>e===`existing-branch`?r||null:n?null:t||null,Mn=({branches:e,savedSourceBranch:t,rootBranch:n})=>t&&e.includes(t)&&t?{sourceBranch:t,shouldClearSavedSourceBranch:!1}:{sourceBranch:n&&e.includes(n)?n:e.includes(`main`)?`main`:e.includes(`master`)?`master`:e[0]??``,shouldClearSavedSourceBranch:!!t},Nn=(e,t,n)=>{if(!e)return e;let r=t.length>0&&!/\s$/.test(t)&&!/^\s/.test(e)&&!/[([{]$/.test(t),i=n.length>0&&!/\s$/.test(e)&&!/^\s/.test(n)&&!/^[\])}.,;:!?]/.test(n);return`${r?` `:``}${e}${i?` `:``}`},Pn=(e,t,n)=>{let r=Nn(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},Fn=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=Pn(r,i,a),s=Math.max(0,o.indexOf(r)),c=i.length+s;return{text:`${i}${o}${a}`,caret:i.length+o.length,start:c,end:c+r.length}},In=(e,t)=>{let n=e=>`${e.kind}:${e.value}:${e.range.start}:${e.range.end}`;return new Set(e.map(n)).has(n(t))||e.some(e=>e.range.start<t.range.end&&t.range.start<e.range.end)?[...e]:[...e,t]},Ln=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{Fe as A,At as C,Be as D,He as E,ke as M,X as O,kt as S,Xe as T,yn as _,An as a,_n as b,kn as c,vn as d,hn as f,gn as g,bn as h,Pn as i,Pe as j,Ie as k,En as l,xn as m,In as n,Mn as o,Sn as p,Fn as r,jn as s,Ln as t,On as u,mn as v,Qe as w,Mt as x,$ as y};
@@ -1,4 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{tn as t}from"./persistence-CMWO3jFo.js";import{a as n,r}from"./vendor-zustand-B4dlGEM2.js";import{nt as i,rt as a}from"./vendor-base-ui-CnHfUmDN.js";import{Bn as o,Ct as s,Kn as c,Nt as l}from"./platform-BxU3ZvQ0.js";import{n as u}from"./useUIStore-Brsa2mKs.js";import{n as d}from"./vendor-react-DLPElpoQ.js";import{n as f}from"./vendor-reactuses-core-Dq5ocTF8.js";import{f as p,i as m,r as h,t as g,y as _}from"./button-EzCcYrQl.js";import{Cr as v,Sa as y,Un as b,Wn as x,Xa as S,aa as ee,ba as C,d as w,qn as T,rr as E,u as D,yr as O}from"./useMobileNavigationStore-DrdLEZXl.js";import{n as k}from"./Icon-DKd015RD.js";import{n as te}from"./gitApi-BiPCMFjN.js";import{D as ne,O as re,S as A,_ as ie,a as j,b as ae,f as M,g as oe,h as se,i as N,j as ce,k as le,m as ue,n as P,v as F,x as de,y as I}from"./projectMeta-CdRGrq5D.js";import{t as L}from"./input-DksVnckl.js";import{i as R,n as z,t as B}from"./tooltip-DwUy2erJ.js";import{o as fe}from"./OverlayScrollbar-SUdC3Pqe.js";import{n as V}from"./useRuntimeAPIs-DSLXJybW.js";import{r as pe,t as me}from"./textarea-B9pCxe-7.js";import{O as he,T as ge,a as H,b as U,c as _e,f as W,h as G,l as K,o as q,p as J,r as ve,w as ye,y as Y}from"./insertionBoundaries-DN60qQpt.js";import{n as be,r as xe,t as Se}from"./collapsible-BwvSZkMC.js";var X=e(a(),1),Ce=d(),Z=/^[a-z0-9](?:[a-z0-9-]{0,48}[a-z0-9])?$/,Q=/^g[1-9]\d*$/,we=(e,t,n,r,i)=>{if(!Z.test(e)||t!==void 0&&!Q.test(t)||!n?.trim()||!r?.trim()||n!==n.trim()||r!==r.trim())return null;if(i===void 0)return{groupSlug:e,runGroup:t,providerID:n,modelID:r,fusion:!1};if(i===`fusion`)return{groupSlug:e,runGroup:t,providerID:n,modelID:r,fusion:!0};if(!/^\d+$/.test(i))return null;let a=Number.parseInt(i,10);return!Number.isSafeInteger(a)||a<=0?null:{groupSlug:e,runGroup:t,providerID:n,modelID:r,index:a,fusion:!1}},Te=e=>{if(!e)return null;let t=e.split(`/`);if(t.length<3||t.length>5)return null;let[n]=t;if(t.length===3)return we(n,void 0,t[1],t[2],void 0);if(t.length===4){let[,e,r,i]=t;return Q.test(e)?we(n,e,r,i,void 0):we(n,void 0,e,r,i)}let[,r,i,a,o]=t;return r===``?we(n,void 0,i,a,o):we(n,r,i,a,o)},Ee=e=>{let t=[e.groupSlug];return e.runGroup&&t.push(e.runGroup),t.push(e.providerID,e.modelID),e.index!==void 0&&t.push(String(e.index)),t.join(`/`)},De=(e,t,n,r)=>{let i=[e];return r&&i.push(r),i.push(t,n,`fusion`),i.join(`/`)},Oe=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).substring(0,50),ke=(e,t)=>`${Oe(e)}-${Oe(t)}`.substring(0,60),Ae=(e,t)=>`${e}/${t}`,je=e=>{let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.length>1?t.replace(/\/+$/,``):t},Me=(e,t)=>{let n=je(t),r=e.directory,i=typeof r==`string`&&r.trim().length>0?e:{...e,directory:n};c(e.id,n),w.getState().markSessionAsOpenChamberCreated(e.id),O.getState().upsertSession(i);try{o().ensureChild(n,{bootstrap:!1}).setState(t=>{let n=t.session.findIndex(t=>t.id===e.id);if(n>=0&&t.session[n]===i)return t;let r=n>=0?t.session.map((e,t)=>t===n?i:e):[...t.session,i].sort((e,t)=>e.id.localeCompare(t.id));return{session:r,sessionTotal:Math.max(t.sessionTotal,r.length),limit:Math.max(t.limit,r.length)}})}catch{}return i},Ne=()=>{let e=S.getState(),t=e.activeProjectId;if(!t)return null;let n=e.projects.find(e=>e.id===t);if(n?.path)return{id:n.id,path:n.path};let r=s.getState().currentDirectory??null;if(r&&r.trim().length>0){let e=r.replace(/\\/g,`/`).replace(/\/+$/,``)||r;return{id:`path:${e}`,path:e}}return null},Pe=n()(r(e=>({isLoading:!1,error:null,createMultiRun:async t=>{let n=t.name.trim(),{groups:r,agent:i,files:a,setupCommands:o}=t;if(!n)return e({error:`Group name is required`}),null;if(!r||r.length===0)return e({error:`At least one run group is required`}),null;for(let t=0;t<r.length;t++){if(!r[t].prompt.trim())return e({error:`Group ${t+1}: prompt is required`}),null;if(r[t].models.length<1)return e({error:`Group ${t+1}: select at least 1 model`}),null;if(r[t].models.length>5)return e({error:`Group ${t+1}: maximum 5 models allowed`}),null}e({isLoading:!0,error:null});try{let s=Ne();if(!s)return e({error:`Select a project`,isLoading:!1}),null;let c=s.path,u=await te(c)&&t.isolateRuns!==!1,d=Oe(n),f=u?await M(c):void 0,p=u?await K(c):null,m=[],h=o?.filter(e=>e.trim().length>0)??[];for(let e=0;e<r.length;e++){let n=r[e],i=n.prompt,a=new Map;for(let e of n.models){let t=`${e.providerID}:${e.modelID}`;a.set(t,(a.get(t)||0)+1)}let o=new Map;for(let g of n.models){let n=`${g.providerID}:${g.modelID}`,_=a.get(n)||1,v=(o.get(n)||0)+1;o.set(n,v);let y=ke(g.providerID,g.modelID),b=r.length>1?`g${e+1}`:void 0,S=_>1?Ae(d,`${y}/${v}`):Ae(d,y),ee=b?`${b}/${S}`:S,C=Ee({groupSlug:d,runGroup:b,providerID:g.providerID,modelID:g.modelID,index:_>1?v:void 0});try{if(!u){let e=await l.withDirectory(c,()=>l.createSession({title:C}));Me(e,c),m.push({sessionId:e.id,worktreePath:c,providerID:g.providerID,modelID:g.modelID,variant:g.variant,prompt:i});continue}let e=await _e(s,{preferredName:ee,mode:`new`,branchName:ee,worktreeName:ee,startRef:t.worktreeBaseBranch||`HEAD`,setupCommands:h,returnAfterDirectoryCreated:!0},{resolvedRootTrackingRemote:p}),n={...e,createdFromBranch:f,kind:`standard`};await x(s)&&await E(e.path);let r=await l.withDirectory(e.path,()=>l.createSession({title:C}));Me(r,e.path),w.getState().setWorktreeMetadata(r.id,n),m.push({sessionId:r.id,worktreePath:e.path,providerID:g.providerID,modelID:g.modelID,variant:g.variant,prompt:i})}catch(e){console.warn(`[MultiRun] Failed to create session:`,e)}}}let g=o?.filter(e=>e.trim().length>0)??[];g.length>0&&T(s,g).catch(()=>{console.warn(`[MultiRun] Failed to save worktree setup commands`)});let _=m.map(e=>e.sessionId),v=m[0]?.sessionId??null;if(_.length===0)return e({error:`Failed to create any sessions`,isLoading:!1}),null;let y=a?.map(e=>({type:`file`,mime:e.mime,filename:e.filename,url:e.url}));return(async()=>{try{let e=le.getState().expandText;await Promise.allSettled(m.map(async t=>{try{let n=await e(t.prompt).catch(()=>t.prompt);await D({sessionId:t.sessionId,directory:t.worktreePath,content:n,providerID:t.providerID,modelID:t.modelID,variant:t.variant,agent:i,files:y})}catch(e){console.warn(`[MultiRun] Failed to start run:`,e)}}))}catch(e){console.warn(`[MultiRun] Failed to start runs:`,e)}})(),e({isLoading:!1}),{groupSlug:d,sessionIds:_,firstSessionId:v}}catch(t){return e({error:t instanceof Error?t.message:`Failed to create Multi-Run`,isLoading:!1}),null}},clearError:()=>{e({error:null})}}),{name:`multirun-store`})),$=i(),Fe=`h-7`,Ie=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,Le=e=>{let t=(0,Ce.c)(13),{model:n,instanceIndex:r,totalSameModel:i,onRemove:a}=e,o=n.displayName||`${n.providerID}/${n.modelID}`,s=i>1?`${o} (${r})`:o,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=h(`flex items-center gap-1.5 px-2 rounded-md bg-interactive-selection/20 border border-border/30`,Fe),t[0]=c):c=t[0];let l;t[1]!==n.modelID||t[2]!==n.providerID?(l=(0,$.jsx)(re,{modelId:n.modelID,providerId:n.providerID,className:`h-3.5 w-3.5`}),t[1]=n.modelID,t[2]=n.providerID,t[3]=l):l=t[3];let u;t[4]===s?u=t[5]:(u=(0,$.jsx)(`span`,{className:`typography-meta font-medium truncate max-w-[140px]`,children:s}),t[4]=s,t[5]=u);let d;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(k,{name:`close`,className:`h-3.5 w-3.5`}),t[6]=d):d=t[6];let f;t[7]===a?f=t[8]:(f=(0,$.jsx)(`button`,{type:`button`,onClick:a,className:`text-muted-foreground hover:text-foreground ml-0.5`,children:d}),t[7]=a,t[8]=f);let p;return t[9]!==l||t[10]!==u||t[11]!==f?(p=(0,$.jsxs)(`div`,{className:c,children:[l,u,f]}),t[9]=l,t[10]=u,t[11]=f,t[12]=p):p=t[12],p},Re=e=>{let t=(0,Ce.c)(131),{selectedModels:n,onAdd:r,onRemove:i,onUpdate:a,minModels:o,addButtonLabel:s,showChips:c,maxModels:l,addButtonClassName:d,dropdownSide:f,dropdownClassName:m,containerClassName:_,triggerIcon:v}=e,b=c===void 0||c,x=f===void 0?`top`:f,{t:S}=p(),C=ee(ze),w=ee(Be),T=u(Ve),E=u(He),{favoriteModelsList:D,recentModelsList:O}=ne(),te=u(Ue),re=u(We),[j,M]=X.useState(!1),[oe,N]=X.useState(``),[ce,le]=X.useState(null),P=X.useRef(null),F=X.useRef(null),I=l===1,L=l===void 0||n.length<l||I,R;if(t[0]!==n){R=new Map;for(let e of n){let t=`${e.providerID}:${e.modelID}`;R.set(t,(R.get(t)||0)+1)}t[0]=n,t[1]=R}else R=t[1];let z=R,B;t[2]===n?B=t[3]:(B=e=>n.filter(t=>t.providerID===e.providerID&&t.modelID===e.modelID).findIndex(t=>t.instanceId===e.instanceId)+1,t[2]=n,t[3]=B);let fe=B,V,pe;t[4]!==x||t[5]!==j?(V=()=>{if(!j||!F.current)return;let e=F.current.getBoundingClientRect();if(x===`bottom`){let t=(window.visualViewport?.height??document.documentElement.clientHeight??window.innerHeight)-e.bottom-16-112;le(Math.max(160,Math.min(320,t)));return}let t=F.current.parentElement;for(;t&&!(t.getAttribute(`role`)===`dialog`||t.hasAttribute(`data-scroll-shadow`));){let e=getComputedStyle(t);if(e.overflow===`auto`||e.overflow===`hidden`||e.overflowY===`auto`||e.overflowY===`hidden`)break;t=t.parentElement}let n=t?t.getBoundingClientRect().top:0,r=e.top-n-16;le(Math.max(150,Math.min(300,r)))},pe=[x,j],t[4]=x,t[5]=j,t[6]=V,t[7]=pe):(V=t[6],pe=t[7]),X.useEffect(V,pe);let me,he;t[8]!==L||t[9]!==j?(me=()=>{!L&&j&&(M(!1),N(``))},he=[L,j],t[8]=L,t[9]=j,t[10]=me,t[11]=he):(me=t[10],he=t[11]),X.useEffect(me,he);let ge,H;t[12]===j?(ge=t[13],H=t[14]):(ge=()=>{if(!j)return;let e=e=>{P.current&&!P.current.contains(e.target)&&(M(!1),N(``))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},H=[j],t[12]=j,t[13]=ge,t[14]=H),X.useEffect(ge,H);let U;t[15]!==I||t[16]!==r||t[17]!==a||t[18]!==n.length?(U=e=>{let t={providerID:e.providerID,modelID:e.modelID,displayName:y(e.model,e.modelID)||e.modelID,instanceId:Ie()};I&&n.length>0&&a?a(0,t):r(t),I&&(M(!1),N(``))},t[15]=I,t[16]=r,t[17]=a,t[18]=n.length,t[19]=U):U=t[19];let _e=U,W;t[20]===S?W=t[21]:(W=S(`multirun.modelMultiSelect.search.placeholder`),t[20]=S,t[21]=W);let G;t[22]===S?G=t[23]:(G=S(`multirun.modelMultiSelect.search.noResults`),t[22]=S,t[23]=G);let K;t[24]===S?K=t[25]:(K=S(`multirun.modelMultiSelect.sections.favorites`),t[24]=S,t[25]=K);let q;t[26]===S?q=t[27]:(q=S(`multirun.modelMultiSelect.sections.recent`),t[26]=S,t[27]=q);let J;t[28]===S?J=t[29]:(J=S(`multirun.modelMultiSelect.keyboard.hint`),t[28]=S,t[29]=J);let ve;t[30]===S?ve=t[31]:(ve=S(`settings.agents.modelSelector.actions.favorite`),t[30]=S,t[31]=ve);let ye;t[32]===S?ye=t[33]:(ye=S(`settings.agents.modelSelector.actions.unfavorite`),t[32]=S,t[33]=ye);let Y;t[34]===S?Y=t[35]:(Y=S(`chat.modelControls.provider`),t[34]=S,t[35]=Y);let be;t[36]===S?be=t[37]:(be=S(`chat.modelControls.capabilities`),t[36]=S,t[37]=be);let xe;t[38]===S?xe=t[39]:(xe=S(`chat.modelControls.capability.toolCalling`),t[38]=S,t[39]=xe);let Se;t[40]===S?Se=t[41]:(Se=S(`chat.modelControls.capability.reasoning`),t[40]=S,t[41]=Se);let Z;t[42]===S?Z=t[43]:(Z=S(`chat.modelControls.modality.image`),t[42]=S,t[43]=Z);let Q;t[44]===S?Q=t[45]:(Q=S(`chat.modelControls.modality.video`),t[44]=S,t[45]=Q);let we;t[46]===S?we=t[47]:(we=S(`chat.modelControls.modality.audio`),t[46]=S,t[47]=we);let Te;t[48]===S?Te=t[49]:(Te=S(`chat.modelControls.costPerMillion`),t[48]=S,t[49]=Te);let Ee;t[50]===S?Ee=t[51]:(Ee=S(`chat.modelControls.costInput`),t[50]=S,t[51]=Ee);let De;t[52]===S?De=t[53]:(De=S(`chat.modelControls.costOutput`),t[52]=S,t[53]=De);let Oe;t[54]!==W||t[55]!==G||t[56]!==K||t[57]!==q||t[58]!==J||t[59]!==ve||t[60]!==ye||t[61]!==Y||t[62]!==be||t[63]!==xe||t[64]!==Se||t[65]!==Z||t[66]!==Q||t[67]!==we||t[68]!==Te||t[69]!==Ee||t[70]!==De?(Oe={searchPlaceholder:W,noResults:G,favorites:K,recent:q,keyboardHint:J,favorite:ve,unfavorite:ye,provider:Y,capabilities:be,capabilityToolCalling:xe,capabilityReasoning:Se,modalityImage:Z,modalityVideo:Q,modalityAudio:we,costPerMillion:Te,costInput:Ee,costOutput:De},t[54]=W,t[55]=G,t[56]=K,t[57]=q,t[58]=J,t[59]=ve,t[60]=ye,t[61]=Y,t[62]=be,t[63]=xe,t[64]=Se,t[65]=Z,t[66]=Q,t[67]=we,t[68]=Te,t[69]=Ee,t[70]=De,t[71]=Oe):Oe=t[71];let ke=Oe,Ae;t[72]===_?Ae=t[73]:(Ae=h(`relative`,_),t[72]=_,t[73]=Ae);let je;t[74]===d?je=t[75]:(je=h(Fe,`!border-border/80 !bg-[var(--surface-subtle)] hover:!bg-[var(--interactive-hover)]/70`,d),t[74]=d,t[75]=je);let Me=!L,Ne;t[76]===j?Ne=t[77]:(Ne=()=>{M(!j)},t[76]=j,t[77]=Ne);let Pe;t[78]===v?Pe=t[79]:(Pe=v??(0,$.jsx)(k,{name:`add`,className:`h-3.5 w-3.5 mr-1`}),t[78]=v,t[79]=Pe);let Re;t[80]!==s||t[81]!==S?(Re=s??S(`multirun.modelMultiSelect.actions.addModel`),t[80]=s,t[81]=S,t[82]=Re):Re=t[82];let Ke;t[83]!==je||t[84]!==Me||t[85]!==Ne||t[86]!==Pe||t[87]!==Re?(Ke=(0,$.jsxs)(g,{ref:F,type:`button`,variant:`outline`,size:`sm`,className:je,disabled:Me,onClick:Ne,children:[Pe,Re]}),t[83]=je,t[84]=Me,t[85]=Ne,t[86]=Pe,t[87]=Re,t[88]=Ke):Ke=t[88];let qe;t[89]!==ce||t[90]!==L||t[91]!==m||t[92]!==x||t[93]!==D||t[94]!==w||t[95]!==_e||t[96]!==te||t[97]!==E||t[98]!==j||t[99]!==ke||t[100]!==z||t[101]!==re||t[102]!==C||t[103]!==O||t[104]!==oe||t[105]!==T?(qe=j?(0,$.jsx)(`div`,{className:h(`absolute left-0 z-50 w-[min(420px,calc(100vw-2rem))] max-w-[calc(100vw-2rem)] flex flex-col overflow-hidden rounded-xl border border-border/50 shadow-lg`,x===`top`?`bottom-full mb-1`:`top-full mt-1`,m),style:{background:`linear-gradient(var(--surface-elevated),var(--surface-elevated)),linear-gradient(var(--surface-background),var(--surface-background))`},children:(0,$.jsx)(A,{providers:C,providerOrder:re,favoriteModels:D,recentModels:O,getMetadata:w,hiddenModels:te,searchQuery:oe,onSearchQueryChange:N,onSelect:_e,labels:ke,selectionCount:e=>z.get(`${e.providerID}:${e.modelID}`)||0,disabled:!L,maxHeightClassName:`flex-1`,maxHeightStyle:{maxHeight:ce?`${ce}px`:`300px`},stickyHeaders:!0,tooltipsEnabled:j,isFavorite:e=>E(e.providerID,e.modelID),onToggleFavorite:e=>T(e.providerID,e.modelID),onEscape:()=>{M(!1),N(``)}})}):null,t[89]=ce,t[90]=L,t[91]=m,t[92]=x,t[93]=D,t[94]=w,t[95]=_e,t[96]=te,t[97]=E,t[98]=j,t[99]=ke,t[100]=z,t[101]=re,t[102]=C,t[103]=O,t[104]=oe,t[105]=T,t[106]=qe):qe=t[106];let Je;t[107]!==Ae||t[108]!==Ke||t[109]!==qe?(Je=(0,$.jsxs)(`div`,{className:Ae,ref:P,children:[Ke,qe]}),t[107]=Ae,t[108]=Ke,t[109]=qe,t[110]=Je):Je=t[110];let Ye;t[111]!==fe||t[112]!==z||t[113]!==i||t[114]!==a||t[115]!==C||t[116]!==n||t[117]!==b||t[118]!==S?(Ye=b&&n.length>0&&(0,$.jsx)(`div`,{className:`flex flex-col gap-2 w-full`,children:n.map((e,t)=>{let n=`${e.providerID}:${e.modelID}`,r=z.get(n)||1,o=fe(e),s=C.find(t=>t.id===e.providerID)?.models?.find(t=>t.id===e.modelID),c=s?.variants?Object.keys(s.variants):[],l=c.length>0,u=e.variant??`__default__`;return(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(Le,{model:e,instanceIndex:o,totalSameModel:r,onRemove:()=>i(t)}),l&&(0,$.jsxs)(ue,{value:u,onValueChange:n=>{if(!a)return;let r=n===`__default__`?void 0:n;a(t,{...e,variant:r})},children:[(0,$.jsxs)(ae,{size:`chip`,className:`px-2 gap-1.5 rounded-md !border-border/80 !bg-[var(--surface-subtle)] hover:!bg-[var(--interactive-hover)]/70 typography-meta font-medium text-foreground`,children:[(0,$.jsx)(k,{name:`brain-ai-3`,className:h(`h-3.5 w-3.5 flex-shrink-0`,u===`__default__`?`text-muted-foreground`:`text-[color:var(--status-info)]`)}),(0,$.jsx)(de,{placeholder:S(`multirun.modelMultiSelect.variant.placeholder`),children:e=>e===`__default__`?S(`multirun.modelMultiSelect.variant.default`):e})]}),(0,$.jsxs)(se,{fitContent:!0,children:[(0,$.jsx)(ie,{value:`__default__`,className:`pr-2 [&>span:first-child]:hidden`,children:S(`multirun.modelMultiSelect.variant.default`)}),c.map(Ge)]})]})]},e.instanceId)})}),t[111]=fe,t[112]=z,t[113]=i,t[114]=a,t[115]=C,t[116]=n,t[117]=b,t[118]=S,t[119]=Ye):Ye=t[119];let Xe;t[120]!==Je||t[121]!==Ye?(Xe=(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 items-center`,children:[Je,Ye]}),t[120]=Je,t[121]=Ye,t[122]=Xe):Xe=t[122];let Ze;t[123]!==l||t[124]!==o||t[125]!==n.length||t[126]!==S?(Ze=o!==void 0&&n.length<o&&(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:l===void 0?S(`multirun.modelMultiSelect.validation.minOnly`,{min:o}):S(`multirun.modelMultiSelect.validation.minToMax`,{min:o,max:l})}),t[123]=l,t[124]=o,t[125]=n.length,t[126]=S,t[127]=Ze):Ze=t[127];let Qe;return t[128]!==Xe||t[129]!==Ze?(Qe=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[Xe,Ze]}),t[128]=Xe,t[129]=Ze,t[130]=Qe):Qe=t[130],Qe};function ze(e){return e.providers}function Be(e){return e.getModelMetadata}function Ve(e){return e.toggleFavoriteModel}function He(e){return e.isFavoriteModel}function Ue(e){return e.hiddenModels}function We(e){return e.providerOrder}function Ge(e){return(0,$.jsx)(ie,{value:e,className:`pr-2 [&>span:first-child]:hidden`,children:e},e)}function Ke(e){let t=(0,Ce.c)(30),{git:n}=V(),r=W(e),i=U(e),a=G(e),o=J(e),s=Y(Ze),c=Y(Xe),l,u;t[0]!==e||t[1]!==c||t[2]!==n||t[3]!==i||t[4]!==a?(l=()=>{!e||!n||i!==null||a||c(e,n,{silent:!0})},u=[e,n,c,i,a],t[0]=e,t[1]=c,t[2]=n,t[3]=i,t[4]=a,t[5]=l,t[6]=u):(l=t[5],u=t[6]),X.useEffect(l,u);let d;t[7]!==r?.all||t[8]!==e||t[9]!==s||t[10]!==n||t[11]!==i?(d=()=>{!e||!n||i===!0&&(r?.all||s(e,n))},t[7]=r?.all,t[8]=e,t[9]=s,t[10]=n,t[11]=i,t[12]=d):d=t[12];let f=r?.all,p;t[13]!==e||t[14]!==s||t[15]!==n||t[16]!==i||t[17]!==f?(p=[e,n,i,f,s],t[13]=e,t[14]=s,t[15]=n,t[16]=i,t[17]=f,t[18]=p):p=t[18],X.useEffect(d,p);let m=a||i===!0&&o,h;bb0:{if(!r?.all){let e;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[19]=e):e=t[19],h=e;break bb0}let e;t[20]===r.all?e=t[21]:(e=r.all.filter(Ye).sort(),t[20]=r.all,t[21]=e),h=e}let g=h,_;bb1:{if(!r?.all){let e;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[22]=e):e=t[22],_=e;break bb1}let e;t[23]===r.all?e=t[24]:(e=r.all.filter(Je).map(qe).sort(),t[23]=r.all,t[24]=e),_=e}let v=_,y;bb2:{if(!e){y=null;break bb2}if(i!==null){y=i;break bb2}if(m){y=null;break bb2}y=r?.all?!0:null}let b=y,x;return t[25]!==b||t[26]!==m||t[27]!==g||t[28]!==v?(x={localBranches:g,remoteBranches:v,isLoading:m,isGitRepository:b},t[25]=b,t[26]=m,t[27]=g,t[28]=v,t[29]=x):x=t[29],x}function qe(e){return e.replace(/^remotes\//,``)}function Je(e){return e.startsWith(`remotes/`)}function Ye(e){return!e.startsWith(`remotes/`)}function Xe(e){return e.fetchStatus}function Ze(e){return e.fetchBranches}var Qe=({directory:e,value:t,onChange:n,className:r,disabled:i,id:a})=>{let{t:o}=p(),{localBranches:s,remoteBranches:c,isLoading:l,isGitRepository:u}=Ke(e),d=X.useMemo(()=>[...s,...c.map(e=>`remotes/${e}`)],[s,c]);return X.useEffect(()=>{if(i||l||d.length===0||t&&d.includes(t))return;let r=t,a=!1;return(async()=>{try{let t=e?await M(e).catch(()=>null):null;if(a)return;let i=localStorage.getItem(H),{sourceBranch:o,shouldClearSavedSourceBranch:s}=q({branches:d,savedSourceBranch:i,rootBranch:t});if(s&&localStorage.removeItem(H),a||r&&d.includes(r))return;o&&n(o)}catch{}})(),()=>{a=!0}},[d,e,i,l,n,t]),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(ue,{value:t,onValueChange:n,disabled:i||!u||l,children:[(0,$.jsx)(ae,{id:a,size:`lg`,className:r??`w-fit typography-meta text-foreground`,children:(0,$.jsx)(de,{placeholder:o(l?`multiRun.branchSelector.status.loadingBranches`:`multiRun.branchSelector.placeholder.selectSourceBranch`)})}),(0,$.jsx)(se,{className:`max-h-[280px] max-w-[320px]`,children:l?(0,$.jsx)(`div`,{className:`px-2 py-4 text-center typography-meta text-muted-foreground`,children:o(`multiRun.branchSelector.status.loadingBranches`)}):s.length===0&&c.length===0?(0,$.jsx)(`div`,{className:`px-2 py-4 text-center typography-meta text-muted-foreground`,children:o(`multiRun.branchSelector.status.noBranchesFound`)}):(0,$.jsxs)($.Fragment,{children:[s.length>0&&(0,$.jsxs)(oe,{children:[(0,$.jsx)(F,{className:`font-semibold text-foreground`,children:o(`multiRun.branchSelector.groups.localBranches`)}),s.map(e=>(0,$.jsx)(ie,{value:e,className:`whitespace-normal break-all`,children:e},e))]}),s.length>0&&c.length>0&&(0,$.jsx)(I,{}),c.length>0&&(0,$.jsxs)(oe,{children:[(0,$.jsx)(F,{className:`font-semibold text-foreground`,children:o(`multiRun.branchSelector.groups.remoteBranches`)}),c.map(e=>(0,$.jsx)(ie,{value:`remotes/${e}`,className:`whitespace-normal break-all`,children:e},`remotes/${e}`))]})]})})]}),u===!1&&(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/70 mt-2`,children:o(`multiRun.branchSelector.status.notInGitRepository`)})]})},$e=e=>{let t=(0,Ce.c)(36),{value:n,onChange:r,className:i,disabled:a,id:o,portalToBody:s}=e,{t:c}=p(),l=ee(et),u=ee(tt),d=ee(nt),f;t[0]===l?f=t[1]:(f=l(),t[0]=l,t[1]=f);let m=f,g;t[2]===m?g=t[3]:(g=m.filter(rt),t[2]=m,t[3]=g);let _=g,v,y;t[4]!==m.length||t[5]!==u?(v=()=>{m.length===0&&u()},y=[m.length,u],t[4]=m.length,t[5]=u,t[6]=v,t[7]=y):(v=t[6],y=t[7]),X.useEffect(v,y);let b,x;t[8]!==d||t[9]!==a||t[10]!==r||t[11]!==_||t[12]!==n?(b=()=>{if(a)return;let e=n.trim();if(e.length>0&&_.some(t=>t.name===e))return;let t=typeof d==`string`&&d.trim().length>0?d.trim():null;if(t&&_.some(e=>e.name===t)){r(t);return}let i=_[0]?.name;i&&r(i)},x=[d,a,r,_,n],t[8]=d,t[9]=a,t[10]=r,t[11]=_,t[12]=n,t[13]=b,t[14]=x):(b=t[13],x=t[14]),X.useEffect(b,x);let S=n.trim().length>0?n:void 0,C;t[15]===i?C=t[16]:(C=h(`max-w-full typography-meta text-foreground !border-border/80 !bg-[var(--surface-subtle)] hover:!bg-[var(--interactive-hover)]/70 data-[popup-open]:!bg-[var(--interactive-active)]/70`,i),t[15]=i,t[16]=C);let w;t[17]===c?w=t[18]:(w=c(`multirun.agentSelector.placeholder`),t[17]=c,t[18]=w);let T;t[19]===w?T=t[20]:(T=(0,$.jsx)(de,{placeholder:w}),t[19]=w,t[20]=T);let E;t[21]!==o||t[22]!==C||t[23]!==T?(E=(0,$.jsx)(ae,{id:o,size:`lg`,className:C,children:T}),t[21]=o,t[22]=C,t[23]=T,t[24]=E):E=t[24];let D;t[25]===_?D=t[26]:(D=_.length>0&&(0,$.jsx)(oe,{children:_.map(it)}),t[25]=_,t[26]=D);let O;t[27]!==s||t[28]!==D?(O=(0,$.jsx)(se,{fitContent:!0,portalToBody:s,children:D}),t[27]=s,t[28]=D,t[29]=O):O=t[29];let k;return t[30]!==a||t[31]!==r||t[32]!==S||t[33]!==E||t[34]!==O?(k=(0,$.jsxs)(ue,{value:S,onValueChange:r,disabled:a,children:[E,O]}),t[30]=a,t[31]=r,t[32]=S,t[33]=E,t[34]=O,t[35]=k):k=t[35],k};function et(e){return e.getVisibleAgents}function tt(e){return e.loadAgents}function nt(e){return e.currentAgentName}function rt(e){return C(e.mode)}function it(e){return(0,$.jsx)(ie,{value:e.name,className:`w-auto whitespace-nowrap`,children:e.name},e.name)}var at=10485760,ot=5,st=e=>{let t=(0,Ce.c)(3),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,tabIndex:-1,className:`inline-flex items-center justify-center text-muted-foreground/50 hover:text-muted-foreground transition-colors`,children:(0,$.jsx)(k,{name:`information`,className:`h-3.5 w-3.5`})})}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,$.jsxs)(B,{children:[r,(0,$.jsx)(z,{side:`top`,className:`max-w-[240px]`,children:n})]}),t[1]=n,t[2]=i),i},ct=e=>{let t=(0,Ce.c)(9),{htmlFor:n,required:r,children:i,info:a}=e,o;t[0]===r?o=t[1]:(o=r&&(0,$.jsx)(`span`,{className:`text-destructive ml-0.5`,children:`*`}),t[0]=r,t[1]=o);let s;t[2]!==i||t[3]!==n||t[4]!==o?(s=(0,$.jsxs)(`label`,{htmlFor:n,className:`typography-meta font-medium text-foreground`,children:[i,o]}),t[2]=i,t[3]=n,t[4]=o,t[5]=s):s=t[5];let c=a&&a,l;return t[6]!==s||t[7]!==c?(l=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8],l},lt=e=>{let t=m(e.path),n=e.icon?N[e.icon]:null,r=e.color?P[e.color]:void 0,i=(0,$.jsx)(k,{name:n??`folder`,className:`h-3.5 w-3.5`,style:r?{color:r}:void 0});return(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`flex h-4 w-4 shrink-0 items-center justify-center overflow-hidden text-muted-foreground`,children:e.iconImage?(0,$.jsx)(j,{project:e,className:`size-full object-contain`,fallback:i}):i}),(0,$.jsx)(`span`,{className:`truncate`,children:t})]})},ut=({initialPrompt:e,onCreated:n,onCancel:r,isWindowed:i=!1})=>{let{t:a}=p(),[o,c]=X.useState(``),[l,u]=X.useState(()=>[{id:Ie(),prompt:``,models:[]}]),[d,m]=X.useState(``),[y,x]=X.useState([]),[ee,C]=X.useState(!1),[T,E]=X.useState([]),[D,O]=X.useState(!1),[te,ne]=X.useState(!1),[re,A]=X.useState(!0),j=X.useRef(null),M=s(e=>e.currentDirectory??null),oe=X.useMemo(()=>{if(typeof window>`u`)return null;let e=window.__VSCODE_CONFIG__?.workspaceFolder;return typeof e==`string`&&e.trim().length>0?e.trim():null},[]),N=S(e=>e.activeProjectId),le=S(e=>e.setActiveProjectIdOnly),P=S(e=>e.projects),[F,I]=X.useState(()=>N??null);X.useEffect(()=>{if(N){I(N);return}!F&&P.length>0&&I(P[0].id)},[N,P,F]);let V=X.useMemo(()=>F?P.find(e=>e.id===F)??null:null,[P,F]),me=V?.path??M,he=f(e=>{I(e),e!==N&&le(e)}),ge=X.useMemo(()=>{if(V?.path)return{id:V.id,path:V.path};let e=M??oe;return e?{id:`path:${e}`,path:e}:null},[V,M,oe]),[H]=X.useState(()=>typeof window<`u`&&t()),U=X.useMemo(()=>typeof navigator>`u`?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||``),[]),_e=fe(),W=X.useMemo(()=>{if(typeof window>`u`)return null;let e=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return e;if(typeof navigator>`u`)return null;let t=(navigator.userAgent||``).match(/Mac OS X (\d+)[._](\d+)/);if(!t)return null;let n=Number.parseInt(t[1],10),r=Number.parseInt(t[2],10);return Number.isNaN(n)?null:n===10?r:n},[]),G=X.useMemo(()=>H&&U||_e?`pl-[5.5rem]`:`pl-3`,[H,U,_e]),K=X.useMemo(()=>!H||!U||W===null?``:W>=26?`h-12`:W<=15?`h-14`:``,[H,U,W]),q=f(async e=>{e.target.closest(`button, a, input, select, textarea`)||e.button===0&&H&&await _()}),J=f(e=>{r&&e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),r())}),ve=!!r;X.useEffect(()=>{if(ve)return window.addEventListener(`keydown`,J,!0),()=>window.removeEventListener(`keydown`,J,!0)},[ve]);let[ye,Y]=X.useState(``),{isLoading:Ce,isGitRepository:Z}=Ke(me),Q=X.useRef(!1),we=Z===!0,Te=we&&re;X.useEffect(()=>{if(Z===!1){Q.current=!0,A(!1);return}Z===!0&&Q.current&&(Q.current=!1,A(!0))},[Z]);let Ee=Pe(e=>e.createMultiRun),De=Pe(e=>e.error),Oe=Pe(e=>e.clearError);X.useEffect(()=>{typeof e==`string`&&e.trim().length>0&&u(t=>{let n=[...t];return n.length>0&&!n[0].prompt.trim()&&(n[0]={...n[0],prompt:e}),n})},[e]),X.useEffect(()=>{if(!ge)return;let e=!1;return ne(!0),(async()=>{try{let t=await b(ge);e||E(t)}catch{}finally{e||ne(!1)}})(),()=>{e=!0}},[ge]);let ke=f((e,t)=>{u(n=>n.map(n=>n.id===e?{...n,...t}:n))}),Ae=f(e=>{u(t=>t.filter(t=>t.id!==e))}),je=f(()=>{u(e=>[...e,{id:Ie(),prompt:``,models:[]}])}),Me=async e=>{let t=e.target.files;if(!t)return;let n=0;for(let e=0;e<t.length;e++){let r=t[e];if(r.size>at){v.error(a(`multirun.launcher.toast.fileTooLarge`,{fileName:r.name}));continue}try{let e=await new Promise((e,t)=>{let n=new FileReader;n.onload=()=>e(n.result),n.onerror=t,n.readAsDataURL(r)});x(t=>[...t,{id:Ie(),filename:r.name,mimeType:r.type||`application/octet-stream`,size:r.size,dataUrl:e}]),n++}catch(e){console.error(`File attach failed`,e),v.error(a(`multirun.launcher.toast.attachFailed`,{fileName:r.name}))}}n>0&&v.success(a(n===1?`multirun.launcher.toast.attachedSingle`:`multirun.launcher.toast.attachedPlural`,{count:n})),j.current&&(j.current.value=``)},Ne=e=>{x(t=>t.filter(t=>t.id!==e))},Fe=X.useMemo(()=>l.reduce((e,t)=>e+t.models.length,0),[l]),Le=async e=>{e.preventDefault();let t=l.filter(e=>e.prompt.trim()&&e.models.length>=1);if(t.length!==0&&!(Fe<1)){C(!0),Oe();try{F&&F!==N&&le(F);let e=y.map(e=>({mime:e.mimeType,filename:e.filename,url:e.dataUrl})),r=T.filter(e=>e.trim().length>0),i=t.map(e=>({prompt:e.prompt.trim(),models:e.models.map(e=>({providerID:e.providerID,modelID:e.modelID,displayName:e.displayName,variant:e.variant}))})),a={name:o.trim(),groups:i,agent:d||void 0,worktreeBaseBranch:Te?ye:void 0,isolateRuns:Te,files:e.length>0?e:void 0,setupCommands:r.length>0?r:void 0},s=await Ee(a);s&&(s.firstSessionId&&w.getState().setCurrentSession(s.firstSessionId),n?.())}finally{C(!1)}}},Re=!!(o.trim()&&l.some(e=>e.prompt.trim()&&e.models.length>=1)&&Fe>=1&&me&&!Ce&&(Z===!1||!Te||ye)),ze=T.filter(e=>e.trim()).length;return(0,$.jsxs)(`form`,{onSubmit:Le,className:`flex flex-col h-full bg-background`,children:[i?null:(0,$.jsxs)(`header`,{onMouseDown:q,className:h(`relative flex h-12 shrink-0 items-center justify-center border-b app-region-drag select-none`,G,K),style:{borderColor:`var(--interactive-border)`},children:[(0,$.jsx)(`h1`,{className:`typography-ui-label font-medium`,children:a(`multirun.launcher.title`)}),r&&(0,$.jsx)(`div`,{className:`absolute right-0 flex items-center pr-3`,children:(0,$.jsxs)(B,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:r,"aria-label":a(`multirun.launcher.actions.closeEsc`),className:`inline-flex h-9 w-9 items-center justify-center p-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary app-region-no-drag`,children:(0,$.jsx)(k,{name:`close`,className:`h-5 w-5`})})}),(0,$.jsx)(z,{children:(0,$.jsx)(`p`,{children:a(`multirun.launcher.actions.closeEsc`)})})]})})]}),(0,$.jsx)(pe,{className:`flex-1 min-h-0 overflow-auto`,size:64,hideTopShadow:!0,children:(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-2xl px-4 sm:px-6 py-5`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(ct,{htmlFor:`multirun-project`,required:!0,children:a(`multirun.launcher.project.label`)}),P.length>0?(0,$.jsxs)(ue,{value:F??void 0,onValueChange:he,children:[(0,$.jsx)(ae,{id:`multirun-project`,size:`lg`,className:`w-fit max-w-full`,children:V?(0,$.jsx)(de,{children:lt(V)}):(0,$.jsx)(de,{placeholder:a(`multirun.launcher.project.placeholder`)})}),(0,$.jsx)(se,{fitContent:!0,children:P.map(e=>(0,$.jsx)(ie,{value:e.id,className:`max-w-[24rem]`,children:lt(e)},e.id))})]}):(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground py-2`,children:a(`multirun.launcher.project.empty`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(ct,{htmlFor:`group-name`,required:!0,info:(0,$.jsx)(st,{children:a(`multirun.launcher.groupName.info`)}),children:a(`multirun.launcher.groupName.label`)}),(0,$.jsx)(L,{id:`group-name`,value:o,onChange:e=>c(e.target.value),placeholder:a(`multirun.launcher.groupName.placeholder`),className:`typography-meta w-full`,required:!0})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(ct,{htmlFor:`multirun-worktree-base-branch`,info:(0,$.jsx)(st,{children:a(`multirun.launcher.baseBranch.info`)}),children:a(`multirun.launcher.baseBranch.label`)}),(0,$.jsx)(Qe,{directory:me,value:ye,onChange:Y,disabled:!Te,id:`multirun-worktree-base-branch`}),(0,$.jsxs)(`label`,{className:`mt-1.5 flex w-fit items-center gap-1.5 typography-micro text-muted-foreground`,children:[(0,$.jsx)(ce,{checked:re,onChange:A,disabled:!we,ariaLabel:a(`multirun.launcher.isolateRuns.label`)}),(0,$.jsx)(`span`,{children:a(`multirun.launcher.isolateRuns.label`)})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(ct,{htmlFor:`multirun-agent`,info:(0,$.jsx)(st,{children:a(`multirun.launcher.agent.info`)}),children:a(`multirun.launcher.agent.label`)}),(0,$.jsx)($e,{value:d,onChange:m,id:`multirun-agent`})]})]}),(0,$.jsxs)(Se,{open:D,onOpenChange:O,children:[(0,$.jsxs)(xe,{className:`w-full flex items-center gap-2 py-1.5 px-2 -mx-2 rounded-lg hover:bg-[var(--interactive-hover)]/50 transition-colors group`,children:[(0,$.jsx)(k,{name:`terminal`,className:`h-3.5 w-3.5 text-muted-foreground/70`}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-muted-foreground group-hover:text-foreground transition-colors`,children:a(`multirun.launcher.setupCommands.label`)}),ze>0&&(0,$.jsx)(`span`,{className:`inline-flex items-center justify-center h-4 min-w-4 px-1 rounded-full typography-micro font-medium`,style:{backgroundColor:`var(--primary-base)`,color:`var(--primary-foreground)`,fontSize:`0.625rem`,lineHeight:1},children:ze}),(0,$.jsx)(k,{name:`arrow-down-s`,className:h(`h-3.5 w-3.5 text-muted-foreground/50 transition-transform duration-200 ml-auto`,D&&`rotate-180`)})]}),(0,$.jsx)(be,{children:(0,$.jsx)(`div`,{className:`pt-2 space-y-1.5`,children:te?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground/70 px-2`,children:a(`multirun.launcher.setupCommands.loading`)}):(0,$.jsxs)($.Fragment,{children:[T.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,$.jsx)(L,{value:e,onChange:e=>{let n=[...T];n[t]=e.target.value,E(n)},placeholder:a(`multirun.launcher.setupCommands.commandPlaceholder`),className:`h-8 flex-1 font-mono text-xs`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>E(T.filter((e,n)=>n!==t)),className:`flex-shrink-0 flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":a(`multirun.launcher.setupCommands.removeCommandAria`),children:(0,$.jsx)(k,{name:`close`,className:`h-3.5 w-3.5`})})]},`${e}-${t}`)),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>E([...T,``]),className:`flex items-center gap-1 typography-meta text-muted-foreground hover:text-foreground transition-colors px-1`,children:[(0,$.jsx)(k,{name:`add`,className:`h-3 w-3`}),a(`multirun.launcher.setupCommands.addCommand`)]})]})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(ct,{htmlFor:`prompt`,required:!0,children:a(`multirun.launcher.attachments.label`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,$.jsx)(`input`,{ref:j,type:`file`,multiple:!0,className:`hidden`,onChange:Me,accept:`*/*`}),(0,$.jsxs)(B,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>j.current?.click(),className:`inline-flex items-center gap-1 h-6 px-2 rounded-md typography-micro text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors`,children:[(0,$.jsx)(k,{name:`attachment-2`,className:`h-3 w-3`}),a(`multirun.launcher.attachments.attach`)]})}),(0,$.jsx)(z,{children:a(`multirun.launcher.attachments.tooltip`)})]}),y.map(e=>(0,$.jsxs)(`div`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md typography-micro border`,style:{backgroundColor:`var(--surface-elevated)`,borderColor:`var(--interactive-border)`},children:[e.mimeType.startsWith(`image/`)?(0,$.jsx)(k,{name:`file-image`,className:`h-3 w-3 text-muted-foreground`}):(0,$.jsx)(k,{name:`file`,className:`h-3 w-3 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`truncate max-w-[100px]`,title:e.filename,children:e.filename}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>Ne(e.id),className:`text-muted-foreground hover:text-destructive`,children:(0,$.jsx)(k,{name:`close`,className:`h-3 w-3`})})]},e.id))]})]}),l.map((e,t)=>(0,$.jsx)(dt,{group:e,groupIndex:t,canRemove:l.length>1,onUpdate:ke,onRemove:Ae},e.id)),(0,$.jsxs)(`button`,{type:`button`,onClick:je,className:`flex items-center gap-1.5 py-2 px-3 -mx-3 rounded-lg typography-meta font-medium text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors`,children:[(0,$.jsx)(k,{name:`add`,className:`h-3.5 w-3.5`}),a(`multirun.launcher.groups.addGroup`)]}),De&&(0,$.jsx)(`div`,{className:`px-3 py-2 rounded-lg typography-meta`,style:{backgroundColor:`var(--status-error-background)`,color:`var(--status-error)`,borderWidth:1,borderColor:`var(--status-error-border)`},children:De})]})})}),(0,$.jsx)(`div`,{className:`shrink-0 px-4 sm:px-6 py-3`,children:(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl flex items-center justify-end gap-2`,children:[!Te&&Z!==null?(0,$.jsxs)(`div`,{className:`mr-auto flex min-w-0 items-center gap-1.5 typography-micro text-muted-foreground`,children:[(0,$.jsx)(k,{name:`information`,className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:a(`multirun.launcher.project.gitRequired`)})]}):null,(0,$.jsx)(g,{type:`button`,variant:`ghost`,size:`sm`,onClick:r,children:a(`multirun.launcher.actions.cancel`)}),(0,$.jsx)(g,{type:`submit`,size:`sm`,disabled:!Re||ee,children:ee?a(`multirun.launcher.actions.creating`):(0,$.jsx)($.Fragment,{children:a(`multirun.launcher.actions.startWithRunCount`,{count:Fe})})})]})})]})},dt=e=>{let t=(0,Ce.c)(104),{group:n,groupIndex:r,canRemove:i,onUpdate:a,onRemove:o}=e,{t:s}=p(),[c,l]=X.useState(!1),[u,d]=X.useState(``),[m,h]=X.useState(!1),[g,_]=X.useState(``),[v,y]=X.useState(!1),[b,x]=X.useState(``),S=X.useRef(null),ee=X.useRef(null),C=X.useRef(null),w=X.useRef(null),T;t[0]!==n.id||t[1]!==n.models||t[2]!==a?(T=e=>{n.models.length>=ot||a(n.id,{models:[...n.models,e]})},t[0]=n.id,t[1]=n.models,t[2]=a,t[3]=T):T=t[3];let E=f(T),D;t[4]!==n.id||t[5]!==n.models||t[6]!==a?(D=e=>{a(n.id,{models:n.models.filter((t,n)=>n!==e)})},t[4]=n.id,t[5]=n.models,t[6]=a,t[7]=D):D=t[7];let O=f(D),te;t[8]!==n.id||t[9]!==n.models||t[10]!==a?(te=(e,t)=>{a(n.id,{models:n.models.map((n,r)=>r===e?t:n)})},t[8]=n.id,t[9]=n.models,t[10]=a,t[11]=te):te=t[11];let ne=f(te),re;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(re=(e,t)=>{if(e.startsWith(`/`)){let n=e.indexOf(` `),r=e.indexOf(`
2
- `),i=Math.min(n===-1?e.length:n,r===-1?e.length:r);if(t<=i&&n===-1){_(e.substring(1,i)),h(!0),l(!1),y(!1);return}}h(!1);let n=e.substring(0,t),r=n.lastIndexOf(`#`);if(r!==-1){let e=r>0?n[r-1]:null,t=n.substring(r+1);if((!e||/\s/.test(e))&&!t.includes(` `)&&!t.includes(`
3
- `)){x(t),y(!0),l(!1);return}}y(!1);let i=n.lastIndexOf(`@`);if(i!==-1){let e=i>0?n[i-1]:null,t=n.substring(i+1);(!e||/\s/.test(e))&&!t.includes(` `)&&!t.includes(`
4
- `)?(d(t),l(!0)):l(!1);return}l(!1)},t[12]=re):re=t[12];let A=f(re),ie;t[13]!==n.id||t[14]!==a?(ie=e=>{a(n.id,{prompt:e})},t[13]=n.id,t[14]=a,t[15]=ie):ie=t[15];let j=f(ie),ae;t[16]!==n.prompt||t[17]!==j||t[18]!==A?(ae=e=>{let t=n.prompt,r=S.current?.selectionStart??t.length,i=t.substring(0,r).lastIndexOf(`@`),a=e.relativePath&&e.relativePath.trim().length>0?e.relativePath.trim():e.path||e.name,o=ve(t,i===-1?r:i,r,`@${a}`);j(o.text),l(!1),d(``),requestAnimationFrame(()=>{let e=S.current;e&&(e.selectionStart=o.caret,e.selectionEnd=o.caret,e.focus()),A(o.text,o.caret)})},t[16]=n.prompt,t[17]=j,t[18]=A,t[19]=ae):ae=t[19];let M=f(ae),oe;t[20]!==n.prompt||t[21]!==j||t[22]!==A?(oe=e=>{let t=n.prompt,r=S.current?.selectionStart??t.length,i=t.substring(0,r).lastIndexOf(`@`),a=ve(t,i===-1?r:i,r,`@${e}`);j(a.text),l(!1),d(``),requestAnimationFrame(()=>{let e=S.current;e&&(e.selectionStart=a.caret,e.selectionEnd=a.caret,e.focus()),A(a.text,a.caret)})},t[20]=n.prompt,t[21]=j,t[22]=A,t[23]=oe):oe=t[23];let se=f(oe),N;t[24]!==j||t[25]!==A?(N=e=>{let t=`/${e.name} `;j(t),h(!1),_(``),y(!1),requestAnimationFrame(()=>{let e=S.current;e&&(e.focus(),e.selectionStart=e.value.length,e.selectionEnd=e.value.length),A(t,t.length)})},t[24]=j,t[25]=A,t[26]=N):N=t[26];let ce=f(N),le;t[27]!==n.prompt||t[28]!==j||t[29]!==A?(le=(e,t)=>{let r=n.prompt,i=S.current?.selectionStart??r.length,a=r.substring(0,i).lastIndexOf(`#`),o=a===-1?i:a,s=`${r.substring(0,o)}#${t} ${r.substring(i)}`,c=o+t.length+2;j(s),y(!1),x(``),requestAnimationFrame(()=>{let e=S.current;e&&(e.selectionStart=c,e.selectionEnd=c,e.focus()),A(s,c)})},t[27]=n.prompt,t[28]=j,t[29]=A,t[30]=le):le=t[30];let ue=f(le),P;t[31]!==m||t[32]!==c||t[33]!==v?(P=e=>{if(m&&C.current&&(e.key===`Enter`||e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`Escape`||e.key===`Tab`)){e.preventDefault(),C.current.handleKeyDown(e.key);return}c&&ee.current&&(e.key===`Enter`||e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`Escape`||e.key===`Tab`)&&(e.preventDefault(),ee.current.handleKeyDown(e.key)),v&&w.current&&(e.key===`Enter`||e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`Escape`||e.key===`Tab`)&&(e.preventDefault(),w.current.handleKeyDown(e.key))},t[31]=m,t[32]=c,t[33]=v,t[34]=P):P=t[34];let F=f(P),de=r+1,I;t[35]!==s||t[36]!==de?(I=s(`multirun.launcher.groups.groupLabel`,{index:de}),t[35]=s,t[36]=de,t[37]=I):I=t[37];let L;t[38]===I?L=t[39]:(L=(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:I}),t[38]=I,t[39]=L);let R;t[40]!==i||t[41]!==n.id||t[42]!==o||t[43]!==s?(R=i&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>o(n.id),className:`inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10`,"aria-label":s(`multirun.launcher.groups.removeGroup`),children:(0,$.jsx)(k,{name:`close`,className:`h-3.5 w-3.5`})}),t[40]=i,t[41]=n.id,t[42]=o,t[43]=s,t[44]=R):R=t[44];let z;t[45]!==L||t[46]!==R?(z=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[L,R]}),t[45]=L,t[46]=R,t[47]=z):z=t[47];let B;t[48]===s?B=t[49]:(B=s(`multirun.launcher.groups.prompt.label`),t[48]=s,t[49]=B);let fe;t[50]===B?fe=t[51]:(fe=(0,$.jsx)(ct,{required:!0,children:B}),t[50]=B,t[51]=fe);let V=n.prompt,pe;t[52]!==j||t[53]!==A?(pe=e=>{let t=e.target.value;j(t);let n=e.target.selectionStart??t.length;A(t,n)},t[52]=j,t[53]=A,t[54]=pe):pe=t[54];let H;t[55]===s?H=t[56]:(H=s(`multirun.launcher.groups.prompt.placeholder`),t[55]=s,t[56]=H);let U;t[57]!==n.prompt||t[58]!==F||t[59]!==pe||t[60]!==H?(U=(0,$.jsx)(me,{ref:S,value:V,onChange:pe,onKeyDown:F,placeholder:H,className:`typography-meta min-h-[80px] max-h-[200px] resize-none overflow-y-auto field-sizing-content`,required:!0}),t[57]=n.prompt,t[58]=F,t[59]=pe,t[60]=H,t[61]=U):U=t[61];let _e;t[62]!==g||t[63]!==ce||t[64]!==m?(_e=m?(0,$.jsx)(ge,{ref:C,searchQuery:g,onCommandSelect:ce,onClose:()=>h(!1),style:{left:0,top:`auto`,bottom:`calc(100% + 6px)`,marginBottom:0,maxWidth:`100%`}}):null,t[62]=g,t[63]=ce,t[64]=m,t[65]=_e):_e=t[65];let W;t[66]!==se||t[67]!==M||t[68]!==u||t[69]!==c?(W=c?(0,$.jsx)(he,{ref:ee,searchQuery:u,onFileSelect:M,onAgentSelect:se,onSkillSelect:e=>se(e.name),onClose:()=>l(!1),style:{left:0,top:`auto`,bottom:`calc(100% + 6px)`,marginBottom:0,maxWidth:`100%`}}):null,t[66]=se,t[67]=M,t[68]=u,t[69]=c,t[70]=W):W=t[70];let G;t[71]!==ue||t[72]!==v||t[73]!==b?(G=v?(0,$.jsx)(ye,{ref:w,searchQuery:b,onSnippetSelect:ue,onClose:()=>y(!1),style:{left:0,top:`auto`,bottom:`calc(100% + 6px)`,marginBottom:0,maxWidth:`100%`}}):null,t[71]=ue,t[72]=v,t[73]=b,t[74]=G):G=t[74];let K;t[75]!==U||t[76]!==_e||t[77]!==W||t[78]!==G?(K=(0,$.jsxs)(`div`,{className:`relative`,children:[U,_e,W,G]}),t[75]=U,t[76]=_e,t[77]=W,t[78]=G,t[79]=K):K=t[79];let q;t[80]!==fe||t[81]!==K?(q=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[fe,K]}),t[80]=fe,t[81]=K,t[82]=q):q=t[82];let J;t[83]===s?J=t[84]:(J=s(`multirun.launcher.models.info`,{max:ot}),t[83]=s,t[84]=J);let Y;t[85]===J?Y=t[86]:(Y=(0,$.jsx)(st,{children:J}),t[85]=J,t[86]=Y);let be;t[87]===s?be=t[88]:(be=s(`multirun.launcher.models.label`),t[87]=s,t[88]=be);let xe;t[89]!==Y||t[90]!==be?(xe=(0,$.jsx)(ct,{required:!0,info:Y,children:be}),t[89]=Y,t[90]=be,t[91]=xe):xe=t[91];let Se;t[92]!==n.models||t[93]!==E||t[94]!==O||t[95]!==ne?(Se=(0,$.jsx)(Re,{selectedModels:n.models,onAdd:E,onRemove:O,onUpdate:ne,minModels:1,maxModels:ot}),t[92]=n.models,t[93]=E,t[94]=O,t[95]=ne,t[96]=Se):Se=t[96];let Z;t[97]!==xe||t[98]!==Se?(Z=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[xe,Se]}),t[97]=xe,t[98]=Se,t[99]=Z):Z=t[99];let Q;return t[100]!==z||t[101]!==q||t[102]!==Z?(Q=(0,$.jsxs)(`div`,{className:`rounded-lg border border-border p-3 space-y-3`,children:[z,q,Z]}),t[100]=z,t[101]=q,t[102]=Z,t[103]=Q):Q=t[103],Q};export{De as a,Ie as i,$e as n,Te as o,Re as r,ut as t};