@openchambery/web 1.19.20 → 1.19.21-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AssistantView-BjvfkSRS.js → AssistantView-BtGYjSW5.js} +3 -3
- package/dist/assets/{DiagramView-C_JfbxNl.js → DiagramView-Bh06xinl.js} +1 -1
- package/dist/assets/MarkdownRenderer-AwDKOCvD.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-B1iUwzOz.js → MarkdownRendererImpl-f2agCc4q.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-BPtMj3-X.js → MarkstreamRendererImpl-ChD4WD2v.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-s_vvUD_F.js → MobileDetailNavigation-B6fGRYsg.js} +1 -1
- package/dist/assets/{MobileShareBridge-CKClHsWN.js → MobileShareBridge-D7SG0ueZ.js} +1 -1
- package/dist/assets/MobileSurface-BY7eErHN.js +2 -0
- package/dist/assets/{MultiRunWindow-DiA24bnN.js → MultiRunWindow-CjCw1X4n.js} +1 -1
- package/dist/assets/{SettingsView-l0J7pfYo.js → SettingsView-lcRi35Y3.js} +9 -9
- package/dist/assets/{SettingsWindow-XlzRSS7E.js → SettingsWindow-C2DgbXJ3.js} +1 -1
- package/dist/assets/{TerminalView-DdIaaLba.js → TerminalView-lubDPKMs.js} +1 -1
- package/dist/assets/{ToolOutputDialog-BbwuLdXU.js → ToolOutputDialog-CzgW3-Cb.js} +1 -1
- package/dist/assets/{appThemeRegistry-ChzfD7mc.js → appThemeRegistry-BKc-qXbQ.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-DyjmxUEN.js → fileMentionTouchSelection-BTkP7aYI.js} +1 -1
- package/dist/assets/{gitApi-CHpibtno.js → gitApi-CcIuekQ3.js} +1 -1
- package/dist/assets/insertionBoundaries-BocNNP9Q.js +1 -0
- package/dist/assets/{main-DCDcdV5o.js → main-CFLmpNC5.js} +10 -10
- package/dist/assets/{main-BoRXxmB3.js → main-Ckj_IpUy.js} +2 -2
- package/dist/assets/{miniChat-12fxk5KR.js → miniChat-Dq1CTKNs.js} +2 -2
- package/dist/assets/{mobile-CkZem9Ad.js → mobile-DlJ0Yr7h.js} +2 -2
- package/dist/assets/multirun-BGUKIJys.js +4 -0
- package/dist/assets/projectMeta-Bft2t6GF.js +3 -0
- package/dist/assets/{renderElectronMiniChatApp-COFc0ZDJ.js → renderElectronMiniChatApp-CTbXbB0Y.js} +2 -2
- package/dist/assets/{renderMobileApp-BKzx7JL3.js → renderMobileApp-DLewUqoE.js} +6 -6
- package/dist/assets/{runtimeConfig-DYWtBrkW.js → runtimeConfig-PpnZiwcW.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-BSWg99jc.js → runtimeEndpointReset-BGjzNuQl.js} +6 -6
- package/dist/assets/sessionChangeSummary-DiqwX3vZ.js +2 -0
- package/dist/assets/{sessionLookup-DP2X1qRR.js → sessionLookup-CbbzalcH.js} +1 -1
- package/dist/assets/src-rS3zCcsC.css +2 -0
- package/dist/assets/textarea-DpK2Z0Gp.js +1 -0
- package/dist/assets/{useAppFontEffects-DWLxpWlS.js → useAppFontEffects-BJBcy-84.js} +43 -43
- package/dist/assets/useDesktopWindowControlsLayout-3Bm0rXCQ.js +1 -0
- package/dist/assets/{useEffectiveDirectory-CbV9_r1s.js → useEffectiveDirectory-CzHynoi_.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-DrB_awgk.js → useMobileNavigationStore-BIyCYi_z.js} +1 -1
- package/dist/assets/{useSessionAutoCleanup-Dnors7hB.js → useSessionAutoCleanup-DzV9N6G-.js} +1 -1
- package/dist/assets/{useWorkerHighlightedLines-DQqqrOBU.js → useWorkerHighlightedLines-Bi9ASKr_.js} +1 -1
- package/dist/index.html +3 -3
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +1 -1
- package/dist/assets/MarkdownRenderer-Cg82L3fN.js +0 -2
- package/dist/assets/MobileSurface-DHpXHbJp.js +0 -2
- package/dist/assets/insertionBoundaries-Yd1Lorjw.js +0 -1
- package/dist/assets/multirun-8fkF0Ji_.js +0 -4
- package/dist/assets/projectMeta--y6tyjrv.js +0 -3
- package/dist/assets/sessionChangeSummary-BwupJF-Q.js +0 -2
- package/dist/assets/src-DZ60kHBP.css +0 -2
- package/dist/assets/textarea-BnD799LW.js +0 -1
- package/dist/assets/useDesktopWindowControlsLayout-BGPR_rq6.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{c as t,i as n}from"./runtime-switch-LvWDU-SL.js";import{Cn as r,D as i,d as a,k as o,tn as s,u as c}from"./persistence-Ce3AnpEr.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-0w_Q9_ji.js";import{b as v,t as ee,y}from"./useUIStore-Bxv3f23A.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-BnW6GxJt.js";import{f as te,r as C,u as ne}from"./button-DtzFDvij.js";import{An as re,ao as ie,bo as ae,c as w,ct as oe,dt as se,g as T,hr as ce,lt as E,ot as D,pn as O,ra as le,rn as k,st as ue,xo as A,y as j}from"./useMobileNavigationStore-DrB_awgk.js";import{n as M}from"./Icon-i5GiQRLq.js";import{g as N,v as P}from"./gitApi-CHpibtno.js";import{f as F,o as I,q as de}from"./projectMeta--y6tyjrv.js";import{n as fe,r as pe,t as me}from"./fileMentionTouchSelection-DyjmxUEN.js";import{n as he}from"./textarea-BnD799LW.js";var L=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`goal`:return`target`;case`review`:return`search-eye`;case`test`:case`build`:case`run`:return`terminal-box`;default:return e.isBuiltIn?`flashlight`:`command`}},R=()=>`book-open`,z=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`}},B=()=>`ai-agent`,ge=()=>`chat-thread`,_e=(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:L(e)}}),ve=e=>e.map(e=>({id:`${e.name}-${e.scope}`,title:e.name,subtitle:e.description,badge:e.scope,iconName:R()})),ye=({agents:e,sessions:t,recentFiles:n,pathHits:r,untitledSession:i,sessionBadge:a})=>{let o=[];for(let t of e)o.push({id:`agent:${t.name}`,title:`@${t.name}`,subtitle:t.description,iconName:B()});for(let e of t)o.push({id:`session:${e.id}`,title:e.title||i,badge:a,iconName:ge()});for(let e of n)o.push({id:`recent:${e.path}`,title:e.relativePath||e.name,iconName:z(e)});for(let e of r)o.push({id:`file:${e.path}`,title:e.relativePath||e.name,iconName:z(e)});return o},be=(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=re([...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)},xe=(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}),Se=(e,t)=>e.highlightedIndex===t.highlightedIndex&&xe(e.rows,t.rows),Ce=(e,t)=>xe(e,t)?e:t.slice(),we=(e,t,n)=>{e&&(t.current&&Se(t.current,n)||(t.current=n,e(n)))},Te=(e,t)=>{t.current=null,e?.({rows:[],highlightedIndex:0})},V=e(p(),1),H=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},U=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,W=(e,t)=>{let n=H(t),r=H(e);if(!n||!r)return!1;let i=U(n),a=U(r);return a===i||a.startsWith(`${i}/`)},G=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t=H(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=>H(e)).filter(e=>W(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>H(e)).filter(e=>W(e,t)))):[],s=typeof i.selectedPath==`string`?H(i.selectedPath):null,c=s&&W(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},K=(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},q=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},Ee=l()(d(u((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=H((t||``).trim()),a=H((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!W(a,i)||e(e=>{let t=e.byRoot[i],n=q(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:K({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=H((t||``).trim()),i=H((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=U(i),a=e=>U(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:K({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=H((t||``).trim()),i=H((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=U(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=U(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:K({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=H((t||``).trim()),i=H((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=U(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=U(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:K({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=H((t||``).trim()),a=n?H(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!W(a,i)||e(e=>{let t=e.byRoot[i],n=q(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:K({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=H((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=H((t||``).trim()),i=H((n||``).trim());!r||!i||!W(i,r)||e(e=>{let t=e.byRoot[r],n=q(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:K({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=H((t||``).trim()),i=H((n||``).trim());!r||!i||!W(i,r)||e(e=>{let t=e.byRoot[r],n=q(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:K({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=H((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>H((e||``).trim())).filter(e=>e&&W(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=q(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:K({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,...o]}},20)}})}}),{name:`files-view-tabs-store`,version:2,storage:y(),migrate:e=>{if(!e||typeof e!=`object`)return{byRoot:{}};let t=e.byRoot;return{byRoot:G(t)}},partialize:e=>({byRoot:G(e.byRoot)})}),{name:`files-view-tabs-store`})),J=b(),De=(e,t)=>{let n=(0,J.c)(4),r=t===void 0?200:t,[i,a]=V.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]),V.useEffect(o,s),i},Oe=()=>{let e=(0,J.c)(17),t=w(Y),n=O(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=j(r),a=w(X),o=w(ke),s=A(Ae),c=A(je),l=h(Me);if(t){let r;e[2]===i?r=e[3]:(r=T(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 Y(e){return e.currentSessionId}function X(e){return e.worktreeMetadata}function ke(e){return e.newSessionDraft}function Ae(e){return e.activeProjectId}function je(e){return e.projects}function Me(e){return e.currentDirectory}var Z=f(),Ne=V.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSessionSelect:r,onClose:a,style:s,onRowsChange:c},l)=>{let{t:u}=te(),d=Oe()??``,f=w(e=>e.currentSessionId),p=ce(e=>e.activeSessions),m=A(e=>e.activeProjectId),h=A(e=>e.projects),g=V.useMemo(()=>h.find(e=>e.id===m)?.path??null,[m,h]),v=V.useMemo(()=>{let e=g||d;return e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null},[g,d]),y=Ee(e=>v?e.byRoot[v]:void 0),b=le(e=>e.getVisibleAgents),x=_(e=>e.searchFiles),re=De(e,180),ie=o(),ae=i(),[T,O]=V.useState([]),[k,j]=V.useState([]),[N,P]=V.useState(!1),[F,I]=V.useState(0),de=V.useRef(0),[L,R]=V.useState(360),[B,ge]=V.useState({}),[_e,ve]=V.useState({}),be=V.useRef([]),xe=V.useRef([]),Se=V.useRef([]),Ce=V.useRef(null),H=V.useRef(null),U=V.useRef(null);U.current||=me();let W=ee(e=>e.isMobile),G=(e??``).trim(),K=V.useMemo(()=>{if(!v||!y)return[];let e=[y.selectedPath,...y.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(`${v}/`)?e.slice(v.length+1):e;n.push({name:i,path:e,relativePath:a,extension:i.includes(`.`)?i.split(`.`).pop()?.toLowerCase():void 0})}return E(n,G,{limit:6})},[G,v,y]),q=V.useMemo(()=>G.length>0?k:k.slice(0,2),[k,G.length]),J=V.useMemo(()=>r?D({sessions:p,currentSessionId:f,searchQuery:G}):[],[p,f,G,r]),Y=K,X=T;V.useEffect(()=>{let e=e=>{let t=e.target;!t||!Ce.current||Ce.current.contains(t)||a()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[a]),V.useEffect(()=>{if(!d){O([]);return}let e=(re??``).trim(),t=se(e);if(!t){O([]);return}let n=!1;P(!0);let r={includeHidden:ie,respectGitignore:!ae};return Promise.all([x(d,t,80,{...r,type:`file`}),x(d,t,40,{...r,type:`directory`})]).then(([t,r])=>{if(n)return;let i=new Set(K.map(e=>e.path));O(ue({files:t,directories:r,query:e,excludePaths:i,limit:20}))}).catch(()=>{n||O([])}).finally(()=>{n||P(!1)}),()=>{n=!0}},[d,re,K,x,ie,ae]),V.useEffect(()=>{let t=b().filter(e=>e.mode&&e.mode!==`primary`).map(e=>({name:e.name,description:e.description,mode:e.mode}));j(oe(t,e??``))},[b,e]),V.useEffect(()=>{I(0),ge({}),ve({})},[X,Y.length,q.length,J.length]),V.useEffect(()=>{de.current=F},[F]),V.useEffect(()=>{be.current[F]?.scrollIntoView({block:`nearest`})},[F]),V.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};xe.current.forEach((n,r)=>{if(!n)return;let i=Se.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}}),ge(e),ve(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[X,Y]),V.useEffect(()=>{let e=xe.current[F];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&R(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[F]);let ke=S(e=>{t(e)}),Ae=S(e=>{n?.(e)}),je=S(e=>{r?.(e)}),Me=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&U.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&U.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(U.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>U.current?.pointerCancel(),onClick:()=>{U.current?.click(t)},onMouseMove:()=>I(e)}),Ne=e=>{let t=q.length+J.length+Y.length+X.length;if(t===0)return;let n=(e%t+t)%t;if(n<q.length){let e=q[n];e&&Ae(e.name);return}let r=n-q.length;if(r<J.length){let e=J[r];e&&je(e);return}let i=r-J.length,a=i<Y.length?Y[i]:X[i-Y.length];a&&ke(a)};V.useEffect(()=>{we(c,H,{rows:ye({agents:q,sessions:J,recentFiles:Y,pathHits:X,untitledSession:u(`chat.fileMentionAutocomplete.untitledSession`),sessionBadge:u(`chat.fileMentionAutocomplete.sessionType`)}),highlightedIndex:F})},[c,F,u,q,X,Y,J]);let Pe=V.useRef(c);Pe.current=c,V.useEffect(()=>()=>{Te(Pe.current,H)},[]),V.useImperativeHandle(l,()=>({acceptIndex:e=>{Ne(e)},handleKeyDown:e=>{if(e===`Escape`){a();return}let t=q.length+J.length+Y.length+X.length;if(t!==0){if(e===`ArrowDown`){I(e=>(e+1)%t);return}if(e===`ArrowUp`){I(e=>(e-1+t)%t);return}(e===`Enter`||e===`Tab`)&&Ne(de.current)}}}),[X,Y,q,J,a,ke,Ae,je]);let Fe=e=>(0,Z.jsx)(M,{name:z(e),className:`h-3.5 w-3.5 text-current`});return(0,Z.jsxs)(fe,{ref:Ce,isMobile:W,className:`max-w-[640px] max-h-64`,style:s,children:[(0,Z.jsx)(he,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,Z.jsxs)(`div`,{className:`pb-2`,children:[q.length>0&&(0,Z.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.groups.agents`)}),q.map((e,t)=>{let n=F===t;return(0,Z.jsx)(`div`,{ref:e=>{be.current[t]=e},className:C(`flex items-start gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,W&&`min-h-11`,pe(W,n),!W&&n&&`text-interactive-selection-foreground`),...Me(t,()=>Ae(e.name)),children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`font-semibold truncate`,children:[`@`,e.name]}),e.description&&!W?(0,Z.jsx)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:e.description}):null]})},`agent-${e.name}`)}),q.length===2&&G.length===0&&k.length>2&&(0,Z.jsx)(`div`,{className:`px-3 py-1 typography-meta text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.searchMoreAgents`)}),J.length>0&&(0,Z.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.groups.sessions`)}),J.map((e,t)=>{let n=q.length+t,r=F===n;return(0,Z.jsxs)(`div`,{ref:e=>{be.current[n]=e},className:C(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,W&&`min-h-11`,pe(W,r),!W&&r&&`text-interactive-selection-foreground`),...Me(n,()=>je(e)),children:[(0,Z.jsx)(M,{name:`chat-thread`,className:`h-4 w-4 flex-shrink-0 text-[var(--primary-base)]`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.title||u(`chat.fileMentionAutocomplete.untitledSession`),children:e.title||u(`chat.fileMentionAutocomplete.untitledSession`)}),W?null:(0,Z.jsx)(`span`,{className:`flex-shrink-0 typography-meta text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.sessionType`)})]},`session-${e.id}`)}),Y.length>0&&(0,Z.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.groups.recentFiles`)}),Y.map((e,t)=>{let n=q.length+J.length+t,r=e.relativePath||e.name,i=ne(r,{maxLength:60}),a=F===n,o=B[n]??!1,s=_e[n]??2.6;return(0,Z.jsxs)(`div`,{ref:e=>{be.current[n]=e},className:C(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,W&&`min-h-11`,pe(W,a),!W&&a&&`text-interactive-selection-foreground`),...Me(n,()=>ke(e)),children:[Fe(e),(0,Z.jsxs)(`span`,{ref:e=>{xe.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${L}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,Z.jsx)(`span`,{ref:e=>{Se.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,Z.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:r}):(0,Z.jsx)(`span`,{className:`block truncate`,children:i})]})]},`recent-${e.path}`)}),X.length>0&&(0,Z.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.groups.files`)}),X.map((e,t)=>{let n=q.length+J.length+Y.length+t,r=e.relativePath||e.name,i=ne(r,{maxLength:60}),a=F===n,o=B[n]??!1,s=_e[n]??2.6;return(0,Z.jsxs)(`div`,{ref:e=>{be.current[n]=e},className:C(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,W&&`min-h-11`,pe(W,a),!W&&a&&`text-interactive-selection-foreground`),...Me(n,()=>ke(e)),children:[Fe(e),(0,Z.jsxs)(`span`,{ref:e=>{xe.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${L}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,Z.jsx)(`span`,{ref:e=>{Se.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,Z.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:r}):(0,Z.jsx)(`span`,{className:`block truncate`,children:i})]})]},e.path)}),N&&X.length===0?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,Z.jsx)(M,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!N&&X.length===0&&Y.length===0&&q.length===0&&J.length===0&&(0,Z.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.empty`)})]})}),!W&&(0,Z.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})}),Pe=new Set([`new`,`fork`,`compact`,`undo`,`redo`,`model`,`goal`]),Fe=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&Pe.has(n))},Ie=(e,t)=>!e||t({name:e}),Le=` `,Re=(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]===Le&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},ze=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,Be=C(ze,`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)]`),Ve=C(ze,`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)]`),He=C(ze,`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)]`),Ue=C(ze,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),We=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id),Ge=(e,t)=>{let n=!!e.sessionID;return{hasSession:n,canStartSessionCommand:n||e.hasNewDraft,canUseReviewHandoffFlow:n&&!t&&!s()}},Ke=V.forwardRef(({searchQuery:e,onCommandSelect:t,onClose:n,directory:r,style:i,commandPolicy:a,commandContext:o,onRowsChange:s},c)=>{let{t:l}=te(),u=ee(e=>e.isMobile),d=w(e=>e.currentSessionId),f=w(e=>!!e.newSessionDraft?.open),p=w(V.useCallback(e=>d?e.getDirectoryForSession(d):void 0,[d])),m=k(d??``,p??void 0),h=V.useMemo(()=>o??{sessionID:d??null,hasMessages:m.length>0,hasNewDraft:f},[o,d,m.length,f]),{hasSession:g,canStartSessionCommand:_,canUseReviewHandoffFlow:v}=V.useMemo(()=>Ge(h,u),[h,u]),y=h.hasMessages,[b,x]=V.useState([]),[S,ne]=V.useState(!1),re=ae({directory:r}),oe=V.useMemo(()=>re.data??[],[re.data]),se=re.isFetching,T=ie({directory:r}),ce=V.useMemo(()=>T.data??[],[T.data]),[E,D]=V.useState(0),O=V.useRef(0),le=V.useRef(!1),ue=V.useRef([]),A=V.useRef(null),j=V.useRef(!1),N=V.useRef(null),P=V.useRef(!1),F=V.useRef(null);V.useEffect(()=>{let e=e=>{let t=e.target;!t||!A.current||A.current.contains(t)||n()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[n]),V.useEffect(()=>{(async()=>{ne(se);try{let t=oe.map((e,t)=>({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,isSkill:e.source===`skill`,scope:e.scope,reference:e.reference})),n=ce.map((e,t)=>({id:`skill:${e.scope}:${e.source??`opencode`}:${e.name}:${t}`,name:e.name,source:`skill`,description:e.description,isSkill:!0,scope:e.scope})),r=[{id:`openchamber:new`,name:`new`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},...g&&!y?[{id:`openchamber:init`,name:`init`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],...g?[{id:`openchamber:undo`,name:`undo`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`openchamber:redo`,name:`redo`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`openchamber:fork`,name:`fork`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`openchamber:timeline`,name:`timeline`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`openchamber:model`,name:`model`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`openchamber:compact`,name:`compact`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...g?[{id:`openchamber:summary`,name:`summary`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.summaryDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:workspace-review`,name:`workspace-review`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.workspaceReviewDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:handoff-review`,name:`handoff-review`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.handoffReviewDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:craft-goal`,name:`craft-goal`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.craftGoalDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:goal`,name:`goal`,source:`openchamber`,description:l(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:catch-up`,name:`catch-up`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.catchUpDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:debug`,name:`debug`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.debugDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:weigh`,name:`weigh`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.weighDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:explore`,name:`explore`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.exploreDescription`),isOpenChamber:!0}]:[],...t,...n],i=!y,o=be(r.filter(e=>(i||e.name!==`init`)&&(a?.(e)??!0)),e);x(e=>We(e,o)?e:o)}catch{let t=!y,n=be([{id:`openchamber:new`,name:`new`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},...g&&!y?[{id:`openchamber:init`,name:`init`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],...g?[{id:`openchamber:undo`,name:`undo`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`openchamber:redo`,name:`redo`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`openchamber:fork`,name:`fork`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`openchamber:timeline`,name:`timeline`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`openchamber:model`,name:`model`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`openchamber:compact`,name:`compact`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...g?[{id:`openchamber:summary`,name:`summary`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.summaryDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:workspace-review`,name:`workspace-review`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.workspaceReviewDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:handoff-review`,name:`handoff-review`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.handoffReviewDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:craft-goal`,name:`craft-goal`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.craftGoalDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:goal`,name:`goal`,source:`openchamber`,description:l(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:catch-up`,name:`catch-up`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.catchUpDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:debug`,name:`debug`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.debugDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:weigh`,name:`weigh`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.weighDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:explore`,name:`explore`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.exploreDescription`),isOpenChamber:!0}]:[]].filter(e=>(t||e.name!==`init`)&&(a?.(e)??!0)),e);x(e=>We(e,n)?e:n)}finally{ne(!1)}})()},[e,y,g,_,v,oe,se,ce,l,a]),V.useEffect(()=>{D(0)},[b]),V.useEffect(()=>{O.current=E},[E]),V.useEffect(()=>{ue.current[E]?.scrollIntoView({block:`nearest`})},[E]),V.useEffect(()=>{we(s,F,{rows:_e(b,{skill:l(`chat.commandAutocomplete.badge.skill`),command:l(`chat.commandAutocomplete.badge.command`),system:l(`chat.commandAutocomplete.badge.system`)}),highlightedIndex:E})},[b,s,E,l]);let I=V.useRef(s);I.current=s,V.useEffect(()=>()=>{Te(I.current,F)},[]),V.useImperativeHandle(c,()=>({acceptIndex:(e,n=!0)=>{let r=b[e];r&&t(r,Fe(r,n))},handleKeyDown:e=>{let r=b.length;if(e===`Escape`){n();return}if(r!==0){if(e===`ArrowDown`){le.current=!0,D(e=>(e+1)%r);return}if(e===`ArrowUp`){le.current=!0,D(e=>(e-1+r)%r);return}if(e===`Enter`||e===`Tab`){let n=(O.current%r+r)%r,i=b[n];i&&t(i,Fe(i,e===`Enter`))}}}}),[b,n,t]);let de=e=>{let t=L(e);switch(e.name){case`new`:return(0,Z.jsx)(M,{name:t,className:`h-3.5 w-3.5`});case`init`:return(0,Z.jsx)(M,{name:t,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,Z.jsx)(M,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,Z.jsx)(M,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:return(0,Z.jsx)(M,{name:t,className:`h-3.5 w-3.5`});case`compact`:return(0,Z.jsx)(M,{name:t,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,Z.jsx)(M,{name:t,className:`h-3.5 w-3.5`});case`review`:return(0,Z.jsx)(M,{name:t,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,Z.jsx)(M,{name:t,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,Z.jsx)(M,{name:t,className:`h-3.5 w-3.5 text-yellow-500`}):(0,Z.jsx)(M,{name:t,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,Z.jsxs)(fe,{ref:A,isMobile:u,className:`max-w-[450px] max-h-64`,style:i,children:[(0,Z.jsx)(he,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 pb-2`,children:S?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,Z.jsx)(M,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,Z.jsxs)(`div`,{children:[b.map((e,n)=>{let r=e.isBuiltIn,i=e.isOpenChamber;return(0,Z.jsxs)(`div`,{ref:e=>{ue.current[n]=e},className:C(`flex gap-2 px-3 py-2 cursor-pointer rounded-lg`,u?`items-center`:`items-start`,pe(u,n===E)),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(N.current={x:e.clientX,y:e.clientY},P.current=!1)},onPointerMove:e=>{if(e.pointerType!==`touch`||!N.current)return;let t=e.clientX-N.current.x,n=e.clientY-N.current.y;Math.hypot(t,n)>6&&(P.current=!0)},onPointerUp:n=>{if(n.pointerType!==`touch`)return;let r=P.current;N.current=null,P.current=!1,!r&&(n.preventDefault(),n.stopPropagation(),j.current=!0,t(e,Fe(e,u)))},onPointerCancel:()=>{N.current=null,P.current=!1},onClick:()=>{if(j.current){j.current=!1;return}t(e,Fe(e,u))},onMouseMove:()=>{le.current=!1,D(n)},children:[(0,Z.jsx)(`div`,{className:C(!u&&`mt-0.5`),children:de(e)}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,e.name]}),e.isSkill?(0,Z.jsx)(`span`,{className:Be,children:l(`chat.commandAutocomplete.badge.skill`)}):(0,Z.jsx)(`span`,{className:Be,children:l(`chat.commandAutocomplete.badge.command`)}),i?(0,Z.jsx)(`span`,{className:Ue,children:`OpenChamber`}):r?(0,Z.jsx)(`span`,{className:Ue,children:l(`chat.commandAutocomplete.badge.system`)}):e.scope?(0,Z.jsx)(`span`,{className:e.scope===`project`?He:Ve,children:e.scope}):null,e.agent&&(0,Z.jsx)(`span`,{className:Ue,children:e.agent})]}),e.description&&!u&&(0,Z.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:e.description})]})]},e.id)}),b.length===0&&(0,Z.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:l(`chat.commandAutocomplete.empty`)})]})}),!u&&(0,Z.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:l(`chat.autocomplete.keyboardHint`)})]})});Ke.displayName=`CommandAutocomplete`;function qe(e){return(e.description||e.content).replace(/\s+/g,` `).trim().slice(0,120)}var Je=V.forwardRef((e,t)=>{let n=(0,J.c)(62),{searchQuery:r,onSnippetSelect:i,onClose:a,style:o}=e,{t:s}=te(),c=V.useRef(null),l=ee(Ye),[u,d]=V.useState(0),f=V.useRef(0),p;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=[],n[0]=p):p=n[0];let[m,h]=V.useState(p),g;n[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=[],n[1]=g):g=n[1];let _=V.useRef(g),v=de(Xe),y=de(Ze),b=de(Qe),x=de($e),S=ee(et),ne=ee(tt),ie,ae;n[2]===y?(ie=n[3],ae=n[4]):(ie=()=>{y()},ae=[y],n[2]=y,n[3]=ie,n[4]=ae),V.useEffect(ie,ae);let w,oe;n[5]!==r||n[6]!==v?(w=()=>{let e=r.trim();if(!e.length){let e=[...v].sort(nt);h(e),d(+!!e.length);return}let t=re(v,e,rt);t.sort(it);let n=t.map(at);h(n),d(+!!n.length)},oe=[r,v],n[5]=r,n[6]=v,n[7]=w,n[8]=oe):(w=n[7],oe=n[8]),V.useEffect(w,oe);let se,T;n[9]===u?(se=n[10],T=n[11]):(se=()=>{f.current=u,_.current[u]?.scrollIntoView({block:`nearest`})},T=[u],n[9]=u,n[10]=se,n[11]=T),V.useEffect(se,T);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),V.useEffect(E,ce);let D;n[15]!==i||n[16]!==r?(D=e=>{let t=r.trim(),n=e.aliases.includes(t)?t:e.name;i(e,n)},n[15]=i,n[16]=r,n[17]=D):D=n[17];let O=D,le;n[18]!==a||n[19]!==x||n[20]!==S||n[21]!==ne||n[22]!==b||n[23]!==v?(le=()=>{let e=new Set(v.map(ot)),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]=le):le=n[24];let k=le,ue,A;n[25]!==O||n[26]!==m||n[27]!==a||n[28]!==k?(ue=()=>({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){k();return}let e=m[f.current-1];e&&O(e)}}}),A=[O,m,a,k],n[25]=O,n[26]=m,n[27]=a,n[28]=k,n[29]=ue,n[30]=A):(ue=n[29],A=n[30]),V.useImperativeHandle(t,ue,A);let j;n[31]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>{_.current[0]=e},n[31]=j):j=n[31];let N;n[32]!==l||n[33]!==u?(N=C(`flex items-center gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label`,pe(l,u===0)),n[32]=l,n[33]=u,n[34]=N):N=n[34];let P,F;n[35]===Symbol.for(`react.memo_cache_sentinel`)?(P=()=>d(0),F=(0,Z.jsx)(M,{name:`add`,className:`h-3.5 w-3.5 text-muted-foreground`}),n[35]=P,n[36]=F):(P=n[35],F=n[36]);let I;n[37]===s?I=n[38]:(I=s(`chat.snippetAutocomplete.action.addNew`),n[37]=s,n[38]=I);let me;n[39]===I?me=n[40]:(me=(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:I}),n[39]=I,n[40]=me);let L;n[41]!==k||n[42]!==N||n[43]!==me?(L=(0,Z.jsxs)(`div`,{ref:j,className:N,onClick:k,onMouseMove:P,children:[F,me]}),n[41]=k,n[42]=N,n[43]=me,n[44]=L):L=n[44];let R;n[45]!==O||n[46]!==m||n[47]!==l||n[48]!==u||n[49]!==s?(R=m.length?m.map((e,t)=>(0,Z.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`,pe(l,t+1===u)),onClick:()=>O(e),onMouseMove:()=>d(t+1),children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(`span`,{className:`font-semibold truncate`,children:[`#`,e.name]}),(0,Z.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,Z.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:qe(e)})]})},`${e.source}:${e.filePath}`)):(0,Z.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:s(`chat.snippetAutocomplete.empty`)}),n[45]=O,n[46]=m,n[47]=l,n[48]=u,n[49]=s,n[50]=R):R=n[50];let z;n[51]!==L||n[52]!==R?(z=(0,Z.jsxs)(he,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 pb-2`,children:[L,R]}),n[51]=L,n[52]=R,n[53]=z):z=n[53];let B;n[54]!==l||n[55]!==s?(B=!l&&(0,Z.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:s(`chat.snippetAutocomplete.footer`)}),n[54]=l,n[55]=s,n[56]=B):B=n[56];let ge;return n[57]!==l||n[58]!==o||n[59]!==z||n[60]!==B?(ge=(0,Z.jsxs)(fe,{ref:c,isMobile:l,className:`max-w-[450px] max-h-60`,style:o,children:[z,B]}),n[57]=l,n[58]=o,n[59]=z,n[60]=B,n[61]=ge):ge=n[61],ge});Je.displayName=`SnippetAutocomplete`;function Ye(e){return e.isMobile}function Xe(e){return e.snippets}function Ze(e){return e.loadSnippets}function Qe(e){return e.setSnippetDraft}function $e(e){return e.setSelectedSnippet}function et(e){return e.setSettingsDialogOpen}function tt(e){return e.setSettingsPage}function nt(e,t){return e.source===`project`&&t.source!==`project`?-1:e.source!==`project`&&t.source===`project`?1:e.name.localeCompare(t.name)}function rt(e){return[e.name,...e.aliases]}function it(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 at(e){return e.item}function ot(e){return e.name}var st=2,ct=e=>!!e&&typeof e==`object`&&!Array.isArray(e),lt=e=>{let t=e?.trim().replace(/\\/g,`/`);return t?t.length>1?t.replace(/\/+$/,``):t:null},ut=e=>ct(e)&&Array.isArray(e.all)&&e.all.every(e=>typeof e==`string`)&&typeof e.current==`string`&&ct(e.branches),dt=(e,t)=>JSON.stringify([e,t]),ft=e=>`version`in e&&e.version===st&&ct(e.entries),pt=e=>{if(!e)return null;try{let t=JSON.parse(e);return ct(t)?t.version===st&&ct(t.entries)?{version:st,entries:t.entries}:t:null}catch{return null}},mt=(e,t)=>{try{e.setItem(`oc.gitBranchCache`,JSON.stringify(t))}catch{}},ht=(e,t,n)=>{let r=lt(e);if(!r||!t)return null;let i;try{i=n.getItem(`oc.gitBranchCache`)}catch{return null}let a=pt(i);if(!a)return null;if(ft(a))return ut(a.entries[dt(t,r)])?a.entries[dt(t,r)]:null;let o={};for(let[e,n]of Object.entries(a)){let r=lt(e);r&&ut(n)&&(o[dt(t,r)]=n)}return mt(n,{version:st,entries:o}),o[dt(t,r)]??null},gt=(e,t,n,r)=>{let i=lt(e);if(!i||!t||!ut(n))return;let a=null;try{a=r.getItem(`oc.gitBranchCache`)}catch{return}let o=pt(a);mt(r,{version:st,entries:{...o&&ft(o)?o.entries:{},[dt(t,i)]:n}})},_t=3e4,vt=lt,yt=(e,t=n())=>a.git.branches(vt(e),t),bt=(e,t=n())=>a.git.remotes(vt(e),t),xt=async(e,t,n)=>{n.throwIfAborted();let i=r()?.git,a=t?.getGitBranches?await t.getGitBranches(e,{signal:n}):i?await i.getGitBranches(e,{signal:n}):await g(e,{signal:n});return n.throwIfAborted(),a},St=async(e,t,n)=>{n.throwIfAborted();let i=r()?.git,a=t?.getRemotes?await t.getRemotes(e,{signal:n}):i?await i.getRemotes(e,{signal:n}):await m(e,{signal:n});return n.throwIfAborted(),a},Ct=(e,t,r=n(),i=v())=>{let a=vt(e),o=t;return{queryKey:yt(a,r),queryFn:async({signal:e})=>{if(!a)throw Error(`Git branches require a directory`);let t=await xt(a,o,e);return gt(a,r,t,i),t},staleTime:_t,gcTime:1/0,initialData:()=>ht(a,r,i)??void 0,initialDataUpdatedAt:0}},wt=(e,t,r=n())=>{let i=vt(e),a=t;return{queryKey:bt(i,r),queryFn:({signal:e})=>{if(!i)throw Error(`Git remotes require a directory`);return St(i,a,e)},staleTime:_t,gcTime:1/0}},Tt=(e,r,i)=>{let a=(0,J.c)(9),o=i===void 0||i,s=V.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=vt(e),u=x,l=Ct(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)},Et=(e,r,i)=>{let a=(0,J.c)(9),o=i===void 0||i,s=V.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=vt(e),u=x,l=wt(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)},Dt=(e,t,r=c,i=n())=>r.fetchQuery(Ct(e,t,i)),Ot=(e,t,r=c,i=n())=>r.fetchQuery({...Ct(e,t,i),staleTime:0}),kt=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,At=1e4,jt=6e4,Mt=5e3,Nt=3e4,Pt=6e4,Ft=25,It=40,Lt=2,Rt=15e3,zt=500,Bt=30,Vt=20971520,Ht=new Map,Ut=new Map,Wt=new Map,Gt=new Map,Kt=new Map,qt=(e,t)=>`${t}:${e}`,Jt=e=>Ut.get(e)??0,Yt=e=>{let t=Jt(e)+1;return Ut.set(e,t),t},Xt=e=>{let t=(Wt.get(e)??0)+1;return Wt.set(e,t),t},Zt=e=>{let t=Ht.get(e);if(t)return t;let n=new Set;return Ht.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}),Qt=(e,t=Bt,n=Vt)=>{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},$t=(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},en=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,tn=(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&&en(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&&$t(e.diffStats,t.diffStats))},nn=(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},rn=(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},an=e=>!e||e.trim().length===0,on=e=>(e||``).trim()===`U`,sn=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(on(t)||on(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},cn=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(on(t)||on(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},ln=e=>an(e.index)&&an(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&&Yt(r),n&&Yt(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=qt(n,a),s=Gt.get(o)??(a===`light`?Gt.get(qt(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)>jt,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(tn(s.status,u)){c=!0;let r=new Map(t().directories),i=r.get(n)??Q(),s=nn(i.status,u),l=rn(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&&Yt(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})();Gt.set(o,c);try{return await c}finally{Gt.get(o)===c&&Gt.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`?sn(e):cn(e);t!==e&&(l=!0),ln(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=Xt(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 Ot(r,i,void 0,o):await Dt(r,i,void 0,o);if(s!==Wt.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(kt(i)||console.error(`Failed to fetch git branches:`,i),s!==Wt.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>At||!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=Qt(s);a.set(n,{...o,diffCache:c}),e({directories:a})},clearDiffCache:n=>{Yt(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,Ft);await t().prefetchDiffs(e,n,i,{maxFiles:Ft})},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=It}=a,c=new Set(o.status.files.map(e=>e.path)),l=o.status.diffStats,u=Zt(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>zt||d.push(e)}let p=d.slice(0,Math.max(1,s));if(p.length===0)return;let m=Jt(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 ${Rt}ms`)),Rt)}),a=await Promise.race([t,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},ee=async()=>{for(;;){if(m!==Jt(n))return;let e=_();if(!e)return;try{g.push(await v(e))}catch{}finally{u.delete(e)}}},y=Math.min(Lt,p.length);if(await Promise.allSettled(Array.from({length:y},()=>ee())),p.forEach(e=>u.delete(e)),m!==Jt(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=Qt(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<Mt||await t().fetchStatus(e,n,{silent:!!r?.status})},ensureAll:(e,n)=>{let r=Kt.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)>=Mt)&&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>=Nt)&&o.push(t().fetchBranches(e,n)),(!a.log||i-a.lastLogFetch>=At)&&o.push(t().fetchLog(e,n)),(!a.identity||i-a.lastIdentityFetch>=Pt)&&o.push(t().fetchIdentity(e,n)),o.length>0&&await Promise.all(o)})();return Kt.set(e,i),i.finally(()=>{Kt.get(e)===i&&Kt.delete(e)}),i},refresh:async(e,n={})=>{let{activeDirectory:r}=t();r&&await t().fetchAll(r,e,n)}}),{name:`git-store`})),un=e=>{let t=(0,J.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)},dn=e=>{let r=(0,J.c)(3),i=V.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)},fn=e=>{let t=(0,J.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)},pn=e=>{let t=(0,J.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)},mn=e=>{let t=(0,J.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)},hn={current:new Map},gn=()=>$(xn),_n=e=>{let t=(0,J.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=V.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)},vn=e=>{let t=(0,J.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)},yn=e=>{let t=(0,J.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)},bn=e=>{let t=(0,J.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)};function xn(e){let t=hn.current,n=t.size===e.directories.size;if(n){for(let[r,i]of e.directories)if(t.get(r)!==(i.status?.current??null)){n=!1;break}}if(n)return t;let r=new Map;for(let[t,n]of e.directories)r.set(t,n.status?.current??null);return hn.current=r,r}var Sn=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)}},Cn=e=>String(e||``).trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/^remotes\//,``),wn=e=>e.branchName?Cn(e.branchName):e.mode===`existing`?Cn(e.existingBranch||e.preferredName||``):Cn(e.preferredName||``),Tn=async e=>{let t=await F(e);try{let n=Sn((await N(e)).branches?.[t]?.tracking||null);if(n?.remote)return n.remote}catch{}try{let t=Sn((await P(e)).tracking);if(t?.remote)return t.remote}catch{}return null},En=async(e,t)=>{let n=await Tn(e),r=Cn(t);return!n||!r?null:{setUpstream:!0,upstreamRemote:n,upstreamBranch:r}},Dn=async(e,t,n)=>{let r=wn(t),i=n?.resolvedRootTrackingRemote,a=i===void 0?await En(e,r):i&&Cn(r)?{setUpstream:!0,upstreamRemote:i,upstreamBranch:Cn(r)}:null;return a?{...t,setUpstream:t.setUpstream??a.setUpstream,upstreamRemote:t.upstreamRemote||a.upstreamRemote,upstreamBranch:t.upstreamBranch||a.upstreamBranch}:t},On=async(e,t,n)=>{let r=await Dn(e.path,t,n);return I(e,r)},kn=`oc:lastWorktreeSourceBranch`,An=({mode:e,sourceBranch:t,linkedPr:n,selectedBranch:r})=>e===`existing-branch`?r||null:n?null:t||null,jn=({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},Mn=(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?` `:``}`},Nn=(e,t,n)=>{let r=Mn(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},Pn=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=Nn(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}},Fn=(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]:[...e,t]},In=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{Oe as A,Tt as C,Re as D,Ke as E,Te as F,ve as I,Ee as M,Ce as N,Ie as O,we as P,Ot as S,Je as T,fn as _,kn as a,$ as b,On as c,gn as d,mn as f,vn as g,yn as h,Nn as i,De as j,Ne as k,Tn as l,bn as m,Fn as n,jn as o,dn as p,Pn as r,An as s,In as t,Dn as u,_n as v,Et as w,pn as x,un as y};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{Qt as t}from"./persistence-Ce3AnpEr.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{Ct as o,Nt as s}from"./platform-0w_Q9_ji.js";import{t as c}from"./useUIStore-Bxv3f23A.js";import{n as l}from"./vendor-react-DLPElpoQ.js";import{n as u}from"./vendor-reactuses-core-BnW6GxJt.js";import{f as d,i as f,r as p,t as m,y as h}from"./button-DtzFDvij.js";import{Bn as g,Ja as _,Ka as v,Vn as y,Wn as b,c as x,er as S,hr as C,oa as w,ra as T,s as E,ua as D,xo as O,yr as k}from"./useMobileNavigationStore-DrB_awgk.js";import{n as A}from"./Icon-i5GiQRLq.js";import{n as ee}from"./gitApi-CHpibtno.js";import{D as te,O as ne,S as j,Z as M,_ as N,a as P,b as re,f as ie,g as ae,h as oe,i as F,m as se,n as ce,q as I,v as L,x as le,y as R}from"./projectMeta--y6tyjrv.js";import{t as z}from"./input-CbB2HdLg.js";import{i as B,n as V,t as ue}from"./tooltip-Djn7MSOX.js";import{o as de}from"./OverlayScrollbar-NuQI58XD.js";import{n as fe}from"./useRuntimeAPIs-DSLXJybW.js";import{E as pe,T as me,a as H,b as U,c as W,g as he,k as ge,l as G,m as K,o as q,p as J,r as _e,x as Y}from"./insertionBoundaries-Yd1Lorjw.js";import{r as ve,t as ye}from"./textarea-BnD799LW.js";import{n as be,r as xe,t as Se}from"./collapsible-D-nzhcyF.js";var X=e(a(),1),Ce=l(),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};D(e.id,n),x.getState().markSessionAsOpenChamberCreated(e.id),C.getState().upsertSession(i);try{w().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=O.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=o.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 c=Ne();if(!c)return e({error:`Select a project`,isLoading:!1}),null;let l=c.path,u=await ee(l)&&t.isolateRuns!==!1,d=Oe(n),f=u?await ie(l):void 0,p=u?await G(l):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 b=ke(g.providerID,g.modelID),C=r.length>1?`g${e+1}`:void 0,w=_>1?Ae(d,`${b}/${v}`):Ae(d,b),T=C?`${C}/${w}`:w,E=Ee({groupSlug:d,runGroup:C,providerID:g.providerID,modelID:g.modelID,index:_>1?v:void 0});try{if(!u){let e=await s.withDirectory(l,()=>s.createSession({title:E}));Me(e,l),m.push({sessionId:e.id,worktreePath:l,providerID:g.providerID,modelID:g.modelID,variant:g.variant,prompt:i});continue}let e=await W(c,{preferredName:T,mode:`new`,branchName:T,worktreeName:T,startRef:t.worktreeBaseBranch||`HEAD`,setupCommands:h,returnAfterDirectoryCreated:!0},{resolvedRootTrackingRemote:p}),n={...e,createdFromBranch:f,kind:`standard`};await y(c)&&await S(e.path);let r=await s.withDirectory(e.path,()=>s.createSession({title:E}));Me(r,e.path),x.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&&b(c,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 C=a?.map(e=>({type:`file`,mime:e.mime,filename:e.filename,url:e.url}));return(async()=>{try{let e=I.getState().expandText;await Promise.allSettled(m.map(async t=>{try{let n=await e(t.prompt).catch(()=>t.prompt);await E({sessionId:t.sessionId,directory:t.worktreePath,content:n,providerID:t.providerID,modelID:t.modelID,variant:t.variant,agent:i,files:C})}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=p(`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)(ne,{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)(A,{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 m;return t[9]!==l||t[10]!==u||t[11]!==f?(m=(0,$.jsxs)(`div`,{className:c,children:[l,u,f]}),t[9]=l,t[10]=u,t[11]=f,t[12]=m):m=t[12],m},Re=e=>{let t=(0,Ce.c)(131),{selectedModels:n,onAdd:r,onRemove:i,onUpdate:a,minModels:o,addButtonLabel:s,showChips:l,maxModels:u,addButtonClassName:f,dropdownSide:h,dropdownClassName:g,containerClassName:v,triggerIcon:y}=e,b=l===void 0||l,x=h===void 0?`top`:h,{t:S}=d(),C=T(ze),w=T(Be),E=c(Ve),D=c(He),{favoriteModelsList:O,recentModelsList:k}=te(),ee=c(Ue),ne=c(We),[M,P]=X.useState(!1),[ie,ae]=X.useState(``),[F,ce]=X.useState(null),I=X.useRef(null),L=X.useRef(null),R=u===1,z=u===void 0||n.length<u||R,B;if(t[0]!==n){B=new Map;for(let e of n){let t=`${e.providerID}:${e.modelID}`;B.set(t,(B.get(t)||0)+1)}t[0]=n,t[1]=B}else B=t[1];let V=B,ue;t[2]===n?ue=t[3]:(ue=e=>n.filter(t=>t.providerID===e.providerID&&t.modelID===e.modelID).findIndex(t=>t.instanceId===e.instanceId)+1,t[2]=n,t[3]=ue);let de=ue,fe,pe;t[4]!==x||t[5]!==M?(fe=()=>{if(!M||!L.current)return;let e=L.current.getBoundingClientRect();if(x===`bottom`){let t=(window.visualViewport?.height??document.documentElement.clientHeight??window.innerHeight)-e.bottom-16-112;ce(Math.max(160,Math.min(320,t)));return}let t=L.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;ce(Math.max(150,Math.min(300,r)))},pe=[x,M],t[4]=x,t[5]=M,t[6]=fe,t[7]=pe):(fe=t[6],pe=t[7]),X.useEffect(fe,pe);let me,H;t[8]!==z||t[9]!==M?(me=()=>{!z&&M&&(P(!1),ae(``))},H=[z,M],t[8]=z,t[9]=M,t[10]=me,t[11]=H):(me=t[10],H=t[11]),X.useEffect(me,H);let U,W;t[12]===M?(U=t[13],W=t[14]):(U=()=>{if(!M)return;let e=e=>{I.current&&!I.current.contains(e.target)&&(P(!1),ae(``))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},W=[M],t[12]=M,t[13]=U,t[14]=W),X.useEffect(U,W);let he;t[15]!==R||t[16]!==r||t[17]!==a||t[18]!==n.length?(he=e=>{let t={providerID:e.providerID,modelID:e.modelID,displayName:_(e.model,e.modelID)||e.modelID,instanceId:Ie()};R&&n.length>0&&a?a(0,t):r(t),R&&(P(!1),ae(``))},t[15]=R,t[16]=r,t[17]=a,t[18]=n.length,t[19]=he):he=t[19];let ge=he,G;t[20]===S?G=t[21]:(G=S(`multirun.modelMultiSelect.search.placeholder`),t[20]=S,t[21]=G);let K;t[22]===S?K=t[23]:(K=S(`multirun.modelMultiSelect.search.noResults`),t[22]=S,t[23]=K);let q;t[24]===S?q=t[25]:(q=S(`multirun.modelMultiSelect.sections.favorites`),t[24]=S,t[25]=q);let J;t[26]===S?J=t[27]:(J=S(`multirun.modelMultiSelect.sections.recent`),t[26]=S,t[27]=J);let _e;t[28]===S?_e=t[29]:(_e=S(`multirun.modelMultiSelect.keyboard.hint`),t[28]=S,t[29]=_e);let Y;t[30]===S?Y=t[31]:(Y=S(`settings.agents.modelSelector.actions.favorite`),t[30]=S,t[31]=Y);let ve;t[32]===S?ve=t[33]:(ve=S(`settings.agents.modelSelector.actions.unfavorite`),t[32]=S,t[33]=ve);let ye;t[34]===S?ye=t[35]:(ye=S(`chat.modelControls.provider`),t[34]=S,t[35]=ye);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]!==G||t[55]!==K||t[56]!==q||t[57]!==J||t[58]!==_e||t[59]!==Y||t[60]!==ve||t[61]!==ye||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:G,noResults:K,favorites:q,recent:J,keyboardHint:_e,favorite:Y,unfavorite:ve,provider:ye,capabilities:be,capabilityToolCalling:xe,capabilityReasoning:Se,modalityImage:Z,modalityVideo:Q,modalityAudio:we,costPerMillion:Te,costInput:Ee,costOutput:De},t[54]=G,t[55]=K,t[56]=q,t[57]=J,t[58]=_e,t[59]=Y,t[60]=ve,t[61]=ye,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]===v?Ae=t[73]:(Ae=p(`relative`,v),t[72]=v,t[73]=Ae);let je;t[74]===f?je=t[75]:(je=p(Fe,`!border-border/80 !bg-[var(--surface-subtle)] hover:!bg-[var(--interactive-hover)]/70`,f),t[74]=f,t[75]=je);let Me=!z,Ne;t[76]===M?Ne=t[77]:(Ne=()=>{P(!M)},t[76]=M,t[77]=Ne);let Pe;t[78]===y?Pe=t[79]:(Pe=y??(0,$.jsx)(A,{name:`add`,className:`h-3.5 w-3.5 mr-1`}),t[78]=y,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)(m,{ref:L,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]!==F||t[90]!==z||t[91]!==g||t[92]!==x||t[93]!==O||t[94]!==w||t[95]!==ge||t[96]!==ee||t[97]!==D||t[98]!==M||t[99]!==ke||t[100]!==V||t[101]!==ne||t[102]!==C||t[103]!==k||t[104]!==ie||t[105]!==E?(qe=M?(0,$.jsx)(`div`,{className:p(`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`,g),style:{background:`linear-gradient(var(--surface-elevated),var(--surface-elevated)),linear-gradient(var(--surface-background),var(--surface-background))`},children:(0,$.jsx)(j,{providers:C,providerOrder:ne,favoriteModels:O,recentModels:k,getMetadata:w,hiddenModels:ee,searchQuery:ie,onSearchQueryChange:ae,onSelect:ge,labels:ke,selectionCount:e=>V.get(`${e.providerID}:${e.modelID}`)||0,disabled:!z,maxHeightClassName:`flex-1`,maxHeightStyle:{maxHeight:F?`${F}px`:`300px`},stickyHeaders:!0,tooltipsEnabled:M,isFavorite:e=>D(e.providerID,e.modelID),onToggleFavorite:e=>E(e.providerID,e.modelID),onEscape:()=>{P(!1),ae(``)}})}):null,t[89]=F,t[90]=z,t[91]=g,t[92]=x,t[93]=O,t[94]=w,t[95]=ge,t[96]=ee,t[97]=D,t[98]=M,t[99]=ke,t[100]=V,t[101]=ne,t[102]=C,t[103]=k,t[104]=ie,t[105]=E,t[106]=qe):qe=t[106];let Je;t[107]!==Ae||t[108]!==Ke||t[109]!==qe?(Je=(0,$.jsxs)(`div`,{className:Ae,ref:I,children:[Ke,qe]}),t[107]=Ae,t[108]=Ke,t[109]=qe,t[110]=Je):Je=t[110];let Ye;t[111]!==de||t[112]!==V||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=V.get(n)||1,o=de(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)(se,{value:u,onValueChange:n=>{if(!a)return;let r=n===`__default__`?void 0:n;a(t,{...e,variant:r})},children:[(0,$.jsxs)(re,{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)(A,{name:`brain-ai-3`,className:p(`h-3.5 w-3.5 flex-shrink-0`,u===`__default__`?`text-muted-foreground`:`text-[color:var(--status-info)]`)}),(0,$.jsx)(le,{placeholder:S(`multirun.modelMultiSelect.variant.placeholder`),children:e=>e===`__default__`?S(`multirun.modelMultiSelect.variant.default`):e})]}),(0,$.jsxs)(oe,{fitContent:!0,children:[(0,$.jsx)(N,{value:`__default__`,className:`pr-2 [&>span:first-child]:hidden`,children:S(`multirun.modelMultiSelect.variant.default`)}),c.map(Ge)]})]})]},e.instanceId)})}),t[111]=de,t[112]=V,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]!==u||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:u===void 0?S(`multirun.modelMultiSelect.validation.minOnly`,{min:o}):S(`multirun.modelMultiSelect.validation.minToMax`,{min:o,max:u})}),t[123]=u,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)(N,{value:e,className:`pr-2 [&>span:first-child]:hidden`,children:e},e)}function Ke(e){let t=(0,Ce.c)(30),{git:n}=fe(),r=J(e),i=Y(e),a=he(e),o=K(e),s=U(Ze),c=U(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}=d(),{localBranches:s,remoteBranches:c,isLoading:l,isGitRepository:u}=Ke(e),f=X.useMemo(()=>[...s,...c.map(e=>`remotes/${e}`)],[s,c]);return X.useEffect(()=>{if(i||l||f.length===0||t&&f.includes(t))return;let r=t,a=!1;return(async()=>{try{let t=e?await ie(e).catch(()=>null):null;if(a)return;let i=localStorage.getItem(H),{sourceBranch:o,shouldClearSavedSourceBranch:s}=q({branches:f,savedSourceBranch:i,rootBranch:t});if(s&&localStorage.removeItem(H),a||r&&f.includes(r))return;o&&n(o)}catch{}})(),()=>{a=!0}},[f,e,i,l,n,t]),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(se,{value:t,onValueChange:n,disabled:i||!u||l,children:[(0,$.jsx)(re,{id:a,size:`lg`,className:r??`w-fit typography-meta text-foreground`,children:(0,$.jsx)(le,{placeholder:o(l?`multiRun.branchSelector.status.loadingBranches`:`multiRun.branchSelector.placeholder.selectSourceBranch`)})}),(0,$.jsx)(oe,{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)(ae,{children:[(0,$.jsx)(L,{className:`font-semibold text-foreground`,children:o(`multiRun.branchSelector.groups.localBranches`)}),s.map(e=>(0,$.jsx)(N,{value:e,className:`whitespace-normal break-all`,children:e},e))]}),s.length>0&&c.length>0&&(0,$.jsx)(R,{}),c.length>0&&(0,$.jsxs)(ae,{children:[(0,$.jsx)(L,{className:`font-semibold text-foreground`,children:o(`multiRun.branchSelector.groups.remoteBranches`)}),c.map(e=>(0,$.jsx)(N,{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}=d(),l=T(et),u=T(tt),f=T(nt),m;t[0]===l?m=t[1]:(m=l(),t[0]=l,t[1]=m);let h=m,g;t[2]===h?g=t[3]:(g=h.filter(rt),t[2]=h,t[3]=g);let _=g,v,y;t[4]!==h.length||t[5]!==u?(v=()=>{h.length===0&&u()},y=[h.length,u],t[4]=h.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]!==f||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 f==`string`&&f.trim().length>0?f.trim():null;if(t&&_.some(e=>e.name===t)){r(t);return}let i=_[0]?.name;i&&r(i)},x=[f,a,r,_,n],t[8]=f,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=p(`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 E;t[19]===w?E=t[20]:(E=(0,$.jsx)(le,{placeholder:w}),t[19]=w,t[20]=E);let D;t[21]!==o||t[22]!==C||t[23]!==E?(D=(0,$.jsx)(re,{id:o,size:`lg`,className:C,children:E}),t[21]=o,t[22]=C,t[23]=E,t[24]=D):D=t[24];let O;t[25]===_?O=t[26]:(O=_.length>0&&(0,$.jsx)(ae,{children:_.map(it)}),t[25]=_,t[26]=O);let k;t[27]!==s||t[28]!==O?(k=(0,$.jsx)(oe,{fitContent:!0,portalToBody:s,children:O}),t[27]=s,t[28]=O,t[29]=k):k=t[29];let A;return t[30]!==a||t[31]!==r||t[32]!==S||t[33]!==D||t[34]!==k?(A=(0,$.jsxs)(se,{value:S,onValueChange:r,disabled:a,children:[D,k]}),t[30]=a,t[31]=r,t[32]=S,t[33]=D,t[34]=k,t[35]=A):A=t[35],A};function et(e){return e.getVisibleAgents}function tt(e){return e.loadAgents}function nt(e){return e.currentAgentName}function rt(e){return v(e.mode)}function it(e){return(0,$.jsx)(N,{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)(B,{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)(A,{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)(ue,{children:[r,(0,$.jsx)(V,{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=f(e.path),n=e.icon?F[e.icon]:null,r=e.color?ce[e.color]:void 0,i=(0,$.jsx)(A,{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)(P,{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}=d(),[s,c]=X.useState(``),[l,f]=X.useState(()=>[{id:Ie(),prompt:``,models:[]}]),[_,v]=X.useState(``),[y,b]=X.useState([]),[S,C]=X.useState(!1),[w,T]=X.useState([]),[E,D]=X.useState(!1),[ee,te]=X.useState(!1),[ne,j]=X.useState(!0),P=X.useRef(null),ie=o(e=>e.currentDirectory??null),ae=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},[]),F=O(e=>e.activeProjectId),ce=O(e=>e.setActiveProjectIdOnly),I=O(e=>e.projects),[L,R]=X.useState(()=>F??null);X.useEffect(()=>{if(F){R(F);return}!L&&I.length>0&&R(I[0].id)},[F,I,L]);let fe=X.useMemo(()=>L?I.find(e=>e.id===L)??null:null,[I,L]),pe=fe?.path??ie,me=u(e=>{R(e),e!==F&&ce(e)}),H=X.useMemo(()=>{if(fe?.path)return{id:fe.id,path:fe.path};let e=ie??ae;return e?{id:`path:${e}`,path:e}:null},[fe,ie,ae]),[U]=X.useState(()=>typeof window<`u`&&t()),W=X.useMemo(()=>typeof navigator>`u`?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||``),[]),he=de(),ge=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(()=>U&&W||he?`pl-[5.5rem]`:`pl-3`,[U,W,he]),K=X.useMemo(()=>!U||!W||ge===null?``:ge>=26?`h-12`:ge<=15?`h-14`:``,[U,W,ge]),q=u(async e=>{e.target.closest(`button, a, input, select, textarea`)||e.button===0&&U&&await h()}),J=u(e=>{r&&e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),r())}),_e=!!r;X.useEffect(()=>{if(_e)return window.addEventListener(`keydown`,J,!0),()=>window.removeEventListener(`keydown`,J,!0)},[_e]);let[Y,ye]=X.useState(``),{isLoading:Ce,isGitRepository:Z}=Ke(pe),Q=X.useRef(!1),we=Z===!0,Te=we&≠X.useEffect(()=>{if(Z===!1){Q.current=!0,j(!1);return}Z===!0&&Q.current&&(Q.current=!1,j(!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&&f(t=>{let n=[...t];return n.length>0&&!n[0].prompt.trim()&&(n[0]={...n[0],prompt:e}),n})},[e]),X.useEffect(()=>{if(!H)return;let e=!1;return te(!0),(async()=>{try{let t=await g(H);e||T(t)}catch{}finally{e||te(!1)}})(),()=>{e=!0}},[H]);let ke=u((e,t)=>{f(n=>n.map(n=>n.id===e?{...n,...t}:n))}),Ae=u(e=>{f(t=>t.filter(t=>t.id!==e))}),je=u(()=>{f(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){k.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)});b(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),k.error(a(`multirun.launcher.toast.attachFailed`,{fileName:r.name}))}}n>0&&k.success(a(n===1?`multirun.launcher.toast.attachedSingle`:`multirun.launcher.toast.attachedPlural`,{count:n})),P.current&&(P.current.value=``)},Ne=e=>{b(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{L&&L!==F&&ce(L);let e=y.map(e=>({mime:e.mimeType,filename:e.filename,url:e.dataUrl})),r=w.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:s.trim(),groups:i,agent:_||void 0,worktreeBaseBranch:Te?Y:void 0,isolateRuns:Te,files:e.length>0?e:void 0,setupCommands:r.length>0?r:void 0},o=await Ee(a);o&&(o.firstSessionId&&x.getState().setCurrentSession(o.firstSessionId),n?.())}finally{C(!1)}}},Re=!!(s.trim()&&l.some(e=>e.prompt.trim()&&e.models.length>=1)&&Fe>=1&&pe&&!Ce&&(Z===!1||!Te||Y)),ze=w.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:p(`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)(ue,{children:[(0,$.jsx)(B,{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)(A,{name:`close`,className:`h-5 w-5`})})}),(0,$.jsx)(V,{children:(0,$.jsx)(`p`,{children:a(`multirun.launcher.actions.closeEsc`)})})]})})]}),(0,$.jsx)(ve,{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`)}),I.length>0?(0,$.jsxs)(se,{value:L??void 0,onValueChange:me,children:[(0,$.jsx)(re,{id:`multirun-project`,size:`lg`,className:`w-fit max-w-full`,children:fe?(0,$.jsx)(le,{children:lt(fe)}):(0,$.jsx)(le,{placeholder:a(`multirun.launcher.project.placeholder`)})}),(0,$.jsx)(oe,{fitContent:!0,children:I.map(e=>(0,$.jsx)(N,{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)(z,{id:`group-name`,value:s,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:pe,value:Y,onChange:ye,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)(M,{checked:ne,onChange:j,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:_,onChange:v,id:`multirun-agent`})]})]}),(0,$.jsxs)(Se,{open:E,onOpenChange:D,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)(A,{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)(A,{name:`arrow-down-s`,className:p(`h-3.5 w-3.5 text-muted-foreground/50 transition-transform duration-200 ml-auto`,E&&`rotate-180`)})]}),(0,$.jsx)(be,{children:(0,$.jsx)(`div`,{className:`pt-2 space-y-1.5`,children:ee?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground/70 px-2`,children:a(`multirun.launcher.setupCommands.loading`)}):(0,$.jsxs)($.Fragment,{children:[w.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,$.jsx)(z,{value:e,onChange:e=>{let n=[...w];n[t]=e.target.value,T(n)},placeholder:a(`multirun.launcher.setupCommands.commandPlaceholder`),className:`h-8 flex-1 font-mono text-xs`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>T(w.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)(A,{name:`close`,className:`h-3.5 w-3.5`})})]},`${e}-${t}`)),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>T([...w,``]),className:`flex items-center gap-1 typography-meta text-muted-foreground hover:text-foreground transition-colors px-1`,children:[(0,$.jsx)(A,{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:P,type:`file`,multiple:!0,className:`hidden`,onChange:Me,accept:`*/*`}),(0,$.jsxs)(ue,{children:[(0,$.jsx)(B,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>P.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)(A,{name:`attachment-2`,className:`h-3 w-3`}),a(`multirun.launcher.attachments.attach`)]})}),(0,$.jsx)(V,{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)(A,{name:`file-image`,className:`h-3 w-3 text-muted-foreground`}):(0,$.jsx)(A,{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)(A,{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)(A,{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)(A,{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)(m,{type:`button`,variant:`ghost`,size:`sm`,onClick:r,children:a(`multirun.launcher.actions.cancel`)}),(0,$.jsx)(m,{type:`submit`,size:`sm`,disabled:!Re||S,children:S?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}=d(),[c,l]=X.useState(!1),[f,p]=X.useState(``),[m,h]=X.useState(!1),[g,_]=X.useState(``),[v,y]=X.useState(!1),[b,x]=X.useState(``),S=X.useRef(null),C=X.useRef(null),w=X.useRef(null),T=X.useRef(null),E;t[0]!==n.id||t[1]!==n.models||t[2]!==a?(E=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]=E):E=t[3];let D=u(E),O;t[4]!==n.id||t[5]!==n.models||t[6]!==a?(O=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]=O):O=t[7];let k=u(O),ee;t[8]!==n.id||t[9]!==n.models||t[10]!==a?(ee=(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]=ee):ee=t[11];let te=u(ee),ne;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(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
|
-
`)?(p(t),l(!0)):l(!1);return}l(!1)},t[12]=ne):ne=t[12];let j=u(ne),M;t[13]!==n.id||t[14]!==a?(M=e=>{a(n.id,{prompt:e})},t[13]=n.id,t[14]=a,t[15]=M):M=t[15];let N=u(M),P;t[16]!==n.prompt||t[17]!==N||t[18]!==j?(P=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=_e(t,i===-1?r:i,r,`@${a}`);N(o.text),l(!1),p(``),requestAnimationFrame(()=>{let e=S.current;e&&(e.selectionStart=o.caret,e.selectionEnd=o.caret,e.focus()),j(o.text,o.caret)})},t[16]=n.prompt,t[17]=N,t[18]=j,t[19]=P):P=t[19];let re=u(P),ie;t[20]!==n.prompt||t[21]!==N||t[22]!==j?(ie=e=>{let t=n.prompt,r=S.current?.selectionStart??t.length,i=t.substring(0,r).lastIndexOf(`@`),a=_e(t,i===-1?r:i,r,`@${e}`);N(a.text),l(!1),p(``),requestAnimationFrame(()=>{let e=S.current;e&&(e.selectionStart=a.caret,e.selectionEnd=a.caret,e.focus()),j(a.text,a.caret)})},t[20]=n.prompt,t[21]=N,t[22]=j,t[23]=ie):ie=t[23];let ae=u(ie),oe;t[24]!==N||t[25]!==j?(oe=e=>{let t=`/${e.name} `;N(t),h(!1),_(``),y(!1),requestAnimationFrame(()=>{let e=S.current;e&&(e.focus(),e.selectionStart=e.value.length,e.selectionEnd=e.value.length),j(t,t.length)})},t[24]=N,t[25]=j,t[26]=oe):oe=t[26];let F=u(oe),se;t[27]!==n.prompt||t[28]!==N||t[29]!==j?(se=(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;N(s),y(!1),x(``),requestAnimationFrame(()=>{let e=S.current;e&&(e.selectionStart=c,e.selectionEnd=c,e.focus()),j(s,c)})},t[27]=n.prompt,t[28]=N,t[29]=j,t[30]=se):se=t[30];let ce=u(se),I;t[31]!==m||t[32]!==c||t[33]!==v?(I=e=>{if(m&&w.current&&(e.key===`Enter`||e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`Escape`||e.key===`Tab`)){e.preventDefault(),w.current.handleKeyDown(e.key);return}c&&C.current&&(e.key===`Enter`||e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`Escape`||e.key===`Tab`)&&(e.preventDefault(),C.current.handleKeyDown(e.key)),v&&T.current&&(e.key===`Enter`||e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`Escape`||e.key===`Tab`)&&(e.preventDefault(),T.current.handleKeyDown(e.key))},t[31]=m,t[32]=c,t[33]=v,t[34]=I):I=t[34];let L=u(I),le=r+1,R;t[35]!==s||t[36]!==le?(R=s(`multirun.launcher.groups.groupLabel`,{index:le}),t[35]=s,t[36]=le,t[37]=R):R=t[37];let z;t[38]===R?z=t[39]:(z=(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:R}),t[38]=R,t[39]=z);let B;t[40]!==i||t[41]!==n.id||t[42]!==o||t[43]!==s?(B=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)(A,{name:`close`,className:`h-3.5 w-3.5`})}),t[40]=i,t[41]=n.id,t[42]=o,t[43]=s,t[44]=B):B=t[44];let V;t[45]!==z||t[46]!==B?(V=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[z,B]}),t[45]=z,t[46]=B,t[47]=V):V=t[47];let ue;t[48]===s?ue=t[49]:(ue=s(`multirun.launcher.groups.prompt.label`),t[48]=s,t[49]=ue);let de;t[50]===ue?de=t[51]:(de=(0,$.jsx)(ct,{required:!0,children:ue}),t[50]=ue,t[51]=de);let fe=n.prompt,H;t[52]!==N||t[53]!==j?(H=e=>{let t=e.target.value;N(t);let n=e.target.selectionStart??t.length;j(t,n)},t[52]=N,t[53]=j,t[54]=H):H=t[54];let U;t[55]===s?U=t[56]:(U=s(`multirun.launcher.groups.prompt.placeholder`),t[55]=s,t[56]=U);let W;t[57]!==n.prompt||t[58]!==L||t[59]!==H||t[60]!==U?(W=(0,$.jsx)(ye,{ref:S,value:fe,onChange:H,onKeyDown:L,placeholder:U,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]=L,t[59]=H,t[60]=U,t[61]=W):W=t[61];let he;t[62]!==g||t[63]!==F||t[64]!==m?(he=m?(0,$.jsx)(pe,{ref:w,searchQuery:g,onCommandSelect:F,onClose:()=>h(!1),style:{left:0,top:`auto`,bottom:`calc(100% + 6px)`,marginBottom:0,maxWidth:`100%`}}):null,t[62]=g,t[63]=F,t[64]=m,t[65]=he):he=t[65];let G;t[66]!==ae||t[67]!==re||t[68]!==f||t[69]!==c?(G=c?(0,$.jsx)(ge,{ref:C,searchQuery:f,onFileSelect:re,onAgentSelect:ae,onClose:()=>l(!1),style:{left:0,top:`auto`,bottom:`calc(100% + 6px)`,marginBottom:0,maxWidth:`100%`}}):null,t[66]=ae,t[67]=re,t[68]=f,t[69]=c,t[70]=G):G=t[70];let K;t[71]!==ce||t[72]!==v||t[73]!==b?(K=v?(0,$.jsx)(me,{ref:T,searchQuery:b,onSnippetSelect:ce,onClose:()=>y(!1),style:{left:0,top:`auto`,bottom:`calc(100% + 6px)`,marginBottom:0,maxWidth:`100%`}}):null,t[71]=ce,t[72]=v,t[73]=b,t[74]=K):K=t[74];let q;t[75]!==W||t[76]!==he||t[77]!==G||t[78]!==K?(q=(0,$.jsxs)(`div`,{className:`relative`,children:[W,he,G,K]}),t[75]=W,t[76]=he,t[77]=G,t[78]=K,t[79]=q):q=t[79];let J;t[80]!==de||t[81]!==q?(J=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[de,q]}),t[80]=de,t[81]=q,t[82]=J):J=t[82];let Y;t[83]===s?Y=t[84]:(Y=s(`multirun.launcher.models.info`,{max:ot}),t[83]=s,t[84]=Y);let ve;t[85]===Y?ve=t[86]:(ve=(0,$.jsx)(st,{children:Y}),t[85]=Y,t[86]=ve);let be;t[87]===s?be=t[88]:(be=s(`multirun.launcher.models.label`),t[87]=s,t[88]=be);let xe;t[89]!==ve||t[90]!==be?(xe=(0,$.jsx)(ct,{required:!0,info:ve,children:be}),t[89]=ve,t[90]=be,t[91]=xe):xe=t[91];let Se;t[92]!==n.models||t[93]!==D||t[94]!==k||t[95]!==te?(Se=(0,$.jsx)(Re,{selectedModels:n.models,onAdd:D,onRemove:k,onUpdate:te,minModels:1,maxModels:ot}),t[92]=n.models,t[93]=D,t[94]=k,t[95]=te,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]!==V||t[101]!==J||t[102]!==Z?(Q=(0,$.jsxs)(`div`,{className:`rounded-lg border border-border p-3 space-y-3`,children:[V,J,Z]}),t[100]=V,t[101]=J,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};
|