remote-codex 0.11.20 → 0.11.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/supervisor-api/dist/index.js +64 -4
- package/apps/supervisor-web/dist/assets/{index-BdeDlmJY.js → index-BfspE5mQ.js} +1 -1
- package/apps/supervisor-web/dist/assets/{thread-ui-C5nUCiEf.js → thread-ui-CDgAOcDh.js} +33 -26
- package/apps/supervisor-web/dist/index.html +2 -2
- package/package.json +1 -1
- package/packages/claude/src/runtimeAdapter.test.ts +6 -1
- package/packages/claude/src/runtimeAdapter.ts +19 -0
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/core-oEok_Crl.js","assets/markdown-vendor-BQJfKm05.js","assets/react-vendor-CgLzZcV4.js","assets/html-pp8916En.js","assets/javascript-wDzz0qaB.js","assets/css-CLj8gQPS.js","assets/terminal-vendor-B365Go3Z.js","assets/terminal-vendor-Beg8tuEN.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{l as G,R as _i,I as Ai,H as $i,T as Di,C as Bi,S as zs,a as Gi,b as Fi,c as Hi,d as Oi,e as Ui,D as Wi,P as Vi,O as Ki,f as qi,g as Xi,h as Yi,i as Zi,j as Ji,k as Qi,m as ed,n as td,A as rd,o as nd,p as ad}from"./ui-vendor-CeKGesq3.js";import{r as c,R as sd,j as t,b as Dr}from"./react-vendor-CgLzZcV4.js";import{u as od,a as ld,H as xa,P as Pt,b as id,M as Is,R as dd,i as cd,C as hd,B as ud,c as ba,g as Rs}from"./graph-vendor-DVPtkh3h.js";import"./terminal-vendor-B365Go3Z.js";import{M as md,r as pd,a as fd,b as gd}from"./markdown-vendor-BQJfKm05.js";const xd="modulepreload",bd=function(e){return"/"+e},va={},Ue=function(r,n,a){let s=Promise.resolve();if(n&&n.length>0){let l=function(h){return Promise.all(h.map(u=>Promise.resolve(u).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),d=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));s=l(n.map(h=>{if(h=bd(h),h in va)return;va[h]=!0;const u=h.endsWith(".css"),m=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${m}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":xd,u||(f.as="script"),f.crossOrigin="",f.href=h,d&&f.setAttribute("nonce",d),document.head.appendChild(f),u)return new Promise((p,g)=>{f.addEventListener("load",p),f.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${h}`)))})}))}function o(l){const i=new Event("vite:preloadError",{cancelable:!0});if(i.payload=l,window.dispatchEvent(i),!i.defaultPrevented)throw l}return s.then(l=>{for(const i of l||[])i.status==="rejected"&&o(i.reason);return r().catch(o)})};function Ms(e){var r,n,a="";if(typeof e=="string"||typeof e=="number")a+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(r=0;r<s;r++)e[r]&&(n=Ms(e[r]))&&(a&&(a+=" "),a+=n)}else for(n in e)e[n]&&(a&&(a+=" "),a+=n);return a}function _s(){for(var e,r,n=0,a="",s=arguments.length;n<s;n++)(e=arguments[n])&&(r=Ms(e))&&(a&&(a+=" "),a+=r);return a}const vd=(e,r)=>{const n=new Array(e.length+r.length);for(let a=0;a<e.length;a++)n[a]=e[a];for(let a=0;a<r.length;a++)n[e.length+a]=r[a];return n},kd=(e,r)=>({classGroupId:e,validator:r}),As=(e=new Map,r=null,n)=>({nextPart:e,validators:r,classGroupId:n}),Ir="-",ka=[],wd="arbitrary..",yd=e=>{const r=Nd(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:a}=e;return{getClassGroupId:l=>{if(l.startsWith("[")&&l.endsWith("]"))return jd(l);const i=l.split(Ir),d=i[0]===""&&i.length>1?1:0;return $s(i,d,r)},getConflictingClassGroupIds:(l,i)=>{if(i){const d=a[l],h=n[l];return d?h?vd(h,d):d:h||ka}return n[l]||ka}}},$s=(e,r,n)=>{if(e.length-r===0)return n.classGroupId;const s=e[r],o=n.nextPart.get(s);if(o){const h=$s(e,r+1,o);if(h)return h}const l=n.validators;if(l===null)return;const i=r===0?e.join(Ir):e.slice(r).join(Ir),d=l.length;for(let h=0;h<d;h++){const u=l[h];if(u.validator(i))return u.classGroupId}},jd=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const r=e.slice(1,-1),n=r.indexOf(":"),a=r.slice(0,n);return a?wd+a:void 0})(),Nd=e=>{const{theme:r,classGroups:n}=e;return Cd(n,r)},Cd=(e,r)=>{const n=As();for(const a in e){const s=e[a];Vn(s,n,a,r)}return n},Vn=(e,r,n,a)=>{const s=e.length;for(let o=0;o<s;o++){const l=e[o];Sd(l,r,n,a)}},Sd=(e,r,n,a)=>{if(typeof e=="string"){Td(e,r,n);return}if(typeof e=="function"){Ed(e,r,n,a);return}Ld(e,r,n,a)},Td=(e,r,n)=>{const a=e===""?r:Ds(r,e);a.classGroupId=n},Ed=(e,r,n,a)=>{if(Pd(e)){Vn(e(a),r,n,a);return}r.validators===null&&(r.validators=[]),r.validators.push(kd(n,e))},Ld=(e,r,n,a)=>{const s=Object.entries(e),o=s.length;for(let l=0;l<o;l++){const[i,d]=s[l];Vn(d,Ds(r,i),n,a)}},Ds=(e,r)=>{let n=e;const a=r.split(Ir),s=a.length;for(let o=0;o<s;o++){const l=a[o];let i=n.nextPart.get(l);i||(i=As(),n.nextPart.set(l,i)),n=i}return n},Pd=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,zd=e=>{if(e<1)return{get:()=>{},set:()=>{}};let r=0,n=Object.create(null),a=Object.create(null);const s=(o,l)=>{n[o]=l,r++,r>e&&(r=0,a=n,n=Object.create(null))};return{get(o){let l=n[o];if(l!==void 0)return l;if((l=a[o])!==void 0)return s(o,l),l},set(o,l){o in n?n[o]=l:s(o,l)}}},Cn="!",wa=":",Id=[],ya=(e,r,n,a,s)=>({modifiers:e,hasImportantModifier:r,baseClassName:n,maybePostfixModifierPosition:a,isExternal:s}),Rd=e=>{const{prefix:r,experimentalParseClassName:n}=e;let a=s=>{const o=[];let l=0,i=0,d=0,h;const u=s.length;for(let b=0;b<u;b++){const v=s[b];if(l===0&&i===0){if(v===wa){o.push(s.slice(d,b)),d=b+1;continue}if(v==="/"){h=b;continue}}v==="["?l++:v==="]"?l--:v==="("?i++:v===")"&&i--}const m=o.length===0?s:s.slice(d);let f=m,p=!1;m.endsWith(Cn)?(f=m.slice(0,-1),p=!0):m.startsWith(Cn)&&(f=m.slice(1),p=!0);const g=h&&h>d?h-d:void 0;return ya(o,p,f,g)};if(r){const s=r+wa,o=a;a=l=>l.startsWith(s)?o(l.slice(s.length)):ya(Id,!1,l,void 0,!0)}if(n){const s=a;a=o=>n({className:o,parseClassName:s})}return a},Md=e=>{const r=new Map;return e.orderSensitiveModifiers.forEach((n,a)=>{r.set(n,1e6+a)}),n=>{const a=[];let s=[];for(let o=0;o<n.length;o++){const l=n[o],i=l[0]==="[",d=r.has(l);i||d?(s.length>0&&(s.sort(),a.push(...s),s=[]),a.push(l)):s.push(l)}return s.length>0&&(s.sort(),a.push(...s)),a}},_d=e=>({cache:zd(e.cacheSize),parseClassName:Rd(e),sortModifiers:Md(e),postfixLookupClassGroupIds:Ad(e),...yd(e)}),Ad=e=>{const r=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let a=0;a<n.length;a++)r[n[a]]=!0;return r},$d=/\s+/,Dd=(e,r)=>{const{parseClassName:n,getClassGroupId:a,getConflictingClassGroupIds:s,sortModifiers:o,postfixLookupClassGroupIds:l}=r,i=[],d=e.trim().split($d);let h="";for(let u=d.length-1;u>=0;u-=1){const m=d[u],{isExternal:f,modifiers:p,hasImportantModifier:g,baseClassName:b,maybePostfixModifierPosition:v}=n(m);if(f){h=m+(h.length>0?" "+h:h);continue}let x=!!v,y;if(x){const S=b.substring(0,v);y=a(S);const L=y&&l[y]?a(b):void 0;L&&L!==y&&(y=L,x=!1)}else y=a(b);if(!y){if(!x){h=m+(h.length>0?" "+h:h);continue}if(y=a(b),!y){h=m+(h.length>0?" "+h:h);continue}x=!1}const k=p.length===0?"":p.length===1?p[0]:o(p).join(":"),j=g?k+Cn:k,w=j+y;if(i.indexOf(w)>-1)continue;i.push(w);const N=s(y,x);for(let S=0;S<N.length;++S){const L=N[S];i.push(j+L)}h=m+(h.length>0?" "+h:h)}return h},Bd=(...e)=>{let r=0,n,a,s="";for(;r<e.length;)(n=e[r++])&&(a=Bs(n))&&(s&&(s+=" "),s+=a);return s},Bs=e=>{if(typeof e=="string")return e;let r,n="";for(let a=0;a<e.length;a++)e[a]&&(r=Bs(e[a]))&&(n&&(n+=" "),n+=r);return n},Gd=(e,...r)=>{let n,a,s,o;const l=d=>{const h=r.reduce((u,m)=>m(u),e());return n=_d(h),a=n.cache.get,s=n.cache.set,o=i,i(d)},i=d=>{const h=a(d);if(h)return h;const u=Dd(d,n);return s(d,u),u};return o=l,(...d)=>o(Bd(...d))},Fd=[],Xe=e=>{const r=n=>n[e]||Fd;return r.isThemeGetter=!0,r},Gs=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Fs=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Hd=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Od=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Ud=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Wd=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Vd=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Kd=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,vt=e=>Hd.test(e),Se=e=>!!e&&!Number.isNaN(Number(e)),ut=e=>!!e&&Number.isInteger(Number(e)),sn=e=>e.endsWith("%")&&Se(e.slice(0,-1)),ft=e=>Od.test(e),Hs=()=>!0,qd=e=>Ud.test(e)&&!Wd.test(e),Kn=()=>!1,Xd=e=>Vd.test(e),Yd=e=>Kd.test(e),Zd=e=>!oe(e)&&!le(e),Jd=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),Qd=e=>jt(e,Ws,Kn),oe=e=>Gs.test(e),Tt=e=>jt(e,Vs,qd),ja=e=>jt(e,lc,Se),ec=e=>jt(e,qs,Hs),tc=e=>jt(e,Ks,Kn),Na=e=>jt(e,Os,Kn),rc=e=>jt(e,Us,Yd),kr=e=>jt(e,Xs,Xd),le=e=>Fs.test(e),rr=e=>$t(e,Vs),nc=e=>$t(e,Ks),Ca=e=>$t(e,Os),ac=e=>$t(e,Ws),sc=e=>$t(e,Us),wr=e=>$t(e,Xs,!0),oc=e=>$t(e,qs,!0),jt=(e,r,n)=>{const a=Gs.exec(e);return a?a[1]?r(a[1]):n(a[2]):!1},$t=(e,r,n=!1)=>{const a=Fs.exec(e);return a?a[1]?r(a[1]):n:!1},Os=e=>e==="position"||e==="percentage",Us=e=>e==="image"||e==="url",Ws=e=>e==="length"||e==="size"||e==="bg-size",Vs=e=>e==="length",lc=e=>e==="number",Ks=e=>e==="family-name",qs=e=>e==="number"||e==="weight",Xs=e=>e==="shadow",ic=()=>{const e=Xe("color"),r=Xe("font"),n=Xe("text"),a=Xe("font-weight"),s=Xe("tracking"),o=Xe("leading"),l=Xe("breakpoint"),i=Xe("container"),d=Xe("spacing"),h=Xe("radius"),u=Xe("shadow"),m=Xe("inset-shadow"),f=Xe("text-shadow"),p=Xe("drop-shadow"),g=Xe("blur"),b=Xe("perspective"),v=Xe("aspect"),x=Xe("ease"),y=Xe("animate"),k=()=>["auto","avoid","all","avoid-page","page","left","right","column"],j=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],w=()=>[...j(),le,oe],N=()=>["auto","hidden","clip","visible","scroll"],S=()=>["auto","contain","none"],L=()=>[le,oe,d],T=()=>[vt,"full","auto",...L()],q=()=>[ut,"none","subgrid",le,oe],A=()=>["auto",{span:["full",ut,le,oe]},ut,le,oe],D=()=>[ut,"auto",le,oe],J=()=>["auto","min","max","fr",le,oe],W=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],O=()=>["start","end","center","stretch","center-safe","end-safe"],ee=()=>["auto",...L()],he=()=>[vt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...L()],E=()=>[vt,"screen","full","dvw","lvw","svw","min","max","fit",...L()],re=()=>[vt,"screen","full","lh","dvh","lvh","svh","min","max","fit",...L()],_=()=>[e,le,oe],V=()=>[...j(),Ca,Na,{position:[le,oe]}],U=()=>["no-repeat",{repeat:["","x","y","space","round"]}],z=()=>["auto","cover","contain",ac,Qd,{size:[le,oe]}],X=()=>[sn,rr,Tt],F=()=>["","none","full",h,le,oe],I=()=>["",Se,rr,Tt],P=()=>["solid","dashed","dotted","double"],Z=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],K=()=>[Se,sn,Ca,Na],de=()=>["","none",g,le,oe],M=()=>["none",Se,le,oe],Y=()=>["none",Se,le,oe],te=()=>[Se,le,oe],ie=()=>[vt,"full",...L()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ft],breakpoint:[ft],color:[Hs],container:[ft],"drop-shadow":[ft],ease:["in","out","in-out"],font:[Zd],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ft],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ft],shadow:[ft],spacing:["px",Se],text:[ft],"text-shadow":[ft],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",vt,oe,le,v]}],container:["container"],"container-type":[{"@container":["","normal","size",le,oe]}],"container-named":[Jd],columns:[{columns:[Se,oe,le,i]}],"break-after":[{"break-after":k()}],"break-before":[{"break-before":k()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:w()}],overflow:[{overflow:N()}],"overflow-x":[{"overflow-x":N()}],"overflow-y":[{"overflow-y":N()}],overscroll:[{overscroll:S()}],"overscroll-x":[{"overscroll-x":S()}],"overscroll-y":[{"overscroll-y":S()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{"inset-s":T(),start:T()}],end:[{"inset-e":T(),end:T()}],"inset-bs":[{"inset-bs":T()}],"inset-be":[{"inset-be":T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:["visible","invisible","collapse"],z:[{z:[ut,"auto",le,oe]}],basis:[{basis:[vt,"full","auto",i,...L()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Se,vt,"auto","initial","none",oe]}],grow:[{grow:["",Se,le,oe]}],shrink:[{shrink:["",Se,le,oe]}],order:[{order:[ut,"first","last","none",le,oe]}],"grid-cols":[{"grid-cols":q()}],"col-start-end":[{col:A()}],"col-start":[{"col-start":D()}],"col-end":[{"col-end":D()}],"grid-rows":[{"grid-rows":q()}],"row-start-end":[{row:A()}],"row-start":[{"row-start":D()}],"row-end":[{"row-end":D()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":J()}],"auto-rows":[{"auto-rows":J()}],gap:[{gap:L()}],"gap-x":[{"gap-x":L()}],"gap-y":[{"gap-y":L()}],"justify-content":[{justify:[...W(),"normal"]}],"justify-items":[{"justify-items":[...O(),"normal"]}],"justify-self":[{"justify-self":["auto",...O()]}],"align-content":[{content:["normal",...W()]}],"align-items":[{items:[...O(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...O(),{baseline:["","last"]}]}],"place-content":[{"place-content":W()}],"place-items":[{"place-items":[...O(),"baseline"]}],"place-self":[{"place-self":["auto",...O()]}],p:[{p:L()}],px:[{px:L()}],py:[{py:L()}],ps:[{ps:L()}],pe:[{pe:L()}],pbs:[{pbs:L()}],pbe:[{pbe:L()}],pt:[{pt:L()}],pr:[{pr:L()}],pb:[{pb:L()}],pl:[{pl:L()}],m:[{m:ee()}],mx:[{mx:ee()}],my:[{my:ee()}],ms:[{ms:ee()}],me:[{me:ee()}],mbs:[{mbs:ee()}],mbe:[{mbe:ee()}],mt:[{mt:ee()}],mr:[{mr:ee()}],mb:[{mb:ee()}],ml:[{ml:ee()}],"space-x":[{"space-x":L()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":L()}],"space-y-reverse":["space-y-reverse"],size:[{size:he()}],"inline-size":[{inline:["auto",...E()]}],"min-inline-size":[{"min-inline":["auto",...E()]}],"max-inline-size":[{"max-inline":["none",...E()]}],"block-size":[{block:["auto",...re()]}],"min-block-size":[{"min-block":["auto",...re()]}],"max-block-size":[{"max-block":["none",...re()]}],w:[{w:[i,"screen",...he()]}],"min-w":[{"min-w":[i,"screen","none",...he()]}],"max-w":[{"max-w":[i,"screen","none","prose",{screen:[l]},...he()]}],h:[{h:["screen","lh",...he()]}],"min-h":[{"min-h":["screen","lh","none",...he()]}],"max-h":[{"max-h":["screen","lh",...he()]}],"font-size":[{text:["base",n,rr,Tt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,oc,ec]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",sn,oe]}],"font-family":[{font:[nc,tc,r]}],"font-features":[{"font-features":[oe]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[s,le,oe]}],"line-clamp":[{"line-clamp":[Se,"none",le,ja]}],leading:[{leading:[o,...L()]}],"list-image":[{"list-image":["none",le,oe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",le,oe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:_()}],"text-color":[{text:_()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...P(),"wavy"]}],"text-decoration-thickness":[{decoration:[Se,"from-font","auto",le,Tt]}],"text-decoration-color":[{decoration:_()}],"underline-offset":[{"underline-offset":[Se,"auto",le,oe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:L()}],"tab-size":[{tab:[ut,le,oe]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",le,oe]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",le,oe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:V()}],"bg-repeat":[{bg:U()}],"bg-size":[{bg:z()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},ut,le,oe],radial:["",le,oe],conic:[ut,le,oe]},sc,rc]}],"bg-color":[{bg:_()}],"gradient-from-pos":[{from:X()}],"gradient-via-pos":[{via:X()}],"gradient-to-pos":[{to:X()}],"gradient-from":[{from:_()}],"gradient-via":[{via:_()}],"gradient-to":[{to:_()}],rounded:[{rounded:F()}],"rounded-s":[{"rounded-s":F()}],"rounded-e":[{"rounded-e":F()}],"rounded-t":[{"rounded-t":F()}],"rounded-r":[{"rounded-r":F()}],"rounded-b":[{"rounded-b":F()}],"rounded-l":[{"rounded-l":F()}],"rounded-ss":[{"rounded-ss":F()}],"rounded-se":[{"rounded-se":F()}],"rounded-ee":[{"rounded-ee":F()}],"rounded-es":[{"rounded-es":F()}],"rounded-tl":[{"rounded-tl":F()}],"rounded-tr":[{"rounded-tr":F()}],"rounded-br":[{"rounded-br":F()}],"rounded-bl":[{"rounded-bl":F()}],"border-w":[{border:I()}],"border-w-x":[{"border-x":I()}],"border-w-y":[{"border-y":I()}],"border-w-s":[{"border-s":I()}],"border-w-e":[{"border-e":I()}],"border-w-bs":[{"border-bs":I()}],"border-w-be":[{"border-be":I()}],"border-w-t":[{"border-t":I()}],"border-w-r":[{"border-r":I()}],"border-w-b":[{"border-b":I()}],"border-w-l":[{"border-l":I()}],"divide-x":[{"divide-x":I()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":I()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...P(),"hidden","none"]}],"divide-style":[{divide:[...P(),"hidden","none"]}],"border-color":[{border:_()}],"border-color-x":[{"border-x":_()}],"border-color-y":[{"border-y":_()}],"border-color-s":[{"border-s":_()}],"border-color-e":[{"border-e":_()}],"border-color-bs":[{"border-bs":_()}],"border-color-be":[{"border-be":_()}],"border-color-t":[{"border-t":_()}],"border-color-r":[{"border-r":_()}],"border-color-b":[{"border-b":_()}],"border-color-l":[{"border-l":_()}],"divide-color":[{divide:_()}],"outline-style":[{outline:[...P(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Se,le,oe]}],"outline-w":[{outline:["",Se,rr,Tt]}],"outline-color":[{outline:_()}],shadow:[{shadow:["","none",u,wr,kr]}],"shadow-color":[{shadow:_()}],"inset-shadow":[{"inset-shadow":["none",m,wr,kr]}],"inset-shadow-color":[{"inset-shadow":_()}],"ring-w":[{ring:I()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:_()}],"ring-offset-w":[{"ring-offset":[Se,Tt]}],"ring-offset-color":[{"ring-offset":_()}],"inset-ring-w":[{"inset-ring":I()}],"inset-ring-color":[{"inset-ring":_()}],"text-shadow":[{"text-shadow":["none",f,wr,kr]}],"text-shadow-color":[{"text-shadow":_()}],opacity:[{opacity:[Se,le,oe]}],"mix-blend":[{"mix-blend":[...Z(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Z()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Se]}],"mask-image-linear-from-pos":[{"mask-linear-from":K()}],"mask-image-linear-to-pos":[{"mask-linear-to":K()}],"mask-image-linear-from-color":[{"mask-linear-from":_()}],"mask-image-linear-to-color":[{"mask-linear-to":_()}],"mask-image-t-from-pos":[{"mask-t-from":K()}],"mask-image-t-to-pos":[{"mask-t-to":K()}],"mask-image-t-from-color":[{"mask-t-from":_()}],"mask-image-t-to-color":[{"mask-t-to":_()}],"mask-image-r-from-pos":[{"mask-r-from":K()}],"mask-image-r-to-pos":[{"mask-r-to":K()}],"mask-image-r-from-color":[{"mask-r-from":_()}],"mask-image-r-to-color":[{"mask-r-to":_()}],"mask-image-b-from-pos":[{"mask-b-from":K()}],"mask-image-b-to-pos":[{"mask-b-to":K()}],"mask-image-b-from-color":[{"mask-b-from":_()}],"mask-image-b-to-color":[{"mask-b-to":_()}],"mask-image-l-from-pos":[{"mask-l-from":K()}],"mask-image-l-to-pos":[{"mask-l-to":K()}],"mask-image-l-from-color":[{"mask-l-from":_()}],"mask-image-l-to-color":[{"mask-l-to":_()}],"mask-image-x-from-pos":[{"mask-x-from":K()}],"mask-image-x-to-pos":[{"mask-x-to":K()}],"mask-image-x-from-color":[{"mask-x-from":_()}],"mask-image-x-to-color":[{"mask-x-to":_()}],"mask-image-y-from-pos":[{"mask-y-from":K()}],"mask-image-y-to-pos":[{"mask-y-to":K()}],"mask-image-y-from-color":[{"mask-y-from":_()}],"mask-image-y-to-color":[{"mask-y-to":_()}],"mask-image-radial":[{"mask-radial":[le,oe]}],"mask-image-radial-from-pos":[{"mask-radial-from":K()}],"mask-image-radial-to-pos":[{"mask-radial-to":K()}],"mask-image-radial-from-color":[{"mask-radial-from":_()}],"mask-image-radial-to-color":[{"mask-radial-to":_()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":j()}],"mask-image-conic-pos":[{"mask-conic":[Se]}],"mask-image-conic-from-pos":[{"mask-conic-from":K()}],"mask-image-conic-to-pos":[{"mask-conic-to":K()}],"mask-image-conic-from-color":[{"mask-conic-from":_()}],"mask-image-conic-to-color":[{"mask-conic-to":_()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:V()}],"mask-repeat":[{mask:U()}],"mask-size":[{mask:z()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",le,oe]}],filter:[{filter:["","none",le,oe]}],blur:[{blur:de()}],brightness:[{brightness:[Se,le,oe]}],contrast:[{contrast:[Se,le,oe]}],"drop-shadow":[{"drop-shadow":["","none",p,wr,kr]}],"drop-shadow-color":[{"drop-shadow":_()}],grayscale:[{grayscale:["",Se,le,oe]}],"hue-rotate":[{"hue-rotate":[Se,le,oe]}],invert:[{invert:["",Se,le,oe]}],saturate:[{saturate:[Se,le,oe]}],sepia:[{sepia:["",Se,le,oe]}],"backdrop-filter":[{"backdrop-filter":["","none",le,oe]}],"backdrop-blur":[{"backdrop-blur":de()}],"backdrop-brightness":[{"backdrop-brightness":[Se,le,oe]}],"backdrop-contrast":[{"backdrop-contrast":[Se,le,oe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Se,le,oe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Se,le,oe]}],"backdrop-invert":[{"backdrop-invert":["",Se,le,oe]}],"backdrop-opacity":[{"backdrop-opacity":[Se,le,oe]}],"backdrop-saturate":[{"backdrop-saturate":[Se,le,oe]}],"backdrop-sepia":[{"backdrop-sepia":["",Se,le,oe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":L()}],"border-spacing-x":[{"border-spacing-x":L()}],"border-spacing-y":[{"border-spacing-y":L()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",le,oe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Se,"initial",le,oe]}],ease:[{ease:["linear","initial",x,le,oe]}],delay:[{delay:[Se,le,oe]}],animate:[{animate:["none",y,le,oe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,le,oe]}],"perspective-origin":[{"perspective-origin":w()}],rotate:[{rotate:M()}],"rotate-x":[{"rotate-x":M()}],"rotate-y":[{"rotate-y":M()}],"rotate-z":[{"rotate-z":M()}],scale:[{scale:Y()}],"scale-x":[{"scale-x":Y()}],"scale-y":[{"scale-y":Y()}],"scale-z":[{"scale-z":Y()}],"scale-3d":["scale-3d"],skew:[{skew:te()}],"skew-x":[{"skew-x":te()}],"skew-y":[{"skew-y":te()}],transform:[{transform:[le,oe,"","none","gpu","cpu"]}],"transform-origin":[{origin:w()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ie()}],"translate-x":[{"translate-x":ie()}],"translate-y":[{"translate-y":ie()}],"translate-z":[{"translate-z":ie()}],"translate-none":["translate-none"],zoom:[{zoom:[ut,le,oe]}],accent:[{accent:_()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:_()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",le,oe]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":_()}],"scrollbar-track-color":[{"scrollbar-track":_()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":L()}],"scroll-mx":[{"scroll-mx":L()}],"scroll-my":[{"scroll-my":L()}],"scroll-ms":[{"scroll-ms":L()}],"scroll-me":[{"scroll-me":L()}],"scroll-mbs":[{"scroll-mbs":L()}],"scroll-mbe":[{"scroll-mbe":L()}],"scroll-mt":[{"scroll-mt":L()}],"scroll-mr":[{"scroll-mr":L()}],"scroll-mb":[{"scroll-mb":L()}],"scroll-ml":[{"scroll-ml":L()}],"scroll-p":[{"scroll-p":L()}],"scroll-px":[{"scroll-px":L()}],"scroll-py":[{"scroll-py":L()}],"scroll-ps":[{"scroll-ps":L()}],"scroll-pe":[{"scroll-pe":L()}],"scroll-pbs":[{"scroll-pbs":L()}],"scroll-pbe":[{"scroll-pbe":L()}],"scroll-pt":[{"scroll-pt":L()}],"scroll-pr":[{"scroll-pr":L()}],"scroll-pb":[{"scroll-pb":L()}],"scroll-pl":[{"scroll-pl":L()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",le,oe]}],fill:[{fill:["none",..._()]}],"stroke-w":[{stroke:[Se,rr,Tt,ja]}],stroke:[{stroke:["none",..._()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},dc=Gd(ic),Sa=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Ta=_s,mr=(e,r)=>n=>{var a;if((r==null?void 0:r.variants)==null)return Ta(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:s,defaultVariants:o}=r,l=Object.keys(s).map(h=>{const u=n==null?void 0:n[h],m=o==null?void 0:o[h];if(u===null)return null;const f=Sa(u)||Sa(m);return s[h][f]}),i=n&&Object.entries(n).reduce((h,u)=>{let[m,f]=u;return f===void 0||(h[m]=f),h},{}),d=r==null||(a=r.compoundVariants)===null||a===void 0?void 0:a.reduce((h,u)=>{let{class:m,className:f,...p}=u;return Object.entries(p).every(g=>{let[b,v]=g;return Array.isArray(v)?v.includes({...o,...i}[b]):{...o,...i}[b]===v})?[...h,m,f]:h},[]);return Ta(e,l,d,n==null?void 0:n.class,n==null?void 0:n.className)},Br=c.createContext(null);Br.displayName="PanelGroupContext";const Fe={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},qn=10,Rt=c.useLayoutEffect,Ea=sd.useId,cc=typeof Ea=="function"?Ea:()=>null;let hc=0;function Xn(e=null){const r=cc(),n=c.useRef(e||r||null);return n.current===null&&(n.current=""+hc++),e??n.current}function Ys({children:e,className:r="",collapsedSize:n,collapsible:a,defaultSize:s,forwardedRef:o,id:l,maxSize:i,minSize:d,onCollapse:h,onExpand:u,onResize:m,order:f,style:p,tagName:g="div",...b}){const v=c.useContext(Br);if(v===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:x,expandPanel:y,getPanelSize:k,getPanelStyle:j,groupId:w,isPanelCollapsed:N,reevaluatePanelConstraints:S,registerPanel:L,resizePanel:T,unregisterPanel:q}=v,A=Xn(l),D=c.useRef({callbacks:{onCollapse:h,onExpand:u,onResize:m},constraints:{collapsedSize:n,collapsible:a,defaultSize:s,maxSize:i,minSize:d},id:A,idIsFromProps:l!==void 0,order:f});c.useRef({didLogMissingDefaultSizeWarning:!1}),Rt(()=>{const{callbacks:W,constraints:O}=D.current,ee={...O};D.current.id=A,D.current.idIsFromProps=l!==void 0,D.current.order=f,W.onCollapse=h,W.onExpand=u,W.onResize=m,O.collapsedSize=n,O.collapsible=a,O.defaultSize=s,O.maxSize=i,O.minSize=d,(ee.collapsedSize!==O.collapsedSize||ee.collapsible!==O.collapsible||ee.maxSize!==O.maxSize||ee.minSize!==O.minSize)&&S(D.current,ee)}),Rt(()=>{const W=D.current;return L(W),()=>{q(W)}},[f,A,L,q]),c.useImperativeHandle(o,()=>({collapse:()=>{x(D.current)},expand:W=>{y(D.current,W)},getId(){return A},getSize(){return k(D.current)},isCollapsed(){return N(D.current)},isExpanded(){return!N(D.current)},resize:W=>{T(D.current,W)}}),[x,y,k,N,A,T]);const J=j(D.current,s);return c.createElement(g,{...b,children:e,className:r,id:A,style:{...J,...p},[Fe.groupId]:w,[Fe.panel]:"",[Fe.panelCollapsible]:a||void 0,[Fe.panelId]:A,[Fe.panelSize]:parseFloat(""+J.flexGrow).toFixed(1)})}const Zs=c.forwardRef((e,r)=>c.createElement(Ys,{...e,forwardedRef:r}));Ys.displayName="Panel";Zs.displayName="forwardRef(Panel)";let Sn=null,Tr=-1,wt=null;function uc(e,r,n){const a=(r&ro)!==0,s=(r&no)!==0,o=(r&ao)!==0,l=(r&so)!==0;if(r){if(a)return o?"se-resize":l?"ne-resize":"e-resize";if(s)return o?"sw-resize":l?"nw-resize":"w-resize";if(o)return"s-resize";if(l)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function mc(){wt!==null&&(document.head.removeChild(wt),Sn=null,wt=null,Tr=-1)}function on(e,r,n){var a,s;const o=uc(e,r);if(Sn!==o){if(Sn=o,wt===null&&(wt=document.createElement("style"),document.head.appendChild(wt)),Tr>=0){var l;(l=wt.sheet)===null||l===void 0||l.removeRule(Tr)}Tr=(a=(s=wt.sheet)===null||s===void 0?void 0:s.insertRule(`*{cursor: ${o} !important;}`))!==null&&a!==void 0?a:-1}}function Js(e){return e.type==="keydown"}function Qs(e){return e.type.startsWith("pointer")}function eo(e){return e.type.startsWith("mouse")}function Gr(e){if(Qs(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(eo(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function pc(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function fc(e,r,n){return e.x<r.x+r.width&&e.x+e.width>r.x&&e.y<r.y+r.height&&e.y+e.height>r.y}function gc(e,r){if(e===r)throw new Error("Cannot compare node with itself");const n={a:za(e),b:za(r)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),r=n.b.pop(),a=e;Ne(a,"Stacking order can only be calculated for elements with a common ancestor");const s={a:Pa(La(n.a)),b:Pa(La(n.b))};if(s.a===s.b){const o=a.childNodes,l={a:n.a.at(-1),b:n.b.at(-1)};let i=o.length;for(;i--;){const d=o[i];if(d===l.a)return 1;if(d===l.b)return-1}}return Math.sign(s.a-s.b)}const xc=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function bc(e){var r;const n=getComputedStyle((r=to(e))!==null&&r!==void 0?r:e).display;return n==="flex"||n==="inline-flex"}function vc(e){const r=getComputedStyle(e);return!!(r.position==="fixed"||r.zIndex!=="auto"&&(r.position!=="static"||bc(e))||+r.opacity<1||"transform"in r&&r.transform!=="none"||"webkitTransform"in r&&r.webkitTransform!=="none"||"mixBlendMode"in r&&r.mixBlendMode!=="normal"||"filter"in r&&r.filter!=="none"||"webkitFilter"in r&&r.webkitFilter!=="none"||"isolation"in r&&r.isolation==="isolate"||xc.test(r.willChange)||r.webkitOverflowScrolling==="touch")}function La(e){let r=e.length;for(;r--;){const n=e[r];if(Ne(n,"Missing node"),vc(n))return n}return null}function Pa(e){return e&&Number(getComputedStyle(e).zIndex)||0}function za(e){const r=[];for(;e;)r.push(e),e=to(e);return r}function to(e){const{parentNode:r}=e;return r&&r instanceof ShadowRoot?r.host:r}const ro=1,no=2,ao=4,so=8,kc=pc()==="coarse";let ct=[],Yt=!1,yt=new Map,Fr=new Map;const cr=new Set;function wc(e,r,n,a,s){var o;const{ownerDocument:l}=r,i={direction:n,element:r,hitAreaMargins:a,setResizeHandlerState:s},d=(o=yt.get(l))!==null&&o!==void 0?o:0;return yt.set(l,d+1),cr.add(i),Rr(),function(){var u;Fr.delete(e),cr.delete(i);const m=(u=yt.get(l))!==null&&u!==void 0?u:1;if(yt.set(l,m-1),Rr(),m===1&&yt.delete(l),ct.includes(i)){const f=ct.indexOf(i);f>=0&&ct.splice(f,1),Hr(),s("up",!0,null)}}}function yc(e){const{target:r}=e,{x:n,y:a}=Gr(e);Yt=!0,Yn({target:r,x:n,y:a}),Rr(),ct.length>0&&(Mr("down",e),Hr(),e.preventDefault(),oo(r)||e.stopImmediatePropagation())}function ln(e){const{x:r,y:n}=Gr(e);if(Yt&&e.type!=="pointerleave"&&e.buttons===0&&(Yt=!1,Mr("up",e)),!Yt){const{target:a}=e;Yn({target:a,x:r,y:n})}Mr("move",e),Hr(),ct.length>0&&e.preventDefault()}function dn(e){const{target:r}=e,{x:n,y:a}=Gr(e);Fr.clear(),Yt=!1,ct.length>0&&(e.preventDefault(),oo(r)||e.stopImmediatePropagation()),Mr("up",e),Yn({target:r,x:n,y:a}),Hr(),Rr()}function oo(e){let r=e;for(;r;){if(r.hasAttribute(Fe.resizeHandle))return!0;r=r.parentElement}return!1}function Yn({target:e,x:r,y:n}){ct.splice(0);let a=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(a=e),cr.forEach(s=>{const{element:o,hitAreaMargins:l}=s,i=o.getBoundingClientRect(),{bottom:d,left:h,right:u,top:m}=i,f=kc?l.coarse:l.fine;if(r>=h-f&&r<=u+f&&n>=m-f&&n<=d+f){if(a!==null&&document.contains(a)&&o!==a&&!o.contains(a)&&!a.contains(o)&&gc(a,o)>0){let g=a,b=!1;for(;g&&!g.contains(o);){if(fc(g.getBoundingClientRect(),i)){b=!0;break}g=g.parentElement}if(b)return}ct.push(s)}})}function cn(e,r){Fr.set(e,r)}function Hr(){let e=!1,r=!1;ct.forEach(a=>{const{direction:s}=a;s==="horizontal"?e=!0:r=!0});let n=0;Fr.forEach(a=>{n|=a}),e&&r?on("intersection",n):e?on("horizontal",n):r?on("vertical",n):mc()}let hn;function Rr(){var e;(e=hn)===null||e===void 0||e.abort(),hn=new AbortController;const r={capture:!0,signal:hn.signal};cr.size&&(Yt?(ct.length>0&&yt.forEach((n,a)=>{const{body:s}=a;n>0&&(s.addEventListener("contextmenu",dn,r),s.addEventListener("pointerleave",ln,r),s.addEventListener("pointermove",ln,r))}),yt.forEach((n,a)=>{const{body:s}=a;s.addEventListener("pointerup",dn,r),s.addEventListener("pointercancel",dn,r)})):yt.forEach((n,a)=>{const{body:s}=a;n>0&&(s.addEventListener("pointerdown",yc,r),s.addEventListener("pointermove",ln,r))}))}function Mr(e,r){cr.forEach(n=>{const{setResizeHandlerState:a}=n,s=ct.includes(n);a(e,s,r)})}function jc(){const[e,r]=c.useState(0);return c.useCallback(()=>r(n=>n+1),[])}function Ne(e,r){if(!e)throw console.error(r),Error(r)}function At(e,r,n=qn){return e.toFixed(n)===r.toFixed(n)?0:e>r?1:-1}function gt(e,r,n=qn){return At(e,r,n)===0}function ot(e,r,n){return At(e,r,n)===0}function Nc(e,r,n){if(e.length!==r.length)return!1;for(let a=0;a<e.length;a++){const s=e[a],o=r[a];if(!ot(s,o,n))return!1}return!0}function qt({panelConstraints:e,panelIndex:r,size:n}){const a=e[r];Ne(a!=null,`Panel constraints not found for index ${r}`);let{collapsedSize:s=0,collapsible:o,maxSize:l=100,minSize:i=0}=a;if(At(n,i)<0)if(o){const d=(s+i)/2;At(n,d)<0?n=s:n=i}else n=i;return n=Math.min(l,n),n=parseFloat(n.toFixed(qn)),n}function or({delta:e,initialLayout:r,panelConstraints:n,pivotIndices:a,prevLayout:s,trigger:o}){if(ot(e,0))return r;const l=[...r],[i,d]=a;Ne(i!=null,"Invalid first pivot index"),Ne(d!=null,"Invalid second pivot index");let h=0;if(o==="keyboard"){{const m=e<0?d:i,f=n[m];Ne(f,`Panel constraints not found for index ${m}`);const{collapsedSize:p=0,collapsible:g,minSize:b=0}=f;if(g){const v=r[m];if(Ne(v!=null,`Previous layout not found for panel index ${m}`),ot(v,p)){const x=b-v;At(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}{const m=e<0?i:d,f=n[m];Ne(f,`No panel constraints found for index ${m}`);const{collapsedSize:p=0,collapsible:g,minSize:b=0}=f;if(g){const v=r[m];if(Ne(v!=null,`Previous layout not found for panel index ${m}`),ot(v,b)){const x=v-p;At(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}}{const m=e<0?1:-1;let f=e<0?d:i,p=0;for(;;){const b=r[f];Ne(b!=null,`Previous layout not found for panel index ${f}`);const x=qt({panelConstraints:n,panelIndex:f,size:100})-b;if(p+=x,f+=m,f<0||f>=n.length)break}const g=Math.min(Math.abs(e),Math.abs(p));e=e<0?0-g:g}{let f=e<0?i:d;for(;f>=0&&f<n.length;){const p=Math.abs(e)-Math.abs(h),g=r[f];Ne(g!=null,`Previous layout not found for panel index ${f}`);const b=g-p,v=qt({panelConstraints:n,panelIndex:f,size:b});if(!ot(g,v)&&(h+=g-v,l[f]=v,h.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?f--:f++}}if(Nc(s,l))return s;{const m=e<0?d:i,f=r[m];Ne(f!=null,`Previous layout not found for panel index ${m}`);const p=f+h,g=qt({panelConstraints:n,panelIndex:m,size:p});if(l[m]=g,!ot(g,p)){let b=p-g,x=e<0?d:i;for(;x>=0&&x<n.length;){const y=l[x];Ne(y!=null,`Previous layout not found for panel index ${x}`);const k=y+b,j=qt({panelConstraints:n,panelIndex:x,size:k});if(ot(y,j)||(b-=j-y,l[x]=j),ot(b,0))break;e>0?x--:x++}}}const u=l.reduce((m,f)=>f+m,0);return ot(u,100)?l:s}function Cc({layout:e,panelsArray:r,pivotIndices:n}){let a=0,s=100,o=0,l=0;const i=n[0];Ne(i!=null,"No pivot index found"),r.forEach((m,f)=>{const{constraints:p}=m,{maxSize:g=100,minSize:b=0}=p;f===i?(a=b,s=g):(o+=b,l+=g)});const d=Math.min(s,100-o),h=Math.max(a,100-l),u=e[i];return{valueMax:d,valueMin:h,valueNow:u}}function hr(e,r=document){return Array.from(r.querySelectorAll(`[${Fe.resizeHandleId}][data-panel-group-id="${e}"]`))}function lo(e,r,n=document){const s=hr(e,n).findIndex(o=>o.getAttribute(Fe.resizeHandleId)===r);return s??null}function io(e,r,n){const a=lo(e,r,n);return a!=null?[a,a+1]:[-1,-1]}function Sc(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function co(e,r=document){if(Sc(r)&&r.dataset.panelGroupId==e)return r;const n=r.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function Or(e,r=document){const n=r.querySelector(`[${Fe.resizeHandleId}="${e}"]`);return n||null}function Tc(e,r,n,a=document){var s,o,l,i;const d=Or(r,a),h=hr(e,a),u=d?h.indexOf(d):-1,m=(s=(o=n[u])===null||o===void 0?void 0:o.id)!==null&&s!==void 0?s:null,f=(l=(i=n[u+1])===null||i===void 0?void 0:i.id)!==null&&l!==void 0?l:null;return[m,f]}function Ec({committedValuesRef:e,eagerValuesRef:r,groupId:n,layout:a,panelDataArray:s,panelGroupElement:o,setLayout:l}){c.useRef({didWarnAboutMissingResizeHandle:!1}),Rt(()=>{if(!o)return;const i=hr(n,o);for(let d=0;d<s.length-1;d++){const{valueMax:h,valueMin:u,valueNow:m}=Cc({layout:a,panelsArray:s,pivotIndices:[d,d+1]}),f=i[d];if(f!=null){const p=s[d];Ne(p,`No panel data found for index "${d}"`),f.setAttribute("aria-controls",p.id),f.setAttribute("aria-valuemax",""+Math.round(h)),f.setAttribute("aria-valuemin",""+Math.round(u)),f.setAttribute("aria-valuenow",m!=null?""+Math.round(m):"")}}return()=>{i.forEach((d,h)=>{d.removeAttribute("aria-controls"),d.removeAttribute("aria-valuemax"),d.removeAttribute("aria-valuemin"),d.removeAttribute("aria-valuenow")})}},[n,a,s,o]),c.useEffect(()=>{if(!o)return;const i=r.current;Ne(i,"Eager values not found");const{panelDataArray:d}=i,h=co(n,o);Ne(h!=null,`No group found for id "${n}"`);const u=hr(n,o);Ne(u,`No resize handles found for group id "${n}"`);const m=u.map(f=>{const p=f.getAttribute(Fe.resizeHandleId);Ne(p,"Resize handle element has no handle id attribute");const[g,b]=Tc(n,p,d,o);if(g==null||b==null)return()=>{};const v=x=>{if(!x.defaultPrevented)switch(x.key){case"Enter":{x.preventDefault();const y=d.findIndex(k=>k.id===g);if(y>=0){const k=d[y];Ne(k,`No panel data found for index ${y}`);const j=a[y],{collapsedSize:w=0,collapsible:N,minSize:S=0}=k.constraints;if(j!=null&&N){const L=or({delta:ot(j,w)?S-w:w-j,initialLayout:a,panelConstraints:d.map(T=>T.constraints),pivotIndices:io(n,p,o),prevLayout:a,trigger:"keyboard"});a!==L&&l(L)}}break}}};return f.addEventListener("keydown",v),()=>{f.removeEventListener("keydown",v)}});return()=>{m.forEach(f=>f())}},[o,e,r,n,a,s,l])}function Ia(e,r){if(e.length!==r.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==r[n])return!1;return!0}function ho(e,r){const n=e==="horizontal",{x:a,y:s}=Gr(r);return n?a:s}function Lc(e,r,n,a,s){const o=n==="horizontal",l=Or(r,s);Ne(l,`No resize handle element found for id "${r}"`);const i=l.getAttribute(Fe.groupId);Ne(i,"Resize handle element has no group id attribute");let{initialCursorPosition:d}=a;const h=ho(n,e),u=co(i,s);Ne(u,`No group element found for id "${i}"`);const m=u.getBoundingClientRect(),f=o?m.width:m.height;return(h-d)/f*100}function Pc(e,r,n,a,s,o){if(Js(e)){const l=n==="horizontal";let i=0;e.shiftKey?i=100:s!=null?i=s:i=10;let d=0;switch(e.key){case"ArrowDown":d=l?0:i;break;case"ArrowLeft":d=l?-i:0;break;case"ArrowRight":d=l?i:0;break;case"ArrowUp":d=l?0:-i;break;case"End":d=100;break;case"Home":d=-100;break}return d}else return a==null?0:Lc(e,r,n,a,o)}function zc({panelDataArray:e}){const r=Array(e.length),n=e.map(o=>o.constraints);let a=0,s=100;for(let o=0;o<e.length;o++){const l=n[o];Ne(l,`Panel constraints not found for index ${o}`);const{defaultSize:i}=l;i!=null&&(a++,r[o]=i,s-=i)}for(let o=0;o<e.length;o++){const l=n[o];Ne(l,`Panel constraints not found for index ${o}`);const{defaultSize:i}=l;if(i!=null)continue;const d=e.length-a,h=s/d;a++,r[o]=h,s-=h}return r}function Ot(e,r,n){r.forEach((a,s)=>{const o=e[s];Ne(o,`Panel data not found for index ${s}`);const{callbacks:l,constraints:i,id:d}=o,{collapsedSize:h=0,collapsible:u}=i,m=n[d];if(m==null||a!==m){n[d]=a;const{onCollapse:f,onExpand:p,onResize:g}=l;g&&g(a,m),u&&(f||p)&&(p&&(m==null||gt(m,h))&&!gt(a,h)&&p(),f&&(m==null||!gt(m,h))&>(a,h)&&f())}})}function yr(e,r){if(e.length!==r.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=r[n])return!1;return!0}function Ic({defaultSize:e,dragState:r,layout:n,panelData:a,panelIndex:s,precision:o=3}){const l=n[s];let i;return l==null?i=e!=null?e.toFixed(o):"1":a.length===1?i="1":i=l.toFixed(o),{flexBasis:0,flexGrow:i,flexShrink:1,overflow:"hidden",pointerEvents:r!==null?"none":void 0}}function Rc(e,r=10){let n=null;return(...s)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...s)},r)}}function Ra(e){try{if(typeof localStorage<"u")e.getItem=r=>localStorage.getItem(r),e.setItem=(r,n)=>{localStorage.setItem(r,n)};else throw new Error("localStorage not supported in this environment")}catch(r){console.error(r),e.getItem=()=>null,e.setItem=()=>{}}}function uo(e){return`react-resizable-panels:${e}`}function mo(e){return e.map(r=>{const{constraints:n,id:a,idIsFromProps:s,order:o}=r;return s?a:o?`${o}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((r,n)=>r.localeCompare(n)).join(",")}function po(e,r){try{const n=uo(e),a=r.getItem(n);if(a){const s=JSON.parse(a);if(typeof s=="object"&&s!=null)return s}}catch{}return null}function Mc(e,r,n){var a,s;const o=(a=po(e,n))!==null&&a!==void 0?a:{},l=mo(r);return(s=o[l])!==null&&s!==void 0?s:null}function _c(e,r,n,a,s){var o;const l=uo(e),i=mo(r),d=(o=po(e,s))!==null&&o!==void 0?o:{};d[i]={expandToSizes:Object.fromEntries(n.entries()),layout:a};try{s.setItem(l,JSON.stringify(d))}catch(h){console.error(h)}}function Ma({layout:e,panelConstraints:r}){const n=[...e],a=n.reduce((o,l)=>o+l,0);if(n.length!==r.length)throw Error(`Invalid ${r.length} panel layout: ${n.map(o=>`${o}%`).join(", ")}`);if(!ot(a,100)&&n.length>0)for(let o=0;o<r.length;o++){const l=n[o];Ne(l!=null,`No layout data found for index ${o}`);const i=100/a*l;n[o]=i}let s=0;for(let o=0;o<r.length;o++){const l=n[o];Ne(l!=null,`No layout data found for index ${o}`);const i=qt({panelConstraints:r,panelIndex:o,size:l});l!=i&&(s+=l-i,n[o]=i)}if(!ot(s,0))for(let o=0;o<r.length;o++){const l=n[o];Ne(l!=null,`No layout data found for index ${o}`);const i=l+s,d=qt({panelConstraints:r,panelIndex:o,size:i});if(l!==d&&(s-=d-l,n[o]=d,ot(s,0)))break}return n}const Ac=100,lr={getItem:e=>(Ra(lr),lr.getItem(e)),setItem:(e,r)=>{Ra(lr),lr.setItem(e,r)}},_a={};function fo({autoSaveId:e=null,children:r,className:n="",direction:a,forwardedRef:s,id:o=null,onLayout:l=null,keyboardResizeBy:i=null,storage:d=lr,style:h,tagName:u="div",...m}){const f=Xn(o),p=c.useRef(null),[g,b]=c.useState(null),[v,x]=c.useState([]),y=jc(),k=c.useRef({}),j=c.useRef(new Map),w=c.useRef(0),N=c.useRef({autoSaveId:e,direction:a,dragState:g,id:f,keyboardResizeBy:i,onLayout:l,storage:d}),S=c.useRef({layout:v,panelDataArray:[],panelDataArrayChanged:!1});c.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),c.useImperativeHandle(s,()=>({getId:()=>N.current.id,getLayout:()=>{const{layout:z}=S.current;return z},setLayout:z=>{const{onLayout:X}=N.current,{layout:F,panelDataArray:I}=S.current,P=Ma({layout:z,panelConstraints:I.map(Z=>Z.constraints)});Ia(F,P)||(x(P),S.current.layout=P,X&&X(P),Ot(I,P,k.current))}}),[]),Rt(()=>{N.current.autoSaveId=e,N.current.direction=a,N.current.dragState=g,N.current.id=f,N.current.onLayout=l,N.current.storage=d}),Ec({committedValuesRef:N,eagerValuesRef:S,groupId:f,layout:v,panelDataArray:S.current.panelDataArray,setLayout:x,panelGroupElement:p.current}),c.useEffect(()=>{const{panelDataArray:z}=S.current;if(e){if(v.length===0||v.length!==z.length)return;let X=_a[e];X==null&&(X=Rc(_c,Ac),_a[e]=X);const F=[...z],I=new Map(j.current);X(e,F,I,v,d)}},[e,v,d]),c.useEffect(()=>{});const L=c.useCallback(z=>{const{onLayout:X}=N.current,{layout:F,panelDataArray:I}=S.current;if(z.constraints.collapsible){const P=I.map(M=>M.constraints),{collapsedSize:Z=0,panelSize:K,pivotIndices:de}=Et(I,z,F);if(Ne(K!=null,`Panel size not found for panel "${z.id}"`),!gt(K,Z)){j.current.set(z.id,K);const Y=Wt(I,z)===I.length-1?K-Z:Z-K,te=or({delta:Y,initialLayout:F,panelConstraints:P,pivotIndices:de,prevLayout:F,trigger:"imperative-api"});yr(F,te)||(x(te),S.current.layout=te,X&&X(te),Ot(I,te,k.current))}}},[]),T=c.useCallback((z,X)=>{const{onLayout:F}=N.current,{layout:I,panelDataArray:P}=S.current;if(z.constraints.collapsible){const Z=P.map(ie=>ie.constraints),{collapsedSize:K=0,panelSize:de=0,minSize:M=0,pivotIndices:Y}=Et(P,z,I),te=X??M;if(gt(de,K)){const ie=j.current.get(z.id),ue=ie!=null&&ie>=te?ie:te,Le=Wt(P,z)===P.length-1?de-ue:ue-de,ae=or({delta:Le,initialLayout:I,panelConstraints:Z,pivotIndices:Y,prevLayout:I,trigger:"imperative-api"});yr(I,ae)||(x(ae),S.current.layout=ae,F&&F(ae),Ot(P,ae,k.current))}}},[]),q=c.useCallback(z=>{const{layout:X,panelDataArray:F}=S.current,{panelSize:I}=Et(F,z,X);return Ne(I!=null,`Panel size not found for panel "${z.id}"`),I},[]),A=c.useCallback((z,X)=>{const{panelDataArray:F}=S.current,I=Wt(F,z);return Ic({defaultSize:X,dragState:g,layout:v,panelData:F,panelIndex:I})},[g,v]),D=c.useCallback(z=>{const{layout:X,panelDataArray:F}=S.current,{collapsedSize:I=0,collapsible:P,panelSize:Z}=Et(F,z,X);return Ne(Z!=null,`Panel size not found for panel "${z.id}"`),P===!0&>(Z,I)},[]),J=c.useCallback(z=>{const{layout:X,panelDataArray:F}=S.current,{collapsedSize:I=0,collapsible:P,panelSize:Z}=Et(F,z,X);return Ne(Z!=null,`Panel size not found for panel "${z.id}"`),!P||At(Z,I)>0},[]),W=c.useCallback(z=>{const{panelDataArray:X}=S.current;X.push(z),X.sort((F,I)=>{const P=F.order,Z=I.order;return P==null&&Z==null?0:P==null?-1:Z==null?1:P-Z}),S.current.panelDataArrayChanged=!0,y()},[y]);Rt(()=>{if(S.current.panelDataArrayChanged){S.current.panelDataArrayChanged=!1;const{autoSaveId:z,onLayout:X,storage:F}=N.current,{layout:I,panelDataArray:P}=S.current;let Z=null;if(z){const de=Mc(z,P,F);de&&(j.current=new Map(Object.entries(de.expandToSizes)),Z=de.layout)}Z==null&&(Z=zc({panelDataArray:P}));const K=Ma({layout:Z,panelConstraints:P.map(de=>de.constraints)});Ia(I,K)||(x(K),S.current.layout=K,X&&X(K),Ot(P,K,k.current))}}),Rt(()=>{const z=S.current;return()=>{z.layout=[]}},[]);const O=c.useCallback(z=>{let X=!1;const F=p.current;return F&&window.getComputedStyle(F,null).getPropertyValue("direction")==="rtl"&&(X=!0),function(P){P.preventDefault();const Z=p.current;if(!Z)return()=>null;const{direction:K,dragState:de,id:M,keyboardResizeBy:Y,onLayout:te}=N.current,{layout:ie,panelDataArray:ue}=S.current,{initialLayout:be}=de??{},Le=io(M,z,Z);let ae=Pc(P,z,K,de,Y,Z);const ve=K==="horizontal";ve&&X&&(ae=-ae);const ke=ue.map(je=>je.constraints),pe=or({delta:ae,initialLayout:be??ie,panelConstraints:ke,pivotIndices:Le,prevLayout:ie,trigger:Js(P)?"keyboard":"mouse-or-touch"}),ze=!yr(ie,pe);(Qs(P)||eo(P))&&w.current!=ae&&(w.current=ae,!ze&&ae!==0?ve?cn(z,ae<0?ro:no):cn(z,ae<0?ao:so):cn(z,0)),ze&&(x(pe),S.current.layout=pe,te&&te(pe),Ot(ue,pe,k.current))}},[]),ee=c.useCallback((z,X)=>{const{onLayout:F}=N.current,{layout:I,panelDataArray:P}=S.current,Z=P.map(ie=>ie.constraints),{panelSize:K,pivotIndices:de}=Et(P,z,I);Ne(K!=null,`Panel size not found for panel "${z.id}"`);const Y=Wt(P,z)===P.length-1?K-X:X-K,te=or({delta:Y,initialLayout:I,panelConstraints:Z,pivotIndices:de,prevLayout:I,trigger:"imperative-api"});yr(I,te)||(x(te),S.current.layout=te,F&&F(te),Ot(P,te,k.current))},[]),he=c.useCallback((z,X)=>{const{layout:F,panelDataArray:I}=S.current,{collapsedSize:P=0,collapsible:Z}=X,{collapsedSize:K=0,collapsible:de,maxSize:M=100,minSize:Y=0}=z.constraints,{panelSize:te}=Et(I,z,F);te!=null&&(Z&&de&>(te,P)?gt(P,K)||ee(z,K):te<Y?ee(z,Y):te>M&&ee(z,M))},[ee]),E=c.useCallback((z,X)=>{const{direction:F}=N.current,{layout:I}=S.current;if(!p.current)return;const P=Or(z,p.current);Ne(P,`Drag handle element not found for id "${z}"`);const Z=ho(F,X);b({dragHandleId:z,dragHandleRect:P.getBoundingClientRect(),initialCursorPosition:Z,initialLayout:I})},[]),re=c.useCallback(()=>{b(null)},[]),_=c.useCallback(z=>{const{panelDataArray:X}=S.current,F=Wt(X,z);F>=0&&(X.splice(F,1),delete k.current[z.id],S.current.panelDataArrayChanged=!0,y())},[y]),V=c.useMemo(()=>({collapsePanel:L,direction:a,dragState:g,expandPanel:T,getPanelSize:q,getPanelStyle:A,groupId:f,isPanelCollapsed:D,isPanelExpanded:J,reevaluatePanelConstraints:he,registerPanel:W,registerResizeHandle:O,resizePanel:ee,startDragging:E,stopDragging:re,unregisterPanel:_,panelGroupElement:p.current}),[L,g,a,T,q,A,f,D,J,he,W,O,ee,E,re,_]),U={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return c.createElement(Br.Provider,{value:V},c.createElement(u,{...m,children:r,className:n,id:o,ref:p,style:{...U,...h},[Fe.group]:"",[Fe.groupDirection]:a,[Fe.groupId]:f}))}const go=c.forwardRef((e,r)=>c.createElement(fo,{...e,forwardedRef:r}));fo.displayName="PanelGroup";go.displayName="forwardRef(PanelGroup)";function Wt(e,r){return e.findIndex(n=>n===r||n.id===r.id)}function Et(e,r,n){const a=Wt(e,r),o=a===e.length-1?[a-1,a]:[a,a+1],l=n[a];return{...r.constraints,panelSize:l,pivotIndices:o}}function $c({disabled:e,handleId:r,resizeHandler:n,panelGroupElement:a}){c.useEffect(()=>{if(e||n==null||a==null)return;const s=Or(r,a);if(s==null)return;const o=l=>{if(!l.defaultPrevented)switch(l.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{l.preventDefault(),n(l);break}case"F6":{l.preventDefault();const i=s.getAttribute(Fe.groupId);Ne(i,`No group element found for id "${i}"`);const d=hr(i,a),h=lo(i,r,a);Ne(h!==null,`No resize element found for id "${r}"`);const u=l.shiftKey?h>0?h-1:d.length-1:h+1<d.length?h+1:0;d[u].focus();break}}};return s.addEventListener("keydown",o),()=>{s.removeEventListener("keydown",o)}},[a,e,r,n])}function xo({children:e=null,className:r="",disabled:n=!1,hitAreaMargins:a,id:s,onBlur:o,onClick:l,onDragging:i,onFocus:d,onPointerDown:h,onPointerUp:u,style:m={},tabIndex:f=0,tagName:p="div",...g}){var b,v;const x=c.useRef(null),y=c.useRef({onClick:l,onDragging:i,onPointerDown:h,onPointerUp:u});c.useEffect(()=>{y.current.onClick=l,y.current.onDragging=i,y.current.onPointerDown=h,y.current.onPointerUp=u});const k=c.useContext(Br);if(k===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:j,groupId:w,registerResizeHandle:N,startDragging:S,stopDragging:L,panelGroupElement:T}=k,q=Xn(s),[A,D]=c.useState("inactive"),[J,W]=c.useState(!1),[O,ee]=c.useState(null),he=c.useRef({state:A});Rt(()=>{he.current.state=A}),c.useEffect(()=>{if(n)ee(null);else{const V=N(q);ee(()=>V)}},[n,q,N]);const E=(b=a==null?void 0:a.coarse)!==null&&b!==void 0?b:15,re=(v=a==null?void 0:a.fine)!==null&&v!==void 0?v:5;c.useEffect(()=>{if(n||O==null)return;const V=x.current;Ne(V,"Element ref not attached");let U=!1;return wc(q,V,j,{coarse:E,fine:re},(X,F,I)=>{if(!F){D("inactive");return}switch(X){case"down":{D("drag"),U=!1,Ne(I,'Expected event to be defined for "down" action'),S(q,I);const{onDragging:P,onPointerDown:Z}=y.current;P==null||P(!0),Z==null||Z();break}case"move":{const{state:P}=he.current;U=!0,P!=="drag"&&D("hover"),Ne(I,'Expected event to be defined for "move" action'),O(I);break}case"up":{D("hover"),L();const{onClick:P,onDragging:Z,onPointerUp:K}=y.current;Z==null||Z(!1),K==null||K(),U||P==null||P();break}}})},[E,j,n,re,N,q,O,S,L]),$c({disabled:n,handleId:q,resizeHandler:O,panelGroupElement:T});const _={touchAction:"none",userSelect:"none"};return c.createElement(p,{...g,children:e,className:r,id:s,onBlur:()=>{W(!1),o==null||o()},onFocus:()=>{W(!0),d==null||d()},ref:x,role:"separator",style:{..._,...m},tabIndex:f,[Fe.groupDirection]:j,[Fe.groupId]:w,[Fe.resizeHandle]:"",[Fe.resizeHandleActive]:A==="drag"?"pointer":J?"keyboard":void 0,[Fe.resizeHandleEnabled]:!n,[Fe.resizeHandleId]:q,[Fe.resizeHandleState]:A})}xo.displayName="PanelResizeHandle";var Dc=Object.defineProperty,Bc=Object.getOwnPropertyNames,$e=(e,r)=>function(){return e&&(r=(0,e[Bc(e)[0]])(e=0)),r},Gc=(e,r)=>{for(var n in r)Dc(e,n,{get:r[n],enumerable:!0})};function et(...e){return dc(_s(e))}var Nt=$e({"src/components/graph-ui/utils.ts"(){}});function ur({asChild:e=!1,className:r,size:n,variant:a,...s}){const o=e?zs:"button";return t.jsx(o,{"data-slot":"button",className:et(bo({variant:a,size:n,className:r})),...s})}var bo,Ur=$e({"src/components/graph-ui/Button.tsx"(){Nt(),bo=mr("inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium outline-none transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}})}});function vo(...e){return e.filter(Boolean).join(" ")}function Tn({className:e,...r}){return t.jsx(go,{"data-slot":"resizable-panel-group",className:vo("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...r})}function Xt({...e}){return t.jsx(Zs,{"data-slot":"resizable-panel",...e})}function En({withHandle:e,className:r,...n}){return t.jsx(xo,{"data-slot":"resizable-handle",className:vo("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",r),...n,children:e?t.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:t.jsx(G.GripVerticalIcon,{className:"size-2.5"})}):null})}var ko=$e({"src/components/graph-workspace/GraphResizablePanels.tsx"(){}});function Zn(...e){return e.filter(Boolean).join(" ")}function pr({...e}){return t.jsx(_i,{"data-slot":"accordion",...e})}function fr({className:e,...r}){return t.jsx(Ai,{"data-slot":"accordion-item",className:Zn("border-b last:border-b-0",e),...r})}function gr({className:e,children:r,...n}){return t.jsx($i,{className:"flex",children:t.jsxs(Di,{"data-slot":"accordion-trigger",className:Zn("flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium outline-none transition-all hover:underline disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",e),...n,children:[r,t.jsx(G.ChevronDownIcon,{className:"pointer-events-none size-4 shrink-0 translate-y-0.5 text-[var(--theme-fg-muted)] transition-transform duration-200"})]})})}function xr({className:e,children:r,...n}){return t.jsx(Bi,{"data-slot":"accordion-content",className:"overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:t.jsx("div",{className:Zn("pb-4 pt-0",e),children:r})})}var br=$e({"src/components/graph-workspace/GraphAccordion.tsx"(){}});function Fc(e){var n;const r=[];for(const a of e.turns)for(const s of a.items)s.kind==="artifact"&&s.artifact&&r.push(s.artifact);for(const a of((n=e.liveItems)==null?void 0:n.items)??[])a.kind==="artifact"&&a.artifact&&r.push(a.artifact);return r}function Hc(e){return e.trim().replace(/^\/+|\/+$/g,"").replace(/[^\w.-]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function vr(e){var r;return((r=e.split(".").pop())==null?void 0:r.toLowerCase())||""}function Oc(e){return e.split("/").filter(Boolean).at(-1)??e}function Vt(e){const r=e.kind==="directory"?"directory":"file",n=(e.children??[]).map(Vt);return{id:`workspace:${e.path}`,name:e.name,path:e.path,kind:r,...e.size!==void 0?{size:e.size}:{},...e.hasChildren!==void 0?{hasChildren:e.hasChildren}:r==="directory"?{hasChildren:n.length>0}:{},...e.childrenLoaded!==void 0?{childrenLoaded:e.childrenLoaded}:r==="directory"?{childrenLoaded:e.children!==void 0}:{},...e.truncated!==void 0?{truncated:e.truncated}:{},workspaceNode:e,children:n}}function wo(e,r,n,a={}){if(e.path===r)return{...e,children:n,hasChildren:n.length>0,childrenLoaded:!0,truncated:a.truncated??e.truncated};if(e.children.length===0)return e;let s=!1;const o=e.children.map(l=>{const i=wo(l,r,n,a);return i!==l&&(s=!0),i});return s?{...e,children:o}:e}function yo(e){if(e.kind==="file")return e;for(const r of e.children){const n=yo(r);if(n)return n}return null}function Ln(e,r){if(!e||r===null)return null;if(e.path===r)return e;for(const n of e.children){const a=Ln(n,r);if(a)return a}return null}function jo(e){return e.trim().replace(/\\/g,"/").replace(/^\.\/+/,"").replace(/^\/+/,"")}function Uc(e){const n=jo(e).split("/").filter(Boolean);n.pop();const a=[];let s="";for(const o of n)s=s?`${s}/${o}`:o,a.push(s);return a}function Pn(e,r,n){if(e.path===r)return n;if(e.children.length===0)return e;let a=!1;const s=e.children.map(o=>{const l=Pn(o,r,n);return l!==o&&(a=!0),l});return a?{...e,children:s}:e}function zn(e,r){return!e||!r?!1:e.path===r?!0:e.children.some(n=>zn(n,r))}function Wc(e){if(!e)return null;const r=vr(e.path);return Jn.has(r)?{content:[e.content.endsWith(`
|
|
2
|
+
import{l as G,R as _i,I as Ai,C as Mi,S as Ps,H as $i,T as Di,a as Bi,b as Gi,c as Fi,d as Hi,e as Oi,D as Ui,P as Wi,O as Vi,f as Ki,g as qi,h as Xi,i as Yi,j as Zi,k as Ji,m as Qi,n as ed,A as td,o as rd,p as nd}from"./ui-vendor-CeKGesq3.js";import{r as c,R as ad,j as t,b as $r}from"./react-vendor-CgLzZcV4.js";import{u as sd,a as od,H as ga,P as Pt,b as ld,M as Is,R as id,i as dd,C as cd,B as hd,c as xa,g as zs}from"./graph-vendor-DVPtkh3h.js";import"./terminal-vendor-B365Go3Z.js";import{M as ud,r as md,a as pd,b as fd}from"./markdown-vendor-BQJfKm05.js";const gd="modulepreload",xd=function(e){return"/"+e},ba={},Ue=function(r,n,a){let s=Promise.resolve();if(n&&n.length>0){let l=function(h){return Promise.all(h.map(u=>Promise.resolve(u).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),d=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));s=l(n.map(h=>{if(h=xd(h),h in ba)return;ba[h]=!0;const u=h.endsWith(".css"),m=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${m}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":gd,u||(f.as="script"),f.crossOrigin="",f.href=h,d&&f.setAttribute("nonce",d),document.head.appendChild(f),u)return new Promise((p,g)=>{f.addEventListener("load",p),f.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${h}`)))})}))}function o(l){const i=new Event("vite:preloadError",{cancelable:!0});if(i.payload=l,window.dispatchEvent(i),!i.defaultPrevented)throw l}return s.then(l=>{for(const i of l||[])i.status==="rejected"&&o(i.reason);return r().catch(o)})};function Rs(e){var r,n,a="";if(typeof e=="string"||typeof e=="number")a+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(r=0;r<s;r++)e[r]&&(n=Rs(e[r]))&&(a&&(a+=" "),a+=n)}else for(n in e)e[n]&&(a&&(a+=" "),a+=n);return a}function _s(){for(var e,r,n=0,a="",s=arguments.length;n<s;n++)(e=arguments[n])&&(r=Rs(e))&&(a&&(a+=" "),a+=r);return a}const bd=(e,r)=>{const n=new Array(e.length+r.length);for(let a=0;a<e.length;a++)n[a]=e[a];for(let a=0;a<r.length;a++)n[e.length+a]=r[a];return n},vd=(e,r)=>({classGroupId:e,validator:r}),As=(e=new Map,r=null,n)=>({nextPart:e,validators:r,classGroupId:n}),Ir="-",va=[],kd="arbitrary..",wd=e=>{const r=jd(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:a}=e;return{getClassGroupId:l=>{if(l.startsWith("[")&&l.endsWith("]"))return yd(l);const i=l.split(Ir),d=i[0]===""&&i.length>1?1:0;return Ms(i,d,r)},getConflictingClassGroupIds:(l,i)=>{if(i){const d=a[l],h=n[l];return d?h?bd(h,d):d:h||va}return n[l]||va}}},Ms=(e,r,n)=>{if(e.length-r===0)return n.classGroupId;const s=e[r],o=n.nextPart.get(s);if(o){const h=Ms(e,r+1,o);if(h)return h}const l=n.validators;if(l===null)return;const i=r===0?e.join(Ir):e.slice(r).join(Ir),d=l.length;for(let h=0;h<d;h++){const u=l[h];if(u.validator(i))return u.classGroupId}},yd=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const r=e.slice(1,-1),n=r.indexOf(":"),a=r.slice(0,n);return a?kd+a:void 0})(),jd=e=>{const{theme:r,classGroups:n}=e;return Nd(n,r)},Nd=(e,r)=>{const n=As();for(const a in e){const s=e[a];Wn(s,n,a,r)}return n},Wn=(e,r,n,a)=>{const s=e.length;for(let o=0;o<s;o++){const l=e[o];Cd(l,r,n,a)}},Cd=(e,r,n,a)=>{if(typeof e=="string"){Sd(e,r,n);return}if(typeof e=="function"){Td(e,r,n,a);return}Ed(e,r,n,a)},Sd=(e,r,n)=>{const a=e===""?r:$s(r,e);a.classGroupId=n},Td=(e,r,n,a)=>{if(Ld(e)){Wn(e(a),r,n,a);return}r.validators===null&&(r.validators=[]),r.validators.push(vd(n,e))},Ed=(e,r,n,a)=>{const s=Object.entries(e),o=s.length;for(let l=0;l<o;l++){const[i,d]=s[l];Wn(d,$s(r,i),n,a)}},$s=(e,r)=>{let n=e;const a=r.split(Ir),s=a.length;for(let o=0;o<s;o++){const l=a[o];let i=n.nextPart.get(l);i||(i=As(),n.nextPart.set(l,i)),n=i}return n},Ld=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Pd=e=>{if(e<1)return{get:()=>{},set:()=>{}};let r=0,n=Object.create(null),a=Object.create(null);const s=(o,l)=>{n[o]=l,r++,r>e&&(r=0,a=n,n=Object.create(null))};return{get(o){let l=n[o];if(l!==void 0)return l;if((l=a[o])!==void 0)return s(o,l),l},set(o,l){o in n?n[o]=l:s(o,l)}}},Nn="!",ka=":",Id=[],wa=(e,r,n,a,s)=>({modifiers:e,hasImportantModifier:r,baseClassName:n,maybePostfixModifierPosition:a,isExternal:s}),zd=e=>{const{prefix:r,experimentalParseClassName:n}=e;let a=s=>{const o=[];let l=0,i=0,d=0,h;const u=s.length;for(let b=0;b<u;b++){const v=s[b];if(l===0&&i===0){if(v===ka){o.push(s.slice(d,b)),d=b+1;continue}if(v==="/"){h=b;continue}}v==="["?l++:v==="]"?l--:v==="("?i++:v===")"&&i--}const m=o.length===0?s:s.slice(d);let f=m,p=!1;m.endsWith(Nn)?(f=m.slice(0,-1),p=!0):m.startsWith(Nn)&&(f=m.slice(1),p=!0);const g=h&&h>d?h-d:void 0;return wa(o,p,f,g)};if(r){const s=r+ka,o=a;a=l=>l.startsWith(s)?o(l.slice(s.length)):wa(Id,!1,l,void 0,!0)}if(n){const s=a;a=o=>n({className:o,parseClassName:s})}return a},Rd=e=>{const r=new Map;return e.orderSensitiveModifiers.forEach((n,a)=>{r.set(n,1e6+a)}),n=>{const a=[];let s=[];for(let o=0;o<n.length;o++){const l=n[o],i=l[0]==="[",d=r.has(l);i||d?(s.length>0&&(s.sort(),a.push(...s),s=[]),a.push(l)):s.push(l)}return s.length>0&&(s.sort(),a.push(...s)),a}},_d=e=>({cache:Pd(e.cacheSize),parseClassName:zd(e),sortModifiers:Rd(e),postfixLookupClassGroupIds:Ad(e),...wd(e)}),Ad=e=>{const r=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let a=0;a<n.length;a++)r[n[a]]=!0;return r},Md=/\s+/,$d=(e,r)=>{const{parseClassName:n,getClassGroupId:a,getConflictingClassGroupIds:s,sortModifiers:o,postfixLookupClassGroupIds:l}=r,i=[],d=e.trim().split(Md);let h="";for(let u=d.length-1;u>=0;u-=1){const m=d[u],{isExternal:f,modifiers:p,hasImportantModifier:g,baseClassName:b,maybePostfixModifierPosition:v}=n(m);if(f){h=m+(h.length>0?" "+h:h);continue}let x=!!v,y;if(x){const C=b.substring(0,v);y=a(C);const L=y&&l[y]?a(b):void 0;L&&L!==y&&(y=L,x=!1)}else y=a(b);if(!y){if(!x){h=m+(h.length>0?" "+h:h);continue}if(y=a(b),!y){h=m+(h.length>0?" "+h:h);continue}x=!1}const k=p.length===0?"":p.length===1?p[0]:o(p).join(":"),N=g?k+Nn:k,w=N+y;if(i.indexOf(w)>-1)continue;i.push(w);const j=s(y,x);for(let C=0;C<j.length;++C){const L=j[C];i.push(N+L)}h=m+(h.length>0?" "+h:h)}return h},Dd=(...e)=>{let r=0,n,a,s="";for(;r<e.length;)(n=e[r++])&&(a=Ds(n))&&(s&&(s+=" "),s+=a);return s},Ds=e=>{if(typeof e=="string")return e;let r,n="";for(let a=0;a<e.length;a++)e[a]&&(r=Ds(e[a]))&&(n&&(n+=" "),n+=r);return n},Bd=(e,...r)=>{let n,a,s,o;const l=d=>{const h=r.reduce((u,m)=>m(u),e());return n=_d(h),a=n.cache.get,s=n.cache.set,o=i,i(d)},i=d=>{const h=a(d);if(h)return h;const u=$d(d,n);return s(d,u),u};return o=l,(...d)=>o(Dd(...d))},Gd=[],Xe=e=>{const r=n=>n[e]||Gd;return r.isThemeGetter=!0,r},Bs=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Gs=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Fd=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Hd=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Od=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Ud=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Wd=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Vd=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,vt=e=>Fd.test(e),Se=e=>!!e&&!Number.isNaN(Number(e)),ut=e=>!!e&&Number.isInteger(Number(e)),sn=e=>e.endsWith("%")&&Se(e.slice(0,-1)),ft=e=>Hd.test(e),Fs=()=>!0,Kd=e=>Od.test(e)&&!Ud.test(e),Vn=()=>!1,qd=e=>Wd.test(e),Xd=e=>Vd.test(e),Yd=e=>!oe(e)&&!le(e),Zd=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),Jd=e=>jt(e,Us,Vn),oe=e=>Bs.test(e),Tt=e=>jt(e,Ws,Kd),ya=e=>jt(e,oc,Se),Qd=e=>jt(e,Ks,Fs),ec=e=>jt(e,Vs,Vn),ja=e=>jt(e,Hs,Vn),tc=e=>jt(e,Os,Xd),vr=e=>jt(e,qs,qd),le=e=>Gs.test(e),rr=e=>$t(e,Ws),rc=e=>$t(e,Vs),Na=e=>$t(e,Hs),nc=e=>$t(e,Us),ac=e=>$t(e,Os),kr=e=>$t(e,qs,!0),sc=e=>$t(e,Ks,!0),jt=(e,r,n)=>{const a=Bs.exec(e);return a?a[1]?r(a[1]):n(a[2]):!1},$t=(e,r,n=!1)=>{const a=Gs.exec(e);return a?a[1]?r(a[1]):n:!1},Hs=e=>e==="position"||e==="percentage",Os=e=>e==="image"||e==="url",Us=e=>e==="length"||e==="size"||e==="bg-size",Ws=e=>e==="length",oc=e=>e==="number",Vs=e=>e==="family-name",Ks=e=>e==="number"||e==="weight",qs=e=>e==="shadow",lc=()=>{const e=Xe("color"),r=Xe("font"),n=Xe("text"),a=Xe("font-weight"),s=Xe("tracking"),o=Xe("leading"),l=Xe("breakpoint"),i=Xe("container"),d=Xe("spacing"),h=Xe("radius"),u=Xe("shadow"),m=Xe("inset-shadow"),f=Xe("text-shadow"),p=Xe("drop-shadow"),g=Xe("blur"),b=Xe("perspective"),v=Xe("aspect"),x=Xe("ease"),y=Xe("animate"),k=()=>["auto","avoid","all","avoid-page","page","left","right","column"],N=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],w=()=>[...N(),le,oe],j=()=>["auto","hidden","clip","visible","scroll"],C=()=>["auto","contain","none"],L=()=>[le,oe,d],T=()=>[vt,"full","auto",...L()],q=()=>[ut,"none","subgrid",le,oe],M=()=>["auto",{span:["full",ut,le,oe]},ut,le,oe],D=()=>[ut,"auto",le,oe],J=()=>["auto","min","max","fr",le,oe],W=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],O=()=>["start","end","center","stretch","center-safe","end-safe"],ee=()=>["auto",...L()],he=()=>[vt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...L()],E=()=>[vt,"screen","full","dvw","lvw","svw","min","max","fit",...L()],re=()=>[vt,"screen","full","lh","dvh","lvh","svh","min","max","fit",...L()],A=()=>[e,le,oe],V=()=>[...N(),Na,ja,{position:[le,oe]}],U=()=>["no-repeat",{repeat:["","x","y","space","round"]}],I=()=>["auto","cover","contain",nc,Jd,{size:[le,oe]}],X=()=>[sn,rr,Tt],F=()=>["","none","full",h,le,oe],z=()=>["",Se,rr,Tt],P=()=>["solid","dashed","dotted","double"],Z=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],K=()=>[Se,sn,Na,ja],de=()=>["","none",g,le,oe],_=()=>["none",Se,le,oe],Y=()=>["none",Se,le,oe],te=()=>[Se,le,oe],ie=()=>[vt,"full",...L()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ft],breakpoint:[ft],color:[Fs],container:[ft],"drop-shadow":[ft],ease:["in","out","in-out"],font:[Yd],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ft],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ft],shadow:[ft],spacing:["px",Se],text:[ft],"text-shadow":[ft],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",vt,oe,le,v]}],container:["container"],"container-type":[{"@container":["","normal","size",le,oe]}],"container-named":[Zd],columns:[{columns:[Se,oe,le,i]}],"break-after":[{"break-after":k()}],"break-before":[{"break-before":k()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:w()}],overflow:[{overflow:j()}],"overflow-x":[{"overflow-x":j()}],"overflow-y":[{"overflow-y":j()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{"inset-s":T(),start:T()}],end:[{"inset-e":T(),end:T()}],"inset-bs":[{"inset-bs":T()}],"inset-be":[{"inset-be":T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:["visible","invisible","collapse"],z:[{z:[ut,"auto",le,oe]}],basis:[{basis:[vt,"full","auto",i,...L()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Se,vt,"auto","initial","none",oe]}],grow:[{grow:["",Se,le,oe]}],shrink:[{shrink:["",Se,le,oe]}],order:[{order:[ut,"first","last","none",le,oe]}],"grid-cols":[{"grid-cols":q()}],"col-start-end":[{col:M()}],"col-start":[{"col-start":D()}],"col-end":[{"col-end":D()}],"grid-rows":[{"grid-rows":q()}],"row-start-end":[{row:M()}],"row-start":[{"row-start":D()}],"row-end":[{"row-end":D()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":J()}],"auto-rows":[{"auto-rows":J()}],gap:[{gap:L()}],"gap-x":[{"gap-x":L()}],"gap-y":[{"gap-y":L()}],"justify-content":[{justify:[...W(),"normal"]}],"justify-items":[{"justify-items":[...O(),"normal"]}],"justify-self":[{"justify-self":["auto",...O()]}],"align-content":[{content:["normal",...W()]}],"align-items":[{items:[...O(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...O(),{baseline:["","last"]}]}],"place-content":[{"place-content":W()}],"place-items":[{"place-items":[...O(),"baseline"]}],"place-self":[{"place-self":["auto",...O()]}],p:[{p:L()}],px:[{px:L()}],py:[{py:L()}],ps:[{ps:L()}],pe:[{pe:L()}],pbs:[{pbs:L()}],pbe:[{pbe:L()}],pt:[{pt:L()}],pr:[{pr:L()}],pb:[{pb:L()}],pl:[{pl:L()}],m:[{m:ee()}],mx:[{mx:ee()}],my:[{my:ee()}],ms:[{ms:ee()}],me:[{me:ee()}],mbs:[{mbs:ee()}],mbe:[{mbe:ee()}],mt:[{mt:ee()}],mr:[{mr:ee()}],mb:[{mb:ee()}],ml:[{ml:ee()}],"space-x":[{"space-x":L()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":L()}],"space-y-reverse":["space-y-reverse"],size:[{size:he()}],"inline-size":[{inline:["auto",...E()]}],"min-inline-size":[{"min-inline":["auto",...E()]}],"max-inline-size":[{"max-inline":["none",...E()]}],"block-size":[{block:["auto",...re()]}],"min-block-size":[{"min-block":["auto",...re()]}],"max-block-size":[{"max-block":["none",...re()]}],w:[{w:[i,"screen",...he()]}],"min-w":[{"min-w":[i,"screen","none",...he()]}],"max-w":[{"max-w":[i,"screen","none","prose",{screen:[l]},...he()]}],h:[{h:["screen","lh",...he()]}],"min-h":[{"min-h":["screen","lh","none",...he()]}],"max-h":[{"max-h":["screen","lh",...he()]}],"font-size":[{text:["base",n,rr,Tt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,sc,Qd]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",sn,oe]}],"font-family":[{font:[rc,ec,r]}],"font-features":[{"font-features":[oe]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[s,le,oe]}],"line-clamp":[{"line-clamp":[Se,"none",le,ya]}],leading:[{leading:[o,...L()]}],"list-image":[{"list-image":["none",le,oe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",le,oe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:A()}],"text-color":[{text:A()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...P(),"wavy"]}],"text-decoration-thickness":[{decoration:[Se,"from-font","auto",le,Tt]}],"text-decoration-color":[{decoration:A()}],"underline-offset":[{"underline-offset":[Se,"auto",le,oe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:L()}],"tab-size":[{tab:[ut,le,oe]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",le,oe]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",le,oe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:V()}],"bg-repeat":[{bg:U()}],"bg-size":[{bg:I()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},ut,le,oe],radial:["",le,oe],conic:[ut,le,oe]},ac,tc]}],"bg-color":[{bg:A()}],"gradient-from-pos":[{from:X()}],"gradient-via-pos":[{via:X()}],"gradient-to-pos":[{to:X()}],"gradient-from":[{from:A()}],"gradient-via":[{via:A()}],"gradient-to":[{to:A()}],rounded:[{rounded:F()}],"rounded-s":[{"rounded-s":F()}],"rounded-e":[{"rounded-e":F()}],"rounded-t":[{"rounded-t":F()}],"rounded-r":[{"rounded-r":F()}],"rounded-b":[{"rounded-b":F()}],"rounded-l":[{"rounded-l":F()}],"rounded-ss":[{"rounded-ss":F()}],"rounded-se":[{"rounded-se":F()}],"rounded-ee":[{"rounded-ee":F()}],"rounded-es":[{"rounded-es":F()}],"rounded-tl":[{"rounded-tl":F()}],"rounded-tr":[{"rounded-tr":F()}],"rounded-br":[{"rounded-br":F()}],"rounded-bl":[{"rounded-bl":F()}],"border-w":[{border:z()}],"border-w-x":[{"border-x":z()}],"border-w-y":[{"border-y":z()}],"border-w-s":[{"border-s":z()}],"border-w-e":[{"border-e":z()}],"border-w-bs":[{"border-bs":z()}],"border-w-be":[{"border-be":z()}],"border-w-t":[{"border-t":z()}],"border-w-r":[{"border-r":z()}],"border-w-b":[{"border-b":z()}],"border-w-l":[{"border-l":z()}],"divide-x":[{"divide-x":z()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":z()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...P(),"hidden","none"]}],"divide-style":[{divide:[...P(),"hidden","none"]}],"border-color":[{border:A()}],"border-color-x":[{"border-x":A()}],"border-color-y":[{"border-y":A()}],"border-color-s":[{"border-s":A()}],"border-color-e":[{"border-e":A()}],"border-color-bs":[{"border-bs":A()}],"border-color-be":[{"border-be":A()}],"border-color-t":[{"border-t":A()}],"border-color-r":[{"border-r":A()}],"border-color-b":[{"border-b":A()}],"border-color-l":[{"border-l":A()}],"divide-color":[{divide:A()}],"outline-style":[{outline:[...P(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Se,le,oe]}],"outline-w":[{outline:["",Se,rr,Tt]}],"outline-color":[{outline:A()}],shadow:[{shadow:["","none",u,kr,vr]}],"shadow-color":[{shadow:A()}],"inset-shadow":[{"inset-shadow":["none",m,kr,vr]}],"inset-shadow-color":[{"inset-shadow":A()}],"ring-w":[{ring:z()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:A()}],"ring-offset-w":[{"ring-offset":[Se,Tt]}],"ring-offset-color":[{"ring-offset":A()}],"inset-ring-w":[{"inset-ring":z()}],"inset-ring-color":[{"inset-ring":A()}],"text-shadow":[{"text-shadow":["none",f,kr,vr]}],"text-shadow-color":[{"text-shadow":A()}],opacity:[{opacity:[Se,le,oe]}],"mix-blend":[{"mix-blend":[...Z(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Z()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Se]}],"mask-image-linear-from-pos":[{"mask-linear-from":K()}],"mask-image-linear-to-pos":[{"mask-linear-to":K()}],"mask-image-linear-from-color":[{"mask-linear-from":A()}],"mask-image-linear-to-color":[{"mask-linear-to":A()}],"mask-image-t-from-pos":[{"mask-t-from":K()}],"mask-image-t-to-pos":[{"mask-t-to":K()}],"mask-image-t-from-color":[{"mask-t-from":A()}],"mask-image-t-to-color":[{"mask-t-to":A()}],"mask-image-r-from-pos":[{"mask-r-from":K()}],"mask-image-r-to-pos":[{"mask-r-to":K()}],"mask-image-r-from-color":[{"mask-r-from":A()}],"mask-image-r-to-color":[{"mask-r-to":A()}],"mask-image-b-from-pos":[{"mask-b-from":K()}],"mask-image-b-to-pos":[{"mask-b-to":K()}],"mask-image-b-from-color":[{"mask-b-from":A()}],"mask-image-b-to-color":[{"mask-b-to":A()}],"mask-image-l-from-pos":[{"mask-l-from":K()}],"mask-image-l-to-pos":[{"mask-l-to":K()}],"mask-image-l-from-color":[{"mask-l-from":A()}],"mask-image-l-to-color":[{"mask-l-to":A()}],"mask-image-x-from-pos":[{"mask-x-from":K()}],"mask-image-x-to-pos":[{"mask-x-to":K()}],"mask-image-x-from-color":[{"mask-x-from":A()}],"mask-image-x-to-color":[{"mask-x-to":A()}],"mask-image-y-from-pos":[{"mask-y-from":K()}],"mask-image-y-to-pos":[{"mask-y-to":K()}],"mask-image-y-from-color":[{"mask-y-from":A()}],"mask-image-y-to-color":[{"mask-y-to":A()}],"mask-image-radial":[{"mask-radial":[le,oe]}],"mask-image-radial-from-pos":[{"mask-radial-from":K()}],"mask-image-radial-to-pos":[{"mask-radial-to":K()}],"mask-image-radial-from-color":[{"mask-radial-from":A()}],"mask-image-radial-to-color":[{"mask-radial-to":A()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":N()}],"mask-image-conic-pos":[{"mask-conic":[Se]}],"mask-image-conic-from-pos":[{"mask-conic-from":K()}],"mask-image-conic-to-pos":[{"mask-conic-to":K()}],"mask-image-conic-from-color":[{"mask-conic-from":A()}],"mask-image-conic-to-color":[{"mask-conic-to":A()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:V()}],"mask-repeat":[{mask:U()}],"mask-size":[{mask:I()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",le,oe]}],filter:[{filter:["","none",le,oe]}],blur:[{blur:de()}],brightness:[{brightness:[Se,le,oe]}],contrast:[{contrast:[Se,le,oe]}],"drop-shadow":[{"drop-shadow":["","none",p,kr,vr]}],"drop-shadow-color":[{"drop-shadow":A()}],grayscale:[{grayscale:["",Se,le,oe]}],"hue-rotate":[{"hue-rotate":[Se,le,oe]}],invert:[{invert:["",Se,le,oe]}],saturate:[{saturate:[Se,le,oe]}],sepia:[{sepia:["",Se,le,oe]}],"backdrop-filter":[{"backdrop-filter":["","none",le,oe]}],"backdrop-blur":[{"backdrop-blur":de()}],"backdrop-brightness":[{"backdrop-brightness":[Se,le,oe]}],"backdrop-contrast":[{"backdrop-contrast":[Se,le,oe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Se,le,oe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Se,le,oe]}],"backdrop-invert":[{"backdrop-invert":["",Se,le,oe]}],"backdrop-opacity":[{"backdrop-opacity":[Se,le,oe]}],"backdrop-saturate":[{"backdrop-saturate":[Se,le,oe]}],"backdrop-sepia":[{"backdrop-sepia":["",Se,le,oe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":L()}],"border-spacing-x":[{"border-spacing-x":L()}],"border-spacing-y":[{"border-spacing-y":L()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",le,oe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Se,"initial",le,oe]}],ease:[{ease:["linear","initial",x,le,oe]}],delay:[{delay:[Se,le,oe]}],animate:[{animate:["none",y,le,oe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,le,oe]}],"perspective-origin":[{"perspective-origin":w()}],rotate:[{rotate:_()}],"rotate-x":[{"rotate-x":_()}],"rotate-y":[{"rotate-y":_()}],"rotate-z":[{"rotate-z":_()}],scale:[{scale:Y()}],"scale-x":[{"scale-x":Y()}],"scale-y":[{"scale-y":Y()}],"scale-z":[{"scale-z":Y()}],"scale-3d":["scale-3d"],skew:[{skew:te()}],"skew-x":[{"skew-x":te()}],"skew-y":[{"skew-y":te()}],transform:[{transform:[le,oe,"","none","gpu","cpu"]}],"transform-origin":[{origin:w()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ie()}],"translate-x":[{"translate-x":ie()}],"translate-y":[{"translate-y":ie()}],"translate-z":[{"translate-z":ie()}],"translate-none":["translate-none"],zoom:[{zoom:[ut,le,oe]}],accent:[{accent:A()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:A()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",le,oe]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":A()}],"scrollbar-track-color":[{"scrollbar-track":A()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":L()}],"scroll-mx":[{"scroll-mx":L()}],"scroll-my":[{"scroll-my":L()}],"scroll-ms":[{"scroll-ms":L()}],"scroll-me":[{"scroll-me":L()}],"scroll-mbs":[{"scroll-mbs":L()}],"scroll-mbe":[{"scroll-mbe":L()}],"scroll-mt":[{"scroll-mt":L()}],"scroll-mr":[{"scroll-mr":L()}],"scroll-mb":[{"scroll-mb":L()}],"scroll-ml":[{"scroll-ml":L()}],"scroll-p":[{"scroll-p":L()}],"scroll-px":[{"scroll-px":L()}],"scroll-py":[{"scroll-py":L()}],"scroll-ps":[{"scroll-ps":L()}],"scroll-pe":[{"scroll-pe":L()}],"scroll-pbs":[{"scroll-pbs":L()}],"scroll-pbe":[{"scroll-pbe":L()}],"scroll-pt":[{"scroll-pt":L()}],"scroll-pr":[{"scroll-pr":L()}],"scroll-pb":[{"scroll-pb":L()}],"scroll-pl":[{"scroll-pl":L()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",le,oe]}],fill:[{fill:["none",...A()]}],"stroke-w":[{stroke:[Se,rr,Tt,ya]}],stroke:[{stroke:["none",...A()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},ic=Bd(lc),Ca=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Sa=_s,mr=(e,r)=>n=>{var a;if((r==null?void 0:r.variants)==null)return Sa(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:s,defaultVariants:o}=r,l=Object.keys(s).map(h=>{const u=n==null?void 0:n[h],m=o==null?void 0:o[h];if(u===null)return null;const f=Ca(u)||Ca(m);return s[h][f]}),i=n&&Object.entries(n).reduce((h,u)=>{let[m,f]=u;return f===void 0||(h[m]=f),h},{}),d=r==null||(a=r.compoundVariants)===null||a===void 0?void 0:a.reduce((h,u)=>{let{class:m,className:f,...p}=u;return Object.entries(p).every(g=>{let[b,v]=g;return Array.isArray(v)?v.includes({...o,...i}[b]):{...o,...i}[b]===v})?[...h,m,f]:h},[]);return Sa(e,l,d,n==null?void 0:n.class,n==null?void 0:n.className)},Dr=c.createContext(null);Dr.displayName="PanelGroupContext";const Fe={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},Kn=10,Rt=c.useLayoutEffect,Ta=ad.useId,dc=typeof Ta=="function"?Ta:()=>null;let cc=0;function qn(e=null){const r=dc(),n=c.useRef(e||r||null);return n.current===null&&(n.current=""+cc++),e??n.current}function Xs({children:e,className:r="",collapsedSize:n,collapsible:a,defaultSize:s,forwardedRef:o,id:l,maxSize:i,minSize:d,onCollapse:h,onExpand:u,onResize:m,order:f,style:p,tagName:g="div",...b}){const v=c.useContext(Dr);if(v===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:x,expandPanel:y,getPanelSize:k,getPanelStyle:N,groupId:w,isPanelCollapsed:j,reevaluatePanelConstraints:C,registerPanel:L,resizePanel:T,unregisterPanel:q}=v,M=qn(l),D=c.useRef({callbacks:{onCollapse:h,onExpand:u,onResize:m},constraints:{collapsedSize:n,collapsible:a,defaultSize:s,maxSize:i,minSize:d},id:M,idIsFromProps:l!==void 0,order:f});c.useRef({didLogMissingDefaultSizeWarning:!1}),Rt(()=>{const{callbacks:W,constraints:O}=D.current,ee={...O};D.current.id=M,D.current.idIsFromProps=l!==void 0,D.current.order=f,W.onCollapse=h,W.onExpand=u,W.onResize=m,O.collapsedSize=n,O.collapsible=a,O.defaultSize=s,O.maxSize=i,O.minSize=d,(ee.collapsedSize!==O.collapsedSize||ee.collapsible!==O.collapsible||ee.maxSize!==O.maxSize||ee.minSize!==O.minSize)&&C(D.current,ee)}),Rt(()=>{const W=D.current;return L(W),()=>{q(W)}},[f,M,L,q]),c.useImperativeHandle(o,()=>({collapse:()=>{x(D.current)},expand:W=>{y(D.current,W)},getId(){return M},getSize(){return k(D.current)},isCollapsed(){return j(D.current)},isExpanded(){return!j(D.current)},resize:W=>{T(D.current,W)}}),[x,y,k,j,M,T]);const J=N(D.current,s);return c.createElement(g,{...b,children:e,className:r,id:M,style:{...J,...p},[Fe.groupId]:w,[Fe.panel]:"",[Fe.panelCollapsible]:a||void 0,[Fe.panelId]:M,[Fe.panelSize]:parseFloat(""+J.flexGrow).toFixed(1)})}const Ys=c.forwardRef((e,r)=>c.createElement(Xs,{...e,forwardedRef:r}));Xs.displayName="Panel";Ys.displayName="forwardRef(Panel)";let Cn=null,Sr=-1,wt=null;function hc(e,r,n){const a=(r&to)!==0,s=(r&ro)!==0,o=(r&no)!==0,l=(r&ao)!==0;if(r){if(a)return o?"se-resize":l?"ne-resize":"e-resize";if(s)return o?"sw-resize":l?"nw-resize":"w-resize";if(o)return"s-resize";if(l)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function uc(){wt!==null&&(document.head.removeChild(wt),Cn=null,wt=null,Sr=-1)}function on(e,r,n){var a,s;const o=hc(e,r);if(Cn!==o){if(Cn=o,wt===null&&(wt=document.createElement("style"),document.head.appendChild(wt)),Sr>=0){var l;(l=wt.sheet)===null||l===void 0||l.removeRule(Sr)}Sr=(a=(s=wt.sheet)===null||s===void 0?void 0:s.insertRule(`*{cursor: ${o} !important;}`))!==null&&a!==void 0?a:-1}}function Zs(e){return e.type==="keydown"}function Js(e){return e.type.startsWith("pointer")}function Qs(e){return e.type.startsWith("mouse")}function Br(e){if(Js(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Qs(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function mc(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function pc(e,r,n){return e.x<r.x+r.width&&e.x+e.width>r.x&&e.y<r.y+r.height&&e.y+e.height>r.y}function fc(e,r){if(e===r)throw new Error("Cannot compare node with itself");const n={a:Pa(e),b:Pa(r)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),r=n.b.pop(),a=e;Ne(a,"Stacking order can only be calculated for elements with a common ancestor");const s={a:La(Ea(n.a)),b:La(Ea(n.b))};if(s.a===s.b){const o=a.childNodes,l={a:n.a.at(-1),b:n.b.at(-1)};let i=o.length;for(;i--;){const d=o[i];if(d===l.a)return 1;if(d===l.b)return-1}}return Math.sign(s.a-s.b)}const gc=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function xc(e){var r;const n=getComputedStyle((r=eo(e))!==null&&r!==void 0?r:e).display;return n==="flex"||n==="inline-flex"}function bc(e){const r=getComputedStyle(e);return!!(r.position==="fixed"||r.zIndex!=="auto"&&(r.position!=="static"||xc(e))||+r.opacity<1||"transform"in r&&r.transform!=="none"||"webkitTransform"in r&&r.webkitTransform!=="none"||"mixBlendMode"in r&&r.mixBlendMode!=="normal"||"filter"in r&&r.filter!=="none"||"webkitFilter"in r&&r.webkitFilter!=="none"||"isolation"in r&&r.isolation==="isolate"||gc.test(r.willChange)||r.webkitOverflowScrolling==="touch")}function Ea(e){let r=e.length;for(;r--;){const n=e[r];if(Ne(n,"Missing node"),bc(n))return n}return null}function La(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Pa(e){const r=[];for(;e;)r.push(e),e=eo(e);return r}function eo(e){const{parentNode:r}=e;return r&&r instanceof ShadowRoot?r.host:r}const to=1,ro=2,no=4,ao=8,vc=mc()==="coarse";let ct=[],Yt=!1,yt=new Map,Gr=new Map;const cr=new Set;function kc(e,r,n,a,s){var o;const{ownerDocument:l}=r,i={direction:n,element:r,hitAreaMargins:a,setResizeHandlerState:s},d=(o=yt.get(l))!==null&&o!==void 0?o:0;return yt.set(l,d+1),cr.add(i),zr(),function(){var u;Gr.delete(e),cr.delete(i);const m=(u=yt.get(l))!==null&&u!==void 0?u:1;if(yt.set(l,m-1),zr(),m===1&&yt.delete(l),ct.includes(i)){const f=ct.indexOf(i);f>=0&&ct.splice(f,1),Fr(),s("up",!0,null)}}}function wc(e){const{target:r}=e,{x:n,y:a}=Br(e);Yt=!0,Xn({target:r,x:n,y:a}),zr(),ct.length>0&&(Rr("down",e),Fr(),e.preventDefault(),so(r)||e.stopImmediatePropagation())}function ln(e){const{x:r,y:n}=Br(e);if(Yt&&e.type!=="pointerleave"&&e.buttons===0&&(Yt=!1,Rr("up",e)),!Yt){const{target:a}=e;Xn({target:a,x:r,y:n})}Rr("move",e),Fr(),ct.length>0&&e.preventDefault()}function dn(e){const{target:r}=e,{x:n,y:a}=Br(e);Gr.clear(),Yt=!1,ct.length>0&&(e.preventDefault(),so(r)||e.stopImmediatePropagation()),Rr("up",e),Xn({target:r,x:n,y:a}),Fr(),zr()}function so(e){let r=e;for(;r;){if(r.hasAttribute(Fe.resizeHandle))return!0;r=r.parentElement}return!1}function Xn({target:e,x:r,y:n}){ct.splice(0);let a=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(a=e),cr.forEach(s=>{const{element:o,hitAreaMargins:l}=s,i=o.getBoundingClientRect(),{bottom:d,left:h,right:u,top:m}=i,f=vc?l.coarse:l.fine;if(r>=h-f&&r<=u+f&&n>=m-f&&n<=d+f){if(a!==null&&document.contains(a)&&o!==a&&!o.contains(a)&&!a.contains(o)&&fc(a,o)>0){let g=a,b=!1;for(;g&&!g.contains(o);){if(pc(g.getBoundingClientRect(),i)){b=!0;break}g=g.parentElement}if(b)return}ct.push(s)}})}function cn(e,r){Gr.set(e,r)}function Fr(){let e=!1,r=!1;ct.forEach(a=>{const{direction:s}=a;s==="horizontal"?e=!0:r=!0});let n=0;Gr.forEach(a=>{n|=a}),e&&r?on("intersection",n):e?on("horizontal",n):r?on("vertical",n):uc()}let hn;function zr(){var e;(e=hn)===null||e===void 0||e.abort(),hn=new AbortController;const r={capture:!0,signal:hn.signal};cr.size&&(Yt?(ct.length>0&&yt.forEach((n,a)=>{const{body:s}=a;n>0&&(s.addEventListener("contextmenu",dn,r),s.addEventListener("pointerleave",ln,r),s.addEventListener("pointermove",ln,r))}),yt.forEach((n,a)=>{const{body:s}=a;s.addEventListener("pointerup",dn,r),s.addEventListener("pointercancel",dn,r)})):yt.forEach((n,a)=>{const{body:s}=a;n>0&&(s.addEventListener("pointerdown",wc,r),s.addEventListener("pointermove",ln,r))}))}function Rr(e,r){cr.forEach(n=>{const{setResizeHandlerState:a}=n,s=ct.includes(n);a(e,s,r)})}function yc(){const[e,r]=c.useState(0);return c.useCallback(()=>r(n=>n+1),[])}function Ne(e,r){if(!e)throw console.error(r),Error(r)}function Mt(e,r,n=Kn){return e.toFixed(n)===r.toFixed(n)?0:e>r?1:-1}function gt(e,r,n=Kn){return Mt(e,r,n)===0}function ot(e,r,n){return Mt(e,r,n)===0}function jc(e,r,n){if(e.length!==r.length)return!1;for(let a=0;a<e.length;a++){const s=e[a],o=r[a];if(!ot(s,o,n))return!1}return!0}function qt({panelConstraints:e,panelIndex:r,size:n}){const a=e[r];Ne(a!=null,`Panel constraints not found for index ${r}`);let{collapsedSize:s=0,collapsible:o,maxSize:l=100,minSize:i=0}=a;if(Mt(n,i)<0)if(o){const d=(s+i)/2;Mt(n,d)<0?n=s:n=i}else n=i;return n=Math.min(l,n),n=parseFloat(n.toFixed(Kn)),n}function or({delta:e,initialLayout:r,panelConstraints:n,pivotIndices:a,prevLayout:s,trigger:o}){if(ot(e,0))return r;const l=[...r],[i,d]=a;Ne(i!=null,"Invalid first pivot index"),Ne(d!=null,"Invalid second pivot index");let h=0;if(o==="keyboard"){{const m=e<0?d:i,f=n[m];Ne(f,`Panel constraints not found for index ${m}`);const{collapsedSize:p=0,collapsible:g,minSize:b=0}=f;if(g){const v=r[m];if(Ne(v!=null,`Previous layout not found for panel index ${m}`),ot(v,p)){const x=b-v;Mt(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}{const m=e<0?i:d,f=n[m];Ne(f,`No panel constraints found for index ${m}`);const{collapsedSize:p=0,collapsible:g,minSize:b=0}=f;if(g){const v=r[m];if(Ne(v!=null,`Previous layout not found for panel index ${m}`),ot(v,b)){const x=v-p;Mt(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}}{const m=e<0?1:-1;let f=e<0?d:i,p=0;for(;;){const b=r[f];Ne(b!=null,`Previous layout not found for panel index ${f}`);const x=qt({panelConstraints:n,panelIndex:f,size:100})-b;if(p+=x,f+=m,f<0||f>=n.length)break}const g=Math.min(Math.abs(e),Math.abs(p));e=e<0?0-g:g}{let f=e<0?i:d;for(;f>=0&&f<n.length;){const p=Math.abs(e)-Math.abs(h),g=r[f];Ne(g!=null,`Previous layout not found for panel index ${f}`);const b=g-p,v=qt({panelConstraints:n,panelIndex:f,size:b});if(!ot(g,v)&&(h+=g-v,l[f]=v,h.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?f--:f++}}if(jc(s,l))return s;{const m=e<0?d:i,f=r[m];Ne(f!=null,`Previous layout not found for panel index ${m}`);const p=f+h,g=qt({panelConstraints:n,panelIndex:m,size:p});if(l[m]=g,!ot(g,p)){let b=p-g,x=e<0?d:i;for(;x>=0&&x<n.length;){const y=l[x];Ne(y!=null,`Previous layout not found for panel index ${x}`);const k=y+b,N=qt({panelConstraints:n,panelIndex:x,size:k});if(ot(y,N)||(b-=N-y,l[x]=N),ot(b,0))break;e>0?x--:x++}}}const u=l.reduce((m,f)=>f+m,0);return ot(u,100)?l:s}function Nc({layout:e,panelsArray:r,pivotIndices:n}){let a=0,s=100,o=0,l=0;const i=n[0];Ne(i!=null,"No pivot index found"),r.forEach((m,f)=>{const{constraints:p}=m,{maxSize:g=100,minSize:b=0}=p;f===i?(a=b,s=g):(o+=b,l+=g)});const d=Math.min(s,100-o),h=Math.max(a,100-l),u=e[i];return{valueMax:d,valueMin:h,valueNow:u}}function hr(e,r=document){return Array.from(r.querySelectorAll(`[${Fe.resizeHandleId}][data-panel-group-id="${e}"]`))}function oo(e,r,n=document){const s=hr(e,n).findIndex(o=>o.getAttribute(Fe.resizeHandleId)===r);return s??null}function lo(e,r,n){const a=oo(e,r,n);return a!=null?[a,a+1]:[-1,-1]}function Cc(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function io(e,r=document){if(Cc(r)&&r.dataset.panelGroupId==e)return r;const n=r.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function Hr(e,r=document){const n=r.querySelector(`[${Fe.resizeHandleId}="${e}"]`);return n||null}function Sc(e,r,n,a=document){var s,o,l,i;const d=Hr(r,a),h=hr(e,a),u=d?h.indexOf(d):-1,m=(s=(o=n[u])===null||o===void 0?void 0:o.id)!==null&&s!==void 0?s:null,f=(l=(i=n[u+1])===null||i===void 0?void 0:i.id)!==null&&l!==void 0?l:null;return[m,f]}function Tc({committedValuesRef:e,eagerValuesRef:r,groupId:n,layout:a,panelDataArray:s,panelGroupElement:o,setLayout:l}){c.useRef({didWarnAboutMissingResizeHandle:!1}),Rt(()=>{if(!o)return;const i=hr(n,o);for(let d=0;d<s.length-1;d++){const{valueMax:h,valueMin:u,valueNow:m}=Nc({layout:a,panelsArray:s,pivotIndices:[d,d+1]}),f=i[d];if(f!=null){const p=s[d];Ne(p,`No panel data found for index "${d}"`),f.setAttribute("aria-controls",p.id),f.setAttribute("aria-valuemax",""+Math.round(h)),f.setAttribute("aria-valuemin",""+Math.round(u)),f.setAttribute("aria-valuenow",m!=null?""+Math.round(m):"")}}return()=>{i.forEach((d,h)=>{d.removeAttribute("aria-controls"),d.removeAttribute("aria-valuemax"),d.removeAttribute("aria-valuemin"),d.removeAttribute("aria-valuenow")})}},[n,a,s,o]),c.useEffect(()=>{if(!o)return;const i=r.current;Ne(i,"Eager values not found");const{panelDataArray:d}=i,h=io(n,o);Ne(h!=null,`No group found for id "${n}"`);const u=hr(n,o);Ne(u,`No resize handles found for group id "${n}"`);const m=u.map(f=>{const p=f.getAttribute(Fe.resizeHandleId);Ne(p,"Resize handle element has no handle id attribute");const[g,b]=Sc(n,p,d,o);if(g==null||b==null)return()=>{};const v=x=>{if(!x.defaultPrevented)switch(x.key){case"Enter":{x.preventDefault();const y=d.findIndex(k=>k.id===g);if(y>=0){const k=d[y];Ne(k,`No panel data found for index ${y}`);const N=a[y],{collapsedSize:w=0,collapsible:j,minSize:C=0}=k.constraints;if(N!=null&&j){const L=or({delta:ot(N,w)?C-w:w-N,initialLayout:a,panelConstraints:d.map(T=>T.constraints),pivotIndices:lo(n,p,o),prevLayout:a,trigger:"keyboard"});a!==L&&l(L)}}break}}};return f.addEventListener("keydown",v),()=>{f.removeEventListener("keydown",v)}});return()=>{m.forEach(f=>f())}},[o,e,r,n,a,s,l])}function Ia(e,r){if(e.length!==r.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==r[n])return!1;return!0}function co(e,r){const n=e==="horizontal",{x:a,y:s}=Br(r);return n?a:s}function Ec(e,r,n,a,s){const o=n==="horizontal",l=Hr(r,s);Ne(l,`No resize handle element found for id "${r}"`);const i=l.getAttribute(Fe.groupId);Ne(i,"Resize handle element has no group id attribute");let{initialCursorPosition:d}=a;const h=co(n,e),u=io(i,s);Ne(u,`No group element found for id "${i}"`);const m=u.getBoundingClientRect(),f=o?m.width:m.height;return(h-d)/f*100}function Lc(e,r,n,a,s,o){if(Zs(e)){const l=n==="horizontal";let i=0;e.shiftKey?i=100:s!=null?i=s:i=10;let d=0;switch(e.key){case"ArrowDown":d=l?0:i;break;case"ArrowLeft":d=l?-i:0;break;case"ArrowRight":d=l?i:0;break;case"ArrowUp":d=l?0:-i;break;case"End":d=100;break;case"Home":d=-100;break}return d}else return a==null?0:Ec(e,r,n,a,o)}function Pc({panelDataArray:e}){const r=Array(e.length),n=e.map(o=>o.constraints);let a=0,s=100;for(let o=0;o<e.length;o++){const l=n[o];Ne(l,`Panel constraints not found for index ${o}`);const{defaultSize:i}=l;i!=null&&(a++,r[o]=i,s-=i)}for(let o=0;o<e.length;o++){const l=n[o];Ne(l,`Panel constraints not found for index ${o}`);const{defaultSize:i}=l;if(i!=null)continue;const d=e.length-a,h=s/d;a++,r[o]=h,s-=h}return r}function Ot(e,r,n){r.forEach((a,s)=>{const o=e[s];Ne(o,`Panel data not found for index ${s}`);const{callbacks:l,constraints:i,id:d}=o,{collapsedSize:h=0,collapsible:u}=i,m=n[d];if(m==null||a!==m){n[d]=a;const{onCollapse:f,onExpand:p,onResize:g}=l;g&&g(a,m),u&&(f||p)&&(p&&(m==null||gt(m,h))&&!gt(a,h)&&p(),f&&(m==null||!gt(m,h))&>(a,h)&&f())}})}function wr(e,r){if(e.length!==r.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=r[n])return!1;return!0}function Ic({defaultSize:e,dragState:r,layout:n,panelData:a,panelIndex:s,precision:o=3}){const l=n[s];let i;return l==null?i=e!=null?e.toFixed(o):"1":a.length===1?i="1":i=l.toFixed(o),{flexBasis:0,flexGrow:i,flexShrink:1,overflow:"hidden",pointerEvents:r!==null?"none":void 0}}function zc(e,r=10){let n=null;return(...s)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...s)},r)}}function za(e){try{if(typeof localStorage<"u")e.getItem=r=>localStorage.getItem(r),e.setItem=(r,n)=>{localStorage.setItem(r,n)};else throw new Error("localStorage not supported in this environment")}catch(r){console.error(r),e.getItem=()=>null,e.setItem=()=>{}}}function ho(e){return`react-resizable-panels:${e}`}function uo(e){return e.map(r=>{const{constraints:n,id:a,idIsFromProps:s,order:o}=r;return s?a:o?`${o}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((r,n)=>r.localeCompare(n)).join(",")}function mo(e,r){try{const n=ho(e),a=r.getItem(n);if(a){const s=JSON.parse(a);if(typeof s=="object"&&s!=null)return s}}catch{}return null}function Rc(e,r,n){var a,s;const o=(a=mo(e,n))!==null&&a!==void 0?a:{},l=uo(r);return(s=o[l])!==null&&s!==void 0?s:null}function _c(e,r,n,a,s){var o;const l=ho(e),i=uo(r),d=(o=mo(e,s))!==null&&o!==void 0?o:{};d[i]={expandToSizes:Object.fromEntries(n.entries()),layout:a};try{s.setItem(l,JSON.stringify(d))}catch(h){console.error(h)}}function Ra({layout:e,panelConstraints:r}){const n=[...e],a=n.reduce((o,l)=>o+l,0);if(n.length!==r.length)throw Error(`Invalid ${r.length} panel layout: ${n.map(o=>`${o}%`).join(", ")}`);if(!ot(a,100)&&n.length>0)for(let o=0;o<r.length;o++){const l=n[o];Ne(l!=null,`No layout data found for index ${o}`);const i=100/a*l;n[o]=i}let s=0;for(let o=0;o<r.length;o++){const l=n[o];Ne(l!=null,`No layout data found for index ${o}`);const i=qt({panelConstraints:r,panelIndex:o,size:l});l!=i&&(s+=l-i,n[o]=i)}if(!ot(s,0))for(let o=0;o<r.length;o++){const l=n[o];Ne(l!=null,`No layout data found for index ${o}`);const i=l+s,d=qt({panelConstraints:r,panelIndex:o,size:i});if(l!==d&&(s-=d-l,n[o]=d,ot(s,0)))break}return n}const Ac=100,lr={getItem:e=>(za(lr),lr.getItem(e)),setItem:(e,r)=>{za(lr),lr.setItem(e,r)}},_a={};function po({autoSaveId:e=null,children:r,className:n="",direction:a,forwardedRef:s,id:o=null,onLayout:l=null,keyboardResizeBy:i=null,storage:d=lr,style:h,tagName:u="div",...m}){const f=qn(o),p=c.useRef(null),[g,b]=c.useState(null),[v,x]=c.useState([]),y=yc(),k=c.useRef({}),N=c.useRef(new Map),w=c.useRef(0),j=c.useRef({autoSaveId:e,direction:a,dragState:g,id:f,keyboardResizeBy:i,onLayout:l,storage:d}),C=c.useRef({layout:v,panelDataArray:[],panelDataArrayChanged:!1});c.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),c.useImperativeHandle(s,()=>({getId:()=>j.current.id,getLayout:()=>{const{layout:I}=C.current;return I},setLayout:I=>{const{onLayout:X}=j.current,{layout:F,panelDataArray:z}=C.current,P=Ra({layout:I,panelConstraints:z.map(Z=>Z.constraints)});Ia(F,P)||(x(P),C.current.layout=P,X&&X(P),Ot(z,P,k.current))}}),[]),Rt(()=>{j.current.autoSaveId=e,j.current.direction=a,j.current.dragState=g,j.current.id=f,j.current.onLayout=l,j.current.storage=d}),Tc({committedValuesRef:j,eagerValuesRef:C,groupId:f,layout:v,panelDataArray:C.current.panelDataArray,setLayout:x,panelGroupElement:p.current}),c.useEffect(()=>{const{panelDataArray:I}=C.current;if(e){if(v.length===0||v.length!==I.length)return;let X=_a[e];X==null&&(X=zc(_c,Ac),_a[e]=X);const F=[...I],z=new Map(N.current);X(e,F,z,v,d)}},[e,v,d]),c.useEffect(()=>{});const L=c.useCallback(I=>{const{onLayout:X}=j.current,{layout:F,panelDataArray:z}=C.current;if(I.constraints.collapsible){const P=z.map(_=>_.constraints),{collapsedSize:Z=0,panelSize:K,pivotIndices:de}=Et(z,I,F);if(Ne(K!=null,`Panel size not found for panel "${I.id}"`),!gt(K,Z)){N.current.set(I.id,K);const Y=Wt(z,I)===z.length-1?K-Z:Z-K,te=or({delta:Y,initialLayout:F,panelConstraints:P,pivotIndices:de,prevLayout:F,trigger:"imperative-api"});wr(F,te)||(x(te),C.current.layout=te,X&&X(te),Ot(z,te,k.current))}}},[]),T=c.useCallback((I,X)=>{const{onLayout:F}=j.current,{layout:z,panelDataArray:P}=C.current;if(I.constraints.collapsible){const Z=P.map(ie=>ie.constraints),{collapsedSize:K=0,panelSize:de=0,minSize:_=0,pivotIndices:Y}=Et(P,I,z),te=X??_;if(gt(de,K)){const ie=N.current.get(I.id),ue=ie!=null&&ie>=te?ie:te,Le=Wt(P,I)===P.length-1?de-ue:ue-de,ae=or({delta:Le,initialLayout:z,panelConstraints:Z,pivotIndices:Y,prevLayout:z,trigger:"imperative-api"});wr(z,ae)||(x(ae),C.current.layout=ae,F&&F(ae),Ot(P,ae,k.current))}}},[]),q=c.useCallback(I=>{const{layout:X,panelDataArray:F}=C.current,{panelSize:z}=Et(F,I,X);return Ne(z!=null,`Panel size not found for panel "${I.id}"`),z},[]),M=c.useCallback((I,X)=>{const{panelDataArray:F}=C.current,z=Wt(F,I);return Ic({defaultSize:X,dragState:g,layout:v,panelData:F,panelIndex:z})},[g,v]),D=c.useCallback(I=>{const{layout:X,panelDataArray:F}=C.current,{collapsedSize:z=0,collapsible:P,panelSize:Z}=Et(F,I,X);return Ne(Z!=null,`Panel size not found for panel "${I.id}"`),P===!0&>(Z,z)},[]),J=c.useCallback(I=>{const{layout:X,panelDataArray:F}=C.current,{collapsedSize:z=0,collapsible:P,panelSize:Z}=Et(F,I,X);return Ne(Z!=null,`Panel size not found for panel "${I.id}"`),!P||Mt(Z,z)>0},[]),W=c.useCallback(I=>{const{panelDataArray:X}=C.current;X.push(I),X.sort((F,z)=>{const P=F.order,Z=z.order;return P==null&&Z==null?0:P==null?-1:Z==null?1:P-Z}),C.current.panelDataArrayChanged=!0,y()},[y]);Rt(()=>{if(C.current.panelDataArrayChanged){C.current.panelDataArrayChanged=!1;const{autoSaveId:I,onLayout:X,storage:F}=j.current,{layout:z,panelDataArray:P}=C.current;let Z=null;if(I){const de=Rc(I,P,F);de&&(N.current=new Map(Object.entries(de.expandToSizes)),Z=de.layout)}Z==null&&(Z=Pc({panelDataArray:P}));const K=Ra({layout:Z,panelConstraints:P.map(de=>de.constraints)});Ia(z,K)||(x(K),C.current.layout=K,X&&X(K),Ot(P,K,k.current))}}),Rt(()=>{const I=C.current;return()=>{I.layout=[]}},[]);const O=c.useCallback(I=>{let X=!1;const F=p.current;return F&&window.getComputedStyle(F,null).getPropertyValue("direction")==="rtl"&&(X=!0),function(P){P.preventDefault();const Z=p.current;if(!Z)return()=>null;const{direction:K,dragState:de,id:_,keyboardResizeBy:Y,onLayout:te}=j.current,{layout:ie,panelDataArray:ue}=C.current,{initialLayout:be}=de??{},Le=lo(_,I,Z);let ae=Lc(P,I,K,de,Y,Z);const ve=K==="horizontal";ve&&X&&(ae=-ae);const ke=ue.map(je=>je.constraints),pe=or({delta:ae,initialLayout:be??ie,panelConstraints:ke,pivotIndices:Le,prevLayout:ie,trigger:Zs(P)?"keyboard":"mouse-or-touch"}),Ie=!wr(ie,pe);(Js(P)||Qs(P))&&w.current!=ae&&(w.current=ae,!Ie&&ae!==0?ve?cn(I,ae<0?to:ro):cn(I,ae<0?no:ao):cn(I,0)),Ie&&(x(pe),C.current.layout=pe,te&&te(pe),Ot(ue,pe,k.current))}},[]),ee=c.useCallback((I,X)=>{const{onLayout:F}=j.current,{layout:z,panelDataArray:P}=C.current,Z=P.map(ie=>ie.constraints),{panelSize:K,pivotIndices:de}=Et(P,I,z);Ne(K!=null,`Panel size not found for panel "${I.id}"`);const Y=Wt(P,I)===P.length-1?K-X:X-K,te=or({delta:Y,initialLayout:z,panelConstraints:Z,pivotIndices:de,prevLayout:z,trigger:"imperative-api"});wr(z,te)||(x(te),C.current.layout=te,F&&F(te),Ot(P,te,k.current))},[]),he=c.useCallback((I,X)=>{const{layout:F,panelDataArray:z}=C.current,{collapsedSize:P=0,collapsible:Z}=X,{collapsedSize:K=0,collapsible:de,maxSize:_=100,minSize:Y=0}=I.constraints,{panelSize:te}=Et(z,I,F);te!=null&&(Z&&de&>(te,P)?gt(P,K)||ee(I,K):te<Y?ee(I,Y):te>_&&ee(I,_))},[ee]),E=c.useCallback((I,X)=>{const{direction:F}=j.current,{layout:z}=C.current;if(!p.current)return;const P=Hr(I,p.current);Ne(P,`Drag handle element not found for id "${I}"`);const Z=co(F,X);b({dragHandleId:I,dragHandleRect:P.getBoundingClientRect(),initialCursorPosition:Z,initialLayout:z})},[]),re=c.useCallback(()=>{b(null)},[]),A=c.useCallback(I=>{const{panelDataArray:X}=C.current,F=Wt(X,I);F>=0&&(X.splice(F,1),delete k.current[I.id],C.current.panelDataArrayChanged=!0,y())},[y]),V=c.useMemo(()=>({collapsePanel:L,direction:a,dragState:g,expandPanel:T,getPanelSize:q,getPanelStyle:M,groupId:f,isPanelCollapsed:D,isPanelExpanded:J,reevaluatePanelConstraints:he,registerPanel:W,registerResizeHandle:O,resizePanel:ee,startDragging:E,stopDragging:re,unregisterPanel:A,panelGroupElement:p.current}),[L,g,a,T,q,M,f,D,J,he,W,O,ee,E,re,A]),U={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return c.createElement(Dr.Provider,{value:V},c.createElement(u,{...m,children:r,className:n,id:o,ref:p,style:{...U,...h},[Fe.group]:"",[Fe.groupDirection]:a,[Fe.groupId]:f}))}const fo=c.forwardRef((e,r)=>c.createElement(po,{...e,forwardedRef:r}));po.displayName="PanelGroup";fo.displayName="forwardRef(PanelGroup)";function Wt(e,r){return e.findIndex(n=>n===r||n.id===r.id)}function Et(e,r,n){const a=Wt(e,r),o=a===e.length-1?[a-1,a]:[a,a+1],l=n[a];return{...r.constraints,panelSize:l,pivotIndices:o}}function Mc({disabled:e,handleId:r,resizeHandler:n,panelGroupElement:a}){c.useEffect(()=>{if(e||n==null||a==null)return;const s=Hr(r,a);if(s==null)return;const o=l=>{if(!l.defaultPrevented)switch(l.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{l.preventDefault(),n(l);break}case"F6":{l.preventDefault();const i=s.getAttribute(Fe.groupId);Ne(i,`No group element found for id "${i}"`);const d=hr(i,a),h=oo(i,r,a);Ne(h!==null,`No resize element found for id "${r}"`);const u=l.shiftKey?h>0?h-1:d.length-1:h+1<d.length?h+1:0;d[u].focus();break}}};return s.addEventListener("keydown",o),()=>{s.removeEventListener("keydown",o)}},[a,e,r,n])}function go({children:e=null,className:r="",disabled:n=!1,hitAreaMargins:a,id:s,onBlur:o,onClick:l,onDragging:i,onFocus:d,onPointerDown:h,onPointerUp:u,style:m={},tabIndex:f=0,tagName:p="div",...g}){var b,v;const x=c.useRef(null),y=c.useRef({onClick:l,onDragging:i,onPointerDown:h,onPointerUp:u});c.useEffect(()=>{y.current.onClick=l,y.current.onDragging=i,y.current.onPointerDown=h,y.current.onPointerUp=u});const k=c.useContext(Dr);if(k===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:N,groupId:w,registerResizeHandle:j,startDragging:C,stopDragging:L,panelGroupElement:T}=k,q=qn(s),[M,D]=c.useState("inactive"),[J,W]=c.useState(!1),[O,ee]=c.useState(null),he=c.useRef({state:M});Rt(()=>{he.current.state=M}),c.useEffect(()=>{if(n)ee(null);else{const V=j(q);ee(()=>V)}},[n,q,j]);const E=(b=a==null?void 0:a.coarse)!==null&&b!==void 0?b:15,re=(v=a==null?void 0:a.fine)!==null&&v!==void 0?v:5;c.useEffect(()=>{if(n||O==null)return;const V=x.current;Ne(V,"Element ref not attached");let U=!1;return kc(q,V,N,{coarse:E,fine:re},(X,F,z)=>{if(!F){D("inactive");return}switch(X){case"down":{D("drag"),U=!1,Ne(z,'Expected event to be defined for "down" action'),C(q,z);const{onDragging:P,onPointerDown:Z}=y.current;P==null||P(!0),Z==null||Z();break}case"move":{const{state:P}=he.current;U=!0,P!=="drag"&&D("hover"),Ne(z,'Expected event to be defined for "move" action'),O(z);break}case"up":{D("hover"),L();const{onClick:P,onDragging:Z,onPointerUp:K}=y.current;Z==null||Z(!1),K==null||K(),U||P==null||P();break}}})},[E,N,n,re,j,q,O,C,L]),Mc({disabled:n,handleId:q,resizeHandler:O,panelGroupElement:T});const A={touchAction:"none",userSelect:"none"};return c.createElement(p,{...g,children:e,className:r,id:s,onBlur:()=>{W(!1),o==null||o()},onFocus:()=>{W(!0),d==null||d()},ref:x,role:"separator",style:{...A,...m},tabIndex:f,[Fe.groupDirection]:N,[Fe.groupId]:w,[Fe.resizeHandle]:"",[Fe.resizeHandleActive]:M==="drag"?"pointer":J?"keyboard":void 0,[Fe.resizeHandleEnabled]:!n,[Fe.resizeHandleId]:q,[Fe.resizeHandleState]:M})}go.displayName="PanelResizeHandle";var $c=Object.defineProperty,Dc=Object.getOwnPropertyNames,$e=(e,r)=>function(){return e&&(r=(0,e[Dc(e)[0]])(e=0)),r},Bc=(e,r)=>{for(var n in r)$c(e,n,{get:r[n],enumerable:!0})};function et(...e){return ic(_s(e))}var Nt=$e({"src/components/graph-ui/utils.ts"(){}});function ur({asChild:e=!1,className:r,size:n,variant:a,...s}){const o=e?Ps:"button";return t.jsx(o,{"data-slot":"button",className:et(xo({variant:a,size:n,className:r})),...s})}var xo,Or=$e({"src/components/graph-ui/Button.tsx"(){Nt(),xo=mr("inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium outline-none transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}})}});function bo(...e){return e.filter(Boolean).join(" ")}function Sn({className:e,...r}){return t.jsx(fo,{"data-slot":"resizable-panel-group",className:bo("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...r})}function Xt({...e}){return t.jsx(Ys,{"data-slot":"resizable-panel",...e})}function Tn({withHandle:e,className:r,...n}){return t.jsx(go,{"data-slot":"resizable-handle",className:bo("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",r),...n,children:e?t.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:t.jsx(G.GripVerticalIcon,{className:"size-2.5"})}):null})}var vo=$e({"src/components/graph-workspace/GraphResizablePanels.tsx"(){}});function Yn(...e){return e.filter(Boolean).join(" ")}function pr({...e}){return t.jsx(_i,{"data-slot":"accordion",...e})}function fr({className:e,...r}){return t.jsx(Ai,{"data-slot":"accordion-item",className:Yn("border-b last:border-b-0",e),...r})}function Ur({className:e,children:r,...n}){return t.jsx($i,{className:"flex",children:t.jsxs(Di,{"data-slot":"accordion-trigger",className:Yn("flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium outline-none transition-all hover:underline disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",e),...n,children:[r,t.jsx(G.ChevronDownIcon,{className:"pointer-events-none size-4 shrink-0 translate-y-0.5 text-[var(--theme-fg-muted)] transition-transform duration-200"})]})})}function gr({className:e,children:r,...n}){return t.jsx(Mi,{"data-slot":"accordion-content",className:"overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:t.jsx("div",{className:Yn("pb-4 pt-0",e),children:r})})}var xr=$e({"src/components/graph-workspace/GraphAccordion.tsx"(){}});function Gc(e){var n;const r=[];for(const a of e.turns)for(const s of a.items)s.kind==="artifact"&&s.artifact&&r.push(s.artifact);for(const a of((n=e.liveItems)==null?void 0:n.items)??[])a.kind==="artifact"&&a.artifact&&r.push(a.artifact);return r}function Fc(e){return e.trim().replace(/^\/+|\/+$/g,"").replace(/[^\w.-]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function br(e){var r;return((r=e.split(".").pop())==null?void 0:r.toLowerCase())||""}function Hc(e){return e.split("/").filter(Boolean).at(-1)??e}function Vt(e){const r=e.kind==="directory"?"directory":"file",n=(e.children??[]).map(Vt);return{id:`workspace:${e.path}`,name:e.name,path:e.path,kind:r,...e.size!==void 0?{size:e.size}:{},...e.hasChildren!==void 0?{hasChildren:e.hasChildren}:r==="directory"?{hasChildren:n.length>0}:{},...e.childrenLoaded!==void 0?{childrenLoaded:e.childrenLoaded}:r==="directory"?{childrenLoaded:e.children!==void 0}:{},...e.truncated!==void 0?{truncated:e.truncated}:{},workspaceNode:e,children:n}}function ko(e,r,n,a={}){if(e.path===r)return{...e,children:n,hasChildren:n.length>0,childrenLoaded:!0,truncated:a.truncated??e.truncated};if(e.children.length===0)return e;let s=!1;const o=e.children.map(l=>{const i=ko(l,r,n,a);return i!==l&&(s=!0),i});return s?{...e,children:o}:e}function wo(e){if(e.kind==="file")return e;for(const r of e.children){const n=wo(r);if(n)return n}return null}function En(e,r){if(!e||r===null)return null;if(e.path===r)return e;for(const n of e.children){const a=En(n,r);if(a)return a}return null}function yo(e){return e.trim().replace(/\\/g,"/").replace(/^\.\/+/,"").replace(/^\/+/,"")}function Oc(e){const n=yo(e).split("/").filter(Boolean);n.pop();const a=[];let s="";for(const o of n)s=s?`${s}/${o}`:o,a.push(s);return a}function Ln(e,r,n){if(e.path===r)return n;if(e.children.length===0)return e;let a=!1;const s=e.children.map(o=>{const l=Ln(o,r,n);return l!==o&&(a=!0),l});return a?{...e,children:s}:e}function Pn(e,r){return!e||!r?!1:e.path===r?!0:e.children.some(n=>Pn(n,r))}function Uc(e){if(!e)return null;const r=br(e.path);return Zn.has(r)?{content:[e.content.endsWith(`
|
|
3
3
|
`)?e.content:`${e.content}
|
|
4
|
-
`],format:r==="extxyz"?"xyz":r,name:e.name,uuid:e.path}:null}function Vc(e){const r=vr(e);return r==="tsx"||r==="jsx"?"tsx":r==="yml"?"yaml":r||"text"}function Kc(e,r){let n=e,a="";for(const s of r){a=a?`${a}/${s}`:s;let o=n.children.find(l=>l.kind==="directory"&&l.name===s);o||(o={id:`dir:${a}`,name:s,path:a,kind:"directory",children:[]},n.children.push(o)),n=o}return n}function qc(e,r,n){const a=r.split("/").filter(Boolean),s=a.pop()??n.name;Kc(e,a).children.push({...n,name:n.name||s,path:r})}function Xc(e,r){return e.kind==="directory"&&r.kind!=="directory"?-1:e.kind!=="directory"&&r.kind==="directory"?1:e.name.localeCompare(r.name)}function No(e){e.children.sort(Xc);for(const r of e.children)No(r);return e}function Aa(e,r,n,a){var u;const s={id:"root",name:e.workspace.label??"Workspace",path:"",kind:"directory",children:[]},o={id:"artifacts",name:"artifacts",path:"artifacts",kind:"directory",children:[]};for(const m of r){const f=m.title||m.id,p=Hc(f)||m.id;o.children.push({id:`artifact:${m.id}`,name:`${p}.artifact`,path:`artifacts/${p}.artifact`,kind:"artifact",artifact:m,preview:m.summaryText??m.type,detail:JSON.stringify(m.payload,null,2),children:[]})}const l={id:"thread-events",name:"thread-events",path:"thread-events",kind:"directory",children:[]},i={id:"live",name:"live",path:"live",kind:"directory",children:[]};let d=0;const h=(m,f,p=!1)=>{d+=1;const g=f.kind.replace(/([A-Z])/g,"-$1").toLowerCase(),b=`${p?"live":`thread-events/${m}`}/${String(d).padStart(3,"0")}-${g}.json`,v="text"in f&&typeof f.text=="string"?f.text.slice(0,160):f.kind,x=f.kind==="artifact"&&f.artifact?f.artifact:null,y=x&&p?{id:`live-artifact:${x.id}`,name:x.title||x.id,path:b,kind:"live-artifact",artifact:x,item:f,preview:x.summaryText??x.type,detail:JSON.stringify(x.payload,null,2),children:[]}:{id:`event:${f.id}`,name:Oc(b),path:b,kind:"event",item:f,preview:v,detail:JSON.stringify(f,null,2),children:[]};if(p){i.children.push(y);return}qc(l,b.replace(/^thread-events\//,""),y)};for(const m of e.turns)for(const f of m.items)(f.kind==="commandExecution"||f.kind==="webSearch"||f.kind==="fileRead"||f.kind==="fileChange"||f.kind==="agentToolCall"||f.kind==="skillToolCall"||f.kind==="toolCall"||f.kind==="hook"||f.kind==="plan"||f.kind==="reasoning")&&h(m.id,f);for(const m of((u=e.liveItems)==null?void 0:u.items)??[])h(e.thread.activeTurnId??"live",m,!0);return s.children.push(o,l,i),No(s)}function Yc(e){const r=new Map,n=a=>{r.set(a.id,a);for(const s of a.children)n(s)};return n(e),r}function Co(e){if(e.kind==="artifact"||e.kind==="live-artifact"||e.kind==="event"||e.kind==="file")return e;for(const r of e.children){const n=Co(r);if(n)return n}return null}function $a(e){const r=e.split("/").filter(Boolean),n=[];for(let a=1;a<=r.length;a+=1)n.push(r.slice(0,a).join("/"));return n}var Jn,So,To,Qn=$e({"src/components/graph-workspace/workspaceTree.ts"(){Jn=new Set(["xyz","extxyz","cif","pdb"]),So=new Set(["png","jpg","jpeg","gif","webp","svg"]),To=new Set(["pdf"])}});function Kt({label:e,children:r}){return t.jsxs("section",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:e}),t.jsx("div",{className:"mt-2 text-sm text-[var(--theme-fg)]",children:r})]})}var Eo=$e({"src/components/graph-workspace/GraphWorkspaceCards.tsx"(){}});function Zc({className:e,decorative:r=!0,orientation:n="horizontal",...a}){return t.jsx(nd,{"data-slot":"separator",decorative:r,orientation:n,className:et("shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",e),...a})}var Jc=$e({"src/components/graph-ui/Separator.tsx"(){Nt()}});function Qc({className:e,orientation:r,...n}){return t.jsx("div",{role:"group","data-slot":"button-group","data-orientation":r,className:et(Lo({orientation:r}),e),...n})}function eh({className:e,orientation:r="vertical",...n}){return t.jsx(Zc,{"data-slot":"button-group-separator",orientation:r,className:et("relative !m-0 self-stretch bg-input data-[orientation=vertical]:h-auto",e),...n})}var Lo,Po=$e({"src/components/graph-ui/ButtonGroup.tsx"(){Jc(),Nt(),Lo=mr("flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}})}});function th({delayDuration:e=0,...r}){return t.jsx(ad,{"data-slot":"tooltip-provider",delayDuration:e,...r})}function rh({...e}){return t.jsx(th,{children:t.jsx(Ji,{"data-slot":"tooltip",...e})})}function nh({...e}){return t.jsx(Qi,{"data-slot":"tooltip-trigger",...e})}function ah({children:e,className:r,sideOffset:n=0,...a}){return t.jsx(ed,{children:t.jsxs(td,{"data-slot":"tooltip-content",sideOffset:n,className:et("z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md bg-foreground px-3 py-1.5 text-balance text-xs text-background animate-in fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",r),...a,children:[e,t.jsx(rd,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}var sh=$e({"src/components/graph-ui/Tooltip.tsx"(){Nt()}});function oh(e){return(e==null?void 0:e.trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""))||"molecule"}function Da(e,r){const n=new Blob([e],{type:"text/plain"}),a=URL.createObjectURL(n),s=document.createElement("a");s.href=a,s.download=r,s.click(),URL.revokeObjectURL(a)}function We({children:e,disabled:r,label:n,onClick:a}){return t.jsxs(rh,{children:[t.jsx(nh,{asChild:!0,children:t.jsx(ur,{type:"button",variant:"outline",size:"icon",className:"thread-graph-molecule-button size-8",disabled:r,onClick:a,title:n,"aria-label":n,children:e})}),t.jsx(ah,{children:t.jsx("p",{children:n})})]})}function In({children:e,className:r=""}){return t.jsx(Qc,{className:`thread-graph-molecule-button-group ${r}`,children:e})}var zo=$e({"src/components/graph-workspace/GraphMoleculeViewerControls.tsx"(){Ur(),Po(),sh()}});function lh({cameraInfo:e,onClearSelection:r,onClearStaged:n,onSendSelection:a,onSendStaged:s,onStageSelection:o,onToggleUnitCell:l,selectedAtomLabels:i,selectedSerials:d,stagedAtoms:h,stagedMolecules:u,unitCellAvailable:m,unitCellVisible:f}){const p=d.length>0,g=h>0;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex w-full justify-between gap-2 overflow-x-auto",children:[t.jsxs(In,{children:[t.jsx(We,{label:"Distance",children:t.jsx(G.AlignVerticalDistributeCenter,{className:"size-4"})}),t.jsx(We,{label:"Connectivity",children:t.jsx(G.Share2,{className:"size-4"})}),t.jsx(We,{label:"Angle",children:t.jsx(G.Waypoints,{className:"size-4"})}),t.jsx(We,{label:"Dihedral",children:t.jsx(G.Spline,{className:"size-4"})}),t.jsx(We,{label:"Add dummy atoms",children:t.jsx(G.Bubbles,{className:"size-4"})}),t.jsx(We,{label:"Delete atoms",children:t.jsx(G.CircleX,{className:"size-4"})}),t.jsx(We,{label:"Rotate",children:t.jsx(G.Rotate3d,{className:"size-4"})})]}),t.jsxs(In,{children:[t.jsx(We,{label:f?"Hide unit cell":"Show unit cell",disabled:!m,onClick:l,children:t.jsx(G.Boxes,{className:"size-4"})}),t.jsx(We,{label:"Clear selection",disabled:!p,onClick:r,children:t.jsx(G.Trash2,{className:"size-4"})}),t.jsx(We,{label:"Send selection",disabled:!p,onClick:a,children:t.jsx(G.Send,{className:"size-4"})}),t.jsx(We,{label:"Stage current selection",disabled:!p,onClick:o,children:t.jsx(G.Box,{className:"size-4"})}),t.jsx(We,{label:"Clear staged selections",disabled:!g,onClick:n,children:t.jsx(G.Eraser,{className:"size-4"})}),t.jsx(We,{label:"Send staged selections",disabled:!g,onClick:s,children:t.jsx(G.ArrowUpRight,{className:"size-4"})})]})]}),e?t.jsxs("div",{className:"thread-graph-molecule-camera",children:[t.jsxs("div",{children:[t.jsx("strong",{children:"XYZ: "}),"x=",e.position.x.toFixed(1)," y=",e.position.y.toFixed(1)," z=",e.position.z.toFixed(1),t.jsx("br",{}),t.jsx("strong",{children:"Quat: "}),"qx=",e.position.qx.toFixed(2)," qy=",e.position.qy.toFixed(2)," qz=",e.position.qz.toFixed(2)," qw=",e.position.qw.toFixed(2)]}),t.jsx("div",{className:"thread-graph-molecule-camera-divider"}),t.jsxs("div",{className:"flex flex-col gap-1 text-[10px]",children:[t.jsxs("div",{children:["Selected atoms:"," ",d.length>0?d.map(b=>`${i[b]??"Atom"}(${b})`).join(", "):"None"]}),t.jsxs("div",{children:["Staged: ",u," molecule(s), ",h," atom(s)"]})]})]}):null]})}var ih=$e({"src/components/graph-workspace/GraphMoleculeViewerLowerButtonGroup.tsx"(){zo()}});function dh({currentIndex:e,exportContent:r,moleculeId:n,onScreenshot:a,viewerRef:s,xyzContent:o,xyzFormat:l}){const i=oh(n);async function d(){o&&await navigator.clipboard.writeText(o)}function h(){o&&Da(o,`${i}_step_${e+1}.${l||"xyz"}`)}function u(){r&&Da(r,`${i}_trajectory.${l||"xyz"}`)}function m(){s.current&&(s.current.zoom(1.2),s.current.render())}function f(){s.current&&(s.current.zoom(.8),s.current.render())}function p(){s.current&&(s.current.zoomTo(),s.current.setCameraParameters({}),s.current.render())}return t.jsxs(In,{className:"ml-auto justify-end",children:[t.jsx(We,{label:"Copy current structure",onClick:()=>void d(),disabled:!o,children:t.jsx(G.Copy,{className:"size-3.5"})}),t.jsx(We,{label:"Download current structure",onClick:h,disabled:!o,children:t.jsx(G.Download,{className:"size-3.5"})}),t.jsx(We,{label:"Download full trajectory",onClick:u,disabled:!r,children:t.jsx(G.Box,{className:"size-3.5"})}),t.jsx(We,{label:"Copy screenshot",onClick:a,disabled:!s.current||!o,children:t.jsx(G.Camera,{className:"size-3.5"})}),t.jsx(eh,{className:"thread-graph-molecule-button-divider"}),t.jsx(We,{label:"Zoom in",onClick:m,disabled:!s.current||!o,children:t.jsx(G.ZoomIn,{className:"size-3.5"})}),t.jsx(We,{label:"Zoom out",onClick:f,disabled:!s.current||!o,children:t.jsx(G.ZoomOut,{className:"size-3.5"})}),t.jsx(We,{label:"Reset camera",onClick:p,disabled:!s.current||!o,children:t.jsx(G.RotateCcw,{className:"size-3.5"})})]})}var ch=$e({"src/components/graph-workspace/GraphMoleculeViewerUpperButtonGroup.tsx"(){Po(),zo()}});async function hh(){if(typeof window>"u")throw new Error("3Dmol is only available in a browser environment.");return window["3Dmol"]?window["3Dmol"]:(Er||(Er=new Promise((e,r)=>{const n=document.querySelector('script[data-remote-codex-3dmol="true"]'),a=()=>{if(window["3Dmol"]){e(window["3Dmol"]);return}r(new Error("3Dmol loaded without exposing the expected global."))};if(n){n.addEventListener("load",a,{once:!0}),n.addEventListener("error",()=>r(new Error("Unable to load 3Dmol viewer runtime.")),{once:!0});return}const s=document.createElement("script");s.src="/vendor/3Dmol-min.js",s.async=!0,s.dataset.remoteCodex3dmol="true",s.addEventListener("load",a,{once:!0}),s.addEventListener("error",()=>r(new Error("Unable to load 3Dmol viewer runtime.")),{once:!0}),document.head.appendChild(s)})),Er)}var Er,uh=$e({"src/components/graph-workspace/load3Dmol.ts"(){Er=null}});function mh({className:e,defaultValue:r,max:n=100,min:a=0,value:s,...o}){const l=c.useMemo(()=>Array.isArray(s)?s:Array.isArray(r)?r:[a,n],[r,n,a,s]);return t.jsxs(qi,{"data-slot":"slider",...r!==void 0?{defaultValue:r}:{},...s!==void 0?{value:s}:{},min:a,max:n,className:et("relative flex w-full touch-none select-none items-center data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",e),...o,children:[t.jsx(Xi,{"data-slot":"slider-track",className:"relative grow overflow-hidden rounded-full bg-muted data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5",children:t.jsx(Yi,{"data-slot":"slider-range",className:"absolute bg-primary data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"})}),Array.from({length:l.length},(i,d)=>t.jsx(Zi,{"data-slot":"slider-thumb",className:"block size-4 shrink-0 rounded-full border border-primary bg-white shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:outline-hidden focus-visible:ring-4 disabled:pointer-events-none disabled:opacity-50"},d))]})}var ph=$e({"src/components/graph-ui/Slider.tsx"(){Nt()}});function fh(e){const r=e==null?void 0:e.trim().toLowerCase();return!r||r==="extxyz"?"xyz":r}function gh(e){var s,o;const r=e.replace(/\r\n/g,`
|
|
4
|
+
`],format:r==="extxyz"?"xyz":r,name:e.name,uuid:e.path}:null}function Wc(e){const r=br(e);return r==="tsx"||r==="jsx"?"tsx":r==="yml"?"yaml":r||"text"}function Vc(e,r){let n=e,a="";for(const s of r){a=a?`${a}/${s}`:s;let o=n.children.find(l=>l.kind==="directory"&&l.name===s);o||(o={id:`dir:${a}`,name:s,path:a,kind:"directory",children:[]},n.children.push(o)),n=o}return n}function Kc(e,r,n){const a=r.split("/").filter(Boolean),s=a.pop()??n.name;Vc(e,a).children.push({...n,name:n.name||s,path:r})}function qc(e,r){return e.kind==="directory"&&r.kind!=="directory"?-1:e.kind!=="directory"&&r.kind==="directory"?1:e.name.localeCompare(r.name)}function jo(e){e.children.sort(qc);for(const r of e.children)jo(r);return e}function Aa(e,r,n,a){var u;const s={id:"root",name:e.workspace.label??"Workspace",path:"",kind:"directory",children:[]},o={id:"artifacts",name:"artifacts",path:"artifacts",kind:"directory",children:[]};for(const m of r){const f=m.title||m.id,p=Fc(f)||m.id;o.children.push({id:`artifact:${m.id}`,name:`${p}.artifact`,path:`artifacts/${p}.artifact`,kind:"artifact",artifact:m,preview:m.summaryText??m.type,detail:JSON.stringify(m.payload,null,2),children:[]})}const l={id:"thread-events",name:"thread-events",path:"thread-events",kind:"directory",children:[]},i={id:"live",name:"live",path:"live",kind:"directory",children:[]};let d=0;const h=(m,f,p=!1)=>{d+=1;const g=f.kind.replace(/([A-Z])/g,"-$1").toLowerCase(),b=`${p?"live":`thread-events/${m}`}/${String(d).padStart(3,"0")}-${g}.json`,v="text"in f&&typeof f.text=="string"?f.text.slice(0,160):f.kind,x=f.kind==="artifact"&&f.artifact?f.artifact:null,y=x&&p?{id:`live-artifact:${x.id}`,name:x.title||x.id,path:b,kind:"live-artifact",artifact:x,item:f,preview:x.summaryText??x.type,detail:JSON.stringify(x.payload,null,2),children:[]}:{id:`event:${f.id}`,name:Hc(b),path:b,kind:"event",item:f,preview:v,detail:JSON.stringify(f,null,2),children:[]};if(p){i.children.push(y);return}Kc(l,b.replace(/^thread-events\//,""),y)};for(const m of e.turns)for(const f of m.items)(f.kind==="commandExecution"||f.kind==="webSearch"||f.kind==="fileRead"||f.kind==="fileChange"||f.kind==="agentToolCall"||f.kind==="skillToolCall"||f.kind==="toolCall"||f.kind==="hook"||f.kind==="plan"||f.kind==="reasoning")&&h(m.id,f);for(const m of((u=e.liveItems)==null?void 0:u.items)??[])h(e.thread.activeTurnId??"live",m,!0);return s.children.push(o,l,i),jo(s)}function Xc(e){const r=new Map,n=a=>{r.set(a.id,a);for(const s of a.children)n(s)};return n(e),r}function No(e){if(e.kind==="artifact"||e.kind==="live-artifact"||e.kind==="event"||e.kind==="file")return e;for(const r of e.children){const n=No(r);if(n)return n}return null}function Ma(e){const r=e.split("/").filter(Boolean),n=[];for(let a=1;a<=r.length;a+=1)n.push(r.slice(0,a).join("/"));return n}var Zn,Co,So,Jn=$e({"src/components/graph-workspace/workspaceTree.ts"(){Zn=new Set(["xyz","extxyz","cif","pdb"]),Co=new Set(["png","jpg","jpeg","gif","webp","svg"]),So=new Set(["pdf"])}});function Kt({label:e,children:r}){return t.jsxs("section",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:e}),t.jsx("div",{className:"mt-2 text-sm text-[var(--theme-fg)]",children:r})]})}var To=$e({"src/components/graph-workspace/GraphWorkspaceCards.tsx"(){}});function Yc({className:e,decorative:r=!0,orientation:n="horizontal",...a}){return t.jsx(rd,{"data-slot":"separator",decorative:r,orientation:n,className:et("shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",e),...a})}var Zc=$e({"src/components/graph-ui/Separator.tsx"(){Nt()}});function Jc({className:e,orientation:r,...n}){return t.jsx("div",{role:"group","data-slot":"button-group","data-orientation":r,className:et(Eo({orientation:r}),e),...n})}function Qc({className:e,orientation:r="vertical",...n}){return t.jsx(Yc,{"data-slot":"button-group-separator",orientation:r,className:et("relative !m-0 self-stretch bg-input data-[orientation=vertical]:h-auto",e),...n})}var Eo,Lo=$e({"src/components/graph-ui/ButtonGroup.tsx"(){Zc(),Nt(),Eo=mr("flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}})}});function eh({delayDuration:e=0,...r}){return t.jsx(nd,{"data-slot":"tooltip-provider",delayDuration:e,...r})}function th({...e}){return t.jsx(eh,{children:t.jsx(Zi,{"data-slot":"tooltip",...e})})}function rh({...e}){return t.jsx(Ji,{"data-slot":"tooltip-trigger",...e})}function nh({children:e,className:r,sideOffset:n=0,...a}){return t.jsx(Qi,{children:t.jsxs(ed,{"data-slot":"tooltip-content",sideOffset:n,className:et("z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md bg-foreground px-3 py-1.5 text-balance text-xs text-background animate-in fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",r),...a,children:[e,t.jsx(td,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}var ah=$e({"src/components/graph-ui/Tooltip.tsx"(){Nt()}});function sh(e){return(e==null?void 0:e.trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""))||"molecule"}function $a(e,r){const n=new Blob([e],{type:"text/plain"}),a=URL.createObjectURL(n),s=document.createElement("a");s.href=a,s.download=r,s.click(),URL.revokeObjectURL(a)}function We({children:e,disabled:r,label:n,onClick:a}){return t.jsxs(th,{children:[t.jsx(rh,{asChild:!0,children:t.jsx(ur,{type:"button",variant:"outline",size:"icon",className:"thread-graph-molecule-button size-8",disabled:r,onClick:a,title:n,"aria-label":n,children:e})}),t.jsx(nh,{children:t.jsx("p",{children:n})})]})}function In({children:e,className:r=""}){return t.jsx(Jc,{className:`thread-graph-molecule-button-group ${r}`,children:e})}var Po=$e({"src/components/graph-workspace/GraphMoleculeViewerControls.tsx"(){Or(),Lo(),ah()}});function oh({cameraInfo:e,onClearSelection:r,onClearStaged:n,onSendSelection:a,onSendStaged:s,onStageSelection:o,onToggleUnitCell:l,selectedAtomLabels:i,selectedSerials:d,stagedAtoms:h,stagedMolecules:u,unitCellAvailable:m,unitCellVisible:f}){const p=d.length>0,g=h>0;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex w-full justify-between gap-2 overflow-x-auto",children:[t.jsxs(In,{children:[t.jsx(We,{label:"Distance",children:t.jsx(G.AlignVerticalDistributeCenter,{className:"size-4"})}),t.jsx(We,{label:"Connectivity",children:t.jsx(G.Share2,{className:"size-4"})}),t.jsx(We,{label:"Angle",children:t.jsx(G.Waypoints,{className:"size-4"})}),t.jsx(We,{label:"Dihedral",children:t.jsx(G.Spline,{className:"size-4"})}),t.jsx(We,{label:"Add dummy atoms",children:t.jsx(G.Bubbles,{className:"size-4"})}),t.jsx(We,{label:"Delete atoms",children:t.jsx(G.CircleX,{className:"size-4"})}),t.jsx(We,{label:"Rotate",children:t.jsx(G.Rotate3d,{className:"size-4"})})]}),t.jsxs(In,{children:[t.jsx(We,{label:f?"Hide unit cell":"Show unit cell",disabled:!m,onClick:l,children:t.jsx(G.Boxes,{className:"size-4"})}),t.jsx(We,{label:"Clear selection",disabled:!p,onClick:r,children:t.jsx(G.Trash2,{className:"size-4"})}),t.jsx(We,{label:"Send selection",disabled:!p,onClick:a,children:t.jsx(G.Send,{className:"size-4"})}),t.jsx(We,{label:"Stage current selection",disabled:!p,onClick:o,children:t.jsx(G.Box,{className:"size-4"})}),t.jsx(We,{label:"Clear staged selections",disabled:!g,onClick:n,children:t.jsx(G.Eraser,{className:"size-4"})}),t.jsx(We,{label:"Send staged selections",disabled:!g,onClick:s,children:t.jsx(G.ArrowUpRight,{className:"size-4"})})]})]}),e?t.jsxs("div",{className:"thread-graph-molecule-camera",children:[t.jsxs("div",{children:[t.jsx("strong",{children:"XYZ: "}),"x=",e.position.x.toFixed(1)," y=",e.position.y.toFixed(1)," z=",e.position.z.toFixed(1),t.jsx("br",{}),t.jsx("strong",{children:"Quat: "}),"qx=",e.position.qx.toFixed(2)," qy=",e.position.qy.toFixed(2)," qz=",e.position.qz.toFixed(2)," qw=",e.position.qw.toFixed(2)]}),t.jsx("div",{className:"thread-graph-molecule-camera-divider"}),t.jsxs("div",{className:"flex flex-col gap-1 text-[10px]",children:[t.jsxs("div",{children:["Selected atoms:"," ",d.length>0?d.map(b=>`${i[b]??"Atom"}(${b})`).join(", "):"None"]}),t.jsxs("div",{children:["Staged: ",u," molecule(s), ",h," atom(s)"]})]})]}):null]})}var lh=$e({"src/components/graph-workspace/GraphMoleculeViewerLowerButtonGroup.tsx"(){Po()}});function ih({currentIndex:e,exportContent:r,moleculeId:n,onScreenshot:a,viewerRef:s,xyzContent:o,xyzFormat:l}){const i=sh(n);async function d(){o&&await navigator.clipboard.writeText(o)}function h(){o&&$a(o,`${i}_step_${e+1}.${l||"xyz"}`)}function u(){r&&$a(r,`${i}_trajectory.${l||"xyz"}`)}function m(){s.current&&(s.current.zoom(1.2),s.current.render())}function f(){s.current&&(s.current.zoom(.8),s.current.render())}function p(){s.current&&(s.current.zoomTo(),s.current.setCameraParameters({}),s.current.render())}return t.jsxs(In,{className:"ml-auto justify-end",children:[t.jsx(We,{label:"Copy current structure",onClick:()=>void d(),disabled:!o,children:t.jsx(G.Copy,{className:"size-3.5"})}),t.jsx(We,{label:"Download current structure",onClick:h,disabled:!o,children:t.jsx(G.Download,{className:"size-3.5"})}),t.jsx(We,{label:"Download full trajectory",onClick:u,disabled:!r,children:t.jsx(G.Box,{className:"size-3.5"})}),t.jsx(We,{label:"Copy screenshot",onClick:a,disabled:!s.current||!o,children:t.jsx(G.Camera,{className:"size-3.5"})}),t.jsx(Qc,{className:"thread-graph-molecule-button-divider"}),t.jsx(We,{label:"Zoom in",onClick:m,disabled:!s.current||!o,children:t.jsx(G.ZoomIn,{className:"size-3.5"})}),t.jsx(We,{label:"Zoom out",onClick:f,disabled:!s.current||!o,children:t.jsx(G.ZoomOut,{className:"size-3.5"})}),t.jsx(We,{label:"Reset camera",onClick:p,disabled:!s.current||!o,children:t.jsx(G.RotateCcw,{className:"size-3.5"})})]})}var dh=$e({"src/components/graph-workspace/GraphMoleculeViewerUpperButtonGroup.tsx"(){Lo(),Po()}});async function ch(){if(typeof window>"u")throw new Error("3Dmol is only available in a browser environment.");return window["3Dmol"]?window["3Dmol"]:(Tr||(Tr=new Promise((e,r)=>{const n=document.querySelector('script[data-remote-codex-3dmol="true"]'),a=()=>{if(window["3Dmol"]){e(window["3Dmol"]);return}r(new Error("3Dmol loaded without exposing the expected global."))};if(n){n.addEventListener("load",a,{once:!0}),n.addEventListener("error",()=>r(new Error("Unable to load 3Dmol viewer runtime.")),{once:!0});return}const s=document.createElement("script");s.src="/vendor/3Dmol-min.js",s.async=!0,s.dataset.remoteCodex3dmol="true",s.addEventListener("load",a,{once:!0}),s.addEventListener("error",()=>r(new Error("Unable to load 3Dmol viewer runtime.")),{once:!0}),document.head.appendChild(s)})),Tr)}var Tr,hh=$e({"src/components/graph-workspace/load3Dmol.ts"(){Tr=null}});function uh({className:e,defaultValue:r,max:n=100,min:a=0,value:s,...o}){const l=c.useMemo(()=>Array.isArray(s)?s:Array.isArray(r)?r:[a,n],[r,n,a,s]);return t.jsxs(Ki,{"data-slot":"slider",...r!==void 0?{defaultValue:r}:{},...s!==void 0?{value:s}:{},min:a,max:n,className:et("relative flex w-full touch-none select-none items-center data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",e),...o,children:[t.jsx(qi,{"data-slot":"slider-track",className:"relative grow overflow-hidden rounded-full bg-muted data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5",children:t.jsx(Xi,{"data-slot":"slider-range",className:"absolute bg-primary data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"})}),Array.from({length:l.length},(i,d)=>t.jsx(Yi,{"data-slot":"slider-thumb",className:"block size-4 shrink-0 rounded-full border border-primary bg-white shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:outline-hidden focus-visible:ring-4 disabled:pointer-events-none disabled:opacity-50"},d))]})}var mh=$e({"src/components/graph-ui/Slider.tsx"(){Nt()}});function ph(e){const r=e==null?void 0:e.trim().toLowerCase();return!r||r==="extxyz"?"xyz":r}function fh(e){var s,o;const r=e.replace(/\r\n/g,`
|
|
5
5
|
`).replace(/\r/g,`
|
|
6
6
|
`).split(`
|
|
7
7
|
`),n=[];let a=0;for(;a<r.length;){for(;a<r.length&&((s=r[a])==null?void 0:s.trim())==="";)a+=1;if(a>=r.length)break;const l=Number.parseInt(((o=r[a])==null?void 0:o.trim())??"",10);if(!Number.isFinite(l)||l<0)return[e];const i=l+2;if(a+i>r.length)return[e];n.push(`${r.slice(a,a+i).join(`
|
|
8
8
|
`)}
|
|
9
|
-
`),a+=i}return n.length>0?n:[e]}function
|
|
10
|
-
`).join("")}function
|
|
11
|
-
`).slice(2).map(
|
|
12
|
-
`).length<=Ro}function yh(e){return e&&(e.node.path||e.node.name)||null}function jh(e){if(!e)return null;switch(e.kind){case"live-artifact":return{kind:"live-molecule",node:e};case"file":return{kind:"workspace-file",node:e};case"artifact":return{kind:"artifact",node:e};case"event":return{kind:"event",node:e};case"meta":return{kind:"meta",node:e};case"directory":return null}}function Nh({error:e,imageUrl:r,loadingMore:n,onSaveFile:a,onLoadMore:s,onCollapse:o,pdfUrl:l,previewFile:i,previewLoading:d,plugins:h,selectedTarget:u}){const[m,f]=c.useState(!1),[p,g]=c.useState(""),[b,v]=c.useState(null),[x,y]=c.useState(!1),k=(u==null?void 0:u.node)??null,j=k!=null&&k.artifact?h.renderArtifact({artifact:k.artifact,expanded:!0,onToggleExpanded:()=>{}}):null,w=Wc(i??null),N=(i==null?void 0:i.language)||Vc((i==null?void 0:i.path)??""),S=i?vr(i.path):"",L=yh(u),T=i!==null&&Jn.has(S),q=!!(i&&a)&&!T&&wh(i),A=(u==null?void 0:u.kind)==="live-molecule",D=!!(k!=null&&k.artifact&&j),J=!!w||D;c.useEffect(()=>{f(!1),g((i==null?void 0:i.content)??""),v(null)},[i==null?void 0:i.path,i==null?void 0:i.content]);async function W(){if(!(!i||!a)){y(!0),v(null);try{await a({path:i.path,content:p}),f(!1)}catch(O){v(O instanceof Error?O.message:"Failed to save file.")}finally{y(!1)}}}return t.jsxs("section",{className:"thread-graph-viewer flex h-full min-h-0 flex-col overflow-hidden rounded-[12px]","data-preview-target-kind":(u==null?void 0:u.kind)??"none",children:[t.jsxs("div",{className:"thread-graph-viewer-header flex h-12 shrink-0 items-center justify-between gap-3 border-b px-3 sm:h-[60px] sm:px-5",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[t.jsx("h2",{className:"text-base font-semibold text-slate-900 sm:text-[18px] dark:text-slate-100",children:"Viewer"}),L?t.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-slate-500 dark:text-slate-400",children:L}):null]}),o?t.jsx("button",{type:"button",onClick:o,"data-testid":"collapse-viewer",className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-[#222733] dark:hover:text-slate-100",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(G.ChevronsRight,{className:"h-4 w-4"})}):null]}),t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[e?t.jsx("div",{className:"border-b border-rose-200 bg-rose-50 px-5 py-3 text-sm text-rose-700 dark:border-rose-400/25 dark:bg-rose-400/10 dark:text-rose-200",children:e}):null,u?u.kind==="workspace-file"&&d?t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center px-5 text-center text-sm text-slate-400 dark:text-slate-500",children:"Loading file preview..."}):u.kind==="workspace-file"&&w?t.jsx("div",{className:"thread-graph-molecule-preview min-h-0 flex-1 overflow-hidden",children:t.jsx(vh,{source:w,moleculeId:w.uuid??u.node.path,title:"PyMOL-style (PDB/CIF)"})}):u.kind==="workspace-file"&&r?t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-auto p-5",children:t.jsx("img",{src:r,alt:u.node.path||u.node.name,className:"max-h-full max-w-full object-contain"})}):u.kind==="workspace-file"&&l?t.jsx("div",{className:"thread-graph-file-preview-frame min-h-0 flex-1 overflow-hidden",children:t.jsx("iframe",{src:l,title:`PDF preview: ${u.node.path||u.node.name}`,className:"h-full w-full border-0"})}):u.kind==="workspace-file"&&i?t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs("div",{className:"thread-graph-file-preview-header flex min-h-12 items-center justify-between gap-3 border-b px-4 py-2",children:[t.jsxs("div",{className:"min-w-0 text-xs uppercase tracking-[0.12em]",children:[T?"molecule":N||S||"text"," |"," ",i.size.toLocaleString()," bytes",i.truncated?t.jsxs("span",{className:"ml-2 text-amber-500",children:["showing ",i.nextOffset.toLocaleString()," bytes"]}):null]}),q?t.jsx("div",{className:"flex shrink-0 items-center gap-1",children:m?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>{g(i.content),f(!1),v(null)},disabled:x,className:"thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition disabled:cursor-not-allowed disabled:opacity-50",title:"Cancel edits","aria-label":"Cancel edits",children:t.jsx(G.X,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:()=>void W(),disabled:x||p===i.content,className:"thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition disabled:cursor-not-allowed disabled:opacity-50",title:"Save file","aria-label":"Save file",children:t.jsx(G.Save,{className:"h-4 w-4"})})]}):t.jsx("button",{type:"button",onClick:()=>{g(i.content),f(!0),v(null)},className:"thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition",title:"Edit file","aria-label":"Edit file",children:t.jsx(G.Pencil,{className:"h-4 w-4"})})}):null]}),b?t.jsx("div",{className:"border-b border-rose-200 bg-rose-50 px-4 py-2 text-sm text-rose-700 dark:border-rose-400/25 dark:bg-rose-400/10 dark:text-rose-200",children:b}):null,m?t.jsx("textarea",{value:p,onChange:O=>g(O.currentTarget.value),spellCheck:!1,"aria-label":"Workspace file editor",className:"thread-graph-file-editor min-h-0 flex-1 resize-none border-0 bg-transparent p-4 font-mono text-[12px] leading-5 text-slate-900 outline-none dark:text-slate-100"}):t.jsx(Lr,{content:i.content}),i.truncated&&s?t.jsx("div",{className:"thread-graph-file-preview-footer flex justify-center border-t px-4 py-3",children:t.jsx("button",{type:"button",onClick:s,disabled:n,title:"Load more workspace preview","aria-label":"Load more workspace preview",className:"thread-graph-load-more-button rounded-md px-4 py-1.5 text-xs disabled:opacity-50",children:n?"Loading...":`Load more (${(i.size-i.nextOffset).toLocaleString()} bytes remaining)`})}):null]}):(u.kind==="live-molecule"||u.kind==="artifact")&&u.node.artifact?t.jsx("div",{className:J||A?"min-h-0 flex-1 overflow-hidden":"min-h-0 flex-1 overflow-auto p-3",children:j}):u.kind==="meta"?t.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-3",children:t.jsx("div",{className:"grid gap-3",children:t.jsx(Kt,{label:"Workspace Data",children:t.jsx(Lr,{content:u.node.detail??""})})})}):t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsx("div",{className:"thread-graph-file-preview-header border-b px-4 py-3 text-xs uppercase tracking-[0.12em]",children:u.node.kind}),t.jsx(Lr,{content:u.node.detail??u.node.preview??u.node.name})]}):t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center px-5 text-center text-sm text-slate-400 dark:text-slate-500",children:"Pick a live molecule, workspace file, artifact, or thread event to preview it."})]})]})}var Io,Ro,Lr,Ch=$e({"src/components/graph-workspace/GraphWorkspacePreviewPane.tsx"(){Qn(),Eo(),kh(),Io=50*1024,Ro=1e3,Lr=c.memo(function({content:r}){return t.jsx("div",{className:"thread-graph-code-preview min-h-0 flex-1 overflow-auto",children:t.jsx("pre",{className:"thread-graph-plain-code-preview",children:t.jsx("code",{children:r})})})})}});function Sh({files:e,onCancel:r,onConfirm:n}){return t.jsx("div",{className:"thread-graph-dialog-backdrop fixed inset-0 z-50 flex items-center justify-center bg-black/40 px-4",children:t.jsxs("div",{className:"thread-graph-dialog w-full max-w-sm rounded-xl border bg-[var(--theme-panel)] p-6 shadow-xl",children:[t.jsx("h3",{className:"text-base font-semibold text-[var(--theme-fg)]",children:"Empty garbage?"}),t.jsxs("p",{className:"mt-1 text-sm leading-5 text-[var(--theme-fg-muted)]",children:["Permanently delete all files in the"," ",t.jsx("code",{className:"rounded bg-[var(--theme-muted)] px-1 text-xs text-[var(--theme-fg-soft)]",children:"garbage/"})," ","folder."]}),e.length===0?t.jsx("p",{className:"mt-3 text-sm text-[var(--theme-fg-muted)]",children:"Garbage is empty."}):t.jsx("ul",{className:"mt-3 max-h-40 overflow-y-auto rounded-md border border-[var(--theme-border)] bg-[var(--theme-surface)] p-2 text-xs text-[var(--theme-fg-soft)]",children:e.map(a=>t.jsx("li",{className:"truncate py-0.5",title:a,children:a},a))}),t.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:r,className:"thread-secondary-action rounded-md px-3 py-1.5 text-sm",children:"Cancel"}),e.length>0?t.jsx("button",{type:"button",onClick:n,className:"ui-action-danger rounded-md px-3 py-1.5 text-sm font-medium",children:"Yes, empty garbage"}):null]})]})})}var Th=$e({"src/components/graph-workspace/GraphEmptyGarbageDialog.tsx"(){}});function Mo(e){return`${Ao}${e.workspaceId??"workspace"}:${e.threadId}`}function Eh(e){if(typeof window>"u")return[];try{const r=window.localStorage.getItem(Mo(e));if(!r)return[];const n=JSON.parse(r);return Array.isArray(n)?n.filter(a=>typeof a=="string"):[]}catch{return[]}}function Fa(e,r){if(!(typeof window>"u"))try{window.localStorage.setItem(Mo(e),JSON.stringify([...r]))}catch{}}function Rn(e,r){if(!r||e.path!==r.path||e.kind!=="directory")return e;const n=new Map(r.children.map(o=>[o.path,o])),a=e.children.map(o=>Rn(o,n.get(o.path)??null)),s=e.childrenLoaded&&e.children.length>0;return{...e,children:s||!r.childrenLoaded?a:r.children,childrenLoaded:e.childrenLoaded||r.childrenLoaded,truncated:e.truncated??r.truncated}}function Ha(e,r){if(e.kind==="directory")return r?t.jsx(G.FolderOpen,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"}):t.jsx(G.Folder,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"});const n=vr(e.name);return n==="zip"?t.jsx(G.FileArchive,{className:"h-4 w-4 text-amber-600"}):e.kind==="file"&&["png","jpg","jpeg","gif","webp","svg"].includes(n)?t.jsx(G.FileImage,{className:"h-4 w-4 text-sky-500"}):e.kind==="artifact"||["xyz","extxyz","cif","pdf","json","ts","tsx","js","jsx","md","yaml","yml","py"].includes(n)?t.jsx(G.FileCode2,{className:"h-4 w-4 text-emerald-600"}):t.jsx(G.File,{className:"h-4 w-4 text-slate-400 dark:text-slate-500"})}function _o({depth:e,expandedPaths:r,loadingPaths:n,node:a,onDownload:s,onPreview:o,onSelect:l,onToggle:i,selectedNodeId:d}){const h=a.kind==="directory",u=h&&(a.path===""||r.has(a.path)),m=h&&n.has(a.path),f=d===a.id,p=`${e*.75+.5}rem`;return h?t.jsxs("div",{children:[t.jsxs("div",{className:"thread-graph-tree-row group flex items-center text-sm text-slate-600 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100",children:[t.jsxs("button",{type:"button",onClick:()=>i(a.path),className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 px-2 py-2 text-left sm:min-h-0 sm:py-1.5",style:{paddingLeft:p},children:[u?t.jsx(G.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}):t.jsx(G.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}),Ha(a,u),t.jsx("span",{className:"truncate",children:a.name}),m?t.jsx("span",{className:"ml-auto shrink-0 text-xs text-slate-400 dark:text-slate-500",children:"Loading"}):null]}),s?t.jsx("button",{type:"button",onClick:()=>s(a),className:"thread-graph-tree-action mr-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-slate-400 transition hover:bg-white hover:text-slate-900 sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100",title:a.path?`Download ${a.name}`:"Download workspace","aria-label":a.path?`Download ${a.name}`:"Download workspace",children:t.jsx(G.Download,{className:"h-3.5 w-3.5"})}):null]}),u?t.jsxs("div",{children:[a.children.map(g=>t.jsx(_o,{depth:e+1,expandedPaths:r,loadingPaths:n,node:g,...s?{onDownload:s}:{},...o?{onPreview:o}:{},onSelect:l,onToggle:i,selectedNodeId:d},g.id)),a.truncated?t.jsx("div",{className:"px-2 py-1 text-xs text-slate-400 dark:text-slate-500",style:{paddingLeft:`${(e+1)*.75+.5}rem`},children:"More items not shown"}):null]}):null]}):t.jsxs("div",{className:`thread-graph-tree-row group flex items-center text-sm transition ${f?"is-selected":"text-slate-600 hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100"}`,children:[t.jsxs("button",{type:"button",onClick:()=>l(a.id),className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 px-2 py-2 text-left sm:min-h-0 sm:py-1.5",style:{paddingLeft:`${e*.75+2.2}rem`},children:[Ha(a,!1),t.jsx("span",{className:"truncate",children:a.name})]}),a.kind==="file"&&(o||s)?t.jsxs("div",{className:"mr-1 flex shrink-0 items-center gap-0.5",children:[o?t.jsx("button",{type:"button",onClick:()=>o(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${f?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Preview ${a.name}`,"aria-label":`Preview ${a.name}`,children:t.jsx(G.Eye,{className:"h-3.5 w-3.5"})}):null,s?t.jsx("button",{type:"button",onClick:()=>s(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${f?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Download ${a.name}`,"aria-label":`Download ${a.name}`,children:t.jsx(G.Download,{className:"h-3.5 w-3.5"})}):null]}):null]})}function Lh({liveNodes:e,onSelect:r,selectedNodeId:n}){return e.length===0?null:t.jsxs("div",{className:"border-b border-slate-200 py-2 dark:border-[#2a2f3a]",children:[t.jsx("div",{className:"thread-graph-workspace-label px-3 pb-1 text-[11px] font-semibold tracking-normal text-slate-500 dark:text-slate-400",children:"Live"}),t.jsx("div",{className:"space-y-0.5",children:e.map(a=>{var o;const s=n===a.id;return t.jsxs("button",{type:"button","data-testid":"live-molecule-item","data-molecule-id":((o=a.artifact)==null?void 0:o.id)??a.id,onClick:()=>r(a.id),className:`thread-graph-tree-row flex min-h-9 w-full items-center gap-2 px-3 py-2 text-left text-sm transition sm:min-h-0 sm:py-1.5 ${s?"is-selected":"text-slate-600 hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100"}`,children:[t.jsx(G.FileCode2,{className:`h-4 w-4 shrink-0 ${s?"text-current":"text-emerald-600 dark:text-emerald-300"}`}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:a.name})]},a.id)})})]})}function Ph({canEmptyGarbage:e,canUpload:r,onCollapse:n,expandedPaths:a,loadingPaths:s,loading:o,onDownload:l,onEmptyGarbage:i,onPreview:d,onRefresh:h,onSelect:u,onToggle:m,onUpload:f,explorerScrollTopRef:p,explorerScrollerRef:g,selectedNodeId:b,tree:v,liveNodes:x}){const y=c.useMemo(()=>({...v,children:v.children.filter(k=>k.path!=="live")}),[v]);return c.useLayoutEffect(()=>{const k=g.current;k&&(k.scrollTop=p.current)},[g,p]),t.jsxs("aside",{className:`${$o} flex flex-col`,children:[t.jsxs("div",{className:Do,children:[t.jsx("div",{className:"min-w-0",children:t.jsx("h2",{className:Bo,children:"Explorer"})}),t.jsxs("div",{className:"flex items-center gap-1",children:[n?t.jsxs("button",{type:"button","data-testid":"collapse-explorer",onClick:n,className:Go,title:"Collapse Explorer","aria-label":"Collapse Explorer",children:[t.jsx(G.ChevronsLeft,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Collapse Explorer"})]}):null,t.jsx("button",{type:"button",onClick:f,disabled:!r,className:zr,title:r?"Upload file":"Upload is unavailable for this workspace","aria-label":"Upload file",children:t.jsx(G.Upload,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:h,className:zr,title:"Refresh workspace","aria-label":"Refresh workspace",children:t.jsx(G.RefreshCw,{className:`h-4 w-4 ${o?"animate-spin":""}`})}),i?t.jsx("button",{type:"button",onClick:i,disabled:!e,className:zr,title:e?"Empty garbage":"Garbage controls are unavailable","aria-label":"Empty garbage",children:t.jsx(G.Trash2,{className:"h-4 w-4"})}):null]})]}),t.jsxs("div",{ref:g,className:"thread-graph-workspace-tree-scroll min-h-0 flex-1 overflow-y-auto py-2",onScroll:k=>{p.current=k.currentTarget.scrollTop},children:[t.jsx(Lh,{liveNodes:x??[],onSelect:u,selectedNodeId:b}),t.jsx("div",{className:Fo,children:"Workspace"}),t.jsx(_o,{depth:0,expandedPaths:a,loadingPaths:s,node:y,...l?{onDownload:l}:{},...d?{onPreview:d}:{},onSelect:u,onToggle:m,selectedNodeId:b}),y.children.length===0?t.jsx("p",{className:Ho,children:"This workspace is empty. Agent tool runs execute inside the thread workspace, so files should appear here as the session works."}):null]})]})}function zh({activeView:e,detail:r,artifacts:n,plugins:a,status:s,focusPathRequest:o,workspaceAdapter:l}){const[i,d]=c.useState(null),h=c.useMemo(()=>l&&i?null:Aa(r,n),[e,i,n,r,s,l]),u=i??h??Aa(r,n),m=c.useMemo(()=>Yc(u),[u]),f=c.useMemo(()=>{var R;return((R=u.children.find($=>$.path==="live"))==null?void 0:R.children)??[]},[u]),p=Co(u),[g,b]=c.useState(()=>(p==null?void 0:p.id)??null),[v,x]=c.useState(()=>new Set(["","artifacts","thread-events","live",...$a((p==null?void 0:p.path)??"")])),[y,k]=c.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 639px)").matches?"viewer":null),[j,w]=c.useState(null),[N,S]=c.useState(!1),[L,T]=c.useState(()=>new Set),[q,A]=c.useState(!1),[D,J]=c.useState(!1),[W,O]=c.useState(!1),[ee,he]=c.useState([]),[E,re]=c.useState(null),[_,V]=c.useState(null),[U,z]=c.useState(null),[X,F]=c.useState(!1),I=c.useRef(null),P=c.useRef(null),Z=c.useRef(0),K=c.useRef(null),de=!!l,M=(g?m.get(g):null)??p??null,Y={threadId:r.thread.id,workspaceId:r.workspace.id??r.thread.workspaceId??null};c.useEffect(()=>{Z.current=0,K.current=null,x(new Set(["","artifacts","thread-events","live",...Eh(Y),...$a((p==null?void 0:p.path)??"")]))},[Y.threadId,Y.workspaceId]);function te(){var $;const R=(($=P.current)==null?void 0:$.scrollTop)??Z.current;Z.current=R,K.current=R}function ie(){const R=K.current??Z.current;if(!P.current)return;let Q=0;const me=()=>{const xe=P.current;xe&&(xe.scrollTop=Math.min(R,Math.max(0,xe.scrollHeight-xe.clientHeight)),Z.current=xe.scrollTop,Q+=1,Q<8?window.requestAnimationFrame(me):K.current=null)};window.requestAnimationFrame(me)}c.useLayoutEffect(()=>{y!=="explorer"&&ie()},[y,u]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const R=window.matchMedia("(max-width: 639px)"),$=()=>F(R.matches);return $(),typeof R.addEventListener=="function"?(R.addEventListener("change",$),()=>R.removeEventListener("change",$)):(R.addListener($),()=>R.removeListener($))},[]);async function ue(R){if(!l)return;const $=R??(M==null?void 0:M.path)??null;S(!0),w(null);try{const Q=Vt(await l.listTree({...Y,path:""}));let me=i?Rn(Q,i):Q;if(i){const Ie=[...v].filter(ge=>ge).sort((ge,Ae)=>ge.split("/").length-Ae.split("/").length);for(const ge of Ie){const Ae=Ln(i,ge);if((Ae==null?void 0:Ae.kind)!=="directory"||!Ae.childrenLoaded)continue;const at=Vt(await l.listTree({...Y,path:ge}));me=Pn(me,ge,Rn(at,Ae))}}d(me);const xe=yo(me);b(Ie=>{var Ae;const ge=$??(Ie?(Ae=m.get(Ie))==null?void 0:Ae.path:null);return ge&&zn(me,ge)?`workspace:${ge}`:(xe==null?void 0:xe.id)??Ie})}catch(Q){w(Q instanceof Error?Q.message:"Failed to load workspace"),d(null)}finally{S(!1)}}async function be(R){if(!(!l||!i)){T($=>{if($.has(R))return $;const Q=new Set($);return Q.add(R),Q}),w(null);try{const $=Vt(await l.listTree({...Y,path:R}));d(Q=>Q&&wo(Q,R,$.children,{truncated:$.truncated}))}catch($){w($ instanceof Error?$.message:"Failed to load directory")}finally{T($=>{if(!$.has(R))return $;const Q=new Set($);return Q.delete(R),Q})}}}async function Le(R){const $=jo(R);if(!$)return;const Q=Uc($);if(k(null),x(me=>{const xe=new Set(me);xe.add("");for(const Ie of Q)xe.add(Ie);return Fa(Y,xe),xe}),!l){zn(u,$)&&b(`workspace:${$}`);return}S(!0),w(null);try{let me=i??Vt(await l.listTree({...Y,path:""}));for(const xe of Q){const Ie=Ln(me,xe);if((Ie==null?void 0:Ie.kind)==="directory"&&Ie.childrenLoaded)continue;const ge=Vt(await l.listTree({...Y,path:xe}));me=Pn(me,xe,ge)}d(me),b(`workspace:${$}`)}catch(me){w(me instanceof Error?me.message:`Failed to open ${$}`)}finally{S(!1)}}c.useEffect(()=>{if(!(!l||!i))for(const R of m.values())R.path&&R.kind==="directory"&&v.has(R.path)&&R.hasChildren&&!R.childrenLoaded&&!L.has(R.path)&&be(R.path)},[i,v,m,l]),c.useEffect(()=>{d(null),T(new Set),re(null),V(null),z(null),w(null),ue()},[de,r.thread.id,r.workspace.id,r.thread.workspaceId]),c.useEffect(()=>{o&&Le(o.path)},[o==null?void 0:o.requestId]),c.useEffect(()=>{l!=null&&l.subscribeWorkspaceChanged},[l,Y.threadId,Y.workspaceId]),c.useEffect(()=>{const R=l&&(M==null?void 0:M.kind)==="file"?M.path:null;if(!R){re(null),V(null),z(null);return}const $=R;let Q=!1;async function me(){var xe;if(l){A(!0),w(null),re(null),V(null),z(null);try{const Ie=vr($),ge=(xe=l.getRawFileUrl)==null?void 0:xe.call(l,{...Y,path:$});if(ge&&So.has(Ie)){Q||V(ge);return}if(ge&&To.has(Ie)){Q||z(ge);return}const Ae=await l.readFile({...Y,path:$,limit:Pr});Q||re(Ae)}catch(Ie){Q||w(Ie instanceof Error?Ie.message:"Failed to read file")}finally{Q||A(!1)}}}return me(),()=>{Q=!0}},[l,M==null?void 0:M.id]);async function ae(){if(!(!l||!(E!=null&&E.truncated))){J(!0);try{const R=await l.readFile({...Y,path:E.path,offset:E.nextOffset,limit:Pr});re($=>$&&{...$,content:$.content+R.content,truncated:R.truncated,nextOffset:R.nextOffset,size:R.size})}finally{J(!1)}}}async function ve(R){if(!(l!=null&&l.writeFile))return;w(null),await l.writeFile({...Y,path:R.path,content:R.content}),await ue(R.path);const $=await l.readFile({...Y,path:R.path,limit:Pr});re($)}async function ke(R){if(!(!(l!=null&&l.uploadFile)||!R)){S(!0),w(null);try{const $=await l.uploadFile({...Y,path:R.name,file:R}),Q=$.kind==="archive"?$.paths[0]??null:$.file.path;await ue(Q)}catch($){w($ instanceof Error?$.message:"Failed to upload file")}finally{S(!1)}}}async function pe(R){var Q;const $=(Q=R.target.files)==null?void 0:Q[0];R.target.value="",$&&await ke($)}function ze(){if(!(l!=null&&l.uploadFile))return;const R=()=>{var $;return($=I.current)==null?void 0:$.click()};if(l.pickUploadFile){l.pickUploadFile({...Y,defaultPick:R,upload:ke});return}R()}function je(R){var $;($=l==null?void 0:l.downloadNode)==null||$.call(l,{...Y,path:R.path,kind:R.kind==="directory"?"directory":"file"})}function Me(R){R.kind==="file"&&(te(),b(R.id),k("explorer"))}async function Pe(){if(l!=null&&l.emptyGarbage){if(w(null),!l.listGarbage){he([]),O(!0);return}try{const R=await l.listGarbage(Y);he(R.map($=>`garbage/${$}`))}catch(R){he([]),w(R instanceof Error?R.message:"Failed to list garbage files")}finally{O(!0)}}}async function _e(){if(l!=null&&l.emptyGarbage){O(!1),w(null);try{await l.emptyGarbage(Y),await ue((M==null?void 0:M.path)??null)}catch(R){w(R instanceof Error?R.message:"Failed to empty garbage")}}}const Ce={...l!=null&&l.downloadNode?{onDownload:je}:{},...l!=null&&l.emptyGarbage?{onEmptyGarbage:Pe}:{},...l?{onRefresh:()=>void ue((M==null?void 0:M.path)??null)}:{},...l!=null&&l.uploadFile?{onUpload:ze}:{}};function Re(R){if(!R)return;const $=m.get(`workspace:${R}`),Q=($==null?void 0:$.kind)==="directory"&&$.hasChildren&&!$.childrenLoaded&&!L.has(R);x(me=>{const xe=new Set(me);return xe.has(R)?xe.delete(R):xe.add(R),Fa(Y,xe),xe}),!v.has(R)&&Q&&be(R)}const H=t.jsx(Ph,{canEmptyGarbage:!!(l!=null&&l.emptyGarbage),canUpload:!!(l!=null&&l.uploadFile),onCollapse:()=>{te(),k("explorer")},expandedPaths:v,loadingPaths:L,loading:N,explorerScrollTopRef:Z,explorerScrollerRef:P,...Ce,onPreview:Me,onSelect:R=>{b(R)},onToggle:Re,selectedNodeId:(M==null?void 0:M.id)??null,tree:u,liveNodes:f}),ce=t.jsx(Nh,{error:j,imageUrl:_,loadingMore:D,onLoadMore:ae,...l!=null&&l.writeFile?{onSaveFile:ve}:{},onCollapse:()=>{te(),k("viewer")},pdfUrl:U,previewFile:E,previewLoading:q,plugins:a,selectedTarget:jh(M)});return y==="explorer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:ce}):y==="viewer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:H}):t.jsxs("div",{"data-testid":"workspace-panel",className:"flex h-full min-h-0 w-full overflow-hidden bg-transparent p-2",children:[W?t.jsx(Sh,{files:ee,onCancel:()=>O(!1),onConfirm:()=>void _e()}):null,X?t.jsxs(Tn,{direction:"vertical",className:"thread-graph-workspace-mobile-stack",children:[t.jsx(Xt,{defaultSize:42,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-explorer h-full min-h-0 overflow-hidden",children:H})}),t.jsx(En,{className:"thread-graph-workspace-resize-handle h-2 bg-transparent after:h-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(Xt,{defaultSize:58,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-viewer h-full min-h-0 overflow-hidden",children:ce})})]}):t.jsxs(Tn,{direction:"horizontal",className:"thread-graph-workspace-resizable",children:[t.jsx(Xt,{defaultSize:33,minSize:20,children:t.jsx("div",{className:"thread-graph-workspace-explorer-pane h-full min-h-0 overflow-hidden",children:H})}),t.jsx(En,{className:"thread-graph-workspace-resize-handle w-2 bg-transparent after:w-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(Xt,{defaultSize:67,minSize:30,children:t.jsx("div",{className:"thread-graph-workspace-viewer-pane h-full min-h-0 overflow-hidden",children:ce})})]}),t.jsx("input",{ref:I,type:"file","aria-label":"Workspace upload file input","data-testid":"workspace-upload-file-input",className:"hidden",onChange:R=>void pe(R)})]})}var Pr,Ao,$o,Do,Bo,zr,Go,Fo,Ho,Ih=$e({"src/components/graph-workspace/GraphWorkspaceExplorer.tsx"(){Qn(),Ch(),Th(),ko(),Pr=24e3,Ao="remote-codex:graphchat:workspace:expanded:",$o="thread-graph-explorer h-full min-h-0 overflow-hidden rounded-[12px]",Do="thread-graph-explorer-header flex h-[60px] shrink-0 items-center justify-between border-b px-4",Bo="text-[18px] font-semibold text-slate-900 dark:text-slate-100",zr="thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition disabled:cursor-not-allowed disabled:opacity-50",Go="thread-graph-explorer-collapse-button flex h-8 w-8 items-center justify-center rounded-full text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-[#222733] dark:hover:text-slate-100",Fo="thread-graph-workspace-label px-3 pb-1 pt-2 text-[11px] font-semibold tracking-normal text-slate-500 dark:text-slate-400",Ho="thread-graph-workspace-empty mx-4 mt-3 rounded-lg border border-dashed border-slate-200 bg-slate-50 px-3 py-4 text-sm text-slate-500 dark:border-[#303642] dark:bg-[#1b1f29] dark:text-slate-400"}});function un({children:e}){return t.jsx("span",{className:"thread-guide-tag inline-flex items-center rounded px-1.5 py-0.5 font-mono text-[10px]",children:e})}function Ut({items:e}){return t.jsx("ul",{className:"space-y-1 text-[12px] text-[var(--theme-fg-muted)]",children:e.map((r,n)=>t.jsxs("li",{className:"flex gap-2",children:[t.jsx("span",{className:"mt-[6px] h-1 w-1 shrink-0 rounded-full bg-[var(--theme-border-contrast)]"}),t.jsx("span",{children:r})]},n))})}function Rh({children:e}){return t.jsx("span",{className:"thread-guide-icon flex h-5 w-5 shrink-0 items-center justify-center rounded-md",children:e})}function nr({value:e,title:r,icon:n,children:a}){return t.jsxs(fr,{value:e,className:"thread-guide-section border-b border-[var(--theme-border)] last:border-b-0",children:[t.jsx(gr,{className:"py-3 hover:no-underline [&[data-state=open]]:pb-2",children:t.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-[var(--theme-fg)]",children:[t.jsx(Rh,{children:n}),r]})}),t.jsx(xr,{className:"space-y-3 pb-3",children:a})]})}function Mh(){return t.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[t.jsxs("div",{className:"shrink-0 border-b border-[var(--theme-border)] px-4 py-3",children:[t.jsx("h2",{className:"text-xs font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"What can I do?"}),t.jsx("p",{className:"mt-0.5 text-[11px] text-[var(--theme-fg-muted)]",children:"Upload files, ask in plain language, get results."})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-3 pb-6",children:t.jsxs(pr,{type:"multiple",defaultValue:["start","workspace","remote-codex"],className:"space-y-0",children:[t.jsxs(nr,{value:"start",title:"Getting Started",icon:t.jsx(G.Zap,{className:"h-3 w-3"}),children:[t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"graphchat connects a language model to your files and a set of tools. Each Remote Codex thread has its own isolated workspace."}),t.jsx(Ut,{items:["Upload data files via the Workspace panel","Type a question or task in plain language","The agent calls tools, writes results to the workspace, and explains what it found","Agent-produced files appear in the workspace automatically when the host reports changes"]})]}),t.jsxs(nr,{value:"workspace",title:"Workspace Explorer",icon:t.jsx(G.FolderOpen,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(G.Upload,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Upload"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Upload files through the Workspace panel when the host exposes workspace upload support. Composer attachments stay available for prompt context."})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(G.Plus,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"New files and folders"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Remote Codex normally creates files through tools and shell commands. They appear in Explorer after workspace refreshes."})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(G.MoveRight,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Move and organize"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Use the agent or terminal to reorganize files. Explorer keeps the GraphChat file tree and preview flow."})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(G.Trash2,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-rose-400"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Garbage folder"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"If the host exposes garbage controls, Explorer can permanently empty unwanted workspace files."})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(G.RefreshCw,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Refresh"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Resync the file tree manually after shell commands, external changes, or agent tool runs."})]})]}),t.jsxs("div",{className:"rounded-lg border border-[var(--theme-border)] p-2.5",children:[t.jsx("p",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"Preview surfaces"}),t.jsx(Ut,{items:[t.jsxs(t.Fragment,{children:[t.jsx(un,{children:".xyz .extxyz .cif"})," use the 3D molecule plugin."]}),t.jsxs(t.Fragment,{children:[t.jsx(un,{children:".png .jpg .gif .svg .webp"})," use inline image preview."]}),t.jsxs(t.Fragment,{children:[t.jsx(un,{children:".py .json .ts .md .csv"})," use text/code preview."]}),"Large files load in chunks when the workspace adapter supports it."]})]})]}),t.jsxs(nr,{value:"viewer",title:"Viewer",icon:t.jsx(G.FileImage,{className:"h-3 w-3"}),children:[t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Viewer is the GraphChat-style artifact surface. It opens Remote Codex artifacts through the same frontend plugin renderers used in rich message bubbles, and previews workspace files from Explorer."}),t.jsx(Ut,{items:["Expand one artifact at a time for inspection","Fallback JSON preview is available for unknown artifact types","3D molecule artifacts remain interactive when the XYZ plugin is enabled"]})]}),t.jsxs(nr,{value:"usage",title:"Tool Usage & Chat",icon:t.jsx(G.BarChart2,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(G.BarChart2,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Usage tab"}),t.jsx(Ut,{items:["Bar chart of tool and command counts for this thread","Expandable call log: inspect every input and output","Recent live events appear with persisted history"]})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(G.MessageSquare,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Chat controls"}),t.jsx(Ut,{items:["New Chat creates a fresh Remote Codex thread with its own workspace","Interrupt, compact, goal controls, and model controls remain in the composer","Shell view stays available when a shell adapter is attached"]})]})]})]}),t.jsx(nr,{value:"remote-codex",title:"Remote Codex Extras",icon:t.jsx(G.Code2,{className:"h-3 w-3"}),children:t.jsx(Ut,{items:["Slash toolbox: skills, MCP, hooks, goals, forks, model controls, provider settings","Rich message bubbles: reasoning, commands, searches, file reads, file changes, plans, action requests, artifacts","Plugin surfaces: terminal, XYZ molecule viewer, inline code renderers, and imported plugin panels","Thread metadata stays in the left rail and Workspace tab instead of replacing chat"]})})]})})]})}var _h=$e({"src/components/graph-workspace/GraphGuidePanel.tsx"(){br()}});function Ah(e){if(e==null)return"—";if(typeof e=="string")return e.length>2e3?`${e.slice(0,2e3)}
|
|
13
|
-
...(truncated)`:e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Oa({label:e,value:r}){return t.jsxs("div",{children:[t.jsx("p",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:e}),t.jsx("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap break-words rounded bg-[var(--theme-surface-strong)] p-2 text-[11px] leading-relaxed text-[var(--theme-fg-soft)]",children:Ah(r)})]})}function $h({event:e}){return t.jsxs(fr,{value:e.id,className:"thread-tool-call mb-2 overflow-hidden rounded-lg border border-[var(--theme-border)] last:mb-0",children:[t.jsxs(gr,{className:"px-3 py-2 text-xs font-medium text-[var(--theme-fg)] hover:bg-[var(--theme-hover)] hover:no-underline [&[data-state=open]]:bg-[var(--theme-hover)]",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full bg-[var(--theme-accent-strong)]"}),t.jsx("span",{className:"truncate font-mono text-xs font-medium text-[var(--theme-fg)]",children:e.label}),e.status?t.jsx("span",{className:"shrink-0 rounded-full border border-[var(--theme-border)] px-1.5 py-0.5 text-[9px] uppercase tracking-[0.12em] text-[var(--theme-fg-muted)]",children:e.status}):null]}),t.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:e.turnId?t.jsx("span",{className:"max-w-20 truncate text-[10px] text-[var(--theme-fg-muted)]",children:e.turnId}):null})]}),t.jsx(xr,{className:"px-3 pb-3",children:t.jsxs("div",{className:"space-y-2 px-3 pb-3 pt-1",children:[t.jsx(Oa,{label:"Input",value:e.preview}),t.jsx(Oa,{label:"Output",value:e.detail})]})})]})}function Dh({formatToolKind:e,toolCounts:r,toolEvents:n,maxToolCount:a}){const[s,o]=c.useState(()=>{var i;return((i=n.at(-1))==null?void 0:i.id)??null}),l=c.useRef(null);return c.useEffect(()=>{o(i=>{var d;return i??((d=n.at(-1))==null?void 0:d.id)??null})},[n]),c.useEffect(()=>{var i;(i=l.current)==null||i.scrollIntoView({behavior:"smooth",block:"nearest"})},[n.length]),r.length?t.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[t.jsxs("div",{className:"shrink-0 border-b border-[var(--theme-border)] p-4",children:[t.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[t.jsx("h2",{className:"text-xs font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"Calls this session"}),t.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-[var(--theme-fg-muted)] opacity-60",disabled:!0,title:"Remote Codex streams tool history from thread events",children:[t.jsx(G.RefreshCw,{className:"h-3 w-3"}),"Reload"]})]}),t.jsx("div",{className:"space-y-2",children:r.map(([i,d])=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"w-40 shrink-0 truncate text-right font-mono text-[11px] text-[var(--theme-fg-muted)]",title:e(i),children:e(i)}),t.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[t.jsx("div",{className:"relative h-4 flex-1 overflow-hidden rounded-sm bg-[var(--theme-muted)]",children:t.jsx("div",{className:"h-full rounded-sm bg-[var(--theme-accent-strong)] transition-all duration-300",style:{width:`${d/a*100}%`}})}),t.jsx("span",{className:"w-5 shrink-0 text-right text-[11px] font-medium text-[var(--theme-fg-soft)]",children:d})]})]},i))})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:[t.jsx("h2",{className:"mb-3 text-xs font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"Call log"}),t.jsx(pr,{type:"single",collapsible:!0,value:s??"",onValueChange:i=>o(i||null),className:"space-y-0",children:n.slice(-50).map(i=>t.jsx($h,{event:i},i.id))}),t.jsx("div",{ref:l})]})]}):t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 text-sm text-[var(--theme-fg-muted)]",children:[t.jsx("span",{children:"No tool calls yet. Run the agent to see usage."}),t.jsxs("span",{className:"inline-flex items-center gap-1 rounded px-2 py-1 text-xs",children:[t.jsx(G.RefreshCw,{className:"h-3 w-3"}),"Reload from workspace"]})]})}var Bh=$e({"src/components/graph-workspace/GraphToolUsagePanel.tsx"(){br()}});function Ua(e,r){const n=Math.max(e.measured.width??1,1),a=Math.max(e.measured.height??1,1),s=e.internals.positionAbsolute,o=r.internals.positionAbsolute,l=Math.max(r.measured.width??1,1),i=Math.max(r.measured.height??1,1),d=n/2,h=a/2,u=s.x+d,m=s.y+h,f=o.x+l/2,p=o.y+i/2,g=(f-u)/(2*d)-(p-m)/(2*h),b=(f-u)/(2*d)+(p-m)/(2*h),v=1/(Math.abs(g)+Math.abs(b)),x=v*g,y=v*b,k=d*(x+y)+u,j=h*(-x+y)+m;return{x:k,y:j}}function Wa(e,r){const n={...e.internals.positionAbsolute,...e},a=Math.round(n.x),s=Math.round(n.y),o=Math.round(r.x),l=Math.round(r.y);return o<=a+1?Pt.Left:o>=a+(e.measured.width??1)-1?Pt.Right:l<=s+1?Pt.Top:l>=n.y+(e.measured.height??1)-1?Pt.Bottom:Pt.Top}function Oo(e,r){const n=Ua(e,r),a=Ua(r,e),s=Wa(e,n),o=Wa(r,a);return{sx:n.x,sy:n.y,tx:a.x,ty:a.y,sourcePos:s,targetPos:o}}function Gh(e,r=900,n=620){if(!e||!Array.isArray(e))return{nodes:[],edges:[]};const a=(d,h,u,m)=>{const f=new Map,p=d.length;d.forEach((g,b)=>{const v=g.id.split("").reduce((x,y)=>{const k=(x<<5)-x+y.charCodeAt(0);return k&k},0);f.set(g.id,{x:Math.abs(v)%u+b*100%u,y:Math.abs(v>>16)%m+b*150%m,vx:0,vy:0})});for(let g=0;g<200;g+=1){for(let b=0;b<p;b+=1)for(let v=b+1;v<p;v+=1){const x=d[b],y=d[v];if(!x||!y)continue;const k=f.get(x.id),j=f.get(y.id);if(!k||!j)continue;const w=k.x-j.x,N=k.y-j.y,S=Math.sqrt(w*w+N*N)||1,T=(200-S)*.5,q=w/S*T,A=N/S*T;k.vx+=q,k.vy+=A,j.vx-=q,j.vy-=A}h.forEach(b=>{const v=f.get(b.source),x=f.get(b.target);if(!v||!x)return;const y=x.x-v.x,k=x.y-v.y,j=Math.sqrt(y*y+k*k)||1,N=(j-120)*.3,S=y/j*N,L=k/j*N;v.vx+=S,v.vy+=L,x.vx-=S,x.vy-=L}),f.forEach(b=>{b.x+=b.vx*.1,b.y+=b.vy*.1,b.vx*=.9,b.vy*=.9,b.x=Math.max(80,Math.min(u-80,b.x)),b.y=Math.max(80,Math.min(m-80,b.y))})}return f},s=new Set(e.map(d=>d.id)),o=[];e.forEach(d=>{if(!d.out_node_id)return;(Array.isArray(d.out_node_id)?d.out_node_id:[d.out_node_id]).forEach(u=>{s.has(u)&&o.push({id:`${d.id}-${u}`,source:d.id,target:u,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:Is.Arrow}})})});const l=a(e,o,r,n);return{nodes:e.map(d=>({id:d.id,type:"styledNode",position:l.get(d.id)??{x:100,y:100},data:{label:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-sm font-semibold",children:d.name}),d.description?t.jsx("div",{className:"mt-1 max-w-32 overflow-hidden text-ellipsis text-xs text-slate-500 dark:text-slate-400",children:d.description}):null]})}})),edges:o}}var ea=$e({"src/components/graph-chat/FloatingHelper.tsx"(){}});function Fh({toX:e,toY:r,fromPosition:n,toPosition:a,fromNode:s}){if(!s)return null;const o={id:"connection-target",measured:{width:1,height:1},internals:{positionAbsolute:{x:e,y:r}}},{sx:l,sy:i,tx:d,ty:h,sourcePos:u,targetPos:m}=Oo(s,o),[f]=Rs({sourceX:l,sourceY:i,sourcePosition:u||n,targetPosition:m||a,targetX:d||e,targetY:h||r});return t.jsxs("g",{children:[t.jsx("path",{fill:"none",stroke:"currentColor",strokeWidth:1.5,className:"animated",d:f}),t.jsx("circle",{cx:d||e,cy:h||r,fill:"var(--theme-panel)",r:3,stroke:"currentColor",strokeWidth:1.5})]})}var Hh=$e({"src/components/graph-chat/FloatingConnectionLine.tsx"(){ea()}});function Oh({id:e,source:r,target:n,markerEnd:a,style:s}){const o=ba(r),l=ba(n);if(!o||!l)return null;const{sx:i,sy:d,tx:h,ty:u,sourcePos:m,targetPos:f}=Oo(o,l),[p]=Rs({sourceX:i,sourceY:d,sourcePosition:m,targetPosition:f,targetX:h,targetY:u});return t.jsx("path",{id:e,className:"react-flow__edge-path",d:p,markerEnd:a,style:s})}var Uh=$e({"src/components/graph-chat/FloatingEdge.tsx"(){ea()}});function Wh({nodes:e}){const[r,n,a]=od([]),[s,o,l]=ld([]),i=c.useMemo(()=>Gh(e),[e]),d=c.useMemo(()=>({floating:Oh}),[]),h=c.useMemo(()=>({styledNode:({data:m,isConnectable:f})=>t.jsxs("div",{className:"thread-graph-flow-node",children:[m.label,t.jsx(xa,{type:"target",position:Pt.Top,isConnectable:f,style:{opacity:0,pointerEvents:"none"}}),t.jsx(xa,{type:"source",position:Pt.Bottom,isConnectable:f,style:{opacity:0,pointerEvents:"none"}})]})}),[]);c.useEffect(()=>{n(i.nodes),o(i.edges)},[i.edges,i.nodes,o,n]);const u=c.useCallback(m=>o(f=>id({...m,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:Is.Arrow}},f)),[o]);return t.jsx("div",{className:"thread-graph-flow h-full min-h-0",children:t.jsx(dd,{children:t.jsxs(cd,{nodes:r,edges:s,onNodesChange:a,onEdgesChange:l,onConnect:u,fitView:!0,nodeTypes:h,edgeTypes:d,connectionLineComponent:Fh,children:[t.jsx(hd,{}),t.jsx(ud,{gap:16})]})})})}var Vh=$e({"src/components/graph-chat/GraphVisualization.tsx"(){Hh(),Uh(),ea()}});function Kh(e){return{...Wo,...e}}function Va(e,r){const n=a=>{switch(a){case"workspace":return e.workspace;case"tools":return e.toolUsage;case"guide":return e.guide;case"graph":return e.threadGraph;case"extensions":return e.extensions}};return r&&n(r)?r:["workspace","tools","guide","graph","extensions"].find(n)??null}function qh(e,r){switch(r){case"workspace":return e.workspace;case"tools":return e.toolUsage;case"guide":return e.guide;case"graph":return e.threadGraph;case"extensions":return e.extensions}}function Xh(e){var s;const r=[],n=new Set(["toolCall","commandExecution","webSearch","fileRead","fileChange","agentToolCall","skillToolCall","hook"]);let a=0;for(const o of e.turns)for(const l of o.items)n.has(l.kind)&&(r.push({id:l.id,kind:l.kind,label:_r(l.kind),preview:l.previewText??l.text??l.kind,detail:l.detailText??l.text??l.previewText??l.kind,turnId:l.sourceTurnId??o.id,status:l.status??null,sequence:a}),a+=1);for(const o of((s=e.liveItems)==null?void 0:s.items)??[])n.has(o.kind)&&(r.push({id:o.id,kind:o.kind,label:_r(o.kind),preview:o.previewText??o.text??o.kind,detail:o.detailText??o.text??o.previewText??o.kind,turnId:o.sourceTurnId??null,status:o.status??null,sequence:a}),a+=1);return r}function _r(e){switch(e){case"toolCall":return"Tool call";case"agentToolCall":return"Agent tool";case"skillToolCall":return"Skill tool";case"commandExecution":return"Command";case"webSearch":return"Search";case"fileRead":return"File read";case"fileChange":return"File change";case"hook":return"Hook";default:return e.replace(/([A-Z])/g," $1").replace(/^./,r=>r.toUpperCase())}}function Yh(e){switch(e.kind){case"userMessage":return"User";case"agentMessage":return"Agent";default:return _r(e.kind)}}function Zh(e){return(e.previewText??e.text??e.detailText??e.kind).replace(/\s+/g," ").slice(0,96)}function Jh(e,r){const n=[{id:`thread:${e.thread.id}`,name:e.thread.title||"Thread",description:e.thread.model??e.thread.status},{id:`workspace:${e.workspace.id}`,name:e.workspace.label??"Workspace",description:e.workspace.absPath,out_node_id:`thread:${e.thread.id}`}];let a=null;for(const o of e.turns){const l=`turn:${o.id}`;n.push({id:l,name:`Turn ${n.filter(d=>d.id.startsWith("turn:")).length+1}`,description:o.status,out_node_id:a?[`thread:${e.thread.id}`,a]:`thread:${e.thread.id}`}),a=l;let i=null;for(const d of o.items){const h=`item:${d.id}`,u=[l];i&&u.push(i),n.push({id:h,name:Yh(d),description:Zh(d),out_node_id:u}),i=h,d.kind==="artifact"&&d.artifact&&n.push({id:`artifact:${d.artifact.id}`,name:d.artifact.title||d.artifact.type,description:d.artifact.summaryText??d.artifact.type,out_node_id:h})}}const s=new Set(n.map(o=>o.id));for(const o of r){const l=`tool:${o.id}`;s.has(l)||s.has(`item:${o.id}`)||n.push({id:l,name:o.label,description:o.preview,out_node_id:o.turnId?`turn:${o.turnId}`:`thread:${e.thread.id}`})}return n.slice(0,120)}function Uo({detail:e,status:r,plugins:n,workspaceAdapter:a,metaContent:s,settingsContent:o,activeView:l="chat",features:i,focusPathRequest:d=null}){const h=c.useMemo(()=>Kh(i),[i]),u=Va(h,i==null?void 0:i.defaultTab),[m,f]=c.useState(u),p=c.useMemo(()=>Fc(e),[e]),g=c.useMemo(()=>Xh(e),[e]),b=c.useMemo(()=>{const w=new Map;for(const N of g)w.set(N.kind,(w.get(N.kind)??0)+1);return[...w.entries()].sort((N,S)=>S[1]-N[1])},[g]),v=n.getThreadPanels(),x=Math.max(...b.map(([,w])=>w),1),y=c.useMemo(()=>Jh(e,g),[e,g]),k=c.useMemo(()=>{const w=[];return h.workspace&&w.push({id:"workspace",label:"Workspace",icon:null}),h.toolUsage&&w.push({id:"tools",label:"Tool Usage",icon:G.BarChart2}),h.guide&&w.push({id:"guide",label:"Guide",icon:G.BookOpen}),w},[h.guide,h.toolUsage,h.workspace]),j=c.useMemo(()=>{const w=[];return h.threadGraph&&w.push({id:"graph",label:"Thread graph",icon:G.GitBranch}),h.extensions&&w.push({id:"extensions",label:"Remote Codex extensions",icon:G.Wrench}),w},[h.extensions,h.threadGraph]);return c.useEffect(()=>{(!m||!qh(h,m))&&f(Va(h,i==null?void 0:i.defaultTab))},[m,i==null?void 0:i.defaultTab,h]),c.useEffect(()=>{d&&h.workspace&&f("workspace")},[h.workspace,d==null?void 0:d.requestId]),m?t.jsxs("div",{className:"thread-graph-right-panel flex h-full min-h-0 flex-col overflow-hidden",children:[t.jsxs("div",{className:"thread-graph-right-tabs flex shrink-0 items-center gap-1 overflow-hidden border-b px-3 py-2",children:[k.map(w=>{const N=w.icon;return t.jsxs("button",{type:"button",onClick:()=>f(w.id),className:`thread-graph-right-tab inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md px-3 text-xs font-medium transition ${m===w.id?"is-active":""}`,children:[N?t.jsx(N,{className:"h-3.5 w-3.5"}):null,w.label]},w.id)}),j.length?t.jsx("div",{className:"thread-graph-right-tab-secondary ml-auto flex min-w-0 shrink items-center gap-1 border-l pl-2","aria-label":"Remote Codex workspace extensions",children:j.map(w=>{const N=w.icon;return t.jsx("button",{type:"button",onClick:()=>f(w.id),className:`thread-graph-right-tab inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-xs font-medium transition ${m===w.id?"is-active":""}`,title:w.label,"aria-label":w.label,children:t.jsx(N,{className:"h-3.5 w-3.5"})},w.id)})}):null]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[m==="workspace"?t.jsx(zh,{activeView:l,detail:e,artifacts:p,plugins:n,status:r,focusPathRequest:d,workspaceAdapter:a??null}):null,m==="tools"?t.jsx(Dh,{formatToolKind:_r,toolCounts:b,toolEvents:g,maxToolCount:x}):null,m==="graph"?t.jsx("div",{className:"thread-graph-visualization-panel h-full min-h-0 p-3",children:t.jsx(Wh,{nodes:y})}):null,m==="extensions"?t.jsx("div",{className:"h-full min-h-0 overflow-y-auto p-3",children:t.jsxs("div",{className:"grid gap-3",children:[t.jsx(Kt,{label:"Plugin Panels",children:v.length?t.jsx("div",{className:"flex flex-wrap gap-2",children:v.map(w=>t.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-1 text-xs text-[var(--theme-fg-soft)]",children:w.label},w.id))}):t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"No thread panels are enabled."})}),t.jsx(Kt,{label:"Enabled Renderers",children:t.jsx("div",{className:"flex flex-wrap gap-2",children:n.plugins.filter(w=>w.enabled).map(w=>t.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-1 text-xs text-[var(--theme-fg-soft)]",children:w.name},w.id))})}),t.jsx(Kt,{label:"Remote Codex Tools",children:t.jsxs("div",{className:"grid gap-2 text-[var(--theme-fg-muted)]",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(G.Terminal,{className:"mt-0.5 h-4 w-4 shrink-0"}),t.jsx("p",{children:"Terminal stays available when the Terminal plugin and shell adapter are attached."})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(G.Paperclip,{className:"mt-0.5 h-4 w-4 shrink-0"}),t.jsx("p",{children:"Composer attachments, slash panels, hooks, MCP, goals, and fork controls remain part of the chat surface."})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(G.Trash2,{className:"mt-0.5 h-4 w-4 shrink-0"}),t.jsx("p",{children:"Destructive actions stay explicit: delete thread, interrupt, compact, and hook trust controls remain host governed."})]})]})}),s?t.jsx(Kt,{label:"Thread Meta",children:s}):null,o?t.jsx(Kt,{label:"Settings",children:o}):null]})}):null,m==="guide"?t.jsx(Mh,{}):null]})]}):null}var Wo,Vo,Qh=$e({"src/components/ThreadGraphWorkspacePanel.tsx"(){Ih(),Eo(),_h(),Bh(),Qn(),Vh(),Wo={workspace:!0,toolUsage:!0,guide:!0,threadGraph:!0,extensions:!0},Vo=c.memo(Uo)}}),Ko={};Gc(Ko,{MemoizedThreadGraphWorkspacePanel:()=>Vo,ThreadGraphWorkspacePanel:()=>Uo});var eu=$e({"src/workspace-panel.ts"(){Qh()}});function Qt(e,{insertAt:r}={}){if(!e||typeof document>"u")return;const n=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css",r==="top"&&n.firstChild?n.insertBefore(a,n.firstChild):n.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}Qt(`.thread-ui-shell,
|
|
9
|
+
`),a+=i}return n.length>0?n:[e]}function Da(e,r){return r!=="xyz"?e:e.flatMap(n=>fh(n))}function Ba(e){return e.map(r=>`${r.replace(/\s+$/g,"")}
|
|
10
|
+
`).join("")}function gh(e){if(!e)return{format:"xyz",frames:[],exportContent:""};if(typeof e=="string"){const s=Da([e],"xyz");return{frames:s,format:"xyz",exportContent:Ba(s)}}const r=ph(e.format),n=e.content.filter(s=>s.trim().length>0);return{frames:Da(n,r),format:r,exportContent:Ba(n)}}var xh=$e({"src/components/graph-workspace/GraphMoleculeViewerData.ts"(){}});function bh({className:e="",moleculeId:r=null,onScreenshot:n,onSelectionChange:a,source:s,title:o="PyMOL-style (PDB/CIF)"}){const l=c.useRef(null),i=c.useRef(null),d=c.useRef(null),h=c.useRef(!1),u=c.useRef(!0),[m,f]=c.useState(null),[p,g]=c.useState(0),[b,v]=c.useState(null),[x,y]=c.useState(!1),[k,N]=c.useState({}),[w,j]=c.useState([]),[C,L]=c.useState({}),[T,q]=c.useState(!1),[M,D]=c.useState(!1),[J,W]=c.useState(null),O=c.useMemo(()=>gh(s),[s]),ee=O.frames,he=O.format,E=ee[p]??null,re=ee.length>0&&p===ee.length-1,A=r??"current",V=Object.values(C).reduce((z,P)=>z+P.length,0),U=Object.keys(C).length;c.useEffect(()=>{if(ee.length===0){g(0);return}g(ee.length-1)},[ee.length]),c.useEffect(()=>{if(!x||ee.length<=1)return;const z=window.setInterval(()=>{g(P=>P>=ee.length-1?(window.clearInterval(z),y(!1),P):P+1)},200);return()=>window.clearInterval(z)},[x,ee.length]),c.useEffect(()=>{const z=l.current;if(!z||i.current)return;let P=!1;try{const K=document.createElement("canvas");if(!(K.getContext("webgl2")||K.getContext("webgl")||K.getContext("experimental-webgl"))){W("WebGL is unavailable in this browser environment. Unable to render 3D viewer.");return}}catch{W("WebGL is unavailable in this browser environment. Unable to render 3D viewer.");return}const Z=()=>{var K,de;(K=i.current)==null||K.resize(),(de=i.current)==null||de.render()};return ch().then(K=>{if(!(P||i.current))try{const de=K.createViewer(z,{});i.current=de,de.setBackgroundColor("#f8fafc",.8),window.addEventListener("resize",Z),window.setTimeout(Z,100)}catch(de){console.error("Failed to initialize 3Dmol viewer:",de),W("Failed to initialize 3D viewer. Please refresh or try another browser.")}}).catch(K=>{console.error("Failed to load 3Dmol viewer runtime:",K),W("Failed to load 3D viewer runtime. Please refresh or try another browser.")}),()=>{P=!0,window.removeEventListener("resize",Z),i.current=null,d.current=null}},[]),c.useEffect(()=>{const z=i.current;if(!(!z||!E))try{z.removeAllModels(),z.removeAllShapes(),z.removeAllLabels();const P=z.addModel(E,he||"xyz");d.current=P,P.setStyle({},{stick:{radius:.2},sphere:{scale:.3}});const Z=P.getCrystData(),K=!!(Z&&typeof Z=="object"&&Object.keys(Z).length);q(K),D(K?u.current:!1),j([]),N({});const de=E.split(`
|
|
11
|
+
`).slice(2).map(_=>_.trim()).filter(Boolean).map(_=>_.split(/\s+/)[0]??"Atom");h.current||(z.zoomTo(),h.current=!0),P.setClickable({},!0,(_,Y,te)=>{const ie=_.serial??_.index;if(ie===void 0)return;const ue=_.atom||_.elem||de[ie]||"Atom";j(be=>{const ae=!!(te!=null&&te.shiftKey||te!=null&&te.metaKey||te!=null&&te.ctrlKey)?be.includes(ie)?be.filter(ve=>ve!==ie):[...be,ie]:be.length===1&&be[0]===ie?[]:[ie];return N(ve=>{if(ae.length===0)return{};const ke={};return ae.forEach(pe=>{ke[pe]=ve[pe]||de[pe]||ue}),ke}),ae})}),P.setHoverable({},!0,(_,Y,te)=>{!te||!_||v({x:te.clientX,y:te.clientY,label:`${_.atom||_.elem||"Atom"} (${_.serial??_.index??"?"})`,coords:{x:_.x.toFixed(2),y:_.y.toFixed(2),z:_.z.toFixed(2)}})},()=>v(null)),z.render()}catch(P){console.error("Failed to render molecule:",P),W("Unable to render this molecular structure.")}},[E,he]),c.useEffect(()=>{const z=i.current,P=d.current;if(!(!z||!P)){try{z.removeUnitCell(P)}catch{}if(M&&T)try{z.addUnitCell(P,{box:{color:"black",opacity:1,linewidth:5},astyle:{radius:.12,mid:.85,color:"red",opacity:.6},bstyle:{radius:.12,mid:.85,color:"green",opacity:.6},cstyle:{radius:.12,mid:.85,color:"blue",opacity:.6},alabel:"a",blabel:"b",clabel:"c"})}catch{q(!1),D(!1)}z.render()}},[T,M,E,he]),c.useEffect(()=>{const z=i.current,P=d.current;!z||!P||!E||(P.setStyle({},{stick:{radius:.2},sphere:{scale:.3}}),w.length>0&&P.setStyle({serial:w},{stick:{radius:.3,color:"yellow"},sphere:{scale:.4,color:"yellow"}}),z.render(),a==null||a({moleculeId:r,atoms:w}))},[r,a,w,E]),c.useEffect(()=>{if(!E)return;let z=0;const P=()=>{var K,de;const Z=(de=(K=i.current)==null?void 0:K.getView)==null?void 0:de.call(K);if(Array.isArray(Z)&&Z.length>=8){const[_,Y,te,ie,ue,be,Le,ae]=Z;if(typeof _=="number"&&typeof Y=="number"&&typeof te=="number"&&typeof ie=="number"&&typeof ue=="number"&&typeof be=="number"&&typeof Le=="number"&&typeof ae=="number"){const ve=Math.sqrt(ue*ue+be*be+Le*Le),ke=ve>0?{x:ue/ve,y:be/ve,z:Le/ve}:{x:0,y:0,z:0};f({position:{x:_,y:Y,z:te,qx:ue,qy:be,qz:Le,qw:ae},lookAt:ke,zoom:ie})}}z=window.requestAnimationFrame(P)};return z=window.requestAnimationFrame(P),()=>window.cancelAnimationFrame(z)},[E]);const I=c.useCallback(async()=>{const z=i.current;if(!(z!=null&&z.pngURI))return;z.render();const P=z.pngURI();if(P){try{const K=await(await fetch(P)).blob(),de=new ClipboardItem({[K.type||"image/png"]:K});await navigator.clipboard.write([de])}catch{}n==null||n({moleculeId:r,image:P})}},[r,n]);function X(){T&&D(z=>{const P=!z;return u.current=P,P})}function F(){w.length!==0&&L(z=>{const P=z[A]??[];return{...z,[A]:Array.from(new Set([...P,...w]))}})}return t.jsxs("div",{className:`thread-graph-molecule-viewer flex h-full min-h-0 flex-col bg-white ${e}`,children:[t.jsxs("div",{className:"thread-graph-molecule-header flex shrink-0 items-center justify-between gap-3 border-b border-slate-200 px-3 py-2 sm:px-4 sm:py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"truncate text-sm font-semibold text-slate-900",children:o}),t.jsx("p",{className:"mt-1 hidden text-[11px] text-slate-400 sm:block",children:"cartoon + surface"})]}),t.jsx("span",{className:"shrink-0 text-[11px] text-slate-400",children:"workspace preview"})]}),t.jsxs("div",{className:"thread-graph-molecule-body min-h-0 flex-1",children:[t.jsxs("div",{ref:l,"data-testid":"molecule-viewer",className:"thread-graph-molecule-stage relative min-h-0 flex-1 overflow-hidden",children:[J?t.jsx("div",{"data-testid":"molecule-viewer-error",className:"thread-graph-molecule-error absolute inset-0 flex items-center justify-center bg-red-50 p-4 text-sm text-red-700",children:J}):null,!J&&!E?t.jsx("div",{className:"thread-graph-molecule-empty absolute inset-0 flex items-center justify-center p-4 text-sm text-slate-400",children:"No molecule data available."}):null,b?t.jsxs("div",{className:"thread-graph-molecule-tooltip pointer-events-none fixed z-[1000] rounded-md border border-gray-300 bg-white/95 px-2 py-1.5 text-[10px] text-gray-800 shadow-md",style:{left:b.x-20,top:b.y-50},children:[t.jsx("div",{className:"mb-0.5 font-semibold text-gray-900",children:b.label}),t.jsxs("div",{className:"space-x-2 text-gray-600",children:[t.jsxs("span",{children:["x: ",b.coords.x]}),t.jsxs("span",{children:["y: ",b.coords.y]}),t.jsxs("span",{children:["z: ",b.coords.z]})]})]}):null]}),t.jsxs("div",{className:"thread-graph-molecule-controls shrink-0",children:[t.jsxs("div",{className:"thread-graph-molecule-control-row",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-graph-molecule-control-title",children:"Ball & Stick"}),t.jsx("p",{className:"thread-graph-molecule-control-subtitle",children:"XYZ / PDB / CIF preview"})]}),t.jsx(ih,{currentIndex:p,exportContent:O.exportContent,moleculeId:r,onScreenshot:()=>void I(),viewerRef:i,xyzContent:E,xyzFormat:he})]}),ee.length>1?t.jsxs("div",{className:"thread-graph-molecule-trajectory",children:[t.jsxs("div",{className:"mb-2 flex justify-between gap-3 text-xs",children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:["Trajectory ",p+1," / ",ee.length,t.jsx(ur,{type:"button",variant:"ghost",size:"icon",className:"thread-graph-molecule-button h-5 w-5",onClick:()=>{y(z=>{const P=!z;return P&&p===ee.length-1&&g(0),P})},"aria-label":x?"Pause trajectory":"Play trajectory",title:x?"Pause trajectory":"Play trajectory",children:x&&p!==ee.length-1?t.jsx(G.Pause,{className:"h-3 w-3"}):t.jsx(G.Play,{className:"h-3 w-3"})})]}),t.jsxs(ur,{type:"button",variant:"ghost",onClick:()=>g(ee.length-1),className:"thread-graph-molecule-live-button",children:[t.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${re?"animate-pulse bg-red-600":"bg-gray-300"}`}),"Live"]})]}),t.jsx(uh,{value:[p],max:ee.length-1,step:1,onValueChange:z=>g(z[0]??0),"aria-label":"Trajectory frame"})]}):null,t.jsx(oh,{cameraInfo:m,onClearSelection:()=>j([]),onClearStaged:()=>L({}),onSendSelection:()=>a==null?void 0:a({moleculeId:r,atoms:w}),onSendStaged:()=>{Object.entries(C).forEach(([z,P])=>{a==null||a({moleculeId:z==="current"?r:z,atoms:P})})},onStageSelection:F,onToggleUnitCell:X,selectedAtomLabels:k,selectedSerials:w,stagedAtoms:V,stagedMolecules:U,unitCellAvailable:T,unitCellVisible:M})]})]})]})}var vh=$e({"src/components/graph-workspace/GraphMoleculeViewer.tsx"(){lh(),dh(),hh(),Or(),mh(),xh()}});function kh(e){return!e.truncated&&e.size<=Io&&e.content.split(`
|
|
12
|
+
`).length<=zo}function wh(e){return e&&(e.node.path||e.node.name)||null}function yh(e){if(!e)return null;switch(e.kind){case"live-artifact":return{kind:"live-molecule",node:e};case"file":return{kind:"workspace-file",node:e};case"artifact":return{kind:"artifact",node:e};case"event":return{kind:"event",node:e};case"meta":return{kind:"meta",node:e};case"directory":return null}}function jh({error:e,imageUrl:r,loadingMore:n,onSaveFile:a,onLoadMore:s,onCollapse:o,pdfUrl:l,previewFile:i,previewLoading:d,plugins:h,selectedTarget:u}){const[m,f]=c.useState(!1),[p,g]=c.useState(""),[b,v]=c.useState(null),[x,y]=c.useState(!1),k=(u==null?void 0:u.node)??null,N=k!=null&&k.artifact?h.renderArtifact({artifact:k.artifact,expanded:!0,onToggleExpanded:()=>{}}):null,w=Uc(i??null),j=(i==null?void 0:i.language)||Wc((i==null?void 0:i.path)??""),C=i?br(i.path):"",L=wh(u),T=i!==null&&Zn.has(C),q=!!(i&&a)&&!T&&kh(i),M=(u==null?void 0:u.kind)==="live-molecule",D=!!(k!=null&&k.artifact&&N),J=!!w||D;c.useEffect(()=>{f(!1),g((i==null?void 0:i.content)??""),v(null)},[i==null?void 0:i.path,i==null?void 0:i.content]);async function W(){if(!(!i||!a)){y(!0),v(null);try{await a({path:i.path,content:p}),f(!1)}catch(O){v(O instanceof Error?O.message:"Failed to save file.")}finally{y(!1)}}}return t.jsxs("section",{className:"thread-graph-viewer flex h-full min-h-0 flex-col overflow-hidden rounded-[12px]","data-preview-target-kind":(u==null?void 0:u.kind)??"none",children:[t.jsxs("div",{className:"thread-graph-viewer-header flex h-12 shrink-0 items-center justify-between gap-3 border-b px-3 sm:h-[60px] sm:px-5",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[t.jsx("h2",{className:"text-base font-semibold text-slate-900 sm:text-[18px] dark:text-slate-100",children:"Viewer"}),L?t.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-slate-500 dark:text-slate-400",children:L}):null]}),o?t.jsx("button",{type:"button",onClick:o,"data-testid":"collapse-viewer",className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-[#222733] dark:hover:text-slate-100",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(G.ChevronsRight,{className:"h-4 w-4"})}):null]}),t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[e?t.jsx("div",{className:"border-b border-rose-200 bg-rose-50 px-5 py-3 text-sm text-rose-700 dark:border-rose-400/25 dark:bg-rose-400/10 dark:text-rose-200",children:e}):null,u?u.kind==="workspace-file"&&d?t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center px-5 text-center text-sm text-slate-400 dark:text-slate-500",children:"Loading file preview..."}):u.kind==="workspace-file"&&w?t.jsx("div",{className:"thread-graph-molecule-preview min-h-0 flex-1 overflow-hidden",children:t.jsx(bh,{source:w,moleculeId:w.uuid??u.node.path,title:"PyMOL-style (PDB/CIF)"})}):u.kind==="workspace-file"&&r?t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-auto p-5",children:t.jsx("img",{src:r,alt:u.node.path||u.node.name,className:"max-h-full max-w-full object-contain"})}):u.kind==="workspace-file"&&l?t.jsx("div",{className:"thread-graph-file-preview-frame min-h-0 flex-1 overflow-hidden",children:t.jsx("iframe",{src:l,title:`PDF preview: ${u.node.path||u.node.name}`,className:"h-full w-full border-0"})}):u.kind==="workspace-file"&&i?t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs("div",{className:"thread-graph-file-preview-header flex min-h-12 items-center justify-between gap-3 border-b px-4 py-2",children:[t.jsxs("div",{className:"min-w-0 text-xs uppercase tracking-[0.12em]",children:[T?"molecule":j||C||"text"," |"," ",i.size.toLocaleString()," bytes",i.truncated?t.jsxs("span",{className:"ml-2 text-amber-500",children:["showing ",i.nextOffset.toLocaleString()," bytes"]}):null]}),q?t.jsx("div",{className:"flex shrink-0 items-center gap-1",children:m?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>{g(i.content),f(!1),v(null)},disabled:x,className:"thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition disabled:cursor-not-allowed disabled:opacity-50",title:"Cancel edits","aria-label":"Cancel edits",children:t.jsx(G.X,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:()=>void W(),disabled:x||p===i.content,className:"thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition disabled:cursor-not-allowed disabled:opacity-50",title:"Save file","aria-label":"Save file",children:t.jsx(G.Save,{className:"h-4 w-4"})})]}):t.jsx("button",{type:"button",onClick:()=>{g(i.content),f(!0),v(null)},className:"thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition",title:"Edit file","aria-label":"Edit file",children:t.jsx(G.Pencil,{className:"h-4 w-4"})})}):null]}),b?t.jsx("div",{className:"border-b border-rose-200 bg-rose-50 px-4 py-2 text-sm text-rose-700 dark:border-rose-400/25 dark:bg-rose-400/10 dark:text-rose-200",children:b}):null,m?t.jsx("textarea",{value:p,onChange:O=>g(O.currentTarget.value),spellCheck:!1,"aria-label":"Workspace file editor",className:"thread-graph-file-editor min-h-0 flex-1 resize-none border-0 bg-transparent p-4 font-mono text-[12px] leading-5 text-slate-900 outline-none dark:text-slate-100"}):t.jsx(Er,{content:i.content}),i.truncated&&s?t.jsx("div",{className:"thread-graph-file-preview-footer flex justify-center border-t px-4 py-3",children:t.jsx("button",{type:"button",onClick:s,disabled:n,title:"Load more workspace preview","aria-label":"Load more workspace preview",className:"thread-graph-load-more-button rounded-md px-4 py-1.5 text-xs disabled:opacity-50",children:n?"Loading...":`Load more (${(i.size-i.nextOffset).toLocaleString()} bytes remaining)`})}):null]}):(u.kind==="live-molecule"||u.kind==="artifact")&&u.node.artifact?t.jsx("div",{className:J||M?"min-h-0 flex-1 overflow-hidden":"min-h-0 flex-1 overflow-auto p-3",children:N}):u.kind==="meta"?t.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-3",children:t.jsx("div",{className:"grid gap-3",children:t.jsx(Kt,{label:"Workspace Data",children:t.jsx(Er,{content:u.node.detail??""})})})}):t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsx("div",{className:"thread-graph-file-preview-header border-b px-4 py-3 text-xs uppercase tracking-[0.12em]",children:u.node.kind}),t.jsx(Er,{content:u.node.detail??u.node.preview??u.node.name})]}):t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center px-5 text-center text-sm text-slate-400 dark:text-slate-500",children:"Pick a live molecule, workspace file, artifact, or thread event to preview it."})]})]})}var Io,zo,Er,Nh=$e({"src/components/graph-workspace/GraphWorkspacePreviewPane.tsx"(){Jn(),To(),vh(),Io=50*1024,zo=1e3,Er=c.memo(function({content:r}){return t.jsx("div",{className:"thread-graph-code-preview min-h-0 flex-1 overflow-auto",children:t.jsx("pre",{className:"thread-graph-plain-code-preview",children:t.jsx("code",{children:r})})})})}});function Ch({files:e,onCancel:r,onConfirm:n}){return t.jsx("div",{className:"thread-graph-dialog-backdrop fixed inset-0 z-50 flex items-center justify-center bg-black/40 px-4",children:t.jsxs("div",{className:"thread-graph-dialog w-full max-w-sm rounded-xl border bg-[var(--theme-panel)] p-6 shadow-xl",children:[t.jsx("h3",{className:"text-base font-semibold text-[var(--theme-fg)]",children:"Empty garbage?"}),t.jsxs("p",{className:"mt-1 text-sm leading-5 text-[var(--theme-fg-muted)]",children:["Permanently delete all files in the"," ",t.jsx("code",{className:"rounded bg-[var(--theme-muted)] px-1 text-xs text-[var(--theme-fg-soft)]",children:"garbage/"})," ","folder."]}),e.length===0?t.jsx("p",{className:"mt-3 text-sm text-[var(--theme-fg-muted)]",children:"Garbage is empty."}):t.jsx("ul",{className:"mt-3 max-h-40 overflow-y-auto rounded-md border border-[var(--theme-border)] bg-[var(--theme-surface)] p-2 text-xs text-[var(--theme-fg-soft)]",children:e.map(a=>t.jsx("li",{className:"truncate py-0.5",title:a,children:a},a))}),t.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:r,className:"thread-secondary-action rounded-md px-3 py-1.5 text-sm",children:"Cancel"}),e.length>0?t.jsx("button",{type:"button",onClick:n,className:"ui-action-danger rounded-md px-3 py-1.5 text-sm font-medium",children:"Yes, empty garbage"}):null]})]})})}var Sh=$e({"src/components/graph-workspace/GraphEmptyGarbageDialog.tsx"(){}});function Ro(e){return`${Ao}${e.workspaceId??"workspace"}:${e.threadId}`}function Th(e){if(typeof window>"u")return[];try{const r=window.localStorage.getItem(Ro(e));if(!r)return[];const n=JSON.parse(r);return Array.isArray(n)?n.filter(a=>typeof a=="string"):[]}catch{return[]}}function Ga(e,r){if(!(typeof window>"u"))try{window.localStorage.setItem(Ro(e),JSON.stringify([...r]))}catch{}}function zn(e,r){if(!r||e.path!==r.path||e.kind!=="directory")return e;const n=new Map(r.children.map(o=>[o.path,o])),a=e.children.map(o=>zn(o,n.get(o.path)??null)),s=e.childrenLoaded&&e.children.length>0;return{...e,children:s||!r.childrenLoaded?a:r.children,childrenLoaded:e.childrenLoaded||r.childrenLoaded,truncated:e.truncated??r.truncated}}function Fa(e,r){if(e.kind==="directory")return r?t.jsx(G.FolderOpen,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"}):t.jsx(G.Folder,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"});const n=br(e.name);return n==="zip"?t.jsx(G.FileArchive,{className:"h-4 w-4 text-amber-600"}):e.kind==="file"&&["png","jpg","jpeg","gif","webp","svg"].includes(n)?t.jsx(G.FileImage,{className:"h-4 w-4 text-sky-500"}):e.kind==="artifact"||["xyz","extxyz","cif","pdf","json","ts","tsx","js","jsx","md","yaml","yml","py"].includes(n)?t.jsx(G.FileCode2,{className:"h-4 w-4 text-emerald-600"}):t.jsx(G.File,{className:"h-4 w-4 text-slate-400 dark:text-slate-500"})}function _o({depth:e,expandedPaths:r,loadingPaths:n,node:a,onDownload:s,onPreview:o,onSelect:l,onToggle:i,selectedNodeId:d}){const h=a.kind==="directory",u=h&&(a.path===""||r.has(a.path)),m=h&&n.has(a.path),f=d===a.id,p=`${e*.75+.5}rem`;return h?t.jsxs("div",{children:[t.jsxs("div",{className:"thread-graph-tree-row group flex items-center text-sm text-slate-600 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100",children:[t.jsxs("button",{type:"button",onClick:()=>i(a.path),className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 px-2 py-2 text-left sm:min-h-0 sm:py-1.5",style:{paddingLeft:p},children:[u?t.jsx(G.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}):t.jsx(G.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}),Fa(a,u),t.jsx("span",{className:"truncate",children:a.name}),m?t.jsx("span",{className:"ml-auto shrink-0 text-xs text-slate-400 dark:text-slate-500",children:"Loading"}):null]}),s?t.jsx("button",{type:"button",onClick:()=>s(a),className:"thread-graph-tree-action mr-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-slate-400 transition hover:bg-white hover:text-slate-900 sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100",title:a.path?`Download ${a.name}`:"Download workspace","aria-label":a.path?`Download ${a.name}`:"Download workspace",children:t.jsx(G.Download,{className:"h-3.5 w-3.5"})}):null]}),u?t.jsxs("div",{children:[a.children.map(g=>t.jsx(_o,{depth:e+1,expandedPaths:r,loadingPaths:n,node:g,...s?{onDownload:s}:{},...o?{onPreview:o}:{},onSelect:l,onToggle:i,selectedNodeId:d},g.id)),a.truncated?t.jsx("div",{className:"px-2 py-1 text-xs text-slate-400 dark:text-slate-500",style:{paddingLeft:`${(e+1)*.75+.5}rem`},children:"More items not shown"}):null]}):null]}):t.jsxs("div",{className:`thread-graph-tree-row group flex items-center text-sm transition ${f?"is-selected":"text-slate-600 hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100"}`,children:[t.jsxs("button",{type:"button",onClick:()=>l(a.id),className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 px-2 py-2 text-left sm:min-h-0 sm:py-1.5",style:{paddingLeft:`${e*.75+2.2}rem`},children:[Fa(a,!1),t.jsx("span",{className:"truncate",children:a.name})]}),a.kind==="file"&&(o||s)?t.jsxs("div",{className:"mr-1 flex shrink-0 items-center gap-0.5",children:[o?t.jsx("button",{type:"button",onClick:()=>o(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${f?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Preview ${a.name}`,"aria-label":`Preview ${a.name}`,children:t.jsx(G.Eye,{className:"h-3.5 w-3.5"})}):null,s?t.jsx("button",{type:"button",onClick:()=>s(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${f?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Download ${a.name}`,"aria-label":`Download ${a.name}`,children:t.jsx(G.Download,{className:"h-3.5 w-3.5"})}):null]}):null]})}function Eh({liveNodes:e,onSelect:r,selectedNodeId:n}){return e.length===0?null:t.jsxs("div",{className:"border-b border-slate-200 py-2 dark:border-[#2a2f3a]",children:[t.jsx("div",{className:"thread-graph-workspace-label px-3 pb-1 text-[11px] font-semibold tracking-normal text-slate-500 dark:text-slate-400",children:"Live"}),t.jsx("div",{className:"space-y-0.5",children:e.map(a=>{var o;const s=n===a.id;return t.jsxs("button",{type:"button","data-testid":"live-molecule-item","data-molecule-id":((o=a.artifact)==null?void 0:o.id)??a.id,onClick:()=>r(a.id),className:`thread-graph-tree-row flex min-h-9 w-full items-center gap-2 px-3 py-2 text-left text-sm transition sm:min-h-0 sm:py-1.5 ${s?"is-selected":"text-slate-600 hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100"}`,children:[t.jsx(G.FileCode2,{className:`h-4 w-4 shrink-0 ${s?"text-current":"text-emerald-600 dark:text-emerald-300"}`}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:a.name})]},a.id)})})]})}function Lh({canEmptyGarbage:e,canUpload:r,onCollapse:n,expandedPaths:a,loadingPaths:s,loading:o,onDownload:l,onEmptyGarbage:i,onPreview:d,onRefresh:h,onSelect:u,onToggle:m,onUpload:f,explorerScrollTopRef:p,explorerScrollerRef:g,selectedNodeId:b,tree:v,liveNodes:x}){const y=c.useMemo(()=>({...v,children:v.children.filter(k=>k.path!=="live")}),[v]);return c.useLayoutEffect(()=>{const k=g.current;k&&(k.scrollTop=p.current)},[g,p]),t.jsxs("aside",{className:`${Mo} flex flex-col`,children:[t.jsxs("div",{className:$o,children:[t.jsx("div",{className:"min-w-0",children:t.jsx("h2",{className:Do,children:"Explorer"})}),t.jsxs("div",{className:"flex items-center gap-1",children:[n?t.jsxs("button",{type:"button","data-testid":"collapse-explorer",onClick:n,className:Bo,title:"Collapse Explorer","aria-label":"Collapse Explorer",children:[t.jsx(G.ChevronsLeft,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Collapse Explorer"})]}):null,t.jsx("button",{type:"button",onClick:f,disabled:!r,className:Pr,title:r?"Upload file":"Upload is unavailable for this workspace","aria-label":"Upload file",children:t.jsx(G.Upload,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:h,className:Pr,title:"Refresh workspace","aria-label":"Refresh workspace",children:t.jsx(G.RefreshCw,{className:`h-4 w-4 ${o?"animate-spin":""}`})}),i?t.jsx("button",{type:"button",onClick:i,disabled:!e,className:Pr,title:e?"Empty garbage":"Garbage controls are unavailable","aria-label":"Empty garbage",children:t.jsx(G.Trash2,{className:"h-4 w-4"})}):null]})]}),t.jsxs("div",{ref:g,className:"thread-graph-workspace-tree-scroll min-h-0 flex-1 overflow-y-auto py-2",onScroll:k=>{p.current=k.currentTarget.scrollTop},children:[t.jsx(Eh,{liveNodes:x??[],onSelect:u,selectedNodeId:b}),t.jsx("div",{className:Go,children:"Workspace"}),t.jsx(_o,{depth:0,expandedPaths:a,loadingPaths:s,node:y,...l?{onDownload:l}:{},...d?{onPreview:d}:{},onSelect:u,onToggle:m,selectedNodeId:b}),y.children.length===0?t.jsx("p",{className:Fo,children:"This workspace is empty. Agent tool runs execute inside the thread workspace, so files should appear here as the session works."}):null]})]})}function Ph({activeView:e,detail:r,artifacts:n,plugins:a,status:s,focusPathRequest:o,workspaceAdapter:l}){const[i,d]=c.useState(null),h=c.useMemo(()=>l&&i?null:Aa(r,n),[e,i,n,r,s,l]),u=i??h??Aa(r,n),m=c.useMemo(()=>Xc(u),[u]),f=c.useMemo(()=>{var R;return((R=u.children.find($=>$.path==="live"))==null?void 0:R.children)??[]},[u]),p=No(u),[g,b]=c.useState(()=>(p==null?void 0:p.id)??null),[v,x]=c.useState(()=>new Set(["","artifacts","thread-events","live",...Ma((p==null?void 0:p.path)??"")])),[y,k]=c.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 639px)").matches?"viewer":null),[N,w]=c.useState(null),[j,C]=c.useState(!1),[L,T]=c.useState(()=>new Set),[q,M]=c.useState(!1),[D,J]=c.useState(!1),[W,O]=c.useState(!1),[ee,he]=c.useState([]),[E,re]=c.useState(null),[A,V]=c.useState(null),[U,I]=c.useState(null),[X,F]=c.useState(!1),z=c.useRef(null),P=c.useRef(null),Z=c.useRef(0),K=c.useRef(null),de=!!l,_=(g?m.get(g):null)??p??null,Y={threadId:r.thread.id,workspaceId:r.workspace.id??r.thread.workspaceId??null};c.useEffect(()=>{Z.current=0,K.current=null,x(new Set(["","artifacts","thread-events","live",...Th(Y),...Ma((p==null?void 0:p.path)??"")]))},[Y.threadId,Y.workspaceId]);function te(){var $;const R=(($=P.current)==null?void 0:$.scrollTop)??Z.current;Z.current=R,K.current=R}function ie(){const R=K.current??Z.current;if(!P.current)return;let Q=0;const me=()=>{const xe=P.current;xe&&(xe.scrollTop=Math.min(R,Math.max(0,xe.scrollHeight-xe.clientHeight)),Z.current=xe.scrollTop,Q+=1,Q<8?window.requestAnimationFrame(me):K.current=null)};window.requestAnimationFrame(me)}c.useLayoutEffect(()=>{y!=="explorer"&&ie()},[y,u]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const R=window.matchMedia("(max-width: 639px)"),$=()=>F(R.matches);return $(),typeof R.addEventListener=="function"?(R.addEventListener("change",$),()=>R.removeEventListener("change",$)):(R.addListener($),()=>R.removeListener($))},[]);async function ue(R){if(!l)return;const $=R??(_==null?void 0:_.path)??null;C(!0),w(null);try{const Q=Vt(await l.listTree({...Y,path:""}));let me=i?zn(Q,i):Q;if(i){const ze=[...v].filter(ge=>ge).sort((ge,Me)=>ge.split("/").length-Me.split("/").length);for(const ge of ze){const Me=En(i,ge);if((Me==null?void 0:Me.kind)!=="directory"||!Me.childrenLoaded)continue;const at=Vt(await l.listTree({...Y,path:ge}));me=Ln(me,ge,zn(at,Me))}}d(me);const xe=wo(me);b(ze=>{var Me;const ge=$??(ze?(Me=m.get(ze))==null?void 0:Me.path:null);return ge&&Pn(me,ge)?`workspace:${ge}`:(xe==null?void 0:xe.id)??ze})}catch(Q){w(Q instanceof Error?Q.message:"Failed to load workspace"),d(null)}finally{C(!1)}}async function be(R){if(!(!l||!i)){T($=>{if($.has(R))return $;const Q=new Set($);return Q.add(R),Q}),w(null);try{const $=Vt(await l.listTree({...Y,path:R}));d(Q=>Q&&ko(Q,R,$.children,{truncated:$.truncated}))}catch($){w($ instanceof Error?$.message:"Failed to load directory")}finally{T($=>{if(!$.has(R))return $;const Q=new Set($);return Q.delete(R),Q})}}}async function Le(R){const $=yo(R);if(!$)return;const Q=Oc($);if(k(null),x(me=>{const xe=new Set(me);xe.add("");for(const ze of Q)xe.add(ze);return Ga(Y,xe),xe}),!l){Pn(u,$)&&b(`workspace:${$}`);return}C(!0),w(null);try{let me=i??Vt(await l.listTree({...Y,path:""}));for(const xe of Q){const ze=En(me,xe);if((ze==null?void 0:ze.kind)==="directory"&&ze.childrenLoaded)continue;const ge=Vt(await l.listTree({...Y,path:xe}));me=Ln(me,xe,ge)}d(me),b(`workspace:${$}`)}catch(me){w(me instanceof Error?me.message:`Failed to open ${$}`)}finally{C(!1)}}c.useEffect(()=>{if(!(!l||!i))for(const R of m.values())R.path&&R.kind==="directory"&&v.has(R.path)&&R.hasChildren&&!R.childrenLoaded&&!L.has(R.path)&&be(R.path)},[i,v,m,l]),c.useEffect(()=>{d(null),T(new Set),re(null),V(null),I(null),w(null),ue()},[de,r.thread.id,r.workspace.id,r.thread.workspaceId]),c.useEffect(()=>{o&&Le(o.path)},[o==null?void 0:o.requestId]),c.useEffect(()=>{l!=null&&l.subscribeWorkspaceChanged},[l,Y.threadId,Y.workspaceId]),c.useEffect(()=>{const R=l&&(_==null?void 0:_.kind)==="file"?_.path:null;if(!R){re(null),V(null),I(null);return}const $=R;let Q=!1;async function me(){var xe;if(l){M(!0),w(null),re(null),V(null),I(null);try{const ze=br($),ge=(xe=l.getRawFileUrl)==null?void 0:xe.call(l,{...Y,path:$});if(ge&&Co.has(ze)){Q||V(ge);return}if(ge&&So.has(ze)){Q||I(ge);return}const Me=await l.readFile({...Y,path:$,limit:Lr});Q||re(Me)}catch(ze){Q||w(ze instanceof Error?ze.message:"Failed to read file")}finally{Q||M(!1)}}}return me(),()=>{Q=!0}},[l,_==null?void 0:_.id]);async function ae(){if(!(!l||!(E!=null&&E.truncated))){J(!0);try{const R=await l.readFile({...Y,path:E.path,offset:E.nextOffset,limit:Lr});re($=>$&&{...$,content:$.content+R.content,truncated:R.truncated,nextOffset:R.nextOffset,size:R.size})}finally{J(!1)}}}async function ve(R){if(!(l!=null&&l.writeFile))return;w(null),await l.writeFile({...Y,path:R.path,content:R.content}),await ue(R.path);const $=await l.readFile({...Y,path:R.path,limit:Lr});re($)}async function ke(R){if(!(!(l!=null&&l.uploadFile)||!R)){C(!0),w(null);try{const $=await l.uploadFile({...Y,path:R.name,file:R}),Q=$.kind==="archive"?$.paths[0]??null:$.file.path;await ue(Q)}catch($){w($ instanceof Error?$.message:"Failed to upload file")}finally{C(!1)}}}async function pe(R){var Q;const $=(Q=R.target.files)==null?void 0:Q[0];R.target.value="",$&&await ke($)}function Ie(){if(!(l!=null&&l.uploadFile))return;const R=()=>{var $;return($=z.current)==null?void 0:$.click()};if(l.pickUploadFile){l.pickUploadFile({...Y,defaultPick:R,upload:ke});return}R()}function je(R){var $;($=l==null?void 0:l.downloadNode)==null||$.call(l,{...Y,path:R.path,kind:R.kind==="directory"?"directory":"file"})}function _e(R){R.kind==="file"&&(te(),b(R.id),k("explorer"))}async function Pe(){if(l!=null&&l.emptyGarbage){if(w(null),!l.listGarbage){he([]),O(!0);return}try{const R=await l.listGarbage(Y);he(R.map($=>`garbage/${$}`))}catch(R){he([]),w(R instanceof Error?R.message:"Failed to list garbage files")}finally{O(!0)}}}async function Ae(){if(l!=null&&l.emptyGarbage){O(!1),w(null);try{await l.emptyGarbage(Y),await ue((_==null?void 0:_.path)??null)}catch(R){w(R instanceof Error?R.message:"Failed to empty garbage")}}}const Ce={...l!=null&&l.downloadNode?{onDownload:je}:{},...l!=null&&l.emptyGarbage?{onEmptyGarbage:Pe}:{},...l?{onRefresh:()=>void ue((_==null?void 0:_.path)??null)}:{},...l!=null&&l.uploadFile?{onUpload:Ie}:{}};function Re(R){if(!R)return;const $=m.get(`workspace:${R}`),Q=($==null?void 0:$.kind)==="directory"&&$.hasChildren&&!$.childrenLoaded&&!L.has(R);x(me=>{const xe=new Set(me);return xe.has(R)?xe.delete(R):xe.add(R),Ga(Y,xe),xe}),!v.has(R)&&Q&&be(R)}const H=t.jsx(Lh,{canEmptyGarbage:!!(l!=null&&l.emptyGarbage),canUpload:!!(l!=null&&l.uploadFile),onCollapse:()=>{te(),k("explorer")},expandedPaths:v,loadingPaths:L,loading:j,explorerScrollTopRef:Z,explorerScrollerRef:P,...Ce,onPreview:_e,onSelect:R=>{b(R)},onToggle:Re,selectedNodeId:(_==null?void 0:_.id)??null,tree:u,liveNodes:f}),ce=t.jsx(jh,{error:N,imageUrl:A,loadingMore:D,onLoadMore:ae,...l!=null&&l.writeFile?{onSaveFile:ve}:{},onCollapse:()=>{te(),k("viewer")},pdfUrl:U,previewFile:E,previewLoading:q,plugins:a,selectedTarget:yh(_)});return y==="explorer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:ce}):y==="viewer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:H}):t.jsxs("div",{"data-testid":"workspace-panel",className:"flex h-full min-h-0 w-full overflow-hidden bg-transparent p-2",children:[W?t.jsx(Ch,{files:ee,onCancel:()=>O(!1),onConfirm:()=>void Ae()}):null,X?t.jsxs(Sn,{direction:"vertical",className:"thread-graph-workspace-mobile-stack",children:[t.jsx(Xt,{defaultSize:42,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-explorer h-full min-h-0 overflow-hidden",children:H})}),t.jsx(Tn,{className:"thread-graph-workspace-resize-handle h-2 bg-transparent after:h-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(Xt,{defaultSize:58,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-viewer h-full min-h-0 overflow-hidden",children:ce})})]}):t.jsxs(Sn,{direction:"horizontal",className:"thread-graph-workspace-resizable",children:[t.jsx(Xt,{defaultSize:33,minSize:20,children:t.jsx("div",{className:"thread-graph-workspace-explorer-pane h-full min-h-0 overflow-hidden",children:H})}),t.jsx(Tn,{className:"thread-graph-workspace-resize-handle w-2 bg-transparent after:w-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(Xt,{defaultSize:67,minSize:30,children:t.jsx("div",{className:"thread-graph-workspace-viewer-pane h-full min-h-0 overflow-hidden",children:ce})})]}),t.jsx("input",{ref:z,type:"file","aria-label":"Workspace upload file input","data-testid":"workspace-upload-file-input",className:"hidden",onChange:R=>void pe(R)})]})}var Lr,Ao,Mo,$o,Do,Pr,Bo,Go,Fo,Ih=$e({"src/components/graph-workspace/GraphWorkspaceExplorer.tsx"(){Jn(),Nh(),Sh(),vo(),Lr=24e3,Ao="remote-codex:graphchat:workspace:expanded:",Mo="thread-graph-explorer h-full min-h-0 overflow-hidden rounded-[12px]",$o="thread-graph-explorer-header flex h-[60px] shrink-0 items-center justify-between border-b px-4",Do="text-[18px] font-semibold text-slate-900 dark:text-slate-100",Pr="thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition disabled:cursor-not-allowed disabled:opacity-50",Bo="thread-graph-explorer-collapse-button flex h-8 w-8 items-center justify-center rounded-full text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-[#222733] dark:hover:text-slate-100",Go="thread-graph-workspace-label px-3 pb-1 pt-2 text-[11px] font-semibold tracking-normal text-slate-500 dark:text-slate-400",Fo="thread-graph-workspace-empty mx-4 mt-3 rounded-lg border border-dashed border-slate-200 bg-slate-50 px-3 py-4 text-sm text-slate-500 dark:border-[#303642] dark:bg-[#1b1f29] dark:text-slate-400"}});function un({children:e}){return t.jsx("span",{className:"thread-guide-tag inline-flex items-center rounded px-1.5 py-0.5 font-mono text-[10px]",children:e})}function Ut({items:e}){return t.jsx("ul",{className:"space-y-1 text-[12px] text-[var(--theme-fg-muted)]",children:e.map((r,n)=>t.jsxs("li",{className:"flex gap-2",children:[t.jsx("span",{className:"mt-[6px] h-1 w-1 shrink-0 rounded-full bg-[var(--theme-border-contrast)]"}),t.jsx("span",{children:r})]},n))})}function zh({children:e}){return t.jsx("span",{className:"thread-guide-icon flex h-5 w-5 shrink-0 items-center justify-center rounded-md",children:e})}function nr({value:e,title:r,icon:n,children:a}){return t.jsxs(fr,{value:e,className:"thread-guide-section border-b border-[var(--theme-border)] last:border-b-0",children:[t.jsx(Ur,{className:"py-3 hover:no-underline [&[data-state=open]]:pb-2",children:t.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-[var(--theme-fg)]",children:[t.jsx(zh,{children:n}),r]})}),t.jsx(gr,{className:"space-y-3 pb-3",children:a})]})}function Rh(){return t.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[t.jsxs("div",{className:"shrink-0 border-b border-[var(--theme-border)] px-4 py-3",children:[t.jsx("h2",{className:"text-xs font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"What can I do?"}),t.jsx("p",{className:"mt-0.5 text-[11px] text-[var(--theme-fg-muted)]",children:"Upload files, ask in plain language, get results."})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-3 pb-6",children:t.jsxs(pr,{type:"multiple",defaultValue:["start","workspace","remote-codex"],className:"space-y-0",children:[t.jsxs(nr,{value:"start",title:"Getting Started",icon:t.jsx(G.Zap,{className:"h-3 w-3"}),children:[t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"graphchat connects a language model to your files and a set of tools. Each Remote Codex thread has its own isolated workspace."}),t.jsx(Ut,{items:["Upload data files via the Workspace panel","Type a question or task in plain language","The agent calls tools, writes results to the workspace, and explains what it found","Agent-produced files appear in the workspace automatically when the host reports changes"]})]}),t.jsxs(nr,{value:"workspace",title:"Workspace Explorer",icon:t.jsx(G.FolderOpen,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(G.Upload,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Upload"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Upload files through the Workspace panel when the host exposes workspace upload support. Composer attachments stay available for prompt context."})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(G.Plus,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"New files and folders"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Remote Codex normally creates files through tools and shell commands. They appear in Explorer after workspace refreshes."})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(G.MoveRight,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Move and organize"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Use the agent or terminal to reorganize files. Explorer keeps the GraphChat file tree and preview flow."})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(G.Trash2,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-rose-400"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Garbage folder"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"If the host exposes garbage controls, Explorer can permanently empty unwanted workspace files."})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(G.RefreshCw,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Refresh"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Resync the file tree manually after shell commands, external changes, or agent tool runs."})]})]}),t.jsxs("div",{className:"rounded-lg border border-[var(--theme-border)] p-2.5",children:[t.jsx("p",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"Preview surfaces"}),t.jsx(Ut,{items:[t.jsxs(t.Fragment,{children:[t.jsx(un,{children:".xyz .extxyz .cif"})," use the 3D molecule plugin."]}),t.jsxs(t.Fragment,{children:[t.jsx(un,{children:".png .jpg .gif .svg .webp"})," use inline image preview."]}),t.jsxs(t.Fragment,{children:[t.jsx(un,{children:".py .json .ts .md .csv"})," use text/code preview."]}),"Large files load in chunks when the workspace adapter supports it."]})]})]}),t.jsxs(nr,{value:"viewer",title:"Viewer",icon:t.jsx(G.FileImage,{className:"h-3 w-3"}),children:[t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Viewer is the GraphChat-style artifact surface. It opens Remote Codex artifacts through the same frontend plugin renderers used in rich message bubbles, and previews workspace files from Explorer."}),t.jsx(Ut,{items:["Expand one artifact at a time for inspection","Fallback JSON preview is available for unknown artifact types","3D molecule artifacts remain interactive when the XYZ plugin is enabled"]})]}),t.jsxs(nr,{value:"usage",title:"Tool Usage & Chat",icon:t.jsx(G.BarChart2,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(G.BarChart2,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Usage tab"}),t.jsx(Ut,{items:["Bar chart of tool and command counts for this thread","Expandable call log: inspect every input and output","Recent live events appear with persisted history"]})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(G.MessageSquare,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Chat controls"}),t.jsx(Ut,{items:["New Chat creates a fresh Remote Codex thread with its own workspace","Interrupt, compact, goal controls, and model controls remain in the composer","Shell view stays available when a shell adapter is attached"]})]})]})]}),t.jsx(nr,{value:"remote-codex",title:"Remote Codex Extras",icon:t.jsx(G.Code2,{className:"h-3 w-3"}),children:t.jsx(Ut,{items:["Slash toolbox: skills, MCP, hooks, goals, forks, model controls, provider settings","Rich message bubbles: reasoning, commands, searches, file reads, file changes, plans, action requests, artifacts","Plugin surfaces: terminal, XYZ molecule viewer, inline code renderers, and imported plugin panels","Thread metadata stays in the left rail and Workspace tab instead of replacing chat"]})})]})})]})}var _h=$e({"src/components/graph-workspace/GraphGuidePanel.tsx"(){xr()}});function Ah(e){if(e==null)return"—";if(typeof e=="string")return e.length>2e3?`${e.slice(0,2e3)}
|
|
13
|
+
...(truncated)`:e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Ha({label:e,value:r}){return t.jsxs("div",{children:[t.jsx("p",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:e}),t.jsx("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap break-words rounded bg-[var(--theme-surface-strong)] p-2 text-[11px] leading-relaxed text-[var(--theme-fg-soft)]",children:Ah(r)})]})}function Mh({event:e}){return t.jsxs(fr,{value:e.id,className:"thread-tool-call mb-2 overflow-hidden rounded-lg border border-[var(--theme-border)] last:mb-0",children:[t.jsxs(Ur,{className:"px-3 py-2 text-xs font-medium text-[var(--theme-fg)] hover:bg-[var(--theme-hover)] hover:no-underline [&[data-state=open]]:bg-[var(--theme-hover)]",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full bg-[var(--theme-accent-strong)]"}),t.jsx("span",{className:"truncate font-mono text-xs font-medium text-[var(--theme-fg)]",children:e.label}),e.status?t.jsx("span",{className:"shrink-0 rounded-full border border-[var(--theme-border)] px-1.5 py-0.5 text-[9px] uppercase tracking-[0.12em] text-[var(--theme-fg-muted)]",children:e.status}):null]}),t.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:e.turnId?t.jsx("span",{className:"max-w-20 truncate text-[10px] text-[var(--theme-fg-muted)]",children:e.turnId}):null})]}),t.jsx(gr,{className:"px-3 pb-3",children:t.jsxs("div",{className:"space-y-2 px-3 pb-3 pt-1",children:[t.jsx(Ha,{label:"Input",value:e.preview}),t.jsx(Ha,{label:"Output",value:e.detail})]})})]})}function $h({formatToolKind:e,toolCounts:r,toolEvents:n,maxToolCount:a}){const[s,o]=c.useState(()=>{var i;return((i=n.at(-1))==null?void 0:i.id)??null}),l=c.useRef(null);return c.useEffect(()=>{o(i=>{var d;return i??((d=n.at(-1))==null?void 0:d.id)??null})},[n]),c.useEffect(()=>{var i;(i=l.current)==null||i.scrollIntoView({behavior:"smooth",block:"nearest"})},[n.length]),r.length?t.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[t.jsxs("div",{className:"shrink-0 border-b border-[var(--theme-border)] p-4",children:[t.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[t.jsx("h2",{className:"text-xs font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"Calls this session"}),t.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-[var(--theme-fg-muted)] opacity-60",disabled:!0,title:"Remote Codex streams tool history from thread events",children:[t.jsx(G.RefreshCw,{className:"h-3 w-3"}),"Reload"]})]}),t.jsx("div",{className:"space-y-2",children:r.map(([i,d])=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"w-40 shrink-0 truncate text-right font-mono text-[11px] text-[var(--theme-fg-muted)]",title:e(i),children:e(i)}),t.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[t.jsx("div",{className:"relative h-4 flex-1 overflow-hidden rounded-sm bg-[var(--theme-muted)]",children:t.jsx("div",{className:"h-full rounded-sm bg-[var(--theme-accent-strong)] transition-all duration-300",style:{width:`${d/a*100}%`}})}),t.jsx("span",{className:"w-5 shrink-0 text-right text-[11px] font-medium text-[var(--theme-fg-soft)]",children:d})]})]},i))})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:[t.jsx("h2",{className:"mb-3 text-xs font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"Call log"}),t.jsx(pr,{type:"single",collapsible:!0,value:s??"",onValueChange:i=>o(i||null),className:"space-y-0",children:n.slice(-50).map(i=>t.jsx(Mh,{event:i},i.id))}),t.jsx("div",{ref:l})]})]}):t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 text-sm text-[var(--theme-fg-muted)]",children:[t.jsx("span",{children:"No tool calls yet. Run the agent to see usage."}),t.jsxs("span",{className:"inline-flex items-center gap-1 rounded px-2 py-1 text-xs",children:[t.jsx(G.RefreshCw,{className:"h-3 w-3"}),"Reload from workspace"]})]})}var Dh=$e({"src/components/graph-workspace/GraphToolUsagePanel.tsx"(){xr()}});function Oa(e,r){const n=Math.max(e.measured.width??1,1),a=Math.max(e.measured.height??1,1),s=e.internals.positionAbsolute,o=r.internals.positionAbsolute,l=Math.max(r.measured.width??1,1),i=Math.max(r.measured.height??1,1),d=n/2,h=a/2,u=s.x+d,m=s.y+h,f=o.x+l/2,p=o.y+i/2,g=(f-u)/(2*d)-(p-m)/(2*h),b=(f-u)/(2*d)+(p-m)/(2*h),v=1/(Math.abs(g)+Math.abs(b)),x=v*g,y=v*b,k=d*(x+y)+u,N=h*(-x+y)+m;return{x:k,y:N}}function Ua(e,r){const n={...e.internals.positionAbsolute,...e},a=Math.round(n.x),s=Math.round(n.y),o=Math.round(r.x),l=Math.round(r.y);return o<=a+1?Pt.Left:o>=a+(e.measured.width??1)-1?Pt.Right:l<=s+1?Pt.Top:l>=n.y+(e.measured.height??1)-1?Pt.Bottom:Pt.Top}function Ho(e,r){const n=Oa(e,r),a=Oa(r,e),s=Ua(e,n),o=Ua(r,a);return{sx:n.x,sy:n.y,tx:a.x,ty:a.y,sourcePos:s,targetPos:o}}function Bh(e,r=900,n=620){if(!e||!Array.isArray(e))return{nodes:[],edges:[]};const a=(d,h,u,m)=>{const f=new Map,p=d.length;d.forEach((g,b)=>{const v=g.id.split("").reduce((x,y)=>{const k=(x<<5)-x+y.charCodeAt(0);return k&k},0);f.set(g.id,{x:Math.abs(v)%u+b*100%u,y:Math.abs(v>>16)%m+b*150%m,vx:0,vy:0})});for(let g=0;g<200;g+=1){for(let b=0;b<p;b+=1)for(let v=b+1;v<p;v+=1){const x=d[b],y=d[v];if(!x||!y)continue;const k=f.get(x.id),N=f.get(y.id);if(!k||!N)continue;const w=k.x-N.x,j=k.y-N.y,C=Math.sqrt(w*w+j*j)||1,T=(200-C)*.5,q=w/C*T,M=j/C*T;k.vx+=q,k.vy+=M,N.vx-=q,N.vy-=M}h.forEach(b=>{const v=f.get(b.source),x=f.get(b.target);if(!v||!x)return;const y=x.x-v.x,k=x.y-v.y,N=Math.sqrt(y*y+k*k)||1,j=(N-120)*.3,C=y/N*j,L=k/N*j;v.vx+=C,v.vy+=L,x.vx-=C,x.vy-=L}),f.forEach(b=>{b.x+=b.vx*.1,b.y+=b.vy*.1,b.vx*=.9,b.vy*=.9,b.x=Math.max(80,Math.min(u-80,b.x)),b.y=Math.max(80,Math.min(m-80,b.y))})}return f},s=new Set(e.map(d=>d.id)),o=[];e.forEach(d=>{if(!d.out_node_id)return;(Array.isArray(d.out_node_id)?d.out_node_id:[d.out_node_id]).forEach(u=>{s.has(u)&&o.push({id:`${d.id}-${u}`,source:d.id,target:u,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:Is.Arrow}})})});const l=a(e,o,r,n);return{nodes:e.map(d=>({id:d.id,type:"styledNode",position:l.get(d.id)??{x:100,y:100},data:{label:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-sm font-semibold",children:d.name}),d.description?t.jsx("div",{className:"mt-1 max-w-32 overflow-hidden text-ellipsis text-xs text-slate-500 dark:text-slate-400",children:d.description}):null]})}})),edges:o}}var Qn=$e({"src/components/graph-chat/FloatingHelper.tsx"(){}});function Gh({toX:e,toY:r,fromPosition:n,toPosition:a,fromNode:s}){if(!s)return null;const o={id:"connection-target",measured:{width:1,height:1},internals:{positionAbsolute:{x:e,y:r}}},{sx:l,sy:i,tx:d,ty:h,sourcePos:u,targetPos:m}=Ho(s,o),[f]=zs({sourceX:l,sourceY:i,sourcePosition:u||n,targetPosition:m||a,targetX:d||e,targetY:h||r});return t.jsxs("g",{children:[t.jsx("path",{fill:"none",stroke:"currentColor",strokeWidth:1.5,className:"animated",d:f}),t.jsx("circle",{cx:d||e,cy:h||r,fill:"var(--theme-panel)",r:3,stroke:"currentColor",strokeWidth:1.5})]})}var Fh=$e({"src/components/graph-chat/FloatingConnectionLine.tsx"(){Qn()}});function Hh({id:e,source:r,target:n,markerEnd:a,style:s}){const o=xa(r),l=xa(n);if(!o||!l)return null;const{sx:i,sy:d,tx:h,ty:u,sourcePos:m,targetPos:f}=Ho(o,l),[p]=zs({sourceX:i,sourceY:d,sourcePosition:m,targetPosition:f,targetX:h,targetY:u});return t.jsx("path",{id:e,className:"react-flow__edge-path",d:p,markerEnd:a,style:s})}var Oh=$e({"src/components/graph-chat/FloatingEdge.tsx"(){Qn()}});function Uh({nodes:e}){const[r,n,a]=sd([]),[s,o,l]=od([]),i=c.useMemo(()=>Bh(e),[e]),d=c.useMemo(()=>({floating:Hh}),[]),h=c.useMemo(()=>({styledNode:({data:m,isConnectable:f})=>t.jsxs("div",{className:"thread-graph-flow-node",children:[m.label,t.jsx(ga,{type:"target",position:Pt.Top,isConnectable:f,style:{opacity:0,pointerEvents:"none"}}),t.jsx(ga,{type:"source",position:Pt.Bottom,isConnectable:f,style:{opacity:0,pointerEvents:"none"}})]})}),[]);c.useEffect(()=>{n(i.nodes),o(i.edges)},[i.edges,i.nodes,o,n]);const u=c.useCallback(m=>o(f=>ld({...m,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:Is.Arrow}},f)),[o]);return t.jsx("div",{className:"thread-graph-flow h-full min-h-0",children:t.jsx(id,{children:t.jsxs(dd,{nodes:r,edges:s,onNodesChange:a,onEdgesChange:l,onConnect:u,fitView:!0,nodeTypes:h,edgeTypes:d,connectionLineComponent:Gh,children:[t.jsx(cd,{}),t.jsx(hd,{gap:16})]})})})}var Wh=$e({"src/components/graph-chat/GraphVisualization.tsx"(){Fh(),Oh(),Qn()}});function Vh(e){return{...Uo,...e}}function Wa(e,r){const n=a=>{switch(a){case"workspace":return e.workspace;case"tools":return e.toolUsage;case"guide":return e.guide;case"graph":return e.threadGraph;case"extensions":return e.extensions}};return r&&n(r)?r:["workspace","tools","guide","graph","extensions"].find(n)??null}function Kh(e,r){switch(r){case"workspace":return e.workspace;case"tools":return e.toolUsage;case"guide":return e.guide;case"graph":return e.threadGraph;case"extensions":return e.extensions}}function qh(e){var s;const r=[],n=new Set(["toolCall","commandExecution","webSearch","fileRead","fileChange","agentToolCall","skillToolCall","hook"]);let a=0;for(const o of e.turns)for(const l of o.items)n.has(l.kind)&&(r.push({id:l.id,kind:l.kind,label:_r(l.kind),preview:l.previewText??l.text??l.kind,detail:l.detailText??l.text??l.previewText??l.kind,turnId:l.sourceTurnId??o.id,status:l.status??null,sequence:a}),a+=1);for(const o of((s=e.liveItems)==null?void 0:s.items)??[])n.has(o.kind)&&(r.push({id:o.id,kind:o.kind,label:_r(o.kind),preview:o.previewText??o.text??o.kind,detail:o.detailText??o.text??o.previewText??o.kind,turnId:o.sourceTurnId??null,status:o.status??null,sequence:a}),a+=1);return r}function _r(e){switch(e){case"toolCall":return"Tool call";case"agentToolCall":return"Agent tool";case"skillToolCall":return"Skill tool";case"commandExecution":return"Command";case"webSearch":return"Search";case"fileRead":return"File read";case"fileChange":return"File change";case"hook":return"Hook";default:return e.replace(/([A-Z])/g," $1").replace(/^./,r=>r.toUpperCase())}}function Xh(e){switch(e.kind){case"userMessage":return"User";case"agentMessage":return"Agent";default:return _r(e.kind)}}function Yh(e){return(e.previewText??e.text??e.detailText??e.kind).replace(/\s+/g," ").slice(0,96)}function Zh(e,r){const n=[{id:`thread:${e.thread.id}`,name:e.thread.title||"Thread",description:e.thread.model??e.thread.status},{id:`workspace:${e.workspace.id}`,name:e.workspace.label??"Workspace",description:e.workspace.absPath,out_node_id:`thread:${e.thread.id}`}];let a=null;for(const o of e.turns){const l=`turn:${o.id}`;n.push({id:l,name:`Turn ${n.filter(d=>d.id.startsWith("turn:")).length+1}`,description:o.status,out_node_id:a?[`thread:${e.thread.id}`,a]:`thread:${e.thread.id}`}),a=l;let i=null;for(const d of o.items){const h=`item:${d.id}`,u=[l];i&&u.push(i),n.push({id:h,name:Xh(d),description:Yh(d),out_node_id:u}),i=h,d.kind==="artifact"&&d.artifact&&n.push({id:`artifact:${d.artifact.id}`,name:d.artifact.title||d.artifact.type,description:d.artifact.summaryText??d.artifact.type,out_node_id:h})}}const s=new Set(n.map(o=>o.id));for(const o of r){const l=`tool:${o.id}`;s.has(l)||s.has(`item:${o.id}`)||n.push({id:l,name:o.label,description:o.preview,out_node_id:o.turnId?`turn:${o.turnId}`:`thread:${e.thread.id}`})}return n.slice(0,120)}function Oo({detail:e,status:r,plugins:n,workspaceAdapter:a,metaContent:s,settingsContent:o,activeView:l="chat",features:i,focusPathRequest:d=null}){const h=c.useMemo(()=>Vh(i),[i]),u=Wa(h,i==null?void 0:i.defaultTab),[m,f]=c.useState(u),p=c.useMemo(()=>Gc(e),[e]),g=c.useMemo(()=>qh(e),[e]),b=c.useMemo(()=>{const w=new Map;for(const j of g)w.set(j.kind,(w.get(j.kind)??0)+1);return[...w.entries()].sort((j,C)=>C[1]-j[1])},[g]),v=n.getThreadPanels(),x=Math.max(...b.map(([,w])=>w),1),y=c.useMemo(()=>Zh(e,g),[e,g]),k=c.useMemo(()=>{const w=[];return h.workspace&&w.push({id:"workspace",label:"Workspace",icon:null}),h.toolUsage&&w.push({id:"tools",label:"Tool Usage",icon:G.BarChart2}),h.guide&&w.push({id:"guide",label:"Guide",icon:G.BookOpen}),w},[h.guide,h.toolUsage,h.workspace]),N=c.useMemo(()=>{const w=[];return h.threadGraph&&w.push({id:"graph",label:"Thread graph",icon:G.GitBranch}),h.extensions&&w.push({id:"extensions",label:"Remote Codex extensions",icon:G.Wrench}),w},[h.extensions,h.threadGraph]);return c.useEffect(()=>{(!m||!Kh(h,m))&&f(Wa(h,i==null?void 0:i.defaultTab))},[m,i==null?void 0:i.defaultTab,h]),c.useEffect(()=>{d&&h.workspace&&f("workspace")},[h.workspace,d==null?void 0:d.requestId]),m?t.jsxs("div",{className:"thread-graph-right-panel flex h-full min-h-0 flex-col overflow-hidden",children:[t.jsxs("div",{className:"thread-graph-right-tabs flex shrink-0 items-center gap-1 overflow-hidden border-b px-3 py-2",children:[k.map(w=>{const j=w.icon;return t.jsxs("button",{type:"button",onClick:()=>f(w.id),className:`thread-graph-right-tab inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md px-3 text-xs font-medium transition ${m===w.id?"is-active":""}`,children:[j?t.jsx(j,{className:"h-3.5 w-3.5"}):null,w.label]},w.id)}),N.length?t.jsx("div",{className:"thread-graph-right-tab-secondary ml-auto flex min-w-0 shrink items-center gap-1 border-l pl-2","aria-label":"Remote Codex workspace extensions",children:N.map(w=>{const j=w.icon;return t.jsx("button",{type:"button",onClick:()=>f(w.id),className:`thread-graph-right-tab inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-xs font-medium transition ${m===w.id?"is-active":""}`,title:w.label,"aria-label":w.label,children:t.jsx(j,{className:"h-3.5 w-3.5"})},w.id)})}):null]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[m==="workspace"?t.jsx(Ph,{activeView:l,detail:e,artifacts:p,plugins:n,status:r,focusPathRequest:d,workspaceAdapter:a??null}):null,m==="tools"?t.jsx($h,{formatToolKind:_r,toolCounts:b,toolEvents:g,maxToolCount:x}):null,m==="graph"?t.jsx("div",{className:"thread-graph-visualization-panel h-full min-h-0 p-3",children:t.jsx(Uh,{nodes:y})}):null,m==="extensions"?t.jsx("div",{className:"h-full min-h-0 overflow-y-auto p-3",children:t.jsxs("div",{className:"grid gap-3",children:[t.jsx(Kt,{label:"Plugin Panels",children:v.length?t.jsx("div",{className:"flex flex-wrap gap-2",children:v.map(w=>t.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-1 text-xs text-[var(--theme-fg-soft)]",children:w.label},w.id))}):t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"No thread panels are enabled."})}),t.jsx(Kt,{label:"Enabled Renderers",children:t.jsx("div",{className:"flex flex-wrap gap-2",children:n.plugins.filter(w=>w.enabled).map(w=>t.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-1 text-xs text-[var(--theme-fg-soft)]",children:w.name},w.id))})}),t.jsx(Kt,{label:"Remote Codex Tools",children:t.jsxs("div",{className:"grid gap-2 text-[var(--theme-fg-muted)]",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(G.Terminal,{className:"mt-0.5 h-4 w-4 shrink-0"}),t.jsx("p",{children:"Terminal stays available when the Terminal plugin and shell adapter are attached."})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(G.Paperclip,{className:"mt-0.5 h-4 w-4 shrink-0"}),t.jsx("p",{children:"Composer attachments, slash panels, hooks, MCP, goals, and fork controls remain part of the chat surface."})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(G.Trash2,{className:"mt-0.5 h-4 w-4 shrink-0"}),t.jsx("p",{children:"Destructive actions stay explicit: delete thread, interrupt, compact, and hook trust controls remain host governed."})]})]})}),s?t.jsx(Kt,{label:"Thread Meta",children:s}):null,o?t.jsx(Kt,{label:"Settings",children:o}):null]})}):null,m==="guide"?t.jsx(Rh,{}):null]})]}):null}var Uo,Wo,Jh=$e({"src/components/ThreadGraphWorkspacePanel.tsx"(){Ih(),To(),_h(),Dh(),Jn(),Wh(),Uo={workspace:!0,toolUsage:!0,guide:!0,threadGraph:!0,extensions:!0},Wo=c.memo(Oo)}}),Vo={};Bc(Vo,{MemoizedThreadGraphWorkspacePanel:()=>Wo,ThreadGraphWorkspacePanel:()=>Oo});var Qh=$e({"src/workspace-panel.ts"(){Jh()}});function Qt(e,{insertAt:r}={}){if(!e||typeof document>"u")return;const n=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css",r==="top"&&n.firstChild?n.insertBefore(a,n.firstChild):n.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}Qt(`.thread-ui-shell,
|
|
14
14
|
.thread-graph-dialog {
|
|
15
15
|
color-scheme: light;
|
|
16
16
|
--radius: 0.625rem;
|
|
@@ -2613,7 +2613,14 @@ import{l as G,R as _i,I as Ai,H as $i,T as Di,C as Bi,S as zs,a as Gi,b as Fi,c
|
|
|
2613
2613
|
background: var(--theme-panel);
|
|
2614
2614
|
color: var(--theme-fg-muted);
|
|
2615
2615
|
}
|
|
2616
|
-
.thread-ui-shell .thread-graph-
|
|
2616
|
+
.thread-ui-shell .thread-graph-thinking-toggle {
|
|
2617
|
+
border-color: var(--theme-border);
|
|
2618
|
+
background: var(--theme-panel);
|
|
2619
|
+
color: var(--theme-fg-muted);
|
|
2620
|
+
}
|
|
2621
|
+
.thread-ui-shell .thread-graph-message-copy:hover,
|
|
2622
|
+
.thread-ui-shell .thread-graph-thinking-toggle:hover,
|
|
2623
|
+
.thread-ui-shell .thread-graph-thinking-toggle.is-open {
|
|
2617
2624
|
background: var(--theme-hover);
|
|
2618
2625
|
color: var(--theme-fg);
|
|
2619
2626
|
}
|
|
@@ -3582,11 +3589,11 @@ import{l as G,R as _i,I as Ai,H as $i,T as Di,C as Bi,S as zs,a as Gi,b as Fi,c
|
|
|
3582
3589
|
.thread-export-dialog-turn-row {
|
|
3583
3590
|
color: var(--export-fg-soft);
|
|
3584
3591
|
}
|
|
3585
|
-
`);function
|
|
3586
|
-
`)}function
|
|
3587
|
-
`).map(s=>s.trim()).filter(Boolean).find(s=>/^\[mcp_servers\.[^\]]+\]$/.test(s));if(!n)return null;const a=n.match(/^\[mcp_servers\.([A-Za-z0-9_-]+)\]$/);return(a==null?void 0:a[1])??null}function
|
|
3592
|
+
`);function eu(e){return e.replace(/\u00a0/g," ")}function tu(e,r){if(!e)return[];const n=[],a=[...r].sort((l,i)=>i.placeholder.length-l.placeholder.length);let s=0,o=0;for(;s<e.length;){const l=a.find(h=>e.startsWith(h.placeholder,s));if(l){n.push({type:"attachment",key:`${l.clientId}-${s}`,attachment:l}),s+=l.placeholder.length;continue}let i=e.length;for(const h of a){const u=e.indexOf(h.placeholder,s);u!==-1&&u<i&&(i=u)}const d=e.slice(s,i);d&&(n.push({type:"text",key:`text-${o}`,text:d}),o+=1),s=i}return n}function ru(e,r,n){const a=e==="photo"?"PHOTO":"FILE";let s=0;for(;;){const o=s===0?r:`${r} (${s+1})`,l=`[${a} ${o}]`;if(!n.has(l))return l;s+=1}}function nu(e,r,n){const a=r.start>0?e[r.start-1]:"",s=r.end<e.length?e[r.end]:"",o=!!(a&&!/\s/.test(a)),l=!s||!/\s/.test(s);return`${o?" ":""}${n.join(" ")}${l?" ":""}`}function au({files:e,kindForFile:r,usedPlaceholders:n,buildClientId:a}){return e.map(s=>{const o=r(s),l=xu(s,o),i=ru(o,bu(l),n);return n.add(i),{clientId:a(),kind:o,originalName:l,placeholder:i,file:s}})}function su({prompt:e,attachments:r,files:n,selection:a,kindForFile:s,buildClientId:o}){const l=new Set(r.map(p=>p.placeholder)),i=au({files:n,kindForFile:s,usedPlaceholders:l,buildClientId:o}),d=a?{start:a.start,end:a.end}:{start:e.length,end:e.length},h=nu(e,d,i.map(p=>p.placeholder)),u=`${e.slice(0,d.start)}${h}${e.slice(d.end)}`,m=h.endsWith(" ")?1:0,f=d.start+h.length-m;return{draft:{prompt:u,attachments:[...r,...i]},selection:{start:f,end:f},insertedAttachmentIds:i.map(p=>p.clientId)}}function ou({prompt:e,attachments:r,isShellView:n}){if(n)return{prompt:e};const a=e.trim();if(!a)return null;const s=r.filter(o=>a.includes(o.placeholder));return s.length>0?{prompt:a,attachments:s}:{prompt:a}}function lu({files:e,plainText:r,htmlText:n,htmlToText:a}){if(e.length>0)return{type:"append-files",preventDefault:!0,files:e};const s=r||a(n);return!s&&!n?{type:"ignore",preventDefault:!1}:{type:"insert-text",preventDefault:!0,text:s}}function Va(e){return e?{type:"accept-files",preventDefault:!0,activateDragTarget:!0}:{type:"ignore",preventDefault:!1,activateDragTarget:!1}}function iu(e){return e.length>0?{type:"accept-files",preventDefault:!0,activateDragTarget:!0,files:e}:{type:"ignore",preventDefault:!1,activateDragTarget:!1}}function du({key:e,metaKey:r,ctrlKey:n,busy:a,disabled:s}){const o=e==="Enter"&&(r||n);return{preventDefault:o,submit:o&&!a&&!s}}function cu({nextMode:e,previousOptimisticMode:r}){return{optimisticMode:e??null,rollbackMode:e?r:null,shouldRollbackMode:!!e,closeMenuOnSuccess:!0}}function yr(e){return`${e.prompt}${e.attachments.map(r=>`${r.clientId}${r.kind}${r.placeholder}${r.originalName}`).join("")}`}function Ka(e){if(!e)return"Auto";switch(e){case"xhigh":return"xhigh";default:return e}}function hu(e){const r=e.trim();if(!r)return null;const n=Number(r);return!Number.isFinite(n)||n<=0?Number.NaN:Math.round(n*1e3)}function uu(e){if(!e)return"";const r=e/1e3;return Number.isInteger(r)?String(r):String(Number(r.toFixed(1)))}function Rn(e){return e.replace(/\r\n/g,`
|
|
3593
|
+
`)}function mu(e){const r=e.trim();return/^[A-Za-z0-9_-]+$/.test(r)?r:null}function pu(e){const n=Rn(e).split(`
|
|
3594
|
+
`).map(s=>s.trim()).filter(Boolean).find(s=>/^\[mcp_servers\.[^\]]+\]$/.test(s));if(!n)return null;const a=n.match(/^\[mcp_servers\.([A-Za-z0-9_-]+)\]$/);return(a==null?void 0:a[1])??null}function fu(e,r){return`[mcp_servers.${e}]
|
|
3588
3595
|
url = ${JSON.stringify(r.trim())}
|
|
3589
|
-
`}function
|
|
3596
|
+
`}function qa(e,r,n){var m,f;const a=Rn(e),s=`${Rn(n).trim()}
|
|
3590
3597
|
`,o=a.split(`
|
|
3591
3598
|
`),l=`[mcp_servers.${r}]`,i=`[mcp_servers.${r}.`;let d=-1,h=o.length;for(let p=0;p<o.length;p+=1)if((((m=o[p])==null?void 0:m.trim())??"")===l){d=p;break}if(d>=0){for(let b=d+1;b<o.length;b+=1){const v=((f=o[b])==null?void 0:f.trim())??"";if(v.startsWith("[")&&!(v===l||v.startsWith(i))){h=b;break}}const p=o.slice(0,d).join(`
|
|
3592
3599
|
`).trimEnd(),g=o.slice(h).join(`
|
|
@@ -3597,28 +3604,28 @@ url = ${JSON.stringify(r.trim())}
|
|
|
3597
3604
|
`).concat(`
|
|
3598
3605
|
`)}const u=a.trimEnd();return u?`${u}
|
|
3599
3606
|
|
|
3600
|
-
${s}`:s}function qo(e){return typeof e!="number"||Number.isNaN(e)?0:Math.max(0,Math.min(100,Math.round(e)))}function mn(e){const r=e/1e3;return Number.isInteger(r)?`${r}k`:`${Number(r.toFixed(1))}k`}function xu(e,r){if(!e)return"Select model";if((r==null?void 0:r.availability)!=="available"||typeof r.tokensInContextWindow!="number"||typeof r.modelContextWindow!="number")return`${e} · context unavailable`;const n=Math.max(r.tokensInContextWindow,0),a=Math.max(r.modelContextWindow,0),s=Math.max(a-n,0);return[e,`${mn(n)} used / ${mn(a)}`,`${mn(s)} left`,`${qo(r.remainingPercent)}% context left`].join(" · ")}function bu(e,r){const n=e.name.trim();if(n)return n;const a=r==="photo"?e.type.includes("png")?".png":e.type.includes("heic")?".heic":e.type.includes("heif")?".heif":e.type.includes("webp")?".webp":".jpg":"";return`${r==="photo"?"photo":"file"}-${Date.now()}${a}`}function vu(e){return e.replace(/[\r\n[\]]+/g," ").replace(/\s+/g," ").trim()||"attachment"}function _n(e){return e.type.startsWith("image/")?"photo":"file"}function An(e,r){const n=[];if(e)for(const a of Array.from(e)){if(a.kind!=="file")continue;const s=a.getAsFile();s&&n.push(s)}return n.length>0?n:r?Array.from(r):[]}function Ya(e,r){return An(e,r).length>0}function ku(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function Za(e){const r=e.placeholder.match(/^\[(?:PHOTO|FILE)\s+(.+)\]$/);return r!=null&&r[1]?r[1]:ku(e.originalName)}var Ar=[{value:"preToolUse",label:"PreToolUse",matcherHint:"Bash"},{value:"permissionRequest",label:"PermissionRequest",matcherHint:"Bash"},{value:"postToolUse",label:"PostToolUse",matcherHint:"Bash"},{value:"sessionStart",label:"SessionStart",matcherHint:"startup|resume"},{value:"userPromptSubmit",label:"UserPromptSubmit",matcherHint:""},{value:"stop",label:"Stop",matcherHint:""},{value:"preCompact",label:"PreCompact",matcherHint:""},{value:"postCompact",label:"PostCompact",matcherHint:""}];function wu({goalComposeMode:e,goalBusy:r,threadConnected:n,busy:a,isShellView:s,disabledPlaceholder:o,settingsBusy:l,supportedEffortCount:i,fastMode:d}){const h=e?"Describe the goal the backend should continue working toward...":o??(s?"Send shell input to the attached terminal...":"Ask the backend to inspect, modify, or explain code..."),u=e?r?"Setting...":"Set goal":!n&&a?"Connecting...":n&&a&&!s?"Sending...":"Send",m=n?e?"ui-action-info":"ui-action-primary":"ui-action-danger",f=l;return{promptPlaceholder:h,interruptLabel:s?"Send Ctrl-C":"Stop Current Turn",sendButtonLabel:u,sendButtonClassName:m,modelControlsDisabled:f,effortControlsDisabled:f||i===0,effortControlTitle:d?"Fast mode is on. Turn it off from the slash toolbox to edit reasoning.":i===0?"The selected model does not expose adjustable reasoning effort.":"Select reasoning effort"}}function yu({isShellView:e,edgeToEdgeMobile:r,isMobileShell:n,openMenu:a,isDragTargetActive:s,busy:o}){const l=e?"thread-composer-layer thread-shell-composer-layer":"thread-graph-composer-layer",i=e?"thread-composer-form":"thread-graph-composer-form",d=e?"thread-composer-form-floating":"thread-graph-composer-form-floating",h=e?"thread-composer-input":"thread-graph-composer-input";return{composerLayerClassName:a?`${l} relative z-[80] shrink-0`:`${l} relative z-20 shrink-0`,formClassName:e?r||n?`${i} ${d} relative z-20 shrink-0 border-t border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`:`${i} relative z-20 shrink-0 border-t border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`:`${i} ${r?d:""} relative z-20 shrink-0 border-t px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`,composerShellClassName:e?"thread-composer-shell":"thread-graph-composer-shell",composerToolbarClassName:e?"thread-composer-toolbar":"thread-graph-composer-toolbar",composerInputClassName:h,composerIconButtonClassName:e?"thread-composer-icon-button":"thread-graph-composer-icon-button",composerMenuClassName:e?"thread-composer-menu":"thread-graph-composer-menu",composerMenuItemClassName:e?"thread-composer-menu-item":"thread-graph-composer-menu-item",composerInlineToggleClassName:e?"thread-composer-inline-toggle":"thread-graph-composer-inline-toggle",composerPanelButtonClassName:e?"thread-composer-panel-button":"thread-graph-composer-panel-button",composerChipButtonClassName:e?"thread-composer-chip-button":"thread-graph-composer-chip-button",composerPlanToggleActiveClassName:e?"thread-composer-plan-toggle-active":"thread-graph-composer-plan-toggle-active",composerSendButtonClassName:e?"thread-composer-send-button":"thread-graph-composer-send-button",composerPromptRegionClassName:e?"thread-composer-prompt-region":"thread-graph-composer-prompt-region",promptInputClassName:`${h} min-h-[5.25rem] w-full px-4 pr-14 pt-3 outline-none transition sm:min-h-[5.75rem] ${s?"is-drag-target border-sky-300/80 bg-sky-300/[0.08] shadow-[0_0_0_1px_rgba(125,211,252,0.2)]":""}`,graphChatInputGroupClassName:`thread-graph-composer-input-group relative border-0 bg-transparent shadow-none ring-0 ${o?"bg-amber-50/40 dark:bg-amber-400/10":"bg-transparent"}`,graphChatInputClassName:`${h} min-h-[68px] max-h-32 w-full overflow-y-auto px-3 pt-3 text-[16px] leading-relaxed text-slate-800 outline-none transition sm:min-h-[92px] sm:max-h-40 sm:px-4 sm:pt-4 sm:text-[14px] dark:text-slate-100 ${s?"is-drag-target bg-sky-300/[0.08] shadow-[0_0_0_1px_rgba(125,211,252,0.2)]":""}`}}function ju(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"m4 5 2 2-2 2"}),t.jsx("path",{d:"M7.75 9.5h4.25"})]})}function Nu(){return t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",children:t.jsx("path",{d:"M8 3.25v9.5M3.25 8h9.5"})})}function Cu(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M10.75 2.5 5.25 13.5"}),t.jsx("path",{d:"M4.25 5.25h2.25"}),t.jsx("path",{d:"M9.5 10.75h2.25"})]})}function Su(){return t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3 4.5A1.75 1.75 0 0 1 4.75 2.75h6.5A1.75 1.75 0 0 1 13 4.5v4A1.75 1.75 0 0 1 11.25 10.25H8l-2.75 2v-2H4.75A1.75 1.75 0 0 1 3 8.5v-4Z"})})}function Tu(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",className:"h-3.5 w-3.5 fill-current",children:[t.jsx("path",{fillRule:"evenodd",d:"M14.5 10C16.9853 10 19 7.98528 19 5.5C19 5.01783 18.9242 4.55338 18.7838 4.11791C18.6792 3.79367 18.2734 3.72683 18.0325 3.96772L15.3402 6.66002C15.2098 6.79041 15.0168 6.84163 14.8466 6.77074C14.1172 6.46695 13.5334 5.88351 13.2292 5.15431C13.1582 4.98403 13.2094 4.79088 13.3398 4.66042L16.0327 1.9676C16.2735 1.72672 16.2067 1.32092 15.8825 1.21636C15.4469 1.07588 14.9823 1 14.5 1C12.0147 1 10 3.01472 10 5.5C10 5.59783 10.0031 5.69494 10.0093 5.79122C10.065 6.66418 9.88174 7.59855 9.20974 8.15855L1.98017 14.1832C1.3591 14.7008 1 15.4674 1 16.2759C1 17.7804 2.21962 19 3.7241 19C4.53256 19 5.29925 18.6409 5.81681 18.0198L11.8414 10.7903C12.4014 10.1183 13.3358 9.93497 14.2088 9.99073C14.3051 9.99688 14.4022 10 14.5 10ZM5 16C5 16.5523 4.55228 17 4 17C3.44772 17 3 16.5523 3 16C3 15.4477 3.44772 15 4 15C4.55228 15 5 15.4477 5 16Z",clipRule:"evenodd"}),t.jsx("path",{d:"M14.5 11.5C14.6731 11.5 14.8445 11.4927 15.0138 11.4783L18.7678 15.2323C19.7441 16.2086 19.7441 17.7915 18.7678 18.7678C17.7915 19.7441 16.2086 19.7441 15.2323 18.7678L10.8216 14.3571L12.9938 11.7505C13.0455 11.6885 13.1413 11.6131 13.3357 11.5552C13.5378 11.4951 13.805 11.468 14.1132 11.4877C14.2413 11.4959 14.3702 11.5 14.5 11.5Z"}),t.jsx("path",{d:"M6.00003 4.58582L8.33056 6.91635C8.3027 6.95627 8.27496 6.98497 8.24946 7.00622L6.79994 8.21415L4.58582 6.00003H3.30905C3.11966 6.00003 2.94653 5.89303 2.86184 5.72364L1.1612 2.32237C1.06495 2.12987 1.10268 1.89739 1.25486 1.74521L1.74521 1.25486C1.89739 1.10268 2.12987 1.06495 2.32237 1.1612L5.72364 2.86184C5.89303 2.94653 6.00003 3.11966 6.00003 3.30905V4.58582Z"})]})}function $n(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5.5 3.25h5"}),t.jsx("path",{d:"M6.4 2h3.2a.9.9 0 0 1 .9.9v.35h1.3a1.2 1.2 0 0 1 1.2 1.2v7.35a1.2 1.2 0 0 1-1.2 1.2H4.2A1.2 1.2 0 0 1 3 11.8V4.45a1.2 1.2 0 0 1 1.2-1.2h1.3V2.9a.9.9 0 0 1 .9-.9Z"})]})}function Eu(e){switch(e){case"bearerToken":return"Token";case"oAuth":return"OAuth";case"notLoggedIn":return"Login";case"unsupported":return"Public";default:return"Unknown"}}function Lu(e){switch(e){case"repo":return"Repo";case"system":return"System";case"admin":return"Admin";case"user":default:return"User"}}function Pu(e){var r;return((r=Ar.find(n=>n.value===e))==null?void 0:r.label)??e}function zu(e){var r;switch(e){case"cloudRequirements":return"Cloud";case"legacyManagedConfigFile":case"legacyManagedConfigMdm":return"Managed";case"sessionFlags":return"Session";default:return((r=e[0])==null?void 0:r.toUpperCase())+e.slice(1)}}function Iu(e){switch(e){case"managed":return"Managed";case"modified":return"Modified";case"trusted":return"Trusted";case"untrusted":return"Review"}}function Ru(e){switch(e){case"preToolUse":return"PreToolUse";case"permissionRequest":return"PermissionRequest";case"postToolUse":return"PostToolUse";case"preCompact":return"PreCompact";case"postCompact":return"PostCompact";case"sessionStart":return"SessionStart";case"userPromptSubmit":return"UserPromptSubmit";case"stop":return"Stop"}}function Mu(e){return e.source==="user"?"global":e.source==="project"?"project":null}function Xo(e){const r=Mu(e);return!r||e.handlerType!=="command"||!e.command||e.isManaged?null:{scope:r,eventName:e.eventName,matcher:e.matcher,command:e.command,timeoutSec:e.timeoutSec,statusMessage:e.statusMessage}}function _u(e){switch(e){case"active":return"Active";case"paused":return"Paused";case"budgetLimited":return"Budget";case"complete":return"Complete";default:return e}}function Au({contextUsage:e}){const r=(e==null?void 0:e.availability)??"unavailable",n=qo(e==null?void 0:e.remainingPercent);if(r!=="available")return null;const a=n<=20?"rgba(251,113,133,0.90)":n<=40?"rgba(252,211,77,0.85)":"rgba(125,211,252,0.80)";return t.jsx("span",{"aria-hidden":"true",className:"thread-context-progress-track pointer-events-none mt-0.5 block",children:t.jsx("span",{className:"thread-context-progress-fill block",style:{width:`${n}%`,backgroundColor:a}})})}function Lt({label:e,tone:r="stone"}){const n=r==="rose"?"border-rose-300/35 bg-rose-300/14 text-rose-50":r==="sky"?"border-sky-300/35 bg-sky-300/14 text-sky-50":"border-stone-700/90 bg-stone-900/80 text-stone-100";return t.jsx("span",{className:`inline-flex min-w-[3rem] items-center justify-center rounded-full border px-2 py-1.5 text-[10px] font-medium tracking-[0.12em] ${n}`,children:e})}function $u(e,r){return(e??[]).filter(n=>{switch(n.action){case"fast":return r.fast;case"compact":return r.compact;case"goal":return r.goal;case"fork":return r.fork;case"skills":return r.skills;case"mcp":return r.mcp;case"hooks":return r.hooks;case"prompt":case"unsupported":return!0;default:return!1}})}function Du(e,{fastMode:r,goalComposeMode:n}){switch(e.action){case"fast":return{type:"toggleFast",fastMode:!r};case"compact":return{type:"runCompact"};case"goal":return n?{type:"exitGoalCompose"}:{type:"enterGoalCompose"};case"fork":case"skills":case"mcp":case"hooks":return{type:"openPanel",panel:e.action};case"prompt":return{type:"insertPrompt",text:`${e.command} `};default:return{type:"noop"}}}function Bu(e,{fastMode:r,compactBusy:n,goalComposeMode:a,goalStatus:s,busy:o}){switch(e.action){case"fast":return r?"On":"Off";case"compact":return n?"Busy":"Run";case"goal":return a?"Composing":s?_u(s):"Open";case"fork":return o?"Idle only":"Open";case"skills":case"mcp":case"hooks":return"View";case"prompt":return"Compose";case"unsupported":return"Unavailable";default:return""}}function Gu(e,{settingsBusy:r,compactBusy:n,busy:a,forkBusy:s}){switch(e.action){case"fast":return r;case"compact":return n||a;case"fork":return a||s;case"unsupported":return!0;default:return!1}}function Fu(e,{fastMode:r,goalComposeMode:n,goalStatus:a,menuItemClassName:s}){return`${e.action==="fast"&&r||e.action==="goal"&&(n||a==="active")?"ui-status-warning":s} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`}function Hu(e){if(!e)return"";const r=document.createElement("div");return r.innerHTML=e,r.textContent??""}function Ou(e){return!!e.querySelector("[style], font")}function zt(e){return e instanceof HTMLElement&&e.dataset.segmentType==="attachment"&&e.dataset.placeholder?e.dataset.placeholder:e.textContent??""}function Yo(e){let r="";for(const n of Array.from(e.childNodes))r+=zt(n);return r.replace(/\u00a0/g," ")}function Ja(e,r,n){var i;let a=null,s=n;if(r===e){const d=Array.from(e.childNodes);let h=0;for(let u=0;u<Math.min(n,d.length);u+=1){const m=d[u];m&&(h+=zt(m).length)}return h}if(r.nodeType===Node.TEXT_NODE)a=r;else{const d=Array.from(e.childNodes).find(h=>h.contains(r));if(!d)return Yo(e).length;if(a=d,d instanceof HTMLElement&&d.dataset.segmentType==="attachment"){const h=document.createRange();h.selectNodeContents(d);const u=zt(d).length;try{h.setEnd(r,n);const m=h.toString().length,f=((i=d.textContent)==null?void 0:i.length)??0;f===0?s=u:s=Math.round(Math.min(1,m/f)*u)}catch{s=u}}else{const h=document.createRange();h.selectNodeContents(d);try{h.setEnd(r,n),s=h.toString().length}catch{s=zt(d).length}}}const o=Array.from(e.childNodes);let l=0;for(const d of o){if(d===a)return d.nodeType===Node.TEXT_NODE?l+s:l+Math.min(s,zt(d).length);l+=zt(d).length}return l}function Uu(e){const r=window.getSelection();if(!r||r.rangeCount===0)return null;const n=r.getRangeAt(0);return!e.contains(n.startContainer)||!e.contains(n.endContainer)?null:{start:Ja(e,n.startContainer,n.startOffset),end:Ja(e,n.endContainer,n.endOffset)}}function Qa(e,r){let n=Math.max(0,r);const a=Array.from(e.childNodes);for(const[s,o]of a.entries()){const i=zt(o).length;if(o.nodeType===Node.TEXT_NODE){if(n<=i)return{node:o,offset:n};n-=i;continue}if(o instanceof HTMLElement&&o.dataset.segmentType==="attachment"){if(n===0)return{node:e,offset:s};if(n<=i){const d=a[s+1];return n===i&&(d==null?void 0:d.nodeType)===Node.TEXT_NODE?{node:d,offset:0}:{node:e,offset:s+1}}n-=i;continue}if(n<=i)return{node:e,offset:s+1};n-=i}return{node:e,offset:e.childNodes.length}}function Wu(e,r){const n=Qa(e,r.start),a=Qa(e,r.end),s=document.createRange();s.setStart(n.node,n.offset),s.setEnd(a.node,a.offset);const o=window.getSelection();o==null||o.removeAllRanges(),o==null||o.addRange(s)}function Vu(e,r){if(r.length===0)return!1;const n=r.at(-1);if(!n)return!1;const a=Array.from(e.childNodes).find(i=>i instanceof HTMLElement&&i.dataset.segmentType==="attachment"&&i.dataset.clientId===n);if(!(a instanceof HTMLElement))return!1;const s=document.createRange(),o=a.nextSibling;(o==null?void 0:o.nodeType)===Node.TEXT_NODE?s.setStart(o,0):s.setStartAfter(a),s.collapse(!0);const l=window.getSelection();return l==null||l.removeAllRanges(),l==null||l.addRange(s),!0}Ur();Nt();function Ku({className:e,...r}){return t.jsx("div",{"data-slot":"input-group",role:"group",className:et("group/input-group relative flex w-full min-w-0 items-center rounded-md border shadow-xs outline-none transition-[color,box-shadow]","h-9 has-[>textarea]:h-auto","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col",e),...r})}var qu=mr("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*=size-])]:size-4",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.45rem]","block-start":"order-first w-full justify-start px-3 pt-3","block-end":"order-last w-full justify-start px-3 pb-3"}},defaultVariants:{align:"inline-start"}});function Xu({className:e,align:r="inline-start",...n}){return t.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":r,className:et(qu({align:r}),e),onClick:a=>{var o;if(a.target.closest("button"))return;const s=(o=a.currentTarget.parentElement)==null?void 0:o.querySelector('[data-slot="input-group-control"] [contenteditable="true"], [data-slot="input-group-control"] textarea, [data-slot="input-group-control"] input, [data-slot="input-group-control"]');s==null||s.focus()},...n})}var Yu=mr("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*=size-])]:size-3.5",sm:"h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function xt({className:e,type:r="button",variant:n="ghost",size:a="xs",...s}){return t.jsx(ur,{type:r,"data-size":a,variant:n,className:et(Yu({size:a}),e),...s})}function Zu({className:e,...r}){return t.jsx("span",{className:et("flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*=size-])]:size-4",e),...r})}function Ju({photoInputRef:e,fileInputRef:r,onAppendAttachments:n}){function a(s,o){n(s.target.files,o),s.target.value=""}return t.jsxs(t.Fragment,{children:[t.jsx("input",{ref:e,type:"file",accept:"image/*",multiple:!0,tabIndex:-1,className:"sr-only",onChange:s=>a(s,"photo")}),t.jsx("input",{ref:r,type:"file",multiple:!0,tabIndex:-1,className:"sr-only",onChange:s=>a(s,"file")})]})}function Qu({activeView:e,followTail:r,onToggleFollow:n}){return e!=="chat"?null:t.jsx("button",{type:"button","aria-label":"Jump to latest",title:r?"Latest turn is in view":"Jump to the latest messages",onClick:()=>n==null?void 0:n(),className:"absolute left-1/2 top-0 z-[90] inline-flex h-11 min-w-[7rem] -translate-x-1/2 -translate-y-full items-end justify-center bg-transparent pb-1 touch-manipulation sm:h-10",children:t.jsx("span",{className:`thread-jump-latest-badge pointer-events-none inline-flex h-4 min-w-[3.75rem] items-center justify-center rounded-[0.7rem] border shadow-sm transition ${r?"is-active border-sky-300/36 bg-sky-300/[0.03] text-sky-100/86":"border-stone-500/70 bg-stone-950/[0.08] text-stone-200/86"}`,children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m4 6 4 4 4-4"})})})})}function em({activeView:e,layerClassName:r,formClassName:n,shellClassName:a,inputGroupClassName:s,error:o,followTail:l,photoInputRef:i,fileInputRef:d,onAppendAttachments:h,onToggleFollow:u,onSubmit:m,formRef:f,promptSlot:p,toolbarSlot:g,goalSlot:b,shellPromptSlot:v}){return t.jsxs("div",{className:r,children:[t.jsx(Ju,{photoInputRef:i,fileInputRef:d,onAppendAttachments:h}),t.jsx(Qu,{activeView:e,followTail:l,onToggleFollow:u}),t.jsxs("form",{ref:f,"data-testid":e==="chat"?"chat-composer":void 0,onSubmit:m,className:n,children:[t.jsxs("div",{className:`${a} flex w-full flex-col overflow-visible rounded-[16px] sm:rounded-[18px]`,children:[t.jsxs(Ku,{className:s,children:[p,g]}),b,v]}),o?t.jsx("div",{className:"mt-2 rounded-2xl border border-rose-500/40 bg-rose-500/10 px-4 py-3 text-sm text-rose-200",children:o}):null]})]})}function tm({open:e,iconButtonClassName:r,menuClassName:n,menuItemClassName:a,onToggle:s,onPickPhoto:o,onPickFile:l}){return t.jsxs("div",{className:"relative",children:[t.jsx(xt,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Add attachment",title:"Add attachment",onClick:s,className:`${r} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx(Nu,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${n} absolute bottom-full left-0 mb-2 w-32 overflow-hidden rounded-2xl border bg-stone-900/72 shadow-2xl shadow-stone-950/20`,children:t.jsxs("div",{className:"p-2",children:[t.jsx("button",{type:"button",onClick:o,className:`${a} block w-full rounded-xl px-3 py-2 text-left text-sm transition`,children:"Photo"}),t.jsx("button",{type:"button",onClick:l,className:`${a} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition`,children:"File"})]})})]})}var Zo=[{mode:"read-only",label:"Read only"},{mode:"workspace-write",label:"Workspace write"},{mode:"danger-full-access",label:"Danger"}];function es(e){var r;return((r=Zo.find(n=>n.mode===e))==null?void 0:r.label)??"Default"}function rm({openMenu:e,model:r,modelOptions:n,modelContextTitle:a,contextUsage:s,reasoningEffort:o,supportedEfforts:l,displayedCollaborationMode:i,sandboxMode:d,planModeAvailable:h,sandboxModeAvailable:u,settingsBusy:m,goalComposeMode:f,goalBusy:p,activeView:g,disabled:b,fastMode:v,sendButtonLabel:x,sendButtonClassName:y,modelControlsDisabled:k,effortControlsDisabled:j,effortControlTitle:w,inlineToggleClassName:N,menuItemClassName:S,planToggleActiveClassName:L,sendButtonBaseClassName:T,onSetOpenMenu:q,onUpdateSettings:A}){return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative min-w-0",children:[t.jsx(xt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="model","aria-label":r??"Select model",disabled:k||n.length===0,onClick:()=>q(D=>D==="model"?null:"model"),title:v?`Fast mode is on. Turn it off from the slash toolbox to edit model. ${a}`:a,className:`${N} relative min-w-0 max-w-[8.75rem] overflow-hidden rounded-full px-2.5 text-left text-stone-300 disabled:cursor-not-allowed disabled:text-stone-600 sm:max-w-[11rem]`,children:t.jsx("span",{className:"relative z-[1] block min-w-0 truncate whitespace-nowrap [direction:rtl]",children:r??"Select model"})}),r?t.jsx(Au,{contextUsage:s}):null,e==="model"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[9rem] max-w-[14rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:n.map(D=>t.jsx("button",{type:"button",onClick:()=>A({model:D.model,reasoningEffort:D.defaultReasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${D.model===r?"ui-status-warning":`${S} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:D.model})},D.id))})})]}),t.jsxs("div",{className:"relative",children:[t.jsx(xt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="effort",disabled:j,onClick:()=>q(D=>D==="effort"?null:"effort"),title:w,className:`${N} rounded-full px-2 disabled:cursor-not-allowed disabled:text-stone-700 ${j?"text-stone-500":"text-stone-300 hover:text-stone-100"}`,children:qa(o)}),e==="effort"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[8rem] max-w-[12rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:l.map(D=>t.jsx("button",{type:"button",onClick:()=>A({reasoningEffort:D.reasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${D.reasoningEffort===o?"ui-status-warning":`${S} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:qa(D.reasoningEffort)})},D.reasoningEffort))})})]}),u&&t.jsxs("div",{className:"relative",children:[t.jsx(xt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="sandbox","aria-label":`Sandbox: ${es(d)}`,disabled:m,onClick:()=>q(D=>D==="sandbox"?null:"sandbox"),title:`Sandbox: ${es(d)}`,className:`${N} rounded-full px-2.5 text-stone-300 disabled:cursor-not-allowed disabled:text-stone-700`,children:"Sandbox"}),e==="sandbox"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[9rem] max-w-[13rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:Zo.map(D=>t.jsx("button",{type:"button",onClick:()=>A({sandboxMode:D.mode}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${D.mode===d?"ui-status-warning":`${S} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:D.label})},D.mode))})})]}),h&&t.jsx(xt,{type:"button",variant:"ghost",size:"xs","aria-pressed":i==="plan",disabled:m,onClick:()=>A({collaborationMode:i==="plan"?"default":"plan"}),className:`${N} rounded-full px-2.5 ${i==="plan"?`${L} border !border-[oklch(0.78_0.16_86_/_0.76)] !bg-[oklch(0.44_0.095_82_/_0.72)] !text-[oklch(0.96_0.055_92)] shadow-[0_0_0_1px_oklch(0.78_0.16_86_/_0.24),0_0_18px_oklch(0.78_0.16_86_/_0.42),inset_0_0_0_1px_oklch(0.98_0.04_96_/_0.18)]`:"text-stone-500"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Plan"}),t.jsx(xt,{type:"submit",variant:"default",size:"icon-xs","aria-label":f?"Set goal":"Send Prompt",title:x,disabled:p||(g==="chat"?b:!1),className:`${T} h-9 w-9 rounded-full text-sm font-medium disabled:cursor-not-allowed sm:h-8 sm:w-8 ${y}`,children:t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-none stroke-current",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M8 13V3"}),t.jsx("path",{d:"m4 7 4-4 4 4"})]})})]})}function nm({busy:e,shellControlState:r,onPaste:n,onCopy:a,onClear:s,onShellControl:o}){const l=!!(r!=null&&r.shellInputEnabled),i=!!(r!=null&&r.isCommandRunning);return t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute right-0 top-full z-40 mt-2 w-[11.5rem] max-w-[calc(100vw-1.5rem)] rounded-[1rem] border border-stone-700/90 bg-stone-950/96 p-2 shadow-2xl shadow-stone-950/40 sm:w-48",onMouseDown:d=>{d.stopPropagation()},onPointerDown:d=>{d.stopPropagation()},onTouchStart:d=>{d.stopPropagation()},children:t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx("button",{type:"button",onClick:n,className:"inline-flex items-center justify-center rounded-full border border-sky-300/35 bg-sky-300/12 px-2 py-2 text-sky-50",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx($n,{}),t.jsx("span",{className:"text-[10px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:a,className:"inline-flex items-center justify-center rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-2 text-stone-100",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx($n,{}),t.jsx("span",{className:"text-[10px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:e,onClick:s,className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Lt,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!l||!i,onClick:()=>o("ctrl_c"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Lt,{label:"CTRL-C",tone:"rose"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("ctrl_d"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Lt,{label:"CTRL-D"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("esc"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Lt,{label:"ESC"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("tab"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Lt,{label:"TAB"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("up"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Lt,{label:"UP"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("down"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Lt,{label:"DOWN"})})]})})}function am({busy:e,forkBusy:r,composerMenuItemClassName:n,onForkLatest:a,onSelectForkTurnPanel:s}){return t.jsxs("div",{className:"p-2",children:[t.jsx("button",{type:"button",disabled:e||r,onClick:()=>void a(),className:`${n} block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:"Fork from latest"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:r?"Forking":"Run"})]})}),t.jsx("button",{type:"button",disabled:e||r,onClick:o=>{o.stopPropagation(),s()},className:`${n} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:"Fork from selected turn"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:"Pick"})]})}),e?t.jsx("p",{className:"mt-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Fork is only available while the thread is idle."}):null]})}function sm({forkTurnOptionsState:e,forkBusy:r,composerPanelButtonClassName:n,onForkTurn:a}){var s,o;return t.jsxs("div",{className:"p-2",children:[e.status==="loading"&&!e.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading turns..."}):null,e.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:e.error}):null,(s=e.data)!=null&&s.length?t.jsx("div",{className:"space-y-2",children:e.data.map(l=>t.jsx("button",{type:"button",disabled:r,onClick:()=>void a(l.turnId),className:`${n} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("span",{className:"text-sm text-stone-100",children:["Turn ",l.turnIndex]}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:r?"Forking":l.status})]})},l.turnId))}):null,e.status!=="loading"&&!e.error&&(((o=e.data)==null?void 0:o.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No turns available to fork yet."}):null]})}function om({hooksPanelMode:e,hooksState:r,hostConfigFilesAvailable:n,hookTrustAvailable:a,hookConfigBusy:s,hookConfigError:o,hookConfigSuccess:l,editingHookTarget:i,hookScope:d,hookEventName:h,hookMatcher:u,hookCommand:m,hookTimeoutSec:f,hookStatusMessage:p,composerChipButtonClassName:g,onResetHookForm:b,onSetHooksPanelMode:v,onClearHookConfigStatus:x,onSetEditingHookTarget:y,onSetHookScope:k,onSetHookEventName:j,onSetHookMatcher:w,onSetHookCommand:N,onSetHookTimeoutSec:S,onSetHookStatusMessage:L,onSaveHook:T,onStartEditingHook:q,onTrustHook:A,onUntrustHook:D}){var J,W,O,ee,he;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"Hook config sources"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:((J=r.data)==null?void 0:J.projectHooksPath)??"<workspace hooks config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:E=>{E.stopPropagation(),b(),v("add"),x()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add Hook"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading hooks..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,o?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:o}):null,l?t.jsx("p",{className:"mb-2 rounded-xl border border-emerald-500/35 bg-emerald-500/10 px-3 py-3 text-sm text-emerald-100/90",children:l}):null,e==="add"||e==="edit"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[e==="edit"?t.jsxs("p",{className:"rounded-lg border border-stone-800 bg-stone-950 px-3 py-2 text-[11px] text-stone-400",children:["Editing"," ",Ru((i==null?void 0:i.eventName)??h)," ","in ",(i==null?void 0:i.scope)==="global"?"global":"project"," ","hooks.json"]}):null,t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("label",{className:"block text-xs text-stone-400",children:["Scope",t.jsxs("select",{"aria-label":"Hook scope",value:d,onChange:E=>k(E.target.value),disabled:e==="edit",className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-2.5 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50",children:[t.jsx("option",{value:"project",children:"Project"}),t.jsx("option",{value:"global",children:"Global"})]})]}),t.jsxs("label",{className:"block text-xs text-stone-400",children:["Event",t.jsx("select",{"aria-label":"Hook event",value:h,onChange:E=>j(E.target.value),className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-2.5 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50",children:Ar.map(E=>t.jsx("option",{value:E.value,children:E.label},E.value))})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"Matcher"}),t.jsx("input",{"aria-label":"Hook matcher",value:u,onChange:E=>w(E.target.value),placeholder:"Bash",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"Command"}),t.jsx("textarea",{"aria-label":"Hook command",value:m,onChange:E=>N(E.target.value),rows:3,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 font-mono text-xs text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("label",{className:"block text-xs text-stone-400",children:["Timeout",t.jsx("input",{"aria-label":"Hook timeout seconds",value:f,onChange:E=>S(E.target.value),inputMode:"numeric",className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50"})]}),t.jsxs("label",{className:"block text-xs text-stone-400",children:["Status message",t.jsx("input",{"aria-label":"Hook status message",value:p,onChange:E=>L(E.target.value),className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50"})]})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>{v("list"),y(null)},className:`${g} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void T(),disabled:s,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:s?"Saving...":e==="edit"?"Update Hook":"Write Hook"})]})]}):null,e==="list"&&((W=r.data)!=null&&W.warnings.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.warnings.map(E=>t.jsx("p",{className:"rounded-xl border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-100/85",children:E},E))}):null,e==="list"&&((O=r.data)!=null&&O.errors.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.errors.map(E=>t.jsxs("div",{className:"rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-2 text-xs text-rose-100/90",children:[t.jsx("p",{className:"font-medium",children:E.message}),t.jsx("p",{className:"mt-1 break-all text-rose-100/60",children:E.path})]},`${E.path}:${E.message}`))}):null,e==="list"&&((ee=r.data)!=null&&ee.hooks.length)?t.jsx("div",{className:"space-y-2",children:r.data.hooks.map(E=>t.jsxs("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("p",{className:"truncate text-sm font-medium text-stone-100",children:[Pu(E.eventName),E.matcher?` · ${E.matcher}`:""]}),t.jsx("p",{className:"mt-0.5 truncate font-mono text-[11px] text-stone-400",children:E.command??E.handlerType}),E.statusMessage?t.jsx("p",{className:"mt-1 truncate text-[11px] text-stone-500",children:E.statusMessage}):null]}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.08em] text-stone-500",children:[Xo(E)?t.jsx("button",{type:"button",onClick:re=>{re.stopPropagation(),q(E)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-sky-100 transition hover:border-sky-300/35 hover:bg-sky-300/10`,children:"Edit"}):null,a&&E.trustStatus==="trusted"&&!E.isManaged?t.jsx("button",{type:"button",disabled:s,onClick:re=>{re.stopPropagation(),D(E)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-amber-100 transition hover:border-amber-300/35 hover:bg-amber-300/10 disabled:cursor-not-allowed disabled:opacity-50`,children:"Untrust"}):null,(E.trustStatus==="untrusted"||E.trustStatus==="modified")&&!E.isManaged&&a?t.jsx("button",{type:"button",disabled:s||!E.currentHash,onClick:re=>{re.stopPropagation(),A(E)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-emerald-100 transition hover:border-emerald-300/35 hover:bg-emerald-300/10 disabled:cursor-not-allowed disabled:opacity-50`,children:"Trust"}):null,t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-0.5 text-stone-300",children:Iu(E.trustStatus)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.14em] text-stone-500",children:[t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:zu(E.source)}),t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:E.enabled?"Enabled":"Disabled"}),t.jsxs("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:[E.timeoutSec,"s"]})]})]},E.key))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((he=r.data)==null?void 0:he.hooks.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No hooks configured for this workspace."}):null]})}function lm({mcpPanelMode:e,mcpState:r,mcpConfigEditing:n,mcpConfigPath:a,mcpConfigError:s,mcpConfigSuccess:o,mcpConfigBusy:l,mcpHttpName:i,mcpHttpUrl:d,mcpRawBlock:h,composerPanelButtonClassName:u,composerChipButtonClassName:m,onSetMcpPanelMode:f,onClearMcpConfigStatus:p,onSetMcpHttpName:g,onSetMcpHttpUrl:b,onSetMcpRawBlock:v,onPrepareRawMcpBlock:x,onSaveHttpMcp:y,onSaveRawMcpBlock:k}){var j,w;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"MCP config source"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:a??"<provider config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),f("add"),p()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add MCP"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading MCP servers..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,s?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:s}):null,o?t.jsx("p",{className:"mb-2 rounded-xl border border-emerald-500/35 bg-emerald-500/10 px-3 py-3 text-sm text-emerald-100/90",children:o}):null,e==="add"?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:N=>{N.stopPropagation(),f("http"),p()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"HTTP / Streamable HTTP"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"Form"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Add an MCP server with a name and URL, then write the matching block into provider config."})]}),t.jsxs("button",{type:"button",onClick:N=>{N.stopPropagation(),x()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"stdio / raw block"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"TOML"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Write a single `[mcp_servers.name]` block, then save it back into provider config."})]})]}):null,e==="http"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"MCP name"}),t.jsx("input",{"aria-label":"MCP name",value:i,onChange:N=>g(N.target.value),placeholder:"openaiDeveloperDocs",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"URL"}),t.jsx("input",{"aria-label":"URL",value:d,onChange:N=>b(N.target.value),placeholder:"https://developers.openai.com/mcp",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void y(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write HTTP MCP"})]})]}):null,e==="stdio"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsx("label",{className:"block text-xs text-stone-400",children:"MCP block for provider config"}),t.jsx("textarea",{"aria-label":"MCP block for provider config",value:h,onChange:N=>v(N.target.value),rows:8,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void k(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write raw block"})]})]}):null,e==="list"&&((j=r.data)!=null&&j.servers.length)?t.jsx("div",{className:"space-y-2",children:r.data.servers.map(N=>t.jsxs("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:N.name}),t.jsxs("p",{className:"mt-0.5 text-xs text-stone-400",children:[N.tools.length," tools · ",N.resourceCount," ","resources · ",N.resourceTemplateCount," templates"]})]}),t.jsx("span",{className:"shrink-0 rounded-full border border-stone-700 px-2 py-1 text-[10px] uppercase tracking-[0.14em] text-stone-300",children:Eu(N.authStatus)})]}),N.tools.length>0?t.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-stone-500",children:N.tools.slice(0,4).map(S=>S.title??S.name).join(" · ")}):null]},N.name))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((w=r.data)==null?void 0:w.servers.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No MCP servers available right now."}):null]})}function im({skillsState:e,copiedSkillName:r,composerChipButtonClassName:n,onCopySkillInvokeName:a}){var s,o,l,i;return t.jsxs("div",{className:"p-2",children:[e.status==="loading"&&!e.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading skills..."}):null,e.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:e.error}):null,(s=e.data)!=null&&s.skills.length?t.jsx("div",{className:"space-y-2",children:e.data.skills.map(d=>{var h,u;return t.jsx("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:((h=d.interface)==null?void 0:h.displayName)??d.name}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.14em]",children:[t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1 text-stone-400",children:Lu(d.scope)}),t.jsxs("button",{type:"button",className:`inline-flex items-center gap-1 rounded-full border px-2 py-1 normal-case tracking-normal transition ${r===d.name?"border-emerald-400/45 bg-emerald-400/12 text-emerald-100":`${n} border-stone-700 text-stone-300 hover:border-stone-500`}`,onClick:()=>void a(d.name),title:`Copy $${d.name}`,"aria-label":`Copy $${d.name}`,children:[t.jsx($n,{}),"$",d.name]})]}),t.jsx("p",{className:"text-xs leading-5 text-stone-400",children:((u=d.interface)==null?void 0:u.shortDescription)??d.shortDescription??d.description})]})},d.path)})}):null,(o=e.data)!=null&&o.errors.length?t.jsx("div",{className:"mt-2 space-y-2",children:e.data.errors.map(d=>t.jsxs("div",{className:"rounded-xl border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-100/85",children:[t.jsx("p",{className:"font-medium",children:d.message}),t.jsx("p",{className:"mt-1 break-all text-amber-100/60",children:d.path})]},`${d.path}:${d.message}`))}):null,e.status!=="loading"&&!e.error&&(((l=e.data)==null?void 0:l.skills.length)??0)===0&&(((i=e.data)==null?void 0:i.errors.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No skills available right now."}):null]})}function dm({open:e,slashPanelView:r,availableToolboxItems:n,busy:a,forkBusy:s,forkTurnOptionsState:o,skillsState:l,copiedSkillName:i,hooksPanelMode:d,hooksState:h,hostConfigFilesAvailable:u,hookTrustAvailable:m,hookConfigBusy:f,hookConfigError:p,hookConfigSuccess:g,editingHookTarget:b,hookScope:v,hookEventName:x,hookMatcher:y,hookCommand:k,hookTimeoutSec:j,hookStatusMessage:w,mcpPanelMode:N,mcpState:S,mcpConfigEditing:L,mcpConfigPath:T,mcpConfigError:q,mcpConfigSuccess:A,mcpConfigBusy:D,mcpHttpName:J,mcpHttpUrl:W,mcpRawBlock:O,iconButtonClassName:ee,menuClassName:he,menuItemClassName:E,panelButtonClassName:re,chipButtonClassName:_,onToggle:V,onToolboxItemClick:U,toolboxItemDisabled:z,toolboxItemClassName:X,toolboxItemStatus:F,onSetSlashPanelView:I,onOpenForkTurns:P,onForkLatest:Z,onForkTurn:K,onCopySkillInvokeName:de,onResetHookForm:M,onSetHooksPanelMode:Y,onClearHookConfigStatus:te,onSetEditingHookTarget:ie,onSetHookScope:ue,onSetHookEventName:be,onSetHookMatcher:Le,onSetHookCommand:ae,onSetHookTimeoutSec:ve,onSetHookStatusMessage:ke,onSaveHook:pe,onStartEditingHook:ze,onTrustHook:je,onUntrustHook:Me,onSetMcpPanelMode:Pe,onClearMcpConfigStatus:_e,onSetMcpHttpName:Ce,onSetMcpHttpUrl:Re,onSetMcpRawBlock:H,onPrepareRawMcpBlock:ce,onSaveHttpMcp:R,onSaveRawMcpBlock:$}){return t.jsxs("div",{className:"relative",children:[t.jsx(xt,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Open slash toolbox",title:"Open slash toolbox",onClick:V,className:`${ee} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx(Cu,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${he} absolute bottom-full left-0 z-40 mb-2 w-72 overflow-hidden rounded-2xl border bg-stone-900/72 shadow-2xl shadow-stone-950/20 backdrop-blur-xl`,onClick:Q=>{Q.stopPropagation()},onMouseDown:Q=>{Q.stopPropagation()},onPointerDown:Q=>{Q.stopPropagation()},onTouchStart:Q=>{Q.stopPropagation()},children:r==="root"?t.jsxs("div",{className:"p-2",children:[n.map((Q,me)=>t.jsx("button",{type:"button",disabled:z(Q),onClick:xe=>U(Q,xe),className:`${X(Q)} ${me===0?"mt-0":""}`,title:Q.description??Q.label,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:Q.command}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:F(Q)})]})},`${Q.action}:${Q.command}`)),n.length===0?t.jsx("p",{className:"px-3 py-2 text-sm text-stone-400",children:"No backend tools are available for this thread."}):null]}):t.jsx("div",{className:"max-h-80 overflow-auto",children:r==="fork"?t.jsx(am,{busy:a,forkBusy:s,composerMenuItemClassName:E,onForkLatest:Z,onSelectForkTurnPanel:()=>(I("forkTurns"),P())}):r==="forkTurns"?t.jsx(sm,{forkTurnOptionsState:o,forkBusy:s,composerPanelButtonClassName:re,onForkTurn:K}):r==="skills"?t.jsx(im,{skillsState:l,copiedSkillName:i,composerChipButtonClassName:_,onCopySkillInvokeName:de}):r==="hooks"?t.jsx(om,{hooksPanelMode:d,hooksState:h,hostConfigFilesAvailable:u,hookTrustAvailable:m,hookConfigBusy:f,hookConfigError:p,hookConfigSuccess:g,editingHookTarget:b,hookScope:v,hookEventName:x,hookMatcher:y,hookCommand:k,hookTimeoutSec:j,hookStatusMessage:w,composerChipButtonClassName:_,onResetHookForm:M,onSetHooksPanelMode:Y,onClearHookConfigStatus:te,onSetEditingHookTarget:ie,onSetHookScope:ue,onSetHookEventName:be,onSetHookMatcher:Le,onSetHookCommand:ae,onSetHookTimeoutSec:ve,onSetHookStatusMessage:ke,onSaveHook:pe,onStartEditingHook:ze,onTrustHook:je,onUntrustHook:Me}):t.jsx(lm,{mcpPanelMode:N,mcpState:S,mcpConfigEditing:L,mcpConfigPath:T,mcpConfigError:q,mcpConfigSuccess:A,mcpConfigBusy:D,mcpHttpName:J,mcpHttpUrl:W,mcpRawBlock:O,composerPanelButtonClassName:re,composerChipButtonClassName:_,onSetMcpPanelMode:Pe,onClearMcpConfigStatus:_e,onSetMcpHttpName:Ce,onSetMcpHttpUrl:Re,onSetMcpRawBlock:H,onPrepareRawMcpBlock:ce,onSaveHttpMcp:R,onSaveRawMcpBlock:$})})})]})}function cm({isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:s,toolbarClassName:o,iconButtonClassName:l,slashToolboxProps:i,attachmentMenuProps:d,settingsToolbarProps:h,shellToolsPanelProps:u,onToggleView:m,onDismissPromptFocus:f,onSetOpenMenu:p}){return t.jsxs(Xu,{align:"block-end",className:`${o} relative z-30 mb-0 flex items-center gap-2 text-xs`,children:[t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[!e&&i?t.jsx(dm,{...i}):null,!e&&d?t.jsx(tm,{...d}):null,r&&t.jsx(xt,{type:"button",variant:"ghost",size:"icon-xs","aria-label":e?"Switch to chat":"Switch to shell",title:e?"Switch to chat":"Switch to shell",onClick:()=>m==null?void 0:m(),className:`${l} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:e?t.jsx(Su,{}):t.jsx(ju,{})})]}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-end gap-1.5",children:[!e&&h?t.jsx(rm,{...h}):null,e&&a?t.jsx(Zu,{className:"min-w-0 max-w-[12rem] truncate rounded-full px-1.5 py-1 text-stone-400",title:a,children:a}):null,n&&t.jsxs("div",{className:"relative",children:[t.jsx("button",{type:"button","data-composer-menu-trigger":"true","aria-label":s==="shellTools"?"Close shell tools":"Open shell tools","aria-haspopup":"menu","aria-expanded":s==="shellTools",title:s==="shellTools"?"Close shell tools":"Open shell tools",onClick:()=>{f(),p(g=>g==="shellTools"?null:"shellTools")},className:"inline-flex h-7 w-7 items-center justify-center rounded-full border border-stone-700 bg-stone-900/92 text-stone-200 transition hover:bg-stone-800",children:t.jsx(Tu,{})}),s==="shellTools"&&u?t.jsx(nm,{...u}):null]})]})]})}function hm(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`attachment-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function um(e){return[...e.filter(r=>_n(r)==="photo"),...e.filter(r=>_n(r)==="file")]}function mm({prompt:e,attachments:r,updateDraft:n,getSelection:a,selectionSnapshotRef:s,pendingSelectionRef:o,pendingInsertedAttachmentIdsRef:l,onInserted:i,buildClientId:d=hm}){const h=c.useCallback((f,p)=>{if(f.length===0)return!1;const g=ou({prompt:e,attachments:r,files:f,selection:a()??s.current,kindForFile:p,buildClientId:d});return n(()=>g.draft),o.current=g.selection,s.current=g.selection,l.current=g.insertedAttachmentIds,i==null||i(),!0},[r,d,a,i,l,o,e,s,n]),u=c.useCallback((f,p)=>!f||f.length===0?!1:h(Array.from(f),()=>p),[h]),m=c.useCallback(f=>h(um(f),_n),[h]);return{appendAttachments:u,appendDroppedAttachments:m}}function ts(e){for(const r of e.values())URL.revokeObjectURL(r);e.clear()}function pm({attachments:e,isShellView:r}){const n=c.useRef(new Map),[a,s]=c.useState({});return c.useEffect(()=>{const o=n.current;if(r){ts(o),s({});return}const l={},i=new Set;for(const d of e){if(d.kind!=="photo")continue;i.add(d.clientId);let h=o.get(d.clientId);h||(h=URL.createObjectURL(d.file),o.set(d.clientId,h)),l[d.clientId]=h}for(const[d,h]of o.entries())i.has(d)||(URL.revokeObjectURL(h),o.delete(d));s(l)},[e,r]),c.useEffect(()=>{const o=n.current;return()=>{ts(o)}},[]),a}var fm=180;function pn(e,r){return{prompt:e??"",attachments:r??[]}}function gm({isShellView:e,draftPrompt:r,draftAttachments:n,onDraftChange:a}){const[s,o]=c.useState({prompt:"",attachments:[]}),[l,i]=c.useState(()=>pn(r,n)),d=c.useRef(null),h=c.useRef(l),u=c.useRef(jr(l)),m=!e&&r!==void 0&&n!==void 0&&typeof a=="function",f=m?jr(pn(r,n)):"",p=c.useRef(f);c.useLayoutEffect(()=>{if(!m){p.current="";return}const k=pn(r,n),j=jr(k);j!==p.current&&(p.current=j,u.current=j,h.current=k,d.current!==null&&(window.clearTimeout(d.current),d.current=null),i(k))},[n,r,m]);const g=c.useCallback(k=>{if(!m||!a)return;const j=jr(k);j!==u.current&&(u.current=j,a(()=>({prompt:k.prompt,attachments:k.attachments})))},[m,a]);c.useEffect(()=>()=>{g(h.current),d.current!==null&&window.clearTimeout(d.current)},[g]);const b=c.useCallback((k,j)=>{if(m){if(d.current!==null&&(window.clearTimeout(d.current),d.current=null),j==="immediate"){g(k);return}d.current=window.setTimeout(()=>{d.current=null,g(h.current)},fm)}},[m,g]),v=c.useCallback((k=h.current)=>{b(k,"immediate")},[b]),x=c.useCallback((k,j="immediate")=>{if(m){const w=k(h.current);h.current=w,i(w),b(w,j);return}o(w=>k(w))},[m,b]),y=m?l:s;return{prompt:y.prompt,attachments:y.attachments,isDraftControlled:m,updateDraft:x,flushControlledDraftToHost:v}}function xm({slashPanelView:e,onForkLatest:r,onForkTurn:n,closeMenu:a}){const[s,o]=c.useState(!1);c.useEffect(()=>{e!=="forkTurns"&&o(!1)},[e]);const l=c.useCallback(async()=>{if(r){o(!0);try{await r(),a()}finally{o(!1)}}},[a,r]),i=c.useCallback(async d=>{if(n){o(!0);try{await n(d),a()}finally{o(!1)}}},[a,n]);return{forkBusy:s,forkLatest:l,forkTurn:i}}function bm({prompt:e,goalTokenBudgetSource:r,promptRef:n,onOpenGoal:a,onUpdateGoal:s,updateDraft:o,closeMenu:l,resetSlashPanel:i}){const[d,h]=c.useState(!1),[u,m]=c.useState(""),[f,p]=c.useState(!1),[g,b]=c.useState(null),v=c.useCallback(async()=>{const k=e.trim();if(!k)return b("Goal objective cannot be empty."),!1;const j=u.trim(),w=uu(j);if(j.length>0&&(w===null||!Number.isInteger(w)||w<=0))return b("Token budget must be a positive number in thousands."),!1;if(!s)return b("/goal is unavailable in this view."),!1;p(!0),b(null);try{return await s({objective:k,status:"active",tokenBudget:w}),m(""),h(!1),o(()=>({prompt:"",attachments:[]})),!0}catch(N){return b(N instanceof Error?N.message:"Unable to set goal."),!1}finally{p(!1)}},[u,s,e,o]),x=c.useCallback(()=>{l(),i(),h(!0),m(mu(r==null?void 0:r.tokenBudget)),b(null),a==null||a(),requestAnimationFrame(()=>{var k;(k=n.current)==null||k.focus()})},[l,r==null?void 0:r.tokenBudget,a,n,i]),y=c.useCallback(()=>{h(!1),b(null)},[]);return{goalComposeMode:d,goalTokenBudget:u,goalBusy:f,goalLocalError:g,setGoalTokenBudget:m,submitGoal:v,enterGoalComposeMode:x,exitGoalComposeMode:y}}var fn=`node -e "process.stdin.resume(); process.stdin.on('end', () => console.error('hook ran'))"`;function vm(e){const r=new Map;for(const n of e??[])r.set(n.eventName,n.command);return r}function km({slashPanelView:e,hookCommandTemplates:r,onCreateHook:n,onUpdateHook:a,onTrustHook:s,onUntrustHook:o}){const[l,i]=c.useState("list"),[d,h]=c.useState("project"),[u,m]=c.useState("preToolUse"),[f,p]=c.useState("Bash"),[g,b]=c.useState(fn),[v,x]=c.useState("30"),[y,k]=c.useState("Running hook"),[j,w]=c.useState(null),[N,S]=c.useState(!1),[L,T]=c.useState(null),[q,A]=c.useState(null),D=c.useMemo(()=>vm(r),[r]),J=c.useCallback(V=>D.get(V)??D.get("preToolUse")??fn,[D]),W=c.useMemo(()=>new Set([fn,...D.values()]),[D]),O=c.useCallback(()=>{T(null),A(null)},[]);c.useEffect(()=>{e!=="hooks"&&(i("list"),O())},[O,e]),c.useEffect(()=>{const V=Ar.find(U=>U.value===u);p(U=>{const z=U.trim(),X=new Set(Ar.map(F=>F.matcherHint).filter(Boolean));return z&&!X.has(z)?U:(V==null?void 0:V.matcherHint)??""}),b(U=>W.has(U.trim())?J(u):U)},[J,W,u]);const ee=c.useCallback(()=>{w(null),h("project"),m("preToolUse"),p("Bash"),b(J("preToolUse")),x("30"),k("Running hook")},[J]),he=c.useCallback(V=>{const U=Xo(V);if(!U){T("Only command hooks in global or project hooks.json can be edited here.");return}w(U),h(U.scope),m(U.eventName),p(U.matcher??""),b(U.command),x(U.timeoutSec?String(U.timeoutSec):""),k(U.statusMessage??""),T(null),A(null),i("edit")},[]),E=c.useCallback(async()=>{if(l==="edit"&&!a){T("Hook editing is unavailable in this view.");return}if(l!=="edit"&&!n){T("Hook editing is unavailable in this view.");return}if(l==="edit"&&!j){T("Select a hook to edit first.");return}const V=g.trim();if(!V){T("Hook command cannot be empty.");return}const U=v.trim(),z=U?Number(U):null;if(U&&(z===null||!Number.isInteger(z)||z<=0)){T("Timeout must be a positive number of seconds.");return}S(!0),T(null),A(null);try{const X={scope:d,eventName:u,matcher:f.trim()||null,command:V,timeoutSec:z,statusMessage:y.trim()||null};l==="edit"?await(a==null?void 0:a({...X,target:j})):await(n==null?void 0:n(X)),A(`${d==="project"?"Project":"Global"} hook ${l==="edit"?"updated":"written"} in hooks.json and trusted.`),i("list"),w(null)}catch(X){T(X instanceof Error?X.message:"Unable to write hooks.json.")}finally{S(!1)}},[j,g,u,f,d,y,v,l,n,a]),re=c.useCallback(async V=>{if(!s||!V.currentHash){T("Hook trust is unavailable in this view.");return}S(!0),T(null),A(null);try{await s({key:V.key,currentHash:V.currentHash}),A("Hook trusted.")}catch(U){T(U instanceof Error?U.message:"Unable to trust hook.")}finally{S(!1)}},[s]),_=c.useCallback(async V=>{if(!o){T("Hook trust is unavailable in this view.");return}S(!0),T(null),A(null);try{await o({key:V.key}),A("Hook untrusted.")}catch(U){T(U instanceof Error?U.message:"Unable to untrust hook.")}finally{S(!1)}},[o]);return{hooksPanelMode:l,hookScope:d,hookEventName:u,hookMatcher:f,hookCommand:g,hookTimeoutSec:v,hookStatusMessage:y,editingHookTarget:j,hookConfigBusy:N,hookConfigError:L,hookConfigSuccess:q,setHooksPanelMode:i,setEditingHookTarget:w,setHookScope:h,setHookEventName:m,setHookMatcher:p,setHookCommand:b,setHookTimeoutSec:x,setHookStatusMessage:k,clearHookConfigStatus:O,resetHookForm:ee,startEditingHook:he,saveHook:E,trustHook:re,untrustHook:_}}var wm=`[mcp_servers.example_stdio]
|
|
3607
|
+
${s}`:s}function Ko(e){return typeof e!="number"||Number.isNaN(e)?0:Math.max(0,Math.min(100,Math.round(e)))}function mn(e){const r=e/1e3;return Number.isInteger(r)?`${r}k`:`${Number(r.toFixed(1))}k`}function gu(e,r){if(!e)return"Select model";if((r==null?void 0:r.availability)!=="available"||typeof r.tokensInContextWindow!="number"||typeof r.modelContextWindow!="number")return`${e} · context unavailable`;const n=Math.max(r.tokensInContextWindow,0),a=Math.max(r.modelContextWindow,0),s=Math.max(a-n,0);return[e,`${mn(n)} used / ${mn(a)}`,`${mn(s)} left`,`${Ko(r.remainingPercent)}% context left`].join(" · ")}function xu(e,r){const n=e.name.trim();if(n)return n;const a=r==="photo"?e.type.includes("png")?".png":e.type.includes("heic")?".heic":e.type.includes("heif")?".heif":e.type.includes("webp")?".webp":".jpg":"";return`${r==="photo"?"photo":"file"}-${Date.now()}${a}`}function bu(e){return e.replace(/[\r\n[\]]+/g," ").replace(/\s+/g," ").trim()||"attachment"}function _n(e){return e.type.startsWith("image/")?"photo":"file"}function An(e,r){const n=[];if(e)for(const a of Array.from(e)){if(a.kind!=="file")continue;const s=a.getAsFile();s&&n.push(s)}return n.length>0?n:r?Array.from(r):[]}function Xa(e,r){return An(e,r).length>0}function vu(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function Ya(e){const r=e.placeholder.match(/^\[(?:PHOTO|FILE)\s+(.+)\]$/);return r!=null&&r[1]?r[1]:vu(e.originalName)}var Ar=[{value:"preToolUse",label:"PreToolUse",matcherHint:"Bash"},{value:"permissionRequest",label:"PermissionRequest",matcherHint:"Bash"},{value:"postToolUse",label:"PostToolUse",matcherHint:"Bash"},{value:"sessionStart",label:"SessionStart",matcherHint:"startup|resume"},{value:"userPromptSubmit",label:"UserPromptSubmit",matcherHint:""},{value:"stop",label:"Stop",matcherHint:""},{value:"preCompact",label:"PreCompact",matcherHint:""},{value:"postCompact",label:"PostCompact",matcherHint:""}];function ku({goalComposeMode:e,goalBusy:r,threadConnected:n,busy:a,isShellView:s,disabledPlaceholder:o,settingsBusy:l,supportedEffortCount:i,fastMode:d}){const h=e?"Describe the goal the backend should continue working toward...":o??(s?"Send shell input to the attached terminal...":"Ask the backend to inspect, modify, or explain code..."),u=e?r?"Setting...":"Set goal":!n&&a?"Connecting...":n&&a&&!s?"Sending...":"Send",m=n?e?"ui-action-info":"ui-action-primary":"ui-action-danger",f=l;return{promptPlaceholder:h,interruptLabel:s?"Send Ctrl-C":"Stop Current Turn",sendButtonLabel:u,sendButtonClassName:m,modelControlsDisabled:f,effortControlsDisabled:f||i===0,effortControlTitle:d?"Fast mode is on. Turn it off from the slash toolbox to edit reasoning.":i===0?"The selected model does not expose adjustable reasoning effort.":"Select reasoning effort"}}function wu({isShellView:e,edgeToEdgeMobile:r,isMobileShell:n,openMenu:a,isDragTargetActive:s,busy:o}){const l=e?"thread-composer-layer thread-shell-composer-layer":"thread-graph-composer-layer",i=e?"thread-composer-form":"thread-graph-composer-form",d=e?"thread-composer-form-floating":"thread-graph-composer-form-floating",h=e?"thread-composer-input":"thread-graph-composer-input";return{composerLayerClassName:a?`${l} relative z-[80] shrink-0`:`${l} relative z-20 shrink-0`,formClassName:e?r||n?`${i} ${d} relative z-20 shrink-0 border-t border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`:`${i} relative z-20 shrink-0 border-t border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`:`${i} ${r?d:""} relative z-20 shrink-0 border-t px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`,composerShellClassName:e?"thread-composer-shell":"thread-graph-composer-shell",composerToolbarClassName:e?"thread-composer-toolbar":"thread-graph-composer-toolbar",composerInputClassName:h,composerIconButtonClassName:e?"thread-composer-icon-button":"thread-graph-composer-icon-button",composerMenuClassName:e?"thread-composer-menu":"thread-graph-composer-menu",composerMenuItemClassName:e?"thread-composer-menu-item":"thread-graph-composer-menu-item",composerInlineToggleClassName:e?"thread-composer-inline-toggle":"thread-graph-composer-inline-toggle",composerPanelButtonClassName:e?"thread-composer-panel-button":"thread-graph-composer-panel-button",composerChipButtonClassName:e?"thread-composer-chip-button":"thread-graph-composer-chip-button",composerPlanToggleActiveClassName:e?"thread-composer-plan-toggle-active":"thread-graph-composer-plan-toggle-active",composerSendButtonClassName:e?"thread-composer-send-button":"thread-graph-composer-send-button",composerPromptRegionClassName:e?"thread-composer-prompt-region":"thread-graph-composer-prompt-region",promptInputClassName:`${h} min-h-[5.25rem] w-full px-4 pr-14 pt-3 outline-none transition sm:min-h-[5.75rem] ${s?"is-drag-target border-sky-300/80 bg-sky-300/[0.08] shadow-[0_0_0_1px_rgba(125,211,252,0.2)]":""}`,graphChatInputGroupClassName:`thread-graph-composer-input-group relative border-0 bg-transparent shadow-none ring-0 ${o?"bg-amber-50/40 dark:bg-amber-400/10":"bg-transparent"}`,graphChatInputClassName:`${h} min-h-[68px] max-h-32 w-full overflow-y-auto px-3 pt-3 text-[16px] leading-relaxed text-slate-800 outline-none transition sm:min-h-[92px] sm:max-h-40 sm:px-4 sm:pt-4 sm:text-[14px] dark:text-slate-100 ${s?"is-drag-target bg-sky-300/[0.08] shadow-[0_0_0_1px_rgba(125,211,252,0.2)]":""}`}}function yu(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"m4 5 2 2-2 2"}),t.jsx("path",{d:"M7.75 9.5h4.25"})]})}function ju(){return t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",children:t.jsx("path",{d:"M8 3.25v9.5M3.25 8h9.5"})})}function Nu(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M10.75 2.5 5.25 13.5"}),t.jsx("path",{d:"M4.25 5.25h2.25"}),t.jsx("path",{d:"M9.5 10.75h2.25"})]})}function Cu(){return t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3 4.5A1.75 1.75 0 0 1 4.75 2.75h6.5A1.75 1.75 0 0 1 13 4.5v4A1.75 1.75 0 0 1 11.25 10.25H8l-2.75 2v-2H4.75A1.75 1.75 0 0 1 3 8.5v-4Z"})})}function Su(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",className:"h-3.5 w-3.5 fill-current",children:[t.jsx("path",{fillRule:"evenodd",d:"M14.5 10C16.9853 10 19 7.98528 19 5.5C19 5.01783 18.9242 4.55338 18.7838 4.11791C18.6792 3.79367 18.2734 3.72683 18.0325 3.96772L15.3402 6.66002C15.2098 6.79041 15.0168 6.84163 14.8466 6.77074C14.1172 6.46695 13.5334 5.88351 13.2292 5.15431C13.1582 4.98403 13.2094 4.79088 13.3398 4.66042L16.0327 1.9676C16.2735 1.72672 16.2067 1.32092 15.8825 1.21636C15.4469 1.07588 14.9823 1 14.5 1C12.0147 1 10 3.01472 10 5.5C10 5.59783 10.0031 5.69494 10.0093 5.79122C10.065 6.66418 9.88174 7.59855 9.20974 8.15855L1.98017 14.1832C1.3591 14.7008 1 15.4674 1 16.2759C1 17.7804 2.21962 19 3.7241 19C4.53256 19 5.29925 18.6409 5.81681 18.0198L11.8414 10.7903C12.4014 10.1183 13.3358 9.93497 14.2088 9.99073C14.3051 9.99688 14.4022 10 14.5 10ZM5 16C5 16.5523 4.55228 17 4 17C3.44772 17 3 16.5523 3 16C3 15.4477 3.44772 15 4 15C4.55228 15 5 15.4477 5 16Z",clipRule:"evenodd"}),t.jsx("path",{d:"M14.5 11.5C14.6731 11.5 14.8445 11.4927 15.0138 11.4783L18.7678 15.2323C19.7441 16.2086 19.7441 17.7915 18.7678 18.7678C17.7915 19.7441 16.2086 19.7441 15.2323 18.7678L10.8216 14.3571L12.9938 11.7505C13.0455 11.6885 13.1413 11.6131 13.3357 11.5552C13.5378 11.4951 13.805 11.468 14.1132 11.4877C14.2413 11.4959 14.3702 11.5 14.5 11.5Z"}),t.jsx("path",{d:"M6.00003 4.58582L8.33056 6.91635C8.3027 6.95627 8.27496 6.98497 8.24946 7.00622L6.79994 8.21415L4.58582 6.00003H3.30905C3.11966 6.00003 2.94653 5.89303 2.86184 5.72364L1.1612 2.32237C1.06495 2.12987 1.10268 1.89739 1.25486 1.74521L1.74521 1.25486C1.89739 1.10268 2.12987 1.06495 2.32237 1.1612L5.72364 2.86184C5.89303 2.94653 6.00003 3.11966 6.00003 3.30905V4.58582Z"})]})}function Mn(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5.5 3.25h5"}),t.jsx("path",{d:"M6.4 2h3.2a.9.9 0 0 1 .9.9v.35h1.3a1.2 1.2 0 0 1 1.2 1.2v7.35a1.2 1.2 0 0 1-1.2 1.2H4.2A1.2 1.2 0 0 1 3 11.8V4.45a1.2 1.2 0 0 1 1.2-1.2h1.3V2.9a.9.9 0 0 1 .9-.9Z"})]})}function Tu(e){switch(e){case"bearerToken":return"Token";case"oAuth":return"OAuth";case"notLoggedIn":return"Login";case"unsupported":return"Public";default:return"Unknown"}}function Eu(e){switch(e){case"repo":return"Repo";case"system":return"System";case"admin":return"Admin";case"user":default:return"User"}}function Lu(e){var r;return((r=Ar.find(n=>n.value===e))==null?void 0:r.label)??e}function Pu(e){var r;switch(e){case"cloudRequirements":return"Cloud";case"legacyManagedConfigFile":case"legacyManagedConfigMdm":return"Managed";case"sessionFlags":return"Session";default:return((r=e[0])==null?void 0:r.toUpperCase())+e.slice(1)}}function Iu(e){switch(e){case"managed":return"Managed";case"modified":return"Modified";case"trusted":return"Trusted";case"untrusted":return"Review"}}function zu(e){switch(e){case"preToolUse":return"PreToolUse";case"permissionRequest":return"PermissionRequest";case"postToolUse":return"PostToolUse";case"preCompact":return"PreCompact";case"postCompact":return"PostCompact";case"sessionStart":return"SessionStart";case"userPromptSubmit":return"UserPromptSubmit";case"stop":return"Stop"}}function Ru(e){return e.source==="user"?"global":e.source==="project"?"project":null}function qo(e){const r=Ru(e);return!r||e.handlerType!=="command"||!e.command||e.isManaged?null:{scope:r,eventName:e.eventName,matcher:e.matcher,command:e.command,timeoutSec:e.timeoutSec,statusMessage:e.statusMessage}}function _u(e){switch(e){case"active":return"Active";case"paused":return"Paused";case"budgetLimited":return"Budget";case"complete":return"Complete";default:return e}}function Au({contextUsage:e}){const r=(e==null?void 0:e.availability)??"unavailable",n=Ko(e==null?void 0:e.remainingPercent);if(r!=="available")return null;const a=n<=20?"rgba(251,113,133,0.90)":n<=40?"rgba(252,211,77,0.85)":"rgba(125,211,252,0.80)";return t.jsx("span",{"aria-hidden":"true",className:"thread-context-progress-track pointer-events-none mt-0.5 block",children:t.jsx("span",{className:"thread-context-progress-fill block",style:{width:`${n}%`,backgroundColor:a}})})}function Lt({label:e,tone:r="stone"}){const n=r==="rose"?"border-rose-300/35 bg-rose-300/14 text-rose-50":r==="sky"?"border-sky-300/35 bg-sky-300/14 text-sky-50":"border-stone-700/90 bg-stone-900/80 text-stone-100";return t.jsx("span",{className:`inline-flex min-w-[3rem] items-center justify-center rounded-full border px-2 py-1.5 text-[10px] font-medium tracking-[0.12em] ${n}`,children:e})}function Mu(e,r){return(e??[]).filter(n=>{switch(n.action){case"fast":return r.fast;case"compact":return r.compact;case"goal":return r.goal;case"fork":return r.fork;case"skills":return r.skills;case"mcp":return r.mcp;case"hooks":return r.hooks;case"prompt":case"unsupported":return!0;default:return!1}})}function $u(e,{fastMode:r,goalComposeMode:n}){switch(e.action){case"fast":return{type:"toggleFast",fastMode:!r};case"compact":return{type:"runCompact"};case"goal":return n?{type:"exitGoalCompose"}:{type:"enterGoalCompose"};case"fork":case"skills":case"mcp":case"hooks":return{type:"openPanel",panel:e.action};case"prompt":return{type:"insertPrompt",text:`${e.command} `};default:return{type:"noop"}}}function Du(e,{fastMode:r,compactBusy:n,goalComposeMode:a,goalStatus:s,busy:o}){switch(e.action){case"fast":return r?"On":"Off";case"compact":return n?"Busy":"Run";case"goal":return a?"Composing":s?_u(s):"Open";case"fork":return o?"Idle only":"Open";case"skills":case"mcp":case"hooks":return"View";case"prompt":return"Compose";case"unsupported":return"Unavailable";default:return""}}function Bu(e,{settingsBusy:r,compactBusy:n,busy:a,forkBusy:s}){switch(e.action){case"fast":return r;case"compact":return n||a;case"fork":return a||s;case"unsupported":return!0;default:return!1}}function Gu(e,{fastMode:r,goalComposeMode:n,goalStatus:a,menuItemClassName:s}){return`${e.action==="fast"&&r||e.action==="goal"&&(n||a==="active")?"ui-status-warning":s} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`}function Fu(e){if(!e)return"";const r=document.createElement("div");return r.innerHTML=e,r.textContent??""}function Hu(e){return!!e.querySelector("[style], font")}function It(e){return e instanceof HTMLElement&&e.dataset.segmentType==="attachment"&&e.dataset.placeholder?e.dataset.placeholder:e.textContent??""}function Xo(e){let r="";for(const n of Array.from(e.childNodes))r+=It(n);return r.replace(/\u00a0/g," ")}function Za(e,r,n){var i;let a=null,s=n;if(r===e){const d=Array.from(e.childNodes);let h=0;for(let u=0;u<Math.min(n,d.length);u+=1){const m=d[u];m&&(h+=It(m).length)}return h}if(r.nodeType===Node.TEXT_NODE)a=r;else{const d=Array.from(e.childNodes).find(h=>h.contains(r));if(!d)return Xo(e).length;if(a=d,d instanceof HTMLElement&&d.dataset.segmentType==="attachment"){const h=document.createRange();h.selectNodeContents(d);const u=It(d).length;try{h.setEnd(r,n);const m=h.toString().length,f=((i=d.textContent)==null?void 0:i.length)??0;f===0?s=u:s=Math.round(Math.min(1,m/f)*u)}catch{s=u}}else{const h=document.createRange();h.selectNodeContents(d);try{h.setEnd(r,n),s=h.toString().length}catch{s=It(d).length}}}const o=Array.from(e.childNodes);let l=0;for(const d of o){if(d===a)return d.nodeType===Node.TEXT_NODE?l+s:l+Math.min(s,It(d).length);l+=It(d).length}return l}function Ou(e){const r=window.getSelection();if(!r||r.rangeCount===0)return null;const n=r.getRangeAt(0);return!e.contains(n.startContainer)||!e.contains(n.endContainer)?null:{start:Za(e,n.startContainer,n.startOffset),end:Za(e,n.endContainer,n.endOffset)}}function Ja(e,r){let n=Math.max(0,r);const a=Array.from(e.childNodes);for(const[s,o]of a.entries()){const i=It(o).length;if(o.nodeType===Node.TEXT_NODE){if(n<=i)return{node:o,offset:n};n-=i;continue}if(o instanceof HTMLElement&&o.dataset.segmentType==="attachment"){if(n===0)return{node:e,offset:s};if(n<=i){const d=a[s+1];return n===i&&(d==null?void 0:d.nodeType)===Node.TEXT_NODE?{node:d,offset:0}:{node:e,offset:s+1}}n-=i;continue}if(n<=i)return{node:e,offset:s+1};n-=i}return{node:e,offset:e.childNodes.length}}function Uu(e,r){const n=Ja(e,r.start),a=Ja(e,r.end),s=document.createRange();s.setStart(n.node,n.offset),s.setEnd(a.node,a.offset);const o=window.getSelection();o==null||o.removeAllRanges(),o==null||o.addRange(s)}function Wu(e,r){if(r.length===0)return!1;const n=r.at(-1);if(!n)return!1;const a=Array.from(e.childNodes).find(i=>i instanceof HTMLElement&&i.dataset.segmentType==="attachment"&&i.dataset.clientId===n);if(!(a instanceof HTMLElement))return!1;const s=document.createRange(),o=a.nextSibling;(o==null?void 0:o.nodeType)===Node.TEXT_NODE?s.setStart(o,0):s.setStartAfter(a),s.collapse(!0);const l=window.getSelection();return l==null||l.removeAllRanges(),l==null||l.addRange(s),!0}Or();Nt();function Vu({className:e,...r}){return t.jsx("div",{"data-slot":"input-group",role:"group",className:et("group/input-group relative flex w-full min-w-0 items-center rounded-md border shadow-xs outline-none transition-[color,box-shadow]","h-9 has-[>textarea]:h-auto","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col",e),...r})}var Ku=mr("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*=size-])]:size-4",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.45rem]","block-start":"order-first w-full justify-start px-3 pt-3","block-end":"order-last w-full justify-start px-3 pb-3"}},defaultVariants:{align:"inline-start"}});function qu({className:e,align:r="inline-start",...n}){return t.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":r,className:et(Ku({align:r}),e),onClick:a=>{var o;if(a.target.closest("button"))return;const s=(o=a.currentTarget.parentElement)==null?void 0:o.querySelector('[data-slot="input-group-control"] [contenteditable="true"], [data-slot="input-group-control"] textarea, [data-slot="input-group-control"] input, [data-slot="input-group-control"]');s==null||s.focus()},...n})}var Xu=mr("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*=size-])]:size-3.5",sm:"h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function xt({className:e,type:r="button",variant:n="ghost",size:a="xs",...s}){return t.jsx(ur,{type:r,"data-size":a,variant:n,className:et(Xu({size:a}),e),...s})}function Yu({className:e,...r}){return t.jsx("span",{className:et("flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*=size-])]:size-4",e),...r})}function Zu({photoInputRef:e,fileInputRef:r,onAppendAttachments:n}){function a(s,o){n(s.target.files,o),s.target.value=""}return t.jsxs(t.Fragment,{children:[t.jsx("input",{ref:e,type:"file",accept:"image/*",multiple:!0,tabIndex:-1,className:"sr-only",onChange:s=>a(s,"photo")}),t.jsx("input",{ref:r,type:"file",multiple:!0,tabIndex:-1,className:"sr-only",onChange:s=>a(s,"file")})]})}function Ju({activeView:e,followTail:r,onToggleFollow:n}){return e!=="chat"?null:t.jsx("button",{type:"button","aria-label":"Jump to latest",title:r?"Latest turn is in view":"Jump to the latest messages",onClick:()=>n==null?void 0:n(),className:"absolute left-1/2 top-0 z-[90] inline-flex h-11 min-w-[7rem] -translate-x-1/2 -translate-y-full items-end justify-center bg-transparent pb-1 touch-manipulation sm:h-10",children:t.jsx("span",{className:`thread-jump-latest-badge pointer-events-none inline-flex h-4 min-w-[3.75rem] items-center justify-center rounded-[0.7rem] border shadow-sm transition ${r?"is-active border-sky-300/36 bg-sky-300/[0.03] text-sky-100/86":"border-stone-500/70 bg-stone-950/[0.08] text-stone-200/86"}`,children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m4 6 4 4 4-4"})})})})}function Qu({activeView:e,layerClassName:r,formClassName:n,shellClassName:a,inputGroupClassName:s,error:o,followTail:l,photoInputRef:i,fileInputRef:d,onAppendAttachments:h,onToggleFollow:u,onSubmit:m,formRef:f,promptSlot:p,toolbarSlot:g,goalSlot:b,shellPromptSlot:v}){return t.jsxs("div",{className:r,children:[t.jsx(Zu,{photoInputRef:i,fileInputRef:d,onAppendAttachments:h}),t.jsx(Ju,{activeView:e,followTail:l,onToggleFollow:u}),t.jsxs("form",{ref:f,"data-testid":e==="chat"?"chat-composer":void 0,onSubmit:m,className:n,children:[t.jsxs("div",{className:`${a} flex w-full flex-col overflow-visible rounded-[16px] sm:rounded-[18px]`,children:[t.jsxs(Vu,{className:s,children:[p,g]}),b,v]}),o?t.jsx("div",{className:"mt-2 rounded-2xl border border-rose-500/40 bg-rose-500/10 px-4 py-3 text-sm text-rose-200",children:o}):null]})]})}function em({open:e,iconButtonClassName:r,menuClassName:n,menuItemClassName:a,onToggle:s,onPickPhoto:o,onPickFile:l}){return t.jsxs("div",{className:"relative",children:[t.jsx(xt,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Add attachment",title:"Add attachment",onClick:s,className:`${r} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx(ju,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${n} absolute bottom-full left-0 mb-2 w-32 overflow-hidden rounded-2xl border bg-stone-900/72 shadow-2xl shadow-stone-950/20`,children:t.jsxs("div",{className:"p-2",children:[t.jsx("button",{type:"button",onClick:o,className:`${a} block w-full rounded-xl px-3 py-2 text-left text-sm transition`,children:"Photo"}),t.jsx("button",{type:"button",onClick:l,className:`${a} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition`,children:"File"})]})})]})}var Yo=[{mode:"read-only",label:"Read only"},{mode:"workspace-write",label:"Workspace write"},{mode:"danger-full-access",label:"Danger"}];function Qa(e){var r;return((r=Yo.find(n=>n.mode===e))==null?void 0:r.label)??"Default"}function tm({openMenu:e,model:r,modelOptions:n,modelContextTitle:a,contextUsage:s,reasoningEffort:o,supportedEfforts:l,displayedCollaborationMode:i,sandboxMode:d,planModeAvailable:h,sandboxModeAvailable:u,settingsBusy:m,goalComposeMode:f,goalBusy:p,activeView:g,disabled:b,fastMode:v,sendButtonLabel:x,sendButtonClassName:y,modelControlsDisabled:k,effortControlsDisabled:N,effortControlTitle:w,inlineToggleClassName:j,menuItemClassName:C,planToggleActiveClassName:L,sendButtonBaseClassName:T,onSetOpenMenu:q,onUpdateSettings:M}){return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative min-w-0",children:[t.jsx(xt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="model","aria-label":r??"Select model",disabled:k||n.length===0,onClick:()=>q(D=>D==="model"?null:"model"),title:v?`Fast mode is on. Turn it off from the slash toolbox to edit model. ${a}`:a,className:`${j} relative min-w-0 max-w-[8.75rem] overflow-hidden rounded-full px-2.5 text-left text-stone-300 disabled:cursor-not-allowed disabled:text-stone-600 sm:max-w-[11rem]`,children:t.jsx("span",{className:"relative z-[1] block min-w-0 truncate whitespace-nowrap [direction:rtl]",children:r??"Select model"})}),r?t.jsx(Au,{contextUsage:s}):null,e==="model"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[9rem] max-w-[14rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:n.map(D=>t.jsx("button",{type:"button",onClick:()=>M({model:D.model,reasoningEffort:D.defaultReasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${D.model===r?"ui-status-warning":`${C} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:D.model})},D.id))})})]}),t.jsxs("div",{className:"relative",children:[t.jsx(xt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="effort",disabled:N,onClick:()=>q(D=>D==="effort"?null:"effort"),title:w,className:`${j} rounded-full px-2 disabled:cursor-not-allowed disabled:text-stone-700 ${N?"text-stone-500":"text-stone-300 hover:text-stone-100"}`,children:Ka(o)}),e==="effort"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[8rem] max-w-[12rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:l.map(D=>t.jsx("button",{type:"button",onClick:()=>M({reasoningEffort:D.reasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${D.reasoningEffort===o?"ui-status-warning":`${C} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:Ka(D.reasoningEffort)})},D.reasoningEffort))})})]}),u&&t.jsxs("div",{className:"relative",children:[t.jsx(xt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="sandbox","aria-label":`Sandbox: ${Qa(d)}`,disabled:m,onClick:()=>q(D=>D==="sandbox"?null:"sandbox"),title:`Sandbox: ${Qa(d)}`,className:`${j} rounded-full px-2.5 text-stone-300 disabled:cursor-not-allowed disabled:text-stone-700`,children:"Sandbox"}),e==="sandbox"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[9rem] max-w-[13rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:Yo.map(D=>t.jsx("button",{type:"button",onClick:()=>M({sandboxMode:D.mode}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${D.mode===d?"ui-status-warning":`${C} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:D.label})},D.mode))})})]}),h&&t.jsx(xt,{type:"button",variant:"ghost",size:"xs","aria-pressed":i==="plan",disabled:m,onClick:()=>M({collaborationMode:i==="plan"?"default":"plan"}),className:`${j} rounded-full px-2.5 ${i==="plan"?`${L} border !border-[oklch(0.78_0.16_86_/_0.76)] !bg-[oklch(0.44_0.095_82_/_0.72)] !text-[oklch(0.96_0.055_92)] shadow-[0_0_0_1px_oklch(0.78_0.16_86_/_0.24),0_0_18px_oklch(0.78_0.16_86_/_0.42),inset_0_0_0_1px_oklch(0.98_0.04_96_/_0.18)]`:"text-stone-500"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Plan"}),t.jsx(xt,{type:"submit",variant:"default",size:"icon-xs","aria-label":f?"Set goal":"Send Prompt",title:x,disabled:p||(g==="chat"?b:!1),className:`${T} h-9 w-9 rounded-full text-sm font-medium disabled:cursor-not-allowed sm:h-8 sm:w-8 ${y}`,children:t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-none stroke-current",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M8 13V3"}),t.jsx("path",{d:"m4 7 4-4 4 4"})]})})]})}function rm({busy:e,shellControlState:r,onPaste:n,onCopy:a,onClear:s,onShellControl:o}){const l=!!(r!=null&&r.shellInputEnabled),i=!!(r!=null&&r.isCommandRunning);return t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute right-0 top-full z-40 mt-2 w-[11.5rem] max-w-[calc(100vw-1.5rem)] rounded-[1rem] border border-stone-700/90 bg-stone-950/96 p-2 shadow-2xl shadow-stone-950/40 sm:w-48",onMouseDown:d=>{d.stopPropagation()},onPointerDown:d=>{d.stopPropagation()},onTouchStart:d=>{d.stopPropagation()},children:t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx("button",{type:"button",onClick:n,className:"inline-flex items-center justify-center rounded-full border border-sky-300/35 bg-sky-300/12 px-2 py-2 text-sky-50",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Mn,{}),t.jsx("span",{className:"text-[10px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:a,className:"inline-flex items-center justify-center rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-2 text-stone-100",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Mn,{}),t.jsx("span",{className:"text-[10px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:e,onClick:s,className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Lt,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!l||!i,onClick:()=>o("ctrl_c"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Lt,{label:"CTRL-C",tone:"rose"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("ctrl_d"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Lt,{label:"CTRL-D"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("esc"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Lt,{label:"ESC"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("tab"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Lt,{label:"TAB"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("up"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Lt,{label:"UP"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("down"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Lt,{label:"DOWN"})})]})})}function nm({busy:e,forkBusy:r,composerMenuItemClassName:n,onForkLatest:a,onSelectForkTurnPanel:s}){return t.jsxs("div",{className:"p-2",children:[t.jsx("button",{type:"button",disabled:e||r,onClick:()=>void a(),className:`${n} block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:"Fork from latest"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:r?"Forking":"Run"})]})}),t.jsx("button",{type:"button",disabled:e||r,onClick:o=>{o.stopPropagation(),s()},className:`${n} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:"Fork from selected turn"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:"Pick"})]})}),e?t.jsx("p",{className:"mt-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Fork is only available while the thread is idle."}):null]})}function am({forkTurnOptionsState:e,forkBusy:r,composerPanelButtonClassName:n,onForkTurn:a}){var s,o;return t.jsxs("div",{className:"p-2",children:[e.status==="loading"&&!e.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading turns..."}):null,e.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:e.error}):null,(s=e.data)!=null&&s.length?t.jsx("div",{className:"space-y-2",children:e.data.map(l=>t.jsx("button",{type:"button",disabled:r,onClick:()=>void a(l.turnId),className:`${n} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("span",{className:"text-sm text-stone-100",children:["Turn ",l.turnIndex]}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:r?"Forking":l.status})]})},l.turnId))}):null,e.status!=="loading"&&!e.error&&(((o=e.data)==null?void 0:o.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No turns available to fork yet."}):null]})}function sm({hooksPanelMode:e,hooksState:r,hostConfigFilesAvailable:n,hookTrustAvailable:a,hookConfigBusy:s,hookConfigError:o,hookConfigSuccess:l,editingHookTarget:i,hookScope:d,hookEventName:h,hookMatcher:u,hookCommand:m,hookTimeoutSec:f,hookStatusMessage:p,composerChipButtonClassName:g,onResetHookForm:b,onSetHooksPanelMode:v,onClearHookConfigStatus:x,onSetEditingHookTarget:y,onSetHookScope:k,onSetHookEventName:N,onSetHookMatcher:w,onSetHookCommand:j,onSetHookTimeoutSec:C,onSetHookStatusMessage:L,onSaveHook:T,onStartEditingHook:q,onTrustHook:M,onUntrustHook:D}){var J,W,O,ee,he;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"Hook config sources"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:((J=r.data)==null?void 0:J.projectHooksPath)??"<workspace hooks config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:E=>{E.stopPropagation(),b(),v("add"),x()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add Hook"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading hooks..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,o?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:o}):null,l?t.jsx("p",{className:"mb-2 rounded-xl border border-emerald-500/35 bg-emerald-500/10 px-3 py-3 text-sm text-emerald-100/90",children:l}):null,e==="add"||e==="edit"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[e==="edit"?t.jsxs("p",{className:"rounded-lg border border-stone-800 bg-stone-950 px-3 py-2 text-[11px] text-stone-400",children:["Editing"," ",zu((i==null?void 0:i.eventName)??h)," ","in ",(i==null?void 0:i.scope)==="global"?"global":"project"," ","hooks.json"]}):null,t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("label",{className:"block text-xs text-stone-400",children:["Scope",t.jsxs("select",{"aria-label":"Hook scope",value:d,onChange:E=>k(E.target.value),disabled:e==="edit",className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-2.5 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50",children:[t.jsx("option",{value:"project",children:"Project"}),t.jsx("option",{value:"global",children:"Global"})]})]}),t.jsxs("label",{className:"block text-xs text-stone-400",children:["Event",t.jsx("select",{"aria-label":"Hook event",value:h,onChange:E=>N(E.target.value),className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-2.5 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50",children:Ar.map(E=>t.jsx("option",{value:E.value,children:E.label},E.value))})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"Matcher"}),t.jsx("input",{"aria-label":"Hook matcher",value:u,onChange:E=>w(E.target.value),placeholder:"Bash",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"Command"}),t.jsx("textarea",{"aria-label":"Hook command",value:m,onChange:E=>j(E.target.value),rows:3,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 font-mono text-xs text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("label",{className:"block text-xs text-stone-400",children:["Timeout",t.jsx("input",{"aria-label":"Hook timeout seconds",value:f,onChange:E=>C(E.target.value),inputMode:"numeric",className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50"})]}),t.jsxs("label",{className:"block text-xs text-stone-400",children:["Status message",t.jsx("input",{"aria-label":"Hook status message",value:p,onChange:E=>L(E.target.value),className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50"})]})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>{v("list"),y(null)},className:`${g} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void T(),disabled:s,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:s?"Saving...":e==="edit"?"Update Hook":"Write Hook"})]})]}):null,e==="list"&&((W=r.data)!=null&&W.warnings.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.warnings.map(E=>t.jsx("p",{className:"rounded-xl border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-100/85",children:E},E))}):null,e==="list"&&((O=r.data)!=null&&O.errors.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.errors.map(E=>t.jsxs("div",{className:"rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-2 text-xs text-rose-100/90",children:[t.jsx("p",{className:"font-medium",children:E.message}),t.jsx("p",{className:"mt-1 break-all text-rose-100/60",children:E.path})]},`${E.path}:${E.message}`))}):null,e==="list"&&((ee=r.data)!=null&&ee.hooks.length)?t.jsx("div",{className:"space-y-2",children:r.data.hooks.map(E=>t.jsxs("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("p",{className:"truncate text-sm font-medium text-stone-100",children:[Lu(E.eventName),E.matcher?` · ${E.matcher}`:""]}),t.jsx("p",{className:"mt-0.5 truncate font-mono text-[11px] text-stone-400",children:E.command??E.handlerType}),E.statusMessage?t.jsx("p",{className:"mt-1 truncate text-[11px] text-stone-500",children:E.statusMessage}):null]}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.08em] text-stone-500",children:[qo(E)?t.jsx("button",{type:"button",onClick:re=>{re.stopPropagation(),q(E)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-sky-100 transition hover:border-sky-300/35 hover:bg-sky-300/10`,children:"Edit"}):null,a&&E.trustStatus==="trusted"&&!E.isManaged?t.jsx("button",{type:"button",disabled:s,onClick:re=>{re.stopPropagation(),D(E)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-amber-100 transition hover:border-amber-300/35 hover:bg-amber-300/10 disabled:cursor-not-allowed disabled:opacity-50`,children:"Untrust"}):null,(E.trustStatus==="untrusted"||E.trustStatus==="modified")&&!E.isManaged&&a?t.jsx("button",{type:"button",disabled:s||!E.currentHash,onClick:re=>{re.stopPropagation(),M(E)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-emerald-100 transition hover:border-emerald-300/35 hover:bg-emerald-300/10 disabled:cursor-not-allowed disabled:opacity-50`,children:"Trust"}):null,t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-0.5 text-stone-300",children:Iu(E.trustStatus)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.14em] text-stone-500",children:[t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:Pu(E.source)}),t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:E.enabled?"Enabled":"Disabled"}),t.jsxs("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:[E.timeoutSec,"s"]})]})]},E.key))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((he=r.data)==null?void 0:he.hooks.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No hooks configured for this workspace."}):null]})}function om({mcpPanelMode:e,mcpState:r,mcpConfigEditing:n,mcpConfigPath:a,mcpConfigError:s,mcpConfigSuccess:o,mcpConfigBusy:l,mcpHttpName:i,mcpHttpUrl:d,mcpRawBlock:h,composerPanelButtonClassName:u,composerChipButtonClassName:m,onSetMcpPanelMode:f,onClearMcpConfigStatus:p,onSetMcpHttpName:g,onSetMcpHttpUrl:b,onSetMcpRawBlock:v,onPrepareRawMcpBlock:x,onSaveHttpMcp:y,onSaveRawMcpBlock:k}){var N,w;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"MCP config source"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:a??"<provider config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),f("add"),p()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add MCP"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading MCP servers..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,s?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:s}):null,o?t.jsx("p",{className:"mb-2 rounded-xl border border-emerald-500/35 bg-emerald-500/10 px-3 py-3 text-sm text-emerald-100/90",children:o}):null,e==="add"?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:j=>{j.stopPropagation(),f("http"),p()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"HTTP / Streamable HTTP"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"Form"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Add an MCP server with a name and URL, then write the matching block into provider config."})]}),t.jsxs("button",{type:"button",onClick:j=>{j.stopPropagation(),x()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"stdio / raw block"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"TOML"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Write a single `[mcp_servers.name]` block, then save it back into provider config."})]})]}):null,e==="http"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"MCP name"}),t.jsx("input",{"aria-label":"MCP name",value:i,onChange:j=>g(j.target.value),placeholder:"openaiDeveloperDocs",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"URL"}),t.jsx("input",{"aria-label":"URL",value:d,onChange:j=>b(j.target.value),placeholder:"https://developers.openai.com/mcp",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void y(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write HTTP MCP"})]})]}):null,e==="stdio"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsx("label",{className:"block text-xs text-stone-400",children:"MCP block for provider config"}),t.jsx("textarea",{"aria-label":"MCP block for provider config",value:h,onChange:j=>v(j.target.value),rows:8,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void k(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write raw block"})]})]}):null,e==="list"&&((N=r.data)!=null&&N.servers.length)?t.jsx("div",{className:"space-y-2",children:r.data.servers.map(j=>t.jsxs("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:j.name}),t.jsxs("p",{className:"mt-0.5 text-xs text-stone-400",children:[j.tools.length," tools · ",j.resourceCount," ","resources · ",j.resourceTemplateCount," templates"]})]}),t.jsx("span",{className:"shrink-0 rounded-full border border-stone-700 px-2 py-1 text-[10px] uppercase tracking-[0.14em] text-stone-300",children:Tu(j.authStatus)})]}),j.tools.length>0?t.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-stone-500",children:j.tools.slice(0,4).map(C=>C.title??C.name).join(" · ")}):null]},j.name))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((w=r.data)==null?void 0:w.servers.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No MCP servers available right now."}):null]})}function lm({skillsState:e,copiedSkillName:r,composerChipButtonClassName:n,onCopySkillInvokeName:a}){var s,o,l,i;return t.jsxs("div",{className:"p-2",children:[e.status==="loading"&&!e.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading skills..."}):null,e.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:e.error}):null,(s=e.data)!=null&&s.skills.length?t.jsx("div",{className:"space-y-2",children:e.data.skills.map(d=>{var h,u;return t.jsx("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:((h=d.interface)==null?void 0:h.displayName)??d.name}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.14em]",children:[t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1 text-stone-400",children:Eu(d.scope)}),t.jsxs("button",{type:"button",className:`inline-flex items-center gap-1 rounded-full border px-2 py-1 normal-case tracking-normal transition ${r===d.name?"border-emerald-400/45 bg-emerald-400/12 text-emerald-100":`${n} border-stone-700 text-stone-300 hover:border-stone-500`}`,onClick:()=>void a(d.name),title:`Copy $${d.name}`,"aria-label":`Copy $${d.name}`,children:[t.jsx(Mn,{}),"$",d.name]})]}),t.jsx("p",{className:"text-xs leading-5 text-stone-400",children:((u=d.interface)==null?void 0:u.shortDescription)??d.shortDescription??d.description})]})},d.path)})}):null,(o=e.data)!=null&&o.errors.length?t.jsx("div",{className:"mt-2 space-y-2",children:e.data.errors.map(d=>t.jsxs("div",{className:"rounded-xl border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-100/85",children:[t.jsx("p",{className:"font-medium",children:d.message}),t.jsx("p",{className:"mt-1 break-all text-amber-100/60",children:d.path})]},`${d.path}:${d.message}`))}):null,e.status!=="loading"&&!e.error&&(((l=e.data)==null?void 0:l.skills.length)??0)===0&&(((i=e.data)==null?void 0:i.errors.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No skills available right now."}):null]})}function im({open:e,slashPanelView:r,availableToolboxItems:n,busy:a,forkBusy:s,forkTurnOptionsState:o,skillsState:l,copiedSkillName:i,hooksPanelMode:d,hooksState:h,hostConfigFilesAvailable:u,hookTrustAvailable:m,hookConfigBusy:f,hookConfigError:p,hookConfigSuccess:g,editingHookTarget:b,hookScope:v,hookEventName:x,hookMatcher:y,hookCommand:k,hookTimeoutSec:N,hookStatusMessage:w,mcpPanelMode:j,mcpState:C,mcpConfigEditing:L,mcpConfigPath:T,mcpConfigError:q,mcpConfigSuccess:M,mcpConfigBusy:D,mcpHttpName:J,mcpHttpUrl:W,mcpRawBlock:O,iconButtonClassName:ee,menuClassName:he,menuItemClassName:E,panelButtonClassName:re,chipButtonClassName:A,onToggle:V,onToolboxItemClick:U,toolboxItemDisabled:I,toolboxItemClassName:X,toolboxItemStatus:F,onSetSlashPanelView:z,onOpenForkTurns:P,onForkLatest:Z,onForkTurn:K,onCopySkillInvokeName:de,onResetHookForm:_,onSetHooksPanelMode:Y,onClearHookConfigStatus:te,onSetEditingHookTarget:ie,onSetHookScope:ue,onSetHookEventName:be,onSetHookMatcher:Le,onSetHookCommand:ae,onSetHookTimeoutSec:ve,onSetHookStatusMessage:ke,onSaveHook:pe,onStartEditingHook:Ie,onTrustHook:je,onUntrustHook:_e,onSetMcpPanelMode:Pe,onClearMcpConfigStatus:Ae,onSetMcpHttpName:Ce,onSetMcpHttpUrl:Re,onSetMcpRawBlock:H,onPrepareRawMcpBlock:ce,onSaveHttpMcp:R,onSaveRawMcpBlock:$}){return t.jsxs("div",{className:"relative",children:[t.jsx(xt,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Open slash toolbox",title:"Open slash toolbox",onClick:V,className:`${ee} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx(Nu,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${he} absolute bottom-full left-0 z-40 mb-2 w-72 overflow-hidden rounded-2xl border bg-stone-900/72 shadow-2xl shadow-stone-950/20 backdrop-blur-xl`,onClick:Q=>{Q.stopPropagation()},onMouseDown:Q=>{Q.stopPropagation()},onPointerDown:Q=>{Q.stopPropagation()},onTouchStart:Q=>{Q.stopPropagation()},children:r==="root"?t.jsxs("div",{className:"p-2",children:[n.map((Q,me)=>t.jsx("button",{type:"button",disabled:I(Q),onClick:xe=>U(Q,xe),className:`${X(Q)} ${me===0?"mt-0":""}`,title:Q.description??Q.label,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:Q.command}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:F(Q)})]})},`${Q.action}:${Q.command}`)),n.length===0?t.jsx("p",{className:"px-3 py-2 text-sm text-stone-400",children:"No backend tools are available for this thread."}):null]}):t.jsx("div",{className:"max-h-80 overflow-auto",children:r==="fork"?t.jsx(nm,{busy:a,forkBusy:s,composerMenuItemClassName:E,onForkLatest:Z,onSelectForkTurnPanel:()=>(z("forkTurns"),P())}):r==="forkTurns"?t.jsx(am,{forkTurnOptionsState:o,forkBusy:s,composerPanelButtonClassName:re,onForkTurn:K}):r==="skills"?t.jsx(lm,{skillsState:l,copiedSkillName:i,composerChipButtonClassName:A,onCopySkillInvokeName:de}):r==="hooks"?t.jsx(sm,{hooksPanelMode:d,hooksState:h,hostConfigFilesAvailable:u,hookTrustAvailable:m,hookConfigBusy:f,hookConfigError:p,hookConfigSuccess:g,editingHookTarget:b,hookScope:v,hookEventName:x,hookMatcher:y,hookCommand:k,hookTimeoutSec:N,hookStatusMessage:w,composerChipButtonClassName:A,onResetHookForm:_,onSetHooksPanelMode:Y,onClearHookConfigStatus:te,onSetEditingHookTarget:ie,onSetHookScope:ue,onSetHookEventName:be,onSetHookMatcher:Le,onSetHookCommand:ae,onSetHookTimeoutSec:ve,onSetHookStatusMessage:ke,onSaveHook:pe,onStartEditingHook:Ie,onTrustHook:je,onUntrustHook:_e}):t.jsx(om,{mcpPanelMode:j,mcpState:C,mcpConfigEditing:L,mcpConfigPath:T,mcpConfigError:q,mcpConfigSuccess:M,mcpConfigBusy:D,mcpHttpName:J,mcpHttpUrl:W,mcpRawBlock:O,composerPanelButtonClassName:re,composerChipButtonClassName:A,onSetMcpPanelMode:Pe,onClearMcpConfigStatus:Ae,onSetMcpHttpName:Ce,onSetMcpHttpUrl:Re,onSetMcpRawBlock:H,onPrepareRawMcpBlock:ce,onSaveHttpMcp:R,onSaveRawMcpBlock:$})})})]})}function dm({isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:s,toolbarClassName:o,iconButtonClassName:l,slashToolboxProps:i,attachmentMenuProps:d,settingsToolbarProps:h,shellToolsPanelProps:u,onToggleView:m,onDismissPromptFocus:f,onSetOpenMenu:p}){return t.jsxs(qu,{align:"block-end",className:`${o} relative z-30 mb-0 flex items-center gap-2 text-xs`,children:[t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[!e&&i?t.jsx(im,{...i}):null,!e&&d?t.jsx(em,{...d}):null,r&&t.jsx(xt,{type:"button",variant:"ghost",size:"icon-xs","aria-label":e?"Switch to chat":"Switch to shell",title:e?"Switch to chat":"Switch to shell",onClick:()=>m==null?void 0:m(),className:`${l} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:e?t.jsx(Cu,{}):t.jsx(yu,{})})]}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-end gap-1.5",children:[!e&&h?t.jsx(tm,{...h}):null,e&&a?t.jsx(Yu,{className:"min-w-0 max-w-[12rem] truncate rounded-full px-1.5 py-1 text-stone-400",title:a,children:a}):null,n&&t.jsxs("div",{className:"relative",children:[t.jsx("button",{type:"button","data-composer-menu-trigger":"true","aria-label":s==="shellTools"?"Close shell tools":"Open shell tools","aria-haspopup":"menu","aria-expanded":s==="shellTools",title:s==="shellTools"?"Close shell tools":"Open shell tools",onClick:()=>{f(),p(g=>g==="shellTools"?null:"shellTools")},className:"inline-flex h-7 w-7 items-center justify-center rounded-full border border-stone-700 bg-stone-900/92 text-stone-200 transition hover:bg-stone-800",children:t.jsx(Su,{})}),s==="shellTools"&&u?t.jsx(rm,{...u}):null]})]})]})}function cm(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`attachment-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function hm(e){return[...e.filter(r=>_n(r)==="photo"),...e.filter(r=>_n(r)==="file")]}function um({prompt:e,attachments:r,updateDraft:n,getSelection:a,selectionSnapshotRef:s,pendingSelectionRef:o,pendingInsertedAttachmentIdsRef:l,onInserted:i,buildClientId:d=cm}){const h=c.useCallback((f,p)=>{if(f.length===0)return!1;const g=su({prompt:e,attachments:r,files:f,selection:a()??s.current,kindForFile:p,buildClientId:d});return n(()=>g.draft),o.current=g.selection,s.current=g.selection,l.current=g.insertedAttachmentIds,i==null||i(),!0},[r,d,a,i,l,o,e,s,n]),u=c.useCallback((f,p)=>!f||f.length===0?!1:h(Array.from(f),()=>p),[h]),m=c.useCallback(f=>h(hm(f),_n),[h]);return{appendAttachments:u,appendDroppedAttachments:m}}function es(e){for(const r of e.values())URL.revokeObjectURL(r);e.clear()}function mm({attachments:e,isShellView:r}){const n=c.useRef(new Map),[a,s]=c.useState({});return c.useEffect(()=>{const o=n.current;if(r){es(o),s({});return}const l={},i=new Set;for(const d of e){if(d.kind!=="photo")continue;i.add(d.clientId);let h=o.get(d.clientId);h||(h=URL.createObjectURL(d.file),o.set(d.clientId,h)),l[d.clientId]=h}for(const[d,h]of o.entries())i.has(d)||(URL.revokeObjectURL(h),o.delete(d));s(l)},[e,r]),c.useEffect(()=>{const o=n.current;return()=>{es(o)}},[]),a}var pm=180;function pn(e,r){return{prompt:e??"",attachments:r??[]}}function fm({isShellView:e,draftPrompt:r,draftAttachments:n,onDraftChange:a}){const[s,o]=c.useState({prompt:"",attachments:[]}),[l,i]=c.useState(()=>pn(r,n)),d=c.useRef(null),h=c.useRef(l),u=c.useRef(yr(l)),m=!e&&r!==void 0&&n!==void 0&&typeof a=="function",f=m?yr(pn(r,n)):"",p=c.useRef(f);c.useLayoutEffect(()=>{if(!m){p.current="";return}const k=pn(r,n),N=yr(k);N!==p.current&&(p.current=N,u.current=N,h.current=k,d.current!==null&&(window.clearTimeout(d.current),d.current=null),i(k))},[n,r,m]);const g=c.useCallback(k=>{if(!m||!a)return;const N=yr(k);N!==u.current&&(u.current=N,a(()=>({prompt:k.prompt,attachments:k.attachments})))},[m,a]);c.useEffect(()=>()=>{g(h.current),d.current!==null&&window.clearTimeout(d.current)},[g]);const b=c.useCallback((k,N)=>{if(m){if(d.current!==null&&(window.clearTimeout(d.current),d.current=null),N==="immediate"){g(k);return}d.current=window.setTimeout(()=>{d.current=null,g(h.current)},pm)}},[m,g]),v=c.useCallback((k=h.current)=>{b(k,"immediate")},[b]),x=c.useCallback((k,N="immediate")=>{if(m){const w=k(h.current);h.current=w,i(w),b(w,N);return}o(w=>k(w))},[m,b]),y=m?l:s;return{prompt:y.prompt,attachments:y.attachments,isDraftControlled:m,updateDraft:x,flushControlledDraftToHost:v}}function gm({slashPanelView:e,onForkLatest:r,onForkTurn:n,closeMenu:a}){const[s,o]=c.useState(!1);c.useEffect(()=>{e!=="forkTurns"&&o(!1)},[e]);const l=c.useCallback(async()=>{if(r){o(!0);try{await r(),a()}finally{o(!1)}}},[a,r]),i=c.useCallback(async d=>{if(n){o(!0);try{await n(d),a()}finally{o(!1)}}},[a,n]);return{forkBusy:s,forkLatest:l,forkTurn:i}}function xm({prompt:e,goalTokenBudgetSource:r,promptRef:n,onOpenGoal:a,onUpdateGoal:s,updateDraft:o,closeMenu:l,resetSlashPanel:i}){const[d,h]=c.useState(!1),[u,m]=c.useState(""),[f,p]=c.useState(!1),[g,b]=c.useState(null),v=c.useCallback(async()=>{const k=e.trim();if(!k)return b("Goal objective cannot be empty."),!1;const N=u.trim(),w=hu(N);if(N.length>0&&(w===null||!Number.isInteger(w)||w<=0))return b("Token budget must be a positive number in thousands."),!1;if(!s)return b("/goal is unavailable in this view."),!1;p(!0),b(null);try{return await s({objective:k,status:"active",tokenBudget:w}),m(""),h(!1),o(()=>({prompt:"",attachments:[]})),!0}catch(j){return b(j instanceof Error?j.message:"Unable to set goal."),!1}finally{p(!1)}},[u,s,e,o]),x=c.useCallback(()=>{l(),i(),h(!0),m(uu(r==null?void 0:r.tokenBudget)),b(null),a==null||a(),requestAnimationFrame(()=>{var k;(k=n.current)==null||k.focus()})},[l,r==null?void 0:r.tokenBudget,a,n,i]),y=c.useCallback(()=>{h(!1),b(null)},[]);return{goalComposeMode:d,goalTokenBudget:u,goalBusy:f,goalLocalError:g,setGoalTokenBudget:m,submitGoal:v,enterGoalComposeMode:x,exitGoalComposeMode:y}}var fn=`node -e "process.stdin.resume(); process.stdin.on('end', () => console.error('hook ran'))"`;function bm(e){const r=new Map;for(const n of e??[])r.set(n.eventName,n.command);return r}function vm({slashPanelView:e,hookCommandTemplates:r,onCreateHook:n,onUpdateHook:a,onTrustHook:s,onUntrustHook:o}){const[l,i]=c.useState("list"),[d,h]=c.useState("project"),[u,m]=c.useState("preToolUse"),[f,p]=c.useState("Bash"),[g,b]=c.useState(fn),[v,x]=c.useState("30"),[y,k]=c.useState("Running hook"),[N,w]=c.useState(null),[j,C]=c.useState(!1),[L,T]=c.useState(null),[q,M]=c.useState(null),D=c.useMemo(()=>bm(r),[r]),J=c.useCallback(V=>D.get(V)??D.get("preToolUse")??fn,[D]),W=c.useMemo(()=>new Set([fn,...D.values()]),[D]),O=c.useCallback(()=>{T(null),M(null)},[]);c.useEffect(()=>{e!=="hooks"&&(i("list"),O())},[O,e]),c.useEffect(()=>{const V=Ar.find(U=>U.value===u);p(U=>{const I=U.trim(),X=new Set(Ar.map(F=>F.matcherHint).filter(Boolean));return I&&!X.has(I)?U:(V==null?void 0:V.matcherHint)??""}),b(U=>W.has(U.trim())?J(u):U)},[J,W,u]);const ee=c.useCallback(()=>{w(null),h("project"),m("preToolUse"),p("Bash"),b(J("preToolUse")),x("30"),k("Running hook")},[J]),he=c.useCallback(V=>{const U=qo(V);if(!U){T("Only command hooks in global or project hooks.json can be edited here.");return}w(U),h(U.scope),m(U.eventName),p(U.matcher??""),b(U.command),x(U.timeoutSec?String(U.timeoutSec):""),k(U.statusMessage??""),T(null),M(null),i("edit")},[]),E=c.useCallback(async()=>{if(l==="edit"&&!a){T("Hook editing is unavailable in this view.");return}if(l!=="edit"&&!n){T("Hook editing is unavailable in this view.");return}if(l==="edit"&&!N){T("Select a hook to edit first.");return}const V=g.trim();if(!V){T("Hook command cannot be empty.");return}const U=v.trim(),I=U?Number(U):null;if(U&&(I===null||!Number.isInteger(I)||I<=0)){T("Timeout must be a positive number of seconds.");return}C(!0),T(null),M(null);try{const X={scope:d,eventName:u,matcher:f.trim()||null,command:V,timeoutSec:I,statusMessage:y.trim()||null};l==="edit"?await(a==null?void 0:a({...X,target:N})):await(n==null?void 0:n(X)),M(`${d==="project"?"Project":"Global"} hook ${l==="edit"?"updated":"written"} in hooks.json and trusted.`),i("list"),w(null)}catch(X){T(X instanceof Error?X.message:"Unable to write hooks.json.")}finally{C(!1)}},[N,g,u,f,d,y,v,l,n,a]),re=c.useCallback(async V=>{if(!s||!V.currentHash){T("Hook trust is unavailable in this view.");return}C(!0),T(null),M(null);try{await s({key:V.key,currentHash:V.currentHash}),M("Hook trusted.")}catch(U){T(U instanceof Error?U.message:"Unable to trust hook.")}finally{C(!1)}},[s]),A=c.useCallback(async V=>{if(!o){T("Hook trust is unavailable in this view.");return}C(!0),T(null),M(null);try{await o({key:V.key}),M("Hook untrusted.")}catch(U){T(U instanceof Error?U.message:"Unable to untrust hook.")}finally{C(!1)}},[o]);return{hooksPanelMode:l,hookScope:d,hookEventName:u,hookMatcher:f,hookCommand:g,hookTimeoutSec:v,hookStatusMessage:y,editingHookTarget:N,hookConfigBusy:j,hookConfigError:L,hookConfigSuccess:q,setHooksPanelMode:i,setEditingHookTarget:w,setHookScope:h,setHookEventName:m,setHookMatcher:p,setHookCommand:b,setHookTimeoutSec:x,setHookStatusMessage:k,clearHookConfigStatus:O,resetHookForm:ee,startEditingHook:he,saveHook:E,trustHook:re,untrustHook:A}}var km=`[mcp_servers.example_stdio]
|
|
3601
3608
|
command = "npx"
|
|
3602
3609
|
args = ["-y", "your-mcp-server"]
|
|
3603
|
-
`,rs="MCP entry written to provider config. Restart the backend if it does not appear immediately.";function ym({hostConfigFilesAvailable:e,onReadProviderConfig:r,onWriteProviderConfig:n,setMcpPanelMode:a,onOpenMcp:s}){const[o,l]=c.useState(""),[i,d]=c.useState(""),[h,u]=c.useState(""),[m,f]=c.useState(null),[p,g]=c.useState(!1),[b,v]=c.useState(null),[x,y]=c.useState(null),k=c.useCallback(()=>{v(null),y(null)},[]),j=c.useCallback(async()=>{if(!e||!r)throw new Error("Provider config editing is unavailable for this thread.");const T=await r();return f(T.path),T},[e,r]),w=c.useCallback(async T=>{if(!e||!n)throw new Error("Provider config editing is unavailable for this thread.");const q=await n(T);return f(q.path),q},[e,n]),N=c.useCallback(async()=>{const T=pu(o),q=i.trim();if(!T){v("MCP name must use only letters, numbers, underscore, or hyphen.");return}if(!/^https?:\/\//i.test(q)){v("HTTP MCP URL must start with http:// or https://");return}g(!0),v(null),y(null);try{const A=await j(),D=Xa(A.content,T,gu(T,q));await w(D),y(rs),a("list"),l(""),d(""),s==null||s()}catch(A){v(A instanceof Error?A.message:"Unable to update provider config.")}finally{g(!1)}},[j,o,i,s,a,w]),S=c.useCallback(async()=>{g(!0),v(null),y(null);try{await j(),u(T=>T||wm),a("stdio")}catch(T){v(T instanceof Error?T.message:"Unable to load provider config.")}finally{g(!1)}},[j,a]),L=c.useCallback(async()=>{const T=fu(h);if(!T){v("The raw MCP block must start with a header like [mcp_servers.name].");return}g(!0),v(null),y(null);try{const q=await j(),A=Xa(q.content,T,h);await w(A),y(rs),a("list"),s==null||s()}catch(q){v(q instanceof Error?q.message:"Unable to update provider config.")}finally{g(!1)}},[j,h,s,a,w]);return{mcpHttpName:o,mcpHttpUrl:i,mcpRawBlock:h,mcpConfigPath:m,mcpConfigBusy:p,mcpConfigError:b,mcpConfigSuccess:x,setMcpHttpName:l,setMcpHttpUrl:d,setMcpRawBlock:u,clearMcpConfigStatus:k,prepareRawMcpBlock:S,saveHttpMcp:N,saveRawMcpBlock:L}}function jm({openMenu:e,setOpenMenu:r,slashPanelView:n,setSlashPanelView:a,setMcpPanelMode:s,clearMcpConfigStatus:o,clearHookConfigStatus:l}){const[i,d]=c.useState(null);c.useEffect(()=>{e!=="slash"&&(a("root"),s("list"),o(),l())},[l,o,e,s,a]),c.useEffect(()=>{n!=="mcp"&&(s("list"),o())},[o,s,n]),c.useEffect(()=>{if(!i)return;const u=window.setTimeout(()=>{d(m=>m===i?null:m)},1400);return()=>{window.clearTimeout(u)}},[i]),c.useEffect(()=>{function u(m){(typeof m.composedPath=="function"?m.composedPath():[]).some(g=>g instanceof HTMLElement&&(g.dataset.composerMenuSurface==="true"||g.dataset.composerMenuTrigger==="true"))||e&&r(null)}if(e)return window.addEventListener("pointerdown",u),()=>{window.removeEventListener("pointerdown",u)}},[e,r]);const h=c.useCallback(async u=>{try{await navigator.clipboard.writeText(`$${u}`),d(u)}catch{d(null)}},[]);return{copiedSkillName:i,copySkillInvokeName:h}}function Nm(e,r){const{attachment:n}=e,a=document.createElement("span");if(a.dataset.segmentType="attachment",a.dataset.clientId=n.clientId,a.dataset.placeholder=n.placeholder,a.contentEditable="false",a.className="thread-composer-attachment-chip mx-[0.12rem] inline-flex max-w-full align-baseline",n.kind==="photo"){a.classList.add("thread-composer-attachment-chip-photo","rounded-[0.95rem]","border","border-sky-300/35","bg-sky-300/10","p-1","shadow-sm","shadow-stone-950/20");const l=r[n.clientId];if(l){const d=document.createElement("img");d.src=l,d.alt=n.originalName||"Pasted image",d.className="thread-composer-attachment-thumb h-[4.5rem] w-[6rem] rounded-[0.7rem] bg-stone-950 object-contain",d.draggable=!1,a.append(d)}else{const d=document.createElement("span");d.className="thread-composer-attachment-thumb inline-block h-[4.5rem] w-[6rem] rounded-[0.7rem] bg-stone-900/80",d.setAttribute("aria-hidden","true"),a.append(d)}const i=document.createElement("span");return i.className="thread-composer-attachment-caption ml-2 inline-flex max-w-[8rem] items-center text-[10px] font-medium tracking-[0.08em] text-sky-50",i.textContent=Za(n),a.append(i),a}a.classList.add("items-center","gap-2","rounded-[0.95rem]","border","border-emerald-300/35","bg-emerald-300/10","px-2.5","py-2","text-[10px]","font-medium","tracking-[0.08em]","text-emerald-50","shadow-sm","shadow-stone-950/20");const s=document.createElement("span");s.className="inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-emerald-200/25 bg-emerald-300/12 text-[9px]",s.textContent="FILE";const o=document.createElement("span");return o.className="inline-flex max-w-[10rem] truncate",o.textContent=Za(n),a.append(s,o),a}function Cm(e,r){const n=document.createDocumentFragment();for(const a of e){if(a.type==="text"){n.append(document.createTextNode(a.text===" "?" ":a.text));continue}n.append(Nm(a,r))}return n}function Sm({promptRef:e,isShellView:r,prompt:n,promptSegments:a,attachmentPreviewUrls:s,previewSignature:o,editorSanitizeNonce:l,pendingSelectionRef:i,pendingInsertedAttachmentIdsRef:d,selectionSnapshotRef:h,renderedPreviewSignatureRef:u,renderedSanitizeNonceRef:m,serializeEditorPrompt:f,restoreSelection:p}){c.useLayoutEffect(()=>{const g=e.current;if(!g||r)return;const b=i.current,v=f()!==n||u.current!==o||m.current!==l;v&&(g.replaceChildren(Cm(a,s)),u.current=o,m.current=l),b!==null?(g.focus(),Vu(g,d.current)||p(b),h.current=b):document.activeElement===g&&v&&p(h.current),i.current=null,d.current=[]},[s,l,r,o,n,e,a,d,i,u,m,p,h,f])}function Tm({tokenBudget:e,error:r,onTokenBudgetChange:n,onCancel:a}){return t.jsxs("div",{className:"thread-goal-compose-card relative z-20 mb-1.5 flex flex-wrap items-center gap-2 rounded-2xl border px-3 py-2 text-xs shadow-sm",children:[t.jsx("span",{className:"thread-goal-compose-label font-medium uppercase tracking-[0.16em]",children:"Goal"}),t.jsxs("label",{className:"thread-goal-compose-field flex items-center gap-2",children:[t.jsx("span",{children:"Max tokens (k)"}),t.jsx("input",{"aria-label":"Goal token budget",value:e,onChange:s=>n(s.target.value),inputMode:"numeric",placeholder:"Optional",className:"thread-goal-compose-input h-7 w-24 rounded-full border px-3 text-xs outline-none"})]}),r?t.jsx("span",{className:"thread-goal-compose-error min-w-0 flex-1",children:r}):null,t.jsx("button",{type:"button",onClick:a,className:"thread-goal-compose-cancel rounded-full border px-2.5 py-1 text-[11px] transition",children:"Cancel"})]})}function Em({promptRef:e,prompt:r,disabled:n,promptPlaceholder:a,canInterrupt:s,interruptLabel:o,composerPromptRegionClassName:l,graphChatInputClassName:i,onInterrupt:d,onInput:h,onPaste:u,onKeyDown:m,onKeyUp:f,onMouseUp:p,onBlur:g,onDragEnter:b,onDragOver:v,onDragLeave:x,onDrop:y}){return t.jsxs("div",{"data-slot":"input-group-control",className:`${l} relative w-full`,children:[t.jsxs("div",{className:i,children:[r.length===0&&t.jsx("span",{className:`pointer-events-none absolute left-3 top-3 truncate text-slate-500 sm:left-4 sm:top-4 dark:text-slate-400 ${s?"right-12":"right-3 sm:right-4"}`,children:a}),t.jsx("div",{ref:e,role:"textbox","aria-label":"Prompt","aria-multiline":"true",contentEditable:!n,suppressContentEditableWarning:!0,onInput:h,onPaste:u,onKeyDown:m,onKeyUp:f,onMouseUp:p,onBlur:g,onDragEnter:b,onDragOver:v,onDragLeave:x,onDrop:y,className:`relative z-[1] min-h-[4.25rem] whitespace-pre-wrap break-words pb-2 outline-none sm:min-h-[4.25rem] ${s?"pr-12":""} ${n?"cursor-not-allowed text-slate-500":""}`})]}),s?t.jsx(xt,{type:"button",variant:"ghost",size:"icon-xs","aria-label":o,title:o,onClick:k=>{k.preventDefault(),d==null||d()},className:"thread-graph-composer-stop-button ui-action-danger absolute right-2 top-2 z-30 h-8 w-8 rounded-full text-sm font-medium",children:t.jsx("span",{"aria-hidden":"true",className:"block h-2.5 w-2.5 rounded-[2px] bg-current"})}):null]})}function Lm({prompt:e,promptPlaceholder:r,promptRegionClassName:n,promptInputClassName:a,interruptLabel:s,canInterrupt:o,sendButtonLabel:l,sendButtonClassName:i,sendDisabled:d,onPromptChange:h,onPromptKeyDown:u,onInterrupt:m}){return t.jsxs("div",{className:`${n} relative`,children:[t.jsx("textarea",{"aria-label":"Prompt",disabled:!1,value:e,onChange:f=>h(f.target.value),onKeyDown:u,rows:2,placeholder:r,className:`${a} resize-y pb-10`}),t.jsx("button",{type:"button","aria-label":s,title:s,onClick:()=>void(m==null?void 0:m()),disabled:!o,className:`absolute right-2.5 top-2.5 inline-flex h-8 w-8 items-center justify-center rounded-full border transition ${o?"border-rose-300/55 bg-rose-300/[0.14] text-rose-50 shadow-lg shadow-rose-950/20 hover:bg-rose-300/[0.22]":"cursor-not-allowed border-stone-700/30 bg-stone-400/[0.02] text-stone-500/55 opacity-55"}`,children:t.jsx("span",{"aria-hidden":"true",className:"block h-2.5 w-2.5 rounded-[2px] bg-current"})}),t.jsx("button",{type:"submit","aria-label":"Send Shell Input",onMouseDown:f=>{f.preventDefault()},onPointerDown:f=>{f.preventDefault()},onTouchStart:f=>{f.preventDefault()},disabled:d,className:`absolute bottom-2.5 right-2.5 rounded-full px-3.5 py-1.5 text-sm font-medium shadow-lg shadow-stone-950/30 transition disabled:cursor-not-allowed disabled:bg-stone-700 disabled:text-stone-300 ${i}`,children:l})]})}function Pm({isShellView:e,promptRef:r,prompt:n,disabled:a,promptPlaceholder:s,canInterrupt:o,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,promptInputClassName:h,goalComposeMode:u,goalTokenBudget:m,goalLocalError:f,goalBusy:p,busy:g,sendButtonLabel:b,sendButtonClassName:v,onInterrupt:x,onPromptInput:y,onPromptPaste:k,onPromptKeyDown:j,onPromptKeyUp:w,onPromptMouseUp:N,onPromptBlur:S,onPromptDragEnter:L,onPromptDragOver:T,onPromptDragLeave:q,onPromptDrop:A,onGoalTokenBudgetChange:D,onCancelGoal:J,onShellPromptChange:W}){return{promptSlot:e?null:t.jsx(Em,{promptRef:r,prompt:n,disabled:a,promptPlaceholder:s,canInterrupt:o,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,onInterrupt:x,onInput:y,onPaste:k,onKeyDown:j,onKeyUp:w,onMouseUp:N,onBlur:S,onDragEnter:L,onDragOver:T,onDragLeave:q,onDrop:A}),goalSlot:u&&!e?t.jsx(Tm,{tokenBudget:m,error:f,onTokenBudgetChange:D,onCancel:J}):null,shellPromptSlot:e?t.jsx(Lm,{prompt:n,promptPlaceholder:s,promptRegionClassName:i,promptInputClassName:h,interruptLabel:l,canInterrupt:o,sendButtonLabel:b,sendButtonClassName:v,sendDisabled:p||g,onPromptChange:W,onPromptKeyDown:j,onInterrupt:x}):null}}function zm({collaborationMode:e,onUpdateSettings:r,closeMenu:n}){const[a,s]=c.useState(null),o=a??e;c.useEffect(()=>{s(null)},[e]);const l=c.useCallback(async i=>{const d=hu({nextMode:i.collaborationMode,previousOptimisticMode:a});d.optimisticMode&&s(d.optimisticMode);try{await(r==null?void 0:r(i)),d.closeMenuOnSuccess&&n()}catch(h){throw d.shouldRollbackMode&&s(d.rollbackMode),h}},[n,r,a]);return{displayedCollaborationMode:o,updateSettings:l}}function Im({isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:s,toolbarClassName:o,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,inlineToggleClassName:m,planToggleActiveClassName:f,sendButtonBaseClassName:p,slashPanelView:g,availableToolboxItems:b,busy:v,settingsBusy:x,compactBusy:y,forkBusy:k,fastMode:j,goalComposeMode:w,goalBusy:N,goalStatus:S,activeView:L,disabled:T,model:q,modelOptions:A,modelContextTitle:D,contextUsage:J,reasoningEffort:W,supportedEfforts:O,displayedCollaborationMode:ee,sandboxMode:he,sendButtonLabel:E,sendButtonClassName:re,modelControlsDisabled:_,effortControlsDisabled:V,effortControlTitle:U,forkTurnOptionsState:z,skillsState:X,copiedSkillName:F,hooksPanelMode:I,hooksState:P,hookConfigBusy:Z,hookConfigError:K,hookConfigSuccess:de,editingHookTarget:M,hookScope:Y,hookEventName:te,hookMatcher:ie,hookCommand:ue,hookTimeoutSec:be,hookStatusMessage:Le,mcpPanelMode:ae,mcpState:ve,mcpConfigPath:ke,mcpConfigError:pe,mcpConfigSuccess:ze,mcpConfigBusy:je,mcpHttpName:Me,mcpHttpUrl:Pe,mcpRawBlock:_e,capabilities:Ce,shellControlState:Re,onToggleView:H,onDismissPromptFocus:ce,onSetOpenMenu:R,onToolboxItemClick:$,onSetSlashPanelView:Q,onOpenForkTurns:me,onForkLatest:xe,onForkTurn:Ie,onCopySkillInvokeName:ge,onResetHookForm:Ae,onSetHooksPanelMode:at,onClearHookConfigStatus:Je,onSetEditingHookTarget:Qe,onSetHookScope:De,onSetHookEventName:Be,onSetHookMatcher:lt,onSetHookCommand:He,onSetHookTimeoutSec:tt,onSetHookStatusMessage:it,onSaveHook:Ye,onStartEditingHook:C,onTrustHook:B,onUntrustHook:se,onSetMcpPanelMode:ye,onClearMcpConfigStatus:Oe,onSetMcpHttpName:rt,onSetMcpHttpUrl:nt,onSetMcpRawBlock:Ge,onPrepareRawMcpBlock:Ve,onSaveHttpMcp:ht,onSaveRawMcpBlock:bt,onPickPhoto:fe,onPickFile:Te,onUpdateSettings:Ze,onPasteShell:Ke,onCopyShell:Bt,onClearShell:Gt,onShellControl:Yr}){const Zr=e?null:{open:s==="slash",slashPanelView:g,availableToolboxItems:b,busy:v,forkBusy:k,forkTurnOptionsState:z,skillsState:X,copiedSkillName:F,hooksPanelMode:I,hooksState:P,hostConfigFilesAvailable:Ce.hostConfigFiles,hookTrustAvailable:Ce.hookTrust,hookConfigBusy:Z,hookConfigError:K,hookConfigSuccess:de,editingHookTarget:M,hookScope:Y,hookEventName:te,hookMatcher:ie,hookCommand:ue,hookTimeoutSec:be,hookStatusMessage:Le,mcpPanelMode:ae,mcpState:ve,mcpConfigEditing:Ce.mcpConfigEditing,mcpConfigPath:ke,mcpConfigError:pe,mcpConfigSuccess:ze,mcpConfigBusy:je,mcpHttpName:Me,mcpHttpUrl:Pe,mcpRawBlock:_e,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,onToggle:()=>R(dt=>dt==="slash"?null:"slash"),onToolboxItemClick:$,toolboxItemDisabled:dt=>Gu(dt,{settingsBusy:x,compactBusy:y,busy:v,forkBusy:k}),toolboxItemClassName:dt=>Fu(dt,{fastMode:j,goalComposeMode:w,goalStatus:S,menuItemClassName:d}),toolboxItemStatus:dt=>Bu(dt,{fastMode:j,compactBusy:y,goalComposeMode:w,goalStatus:S,busy:v}),onSetSlashPanelView:Q,onOpenForkTurns:me,onForkLatest:xe,onForkTurn:Ie,onCopySkillInvokeName:ge,onResetHookForm:Ae,onSetHooksPanelMode:at,onClearHookConfigStatus:Je,onSetEditingHookTarget:Qe,onSetHookScope:De,onSetHookEventName:Be,onSetHookMatcher:lt,onSetHookCommand:He,onSetHookTimeoutSec:tt,onSetHookStatusMessage:it,onSaveHook:Ye,onStartEditingHook:C,onTrustHook:B,onUntrustHook:se,onSetMcpPanelMode:ye,onClearMcpConfigStatus:Oe,onSetMcpHttpName:rt,onSetMcpHttpUrl:nt,onSetMcpRawBlock:Ge,onPrepareRawMcpBlock:Ve,onSaveHttpMcp:ht,onSaveRawMcpBlock:bt},Jr=e?null:{open:s==="attachments",iconButtonClassName:l,menuClassName:i,menuItemClassName:d,onToggle:()=>R(dt=>dt==="attachments"?null:"attachments"),onPickPhoto:fe,onPickFile:Te},Qr=e?null:{openMenu:s,model:q,modelOptions:A,modelContextTitle:D,contextUsage:J,reasoningEffort:W,supportedEfforts:O,displayedCollaborationMode:ee,sandboxMode:he,planModeAvailable:Ce.planMode,sandboxModeAvailable:Ce.sandboxMode,settingsBusy:x,goalComposeMode:w,goalBusy:N,activeView:L,disabled:T,fastMode:j,sendButtonLabel:E,sendButtonClassName:re,modelControlsDisabled:_,effortControlsDisabled:V,effortControlTitle:U,inlineToggleClassName:m,menuItemClassName:d,planToggleActiveClassName:f,sendButtonBaseClassName:p,onSetOpenMenu:R,onUpdateSettings:Ze};return{isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:s,toolbarClassName:o,iconButtonClassName:l,slashToolboxProps:Zr,attachmentMenuProps:Jr,settingsToolbarProps:Qr,shellToolsPanelProps:s==="shellTools"?{busy:v,shellControlState:Re,onPaste:Ke,onCopy:Bt,onClear:Gt,onShellControl:Yr}:null,shellControlState:Re,onToggleView:H,onDismissPromptFocus:ce,onSetOpenMenu:R}}function Dn({activeView:e,edgeToEdgeMobile:r=!1,busy:n=!1,settingsBusy:a=!1,compactBusy:s=!1,error:o,model:l=null,reasoningEffort:i=null,fastMode:d=!1,collaborationMode:h="default",sandboxMode:u=null,hideSandboxModeControl:m=!1,modelOptions:f=[],contextUsage:p=null,capabilities:g=null,toolboxItems:b=null,hookCommandTemplates:v=null,mcpConfigFormat:x="none",followTail:y=!1,threadConnected:k=!0,shellAvailable:j=!0,disabled:w=!1,disabledPlaceholder:N,shellControlState:S=null,draftPrompt:L,draftAttachments:T,onPickAttachment:q,skillsState:A={status:"idle",data:null,error:null},mcpState:D={status:"idle",data:null,error:null},hooksState:J={status:"idle",data:null,error:null},goalState:W={status:"idle",data:null,error:null},forkTurnOptionsState:O={status:"idle",data:null,error:null},onDraftChange:ee,onSubmit:he,onInterrupt:E,onCompact:re,onOpenSkills:_,onOpenMcp:V,onOpenHooks:U,onCreateHook:z,onUpdateHook:X,onTrustHook:F,onUntrustHook:I,onOpenGoal:P,onUpdateGoal:Z,onOpenForkTurns:K,onForkLatest:de,onForkTurn:M,onReadProviderConfig:Y,onWriteProviderConfig:te,onToggleFollow:ie,onUpdateSettings:ue,onToggleView:be,onShellCopy:Le,onShellControl:ae,canInterrupt:ve=!1}){var ga;const[ke,pe]=c.useState(null),[ze,je]=c.useState("root"),[Me,Pe]=c.useState("list"),_e=c.useMemo(()=>({fast:(g==null?void 0:g.controls.performanceMode)??!1,compact:(g==null?void 0:g.turns.compact)??!1,goal:(g==null?void 0:g.controls.goals)??!1,fork:(g==null?void 0:g.branching.fork)??!1,skills:(g==null?void 0:g.management.skills)??!1,mcp:(g==null?void 0:g.management.mcpStatus)??!1,hooks:(g==null?void 0:g.management.hooks)??!1,hostConfigFiles:(g==null?void 0:g.management.hostConfigFiles)??!1,mcpConfigEditing:x==="codex-toml"&&!!(g!=null&&g.management.hostConfigFiles)&&!!Y&&!!te,hookTrust:(g==null?void 0:g.management.hookTrust)??!1,planMode:(g==null?void 0:g.controls.planMode)??!1,sandboxMode:(g==null?void 0:g.controls.sandboxMode)??!1}),[g,x,Y,te]),Ce=c.useMemo(()=>$u(b,_e),[_e,b]),Re=c.useRef(null),H=c.useRef(null),ce=c.useRef(null),R=c.useRef(null),$=c.useRef(null),Q=c.useRef([]),me=c.useRef(null),xe=c.useRef(""),Ie=c.useRef(0),ge=e==="shell",Ae=j||ge,at=!!(ge&&(S!=null&&S.isMobileShell)),Je=(S==null?void 0:S.promptLabel)??null,[Qe,De]=c.useState(!1),[Be,lt]=c.useState(0),{prompt:He,attachments:tt,isDraftControlled:it,updateDraft:Ye,flushControlledDraftToHost:C}=gm({isShellView:ge,draftPrompt:L,draftAttachments:T,onDraftChange:ee}),B=pm({attachments:tt,isShellView:ge}),{displayedCollaborationMode:se,updateSettings:ye}=zm({collaborationMode:h,onUpdateSettings:ue,closeMenu:()=>pe(null)}),{forkBusy:Oe,forkLatest:rt,forkTurn:nt}=xm({slashPanelView:ze,onForkLatest:de,onForkTurn:M,closeMenu:()=>pe(null)}),{hooksPanelMode:Ge,hookScope:Ve,hookEventName:ht,hookMatcher:bt,hookCommand:fe,hookTimeoutSec:Te,hookStatusMessage:Ze,editingHookTarget:Ke,hookConfigBusy:Bt,hookConfigError:Gt,hookConfigSuccess:Yr,setHooksPanelMode:Zr,setEditingHookTarget:Jr,setHookScope:Qr,setHookEventName:oa,setHookMatcher:dt,setHookCommand:kl,setHookTimeoutSec:wl,setHookStatusMessage:yl,clearHookConfigStatus:la,resetHookForm:jl,startEditingHook:Nl,saveHook:Cl,trustHook:Sl,untrustHook:Tl}=km({slashPanelView:ze,hookCommandTemplates:v,onCreateHook:z,onUpdateHook:X,onTrustHook:F,onUntrustHook:I}),{goalComposeMode:tr,goalTokenBudget:El,goalBusy:en,goalLocalError:Ll,setGoalTokenBudget:Pl,submitGoal:zl,enterGoalComposeMode:Il,exitGoalComposeMode:ia}=bm({prompt:He,goalTokenBudgetSource:W.data,promptRef:H,onOpenGoal:P,onUpdateGoal:Z,updateDraft:Ye,closeMenu:()=>pe(null),resetSlashPanel:()=>je("root")}),{mcpHttpName:Rl,mcpHttpUrl:Ml,mcpRawBlock:_l,mcpConfigPath:Al,mcpConfigBusy:$l,mcpConfigError:Dl,mcpConfigSuccess:Bl,setMcpHttpName:Gl,setMcpHttpUrl:Fl,setMcpRawBlock:Hl,clearMcpConfigStatus:da,prepareRawMcpBlock:Ol,saveHttpMcp:Ul,saveRawMcpBlock:Wl}=ym({hostConfigFilesAvailable:_e.hostConfigFiles,onReadProviderConfig:Y,onWriteProviderConfig:te,setMcpPanelMode:Pe,onOpenMcp:V}),{copiedSkillName:Vl,copySkillInvokeName:Kl}=jm({openMenu:ke,setOpenMenu:pe,slashPanelView:ze,setSlashPanelView:je,setMcpPanelMode:Pe,clearMcpConfigStatus:da,clearHookConfigStatus:la}),ql=c.useCallback(ne=>{Ye(we=>{if(typeof ne=="function"){const Ee=ne(we.prompt,we.attachments);return{prompt:Ee.prompt,attachments:Ee.attachments??we.attachments}}return{prompt:ne,attachments:we.attachments}})},[Ye]),tn=c.useMemo(()=>f.find(ne=>ne.model===l)??null,[l,f]),Xl=xu(l,p),ca=(tn==null?void 0:tn.supportedReasoningEfforts)??[],Yl=c.useMemo(()=>ru(He,tt),[tt,He]),Zl=c.useMemo(()=>Object.entries(B).sort(([ne],[we])=>ne.localeCompare(we)).map(([ne,we])=>`${ne}:${we}`).join("|"),[B]);function Jl(ne,we){we.stopPropagation();const Ee=Du(ne,{fastMode:d,goalComposeMode:tr});switch(Ee.type){case"toggleFast":ye({fastMode:Ee.fastMode});break;case"runCompact":pe(null),re==null||re();break;case"enterGoalCompose":Il();break;case"exitGoalCompose":ia(),pe(null);break;case"openPanel":je(Ee.panel),Ee.panel==="skills"?_==null||_():Ee.panel==="mcp"?V==null||V():Ee.panel==="hooks"&&(U==null||U());break;case"insertPrompt":an(Ee.text),je("root"),pe(null);break}}function Ft(){const ne=H.current;return ne?Uu(ne):null}const Ql=c.useCallback(ne=>{const we=H.current;!we||!ne||Wu(we,ne)},[]),rn=c.useCallback(()=>{const ne=H.current;return ne?Yo(ne):He},[He]),{appendAttachments:nn,appendDroppedAttachments:ha}=mm({prompt:He,attachments:tt,updateDraft:Ye,getSelection:Ft,selectionSnapshotRef:me,pendingSelectionRef:$,pendingInsertedAttachmentIdsRef:Q,onInserted:()=>pe(null)}),ua=c.useCallback((ne,we)=>{var Ee;if(Ct(),q){q({kind:ne,appendAttachments:(qe,st=ne)=>nn(qe,st),defaultPick:()=>{var qe;return(qe=we.current)==null?void 0:qe.click()}});return}(Ee=we.current)==null||Ee.click()},[nn,Ct,q]);function an(ne){if(!ne)return;const we=Ft()??me.current,Ee=(we==null?void 0:we.start)??He.length,qe=(we==null?void 0:we.end)??Ee,st=tu(ne),Ht=`${He.slice(0,Ee)}${st}${He.slice(qe)}`;Ye(Mi=>({prompt:Ht,attachments:Mi.attachments}));const St=Ee+st.length;$.current={start:St,end:St},me.current={start:St,end:St}}Sm({promptRef:H,isShellView:ge,prompt:He,promptSegments:Yl,attachmentPreviewUrls:B,previewSignature:Zl,editorSanitizeNonce:Be,pendingSelectionRef:$,pendingInsertedAttachmentIdsRef:Q,selectionSnapshotRef:me,renderedPreviewSignatureRef:xe,renderedSanitizeNonceRef:Ie,serializeEditorPrompt:rn,restoreSelection:Ql});function Ct(){var ne;(ne=H.current)==null||ne.blur(),document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.blur()}async function ei(){var ne;if(Ct(),pe(null),!!((ne=navigator.clipboard)!=null&&ne.readText))try{const we=await navigator.clipboard.readText();an(we)}catch{return}}async function ma(){if(it&&C(),tr&&!ge){await zl();return}const ne=lu({prompt:He,attachments:tt,isShellView:ge});!ne||await he(ne)===!1||Ye(()=>({prompt:"",attachments:[]}))}async function ti(ne){ne.preventDefault(),await ma()}function ri(){const ne=rn(),we=Ft();me.current=we;const Ee=H.current;(Ee?Ou(Ee):!1)&&($.current=we,lt(st=>st+1)),Ye(st=>({prompt:ne,attachments:st.attachments.filter(Ht=>ne.includes(Ht.placeholder))}),"deferred")}function ni(ne){var qe,st,Ht,St;const we=An((qe=ne.clipboardData)==null?void 0:qe.items,(st=ne.clipboardData)==null?void 0:st.files),Ee=iu({files:we,plainText:((Ht=ne.clipboardData)==null?void 0:Ht.getData("text/plain"))??"",htmlText:((St=ne.clipboardData)==null?void 0:St.getData("text/html"))??"",htmlToText:Hu});Ee.preventDefault&&ne.preventDefault(),Ee.type==="insert-text"?an(Ee.text):Ee.type==="append-files"&&ha(Ee.files)}function ai(ne){var Ee,qe;const we=Ka(Ya((Ee=ne.dataTransfer)==null?void 0:Ee.items,(qe=ne.dataTransfer)==null?void 0:qe.files));we.preventDefault&&ne.preventDefault(),we.activateDragTarget&&De(!0)}function si(ne){var Ee,qe;const we=Ka(Ya((Ee=ne.dataTransfer)==null?void 0:Ee.items,(qe=ne.dataTransfer)==null?void 0:qe.files));we.preventDefault&&ne.preventDefault(),we.activateDragTarget&&ne.dataTransfer&&(ne.dataTransfer.dropEffect="copy"),we.activateDragTarget&&De(!0)}function oi(ne){ne.currentTarget.contains(ne.relatedTarget)||De(!1)}function li(ne){var qe,st;const we=An((qe=ne.dataTransfer)==null?void 0:qe.items,(st=ne.dataTransfer)==null?void 0:st.files),Ee=du(we);Ee.preventDefault&&ne.preventDefault(),Ee.type==="accept-files"&&(De(!1),ha(Ee.files??[]))}function ii(ne){if(e==="chat"&&ne.key==="/"&&!ne.metaKey&&!ne.ctrlKey&&!ne.altKey&&!n&&!w&&Ce.length>0&&rn().trim().length===0){ne.preventDefault(),je("root"),pe("slash");return}const we=cu({key:ne.key,metaKey:ne.metaKey,ctrlKey:ne.ctrlKey,busy:n,disabled:w});we.preventDefault&&ne.preventDefault(),we.submit&&ma()}const{promptPlaceholder:di,interruptLabel:ci,sendButtonLabel:pa,sendButtonClassName:fa,modelControlsDisabled:hi,effortControlsDisabled:ui,effortControlTitle:mi}=wu({goalComposeMode:tr,goalBusy:en,threadConnected:k,busy:n,isShellView:ge,disabledPlaceholder:N,settingsBusy:a,supportedEffortCount:ca.length,fastMode:d}),{composerLayerClassName:pi,formClassName:fi,composerShellClassName:gi,composerToolbarClassName:xi,composerIconButtonClassName:bi,composerMenuClassName:vi,composerMenuItemClassName:ki,composerInlineToggleClassName:wi,composerPanelButtonClassName:yi,composerChipButtonClassName:ji,composerPlanToggleActiveClassName:Ni,composerSendButtonClassName:Ci,composerPromptRegionClassName:Si,promptInputClassName:Ti,graphChatInputGroupClassName:Ei,graphChatInputClassName:Li}=yu({isShellView:ge,edgeToEdgeMobile:r,isMobileShell:at,openMenu:ke!==null,isDragTargetActive:Qe,busy:n}),Pi=Im({isShellView:ge,canToggleShellView:Ae,isMobileShell:at,shellPromptLabel:Je,openMenu:ke,toolbarClassName:xi,iconButtonClassName:bi,menuClassName:vi,menuItemClassName:ki,panelButtonClassName:yi,chipButtonClassName:ji,inlineToggleClassName:wi,planToggleActiveClassName:Ni,sendButtonBaseClassName:Ci,slashPanelView:ze,availableToolboxItems:Ce,busy:n,settingsBusy:a,compactBusy:s,forkBusy:Oe,fastMode:d,goalComposeMode:tr,goalBusy:en,goalStatus:(ga=W.data)==null?void 0:ga.status,activeView:e,disabled:w,model:l,modelOptions:f,modelContextTitle:Xl,contextUsage:p,reasoningEffort:i,supportedEfforts:ca,displayedCollaborationMode:se,sandboxMode:u,sendButtonLabel:pa,sendButtonClassName:fa,modelControlsDisabled:hi,effortControlsDisabled:ui,effortControlTitle:mi,forkTurnOptionsState:O,skillsState:A,copiedSkillName:Vl,hooksPanelMode:Ge,hooksState:J,hookConfigBusy:Bt,hookConfigError:Gt,hookConfigSuccess:Yr,editingHookTarget:Ke,hookScope:Ve,hookEventName:ht,hookMatcher:bt,hookCommand:fe,hookTimeoutSec:Te,hookStatusMessage:Ze,mcpPanelMode:Me,mcpState:D,mcpConfigPath:Al,mcpConfigError:Dl,mcpConfigSuccess:Bl,mcpConfigBusy:$l,mcpHttpName:Rl,mcpHttpUrl:Ml,mcpRawBlock:_l,capabilities:{hostConfigFiles:_e.hostConfigFiles,hookTrust:_e.hookTrust,mcpConfigEditing:_e.mcpConfigEditing,planMode:_e.planMode,sandboxMode:m?!1:_e.sandboxMode},shellControlState:S,onToggleView:be,onDismissPromptFocus:Ct,onSetOpenMenu:pe,onToolboxItemClick:Jl,onSetSlashPanelView:je,onOpenForkTurns:()=>K==null?void 0:K(),onForkLatest:rt,onForkTurn:nt,onCopySkillInvokeName:Kl,onResetHookForm:jl,onSetHooksPanelMode:Zr,onClearHookConfigStatus:la,onSetEditingHookTarget:Jr,onSetHookScope:Qr,onSetHookEventName:oa,onSetHookMatcher:dt,onSetHookCommand:kl,onSetHookTimeoutSec:wl,onSetHookStatusMessage:yl,onSaveHook:Cl,onStartEditingHook:Nl,onTrustHook:Sl,onUntrustHook:Tl,onSetMcpPanelMode:Pe,onClearMcpConfigStatus:da,onSetMcpHttpName:Gl,onSetMcpHttpUrl:Fl,onSetMcpRawBlock:Hl,onPrepareRawMcpBlock:Ol,onSaveHttpMcp:Ul,onSaveRawMcpBlock:Wl,onPickPhoto:()=>ua("photo",ce),onPickFile:()=>ua("file",R),onUpdateSettings:ne=>void ye(ne),onPasteShell:()=>void ei(),onCopyShell:()=>{Ct(),pe(null),Le==null||Le()},onClearShell:()=>{Ct(),pe(null),he({prompt:"clear"})},onShellControl:ne=>{Ct(),pe(null),ae==null||ae(ne)}}),{promptSlot:zi,goalSlot:Ii,shellPromptSlot:Ri}=Pm({isShellView:ge,promptRef:H,prompt:He,disabled:w,promptPlaceholder:di,canInterrupt:ve,interruptLabel:ci,composerPromptRegionClassName:Si,graphChatInputClassName:Li,promptInputClassName:Ti,goalComposeMode:tr,goalTokenBudget:El,goalLocalError:Ll,goalBusy:en,busy:n,sendButtonLabel:pa,sendButtonClassName:fa,onInterrupt:E,onPromptInput:ri,onPromptPaste:ni,onPromptKeyDown:ii,onPromptKeyUp:()=>{me.current=Ft()},onPromptMouseUp:()=>{me.current=Ft()},onPromptBlur:()=>{me.current=Ft(),De(!1),it&&C()},onPromptDragEnter:ai,onPromptDragOver:si,onPromptDragLeave:oi,onPromptDrop:li,onGoalTokenBudgetChange:Pl,onCancelGoal:ia,onShellPromptChange:ql});return t.jsx(em,{activeView:e,layerClassName:pi,formClassName:fi,shellClassName:gi,inputGroupClassName:Ei,error:o,followTail:y,photoInputRef:ce,fileInputRef:R,onAppendAttachments:nn,onToggleFollow:ie,onSubmit:ti,formRef:Re,promptSlot:zi,toolbarSlot:t.jsx(cm,{...Pi}),goalSlot:Ii,shellPromptSlot:Ri})}var Rm=c.createContext(null);function Jo(){return c.useContext(Rm)}function Mt(e){return e?new Date(e).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"}):"Time unavailable"}function Zt(e){return e?new Date(e).toLocaleString():"Time unavailable"}function Mm(e){switch(e){case"idle":return"Idle";case"running":return"Running";case"interrupted":return"Interrupted";case"failed":return"Failed";case"not_loaded":return"Not Loaded";case"system_error":return"System Error"}}function _m(e){switch(e){case"idle":return"ui-status-neutral";case"running":return"ui-status-info";case"interrupted":return"ui-status-warning";case"failed":case"system_error":return"ui-status-danger";case"not_loaded":return"ui-status-neutral"}}function Qo(e){switch(e){case"sending":return"Sending";case"completed":return"Completed";case"interrupted":return"Interrupted";case"failed":return"Failed";case"inProgress":return"Running"}}function Am({open:e,title:r,label:n,value:a,busy:s=!1,onChange:o,onCancel:l,onSubmit:i}){if(c.useEffect(()=>{if(!e)return;function h(u){u.key==="Escape"&&!s&&l()}return window.addEventListener("keydown",h),()=>{window.removeEventListener("keydown",h)}},[s,l,e]),!e)return null;function d(h){h.preventDefault(),i()}return Dr.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[95] flex items-center justify-center p-4 sm:p-6",children:[t.jsx("button",{type:"button","aria-label":"Close rename dialog",onClick:l,disabled:s,className:"absolute inset-0 bg-stone-950/78 backdrop-blur-sm disabled:cursor-not-allowed"}),t.jsxs("form",{role:"dialog","aria-modal":"true","aria-label":r,onSubmit:d,className:"relative z-[1] w-full max-w-md rounded-[1.6rem] border border-stone-700 bg-stone-900 p-5 shadow-2xl shadow-stone-950/40 sm:p-6",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium text-stone-100",children:r}),t.jsx("p",{className:"mt-1 text-sm text-stone-500",children:"Changes are saved only after confirmation."})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:l,disabled:s,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-stone-700 text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsxs("div",{className:"mt-5",children:[t.jsx("label",{htmlFor:"rename-dialog-input",className:"text-sm font-medium text-stone-200",children:n}),t.jsx("input",{id:"rename-dialog-input","aria-label":n,autoFocus:!0,value:a,onChange:h=>o(h.target.value),className:"mt-2 w-full rounded-2xl border border-stone-700 bg-stone-950 px-4 py-3 text-stone-100 outline-none transition focus:border-amber-300"})]}),t.jsxs("div",{className:"mt-5 flex items-center justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:l,disabled:s,className:"rounded-full border border-stone-700 px-4 py-2 text-sm font-medium text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),t.jsx("button",{type:"submit",disabled:s||!a.trim(),className:"ui-action-success rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:"Save"})]})]})]}),document.body)}function $m({children:e,effectiveTheme:r,layoutMode:n,themeMode:a,viewportConstrained:s}){return t.jsx("div",{className:`thread-ui-shell ${r==="dark"?"thread-ui-theme-dark dark":""} ${s?"thread-ui-viewport-constrained":""} ${s?"h-[100svh] max-h-[100svh] min-h-0 overflow-hidden overscroll-none":"min-h-[100svh] overflow-hidden"} bg-[#f6f8fb] text-slate-900 transition-colors duration-200 sm:p-2`,"data-theme-effective":r,"data-theme-mode":a??r,"data-thread-layout":n,children:e})}function Dm({children:e,roomsRailCollapsed:r}){return t.jsx("div",{className:`thread-shell-frame relative h-full min-h-0 ${r?"is-rail-collapsed sm:grid-cols-[56px_minmax(0,1fr)]":"sm:grid-cols-[264px_minmax(0,1fr)]"}`,children:e})}function Bm({onClose:e,open:r}){return r?t.jsx("button",{type:"button","aria-hidden":"true",tabIndex:-1,className:"thread-mobile-only-block thread-mobile-scrim fixed inset-0 z-40 bg-slate-950/35 backdrop-blur-[1px]",onClick:e}):null}function Gm({children:e,collapsed:r,mobileOpen:n}){return t.jsx("aside",{className:`thread-graph-rooms-surface thread-rooms-rail fixed inset-y-0 left-0 z-50 flex min-h-0 min-w-0 w-[min(20rem,calc(100vw-2rem))] flex-col overflow-x-hidden border-r border-slate-200/80 bg-white shadow-[0_20px_50px_rgba(15,23,42,0.18)] transition-transform duration-200 ease-out sm:static sm:z-auto sm:w-auto sm:translate-x-0 sm:rounded-[12px] sm:border sm:shadow-[0_10px_30px_rgba(15,23,42,0.04)] ${n?"translate-x-0":"pointer-events-none -translate-x-full sm:pointer-events-auto"} ${r?"thread-ui-rail-collapsed sm:items-center":""}`,style:{paddingTop:"var(--android-safe-area-top, 0px)"},children:e})}function Fm({children:e}){return t.jsx("main",{className:"thread-shell-main h-full min-h-0 min-w-0 overflow-hidden",children:t.jsx("div",{className:"thread-main-panel thread-shell-card flex h-full min-h-0 flex-col overflow-hidden bg-white shadow-[0_10px_30px_rgba(15,23,42,0.04)] sm:rounded-[12px] sm:border sm:border-slate-200/80",children:e})})}function Hm({children:e}){return t.jsx("div",{className:"thread-topbar-surface flex shrink-0 flex-col border-b border-slate-200 bg-white pt-[env(safe-area-inset-top)] sm:pt-0",children:e})}function Om({children:e}){return t.jsx("div",{className:"thread-split-region min-h-0 flex-1 overflow-hidden p-0 sm:p-2",children:e})}ko();Nt();function ns({...e}){return t.jsx(Gi,{"data-slot":"dialog",...e})}function as({...e}){return t.jsx(Fi,{"data-slot":"dialog-trigger",...e})}function Um({...e}){return t.jsx(Vi,{"data-slot":"dialog-portal",...e})}function Wm({className:e,...r}){return t.jsx(Ki,{"data-slot":"dialog-overlay",className:et("fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",e),...r})}function ss({children:e,className:r,showCloseButton:n=!0,...a}){return t.jsxs(Um,{"data-slot":"dialog-portal",children:[t.jsx(Wm,{}),t.jsxs(Hi,{"data-slot":"dialog-content",className:et("fixed left-[50%] top-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg",r),...a,children:[e,n?t.jsxs(Oi,{"data-slot":"dialog-close",className:"absolute right-4 top-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[t.jsx(G.XIcon,{}),t.jsx("span",{className:"sr-only",children:"Close"})]}):null]})]})}function os({className:e,...r}){return t.jsx("div",{"data-slot":"dialog-header",className:et("flex flex-col gap-2 text-center sm:text-left",e),...r})}function ls({className:e,...r}){return t.jsx(Ui,{"data-slot":"dialog-title",className:et("text-lg font-semibold leading-none",e),...r})}function is({className:e,...r}){return t.jsx(Wi,{"data-slot":"dialog-description",className:et("text-sm text-muted-foreground",e),...r})}var Vm=[{value:"system",label:"Follow system",icon:G.Monitor},{value:"dark",label:"Dark",icon:G.Moon},{value:"light",label:"Light",icon:G.Sun}];function Km({thread:e,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a={},onOpenThread:s,getThreadHref:o,renderThreadLink:l,onBeginRenameThread:i,onDeleteThread:d,showDeleteButton:h=!1,showSessionCopyButton:u=!1,collapsed:m=!1}){const[f,p]=c.useState("idle"),g=c.useRef(null),b=a[e.workspaceId],v=b&&!n?b:null,x=r===e.id;c.useEffect(()=>()=>{g.current!==null&&window.clearTimeout(g.current)},[]);async function y(){const S=e.providerSessionId;if(S)try{await navigator.clipboard.writeText(S),p("copied"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>p("idle"),1200)}catch{p("failed"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>p("idle"),1600)}}const k=()=>s(e.id),j=`thread-graph-room-card group flex w-full items-center gap-3 rounded-xl border text-left transition ${x?"is-active":""} ${m?"justify-center px-2 py-2":"px-3 py-2.5"}`,w=t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`thread-graph-room-card-icon flex h-8 w-8 shrink-0 items-center justify-center rounded-full ${x?"is-active":""}`,children:t.jsx(G.MessageSquare,{className:"h-4 w-4"})}),t.jsxs("div",{className:`min-w-0 flex-1 ${m?"thread-desktop-collapsed-hidden":""}`,children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[t.jsx("p",{className:"thread-graph-room-card-title min-w-0 flex-1 truncate text-sm font-medium",title:e.title,children:e.title}),i&&!m?t.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),S.preventDefault(),i(e)},"aria-label":`Rename thread ${e.title}`,title:"Rename thread",className:"thread-card-quiet-button inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full transition",children:t.jsx(G.Pencil,{className:"h-3 w-3"})}):null,u&&e.providerSessionId?t.jsx("button",{type:"button","aria-label":"Copy session ID",title:f==="copied"?"Copied":f==="failed"?"Copy failed":"Copy session ID",onClick:S=>{S.stopPropagation(),S.preventDefault(),y()},className:"thread-card-quiet-button thread-card-session-copy-button inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition",children:t.jsx(G.Copy,{className:"h-3.5 w-3.5"})}):null]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2",children:[v?t.jsx("p",{className:"thread-graph-room-card-meta min-w-0 flex-1 truncate text-[11px] text-[var(--theme-fg-muted)]",title:v,children:v}):t.jsx("span",{className:"min-w-0 flex-1","aria-hidden":"true"}),t.jsx("span",{className:`shrink-0 rounded-full border px-1.5 py-0.5 text-[9px] uppercase tracking-normal ${_m(e.status)}`,children:Mm(e.status)}),t.jsx("time",{className:"shrink-0 text-[11px] text-[var(--theme-fg-muted)]",dateTime:e.lastTurnStartedAt??e.updatedAt,children:Mt(e.lastTurnStartedAt??e.updatedAt)})]})]}),h&&d&&!m?t.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),S.preventDefault(),d(e)},"aria-label":`Delete thread ${e.title}`,className:"thread-card-danger-button shrink-0 rounded-full p-1 transition",title:"Delete thread",children:t.jsx(G.Trash2,{className:"h-3.5 w-3.5"})}):null]}),N=o==null?void 0:o(e.id);return l?t.jsx(t.Fragment,{children:l({thread:e,children:w,className:j,onClick:k})}):N?t.jsx("a",{href:N,onClick:S=>{S.preventDefault(),k()},title:m?e.title:void 0,className:j,children:w}):t.jsx("div",{role:"link",tabIndex:0,onClick:k,onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),k())},title:m?e.title:void 0,className:j,children:w})}function qm({threads:e,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a={},onOpenThread:s,getThreadHref:o,renderThreadLink:l,onBeginRenameThread:i,onDeleteThread:d,scrollable:h=!1,maxHeightClassName:u="max-h-full",showDeleteButton:m=!1,showSessionCopyButton:f=!1,collapsed:p=!1}){const g=h?`min-h-0 min-w-0 overflow-x-hidden overflow-y-auto overscroll-contain pr-1 ${u}`:"";return t.jsx("div",{className:g,children:t.jsx("div",{className:"min-w-0 space-y-1",children:e.map(b=>t.jsx(Km,{thread:b,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a,onOpenThread:s,showDeleteButton:m,showSessionCopyButton:f,collapsed:p,...o?{getThreadHref:o}:{},...l?{renderThreadLink:l}:{},...i?{onBeginRenameThread:i}:{},...d?{onDeleteThread:d}:{}},b.id))})})}function Xm({threads:e,status:r,loading:n=!1,error:a,viewportConstrained:s=!1,layoutMode:o="responsive",effectiveTheme:l,themeMode:i,onThemeModeChange:d,showMobileNewThreadShortcut:h=!0,settingsDialogOpen:u,onSettingsDialogOpenChange:m,mobileHeaderAction:f,currentThreadId:p,currentThreadLabel:g=null,currentWorkspaceId:b=null,currentWorkspaceLabel:v=null,sessionLabel:x=null,usageLabel:y=null,topbarActions:k,metaContent:j,settingsContent:w,globalSettingsContent:N,workspaceLabels:S={},workspaceReturnHref:L,onWorkspaceReturn:T,getThreadHref:q,onOpenThread:A,getNewThreadHref:D,newThreadHref:J,newThreadLabel:W="New Chat",onNewThread:O,onNewThreadTitle:ee,renderThreadLink:he,onCloseAppNavigation:E,onRenameThread:re,onDeleteThread:_,workspaceContent:V,workspaceTitle:U="Workspace",workspaceActions:z,children:X}){const F=Jo(),[I,P]=c.useState(()=>typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)").matches:!1),Z=i??(F==null?void 0:F.themeMode)??"system",K=l??(F==null?void 0:F.effectiveTheme)??(Z==="system"?I?"dark":"light":Z),[de,M]=c.useState(!1),[Y,te]=c.useState(!1),[ie,ue]=c.useState(!1),[be,Le]=c.useState(()=>typeof window<"u"?window.matchMedia("(max-width: 639px)").matches:o==="mobile"),[ae,ve]=c.useState("workspace"),[ke,pe]=c.useState(null),[ze,je]=c.useState(""),[Me,Pe]=c.useState(null),[_e,Ce]=c.useState(!1),[Re,H]=c.useState(""),[ce,R]=c.useState(!1),[$,Q]=c.useState(!1),[me,xe]=c.useState("session");c.useEffect(()=>{if(typeof window>"u")return;const fe=window.matchMedia("(max-width: 639px)"),Te=()=>{Le(fe.matches)};return Te(),fe.addEventListener("change",Te),()=>{fe.removeEventListener("change",Te)}},[]),c.useEffect(()=>{if(typeof window>"u")return;const fe=window.matchMedia("(prefers-color-scheme: dark)"),Te=()=>{P(fe.matches)};return Te(),fe.addEventListener("change",Te),()=>{fe.removeEventListener("change",Te)}},[]);const Ie=c.useMemo(()=>[...b?e.filter(Te=>Te.workspaceId===b):e].sort((Te,Ze)=>{if(Te.id===p)return-1;if(Ze.id===p)return 1;const Ke=Date.parse(Te.lastTurnStartedAt??Te.updatedAt);return Date.parse(Ze.lastTurnStartedAt??Ze.updatedAt)-Ke}),[p,b,e]),ge=J??(D==null?void 0:D(b)),Ae=v??b??"all",at=x??g??p??"default_session",Je=y??(r!=null&&r.state?`runtime ${r.state}`:"waiting for agent usage"),Qe=d??(F==null?void 0:F.setThemeMode),De=!!Qe,Be=()=>{M(!1),E==null||E()};async function lt(fe){if(!re)return;const Te=ze.trim();if(Te){Pe(fe);try{await re(fe,Te),pe(null),je("")}finally{Pe(null)}}}function He(fe){pe(fe.id),je(fe.title)}function tt(){pe(null),je("")}function it(fe){A==null||A(fe),Be()}function Ye(fe){if(!ge||!fe.trim())return ge;try{const Te=new URL(ge,window.location.origin);return Te.searchParams.set("title",fe.trim()),`${Te.pathname}${Te.search}${Te.hash}`}catch{const Te=ge.includes("?")?"&":"?";return`${ge}${Te}title=${encodeURIComponent(fe.trim())}`}}async function C(){const fe=Re.trim();R(!0);try{if(fe&&ee){await ee(fe),H(""),Ce(!1),Be();return}if(ge){window.location.assign(Ye(fe)??ge);return}await(O==null?void 0:O()),H(""),Ce(!1),Be()}finally{R(!1)}}function B(fe,Te=!1){const Ze=Te?t.jsxs(t.Fragment,{children:[t.jsx(G.Plus,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:W})]}):t.jsxs(t.Fragment,{children:[t.jsx(G.Plus,{className:"h-4 w-4"}),t.jsx("span",{children:W})]});return t.jsxs(ns,{open:_e,onOpenChange:Ke=>{ce||Ce(Ke)},children:[t.jsx(as,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":Te?W:void 0,title:W,className:fe,children:Ze})}),t.jsxs(ss,{"data-testid":"create-thread-dialog","data-theme-effective":K,"data-theme-mode":Z,className:"thread-graph-create-thread-dialog thread-graph-dialog",children:[t.jsxs(os,{children:[t.jsx(ls,{children:"Create New Chat"}),t.jsx(is,{children:"Name the room so it is easy to find later."})]}),t.jsxs("div",{className:"grid gap-3",children:[t.jsx("input",{id:"thread-graph-create-thread-title",name:"thread-title",value:Re,onChange:Ke=>H(Ke.target.value),onKeyDown:Ke=>{Ke.key==="Enter"&&(Ke.preventDefault(),C())},placeholder:"Chat name","aria-label":"Chat name",autoComplete:"off",className:"thread-graph-create-thread-input h-10 rounded-md border px-3 text-sm outline-none transition"}),t.jsx("button",{type:"button",onClick:()=>void C(),disabled:ce,className:"thread-graph-create-thread-submit inline-flex h-10 items-center justify-center rounded-md px-4 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:ce?"Creating...":"Create"})]})]})]})}function se(){if(!w&&!j&&!N&&!De)return null;const fe=!!(w||j),Te=!!N,Ze=me==="global"&&Te||!fe&&Te?"global":"session";return t.jsxs(ns,{...u!==void 0?{open:u}:{},...m?{onOpenChange:m}:{},children:[t.jsx(as,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":"Open settings",title:"Settings",className:"thread-icon-button inline-flex h-10 w-10 items-center justify-center rounded-full sm:h-9 sm:w-9",children:t.jsx(G.Settings,{className:"h-4 w-4"})})}),t.jsxs(ss,{"data-testid":"settings-dialog","data-theme-effective":K,"data-theme-mode":Z,className:"thread-graph-settings-dialog thread-graph-dialog",children:[t.jsxs(os,{children:[t.jsx(ls,{children:"Settings"}),t.jsx(is,{children:"Manage this session and host-wide preferences."})]}),De?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"font-medium text-[var(--theme-fg)]",children:"Appearance"}),t.jsxs("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:["Current theme: ",K]})]}),t.jsx("div",{className:"thread-graph-theme-mode-group grid grid-cols-3 gap-1 rounded-lg border p-1",role:"group","aria-label":"Theme mode",children:Vm.map(Ke=>{const Bt=Ke.icon,Gt=Z===Ke.value;return t.jsxs("button",{type:"button","data-testid":`theme-mode-${Ke.value}`,"aria-pressed":Gt,disabled:!De,onClick:()=>Qe==null?void 0:Qe(Ke.value),className:`thread-graph-theme-mode-button inline-flex min-h-9 items-center justify-center gap-1.5 rounded-md px-2 text-xs font-medium transition ${Gt?"is-selected":""}`,children:[t.jsx(Bt,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:"truncate",children:Ke.label})]},Ke.value)})})]})}):null,t.jsxs("div",{className:"thread-graph-settings-tabs grid grid-cols-2 gap-1 rounded-lg border p-1",children:[t.jsx("button",{type:"button","aria-pressed":Ze==="session",onClick:()=>xe("session"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Ze==="session"?"is-active":""}`,children:"Session"}),t.jsx("button",{type:"button","aria-pressed":Ze==="global",disabled:!Te,onClick:()=>xe("global"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Ze==="global"?"is-active":""}`,children:"Global"})]}),t.jsx("div",{className:"thread-graph-settings-body mt-4 min-h-0 overflow-y-auto pr-1 text-sm",children:Ze==="session"?t.jsxs("div",{className:"grid gap-4",children:[w?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:w}):null,j?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:j}):null,fe?null:t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3 text-[var(--theme-fg-muted)]",children:"No session settings are available."})]}):t.jsx("div",{className:"thread-graph-settings-global-content",children:N})})]})]})}function ye(fe=!1){return t.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:t.jsxs("section",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs("div",{className:`mb-3 flex items-center gap-2 px-2 text-xs font-medium tracking-normal text-[var(--theme-fg-muted)] ${fe?"justify-center":""}`,children:[t.jsx(G.Rows3,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:fe?"sr-only":"",children:"Rooms"}),!fe&&n?t.jsx("span",{className:"ml-auto text-xs text-[var(--theme-fg-muted)]",children:"Refreshing..."}):null]}),t.jsxs("div",{className:"min-h-0 min-w-0 flex-1 overflow-x-hidden overflow-y-auto px-1",children:[a?t.jsx("div",{className:"rounded-xl border border-rose-500/30 bg-rose-500/10 px-3 py-3 text-sm text-rose-900 dark:text-rose-100",children:a}):null,!a&&Ie.length===0&&!n?t.jsx("div",{className:"rounded-xl border border-dashed border-[var(--theme-border)] bg-[var(--theme-surface)] px-4 py-6 text-sm text-[var(--theme-fg-muted)]",children:"No threads available in this view."}):null,Ie.length>0?t.jsx(qm,{threads:Ie,currentThreadId:p,currentWorkspaceId:b,workspaceLabels:S,onOpenThread:it,collapsed:fe,...re?{onBeginRenameThread:He}:{},showDeleteButton:!!_,...q?{getThreadHref:q}:{},...he?{renderThreadLink:he}:{},..._?{onDeleteThread:_}:{}}):null]})]})})}function Oe(){return V?t.jsxs("div",{className:"thread-workspace-panel relative flex h-full min-h-0 flex-col overflow-hidden rounded-[12px] border",children:[t.jsx("button",{type:"button",onClick:()=>ue(!0),className:"thread-workspace-collapse-tab thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(G.ChevronsRight,{className:"h-4 w-4"})}),z?t.jsx("div",{className:"pointer-events-none absolute right-12 top-2 z-20 flex items-center gap-1",children:t.jsx("div",{className:"pointer-events-auto",children:z})}):null,t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:V})]}):t.jsxs("div",{className:"thread-workspace-panel flex h-full min-h-0 flex-col overflow-hidden rounded-[12px] border",children:[t.jsxs("div",{className:"thread-workspace-panel-header flex h-12 shrink-0 items-center justify-between gap-3 border-b border-[var(--theme-border)] px-3 sm:h-[60px] sm:px-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-base font-semibold text-[var(--theme-fg)] sm:text-[18px]",children:U}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:v??b??"Current context"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[z,t.jsx("button",{type:"button",onClick:()=>ue(!0),className:"thread-workspace-small-toggle thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(G.ChevronsRight,{className:"h-4 w-4"})})]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:V??t.jsxs("div",{className:"grid h-full min-h-0 gap-3 overflow-y-auto p-3 text-sm text-[var(--theme-fg-soft)]",children:[t.jsxs("div",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:"Runtime"}),t.jsx("p",{className:"mt-2 text-[var(--theme-fg)]",children:(r==null?void 0:r.state)??"unknown"})]}),t.jsxs("div",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:"Workspace"}),t.jsx("p",{className:"mt-2 break-words text-[var(--theme-fg)]",children:v??b??"All threads"})]})]})})]})}const rt=!!V,nt=o==="mobile"||o==="responsive"&&be,Ge=nt,Ve=Ge&&!de,bt=!!(L||T)?t.jsx("a",{href:L??"#",onClick:fe=>{T&&(fe.preventDefault(),T())},className:"thread-icon-button inline-flex h-10 w-10 items-center justify-center rounded-full sm:h-9 sm:w-9",title:"Back to workspace","aria-label":"Back to workspace",children:t.jsx(G.ArrowLeft,{className:"h-4 w-4"})}):null;return t.jsxs(t.Fragment,{children:[t.jsx($m,{effectiveTheme:K,layoutMode:o,themeMode:Z,viewportConstrained:s,children:t.jsxs(Dm,{roomsRailCollapsed:Y,children:[t.jsx(Bm,{open:de,onClose:()=>M(!1)}),t.jsxs(Gm,{collapsed:Y,mobileOpen:de,children:[t.jsx("div",{className:`thread-rooms-rail-header flex h-[calc(3.75rem+env(safe-area-inset-top))] shrink-0 items-end border-b border-[var(--theme-border)] px-4 pb-3 sm:h-16 sm:items-center sm:pb-0 ${Y?"sm:w-full sm:justify-center sm:px-2":""}`,children:t.jsxs("div",{className:`flex w-full items-center gap-3 ${Y?"sm:justify-center":"justify-between"}`,children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[t.jsx("button",{type:"button",onClick:()=>te(fe=>!fe),className:"thread-icon-button thread-desktop-only-flex h-9 w-9 shrink-0 items-center justify-center rounded-full",title:Y?"Expand rooms":"Collapse rooms","aria-label":Y?"Expand rooms":"Collapse rooms",children:Y?t.jsx(G.PanelLeftOpen,{className:"h-4 w-4"}):t.jsx(G.PanelLeftClose,{className:"h-4 w-4"})}),t.jsx("div",{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-[var(--theme-accent-solid)] text-sm font-semibold text-[var(--theme-accent-solid-fg)] ${Y?"thread-desktop-collapsed-hidden":""}`,children:(v??"R").charAt(0).toUpperCase()}),t.jsxs("div",{className:`min-w-0 ${Y?"thread-desktop-collapsed-hidden":""}`,children:[t.jsx("p",{className:"truncate text-sm font-semibold text-[var(--theme-fg)]",children:v??"Remote Codex"}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:b??"Thread workspace"})]})]}),t.jsxs("div",{className:`flex shrink-0 items-center gap-1 ${Y?"thread-desktop-collapsed-hidden":""}`,children:[se(),bt,t.jsx("button",{type:"button",onClick:()=>M(!1),"aria-label":"Close rooms",title:"Close rooms",className:"thread-icon-button thread-mobile-only-inline-flex h-10 w-10 items-center justify-center rounded-full",children:t.jsx(G.X,{className:"h-4 w-4"})})]})]})}),t.jsx("div",{className:`thread-graph-new-room-strip flex shrink-0 items-center border-b ${Y?"h-12 w-full justify-center px-2 sm:h-12":"h-[68px] px-4"}`,children:B(`thread-graph-new-room-button inline-flex items-center justify-center rounded-xl font-medium transition ${Y?"h-9 w-9 p-0":"h-11 w-full gap-2 px-3 text-sm sm:h-9"}`,Y)}),t.jsx("div",{className:`flex min-h-0 flex-1 flex-col ${Y?"w-full px-2 py-2":"px-3 py-3"}`,children:ye(Y)})]}),t.jsxs(Fm,{children:[t.jsx(Hm,{children:t.jsx("div",{className:"thread-topbar-row flex min-h-12 items-center px-3 py-1.5 sm:min-h-12 sm:px-4",children:t.jsxs("div",{className:"flex w-full items-center justify-between gap-3 sm:gap-4",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2 sm:gap-3",children:[Ve?t.jsx("button",{type:"button",onClick:()=>M(!0),"aria-label":"Open rooms",title:"Open rooms",className:"thread-icon-button thread-mobile-only-inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-full",children:t.jsx(G.Menu,{className:"h-4 w-4"})}):null,t.jsxs("div",{className:"min-w-0",children:[Ge?t.jsx("h1",{className:"thread-mobile-only-block min-w-0 truncate text-sm font-semibold leading-none text-[var(--theme-fg)]",children:g??"Shared Workspace"}):null,t.jsxs("div",{className:"relative flex min-w-0 items-center gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{Q(fe=>!fe)},"aria-expanded":$,"aria-haspopup":"dialog",className:"thread-topbar-meta-row flex min-w-0 max-w-full items-center gap-1 text-left text-[11px] leading-none sm:text-xs",title:"Session and usage",children:[t.jsx("span",{className:"shrink-0",children:"Room"}),t.jsx("span",{className:"truncate font-mono",children:Ae})]}),$?t.jsxs("div",{className:"thread-topbar-details-popover absolute left-0 top-[calc(100%+0.5rem)] z-50 w-[min(26rem,calc(100vw-1.5rem))] rounded-lg border p-2.5 shadow-lg",role:"dialog","aria-label":"Session and usage",children:[t.jsxs("button",{type:"button",onClick:()=>{var fe;Ae&&((fe=navigator.clipboard)==null||fe.writeText(Ae))},className:"thread-topbar-meta-row flex min-w-0 max-w-full items-center gap-2 text-left text-xs leading-5",title:"Copy room ID",children:[t.jsx("span",{className:"w-12 shrink-0",children:"Room"}),t.jsx("span",{className:"truncate font-mono",children:Ae})]}),t.jsxs("button",{type:"button",onClick:()=>{var fe;at&&((fe=navigator.clipboard)==null||fe.writeText(at))},className:"thread-topbar-meta-row flex min-w-0 max-w-full items-center gap-2 text-left text-xs leading-5",title:"Copy session ID",children:[t.jsx("span",{className:"w-12 shrink-0",children:"Session"}),t.jsx("span",{className:"truncate font-mono",children:at})]}),t.jsxs("div",{className:"thread-topbar-meta-row mt-1 flex min-w-0 max-w-full items-center gap-2 text-xs leading-5",title:"Room token usage",children:[t.jsx("span",{className:"w-12 shrink-0",children:"Usage"}),t.jsx("span",{className:"truncate font-mono",children:Je})]})]}):null]})]})]}),t.jsxs("div",{className:"inline-flex shrink-0 items-center gap-2",children:[k?t.jsx("div",{className:"thread-graph-topbar-actions thread-desktop-only-inline-flex items-center rounded-lg border p-0.5 shadow-none",children:k}):null,Ge&&rt?t.jsx("button",{type:"button",onClick:()=>ve(fe=>fe==="workspace"?"chat":"workspace"),"aria-label":ae==="workspace"?"Show chat":"Show workspace",title:ae==="workspace"?"Show chat":"Show workspace",className:"thread-icon-button thread-mobile-only-inline-flex h-10 w-10 items-center justify-center rounded-full",children:ae==="workspace"?t.jsx(G.MessageSquare,{className:"h-4 w-4"}):t.jsx(G.Folder,{className:"h-4 w-4"})}):null,Ge?f:null,Ge&&h?B("thread-secondary-action inline-flex h-10 items-center justify-center gap-2 rounded-lg border px-3 text-sm font-medium sm:h-9"):null]})]})})}),t.jsx(Om,{children:rt&&!ie?nt?t.jsxs("div",{className:"thread-split-container thread-graph-shell-mobile-split h-full min-h-0 overflow-hidden",children:[t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${ae==="chat"?"block":"thread-mobile-chat-hidden"}`,children:X}),t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${ae==="workspace"?"block":"thread-mobile-workspace-hidden"}`,children:Oe()})]}):t.jsxs(Tn,{direction:"horizontal",className:"thread-split-container thread-graph-shell-resizable thread-graph-shell-desktop-split h-full min-h-0 overflow-hidden",children:[t.jsx(Xt,{defaultSize:47,minSize:30,maxSize:75,className:"thread-split-chat-pane min-w-0 overflow-hidden",children:X}),t.jsx(En,{className:"thread-resize-handle w-2 bg-transparent after:w-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(Xt,{defaultSize:53,minSize:30,maxSize:70,className:"thread-split-workspace-pane min-w-0 overflow-hidden",children:Oe()})]}):t.jsxs("div",{className:"thread-split-container relative h-full min-h-0 overflow-hidden",children:[rt&&ie?t.jsx("button",{type:"button",onClick:()=>ue(!1),className:"thread-workspace-expand-fab thread-desktop-only-inline-flex",title:"Expand workspace","aria-label":"Expand workspace",children:t.jsx(G.ChevronsLeft,{className:"h-4 w-4"})}):null,X]})})]})]})}),t.jsx(Am,{open:ke!==null,title:"Rename Thread",label:"Thread Title",value:ze,busy:Me!==null,onChange:je,onCancel:tt,onSubmit:()=>ke?lt(ke):void 0})]})}function Ym({open:e,title:r,text:n,onClose:a}){return c.useEffect(()=>{if(!e)return;function s(o){o.key==="Escape"&&a()}return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[a,e]),e?Dr.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[90] flex items-center justify-center p-4 sm:p-6",children:[t.jsx("button",{type:"button","aria-label":"Close full text",onClick:a,className:"absolute inset-0 bg-stone-950/78 backdrop-blur-sm"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":r,className:"relative z-[1] flex max-h-[min(82vh,52rem)] w-full max-w-4xl flex-col overflow-hidden rounded-[1.8rem] border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-stone-800 px-4 py-3 sm:px-5",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:r}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:a,className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-stone-700 text-stone-300 transition hover:bg-stone-800",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-4 py-4 sm:px-5",children:t.jsx("pre",{className:"whitespace-pre-wrap break-words text-sm leading-6 text-stone-200",children:n})})]})]}),document.body):null}var Zm=[/^(?: {0,3})#{1,6}\s+\S/m,/^(?: {0,3})>{1,}\s*\S/m,/^(?: {0,3})(?:[-+*]|\d{1,9}[.)])\s+(?:\[[ xX]\]\s+)?\S/m,/^(?: {0,3})(?:```|~~~)/m,/^(?: {0,3})(?:[-*_]\s*){3,}$/m],Jm=/^(?:\|?[^|\n]+\|[^|\n]+(?:\|[^|\n]+)*\|?\s*\n\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$)/m,Qm=/!?\[[^\]\n]+\]\([^)]+\)/,ep=/`[^`\n]+`/,tp=/(?:\*\*[^*\n]+\*\*|__[^_\n]+__)/,rp=/(^|[^\w])(?:\*[^*\n]+\*|_[^_\n]+_)(?=[^\w]|$)/,np=/~~[^~\n]+~~/;function ap(e){const r=e.trim();return r?Zm.some(n=>n.test(r))||Jm.test(r)?!0:/[`[\]*_~!]/.test(r)?Qm.test(r)||ep.test(r)||tp.test(r)||rp.test(r)||np.test(r):!1:!1}Ur();function Bn(e,r){const n=new Map(r.map(o=>[o.id,o])),a=e.map(o=>{var l,i;return{...o.manifest,enabled:((l=n.get(o.manifest.id))==null?void 0:l.enabled)??!0,source:((i=n.get(o.manifest.id))==null?void 0:i.source)??"builtin"}}),s=new Set(e.map(o=>o.manifest.id));for(const o of r)s.has(o.id)||a.push(o);return a}function ta(e=[]){const r=Bn(e,[]),n=e;return{plugins:r,loading:!1,error:null,async refresh(){},async importPluginManifest(){},async setPluginEnabled(){},async uninstallPlugin(){},renderArtifact:o=>{var i;const l=n.find(d=>d.renderArtifact&&d.manifest.capabilities.artifactTypes.some(h=>h.type===o.artifact.type));return((i=l==null?void 0:l.renderArtifact)==null?void 0:i.call(l,o))??null},renderInlineCode:o=>{for(const l of n)for(const i of l.inlineCodeRenderers??[]){if(!i.languages.includes(o.language.trim().toLowerCase()))continue;const d=i.render(o);if(d)return d}return null},hasRendererForArtifact:o=>n.some(l=>!!l.renderArtifact&&l.manifest.capabilities.artifactTypes.some(i=>i.type===o.type)),getThreadPanels:()=>n.flatMap(o=>o.threadPanels??[])}}var ra=c.createContext(ta());function na(){return c.useContext(ra)??ta()}br();function el(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ds(e){return el(e)?Object.entries(e):e==null||e===""?[]:[["value",e]]}function tl(e){return typeof e=="string"?t.jsxs("span",{className:"thread-graph-tool-string",children:['"',e,'"']}):typeof e=="number"?t.jsx("span",{className:"thread-graph-tool-number",children:e}):typeof e=="boolean"?t.jsx("span",{className:"thread-graph-tool-boolean",children:String(e)}):e===null?t.jsx("span",{className:"thread-graph-tool-null",children:"null"}):typeof e=="object"?t.jsx("span",{className:"thread-graph-tool-object",children:JSON.stringify(e)}):t.jsx("span",{children:String(e)})}function sp(e,r){return typeof r=="string"&&(e==="stdout"||e==="stderr"||e==="result")?t.jsx("pre",{className:"thread-graph-tool-output",children:r||"(empty)"}):typeof r=="object"&&r!==null?t.jsx("pre",{className:"thread-graph-tool-output",children:JSON.stringify(r,null,2)}):tl(r)}function cs({callId:e,toolName:r,status:n,parameters:a,result:s}){const o=c.useMemo(()=>{switch(n){case"completed":return{className:"is-completed",icon:t.jsx(G.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"};case"failed":return{className:"is-failed",icon:t.jsx(G.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"};default:return{className:"is-pending",icon:t.jsx(G.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),label:"Running"}}},[n]),l=c.useMemo(()=>ds(s),[s]),i=c.useMemo(()=>ds(a),[a]),d=c.useMemo(()=>typeof s=="string"?s.length>0:el(s)?["stdout","stderr","result"].some(f=>{const p=s[f];return typeof p=="string"&&p.length>0}):!1,[s]),h=n==="pending"||d,[u,m]=c.useState(h?"item-1":void 0);return c.useEffect(()=>{h&&m("item-1")},[e,h]),t.jsx("div",{className:"thread-graph-tool-call my-2 w-full font-sans not-prose",children:t.jsx(pr,{type:"single",collapsible:!0,onValueChange:f=>m(f||void 0),className:"thread-graph-tool-accordion w-full overflow-hidden rounded-lg border",...u!==void 0?{value:u}:{},children:t.jsxs(fr,{value:"item-1",className:"border-0",children:[t.jsx(gr,{className:"thread-graph-tool-trigger px-4 py-3 hover:no-underline",children:t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(G.Wrench,{className:"h-4 w-4 shrink-0"}),t.jsx("span",{className:"min-w-0 truncate font-mono text-sm font-semibold",children:r}),t.jsxs("span",{className:`thread-graph-tool-badge ${o.className}`,title:o.label,"aria-label":`Status: ${o.label}`,children:[o.icon,t.jsx("span",{className:"thread-graph-status-label",children:o.label})]})]})}),t.jsxs(xr,{className:"thread-graph-tool-content px-4 pb-4 pt-1",children:[t.jsxs("section",{children:[t.jsx("h4",{children:"Parameters"}),t.jsxs("div",{className:"thread-graph-tool-json",children:["{",t.jsx("br",{}),i.length>0?i.map(([f,p],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',f,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),tl(p),g<i.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},f)):t.jsx("div",{children:t.jsx("span",{className:"thread-graph-tool-null",children:"empty"})}),"}"]})]}),l.length>0?t.jsxs("section",{children:[t.jsx("h4",{children:"Result"}),t.jsxs("div",{className:"thread-graph-tool-json",children:["{",t.jsx("br",{}),l.map(([f,p],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',f,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),sp(f,p),g<l.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},f)),"}"]})]}):null]})]})})})}var hs=null;function op(){return hs??(hs=Promise.all([Ue(()=>import("./core-oEok_Crl.js"),__vite__mapDeps([0,1,2])),Ue(()=>import("./engine-javascript-DBd1bXLz.js"),[]),Ue(()=>import("./ayu-light-BA47KaF1.js"),[]),Ue(()=>import("./ayu-dark-DYE7WIF3.js"),[]),Ue(()=>import("./javascript-wDzz0qaB.js"),[]),Ue(()=>import("./typescript-BPQ3VLAy.js"),[]),Ue(()=>import("./tsx-COt5Ahok.js"),[]),Ue(()=>import("./jsx-g9-lgVsj.js"),[]),Ue(()=>import("./python-B6aJPvgy.js"),[]),Ue(()=>import("./json-Cp-IABpG.js"),[]),Ue(()=>import("./shellscript-CEILq0vU.js").then(e=>e.b),[]),Ue(()=>import("./shellscript-CEILq0vU.js").then(e=>e.s),[]),Ue(()=>import("./yaml-Buea-lGh.js"),[]),Ue(()=>import("./toml-vGWfd6FD.js"),[]),Ue(()=>import("./markdown-Cvjx9yec.js"),[]),Ue(()=>import("./html-pp8916En.js"),__vite__mapDeps([3,4,5])),Ue(()=>import("./css-CLj8gQPS.js"),[]),Ue(()=>import("./sql-CRqJ_cUM.js"),[]),Ue(()=>import("./csv-fuZLfV_i.js"),[])]).then(([{createHighlighterCore:e},{createJavaScriptRegexEngine:r},n,a,s,o,l,i,d,h,u,m,f,p,g,b,v,x,y])=>e({engine:r(),themes:[n.default,a.default],langs:[s.default,o.default,l.default,i.default,d.default,h.default,u.default,m.default,f.default,p.default,g.default,b.default,v.default,x.default,y.default]}))),hs}function Wr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Gn(e){if(!e)return{};if(Wr(e)&&Object.prototype.hasOwnProperty.call(e,"0"))try{const r=Object.keys(e).map(Number).filter(n=>Number.isFinite(n)).sort((n,a)=>n-a).map(n=>String(e[String(n)]??"")).join("");return JSON.parse(r)}catch{return e}if(typeof e=="string")try{return JSON.parse(e)}catch{return e}return e}function Fn(){return{finalResult:null,stdout:"",stderr:""}}function lp(e){return typeof e=="string"?{result:e}:e}function rl(e){const r=Wr(e.finalResult)?{...e.finalResult}:e.finalResult!=null?{result:e.finalResult}:{};return e.stdout&&(r.stdout=e.stdout),e.stderr&&(r.stderr=e.stderr),!("status"in r)&&(e.stdout||e.stderr)&&(r.status="pending"),r}function us(e){if(!e)return"pending";if(!Wr(e))return"completed";const r=e.status;return r==="stream"||r==="pending"||r==="running"?"pending":r==="failed"||r==="error"||r==="timed_out"||typeof e.exit_code=="number"&&e.exit_code!==0?"failed":"completed"}function ip(e){const r=new Map,n=/```tool-result\s*([\s\S]*?)\s*```/g,a=e.replace(n,(l,i)=>{try{const d=JSON.parse(i),h=d.call_id;if(typeof h!="string")return l;const u=lp(d.result),m=r.get(h)??Fn();return Wr(u)&&u.status==="stream"&&typeof u.chunk=="string"?u.stream==="stderr"?m.stderr+=u.chunk:m.stdout+=u.chunk:m.finalResult=u,r.set(h,m),""}catch{return l}}),s=/```tool-call\s*([\s\S]*?)\s*```/g;return{processedContent:a.replace(s,(l,i)=>{try{const d=JSON.parse(i),h=d.call_id,u=d.tool;if(typeof u!="string")return l;const m=Gn(d.args);if(typeof h=="string"&&r.has(h)){const f=rl(r.get(h)??Fn());return`\`\`\`tool-merged
|
|
3610
|
+
`,ts="MCP entry written to provider config. Restart the backend if it does not appear immediately.";function wm({hostConfigFilesAvailable:e,onReadProviderConfig:r,onWriteProviderConfig:n,setMcpPanelMode:a,onOpenMcp:s}){const[o,l]=c.useState(""),[i,d]=c.useState(""),[h,u]=c.useState(""),[m,f]=c.useState(null),[p,g]=c.useState(!1),[b,v]=c.useState(null),[x,y]=c.useState(null),k=c.useCallback(()=>{v(null),y(null)},[]),N=c.useCallback(async()=>{if(!e||!r)throw new Error("Provider config editing is unavailable for this thread.");const T=await r();return f(T.path),T},[e,r]),w=c.useCallback(async T=>{if(!e||!n)throw new Error("Provider config editing is unavailable for this thread.");const q=await n(T);return f(q.path),q},[e,n]),j=c.useCallback(async()=>{const T=mu(o),q=i.trim();if(!T){v("MCP name must use only letters, numbers, underscore, or hyphen.");return}if(!/^https?:\/\//i.test(q)){v("HTTP MCP URL must start with http:// or https://");return}g(!0),v(null),y(null);try{const M=await N(),D=qa(M.content,T,fu(T,q));await w(D),y(ts),a("list"),l(""),d(""),s==null||s()}catch(M){v(M instanceof Error?M.message:"Unable to update provider config.")}finally{g(!1)}},[N,o,i,s,a,w]),C=c.useCallback(async()=>{g(!0),v(null),y(null);try{await N(),u(T=>T||km),a("stdio")}catch(T){v(T instanceof Error?T.message:"Unable to load provider config.")}finally{g(!1)}},[N,a]),L=c.useCallback(async()=>{const T=pu(h);if(!T){v("The raw MCP block must start with a header like [mcp_servers.name].");return}g(!0),v(null),y(null);try{const q=await N(),M=qa(q.content,T,h);await w(M),y(ts),a("list"),s==null||s()}catch(q){v(q instanceof Error?q.message:"Unable to update provider config.")}finally{g(!1)}},[N,h,s,a,w]);return{mcpHttpName:o,mcpHttpUrl:i,mcpRawBlock:h,mcpConfigPath:m,mcpConfigBusy:p,mcpConfigError:b,mcpConfigSuccess:x,setMcpHttpName:l,setMcpHttpUrl:d,setMcpRawBlock:u,clearMcpConfigStatus:k,prepareRawMcpBlock:C,saveHttpMcp:j,saveRawMcpBlock:L}}function ym({openMenu:e,setOpenMenu:r,slashPanelView:n,setSlashPanelView:a,setMcpPanelMode:s,clearMcpConfigStatus:o,clearHookConfigStatus:l}){const[i,d]=c.useState(null);c.useEffect(()=>{e!=="slash"&&(a("root"),s("list"),o(),l())},[l,o,e,s,a]),c.useEffect(()=>{n!=="mcp"&&(s("list"),o())},[o,s,n]),c.useEffect(()=>{if(!i)return;const u=window.setTimeout(()=>{d(m=>m===i?null:m)},1400);return()=>{window.clearTimeout(u)}},[i]),c.useEffect(()=>{function u(m){(typeof m.composedPath=="function"?m.composedPath():[]).some(g=>g instanceof HTMLElement&&(g.dataset.composerMenuSurface==="true"||g.dataset.composerMenuTrigger==="true"))||e&&r(null)}if(e)return window.addEventListener("pointerdown",u),()=>{window.removeEventListener("pointerdown",u)}},[e,r]);const h=c.useCallback(async u=>{try{await navigator.clipboard.writeText(`$${u}`),d(u)}catch{d(null)}},[]);return{copiedSkillName:i,copySkillInvokeName:h}}function jm(e,r){const{attachment:n}=e,a=document.createElement("span");if(a.dataset.segmentType="attachment",a.dataset.clientId=n.clientId,a.dataset.placeholder=n.placeholder,a.contentEditable="false",a.className="thread-composer-attachment-chip mx-[0.12rem] inline-flex max-w-full align-baseline",n.kind==="photo"){a.classList.add("thread-composer-attachment-chip-photo","rounded-[0.95rem]","border","border-sky-300/35","bg-sky-300/10","p-1","shadow-sm","shadow-stone-950/20");const l=r[n.clientId];if(l){const d=document.createElement("img");d.src=l,d.alt=n.originalName||"Pasted image",d.className="thread-composer-attachment-thumb h-[4.5rem] w-[6rem] rounded-[0.7rem] bg-stone-950 object-contain",d.draggable=!1,a.append(d)}else{const d=document.createElement("span");d.className="thread-composer-attachment-thumb inline-block h-[4.5rem] w-[6rem] rounded-[0.7rem] bg-stone-900/80",d.setAttribute("aria-hidden","true"),a.append(d)}const i=document.createElement("span");return i.className="thread-composer-attachment-caption ml-2 inline-flex max-w-[8rem] items-center text-[10px] font-medium tracking-[0.08em] text-sky-50",i.textContent=Ya(n),a.append(i),a}a.classList.add("items-center","gap-2","rounded-[0.95rem]","border","border-emerald-300/35","bg-emerald-300/10","px-2.5","py-2","text-[10px]","font-medium","tracking-[0.08em]","text-emerald-50","shadow-sm","shadow-stone-950/20");const s=document.createElement("span");s.className="inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-emerald-200/25 bg-emerald-300/12 text-[9px]",s.textContent="FILE";const o=document.createElement("span");return o.className="inline-flex max-w-[10rem] truncate",o.textContent=Ya(n),a.append(s,o),a}function Nm(e,r){const n=document.createDocumentFragment();for(const a of e){if(a.type==="text"){n.append(document.createTextNode(a.text===" "?" ":a.text));continue}n.append(jm(a,r))}return n}function Cm({promptRef:e,isShellView:r,prompt:n,promptSegments:a,attachmentPreviewUrls:s,previewSignature:o,editorSanitizeNonce:l,pendingSelectionRef:i,pendingInsertedAttachmentIdsRef:d,selectionSnapshotRef:h,renderedPreviewSignatureRef:u,renderedSanitizeNonceRef:m,serializeEditorPrompt:f,restoreSelection:p}){c.useLayoutEffect(()=>{const g=e.current;if(!g||r)return;const b=i.current,v=f()!==n||u.current!==o||m.current!==l;v&&(g.replaceChildren(Nm(a,s)),u.current=o,m.current=l),b!==null?(g.focus(),Wu(g,d.current)||p(b),h.current=b):document.activeElement===g&&v&&p(h.current),i.current=null,d.current=[]},[s,l,r,o,n,e,a,d,i,u,m,p,h,f])}function Sm({tokenBudget:e,error:r,onTokenBudgetChange:n,onCancel:a}){return t.jsxs("div",{className:"thread-goal-compose-card relative z-20 mb-1.5 flex flex-wrap items-center gap-2 rounded-2xl border px-3 py-2 text-xs shadow-sm",children:[t.jsx("span",{className:"thread-goal-compose-label font-medium uppercase tracking-[0.16em]",children:"Goal"}),t.jsxs("label",{className:"thread-goal-compose-field flex items-center gap-2",children:[t.jsx("span",{children:"Max tokens (k)"}),t.jsx("input",{"aria-label":"Goal token budget",value:e,onChange:s=>n(s.target.value),inputMode:"numeric",placeholder:"Optional",className:"thread-goal-compose-input h-7 w-24 rounded-full border px-3 text-xs outline-none"})]}),r?t.jsx("span",{className:"thread-goal-compose-error min-w-0 flex-1",children:r}):null,t.jsx("button",{type:"button",onClick:a,className:"thread-goal-compose-cancel rounded-full border px-2.5 py-1 text-[11px] transition",children:"Cancel"})]})}function Tm({promptRef:e,prompt:r,disabled:n,promptPlaceholder:a,canInterrupt:s,interruptLabel:o,composerPromptRegionClassName:l,graphChatInputClassName:i,onInterrupt:d,onInput:h,onPaste:u,onKeyDown:m,onKeyUp:f,onMouseUp:p,onBlur:g,onDragEnter:b,onDragOver:v,onDragLeave:x,onDrop:y}){return t.jsxs("div",{"data-slot":"input-group-control",className:`${l} relative w-full`,children:[t.jsxs("div",{className:i,children:[r.length===0&&t.jsx("span",{className:`pointer-events-none absolute left-3 top-3 truncate text-slate-500 sm:left-4 sm:top-4 dark:text-slate-400 ${s?"right-12":"right-3 sm:right-4"}`,children:a}),t.jsx("div",{ref:e,role:"textbox","aria-label":"Prompt","aria-multiline":"true",contentEditable:!n,suppressContentEditableWarning:!0,onInput:h,onPaste:u,onKeyDown:m,onKeyUp:f,onMouseUp:p,onBlur:g,onDragEnter:b,onDragOver:v,onDragLeave:x,onDrop:y,className:`relative z-[1] min-h-[4.25rem] whitespace-pre-wrap break-words pb-2 outline-none sm:min-h-[4.25rem] ${s?"pr-12":""} ${n?"cursor-not-allowed text-slate-500":""}`})]}),s?t.jsx(xt,{type:"button",variant:"ghost",size:"icon-xs","aria-label":o,title:o,onClick:k=>{k.preventDefault(),d==null||d()},className:"thread-graph-composer-stop-button ui-action-danger absolute right-2 top-2 z-30 h-8 w-8 rounded-full text-sm font-medium",children:t.jsx("span",{"aria-hidden":"true",className:"block h-2.5 w-2.5 rounded-[2px] bg-current"})}):null]})}function Em({prompt:e,promptPlaceholder:r,promptRegionClassName:n,promptInputClassName:a,interruptLabel:s,canInterrupt:o,sendButtonLabel:l,sendButtonClassName:i,sendDisabled:d,onPromptChange:h,onPromptKeyDown:u,onInterrupt:m}){return t.jsxs("div",{className:`${n} relative`,children:[t.jsx("textarea",{"aria-label":"Prompt",disabled:!1,value:e,onChange:f=>h(f.target.value),onKeyDown:u,rows:2,placeholder:r,className:`${a} resize-y pb-10`}),t.jsx("button",{type:"button","aria-label":s,title:s,onClick:()=>void(m==null?void 0:m()),disabled:!o,className:`absolute right-2.5 top-2.5 inline-flex h-8 w-8 items-center justify-center rounded-full border transition ${o?"border-rose-300/55 bg-rose-300/[0.14] text-rose-50 shadow-lg shadow-rose-950/20 hover:bg-rose-300/[0.22]":"cursor-not-allowed border-stone-700/30 bg-stone-400/[0.02] text-stone-500/55 opacity-55"}`,children:t.jsx("span",{"aria-hidden":"true",className:"block h-2.5 w-2.5 rounded-[2px] bg-current"})}),t.jsx("button",{type:"submit","aria-label":"Send Shell Input",onMouseDown:f=>{f.preventDefault()},onPointerDown:f=>{f.preventDefault()},onTouchStart:f=>{f.preventDefault()},disabled:d,className:`absolute bottom-2.5 right-2.5 rounded-full px-3.5 py-1.5 text-sm font-medium shadow-lg shadow-stone-950/30 transition disabled:cursor-not-allowed disabled:bg-stone-700 disabled:text-stone-300 ${i}`,children:l})]})}function Lm({isShellView:e,promptRef:r,prompt:n,disabled:a,promptPlaceholder:s,canInterrupt:o,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,promptInputClassName:h,goalComposeMode:u,goalTokenBudget:m,goalLocalError:f,goalBusy:p,busy:g,sendButtonLabel:b,sendButtonClassName:v,onInterrupt:x,onPromptInput:y,onPromptPaste:k,onPromptKeyDown:N,onPromptKeyUp:w,onPromptMouseUp:j,onPromptBlur:C,onPromptDragEnter:L,onPromptDragOver:T,onPromptDragLeave:q,onPromptDrop:M,onGoalTokenBudgetChange:D,onCancelGoal:J,onShellPromptChange:W}){return{promptSlot:e?null:t.jsx(Tm,{promptRef:r,prompt:n,disabled:a,promptPlaceholder:s,canInterrupt:o,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,onInterrupt:x,onInput:y,onPaste:k,onKeyDown:N,onKeyUp:w,onMouseUp:j,onBlur:C,onDragEnter:L,onDragOver:T,onDragLeave:q,onDrop:M}),goalSlot:u&&!e?t.jsx(Sm,{tokenBudget:m,error:f,onTokenBudgetChange:D,onCancel:J}):null,shellPromptSlot:e?t.jsx(Em,{prompt:n,promptPlaceholder:s,promptRegionClassName:i,promptInputClassName:h,interruptLabel:l,canInterrupt:o,sendButtonLabel:b,sendButtonClassName:v,sendDisabled:p||g,onPromptChange:W,onPromptKeyDown:N,onInterrupt:x}):null}}function Pm({collaborationMode:e,onUpdateSettings:r,closeMenu:n}){const[a,s]=c.useState(null),o=a??e;c.useEffect(()=>{s(null)},[e]);const l=c.useCallback(async i=>{const d=cu({nextMode:i.collaborationMode,previousOptimisticMode:a});d.optimisticMode&&s(d.optimisticMode);try{await(r==null?void 0:r(i)),d.closeMenuOnSuccess&&n()}catch(h){throw d.shouldRollbackMode&&s(d.rollbackMode),h}},[n,r,a]);return{displayedCollaborationMode:o,updateSettings:l}}function Im({isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:s,toolbarClassName:o,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,inlineToggleClassName:m,planToggleActiveClassName:f,sendButtonBaseClassName:p,slashPanelView:g,availableToolboxItems:b,busy:v,settingsBusy:x,compactBusy:y,forkBusy:k,fastMode:N,goalComposeMode:w,goalBusy:j,goalStatus:C,activeView:L,disabled:T,model:q,modelOptions:M,modelContextTitle:D,contextUsage:J,reasoningEffort:W,supportedEfforts:O,displayedCollaborationMode:ee,sandboxMode:he,sendButtonLabel:E,sendButtonClassName:re,modelControlsDisabled:A,effortControlsDisabled:V,effortControlTitle:U,forkTurnOptionsState:I,skillsState:X,copiedSkillName:F,hooksPanelMode:z,hooksState:P,hookConfigBusy:Z,hookConfigError:K,hookConfigSuccess:de,editingHookTarget:_,hookScope:Y,hookEventName:te,hookMatcher:ie,hookCommand:ue,hookTimeoutSec:be,hookStatusMessage:Le,mcpPanelMode:ae,mcpState:ve,mcpConfigPath:ke,mcpConfigError:pe,mcpConfigSuccess:Ie,mcpConfigBusy:je,mcpHttpName:_e,mcpHttpUrl:Pe,mcpRawBlock:Ae,capabilities:Ce,shellControlState:Re,onToggleView:H,onDismissPromptFocus:ce,onSetOpenMenu:R,onToolboxItemClick:$,onSetSlashPanelView:Q,onOpenForkTurns:me,onForkLatest:xe,onForkTurn:ze,onCopySkillInvokeName:ge,onResetHookForm:Me,onSetHooksPanelMode:at,onClearHookConfigStatus:Je,onSetEditingHookTarget:Qe,onSetHookScope:De,onSetHookEventName:Be,onSetHookMatcher:lt,onSetHookCommand:He,onSetHookTimeoutSec:tt,onSetHookStatusMessage:it,onSaveHook:Ye,onStartEditingHook:S,onTrustHook:B,onUntrustHook:se,onSetMcpPanelMode:ye,onClearMcpConfigStatus:Oe,onSetMcpHttpName:rt,onSetMcpHttpUrl:nt,onSetMcpRawBlock:Ge,onPrepareRawMcpBlock:Ve,onSaveHttpMcp:ht,onSaveRawMcpBlock:bt,onPickPhoto:fe,onPickFile:Te,onUpdateSettings:Ze,onPasteShell:Ke,onCopyShell:Bt,onClearShell:Gt,onShellControl:Yr}){const Zr=e?null:{open:s==="slash",slashPanelView:g,availableToolboxItems:b,busy:v,forkBusy:k,forkTurnOptionsState:I,skillsState:X,copiedSkillName:F,hooksPanelMode:z,hooksState:P,hostConfigFilesAvailable:Ce.hostConfigFiles,hookTrustAvailable:Ce.hookTrust,hookConfigBusy:Z,hookConfigError:K,hookConfigSuccess:de,editingHookTarget:_,hookScope:Y,hookEventName:te,hookMatcher:ie,hookCommand:ue,hookTimeoutSec:be,hookStatusMessage:Le,mcpPanelMode:ae,mcpState:ve,mcpConfigEditing:Ce.mcpConfigEditing,mcpConfigPath:ke,mcpConfigError:pe,mcpConfigSuccess:Ie,mcpConfigBusy:je,mcpHttpName:_e,mcpHttpUrl:Pe,mcpRawBlock:Ae,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,onToggle:()=>R(dt=>dt==="slash"?null:"slash"),onToolboxItemClick:$,toolboxItemDisabled:dt=>Bu(dt,{settingsBusy:x,compactBusy:y,busy:v,forkBusy:k}),toolboxItemClassName:dt=>Gu(dt,{fastMode:N,goalComposeMode:w,goalStatus:C,menuItemClassName:d}),toolboxItemStatus:dt=>Du(dt,{fastMode:N,compactBusy:y,goalComposeMode:w,goalStatus:C,busy:v}),onSetSlashPanelView:Q,onOpenForkTurns:me,onForkLatest:xe,onForkTurn:ze,onCopySkillInvokeName:ge,onResetHookForm:Me,onSetHooksPanelMode:at,onClearHookConfigStatus:Je,onSetEditingHookTarget:Qe,onSetHookScope:De,onSetHookEventName:Be,onSetHookMatcher:lt,onSetHookCommand:He,onSetHookTimeoutSec:tt,onSetHookStatusMessage:it,onSaveHook:Ye,onStartEditingHook:S,onTrustHook:B,onUntrustHook:se,onSetMcpPanelMode:ye,onClearMcpConfigStatus:Oe,onSetMcpHttpName:rt,onSetMcpHttpUrl:nt,onSetMcpRawBlock:Ge,onPrepareRawMcpBlock:Ve,onSaveHttpMcp:ht,onSaveRawMcpBlock:bt},Jr=e?null:{open:s==="attachments",iconButtonClassName:l,menuClassName:i,menuItemClassName:d,onToggle:()=>R(dt=>dt==="attachments"?null:"attachments"),onPickPhoto:fe,onPickFile:Te},Qr=e?null:{openMenu:s,model:q,modelOptions:M,modelContextTitle:D,contextUsage:J,reasoningEffort:W,supportedEfforts:O,displayedCollaborationMode:ee,sandboxMode:he,planModeAvailable:Ce.planMode,sandboxModeAvailable:Ce.sandboxMode,settingsBusy:x,goalComposeMode:w,goalBusy:j,activeView:L,disabled:T,fastMode:N,sendButtonLabel:E,sendButtonClassName:re,modelControlsDisabled:A,effortControlsDisabled:V,effortControlTitle:U,inlineToggleClassName:m,menuItemClassName:d,planToggleActiveClassName:f,sendButtonBaseClassName:p,onSetOpenMenu:R,onUpdateSettings:Ze};return{isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:s,toolbarClassName:o,iconButtonClassName:l,slashToolboxProps:Zr,attachmentMenuProps:Jr,settingsToolbarProps:Qr,shellToolsPanelProps:s==="shellTools"?{busy:v,shellControlState:Re,onPaste:Ke,onCopy:Bt,onClear:Gt,onShellControl:Yr}:null,shellControlState:Re,onToggleView:H,onDismissPromptFocus:ce,onSetOpenMenu:R}}function $n({activeView:e,edgeToEdgeMobile:r=!1,busy:n=!1,settingsBusy:a=!1,compactBusy:s=!1,error:o,model:l=null,reasoningEffort:i=null,fastMode:d=!1,collaborationMode:h="default",sandboxMode:u=null,hideSandboxModeControl:m=!1,modelOptions:f=[],contextUsage:p=null,capabilities:g=null,toolboxItems:b=null,hookCommandTemplates:v=null,mcpConfigFormat:x="none",followTail:y=!1,threadConnected:k=!0,shellAvailable:N=!0,disabled:w=!1,disabledPlaceholder:j,shellControlState:C=null,draftPrompt:L,draftAttachments:T,onPickAttachment:q,skillsState:M={status:"idle",data:null,error:null},mcpState:D={status:"idle",data:null,error:null},hooksState:J={status:"idle",data:null,error:null},goalState:W={status:"idle",data:null,error:null},forkTurnOptionsState:O={status:"idle",data:null,error:null},onDraftChange:ee,onSubmit:he,onInterrupt:E,onCompact:re,onOpenSkills:A,onOpenMcp:V,onOpenHooks:U,onCreateHook:I,onUpdateHook:X,onTrustHook:F,onUntrustHook:z,onOpenGoal:P,onUpdateGoal:Z,onOpenForkTurns:K,onForkLatest:de,onForkTurn:_,onReadProviderConfig:Y,onWriteProviderConfig:te,onToggleFollow:ie,onUpdateSettings:ue,onToggleView:be,onShellCopy:Le,onShellControl:ae,canInterrupt:ve=!1}){var fa;const[ke,pe]=c.useState(null),[Ie,je]=c.useState("root"),[_e,Pe]=c.useState("list"),Ae=c.useMemo(()=>({fast:(g==null?void 0:g.controls.performanceMode)??!1,compact:(g==null?void 0:g.turns.compact)??!1,goal:(g==null?void 0:g.controls.goals)??!1,fork:(g==null?void 0:g.branching.fork)??!1,skills:(g==null?void 0:g.management.skills)??!1,mcp:(g==null?void 0:g.management.mcpStatus)??!1,hooks:(g==null?void 0:g.management.hooks)??!1,hostConfigFiles:(g==null?void 0:g.management.hostConfigFiles)??!1,mcpConfigEditing:x==="codex-toml"&&!!(g!=null&&g.management.hostConfigFiles)&&!!Y&&!!te,hookTrust:(g==null?void 0:g.management.hookTrust)??!1,planMode:(g==null?void 0:g.controls.planMode)??!1,sandboxMode:(g==null?void 0:g.controls.sandboxMode)??!1}),[g,x,Y,te]),Ce=c.useMemo(()=>Mu(b,Ae),[Ae,b]),Re=c.useRef(null),H=c.useRef(null),ce=c.useRef(null),R=c.useRef(null),$=c.useRef(null),Q=c.useRef([]),me=c.useRef(null),xe=c.useRef(""),ze=c.useRef(0),ge=e==="shell",Me=N||ge,at=!!(ge&&(C!=null&&C.isMobileShell)),Je=(C==null?void 0:C.promptLabel)??null,[Qe,De]=c.useState(!1),[Be,lt]=c.useState(0),{prompt:He,attachments:tt,isDraftControlled:it,updateDraft:Ye,flushControlledDraftToHost:S}=fm({isShellView:ge,draftPrompt:L,draftAttachments:T,onDraftChange:ee}),B=mm({attachments:tt,isShellView:ge}),{displayedCollaborationMode:se,updateSettings:ye}=Pm({collaborationMode:h,onUpdateSettings:ue,closeMenu:()=>pe(null)}),{forkBusy:Oe,forkLatest:rt,forkTurn:nt}=gm({slashPanelView:Ie,onForkLatest:de,onForkTurn:_,closeMenu:()=>pe(null)}),{hooksPanelMode:Ge,hookScope:Ve,hookEventName:ht,hookMatcher:bt,hookCommand:fe,hookTimeoutSec:Te,hookStatusMessage:Ze,editingHookTarget:Ke,hookConfigBusy:Bt,hookConfigError:Gt,hookConfigSuccess:Yr,setHooksPanelMode:Zr,setEditingHookTarget:Jr,setHookScope:Qr,setHookEventName:sa,setHookMatcher:dt,setHookCommand:vl,setHookTimeoutSec:kl,setHookStatusMessage:wl,clearHookConfigStatus:oa,resetHookForm:yl,startEditingHook:jl,saveHook:Nl,trustHook:Cl,untrustHook:Sl}=vm({slashPanelView:Ie,hookCommandTemplates:v,onCreateHook:I,onUpdateHook:X,onTrustHook:F,onUntrustHook:z}),{goalComposeMode:tr,goalTokenBudget:Tl,goalBusy:en,goalLocalError:El,setGoalTokenBudget:Ll,submitGoal:Pl,enterGoalComposeMode:Il,exitGoalComposeMode:la}=xm({prompt:He,goalTokenBudgetSource:W.data,promptRef:H,onOpenGoal:P,onUpdateGoal:Z,updateDraft:Ye,closeMenu:()=>pe(null),resetSlashPanel:()=>je("root")}),{mcpHttpName:zl,mcpHttpUrl:Rl,mcpRawBlock:_l,mcpConfigPath:Al,mcpConfigBusy:Ml,mcpConfigError:$l,mcpConfigSuccess:Dl,setMcpHttpName:Bl,setMcpHttpUrl:Gl,setMcpRawBlock:Fl,clearMcpConfigStatus:ia,prepareRawMcpBlock:Hl,saveHttpMcp:Ol,saveRawMcpBlock:Ul}=wm({hostConfigFilesAvailable:Ae.hostConfigFiles,onReadProviderConfig:Y,onWriteProviderConfig:te,setMcpPanelMode:Pe,onOpenMcp:V}),{copiedSkillName:Wl,copySkillInvokeName:Vl}=ym({openMenu:ke,setOpenMenu:pe,slashPanelView:Ie,setSlashPanelView:je,setMcpPanelMode:Pe,clearMcpConfigStatus:ia,clearHookConfigStatus:oa}),Kl=c.useCallback(ne=>{Ye(we=>{if(typeof ne=="function"){const Ee=ne(we.prompt,we.attachments);return{prompt:Ee.prompt,attachments:Ee.attachments??we.attachments}}return{prompt:ne,attachments:we.attachments}})},[Ye]),tn=c.useMemo(()=>f.find(ne=>ne.model===l)??null,[l,f]),ql=gu(l,p),da=(tn==null?void 0:tn.supportedReasoningEfforts)??[],Xl=c.useMemo(()=>tu(He,tt),[tt,He]),Yl=c.useMemo(()=>Object.entries(B).sort(([ne],[we])=>ne.localeCompare(we)).map(([ne,we])=>`${ne}:${we}`).join("|"),[B]);function Zl(ne,we){we.stopPropagation();const Ee=$u(ne,{fastMode:d,goalComposeMode:tr});switch(Ee.type){case"toggleFast":ye({fastMode:Ee.fastMode});break;case"runCompact":pe(null),re==null||re();break;case"enterGoalCompose":Il();break;case"exitGoalCompose":la(),pe(null);break;case"openPanel":je(Ee.panel),Ee.panel==="skills"?A==null||A():Ee.panel==="mcp"?V==null||V():Ee.panel==="hooks"&&(U==null||U());break;case"insertPrompt":an(Ee.text),je("root"),pe(null);break}}function Ft(){const ne=H.current;return ne?Ou(ne):null}const Jl=c.useCallback(ne=>{const we=H.current;!we||!ne||Uu(we,ne)},[]),rn=c.useCallback(()=>{const ne=H.current;return ne?Xo(ne):He},[He]),{appendAttachments:nn,appendDroppedAttachments:ca}=um({prompt:He,attachments:tt,updateDraft:Ye,getSelection:Ft,selectionSnapshotRef:me,pendingSelectionRef:$,pendingInsertedAttachmentIdsRef:Q,onInserted:()=>pe(null)}),ha=c.useCallback((ne,we)=>{var Ee;if(Ct(),q){q({kind:ne,appendAttachments:(qe,st=ne)=>nn(qe,st),defaultPick:()=>{var qe;return(qe=we.current)==null?void 0:qe.click()}});return}(Ee=we.current)==null||Ee.click()},[nn,Ct,q]);function an(ne){if(!ne)return;const we=Ft()??me.current,Ee=(we==null?void 0:we.start)??He.length,qe=(we==null?void 0:we.end)??Ee,st=eu(ne),Ht=`${He.slice(0,Ee)}${st}${He.slice(qe)}`;Ye(Ri=>({prompt:Ht,attachments:Ri.attachments}));const St=Ee+st.length;$.current={start:St,end:St},me.current={start:St,end:St}}Cm({promptRef:H,isShellView:ge,prompt:He,promptSegments:Xl,attachmentPreviewUrls:B,previewSignature:Yl,editorSanitizeNonce:Be,pendingSelectionRef:$,pendingInsertedAttachmentIdsRef:Q,selectionSnapshotRef:me,renderedPreviewSignatureRef:xe,renderedSanitizeNonceRef:ze,serializeEditorPrompt:rn,restoreSelection:Jl});function Ct(){var ne;(ne=H.current)==null||ne.blur(),document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.blur()}async function Ql(){var ne;if(Ct(),pe(null),!!((ne=navigator.clipboard)!=null&&ne.readText))try{const we=await navigator.clipboard.readText();an(we)}catch{return}}async function ua(){if(it&&S(),tr&&!ge){await Pl();return}const ne=ou({prompt:He,attachments:tt,isShellView:ge});!ne||await he(ne)===!1||Ye(()=>({prompt:"",attachments:[]}))}async function ei(ne){ne.preventDefault(),await ua()}function ti(){const ne=rn(),we=Ft();me.current=we;const Ee=H.current;(Ee?Hu(Ee):!1)&&($.current=we,lt(st=>st+1)),Ye(st=>({prompt:ne,attachments:st.attachments.filter(Ht=>ne.includes(Ht.placeholder))}),"deferred")}function ri(ne){var qe,st,Ht,St;const we=An((qe=ne.clipboardData)==null?void 0:qe.items,(st=ne.clipboardData)==null?void 0:st.files),Ee=lu({files:we,plainText:((Ht=ne.clipboardData)==null?void 0:Ht.getData("text/plain"))??"",htmlText:((St=ne.clipboardData)==null?void 0:St.getData("text/html"))??"",htmlToText:Fu});Ee.preventDefault&&ne.preventDefault(),Ee.type==="insert-text"?an(Ee.text):Ee.type==="append-files"&&ca(Ee.files)}function ni(ne){var Ee,qe;const we=Va(Xa((Ee=ne.dataTransfer)==null?void 0:Ee.items,(qe=ne.dataTransfer)==null?void 0:qe.files));we.preventDefault&&ne.preventDefault(),we.activateDragTarget&&De(!0)}function ai(ne){var Ee,qe;const we=Va(Xa((Ee=ne.dataTransfer)==null?void 0:Ee.items,(qe=ne.dataTransfer)==null?void 0:qe.files));we.preventDefault&&ne.preventDefault(),we.activateDragTarget&&ne.dataTransfer&&(ne.dataTransfer.dropEffect="copy"),we.activateDragTarget&&De(!0)}function si(ne){ne.currentTarget.contains(ne.relatedTarget)||De(!1)}function oi(ne){var qe,st;const we=An((qe=ne.dataTransfer)==null?void 0:qe.items,(st=ne.dataTransfer)==null?void 0:st.files),Ee=iu(we);Ee.preventDefault&&ne.preventDefault(),Ee.type==="accept-files"&&(De(!1),ca(Ee.files??[]))}function li(ne){if(e==="chat"&&ne.key==="/"&&!ne.metaKey&&!ne.ctrlKey&&!ne.altKey&&!n&&!w&&Ce.length>0&&rn().trim().length===0){ne.preventDefault(),je("root"),pe("slash");return}const we=du({key:ne.key,metaKey:ne.metaKey,ctrlKey:ne.ctrlKey,busy:n,disabled:w});we.preventDefault&&ne.preventDefault(),we.submit&&ua()}const{promptPlaceholder:ii,interruptLabel:di,sendButtonLabel:ma,sendButtonClassName:pa,modelControlsDisabled:ci,effortControlsDisabled:hi,effortControlTitle:ui}=ku({goalComposeMode:tr,goalBusy:en,threadConnected:k,busy:n,isShellView:ge,disabledPlaceholder:j,settingsBusy:a,supportedEffortCount:da.length,fastMode:d}),{composerLayerClassName:mi,formClassName:pi,composerShellClassName:fi,composerToolbarClassName:gi,composerIconButtonClassName:xi,composerMenuClassName:bi,composerMenuItemClassName:vi,composerInlineToggleClassName:ki,composerPanelButtonClassName:wi,composerChipButtonClassName:yi,composerPlanToggleActiveClassName:ji,composerSendButtonClassName:Ni,composerPromptRegionClassName:Ci,promptInputClassName:Si,graphChatInputGroupClassName:Ti,graphChatInputClassName:Ei}=wu({isShellView:ge,edgeToEdgeMobile:r,isMobileShell:at,openMenu:ke!==null,isDragTargetActive:Qe,busy:n}),Li=Im({isShellView:ge,canToggleShellView:Me,isMobileShell:at,shellPromptLabel:Je,openMenu:ke,toolbarClassName:gi,iconButtonClassName:xi,menuClassName:bi,menuItemClassName:vi,panelButtonClassName:wi,chipButtonClassName:yi,inlineToggleClassName:ki,planToggleActiveClassName:ji,sendButtonBaseClassName:Ni,slashPanelView:Ie,availableToolboxItems:Ce,busy:n,settingsBusy:a,compactBusy:s,forkBusy:Oe,fastMode:d,goalComposeMode:tr,goalBusy:en,goalStatus:(fa=W.data)==null?void 0:fa.status,activeView:e,disabled:w,model:l,modelOptions:f,modelContextTitle:ql,contextUsage:p,reasoningEffort:i,supportedEfforts:da,displayedCollaborationMode:se,sandboxMode:u,sendButtonLabel:ma,sendButtonClassName:pa,modelControlsDisabled:ci,effortControlsDisabled:hi,effortControlTitle:ui,forkTurnOptionsState:O,skillsState:M,copiedSkillName:Wl,hooksPanelMode:Ge,hooksState:J,hookConfigBusy:Bt,hookConfigError:Gt,hookConfigSuccess:Yr,editingHookTarget:Ke,hookScope:Ve,hookEventName:ht,hookMatcher:bt,hookCommand:fe,hookTimeoutSec:Te,hookStatusMessage:Ze,mcpPanelMode:_e,mcpState:D,mcpConfigPath:Al,mcpConfigError:$l,mcpConfigSuccess:Dl,mcpConfigBusy:Ml,mcpHttpName:zl,mcpHttpUrl:Rl,mcpRawBlock:_l,capabilities:{hostConfigFiles:Ae.hostConfigFiles,hookTrust:Ae.hookTrust,mcpConfigEditing:Ae.mcpConfigEditing,planMode:Ae.planMode,sandboxMode:m?!1:Ae.sandboxMode},shellControlState:C,onToggleView:be,onDismissPromptFocus:Ct,onSetOpenMenu:pe,onToolboxItemClick:Zl,onSetSlashPanelView:je,onOpenForkTurns:()=>K==null?void 0:K(),onForkLatest:rt,onForkTurn:nt,onCopySkillInvokeName:Vl,onResetHookForm:yl,onSetHooksPanelMode:Zr,onClearHookConfigStatus:oa,onSetEditingHookTarget:Jr,onSetHookScope:Qr,onSetHookEventName:sa,onSetHookMatcher:dt,onSetHookCommand:vl,onSetHookTimeoutSec:kl,onSetHookStatusMessage:wl,onSaveHook:Nl,onStartEditingHook:jl,onTrustHook:Cl,onUntrustHook:Sl,onSetMcpPanelMode:Pe,onClearMcpConfigStatus:ia,onSetMcpHttpName:Bl,onSetMcpHttpUrl:Gl,onSetMcpRawBlock:Fl,onPrepareRawMcpBlock:Hl,onSaveHttpMcp:Ol,onSaveRawMcpBlock:Ul,onPickPhoto:()=>ha("photo",ce),onPickFile:()=>ha("file",R),onUpdateSettings:ne=>void ye(ne),onPasteShell:()=>void Ql(),onCopyShell:()=>{Ct(),pe(null),Le==null||Le()},onClearShell:()=>{Ct(),pe(null),he({prompt:"clear"})},onShellControl:ne=>{Ct(),pe(null),ae==null||ae(ne)}}),{promptSlot:Pi,goalSlot:Ii,shellPromptSlot:zi}=Lm({isShellView:ge,promptRef:H,prompt:He,disabled:w,promptPlaceholder:ii,canInterrupt:ve,interruptLabel:di,composerPromptRegionClassName:Ci,graphChatInputClassName:Ei,promptInputClassName:Si,goalComposeMode:tr,goalTokenBudget:Tl,goalLocalError:El,goalBusy:en,busy:n,sendButtonLabel:ma,sendButtonClassName:pa,onInterrupt:E,onPromptInput:ti,onPromptPaste:ri,onPromptKeyDown:li,onPromptKeyUp:()=>{me.current=Ft()},onPromptMouseUp:()=>{me.current=Ft()},onPromptBlur:()=>{me.current=Ft(),De(!1),it&&S()},onPromptDragEnter:ni,onPromptDragOver:ai,onPromptDragLeave:si,onPromptDrop:oi,onGoalTokenBudgetChange:Ll,onCancelGoal:la,onShellPromptChange:Kl});return t.jsx(Qu,{activeView:e,layerClassName:mi,formClassName:pi,shellClassName:fi,inputGroupClassName:Ti,error:o,followTail:y,photoInputRef:ce,fileInputRef:R,onAppendAttachments:nn,onToggleFollow:ie,onSubmit:ei,formRef:Re,promptSlot:Pi,toolbarSlot:t.jsx(dm,{...Li}),goalSlot:Ii,shellPromptSlot:zi})}var zm=c.createContext(null);function Zo(){return c.useContext(zm)}function _t(e){return e?new Date(e).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"}):"Time unavailable"}function Zt(e){return e?new Date(e).toLocaleString():"Time unavailable"}function Rm(e){switch(e){case"idle":return"Idle";case"running":return"Running";case"interrupted":return"Interrupted";case"failed":return"Failed";case"not_loaded":return"Not Loaded";case"system_error":return"System Error"}}function _m(e){switch(e){case"idle":return"ui-status-neutral";case"running":return"ui-status-info";case"interrupted":return"ui-status-warning";case"failed":case"system_error":return"ui-status-danger";case"not_loaded":return"ui-status-neutral"}}function Jo(e){switch(e){case"sending":return"Sending";case"completed":return"Completed";case"interrupted":return"Interrupted";case"failed":return"Failed";case"inProgress":return"Running"}}function Am({open:e,title:r,label:n,value:a,busy:s=!1,onChange:o,onCancel:l,onSubmit:i}){if(c.useEffect(()=>{if(!e)return;function h(u){u.key==="Escape"&&!s&&l()}return window.addEventListener("keydown",h),()=>{window.removeEventListener("keydown",h)}},[s,l,e]),!e)return null;function d(h){h.preventDefault(),i()}return $r.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[95] flex items-center justify-center p-4 sm:p-6",children:[t.jsx("button",{type:"button","aria-label":"Close rename dialog",onClick:l,disabled:s,className:"absolute inset-0 bg-stone-950/78 backdrop-blur-sm disabled:cursor-not-allowed"}),t.jsxs("form",{role:"dialog","aria-modal":"true","aria-label":r,onSubmit:d,className:"relative z-[1] w-full max-w-md rounded-[1.6rem] border border-stone-700 bg-stone-900 p-5 shadow-2xl shadow-stone-950/40 sm:p-6",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium text-stone-100",children:r}),t.jsx("p",{className:"mt-1 text-sm text-stone-500",children:"Changes are saved only after confirmation."})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:l,disabled:s,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-stone-700 text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsxs("div",{className:"mt-5",children:[t.jsx("label",{htmlFor:"rename-dialog-input",className:"text-sm font-medium text-stone-200",children:n}),t.jsx("input",{id:"rename-dialog-input","aria-label":n,autoFocus:!0,value:a,onChange:h=>o(h.target.value),className:"mt-2 w-full rounded-2xl border border-stone-700 bg-stone-950 px-4 py-3 text-stone-100 outline-none transition focus:border-amber-300"})]}),t.jsxs("div",{className:"mt-5 flex items-center justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:l,disabled:s,className:"rounded-full border border-stone-700 px-4 py-2 text-sm font-medium text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),t.jsx("button",{type:"submit",disabled:s||!a.trim(),className:"ui-action-success rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:"Save"})]})]})]}),document.body)}function Mm({children:e,effectiveTheme:r,layoutMode:n,themeMode:a,viewportConstrained:s}){return t.jsx("div",{className:`thread-ui-shell ${r==="dark"?"thread-ui-theme-dark dark":""} ${s?"thread-ui-viewport-constrained":""} ${s?"h-[100svh] max-h-[100svh] min-h-0 overflow-hidden overscroll-none":"min-h-[100svh] overflow-hidden"} bg-[#f6f8fb] text-slate-900 transition-colors duration-200 sm:p-2`,"data-theme-effective":r,"data-theme-mode":a??r,"data-thread-layout":n,children:e})}function $m({children:e,roomsRailCollapsed:r}){return t.jsx("div",{className:`thread-shell-frame relative h-full min-h-0 ${r?"is-rail-collapsed sm:grid-cols-[56px_minmax(0,1fr)]":"sm:grid-cols-[264px_minmax(0,1fr)]"}`,children:e})}function Dm({onClose:e,open:r}){return r?t.jsx("button",{type:"button","aria-hidden":"true",tabIndex:-1,className:"thread-mobile-only-block thread-mobile-scrim fixed inset-0 z-40 bg-slate-950/35 backdrop-blur-[1px]",onClick:e}):null}function Bm({children:e,collapsed:r,mobileOpen:n}){return t.jsx("aside",{className:`thread-graph-rooms-surface thread-rooms-rail fixed inset-y-0 left-0 z-50 flex min-h-0 min-w-0 w-[min(20rem,calc(100vw-2rem))] flex-col overflow-x-hidden border-r border-slate-200/80 bg-white shadow-[0_20px_50px_rgba(15,23,42,0.18)] transition-transform duration-200 ease-out sm:static sm:z-auto sm:w-auto sm:translate-x-0 sm:rounded-[12px] sm:border sm:shadow-[0_10px_30px_rgba(15,23,42,0.04)] ${n?"translate-x-0":"pointer-events-none -translate-x-full sm:pointer-events-auto"} ${r?"thread-ui-rail-collapsed sm:items-center":""}`,style:{paddingTop:"var(--android-safe-area-top, 0px)"},children:e})}function Gm({children:e}){return t.jsx("main",{className:"thread-shell-main h-full min-h-0 min-w-0 overflow-hidden",children:t.jsx("div",{className:"thread-main-panel thread-shell-card flex h-full min-h-0 flex-col overflow-hidden bg-white shadow-[0_10px_30px_rgba(15,23,42,0.04)] sm:rounded-[12px] sm:border sm:border-slate-200/80",children:e})})}function Fm({children:e}){return t.jsx("div",{className:"thread-topbar-surface flex shrink-0 flex-col border-b border-slate-200 bg-white pt-[env(safe-area-inset-top)] sm:pt-0",children:e})}function Hm({children:e}){return t.jsx("div",{className:"thread-split-region min-h-0 flex-1 overflow-hidden p-0 sm:p-2",children:e})}vo();Nt();function rs({...e}){return t.jsx(Bi,{"data-slot":"dialog",...e})}function ns({...e}){return t.jsx(Gi,{"data-slot":"dialog-trigger",...e})}function Om({...e}){return t.jsx(Wi,{"data-slot":"dialog-portal",...e})}function Um({className:e,...r}){return t.jsx(Vi,{"data-slot":"dialog-overlay",className:et("fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",e),...r})}function as({children:e,className:r,showCloseButton:n=!0,...a}){return t.jsxs(Om,{"data-slot":"dialog-portal",children:[t.jsx(Um,{}),t.jsxs(Fi,{"data-slot":"dialog-content",className:et("fixed left-[50%] top-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg",r),...a,children:[e,n?t.jsxs(Hi,{"data-slot":"dialog-close",className:"absolute right-4 top-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[t.jsx(G.XIcon,{}),t.jsx("span",{className:"sr-only",children:"Close"})]}):null]})]})}function ss({className:e,...r}){return t.jsx("div",{"data-slot":"dialog-header",className:et("flex flex-col gap-2 text-center sm:text-left",e),...r})}function os({className:e,...r}){return t.jsx(Oi,{"data-slot":"dialog-title",className:et("text-lg font-semibold leading-none",e),...r})}function ls({className:e,...r}){return t.jsx(Ui,{"data-slot":"dialog-description",className:et("text-sm text-muted-foreground",e),...r})}var Wm=[{value:"system",label:"Follow system",icon:G.Monitor},{value:"dark",label:"Dark",icon:G.Moon},{value:"light",label:"Light",icon:G.Sun}];function Vm({thread:e,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a={},onOpenThread:s,getThreadHref:o,renderThreadLink:l,onBeginRenameThread:i,onDeleteThread:d,showDeleteButton:h=!1,showSessionCopyButton:u=!1,collapsed:m=!1}){const[f,p]=c.useState("idle"),g=c.useRef(null),b=a[e.workspaceId],v=b&&!n?b:null,x=r===e.id;c.useEffect(()=>()=>{g.current!==null&&window.clearTimeout(g.current)},[]);async function y(){const C=e.providerSessionId;if(C)try{await navigator.clipboard.writeText(C),p("copied"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>p("idle"),1200)}catch{p("failed"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>p("idle"),1600)}}const k=()=>s(e.id),N=`thread-graph-room-card group flex w-full items-center gap-3 rounded-xl border text-left transition ${x?"is-active":""} ${m?"justify-center px-2 py-2":"px-3 py-2.5"}`,w=t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`thread-graph-room-card-icon flex h-8 w-8 shrink-0 items-center justify-center rounded-full ${x?"is-active":""}`,children:t.jsx(G.MessageSquare,{className:"h-4 w-4"})}),t.jsxs("div",{className:`min-w-0 flex-1 ${m?"thread-desktop-collapsed-hidden":""}`,children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[t.jsx("p",{className:"thread-graph-room-card-title min-w-0 flex-1 truncate text-sm font-medium",title:e.title,children:e.title}),i&&!m?t.jsx("button",{type:"button",onClick:C=>{C.stopPropagation(),C.preventDefault(),i(e)},"aria-label":`Rename thread ${e.title}`,title:"Rename thread",className:"thread-card-quiet-button inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full transition",children:t.jsx(G.Pencil,{className:"h-3 w-3"})}):null,u&&e.providerSessionId?t.jsx("button",{type:"button","aria-label":"Copy session ID",title:f==="copied"?"Copied":f==="failed"?"Copy failed":"Copy session ID",onClick:C=>{C.stopPropagation(),C.preventDefault(),y()},className:"thread-card-quiet-button thread-card-session-copy-button inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition",children:t.jsx(G.Copy,{className:"h-3.5 w-3.5"})}):null]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2",children:[v?t.jsx("p",{className:"thread-graph-room-card-meta min-w-0 flex-1 truncate text-[11px] text-[var(--theme-fg-muted)]",title:v,children:v}):t.jsx("span",{className:"min-w-0 flex-1","aria-hidden":"true"}),t.jsx("span",{className:`shrink-0 rounded-full border px-1.5 py-0.5 text-[9px] uppercase tracking-normal ${_m(e.status)}`,children:Rm(e.status)}),t.jsx("time",{className:"shrink-0 text-[11px] text-[var(--theme-fg-muted)]",dateTime:e.lastTurnStartedAt??e.updatedAt,children:_t(e.lastTurnStartedAt??e.updatedAt)})]})]}),h&&d&&!m?t.jsx("button",{type:"button",onClick:C=>{C.stopPropagation(),C.preventDefault(),d(e)},"aria-label":`Delete thread ${e.title}`,className:"thread-card-danger-button shrink-0 rounded-full p-1 transition",title:"Delete thread",children:t.jsx(G.Trash2,{className:"h-3.5 w-3.5"})}):null]}),j=o==null?void 0:o(e.id);return l?t.jsx(t.Fragment,{children:l({thread:e,children:w,className:N,onClick:k})}):j?t.jsx("a",{href:j,onClick:C=>{C.preventDefault(),k()},title:m?e.title:void 0,className:N,children:w}):t.jsx("div",{role:"link",tabIndex:0,onClick:k,onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),k())},title:m?e.title:void 0,className:N,children:w})}function Km({threads:e,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a={},onOpenThread:s,getThreadHref:o,renderThreadLink:l,onBeginRenameThread:i,onDeleteThread:d,scrollable:h=!1,maxHeightClassName:u="max-h-full",showDeleteButton:m=!1,showSessionCopyButton:f=!1,collapsed:p=!1}){const g=h?`min-h-0 min-w-0 overflow-x-hidden overflow-y-auto overscroll-contain pr-1 ${u}`:"";return t.jsx("div",{className:g,children:t.jsx("div",{className:"min-w-0 space-y-1",children:e.map(b=>t.jsx(Vm,{thread:b,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a,onOpenThread:s,showDeleteButton:m,showSessionCopyButton:f,collapsed:p,...o?{getThreadHref:o}:{},...l?{renderThreadLink:l}:{},...i?{onBeginRenameThread:i}:{},...d?{onDeleteThread:d}:{}},b.id))})})}function qm({threads:e,status:r,loading:n=!1,error:a,viewportConstrained:s=!1,layoutMode:o="responsive",effectiveTheme:l,themeMode:i,onThemeModeChange:d,showMobileNewThreadShortcut:h=!0,settingsDialogOpen:u,onSettingsDialogOpenChange:m,mobileHeaderAction:f,currentThreadId:p,currentThreadLabel:g=null,currentWorkspaceId:b=null,currentWorkspaceLabel:v=null,sessionLabel:x=null,usageLabel:y=null,topbarActions:k,metaContent:N,settingsContent:w,globalSettingsContent:j,workspaceLabels:C={},workspaceReturnHref:L,onWorkspaceReturn:T,getThreadHref:q,onOpenThread:M,getNewThreadHref:D,newThreadHref:J,newThreadLabel:W="New Chat",onNewThread:O,onNewThreadTitle:ee,renderThreadLink:he,onCloseAppNavigation:E,onRenameThread:re,onDeleteThread:A,workspaceContent:V,workspaceTitle:U="Workspace",workspaceActions:I,children:X}){const F=Zo(),[z,P]=c.useState(()=>typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)").matches:!1),Z=i??(F==null?void 0:F.themeMode)??"system",K=l??(F==null?void 0:F.effectiveTheme)??(Z==="system"?z?"dark":"light":Z),[de,_]=c.useState(!1),[Y,te]=c.useState(!1),[ie,ue]=c.useState(!1),[be,Le]=c.useState(()=>typeof window<"u"?window.matchMedia("(max-width: 639px)").matches:o==="mobile"),[ae,ve]=c.useState("workspace"),[ke,pe]=c.useState(null),[Ie,je]=c.useState(""),[_e,Pe]=c.useState(null),[Ae,Ce]=c.useState(!1),[Re,H]=c.useState(""),[ce,R]=c.useState(!1),[$,Q]=c.useState(!1),[me,xe]=c.useState("session");c.useEffect(()=>{if(typeof window>"u")return;const fe=window.matchMedia("(max-width: 639px)"),Te=()=>{Le(fe.matches)};return Te(),fe.addEventListener("change",Te),()=>{fe.removeEventListener("change",Te)}},[]),c.useEffect(()=>{if(typeof window>"u")return;const fe=window.matchMedia("(prefers-color-scheme: dark)"),Te=()=>{P(fe.matches)};return Te(),fe.addEventListener("change",Te),()=>{fe.removeEventListener("change",Te)}},[]);const ze=c.useMemo(()=>[...b?e.filter(Te=>Te.workspaceId===b):e].sort((Te,Ze)=>{if(Te.id===p)return-1;if(Ze.id===p)return 1;const Ke=Date.parse(Te.lastTurnStartedAt??Te.updatedAt);return Date.parse(Ze.lastTurnStartedAt??Ze.updatedAt)-Ke}),[p,b,e]),ge=J??(D==null?void 0:D(b)),Me=v??b??"all",at=x??g??p??"default_session",Je=y??(r!=null&&r.state?`runtime ${r.state}`:"waiting for agent usage"),Qe=d??(F==null?void 0:F.setThemeMode),De=!!Qe,Be=()=>{_(!1),E==null||E()};async function lt(fe){if(!re)return;const Te=Ie.trim();if(Te){Pe(fe);try{await re(fe,Te),pe(null),je("")}finally{Pe(null)}}}function He(fe){pe(fe.id),je(fe.title)}function tt(){pe(null),je("")}function it(fe){M==null||M(fe),Be()}function Ye(fe){if(!ge||!fe.trim())return ge;try{const Te=new URL(ge,window.location.origin);return Te.searchParams.set("title",fe.trim()),`${Te.pathname}${Te.search}${Te.hash}`}catch{const Te=ge.includes("?")?"&":"?";return`${ge}${Te}title=${encodeURIComponent(fe.trim())}`}}async function S(){const fe=Re.trim();R(!0);try{if(fe&&ee){await ee(fe),H(""),Ce(!1),Be();return}if(ge){window.location.assign(Ye(fe)??ge);return}await(O==null?void 0:O()),H(""),Ce(!1),Be()}finally{R(!1)}}function B(fe,Te=!1){const Ze=Te?t.jsxs(t.Fragment,{children:[t.jsx(G.Plus,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:W})]}):t.jsxs(t.Fragment,{children:[t.jsx(G.Plus,{className:"h-4 w-4"}),t.jsx("span",{children:W})]});return t.jsxs(rs,{open:Ae,onOpenChange:Ke=>{ce||Ce(Ke)},children:[t.jsx(ns,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":Te?W:void 0,title:W,className:fe,children:Ze})}),t.jsxs(as,{"data-testid":"create-thread-dialog","data-theme-effective":K,"data-theme-mode":Z,className:"thread-graph-create-thread-dialog thread-graph-dialog",children:[t.jsxs(ss,{children:[t.jsx(os,{children:"Create New Chat"}),t.jsx(ls,{children:"Name the room so it is easy to find later."})]}),t.jsxs("div",{className:"grid gap-3",children:[t.jsx("input",{id:"thread-graph-create-thread-title",name:"thread-title",value:Re,onChange:Ke=>H(Ke.target.value),onKeyDown:Ke=>{Ke.key==="Enter"&&(Ke.preventDefault(),S())},placeholder:"Chat name","aria-label":"Chat name",autoComplete:"off",className:"thread-graph-create-thread-input h-10 rounded-md border px-3 text-sm outline-none transition"}),t.jsx("button",{type:"button",onClick:()=>void S(),disabled:ce,className:"thread-graph-create-thread-submit inline-flex h-10 items-center justify-center rounded-md px-4 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:ce?"Creating...":"Create"})]})]})]})}function se(){if(!w&&!N&&!j&&!De)return null;const fe=!!(w||N),Te=!!j,Ze=me==="global"&&Te||!fe&&Te?"global":"session";return t.jsxs(rs,{...u!==void 0?{open:u}:{},...m?{onOpenChange:m}:{},children:[t.jsx(ns,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":"Open settings",title:"Settings",className:"thread-icon-button inline-flex h-10 w-10 items-center justify-center rounded-full sm:h-9 sm:w-9",children:t.jsx(G.Settings,{className:"h-4 w-4"})})}),t.jsxs(as,{"data-testid":"settings-dialog","data-theme-effective":K,"data-theme-mode":Z,className:"thread-graph-settings-dialog thread-graph-dialog",children:[t.jsxs(ss,{children:[t.jsx(os,{children:"Settings"}),t.jsx(ls,{children:"Manage this session and host-wide preferences."})]}),De?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"font-medium text-[var(--theme-fg)]",children:"Appearance"}),t.jsxs("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:["Current theme: ",K]})]}),t.jsx("div",{className:"thread-graph-theme-mode-group grid grid-cols-3 gap-1 rounded-lg border p-1",role:"group","aria-label":"Theme mode",children:Wm.map(Ke=>{const Bt=Ke.icon,Gt=Z===Ke.value;return t.jsxs("button",{type:"button","data-testid":`theme-mode-${Ke.value}`,"aria-pressed":Gt,disabled:!De,onClick:()=>Qe==null?void 0:Qe(Ke.value),className:`thread-graph-theme-mode-button inline-flex min-h-9 items-center justify-center gap-1.5 rounded-md px-2 text-xs font-medium transition ${Gt?"is-selected":""}`,children:[t.jsx(Bt,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:"truncate",children:Ke.label})]},Ke.value)})})]})}):null,t.jsxs("div",{className:"thread-graph-settings-tabs grid grid-cols-2 gap-1 rounded-lg border p-1",children:[t.jsx("button",{type:"button","aria-pressed":Ze==="session",onClick:()=>xe("session"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Ze==="session"?"is-active":""}`,children:"Session"}),t.jsx("button",{type:"button","aria-pressed":Ze==="global",disabled:!Te,onClick:()=>xe("global"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Ze==="global"?"is-active":""}`,children:"Global"})]}),t.jsx("div",{className:"thread-graph-settings-body mt-4 min-h-0 overflow-y-auto pr-1 text-sm",children:Ze==="session"?t.jsxs("div",{className:"grid gap-4",children:[w?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:w}):null,N?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:N}):null,fe?null:t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3 text-[var(--theme-fg-muted)]",children:"No session settings are available."})]}):t.jsx("div",{className:"thread-graph-settings-global-content",children:j})})]})]})}function ye(fe=!1){return t.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:t.jsxs("section",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs("div",{className:`mb-3 flex items-center gap-2 px-2 text-xs font-medium tracking-normal text-[var(--theme-fg-muted)] ${fe?"justify-center":""}`,children:[t.jsx(G.Rows3,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:fe?"sr-only":"",children:"Rooms"}),!fe&&n?t.jsx("span",{className:"ml-auto text-xs text-[var(--theme-fg-muted)]",children:"Refreshing..."}):null]}),t.jsxs("div",{className:"min-h-0 min-w-0 flex-1 overflow-x-hidden overflow-y-auto px-1",children:[a?t.jsx("div",{className:"rounded-xl border border-rose-500/30 bg-rose-500/10 px-3 py-3 text-sm text-rose-900 dark:text-rose-100",children:a}):null,!a&&ze.length===0&&!n?t.jsx("div",{className:"rounded-xl border border-dashed border-[var(--theme-border)] bg-[var(--theme-surface)] px-4 py-6 text-sm text-[var(--theme-fg-muted)]",children:"No threads available in this view."}):null,ze.length>0?t.jsx(Km,{threads:ze,currentThreadId:p,currentWorkspaceId:b,workspaceLabels:C,onOpenThread:it,collapsed:fe,...re?{onBeginRenameThread:He}:{},showDeleteButton:!!A,...q?{getThreadHref:q}:{},...he?{renderThreadLink:he}:{},...A?{onDeleteThread:A}:{}}):null]})]})})}function Oe(){return V?t.jsxs("div",{className:"thread-workspace-panel relative flex h-full min-h-0 flex-col overflow-hidden rounded-[12px] border",children:[t.jsx("button",{type:"button",onClick:()=>ue(!0),className:"thread-workspace-collapse-tab thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(G.ChevronsRight,{className:"h-4 w-4"})}),I?t.jsx("div",{className:"pointer-events-none absolute right-12 top-2 z-20 flex items-center gap-1",children:t.jsx("div",{className:"pointer-events-auto",children:I})}):null,t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:V})]}):t.jsxs("div",{className:"thread-workspace-panel flex h-full min-h-0 flex-col overflow-hidden rounded-[12px] border",children:[t.jsxs("div",{className:"thread-workspace-panel-header flex h-12 shrink-0 items-center justify-between gap-3 border-b border-[var(--theme-border)] px-3 sm:h-[60px] sm:px-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-base font-semibold text-[var(--theme-fg)] sm:text-[18px]",children:U}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:v??b??"Current context"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[I,t.jsx("button",{type:"button",onClick:()=>ue(!0),className:"thread-workspace-small-toggle thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(G.ChevronsRight,{className:"h-4 w-4"})})]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:V??t.jsxs("div",{className:"grid h-full min-h-0 gap-3 overflow-y-auto p-3 text-sm text-[var(--theme-fg-soft)]",children:[t.jsxs("div",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:"Runtime"}),t.jsx("p",{className:"mt-2 text-[var(--theme-fg)]",children:(r==null?void 0:r.state)??"unknown"})]}),t.jsxs("div",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:"Workspace"}),t.jsx("p",{className:"mt-2 break-words text-[var(--theme-fg)]",children:v??b??"All threads"})]})]})})]})}const rt=!!V,nt=o==="mobile"||o==="responsive"&&be,Ge=nt,Ve=Ge&&!de,bt=!!(L||T)?t.jsx("a",{href:L??"#",onClick:fe=>{T&&(fe.preventDefault(),T())},className:"thread-icon-button inline-flex h-10 w-10 items-center justify-center rounded-full sm:h-9 sm:w-9",title:"Back to workspace","aria-label":"Back to workspace",children:t.jsx(G.ArrowLeft,{className:"h-4 w-4"})}):null;return t.jsxs(t.Fragment,{children:[t.jsx(Mm,{effectiveTheme:K,layoutMode:o,themeMode:Z,viewportConstrained:s,children:t.jsxs($m,{roomsRailCollapsed:Y,children:[t.jsx(Dm,{open:de,onClose:()=>_(!1)}),t.jsxs(Bm,{collapsed:Y,mobileOpen:de,children:[t.jsx("div",{className:`thread-rooms-rail-header flex h-[calc(3.75rem+env(safe-area-inset-top))] shrink-0 items-end border-b border-[var(--theme-border)] px-4 pb-3 sm:h-16 sm:items-center sm:pb-0 ${Y?"sm:w-full sm:justify-center sm:px-2":""}`,children:t.jsxs("div",{className:`flex w-full items-center gap-3 ${Y?"sm:justify-center":"justify-between"}`,children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[t.jsx("button",{type:"button",onClick:()=>te(fe=>!fe),className:"thread-icon-button thread-desktop-only-flex h-9 w-9 shrink-0 items-center justify-center rounded-full",title:Y?"Expand rooms":"Collapse rooms","aria-label":Y?"Expand rooms":"Collapse rooms",children:Y?t.jsx(G.PanelLeftOpen,{className:"h-4 w-4"}):t.jsx(G.PanelLeftClose,{className:"h-4 w-4"})}),t.jsx("div",{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-[var(--theme-accent-solid)] text-sm font-semibold text-[var(--theme-accent-solid-fg)] ${Y?"thread-desktop-collapsed-hidden":""}`,children:(v??"R").charAt(0).toUpperCase()}),t.jsxs("div",{className:`min-w-0 ${Y?"thread-desktop-collapsed-hidden":""}`,children:[t.jsx("p",{className:"truncate text-sm font-semibold text-[var(--theme-fg)]",children:v??"Remote Codex"}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:b??"Thread workspace"})]})]}),t.jsxs("div",{className:`flex shrink-0 items-center gap-1 ${Y?"thread-desktop-collapsed-hidden":""}`,children:[se(),bt,t.jsx("button",{type:"button",onClick:()=>_(!1),"aria-label":"Close rooms",title:"Close rooms",className:"thread-icon-button thread-mobile-only-inline-flex h-10 w-10 items-center justify-center rounded-full",children:t.jsx(G.X,{className:"h-4 w-4"})})]})]})}),t.jsx("div",{className:`thread-graph-new-room-strip flex shrink-0 items-center border-b ${Y?"h-12 w-full justify-center px-2 sm:h-12":"h-[68px] px-4"}`,children:B(`thread-graph-new-room-button inline-flex items-center justify-center rounded-xl font-medium transition ${Y?"h-9 w-9 p-0":"h-11 w-full gap-2 px-3 text-sm sm:h-9"}`,Y)}),t.jsx("div",{className:`flex min-h-0 flex-1 flex-col ${Y?"w-full px-2 py-2":"px-3 py-3"}`,children:ye(Y)})]}),t.jsxs(Gm,{children:[t.jsx(Fm,{children:t.jsx("div",{className:"thread-topbar-row flex min-h-12 items-center px-3 py-1.5 sm:min-h-12 sm:px-4",children:t.jsxs("div",{className:"flex w-full items-center justify-between gap-3 sm:gap-4",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2 sm:gap-3",children:[Ve?t.jsx("button",{type:"button",onClick:()=>_(!0),"aria-label":"Open rooms",title:"Open rooms",className:"thread-icon-button thread-mobile-only-inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-full",children:t.jsx(G.Menu,{className:"h-4 w-4"})}):null,t.jsxs("div",{className:"min-w-0",children:[Ge?t.jsx("h1",{className:"thread-mobile-only-block min-w-0 truncate text-sm font-semibold leading-none text-[var(--theme-fg)]",children:g??"Shared Workspace"}):null,t.jsxs("div",{className:"relative flex min-w-0 items-center gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{Q(fe=>!fe)},"aria-expanded":$,"aria-haspopup":"dialog",className:"thread-topbar-meta-row flex min-w-0 max-w-full items-center gap-1 text-left text-[11px] leading-none sm:text-xs",title:"Session and usage",children:[t.jsx("span",{className:"shrink-0",children:"Room"}),t.jsx("span",{className:"truncate font-mono",children:Me})]}),$?t.jsxs("div",{className:"thread-topbar-details-popover absolute left-0 top-[calc(100%+0.5rem)] z-50 w-[min(26rem,calc(100vw-1.5rem))] rounded-lg border p-2.5 shadow-lg",role:"dialog","aria-label":"Session and usage",children:[t.jsxs("button",{type:"button",onClick:()=>{var fe;Me&&((fe=navigator.clipboard)==null||fe.writeText(Me))},className:"thread-topbar-meta-row flex min-w-0 max-w-full items-center gap-2 text-left text-xs leading-5",title:"Copy room ID",children:[t.jsx("span",{className:"w-12 shrink-0",children:"Room"}),t.jsx("span",{className:"truncate font-mono",children:Me})]}),t.jsxs("button",{type:"button",onClick:()=>{var fe;at&&((fe=navigator.clipboard)==null||fe.writeText(at))},className:"thread-topbar-meta-row flex min-w-0 max-w-full items-center gap-2 text-left text-xs leading-5",title:"Copy session ID",children:[t.jsx("span",{className:"w-12 shrink-0",children:"Session"}),t.jsx("span",{className:"truncate font-mono",children:at})]}),t.jsxs("div",{className:"thread-topbar-meta-row mt-1 flex min-w-0 max-w-full items-center gap-2 text-xs leading-5",title:"Room token usage",children:[t.jsx("span",{className:"w-12 shrink-0",children:"Usage"}),t.jsx("span",{className:"truncate font-mono",children:Je})]})]}):null]})]})]}),t.jsxs("div",{className:"inline-flex shrink-0 items-center gap-2",children:[k?t.jsx("div",{className:"thread-graph-topbar-actions thread-desktop-only-inline-flex items-center rounded-lg border p-0.5 shadow-none",children:k}):null,Ge&&rt?t.jsx("button",{type:"button",onClick:()=>ve(fe=>fe==="workspace"?"chat":"workspace"),"aria-label":ae==="workspace"?"Show chat":"Show workspace",title:ae==="workspace"?"Show chat":"Show workspace",className:"thread-icon-button thread-mobile-only-inline-flex h-10 w-10 items-center justify-center rounded-full",children:ae==="workspace"?t.jsx(G.MessageSquare,{className:"h-4 w-4"}):t.jsx(G.Folder,{className:"h-4 w-4"})}):null,Ge?f:null,Ge&&h?B("thread-secondary-action inline-flex h-10 items-center justify-center gap-2 rounded-lg border px-3 text-sm font-medium sm:h-9"):null]})]})})}),t.jsx(Hm,{children:rt&&!ie?nt?t.jsxs("div",{className:"thread-split-container thread-graph-shell-mobile-split h-full min-h-0 overflow-hidden",children:[t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${ae==="chat"?"block":"thread-mobile-chat-hidden"}`,children:X}),t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${ae==="workspace"?"block":"thread-mobile-workspace-hidden"}`,children:Oe()})]}):t.jsxs(Sn,{direction:"horizontal",className:"thread-split-container thread-graph-shell-resizable thread-graph-shell-desktop-split h-full min-h-0 overflow-hidden",children:[t.jsx(Xt,{defaultSize:47,minSize:30,maxSize:75,className:"thread-split-chat-pane min-w-0 overflow-hidden",children:X}),t.jsx(Tn,{className:"thread-resize-handle w-2 bg-transparent after:w-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(Xt,{defaultSize:53,minSize:30,maxSize:70,className:"thread-split-workspace-pane min-w-0 overflow-hidden",children:Oe()})]}):t.jsxs("div",{className:"thread-split-container relative h-full min-h-0 overflow-hidden",children:[rt&&ie?t.jsx("button",{type:"button",onClick:()=>ue(!1),className:"thread-workspace-expand-fab thread-desktop-only-inline-flex",title:"Expand workspace","aria-label":"Expand workspace",children:t.jsx(G.ChevronsLeft,{className:"h-4 w-4"})}):null,X]})})]})]})}),t.jsx(Am,{open:ke!==null,title:"Rename Thread",label:"Thread Title",value:Ie,busy:_e!==null,onChange:je,onCancel:tt,onSubmit:()=>ke?lt(ke):void 0})]})}function Xm({open:e,title:r,text:n,onClose:a}){return c.useEffect(()=>{if(!e)return;function s(o){o.key==="Escape"&&a()}return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[a,e]),e?$r.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[90] flex items-center justify-center p-4 sm:p-6",children:[t.jsx("button",{type:"button","aria-label":"Close full text",onClick:a,className:"absolute inset-0 bg-stone-950/78 backdrop-blur-sm"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":r,className:"relative z-[1] flex max-h-[min(82vh,52rem)] w-full max-w-4xl flex-col overflow-hidden rounded-[1.8rem] border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-stone-800 px-4 py-3 sm:px-5",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:r}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:a,className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-stone-700 text-stone-300 transition hover:bg-stone-800",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-4 py-4 sm:px-5",children:t.jsx("pre",{className:"whitespace-pre-wrap break-words text-sm leading-6 text-stone-200",children:n})})]})]}),document.body):null}var Ym=[/^(?: {0,3})#{1,6}\s+\S/m,/^(?: {0,3})>{1,}\s*\S/m,/^(?: {0,3})(?:[-+*]|\d{1,9}[.)])\s+(?:\[[ xX]\]\s+)?\S/m,/^(?: {0,3})(?:```|~~~)/m,/^(?: {0,3})(?:[-*_]\s*){3,}$/m],Zm=/^(?:\|?[^|\n]+\|[^|\n]+(?:\|[^|\n]+)*\|?\s*\n\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$)/m,Jm=/!?\[[^\]\n]+\]\([^)]+\)/,Qm=/`[^`\n]+`/,ep=/(?:\*\*[^*\n]+\*\*|__[^_\n]+__)/,tp=/(^|[^\w])(?:\*[^*\n]+\*|_[^_\n]+_)(?=[^\w]|$)/,rp=/~~[^~\n]+~~/;function np(e){const r=e.trim();return r?Ym.some(n=>n.test(r))||Zm.test(r)?!0:/[`[\]*_~!]/.test(r)?Jm.test(r)||Qm.test(r)||ep.test(r)||tp.test(r)||rp.test(r):!1:!1}Or();function Dn(e,r){const n=new Map(r.map(o=>[o.id,o])),a=e.map(o=>{var l,i;return{...o.manifest,enabled:((l=n.get(o.manifest.id))==null?void 0:l.enabled)??!0,source:((i=n.get(o.manifest.id))==null?void 0:i.source)??"builtin"}}),s=new Set(e.map(o=>o.manifest.id));for(const o of r)s.has(o.id)||a.push(o);return a}function ea(e=[]){const r=Dn(e,[]),n=e;return{plugins:r,loading:!1,error:null,async refresh(){},async importPluginManifest(){},async setPluginEnabled(){},async uninstallPlugin(){},renderArtifact:o=>{var i;const l=n.find(d=>d.renderArtifact&&d.manifest.capabilities.artifactTypes.some(h=>h.type===o.artifact.type));return((i=l==null?void 0:l.renderArtifact)==null?void 0:i.call(l,o))??null},renderInlineCode:o=>{for(const l of n)for(const i of l.inlineCodeRenderers??[]){if(!i.languages.includes(o.language.trim().toLowerCase()))continue;const d=i.render(o);if(d)return d}return null},hasRendererForArtifact:o=>n.some(l=>!!l.renderArtifact&&l.manifest.capabilities.artifactTypes.some(i=>i.type===o.type)),getThreadPanels:()=>n.flatMap(o=>o.threadPanels??[])}}var ta=c.createContext(ea());function ra(){return c.useContext(ta)??ea()}xr();function Qo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function is(e){return Qo(e)?Object.entries(e):e==null||e===""?[]:[["value",e]]}function el(e){return typeof e=="string"?t.jsxs("span",{className:"thread-graph-tool-string",children:['"',e,'"']}):typeof e=="number"?t.jsx("span",{className:"thread-graph-tool-number",children:e}):typeof e=="boolean"?t.jsx("span",{className:"thread-graph-tool-boolean",children:String(e)}):e===null?t.jsx("span",{className:"thread-graph-tool-null",children:"null"}):typeof e=="object"?t.jsx("span",{className:"thread-graph-tool-object",children:JSON.stringify(e)}):t.jsx("span",{children:String(e)})}function ap(e,r){return typeof r=="string"&&(e==="stdout"||e==="stderr"||e==="result")?t.jsx("pre",{className:"thread-graph-tool-output",children:r||"(empty)"}):typeof r=="object"&&r!==null?t.jsx("pre",{className:"thread-graph-tool-output",children:JSON.stringify(r,null,2)}):el(r)}function ds({callId:e,toolName:r,status:n,parameters:a,result:s}){const o=c.useMemo(()=>{switch(n){case"completed":return{className:"is-completed",icon:t.jsx(G.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"};case"failed":return{className:"is-failed",icon:t.jsx(G.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"};default:return{className:"is-pending",icon:t.jsx(G.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),label:"Running"}}},[n]),l=c.useMemo(()=>is(s),[s]),i=c.useMemo(()=>is(a),[a]),d=c.useMemo(()=>typeof s=="string"?s.length>0:Qo(s)?["stdout","stderr","result"].some(f=>{const p=s[f];return typeof p=="string"&&p.length>0}):!1,[s]),h=n==="pending"||d,[u,m]=c.useState(h?"item-1":void 0);return c.useEffect(()=>{h&&m("item-1")},[e,h]),t.jsx("div",{className:"thread-graph-tool-call my-2 w-full font-sans not-prose",children:t.jsx(pr,{type:"single",collapsible:!0,onValueChange:f=>m(f||void 0),className:"thread-graph-tool-accordion w-full overflow-hidden rounded-lg border",...u!==void 0?{value:u}:{},children:t.jsxs(fr,{value:"item-1",className:"border-0",children:[t.jsx(Ur,{className:"thread-graph-tool-trigger px-4 py-3 hover:no-underline",children:t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(G.Wrench,{className:"h-4 w-4 shrink-0"}),t.jsx("span",{className:"min-w-0 truncate font-mono text-sm font-semibold",children:r}),t.jsxs("span",{className:`thread-graph-tool-badge ${o.className}`,title:o.label,"aria-label":`Status: ${o.label}`,children:[o.icon,t.jsx("span",{className:"thread-graph-status-label",children:o.label})]})]})}),t.jsxs(gr,{className:"thread-graph-tool-content px-4 pb-4 pt-1",children:[t.jsxs("section",{children:[t.jsx("h4",{children:"Parameters"}),t.jsxs("div",{className:"thread-graph-tool-json",children:["{",t.jsx("br",{}),i.length>0?i.map(([f,p],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',f,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),el(p),g<i.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},f)):t.jsx("div",{children:t.jsx("span",{className:"thread-graph-tool-null",children:"empty"})}),"}"]})]}),l.length>0?t.jsxs("section",{children:[t.jsx("h4",{children:"Result"}),t.jsxs("div",{className:"thread-graph-tool-json",children:["{",t.jsx("br",{}),l.map(([f,p],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',f,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),ap(f,p),g<l.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},f)),"}"]})]}):null]})]})})})}var cs=null;function sp(){return cs??(cs=Promise.all([Ue(()=>import("./core-oEok_Crl.js"),__vite__mapDeps([0,1,2])),Ue(()=>import("./engine-javascript-DBd1bXLz.js"),[]),Ue(()=>import("./ayu-light-BA47KaF1.js"),[]),Ue(()=>import("./ayu-dark-DYE7WIF3.js"),[]),Ue(()=>import("./javascript-wDzz0qaB.js"),[]),Ue(()=>import("./typescript-BPQ3VLAy.js"),[]),Ue(()=>import("./tsx-COt5Ahok.js"),[]),Ue(()=>import("./jsx-g9-lgVsj.js"),[]),Ue(()=>import("./python-B6aJPvgy.js"),[]),Ue(()=>import("./json-Cp-IABpG.js"),[]),Ue(()=>import("./shellscript-CEILq0vU.js").then(e=>e.b),[]),Ue(()=>import("./shellscript-CEILq0vU.js").then(e=>e.s),[]),Ue(()=>import("./yaml-Buea-lGh.js"),[]),Ue(()=>import("./toml-vGWfd6FD.js"),[]),Ue(()=>import("./markdown-Cvjx9yec.js"),[]),Ue(()=>import("./html-pp8916En.js"),__vite__mapDeps([3,4,5])),Ue(()=>import("./css-CLj8gQPS.js"),[]),Ue(()=>import("./sql-CRqJ_cUM.js"),[]),Ue(()=>import("./csv-fuZLfV_i.js"),[])]).then(([{createHighlighterCore:e},{createJavaScriptRegexEngine:r},n,a,s,o,l,i,d,h,u,m,f,p,g,b,v,x,y])=>e({engine:r(),themes:[n.default,a.default],langs:[s.default,o.default,l.default,i.default,d.default,h.default,u.default,m.default,f.default,p.default,g.default,b.default,v.default,x.default,y.default]}))),cs}function Wr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Bn(e){if(!e)return{};if(Wr(e)&&Object.prototype.hasOwnProperty.call(e,"0"))try{const r=Object.keys(e).map(Number).filter(n=>Number.isFinite(n)).sort((n,a)=>n-a).map(n=>String(e[String(n)]??"")).join("");return JSON.parse(r)}catch{return e}if(typeof e=="string")try{return JSON.parse(e)}catch{return e}return e}function Gn(){return{finalResult:null,stdout:"",stderr:""}}function op(e){return typeof e=="string"?{result:e}:e}function tl(e){const r=Wr(e.finalResult)?{...e.finalResult}:e.finalResult!=null?{result:e.finalResult}:{};return e.stdout&&(r.stdout=e.stdout),e.stderr&&(r.stderr=e.stderr),!("status"in r)&&(e.stdout||e.stderr)&&(r.status="pending"),r}function hs(e){if(!e)return"pending";if(!Wr(e))return"completed";const r=e.status;return r==="stream"||r==="pending"||r==="running"?"pending":r==="failed"||r==="error"||r==="timed_out"||typeof e.exit_code=="number"&&e.exit_code!==0?"failed":"completed"}function lp(e){const r=new Map,n=/```tool-result\s*([\s\S]*?)\s*```/g,a=e.replace(n,(l,i)=>{try{const d=JSON.parse(i),h=d.call_id;if(typeof h!="string")return l;const u=op(d.result),m=r.get(h)??Gn();return Wr(u)&&u.status==="stream"&&typeof u.chunk=="string"?u.stream==="stderr"?m.stderr+=u.chunk:m.stdout+=u.chunk:m.finalResult=u,r.set(h,m),""}catch{return l}}),s=/```tool-call\s*([\s\S]*?)\s*```/g;return{processedContent:a.replace(s,(l,i)=>{try{const d=JSON.parse(i),h=d.call_id,u=d.tool;if(typeof u!="string")return l;const m=Bn(d.args);if(typeof h=="string"&&r.has(h)){const f=tl(r.get(h)??Gn());return`\`\`\`tool-merged
|
|
3604
3611
|
${JSON.stringify({call:{tool:u,args:m,call_id:h},result:f},null,2)}
|
|
3605
|
-
\`\`\``}return l}catch{return l}}),resultMap:r}}var
|
|
3606
|
-
`)||L!==T;if(
|
|
3612
|
+
\`\`\``}return l}catch{return l}}),resultMap:r}}var ip=["/api/","/assets/","/control-plane","/devices/","/relay/","/relay-account","/relay-admin","/relay-devices","/relay-portal","/threads","/workspaces"];function us(e){return e.replace(/background-color:[^;"]+;?/g,"background-color: transparent;").replace(/background:[^;"]+;?/g,"background: transparent;")}function ms(e){return Array.isArray(e)?e.map(r=>String(r)).join(""):String(e??"")}function dp(e){if(!e||typeof e!="object"||!("position"in e))return{startLine:void 0,endLine:void 0};const r=e.position;if(!r||typeof r!="object")return{startLine:void 0,endLine:void 0};const n=r.start,a=r.end,s=n&&typeof n=="object"?n.line:void 0,o=a&&typeof a=="object"?a.line:void 0;return{startLine:typeof s=="number"?s:void 0,endLine:typeof o=="number"?o:void 0}}function cp(e){if(!e)return null;let r=e.trim();if(!r)return null;try{if(typeof window>"u")return null;const o=new URL(r,window.location.origin);if(o.origin!==window.location.origin&&o.protocol!=="file:")return null;r=(o.protocol==="file:",o.pathname)}catch{}try{r=decodeURIComponent(r)}catch{}if(!r.startsWith("/")||ip.some(o=>r===o||r.startsWith(o)))return null;const n=r.match(/:(\d+)(?::\d+)?$/),a=n?Number.parseInt(n[1]??"",10):void 0,s=n?r.slice(0,-n[0].length):r;return!s||s==="/"?null:{path:s,...Number.isFinite(a)?{line:a}:{}}}function hp({children:e,...r}){return up(e)?t.jsx(t.Fragment,{children:e}):t.jsx("pre",{...r,children:e})}function up(e){var n;if(!e||typeof e!="object"||!("props"in e))return!1;const r=(n=e.props)==null?void 0:n.className;return typeof r!="string"?!1:r.includes("language-tool-call")||r.includes("language-tool-merged")||r.includes("language-tool-result")}var mp=c.memo(function({className:r="thread-graph-markdown",content:n,onOpenWorkspaceFile:a}){const s=c.useRef(null),o=ra(),[l,i]=c.useState(null),[d,h]=c.useState({}),[u,m]=c.useState(!1),{processedContent:f,resultMap:p}=c.useMemo(()=>lp(n),[n]);c.useEffect(()=>{let v=!0;return sp().then(x=>{v&&i(x)}).catch(()=>{}),()=>{v=!1}},[]),c.useEffect(()=>{const v=s.current,x=v==null?void 0:v.closest(".thread-ui-shell"),y=()=>x?x.getAttribute("data-theme-effective")==="dark"||x.classList.contains("dark")||x.classList.contains("thread-ui-theme-dark"):document.documentElement.classList.contains("dark");if(m(y()),!x)return;const k=new MutationObserver(()=>m(y()));return k.observe(x,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>k.disconnect()},[]);async function g(v,x){try{await navigator.clipboard.writeText(x),h(y=>({...y,[v]:"copied"})),window.setTimeout(()=>{h(y=>{const k={...y};return delete k[v],k})},1200)}catch{h(y=>({...y,[v]:"failed"}))}}const b=({children:v,className:x,inline:y,node:k,...N})=>{var D;const w=/language-(\w+(?:-\w+)*)/.exec(x||""),j=w?w[1]??"":"",C=ms(v).replace(/\n$/,""),{startLine:L,endLine:T}=dp(k),q=y===!1||!!x||C.includes(`
|
|
3613
|
+
`)||L!==T;if(j==="tool-merged"){let J={call:{tool:"Unknown",args:{},call_id:void 0},result:null};try{J=JSON.parse(C)}catch{J={call:{tool:"Error",args:{raw:C}},result:{status:"failed"}}}const W=typeof J.call.tool=="string"?J.call.tool:"Unknown",O=typeof J.call.call_id=="string"?J.call.call_id:void 0;return t.jsx(ds,{callId:O,toolName:W,status:hs(J.result),parameters:Bn(J.call.args),result:J.result})}if(j==="tool-call"){let J={tool:"Unknown",args:{},call_id:void 0};try{J=JSON.parse(C)}catch{J={tool:"Error",args:{raw:C}}}const W=typeof J.call_id=="string"?J.call_id:void 0,O=W&&p.has(W)?tl(p.get(W)??Gn()):void 0;return t.jsx(ds,{callId:W,toolName:typeof J.tool=="string"?J.tool:"Unknown",status:O?hs(O):"pending",parameters:Bn(J.args),result:O})}if(j==="tool-result")return null;if(["xyz","extxyz","cif","pdb"].includes(j)){const J=o.renderInlineCode({code:C,isIncomplete:!1,language:j});if(c.isValidElement(J))return J}if(q){const W=(((D=l==null?void 0:l.getLoadedLanguages)==null?void 0:D.call(l))??[]).includes(j)?j:"text",O=u?"ayu-dark":"ayu-light",ee=`${j||"text"}:${C.length}:${C.slice(0,32)}`;let he="";if(l)try{he=us(l.codeToHtml(C,{lang:W,theme:O}))}catch{he=us(l.codeToHtml(C,{lang:"text",theme:O}))}return t.jsxs("div",{className:"thread-graph-code-block not-prose relative my-3 overflow-auto rounded-xl border p-3 text-sm shadow-sm",children:[t.jsx(ur,{type:"button",onClick:()=>void g(ee,C),variant:"ghost",size:"sm",className:"thread-graph-code-copy absolute right-2 top-2 z-10 rounded-md p-1.5",title:d[ee]==="copied"?"Copied":d[ee]==="failed"?"Copy failed":"Copy","aria-label":"Copy code",children:t.jsx(G.Copy,{className:"h-3.5 w-3.5"})}),he?t.jsx("div",{dangerouslySetInnerHTML:{__html:he}}):t.jsx("pre",{children:t.jsx("code",{className:"whitespace-pre",children:C})})]})}const M=ms(v).replace(/`+/g,"");return t.jsx("code",{className:`thread-graph-inline-code rounded px-1 py-0.5 font-mono font-normal text-[0.9em] ${x||""}`,...N,children:M})};return t.jsx("div",{ref:s,className:`thread-graph-message-markdown ${r}`,children:t.jsx(ud,{remarkPlugins:[pd,fd],rehypePlugins:[md],components:{a({href:v,children:x,...y}){const k=cp(v);return k&&a?t.jsx("a",{...y,href:v,className:"thread-inline-link",onClick:N=>{N.preventDefault(),a(k)},children:x}):t.jsx("a",{...y,href:v,className:"thread-inline-link",children:x})},code:b,pre:hp},children:f})})}),ps=4e3,pp=/\b(?:https?:\/\/|www\.)[^\s<>"'`]+/gi,fp=/[),.;:!?]+$/;function gp(e){return e.startsWith("www.")?`https://${e}`:e}function fs(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function xp(e){var o;if(!e)return[];const r=/\[(PHOTO|FILE)\s+([^\]]+)\]/g,n=[];let a=0,s=0;for(const l of e.matchAll(r)){const i=l.index??0;i>a&&(n.push({type:"text",key:`text-${s}`,text:e.slice(a,i)}),s+=1);const d=l[1],h=((o=l[2])==null?void 0:o.trim())??"";d==="PHOTO"&&h?n.push({type:"photo",key:`photo-${s}`,path:h}):d==="FILE"&&h?n.push({type:"file",key:`file-${s}`,path:h}):n.push({type:"text",key:`text-${s}`,text:l[0]}),s+=1,a=i+l[0].length}return a<e.length&&n.push({type:"text",key:`text-${s}`,text:e.slice(a)}),n}function Jt({text:e}){var a;const r=[];let n=0;for(const s of e.matchAll(pp)){const o=s[0],l=s.index??0,i=((a=o.match(fp))==null?void 0:a[0])??"",d=i?o.slice(0,-i.length):o;d&&(l>n&&r.push(e.slice(n,l)),r.push(t.jsx("a",{href:gp(d),target:"_blank",rel:"noreferrer",className:"thread-inline-link",children:d},`${l}-${d}`)),i&&r.push(i),n=l+o.length)}return n<e.length&&r.push(e.slice(n)),t.jsx(t.Fragment,{children:r.length>0?r:e})}var rl=c.memo(function({text:r,scrollRootRef:n,streaming:a=!1,containerClassName:s="",plainTextClassName:o="thread-graph-plain-text whitespace-pre-wrap break-words text-[15px] leading-6",markdownClassName:l="thread-graph-markdown",onBeforeResize:i,onOpenWorkspaceFile:d}){const h=c.useRef(null),u=c.useRef(null),[m,f]=c.useState(!1),p=np(r),g=!a&&r.length>ps,b=g&&!m?`${r.slice(0,ps).trimEnd()}
|
|
3607
3614
|
|
|
3608
|
-
...`:r,[v,x]=c.useState(a||typeof IntersectionObserver>"u"),y=c.useCallback(()=>{const k=n.current,
|
|
3615
|
+
...`:r,[v,x]=c.useState(a||typeof IntersectionObserver>"u"),y=c.useCallback(()=>{const k=n.current,N=h.current,w=(N==null?void 0:N.getBoundingClientRect().top)??null;i==null||i(),u.current=k&&w!==null?{root:k,top:w}:null,f(j=>!j)},[i,n]);return c.useLayoutEffect(()=>{const k=u.current,N=h.current;if(!k||!N)return;u.current=null;const w=()=>{const C=N.getBoundingClientRect().top;k.root.scrollTop+=C-k.top};w();const j=window.requestAnimationFrame(w);return()=>{window.cancelAnimationFrame(j)}},[m]),c.useEffect(()=>{if(a||typeof IntersectionObserver>"u"){x(!0);return}if(v||!h.current)return;const k=new IntersectionObserver(N=>{for(const w of N)if(w.isIntersecting){x(!0),k.disconnect();break}},{root:n.current,threshold:0});return k.observe(h.current),()=>{k.disconnect()}},[v,n,a]),t.jsxs("div",{ref:h,className:s,children:[v&&p?t.jsx(mp,{content:b,className:l,onOpenWorkspaceFile:d}):t.jsx("p",{className:o,children:t.jsx(Jt,{text:b})}),g?t.jsx("button",{type:"button",onClick:y,className:"thread-graph-show-more timeline-meta-text mt-1.5 flex w-full items-center justify-center rounded-md border border-[var(--theme-border)] px-2 py-0.5 text-[10px] leading-4 transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)]",children:m?"Show less":`Show more (${r.length.toLocaleString()} chars)`}):null]})}),bp=c.memo(function({text:r,scrollRootRef:n,streaming:a=!1,onBeforeResize:s,onOpenWorkspaceFile:o}){return t.jsx(rl,{text:r,scrollRootRef:n,streaming:a,containerClassName:"thread-graph-message-prose",...s?{onBeforeResize:s}:{},...o?{onOpenWorkspaceFile:o}:{}})}),vp=c.memo(function({threadId:r,text:n,attachmentPreviewUrls:a,getImageAssetUrl:s}){const o=c.useMemo(()=>xp(n),[n]);return t.jsx("div",{className:"thread-graph-message-prose whitespace-pre-wrap break-words text-[15px] leading-6",children:o.map(l=>{if(l.type==="text")return t.jsx("span",{children:l.text},l.key);if(l.type==="photo"){const d=(a==null?void 0:a[l.path])??(r?(s==null?void 0:s({threadId:r,path:l.path}))??null:null),h=fs(l.path)||"Attached image";return t.jsx("span",{className:"mx-[0.14rem] inline-flex align-middle",children:t.jsxs("span",{className:"inline-flex max-w-full flex-col rounded-[1rem] border border-sky-300/28 bg-sky-300/[0.08] p-1.5 shadow-sm shadow-stone-950/20",children:[d?t.jsx("img",{src:d,alt:h,className:"h-[4.5rem] w-[6rem] rounded-[0.75rem] bg-stone-950 object-contain",loading:"lazy"}):t.jsx("span",{className:"inline-flex h-[4.5rem] w-[6rem] items-center justify-center rounded-[0.75rem] bg-stone-950 text-[10px] text-sky-100",children:"PHOTO"}),t.jsx("span",{className:"mt-1 max-w-[7rem] truncate text-[10px] font-medium tracking-[0.08em] text-sky-50",title:l.path,children:h})]})},l.key)}const i=fs(l.path)||"Attached file";return t.jsx("span",{className:"mx-[0.14rem] inline-flex align-middle",children:t.jsxs("span",{className:"inline-flex max-w-[12rem] items-center gap-2 rounded-[0.95rem] border border-emerald-300/28 bg-emerald-300/[0.08] px-2.5 py-2 text-[10px] font-medium tracking-[0.08em] text-emerald-50 shadow-sm shadow-stone-950/20",title:l.path,children:[t.jsx("span",{className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-emerald-200/20 bg-emerald-300/12 text-[9px]",children:"FILE"}),t.jsx("span",{className:"min-w-0 truncate",children:i})]})},l.key)})})});function kp(){return t.jsx("span",{className:"ml-1.5 inline-flex items-center gap-1","aria-hidden":"true",children:[0,1,2].map(e=>t.jsx("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-sky-200/90",style:{animationDelay:`${e*180}ms`}},e))})}function gs({status:e}){if(!e)return null;const r=e.toLowerCase(),n=r.includes("running")||r.includes("generating")||r.includes("steering"),a=r.includes("failed")||r.includes("error"),s=r.includes("accepted")||r.includes("complete"),o=n?"ui-status-warning":a?"ui-status-danger":s?"ui-status-success":"ui-status-neutral",l=n?t.jsx(G.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):a?t.jsx(G.XCircle,{className:"h-3.5 w-3.5"}):s?t.jsx(G.CheckCircle2,{className:"h-3.5 w-3.5"}):t.jsx(G.Circle,{className:"h-3.5 w-3.5"});return t.jsxs("span",{className:`thread-graph-message-status inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs font-normal ${o}`,title:e,"aria-label":`Status: ${e}`,children:[t.jsx("span",{className:"thread-graph-message-status-icon inline-flex shrink-0",children:n?t.jsx(kp,{}):l}),t.jsx("span",{className:"thread-graph-status-label",children:e})]})}function wp({children:e,copyButton:r,kind:n,metaControl:a,reasoning:s,status:o,timeLabel:l,timeTitle:i}){const d=n==="userMessage",h=l?t.jsx("time",{dateTime:i??void 0,title:i??void 0,className:"thread-graph-message-time text-[10px] leading-none sm:text-[11px]",children:l}):null;return t.jsx("div",{"data-testid":"chat-message","data-role":d?"user":"assistant",className:"thread-graph-message flex justify-start",children:t.jsxs("div",{className:`thread-graph-message-bubble min-w-0 w-full max-w-full ${d?"is-user":"is-assistant"}`,children:[d?null:t.jsxs("div",{className:"thread-graph-message-header mb-2 flex min-w-0 items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"thread-graph-message-sender rounded-full px-2.5 py-1 text-xs font-semibold tracking-[0.02em]",children:"Assistant"}),t.jsx(gs,{status:o??"Complete"})]}),a?t.jsx("div",{className:"thread-graph-message-header-meta flex min-w-0 flex-1 justify-center",children:a}):null,r||h?t.jsxs("div",{className:"thread-graph-message-header-actions flex shrink-0 items-center gap-1.5 sm:gap-2",children:[r,h]}):null]}),s,t.jsx("div",{className:`thread-graph-message-content min-w-0 ${d?"is-user":"is-assistant"}`,children:e}),d&&(o||h)?t.jsxs("div",{className:"mt-1 flex items-center justify-end gap-2",children:[o?t.jsx(gs,{status:o}):null,h]}):null]})})}xr();function yp(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function jp({tone:e="amber"}){const r=e==="sky"?"bg-sky-300/90":"bg-amber-200/90";return t.jsx("span",{className:"ml-1.5 inline-flex items-center gap-1","aria-hidden":"true",children:[0,1,2].map(n=>t.jsx("span",{className:`h-1.5 w-1.5 animate-pulse rounded-full ${r}`,style:{animationDelay:`${n*180}ms`}},n))})}var At=c.memo(function({threadId:r,item:n,scrollRootRef:a,streaming:s=!1,adapter:o,timeLabel:l,timeTitle:i,onBeforeMessageResize:d}){const[h,u]=c.useState("idle"),[m,f]=c.useState(!1),p=c.useRef(null),g=n.kind==="agentMessage"?n.reasoningItems??[]:[],b=g.map(C=>C.text.trim()).filter(Boolean).join(`
|
|
3609
3616
|
|
|
3610
|
-
`),v=n.kind==="userMessage"&&(n.status==="Steering"||n.status==="Accepted"||n.status==="Awaiting response");c.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current)},[]);async function x(){try{await navigator.clipboard.writeText(n.text),u("copied"),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>u("idle"),1200)}catch{u("failed"),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>u("idle"),1600)}}const y=n.kind==="agentMessage"?t.jsx("button",{type:"button","aria-label":"Copy agent reply",title:h==="copied"?"Copied":h==="failed"?"Copy failed":"Copy agent reply",onClick:()=>void x(),className:`thread-graph-message-copy inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border transition ${h==="copied"?"ui-status-info":h==="failed"?"ui-status-danger":""}`,children:t.jsx(G.Copy,{className:"h-3.5 w-3.5"})}):null,k=n.kind==="agentMessage"&&b?t.jsx("div",{className:"thread-graph-message-thinking mb-3 mt-2",children:t.jsx(pr,{type:"single",collapsible:!0,className:"thread-graph-thinking-accordion w-full border-none",onValueChange:j=>f(!!j),...m?{value:"thoughts"}:{},children:t.jsxs(fr,{value:"thoughts",className:"border-b-0",children:[t.jsx(gr,{className:"thread-graph-thinking-trigger py-2 hover:no-underline",children:t.jsxs("div",{className:"thread-graph-thinking-label flex items-center gap-2 text-sm font-medium transition-colors",children:[t.jsx(G.Brain,{className:`h-4 w-4 ${g.some(j=>gn(j.status))?"animate-pulse":""}`}),t.jsx("span",{children:g.some(j=>gn(j.status))?"Thinking...":"Thought Process"}),g.some(j=>gn(j.status))?t.jsx(jp,{tone:"sky"}):null]})}),t.jsx(xr,{className:"thread-graph-thinking-content pb-0",children:t.jsx("pre",{className:"thread-graph-thinking-body my-1 max-h-56 overflow-auto whitespace-pre-wrap break-words rounded-xl border p-3 text-[12px] leading-5",children:t.jsx(Jt,{text:b})})})]})})}):null;return t.jsx(yp,{kind:n.kind,status:v||n.kind==="agentMessage"?n.status:null,copyButton:y,reasoning:k,timeLabel:l,timeTitle:i,children:n.kind==="agentMessage"?t.jsx(vp,{text:n.text,scrollRootRef:a,streaming:s,...d?{onBeforeResize:d}:{},...o!=null&&o.onOpenWorkspaceFile?{onOpenWorkspaceFile:o.onOpenWorkspaceFile}:{}}):t.jsx(kp,{threadId:r,text:n.text,attachmentPreviewUrls:n.attachmentPreviewUrls,getImageAssetUrl:o==null?void 0:o.getImageAssetUrl})})});function bs(e){return e.replace(/"/g,'"').replace(/'/g,"'").replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&")}function al(e){const r=e.trim().match(/^<hook_prompt(?:\s+hook_run_id="([^"]+)")?>([\s\S]*)<\/hook_prompt>$/);if(!r)return null;const n=r[1]?bs(r[1]):null,a=bs(r[2]??"").trim(),s=(n==null?void 0:n.split(":")[0])??"hook",o=s==="stop"?"Stop":s,l=(n==null?void 0:n.split(":").slice(2).join(":"))||null;return{id:`live-hook-prompt:${n??"unknown"}`,kind:"hook",text:`${o} hook`,previewText:a||`${o} hook`,detailText:a||null,status:"Completed",hookEventName:s,hookEventLabel:o,hookHandlerType:"command",hookScope:"turn",hookSource:l?"project":null,hookSourcePath:l,hookStatusMessage:null,hookOutputEntries:a?[{kind:"warning",text:a}]:[]}}function Np(e){return e==="userMessage"||e==="agentMessage"}function Cp(e){return e==="commandExecution"||e==="webSearch"||e==="fileRead"||e==="fileChange"||e==="image"||e==="contextCompaction"}function Sp(e){return e==="agentMessage"||e==="reasoning"||e==="agentToolCall"||e==="skillToolCall"||e==="toolCall"||e==="plan"}function Tp(e,r){if(!r)return e;const n=[...e],a=n.findIndex(o=>o.kind==="userMessage");if(a<0)return n;for(let o=a+1;o<n.length;o+=1){const l=n[o];if(!l||l.kind!=="userMessage")continue;let i=o+1;for(;i<n.length&&Cp(n[i].kind);)i+=1;if(i===o+1)continue;const[d]=n.splice(o,1);n.splice(i-1,0,d),o=i-1}let s=!1;return n.map((o,l)=>o.kind!=="userMessage"?o:s?n.slice(l+1).some(d=>Sp(d.kind))?o:{...o,status:"Awaiting response"}:(s=!0,o))}function kt(e){return typeof e.sequence=="number"&&Number.isFinite(e.sequence)}function Nr(e){return kt(e)?e.sequence:Number.POSITIVE_INFINITY}function vs(e){var h;const r=[];let n=0;for(;n<e.length&&((h=e[n])==null?void 0:h.kind)==="userMessage"&&!kt(e[n]);)r.push(e[n]),n+=1;const a=e.slice(n);if(!a.some(kt))return e;const s=a.map(u=>Nr(u)).filter(Number.isFinite),o=s.length>0?Math.max(...s):0,l=[];let i=0;for(;i<a.length;){const u=a[i];if(kt(u)){l.push({item:u,index:i,order:Nr(u)}),i+=1;continue}const m=i;for(;i<a.length&&!kt(a[i]);)i+=1;const f=a.slice(m,i),p=[...a.slice(0,m)].reverse().find(kt),g=a.slice(i).find(kt),b=p?Nr(p):null,v=g?Nr(g):null;f.forEach((x,y)=>{let k;if(b===null&&v!==null)k=v-(f.length-y)/(f.length+1);else if(b!==null&&v!==null&&v>b){const j=v-b;k=b+(y+1)/(f.length+1)*j}else k=o+1+y/(f.length+1);l.push({item:x,index:m+y,order:k})})}const d=l.sort((u,m)=>{const f=u.order-m.order;return f===0?u.index-m.index:f}).map(u=>u.item);return[...r,...d]}function Ep(e,r){if(!r||r.length===0)return vs(e);const n=new Map(r.map(o=>[o.id,o])),a=e.map(o=>{const l=n.get(o.id);if(!l)return o;n.delete(o.id);const i={...o,...l,text:l.text||o.text},d=l.detailText??o.detailText,h=l.previewText??o.previewText,u=l.status??o.status,m=l.sequence??o.sequence;return d!==void 0&&(i.detailText=d),h!==void 0&&(i.previewText=h),u!==void 0&&(i.status=u),m!==void 0&&(i.sequence=m),i}),s=[...n.values()];return s.length===0&&!a.some(kt)||(a.push(...s),!a.some(o=>typeof o.sequence=="number"&&Number.isFinite(o.sequence)))?a:vs(a)}function Lp(e,r){if(!e)return"";const n=r.filter(d=>d.kind==="agentMessage").map(d=>d.text).filter(d=>d.length>0),a=n.at(-1)??"";if(a){const d=e.lastIndexOf(a);if(d>=0){const h=e.slice(d+a.length);return h.trim()?h:""}}const s=n.join("");if(!s)return e;const o=Math.min(e.length,s.length);let l=0;for(;l<o&&e[l]===s[l];)l+=1;if(l===0)return e;const i=e.slice(l);return i.trim()?i:""}function sl(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function $r(e){return e==="inProgress"||e==="sending"}function Pp(e){var d,h;const r=[];let n=0;const a=new Set,s=[];function o(){const u=r.at(-1);return(u==null?void 0:u.kind)!=="item"||u.item.kind!=="agentMessage"?null:u}function l(u,m){if(m.length!==0){u.item={...u.item,reasoningItems:[...u.item.reasoningItems??[],...m]};for(const f of m)a.add(f.id)}}function i(){const u=s.splice(0);for(const m of u)r.push({kind:"item",key:m.id,item:m})}for(;n<e.length;){const u=e[n];if(!u)break;if(a.has(u.id)){n+=1;continue}if(u.kind==="reasoning"){let p=n;const g=[];for(;p<e.length&&((d=e[p])==null?void 0:d.kind)==="reasoning";)g.push(e[p]),p+=1;const b=o();b?l(b,g):s.push(...g),n=p;continue}if(u.kind==="agentMessage"){const p=s.splice(0),g={kind:"item",key:u.id,item:u};l(g,p),r.push(g),n+=1;continue}if(u.kind!=="commandExecution"&&u.kind!=="fileChange"&&u.kind!=="webSearch"&&u.kind!=="fileRead"){r.push({kind:"item",key:u.id,item:u}),n+=1;continue}const m=[];for(;n<e.length&&((h=e[n])==null?void 0:h.kind)===u.kind;)m.push(e[n]),n+=1;if(m.length===1){r.push({kind:"item",key:m[0].id,item:m[0]});continue}const f=m.map(p=>p.id).join(":");if(u.kind==="commandExecution"){r.push({kind:"commandGroup",key:f,items:m});continue}if(u.kind==="fileChange"){r.push({kind:"fileChangeGroup",key:f,items:m});continue}if(u.kind==="fileRead"){r.push({kind:"fileReadGroup",key:f,items:m});continue}r.push({kind:"searchGroup",key:f,items:m})}return i(),r}function ol(e,r){return[...e.map(n=>({id:n.id,startedAt:n.startedAt??""})),...r?[{id:r.id,startedAt:r.startedAt??""}]:[]]}function dr(e,r,n){const a=e.get(r)??[];a.push(n),e.set(r,a)}function ll(e,r){return e.find(n=>r&&n.startedAt&&r.localeCompare(n.startedAt)<=0)}function zp({answeredRequestNotes:e,pendingRequests:r,visibleTurns:n,optimisticTurn:a}){const s=new Set(n.map(p=>p.id)),o=new Map,l=new Map,i=[],d=[];for(const p of e)p.turnId&&s.has(p.turnId)?dr(o,p.turnId,p):i.push(p);for(const p of r)p.turnId&&s.has(p.turnId)?dr(l,p.turnId,p):d.push(p);const h=ol(n,a),u=new Map,m=[],f=[...i.map(p=>({kind:"note",id:p.id,createdAt:p.createdAt??"",note:p})),...d.map(p=>({kind:"request",id:p.id,createdAt:p.createdAt,request:p}))].sort((p,g)=>p.createdAt.localeCompare(g.createdAt));for(const p of f){const g=ll(h,p.createdAt);if(!g){m.push(p);continue}dr(u,g.id,p)}return{notesByTurnId:o,pendingRequestsByTurnId:l,beforeTurnId:u,trailing:m}}function Ip({activityNotes:e,visibleTurns:r,optimisticTurn:n}){const a=[...e].sort((m,f)=>m.createdAt.localeCompare(f.createdAt)),s=ol(r,n),o=[],l=new Map,i=new Map,d=[],u=s.map(m=>m.startedAt).filter(m=>!!m).sort().at(-1)??null;for(const m of a){if(m.anchorTurnId==="__leading__"){o.push(m);continue}if(m.anchorTurnId){s.some(p=>p.id===m.anchorTurnId)?dr(i,m.anchorTurnId,m):o.push(m);continue}const f=ll(s,m.createdAt);if(!f){!u||m.createdAt.localeCompare(u)<=0?o.push(m):d.push(m);continue}dr(l,f.id,m)}return{leading:o,beforeTurnId:l,afterTurnId:i,trailing:d}}function il({request:e,busy:r=!1,onRespond:n}){const[a,s]=c.useState({}),[o,l]=c.useState({}),[i,d]=c.useState(null),h=e.questions[0]??null,u="__other__",m=e.kind==="planDecision"?"Plan":e.kind==="requestUserInput"?"Answer Required":e.title;function f(x){const y=/\s*\(recommended\)\s*$/i.test(x);return{rawLabel:x,displayLabel:x.replace(/\s*\(recommended\)\s*$/i,"").trim(),recommended:y}}function p(x){h&&(d(x),n==null||n(e.id,{answers:{[h.id]:{answers:[x]}}}))}function g(x){const y=a[x.id]??"";return Array.isArray(y)?y.map(k=>k===u?(o[x.id]??"").trim():k.trim()).filter(Boolean).join(", "):y===u?(o[x.id]??"").trim():y.trim()}function b(x){const y=a[x.id]??"";if(Array.isArray(y))return y.map(j=>j===u?(o[x.id]??"").trim():j.trim()).filter(Boolean);if(y===u){const j=(o[x.id]??"").trim();return j?[j]:[]}const k=y.trim();return k?[k]:[]}function v(x,y){s(k=>{const j=k[x],w=Array.isArray(j)?j:[],N=w.includes(y)?w.filter(S=>S!==y):[...w,y];return{...k,[x]:N}})}return t.jsxs("div",{className:"timeline-pending-card w-full rounded-[1rem] border px-3 py-3 sm:rounded-[1.2rem] sm:px-4",children:[t.jsx("div",{className:"flex items-center justify-between gap-3",children:t.jsxs("div",{children:[t.jsx("p",{className:"timeline-primary-text text-sm font-medium",children:m}),e.kind!=="planDecision"&&e.description&&t.jsx("p",{className:"timeline-soft-text mt-1 text-[13px] leading-5",children:e.description})]})}),t.jsx("div",{className:"mt-3 space-y-3",children:e.questions.map(x=>t.jsxs("div",{className:"timeline-question-section rounded-xl border p-2.5 sm:p-3",children:[t.jsx("p",{className:"timeline-meta-text text-xs uppercase tracking-[0.2em]",children:x.header}),t.jsx("p",{className:"timeline-primary-text mt-1 text-[13px] leading-5 sm:text-sm",children:x.question}),e.kind==="planDecision"&&x.options&&x.options.length>0?t.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:x.options.map((y,k)=>{const j=f(y.label),w=j.displayLabel.toLowerCase()==="implement";return t.jsxs("button",{type:"button",disabled:r,onClick:()=>p(y.label),className:`relative rounded-2xl border px-2.5 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${k===0?"ui-action-info":"border-stone-700 text-stone-200 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:y.description,children:[j.recommended?t.jsx("span",{"aria-hidden":"true",className:"absolute right-1.5 top-1 inline-flex h-3.5 w-3.5 items-center justify-center rounded-full bg-white/18 text-[10px] leading-none text-current",children:"✦"}):null,r&&i===y.label?w?"Starting...":"Saving...":j.displayLabel]},y.label)})}):x.options&&x.options.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[x.options.map(y=>{const k=f(y.label),j=a[x.id];return t.jsxs("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?v(x.id,y.label):s(w=>({...w,[x.id]:y.label})),className:`relative rounded-2xl border px-3 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${(x.multiSelect?Array.isArray(j)&&j.includes(y.label):j===y.label)?"ui-status-warning":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:y.description,children:[k.recommended?t.jsx("span",{"aria-hidden":"true",className:"absolute right-1.5 top-1 inline-flex h-3.5 w-3.5 items-center justify-center rounded-full bg-white/10 text-[10px] leading-none text-amber-100/90",children:"✦"}):null,k.displayLabel]},y.label)}),x.isOther&&(()=>{const y=a[x.id];return t.jsx("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?v(x.id,u):s(k=>({...k,[x.id]:u})),className:`rounded-2xl border px-3 py-1.5 text-[12px] leading-4 transition sm:text-[13px] ${(x.multiSelect?Array.isArray(y)&&y.includes(u):y===u)?"ui-status-info":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Not from above"})})()]}),x.isOther&&(()=>{const y=a[x.id];return(x.multiSelect?Array.isArray(y)&&y.includes(u):y===u)?t.jsx("input",{"aria-label":`${x.header} custom answer`,value:o[x.id]??"",onChange:j=>l(w=>({...w,[x.id]:j.target.value})),placeholder:"Enter a custom answer",className:"mt-3 w-full rounded-xl border border-stone-700 bg-stone-900 px-3 py-2 text-sm text-stone-100 outline-none transition focus:border-sky-300"}):null})()]}):t.jsx("input",{"aria-label":x.header,value:a[x.id]??"",onChange:y=>s(k=>({...k,[x.id]:y.target.value})),className:"mt-3 w-full rounded-xl border border-stone-700 bg-stone-900 px-3 py-2 text-sm text-stone-100 outline-none transition focus:border-amber-300"})]},x.id))}),e.kind!=="planDecision"&&t.jsx("div",{className:"mt-3 flex justify-end",children:t.jsx("button",{type:"button",disabled:r||e.questions.some(x=>!g(x)),onClick:()=>void(n==null?void 0:n(e.id,{answers:Object.fromEntries(e.questions.map(x=>[x.id,{answers:b(x)}]))})),className:"ui-action-info rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:r?"Submitting...":"Submit"})})]})}function dl({note:e}){return t.jsxs("div",{className:"timeline-note-card w-full rounded-2xl border px-3 py-2.5",children:[t.jsx("p",{className:"timeline-meta-text text-[11px] uppercase tracking-[0.2em]",children:e.title}),t.jsx("div",{className:"mt-1 space-y-1",children:e.summaryLines.map((r,n)=>t.jsxs("p",{className:"timeline-primary-text text-[13px] leading-5",children:["You selected ",r]},`${e.id}-${n}`))})]})}function cl({note:e,onOpenThread:r,onOpenLinkedThread:n}){const a=e.kind==="forkCreated"?"Fork":e.kind==="forkSource"?"Fork source":"System",s=e.kind==="forkCreated"?`Thread forked from Turn ${e.turnIndex??"?"}`:e.kind==="forkSource"?`Forked from ${e.linkedThreadTitle??"source thread"} at Turn ${e.turnIndex??"?"}`:e.text??"";return t.jsxs("div",{className:"timeline-activity-card w-full rounded-2xl border px-3 py-2.5",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("p",{className:"timeline-meta-text text-[11px] uppercase tracking-[0.2em]",children:a}),t.jsx("time",{dateTime:e.createdAt,title:Zt(e.createdAt),className:"timeline-meta-text text-[10px]",children:Mt(e.createdAt)})]}),t.jsx("p",{className:"timeline-primary-text mt-1 text-[13px] leading-5",children:s}),e.linkedThreadId?t.jsx("button",{type:"button",onClick:()=>{const o=e.linkedThreadId;o&&(n==null||n(o),r==null||r(o))},className:"relative z-10 mt-2 inline-flex cursor-pointer rounded-full border border-amber-300/30 px-3 py-1.5 text-xs text-amber-100 transition hover:bg-amber-300/10",children:e.kind==="forkCreated"?"Open fork":"Back to source"}):null]})}function ar({notes:e,onOpenThread:r,onOpenLinkedThread:n}){return e.length===0?null:t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:e.map(a=>t.jsx(cl,{note:a,onOpenThread:r,onOpenLinkedThread:n},a.id))})}function Hn({entries:e,respondingRequestId:r,onRespondToRequest:n}){return e.length===0?null:t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:e.map(a=>a.kind==="note"?t.jsx(dl,{note:a.note},a.id):t.jsx(il,{request:a.request,busy:r===a.request.id,onRespond:n},a.id))})}function Rp({notes:e,requests:r,respondingRequestId:n,onRespondToRequest:a}){const s=[...e.map(o=>({kind:"note",id:o.id,createdAt:o.createdAt??"",note:o})),...r.map(o=>({kind:"request",id:o.id,createdAt:o.createdAt,request:o}))].sort((o,l)=>o.createdAt.localeCompare(l.createdAt));return t.jsx(Hn,{entries:s,respondingRequestId:n,onRespondToRequest:a})}function Mp({entries:e,respondingRequestId:r,onRespondToRequest:n,onOpenThread:a,onOpenLinkedThread:s}){return e.length===0?null:t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:[...e].sort((o,l)=>o.createdAt.localeCompare(l.createdAt)).map(o=>o.kind==="activity"?t.jsx(cl,{note:o.note,onOpenThread:a,onOpenLinkedThread:s},o.id):o.kind==="note"?t.jsx(dl,{note:o.note},o.id):t.jsx(il,{request:o.request,busy:r===o.request.id,onRespond:n},o.id))})}function _p({entries:e,expandedGroups:r,onToggleGroupedItem:n,renderCommandGroup:a,renderFileChangeGroup:s,renderFileReadGroup:o,renderItem:l,renderSearchGroup:i}){return t.jsx(t.Fragment,{children:e.map(d=>{const h=r[d.key]??!1,u=()=>n(d.key);return d.kind==="commandGroup"?a(d,h,u):d.kind==="fileChangeGroup"?s(d,h,u):d.kind==="searchGroup"?i(d,h,u):d.kind==="fileReadGroup"?o(d,h,u):l(d)})})}function Vr({children:e,className:r,count:n,countBadgeClassName:a,desktopIconClassName:s,expanded:o,expandedListClassName:l,icon:i,onToggleExpanded:d,runningIndicator:h,summary:u,toggleAriaLabel:m,trailingSummary:f}){return t.jsx("div",{className:`thread-graph-history-group ${r} relative min-w-0 w-full overflow-hidden rounded-[0.9rem] border px-3 py-2.5`,children:t.jsxs("div",{className:"flex items-start gap-2.5",children:[t.jsxs("div",{className:"thread-graph-history-group-icon mt-0.5 flex shrink-0 items-center",children:[t.jsxs("span",{className:`relative inline-flex h-8 w-8 items-center justify-center rounded-[0.9rem] border shadow-sm shadow-stone-950/20 ${s}`,children:[i,t.jsx("span",{className:`absolute -right-1 -top-1 inline-flex min-w-[1.1rem] items-center justify-center rounded-full border bg-stone-950/90 px-1 text-[9px] font-semibold leading-4 ${a}`,children:n})]}),h]}),t.jsxs("div",{className:"thread-graph-history-group-card min-w-0 flex-1 rounded-[0.85rem] border px-3 py-2",children:[t.jsxs("button",{type:"button","aria-expanded":o,"aria-label":m,onClick:d,className:"thread-graph-history-group-toggle flex w-full min-w-0 items-center justify-between gap-3 text-left",children:[t.jsx("div",{className:"thread-graph-history-group-summary min-w-0 flex flex-1 flex-wrap items-center gap-2 pr-1",children:u}),f]}),o?t.jsx("div",{className:`thread-graph-history-group-list mt-3 space-y-2 border-t pt-3 ${l}`,children:e}):null]})]})})}br();Nt();var Ap=mr("inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden whitespace-nowrap rounded-md border px-2 py-0.5 text-xs font-medium outline-none transition-[color,box-shadow] focus-visible:ring-[3px] [&>svg]:pointer-events-none [&>svg]:size-3",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-white",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Kr({asChild:e=!1,className:r,variant:n,...a}){const s=e?zs:"span";return t.jsx(s,{"data-slot":"badge",className:et(Ap({variant:n,className:r})),...a})}function qr(e){if(!e)return!1;const r=e.trim().toLowerCase();return r==="running"||r==="in_progress"||r==="in progress"||r==="pending"}function $p(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5 2.75h4l2 2v6.5a1.5 1.5 0 0 1-1.5 1.5h-4A1.5 1.5 0 0 1 4 11.25v-7A1.5 1.5 0 0 1 5.5 2.75Z"}),t.jsx("path",{d:"M9 2.75v2h2"}),t.jsx("path",{d:"M6.2 8h3.6"}),t.jsx("path",{d:"M6.2 10h1.7"})]})}function Dp(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5 2.75h4l2 2v6.5a1.5 1.5 0 0 1-1.5 1.5h-4A1.5 1.5 0 0 1 4 11.25v-7A1.5 1.5 0 0 1 5.5 2.75Z"}),t.jsx("path",{d:"M9 2.75v2h2"}),t.jsx("path",{d:"M6.15 7.25h3.7"}),t.jsx("path",{d:"M6.15 9.25h2.8"}),t.jsx("path",{d:"m10.4 10.7 1.2 1.2"}),t.jsx("circle",{cx:"9.25",cy:"9.55",r:"1.45"})]})}function Bp(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"2.75",y:"3",width:"8.5",height:"3",rx:"1.1"}),t.jsx("rect",{x:"4.25",y:"6.5",width:"8.5",height:"3",rx:"1.1"}),t.jsx("rect",{x:"5.75",y:"10",width:"7.5",height:"3",rx:"1.1"}),t.jsx("path",{d:"m6.25 4.5 1 1-1 1"}),t.jsx("path",{d:"M7.9 5.5h1.7"}),t.jsx("path",{d:"m7.75 8 1 1-1 1"}),t.jsx("path",{d:"M9.4 9h1.7"})]})}function Gp(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"6",cy:"6",r:"2.3"}),t.jsx("path",{d:"m8 8 1.6 1.6"}),t.jsx("circle",{cx:"9.3",cy:"8.8",r:"2"}),t.jsx("path",{d:"m10.75 10.25 1.65 1.65"}),t.jsx("circle",{cx:"11.2",cy:"4.75",r:"1.8"}),t.jsx("path",{d:"m12.45 6 1.1 1.1"})]})}function Fp(e){const r=e.trim();if(!r)return"";const n=r.match(/(, \+\d+ more.*)$/),a=(n==null?void 0:n[1])??"",o=(a?r.slice(0,-a.length):r).replace(/\\/g,"/");if(!o.startsWith("/"))return`${o.replace(/^\.\//,"")}${a}`;const l=["/apps/","/packages/","/src/","/test/","/tests/","/docs/","/config/","/scripts/","/e2e/","/.agents/","/.codex/"];for(const i of l){const d=o.indexOf(i);if(d>=0)return`${o.slice(d+1)}${a}`}return r}function hl(e,r=42){const n=Fp(e);if(!n)return"";const a=n.match(/(, \+\d+ more.*)$/),s=(a==null?void 0:a[1])??"",o=s?n.slice(0,-s.length):n;if(o.length<=r)return`${o}${s}`;const i=o.replace(/\\/g,"/").split("/").filter(Boolean);if(i.length>1){const d=[];let h=s.length+4;for(let u=i.length-1;u>=0;u-=1){const m=i[u],f=h+m.length+(d.length>0?1:0);if(d.length>0&&f>r)break;d.unshift(m),h=f}if(d.length>0)return`.../${d.join("/")}${s}`}return`...${o.slice(-(r-s.length-3))}${s}`}function Hp(e){var a;const r=[];if(typeof e.changedFiles=="number"&&e.changedFiles>0&&r.push(`${e.changedFiles} ${e.changedFiles===1?"file":"files"}`),typeof e.addedLines=="number"&&e.addedLines>0&&r.push(`+${e.addedLines}`),typeof e.removedLines=="number"&&e.removedLines>0&&r.push(`-${e.removedLines}`),r.length>0)return r;const n=(a=e.previewText)==null?void 0:a.trim();return n?n.replace(/\bfiles changed\b/gi,"files").replace(/\bfile changed\b/gi,"file").split("·").map(s=>s.trim()).filter(Boolean):[]}function On({tone:e="amber"}){const r=e==="emerald"?"bg-sky-200/90":e==="sky"?"bg-sky-300/90":"bg-amber-200/90";return t.jsx("span",{className:"ml-1.5 inline-flex items-center gap-1","aria-hidden":"true",children:[0,1,2].map(n=>t.jsx("span",{className:`h-1.5 w-1.5 animate-pulse rounded-full ${r}`,style:{animationDelay:`${n*180}ms`}},n))})}function Op(e){var n;const r=e.replace(/\r\n/g,`
|
|
3617
|
+
`),v=n.kind==="userMessage"&&(n.status==="Steering"||n.status==="Accepted"||n.status==="Awaiting response");c.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current)},[]);async function x(){try{await navigator.clipboard.writeText(n.text),u("copied"),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>u("idle"),1200)}catch{u("failed"),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>u("idle"),1600)}}function y(){d==null||d(),f(C=>!C)}const k=n.kind==="agentMessage"?t.jsx("button",{type:"button","aria-label":"Copy agent reply",title:h==="copied"?"Copied":h==="failed"?"Copy failed":"Copy agent reply",onClick:()=>void x(),className:`thread-graph-message-copy inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border transition ${h==="copied"?"ui-status-info":h==="failed"?"ui-status-danger":""}`,children:t.jsx(G.Copy,{className:"h-3.5 w-3.5"})}):null,N=g.some(C=>yp(C.status)),w=n.kind==="agentMessage"&&b?t.jsxs("button",{type:"button","aria-label":m?"Hide chain of thought":"Show chain of thought","aria-expanded":m,title:m?"Hide CoT":"Show CoT",onClick:y,className:`thread-graph-thinking-toggle inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border px-2 text-xs font-medium transition ${m?"is-open":""}`,children:[t.jsx(G.Brain,{className:`h-3.5 w-3.5 ${N?"animate-pulse":""}`}),t.jsx("span",{children:"CoT"}),N?t.jsx(jp,{tone:"sky"}):null]}):null,j=n.kind==="agentMessage"&&b?t.jsx("div",{className:"thread-graph-message-thinking mb-3",children:t.jsx(pr,{type:"single",collapsible:!0,className:"thread-graph-thinking-accordion w-full border-none",onValueChange:C=>f(!!C),...m?{value:"thoughts"}:{},children:t.jsx(fr,{value:"thoughts",className:"border-b-0",children:t.jsx(gr,{className:"thread-graph-thinking-content pb-0",children:t.jsx("pre",{className:"thread-graph-thinking-body my-1 max-h-56 overflow-auto whitespace-pre-wrap break-words rounded-xl border p-3 text-[12px] leading-5",children:t.jsx(Jt,{text:b})})})})})}):null;return t.jsx(wp,{kind:n.kind,status:v||n.kind==="agentMessage"?n.status:null,copyButton:k,metaControl:w,reasoning:j,timeLabel:l,timeTitle:i,children:n.kind==="agentMessage"?t.jsx(bp,{text:n.text,scrollRootRef:a,streaming:s,...d?{onBeforeResize:d}:{},...o!=null&&o.onOpenWorkspaceFile?{onOpenWorkspaceFile:o.onOpenWorkspaceFile}:{}}):t.jsx(vp,{threadId:r,text:n.text,attachmentPreviewUrls:n.attachmentPreviewUrls,getImageAssetUrl:o==null?void 0:o.getImageAssetUrl})})});function xs(e){return e.replace(/"/g,'"').replace(/'/g,"'").replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&")}function nl(e){const r=e.trim().match(/^<hook_prompt(?:\s+hook_run_id="([^"]+)")?>([\s\S]*)<\/hook_prompt>$/);if(!r)return null;const n=r[1]?xs(r[1]):null,a=xs(r[2]??"").trim(),s=(n==null?void 0:n.split(":")[0])??"hook",o=s==="stop"?"Stop":s,l=(n==null?void 0:n.split(":").slice(2).join(":"))||null;return{id:`live-hook-prompt:${n??"unknown"}`,kind:"hook",text:`${o} hook`,previewText:a||`${o} hook`,detailText:a||null,status:"Completed",hookEventName:s,hookEventLabel:o,hookHandlerType:"command",hookScope:"turn",hookSource:l?"project":null,hookSourcePath:l,hookStatusMessage:null,hookOutputEntries:a?[{kind:"warning",text:a}]:[]}}function Np(e){return e==="userMessage"||e==="agentMessage"}function Cp(e){return e==="commandExecution"||e==="webSearch"||e==="fileRead"||e==="fileChange"||e==="image"||e==="contextCompaction"}function Sp(e){return e==="agentMessage"||e==="reasoning"||e==="agentToolCall"||e==="skillToolCall"||e==="toolCall"||e==="plan"}function Tp(e,r){if(!r)return e;const n=[...e],a=n.findIndex(o=>o.kind==="userMessage");if(a<0)return n;for(let o=a+1;o<n.length;o+=1){const l=n[o];if(!l||l.kind!=="userMessage")continue;let i=o+1;for(;i<n.length&&Cp(n[i].kind);)i+=1;if(i===o+1)continue;const[d]=n.splice(o,1);n.splice(i-1,0,d),o=i-1}let s=!1;return n.map((o,l)=>o.kind!=="userMessage"?o:s?n.slice(l+1).some(d=>Sp(d.kind))?o:{...o,status:"Awaiting response"}:(s=!0,o))}function kt(e){return typeof e.sequence=="number"&&Number.isFinite(e.sequence)}function jr(e){return kt(e)?e.sequence:Number.POSITIVE_INFINITY}function bs(e){var h;const r=[];let n=0;for(;n<e.length&&((h=e[n])==null?void 0:h.kind)==="userMessage"&&!kt(e[n]);)r.push(e[n]),n+=1;const a=e.slice(n);if(!a.some(kt))return e;const s=a.map(u=>jr(u)).filter(Number.isFinite),o=s.length>0?Math.max(...s):0,l=[];let i=0;for(;i<a.length;){const u=a[i];if(kt(u)){l.push({item:u,index:i,order:jr(u)}),i+=1;continue}const m=i;for(;i<a.length&&!kt(a[i]);)i+=1;const f=a.slice(m,i),p=[...a.slice(0,m)].reverse().find(kt),g=a.slice(i).find(kt),b=p?jr(p):null,v=g?jr(g):null;f.forEach((x,y)=>{let k;if(b===null&&v!==null)k=v-(f.length-y)/(f.length+1);else if(b!==null&&v!==null&&v>b){const N=v-b;k=b+(y+1)/(f.length+1)*N}else k=o+1+y/(f.length+1);l.push({item:x,index:m+y,order:k})})}const d=l.sort((u,m)=>{const f=u.order-m.order;return f===0?u.index-m.index:f}).map(u=>u.item);return[...r,...d]}function Ep(e,r){if(!r||r.length===0)return bs(e);const n=new Map(r.map(o=>[o.id,o])),a=e.map(o=>{const l=n.get(o.id);if(!l)return o;n.delete(o.id);const i={...o,...l,text:l.text||o.text},d=l.detailText??o.detailText,h=l.previewText??o.previewText,u=l.status??o.status,m=l.sequence??o.sequence;return d!==void 0&&(i.detailText=d),h!==void 0&&(i.previewText=h),u!==void 0&&(i.status=u),m!==void 0&&(i.sequence=m),i}),s=[...n.values()];return s.length===0&&!a.some(kt)||(a.push(...s),!a.some(o=>typeof o.sequence=="number"&&Number.isFinite(o.sequence)))?a:bs(a)}function Lp(e,r){if(!e)return"";const n=r.filter(d=>d.kind==="agentMessage").map(d=>d.text).filter(d=>d.length>0),a=n.at(-1)??"";if(a){const d=e.lastIndexOf(a);if(d>=0){const h=e.slice(d+a.length);return h.trim()?h:""}}const s=n.join("");if(!s)return e;const o=Math.min(e.length,s.length);let l=0;for(;l<o&&e[l]===s[l];)l+=1;if(l===0)return e;const i=e.slice(l);return i.trim()?i:""}function al(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function Mr(e){return e==="inProgress"||e==="sending"}function Pp(e){var d,h;const r=[];let n=0;const a=new Set,s=[];function o(){const u=r.at(-1);return(u==null?void 0:u.kind)!=="item"||u.item.kind!=="agentMessage"?null:u}function l(u,m){if(m.length!==0){u.item={...u.item,reasoningItems:[...u.item.reasoningItems??[],...m]};for(const f of m)a.add(f.id)}}function i(){const u=s.splice(0);for(const m of u)r.push({kind:"item",key:m.id,item:m})}for(;n<e.length;){const u=e[n];if(!u)break;if(a.has(u.id)){n+=1;continue}if(u.kind==="reasoning"){let p=n;const g=[];for(;p<e.length&&((d=e[p])==null?void 0:d.kind)==="reasoning";)g.push(e[p]),p+=1;const b=o();b?l(b,g):s.push(...g),n=p;continue}if(u.kind==="agentMessage"){const p=s.splice(0),g={kind:"item",key:u.id,item:u};l(g,p),r.push(g),n+=1;continue}if(u.kind!=="commandExecution"&&u.kind!=="fileChange"&&u.kind!=="webSearch"&&u.kind!=="fileRead"){r.push({kind:"item",key:u.id,item:u}),n+=1;continue}const m=[];for(;n<e.length&&((h=e[n])==null?void 0:h.kind)===u.kind;)m.push(e[n]),n+=1;if(m.length===1){r.push({kind:"item",key:m[0].id,item:m[0]});continue}const f=m.map(p=>p.id).join(":");if(u.kind==="commandExecution"){r.push({kind:"commandGroup",key:f,items:m});continue}if(u.kind==="fileChange"){r.push({kind:"fileChangeGroup",key:f,items:m});continue}if(u.kind==="fileRead"){r.push({kind:"fileReadGroup",key:f,items:m});continue}r.push({kind:"searchGroup",key:f,items:m})}return i(),r}function sl(e,r){return[...e.map(n=>({id:n.id,startedAt:n.startedAt??""})),...r?[{id:r.id,startedAt:r.startedAt??""}]:[]]}function dr(e,r,n){const a=e.get(r)??[];a.push(n),e.set(r,a)}function ol(e,r){return e.find(n=>r&&n.startedAt&&r.localeCompare(n.startedAt)<=0)}function Ip({answeredRequestNotes:e,pendingRequests:r,visibleTurns:n,optimisticTurn:a}){const s=new Set(n.map(p=>p.id)),o=new Map,l=new Map,i=[],d=[];for(const p of e)p.turnId&&s.has(p.turnId)?dr(o,p.turnId,p):i.push(p);for(const p of r)p.turnId&&s.has(p.turnId)?dr(l,p.turnId,p):d.push(p);const h=sl(n,a),u=new Map,m=[],f=[...i.map(p=>({kind:"note",id:p.id,createdAt:p.createdAt??"",note:p})),...d.map(p=>({kind:"request",id:p.id,createdAt:p.createdAt,request:p}))].sort((p,g)=>p.createdAt.localeCompare(g.createdAt));for(const p of f){const g=ol(h,p.createdAt);if(!g){m.push(p);continue}dr(u,g.id,p)}return{notesByTurnId:o,pendingRequestsByTurnId:l,beforeTurnId:u,trailing:m}}function zp({activityNotes:e,visibleTurns:r,optimisticTurn:n}){const a=[...e].sort((m,f)=>m.createdAt.localeCompare(f.createdAt)),s=sl(r,n),o=[],l=new Map,i=new Map,d=[],u=s.map(m=>m.startedAt).filter(m=>!!m).sort().at(-1)??null;for(const m of a){if(m.anchorTurnId==="__leading__"){o.push(m);continue}if(m.anchorTurnId){s.some(p=>p.id===m.anchorTurnId)?dr(i,m.anchorTurnId,m):o.push(m);continue}const f=ol(s,m.createdAt);if(!f){!u||m.createdAt.localeCompare(u)<=0?o.push(m):d.push(m);continue}dr(l,f.id,m)}return{leading:o,beforeTurnId:l,afterTurnId:i,trailing:d}}function ll({request:e,busy:r=!1,onRespond:n}){const[a,s]=c.useState({}),[o,l]=c.useState({}),[i,d]=c.useState(null),h=e.questions[0]??null,u="__other__",m=e.kind==="planDecision"?"Plan":e.kind==="requestUserInput"?"Answer Required":e.title;function f(x){const y=/\s*\(recommended\)\s*$/i.test(x);return{rawLabel:x,displayLabel:x.replace(/\s*\(recommended\)\s*$/i,"").trim(),recommended:y}}function p(x){h&&(d(x),n==null||n(e.id,{answers:{[h.id]:{answers:[x]}}}))}function g(x){const y=a[x.id]??"";return Array.isArray(y)?y.map(k=>k===u?(o[x.id]??"").trim():k.trim()).filter(Boolean).join(", "):y===u?(o[x.id]??"").trim():y.trim()}function b(x){const y=a[x.id]??"";if(Array.isArray(y))return y.map(N=>N===u?(o[x.id]??"").trim():N.trim()).filter(Boolean);if(y===u){const N=(o[x.id]??"").trim();return N?[N]:[]}const k=y.trim();return k?[k]:[]}function v(x,y){s(k=>{const N=k[x],w=Array.isArray(N)?N:[],j=w.includes(y)?w.filter(C=>C!==y):[...w,y];return{...k,[x]:j}})}return t.jsxs("div",{className:"timeline-pending-card w-full rounded-[1rem] border px-3 py-3 sm:rounded-[1.2rem] sm:px-4",children:[t.jsx("div",{className:"flex items-center justify-between gap-3",children:t.jsxs("div",{children:[t.jsx("p",{className:"timeline-primary-text text-sm font-medium",children:m}),e.kind!=="planDecision"&&e.description&&t.jsx("p",{className:"timeline-soft-text mt-1 text-[13px] leading-5",children:e.description})]})}),t.jsx("div",{className:"mt-3 space-y-3",children:e.questions.map(x=>t.jsxs("div",{className:"timeline-question-section rounded-xl border p-2.5 sm:p-3",children:[t.jsx("p",{className:"timeline-meta-text text-xs uppercase tracking-[0.2em]",children:x.header}),t.jsx("p",{className:"timeline-primary-text mt-1 text-[13px] leading-5 sm:text-sm",children:x.question}),e.kind==="planDecision"&&x.options&&x.options.length>0?t.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:x.options.map((y,k)=>{const N=f(y.label),w=N.displayLabel.toLowerCase()==="implement";return t.jsxs("button",{type:"button",disabled:r,onClick:()=>p(y.label),className:`relative rounded-2xl border px-2.5 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${k===0?"ui-action-info":"border-stone-700 text-stone-200 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:y.description,children:[N.recommended?t.jsx("span",{"aria-hidden":"true",className:"absolute right-1.5 top-1 inline-flex h-3.5 w-3.5 items-center justify-center rounded-full bg-white/18 text-[10px] leading-none text-current",children:"✦"}):null,r&&i===y.label?w?"Starting...":"Saving...":N.displayLabel]},y.label)})}):x.options&&x.options.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[x.options.map(y=>{const k=f(y.label),N=a[x.id];return t.jsxs("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?v(x.id,y.label):s(w=>({...w,[x.id]:y.label})),className:`relative rounded-2xl border px-3 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${(x.multiSelect?Array.isArray(N)&&N.includes(y.label):N===y.label)?"ui-status-warning":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:y.description,children:[k.recommended?t.jsx("span",{"aria-hidden":"true",className:"absolute right-1.5 top-1 inline-flex h-3.5 w-3.5 items-center justify-center rounded-full bg-white/10 text-[10px] leading-none text-amber-100/90",children:"✦"}):null,k.displayLabel]},y.label)}),x.isOther&&(()=>{const y=a[x.id];return t.jsx("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?v(x.id,u):s(k=>({...k,[x.id]:u})),className:`rounded-2xl border px-3 py-1.5 text-[12px] leading-4 transition sm:text-[13px] ${(x.multiSelect?Array.isArray(y)&&y.includes(u):y===u)?"ui-status-info":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Not from above"})})()]}),x.isOther&&(()=>{const y=a[x.id];return(x.multiSelect?Array.isArray(y)&&y.includes(u):y===u)?t.jsx("input",{"aria-label":`${x.header} custom answer`,value:o[x.id]??"",onChange:N=>l(w=>({...w,[x.id]:N.target.value})),placeholder:"Enter a custom answer",className:"mt-3 w-full rounded-xl border border-stone-700 bg-stone-900 px-3 py-2 text-sm text-stone-100 outline-none transition focus:border-sky-300"}):null})()]}):t.jsx("input",{"aria-label":x.header,value:a[x.id]??"",onChange:y=>s(k=>({...k,[x.id]:y.target.value})),className:"mt-3 w-full rounded-xl border border-stone-700 bg-stone-900 px-3 py-2 text-sm text-stone-100 outline-none transition focus:border-amber-300"})]},x.id))}),e.kind!=="planDecision"&&t.jsx("div",{className:"mt-3 flex justify-end",children:t.jsx("button",{type:"button",disabled:r||e.questions.some(x=>!g(x)),onClick:()=>void(n==null?void 0:n(e.id,{answers:Object.fromEntries(e.questions.map(x=>[x.id,{answers:b(x)}]))})),className:"ui-action-info rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:r?"Submitting...":"Submit"})})]})}function il({note:e}){return t.jsxs("div",{className:"timeline-note-card w-full rounded-2xl border px-3 py-2.5",children:[t.jsx("p",{className:"timeline-meta-text text-[11px] uppercase tracking-[0.2em]",children:e.title}),t.jsx("div",{className:"mt-1 space-y-1",children:e.summaryLines.map((r,n)=>t.jsxs("p",{className:"timeline-primary-text text-[13px] leading-5",children:["You selected ",r]},`${e.id}-${n}`))})]})}function dl({note:e,onOpenThread:r,onOpenLinkedThread:n}){const a=e.kind==="forkCreated"?"Fork":e.kind==="forkSource"?"Fork source":"System",s=e.kind==="forkCreated"?`Thread forked from Turn ${e.turnIndex??"?"}`:e.kind==="forkSource"?`Forked from ${e.linkedThreadTitle??"source thread"} at Turn ${e.turnIndex??"?"}`:e.text??"";return t.jsxs("div",{className:"timeline-activity-card w-full rounded-2xl border px-3 py-2.5",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("p",{className:"timeline-meta-text text-[11px] uppercase tracking-[0.2em]",children:a}),t.jsx("time",{dateTime:e.createdAt,title:Zt(e.createdAt),className:"timeline-meta-text text-[10px]",children:_t(e.createdAt)})]}),t.jsx("p",{className:"timeline-primary-text mt-1 text-[13px] leading-5",children:s}),e.linkedThreadId?t.jsx("button",{type:"button",onClick:()=>{const o=e.linkedThreadId;o&&(n==null||n(o),r==null||r(o))},className:"relative z-10 mt-2 inline-flex cursor-pointer rounded-full border border-amber-300/30 px-3 py-1.5 text-xs text-amber-100 transition hover:bg-amber-300/10",children:e.kind==="forkCreated"?"Open fork":"Back to source"}):null]})}function ar({notes:e,onOpenThread:r,onOpenLinkedThread:n}){return e.length===0?null:t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:e.map(a=>t.jsx(dl,{note:a,onOpenThread:r,onOpenLinkedThread:n},a.id))})}function Fn({entries:e,respondingRequestId:r,onRespondToRequest:n}){return e.length===0?null:t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:e.map(a=>a.kind==="note"?t.jsx(il,{note:a.note},a.id):t.jsx(ll,{request:a.request,busy:r===a.request.id,onRespond:n},a.id))})}function Rp({notes:e,requests:r,respondingRequestId:n,onRespondToRequest:a}){const s=[...e.map(o=>({kind:"note",id:o.id,createdAt:o.createdAt??"",note:o})),...r.map(o=>({kind:"request",id:o.id,createdAt:o.createdAt,request:o}))].sort((o,l)=>o.createdAt.localeCompare(l.createdAt));return t.jsx(Fn,{entries:s,respondingRequestId:n,onRespondToRequest:a})}function _p({entries:e,respondingRequestId:r,onRespondToRequest:n,onOpenThread:a,onOpenLinkedThread:s}){return e.length===0?null:t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:[...e].sort((o,l)=>o.createdAt.localeCompare(l.createdAt)).map(o=>o.kind==="activity"?t.jsx(dl,{note:o.note,onOpenThread:a,onOpenLinkedThread:s},o.id):o.kind==="note"?t.jsx(il,{note:o.note},o.id):t.jsx(ll,{request:o.request,busy:r===o.request.id,onRespond:n},o.id))})}function Ap({entries:e,expandedGroups:r,onToggleGroupedItem:n,renderCommandGroup:a,renderFileChangeGroup:s,renderFileReadGroup:o,renderItem:l,renderSearchGroup:i}){return t.jsx(t.Fragment,{children:e.map(d=>{const h=r[d.key]??!1,u=()=>n(d.key);return d.kind==="commandGroup"?a(d,h,u):d.kind==="fileChangeGroup"?s(d,h,u):d.kind==="searchGroup"?i(d,h,u):d.kind==="fileReadGroup"?o(d,h,u):l(d)})})}function Vr({children:e,className:r,count:n,countBadgeClassName:a,desktopIconClassName:s,expanded:o,expandedListClassName:l,icon:i,onToggleExpanded:d,runningIndicator:h,summary:u,toggleAriaLabel:m,trailingSummary:f}){return t.jsx("div",{className:`thread-graph-history-group ${r} relative min-w-0 w-full overflow-hidden rounded-[0.9rem] border px-3 py-2.5`,children:t.jsxs("div",{className:"flex items-start gap-2.5",children:[t.jsxs("div",{className:"thread-graph-history-group-icon mt-0.5 flex shrink-0 items-center",children:[t.jsxs("span",{className:`relative inline-flex h-8 w-8 items-center justify-center rounded-[0.9rem] border shadow-sm shadow-stone-950/20 ${s}`,children:[i,t.jsx("span",{className:`absolute -right-1 -top-1 inline-flex min-w-[1.1rem] items-center justify-center rounded-full border bg-stone-950/90 px-1 text-[9px] font-semibold leading-4 ${a}`,children:n})]}),h]}),t.jsxs("div",{className:"thread-graph-history-group-card min-w-0 flex-1 rounded-[0.85rem] border px-3 py-2",children:[t.jsxs("button",{type:"button","aria-expanded":o,"aria-label":m,onClick:d,className:"thread-graph-history-group-toggle flex w-full min-w-0 items-center justify-between gap-3 text-left",children:[t.jsx("div",{className:"thread-graph-history-group-summary min-w-0 flex flex-1 flex-wrap items-center gap-2 pr-1",children:u}),f]}),o?t.jsx("div",{className:`thread-graph-history-group-list mt-3 space-y-2 border-t pt-3 ${l}`,children:e}):null]})]})})}xr();Nt();var Mp=mr("inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden whitespace-nowrap rounded-md border px-2 py-0.5 text-xs font-medium outline-none transition-[color,box-shadow] focus-visible:ring-[3px] [&>svg]:pointer-events-none [&>svg]:size-3",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-white",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Kr({asChild:e=!1,className:r,variant:n,...a}){const s=e?Ps:"span";return t.jsx(s,{"data-slot":"badge",className:et(Mp({variant:n,className:r})),...a})}function qr(e){if(!e)return!1;const r=e.trim().toLowerCase();return r==="running"||r==="in_progress"||r==="in progress"||r==="pending"}function $p(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5 2.75h4l2 2v6.5a1.5 1.5 0 0 1-1.5 1.5h-4A1.5 1.5 0 0 1 4 11.25v-7A1.5 1.5 0 0 1 5.5 2.75Z"}),t.jsx("path",{d:"M9 2.75v2h2"}),t.jsx("path",{d:"M6.2 8h3.6"}),t.jsx("path",{d:"M6.2 10h1.7"})]})}function Dp(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5 2.75h4l2 2v6.5a1.5 1.5 0 0 1-1.5 1.5h-4A1.5 1.5 0 0 1 4 11.25v-7A1.5 1.5 0 0 1 5.5 2.75Z"}),t.jsx("path",{d:"M9 2.75v2h2"}),t.jsx("path",{d:"M6.15 7.25h3.7"}),t.jsx("path",{d:"M6.15 9.25h2.8"}),t.jsx("path",{d:"m10.4 10.7 1.2 1.2"}),t.jsx("circle",{cx:"9.25",cy:"9.55",r:"1.45"})]})}function Bp(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"2.75",y:"3",width:"8.5",height:"3",rx:"1.1"}),t.jsx("rect",{x:"4.25",y:"6.5",width:"8.5",height:"3",rx:"1.1"}),t.jsx("rect",{x:"5.75",y:"10",width:"7.5",height:"3",rx:"1.1"}),t.jsx("path",{d:"m6.25 4.5 1 1-1 1"}),t.jsx("path",{d:"M7.9 5.5h1.7"}),t.jsx("path",{d:"m7.75 8 1 1-1 1"}),t.jsx("path",{d:"M9.4 9h1.7"})]})}function Gp(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"6",cy:"6",r:"2.3"}),t.jsx("path",{d:"m8 8 1.6 1.6"}),t.jsx("circle",{cx:"9.3",cy:"8.8",r:"2"}),t.jsx("path",{d:"m10.75 10.25 1.65 1.65"}),t.jsx("circle",{cx:"11.2",cy:"4.75",r:"1.8"}),t.jsx("path",{d:"m12.45 6 1.1 1.1"})]})}function Fp(e){const r=e.trim();if(!r)return"";const n=r.match(/(, \+\d+ more.*)$/),a=(n==null?void 0:n[1])??"",o=(a?r.slice(0,-a.length):r).replace(/\\/g,"/");if(!o.startsWith("/"))return`${o.replace(/^\.\//,"")}${a}`;const l=["/apps/","/packages/","/src/","/test/","/tests/","/docs/","/config/","/scripts/","/e2e/","/.agents/","/.codex/"];for(const i of l){const d=o.indexOf(i);if(d>=0)return`${o.slice(d+1)}${a}`}return r}function cl(e,r=42){const n=Fp(e);if(!n)return"";const a=n.match(/(, \+\d+ more.*)$/),s=(a==null?void 0:a[1])??"",o=s?n.slice(0,-s.length):n;if(o.length<=r)return`${o}${s}`;const i=o.replace(/\\/g,"/").split("/").filter(Boolean);if(i.length>1){const d=[];let h=s.length+4;for(let u=i.length-1;u>=0;u-=1){const m=i[u],f=h+m.length+(d.length>0?1:0);if(d.length>0&&f>r)break;d.unshift(m),h=f}if(d.length>0)return`.../${d.join("/")}${s}`}return`...${o.slice(-(r-s.length-3))}${s}`}function Hp(e){var a;const r=[];if(typeof e.changedFiles=="number"&&e.changedFiles>0&&r.push(`${e.changedFiles} ${e.changedFiles===1?"file":"files"}`),typeof e.addedLines=="number"&&e.addedLines>0&&r.push(`+${e.addedLines}`),typeof e.removedLines=="number"&&e.removedLines>0&&r.push(`-${e.removedLines}`),r.length>0)return r;const n=(a=e.previewText)==null?void 0:a.trim();return n?n.replace(/\bfiles changed\b/gi,"files").replace(/\bfile changed\b/gi,"file").split("·").map(s=>s.trim()).filter(Boolean):[]}function Hn({tone:e="amber"}){const r=e==="emerald"?"bg-sky-200/90":e==="sky"?"bg-sky-300/90":"bg-amber-200/90";return t.jsx("span",{className:"ml-1.5 inline-flex items-center gap-1","aria-hidden":"true",children:[0,1,2].map(n=>t.jsx("span",{className:`h-1.5 w-1.5 animate-pulse rounded-full ${r}`,style:{animationDelay:`${n*180}ms`}},n))})}function Op(e){var n;const r=e.replace(/\r\n/g,`
|
|
3611
3618
|
`).split(`
|
|
3612
|
-
`);for(;r.length>1&&((n=r.at(-1))==null?void 0:n.trim())==="";)r.pop();return r}function pt(e){const r=Op(e);return r.length===1?{firstLine:r[0]??"",showGap:!1,isTruncated:!1}:{firstLine:r[0]??"",showGap:!0,isTruncated:!0}}function ul(e){const r=(e==null?void 0:e.trim().toLowerCase())??"";return r==="completed"||r==="complete"||r==="success"||r==="succeeded"?{className:"is-completed",icon:t.jsx(G.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"}:r==="failed"||r==="failure"||r==="error"||r==="errored"?{className:"is-failed",icon:t.jsx(G.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"}:qr(e)?{className:"is-pending",icon:t.jsx(G.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),label:(e==null?void 0:e.trim())||"Running"}:{className:"is-neutral",icon:null,label:(e==null?void 0:e.trim())||"Event"}}function Up(e){switch(e){case"command":return"is-command";case"tool":return"is-tool";case"agent":return"is-agent";case"skill":return"is-skill";case"search":return"is-search";case"fileRead":return"is-file-read"}}function Wp(e){switch(e){case"plan":return"is-plan";case"context":return"is-context";case"generic":return"is-generic";case"image":return"is-image";case"fileChange":return"is-file-change";case"artifact":return"is-artifact";case"hook":return"is-hook"}}function Dt({actions:e,children:r,className:n,headerMeta:a,icon:s,item:o,title:l,tone:i}){const d=ul(o.status);return t.jsxs("div",{className:`thread-graph-event thread-graph-history-event ${Wp(i)} ${n??""}`,children:[t.jsx("div",{className:"thread-graph-history-event-icon","aria-hidden":"true",children:s}),t.jsxs("div",{className:"thread-graph-history-event-card",children:[t.jsxs("div",{className:"thread-graph-history-event-header",children:[t.jsxs("div",{className:"thread-graph-history-event-heading flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-event-title min-w-0 truncate font-mono text-sm font-semibold",children:l}),o.status?t.jsxs(Kr,{variant:"outline",className:`thread-graph-tool-badge ${d.className} rounded-full px-2 py-0.5 text-xs font-normal`,title:d.label,"aria-label":`Status: ${d.label}`,children:[d.icon,t.jsx("span",{className:"thread-graph-status-label",children:d.label})]}):null,a]}),e?t.jsx("div",{className:"thread-graph-history-event-actions",children:e}):null]}),r?t.jsx("div",{className:"thread-graph-history-event-body",children:r}):null]})]})}function er({actionLabel:e="Open details",actionTitle:r,className:n,details:a,icon:s,item:o,onOpen:l,preview:i,title:d,tone:h}){const u=ul(o.status),[m,f]=c.useState(qr(o.status)?"item-1":void 0);return t.jsx("div",{className:`thread-graph-event thread-graph-history-tool ${Up(h)} ${n??""}`,children:t.jsx(pr,{type:"single",collapsible:!0,onValueChange:p=>f(p||void 0),className:"thread-graph-tool-accordion thread-graph-history-tool-accordion w-full overflow-hidden rounded-lg border",...m!==void 0?{value:m}:{},children:t.jsxs(fr,{value:"item-1",className:"border-0",children:[t.jsx(gr,{"aria-label":`${m==="item-1"?"Collapse":"Expand"} ${d} history item`,className:"thread-graph-tool-trigger thread-graph-history-tool-trigger px-4 py-3 hover:no-underline",children:t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-tool-icon shrink-0",children:s}),t.jsx("span",{className:"min-w-0 truncate font-mono text-sm font-semibold",children:d}),t.jsxs(Kr,{variant:"outline",className:`thread-graph-tool-badge ${u.className} ml-1 sm:ml-2 rounded-full px-2 py-0.5 text-xs font-normal`,title:u.label,"aria-label":`Status: ${u.label}`,children:[u.icon,t.jsx("span",{className:"thread-graph-status-label",children:u.label})]})]})}),t.jsxs(xr,{className:"thread-graph-tool-content thread-graph-history-tool-content px-4 pb-4 pt-1",children:[t.jsxs("section",{children:[t.jsx("h4",{children:"Summary"}),t.jsxs("div",{className:"thread-graph-history-tool-summary",children:[t.jsx(Jt,{text:i.firstLine}),i.showGap?t.jsx("span",{className:"thread-graph-history-tool-ellipsis",children:"..."}):null]})]}),a?t.jsx("section",{children:a}):null,t.jsxs("button",{type:"button","aria-label":e,onClick:l,className:"thread-graph-history-tool-open inline-flex items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium transition",children:[t.jsx(G.ExternalLink,{className:"h-3.5 w-3.5"}),r]})]})]})})})}var Vp=c.memo(function({item:r,scrollRootRef:n,onBeforeResize:a}){return t.jsx(Dt,{className:"thread-graph-event-plan",icon:t.jsx(G.ClipboardList,{className:"h-4 w-4"}),item:r,title:"plan",tone:"plan",children:t.jsx("div",{className:"thread-graph-history-event-prose",children:t.jsx(nl,{text:r.text,scrollRootRef:n,plainTextClassName:"thread-graph-plain-text whitespace-pre-wrap break-words text-sm leading-6",markdownClassName:"thread-graph-markdown text-sm",...a?{onBeforeResize:a}:{}})})})}),Kp=c.memo(function({item:r}){const n=qr(r.status)||r.text==="Compacting context",a=n?"Compacting context":"Context compacted",s=r.detailText&&r.detailText!==a?r.detailText:null;return t.jsxs(Dt,{className:"thread-graph-event-context",icon:t.jsx(G.Archive,{className:"h-4 w-4"}),item:r,title:"context",tone:"context",children:[t.jsxs("div",{className:"thread-graph-history-event-line",children:[t.jsx("span",{className:"thread-graph-history-event-primary",children:a}),n?t.jsx(On,{tone:"emerald"}):null]}),s?t.jsx("p",{className:"thread-graph-history-event-secondary",title:s,children:s}):null]})}),qp=c.memo(function({item:r}){return t.jsx(Dt,{className:"thread-graph-event-generic",icon:t.jsx(G.Info,{className:"h-4 w-4"}),item:r,title:r.kind,tone:"generic",children:t.jsx("pre",{className:"thread-graph-history-event-pre",children:t.jsx(Jt,{text:r.text})})})}),Xp=c.memo(function({item:r,onOpen:n}){const a=pt(r.previewText??r.text);return t.jsx(er,{actionLabel:"Open full command",actionTitle:"Command Output",className:"thread-graph-event-command",icon:t.jsx(G.Terminal,{className:"h-4 w-4"}),item:r,onOpen:()=>n(r,"Command Output"),preview:a,title:"command",tone:"command"})}),Yp=c.memo(function({item:r,onOpen:n}){const a=pt(r.text);return t.jsx(er,{actionLabel:"Open full tool call",actionTitle:"Tool Call Details",className:"thread-graph-event-tool",icon:t.jsx(G.Wrench,{className:"h-4 w-4"}),item:r,onOpen:()=>n(r,"Tool Call Details"),preview:a,title:"tool_call",tone:"tool"})}),Zp=c.memo(function({item:r,onOpen:n}){const a=pt(r.text);return t.jsx(er,{actionLabel:"Open agent details",actionTitle:"Agent Details",className:"thread-graph-event-agent-tool",icon:t.jsx(G.Bot,{className:"h-4 w-4"}),item:r,onOpen:()=>n(r,"Agent Details"),preview:a,title:"agent",tone:"agent"})}),Jp=c.memo(function({item:r,onOpen:n}){const a=pt(r.text);return t.jsx(er,{actionLabel:"Open skill details",actionTitle:"Skill Details",className:"thread-graph-event-skill-tool",icon:t.jsx(G.Sparkles,{className:"h-4 w-4"}),item:r,onOpen:()=>n(r,"Skill Details"),preview:a,title:"skill",tone:"skill"})}),Qp=c.memo(function({item:r,onOpen:n}){var l,i;const a=((l=r.previewText)==null?void 0:l.trim())||r.text||"Web search",s=((i=r.detailText)==null?void 0:i.trim())||r.text||"Web search",o=pt(a);return t.jsx(er,{actionLabel:"Open full web search",actionTitle:"Web Search Details",className:"thread-graph-event-search",icon:t.jsx(G.Search,{className:"h-4 w-4"}),item:r,onOpen:()=>n("Web Search Details",s),preview:o,title:"web_search",tone:"search"})}),ef=c.memo(function({item:r,onOpen:n}){var l,i;const a=((l=r.previewText)==null?void 0:l.trim())||r.text||"File read",s=((i=r.detailText)==null?void 0:i.trim())||r.text||"File read",o=pt(a);return t.jsx(er,{actionLabel:"Open full file read",actionTitle:"File Read Details",className:"thread-graph-event-file-read",icon:t.jsx(G.FileText,{className:"h-4 w-4"}),item:r,onOpen:()=>n("File Read Details",s),preview:o,title:"file_read",tone:"fileRead"})}),tf=c.memo(function({threadId:r,item:n,onOpen:a,getImageAssetUrl:s}){const o=n.assetPath??n.detailText??null,l=r&&o?(s==null?void 0:s({threadId:r,path:o}))??null:null;return t.jsxs(Dt,{className:"thread-graph-event-image",icon:t.jsx(G.Image,{className:"h-4 w-4"}),item:n,title:"image",tone:"image",children:[l?t.jsx("button",{type:"button",onClick:()=>a("Image Path",o??n.text),className:"block w-full text-left",children:t.jsx("img",{src:l,alt:n.text||"Image preview",className:"thread-graph-history-event-image",loading:"lazy"})}):t.jsx("div",{className:"thread-graph-history-event-summary",children:n.text}),o?t.jsx("button",{type:"button",onClick:()=>a("Image Path",o),className:"thread-graph-history-event-path",title:o,children:o}):null]})}),rf=c.memo(function({item:r,onOpen:n}){var u,m,f;const a=(u=r.previewText)!=null&&u.trim()&&r.text.trim()!==r.previewText.trim()?r.text.trim():null,s=((m=r.detailText)==null?void 0:m.trim())||null,o=hl(a??((f=r.previewText)==null?void 0:f.trim())??r.text,48),l=Hp(r),i=!!(s||r.hasDeferredDetail),d=t.jsxs("div",{className:"thread-graph-event-line thread-graph-file-change-inline flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip text-sm",title:a??o,children:o}),l.length>0&&t.jsx("div",{className:"inline-flex shrink-0 items-center justify-end gap-1.5 text-xs",children:l.map(p=>t.jsx("span",{className:`thread-graph-history-delta-badge ${p.startsWith("+")?"is-add":p.startsWith("-")?"is-remove":"is-neutral"}`,children:p},p))})]}),h=i?t.jsx("button",{type:"button","aria-label":"Open file change details",onClick:()=>n("File Change Details",s??r.text),className:"thread-graph-file-change-inline-button min-w-0 flex-1 text-left",title:a??o,children:d}):d;return t.jsx(Dt,{className:"thread-graph-event-file-change",headerMeta:h,icon:t.jsx(G.FilePenLine,{className:"h-4 w-4"}),item:r,title:"file_change",tone:"fileChange"})}),nf=c.memo(function({item:r,onSelect:n}){const a=na(),[s,o]=c.useState(!1),l=r.artifact,i=l?a.renderArtifact({artifact:l,expanded:s,onToggleExpanded:()=>o(d=>!d)}):null;return t.jsx(Dt,{actions:t.jsxs("span",{className:"inline-flex items-center gap-2",children:[l&&!a.hasRendererForArtifact(l)?t.jsx("span",{className:"thread-graph-history-event-secondary",children:"No renderer"}):null,l&&n?t.jsxs("button",{type:"button","aria-label":`Open artifact inspector for ${l.title}`,onClick:()=>n(r,l),className:"thread-graph-history-event-action",children:[t.jsx(G.PackageOpen,{className:"h-3.5 w-3.5"}),"Inspect"]}):null]}),className:"thread-graph-event-artifact",icon:t.jsx(G.PackageOpen,{className:"h-4 w-4"}),item:r,title:(l==null?void 0:l.type)??"artifact",tone:"artifact",children:i??t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:()=>o(d=>!d),className:"thread-graph-history-event-summary is-clickable flex w-full items-center justify-between gap-3 text-left",children:[t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"thread-graph-history-event-primary block truncate",children:(l==null?void 0:l.title)??r.text}),t.jsx("span",{className:"thread-graph-history-event-secondary mt-1 block truncate",children:(l==null?void 0:l.summaryText)??r.previewText??r.text})]}),t.jsx("span",{className:"thread-graph-history-event-pill",children:s?"Hide":"Open"})]}),s?t.jsx("pre",{className:"thread-graph-history-event-pre max-h-80 overflow-auto",children:JSON.stringify((l==null?void 0:l.payload)??r,null,2)}):null]})})}),af=c.memo(function({item:r}){var d,h;const n=((d=r.hookOutputEntries)==null?void 0:d.map(u=>u.text.trim()).filter(Boolean).join(`
|
|
3613
|
-
`).trim())??"",a=r.hookEventLabel?`${r.hookEventLabel} hook`:r.text,s=((h=r.hookStatusMessage)==null?void 0:h.trim())||(r.previewText&&r.previewText!==r.hookStatusMessage?r.previewText.trim():"")||r.text.trim(),l=pt(n||(s&&s!==a?s:a)),i=!!(n&&l.showGap);return t.jsx(Dt,{className:"thread-graph-event-hook",icon:t.jsx(G.Webhook,{className:"h-4 w-4"}),item:r,title:r.hookEventLabel?`${r.hookEventLabel}_hook`:"hook",tone:"hook",children:t.jsxs("div",{className:"thread-graph-history-event-line",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:n?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"thread-graph-history-event-secondary mr-2 font-sans text-[11px] uppercase",children:a}),t.jsx(Jt,{text:l.firstLine})]}):t.jsx(Jt,{text:l.firstLine&&l.firstLine!==a?`${a} · ${l.firstLine}`:a})}),i?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})})}),sf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s}){const o=r.filter(i=>qr(i.status)).length,l=r.length===1?"1 command":`${r.length} commands`;return t.jsx(Vr,{className:"thread-graph-history-group-command",count:r.length,countBadgeClassName:"border-amber-200/35 text-amber-100",desktopIconClassName:"border-amber-300/30 bg-amber-300/[0.14] text-amber-100",expanded:n,expandedListClassName:"border-amber-300/12",icon:t.jsx(Bp,{}),onToggleExpanded:a,runningIndicator:o>0?t.jsx(On,{}):null,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-amber-300/28 bg-amber-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-amber-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:l}),o>0?t.jsx("span",{className:"inline-flex items-center text-xs text-amber-100/90",children:t.jsx(On,{})}):null]}),toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} command entries`,children:r.map((i,d)=>{const h=pt(i.text);return t.jsxs("button",{type:"button","aria-label":`Open grouped command ${d+1}`,onClick:()=>s(i,`Command Output ${d+1}`),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"rounded-full border border-amber-300/18 bg-amber-300/[0.07] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-amber-100",children:["Step ",d+1]}),i.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:i.status})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2 text-sm leading-6",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:h.firstLine}),h.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},i.id)})})}),of=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s}){const o=r.length===1?"1 search":`${r.length} searches`;return t.jsx(Vr,{className:"thread-graph-history-group-search",count:r.length,countBadgeClassName:"border-sky-200/35 text-sky-100",desktopIconClassName:"border-sky-300/30 bg-sky-300/[0.14] text-sky-100",expanded:n,expandedListClassName:"border-sky-300/12",icon:t.jsx(Gp,{}),onToggleExpanded:a,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-sky-300/28 bg-sky-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-sky-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:o})]}),toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} web search entries`,children:r.map((l,i)=>{var m,f;const d=((m=l.previewText)==null?void 0:m.trim())||l.text||"Web search",h=pt(d),u=((f=l.detailText)==null?void 0:f.trim())||l.text||"Web search";return t.jsxs("button",{type:"button","aria-label":`Open grouped web search ${i+1}`,onClick:()=>s(`Web Search ${i+1}`,u),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"rounded-full border border-sky-300/18 bg-sky-300/[0.07] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-sky-100",children:["Search ",i+1]}),l.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:l.status})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2 text-sm leading-6",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:h.firstLine}),h.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},l.id)})})}),lf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s}){const o=r.length===1?"1 file read":`${r.length} file reads`;return t.jsx(Vr,{className:"thread-graph-history-group-file-read",count:r.length,countBadgeClassName:"border-cyan-200/35 text-cyan-100",desktopIconClassName:"border-cyan-300/30 bg-cyan-300/[0.14] text-cyan-100",expanded:n,expandedListClassName:"border-cyan-300/12",icon:t.jsx(Dp,{}),onToggleExpanded:a,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-cyan-300/28 bg-cyan-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-cyan-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:o})]}),toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} file read entries`,children:r.map((l,i)=>{var m,f;const d=((m=l.previewText)==null?void 0:m.trim())||l.text||"File read",h=pt(d),u=((f=l.detailText)==null?void 0:f.trim())||l.text||"File read";return t.jsxs("button",{type:"button","aria-label":`Open grouped file read ${i+1}`,onClick:()=>s(`File Read ${i+1}`,u),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"rounded-full border border-cyan-300/18 bg-cyan-300/[0.07] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-cyan-100",children:["Read ",i+1]}),l.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:l.status})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2 text-sm leading-6",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:h.firstLine}),h.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},l.id)})})}),df=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s}){const o=r.reduce((h,u)=>h+(u.changedFiles??0),0),l=r.reduce((h,u)=>h+(u.addedLines??0),0),i=r.reduce((h,u)=>h+(u.removedLines??0),0),d=r.length===1?"1 file change":`${r.length} file changes`;return t.jsx(Vr,{className:"thread-graph-history-group-file-change",count:r.length,countBadgeClassName:"border-lime-200/35 text-lime-100",desktopIconClassName:"border-lime-300/30 bg-lime-300/[0.14] text-lime-100",expanded:n,expandedListClassName:"border-lime-300/12",icon:t.jsx($p,{}),onToggleExpanded:a,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-lime-300/28 bg-lime-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-lime-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:d}),o>0?t.jsxs("span",{className:"thread-graph-history-detail-meta text-xs",children:[o," files"]}):null]}),toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} file change entries`,trailingSummary:t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[l>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-add",children:["+",l]}):null,i>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-remove",children:["-",i]}):null]}),children:r.map((h,u)=>{var p,g,b,v;const m=((p=h.detailText)==null?void 0:p.trim())||((g=h.previewText)==null?void 0:g.trim())||h.text,f=(b=h.previewText)!=null&&b.trim()&&h.text.trim()!==h.previewText.trim()?h.text.trim():((v=h.previewText)==null?void 0:v.trim())||h.text;return t.jsx("button",{type:"button","aria-label":`Open grouped file change ${u+1}`,onClick:()=>s(`File Change ${u+1}`,m),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-detail-text min-w-0 flex-1 text-sm leading-6",title:f,children:hl(f,34)}),t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[(h.addedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-add",children:["+",h.addedLines]}):null,(h.removedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-remove",children:["-",h.removedLines]}):null]})]})},h.id)})})});function cf(e){const r=e.trim().toLowerCase();return r==="completed"||r==="done"||r==="complete"?"completed":r==="in_progress"||r==="in-progress"||r==="running"||r==="active"?"in_progress":r==="failed"||r==="error"||r==="cancelled"?"failed":r==="pending"||r==="todo"?"pending":"unknown"}function hf({status:e}){const r=cf(e),n=r==="completed"?"Plan step status: Completed":r==="in_progress"?"Plan step status: In progress":r==="pending"?"Plan step status: Pending":r==="failed"?"Plan step status: Failed":`Plan step status: ${e}`,a=r==="completed"?"thread-graph-plan-status is-completed":r==="in_progress"?"thread-graph-plan-status is-running":r==="pending"?"thread-graph-plan-status is-pending":r==="failed"?"thread-graph-plan-status is-failed":"thread-graph-plan-status is-unknown";return t.jsx(Kr,{"aria-label":n,title:n.replace("Plan step status: ",""),className:a,children:r==="completed"?t.jsx(G.CheckCircle2,{className:"h-3.5 w-3.5"}):r==="in_progress"?t.jsx(G.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):r==="pending"?t.jsx(G.Clock3,{className:"h-3.5 w-3.5"}):r==="failed"?t.jsx(G.XCircle,{className:"h-3.5 w-3.5"}):t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.14em]",children:"?"})})}function uf({livePlan:e}){return t.jsxs("div",{className:"thread-graph-plan-card rounded-xl border px-3 py-3",children:[t.jsxs("div",{className:"thread-graph-plan-header flex flex-wrap items-center justify-between gap-2",children:[t.jsx("p",{className:"text-sm font-semibold",children:"Plan update"}),t.jsx(Kr,{className:"thread-graph-plan-badge",children:"Live"})]}),e.explanation?t.jsx("p",{className:"thread-graph-plan-explanation mt-3 text-sm",children:e.explanation}):null,t.jsx("div",{className:"mt-3 space-y-2",children:e.plan.map((r,n)=>t.jsxs("div",{className:"thread-graph-plan-step flex items-center justify-between gap-3 rounded-lg border px-3 py-2 text-sm",children:[t.jsx("span",{className:"thread-graph-plan-step-text min-w-0 flex-1",children:r.step}),t.jsx(hf,{status:r.status})]},`${e.turnId}-${n}`))})]})}function mf({footer:e,history:r,liveHookPrompt:n,liveOutput:a,livePlan:s}){return t.jsxs(t.Fragment,{children:[r,s?t.jsx(uf,{livePlan:s}):null,n??a??null,e]})}function pf({absoluteIndex:e,body:r,collapsed:n,collapsedBody:a,error:s,footer:o,headerStatus:l,isActive:i=!1,onToggleCollapse:d,refCallback:h,startedAt:u,timeLabel:m,timeTitle:f,tokenSummary:p}){return t.jsxs("article",{ref:h,"data-testid":"chat-turn","data-turn-active":i?"true":"false",className:"thread-graph-turn px-3 py-2 sm:px-5 sm:py-3",children:[t.jsxs("div",{className:"thread-graph-turn-header flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0 flex flex-1 items-start gap-1.5",children:[t.jsxs("div",{className:"min-w-0 flex flex-1 items-center gap-1.5 overflow-hidden",children:[t.jsxs("span",{className:"thread-graph-turn-index rounded-[0.6rem] border px-1.5 py-0.5 text-[10px] uppercase tracking-[0.16em]",children:["Turn ",e]}),t.jsx("time",{dateTime:u??void 0,title:f,className:"thread-graph-turn-time shrink-0 text-[10px] sm:text-[11px]",children:m}),l,s?t.jsx("p",{className:"hidden truncate text-[11px] text-rose-200 sm:block",children:s}):null]}),p]}),t.jsx("button",{type:"button","aria-label":`${n?"Expand":"Collapse"} turn ${e}`,title:n?"Expand turn":"Collapse turn",onClick:d,className:"thread-graph-turn-collapse inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-md transition",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:n?t.jsx("path",{d:"m4.5 10 3.5-3.5L11.5 10"}):t.jsx("path",{d:"m4.5 6 3.5 3.5L11.5 6"})})})]}),s?t.jsx("p",{className:"mt-1 text-[11px] text-rose-200 sm:hidden",children:s}):null,t.jsxs("div",{className:"thread-graph-turn-body mt-2 space-y-2",children:[n?a:r,n?null:o]})]})}function ff(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M8 2.75v8"}),t.jsx("path",{d:"m4.75 7.5 3.25 3.25L11.25 7.5"})]})}function gf(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M8 13.25v-8"}),t.jsx("path",{d:"m11.25 8.5-3.25-3.25L4.75 8.5"})]})}function xf(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.45",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M3.25 5.25 8 2.75l4.75 2.5L8 7.75l-4.75-2.5Z"}),t.jsx("path",{d:"M3.25 8 8 10.5 12.75 8"}),t.jsx("path",{d:"M3.25 10.75 8 13.25l4.75-2.5"}),t.jsx("path",{d:"M3.25 5.25v5.5"}),t.jsx("path",{d:"M12.75 5.25v5.5"})]})}function bf(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.45",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M6.2 3.2a2.3 2.3 0 0 0-2.95 3.5A2.4 2.4 0 0 0 4.5 11h.2c.25 1.1 1.1 1.8 2.3 1.8h1.8c1.2 0 2.05-.7 2.3-1.8h.2A2.4 2.4 0 0 0 12.75 6.7 2.3 2.3 0 0 0 9.8 3.2"}),t.jsx("path",{d:"M6.3 6.15c.45-.42 1.02-.65 1.7-.65s1.25.23 1.7.65"}),t.jsx("path",{d:"M8 5.5v4.75"}),t.jsx("path",{d:"M6.75 9.05 8 10.25l1.25-1.2"})]})}function Cr(e){if(!Number.isFinite(e)||e<=0)return"0";if(e>=1e6){const r=e>=1e7?Math.round(e/1e6):e/1e6;return`${String(r.toFixed(1)).replace(/\.0$/,"")}m`}if(e>=1e3){const r=e>=1e4?Math.round(e/1e3):e/1e3;return`${String(r.toFixed(1)).replace(/\.0$/,"")}k`}return String(Math.round(e))}function vf(e){return!Number.isFinite(e)||e<=0?"$0":e>=100?`$${Math.round(e)}`:e>=10?`$${String(e.toFixed(1)).replace(/\.0$/,"")}`:e>=1?`$${String(e.toFixed(2)).replace(/0$/,"").replace(/\.$/,"")}`:e>=.1?`$${e.toFixed(2)}`:e>=.01?`$${e.toFixed(3)}`:e>=.001?`$${e.toFixed(4)}`:"<$0.001"}function ir(e){return!Number.isFinite(e)||e<=0?"$0.0000":`$${e.toFixed(4)}`}function Sr(e,r,n){const a=e??null;return!Number.isFinite(a??NaN)||a===null||r<=0||n<=0?null:a*n/r}function ml(e){var i,d,h,u,m;const r=(i=e.tokenUsage)==null?void 0:i.total;if(!r)return[];const n=Math.max(r.inputTokens-r.cachedInputTokens,0),a=Math.max(r.cachedInputTokens,0),s=Math.max(r.reasoningOutputTokens,0),o=Math.max(r.outputTokens-s,0);return[n>0?{id:"in",label:"Input",tokenCompactValue:Cr(n),tokenRawValue:n,usdCompactValue:e.priceEstimate?ir(e.priceEstimate.inputUsd):"--",usdRawValue:((d=e.priceEstimate)==null?void 0:d.inputUsd)??null,className:"token-badge-in",icon:t.jsx(ff,{})}:null,a>0?{id:"cache",label:"Cached input",tokenCompactValue:Cr(a),tokenRawValue:a,usdCompactValue:e.priceEstimate?ir(e.priceEstimate.cachedInputUsd):"--",usdRawValue:((h=e.priceEstimate)==null?void 0:h.cachedInputUsd)??null,className:"token-badge-cache",icon:t.jsx(xf,{})}:null,o>0?{id:"out",label:"Output",tokenCompactValue:Cr(o),tokenRawValue:o,usdCompactValue:e.priceEstimate?ir(Sr(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),o)??0):"--",usdRawValue:Sr((u=e.priceEstimate)==null?void 0:u.outputUsd,Math.max(r.outputTokens,0),o),className:"token-badge-out",icon:t.jsx(gf,{})}:null,s>0?{id:"reason",label:"Reasoning",tokenCompactValue:Cr(s),tokenRawValue:s,usdCompactValue:e.priceEstimate?ir(Sr(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),s)??0):"--",usdRawValue:Sr((m=e.priceEstimate)==null?void 0:m.outputUsd,Math.max(r.outputTokens,0),s),className:"token-badge-reason",icon:t.jsx(bf,{})}:null].filter(f=>f!==null)}function kf(e){return ml(e).map(r=>({id:r.id,label:r.tokenCompactValue,title:`${r.label}: ${r.tokenRawValue} tokens`,className:r.className,icon:r.icon}))}function pl(e){return{label:e.priceEstimate?vf(e.priceEstimate.totalUsd):"--",title:e.priceEstimate===null||e.priceEstimate===void 0?"Price estimate unavailable for this model.":`Estimated cost: ${ir(e.priceEstimate.totalUsd)}`,className:e.priceEstimate?"token-badge-total":"token-badge-empty"}}var xn="inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-normal leading-none sm:text-[11px]";function wf({turn:e}){const r=ml(e),n=pl(e),[a,s]=c.useState(!1),[o,l]=c.useState(!1),[i,d]=c.useState(0),h=c.useRef(null),u=c.useRef(null),m=c.useRef(null);if(c.useLayoutEffect(()=>{if(!a||r.length===0){d(0);return}const p=()=>{const g=h.current,b=m.current;if(!g||!b)return;const v=g.getBoundingClientRect(),x=b.offsetWidth||b.getBoundingClientRect().width;if(x<=0)return;const y=window.innerWidth||document.documentElement.clientWidth,k=12,j=v.left+v.width/2-x/2,w=k,N=Math.max(w,y-k-x),S=Math.min(Math.max(j,w),N);d(Math.round(S-j))};return p(),window.addEventListener("resize",p),()=>{window.removeEventListener("resize",p)}},[r.length,a]),c.useEffect(()=>{if(!a&&!o)return;const p=g=>{g.target instanceof Node&&(h.current&&!h.current.contains(g.target)&&s(!1),u.current&&!u.current.contains(g.target)&&l(!1))};return document.addEventListener("pointerdown",p),()=>{document.removeEventListener("pointerdown",p)}},[o,a]),!n&&r.length===0)return null;const f=()=>t.jsx("div",{className:"thread-token-popover min-w-[12rem] rounded-2xl border p-2.5 shadow-2xl shadow-black/20 backdrop-blur",children:t.jsx("div",{className:"space-y-1",children:r.map(p=>t.jsxs("div",{className:"thread-token-popover-row flex items-center justify-between gap-3 rounded-xl border px-2.5 py-1.5 text-[11px]",title:`${p.label}: ${p.tokenRawValue} tokens`,children:[t.jsxs("span",{className:"thread-token-popover-text inline-flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"inline-flex shrink-0",children:p.icon}),t.jsx("span",{className:"thread-token-popover-strong font-medium",children:p.usdCompactValue})]}),t.jsx("span",{className:"thread-token-popover-text shrink-0 font-medium",children:p.tokenCompactValue})]},p.id))})});return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"hidden shrink-0 items-center gap-1.5 md:inline-flex",children:[n?t.jsxs("div",{ref:u,className:"relative shrink-0",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[t.jsx("button",{type:"button","aria-label":"Show token and price details","aria-expanded":o,onFocus:()=>l(!0),onBlur:()=>l(!1),className:`${xn} appearance-none whitespace-nowrap bg-transparent !text-[10px] !font-normal !leading-none transition hover:bg-[var(--theme-hover)] sm:!text-[11px] ${n.className}`,title:n.title,children:n.label}),o&&r.length>0?t.jsx("div",{className:"absolute left-1/2 top-full z-30 mt-1.5 -translate-x-1/2",children:f()}):null]}):null,r.map(p=>t.jsxs("span",{className:`${xn} ${p.className}`,title:`${p.label}: ${p.usdCompactValue}, ${p.tokenRawValue} tokens`,children:[p.icon,t.jsx("span",{className:"thread-token-badge-value font-medium",children:p.tokenCompactValue})]},p.id))]}),t.jsxs("div",{ref:h,className:"relative shrink-0 md:hidden",children:[n?t.jsx("button",{type:"button","aria-label":"Show token and price details","aria-expanded":a,onClick:()=>s(p=>!p),className:`${xn} appearance-none whitespace-nowrap bg-transparent !text-[10px] !font-normal !leading-none transition hover:bg-[var(--theme-hover)] sm:!text-[11px] ${n.className}`,title:n.title,children:n.label}):null,a&&r.length>0?t.jsx("div",{ref:m,className:"absolute left-1/2 top-full z-30 mt-1.5",style:{transform:`translateX(${i}px) translateX(-50%)`},children:f()}):null]})]})}function yf({tone:e="amber"}){const r=e==="emerald"?"bg-sky-200/90":e==="sky"?"bg-sky-300/90":"bg-amber-200/90";return t.jsx("span",{className:"ml-1.5 inline-flex items-center gap-1","aria-hidden":"true",children:[0,1,2].map(n=>t.jsx("span",{className:`h-1.5 w-1.5 rounded-full animate-pulse ${r}`,style:{animationDelay:`${n*180}ms`}},n))})}function ks(e){const r=e.trim().toLowerCase();return r==="completed"||r==="done"||r==="complete"?"completed":r==="in_progress"||r==="in progress"||r==="inprogress"||r==="running"||r==="active"?"in_progress":r==="pending"||r==="todo"||r==="not_started"||r==="not started"||r==="queued"?"pending":r==="failed"||r==="error"?"failed":"other"}function jf(e){switch(e.kind){case"fileChange":case"webSearch":case"image":case"contextCompaction":return!0;case"commandExecution":case"toolCall":return!sl(e.status);default:return!1}}function Nf(e,r,n){if(!e||!$r(n))return e;const a=e.plan.findIndex(i=>ks(i.status)==="in_progress");if(a<0)return e;const s=e.plan.findIndex((i,d)=>d>a&&ks(i.status)==="pending");if(s<0||!r.some(i=>jf(i)))return e;const l=e.plan.map((i,d)=>d===a?{...i,status:"completed"}:d===s?{...i,status:"in_progress"}:i);return{...e,plan:l}}function Cf(e){var a;const r=(a=e.model)!=null&&a.trim()?e.model.trim():"--";let n="--";return e.reasoningEffortAvailable===null||e.reasoningEffortAvailable===void 0?n="--":e.reasoningEffortAvailable===!1?n="-":n=e.reasoningEffort??"--",[r,n].join(" · ")}function ws({status:e}){const r=Qo(e);return e==="completed"?t.jsx("span",{"aria-label":r,title:r,className:"timeline-status-icon timeline-status-icon-success inline-flex h-4 w-4 items-center justify-center",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m3.75 8.25 2.5 2.5 6-6"})})}):e==="failed"?t.jsx("span",{"aria-label":r,title:r,className:"timeline-status-icon timeline-status-icon-failed inline-flex h-4 w-4 items-center justify-center",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m5 5 6 6M11 5l-6 6"})})}):e==="interrupted"?t.jsx("span",{"aria-label":r,title:r,className:"timeline-status-icon timeline-status-icon-warning inline-flex h-4 w-4 items-center justify-center",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M6 4.5v7M10 4.5v7"})})}):t.jsx("span",{"aria-label":r,title:r,className:"inline-flex min-w-[1.25rem] items-center justify-center text-sky-200",children:t.jsx(yf,{tone:"emerald"})})}function ys({turn:e,variant:r="header"}){const n=Qo(e.status),a=Cf(e),s=kf(e),o=pl(e),l=$r(e.status),i=e.status==="failed"?"border-rose-300/20 bg-rose-300/[0.06] text-rose-100":l?"border-sky-300/22 bg-sky-300/[0.08] text-sky-100":"border-stone-700/90 bg-stone-900/70 text-stone-200";if(r==="footer")return t.jsxs("div",{className:`flex w-full flex-col gap-1.5 rounded-[0.95rem] border px-3 py-2 text-xs ${i}`,children:[t.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(ws,{status:e.status}),t.jsx("span",{className:"timeline-soft-text min-w-0 truncate",children:a})]}),e.startedAt&&t.jsx("time",{dateTime:e.startedAt,title:Zt(e.startedAt),className:"timeline-meta-text shrink-0 text-[11px]",children:Mt(e.startedAt)})]}),(o||s.length>0)&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 pl-6",children:[o?t.jsx("span",{className:`inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${o.className}`,title:o.title,children:o.label}):null,s.map(h=>t.jsxs("span",{className:`inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${h.className}`,title:h.title,children:[h.icon?t.jsx("span",{className:"mr-1",children:h.icon}):null,h.label]},h.id))]})]});const d=`${n} · ${a}`;return t.jsxs("span",{className:`inline-flex min-w-0 items-center gap-1.5 rounded-full border px-2 py-1 text-[10px] sm:text-[11px] ${i}`,title:d,children:[t.jsx(ws,{status:e.status}),t.jsx("span",{className:"timeline-meta-text min-w-0 truncate",children:a})]})}function Sf(e,r){return e.createdAt??r}var aa=c.memo(function({threadId:r,item:n,scrollRootRef:a,onOpenExpandedText:s,onOpenCommandDetail:o,onOpenToolCallDetail:l,onOpenDeferredHistoryItemDetail:i,onSelectArtifact:d,onBeforeMessageResize:h,adapter:u,timeLabel:m,timeTitle:f}){var p,g,b;if(Np(n.kind))return t.jsx(_t,{threadId:r,item:n,scrollRootRef:a,timeLabel:m,timeTitle:f,...h?{onBeforeMessageResize:h}:{},...u?{adapter:u}:{}});if(n.kind==="artifact")return t.jsx(nf,{item:n,...d?{onSelect:(v,x)=>d({item:v,artifact:x})}:{}});if(n.kind==="commandExecution")return t.jsx(Xp,{item:n,onOpen:o});if(n.kind==="toolCall")return t.jsx(Yp,{item:n,onOpen:l});if(n.kind==="agentToolCall")return t.jsx(Zp,{item:n,onOpen:l});if(n.kind==="skillToolCall")return t.jsx(Jp,{item:n,onOpen:l});if(n.kind==="webSearch"){const v=n,x=((p=v.detailText)==null?void 0:p.trim())||v.text||"Web search";return t.jsx(Qp,{item:v,onOpen:()=>i(v,"Web Search Details",x,"Loading full web search details...","Unable to load full web search details.")})}if(n.kind==="fileRead"){const v=n,x=((g=v.detailText)==null?void 0:g.trim())||v.text||"File read";return t.jsx(ef,{item:v,onOpen:()=>i(v,"File Read Details",x,"Loading full file read details...","Unable to load full file read details.")})}if(n.kind==="image")return t.jsx(tf,{threadId:r,item:n,onOpen:s,getImageAssetUrl:u==null?void 0:u.getImageAssetUrl});if(n.kind==="plan")return t.jsx(Vp,{item:n,scrollRootRef:a,...h?{onBeforeResize:h}:{}});if(n.kind==="fileChange"){const v=n,x=((b=v.detailText)==null?void 0:b.trim())||v.text||"File change";return t.jsx(rf,{item:v,onOpen:()=>i(v,"File Change Details",x,"Loading full file change details...","Unable to load full file change details.")})}return n.kind==="contextCompaction"?t.jsx(Kp,{item:n}):n.kind==="hook"?t.jsx(af,{item:n}):t.jsx(qp,{item:n})});function Tf(e){return e==="completed"||e==="failed"||e==="interrupted"}function Ef(e){const r=Date.parse(e.createdAt??"");return Number.isFinite(r)?r:null}function Lf(e){let r=null;for(const n of e){const a=Ef(n);a!==null&&(r=r===null?a:Math.max(r,a))}return r}function Pf(e,r){const n=Date.parse(e??""),a=Lf(r);if(!Number.isFinite(n)||a===null||a<n)return"Worked";const s=Math.max(1,Math.round((a-n)/1e3)),o=Math.floor(s/3600),l=Math.floor(s%3600/60),i=s%60;return o>0?`Worked for ${o}h ${l}m`:l>0?`Worked for ${l}m ${i}s`:`Worked for ${i}s`}function zf(e){const r=e.filter(a=>a.kind==="userMessage"),n=[...e].reverse().find(a=>a.kind==="agentMessage"&&a.text.trim().length>0);return{users:r,finalAgent:n,hiddenItems:e.filter(a=>a.kind!=="userMessage"&&a.id!==(n==null?void 0:n.id))}}var bn=c.memo(function({threadId:r,adapter:n,turn:a,absoluteIndex:s,isCollapsed:o,livePlan:l,liveItems:i,liveOutput:d,forceActive:h=!1,onToggleCollapse:u,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,onSelectArtifact:b,onBeforeMessageResize:v,scrollRootRef:x,articleRef:y,isLatestVisibleTurn:k=!1}){const j=!!l||!!d||!!(i&&i.length>0),w=h||$r(a.status)||j||k,N=w&&!$r(a.status)?{...a,status:"inProgress"}:a,S=c.useMemo(()=>Ep(a.items,i),[i,a.items]),L=c.useMemo(()=>Nf(l,S,a.status),[l,S,a.status]),T=c.useMemo(()=>Lp(d,S),[d,S]),q=c.useMemo(()=>Tp(S,w),[w,S]),A=c.useMemo(()=>Pp(q),[q]),D=Mt(a.startedAt),J=Zt(a.startedAt),W=c.useMemo(()=>al(T),[T]),[O,ee]=c.useState({}),he=c.useCallback(Z=>{ee(K=>({...K,[Z]:!K[Z]}))},[]),E=t.jsx(If,{entries:A,expandedGroups:O,onToggleGroupedItem:he,threadId:r,scrollRootRef:x,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,...v?{onBeforeMessageResize:v}:{},fallbackTimestamp:a.startedAt,fallbackTimeLabel:D,fallbackTimeTitle:J,...b?{onSelectArtifact:b}:{},...n?{adapter:n}:{}}),re=W?t.jsx(aa,{threadId:r,item:W,scrollRootRef:x,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,timeLabel:D,timeTitle:J,...b?{onSelectArtifact:b}:{},...n?{adapter:n}:{}}):null,_=!W&&T?t.jsx(_t,{item:{id:"live-agent-message",kind:"agentMessage",text:T},scrollRootRef:x,timeLabel:D,timeTitle:J,streaming:!0,...v?{onBeforeMessageResize:v}:{}}):null,V=w?t.jsx(ys,{turn:N,variant:"footer"}):null,U=c.useMemo(()=>zf(S),[S]),z=c.useMemo(()=>Pf(a.startedAt,S),[S,a.startedAt]),X=U.hiddenItems.length>0,F=o&&X,I=Tf(a.status)&&X?t.jsxs("div",{className:"thread-graph-turn-collapsed-summary space-y-2",children:[U.users.map(Z=>t.jsx(_t,{threadId:r,item:Z,scrollRootRef:x,timeLabel:Z.createdAt?Mt(Z.createdAt):D,timeTitle:Z.createdAt?Zt(Z.createdAt):J,...v?{onBeforeMessageResize:v}:{},...n?{adapter:n}:{}},Z.id)),t.jsxs("button",{type:"button",className:"thread-graph-worked-summary group flex w-full items-center gap-2 py-2 text-left text-sm transition",onClick:()=>u(a.id,!0),"aria-label":`${z}. Expand turn ${s}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:z}),t.jsx(G.ChevronRight,{className:"h-4 w-4 shrink-0 transition group-hover:translate-x-0.5"}),t.jsx("span",{className:"thread-graph-worked-rule h-px min-w-0 flex-1","aria-hidden":"true"})]}),U.finalAgent?t.jsx(_t,{threadId:r,item:U.finalAgent,scrollRootRef:x,timeLabel:U.finalAgent.createdAt?Mt(U.finalAgent.createdAt):D,timeTitle:U.finalAgent.createdAt?Zt(U.finalAgent.createdAt):J,...v?{onBeforeMessageResize:v}:{},...n?{adapter:n}:{}}):null]}):null,P=t.jsx(mf,{footer:V,history:E,liveHookPrompt:re,liveOutput:_,livePlan:L});return t.jsx(pf,{absoluteIndex:s,body:P,collapsed:F,collapsedBody:I,error:a.error,headerStatus:t.jsx(ys,{turn:a}),isActive:w,onToggleCollapse:()=>u(a.id,F),refCallback:y,startedAt:a.startedAt,timeLabel:D,timeTitle:J,tokenSummary:t.jsx(wf,{turn:a})})});function If({entries:e,expandedGroups:r,onToggleGroupedItem:n,threadId:a,scrollRootRef:s,onOpenExpandedText:o,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,onSelectArtifact:h,onBeforeMessageResize:u,adapter:m,fallbackTimestamp:f,fallbackTimeLabel:p,fallbackTimeTitle:g}){return t.jsx(_p,{entries:e,expandedGroups:r,onToggleGroupedItem:n,renderCommandGroup:(b,v,x)=>t.jsx(sf,{items:b.items,expanded:v,onToggleExpanded:x,onOpen:l},b.key),renderFileChangeGroup:(b,v,x)=>t.jsx(df,{items:b.items,expanded:v,onToggleExpanded:x,onOpen:o},b.key),renderSearchGroup:(b,v,x)=>t.jsx(of,{items:b.items,expanded:v,onToggleExpanded:x,onOpen:o},b.key),renderFileReadGroup:(b,v,x)=>t.jsx(lf,{items:b.items,expanded:v,onToggleExpanded:x,onOpen:o},b.key),renderItem:b=>{const v=Sf(b.item,f??null);return t.jsx(aa,{threadId:a,item:b.item,scrollRootRef:s,timeLabel:b.item.createdAt?Mt(v):p,timeTitle:b.item.createdAt?Zt(v):g,onOpenExpandedText:o,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,...u?{onBeforeMessageResize:u}:{},...h?{onSelectArtifact:h}:{},...m?{adapter:m}:{}},b.key)}})}var js=3,Rf=3,Un=80;function sr(e,r=Un){return e.scrollHeight-e.scrollTop-e.clientHeight<=r}function Mf(e,r){const n=e.getBoundingClientRect(),a=r.getBoundingClientRect(),s=Math.max(n.top,a.top),o=Math.min(n.bottom,a.bottom);return Math.max(0,o-s)>0}function _f(e){return e.map(n=>{const a=n.createdAt;return typeof a=="string"&&a.trim()?a:null}).filter(n=>!!n).sort()[0]??null}function Af(e,r){return{id:e,startedAt:_f(r),status:"inProgress",error:null,model:null,reasoningEffort:null,reasoningEffortAvailable:null,tokenUsage:null,priceEstimate:null,items:[]}}function Ns(e,r,n){return{id:e.id,kind:e.kind,title:r,text:n}}function $f({loadHistoryItemDetail:e,onSelectHistoryItemDetail:r}){const n=c.useRef(0),a=c.useRef(new Map),[s,o]=c.useState(null),l=c.useCallback((p,g)=>{o({title:p,text:g})},[]),i=c.useCallback((p,g,b)=>{if(b&&r){r({item:p,detail:g});return}o({title:g.title,text:g.text})},[r]),d=c.useCallback(async({item:p,fallbackTitle:g,fallbackText:b,loadingText:v,errorText:x,useSelectionCallback:y})=>{if(!p.hasDeferredDetail||!e){i(p,Ns(p,g,b),y);return}const k=a.current.get(p.id);if(k){i(p,k,y);return}const j=n.current+1;n.current=j,y&&r||o({title:g,text:v});try{const w=await e(p.id);if(a.current.set(p.id,w),n.current!==j)return;i(p,w,y)}catch(w){if(n.current!==j)return;i(p,Ns(p,g,w instanceof Error?w.message:x),y)}},[e,r,i]),h=c.useCallback(async(p,g)=>{var b;await d({item:p,fallbackTitle:g,fallbackText:((b=p.detailText)==null?void 0:b.trim())||p.text||"Command output",loadingText:"Loading full command output...",errorText:"Unable to load full command output.",useSelectionCallback:!0})},[d]),u=c.useCallback(async(p,g)=>{var b;await d({item:p,fallbackTitle:g,fallbackText:((b=p.detailText)==null?void 0:b.trim())||p.text||"Tool call",loadingText:"Loading full tool call details...",errorText:"Unable to load full tool call details.",useSelectionCallback:!0})},[d]),m=c.useCallback(async(p,g,b,v,x)=>{await d({item:p,fallbackTitle:g,fallbackText:b,loadingText:v,errorText:x,useSelectionCallback:!1})},[d]),f=c.useCallback(()=>{n.current+=1,o(null)},[]);return{expandedText:s,openExpandedText:l,openCommandDetail:h,openToolCallDetail:u,openDeferredHistoryItemDetail:m,closeExpandedText:f}}function Df(e){const r=c.useRef(null),n=c.useRef(0),a=r.current;return(a===null||a.length!==e.length||e.some((o,l)=>!Object.is(o,a[l])))&&(n.current+=1,r.current=e),n.current}function Bf({threadId:e,turnsLength:r,totalTurnCount:n,loadingEarlier:a,onLoadEarlier:s,scrollRequestKey:o,bottomSpacer:l,onTailVisibilityChange:i,contentRevisionInputs:d}){const h=c.useRef(null),u=c.useRef(null),m=c.useRef(o),f=c.useRef(null),p=c.useRef(l),g=c.useRef(0),b=c.useRef(0),v=c.useRef(null),x=c.useRef(null),y=c.useRef(!0),k=c.useRef(!0),j=c.useRef(!1),w=c.useRef(!1),N=c.useRef(!1),[S,L]=c.useState(js),[T,q]=c.useState(0),[A,D]=c.useState(!0),J=Df(d),W=typeof s=="function"||n!==void 0,O=n??r,ee=W?0:Math.max(0,r-S),E=(W?Math.max(0,O-r):0)+ee,re=W?r:r-ee,_=W?0:r-re,V=W?Math.max(0,O-r):0,U=W?V+_:_,z=!W&&U>0&&T>=2,X=W&&V>0&&_===0&&typeof s=="function",F=c.useCallback(()=>{const M=h.current,Y=v.current;if(!M)return;const te=Y?Mf(M,Y):sr(M);y.current=te,D(ie=>ie===te?ie:te)},[]),I=c.useCallback(()=>{const M=h.current;if(M){w.current=!0;const Y=M.scrollTop,te=b.current,ie=Y-te;b.current=Y,sr(M,1)?(j.current=!1,k.current=!0):ie<-1?(j.current=!0,k.current=!1):ie>1&&(k.current=!j.current&&sr(M,Un))}F()},[F]),P=c.useCallback(()=>{const M=h.current;M&&(M.scrollTop=M.scrollHeight,b.current=M.scrollTop,g.current=M.scrollHeight,y.current=!0,D(Y=>Y||!0),j.current=!1,k.current=!0)},[]),Z=c.useCallback(()=>{const M=h.current;M&&(b.current=M.scrollTop,g.current=M.scrollHeight,k.current=!1,j.current=!0)},[]),K=c.useCallback(()=>{if(W&&_===0){s==null||s();return}L(M=>Math.min(r,M+Rf)),q(M=>M+1)},[_,s,W,r]),de=c.useCallback(()=>{L(r)},[r]);return c.useLayoutEffect(()=>{const M=window.requestAnimationFrame(()=>{P()});return()=>{window.cancelAnimationFrame(M)}},[e,P]),c.useEffect(()=>{N.current=!1,w.current=!1},[e]),c.useEffect(()=>{a||(N.current=!1)},[a,r]),c.useEffect(()=>{L(M=>M>=r-1?r:Math.max(M,js))},[r]),c.useEffect(()=>{const M=h.current;M&&(g.current=M.scrollHeight,b.current=M.scrollTop,sr(M,1)?(j.current=!1,k.current=!0):(j.current||!sr(M,Un))&&(k.current=!1)),F()},[J,F,S]),c.useEffect(()=>{const M=o!==m.current,Y=f.current!==J;if(f.current=J,!(M||Y&&k.current&&!j.current))return;const ie=window.requestAnimationFrame(()=>{P()});return o!==m.current&&(m.current=o),()=>{window.cancelAnimationFrame(ie)}},[J,A,P,o]),c.useEffect(()=>{const M=h.current,Y=u.current;if(!M||!Y||typeof ResizeObserver>"u")return;g.current=M.scrollHeight;const te=new ResizeObserver(()=>{const ie=M.scrollHeight,ue=g.current;if(g.current=ie,ie<=ue)return;const be=ue>0&&ue-M.scrollTop-M.clientHeight<=1;j.current||!(k.current||be||y.current)||window.requestAnimationFrame(()=>{P()})});return te.observe(Y),()=>{te.disconnect()}},[P]),c.useEffect(()=>{if(!k.current||j.current){p.current=l;return}if(l===p.current)return;p.current=l;const M=window.requestAnimationFrame(()=>{P()});return()=>{window.cancelAnimationFrame(M)}},[l,P]),c.useEffect(()=>{i==null||i(A)},[A,i]),c.useEffect(()=>{const M=h.current,Y=x.current;if(!M||!Y||!X||a||N.current||typeof IntersectionObserver>"u")return;const te=new IntersectionObserver(ie=>{!w.current||a||N.current||!ie.some(ue=>ue.isIntersecting)||(N.current=!0,s==null||s())},{root:M,threshold:.01});return te.observe(Y),()=>{te.disconnect()}},[X,a,s]),{scrollContainerRef:h,scrollContentRef:u,tailSentinelRef:v,topSentinelRef:x,isTailVisible:A,handleScroll:I,preserveScrollPositionForResize:Z,serverManagedHistory:W,effectiveTotalTurnCount:O,startIndex:ee,visibleTurnAbsoluteOffset:E,hiddenCount:U,loadedHiddenCount:_,unloadedHiddenCount:V,showLoadAll:z,handleLoadEarlierClick:K,handleLoadAllClick:de}}function Gf(e){return e==="completed"||e==="failed"||e==="interrupted"}function Ff(e,r){if(!r||r.id!==e.id||r.items.length===0)return e;const n=new Set(e.items.map(s=>s.id)),a=r.items.filter(s=>!n.has(s.id));return a.length===0?e:{...e,items:[...a,...e.items]}}function Hf({threadId:e,turns:r,totalTurnCount:n,pendingRequests:a=[],activeTurnId:s=null,threadRunning:o=!1,pendingSteers:l=[],livePlan:i=null,liveItems:d=null,respondingRequestId:h=null,onRespondToRequest:u,liveOutput:m,scrollRequestKey:f=0,bottomSpacer:p=0,className:g="",onTailVisibilityChange:b,loadingEarlier:v=!1,onLoadEarlier:x,ephemeralUserNote:y=null,answeredRequestNotes:k=[],activityNotes:j=[],optimisticSteers:w=[],optimisticTurn:N=null,onLoadHistoryItemDetail:S,onOpenThread:L,onSelectArtifact:T,onSelectHistoryItemDetail:q,adapter:A,autoCollapseCompletedTurns:D}){var lt,He,tt,it,Ye;const J=Jo(),W=D??(J==null?void 0:J.autoCollapseCompletedTurns)??!1,[O,ee]=c.useState({}),[he,E]=c.useState(()=>new Set),re=(A==null?void 0:A.onLoadHistoryItemDetail)??S,_=A==null?void 0:A.onOpenLinkedThread,{expandedText:V,openExpandedText:U,openCommandDetail:z,openToolCallDetail:X,openDeferredHistoryItemDetail:F,closeExpandedText:I}=$f({loadHistoryItemDetail:re,onSelectHistoryItemDetail:q}),{scrollContainerRef:P,scrollContentRef:Z,tailSentinelRef:K,topSentinelRef:de,handleScroll:M,preserveScrollPositionForResize:Y,serverManagedHistory:te,effectiveTotalTurnCount:ie,startIndex:ue,visibleTurnAbsoluteOffset:be,hiddenCount:Le,loadedHiddenCount:ae,unloadedHiddenCount:ve,showLoadAll:ke,handleLoadEarlierClick:pe,handleLoadAllClick:ze}=Bf({threadId:e,turnsLength:r.length,totalTurnCount:n,loadingEarlier:v,onLoadEarlier:x,scrollRequestKey:f,bottomSpacer:p,onTailVisibilityChange:b,contentRevisionInputs:[r,a,l,w,m,i,d,N,k,j,y,p]}),je=c.useCallback((C,B)=>{ee(se=>({...se,[C]:!B}))},[]),Me=c.useCallback((C,B)=>{const se=O[C.id];return se!==void 0?se:!!(W&&Gf(C.status)&&!B.forceActive&&!B.hasLiveActivity)},[O,W]),Pe=te?r:r.slice(ue),_e=ie+1,Ce=o&&(!s||!Pe.some(C=>C.id===s)&&(N==null?void 0:N.id)!==s),Re=(N==null?void 0:N.id)??((lt=Pe.at(-1))==null?void 0:lt.id)??null,H=Ce&&Re!==null,ce=!!d&&(Pe.some(C=>C.id===d.turnId)||(N==null?void 0:N.id)===d.turnId),R=d&&ce?d.turnId:d&&H?Re:null,$=N&&R===N.id?(d==null?void 0:d.items)??null:null,Q=((d==null?void 0:d.items.length)??0)>0,me=d&&R===null?d.items:null,xe=c.useMemo(()=>d&&R===null&&d.items.length>0?Af(d.turnId,d.items):null,[d,R]),Ie=Math.max(1,ie+(N?1:0)),ge=!!m&&!!N&&N.status!=="failed"&&!$,Ae=m&&Pe.length>0?s&&Pe.some(C=>C.id===s)?s:((He=Pe.findLast(C=>sl(C.status)))==null?void 0:He.id)??(H?Re:null):null,at=!!Ae,Je=c.useMemo(()=>al(m),[m]),Qe=[...l.map(C=>({id:C.id,prompt:C.prompt,status:"Accepted",createdAt:C.createdAt,canCancel:!0})),...w.map(C=>({id:C.id,prompt:C.prompt,status:C.status==="steering"?"Steering":null,createdAt:C.createdAt,canCancel:!1}))].sort((C,B)=>C.createdAt.localeCompare(B.createdAt)),De=c.useMemo(()=>zp({answeredRequestNotes:k,pendingRequests:a,visibleTurns:Pe,optimisticTurn:N}),[k,N,a,Pe]),Be=c.useMemo(()=>Ip({activityNotes:j,visibleTurns:Pe,optimisticTurn:N}),[j,N,Pe]);return t.jsxs(t.Fragment,{children:[t.jsx("section",{className:`flex min-h-0 flex-1 flex-col ${g}`.trim(),children:t.jsx("div",{ref:P,"data-testid":"thread-scroll-container",onScroll:M,className:"thread-graph-scroll-container min-h-0 flex-1 overflow-y-auto overscroll-contain",style:p>0?{paddingBottom:p}:void 0,children:t.jsxs("div",{ref:Z,className:"thread-graph-scroll-content",children:[t.jsx("div",{ref:de,"aria-hidden":"true",className:"h-px"}),r.length>0&&t.jsx("div",{className:"thread-graph-history-control px-3 pb-1 pt-2 sm:px-5 sm:pb-1.5 sm:pt-3",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 text-xs sm:text-sm",children:[Le>0&&t.jsx("button",{type:"button",onClick:pe,disabled:v,className:"thread-graph-history-button rounded-full border px-2.5 py-1.5 transition",children:v?"Loading earlier...":"Load 3 earlier"}),ke&&t.jsx("button",{type:"button",onClick:ze,className:"rounded-full border border-amber-300/40 px-2.5 py-1.5 text-amber-200 transition hover:bg-amber-300/10",children:"Load full history"}),t.jsxs("p",{className:"timeline-meta-text",children:["Showing ",Pe.length," of ",ie," turns",Le>0?` · ${Le} earlier hidden${ae>0&&ve>0?` (${ae} loaded)`:""}`:""]})]})}),r.length===0&&!m&&!N&&t.jsx("div",{className:"thread-graph-empty-state px-3 py-8 text-sm sm:px-5",children:"Send the first prompt to start the thread."}),(Pe.length>0||N||Be.leading.length>0||Be.trailing.length>0)&&t.jsxs("div",{className:"thread-graph-message-list",children:[Be.leading.length>0?t.jsx(ar,{notes:Be.leading,onOpenThread:L,onOpenLinkedThread:_}):null,Pe.map((C,B)=>{var se,ye,Oe,rt,nt;return t.jsxs("div",{children:[(((se=Be.beforeTurnId.get(C.id))==null?void 0:se.length)??0)>0?t.jsx(ar,{notes:Be.beforeTurnId.get(C.id)??[],onOpenThread:L,onOpenLinkedThread:_}):null,(((ye=De.beforeTurnId.get(C.id))==null?void 0:ye.length)??0)>0?t.jsx(Hn,{entries:De.beforeTurnId.get(C.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const Ge=Ff(C,N),Ve=(i==null?void 0:i.turnId)===C.id?i:null,ht=R===C.id?(d==null?void 0:d.items)??null:null,bt=Ae===C.id?m:"",fe=s===C.id||H&&Re===C.id,Te=!!Ve||!!bt||!!(ht&&ht.length>0),Ze=Me(Ge,{forceActive:fe,hasLiveActivity:Te});return t.jsx(bn,{threadId:e,...A?{adapter:A}:{},turn:Ge,absoluteIndex:be+B+1,isCollapsed:Ze,livePlan:Ve,liveItems:ht,liveOutput:bt,forceActive:fe,onToggleCollapse:je,onOpenExpandedText:U,onOpenCommandDetail:z,onOpenToolCallDetail:X,onOpenDeferredHistoryItemDetail:F,onBeforeMessageResize:Y,...T?{onSelectArtifact:T}:{},scrollRootRef:P,articleRef:void 0})})(),(((Oe=Be.afterTurnId.get(C.id))==null?void 0:Oe.length)??0)>0?t.jsx(ar,{notes:Be.afterTurnId.get(C.id)??[],onOpenThread:L,onOpenLinkedThread:_}):null,(rt=De.notesByTurnId.get(C.id))!=null&&rt.length||(nt=De.pendingRequestsByTurnId.get(C.id))!=null&&nt.length?t.jsx(Rp,{notes:De.notesByTurnId.get(C.id)??[],requests:De.pendingRequestsByTurnId.get(C.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null]},C.id)}),N&&Pe.every(C=>C.id!==N.id)&&t.jsxs(t.Fragment,{children:[(((tt=Be.beforeTurnId.get(N.id))==null?void 0:tt.length)??0)>0?t.jsx(ar,{notes:Be.beforeTurnId.get(N.id)??[],onOpenThread:L,onOpenLinkedThread:_}):null,(((it=De.beforeTurnId.get(N.id))==null?void 0:it.length)??0)>0?t.jsx(Hn,{entries:De.beforeTurnId.get(N.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const C=ge?m:"",B=s===N.id||H&&Re===N.id,se=!!($&&$.length>0)||!!C,ye=Me(N,{forceActive:B,hasLiveActivity:se});return t.jsx(bn,{threadId:e,...A?{adapter:A}:{},turn:N,absoluteIndex:_e,isCollapsed:ye,livePlan:null,liveItems:$,liveOutput:C,forceActive:B,onToggleCollapse:je,onOpenExpandedText:U,onOpenCommandDetail:z,onOpenToolCallDetail:X,onOpenDeferredHistoryItemDetail:F,onBeforeMessageResize:Y,...T?{onSelectArtifact:T}:{},scrollRootRef:P})})(),(((Ye=Be.afterTurnId.get(N.id))==null?void 0:Ye.length)??0)>0?t.jsx(ar,{notes:Be.afterTurnId.get(N.id)??[],onOpenThread:L,onOpenLinkedThread:_}):null]})]}),Qe.length>0&&t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:Qe.map(C=>t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(_t,{threadId:e,item:{id:C.id,kind:"userMessage",text:C.prompt,status:C.status},scrollRootRef:P,onBeforeMessageResize:Y,...A?{adapter:A}:{}}),e&&C.canCancel&&(A!=null&&A.cancelPendingSteer)?t.jsx("div",{className:"flex justify-end px-1",children:t.jsx("button",{type:"button",className:"thread-graph-history-button rounded-full border px-2.5 py-1 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",disabled:he.has(C.id),onClick:()=>{var B;E(se=>new Set(se).add(C.id)),Promise.resolve((B=A.cancelPendingSteer)==null?void 0:B.call(A,e,C.id)).catch(()=>{}).finally(()=>{E(se=>{const ye=new Set(se);return ye.delete(C.id),ye})})},children:he.has(C.id)?"Canceling...":"Cancel"})}):null]},C.id))}),(De.trailing.length>0||Be.trailing.length>0)&&t.jsx(Mp,{entries:[...Be.trailing.map(C=>({kind:"activity",id:C.id,createdAt:C.createdAt,note:C})),...De.trailing],respondingRequestId:h,onRespondToRequest:u??void 0,onOpenThread:L,onOpenLinkedThread:_}),y&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:t.jsx(_t,{threadId:e,item:{id:"ephemeral-plan-decision-note",kind:"userMessage",text:y},scrollRootRef:P,onBeforeMessageResize:Y})}),xe&&me&&me.length>0&&t.jsx(bn,{threadId:e,...A?{adapter:A}:{},turn:xe,absoluteIndex:Ie,isCollapsed:O[xe.id]??!1,livePlan:(i==null?void 0:i.turnId)===xe.id?i:null,liveItems:me,liveOutput:"",forceActive:!0,onToggleCollapse:je,onOpenExpandedText:U,onOpenCommandDetail:z,onOpenToolCallDetail:X,onOpenDeferredHistoryItemDetail:F,onBeforeMessageResize:Y,...T?{onSelectArtifact:T}:{},scrollRootRef:P}),m&&!at&&!ge&&!Q&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:Je?t.jsx(aa,{threadId:e,item:Je,scrollRootRef:P,onOpenExpandedText:U,onOpenCommandDetail:z,onOpenToolCallDetail:X,onOpenDeferredHistoryItemDetail:F,onBeforeMessageResize:Y,...T?{onSelectArtifact:T}:{},...A?{adapter:A}:{}}):t.jsx(_t,{threadId:e,item:{id:"live-agent-message-fallback",kind:"agentMessage",text:m},scrollRootRef:P,streaming:!0,onBeforeMessageResize:Y,...A?{adapter:A}:{}})}),t.jsx("div",{ref:K,"aria-hidden":"true",className:"h-px w-full"})]})})}),t.jsx(Ym,{open:V!==null,title:(V==null?void 0:V.title)??"Full text",text:(V==null?void 0:V.text)??"",onClose:I})]})}var fl=c.memo(Hf);function Of(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}function Wn(e){return e.replace(/\r\n/g,`
|
|
3614
|
-
`)}function
|
|
3619
|
+
`);for(;r.length>1&&((n=r.at(-1))==null?void 0:n.trim())==="";)r.pop();return r}function pt(e){const r=Op(e);return r.length===1?{firstLine:r[0]??"",showGap:!1,isTruncated:!1}:{firstLine:r[0]??"",showGap:!0,isTruncated:!0}}function hl(e){const r=(e==null?void 0:e.trim().toLowerCase())??"";return r==="completed"||r==="complete"||r==="success"||r==="succeeded"?{className:"is-completed",icon:t.jsx(G.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"}:r==="failed"||r==="failure"||r==="error"||r==="errored"?{className:"is-failed",icon:t.jsx(G.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"}:qr(e)?{className:"is-pending",icon:t.jsx(G.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),label:(e==null?void 0:e.trim())||"Running"}:{className:"is-neutral",icon:null,label:(e==null?void 0:e.trim())||"Event"}}function Up(e){switch(e){case"command":return"is-command";case"tool":return"is-tool";case"agent":return"is-agent";case"skill":return"is-skill";case"search":return"is-search";case"fileRead":return"is-file-read"}}function Wp(e){switch(e){case"plan":return"is-plan";case"context":return"is-context";case"generic":return"is-generic";case"image":return"is-image";case"fileChange":return"is-file-change";case"artifact":return"is-artifact";case"hook":return"is-hook"}}function Dt({actions:e,children:r,className:n,headerMeta:a,icon:s,item:o,title:l,tone:i}){const d=hl(o.status);return t.jsxs("div",{className:`thread-graph-event thread-graph-history-event ${Wp(i)} ${n??""}`,children:[t.jsx("div",{className:"thread-graph-history-event-icon","aria-hidden":"true",children:s}),t.jsxs("div",{className:"thread-graph-history-event-card",children:[t.jsxs("div",{className:"thread-graph-history-event-header",children:[t.jsxs("div",{className:"thread-graph-history-event-heading flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-event-title min-w-0 truncate font-mono text-sm font-semibold",children:l}),o.status?t.jsxs(Kr,{variant:"outline",className:`thread-graph-tool-badge ${d.className} rounded-full px-2 py-0.5 text-xs font-normal`,title:d.label,"aria-label":`Status: ${d.label}`,children:[d.icon,t.jsx("span",{className:"thread-graph-status-label",children:d.label})]}):null,a]}),e?t.jsx("div",{className:"thread-graph-history-event-actions",children:e}):null]}),r?t.jsx("div",{className:"thread-graph-history-event-body",children:r}):null]})]})}function er({actionLabel:e="Open details",actionTitle:r,className:n,details:a,icon:s,item:o,onOpen:l,preview:i,title:d,tone:h}){const u=hl(o.status),[m,f]=c.useState(qr(o.status)?"item-1":void 0);return t.jsx("div",{className:`thread-graph-event thread-graph-history-tool ${Up(h)} ${n??""}`,children:t.jsx(pr,{type:"single",collapsible:!0,onValueChange:p=>f(p||void 0),className:"thread-graph-tool-accordion thread-graph-history-tool-accordion w-full overflow-hidden rounded-lg border",...m!==void 0?{value:m}:{},children:t.jsxs(fr,{value:"item-1",className:"border-0",children:[t.jsx(Ur,{"aria-label":`${m==="item-1"?"Collapse":"Expand"} ${d} history item`,className:"thread-graph-tool-trigger thread-graph-history-tool-trigger px-4 py-3 hover:no-underline",children:t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-tool-icon shrink-0",children:s}),t.jsx("span",{className:"min-w-0 truncate font-mono text-sm font-semibold",children:d}),t.jsxs(Kr,{variant:"outline",className:`thread-graph-tool-badge ${u.className} ml-1 sm:ml-2 rounded-full px-2 py-0.5 text-xs font-normal`,title:u.label,"aria-label":`Status: ${u.label}`,children:[u.icon,t.jsx("span",{className:"thread-graph-status-label",children:u.label})]})]})}),t.jsxs(gr,{className:"thread-graph-tool-content thread-graph-history-tool-content px-4 pb-4 pt-1",children:[t.jsxs("section",{children:[t.jsx("h4",{children:"Summary"}),t.jsxs("div",{className:"thread-graph-history-tool-summary",children:[t.jsx(Jt,{text:i.firstLine}),i.showGap?t.jsx("span",{className:"thread-graph-history-tool-ellipsis",children:"..."}):null]})]}),a?t.jsx("section",{children:a}):null,t.jsxs("button",{type:"button","aria-label":e,onClick:l,className:"thread-graph-history-tool-open inline-flex items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium transition",children:[t.jsx(G.ExternalLink,{className:"h-3.5 w-3.5"}),r]})]})]})})})}var Vp=c.memo(function({item:r,scrollRootRef:n,onBeforeResize:a}){return t.jsx(Dt,{className:"thread-graph-event-plan",icon:t.jsx(G.ClipboardList,{className:"h-4 w-4"}),item:r,title:"plan",tone:"plan",children:t.jsx("div",{className:"thread-graph-history-event-prose",children:t.jsx(rl,{text:r.text,scrollRootRef:n,plainTextClassName:"thread-graph-plain-text whitespace-pre-wrap break-words text-sm leading-6",markdownClassName:"thread-graph-markdown text-sm",...a?{onBeforeResize:a}:{}})})})}),Kp=c.memo(function({item:r}){const n=qr(r.status)||r.text==="Compacting context",a=n?"Compacting context":"Context compacted",s=r.detailText&&r.detailText!==a?r.detailText:null;return t.jsxs(Dt,{className:"thread-graph-event-context",icon:t.jsx(G.Archive,{className:"h-4 w-4"}),item:r,title:"context",tone:"context",children:[t.jsxs("div",{className:"thread-graph-history-event-line",children:[t.jsx("span",{className:"thread-graph-history-event-primary",children:a}),n?t.jsx(Hn,{tone:"emerald"}):null]}),s?t.jsx("p",{className:"thread-graph-history-event-secondary",title:s,children:s}):null]})}),qp=c.memo(function({item:r}){return t.jsx(Dt,{className:"thread-graph-event-generic",icon:t.jsx(G.Info,{className:"h-4 w-4"}),item:r,title:r.kind,tone:"generic",children:t.jsx("pre",{className:"thread-graph-history-event-pre",children:t.jsx(Jt,{text:r.text})})})}),Xp=c.memo(function({item:r,onOpen:n}){const a=pt(r.previewText??r.text);return t.jsx(er,{actionLabel:"Open full command",actionTitle:"Command Output",className:"thread-graph-event-command",icon:t.jsx(G.Terminal,{className:"h-4 w-4"}),item:r,onOpen:()=>n(r,"Command Output"),preview:a,title:"command",tone:"command"})}),Yp=c.memo(function({item:r,onOpen:n}){const a=pt(r.text);return t.jsx(er,{actionLabel:"Open full tool call",actionTitle:"Tool Call Details",className:"thread-graph-event-tool",icon:t.jsx(G.Wrench,{className:"h-4 w-4"}),item:r,onOpen:()=>n(r,"Tool Call Details"),preview:a,title:"tool_call",tone:"tool"})}),Zp=c.memo(function({item:r,onOpen:n}){const a=pt(r.text);return t.jsx(er,{actionLabel:"Open agent details",actionTitle:"Agent Details",className:"thread-graph-event-agent-tool",icon:t.jsx(G.Bot,{className:"h-4 w-4"}),item:r,onOpen:()=>n(r,"Agent Details"),preview:a,title:"agent",tone:"agent"})}),Jp=c.memo(function({item:r,onOpen:n}){const a=pt(r.text);return t.jsx(er,{actionLabel:"Open skill details",actionTitle:"Skill Details",className:"thread-graph-event-skill-tool",icon:t.jsx(G.Sparkles,{className:"h-4 w-4"}),item:r,onOpen:()=>n(r,"Skill Details"),preview:a,title:"skill",tone:"skill"})}),Qp=c.memo(function({item:r,onOpen:n}){var l,i;const a=((l=r.previewText)==null?void 0:l.trim())||r.text||"Web search",s=((i=r.detailText)==null?void 0:i.trim())||r.text||"Web search",o=pt(a);return t.jsx(er,{actionLabel:"Open full web search",actionTitle:"Web Search Details",className:"thread-graph-event-search",icon:t.jsx(G.Search,{className:"h-4 w-4"}),item:r,onOpen:()=>n("Web Search Details",s),preview:o,title:"web_search",tone:"search"})}),ef=c.memo(function({item:r,onOpen:n}){var l,i;const a=((l=r.previewText)==null?void 0:l.trim())||r.text||"File read",s=((i=r.detailText)==null?void 0:i.trim())||r.text||"File read",o=pt(a);return t.jsx(er,{actionLabel:"Open full file read",actionTitle:"File Read Details",className:"thread-graph-event-file-read",icon:t.jsx(G.FileText,{className:"h-4 w-4"}),item:r,onOpen:()=>n("File Read Details",s),preview:o,title:"file_read",tone:"fileRead"})}),tf=c.memo(function({threadId:r,item:n,onOpen:a,getImageAssetUrl:s}){const o=n.assetPath??n.detailText??null,l=r&&o?(s==null?void 0:s({threadId:r,path:o}))??null:null;return t.jsxs(Dt,{className:"thread-graph-event-image",icon:t.jsx(G.Image,{className:"h-4 w-4"}),item:n,title:"image",tone:"image",children:[l?t.jsx("button",{type:"button",onClick:()=>a("Image Path",o??n.text),className:"block w-full text-left",children:t.jsx("img",{src:l,alt:n.text||"Image preview",className:"thread-graph-history-event-image",loading:"lazy"})}):t.jsx("div",{className:"thread-graph-history-event-summary",children:n.text}),o?t.jsx("button",{type:"button",onClick:()=>a("Image Path",o),className:"thread-graph-history-event-path",title:o,children:o}):null]})}),rf=c.memo(function({item:r,onOpen:n}){var u,m,f;const a=(u=r.previewText)!=null&&u.trim()&&r.text.trim()!==r.previewText.trim()?r.text.trim():null,s=((m=r.detailText)==null?void 0:m.trim())||null,o=cl(a??((f=r.previewText)==null?void 0:f.trim())??r.text,48),l=Hp(r),i=!!(s||r.hasDeferredDetail),d=t.jsxs("div",{className:"thread-graph-event-line thread-graph-file-change-inline flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip text-sm",title:a??o,children:o}),l.length>0&&t.jsx("div",{className:"inline-flex shrink-0 items-center justify-end gap-1.5 text-xs",children:l.map(p=>t.jsx("span",{className:`thread-graph-history-delta-badge ${p.startsWith("+")?"is-add":p.startsWith("-")?"is-remove":"is-neutral"}`,children:p},p))})]}),h=i?t.jsx("button",{type:"button","aria-label":"Open file change details",onClick:()=>n("File Change Details",s??r.text),className:"thread-graph-file-change-inline-button min-w-0 flex-1 text-left",title:a??o,children:d}):d;return t.jsx(Dt,{className:"thread-graph-event-file-change",headerMeta:h,icon:t.jsx(G.FilePenLine,{className:"h-4 w-4"}),item:r,title:"file_change",tone:"fileChange"})}),nf=c.memo(function({item:r,onSelect:n}){const a=ra(),[s,o]=c.useState(!1),l=r.artifact,i=l?a.renderArtifact({artifact:l,expanded:s,onToggleExpanded:()=>o(d=>!d)}):null;return t.jsx(Dt,{actions:t.jsxs("span",{className:"inline-flex items-center gap-2",children:[l&&!a.hasRendererForArtifact(l)?t.jsx("span",{className:"thread-graph-history-event-secondary",children:"No renderer"}):null,l&&n?t.jsxs("button",{type:"button","aria-label":`Open artifact inspector for ${l.title}`,onClick:()=>n(r,l),className:"thread-graph-history-event-action",children:[t.jsx(G.PackageOpen,{className:"h-3.5 w-3.5"}),"Inspect"]}):null]}),className:"thread-graph-event-artifact",icon:t.jsx(G.PackageOpen,{className:"h-4 w-4"}),item:r,title:(l==null?void 0:l.type)??"artifact",tone:"artifact",children:i??t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:()=>o(d=>!d),className:"thread-graph-history-event-summary is-clickable flex w-full items-center justify-between gap-3 text-left",children:[t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"thread-graph-history-event-primary block truncate",children:(l==null?void 0:l.title)??r.text}),t.jsx("span",{className:"thread-graph-history-event-secondary mt-1 block truncate",children:(l==null?void 0:l.summaryText)??r.previewText??r.text})]}),t.jsx("span",{className:"thread-graph-history-event-pill",children:s?"Hide":"Open"})]}),s?t.jsx("pre",{className:"thread-graph-history-event-pre max-h-80 overflow-auto",children:JSON.stringify((l==null?void 0:l.payload)??r,null,2)}):null]})})}),af=c.memo(function({item:r}){var d,h;const n=((d=r.hookOutputEntries)==null?void 0:d.map(u=>u.text.trim()).filter(Boolean).join(`
|
|
3620
|
+
`).trim())??"",a=r.hookEventLabel?`${r.hookEventLabel} hook`:r.text,s=((h=r.hookStatusMessage)==null?void 0:h.trim())||(r.previewText&&r.previewText!==r.hookStatusMessage?r.previewText.trim():"")||r.text.trim(),l=pt(n||(s&&s!==a?s:a)),i=!!(n&&l.showGap);return t.jsx(Dt,{className:"thread-graph-event-hook",icon:t.jsx(G.Webhook,{className:"h-4 w-4"}),item:r,title:r.hookEventLabel?`${r.hookEventLabel}_hook`:"hook",tone:"hook",children:t.jsxs("div",{className:"thread-graph-history-event-line",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:n?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"thread-graph-history-event-secondary mr-2 font-sans text-[11px] uppercase",children:a}),t.jsx(Jt,{text:l.firstLine})]}):t.jsx(Jt,{text:l.firstLine&&l.firstLine!==a?`${a} · ${l.firstLine}`:a})}),i?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})})}),sf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s}){const o=r.filter(i=>qr(i.status)).length,l=r.length===1?"1 command":`${r.length} commands`;return t.jsx(Vr,{className:"thread-graph-history-group-command",count:r.length,countBadgeClassName:"border-amber-200/35 text-amber-100",desktopIconClassName:"border-amber-300/30 bg-amber-300/[0.14] text-amber-100",expanded:n,expandedListClassName:"border-amber-300/12",icon:t.jsx(Bp,{}),onToggleExpanded:a,runningIndicator:o>0?t.jsx(Hn,{}):null,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-amber-300/28 bg-amber-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-amber-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:l}),o>0?t.jsx("span",{className:"inline-flex items-center text-xs text-amber-100/90",children:t.jsx(Hn,{})}):null]}),toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} command entries`,children:r.map((i,d)=>{const h=pt(i.text);return t.jsxs("button",{type:"button","aria-label":`Open grouped command ${d+1}`,onClick:()=>s(i,`Command Output ${d+1}`),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"rounded-full border border-amber-300/18 bg-amber-300/[0.07] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-amber-100",children:["Step ",d+1]}),i.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:i.status})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2 text-sm leading-6",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:h.firstLine}),h.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},i.id)})})}),of=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s}){const o=r.length===1?"1 search":`${r.length} searches`;return t.jsx(Vr,{className:"thread-graph-history-group-search",count:r.length,countBadgeClassName:"border-sky-200/35 text-sky-100",desktopIconClassName:"border-sky-300/30 bg-sky-300/[0.14] text-sky-100",expanded:n,expandedListClassName:"border-sky-300/12",icon:t.jsx(Gp,{}),onToggleExpanded:a,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-sky-300/28 bg-sky-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-sky-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:o})]}),toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} web search entries`,children:r.map((l,i)=>{var m,f;const d=((m=l.previewText)==null?void 0:m.trim())||l.text||"Web search",h=pt(d),u=((f=l.detailText)==null?void 0:f.trim())||l.text||"Web search";return t.jsxs("button",{type:"button","aria-label":`Open grouped web search ${i+1}`,onClick:()=>s(`Web Search ${i+1}`,u),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"rounded-full border border-sky-300/18 bg-sky-300/[0.07] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-sky-100",children:["Search ",i+1]}),l.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:l.status})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2 text-sm leading-6",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:h.firstLine}),h.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},l.id)})})}),lf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s}){const o=r.length===1?"1 file read":`${r.length} file reads`;return t.jsx(Vr,{className:"thread-graph-history-group-file-read",count:r.length,countBadgeClassName:"border-cyan-200/35 text-cyan-100",desktopIconClassName:"border-cyan-300/30 bg-cyan-300/[0.14] text-cyan-100",expanded:n,expandedListClassName:"border-cyan-300/12",icon:t.jsx(Dp,{}),onToggleExpanded:a,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-cyan-300/28 bg-cyan-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-cyan-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:o})]}),toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} file read entries`,children:r.map((l,i)=>{var m,f;const d=((m=l.previewText)==null?void 0:m.trim())||l.text||"File read",h=pt(d),u=((f=l.detailText)==null?void 0:f.trim())||l.text||"File read";return t.jsxs("button",{type:"button","aria-label":`Open grouped file read ${i+1}`,onClick:()=>s(`File Read ${i+1}`,u),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"rounded-full border border-cyan-300/18 bg-cyan-300/[0.07] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-cyan-100",children:["Read ",i+1]}),l.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:l.status})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2 text-sm leading-6",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:h.firstLine}),h.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},l.id)})})}),df=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s}){const o=r.reduce((h,u)=>h+(u.changedFiles??0),0),l=r.reduce((h,u)=>h+(u.addedLines??0),0),i=r.reduce((h,u)=>h+(u.removedLines??0),0),d=r.length===1?"1 file change":`${r.length} file changes`;return t.jsx(Vr,{className:"thread-graph-history-group-file-change",count:r.length,countBadgeClassName:"border-lime-200/35 text-lime-100",desktopIconClassName:"border-lime-300/30 bg-lime-300/[0.14] text-lime-100",expanded:n,expandedListClassName:"border-lime-300/12",icon:t.jsx($p,{}),onToggleExpanded:a,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-lime-300/28 bg-lime-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-lime-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:d}),o>0?t.jsxs("span",{className:"thread-graph-history-detail-meta text-xs",children:[o," files"]}):null]}),toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} file change entries`,trailingSummary:t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[l>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-add",children:["+",l]}):null,i>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-remove",children:["-",i]}):null]}),children:r.map((h,u)=>{var p,g,b,v;const m=((p=h.detailText)==null?void 0:p.trim())||((g=h.previewText)==null?void 0:g.trim())||h.text,f=(b=h.previewText)!=null&&b.trim()&&h.text.trim()!==h.previewText.trim()?h.text.trim():((v=h.previewText)==null?void 0:v.trim())||h.text;return t.jsx("button",{type:"button","aria-label":`Open grouped file change ${u+1}`,onClick:()=>s(`File Change ${u+1}`,m),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-detail-text min-w-0 flex-1 text-sm leading-6",title:f,children:cl(f,34)}),t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[(h.addedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-add",children:["+",h.addedLines]}):null,(h.removedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-remove",children:["-",h.removedLines]}):null]})]})},h.id)})})});function cf(e){const r=e.trim().toLowerCase();return r==="completed"||r==="done"||r==="complete"?"completed":r==="in_progress"||r==="in-progress"||r==="running"||r==="active"?"in_progress":r==="failed"||r==="error"||r==="cancelled"?"failed":r==="pending"||r==="todo"?"pending":"unknown"}function hf({status:e}){const r=cf(e),n=r==="completed"?"Plan step status: Completed":r==="in_progress"?"Plan step status: In progress":r==="pending"?"Plan step status: Pending":r==="failed"?"Plan step status: Failed":`Plan step status: ${e}`,a=r==="completed"?"thread-graph-plan-status is-completed":r==="in_progress"?"thread-graph-plan-status is-running":r==="pending"?"thread-graph-plan-status is-pending":r==="failed"?"thread-graph-plan-status is-failed":"thread-graph-plan-status is-unknown";return t.jsx(Kr,{"aria-label":n,title:n.replace("Plan step status: ",""),className:a,children:r==="completed"?t.jsx(G.CheckCircle2,{className:"h-3.5 w-3.5"}):r==="in_progress"?t.jsx(G.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):r==="pending"?t.jsx(G.Clock3,{className:"h-3.5 w-3.5"}):r==="failed"?t.jsx(G.XCircle,{className:"h-3.5 w-3.5"}):t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.14em]",children:"?"})})}function uf({livePlan:e}){return t.jsxs("div",{className:"thread-graph-plan-card rounded-xl border px-3 py-3",children:[t.jsxs("div",{className:"thread-graph-plan-header flex flex-wrap items-center justify-between gap-2",children:[t.jsx("p",{className:"text-sm font-semibold",children:"Plan update"}),t.jsx(Kr,{className:"thread-graph-plan-badge",children:"Live"})]}),e.explanation?t.jsx("p",{className:"thread-graph-plan-explanation mt-3 text-sm",children:e.explanation}):null,t.jsx("div",{className:"mt-3 space-y-2",children:e.plan.map((r,n)=>t.jsxs("div",{className:"thread-graph-plan-step flex items-center justify-between gap-3 rounded-lg border px-3 py-2 text-sm",children:[t.jsx("span",{className:"thread-graph-plan-step-text min-w-0 flex-1",children:r.step}),t.jsx(hf,{status:r.status})]},`${e.turnId}-${n}`))})]})}function mf({footer:e,history:r,liveHookPrompt:n,liveOutput:a,livePlan:s}){return t.jsxs(t.Fragment,{children:[r,s?t.jsx(uf,{livePlan:s}):null,n??a??null,e]})}function pf({absoluteIndex:e,body:r,collapsed:n,collapsedBody:a,error:s,footer:o,headerStatus:l,isActive:i=!1,onToggleCollapse:d,refCallback:h,startedAt:u,timeLabel:m,timeTitle:f,tokenSummary:p}){return t.jsxs("article",{ref:h,"data-testid":"chat-turn","data-turn-active":i?"true":"false",className:"thread-graph-turn px-3 py-2 sm:px-5 sm:py-3",children:[t.jsxs("div",{className:"thread-graph-turn-header flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0 flex flex-1 items-start gap-1.5",children:[t.jsxs("div",{className:"min-w-0 flex flex-1 items-center gap-1.5 overflow-hidden",children:[t.jsxs("span",{className:"thread-graph-turn-index rounded-[0.6rem] border px-1.5 py-0.5 text-[10px] uppercase tracking-[0.16em]",children:["Turn ",e]}),t.jsx("time",{dateTime:u??void 0,title:f,className:"thread-graph-turn-time shrink-0 text-[10px] sm:text-[11px]",children:m}),l,s?t.jsx("p",{className:"hidden truncate text-[11px] text-rose-200 sm:block",children:s}):null]}),p]}),t.jsx("button",{type:"button","aria-label":`${n?"Expand":"Collapse"} turn ${e}`,title:n?"Expand turn":"Collapse turn",onClick:d,className:"thread-graph-turn-collapse inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-md transition",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:n?t.jsx("path",{d:"m4.5 10 3.5-3.5L11.5 10"}):t.jsx("path",{d:"m4.5 6 3.5 3.5L11.5 6"})})})]}),s?t.jsx("p",{className:"mt-1 text-[11px] text-rose-200 sm:hidden",children:s}):null,t.jsxs("div",{className:"thread-graph-turn-body mt-2 space-y-2",children:[n?a:r,n?null:o]})]})}function ff(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M8 2.75v8"}),t.jsx("path",{d:"m4.75 7.5 3.25 3.25L11.25 7.5"})]})}function gf(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M8 13.25v-8"}),t.jsx("path",{d:"m11.25 8.5-3.25-3.25L4.75 8.5"})]})}function xf(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.45",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M3.25 5.25 8 2.75l4.75 2.5L8 7.75l-4.75-2.5Z"}),t.jsx("path",{d:"M3.25 8 8 10.5 12.75 8"}),t.jsx("path",{d:"M3.25 10.75 8 13.25l4.75-2.5"}),t.jsx("path",{d:"M3.25 5.25v5.5"}),t.jsx("path",{d:"M12.75 5.25v5.5"})]})}function bf(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.45",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M6.2 3.2a2.3 2.3 0 0 0-2.95 3.5A2.4 2.4 0 0 0 4.5 11h.2c.25 1.1 1.1 1.8 2.3 1.8h1.8c1.2 0 2.05-.7 2.3-1.8h.2A2.4 2.4 0 0 0 12.75 6.7 2.3 2.3 0 0 0 9.8 3.2"}),t.jsx("path",{d:"M6.3 6.15c.45-.42 1.02-.65 1.7-.65s1.25.23 1.7.65"}),t.jsx("path",{d:"M8 5.5v4.75"}),t.jsx("path",{d:"M6.75 9.05 8 10.25l1.25-1.2"})]})}function Nr(e){if(!Number.isFinite(e)||e<=0)return"0";if(e>=1e6){const r=e>=1e7?Math.round(e/1e6):e/1e6;return`${String(r.toFixed(1)).replace(/\.0$/,"")}m`}if(e>=1e3){const r=e>=1e4?Math.round(e/1e3):e/1e3;return`${String(r.toFixed(1)).replace(/\.0$/,"")}k`}return String(Math.round(e))}function vf(e){return!Number.isFinite(e)||e<=0?"$0":e>=100?`$${Math.round(e)}`:e>=10?`$${String(e.toFixed(1)).replace(/\.0$/,"")}`:e>=1?`$${String(e.toFixed(2)).replace(/0$/,"").replace(/\.$/,"")}`:e>=.1?`$${e.toFixed(2)}`:e>=.01?`$${e.toFixed(3)}`:e>=.001?`$${e.toFixed(4)}`:"<$0.001"}function ir(e){return!Number.isFinite(e)||e<=0?"$0.0000":`$${e.toFixed(4)}`}function Cr(e,r,n){const a=e??null;return!Number.isFinite(a??NaN)||a===null||r<=0||n<=0?null:a*n/r}function ul(e){var i,d,h,u,m;const r=(i=e.tokenUsage)==null?void 0:i.total;if(!r)return[];const n=Math.max(r.inputTokens-r.cachedInputTokens,0),a=Math.max(r.cachedInputTokens,0),s=Math.max(r.reasoningOutputTokens,0),o=Math.max(r.outputTokens-s,0);return[n>0?{id:"in",label:"Input",tokenCompactValue:Nr(n),tokenRawValue:n,usdCompactValue:e.priceEstimate?ir(e.priceEstimate.inputUsd):"--",usdRawValue:((d=e.priceEstimate)==null?void 0:d.inputUsd)??null,className:"token-badge-in",icon:t.jsx(ff,{})}:null,a>0?{id:"cache",label:"Cached input",tokenCompactValue:Nr(a),tokenRawValue:a,usdCompactValue:e.priceEstimate?ir(e.priceEstimate.cachedInputUsd):"--",usdRawValue:((h=e.priceEstimate)==null?void 0:h.cachedInputUsd)??null,className:"token-badge-cache",icon:t.jsx(xf,{})}:null,o>0?{id:"out",label:"Output",tokenCompactValue:Nr(o),tokenRawValue:o,usdCompactValue:e.priceEstimate?ir(Cr(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),o)??0):"--",usdRawValue:Cr((u=e.priceEstimate)==null?void 0:u.outputUsd,Math.max(r.outputTokens,0),o),className:"token-badge-out",icon:t.jsx(gf,{})}:null,s>0?{id:"reason",label:"Reasoning",tokenCompactValue:Nr(s),tokenRawValue:s,usdCompactValue:e.priceEstimate?ir(Cr(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),s)??0):"--",usdRawValue:Cr((m=e.priceEstimate)==null?void 0:m.outputUsd,Math.max(r.outputTokens,0),s),className:"token-badge-reason",icon:t.jsx(bf,{})}:null].filter(f=>f!==null)}function kf(e){return ul(e).map(r=>({id:r.id,label:r.tokenCompactValue,title:`${r.label}: ${r.tokenRawValue} tokens`,className:r.className,icon:r.icon}))}function ml(e){return{label:e.priceEstimate?vf(e.priceEstimate.totalUsd):"--",title:e.priceEstimate===null||e.priceEstimate===void 0?"Price estimate unavailable for this model.":`Estimated cost: ${ir(e.priceEstimate.totalUsd)}`,className:e.priceEstimate?"token-badge-total":"token-badge-empty"}}var gn="inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-normal leading-none sm:text-[11px]";function wf({turn:e}){const r=ul(e),n=ml(e),[a,s]=c.useState(!1),[o,l]=c.useState(!1),[i,d]=c.useState(0),h=c.useRef(null),u=c.useRef(null),m=c.useRef(null);if(c.useLayoutEffect(()=>{if(!a||r.length===0){d(0);return}const p=()=>{const g=h.current,b=m.current;if(!g||!b)return;const v=g.getBoundingClientRect(),x=b.offsetWidth||b.getBoundingClientRect().width;if(x<=0)return;const y=window.innerWidth||document.documentElement.clientWidth,k=12,N=v.left+v.width/2-x/2,w=k,j=Math.max(w,y-k-x),C=Math.min(Math.max(N,w),j);d(Math.round(C-N))};return p(),window.addEventListener("resize",p),()=>{window.removeEventListener("resize",p)}},[r.length,a]),c.useEffect(()=>{if(!a&&!o)return;const p=g=>{g.target instanceof Node&&(h.current&&!h.current.contains(g.target)&&s(!1),u.current&&!u.current.contains(g.target)&&l(!1))};return document.addEventListener("pointerdown",p),()=>{document.removeEventListener("pointerdown",p)}},[o,a]),!n&&r.length===0)return null;const f=()=>t.jsx("div",{className:"thread-token-popover min-w-[12rem] rounded-2xl border p-2.5 shadow-2xl shadow-black/20 backdrop-blur",children:t.jsx("div",{className:"space-y-1",children:r.map(p=>t.jsxs("div",{className:"thread-token-popover-row flex items-center justify-between gap-3 rounded-xl border px-2.5 py-1.5 text-[11px]",title:`${p.label}: ${p.tokenRawValue} tokens`,children:[t.jsxs("span",{className:"thread-token-popover-text inline-flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"inline-flex shrink-0",children:p.icon}),t.jsx("span",{className:"thread-token-popover-strong font-medium",children:p.usdCompactValue})]}),t.jsx("span",{className:"thread-token-popover-text shrink-0 font-medium",children:p.tokenCompactValue})]},p.id))})});return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"hidden shrink-0 items-center gap-1.5 md:inline-flex",children:[n?t.jsxs("div",{ref:u,className:"relative shrink-0",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[t.jsx("button",{type:"button","aria-label":"Show token and price details","aria-expanded":o,onFocus:()=>l(!0),onBlur:()=>l(!1),className:`${gn} appearance-none whitespace-nowrap bg-transparent !text-[10px] !font-normal !leading-none transition hover:bg-[var(--theme-hover)] sm:!text-[11px] ${n.className}`,title:n.title,children:n.label}),o&&r.length>0?t.jsx("div",{className:"absolute left-1/2 top-full z-30 mt-1.5 -translate-x-1/2",children:f()}):null]}):null,r.map(p=>t.jsxs("span",{className:`${gn} ${p.className}`,title:`${p.label}: ${p.usdCompactValue}, ${p.tokenRawValue} tokens`,children:[p.icon,t.jsx("span",{className:"thread-token-badge-value font-medium",children:p.tokenCompactValue})]},p.id))]}),t.jsxs("div",{ref:h,className:"relative shrink-0 md:hidden",children:[n?t.jsx("button",{type:"button","aria-label":"Show token and price details","aria-expanded":a,onClick:()=>s(p=>!p),className:`${gn} appearance-none whitespace-nowrap bg-transparent !text-[10px] !font-normal !leading-none transition hover:bg-[var(--theme-hover)] sm:!text-[11px] ${n.className}`,title:n.title,children:n.label}):null,a&&r.length>0?t.jsx("div",{ref:m,className:"absolute left-1/2 top-full z-30 mt-1.5",style:{transform:`translateX(${i}px) translateX(-50%)`},children:f()}):null]})]})}function yf({tone:e="amber"}){const r=e==="emerald"?"bg-sky-200/90":e==="sky"?"bg-sky-300/90":"bg-amber-200/90";return t.jsx("span",{className:"ml-1.5 inline-flex items-center gap-1","aria-hidden":"true",children:[0,1,2].map(n=>t.jsx("span",{className:`h-1.5 w-1.5 rounded-full animate-pulse ${r}`,style:{animationDelay:`${n*180}ms`}},n))})}function vs(e){const r=e.trim().toLowerCase();return r==="completed"||r==="done"||r==="complete"?"completed":r==="in_progress"||r==="in progress"||r==="inprogress"||r==="running"||r==="active"?"in_progress":r==="pending"||r==="todo"||r==="not_started"||r==="not started"||r==="queued"?"pending":r==="failed"||r==="error"?"failed":"other"}function jf(e){switch(e.kind){case"fileChange":case"webSearch":case"image":case"contextCompaction":return!0;case"commandExecution":case"toolCall":return!al(e.status);default:return!1}}function Nf(e,r,n){if(!e||!Mr(n))return e;const a=e.plan.findIndex(i=>vs(i.status)==="in_progress");if(a<0)return e;const s=e.plan.findIndex((i,d)=>d>a&&vs(i.status)==="pending");if(s<0||!r.some(i=>jf(i)))return e;const l=e.plan.map((i,d)=>d===a?{...i,status:"completed"}:d===s?{...i,status:"in_progress"}:i);return{...e,plan:l}}function Cf(e){var a;const r=(a=e.model)!=null&&a.trim()?e.model.trim():"--";let n="--";return e.reasoningEffortAvailable===null||e.reasoningEffortAvailable===void 0?n="--":e.reasoningEffortAvailable===!1?n="-":n=e.reasoningEffort??"--",[r,n].join(" · ")}function ks({status:e}){const r=Jo(e);return e==="completed"?t.jsx("span",{"aria-label":r,title:r,className:"timeline-status-icon timeline-status-icon-success inline-flex h-4 w-4 items-center justify-center",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m3.75 8.25 2.5 2.5 6-6"})})}):e==="failed"?t.jsx("span",{"aria-label":r,title:r,className:"timeline-status-icon timeline-status-icon-failed inline-flex h-4 w-4 items-center justify-center",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m5 5 6 6M11 5l-6 6"})})}):e==="interrupted"?t.jsx("span",{"aria-label":r,title:r,className:"timeline-status-icon timeline-status-icon-warning inline-flex h-4 w-4 items-center justify-center",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M6 4.5v7M10 4.5v7"})})}):t.jsx("span",{"aria-label":r,title:r,className:"inline-flex min-w-[1.25rem] items-center justify-center text-sky-200",children:t.jsx(yf,{tone:"emerald"})})}function ws({turn:e,variant:r="header"}){const n=Jo(e.status),a=Cf(e),s=kf(e),o=ml(e),l=Mr(e.status),i=e.status==="failed"?"border-rose-300/20 bg-rose-300/[0.06] text-rose-100":l?"border-sky-300/22 bg-sky-300/[0.08] text-sky-100":"border-stone-700/90 bg-stone-900/70 text-stone-200";if(r==="footer")return t.jsxs("div",{className:`flex w-full flex-col gap-1.5 rounded-[0.95rem] border px-3 py-2 text-xs ${i}`,children:[t.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(ks,{status:e.status}),t.jsx("span",{className:"timeline-soft-text min-w-0 truncate",children:a})]}),e.startedAt&&t.jsx("time",{dateTime:e.startedAt,title:Zt(e.startedAt),className:"timeline-meta-text shrink-0 text-[11px]",children:_t(e.startedAt)})]}),(o||s.length>0)&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 pl-6",children:[o?t.jsx("span",{className:`inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${o.className}`,title:o.title,children:o.label}):null,s.map(h=>t.jsxs("span",{className:`inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${h.className}`,title:h.title,children:[h.icon?t.jsx("span",{className:"mr-1",children:h.icon}):null,h.label]},h.id))]})]});const d=`${n} · ${a}`;return t.jsxs("span",{className:`inline-flex min-w-0 items-center gap-1.5 rounded-full border px-2 py-1 text-[10px] sm:text-[11px] ${i}`,title:d,children:[t.jsx(ks,{status:e.status}),t.jsx("span",{className:"timeline-meta-text min-w-0 truncate",children:a})]})}function Sf(e,r){return e.createdAt??r}var na=c.memo(function({threadId:r,item:n,scrollRootRef:a,onOpenExpandedText:s,onOpenCommandDetail:o,onOpenToolCallDetail:l,onOpenDeferredHistoryItemDetail:i,onSelectArtifact:d,onBeforeMessageResize:h,adapter:u,timeLabel:m,timeTitle:f}){var p,g,b;if(Np(n.kind))return t.jsx(At,{threadId:r,item:n,scrollRootRef:a,timeLabel:m,timeTitle:f,...h?{onBeforeMessageResize:h}:{},...u?{adapter:u}:{}});if(n.kind==="artifact")return t.jsx(nf,{item:n,...d?{onSelect:(v,x)=>d({item:v,artifact:x})}:{}});if(n.kind==="commandExecution")return t.jsx(Xp,{item:n,onOpen:o});if(n.kind==="toolCall")return t.jsx(Yp,{item:n,onOpen:l});if(n.kind==="agentToolCall")return t.jsx(Zp,{item:n,onOpen:l});if(n.kind==="skillToolCall")return t.jsx(Jp,{item:n,onOpen:l});if(n.kind==="webSearch"){const v=n,x=((p=v.detailText)==null?void 0:p.trim())||v.text||"Web search";return t.jsx(Qp,{item:v,onOpen:()=>i(v,"Web Search Details",x,"Loading full web search details...","Unable to load full web search details.")})}if(n.kind==="fileRead"){const v=n,x=((g=v.detailText)==null?void 0:g.trim())||v.text||"File read";return t.jsx(ef,{item:v,onOpen:()=>i(v,"File Read Details",x,"Loading full file read details...","Unable to load full file read details.")})}if(n.kind==="image")return t.jsx(tf,{threadId:r,item:n,onOpen:s,getImageAssetUrl:u==null?void 0:u.getImageAssetUrl});if(n.kind==="plan")return t.jsx(Vp,{item:n,scrollRootRef:a,...h?{onBeforeResize:h}:{}});if(n.kind==="fileChange"){const v=n,x=((b=v.detailText)==null?void 0:b.trim())||v.text||"File change";return t.jsx(rf,{item:v,onOpen:()=>i(v,"File Change Details",x,"Loading full file change details...","Unable to load full file change details.")})}return n.kind==="contextCompaction"?t.jsx(Kp,{item:n}):n.kind==="hook"?t.jsx(af,{item:n}):t.jsx(qp,{item:n})});function Tf(e){return e==="completed"||e==="failed"||e==="interrupted"}function Ef(e){const r=Date.parse(e.createdAt??"");return Number.isFinite(r)?r:null}function Lf(e){let r=null;for(const n of e){const a=Ef(n);a!==null&&(r=r===null?a:Math.max(r,a))}return r}function Pf(e,r){const n=Date.parse(e??""),a=Lf(r);if(!Number.isFinite(n)||a===null||a<n)return"Worked";const s=Math.max(1,Math.round((a-n)/1e3)),o=Math.floor(s/3600),l=Math.floor(s%3600/60),i=s%60;return o>0?`Worked for ${o}h ${l}m`:l>0?`Worked for ${l}m ${i}s`:`Worked for ${i}s`}function If(e){const r=e.filter(a=>a.kind==="userMessage"),n=[...e].reverse().find(a=>a.kind==="agentMessage"&&a.text.trim().length>0);return{users:r,finalAgent:n,hiddenItems:e.filter(a=>a.kind!=="userMessage"&&a.id!==(n==null?void 0:n.id))}}var xn=c.memo(function({threadId:r,adapter:n,turn:a,absoluteIndex:s,isCollapsed:o,livePlan:l,liveItems:i,liveOutput:d,forceActive:h=!1,onToggleCollapse:u,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,onSelectArtifact:b,onBeforeMessageResize:v,scrollRootRef:x,articleRef:y,isLatestVisibleTurn:k=!1}){const N=!!l||!!d||!!(i&&i.length>0),w=h||Mr(a.status)||N||k,j=w&&!Mr(a.status)?{...a,status:"inProgress"}:a,C=c.useMemo(()=>Ep(a.items,i),[i,a.items]),L=c.useMemo(()=>Nf(l,C,a.status),[l,C,a.status]),T=c.useMemo(()=>Lp(d,C),[d,C]),q=c.useMemo(()=>Tp(C,w),[w,C]),M=c.useMemo(()=>Pp(q),[q]),D=_t(a.startedAt),J=Zt(a.startedAt),W=c.useMemo(()=>nl(T),[T]),[O,ee]=c.useState({}),he=c.useCallback(Z=>{ee(K=>({...K,[Z]:!K[Z]}))},[]),E=t.jsx(zf,{entries:M,expandedGroups:O,onToggleGroupedItem:he,threadId:r,scrollRootRef:x,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,...v?{onBeforeMessageResize:v}:{},fallbackTimestamp:a.startedAt,fallbackTimeLabel:D,fallbackTimeTitle:J,...b?{onSelectArtifact:b}:{},...n?{adapter:n}:{}}),re=W?t.jsx(na,{threadId:r,item:W,scrollRootRef:x,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,timeLabel:D,timeTitle:J,...b?{onSelectArtifact:b}:{},...n?{adapter:n}:{}}):null,A=!W&&T?t.jsx(At,{item:{id:"live-agent-message",kind:"agentMessage",text:T},scrollRootRef:x,timeLabel:D,timeTitle:J,streaming:!0,...v?{onBeforeMessageResize:v}:{}}):null,V=w?t.jsx(ws,{turn:j,variant:"footer"}):null,U=c.useMemo(()=>If(C),[C]),I=c.useMemo(()=>Pf(a.startedAt,C),[C,a.startedAt]),X=U.hiddenItems.length>0,F=o&&X,z=Tf(a.status)&&X?t.jsxs("div",{className:"thread-graph-turn-collapsed-summary space-y-2",children:[U.users.map(Z=>t.jsx(At,{threadId:r,item:Z,scrollRootRef:x,timeLabel:Z.createdAt?_t(Z.createdAt):D,timeTitle:Z.createdAt?Zt(Z.createdAt):J,...v?{onBeforeMessageResize:v}:{},...n?{adapter:n}:{}},Z.id)),t.jsxs("button",{type:"button",className:"thread-graph-worked-summary group flex w-full items-center gap-2 py-2 text-left text-sm transition",onClick:()=>u(a.id,!0),"aria-label":`${I}. Expand turn ${s}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:I}),t.jsx(G.ChevronRight,{className:"h-4 w-4 shrink-0 transition group-hover:translate-x-0.5"}),t.jsx("span",{className:"thread-graph-worked-rule h-px min-w-0 flex-1","aria-hidden":"true"})]}),U.finalAgent?t.jsx(At,{threadId:r,item:U.finalAgent,scrollRootRef:x,timeLabel:U.finalAgent.createdAt?_t(U.finalAgent.createdAt):D,timeTitle:U.finalAgent.createdAt?Zt(U.finalAgent.createdAt):J,...v?{onBeforeMessageResize:v}:{},...n?{adapter:n}:{}}):null]}):null,P=t.jsx(mf,{footer:V,history:E,liveHookPrompt:re,liveOutput:A,livePlan:L});return t.jsx(pf,{absoluteIndex:s,body:P,collapsed:F,collapsedBody:z,error:a.error,headerStatus:t.jsx(ws,{turn:a}),isActive:w,onToggleCollapse:()=>u(a.id,F),refCallback:y,startedAt:a.startedAt,timeLabel:D,timeTitle:J,tokenSummary:t.jsx(wf,{turn:a})})});function zf({entries:e,expandedGroups:r,onToggleGroupedItem:n,threadId:a,scrollRootRef:s,onOpenExpandedText:o,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,onSelectArtifact:h,onBeforeMessageResize:u,adapter:m,fallbackTimestamp:f,fallbackTimeLabel:p,fallbackTimeTitle:g}){return t.jsx(Ap,{entries:e,expandedGroups:r,onToggleGroupedItem:n,renderCommandGroup:(b,v,x)=>t.jsx(sf,{items:b.items,expanded:v,onToggleExpanded:x,onOpen:l},b.key),renderFileChangeGroup:(b,v,x)=>t.jsx(df,{items:b.items,expanded:v,onToggleExpanded:x,onOpen:o},b.key),renderSearchGroup:(b,v,x)=>t.jsx(of,{items:b.items,expanded:v,onToggleExpanded:x,onOpen:o},b.key),renderFileReadGroup:(b,v,x)=>t.jsx(lf,{items:b.items,expanded:v,onToggleExpanded:x,onOpen:o},b.key),renderItem:b=>{const v=Sf(b.item,f??null);return t.jsx(na,{threadId:a,item:b.item,scrollRootRef:s,timeLabel:b.item.createdAt?_t(v):p,timeTitle:b.item.createdAt?Zt(v):g,onOpenExpandedText:o,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,...u?{onBeforeMessageResize:u}:{},...h?{onSelectArtifact:h}:{},...m?{adapter:m}:{}},b.key)}})}var ys=3,Rf=3,On=80;function sr(e,r=On){return e.scrollHeight-e.scrollTop-e.clientHeight<=r}function _f(e,r){const n=e.getBoundingClientRect(),a=r.getBoundingClientRect(),s=Math.max(n.top,a.top),o=Math.min(n.bottom,a.bottom);return Math.max(0,o-s)>0}function Af(e){return e.map(n=>{const a=n.createdAt;return typeof a=="string"&&a.trim()?a:null}).filter(n=>!!n).sort()[0]??null}function Mf(e,r){return{id:e,startedAt:Af(r),status:"inProgress",error:null,model:null,reasoningEffort:null,reasoningEffortAvailable:null,tokenUsage:null,priceEstimate:null,items:[]}}function js(e,r,n){return{id:e.id,kind:e.kind,title:r,text:n}}function $f({loadHistoryItemDetail:e,onSelectHistoryItemDetail:r}){const n=c.useRef(0),a=c.useRef(new Map),[s,o]=c.useState(null),l=c.useCallback((p,g)=>{o({title:p,text:g})},[]),i=c.useCallback((p,g,b)=>{if(b&&r){r({item:p,detail:g});return}o({title:g.title,text:g.text})},[r]),d=c.useCallback(async({item:p,fallbackTitle:g,fallbackText:b,loadingText:v,errorText:x,useSelectionCallback:y})=>{if(!p.hasDeferredDetail||!e){i(p,js(p,g,b),y);return}const k=a.current.get(p.id);if(k){i(p,k,y);return}const N=n.current+1;n.current=N,y&&r||o({title:g,text:v});try{const w=await e(p.id);if(a.current.set(p.id,w),n.current!==N)return;i(p,w,y)}catch(w){if(n.current!==N)return;i(p,js(p,g,w instanceof Error?w.message:x),y)}},[e,r,i]),h=c.useCallback(async(p,g)=>{var b;await d({item:p,fallbackTitle:g,fallbackText:((b=p.detailText)==null?void 0:b.trim())||p.text||"Command output",loadingText:"Loading full command output...",errorText:"Unable to load full command output.",useSelectionCallback:!0})},[d]),u=c.useCallback(async(p,g)=>{var b;await d({item:p,fallbackTitle:g,fallbackText:((b=p.detailText)==null?void 0:b.trim())||p.text||"Tool call",loadingText:"Loading full tool call details...",errorText:"Unable to load full tool call details.",useSelectionCallback:!0})},[d]),m=c.useCallback(async(p,g,b,v,x)=>{await d({item:p,fallbackTitle:g,fallbackText:b,loadingText:v,errorText:x,useSelectionCallback:!1})},[d]),f=c.useCallback(()=>{n.current+=1,o(null)},[]);return{expandedText:s,openExpandedText:l,openCommandDetail:h,openToolCallDetail:u,openDeferredHistoryItemDetail:m,closeExpandedText:f}}function Df(e){const r=c.useRef(null),n=c.useRef(0),a=r.current;return(a===null||a.length!==e.length||e.some((o,l)=>!Object.is(o,a[l])))&&(n.current+=1,r.current=e),n.current}function Bf({threadId:e,turnsLength:r,totalTurnCount:n,loadingEarlier:a,onLoadEarlier:s,scrollRequestKey:o,bottomSpacer:l,onTailVisibilityChange:i,contentRevisionInputs:d}){const h=c.useRef(null),u=c.useRef(null),m=c.useRef(o),f=c.useRef(null),p=c.useRef(l),g=c.useRef(0),b=c.useRef(0),v=c.useRef(null),x=c.useRef(null),y=c.useRef(!0),k=c.useRef(!0),N=c.useRef(!1),w=c.useRef(!1),j=c.useRef(!1),[C,L]=c.useState(ys),[T,q]=c.useState(0),[M,D]=c.useState(!0),J=Df(d),W=typeof s=="function"||n!==void 0,O=n??r,ee=W?0:Math.max(0,r-C),E=(W?Math.max(0,O-r):0)+ee,re=W?r:r-ee,A=W?0:r-re,V=W?Math.max(0,O-r):0,U=W?V+A:A,I=!W&&U>0&&T>=2,X=W&&V>0&&A===0&&typeof s=="function",F=c.useCallback(()=>{const _=h.current,Y=v.current;if(!_)return;const te=Y?_f(_,Y):sr(_);y.current=te,D(ie=>ie===te?ie:te)},[]),z=c.useCallback(()=>{const _=h.current;if(_){w.current=!0;const Y=_.scrollTop,te=b.current,ie=Y-te;b.current=Y,sr(_,1)?(N.current=!1,k.current=!0):ie<-1?(N.current=!0,k.current=!1):ie>1&&(k.current=!N.current&&sr(_,On))}F()},[F]),P=c.useCallback(()=>{const _=h.current;_&&(_.scrollTop=_.scrollHeight,b.current=_.scrollTop,g.current=_.scrollHeight,y.current=!0,D(Y=>Y||!0),N.current=!1,k.current=!0)},[]),Z=c.useCallback(()=>{const _=h.current;_&&(b.current=_.scrollTop,g.current=_.scrollHeight,k.current=!1,N.current=!0)},[]),K=c.useCallback(()=>{if(W&&A===0){s==null||s();return}L(_=>Math.min(r,_+Rf)),q(_=>_+1)},[A,s,W,r]),de=c.useCallback(()=>{L(r)},[r]);return c.useLayoutEffect(()=>{const _=window.requestAnimationFrame(()=>{P()});return()=>{window.cancelAnimationFrame(_)}},[e,P]),c.useEffect(()=>{j.current=!1,w.current=!1},[e]),c.useEffect(()=>{a||(j.current=!1)},[a,r]),c.useEffect(()=>{L(_=>_>=r-1?r:Math.max(_,ys))},[r]),c.useEffect(()=>{const _=h.current;_&&(g.current=_.scrollHeight,b.current=_.scrollTop,sr(_,1)?(N.current=!1,k.current=!0):(N.current||!sr(_,On))&&(k.current=!1)),F()},[J,F,C]),c.useEffect(()=>{const _=o!==m.current,Y=f.current!==J;if(f.current=J,!(_||Y&&k.current&&!N.current))return;const ie=window.requestAnimationFrame(()=>{P()});return o!==m.current&&(m.current=o),()=>{window.cancelAnimationFrame(ie)}},[J,M,P,o]),c.useEffect(()=>{const _=h.current,Y=u.current;if(!_||!Y||typeof ResizeObserver>"u")return;g.current=_.scrollHeight;const te=new ResizeObserver(()=>{const ie=_.scrollHeight,ue=g.current;if(g.current=ie,ie<=ue)return;const be=ue>0&&ue-_.scrollTop-_.clientHeight<=1;N.current||!(k.current||be||y.current)||window.requestAnimationFrame(()=>{P()})});return te.observe(Y),()=>{te.disconnect()}},[P]),c.useEffect(()=>{if(!k.current||N.current){p.current=l;return}if(l===p.current)return;p.current=l;const _=window.requestAnimationFrame(()=>{P()});return()=>{window.cancelAnimationFrame(_)}},[l,P]),c.useEffect(()=>{i==null||i(M)},[M,i]),c.useEffect(()=>{const _=h.current,Y=x.current;if(!_||!Y||!X||a||j.current||typeof IntersectionObserver>"u")return;const te=new IntersectionObserver(ie=>{!w.current||a||j.current||!ie.some(ue=>ue.isIntersecting)||(j.current=!0,s==null||s())},{root:_,threshold:.01});return te.observe(Y),()=>{te.disconnect()}},[X,a,s]),{scrollContainerRef:h,scrollContentRef:u,tailSentinelRef:v,topSentinelRef:x,isTailVisible:M,handleScroll:z,preserveScrollPositionForResize:Z,serverManagedHistory:W,effectiveTotalTurnCount:O,startIndex:ee,visibleTurnAbsoluteOffset:E,hiddenCount:U,loadedHiddenCount:A,unloadedHiddenCount:V,showLoadAll:I,handleLoadEarlierClick:K,handleLoadAllClick:de}}function Gf(e){return e==="completed"||e==="failed"||e==="interrupted"}function Ff(e,r){if(!r||r.id!==e.id||r.items.length===0)return e;const n=new Set(e.items.map(s=>s.id)),a=r.items.filter(s=>!n.has(s.id));return a.length===0?e:{...e,items:[...a,...e.items]}}function Hf({threadId:e,turns:r,totalTurnCount:n,pendingRequests:a=[],activeTurnId:s=null,threadRunning:o=!1,pendingSteers:l=[],livePlan:i=null,liveItems:d=null,respondingRequestId:h=null,onRespondToRequest:u,liveOutput:m,scrollRequestKey:f=0,bottomSpacer:p=0,className:g="",onTailVisibilityChange:b,loadingEarlier:v=!1,onLoadEarlier:x,ephemeralUserNote:y=null,answeredRequestNotes:k=[],activityNotes:N=[],optimisticSteers:w=[],optimisticTurn:j=null,onLoadHistoryItemDetail:C,onOpenThread:L,onSelectArtifact:T,onSelectHistoryItemDetail:q,adapter:M,autoCollapseCompletedTurns:D}){var lt,He,tt,it,Ye;const J=Zo(),W=D??(J==null?void 0:J.autoCollapseCompletedTurns)??!1,[O,ee]=c.useState({}),[he,E]=c.useState(()=>new Set),re=(M==null?void 0:M.onLoadHistoryItemDetail)??C,A=M==null?void 0:M.onOpenLinkedThread,{expandedText:V,openExpandedText:U,openCommandDetail:I,openToolCallDetail:X,openDeferredHistoryItemDetail:F,closeExpandedText:z}=$f({loadHistoryItemDetail:re,onSelectHistoryItemDetail:q}),{scrollContainerRef:P,scrollContentRef:Z,tailSentinelRef:K,topSentinelRef:de,handleScroll:_,preserveScrollPositionForResize:Y,serverManagedHistory:te,effectiveTotalTurnCount:ie,startIndex:ue,visibleTurnAbsoluteOffset:be,hiddenCount:Le,loadedHiddenCount:ae,unloadedHiddenCount:ve,showLoadAll:ke,handleLoadEarlierClick:pe,handleLoadAllClick:Ie}=Bf({threadId:e,turnsLength:r.length,totalTurnCount:n,loadingEarlier:v,onLoadEarlier:x,scrollRequestKey:f,bottomSpacer:p,onTailVisibilityChange:b,contentRevisionInputs:[r,a,l,w,m,i,d,j,k,N,y,p]}),je=c.useCallback((S,B)=>{ee(se=>({...se,[S]:!B}))},[]),_e=c.useCallback((S,B)=>{const se=O[S.id];return se!==void 0?se:!!(W&&Gf(S.status)&&!B.forceActive&&!B.hasLiveActivity)},[O,W]),Pe=te?r:r.slice(ue),Ae=ie+1,Ce=o&&(!s||!Pe.some(S=>S.id===s)&&(j==null?void 0:j.id)!==s),Re=(j==null?void 0:j.id)??((lt=Pe.at(-1))==null?void 0:lt.id)??null,H=Ce&&Re!==null,ce=!!d&&(Pe.some(S=>S.id===d.turnId)||(j==null?void 0:j.id)===d.turnId),R=d&&ce?d.turnId:d&&H?Re:null,$=j&&R===j.id?(d==null?void 0:d.items)??null:null,Q=((d==null?void 0:d.items.length)??0)>0,me=d&&R===null?d.items:null,xe=c.useMemo(()=>d&&R===null&&d.items.length>0?Mf(d.turnId,d.items):null,[d,R]),ze=Math.max(1,ie+(j?1:0)),ge=!!m&&!!j&&j.status!=="failed"&&!$,Me=m&&Pe.length>0?s&&Pe.some(S=>S.id===s)?s:((He=Pe.findLast(S=>al(S.status)))==null?void 0:He.id)??(H?Re:null):null,at=!!Me,Je=c.useMemo(()=>nl(m),[m]),Qe=[...l.map(S=>({id:S.id,prompt:S.prompt,status:"Accepted",createdAt:S.createdAt,canCancel:!0})),...w.map(S=>({id:S.id,prompt:S.prompt,status:S.status==="steering"?"Steering":null,createdAt:S.createdAt,canCancel:!1}))].sort((S,B)=>S.createdAt.localeCompare(B.createdAt)),De=c.useMemo(()=>Ip({answeredRequestNotes:k,pendingRequests:a,visibleTurns:Pe,optimisticTurn:j}),[k,j,a,Pe]),Be=c.useMemo(()=>zp({activityNotes:N,visibleTurns:Pe,optimisticTurn:j}),[N,j,Pe]);return t.jsxs(t.Fragment,{children:[t.jsx("section",{className:`flex min-h-0 flex-1 flex-col ${g}`.trim(),children:t.jsx("div",{ref:P,"data-testid":"thread-scroll-container",onScroll:_,className:"thread-graph-scroll-container min-h-0 flex-1 overflow-y-auto overscroll-contain",style:p>0?{paddingBottom:p}:void 0,children:t.jsxs("div",{ref:Z,className:"thread-graph-scroll-content",children:[t.jsx("div",{ref:de,"aria-hidden":"true",className:"h-px"}),r.length>0&&t.jsx("div",{className:"thread-graph-history-control px-3 pb-1 pt-2 sm:px-5 sm:pb-1.5 sm:pt-3",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 text-xs sm:text-sm",children:[Le>0&&t.jsx("button",{type:"button",onClick:pe,disabled:v,className:"thread-graph-history-button rounded-full border px-2.5 py-1.5 transition",children:v?"Loading earlier...":"Load 3 earlier"}),ke&&t.jsx("button",{type:"button",onClick:Ie,className:"rounded-full border border-amber-300/40 px-2.5 py-1.5 text-amber-200 transition hover:bg-amber-300/10",children:"Load full history"}),t.jsxs("p",{className:"timeline-meta-text",children:["Showing ",Pe.length," of ",ie," turns",Le>0?` · ${Le} earlier hidden${ae>0&&ve>0?` (${ae} loaded)`:""}`:""]})]})}),r.length===0&&!m&&!j&&t.jsx("div",{className:"thread-graph-empty-state px-3 py-8 text-sm sm:px-5",children:"Send the first prompt to start the thread."}),(Pe.length>0||j||Be.leading.length>0||Be.trailing.length>0)&&t.jsxs("div",{className:"thread-graph-message-list",children:[Be.leading.length>0?t.jsx(ar,{notes:Be.leading,onOpenThread:L,onOpenLinkedThread:A}):null,Pe.map((S,B)=>{var se,ye,Oe,rt,nt;return t.jsxs("div",{children:[(((se=Be.beforeTurnId.get(S.id))==null?void 0:se.length)??0)>0?t.jsx(ar,{notes:Be.beforeTurnId.get(S.id)??[],onOpenThread:L,onOpenLinkedThread:A}):null,(((ye=De.beforeTurnId.get(S.id))==null?void 0:ye.length)??0)>0?t.jsx(Fn,{entries:De.beforeTurnId.get(S.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const Ge=Ff(S,j),Ve=(i==null?void 0:i.turnId)===S.id?i:null,ht=R===S.id?(d==null?void 0:d.items)??null:null,bt=Me===S.id?m:"",fe=s===S.id||H&&Re===S.id,Te=!!Ve||!!bt||!!(ht&&ht.length>0),Ze=_e(Ge,{forceActive:fe,hasLiveActivity:Te});return t.jsx(xn,{threadId:e,...M?{adapter:M}:{},turn:Ge,absoluteIndex:be+B+1,isCollapsed:Ze,livePlan:Ve,liveItems:ht,liveOutput:bt,forceActive:fe,onToggleCollapse:je,onOpenExpandedText:U,onOpenCommandDetail:I,onOpenToolCallDetail:X,onOpenDeferredHistoryItemDetail:F,onBeforeMessageResize:Y,...T?{onSelectArtifact:T}:{},scrollRootRef:P,articleRef:void 0})})(),(((Oe=Be.afterTurnId.get(S.id))==null?void 0:Oe.length)??0)>0?t.jsx(ar,{notes:Be.afterTurnId.get(S.id)??[],onOpenThread:L,onOpenLinkedThread:A}):null,(rt=De.notesByTurnId.get(S.id))!=null&&rt.length||(nt=De.pendingRequestsByTurnId.get(S.id))!=null&&nt.length?t.jsx(Rp,{notes:De.notesByTurnId.get(S.id)??[],requests:De.pendingRequestsByTurnId.get(S.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null]},S.id)}),j&&Pe.every(S=>S.id!==j.id)&&t.jsxs(t.Fragment,{children:[(((tt=Be.beforeTurnId.get(j.id))==null?void 0:tt.length)??0)>0?t.jsx(ar,{notes:Be.beforeTurnId.get(j.id)??[],onOpenThread:L,onOpenLinkedThread:A}):null,(((it=De.beforeTurnId.get(j.id))==null?void 0:it.length)??0)>0?t.jsx(Fn,{entries:De.beforeTurnId.get(j.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const S=ge?m:"",B=s===j.id||H&&Re===j.id,se=!!($&&$.length>0)||!!S,ye=_e(j,{forceActive:B,hasLiveActivity:se});return t.jsx(xn,{threadId:e,...M?{adapter:M}:{},turn:j,absoluteIndex:Ae,isCollapsed:ye,livePlan:null,liveItems:$,liveOutput:S,forceActive:B,onToggleCollapse:je,onOpenExpandedText:U,onOpenCommandDetail:I,onOpenToolCallDetail:X,onOpenDeferredHistoryItemDetail:F,onBeforeMessageResize:Y,...T?{onSelectArtifact:T}:{},scrollRootRef:P})})(),(((Ye=Be.afterTurnId.get(j.id))==null?void 0:Ye.length)??0)>0?t.jsx(ar,{notes:Be.afterTurnId.get(j.id)??[],onOpenThread:L,onOpenLinkedThread:A}):null]})]}),Qe.length>0&&t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:Qe.map(S=>t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(At,{threadId:e,item:{id:S.id,kind:"userMessage",text:S.prompt,status:S.status},scrollRootRef:P,onBeforeMessageResize:Y,...M?{adapter:M}:{}}),e&&S.canCancel&&(M!=null&&M.cancelPendingSteer)?t.jsx("div",{className:"flex justify-end px-1",children:t.jsx("button",{type:"button",className:"thread-graph-history-button rounded-full border px-2.5 py-1 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",disabled:he.has(S.id),onClick:()=>{var B;E(se=>new Set(se).add(S.id)),Promise.resolve((B=M.cancelPendingSteer)==null?void 0:B.call(M,e,S.id)).catch(()=>{}).finally(()=>{E(se=>{const ye=new Set(se);return ye.delete(S.id),ye})})},children:he.has(S.id)?"Canceling...":"Cancel"})}):null]},S.id))}),(De.trailing.length>0||Be.trailing.length>0)&&t.jsx(_p,{entries:[...Be.trailing.map(S=>({kind:"activity",id:S.id,createdAt:S.createdAt,note:S})),...De.trailing],respondingRequestId:h,onRespondToRequest:u??void 0,onOpenThread:L,onOpenLinkedThread:A}),y&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:t.jsx(At,{threadId:e,item:{id:"ephemeral-plan-decision-note",kind:"userMessage",text:y},scrollRootRef:P,onBeforeMessageResize:Y})}),xe&&me&&me.length>0&&t.jsx(xn,{threadId:e,...M?{adapter:M}:{},turn:xe,absoluteIndex:ze,isCollapsed:O[xe.id]??!1,livePlan:(i==null?void 0:i.turnId)===xe.id?i:null,liveItems:me,liveOutput:"",forceActive:!0,onToggleCollapse:je,onOpenExpandedText:U,onOpenCommandDetail:I,onOpenToolCallDetail:X,onOpenDeferredHistoryItemDetail:F,onBeforeMessageResize:Y,...T?{onSelectArtifact:T}:{},scrollRootRef:P}),m&&!at&&!ge&&!Q&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:Je?t.jsx(na,{threadId:e,item:Je,scrollRootRef:P,onOpenExpandedText:U,onOpenCommandDetail:I,onOpenToolCallDetail:X,onOpenDeferredHistoryItemDetail:F,onBeforeMessageResize:Y,...T?{onSelectArtifact:T}:{},...M?{adapter:M}:{}}):t.jsx(At,{threadId:e,item:{id:"live-agent-message-fallback",kind:"agentMessage",text:m},scrollRootRef:P,streaming:!0,onBeforeMessageResize:Y,...M?{adapter:M}:{}})}),t.jsx("div",{ref:K,"aria-hidden":"true",className:"h-px w-full"})]})})}),t.jsx(Xm,{open:V!==null,title:(V==null?void 0:V.title)??"Full text",text:(V==null?void 0:V.text)??"",onClose:z})]})}var pl=c.memo(Hf);function Of(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}function Un(e){return e.replace(/\r\n/g,`
|
|
3621
|
+
`)}function Ns(e){const r=Un(e),n=r.split(`
|
|
3615
3622
|
`);return r.endsWith(`
|
|
3616
|
-
`)&&n.at(-1)===""&&n.pop(),n}function Uf(e){const r=e.trim();return r?/(?:[$%#>])\s*$/.test(r):!1}function Wf(e,r){const n=r.trim();if(!n||e.length===0)return e;const[a,...s]=e;if(a===void 0)return e;const o=a.trim();return o===n||o.endsWith(` ${n}`)||o.endsWith(`$ ${n}`)||o.endsWith(`% ${n}`)||o.endsWith(`# ${n}`)||o.endsWith(`> ${n}`)?s:e}function Vf(e,r,n){var d,h;const a=
|
|
3617
|
-
`).trimEnd()}function Kf(e){switch(e){case"ctrl_c":return"";case"ctrl_d":return"";case"esc":return"\x1B";case"tab":return" ";case"up":return"\x1B[A";case"down":return"\x1B[B"}}function Ss(e){return{background:e==="light"?"#f2ede5":"#0c1117",foreground:e==="light"?"#3f3a36":"#d6dde6",cursor:e==="light"?"#3f3a36":"#d6dde6",black:e==="light"?"#d8cfc2":"#0f1720",brightBlack:e==="light"?"#8a7f73":"#475569",red:"#f87171",brightRed:"#fb7185",green:e==="light"?"#16a34a":"#86efac",brightGreen:e==="light"?"#22c55e":"#4ade80",yellow:"#fbbf24",brightYellow:"#fcd34d",blue:e==="light"?"#2563eb":"#93c5fd",brightBlue:e==="light"?"#3b82f6":"#60a5fa",magenta:e==="light"?"#7c3aed":"#c4b5fd",brightMagenta:e==="light"?"#8b5cf6":"#a78bfa",cyan:e==="light"?"#0891b2":"#67e8f9",brightCyan:e==="light"?"#06b6d4":"#22d3ee",white:e==="light"?"#5b5148":"#e2e8f0",brightWhite:e==="light"?"#2c2723":"#f8fafc"}}function vn(e){switch(e){case"not_created":return"Not created";case"creating":return"Creating";case"running":return"Running";case"attached":return"Attached";case"detached":return"Detached";case"exited":return"Exited";case"not_found":return"Missing";case"workspace_missing":return"Workspace missing"}}function Xr(e){if(!e)return"";const r=e.replace(/[\\/]+$/,"");return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function sa(e,r){const n=[r==null?void 0:r.trim(),e==null?void 0:e.trim()].filter(Boolean);return n.length>0?n.join(" "):null}function kn(e){return Math.min(75,Math.max(25,e))}function qf(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",className:"h-4 w-4 fill-current",children:[t.jsx("path",{fillRule:"evenodd",d:"M14.5 10C16.9853 10 19 7.98528 19 5.5C19 5.01783 18.9242 4.55338 18.7838 4.11791C18.6792 3.79367 18.2734 3.72683 18.0325 3.96772L15.3402 6.66002C15.2098 6.79041 15.0168 6.84163 14.8466 6.77074C14.1172 6.46695 13.5334 5.88351 13.2292 5.15431C13.1582 4.98403 13.2094 4.79088 13.3398 4.66042L16.0327 1.9676C16.2735 1.72672 16.2067 1.32092 15.8825 1.21636C15.4469 1.07588 14.9823 1 14.5 1C12.0147 1 10 3.01472 10 5.5C10 5.59783 10.0031 5.69494 10.0093 5.79122C10.065 6.66418 9.88174 7.59855 9.20974 8.15855L1.98017 14.1832C1.3591 14.7008 1 15.4674 1 16.2759C1 17.7804 2.21962 19 3.7241 19C4.53256 19 5.29925 18.6409 5.81681 18.0198L11.8414 10.7903C12.4014 10.1183 13.3358 9.93497 14.2088 9.99073C14.3051 9.99688 14.4022 10 14.5 10ZM5 16C5 16.5523 4.55228 17 4 17C3.44772 17 3 16.5523 3 16C3 15.4477 3.44772 15 4 15C4.55228 15 5 15.4477 5 16Z",clipRule:"evenodd"}),t.jsx("path",{d:"M14.5 11.5C14.6731 11.5 14.8445 11.4927 15.0138 11.4783L18.7678 15.2323C19.7441 16.2086 19.7441 17.7915 18.7678 18.7678C17.7915 19.7441 16.2086 19.7441 15.2323 18.7678L10.8216 14.3571L12.9938 11.7505C13.0455 11.6885 13.1413 11.6131 13.3357 11.5552C13.5378 11.4951 13.805 11.468 14.1132 11.4877C14.2413 11.4959 14.3702 11.5 14.5 11.5Z"}),t.jsx("path",{d:"M6.00003 4.58582L8.33056 6.91635C8.3027 6.95627 8.27496 6.98497 8.24946 7.00622L6.79994 8.21415L4.58582 6.00003H3.30905C3.11966 6.00003 2.94653 5.89303 2.86184 5.72364L1.1612 2.32237C1.06495 2.12987 1.10268 1.89739 1.25486 1.74521L1.74521 1.25486C1.89739 1.10268 2.12987 1.06495 2.32237 1.1612L5.72364 2.86184C5.89303 2.94653 6.00003 3.11966 6.00003 3.30905V4.58582Z"})]})}function Xf({connected:e}){return e?t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",className:"h-4.5 w-4.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M13.19 8.688a4.5 4.5 0 0 1 1.242 7.244l-4.5 4.5a4.5 4.5 0 0 1-6.364-6.364l1.757-1.757m13.35-.622 1.757-1.757a4.5 4.5 0 0 0-6.364-6.364l-4.5 4.5a4.5 4.5 0 0 0 1.242 7.244"})}):t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",className:"h-4.5 w-4.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M13.181 8.68a4.503 4.503 0 0 1 1.903 6.405m-9.768-2.782L3.56 14.06a4.5 4.5 0 0 0 6.364 6.365l3.129-3.129m5.614-5.615 1.757-1.757a4.5 4.5 0 0 0-6.364-6.365l-4.5 4.5c-.258.26-.479.541-.661.84m1.903 6.405a4.495 4.495 0 0 1-1.242-.88 4.483 4.483 0 0 1-1.062-1.683m6.587 2.345 5.907 5.907m-5.907-5.907L8.898 8.898M2.991 2.99 8.898 8.9"})})}function Ts(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5.5 3.25h5"}),t.jsx("path",{d:"M6.4 2h3.2a.9.9 0 0 1 .9.9v.35h1.3a1.2 1.2 0 0 1 1.2 1.2v7.35a1.2 1.2 0 0 1-1.2 1.2H4.2A1.2 1.2 0 0 1 3 11.8V4.45a1.2 1.2 0 0 1 1.2-1.2h1.3V2.9a.9.9 0 0 1 .9-.9Z"})]})}function wn({label:e,tone:r="stone"}){const n=r==="rose"?"border-rose-300/35 bg-rose-300/14 text-rose-600 dark:text-rose-50":r==="sky"?"border-sky-300/35 bg-sky-300/14 text-sky-600 dark:text-sky-50":"shell-control-chip border";return t.jsx("span",{className:`inline-flex min-w-[3.45rem] items-center justify-center rounded-full border px-2.5 py-1.5 text-[11px] font-medium tracking-[0.12em] ${n}`,children:e})}var Yf=120,Zf=800,Jf=4e3,Qf=4500,eg="Shell connection timed out. Reconnecting...";function tg({isCurrentSocket:e,viewerId:r}){return!e||r?null:{connectionError:eg,isConnecting:!1,settleAttachPromise:!1,closeSocket:!0}}function rg({isCurrentSocket:e,shellId:r,attachSize:n}){return e?{message:{type:"shell.attach",shellId:r,cols:n.cols,rows:n.rows},shouldScheduleAttachTimeout:!0}:null}function ng({intentionalDisconnect:e,userDisconnectedShellId:r,shellId:n}){return!e&&r!==n}function ag({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:s}){return e?{shouldDetachShell:r,shouldScheduleReconnect:ng({intentionalDisconnect:n,userDisconnectedShellId:a,shellId:s})}:null}function sg({hasAttachSize:e,hasPendingRetry:r}){return!e&&!r}function gl({shellId:e,terminalReady:r,isVisible:n,canAttachShell:a,userDisconnectedShellId:s,hasTerminal:o,attachSize:l,hasPendingAttachRetry:i,hasCurrentSocketForShell:d,hasReconnectTimer:h}){return!e||!r||!n||!a||s===e||!o?{type:"skip"}:l===void 0?{type:"measureSize"}:l?d?{type:"reuseSocket",shouldClearAttachRetry:i}:{type:"startAttach",attachSize:l,shouldClearAttachRetry:i,shouldClearReconnectTimer:h}:sg({hasAttachSize:!1,hasPendingRetry:i})?{type:"scheduleRetry"}:{type:"skip"}}function og({hasShellId:e,terminalReady:r,workspacePathMissing:n,hasViewer:a,hasPendingAttach:s}){return!e||!r||n?{type:"reject"}:a?{type:"alreadyConnected"}:s?{type:"joinPending"}:{type:"startAttach"}}function lg({shellId:e,userDisconnectedShellId:r}){return{shouldClearUserDisconnectedShellId:!!e&&r===e,intentionalDisconnect:!1,connectionError:null,isConnecting:!0,shouldIncrementReconnectKey:!0}}function ig({hasShell:e}){return e?null:{viewerId:null,isConnecting:!1,settleAttachPromise:!1,connectionError:null,runtimePromptLabel:null,isCommandRunning:!1,shellSnapshot:"",lastCommandOutput:"",pendingCommand:null,shouldResetTerminal:!0}}function dg({hasReconnectTimer:e,hasAttachTimeout:r,hasAttachRetry:n}){return{shouldClearReconnectTimer:e,shouldClearAttachTimeout:r,shouldClearAttachRetry:n,settleAttachPromise:!1}}function xl({shellId:e,viewerId:r}){return e&&r?{type:"shell.detach",shellId:e,viewerId:r}:null}function cg({shellId:e,viewerId:r,hasSocket:n}){return{userDisconnectedShellId:e,intentionalDisconnect:!0,detachMessage:xl({shellId:e,viewerId:r}),shouldCloseSocket:n,shouldClearSocketRef:!0,shouldClearLastSentSize:!0,shouldDetachShell:!!e}}function hg({shellId:e,viewerId:r,socketReadyState:n,openReadyState:a,hasAttachRetryTimer:s,hasAttachTimeout:o,isCurrentSocket:l}){const i=xl({shellId:e,viewerId:r});return{intentionalDisconnect:!0,shouldClearAttachRetry:s,detachMessage:i,shouldSendDetachMessage:!!(i&&n===a),shouldClearViewer:!0,isConnecting:!1,settleAttachPromise:l?!1:void 0,shouldClearAttachTimeout:o,shouldCloseSocket:!0,shouldClearSocketRef:l}}function ug({size:e,previousSize:r,shellId:n,viewerId:a,syncBackendSize:s}){return s?(r==null?void 0:r.cols)===e.cols&&r.rows===e.rows?{nextLastSentSize:r,message:null}:{nextLastSentSize:e,message:n&&a?{type:"shell.resize",shellId:n,viewerId:a,cols:e.cols,rows:e.rows}:null}:{nextLastSentSize:r??e,message:null}}function mg(e,r){const n=typeof e.cwdBaseName=="string"?e.cwdBaseName:null,a=typeof e.envPrefix=="string"?e.envPrefix:null;return{data:typeof e.data=="string"?e.data:"",replace:e.replace===!0,cursorX:typeof e.cursorX=="number"?e.cursorX:void 0,cursorY:typeof e.cursorY=="number"?e.cursorY:void 0,paneHeight:typeof e.paneHeight=="number"?e.paneHeight:void 0,promptLabel:sa(n??Xr(r),a),isCommandRunning:e.isCommandRunning===!0}}function pg({currentSnapshot:e,data:r,replace:n,isCommandRunning:a,pendingCommand:s}){if(!r)return{nextSnapshot:e,nextPendingCommand:s,lastCommandOutput:null};const o=Wn(n?r:`${e}${r}`);return!n||a||!s?{nextSnapshot:o,nextPendingCommand:s,lastCommandOutput:null}:{nextSnapshot:o,nextPendingCommand:null,lastCommandOutput:Vf(s.beforeSnapshot,o,s.command)}}function fg({event:e,currentViewerId:r}){if(e.type==="shell.output")return null;if(e.type==="shell.connected"){const a=String(e.payload.viewerId??"");return{viewerId:a||null,isConnecting:!1,settleAttachPromise:!!a,isCommandRunning:void 0,connectionError:void 0,intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:{status:"attached",attachedViewerId:a}}}if(e.type==="shell.error")return{viewerId:void 0,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:void 0,connectionError:String(e.payload.message??"Shell connection failed."),intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:e.payload.code==="viewer_conflict"?{status:"detached",attachedViewerId:null}:void 0};if(e.type==="shell.detached"){const a=String(e.payload.viewerId??"");if(!a||a!==r)return null;const s=String(e.payload.reason??"");return{viewerId:null,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:!1,connectionError:s==="replaced"?"This shell connection was taken over by another pane or device.":null,intentionalDisconnect:s==="replaced"?!0:void 0,closeSocket:!0,shellUpdate:{status:"detached",attachedViewerId:null}}}if(e.type==="shell.exited")return{viewerId:null,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:!1,connectionError:void 0,intentionalDisconnect:!0,closeSocket:!0,shellUpdate:{status:e.payload.state==="exited"?"exited":"not_found",attachedViewerId:null}};const n=e.payload.state;return{viewerId:n==="attached"?void 0:null,isConnecting:n==="attached"?void 0:!1,settleAttachPromise:n==="attached"?void 0:!1,isCommandRunning:n==="attached"?void 0:!1,connectionError:void 0,intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:{status:n,attachedViewerId:n==="attached"?void 0:null}}}function bl(e,r,n,a,s){const o=r.replace(/\r\n/g,`
|
|
3623
|
+
`)&&n.at(-1)===""&&n.pop(),n}function Uf(e){const r=e.trim();return r?/(?:[$%#>])\s*$/.test(r):!1}function Wf(e,r){const n=r.trim();if(!n||e.length===0)return e;const[a,...s]=e;if(a===void 0)return e;const o=a.trim();return o===n||o.endsWith(` ${n}`)||o.endsWith(`$ ${n}`)||o.endsWith(`% ${n}`)||o.endsWith(`# ${n}`)||o.endsWith(`> ${n}`)?s:e}function Vf(e,r,n){var d,h;const a=Ns(e),s=Ns(r);let o=0;for(;o<a.length&&o<s.length&&a[o]===s[o];)o+=1;let l=0;for(;l<a.length-o&&l<s.length-o&&a[a.length-1-l]===s[s.length-1-l];)l+=1;let i=s.slice(o,s.length-l);for(i=Wf(i,n);i.length>0&&((d=i[0])==null?void 0:d.trim())==="";)i.shift();for(;i.length>0&&(((h=i.at(-1))==null?void 0:h.trim())===""||Uf(i.at(-1)??""));)i.pop();return i.join(`
|
|
3624
|
+
`).trimEnd()}function Kf(e){switch(e){case"ctrl_c":return"";case"ctrl_d":return"";case"esc":return"\x1B";case"tab":return" ";case"up":return"\x1B[A";case"down":return"\x1B[B"}}function Cs(e){return{background:e==="light"?"#f2ede5":"#0c1117",foreground:e==="light"?"#3f3a36":"#d6dde6",cursor:e==="light"?"#3f3a36":"#d6dde6",black:e==="light"?"#d8cfc2":"#0f1720",brightBlack:e==="light"?"#8a7f73":"#475569",red:"#f87171",brightRed:"#fb7185",green:e==="light"?"#16a34a":"#86efac",brightGreen:e==="light"?"#22c55e":"#4ade80",yellow:"#fbbf24",brightYellow:"#fcd34d",blue:e==="light"?"#2563eb":"#93c5fd",brightBlue:e==="light"?"#3b82f6":"#60a5fa",magenta:e==="light"?"#7c3aed":"#c4b5fd",brightMagenta:e==="light"?"#8b5cf6":"#a78bfa",cyan:e==="light"?"#0891b2":"#67e8f9",brightCyan:e==="light"?"#06b6d4":"#22d3ee",white:e==="light"?"#5b5148":"#e2e8f0",brightWhite:e==="light"?"#2c2723":"#f8fafc"}}function bn(e){switch(e){case"not_created":return"Not created";case"creating":return"Creating";case"running":return"Running";case"attached":return"Attached";case"detached":return"Detached";case"exited":return"Exited";case"not_found":return"Missing";case"workspace_missing":return"Workspace missing"}}function Xr(e){if(!e)return"";const r=e.replace(/[\\/]+$/,"");return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function aa(e,r){const n=[r==null?void 0:r.trim(),e==null?void 0:e.trim()].filter(Boolean);return n.length>0?n.join(" "):null}function vn(e){return Math.min(75,Math.max(25,e))}function qf(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",className:"h-4 w-4 fill-current",children:[t.jsx("path",{fillRule:"evenodd",d:"M14.5 10C16.9853 10 19 7.98528 19 5.5C19 5.01783 18.9242 4.55338 18.7838 4.11791C18.6792 3.79367 18.2734 3.72683 18.0325 3.96772L15.3402 6.66002C15.2098 6.79041 15.0168 6.84163 14.8466 6.77074C14.1172 6.46695 13.5334 5.88351 13.2292 5.15431C13.1582 4.98403 13.2094 4.79088 13.3398 4.66042L16.0327 1.9676C16.2735 1.72672 16.2067 1.32092 15.8825 1.21636C15.4469 1.07588 14.9823 1 14.5 1C12.0147 1 10 3.01472 10 5.5C10 5.59783 10.0031 5.69494 10.0093 5.79122C10.065 6.66418 9.88174 7.59855 9.20974 8.15855L1.98017 14.1832C1.3591 14.7008 1 15.4674 1 16.2759C1 17.7804 2.21962 19 3.7241 19C4.53256 19 5.29925 18.6409 5.81681 18.0198L11.8414 10.7903C12.4014 10.1183 13.3358 9.93497 14.2088 9.99073C14.3051 9.99688 14.4022 10 14.5 10ZM5 16C5 16.5523 4.55228 17 4 17C3.44772 17 3 16.5523 3 16C3 15.4477 3.44772 15 4 15C4.55228 15 5 15.4477 5 16Z",clipRule:"evenodd"}),t.jsx("path",{d:"M14.5 11.5C14.6731 11.5 14.8445 11.4927 15.0138 11.4783L18.7678 15.2323C19.7441 16.2086 19.7441 17.7915 18.7678 18.7678C17.7915 19.7441 16.2086 19.7441 15.2323 18.7678L10.8216 14.3571L12.9938 11.7505C13.0455 11.6885 13.1413 11.6131 13.3357 11.5552C13.5378 11.4951 13.805 11.468 14.1132 11.4877C14.2413 11.4959 14.3702 11.5 14.5 11.5Z"}),t.jsx("path",{d:"M6.00003 4.58582L8.33056 6.91635C8.3027 6.95627 8.27496 6.98497 8.24946 7.00622L6.79994 8.21415L4.58582 6.00003H3.30905C3.11966 6.00003 2.94653 5.89303 2.86184 5.72364L1.1612 2.32237C1.06495 2.12987 1.10268 1.89739 1.25486 1.74521L1.74521 1.25486C1.89739 1.10268 2.12987 1.06495 2.32237 1.1612L5.72364 2.86184C5.89303 2.94653 6.00003 3.11966 6.00003 3.30905V4.58582Z"})]})}function Xf({connected:e}){return e?t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",className:"h-4.5 w-4.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M13.19 8.688a4.5 4.5 0 0 1 1.242 7.244l-4.5 4.5a4.5 4.5 0 0 1-6.364-6.364l1.757-1.757m13.35-.622 1.757-1.757a4.5 4.5 0 0 0-6.364-6.364l-4.5 4.5a4.5 4.5 0 0 0 1.242 7.244"})}):t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",className:"h-4.5 w-4.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M13.181 8.68a4.503 4.503 0 0 1 1.903 6.405m-9.768-2.782L3.56 14.06a4.5 4.5 0 0 0 6.364 6.365l3.129-3.129m5.614-5.615 1.757-1.757a4.5 4.5 0 0 0-6.364-6.365l-4.5 4.5c-.258.26-.479.541-.661.84m1.903 6.405a4.495 4.495 0 0 1-1.242-.88 4.483 4.483 0 0 1-1.062-1.683m6.587 2.345 5.907 5.907m-5.907-5.907L8.898 8.898M2.991 2.99 8.898 8.9"})})}function Ss(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5.5 3.25h5"}),t.jsx("path",{d:"M6.4 2h3.2a.9.9 0 0 1 .9.9v.35h1.3a1.2 1.2 0 0 1 1.2 1.2v7.35a1.2 1.2 0 0 1-1.2 1.2H4.2A1.2 1.2 0 0 1 3 11.8V4.45a1.2 1.2 0 0 1 1.2-1.2h1.3V2.9a.9.9 0 0 1 .9-.9Z"})]})}function kn({label:e,tone:r="stone"}){const n=r==="rose"?"border-rose-300/35 bg-rose-300/14 text-rose-600 dark:text-rose-50":r==="sky"?"border-sky-300/35 bg-sky-300/14 text-sky-600 dark:text-sky-50":"shell-control-chip border";return t.jsx("span",{className:`inline-flex min-w-[3.45rem] items-center justify-center rounded-full border px-2.5 py-1.5 text-[11px] font-medium tracking-[0.12em] ${n}`,children:e})}var Yf=120,Zf=800,Jf=4e3,Qf=4500,eg="Shell connection timed out. Reconnecting...";function tg({isCurrentSocket:e,viewerId:r}){return!e||r?null:{connectionError:eg,isConnecting:!1,settleAttachPromise:!1,closeSocket:!0}}function rg({isCurrentSocket:e,shellId:r,attachSize:n}){return e?{message:{type:"shell.attach",shellId:r,cols:n.cols,rows:n.rows},shouldScheduleAttachTimeout:!0}:null}function ng({intentionalDisconnect:e,userDisconnectedShellId:r,shellId:n}){return!e&&r!==n}function ag({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:s}){return e?{shouldDetachShell:r,shouldScheduleReconnect:ng({intentionalDisconnect:n,userDisconnectedShellId:a,shellId:s})}:null}function sg({hasAttachSize:e,hasPendingRetry:r}){return!e&&!r}function fl({shellId:e,terminalReady:r,isVisible:n,canAttachShell:a,userDisconnectedShellId:s,hasTerminal:o,attachSize:l,hasPendingAttachRetry:i,hasCurrentSocketForShell:d,hasReconnectTimer:h}){return!e||!r||!n||!a||s===e||!o?{type:"skip"}:l===void 0?{type:"measureSize"}:l?d?{type:"reuseSocket",shouldClearAttachRetry:i}:{type:"startAttach",attachSize:l,shouldClearAttachRetry:i,shouldClearReconnectTimer:h}:sg({hasAttachSize:!1,hasPendingRetry:i})?{type:"scheduleRetry"}:{type:"skip"}}function og({hasShellId:e,terminalReady:r,workspacePathMissing:n,hasViewer:a,hasPendingAttach:s}){return!e||!r||n?{type:"reject"}:a?{type:"alreadyConnected"}:s?{type:"joinPending"}:{type:"startAttach"}}function lg({shellId:e,userDisconnectedShellId:r}){return{shouldClearUserDisconnectedShellId:!!e&&r===e,intentionalDisconnect:!1,connectionError:null,isConnecting:!0,shouldIncrementReconnectKey:!0}}function ig({hasShell:e}){return e?null:{viewerId:null,isConnecting:!1,settleAttachPromise:!1,connectionError:null,runtimePromptLabel:null,isCommandRunning:!1,shellSnapshot:"",lastCommandOutput:"",pendingCommand:null,shouldResetTerminal:!0}}function dg({hasReconnectTimer:e,hasAttachTimeout:r,hasAttachRetry:n}){return{shouldClearReconnectTimer:e,shouldClearAttachTimeout:r,shouldClearAttachRetry:n,settleAttachPromise:!1}}function gl({shellId:e,viewerId:r}){return e&&r?{type:"shell.detach",shellId:e,viewerId:r}:null}function cg({shellId:e,viewerId:r,hasSocket:n}){return{userDisconnectedShellId:e,intentionalDisconnect:!0,detachMessage:gl({shellId:e,viewerId:r}),shouldCloseSocket:n,shouldClearSocketRef:!0,shouldClearLastSentSize:!0,shouldDetachShell:!!e}}function hg({shellId:e,viewerId:r,socketReadyState:n,openReadyState:a,hasAttachRetryTimer:s,hasAttachTimeout:o,isCurrentSocket:l}){const i=gl({shellId:e,viewerId:r});return{intentionalDisconnect:!0,shouldClearAttachRetry:s,detachMessage:i,shouldSendDetachMessage:!!(i&&n===a),shouldClearViewer:!0,isConnecting:!1,settleAttachPromise:l?!1:void 0,shouldClearAttachTimeout:o,shouldCloseSocket:!0,shouldClearSocketRef:l}}function ug({size:e,previousSize:r,shellId:n,viewerId:a,syncBackendSize:s}){return s?(r==null?void 0:r.cols)===e.cols&&r.rows===e.rows?{nextLastSentSize:r,message:null}:{nextLastSentSize:e,message:n&&a?{type:"shell.resize",shellId:n,viewerId:a,cols:e.cols,rows:e.rows}:null}:{nextLastSentSize:r??e,message:null}}function mg(e,r){const n=typeof e.cwdBaseName=="string"?e.cwdBaseName:null,a=typeof e.envPrefix=="string"?e.envPrefix:null;return{data:typeof e.data=="string"?e.data:"",replace:e.replace===!0,cursorX:typeof e.cursorX=="number"?e.cursorX:void 0,cursorY:typeof e.cursorY=="number"?e.cursorY:void 0,paneHeight:typeof e.paneHeight=="number"?e.paneHeight:void 0,promptLabel:aa(n??Xr(r),a),isCommandRunning:e.isCommandRunning===!0}}function pg({currentSnapshot:e,data:r,replace:n,isCommandRunning:a,pendingCommand:s}){if(!r)return{nextSnapshot:e,nextPendingCommand:s,lastCommandOutput:null};const o=Un(n?r:`${e}${r}`);return!n||a||!s?{nextSnapshot:o,nextPendingCommand:s,lastCommandOutput:null}:{nextSnapshot:o,nextPendingCommand:null,lastCommandOutput:Vf(s.beforeSnapshot,o,s.command)}}function fg({event:e,currentViewerId:r}){if(e.type==="shell.output")return null;if(e.type==="shell.connected"){const a=String(e.payload.viewerId??"");return{viewerId:a||null,isConnecting:!1,settleAttachPromise:!!a,isCommandRunning:void 0,connectionError:void 0,intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:{status:"attached",attachedViewerId:a}}}if(e.type==="shell.error")return{viewerId:void 0,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:void 0,connectionError:String(e.payload.message??"Shell connection failed."),intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:e.payload.code==="viewer_conflict"?{status:"detached",attachedViewerId:null}:void 0};if(e.type==="shell.detached"){const a=String(e.payload.viewerId??"");if(!a||a!==r)return null;const s=String(e.payload.reason??"");return{viewerId:null,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:!1,connectionError:s==="replaced"?"This shell connection was taken over by another pane or device.":null,intentionalDisconnect:s==="replaced"?!0:void 0,closeSocket:!0,shellUpdate:{status:"detached",attachedViewerId:null}}}if(e.type==="shell.exited")return{viewerId:null,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:!1,connectionError:void 0,intentionalDisconnect:!0,closeSocket:!0,shellUpdate:{status:e.payload.state==="exited"?"exited":"not_found",attachedViewerId:null}};const n=e.payload.state;return{viewerId:n==="attached"?void 0:null,isConnecting:n==="attached"?void 0:!1,settleAttachPromise:n==="attached"?void 0:!1,isCommandRunning:n==="attached"?void 0:!1,connectionError:void 0,intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:{status:n,attachedViewerId:n==="attached"?void 0:null}}}function xl(e,r,n,a,s){const o=r.replace(/\r\n/g,`
|
|
3618
3625
|
`),l=o.split(`
|
|
3619
3626
|
`);o.endsWith(`
|
|
3620
3627
|
`)&&l.at(-1)===""&&l.pop();let d=l.join(`\r
|
|
3621
|
-
`);if(n!==void 0&&a!==void 0){const u=(s!==void 0?Math.max(0,l.length-s):0)+a,m=Math.max(0,l.length-u-1);m>0&&(d+=`\x1B[${m}A`),d+=`\r\x1B[${n+1}G`}e.reset(),e.write(d,()=>{e.scrollToBottom()})}function
|
|
3622
|
-
`).trimEnd():""}function gg({clearTimeout:e}){let r=null;const n=s=>{(s==null?void 0:s.timer)!==null&&(s==null?void 0:s.timer)!==void 0&&e(s.timer)};return{hasPending:()=>!!r,joinPending:()=>new Promise(s=>{r==null||r.waiters.push(s)}),start:({timeoutMs:s,setTimeout:o,onTimeout:l})=>new Promise(i=>{const d=o(()=>{r=null,l(),i(!1)},s);r={waiters:[i],timer:d}}),settle:s=>{const o=r;if(o){r=null,n(o);for(const l of o.waiters)l(s)}},clear:()=>{const s=r;r=null,n(s)}}}var Ls={status:"not_created",shellInputEnabled:!1,isConnecting:!1,isCommandRunning:!1,promptLabel:null,error:null,hasShell:!1};function mt(e){return e.status!=="exited"&&e.status!=="not_found"}function xg({shell:e,workspacePathMissing:r}){return!!(e&&!r&&mt(e))}function bg(e,r){return e.status===r.status&&e.shellInputEnabled===r.shellInputEnabled&&e.isConnecting===r.isConnecting&&e.isCommandRunning===r.isCommandRunning&&e.promptLabel===r.promptLabel&&e.error===r.error&&e.hasShell===r.hasShell}function vg(e){return(e.activeShellId?e.shells.find(r=>r.id===e.activeShellId&&mt(r)):null)??(e.shell&&mt(e.shell)?e.shell:null)??e.shells.find(mt)??null}function kg({activeRuntime:e,activeShell:r,busy:n,loading:a,status:s,workspacePathMissing:o}){const l=n||a||s==="creating"||o,i=e.shellInputEnabled?"Disconnect shell":r&&!mt(r)?"Restart shell":r?"Connect shell":"Create shell",d=e.shellInputEnabled?"border-emerald-300/45 bg-emerald-300/18 text-emerald-50 ring-1 ring-emerald-300/20 hover:bg-emerald-300/24":r&&!mt(r)?"border-stone-600 bg-stone-800/90 text-stone-100 hover:border-stone-500 hover:bg-stone-800":o?"border-rose-300/35 bg-rose-300/12 text-rose-100":"border-stone-600 bg-stone-800/90 text-stone-100 hover:border-stone-500 hover:bg-stone-800";return{disabled:l,label:i,className:d}}function wg({activeRuntime:e,activeShell:r,connectionButtonDisabled:n,connectionButtonLabel:a,isMobileShell:s,busy:o,loading:l,error:i}){return{status:e.status,connectionButtonDisabled:n,connectionButtonLabel:a,shellInputEnabled:e.shellInputEnabled,isConnecting:e.isConnecting,isCommandRunning:e.isCommandRunning,promptLabel:e.promptLabel??(r?sa(Xr(r.cwd),null):null),isMobileShell:s,hasShell:!!r,busy:o,loading:l,error:e.error??i}}function It(e){return e.current===null?!1:(window.clearTimeout(e.current),e.current=null,!0)}function yg({attachRetryTimerRef:e,setReconnectKey:r,delayMs:n=Yf}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function jg({reconnectTimerRef:e,setReconnectKey:r,delayMs:n=Zf}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function Ng({shellSocket:e,socketRef:r,viewerIdRef:n,attachTimeoutRef:a,setConnectionError:s,setIsConnecting:o,settleAttachPromise:l,delayMs:i=Jf}){a.current=window.setTimeout(()=>{var h,u,m;a.current=null;const d=tg({isCurrentSocket:!e.socket||((h=r.current)==null?void 0:h.socket)===e.socket,viewerId:n.current});d&&(s(d.connectionError),o(d.isConnecting),l(d.settleAttachPromise),d.closeSocket&&((u=e.close)==null||u.call(e),(m=e.socket)==null||m.close()))},i)}function Cg(e){return{...e,status:e.status==="attached"?"detached":e.status,attachedViewerId:null}}function Sg({shellId:e,viewerId:r,shellSocket:n,attachRetryTimerRef:a,attachTimeoutRef:s,socketRef:o,openReadyState:l}){var i;return hg({shellId:e,viewerId:r,socketReadyState:n.socket.readyState,openReadyState:l,hasAttachRetryTimer:a.current!==null,hasAttachTimeout:s.current!==null,isCurrentSocket:((i=o.current)==null?void 0:i.socket)===n.socket})}function Tg({closeApplication:e,shellId:r,attachTimeoutRef:n,socketRef:a,reconnectTimerRef:s,setViewerId:o,setIsConnecting:l,settleAttachPromise:i,onShellUpdate:d,setReconnectKey:h}){const u=e.closeAction;return u?(e.shouldClearAttachTimeout&&It(n),e.shouldClearSocketRef&&(a.current=null),o(e.viewerId),l(e.isConnecting),i(e.settleAttachPromise),u.shouldDetachShell&&d(r,Cg,"detached"),u.shouldScheduleReconnect&&jg({reconnectTimerRef:s,setReconnectKey:h}),!0):!1}function Eg({cleanupAction:e,shellSocket:r,attachRetryTimerRef:n,attachTimeoutRef:a,socketRef:s,intentionalDisconnectRef:o,setViewerId:l,setIsConnecting:i,settleAttachPromise:d}){o.current=e.intentionalDisconnect,e.shouldClearAttachRetry&&It(n),e.shouldSendDetachMessage&&e.detachMessage&&r.send(e.detachMessage),l(null),i(e.isConnecting),e.settleAttachPromise!==void 0&&d(e.settleAttachPromise),e.shouldClearAttachTimeout&&It(a),r.socket.close(),e.shouldClearSocketRef&&(s.current=null)}function Lg({eventShellId:e,shellId:r,socketExists:n,isCurrentSocket:a}){return n&&!a?!1:e===r}function Pg(e){return gl({...e,attachSize:void 0})}function zg({attachSize:e,...r}){return gl({...r,attachSize:e})}function Ig({isCurrentSocket:e,shellId:r,attachSize:n,hasAttachTimeout:a}){const s=rg({isCurrentSocket:e,shellId:r,attachSize:n});return{openAction:s,shouldClearAttachTimeout:!!(s&&a)}}function Rg(e){const r=String(e.payload.viewerId??"");return{viewerId:r||null,settleAttachPromise:!!r,nextShell:n=>({...n,status:"attached",attachedViewerId:r})}}function Mg({event:e,shellCwd:r,currentSnapshot:n,pendingCommand:a}){const s=mg(e.payload,r),o=s.data?pg({currentSnapshot:n,data:s.data,replace:s.replace,isCommandRunning:s.isCommandRunning,pendingCommand:a}):null;return{output:s,snapshotUpdate:o}}function _g({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:s,hasAttachTimeout:o}){const l=ag({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:s});return{closeAction:l,shouldClearAttachTimeout:!!(l&&o),shouldClearSocketRef:!!l,viewerId:null,isConnecting:!1,settleAttachPromise:!1}}function Ag(e,r){return r.shellUpdate?{...e,status:r.shellUpdate.status==="attached"||r.shellUpdate.status==="detached"||r.shellUpdate.status==="exited"||r.shellUpdate.status==="not_found"?r.shellUpdate.status:e.status,attachedViewerId:r.shellUpdate.attachedViewerId===void 0?e.attachedViewerId:r.shellUpdate.attachedViewerId}:e}function $g(e){return e.current}function Dg({shell:e,shellAdapter:r,canAttachShell:n,terminalReady:a,reconnectKey:s,terminalRef:o,socketRef:l,viewerIdRef:i,shellIdRef:d,reconnectTimerRef:h,attachTimeoutRef:u,attachRetryTimerRef:m,isVisibleRef:f,intentionalDisconnectRef:p,userDisconnectedShellIdRef:g,shellSnapshotRef:b,pendingCommandRef:v,lastCommandOutputRef:x,snapshotCursorRef:y,syncTerminalSizeRef:k,setReconnectKey:j,setViewerId:w,setIsConnecting:N,setConnectionError:S,setRuntimePromptLabel:L,setIsCommandRunning:T,settleAttachPromise:q,onShellUpdate:A}){const D=e==null?void 0:e.id,J=e==null?void 0:e.cwd;c.useEffect(()=>{const W=o.current,O={shellId:D??null,terminalReady:a,isVisible:f.current,canAttachShell:n,userDisconnectedShellId:g.current,hasTerminal:!!W,hasPendingAttachRetry:m.current!==null,hasCurrentSocketForShell:!!(l.current&&d.current===D),hasReconnectTimer:h.current!==null};if(Pg(O).type==="skip")return;const he=k.current(),E=zg({...O,attachSize:he});if(E.type==="skip"||E.type==="measureSize")return;if(E.type==="scheduleRetry"){yg({attachRetryTimerRef:m,setReconnectKey:j});return}if(E.shouldClearAttachRetry&&It(m),E.type==="reuseSocket"||(E.shouldClearReconnectTimer&&It(h),!D||!W))return;const re=E.attachSize;d.current=D,W.reset(),S(null),w(null),N(!0),p.current=!1;const _=r.connectSocket({onConnected:()=>{var X;const V=u.current,U=Ig({isCurrentSocket:((X=l.current)==null?void 0:X.socket)===_.socket,shellId:D,attachSize:re,hasAttachTimeout:V!==null}),z=U.openAction;z&&(_.send(z.message),U.shouldClearAttachTimeout&&V!==null&&It(u),z.shouldScheduleAttachTimeout&&Ng({shellSocket:_,socketRef:l,viewerIdRef:i,attachTimeoutRef:u,setConnectionError:S,setIsConnecting:N,settleAttachPromise:q}))},onShellEvent:V=>{var X;if(!Lg({eventShellId:V.shellId,shellId:D,socketExists:!!_.socket,isCurrentSocket:((X=l.current)==null?void 0:X.socket)===_.socket}))return;if(V.type==="shell.connected"){It(u);const F=Rg(V);w(F.viewerId),N(!1),q(F.settleAttachPromise),A(D,F.nextShell,"attached");return}if(V.type==="shell.output"){const{output:F,snapshotUpdate:I}=Mg({event:V,shellCwd:J,currentSnapshot:b.current,pendingCommand:v.current});y.current={cursorX:F.cursorX,cursorY:F.cursorY,paneHeight:F.paneHeight},L(F.promptLabel),T(F.isCommandRunning),I&&(b.current=I.nextSnapshot,v.current=I.nextPendingCommand,I.lastCommandOutput!==null&&(x.current=I.lastCommandOutput),F.replace?bl(W,F.data,F.cursorX,F.cursorY,F.paneHeight):W.write(F.data));return}const z=fg({event:V,currentViewerId:i.current});z&&(z.viewerId!==void 0&&w(z.viewerId),z.isConnecting!==void 0&&N(z.isConnecting),z.settleAttachPromise!==void 0&&q(z.settleAttachPromise),z.isCommandRunning!==void 0&&T(z.isCommandRunning),z.connectionError!==void 0&&S(z.connectionError),z.intentionalDisconnect!==void 0&&(p.current=z.intentionalDisconnect),z.shellUpdate&&A(D,F=>Ag(F,z),z.shellUpdate.status),z.closeSocket&&_.socket.close())}});return l.current=_,_.socket.addEventListener("close",()=>{var z;const V=u.current,U=_g({isCurrentSocket:((z=l.current)==null?void 0:z.socket)===_.socket,hadViewer:!!i.current,intentionalDisconnect:p.current,userDisconnectedShellId:g.current,shellId:D,hasAttachTimeout:V!==null});Tg({closeApplication:U,shellId:D,attachTimeoutRef:u,socketRef:l,reconnectTimerRef:h,setViewerId:w,setIsConnecting:N,settleAttachPromise:q,onShellUpdate:A,setReconnectKey:j})}),()=>{const V=$g(i),U=Sg({shellId:D,viewerId:V,shellSocket:_,attachRetryTimerRef:m,attachTimeoutRef:u,socketRef:l,openReadyState:WebSocket.OPEN});Eg({cleanupAction:U,shellSocket:_,attachRetryTimerRef:m,attachTimeoutRef:u,socketRef:l,intentionalDisconnectRef:p,setViewerId:w,setIsConnecting:N,settleAttachPromise:q})}},[m,u,n,p,f,x,A,v,s,h,S,T,N,j,L,w,q,J,D,r,d,b,y,l,k,a,o,g,i])}function yn(e){return e.current}var Ps=c.forwardRef(function({paneId:r,shell:n,isActive:a,isVisible:s,isMobileShell:o,effectiveTheme:l,workspacePathMissing:i,shellAdapter:d,onActivate:h,onShellUpdate:u,onRuntimeStateChange:m,onFeedback:f},p){const g=c.useRef(null),b=c.useRef(null),v=c.useRef(null),x=c.useRef(null),y=c.useRef(null),k=c.useRef(null),j=c.useRef(null),w=c.useRef(null),N=c.useRef(!1),S=c.useRef(null),L=c.useRef(""),T=c.useRef(null),q=c.useRef(""),A=c.useRef(null),D=c.useRef(null),J=c.useRef({cursorX:void 0,cursorY:void 0,paneHeight:void 0}),W=c.useRef(!1),O=c.useRef(null),ee=c.useRef(s),he=c.useRef(o),E=c.useRef(()=>!1),re=c.useRef(()=>null),_=c.useRef(()=>{}),V=c.useRef(gg({clearTimeout:window.clearTimeout})),[U,z]=c.useState(null),[X,F]=c.useState(!1),[I,P]=c.useState(null),[Z,K]=c.useState(!1),[de,M]=c.useState(null),[Y,te]=c.useState(null),[ie,ue]=c.useState(!1),[be,Le]=c.useState(0),ae=(n==null?void 0:n.status)??"not_created",ve=xg({shell:n,workspacePathMissing:i}),ke=c.useMemo(()=>sa(Xr(n==null?void 0:n.cwd),null),[n==null?void 0:n.cwd]),pe=Y??ke,ze=c.useCallback(H=>{x.current=H,P(H)},[]),je=c.useCallback(H=>{V.current.settle(H)},[]);c.useEffect(()=>{ee.current=s},[s]),c.useEffect(()=>{he.current=o},[o]),c.useEffect(()=>{y.current=(n==null?void 0:n.id)??null},[n==null?void 0:n.id]);const Me=c.useCallback(H=>{const ce=v.current,R=y.current,$=x.current;return!ce||!R||!$?!1:(ce.send({type:"shell.input",shellId:R,viewerId:$,data:H}),!0)},[]);c.useEffect(()=>{E.current=Me},[Me]);const Pe=c.useCallback(()=>{const H=v.current,ce=y.current,R=x.current;return!H||!ce||!R?!1:(H.send({type:"shell.clear",shellId:ce,viewerId:R}),!0)},[]),_e=c.useCallback(()=>{if(!s||!U)return!1;const H=U.getBoundingClientRect();return H.width>0&&H.height>0},[s,U]),Ce=c.useCallback(H=>{const ce=g.current,R=b.current;if(!ce||!R||!_e()||(R.fit(),ce.cols<=0||ce.rows<=0))return null;const $={cols:ce.cols,rows:ce.rows},Q=ug({size:$,previousSize:D.current,shellId:y.current,viewerId:x.current,syncBackendSize:(H==null?void 0:H.syncBackendSize)!==!1});return(H==null?void 0:H.syncBackendSize)===!1||(D.current=Q.nextLastSentSize,!Q.message)||v.current&&v.current.send(Q.message),$},[_e]);c.useEffect(()=>{re.current=Ce},[Ce]);const Re=c.useCallback(H=>{const ce=g.current;!ce||!_e()||(Ce((H==null?void 0:H.syncBackendSize)===void 0?void 0:{syncBackendSize:H.syncBackendSize}),L.current&&!Es(U)?bl(ce,L.current,J.current.cursorX,J.current.cursorY,J.current.paneHeight):ce.scrollToBottom(),H!=null&&H.focus&&!o&&ce.focus())},[o,_e,Ce,U]);return c.useEffect(()=>{_.current=()=>Re()},[Re]),c.useEffect(()=>{m({status:I?"attached":ae,shellInputEnabled:!!(I&&n),isConnecting:Z,isCommandRunning:ie,promptLabel:pe,error:de,hasShell:!!n})},[de,Z,ie,m,pe,n,ae,I]),c.useEffect(()=>{if(!U||g.current||W.current)return;let H=!1;return W.current=!0,(async()=>{const[{Terminal:ce},{FitAddon:R}]=await Promise.all([Ue(()=>import("./terminal-vendor-B365Go3Z.js").then(me=>me.x),__vite__mapDeps([6,2,7])),Ue(()=>import("./terminal-vendor-B365Go3Z.js").then(me=>me.a),__vite__mapDeps([6,2,7]))]);if(H||!U){W.current=!1;return}const $=new ce({cursorBlink:!0,disableStdin:he.current,fontFamily:"IBM Plex Mono, SFMono-Regular, Menlo, monospace",fontSize:13,lineHeight:1.25,scrollback:3e3,theme:Ss(l)}),Q=new R;$.loadAddon(Q),$.open(U),g.current=$,b.current=Q,re.current(),$.attachCustomKeyEventHandler(me=>{if(he.current||me.type!=="keydown")return!0;if(me.ctrlKey&&!me.altKey&&!me.metaKey&&!me.shiftKey){const xe=Of(me.key);if(!xe)return!0;if(E.current(xe))return me.preventDefault(),!1}return!0}),F(!0),W.current=!1,A.current=new ResizeObserver(()=>{_.current()}),A.current.observe(U),O.current=$.onData(me=>{he.current||E.current(me)})})(),()=>{var ce,R,$;H=!0,W.current=!1,(ce=O.current)==null||ce.dispose(),O.current=null,(R=A.current)==null||R.disconnect(),A.current=null,F(!1),($=g.current)==null||$.dispose(),g.current=null,b.current=null,D.current=null}},[l,U]),c.useEffect(()=>{var ce;const H=ig({hasShell:!!n});H&&(ze(H.viewerId),K(H.isConnecting),je(H.settleAttachPromise),M(H.connectionError),te(H.runtimePromptLabel),ue(H.isCommandRunning),L.current=H.shellSnapshot,q.current=H.lastCommandOutput,T.current=H.pendingCommand,H.shouldResetTerminal&&((ce=g.current)==null||ce.reset()))},[ze,je,n]),c.useEffect(()=>{const H=g.current;H&&(H.options.theme=Ss(l))},[l]),c.useEffect(()=>{const H=g.current;H&&(H.options.disableStdin=o)},[o]),c.useEffect(()=>{if(!s||!X)return;const H=window.requestAnimationFrame(()=>{Re({focus:a,syncBackendSize:!1}),!v.current&&(n!=null&&n.id)&&S.current!==n.id&&Le(ce=>ce+1)});return()=>{window.cancelAnimationFrame(H)}},[a,s,Re,n==null?void 0:n.id,X]),Dg({shell:n,shellAdapter:d,canAttachShell:ve,terminalReady:X,reconnectKey:be,terminalRef:g,socketRef:v,viewerIdRef:x,shellIdRef:y,reconnectTimerRef:k,attachTimeoutRef:j,attachRetryTimerRef:w,isVisibleRef:ee,intentionalDisconnectRef:N,userDisconnectedShellIdRef:S,shellSnapshotRef:L,pendingCommandRef:T,lastCommandOutputRef:q,snapshotCursorRef:J,syncTerminalSizeRef:re,setReconnectKey:Le,setViewerId:ze,setIsConnecting:K,setConnectionError:M,setRuntimePromptLabel:te,setIsCommandRunning:ue,settleAttachPromise:je,onShellUpdate:u}),c.useEffect(()=>()=>{const H=yn(k),ce=yn(j),R=yn(w),$=dg({hasReconnectTimer:H!==null,hasAttachTimeout:ce!==null,hasAttachRetry:R!==null});$.shouldClearReconnectTimer&&H!==null&&window.clearTimeout(H),$.shouldClearAttachTimeout&&ce!==null&&window.clearTimeout(ce),$.shouldClearAttachRetry&&R!==null&&window.clearTimeout(R),je($.settleAttachPromise)},[je]),c.useImperativeHandle(p,()=>({disconnect(){const H=v.current,ce=y.current,R=x.current,$=cg({shellId:ce,viewerId:R,hasSocket:!!H});S.current=$.userDisconnectedShellId,N.current=$.intentionalDisconnect,H&&$.detachMessage&&H.send($.detachMessage),ze(null),K(!1),je(!1),$.shouldCloseSocket&&(H==null||H.socket.close()),v.current=null,D.current=null,$.shouldDetachShell&&ce&&u(ce,Q=>({...Q,status:"detached",attachedViewerId:null}),"detached")},reconnect(){const H=og({hasShellId:!!y.current,terminalReady:X,workspacePathMissing:i,hasViewer:!!x.current,hasPendingAttach:V.current.hasPending()});if(H.type==="reject")return Promise.resolve(!1);if(H.type==="alreadyConnected")return Promise.resolve(!0);if(H.type==="joinPending")return V.current.joinPending();const ce=V.current.start({timeoutMs:Qf,setTimeout:window.setTimeout,onTimeout:()=>{K(!1)}}),R=lg({shellId:y.current,userDisconnectedShellId:S.current});return R.shouldClearUserDisconnectedShellId&&(S.current=null),N.current=R.intentionalDisconnect,M(R.connectionError),K(R.isConnecting),Le($=>$+1),ce},sendInput(H){return Me(H)},sendCommand(H){const ce={command:H,beforeSnapshot:L.current};if(T.current=ce,H.trim()==="clear"){const Q=Pe();return!Q&&T.current===ce&&(T.current=null),Q}const R=H.endsWith(`
|
|
3628
|
+
`);if(n!==void 0&&a!==void 0){const u=(s!==void 0?Math.max(0,l.length-s):0)+a,m=Math.max(0,l.length-u-1);m>0&&(d+=`\x1B[${m}A`),d+=`\r\x1B[${n+1}G`}e.reset(),e.write(d,()=>{e.scrollToBottom()})}function Ts(e){return e?Array.from(e.querySelectorAll(".xterm-rows > div")).map(n=>n.textContent??"").filter((n,a,s)=>n.length>0||a<s.length-1).join(`
|
|
3629
|
+
`).trimEnd():""}function gg({clearTimeout:e}){let r=null;const n=s=>{(s==null?void 0:s.timer)!==null&&(s==null?void 0:s.timer)!==void 0&&e(s.timer)};return{hasPending:()=>!!r,joinPending:()=>new Promise(s=>{r==null||r.waiters.push(s)}),start:({timeoutMs:s,setTimeout:o,onTimeout:l})=>new Promise(i=>{const d=o(()=>{r=null,l(),i(!1)},s);r={waiters:[i],timer:d}}),settle:s=>{const o=r;if(o){r=null,n(o);for(const l of o.waiters)l(s)}},clear:()=>{const s=r;r=null,n(s)}}}var Es={status:"not_created",shellInputEnabled:!1,isConnecting:!1,isCommandRunning:!1,promptLabel:null,error:null,hasShell:!1};function mt(e){return e.status!=="exited"&&e.status!=="not_found"}function xg({shell:e,workspacePathMissing:r}){return!!(e&&!r&&mt(e))}function bg(e,r){return e.status===r.status&&e.shellInputEnabled===r.shellInputEnabled&&e.isConnecting===r.isConnecting&&e.isCommandRunning===r.isCommandRunning&&e.promptLabel===r.promptLabel&&e.error===r.error&&e.hasShell===r.hasShell}function vg(e){return(e.activeShellId?e.shells.find(r=>r.id===e.activeShellId&&mt(r)):null)??(e.shell&&mt(e.shell)?e.shell:null)??e.shells.find(mt)??null}function kg({activeRuntime:e,activeShell:r,busy:n,loading:a,status:s,workspacePathMissing:o}){const l=n||a||s==="creating"||o,i=e.shellInputEnabled?"Disconnect shell":r&&!mt(r)?"Restart shell":r?"Connect shell":"Create shell",d=e.shellInputEnabled?"border-emerald-300/45 bg-emerald-300/18 text-emerald-50 ring-1 ring-emerald-300/20 hover:bg-emerald-300/24":r&&!mt(r)?"border-stone-600 bg-stone-800/90 text-stone-100 hover:border-stone-500 hover:bg-stone-800":o?"border-rose-300/35 bg-rose-300/12 text-rose-100":"border-stone-600 bg-stone-800/90 text-stone-100 hover:border-stone-500 hover:bg-stone-800";return{disabled:l,label:i,className:d}}function wg({activeRuntime:e,activeShell:r,connectionButtonDisabled:n,connectionButtonLabel:a,isMobileShell:s,busy:o,loading:l,error:i}){return{status:e.status,connectionButtonDisabled:n,connectionButtonLabel:a,shellInputEnabled:e.shellInputEnabled,isConnecting:e.isConnecting,isCommandRunning:e.isCommandRunning,promptLabel:e.promptLabel??(r?aa(Xr(r.cwd),null):null),isMobileShell:s,hasShell:!!r,busy:o,loading:l,error:e.error??i}}function zt(e){return e.current===null?!1:(window.clearTimeout(e.current),e.current=null,!0)}function yg({attachRetryTimerRef:e,setReconnectKey:r,delayMs:n=Yf}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function jg({reconnectTimerRef:e,setReconnectKey:r,delayMs:n=Zf}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function Ng({shellSocket:e,socketRef:r,viewerIdRef:n,attachTimeoutRef:a,setConnectionError:s,setIsConnecting:o,settleAttachPromise:l,delayMs:i=Jf}){a.current=window.setTimeout(()=>{var h,u,m;a.current=null;const d=tg({isCurrentSocket:!e.socket||((h=r.current)==null?void 0:h.socket)===e.socket,viewerId:n.current});d&&(s(d.connectionError),o(d.isConnecting),l(d.settleAttachPromise),d.closeSocket&&((u=e.close)==null||u.call(e),(m=e.socket)==null||m.close()))},i)}function Cg(e){return{...e,status:e.status==="attached"?"detached":e.status,attachedViewerId:null}}function Sg({shellId:e,viewerId:r,shellSocket:n,attachRetryTimerRef:a,attachTimeoutRef:s,socketRef:o,openReadyState:l}){var i;return hg({shellId:e,viewerId:r,socketReadyState:n.socket.readyState,openReadyState:l,hasAttachRetryTimer:a.current!==null,hasAttachTimeout:s.current!==null,isCurrentSocket:((i=o.current)==null?void 0:i.socket)===n.socket})}function Tg({closeApplication:e,shellId:r,attachTimeoutRef:n,socketRef:a,reconnectTimerRef:s,setViewerId:o,setIsConnecting:l,settleAttachPromise:i,onShellUpdate:d,setReconnectKey:h}){const u=e.closeAction;return u?(e.shouldClearAttachTimeout&&zt(n),e.shouldClearSocketRef&&(a.current=null),o(e.viewerId),l(e.isConnecting),i(e.settleAttachPromise),u.shouldDetachShell&&d(r,Cg,"detached"),u.shouldScheduleReconnect&&jg({reconnectTimerRef:s,setReconnectKey:h}),!0):!1}function Eg({cleanupAction:e,shellSocket:r,attachRetryTimerRef:n,attachTimeoutRef:a,socketRef:s,intentionalDisconnectRef:o,setViewerId:l,setIsConnecting:i,settleAttachPromise:d}){o.current=e.intentionalDisconnect,e.shouldClearAttachRetry&&zt(n),e.shouldSendDetachMessage&&e.detachMessage&&r.send(e.detachMessage),l(null),i(e.isConnecting),e.settleAttachPromise!==void 0&&d(e.settleAttachPromise),e.shouldClearAttachTimeout&&zt(a),r.socket.close(),e.shouldClearSocketRef&&(s.current=null)}function Lg({eventShellId:e,shellId:r,socketExists:n,isCurrentSocket:a}){return n&&!a?!1:e===r}function Pg(e){return fl({...e,attachSize:void 0})}function Ig({attachSize:e,...r}){return fl({...r,attachSize:e})}function zg({isCurrentSocket:e,shellId:r,attachSize:n,hasAttachTimeout:a}){const s=rg({isCurrentSocket:e,shellId:r,attachSize:n});return{openAction:s,shouldClearAttachTimeout:!!(s&&a)}}function Rg(e){const r=String(e.payload.viewerId??"");return{viewerId:r||null,settleAttachPromise:!!r,nextShell:n=>({...n,status:"attached",attachedViewerId:r})}}function _g({event:e,shellCwd:r,currentSnapshot:n,pendingCommand:a}){const s=mg(e.payload,r),o=s.data?pg({currentSnapshot:n,data:s.data,replace:s.replace,isCommandRunning:s.isCommandRunning,pendingCommand:a}):null;return{output:s,snapshotUpdate:o}}function Ag({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:s,hasAttachTimeout:o}){const l=ag({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:s});return{closeAction:l,shouldClearAttachTimeout:!!(l&&o),shouldClearSocketRef:!!l,viewerId:null,isConnecting:!1,settleAttachPromise:!1}}function Mg(e,r){return r.shellUpdate?{...e,status:r.shellUpdate.status==="attached"||r.shellUpdate.status==="detached"||r.shellUpdate.status==="exited"||r.shellUpdate.status==="not_found"?r.shellUpdate.status:e.status,attachedViewerId:r.shellUpdate.attachedViewerId===void 0?e.attachedViewerId:r.shellUpdate.attachedViewerId}:e}function $g(e){return e.current}function Dg({shell:e,shellAdapter:r,canAttachShell:n,terminalReady:a,reconnectKey:s,terminalRef:o,socketRef:l,viewerIdRef:i,shellIdRef:d,reconnectTimerRef:h,attachTimeoutRef:u,attachRetryTimerRef:m,isVisibleRef:f,intentionalDisconnectRef:p,userDisconnectedShellIdRef:g,shellSnapshotRef:b,pendingCommandRef:v,lastCommandOutputRef:x,snapshotCursorRef:y,syncTerminalSizeRef:k,setReconnectKey:N,setViewerId:w,setIsConnecting:j,setConnectionError:C,setRuntimePromptLabel:L,setIsCommandRunning:T,settleAttachPromise:q,onShellUpdate:M}){const D=e==null?void 0:e.id,J=e==null?void 0:e.cwd;c.useEffect(()=>{const W=o.current,O={shellId:D??null,terminalReady:a,isVisible:f.current,canAttachShell:n,userDisconnectedShellId:g.current,hasTerminal:!!W,hasPendingAttachRetry:m.current!==null,hasCurrentSocketForShell:!!(l.current&&d.current===D),hasReconnectTimer:h.current!==null};if(Pg(O).type==="skip")return;const he=k.current(),E=Ig({...O,attachSize:he});if(E.type==="skip"||E.type==="measureSize")return;if(E.type==="scheduleRetry"){yg({attachRetryTimerRef:m,setReconnectKey:N});return}if(E.shouldClearAttachRetry&&zt(m),E.type==="reuseSocket"||(E.shouldClearReconnectTimer&&zt(h),!D||!W))return;const re=E.attachSize;d.current=D,W.reset(),C(null),w(null),j(!0),p.current=!1;const A=r.connectSocket({onConnected:()=>{var X;const V=u.current,U=zg({isCurrentSocket:((X=l.current)==null?void 0:X.socket)===A.socket,shellId:D,attachSize:re,hasAttachTimeout:V!==null}),I=U.openAction;I&&(A.send(I.message),U.shouldClearAttachTimeout&&V!==null&&zt(u),I.shouldScheduleAttachTimeout&&Ng({shellSocket:A,socketRef:l,viewerIdRef:i,attachTimeoutRef:u,setConnectionError:C,setIsConnecting:j,settleAttachPromise:q}))},onShellEvent:V=>{var X;if(!Lg({eventShellId:V.shellId,shellId:D,socketExists:!!A.socket,isCurrentSocket:((X=l.current)==null?void 0:X.socket)===A.socket}))return;if(V.type==="shell.connected"){zt(u);const F=Rg(V);w(F.viewerId),j(!1),q(F.settleAttachPromise),M(D,F.nextShell,"attached");return}if(V.type==="shell.output"){const{output:F,snapshotUpdate:z}=_g({event:V,shellCwd:J,currentSnapshot:b.current,pendingCommand:v.current});y.current={cursorX:F.cursorX,cursorY:F.cursorY,paneHeight:F.paneHeight},L(F.promptLabel),T(F.isCommandRunning),z&&(b.current=z.nextSnapshot,v.current=z.nextPendingCommand,z.lastCommandOutput!==null&&(x.current=z.lastCommandOutput),F.replace?xl(W,F.data,F.cursorX,F.cursorY,F.paneHeight):W.write(F.data));return}const I=fg({event:V,currentViewerId:i.current});I&&(I.viewerId!==void 0&&w(I.viewerId),I.isConnecting!==void 0&&j(I.isConnecting),I.settleAttachPromise!==void 0&&q(I.settleAttachPromise),I.isCommandRunning!==void 0&&T(I.isCommandRunning),I.connectionError!==void 0&&C(I.connectionError),I.intentionalDisconnect!==void 0&&(p.current=I.intentionalDisconnect),I.shellUpdate&&M(D,F=>Mg(F,I),I.shellUpdate.status),I.closeSocket&&A.socket.close())}});return l.current=A,A.socket.addEventListener("close",()=>{var I;const V=u.current,U=Ag({isCurrentSocket:((I=l.current)==null?void 0:I.socket)===A.socket,hadViewer:!!i.current,intentionalDisconnect:p.current,userDisconnectedShellId:g.current,shellId:D,hasAttachTimeout:V!==null});Tg({closeApplication:U,shellId:D,attachTimeoutRef:u,socketRef:l,reconnectTimerRef:h,setViewerId:w,setIsConnecting:j,settleAttachPromise:q,onShellUpdate:M,setReconnectKey:N})}),()=>{const V=$g(i),U=Sg({shellId:D,viewerId:V,shellSocket:A,attachRetryTimerRef:m,attachTimeoutRef:u,socketRef:l,openReadyState:WebSocket.OPEN});Eg({cleanupAction:U,shellSocket:A,attachRetryTimerRef:m,attachTimeoutRef:u,socketRef:l,intentionalDisconnectRef:p,setViewerId:w,setIsConnecting:j,settleAttachPromise:q})}},[m,u,n,p,f,x,M,v,s,h,C,T,j,N,L,w,q,J,D,r,d,b,y,l,k,a,o,g,i])}function wn(e){return e.current}var Ls=c.forwardRef(function({paneId:r,shell:n,isActive:a,isVisible:s,isMobileShell:o,effectiveTheme:l,workspacePathMissing:i,shellAdapter:d,onActivate:h,onShellUpdate:u,onRuntimeStateChange:m,onFeedback:f},p){const g=c.useRef(null),b=c.useRef(null),v=c.useRef(null),x=c.useRef(null),y=c.useRef(null),k=c.useRef(null),N=c.useRef(null),w=c.useRef(null),j=c.useRef(!1),C=c.useRef(null),L=c.useRef(""),T=c.useRef(null),q=c.useRef(""),M=c.useRef(null),D=c.useRef(null),J=c.useRef({cursorX:void 0,cursorY:void 0,paneHeight:void 0}),W=c.useRef(!1),O=c.useRef(null),ee=c.useRef(s),he=c.useRef(o),E=c.useRef(()=>!1),re=c.useRef(()=>null),A=c.useRef(()=>{}),V=c.useRef(gg({clearTimeout:window.clearTimeout})),[U,I]=c.useState(null),[X,F]=c.useState(!1),[z,P]=c.useState(null),[Z,K]=c.useState(!1),[de,_]=c.useState(null),[Y,te]=c.useState(null),[ie,ue]=c.useState(!1),[be,Le]=c.useState(0),ae=(n==null?void 0:n.status)??"not_created",ve=xg({shell:n,workspacePathMissing:i}),ke=c.useMemo(()=>aa(Xr(n==null?void 0:n.cwd),null),[n==null?void 0:n.cwd]),pe=Y??ke,Ie=c.useCallback(H=>{x.current=H,P(H)},[]),je=c.useCallback(H=>{V.current.settle(H)},[]);c.useEffect(()=>{ee.current=s},[s]),c.useEffect(()=>{he.current=o},[o]),c.useEffect(()=>{y.current=(n==null?void 0:n.id)??null},[n==null?void 0:n.id]);const _e=c.useCallback(H=>{const ce=v.current,R=y.current,$=x.current;return!ce||!R||!$?!1:(ce.send({type:"shell.input",shellId:R,viewerId:$,data:H}),!0)},[]);c.useEffect(()=>{E.current=_e},[_e]);const Pe=c.useCallback(()=>{const H=v.current,ce=y.current,R=x.current;return!H||!ce||!R?!1:(H.send({type:"shell.clear",shellId:ce,viewerId:R}),!0)},[]),Ae=c.useCallback(()=>{if(!s||!U)return!1;const H=U.getBoundingClientRect();return H.width>0&&H.height>0},[s,U]),Ce=c.useCallback(H=>{const ce=g.current,R=b.current;if(!ce||!R||!Ae()||(R.fit(),ce.cols<=0||ce.rows<=0))return null;const $={cols:ce.cols,rows:ce.rows},Q=ug({size:$,previousSize:D.current,shellId:y.current,viewerId:x.current,syncBackendSize:(H==null?void 0:H.syncBackendSize)!==!1});return(H==null?void 0:H.syncBackendSize)===!1||(D.current=Q.nextLastSentSize,!Q.message)||v.current&&v.current.send(Q.message),$},[Ae]);c.useEffect(()=>{re.current=Ce},[Ce]);const Re=c.useCallback(H=>{const ce=g.current;!ce||!Ae()||(Ce((H==null?void 0:H.syncBackendSize)===void 0?void 0:{syncBackendSize:H.syncBackendSize}),L.current&&!Ts(U)?xl(ce,L.current,J.current.cursorX,J.current.cursorY,J.current.paneHeight):ce.scrollToBottom(),H!=null&&H.focus&&!o&&ce.focus())},[o,Ae,Ce,U]);return c.useEffect(()=>{A.current=()=>Re()},[Re]),c.useEffect(()=>{m({status:z?"attached":ae,shellInputEnabled:!!(z&&n),isConnecting:Z,isCommandRunning:ie,promptLabel:pe,error:de,hasShell:!!n})},[de,Z,ie,m,pe,n,ae,z]),c.useEffect(()=>{if(!U||g.current||W.current)return;let H=!1;return W.current=!0,(async()=>{const[{Terminal:ce},{FitAddon:R}]=await Promise.all([Ue(()=>import("./terminal-vendor-B365Go3Z.js").then(me=>me.x),__vite__mapDeps([6,2,7])),Ue(()=>import("./terminal-vendor-B365Go3Z.js").then(me=>me.a),__vite__mapDeps([6,2,7]))]);if(H||!U){W.current=!1;return}const $=new ce({cursorBlink:!0,disableStdin:he.current,fontFamily:"IBM Plex Mono, SFMono-Regular, Menlo, monospace",fontSize:13,lineHeight:1.25,scrollback:3e3,theme:Cs(l)}),Q=new R;$.loadAddon(Q),$.open(U),g.current=$,b.current=Q,re.current(),$.attachCustomKeyEventHandler(me=>{if(he.current||me.type!=="keydown")return!0;if(me.ctrlKey&&!me.altKey&&!me.metaKey&&!me.shiftKey){const xe=Of(me.key);if(!xe)return!0;if(E.current(xe))return me.preventDefault(),!1}return!0}),F(!0),W.current=!1,M.current=new ResizeObserver(()=>{A.current()}),M.current.observe(U),O.current=$.onData(me=>{he.current||E.current(me)})})(),()=>{var ce,R,$;H=!0,W.current=!1,(ce=O.current)==null||ce.dispose(),O.current=null,(R=M.current)==null||R.disconnect(),M.current=null,F(!1),($=g.current)==null||$.dispose(),g.current=null,b.current=null,D.current=null}},[l,U]),c.useEffect(()=>{var ce;const H=ig({hasShell:!!n});H&&(Ie(H.viewerId),K(H.isConnecting),je(H.settleAttachPromise),_(H.connectionError),te(H.runtimePromptLabel),ue(H.isCommandRunning),L.current=H.shellSnapshot,q.current=H.lastCommandOutput,T.current=H.pendingCommand,H.shouldResetTerminal&&((ce=g.current)==null||ce.reset()))},[Ie,je,n]),c.useEffect(()=>{const H=g.current;H&&(H.options.theme=Cs(l))},[l]),c.useEffect(()=>{const H=g.current;H&&(H.options.disableStdin=o)},[o]),c.useEffect(()=>{if(!s||!X)return;const H=window.requestAnimationFrame(()=>{Re({focus:a,syncBackendSize:!1}),!v.current&&(n!=null&&n.id)&&C.current!==n.id&&Le(ce=>ce+1)});return()=>{window.cancelAnimationFrame(H)}},[a,s,Re,n==null?void 0:n.id,X]),Dg({shell:n,shellAdapter:d,canAttachShell:ve,terminalReady:X,reconnectKey:be,terminalRef:g,socketRef:v,viewerIdRef:x,shellIdRef:y,reconnectTimerRef:k,attachTimeoutRef:N,attachRetryTimerRef:w,isVisibleRef:ee,intentionalDisconnectRef:j,userDisconnectedShellIdRef:C,shellSnapshotRef:L,pendingCommandRef:T,lastCommandOutputRef:q,snapshotCursorRef:J,syncTerminalSizeRef:re,setReconnectKey:Le,setViewerId:Ie,setIsConnecting:K,setConnectionError:_,setRuntimePromptLabel:te,setIsCommandRunning:ue,settleAttachPromise:je,onShellUpdate:u}),c.useEffect(()=>()=>{const H=wn(k),ce=wn(N),R=wn(w),$=dg({hasReconnectTimer:H!==null,hasAttachTimeout:ce!==null,hasAttachRetry:R!==null});$.shouldClearReconnectTimer&&H!==null&&window.clearTimeout(H),$.shouldClearAttachTimeout&&ce!==null&&window.clearTimeout(ce),$.shouldClearAttachRetry&&R!==null&&window.clearTimeout(R),je($.settleAttachPromise)},[je]),c.useImperativeHandle(p,()=>({disconnect(){const H=v.current,ce=y.current,R=x.current,$=cg({shellId:ce,viewerId:R,hasSocket:!!H});C.current=$.userDisconnectedShellId,j.current=$.intentionalDisconnect,H&&$.detachMessage&&H.send($.detachMessage),Ie(null),K(!1),je(!1),$.shouldCloseSocket&&(H==null||H.socket.close()),v.current=null,D.current=null,$.shouldDetachShell&&ce&&u(ce,Q=>({...Q,status:"detached",attachedViewerId:null}),"detached")},reconnect(){const H=og({hasShellId:!!y.current,terminalReady:X,workspacePathMissing:i,hasViewer:!!x.current,hasPendingAttach:V.current.hasPending()});if(H.type==="reject")return Promise.resolve(!1);if(H.type==="alreadyConnected")return Promise.resolve(!0);if(H.type==="joinPending")return V.current.joinPending();const ce=V.current.start({timeoutMs:Qf,setTimeout:window.setTimeout,onTimeout:()=>{K(!1)}}),R=lg({shellId:y.current,userDisconnectedShellId:C.current});return R.shouldClearUserDisconnectedShellId&&(C.current=null),j.current=R.intentionalDisconnect,_(R.connectionError),K(R.isConnecting),Le($=>$+1),ce},sendInput(H){return _e(H)},sendCommand(H){const ce={command:H,beforeSnapshot:L.current};if(T.current=ce,H.trim()==="clear"){const Q=Pe();return!Q&&T.current===ce&&(T.current=null),Q}const R=H.endsWith(`
|
|
3623
3630
|
`)?H:`${H}
|
|
3624
|
-
`,$=Me(R);return!$&&T.current===ce&&(T.current=null),$},sendControl(H){return H==="clear"?Pe():Me(Kf(H))},async copyLastCommandOutput(){const H=q.current.trim()||Es(U);if(!H)return f==null||f("failed","Nothing to copy"),!1;try{return await navigator.clipboard.writeText(H),f==null||f("done","Copied"),!0}catch{return f==null||f("failed","Copy failed"),!1}},focus(){var H;(H=g.current)==null||H.focus()},refreshLayout(H){Re(H)}}),[f,u,Re,Pe,Me,ze,je,U,X,i]),t.jsxs("div",{className:`relative min-h-0 flex-1 overflow-hidden ${a?"shell-pane-active":""}`,onMouseDown:h,"data-pane-id":r,children:[t.jsx("div",{ref:z,className:`h-full w-full px-2 py-2 sm:px-3 sm:py-3 ${o?"mobile-shell-selectable":""}`,onMouseDown:()=>{var H;h(),(H=g.current)==null||H.focus()}}),a&&t.jsx("div",{className:"pointer-events-none absolute right-2 top-2 rounded-md border border-sky-300/30 bg-sky-300/10 px-2 py-1 text-[10px] uppercase tracking-[0.12em] text-sky-100",children:"Active"})]})}),Bg=c.forwardRef(function({threadId:r,shellAdapter:n,isVisible:a=!0,showHeader:s=!0,showFloatingToolbox:o=!0,effectiveTheme:l="dark",loadSplitRatio:i,saveSplitRatio:d,onStateChange:h},u){const m=c.useRef(null),f=c.useRef(null),p=c.useRef(null),g=c.useRef(null),b=c.useRef(null),v=c.useRef(!1),[x,y]=c.useState(null),[k,j]=c.useState(!0),[w,N]=c.useState(!1),[S,L]=c.useState(null),[T,q]=c.useState("primary"),[A,D]=c.useState(null),[J,W]=c.useState(null),[O,ee]=c.useState("single"),[he,E]=c.useState(50),[re,_]=c.useState(null),[V,U]=c.useState(""),[z,X]=c.useState(!1),[F,I]=c.useState(!1),[P,Z]=c.useState(!1),[K,de]=c.useState({primary:Ls,secondary:Ls}),[M,Y]=c.useState(null),te=(x==null?void 0:x.state)??"not_created",ie=c.useMemo(()=>(x==null?void 0:x.shells)??[],[x==null?void 0:x.shells]),ue=c.useMemo(()=>ie.filter(mt),[ie]),be=c.useMemo(()=>ue.find(C=>C.id===A)??null,[ue,A]),Le=c.useMemo(()=>ue.find(C=>C.id===J)??null,[ue,J]),ae=T==="secondary"?Le:be,ve=K[T],ke=(x==null?void 0:x.workspacePathStatus)==="missing",pe=T==="secondary"?f:m,ze=kg({activeRuntime:ve,activeShell:ae,busy:w,loading:k,status:te,workspacePathMissing:ke}),je=ze.disabled,Me=ze.label,Pe=ze.className,_e=(M==null?void 0:M.tone)==="done"?"shell-floating-feedback shell-floating-feedback-done":(M==null?void 0:M.tone)==="failed"?"shell-floating-feedback shell-floating-feedback-failed":"shell-floating-feedback",Ce=c.useCallback((C,B)=>{Y({tone:C,text:B}),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{Y(null),p.current=null},1800)},[]),Re=c.useCallback((C,B,se)=>{y(ye=>{var nt;if(!ye)return ye;const Oe=ye.shells.map(Ge=>Ge.id===C?B(Ge):Ge),rt=((nt=ye.shell)==null?void 0:nt.id)===C?B(ye.shell):Oe.find(Ge=>{var Ve;return Ge.id===((Ve=ye.shell)==null?void 0:Ve.id)})??ye.shell;return{...ye,...se?{state:se}:{},shell:rt,shells:Oe}})},[]),H=c.useCallback(async()=>{j(!0);try{const C=await n.fetchState(r);y(C),L(null)}catch(C){L(C instanceof Error?C.message:"Unable to load shell state.")}finally{j(!1)}},[n,r]);c.useEffect(()=>{H()},[H]),c.useEffect(()=>{const C=i==null?void 0:i(r);if(C==null){E(50);return}const B=typeof C=="number"?C:Number.parseFloat(String(C));E(Number.isFinite(B)?kn(B):50)},[i,r]),c.useEffect(()=>{if(!x){D(null),W(null);return}const C=vg(x);D(B=>B&&x.shells.some(se=>se.id===B&&mt(se))?B:(C==null?void 0:C.id)??null),W(B=>{if(O!=="columns")return null;if(B&&x.shells.some(ye=>ye.id===B&&mt(ye)))return B;const se=x.shells.find(ye=>mt(ye)&&ye.id!==(C==null?void 0:C.id));return(se==null?void 0:se.id)??null})},[x,O]),c.useEffect(()=>{O!=="columns"&&(q("primary"),W(null))},[O]),c.useEffect(()=>{if(O!=="columns"||J||ue.length<2)return;const C=ue.find(B=>B.id!==(be==null?void 0:be.id))??null;C&&W(C.id)},[ue,be==null?void 0:be.id,J,O]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const C=window.matchMedia("(max-width: 767px), (hover: none) and (pointer: coarse)"),B=()=>{X(C.matches),C.matches||(Z(!1),I(!1))};return B(),C.addEventListener("change",B),()=>{C.removeEventListener("change",B)}},[]),c.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current),b.current!==null&&window.cancelAnimationFrame(b.current)},[]);const ce=c.useCallback((C,B)=>{de(se=>{const ye=se[C];return bg(ye,B)?se:{...se,[C]:B}})},[]),R=c.useCallback(C=>ce("primary",C),[ce]),$=c.useCallback(C=>ce("secondary",C),[ce]),Q=c.useCallback(C=>{var se;if((se=C.label)!=null&&se.trim())return C.label.trim();const B=ie.findIndex(ye=>ye.id===C.id);return`Shell ${B>=0?B+1:""}`.trim()},[ie]),me=c.useCallback(C=>{var B;_(C.id),U(((B=C.label)==null?void 0:B.trim())||Q(C))},[Q]),xe=c.useCallback(()=>{_(null),U("")},[]),Ie=c.useCallback(async()=>{if(re){N(!0);try{const C=V.trim(),B=await n.updateShell(re,{label:C.length>0?C:null});y(se=>{var ye;return se&&{...se,state:se.activeShellId===B.id?B.status:se.state,shell:((ye=se.shell)==null?void 0:ye.id)===B.id?B:se.shell,shells:se.shells.map(Oe=>Oe.id===B.id?B:Oe)}}),_(null),U(""),L(null)}catch(C){L(C instanceof Error?C.message:"Unable to rename shell.")}finally{N(!1)}}},[V,re,n]),ge=c.useCallback((C,B)=>{if(C==="primary"){D(B),W(se=>se===B?null:se);return}W(B),D(se=>se===B?null:se)},[]),Ae=c.useCallback(C=>{var B,se;if(C==="primary"){(B=m.current)==null||B.disconnect(),D(null),O==="columns"&&q("secondary");return}(se=f.current)==null||se.disconnect(),W(null),q("primary"),ee("single")},[O]),at=c.useCallback((C,B=T)=>{const se=O==="columns"?B:"primary";ge(se,C.id),O!=="columns"&&W(null),q(se)},[T,ge,O]),Je=c.useCallback(async(C=T)=>{var B;if(!v.current){v.current=!0,N(!0);try{const se=await n.createShell(r);y(se);const ye=se.activeShellId??((B=se.shell)==null?void 0:B.id)??null;if(ye){const Oe=O==="columns"?C:"primary";ge(Oe,ye),O!=="columns"&&W(null),q(Oe)}L(null)}catch(se){L(se instanceof Error?se.message:"Unable to create shell.")}finally{v.current=!1,N(!1)}}},[T,ge,n,O,r]);c.useEffect(()=>{!a||!x||k||w||ke||te==="creating"||ue.length>0||Je("primary")},[w,Je,a,ue.length,k,x,te,ke]);const Qe=c.useCallback(async(C=(ae==null?void 0:ae.id)??"")=>{if(C){N(!0);try{await n.terminateShell(C),D(B=>B===C?null:B),W(B=>B===C?null:B),await H(),L(null)}catch(B){L(B instanceof Error?B.message:"Unable to terminate shell.")}finally{N(!1)}}},[ae==null?void 0:ae.id,H,n]),De=c.useCallback(async()=>{var C,B;if(!je){if(ve.shellInputEnabled){(C=pe.current)==null||C.disconnect();return}if(!ae||ae.status==="exited"||ae.status==="not_found"){await Je(T);return}await((B=pe.current)==null?void 0:B.reconnect())}},[T,pe,ve.shellInputEnabled,ae,je,Je]),Be=c.useCallback(C=>{typeof window>"u"||d==null||d(r,kn(C))},[d,r]),lt=c.useCallback(()=>{var C,B;(C=m.current)==null||C.refreshLayout({syncBackendSize:!0}),(B=f.current)==null||B.refreshLayout({syncBackendSize:!0})},[]),He=c.useCallback(C=>{var rt,nt;if(O!=="columns")return;const B=g.current;if(!B)return;C.preventDefault(),(nt=(rt=C.currentTarget).setPointerCapture)==null||nt.call(rt,C.pointerId);const se=Ge=>{const Ve=B.getBoundingClientRect();if(Ve.width<=0)return;const ht=kn((Ge-Ve.left)/Ve.width*100);E(ht),b.current!==null&&window.cancelAnimationFrame(b.current),b.current=window.requestAnimationFrame(()=>{b.current=null,lt()})},ye=Ge=>{se(Ge.clientX)},Oe=Ge=>{se(Ge.clientX);const Ve=B.getBoundingClientRect();Ve.width>0&&Be((Ge.clientX-Ve.left)/Ve.width*100),window.removeEventListener("pointermove",ye),window.removeEventListener("pointerup",Oe)};window.addEventListener("pointermove",ye),window.addEventListener("pointerup",Oe,{once:!0})},[Be,lt,O]),tt=c.useCallback((C,B)=>{ge(B,C.id),q(B)},[ge]),it=c.useCallback(async()=>{var B;return await((B=pe.current)==null?void 0:B.copyLastCommandOutput())?!0:(Ce("failed","Nothing to copy"),!1)},[pe,Ce]);c.useEffect(()=>{h==null||h(wg({activeRuntime:ve,activeShell:ae,connectionButtonDisabled:je,connectionButtonLabel:Me,isMobileShell:z,busy:w,loading:k,error:S}))},[ve,ae,w,je,Me,S,z,k,h]),c.useImperativeHandle(u,()=>({async toggleConnection(){await De()},sendInput(C){var B;return((B=pe.current)==null?void 0:B.sendInput(C))??!1},sendCommand(C){var B;return((B=pe.current)==null?void 0:B.sendCommand(C))??!1},sendControl(C){var B;return((B=pe.current)==null?void 0:B.sendControl(C))??!1},async copyLastCommandOutput(){var C;return await((C=pe.current)==null?void 0:C.copyLastCommandOutput())??!1},async terminate(){await Qe()},focus(){var C;(C=pe.current)==null||C.focus()},refreshLayout(C){var B,se;(B=m.current)==null||B.refreshLayout(C),O==="columns"&&((se=f.current)==null||se.refreshLayout(C))}}),[pe,De,Qe,O]);const Ye=C=>t.jsx("div",{className:`rounded-md border px-2 py-1.5 text-xs ${C.id===(ae==null?void 0:ae.id)?"border-sky-300/40 bg-sky-300/12 text-sky-50":"border-stone-800 bg-stone-900/40 text-stone-300"}`,children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[re===C.id?t.jsx("form",{className:"min-w-0 flex-1",onSubmit:B=>{B.preventDefault(),Ie()},children:t.jsx("input",{value:V,onChange:B=>U(B.currentTarget.value),onKeyDown:B=>{B.key==="Escape"&&(B.preventDefault(),xe())},autoFocus:!0,className:"w-full rounded border border-sky-300/35 bg-stone-950/70 px-2 py-1 text-xs text-stone-100 outline-none","aria-label":"Shell name"})}):t.jsxs("button",{type:"button",onClick:()=>at(C),onDoubleClick:()=>me(C),className:"min-w-0 flex-1 text-left",title:C.tmuxSessionName,children:[t.jsx("span",{className:"block truncate",children:Q(C)}),t.jsxs("span",{className:"block truncate text-[10px] text-[var(--theme-fg-muted)]",children:[vn(C.status)," · ",Xr(C.cwd)||C.cwd]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[re===C.id?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>void Ie(),className:"rounded border border-sky-300/35 bg-sky-300/12 px-1.5 py-1 text-[10px] text-sky-50",title:"Save shell name",children:"Save"}),t.jsx("button",{type:"button",onClick:xe,className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200",title:"Cancel rename",children:"Cancel"})]}):t.jsx("button",{type:"button",onClick:()=>me(C),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Rename shell",children:"Rename"}),O==="columns"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>tt(C,"primary"),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Open in left pane",children:"L"}),t.jsx("button",{type:"button",onClick:()=>tt(C,"secondary"),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Open in right pane",children:"R"})]}),t.jsx("button",{type:"button",disabled:w,onClick:()=>void Qe(C.id),className:"rounded border border-rose-300/35 bg-rose-300/12 px-1.5 py-1 text-[10px] text-rose-100 disabled:cursor-not-allowed disabled:opacity-50",title:"Kill shell process",children:"Kill"})]})]})},C.id);return t.jsxs("div",{className:"shell-panel flex min-h-0 flex-1 flex-col",children:[s&&t.jsxs("div",{className:"shell-header shrink-0 border-b px-3 py-3 sm:px-5",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs uppercase tracking-[0.24em] text-[var(--theme-fg-muted)]",children:"Shell"}),t.jsx("p",{className:"mt-1 truncate text-sm text-[var(--theme-fg-soft)]",children:ve.promptLabel??(ae==null?void 0:ae.cwd)??"Create a terminal for this thread."})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("button",{type:"button","aria-label":Me,title:`${Me} (${vn(ve.status)})`,disabled:je,onClick:()=>void De(),className:`inline-flex h-10 w-10 items-center justify-center rounded-full border shadow-lg shadow-stone-950/25 transition disabled:cursor-not-allowed disabled:opacity-60 ${Pe}`,children:t.jsx(Xf,{connected:ve.shellInputEnabled})}),ae&&t.jsx("button",{type:"button",disabled:w,onClick:()=>void Qe(ae.id),className:"rounded-full border border-rose-300/35 bg-rose-300/12 px-3 py-2 text-sm text-rose-600 transition hover:bg-rose-300/18 dark:text-rose-100 disabled:cursor-not-allowed disabled:opacity-60",children:"Terminate"})]})]}),(S||k||ke)&&t.jsxs("div",{className:"shell-banner mt-3 rounded-2xl border px-3 py-3 text-sm",children:[k&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!k&&ke&&t.jsx("p",{className:"text-rose-600 dark:text-rose-100",children:"Workspace path is missing on this machine. Restore the path before creating a shell."}),!k&&S&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:S})]})]}),t.jsx("div",{className:"min-h-0 flex-1",children:t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("div",{className:"shell-terminal-bar flex shrink-0 items-center gap-2 border-b px-2 py-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-1",children:[t.jsx("span",{className:"min-w-0 truncate text-xs text-[var(--theme-fg-soft)]",children:ae?Q(ae):"No live shell process"}),ae&&t.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.12em] text-[var(--theme-fg-muted)]",children:vn(ve.status)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.jsxs("span",{className:"hidden text-xs text-[var(--theme-fg-muted)] sm:inline",children:["Live ",ue.length]}),t.jsx("button",{type:"button","aria-expanded":F,"aria-label":F?"Hide shell processes":"Show shell processes",onClick:()=>I(C=>!C),className:"rounded-md border border-stone-700/80 bg-stone-900/50 px-2.5 py-1.5 text-xs text-stone-200 sm:hidden",children:"Processes"})]})]}),F&&t.jsxs("div",{className:"shrink-0 border-b border-stone-800/80 bg-stone-950/55 p-2 sm:hidden",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsx("p",{className:"text-xs uppercase tracking-[0.16em] text-[var(--theme-fg-muted)]",children:"Processes"}),t.jsxs("span",{className:"text-[10px] text-[var(--theme-fg-muted)]",children:[ue.length," live"]})]}),t.jsxs("div",{className:"max-h-52 space-y-1 overflow-y-auto",children:[ue.map(Ye),ue.length===0&&t.jsx("p",{className:"px-2 py-3 text-xs text-[var(--theme-fg-muted)]",children:"No live shell processes"})]}),t.jsx("div",{className:"mt-2 flex justify-end border-t border-stone-800/80 pt-2",children:t.jsx("button",{type:"button","aria-label":"New shell",title:"New shell",disabled:w||k||ke,onClick:()=>void Je(T),className:"inline-flex h-8 w-8 items-center justify-center rounded-md border border-sky-300/35 bg-sky-300/12 text-base leading-none text-sky-50 disabled:cursor-not-allowed disabled:opacity-50",children:"+"})})]}),te==="not_created"||ke?t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"shell-empty-state max-w-md rounded-[1.6rem] border px-6 py-8",children:[t.jsx("p",{className:"text-base font-medium text-[var(--theme-fg)]",children:"Durable thread shell"}),t.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--theme-fg-muted)]",children:"The shell runs under a supervisor-managed PTY and reconnects after browser disconnects. Create it explicitly when you want to inspect or take over the workspace."}),!ke&&t.jsx("button",{type:"button",disabled:w||k,onClick:()=>void Je("primary"),className:"mt-5 rounded-md border border-sky-300/35 bg-sky-300/12 px-3 py-2 text-sm text-sky-50 disabled:cursor-not-allowed disabled:opacity-50",children:"New Shell"})]})}):t.jsxs("div",{className:"grid h-full min-h-0 grid-cols-1 gap-2 p-2 sm:grid-cols-[minmax(0,1fr)_16rem] sm:p-3",children:[t.jsxs("div",{className:"shell-terminal-frame relative min-h-0 overflow-hidden rounded-[1.4rem] border shadow-inner",children:[!s&&(S||k||ke)&&t.jsxs("div",{className:"shell-banner absolute left-2 right-2 top-2 z-10 rounded-2xl border px-3 py-3 text-sm backdrop-blur sm:left-3 sm:right-3 sm:top-3",children:[k&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!k&&ke&&t.jsx("p",{className:"text-rose-600 dark:text-rose-100",children:"Workspace path is missing on this machine. Restore the path before creating a shell."}),!k&&S&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:S})]}),t.jsxs("div",{ref:g,className:`relative grid h-full min-h-0 ${O==="columns"?"grid-cols-1 sm:grid-cols-[var(--shell-left)_0.35rem_var(--shell-right)]":"grid-cols-1"}`,style:O==="columns"?{"--shell-left":`${he}fr`,"--shell-right":`${100-he}fr`}:void 0,"data-shell-split-ratio":he,children:[t.jsx(Ps,{ref:m,paneId:"primary",shell:be,isActive:T==="primary",isVisible:a,isMobileShell:z,effectiveTheme:l,workspacePathMissing:ke,shellAdapter:n,onActivate:()=>q("primary"),onShellUpdate:Re,onRuntimeStateChange:R,onFeedback:Ce}),O==="columns"&&t.jsx("button",{type:"button",onClick:()=>Ae("primary"),className:"absolute left-2 top-2 z-10 rounded-md border border-stone-700/80 bg-stone-950/70 px-2 py-1 text-[10px] text-stone-200 hover:border-rose-300/40",title:"Close left pane",children:"Close"}),O==="columns"&&t.jsx("button",{type:"button","aria-label":"Resize shell panes",title:"Resize shell panes",onPointerDown:He,className:"hidden cursor-col-resize border-x border-stone-800/80 bg-stone-900/60 transition hover:border-sky-300/40 hover:bg-sky-300/10 sm:block"}),O==="columns"&&t.jsxs("div",{className:"relative min-h-0 border-t border-stone-800/80 sm:border-l sm:border-t-0",children:[t.jsx(Ps,{ref:f,paneId:"secondary",shell:Le,isActive:T==="secondary",isVisible:a,isMobileShell:z,effectiveTheme:l,workspacePathMissing:ke,shellAdapter:n,onActivate:()=>q("secondary"),onShellUpdate:Re,onRuntimeStateChange:$,onFeedback:Ce}),t.jsx("button",{type:"button",onClick:()=>Ae("secondary"),className:"absolute left-2 top-2 z-10 rounded-md border border-stone-700/80 bg-stone-950/70 px-2 py-1 text-[10px] text-stone-200 hover:border-rose-300/40",title:"Close right pane",children:"Close"})]})]}),o&&z&&t.jsxs("div",{className:"pointer-events-none absolute bottom-3 right-3 z-20 flex flex-col items-end gap-2",children:[M&&t.jsx("div",{className:`pointer-events-auto rounded-full border px-3 py-1.5 text-[11px] shadow-lg shadow-stone-950/30 backdrop-blur ${_e}`,children:M.text}),P&&t.jsx("div",{className:"shell-toolbox pointer-events-auto rounded-[1.2rem] border p-2 shadow-2xl backdrop-blur",children:t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx("button",{type:"button",onClick:()=>{Ce("idle","Use the prompt box tools to paste")},className:"inline-flex items-center justify-center rounded-full border border-sky-300/35 bg-sky-300/12 px-2.5 py-2 text-sky-600 dark:text-sky-50",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Ts,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:()=>void it(),className:"shell-toolbox-copy inline-flex items-center justify-center rounded-full border px-2.5 py-2",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Ts,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:!ve.shellInputEnabled,onClick:()=>{var C;(C=pe.current)!=null&&C.sendControl("clear")?Ce("done","Cleared"):Ce("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(wn,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!ve.shellInputEnabled||!ve.isCommandRunning,onClick:()=>{var C;(C=pe.current)!=null&&C.sendInput("")?Ce("done","Sent Ctrl-C"):Ce("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(wn,{label:"CTRL-C",tone:"rose"})}),["ctrl_d","esc","tab","up","down"].map(C=>t.jsx("button",{type:"button",disabled:!ve.shellInputEnabled,onClick:()=>{var B;(B=pe.current)!=null&&B.sendControl(C)?Ce("done",`Sent ${C.toUpperCase().replace("_","-")}`):Ce("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(wn,{label:C.toUpperCase().replace("_","-"),tone:"stone"})},C))]})}),t.jsx("button",{type:"button","aria-expanded":P,"aria-label":P?"Close shell tools":"Open shell tools",onClick:()=>Z(C=>!C),className:"shell-toolbox-trigger pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-2xl backdrop-blur transition",children:t.jsx(qf,{})})]})]}),t.jsxs("aside",{className:"hidden min-h-0 overflow-hidden rounded-[1rem] border border-stone-800/80 bg-stone-950/30 p-2 sm:flex sm:flex-col",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsx("p",{className:"text-xs uppercase tracking-[0.16em] text-[var(--theme-fg-muted)]",children:"Processes"}),t.jsxs("span",{className:"text-[10px] text-[var(--theme-fg-muted)]",children:[ue.length," live"]})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-1 overflow-y-auto",children:[ue.map(Ye),ue.length===0&&t.jsx("p",{className:"px-2 py-3 text-xs text-[var(--theme-fg-muted)]",children:"No live shell processes"})]}),t.jsx("div",{className:"mt-2 flex justify-end border-t border-stone-800/80 pt-2",children:t.jsx("button",{type:"button","aria-label":"New shell",title:"New shell",disabled:w||k||ke,onClick:()=>void Je(T),className:"inline-flex h-8 w-8 items-center justify-center rounded-md border border-sky-300/35 bg-sky-300/12 text-base leading-none text-sky-50 disabled:cursor-not-allowed disabled:opacity-50",children:"+"})})]})]})]})})]})}),Gg=c.lazy(async()=>({default:(await Promise.resolve().then(()=>(eu(),Ko))).ThreadGraphWorkspacePanel}));function Fg(){return t.jsx("div",{className:"flex h-full min-h-0 flex-1 items-center justify-center px-4 text-sm text-[var(--theme-fg-muted)]",children:"Loading workspace..."})}function vl(e){return t.jsx(c.Suspense,{fallback:t.jsx(Fg,{}),children:t.jsx(Gg,{...e})})}c.memo(vl);function tx({open:e,title:r,description:n,confirmLabel:a="Delete",busy:s=!1,onCancel:o,onConfirm:l}){return c.useEffect(()=>{if(!e)return;function i(d){d.key==="Escape"&&!s&&o()}return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[s,o,e]),e?Dr.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[95] flex items-center justify-center p-4 sm:p-6",children:[t.jsx("button",{type:"button","aria-label":"Close confirmation dialog",onClick:o,disabled:s,className:"absolute inset-0 bg-stone-950/78 backdrop-blur-sm disabled:cursor-not-allowed"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":r,className:"relative z-[1] w-full max-w-md rounded-[1.6rem] border border-stone-700 bg-stone-900 p-5 shadow-2xl shadow-stone-950/40 sm:p-6",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium text-stone-100",children:r}),t.jsx("p",{className:"mt-2 text-sm leading-6 text-stone-400",children:n})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:o,disabled:s,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-stone-700 text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsxs("div",{className:"mt-5 flex items-center justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:o,disabled:s,className:"rounded-full border border-stone-700 px-4 py-2 text-sm font-medium text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),t.jsx("button",{type:"button",onClick:()=>void l(),disabled:s,className:"ui-action-danger rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:s?"Deleting...":a})]})]})]}),document.body):null}function Hg(e){if(!e)return"No time";const r=new Date(e);return Number.isNaN(r.getTime())?e:r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Og(e){switch(e){case"inProgress":return"running";case"completed":return"completed";case"interrupted":return"interrupted";case"failed":return"failed"}}function rx({open:e,busy:r=!1,turnsState:n,onCancel:a,onLoadTurns:s,onExport:o}){var N,S,L;const l=c.useMemo(()=>{var T;return((T=n.data)==null?void 0:T.turns)??[]},[(N=n.data)==null?void 0:N.turns]),i=c.useMemo(()=>l.slice(0,10).map(T=>T.turnId),[l]),[d,h]=c.useState("latest"),[u,m]=c.useState(()=>new Set),[f,p]=c.useState(!0),[g,b]=c.useState("pdf"),[v,x]=c.useState(()=>typeof document<"u"&&!document.documentElement.classList.contains("dark")?"light":"dark");if(c.useEffect(()=>{e&&(h("latest"),b("pdf"),p(!0),s())},[s,e]),c.useEffect(()=>{e&&l.length>0&&m(new Set(i))},[i,e,l.length]),c.useEffect(()=>{if(!e)return;function T(q){q.key==="Escape"&&!r&&a()}return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[r,a,e]),c.useEffect(()=>{if(!e)return;const T=document.querySelector(".thread-ui-shell"),q=()=>T?T.getAttribute("data-theme-effective")==="dark"||T.classList.contains("dark")||T.classList.contains("thread-ui-theme-dark")?"dark":"light":document.documentElement.classList.contains("dark")?"dark":"light";if(x(q()),!T)return;const A=new MutationObserver(()=>x(q()));return A.observe(T,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>A.disconnect()},[e]),!e)return null;const y=d==="latest"?Math.min(10,((S=n.data)==null?void 0:S.totalTurnCount)??10):u.size,k=!r&&(d==="latest"||u.size>0);function j(T){m(q=>{const A=new Set(q);return A.has(T)?A.delete(T):A.add(T),A})}function w(){const T={format:g,mode:d,...d==="latest"?{limit:10}:{turnIds:[...u]},profile:"review",options:{includeTokenAndPrice:f}};o(T)}return Dr.createPortal(t.jsxs("div",{className:`thread-export-dialog-root thread-ui-theme-${v} fixed inset-0 z-[96] flex items-center justify-center p-3 sm:p-6`,"data-theme-effective":v,children:[t.jsx("button",{type:"button","aria-label":"Close export dialog",onClick:a,disabled:r,className:"thread-export-dialog-backdrop absolute inset-0 backdrop-blur-sm disabled:cursor-not-allowed"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Export transcript",className:"thread-export-dialog-panel relative z-[1] flex max-h-[min(46rem,calc(100vh-2rem))] w-full max-w-2xl flex-col rounded-[1.6rem] border shadow-2xl",children:[t.jsxs("div",{className:"thread-export-dialog-header flex items-start justify-between gap-3 border-b px-5 py-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-export-dialog-title text-sm font-semibold",children:"Export transcript"}),t.jsx("p",{className:"thread-export-dialog-subtitle mt-1 text-xs",children:"Default review copy summarizes command batches and file changes."})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:a,disabled:r,className:"thread-export-dialog-icon-button inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border transition disabled:cursor-not-allowed disabled:opacity-60",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-auto px-5 py-4",children:[t.jsx("div",{className:"thread-export-dialog-segment inline-flex rounded-full border p-1",children:[["latest","Latest 10"],["selected","Custom selection"]].map(([T,q])=>t.jsx("button",{type:"button",onClick:()=>h(T),className:`rounded-full px-3 py-1.5 text-sm transition ${d===T?"ui-status-warning":"thread-export-dialog-muted-action"}`,children:q},T))}),t.jsx("div",{className:"thread-export-dialog-segment mt-4 inline-flex rounded-full border p-1",children:[["pdf","PDF"],["html","HTML"]].map(([T,q])=>t.jsx("button",{type:"button",onClick:()=>b(T),className:`rounded-full px-3 py-1.5 text-sm transition ${g===T?"ui-status-warning":"thread-export-dialog-muted-action"}`,children:q},T))}),d==="selected"?t.jsxs("div",{className:"thread-export-dialog-box mt-4 rounded-2xl border",children:[t.jsxs("div",{className:"thread-export-dialog-box-header flex flex-wrap items-center justify-between gap-2 border-b px-3 py-2.5",children:[t.jsxs("p",{className:"thread-export-dialog-subtitle text-xs",children:["Selected ",u.size," of ",((L=n.data)==null?void 0:L.totalTurnCount)??l.length]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>m(new Set(l.map(T=>T.turnId))),className:"thread-export-dialog-secondary-button rounded-full border px-2.5 py-1 text-xs transition",children:"Select all"}),t.jsx("button",{type:"button",onClick:()=>m(new Set),className:"thread-export-dialog-secondary-button rounded-full border px-2.5 py-1 text-xs transition",children:"Clear"})]})]}),n.status==="loading"?t.jsx("p",{className:"thread-export-dialog-subtitle px-3 py-6 text-sm",children:"Loading turns..."}):n.status==="failed"?t.jsx("p",{className:"px-3 py-6 text-sm text-rose-500 dark:text-rose-200",children:n.error}):t.jsx("div",{className:"max-h-80 overflow-auto p-2",children:l.map(T=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex cursor-pointer items-center gap-3 rounded-xl px-2.5 py-2 text-sm transition",children:[t.jsx("input",{type:"checkbox",checked:u.has(T.turnId),onChange:()=>j(T.turnId),className:"thread-export-dialog-checkbox h-4 w-4"}),t.jsxs("span",{className:"thread-export-dialog-strong shrink-0 text-xs font-medium",children:["Turn ",T.turnNumber]}),t.jsx("span",{className:"thread-export-dialog-subtitle shrink-0 text-xs",children:Hg(T.startedAt)}),t.jsx("span",{className:"thread-export-dialog-body-text min-w-0 flex-1 truncate text-left",children:T.userPromptPreview}),t.jsx("span",{className:"thread-export-dialog-status-pill hidden shrink-0 rounded-full border px-2 py-0.5 text-[10px] sm:inline",children:Og(T.status)})]},T.turnId))})]}):t.jsx("p",{className:"thread-export-dialog-box thread-export-dialog-body-text mt-4 rounded-2xl border px-3 py-3 text-sm",children:"Exports the latest 10 turns in chronological order."}),t.jsxs("div",{className:"thread-export-dialog-body-text mt-4 grid gap-2 text-sm sm:grid-cols-2",children:[t.jsxs("label",{className:"thread-export-dialog-box flex items-center gap-2 rounded-xl border px-3 py-2",children:[t.jsx("input",{type:"checkbox",checked:f,onChange:T=>p(T.target.checked),className:"thread-export-dialog-checkbox h-4 w-4"}),"Token and price"]}),t.jsx("p",{className:"thread-export-dialog-box thread-export-dialog-subtitle flex items-center rounded-xl border px-3 py-2 text-xs",children:g==="html"?"HTML keeps the chat timeline styling and omits raw command output.":"Review exports keep message text readable and omit tool activity."})]})]}),t.jsxs("div",{className:"thread-export-dialog-footer flex items-center justify-between gap-3 border-t px-5 py-4",children:[t.jsxs("p",{className:"thread-export-dialog-subtitle min-w-0 text-xs",children:[y," ",y===1?"turn":"turns"," will be exported."]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:a,disabled:r,className:"thread-export-dialog-secondary-button rounded-full border px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),t.jsx("button",{type:"button",onClick:w,disabled:!k,className:"ui-status-warning rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:r?"Exporting...":`Export ${g.toUpperCase()}`})]})]})]})]}),document.body)}function jn(e){if(e===void 0)return"-";if(Math.abs(e)>1e4){const r=Math.abs(e)>=1e5?0:1;return`${(e/1e3).toLocaleString(void 0,{maximumFractionDigits:r})}k`}return e.toLocaleString()}function Ug(e){return`in ${jn(e.input)} / out ${jn(e.output)} / cache ${jn(e.cache)}`}function Wg({detail:e,adapter:r,timelineAdapter:n,TimelineComponent:a=fl,liveOutput:s="",beforeTimelineContent:o,composerProps:l,timelineProps:i,threadUsageSummary:d,transcriptItemCount:h,useFloatingMobileComposer:u=!1,floatingMobileComposerBottomOffset:m=0,composerHostRef:f}){const[p,g]=c.useState(!1),[b,v]=c.useState(0),[x,y]=c.useState(0),[k,j]=c.useState(0),[w,N]=c.useState(!1),S=c.useRef(null),L=i==null?void 0:i.onTailVisibilityChange,T=e.pendingRequests.length>0,q=c.useCallback(E=>{L==null||L(E)},[L]);c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const E=window.matchMedia("(max-width: 639px)"),re=()=>g(E.matches);return re(),E.addEventListener("change",re),()=>{E.removeEventListener("change",re)}},[]),c.useEffect(()=>{var re,_;if(typeof window>"u")return;const E=()=>{const V=window.visualViewport,U=V?Math.max(0,Math.round(window.innerHeight-V.height-V.offsetTop)):0,z=V?Math.max(0,Math.round(window.innerHeight-V.height)):U,X=Math.min(U,z),F=Math.max(0,Math.round(window.innerHeight*.52));j(Math.min(X,F))};return E(),(re=window.visualViewport)==null||re.addEventListener("resize",E),(_=window.visualViewport)==null||_.addEventListener("scroll",E),window.addEventListener("resize",E),()=>{var V,U;(V=window.visualViewport)==null||V.removeEventListener("resize",E),(U=window.visualViewport)==null||U.removeEventListener("scroll",E),window.removeEventListener("resize",E)}},[]),c.useLayoutEffect(()=>{const E=S.current;if(!E||!p){v(0);return}const re=()=>{v(Math.ceil(E.getBoundingClientRect().height))};if(re(),typeof ResizeObserver>"u")return;const _=new ResizeObserver(re);return _.observe(E),()=>{_.disconnect()}},[p,l,T]),c.useLayoutEffect(()=>{var V,U;const E=S.current;if(!E||!p){y(0);return}const re=()=>{const z=E.getBoundingClientRect();y(Math.max(0,Math.ceil(window.innerHeight-z.top)))};re(),window.addEventListener("resize",re),(V=window.visualViewport)==null||V.addEventListener("resize",re),(U=window.visualViewport)==null||U.addEventListener("scroll",re);let _=null;return typeof ResizeObserver<"u"&&(_=new ResizeObserver(re),_.observe(E)),()=>{var z,X;window.removeEventListener("resize",re),(z=window.visualViewport)==null||z.removeEventListener("resize",re),(X=window.visualViewport)==null||X.removeEventListener("scroll",re),_==null||_.disconnect()}},[p,k,w,l,T]),c.useEffect(()=>{if(!p){N(!1);return}const E=_=>{var U;const V=_.target;V instanceof HTMLElement&&((U=S.current)!=null&&U.contains(V))&&N(!0)},re=_=>{var U;const V=_.relatedTarget;V instanceof HTMLElement&&((U=S.current)!=null&&U.contains(V))||N(!1)};return document.addEventListener("focusin",E),document.addEventListener("focusout",re),()=>{document.removeEventListener("focusin",E),document.removeEventListener("focusout",re)}},[p]);const A=c.useCallback(E=>{S.current=E,f&&(f.current=E)},[f]),D=p&&w?Math.max(0,k-m):0,J=Math.max(b,144),W=Math.max(x,J+D),O=p?W+12:0,ee=O>0?{"--thread-graph-chat-scroll-bottom-spacer":`${O}px`}:void 0,he=u&&p?{bottom:`${m+D}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"}:void 0;return t.jsxs("div",{"data-testid":"chat-panel",className:"thread-graph-chat-panel relative flex h-full min-h-0 flex-col",style:ee,children:[o,t.jsx(a,{threadId:e.thread.id,turns:e.turns,totalTurnCount:e.totalTurnCount??e.turns.length,pendingRequests:e.pendingRequests,activeTurnId:e.thread.activeTurnId,threadRunning:e.thread.status==="running"||e.thread.activeTurnId!==null,liveOutput:s,className:"thread-timeline-surface min-h-0 flex-1",...i,adapter:n,onOpenThread:(i==null?void 0:i.onOpenThread)??r.openThread,onTailVisibilityChange:q}),t.jsxs("div",{className:"thread-chat-usage-footer hidden shrink-0 items-center justify-between gap-3 px-4 py-1 text-[10px] leading-4 sm:flex",children:[t.jsxs("span",{className:"min-w-0 truncate",children:[e.turns.length," turn",e.turns.length!==1?"s":"",t.jsx("span",{className:"mx-1 text-[var(--theme-border-contrast)]",children:"|"}),h," item",h!==1?"s":""]}),t.jsxs("span",{className:"shrink-0",children:["Usage"," ",d&&d.turns>0?Ug(d):"waiting for agent usage"]})]}),l?u?t.jsx("div",{ref:A,className:"fixed inset-x-0 bottom-0 z-50 overflow-visible sm:hidden",style:he??{bottom:`${m}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"},children:t.jsx(Dn,{...l,activeView:"chat",edgeToEdgeMobile:!0,onSubmit:r.sendPrompt})}):t.jsx("div",{ref:A,className:"thread-graph-composer-host shrink-0",children:t.jsx(Dn,{...l,activeView:"chat",onSubmit:r.sendPrompt})}):null]})}function Vg(e){return e.turns.reduce((r,n)=>{var s;const a=(s=n.tokenUsage)==null?void 0:s.total;return a?{input:r.input+a.inputTokens,output:r.output+a.outputTokens,cache:r.cache+a.cachedInputTokens,turns:r.turns+1}:r},{input:0,output:0,cache:0,turns:0})}function Nn(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?"0":e>=1e6?`${(e/1e6).toFixed(e>=1e7?0:1)}m`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(Math.round(e))}function Kg(e){return!e||e.turns<=0?"waiting for agent usage":`in ${Nn(e.input)} / out ${Nn(e.output)} / cache ${Nn(e.cache)}`}function nx({threads:e,detail:r,loading:n,error:a,status:s=null,plugins:o,adapter:l,metaContent:i,settingsContent:d,globalSettingsContent:h,settingsDialogOpen:u,onSettingsDialogOpenChange:m,mobileHeaderAction:f,appMenuButton:p,appNavigationMenu:g,workspaceReturnHref:b,onWorkspaceReturn:v,surfaceActions:x,floatingPanel:y,workspaceContent:k,workspaceTitle:j,workspaceActions:w,workspaceFeatures:N,workspaceFocusPathRequest:S=null,onNewThreadTitle:L,beforeTimelineContent:T,errorContent:q,workspaceMissingContent:A,dialogs:D,currentThreadId:J,currentWorkspaceId:W,currentWorkspaceLabel:O,onCloseAppNavigation:ee,className:he="thread-detail-surface relative flex h-full min-h-0 flex-1 flex-col overflow-hidden",activeView:E="chat",liveOutput:re="",timelineProps:_,composerProps:V,shellComposerProps:U,useFloatingMobileComposer:z=!1,floatingMobileComposerBottomOffset:X=0,composerHostRef:F,shellPanelRef:I,shellEffectiveTheme:P="dark",shellThemeMode:Z=P,onShellThemeModeChange:K,onShellStateChange:de,shellUnavailableContent:M,shellDisconnectedContent:Y,timelineComponent:te=fl,shellPanelComponent:ie=Bg,shellContent:ue,loadingContent:be,emptyContent:Le}){const ae=na(),ve=o??ae??ta(),{getImageAssetUrl:ke,loadHistoryItemDetail:pe,openWorkspaceFile:ze,openThread:je,cancelPendingSteer:Me}=l,Pe=c.useMemo(()=>({...ke?{getImageAssetUrl:Q=>ke(Q.path)}:{},onOpenLinkedThread:je,...ze?{onOpenWorkspaceFile:ze}:{},...pe?{onLoadHistoryItemDetail:pe}:{},...Me?{cancelPendingSteer:Me}:{}}),[Me,ke,pe,ze,je]),_e=ve.getThreadPanels().some(Q=>Q.kind==="terminal"),Ce=c.useMemo(()=>r?Vg(r):null,[r]),Re=c.useMemo(()=>Kg(Ce),[Ce]),H=c.useMemo(()=>{var Q;return r?r.turns.reduce((me,xe)=>me+xe.items.length,((Q=r.liveItems)==null?void 0:Q.items.length)??0):0},[r]),ce=k??(r?t.jsx(vl,{detail:r,status:s,plugins:ve,workspaceAdapter:l.workspace??null,metaContent:i,settingsContent:d,activeView:E,features:N,focusPathRequest:S}):null),R=n?be??t.jsx("div",{className:"flex flex-1 items-center justify-center px-6 py-12 text-center text-[var(--theme-fg-muted)]",children:"Loading thread detail..."}):r?t.jsxs("div",{className:he,children:[y?t.jsx("div",{className:"fixed right-3 top-20 z-50 lg:absolute lg:right-4 lg:top-16",children:y}):null,a&&!n&&(q??t.jsx("div",{className:"shrink-0 border-b border-rose-500/20 bg-rose-500/10 px-5 py-4 text-sm text-rose-100 sm:px-6",children:a})),r.workspacePathStatus==="missing"&&(A??t.jsxs("div",{className:"shrink-0 border-b border-rose-500/20 bg-rose-500/10 px-5 py-4 text-sm text-rose-100 sm:px-6",children:[t.jsx("p",{className:"font-medium text-rose-50",children:"Workspace path missing"}),t.jsx("p",{className:"mt-1 break-words text-rose-100/90",children:r.workspace.absPath})]})),t.jsx("div",{className:E==="chat"?"flex min-h-0 flex-1 flex-col":"hidden",children:t.jsx(Wg,{detail:r,adapter:l,timelineAdapter:Pe,TimelineComponent:te,liveOutput:re,threadUsageSummary:Ce,transcriptItemCount:H,useFloatingMobileComposer:z,floatingMobileComposerBottomOffset:X,...T?{beforeTimelineContent:T}:{},...V?{composerProps:V}:{},..._?{timelineProps:_}:{},...F?{composerHostRef:F}:{}})}),t.jsxs("div",{className:E==="shell"?"flex min-h-0 flex-1 flex-col":"hidden",children:[ue??(r.thread.isLoaded&&_e&&l.shell?t.jsx(ie,{ref:I,threadId:r.thread.id,shellAdapter:l.shell,effectiveTheme:P,isVisible:E==="shell",showHeader:!1,showFloatingToolbox:!1,...de?{onStateChange:de}:{}}):r.thread.isLoaded&&!_e?M??t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center p-4 sm:p-6",children:t.jsxs("div",{className:"thread-empty-surface max-w-md rounded-[1.6rem] border px-6 py-8 text-center",children:[t.jsx("p",{className:"text-base font-medium text-[var(--theme-fg)]",children:"Terminal plugin disabled"}),t.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--theme-fg-muted)]",children:"Enable the Terminal plugin in Settings to use the shell panel."})]})}):Y??t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center p-4 sm:p-6",children:t.jsxs("div",{className:"thread-empty-surface max-w-md rounded-[1.6rem] border px-6 py-8 text-center",children:[t.jsx("p",{className:"text-base font-medium text-[var(--theme-fg)]",children:"Thread disconnected"}),t.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--theme-fg-soft)]",children:"Reconnect this thread before creating or attaching a shell."})]})})),E==="shell"&&U&&!ue?t.jsx(Dn,{...U,activeView:"shell",onSubmit:l.sendPrompt}):null]}),D]}):Le??t.jsx("div",{className:"flex flex-1 items-center justify-center px-6 py-12 text-center text-[var(--theme-fg-muted)]",children:"Select a thread to inspect."}),$=t.jsx(Xm,{threads:e,status:s,loading:n,error:n?null:a,viewportConstrained:!0,currentThreadId:J??(r==null?void 0:r.thread.id),currentThreadLabel:r==null?void 0:r.thread.title,currentWorkspaceId:W??(r==null?void 0:r.thread.workspaceId),currentWorkspaceLabel:O??(r==null?void 0:r.workspace.label),sessionLabel:(r==null?void 0:r.thread.providerSessionId)??(r==null?void 0:r.thread.id),usageLabel:Re,topbarActions:x,metaContent:i,settingsContent:d,globalSettingsContent:h,...u!==void 0?{settingsDialogOpen:u}:{},...m?{onSettingsDialogOpenChange:m}:{},mobileHeaderAction:f,effectiveTheme:P,themeMode:Z,appMenuButton:p,appNavigationMenu:g,workspaceReturnHref:b,...v?{onWorkspaceReturn:v}:{},showMobileAppMenu:!!p,showMobileThreadNavToggle:!0,showMobileNewThreadShortcut:!1,onOpenThread:l.openThread,workspaceContent:ce,workspaceTitle:j??"Workspace",workspaceActions:w,...L?{onNewThreadTitle:L}:{},...ee?{onCloseAppNavigation:ee}:{},...K?{onThemeModeChange:K}:{},...l.getThreadHref?{getThreadHref:l.getThreadHref}:{},...l.getNewThreadHref?{getNewThreadHref:l.getNewThreadHref}:{},...l.renameThread?{onRenameThread:l.renameThread}:{},...l.deleteThread?{onDeleteThread:l.deleteThread}:{},children:R});return o?t.jsx(ra.Provider,{value:ve,children:$}):$}var qg={},Xg=[];function ax({adapter:e=qg,builtinPlugins:r=Xg,children:n}){const[a,s]=c.useState(()=>Bn(r,[])),[o,l]=c.useState(!1),[i,d]=c.useState(null),h=c.useCallback(async()=>{l(!0),d(null);try{const k=e.fetchPlugins?await e.fetchPlugins():[];s(Bn(r,k))}catch(k){d(k instanceof Error?k.message:"Unable to load plugins.")}finally{l(!1)}},[e,r]);c.useEffect(()=>{h()},[h]);const u=c.useCallback(async(k,j)=>{if(e.updatePlugin){const w=await e.updatePlugin(k,{enabled:j});s(N=>N.map(S=>S.id===w.id?w:S));return}s(w=>w.map(N=>N.id===k?{...N,enabled:j}:N))},[e]),m=c.useCallback(async k=>{if(!e.importPlugin)throw new Error("Plugin import is not available.");const j=await e.importPlugin(k);s(w=>[...w.filter(S=>S.id!==j.id),j])},[e]),f=c.useCallback(async k=>{if(!e.deletePlugin)throw new Error("Plugin uninstall is not available.");const j=await e.deletePlugin(k);s(w=>w.filter(N=>N.id!==j.id))},[e]),p=c.useMemo(()=>{const k=new Set(a.filter(j=>j.enabled).map(j=>j.id));return r.filter(j=>k.has(j.manifest.id))},[r,a]),g=c.useCallback(k=>{var w;const j=p.find(N=>N.renderArtifact&&N.manifest.capabilities.artifactTypes.some(S=>S.type===k.artifact.type));return((w=j==null?void 0:j.renderArtifact)==null?void 0:w.call(j,k))??null},[p]),b=c.useCallback(k=>{for(const j of p)for(const w of j.inlineCodeRenderers??[]){if(!w.languages.includes(k.language.trim().toLowerCase()))continue;const N=w.render(k);if(N)return N}return null},[p]),v=c.useCallback(k=>p.some(j=>!!j.renderArtifact&&j.manifest.capabilities.artifactTypes.some(w=>w.type===k.type)),[p]),x=c.useCallback(()=>p.flatMap(k=>k.threadPanels??[]),[p]),y=c.useMemo(()=>({plugins:a,loading:o,error:i,refresh:h,importPluginManifest:m,setPluginEnabled:u,uninstallPlugin:f,renderArtifact:g,renderInlineCode:b,hasRendererForArtifact:v,getThreadPanels:x}),[i,x,v,m,o,a,h,g,b,u,f]);return t.jsx(ra.Provider,{value:y,children:n})}export{Rm as A,tx as C,rx as E,Ym as L,ax as P,nx as T,na as a,Bg as b,fl as c,Xm as d,qm as e,Zt as f,Mm as t,Jo as u};
|
|
3631
|
+
`,$=_e(R);return!$&&T.current===ce&&(T.current=null),$},sendControl(H){return H==="clear"?Pe():_e(Kf(H))},async copyLastCommandOutput(){const H=q.current.trim()||Ts(U);if(!H)return f==null||f("failed","Nothing to copy"),!1;try{return await navigator.clipboard.writeText(H),f==null||f("done","Copied"),!0}catch{return f==null||f("failed","Copy failed"),!1}},focus(){var H;(H=g.current)==null||H.focus()},refreshLayout(H){Re(H)}}),[f,u,Re,Pe,_e,Ie,je,U,X,i]),t.jsxs("div",{className:`relative min-h-0 flex-1 overflow-hidden ${a?"shell-pane-active":""}`,onMouseDown:h,"data-pane-id":r,children:[t.jsx("div",{ref:I,className:`h-full w-full px-2 py-2 sm:px-3 sm:py-3 ${o?"mobile-shell-selectable":""}`,onMouseDown:()=>{var H;h(),(H=g.current)==null||H.focus()}}),a&&t.jsx("div",{className:"pointer-events-none absolute right-2 top-2 rounded-md border border-sky-300/30 bg-sky-300/10 px-2 py-1 text-[10px] uppercase tracking-[0.12em] text-sky-100",children:"Active"})]})}),Bg=c.forwardRef(function({threadId:r,shellAdapter:n,isVisible:a=!0,showHeader:s=!0,showFloatingToolbox:o=!0,effectiveTheme:l="dark",loadSplitRatio:i,saveSplitRatio:d,onStateChange:h},u){const m=c.useRef(null),f=c.useRef(null),p=c.useRef(null),g=c.useRef(null),b=c.useRef(null),v=c.useRef(!1),[x,y]=c.useState(null),[k,N]=c.useState(!0),[w,j]=c.useState(!1),[C,L]=c.useState(null),[T,q]=c.useState("primary"),[M,D]=c.useState(null),[J,W]=c.useState(null),[O,ee]=c.useState("single"),[he,E]=c.useState(50),[re,A]=c.useState(null),[V,U]=c.useState(""),[I,X]=c.useState(!1),[F,z]=c.useState(!1),[P,Z]=c.useState(!1),[K,de]=c.useState({primary:Es,secondary:Es}),[_,Y]=c.useState(null),te=(x==null?void 0:x.state)??"not_created",ie=c.useMemo(()=>(x==null?void 0:x.shells)??[],[x==null?void 0:x.shells]),ue=c.useMemo(()=>ie.filter(mt),[ie]),be=c.useMemo(()=>ue.find(S=>S.id===M)??null,[ue,M]),Le=c.useMemo(()=>ue.find(S=>S.id===J)??null,[ue,J]),ae=T==="secondary"?Le:be,ve=K[T],ke=(x==null?void 0:x.workspacePathStatus)==="missing",pe=T==="secondary"?f:m,Ie=kg({activeRuntime:ve,activeShell:ae,busy:w,loading:k,status:te,workspacePathMissing:ke}),je=Ie.disabled,_e=Ie.label,Pe=Ie.className,Ae=(_==null?void 0:_.tone)==="done"?"shell-floating-feedback shell-floating-feedback-done":(_==null?void 0:_.tone)==="failed"?"shell-floating-feedback shell-floating-feedback-failed":"shell-floating-feedback",Ce=c.useCallback((S,B)=>{Y({tone:S,text:B}),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{Y(null),p.current=null},1800)},[]),Re=c.useCallback((S,B,se)=>{y(ye=>{var nt;if(!ye)return ye;const Oe=ye.shells.map(Ge=>Ge.id===S?B(Ge):Ge),rt=((nt=ye.shell)==null?void 0:nt.id)===S?B(ye.shell):Oe.find(Ge=>{var Ve;return Ge.id===((Ve=ye.shell)==null?void 0:Ve.id)})??ye.shell;return{...ye,...se?{state:se}:{},shell:rt,shells:Oe}})},[]),H=c.useCallback(async()=>{N(!0);try{const S=await n.fetchState(r);y(S),L(null)}catch(S){L(S instanceof Error?S.message:"Unable to load shell state.")}finally{N(!1)}},[n,r]);c.useEffect(()=>{H()},[H]),c.useEffect(()=>{const S=i==null?void 0:i(r);if(S==null){E(50);return}const B=typeof S=="number"?S:Number.parseFloat(String(S));E(Number.isFinite(B)?vn(B):50)},[i,r]),c.useEffect(()=>{if(!x){D(null),W(null);return}const S=vg(x);D(B=>B&&x.shells.some(se=>se.id===B&&mt(se))?B:(S==null?void 0:S.id)??null),W(B=>{if(O!=="columns")return null;if(B&&x.shells.some(ye=>ye.id===B&&mt(ye)))return B;const se=x.shells.find(ye=>mt(ye)&&ye.id!==(S==null?void 0:S.id));return(se==null?void 0:se.id)??null})},[x,O]),c.useEffect(()=>{O!=="columns"&&(q("primary"),W(null))},[O]),c.useEffect(()=>{if(O!=="columns"||J||ue.length<2)return;const S=ue.find(B=>B.id!==(be==null?void 0:be.id))??null;S&&W(S.id)},[ue,be==null?void 0:be.id,J,O]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const S=window.matchMedia("(max-width: 767px), (hover: none) and (pointer: coarse)"),B=()=>{X(S.matches),S.matches||(Z(!1),z(!1))};return B(),S.addEventListener("change",B),()=>{S.removeEventListener("change",B)}},[]),c.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current),b.current!==null&&window.cancelAnimationFrame(b.current)},[]);const ce=c.useCallback((S,B)=>{de(se=>{const ye=se[S];return bg(ye,B)?se:{...se,[S]:B}})},[]),R=c.useCallback(S=>ce("primary",S),[ce]),$=c.useCallback(S=>ce("secondary",S),[ce]),Q=c.useCallback(S=>{var se;if((se=S.label)!=null&&se.trim())return S.label.trim();const B=ie.findIndex(ye=>ye.id===S.id);return`Shell ${B>=0?B+1:""}`.trim()},[ie]),me=c.useCallback(S=>{var B;A(S.id),U(((B=S.label)==null?void 0:B.trim())||Q(S))},[Q]),xe=c.useCallback(()=>{A(null),U("")},[]),ze=c.useCallback(async()=>{if(re){j(!0);try{const S=V.trim(),B=await n.updateShell(re,{label:S.length>0?S:null});y(se=>{var ye;return se&&{...se,state:se.activeShellId===B.id?B.status:se.state,shell:((ye=se.shell)==null?void 0:ye.id)===B.id?B:se.shell,shells:se.shells.map(Oe=>Oe.id===B.id?B:Oe)}}),A(null),U(""),L(null)}catch(S){L(S instanceof Error?S.message:"Unable to rename shell.")}finally{j(!1)}}},[V,re,n]),ge=c.useCallback((S,B)=>{if(S==="primary"){D(B),W(se=>se===B?null:se);return}W(B),D(se=>se===B?null:se)},[]),Me=c.useCallback(S=>{var B,se;if(S==="primary"){(B=m.current)==null||B.disconnect(),D(null),O==="columns"&&q("secondary");return}(se=f.current)==null||se.disconnect(),W(null),q("primary"),ee("single")},[O]),at=c.useCallback((S,B=T)=>{const se=O==="columns"?B:"primary";ge(se,S.id),O!=="columns"&&W(null),q(se)},[T,ge,O]),Je=c.useCallback(async(S=T)=>{var B;if(!v.current){v.current=!0,j(!0);try{const se=await n.createShell(r);y(se);const ye=se.activeShellId??((B=se.shell)==null?void 0:B.id)??null;if(ye){const Oe=O==="columns"?S:"primary";ge(Oe,ye),O!=="columns"&&W(null),q(Oe)}L(null)}catch(se){L(se instanceof Error?se.message:"Unable to create shell.")}finally{v.current=!1,j(!1)}}},[T,ge,n,O,r]);c.useEffect(()=>{!a||!x||k||w||ke||te==="creating"||ue.length>0||Je("primary")},[w,Je,a,ue.length,k,x,te,ke]);const Qe=c.useCallback(async(S=(ae==null?void 0:ae.id)??"")=>{if(S){j(!0);try{await n.terminateShell(S),D(B=>B===S?null:B),W(B=>B===S?null:B),await H(),L(null)}catch(B){L(B instanceof Error?B.message:"Unable to terminate shell.")}finally{j(!1)}}},[ae==null?void 0:ae.id,H,n]),De=c.useCallback(async()=>{var S,B;if(!je){if(ve.shellInputEnabled){(S=pe.current)==null||S.disconnect();return}if(!ae||ae.status==="exited"||ae.status==="not_found"){await Je(T);return}await((B=pe.current)==null?void 0:B.reconnect())}},[T,pe,ve.shellInputEnabled,ae,je,Je]),Be=c.useCallback(S=>{typeof window>"u"||d==null||d(r,vn(S))},[d,r]),lt=c.useCallback(()=>{var S,B;(S=m.current)==null||S.refreshLayout({syncBackendSize:!0}),(B=f.current)==null||B.refreshLayout({syncBackendSize:!0})},[]),He=c.useCallback(S=>{var rt,nt;if(O!=="columns")return;const B=g.current;if(!B)return;S.preventDefault(),(nt=(rt=S.currentTarget).setPointerCapture)==null||nt.call(rt,S.pointerId);const se=Ge=>{const Ve=B.getBoundingClientRect();if(Ve.width<=0)return;const ht=vn((Ge-Ve.left)/Ve.width*100);E(ht),b.current!==null&&window.cancelAnimationFrame(b.current),b.current=window.requestAnimationFrame(()=>{b.current=null,lt()})},ye=Ge=>{se(Ge.clientX)},Oe=Ge=>{se(Ge.clientX);const Ve=B.getBoundingClientRect();Ve.width>0&&Be((Ge.clientX-Ve.left)/Ve.width*100),window.removeEventListener("pointermove",ye),window.removeEventListener("pointerup",Oe)};window.addEventListener("pointermove",ye),window.addEventListener("pointerup",Oe,{once:!0})},[Be,lt,O]),tt=c.useCallback((S,B)=>{ge(B,S.id),q(B)},[ge]),it=c.useCallback(async()=>{var B;return await((B=pe.current)==null?void 0:B.copyLastCommandOutput())?!0:(Ce("failed","Nothing to copy"),!1)},[pe,Ce]);c.useEffect(()=>{h==null||h(wg({activeRuntime:ve,activeShell:ae,connectionButtonDisabled:je,connectionButtonLabel:_e,isMobileShell:I,busy:w,loading:k,error:C}))},[ve,ae,w,je,_e,C,I,k,h]),c.useImperativeHandle(u,()=>({async toggleConnection(){await De()},sendInput(S){var B;return((B=pe.current)==null?void 0:B.sendInput(S))??!1},sendCommand(S){var B;return((B=pe.current)==null?void 0:B.sendCommand(S))??!1},sendControl(S){var B;return((B=pe.current)==null?void 0:B.sendControl(S))??!1},async copyLastCommandOutput(){var S;return await((S=pe.current)==null?void 0:S.copyLastCommandOutput())??!1},async terminate(){await Qe()},focus(){var S;(S=pe.current)==null||S.focus()},refreshLayout(S){var B,se;(B=m.current)==null||B.refreshLayout(S),O==="columns"&&((se=f.current)==null||se.refreshLayout(S))}}),[pe,De,Qe,O]);const Ye=S=>t.jsx("div",{className:`rounded-md border px-2 py-1.5 text-xs ${S.id===(ae==null?void 0:ae.id)?"border-sky-300/40 bg-sky-300/12 text-sky-50":"border-stone-800 bg-stone-900/40 text-stone-300"}`,children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[re===S.id?t.jsx("form",{className:"min-w-0 flex-1",onSubmit:B=>{B.preventDefault(),ze()},children:t.jsx("input",{value:V,onChange:B=>U(B.currentTarget.value),onKeyDown:B=>{B.key==="Escape"&&(B.preventDefault(),xe())},autoFocus:!0,className:"w-full rounded border border-sky-300/35 bg-stone-950/70 px-2 py-1 text-xs text-stone-100 outline-none","aria-label":"Shell name"})}):t.jsxs("button",{type:"button",onClick:()=>at(S),onDoubleClick:()=>me(S),className:"min-w-0 flex-1 text-left",title:S.tmuxSessionName,children:[t.jsx("span",{className:"block truncate",children:Q(S)}),t.jsxs("span",{className:"block truncate text-[10px] text-[var(--theme-fg-muted)]",children:[bn(S.status)," · ",Xr(S.cwd)||S.cwd]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[re===S.id?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>void ze(),className:"rounded border border-sky-300/35 bg-sky-300/12 px-1.5 py-1 text-[10px] text-sky-50",title:"Save shell name",children:"Save"}),t.jsx("button",{type:"button",onClick:xe,className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200",title:"Cancel rename",children:"Cancel"})]}):t.jsx("button",{type:"button",onClick:()=>me(S),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Rename shell",children:"Rename"}),O==="columns"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>tt(S,"primary"),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Open in left pane",children:"L"}),t.jsx("button",{type:"button",onClick:()=>tt(S,"secondary"),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Open in right pane",children:"R"})]}),t.jsx("button",{type:"button",disabled:w,onClick:()=>void Qe(S.id),className:"rounded border border-rose-300/35 bg-rose-300/12 px-1.5 py-1 text-[10px] text-rose-100 disabled:cursor-not-allowed disabled:opacity-50",title:"Kill shell process",children:"Kill"})]})]})},S.id);return t.jsxs("div",{className:"shell-panel flex min-h-0 flex-1 flex-col",children:[s&&t.jsxs("div",{className:"shell-header shrink-0 border-b px-3 py-3 sm:px-5",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs uppercase tracking-[0.24em] text-[var(--theme-fg-muted)]",children:"Shell"}),t.jsx("p",{className:"mt-1 truncate text-sm text-[var(--theme-fg-soft)]",children:ve.promptLabel??(ae==null?void 0:ae.cwd)??"Create a terminal for this thread."})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("button",{type:"button","aria-label":_e,title:`${_e} (${bn(ve.status)})`,disabled:je,onClick:()=>void De(),className:`inline-flex h-10 w-10 items-center justify-center rounded-full border shadow-lg shadow-stone-950/25 transition disabled:cursor-not-allowed disabled:opacity-60 ${Pe}`,children:t.jsx(Xf,{connected:ve.shellInputEnabled})}),ae&&t.jsx("button",{type:"button",disabled:w,onClick:()=>void Qe(ae.id),className:"rounded-full border border-rose-300/35 bg-rose-300/12 px-3 py-2 text-sm text-rose-600 transition hover:bg-rose-300/18 dark:text-rose-100 disabled:cursor-not-allowed disabled:opacity-60",children:"Terminate"})]})]}),(C||k||ke)&&t.jsxs("div",{className:"shell-banner mt-3 rounded-2xl border px-3 py-3 text-sm",children:[k&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!k&&ke&&t.jsx("p",{className:"text-rose-600 dark:text-rose-100",children:"Workspace path is missing on this machine. Restore the path before creating a shell."}),!k&&C&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:C})]})]}),t.jsx("div",{className:"min-h-0 flex-1",children:t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("div",{className:"shell-terminal-bar flex shrink-0 items-center gap-2 border-b px-2 py-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-1",children:[t.jsx("span",{className:"min-w-0 truncate text-xs text-[var(--theme-fg-soft)]",children:ae?Q(ae):"No live shell process"}),ae&&t.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.12em] text-[var(--theme-fg-muted)]",children:bn(ve.status)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.jsxs("span",{className:"hidden text-xs text-[var(--theme-fg-muted)] sm:inline",children:["Live ",ue.length]}),t.jsx("button",{type:"button","aria-expanded":F,"aria-label":F?"Hide shell processes":"Show shell processes",onClick:()=>z(S=>!S),className:"rounded-md border border-stone-700/80 bg-stone-900/50 px-2.5 py-1.5 text-xs text-stone-200 sm:hidden",children:"Processes"})]})]}),F&&t.jsxs("div",{className:"shrink-0 border-b border-stone-800/80 bg-stone-950/55 p-2 sm:hidden",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsx("p",{className:"text-xs uppercase tracking-[0.16em] text-[var(--theme-fg-muted)]",children:"Processes"}),t.jsxs("span",{className:"text-[10px] text-[var(--theme-fg-muted)]",children:[ue.length," live"]})]}),t.jsxs("div",{className:"max-h-52 space-y-1 overflow-y-auto",children:[ue.map(Ye),ue.length===0&&t.jsx("p",{className:"px-2 py-3 text-xs text-[var(--theme-fg-muted)]",children:"No live shell processes"})]}),t.jsx("div",{className:"mt-2 flex justify-end border-t border-stone-800/80 pt-2",children:t.jsx("button",{type:"button","aria-label":"New shell",title:"New shell",disabled:w||k||ke,onClick:()=>void Je(T),className:"inline-flex h-8 w-8 items-center justify-center rounded-md border border-sky-300/35 bg-sky-300/12 text-base leading-none text-sky-50 disabled:cursor-not-allowed disabled:opacity-50",children:"+"})})]}),te==="not_created"||ke?t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"shell-empty-state max-w-md rounded-[1.6rem] border px-6 py-8",children:[t.jsx("p",{className:"text-base font-medium text-[var(--theme-fg)]",children:"Durable thread shell"}),t.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--theme-fg-muted)]",children:"The shell runs under a supervisor-managed PTY and reconnects after browser disconnects. Create it explicitly when you want to inspect or take over the workspace."}),!ke&&t.jsx("button",{type:"button",disabled:w||k,onClick:()=>void Je("primary"),className:"mt-5 rounded-md border border-sky-300/35 bg-sky-300/12 px-3 py-2 text-sm text-sky-50 disabled:cursor-not-allowed disabled:opacity-50",children:"New Shell"})]})}):t.jsxs("div",{className:"grid h-full min-h-0 grid-cols-1 gap-2 p-2 sm:grid-cols-[minmax(0,1fr)_16rem] sm:p-3",children:[t.jsxs("div",{className:"shell-terminal-frame relative min-h-0 overflow-hidden rounded-[1.4rem] border shadow-inner",children:[!s&&(C||k||ke)&&t.jsxs("div",{className:"shell-banner absolute left-2 right-2 top-2 z-10 rounded-2xl border px-3 py-3 text-sm backdrop-blur sm:left-3 sm:right-3 sm:top-3",children:[k&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!k&&ke&&t.jsx("p",{className:"text-rose-600 dark:text-rose-100",children:"Workspace path is missing on this machine. Restore the path before creating a shell."}),!k&&C&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:C})]}),t.jsxs("div",{ref:g,className:`relative grid h-full min-h-0 ${O==="columns"?"grid-cols-1 sm:grid-cols-[var(--shell-left)_0.35rem_var(--shell-right)]":"grid-cols-1"}`,style:O==="columns"?{"--shell-left":`${he}fr`,"--shell-right":`${100-he}fr`}:void 0,"data-shell-split-ratio":he,children:[t.jsx(Ls,{ref:m,paneId:"primary",shell:be,isActive:T==="primary",isVisible:a,isMobileShell:I,effectiveTheme:l,workspacePathMissing:ke,shellAdapter:n,onActivate:()=>q("primary"),onShellUpdate:Re,onRuntimeStateChange:R,onFeedback:Ce}),O==="columns"&&t.jsx("button",{type:"button",onClick:()=>Me("primary"),className:"absolute left-2 top-2 z-10 rounded-md border border-stone-700/80 bg-stone-950/70 px-2 py-1 text-[10px] text-stone-200 hover:border-rose-300/40",title:"Close left pane",children:"Close"}),O==="columns"&&t.jsx("button",{type:"button","aria-label":"Resize shell panes",title:"Resize shell panes",onPointerDown:He,className:"hidden cursor-col-resize border-x border-stone-800/80 bg-stone-900/60 transition hover:border-sky-300/40 hover:bg-sky-300/10 sm:block"}),O==="columns"&&t.jsxs("div",{className:"relative min-h-0 border-t border-stone-800/80 sm:border-l sm:border-t-0",children:[t.jsx(Ls,{ref:f,paneId:"secondary",shell:Le,isActive:T==="secondary",isVisible:a,isMobileShell:I,effectiveTheme:l,workspacePathMissing:ke,shellAdapter:n,onActivate:()=>q("secondary"),onShellUpdate:Re,onRuntimeStateChange:$,onFeedback:Ce}),t.jsx("button",{type:"button",onClick:()=>Me("secondary"),className:"absolute left-2 top-2 z-10 rounded-md border border-stone-700/80 bg-stone-950/70 px-2 py-1 text-[10px] text-stone-200 hover:border-rose-300/40",title:"Close right pane",children:"Close"})]})]}),o&&I&&t.jsxs("div",{className:"pointer-events-none absolute bottom-3 right-3 z-20 flex flex-col items-end gap-2",children:[_&&t.jsx("div",{className:`pointer-events-auto rounded-full border px-3 py-1.5 text-[11px] shadow-lg shadow-stone-950/30 backdrop-blur ${Ae}`,children:_.text}),P&&t.jsx("div",{className:"shell-toolbox pointer-events-auto rounded-[1.2rem] border p-2 shadow-2xl backdrop-blur",children:t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx("button",{type:"button",onClick:()=>{Ce("idle","Use the prompt box tools to paste")},className:"inline-flex items-center justify-center rounded-full border border-sky-300/35 bg-sky-300/12 px-2.5 py-2 text-sky-600 dark:text-sky-50",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Ss,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:()=>void it(),className:"shell-toolbox-copy inline-flex items-center justify-center rounded-full border px-2.5 py-2",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Ss,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:!ve.shellInputEnabled,onClick:()=>{var S;(S=pe.current)!=null&&S.sendControl("clear")?Ce("done","Cleared"):Ce("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(kn,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!ve.shellInputEnabled||!ve.isCommandRunning,onClick:()=>{var S;(S=pe.current)!=null&&S.sendInput("")?Ce("done","Sent Ctrl-C"):Ce("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(kn,{label:"CTRL-C",tone:"rose"})}),["ctrl_d","esc","tab","up","down"].map(S=>t.jsx("button",{type:"button",disabled:!ve.shellInputEnabled,onClick:()=>{var B;(B=pe.current)!=null&&B.sendControl(S)?Ce("done",`Sent ${S.toUpperCase().replace("_","-")}`):Ce("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(kn,{label:S.toUpperCase().replace("_","-"),tone:"stone"})},S))]})}),t.jsx("button",{type:"button","aria-expanded":P,"aria-label":P?"Close shell tools":"Open shell tools",onClick:()=>Z(S=>!S),className:"shell-toolbox-trigger pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-2xl backdrop-blur transition",children:t.jsx(qf,{})})]})]}),t.jsxs("aside",{className:"hidden min-h-0 overflow-hidden rounded-[1rem] border border-stone-800/80 bg-stone-950/30 p-2 sm:flex sm:flex-col",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsx("p",{className:"text-xs uppercase tracking-[0.16em] text-[var(--theme-fg-muted)]",children:"Processes"}),t.jsxs("span",{className:"text-[10px] text-[var(--theme-fg-muted)]",children:[ue.length," live"]})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-1 overflow-y-auto",children:[ue.map(Ye),ue.length===0&&t.jsx("p",{className:"px-2 py-3 text-xs text-[var(--theme-fg-muted)]",children:"No live shell processes"})]}),t.jsx("div",{className:"mt-2 flex justify-end border-t border-stone-800/80 pt-2",children:t.jsx("button",{type:"button","aria-label":"New shell",title:"New shell",disabled:w||k||ke,onClick:()=>void Je(T),className:"inline-flex h-8 w-8 items-center justify-center rounded-md border border-sky-300/35 bg-sky-300/12 text-base leading-none text-sky-50 disabled:cursor-not-allowed disabled:opacity-50",children:"+"})})]})]})]})})]})}),Gg=c.lazy(async()=>({default:(await Promise.resolve().then(()=>(Qh(),Vo))).ThreadGraphWorkspacePanel}));function Fg(){return t.jsx("div",{className:"flex h-full min-h-0 flex-1 items-center justify-center px-4 text-sm text-[var(--theme-fg-muted)]",children:"Loading workspace..."})}function bl(e){return t.jsx(c.Suspense,{fallback:t.jsx(Fg,{}),children:t.jsx(Gg,{...e})})}c.memo(bl);function tx({open:e,title:r,description:n,confirmLabel:a="Delete",busy:s=!1,onCancel:o,onConfirm:l}){return c.useEffect(()=>{if(!e)return;function i(d){d.key==="Escape"&&!s&&o()}return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[s,o,e]),e?$r.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[95] flex items-center justify-center p-4 sm:p-6",children:[t.jsx("button",{type:"button","aria-label":"Close confirmation dialog",onClick:o,disabled:s,className:"absolute inset-0 bg-stone-950/78 backdrop-blur-sm disabled:cursor-not-allowed"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":r,className:"relative z-[1] w-full max-w-md rounded-[1.6rem] border border-stone-700 bg-stone-900 p-5 shadow-2xl shadow-stone-950/40 sm:p-6",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium text-stone-100",children:r}),t.jsx("p",{className:"mt-2 text-sm leading-6 text-stone-400",children:n})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:o,disabled:s,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-stone-700 text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsxs("div",{className:"mt-5 flex items-center justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:o,disabled:s,className:"rounded-full border border-stone-700 px-4 py-2 text-sm font-medium text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),t.jsx("button",{type:"button",onClick:()=>void l(),disabled:s,className:"ui-action-danger rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:s?"Deleting...":a})]})]})]}),document.body):null}function Hg(e){if(!e)return"No time";const r=new Date(e);return Number.isNaN(r.getTime())?e:r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Og(e){switch(e){case"inProgress":return"running";case"completed":return"completed";case"interrupted":return"interrupted";case"failed":return"failed"}}function rx({open:e,busy:r=!1,turnsState:n,onCancel:a,onLoadTurns:s,onExport:o}){var j,C,L;const l=c.useMemo(()=>{var T;return((T=n.data)==null?void 0:T.turns)??[]},[(j=n.data)==null?void 0:j.turns]),i=c.useMemo(()=>l.slice(0,10).map(T=>T.turnId),[l]),[d,h]=c.useState("latest"),[u,m]=c.useState(()=>new Set),[f,p]=c.useState(!0),[g,b]=c.useState("pdf"),[v,x]=c.useState(()=>typeof document<"u"&&!document.documentElement.classList.contains("dark")?"light":"dark");if(c.useEffect(()=>{e&&(h("latest"),b("pdf"),p(!0),s())},[s,e]),c.useEffect(()=>{e&&l.length>0&&m(new Set(i))},[i,e,l.length]),c.useEffect(()=>{if(!e)return;function T(q){q.key==="Escape"&&!r&&a()}return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[r,a,e]),c.useEffect(()=>{if(!e)return;const T=document.querySelector(".thread-ui-shell"),q=()=>T?T.getAttribute("data-theme-effective")==="dark"||T.classList.contains("dark")||T.classList.contains("thread-ui-theme-dark")?"dark":"light":document.documentElement.classList.contains("dark")?"dark":"light";if(x(q()),!T)return;const M=new MutationObserver(()=>x(q()));return M.observe(T,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>M.disconnect()},[e]),!e)return null;const y=d==="latest"?Math.min(10,((C=n.data)==null?void 0:C.totalTurnCount)??10):u.size,k=!r&&(d==="latest"||u.size>0);function N(T){m(q=>{const M=new Set(q);return M.has(T)?M.delete(T):M.add(T),M})}function w(){const T={format:g,mode:d,...d==="latest"?{limit:10}:{turnIds:[...u]},profile:"review",options:{includeTokenAndPrice:f}};o(T)}return $r.createPortal(t.jsxs("div",{className:`thread-export-dialog-root thread-ui-theme-${v} fixed inset-0 z-[96] flex items-center justify-center p-3 sm:p-6`,"data-theme-effective":v,children:[t.jsx("button",{type:"button","aria-label":"Close export dialog",onClick:a,disabled:r,className:"thread-export-dialog-backdrop absolute inset-0 backdrop-blur-sm disabled:cursor-not-allowed"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Export transcript",className:"thread-export-dialog-panel relative z-[1] flex max-h-[min(46rem,calc(100vh-2rem))] w-full max-w-2xl flex-col rounded-[1.6rem] border shadow-2xl",children:[t.jsxs("div",{className:"thread-export-dialog-header flex items-start justify-between gap-3 border-b px-5 py-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-export-dialog-title text-sm font-semibold",children:"Export transcript"}),t.jsx("p",{className:"thread-export-dialog-subtitle mt-1 text-xs",children:"Default review copy summarizes command batches and file changes."})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:a,disabled:r,className:"thread-export-dialog-icon-button inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border transition disabled:cursor-not-allowed disabled:opacity-60",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-auto px-5 py-4",children:[t.jsx("div",{className:"thread-export-dialog-segment inline-flex rounded-full border p-1",children:[["latest","Latest 10"],["selected","Custom selection"]].map(([T,q])=>t.jsx("button",{type:"button",onClick:()=>h(T),className:`rounded-full px-3 py-1.5 text-sm transition ${d===T?"ui-status-warning":"thread-export-dialog-muted-action"}`,children:q},T))}),t.jsx("div",{className:"thread-export-dialog-segment mt-4 inline-flex rounded-full border p-1",children:[["pdf","PDF"],["html","HTML"]].map(([T,q])=>t.jsx("button",{type:"button",onClick:()=>b(T),className:`rounded-full px-3 py-1.5 text-sm transition ${g===T?"ui-status-warning":"thread-export-dialog-muted-action"}`,children:q},T))}),d==="selected"?t.jsxs("div",{className:"thread-export-dialog-box mt-4 rounded-2xl border",children:[t.jsxs("div",{className:"thread-export-dialog-box-header flex flex-wrap items-center justify-between gap-2 border-b px-3 py-2.5",children:[t.jsxs("p",{className:"thread-export-dialog-subtitle text-xs",children:["Selected ",u.size," of ",((L=n.data)==null?void 0:L.totalTurnCount)??l.length]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>m(new Set(l.map(T=>T.turnId))),className:"thread-export-dialog-secondary-button rounded-full border px-2.5 py-1 text-xs transition",children:"Select all"}),t.jsx("button",{type:"button",onClick:()=>m(new Set),className:"thread-export-dialog-secondary-button rounded-full border px-2.5 py-1 text-xs transition",children:"Clear"})]})]}),n.status==="loading"?t.jsx("p",{className:"thread-export-dialog-subtitle px-3 py-6 text-sm",children:"Loading turns..."}):n.status==="failed"?t.jsx("p",{className:"px-3 py-6 text-sm text-rose-500 dark:text-rose-200",children:n.error}):t.jsx("div",{className:"max-h-80 overflow-auto p-2",children:l.map(T=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex cursor-pointer items-center gap-3 rounded-xl px-2.5 py-2 text-sm transition",children:[t.jsx("input",{type:"checkbox",checked:u.has(T.turnId),onChange:()=>N(T.turnId),className:"thread-export-dialog-checkbox h-4 w-4"}),t.jsxs("span",{className:"thread-export-dialog-strong shrink-0 text-xs font-medium",children:["Turn ",T.turnNumber]}),t.jsx("span",{className:"thread-export-dialog-subtitle shrink-0 text-xs",children:Hg(T.startedAt)}),t.jsx("span",{className:"thread-export-dialog-body-text min-w-0 flex-1 truncate text-left",children:T.userPromptPreview}),t.jsx("span",{className:"thread-export-dialog-status-pill hidden shrink-0 rounded-full border px-2 py-0.5 text-[10px] sm:inline",children:Og(T.status)})]},T.turnId))})]}):t.jsx("p",{className:"thread-export-dialog-box thread-export-dialog-body-text mt-4 rounded-2xl border px-3 py-3 text-sm",children:"Exports the latest 10 turns in chronological order."}),t.jsxs("div",{className:"thread-export-dialog-body-text mt-4 grid gap-2 text-sm sm:grid-cols-2",children:[t.jsxs("label",{className:"thread-export-dialog-box flex items-center gap-2 rounded-xl border px-3 py-2",children:[t.jsx("input",{type:"checkbox",checked:f,onChange:T=>p(T.target.checked),className:"thread-export-dialog-checkbox h-4 w-4"}),"Token and price"]}),t.jsx("p",{className:"thread-export-dialog-box thread-export-dialog-subtitle flex items-center rounded-xl border px-3 py-2 text-xs",children:g==="html"?"HTML keeps the chat timeline styling and omits raw command output.":"Review exports keep message text readable and omit tool activity."})]})]}),t.jsxs("div",{className:"thread-export-dialog-footer flex items-center justify-between gap-3 border-t px-5 py-4",children:[t.jsxs("p",{className:"thread-export-dialog-subtitle min-w-0 text-xs",children:[y," ",y===1?"turn":"turns"," will be exported."]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:a,disabled:r,className:"thread-export-dialog-secondary-button rounded-full border px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),t.jsx("button",{type:"button",onClick:w,disabled:!k,className:"ui-status-warning rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:r?"Exporting...":`Export ${g.toUpperCase()}`})]})]})]})]}),document.body)}function yn(e){if(e===void 0)return"-";if(Math.abs(e)>1e4){const r=Math.abs(e)>=1e5?0:1;return`${(e/1e3).toLocaleString(void 0,{maximumFractionDigits:r})}k`}return e.toLocaleString()}function Ug(e){return`in ${yn(e.input)} / out ${yn(e.output)} / cache ${yn(e.cache)}`}function Wg({detail:e,adapter:r,timelineAdapter:n,TimelineComponent:a=pl,liveOutput:s="",beforeTimelineContent:o,composerProps:l,timelineProps:i,threadUsageSummary:d,transcriptItemCount:h,useFloatingMobileComposer:u=!1,floatingMobileComposerBottomOffset:m=0,composerHostRef:f}){const[p,g]=c.useState(!1),[b,v]=c.useState(0),[x,y]=c.useState(0),[k,N]=c.useState(0),[w,j]=c.useState(!1),C=c.useRef(null),L=i==null?void 0:i.onTailVisibilityChange,T=e.pendingRequests.length>0,q=c.useCallback(E=>{L==null||L(E)},[L]);c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const E=window.matchMedia("(max-width: 639px)"),re=()=>g(E.matches);return re(),E.addEventListener("change",re),()=>{E.removeEventListener("change",re)}},[]),c.useEffect(()=>{var re,A;if(typeof window>"u")return;const E=()=>{const V=window.visualViewport,U=V?Math.max(0,Math.round(window.innerHeight-V.height-V.offsetTop)):0,I=V?Math.max(0,Math.round(window.innerHeight-V.height)):U,X=Math.min(U,I),F=Math.max(0,Math.round(window.innerHeight*.52));N(Math.min(X,F))};return E(),(re=window.visualViewport)==null||re.addEventListener("resize",E),(A=window.visualViewport)==null||A.addEventListener("scroll",E),window.addEventListener("resize",E),()=>{var V,U;(V=window.visualViewport)==null||V.removeEventListener("resize",E),(U=window.visualViewport)==null||U.removeEventListener("scroll",E),window.removeEventListener("resize",E)}},[]),c.useLayoutEffect(()=>{const E=C.current;if(!E||!p){v(0);return}const re=()=>{v(Math.ceil(E.getBoundingClientRect().height))};if(re(),typeof ResizeObserver>"u")return;const A=new ResizeObserver(re);return A.observe(E),()=>{A.disconnect()}},[p,l,T]),c.useLayoutEffect(()=>{var V,U;const E=C.current;if(!E||!p){y(0);return}const re=()=>{const I=E.getBoundingClientRect();y(Math.max(0,Math.ceil(window.innerHeight-I.top)))};re(),window.addEventListener("resize",re),(V=window.visualViewport)==null||V.addEventListener("resize",re),(U=window.visualViewport)==null||U.addEventListener("scroll",re);let A=null;return typeof ResizeObserver<"u"&&(A=new ResizeObserver(re),A.observe(E)),()=>{var I,X;window.removeEventListener("resize",re),(I=window.visualViewport)==null||I.removeEventListener("resize",re),(X=window.visualViewport)==null||X.removeEventListener("scroll",re),A==null||A.disconnect()}},[p,k,w,l,T]),c.useEffect(()=>{if(!p){j(!1);return}const E=A=>{var U;const V=A.target;V instanceof HTMLElement&&((U=C.current)!=null&&U.contains(V))&&j(!0)},re=A=>{var U;const V=A.relatedTarget;V instanceof HTMLElement&&((U=C.current)!=null&&U.contains(V))||j(!1)};return document.addEventListener("focusin",E),document.addEventListener("focusout",re),()=>{document.removeEventListener("focusin",E),document.removeEventListener("focusout",re)}},[p]);const M=c.useCallback(E=>{C.current=E,f&&(f.current=E)},[f]),D=p&&w?Math.max(0,k-m):0,J=Math.max(b,144),W=Math.max(x,J+D),O=p?W+12:0,ee=O>0?{"--thread-graph-chat-scroll-bottom-spacer":`${O}px`}:void 0,he=u&&p?{bottom:`${m+D}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"}:void 0;return t.jsxs("div",{"data-testid":"chat-panel",className:"thread-graph-chat-panel relative flex h-full min-h-0 flex-col",style:ee,children:[o,t.jsx(a,{threadId:e.thread.id,turns:e.turns,totalTurnCount:e.totalTurnCount??e.turns.length,pendingRequests:e.pendingRequests,activeTurnId:e.thread.activeTurnId,threadRunning:e.thread.status==="running"||e.thread.activeTurnId!==null,liveOutput:s,className:"thread-timeline-surface min-h-0 flex-1",...i,adapter:n,onOpenThread:(i==null?void 0:i.onOpenThread)??r.openThread,onTailVisibilityChange:q}),t.jsxs("div",{className:"thread-chat-usage-footer hidden shrink-0 items-center justify-between gap-3 px-4 py-1 text-[10px] leading-4 sm:flex",children:[t.jsxs("span",{className:"min-w-0 truncate",children:[e.turns.length," turn",e.turns.length!==1?"s":"",t.jsx("span",{className:"mx-1 text-[var(--theme-border-contrast)]",children:"|"}),h," item",h!==1?"s":""]}),t.jsxs("span",{className:"shrink-0",children:["Usage"," ",d&&d.turns>0?Ug(d):"waiting for agent usage"]})]}),l?u?t.jsx("div",{ref:M,className:"fixed inset-x-0 bottom-0 z-50 overflow-visible sm:hidden",style:he??{bottom:`${m}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"},children:t.jsx($n,{...l,activeView:"chat",edgeToEdgeMobile:!0,onSubmit:r.sendPrompt})}):t.jsx("div",{ref:M,className:"thread-graph-composer-host shrink-0",children:t.jsx($n,{...l,activeView:"chat",onSubmit:r.sendPrompt})}):null]})}function Vg(e){return e.turns.reduce((r,n)=>{var s;const a=(s=n.tokenUsage)==null?void 0:s.total;return a?{input:r.input+a.inputTokens,output:r.output+a.outputTokens,cache:r.cache+a.cachedInputTokens,turns:r.turns+1}:r},{input:0,output:0,cache:0,turns:0})}function jn(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?"0":e>=1e6?`${(e/1e6).toFixed(e>=1e7?0:1)}m`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(Math.round(e))}function Kg(e){return!e||e.turns<=0?"waiting for agent usage":`in ${jn(e.input)} / out ${jn(e.output)} / cache ${jn(e.cache)}`}function nx({threads:e,detail:r,loading:n,error:a,status:s=null,plugins:o,adapter:l,metaContent:i,settingsContent:d,globalSettingsContent:h,settingsDialogOpen:u,onSettingsDialogOpenChange:m,mobileHeaderAction:f,appMenuButton:p,appNavigationMenu:g,workspaceReturnHref:b,onWorkspaceReturn:v,surfaceActions:x,floatingPanel:y,workspaceContent:k,workspaceTitle:N,workspaceActions:w,workspaceFeatures:j,workspaceFocusPathRequest:C=null,onNewThreadTitle:L,beforeTimelineContent:T,errorContent:q,workspaceMissingContent:M,dialogs:D,currentThreadId:J,currentWorkspaceId:W,currentWorkspaceLabel:O,onCloseAppNavigation:ee,className:he="thread-detail-surface relative flex h-full min-h-0 flex-1 flex-col overflow-hidden",activeView:E="chat",liveOutput:re="",timelineProps:A,composerProps:V,shellComposerProps:U,useFloatingMobileComposer:I=!1,floatingMobileComposerBottomOffset:X=0,composerHostRef:F,shellPanelRef:z,shellEffectiveTheme:P="dark",shellThemeMode:Z=P,onShellThemeModeChange:K,onShellStateChange:de,shellUnavailableContent:_,shellDisconnectedContent:Y,timelineComponent:te=pl,shellPanelComponent:ie=Bg,shellContent:ue,loadingContent:be,emptyContent:Le}){const ae=ra(),ve=o??ae??ea(),{getImageAssetUrl:ke,loadHistoryItemDetail:pe,openWorkspaceFile:Ie,openThread:je,cancelPendingSteer:_e}=l,Pe=c.useMemo(()=>({...ke?{getImageAssetUrl:Q=>ke(Q.path)}:{},onOpenLinkedThread:je,...Ie?{onOpenWorkspaceFile:Ie}:{},...pe?{onLoadHistoryItemDetail:pe}:{},..._e?{cancelPendingSteer:_e}:{}}),[_e,ke,pe,Ie,je]),Ae=ve.getThreadPanels().some(Q=>Q.kind==="terminal"),Ce=c.useMemo(()=>r?Vg(r):null,[r]),Re=c.useMemo(()=>Kg(Ce),[Ce]),H=c.useMemo(()=>{var Q;return r?r.turns.reduce((me,xe)=>me+xe.items.length,((Q=r.liveItems)==null?void 0:Q.items.length)??0):0},[r]),ce=k??(r?t.jsx(bl,{detail:r,status:s,plugins:ve,workspaceAdapter:l.workspace??null,metaContent:i,settingsContent:d,activeView:E,features:j,focusPathRequest:C}):null),R=n?be??t.jsx("div",{className:"flex flex-1 items-center justify-center px-6 py-12 text-center text-[var(--theme-fg-muted)]",children:"Loading thread detail..."}):r?t.jsxs("div",{className:he,children:[y?t.jsx("div",{className:"fixed right-3 top-20 z-50 lg:absolute lg:right-4 lg:top-16",children:y}):null,a&&!n&&(q??t.jsx("div",{className:"shrink-0 border-b border-rose-500/20 bg-rose-500/10 px-5 py-4 text-sm text-rose-100 sm:px-6",children:a})),r.workspacePathStatus==="missing"&&(M??t.jsxs("div",{className:"shrink-0 border-b border-rose-500/20 bg-rose-500/10 px-5 py-4 text-sm text-rose-100 sm:px-6",children:[t.jsx("p",{className:"font-medium text-rose-50",children:"Workspace path missing"}),t.jsx("p",{className:"mt-1 break-words text-rose-100/90",children:r.workspace.absPath})]})),t.jsx("div",{className:E==="chat"?"flex min-h-0 flex-1 flex-col":"hidden",children:t.jsx(Wg,{detail:r,adapter:l,timelineAdapter:Pe,TimelineComponent:te,liveOutput:re,threadUsageSummary:Ce,transcriptItemCount:H,useFloatingMobileComposer:I,floatingMobileComposerBottomOffset:X,...T?{beforeTimelineContent:T}:{},...V?{composerProps:V}:{},...A?{timelineProps:A}:{},...F?{composerHostRef:F}:{}})}),t.jsxs("div",{className:E==="shell"?"flex min-h-0 flex-1 flex-col":"hidden",children:[ue??(r.thread.isLoaded&&Ae&&l.shell?t.jsx(ie,{ref:z,threadId:r.thread.id,shellAdapter:l.shell,effectiveTheme:P,isVisible:E==="shell",showHeader:!1,showFloatingToolbox:!1,...de?{onStateChange:de}:{}}):r.thread.isLoaded&&!Ae?_??t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center p-4 sm:p-6",children:t.jsxs("div",{className:"thread-empty-surface max-w-md rounded-[1.6rem] border px-6 py-8 text-center",children:[t.jsx("p",{className:"text-base font-medium text-[var(--theme-fg)]",children:"Terminal plugin disabled"}),t.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--theme-fg-muted)]",children:"Enable the Terminal plugin in Settings to use the shell panel."})]})}):Y??t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center p-4 sm:p-6",children:t.jsxs("div",{className:"thread-empty-surface max-w-md rounded-[1.6rem] border px-6 py-8 text-center",children:[t.jsx("p",{className:"text-base font-medium text-[var(--theme-fg)]",children:"Thread disconnected"}),t.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--theme-fg-soft)]",children:"Reconnect this thread before creating or attaching a shell."})]})})),E==="shell"&&U&&!ue?t.jsx($n,{...U,activeView:"shell",onSubmit:l.sendPrompt}):null]}),D]}):Le??t.jsx("div",{className:"flex flex-1 items-center justify-center px-6 py-12 text-center text-[var(--theme-fg-muted)]",children:"Select a thread to inspect."}),$=t.jsx(qm,{threads:e,status:s,loading:n,error:n?null:a,viewportConstrained:!0,currentThreadId:J??(r==null?void 0:r.thread.id),currentThreadLabel:r==null?void 0:r.thread.title,currentWorkspaceId:W??(r==null?void 0:r.thread.workspaceId),currentWorkspaceLabel:O??(r==null?void 0:r.workspace.label),sessionLabel:(r==null?void 0:r.thread.providerSessionId)??(r==null?void 0:r.thread.id),usageLabel:Re,topbarActions:x,metaContent:i,settingsContent:d,globalSettingsContent:h,...u!==void 0?{settingsDialogOpen:u}:{},...m?{onSettingsDialogOpenChange:m}:{},mobileHeaderAction:f,effectiveTheme:P,themeMode:Z,appMenuButton:p,appNavigationMenu:g,workspaceReturnHref:b,...v?{onWorkspaceReturn:v}:{},showMobileAppMenu:!!p,showMobileThreadNavToggle:!0,showMobileNewThreadShortcut:!1,onOpenThread:l.openThread,workspaceContent:ce,workspaceTitle:N??"Workspace",workspaceActions:w,...L?{onNewThreadTitle:L}:{},...ee?{onCloseAppNavigation:ee}:{},...K?{onThemeModeChange:K}:{},...l.getThreadHref?{getThreadHref:l.getThreadHref}:{},...l.getNewThreadHref?{getNewThreadHref:l.getNewThreadHref}:{},...l.renameThread?{onRenameThread:l.renameThread}:{},...l.deleteThread?{onDeleteThread:l.deleteThread}:{},children:R});return o?t.jsx(ta.Provider,{value:ve,children:$}):$}var qg={},Xg=[];function ax({adapter:e=qg,builtinPlugins:r=Xg,children:n}){const[a,s]=c.useState(()=>Dn(r,[])),[o,l]=c.useState(!1),[i,d]=c.useState(null),h=c.useCallback(async()=>{l(!0),d(null);try{const k=e.fetchPlugins?await e.fetchPlugins():[];s(Dn(r,k))}catch(k){d(k instanceof Error?k.message:"Unable to load plugins.")}finally{l(!1)}},[e,r]);c.useEffect(()=>{h()},[h]);const u=c.useCallback(async(k,N)=>{if(e.updatePlugin){const w=await e.updatePlugin(k,{enabled:N});s(j=>j.map(C=>C.id===w.id?w:C));return}s(w=>w.map(j=>j.id===k?{...j,enabled:N}:j))},[e]),m=c.useCallback(async k=>{if(!e.importPlugin)throw new Error("Plugin import is not available.");const N=await e.importPlugin(k);s(w=>[...w.filter(C=>C.id!==N.id),N])},[e]),f=c.useCallback(async k=>{if(!e.deletePlugin)throw new Error("Plugin uninstall is not available.");const N=await e.deletePlugin(k);s(w=>w.filter(j=>j.id!==N.id))},[e]),p=c.useMemo(()=>{const k=new Set(a.filter(N=>N.enabled).map(N=>N.id));return r.filter(N=>k.has(N.manifest.id))},[r,a]),g=c.useCallback(k=>{var w;const N=p.find(j=>j.renderArtifact&&j.manifest.capabilities.artifactTypes.some(C=>C.type===k.artifact.type));return((w=N==null?void 0:N.renderArtifact)==null?void 0:w.call(N,k))??null},[p]),b=c.useCallback(k=>{for(const N of p)for(const w of N.inlineCodeRenderers??[]){if(!w.languages.includes(k.language.trim().toLowerCase()))continue;const j=w.render(k);if(j)return j}return null},[p]),v=c.useCallback(k=>p.some(N=>!!N.renderArtifact&&N.manifest.capabilities.artifactTypes.some(w=>w.type===k.type)),[p]),x=c.useCallback(()=>p.flatMap(k=>k.threadPanels??[]),[p]),y=c.useMemo(()=>({plugins:a,loading:o,error:i,refresh:h,importPluginManifest:m,setPluginEnabled:u,uninstallPlugin:f,renderArtifact:g,renderInlineCode:b,hasRendererForArtifact:v,getThreadPanels:x}),[i,x,v,m,o,a,h,g,b,u,f]);return t.jsx(ta.Provider,{value:y,children:n})}export{zm as A,tx as C,rx as E,Xm as L,ax as P,nx as T,ra as a,Bg as b,pl as c,qm as d,Km as e,Zt as f,Rm as t,Zo as u};
|