@openchambery/web 2.1.10-beta.3 → 2.1.10-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/assets/AssistantView-b4ehjorA.js +3 -0
  2. package/dist/assets/{DiagramView-DI9Ebx_C.js → DiagramView-BaGHUm0-.js} +1 -1
  3. package/dist/assets/FadeInOnReveal-C-zbv53H.js +1 -0
  4. package/dist/assets/{MarkdownRenderer-CDneNNiI.js → MarkdownRenderer-CFVvfuhR.js} +2 -2
  5. package/dist/assets/MarkdownRendererImpl-jmqHuDQZ.js +10 -0
  6. package/dist/assets/{MarkstreamRendererImpl-BfxspazH.js → MarkstreamRendererImpl-DPOZ9qu8.js} +1 -1
  7. package/dist/assets/{MobileDetailNavigation-CKK6v7FY.js → MobileDetailNavigation-BIoz1Npe.js} +1 -1
  8. package/dist/assets/MobileResizableSheet-Bs4gAbDr.js +1 -0
  9. package/dist/assets/{MobileShareBridge-3USYeuqn.js → MobileShareBridge-J0mniNpy.js} +1 -1
  10. package/dist/assets/{MobileTabPageHeader-DCDm3ht4.js → MobileTabPageHeader-BCh8oQ6e.js} +1 -1
  11. package/dist/assets/{MultiRunWindow-UGOlLCjx.js → MultiRunWindow-DDlBWa0m.js} +1 -1
  12. package/dist/assets/{SettingsView-CEH-gWxO.js → SettingsView-D52TGtCB.js} +9 -9
  13. package/dist/assets/{SettingsWindow-rvAeDIbl.js → SettingsWindow-C2AHpt9S.js} +1 -1
  14. package/dist/assets/{TerminalView-D1zZxozG.js → TerminalView-J0dHlg0u.js} +1 -1
  15. package/dist/assets/ToolOutputDialog-GWRtb7zV.js +10 -0
  16. package/dist/assets/{appThemeRegistry-nMIsNW7b.js → appThemeRegistry-C8bq_-cg.js} +1 -1
  17. package/dist/assets/{fileMentionTouchSelection-DaZJsfwG.js → fileMentionTouchSelection-C8hotsbV.js} +1 -1
  18. package/dist/assets/{gitApi-BSKCuIuE.js → gitApi-etcbFClL.js} +1 -1
  19. package/dist/assets/insertionBoundaries-B42nWZi5.js +1 -0
  20. package/dist/assets/{main-Bwmb5RTq.js → main-DRvqRoHG.js} +2 -2
  21. package/dist/assets/{main-PkH0Hs7D.js → main-QSpW8-bh.js} +9 -9
  22. package/dist/assets/markdownTheme-Y4nBAXal.js +1 -0
  23. package/dist/assets/{mcpQueries-CG7M_F23.js → mcpQueries-CqXmLf7u.js} +1 -1
  24. package/dist/assets/{miniChat-A0XUm4NE.js → miniChat-CVVkf6qd.js} +2 -2
  25. package/dist/assets/mobile-C3YKq4-C.js +2 -0
  26. package/dist/assets/multirun-D8Ii4AuB.js +3 -0
  27. package/dist/assets/projectMeta-6tg2sJJq.js +1 -0
  28. package/dist/assets/{renderElectronMiniChatApp-iAsxSr3f.js → renderElectronMiniChatApp-B52l6XWX.js} +2 -2
  29. package/dist/assets/renderMobileApp-G6v2GZNC.js +28 -0
  30. package/dist/assets/{runtimeConfig-S5cf8TMp.js → runtimeConfig-DHT_B7ZP.js} +1 -1
  31. package/dist/assets/{runtimeEndpointReset-CU_9RUmN.js → runtimeEndpointReset-DyJRGL5Y.js} +6 -6
  32. package/dist/assets/sessionChangeSummary-BM6atDrR.js +1 -0
  33. package/dist/assets/{sessionLookup-bRxb556M.js → sessionLookup-CZ26KqA-.js} +1 -1
  34. package/dist/assets/speechSettingsQueries-8iZjJmXu.js +4 -0
  35. package/dist/assets/src-B1YRV5EQ.css +2 -0
  36. package/dist/assets/textarea-BAwBi2AO.js +1 -0
  37. package/dist/assets/{useAppFontEffects-CwhU0vu2.js → useAppFontEffects-BRHGEFRm.js} +51 -51
  38. package/dist/assets/{useDesktopWindowControlsLayout-BLr68GS8.js → useDesktopWindowControlsLayout-g2wk-J1P.js} +1 -1
  39. package/dist/assets/{useEffectiveDirectory-_UyYQwIy.js → useEffectiveDirectory-C5trBWhE.js} +1 -1
  40. package/dist/assets/{useMobileNavigationStore-DD_frNrb.js → useMobileNavigationStore-BnxWwj5z.js} +3 -3
  41. package/dist/assets/useWorkerHighlightedLines-D3P0ms_2.js +7 -0
  42. package/dist/index.html +3 -3
  43. package/dist/mini-chat.html +3 -3
  44. package/dist/mobile.html +3 -3
  45. package/package.json +1 -1
  46. package/dist/assets/AssistantView-CVC7X0Lx.js +0 -3
  47. package/dist/assets/FadeInOnReveal-CX8Bkq-l.js +0 -1
  48. package/dist/assets/MarkdownRendererImpl-Bl-Z2nHf.js +0 -10
  49. package/dist/assets/MobileWindowStack-DGLdgoGr.js +0 -1
  50. package/dist/assets/ToolOutputDialog-DAIUy5I5.js +0 -10
  51. package/dist/assets/insertionBoundaries-DIiKL4e-.js +0 -1
  52. package/dist/assets/markdownTheme-CV7_0QAL.js +0 -1
  53. package/dist/assets/mobile-CsfhjHAl.js +0 -2
  54. package/dist/assets/multirun-2JJr8VoR.js +0 -3
  55. package/dist/assets/projectMeta-cKz9O_kp.js +0 -1
  56. package/dist/assets/renderMobileApp-1A-brlHd.js +0 -28
  57. package/dist/assets/sessionChangeSummary-vEEPbusH.js +0 -1
  58. package/dist/assets/speechSettingsQueries-CypxKs6Q.js +0 -4
  59. package/dist/assets/src-Bud55RXh.css +0 -2
  60. package/dist/assets/textarea-D_tvJ-Lw.js +0 -1
  61. package/dist/assets/useWorkerHighlightedLines-uicGNlIu.js +0 -7
@@ -1,10 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t}from"./runtime-fetch-WgH0pROs.js";import{it as n,nt as r,rt as i}from"./vendor-base-ui-CdzJ6My_.js";import{_ as a}from"./useUIStore-CEqU9Ujv.js";import{n as o}from"./vendor-react-BP2cRVqX.js";import{a as s,i as c}from"./vendor-pierre-diffs-DPBtNDJ5.js";import{n as l}from"./vendor-reactuses-core-BpfIZ1tg.js";import{f as u,r as d,t as f}from"./button-CWSs9Baz.js";import{n as p,t as m}from"./useThemeSystem-8jhE4Zyk.js";import{n as h}from"./Icon-BCFeHDWx.js";import{n as g,t as _}from"./dialog-BMa16qrs.js";import{s as v,v as y}from"./image-loading-Bj11k4gM.js";import{t as b}from"./MobileWindowStack-DGLdgoGr.js";import{i as x,t as S}from"./appThemeRegistry-nMIsNW7b.js";import{n as C}from"./MarkdownRenderer-CDneNNiI.js";import{l as w}from"./markdown-worker-DFNZ3KJ_.js";import{n as T}from"./useEffectiveDirectory-_UyYQwIy.js";import{i as E,n as D}from"./markdownTheme-CV7_0QAL.js";import{t as O}from"./ImageLoadingPlaceholder-DEpMJXzV.js";import{_ as k,d as A,f as j,g as M,h as N,l as P,m as F,n as I,p as L,r as R,s as ee,t as z,u as B}from"./useWorkerHighlightedLines-uicGNlIu.js";import{t as V}from"./vendor-tanstack-react-virtual-B_EO--9t.js";var H=o(),U=e(n(),1),W=i(),G=80,te=20,ne=U.memo(e=>{let t=(0,H.c)(26),{lines:n,language:r,maxHeight:i,showLineNumbers:a,lineStyles:o}=e,s=i===void 0?`60vh`:i,c=a===void 0||a,{currentTheme:l}=p(),u;t[0]===l?u=t[1]:(u=D(l),t[0]=l,t[1]=u);let d=u,f;t[2]===n?f=t[3]:(f=n.map(ie).join(`
2
- `),t[2]=n,t[3]=f);let m=z(f,r);if(!(n.length>G)){let e=d,r;t[4]!==s||t[5]!==e?(r={...e,maxHeight:s,overflow:`auto`},t[4]=s,t[5]=e,t[6]=r):r=t[6];let i;if(t[7]!==m||t[8]!==o||t[9]!==n||t[10]!==c){let e;t[12]!==m||t[13]!==o||t[14]!==c?(e=(e,t)=>(0,W.jsx)(K,{line:e,html:m?.[t],showLineNumbers:c,style:o?.(e)},t),t[12]=m,t[13]=o,t[14]=c,t[15]=e):e=t[15],i=n.map(e),t[7]=m,t[8]=o,t[9]=n,t[10]=c,t[11]=i}else i=t[11];let a;return t[16]!==r||t[17]!==i?(a=(0,W.jsx)(`div`,{className:`typography-code font-mono w-full min-w-0`,style:r,children:i}),t[16]=r,t[17]=i,t[18]=a):a=t[18],a}let h;return t[19]!==m||t[20]!==o||t[21]!==n||t[22]!==s||t[23]!==c||t[24]!==d?(h=(0,W.jsx)(re,{lines:n,highlighted:m,syntaxVars:d,maxHeight:s,showLineNumbers:c,lineStyles:o}),t[19]=m,t[20]=o,t[21]=n,t[22]=s,t[23]=c,t[24]=d,t[25]=h):h=t[25],h});ne.displayName=`VirtualizedCodeBlock`;var re=U.memo(({lines:e,highlighted:t,syntaxVars:n,maxHeight:r,showLineNumbers:i,lineStyles:a})=>{let o=U.useRef(null),s=`min(${e.length*te}px, ${r})`,c=V({count:e.length,getScrollElement:()=>o.current,estimateSize:()=>te,overscan:20}),l=c.getVirtualItems();return(0,W.jsx)(`div`,{ref:o,className:`typography-code font-mono w-full min-w-0`,style:{...n,height:s,maxHeight:r,overflow:`auto`},children:(0,W.jsx)(`div`,{style:{height:c.getTotalSize(),position:`relative`},children:l.map(n=>{let r=e[n.index];return r?(0,W.jsx)(`div`,{"data-index":n.index,ref:c.measureElement,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${n.start}px)`},children:(0,W.jsx)(K,{line:r,html:t?.[n.index],showLineNumbers:i,style:a?.(r)})},n.index):null})})})});re.displayName=`VirtualizedRows`;var K=U.memo(e=>{let t=(0,H.c)(12),{line:n,html:r,showLineNumbers:i,style:a}=e,o;t[0]!==n.isInfo||t[1]!==n.lineNumber||t[2]!==i?(o=i&&(0,W.jsx)(`span`,{className:`w-10 flex-shrink-0 text-right pr-3 select-none border-r mr-3 -my-0.5 py-0.5`,style:{color:`var(--tools-edit-line-number)`,borderColor:`var(--tools-border)`},children:!n.isInfo&&n.lineNumber!=null?n.lineNumber:``}),t[0]=n.isInfo,t[1]=n.lineNumber,t[2]=i,t[3]=o):o=t[3];let s;t[4]!==r||t[5]!==n.isInfo||t[6]!==n.text?(s=(0,W.jsx)(`div`,{className:`flex-1 min-w-0`,children:n.isInfo?(0,W.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-muted-foreground/70 italic`,children:n.text}):r===void 0?(0,W.jsx)(`div`,{className:`whitespace-pre`,children:n.text}):(0,W.jsx)(`div`,{className:`whitespace-pre`,dangerouslySetInnerHTML:{__html:r}})}),t[4]=r,t[5]=n.isInfo,t[6]=n.text,t[7]=s):s=t[7];let c;return t[8]!==a||t[9]!==o||t[10]!==s?(c=(0,W.jsxs)(`div`,{className:`typography-code font-mono flex w-full min-w-0`,style:a,children:[o,s]}),t[8]=a,t[9]=o,t[10]=s,t[11]=c):c=t[11],c});K.displayName=`VirtualizedCodeBlock.Row`;function ie(e){return e.text}var ae=U.memo(function({jsonString:e,className:t,maxHeight:n=`100%`,initiallyExpandedDepth:r=2}){let{t:i}=u(),a=U.useRef(null),[o,s]=U.useState(null),c=U.useMemo(()=>{try{let t=e.trim();if(!t)return s(i(`jsonTreeView.error.emptyJson`)),null;let n=JSON.parse(t);return s(null),n}catch(e){return s(e instanceof Error?e.message:i(`jsonTreeView.error.invalidJson`)),null}},[e,i]),l=U.useCallback(()=>{a.current?.expandAll()},[]),d=U.useCallback(()=>{a.current?.collapseAll()},[]);return o?(0,W.jsx)(`div`,{className:t,children:(0,W.jsxs)(`div`,{className:`rounded-md border border-[var(--interactive-border)] bg-[var(--syntax-base-background)] p-4`,children:[(0,W.jsx)(`div`,{className:`mb-1 font-medium text-[var(--surface-foreground)]`,children:i(`jsonTreeView.error.invalidJsonTitle`)}),(0,W.jsx)(`div`,{className:`font-mono text-xs text-[var(--surface-mutedForeground)]`,children:o})]})}):c===null?null:(0,W.jsxs)(`div`,{className:t,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-[var(--interactive-border)] px-2 py-1`,children:[(0,W.jsxs)(f,{variant:`ghost`,size:`xs`,onClick:l,className:`gap-1 text-xs text-muted-foreground`,children:[(0,W.jsx)(h,{name:`arrow-down-s`,className:`h-3 w-3`}),i(`jsonTreeView.actions.expandAll`)]}),(0,W.jsxs)(f,{variant:`ghost`,size:`xs`,onClick:d,className:`gap-1 text-xs text-muted-foreground`,children:[(0,W.jsx)(h,{name:`arrow-up-s`,className:`h-3 w-3`}),i(`jsonTreeView.actions.collapseAll`)]})]}),(0,W.jsx)(`div`,{className:`bg-[var(--syntax-base-background)] py-1`,style:{maxHeight:n,overflow:`auto`},children:(0,W.jsx)(R,{ref:a,data:c,maxHeight:n,initiallyExpandedDepth:r})})]})}),q=class extends Error{key;params;constructor(e,t){super(e),this.name=`MermaidLoadFailure`,this.key=e,this.params=t}},oe=(e,t)=>new q(e,t),se=e=>e instanceof q,ce=e=>e+1,J=(e,t)=>e===t,le=e=>{let t=e.indexOf(`,`);if(t<0)throw oe(`chat.toolOutputDialog.mermaid.dataUrlMalformed`);let n=e.slice(0,t).toLowerCase(),r=e.slice(t+1);return n.includes(`;base64`)?atob(r):decodeURIComponent(r)},ue=e=>Promise.resolve().then(()=>le(e)),Y=1,X=56,Z=(e,t,n)=>Math.min(n,Math.max(t,e)),de=({isMobile:e,pointerType:t,cancelled:n,moved:r,suppressTap:i,targetWasCanvas:a,start:o,end:s,startScale:c,hasMultipleImages:l})=>{if(n||i)return`none`;let u={x:s.x-o.x,y:s.y-o.y},d=Math.hypot(u.x,u.y),f=t!==`mouse`;if(e&&f&&c<=1.01&&Math.abs(u.x)>=X&&Math.abs(u.x)>Math.abs(u.y)*1.2)return l?u.x<0?`next`:`previous`:`none`;let p=!r&&d<=10;return e&&f&&p||!e&&t===`mouse`&&p&&a?`close`:`none`},fe=(e,t)=>{if(e.width<=0||e.height<=0||t.width<=0||t.height<=0)return{width:1,height:1};let n=Math.min(t.width/e.width,t.height/e.height);return{width:Math.max(1,e.width*n),height:Math.max(1,e.height*n)}},pe=(e,t)=>{let n=t.minScale??Y,r=t.maxScale??5,i=Z(e.scale,n,r),a=Math.max(0,(t.image.width*i-t.viewport.width)/2),o=Math.max(0,(t.image.height*i-t.viewport.height)/2);return{scale:i,x:Z(e.x,-a,a),y:Z(e.y,-o,o)}},me=(e,t,n,r,i)=>{let a=Z(t,i.minScale??Y,i.maxScale??5),o=a/e.scale;return pe({scale:a,x:n.x-r.x-(n.x-r.x-e.x)*o,y:n.y-r.y-(n.y-r.y-e.y)*o},i)},he=(e,t,n)=>pe({...e,x:e.x+t.x,y:e.y+t.y},n),ge=(e,t,n,r,i,a)=>{let o=Z(r,a.minScale??Y,a.maxScale??5),s=o/e.scale;return pe({scale:o,x:n.x-i.x-(t.x-i.x-e.x)*s,y:n.y-i.y-(t.y-i.y-e.y)*s},a)},_e=500,ve=24,ye=(e,t={})=>{let n=t.target??(typeof document>`u`?null:document);if(!n)return()=>{};let r=t.durationMs??_e,i=t.maxDistance??ve,a=!0,o,s=()=>{a&&(a=!1,n.removeEventListener(`click`,c,!0),o!==void 0&&globalThis.clearTimeout(o))},c=t=>{let n=t;typeof n.clientX==`number`&&typeof n.clientY==`number`&&(Math.hypot(n.clientX-e.x,n.clientY-e.y)>i||(s(),t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()))};return n.addEventListener(`click`,c,!0),o=globalThis.setTimeout(s,r),s},be=(e,t,n={})=>{ye(e,n),t()},xe=e(r(),1);function Se(e,t,n,r,i){let a=e instanceof HTMLImageElement?e:e.querySelector(`img`);if(!a||!t.complete||!t.naturalWidth||!t.animate)return;let o=t.getBoundingClientRect(),s=a.getBoundingClientRect();if(!o.width||!o.height||!s.width||!s.height)return;let c=getComputedStyle(a),l=t.naturalWidth/t.naturalHeight,u=c.objectFit===`cover`?Math.max(s.width,s.height*l):Math.min(s.width,s.height*l),d=u/l,f=c.objectPosition.split(` `);if(!f.every(e=>e.endsWith(`%`)))return;let p=(s.width-u)*parseFloat(f[0])/100,m=(s.height-d)*parseFloat(f[1]??f[0])/100,h=s.left,g=s.top,_=s.right,v=s.bottom,y=c.borderRadius;for(let e=a.parentElement;e;e=e.parentElement){let t=getComputedStyle(e),n=e.getBoundingClientRect();[`hidden`,`clip`,`auto`,`scroll`].includes(t.overflowX)&&(h=Math.max(h,n.left),_=Math.min(_,n.right)),[`hidden`,`clip`,`auto`,`scroll`].includes(t.overflowY)&&(g=Math.max(g,n.top),v=Math.min(v,n.bottom)),n.width===s.width&&n.height===s.height&&t.borderRadius!==`0px`&&(y=t.borderRadius)}if(_<=h||v<=g)return;let b=document.createElement(`div`);b.dataset.mediaCropAnimation=``,b.setAttribute(`aria-hidden`,`true`),Object.assign(b.style,{position:`fixed`,left:`0`,top:`0`,overflow:`hidden`,pointerEvents:`none`,zIndex:`51`,contain:`paint`});let x=document.createElement(`img`);x.src=t.currentSrc||t.src,x.alt=``,Object.assign(x.style,{display:`block`,width:`${o.width}px`,height:`${o.height}px`,maxWidth:`none`,transformOrigin:`0 0`}),b.append(x),document.body.append(b);let S={transform:`translate(${o.left}px, ${o.top}px)`,width:`${o.width}px`,height:`${o.height}px`,borderRadius:`0px`},C={transform:`translate(${h}px, ${g}px)`,width:`${_-h}px`,height:`${v-g}px`,borderRadius:y},w={transform:`translate(0px, 0px) scale(1)`},T={transform:`translate(${s.left+p-h}px, ${s.top+m-g}px) scale(${u/o.width})`},E={duration:280,easing:`cubic-bezier(0.2, 0, 0, 1)`,fill:`both`},D=t.style.visibility;t.style.visibility=`hidden`;let O=[b.animate(r?[S,C]:[C,S],E),x.animate(r?[w,T]:[T,w],E),n.animate({opacity:r?[1,0]:[0,1]},E)],k=!1,A=(e=!1)=>{b.remove(),t.style.visibility=D,O.forEach((t,n)=>{(!e||n!==2)&&t.cancel()})};return Promise.all(O.map(e=>e.finished)).then(()=>{k||(A(r),i())},()=>{k||(A(),i())}),()=>{k=!0,A()}}function Ce(e,t,n,r,i=()=>{}){let a=e?.getBoundingClientRect(),o=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;if(!o&&e?.isConnected&&t instanceof HTMLImageElement&&n&&a?.width&&a.height&&a.bottom>0&&a.top<window.innerHeight&&a.right>0&&a.left<window.innerWidth){let a=Se(e,t,n,r,i);if(a)return a}if(!document.startViewTransition||o||!e?.isConnected||!t||!n||!a?.width||!a.height||a.bottom<=0||a.top>=window.innerHeight||a.right<=0||a.left>=window.innerWidth){if(!n?.animate||o)return i(),()=>{};let e=n.animate({opacity:r?[1,0]:[0,1]},{duration:150,fill:`forwards`}),t=!1;return e.finished.then(()=>{t||i()},()=>{}),()=>{t=!0,e.cancel()}}let s=e.style.viewTransitionName,c=t.style.viewTransitionName,l=n.style.visibility,u=!1,d=`oc-media-preview`;e.style.viewTransitionName=r?`none`:d,t.style.viewTransitionName=r?d:`none`,r||(n.style.visibility=`hidden`);let f=document.startViewTransition(()=>{u||(e.style.viewTransitionName=r?d:`none`,t.style.viewTransitionName=r?`none`:d,n.style.visibility=r?`hidden`:l)}),p=()=>{e.style.viewTransitionName=s,t.style.viewTransitionName=c,n.style.visibility=l};f.ready.catch(()=>{});let m=()=>{u||(p(),i())};return f.finished.then(m,m),()=>{u=!0,f.skipTransition(),p()}}function we(e){let t=(0,H.c)(12),{onClose:n,isMobile:r,size:i}=e,{t:a}=u(),o;t[0]!==r||t[1]!==i?(o=r?{top:`calc(var(--oc-safe-area-top, 0px) + 0.5rem)`,right:`calc(var(--oc-safe-area-right, 0px) + 0.75rem)`}:{top:i?`calc(50% - ${i.height/2}px + 0.5rem)`:`0.5rem`,right:i?`calc(50% - ${i.width/2}px + 0.5rem)`:`0.5rem`},t[0]=r,t[1]=i,t[2]=o):o=t[2];let s;t[3]===a?s=t[4]:(s=a(`dialog.common.actions.close`),t[3]=a,t[4]=s);let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,W.jsx)(h,{name:`close`,className:`size-5`}),t[5]=c):c=t[5];let l;t[6]!==n||t[7]!==s?(l=(0,W.jsx)(f,{variant:`mobileGlass`,size:`mobileIcon`,"aria-label":s,onClick:n,children:c}),t[6]=n,t[7]=s,t[8]=l):l=t[8];let d;return t[9]!==o||t[10]!==l?(d=(0,W.jsx)(`div`,{className:`absolute right-3 z-20`,style:o,children:l}),t[9]=o,t[10]=l,t[11]=d):d=t[11],d}function Te(e){let t=(0,H.c)(28),{open:n,title:r,kind:i,source:a,isMobile:o,onOpenChange:s,children:c}=e,u=U.useRef(null),d=U.useId(),f=U.useRef(null),p=U.useRef(!1),[m,h]=U.useState(!1),g;t[0]!==s||t[1]!==a?(g=()=>{if(p.current)return;p.current=!0,f.current?.();let e=u.current?.querySelector(`[data-preview-transition-target]`)??null;f.current=Ce(e?.dataset.previewReturn===`false`?void 0:a,e,u.current,!0,()=>{h(!0),s(!1)})},t[0]=s,t[1]=a,t[2]=g):g=t[2];let _=l(g),v=`${i}-preview`,y=n&&!m&&o,S;t[3]!==_||t[4]!==v||t[5]!==y?(S={id:v,active:y,layer:`overlay`,onBack:_,surfaceRef:u},t[3]=_,t[4]=v,t[5]=y,t[6]=S):S=t[6],x(S);let C,w;if(t[7]!==_||t[8]!==m||t[9]!==o||t[10]!==d||t[11]!==n||t[12]!==a?(C=()=>{if(!n){h(!1),p.current=!1;return}if(m)return;let e=u.current,t=document.activeElement instanceof HTMLElement?document.activeElement:null,r=o?b.add({id:d,onClose:_},document.body):void 0;return e?.querySelector(`button`)?.focus({preventScroll:!0}),f.current=Ce(a,e?.querySelector(`[data-preview-transition-target]`)??null,e,!1),()=>{f.current?.(),f.current=null,p.current=!1,r?.(),t?.isConnected&&t.focus({preventScroll:!0})}},w=[m,n,a,o,d,_],t[7]=_,t[8]=m,t[9]=o,t[10]=d,t[11]=n,t[12]=a,t[13]=C,t[14]=w):(C=t[13],w=t[14]),U.useLayoutEffect(C,w),!n||m||typeof document>`u`)return null;let T=o?`var(--oc-media-preview-background)`:`color-mix(in srgb, var(--oc-media-preview-background) ${i===`mermaid`?90:70}%, transparent)`,E;t[15]===T?E=t[16]:(E={backgroundColor:T,color:`var(--oc-media-preview-foreground)`},t[15]=T,t[16]=E);let D;t[17]===_?D=t[18]:(D=e=>{if(e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),_()),e.key!==`Tab`)return;let t=Array.from(e.currentTarget.querySelectorAll(`button:not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex="0"]`)),n=t[0],r=t.at(-1);e.shiftKey&&document.activeElement===n?(e.preventDefault(),r?.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n?.focus())},t[17]=_,t[18]=D);let O;t[19]!==c||t[20]!==_?(O=c(_),t[19]=c,t[20]=_,t[21]=O):O=t[21];let k;return t[22]!==i||t[23]!==O||t[24]!==E||t[25]!==D||t[26]!==r?(k=(0,xe.createPortal)((0,W.jsx)(`div`,{ref:u,role:`dialog`,"aria-modal":`true`,"aria-label":r,"data-media-preview":i,"data-page-scroll-lock":`true`,tabIndex:-1,className:`fixed inset-0 z-[80] overflow-hidden select-none`,style:E,onClick:Ee,onKeyDown:D,children:O}),document.body),t[22]=i,t[23]=O,t[24]=E,t[25]=D,t[26]=r,t[27]=k):k=t[27],k}function Ee(e){e.preventDefault(),e.stopPropagation()}var De=500,Oe=400,ke=(e,t)=>new q(e,t),Ae=e=>{let t=`h-3.5 w-3.5 flex-shrink-0`,n=e.toLowerCase();return n===`reasoning`?(0,W.jsx)(h,{name:`brain-ai-3`,className:t}):n===`image-preview`?(0,W.jsx)(h,{name:`file-image`,className:t}):n===`mermaid-preview`?(0,W.jsx)(h,{name:`file-list-2`,className:t}):n===`edit`||n===`multiedit`||n===`apply_patch`||n===`str_replace`||n===`str_replace_based_edit_tool`?(0,W.jsx)(h,{name:`pencil-ai`,className:t}):n===`write`||n===`create`||n===`file_write`||n===`read`||n===`view`||n===`file_read`||n===`cat`?(0,W.jsx)(h,{name:`file-pdf`,className:t}):n===`bash`||n===`shell`||n===`cmd`||n===`terminal`?(0,W.jsx)(h,{name:`terminal-box`,className:t}):n===`list`||n===`ls`||n===`dir`||n===`list_files`?(0,W.jsx)(h,{name:`folder-6`,className:t}):n===`search`||n===`grep`||n===`find`||n===`ripgrep`?(0,W.jsx)(h,{name:`search`,className:t}):n===`glob`?(0,W.jsx)(h,{name:`file-search`,className:t}):n===`fetch`||n===`curl`||n===`wget`||n===`webfetch`?(0,W.jsx)(h,{name:`global`,className:t}):n===`web-search`||n===`websearch`||n===`search_web`||n===`google`||n===`bing`||n===`duckduckgo`?(0,W.jsx)(h,{name:`search`,className:t}):n===`todowrite`||n===`todoread`?(0,W.jsx)(h,{name:`list-check-3`,className:t}):n.startsWith(`git`)?(0,W.jsx)(h,{name:`git-branch`,className:t}):(0,W.jsx)(h,{name:`tools`,className:t})},Q={style:{background:`transparent`,backgroundColor:`transparent`,fontSize:`inherit`}},je={download:!1,copy:!1,showPanZoomControls:!0},$=`
3
- [data-diff-header],
4
- [data-diff] {
5
- [data-separator] {
6
- height: 24px !important;
7
- }
8
- }
9
- `,Me={hunkLineCount:50,lineHeight:24,diffHeaderHeight:44,hunkSeparatorHeight:24,spacing:0},Ne=()=>{let e=(0,H.c)(22),t=m(),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=y(!1),e[0]=n):n=e[0];let r=n,i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=y(!0),e[1]=i):i=e[1];let a=i,o;e[2]===t?.availableThemes?o=e[3]:(o=()=>t?.availableThemes??[r,a],e[2]=t?.availableThemes,e[3]=o),t?.availableThemes;let s;e[4]===o?s=e[5]:(s=o(),e[4]=o,e[5]=s);let c=s,l=t?.lightThemeId??r.metadata.id,u=t?.darkThemeId??a.metadata.id,d;e[6]!==c||e[7]!==l?(d=c.find(e=>e.metadata.id===l)??r,e[6]=c,e[7]=l,e[8]=d):d=e[8];let f=d,p;e[9]!==c||e[10]!==u?(p=c.find(e=>e.metadata.id===u)??a,e[9]=c,e[10]=u,e[11]=p):p=e[11];let h=p,g,_;e[12]!==h||e[13]!==f?(g=()=>{S(f),S(h)},_=[h,f],e[12]=h,e[13]=f,e[14]=g,e[15]=_):(g=e[14],_=e[15]),U.useEffect(g,_);let v=t?.currentTheme.metadata.variant??`light`,b;e[16]!==h.metadata.id||e[17]!==f.metadata.id?(b={light:f.metadata.id,dark:h.metadata.id},e[16]=h.metadata.id,e[17]=f.metadata.id,e[18]=b):b=e[18];let x=v===`dark`?`dark`:`light`,C;return e[19]!==b||e[20]!==x?(C={theme:b,themeType:x},e[19]=b,e[20]=x,e[21]=C):C=e[21],C},Pe=()=>({width:typeof window<`u`?window.innerWidth:0,height:typeof window<`u`?window.innerHeight:0}),Fe=e=>{let t=(0,H.c)(3),[n,r]=U.useState(Pe),i,a;return t[0]===e?(i=t[1],a=t[2]):(i=()=>{if(!e||typeof window>`u`)return;let t=()=>{r(Pe())};return t(),window.addEventListener(`resize`,t),()=>{window.removeEventListener(`resize`,t)}},a=[e],t[0]=e,t[1]=i,t[2]=a),U.useEffect(i,a),n},Ie=({popup:e,onOpenChange:t,isMobile:n})=>{let{t:r}=u(),i=m(),a=T()??``,o=U.useMemo(()=>{let t=e.image;if(!t)return[];let n=Array.isArray(t.gallery)?t.gallery.filter(e=>!!e?.url):[];return n.length>0?n:[{url:t.url,mimeType:t.mimeType,filename:t.filename,size:t.size}]},[e.image]),[s,c]=U.useState(()=>{let t=e.image?.index??o.findIndex(t=>t.url===e.image?.url);return t>=0&&t<o.length?t:0}),p=e.previewSource instanceof HTMLImageElement?e.previewSource:void 0,g=p?.naturalWidth&&p.naturalHeight?{width:p.naturalWidth,height:p.naturalHeight}:null,[_,y]=U.useState(g),[b,x]=U.useState(!!g),S=e.open,C=Fe(e.open),w=U.useRef(null),D=U.useRef(null),A=U.useRef(null),j=U.useRef(null),M=U.useRef({scale:1,x:0,y:0}),N=U.useRef({image:{width:1,height:1},viewport:{width:1,height:1},maxScale:5}),P=U.useRef(new Map),F=U.useRef(null),I=U.useRef(null),L=U.useRef(null),R=U.useRef(null),ee=U.useRef(0);U.useEffect(()=>{e.open&&(ee.current=typeof performance<`u`?performance.now():Date.now())},[e.open]);let z=l(()=>(typeof performance<`u`?performance.now():Date.now())-ee.current<Oe),B=l(()=>{let e=F.current;e?.longPressTimer&&(clearTimeout(e.longPressTimer),e.longPressTimer=null)});U.useEffect(()=>{if(!e.open||o.length===0)return;let t=typeof e.image?.index==`number`?e.image.index:-1;if(t>=0&&t<o.length){c(t);return}let n=e.image?.url?o.findIndex(t=>t.url===e.image?.url):-1;c(n>=0?n:0)},[o,e.image?.index,e.image?.url,e.open]);let V=o[s]??o[0]??e.image,H=v(V?.url??``,a,`preview`),G=H.source||(V?.url===e.image?.url?p?.currentSrc:``)||``,te=`${H.key}\n${G}`,[ne,re]=U.useState(``),K=!!(H.error||ne===te),ie=l(()=>re(te)),ae=V?.filename||e.title,q=o.length>1,oe=l(()=>{let t=V?.url??e.image?.url??``;if(!t&&!G)return;let n=V?.mimeType||e.image?.mimeType,r=V?.filename||e.image?.filename||e.title,i=A.current;if(i&&i.naturalWidth>0){k(i,n||`image/png`).then(e=>{E({sourceUrl:t||G,displayUrl:G||i.currentSrc||i.src||void 0,filename:r,mimeType:n,effectiveDirectory:a,prefetchedBlob:e??void 0})});return}E({sourceUrl:t||G,displayUrl:G||void 0,filename:r,mimeType:n,effectiveDirectory:a})}),se=l(()=>{o.length<=1||c(e=>(e-1+o.length)%o.length)}),ce=l(()=>{o.length<=1||c(e=>(e+1)%o.length)}),J=U.useMemo(()=>{let e={width:Math.max(1,C.width*(n?1:.8)),height:Math.max(1,C.height*(n?1:.95))};return _?fe(_,e):e},[_,n,C.height,C.width]),le=U.useMemo(()=>({image:J,viewport:{width:Math.max(1,C.width),height:Math.max(1,C.height)},maxScale:5}),[J,C.height,C.width]),ue=l((e,t=!1)=>{let n=pe(e,N.current);M.current=n,R.current={transform:n,animate:t},!(L.current!==null||typeof window>`u`)&&(L.current=window.requestAnimationFrame(()=>{L.current=null;let e=R.current;R.current=null,e&&(A.current&&(A.current.style.transition=e.animate?`transform 180ms cubic-bezier(0.22, 1, 0.36, 1)`:`none`,A.current.style.transform=`translate3d(${e.transform.x}px, ${e.transform.y}px, 0) scale(${e.transform.scale})`),j.current&&(j.current.textContent=`${Math.round(e.transform.scale*100)}%`),w.current&&(w.current.style.cursor=e.transform.scale>1?`grab`:`zoom-in`))}))}),Y=l((e=!0)=>{ue({scale:1,x:0,y:0},e)}),X=l(()=>({x:N.current.viewport.width/2,y:N.current.viewport.height/2})),Z=l((e,t,n=!1)=>{ue(me(M.current,e,t,X(),N.current),n)}),_e=l(e=>{if(M.current.scale>1.01){Y(!0);return}Z(2,e,!0)}),ve=l(e=>{if(!(n||e.defaultPrevented)){if(e.key===`+`||e.key===`=`){e.preventDefault(),Z(M.current.scale*1.4,X(),!0);return}if(e.key===`-`||e.key===`_`){e.preventDefault(),Z(M.current.scale/1.4,X(),!0);return}if(e.key===`0`){e.preventDefault(),Y(!0);return}if(e.key===`ArrowLeft`&&q){e.preventDefault(),se();return}e.key===`ArrowRight`&&q&&(e.preventDefault(),ce())}});U.useEffect(()=>{if(e.open)return window.addEventListener(`keydown`,ve),()=>{window.removeEventListener(`keydown`,ve)}},[e.open]),U.useEffect(()=>{L.current!==null&&window.cancelAnimationFrame(L.current),L.current=null,R.current=null;let t=V?.url===e.image?.url?p:void 0;y(t?.naturalWidth&&t.naturalHeight?{width:t.naturalWidth,height:t.naturalHeight}:null),x(!!t?.naturalWidth),M.current={scale:1,x:0,y:0},P.current.clear(),F.current=null,I.current=null,A.current&&(A.current.style.transform=`translate3d(0, 0, 0) scale(1)`),j.current&&(j.current.textContent=`100%`)},[V?.url,G,e.image?.url,p]),U.useLayoutEffect(()=>{N.current=le;let e=pe(M.current,N.current);M.current=e,A.current&&(A.current.style.transition=`none`,A.current.style.transform=`translate3d(${e.x}px, ${e.y}px, 0) scale(${e.scale})`)},[le]),U.useEffect(()=>()=>{L.current!==null&&window.cancelAnimationFrame(L.current),L.current=null,R.current=null;let e=F.current;e?.longPressTimer&&(clearTimeout(e.longPressTimer),e.longPressTimer=null)},[]);let ye=l(e=>{if(n)return;e.preventDefault();let t={x:e.clientX,y:e.clientY},r=Math.exp(-e.deltaY*.002);Z(M.current.scale*r,t)});U.useEffect(()=>{let e=w.current;if(!(!S||n||!e))return e.addEventListener(`wheel`,ye,{passive:!1}),()=>e.removeEventListener(`wheel`,ye)},[n,S]);let xe=l(e=>{n||(e.preventDefault(),_e({x:e.clientX,y:e.clientY}))}),Se=l(e=>{e.preventDefault(),e.stopPropagation()}),Ce=l(e=>{e.pointerType!==`mouse`&&e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId);let t={x:e.clientX,y:e.clientY};if(P.current.set(e.pointerId,{point:t,pointerType:e.pointerType}),P.current.size===1){if(F.current={pointerId:e.pointerId,pointerType:e.pointerType,start:t,transform:M.current,moved:!1,targetWasCanvas:e.target===e.currentTarget,suppressTap:!1,longPressTimer:null,longPressTriggered:!1},e.pointerType!==`mouse`||M.current.scale<=1.01){let t=F.current;t.longPressTimer=setTimeout(()=>{!F.current||F.current.pointerId!==e.pointerId||F.current.moved||(F.current.longPressTriggered=!0,F.current.suppressTap=!0,oe())},De)}w.current&&M.current.scale>1&&(w.current.style.cursor=`grabbing`);return}B(),F.current&&(F.current.suppressTap=!0,F.current.longPressTriggered=!1);let n=Array.from(P.current.values()).slice(0,2).map(e=>e.point),r=n[1].x-n[0].x,i=n[1].y-n[0].y;I.current={distance:Math.max(1,Math.hypot(r,i)),midpoint:{x:(n[0].x+n[1].x)/2,y:(n[0].y+n[1].y)/2},transform:M.current},F.current&&(F.current.suppressTap=!0)}),Te=l(e=>{if(!P.current.has(e.pointerId))return;e.preventDefault();let t={x:e.clientX,y:e.clientY};if(P.current.set(e.pointerId,{point:t,pointerType:e.pointerType}),P.current.size>=2&&I.current){B();let e=Array.from(P.current.values()).slice(0,2).map(e=>e.point),t=e[1].x-e[0].x,n=e[1].y-e[0].y,r={x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},i=I.current.transform.scale*Math.hypot(t,n)/I.current.distance;ue(ge(I.current.transform,I.current.midpoint,r,i,X(),N.current));return}let n=F.current;if(!n||n.pointerId!==e.pointerId)return;let r={x:t.x-n.start.x,y:t.y-n.start.y};Math.hypot(r.x,r.y)>10&&(n.moved=!0,B()),n.transform.scale>1.01&&ue(he(n.transform,r,N.current))}),Ee=l((e,r)=>{let i=F.current,a=P.current.get(e.pointerId)?{x:e.clientX,y:e.clientY}:void 0;if(P.current.delete(e.pointerId),i?.pointerId===e.pointerId&&(B(),a&&!i.longPressTriggered)){let e=de({isMobile:n,pointerType:i.pointerType,cancelled:r,moved:i.moved||Math.hypot(a.x-i.start.x,a.y-i.start.y)>10,suppressTap:i.suppressTap,targetWasCanvas:i.targetWasCanvas,start:i.start,end:a,startScale:i.transform.scale,hasMultipleImages:q});if(e===`next`&&ce(),e===`previous`&&se(),e===`close`){if(z())return;if(n&&i.pointerType!==`mouse`){be(a,()=>t(!1));return}t(!1)}}if(P.current.size===1){let[e,t]=Array.from(P.current.entries())[0];F.current={pointerId:e,pointerType:t.pointerType,start:t.point,transform:M.current,moved:!1,targetWasCanvas:!1,suppressTap:!0,longPressTimer:null,longPressTriggered:!1},I.current=null}else P.current.size===0&&(F.current=null,I.current=null,w.current&&(w.current.style.cursor=M.current.scale>1?`grab`:`zoom-in`));e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)}),ke=l(e=>{e.preventDefault(),e.stopPropagation(),oe()}),Ae=l(e=>{let t=e.currentTarget;t.naturalWidth>0&&t.naturalHeight>0&&y(e=>e?.width===t.naturalWidth&&e.height===t.naturalHeight?e:{width:t.naturalWidth,height:t.naturalHeight}),x(!0)});if(!S||!V||typeof document>`u`)return null;let Q=i?.currentTheme.metadata.variant===`dark`,je=Q?`border-foreground/15 bg-foreground/10 text-foreground`:`border-background/15 bg-background/10 text-background`,$=Q?`text-foreground hover:bg-foreground/15 hover:text-foreground`:`text-background hover:bg-background/15 hover:text-background`;return(0,W.jsxs)(`div`,{ref:D,className:`absolute inset-0 overflow-hidden select-none`,tabIndex:-1,onClick:Se,children:[(0,W.jsx)(we,{onClose:()=>t(!1),isMobile:n,size:J}),(0,W.jsxs)(`div`,{ref:w,className:`absolute inset-0 flex items-center justify-center overflow-hidden touch-none [overscroll-behavior:none]`,onDoubleClick:n?void 0:xe,onContextMenu:ke,onPointerDown:Ce,onPointerMove:Te,onPointerUp:e=>Ee(e,!1),onPointerCancel:e=>Ee(e,!0),onLostPointerCapture:e=>Ee(e,!0),children:[!b&&!K&&(0,W.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center`,role:`status`,children:(0,W.jsx)(O,{className:`aspect-square w-64 max-w-[80vw] rounded-xl`})}),K?(0,W.jsx)(`p`,{role:`status`,className:`px-6 text-center typography-ui-label`,children:r(`filesView.error.readFileFailed`)}):(0,W.jsx)(`img`,{ref:A,"data-preview-transition-target":``,"data-preview-return":V?.url===e.image?.url,src:G||void 0,alt:ae??``,className:d(`block max-w-none object-contain will-change-transform`,b?`opacity-100`:`opacity-0`),style:{width:`${J.width}px`,height:`${J.height}px`},loading:`lazy`,draggable:!1,onLoad:Ae,onError:ie})]}),(0,W.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 z-10 flex justify-center px-2 pb-2`,children:(0,W.jsxs)(`div`,{className:d(`pointer-events-auto flex h-10 items-center gap-0.5 rounded-full border px-1 shadow-lg backdrop-blur-xl`,je),onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:[q&&(0,W.jsx)(f,{variant:`ghost`,size:`icon`,className:d(`size-8 rounded-full`,$),onClick:se,"aria-label":r(`chat.toolOutputDialog.image.previousAria`),title:r(`chat.toolOutputDialog.image.previousAria`),children:(0,W.jsx)(h,{name:`arrow-left-s`,className:`size-5`})}),q&&(0,W.jsxs)(`span`,{className:`min-w-10 px-1 text-center typography-micro tabular-nums opacity-80`,children:[s+1,` / `,o.length]}),q&&(0,W.jsx)(f,{variant:`ghost`,size:`icon`,className:d(`size-8 rounded-full`,$),onClick:ce,"aria-label":r(`chat.toolOutputDialog.image.nextAria`),title:r(`chat.toolOutputDialog.image.nextAria`),children:(0,W.jsx)(h,{name:`arrow-right-s`,className:`size-5`})}),q&&(0,W.jsx)(`span`,{className:`mx-0.5 h-4 w-px bg-current opacity-15`,"aria-hidden":`true`}),(0,W.jsx)(f,{variant:`ghost`,size:`icon`,className:d(`size-8 rounded-full`,$),onClick:()=>Z(M.current.scale/1.4,X(),!0),"aria-label":r(`chat.toolOutputDialog.image.zoomOutAria`),title:r(`chat.toolOutputDialog.image.zoomOutAria`),children:(0,W.jsx)(h,{name:`subtract`,className:`size-4`})}),(0,W.jsxs)(f,{variant:`ghost`,size:`sm`,className:d(`h-8 min-w-14 rounded-full px-2 tabular-nums`,$),onClick:()=>Y(!0),"aria-label":r(`chat.toolOutputDialog.image.resetZoomAria`),title:r(`chat.toolOutputDialog.image.resetZoomAria`),children:[(0,W.jsx)(h,{name:`restart`,className:`size-3.5`}),(0,W.jsx)(`span`,{ref:j,children:`100%`})]}),(0,W.jsx)(f,{variant:`ghost`,size:`icon`,className:d(`size-8 rounded-full`,$),onClick:()=>Z(M.current.scale*1.4,X(),!0),"aria-label":r(`chat.toolOutputDialog.image.zoomInAria`),title:r(`chat.toolOutputDialog.image.zoomInAria`),children:(0,W.jsx)(h,{name:`add`,className:`size-4`})})]})})]})},Le=U.memo(e=>{let t=(0,H.c)(7),{popup:n,diffViewMode:r,pierreThemeConfig:i}=e,a=n.content||``,o=r===`unified`?`unified`:`split`,s;t[0]!==i.theme||t[1]!==i.themeType||t[2]!==o?(s={diffStyle:o,diffIndicators:`none`,hunkSeparators:`line-info-basic`,lineDiffType:`none`,disableFileHeader:!0,maxLineDiffLength:1e3,expansionLineCount:20,overflow:`wrap`,theme:i.theme,themeType:i.themeType,unsafeCSS:$},t[0]=i.theme,t[1]=i.themeType,t[2]=o,t[3]=s):s=t[3];let l;return t[4]!==a||t[5]!==s?(l=(0,W.jsx)(`div`,{className:`typography-code`,children:(0,W.jsx)(c,{patch:a,metrics:Me,options:s,className:`block w-full`})}),t[4]=a,t[5]=s,t[6]=l):l=t[6],l});Le.displayName=`DialogUnifiedDiff`;var Re=U.memo(e=>{let t=(0,H.c)(29),{popup:n,pierreThemeConfig:r}=e,i;t[0]===n.content?i=t[1]:(i=P(n.content),t[0]=n.content,t[1]=i);let a=i,o=n.metadata?.input,c;t[2]===o?c=t[3]:(c=typeof o==`object`&&o?o:{},t[2]=o,t[3]=c);let l=c,u=typeof l.offset==`number`?l.offset:0,d=typeof l.file_path==`string`?l.file_path:typeof l.filePath==`string`?l.filePath:typeof l.path==`string`?l.path:`read-output`,f;t[4]===a.lines?f=t[5]:(f=a.lines.map(Ve).join(`
10
- `),t[4]=a.lines,t[5]=f);let p=f,m;t[6]!==d||t[7]!==n.language?(m=n.language||w(d)||`text`,t[6]=d,t[7]=n.language,t[8]=m):m=t[8];let h=m,g;t[9]===a.lines?g=t[10]:(g=a.lines.some(He),t[9]=a.lines,t[10]=g);let _=g,v;if(t[11]!==_||t[12]!==u||t[13]!==a.lines||t[14]!==a.type){v=[];let e=u;for(let t of a.lines){t.lineNumber!==null&&(e=t.lineNumber);let n=a.type===`file`&&!_&&t.lineNumber===null&&!t.isInfo,r=t.lineNumber??(n?e+1:null);typeof r==`number`&&(e=r),v.push({text:t.text,lineNumber:r,isInfo:t.isInfo})}t[11]=_,t[12]=u,t[13]=a.lines,t[14]=a.type,t[15]=v}else v=t[15];let y=v;if(a.type===`file`){let e=h||void 0,n;t[16]!==p||t[17]!==d||t[18]!==e?(n={name:d,contents:p,lang:e},t[16]=p,t[17]=d,t[18]=e,t[19]=n):n=t[19];let i;t[20]!==r.theme||t[21]!==r.themeType?(i={disableFileHeader:!0,overflow:`wrap`,theme:r.theme,themeType:r.themeType},t[20]=r.theme,t[21]=r.themeType,t[22]=i):i=t[22];let a;return t[23]!==n||t[24]!==i?(a=(0,W.jsx)(s,{file:n,options:i,className:`block w-full`}),t[23]=n,t[24]=i,t[25]=a):a=t[25],a}let b;return t[26]!==y||t[27]!==h?(b=(0,W.jsx)(ne,{lines:y,language:h,maxHeight:`70vh`}),t[26]=y,t[27]=h,t[28]=b):b=t[28],b});Re.displayName=`DialogReadContent`;var ze=({popup:e,onOpenChange:n,isMobile:r})=>{let{t:i}=u(),a=m(),o=U.useMemo(()=>a?.currentTheme.metadata.variant===`dark`?a.currentTheme:a?.availableThemes.find(e=>e.metadata.id===a.darkThemeId&&e.metadata.variant===`dark`)??y(!0),[a?.currentTheme,a?.availableThemes,a?.darkThemeId]),[s,c]=U.useState(e.mermaid?.source||``),[l,d]=U.useState(e.mermaid?.source?`ready`:`idle`),[f,p]=U.useState(``),g=U.useRef(0),_=U.useCallback(e=>{let t=e.trim();if(!t.toLowerCase().startsWith(`file://`))return null;let n=e=>{if(!e||/[\0\r\n]/.test(e))return!1;let t=e.replace(/\\/g,`/`);return t.split(`/`).filter(Boolean).includes(`..`)?!1:t.startsWith(`/`)?!0:/^[A-Za-z]:\//.test(t)},r=e=>e.replace(/%([0-9A-Fa-f]{2})/g,(e,t)=>{let n=Number.parseInt(t,16);return Number.isFinite(n)?String.fromCharCode(n):`%${t}`});if(typeof URL.canParse==`function`&&URL.canParse(t)){let e=r(new URL(t).pathname||``);return/^\/[A-Za-z]:\//.test(e)&&(e=e.slice(1)),n(e)?e:null}let i=t.replace(/^file:\/\//i,``),a=r(i);return n(a)?a:n(i)?i:null},[]),v=U.useCallback(async()=>{let n=e.mermaid,r=ce(g.current);if(g.current=r,!n?.url){d(`error`),p(i(`chat.toolOutputDialog.mermaid.missingSource`));return}if(n.source){c(n.source),d(`ready`),p(``);return}d(`loading`),p(``);let a;if(n.url.startsWith(`data:`))a=ue(n.url);else if(n.url.toLowerCase().startsWith(`file://`)){let e=_(n.url);a=e?t(`/api/fs/raw`,{query:{path:e}}).then(e=>e.ok?e.text():Promise.reject(ke(`chat.toolOutputDialog.mermaid.readFileFailedWithStatus`,{status:e.status}))):Promise.reject(ke(`chat.toolOutputDialog.mermaid.invalidLocalPath`))}else{let e=typeof URL.canParse==`function`&&URL.canParse(n.url,window.location.origin)?new URL(n.url,window.location.origin):null;a=!e||e.protocol!==`http:`&&e.protocol!==`https:`?Promise.reject(ke(`chat.toolOutputDialog.mermaid.unsupportedUrlProtocol`)):fetch(e.toString()).then(e=>e.ok?e.text():Promise.reject(ke(`chat.toolOutputDialog.mermaid.loadFailedWithStatus`,{status:e.status})))}await a.then(e=>{J(g.current,r)&&(c(e),d(`ready`))}).catch(e=>{J(g.current,r)&&(d(`error`),p(se(e)?i(e.key,e.params):i(`chat.toolOutputDialog.mermaid.loadFailed`)))})},[_,e.mermaid,i]);U.useEffect(()=>{!e.open||!e.mermaid||v()},[v,e.mermaid,e.open]);let b=`\`\`\`mermaid\n${s}\n\`\`\``;return!e.open||typeof document>`u`?null:(0,W.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,onClick:e=>{e.target===e.currentTarget&&n(!1)},children:(0,W.jsxs)(`div`,{"data-mermaid-preview":`true`,"data-preview-transition-target":``,className:`relative flex min-h-0 flex-col overflow-hidden`,style:{width:r?`100%`:`80%`,height:r?`100%`:`95%`},onMouseDown:e=>e.stopPropagation(),children:[(0,W.jsx)(we,{onClose:()=>n(!1),isMobile:r}),(0,W.jsx)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:(0,W.jsxs)(`div`,{className:`h-full overflow-hidden`,children:[l===`loading`&&(0,W.jsxs)(`div`,{className:`h-full min-h-28 flex items-center justify-center gap-2 text-muted-foreground typography-meta`,children:[(0,W.jsx)(h,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),(0,W.jsx)(`span`,{children:i(`chat.toolOutputDialog.mermaid.loading`)})]}),l===`error`&&(0,W.jsxs)(`div`,{className:`rounded-xl border p-3 space-y-3`,style:{backgroundColor:`var(--status-error-background)`,borderColor:`var(--status-error-border)`},children:[(0,W.jsx)(`p`,{className:`typography-markdown`,style:{color:`var(--status-error)`},children:f||i(`chat.toolOutputDialog.mermaid.renderFailed`)}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>{v()},className:`px-3 py-1.5 rounded-lg typography-meta border transition-colors hover:bg-[var(--interactive-hover)]`,style:{borderColor:`var(--interactive-border)`,color:`var(--surface-foreground)`},children:i(`chat.toolOutputDialog.mermaid.retry`)})]}),l===`ready`&&(0,W.jsx)(`div`,{className:`h-full`,children:(0,W.jsx)(C,{content:b,variant:`tool`,allowMermaidWheelEvents:!0,className:`markdown-mermaid-fullscreen h-full`,mermaidControls:je,mermaidTheme:o,enableFileReferences:!1})})]})})]})})},Be=e=>{let t=(0,H.c)(51),{popup:n,onOpenChange:r,isMobile:i}=e,{t:o}=u(),[c,l]=U.useState(`unified`),f=Ne(),p;t[0]===n.open?p=t[1]:(p=()=>{n.open&&l(`unified`)},t[0]=n.open,t[1]=p);let m;if(t[2]!==n.open||t[3]!==n.title?(m=[n.open,n.title],t[2]=n.open,t[3]=n.title,t[4]=m):m=t[4],U.useEffect(p,m),n.image||n.mermaid){let e=n.image?`image`:`mermaid`,a;t[5]!==i||t[6]!==n?(a=e=>n.image?(0,W.jsx)(Ie,{popup:n,onOpenChange:e,isMobile:i}):(0,W.jsx)(ze,{popup:n,onOpenChange:e,isMobile:i}),t[5]=i,t[6]=n,t[7]=a):a=t[7];let o;return t[8]!==i||t[9]!==r||t[10]!==n.open||t[11]!==n.previewSource||t[12]!==n.title||t[13]!==e||t[14]!==a?(o=(0,W.jsx)(Te,{open:n.open,title:n.title,kind:e,source:n.previewSource,isMobile:i,onOpenChange:r,children:a}),t[8]=i,t[9]=r,t[10]=n.open,t[11]=n.previewSource,t[12]=n.title,t[13]=e,t[14]=a,t[15]=o):o=t[15],o}let v=n.open,y=i?`w-[95vw] max-w-[95vw]`:`max-w-5xl`,b=i?`[&>button]:right-1`:`[&>button]:top-2.5 [&>button]:right-4`,x;t[16]!==y||t[17]!==b?(x=d(`overflow-hidden flex flex-col min-h-0 pt-3 pb-4 px-4 gap-1`,`[&>button]:top-1.5`,y,b),t[16]=y,t[17]=b,t[18]=x):x=t[18];let S;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(S={maxHeight:`90vh`},t[19]=S):S=t[19];let T;t[20]===n.metadata?T=t[21]:(T=n.metadata?.tool?Ae(n.metadata.tool):(0,W.jsx)(h,{name:`tools`,className:`h-3.5 w-3.5 text-foreground flex-shrink-0`}),t[20]=n.metadata,t[21]=T);let E;t[22]===n.title?E=t[23]:(E=(0,W.jsx)(`span`,{className:`break-words flex-1 leading-tight`,children:n.title}),t[22]=n.title,t[23]=E);let D;t[24]!==c||t[25]!==n.isDiff?(D=n.isDiff&&(0,W.jsx)(I,{mode:c,onModeChange:l,className:`mr-8 flex-shrink-0`}),t[24]=c,t[25]=n.isDiff,t[26]=D):D=t[26];let O;t[27]!==D||t[28]!==T||t[29]!==E?(O=(0,W.jsx)(`div`,{className:`flex-shrink-0 pb-1`,children:(0,W.jsxs)(`div`,{className:`flex items-start gap-2 text-foreground typography-ui-header font-semibold`,children:[T,E,D]})}),t[27]=D,t[28]=T,t[29]=E,t[30]=O):O=t[30];let k;t[31]!==f||t[32]!==n.metadata?(k=n.metadata?.input&&typeof n.metadata.input==`object`&&Object.keys(n.metadata.input).length>0&&n.metadata?.tool!==`todowrite`&&n.metadata?.tool!==`todoread`&&n.metadata?.tool!==`apply_patch`?(()=>{let e=n.metadata,t=e.input,r=e=>{let n=t[e];return typeof n==`string`?n:typeof n==`number`?String(n):null};return(0,W.jsxs)(`div`,{className:`border-b border-border/20 p-4 -mx-3`,children:[(0,W.jsx)(`div`,{className:`typography-markdown font-medium text-muted-foreground mb-2 px-3`,children:e.tool===`bash`||e.tool===`shell`?`Command:`:e.tool===`task`||e.tool===`subagent`?`Task Details:`:`Input:`}),(e.tool===`bash`||e.tool===`shell`)&&r(`command`)?(0,W.jsx)(`div`,{className:`tool-input-surface bg-transparent rounded-xl border border-border/20 mx-3`,children:(0,W.jsx)(M,{language:`bash`,code:r(`command`),style:a.getPopupStyles(),codeStyle:Q.style,wrap:!0})}):(e.tool===`task`||e.tool===`subagent`)&&r(`prompt`)?(0,W.jsxs)(`div`,{className:`tool-input-surface bg-transparent rounded-xl border border-border/20 font-mono whitespace-pre-wrap text-foreground/90 mx-3`,style:a.getPopupStyles(),children:[r(`description`)?`Task: ${r(`description`)}\n`:``,r(`subagent_type`)||r(`agent`)?`Agent Type: ${r(`subagent_type`)||r(`agent`)}\n`:``,`Instructions:\n${r(`prompt`)}`]}):e.tool===`write`&&r(`content`)?(0,W.jsx)(`div`,{className:`tool-input-surface bg-transparent rounded-xl border border-border/20 mx-3`,children:(0,W.jsx)(s,{file:{name:r(`filePath`)||r(`file_path`)||`new-file`,contents:r(`content`),lang:w(r(`filePath`)||r(`file_path`)||``)||void 0},options:{disableFileHeader:!0,overflow:`wrap`,theme:f.theme,themeType:f.themeType},className:`block w-full`})}):(0,W.jsx)(`div`,{className:`tool-input-surface bg-transparent rounded-xl border border-border/20 font-mono whitespace-pre-wrap text-foreground/90 mx-3`,style:a.getPopupStyles(),children:ee(t,e.tool)})]})})():null,t[31]=f,t[32]=n.metadata,t[33]=k):k=t[33];let P;t[34]!==c||t[35]!==i||t[36]!==f||t[37]!==n||t[38]!==o?(P=n.isDiff?(0,W.jsx)(Le,{popup:n,diffViewMode:c,pierreThemeConfig:f}):n.content?(0,W.jsx)(`div`,{className:`p-4`,children:(()=>{let e=n.metadata?.tool;return e===`todowrite`||e===`todoread`?L(n.content)||(0,W.jsx)(M,{language:`json`,code:n.content,style:a.getPopupContainerStyles(),codeStyle:Q.style,wrap:!0}):e===`list`?j(n.content)||(0,W.jsx)(`pre`,{className:`typography-markdown bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap`,children:n.content}):e===`grep`?A(n.content,i)||(0,W.jsx)(`pre`,{className:`typography-code bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap`,children:n.content}):e===`glob`?B(n.content,i)||(0,W.jsx)(`pre`,{className:`typography-code bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap`,children:n.content}):e===`task`||e===`subagent`||e===`reasoning`?(0,W.jsx)(`div`,{className:e===`reasoning`?`text-muted-foreground/70`:``,children:(0,W.jsx)(C,{content:n.content,variant:`tool`})}):e===`web-search`||e===`websearch`||e===`search_web`?F(n.content)||(0,W.jsx)(M,{language:`text`,code:n.content,style:a.getPopupContainerStyles(),codeStyle:Q.style,wrap:!0}):e===`read`?(0,W.jsx)(Re,{popup:n,pierreThemeConfig:f}):(n.content?N(n.content):{data:null,isJson:!1}).isJson?(0,W.jsx)(ae,{jsonString:n.content,initiallyExpandedDepth:3,maxHeight:`70vh`}):(0,W.jsx)(M,{language:n.language||`text`,code:n.content,style:a.getPopupContainerStyles(),codeStyle:Q.style,wrap:!0})})()}):(0,W.jsxs)(`div`,{className:`p-8 text-muted-foreground typography-ui-header`,children:[(0,W.jsx)(`div`,{className:`mb-2`,children:o(`chat.toolOutputDialog.commandCompleted`)}),(0,W.jsx)(`div`,{className:`typography-meta`,children:o(`chat.toolOutputDialog.noOutputProduced`)})]}),t[34]=c,t[35]=i,t[36]=f,t[37]=n,t[38]=o,t[39]=P):P=t[39];let R;t[40]!==k||t[41]!==P?(R=(0,W.jsx)(`div`,{className:`flex-1 min-h-0 rounded-xl border border-border/30 bg-muted/10 overflow-hidden`,children:(0,W.jsxs)(`div`,{className:`tool-output-surface h-full max-h-[75vh] overflow-y-auto px-3 pr-4`,children:[k,P]})}),t[40]=k,t[41]=P,t[42]=R):R=t[42];let z;t[43]!==O||t[44]!==R||t[45]!==x?(z=(0,W.jsxs)(g,{className:x,style:S,children:[O,R]}),t[43]=O,t[44]=R,t[45]=x,t[46]=z):z=t[46];let V;return t[47]!==r||t[48]!==n.open||t[49]!==z?(V=(0,W.jsx)(_,{open:v,onOpenChange:r,children:z}),t[47]=r,t[48]=n.open,t[49]=z,t[50]=V):V=t[50],V};function Ve(e){return e.text}function He(e){return e.lineNumber!==null}export{Be as default};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n}from"./runtime-switch-CMiMO5Yj.js";import{Mn as r,N as i,P as a,h as o,ln as s,m as c}from"./persistence-BKszKaoQ.js";import{a as l,i as u,r as d}from"./vendor-zustand-o69pgTEK.js";import{it as f,rt as p}from"./vendor-base-ui-CdzJ6My_.js";import{B as m,Ct as h,M as g,Mt as _}from"./platform-CgwxwfA4.js";import{b as v,n as ee,x as y}from"./useUIStore-CEqU9Ujv.js";import{n as b}from"./vendor-react-BP2cRVqX.js";import{s as x}from"./vendor-tanstack-react-query-CdqCAt40.js";import{n as S}from"./vendor-reactuses-core-BpfIZ1tg.js";import{f as te,r as C,u as ne}from"./button-CWSs9Baz.js";import{Bt as re,Dr as ie,Pr as ae,S as oe,Un as w,Ya as T,cn as se,ct as ce,d as E,do as le,fo as D,ht as ue,lt as de,ut as fe,vn as O,wa as k,y as pe,za as me}from"./useMobileNavigationStore-DD_frNrb.js";import{t as he}from"./AgentAvatar-CSTBp5FT.js";import{n as A}from"./Icon-BCFeHDWx.js";import{g as ge,v as _e}from"./gitApi-BSKCuIuE.js";import{f as ve,o as j}from"./projectMeta-cKz9O_kp.js";import{n as ye}from"./textarea-D_tvJ-Lw.js";import{c as be,d as M,l as N,n as xe,r as Se,t as Ce}from"./fileMentionTouchSelection-DaZJsfwG.js";var we=(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=w([...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)},Te=(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&&e.agentName===r.agentName}),Ee=(e,t)=>e.highlightedIndex===t.highlightedIndex&&Te(e.rows,t.rows),De=(e,t)=>Te(e,t)?e:t.slice(),Oe=(e,t,n)=>{e&&(t.current&&Ee(t.current,n)||(t.current=n,e(n)))},ke=(e,t)=>{t.current=null,e?.({rows:[],highlightedIndex:0})},P=e(f(),1),F=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},I=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,L=(e,t)=>{let n=F(t),r=F(e);if(!n||!r)return!1;let i=I(n),a=I(r);return a===i||a.startsWith(`${i}/`)},Ae=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t=F(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=>F(e)).filter(e=>L(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>F(e)).filter(e=>L(e,t)))):[],s=typeof i.selectedPath==`string`?F(i.selectedPath):null,c=s&&L(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},R=(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},z=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},je=l()(d(u((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=F((t||``).trim()),a=F((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!L(a,i)||e(e=>{let t=e.byRoot[i],n=z(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:R({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=F((t||``).trim()),i=F((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=I(i),a=e=>I(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:R({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=F((t||``).trim()),i=F((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=I(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=I(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:R({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=F((t||``).trim()),i=F((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=I(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=I(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:R({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=F((t||``).trim()),a=n?F(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!L(a,i)||e(e=>{let t=e.byRoot[i],n=z(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:R({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=F((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=F((t||``).trim()),i=F((n||``).trim());!r||!i||!L(i,r)||e(e=>{let t=e.byRoot[r],n=z(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:R({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=F((t||``).trim()),i=F((n||``).trim());!r||!i||!L(i,r)||e(e=>{let t=e.byRoot[r],n=z(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:R({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=F((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>F((e||``).trim())).filter(e=>e&&L(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=z(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:R({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,...o]}},20)}})}}),{name:`files-view-tabs-store`,version:2,storage:v(),migrate:e=>{if(!e||typeof e!=`object`)return{byRoot:{}};let t=e.byRoot;return{byRoot:Ae(t)}},partialize:e=>({byRoot:Ae(e.byRoot)})}),{name:`files-view-tabs-store`})),B=b(),Me=(e,t)=>{let n=(0,B.c)(4),r=t===void 0?200:t,[i,a]=P.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]),P.useEffect(o,s),i},Ne=()=>{let e=(0,B.c)(17),t=E(Pe),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=oe(r),a=E(V),o=E(H),s=D(U),c=D(Fe),l=h(Ie);if(t){let r;e[2]===i?r=e[3]:(r=pe(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 Pe(e){return e.currentSessionId}function V(e){return e.worktreeMetadata}function H(e){return e.newSessionDraft}function U(e){return e.activeProjectId}function Fe(e){return e.projects}function Ie(e){return e.currentDirectory}var W=p(),Le=`bg-transparent font-[inherit] text-[var(--primary-base)]`,G=(e,t)=>{let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase();if(!r.includes(n))return e;let i=[],a=0,o=r.indexOf(n);for(;o!==-1;)o>a&&i.push(e.slice(a,o)),i.push((0,W.jsx)(`mark`,{className:Le,children:e.slice(o,o+n.length)},`${o}-${n}`)),a=o+n.length,o=r.indexOf(n,a);return a<e.length&&i.push(e.slice(a)),i},Re=P.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSkillSelect:r,onSessionSelect:o,onClose:s,style:c,onRowsChange:l},u)=>{let{t:d}=te(),f=Ne()??``,p=E(e=>e.currentSessionId),m=ae(e=>e.activeSessions),h=re({enabled:!!o}),g=D(e=>e.activeProjectId),v=D(e=>e.projects),y=P.useMemo(()=>v.find(e=>e.id===g)?.path??null,[g,v]),b=P.useMemo(()=>{let e=y||f;return e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null},[y,f]),x=je(e=>b?e.byRoot[b]:void 0),oe=k(e=>e.agents),w=_(e=>e.searchFiles),se=Me(e,180),le=a(),O=i(),[pe,ge]=P.useState([]),[_e,ve]=P.useState(!1),[j,M]=P.useState(0),N=P.useRef(0),we=P.useRef({query:e,directory:f,ids:[]}),[Te,Ee]=P.useState(360),[De,F]=P.useState({}),[I,L]=P.useState({}),Ae=P.useRef([]),R=P.useRef([]),z=P.useRef([]),B=P.useRef(null),Pe=P.useRef(null),V=P.useRef(null);V.current||=Ce();let H=ee(e=>e.isMobile),U=(e??``).trim(),Fe=T({directory:f||null}),Ie=P.useMemo(()=>r?Fe.data??[]:[],[r,Fe.data]),Le=P.useMemo(()=>{if(!b||!x)return[];let e=[x.selectedPath,...x.openPaths.slice().reverse()].filter(e=>typeof e==`string`&&e.length>0),t=new Set,n=[];for(let r of e){if(t.has(r))continue;t.add(r);let e=r.replace(/\\/g,`/`),i=e.split(`/`).filter(Boolean).pop()||e,a=e.startsWith(`${b}/`)?e.slice(b.length+1):e;n.push({name:i,path:e,relativePath:a,extension:i.includes(`.`)?i.split(`.`).pop()?.toLowerCase():void 0})}return fe(n,U,{limit:6})},[U,b,x]),Re=P.useMemo(()=>n?me(oe).filter(e=>e.mode!==`primary`):[],[oe,n]),ze=P.useMemo(()=>o?ce({sessions:ie(m,h),currentSessionId:p,searchQuery:U}):[],[m,p,h,U,o]),K=Le,Be=pe,q=P.useMemo(()=>be({skills:Ie,agents:Re,sessions:ze,recentFiles:K,pathHits:Be,searchQuery:U,untitledSession:d(`chat.fileMentionAutocomplete.untitledSession`),sessionBadge:d(`chat.fileMentionAutocomplete.sessionType`),skillBadge:d(`chat.commandAutocomplete.badge.skill`)}),[Ie,Re,ze,K,Be,U,d]);P.useEffect(()=>{let e=e=>{let t=e.target;!t||!B.current||B.current.contains(t)||s()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[s]),P.useEffect(()=>{if(!f){ge([]);return}let e=(se??``).trim(),t=ue(e);if(!t){ge([]);return}let n=!1;ve(!0);let r={includeHidden:le,respectGitignore:!O};return Promise.all([w(f,t,80,{...r,type:`file`}),w(f,t,40,{...r,type:`directory`})]).then(([t,r])=>{if(n)return;let i=new Set(Le.map(e=>e.path));ge(de({files:t,directories:r,query:e,excludePaths:i,limit:20}))}).catch(()=>{n||ge([])}).finally(()=>{n||ve(!1)}),()=>{n=!0}},[f,se,Le,w,le,O]),P.useLayoutEffect(()=>{let t=we.current,n=t.ids[N.current],r=t.query===e&&t.directory===f?Math.max(0,q.findIndex(e=>e.id===n)):0;we.current={query:e,directory:f,ids:q.map(e=>e.id)},N.current=r,M(r)},[q,e,f]),P.useEffect(()=>{F({}),L({})},[q]),P.useEffect(()=>{Ae.current[j]?.scrollIntoView({block:`nearest`})},[j]),P.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};R.current.forEach((n,r)=>{if(!n)return;let i=z.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}}),F(e),L(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[q]),P.useEffect(()=>{let e=R.current[j];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&Ee(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[j]);let Ve=S(e=>{t(e)}),He=S(e=>{n?.(e)}),Ue=S(e=>{o?.(e)}),We=S(e=>{r?.(e)}),Ge=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&V.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&V.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(V.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>V.current?.pointerCancel(),onClick:()=>{V.current?.click(t)},onMouseMove:()=>{N.current=e,M(e)}}),J=e=>{let t=q.length;if(t===0)return;let n=(e%t+t)%t,r=q[n];if(r.agentName!==void 0){He(r.agentName);return}if(r.id.startsWith(`skill:`)){let e=Ie.find(e=>r.id===`skill:${e.name}-${e.scope}`);e&&We(e);return}if(r.id.startsWith(`session:`)){let e=ze.find(e=>r.id===`session:${e.id}`);e&&Ue(e);return}let i=r.id.startsWith(`recent:`)?K.find(e=>r.id===`recent:${e.path}`):Be.find(e=>r.id===`file:${e.path}`);i&&Ve(i)};P.useEffect(()=>{Oe(l,Pe,{rows:q,highlightedIndex:j})},[l,j,q]);let Ke=P.useRef(l);return Ke.current=l,P.useEffect(()=>()=>{ke(Ke.current,Pe)},[]),P.useImperativeHandle(u,()=>({acceptIndex:e=>{J(e)},handleKeyDown:e=>{if(e===`Escape`){s();return}let t=q.length;if(t!==0){if(e===`ArrowDown`){N.current=(N.current+1)%t,M(N.current);return}if(e===`ArrowUp`){N.current=(N.current-1+t)%t,M(N.current);return}(e===`Enter`||e===`Tab`)&&J(N.current)}}})),(0,W.jsxs)(xe,{ref:B,isMobile:H,className:`max-w-[640px] max-h-64`,style:c,children:[(0,W.jsx)(ye,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,W.jsxs)(`div`,{className:`py-1`,children:[q.map((e,t)=>{let n=e.id.startsWith(`file:`)||e.id.startsWith(`recent:`),r=n?ne(e.title,{maxLength:60}):e.title,i=j===t,a=De[t]??!1,o=I[t]??2.6;return(0,W.jsxs)(`div`,{"data-mention-id":e.id,ref:e=>{Ae.current[t]=e},className:C(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,H&&`min-h-11`,Se(H,i),!H&&i&&`text-interactive-selection-foreground`),...Ge(t,()=>J(t)),children:[(0,W.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center`,children:e.agentName===void 0?(0,W.jsx)(A,{name:e.iconName,className:`size-3.5 text-current`}):(0,W.jsx)(he,{name:e.agentName,size:20})}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`span`,{ref:e=>{R.current[t]=e},className:`relative block min-w-0 overflow-hidden file-mention-marquee-container`,style:i?{"--file-mention-marquee-width":`${Te}px`,"--file-mention-marquee-duration":`${o}s`}:void 0,title:e.title,children:[(0,W.jsx)(`span`,{ref:e=>{z.current[t]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:e.title}),n&&a&&i?(0,W.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:G(e.title,U)}):(0,W.jsx)(`span`,{className:`block truncate`,children:G(r,U)})]}),e.subtitle?(0,W.jsx)(`div`,{className:C(`truncate text-muted-foreground`,H?`typography-micro`:`typography-meta`),children:G(e.subtitle,U)}):null]})]},e.id)}),_e&&Be.length===0?(0,W.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,W.jsx)(A,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!_e&&q.length===0&&(0,W.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.empty`)})]})}),!H&&(0,W.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:d(`chat.autocomplete.keyboardHint`)})]})}),ze=new Set([`new`,`fork`,`compact`,`reload`,`undo`,`redo`,`model`,`goal`,`btw`]),K=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&ze.has(n))},Be=(e,t)=>!e||t({name:e}),q=` `,Ve=(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]===q&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},He=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,Ue=C(He,`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)]`),We=C(He,`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)]`),Ge=C(He,`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)]`),J=C(He,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),Ke=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id&&e.description===t[n]?.description),qe=(e,t)=>{let n=!!e.sessionID;return{hasSession:n,canStartSessionCommand:n||e.hasNewDraft,canUseReviewHandoffFlow:n&&!t&&!s()}},Je=P.forwardRef(({searchQuery:e,onCommandSelect:t,onClose:n,directory:r,style:i,commandPolicy:a,commandContext:o,onRowsChange:c},l)=>{let{t:u}=te(),d=ee(e=>e.isMobile),f=E(e=>e.currentSessionId),p=E(e=>!!e.newSessionDraft?.open),m=E(P.useCallback(e=>f?e.getDirectoryForSession(f):void 0,[f])),h=se(f??``,m??void 0),g=P.useMemo(()=>o??{sessionID:f??null,hasMessages:h.length>0,hasNewDraft:p},[o,f,h.length,p]),{hasSession:_,canStartSessionCommand:v,canUseReviewHandoffFlow:y}=P.useMemo(()=>qe(g,d),[g,d]),b=g.hasMessages,[x,S]=P.useState([]),[ne,re]=P.useState(!1),ie=le({directory:r}),ae=P.useMemo(()=>ie.data??[],[ie.data]),oe=ie.isFetching,[w,T]=P.useState(0),ce=P.useRef(0),D=P.useRef(!1),ue=P.useRef([]),de=P.useRef(null),fe=P.useRef(!1),O=P.useRef(null),k=P.useRef(!1),pe=P.useRef(null);P.useEffect(()=>{let e=e=>{let t=e.target;!t||!de.current||de.current.contains(t)||n()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[n]),P.useEffect(()=>{(async()=>{re(oe);try{let t=ae.flatMap((e,t)=>e.source===`skill`?[]:[{id:`opencode:${e.scope??`global`}:${e.name}:${e.agent??``}:${e.model??``}:${t}`,name:e.name,source:`opencode`,description:e.description,agent:e.agent??void 0,model:e.model??void 0,isBuiltIn:e.isBuiltIn,scope:e.scope,reference:e.reference}]),n=[{id:`openchamber:new`,name:`new`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!b?[{id:`openchamber:init`,name:`init`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:btw`,name:`btw`,source:`openchamber`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`openchamber:undo`,name:`undo`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`openchamber:redo`,name:`redo`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`openchamber:fork`,name:`fork`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`openchamber:timeline`,name:`timeline`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`openchamber:model`,name:`model`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`openchamber:compact`,name:`compact`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...s()?[{id:`openchamber:reload`,name:`reload`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:summary`,name:`summary`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:workspace-review`,name:`workspace-review`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isOpenChamber:!0}]:[],...y?[{id:`openchamber:handoff-review`,name:`handoff-review`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.handoffReviewDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:craft-goal`,name:`craft-goal`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:goal`,name:`goal`,source:`openchamber`,description:u(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],...v?[{id:`openchamber:catch-up`,name:`catch-up`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:debug`,name:`debug`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.debugDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:weigh`,name:`weigh`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.weighDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:explore`,name:`explore`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isOpenChamber:!0}]:[],...t],r=!b,i=we(n.filter(e=>(r||e.name!==`init`)&&(a?.(e)??!0)),e);S(e=>Ke(e,i)?e:i)}catch{let t=!b,n=we([{id:`openchamber:new`,name:`new`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!b?[{id:`openchamber:init`,name:`init`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:btw`,name:`btw`,source:`openchamber`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`openchamber:undo`,name:`undo`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`openchamber:redo`,name:`redo`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`openchamber:fork`,name:`fork`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`openchamber:timeline`,name:`timeline`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`openchamber:model`,name:`model`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`openchamber:compact`,name:`compact`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...s()?[{id:`openchamber:reload`,name:`reload`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:summary`,name:`summary`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:workspace-review`,name:`workspace-review`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isOpenChamber:!0}]:[],...y?[{id:`openchamber:handoff-review`,name:`handoff-review`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.handoffReviewDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:craft-goal`,name:`craft-goal`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:goal`,name:`goal`,source:`openchamber`,description:u(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],...v?[{id:`openchamber:catch-up`,name:`catch-up`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:debug`,name:`debug`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.debugDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:weigh`,name:`weigh`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.weighDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:explore`,name:`explore`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isOpenChamber:!0}]:[]].filter(e=>(t||e.name!==`init`)&&(a?.(e)??!0)),e);S(e=>Ke(e,n)?e:n)}finally{re(!1)}})()},[e,b,_,v,y,ae,oe,u,a]),P.useEffect(()=>{T(0)},[x]),P.useEffect(()=>{ce.current=w},[w]),P.useEffect(()=>{ue.current[w]?.scrollIntoView({block:`nearest`})},[w]),P.useEffect(()=>{Oe(c,pe,{rows:N(x,{skill:u(`chat.commandAutocomplete.badge.skill`),command:u(`chat.commandAutocomplete.badge.command`),system:u(`chat.commandAutocomplete.badge.system`)}),highlightedIndex:w})},[x,c,w,u]);let me=P.useRef(c);me.current=c,P.useEffect(()=>()=>{ke(me.current,pe)},[]),P.useImperativeHandle(l,()=>({acceptIndex:(e,n=!0)=>{let r=x[e];r&&t(r,K(r,n))},handleKeyDown:e=>{let r=x.length;if(e===`Escape`){n();return}if(r!==0){if(e===`ArrowDown`){D.current=!0,T(e=>(e+1)%r);return}if(e===`ArrowUp`){D.current=!0,T(e=>(e-1+r)%r);return}if(e===`Enter`||e===`Tab`){let n=(ce.current%r+r)%r,i=x[n];i&&t(i,K(i,e===`Enter`))}}}}),[x,n,t]);let he=e=>{let t=M(e);switch(e.name){case`new`:return(0,W.jsx)(A,{name:t,className:`h-3.5 w-3.5`});case`init`:return(0,W.jsx)(A,{name:t,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,W.jsx)(A,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,W.jsx)(A,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:case`reload`:return(0,W.jsx)(A,{name:t,className:`h-3.5 w-3.5`});case`compact`:return(0,W.jsx)(A,{name:t,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,W.jsx)(A,{name:t,className:`h-3.5 w-3.5`});case`review`:return(0,W.jsx)(A,{name:t,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,W.jsx)(A,{name:t,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,W.jsx)(A,{name:t,className:`h-3.5 w-3.5 text-yellow-500`}):(0,W.jsx)(A,{name:t,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,W.jsxs)(xe,{ref:de,isMobile:d,className:`max-w-[450px] max-h-64`,style:i,children:[(0,W.jsx)(ye,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 py-1.5`,children:ne?(0,W.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,W.jsx)(A,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,W.jsxs)(`div`,{children:[x.map((n,r)=>{let i=n.isBuiltIn,a=n.isOpenChamber;return(0,W.jsxs)(`div`,{ref:e=>{ue.current[r]=e},className:C(`flex gap-2 px-2 py-2 cursor-pointer rounded-lg`,d?`items-center`:`items-start`,Se(d,r===w),!d&&r===w&&`bg-interactive-selection/35`),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(O.current={x:e.clientX,y:e.clientY},k.current=!1)},onPointerMove:e=>{if(e.pointerType!==`touch`||!O.current)return;let t=e.clientX-O.current.x,n=e.clientY-O.current.y;Math.hypot(t,n)>6&&(k.current=!0)},onPointerUp:e=>{if(e.pointerType!==`touch`)return;let r=k.current;O.current=null,k.current=!1,!r&&(e.preventDefault(),e.stopPropagation(),fe.current=!0,t(n,K(n,d)))},onPointerCancel:()=>{O.current=null,k.current=!1},onClick:()=>{if(fe.current){fe.current=!1;return}t(n,K(n,d))},onMouseMove:()=>{D.current=!1,T(r)},children:[(0,W.jsx)(`div`,{className:C(!d&&`mt-0.5`),children:he(n)}),(0,W.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,G(n.name,e)]}),n.isSkill?(0,W.jsx)(`span`,{className:Ue,children:u(`chat.commandAutocomplete.badge.skill`)}):(0,W.jsx)(`span`,{className:Ue,children:u(`chat.commandAutocomplete.badge.command`)}),a?(0,W.jsx)(`span`,{className:J,children:`OpenChamber`}):i?(0,W.jsx)(`span`,{className:J,children:u(`chat.commandAutocomplete.badge.system`)}):n.scope?(0,W.jsx)(`span`,{className:n.scope===`project`?Ge:We,children:n.scope}):null,n.agent&&(0,W.jsx)(`span`,{className:J,children:n.agent})]}),n.description&&!d&&(0,W.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:G(n.description,e)})]})]},n.id)}),x.length===0&&(0,W.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.commandAutocomplete.empty`)})]})}),!d&&(0,W.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})});Je.displayName=`CommandAutocomplete`;var Ye=2,Xe=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Ze=e=>{let t=e?.trim().replace(/\\/g,`/`);return t?t.length>1?t.replace(/\/+$/,``):t:null},Qe=e=>Xe(e)&&Array.isArray(e.all)&&e.all.every(e=>typeof e==`string`)&&typeof e.current==`string`&&Xe(e.branches),Y=(e,t)=>JSON.stringify([e,t]),$e=e=>`version`in e&&e.version===Ye&&Xe(e.entries),et=e=>{if(!e)return null;try{let t=JSON.parse(e);return Xe(t)?t.version===Ye&&Xe(t.entries)?{version:Ye,entries:t.entries}:t:null}catch{return null}},tt=(e,t)=>{try{e.setItem(`oc.gitBranchCache`,JSON.stringify(t))}catch{}},nt=(e,t,n)=>{let r=Ze(e);if(!r||!t)return null;let i;try{i=n.getItem(`oc.gitBranchCache`)}catch{return null}let a=et(i);if(!a)return null;if($e(a))return Qe(a.entries[Y(t,r)])?a.entries[Y(t,r)]:null;let o={};for(let[e,n]of Object.entries(a)){let r=Ze(e);r&&Qe(n)&&(o[Y(t,r)]=n)}return tt(n,{version:Ye,entries:o}),o[Y(t,r)]??null},rt=(e,t,n,r)=>{let i=Ze(e);if(!i||!t||!Qe(n))return;let a=null;try{a=r.getItem(`oc.gitBranchCache`)}catch{return}let o=et(a);tt(r,{version:Ye,entries:{...o&&$e(o)?o.entries:{},[Y(t,i)]:n}})},it=3e4,X=Ze,at=(e,t=n())=>o.git.branches(X(e),t),ot=(e,t=n())=>o.git.remotes(X(e),t),st=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},ct=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},lt=(e,t,r=n(),i=y())=>{let a=X(e),o=t;return{queryKey:at(a,r),queryFn:async({signal:e})=>{if(!a)throw Error(`Git branches require a directory`);let t=await st(a,o,e);return rt(a,r,t,i),t},staleTime:it,gcTime:1/0,initialData:()=>nt(a,r,i)??void 0,initialDataUpdatedAt:0}},ut=(e,t,r=n())=>{let i=X(e),a=t;return{queryKey:ot(i,r),queryFn:({signal:e})=>{if(!i)throw Error(`Git remotes require a directory`);return ct(i,a,e)},staleTime:it,gcTime:1/0}},dt=(e,r,i)=>{let a=(0,B.c)(9),o=i===void 0||i,s=P.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=X(e),u=x,l=lt(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)},ft=(e,r,i)=>{let a=(0,B.c)(9),o=i===void 0||i,s=P.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=X(e),u=x,l=ut(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)},pt=(e,t,r=c,i=n())=>r.fetchQuery(lt(e,t,i)),mt=(e,t,r=c,i=n())=>r.fetchQuery({...lt(e,t,i),staleTime:0}),ht=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,gt=1e4,_t=6e4,vt=5e3,yt=3e4,bt=6e4,xt=25,St=40,Ct=2,wt=15e3,Tt=500,Et=30,Dt=20971520,Ot=new Map,kt=new Map,At=new Map,jt=new Map,Mt=new Map,Nt=(e,t)=>`${t}:${e}`,Pt=e=>kt.get(e)??0,Ft=e=>{let t=Pt(e)+1;return kt.set(e,t),t},It=e=>{let t=(At.get(e)??0)+1;return At.set(e,t),t},Lt=e=>{let t=Ot.get(e);if(t)return t;let n=new Set;return Ot.set(e,n),n},Z=()=>({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}),Rt=(e,t=Et,n=Dt)=>{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},zt=(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},Bt=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,Vt=(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&&Bt(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&&zt(e.diffStats,t.diffStats))},Ht=(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},Ut=(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},Wt=e=>!e||e.trim().length===0,Gt=e=>(e||``).trim()===`U`,Kt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(Gt(t)||Gt(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},qt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(Gt(t)||Gt(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},Jt=e=>Wt(e.index)&&Wt(e.working_dir),Q=l()(d((e,t)=>({directories:new Map,activeDirectory:null,setActiveDirectory:n=>{let{activeDirectory:r,directories:i}=t();if(r!==n)if(r&&Ft(r),n&&Ft(n),n&&!i.has(n)){let t=new Map(i);t.set(n,Z()),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=Nt(n,a),s=jt.get(o)??(a===`light`?jt.get(Nt(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||=Z(),!a){let r=new Map(t().directories),i=r.get(n)??Z();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)>_t,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(Vt(s.status,u)){c=!0;let r=new Map(t().directories),i=r.get(n)??Z(),s=Ht(i.status,u),l=Ut(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&&Ft(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)??Z();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)??Z();r.set(n,{...i,isLoadingStatus:!1}),e({directories:r})}}return c})();jt.set(o,c);try{return await c}finally{jt.get(o)===c&&jt.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`?Kt(e):qt(e);t!==e&&(l=!0),Jt(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=It(r);{let n=new Map(t().directories),i=n.get(r)??Z();n.set(r,{...i,isLoadingBranches:!0}),e({directories:n})}try{let c=a.force?await mt(r,i,void 0,o):await pt(r,i,void 0,o);if(s!==At.get(r)||o!==n())return;let l=new Map(t().directories),u=l.get(r)??Z();l.set(r,{...u,branches:c,branchesTransportIdentity:o,isLoadingBranches:!1,lastBranchesFetch:Date.now()}),e({directories:l})}catch(i){if(ht(i)||console.error(`Failed to fetch git branches:`,i),s!==At.get(r)||o!==n())return;let a=new Map(t().directories),c=a.get(r)??Z();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)??Z();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)??Z();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)??Z();i.set(n,{...a,isLoadingLog:!1}),e({directories:i})}},fetchIdentity:async(n,r)=>{{let r=new Map(t().directories),i=r.get(n)??Z();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)??Z();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)??Z();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=Z();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>gt||!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)??Z(),s=new Map(o.diffCache);s.set(r,{...i,fetchedAt:Date.now()});let c=Rt(s);a.set(n,{...o,diffCache:c}),e({directories:a})},clearDiffCache:n=>{Ft(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,xt);await t().prefetchDiffs(e,n,i,{maxFiles:xt})},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=St}=a,c=new Set(o.status.files.map(e=>e.path)),l=o.status.diffStats,u=Lt(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>Tt||d.push(e)}let p=d.slice(0,Math.max(1,s));if(p.length===0)return;let m=Pt(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 ${wt}ms`)),wt)}),a=await Promise.race([t,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},ee=async()=>{for(;;){if(m!==Pt(n))return;let e=_();if(!e)return;try{g.push(await v(e))}catch{}finally{u.delete(e)}}},y=Math.min(Ct,p.length);if(await Promise.allSettled(Array.from({length:y},()=>ee())),p.forEach(e=>u.delete(e)),m!==Pt(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=Rt(S);b.set(n,{...x,diffCache:C}),e({directories:b})},setLogMaxCount:(n,r)=>{let i=new Map(t().directories),a=i.get(n)??Z();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<vt||await t().fetchStatus(e,n,{silent:!!r?.status})},ensureAll:(e,n)=>{let r=Mt.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)>=vt)&&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>=yt)&&o.push(t().fetchBranches(e,n)),(!a.log||i-a.lastLogFetch>=gt)&&o.push(t().fetchLog(e,n)),(!a.identity||i-a.lastIdentityFetch>=bt)&&o.push(t().fetchIdentity(e,n)),o.length>0&&await Promise.all(o)})();return Mt.set(e,i),i.finally(()=>{Mt.get(e)===i&&Mt.delete(e)}),i},refresh:async(e,n={})=>{let{activeDirectory:r}=t();r&&await t().fetchAll(r,e,n)}}),{name:`git-store`})),Yt=e=>{let t=(0,B.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),Q(n)},Xt=e=>{let r=(0,B.c)(3),i=P.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],Q(a)},Zt=e=>{let t=(0,B.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),Q(n)},Qt=e=>{let t=(0,B.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),Q(n)},$t=e=>{let t=(0,B.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),Q(n)},en=e=>{let t=(0,B.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=P.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),Q(i)},tn=e=>{let t=(0,B.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),Q(n)},nn=e=>{let t=(0,B.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),Q(n)},rn=e=>{let t=(0,B.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),Q(n)},an=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)}},$=e=>String(e||``).trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/^remotes\//,``),on=e=>e.branchName?$(e.branchName):e.mode===`existing`?$(e.existingBranch||e.preferredName||``):$(e.preferredName||``),sn=async e=>{let t=await ve(e);try{let n=an((await ge(e)).branches?.[t]?.tracking||null);if(n?.remote)return n.remote}catch{}try{let t=an((await _e(e)).tracking);if(t?.remote)return t.remote}catch{}return null},cn=async(e,t)=>{let n=await sn(e),r=$(t);return!n||!r?null:{setUpstream:!0,upstreamRemote:n,upstreamBranch:r}},ln=async(e,t,n)=>{let r=on(t),i=n?.resolvedRootTrackingRemote,a=i===void 0?await cn(e,r):i&&$(r)?{setUpstream:!0,upstreamRemote:i,upstreamBranch:$(r)}:null;return a?{...t,setUpstream:t.setUpstream??a.setUpstream,upstreamRemote:t.upstreamRemote||a.upstreamRemote,upstreamBranch:t.upstreamBranch||a.upstreamBranch}:t},un=async(e,t,n)=>{let r=await ln(e.path,t,n);return j(e,r)},dn=`oc:lastWorktreeSourceBranch`,fn=({mode:e,sourceBranch:t,linkedPr:n,selectedBranch:r})=>e===`existing-branch`?r||null:n?null:t||null,pn=({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?` `:``}`},hn=(e,t,n)=>{let r=mn(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},gn=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=hn(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}},_n=(e,t)=>{let n=e=>`${e.kind}:${e.value}:${e.range.start}:${e.range.end}`;return new Set(e.map(n)).has(n(t))||e.some(e=>e.range.start<t.range.end&&t.range.start<e.range.end)?[...e]:[...e,t]},vn=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{je as A,ft as C,Re as D,Be as E,Ne as O,dt as S,Ve as T,en as _,dn as a,Qt as b,un as c,$t as d,Xt as f,Zt as g,tn as h,hn as i,De as j,Me as k,sn as l,nn as m,_n as n,pn as o,rn as p,gn as r,fn as s,vn as t,ln as u,Yt as v,Je as w,mt as x,Q as y};
@@ -1 +0,0 @@
1
- import{r as e}from"./vendor-pierre-diffs-DPBtNDJ5.js";var t=[],n=e=>(t.push(e),()=>{let n=t.lastIndexOf(e);n>=0&&t.splice(n,1)}),r=e=>{let n=t[t.length-1];if(!n)return!1;let r=e.sourceUrl.trim();return!r&&!e.displayUrl?.trim()?!1:(n({...e,sourceUrl:r||e.displayUrl.trim()}),!0)},i=`openchamber-md`,a={name:i,colors:{"editor.background":`transparent`,"editor.foreground":`var(--md-syntax-foreground)`},tokenColors:[{scope:[`comment`,`punctuation.definition.comment`,`string.comment`],settings:{foreground:`var(--md-syntax-comment)`,fontStyle:`italic`}},{scope:[`string`,`punctuation.definition.string`,`string.template`],settings:{foreground:`var(--md-syntax-string)`}},{scope:[`constant.numeric`,`constant.language`,`constant.character`,`constant`],settings:{foreground:`var(--md-syntax-number)`}},{scope:[`keyword`,`storage`,`storage.type`,`storage.modifier`,`keyword.control`],settings:{foreground:`var(--md-syntax-keyword)`}},{scope:[`keyword.operator`,`punctuation.separator`,`punctuation.terminator`],settings:{foreground:`var(--md-syntax-operator)`}},{scope:[`entity.name.function`,`support.function`,`meta.function-call`],settings:{foreground:`var(--md-syntax-function)`}},{scope:[`entity.name.type`,`entity.name.class`,`support.type`,`support.class`,`entity.other.inherited-class`],settings:{foreground:`var(--md-syntax-type)`}},{scope:[`variable`,`variable.other`,`variable.parameter`,`meta.definition.variable`],settings:{foreground:`var(--md-syntax-variable)`}},{scope:[`variable.other.property`,`meta.property-name`,`support.type.property-name`],settings:{foreground:`var(--md-syntax-property)`}},{scope:[`entity.name.tag`,`punctuation.definition.tag`],settings:{foreground:`var(--md-syntax-keyword)`}},{scope:[`entity.other.attribute-name`],settings:{foreground:`var(--md-syntax-property)`}},{scope:[`markup.bold`,`punctuation.definition.bold`],settings:{fontStyle:`bold`}},{scope:[`markup.italic`,`punctuation.definition.italic`],settings:{fontStyle:`italic`}},{scope:[`markup.heading`,`markup.heading entity.name`],settings:{foreground:`var(--md-syntax-keyword)`,fontStyle:`bold`}},{scope:[`markup.inserted`,`punctuation.definition.inserted`],settings:{foreground:`var(--md-syntax-inserted)`}},{scope:[`markup.deleted`,`punctuation.definition.deleted`],settings:{foreground:`var(--md-syntax-deleted)`}},{scope:[`invalid`,`invalid.illegal`],settings:{foreground:`var(--md-syntax-deleted)`}}]},o=!1,s=()=>{o||(o=!0,e(i,()=>Promise.resolve(a)))},c=e=>{let t=e.colors.syntax.base,n=e.colors.syntax.tokens??{},r=e.colors.status;return{"--md-syntax-foreground":t.foreground,"--md-syntax-comment":t.comment,"--md-syntax-string":t.string,"--md-syntax-number":t.number,"--md-syntax-keyword":t.keyword,"--md-syntax-operator":t.operator,"--md-syntax-function":t.function,"--md-syntax-type":t.type,"--md-syntax-variable":t.variable,"--md-syntax-property":n.variableProperty??t.variable,"--md-syntax-inserted":r.success,"--md-syntax-deleted":r.error}};export{r as i,c as n,n as r,s as t};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/renderMobileApp-1A-brlHd.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-auth-BpCQ-dPr.js","assets/runtime-switch-CMiMO5Yj.js","assets/runtime-fetch-WgH0pROs.js","assets/persistence-BKszKaoQ.js","assets/vendor-zustand-o69pgTEK.js","assets/vendor-base-ui-CdzJ6My_.js","assets/useUIStore-CEqU9Ujv.js","assets/vendor-react-BP2cRVqX.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/platform-CgwxwfA4.js","assets/vendor-opencode-client-MF2GBrFx.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/capgoAdapter-KNLHDj7G.js","assets/types-BuiqMmh_.js","assets/vendor-pierre-diffs-DPBtNDJ5.js","assets/vendor-hast-util-to-html-Bw_SgZ1t.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-BMOrLc9L.js","assets/vendor-sonner-ZS8XIOVl.js","assets/vendor-reactuses-core-BpfIZ1tg.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/button-CWSs9Baz.js","assets/store-CG7Ytsg9.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/MobileShareBridge-3USYeuqn.js","assets/MobileDetailNavigation-CKK6v7FY.js","assets/vendor-tanstack-react-query-CdqCAt40.js","assets/useMobileNavigationStore-DD_frNrb.js","assets/useAssistantUIStore-OyPm_4M_.js","assets/vendor-zod-Dzk5kdUU.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/Icon-BCFeHDWx.js","assets/AgentAvatar-CSTBp5FT.js","assets/agentColors-DWSbQXy2.js","assets/vendor-dicebear-core-CV95S5Pg.js","assets/vendor-dicebear-styles-7lEG-JsF.js","assets/dualLimitLru-D8Sphgua.js","assets/useThemeSystem-8jhE4Zyk.js","assets/dialog-BMa16qrs.js","assets/rasterizePng-056Poix7.js","assets/gitApi-BSKCuIuE.js","assets/useAppFontEffects-CwhU0vu2.js","assets/desktopHosts-C0e7Nes2.js","assets/desktopRelayRestore-DckkHKsi.js","assets/vendor-simplewebauthn-browser-Dwhcdg_5.js","assets/projectMeta-cKz9O_kp.js","assets/input-CALwaZEB.js","assets/tooltip-CV6dvLBp.js","assets/OverlayScrollbar-BY5HaNrb.js","assets/textarea-D_tvJ-Lw.js","assets/vendor-framer-motion-D-oiwsxL.js","assets/MobileWindowStack-DGLdgoGr.js","assets/vendor-dnd-kit-core-5pNnzVdw.js","assets/vendor-dnd-kit-accessibility-COSwgjFs.js","assets/vendor-dnd-kit-sortable-Dm50I0m7.js","assets/speechSettingsQueries-CypxKs6Q.js","assets/dropdown-menu.styles-BNwZmBRp.js","assets/image-loading-Bj11k4gM.js","assets/fileQueries-DVpZC5ha.js","assets/useRuntimeAPIs-Cx8S1HLz.js","assets/relay-image-stream-SV0lH6aG.js","assets/image-loading-CObM4tcX.css","assets/sessionChangeSummary-vEEPbusH.js","assets/LoadingImage-BAT9D9wN.js","assets/ImageLoadingPlaceholder-DEpMJXzV.js","assets/sessionChangeSummary-vC84qM3v.css","assets/fileMentionTouchSelection-DaZJsfwG.js","assets/vendor-fuzzysort-ukaRp9PC.js","assets/insertionBoundaries-DIiKL4e-.js","assets/appThemeRegistry-nMIsNW7b.js","assets/MarkdownRenderer-CDneNNiI.js","assets/markdownHeightCache-DXM_5jTe.js","assets/url-nBOUbtV_.js","assets/markdown-worker-DFNZ3KJ_.js","assets/useEffectiveDirectory-_UyYQwIy.js","assets/FadeInOnReveal-CX8Bkq-l.js","assets/markdownTheme-CV7_0QAL.js","assets/useWorkerHighlightedLines-uicGNlIu.js","assets/vendor-tanstack-react-virtual-B_EO--9t.js","assets/vendor-cmdk-RDxC-9Iz.js","assets/vendor-aria-hidden-BbL3cEyI.js","assets/sortable-tabs-strip-CscHgCaq.js","assets/vendor-motion-88WXBOBf.js","assets/vendor-legendapp-list-CNxU_ALy.js","assets/useFontPreferences-DqEIKMEW.js","assets/terminalApi-rxsMWL0o.js","assets/MobileTabPageHeader-DCDm3ht4.js","assets/vendor-codemirror-autocomplete-7c2L_4dM.js","assets/vendor-codemirror-lang-angular-DXOgWEVj.js","assets/vendor-codemirror-lang-json-mLulNbwB.js","assets/vendor-codemirror-lang-markdown-CV1IO6Qs.js","assets/vendor-codemirror-lang-python-YM2WVLHF.js","assets/vendor-codemirror-legacy-modes-DwltVFbT.js","assets/mcpQueries-CG7M_F23.js","assets/collapsible-ngtoKADo.js","assets/vendor-codemirror-commands-B8KrBQ9B.js","assets/vendor-codemirror-search-ZqtrPLjU.js","assets/vendor-replit-codemirror-vim-DDj0dSVY.js","assets/vendor-codemirror-language-data-Ctd4WxgW.js","assets/projectActions-CWvNGKfA.js","assets/runtimeEndpointReset-CU_9RUmN.js","assets/scheduledTaskNavigation-DQcLqQ52.js","assets/sessionLookup-bRxb556M.js","assets/vendor-cron-parser-BmO80h0C.js","assets/runtimeEndpointReset-ByXtaeWD.css","assets/SettingsView-CEH-gWxO.js","assets/vendor-yaml-C9KlJAlj.js","assets/vendor-qrcode-D7jBCyl-.js","assets/vendor-dijkstrajs-BAzPDGZM.js","assets/AssistantView-CVC7X0Lx.js","assets/assistant-attachment-cache-B2UAUHUZ.js","assets/src-Bud55RXh.css"])))=>i.map(i=>d[i]);
2
- import{t as e}from"./runtimeConfig-S5cf8TMp.js";import{o as t}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";/* empty css */window.__OPENCHAMBER_RUNTIME_APIS__=e(),t(async()=>{let{renderMobileApp:e}=await import(`./renderMobileApp-1A-brlHd.js`);return{renderMobileApp:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122])).then(({renderMobileApp:t})=>{t(window.__OPENCHAMBER_RUNTIME_APIS__??e())});
@@ -1,3 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{on as t}from"./persistence-BKszKaoQ.js";import{a as n,r}from"./vendor-zustand-o69pgTEK.js";import{it as i,rt as a}from"./vendor-base-ui-CdzJ6My_.js";import{Ct as o,Gn as s,Nt as c,zn as l}from"./platform-CgwxwfA4.js";import{n as u}from"./useUIStore-CEqU9Ujv.js";import{n as d}from"./vendor-react-BP2cRVqX.js";import{n as f}from"./vendor-reactuses-core-BpfIZ1tg.js";import{f as p,i as m,r as h,t as g,y as _}from"./button-CWSs9Baz.js";import{Fa as v,La as y,Pr as b,Rr as x,d as S,fo as C,gr as w,nr as T,or as E,rr as D,u as O,wa as ee}from"./useMobileNavigationStore-DD_frNrb.js";import{n as k}from"./Icon-BCFeHDWx.js";import{n as A}from"./gitApi-BSKCuIuE.js";import{A as te,D as ne,O as j,S as re,_ as ie,a as M,b as ae,f as oe,g as N,h as se,i as P,m as ce,n as le,v as F,x as ue,y as I}from"./projectMeta-cKz9O_kp.js";import{t as L}from"./input-CALwaZEB.js";import{i as R,n as z,t as B}from"./tooltip-CV6dvLBp.js";import{o as de}from"./OverlayScrollbar-BY5HaNrb.js";import{n as V}from"./useRuntimeAPIs-Cx8S1HLz.js";import{r as fe,t as H}from"./textarea-D_tvJ-Lw.js";import{D as pe,a as U,b as W,c as G,f as K,h as q,l as J,o as Y,p as me,r as he,w as ge,y as _e}from"./insertionBoundaries-DIiKL4e-.js";import{n as ve,r as ye,t as be}from"./collapsible-ngtoKADo.js";var X=e(i(),1),xe=d(),Se=/^[a-z0-9](?:[a-z0-9-]{0,48}[a-z0-9])?$/,Ce=/^g[1-9]\d*$/,Z=(e,t,n,r,i)=>{if(!Se.test(e)||t!==void 0&&!Ce.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}},we=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 Z(n,void 0,t[1],t[2],void 0);if(t.length===4){let[,e,r,i]=t;return Ce.test(e)?Z(n,e,r,i,void 0):Z(n,void 0,e,r,i)}let[,r,i,a,o]=t;return r===``?Z(n,void 0,i,a,o):Z(n,r,i,a,o)},Te=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(`/`)},Q=(e,t,n,r)=>{let i=[e];return r&&i.push(r),i.push(t,n,`fusion`),i.join(`/`)},Ee=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).substring(0,50),De=(e,t)=>`${Ee(e)}-${Ee(t)}`.substring(0,60),Oe=(e,t)=>`${e}/${t}`,ke=e=>{let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.length>1?t.replace(/\/+$/,``):t},Ae=(e,t)=>{let n=ke(t),r=e.directory,i=typeof r==`string`&&r.trim().length>0?e:{...e,directory:n};s(e.id,n),S.getState().markSessionAsOpenChamberCreated(e.id),b.getState().upsertSession(i);try{l().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},je=()=>{let e=C.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},Me=n()(r(e=>({isLoading:!1,error:null,createMultiRun:async t=>{let n=t.name.trim(),{groups:r,agent:i,files:a,setupCommands:o}=t;if(!n)return e({error:`Group name is required`}),null;if(!r||r.length===0)return e({error:`At least one run group is required`}),null;for(let t=0;t<r.length;t++){if(!r[t].prompt.trim())return e({error:`Group ${t+1}: prompt is required`}),null;if(r[t].models.length<1)return e({error:`Group ${t+1}: select at least 1 model`}),null;if(r[t].models.length>5)return e({error:`Group ${t+1}: maximum 5 models allowed`}),null}e({isLoading:!0,error:null});try{let s=je();if(!s)return e({error:`Select a project`,isLoading:!1}),null;let l=s.path,u=await A(l)&&t.isolateRuns!==!1,d=Ee(n),f=u?await oe(l):void 0,p=u?await J(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 y=De(g.providerID,g.modelID),b=r.length>1?`g${e+1}`:void 0,x=_>1?Oe(d,`${y}/${v}`):Oe(d,y),C=b?`${b}/${x}`:x,T=Te({groupSlug:d,runGroup:b,providerID:g.providerID,modelID:g.modelID,index:_>1?v:void 0});try{if(!u){let e=await c.withDirectory(l,()=>c.createSession({title:T}));Ae(e,l),m.push({sessionId:e.id,worktreePath:l,providerID:g.providerID,modelID:g.modelID,variant:g.variant,prompt:i});continue}let e=await G(s,{preferredName:C,mode:`new`,branchName:C,worktreeName:C,startRef:t.worktreeBaseBranch||`HEAD`,setupCommands:h,returnAfterDirectoryCreated:!0},{resolvedRootTrackingRemote:p}),n={...e,createdFromBranch:f,kind:`standard`};await D(s)&&await w(e.path);let r=await c.withDirectory(e.path,()=>c.createSession({title:T}));Ae(r,e.path),S.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&&E(s,g).catch(()=>{console.warn(`[MultiRun] Failed to save worktree setup commands`)});let _=m.map(e=>e.sessionId),v=m[0]?.sessionId??null;if(_.length===0)return e({error:`Failed to create any sessions`,isLoading:!1}),null;let y=a?.map(e=>({type:`file`,mime:e.mime,filename:e.filename,url:e.url}));return(async()=>{try{await Promise.allSettled(m.map(async e=>{try{await O({sessionId:e.sessionId,directory:e.worktreePath,content:e.prompt,providerID:e.providerID,modelID:e.modelID,variant:e.variant,agent:i,files:y})}catch(e){console.warn(`[MultiRun] Failed to start run:`,e)}}))}catch(e){console.warn(`[MultiRun] Failed to start runs:`,e)}})(),e({isLoading:!1}),{groupSlug:d,sessionIds:_,firstSessionId:v}}catch(t){return e({error:t instanceof Error?t.message:`Failed to create Multi-Run`,isLoading:!1}),null}},clearError:()=>{e({error:null})}}),{name:`multirun-store`})),$=a(),Ne=`h-7`,Pe=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,Fe=e=>{let t=(0,xe.c)(13),{model:n,instanceIndex:r,totalSameModel:i,onRemove:a}=e,o=n.displayName||`${n.providerID}/${n.modelID}`,s=i>1?`${o} (${r})`:o,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=h(`flex items-center gap-1.5 px-2 rounded-md bg-interactive-selection/20 border border-border/30`,Ne),t[0]=c):c=t[0];let l;t[1]!==n.modelID||t[2]!==n.providerID?(l=(0,$.jsx)(j,{modelId:n.modelID,providerId:n.providerID,className:`h-3.5 w-3.5`}),t[1]=n.modelID,t[2]=n.providerID,t[3]=l):l=t[3];let u;t[4]===s?u=t[5]:(u=(0,$.jsx)(`span`,{className:`typography-meta font-medium truncate max-w-[140px]`,children:s}),t[4]=s,t[5]=u);let d;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(k,{name:`close`,className:`h-3.5 w-3.5`}),t[6]=d):d=t[6];let f;t[7]===a?f=t[8]:(f=(0,$.jsx)(`button`,{type:`button`,onClick:a,className:`text-muted-foreground hover:text-foreground ml-0.5`,children:d}),t[7]=a,t[8]=f);let p;return t[9]!==l||t[10]!==u||t[11]!==f?(p=(0,$.jsxs)(`div`,{className:c,children:[l,u,f]}),t[9]=l,t[10]=u,t[11]=f,t[12]=p):p=t[12],p},Ie=e=>{let t=(0,xe.c)(131),{selectedModels:n,onAdd:r,onRemove:i,onUpdate:a,minModels:o,addButtonLabel:s,showChips:c,maxModels:l,addButtonClassName:d,dropdownSide:f,dropdownClassName:m,containerClassName:_,triggerIcon:v}=e,b=c===void 0||c,x=f===void 0?`top`:f,{t:S}=p(),C=ee(Le),w=ee(Re),T=u(ze),E=u(Be),{favoriteModelsList:D,recentModelsList:O}=ne(),A=u(Ve),te=u(He),[j,M]=X.useState(!1),[oe,N]=X.useState(``),[P,le]=X.useState(null),F=X.useRef(null),I=X.useRef(null),L=l===1,R=l===void 0||n.length<l||L,z;if(t[0]!==n){z=new Map;for(let e of n){let t=`${e.providerID}:${e.modelID}`;z.set(t,(z.get(t)||0)+1)}t[0]=n,t[1]=z}else z=t[1];let B=z,de;t[2]===n?de=t[3]:(de=e=>n.filter(t=>t.providerID===e.providerID&&t.modelID===e.modelID).findIndex(t=>t.instanceId===e.instanceId)+1,t[2]=n,t[3]=de);let V=de,fe,H;t[4]!==x||t[5]!==j?(fe=()=>{if(!j||!I.current)return;let e=I.current.getBoundingClientRect();if(x===`bottom`){let t=(window.visualViewport?.height??document.documentElement.clientHeight??window.innerHeight)-e.bottom-16-112;le(Math.max(160,Math.min(320,t)));return}let t=I.current.parentElement;for(;t&&!(t.getAttribute(`role`)===`dialog`||t.hasAttribute(`data-scroll-shadow`));){let e=getComputedStyle(t);if(e.overflow===`auto`||e.overflow===`hidden`||e.overflowY===`auto`||e.overflowY===`hidden`)break;t=t.parentElement}let n=t?t.getBoundingClientRect().top:0,r=e.top-n-16;le(Math.max(150,Math.min(300,r)))},H=[x,j],t[4]=x,t[5]=j,t[6]=fe,t[7]=H):(fe=t[6],H=t[7]),X.useEffect(fe,H);let pe,U;t[8]!==R||t[9]!==j?(pe=()=>{!R&&j&&(M(!1),N(``))},U=[R,j],t[8]=R,t[9]=j,t[10]=pe,t[11]=U):(pe=t[10],U=t[11]),X.useEffect(pe,U);let W,G;t[12]===j?(W=t[13],G=t[14]):(W=()=>{if(!j)return;let e=e=>{F.current&&!F.current.contains(e.target)&&(M(!1),N(``))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},G=[j],t[12]=j,t[13]=W,t[14]=G),X.useEffect(W,G);let K;t[15]!==L||t[16]!==r||t[17]!==a||t[18]!==n.length?(K=e=>{let t={providerID:e.providerID,modelID:e.modelID,displayName:y(e.model,e.modelID)||e.modelID,instanceId:Pe()};L&&n.length>0&&a?a(0,t):r(t),L&&(M(!1),N(``))},t[15]=L,t[16]=r,t[17]=a,t[18]=n.length,t[19]=K):K=t[19];let q=K,J;t[20]===S?J=t[21]:(J=S(`multirun.modelMultiSelect.search.placeholder`),t[20]=S,t[21]=J);let Y;t[22]===S?Y=t[23]:(Y=S(`multirun.modelMultiSelect.search.noResults`),t[22]=S,t[23]=Y);let me;t[24]===S?me=t[25]:(me=S(`multirun.modelMultiSelect.sections.favorites`),t[24]=S,t[25]=me);let he;t[26]===S?he=t[27]:(he=S(`multirun.modelMultiSelect.sections.recent`),t[26]=S,t[27]=he);let ge;t[28]===S?ge=t[29]:(ge=S(`multirun.modelMultiSelect.keyboard.hint`),t[28]=S,t[29]=ge);let _e;t[30]===S?_e=t[31]:(_e=S(`settings.agents.modelSelector.actions.favorite`),t[30]=S,t[31]=_e);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 Se;t[38]===S?Se=t[39]:(Se=S(`chat.modelControls.capability.toolCalling`),t[38]=S,t[39]=Se);let Ce;t[40]===S?Ce=t[41]:(Ce=S(`chat.modelControls.capability.reasoning`),t[40]=S,t[41]=Ce);let Z;t[42]===S?Z=t[43]:(Z=S(`chat.modelControls.modality.image`),t[42]=S,t[43]=Z);let we;t[44]===S?we=t[45]:(we=S(`chat.modelControls.modality.video`),t[44]=S,t[45]=we);let Te;t[46]===S?Te=t[47]:(Te=S(`chat.modelControls.modality.audio`),t[46]=S,t[47]=Te);let Q;t[48]===S?Q=t[49]:(Q=S(`chat.modelControls.costPerMillion`),t[48]=S,t[49]=Q);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]!==J||t[55]!==Y||t[56]!==me||t[57]!==he||t[58]!==ge||t[59]!==_e||t[60]!==ve||t[61]!==ye||t[62]!==be||t[63]!==Se||t[64]!==Ce||t[65]!==Z||t[66]!==we||t[67]!==Te||t[68]!==Q||t[69]!==Ee||t[70]!==De?(Oe={searchPlaceholder:J,noResults:Y,favorites:me,recent:he,keyboardHint:ge,favorite:_e,unfavorite:ve,provider:ye,capabilities:be,capabilityToolCalling:Se,capabilityReasoning:Ce,modalityImage:Z,modalityVideo:we,modalityAudio:Te,costPerMillion:Q,costInput:Ee,costOutput:De},t[54]=J,t[55]=Y,t[56]=me,t[57]=he,t[58]=ge,t[59]=_e,t[60]=ve,t[61]=ye,t[62]=be,t[63]=Se,t[64]=Ce,t[65]=Z,t[66]=we,t[67]=Te,t[68]=Q,t[69]=Ee,t[70]=De,t[71]=Oe):Oe=t[71];let ke=Oe,Ae;t[72]===_?Ae=t[73]:(Ae=h(`relative`,_),t[72]=_,t[73]=Ae);let je;t[74]===d?je=t[75]:(je=h(Ne,`!border-border/80 !bg-[var(--surface-subtle)] hover:!bg-[var(--interactive-hover)]/70`,d),t[74]=d,t[75]=je);let Me=!R,Ie;t[76]===j?Ie=t[77]:(Ie=()=>{M(!j)},t[76]=j,t[77]=Ie);let We;t[78]===v?We=t[79]:(We=v??(0,$.jsx)(k,{name:`add`,className:`h-3.5 w-3.5 mr-1`}),t[78]=v,t[79]=We);let Ge;t[80]!==s||t[81]!==S?(Ge=s??S(`multirun.modelMultiSelect.actions.addModel`),t[80]=s,t[81]=S,t[82]=Ge):Ge=t[82];let Ke;t[83]!==je||t[84]!==Me||t[85]!==Ie||t[86]!==We||t[87]!==Ge?(Ke=(0,$.jsxs)(g,{ref:I,type:`button`,variant:`outline`,size:`sm`,className:je,disabled:Me,onClick:Ie,children:[We,Ge]}),t[83]=je,t[84]=Me,t[85]=Ie,t[86]=We,t[87]=Ge,t[88]=Ke):Ke=t[88];let qe;t[89]!==P||t[90]!==R||t[91]!==m||t[92]!==x||t[93]!==D||t[94]!==w||t[95]!==q||t[96]!==A||t[97]!==E||t[98]!==j||t[99]!==ke||t[100]!==B||t[101]!==te||t[102]!==C||t[103]!==O||t[104]!==oe||t[105]!==T?(qe=j?(0,$.jsx)(`div`,{className:h(`absolute left-0 z-50 w-[min(420px,calc(100vw-2rem))] max-w-[calc(100vw-2rem)] flex flex-col overflow-hidden rounded-xl border border-border/50 shadow-lg`,x===`top`?`bottom-full mb-1`:`top-full mt-1`,m),style:{background:`linear-gradient(var(--surface-elevated),var(--surface-elevated)),linear-gradient(var(--surface-background),var(--surface-background))`},children:(0,$.jsx)(re,{providers:C,providerOrder:te,favoriteModels:D,recentModels:O,getMetadata:w,hiddenModels:A,searchQuery:oe,onSearchQueryChange:N,onSelect:q,labels:ke,selectionCount:e=>B.get(`${e.providerID}:${e.modelID}`)||0,disabled:!R,maxHeightClassName:`flex-1`,maxHeightStyle:{maxHeight:P?`${P}px`:`300px`},stickyHeaders:!0,tooltipsEnabled:j,isFavorite:e=>E(e.providerID,e.modelID),onToggleFavorite:e=>T(e.providerID,e.modelID),onEscape:()=>{M(!1),N(``)}})}):null,t[89]=P,t[90]=R,t[91]=m,t[92]=x,t[93]=D,t[94]=w,t[95]=q,t[96]=A,t[97]=E,t[98]=j,t[99]=ke,t[100]=B,t[101]=te,t[102]=C,t[103]=O,t[104]=oe,t[105]=T,t[106]=qe):qe=t[106];let Je;t[107]!==Ae||t[108]!==Ke||t[109]!==qe?(Je=(0,$.jsxs)(`div`,{className:Ae,ref:F,children:[Ke,qe]}),t[107]=Ae,t[108]=Ke,t[109]=qe,t[110]=Je):Je=t[110];let Ye;t[111]!==V||t[112]!==B||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=B.get(n)||1,o=V(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)(Fe,{model:e,instanceIndex:o,totalSameModel:r,onRemove:()=>i(t)}),l&&(0,$.jsxs)(ce,{value:u,onValueChange:n=>{if(!a)return;let r=n===`__default__`?void 0:n;a(t,{...e,variant:r})},children:[(0,$.jsxs)(ae,{size:`chip`,className:`px-2 gap-1.5 rounded-md !border-border/80 !bg-[var(--surface-subtle)] hover:!bg-[var(--interactive-hover)]/70 typography-meta font-medium text-foreground`,children:[(0,$.jsx)(k,{name:`brain-ai-3`,className:h(`h-3.5 w-3.5 flex-shrink-0`,u===`__default__`?`text-muted-foreground`:`text-[color:var(--status-info)]`)}),(0,$.jsx)(ue,{placeholder:S(`multirun.modelMultiSelect.variant.placeholder`),children:e=>e===`__default__`?S(`multirun.modelMultiSelect.variant.default`):e})]}),(0,$.jsxs)(se,{fitContent:!0,children:[(0,$.jsx)(ie,{value:`__default__`,className:`pr-2 [&>span:first-child]:hidden`,children:S(`multirun.modelMultiSelect.variant.default`)}),c.map(Ue)]})]})]},e.instanceId)})}),t[111]=V,t[112]=B,t[113]=i,t[114]=a,t[115]=C,t[116]=n,t[117]=b,t[118]=S,t[119]=Ye):Ye=t[119];let Xe;t[120]!==Je||t[121]!==Ye?(Xe=(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 items-center`,children:[Je,Ye]}),t[120]=Je,t[121]=Ye,t[122]=Xe):Xe=t[122];let Ze;t[123]!==l||t[124]!==o||t[125]!==n.length||t[126]!==S?(Ze=o!==void 0&&n.length<o&&(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:l===void 0?S(`multirun.modelMultiSelect.validation.minOnly`,{min:o}):S(`multirun.modelMultiSelect.validation.minToMax`,{min:o,max:l})}),t[123]=l,t[124]=o,t[125]=n.length,t[126]=S,t[127]=Ze):Ze=t[127];let Qe;return t[128]!==Xe||t[129]!==Ze?(Qe=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[Xe,Ze]}),t[128]=Xe,t[129]=Ze,t[130]=Qe):Qe=t[130],Qe};function Le(e){return e.providers}function Re(e){return e.getModelMetadata}function ze(e){return e.toggleFavoriteModel}function Be(e){return e.isFavoriteModel}function Ve(e){return e.hiddenModels}function He(e){return e.providerOrder}function Ue(e){return(0,$.jsx)(ie,{value:e,className:`pr-2 [&>span:first-child]:hidden`,children:e},e)}function We(e){let t=(0,xe.c)(30),{git:n}=V(),r=K(e),i=W(e),a=q(e),o=me(e),s=_e(Ye),c=_e(Je),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(qe).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(Ke).map(Ge).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 Ge(e){return e.replace(/^remotes\//,``)}function Ke(e){return e.startsWith(`remotes/`)}function qe(e){return!e.startsWith(`remotes/`)}function Je(e){return e.fetchStatus}function Ye(e){return e.fetchBranches}var Xe=({directory:e,value:t,onChange:n,className:r,disabled:i,id:a})=>{let{t:o}=p(),{localBranches:s,remoteBranches:c,isLoading:l,isGitRepository:u}=We(e),d=X.useMemo(()=>[...s,...c.map(e=>`remotes/${e}`)],[s,c]);return X.useEffect(()=>{if(i||l||d.length===0||t&&d.includes(t))return;let r=t,a=!1;return(async()=>{try{let t=e?await oe(e).catch(()=>null):null;if(a)return;let i=localStorage.getItem(U),{sourceBranch:o,shouldClearSavedSourceBranch:s}=Y({branches:d,savedSourceBranch:i,rootBranch:t});if(s&&localStorage.removeItem(U),a||r&&d.includes(r))return;o&&n(o)}catch{}})(),()=>{a=!0}},[d,e,i,l,n,t]),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(ce,{value:t,onValueChange:n,disabled:i||!u||l,children:[(0,$.jsx)(ae,{id:a,size:`lg`,className:r??`w-fit typography-meta text-foreground`,children:(0,$.jsx)(ue,{placeholder:o(l?`multiRun.branchSelector.status.loadingBranches`:`multiRun.branchSelector.placeholder.selectSourceBranch`)})}),(0,$.jsx)(se,{className:`max-h-[280px] max-w-[320px]`,children:l?(0,$.jsx)(`div`,{className:`px-2 py-4 text-center typography-meta text-muted-foreground`,children:o(`multiRun.branchSelector.status.loadingBranches`)}):s.length===0&&c.length===0?(0,$.jsx)(`div`,{className:`px-2 py-4 text-center typography-meta text-muted-foreground`,children:o(`multiRun.branchSelector.status.noBranchesFound`)}):(0,$.jsxs)($.Fragment,{children:[s.length>0&&(0,$.jsxs)(N,{children:[(0,$.jsx)(F,{className:`font-semibold text-foreground`,children:o(`multiRun.branchSelector.groups.localBranches`)}),s.map(e=>(0,$.jsx)(ie,{value:e,className:`whitespace-normal break-all`,children:e},e))]}),s.length>0&&c.length>0&&(0,$.jsx)(I,{}),c.length>0&&(0,$.jsxs)(N,{children:[(0,$.jsx)(F,{className:`font-semibold text-foreground`,children:o(`multiRun.branchSelector.groups.remoteBranches`)}),c.map(e=>(0,$.jsx)(ie,{value:`remotes/${e}`,className:`whitespace-normal break-all`,children:e},`remotes/${e}`))]})]})})]}),u===!1&&(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/70 mt-2`,children:o(`multiRun.branchSelector.status.notInGitRepository`)})]})},Ze=e=>{let t=(0,xe.c)(36),{value:n,onChange:r,className:i,disabled:a,id:o,portalToBody:s}=e,{t:c}=p(),l=ee(Qe),u=ee($e),d=ee(et),f;t[0]===l?f=t[1]:(f=l(),t[0]=l,t[1]=f);let m=f,g;t[2]===m?g=t[3]:(g=m.filter(tt),t[2]=m,t[3]=g);let _=g,v,y;t[4]!==m.length||t[5]!==u?(v=()=>{m.length===0&&u()},y=[m.length,u],t[4]=m.length,t[5]=u,t[6]=v,t[7]=y):(v=t[6],y=t[7]),X.useEffect(v,y);let b,x;t[8]!==d||t[9]!==a||t[10]!==r||t[11]!==_||t[12]!==n?(b=()=>{if(a)return;let e=n.trim();if(e.length>0&&_.some(t=>t.name===e))return;let t=typeof d==`string`&&d.trim().length>0?d.trim():null;if(t&&_.some(e=>e.name===t)){r(t);return}let i=_[0]?.name;i&&r(i)},x=[d,a,r,_,n],t[8]=d,t[9]=a,t[10]=r,t[11]=_,t[12]=n,t[13]=b,t[14]=x):(b=t[13],x=t[14]),X.useEffect(b,x);let S=n.trim().length>0?n:void 0,C;t[15]===i?C=t[16]:(C=h(`max-w-full typography-meta text-foreground !border-border/80 !bg-[var(--surface-subtle)] hover:!bg-[var(--interactive-hover)]/70 data-[popup-open]:!bg-[var(--interactive-active)]/70`,i),t[15]=i,t[16]=C);let w;t[17]===c?w=t[18]:(w=c(`multirun.agentSelector.placeholder`),t[17]=c,t[18]=w);let T;t[19]===w?T=t[20]:(T=(0,$.jsx)(ue,{placeholder:w}),t[19]=w,t[20]=T);let E;t[21]!==o||t[22]!==C||t[23]!==T?(E=(0,$.jsx)(ae,{id:o,size:`lg`,className:C,children:T}),t[21]=o,t[22]=C,t[23]=T,t[24]=E):E=t[24];let D;t[25]===_?D=t[26]:(D=_.length>0&&(0,$.jsx)(N,{children:_.map(nt)}),t[25]=_,t[26]=D);let O;t[27]!==s||t[28]!==D?(O=(0,$.jsx)(se,{fitContent:!0,portalToBody:s,children:D}),t[27]=s,t[28]=D,t[29]=O):O=t[29];let k;return t[30]!==a||t[31]!==r||t[32]!==S||t[33]!==E||t[34]!==O?(k=(0,$.jsxs)(ce,{value:S,onValueChange:r,disabled:a,children:[E,O]}),t[30]=a,t[31]=r,t[32]=S,t[33]=E,t[34]=O,t[35]=k):k=t[35],k};function Qe(e){return e.getVisibleAgents}function $e(e){return e.loadAgents}function et(e){return e.currentAgentName}function tt(e){return v(e.mode)}function nt(e){return(0,$.jsx)(ie,{value:e.name,className:`w-auto whitespace-nowrap`,children:e.name},e.name)}var rt=10485760,it=5,at=e=>{let t=(0,xe.c)(3),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,tabIndex:-1,className:`inline-flex items-center justify-center text-muted-foreground/50 hover:text-muted-foreground transition-colors`,children:(0,$.jsx)(k,{name:`information`,className:`h-3.5 w-3.5`})})}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,$.jsxs)(B,{children:[r,(0,$.jsx)(z,{side:`top`,className:`max-w-[240px]`,children:n})]}),t[1]=n,t[2]=i),i},ot=e=>{let t=(0,xe.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},st=e=>{let t=m(e.path),n=e.icon?P[e.icon]:null,r=e.color?le[e.color]:void 0,i=(0,$.jsx)(k,{name:n??`folder`,className:`h-3.5 w-3.5`,style:r?{color:r}:void 0});return(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`flex h-4 w-4 shrink-0 items-center justify-center overflow-hidden text-muted-foreground`,children:e.iconImage?(0,$.jsx)(M,{project:e,className:`size-full object-contain`,fallback:i}):i}),(0,$.jsx)(`span`,{className:`truncate`,children:t})]})},ct=({initialPrompt:e,onCreated:n,onCancel:r,isWindowed:i=!1})=>{let{t:a}=p(),[s,c]=X.useState(``),[l,u]=X.useState(()=>[{id:Pe(),prompt:``,models:[]}]),[d,m]=X.useState(``),[v,y]=X.useState([]),[b,w]=X.useState(!1),[E,D]=X.useState([]),[O,ee]=X.useState(!1),[A,ne]=X.useState(!1),[j,re]=X.useState(!0),M=X.useRef(null),oe=o(e=>e.currentDirectory??null),N=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},[]),P=C(e=>e.activeProjectId),le=C(e=>e.setActiveProjectIdOnly),F=C(e=>e.projects),[I,V]=X.useState(()=>P??null);X.useEffect(()=>{if(P){V(P);return}!I&&F.length>0&&V(F[0].id)},[P,F,I]);let H=X.useMemo(()=>I?F.find(e=>e.id===I)??null:null,[F,I]),pe=H?.path??oe,U=f(e=>{V(e),e!==P&&le(e)}),W=X.useMemo(()=>{if(H?.path)return{id:H.id,path:H.path};let e=oe??N;return e?{id:`path:${e}`,path:e}:null},[H,oe,N]),[G]=X.useState(()=>typeof window<`u`&&t()),K=X.useMemo(()=>typeof navigator>`u`?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||``),[]),q=de(),J=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},[]),Y=X.useMemo(()=>G&&K||q?`pl-[5.5rem]`:`pl-3`,[G,K,q]),me=X.useMemo(()=>!G||!K||J===null?``:J>=26?`h-12`:J<=15?`h-14`:``,[G,K,J]),he=f(async e=>{e.target.closest(`button, a, input, select, textarea`)||e.button===0&&G&&await _()}),ge=f(e=>{r&&e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),r())}),_e=!!r;X.useEffect(()=>{if(_e)return window.addEventListener(`keydown`,ge,!0),()=>window.removeEventListener(`keydown`,ge,!0)},[_e]);let[xe,Se]=X.useState(``),{isLoading:Ce,isGitRepository:Z}=We(pe),we=X.useRef(!1),Te=Z===!0,Q=Te&&j;X.useEffect(()=>{if(Z===!1){we.current=!0,re(!1);return}Z===!0&&we.current&&(we.current=!1,re(!0))},[Z]);let Ee=Me(e=>e.createMultiRun),De=Me(e=>e.error),Oe=Me(e=>e.clearError);X.useEffect(()=>{typeof e==`string`&&e.trim().length>0&&u(t=>{let n=[...t];return n.length>0&&!n[0].prompt.trim()&&(n[0]={...n[0],prompt:e}),n})},[e]),X.useEffect(()=>{if(!W)return;let e=!1;return ne(!0),(async()=>{try{let t=await T(W);e||D(t)}catch{}finally{e||ne(!1)}})(),()=>{e=!0}},[W]);let ke=f((e,t)=>{u(n=>n.map(n=>n.id===e?{...n,...t}:n))}),Ae=f(e=>{u(t=>t.filter(t=>t.id!==e))}),je=f(()=>{u(e=>[...e,{id:Pe(),prompt:``,models:[]}])}),Ne=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>rt){x.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)});y(t=>[...t,{id:Pe(),filename:r.name,mimeType:r.type||`application/octet-stream`,size:r.size,dataUrl:e}]),n++}catch(e){console.error(`File attach failed`,e),x.error(a(`multirun.launcher.toast.attachFailed`,{fileName:r.name}))}}n>0&&x.success(a(n===1?`multirun.launcher.toast.attachedSingle`:`multirun.launcher.toast.attachedPlural`,{count:n})),M.current&&(M.current.value=``)},Fe=e=>{y(t=>t.filter(t=>t.id!==e))},Ie=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&&!(Ie<1)){w(!0),Oe();try{I&&I!==P&&le(I);let e=v.map(e=>({mime:e.mimeType,filename:e.filename,url:e.dataUrl})),r=E.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:d||void 0,worktreeBaseBranch:Q?xe:void 0,isolateRuns:Q,files:e.length>0?e:void 0,setupCommands:r.length>0?r:void 0},o=await Ee(a);o&&(o.firstSessionId&&S.getState().setCurrentSession(o.firstSessionId),n?.())}finally{w(!1)}}},Re=!!(s.trim()&&l.some(e=>e.prompt.trim()&&e.models.length>=1)&&Ie>=1&&pe&&!Ce&&(Z===!1||!Q||xe)),ze=E.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:he,className:h(`relative flex h-12 shrink-0 items-center justify-center border-b app-region-drag select-none`,Y,me),style:{borderColor:`var(--interactive-border)`},children:[(0,$.jsx)(`h1`,{className:`typography-ui-label font-medium`,children:a(`multirun.launcher.title`)}),r&&(0,$.jsx)(`div`,{className:`absolute right-0 flex items-center pr-3`,children:(0,$.jsxs)(B,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:r,"aria-label":a(`multirun.launcher.actions.closeEsc`),className:`inline-flex h-9 w-9 items-center justify-center p-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary app-region-no-drag`,children:(0,$.jsx)(k,{name:`close`,className:`h-5 w-5`})})}),(0,$.jsx)(z,{children:(0,$.jsx)(`p`,{children:a(`multirun.launcher.actions.closeEsc`)})})]})})]}),(0,$.jsx)(fe,{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)(ot,{htmlFor:`multirun-project`,required:!0,children:a(`multirun.launcher.project.label`)}),F.length>0?(0,$.jsxs)(ce,{value:I??void 0,onValueChange:U,children:[(0,$.jsx)(ae,{id:`multirun-project`,size:`lg`,className:`w-fit max-w-full`,children:H?(0,$.jsx)(ue,{children:st(H)}):(0,$.jsx)(ue,{placeholder:a(`multirun.launcher.project.placeholder`)})}),(0,$.jsx)(se,{fitContent:!0,children:F.map(e=>(0,$.jsx)(ie,{value:e.id,className:`max-w-[24rem]`,children:st(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)(ot,{htmlFor:`group-name`,required:!0,info:(0,$.jsx)(at,{children:a(`multirun.launcher.groupName.info`)}),children:a(`multirun.launcher.groupName.label`)}),(0,$.jsx)(L,{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)(ot,{htmlFor:`multirun-worktree-base-branch`,info:(0,$.jsx)(at,{children:a(`multirun.launcher.baseBranch.info`)}),children:a(`multirun.launcher.baseBranch.label`)}),(0,$.jsx)(Xe,{directory:pe,value:xe,onChange:Se,disabled:!Q,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)(te,{checked:j,onChange:re,disabled:!Te,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)(ot,{htmlFor:`multirun-agent`,info:(0,$.jsx)(at,{children:a(`multirun.launcher.agent.info`)}),children:a(`multirun.launcher.agent.label`)}),(0,$.jsx)(Ze,{value:d,onChange:m,id:`multirun-agent`})]})]}),(0,$.jsxs)(be,{open:O,onOpenChange:ee,children:[(0,$.jsxs)(ye,{className:`w-full flex items-center gap-2 py-1.5 px-2 -mx-2 rounded-lg hover:bg-[var(--interactive-hover)]/50 transition-colors group`,children:[(0,$.jsx)(k,{name:`terminal`,className:`h-3.5 w-3.5 text-muted-foreground/70`}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-muted-foreground group-hover:text-foreground transition-colors`,children:a(`multirun.launcher.setupCommands.label`)}),ze>0&&(0,$.jsx)(`span`,{className:`inline-flex items-center justify-center h-4 min-w-4 px-1 rounded-full typography-micro font-medium`,style:{backgroundColor:`var(--primary-base)`,color:`var(--primary-foreground)`,fontSize:`0.625rem`,lineHeight:1},children:ze}),(0,$.jsx)(k,{name:`arrow-down-s`,className:h(`h-3.5 w-3.5 text-muted-foreground/50 transition-transform duration-200 ml-auto`,O&&`rotate-180`)})]}),(0,$.jsx)(ve,{children:(0,$.jsx)(`div`,{className:`pt-2 space-y-1.5`,children:A?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground/70 px-2`,children:a(`multirun.launcher.setupCommands.loading`)}):(0,$.jsxs)($.Fragment,{children:[E.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,$.jsx)(L,{value:e,onChange:e=>{let n=[...E];n[t]=e.target.value,D(n)},placeholder:a(`multirun.launcher.setupCommands.commandPlaceholder`),className:`h-8 flex-1 font-mono text-xs`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>D(E.filter((e,n)=>n!==t)),className:`flex-shrink-0 flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":a(`multirun.launcher.setupCommands.removeCommandAria`),children:(0,$.jsx)(k,{name:`close`,className:`h-3.5 w-3.5`})})]},`${e}-${t}`)),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>D([...E,``]),className:`flex items-center gap-1 typography-meta text-muted-foreground hover:text-foreground transition-colors px-1`,children:[(0,$.jsx)(k,{name:`add`,className:`h-3 w-3`}),a(`multirun.launcher.setupCommands.addCommand`)]})]})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(ot,{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:M,type:`file`,multiple:!0,className:`hidden`,onChange:Ne,accept:`*/*`}),(0,$.jsxs)(B,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>M.current?.click(),className:`inline-flex items-center gap-1 h-6 px-2 rounded-md typography-micro text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors`,children:[(0,$.jsx)(k,{name:`attachment-2`,className:`h-3 w-3`}),a(`multirun.launcher.attachments.attach`)]})}),(0,$.jsx)(z,{children:a(`multirun.launcher.attachments.tooltip`)})]}),v.map(e=>(0,$.jsxs)(`div`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md typography-micro border`,style:{backgroundColor:`var(--surface-elevated)`,borderColor:`var(--interactive-border)`},children:[e.mimeType.startsWith(`image/`)?(0,$.jsx)(k,{name:`file-image`,className:`h-3 w-3 text-muted-foreground`}):(0,$.jsx)(k,{name:`file`,className:`h-3 w-3 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`truncate max-w-[100px]`,title:e.filename,children:e.filename}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>Fe(e.id),className:`text-muted-foreground hover:text-destructive`,children:(0,$.jsx)(k,{name:`close`,className:`h-3 w-3`})})]},e.id))]})]}),l.map((e,t)=>(0,$.jsx)(lt,{group:e,groupIndex:t,canRemove:l.length>1,onUpdate:ke,onRemove:Ae},e.id)),(0,$.jsxs)(`button`,{type:`button`,onClick:je,className:`flex items-center gap-1.5 py-2 px-3 -mx-3 rounded-lg typography-meta font-medium text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors`,children:[(0,$.jsx)(k,{name:`add`,className:`h-3.5 w-3.5`}),a(`multirun.launcher.groups.addGroup`)]}),De&&(0,$.jsx)(`div`,{className:`px-3 py-2 rounded-lg typography-meta`,style:{backgroundColor:`var(--status-error-background)`,color:`var(--status-error)`,borderWidth:1,borderColor:`var(--status-error-border)`},children:De})]})})}),(0,$.jsx)(`div`,{className:`shrink-0 px-4 sm:px-6 py-3`,children:(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl flex items-center justify-end gap-2`,children:[!Q&&Z!==null?(0,$.jsxs)(`div`,{className:`mr-auto flex min-w-0 items-center gap-1.5 typography-micro text-muted-foreground`,children:[(0,$.jsx)(k,{name:`information`,className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:a(`multirun.launcher.project.gitRequired`)})]}):null,(0,$.jsx)(g,{type:`button`,variant:`ghost`,size:`sm`,onClick:r,children:a(`multirun.launcher.actions.cancel`)}),(0,$.jsx)(g,{type:`submit`,size:`sm`,disabled:!Re||b,children:b?a(`multirun.launcher.actions.creating`):(0,$.jsx)($.Fragment,{children:a(`multirun.launcher.actions.startWithRunCount`,{count:Ie})})})]})})]})},lt=e=>{let t=(0,xe.c)(94),{group:n,groupIndex:r,canRemove:i,onUpdate:a,onRemove:o}=e,{t:s}=p(),[c,l]=X.useState(!1),[u,d]=X.useState(``),[m,h]=X.useState(!1),[g,_]=X.useState(``),v=X.useRef(null),y=X.useRef(null),b=X.useRef(null),x;t[0]!==n.id||t[1]!==n.models||t[2]!==a?(x=e=>{n.models.length>=it||a(n.id,{models:[...n.models,e]})},t[0]=n.id,t[1]=n.models,t[2]=a,t[3]=x):x=t[3];let S=f(x),C;t[4]!==n.id||t[5]!==n.models||t[6]!==a?(C=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]=C):C=t[7];let w=f(C),T;t[8]!==n.id||t[9]!==n.models||t[10]!==a?(T=(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]=T):T=t[11];let E=f(T),D;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(D=(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);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);(!e||/\s/.test(e))&&!t.includes(` `)&&!t.includes(`
3
- `)?(d(t),l(!0)):l(!1);return}l(!1)},t[12]=D):D=t[12];let O=f(D),ee;t[13]!==n.id||t[14]!==a?(ee=e=>{a(n.id,{prompt:e})},t[13]=n.id,t[14]=a,t[15]=ee):ee=t[15];let A=f(ee),te;t[16]!==n.prompt||t[17]!==A||t[18]!==O?(te=e=>{let t=n.prompt,r=v.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=he(t,i===-1?r:i,r,`@${a}`);A(o.text),l(!1),d(``),requestAnimationFrame(()=>{let e=v.current;e&&(e.selectionStart=o.caret,e.selectionEnd=o.caret,e.focus()),O(o.text,o.caret)})},t[16]=n.prompt,t[17]=A,t[18]=O,t[19]=te):te=t[19];let ne=f(te),j;t[20]!==n.prompt||t[21]!==A||t[22]!==O?(j=e=>{let t=n.prompt,r=v.current?.selectionStart??t.length,i=t.substring(0,r).lastIndexOf(`@`),a=he(t,i===-1?r:i,r,`@${e}`);A(a.text),l(!1),d(``),requestAnimationFrame(()=>{let e=v.current;e&&(e.selectionStart=a.caret,e.selectionEnd=a.caret,e.focus()),O(a.text,a.caret)})},t[20]=n.prompt,t[21]=A,t[22]=O,t[23]=j):j=t[23];let re=f(j),ie;t[24]!==A||t[25]!==O?(ie=e=>{let t=`/${e.name} `;A(t),h(!1),_(``),requestAnimationFrame(()=>{let e=v.current;e&&(e.focus(),e.selectionStart=e.value.length,e.selectionEnd=e.value.length),O(t,t.length)})},t[24]=A,t[25]=O,t[26]=ie):ie=t[26];let M=f(ie),ae;t[27]!==m||t[28]!==c?(ae=e=>{if(m&&b.current&&(e.key===`Enter`||e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`Escape`||e.key===`Tab`)){e.preventDefault(),b.current.handleKeyDown(e.key);return}c&&y.current&&(e.key===`Enter`||e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`Escape`||e.key===`Tab`)&&(e.preventDefault(),y.current.handleKeyDown(e.key))},t[27]=m,t[28]=c,t[29]=ae):ae=t[29];let oe=f(ae),N=r+1,se;t[30]!==s||t[31]!==N?(se=s(`multirun.launcher.groups.groupLabel`,{index:N}),t[30]=s,t[31]=N,t[32]=se):se=t[32];let P;t[33]===se?P=t[34]:(P=(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:se}),t[33]=se,t[34]=P);let ce;t[35]!==i||t[36]!==n.id||t[37]!==o||t[38]!==s?(ce=i&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>o(n.id),className:`inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10`,"aria-label":s(`multirun.launcher.groups.removeGroup`),children:(0,$.jsx)(k,{name:`close`,className:`h-3.5 w-3.5`})}),t[35]=i,t[36]=n.id,t[37]=o,t[38]=s,t[39]=ce):ce=t[39];let le;t[40]!==P||t[41]!==ce?(le=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[P,ce]}),t[40]=P,t[41]=ce,t[42]=le):le=t[42];let F;t[43]===s?F=t[44]:(F=s(`multirun.launcher.groups.prompt.label`),t[43]=s,t[44]=F);let ue;t[45]===F?ue=t[46]:(ue=(0,$.jsx)(ot,{required:!0,children:F}),t[45]=F,t[46]=ue);let I=n.prompt,L;t[47]!==A||t[48]!==O?(L=e=>{let t=e.target.value;A(t);let n=e.target.selectionStart??t.length;O(t,n)},t[47]=A,t[48]=O,t[49]=L):L=t[49];let R;t[50]===s?R=t[51]:(R=s(`multirun.launcher.groups.prompt.placeholder`),t[50]=s,t[51]=R);let z;t[52]!==n.prompt||t[53]!==oe||t[54]!==L||t[55]!==R?(z=(0,$.jsx)(H,{ref:v,value:I,onChange:L,onKeyDown:oe,placeholder:R,className:`typography-meta min-h-[80px] max-h-[200px] resize-none overflow-y-auto field-sizing-content`,required:!0}),t[52]=n.prompt,t[53]=oe,t[54]=L,t[55]=R,t[56]=z):z=t[56];let B;t[57]!==g||t[58]!==M||t[59]!==m?(B=m?(0,$.jsx)(ge,{ref:b,searchQuery:g,onCommandSelect:M,onClose:()=>h(!1),style:{left:0,top:`auto`,bottom:`calc(100% + 6px)`,marginBottom:0,maxWidth:`100%`}}):null,t[57]=g,t[58]=M,t[59]=m,t[60]=B):B=t[60];let de;t[61]!==re||t[62]!==ne||t[63]!==u||t[64]!==c?(de=c?(0,$.jsx)(pe,{ref:y,searchQuery:u,onFileSelect:ne,onAgentSelect:re,onSkillSelect:e=>re(e.name),onClose:()=>l(!1),style:{left:0,top:`auto`,bottom:`calc(100% + 6px)`,marginBottom:0,maxWidth:`100%`}}):null,t[61]=re,t[62]=ne,t[63]=u,t[64]=c,t[65]=de):de=t[65];let V;t[66]!==z||t[67]!==B||t[68]!==de?(V=(0,$.jsxs)(`div`,{className:`relative`,children:[z,B,de]}),t[66]=z,t[67]=B,t[68]=de,t[69]=V):V=t[69];let fe;t[70]!==ue||t[71]!==V?(fe=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[ue,V]}),t[70]=ue,t[71]=V,t[72]=fe):fe=t[72];let U;t[73]===s?U=t[74]:(U=s(`multirun.launcher.models.info`,{max:it}),t[73]=s,t[74]=U);let W;t[75]===U?W=t[76]:(W=(0,$.jsx)(at,{children:U}),t[75]=U,t[76]=W);let G;t[77]===s?G=t[78]:(G=s(`multirun.launcher.models.label`),t[77]=s,t[78]=G);let K;t[79]!==W||t[80]!==G?(K=(0,$.jsx)(ot,{required:!0,info:W,children:G}),t[79]=W,t[80]=G,t[81]=K):K=t[81];let q;t[82]!==n.models||t[83]!==S||t[84]!==w||t[85]!==E?(q=(0,$.jsx)(Ie,{selectedModels:n.models,onAdd:S,onRemove:w,onUpdate:E,minModels:1,maxModels:it}),t[82]=n.models,t[83]=S,t[84]=w,t[85]=E,t[86]=q):q=t[86];let J;t[87]!==K||t[88]!==q?(J=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[K,q]}),t[87]=K,t[88]=q,t[89]=J):J=t[89];let Y;return t[90]!==le||t[91]!==fe||t[92]!==J?(Y=(0,$.jsxs)(`div`,{className:`rounded-lg border border-border p-3 space-y-3`,children:[le,fe,J]}),t[90]=le,t[91]=fe,t[92]=J,t[93]=Y):Y=t[93],Y};export{Q as a,Pe as i,Ze as n,we as o,Ie as r,ct as t};