remote-codex 0.11.41 → 0.11.42

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.
@@ -1,16 +1,16 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/core-DODVy7wn.js","assets/markdown-vendor-RZk8L7-L.js","assets/react-vendor-Dfg_6BLf.js","assets/html-pp8916En.js","assets/javascript-wDzz0qaB.js","assets/css-CLj8gQPS.js","assets/terminal-vendor-C5bTa-Ka.js","assets/terminal-vendor-Beg8tuEN.css"])))=>i.map(i=>d[i]);
2
- import{l as _,R as Yi,I as Zi,C as Ji,S as Gs,H as Qi,T as ed,a as td,b as rd,c as nd,d as ad,e as sd,D as od,P as ld,O as id,f as dd,g as cd,h as hd,i as ud,j as md,k as pd,m as fd,n as gd,A as xd,o as bd,p as vd}from"./ui-vendor-CuR8GHb0.js";import{r as c,R as kd,j as t,b as Yr}from"./react-vendor-Dfg_6BLf.js";import{u as wd,a as yd,H as Na,P as Gt,b as jd,M as Fs,R as Nd,i as Cd,C as Sd,B as Td,c as Ca,g as Hs}from"./graph-vendor-DVQUpZ8C.js";import"./terminal-vendor-C5bTa-Ka.js";import{M as Ed,r as Ld,a as Id,b as zd}from"./markdown-vendor-RZk8L7-L.js";const Pd="modulepreload",Rd=function(e){return"/"+e},Sa={},Xe=function(r,n,a){let o=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"));o=l(n.map(h=>{if(h=Rd(h),h in Sa)return;Sa[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":Pd,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 s(l){const i=new Event("vite:preloadError",{cancelable:!0});if(i.payload=l,window.dispatchEvent(i),!i.defaultPrevented)throw l}return o.then(l=>{for(const i of l||[])i.status==="rejected"&&s(i.reason);return r().catch(s)})};function Os(e){var r,n,a="";if(typeof e=="string"||typeof e=="number")a+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(r=0;r<o;r++)e[r]&&(n=Os(e[r]))&&(a&&(a+=" "),a+=n)}else for(n in e)e[n]&&(a&&(a+=" "),a+=n);return a}function Ws(){for(var e,r,n=0,a="",o=arguments.length;n<o;n++)(e=arguments[n])&&(r=Os(e))&&(a&&(a+=" "),a+=r);return a}const Md=(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},Ad=(e,r)=>({classGroupId:e,validator:r}),Us=(e=new Map,r=null,n)=>({nextPart:e,validators:r,classGroupId:n}),Ur="-",Ta=[],_d="arbitrary..",$d=e=>{const r=Bd(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:a}=e;return{getClassGroupId:l=>{if(l.startsWith("[")&&l.endsWith("]"))return Dd(l);const i=l.split(Ur),d=i[0]===""&&i.length>1?1:0;return Vs(i,d,r)},getConflictingClassGroupIds:(l,i)=>{if(i){const d=a[l],h=n[l];return d?h?Md(h,d):d:h||Ta}return n[l]||Ta}}},Vs=(e,r,n)=>{if(e.length-r===0)return n.classGroupId;const o=e[r],s=n.nextPart.get(o);if(s){const h=Vs(e,r+1,s);if(h)return h}const l=n.validators;if(l===null)return;const i=r===0?e.join(Ur):e.slice(r).join(Ur),d=l.length;for(let h=0;h<d;h++){const u=l[h];if(u.validator(i))return u.classGroupId}},Dd=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?_d+a:void 0})(),Bd=e=>{const{theme:r,classGroups:n}=e;return Gd(n,r)},Gd=(e,r)=>{const n=Us();for(const a in e){const o=e[a];Qn(o,n,a,r)}return n},Qn=(e,r,n,a)=>{const o=e.length;for(let s=0;s<o;s++){const l=e[s];Fd(l,r,n,a)}},Fd=(e,r,n,a)=>{if(typeof e=="string"){Hd(e,r,n);return}if(typeof e=="function"){Od(e,r,n,a);return}Wd(e,r,n,a)},Hd=(e,r,n)=>{const a=e===""?r:qs(r,e);a.classGroupId=n},Od=(e,r,n,a)=>{if(Ud(e)){Qn(e(a),r,n,a);return}r.validators===null&&(r.validators=[]),r.validators.push(Ad(n,e))},Wd=(e,r,n,a)=>{const o=Object.entries(e),s=o.length;for(let l=0;l<s;l++){const[i,d]=o[l];Qn(d,qs(r,i),n,a)}},qs=(e,r)=>{let n=e;const a=r.split(Ur),o=a.length;for(let s=0;s<o;s++){const l=a[s];let i=n.nextPart.get(l);i||(i=Us(),n.nextPart.set(l,i)),n=i}return n},Ud=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Vd=e=>{if(e<1)return{get:()=>{},set:()=>{}};let r=0,n=Object.create(null),a=Object.create(null);const o=(s,l)=>{n[s]=l,r++,r>e&&(r=0,a=n,n=Object.create(null))};return{get(s){let l=n[s];if(l!==void 0)return l;if((l=a[s])!==void 0)return o(s,l),l},set(s,l){s in n?n[s]=l:o(s,l)}}},Pn="!",Ea=":",qd=[],La=(e,r,n,a,o)=>({modifiers:e,hasImportantModifier:r,baseClassName:n,maybePostfixModifierPosition:a,isExternal:o}),Kd=e=>{const{prefix:r,experimentalParseClassName:n}=e;let a=o=>{const s=[];let l=0,i=0,d=0,h;const u=o.length;for(let b=0;b<u;b++){const w=o[b];if(l===0&&i===0){if(w===Ea){s.push(o.slice(d,b)),d=b+1;continue}if(w==="/"){h=b;continue}}w==="["?l++:w==="]"?l--:w==="("?i++:w===")"&&i--}const m=s.length===0?o:o.slice(d);let f=m,p=!1;m.endsWith(Pn)?(f=m.slice(0,-1),p=!0):m.startsWith(Pn)&&(f=m.slice(1),p=!0);const g=h&&h>d?h-d:void 0;return La(s,p,f,g)};if(r){const o=r+Ea,s=a;a=l=>l.startsWith(o)?s(l.slice(o.length)):La(qd,!1,l,void 0,!0)}if(n){const o=a;a=s=>n({className:s,parseClassName:o})}return a},Xd=e=>{const r=new Map;return e.orderSensitiveModifiers.forEach((n,a)=>{r.set(n,1e6+a)}),n=>{const a=[];let o=[];for(let s=0;s<n.length;s++){const l=n[s],i=l[0]==="[",d=r.has(l);i||d?(o.length>0&&(o.sort(),a.push(...o),o=[]),a.push(l)):o.push(l)}return o.length>0&&(o.sort(),a.push(...o)),a}},Yd=e=>({cache:Vd(e.cacheSize),parseClassName:Kd(e),sortModifiers:Xd(e),postfixLookupClassGroupIds:Zd(e),...$d(e)}),Zd=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},Jd=/\s+/,Qd=(e,r)=>{const{parseClassName:n,getClassGroupId:a,getConflictingClassGroupIds:o,sortModifiers:s,postfixLookupClassGroupIds:l}=r,i=[],d=e.trim().split(Jd);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:w}=n(m);if(f){h=m+(h.length>0?" "+h:h);continue}let x=!!w,j;if(x){const N=b.substring(0,w);j=a(N);const L=j&&l[j]?a(b):void 0;L&&L!==j&&(j=L,x=!1)}else j=a(b);if(!j){if(!x){h=m+(h.length>0?" "+h:h);continue}if(j=a(b),!j){h=m+(h.length>0?" "+h:h);continue}x=!1}const y=p.length===0?"":p.length===1?p[0]:s(p).join(":"),v=g?y+Pn:y,k=v+j;if(i.indexOf(k)>-1)continue;i.push(k);const S=o(j,x);for(let N=0;N<S.length;++N){const L=S[N];i.push(v+L)}h=m+(h.length>0?" "+h:h)}return h},ec=(...e)=>{let r=0,n,a,o="";for(;r<e.length;)(n=e[r++])&&(a=Ks(n))&&(o&&(o+=" "),o+=a);return o},Ks=e=>{if(typeof e=="string")return e;let r,n="";for(let a=0;a<e.length;a++)e[a]&&(r=Ks(e[a]))&&(n&&(n+=" "),n+=r);return n},tc=(e,...r)=>{let n,a,o,s;const l=d=>{const h=r.reduce((u,m)=>m(u),e());return n=Yd(h),a=n.cache.get,o=n.cache.set,s=i,i(d)},i=d=>{const h=a(d);if(h)return h;const u=Qd(d,n);return o(d,u),u};return s=l,(...d)=>s(ec(...d))},rc=[],Je=e=>{const r=n=>n[e]||rc;return r.isThemeGetter=!0,r},Xs=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Ys=/^\((?:(\w[\w-]*):)?(.+)\)$/i,nc=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,ac=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,sc=/\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$/,oc=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,lc=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ic=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,St=e=>nc.test(e),Ie=e=>!!e&&!Number.isNaN(Number(e)),xt=e=>!!e&&Number.isInteger(Number(e)),gn=e=>e.endsWith("%")&&Ie(e.slice(0,-1)),jt=e=>ac.test(e),Zs=()=>!0,dc=e=>sc.test(e)&&!oc.test(e),ea=()=>!1,cc=e=>lc.test(e),hc=e=>ic.test(e),uc=e=>!he(e)&&!me(e),mc=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)),pc=e=>zt(e,eo,ea),he=e=>Xs.test(e),$t=e=>zt(e,to,dc),Ia=e=>zt(e,yc,Ie),fc=e=>zt(e,no,Zs),gc=e=>zt(e,ro,ea),za=e=>zt(e,Js,ea),xc=e=>zt(e,Qs,hc),zr=e=>zt(e,ao,cc),me=e=>Ys.test(e),ur=e=>Vt(e,to),bc=e=>Vt(e,ro),Pa=e=>Vt(e,Js),vc=e=>Vt(e,eo),kc=e=>Vt(e,Qs),Pr=e=>Vt(e,ao,!0),wc=e=>Vt(e,no,!0),zt=(e,r,n)=>{const a=Xs.exec(e);return a?a[1]?r(a[1]):n(a[2]):!1},Vt=(e,r,n=!1)=>{const a=Ys.exec(e);return a?a[1]?r(a[1]):n:!1},Js=e=>e==="position"||e==="percentage",Qs=e=>e==="image"||e==="url",eo=e=>e==="length"||e==="size"||e==="bg-size",to=e=>e==="length",yc=e=>e==="number",ro=e=>e==="family-name",no=e=>e==="number"||e==="weight",ao=e=>e==="shadow",jc=()=>{const e=Je("color"),r=Je("font"),n=Je("text"),a=Je("font-weight"),o=Je("tracking"),s=Je("leading"),l=Je("breakpoint"),i=Je("container"),d=Je("spacing"),h=Je("radius"),u=Je("shadow"),m=Je("inset-shadow"),f=Je("text-shadow"),p=Je("drop-shadow"),g=Je("blur"),b=Je("perspective"),w=Je("aspect"),x=Je("ease"),j=Je("animate"),y=()=>["auto","avoid","all","avoid-page","page","left","right","column"],v=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],k=()=>[...v(),me,he],S=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto","contain","none"],L=()=>[me,he,d],R=()=>[St,"full","auto",...L()],P=()=>[xt,"none","subgrid",me,he],Q=()=>["auto",{span:["full",xt,me,he]},xt,me,he],D=()=>[xt,"auto",me,he],Z=()=>["auto","min","max","fr",me,he],J=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],z=()=>["start","end","center","stretch","center-safe","end-safe"],te=()=>["auto",...L()],se=()=>[St,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...L()],$=()=>[St,"screen","full","dvw","lvw","svw","min","max","fit",...L()],le=()=>[St,"screen","full","lh","dvh","lvh","svh","min","max","fit",...L()],q=()=>[e,me,he],H=()=>[...v(),Pa,za,{position:[me,he]}],G=()=>["no-repeat",{repeat:["","x","y","space","round"]}],T=()=>["auto","cover","contain",vc,pc,{size:[me,he]}],F=()=>[gn,ur,$t],B=()=>["","none","full",h,me,he],E=()=>["",Ie,ur,$t],C=()=>["solid","dashed","dotted","double"],W=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],U=()=>[Ie,gn,Pa,za],ne=()=>["","none",g,me,he],K=()=>["none",Ie,me,he],ie=()=>["none",Ie,me,he],ee=()=>[Ie,me,he],ve=()=>[St,"full",...L()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[jt],breakpoint:[jt],color:[Zs],container:[jt],"drop-shadow":[jt],ease:["in","out","in-out"],font:[uc],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[jt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[jt],shadow:[jt],spacing:["px",Ie],text:[jt],"text-shadow":[jt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",St,he,me,w]}],container:["container"],"container-type":[{"@container":["","normal","size",me,he]}],"container-named":[mc],columns:[{columns:[Ie,he,me,i]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"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:k()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:N()}],"overscroll-x":[{"overscroll-x":N()}],"overscroll-y":[{"overscroll-y":N()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:R()}],"inset-x":[{"inset-x":R()}],"inset-y":[{"inset-y":R()}],start:[{"inset-s":R(),start:R()}],end:[{"inset-e":R(),end:R()}],"inset-bs":[{"inset-bs":R()}],"inset-be":[{"inset-be":R()}],top:[{top:R()}],right:[{right:R()}],bottom:[{bottom:R()}],left:[{left:R()}],visibility:["visible","invisible","collapse"],z:[{z:[xt,"auto",me,he]}],basis:[{basis:[St,"full","auto",i,...L()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ie,St,"auto","initial","none",he]}],grow:[{grow:["",Ie,me,he]}],shrink:[{shrink:["",Ie,me,he]}],order:[{order:[xt,"first","last","none",me,he]}],"grid-cols":[{"grid-cols":P()}],"col-start-end":[{col:Q()}],"col-start":[{"col-start":D()}],"col-end":[{"col-end":D()}],"grid-rows":[{"grid-rows":P()}],"row-start-end":[{row:Q()}],"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":Z()}],"auto-rows":[{"auto-rows":Z()}],gap:[{gap:L()}],"gap-x":[{"gap-x":L()}],"gap-y":[{"gap-y":L()}],"justify-content":[{justify:[...J(),"normal"]}],"justify-items":[{"justify-items":[...z(),"normal"]}],"justify-self":[{"justify-self":["auto",...z()]}],"align-content":[{content:["normal",...J()]}],"align-items":[{items:[...z(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...z(),{baseline:["","last"]}]}],"place-content":[{"place-content":J()}],"place-items":[{"place-items":[...z(),"baseline"]}],"place-self":[{"place-self":["auto",...z()]}],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:te()}],mx:[{mx:te()}],my:[{my:te()}],ms:[{ms:te()}],me:[{me:te()}],mbs:[{mbs:te()}],mbe:[{mbe:te()}],mt:[{mt:te()}],mr:[{mr:te()}],mb:[{mb:te()}],ml:[{ml:te()}],"space-x":[{"space-x":L()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":L()}],"space-y-reverse":["space-y-reverse"],size:[{size:se()}],"inline-size":[{inline:["auto",...$()]}],"min-inline-size":[{"min-inline":["auto",...$()]}],"max-inline-size":[{"max-inline":["none",...$()]}],"block-size":[{block:["auto",...le()]}],"min-block-size":[{"min-block":["auto",...le()]}],"max-block-size":[{"max-block":["none",...le()]}],w:[{w:[i,"screen",...se()]}],"min-w":[{"min-w":[i,"screen","none",...se()]}],"max-w":[{"max-w":[i,"screen","none","prose",{screen:[l]},...se()]}],h:[{h:["screen","lh",...se()]}],"min-h":[{"min-h":["screen","lh","none",...se()]}],"max-h":[{"max-h":["screen","lh",...se()]}],"font-size":[{text:["base",n,ur,$t]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,wc,fc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",gn,he]}],"font-family":[{font:[bc,gc,r]}],"font-features":[{"font-features":[he]}],"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:[o,me,he]}],"line-clamp":[{"line-clamp":[Ie,"none",me,Ia]}],leading:[{leading:[s,...L()]}],"list-image":[{"list-image":["none",me,he]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",me,he]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:q()}],"text-color":[{text:q()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...C(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ie,"from-font","auto",me,$t]}],"text-decoration-color":[{decoration:q()}],"underline-offset":[{"underline-offset":[Ie,"auto",me,he]}],"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:[xt,me,he]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",me,he]}],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",me,he]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:H()}],"bg-repeat":[{bg:G()}],"bg-size":[{bg:T()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},xt,me,he],radial:["",me,he],conic:[xt,me,he]},kc,xc]}],"bg-color":[{bg:q()}],"gradient-from-pos":[{from:F()}],"gradient-via-pos":[{via:F()}],"gradient-to-pos":[{to:F()}],"gradient-from":[{from:q()}],"gradient-via":[{via:q()}],"gradient-to":[{to:q()}],rounded:[{rounded:B()}],"rounded-s":[{"rounded-s":B()}],"rounded-e":[{"rounded-e":B()}],"rounded-t":[{"rounded-t":B()}],"rounded-r":[{"rounded-r":B()}],"rounded-b":[{"rounded-b":B()}],"rounded-l":[{"rounded-l":B()}],"rounded-ss":[{"rounded-ss":B()}],"rounded-se":[{"rounded-se":B()}],"rounded-ee":[{"rounded-ee":B()}],"rounded-es":[{"rounded-es":B()}],"rounded-tl":[{"rounded-tl":B()}],"rounded-tr":[{"rounded-tr":B()}],"rounded-br":[{"rounded-br":B()}],"rounded-bl":[{"rounded-bl":B()}],"border-w":[{border:E()}],"border-w-x":[{"border-x":E()}],"border-w-y":[{"border-y":E()}],"border-w-s":[{"border-s":E()}],"border-w-e":[{"border-e":E()}],"border-w-bs":[{"border-bs":E()}],"border-w-be":[{"border-be":E()}],"border-w-t":[{"border-t":E()}],"border-w-r":[{"border-r":E()}],"border-w-b":[{"border-b":E()}],"border-w-l":[{"border-l":E()}],"divide-x":[{"divide-x":E()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":E()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...C(),"hidden","none"]}],"divide-style":[{divide:[...C(),"hidden","none"]}],"border-color":[{border:q()}],"border-color-x":[{"border-x":q()}],"border-color-y":[{"border-y":q()}],"border-color-s":[{"border-s":q()}],"border-color-e":[{"border-e":q()}],"border-color-bs":[{"border-bs":q()}],"border-color-be":[{"border-be":q()}],"border-color-t":[{"border-t":q()}],"border-color-r":[{"border-r":q()}],"border-color-b":[{"border-b":q()}],"border-color-l":[{"border-l":q()}],"divide-color":[{divide:q()}],"outline-style":[{outline:[...C(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ie,me,he]}],"outline-w":[{outline:["",Ie,ur,$t]}],"outline-color":[{outline:q()}],shadow:[{shadow:["","none",u,Pr,zr]}],"shadow-color":[{shadow:q()}],"inset-shadow":[{"inset-shadow":["none",m,Pr,zr]}],"inset-shadow-color":[{"inset-shadow":q()}],"ring-w":[{ring:E()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:q()}],"ring-offset-w":[{"ring-offset":[Ie,$t]}],"ring-offset-color":[{"ring-offset":q()}],"inset-ring-w":[{"inset-ring":E()}],"inset-ring-color":[{"inset-ring":q()}],"text-shadow":[{"text-shadow":["none",f,Pr,zr]}],"text-shadow-color":[{"text-shadow":q()}],opacity:[{opacity:[Ie,me,he]}],"mix-blend":[{"mix-blend":[...W(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":W()}],"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":[Ie]}],"mask-image-linear-from-pos":[{"mask-linear-from":U()}],"mask-image-linear-to-pos":[{"mask-linear-to":U()}],"mask-image-linear-from-color":[{"mask-linear-from":q()}],"mask-image-linear-to-color":[{"mask-linear-to":q()}],"mask-image-t-from-pos":[{"mask-t-from":U()}],"mask-image-t-to-pos":[{"mask-t-to":U()}],"mask-image-t-from-color":[{"mask-t-from":q()}],"mask-image-t-to-color":[{"mask-t-to":q()}],"mask-image-r-from-pos":[{"mask-r-from":U()}],"mask-image-r-to-pos":[{"mask-r-to":U()}],"mask-image-r-from-color":[{"mask-r-from":q()}],"mask-image-r-to-color":[{"mask-r-to":q()}],"mask-image-b-from-pos":[{"mask-b-from":U()}],"mask-image-b-to-pos":[{"mask-b-to":U()}],"mask-image-b-from-color":[{"mask-b-from":q()}],"mask-image-b-to-color":[{"mask-b-to":q()}],"mask-image-l-from-pos":[{"mask-l-from":U()}],"mask-image-l-to-pos":[{"mask-l-to":U()}],"mask-image-l-from-color":[{"mask-l-from":q()}],"mask-image-l-to-color":[{"mask-l-to":q()}],"mask-image-x-from-pos":[{"mask-x-from":U()}],"mask-image-x-to-pos":[{"mask-x-to":U()}],"mask-image-x-from-color":[{"mask-x-from":q()}],"mask-image-x-to-color":[{"mask-x-to":q()}],"mask-image-y-from-pos":[{"mask-y-from":U()}],"mask-image-y-to-pos":[{"mask-y-to":U()}],"mask-image-y-from-color":[{"mask-y-from":q()}],"mask-image-y-to-color":[{"mask-y-to":q()}],"mask-image-radial":[{"mask-radial":[me,he]}],"mask-image-radial-from-pos":[{"mask-radial-from":U()}],"mask-image-radial-to-pos":[{"mask-radial-to":U()}],"mask-image-radial-from-color":[{"mask-radial-from":q()}],"mask-image-radial-to-color":[{"mask-radial-to":q()}],"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":v()}],"mask-image-conic-pos":[{"mask-conic":[Ie]}],"mask-image-conic-from-pos":[{"mask-conic-from":U()}],"mask-image-conic-to-pos":[{"mask-conic-to":U()}],"mask-image-conic-from-color":[{"mask-conic-from":q()}],"mask-image-conic-to-color":[{"mask-conic-to":q()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:H()}],"mask-repeat":[{mask:G()}],"mask-size":[{mask:T()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",me,he]}],filter:[{filter:["","none",me,he]}],blur:[{blur:ne()}],brightness:[{brightness:[Ie,me,he]}],contrast:[{contrast:[Ie,me,he]}],"drop-shadow":[{"drop-shadow":["","none",p,Pr,zr]}],"drop-shadow-color":[{"drop-shadow":q()}],grayscale:[{grayscale:["",Ie,me,he]}],"hue-rotate":[{"hue-rotate":[Ie,me,he]}],invert:[{invert:["",Ie,me,he]}],saturate:[{saturate:[Ie,me,he]}],sepia:[{sepia:["",Ie,me,he]}],"backdrop-filter":[{"backdrop-filter":["","none",me,he]}],"backdrop-blur":[{"backdrop-blur":ne()}],"backdrop-brightness":[{"backdrop-brightness":[Ie,me,he]}],"backdrop-contrast":[{"backdrop-contrast":[Ie,me,he]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ie,me,he]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ie,me,he]}],"backdrop-invert":[{"backdrop-invert":["",Ie,me,he]}],"backdrop-opacity":[{"backdrop-opacity":[Ie,me,he]}],"backdrop-saturate":[{"backdrop-saturate":[Ie,me,he]}],"backdrop-sepia":[{"backdrop-sepia":["",Ie,me,he]}],"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",me,he]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ie,"initial",me,he]}],ease:[{ease:["linear","initial",x,me,he]}],delay:[{delay:[Ie,me,he]}],animate:[{animate:["none",j,me,he]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,me,he]}],"perspective-origin":[{"perspective-origin":k()}],rotate:[{rotate:K()}],"rotate-x":[{"rotate-x":K()}],"rotate-y":[{"rotate-y":K()}],"rotate-z":[{"rotate-z":K()}],scale:[{scale:ie()}],"scale-x":[{"scale-x":ie()}],"scale-y":[{"scale-y":ie()}],"scale-z":[{"scale-z":ie()}],"scale-3d":["scale-3d"],skew:[{skew:ee()}],"skew-x":[{"skew-x":ee()}],"skew-y":[{"skew-y":ee()}],transform:[{transform:[me,he,"","none","gpu","cpu"]}],"transform-origin":[{origin:k()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ve()}],"translate-x":[{"translate-x":ve()}],"translate-y":[{"translate-y":ve()}],"translate-z":[{"translate-z":ve()}],"translate-none":["translate-none"],zoom:[{zoom:[xt,me,he]}],accent:[{accent:q()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:q()}],"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",me,he]}],"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":q()}],"scrollbar-track-color":[{"scrollbar-track":q()}],"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",me,he]}],fill:[{fill:["none",...q()]}],"stroke-w":[{stroke:[Ie,ur,$t,Ia]}],stroke:[{stroke:["none",...q()]}],"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"]}},Nc=tc(jc),Ra=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Ma=Ws,Cr=(e,r)=>n=>{var a;if((r==null?void 0:r.variants)==null)return Ma(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:s}=r,l=Object.keys(o).map(h=>{const u=n==null?void 0:n[h],m=s==null?void 0:s[h];if(u===null)return null;const f=Ra(u)||Ra(m);return o[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,w]=g;return Array.isArray(w)?w.includes({...s,...i}[b]):{...s,...i}[b]===w})?[...h,m,f]:h},[]);return Ma(e,l,d,n==null?void 0:n.class,n==null?void 0:n.className)},Zr=c.createContext(null);Zr.displayName="PanelGroupContext";const qe={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"},ta=10,Ot=c.useLayoutEffect,Aa=kd.useId,Cc=typeof Aa=="function"?Aa:()=>null;let Sc=0;function ra(e=null){const r=Cc(),n=c.useRef(e||r||null);return n.current===null&&(n.current=""+Sc++),e??n.current}function so({children:e,className:r="",collapsedSize:n,collapsible:a,defaultSize:o,forwardedRef:s,id:l,maxSize:i,minSize:d,onCollapse:h,onExpand:u,onResize:m,order:f,style:p,tagName:g="div",...b}){const w=c.useContext(Zr);if(w===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:x,expandPanel:j,getPanelSize:y,getPanelStyle:v,groupId:k,isPanelCollapsed:S,reevaluatePanelConstraints:N,registerPanel:L,resizePanel:R,unregisterPanel:P}=w,Q=ra(l),D=c.useRef({callbacks:{onCollapse:h,onExpand:u,onResize:m},constraints:{collapsedSize:n,collapsible:a,defaultSize:o,maxSize:i,minSize:d},id:Q,idIsFromProps:l!==void 0,order:f});c.useRef({didLogMissingDefaultSizeWarning:!1}),Ot(()=>{const{callbacks:J,constraints:z}=D.current,te={...z};D.current.id=Q,D.current.idIsFromProps=l!==void 0,D.current.order=f,J.onCollapse=h,J.onExpand=u,J.onResize=m,z.collapsedSize=n,z.collapsible=a,z.defaultSize=o,z.maxSize=i,z.minSize=d,(te.collapsedSize!==z.collapsedSize||te.collapsible!==z.collapsible||te.maxSize!==z.maxSize||te.minSize!==z.minSize)&&N(D.current,te)}),Ot(()=>{const J=D.current;return L(J),()=>{P(J)}},[f,Q,L,P]),c.useImperativeHandle(s,()=>({collapse:()=>{x(D.current)},expand:J=>{j(D.current,J)},getId(){return Q},getSize(){return y(D.current)},isCollapsed(){return S(D.current)},isExpanded(){return!S(D.current)},resize:J=>{R(D.current,J)}}),[x,j,y,S,Q,R]);const Z=v(D.current,o);return c.createElement(g,{...b,children:e,className:r,id:Q,style:{...Z,...p},[qe.groupId]:k,[qe.panel]:"",[qe.panelCollapsible]:a||void 0,[qe.panelId]:Q,[qe.panelSize]:parseFloat(""+Z.flexGrow).toFixed(1)})}const oo=c.forwardRef((e,r)=>c.createElement(so,{...e,forwardedRef:r}));so.displayName="Panel";oo.displayName="forwardRef(Panel)";let Rn=null,Br=-1,Et=null;function Tc(e,r,n){const a=(r&uo)!==0,o=(r&mo)!==0,s=(r&po)!==0,l=(r&fo)!==0;if(r){if(a)return s?"se-resize":l?"ne-resize":"e-resize";if(o)return s?"sw-resize":l?"nw-resize":"w-resize";if(s)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 Ec(){Et!==null&&(document.head.removeChild(Et),Rn=null,Et=null,Br=-1)}function xn(e,r,n){var a,o;const s=Tc(e,r);if(Rn!==s){if(Rn=s,Et===null&&(Et=document.createElement("style"),document.head.appendChild(Et)),Br>=0){var l;(l=Et.sheet)===null||l===void 0||l.removeRule(Br)}Br=(a=(o=Et.sheet)===null||o===void 0?void 0:o.insertRule(`*{cursor: ${s} !important;}`))!==null&&a!==void 0?a:-1}}function lo(e){return e.type==="keydown"}function io(e){return e.type.startsWith("pointer")}function co(e){return e.type.startsWith("mouse")}function Jr(e){if(io(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(co(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function Lc(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function Ic(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 zc(e,r){if(e===r)throw new Error("Cannot compare node with itself");const n={a:Da(e),b:Da(r)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),r=n.b.pop(),a=e;Le(a,"Stacking order can only be calculated for elements with a common ancestor");const o={a:$a(_a(n.a)),b:$a(_a(n.b))};if(o.a===o.b){const s=a.childNodes,l={a:n.a.at(-1),b:n.b.at(-1)};let i=s.length;for(;i--;){const d=s[i];if(d===l.a)return 1;if(d===l.b)return-1}}return Math.sign(o.a-o.b)}const Pc=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Rc(e){var r;const n=getComputedStyle((r=ho(e))!==null&&r!==void 0?r:e).display;return n==="flex"||n==="inline-flex"}function Mc(e){const r=getComputedStyle(e);return!!(r.position==="fixed"||r.zIndex!=="auto"&&(r.position!=="static"||Rc(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"||Pc.test(r.willChange)||r.webkitOverflowScrolling==="touch")}function _a(e){let r=e.length;for(;r--;){const n=e[r];if(Le(n,"Missing node"),Mc(n))return n}return null}function $a(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Da(e){const r=[];for(;e;)r.push(e),e=ho(e);return r}function ho(e){const{parentNode:r}=e;return r&&r instanceof ShadowRoot?r.host:r}const uo=1,mo=2,po=4,fo=8,Ac=Lc()==="coarse";let pt=[],or=!1,Lt=new Map,Qr=new Map;const yr=new Set;function _c(e,r,n,a,o){var s;const{ownerDocument:l}=r,i={direction:n,element:r,hitAreaMargins:a,setResizeHandlerState:o},d=(s=Lt.get(l))!==null&&s!==void 0?s:0;return Lt.set(l,d+1),yr.add(i),Vr(),function(){var u;Qr.delete(e),yr.delete(i);const m=(u=Lt.get(l))!==null&&u!==void 0?u:1;if(Lt.set(l,m-1),Vr(),m===1&&Lt.delete(l),pt.includes(i)){const f=pt.indexOf(i);f>=0&&pt.splice(f,1),en(),o("up",!0,null)}}}function $c(e){const{target:r}=e,{x:n,y:a}=Jr(e);or=!0,na({target:r,x:n,y:a}),Vr(),pt.length>0&&(qr("down",e),en(),e.preventDefault(),go(r)||e.stopImmediatePropagation())}function bn(e){const{x:r,y:n}=Jr(e);if(or&&e.type!=="pointerleave"&&e.buttons===0&&(or=!1,qr("up",e)),!or){const{target:a}=e;na({target:a,x:r,y:n})}qr("move",e),en(),pt.length>0&&e.preventDefault()}function vn(e){const{target:r}=e,{x:n,y:a}=Jr(e);Qr.clear(),or=!1,pt.length>0&&(e.preventDefault(),go(r)||e.stopImmediatePropagation()),qr("up",e),na({target:r,x:n,y:a}),en(),Vr()}function go(e){let r=e;for(;r;){if(r.hasAttribute(qe.resizeHandle))return!0;r=r.parentElement}return!1}function na({target:e,x:r,y:n}){pt.splice(0);let a=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(a=e),yr.forEach(o=>{const{element:s,hitAreaMargins:l}=o,i=s.getBoundingClientRect(),{bottom:d,left:h,right:u,top:m}=i,f=Ac?l.coarse:l.fine;if(r>=h-f&&r<=u+f&&n>=m-f&&n<=d+f){if(a!==null&&document.contains(a)&&s!==a&&!s.contains(a)&&!a.contains(s)&&zc(a,s)>0){let g=a,b=!1;for(;g&&!g.contains(s);){if(Ic(g.getBoundingClientRect(),i)){b=!0;break}g=g.parentElement}if(b)return}pt.push(o)}})}function kn(e,r){Qr.set(e,r)}function en(){let e=!1,r=!1;pt.forEach(a=>{const{direction:o}=a;o==="horizontal"?e=!0:r=!0});let n=0;Qr.forEach(a=>{n|=a}),e&&r?xn("intersection",n):e?xn("horizontal",n):r?xn("vertical",n):Ec()}let wn;function Vr(){var e;(e=wn)===null||e===void 0||e.abort(),wn=new AbortController;const r={capture:!0,signal:wn.signal};yr.size&&(or?(pt.length>0&&Lt.forEach((n,a)=>{const{body:o}=a;n>0&&(o.addEventListener("contextmenu",vn,r),o.addEventListener("pointerleave",bn,r),o.addEventListener("pointermove",bn,r))}),Lt.forEach((n,a)=>{const{body:o}=a;o.addEventListener("pointerup",vn,r),o.addEventListener("pointercancel",vn,r)})):Lt.forEach((n,a)=>{const{body:o}=a;n>0&&(o.addEventListener("pointerdown",$c,r),o.addEventListener("pointermove",bn,r))}))}function qr(e,r){yr.forEach(n=>{const{setResizeHandlerState:a}=n,o=pt.includes(n);a(e,o,r)})}function Dc(){const[e,r]=c.useState(0);return c.useCallback(()=>r(n=>n+1),[])}function Le(e,r){if(!e)throw console.error(r),Error(r)}function Ut(e,r,n=ta){return e.toFixed(n)===r.toFixed(n)?0:e>r?1:-1}function Nt(e,r,n=ta){return Ut(e,r,n)===0}function ht(e,r,n){return Ut(e,r,n)===0}function Bc(e,r,n){if(e.length!==r.length)return!1;for(let a=0;a<e.length;a++){const o=e[a],s=r[a];if(!ht(o,s,n))return!1}return!0}function ar({panelConstraints:e,panelIndex:r,size:n}){const a=e[r];Le(a!=null,`Panel constraints not found for index ${r}`);let{collapsedSize:o=0,collapsible:s,maxSize:l=100,minSize:i=0}=a;if(Ut(n,i)<0)if(s){const d=(o+i)/2;Ut(n,d)<0?n=o:n=i}else n=i;return n=Math.min(l,n),n=parseFloat(n.toFixed(ta)),n}function xr({delta:e,initialLayout:r,panelConstraints:n,pivotIndices:a,prevLayout:o,trigger:s}){if(ht(e,0))return r;const l=[...r],[i,d]=a;Le(i!=null,"Invalid first pivot index"),Le(d!=null,"Invalid second pivot index");let h=0;if(s==="keyboard"){{const m=e<0?d:i,f=n[m];Le(f,`Panel constraints not found for index ${m}`);const{collapsedSize:p=0,collapsible:g,minSize:b=0}=f;if(g){const w=r[m];if(Le(w!=null,`Previous layout not found for panel index ${m}`),ht(w,p)){const x=b-w;Ut(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}{const m=e<0?i:d,f=n[m];Le(f,`No panel constraints found for index ${m}`);const{collapsedSize:p=0,collapsible:g,minSize:b=0}=f;if(g){const w=r[m];if(Le(w!=null,`Previous layout not found for panel index ${m}`),ht(w,b)){const x=w-p;Ut(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];Le(b!=null,`Previous layout not found for panel index ${f}`);const x=ar({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];Le(g!=null,`Previous layout not found for panel index ${f}`);const b=g-p,w=ar({panelConstraints:n,panelIndex:f,size:b});if(!ht(g,w)&&(h+=g-w,l[f]=w,h.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?f--:f++}}if(Bc(o,l))return o;{const m=e<0?d:i,f=r[m];Le(f!=null,`Previous layout not found for panel index ${m}`);const p=f+h,g=ar({panelConstraints:n,panelIndex:m,size:p});if(l[m]=g,!ht(g,p)){let b=p-g,x=e<0?d:i;for(;x>=0&&x<n.length;){const j=l[x];Le(j!=null,`Previous layout not found for panel index ${x}`);const y=j+b,v=ar({panelConstraints:n,panelIndex:x,size:y});if(ht(j,v)||(b-=v-j,l[x]=v),ht(b,0))break;e>0?x--:x++}}}const u=l.reduce((m,f)=>f+m,0);return ht(u,100)?l:o}function Gc({layout:e,panelsArray:r,pivotIndices:n}){let a=0,o=100,s=0,l=0;const i=n[0];Le(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,o=g):(s+=b,l+=g)});const d=Math.min(o,100-s),h=Math.max(a,100-l),u=e[i];return{valueMax:d,valueMin:h,valueNow:u}}function jr(e,r=document){return Array.from(r.querySelectorAll(`[${qe.resizeHandleId}][data-panel-group-id="${e}"]`))}function xo(e,r,n=document){const o=jr(e,n).findIndex(s=>s.getAttribute(qe.resizeHandleId)===r);return o??null}function bo(e,r,n){const a=xo(e,r,n);return a!=null?[a,a+1]:[-1,-1]}function Fc(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function vo(e,r=document){if(Fc(r)&&r.dataset.panelGroupId==e)return r;const n=r.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function tn(e,r=document){const n=r.querySelector(`[${qe.resizeHandleId}="${e}"]`);return n||null}function Hc(e,r,n,a=document){var o,s,l,i;const d=tn(r,a),h=jr(e,a),u=d?h.indexOf(d):-1,m=(o=(s=n[u])===null||s===void 0?void 0:s.id)!==null&&o!==void 0?o: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 Oc({committedValuesRef:e,eagerValuesRef:r,groupId:n,layout:a,panelDataArray:o,panelGroupElement:s,setLayout:l}){c.useRef({didWarnAboutMissingResizeHandle:!1}),Ot(()=>{if(!s)return;const i=jr(n,s);for(let d=0;d<o.length-1;d++){const{valueMax:h,valueMin:u,valueNow:m}=Gc({layout:a,panelsArray:o,pivotIndices:[d,d+1]}),f=i[d];if(f!=null){const p=o[d];Le(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,o,s]),c.useEffect(()=>{if(!s)return;const i=r.current;Le(i,"Eager values not found");const{panelDataArray:d}=i,h=vo(n,s);Le(h!=null,`No group found for id "${n}"`);const u=jr(n,s);Le(u,`No resize handles found for group id "${n}"`);const m=u.map(f=>{const p=f.getAttribute(qe.resizeHandleId);Le(p,"Resize handle element has no handle id attribute");const[g,b]=Hc(n,p,d,s);if(g==null||b==null)return()=>{};const w=x=>{if(!x.defaultPrevented)switch(x.key){case"Enter":{x.preventDefault();const j=d.findIndex(y=>y.id===g);if(j>=0){const y=d[j];Le(y,`No panel data found for index ${j}`);const v=a[j],{collapsedSize:k=0,collapsible:S,minSize:N=0}=y.constraints;if(v!=null&&S){const L=xr({delta:ht(v,k)?N-k:k-v,initialLayout:a,panelConstraints:d.map(R=>R.constraints),pivotIndices:bo(n,p,s),prevLayout:a,trigger:"keyboard"});a!==L&&l(L)}}break}}};return f.addEventListener("keydown",w),()=>{f.removeEventListener("keydown",w)}});return()=>{m.forEach(f=>f())}},[s,e,r,n,a,o,l])}function Ba(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 ko(e,r){const n=e==="horizontal",{x:a,y:o}=Jr(r);return n?a:o}function Wc(e,r,n,a,o){const s=n==="horizontal",l=tn(r,o);Le(l,`No resize handle element found for id "${r}"`);const i=l.getAttribute(qe.groupId);Le(i,"Resize handle element has no group id attribute");let{initialCursorPosition:d}=a;const h=ko(n,e),u=vo(i,o);Le(u,`No group element found for id "${i}"`);const m=u.getBoundingClientRect(),f=s?m.width:m.height;return(h-d)/f*100}function Uc(e,r,n,a,o,s){if(lo(e)){const l=n==="horizontal";let i=0;e.shiftKey?i=100:o!=null?i=o: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:Wc(e,r,n,a,s)}function Vc({panelDataArray:e}){const r=Array(e.length),n=e.map(s=>s.constraints);let a=0,o=100;for(let s=0;s<e.length;s++){const l=n[s];Le(l,`Panel constraints not found for index ${s}`);const{defaultSize:i}=l;i!=null&&(a++,r[s]=i,o-=i)}for(let s=0;s<e.length;s++){const l=n[s];Le(l,`Panel constraints not found for index ${s}`);const{defaultSize:i}=l;if(i!=null)continue;const d=e.length-a,h=o/d;a++,r[s]=h,o-=h}return r}function Jt(e,r,n){r.forEach((a,o)=>{const s=e[o];Le(s,`Panel data not found for index ${o}`);const{callbacks:l,constraints:i,id:d}=s,{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||Nt(m,h))&&!Nt(a,h)&&p(),f&&(m==null||!Nt(m,h))&&Nt(a,h)&&f())}})}function Rr(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 qc({defaultSize:e,dragState:r,layout:n,panelData:a,panelIndex:o,precision:s=3}){const l=n[o];let i;return l==null?i=e!=null?e.toFixed(s):"1":a.length===1?i="1":i=l.toFixed(s),{flexBasis:0,flexGrow:i,flexShrink:1,overflow:"hidden",pointerEvents:r!==null?"none":void 0}}function Kc(e,r=10){let n=null;return(...o)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...o)},r)}}function Ga(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 wo(e){return`react-resizable-panels:${e}`}function yo(e){return e.map(r=>{const{constraints:n,id:a,idIsFromProps:o,order:s}=r;return o?a:s?`${s}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((r,n)=>r.localeCompare(n)).join(",")}function jo(e,r){try{const n=wo(e),a=r.getItem(n);if(a){const o=JSON.parse(a);if(typeof o=="object"&&o!=null)return o}}catch{}return null}function Xc(e,r,n){var a,o;const s=(a=jo(e,n))!==null&&a!==void 0?a:{},l=yo(r);return(o=s[l])!==null&&o!==void 0?o:null}function Yc(e,r,n,a,o){var s;const l=wo(e),i=yo(r),d=(s=jo(e,o))!==null&&s!==void 0?s:{};d[i]={expandToSizes:Object.fromEntries(n.entries()),layout:a};try{o.setItem(l,JSON.stringify(d))}catch(h){console.error(h)}}function Fa({layout:e,panelConstraints:r}){const n=[...e],a=n.reduce((s,l)=>s+l,0);if(n.length!==r.length)throw Error(`Invalid ${r.length} panel layout: ${n.map(s=>`${s}%`).join(", ")}`);if(!ht(a,100)&&n.length>0)for(let s=0;s<r.length;s++){const l=n[s];Le(l!=null,`No layout data found for index ${s}`);const i=100/a*l;n[s]=i}let o=0;for(let s=0;s<r.length;s++){const l=n[s];Le(l!=null,`No layout data found for index ${s}`);const i=ar({panelConstraints:r,panelIndex:s,size:l});l!=i&&(o+=l-i,n[s]=i)}if(!ht(o,0))for(let s=0;s<r.length;s++){const l=n[s];Le(l!=null,`No layout data found for index ${s}`);const i=l+o,d=ar({panelConstraints:r,panelIndex:s,size:i});if(l!==d&&(o-=d-l,n[s]=d,ht(o,0)))break}return n}const Zc=100,br={getItem:e=>(Ga(br),br.getItem(e)),setItem:(e,r)=>{Ga(br),br.setItem(e,r)}},Ha={};function No({autoSaveId:e=null,children:r,className:n="",direction:a,forwardedRef:o,id:s=null,onLayout:l=null,keyboardResizeBy:i=null,storage:d=br,style:h,tagName:u="div",...m}){const f=ra(s),p=c.useRef(null),[g,b]=c.useState(null),[w,x]=c.useState([]),j=Dc(),y=c.useRef({}),v=c.useRef(new Map),k=c.useRef(0),S=c.useRef({autoSaveId:e,direction:a,dragState:g,id:f,keyboardResizeBy:i,onLayout:l,storage:d}),N=c.useRef({layout:w,panelDataArray:[],panelDataArrayChanged:!1});c.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),c.useImperativeHandle(o,()=>({getId:()=>S.current.id,getLayout:()=>{const{layout:T}=N.current;return T},setLayout:T=>{const{onLayout:F}=S.current,{layout:B,panelDataArray:E}=N.current,C=Fa({layout:T,panelConstraints:E.map(W=>W.constraints)});Ba(B,C)||(x(C),N.current.layout=C,F&&F(C),Jt(E,C,y.current))}}),[]),Ot(()=>{S.current.autoSaveId=e,S.current.direction=a,S.current.dragState=g,S.current.id=f,S.current.onLayout=l,S.current.storage=d}),Oc({committedValuesRef:S,eagerValuesRef:N,groupId:f,layout:w,panelDataArray:N.current.panelDataArray,setLayout:x,panelGroupElement:p.current}),c.useEffect(()=>{const{panelDataArray:T}=N.current;if(e){if(w.length===0||w.length!==T.length)return;let F=Ha[e];F==null&&(F=Kc(Yc,Zc),Ha[e]=F);const B=[...T],E=new Map(v.current);F(e,B,E,w,d)}},[e,w,d]),c.useEffect(()=>{});const L=c.useCallback(T=>{const{onLayout:F}=S.current,{layout:B,panelDataArray:E}=N.current;if(T.constraints.collapsible){const C=E.map(K=>K.constraints),{collapsedSize:W=0,panelSize:U,pivotIndices:ne}=Dt(E,T,B);if(Le(U!=null,`Panel size not found for panel "${T.id}"`),!Nt(U,W)){v.current.set(T.id,U);const ie=er(E,T)===E.length-1?U-W:W-U,ee=xr({delta:ie,initialLayout:B,panelConstraints:C,pivotIndices:ne,prevLayout:B,trigger:"imperative-api"});Rr(B,ee)||(x(ee),N.current.layout=ee,F&&F(ee),Jt(E,ee,y.current))}}},[]),R=c.useCallback((T,F)=>{const{onLayout:B}=S.current,{layout:E,panelDataArray:C}=N.current;if(T.constraints.collapsible){const W=C.map(ve=>ve.constraints),{collapsedSize:U=0,panelSize:ne=0,minSize:K=0,pivotIndices:ie}=Dt(C,T,E),ee=F??K;if(Nt(ne,U)){const ve=v.current.get(T.id),oe=ve!=null&&ve>=ee?ve:ee,Me=er(C,T)===C.length-1?ne-oe:oe-ne,de=xr({delta:Me,initialLayout:E,panelConstraints:W,pivotIndices:ie,prevLayout:E,trigger:"imperative-api"});Rr(E,de)||(x(de),N.current.layout=de,B&&B(de),Jt(C,de,y.current))}}},[]),P=c.useCallback(T=>{const{layout:F,panelDataArray:B}=N.current,{panelSize:E}=Dt(B,T,F);return Le(E!=null,`Panel size not found for panel "${T.id}"`),E},[]),Q=c.useCallback((T,F)=>{const{panelDataArray:B}=N.current,E=er(B,T);return qc({defaultSize:F,dragState:g,layout:w,panelData:B,panelIndex:E})},[g,w]),D=c.useCallback(T=>{const{layout:F,panelDataArray:B}=N.current,{collapsedSize:E=0,collapsible:C,panelSize:W}=Dt(B,T,F);return Le(W!=null,`Panel size not found for panel "${T.id}"`),C===!0&&Nt(W,E)},[]),Z=c.useCallback(T=>{const{layout:F,panelDataArray:B}=N.current,{collapsedSize:E=0,collapsible:C,panelSize:W}=Dt(B,T,F);return Le(W!=null,`Panel size not found for panel "${T.id}"`),!C||Ut(W,E)>0},[]),J=c.useCallback(T=>{const{panelDataArray:F}=N.current;F.push(T),F.sort((B,E)=>{const C=B.order,W=E.order;return C==null&&W==null?0:C==null?-1:W==null?1:C-W}),N.current.panelDataArrayChanged=!0,j()},[j]);Ot(()=>{if(N.current.panelDataArrayChanged){N.current.panelDataArrayChanged=!1;const{autoSaveId:T,onLayout:F,storage:B}=S.current,{layout:E,panelDataArray:C}=N.current;let W=null;if(T){const ne=Xc(T,C,B);ne&&(v.current=new Map(Object.entries(ne.expandToSizes)),W=ne.layout)}W==null&&(W=Vc({panelDataArray:C}));const U=Fa({layout:W,panelConstraints:C.map(ne=>ne.constraints)});Ba(E,U)||(x(U),N.current.layout=U,F&&F(U),Jt(C,U,y.current))}}),Ot(()=>{const T=N.current;return()=>{T.layout=[]}},[]);const z=c.useCallback(T=>{let F=!1;const B=p.current;return B&&window.getComputedStyle(B,null).getPropertyValue("direction")==="rtl"&&(F=!0),function(C){C.preventDefault();const W=p.current;if(!W)return()=>null;const{direction:U,dragState:ne,id:K,keyboardResizeBy:ie,onLayout:ee}=S.current,{layout:ve,panelDataArray:oe}=N.current,{initialLayout:ye}=ne??{},Me=bo(K,T,W);let de=Uc(C,T,U,ne,ie,W);const Ce=U==="horizontal";Ce&&F&&(de=-de);const Ee=oe.map(ke=>ke.constraints),Y=xr({delta:de,initialLayout:ye??ve,panelConstraints:Ee,pivotIndices:Me,prevLayout:ve,trigger:lo(C)?"keyboard":"mouse-or-touch"}),ue=!Rr(ve,Y);(io(C)||co(C))&&k.current!=de&&(k.current=de,!ue&&de!==0?Ce?kn(T,de<0?uo:mo):kn(T,de<0?po:fo):kn(T,0)),ue&&(x(Y),N.current.layout=Y,ee&&ee(Y),Jt(oe,Y,y.current))}},[]),te=c.useCallback((T,F)=>{const{onLayout:B}=S.current,{layout:E,panelDataArray:C}=N.current,W=C.map(ve=>ve.constraints),{panelSize:U,pivotIndices:ne}=Dt(C,T,E);Le(U!=null,`Panel size not found for panel "${T.id}"`);const ie=er(C,T)===C.length-1?U-F:F-U,ee=xr({delta:ie,initialLayout:E,panelConstraints:W,pivotIndices:ne,prevLayout:E,trigger:"imperative-api"});Rr(E,ee)||(x(ee),N.current.layout=ee,B&&B(ee),Jt(C,ee,y.current))},[]),se=c.useCallback((T,F)=>{const{layout:B,panelDataArray:E}=N.current,{collapsedSize:C=0,collapsible:W}=F,{collapsedSize:U=0,collapsible:ne,maxSize:K=100,minSize:ie=0}=T.constraints,{panelSize:ee}=Dt(E,T,B);ee!=null&&(W&&ne&&Nt(ee,C)?Nt(C,U)||te(T,U):ee<ie?te(T,ie):ee>K&&te(T,K))},[te]),$=c.useCallback((T,F)=>{const{direction:B}=S.current,{layout:E}=N.current;if(!p.current)return;const C=tn(T,p.current);Le(C,`Drag handle element not found for id "${T}"`);const W=ko(B,F);b({dragHandleId:T,dragHandleRect:C.getBoundingClientRect(),initialCursorPosition:W,initialLayout:E})},[]),le=c.useCallback(()=>{b(null)},[]),q=c.useCallback(T=>{const{panelDataArray:F}=N.current,B=er(F,T);B>=0&&(F.splice(B,1),delete y.current[T.id],N.current.panelDataArrayChanged=!0,j())},[j]),H=c.useMemo(()=>({collapsePanel:L,direction:a,dragState:g,expandPanel:R,getPanelSize:P,getPanelStyle:Q,groupId:f,isPanelCollapsed:D,isPanelExpanded:Z,reevaluatePanelConstraints:se,registerPanel:J,registerResizeHandle:z,resizePanel:te,startDragging:$,stopDragging:le,unregisterPanel:q,panelGroupElement:p.current}),[L,g,a,R,P,Q,f,D,Z,se,J,z,te,$,le,q]),G={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return c.createElement(Zr.Provider,{value:H},c.createElement(u,{...m,children:r,className:n,id:s,ref:p,style:{...G,...h},[qe.group]:"",[qe.groupDirection]:a,[qe.groupId]:f}))}const Co=c.forwardRef((e,r)=>c.createElement(No,{...e,forwardedRef:r}));No.displayName="PanelGroup";Co.displayName="forwardRef(PanelGroup)";function er(e,r){return e.findIndex(n=>n===r||n.id===r.id)}function Dt(e,r,n){const a=er(e,r),s=a===e.length-1?[a-1,a]:[a,a+1],l=n[a];return{...r.constraints,panelSize:l,pivotIndices:s}}function Jc({disabled:e,handleId:r,resizeHandler:n,panelGroupElement:a}){c.useEffect(()=>{if(e||n==null||a==null)return;const o=tn(r,a);if(o==null)return;const s=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=o.getAttribute(qe.groupId);Le(i,`No group element found for id "${i}"`);const d=jr(i,a),h=xo(i,r,a);Le(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 o.addEventListener("keydown",s),()=>{o.removeEventListener("keydown",s)}},[a,e,r,n])}function So({children:e=null,className:r="",disabled:n=!1,hitAreaMargins:a,id:o,onBlur:s,onClick:l,onDragging:i,onFocus:d,onPointerDown:h,onPointerUp:u,style:m={},tabIndex:f=0,tagName:p="div",...g}){var b,w;const x=c.useRef(null),j=c.useRef({onClick:l,onDragging:i,onPointerDown:h,onPointerUp:u});c.useEffect(()=>{j.current.onClick=l,j.current.onDragging=i,j.current.onPointerDown=h,j.current.onPointerUp=u});const y=c.useContext(Zr);if(y===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:v,groupId:k,registerResizeHandle:S,startDragging:N,stopDragging:L,panelGroupElement:R}=y,P=ra(o),[Q,D]=c.useState("inactive"),[Z,J]=c.useState(!1),[z,te]=c.useState(null),se=c.useRef({state:Q});Ot(()=>{se.current.state=Q}),c.useEffect(()=>{if(n)te(null);else{const H=S(P);te(()=>H)}},[n,P,S]);const $=(b=a==null?void 0:a.coarse)!==null&&b!==void 0?b:15,le=(w=a==null?void 0:a.fine)!==null&&w!==void 0?w:5;c.useEffect(()=>{if(n||z==null)return;const H=x.current;Le(H,"Element ref not attached");let G=!1;return _c(P,H,v,{coarse:$,fine:le},(F,B,E)=>{if(!B){D("inactive");return}switch(F){case"down":{D("drag"),G=!1,Le(E,'Expected event to be defined for "down" action'),N(P,E);const{onDragging:C,onPointerDown:W}=j.current;C==null||C(!0),W==null||W();break}case"move":{const{state:C}=se.current;G=!0,C!=="drag"&&D("hover"),Le(E,'Expected event to be defined for "move" action'),z(E);break}case"up":{D("hover"),L();const{onClick:C,onDragging:W,onPointerUp:U}=j.current;W==null||W(!1),U==null||U(),G||C==null||C();break}}})},[$,v,n,le,S,P,z,N,L]),Jc({disabled:n,handleId:P,resizeHandler:z,panelGroupElement:R});const q={touchAction:"none",userSelect:"none"};return c.createElement(p,{...g,children:e,className:r,id:o,onBlur:()=>{J(!1),s==null||s()},onFocus:()=>{J(!0),d==null||d()},ref:x,role:"separator",style:{...q,...m},tabIndex:f,[qe.groupDirection]:v,[qe.groupId]:k,[qe.resizeHandle]:"",[qe.resizeHandleActive]:Q==="drag"?"pointer":Z?"keyboard":void 0,[qe.resizeHandleEnabled]:!n,[qe.resizeHandleId]:P,[qe.resizeHandleState]:Q})}So.displayName="PanelResizeHandle";var Qc=Object.defineProperty,eh=Object.getOwnPropertyNames,He=(e,r)=>function(){return e&&(r=(0,e[eh(e)[0]])(e=0)),r},th=(e,r)=>{for(var n in r)Qc(e,n,{get:r[n],enumerable:!0})};function at(...e){return Nc(Ws(e))}var Pt=He({"src/components/graph-ui/utils.ts"(){}});function Nr({asChild:e=!1,className:r,size:n,variant:a,...o}){const s=e?Gs:"button";return t.jsx(s,{"data-slot":"button",className:at(To({variant:a,size:n,className:r})),...o})}var To,rn=He({"src/components/graph-ui/Button.tsx"(){Pt(),To=Cr("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 Eo(...e){return e.filter(Boolean).join(" ")}function Mn({className:e,...r}){return t.jsx(Co,{"data-slot":"resizable-panel-group",className:Eo("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...r})}function sr({...e}){return t.jsx(oo,{"data-slot":"resizable-panel",...e})}function An({withHandle:e,className:r,...n}){return t.jsx(So,{"data-slot":"resizable-handle",className:Eo("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(_.GripVerticalIcon,{className:"size-2.5"})}):null})}var Lo=He({"src/components/graph-workspace/GraphResizablePanels.tsx"(){}});function aa(...e){return e.filter(Boolean).join(" ")}function Sr({...e}){return t.jsx(Yi,{"data-slot":"accordion",...e})}function Tr({className:e,...r}){return t.jsx(Zi,{"data-slot":"accordion-item",className:aa("border-b last:border-b-0",e),...r})}function nn({className:e,children:r,...n}){return t.jsx(Qi,{className:"flex",children:t.jsxs(ed,{"data-slot":"accordion-trigger",className:aa("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(_.ChevronDownIcon,{className:"pointer-events-none size-4 shrink-0 translate-y-0.5 text-[var(--theme-fg-muted)] transition-transform duration-200"})]})})}function Er({className:e,children:r,...n}){return t.jsx(Ji,{"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:aa("pb-4 pt-0",e),children:r})})}var Lr=He({"src/components/graph-workspace/GraphAccordion.tsx"(){}});function rh(e){var n;const r=[];for(const a of e.turns)for(const o of a.items)o.kind==="artifact"&&o.artifact&&r.push(o.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 nh(e){return e.trim().replace(/^\/+|\/+$/g,"").replace(/[^\w.-]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function Ir(e){var r;return((r=e.split(".").pop())==null?void 0:r.toLowerCase())||""}function ah(e){return e.split("/").filter(Boolean).at(-1)??e}function tr(e){const r=e.kind==="directory"?"directory":"file",n=(e.children??[]).map(tr);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 Io(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 o=!1;const s=e.children.map(l=>{const i=Io(l,r,n,a);return i!==l&&(o=!0),i});return o?{...e,children:s}:e}function zo(e){if(e.kind==="file")return e;for(const r of e.children){const n=zo(r);if(n)return n}return null}function _n(e,r){if(!e||r===null)return null;if(e.path===r)return e;for(const n of e.children){const a=_n(n,r);if(a)return a}return null}function Po(e){return e.trim().replace(/\\/g,"/").replace(/^\.\/+/,"").replace(/^\/+/,"")}function sh(e){const n=Po(e).split("/").filter(Boolean);n.pop();const a=[];let o="";for(const s of n)o=o?`${o}/${s}`:s,a.push(o);return a}function $n(e,r,n){if(e.path===r)return n;if(e.children.length===0)return e;let a=!1;const o=e.children.map(s=>{const l=$n(s,r,n);return l!==s&&(a=!0),l});return a?{...e,children:o}:e}function Dn(e,r){return!e||!r?!1:e.path===r?!0:e.children.some(n=>Dn(n,r))}function oh(e){if(!e)return null;const r=Ir(e.path);return sa.has(r)?{content:[e.content.endsWith(`
2
+ import{l as $,R as Qi,I as ed,C as td,S as Os,H as rd,T as nd,a as ad,b as sd,c as od,d as ld,e as id,D as dd,P as cd,O as hd,f as ud,g as md,h as pd,i as fd,j as gd,k as xd,m as bd,n as vd,A as kd,o as wd,p as yd}from"./ui-vendor-CuR8GHb0.js";import{r as c,R as jd,j as t,b as Qr}from"./react-vendor-Dfg_6BLf.js";import{u as Nd,a as Cd,H as Sa,P as Ft,b as Sd,M as Ws,R as Td,i as Ed,C as Ld,B as Id,c as Ta,g as Us}from"./graph-vendor-DVQUpZ8C.js";import"./terminal-vendor-C5bTa-Ka.js";import{M as zd,r as Pd,a as Rd,b as Ad}from"./markdown-vendor-RZk8L7-L.js";const Md="modulepreload",$d=function(e){return"/"+e},Ea={},Xe=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=$d(h),h in Ea)return;Ea[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":Md,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 Vs(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=Vs(e[r]))&&(a&&(a+=" "),a+=n)}else for(n in e)e[n]&&(a&&(a+=" "),a+=n);return a}function qs(){for(var e,r,n=0,a="",s=arguments.length;n<s;n++)(e=arguments[n])&&(r=Vs(e))&&(a&&(a+=" "),a+=r);return a}const _d=(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},Dd=(e,r)=>({classGroupId:e,validator:r}),Ks=(e=new Map,r=null,n)=>({nextPart:e,validators:r,classGroupId:n}),qr="-",La=[],Bd="arbitrary..",Gd=e=>{const r=Hd(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:a}=e;return{getClassGroupId:l=>{if(l.startsWith("[")&&l.endsWith("]"))return Fd(l);const i=l.split(qr),d=i[0]===""&&i.length>1?1:0;return Xs(i,d,r)},getConflictingClassGroupIds:(l,i)=>{if(i){const d=a[l],h=n[l];return d?h?_d(h,d):d:h||La}return n[l]||La}}},Xs=(e,r,n)=>{if(e.length-r===0)return n.classGroupId;const s=e[r],o=n.nextPart.get(s);if(o){const h=Xs(e,r+1,o);if(h)return h}const l=n.validators;if(l===null)return;const i=r===0?e.join(qr):e.slice(r).join(qr),d=l.length;for(let h=0;h<d;h++){const u=l[h];if(u.validator(i))return u.classGroupId}},Fd=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?Bd+a:void 0})(),Hd=e=>{const{theme:r,classGroups:n}=e;return Od(n,r)},Od=(e,r)=>{const n=Ks();for(const a in e){const s=e[a];ta(s,n,a,r)}return n},ta=(e,r,n,a)=>{const s=e.length;for(let o=0;o<s;o++){const l=e[o];Wd(l,r,n,a)}},Wd=(e,r,n,a)=>{if(typeof e=="string"){Ud(e,r,n);return}if(typeof e=="function"){Vd(e,r,n,a);return}qd(e,r,n,a)},Ud=(e,r,n)=>{const a=e===""?r:Ys(r,e);a.classGroupId=n},Vd=(e,r,n,a)=>{if(Kd(e)){ta(e(a),r,n,a);return}r.validators===null&&(r.validators=[]),r.validators.push(Dd(n,e))},qd=(e,r,n,a)=>{const s=Object.entries(e),o=s.length;for(let l=0;l<o;l++){const[i,d]=s[l];ta(d,Ys(r,i),n,a)}},Ys=(e,r)=>{let n=e;const a=r.split(qr),s=a.length;for(let o=0;o<s;o++){const l=a[o];let i=n.nextPart.get(l);i||(i=Ks(),n.nextPart.set(l,i)),n=i}return n},Kd=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Xd=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)}}},Mn="!",Ia=":",Yd=[],za=(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 k=0;k<u;k++){const w=s[k];if(l===0&&i===0){if(w===Ia){o.push(s.slice(d,k)),d=k+1;continue}if(w==="/"){h=k;continue}}w==="["?l++:w==="]"?l--:w==="("?i++:w===")"&&i--}const m=o.length===0?s:s.slice(d);let f=m,p=!1;m.endsWith(Mn)?(f=m.slice(0,-1),p=!0):m.startsWith(Mn)&&(f=m.slice(1),p=!0);const g=h&&h>d?h-d:void 0;return za(o,p,f,g)};if(r){const s=r+Ia,o=a;a=l=>l.startsWith(s)?o(l.slice(s.length)):za(Yd,!1,l,void 0,!0)}if(n){const s=a;a=o=>n({className:o,parseClassName:s})}return a},Jd=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}},Qd=e=>({cache:Xd(e.cacheSize),parseClassName:Zd(e),sortModifiers:Jd(e),postfixLookupClassGroupIds:ec(e),...Gd(e)}),ec=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},tc=/\s+/,rc=(e,r)=>{const{parseClassName:n,getClassGroupId:a,getConflictingClassGroupIds:s,sortModifiers:o,postfixLookupClassGroupIds:l}=r,i=[],d=e.trim().split(tc);let h="";for(let u=d.length-1;u>=0;u-=1){const m=d[u],{isExternal:f,modifiers:p,hasImportantModifier:g,baseClassName:k,maybePostfixModifierPosition:w}=n(m);if(f){h=m+(h.length>0?" "+h:h);continue}let x=!!w,j;if(x){const N=k.substring(0,w);j=a(N);const L=j&&l[j]?a(k):void 0;L&&L!==j&&(j=L,x=!1)}else j=a(k);if(!j){if(!x){h=m+(h.length>0?" "+h:h);continue}if(j=a(k),!j){h=m+(h.length>0?" "+h:h);continue}x=!1}const y=p.length===0?"":p.length===1?p[0]:o(p).join(":"),b=g?y+Mn:y,v=b+j;if(i.indexOf(v)>-1)continue;i.push(v);const S=s(j,x);for(let N=0;N<S.length;++N){const L=S[N];i.push(b+L)}h=m+(h.length>0?" "+h:h)}return h},nc=(...e)=>{let r=0,n,a,s="";for(;r<e.length;)(n=e[r++])&&(a=Zs(n))&&(s&&(s+=" "),s+=a);return s},Zs=e=>{if(typeof e=="string")return e;let r,n="";for(let a=0;a<e.length;a++)e[a]&&(r=Zs(e[a]))&&(n&&(n+=" "),n+=r);return n},ac=(e,...r)=>{let n,a,s,o;const l=d=>{const h=r.reduce((u,m)=>m(u),e());return n=Qd(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=rc(d,n);return s(d,u),u};return o=l,(...d)=>o(nc(...d))},sc=[],Je=e=>{const r=n=>n[e]||sc;return r.isThemeGetter=!0,r},Js=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Qs=/^\((?:(\w[\w-]*):)?(.+)\)$/i,oc=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,lc=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,ic=/\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$/,dc=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,cc=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,hc=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,St=e=>oc.test(e),Ie=e=>!!e&&!Number.isNaN(Number(e)),bt=e=>!!e&&Number.isInteger(Number(e)),vn=e=>e.endsWith("%")&&Ie(e.slice(0,-1)),jt=e=>lc.test(e),eo=()=>!0,uc=e=>ic.test(e)&&!dc.test(e),ra=()=>!1,mc=e=>cc.test(e),pc=e=>hc.test(e),fc=e=>!ue(e)&&!pe(e),gc=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)),xc=e=>zt(e,no,ra),ue=e=>Js.test(e),_t=e=>zt(e,ao,uc),Pa=e=>zt(e,Cc,Ie),bc=e=>zt(e,oo,eo),vc=e=>zt(e,so,ra),Ra=e=>zt(e,to,ra),kc=e=>zt(e,ro,pc),Ar=e=>zt(e,lo,mc),pe=e=>Qs.test(e),fr=e=>qt(e,ao),wc=e=>qt(e,so),Aa=e=>qt(e,to),yc=e=>qt(e,no),jc=e=>qt(e,ro),Mr=e=>qt(e,lo,!0),Nc=e=>qt(e,oo,!0),zt=(e,r,n)=>{const a=Js.exec(e);return a?a[1]?r(a[1]):n(a[2]):!1},qt=(e,r,n=!1)=>{const a=Qs.exec(e);return a?a[1]?r(a[1]):n:!1},to=e=>e==="position"||e==="percentage",ro=e=>e==="image"||e==="url",no=e=>e==="length"||e==="size"||e==="bg-size",ao=e=>e==="length",Cc=e=>e==="number",so=e=>e==="family-name",oo=e=>e==="number"||e==="weight",lo=e=>e==="shadow",Sc=()=>{const e=Je("color"),r=Je("font"),n=Je("text"),a=Je("font-weight"),s=Je("tracking"),o=Je("leading"),l=Je("breakpoint"),i=Je("container"),d=Je("spacing"),h=Je("radius"),u=Je("shadow"),m=Je("inset-shadow"),f=Je("text-shadow"),p=Je("drop-shadow"),g=Je("blur"),k=Je("perspective"),w=Je("aspect"),x=Je("ease"),j=Je("animate"),y=()=>["auto","avoid","all","avoid-page","page","left","right","column"],b=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],v=()=>[...b(),pe,ue],S=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto","contain","none"],L=()=>[pe,ue,d],R=()=>[St,"full","auto",...L()],P=()=>[bt,"none","subgrid",pe,ue],Q=()=>["auto",{span:["full",bt,pe,ue]},bt,pe,ue],D=()=>[bt,"auto",pe,ue],Z=()=>["auto","min","max","fr",pe,ue],J=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],z=()=>["start","end","center","stretch","center-safe","end-safe"],te=()=>["auto",...L()],se=()=>[St,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...L()],_=()=>[St,"screen","full","dvw","lvw","svw","min","max","fit",...L()],ie=()=>[St,"screen","full","lh","dvh","lvh","svh","min","max","fit",...L()],q=()=>[e,pe,ue],H=()=>[...b(),Aa,Ra,{position:[pe,ue]}],G=()=>["no-repeat",{repeat:["","x","y","space","round"]}],T=()=>["auto","cover","contain",yc,xc,{size:[pe,ue]}],F=()=>[vn,fr,_t],B=()=>["","none","full",h,pe,ue],E=()=>["",Ie,fr,_t],C=()=>["solid","dashed","dotted","double"],W=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],U=()=>[Ie,vn,Aa,Ra],ae=()=>["","none",g,pe,ue],K=()=>["none",Ie,pe,ue],de=()=>["none",Ie,pe,ue],ee=()=>[Ie,pe,ue],ke=()=>[St,"full",...L()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[jt],breakpoint:[jt],color:[eo],container:[jt],"drop-shadow":[jt],ease:["in","out","in-out"],font:[fc],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[jt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[jt],shadow:[jt],spacing:["px",Ie],text:[jt],"text-shadow":[jt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",St,ue,pe,w]}],container:["container"],"container-type":[{"@container":["","normal","size",pe,ue]}],"container-named":[gc],columns:[{columns:[Ie,ue,pe,i]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"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:v()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:N()}],"overscroll-x":[{"overscroll-x":N()}],"overscroll-y":[{"overscroll-y":N()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:R()}],"inset-x":[{"inset-x":R()}],"inset-y":[{"inset-y":R()}],start:[{"inset-s":R(),start:R()}],end:[{"inset-e":R(),end:R()}],"inset-bs":[{"inset-bs":R()}],"inset-be":[{"inset-be":R()}],top:[{top:R()}],right:[{right:R()}],bottom:[{bottom:R()}],left:[{left:R()}],visibility:["visible","invisible","collapse"],z:[{z:[bt,"auto",pe,ue]}],basis:[{basis:[St,"full","auto",i,...L()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ie,St,"auto","initial","none",ue]}],grow:[{grow:["",Ie,pe,ue]}],shrink:[{shrink:["",Ie,pe,ue]}],order:[{order:[bt,"first","last","none",pe,ue]}],"grid-cols":[{"grid-cols":P()}],"col-start-end":[{col:Q()}],"col-start":[{"col-start":D()}],"col-end":[{"col-end":D()}],"grid-rows":[{"grid-rows":P()}],"row-start-end":[{row:Q()}],"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":Z()}],"auto-rows":[{"auto-rows":Z()}],gap:[{gap:L()}],"gap-x":[{"gap-x":L()}],"gap-y":[{"gap-y":L()}],"justify-content":[{justify:[...J(),"normal"]}],"justify-items":[{"justify-items":[...z(),"normal"]}],"justify-self":[{"justify-self":["auto",...z()]}],"align-content":[{content:["normal",...J()]}],"align-items":[{items:[...z(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...z(),{baseline:["","last"]}]}],"place-content":[{"place-content":J()}],"place-items":[{"place-items":[...z(),"baseline"]}],"place-self":[{"place-self":["auto",...z()]}],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:te()}],mx:[{mx:te()}],my:[{my:te()}],ms:[{ms:te()}],me:[{me:te()}],mbs:[{mbs:te()}],mbe:[{mbe:te()}],mt:[{mt:te()}],mr:[{mr:te()}],mb:[{mb:te()}],ml:[{ml:te()}],"space-x":[{"space-x":L()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":L()}],"space-y-reverse":["space-y-reverse"],size:[{size:se()}],"inline-size":[{inline:["auto",..._()]}],"min-inline-size":[{"min-inline":["auto",..._()]}],"max-inline-size":[{"max-inline":["none",..._()]}],"block-size":[{block:["auto",...ie()]}],"min-block-size":[{"min-block":["auto",...ie()]}],"max-block-size":[{"max-block":["none",...ie()]}],w:[{w:[i,"screen",...se()]}],"min-w":[{"min-w":[i,"screen","none",...se()]}],"max-w":[{"max-w":[i,"screen","none","prose",{screen:[l]},...se()]}],h:[{h:["screen","lh",...se()]}],"min-h":[{"min-h":["screen","lh","none",...se()]}],"max-h":[{"max-h":["screen","lh",...se()]}],"font-size":[{text:["base",n,fr,_t]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,Nc,bc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",vn,ue]}],"font-family":[{font:[wc,vc,r]}],"font-features":[{"font-features":[ue]}],"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,pe,ue]}],"line-clamp":[{"line-clamp":[Ie,"none",pe,Pa]}],leading:[{leading:[o,...L()]}],"list-image":[{"list-image":["none",pe,ue]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",pe,ue]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:q()}],"text-color":[{text:q()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...C(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ie,"from-font","auto",pe,_t]}],"text-decoration-color":[{decoration:q()}],"underline-offset":[{"underline-offset":[Ie,"auto",pe,ue]}],"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:[bt,pe,ue]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",pe,ue]}],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",pe,ue]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:H()}],"bg-repeat":[{bg:G()}],"bg-size":[{bg:T()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},bt,pe,ue],radial:["",pe,ue],conic:[bt,pe,ue]},jc,kc]}],"bg-color":[{bg:q()}],"gradient-from-pos":[{from:F()}],"gradient-via-pos":[{via:F()}],"gradient-to-pos":[{to:F()}],"gradient-from":[{from:q()}],"gradient-via":[{via:q()}],"gradient-to":[{to:q()}],rounded:[{rounded:B()}],"rounded-s":[{"rounded-s":B()}],"rounded-e":[{"rounded-e":B()}],"rounded-t":[{"rounded-t":B()}],"rounded-r":[{"rounded-r":B()}],"rounded-b":[{"rounded-b":B()}],"rounded-l":[{"rounded-l":B()}],"rounded-ss":[{"rounded-ss":B()}],"rounded-se":[{"rounded-se":B()}],"rounded-ee":[{"rounded-ee":B()}],"rounded-es":[{"rounded-es":B()}],"rounded-tl":[{"rounded-tl":B()}],"rounded-tr":[{"rounded-tr":B()}],"rounded-br":[{"rounded-br":B()}],"rounded-bl":[{"rounded-bl":B()}],"border-w":[{border:E()}],"border-w-x":[{"border-x":E()}],"border-w-y":[{"border-y":E()}],"border-w-s":[{"border-s":E()}],"border-w-e":[{"border-e":E()}],"border-w-bs":[{"border-bs":E()}],"border-w-be":[{"border-be":E()}],"border-w-t":[{"border-t":E()}],"border-w-r":[{"border-r":E()}],"border-w-b":[{"border-b":E()}],"border-w-l":[{"border-l":E()}],"divide-x":[{"divide-x":E()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":E()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...C(),"hidden","none"]}],"divide-style":[{divide:[...C(),"hidden","none"]}],"border-color":[{border:q()}],"border-color-x":[{"border-x":q()}],"border-color-y":[{"border-y":q()}],"border-color-s":[{"border-s":q()}],"border-color-e":[{"border-e":q()}],"border-color-bs":[{"border-bs":q()}],"border-color-be":[{"border-be":q()}],"border-color-t":[{"border-t":q()}],"border-color-r":[{"border-r":q()}],"border-color-b":[{"border-b":q()}],"border-color-l":[{"border-l":q()}],"divide-color":[{divide:q()}],"outline-style":[{outline:[...C(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ie,pe,ue]}],"outline-w":[{outline:["",Ie,fr,_t]}],"outline-color":[{outline:q()}],shadow:[{shadow:["","none",u,Mr,Ar]}],"shadow-color":[{shadow:q()}],"inset-shadow":[{"inset-shadow":["none",m,Mr,Ar]}],"inset-shadow-color":[{"inset-shadow":q()}],"ring-w":[{ring:E()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:q()}],"ring-offset-w":[{"ring-offset":[Ie,_t]}],"ring-offset-color":[{"ring-offset":q()}],"inset-ring-w":[{"inset-ring":E()}],"inset-ring-color":[{"inset-ring":q()}],"text-shadow":[{"text-shadow":["none",f,Mr,Ar]}],"text-shadow-color":[{"text-shadow":q()}],opacity:[{opacity:[Ie,pe,ue]}],"mix-blend":[{"mix-blend":[...W(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":W()}],"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":[Ie]}],"mask-image-linear-from-pos":[{"mask-linear-from":U()}],"mask-image-linear-to-pos":[{"mask-linear-to":U()}],"mask-image-linear-from-color":[{"mask-linear-from":q()}],"mask-image-linear-to-color":[{"mask-linear-to":q()}],"mask-image-t-from-pos":[{"mask-t-from":U()}],"mask-image-t-to-pos":[{"mask-t-to":U()}],"mask-image-t-from-color":[{"mask-t-from":q()}],"mask-image-t-to-color":[{"mask-t-to":q()}],"mask-image-r-from-pos":[{"mask-r-from":U()}],"mask-image-r-to-pos":[{"mask-r-to":U()}],"mask-image-r-from-color":[{"mask-r-from":q()}],"mask-image-r-to-color":[{"mask-r-to":q()}],"mask-image-b-from-pos":[{"mask-b-from":U()}],"mask-image-b-to-pos":[{"mask-b-to":U()}],"mask-image-b-from-color":[{"mask-b-from":q()}],"mask-image-b-to-color":[{"mask-b-to":q()}],"mask-image-l-from-pos":[{"mask-l-from":U()}],"mask-image-l-to-pos":[{"mask-l-to":U()}],"mask-image-l-from-color":[{"mask-l-from":q()}],"mask-image-l-to-color":[{"mask-l-to":q()}],"mask-image-x-from-pos":[{"mask-x-from":U()}],"mask-image-x-to-pos":[{"mask-x-to":U()}],"mask-image-x-from-color":[{"mask-x-from":q()}],"mask-image-x-to-color":[{"mask-x-to":q()}],"mask-image-y-from-pos":[{"mask-y-from":U()}],"mask-image-y-to-pos":[{"mask-y-to":U()}],"mask-image-y-from-color":[{"mask-y-from":q()}],"mask-image-y-to-color":[{"mask-y-to":q()}],"mask-image-radial":[{"mask-radial":[pe,ue]}],"mask-image-radial-from-pos":[{"mask-radial-from":U()}],"mask-image-radial-to-pos":[{"mask-radial-to":U()}],"mask-image-radial-from-color":[{"mask-radial-from":q()}],"mask-image-radial-to-color":[{"mask-radial-to":q()}],"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":b()}],"mask-image-conic-pos":[{"mask-conic":[Ie]}],"mask-image-conic-from-pos":[{"mask-conic-from":U()}],"mask-image-conic-to-pos":[{"mask-conic-to":U()}],"mask-image-conic-from-color":[{"mask-conic-from":q()}],"mask-image-conic-to-color":[{"mask-conic-to":q()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:H()}],"mask-repeat":[{mask:G()}],"mask-size":[{mask:T()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",pe,ue]}],filter:[{filter:["","none",pe,ue]}],blur:[{blur:ae()}],brightness:[{brightness:[Ie,pe,ue]}],contrast:[{contrast:[Ie,pe,ue]}],"drop-shadow":[{"drop-shadow":["","none",p,Mr,Ar]}],"drop-shadow-color":[{"drop-shadow":q()}],grayscale:[{grayscale:["",Ie,pe,ue]}],"hue-rotate":[{"hue-rotate":[Ie,pe,ue]}],invert:[{invert:["",Ie,pe,ue]}],saturate:[{saturate:[Ie,pe,ue]}],sepia:[{sepia:["",Ie,pe,ue]}],"backdrop-filter":[{"backdrop-filter":["","none",pe,ue]}],"backdrop-blur":[{"backdrop-blur":ae()}],"backdrop-brightness":[{"backdrop-brightness":[Ie,pe,ue]}],"backdrop-contrast":[{"backdrop-contrast":[Ie,pe,ue]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ie,pe,ue]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ie,pe,ue]}],"backdrop-invert":[{"backdrop-invert":["",Ie,pe,ue]}],"backdrop-opacity":[{"backdrop-opacity":[Ie,pe,ue]}],"backdrop-saturate":[{"backdrop-saturate":[Ie,pe,ue]}],"backdrop-sepia":[{"backdrop-sepia":["",Ie,pe,ue]}],"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",pe,ue]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ie,"initial",pe,ue]}],ease:[{ease:["linear","initial",x,pe,ue]}],delay:[{delay:[Ie,pe,ue]}],animate:[{animate:["none",j,pe,ue]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[k,pe,ue]}],"perspective-origin":[{"perspective-origin":v()}],rotate:[{rotate:K()}],"rotate-x":[{"rotate-x":K()}],"rotate-y":[{"rotate-y":K()}],"rotate-z":[{"rotate-z":K()}],scale:[{scale:de()}],"scale-x":[{"scale-x":de()}],"scale-y":[{"scale-y":de()}],"scale-z":[{"scale-z":de()}],"scale-3d":["scale-3d"],skew:[{skew:ee()}],"skew-x":[{"skew-x":ee()}],"skew-y":[{"skew-y":ee()}],transform:[{transform:[pe,ue,"","none","gpu","cpu"]}],"transform-origin":[{origin:v()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ke()}],"translate-x":[{"translate-x":ke()}],"translate-y":[{"translate-y":ke()}],"translate-z":[{"translate-z":ke()}],"translate-none":["translate-none"],zoom:[{zoom:[bt,pe,ue]}],accent:[{accent:q()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:q()}],"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",pe,ue]}],"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":q()}],"scrollbar-track-color":[{"scrollbar-track":q()}],"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",pe,ue]}],fill:[{fill:["none",...q()]}],"stroke-w":[{stroke:[Ie,fr,_t,Pa]}],stroke:[{stroke:["none",...q()]}],"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"]}},Tc=ac(Sc),Ma=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,$a=qs,Er=(e,r)=>n=>{var a;if((r==null?void 0:r.variants)==null)return $a(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=Ma(u)||Ma(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[k,w]=g;return Array.isArray(w)?w.includes({...o,...i}[k]):{...o,...i}[k]===w})?[...h,m,f]:h},[]);return $a(e,l,d,n==null?void 0:n.class,n==null?void 0:n.className)},en=c.createContext(null);en.displayName="PanelGroupContext";const qe={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"},na=10,Wt=c.useLayoutEffect,_a=jd.useId,Ec=typeof _a=="function"?_a:()=>null;let Lc=0;function aa(e=null){const r=Ec(),n=c.useRef(e||r||null);return n.current===null&&(n.current=""+Lc++),e??n.current}function io({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",...k}){const w=c.useContext(en);if(w===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:x,expandPanel:j,getPanelSize:y,getPanelStyle:b,groupId:v,isPanelCollapsed:S,reevaluatePanelConstraints:N,registerPanel:L,resizePanel:R,unregisterPanel:P}=w,Q=aa(l),D=c.useRef({callbacks:{onCollapse:h,onExpand:u,onResize:m},constraints:{collapsedSize:n,collapsible:a,defaultSize:s,maxSize:i,minSize:d},id:Q,idIsFromProps:l!==void 0,order:f});c.useRef({didLogMissingDefaultSizeWarning:!1}),Wt(()=>{const{callbacks:J,constraints:z}=D.current,te={...z};D.current.id=Q,D.current.idIsFromProps=l!==void 0,D.current.order=f,J.onCollapse=h,J.onExpand=u,J.onResize=m,z.collapsedSize=n,z.collapsible=a,z.defaultSize=s,z.maxSize=i,z.minSize=d,(te.collapsedSize!==z.collapsedSize||te.collapsible!==z.collapsible||te.maxSize!==z.maxSize||te.minSize!==z.minSize)&&N(D.current,te)}),Wt(()=>{const J=D.current;return L(J),()=>{P(J)}},[f,Q,L,P]),c.useImperativeHandle(o,()=>({collapse:()=>{x(D.current)},expand:J=>{j(D.current,J)},getId(){return Q},getSize(){return y(D.current)},isCollapsed(){return S(D.current)},isExpanded(){return!S(D.current)},resize:J=>{R(D.current,J)}}),[x,j,y,S,Q,R]);const Z=b(D.current,s);return c.createElement(g,{...k,children:e,className:r,id:Q,style:{...Z,...p},[qe.groupId]:v,[qe.panel]:"",[qe.panelCollapsible]:a||void 0,[qe.panelId]:Q,[qe.panelSize]:parseFloat(""+Z.flexGrow).toFixed(1)})}const co=c.forwardRef((e,r)=>c.createElement(io,{...e,forwardedRef:r}));io.displayName="Panel";co.displayName="forwardRef(Panel)";let $n=null,Fr=-1,Et=null;function Ic(e,r,n){const a=(r&fo)!==0,s=(r&go)!==0,o=(r&xo)!==0,l=(r&bo)!==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 zc(){Et!==null&&(document.head.removeChild(Et),$n=null,Et=null,Fr=-1)}function kn(e,r,n){var a,s;const o=Ic(e,r);if($n!==o){if($n=o,Et===null&&(Et=document.createElement("style"),document.head.appendChild(Et)),Fr>=0){var l;(l=Et.sheet)===null||l===void 0||l.removeRule(Fr)}Fr=(a=(s=Et.sheet)===null||s===void 0?void 0:s.insertRule(`*{cursor: ${o} !important;}`))!==null&&a!==void 0?a:-1}}function ho(e){return e.type==="keydown"}function uo(e){return e.type.startsWith("pointer")}function mo(e){return e.type.startsWith("mouse")}function tn(e){if(uo(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(mo(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 Rc(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 Ac(e,r){if(e===r)throw new Error("Cannot compare node with itself");const n={a:Ga(e),b:Ga(r)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),r=n.b.pop(),a=e;Ee(a,"Stacking order can only be calculated for elements with a common ancestor");const s={a:Ba(Da(n.a)),b:Ba(Da(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 Mc=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function $c(e){var r;const n=getComputedStyle((r=po(e))!==null&&r!==void 0?r:e).display;return n==="flex"||n==="inline-flex"}function _c(e){const r=getComputedStyle(e);return!!(r.position==="fixed"||r.zIndex!=="auto"&&(r.position!=="static"||$c(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"||Mc.test(r.willChange)||r.webkitOverflowScrolling==="touch")}function Da(e){let r=e.length;for(;r--;){const n=e[r];if(Ee(n,"Missing node"),_c(n))return n}return null}function Ba(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Ga(e){const r=[];for(;e;)r.push(e),e=po(e);return r}function po(e){const{parentNode:r}=e;return r&&r instanceof ShadowRoot?r.host:r}const fo=1,go=2,xo=4,bo=8,Dc=Pc()==="coarse";let pt=[],lr=!1,Lt=new Map,rn=new Map;const Cr=new Set;function Bc(e,r,n,a,s){var o;const{ownerDocument:l}=r,i={direction:n,element:r,hitAreaMargins:a,setResizeHandlerState:s},d=(o=Lt.get(l))!==null&&o!==void 0?o:0;return Lt.set(l,d+1),Cr.add(i),Kr(),function(){var u;rn.delete(e),Cr.delete(i);const m=(u=Lt.get(l))!==null&&u!==void 0?u:1;if(Lt.set(l,m-1),Kr(),m===1&&Lt.delete(l),pt.includes(i)){const f=pt.indexOf(i);f>=0&&pt.splice(f,1),nn(),s("up",!0,null)}}}function Gc(e){const{target:r}=e,{x:n,y:a}=tn(e);lr=!0,sa({target:r,x:n,y:a}),Kr(),pt.length>0&&(Xr("down",e),nn(),e.preventDefault(),vo(r)||e.stopImmediatePropagation())}function wn(e){const{x:r,y:n}=tn(e);if(lr&&e.type!=="pointerleave"&&e.buttons===0&&(lr=!1,Xr("up",e)),!lr){const{target:a}=e;sa({target:a,x:r,y:n})}Xr("move",e),nn(),pt.length>0&&e.preventDefault()}function yn(e){const{target:r}=e,{x:n,y:a}=tn(e);rn.clear(),lr=!1,pt.length>0&&(e.preventDefault(),vo(r)||e.stopImmediatePropagation()),Xr("up",e),sa({target:r,x:n,y:a}),nn(),Kr()}function vo(e){let r=e;for(;r;){if(r.hasAttribute(qe.resizeHandle))return!0;r=r.parentElement}return!1}function sa({target:e,x:r,y:n}){pt.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=Dc?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)&&Ac(a,o)>0){let g=a,k=!1;for(;g&&!g.contains(o);){if(Rc(g.getBoundingClientRect(),i)){k=!0;break}g=g.parentElement}if(k)return}pt.push(s)}})}function jn(e,r){rn.set(e,r)}function nn(){let e=!1,r=!1;pt.forEach(a=>{const{direction:s}=a;s==="horizontal"?e=!0:r=!0});let n=0;rn.forEach(a=>{n|=a}),e&&r?kn("intersection",n):e?kn("horizontal",n):r?kn("vertical",n):zc()}let Nn;function Kr(){var e;(e=Nn)===null||e===void 0||e.abort(),Nn=new AbortController;const r={capture:!0,signal:Nn.signal};Cr.size&&(lr?(pt.length>0&&Lt.forEach((n,a)=>{const{body:s}=a;n>0&&(s.addEventListener("contextmenu",yn,r),s.addEventListener("pointerleave",wn,r),s.addEventListener("pointermove",wn,r))}),Lt.forEach((n,a)=>{const{body:s}=a;s.addEventListener("pointerup",yn,r),s.addEventListener("pointercancel",yn,r)})):Lt.forEach((n,a)=>{const{body:s}=a;n>0&&(s.addEventListener("pointerdown",Gc,r),s.addEventListener("pointermove",wn,r))}))}function Xr(e,r){Cr.forEach(n=>{const{setResizeHandlerState:a}=n,s=pt.includes(n);a(e,s,r)})}function Fc(){const[e,r]=c.useState(0);return c.useCallback(()=>r(n=>n+1),[])}function Ee(e,r){if(!e)throw console.error(r),Error(r)}function Vt(e,r,n=na){return e.toFixed(n)===r.toFixed(n)?0:e>r?1:-1}function Nt(e,r,n=na){return Vt(e,r,n)===0}function ht(e,r,n){return Vt(e,r,n)===0}function Hc(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(!ht(s,o,n))return!1}return!0}function sr({panelConstraints:e,panelIndex:r,size:n}){const a=e[r];Ee(a!=null,`Panel constraints not found for index ${r}`);let{collapsedSize:s=0,collapsible:o,maxSize:l=100,minSize:i=0}=a;if(Vt(n,i)<0)if(o){const d=(s+i)/2;Vt(n,d)<0?n=s:n=i}else n=i;return n=Math.min(l,n),n=parseFloat(n.toFixed(na)),n}function kr({delta:e,initialLayout:r,panelConstraints:n,pivotIndices:a,prevLayout:s,trigger:o}){if(ht(e,0))return r;const l=[...r],[i,d]=a;Ee(i!=null,"Invalid first pivot index"),Ee(d!=null,"Invalid second pivot index");let h=0;if(o==="keyboard"){{const m=e<0?d:i,f=n[m];Ee(f,`Panel constraints not found for index ${m}`);const{collapsedSize:p=0,collapsible:g,minSize:k=0}=f;if(g){const w=r[m];if(Ee(w!=null,`Previous layout not found for panel index ${m}`),ht(w,p)){const x=k-w;Vt(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}{const m=e<0?i:d,f=n[m];Ee(f,`No panel constraints found for index ${m}`);const{collapsedSize:p=0,collapsible:g,minSize:k=0}=f;if(g){const w=r[m];if(Ee(w!=null,`Previous layout not found for panel index ${m}`),ht(w,k)){const x=w-p;Vt(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 k=r[f];Ee(k!=null,`Previous layout not found for panel index ${f}`);const x=sr({panelConstraints:n,panelIndex:f,size:100})-k;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];Ee(g!=null,`Previous layout not found for panel index ${f}`);const k=g-p,w=sr({panelConstraints:n,panelIndex:f,size:k});if(!ht(g,w)&&(h+=g-w,l[f]=w,h.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?f--:f++}}if(Hc(s,l))return s;{const m=e<0?d:i,f=r[m];Ee(f!=null,`Previous layout not found for panel index ${m}`);const p=f+h,g=sr({panelConstraints:n,panelIndex:m,size:p});if(l[m]=g,!ht(g,p)){let k=p-g,x=e<0?d:i;for(;x>=0&&x<n.length;){const j=l[x];Ee(j!=null,`Previous layout not found for panel index ${x}`);const y=j+k,b=sr({panelConstraints:n,panelIndex:x,size:y});if(ht(j,b)||(k-=b-j,l[x]=b),ht(k,0))break;e>0?x--:x++}}}const u=l.reduce((m,f)=>f+m,0);return ht(u,100)?l:s}function Oc({layout:e,panelsArray:r,pivotIndices:n}){let a=0,s=100,o=0,l=0;const i=n[0];Ee(i!=null,"No pivot index found"),r.forEach((m,f)=>{const{constraints:p}=m,{maxSize:g=100,minSize:k=0}=p;f===i?(a=k,s=g):(o+=k,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 Sr(e,r=document){return Array.from(r.querySelectorAll(`[${qe.resizeHandleId}][data-panel-group-id="${e}"]`))}function ko(e,r,n=document){const s=Sr(e,n).findIndex(o=>o.getAttribute(qe.resizeHandleId)===r);return s??null}function wo(e,r,n){const a=ko(e,r,n);return a!=null?[a,a+1]:[-1,-1]}function Wc(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function yo(e,r=document){if(Wc(r)&&r.dataset.panelGroupId==e)return r;const n=r.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function an(e,r=document){const n=r.querySelector(`[${qe.resizeHandleId}="${e}"]`);return n||null}function Uc(e,r,n,a=document){var s,o,l,i;const d=an(r,a),h=Sr(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 Vc({committedValuesRef:e,eagerValuesRef:r,groupId:n,layout:a,panelDataArray:s,panelGroupElement:o,setLayout:l}){c.useRef({didWarnAboutMissingResizeHandle:!1}),Wt(()=>{if(!o)return;const i=Sr(n,o);for(let d=0;d<s.length-1;d++){const{valueMax:h,valueMin:u,valueNow:m}=Oc({layout:a,panelsArray:s,pivotIndices:[d,d+1]}),f=i[d];if(f!=null){const p=s[d];Ee(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;Ee(i,"Eager values not found");const{panelDataArray:d}=i,h=yo(n,o);Ee(h!=null,`No group found for id "${n}"`);const u=Sr(n,o);Ee(u,`No resize handles found for group id "${n}"`);const m=u.map(f=>{const p=f.getAttribute(qe.resizeHandleId);Ee(p,"Resize handle element has no handle id attribute");const[g,k]=Uc(n,p,d,o);if(g==null||k==null)return()=>{};const w=x=>{if(!x.defaultPrevented)switch(x.key){case"Enter":{x.preventDefault();const j=d.findIndex(y=>y.id===g);if(j>=0){const y=d[j];Ee(y,`No panel data found for index ${j}`);const b=a[j],{collapsedSize:v=0,collapsible:S,minSize:N=0}=y.constraints;if(b!=null&&S){const L=kr({delta:ht(b,v)?N-v:v-b,initialLayout:a,panelConstraints:d.map(R=>R.constraints),pivotIndices:wo(n,p,o),prevLayout:a,trigger:"keyboard"});a!==L&&l(L)}}break}}};return f.addEventListener("keydown",w),()=>{f.removeEventListener("keydown",w)}});return()=>{m.forEach(f=>f())}},[o,e,r,n,a,s,l])}function Fa(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 jo(e,r){const n=e==="horizontal",{x:a,y:s}=tn(r);return n?a:s}function qc(e,r,n,a,s){const o=n==="horizontal",l=an(r,s);Ee(l,`No resize handle element found for id "${r}"`);const i=l.getAttribute(qe.groupId);Ee(i,"Resize handle element has no group id attribute");let{initialCursorPosition:d}=a;const h=jo(n,e),u=yo(i,s);Ee(u,`No group element found for id "${i}"`);const m=u.getBoundingClientRect(),f=o?m.width:m.height;return(h-d)/f*100}function Kc(e,r,n,a,s,o){if(ho(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:qc(e,r,n,a,o)}function Xc({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];Ee(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];Ee(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 Qt(e,r,n){r.forEach((a,s)=>{const o=e[s];Ee(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||Nt(m,h))&&!Nt(a,h)&&p(),f&&(m==null||!Nt(m,h))&&Nt(a,h)&&f())}})}function $r(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 Yc({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 Ha(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 No(e){return`react-resizable-panels:${e}`}function Co(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 So(e,r){try{const n=No(e),a=r.getItem(n);if(a){const s=JSON.parse(a);if(typeof s=="object"&&s!=null)return s}}catch{}return null}function Jc(e,r,n){var a,s;const o=(a=So(e,n))!==null&&a!==void 0?a:{},l=Co(r);return(s=o[l])!==null&&s!==void 0?s:null}function Qc(e,r,n,a,s){var o;const l=No(e),i=Co(r),d=(o=So(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 Oa({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(!ht(a,100)&&n.length>0)for(let o=0;o<r.length;o++){const l=n[o];Ee(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];Ee(l!=null,`No layout data found for index ${o}`);const i=sr({panelConstraints:r,panelIndex:o,size:l});l!=i&&(s+=l-i,n[o]=i)}if(!ht(s,0))for(let o=0;o<r.length;o++){const l=n[o];Ee(l!=null,`No layout data found for index ${o}`);const i=l+s,d=sr({panelConstraints:r,panelIndex:o,size:i});if(l!==d&&(s-=d-l,n[o]=d,ht(s,0)))break}return n}const eh=100,wr={getItem:e=>(Ha(wr),wr.getItem(e)),setItem:(e,r)=>{Ha(wr),wr.setItem(e,r)}},Wa={};function To({autoSaveId:e=null,children:r,className:n="",direction:a,forwardedRef:s,id:o=null,onLayout:l=null,keyboardResizeBy:i=null,storage:d=wr,style:h,tagName:u="div",...m}){const f=aa(o),p=c.useRef(null),[g,k]=c.useState(null),[w,x]=c.useState([]),j=Fc(),y=c.useRef({}),b=c.useRef(new Map),v=c.useRef(0),S=c.useRef({autoSaveId:e,direction:a,dragState:g,id:f,keyboardResizeBy:i,onLayout:l,storage:d}),N=c.useRef({layout:w,panelDataArray:[],panelDataArrayChanged:!1});c.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),c.useImperativeHandle(s,()=>({getId:()=>S.current.id,getLayout:()=>{const{layout:T}=N.current;return T},setLayout:T=>{const{onLayout:F}=S.current,{layout:B,panelDataArray:E}=N.current,C=Oa({layout:T,panelConstraints:E.map(W=>W.constraints)});Fa(B,C)||(x(C),N.current.layout=C,F&&F(C),Qt(E,C,y.current))}}),[]),Wt(()=>{S.current.autoSaveId=e,S.current.direction=a,S.current.dragState=g,S.current.id=f,S.current.onLayout=l,S.current.storage=d}),Vc({committedValuesRef:S,eagerValuesRef:N,groupId:f,layout:w,panelDataArray:N.current.panelDataArray,setLayout:x,panelGroupElement:p.current}),c.useEffect(()=>{const{panelDataArray:T}=N.current;if(e){if(w.length===0||w.length!==T.length)return;let F=Wa[e];F==null&&(F=Zc(Qc,eh),Wa[e]=F);const B=[...T],E=new Map(b.current);F(e,B,E,w,d)}},[e,w,d]),c.useEffect(()=>{});const L=c.useCallback(T=>{const{onLayout:F}=S.current,{layout:B,panelDataArray:E}=N.current;if(T.constraints.collapsible){const C=E.map(K=>K.constraints),{collapsedSize:W=0,panelSize:U,pivotIndices:ae}=Dt(E,T,B);if(Ee(U!=null,`Panel size not found for panel "${T.id}"`),!Nt(U,W)){b.current.set(T.id,U);const de=tr(E,T)===E.length-1?U-W:W-U,ee=kr({delta:de,initialLayout:B,panelConstraints:C,pivotIndices:ae,prevLayout:B,trigger:"imperative-api"});$r(B,ee)||(x(ee),N.current.layout=ee,F&&F(ee),Qt(E,ee,y.current))}}},[]),R=c.useCallback((T,F)=>{const{onLayout:B}=S.current,{layout:E,panelDataArray:C}=N.current;if(T.constraints.collapsible){const W=C.map(ke=>ke.constraints),{collapsedSize:U=0,panelSize:ae=0,minSize:K=0,pivotIndices:de}=Dt(C,T,E),ee=F??K;if(Nt(ae,U)){const ke=b.current.get(T.id),le=ke!=null&&ke>=ee?ke:ee,Ae=tr(C,T)===C.length-1?ae-le:le-ae,ce=kr({delta:Ae,initialLayout:E,panelConstraints:W,pivotIndices:de,prevLayout:E,trigger:"imperative-api"});$r(E,ce)||(x(ce),N.current.layout=ce,B&&B(ce),Qt(C,ce,y.current))}}},[]),P=c.useCallback(T=>{const{layout:F,panelDataArray:B}=N.current,{panelSize:E}=Dt(B,T,F);return Ee(E!=null,`Panel size not found for panel "${T.id}"`),E},[]),Q=c.useCallback((T,F)=>{const{panelDataArray:B}=N.current,E=tr(B,T);return Yc({defaultSize:F,dragState:g,layout:w,panelData:B,panelIndex:E})},[g,w]),D=c.useCallback(T=>{const{layout:F,panelDataArray:B}=N.current,{collapsedSize:E=0,collapsible:C,panelSize:W}=Dt(B,T,F);return Ee(W!=null,`Panel size not found for panel "${T.id}"`),C===!0&&Nt(W,E)},[]),Z=c.useCallback(T=>{const{layout:F,panelDataArray:B}=N.current,{collapsedSize:E=0,collapsible:C,panelSize:W}=Dt(B,T,F);return Ee(W!=null,`Panel size not found for panel "${T.id}"`),!C||Vt(W,E)>0},[]),J=c.useCallback(T=>{const{panelDataArray:F}=N.current;F.push(T),F.sort((B,E)=>{const C=B.order,W=E.order;return C==null&&W==null?0:C==null?-1:W==null?1:C-W}),N.current.panelDataArrayChanged=!0,j()},[j]);Wt(()=>{if(N.current.panelDataArrayChanged){N.current.panelDataArrayChanged=!1;const{autoSaveId:T,onLayout:F,storage:B}=S.current,{layout:E,panelDataArray:C}=N.current;let W=null;if(T){const ae=Jc(T,C,B);ae&&(b.current=new Map(Object.entries(ae.expandToSizes)),W=ae.layout)}W==null&&(W=Xc({panelDataArray:C}));const U=Oa({layout:W,panelConstraints:C.map(ae=>ae.constraints)});Fa(E,U)||(x(U),N.current.layout=U,F&&F(U),Qt(C,U,y.current))}}),Wt(()=>{const T=N.current;return()=>{T.layout=[]}},[]);const z=c.useCallback(T=>{let F=!1;const B=p.current;return B&&window.getComputedStyle(B,null).getPropertyValue("direction")==="rtl"&&(F=!0),function(C){C.preventDefault();const W=p.current;if(!W)return()=>null;const{direction:U,dragState:ae,id:K,keyboardResizeBy:de,onLayout:ee}=S.current,{layout:ke,panelDataArray:le}=N.current,{initialLayout:je}=ae??{},Ae=wo(K,T,W);let ce=Kc(C,T,U,ae,de,W);const ne=U==="horizontal";ne&&F&&(ce=-ce);const Le=le.map(we=>we.constraints),Y=kr({delta:ce,initialLayout:je??ke,panelConstraints:Le,pivotIndices:Ae,prevLayout:ke,trigger:ho(C)?"keyboard":"mouse-or-touch"}),me=!$r(ke,Y);(uo(C)||mo(C))&&v.current!=ce&&(v.current=ce,!me&&ce!==0?ne?jn(T,ce<0?fo:go):jn(T,ce<0?xo:bo):jn(T,0)),me&&(x(Y),N.current.layout=Y,ee&&ee(Y),Qt(le,Y,y.current))}},[]),te=c.useCallback((T,F)=>{const{onLayout:B}=S.current,{layout:E,panelDataArray:C}=N.current,W=C.map(ke=>ke.constraints),{panelSize:U,pivotIndices:ae}=Dt(C,T,E);Ee(U!=null,`Panel size not found for panel "${T.id}"`);const de=tr(C,T)===C.length-1?U-F:F-U,ee=kr({delta:de,initialLayout:E,panelConstraints:W,pivotIndices:ae,prevLayout:E,trigger:"imperative-api"});$r(E,ee)||(x(ee),N.current.layout=ee,B&&B(ee),Qt(C,ee,y.current))},[]),se=c.useCallback((T,F)=>{const{layout:B,panelDataArray:E}=N.current,{collapsedSize:C=0,collapsible:W}=F,{collapsedSize:U=0,collapsible:ae,maxSize:K=100,minSize:de=0}=T.constraints,{panelSize:ee}=Dt(E,T,B);ee!=null&&(W&&ae&&Nt(ee,C)?Nt(C,U)||te(T,U):ee<de?te(T,de):ee>K&&te(T,K))},[te]),_=c.useCallback((T,F)=>{const{direction:B}=S.current,{layout:E}=N.current;if(!p.current)return;const C=an(T,p.current);Ee(C,`Drag handle element not found for id "${T}"`);const W=jo(B,F);k({dragHandleId:T,dragHandleRect:C.getBoundingClientRect(),initialCursorPosition:W,initialLayout:E})},[]),ie=c.useCallback(()=>{k(null)},[]),q=c.useCallback(T=>{const{panelDataArray:F}=N.current,B=tr(F,T);B>=0&&(F.splice(B,1),delete y.current[T.id],N.current.panelDataArrayChanged=!0,j())},[j]),H=c.useMemo(()=>({collapsePanel:L,direction:a,dragState:g,expandPanel:R,getPanelSize:P,getPanelStyle:Q,groupId:f,isPanelCollapsed:D,isPanelExpanded:Z,reevaluatePanelConstraints:se,registerPanel:J,registerResizeHandle:z,resizePanel:te,startDragging:_,stopDragging:ie,unregisterPanel:q,panelGroupElement:p.current}),[L,g,a,R,P,Q,f,D,Z,se,J,z,te,_,ie,q]),G={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return c.createElement(en.Provider,{value:H},c.createElement(u,{...m,children:r,className:n,id:o,ref:p,style:{...G,...h},[qe.group]:"",[qe.groupDirection]:a,[qe.groupId]:f}))}const Eo=c.forwardRef((e,r)=>c.createElement(To,{...e,forwardedRef:r}));To.displayName="PanelGroup";Eo.displayName="forwardRef(PanelGroup)";function tr(e,r){return e.findIndex(n=>n===r||n.id===r.id)}function Dt(e,r,n){const a=tr(e,r),o=a===e.length-1?[a-1,a]:[a,a+1],l=n[a];return{...r.constraints,panelSize:l,pivotIndices:o}}function th({disabled:e,handleId:r,resizeHandler:n,panelGroupElement:a}){c.useEffect(()=>{if(e||n==null||a==null)return;const s=an(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(qe.groupId);Ee(i,`No group element found for id "${i}"`);const d=Sr(i,a),h=ko(i,r,a);Ee(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 Lo({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 k,w;const x=c.useRef(null),j=c.useRef({onClick:l,onDragging:i,onPointerDown:h,onPointerUp:u});c.useEffect(()=>{j.current.onClick=l,j.current.onDragging=i,j.current.onPointerDown=h,j.current.onPointerUp=u});const y=c.useContext(en);if(y===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:b,groupId:v,registerResizeHandle:S,startDragging:N,stopDragging:L,panelGroupElement:R}=y,P=aa(s),[Q,D]=c.useState("inactive"),[Z,J]=c.useState(!1),[z,te]=c.useState(null),se=c.useRef({state:Q});Wt(()=>{se.current.state=Q}),c.useEffect(()=>{if(n)te(null);else{const H=S(P);te(()=>H)}},[n,P,S]);const _=(k=a==null?void 0:a.coarse)!==null&&k!==void 0?k:15,ie=(w=a==null?void 0:a.fine)!==null&&w!==void 0?w:5;c.useEffect(()=>{if(n||z==null)return;const H=x.current;Ee(H,"Element ref not attached");let G=!1;return Bc(P,H,b,{coarse:_,fine:ie},(F,B,E)=>{if(!B){D("inactive");return}switch(F){case"down":{D("drag"),G=!1,Ee(E,'Expected event to be defined for "down" action'),N(P,E);const{onDragging:C,onPointerDown:W}=j.current;C==null||C(!0),W==null||W();break}case"move":{const{state:C}=se.current;G=!0,C!=="drag"&&D("hover"),Ee(E,'Expected event to be defined for "move" action'),z(E);break}case"up":{D("hover"),L();const{onClick:C,onDragging:W,onPointerUp:U}=j.current;W==null||W(!1),U==null||U(),G||C==null||C();break}}})},[_,b,n,ie,S,P,z,N,L]),th({disabled:n,handleId:P,resizeHandler:z,panelGroupElement:R});const q={touchAction:"none",userSelect:"none"};return c.createElement(p,{...g,children:e,className:r,id:s,onBlur:()=>{J(!1),o==null||o()},onFocus:()=>{J(!0),d==null||d()},ref:x,role:"separator",style:{...q,...m},tabIndex:f,[qe.groupDirection]:b,[qe.groupId]:v,[qe.resizeHandle]:"",[qe.resizeHandleActive]:Q==="drag"?"pointer":Z?"keyboard":void 0,[qe.resizeHandleEnabled]:!n,[qe.resizeHandleId]:P,[qe.resizeHandleState]:Q})}Lo.displayName="PanelResizeHandle";var rh=Object.defineProperty,nh=Object.getOwnPropertyNames,He=(e,r)=>function(){return e&&(r=(0,e[nh(e)[0]])(e=0)),r},ah=(e,r)=>{for(var n in r)rh(e,n,{get:r[n],enumerable:!0})};function at(...e){return Tc(qs(e))}var Pt=He({"src/components/graph-ui/utils.ts"(){}});function Tr({asChild:e=!1,className:r,size:n,variant:a,...s}){const o=e?Os:"button";return t.jsx(o,{"data-slot":"button",className:at(Io({variant:a,size:n,className:r})),...s})}var Io,sn=He({"src/components/graph-ui/Button.tsx"(){Pt(),Io=Er("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 zo(...e){return e.filter(Boolean).join(" ")}function _n({className:e,...r}){return t.jsx(Eo,{"data-slot":"resizable-panel-group",className:zo("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...r})}function or({...e}){return t.jsx(co,{"data-slot":"resizable-panel",...e})}function Dn({withHandle:e,className:r,...n}){return t.jsx(Lo,{"data-slot":"resizable-handle",className:zo("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($.GripVerticalIcon,{className:"size-2.5"})}):null})}var Po=He({"src/components/graph-workspace/GraphResizablePanels.tsx"(){}});function oa(...e){return e.filter(Boolean).join(" ")}function Lr({...e}){return t.jsx(Qi,{"data-slot":"accordion",...e})}function Ir({className:e,...r}){return t.jsx(ed,{"data-slot":"accordion-item",className:oa("border-b last:border-b-0",e),...r})}function on({className:e,children:r,...n}){return t.jsx(rd,{className:"flex",children:t.jsxs(nd,{"data-slot":"accordion-trigger",className:oa("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($.ChevronDownIcon,{className:"pointer-events-none size-4 shrink-0 translate-y-0.5 text-[var(--theme-fg-muted)] transition-transform duration-200"})]})})}function zr({className:e,children:r,...n}){return t.jsx(td,{"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:oa("pb-4 pt-0",e),children:r})})}var Pr=He({"src/components/graph-workspace/GraphAccordion.tsx"(){}});function sh(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 oh(e){return e.trim().replace(/^\/+|\/+$/g,"").replace(/[^\w.-]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function Rr(e){var r;return((r=e.split(".").pop())==null?void 0:r.toLowerCase())||""}function lh(e){return e.split("/").filter(Boolean).at(-1)??e}function rr(e){const r=e.kind==="directory"?"directory":"file",n=(e.children??[]).map(rr);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 Ro(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=Ro(l,r,n,a);return i!==l&&(s=!0),i});return s?{...e,children:o}:e}function Ao(e){if(e.kind==="file")return e;for(const r of e.children){const n=Ao(r);if(n)return n}return null}function Bn(e,r){if(!e||r===null)return null;if(e.path===r)return e;for(const n of e.children){const a=Bn(n,r);if(a)return a}return null}function Mo(e){return e.trim().replace(/\\/g,"/").replace(/^\.\/+/,"").replace(/^\/+/,"")}function ih(e){const n=Mo(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 Gn(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=Gn(o,r,n);return l!==o&&(a=!0),l});return a?{...e,children:s}:e}function Fn(e,r){return!e||!r?!1:e.path===r?!0:e.children.some(n=>Fn(n,r))}function dh(e){if(!e)return null;const r=Rr(e.path);return la.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 lh(e){const r=Ir(e);return r==="tsx"||r==="jsx"?"tsx":r==="yml"?"yaml":r||"text"}function ih(e,r){let n=e,a="";for(const o of r){a=a?`${a}/${o}`:o;let s=n.children.find(l=>l.kind==="directory"&&l.name===o);s||(s={id:`dir:${a}`,name:o,path:a,kind:"directory",children:[]},n.children.push(s)),n=s}return n}function dh(e,r,n){const a=r.split("/").filter(Boolean),o=a.pop()??n.name;ih(e,a).children.push({...n,name:n.name||o,path:r})}function ch(e,r){return e.kind==="directory"&&r.kind!=="directory"?-1:e.kind!=="directory"&&r.kind==="directory"?1:e.name.localeCompare(r.name)}function Ro(e){e.children.sort(ch);for(const r of e.children)Ro(r);return e}function Oa(e,r,n,a){var u;const o={id:"root",name:e.workspace.label??"Workspace",path:"",kind:"directory",children:[]},s={id:"artifacts",name:"artifacts",path:"artifacts",kind:"directory",children:[]};for(const m of r){const f=m.title||m.id,p=nh(f)||m.id;s.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`,w="text"in f&&typeof f.text=="string"?f.text.slice(0,160):f.kind,x=f.kind==="artifact"&&f.artifact?f.artifact:null,j=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:ah(b),path:b,kind:"event",item:f,preview:w,detail:JSON.stringify(f,null,2),children:[]};if(p){i.children.push(j);return}dh(l,b.replace(/^thread-events\//,""),j)};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 o.children.push(s,l,i),Ro(o)}function hh(e){const r=new Map,n=a=>{r.set(a.id,a);for(const o of a.children)n(o)};return n(e),r}function Mo(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=Mo(r);if(n)return n}return null}function Wa(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 sa,Ao,_o,oa=He({"src/components/graph-workspace/workspaceTree.ts"(){sa=new Set(["xyz","extxyz","cif","pdb"]),Ao=new Set(["png","jpg","jpeg","gif","webp","svg"]),_o=new Set(["pdf"])}});function rr({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 $o=He({"src/components/graph-workspace/GraphWorkspaceCards.tsx"(){}});function uh({className:e,decorative:r=!0,orientation:n="horizontal",...a}){return t.jsx(bd,{"data-slot":"separator",decorative:r,orientation:n,className:at("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 mh=He({"src/components/graph-ui/Separator.tsx"(){Pt()}});function ph({className:e,orientation:r,...n}){return t.jsx("div",{role:"group","data-slot":"button-group","data-orientation":r,className:at(Do({orientation:r}),e),...n})}function fh({className:e,orientation:r="vertical",...n}){return t.jsx(uh,{"data-slot":"button-group-separator",orientation:r,className:at("relative !m-0 self-stretch bg-input data-[orientation=vertical]:h-auto",e),...n})}var Do,Bo=He({"src/components/graph-ui/ButtonGroup.tsx"(){mh(),Pt(),Do=Cr("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 gh({delayDuration:e=0,...r}){return t.jsx(vd,{"data-slot":"tooltip-provider",delayDuration:e,...r})}function xh({...e}){return t.jsx(gh,{children:t.jsx(md,{"data-slot":"tooltip",...e})})}function bh({...e}){return t.jsx(pd,{"data-slot":"tooltip-trigger",...e})}function vh({children:e,className:r,sideOffset:n=0,...a}){return t.jsx(fd,{children:t.jsxs(gd,{"data-slot":"tooltip-content",sideOffset:n,className:at("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(xd,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}var kh=He({"src/components/graph-ui/Tooltip.tsx"(){Pt()}});function wh(e){return(e==null?void 0:e.trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""))||"molecule"}function Ua(e,r){const n=new Blob([e],{type:"text/plain"}),a=URL.createObjectURL(n),o=document.createElement("a");o.href=a,o.download=r,o.click(),URL.revokeObjectURL(a)}function Ye({children:e,disabled:r,label:n,onClick:a}){return t.jsxs(xh,{children:[t.jsx(bh,{asChild:!0,children:t.jsx(Nr,{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(vh,{children:t.jsx("p",{children:n})})]})}function Bn({children:e,className:r=""}){return t.jsx(ph,{className:`thread-graph-molecule-button-group ${r}`,children:e})}var Go=He({"src/components/graph-workspace/GraphMoleculeViewerControls.tsx"(){rn(),Bo(),kh()}});function yh({cameraInfo:e,onClearSelection:r,onClearStaged:n,onSendSelection:a,onSendStaged:o,onStageSelection:s,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(Bn,{children:[t.jsx(Ye,{label:"Distance",children:t.jsx(_.AlignVerticalDistributeCenter,{className:"size-4"})}),t.jsx(Ye,{label:"Connectivity",children:t.jsx(_.Share2,{className:"size-4"})}),t.jsx(Ye,{label:"Angle",children:t.jsx(_.Waypoints,{className:"size-4"})}),t.jsx(Ye,{label:"Dihedral",children:t.jsx(_.Spline,{className:"size-4"})}),t.jsx(Ye,{label:"Add dummy atoms",children:t.jsx(_.Bubbles,{className:"size-4"})}),t.jsx(Ye,{label:"Delete atoms",children:t.jsx(_.CircleX,{className:"size-4"})}),t.jsx(Ye,{label:"Rotate",children:t.jsx(_.Rotate3d,{className:"size-4"})})]}),t.jsxs(Bn,{children:[t.jsx(Ye,{label:f?"Hide unit cell":"Show unit cell",disabled:!m,onClick:l,children:t.jsx(_.Boxes,{className:"size-4"})}),t.jsx(Ye,{label:"Clear selection",disabled:!p,onClick:r,children:t.jsx(_.Trash2,{className:"size-4"})}),t.jsx(Ye,{label:"Send selection",disabled:!p,onClick:a,children:t.jsx(_.Send,{className:"size-4"})}),t.jsx(Ye,{label:"Stage current selection",disabled:!p,onClick:s,children:t.jsx(_.Box,{className:"size-4"})}),t.jsx(Ye,{label:"Clear staged selections",disabled:!g,onClick:n,children:t.jsx(_.Eraser,{className:"size-4"})}),t.jsx(Ye,{label:"Send staged selections",disabled:!g,onClick:o,children:t.jsx(_.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 jh=He({"src/components/graph-workspace/GraphMoleculeViewerLowerButtonGroup.tsx"(){Go()}});function Nh({currentIndex:e,exportContent:r,moleculeId:n,onScreenshot:a,viewerRef:o,xyzContent:s,xyzFormat:l}){const i=wh(n);async function d(){s&&await navigator.clipboard.writeText(s)}function h(){s&&Ua(s,`${i}_step_${e+1}.${l||"xyz"}`)}function u(){r&&Ua(r,`${i}_trajectory.${l||"xyz"}`)}function m(){o.current&&(o.current.zoom(1.2),o.current.render())}function f(){o.current&&(o.current.zoom(.8),o.current.render())}function p(){o.current&&(o.current.zoomTo(),o.current.setCameraParameters({}),o.current.render())}return t.jsxs(Bn,{className:"ml-auto justify-end",children:[t.jsx(Ye,{label:"Copy current structure",onClick:()=>void d(),disabled:!s,children:t.jsx(_.Copy,{className:"size-3.5"})}),t.jsx(Ye,{label:"Download current structure",onClick:h,disabled:!s,children:t.jsx(_.Download,{className:"size-3.5"})}),t.jsx(Ye,{label:"Download full trajectory",onClick:u,disabled:!r,children:t.jsx(_.Box,{className:"size-3.5"})}),t.jsx(Ye,{label:"Copy screenshot",onClick:a,disabled:!o.current||!s,children:t.jsx(_.Camera,{className:"size-3.5"})}),t.jsx(fh,{className:"thread-graph-molecule-button-divider"}),t.jsx(Ye,{label:"Zoom in",onClick:m,disabled:!o.current||!s,children:t.jsx(_.ZoomIn,{className:"size-3.5"})}),t.jsx(Ye,{label:"Zoom out",onClick:f,disabled:!o.current||!s,children:t.jsx(_.ZoomOut,{className:"size-3.5"})}),t.jsx(Ye,{label:"Reset camera",onClick:p,disabled:!o.current||!s,children:t.jsx(_.RotateCcw,{className:"size-3.5"})})]})}var Ch=He({"src/components/graph-workspace/GraphMoleculeViewerUpperButtonGroup.tsx"(){Bo(),Go()}});async function Sh(){if(typeof window>"u")throw new Error("3Dmol is only available in a browser environment.");return window["3Dmol"]?window["3Dmol"]:(Gr||(Gr=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 o=document.createElement("script");o.src="/vendor/3Dmol-min.js",o.async=!0,o.dataset.remoteCodex3dmol="true",o.addEventListener("load",a,{once:!0}),o.addEventListener("error",()=>r(new Error("Unable to load 3Dmol viewer runtime.")),{once:!0}),document.head.appendChild(o)})),Gr)}var Gr,Th=He({"src/components/graph-workspace/load3Dmol.ts"(){Gr=null}});function Eh({className:e,defaultValue:r,max:n=100,min:a=0,value:o,...s}){const l=c.useMemo(()=>Array.isArray(o)?o:Array.isArray(r)?r:[a,n],[r,n,a,o]);return t.jsxs(dd,{"data-slot":"slider",...r!==void 0?{defaultValue:r}:{},...o!==void 0?{value:o}:{},min:a,max:n,className:at("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),...s,children:[t.jsx(cd,{"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(hd,{"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(ud,{"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 Lh=He({"src/components/graph-ui/Slider.tsx"(){Pt()}});function Ih(e){const r=e==null?void 0:e.trim().toLowerCase();return!r||r==="extxyz"?"xyz":r}function zh(e){var o,s;const r=e.replace(/\r\n/g,`
4
+ `],format:r==="extxyz"?"xyz":r,name:e.name,uuid:e.path}:null}function ch(e){const r=Rr(e);return r==="tsx"||r==="jsx"?"tsx":r==="yml"?"yaml":r||"text"}function hh(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 uh(e,r,n){const a=r.split("/").filter(Boolean),s=a.pop()??n.name;hh(e,a).children.push({...n,name:n.name||s,path:r})}function mh(e,r){return e.kind==="directory"&&r.kind!=="directory"?-1:e.kind!=="directory"&&r.kind==="directory"?1:e.name.localeCompare(r.name)}function $o(e){e.children.sort(mh);for(const r of e.children)$o(r);return e}function Ua(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=oh(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(),k=`${p?"live":`thread-events/${m}`}/${String(d).padStart(3,"0")}-${g}.json`,w="text"in f&&typeof f.text=="string"?f.text.slice(0,160):f.kind,x=f.kind==="artifact"&&f.artifact?f.artifact:null,j=x&&p?{id:`live-artifact:${x.id}`,name:x.title||x.id,path:k,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:lh(k),path:k,kind:"event",item:f,preview:w,detail:JSON.stringify(f,null,2),children:[]};if(p){i.children.push(j);return}uh(l,k.replace(/^thread-events\//,""),j)};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),$o(s)}function ph(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 _o(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=_o(r);if(n)return n}return null}function Va(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 la,Do,Bo,ia=He({"src/components/graph-workspace/workspaceTree.ts"(){la=new Set(["xyz","extxyz","cif","pdb"]),Do=new Set(["png","jpg","jpeg","gif","webp","svg"]),Bo=new Set(["pdf"])}});function nr({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 Go=He({"src/components/graph-workspace/GraphWorkspaceCards.tsx"(){}});function fh({className:e,decorative:r=!0,orientation:n="horizontal",...a}){return t.jsx(wd,{"data-slot":"separator",decorative:r,orientation:n,className:at("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 gh=He({"src/components/graph-ui/Separator.tsx"(){Pt()}});function xh({className:e,orientation:r,...n}){return t.jsx("div",{role:"group","data-slot":"button-group","data-orientation":r,className:at(Fo({orientation:r}),e),...n})}function bh({className:e,orientation:r="vertical",...n}){return t.jsx(fh,{"data-slot":"button-group-separator",orientation:r,className:at("relative !m-0 self-stretch bg-input data-[orientation=vertical]:h-auto",e),...n})}var Fo,Ho=He({"src/components/graph-ui/ButtonGroup.tsx"(){gh(),Pt(),Fo=Er("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 vh({delayDuration:e=0,...r}){return t.jsx(yd,{"data-slot":"tooltip-provider",delayDuration:e,...r})}function kh({...e}){return t.jsx(vh,{children:t.jsx(gd,{"data-slot":"tooltip",...e})})}function wh({...e}){return t.jsx(xd,{"data-slot":"tooltip-trigger",...e})}function yh({children:e,className:r,sideOffset:n=0,...a}){return t.jsx(bd,{children:t.jsxs(vd,{"data-slot":"tooltip-content",sideOffset:n,className:at("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(kd,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}var jh=He({"src/components/graph-ui/Tooltip.tsx"(){Pt()}});function Nh(e){return(e==null?void 0:e.trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""))||"molecule"}function qa(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 Ye({children:e,disabled:r,label:n,onClick:a}){return t.jsxs(kh,{children:[t.jsx(wh,{asChild:!0,children:t.jsx(Tr,{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(yh,{children:t.jsx("p",{children:n})})]})}function Hn({children:e,className:r=""}){return t.jsx(xh,{className:`thread-graph-molecule-button-group ${r}`,children:e})}var Oo=He({"src/components/graph-workspace/GraphMoleculeViewerControls.tsx"(){sn(),Ho(),jh()}});function Ch({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(Hn,{children:[t.jsx(Ye,{label:"Distance",children:t.jsx($.AlignVerticalDistributeCenter,{className:"size-4"})}),t.jsx(Ye,{label:"Connectivity",children:t.jsx($.Share2,{className:"size-4"})}),t.jsx(Ye,{label:"Angle",children:t.jsx($.Waypoints,{className:"size-4"})}),t.jsx(Ye,{label:"Dihedral",children:t.jsx($.Spline,{className:"size-4"})}),t.jsx(Ye,{label:"Add dummy atoms",children:t.jsx($.Bubbles,{className:"size-4"})}),t.jsx(Ye,{label:"Delete atoms",children:t.jsx($.CircleX,{className:"size-4"})}),t.jsx(Ye,{label:"Rotate",children:t.jsx($.Rotate3d,{className:"size-4"})})]}),t.jsxs(Hn,{children:[t.jsx(Ye,{label:f?"Hide unit cell":"Show unit cell",disabled:!m,onClick:l,children:t.jsx($.Boxes,{className:"size-4"})}),t.jsx(Ye,{label:"Clear selection",disabled:!p,onClick:r,children:t.jsx($.Trash2,{className:"size-4"})}),t.jsx(Ye,{label:"Send selection",disabled:!p,onClick:a,children:t.jsx($.Send,{className:"size-4"})}),t.jsx(Ye,{label:"Stage current selection",disabled:!p,onClick:o,children:t.jsx($.Box,{className:"size-4"})}),t.jsx(Ye,{label:"Clear staged selections",disabled:!g,onClick:n,children:t.jsx($.Eraser,{className:"size-4"})}),t.jsx(Ye,{label:"Send staged selections",disabled:!g,onClick:s,children:t.jsx($.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(k=>`${i[k]??"Atom"}(${k})`).join(", "):"None"]}),t.jsxs("div",{children:["Staged: ",u," molecule(s), ",h," atom(s)"]})]})]}):null]})}var Sh=He({"src/components/graph-workspace/GraphMoleculeViewerLowerButtonGroup.tsx"(){Oo()}});function Th({currentIndex:e,exportContent:r,moleculeId:n,onScreenshot:a,viewerRef:s,xyzContent:o,xyzFormat:l}){const i=Nh(n);async function d(){o&&await navigator.clipboard.writeText(o)}function h(){o&&qa(o,`${i}_step_${e+1}.${l||"xyz"}`)}function u(){r&&qa(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(Hn,{className:"ml-auto justify-end",children:[t.jsx(Ye,{label:"Copy current structure",onClick:()=>void d(),disabled:!o,children:t.jsx($.Copy,{className:"size-3.5"})}),t.jsx(Ye,{label:"Download current structure",onClick:h,disabled:!o,children:t.jsx($.Download,{className:"size-3.5"})}),t.jsx(Ye,{label:"Download full trajectory",onClick:u,disabled:!r,children:t.jsx($.Box,{className:"size-3.5"})}),t.jsx(Ye,{label:"Copy screenshot",onClick:a,disabled:!s.current||!o,children:t.jsx($.Camera,{className:"size-3.5"})}),t.jsx(bh,{className:"thread-graph-molecule-button-divider"}),t.jsx(Ye,{label:"Zoom in",onClick:m,disabled:!s.current||!o,children:t.jsx($.ZoomIn,{className:"size-3.5"})}),t.jsx(Ye,{label:"Zoom out",onClick:f,disabled:!s.current||!o,children:t.jsx($.ZoomOut,{className:"size-3.5"})}),t.jsx(Ye,{label:"Reset camera",onClick:p,disabled:!s.current||!o,children:t.jsx($.RotateCcw,{className:"size-3.5"})})]})}var Eh=He({"src/components/graph-workspace/GraphMoleculeViewerUpperButtonGroup.tsx"(){Ho(),Oo()}});async function Lh(){if(typeof window>"u")throw new Error("3Dmol is only available in a browser environment.");return window["3Dmol"]?window["3Dmol"]:(Hr||(Hr=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)})),Hr)}var Hr,Ih=He({"src/components/graph-workspace/load3Dmol.ts"(){Hr=null}});function zh({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(ud,{"data-slot":"slider",...r!==void 0?{defaultValue:r}:{},...s!==void 0?{value:s}:{},min:a,max:n,className:at("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(md,{"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(pd,{"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(fd,{"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=He({"src/components/graph-ui/Slider.tsx"(){Pt()}});function Rh(e){const r=e==null?void 0:e.trim().toLowerCase();return!r||r==="extxyz"?"xyz":r}function Ah(e){var s,o;const r=e.replace(/\r\n/g,`
5
5
  `).replace(/\r/g,`
6
6
  `).split(`
7
- `),n=[];let a=0;for(;a<r.length;){for(;a<r.length&&((o=r[a])==null?void 0:o.trim())==="";)a+=1;if(a>=r.length)break;const l=Number.parseInt(((s=r[a])==null?void 0:s.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(`
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 Va(e,r){return r!=="xyz"?e:e.flatMap(n=>zh(n))}function qa(e){return e.map(r=>`${r.replace(/\s+$/g,"")}
10
- `).join("")}function Ph(e){if(!e)return{format:"xyz",frames:[],exportContent:""};if(typeof e=="string"){const o=Va([e],"xyz");return{frames:o,format:"xyz",exportContent:qa(o)}}const r=Ih(e.format),n=e.content.filter(o=>o.trim().length>0);return{frames:Va(n,r),format:r,exportContent:qa(n)}}var Rh=He({"src/components/graph-workspace/GraphMoleculeViewerData.ts"(){}});function Mh({className:e="",moleculeId:r=null,onScreenshot:n,onSelectionChange:a,source:o,title:s="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,w]=c.useState(null),[x,j]=c.useState(!1),[y,v]=c.useState({}),[k,S]=c.useState([]),[N,L]=c.useState({}),[R,P]=c.useState(!1),[Q,D]=c.useState(!1),[Z,J]=c.useState(null),z=c.useMemo(()=>Ph(o),[o]),te=z.frames,se=z.format,$=te[p]??null,le=te.length>0&&p===te.length-1,q=r??"current",H=Object.values(N).reduce((E,C)=>E+C.length,0),G=Object.keys(N).length;c.useEffect(()=>{if(te.length===0){g(0);return}g(te.length-1)},[te.length]),c.useEffect(()=>{if(!x||te.length<=1)return;const E=window.setInterval(()=>{g(C=>C>=te.length-1?(window.clearInterval(E),j(!1),C):C+1)},200);return()=>window.clearInterval(E)},[x,te.length]),c.useEffect(()=>{const E=l.current;if(!E||i.current)return;let C=!1;try{const U=document.createElement("canvas");if(!(U.getContext("webgl2")||U.getContext("webgl")||U.getContext("experimental-webgl"))){J("WebGL is unavailable in this browser environment. Unable to render 3D viewer.");return}}catch{J("WebGL is unavailable in this browser environment. Unable to render 3D viewer.");return}const W=()=>{var U,ne;(U=i.current)==null||U.resize(),(ne=i.current)==null||ne.render()};return Sh().then(U=>{if(!(C||i.current))try{const ne=U.createViewer(E,{});i.current=ne,ne.setBackgroundColor("#f8fafc",.8),window.addEventListener("resize",W),window.setTimeout(W,100)}catch(ne){console.error("Failed to initialize 3Dmol viewer:",ne),J("Failed to initialize 3D viewer. Please refresh or try another browser.")}}).catch(U=>{console.error("Failed to load 3Dmol viewer runtime:",U),J("Failed to load 3D viewer runtime. Please refresh or try another browser.")}),()=>{C=!0,window.removeEventListener("resize",W),i.current=null,d.current=null}},[]),c.useEffect(()=>{const E=i.current;if(!(!E||!$))try{E.removeAllModels(),E.removeAllShapes(),E.removeAllLabels();const C=E.addModel($,se||"xyz");d.current=C,C.setStyle({},{stick:{radius:.2},sphere:{scale:.3}});const W=C.getCrystData(),U=!!(W&&typeof W=="object"&&Object.keys(W).length);P(U),D(U?u.current:!1),S([]),v({});const ne=$.split(`
11
- `).slice(2).map(K=>K.trim()).filter(Boolean).map(K=>K.split(/\s+/)[0]??"Atom");h.current||(E.zoomTo(),h.current=!0),C.setClickable({},!0,(K,ie,ee)=>{const ve=K.serial??K.index;if(ve===void 0)return;const oe=K.atom||K.elem||ne[ve]||"Atom";S(ye=>{const de=!!(ee!=null&&ee.shiftKey||ee!=null&&ee.metaKey||ee!=null&&ee.ctrlKey)?ye.includes(ve)?ye.filter(Ce=>Ce!==ve):[...ye,ve]:ye.length===1&&ye[0]===ve?[]:[ve];return v(Ce=>{if(de.length===0)return{};const Ee={};return de.forEach(Y=>{Ee[Y]=Ce[Y]||ne[Y]||oe}),Ee}),de})}),C.setHoverable({},!0,(K,ie,ee)=>{!ee||!K||w({x:ee.clientX,y:ee.clientY,label:`${K.atom||K.elem||"Atom"} (${K.serial??K.index??"?"})`,coords:{x:K.x.toFixed(2),y:K.y.toFixed(2),z:K.z.toFixed(2)}})},()=>w(null)),E.render()}catch(C){console.error("Failed to render molecule:",C),J("Unable to render this molecular structure.")}},[$,se]),c.useEffect(()=>{const E=i.current,C=d.current;if(!(!E||!C)){try{E.removeUnitCell(C)}catch{}if(Q&&R)try{E.addUnitCell(C,{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{P(!1),D(!1)}E.render()}},[R,Q,$,se]),c.useEffect(()=>{const E=i.current,C=d.current;!E||!C||!$||(C.setStyle({},{stick:{radius:.2},sphere:{scale:.3}}),k.length>0&&C.setStyle({serial:k},{stick:{radius:.3,color:"yellow"},sphere:{scale:.4,color:"yellow"}}),E.render(),a==null||a({moleculeId:r,atoms:k}))},[r,a,k,$]),c.useEffect(()=>{if(!$)return;let E=0;const C=()=>{var U,ne;const W=(ne=(U=i.current)==null?void 0:U.getView)==null?void 0:ne.call(U);if(Array.isArray(W)&&W.length>=8){const[K,ie,ee,ve,oe,ye,Me,de]=W;if(typeof K=="number"&&typeof ie=="number"&&typeof ee=="number"&&typeof ve=="number"&&typeof oe=="number"&&typeof ye=="number"&&typeof Me=="number"&&typeof de=="number"){const Ce=Math.sqrt(oe*oe+ye*ye+Me*Me),Ee=Ce>0?{x:oe/Ce,y:ye/Ce,z:Me/Ce}:{x:0,y:0,z:0};f({position:{x:K,y:ie,z:ee,qx:oe,qy:ye,qz:Me,qw:de},lookAt:Ee,zoom:ve})}}E=window.requestAnimationFrame(C)};return E=window.requestAnimationFrame(C),()=>window.cancelAnimationFrame(E)},[$]);const T=c.useCallback(async()=>{const E=i.current;if(!(E!=null&&E.pngURI))return;E.render();const C=E.pngURI();if(C){try{const U=await(await fetch(C)).blob(),ne=new ClipboardItem({[U.type||"image/png"]:U});await navigator.clipboard.write([ne])}catch{}n==null||n({moleculeId:r,image:C})}},[r,n]);function F(){R&&D(E=>{const C=!E;return u.current=C,C})}function B(){k.length!==0&&L(E=>{const C=E[q]??[];return{...E,[q]:Array.from(new Set([...C,...k]))}})}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:s}),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:[Z?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:Z}):null,!Z&&!$?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(Nh,{currentIndex:p,exportContent:z.exportContent,moleculeId:r,onScreenshot:()=>void T(),viewerRef:i,xyzContent:$,xyzFormat:se})]}),te.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," / ",te.length,t.jsx(Nr,{type:"button",variant:"ghost",size:"icon",className:"thread-graph-molecule-button h-5 w-5",onClick:()=>{j(E=>{const C=!E;return C&&p===te.length-1&&g(0),C})},"aria-label":x?"Pause trajectory":"Play trajectory",title:x?"Pause trajectory":"Play trajectory",children:x&&p!==te.length-1?t.jsx(_.Pause,{className:"h-3 w-3"}):t.jsx(_.Play,{className:"h-3 w-3"})})]}),t.jsxs(Nr,{type:"button",variant:"ghost",onClick:()=>g(te.length-1),className:"thread-graph-molecule-live-button",children:[t.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${le?"animate-pulse bg-red-600":"bg-gray-300"}`}),"Live"]})]}),t.jsx(Eh,{value:[p],max:te.length-1,step:1,onValueChange:E=>g(E[0]??0),"aria-label":"Trajectory frame"})]}):null,t.jsx(yh,{cameraInfo:m,onClearSelection:()=>S([]),onClearStaged:()=>L({}),onSendSelection:()=>a==null?void 0:a({moleculeId:r,atoms:k}),onSendStaged:()=>{Object.entries(N).forEach(([E,C])=>{a==null||a({moleculeId:E==="current"?r:E,atoms:C})})},onStageSelection:B,onToggleUnitCell:F,selectedAtomLabels:y,selectedSerials:k,stagedAtoms:H,stagedMolecules:G,unitCellAvailable:R,unitCellVisible:Q})]})]})]})}var Ah=He({"src/components/graph-workspace/GraphMoleculeViewer.tsx"(){jh(),Ch(),Th(),rn(),Lh(),Rh()}});function _h(e){return!e.truncated&&e.size<=Fo&&e.content.split(`
12
- `).length<=Ho}function $h(e){return e&&(e.node.path||e.node.name)||null}function Dh(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 Bh({error:e,imageUrl:r,loadingMore:n,onSaveFile:a,onLoadMore:o,onCollapse:s,pdfUrl:l,previewFile:i,previewLoading:d,plugins:h,selectedTarget:u}){const[m,f]=c.useState(!1),[p,g]=c.useState(""),[b,w]=c.useState(null),[x,j]=c.useState(!1),y=(u==null?void 0:u.node)??null,v=y!=null&&y.artifact?h.renderArtifact({artifact:y.artifact,expanded:!0,onToggleExpanded:()=>{}}):null,k=oh(i??null),S=(i==null?void 0:i.language)||lh((i==null?void 0:i.path)??""),N=i?Ir(i.path):"",L=$h(u),R=i!==null&&sa.has(N),P=!!(i&&a)&&!R&&_h(i),Q=(u==null?void 0:u.kind)==="live-molecule",D=!!(y!=null&&y.artifact&&v),Z=!!k||D;c.useEffect(()=>{f(!1),g((i==null?void 0:i.content)??""),w(null)},[i==null?void 0:i.path,i==null?void 0:i.content]);async function J(){if(!(!i||!a)){j(!0),w(null);try{await a({path:i.path,content:p}),f(!1)}catch(z){w(z instanceof Error?z.message:"Failed to save file.")}finally{j(!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]}),s?t.jsx("button",{type:"button",onClick:s,"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(_.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"&&k?t.jsx("div",{className:"thread-graph-molecule-preview min-h-0 flex-1 overflow-hidden",children:t.jsx(Mh,{source:k,moleculeId:k.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:[R?"molecule":S||N||"text"," |"," ",i.size.toLocaleString()," bytes",i.truncated?t.jsxs("span",{className:"ml-2 text-amber-500",children:["showing ",i.nextOffset.toLocaleString()," bytes"]}):null]}),P?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),w(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(_.X,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:()=>void J(),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(_.Save,{className:"h-4 w-4"})})]}):t.jsx("button",{type:"button",onClick:()=>{g(i.content),f(!0),w(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(_.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:z=>g(z.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(Fr,{content:i.content}),i.truncated&&o?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:o,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:Z||Q?"min-h-0 flex-1 overflow-hidden":"min-h-0 flex-1 overflow-auto p-3",children:v}):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(rr,{label:"Workspace Data",children:t.jsx(Fr,{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(Fr,{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 Fo,Ho,Fr,Gh=He({"src/components/graph-workspace/GraphWorkspacePreviewPane.tsx"(){oa(),$o(),Ah(),Fo=50*1024,Ho=1e3,Fr=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 Fh({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 Hh=He({"src/components/graph-workspace/GraphEmptyGarbageDialog.tsx"(){}});function Oo(e){return`${Uo}${e.workspaceId??"workspace"}:${e.threadId}`}function Oh(e){if(typeof window>"u")return[];try{const r=window.localStorage.getItem(Oo(e));if(!r)return[];const n=JSON.parse(r);return Array.isArray(n)?n.filter(a=>typeof a=="string"):[]}catch{return[]}}function Ka(e,r){if(!(typeof window>"u"))try{window.localStorage.setItem(Oo(e),JSON.stringify([...r]))}catch{}}function Gn(e,r){if(!r||e.path!==r.path||e.kind!=="directory")return e;const n=new Map(r.children.map(s=>[s.path,s])),a=e.children.map(s=>Gn(s,n.get(s.path)??null)),o=e.childrenLoaded&&e.children.length>0;return{...e,children:o||!r.childrenLoaded?a:r.children,childrenLoaded:e.childrenLoaded||r.childrenLoaded,truncated:e.truncated??r.truncated}}function Xa(e,r){if(e.kind==="directory")return r?t.jsx(_.FolderOpen,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"}):t.jsx(_.Folder,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"});const n=Ir(e.name);return n==="zip"?t.jsx(_.FileArchive,{className:"h-4 w-4 text-amber-600"}):e.kind==="file"&&["png","jpg","jpeg","gif","webp","svg"].includes(n)?t.jsx(_.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(_.FileCode2,{className:"h-4 w-4 text-emerald-600"}):t.jsx(_.File,{className:"h-4 w-4 text-slate-400 dark:text-slate-500"})}function Wo({depth:e,expandedPaths:r,loadingPaths:n,node:a,onCopyPath:o,onDownload:s,onPreview:l,onSelect:i,onToggle:d,selectedNodeId:h}){const u=a.kind==="directory",m=u&&(a.path===""||r.has(a.path)),f=u&&n.has(a.path),p=h===a.id,g=`${e*.75+.5}rem`;return u?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:()=>d(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:g},children:[m?t.jsx(_.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}):t.jsx(_.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}),Xa(a,m),t.jsx("span",{className:"truncate",children:a.name}),f?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(_.Download,{className:"h-3.5 w-3.5"})}):null,o&&a.path?t.jsx("button",{type:"button",onClick:()=>o(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:`Copy path for ${a.name}`,"aria-label":`Copy path for ${a.name}`,children:t.jsx(_.Copy,{className:"h-3.5 w-3.5"})}):null]}),m?t.jsxs("div",{children:[a.children.map(b=>t.jsx(Wo,{depth:e+1,expandedPaths:r,loadingPaths:n,node:b,...o?{onCopyPath:o}:{},...s?{onDownload:s}:{},...l?{onPreview:l}:{},onSelect:i,onToggle:d,selectedNodeId:h},b.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 ${p?"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:()=>i(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:[Xa(a,!1),t.jsx("span",{className:"truncate",children:a.name})]}),a.kind==="file"&&(l||s||o)?t.jsxs("div",{className:"mr-1 flex shrink-0 items-center gap-0.5",children:[l?t.jsx("button",{type:"button",onClick:()=>l(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 ${p?"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(_.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 ${p?"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(_.Download,{className:"h-3.5 w-3.5"})}):null,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 ${p?"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:`Copy path for ${a.name}`,"aria-label":`Copy path for ${a.name}`,children:t.jsx(_.Copy,{className:"h-3.5 w-3.5"})}):null]}):null]})}function Wh({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 s;const o=n===a.id;return t.jsxs("button",{type:"button","data-testid":"live-molecule-item","data-molecule-id":((s=a.artifact)==null?void 0:s.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 ${o?"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(_.FileCode2,{className:`h-4 w-4 shrink-0 ${o?"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 Uh({canEmptyGarbage:e,canUpload:r,onCollapse:n,expandedPaths:a,loadingPaths:o,loading:s,onDownload:l,onCopyPath:i,onEmptyGarbage:d,onPreview:h,onRefresh:u,onSelect:m,onToggle:f,onUpload:p,explorerScrollTopRef:g,explorerScrollerRef:b,selectedNodeId:w,tree:x,liveNodes:j}){const y=c.useMemo(()=>({...x,children:x.children.filter(v=>v.path!=="live")}),[x]);return c.useLayoutEffect(()=>{const v=b.current;v&&(v.scrollTop=g.current)},[b,g]),t.jsxs("aside",{className:`${Vo} flex flex-col`,children:[t.jsxs("div",{className:qo,children:[t.jsx("div",{className:"min-w-0",children:t.jsx("h2",{className:Ko,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:Xo,title:"Collapse Explorer","aria-label":"Collapse Explorer",children:[t.jsx(_.ChevronsLeft,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Collapse Explorer"})]}):null,t.jsx("button",{type:"button",onClick:p,disabled:!r,className:Or,title:r?"Upload file":"Upload is unavailable for this workspace","aria-label":"Upload file",children:t.jsx(_.Upload,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:u,className:Or,title:"Refresh workspace","aria-label":"Refresh workspace",children:t.jsx(_.RefreshCw,{className:`h-4 w-4 ${s?"animate-spin":""}`})}),d?t.jsx("button",{type:"button",onClick:d,disabled:!e,className:Or,title:e?"Empty garbage":"Garbage controls are unavailable","aria-label":"Empty garbage",children:t.jsx(_.Trash2,{className:"h-4 w-4"})}):null]})]}),t.jsxs("div",{ref:b,className:"thread-graph-workspace-tree-scroll min-h-0 flex-1 overflow-y-auto py-2",onScroll:v=>{g.current=v.currentTarget.scrollTop},children:[t.jsx(Wh,{liveNodes:j??[],onSelect:m,selectedNodeId:w}),t.jsx("div",{className:Yo,children:"Workspace"}),t.jsx(Wo,{depth:0,expandedPaths:a,loadingPaths:o,node:y,...i?{onCopyPath:i}:{},...l?{onDownload:l}:{},...h?{onPreview:h}:{},onSelect:m,onToggle:f,selectedNodeId:w}),y.children.length===0?t.jsx("p",{className:Zo,children:"This workspace is empty. Agent tool runs execute inside the thread workspace, so files should appear here as the session works."}):null]})]})}function Vh({activeView:e,detail:r,artifacts:n,plugins:a,status:o,focusPathRequest:s,workspaceAdapter:l}){const[i,d]=c.useState(null),h=c.useMemo(()=>l&&i?null:Oa(r,n),[e,i,n,r,o,l]),u=i??h??Oa(r,n),m=c.useMemo(()=>hh(u),[u]),f=c.useMemo(()=>{var I;return((I=u.children.find(O=>O.path==="live"))==null?void 0:I.children)??[]},[u]),p=Mo(u),[g,b]=c.useState(()=>(p==null?void 0:p.id)??null),[w,x]=c.useState(()=>new Set(["","artifacts","thread-events","live",...Wa((p==null?void 0:p.path)??"")])),[j,y]=c.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 639px)").matches?"viewer":null),[v,k]=c.useState(null),[S,N]=c.useState(!1),[L,R]=c.useState(()=>new Set),[P,Q]=c.useState(!1),[D,Z]=c.useState(!1),[J,z]=c.useState(!1),[te,se]=c.useState([]),[$,le]=c.useState(null),[q,H]=c.useState(null),[G,T]=c.useState(null),[F,B]=c.useState(!1),E=c.useRef(null),C=c.useRef(null),W=c.useRef(0),U=c.useRef(null),ne=!!l,K=(g?m.get(g):null)??p??null,ie={threadId:r.thread.id,workspaceId:r.workspace.id??r.thread.workspaceId??null};c.useEffect(()=>{W.current=0,U.current=null,x(new Set(["","artifacts","thread-events","live",...Oh(ie),...Wa((p==null?void 0:p.path)??"")]))},[ie.threadId,ie.workspaceId]);function ee(){var O;const I=((O=C.current)==null?void 0:O.scrollTop)??W.current;W.current=I,U.current=I}function ve(){const I=U.current??W.current;if(!C.current)return;let ae=0;const be=()=>{const je=C.current;je&&(je.scrollTop=Math.min(I,Math.max(0,je.scrollHeight-je.clientHeight)),W.current=je.scrollTop,ae+=1,ae<8?window.requestAnimationFrame(be):U.current=null)};window.requestAnimationFrame(be)}c.useLayoutEffect(()=>{j!=="explorer"&&ve()},[j,u]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const I=window.matchMedia("(max-width: 639px)"),O=()=>B(I.matches);return O(),typeof I.addEventListener=="function"?(I.addEventListener("change",O),()=>I.removeEventListener("change",O)):(I.addListener(O),()=>I.removeListener(O))},[]);async function oe(I){if(!l)return;const O=I??(K==null?void 0:K.path)??null;N(!0),k(null);try{const ae=tr(await l.listTree({...ie,path:""}));let be=i?Gn(ae,i):ae;if(i){const Te=[...w].filter(fe=>fe).sort((fe,Be)=>fe.split("/").length-Be.split("/").length);for(const fe of Te){const Be=_n(i,fe);if((Be==null?void 0:Be.kind)!=="directory"||!Be.childrenLoaded)continue;const _e=tr(await l.listTree({...ie,path:fe}));be=$n(be,fe,Gn(_e,Be))}}d(be);const je=zo(be);b(Te=>{var Be;const fe=O??(Te?(Be=m.get(Te))==null?void 0:Be.path:null);return fe&&Dn(be,fe)?`workspace:${fe}`:(je==null?void 0:je.id)??Te})}catch(ae){k(ae instanceof Error?ae.message:"Failed to load workspace"),d(null)}finally{N(!1)}}async function ye(I){if(!(!l||!i)){R(O=>{if(O.has(I))return O;const ae=new Set(O);return ae.add(I),ae}),k(null);try{const O=tr(await l.listTree({...ie,path:I}));d(ae=>ae&&Io(ae,I,O.children,{truncated:O.truncated}))}catch(O){k(O instanceof Error?O.message:"Failed to load directory")}finally{R(O=>{if(!O.has(I))return O;const ae=new Set(O);return ae.delete(I),ae})}}}async function Me(I){const O=Po(I);if(!O)return;const ae=sh(O);if(y(null),x(be=>{const je=new Set(be);je.add("");for(const Te of ae)je.add(Te);return Ka(ie,je),je}),!l){Dn(u,O)&&b(`workspace:${O}`);return}N(!0),k(null);try{let be=i??tr(await l.listTree({...ie,path:""}));for(const je of ae){const Te=_n(be,je);if((Te==null?void 0:Te.kind)==="directory"&&Te.childrenLoaded)continue;const fe=tr(await l.listTree({...ie,path:je}));be=$n(be,je,fe)}d(be),b(`workspace:${O}`)}catch(be){k(be instanceof Error?be.message:`Failed to open ${O}`)}finally{N(!1)}}c.useEffect(()=>{if(!(!l||!i))for(const I of m.values())I.path&&I.kind==="directory"&&w.has(I.path)&&I.hasChildren&&!I.childrenLoaded&&!L.has(I.path)&&ye(I.path)},[i,w,m,l]),c.useEffect(()=>{d(null),R(new Set),le(null),H(null),T(null),k(null),oe()},[ne,r.thread.id,r.workspace.id,r.thread.workspaceId]),c.useEffect(()=>{s&&Me(s.path)},[s==null?void 0:s.requestId]),c.useEffect(()=>{l!=null&&l.subscribeWorkspaceChanged},[l,ie.threadId,ie.workspaceId]),c.useEffect(()=>{const I=l&&(K==null?void 0:K.kind)==="file"?K.path:null;if(!I){le(null),H(null),T(null);return}const O=I;let ae=!1;async function be(){var je;if(l){Q(!0),k(null),le(null),H(null),T(null);try{const Te=Ir(O),fe=(je=l.getRawFileUrl)==null?void 0:je.call(l,{...ie,path:O});if(fe&&Ao.has(Te)){ae||H(fe);return}if(fe&&_o.has(Te)){ae||T(fe);return}const Be=await l.readFile({...ie,path:O,limit:Hr});ae||le(Be)}catch(Te){ae||k(Te instanceof Error?Te.message:"Failed to read file")}finally{ae||Q(!1)}}}return be(),()=>{ae=!0}},[l,K==null?void 0:K.id]);async function de(){if(!(!l||!($!=null&&$.truncated))){Z(!0);try{const I=await l.readFile({...ie,path:$.path,offset:$.nextOffset,limit:Hr});le(O=>O&&{...O,content:O.content+I.content,truncated:I.truncated,nextOffset:I.nextOffset,size:I.size})}finally{Z(!1)}}}async function Ce(I){if(!(l!=null&&l.writeFile))return;k(null),await l.writeFile({...ie,path:I.path,content:I.content}),await oe(I.path);const O=await l.readFile({...ie,path:I.path,limit:Hr});le(O)}async function Ee(I){if(!(!(l!=null&&l.uploadFile)||!I)){N(!0),k(null);try{const O=await l.uploadFile({...ie,path:I.name,file:I}),ae=O.kind==="archive"?O.paths[0]??null:O.file.path;await oe(ae)}catch(O){k(O instanceof Error?O.message:"Failed to upload file")}finally{N(!1)}}}async function Y(I){var ae;const O=(ae=I.target.files)==null?void 0:ae[0];I.target.value="",O&&await Ee(O)}function ue(){if(!(l!=null&&l.uploadFile))return;const I=()=>{var O;return(O=E.current)==null?void 0:O.click()};if(l.pickUploadFile){l.pickUploadFile({...ie,defaultPick:I,upload:Ee});return}I()}function ke(I){var O;(O=l==null?void 0:l.downloadNode)==null||O.call(l,{...ie,path:I.path,kind:I.kind==="directory"?"directory":"file"})}function we(I){if(!I.path||typeof navigator>"u"||!navigator.clipboard)return;const O=r.workspace.absPath.replace(/\/+$/,""),ae=I.path.startsWith("/")?I.path:O?`${O}/${I.path.replace(/^\/+/,"")}`:I.path;navigator.clipboard.writeText(ae).catch(be=>{k(be instanceof Error?be.message:"Failed to copy file path")})}function De(I){I.kind==="file"&&(ee(),b(I.id),y("explorer"))}async function Fe(){if(l!=null&&l.emptyGarbage){if(k(null),!l.listGarbage){se([]),z(!0);return}try{const I=await l.listGarbage(ie);se(I.map(O=>`garbage/${O}`))}catch(I){se([]),k(I instanceof Error?I.message:"Failed to list garbage files")}finally{z(!0)}}}async function Ae(){if(l!=null&&l.emptyGarbage){z(!1),k(null);try{await l.emptyGarbage(ie),await oe((K==null?void 0:K.path)??null)}catch(I){k(I instanceof Error?I.message:"Failed to empty garbage")}}}const Oe={onCopyPath:we,...l!=null&&l.downloadNode?{onDownload:ke}:{},...l!=null&&l.emptyGarbage?{onEmptyGarbage:Fe}:{},...l?{onRefresh:()=>void oe((K==null?void 0:K.path)??null)}:{},...l!=null&&l.uploadFile?{onUpload:ue}:{}};function V(I){if(!I)return;const O=m.get(`workspace:${I}`),ae=(O==null?void 0:O.kind)==="directory"&&O.hasChildren&&!O.childrenLoaded&&!L.has(I);x(be=>{const je=new Set(be);return je.has(I)?je.delete(I):je.add(I),Ka(ie,je),je}),!w.has(I)&&ae&&ye(I)}const ce=t.jsx(Uh,{canEmptyGarbage:!!(l!=null&&l.emptyGarbage),canUpload:!!(l!=null&&l.uploadFile),onCollapse:()=>{ee(),y("explorer")},expandedPaths:w,loadingPaths:L,loading:S,explorerScrollTopRef:W,explorerScrollerRef:C,...Oe,onPreview:De,onSelect:I=>{b(I)},onToggle:V,selectedNodeId:(K==null?void 0:K.id)??null,tree:u,liveNodes:f}),xe=t.jsx(Bh,{error:v,imageUrl:q,loadingMore:D,onLoadMore:de,...l!=null&&l.writeFile?{onSaveFile:Ce}:{},onCollapse:()=>{ee(),y("viewer")},pdfUrl:G,previewFile:$,previewLoading:P,plugins:a,selectedTarget:Dh(K)});return j==="explorer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:xe}):j==="viewer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:ce}):t.jsxs("div",{"data-testid":"workspace-panel",className:"flex h-full min-h-0 w-full overflow-hidden bg-transparent p-2",children:[J?t.jsx(Fh,{files:te,onCancel:()=>z(!1),onConfirm:()=>void Ae()}):null,F?t.jsxs(Mn,{direction:"vertical",className:"thread-graph-workspace-mobile-stack",children:[t.jsx(sr,{defaultSize:42,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-explorer h-full min-h-0 overflow-hidden",children:ce})}),t.jsx(An,{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(sr,{defaultSize:58,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-viewer h-full min-h-0 overflow-hidden",children:xe})})]}):t.jsxs(Mn,{direction:"horizontal",className:"thread-graph-workspace-resizable",children:[t.jsx(sr,{defaultSize:33,minSize:20,children:t.jsx("div",{className:"thread-graph-workspace-explorer-pane h-full min-h-0 overflow-hidden",children:ce})}),t.jsx(An,{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(sr,{defaultSize:67,minSize:30,children:t.jsx("div",{className:"thread-graph-workspace-viewer-pane h-full min-h-0 overflow-hidden",children:xe})})]}),t.jsx("input",{ref:E,type:"file","aria-label":"Workspace upload file input","data-testid":"workspace-upload-file-input",className:"hidden",onChange:I=>void Y(I)})]})}var Hr,Uo,Vo,qo,Ko,Or,Xo,Yo,Zo,qh=He({"src/components/graph-workspace/GraphWorkspaceExplorer.tsx"(){oa(),Gh(),Hh(),Lo(),Hr=24e3,Uo="remote-codex:graphchat:workspace:expanded:",Vo="thread-graph-explorer h-full min-h-0 overflow-hidden rounded-[12px]",qo="thread-graph-explorer-header flex h-[60px] shrink-0 items-center justify-between border-b px-4",Ko="text-[18px] font-semibold text-slate-900 dark:text-slate-100",Or="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",Xo="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",Yo="thread-graph-workspace-label px-3 pb-1 pt-2 text-[11px] font-semibold tracking-normal text-slate-500 dark:text-slate-400",Zo="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 yn({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 Qt({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 Kh({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 mr({value:e,title:r,icon:n,children:a}){return t.jsxs(Tr,{value:e,className:"thread-guide-section border-b border-[var(--theme-border)] last:border-b-0",children:[t.jsx(nn,{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(Kh,{children:n}),r]})}),t.jsx(Er,{className:"space-y-3 pb-3",children:a})]})}function Xh(){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(Sr,{type:"multiple",defaultValue:["start","workspace","remote-codex"],className:"space-y-0",children:[t.jsxs(mr,{value:"start",title:"Getting Started",icon:t.jsx(_.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(Qt,{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(mr,{value:"workspace",title:"Workspace Explorer",icon:t.jsx(_.FolderOpen,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(_.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(_.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(_.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(_.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(_.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(Qt,{items:[t.jsxs(t.Fragment,{children:[t.jsx(yn,{children:".xyz .extxyz .cif"})," use the 3D molecule plugin."]}),t.jsxs(t.Fragment,{children:[t.jsx(yn,{children:".png .jpg .gif .svg .webp"})," use inline image preview."]}),t.jsxs(t.Fragment,{children:[t.jsx(yn,{children:".py .json .ts .md .csv"})," use text/code preview."]}),"Large files load in chunks when the workspace adapter supports it."]})]})]}),t.jsxs(mr,{value:"viewer",title:"Viewer",icon:t.jsx(_.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(Qt,{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(mr,{value:"usage",title:"Tool Usage & Chat",icon:t.jsx(_.BarChart2,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(_.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(Qt,{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(_.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(Qt,{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(mr,{value:"remote-codex",title:"Remote Codex Extras",icon:t.jsx(_.Code2,{className:"h-3 w-3"}),children:t.jsx(Qt,{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 Yh=He({"src/components/graph-workspace/GraphGuidePanel.tsx"(){Lr()}});function Zh(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 Ya({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:Zh(r)})]})}function Jh({event:e}){return t.jsxs(Tr,{value:e.id,className:"thread-tool-call mb-2 overflow-hidden rounded-lg border border-[var(--theme-border)] last:mb-0",children:[t.jsxs(nn,{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(Er,{className:"px-3 pb-3",children:t.jsxs("div",{className:"space-y-2 px-3 pb-3 pt-1",children:[t.jsx(Ya,{label:"Input",value:e.preview}),t.jsx(Ya,{label:"Output",value:e.detail})]})})]})}function Qh({formatToolKind:e,toolCounts:r,toolEvents:n,maxToolCount:a}){const[o,s]=c.useState(()=>{var i;return((i=n.at(-1))==null?void 0:i.id)??null}),l=c.useRef(null);return c.useEffect(()=>{s(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(_.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(Sr,{type:"single",collapsible:!0,value:o??"",onValueChange:i=>s(i||null),className:"space-y-0",children:n.slice(-50).map(i=>t.jsx(Jh,{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(_.RefreshCw,{className:"h-3 w-3"}),"Reload from workspace"]})]})}var eu=He({"src/components/graph-workspace/GraphToolUsagePanel.tsx"(){Lr()}});function Za(e,r){const n=Math.max(e.measured.width??1,1),a=Math.max(e.measured.height??1,1),o=e.internals.positionAbsolute,s=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=o.x+d,m=o.y+h,f=s.x+l/2,p=s.y+i/2,g=(f-u)/(2*d)-(p-m)/(2*h),b=(f-u)/(2*d)+(p-m)/(2*h),w=1/(Math.abs(g)+Math.abs(b)),x=w*g,j=w*b,y=d*(x+j)+u,v=h*(-x+j)+m;return{x:y,y:v}}function Ja(e,r){const n={...e.internals.positionAbsolute,...e},a=Math.round(n.x),o=Math.round(n.y),s=Math.round(r.x),l=Math.round(r.y);return s<=a+1?Gt.Left:s>=a+(e.measured.width??1)-1?Gt.Right:l<=o+1?Gt.Top:l>=n.y+(e.measured.height??1)-1?Gt.Bottom:Gt.Top}function Jo(e,r){const n=Za(e,r),a=Za(r,e),o=Ja(e,n),s=Ja(r,a);return{sx:n.x,sy:n.y,tx:a.x,ty:a.y,sourcePos:o,targetPos:s}}function tu(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 w=g.id.split("").reduce((x,j)=>{const y=(x<<5)-x+j.charCodeAt(0);return y&y},0);f.set(g.id,{x:Math.abs(w)%u+b*100%u,y:Math.abs(w>>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 w=b+1;w<p;w+=1){const x=d[b],j=d[w];if(!x||!j)continue;const y=f.get(x.id),v=f.get(j.id);if(!y||!v)continue;const k=y.x-v.x,S=y.y-v.y,N=Math.sqrt(k*k+S*S)||1,R=(200-N)*.5,P=k/N*R,Q=S/N*R;y.vx+=P,y.vy+=Q,v.vx-=P,v.vy-=Q}h.forEach(b=>{const w=f.get(b.source),x=f.get(b.target);if(!w||!x)return;const j=x.x-w.x,y=x.y-w.y,v=Math.sqrt(j*j+y*y)||1,S=(v-120)*.3,N=j/v*S,L=y/v*S;w.vx+=N,w.vy+=L,x.vx-=N,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},o=new Set(e.map(d=>d.id)),s=[];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=>{o.has(u)&&s.push({id:`${d.id}-${u}`,source:d.id,target:u,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:Fs.Arrow}})})});const l=a(e,s,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:s}}var la=He({"src/components/graph-chat/FloatingHelper.tsx"(){}});function ru({toX:e,toY:r,fromPosition:n,toPosition:a,fromNode:o}){if(!o)return null;const s={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}=Jo(o,s),[f]=Hs({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 nu=He({"src/components/graph-chat/FloatingConnectionLine.tsx"(){la()}});function au({id:e,source:r,target:n,markerEnd:a,style:o}){const s=Ca(r),l=Ca(n);if(!s||!l)return null;const{sx:i,sy:d,tx:h,ty:u,sourcePos:m,targetPos:f}=Jo(s,l),[p]=Hs({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:o})}var su=He({"src/components/graph-chat/FloatingEdge.tsx"(){la()}});function ou({nodes:e}){const[r,n,a]=wd([]),[o,s,l]=yd([]),i=c.useMemo(()=>tu(e),[e]),d=c.useMemo(()=>({floating:au}),[]),h=c.useMemo(()=>({styledNode:({data:m,isConnectable:f})=>t.jsxs("div",{className:"thread-graph-flow-node",children:[m.label,t.jsx(Na,{type:"target",position:Gt.Top,isConnectable:f,style:{opacity:0,pointerEvents:"none"}}),t.jsx(Na,{type:"source",position:Gt.Bottom,isConnectable:f,style:{opacity:0,pointerEvents:"none"}})]})}),[]);c.useEffect(()=>{n(i.nodes),s(i.edges)},[i.edges,i.nodes,s,n]);const u=c.useCallback(m=>s(f=>jd({...m,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:Fs.Arrow}},f)),[s]);return t.jsx("div",{className:"thread-graph-flow h-full min-h-0",children:t.jsx(Nd,{children:t.jsxs(Cd,{nodes:r,edges:o,onNodesChange:a,onEdgesChange:l,onConnect:u,fitView:!0,nodeTypes:h,edgeTypes:d,connectionLineComponent:ru,children:[t.jsx(Sd,{}),t.jsx(Td,{gap:16})]})})})}var lu=He({"src/components/graph-chat/GraphVisualization.tsx"(){nu(),su(),la()}});function iu(e){return{...el,...e}}function Qa(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 du(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 cu(e){var o;const r=[],n=new Set(["toolCall","commandExecution","webSearch","fileRead","fileChange","agentToolCall","skillToolCall","hook"]);let a=0;for(const s of e.turns)for(const l of s.items)n.has(l.kind)&&(r.push({id:l.id,kind:l.kind,label:Kr(l.kind),preview:l.previewText??l.text??l.kind,detail:l.detailText??l.text??l.previewText??l.kind,turnId:l.sourceTurnId??s.id,status:l.status??null,sequence:a}),a+=1);for(const s of((o=e.liveItems)==null?void 0:o.items)??[])n.has(s.kind)&&(r.push({id:s.id,kind:s.kind,label:Kr(s.kind),preview:s.previewText??s.text??s.kind,detail:s.detailText??s.text??s.previewText??s.kind,turnId:s.sourceTurnId??null,status:s.status??null,sequence:a}),a+=1);return r}function Kr(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 hu(e){switch(e.kind){case"userMessage":return"User";case"agentMessage":return"Agent";default:return Kr(e.kind)}}function uu(e){return(e.previewText??e.text??e.detailText??e.kind).replace(/\s+/g," ").slice(0,96)}function mu(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 s of e.turns){const l=`turn:${s.id}`;n.push({id:l,name:`Turn ${n.filter(d=>d.id.startsWith("turn:")).length+1}`,description:s.status,out_node_id:a?[`thread:${e.thread.id}`,a]:`thread:${e.thread.id}`}),a=l;let i=null;for(const d of s.items){const h=`item:${d.id}`,u=[l];i&&u.push(i),n.push({id:h,name:hu(d),description:uu(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 o=new Set(n.map(s=>s.id));for(const s of r){const l=`tool:${s.id}`;o.has(l)||o.has(`item:${s.id}`)||n.push({id:l,name:s.label,description:s.preview,out_node_id:s.turnId?`turn:${s.turnId}`:`thread:${e.thread.id}`})}return n.slice(0,120)}function Qo({detail:e,status:r,plugins:n,workspaceAdapter:a,metaContent:o,settingsContent:s,activeView:l="chat",features:i,focusPathRequest:d=null}){const h=c.useMemo(()=>iu(i),[i]),u=Qa(h,i==null?void 0:i.defaultTab),[m,f]=c.useState(u),p=c.useMemo(()=>rh(e),[e]),g=c.useMemo(()=>cu(e),[e]),b=c.useMemo(()=>{const k=new Map;for(const S of g)k.set(S.kind,(k.get(S.kind)??0)+1);return[...k.entries()].sort((S,N)=>N[1]-S[1])},[g]),w=n.getThreadPanels(),x=Math.max(...b.map(([,k])=>k),1),j=c.useMemo(()=>mu(e,g),[e,g]),y=c.useMemo(()=>{const k=[];return h.workspace&&k.push({id:"workspace",label:"Workspace",icon:null}),h.toolUsage&&k.push({id:"tools",label:"Tool Usage",icon:_.BarChart2}),h.guide&&k.push({id:"guide",label:"Guide",icon:_.BookOpen}),k},[h.guide,h.toolUsage,h.workspace]),v=c.useMemo(()=>{const k=[];return h.threadGraph&&k.push({id:"graph",label:"Thread graph",icon:_.GitBranch}),h.extensions&&k.push({id:"extensions",label:"Remote Codex extensions",icon:_.Wrench}),k},[h.extensions,h.threadGraph]);return c.useEffect(()=>{(!m||!du(h,m))&&f(Qa(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:[y.map(k=>{const S=k.icon;return t.jsxs("button",{type:"button",onClick:()=>f(k.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===k.id?"is-active":""}`,children:[S?t.jsx(S,{className:"h-3.5 w-3.5"}):null,k.label]},k.id)}),v.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:v.map(k=>{const S=k.icon;return t.jsx("button",{type:"button",onClick:()=>f(k.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===k.id?"is-active":""}`,title:k.label,"aria-label":k.label,children:t.jsx(S,{className:"h-3.5 w-3.5"})},k.id)})}):null]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[m==="workspace"?t.jsx(Vh,{activeView:l,detail:e,artifacts:p,plugins:n,status:r,focusPathRequest:d,workspaceAdapter:a??null}):null,m==="tools"?t.jsx(Qh,{formatToolKind:Kr,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(ou,{nodes:j})}):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(rr,{label:"Plugin Panels",children:w.length?t.jsx("div",{className:"flex flex-wrap gap-2",children:w.map(k=>t.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-1 text-xs text-[var(--theme-fg-soft)]",children:k.label},k.id))}):t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"No thread panels are enabled."})}),t.jsx(rr,{label:"Enabled Renderers",children:t.jsx("div",{className:"flex flex-wrap gap-2",children:n.plugins.filter(k=>k.enabled).map(k=>t.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-1 text-xs text-[var(--theme-fg-soft)]",children:k.name},k.id))})}),t.jsx(rr,{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(_.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(_.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(_.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."})]})]})}),o?t.jsx(rr,{label:"Thread Meta",children:o}):null,s?t.jsx(rr,{label:"Settings",children:s}):null]})}):null,m==="guide"?t.jsx(Xh,{}):null]})]}):null}var el,tl,pu=He({"src/components/ThreadGraphWorkspacePanel.tsx"(){qh(),$o(),Yh(),eu(),oa(),lu(),el={workspace:!0,toolUsage:!0,guide:!0,threadGraph:!0,extensions:!0},tl=c.memo(Qo)}}),rl={};th(rl,{MemoizedThreadGraphWorkspacePanel:()=>tl,ThreadGraphWorkspacePanel:()=>Qo});var fu=He({"src/workspace-panel.ts"(){pu()}});function ir(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))}ir(`.thread-ui-shell,
9
+ `),a+=i}return n.length>0?n:[e]}function Ka(e,r){return r!=="xyz"?e:e.flatMap(n=>Ah(n))}function Xa(e){return e.map(r=>`${r.replace(/\s+$/g,"")}
10
+ `).join("")}function Mh(e){if(!e)return{format:"xyz",frames:[],exportContent:""};if(typeof e=="string"){const s=Ka([e],"xyz");return{frames:s,format:"xyz",exportContent:Xa(s)}}const r=Rh(e.format),n=e.content.filter(s=>s.trim().length>0);return{frames:Ka(n,r),format:r,exportContent:Xa(n)}}var $h=He({"src/components/graph-workspace/GraphMoleculeViewerData.ts"(){}});function _h({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),[k,w]=c.useState(null),[x,j]=c.useState(!1),[y,b]=c.useState({}),[v,S]=c.useState([]),[N,L]=c.useState({}),[R,P]=c.useState(!1),[Q,D]=c.useState(!1),[Z,J]=c.useState(null),z=c.useMemo(()=>Mh(s),[s]),te=z.frames,se=z.format,_=te[p]??null,ie=te.length>0&&p===te.length-1,q=r??"current",H=Object.values(N).reduce((E,C)=>E+C.length,0),G=Object.keys(N).length;c.useEffect(()=>{if(te.length===0){g(0);return}g(te.length-1)},[te.length]),c.useEffect(()=>{if(!x||te.length<=1)return;const E=window.setInterval(()=>{g(C=>C>=te.length-1?(window.clearInterval(E),j(!1),C):C+1)},200);return()=>window.clearInterval(E)},[x,te.length]),c.useEffect(()=>{const E=l.current;if(!E||i.current)return;let C=!1;try{const U=document.createElement("canvas");if(!(U.getContext("webgl2")||U.getContext("webgl")||U.getContext("experimental-webgl"))){J("WebGL is unavailable in this browser environment. Unable to render 3D viewer.");return}}catch{J("WebGL is unavailable in this browser environment. Unable to render 3D viewer.");return}const W=()=>{var U,ae;(U=i.current)==null||U.resize(),(ae=i.current)==null||ae.render()};return Lh().then(U=>{if(!(C||i.current))try{const ae=U.createViewer(E,{});i.current=ae,ae.setBackgroundColor("#f8fafc",.8),window.addEventListener("resize",W),window.setTimeout(W,100)}catch(ae){console.error("Failed to initialize 3Dmol viewer:",ae),J("Failed to initialize 3D viewer. Please refresh or try another browser.")}}).catch(U=>{console.error("Failed to load 3Dmol viewer runtime:",U),J("Failed to load 3D viewer runtime. Please refresh or try another browser.")}),()=>{C=!0,window.removeEventListener("resize",W),i.current=null,d.current=null}},[]),c.useEffect(()=>{const E=i.current;if(!(!E||!_))try{E.removeAllModels(),E.removeAllShapes(),E.removeAllLabels();const C=E.addModel(_,se||"xyz");d.current=C,C.setStyle({},{stick:{radius:.2},sphere:{scale:.3}});const W=C.getCrystData(),U=!!(W&&typeof W=="object"&&Object.keys(W).length);P(U),D(U?u.current:!1),S([]),b({});const ae=_.split(`
11
+ `).slice(2).map(K=>K.trim()).filter(Boolean).map(K=>K.split(/\s+/)[0]??"Atom");h.current||(E.zoomTo(),h.current=!0),C.setClickable({},!0,(K,de,ee)=>{const ke=K.serial??K.index;if(ke===void 0)return;const le=K.atom||K.elem||ae[ke]||"Atom";S(je=>{const ce=!!(ee!=null&&ee.shiftKey||ee!=null&&ee.metaKey||ee!=null&&ee.ctrlKey)?je.includes(ke)?je.filter(ne=>ne!==ke):[...je,ke]:je.length===1&&je[0]===ke?[]:[ke];return b(ne=>{if(ce.length===0)return{};const Le={};return ce.forEach(Y=>{Le[Y]=ne[Y]||ae[Y]||le}),Le}),ce})}),C.setHoverable({},!0,(K,de,ee)=>{!ee||!K||w({x:ee.clientX,y:ee.clientY,label:`${K.atom||K.elem||"Atom"} (${K.serial??K.index??"?"})`,coords:{x:K.x.toFixed(2),y:K.y.toFixed(2),z:K.z.toFixed(2)}})},()=>w(null)),E.render()}catch(C){console.error("Failed to render molecule:",C),J("Unable to render this molecular structure.")}},[_,se]),c.useEffect(()=>{const E=i.current,C=d.current;if(!(!E||!C)){try{E.removeUnitCell(C)}catch{}if(Q&&R)try{E.addUnitCell(C,{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{P(!1),D(!1)}E.render()}},[R,Q,_,se]),c.useEffect(()=>{const E=i.current,C=d.current;!E||!C||!_||(C.setStyle({},{stick:{radius:.2},sphere:{scale:.3}}),v.length>0&&C.setStyle({serial:v},{stick:{radius:.3,color:"yellow"},sphere:{scale:.4,color:"yellow"}}),E.render(),a==null||a({moleculeId:r,atoms:v}))},[r,a,v,_]),c.useEffect(()=>{if(!_)return;let E=0;const C=()=>{var U,ae;const W=(ae=(U=i.current)==null?void 0:U.getView)==null?void 0:ae.call(U);if(Array.isArray(W)&&W.length>=8){const[K,de,ee,ke,le,je,Ae,ce]=W;if(typeof K=="number"&&typeof de=="number"&&typeof ee=="number"&&typeof ke=="number"&&typeof le=="number"&&typeof je=="number"&&typeof Ae=="number"&&typeof ce=="number"){const ne=Math.sqrt(le*le+je*je+Ae*Ae),Le=ne>0?{x:le/ne,y:je/ne,z:Ae/ne}:{x:0,y:0,z:0};f({position:{x:K,y:de,z:ee,qx:le,qy:je,qz:Ae,qw:ce},lookAt:Le,zoom:ke})}}E=window.requestAnimationFrame(C)};return E=window.requestAnimationFrame(C),()=>window.cancelAnimationFrame(E)},[_]);const T=c.useCallback(async()=>{const E=i.current;if(!(E!=null&&E.pngURI))return;E.render();const C=E.pngURI();if(C){try{const U=await(await fetch(C)).blob(),ae=new ClipboardItem({[U.type||"image/png"]:U});await navigator.clipboard.write([ae])}catch{}n==null||n({moleculeId:r,image:C})}},[r,n]);function F(){R&&D(E=>{const C=!E;return u.current=C,C})}function B(){v.length!==0&&L(E=>{const C=E[q]??[];return{...E,[q]:Array.from(new Set([...C,...v]))}})}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:[Z?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:Z}):null,!Z&&!_?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,k?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:k.x-20,top:k.y-50},children:[t.jsx("div",{className:"mb-0.5 font-semibold text-gray-900",children:k.label}),t.jsxs("div",{className:"space-x-2 text-gray-600",children:[t.jsxs("span",{children:["x: ",k.coords.x]}),t.jsxs("span",{children:["y: ",k.coords.y]}),t.jsxs("span",{children:["z: ",k.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(Th,{currentIndex:p,exportContent:z.exportContent,moleculeId:r,onScreenshot:()=>void T(),viewerRef:i,xyzContent:_,xyzFormat:se})]}),te.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," / ",te.length,t.jsx(Tr,{type:"button",variant:"ghost",size:"icon",className:"thread-graph-molecule-button h-5 w-5",onClick:()=>{j(E=>{const C=!E;return C&&p===te.length-1&&g(0),C})},"aria-label":x?"Pause trajectory":"Play trajectory",title:x?"Pause trajectory":"Play trajectory",children:x&&p!==te.length-1?t.jsx($.Pause,{className:"h-3 w-3"}):t.jsx($.Play,{className:"h-3 w-3"})})]}),t.jsxs(Tr,{type:"button",variant:"ghost",onClick:()=>g(te.length-1),className:"thread-graph-molecule-live-button",children:[t.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${ie?"animate-pulse bg-red-600":"bg-gray-300"}`}),"Live"]})]}),t.jsx(zh,{value:[p],max:te.length-1,step:1,onValueChange:E=>g(E[0]??0),"aria-label":"Trajectory frame"})]}):null,t.jsx(Ch,{cameraInfo:m,onClearSelection:()=>S([]),onClearStaged:()=>L({}),onSendSelection:()=>a==null?void 0:a({moleculeId:r,atoms:v}),onSendStaged:()=>{Object.entries(N).forEach(([E,C])=>{a==null||a({moleculeId:E==="current"?r:E,atoms:C})})},onStageSelection:B,onToggleUnitCell:F,selectedAtomLabels:y,selectedSerials:v,stagedAtoms:H,stagedMolecules:G,unitCellAvailable:R,unitCellVisible:Q})]})]})]})}var Dh=He({"src/components/graph-workspace/GraphMoleculeViewer.tsx"(){Sh(),Eh(),Ih(),sn(),Ph(),$h()}});function Bh(e){return!e.truncated&&e.size<=Wo&&e.content.split(`
12
+ `).length<=Uo}function Gh(e){return e&&(e.node.path||e.node.name)||null}function Fh(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 Hh({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(""),[k,w]=c.useState(null),[x,j]=c.useState(!1),y=(u==null?void 0:u.node)??null,b=y!=null&&y.artifact?h.renderArtifact({artifact:y.artifact,expanded:!0,onToggleExpanded:()=>{}}):null,v=dh(i??null),S=(i==null?void 0:i.language)||ch((i==null?void 0:i.path)??""),N=i?Rr(i.path):"",L=Gh(u),R=i!==null&&la.has(N),P=!!(i&&a)&&!R&&Bh(i),Q=(u==null?void 0:u.kind)==="live-molecule",D=!!(y!=null&&y.artifact&&b),Z=!!v||D;c.useEffect(()=>{f(!1),g((i==null?void 0:i.content)??""),w(null)},[i==null?void 0:i.path,i==null?void 0:i.content]);async function J(){if(!(!i||!a)){j(!0),w(null);try{await a({path:i.path,content:p}),f(!1)}catch(z){w(z instanceof Error?z.message:"Failed to save file.")}finally{j(!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($.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"&&v?t.jsx("div",{className:"thread-graph-molecule-preview min-h-0 flex-1 overflow-hidden",children:t.jsx(_h,{source:v,moleculeId:v.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:[R?"molecule":S||N||"text"," |"," ",i.size.toLocaleString()," bytes",i.truncated?t.jsxs("span",{className:"ml-2 text-amber-500",children:["showing ",i.nextOffset.toLocaleString()," bytes"]}):null]}),P?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),w(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($.X,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:()=>void J(),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($.Save,{className:"h-4 w-4"})})]}):t.jsx("button",{type:"button",onClick:()=>{g(i.content),f(!0),w(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($.Pencil,{className:"h-4 w-4"})})}):null]}),k?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:k}):null,m?t.jsx("textarea",{value:p,onChange:z=>g(z.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(Or,{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:Z||Q?"min-h-0 flex-1 overflow-hidden":"min-h-0 flex-1 overflow-auto p-3",children:b}):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(nr,{label:"Workspace Data",children:t.jsx(Or,{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(Or,{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 Wo,Uo,Or,Oh=He({"src/components/graph-workspace/GraphWorkspacePreviewPane.tsx"(){ia(),Go(),Dh(),Wo=50*1024,Uo=1e3,Or=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 Wh({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 Uh=He({"src/components/graph-workspace/GraphEmptyGarbageDialog.tsx"(){}});function Vo(e){return`${Ko}${e.workspaceId??"workspace"}:${e.threadId}`}function Vh(e){if(typeof window>"u")return[];try{const r=window.localStorage.getItem(Vo(e));if(!r)return[];const n=JSON.parse(r);return Array.isArray(n)?n.filter(a=>typeof a=="string"):[]}catch{return[]}}function Ya(e,r){if(!(typeof window>"u"))try{window.localStorage.setItem(Vo(e),JSON.stringify([...r]))}catch{}}function On(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=>On(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 Za(e,r){if(e.kind==="directory")return r?t.jsx($.FolderOpen,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"}):t.jsx($.Folder,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"});const n=Rr(e.name);return n==="zip"?t.jsx($.FileArchive,{className:"h-4 w-4 text-amber-600"}):e.kind==="file"&&["png","jpg","jpeg","gif","webp","svg"].includes(n)?t.jsx($.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($.FileCode2,{className:"h-4 w-4 text-emerald-600"}):t.jsx($.File,{className:"h-4 w-4 text-slate-400 dark:text-slate-500"})}function qo({depth:e,expandedPaths:r,loadingPaths:n,node:a,onCopyPath:s,onDownload:o,onPreview:l,onSelect:i,onToggle:d,selectedNodeId:h}){const u=a.kind==="directory",m=u&&(a.path===""||r.has(a.path)),f=u&&n.has(a.path),p=h===a.id,g=`${e*.75+.5}rem`;return u?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:()=>d(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:g},children:[m?t.jsx($.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}):t.jsx($.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}),Za(a,m),t.jsx("span",{className:"truncate",children:a.name}),f?t.jsx("span",{className:"ml-auto shrink-0 text-xs text-slate-400 dark:text-slate-500",children:"Loading"}):null]}),o?t.jsx("button",{type:"button",onClick:()=>o(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($.Download,{className:"h-3.5 w-3.5"})}):null,s&&a.path?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:`Copy path for ${a.name}`,"aria-label":`Copy path for ${a.name}`,children:t.jsx($.Copy,{className:"h-3.5 w-3.5"})}):null]}),m?t.jsxs("div",{children:[a.children.map(k=>t.jsx(qo,{depth:e+1,expandedPaths:r,loadingPaths:n,node:k,...s?{onCopyPath:s}:{},...o?{onDownload:o}:{},...l?{onPreview:l}:{},onSelect:i,onToggle:d,selectedNodeId:h},k.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 ${p?"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:()=>i(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:[Za(a,!1),t.jsx("span",{className:"truncate",children:a.name})]}),a.kind==="file"&&(l||o||s)?t.jsxs("div",{className:"mr-1 flex shrink-0 items-center gap-0.5",children:[l?t.jsx("button",{type:"button",onClick:()=>l(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 ${p?"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($.Eye,{className:"h-3.5 w-3.5"})}):null,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 ${p?"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($.Download,{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 ${p?"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:`Copy path for ${a.name}`,"aria-label":`Copy path for ${a.name}`,children:t.jsx($.Copy,{className:"h-3.5 w-3.5"})}):null]}):null]})}function qh({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($.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 Kh({canEmptyGarbage:e,canUpload:r,onCollapse:n,expandedPaths:a,loadingPaths:s,loading:o,onDownload:l,onCopyPath:i,onEmptyGarbage:d,onPreview:h,onRefresh:u,onSelect:m,onToggle:f,onUpload:p,explorerScrollTopRef:g,explorerScrollerRef:k,selectedNodeId:w,tree:x,liveNodes:j}){const y=c.useMemo(()=>({...x,children:x.children.filter(b=>b.path!=="live")}),[x]);return c.useLayoutEffect(()=>{const b=k.current;b&&(b.scrollTop=g.current)},[k,g]),t.jsxs("aside",{className:`${Xo} flex flex-col`,children:[t.jsxs("div",{className:Yo,children:[t.jsx("div",{className:"min-w-0",children:t.jsx("h2",{className:Zo,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:Jo,title:"Collapse Explorer","aria-label":"Collapse Explorer",children:[t.jsx($.ChevronsLeft,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Collapse Explorer"})]}):null,t.jsx("button",{type:"button",onClick:p,disabled:!r,className:Ur,title:r?"Upload file":"Upload is unavailable for this workspace","aria-label":"Upload file",children:t.jsx($.Upload,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:u,className:Ur,title:"Refresh workspace","aria-label":"Refresh workspace",children:t.jsx($.RefreshCw,{className:`h-4 w-4 ${o?"animate-spin":""}`})}),d?t.jsx("button",{type:"button",onClick:d,disabled:!e,className:Ur,title:e?"Empty garbage":"Garbage controls are unavailable","aria-label":"Empty garbage",children:t.jsx($.Trash2,{className:"h-4 w-4"})}):null]})]}),t.jsxs("div",{ref:k,className:"thread-graph-workspace-tree-scroll min-h-0 flex-1 overflow-y-auto py-2",onScroll:b=>{g.current=b.currentTarget.scrollTop},children:[t.jsx(qh,{liveNodes:j??[],onSelect:m,selectedNodeId:w}),t.jsx("div",{className:Qo,children:"Workspace"}),t.jsx(qo,{depth:0,expandedPaths:a,loadingPaths:s,node:y,...i?{onCopyPath:i}:{},...l?{onDownload:l}:{},...h?{onPreview:h}:{},onSelect:m,onToggle:f,selectedNodeId:w}),y.children.length===0?t.jsx("p",{className:el,children:"This workspace is empty. Agent tool runs execute inside the thread workspace, so files should appear here as the session works."}):null]})]})}function Xh({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:Ua(r,n),[e,i,n,r,s,l]),u=i??h??Ua(r,n),m=c.useMemo(()=>ph(u),[u]),f=c.useMemo(()=>{var I;return((I=u.children.find(O=>O.path==="live"))==null?void 0:I.children)??[]},[u]),p=_o(u),[g,k]=c.useState(()=>(p==null?void 0:p.id)??null),[w,x]=c.useState(()=>new Set(["","artifacts","thread-events","live",...Va((p==null?void 0:p.path)??"")])),[j,y]=c.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 639px)").matches?"viewer":null),[b,v]=c.useState(null),[S,N]=c.useState(!1),[L,R]=c.useState(()=>new Set),[P,Q]=c.useState(!1),[D,Z]=c.useState(!1),[J,z]=c.useState(!1),[te,se]=c.useState([]),[_,ie]=c.useState(null),[q,H]=c.useState(null),[G,T]=c.useState(null),[F,B]=c.useState(!1),E=c.useRef(null),C=c.useRef(null),W=c.useRef(0),U=c.useRef(null),ae=!!l,K=(g?m.get(g):null)??p??null,de={threadId:r.thread.id,workspaceId:r.workspace.id??r.thread.workspaceId??null};c.useEffect(()=>{W.current=0,U.current=null,x(new Set(["","artifacts","thread-events","live",...Vh(de),...Va((p==null?void 0:p.path)??"")]))},[de.threadId,de.workspaceId]);function ee(){var O;const I=((O=C.current)==null?void 0:O.scrollTop)??W.current;W.current=I,U.current=I}function ke(){const I=U.current??W.current;if(!C.current)return;let oe=0;const ge=()=>{const Ne=C.current;Ne&&(Ne.scrollTop=Math.min(I,Math.max(0,Ne.scrollHeight-Ne.clientHeight)),W.current=Ne.scrollTop,oe+=1,oe<8?window.requestAnimationFrame(ge):U.current=null)};window.requestAnimationFrame(ge)}c.useLayoutEffect(()=>{j!=="explorer"&&ke()},[j,u]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const I=window.matchMedia("(max-width: 639px)"),O=()=>B(I.matches);return O(),typeof I.addEventListener=="function"?(I.addEventListener("change",O),()=>I.removeEventListener("change",O)):(I.addListener(O),()=>I.removeListener(O))},[]);async function le(I){if(!l)return;const O=I??(K==null?void 0:K.path)??null;N(!0),v(null);try{const oe=rr(await l.listTree({...de,path:""}));let ge=i?On(oe,i):oe;if(i){const Ce=[...w].filter(xe=>xe).sort((xe,Ge)=>xe.split("/").length-Ge.split("/").length);for(const xe of Ce){const Ge=Bn(i,xe);if((Ge==null?void 0:Ge.kind)!=="directory"||!Ge.childrenLoaded)continue;const Me=rr(await l.listTree({...de,path:xe}));ge=Gn(ge,xe,On(Me,Ge))}}d(ge);const Ne=Ao(ge);k(Ce=>{var Ge;const xe=O??(Ce?(Ge=m.get(Ce))==null?void 0:Ge.path:null);return xe&&Fn(ge,xe)?`workspace:${xe}`:(Ne==null?void 0:Ne.id)??Ce})}catch(oe){v(oe instanceof Error?oe.message:"Failed to load workspace"),d(null)}finally{N(!1)}}async function je(I){if(!(!l||!i)){R(O=>{if(O.has(I))return O;const oe=new Set(O);return oe.add(I),oe}),v(null);try{const O=rr(await l.listTree({...de,path:I}));d(oe=>oe&&Ro(oe,I,O.children,{truncated:O.truncated}))}catch(O){v(O instanceof Error?O.message:"Failed to load directory")}finally{R(O=>{if(!O.has(I))return O;const oe=new Set(O);return oe.delete(I),oe})}}}async function Ae(I){const O=Mo(I);if(!O)return;const oe=ih(O);if(y(null),x(ge=>{const Ne=new Set(ge);Ne.add("");for(const Ce of oe)Ne.add(Ce);return Ya(de,Ne),Ne}),!l){Fn(u,O)&&k(`workspace:${O}`);return}N(!0),v(null);try{let ge=i??rr(await l.listTree({...de,path:""}));for(const Ne of oe){const Ce=Bn(ge,Ne);if((Ce==null?void 0:Ce.kind)==="directory"&&Ce.childrenLoaded)continue;const xe=rr(await l.listTree({...de,path:Ne}));ge=Gn(ge,Ne,xe)}d(ge),k(`workspace:${O}`)}catch(ge){v(ge instanceof Error?ge.message:`Failed to open ${O}`)}finally{N(!1)}}c.useEffect(()=>{if(!(!l||!i))for(const I of m.values())I.path&&I.kind==="directory"&&w.has(I.path)&&I.hasChildren&&!I.childrenLoaded&&!L.has(I.path)&&je(I.path)},[i,w,m,l]),c.useEffect(()=>{d(null),R(new Set),ie(null),H(null),T(null),v(null),le()},[ae,r.thread.id,r.workspace.id,r.thread.workspaceId]),c.useEffect(()=>{o&&Ae(o.path)},[o==null?void 0:o.requestId]),c.useEffect(()=>{l!=null&&l.subscribeWorkspaceChanged},[l,de.threadId,de.workspaceId]),c.useEffect(()=>{const I=l&&(K==null?void 0:K.kind)==="file"?K.path:null;if(!I){ie(null),H(null),T(null);return}const O=I;let oe=!1;async function ge(){var Ne;if(l){Q(!0),v(null),ie(null),H(null),T(null);try{const Ce=Rr(O),xe=(Ne=l.getRawFileUrl)==null?void 0:Ne.call(l,{...de,path:O});if(xe&&Do.has(Ce)){oe||H(xe);return}if(xe&&Bo.has(Ce)){oe||T(xe);return}const Ge=await l.readFile({...de,path:O,limit:Wr});oe||ie(Ge)}catch(Ce){oe||v(Ce instanceof Error?Ce.message:"Failed to read file")}finally{oe||Q(!1)}}}return ge(),()=>{oe=!0}},[l,K==null?void 0:K.id]);async function ce(){if(!(!l||!(_!=null&&_.truncated))){Z(!0);try{const I=await l.readFile({...de,path:_.path,offset:_.nextOffset,limit:Wr});ie(O=>O&&{...O,content:O.content+I.content,truncated:I.truncated,nextOffset:I.nextOffset,size:I.size})}finally{Z(!1)}}}async function ne(I){if(!(l!=null&&l.writeFile))return;v(null),await l.writeFile({...de,path:I.path,content:I.content}),await le(I.path);const O=await l.readFile({...de,path:I.path,limit:Wr});ie(O)}async function Le(I){if(!(!(l!=null&&l.uploadFile)||!I)){N(!0),v(null);try{const O=await l.uploadFile({...de,path:I.name,file:I}),oe=O.kind==="archive"?O.paths[0]??null:O.file.path;await le(oe)}catch(O){v(O instanceof Error?O.message:"Failed to upload file")}finally{N(!1)}}}async function Y(I){var oe;const O=(oe=I.target.files)==null?void 0:oe[0];I.target.value="",O&&await Le(O)}function me(){if(!(l!=null&&l.uploadFile))return;const I=()=>{var O;return(O=E.current)==null?void 0:O.click()};if(l.pickUploadFile){l.pickUploadFile({...de,defaultPick:I,upload:Le});return}I()}function we(I){var O;(O=l==null?void 0:l.downloadNode)==null||O.call(l,{...de,path:I.path,kind:I.kind==="directory"?"directory":"file"})}function ye(I){if(!I.path||typeof navigator>"u"||!navigator.clipboard)return;const O=r.workspace.absPath.replace(/\/+$/,""),oe=I.path.startsWith("/")?I.path:O?`${O}/${I.path.replace(/^\/+/,"")}`:I.path;navigator.clipboard.writeText(oe).catch(ge=>{v(ge instanceof Error?ge.message:"Failed to copy file path")})}function De(I){I.kind==="file"&&(ee(),k(I.id),y("explorer"))}async function Be(){if(l!=null&&l.emptyGarbage){if(v(null),!l.listGarbage){se([]),z(!0);return}try{const I=await l.listGarbage(de);se(I.map(O=>`garbage/${O}`))}catch(I){se([]),v(I instanceof Error?I.message:"Failed to list garbage files")}finally{z(!0)}}}async function _e(){if(l!=null&&l.emptyGarbage){z(!1),v(null);try{await l.emptyGarbage(de),await le((K==null?void 0:K.path)??null)}catch(I){v(I instanceof Error?I.message:"Failed to empty garbage")}}}const Oe={onCopyPath:ye,...l!=null&&l.downloadNode?{onDownload:we}:{},...l!=null&&l.emptyGarbage?{onEmptyGarbage:Be}:{},...l?{onRefresh:()=>void le((K==null?void 0:K.path)??null)}:{},...l!=null&&l.uploadFile?{onUpload:me}:{}};function V(I){if(!I)return;const O=m.get(`workspace:${I}`),oe=(O==null?void 0:O.kind)==="directory"&&O.hasChildren&&!O.childrenLoaded&&!L.has(I);x(ge=>{const Ne=new Set(ge);return Ne.has(I)?Ne.delete(I):Ne.add(I),Ya(de,Ne),Ne}),!w.has(I)&&oe&&je(I)}const he=t.jsx(Kh,{canEmptyGarbage:!!(l!=null&&l.emptyGarbage),canUpload:!!(l!=null&&l.uploadFile),onCollapse:()=>{ee(),y("explorer")},expandedPaths:w,loadingPaths:L,loading:S,explorerScrollTopRef:W,explorerScrollerRef:C,...Oe,onPreview:De,onSelect:I=>{k(I)},onToggle:V,selectedNodeId:(K==null?void 0:K.id)??null,tree:u,liveNodes:f}),ve=t.jsx(Hh,{error:b,imageUrl:q,loadingMore:D,onLoadMore:ce,...l!=null&&l.writeFile?{onSaveFile:ne}:{},onCollapse:()=>{ee(),y("viewer")},pdfUrl:G,previewFile:_,previewLoading:P,plugins:a,selectedTarget:Fh(K)});return j==="explorer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:ve}):j==="viewer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:he}):t.jsxs("div",{"data-testid":"workspace-panel",className:"flex h-full min-h-0 w-full overflow-hidden bg-transparent p-2",children:[J?t.jsx(Wh,{files:te,onCancel:()=>z(!1),onConfirm:()=>void _e()}):null,F?t.jsxs(_n,{direction:"vertical",className:"thread-graph-workspace-mobile-stack",children:[t.jsx(or,{defaultSize:42,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-explorer h-full min-h-0 overflow-hidden",children:he})}),t.jsx(Dn,{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(or,{defaultSize:58,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-viewer h-full min-h-0 overflow-hidden",children:ve})})]}):t.jsxs(_n,{direction:"horizontal",className:"thread-graph-workspace-resizable",children:[t.jsx(or,{defaultSize:33,minSize:20,children:t.jsx("div",{className:"thread-graph-workspace-explorer-pane h-full min-h-0 overflow-hidden",children:he})}),t.jsx(Dn,{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(or,{defaultSize:67,minSize:30,children:t.jsx("div",{className:"thread-graph-workspace-viewer-pane h-full min-h-0 overflow-hidden",children:ve})})]}),t.jsx("input",{ref:E,type:"file","aria-label":"Workspace upload file input","data-testid":"workspace-upload-file-input",className:"hidden",onChange:I=>void Y(I)})]})}var Wr,Ko,Xo,Yo,Zo,Ur,Jo,Qo,el,Yh=He({"src/components/graph-workspace/GraphWorkspaceExplorer.tsx"(){ia(),Oh(),Uh(),Po(),Wr=24e3,Ko="remote-codex:graphchat:workspace:expanded:",Xo="thread-graph-explorer h-full min-h-0 overflow-hidden rounded-[12px]",Yo="thread-graph-explorer-header flex h-[60px] shrink-0 items-center justify-between border-b px-4",Zo="text-[18px] font-semibold text-slate-900 dark:text-slate-100",Ur="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",Jo="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",Qo="thread-graph-workspace-label px-3 pb-1 pt-2 text-[11px] font-semibold tracking-normal text-slate-500 dark:text-slate-400",el="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 Cn({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 er({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 gr({value:e,title:r,icon:n,children:a}){return t.jsxs(Ir,{value:e,className:"thread-guide-section border-b border-[var(--theme-border)] last:border-b-0",children:[t.jsx(on,{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(zr,{className:"space-y-3 pb-3",children:a})]})}function Jh(){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(Lr,{type:"multiple",defaultValue:["start","workspace","remote-codex"],className:"space-y-0",children:[t.jsxs(gr,{value:"start",title:"Getting Started",icon:t.jsx($.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(er,{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(gr,{value:"workspace",title:"Workspace Explorer",icon:t.jsx($.FolderOpen,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx($.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($.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($.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($.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($.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(er,{items:[t.jsxs(t.Fragment,{children:[t.jsx(Cn,{children:".xyz .extxyz .cif"})," use the 3D molecule plugin."]}),t.jsxs(t.Fragment,{children:[t.jsx(Cn,{children:".png .jpg .gif .svg .webp"})," use inline image preview."]}),t.jsxs(t.Fragment,{children:[t.jsx(Cn,{children:".py .json .ts .md .csv"})," use text/code preview."]}),"Large files load in chunks when the workspace adapter supports it."]})]})]}),t.jsxs(gr,{value:"viewer",title:"Viewer",icon:t.jsx($.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(er,{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(gr,{value:"usage",title:"Tool Usage & Chat",icon:t.jsx($.BarChart2,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx($.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(er,{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($.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(er,{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(gr,{value:"remote-codex",title:"Remote Codex Extras",icon:t.jsx($.Code2,{className:"h-3 w-3"}),children:t.jsx(er,{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 Qh=He({"src/components/graph-workspace/GraphGuidePanel.tsx"(){Pr()}});function eu(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 Ja({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:eu(r)})]})}function tu({event:e}){return t.jsxs(Ir,{value:e.id,className:"thread-tool-call mb-2 overflow-hidden rounded-lg border border-[var(--theme-border)] last:mb-0",children:[t.jsxs(on,{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(zr,{className:"px-3 pb-3",children:t.jsxs("div",{className:"space-y-2 px-3 pb-3 pt-1",children:[t.jsx(Ja,{label:"Input",value:e.preview}),t.jsx(Ja,{label:"Output",value:e.detail})]})})]})}function ru({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($.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(Lr,{type:"single",collapsible:!0,value:s??"",onValueChange:i=>o(i||null),className:"space-y-0",children:n.slice(-50).map(i=>t.jsx(tu,{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($.RefreshCw,{className:"h-3 w-3"}),"Reload from workspace"]})]})}var nu=He({"src/components/graph-workspace/GraphToolUsagePanel.tsx"(){Pr()}});function Qa(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),k=(f-u)/(2*d)+(p-m)/(2*h),w=1/(Math.abs(g)+Math.abs(k)),x=w*g,j=w*k,y=d*(x+j)+u,b=h*(-x+j)+m;return{x:y,y:b}}function es(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?Ft.Left:o>=a+(e.measured.width??1)-1?Ft.Right:l<=s+1?Ft.Top:l>=n.y+(e.measured.height??1)-1?Ft.Bottom:Ft.Top}function tl(e,r){const n=Qa(e,r),a=Qa(r,e),s=es(e,n),o=es(r,a);return{sx:n.x,sy:n.y,tx:a.x,ty:a.y,sourcePos:s,targetPos:o}}function au(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,k)=>{const w=g.id.split("").reduce((x,j)=>{const y=(x<<5)-x+j.charCodeAt(0);return y&y},0);f.set(g.id,{x:Math.abs(w)%u+k*100%u,y:Math.abs(w>>16)%m+k*150%m,vx:0,vy:0})});for(let g=0;g<200;g+=1){for(let k=0;k<p;k+=1)for(let w=k+1;w<p;w+=1){const x=d[k],j=d[w];if(!x||!j)continue;const y=f.get(x.id),b=f.get(j.id);if(!y||!b)continue;const v=y.x-b.x,S=y.y-b.y,N=Math.sqrt(v*v+S*S)||1,R=(200-N)*.5,P=v/N*R,Q=S/N*R;y.vx+=P,y.vy+=Q,b.vx-=P,b.vy-=Q}h.forEach(k=>{const w=f.get(k.source),x=f.get(k.target);if(!w||!x)return;const j=x.x-w.x,y=x.y-w.y,b=Math.sqrt(j*j+y*y)||1,S=(b-120)*.3,N=j/b*S,L=y/b*S;w.vx+=N,w.vy+=L,x.vx-=N,x.vy-=L}),f.forEach(k=>{k.x+=k.vx*.1,k.y+=k.vy*.1,k.vx*=.9,k.vy*=.9,k.x=Math.max(80,Math.min(u-80,k.x)),k.y=Math.max(80,Math.min(m-80,k.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:Ws.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 da=He({"src/components/graph-chat/FloatingHelper.tsx"(){}});function su({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}=tl(s,o),[f]=Us({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 ou=He({"src/components/graph-chat/FloatingConnectionLine.tsx"(){da()}});function lu({id:e,source:r,target:n,markerEnd:a,style:s}){const o=Ta(r),l=Ta(n);if(!o||!l)return null;const{sx:i,sy:d,tx:h,ty:u,sourcePos:m,targetPos:f}=tl(o,l),[p]=Us({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 iu=He({"src/components/graph-chat/FloatingEdge.tsx"(){da()}});function du({nodes:e}){const[r,n,a]=Nd([]),[s,o,l]=Cd([]),i=c.useMemo(()=>au(e),[e]),d=c.useMemo(()=>({floating:lu}),[]),h=c.useMemo(()=>({styledNode:({data:m,isConnectable:f})=>t.jsxs("div",{className:"thread-graph-flow-node",children:[m.label,t.jsx(Sa,{type:"target",position:Ft.Top,isConnectable:f,style:{opacity:0,pointerEvents:"none"}}),t.jsx(Sa,{type:"source",position:Ft.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=>Sd({...m,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:Ws.Arrow}},f)),[o]);return t.jsx("div",{className:"thread-graph-flow h-full min-h-0",children:t.jsx(Td,{children:t.jsxs(Ed,{nodes:r,edges:s,onNodesChange:a,onEdgesChange:l,onConnect:u,fitView:!0,nodeTypes:h,edgeTypes:d,connectionLineComponent:su,children:[t.jsx(Ld,{}),t.jsx(Id,{gap:16})]})})})}var cu=He({"src/components/graph-chat/GraphVisualization.tsx"(){ou(),iu(),da()}});function hu(e){return{...nl,...e}}function ts(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 uu(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 mu(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:Yr(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:Yr(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 Yr(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 pu(e){switch(e.kind){case"userMessage":return"User";case"agentMessage":return"Agent";default:return Yr(e.kind)}}function fu(e){return(e.previewText??e.text??e.detailText??e.kind).replace(/\s+/g," ").slice(0,96)}function gu(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:pu(d),description:fu(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 rl({detail:e,status:r,plugins:n,workspaceAdapter:a,metaContent:s,settingsContent:o,activeView:l="chat",features:i,focusPathRequest:d=null}){const h=c.useMemo(()=>hu(i),[i]),u=ts(h,i==null?void 0:i.defaultTab),[m,f]=c.useState(u),p=c.useMemo(()=>sh(e),[e]),g=c.useMemo(()=>mu(e),[e]),k=c.useMemo(()=>{const v=new Map;for(const S of g)v.set(S.kind,(v.get(S.kind)??0)+1);return[...v.entries()].sort((S,N)=>N[1]-S[1])},[g]),w=n.getThreadPanels(),x=Math.max(...k.map(([,v])=>v),1),j=c.useMemo(()=>gu(e,g),[e,g]),y=c.useMemo(()=>{const v=[];return h.workspace&&v.push({id:"workspace",label:"Workspace",icon:null}),h.toolUsage&&v.push({id:"tools",label:"Tool Usage",icon:$.BarChart2}),h.guide&&v.push({id:"guide",label:"Guide",icon:$.BookOpen}),v},[h.guide,h.toolUsage,h.workspace]),b=c.useMemo(()=>{const v=[];return h.threadGraph&&v.push({id:"graph",label:"Thread graph",icon:$.GitBranch}),h.extensions&&v.push({id:"extensions",label:"Remote Codex extensions",icon:$.Wrench}),v},[h.extensions,h.threadGraph]);return c.useEffect(()=>{(!m||!uu(h,m))&&f(ts(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:[y.map(v=>{const S=v.icon;return t.jsxs("button",{type:"button",onClick:()=>f(v.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===v.id?"is-active":""}`,children:[S?t.jsx(S,{className:"h-3.5 w-3.5"}):null,v.label]},v.id)}),b.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:b.map(v=>{const S=v.icon;return t.jsx("button",{type:"button",onClick:()=>f(v.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===v.id?"is-active":""}`,title:v.label,"aria-label":v.label,children:t.jsx(S,{className:"h-3.5 w-3.5"})},v.id)})}):null]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[m==="workspace"?t.jsx(Xh,{activeView:l,detail:e,artifacts:p,plugins:n,status:r,focusPathRequest:d,workspaceAdapter:a??null}):null,m==="tools"?t.jsx(ru,{formatToolKind:Yr,toolCounts:k,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(du,{nodes:j})}):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(nr,{label:"Plugin Panels",children:w.length?t.jsx("div",{className:"flex flex-wrap gap-2",children:w.map(v=>t.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-1 text-xs text-[var(--theme-fg-soft)]",children:v.label},v.id))}):t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"No thread panels are enabled."})}),t.jsx(nr,{label:"Enabled Renderers",children:t.jsx("div",{className:"flex flex-wrap gap-2",children:n.plugins.filter(v=>v.enabled).map(v=>t.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-1 text-xs text-[var(--theme-fg-soft)]",children:v.name},v.id))})}),t.jsx(nr,{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($.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($.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($.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(nr,{label:"Thread Meta",children:s}):null,o?t.jsx(nr,{label:"Settings",children:o}):null]})}):null,m==="guide"?t.jsx(Jh,{}):null]})]}):null}var nl,al,xu=He({"src/components/ThreadGraphWorkspacePanel.tsx"(){Yh(),Go(),Qh(),nu(),ia(),cu(),nl={workspace:!0,toolUsage:!0,guide:!0,threadGraph:!0,extensions:!0},al=c.memo(rl)}}),sl={};ah(sl,{MemoizedThreadGraphWorkspacePanel:()=>al,ThreadGraphWorkspacePanel:()=>rl});var bu=He({"src/workspace-panel.ts"(){xu()}});function cr(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))}cr(`.thread-ui-shell,
14
14
  .thread-graph-dialog {
15
15
  color-scheme: light;
16
16
  --radius: 0.625rem;
@@ -671,7 +671,7 @@ import{l as _,R as Yi,I as Zi,C as Ji,S as Gs,H as Qi,T as ed,a as td,b as rd,c
671
671
  border-color: #465164;
672
672
  background: #2b313d;
673
673
  }
674
- `);ir(`.thread-ui-shell .thread-detail-surface {
674
+ `);cr(`.thread-ui-shell .thread-detail-surface {
675
675
  border-color: transparent;
676
676
  background: var(--theme-surface);
677
677
  box-shadow: none;
@@ -919,7 +919,7 @@ import{l as _,R as Yi,I as Zi,C as Ji,S as Gs,H as Qi,T as ed,a as td,b as rd,c
919
919
  .thread-ui-shell .thread-graph-history-group-list {
920
920
  border-color: var(--theme-border);
921
921
  }
922
- `);ir(`.thread-ui-shell .thread-workspace-panel {
922
+ `);cr(`.thread-ui-shell .thread-workspace-panel {
923
923
  background: var(--theme-panel);
924
924
  }
925
925
  .thread-ui-shell .thread-workspace-card {
@@ -1391,7 +1391,7 @@ import{l as _,R as Yi,I as Zi,C as Ji,S as Gs,H as Qi,T as ed,a as td,b as rd,c
1391
1391
  display: inline-flex;
1392
1392
  transform: translateY(-50%);
1393
1393
  }
1394
- `);ir(`} .thread-ui-shell .thread-graph-panel-expand-fab.left-3 {
1394
+ `);cr(`} .thread-ui-shell .thread-graph-panel-expand-fab.left-3 {
1395
1395
  left: 0.75rem;
1396
1396
  }
1397
1397
  .thread-ui-shell .thread-graph-panel-expand-fab.right-3 {
@@ -2666,7 +2666,9 @@ import{l as _,R as Yi,I as Zi,C as Ji,S as Gs,H as Qi,T as ed,a as td,b as rd,c
2666
2666
  border: 0;
2667
2667
  background: transparent;
2668
2668
  color: var(--theme-fg-muted);
2669
- font: inherit;
2669
+ font-size: 0.625rem;
2670
+ font-weight: 400;
2671
+ line-height: 1;
2670
2672
  white-space: nowrap;
2671
2673
  }
2672
2674
  .thread-ui-shell .thread-graph-relative-time:hover {
@@ -2727,7 +2729,7 @@ import{l as _,R as Yi,I as Zi,C as Ji,S as Gs,H as Qi,T as ed,a as td,b as rd,c
2727
2729
  padding: 0.375rem 1rem;
2728
2730
  }
2729
2731
  }
2730
- `);ir(`.thread-ui-shell .timeline-soft-text,
2732
+ `);cr(`.thread-ui-shell .timeline-soft-text,
2731
2733
  .thread-ui-shell .thread-message-prose :where(blockquote) {
2732
2734
  color: var(--theme-fg-soft);
2733
2735
  }
@@ -3539,7 +3541,7 @@ import{l as _,R as Yi,I as Zi,C as Ji,S as Gs,H as Qi,T as ed,a as td,b as rd,c
3539
3541
  .thread-ui-shell[data-theme-effective=light] .thread-graph-plan-step-text {
3540
3542
  color: rgb(15 23 42) !important;
3541
3543
  }
3542
- `);ir(`.thread-export-dialog-root {
3544
+ `);cr(`.thread-export-dialog-root {
3543
3545
  --export-bg: rgb(248 250 252);
3544
3546
  --export-panel: rgb(255 255 255);
3545
3547
  --export-surface: rgb(241 245 249);
@@ -3668,43 +3670,43 @@ import{l as _,R as Yi,I as Zi,C as Ji,S as Gs,H as Qi,T as ed,a as td,b as rd,c
3668
3670
  padding: 1.5rem;
3669
3671
  }
3670
3672
  }
3671
- `);function gu(e){return e.replace(/\u00a0/g," ")}function xu(e,r){if(!e)return[];const n=[],a=[...r].sort((l,i)=>i.placeholder.length-l.placeholder.length);let o=0,s=0;for(;o<e.length;){const l=a.find(h=>e.startsWith(h.placeholder,o));if(l){n.push({type:"attachment",key:`${l.clientId}-${o}`,attachment:l}),o+=l.placeholder.length;continue}let i=e.length;for(const h of a){const u=e.indexOf(h.placeholder,o);u!==-1&&u<i&&(i=u)}const d=e.slice(o,i);d&&(n.push({type:"text",key:`text-${s}`,text:d}),s+=1),o=i}return n}function bu(e,r,n){const a=e==="photo"?"PHOTO":"FILE";let o=0;for(;;){const s=o===0?r:`${r} (${o+1})`,l=`[${a} ${s}]`;if(!n.has(l))return l;o+=1}}function vu(e,r,n){const a=r.start>0?e[r.start-1]:"",o=r.end<e.length?e[r.end]:"",s=!!(a&&!/\s/.test(a)),l=!o||!/\s/.test(o);return`${s?" ":""}${n.join(" ")}${l?" ":""}`}function ku({files:e,kindForFile:r,usedPlaceholders:n,buildClientId:a}){return e.map(o=>{const s=r(o),l=Ru(o,s),i=bu(s,Mu(l),n);return n.add(i),{clientId:a(),kind:s,originalName:l,placeholder:i,file:o}})}function wu({prompt:e,attachments:r,files:n,selection:a,kindForFile:o,buildClientId:s}){const l=new Set(r.map(p=>p.placeholder)),i=ku({files:n,kindForFile:o,usedPlaceholders:l,buildClientId:s}),d=a?{start:a.start,end:a.end}:{start:e.length,end:e.length},h=vu(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 yu({prompt:e,attachments:r,isShellView:n}){if(n)return{prompt:e};const a=e.trim();if(!a)return null;const o=r.filter(s=>a.includes(s.placeholder));return o.length>0?{prompt:a,attachments:o}:{prompt:a}}function ju({files:e,plainText:r,htmlText:n,htmlToText:a}){if(e.length>0)return{type:"append-files",preventDefault:!0,files:e};const o=r||a(n);return!o&&!n?{type:"ignore",preventDefault:!1}:{type:"insert-text",preventDefault:!0,text:o}}function es(e){return e?{type:"accept-files",preventDefault:!0,activateDragTarget:!0}:{type:"ignore",preventDefault:!1,activateDragTarget:!1}}function Nu(e){return e.length>0?{type:"accept-files",preventDefault:!0,activateDragTarget:!0,files:e}:{type:"ignore",preventDefault:!1,activateDragTarget:!1}}function Cu({key:e,metaKey:r,ctrlKey:n,busy:a,disabled:o}){const s=e==="Enter"&&(r||n);return{preventDefault:s,submit:s&&!a&&!o}}function Su({nextMode:e,previousOptimisticMode:r}){return{optimisticMode:e??null,rollbackMode:e?r:null,shouldRollbackMode:!!e,closeMenuOnSuccess:!0}}function Mr(e){return`${e.prompt}${e.attachments.map(r=>`${r.clientId}${r.kind}${r.placeholder}${r.originalName}`).join("")}`}function ts(e){if(!e)return"Auto";switch(e){case"xhigh":return"xhigh";default:return e}}function Tu(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 Eu(e){if(!e)return"";const r=e/1e3;return Number.isInteger(r)?String(r):String(Number(r.toFixed(1)))}function Fn(e){return e.replace(/\r\n/g,`
3672
- `)}function Lu(e){const r=e.trim();return/^[A-Za-z0-9_-]+$/.test(r)?r:null}function Iu(e){const n=Fn(e).split(`
3673
- `).map(o=>o.trim()).filter(Boolean).find(o=>/^\[mcp_servers\.[^\]]+\]$/.test(o));if(!n)return null;const a=n.match(/^\[mcp_servers\.([A-Za-z0-9_-]+)\]$/);return(a==null?void 0:a[1])??null}function zu(e,r){return`[mcp_servers.${e}]
3673
+ `);function vu(e){return e.replace(/\u00a0/g," ")}function ku(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 wu(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 yu(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 ju({files:e,kindForFile:r,usedPlaceholders:n,buildClientId:a}){return e.map(s=>{const o=r(s),l=$u(s,o),i=wu(o,_u(l),n);return n.add(i),{clientId:a(),kind:o,originalName:l,placeholder:i,file:s}})}function Nu({prompt:e,attachments:r,files:n,selection:a,kindForFile:s,buildClientId:o}){const l=new Set(r.map(p=>p.placeholder)),i=ju({files:n,kindForFile:s,usedPlaceholders:l,buildClientId:o}),d=a?{start:a.start,end:a.end}:{start:e.length,end:e.length},h=yu(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 Cu({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 Su({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 rs(e){return e?{type:"accept-files",preventDefault:!0,activateDragTarget:!0}:{type:"ignore",preventDefault:!1,activateDragTarget:!1}}function Tu(e){return e.length>0?{type:"accept-files",preventDefault:!0,activateDragTarget:!0,files:e}:{type:"ignore",preventDefault:!1,activateDragTarget:!1}}function Eu({key:e,metaKey:r,ctrlKey:n,busy:a,disabled:s}){const o=e==="Enter"&&(r||n);return{preventDefault:o,submit:o&&!a&&!s}}function Lu({nextMode:e,previousOptimisticMode:r}){return{optimisticMode:e??null,rollbackMode:e?r:null,shouldRollbackMode:!!e,closeMenuOnSuccess:!0}}function _r(e){return`${e.prompt}${e.attachments.map(r=>`${r.clientId}${r.kind}${r.placeholder}${r.originalName}`).join("")}`}function ns(e){if(!e)return"Auto";switch(e){case"xhigh":return"xhigh";default:return e}}function Iu(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 zu(e){if(!e)return"";const r=e/1e3;return Number.isInteger(r)?String(r):String(Number(r.toFixed(1)))}function Wn(e){return e.replace(/\r\n/g,`
3674
+ `)}function Pu(e){const r=e.trim();return/^[A-Za-z0-9_-]+$/.test(r)?r:null}function Ru(e){const n=Wn(e).split(`
3675
+ `).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 Au(e,r){return`[mcp_servers.${e}]
3674
3676
  url = ${JSON.stringify(r.trim())}
3675
- `}function rs(e,r,n){var m,f;const a=Fn(e),o=`${Fn(n).trim()}
3676
- `,s=a.split(`
3677
- `),l=`[mcp_servers.${r}]`,i=`[mcp_servers.${r}.`;let d=-1,h=s.length;for(let p=0;p<s.length;p+=1)if((((m=s[p])==null?void 0:m.trim())??"")===l){d=p;break}if(d>=0){for(let b=d+1;b<s.length;b+=1){const w=((f=s[b])==null?void 0:f.trim())??"";if(w.startsWith("[")&&!(w===l||w.startsWith(i))){h=b;break}}const p=s.slice(0,d).join(`
3678
- `).trimEnd(),g=s.slice(h).join(`
3679
- `).trim();return[p,o.trimEnd(),g].filter(Boolean).join(`
3677
+ `}function as(e,r,n){var m,f;const a=Wn(e),s=`${Wn(n).trim()}
3678
+ `,o=a.split(`
3679
+ `),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 k=d+1;k<o.length;k+=1){const w=((f=o[k])==null?void 0:f.trim())??"";if(w.startsWith("[")&&!(w===l||w.startsWith(i))){h=k;break}}const p=o.slice(0,d).join(`
3680
+ `).trimEnd(),g=o.slice(h).join(`
3681
+ `).trim();return[p,s.trimEnd(),g].filter(Boolean).join(`
3680
3682
 
3681
3683
  `).replace(/\n{3,}/g,`
3682
3684
 
3683
3685
  `).concat(`
3684
3686
  `)}const u=a.trimEnd();return u?`${u}
3685
3687
 
3686
- ${o}`:o}function nl(e){return typeof e!="number"||Number.isNaN(e)?0:Math.max(0,Math.min(100,Math.round(e)))}function jn(e){const r=e/1e3;return Number.isInteger(r)?`${r}k`:`${Number(r.toFixed(1))}k`}function Pu(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),o=Math.max(a-n,0);return[e,`${jn(n)} used / ${jn(a)}`,`${jn(o)} left`,`${nl(r.remainingPercent)}% context left`].join(" · ")}function Ru(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 Mu(e){return e.replace(/[\r\n[\]]+/g," ").replace(/\s+/g," ").trim()||"attachment"}function Hn(e){return e.type.startsWith("image/")?"photo":"file"}function On(e,r){const n=[];if(e)for(const a of Array.from(e)){if(a.kind!=="file")continue;const o=a.getAsFile();o&&n.push(o)}return n.length>0?n:r?Array.from(r):[]}function ns(e,r){return On(e,r).length>0}function Au(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function as(e){const r=e.placeholder.match(/^\[(?:PHOTO|FILE)\s+(.+)\]$/);return r!=null&&r[1]?r[1]:Au(e.originalName)}var Xr=[{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 _u({goalComposeMode:e,goalBusy:r,threadConnected:n,busy:a,isShellView:o,disabledPlaceholder:s,settingsBusy:l,supportedEffortCount:i,fastMode:d}){const h=e?"Describe the goal the backend should continue working toward...":s??(o?"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&&!o?"Sending...":"Send",m=n?e?"ui-action-info":"ui-action-primary":"ui-action-danger",f=l;return{promptPlaceholder:h,interruptLabel:o?"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 $u({isShellView:e,edgeToEdgeMobile:r,isMobileShell:n,openMenu:a,isDragTargetActive:o,busy:s}){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] ${o?"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 ${s?"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 ${o?"is-drag-target bg-sky-300/[0.08] shadow-[0_0_0_1px_rgba(125,211,252,0.2)]":""}`}}function Du(){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 Bu(){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 Gu(){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 Fu(){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 Hu(){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 Wn(){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 Ou(e){switch(e){case"bearerToken":return"Token";case"oAuth":return"OAuth";case"notLoggedIn":return"Login";case"unsupported":return"Public";default:return"Unknown"}}function Wu(e){switch(e){case"repo":return"Repo";case"system":return"System";case"admin":return"Admin";case"user":default:return"User"}}function Uu(e){var r;return((r=Xr.find(n=>n.value===e))==null?void 0:r.label)??e}function Vu(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 qu(e){switch(e){case"managed":return"Managed";case"modified":return"Modified";case"trusted":return"Trusted";case"untrusted":return"Review"}}function Ku(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 Xu(e){return e.source==="user"?"global":e.source==="project"?"project":null}function al(e){const r=Xu(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 Yu(e){switch(e){case"active":return"Active";case"paused":return"Paused";case"budgetLimited":return"Budget";case"complete":return"Complete";default:return e}}function Zu({contextUsage:e}){const r=(e==null?void 0:e.availability)??"unavailable",n=nl(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 Bt({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 Ju(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 Qu(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 em(e,{fastMode:r,compactBusy:n,goalComposeMode:a,goalStatus:o,busy:s}){switch(e.action){case"fast":return r?"On":"Off";case"compact":return n?"Busy":"Run";case"goal":return a?"Composing":o?Yu(o):"Open";case"fork":return s?"Idle only":"Open";case"skills":case"mcp":case"hooks":return"View";case"prompt":return"Compose";case"unsupported":return"Unavailable";default:return""}}function tm(e,{settingsBusy:r,compactBusy:n,busy:a,forkBusy:o}){switch(e.action){case"fast":return r;case"compact":return n||a;case"fork":return a||o;case"unsupported":return!0;default:return!1}}function rm(e,{fastMode:r,goalComposeMode:n,goalStatus:a,menuItemClassName:o}){return`${e.action==="fast"&&r||e.action==="goal"&&(n||a==="active")?"ui-status-warning":o} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`}function nm(e){if(!e)return"";const r=document.createElement("div");return r.innerHTML=e,r.textContent??""}function am(e){return!!e.querySelector("[style], font")}function Ft(e){return e instanceof HTMLElement&&e.dataset.segmentType==="attachment"&&e.dataset.placeholder?e.dataset.placeholder:e.textContent??""}function sl(e){let r="";for(const n of Array.from(e.childNodes))r+=Ft(n);return r.replace(/\u00a0/g," ")}function ss(e,r,n){var i;let a=null,o=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+=Ft(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 sl(e).length;if(a=d,d instanceof HTMLElement&&d.dataset.segmentType==="attachment"){const h=document.createRange();h.selectNodeContents(d);const u=Ft(d).length;try{h.setEnd(r,n);const m=h.toString().length,f=((i=d.textContent)==null?void 0:i.length)??0;f===0?o=u:o=Math.round(Math.min(1,m/f)*u)}catch{o=u}}else{const h=document.createRange();h.selectNodeContents(d);try{h.setEnd(r,n),o=h.toString().length}catch{o=Ft(d).length}}}const s=Array.from(e.childNodes);let l=0;for(const d of s){if(d===a)return d.nodeType===Node.TEXT_NODE?l+o:l+Math.min(o,Ft(d).length);l+=Ft(d).length}return l}function sm(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:ss(e,n.startContainer,n.startOffset),end:ss(e,n.endContainer,n.endOffset)}}function os(e,r){let n=Math.max(0,r);const a=Array.from(e.childNodes);for(const[o,s]of a.entries()){const i=Ft(s).length;if(s.nodeType===Node.TEXT_NODE){if(n<=i)return{node:s,offset:n};n-=i;continue}if(s instanceof HTMLElement&&s.dataset.segmentType==="attachment"){if(n===0)return{node:e,offset:o};if(n<=i){const d=a[o+1];return n===i&&(d==null?void 0:d.nodeType)===Node.TEXT_NODE?{node:d,offset:0}:{node:e,offset:o+1}}n-=i;continue}if(n<=i)return{node:e,offset:o+1};n-=i}return{node:e,offset:e.childNodes.length}}function om(e,r){const n=os(e,r.start),a=os(e,r.end),o=document.createRange();o.setStart(n.node,n.offset),o.setEnd(a.node,a.offset);const s=window.getSelection();s==null||s.removeAllRanges(),s==null||s.addRange(o)}function lm(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 o=document.createRange(),s=a.nextSibling;(s==null?void 0:s.nodeType)===Node.TEXT_NODE?o.setStart(s,0):o.setStartAfter(a),o.collapse(!0);const l=window.getSelection();return l==null||l.removeAllRanges(),l==null||l.addRange(o),!0}rn();Pt();function im({className:e,...r}){return t.jsx("div",{"data-slot":"input-group",role:"group",className:at("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 dm=Cr("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 cm({className:e,align:r="inline-start",...n}){return t.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":r,className:at(dm({align:r}),e),onClick:a=>{var s;if(a.target.closest("button"))return;const o=(s=a.currentTarget.parentElement)==null?void 0:s.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"]');o==null||o.focus()},...n})}var hm=Cr("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 Ct({className:e,type:r="button",variant:n="ghost",size:a="xs",...o}){return t.jsx(Nr,{type:r,"data-size":a,variant:n,className:at(hm({size:a}),e),...o})}function um({className:e,...r}){return t.jsx("span",{className:at("flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*=size-])]:size-4",e),...r})}function mm({photoInputRef:e,fileInputRef:r,onAppendAttachments:n}){function a(o,s){n(o.target.files,s),o.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:o=>a(o,"photo")}),t.jsx("input",{ref:r,type:"file",multiple:!0,tabIndex:-1,className:"sr-only",onChange:o=>a(o,"file")})]})}function pm(e){if(!e)return"reset time unavailable";const r=new Date(e);return Number.isNaN(r.getTime())?"reset time unavailable":`resets ${r.toLocaleString()}`}function fm({usage:e}){const[r,n]=c.useState(!1);if(!e||e.authKind!=="subscription"||e.windows.length===0)return null;const a=e.windows.slice(0,2),o=a.map(s=>{const l=Math.max(0,100-s.usedPercent);return`${s.label}: ${l}% remaining, ${pm(s.resetsAt)}`}).join(". ");return t.jsxs("button",{type:"button",className:`thread-subscription-usage group pointer-events-auto absolute bottom-0 right-2 inline-flex h-4 items-center gap-1 rounded-t-md border border-b-0 border-stone-500/50 bg-stone-950 px-1 text-[7px] font-normal leading-none text-stone-200 shadow-sm transition-[border-color,background-color,opacity] duration-200 hover:border-stone-400/75 hover:bg-stone-900 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-sky-200/70 sm:right-3 sm:text-[7px] ${e.stale?"opacity-70":"opacity-95"}`,"aria-label":`${e.provider} subscription usage. ${o}`,"aria-expanded":r,onClick:()=>n(s=>!s),children:[a.map(s=>{const l=Math.max(0,Math.min(100,100-s.usedPercent)),i=Math.round(18+l/100*190);return t.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[t.jsx("span",{className:"font-normal tracking-[-0.01em]",children:s.label}),t.jsx("span",{"data-subscription-window-track":"true",className:"h-0.5 w-7 overflow-hidden rounded-full bg-stone-600/55 sm:w-9",children:t.jsx("span",{className:"block h-full rounded-full transition-[width] duration-500 ease-out",style:{width:`${l}%`,backgroundImage:`linear-gradient(90deg, oklch(68% 0.17 ${i}), oklch(82% 0.13 ${Math.min(i+18,235)}))`}})})]},s.id)}),t.jsxs("span",{"aria-hidden":!r,className:`pointer-events-none absolute right-0 bottom-full mb-1 whitespace-nowrap rounded-md border border-stone-600/65 bg-stone-950/95 px-1.5 py-1 text-[9px] font-normal leading-none text-stone-100 shadow-lg transition-[opacity,transform] duration-200 group-hover:translate-y-0 group-hover:opacity-100 group-focus-visible:translate-y-0 group-focus-visible:opacity-100 ${r?"translate-y-0 opacity-100":"translate-y-0.5 opacity-0"}`,children:[a.map((s,l)=>t.jsxs("span",{children:[l>0?" · ":"",s.label," ",Math.round(100-s.usedPercent),"%"]},s.id)),e.stale?" · last known":""]})]})}function gm({activeView:e,followTail:r,onToggleFollow:n,canJumpToPreviousTurn:a,onJumpToPreviousTurn:o,canJumpToNextTurn:s,onJumpToNextTurn:l,subscriptionUsage:i}){return e!=="chat"?null:t.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-[90] h-11 -translate-y-full bg-transparent touch-manipulation sm:h-10",children:[t.jsxs("span",{role:"group","aria-label":"Timeline navigation",className:`thread-jump-latest-badge pointer-events-auto absolute bottom-1 left-1/2 inline-flex h-5 min-w-[7.5rem] -translate-x-1/2 overflow-hidden 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("button",{type:"button","aria-label":"Jump to previous turn",title:a?"Jump to the start of the previous turn":"No earlier turn",disabled:!a,onClick:()=>o==null?void 0:o(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70 disabled:cursor-default disabled:opacity-35",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:"M3.5 12h9M8 10V5M6 7l2-2 2 2"})})}),t.jsx("span",{"aria-hidden":"true",className:"w-px bg-current opacity-20"}),t.jsx("button",{type:"button","aria-label":"Jump to latest",title:r?"Latest messages are in view":"Jump to the bottom",onClick:()=>n==null?void 0:n(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70",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 5.5 4 4 4-4M3.5 12.5h9"})})}),t.jsx("span",{"aria-hidden":"true",className:"w-px bg-current opacity-20"}),t.jsx("button",{type:"button","aria-label":"Jump to next turn",title:s?"Jump to the start of the next turn":"No later turn",disabled:!s,onClick:()=>l==null?void 0:l(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70 disabled:cursor-default disabled:opacity-35",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:"M3.5 4h9M8 6v5m-2-2 2 2 2-2"})})})]}),t.jsx(fm,{usage:i})]})}function xm({activeView:e,layerClassName:r,formClassName:n,shellClassName:a,inputGroupClassName:o,error:s,followTail:l,photoInputRef:i,fileInputRef:d,onAppendAttachments:h,onToggleFollow:u,canJumpToPreviousTurn:m,onJumpToPreviousTurn:f,canJumpToNextTurn:p,onJumpToNextTurn:g,subscriptionUsage:b,onSubmit:w,formRef:x,promptSlot:j,pendingQueueSlot:y,toolbarSlot:v,goalSlot:k,shellPromptSlot:S}){return t.jsxs("div",{className:r,children:[t.jsx(mm,{photoInputRef:i,fileInputRef:d,onAppendAttachments:h}),t.jsx(gm,{activeView:e,followTail:l,onToggleFollow:u,canJumpToPreviousTurn:m,onJumpToPreviousTurn:f,canJumpToNextTurn:p,onJumpToNextTurn:g,subscriptionUsage:b}),y,t.jsxs("form",{ref:x,"data-testid":e==="chat"?"chat-composer":void 0,onSubmit:w,className:n,children:[t.jsxs("div",{className:`${a} flex w-full flex-col overflow-visible rounded-[16px] sm:rounded-[18px]`,children:[t.jsxs(im,{className:o,children:[j,v]}),k,S]}),s?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:s}):null]})]})}function bm({prompts:e,onSteer:r,onCancel:n}){const[a,o]=c.useState(()=>new Set);async function s(l,i){if(!(!i||a.has(l))){o(d=>new Set(d).add(l));try{await i(l)}catch{}finally{o(d=>{const h=new Set(d);return h.delete(l),h})}}}return t.jsxs("section",{"aria-label":"Queued prompts",className:"thread-composer-pending-queue mx-auto mb-2 w-full max-w-4xl overflow-hidden rounded-xl border",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 text-[11px] font-medium text-[var(--theme-fg-muted)]",children:[t.jsx("span",{children:"Queued"}),t.jsx("span",{children:e.length})]}),t.jsx("div",{className:"max-h-36 overflow-y-auto",children:e.map(l=>{const i=a.has(l.id);return t.jsxs("div",{className:"thread-composer-pending-row flex min-h-10 items-center gap-2 border-t px-3 py-2",children:[t.jsx("p",{className:"min-w-0 flex-1 truncate text-sm text-[var(--theme-fg)]",title:l.prompt,children:l.prompt}),l.optimistic?t.jsxs("span",{className:"inline-flex h-8 items-center gap-1.5 px-1.5 text-xs text-[var(--theme-fg-muted)]",children:[t.jsx(_.Loader2,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":"true"}),"Queueing"]}):t.jsxs(t.Fragment,{children:[r?t.jsxs("button",{type:"button",disabled:i,onClick:()=>void s(l.id,r),className:"thread-composer-steer-button inline-flex h-8 items-center gap-1.5 rounded-lg border px-2.5 text-xs font-medium transition disabled:cursor-wait disabled:opacity-60",children:[i?t.jsx(_.Loader2,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":"true"}):t.jsx(_.CornerUpRight,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Steer"]}):null,n?t.jsx("button",{type:"button",disabled:i,"aria-label":"Remove queued prompt",title:"Remove from queue",onClick:()=>void s(l.id,n),className:"thread-composer-queue-remove inline-flex h-8 w-8 items-center justify-center rounded-lg transition disabled:cursor-wait disabled:opacity-60",children:t.jsx(_.X,{className:"h-4 w-4","aria-hidden":"true"})}):null]})]},l.id)})})]})}function vm({open:e,iconButtonClassName:r,menuClassName:n,menuItemClassName:a,onToggle:o,onPickPhoto:s,onPickFile:l}){return t.jsxs("div",{className:"relative",children:[t.jsx(Ct,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Add attachment",title:"Add attachment",onClick:o,className:`${r} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx(Bu,{})}),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:s,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 ol=[{mode:"read-only",label:"Read only"},{mode:"workspace-write",label:"Workspace write"},{mode:"danger-full-access",label:"Danger"}];function ls(e){var r;return((r=ol.find(n=>n.mode===e))==null?void 0:r.label)??"Default"}function km({openMenu:e,model:r,modelOptions:n,modelContextTitle:a,contextUsage:o,reasoningEffort:s,supportedEfforts:l,displayedCollaborationMode:i,sandboxMode:d,planModeAvailable:h,sandboxModeAvailable:u,settingsBusy:m,goalComposeMode:f,goalBusy:p,activeView:g,disabled:b,fastMode:w,sendButtonLabel:x,sendButtonClassName:j,modelControlsDisabled:y,effortControlsDisabled:v,effortControlTitle:k,inlineToggleClassName:S,menuItemClassName:N,planToggleActiveClassName:L,sendButtonBaseClassName:R,onSetOpenMenu:P,onUpdateSettings:Q}){return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative min-w-0",children:[t.jsx(Ct,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="model","aria-label":r??"Select model",disabled:y||n.length===0,onClick:()=>P(D=>D==="model"?null:"model"),title:w?`Fast mode is on. Turn it off from the slash toolbox to edit model. ${a}`:a,className:`${S} 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(Zu,{contextUsage:o}):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:()=>Q({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":`${N} 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(Ct,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="effort",disabled:v,onClick:()=>P(D=>D==="effort"?null:"effort"),title:k,className:`${S} rounded-full px-2 disabled:cursor-not-allowed disabled:text-stone-700 ${v?"text-stone-500":"text-stone-300 hover:text-stone-100"}`,children:ts(s)}),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:()=>Q({reasoningEffort:D.reasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${D.reasoningEffort===s?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:ts(D.reasoningEffort)})},D.reasoningEffort))})})]}),u&&t.jsxs("div",{className:"relative",children:[t.jsx(Ct,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="sandbox","aria-label":`Sandbox: ${ls(d)}`,disabled:m,onClick:()=>P(D=>D==="sandbox"?null:"sandbox"),title:`Sandbox: ${ls(d)}`,className:`${S} 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:ol.map(D=>t.jsx("button",{type:"button",onClick:()=>Q({sandboxMode:D.mode}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${D.mode===d?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:D.label})},D.mode))})})]}),h&&t.jsx(Ct,{type:"button",variant:"ghost",size:"xs","aria-pressed":i==="plan",disabled:m,onClick:()=>Q({collaborationMode:i==="plan"?"default":"plan"}),className:`${S} 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(Ct,{type:"submit",variant:"default",size:"icon-xs","aria-label":f?"Set goal":"Send Prompt",title:x,disabled:p||(g==="chat"?b:!1),className:`${R} h-9 w-9 rounded-full text-sm font-medium disabled:cursor-not-allowed sm:h-8 sm:w-8 ${j}`,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 wm({busy:e,shellControlState:r,onPaste:n,onCopy:a,onClear:o,onShellControl:s}){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(Wn,{}),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(Wn,{}),t.jsx("span",{className:"text-[10px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:e,onClick:o,className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!l||!i,onClick:()=>s("ctrl_c"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CTRL-C",tone:"rose"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("ctrl_d"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CTRL-D"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("esc"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"ESC"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("tab"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"TAB"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("up"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"UP"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("down"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"DOWN"})})]})})}function ym({busy:e,forkBusy:r,composerMenuItemClassName:n,onForkLatest:a,onSelectForkTurnPanel:o}){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:s=>{s.stopPropagation(),o()},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 jm({forkTurnOptionsState:e,forkBusy:r,composerPanelButtonClassName:n,onForkTurn:a}){var o,s;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,(o=e.data)!=null&&o.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&&(((s=e.data)==null?void 0:s.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 Nm({hooksPanelMode:e,hooksState:r,hostConfigFilesAvailable:n,hookTrustAvailable:a,hookConfigBusy:o,hookConfigError:s,hookConfigSuccess:l,editingHookTarget:i,hookScope:d,hookEventName:h,hookMatcher:u,hookCommand:m,hookTimeoutSec:f,hookStatusMessage:p,composerChipButtonClassName:g,onResetHookForm:b,onSetHooksPanelMode:w,onClearHookConfigStatus:x,onSetEditingHookTarget:j,onSetHookScope:y,onSetHookEventName:v,onSetHookMatcher:k,onSetHookCommand:S,onSetHookTimeoutSec:N,onSetHookStatusMessage:L,onSaveHook:R,onStartEditingHook:P,onTrustHook:Q,onUntrustHook:D}){var Z,J,z,te,se;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:((Z=r.data)==null?void 0:Z.projectHooksPath)??"<workspace hooks config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:$=>{$.stopPropagation(),b(),w("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,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,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"," ",Ku((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:$=>y($.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:$=>v($.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:Xr.map($=>t.jsx("option",{value:$.value,children:$.label},$.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:$=>k($.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:$=>S($.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:$=>N($.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:$=>L($.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:()=>{w("list"),j(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 R(),disabled:o,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:o?"Saving...":e==="edit"?"Update Hook":"Write Hook"})]})]}):null,e==="list"&&((J=r.data)!=null&&J.warnings.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.warnings.map($=>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:$},$))}):null,e==="list"&&((z=r.data)!=null&&z.errors.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.errors.map($=>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:$.message}),t.jsx("p",{className:"mt-1 break-all text-rose-100/60",children:$.path})]},`${$.path}:${$.message}`))}):null,e==="list"&&((te=r.data)!=null&&te.hooks.length)?t.jsx("div",{className:"space-y-2",children:r.data.hooks.map($=>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:[Uu($.eventName),$.matcher?` · ${$.matcher}`:""]}),t.jsx("p",{className:"mt-0.5 truncate font-mono text-[11px] text-stone-400",children:$.command??$.handlerType}),$.statusMessage?t.jsx("p",{className:"mt-1 truncate text-[11px] text-stone-500",children:$.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:[al($)?t.jsx("button",{type:"button",onClick:le=>{le.stopPropagation(),P($)},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&&$.trustStatus==="trusted"&&!$.isManaged?t.jsx("button",{type:"button",disabled:o,onClick:le=>{le.stopPropagation(),D($)},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,($.trustStatus==="untrusted"||$.trustStatus==="modified")&&!$.isManaged&&a?t.jsx("button",{type:"button",disabled:o||!$.currentHash,onClick:le=>{le.stopPropagation(),Q($)},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:qu($.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:Vu($.source)}),t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:$.enabled?"Enabled":"Disabled"}),t.jsxs("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:[$.timeoutSec,"s"]})]})]},$.key))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((se=r.data)==null?void 0:se.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 Wr(e){return e.localGoalId??`${e.createdAt}:${e.objective}`}function Cm(e,r){const n=e?[e,...r]:r,a=new Set;return n.filter(o=>{const s=Wr(o);return a.has(s)?!1:(a.add(s),!0)})}function Sm(e){if(e<60)return`${e}s`;const r=Math.floor(e/60);return r<60?`${r}m`:`${Math.floor(r/60)}h ${r%60}m`}function Tm(e){switch(e){case"budgetLimited":return"Budget limited";case"complete":return"Complete";case"terminated":return"Terminated";case"paused":return"Paused";default:return"Active"}}function Em({goalState:e,goalHistory:r,busy:n,onBack:a,onUpdateGoal:o}){const s=Cm(e.data,r),l=e.data?Wr(e.data):null;return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-h-11 items-center justify-between gap-3 border-b border-[var(--theme-border)] px-3 py-2",children:[t.jsx("button",{type:"button",onClick:a,className:"min-h-9 rounded-lg px-2 text-xs font-medium text-[var(--theme-fg-muted)] transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--theme-accent-border)]",children:"Back"}),t.jsx("span",{className:"text-xs font-semibold text-[var(--theme-fg)]",children:"Goals"})]}),e.error?t.jsx("p",{className:"m-3 rounded-lg border border-[var(--status-danger-border)] bg-[var(--status-danger-bg)] px-3 py-2 text-xs text-[var(--status-danger-fg)]",children:e.error}):null,e.status==="loading"&&s.length===0?t.jsxs("div",{className:"space-y-2 p-3",role:"status","aria-label":"Loading goals",children:[t.jsx("div",{className:"h-12 animate-pulse rounded-lg bg-[var(--theme-muted)] motion-reduce:animate-none"}),t.jsx("div",{className:"h-12 animate-pulse rounded-lg bg-[var(--theme-muted)] motion-reduce:animate-none"})]}):s.length===0?t.jsx("p",{className:"px-4 py-5 text-center text-sm text-[var(--theme-fg-muted)]",children:"No goals in this thread yet."}):t.jsx("div",{className:"max-h-72 divide-y divide-[var(--theme-border)] overflow-y-auto",children:s.map(i=>{const d=Wr(i)===l&&["active","paused","budgetLimited"].includes(i.status);return t.jsxs("div",{className:"px-3 py-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx("p",{className:"min-w-0 flex-1 text-sm font-medium leading-5 text-[var(--theme-fg)]",children:i.objective}),t.jsx("span",{className:"shrink-0 rounded-full border border-[var(--theme-border)] px-2 py-1 text-[10px] font-medium text-[var(--theme-fg-muted)]",children:Tm(i.status)})]}),t.jsxs("p",{className:"mt-1.5 text-[11px] text-[var(--theme-fg-muted)]",children:[Sm(i.timeUsedSeconds)," · ",i.tokensUsed.toLocaleString()," tokens"]}),d&&o?t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsx("button",{type:"button",disabled:n||i.status==="active",onClick:()=>void o({status:"active"}),className:"min-h-9 rounded-lg border border-[var(--theme-border)] px-3 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:opacity-45",children:"Continue"}),t.jsx("button",{type:"button",disabled:n||i.status==="paused",onClick:()=>void o({status:"paused"}),className:"min-h-9 rounded-lg border border-[var(--theme-border)] px-3 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:opacity-45",children:"Pause"}),t.jsx("button",{type:"button",disabled:n,onClick:()=>void o({status:"terminated"}),className:"min-h-9 rounded-lg px-3 text-xs font-medium text-[var(--status-danger-fg)] transition hover:bg-[var(--status-danger-bg)] disabled:cursor-not-allowed disabled:opacity-45",children:"Terminate"})]}):null]},Wr(i))})})]})}function Lm({mcpPanelMode:e,mcpState:r,mcpConfigEditing:n,mcpConfigPath:a,mcpConfigError:o,mcpConfigSuccess:s,mcpConfigBusy:l,mcpHttpName:i,mcpHttpUrl:d,mcpRawBlock:h,composerPanelButtonClassName:u,composerChipButtonClassName:m,onSetMcpPanelMode:f,onClearMcpConfigStatus:p,onSetMcpHttpName:g,onSetMcpHttpUrl:b,onSetMcpRawBlock:w,onPrepareRawMcpBlock:x,onSaveHttpMcp:j,onSaveRawMcpBlock:y}){var v,k;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:S=>{S.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,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,s?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:s}):null,e==="add"?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:S=>{S.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:S=>{S.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:S=>g(S.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:S=>b(S.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 j(),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:S=>w(S.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 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 raw block"})]})]}):null,e==="list"&&((v=r.data)!=null&&v.servers.length)?t.jsx("div",{className:"space-y-2",children:r.data.servers.map(S=>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:S.name}),t.jsxs("p",{className:"mt-0.5 text-xs text-stone-400",children:[S.tools.length," tools · ",S.resourceCount," ","resources · ",S.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:Ou(S.authStatus)})]}),S.tools.length>0?t.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-stone-500",children:S.tools.slice(0,4).map(N=>N.title??N.name).join(" · ")}):null]},S.name))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((k=r.data)==null?void 0:k.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 o,s,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,(o=e.data)!=null&&o.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:Wu(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(Wn,{}),"$",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,(s=e.data)!=null&&s.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 zm({open:e,slashPanelView:r,availableToolboxItems:n,busy:a,forkBusy:o,forkTurnOptionsState:s,skillsState:l,goalState:i,goalHistory:d,goalBusy:h,copiedSkillName:u,hooksPanelMode:m,hooksState:f,hostConfigFilesAvailable:p,hookTrustAvailable:g,hookConfigBusy:b,hookConfigError:w,hookConfigSuccess:x,editingHookTarget:j,hookScope:y,hookEventName:v,hookMatcher:k,hookCommand:S,hookTimeoutSec:N,hookStatusMessage:L,mcpPanelMode:R,mcpState:P,mcpConfigEditing:Q,mcpConfigPath:D,mcpConfigError:Z,mcpConfigSuccess:J,mcpConfigBusy:z,mcpHttpName:te,mcpHttpUrl:se,mcpRawBlock:$,iconButtonClassName:le,menuClassName:q,menuItemClassName:H,panelButtonClassName:G,chipButtonClassName:T,onToggle:F,onToolboxItemClick:B,toolboxItemDisabled:E,toolboxItemClassName:C,toolboxItemStatus:W,onSetSlashPanelView:U,onViewGoals:ne,onUpdateGoal:K,onOpenForkTurns:ie,onForkLatest:ee,onForkTurn:ve,onCopySkillInvokeName:oe,onResetHookForm:ye,onSetHooksPanelMode:Me,onClearHookConfigStatus:de,onSetEditingHookTarget:Ce,onSetHookScope:Ee,onSetHookEventName:Y,onSetHookMatcher:ue,onSetHookCommand:ke,onSetHookTimeoutSec:we,onSetHookStatusMessage:De,onSaveHook:Fe,onStartEditingHook:Ae,onTrustHook:Oe,onUntrustHook:V,onSetMcpPanelMode:ce,onClearMcpConfigStatus:xe,onSetMcpHttpName:I,onSetMcpHttpUrl:O,onSetMcpRawBlock:ae,onPrepareRawMcpBlock:be,onSaveHttpMcp:je,onSaveRawMcpBlock:Te}){return t.jsxs("div",{className:"relative",children:[t.jsx(Ct,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Open slash toolbox",title:"Open slash toolbox",onClick:F,className:`${le} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx(Gu,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${q} 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:fe=>{fe.stopPropagation()},onMouseDown:fe=>{fe.stopPropagation()},onPointerDown:fe=>{fe.stopPropagation()},onTouchStart:fe=>{fe.stopPropagation()},children:r==="root"?t.jsxs("div",{className:"p-2",children:[n.map((fe,Be)=>fe.action==="goal"?t.jsxs("div",{className:`mt-1 flex min-h-11 overflow-hidden rounded-xl border border-[var(--theme-border)] ${Be===0?"mt-0":""}`,title:fe.description??fe.label,children:[t.jsx("button",{type:"button",disabled:E(fe),onClick:()=>{U("goals"),ne==null||ne()},className:"min-w-0 flex-1 px-3 py-2.5 text-left text-sm text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--theme-accent-border)] disabled:cursor-not-allowed disabled:opacity-45","aria-label":"View goals",children:t.jsx("span",{children:fe.command})}),t.jsx("button",{type:"button",disabled:E(fe),onClick:_e=>B(fe,_e),className:"min-w-14 border-l border-[var(--theme-border)] px-3 text-xs font-semibold text-[var(--theme-fg-muted)] transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)] focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--theme-accent-border)] disabled:cursor-not-allowed disabled:opacity-45","aria-label":"Open goal composer",children:"Open"})]},`${fe.action}:${fe.command}`):t.jsx("button",{type:"button",disabled:E(fe),onClick:_e=>B(fe,_e),className:`${C(fe)} ${Be===0?"mt-0":""}`,title:fe.description??fe.label,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:fe.command}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:W(fe)})]})},`${fe.action}:${fe.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==="goals"?t.jsx(Em,{goalState:i,goalHistory:d,busy:h,onBack:()=>U("root"),onUpdateGoal:K}):r==="fork"?t.jsx(ym,{busy:a,forkBusy:o,composerMenuItemClassName:H,onForkLatest:ee,onSelectForkTurnPanel:()=>(U("forkTurns"),ie())}):r==="forkTurns"?t.jsx(jm,{forkTurnOptionsState:s,forkBusy:o,composerPanelButtonClassName:G,onForkTurn:ve}):r==="skills"?t.jsx(Im,{skillsState:l,copiedSkillName:u,composerChipButtonClassName:T,onCopySkillInvokeName:oe}):r==="hooks"?t.jsx(Nm,{hooksPanelMode:m,hooksState:f,hostConfigFilesAvailable:p,hookTrustAvailable:g,hookConfigBusy:b,hookConfigError:w,hookConfigSuccess:x,editingHookTarget:j,hookScope:y,hookEventName:v,hookMatcher:k,hookCommand:S,hookTimeoutSec:N,hookStatusMessage:L,composerChipButtonClassName:T,onResetHookForm:ye,onSetHooksPanelMode:Me,onClearHookConfigStatus:de,onSetEditingHookTarget:Ce,onSetHookScope:Ee,onSetHookEventName:Y,onSetHookMatcher:ue,onSetHookCommand:ke,onSetHookTimeoutSec:we,onSetHookStatusMessage:De,onSaveHook:Fe,onStartEditingHook:Ae,onTrustHook:Oe,onUntrustHook:V}):t.jsx(Lm,{mcpPanelMode:R,mcpState:P,mcpConfigEditing:Q,mcpConfigPath:D,mcpConfigError:Z,mcpConfigSuccess:J,mcpConfigBusy:z,mcpHttpName:te,mcpHttpUrl:se,mcpRawBlock:$,composerPanelButtonClassName:G,composerChipButtonClassName:T,onSetMcpPanelMode:ce,onClearMcpConfigStatus:xe,onSetMcpHttpName:I,onSetMcpHttpUrl:O,onSetMcpRawBlock:ae,onPrepareRawMcpBlock:be,onSaveHttpMcp:je,onSaveRawMcpBlock:Te})})})]})}function Pm({isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:o,toolbarClassName:s,iconButtonClassName:l,slashToolboxProps:i,attachmentMenuProps:d,settingsToolbarProps:h,shellToolsPanelProps:u,onToggleView:m,onDismissPromptFocus:f,onSetOpenMenu:p}){return t.jsxs(cm,{align:"block-end",className:`${s} 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(zm,{...i}):null,!e&&d?t.jsx(vm,{...d}):null,r&&t.jsx(Ct,{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(Fu,{}):t.jsx(Du,{})})]}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-end gap-1.5",children:[!e&&h?t.jsx(km,{...h}):null,e&&a?t.jsx(um,{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":o==="shellTools"?"Close shell tools":"Open shell tools","aria-haspopup":"menu","aria-expanded":o==="shellTools",title:o==="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(Hu,{})}),o==="shellTools"&&u?t.jsx(wm,{...u}):null]})]})]})}function Rm(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`attachment-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function Mm(e){return[...e.filter(r=>Hn(r)==="photo"),...e.filter(r=>Hn(r)==="file")]}function Am({prompt:e,attachments:r,updateDraft:n,getSelection:a,selectionSnapshotRef:o,pendingSelectionRef:s,pendingInsertedAttachmentIdsRef:l,onInserted:i,buildClientId:d=Rm}){const h=c.useCallback((f,p)=>{if(f.length===0)return!1;const g=wu({prompt:e,attachments:r,files:f,selection:a()??o.current,kindForFile:p,buildClientId:d});return n(()=>g.draft),s.current=g.selection,o.current=g.selection,l.current=g.insertedAttachmentIds,i==null||i(),!0},[r,d,a,i,l,s,e,o,n]),u=c.useCallback((f,p)=>!f||f.length===0?!1:h(Array.from(f),()=>p),[h]),m=c.useCallback(f=>h(Mm(f),Hn),[h]);return{appendAttachments:u,appendDroppedAttachments:m}}function is(e){for(const r of e.values())URL.revokeObjectURL(r);e.clear()}function _m({attachments:e,isShellView:r}){const n=c.useRef(new Map),[a,o]=c.useState({});return c.useEffect(()=>{const s=n.current;if(r){is(s),o({});return}const l={},i=new Set;for(const d of e){if(d.kind!=="photo")continue;i.add(d.clientId);let h=s.get(d.clientId);h||(h=URL.createObjectURL(d.file),s.set(d.clientId,h)),l[d.clientId]=h}for(const[d,h]of s.entries())i.has(d)||(URL.revokeObjectURL(h),s.delete(d));o(l)},[e,r]),c.useEffect(()=>{const s=n.current;return()=>{is(s)}},[]),a}var $m=180;function Nn(e,r){return{prompt:e??"",attachments:r??[]}}function Dm({isShellView:e,draftPrompt:r,draftAttachments:n,onDraftChange:a}){const[o,s]=c.useState({prompt:"",attachments:[]}),[l,i]=c.useState(()=>Nn(r,n)),d=c.useRef(null),h=c.useRef(l),u=c.useRef(Mr(l)),m=!e&&r!==void 0&&n!==void 0&&typeof a=="function",f=m?Mr(Nn(r,n)):"",p=c.useRef(f);c.useLayoutEffect(()=>{if(!m){p.current="";return}const y=Nn(r,n),v=Mr(y);v!==p.current&&(p.current=v,u.current=v,h.current=y,d.current!==null&&(window.clearTimeout(d.current),d.current=null),i(y))},[n,r,m]);const g=c.useCallback(y=>{if(!m||!a)return;const v=Mr(y);v!==u.current&&(u.current=v,a(()=>({prompt:y.prompt,attachments:y.attachments})))},[m,a]);c.useEffect(()=>()=>{g(h.current),d.current!==null&&window.clearTimeout(d.current)},[g]);const b=c.useCallback((y,v)=>{if(m){if(d.current!==null&&(window.clearTimeout(d.current),d.current=null),v==="immediate"){g(y);return}d.current=window.setTimeout(()=>{d.current=null,g(h.current)},$m)}},[m,g]),w=c.useCallback((y=h.current)=>{b(y,"immediate")},[b]),x=c.useCallback((y,v="immediate")=>{if(m){const k=y(h.current);h.current=k,i(k),b(k,v);return}s(k=>y(k))},[m,b]),j=m?l:o;return{prompt:j.prompt,attachments:j.attachments,isDraftControlled:m,updateDraft:x,flushControlledDraftToHost:w}}function Bm({slashPanelView:e,onForkLatest:r,onForkTurn:n,closeMenu:a}){const[o,s]=c.useState(!1);c.useEffect(()=>{e!=="forkTurns"&&s(!1)},[e]);const l=c.useCallback(async()=>{if(r){s(!0);try{await r(),a()}finally{s(!1)}}},[a,r]),i=c.useCallback(async d=>{if(n){s(!0);try{await n(d),a()}finally{s(!1)}}},[a,n]);return{forkBusy:o,forkLatest:l,forkTurn:i}}function Gm({prompt:e,goalTokenBudgetSource:r,promptRef:n,onOpenGoal:a,onPrepareGoalSubmit:o,onUpdateGoal:s,updateDraft:l,closeMenu:i,resetSlashPanel:d}){const[h,u]=c.useState(!1),[m,f]=c.useState(""),[p,g]=c.useState(!1),[b,w]=c.useState(null),x=c.useCallback(async()=>{const v=e.trim();if(!v)return w("Goal objective cannot be empty."),!1;const k=m.trim(),S=Tu(k);if(k.length>0&&(S===null||!Number.isInteger(S)||S<=0))return w("Token budget must be a positive number in thousands."),!1;if(!s)return w("/goal is unavailable in this view."),!1;g(!0),w(null);try{return o&&await o({objective:v,tokenBudget:S})===!1?!1:(await s({objective:v,status:"active",tokenBudget:S}),f(""),u(!1),l(()=>({prompt:"",attachments:[]})),!0)}catch(N){return w(N instanceof Error?N.message:"Unable to set goal."),!1}finally{g(!1)}},[m,o,s,e,l]),j=c.useCallback(()=>{i(),d(),u(!0),f(Eu(r==null?void 0:r.tokenBudget)),w(null),a==null||a(),requestAnimationFrame(()=>{var v;(v=n.current)==null||v.focus()})},[i,r==null?void 0:r.tokenBudget,a,n,d]),y=c.useCallback(()=>{u(!1),w(null)},[]);return{goalComposeMode:h,goalTokenBudget:m,goalBusy:p,goalLocalError:b,setGoalTokenBudget:f,submitGoal:x,enterGoalComposeMode:j,exitGoalComposeMode:y}}var Cn=`node -e "process.stdin.resume(); process.stdin.on('end', () => console.error('hook ran'))"`;function Fm(e){const r=new Map;for(const n of e??[])r.set(n.eventName,n.command);return r}function Hm({slashPanelView:e,hookCommandTemplates:r,onCreateHook:n,onUpdateHook:a,onTrustHook:o,onUntrustHook:s}){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(Cn),[w,x]=c.useState("30"),[j,y]=c.useState("Running hook"),[v,k]=c.useState(null),[S,N]=c.useState(!1),[L,R]=c.useState(null),[P,Q]=c.useState(null),D=c.useMemo(()=>Fm(r),[r]),Z=c.useCallback(H=>D.get(H)??D.get("preToolUse")??Cn,[D]),J=c.useMemo(()=>new Set([Cn,...D.values()]),[D]),z=c.useCallback(()=>{R(null),Q(null)},[]);c.useEffect(()=>{e!=="hooks"&&(i("list"),z())},[z,e]),c.useEffect(()=>{const H=Xr.find(G=>G.value===u);p(G=>{const T=G.trim(),F=new Set(Xr.map(B=>B.matcherHint).filter(Boolean));return T&&!F.has(T)?G:(H==null?void 0:H.matcherHint)??""}),b(G=>J.has(G.trim())?Z(u):G)},[Z,J,u]);const te=c.useCallback(()=>{k(null),h("project"),m("preToolUse"),p("Bash"),b(Z("preToolUse")),x("30"),y("Running hook")},[Z]),se=c.useCallback(H=>{const G=al(H);if(!G){R("Only command hooks in global or project hooks.json can be edited here.");return}k(G),h(G.scope),m(G.eventName),p(G.matcher??""),b(G.command),x(G.timeoutSec?String(G.timeoutSec):""),y(G.statusMessage??""),R(null),Q(null),i("edit")},[]),$=c.useCallback(async()=>{if(l==="edit"&&!a){R("Hook editing is unavailable in this view.");return}if(l!=="edit"&&!n){R("Hook editing is unavailable in this view.");return}if(l==="edit"&&!v){R("Select a hook to edit first.");return}const H=g.trim();if(!H){R("Hook command cannot be empty.");return}const G=w.trim(),T=G?Number(G):null;if(G&&(T===null||!Number.isInteger(T)||T<=0)){R("Timeout must be a positive number of seconds.");return}N(!0),R(null),Q(null);try{const F={scope:d,eventName:u,matcher:f.trim()||null,command:H,timeoutSec:T,statusMessage:j.trim()||null};l==="edit"?await(a==null?void 0:a({...F,target:v})):await(n==null?void 0:n(F)),Q(`${d==="project"?"Project":"Global"} hook ${l==="edit"?"updated":"written"} in hooks.json and trusted.`),i("list"),k(null)}catch(F){R(F instanceof Error?F.message:"Unable to write hooks.json.")}finally{N(!1)}},[v,g,u,f,d,j,w,l,n,a]),le=c.useCallback(async H=>{if(!o||!H.currentHash){R("Hook trust is unavailable in this view.");return}N(!0),R(null),Q(null);try{await o({key:H.key,currentHash:H.currentHash}),Q("Hook trusted.")}catch(G){R(G instanceof Error?G.message:"Unable to trust hook.")}finally{N(!1)}},[o]),q=c.useCallback(async H=>{if(!s){R("Hook trust is unavailable in this view.");return}N(!0),R(null),Q(null);try{await s({key:H.key}),Q("Hook untrusted.")}catch(G){R(G instanceof Error?G.message:"Unable to untrust hook.")}finally{N(!1)}},[s]);return{hooksPanelMode:l,hookScope:d,hookEventName:u,hookMatcher:f,hookCommand:g,hookTimeoutSec:w,hookStatusMessage:j,editingHookTarget:v,hookConfigBusy:S,hookConfigError:L,hookConfigSuccess:P,setHooksPanelMode:i,setEditingHookTarget:k,setHookScope:h,setHookEventName:m,setHookMatcher:p,setHookCommand:b,setHookTimeoutSec:x,setHookStatusMessage:y,clearHookConfigStatus:z,resetHookForm:te,startEditingHook:se,saveHook:$,trustHook:le,untrustHook:q}}var Om=`[mcp_servers.example_stdio]
3688
+ ${s}`:s}function ol(e){return typeof e!="number"||Number.isNaN(e)?0:Math.max(0,Math.min(100,Math.round(e)))}function Sn(e){const r=e/1e3;return Number.isInteger(r)?`${r}k`:`${Number(r.toFixed(1))}k`}function Mu(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,`${Sn(n)} used / ${Sn(a)}`,`${Sn(s)} left`,`${ol(r.remainingPercent)}% context left`].join(" · ")}function $u(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 _u(e){return e.replace(/[\r\n[\]]+/g," ").replace(/\s+/g," ").trim()||"attachment"}function Un(e){return e.type.startsWith("image/")?"photo":"file"}function Vn(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 ss(e,r){return Vn(e,r).length>0}function Du(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function os(e){const r=e.placeholder.match(/^\[(?:PHOTO|FILE)\s+(.+)\]$/);return r!=null&&r[1]?r[1]:Du(e.originalName)}var Zr=[{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 Bu({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 Gu({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 Fu(){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 Hu(){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 Ou(){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 Wu(){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 Uu(){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 qn(){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 Vu(e){switch(e){case"bearerToken":return"Token";case"oAuth":return"OAuth";case"notLoggedIn":return"Login";case"unsupported":return"Public";default:return"Unknown"}}function qu(e){switch(e){case"repo":return"Repo";case"system":return"System";case"admin":return"Admin";case"user":default:return"User"}}function Ku(e){var r;return((r=Zr.find(n=>n.value===e))==null?void 0:r.label)??e}function Xu(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 Yu(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 Ju(e){return e.source==="user"?"global":e.source==="project"?"project":null}function ll(e){const r=Ju(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 Qu(e){switch(e){case"active":return"Active";case"paused":return"Paused";case"budgetLimited":return"Budget";case"complete":return"Complete";default:return e}}function em({contextUsage:e}){const r=(e==null?void 0:e.availability)??"unavailable",n=ol(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 Bt({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 tm(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 rm(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 nm(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?Qu(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 am(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 sm(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 om(e){if(!e)return"";const r=document.createElement("div");return r.innerHTML=e,r.textContent??""}function lm(e){return!!e.querySelector("[style], font")}function Ht(e){return e instanceof HTMLElement&&e.dataset.segmentType==="attachment"&&e.dataset.placeholder?e.dataset.placeholder:e.textContent??""}function il(e){let r="";for(const n of Array.from(e.childNodes))r+=Ht(n);return r.replace(/\u00a0/g," ")}function ls(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+=Ht(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 il(e).length;if(a=d,d instanceof HTMLElement&&d.dataset.segmentType==="attachment"){const h=document.createRange();h.selectNodeContents(d);const u=Ht(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=Ht(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,Ht(d).length);l+=Ht(d).length}return l}function im(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:ls(e,n.startContainer,n.startOffset),end:ls(e,n.endContainer,n.endOffset)}}function is(e,r){let n=Math.max(0,r);const a=Array.from(e.childNodes);for(const[s,o]of a.entries()){const i=Ht(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 dm(e,r){const n=is(e,r.start),a=is(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 cm(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}sn();Pt();function hm({className:e,...r}){return t.jsx("div",{"data-slot":"input-group",role:"group",className:at("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 um=Er("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 mm({className:e,align:r="inline-start",...n}){return t.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":r,className:at(um({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 pm=Er("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 Ct({className:e,type:r="button",variant:n="ghost",size:a="xs",...s}){return t.jsx(Tr,{type:r,"data-size":a,variant:n,className:at(pm({size:a}),e),...s})}function fm({className:e,...r}){return t.jsx("span",{className:at("flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*=size-])]:size-4",e),...r})}function gm({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 xm(e){if(!e)return"reset time unavailable";const r=new Date(e);return Number.isNaN(r.getTime())?"reset time unavailable":`resets ${r.toLocaleString()}`}function bm({usage:e}){const[r,n]=c.useState(!1);if(!e||e.authKind!=="subscription"||e.windows.length===0)return null;const a=e.windows.slice(0,2),s=a.map(o=>{const l=Math.max(0,100-o.usedPercent);return`${o.label}: ${l}% remaining, ${xm(o.resetsAt)}`}).join(". ");return t.jsxs("button",{type:"button",className:`thread-subscription-usage group pointer-events-auto absolute bottom-0 right-2 inline-flex h-4 items-center gap-1 rounded-t-md border border-b-0 border-stone-500/50 bg-stone-950 px-1 text-[7px] font-normal leading-none text-stone-200 shadow-sm transition-[border-color,background-color,opacity] duration-200 hover:border-stone-400/75 hover:bg-stone-900 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-sky-200/70 sm:right-3 sm:text-[7px] ${e.stale?"opacity-70":"opacity-95"}`,"aria-label":`${e.provider} subscription usage. ${s}`,"aria-expanded":r,onClick:()=>n(o=>!o),children:[a.map(o=>{const l=Math.max(0,Math.min(100,100-o.usedPercent)),i=Math.round(18+l/100*190);return t.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[t.jsx("span",{className:"font-normal tracking-[-0.01em]",children:o.label}),t.jsx("span",{"data-subscription-window-track":"true",className:"h-0.5 w-7 overflow-hidden rounded-full bg-stone-600/55 sm:w-9",children:t.jsx("span",{className:"block h-full rounded-full transition-[width] duration-500 ease-out",style:{width:`${l}%`,backgroundImage:`linear-gradient(90deg, oklch(68% 0.17 ${i}), oklch(82% 0.13 ${Math.min(i+18,235)}))`}})})]},o.id)}),t.jsxs("span",{"aria-hidden":!r,className:`pointer-events-none absolute right-0 bottom-full mb-1 whitespace-nowrap rounded-md border border-stone-600/65 bg-stone-950/95 px-1.5 py-1 text-[9px] font-normal leading-none text-stone-100 shadow-lg transition-[opacity,transform] duration-200 group-hover:translate-y-0 group-hover:opacity-100 group-focus-visible:translate-y-0 group-focus-visible:opacity-100 ${r?"translate-y-0 opacity-100":"translate-y-0.5 opacity-0"}`,children:[a.map((o,l)=>t.jsxs("span",{children:[l>0?" · ":"",o.label," ",Math.round(100-o.usedPercent),"%"]},o.id)),e.stale?" · last known":""]})]})}function vm({activeView:e,followTail:r,onToggleFollow:n,canJumpToPreviousTurn:a,onJumpToPreviousTurn:s,canJumpToNextTurn:o,onJumpToNextTurn:l,subscriptionUsage:i}){return e!=="chat"?null:t.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-[90] h-11 -translate-y-full bg-transparent touch-manipulation sm:h-10",children:[t.jsxs("span",{role:"group","aria-label":"Timeline navigation",className:`thread-jump-latest-badge pointer-events-auto absolute bottom-1 left-1/2 inline-flex h-5 min-w-[7.5rem] -translate-x-1/2 overflow-hidden 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("button",{type:"button","aria-label":"Jump to previous turn",title:a?"Jump to the start of the previous turn":"No earlier turn",disabled:!a,onClick:()=>s==null?void 0:s(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70 disabled:cursor-default disabled:opacity-35",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:"M3.5 12h9M8 10V5M6 7l2-2 2 2"})})}),t.jsx("span",{"aria-hidden":"true",className:"w-px bg-current opacity-20"}),t.jsx("button",{type:"button","aria-label":"Jump to latest",title:r?"Latest messages are in view":"Jump to the bottom",onClick:()=>n==null?void 0:n(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70",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 5.5 4 4 4-4M3.5 12.5h9"})})}),t.jsx("span",{"aria-hidden":"true",className:"w-px bg-current opacity-20"}),t.jsx("button",{type:"button","aria-label":"Jump to next turn",title:o?"Jump to the start of the next turn":"No later turn",disabled:!o,onClick:()=>l==null?void 0:l(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70 disabled:cursor-default disabled:opacity-35",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:"M3.5 4h9M8 6v5m-2-2 2 2 2-2"})})})]}),t.jsx(bm,{usage:i})]})}function km({activeView:e,layerClassName:r,formClassName:n,shellClassName:a,inputGroupClassName:s,error:o,followTail:l,photoInputRef:i,fileInputRef:d,onAppendAttachments:h,onToggleFollow:u,canJumpToPreviousTurn:m,onJumpToPreviousTurn:f,canJumpToNextTurn:p,onJumpToNextTurn:g,subscriptionUsage:k,onSubmit:w,formRef:x,promptSlot:j,pendingQueueSlot:y,toolbarSlot:b,goalSlot:v,shellPromptSlot:S}){return t.jsxs("div",{className:r,children:[t.jsx(gm,{photoInputRef:i,fileInputRef:d,onAppendAttachments:h}),t.jsx(vm,{activeView:e,followTail:l,onToggleFollow:u,canJumpToPreviousTurn:m,onJumpToPreviousTurn:f,canJumpToNextTurn:p,onJumpToNextTurn:g,subscriptionUsage:k}),y,t.jsxs("form",{ref:x,"data-testid":e==="chat"?"chat-composer":void 0,onSubmit:w,className:n,children:[t.jsxs("div",{className:`${a} flex w-full flex-col overflow-visible rounded-[16px] sm:rounded-[18px]`,children:[t.jsxs(hm,{className:s,children:[j,b]}),v,S]}),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 wm({prompts:e,onSteer:r,onCancel:n}){const[a,s]=c.useState(()=>new Set);async function o(l,i){if(!(!i||a.has(l))){s(d=>new Set(d).add(l));try{await i(l)}catch{}finally{s(d=>{const h=new Set(d);return h.delete(l),h})}}}return t.jsxs("section",{"aria-label":"Queued prompts",className:"thread-composer-pending-queue mx-auto mb-2 w-full max-w-4xl overflow-hidden rounded-xl border",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 text-[11px] font-medium text-[var(--theme-fg-muted)]",children:[t.jsx("span",{children:"Queued"}),t.jsx("span",{children:e.length})]}),t.jsx("div",{className:"max-h-36 overflow-y-auto",children:e.map(l=>{const i=a.has(l.id);return t.jsxs("div",{className:"thread-composer-pending-row flex min-h-10 items-center gap-2 border-t px-3 py-2",children:[t.jsx("p",{className:"min-w-0 flex-1 truncate text-sm text-[var(--theme-fg)]",title:l.prompt,children:l.prompt}),l.optimistic?t.jsxs("span",{className:"inline-flex h-8 items-center gap-1.5 px-1.5 text-xs text-[var(--theme-fg-muted)]",children:[t.jsx($.Loader2,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":"true"}),"Queueing"]}):t.jsxs(t.Fragment,{children:[r?t.jsxs("button",{type:"button",disabled:i,onClick:()=>void o(l.id,r),className:"thread-composer-steer-button inline-flex h-8 items-center gap-1.5 rounded-lg border px-2.5 text-xs font-medium transition disabled:cursor-wait disabled:opacity-60",children:[i?t.jsx($.Loader2,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":"true"}):t.jsx($.CornerUpRight,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Steer"]}):null,n?t.jsx("button",{type:"button",disabled:i,"aria-label":"Remove queued prompt",title:"Remove from queue",onClick:()=>void o(l.id,n),className:"thread-composer-queue-remove inline-flex h-8 w-8 items-center justify-center rounded-lg transition disabled:cursor-wait disabled:opacity-60",children:t.jsx($.X,{className:"h-4 w-4","aria-hidden":"true"})}):null]})]},l.id)})})]})}function ym({open:e,iconButtonClassName:r,menuClassName:n,menuItemClassName:a,onToggle:s,onPickPhoto:o,onPickFile:l}){return t.jsxs("div",{className:"relative",children:[t.jsx(Ct,{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(Hu,{})}),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 dl=[{mode:"read-only",label:"Read only"},{mode:"workspace-write",label:"Workspace write"},{mode:"danger-full-access",label:"Danger"}];function ds(e){var r;return((r=dl.find(n=>n.mode===e))==null?void 0:r.label)??"Default"}function jm({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:k,fastMode:w,sendButtonLabel:x,sendButtonClassName:j,modelControlsDisabled:y,effortControlsDisabled:b,effortControlTitle:v,inlineToggleClassName:S,menuItemClassName:N,planToggleActiveClassName:L,sendButtonBaseClassName:R,onSetOpenMenu:P,onUpdateSettings:Q}){return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative min-w-0",children:[t.jsx(Ct,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="model","aria-label":r??"Select model",disabled:y||n.length===0,onClick:()=>P(D=>D==="model"?null:"model"),title:w?`Fast mode is on. Turn it off from the slash toolbox to edit model. ${a}`:a,className:`${S} 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(em,{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:()=>Q({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":`${N} 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(Ct,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="effort",disabled:b,onClick:()=>P(D=>D==="effort"?null:"effort"),title:v,className:`${S} rounded-full px-2 disabled:cursor-not-allowed disabled:text-stone-700 ${b?"text-stone-500":"text-stone-300 hover:text-stone-100"}`,children:ns(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:()=>Q({reasoningEffort:D.reasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${D.reasoningEffort===o?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:ns(D.reasoningEffort)})},D.reasoningEffort))})})]}),u&&t.jsxs("div",{className:"relative",children:[t.jsx(Ct,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="sandbox","aria-label":`Sandbox: ${ds(d)}`,disabled:m,onClick:()=>P(D=>D==="sandbox"?null:"sandbox"),title:`Sandbox: ${ds(d)}`,className:`${S} 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:dl.map(D=>t.jsx("button",{type:"button",onClick:()=>Q({sandboxMode:D.mode}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${D.mode===d?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:D.label})},D.mode))})})]}),h&&t.jsx(Ct,{type:"button",variant:"ghost",size:"xs","aria-pressed":i==="plan",disabled:m,onClick:()=>Q({collaborationMode:i==="plan"?"default":"plan"}),className:`${S} 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(Ct,{type:"submit",variant:"default",size:"icon-xs","aria-label":f?"Set goal":"Send Prompt",title:x,disabled:p||(g==="chat"?k:!1),className:`${R} h-9 w-9 rounded-full text-sm font-medium disabled:cursor-not-allowed sm:h-8 sm:w-8 ${j}`,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(qn,{}),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(qn,{}),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(Bt,{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(Bt,{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(Bt,{label:"CTRL-D"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("esc"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"ESC"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("tab"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"TAB"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("up"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"UP"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("down"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"DOWN"})})]})})}function Cm({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 Tm({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:k,onSetHooksPanelMode:w,onClearHookConfigStatus:x,onSetEditingHookTarget:j,onSetHookScope:y,onSetHookEventName:b,onSetHookMatcher:v,onSetHookCommand:S,onSetHookTimeoutSec:N,onSetHookStatusMessage:L,onSaveHook:R,onStartEditingHook:P,onTrustHook:Q,onUntrustHook:D}){var Z,J,z,te,se;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:((Z=r.data)==null?void 0:Z.projectHooksPath)??"<workspace hooks config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:_=>{_.stopPropagation(),k(),w("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:_=>y(_.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:_=>b(_.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:Zr.map(_=>t.jsx("option",{value:_.value,children:_.label},_.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:_=>v(_.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:_=>S(_.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:_=>N(_.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:_=>L(_.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:()=>{w("list"),j(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 R(),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"&&((J=r.data)!=null&&J.warnings.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.warnings.map(_=>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:_},_))}):null,e==="list"&&((z=r.data)!=null&&z.errors.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.errors.map(_=>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:_.message}),t.jsx("p",{className:"mt-1 break-all text-rose-100/60",children:_.path})]},`${_.path}:${_.message}`))}):null,e==="list"&&((te=r.data)!=null&&te.hooks.length)?t.jsx("div",{className:"space-y-2",children:r.data.hooks.map(_=>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:[Ku(_.eventName),_.matcher?` · ${_.matcher}`:""]}),t.jsx("p",{className:"mt-0.5 truncate font-mono text-[11px] text-stone-400",children:_.command??_.handlerType}),_.statusMessage?t.jsx("p",{className:"mt-1 truncate text-[11px] text-stone-500",children:_.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:[ll(_)?t.jsx("button",{type:"button",onClick:ie=>{ie.stopPropagation(),P(_)},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&&_.trustStatus==="trusted"&&!_.isManaged?t.jsx("button",{type:"button",disabled:s,onClick:ie=>{ie.stopPropagation(),D(_)},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,(_.trustStatus==="untrusted"||_.trustStatus==="modified")&&!_.isManaged&&a?t.jsx("button",{type:"button",disabled:s||!_.currentHash,onClick:ie=>{ie.stopPropagation(),Q(_)},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:Yu(_.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:Xu(_.source)}),t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:_.enabled?"Enabled":"Disabled"}),t.jsxs("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:[_.timeoutSec,"s"]})]})]},_.key))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((se=r.data)==null?void 0:se.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 Vr(e){return e.localGoalId??`${e.createdAt}:${e.objective}`}function Em(e,r){const n=e?[e,...r]:r,a=new Set;return n.filter(s=>{const o=Vr(s);return a.has(o)?!1:(a.add(o),!0)})}function Lm(e){if(e<60)return`${e}s`;const r=Math.floor(e/60);return r<60?`${r}m`:`${Math.floor(r/60)}h ${r%60}m`}function Im(e){switch(e){case"budgetLimited":return"Budget limited";case"complete":return"Complete";case"terminated":return"Terminated";case"paused":return"Paused";default:return"Active"}}function zm({goalState:e,goalHistory:r,busy:n,onBack:a,onUpdateGoal:s}){const o=Em(e.data,r),l=e.data?Vr(e.data):null;return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-h-11 items-center justify-between gap-3 border-b border-[var(--theme-border)] px-3 py-2",children:[t.jsx("button",{type:"button",onClick:a,className:"min-h-9 rounded-lg px-2 text-xs font-medium text-[var(--theme-fg-muted)] transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--theme-accent-border)]",children:"Back"}),t.jsx("span",{className:"text-xs font-semibold text-[var(--theme-fg)]",children:"Goals"})]}),e.error?t.jsx("p",{className:"m-3 rounded-lg border border-[var(--status-danger-border)] bg-[var(--status-danger-bg)] px-3 py-2 text-xs text-[var(--status-danger-fg)]",children:e.error}):null,e.status==="loading"&&o.length===0?t.jsxs("div",{className:"space-y-2 p-3",role:"status","aria-label":"Loading goals",children:[t.jsx("div",{className:"h-12 animate-pulse rounded-lg bg-[var(--theme-muted)] motion-reduce:animate-none"}),t.jsx("div",{className:"h-12 animate-pulse rounded-lg bg-[var(--theme-muted)] motion-reduce:animate-none"})]}):o.length===0?t.jsx("p",{className:"px-4 py-5 text-center text-sm text-[var(--theme-fg-muted)]",children:"No goals in this thread yet."}):t.jsx("div",{className:"max-h-72 divide-y divide-[var(--theme-border)] overflow-y-auto",children:o.map(i=>{const d=Vr(i)===l&&["active","paused","budgetLimited"].includes(i.status);return t.jsxs("div",{className:"px-3 py-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx("p",{className:"min-w-0 flex-1 text-sm font-medium leading-5 text-[var(--theme-fg)]",children:i.objective}),t.jsx("span",{className:"shrink-0 rounded-full border border-[var(--theme-border)] px-2 py-1 text-[10px] font-medium text-[var(--theme-fg-muted)]",children:Im(i.status)})]}),t.jsxs("p",{className:"mt-1.5 text-[11px] text-[var(--theme-fg-muted)]",children:[Lm(i.timeUsedSeconds)," · ",i.tokensUsed.toLocaleString()," tokens"]}),d&&s?t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsx("button",{type:"button",disabled:n||i.status==="active",onClick:()=>void s({status:"active"}),className:"min-h-9 rounded-lg border border-[var(--theme-border)] px-3 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:opacity-45",children:"Continue"}),t.jsx("button",{type:"button",disabled:n||i.status==="paused",onClick:()=>void s({status:"paused"}),className:"min-h-9 rounded-lg border border-[var(--theme-border)] px-3 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:opacity-45",children:"Pause"}),t.jsx("button",{type:"button",disabled:n,onClick:()=>void s({status:"terminated"}),className:"min-h-9 rounded-lg px-3 text-xs font-medium text-[var(--status-danger-fg)] transition hover:bg-[var(--status-danger-bg)] disabled:cursor-not-allowed disabled:opacity-45",children:"Terminate"})]}):null]},Vr(i))})})]})}function Pm({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:k,onSetMcpRawBlock:w,onPrepareRawMcpBlock:x,onSaveHttpMcp:j,onSaveRawMcpBlock:y}){var b,v;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:S=>{S.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:S=>{S.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:S=>{S.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:S=>g(S.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:S=>k(S.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 j(),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:S=>w(S.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 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 raw block"})]})]}):null,e==="list"&&((b=r.data)!=null&&b.servers.length)?t.jsx("div",{className:"space-y-2",children:r.data.servers.map(S=>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:S.name}),t.jsxs("p",{className:"mt-0.5 text-xs text-stone-400",children:[S.tools.length," tools · ",S.resourceCount," ","resources · ",S.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:Vu(S.authStatus)})]}),S.tools.length>0?t.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-stone-500",children:S.tools.slice(0,4).map(N=>N.title??N.name).join(" · ")}):null]},S.name))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((v=r.data)==null?void 0:v.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 Rm({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:qu(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(qn,{}),"$",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 Am({open:e,slashPanelView:r,availableToolboxItems:n,busy:a,forkBusy:s,forkTurnOptionsState:o,skillsState:l,goalState:i,goalHistory:d,goalBusy:h,copiedSkillName:u,hooksPanelMode:m,hooksState:f,hostConfigFilesAvailable:p,hookTrustAvailable:g,hookConfigBusy:k,hookConfigError:w,hookConfigSuccess:x,editingHookTarget:j,hookScope:y,hookEventName:b,hookMatcher:v,hookCommand:S,hookTimeoutSec:N,hookStatusMessage:L,mcpPanelMode:R,mcpState:P,mcpConfigEditing:Q,mcpConfigPath:D,mcpConfigError:Z,mcpConfigSuccess:J,mcpConfigBusy:z,mcpHttpName:te,mcpHttpUrl:se,mcpRawBlock:_,iconButtonClassName:ie,menuClassName:q,menuItemClassName:H,panelButtonClassName:G,chipButtonClassName:T,onToggle:F,onToolboxItemClick:B,toolboxItemDisabled:E,toolboxItemClassName:C,toolboxItemStatus:W,onSetSlashPanelView:U,onViewGoals:ae,onUpdateGoal:K,onOpenForkTurns:de,onForkLatest:ee,onForkTurn:ke,onCopySkillInvokeName:le,onResetHookForm:je,onSetHooksPanelMode:Ae,onClearHookConfigStatus:ce,onSetEditingHookTarget:ne,onSetHookScope:Le,onSetHookEventName:Y,onSetHookMatcher:me,onSetHookCommand:we,onSetHookTimeoutSec:ye,onSetHookStatusMessage:De,onSaveHook:Be,onStartEditingHook:_e,onTrustHook:Oe,onUntrustHook:V,onSetMcpPanelMode:he,onClearMcpConfigStatus:ve,onSetMcpHttpName:I,onSetMcpHttpUrl:O,onSetMcpRawBlock:oe,onPrepareRawMcpBlock:ge,onSaveHttpMcp:Ne,onSaveRawMcpBlock:Ce}){return t.jsxs("div",{className:"relative",children:[t.jsx(Ct,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Open slash toolbox",title:"Open slash toolbox",onClick:F,className:`${ie} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx(Ou,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${q} 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:xe=>{xe.stopPropagation()},onMouseDown:xe=>{xe.stopPropagation()},onPointerDown:xe=>{xe.stopPropagation()},onTouchStart:xe=>{xe.stopPropagation()},children:r==="root"?t.jsxs("div",{className:"p-2",children:[n.map((xe,Ge)=>xe.action==="goal"?t.jsxs("div",{className:`mt-1 flex min-h-11 overflow-hidden rounded-xl border border-[var(--theme-border)] ${Ge===0?"mt-0":""}`,title:xe.description??xe.label,children:[t.jsx("button",{type:"button",disabled:E(xe),onClick:()=>{U("goals"),ae==null||ae()},className:"min-w-0 flex-1 px-3 py-2.5 text-left text-sm text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--theme-accent-border)] disabled:cursor-not-allowed disabled:opacity-45","aria-label":"View goals",children:t.jsx("span",{children:xe.command})}),t.jsx("button",{type:"button",disabled:E(xe),onClick:Me=>B(xe,Me),className:"min-w-14 border-l border-[var(--theme-border)] px-3 text-xs font-semibold text-[var(--theme-fg-muted)] transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)] focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--theme-accent-border)] disabled:cursor-not-allowed disabled:opacity-45","aria-label":"Open goal composer",children:"Open"})]},`${xe.action}:${xe.command}`):t.jsx("button",{type:"button",disabled:E(xe),onClick:Me=>B(xe,Me),className:`${C(xe)} ${Ge===0?"mt-0":""}`,title:xe.description??xe.label,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:xe.command}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:W(xe)})]})},`${xe.action}:${xe.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==="goals"?t.jsx(zm,{goalState:i,goalHistory:d,busy:h,onBack:()=>U("root"),onUpdateGoal:K}):r==="fork"?t.jsx(Cm,{busy:a,forkBusy:s,composerMenuItemClassName:H,onForkLatest:ee,onSelectForkTurnPanel:()=>(U("forkTurns"),de())}):r==="forkTurns"?t.jsx(Sm,{forkTurnOptionsState:o,forkBusy:s,composerPanelButtonClassName:G,onForkTurn:ke}):r==="skills"?t.jsx(Rm,{skillsState:l,copiedSkillName:u,composerChipButtonClassName:T,onCopySkillInvokeName:le}):r==="hooks"?t.jsx(Tm,{hooksPanelMode:m,hooksState:f,hostConfigFilesAvailable:p,hookTrustAvailable:g,hookConfigBusy:k,hookConfigError:w,hookConfigSuccess:x,editingHookTarget:j,hookScope:y,hookEventName:b,hookMatcher:v,hookCommand:S,hookTimeoutSec:N,hookStatusMessage:L,composerChipButtonClassName:T,onResetHookForm:je,onSetHooksPanelMode:Ae,onClearHookConfigStatus:ce,onSetEditingHookTarget:ne,onSetHookScope:Le,onSetHookEventName:Y,onSetHookMatcher:me,onSetHookCommand:we,onSetHookTimeoutSec:ye,onSetHookStatusMessage:De,onSaveHook:Be,onStartEditingHook:_e,onTrustHook:Oe,onUntrustHook:V}):t.jsx(Pm,{mcpPanelMode:R,mcpState:P,mcpConfigEditing:Q,mcpConfigPath:D,mcpConfigError:Z,mcpConfigSuccess:J,mcpConfigBusy:z,mcpHttpName:te,mcpHttpUrl:se,mcpRawBlock:_,composerPanelButtonClassName:G,composerChipButtonClassName:T,onSetMcpPanelMode:he,onClearMcpConfigStatus:ve,onSetMcpHttpName:I,onSetMcpHttpUrl:O,onSetMcpRawBlock:oe,onPrepareRawMcpBlock:ge,onSaveHttpMcp:Ne,onSaveRawMcpBlock:Ce})})})]})}function Mm({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(mm,{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(Am,{...i}):null,!e&&d?t.jsx(ym,{...d}):null,r&&t.jsx(Ct,{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(Wu,{}):t.jsx(Fu,{})})]}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-end gap-1.5",children:[!e&&h?t.jsx(jm,{...h}):null,e&&a?t.jsx(fm,{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(Uu,{})}),s==="shellTools"&&u?t.jsx(Nm,{...u}):null]})]})]})}function $m(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`attachment-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function _m(e){return[...e.filter(r=>Un(r)==="photo"),...e.filter(r=>Un(r)==="file")]}function Dm({prompt:e,attachments:r,updateDraft:n,getSelection:a,selectionSnapshotRef:s,pendingSelectionRef:o,pendingInsertedAttachmentIdsRef:l,onInserted:i,buildClientId:d=$m}){const h=c.useCallback((f,p)=>{if(f.length===0)return!1;const g=Nu({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(_m(f),Un),[h]);return{appendAttachments:u,appendDroppedAttachments:m}}function cs(e){for(const r of e.values())URL.revokeObjectURL(r);e.clear()}function Bm({attachments:e,isShellView:r}){const n=c.useRef(new Map),[a,s]=c.useState({});return c.useEffect(()=>{const o=n.current;if(r){cs(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()=>{cs(o)}},[]),a}var Gm=180;function Tn(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(()=>Tn(r,n)),d=c.useRef(null),h=c.useRef(l),u=c.useRef(_r(l)),m=!e&&r!==void 0&&n!==void 0&&typeof a=="function",f=m?_r(Tn(r,n)):"",p=c.useRef(f);c.useLayoutEffect(()=>{if(!m){p.current="";return}const y=Tn(r,n),b=_r(y);b!==p.current&&(p.current=b,u.current=b,h.current=y,d.current!==null&&(window.clearTimeout(d.current),d.current=null),i(y))},[n,r,m]);const g=c.useCallback(y=>{if(!m||!a)return;const b=_r(y);b!==u.current&&(u.current=b,a(()=>({prompt:y.prompt,attachments:y.attachments})))},[m,a]);c.useEffect(()=>()=>{g(h.current),d.current!==null&&window.clearTimeout(d.current)},[g]);const k=c.useCallback((y,b)=>{if(m){if(d.current!==null&&(window.clearTimeout(d.current),d.current=null),b==="immediate"){g(y);return}d.current=window.setTimeout(()=>{d.current=null,g(h.current)},Gm)}},[m,g]),w=c.useCallback((y=h.current)=>{k(y,"immediate")},[k]),x=c.useCallback((y,b="immediate")=>{if(m){const v=y(h.current);h.current=v,i(v),k(v,b);return}o(v=>y(v))},[m,k]),j=m?l:s;return{prompt:j.prompt,attachments:j.attachments,isDraftControlled:m,updateDraft:x,flushControlledDraftToHost:w}}function Hm({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 Om({prompt:e,goalTokenBudgetSource:r,promptRef:n,onOpenGoal:a,onPrepareGoalSubmit:s,onUpdateGoal:o,updateDraft:l,closeMenu:i,resetSlashPanel:d}){const[h,u]=c.useState(!1),[m,f]=c.useState(""),[p,g]=c.useState(!1),[k,w]=c.useState(null),x=c.useCallback(async()=>{const b=e.trim();if(!b)return w("Goal objective cannot be empty."),!1;const v=m.trim(),S=Iu(v);if(v.length>0&&(S===null||!Number.isInteger(S)||S<=0))return w("Token budget must be a positive number in thousands."),!1;if(!o)return w("/goal is unavailable in this view."),!1;g(!0),w(null);try{return s&&await s({objective:b,tokenBudget:S})===!1?!1:(await o({objective:b,status:"active",tokenBudget:S}),f(""),u(!1),l(()=>({prompt:"",attachments:[]})),!0)}catch(N){return w(N instanceof Error?N.message:"Unable to set goal."),!1}finally{g(!1)}},[m,s,o,e,l]),j=c.useCallback(()=>{i(),d(),u(!0),f(zu(r==null?void 0:r.tokenBudget)),w(null),a==null||a(),requestAnimationFrame(()=>{var b;(b=n.current)==null||b.focus()})},[i,r==null?void 0:r.tokenBudget,a,n,d]),y=c.useCallback(()=>{u(!1),w(null)},[]);return{goalComposeMode:h,goalTokenBudget:m,goalBusy:p,goalLocalError:k,setGoalTokenBudget:f,submitGoal:x,enterGoalComposeMode:j,exitGoalComposeMode:y}}var En=`node -e "process.stdin.resume(); process.stdin.on('end', () => console.error('hook ran'))"`;function Wm(e){const r=new Map;for(const n of e??[])r.set(n.eventName,n.command);return r}function Um({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,k]=c.useState(En),[w,x]=c.useState("30"),[j,y]=c.useState("Running hook"),[b,v]=c.useState(null),[S,N]=c.useState(!1),[L,R]=c.useState(null),[P,Q]=c.useState(null),D=c.useMemo(()=>Wm(r),[r]),Z=c.useCallback(H=>D.get(H)??D.get("preToolUse")??En,[D]),J=c.useMemo(()=>new Set([En,...D.values()]),[D]),z=c.useCallback(()=>{R(null),Q(null)},[]);c.useEffect(()=>{e!=="hooks"&&(i("list"),z())},[z,e]),c.useEffect(()=>{const H=Zr.find(G=>G.value===u);p(G=>{const T=G.trim(),F=new Set(Zr.map(B=>B.matcherHint).filter(Boolean));return T&&!F.has(T)?G:(H==null?void 0:H.matcherHint)??""}),k(G=>J.has(G.trim())?Z(u):G)},[Z,J,u]);const te=c.useCallback(()=>{v(null),h("project"),m("preToolUse"),p("Bash"),k(Z("preToolUse")),x("30"),y("Running hook")},[Z]),se=c.useCallback(H=>{const G=ll(H);if(!G){R("Only command hooks in global or project hooks.json can be edited here.");return}v(G),h(G.scope),m(G.eventName),p(G.matcher??""),k(G.command),x(G.timeoutSec?String(G.timeoutSec):""),y(G.statusMessage??""),R(null),Q(null),i("edit")},[]),_=c.useCallback(async()=>{if(l==="edit"&&!a){R("Hook editing is unavailable in this view.");return}if(l!=="edit"&&!n){R("Hook editing is unavailable in this view.");return}if(l==="edit"&&!b){R("Select a hook to edit first.");return}const H=g.trim();if(!H){R("Hook command cannot be empty.");return}const G=w.trim(),T=G?Number(G):null;if(G&&(T===null||!Number.isInteger(T)||T<=0)){R("Timeout must be a positive number of seconds.");return}N(!0),R(null),Q(null);try{const F={scope:d,eventName:u,matcher:f.trim()||null,command:H,timeoutSec:T,statusMessage:j.trim()||null};l==="edit"?await(a==null?void 0:a({...F,target:b})):await(n==null?void 0:n(F)),Q(`${d==="project"?"Project":"Global"} hook ${l==="edit"?"updated":"written"} in hooks.json and trusted.`),i("list"),v(null)}catch(F){R(F instanceof Error?F.message:"Unable to write hooks.json.")}finally{N(!1)}},[b,g,u,f,d,j,w,l,n,a]),ie=c.useCallback(async H=>{if(!s||!H.currentHash){R("Hook trust is unavailable in this view.");return}N(!0),R(null),Q(null);try{await s({key:H.key,currentHash:H.currentHash}),Q("Hook trusted.")}catch(G){R(G instanceof Error?G.message:"Unable to trust hook.")}finally{N(!1)}},[s]),q=c.useCallback(async H=>{if(!o){R("Hook trust is unavailable in this view.");return}N(!0),R(null),Q(null);try{await o({key:H.key}),Q("Hook untrusted.")}catch(G){R(G instanceof Error?G.message:"Unable to untrust hook.")}finally{N(!1)}},[o]);return{hooksPanelMode:l,hookScope:d,hookEventName:u,hookMatcher:f,hookCommand:g,hookTimeoutSec:w,hookStatusMessage:j,editingHookTarget:b,hookConfigBusy:S,hookConfigError:L,hookConfigSuccess:P,setHooksPanelMode:i,setEditingHookTarget:v,setHookScope:h,setHookEventName:m,setHookMatcher:p,setHookCommand:k,setHookTimeoutSec:x,setHookStatusMessage:y,clearHookConfigStatus:z,resetHookForm:te,startEditingHook:se,saveHook:_,trustHook:ie,untrustHook:q}}var Vm=`[mcp_servers.example_stdio]
3687
3689
  command = "npx"
3688
3690
  args = ["-y", "your-mcp-server"]
3689
- `,ds="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:o}){const[s,l]=c.useState(""),[i,d]=c.useState(""),[h,u]=c.useState(""),[m,f]=c.useState(null),[p,g]=c.useState(!1),[b,w]=c.useState(null),[x,j]=c.useState(null),y=c.useCallback(()=>{w(null),j(null)},[]),v=c.useCallback(async()=>{if(!e||!r)throw new Error("Provider config editing is unavailable for this thread.");const R=await r();return f(R.path),R},[e,r]),k=c.useCallback(async R=>{if(!e||!n)throw new Error("Provider config editing is unavailable for this thread.");const P=await n(R);return f(P.path),P},[e,n]),S=c.useCallback(async()=>{const R=Lu(s),P=i.trim();if(!R){w("MCP name must use only letters, numbers, underscore, or hyphen.");return}if(!/^https?:\/\//i.test(P)){w("HTTP MCP URL must start with http:// or https://");return}g(!0),w(null),j(null);try{const Q=await v(),D=rs(Q.content,R,zu(R,P));await k(D),j(ds),a("list"),l(""),d(""),o==null||o()}catch(Q){w(Q instanceof Error?Q.message:"Unable to update provider config.")}finally{g(!1)}},[v,s,i,o,a,k]),N=c.useCallback(async()=>{g(!0),w(null),j(null);try{await v(),u(R=>R||Om),a("stdio")}catch(R){w(R instanceof Error?R.message:"Unable to load provider config.")}finally{g(!1)}},[v,a]),L=c.useCallback(async()=>{const R=Iu(h);if(!R){w("The raw MCP block must start with a header like [mcp_servers.name].");return}g(!0),w(null),j(null);try{const P=await v(),Q=rs(P.content,R,h);await k(Q),j(ds),a("list"),o==null||o()}catch(P){w(P instanceof Error?P.message:"Unable to update provider config.")}finally{g(!1)}},[v,h,o,a,k]);return{mcpHttpName:s,mcpHttpUrl:i,mcpRawBlock:h,mcpConfigPath:m,mcpConfigBusy:p,mcpConfigError:b,mcpConfigSuccess:x,setMcpHttpName:l,setMcpHttpUrl:d,setMcpRawBlock:u,clearMcpConfigStatus:y,prepareRawMcpBlock:N,saveHttpMcp:S,saveRawMcpBlock:L}}function Um({openMenu:e,setOpenMenu:r,slashPanelView:n,setSlashPanelView:a,setMcpPanelMode:o,clearMcpConfigStatus:s,clearHookConfigStatus:l}){const[i,d]=c.useState(null);c.useEffect(()=>{e!=="slash"&&(a("root"),o("list"),s(),l())},[l,s,e,o,a]),c.useEffect(()=>{n!=="mcp"&&(o("list"),s())},[s,o,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 Vm(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=as(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 o=document.createElement("span");o.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]",o.textContent="FILE";const s=document.createElement("span");return s.className="inline-flex max-w-[10rem] truncate",s.textContent=as(n),a.append(o,s),a}function qm(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(Vm(a,r))}return n}function Km({promptRef:e,isShellView:r,prompt:n,promptSegments:a,attachmentPreviewUrls:o,previewSignature:s,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,w=f()!==n||u.current!==s||m.current!==l;w&&(g.replaceChildren(qm(a,o)),u.current=s,m.current=l),b!==null?(g.focus(),lm(g,d.current)||p(b),h.current=b):document.activeElement===g&&w&&p(h.current),i.current=null,d.current=[]},[o,l,r,s,n,e,a,d,i,u,m,p,h,f])}function Xm({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:o=>n(o.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 Ym({promptRef:e,prompt:r,disabled:n,promptPlaceholder:a,canInterrupt:o,interruptLabel:s,composerPromptRegionClassName:l,graphChatInputClassName:i,onInterrupt:d,onInput:h,onPointerDown:u,onPaste:m,onKeyDown:f,onKeyUp:p,onMouseUp:g,onBlur:b,onDragEnter:w,onDragOver:x,onDragLeave:j,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 ${o?"right-12":"right-3 sm:right-4"}`,children:a}),t.jsx("div",{ref:e,role:"textbox","aria-label":"Prompt","aria-multiline":"true",contentEditable:!n,inputMode:"text",suppressContentEditableWarning:!0,onPointerDown:v=>{!n&&document.activeElement!==v.currentTarget&&v.currentTarget.focus({preventScroll:!0}),u==null||u(v)},onInput:h,onPaste:m,onKeyDown:f,onKeyUp:p,onMouseUp:g,onBlur:b,onDragEnter:w,onDragOver:x,onDragLeave:j,onDrop:y,className:`relative z-[1] min-h-[4.25rem] whitespace-pre-wrap break-words pb-2 outline-none sm:min-h-[4.25rem] ${o?"pr-12":""} ${n?"cursor-not-allowed text-slate-500":""}`})]}),o?t.jsx(Ct,{type:"button",variant:"ghost",size:"icon-xs","aria-label":s,title:s,onClick:v=>{v.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 Zm({prompt:e,promptPlaceholder:r,promptRegionClassName:n,promptInputClassName:a,interruptLabel:o,canInterrupt:s,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":o,title:o,onClick:()=>void(m==null?void 0:m()),disabled:!s,className:`absolute right-2.5 top-2.5 inline-flex h-8 w-8 items-center justify-center rounded-full border transition ${s?"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 Jm({isShellView:e,promptRef:r,prompt:n,disabled:a,promptPlaceholder:o,canInterrupt:s,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,promptInputClassName:h,goalComposeMode:u,goalTokenBudget:m,goalLocalError:f,goalBusy:p,busy:g,sendButtonLabel:b,sendButtonClassName:w,onInterrupt:x,onPromptInput:j,onPromptPaste:y,onPromptKeyDown:v,onPromptKeyUp:k,onPromptMouseUp:S,onPromptBlur:N,onPromptDragEnter:L,onPromptDragOver:R,onPromptDragLeave:P,onPromptDrop:Q,onGoalTokenBudgetChange:D,onCancelGoal:Z,onShellPromptChange:J}){return{promptSlot:e?null:t.jsx(Ym,{promptRef:r,prompt:n,disabled:a,promptPlaceholder:o,canInterrupt:s,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,onInterrupt:x,onInput:j,onPaste:y,onKeyDown:v,onKeyUp:k,onMouseUp:S,onBlur:N,onDragEnter:L,onDragOver:R,onDragLeave:P,onDrop:Q}),goalSlot:u&&!e?t.jsx(Xm,{tokenBudget:m,error:f,onTokenBudgetChange:D,onCancel:Z}):null,shellPromptSlot:e?t.jsx(Zm,{prompt:n,promptPlaceholder:o,promptRegionClassName:i,promptInputClassName:h,interruptLabel:l,canInterrupt:s,sendButtonLabel:b,sendButtonClassName:w,sendDisabled:p||g,onPromptChange:J,onPromptKeyDown:v,onInterrupt:x}):null}}function Qm({collaborationMode:e,onUpdateSettings:r,closeMenu:n}){const[a,o]=c.useState(null),s=a??e;c.useEffect(()=>{o(null)},[e]);const l=c.useCallback(async i=>{const d=Su({nextMode:i.collaborationMode,previousOptimisticMode:a});d.optimisticMode&&o(d.optimisticMode);try{await(r==null?void 0:r(i)),d.closeMenuOnSuccess&&n()}catch(h){throw d.shouldRollbackMode&&o(d.rollbackMode),h}},[n,r,a]);return{displayedCollaborationMode:s,updateSettings:l}}function ep({isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:o,toolbarClassName:s,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,inlineToggleClassName:m,planToggleActiveClassName:f,sendButtonBaseClassName:p,slashPanelView:g,availableToolboxItems:b,busy:w,settingsBusy:x,compactBusy:j,forkBusy:y,fastMode:v,goalComposeMode:k,goalBusy:S,goalStatus:N,activeView:L,disabled:R,model:P,modelOptions:Q,modelContextTitle:D,contextUsage:Z,reasoningEffort:J,supportedEfforts:z,displayedCollaborationMode:te,sandboxMode:se,sendButtonLabel:$,sendButtonClassName:le,modelControlsDisabled:q,effortControlsDisabled:H,effortControlTitle:G,forkTurnOptionsState:T,skillsState:F,goalState:B,goalHistory:E,copiedSkillName:C,hooksPanelMode:W,hooksState:U,hookConfigBusy:ne,hookConfigError:K,hookConfigSuccess:ie,editingHookTarget:ee,hookScope:ve,hookEventName:oe,hookMatcher:ye,hookCommand:Me,hookTimeoutSec:de,hookStatusMessage:Ce,mcpPanelMode:Ee,mcpState:Y,mcpConfigPath:ue,mcpConfigError:ke,mcpConfigSuccess:we,mcpConfigBusy:De,mcpHttpName:Fe,mcpHttpUrl:Ae,mcpRawBlock:Oe,capabilities:V,shellControlState:ce,onToggleView:xe,onDismissPromptFocus:I,onSetOpenMenu:O,onToolboxItemClick:ae,onSetSlashPanelView:be,onViewGoals:je,onUpdateGoal:Te,onOpenForkTurns:fe,onForkLatest:Be,onForkTurn:_e,onCopySkillInvokeName:Qe,onResetHookForm:et,onSetHooksPanelMode:it,onClearHookConfigStatus:tt,onSetEditingHookTarget:Ke,onSetHookScope:dt,onSetHookEventName:ft,onSetHookMatcher:Ve,onSetHookCommand:M,onSetHookTimeoutSec:X,onSetHookStatusMessage:ge,onSaveHook:Ne,onStartEditingHook:Pe,onTrustHook:rt,onUntrustHook:nt,onSetMcpPanelMode:$e,onClearMcpConfigStatus:We,onSetMcpHttpName:ut,onSetMcpHttpUrl:st,onSetMcpRawBlock:ct,onPrepareRawMcpBlock:gt,onSaveHttpMcp:Rt,onSaveRawMcpBlock:wt,onPickPhoto:A,onPickFile:pe,onUpdateSettings:ze,onPasteShell:Ge,onCopyShell:Ue,onClearShell:mt,onShellControl:yt}){const Kt=e?null:{open:o==="slash",slashPanelView:g,availableToolboxItems:b,busy:w,forkBusy:y,forkTurnOptionsState:T,skillsState:F,goalState:B,goalHistory:E,goalBusy:S,copiedSkillName:C,hooksPanelMode:W,hooksState:U,hostConfigFilesAvailable:V.hostConfigFiles,hookTrustAvailable:V.hookTrust,hookConfigBusy:ne,hookConfigError:K,hookConfigSuccess:ie,editingHookTarget:ee,hookScope:ve,hookEventName:oe,hookMatcher:ye,hookCommand:Me,hookTimeoutSec:de,hookStatusMessage:Ce,mcpPanelMode:Ee,mcpState:Y,mcpConfigEditing:V.mcpConfigEditing,mcpConfigPath:ue,mcpConfigError:ke,mcpConfigSuccess:we,mcpConfigBusy:De,mcpHttpName:Fe,mcpHttpUrl:Ae,mcpRawBlock:Oe,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,onToggle:()=>O(ot=>ot==="slash"?null:"slash"),onToolboxItemClick:ae,toolboxItemDisabled:ot=>tm(ot,{settingsBusy:x,compactBusy:j,busy:w,forkBusy:y}),toolboxItemClassName:ot=>rm(ot,{fastMode:v,goalComposeMode:k,goalStatus:N,menuItemClassName:d}),toolboxItemStatus:ot=>em(ot,{fastMode:v,compactBusy:j,goalComposeMode:k,goalStatus:N,busy:w}),onSetSlashPanelView:be,onViewGoals:je,onUpdateGoal:Te,onOpenForkTurns:fe,onForkLatest:Be,onForkTurn:_e,onCopySkillInvokeName:Qe,onResetHookForm:et,onSetHooksPanelMode:it,onClearHookConfigStatus:tt,onSetEditingHookTarget:Ke,onSetHookScope:dt,onSetHookEventName:ft,onSetHookMatcher:Ve,onSetHookCommand:M,onSetHookTimeoutSec:X,onSetHookStatusMessage:ge,onSaveHook:Ne,onStartEditingHook:Pe,onTrustHook:rt,onUntrustHook:nt,onSetMcpPanelMode:$e,onClearMcpConfigStatus:We,onSetMcpHttpName:ut,onSetMcpHttpUrl:st,onSetMcpRawBlock:ct,onPrepareRawMcpBlock:gt,onSaveHttpMcp:Rt,onSaveRawMcpBlock:wt},Xt=e?null:{open:o==="attachments",iconButtonClassName:l,menuClassName:i,menuItemClassName:d,onToggle:()=>O(ot=>ot==="attachments"?null:"attachments"),onPickPhoto:A,onPickFile:pe},Mt=e?null:{openMenu:o,model:P,modelOptions:Q,modelContextTitle:D,contextUsage:Z,reasoningEffort:J,supportedEfforts:z,displayedCollaborationMode:te,sandboxMode:se,planModeAvailable:V.planMode,sandboxModeAvailable:V.sandboxMode,settingsBusy:x,goalComposeMode:k,goalBusy:S,activeView:L,disabled:R,fastMode:v,sendButtonLabel:$,sendButtonClassName:le,modelControlsDisabled:q,effortControlsDisabled:H,effortControlTitle:G,inlineToggleClassName:m,menuItemClassName:d,planToggleActiveClassName:f,sendButtonBaseClassName:p,onSetOpenMenu:O,onUpdateSettings:ze};return{isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:o,toolbarClassName:s,iconButtonClassName:l,slashToolboxProps:Kt,attachmentMenuProps:Xt,settingsToolbarProps:Mt,shellToolsPanelProps:o==="shellTools"?{busy:w,shellControlState:ce,onPaste:Ge,onCopy:Ue,onClear:mt,onShellControl:yt}:null,shellControlState:ce,onToggleView:xe,onDismissPromptFocus:I,onSetOpenMenu:O}}function Un({activeView:e,edgeToEdgeMobile:r=!1,busy:n=!1,settingsBusy:a=!1,compactBusy:o=!1,error:s,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:w=null,mcpConfigFormat:x="none",followTail:j=!1,threadConnected:y=!0,shellAvailable:v=!0,disabled:k=!1,disabledPlaceholder:S,shellControlState:N=null,draftPrompt:L,draftAttachments:R,onPickAttachment:P,skillsState:Q={status:"idle",data:null,error:null},mcpState:D={status:"idle",data:null,error:null},hooksState:Z={status:"idle",data:null,error:null},goalState:J={status:"idle",data:null,error:null},goalHistory:z=[],forkTurnOptionsState:te={status:"idle",data:null,error:null},onDraftChange:se,onSubmit:$,onInterrupt:le,onCompact:q,onOpenSkills:H,onOpenMcp:G,onOpenHooks:T,onCreateHook:F,onUpdateHook:B,onTrustHook:E,onUntrustHook:C,onOpenGoal:W,onPrepareGoalSubmit:U,onUpdateGoal:ne,onOpenForkTurns:K,onForkLatest:ie,onForkTurn:ee,onReadProviderConfig:ve,onWriteProviderConfig:oe,onToggleFollow:ye,canJumpToPreviousTurn:Me,onJumpToPreviousTurn:de,canJumpToNextTurn:Ce,onJumpToNextTurn:Ee,subscriptionUsage:Y,onUpdateSettings:ue,onToggleView:ke,onShellCopy:we,onShellControl:De,canInterrupt:Fe=!1,pendingPrompts:Ae=[],onSteerPendingPrompt:Oe,onCancelPendingPrompt:V}){var ja;const[ce,xe]=c.useState(null),[I,O]=c.useState("root"),ae=c.useRef(!1),[be,je]=c.useState("list"),Te=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)&&!!ve&&!!oe,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,ve,oe]),fe=c.useMemo(()=>Ju(b,Te),[Te,b]),Be=c.useRef(null),_e=c.useRef(null),Qe=c.useRef(null),et=c.useRef(null),it=c.useRef(null),tt=c.useRef([]),Ke=c.useRef(null),dt=c.useRef(""),ft=c.useRef(0),Ve=e==="shell",M=v||Ve,X=!!(Ve&&(N!=null&&N.isMobileShell)),ge=(N==null?void 0:N.promptLabel)??null,[Ne,Pe]=c.useState(!1),[rt,nt]=c.useState(0),{prompt:$e,attachments:We,isDraftControlled:ut,updateDraft:st,flushControlledDraftToHost:ct}=Dm({isShellView:Ve,draftPrompt:L,draftAttachments:R,onDraftChange:se}),gt=_m({attachments:We,isShellView:Ve}),{displayedCollaborationMode:Rt,updateSettings:wt}=Qm({collaborationMode:h,onUpdateSettings:ue,closeMenu:()=>xe(null)}),{forkBusy:A,forkLatest:pe,forkTurn:ze}=Bm({slashPanelView:I,onForkLatest:ie,onForkTurn:ee,closeMenu:()=>xe(null)}),{hooksPanelMode:Ge,hookScope:Ue,hookEventName:mt,hookMatcher:yt,hookCommand:Kt,hookTimeoutSec:Xt,hookStatusMessage:Mt,editingHookTarget:cr,hookConfigBusy:ot,hookConfigError:dn,hookConfigSuccess:cn,setHooksPanelMode:Il,setEditingHookTarget:zl,setHookScope:Pl,setHookEventName:Rl,setHookMatcher:Ml,setHookCommand:Al,setHookTimeoutSec:_l,setHookStatusMessage:$l,clearHookConfigStatus:pa,resetHookForm:Dl,startEditingHook:Bl,saveHook:Gl,trustHook:Fl,untrustHook:Hl}=Hm({slashPanelView:I,hookCommandTemplates:w,onCreateHook:F,onUpdateHook:B,onTrustHook:E,onUntrustHook:C}),{goalComposeMode:hr,goalTokenBudget:Ol,goalBusy:hn,goalLocalError:Wl,setGoalTokenBudget:Ul,submitGoal:Vl,enterGoalComposeMode:ql,exitGoalComposeMode:fa}=Gm({prompt:$e,goalTokenBudgetSource:J.data,promptRef:_e,onOpenGoal:W,onPrepareGoalSubmit:U,onUpdateGoal:ne,updateDraft:st,closeMenu:()=>xe(null),resetSlashPanel:()=>O("root")}),{mcpHttpName:Kl,mcpHttpUrl:Xl,mcpRawBlock:Yl,mcpConfigPath:Zl,mcpConfigBusy:Jl,mcpConfigError:Ql,mcpConfigSuccess:ei,setMcpHttpName:ti,setMcpHttpUrl:ri,setMcpRawBlock:ni,clearMcpConfigStatus:ga,prepareRawMcpBlock:ai,saveHttpMcp:si,saveRawMcpBlock:oi}=Wm({hostConfigFilesAvailable:Te.hostConfigFiles,onReadProviderConfig:ve,onWriteProviderConfig:oe,setMcpPanelMode:je,onOpenMcp:G}),{copiedSkillName:li,copySkillInvokeName:ii}=Um({openMenu:ce,setOpenMenu:xe,slashPanelView:I,setSlashPanelView:O,setMcpPanelMode:je,clearMcpConfigStatus:ga,clearHookConfigStatus:pa}),di=c.useCallback(re=>{st(Se=>{if(typeof re=="function"){const Re=re(Se.prompt,Se.attachments);return{prompt:Re.prompt,attachments:Re.attachments??Se.attachments}}return{prompt:re,attachments:Se.attachments}})},[st]),un=c.useMemo(()=>f.find(re=>re.model===l)??null,[l,f]),ci=Pu(l,p),xa=(un==null?void 0:un.supportedReasoningEfforts)??[],hi=c.useMemo(()=>xu($e,We),[We,$e]),ui=c.useMemo(()=>Object.entries(gt).sort(([re],[Se])=>re.localeCompare(Se)).map(([re,Se])=>`${re}:${Se}`).join("|"),[gt]);function mi(re,Se){Se.stopPropagation();const Re=Qu(re,{fastMode:d,goalComposeMode:hr});switch(Re.type){case"toggleFast":wt({fastMode:Re.fastMode});break;case"runCompact":xe(null),q==null||q();break;case"enterGoalCompose":ql();break;case"exitGoalCompose":fa(),xe(null);break;case"openPanel":O(Re.panel),Re.panel==="skills"?H==null||H():Re.panel==="mcp"?G==null||G():Re.panel==="hooks"&&(T==null||T());break;case"insertPrompt":fn(Re.text),O("root"),xe(null);break}}function Yt(){const re=_e.current;return re?sm(re):null}const pi=c.useCallback(re=>{const Se=_e.current;!Se||!re||om(Se,re)},[]),mn=c.useCallback(()=>{const re=_e.current;return re?sl(re):$e},[$e]),{appendAttachments:pn,appendDroppedAttachments:ba}=Am({prompt:$e,attachments:We,updateDraft:st,getSelection:Yt,selectionSnapshotRef:Ke,pendingSelectionRef:it,pendingInsertedAttachmentIdsRef:tt,onInserted:()=>xe(null)}),va=c.useCallback((re,Se)=>{var Re;if(At(),P){P({kind:re,appendAttachments:(Ze,lt=re)=>pn(Ze,lt),defaultPick:()=>{var Ze;return(Ze=Se.current)==null?void 0:Ze.click()}});return}(Re=Se.current)==null||Re.click()},[pn,At,P]);function fn(re){if(!re)return;const Se=Yt()??Ke.current,Re=(Se==null?void 0:Se.start)??$e.length,Ze=(Se==null?void 0:Se.end)??Re,lt=gu(re),Zt=`${$e.slice(0,Re)}${lt}${$e.slice(Ze)}`;st(Xi=>({prompt:Zt,attachments:Xi.attachments}));const _t=Re+lt.length;it.current={start:_t,end:_t},Ke.current={start:_t,end:_t}}Km({promptRef:_e,isShellView:Ve,prompt:$e,promptSegments:hi,attachmentPreviewUrls:gt,previewSignature:ui,editorSanitizeNonce:rt,pendingSelectionRef:it,pendingInsertedAttachmentIdsRef:tt,selectionSnapshotRef:Ke,renderedPreviewSignatureRef:dt,renderedSanitizeNonceRef:ft,serializeEditorPrompt:mn,restoreSelection:pi});function At(){var re;(re=_e.current)==null||re.blur(),document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.blur()}async function fi(){var re;if(At(),xe(null),!!((re=navigator.clipboard)!=null&&re.readText))try{const Se=await navigator.clipboard.readText();fn(Se)}catch{return}}async function ka(){if(!ae.current){ae.current=!0;try{if(ut&&ct(),hr&&!Ve){await Vl();return}const re=yu({prompt:$e,attachments:We,isShellView:Ve});if(!re||await $(re)===!1)return;st(()=>({prompt:"",attachments:[]}))}finally{ae.current=!1}}}async function gi(re){re.preventDefault(),await ka()}function xi(){const re=mn(),Se=Yt();Ke.current=Se;const Re=_e.current;(Re?am(Re):!1)&&(it.current=Se,nt(lt=>lt+1)),st(lt=>({prompt:re,attachments:lt.attachments.filter(Zt=>re.includes(Zt.placeholder))}),"deferred")}function bi(re){var Ze,lt,Zt,_t;const Se=On((Ze=re.clipboardData)==null?void 0:Ze.items,(lt=re.clipboardData)==null?void 0:lt.files),Re=ju({files:Se,plainText:((Zt=re.clipboardData)==null?void 0:Zt.getData("text/plain"))??"",htmlText:((_t=re.clipboardData)==null?void 0:_t.getData("text/html"))??"",htmlToText:nm});Re.preventDefault&&re.preventDefault(),Re.type==="insert-text"?fn(Re.text):Re.type==="append-files"&&ba(Re.files)}function vi(re){var Re,Ze;const Se=es(ns((Re=re.dataTransfer)==null?void 0:Re.items,(Ze=re.dataTransfer)==null?void 0:Ze.files));Se.preventDefault&&re.preventDefault(),Se.activateDragTarget&&Pe(!0)}function ki(re){var Re,Ze;const Se=es(ns((Re=re.dataTransfer)==null?void 0:Re.items,(Ze=re.dataTransfer)==null?void 0:Ze.files));Se.preventDefault&&re.preventDefault(),Se.activateDragTarget&&re.dataTransfer&&(re.dataTransfer.dropEffect="copy"),Se.activateDragTarget&&Pe(!0)}function wi(re){re.currentTarget.contains(re.relatedTarget)||Pe(!1)}function yi(re){var Ze,lt;const Se=On((Ze=re.dataTransfer)==null?void 0:Ze.items,(lt=re.dataTransfer)==null?void 0:lt.files),Re=Nu(Se);Re.preventDefault&&re.preventDefault(),Re.type==="accept-files"&&(Pe(!1),ba(Re.files??[]))}function ji(re){if(re.key==="Enter"&&re.repeat){re.preventDefault();return}if(e==="chat"&&re.key==="/"&&!re.metaKey&&!re.ctrlKey&&!re.altKey&&!n&&!k&&fe.length>0&&mn().trim().length===0){re.preventDefault(),O("root"),xe("slash");return}const Se=Cu({key:re.key,metaKey:re.metaKey,ctrlKey:re.ctrlKey,busy:n,disabled:k});Se.preventDefault&&re.preventDefault(),Se.submit&&ka()}const{promptPlaceholder:Ni,interruptLabel:Ci,sendButtonLabel:wa,sendButtonClassName:ya,modelControlsDisabled:Si,effortControlsDisabled:Ti,effortControlTitle:Ei}=_u({goalComposeMode:hr,goalBusy:hn,threadConnected:y,busy:n,isShellView:Ve,disabledPlaceholder:S,settingsBusy:a,supportedEffortCount:xa.length,fastMode:d}),{composerLayerClassName:Li,formClassName:Ii,composerShellClassName:zi,composerToolbarClassName:Pi,composerIconButtonClassName:Ri,composerMenuClassName:Mi,composerMenuItemClassName:Ai,composerInlineToggleClassName:_i,composerPanelButtonClassName:$i,composerChipButtonClassName:Di,composerPlanToggleActiveClassName:Bi,composerSendButtonClassName:Gi,composerPromptRegionClassName:Fi,promptInputClassName:Hi,graphChatInputGroupClassName:Oi,graphChatInputClassName:Wi}=$u({isShellView:Ve,edgeToEdgeMobile:r,isMobileShell:X,openMenu:ce!==null,isDragTargetActive:Ne,busy:n}),Ui=ep({isShellView:Ve,canToggleShellView:M,isMobileShell:X,shellPromptLabel:ge,openMenu:ce,toolbarClassName:Pi,iconButtonClassName:Ri,menuClassName:Mi,menuItemClassName:Ai,panelButtonClassName:$i,chipButtonClassName:Di,inlineToggleClassName:_i,planToggleActiveClassName:Bi,sendButtonBaseClassName:Gi,slashPanelView:I,availableToolboxItems:fe,busy:n,settingsBusy:a,compactBusy:o,forkBusy:A,fastMode:d,goalComposeMode:hr,goalBusy:hn,goalStatus:(ja=J.data)==null?void 0:ja.status,activeView:e,disabled:k,model:l,modelOptions:f,modelContextTitle:ci,contextUsage:p,reasoningEffort:i,supportedEfforts:xa,displayedCollaborationMode:Rt,sandboxMode:u,sendButtonLabel:wa,sendButtonClassName:ya,modelControlsDisabled:Si,effortControlsDisabled:Ti,effortControlTitle:Ei,forkTurnOptionsState:te,skillsState:Q,goalState:J,goalHistory:z,copiedSkillName:li,hooksPanelMode:Ge,hooksState:Z,hookConfigBusy:ot,hookConfigError:dn,hookConfigSuccess:cn,editingHookTarget:cr,hookScope:Ue,hookEventName:mt,hookMatcher:yt,hookCommand:Kt,hookTimeoutSec:Xt,hookStatusMessage:Mt,mcpPanelMode:be,mcpState:D,mcpConfigPath:Zl,mcpConfigError:Ql,mcpConfigSuccess:ei,mcpConfigBusy:Jl,mcpHttpName:Kl,mcpHttpUrl:Xl,mcpRawBlock:Yl,capabilities:{hostConfigFiles:Te.hostConfigFiles,hookTrust:Te.hookTrust,mcpConfigEditing:Te.mcpConfigEditing,planMode:Te.planMode,sandboxMode:m?!1:Te.sandboxMode},shellControlState:N,onToggleView:ke,onDismissPromptFocus:At,onSetOpenMenu:xe,onToolboxItemClick:mi,onSetSlashPanelView:O,onViewGoals:W,onUpdateGoal:ne,onOpenForkTurns:()=>K==null?void 0:K(),onForkLatest:pe,onForkTurn:ze,onCopySkillInvokeName:ii,onResetHookForm:Dl,onSetHooksPanelMode:Il,onClearHookConfigStatus:pa,onSetEditingHookTarget:zl,onSetHookScope:Pl,onSetHookEventName:Rl,onSetHookMatcher:Ml,onSetHookCommand:Al,onSetHookTimeoutSec:_l,onSetHookStatusMessage:$l,onSaveHook:Gl,onStartEditingHook:Bl,onTrustHook:Fl,onUntrustHook:Hl,onSetMcpPanelMode:je,onClearMcpConfigStatus:ga,onSetMcpHttpName:ti,onSetMcpHttpUrl:ri,onSetMcpRawBlock:ni,onPrepareRawMcpBlock:ai,onSaveHttpMcp:si,onSaveRawMcpBlock:oi,onPickPhoto:()=>va("photo",Qe),onPickFile:()=>va("file",et),onUpdateSettings:re=>void wt(re),onPasteShell:()=>void fi(),onCopyShell:()=>{At(),xe(null),we==null||we()},onClearShell:()=>{At(),xe(null),$({prompt:"clear"})},onShellControl:re=>{At(),xe(null),De==null||De(re)}}),{promptSlot:Vi,goalSlot:qi,shellPromptSlot:Ki}=Jm({isShellView:Ve,promptRef:_e,prompt:$e,disabled:k,promptPlaceholder:Ni,canInterrupt:Fe,interruptLabel:Ci,composerPromptRegionClassName:Fi,graphChatInputClassName:Wi,promptInputClassName:Hi,goalComposeMode:hr,goalTokenBudget:Ol,goalLocalError:Wl,goalBusy:hn,busy:n,sendButtonLabel:wa,sendButtonClassName:ya,onInterrupt:le,onPromptInput:xi,onPromptPaste:bi,onPromptKeyDown:ji,onPromptKeyUp:()=>{Ke.current=Yt()},onPromptMouseUp:()=>{Ke.current=Yt()},onPromptBlur:()=>{Ke.current=Yt(),Pe(!1),ut&&ct()},onPromptDragEnter:vi,onPromptDragOver:ki,onPromptDragLeave:wi,onPromptDrop:yi,onGoalTokenBudgetChange:Ul,onCancelGoal:fa,onShellPromptChange:di});return t.jsx(xm,{activeView:e,layerClassName:Li,formClassName:Ii,shellClassName:zi,inputGroupClassName:Oi,error:s,followTail:j,photoInputRef:Qe,fileInputRef:et,onAppendAttachments:pn,onToggleFollow:ye,canJumpToPreviousTurn:Me,onJumpToPreviousTurn:de,canJumpToNextTurn:Ce,onJumpToNextTurn:Ee,subscriptionUsage:Y,onSubmit:gi,formRef:Be,promptSlot:Vi,pendingQueueSlot:!Ve&&Ae.length>0?t.jsx(bm,{prompts:Ae,onSteer:Oe,onCancel:V}):null,toolbarSlot:t.jsx(Pm,{...Ui}),goalSlot:qi,shellPromptSlot:Ki})}var tp=c.createContext(null);function ll(){return c.useContext(tp)}function vt(e){return e?new Date(e).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"}):"Time unavailable"}function Wt(e){return e?new Date(e).toLocaleString():"Time unavailable"}function rp(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 np(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 il(e){switch(e){case"sending":return"Sending";case"completed":return"Completed";case"interrupted":return"Interrupted";case"failed":return"Failed";case"inProgress":return"Running"}}function ap({open:e,title:r,label:n,value:a,busy:o=!1,onChange:s,onCancel:l,onSubmit:i}){if(c.useEffect(()=>{if(!e)return;function h(u){u.key==="Escape"&&!o&&l()}return window.addEventListener("keydown",h),()=>{window.removeEventListener("keydown",h)}},[o,l,e]),!e)return null;function d(h){h.preventDefault(),i()}return Yr.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:o,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:o,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=>s(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:o,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:o||!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 sp({children:e,effectiveTheme:r,layoutMode:n,themeMode:a,viewportConstrained:o}){return t.jsx("div",{className:`thread-ui-shell ${r==="dark"?"thread-ui-theme-dark dark":""} ${o?"thread-ui-viewport-constrained":""} ${o?"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 op({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 lp({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 ip({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 dp({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 cp({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 hp({children:e}){return t.jsx("div",{className:"thread-split-region min-h-0 flex-1 overflow-hidden p-0 sm:p-2",children:e})}Lo();Pt();function cs({...e}){return t.jsx(td,{"data-slot":"dialog",...e})}function hs({...e}){return t.jsx(rd,{"data-slot":"dialog-trigger",...e})}function up({...e}){return t.jsx(ld,{"data-slot":"dialog-portal",...e})}function mp({className:e,...r}){return t.jsx(id,{"data-slot":"dialog-overlay",className:at("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 us({children:e,className:r,showCloseButton:n=!0,...a}){return t.jsxs(up,{"data-slot":"dialog-portal",children:[t.jsx(mp,{}),t.jsxs(nd,{"data-slot":"dialog-content",className:at("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(ad,{"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(_.XIcon,{}),t.jsx("span",{className:"sr-only",children:"Close"})]}):null]})]})}function ms({className:e,...r}){return t.jsx("div",{"data-slot":"dialog-header",className:at("flex flex-col gap-2 text-center sm:text-left",e),...r})}function ps({className:e,...r}){return t.jsx(sd,{"data-slot":"dialog-title",className:at("text-lg font-semibold leading-none",e),...r})}function fs({className:e,...r}){return t.jsx(od,{"data-slot":"dialog-description",className:at("text-sm text-muted-foreground",e),...r})}var pp=[{value:"system",label:"Follow system",icon:_.Monitor},{value:"dark",label:"Dark",icon:_.Moon},{value:"light",label:"Light",icon:_.Sun}];function fp({thread:e,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a={},onOpenThread:o,getThreadHref:s,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],w=b&&!n?b:null,x=r===e.id;c.useEffect(()=>()=>{g.current!==null&&window.clearTimeout(g.current)},[]);async function j(){const N=e.providerSessionId;if(N)try{await navigator.clipboard.writeText(N),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 y=()=>o(e.id),v=`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"}`,k=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(_.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:N=>{N.stopPropagation(),N.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(_.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:N=>{N.stopPropagation(),N.preventDefault(),j()},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:f==="copied"?t.jsx(_.Check,{className:"h-3.5 w-3.5"}):t.jsx(_.Copy,{className:"h-3.5 w-3.5"})}):null]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2",children:[w?t.jsx("p",{className:"thread-graph-room-card-meta min-w-0 flex-1 truncate text-[11px] text-[var(--theme-fg-muted)]",title:w,children:w}):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 ${np(e.status)}`,children:rp(e.status)}),t.jsx("time",{className:"shrink-0 text-[11px] text-[var(--theme-fg-muted)]",dateTime:e.lastTurnStartedAt??e.updatedAt,children:vt(e.lastTurnStartedAt??e.updatedAt)})]})]}),h&&d&&!m?t.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),N.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(_.Trash2,{className:"h-3.5 w-3.5"})}):null]}),S=s==null?void 0:s(e.id);return l?t.jsx(t.Fragment,{children:l({thread:e,children:k,className:v,onClick:y})}):S?t.jsx("a",{href:S,onClick:N=>{N.preventDefault(),y()},title:m?e.title:void 0,className:v,children:k}):t.jsx("div",{role:"link",tabIndex:0,onClick:y,onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),y())},title:m?e.title:void 0,className:v,children:k})}function gp({threads:e,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a={},onOpenThread:o,getThreadHref:s,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(fp,{thread:b,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a,onOpenThread:o,showDeleteButton:m,showSessionCopyButton:f,collapsed:p,...s?{getThreadHref:s}:{},...l?{renderThreadLink:l}:{},...i?{onBeginRenameThread:i}:{},...d?{onDeleteThread:d}:{}},b.id))})})}function xp({threads:e,status:r,loading:n=!1,error:a,viewportConstrained:o=!1,layoutMode:s="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:w=null,sessionLabel:x=null,usageLabel:j=null,threadActionsButton:y,topbarActions:v,metaContent:k,settingsContent:S,globalSettingsContent:N,workspaceLabels:L={},workspaceReturnHref:R,onWorkspaceReturn:P,getThreadHref:Q,onOpenThread:D,getNewThreadHref:Z,newThreadHref:J,newThreadLabel:z="New Chat",onNewThread:te,onNewThreadTitle:se,renderNewThreadDialogContent:$,renderThreadLink:le,onCloseAppNavigation:q,onRenameThread:H,onDeleteThread:G,workspaceContent:T,workspaceTitle:F="Workspace",workspaceActions:B,children:E}){const C=ll(),W=typeof window<"u"?window.matchMedia("(max-width: 639px)").matches:s==="mobile",[U,ne]=c.useState(()=>typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)").matches:!1),K=i??(C==null?void 0:C.themeMode)??"system",ie=l??(C==null?void 0:C.effectiveTheme)??(K==="system"?U?"dark":"light":K),[ee,ve]=c.useState(!1),[oe,ye]=c.useState(!1),[Me,de]=c.useState(!W),[Ce,Ee]=c.useState(W),[Y,ue]=c.useState("chat"),[ke,we]=c.useState(null),[De,Fe]=c.useState(""),[Ae,Oe]=c.useState(null),[V,ce]=c.useState(!1),[xe,I]=c.useState(""),[O,ae]=c.useState(!1),[be,je]=c.useState(!1),[Te,fe]=c.useState("session");c.useEffect(()=>{if(typeof window>"u")return;const A=window.matchMedia("(max-width: 639px)"),pe=()=>{Ee(A.matches)};return pe(),A.addEventListener("change",pe),()=>{A.removeEventListener("change",pe)}},[]),c.useEffect(()=>{if(typeof window>"u")return;const A=window.matchMedia("(prefers-color-scheme: dark)"),pe=()=>{ne(A.matches)};return pe(),A.addEventListener("change",pe),()=>{A.removeEventListener("change",pe)}},[]);const Be=c.useMemo(()=>[...b?e.filter(pe=>pe.workspaceId===b):e].sort((pe,ze)=>{if(pe.id===p)return-1;if(ze.id===p)return 1;const Ge=Date.parse(pe.lastTurnStartedAt??pe.updatedAt);return Date.parse(ze.lastTurnStartedAt??ze.updatedAt)-Ge}),[p,b,e]),_e=J??(Z==null?void 0:Z(b)),Qe=w??b??"all",et=x??g??p??"default_session",it=j??(r!=null&&r.state?`runtime ${r.state}`:"waiting for agent usage"),tt=d??(C==null?void 0:C.setThemeMode),Ke=!!tt,dt=()=>{ve(!1),q==null||q()};async function ft(A){if(!H)return;const pe=De.trim();if(pe){Oe(A);try{await H(A,pe),we(null),Fe("")}finally{Oe(null)}}}function Ve(A){we(A.id),Fe(A.title)}function M(){we(null),Fe("")}function X(A){D==null||D(A),dt()}function ge(){ce(!1),I("")}function Ne(A){if(!_e||!A.trim())return _e;try{const pe=new URL(_e,window.location.origin);return pe.searchParams.set("title",A.trim()),`${pe.pathname}${pe.search}${pe.hash}`}catch{const pe=_e.includes("?")?"&":"?";return`${_e}${pe}title=${encodeURIComponent(A.trim())}`}}async function Pe(){const A=xe.trim();ae(!0);try{if(A&&se){await se(A),I(""),ce(!1),dt();return}if(_e){window.location.assign(Ne(A)??_e);return}await(te==null?void 0:te()),I(""),ce(!1),dt()}finally{ae(!1)}}function rt(A,pe=!1){const ze=pe?t.jsxs(t.Fragment,{children:[t.jsx(_.Plus,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:z})]}):t.jsxs(t.Fragment,{children:[t.jsx(_.Plus,{className:"h-4 w-4"}),t.jsx("span",{children:z})]});return t.jsxs(cs,{open:V,onOpenChange:Ge=>{O||ce(Ge)},children:[t.jsx(hs,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":pe?z:void 0,title:z,className:A,children:ze})}),t.jsx(us,{"data-testid":"create-thread-dialog","data-theme-effective":ie,"data-theme-mode":K,className:"thread-graph-create-thread-dialog thread-graph-dialog max-h-[min(86vh,42rem)] overflow-hidden p-4 sm:max-w-[34rem]",children:$?$({close:ge,closeNavigation:dt,currentWorkspaceId:b}):t.jsxs(t.Fragment,{children:[t.jsxs(ms,{children:[t.jsx(ps,{children:"Create New Chat"}),t.jsx(fs,{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:xe,onChange:Ge=>I(Ge.target.value),onKeyDown:Ge=>{Ge.key==="Enter"&&(Ge.preventDefault(),Pe())},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 Pe(),disabled:O,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:O?"Creating...":"Create"})]})]})})]})}function nt(){if(!S&&!k&&!N&&!Ke)return null;const A=!!(S||k),pe=!!N,ze=A&&pe,Ge=Te==="global"&&pe||!A&&pe?"global":"session";return t.jsxs(cs,{...u!==void 0?{open:u}:{},...m?{onOpenChange:m}:{},children:[t.jsx(hs,{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(_.Settings,{className:"h-4 w-4"})})}),t.jsxs(us,{"data-testid":"settings-dialog","data-theme-effective":ie,"data-theme-mode":K,className:"thread-graph-settings-dialog thread-graph-dialog",children:[t.jsxs(ms,{children:[t.jsx(ps,{children:"Settings"}),t.jsx(fs,{children:"Manage this session and host-wide preferences."})]}),Ke?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: ",ie]})]}),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:pp.map(Ue=>{const mt=Ue.icon,yt=K===Ue.value;return t.jsxs("button",{type:"button","data-testid":`theme-mode-${Ue.value}`,"aria-pressed":yt,disabled:!Ke,onClick:()=>tt==null?void 0:tt(Ue.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 ${yt?"is-selected":""}`,children:[t.jsx(mt,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:"truncate",children:Ue.label})]},Ue.value)})})]})}):null,ze?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":Ge==="session",onClick:()=>fe("session"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Ge==="session"?"is-active":""}`,children:"Session"}),t.jsx("button",{type:"button","aria-pressed":Ge==="global",onClick:()=>fe("global"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Ge==="global"?"is-active":""}`,children:"Global"})]}):null,t.jsx("div",{className:"thread-graph-settings-body mt-4 min-h-0 overflow-y-auto pr-1 text-sm",children:Ge==="session"?t.jsxs("div",{className:"grid gap-4",children:[S?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:S}):null,k?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:k}):null,A?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 $e(A=!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)] ${A?"justify-center":""}`,children:[t.jsx(_.Rows3,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:A?"sr-only":"",children:"Rooms"}),!A&&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&&Be.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,Be.length>0?t.jsx(gp,{threads:Be,currentThreadId:p,currentWorkspaceId:b,workspaceLabels:L,onOpenThread:X,collapsed:A,...H?{onBeginRenameThread:Ve}:{},showDeleteButton:!!G,...Q?{getThreadHref:Q}:{},...le?{renderThreadLink:le}:{},...G?{onDeleteThread:G}:{}}):null]})]})})}function We(){return T?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:()=>de(!0),className:"thread-workspace-collapse-tab thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(_.ChevronsRight,{className:"h-4 w-4"})}),B?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:B})}):null,t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:T})]}):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:F}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:w??b??"Current context"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[B,t.jsx("button",{type:"button",onClick:()=>de(!0),className:"thread-workspace-small-toggle thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(_.ChevronsRight,{className:"h-4 w-4"})})]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:T??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:w??b??"All threads"})]})]})})]})}const ut=!!T,st=s==="mobile"||s==="responsive"&&Ce,ct=st,gt=ct&&!ee,wt=!!(R||P)?t.jsx("a",{href:R??"#",onClick:A=>{P&&(A.preventDefault(),P())},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(_.ArrowLeft,{className:"h-4 w-4"})}):null;return t.jsxs(t.Fragment,{children:[t.jsx(sp,{effectiveTheme:ie,layoutMode:s,themeMode:K,viewportConstrained:o,children:t.jsxs(op,{roomsRailCollapsed:oe,children:[t.jsx(lp,{open:ee,onClose:()=>ve(!1)}),t.jsxs(ip,{collapsed:oe,mobileOpen:ee,children:[t.jsx("div",{className:`thread-rooms-rail-header flex h-[calc(3rem+env(safe-area-inset-top))] shrink-0 items-end border-b border-[var(--theme-border)] px-4 pb-2 sm:h-16 sm:items-center sm:pb-0 ${oe?"sm:w-full sm:justify-center sm:px-2":""}`,children:t.jsxs("div",{className:`flex w-full items-center gap-3 ${oe?"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:()=>ye(A=>!A),className:"thread-icon-button thread-desktop-only-flex h-9 w-9 shrink-0 items-center justify-center rounded-full",title:oe?"Expand rooms":"Collapse rooms","aria-label":oe?"Expand rooms":"Collapse rooms",children:oe?t.jsx(_.PanelLeftOpen,{className:"h-4 w-4"}):t.jsx(_.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)] ${oe?"thread-desktop-collapsed-hidden":""}`,children:(w??"R").charAt(0).toUpperCase()}),t.jsxs("div",{className:`min-w-0 ${oe?"thread-desktop-collapsed-hidden":""}`,children:[t.jsx("p",{className:"truncate text-sm font-semibold text-[var(--theme-fg)]",children:w??"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 ${oe?"thread-desktop-collapsed-hidden":""}`,children:[nt(),wt,t.jsx("button",{type:"button",onClick:()=>ve(!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(_.X,{className:"h-4 w-4"})})]})]})}),t.jsx("div",{className:`thread-graph-new-room-strip flex shrink-0 items-center border-b ${oe?"h-12 w-full justify-center px-2 sm:h-12":"h-[68px] px-4"}`,children:rt(`thread-graph-new-room-button inline-flex items-center justify-center rounded-xl font-medium transition ${oe?"h-9 w-9 p-0":"h-11 w-full gap-2 px-3 text-sm sm:h-9"}`,oe)}),t.jsx("div",{className:`flex min-h-0 flex-1 flex-col ${oe?"w-full px-2 py-2":"px-3 py-3"}`,children:$e(oe)})]}),t.jsxs(dp,{children:[t.jsx(cp,{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 flex-1 items-center gap-2 sm:gap-3",children:[gt?t.jsx("button",{type:"button",onClick:()=>ve(!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(_.Menu,{className:"h-4 w-4"})}):null,t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"min-w-0 truncate text-sm font-semibold leading-tight text-[var(--theme-fg)] sm:text-base",title:g??"Shared Workspace",children:g??"Shared Workspace"}),t.jsxs("div",{className:"relative mt-0.5 flex min-w-0 items-center gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{je(A=>!A)},"aria-expanded":be,"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:Qe})]}),be?t.jsxs("div",{className:"thread-topbar-details-popover absolute left-0 top-[calc(100%+0.5rem)] z-50 w-[min(28rem,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 A;et&&((A=navigator.clipboard)==null||A.writeText(et))},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-14 shrink-0",children:"Session"}),t.jsx("span",{className:"truncate font-mono",children:et})]}),t.jsxs("div",{className:"thread-topbar-meta-row mt-1 flex min-w-0 max-w-full items-start gap-2 text-xs leading-5",title:"Session token usage and estimated cost",children:[t.jsx("span",{className:"w-14 shrink-0",children:"Usage"}),t.jsx("span",{className:"min-w-0 whitespace-normal break-words font-mono",children:it})]})]}):null]})]})]}),t.jsxs("div",{className:"relative z-[1] inline-flex shrink-0 items-center gap-2",children:[y||v?t.jsxs("div",{className:"thread-graph-topbar-actions thread-desktop-only-inline-flex items-center rounded-lg border p-0.5 shadow-none",children:[y,v]}):null,ct&&y?t.jsx("div",{className:"thread-mobile-only-inline-flex",children:y}):null,ct&&ut?t.jsx("button",{type:"button",onClick:()=>ue(A=>A==="workspace"?"chat":"workspace"),"aria-label":Y==="workspace"?"Show chat":"Show workspace",title:Y==="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:Y==="workspace"?t.jsx(_.MessageSquare,{className:"h-4 w-4"}):t.jsx(_.Folder,{className:"h-4 w-4"})}):null,ct?f:null,ct&&h?rt("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(hp,{children:ut&&!Me?st?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 ${Y==="chat"?"block":"thread-mobile-chat-hidden"}`,children:E}),t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${Y==="workspace"?"block":"thread-mobile-workspace-hidden"}`,children:We()})]}):t.jsxs(Mn,{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(sr,{defaultSize:47,minSize:30,maxSize:75,className:"thread-split-chat-pane min-w-0 overflow-hidden",children:E}),t.jsx(An,{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(sr,{defaultSize:53,minSize:30,maxSize:70,className:"thread-split-workspace-pane min-w-0 overflow-hidden",children:We()})]}):t.jsxs("div",{className:"thread-split-container relative h-full min-h-0 overflow-hidden",children:[ut&&Me?t.jsx("button",{type:"button",onClick:()=>de(!1),className:"thread-workspace-expand-fab thread-desktop-only-inline-flex",title:"Expand workspace","aria-label":"Expand workspace",children:t.jsx(_.ChevronsLeft,{className:"h-4 w-4"})}):null,E]})})]})]})}),t.jsx(ap,{open:ke!==null,title:"Rename Thread",label:"Thread Title",value:De,busy:Ae!==null,onChange:Fe,onCancel:M,onSubmit:()=>ke?ft(ke):void 0})]})}function bp({open:e,title:r,text:n,onClose:a}){return c.useEffect(()=>{if(!e)return;function o(s){s.key==="Escape"&&a()}return window.addEventListener("keydown",o),()=>{window.removeEventListener("keydown",o)}},[a,e]),e?Yr.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 vp=[/^(?: {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],kp=/^(?:\|?[^|\n]+\|[^|\n]+(?:\|[^|\n]+)*\|?\s*\n\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$)/m,wp=/!?\[[^\]\n]+\]\([^)]+\)/,yp=/`[^`\n]+`/,jp=/(?:\*\*[^*\n]+\*\*|__[^_\n]+__)/,Np=/(^|[^\w])(?:\*[^*\n]+\*|_[^_\n]+_)(?=[^\w]|$)/,Cp=/~~[^~\n]+~~/;function Sp(e){const r=e.trim();return r?vp.some(n=>n.test(r))||kp.test(r)?!0:/[`[\]*_~!]/.test(r)?wp.test(r)||yp.test(r)||jp.test(r)||Np.test(r)||Cp.test(r):!1:!1}rn();function Vn(e,r){const n=new Map(r.map(s=>[s.id,s])),a=e.map(s=>{var l,i;return{...s.manifest,enabled:((l=n.get(s.manifest.id))==null?void 0:l.enabled)??!0,source:((i=n.get(s.manifest.id))==null?void 0:i.source)??"builtin"}}),o=new Set(e.map(s=>s.manifest.id));for(const s of r)o.has(s.id)||a.push(s);return a}function ia(e=[]){const r=Vn(e,[]),n=e;return{plugins:r,loading:!1,error:null,async refresh(){},async importPluginManifest(){},async setPluginEnabled(){},async uninstallPlugin(){},renderArtifact:s=>{var i;const l=n.find(d=>d.renderArtifact&&d.manifest.capabilities.artifactTypes.some(h=>h.type===s.artifact.type));return((i=l==null?void 0:l.renderArtifact)==null?void 0:i.call(l,s))??null},renderInlineCode:s=>{for(const l of n)for(const i of l.inlineCodeRenderers??[]){if(!i.languages.includes(s.language.trim().toLowerCase()))continue;const d=i.render(s);if(d)return d}return null},hasRendererForArtifact:s=>n.some(l=>!!l.renderArtifact&&l.manifest.capabilities.artifactTypes.some(i=>i.type===s.type)),getThreadPanels:()=>n.flatMap(s=>s.threadPanels??[])}}var da=c.createContext(ia());function ca(){return c.useContext(da)??ia()}Lr();function dl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function gs(e){return dl(e)?Object.entries(e):e==null||e===""?[]:[["value",e]]}function cl(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 Tp(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)}):cl(r)}function xs({callId:e,toolName:r,status:n,parameters:a,result:o}){const s=c.useMemo(()=>{switch(n){case"completed":return{className:"is-completed",icon:t.jsx(_.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"};case"failed":return{className:"is-failed",icon:t.jsx(_.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"};default:return{className:"is-pending",icon:t.jsx(_.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),label:"Running"}}},[n]),l=c.useMemo(()=>gs(o),[o]),i=c.useMemo(()=>gs(a),[a]),d=c.useMemo(()=>typeof o=="string"?o.length>0:dl(o)?["stdout","stderr","result"].some(f=>{const p=o[f];return typeof p=="string"&&p.length>0}):!1,[o]),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(Sr,{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(Tr,{value:"item-1",className:"border-0",children:[t.jsx(nn,{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(_.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 ${s.className}`,title:s.label,"aria-label":`Status: ${s.label}`,children:[s.icon,t.jsx("span",{className:"thread-graph-status-label",children:s.label})]})]})}),t.jsxs(Er,{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:": "}),cl(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:": "}),Tp(f,p),g<l.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},f)),"}"]})]}):null]})]})})})}var bs=null;function Ep(){return bs??(bs=Promise.all([Xe(()=>import("./core-DODVy7wn.js"),__vite__mapDeps([0,1,2])),Xe(()=>import("./engine-javascript-DBd1bXLz.js"),[]),Xe(()=>import("./ayu-light-BA47KaF1.js"),[]),Xe(()=>import("./ayu-dark-DYE7WIF3.js"),[]),Xe(()=>import("./javascript-wDzz0qaB.js"),[]),Xe(()=>import("./typescript-BPQ3VLAy.js"),[]),Xe(()=>import("./tsx-COt5Ahok.js"),[]),Xe(()=>import("./jsx-g9-lgVsj.js"),[]),Xe(()=>import("./python-B6aJPvgy.js"),[]),Xe(()=>import("./json-Cp-IABpG.js"),[]),Xe(()=>import("./shellscript-CEILq0vU.js").then(e=>e.b),[]),Xe(()=>import("./shellscript-CEILq0vU.js").then(e=>e.s),[]),Xe(()=>import("./yaml-Buea-lGh.js"),[]),Xe(()=>import("./toml-vGWfd6FD.js"),[]),Xe(()=>import("./markdown-Cvjx9yec.js"),[]),Xe(()=>import("./html-pp8916En.js"),__vite__mapDeps([3,4,5])),Xe(()=>import("./css-CLj8gQPS.js"),[]),Xe(()=>import("./sql-CRqJ_cUM.js"),[]),Xe(()=>import("./csv-fuZLfV_i.js"),[])]).then(([{createHighlighterCore:e},{createJavaScriptRegexEngine:r},n,a,o,s,l,i,d,h,u,m,f,p,g,b,w,x,j])=>e({engine:r(),themes:[n.default,a.default],langs:[o.default,s.default,l.default,i.default,d.default,h.default,u.default,m.default,f.default,p.default,g.default,b.default,w.default,x.default,j.default]}))),bs}function an(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function qn(e){if(!e)return{};if(an(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 Kn(){return{finalResult:null,stdout:"",stderr:""}}function Lp(e){return typeof e=="string"?{result:e}:e}function hl(e){const r=an(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 vs(e){if(!e)return"pending";if(!an(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)??Kn();return an(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}}),o=/```tool-call\s*([\s\S]*?)\s*```/g;return{processedContent:a.replace(o,(l,i)=>{try{const d=JSON.parse(i),h=d.call_id,u=d.tool;if(typeof u!="string")return l;const m=qn(d.args);if(typeof h=="string"&&r.has(h)){const f=hl(r.get(h)??Kn());return`\`\`\`tool-merged
3691
+ `,hs="MCP entry written to provider config. Restart the backend if it does not appear immediately.";function qm({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),[k,w]=c.useState(null),[x,j]=c.useState(null),y=c.useCallback(()=>{w(null),j(null)},[]),b=c.useCallback(async()=>{if(!e||!r)throw new Error("Provider config editing is unavailable for this thread.");const R=await r();return f(R.path),R},[e,r]),v=c.useCallback(async R=>{if(!e||!n)throw new Error("Provider config editing is unavailable for this thread.");const P=await n(R);return f(P.path),P},[e,n]),S=c.useCallback(async()=>{const R=Pu(o),P=i.trim();if(!R){w("MCP name must use only letters, numbers, underscore, or hyphen.");return}if(!/^https?:\/\//i.test(P)){w("HTTP MCP URL must start with http:// or https://");return}g(!0),w(null),j(null);try{const Q=await b(),D=as(Q.content,R,Au(R,P));await v(D),j(hs),a("list"),l(""),d(""),s==null||s()}catch(Q){w(Q instanceof Error?Q.message:"Unable to update provider config.")}finally{g(!1)}},[b,o,i,s,a,v]),N=c.useCallback(async()=>{g(!0),w(null),j(null);try{await b(),u(R=>R||Vm),a("stdio")}catch(R){w(R instanceof Error?R.message:"Unable to load provider config.")}finally{g(!1)}},[b,a]),L=c.useCallback(async()=>{const R=Ru(h);if(!R){w("The raw MCP block must start with a header like [mcp_servers.name].");return}g(!0),w(null),j(null);try{const P=await b(),Q=as(P.content,R,h);await v(Q),j(hs),a("list"),s==null||s()}catch(P){w(P instanceof Error?P.message:"Unable to update provider config.")}finally{g(!1)}},[b,h,s,a,v]);return{mcpHttpName:o,mcpHttpUrl:i,mcpRawBlock:h,mcpConfigPath:m,mcpConfigBusy:p,mcpConfigError:k,mcpConfigSuccess:x,setMcpHttpName:l,setMcpHttpUrl:d,setMcpRawBlock:u,clearMcpConfigStatus:y,prepareRawMcpBlock:N,saveHttpMcp:S,saveRawMcpBlock:L}}function Km({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 Xm(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=os(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=os(n),a.append(s,o),a}function Ym(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(Xm(a,r))}return n}function Zm({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 k=i.current,w=f()!==n||u.current!==o||m.current!==l;w&&(g.replaceChildren(Ym(a,s)),u.current=o,m.current=l),k!==null?(g.focus(),cm(g,d.current)||p(k),h.current=k):document.activeElement===g&&w&&p(h.current),i.current=null,d.current=[]},[s,l,r,o,n,e,a,d,i,u,m,p,h,f])}function Jm({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 Qm({promptRef:e,prompt:r,disabled:n,promptPlaceholder:a,canInterrupt:s,interruptLabel:o,composerPromptRegionClassName:l,graphChatInputClassName:i,onInterrupt:d,onInput:h,onPointerDown:u,onPaste:m,onKeyDown:f,onKeyUp:p,onMouseUp:g,onBlur:k,onDragEnter:w,onDragOver:x,onDragLeave:j,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,inputMode:"text",suppressContentEditableWarning:!0,onPointerDown:b=>{!n&&document.activeElement!==b.currentTarget&&b.currentTarget.focus({preventScroll:!0}),u==null||u(b)},onInput:h,onPaste:m,onKeyDown:f,onKeyUp:p,onMouseUp:g,onBlur:k,onDragEnter:w,onDragOver:x,onDragLeave:j,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(Ct,{type:"button",variant:"ghost",size:"icon-xs","aria-label":o,title:o,onClick:b=>{b.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 ep({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 tp({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:k,sendButtonClassName:w,onInterrupt:x,onPromptInput:j,onPromptPaste:y,onPromptKeyDown:b,onPromptKeyUp:v,onPromptMouseUp:S,onPromptBlur:N,onPromptDragEnter:L,onPromptDragOver:R,onPromptDragLeave:P,onPromptDrop:Q,onGoalTokenBudgetChange:D,onCancelGoal:Z,onShellPromptChange:J}){return{promptSlot:e?null:t.jsx(Qm,{promptRef:r,prompt:n,disabled:a,promptPlaceholder:s,canInterrupt:o,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,onInterrupt:x,onInput:j,onPaste:y,onKeyDown:b,onKeyUp:v,onMouseUp:S,onBlur:N,onDragEnter:L,onDragOver:R,onDragLeave:P,onDrop:Q}),goalSlot:u&&!e?t.jsx(Jm,{tokenBudget:m,error:f,onTokenBudgetChange:D,onCancel:Z}):null,shellPromptSlot:e?t.jsx(ep,{prompt:n,promptPlaceholder:s,promptRegionClassName:i,promptInputClassName:h,interruptLabel:l,canInterrupt:o,sendButtonLabel:k,sendButtonClassName:w,sendDisabled:p||g,onPromptChange:J,onPromptKeyDown:b,onInterrupt:x}):null}}function rp({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=Lu({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 np({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:k,busy:w,settingsBusy:x,compactBusy:j,forkBusy:y,fastMode:b,goalComposeMode:v,goalBusy:S,goalStatus:N,activeView:L,disabled:R,model:P,modelOptions:Q,modelContextTitle:D,contextUsage:Z,reasoningEffort:J,supportedEfforts:z,displayedCollaborationMode:te,sandboxMode:se,sendButtonLabel:_,sendButtonClassName:ie,modelControlsDisabled:q,effortControlsDisabled:H,effortControlTitle:G,forkTurnOptionsState:T,skillsState:F,goalState:B,goalHistory:E,copiedSkillName:C,hooksPanelMode:W,hooksState:U,hookConfigBusy:ae,hookConfigError:K,hookConfigSuccess:de,editingHookTarget:ee,hookScope:ke,hookEventName:le,hookMatcher:je,hookCommand:Ae,hookTimeoutSec:ce,hookStatusMessage:ne,mcpPanelMode:Le,mcpState:Y,mcpConfigPath:me,mcpConfigError:we,mcpConfigSuccess:ye,mcpConfigBusy:De,mcpHttpName:Be,mcpHttpUrl:_e,mcpRawBlock:Oe,capabilities:V,shellControlState:he,onToggleView:ve,onDismissPromptFocus:I,onSetOpenMenu:O,onToolboxItemClick:oe,onSetSlashPanelView:ge,onViewGoals:Ne,onUpdateGoal:Ce,onOpenForkTurns:xe,onForkLatest:Ge,onForkTurn:Me,onCopySkillInvokeName:Qe,onResetHookForm:et,onSetHooksPanelMode:it,onClearHookConfigStatus:tt,onSetEditingHookTarget:Ke,onSetHookScope:dt,onSetHookEventName:gt,onSetHookMatcher:Ve,onSetHookCommand:A,onSetHookTimeoutSec:X,onSetHookStatusMessage:be,onSaveHook:Se,onStartEditingHook:Pe,onTrustHook:rt,onUntrustHook:nt,onSetMcpPanelMode:$e,onClearMcpConfigStatus:We,onSetMcpHttpName:ut,onSetMcpHttpUrl:st,onSetMcpRawBlock:ct,onPrepareRawMcpBlock:xt,onSaveHttpMcp:Rt,onSaveRawMcpBlock:wt,onPickPhoto:M,onPickFile:fe,onUpdateSettings:ze,onPasteShell:Fe,onCopyShell:Ue,onClearShell:mt,onShellControl:yt}){const Xt=e?null:{open:s==="slash",slashPanelView:g,availableToolboxItems:k,busy:w,forkBusy:y,forkTurnOptionsState:T,skillsState:F,goalState:B,goalHistory:E,goalBusy:S,copiedSkillName:C,hooksPanelMode:W,hooksState:U,hostConfigFilesAvailable:V.hostConfigFiles,hookTrustAvailable:V.hookTrust,hookConfigBusy:ae,hookConfigError:K,hookConfigSuccess:de,editingHookTarget:ee,hookScope:ke,hookEventName:le,hookMatcher:je,hookCommand:Ae,hookTimeoutSec:ce,hookStatusMessage:ne,mcpPanelMode:Le,mcpState:Y,mcpConfigEditing:V.mcpConfigEditing,mcpConfigPath:me,mcpConfigError:we,mcpConfigSuccess:ye,mcpConfigBusy:De,mcpHttpName:Be,mcpHttpUrl:_e,mcpRawBlock:Oe,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,onToggle:()=>O(ot=>ot==="slash"?null:"slash"),onToolboxItemClick:oe,toolboxItemDisabled:ot=>am(ot,{settingsBusy:x,compactBusy:j,busy:w,forkBusy:y}),toolboxItemClassName:ot=>sm(ot,{fastMode:b,goalComposeMode:v,goalStatus:N,menuItemClassName:d}),toolboxItemStatus:ot=>nm(ot,{fastMode:b,compactBusy:j,goalComposeMode:v,goalStatus:N,busy:w}),onSetSlashPanelView:ge,onViewGoals:Ne,onUpdateGoal:Ce,onOpenForkTurns:xe,onForkLatest:Ge,onForkTurn:Me,onCopySkillInvokeName:Qe,onResetHookForm:et,onSetHooksPanelMode:it,onClearHookConfigStatus:tt,onSetEditingHookTarget:Ke,onSetHookScope:dt,onSetHookEventName:gt,onSetHookMatcher:Ve,onSetHookCommand:A,onSetHookTimeoutSec:X,onSetHookStatusMessage:be,onSaveHook:Se,onStartEditingHook:Pe,onTrustHook:rt,onUntrustHook:nt,onSetMcpPanelMode:$e,onClearMcpConfigStatus:We,onSetMcpHttpName:ut,onSetMcpHttpUrl:st,onSetMcpRawBlock:ct,onPrepareRawMcpBlock:xt,onSaveHttpMcp:Rt,onSaveRawMcpBlock:wt},Yt=e?null:{open:s==="attachments",iconButtonClassName:l,menuClassName:i,menuItemClassName:d,onToggle:()=>O(ot=>ot==="attachments"?null:"attachments"),onPickPhoto:M,onPickFile:fe},At=e?null:{openMenu:s,model:P,modelOptions:Q,modelContextTitle:D,contextUsage:Z,reasoningEffort:J,supportedEfforts:z,displayedCollaborationMode:te,sandboxMode:se,planModeAvailable:V.planMode,sandboxModeAvailable:V.sandboxMode,settingsBusy:x,goalComposeMode:v,goalBusy:S,activeView:L,disabled:R,fastMode:b,sendButtonLabel:_,sendButtonClassName:ie,modelControlsDisabled:q,effortControlsDisabled:H,effortControlTitle:G,inlineToggleClassName:m,menuItemClassName:d,planToggleActiveClassName:f,sendButtonBaseClassName:p,onSetOpenMenu:O,onUpdateSettings:ze};return{isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:s,toolbarClassName:o,iconButtonClassName:l,slashToolboxProps:Xt,attachmentMenuProps:Yt,settingsToolbarProps:At,shellToolsPanelProps:s==="shellTools"?{busy:w,shellControlState:he,onPaste:Fe,onCopy:Ue,onClear:mt,onShellControl:yt}:null,shellControlState:he,onToggleView:ve,onDismissPromptFocus:I,onSetOpenMenu:O}}function Kn({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:k=null,hookCommandTemplates:w=null,mcpConfigFormat:x="none",followTail:j=!1,threadConnected:y=!0,shellAvailable:b=!0,disabled:v=!1,disabledPlaceholder:S,shellControlState:N=null,draftPrompt:L,draftAttachments:R,onPickAttachment:P,skillsState:Q={status:"idle",data:null,error:null},mcpState:D={status:"idle",data:null,error:null},hooksState:Z={status:"idle",data:null,error:null},goalState:J={status:"idle",data:null,error:null},goalHistory:z=[],forkTurnOptionsState:te={status:"idle",data:null,error:null},onDraftChange:se,onSubmit:_,onInterrupt:ie,onCompact:q,onOpenSkills:H,onOpenMcp:G,onOpenHooks:T,onCreateHook:F,onUpdateHook:B,onTrustHook:E,onUntrustHook:C,onOpenGoal:W,onPrepareGoalSubmit:U,onUpdateGoal:ae,onOpenForkTurns:K,onForkLatest:de,onForkTurn:ee,onReadProviderConfig:ke,onWriteProviderConfig:le,onToggleFollow:je,canJumpToPreviousTurn:Ae,onJumpToPreviousTurn:ce,canJumpToNextTurn:ne,onJumpToNextTurn:Le,subscriptionUsage:Y,onUpdateSettings:me,onToggleView:we,onShellCopy:ye,onShellControl:De,canInterrupt:Be=!1,pendingPrompts:_e=[],onSteerPendingPrompt:Oe,onCancelPendingPrompt:V}){var Ca;const[he,ve]=c.useState(null),[I,O]=c.useState("root"),oe=c.useRef(!1),[ge,Ne]=c.useState("list"),Ce=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)&&!!ke&&!!le,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,ke,le]),xe=c.useMemo(()=>tm(k,Ce),[Ce,k]),Ge=c.useRef(null),Me=c.useRef(null),Qe=c.useRef(null),et=c.useRef(null),it=c.useRef(null),tt=c.useRef([]),Ke=c.useRef(null),dt=c.useRef(""),gt=c.useRef(0),Ve=e==="shell",A=b||Ve,X=!!(Ve&&(N!=null&&N.isMobileShell)),be=(N==null?void 0:N.promptLabel)??null,[Se,Pe]=c.useState(!1),[rt,nt]=c.useState(0),{prompt:$e,attachments:We,isDraftControlled:ut,updateDraft:st,flushControlledDraftToHost:ct}=Fm({isShellView:Ve,draftPrompt:L,draftAttachments:R,onDraftChange:se}),xt=Bm({attachments:We,isShellView:Ve}),{displayedCollaborationMode:Rt,updateSettings:wt}=rp({collaborationMode:h,onUpdateSettings:me,closeMenu:()=>ve(null)}),{forkBusy:M,forkLatest:fe,forkTurn:ze}=Hm({slashPanelView:I,onForkLatest:de,onForkTurn:ee,closeMenu:()=>ve(null)}),{hooksPanelMode:Fe,hookScope:Ue,hookEventName:mt,hookMatcher:yt,hookCommand:Xt,hookTimeoutSec:Yt,hookStatusMessage:At,editingHookTarget:mr,hookConfigBusy:ot,hookConfigError:un,hookConfigSuccess:mn,setHooksPanelMode:Rl,setEditingHookTarget:Al,setHookScope:Ml,setHookEventName:$l,setHookMatcher:_l,setHookCommand:Dl,setHookTimeoutSec:Bl,setHookStatusMessage:Gl,clearHookConfigStatus:ga,resetHookForm:Fl,startEditingHook:Hl,saveHook:Ol,trustHook:Wl,untrustHook:Ul}=Um({slashPanelView:I,hookCommandTemplates:w,onCreateHook:F,onUpdateHook:B,onTrustHook:E,onUntrustHook:C}),{goalComposeMode:pr,goalTokenBudget:Vl,goalBusy:pn,goalLocalError:ql,setGoalTokenBudget:Kl,submitGoal:Xl,enterGoalComposeMode:Yl,exitGoalComposeMode:xa}=Om({prompt:$e,goalTokenBudgetSource:J.data,promptRef:Me,onOpenGoal:W,onPrepareGoalSubmit:U,onUpdateGoal:ae,updateDraft:st,closeMenu:()=>ve(null),resetSlashPanel:()=>O("root")}),{mcpHttpName:Zl,mcpHttpUrl:Jl,mcpRawBlock:Ql,mcpConfigPath:ei,mcpConfigBusy:ti,mcpConfigError:ri,mcpConfigSuccess:ni,setMcpHttpName:ai,setMcpHttpUrl:si,setMcpRawBlock:oi,clearMcpConfigStatus:ba,prepareRawMcpBlock:li,saveHttpMcp:ii,saveRawMcpBlock:di}=qm({hostConfigFilesAvailable:Ce.hostConfigFiles,onReadProviderConfig:ke,onWriteProviderConfig:le,setMcpPanelMode:Ne,onOpenMcp:G}),{copiedSkillName:ci,copySkillInvokeName:hi}=Km({openMenu:he,setOpenMenu:ve,slashPanelView:I,setSlashPanelView:O,setMcpPanelMode:Ne,clearMcpConfigStatus:ba,clearHookConfigStatus:ga}),ui=c.useCallback(re=>{st(Te=>{if(typeof re=="function"){const Re=re(Te.prompt,Te.attachments);return{prompt:Re.prompt,attachments:Re.attachments??Te.attachments}}return{prompt:re,attachments:Te.attachments}})},[st]),fn=c.useMemo(()=>f.find(re=>re.model===l)??null,[l,f]),mi=Mu(l,p),va=(fn==null?void 0:fn.supportedReasoningEfforts)??[],pi=c.useMemo(()=>ku($e,We),[We,$e]),fi=c.useMemo(()=>Object.entries(xt).sort(([re],[Te])=>re.localeCompare(Te)).map(([re,Te])=>`${re}:${Te}`).join("|"),[xt]);function gi(re,Te){Te.stopPropagation();const Re=rm(re,{fastMode:d,goalComposeMode:pr});switch(Re.type){case"toggleFast":wt({fastMode:Re.fastMode});break;case"runCompact":ve(null),q==null||q();break;case"enterGoalCompose":Yl();break;case"exitGoalCompose":xa(),ve(null);break;case"openPanel":O(Re.panel),Re.panel==="skills"?H==null||H():Re.panel==="mcp"?G==null||G():Re.panel==="hooks"&&(T==null||T());break;case"insertPrompt":bn(Re.text),O("root"),ve(null);break}}function Zt(){const re=Me.current;return re?im(re):null}const xi=c.useCallback(re=>{const Te=Me.current;!Te||!re||dm(Te,re)},[]),gn=c.useCallback(()=>{const re=Me.current;return re?il(re):$e},[$e]),{appendAttachments:xn,appendDroppedAttachments:ka}=Dm({prompt:$e,attachments:We,updateDraft:st,getSelection:Zt,selectionSnapshotRef:Ke,pendingSelectionRef:it,pendingInsertedAttachmentIdsRef:tt,onInserted:()=>ve(null)}),wa=c.useCallback((re,Te)=>{var Re;if(Mt(),P){P({kind:re,appendAttachments:(Ze,lt=re)=>xn(Ze,lt),defaultPick:()=>{var Ze;return(Ze=Te.current)==null?void 0:Ze.click()}});return}(Re=Te.current)==null||Re.click()},[xn,Mt,P]);function bn(re){if(!re)return;const Te=Zt()??Ke.current,Re=(Te==null?void 0:Te.start)??$e.length,Ze=(Te==null?void 0:Te.end)??Re,lt=vu(re),Jt=`${$e.slice(0,Re)}${lt}${$e.slice(Ze)}`;st(Ji=>({prompt:Jt,attachments:Ji.attachments}));const $t=Re+lt.length;it.current={start:$t,end:$t},Ke.current={start:$t,end:$t}}Zm({promptRef:Me,isShellView:Ve,prompt:$e,promptSegments:pi,attachmentPreviewUrls:xt,previewSignature:fi,editorSanitizeNonce:rt,pendingSelectionRef:it,pendingInsertedAttachmentIdsRef:tt,selectionSnapshotRef:Ke,renderedPreviewSignatureRef:dt,renderedSanitizeNonceRef:gt,serializeEditorPrompt:gn,restoreSelection:xi});function Mt(){var re;(re=Me.current)==null||re.blur(),document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.blur()}async function bi(){var re;if(Mt(),ve(null),!!((re=navigator.clipboard)!=null&&re.readText))try{const Te=await navigator.clipboard.readText();bn(Te)}catch{return}}async function ya(){if(!oe.current){oe.current=!0;try{if(ut&&ct(),pr&&!Ve){await Xl();return}const re=Cu({prompt:$e,attachments:We,isShellView:Ve});if(!re||await _(re)===!1)return;st(()=>({prompt:"",attachments:[]}))}finally{oe.current=!1}}}async function vi(re){re.preventDefault(),await ya()}function ki(){const re=gn(),Te=Zt();Ke.current=Te;const Re=Me.current;(Re?lm(Re):!1)&&(it.current=Te,nt(lt=>lt+1)),st(lt=>({prompt:re,attachments:lt.attachments.filter(Jt=>re.includes(Jt.placeholder))}),"deferred")}function wi(re){var Ze,lt,Jt,$t;const Te=Vn((Ze=re.clipboardData)==null?void 0:Ze.items,(lt=re.clipboardData)==null?void 0:lt.files),Re=Su({files:Te,plainText:((Jt=re.clipboardData)==null?void 0:Jt.getData("text/plain"))??"",htmlText:(($t=re.clipboardData)==null?void 0:$t.getData("text/html"))??"",htmlToText:om});Re.preventDefault&&re.preventDefault(),Re.type==="insert-text"?bn(Re.text):Re.type==="append-files"&&ka(Re.files)}function yi(re){var Re,Ze;const Te=rs(ss((Re=re.dataTransfer)==null?void 0:Re.items,(Ze=re.dataTransfer)==null?void 0:Ze.files));Te.preventDefault&&re.preventDefault(),Te.activateDragTarget&&Pe(!0)}function ji(re){var Re,Ze;const Te=rs(ss((Re=re.dataTransfer)==null?void 0:Re.items,(Ze=re.dataTransfer)==null?void 0:Ze.files));Te.preventDefault&&re.preventDefault(),Te.activateDragTarget&&re.dataTransfer&&(re.dataTransfer.dropEffect="copy"),Te.activateDragTarget&&Pe(!0)}function Ni(re){re.currentTarget.contains(re.relatedTarget)||Pe(!1)}function Ci(re){var Ze,lt;const Te=Vn((Ze=re.dataTransfer)==null?void 0:Ze.items,(lt=re.dataTransfer)==null?void 0:lt.files),Re=Tu(Te);Re.preventDefault&&re.preventDefault(),Re.type==="accept-files"&&(Pe(!1),ka(Re.files??[]))}function Si(re){if(re.key==="Enter"&&re.repeat){re.preventDefault();return}if(e==="chat"&&re.key==="/"&&!re.metaKey&&!re.ctrlKey&&!re.altKey&&!n&&!v&&xe.length>0&&gn().trim().length===0){re.preventDefault(),O("root"),ve("slash");return}const Te=Eu({key:re.key,metaKey:re.metaKey,ctrlKey:re.ctrlKey,busy:n,disabled:v});Te.preventDefault&&re.preventDefault(),Te.submit&&ya()}const{promptPlaceholder:Ti,interruptLabel:Ei,sendButtonLabel:ja,sendButtonClassName:Na,modelControlsDisabled:Li,effortControlsDisabled:Ii,effortControlTitle:zi}=Bu({goalComposeMode:pr,goalBusy:pn,threadConnected:y,busy:n,isShellView:Ve,disabledPlaceholder:S,settingsBusy:a,supportedEffortCount:va.length,fastMode:d}),{composerLayerClassName:Pi,formClassName:Ri,composerShellClassName:Ai,composerToolbarClassName:Mi,composerIconButtonClassName:$i,composerMenuClassName:_i,composerMenuItemClassName:Di,composerInlineToggleClassName:Bi,composerPanelButtonClassName:Gi,composerChipButtonClassName:Fi,composerPlanToggleActiveClassName:Hi,composerSendButtonClassName:Oi,composerPromptRegionClassName:Wi,promptInputClassName:Ui,graphChatInputGroupClassName:Vi,graphChatInputClassName:qi}=Gu({isShellView:Ve,edgeToEdgeMobile:r,isMobileShell:X,openMenu:he!==null,isDragTargetActive:Se,busy:n}),Ki=np({isShellView:Ve,canToggleShellView:A,isMobileShell:X,shellPromptLabel:be,openMenu:he,toolbarClassName:Mi,iconButtonClassName:$i,menuClassName:_i,menuItemClassName:Di,panelButtonClassName:Gi,chipButtonClassName:Fi,inlineToggleClassName:Bi,planToggleActiveClassName:Hi,sendButtonBaseClassName:Oi,slashPanelView:I,availableToolboxItems:xe,busy:n,settingsBusy:a,compactBusy:s,forkBusy:M,fastMode:d,goalComposeMode:pr,goalBusy:pn,goalStatus:(Ca=J.data)==null?void 0:Ca.status,activeView:e,disabled:v,model:l,modelOptions:f,modelContextTitle:mi,contextUsage:p,reasoningEffort:i,supportedEfforts:va,displayedCollaborationMode:Rt,sandboxMode:u,sendButtonLabel:ja,sendButtonClassName:Na,modelControlsDisabled:Li,effortControlsDisabled:Ii,effortControlTitle:zi,forkTurnOptionsState:te,skillsState:Q,goalState:J,goalHistory:z,copiedSkillName:ci,hooksPanelMode:Fe,hooksState:Z,hookConfigBusy:ot,hookConfigError:un,hookConfigSuccess:mn,editingHookTarget:mr,hookScope:Ue,hookEventName:mt,hookMatcher:yt,hookCommand:Xt,hookTimeoutSec:Yt,hookStatusMessage:At,mcpPanelMode:ge,mcpState:D,mcpConfigPath:ei,mcpConfigError:ri,mcpConfigSuccess:ni,mcpConfigBusy:ti,mcpHttpName:Zl,mcpHttpUrl:Jl,mcpRawBlock:Ql,capabilities:{hostConfigFiles:Ce.hostConfigFiles,hookTrust:Ce.hookTrust,mcpConfigEditing:Ce.mcpConfigEditing,planMode:Ce.planMode,sandboxMode:m?!1:Ce.sandboxMode},shellControlState:N,onToggleView:we,onDismissPromptFocus:Mt,onSetOpenMenu:ve,onToolboxItemClick:gi,onSetSlashPanelView:O,onViewGoals:W,onUpdateGoal:ae,onOpenForkTurns:()=>K==null?void 0:K(),onForkLatest:fe,onForkTurn:ze,onCopySkillInvokeName:hi,onResetHookForm:Fl,onSetHooksPanelMode:Rl,onClearHookConfigStatus:ga,onSetEditingHookTarget:Al,onSetHookScope:Ml,onSetHookEventName:$l,onSetHookMatcher:_l,onSetHookCommand:Dl,onSetHookTimeoutSec:Bl,onSetHookStatusMessage:Gl,onSaveHook:Ol,onStartEditingHook:Hl,onTrustHook:Wl,onUntrustHook:Ul,onSetMcpPanelMode:Ne,onClearMcpConfigStatus:ba,onSetMcpHttpName:ai,onSetMcpHttpUrl:si,onSetMcpRawBlock:oi,onPrepareRawMcpBlock:li,onSaveHttpMcp:ii,onSaveRawMcpBlock:di,onPickPhoto:()=>wa("photo",Qe),onPickFile:()=>wa("file",et),onUpdateSettings:re=>void wt(re),onPasteShell:()=>void bi(),onCopyShell:()=>{Mt(),ve(null),ye==null||ye()},onClearShell:()=>{Mt(),ve(null),_({prompt:"clear"})},onShellControl:re=>{Mt(),ve(null),De==null||De(re)}}),{promptSlot:Xi,goalSlot:Yi,shellPromptSlot:Zi}=tp({isShellView:Ve,promptRef:Me,prompt:$e,disabled:v,promptPlaceholder:Ti,canInterrupt:Be,interruptLabel:Ei,composerPromptRegionClassName:Wi,graphChatInputClassName:qi,promptInputClassName:Ui,goalComposeMode:pr,goalTokenBudget:Vl,goalLocalError:ql,goalBusy:pn,busy:n,sendButtonLabel:ja,sendButtonClassName:Na,onInterrupt:ie,onPromptInput:ki,onPromptPaste:wi,onPromptKeyDown:Si,onPromptKeyUp:()=>{Ke.current=Zt()},onPromptMouseUp:()=>{Ke.current=Zt()},onPromptBlur:()=>{Ke.current=Zt(),Pe(!1),ut&&ct()},onPromptDragEnter:yi,onPromptDragOver:ji,onPromptDragLeave:Ni,onPromptDrop:Ci,onGoalTokenBudgetChange:Kl,onCancelGoal:xa,onShellPromptChange:ui});return t.jsx(km,{activeView:e,layerClassName:Pi,formClassName:Ri,shellClassName:Ai,inputGroupClassName:Vi,error:o,followTail:j,photoInputRef:Qe,fileInputRef:et,onAppendAttachments:xn,onToggleFollow:je,canJumpToPreviousTurn:Ae,onJumpToPreviousTurn:ce,canJumpToNextTurn:ne,onJumpToNextTurn:Le,subscriptionUsage:Y,onSubmit:vi,formRef:Ge,promptSlot:Xi,pendingQueueSlot:!Ve&&_e.length>0?t.jsx(wm,{prompts:_e,onSteer:Oe,onCancel:V}):null,toolbarSlot:t.jsx(Mm,{...Ki}),goalSlot:Yi,shellPromptSlot:Zi})}var ap=c.createContext(null);function cl(){return c.useContext(ap)}function kt(e){return e?new Date(e).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"}):"Time unavailable"}function Ut(e){return e?new Date(e).toLocaleString():"Time unavailable"}function sp(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 op(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 hl(e){switch(e){case"sending":return"Sending";case"completed":return"Completed";case"interrupted":return"Interrupted";case"failed":return"Failed";case"inProgress":return"Running"}}function lp({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 Qr.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 ip({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 dp({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 cp({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 hp({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 up({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 mp({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 pp({children:e}){return t.jsx("div",{className:"thread-split-region min-h-0 flex-1 overflow-hidden p-0 sm:p-2",children:e})}Po();Pt();function us({...e}){return t.jsx(ad,{"data-slot":"dialog",...e})}function ms({...e}){return t.jsx(sd,{"data-slot":"dialog-trigger",...e})}function fp({...e}){return t.jsx(cd,{"data-slot":"dialog-portal",...e})}function gp({className:e,...r}){return t.jsx(hd,{"data-slot":"dialog-overlay",className:at("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 ps({children:e,className:r,showCloseButton:n=!0,...a}){return t.jsxs(fp,{"data-slot":"dialog-portal",children:[t.jsx(gp,{}),t.jsxs(od,{"data-slot":"dialog-content",className:at("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(ld,{"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($.XIcon,{}),t.jsx("span",{className:"sr-only",children:"Close"})]}):null]})]})}function fs({className:e,...r}){return t.jsx("div",{"data-slot":"dialog-header",className:at("flex flex-col gap-2 text-center sm:text-left",e),...r})}function gs({className:e,...r}){return t.jsx(id,{"data-slot":"dialog-title",className:at("text-lg font-semibold leading-none",e),...r})}function xs({className:e,...r}){return t.jsx(dd,{"data-slot":"dialog-description",className:at("text-sm text-muted-foreground",e),...r})}var xp=[{value:"system",label:"Follow system",icon:$.Monitor},{value:"dark",label:"Dark",icon:$.Moon},{value:"light",label:"Light",icon:$.Sun}];function bp({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),k=a[e.workspaceId],w=k&&!n?k:null,x=r===e.id;c.useEffect(()=>()=>{g.current!==null&&window.clearTimeout(g.current)},[]);async function j(){const N=e.providerSessionId;if(N)try{await navigator.clipboard.writeText(N),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 y=()=>s(e.id),b=`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"}`,v=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($.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:N=>{N.stopPropagation(),N.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($.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:N=>{N.stopPropagation(),N.preventDefault(),j()},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:f==="copied"?t.jsx($.Check,{className:"h-3.5 w-3.5"}):t.jsx($.Copy,{className:"h-3.5 w-3.5"})}):null]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2",children:[w?t.jsx("p",{className:"thread-graph-room-card-meta min-w-0 flex-1 truncate text-[11px] text-[var(--theme-fg-muted)]",title:w,children:w}):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 ${op(e.status)}`,children:sp(e.status)}),t.jsx("time",{className:"shrink-0 text-[11px] text-[var(--theme-fg-muted)]",dateTime:e.lastTurnStartedAt??e.updatedAt,children:kt(e.lastTurnStartedAt??e.updatedAt)})]})]}),h&&d&&!m?t.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),N.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($.Trash2,{className:"h-3.5 w-3.5"})}):null]}),S=o==null?void 0:o(e.id);return l?t.jsx(t.Fragment,{children:l({thread:e,children:v,className:b,onClick:y})}):S?t.jsx("a",{href:S,onClick:N=>{N.preventDefault(),y()},title:m?e.title:void 0,className:b,children:v}):t.jsx("div",{role:"link",tabIndex:0,onClick:y,onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),y())},title:m?e.title:void 0,className:b,children:v})}function vp({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(k=>t.jsx(bp,{thread:k,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}:{}},k.id))})})}function kp({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:k=null,currentWorkspaceLabel:w=null,sessionLabel:x=null,usageLabel:j=null,threadActionsButton:y,topbarActions:b,metaContent:v,settingsContent:S,globalSettingsContent:N,workspaceLabels:L={},workspaceReturnHref:R,onWorkspaceReturn:P,getThreadHref:Q,onOpenThread:D,getNewThreadHref:Z,newThreadHref:J,newThreadLabel:z="New Chat",onNewThread:te,onNewThreadTitle:se,renderNewThreadDialogContent:_,renderThreadLink:ie,onCloseAppNavigation:q,onRenameThread:H,onDeleteThread:G,workspaceContent:T,workspaceTitle:F="Workspace",workspaceActions:B,children:E}){const C=cl(),W=typeof window<"u"?window.matchMedia("(max-width: 639px)").matches:o==="mobile",[U,ae]=c.useState(()=>typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)").matches:!1),K=i??(C==null?void 0:C.themeMode)??"system",de=l??(C==null?void 0:C.effectiveTheme)??(K==="system"?U?"dark":"light":K),[ee,ke]=c.useState(!1),[le,je]=c.useState(!1),[Ae,ce]=c.useState(!W),[ne,Le]=c.useState(W),[Y,me]=c.useState("chat"),[we,ye]=c.useState(null),[De,Be]=c.useState(""),[_e,Oe]=c.useState(null),[V,he]=c.useState(!1),[ve,I]=c.useState(""),[O,oe]=c.useState(!1),[ge,Ne]=c.useState(!1),[Ce,xe]=c.useState("session");c.useEffect(()=>{if(typeof window>"u")return;const M=window.matchMedia("(max-width: 639px)"),fe=()=>{Le(M.matches)};return fe(),M.addEventListener("change",fe),()=>{M.removeEventListener("change",fe)}},[]),c.useEffect(()=>{if(typeof window>"u")return;const M=window.matchMedia("(prefers-color-scheme: dark)"),fe=()=>{ae(M.matches)};return fe(),M.addEventListener("change",fe),()=>{M.removeEventListener("change",fe)}},[]);const Ge=c.useMemo(()=>[...k?e.filter(fe=>fe.workspaceId===k):e].sort((fe,ze)=>{if(fe.id===p)return-1;if(ze.id===p)return 1;const Fe=Date.parse(fe.lastTurnStartedAt??fe.updatedAt);return Date.parse(ze.lastTurnStartedAt??ze.updatedAt)-Fe}),[p,k,e]),Me=J??(Z==null?void 0:Z(k)),Qe=w??k??"all",et=x??g??p??"default_session",it=j??(r!=null&&r.state?`runtime ${r.state}`:"waiting for agent usage"),tt=d??(C==null?void 0:C.setThemeMode),Ke=!!tt,dt=()=>{ke(!1),q==null||q()};async function gt(M){if(!H)return;const fe=De.trim();if(fe){Oe(M);try{await H(M,fe),ye(null),Be("")}finally{Oe(null)}}}function Ve(M){ye(M.id),Be(M.title)}function A(){ye(null),Be("")}function X(M){D==null||D(M),dt()}function be(){he(!1),I("")}function Se(M){if(!Me||!M.trim())return Me;try{const fe=new URL(Me,window.location.origin);return fe.searchParams.set("title",M.trim()),`${fe.pathname}${fe.search}${fe.hash}`}catch{const fe=Me.includes("?")?"&":"?";return`${Me}${fe}title=${encodeURIComponent(M.trim())}`}}async function Pe(){const M=ve.trim();oe(!0);try{if(M&&se){await se(M),I(""),he(!1),dt();return}if(Me){window.location.assign(Se(M)??Me);return}await(te==null?void 0:te()),I(""),he(!1),dt()}finally{oe(!1)}}function rt(M,fe=!1){const ze=fe?t.jsxs(t.Fragment,{children:[t.jsx($.Plus,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:z})]}):t.jsxs(t.Fragment,{children:[t.jsx($.Plus,{className:"h-4 w-4"}),t.jsx("span",{children:z})]});return t.jsxs(us,{open:V,onOpenChange:Fe=>{O||he(Fe)},children:[t.jsx(ms,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":fe?z:void 0,title:z,className:M,children:ze})}),t.jsx(ps,{"data-testid":"create-thread-dialog","data-theme-effective":de,"data-theme-mode":K,className:"thread-graph-create-thread-dialog thread-graph-dialog max-h-[min(86vh,42rem)] overflow-hidden p-4 sm:max-w-[34rem]",children:_?_({close:be,closeNavigation:dt,currentWorkspaceId:k}):t.jsxs(t.Fragment,{children:[t.jsxs(fs,{children:[t.jsx(gs,{children:"Create New Chat"}),t.jsx(xs,{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:ve,onChange:Fe=>I(Fe.target.value),onKeyDown:Fe=>{Fe.key==="Enter"&&(Fe.preventDefault(),Pe())},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 Pe(),disabled:O,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:O?"Creating...":"Create"})]})]})})]})}function nt(){if(!S&&!v&&!N&&!Ke)return null;const M=!!(S||v),fe=!!N,ze=M&&fe,Fe=Ce==="global"&&fe||!M&&fe?"global":"session";return t.jsxs(us,{...u!==void 0?{open:u}:{},...m?{onOpenChange:m}:{},children:[t.jsx(ms,{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($.Settings,{className:"h-4 w-4"})})}),t.jsxs(ps,{"data-testid":"settings-dialog","data-theme-effective":de,"data-theme-mode":K,className:"thread-graph-settings-dialog thread-graph-dialog",children:[t.jsxs(fs,{children:[t.jsx(gs,{children:"Settings"}),t.jsx(xs,{children:"Manage this session and host-wide preferences."})]}),Ke?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: ",de]})]}),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:xp.map(Ue=>{const mt=Ue.icon,yt=K===Ue.value;return t.jsxs("button",{type:"button","data-testid":`theme-mode-${Ue.value}`,"aria-pressed":yt,disabled:!Ke,onClick:()=>tt==null?void 0:tt(Ue.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 ${yt?"is-selected":""}`,children:[t.jsx(mt,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:"truncate",children:Ue.label})]},Ue.value)})})]})}):null,ze?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":Fe==="session",onClick:()=>xe("session"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Fe==="session"?"is-active":""}`,children:"Session"}),t.jsx("button",{type:"button","aria-pressed":Fe==="global",onClick:()=>xe("global"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Fe==="global"?"is-active":""}`,children:"Global"})]}):null,t.jsx("div",{className:"thread-graph-settings-body mt-4 min-h-0 overflow-y-auto pr-1 text-sm",children:Fe==="session"?t.jsxs("div",{className:"grid gap-4",children:[S?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:S}):null,v?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:v}):null,M?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 $e(M=!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)] ${M?"justify-center":""}`,children:[t.jsx($.Rows3,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:M?"sr-only":"",children:"Rooms"}),!M&&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&&Ge.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,Ge.length>0?t.jsx(vp,{threads:Ge,currentThreadId:p,currentWorkspaceId:k,workspaceLabels:L,onOpenThread:X,collapsed:M,...H?{onBeginRenameThread:Ve}:{},showDeleteButton:!!G,...Q?{getThreadHref:Q}:{},...ie?{renderThreadLink:ie}:{},...G?{onDeleteThread:G}:{}}):null]})]})})}function We(){return T?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:()=>ce(!0),className:"thread-workspace-collapse-tab thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx($.ChevronsRight,{className:"h-4 w-4"})}),B?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:B})}):null,t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:T})]}):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:F}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:w??k??"Current context"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[B,t.jsx("button",{type:"button",onClick:()=>ce(!0),className:"thread-workspace-small-toggle thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx($.ChevronsRight,{className:"h-4 w-4"})})]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:T??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:w??k??"All threads"})]})]})})]})}const ut=!!T,st=o==="mobile"||o==="responsive"&&ne,ct=st,xt=ct&&!ee,wt=!!(R||P)?t.jsx("a",{href:R??"#",onClick:M=>{P&&(M.preventDefault(),P())},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($.ArrowLeft,{className:"h-4 w-4"})}):null;return t.jsxs(t.Fragment,{children:[t.jsx(ip,{effectiveTheme:de,layoutMode:o,themeMode:K,viewportConstrained:s,children:t.jsxs(dp,{roomsRailCollapsed:le,children:[t.jsx(cp,{open:ee,onClose:()=>ke(!1)}),t.jsxs(hp,{collapsed:le,mobileOpen:ee,children:[t.jsx("div",{className:`thread-rooms-rail-header flex h-[calc(3rem+env(safe-area-inset-top))] shrink-0 items-end border-b border-[var(--theme-border)] px-4 pb-2 sm:h-16 sm:items-center sm:pb-0 ${le?"sm:w-full sm:justify-center sm:px-2":""}`,children:t.jsxs("div",{className:`flex w-full items-center gap-3 ${le?"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:()=>je(M=>!M),className:"thread-icon-button thread-desktop-only-flex h-9 w-9 shrink-0 items-center justify-center rounded-full",title:le?"Expand rooms":"Collapse rooms","aria-label":le?"Expand rooms":"Collapse rooms",children:le?t.jsx($.PanelLeftOpen,{className:"h-4 w-4"}):t.jsx($.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)] ${le?"thread-desktop-collapsed-hidden":""}`,children:(w??"R").charAt(0).toUpperCase()}),t.jsxs("div",{className:`min-w-0 ${le?"thread-desktop-collapsed-hidden":""}`,children:[t.jsx("p",{className:"truncate text-sm font-semibold text-[var(--theme-fg)]",children:w??"Remote Codex"}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:k??"Thread workspace"})]})]}),t.jsxs("div",{className:`flex shrink-0 items-center gap-1 ${le?"thread-desktop-collapsed-hidden":""}`,children:[nt(),wt,t.jsx("button",{type:"button",onClick:()=>ke(!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($.X,{className:"h-4 w-4"})})]})]})}),t.jsx("div",{className:`thread-graph-new-room-strip flex shrink-0 items-center border-b ${le?"h-12 w-full justify-center px-2 sm:h-12":"h-[68px] px-4"}`,children:rt(`thread-graph-new-room-button inline-flex items-center justify-center rounded-xl font-medium transition ${le?"h-9 w-9 p-0":"h-11 w-full gap-2 px-3 text-sm sm:h-9"}`,le)}),t.jsx("div",{className:`flex min-h-0 flex-1 flex-col ${le?"w-full px-2 py-2":"px-3 py-3"}`,children:$e(le)})]}),t.jsxs(up,{children:[t.jsx(mp,{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 flex-1 items-center gap-2 sm:gap-3",children:[xt?t.jsx("button",{type:"button",onClick:()=>ke(!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($.Menu,{className:"h-4 w-4"})}):null,t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"min-w-0 truncate text-sm font-semibold leading-tight text-[var(--theme-fg)] sm:text-base",title:g??"Shared Workspace",children:g??"Shared Workspace"}),t.jsxs("div",{className:"relative mt-0.5 flex min-w-0 items-center gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{Ne(M=>!M)},"aria-expanded":ge,"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:Qe})]}),ge?t.jsxs("div",{className:"thread-topbar-details-popover absolute left-0 top-[calc(100%+0.5rem)] z-50 w-[min(28rem,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 M;et&&((M=navigator.clipboard)==null||M.writeText(et))},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-14 shrink-0",children:"Session"}),t.jsx("span",{className:"truncate font-mono",children:et})]}),t.jsxs("div",{className:"thread-topbar-meta-row mt-1 flex min-w-0 max-w-full items-start gap-2 text-xs leading-5",title:"Session token usage and estimated cost",children:[t.jsx("span",{className:"w-14 shrink-0",children:"Usage"}),t.jsx("span",{className:"min-w-0 whitespace-normal break-words font-mono",children:it})]})]}):null]})]})]}),t.jsxs("div",{className:"relative z-[1] inline-flex shrink-0 items-center gap-2",children:[y||b?t.jsxs("div",{className:"thread-graph-topbar-actions thread-desktop-only-inline-flex items-center rounded-lg border p-0.5 shadow-none",children:[y,b]}):null,ct&&y?t.jsx("div",{className:"thread-mobile-only-inline-flex",children:y}):null,ct&&ut?t.jsx("button",{type:"button",onClick:()=>me(M=>M==="workspace"?"chat":"workspace"),"aria-label":Y==="workspace"?"Show chat":"Show workspace",title:Y==="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:Y==="workspace"?t.jsx($.MessageSquare,{className:"h-4 w-4"}):t.jsx($.Folder,{className:"h-4 w-4"})}):null,ct?f:null,ct&&h?rt("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(pp,{children:ut&&!Ae?st?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 ${Y==="chat"?"block":"thread-mobile-chat-hidden"}`,children:E}),t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${Y==="workspace"?"block":"thread-mobile-workspace-hidden"}`,children:We()})]}):t.jsxs(_n,{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(or,{defaultSize:47,minSize:30,maxSize:75,className:"thread-split-chat-pane min-w-0 overflow-hidden",children:E}),t.jsx(Dn,{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(or,{defaultSize:53,minSize:30,maxSize:70,className:"thread-split-workspace-pane min-w-0 overflow-hidden",children:We()})]}):t.jsxs("div",{className:"thread-split-container relative h-full min-h-0 overflow-hidden",children:[ut&&Ae?t.jsx("button",{type:"button",onClick:()=>ce(!1),className:"thread-workspace-expand-fab thread-desktop-only-inline-flex",title:"Expand workspace","aria-label":"Expand workspace",children:t.jsx($.ChevronsLeft,{className:"h-4 w-4"})}):null,E]})})]})]})}),t.jsx(lp,{open:we!==null,title:"Rename Thread",label:"Thread Title",value:De,busy:_e!==null,onChange:Be,onCancel:A,onSubmit:()=>we?gt(we):void 0})]})}function wp({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?Qr.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 yp=[/^(?: {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],jp=/^(?:\|?[^|\n]+\|[^|\n]+(?:\|[^|\n]+)*\|?\s*\n\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$)/m,Np=/!?\[[^\]\n]+\]\([^)]+\)/,Cp=/`[^`\n]+`/,Sp=/(?:\*\*[^*\n]+\*\*|__[^_\n]+__)/,Tp=/(^|[^\w])(?:\*[^*\n]+\*|_[^_\n]+_)(?=[^\w]|$)/,Ep=/~~[^~\n]+~~/;function Lp(e){const r=e.trim();return r?yp.some(n=>n.test(r))||jp.test(r)?!0:/[`[\]*_~!]/.test(r)?Np.test(r)||Cp.test(r)||Sp.test(r)||Tp.test(r)||Ep.test(r):!1:!1}sn();function Xn(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 ca(e=[]){const r=Xn(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 ha=c.createContext(ca());function ua(){return c.useContext(ha)??ca()}Pr();function ul(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function bs(e){return ul(e)?Object.entries(e):e==null||e===""?[]:[["value",e]]}function ml(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 Ip(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)}):ml(r)}function vs({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($.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"};case"failed":return{className:"is-failed",icon:t.jsx($.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"};default:return{className:"is-pending",icon:t.jsx($.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),label:"Running"}}},[n]),l=c.useMemo(()=>bs(s),[s]),i=c.useMemo(()=>bs(a),[a]),d=c.useMemo(()=>typeof s=="string"?s.length>0:ul(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(Lr,{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(Ir,{value:"item-1",className:"border-0",children:[t.jsx(on,{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($.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(zr,{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:": "}),ml(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:": "}),Ip(f,p),g<l.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},f)),"}"]})]}):null]})]})})})}var ks=null;function zp(){return ks??(ks=Promise.all([Xe(()=>import("./core-DODVy7wn.js"),__vite__mapDeps([0,1,2])),Xe(()=>import("./engine-javascript-DBd1bXLz.js"),[]),Xe(()=>import("./ayu-light-BA47KaF1.js"),[]),Xe(()=>import("./ayu-dark-DYE7WIF3.js"),[]),Xe(()=>import("./javascript-wDzz0qaB.js"),[]),Xe(()=>import("./typescript-BPQ3VLAy.js"),[]),Xe(()=>import("./tsx-COt5Ahok.js"),[]),Xe(()=>import("./jsx-g9-lgVsj.js"),[]),Xe(()=>import("./python-B6aJPvgy.js"),[]),Xe(()=>import("./json-Cp-IABpG.js"),[]),Xe(()=>import("./shellscript-CEILq0vU.js").then(e=>e.b),[]),Xe(()=>import("./shellscript-CEILq0vU.js").then(e=>e.s),[]),Xe(()=>import("./yaml-Buea-lGh.js"),[]),Xe(()=>import("./toml-vGWfd6FD.js"),[]),Xe(()=>import("./markdown-Cvjx9yec.js"),[]),Xe(()=>import("./html-pp8916En.js"),__vite__mapDeps([3,4,5])),Xe(()=>import("./css-CLj8gQPS.js"),[]),Xe(()=>import("./sql-CRqJ_cUM.js"),[]),Xe(()=>import("./csv-fuZLfV_i.js"),[])]).then(([{createHighlighterCore:e},{createJavaScriptRegexEngine:r},n,a,s,o,l,i,d,h,u,m,f,p,g,k,w,x,j])=>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,k.default,w.default,x.default,j.default]}))),ks}function ln(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Yn(e){if(!e)return{};if(ln(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 Zn(){return{finalResult:null,stdout:"",stderr:""}}function Pp(e){return typeof e=="string"?{result:e}:e}function pl(e){const r=ln(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 ws(e){if(!e)return"pending";if(!ln(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 Rp(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=Pp(d.result),m=r.get(h)??Zn();return ln(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=Yn(d.args);if(typeof h=="string"&&r.has(h)){const f=pl(r.get(h)??Zn());return`\`\`\`tool-merged
3690
3692
  ${JSON.stringify({call:{tool:u,args:m,call_id:h},result:f},null,2)}
3691
- \`\`\``}return l}catch{return l}}),resultMap:r}}var zp=["/api/","/assets/","/control-plane","/devices/","/relay/","/relay-account","/relay-admin","/relay-devices","/relay-portal","/threads","/workspaces"];function ks(e){return e.replace(/background-color:[^;"]+;?/g,"background-color: transparent;").replace(/background:[^;"]+;?/g,"background: transparent;")}function ws(e){return Array.isArray(e)?e.map(r=>String(r)).join(""):String(e??"")}function Pp(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,o=n&&typeof n=="object"?n.line:void 0,s=a&&typeof a=="object"?a.line:void 0;return{startLine:typeof o=="number"?o:void 0,endLine:typeof s=="number"?s:void 0}}function Rp(e){if(!e)return null;let r=e.trim();if(!r)return null;try{if(typeof window>"u")return null;const s=new URL(r,window.location.origin);if(s.origin!==window.location.origin&&s.protocol!=="file:")return null;r=(s.protocol==="file:",s.pathname)}catch{}try{r=decodeURIComponent(r)}catch{}if(!r.startsWith("/")||zp.some(s=>r===s||r.startsWith(s)))return null;const n=r.match(/:(\d+)(?::\d+)?$/),a=n?Number.parseInt(n[1]??"",10):void 0,o=n?r.slice(0,-n[0].length):r;return!o||o==="/"?null:{path:o,...Number.isFinite(a)?{line:a}:{}}}function Mp({children:e,...r}){return Ap(e)?t.jsx(t.Fragment,{children:e}):t.jsx("pre",{...r,children:e})}function Ap(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 _p=c.memo(function({className:r="thread-graph-markdown",content:n,onOpenWorkspaceFile:a}){const o=c.useRef(null),s=ca(),[l,i]=c.useState(null),[d,h]=c.useState({}),[u,m]=c.useState(!1),{processedContent:f,resultMap:p}=c.useMemo(()=>Ip(n),[n]);c.useEffect(()=>{let w=!0;return Ep().then(x=>{w&&i(x)}).catch(()=>{}),()=>{w=!1}},[]),c.useEffect(()=>{const w=o.current,x=w==null?void 0:w.closest(".thread-ui-shell"),j=()=>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(j()),!x)return;const y=new MutationObserver(()=>m(j()));return y.observe(x,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>y.disconnect()},[]);async function g(w,x){try{await navigator.clipboard.writeText(x),h(j=>({...j,[w]:"copied"})),window.setTimeout(()=>{h(j=>{const y={...j};return delete y[w],y})},1200)}catch{h(j=>({...j,[w]:"failed"}))}}const b=({children:w,className:x,inline:j,node:y,...v})=>{var D;const k=/language-(\w+(?:-\w+)*)/.exec(x||""),S=k?k[1]??"":"",N=ws(w).replace(/\n$/,""),{startLine:L,endLine:R}=Pp(y),P=j===!1||!!x||N.includes(`
3692
- `)||L!==R;if(S==="tool-merged"){let Z={call:{tool:"Unknown",args:{},call_id:void 0},result:null};try{Z=JSON.parse(N)}catch{Z={call:{tool:"Error",args:{raw:N}},result:{status:"failed"}}}const J=typeof Z.call.tool=="string"?Z.call.tool:"Unknown",z=typeof Z.call.call_id=="string"?Z.call.call_id:void 0;return t.jsx(xs,{callId:z,toolName:J,status:vs(Z.result),parameters:qn(Z.call.args),result:Z.result})}if(S==="tool-call"){let Z={tool:"Unknown",args:{},call_id:void 0};try{Z=JSON.parse(N)}catch{Z={tool:"Error",args:{raw:N}}}const J=typeof Z.call_id=="string"?Z.call_id:void 0,z=J&&p.has(J)?hl(p.get(J)??Kn()):void 0;return t.jsx(xs,{callId:J,toolName:typeof Z.tool=="string"?Z.tool:"Unknown",status:z?vs(z):"pending",parameters:qn(Z.args),result:z})}if(S==="tool-result")return null;if(["xyz","extxyz","cif","pdb"].includes(S)){const Z=s.renderInlineCode({code:N,isIncomplete:!1,language:S});if(c.isValidElement(Z))return Z}if(P){const J=(((D=l==null?void 0:l.getLoadedLanguages)==null?void 0:D.call(l))??[]).includes(S)?S:"text",z=u?"ayu-dark":"ayu-light",te=`${S||"text"}:${N.length}:${N.slice(0,32)}`;let se="";if(l)try{se=ks(l.codeToHtml(N,{lang:J,theme:z}))}catch{se=ks(l.codeToHtml(N,{lang:"text",theme:z}))}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(Nr,{type:"button",onClick:()=>void g(te,N),variant:"ghost",size:"sm",className:"thread-graph-code-copy absolute right-2 top-2 z-10 rounded-md p-1.5",title:d[te]==="copied"?"Copied":d[te]==="failed"?"Copy failed":"Copy","aria-label":"Copy code",children:d[te]==="copied"?t.jsx(_.Check,{className:"h-3.5 w-3.5"}):t.jsx(_.Copy,{className:"h-3.5 w-3.5"})}),se?t.jsx("div",{dangerouslySetInnerHTML:{__html:se}}):t.jsx("pre",{children:t.jsx("code",{className:"whitespace-pre",children:N})})]})}const Q=ws(w).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||""}`,...v,children:Q})};return t.jsx("div",{ref:o,className:`thread-graph-message-markdown ${r}`,children:t.jsx(Ed,{remarkPlugins:[Id,zd],rehypePlugins:[Ld],components:{a({href:w,children:x,...j}){const y=Rp(w);return y&&a?t.jsx("a",{...j,href:w,className:"thread-inline-link",onClick:v=>{v.preventDefault(),a(y)},children:x}):t.jsx("a",{...j,href:w,className:"thread-inline-link",children:x})},code:b,pre:Mp},children:f})})}),ys=2400,$p=/\b(?:https?:\/\/|www\.)[^\s<>"'`]+/gi,Dp=/[),.;:!?]+$/;function Bp(e){return e.startsWith("www.")?`https://${e}`:e}function js(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function Gp(e){var s;if(!e)return[];const r=/\[(PHOTO|FILE)\s+([^\]]+)\]/g,n=[];let a=0,o=0;for(const l of e.matchAll(r)){const i=l.index??0;i>a&&(n.push({type:"text",key:`text-${o}`,text:e.slice(a,i)}),o+=1);const d=l[1],h=((s=l[2])==null?void 0:s.trim())??"";d==="PHOTO"&&h?n.push({type:"photo",key:`photo-${o}`,path:h}):d==="FILE"&&h?n.push({type:"file",key:`file-${o}`,path:h}):n.push({type:"text",key:`text-${o}`,text:l[0]}),o+=1,a=i+l[0].length}return a<e.length&&n.push({type:"text",key:`text-${o}`,text:e.slice(a)}),n}function lr({text:e}){var a;const r=[];let n=0;for(const o of e.matchAll($p)){const s=o[0],l=o.index??0,i=((a=s.match(Dp))==null?void 0:a[0])??"",d=i?s.slice(0,-i.length):s;d&&(l>n&&r.push(e.slice(n,l)),r.push(t.jsx("a",{href:Bp(d),target:"_blank",rel:"noreferrer",className:"thread-inline-link",children:d},`${l}-${d}`)),i&&r.push(i),n=l+s.length)}return n<e.length&&r.push(e.slice(n)),t.jsx(t.Fragment,{children:r.length>0?r:e})}var ul=c.memo(function({text:r,scrollRootRef:n,streaming:a=!1,containerClassName:o="",plainTextClassName:s="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=Sp(r),g=!a&&r.length>ys,b=g&&!m?`${r.slice(0,ys).trimEnd()}
3693
+ \`\`\``}return l}catch{return l}}),resultMap:r}}var Ap=["/api/","/assets/","/control-plane","/devices/","/relay/","/relay-account","/relay-admin","/relay-devices","/relay-portal","/threads","/workspaces"];function ys(e){return e.replace(/background-color:[^;"]+;?/g,"background-color: transparent;").replace(/background:[^;"]+;?/g,"background: transparent;")}function js(e){return Array.isArray(e)?e.map(r=>String(r)).join(""):String(e??"")}function Mp(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 $p(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("/")||Ap.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 _p({children:e,...r}){return Dp(e)?t.jsx(t.Fragment,{children:e}):t.jsx("pre",{...r,children:e})}function Dp(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 Bp=c.memo(function({className:r="thread-graph-markdown",content:n,onOpenWorkspaceFile:a}){const s=c.useRef(null),o=ua(),[l,i]=c.useState(null),[d,h]=c.useState({}),[u,m]=c.useState(!1),{processedContent:f,resultMap:p}=c.useMemo(()=>Rp(n),[n]);c.useEffect(()=>{let w=!0;return zp().then(x=>{w&&i(x)}).catch(()=>{}),()=>{w=!1}},[]),c.useEffect(()=>{const w=s.current,x=w==null?void 0:w.closest(".thread-ui-shell"),j=()=>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(j()),!x)return;const y=new MutationObserver(()=>m(j()));return y.observe(x,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>y.disconnect()},[]);async function g(w,x){try{await navigator.clipboard.writeText(x),h(j=>({...j,[w]:"copied"})),window.setTimeout(()=>{h(j=>{const y={...j};return delete y[w],y})},1200)}catch{h(j=>({...j,[w]:"failed"}))}}const k=({children:w,className:x,inline:j,node:y,...b})=>{var D;const v=/language-(\w+(?:-\w+)*)/.exec(x||""),S=v?v[1]??"":"",N=js(w).replace(/\n$/,""),{startLine:L,endLine:R}=Mp(y),P=j===!1||!!x||N.includes(`
3694
+ `)||L!==R;if(S==="tool-merged"){let Z={call:{tool:"Unknown",args:{},call_id:void 0},result:null};try{Z=JSON.parse(N)}catch{Z={call:{tool:"Error",args:{raw:N}},result:{status:"failed"}}}const J=typeof Z.call.tool=="string"?Z.call.tool:"Unknown",z=typeof Z.call.call_id=="string"?Z.call.call_id:void 0;return t.jsx(vs,{callId:z,toolName:J,status:ws(Z.result),parameters:Yn(Z.call.args),result:Z.result})}if(S==="tool-call"){let Z={tool:"Unknown",args:{},call_id:void 0};try{Z=JSON.parse(N)}catch{Z={tool:"Error",args:{raw:N}}}const J=typeof Z.call_id=="string"?Z.call_id:void 0,z=J&&p.has(J)?pl(p.get(J)??Zn()):void 0;return t.jsx(vs,{callId:J,toolName:typeof Z.tool=="string"?Z.tool:"Unknown",status:z?ws(z):"pending",parameters:Yn(Z.args),result:z})}if(S==="tool-result")return null;if(["xyz","extxyz","cif","pdb"].includes(S)){const Z=o.renderInlineCode({code:N,isIncomplete:!1,language:S});if(c.isValidElement(Z))return Z}if(P){const J=(((D=l==null?void 0:l.getLoadedLanguages)==null?void 0:D.call(l))??[]).includes(S)?S:"text",z=u?"ayu-dark":"ayu-light",te=`${S||"text"}:${N.length}:${N.slice(0,32)}`;let se="";if(l)try{se=ys(l.codeToHtml(N,{lang:J,theme:z}))}catch{se=ys(l.codeToHtml(N,{lang:"text",theme:z}))}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(Tr,{type:"button",onClick:()=>void g(te,N),variant:"ghost",size:"sm",className:"thread-graph-code-copy absolute right-2 top-2 z-10 rounded-md p-1.5",title:d[te]==="copied"?"Copied":d[te]==="failed"?"Copy failed":"Copy","aria-label":"Copy code",children:d[te]==="copied"?t.jsx($.Check,{className:"h-3.5 w-3.5"}):t.jsx($.Copy,{className:"h-3.5 w-3.5"})}),se?t.jsx("div",{dangerouslySetInnerHTML:{__html:se}}):t.jsx("pre",{children:t.jsx("code",{className:"whitespace-pre",children:N})})]})}const Q=js(w).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||""}`,...b,children:Q})};return t.jsx("div",{ref:s,className:`thread-graph-message-markdown ${r}`,children:t.jsx(zd,{remarkPlugins:[Rd,Ad],rehypePlugins:[Pd],components:{a({href:w,children:x,...j}){const y=$p(w);return y&&a?t.jsx("a",{...j,href:w,className:"thread-inline-link",onClick:b=>{b.preventDefault(),a(y)},children:x}):t.jsx("a",{...j,href:w,className:"thread-inline-link",children:x})},code:k,pre:_p},children:f})})}),Ns=2400,Gp=/\b(?:https?:\/\/|www\.)[^\s<>"'`]+/gi,Fp=/[),.;:!?]+$/;function Hp(e){return e.startsWith("www.")?`https://${e}`:e}function Cs(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function Op(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 ir({text:e}){var a;const r=[];let n=0;for(const s of e.matchAll(Gp)){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:Hp(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 fl=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=Lp(r),g=!a&&r.length>Ns,k=g&&!m?`${r.slice(0,Ns).trimEnd()}
3693
3695
 
3694
- ...`:r,[w,x]=c.useState(a||typeof IntersectionObserver>"u"),j=c.useCallback(()=>{const y=n.current,v=h.current,k=(v==null?void 0:v.getBoundingClientRect().top)??null;i==null||i(),u.current=y&&k!==null?{root:y,top:k}:null,f(S=>!S)},[i,n]);return c.useLayoutEffect(()=>{const y=u.current,v=h.current;if(!y||!v)return;u.current=null;const k=()=>{const N=v.getBoundingClientRect().top;y.root.scrollTop+=N-y.top};k();const S=window.requestAnimationFrame(k);return()=>{window.cancelAnimationFrame(S)}},[m]),c.useEffect(()=>{if(a||typeof IntersectionObserver>"u"){x(!0);return}if(w||!h.current)return;const y=new IntersectionObserver(v=>{for(const k of v)if(k.isIntersecting){x(!0),y.disconnect();break}},{root:n.current,threshold:0});return y.observe(h.current),()=>{y.disconnect()}},[w,n,a]),t.jsxs("div",{ref:h,className:o,children:[w&&p?t.jsx(_p,{content:b,className:l,onOpenWorkspaceFile:d}):t.jsx("p",{className:s,children:t.jsx(lr,{text:b})}),g?t.jsx("button",{type:"button",onClick:j,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]})}),Fp=c.memo(function({text:r,scrollRootRef:n,streaming:a=!1,onBeforeResize:o,onOpenWorkspaceFile:s}){return t.jsx(ul,{text:r,scrollRootRef:n,streaming:a,containerClassName:"thread-graph-message-prose",...o?{onBeforeResize:o}:{},...s?{onOpenWorkspaceFile:s}:{}})}),Hp=c.memo(function({threadId:r,text:n,attachmentPreviewUrls:a,getImageAssetUrl:o}){const s=c.useMemo(()=>Gp(n),[n]);return t.jsx("div",{className:"thread-graph-message-prose whitespace-pre-wrap break-words text-[15px] leading-6",children:s.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?(o==null?void 0:o({threadId:r,path:l.path}))??null:null),h=js(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=js(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 Op(){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 Ns({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"),o=r.includes("accepted")||r.includes("complete"),s=n?"ui-status-warning":a?"ui-status-danger":o?"ui-status-success":"ui-status-neutral",l=n?t.jsx(_.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):a?t.jsx(_.XCircle,{className:"h-3.5 w-3.5"}):o?t.jsx(_.CheckCircle2,{className:"h-3.5 w-3.5"}):t.jsx(_.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 ${s}`,title:e,"aria-label":`Status: ${e}`,children:[t.jsx("span",{className:"thread-graph-message-status-icon inline-flex shrink-0",children:n?t.jsx(Op,{}):l}),t.jsx("span",{className:"thread-graph-status-label",children:e})]})}function Wp({children:e,copyButton:r,kind:n,metaControl:a,reasoning:o,status:s,timeLabel:l,timeTitle:i}){const d=n==="userMessage",h=l?t.jsx("span",{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(Ns,{status:s??"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]}),o,t.jsx("div",{className:`thread-graph-message-content min-w-0 ${d?"is-user":"is-assistant"}`,children:e}),d&&(s||h)?t.jsxs("div",{className:"mt-1 flex items-center justify-end gap-2",children:[s?t.jsx(Ns,{status:s}):null,h]}):null]})})}Lr();function Up(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function Vp({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 It=c.memo(function({threadId:r,item:n,scrollRootRef:a,streaming:o=!1,adapter:s,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(N=>N.text.trim()).filter(Boolean).join(`
3696
+ ...`:r,[w,x]=c.useState(a||typeof IntersectionObserver>"u"),j=c.useCallback(()=>{const y=n.current,b=h.current,v=(b==null?void 0:b.getBoundingClientRect().top)??null;i==null||i(),u.current=y&&v!==null?{root:y,top:v}:null,f(S=>!S)},[i,n]);return c.useLayoutEffect(()=>{const y=u.current,b=h.current;if(!y||!b)return;u.current=null;const v=()=>{const N=b.getBoundingClientRect().top;y.root.scrollTop+=N-y.top};v();const S=window.requestAnimationFrame(v);return()=>{window.cancelAnimationFrame(S)}},[m]),c.useEffect(()=>{if(a||typeof IntersectionObserver>"u"){x(!0);return}if(w||!h.current)return;const y=new IntersectionObserver(b=>{for(const v of b)if(v.isIntersecting){x(!0),y.disconnect();break}},{root:n.current,threshold:0});return y.observe(h.current),()=>{y.disconnect()}},[w,n,a]),t.jsxs("div",{ref:h,className:s,children:[w&&p?t.jsx(Bp,{content:k,className:l,onOpenWorkspaceFile:d}):t.jsx("p",{className:o,children:t.jsx(ir,{text:k})}),g?t.jsx("button",{type:"button",onClick:j,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]})}),Wp=c.memo(function({text:r,scrollRootRef:n,streaming:a=!1,onBeforeResize:s,onOpenWorkspaceFile:o}){return t.jsx(fl,{text:r,scrollRootRef:n,streaming:a,containerClassName:"thread-graph-message-prose",...s?{onBeforeResize:s}:{},...o?{onOpenWorkspaceFile:o}:{}})}),Up=c.memo(function({threadId:r,text:n,attachmentPreviewUrls:a,getImageAssetUrl:s}){const o=c.useMemo(()=>Op(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=Cs(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=Cs(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 Vp(){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 Ss({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($.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):a?t.jsx($.XCircle,{className:"h-3.5 w-3.5"}):s?t.jsx($.CheckCircle2,{className:"h-3.5 w-3.5"}):t.jsx($.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(Vp,{}):l}),t.jsx("span",{className:"thread-graph-status-label",children:e})]})}function qp({children:e,copyButton:r,kind:n,metaControl:a,reasoning:s,status:o,timeLabel:l,timeTitle:i}){const d=n==="userMessage",h=l?t.jsx("span",{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(Ss,{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(Ss,{status:o}):null,h]}):null]})})}Pr();function Kp(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function Xp({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 It=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??[]:[],k=g.map(N=>N.text.trim()).filter(Boolean).join(`
3695
3697
 
3696
- `),w=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 j(){d==null||d(),f(N=>!N)}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:h==="copied"?t.jsx(_.Check,{className:"h-3.5 w-3.5"}):t.jsx(_.Copy,{className:"h-3.5 w-3.5"})}):null,v=g.some(N=>Up(N.status)),k=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:j,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(_.Brain,{className:`h-3.5 w-3.5 ${v?"animate-pulse":""}`}),t.jsx("span",{children:"CoT"}),v?t.jsx(Vp,{tone:"sky"}):null]}):null,S=n.kind==="agentMessage"&&b?t.jsx("div",{className:"thread-graph-message-thinking mb-3",children:t.jsx(Sr,{type:"single",collapsible:!0,className:"thread-graph-thinking-accordion w-full border-none",onValueChange:N=>f(!!N),...m?{value:"thoughts"}:{},children:t.jsx(Tr,{value:"thoughts",className:"border-b-0",children:t.jsx(Er,{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(lr,{text:b})})})})})}):null;return t.jsx(Wp,{kind:n.kind,status:w||n.kind==="agentMessage"?n.status:null,copyButton:y,metaControl:k,reasoning:S,timeLabel:l,timeTitle:i,children:n.kind==="agentMessage"?t.jsx(Fp,{text:n.text,scrollRootRef:a,streaming:o,...d?{onBeforeResize:d}:{},...s!=null&&s.onOpenWorkspaceFile?{onOpenWorkspaceFile:s.onOpenWorkspaceFile}:{}}):t.jsx(Hp,{threadId:r,text:n.text,attachmentPreviewUrls:n.attachmentPreviewUrls,getImageAssetUrl:s==null?void 0:s.getImageAssetUrl})})});function Cs(e){return e.replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&")}function ml(e){const r=e.trim().match(/^<hook_prompt(?:\s+hook_run_id="([^"]+)")?>([\s\S]*)<\/hook_prompt>$/);if(!r)return null;const n=r[1]?Cs(r[1]):null,a=Cs(r[2]??"").trim(),o=(n==null?void 0:n.split(":")[0])??"hook",s=o==="stop"?"Stop":o,l=(n==null?void 0:n.split(":").slice(2).join(":"))||null;return{id:`live-hook-prompt:${n??"unknown"}`,kind:"hook",text:`${s} hook`,previewText:a||`${s} hook`,detailText:a||null,status:"Completed",hookEventName:o,hookEventLabel:s,hookHandlerType:"command",hookScope:"turn",hookSource:l?"project":null,hookSourcePath:l,hookStatusMessage:null,hookOutputEntries:a?[{kind:"warning",text:a}]:[]}}function qp(e){return e==="userMessage"||e==="agentMessage"}function Kp(e){return e==="commandExecution"||e==="webSearch"||e==="fileRead"||e==="fileChange"||e==="image"||e==="contextCompaction"}function Xp(e){return e==="agentMessage"||e==="reasoning"||e==="agentToolCall"||e==="skillToolCall"||e==="toolCall"||e==="plan"}function Yp(e,r){if(!r)return e;const n=[...e],a=n.findIndex(s=>s.kind==="userMessage");if(a<0)return n;for(let s=a+1;s<n.length;s+=1){const l=n[s];if(!l||l.kind!=="userMessage")continue;let i=s+1;for(;i<n.length&&Kp(n[i].kind);)i+=1;if(i===s+1)continue;const[d]=n.splice(s,1);n.splice(i-1,0,d),s=i-1}let o=!1;return n.map((s,l)=>s.kind!=="userMessage"?s:o?n.slice(l+1).some(d=>Xp(d.kind))?s:{...s,status:"Awaiting response"}:(o=!0,s))}function Tt(e){return typeof e.sequence=="number"&&Number.isFinite(e.sequence)}function Ar(e){return Tt(e)?e.sequence:Number.POSITIVE_INFINITY}function Ss(e){var h;const r=[];let n=0;for(;n<e.length&&((h=e[n])==null?void 0:h.kind)==="userMessage"&&!Tt(e[n]);)r.push(e[n]),n+=1;const a=e.slice(n);if(!a.some(Tt))return e;const o=a.map(u=>Ar(u)).filter(Number.isFinite),s=o.length>0?Math.max(...o):0,l=[];let i=0;for(;i<a.length;){const u=a[i];if(Tt(u)){l.push({item:u,index:i,order:Ar(u)}),i+=1;continue}const m=i;for(;i<a.length&&!Tt(a[i]);)i+=1;const f=a.slice(m,i),p=[...a.slice(0,m)].reverse().find(Tt),g=a.slice(i).find(Tt),b=p?Ar(p):null,w=g?Ar(g):null;f.forEach((x,j)=>{let y;if(b===null&&w!==null)y=w-(f.length-j)/(f.length+1);else if(b!==null&&w!==null&&w>b){const v=w-b;y=b+(j+1)/(f.length+1)*v}else y=s+1+j/(f.length+1);l.push({item:x,index:m+j,order:y})})}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 Zp(e,r){if(!r||r.length===0)return Ss(e);const n=new Map(r.map(s=>[s.id,s])),a=e.map(s=>{const l=n.get(s.id);if(!l)return s;n.delete(s.id);const i={...s,...l,text:l.text||s.text},d=l.detailText??s.detailText,h=l.previewText??s.previewText,u=l.status??s.status,m=l.sequence??s.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}),o=[...n.values()];return o.length===0&&!a.some(Tt)||(a.push(...o),!a.some(s=>typeof s.sequence=="number"&&Number.isFinite(s.sequence)))?a:Ss(a)}function Jp(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 o=n.join("");if(!o)return e;const s=Math.min(e.length,o.length);let l=0;for(;l<s&&e[l]===o[l];)l+=1;if(l===0)return e;const i=e.slice(l);return i.trim()?i:""}function pl(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function vr(e){return e==="inProgress"||e==="sending"}function Qp(e){var a;const r=[];let n=0;for(;n<e.length;){const o=e[n];if(!o)break;if(o.kind!=="commandExecution"&&o.kind!=="fileChange"&&o.kind!=="webSearch"&&o.kind!=="fileRead"){r.push({kind:"item",key:o.id,item:o}),n+=1;continue}const s=[];for(;n<e.length&&((a=e[n])==null?void 0:a.kind)===o.kind;)s.push(e[n]),n+=1;if(s.length===1){r.push({kind:"item",key:s[0].id,item:s[0]});continue}const l=s.map(i=>i.id).join(":");if(o.kind==="commandExecution"){r.push({kind:"commandGroup",key:l,items:s});continue}if(o.kind==="fileChange"){r.push({kind:"fileChangeGroup",key:l,items:s});continue}if(o.kind==="fileRead"){r.push({kind:"fileReadGroup",key:l,items:s});continue}r.push({kind:"searchGroup",key:l,items:s})}return r}function fl(e,r){return[...e.map(n=>({id:n.id,startedAt:n.startedAt??""})),...r?[{id:r.id,startedAt:r.startedAt??""}]:[]]}function kr(e,r,n){const a=e.get(r)??[];a.push(n),e.set(r,a)}function gl(e,r){return e.find(n=>r&&n.startedAt&&r.localeCompare(n.startedAt)<=0)}function ef({answeredRequestNotes:e,pendingRequests:r,visibleTurns:n,optimisticTurn:a}){const o=new Set(n.map(p=>p.id)),s=new Map,l=new Map,i=[],d=[];for(const p of e)p.turnId&&o.has(p.turnId)?kr(s,p.turnId,p):i.push(p);for(const p of r)p.turnId&&o.has(p.turnId)?kr(l,p.turnId,p):d.push(p);const h=fl(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=gl(h,p.createdAt);if(!g){m.push(p);continue}kr(u,g.id,p)}return{notesByTurnId:s,pendingRequestsByTurnId:l,beforeTurnId:u,trailing:m}}function tf({activityNotes:e,visibleTurns:r,optimisticTurn:n}){const a=[...e].sort((m,f)=>m.createdAt.localeCompare(f.createdAt)),o=fl(r,n),s=[],l=new Map,i=new Map,d=[],u=o.map(m=>m.startedAt).filter(m=>!!m).sort().at(-1)??null;for(const m of a){if(m.anchorTurnId==="__leading__"){s.push(m);continue}if(m.anchorTurnId){o.some(p=>p.id===m.anchorTurnId)?kr(i,m.anchorTurnId,m):s.push(m);continue}const f=gl(o,m.createdAt);if(!f){!u||m.createdAt.localeCompare(u)<=0?s.push(m):d.push(m);continue}kr(l,f.id,m)}return{leading:s,beforeTurnId:l,afterTurnId:i,trailing:d}}function xl({request:e,busy:r=!1,onRespond:n}){const[a,o]=c.useState({}),[s,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 j=/\s*\(recommended\)\s*$/i.test(x);return{rawLabel:x,displayLabel:x.replace(/\s*\(recommended\)\s*$/i,"").trim(),recommended:j}}function p(x){h&&(d(x),n==null||n(e.id,{answers:{[h.id]:{answers:[x]}}}))}function g(x){const j=a[x.id]??"";return Array.isArray(j)?j.map(y=>y===u?(s[x.id]??"").trim():y.trim()).filter(Boolean).join(", "):j===u?(s[x.id]??"").trim():j.trim()}function b(x){const j=a[x.id]??"";if(Array.isArray(j))return j.map(v=>v===u?(s[x.id]??"").trim():v.trim()).filter(Boolean);if(j===u){const v=(s[x.id]??"").trim();return v?[v]:[]}const y=j.trim();return y?[y]:[]}function w(x,j){o(y=>{const v=y[x],k=Array.isArray(v)?v:[],S=k.includes(j)?k.filter(N=>N!==j):[...k,j];return{...y,[x]:S}})}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((j,y)=>{const v=f(j.label),k=v.displayLabel.toLowerCase()==="implement";return t.jsxs("button",{type:"button",disabled:r,onClick:()=>p(j.label),className:`relative rounded-2xl border px-2.5 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${y===0?"ui-action-info":"border-stone-700 text-stone-200 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:j.description,children:[v.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===j.label?k?"Starting...":"Saving...":v.displayLabel]},j.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(j=>{const y=f(j.label),v=a[x.id];return t.jsxs("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?w(x.id,j.label):o(k=>({...k,[x.id]:j.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(v)&&v.includes(j.label):v===j.label)?"ui-status-warning":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:j.description,children:[y.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,y.displayLabel]},j.label)}),x.isOther&&(()=>{const j=a[x.id];return t.jsx("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?w(x.id,u):o(y=>({...y,[x.id]:u})),className:`rounded-2xl border px-3 py-1.5 text-[12px] leading-4 transition sm:text-[13px] ${(x.multiSelect?Array.isArray(j)&&j.includes(u):j===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 j=a[x.id];return(x.multiSelect?Array.isArray(j)&&j.includes(u):j===u)?t.jsx("input",{"aria-label":`${x.header} custom answer`,value:s[x.id]??"",onChange:v=>l(k=>({...k,[x.id]:v.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:j=>o(y=>({...y,[x.id]:j.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 bl({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 vl({note:e,onOpenThread:r,onOpenLinkedThread:n}){const a=e.kind==="forkCreated"?"Fork":e.kind==="forkSource"?"Fork source":"System",o=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:Wt(e.createdAt),className:"timeline-meta-text text-[10px]",children:vt(e.createdAt)})]}),t.jsx("p",{className:"timeline-primary-text mt-1 text-[13px] leading-5",children:o}),e.linkedThreadId?t.jsx("button",{type:"button",onClick:()=>{const s=e.linkedThreadId;s&&(n==null||n(s),r==null||r(s))},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 pr({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(vl,{note:a,onOpenThread:r,onOpenLinkedThread:n},a.id))})}function Xn({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(bl,{note:a.note},a.id):t.jsx(xl,{request:a.request,busy:r===a.request.id,onRespond:n},a.id))})}function rf({notes:e,requests:r,respondingRequestId:n,onRespondToRequest:a}){const o=[...e.map(s=>({kind:"note",id:s.id,createdAt:s.createdAt??"",note:s})),...r.map(s=>({kind:"request",id:s.id,createdAt:s.createdAt,request:s}))].sort((s,l)=>s.createdAt.localeCompare(l.createdAt));return t.jsx(Xn,{entries:o,respondingRequestId:n,onRespondToRequest:a})}function nf({entries:e,respondingRequestId:r,onRespondToRequest:n,onOpenThread:a,onOpenLinkedThread:o}){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((s,l)=>s.createdAt.localeCompare(l.createdAt)).map(s=>s.kind==="activity"?t.jsx(vl,{note:s.note,onOpenThread:a,onOpenLinkedThread:o},s.id):s.kind==="note"?t.jsx(bl,{note:s.note},s.id):t.jsx(xl,{request:s.request,busy:r===s.request.id,onRespond:n},s.id))})}function af({entries:e,expandedGroups:r,onToggleGroupedItem:n,renderCommandGroup:a,renderFileChangeGroup:o,renderFileReadGroup:s,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"?o(d,h,u):d.kind==="searchGroup"?i(d,h,u):d.kind==="fileReadGroup"?s(d,h,u):l(d)})})}function sn({children:e,className:r,count:n,countBadgeClassName:a,desktopIconClassName:o,expanded:s,expandedListClassName:l,icon:i,onToggleExpanded:d,runningIndicator:h,summary:u,timeMeta:m,toggleAriaLabel:f,trailingSummary:p}){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 ${o}`,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":s,"aria-label":f,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}),p||m?t.jsxs("div",{className:"inline-flex shrink-0 items-center gap-2",children:[p,m]}):null]}),s?t.jsx("div",{className:`thread-graph-history-group-list mt-3 space-y-2 border-t pt-3 ${l}`,children:e}):null]})]})})}Lr();Pt();var sf=Cr("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 on({asChild:e=!1,className:r,variant:n,...a}){const o=e?Gs:"span";return t.jsx(o,{"data-slot":"badge",className:at(sf({variant:n,className:r})),...a})}function ha(e){if(!e)return!1;const r=e.trim().toLowerCase();return r==="running"||r==="in_progress"||r==="in progress"||r==="pending"}function of(){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 lf(){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 df(){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 cf(){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 hf(e){const r=e.trim();if(!r)return"";const n=r.match(/(, \+\d+ more.*)$/),a=(n==null?void 0:n[1])??"",s=(a?r.slice(0,-a.length):r).replace(/\\/g,"/");if(!s.startsWith("/"))return`${s.replace(/^\.\//,"")}${a}`;const l=["/apps/","/packages/","/src/","/test/","/tests/","/docs/","/config/","/scripts/","/e2e/","/.agents/","/.codex/"];for(const i of l){const d=s.indexOf(i);if(d>=0)return`${s.slice(d+1)}${a}`}return r}function kl(e,r=42){const n=hf(e);if(!n)return"";const a=n.match(/(, \+\d+ more.*)$/),o=(a==null?void 0:a[1])??"",s=o?n.slice(0,-o.length):n;if(s.length<=r)return`${s}${o}`;const i=s.replace(/\\/g,"/").split("/").filter(Boolean);if(i.length>1){const d=[];let h=o.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("/")}${o}`}return`...${s.slice(-(r-o.length-3))}${o}`}function uf(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(o=>o.trim()).filter(Boolean):[]}function Yn({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 mf(e){var n;const r=e.replace(/\r\n/g,`
3698
+ `),w=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 j(){d==null||d(),f(N=>!N)}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:h==="copied"?t.jsx($.Check,{className:"h-3.5 w-3.5"}):t.jsx($.Copy,{className:"h-3.5 w-3.5"})}):null,b=g.some(N=>Kp(N.status)),v=n.kind==="agentMessage"&&k?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:j,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($.Brain,{className:`h-3.5 w-3.5 ${b?"animate-pulse":""}`}),t.jsx("span",{children:"CoT"}),b?t.jsx(Xp,{tone:"sky"}):null]}):null,S=n.kind==="agentMessage"&&k?t.jsx("div",{className:"thread-graph-message-thinking mb-3",children:t.jsx(Lr,{type:"single",collapsible:!0,className:"thread-graph-thinking-accordion w-full border-none",onValueChange:N=>f(!!N),...m?{value:"thoughts"}:{},children:t.jsx(Ir,{value:"thoughts",className:"border-b-0",children:t.jsx(zr,{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(ir,{text:k})})})})})}):null;return t.jsx(qp,{kind:n.kind,status:w||n.kind==="agentMessage"?n.status:null,copyButton:y,metaControl:v,reasoning:S,timeLabel:l,timeTitle:i,children:n.kind==="agentMessage"?t.jsx(Wp,{text:n.text,scrollRootRef:a,streaming:s,...d?{onBeforeResize:d}:{},...o!=null&&o.onOpenWorkspaceFile?{onOpenWorkspaceFile:o.onOpenWorkspaceFile}:{}}):t.jsx(Up,{threadId:r,text:n.text,attachmentPreviewUrls:n.attachmentPreviewUrls,getImageAssetUrl:o==null?void 0:o.getImageAssetUrl})})});function Yp(e){return!!(e&&typeof e.id=="string"&&typeof e.kind=="string")}function dr(e){return e.filter(Yp)}function Ts(e){return e.replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&")}function gl(e){const r=e.trim().match(/^<hook_prompt(?:\s+hook_run_id="([^"]+)")?>([\s\S]*)<\/hook_prompt>$/);if(!r)return null;const n=r[1]?Ts(r[1]):null,a=Ts(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 Zp(e){return e==="userMessage"||e==="agentMessage"}function Jp(e){return e==="commandExecution"||e==="webSearch"||e==="fileRead"||e==="fileChange"||e==="image"||e==="contextCompaction"}function Qp(e){return e==="agentMessage"||e==="reasoning"||e==="agentToolCall"||e==="skillToolCall"||e==="toolCall"||e==="plan"}function ef(e,r){const n=dr(e);if(!r)return n;const a=[...n],s=a.findIndex(l=>l.kind==="userMessage");if(s<0)return a;for(let l=s+1;l<a.length;l+=1){const i=a[l];if(!i||i.kind!=="userMessage")continue;let d=l+1;for(;d<a.length&&Jp(a[d].kind);)d+=1;if(d===l+1)continue;const[h]=a.splice(l,1);a.splice(d-1,0,h),l=d-1}let o=!1;return a.map((l,i)=>l.kind!=="userMessage"?l:o?a.slice(i+1).some(h=>Qp(h.kind))?l:{...l,status:"Awaiting response"}:(o=!0,l))}function Tt(e){return typeof e.sequence=="number"&&Number.isFinite(e.sequence)}function Dr(e){return Tt(e)?e.sequence:Number.POSITIVE_INFINITY}function Es(e){var u;const r=dr(e),n=[];let a=0;for(;a<r.length&&((u=r[a])==null?void 0:u.kind)==="userMessage"&&!Tt(r[a]);)n.push(r[a]),a+=1;const s=r.slice(a);if(!s.some(Tt))return r;const o=s.map(m=>Dr(m)).filter(Number.isFinite),l=o.length>0?Math.max(...o):0,i=[];let d=0;for(;d<s.length;){const m=s[d];if(Tt(m)){i.push({item:m,index:d,order:Dr(m)}),d+=1;continue}const f=d;for(;d<s.length&&!Tt(s[d]);)d+=1;const p=s.slice(f,d),g=[...s.slice(0,f)].reverse().find(Tt),k=s.slice(d).find(Tt),w=g?Dr(g):null,x=k?Dr(k):null;p.forEach((j,y)=>{let b;if(w===null&&x!==null)b=x-(p.length-y)/(p.length+1);else if(w!==null&&x!==null&&x>w){const v=x-w;b=w+(y+1)/(p.length+1)*v}else b=l+1+y/(p.length+1);i.push({item:j,index:f+y,order:b})})}const h=i.sort((m,f)=>{const p=m.order-f.order;return p===0?m.index-f.index:p}).map(m=>m.item);return[...n,...h]}function tf(e,r){const n=dr(e),a=dr(r??[]);if(a.length===0)return Es(n);const s=new Map(a.map(i=>[i.id,i])),o=n.map(i=>{const d=s.get(i.id);if(!d)return i;s.delete(i.id);const h={...i,...d,text:d.text||i.text},u=d.detailText??i.detailText,m=d.previewText??i.previewText,f=d.status??i.status,p=d.sequence??i.sequence;return u!==void 0&&(h.detailText=u),m!==void 0&&(h.previewText=m),f!==void 0&&(h.status=f),p!==void 0&&(h.sequence=p),h}),l=[...s.values()];return l.length===0&&!o.some(Tt)||(o.push(...l),!o.some(i=>typeof i.sequence=="number"&&Number.isFinite(i.sequence)))?o:Es(o)}function rf(e,r){if(!e)return"";const n=dr(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 ma(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function yr(e){return e==="inProgress"||e==="sending"}function nf(e){return lf(af(dr(e)))}function af(e){var a;const r=[];let n=0;for(;n<e.length;){const s=e[n];if(!s)break;if(s.kind!=="commandExecution"&&s.kind!=="fileChange"&&s.kind!=="webSearch"&&s.kind!=="fileRead"&&s.kind!=="toolCall"&&s.kind!=="agentToolCall"&&s.kind!=="skillToolCall"){r.push({kind:"item",key:s.id,item:s}),n+=1;continue}const o=[];for(;n<e.length&&((a=e[n])==null?void 0:a.kind)===s.kind;)o.push(e[n]),n+=1;if(o.length===1){r.push({kind:"item",key:o[0].id,item:o[0]});continue}const l=o.map(i=>i.id).join(":");if(s.kind==="commandExecution"){r.push({kind:"commandGroup",key:l,items:o});continue}if(s.kind==="fileChange"){r.push({kind:"fileChangeGroup",key:l,items:o});continue}if(s.kind==="fileRead"){r.push({kind:"fileReadGroup",key:l,items:o});continue}if(s.kind==="toolCall"){r.push({kind:"toolCallGroup",key:l,items:o});continue}if(s.kind==="agentToolCall"){r.push({kind:"agentToolCallGroup",key:l,items:o});continue}if(s.kind==="skillToolCall"){r.push({kind:"skillToolCallGroup",key:l,items:o});continue}r.push({kind:"searchGroup",key:l,items:o})}return r}function Ls(e){return e.kind!=="item"?e.kind!=="agentActivityGroup":e.item.kind==="commandExecution"||e.item.kind==="fileChange"||e.item.kind==="webSearch"||e.item.kind==="fileRead"||e.item.kind==="toolCall"||e.item.kind==="agentToolCall"||e.item.kind==="skillToolCall"}function sf(e){return(e==null?void 0:e.kind)==="item"&&e.item.kind==="agentMessage"&&e.item.text.trim().length>0&&!ma(e.item.status)}function of(e){return e.kind==="item"?1:e.kind==="agentActivityGroup"?e.itemCount:e.items.length}function lf(e){const r=[];let n=0;for(;n<e.length;){if(!Ls(e[n])){r.push(e[n]),n+=1;continue}const a=n;for(;n<e.length&&Ls(e[n]);)n+=1;const s=e.slice(a,n),o=s.reduce((l,i)=>l+of(i),0);if(o>1&&sf(e[n])){r.push({kind:"agentActivityGroup",key:`agent-activity:${s.map(l=>l.key).join(":")}`,entries:s,itemCount:o});continue}r.push(...s)}return r}function xl(e,r){return[...e.map(n=>({id:n.id,startedAt:n.startedAt??""})),...r?[{id:r.id,startedAt:r.startedAt??""}]:[]]}function jr(e,r,n){const a=e.get(r)??[];a.push(n),e.set(r,a)}function bl(e,r){return e.find(n=>r&&n.startedAt&&r.localeCompare(n.startedAt)<=0)}function df({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)?jr(o,p.turnId,p):i.push(p);for(const p of r)p.turnId&&s.has(p.turnId)?jr(l,p.turnId,p):d.push(p);const h=xl(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=bl(h,p.createdAt);if(!g){m.push(p);continue}jr(u,g.id,p)}return{notesByTurnId:o,pendingRequestsByTurnId:l,beforeTurnId:u,trailing:m}}function cf({activityNotes:e,visibleTurns:r,optimisticTurn:n}){const a=[...e].sort((m,f)=>m.createdAt.localeCompare(f.createdAt)),s=xl(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)?jr(i,m.anchorTurnId,m):o.push(m);continue}const f=bl(s,m.createdAt);if(!f){!u||m.createdAt.localeCompare(u)<=0?o.push(m):d.push(m);continue}jr(l,f.id,m)}return{leading:o,beforeTurnId:l,afterTurnId:i,trailing:d}}function vl({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 j=/\s*\(recommended\)\s*$/i.test(x);return{rawLabel:x,displayLabel:x.replace(/\s*\(recommended\)\s*$/i,"").trim(),recommended:j}}function p(x){h&&(d(x),n==null||n(e.id,{answers:{[h.id]:{answers:[x]}}}))}function g(x){const j=a[x.id]??"";return Array.isArray(j)?j.map(y=>y===u?(o[x.id]??"").trim():y.trim()).filter(Boolean).join(", "):j===u?(o[x.id]??"").trim():j.trim()}function k(x){const j=a[x.id]??"";if(Array.isArray(j))return j.map(b=>b===u?(o[x.id]??"").trim():b.trim()).filter(Boolean);if(j===u){const b=(o[x.id]??"").trim();return b?[b]:[]}const y=j.trim();return y?[y]:[]}function w(x,j){s(y=>{const b=y[x],v=Array.isArray(b)?b:[],S=v.includes(j)?v.filter(N=>N!==j):[...v,j];return{...y,[x]:S}})}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((j,y)=>{const b=f(j.label),v=b.displayLabel.toLowerCase()==="implement";return t.jsxs("button",{type:"button",disabled:r,onClick:()=>p(j.label),className:`relative rounded-2xl border px-2.5 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${y===0?"ui-action-info":"border-stone-700 text-stone-200 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:j.description,children:[b.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===j.label?v?"Starting...":"Saving...":b.displayLabel]},j.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(j=>{const y=f(j.label),b=a[x.id];return t.jsxs("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?w(x.id,j.label):s(v=>({...v,[x.id]:j.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(b)&&b.includes(j.label):b===j.label)?"ui-status-warning":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:j.description,children:[y.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,y.displayLabel]},j.label)}),x.isOther&&(()=>{const j=a[x.id];return t.jsx("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?w(x.id,u):s(y=>({...y,[x.id]:u})),className:`rounded-2xl border px-3 py-1.5 text-[12px] leading-4 transition sm:text-[13px] ${(x.multiSelect?Array.isArray(j)&&j.includes(u):j===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 j=a[x.id];return(x.multiSelect?Array.isArray(j)&&j.includes(u):j===u)?t.jsx("input",{"aria-label":`${x.header} custom answer`,value:o[x.id]??"",onChange:b=>l(v=>({...v,[x.id]:b.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:j=>s(y=>({...y,[x.id]:j.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:k(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 kl({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 wl({note:e,onOpenThread:r,onOpenLinkedThread:n}){const a=e.kind==="forkCreated"?"Fork":e.kind==="forkSource"?"Fork source":e.kind==="goal"?"Goal":"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:Ut(e.createdAt),className:"timeline-meta-text text-[10px]",children:kt(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 xr({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(wl,{note:a,onOpenThread:r,onOpenLinkedThread:n},a.id))})}function Jn({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(kl,{note:a.note},a.id):t.jsx(vl,{request:a.request,busy:r===a.request.id,onRespond:n},a.id))})}function hf({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(Jn,{entries:s,respondingRequestId:n,onRespondToRequest:a})}function uf({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(wl,{note:o.note,onOpenThread:a,onOpenLinkedThread:s},o.id):o.kind==="note"?t.jsx(kl,{note:o.note},o.id):t.jsx(vl,{request:o.request,busy:r===o.request.id,onRespond:n},o.id))})}function mf({entries:e,expandedGroups:r,onToggleGroupedItem:n,renderCommandGroup:a,renderFileChangeGroup:s,renderFileReadGroup:o,renderItem:l,renderSearchGroup:i,renderToolCallGroup:d,renderAgentActivityGroup:h}){return t.jsx(t.Fragment,{children:e.map(u=>{const m=r[u.key]??!1,f=()=>n(u.key);return u.kind==="commandGroup"?a(u,m,f):u.kind==="fileChangeGroup"?s(u,m,f):u.kind==="searchGroup"?i(u,m,f):u.kind==="fileReadGroup"?o(u,m,f):u.kind==="toolCallGroup"||u.kind==="agentToolCallGroup"||u.kind==="skillToolCallGroup"?d(u,m,f):u.kind==="agentActivityGroup"?h(u,m,f):l(u)})})}function hr({children:e,className:r,count:n,countBadgeClassName:a,desktopIconClassName:s,expanded:o,expandedListClassName:l,icon:i,onToggleExpanded:d,runningIndicator:h,summary:u,timeMeta:m,toggleAriaLabel:f,trailingSummary:p}){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":f,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}),p||m?t.jsxs("div",{className:"inline-flex shrink-0 items-center gap-2",children:[p,m]}):null]}),o?t.jsx("div",{className:`thread-graph-history-group-list mt-3 space-y-2 border-t pt-3 ${l}`,children:e}):null]})]})})}Pr();Pt();var pf=Er("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 dn({asChild:e=!1,className:r,variant:n,...a}){const s=e?Os:"span";return t.jsx(s,{"data-slot":"badge",className:at(pf({variant:n,className:r})),...a})}function cn(e){if(!e)return!1;const r=e.trim().toLowerCase();return r==="running"||r==="in_progress"||r==="in progress"||r==="pending"}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.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 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.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 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.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 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.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 vf(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 yl(e,r=42){const n=vf(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 kf(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 Jr({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 wf(e){var n;const r=e.replace(/\r\n/g,`
3697
3699
  `).split(`
3698
- `);for(;r.length>1&&((n=r.at(-1))==null?void 0:n.trim())==="";)r.pop();return r}function kt(e){const r=mf(e);return r.length===1?{firstLine:r[0]??"",showGap:!1,isTruncated:!1}:{firstLine:r[0]??"",showGap:!0,isTruncated:!0}}function wl(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(_.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"}:r==="failed"||r==="failure"||r==="error"||r==="errored"?{className:"is-failed",icon:t.jsx(_.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"}:ha(e)?{className:"is-pending",icon:t.jsx(_.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 pf(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 ff(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 qt({actions:e,children:r,className:n,headerMeta:a,icon:o,item:s,timeMeta:l,title:i,tone:d}){const h=wl(s.status);return t.jsxs("div",{className:`thread-graph-event thread-graph-history-event ${ff(d)} ${n??""}`,children:[t.jsx("div",{className:"thread-graph-history-event-icon","aria-hidden":"true",children:o}),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:i}),s.status?t.jsxs(on,{variant:"outline",className:`thread-graph-tool-badge ${h.className} rounded-full px-2 py-0.5 text-xs font-normal`,title:h.label,"aria-label":`Status: ${h.label}`,children:[h.icon,t.jsx("span",{className:"thread-graph-status-label",children:h.label})]}):null,a]}),e||l?t.jsxs("div",{className:"thread-graph-history-event-actions",children:[e,l]}):null]}),r?t.jsx("div",{className:"thread-graph-history-event-body",children:r}):null]})]})}function dr({actionLabel:e="Open details",actionTitle:r,autoOpen:n=!1,className:a,details:o,icon:s,item:l,onOpen:i,preview:d,timeMeta:h,title:u,tone:m}){const f=wl(l.status),[p,g]=c.useState(n?"item-1":void 0),b=c.useRef(n);return c.useLayoutEffect(()=>{n?g("item-1"):b.current&&g(void 0),b.current=n},[n,l.id]),t.jsx("div",{className:`thread-graph-event thread-graph-history-tool ${pf(m)} ${a??""}`,children:t.jsx(Sr,{type:"single",collapsible:!0,onValueChange:w=>{g(w||void 0)},className:"thread-graph-tool-accordion thread-graph-history-tool-accordion w-full overflow-hidden rounded-lg border",value:p??"",children:t.jsxs(Tr,{value:"item-1",className:"border-0",children:[t.jsxs(nn,{"aria-label":`${p==="item-1"?"Collapse":"Expand"} ${u} 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:u}),t.jsxs(on,{variant:"outline",className:`thread-graph-tool-badge ${f.className} ml-1 sm:ml-2 rounded-full px-2 py-0.5 text-xs font-normal`,title:f.label,"aria-label":`Status: ${f.label}`,children:[f.icon,t.jsx("span",{className:"thread-graph-status-label",children:f.label})]})]}),h?t.jsx("span",{className:"thread-graph-history-tool-time shrink-0",children:h}):null]}),t.jsxs(Er,{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(lr,{text:d.firstLine}),d.showGap?t.jsx("span",{className:"thread-graph-history-tool-ellipsis",children:"..."}):null]})]}),o?t.jsx("section",{children:o}):null,t.jsxs("button",{type:"button","aria-label":e,onClick:i,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(_.ExternalLink,{className:"h-3.5 w-3.5"}),r]})]})]})})})}var gf=c.memo(function({item:r,scrollRootRef:n,onBeforeResize:a,timeMeta:o}){return t.jsx(qt,{className:"thread-graph-event-plan",icon:t.jsx(_.ClipboardList,{className:"h-4 w-4"}),item:r,timeMeta:o,title:"plan",tone:"plan",children:t.jsx("div",{className:"thread-graph-history-event-prose",children:t.jsx(ul,{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}:{}})})})}),xf=c.memo(function({item:r,timeMeta:n}){const a=ha(r.status)||r.text==="Compacting context",o=a?"Compacting context":"Context compacted",s=r.detailText&&r.detailText!==o?r.detailText:null;return t.jsxs(qt,{className:"thread-graph-event-context",icon:t.jsx(_.Archive,{className:"h-4 w-4"}),item:r,timeMeta:n,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:o}),a?t.jsx(Yn,{tone:"emerald"}):null]}),s?t.jsx("p",{className:"thread-graph-history-event-secondary",title:s,children:s}):null]})}),bf=c.memo(function({item:r,timeMeta:n}){return t.jsx(qt,{className:"thread-graph-event-generic",icon:t.jsx(_.Info,{className:"h-4 w-4"}),item:r,timeMeta:n,title:r.kind,tone:"generic",children:t.jsx("pre",{className:"thread-graph-history-event-pre",children:t.jsx(lr,{text:r.text})})})}),vf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=kt(n.previewText??n.text);return t.jsx(dr,{actionLabel:"Open full command",actionTitle:"Command Output",autoOpen:r,className:"thread-graph-event-command",icon:t.jsx(_.Terminal,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Command Output"),preview:s,timeMeta:o,title:"command",tone:"command"})}),kf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=kt(n.text);return t.jsx(dr,{actionLabel:"Open full tool call",actionTitle:"Tool Call Details",autoOpen:r,className:"thread-graph-event-tool",icon:t.jsx(_.Wrench,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Tool Call Details"),preview:s,timeMeta:o,title:"tool_call",tone:"tool"})}),wf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=kt(n.text);return t.jsx(dr,{actionLabel:"Open agent details",actionTitle:"Agent Details",autoOpen:r,className:"thread-graph-event-agent-tool",icon:t.jsx(_.Bot,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Agent Details"),preview:s,timeMeta:o,title:"agent",tone:"agent"})}),yf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=kt(n.text);return t.jsx(dr,{actionLabel:"Open skill details",actionTitle:"Skill Details",autoOpen:r,className:"thread-graph-event-skill-tool",icon:t.jsx(_.Sparkles,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Skill Details"),preview:s,timeMeta:o,title:"skill",tone:"skill"})}),jf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){var d,h;const s=((d=n.previewText)==null?void 0:d.trim())||n.text||"Web search",l=((h=n.detailText)==null?void 0:h.trim())||n.text||"Web search",i=kt(s);return t.jsx(dr,{actionLabel:"Open full web search",actionTitle:"Web Search Details",autoOpen:r,className:"thread-graph-event-search",icon:t.jsx(_.Search,{className:"h-4 w-4"}),item:n,onOpen:()=>a("Web Search Details",l),preview:i,timeMeta:o,title:"web_search",tone:"search"})}),Nf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){var d,h;const s=((d=n.previewText)==null?void 0:d.trim())||n.text||"File read",l=((h=n.detailText)==null?void 0:h.trim())||n.text||"File read",i=kt(s);return t.jsx(dr,{actionLabel:"Open full file read",actionTitle:"File Read Details",autoOpen:r,className:"thread-graph-event-file-read",icon:t.jsx(_.FileText,{className:"h-4 w-4"}),item:n,onOpen:()=>a("File Read Details",l),preview:i,timeMeta:o,title:"file_read",tone:"fileRead"})}),Cf=c.memo(function({threadId:r,item:n,onOpen:a,getImageAssetUrl:o,timeMeta:s}){const l=n.assetPath??n.detailText??null,i=r&&l?(o==null?void 0:o({threadId:r,path:l}))??null:null;return t.jsxs(qt,{className:"thread-graph-event-image",icon:t.jsx(_.Image,{className:"h-4 w-4"}),item:n,timeMeta:s,title:"image",tone:"image",children:[i?t.jsx("button",{type:"button",onClick:()=>a("Image Path",l??n.text),className:"block w-full text-left",children:t.jsx("img",{src:i,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}),l?t.jsx("button",{type:"button",onClick:()=>a("Image Path",l),className:"thread-graph-history-event-path",title:l,children:l}):null]})}),Sf=c.memo(function({item:r,onOpen:n,timeMeta:a}){var m,f,p;const o=(m=r.previewText)!=null&&m.trim()&&r.text.trim()!==r.previewText.trim()?r.text.trim():null,s=((f=r.detailText)==null?void 0:f.trim())||null,l=kl(o??((p=r.previewText)==null?void 0:p.trim())??r.text,48),i=uf(r),d=!!(s||r.hasDeferredDetail),h=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:o??l,children:l}),i.length>0&&t.jsx("div",{className:"inline-flex shrink-0 items-center justify-end gap-1.5 text-xs",children:i.map(g=>t.jsx("span",{className:`thread-graph-history-delta-badge ${g.startsWith("+")?"is-add":g.startsWith("-")?"is-remove":"is-neutral"}`,children:g},g))})]}),u=d?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:o??l,children:h}):h;return t.jsx(qt,{className:"thread-graph-event-file-change",headerMeta:u,icon:t.jsx(_.FilePenLine,{className:"h-4 w-4"}),item:r,timeMeta:a,title:"file_change",tone:"fileChange"})}),Tf=c.memo(function({item:r,onSelect:n,timeMeta:a}){const o=ca(),[s,l]=c.useState(!1),i=r.artifact,d=i?o.renderArtifact({artifact:i,expanded:s,onToggleExpanded:()=>l(h=>!h)}):null;return t.jsx(qt,{actions:t.jsxs("span",{className:"inline-flex items-center gap-2",children:[i&&!o.hasRendererForArtifact(i)?t.jsx("span",{className:"thread-graph-history-event-secondary",children:"No renderer"}):null,i&&n?t.jsxs("button",{type:"button","aria-label":`Open artifact inspector for ${i.title}`,onClick:()=>n(r,i),className:"thread-graph-history-event-action",children:[t.jsx(_.PackageOpen,{className:"h-3.5 w-3.5"}),"Inspect"]}):null]}),className:"thread-graph-event-artifact",icon:t.jsx(_.PackageOpen,{className:"h-4 w-4"}),item:r,timeMeta:a,title:(i==null?void 0:i.type)??"artifact",tone:"artifact",children:d??t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:()=>l(h=>!h),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:(i==null?void 0:i.title)??r.text}),t.jsx("span",{className:"thread-graph-history-event-secondary mt-1 block truncate",children:(i==null?void 0:i.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((i==null?void 0:i.payload)??r,null,2)}):null]})})}),Ef=c.memo(function({item:r,timeMeta:n}){var h,u;const a=((h=r.hookOutputEntries)==null?void 0:h.map(m=>m.text.trim()).filter(Boolean).join(`
3699
- `).trim())??"",o=r.hookEventLabel?`${r.hookEventLabel} hook`:r.text,s=((u=r.hookStatusMessage)==null?void 0:u.trim())||(r.previewText&&r.previewText!==r.hookStatusMessage?r.previewText.trim():"")||r.text.trim(),i=kt(a||(s&&s!==o?s:o)),d=!!(a&&i.showGap);return t.jsx(qt,{className:"thread-graph-event-hook",icon:t.jsx(_.Webhook,{className:"h-4 w-4"}),item:r,timeMeta:n,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:a?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"thread-graph-history-event-secondary mr-2 font-sans text-[11px] uppercase",children:o}),t.jsx(lr,{text:i.firstLine})]}):t.jsx(lr,{text:i.firstLine&&i.firstLine!==o?`${o} · ${i.firstLine}`:o})}),d?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})})}),Lf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o,timeMeta:s}){const l=r.filter(d=>ha(d.status)).length,i=r.length===1?"1 command":`${r.length} commands`;return t.jsx(sn,{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(df,{}),onToggleExpanded:a,runningIndicator:l>0?t.jsx(Yn,{}):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:i}),l>0?t.jsx("span",{className:"inline-flex items-center text-xs text-amber-100/90",children:t.jsx(Yn,{})}):null]}),timeMeta:s,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} command entries`,children:r.map((d,h)=>{const u=kt(d.text);return t.jsxs("button",{type:"button","aria-label":`Open grouped command ${h+1}`,onClick:()=>o(d,`Command Output ${h+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 ",h+1]}),d.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:d.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:u.firstLine}),u.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},d.id)})})}),If=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o,timeMeta:s}){const l=r.length===1?"1 search":`${r.length} searches`;return t.jsx(sn,{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(cf,{}),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:l})]}),timeMeta:s,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} web search entries`,children:r.map((i,d)=>{var f,p;const h=((f=i.previewText)==null?void 0:f.trim())||i.text||"Web search",u=kt(h),m=((p=i.detailText)==null?void 0:p.trim())||i.text||"Web search";return t.jsxs("button",{type:"button","aria-label":`Open grouped web search ${d+1}`,onClick:()=>o(`Web Search ${d+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 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 ",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:u.firstLine}),u.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},i.id)})})}),zf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o,timeMeta:s}){const l=r.length===1?"1 file read":`${r.length} file reads`;return t.jsx(sn,{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(lf,{}),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:l})]}),timeMeta:s,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} file read entries`,children:r.map((i,d)=>{var f,p;const h=((f=i.previewText)==null?void 0:f.trim())||i.text||"File read",u=kt(h),m=((p=i.detailText)==null?void 0:p.trim())||i.text||"File read";return t.jsxs("button",{type:"button","aria-label":`Open grouped file read ${d+1}`,onClick:()=>o(`File Read ${d+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 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 ",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:u.firstLine}),u.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},i.id)})})}),Pf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o,timeMeta:s}){const l=r.reduce((u,m)=>u+(m.changedFiles??0),0),i=r.reduce((u,m)=>u+(m.addedLines??0),0),d=r.reduce((u,m)=>u+(m.removedLines??0),0),h=r.length===1?"1 file change":`${r.length} file changes`;return t.jsx(sn,{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(of,{}),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:h}),l>0?t.jsxs("span",{className:"thread-graph-history-detail-meta text-xs",children:[l," files"]}):null]}),timeMeta:s,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} file change entries`,trailingSummary:t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[i>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-add",children:["+",i]}):null,d>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-remove",children:["-",d]}):null]}),children:r.map((u,m)=>{var g,b,w,x;const f=((g=u.detailText)==null?void 0:g.trim())||((b=u.previewText)==null?void 0:b.trim())||u.text,p=(w=u.previewText)!=null&&w.trim()&&u.text.trim()!==u.previewText.trim()?u.text.trim():((x=u.previewText)==null?void 0:x.trim())||u.text;return t.jsx("button",{type:"button","aria-label":`Open grouped file change ${m+1}`,onClick:()=>o(`File Change ${m+1}`,f),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:p,children:kl(p,34)}),t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[(u.addedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-add",children:["+",u.addedLines]}):null,(u.removedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-remove",children:["-",u.removedLines]}):null]})]})},u.id)})})});function Rf(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 Mf({status:e}){const r=Rf(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(on,{"aria-label":n,title:n.replace("Plan step status: ",""),className:a,children:r==="completed"?t.jsx(_.CheckCircle2,{className:"h-3.5 w-3.5"}):r==="in_progress"?t.jsx(_.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):r==="pending"?t.jsx(_.Clock3,{className:"h-3.5 w-3.5"}):r==="failed"?t.jsx(_.XCircle,{className:"h-3.5 w-3.5"}):t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.14em]",children:"?"})})}function Af({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(on,{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(Mf,{status:r.status})]},`${e.turnId}-${n}`))})]})}function _f({footer:e,history:r,liveHookPrompt:n,liveOutput:a,livePlan:o}){return t.jsxs(t.Fragment,{children:[r,o?t.jsx(Af,{livePlan:o}):null,n??a??null,e]})}function $f({absoluteIndex:e,body:r,collapsed:n,collapsedBody:a,error:o,footer:s,headerStatus:l,isActive:i=!1,refCallback:d,startedAt:h,timeLabel:u,timeTitle:m,tokenSummary:f}){return t.jsxs("article",{ref:d,"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.jsx("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:h??void 0,title:m,className:"thread-graph-turn-time shrink-0 text-[10px] sm:text-[11px]",children:u}),l,o?t.jsx("p",{className:"hidden truncate text-[11px] text-rose-200 sm:block",children:o}):null]}),f]})}),o?t.jsx("p",{className:"mt-1 text-[11px] text-rose-200 sm:hidden",children:o}):null,t.jsxs("div",{className:"thread-graph-turn-body mt-2 space-y-2",children:[n?a:r,n?null:s]})]})}function Df(){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 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.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 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.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 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.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 fr(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 yl(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 nr(e){return!Number.isFinite(e)||e<=0?"$0.0000":`$${e.toFixed(4)}`}function _r(e,r,n){const a=e??null;return!Number.isFinite(a??NaN)||a===null||r<=0||n<=0?null:a*n/r}function jl(e){var d,h,u,m,f,p;const r=(d=e.tokenUsage)==null?void 0:d.total;if(!r)return[];const n=Math.max(r.inputTokens-r.cachedInputTokens-(r.cacheWriteInputTokens??0),0),a=Math.max(r.cachedInputTokens,0),o=Math.max(r.cacheWriteInputTokens??0,0),s=Math.max(r.reasoningOutputTokens,0),l=Math.max(r.outputTokens-s,0);return[n>0?{id:"in",label:"Input",tokenCompactValue:fr(n),tokenRawValue:n,usdCompactValue:e.priceEstimate?nr(e.priceEstimate.inputUsd):"--",usdRawValue:((h=e.priceEstimate)==null?void 0:h.inputUsd)??null,className:"token-badge-in",icon:t.jsx(Df,{})}:null,a>0?{id:"cache",label:"Cached input",tokenCompactValue:fr(a),tokenRawValue:a,usdCompactValue:e.priceEstimate?nr(e.priceEstimate.cachedInputUsd):"--",usdRawValue:((u=e.priceEstimate)==null?void 0:u.cachedInputUsd)??null,className:"token-badge-cache",icon:t.jsx(Ts,{})}:null,o>0?{id:"cache-write",label:"Cache write",tokenCompactValue:fr(o),tokenRawValue:o,usdCompactValue:e.priceEstimate?nr(e.priceEstimate.cacheWriteInputUsd??0):"--",usdRawValue:((m=e.priceEstimate)==null?void 0:m.cacheWriteInputUsd)??null,className:"token-badge-cache",icon:t.jsx(Ts,{})}:null,l>0?{id:"out",label:"Output",tokenCompactValue:fr(l),tokenRawValue:l,usdCompactValue:e.priceEstimate?nr(_r(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),l)??0):"--",usdRawValue:_r((f=e.priceEstimate)==null?void 0:f.outputUsd,Math.max(r.outputTokens,0),l),className:"token-badge-out",icon:t.jsx(Bf,{})}:null,s>0?{id:"reason",label:"Reasoning",tokenCompactValue:fr(s),tokenRawValue:s,usdCompactValue:e.priceEstimate?nr(_r(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),s)??0):"--",usdRawValue:_r((p=e.priceEstimate)==null?void 0:p.outputUsd,Math.max(r.outputTokens,0),s),className:"token-badge-reason",icon:t.jsx(Gf,{})}:null].filter(g=>g!==null)}function Ff(e){return jl(e).map(r=>({id:r.id,label:r.tokenCompactValue,title:`${r.label}: ${r.tokenRawValue} tokens`,className:r.className,icon:r.icon}))}function Nl(e){return{label:e.priceEstimate?yl(e.priceEstimate.totalUsd):"--",title:e.priceEstimate===null||e.priceEstimate===void 0?"Price estimate unavailable for this model.":`Estimated cost: ${nr(e.priceEstimate.totalUsd)}`,className:e.priceEstimate?"token-badge-total":"token-badge-empty"}}var Sn="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 Hf({turn:e}){const r=jl(e),n=Nl(e),[a,o]=c.useState(!1),[s,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 w=g.getBoundingClientRect(),x=b.offsetWidth||b.getBoundingClientRect().width;if(x<=0)return;const j=window.innerWidth||document.documentElement.clientWidth,y=12,v=w.left+w.width/2-x/2,k=y,S=Math.max(k,j-y-x),N=Math.min(Math.max(v,k),S);d(Math.round(N-v))};return p(),window.addEventListener("resize",p),()=>{window.removeEventListener("resize",p)}},[r.length,a]),c.useEffect(()=>{if(!a&&!s)return;const p=g=>{g.target instanceof Node&&(h.current&&!h.current.contains(g.target)&&o(!1),u.current&&!u.current.contains(g.target)&&l(!1))};return document.addEventListener("pointerdown",p),()=>{document.removeEventListener("pointerdown",p)}},[s,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":s,onFocus:()=>l(!0),onBlur:()=>l(!1),className:`${Sn} 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}),s&&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:`${Sn} ${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:()=>o(p=>!p),className:`${Sn} 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 Of({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 Es(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 Wf(e){switch(e.kind){case"fileChange":case"webSearch":case"image":case"contextCompaction":return!0;case"commandExecution":case"toolCall":return!pl(e.status);default:return!1}}function Uf(e,r,n){if(!e||!vr(n))return e;const a=e.plan.findIndex(i=>Es(i.status)==="in_progress");if(a<0)return e;const o=e.plan.findIndex((i,d)=>d>a&&Es(i.status)==="pending");if(o<0||!r.some(i=>Wf(i)))return e;const l=e.plan.map((i,d)=>d===a?{...i,status:"completed"}:d===o?{...i,status:"in_progress"}:i);return{...e,plan:l}}function Vf(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 Ls({status:e}){const r=il(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(Of,{tone:"emerald"})})}function Is({turn:e,variant:r="header"}){const n=il(e.status),a=Vf(e),o=Ff(e),s=Nl(e),l=vr(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(Ls,{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:Wt(e.startedAt),className:"timeline-meta-text shrink-0 text-[11px]",children:vt(e.startedAt)})]}),(s||o.length>0)&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 pl-6",children:[s?t.jsx("span",{className:`inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${s.className}`,title:s.title,children:s.label}):null,o.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(Ls,{status:e.status}),t.jsx("span",{className:"timeline-meta-text min-w-0 truncate",children:a})]})}function qf(e,r){return e.createdAt??r}var ua=c.memo(function({threadId:r,item:n,scrollRootRef:a,onOpenExpandedText:o,onOpenCommandDetail:s,onOpenToolCallDetail:l,onOpenDeferredHistoryItemDetail:i,onSelectArtifact:d,onBeforeMessageResize:h,adapter:u,timeLabel:m,timeTitle:f,timeMeta:p,autoOpenToolDetails:g=!1}){var b,w,x;if(qp(n.kind))return t.jsx(It,{threadId:r,item:n,scrollRootRef:a,timeLabel:m,timeTitle:f,...h?{onBeforeMessageResize:h}:{},...u?{adapter:u}:{}});if(n.kind==="reasoning")return t.jsx(It,{item:{...n,kind:"agentMessage",status:n.status??null},scrollRootRef:a,timeLabel:m,timeTitle:f,...h?{onBeforeMessageResize:h}:{}});if(n.kind==="artifact")return t.jsx(Tf,{item:n,timeMeta:p,...d?{onSelect:(j,y)=>d({item:j,artifact:y})}:{}});if(n.kind==="commandExecution")return t.jsx(vf,{autoOpen:g,item:n,onOpen:s,timeMeta:p});if(n.kind==="toolCall")return t.jsx(kf,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="agentToolCall")return t.jsx(wf,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="skillToolCall")return t.jsx(yf,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="webSearch"){const j=n,y=((b=j.detailText)==null?void 0:b.trim())||j.text||"Web search";return t.jsx(jf,{autoOpen:g,item:j,timeMeta:p,onOpen:()=>i(j,"Web Search Details",y,"Loading full web search details...","Unable to load full web search details.")})}if(n.kind==="fileRead"){const j=n,y=((w=j.detailText)==null?void 0:w.trim())||j.text||"File read";return t.jsx(Nf,{autoOpen:g,item:j,timeMeta:p,onOpen:()=>i(j,"File Read Details",y,"Loading full file read details...","Unable to load full file read details.")})}if(n.kind==="image")return t.jsx(Cf,{threadId:r,item:n,onOpen:o,getImageAssetUrl:u==null?void 0:u.getImageAssetUrl,timeMeta:p});if(n.kind==="plan")return t.jsx(gf,{item:n,scrollRootRef:a,timeMeta:p,...h?{onBeforeResize:h}:{}});if(n.kind==="fileChange"){const j=n,y=((x=j.detailText)==null?void 0:x.trim())||j.text||"File change";return t.jsx(Sf,{item:j,timeMeta:p,onOpen:()=>i(j,"File Change Details",y,"Loading full file change details...","Unable to load full file change details.")})}return n.kind==="contextCompaction"?t.jsx(xf,{item:n,timeMeta:p}):n.kind==="hook"?t.jsx(Ef,{item:n,timeMeta:p}):t.jsx(bf,{item:n,timeMeta:p})});function zs(e){return e==="completed"||e==="failed"||e==="interrupted"}function Kf(e){const r=Date.parse(e.createdAt??"");return Number.isFinite(r)?r:null}function Xf(e){let r=null;for(const n of e){const a=Kf(n);a!==null&&(r=r===null?a:Math.max(r,a))}return r}function Yf(e,r){const n=Date.parse(e??""),a=Xf(r);if(!Number.isFinite(n)||a===null||a<n)return"Worked";const o=Math.max(1,Math.round((a-n)/1e3)),s=Math.floor(o/3600),l=Math.floor(o%3600/60),i=o%60;return s>0?`Worked for ${s}h ${l}m`:l>0?`Worked for ${l}m ${i}s`:`Worked for ${i}s`}function Zf(e,r){const n=Date.parse(e??""),a=Date.parse(r??"");if(!Number.isFinite(n)||!Number.isFinite(a))return r?vt(r):"Time unavailable";const o=Math.max(0,Math.round((a-n)/1e3)),s=Math.floor(o/3600),l=Math.floor(o%3600/60),i=o%60;return s>0?`${s}h ${l}m`:l>0?`${l}m ${i}s`:`${i}s`}function wr({absoluteLabel:e,className:r="",timestamp:n,turnStartedAt:a}){const[o,s]=c.useState(!1);if(!n)return null;const l=Wt(n),i=Zf(a,n),d=o?e:i;return t.jsx("span",{role:"button",tabIndex:0,className:`thread-graph-relative-time rounded-full px-1.5 py-0.5 text-[10px] leading-none transition sm:text-[11px] ${r}`,title:o?i:l,"aria-label":`Toggle timestamp, currently ${d}`,onClick:h=>{h.stopPropagation(),s(u=>!u)},onKeyDown:h=>{h.key!=="Enter"&&h.key!==" "||(h.preventDefault(),h.stopPropagation(),s(u=>!u))},children:t.jsx("time",{dateTime:n,children:d})})}function $r(e){var r;return e.kind==="item"?e.item.createdAt??null:((r=e.items.find(n=>n.createdAt))==null?void 0:r.createdAt)??null}function Jf(e){const r=e.filter(s=>s.kind==="item"),n=r.map(s=>s.item).filter(s=>s.kind==="userMessage"),a=r.map(s=>s.item).reverse().find(s=>s.kind==="agentMessage"&&s.text.trim().length>0),o=e.filter(s=>s.kind!=="item"?!0:s.item.kind!=="userMessage"&&s.item.id!==(a==null?void 0:a.id));return{users:n,finalAgent:a,hiddenEntries:o}}var Tn=c.memo(function({threadId:r,adapter:n,turn:a,absoluteIndex:o,isCollapsed:s,livePlan:l,liveItems:i,liveOutput:d,forceActive:h=!1,onToggleCollapse:u,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,onSelectArtifact:b,onBeforeMessageResize:w,scrollRootRef:x,articleRef:j,isLatestVisibleTurn:y=!1}){const v=!!l||!!d||!!(i&&i.length>0),k=h||vr(a.status)||v||y,S=k&&!vr(a.status)?{...a,status:"inProgress"}:a,N=c.useMemo(()=>Zp(a.items,i),[i,a.items]),L=c.useMemo(()=>Uf(l,N,a.status),[l,N,a.status]),R=c.useMemo(()=>Jp(d,N),[d,N]),P=c.useMemo(()=>Yp(N,k),[k,N]),Q=c.useMemo(()=>Qp(P),[P]),D=h||vr(a.status)||v,Z=vt(a.startedAt),J=Wt(a.startedAt),z=c.useMemo(()=>ml(R),[R]),[te,se]=c.useState({}),$=c.useCallback(K=>{se(ie=>({...ie,[K]:!ie[K]}))},[]),le=t.jsx(Qf,{entries:Q,expandedGroups:te,onToggleGroupedItem:$,threadId:r,scrollRootRef:x,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,...w?{onBeforeMessageResize:w}:{},fallbackTimestamp:a.startedAt,fallbackTimeLabel:Z,fallbackTimeTitle:J,turnStartedAt:a.startedAt,autoOpenLatestToolDetails:D,...b?{onSelectArtifact:b}:{},...n?{adapter:n}:{}}),q=z?t.jsx(ua,{threadId:r,item:z,scrollRootRef:x,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,timeLabel:a.startedAt?t.jsx(wr,{absoluteLabel:Z,timestamp:a.startedAt,turnStartedAt:a.startedAt}):Z,timeTitle:J,timeMeta:null,...b?{onSelectArtifact:b}:{},...n?{adapter:n}:{}}):null,H=!z&&R?t.jsx(It,{item:{id:"live-agent-message",kind:"agentMessage",text:R},scrollRootRef:x,timeLabel:a.startedAt?t.jsx(wr,{absoluteLabel:Z,timestamp:a.startedAt,turnStartedAt:a.startedAt}):Z,timeTitle:J,streaming:!0,...w?{onBeforeMessageResize:w}:{}}):null,G=k?t.jsx(Is,{turn:S,variant:"footer"}):null,T=c.useMemo(()=>Jf(Q),[Q]),F=c.useMemo(()=>Yf(a.startedAt,N),[N,a.startedAt]),B=T.hiddenEntries.length>0,E=s&&B,W=zs(a.status)&&B&&!E?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,!1),"aria-label":`${F}. Collapse turn ${o}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:F}),t.jsx(_.ChevronDown,{className:"h-4 w-4 shrink-0 transition group-hover:translate-y-0.5"}),t.jsx("span",{className:"thread-graph-worked-rule h-px min-w-0 flex-1","aria-hidden":"true"})]}):null,U=zs(a.status)&&B?t.jsxs("div",{className:"thread-graph-turn-collapsed-summary space-y-2",children:[T.users.map(K=>t.jsx(It,{threadId:r,item:K,scrollRootRef:x,timeLabel:K.createdAt?vt(K.createdAt):Z,timeTitle:K.createdAt?Wt(K.createdAt):J,...w?{onBeforeMessageResize:w}:{},...n?{adapter:n}:{}},K.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":`${F}. Expand turn ${o}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:F}),t.jsx(_.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"})]}),T.finalAgent?t.jsx(It,{threadId:r,item:T.finalAgent,scrollRootRef:x,timeLabel:T.finalAgent.createdAt?t.jsx(wr,{absoluteLabel:vt(T.finalAgent.createdAt),timestamp:T.finalAgent.createdAt,turnStartedAt:a.startedAt}):Z,timeTitle:T.finalAgent.createdAt?Wt(T.finalAgent.createdAt):J,...w?{onBeforeMessageResize:w}:{},...n?{adapter:n}:{}}):null]}):null,ne=t.jsx(_f,{footer:G,history:t.jsxs(t.Fragment,{children:[W,le]}),liveHookPrompt:q,liveOutput:H,livePlan:L});return t.jsx($f,{absoluteIndex:o,body:ne,collapsed:E,collapsedBody:U,error:a.error,headerStatus:t.jsx(Is,{turn:a}),isActive:k,refCallback:j,startedAt:a.startedAt,timeLabel:Z,timeTitle:J,tokenSummary:t.jsx(Hf,{turn:a})})});function Qf({entries:e,expandedGroups:r,onToggleGroupedItem:n,threadId:a,scrollRootRef:o,onOpenExpandedText:s,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,onSelectArtifact:h,onBeforeMessageResize:u,adapter:m,fallbackTimestamp:f,fallbackTimeLabel:p,fallbackTimeTitle:g,turnStartedAt:b,autoOpenLatestToolDetails:w=!1}){var y;const x=((y=e.at(-1))==null?void 0:y.key)??null,j=c.useCallback(v=>v?t.jsx(wr,{absoluteLabel:vt(v),timestamp:v,turnStartedAt:b??f}):null,[f,b]);return t.jsx(af,{entries:e,expandedGroups:r,onToggleGroupedItem:n,renderCommandGroup:(v,k,S)=>t.jsx(Lf,{items:v.items,expanded:k,onToggleExpanded:S,onOpen:l,timeMeta:j($r(v))},v.key),renderFileChangeGroup:(v,k,S)=>t.jsx(Pf,{items:v.items,expanded:k,onToggleExpanded:S,onOpen:s,timeMeta:j($r(v))},v.key),renderSearchGroup:(v,k,S)=>t.jsx(If,{items:v.items,expanded:k,onToggleExpanded:S,onOpen:s,timeMeta:j($r(v))},v.key),renderFileReadGroup:(v,k,S)=>t.jsx(zf,{items:v.items,expanded:k,onToggleExpanded:S,onOpen:s,timeMeta:j($r(v))},v.key),renderItem:v=>{const k=qf(v.item,f??null),N=v.item.kind==="userMessage"?v.item.createdAt?vt(k):p:v.item.createdAt?t.jsx(wr,{absoluteLabel:vt(k),timestamp:k,turnStartedAt:b??f}):p;return t.jsx(ua,{threadId:a,item:v.item,scrollRootRef:o,timeLabel:N,timeTitle:v.item.createdAt?Wt(k):g,timeMeta:j(k),autoOpenToolDetails:w&&v.key===x,onOpenExpandedText:s,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,...u?{onBeforeMessageResize:u}:{},...h?{onSelectArtifact:h}:{},...m?{adapter:m}:{}},v.key)}})}var Ps=3,eg=3,Zn=80;function gr(e,r=Zn){return e.scrollHeight-e.scrollTop-e.clientHeight<=r}function tg(e,r){const n=e.getBoundingClientRect(),a=r.getBoundingClientRect(),o=Math.max(n.top,a.top),s=Math.min(n.bottom,a.bottom);return Math.max(0,s-o)>0}function rg(e){return e.map(n=>{const a=n.createdAt;return typeof a=="string"&&a.trim()?a:null}).filter(n=>!!n).sort()[0]??null}function ng(e,r){return{id:e,startedAt:rg(r),status:"inProgress",error:null,model:null,reasoningEffort:null,reasoningEffortAvailable:null,tokenUsage:null,priceEstimate:null,items:[]}}function Rs(e,r,n){return{id:e.id,kind:e.kind,title:r,text:n}}function ag({loadHistoryItemDetail:e,onSelectHistoryItemDetail:r}){const n=c.useRef(0),a=c.useRef(new Map),[o,s]=c.useState(null),l=c.useCallback((p,g)=>{s({title:p,text:g})},[]),i=c.useCallback((p,g,b)=>{if(b&&r){r({item:p,detail:g});return}s({title:g.title,text:g.text})},[r]),d=c.useCallback(async({item:p,fallbackTitle:g,fallbackText:b,loadingText:w,errorText:x,useSelectionCallback:j})=>{if(!p.hasDeferredDetail||!e){i(p,Rs(p,g,b),j);return}const y=a.current.get(p.id);if(y){i(p,y,j);return}const v=n.current+1;n.current=v,j&&r||s({title:g,text:w});try{const k=await e(p.id);if(a.current.set(p.id,k),n.current!==v)return;i(p,k,j)}catch(k){if(n.current!==v)return;i(p,Rs(p,g,k instanceof Error?k.message:x),j)}},[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,w,x)=>{await d({item:p,fallbackTitle:g,fallbackText:b,loadingText:w,errorText:x,useSelectionCallback:!1})},[d]),f=c.useCallback(()=>{n.current+=1,s(null)},[]);return{expandedText:o,openExpandedText:l,openCommandDetail:h,openToolCallDetail:u,openDeferredHistoryItemDetail:m,closeExpandedText:f}}function sg(e){const r=c.useRef(null),n=c.useRef(0),a=r.current;return(a===null||a.length!==e.length||e.some((s,l)=>!Object.is(s,a[l])))&&(n.current+=1,r.current=e),n.current}function og({threadId:e,turnsLength:r,totalTurnCount:n,loadingEarlier:a,onLoadEarlier:o,scrollRequestKey:s,bottomSpacer:l,onTailVisibilityChange:i,contentRevisionInputs:d}){const h=c.useRef(null),u=c.useRef(null),m=c.useRef(s),f=c.useRef(null),p=c.useRef(l),g=c.useRef(0),b=c.useRef(0),w=c.useRef(null),x=c.useRef(null),j=c.useRef(null),y=c.useRef(!0),v=c.useRef(!0),k=c.useRef(!1),S=c.useRef(!1),N=c.useRef(!1),L=c.useRef(!1),R=c.useRef(null),P=c.useRef(0),[Q,D]=c.useState(Ps),[Z,J]=c.useState(0),[z,te]=c.useState(!0),se=sg(d),$=typeof o=="function"||n!==void 0,le=n??r,q=$?0:Math.max(0,r-Q),G=($?Math.max(0,le-r):0)+q,T=$?r:r-q,F=$?0:r-T,B=$?Math.max(0,le-r):0,E=$?B+F:F,C=!$&&E>0&&Z>=2,W=$&&B>0&&F===0&&typeof o=="function",U=c.useCallback(()=>{const Y=h.current;if(!Y){w.current=null;return}w.current={scrollHeight:Y.scrollHeight,scrollTop:Y.scrollTop}},[]),ne=c.useCallback(()=>!W||a||N.current?!1:(U(),N.current=!0,L.current=!1,P.current=0,o==null||o(),!0),[W,a,o,U]),K=c.useCallback(()=>{const Y=h.current,ue=x.current;if(!Y)return;const ke=ue?tg(Y,ue):gr(Y);y.current=ke,te(we=>we===ke?we:ke)},[]),ie=c.useCallback(()=>{const Y=h.current;if(Y){S.current=!0;const ue=Y.scrollTop,ke=b.current,we=ue-ke;b.current=ue,gr(Y,1)?(k.current=!1,v.current=!0):we<-1?(k.current=!0,v.current=!1):we>1&&(v.current=!k.current&&gr(Y,Zn)),ue<=0&&S.current?L.current=!0:ue>0&&(L.current=!1,P.current=0)}K()},[K]),ee=c.useCallback(()=>{const Y=h.current;Y&&(Y.scrollTop=Y.scrollHeight,b.current=Y.scrollTop,g.current=Y.scrollHeight,y.current=!0,te(ue=>ue||!0),k.current=!1,v.current=!0)},[]),ve=c.useCallback(()=>{const Y=h.current;Y&&(b.current=Y.scrollTop,g.current=Y.scrollHeight,v.current=!1,k.current=!0)},[]),oe=c.useCallback(()=>{if($&&F===0){ne();return}D(Y=>Math.min(r,Y+eg)),J(Y=>Y+1)},[F,$,ne,r]),ye=c.useCallback(Y=>{const ue=h.current;if(!(!ue||Y.deltaY>=-8||ue.scrollTop>0||!W)){if(!L.current){L.current=!0;return}ne()}},[W,ne]),Me=c.useCallback(Y=>{var ue;R.current=((ue=Y.touches.item(0))==null?void 0:ue.clientY)??null,P.current=0},[]),de=c.useCallback(Y=>{var Fe;const ue=h.current,ke=((Fe=Y.touches.item(0))==null?void 0:Fe.clientY)??null,we=R.current;if(R.current=ke,!ue||ke===null||we===null||ue.scrollTop>0||!W){P.current=0;return}const De=ke-we;if(De<=0){P.current=0;return}if(!L.current){L.current=!0,P.current=0;return}P.current+=De,P.current>=28&&ne()},[W,ne]),Ce=c.useCallback(()=>{R.current=null,P.current=0},[]),Ee=c.useCallback(()=>{D(r)},[r]);return c.useLayoutEffect(()=>{const Y=window.requestAnimationFrame(()=>{ee()});return()=>{window.cancelAnimationFrame(Y)}},[e,ee]),c.useEffect(()=>{N.current=!1,S.current=!1,L.current=!1,w.current=null},[e]),c.useEffect(()=>{a||(N.current=!1)},[a,r]),c.useLayoutEffect(()=>{const Y=w.current,ue=h.current;if(!Y||!ue||a)return;w.current=null;const ke=ue.scrollHeight-Y.scrollHeight;if(ke<=0){g.current=ue.scrollHeight,b.current=ue.scrollTop;return}const we=Y.scrollTop+ke;ue.scrollTop=we,b.current=we,g.current=ue.scrollHeight,k.current=!0,v.current=!1,L.current=!1},[a,r]),c.useEffect(()=>{D(Y=>Y>=r-1?r:Math.max(Y,Ps))},[r]),c.useEffect(()=>{const Y=h.current;Y&&(g.current=Y.scrollHeight,b.current=Y.scrollTop,gr(Y,1)?(k.current=!1,v.current=!0):(k.current||!gr(Y,Zn))&&(v.current=!1)),K()},[se,K,Q]),c.useEffect(()=>{const Y=s!==m.current,ue=f.current!==se;if(f.current=se,!(Y||ue&&v.current&&!k.current))return;const we=window.requestAnimationFrame(()=>{ee()});return s!==m.current&&(m.current=s),()=>{window.cancelAnimationFrame(we)}},[se,z,ee,s]),c.useEffect(()=>{const Y=h.current,ue=u.current;if(!Y||!ue||typeof ResizeObserver>"u")return;g.current=Y.scrollHeight;const ke=new ResizeObserver(()=>{const we=Y.scrollHeight,De=g.current;if(g.current=we,we<=De)return;const Fe=De>0&&De-Y.scrollTop-Y.clientHeight<=1;k.current||!(v.current||Fe||y.current)||window.requestAnimationFrame(()=>{ee()})});return ke.observe(ue),()=>{ke.disconnect()}},[ee]),c.useEffect(()=>{if(!v.current||k.current){p.current=l;return}if(l===p.current)return;p.current=l;const Y=window.requestAnimationFrame(()=>{ee()});return()=>{window.cancelAnimationFrame(Y)}},[l,ee]),c.useEffect(()=>{i==null||i(z)},[z,i]),{scrollContainerRef:h,scrollContentRef:u,tailSentinelRef:x,topSentinelRef:j,isTailVisible:z,handleScroll:ie,handleWheel:ye,handleTouchStart:Me,handleTouchMove:de,handleTouchEnd:Ce,preserveScrollPositionForResize:ve,serverManagedHistory:$,effectiveTotalTurnCount:le,startIndex:q,visibleTurnAbsoluteOffset:G,hiddenCount:E,loadedHiddenCount:F,unloadedHiddenCount:B,showLoadAll:C,handleLoadEarlierClick:oe,handleLoadAllClick:Ee}}function lg(e){return e==="completed"||e==="failed"||e==="interrupted"}function ig(e,r){if(!r||r.id!==e.id||r.items.length===0)return e;const n=new Set(e.items.map(o=>o.id)),a=r.items.filter(o=>!n.has(o.id));return a.length===0?e:{...e,items:[...a,...e.items]}}function dg({threadId:e,turns:r,totalTurnCount:n,pendingRequests:a=[],activeTurnId:o=null,threadRunning:s=!1,pendingSteers:l=[],livePlan:i=null,liveItems:d=null,respondingRequestId:h=null,onRespondToRequest:u,liveOutput:m,scrollRequestKey:f=0,previousTurnScrollRequestKey:p=0,nextTurnScrollRequestKey:g=0,bottomSpacer:b=0,className:w="",onTailVisibilityChange:x,onPreviousTurnAvailabilityChange:j,onNextTurnAvailabilityChange:y,loadingEarlier:v=!1,onLoadEarlier:k,ephemeralUserNote:S=null,answeredRequestNotes:N=[],activityNotes:L=[],optimisticSteers:R=[],optimisticTurn:P=null,onLoadHistoryItemDetail:Q,onOpenThread:D,onSelectArtifact:Z,onSelectHistoryItemDetail:J,adapter:z,autoCollapseCompletedTurns:te}){var st,ct,gt,Rt,wt;const se=ll(),$=te??(se==null?void 0:se.autoCollapseCompletedTurns)??!1,[le,q]=c.useState({}),[H,G]=c.useState(()=>new Set),T=c.useRef(null),F=c.useRef(null),B=(z==null?void 0:z.onLoadHistoryItemDetail)??Q,E=z==null?void 0:z.onOpenLinkedThread,{expandedText:C,openExpandedText:W,openCommandDetail:U,openToolCallDetail:ne,openDeferredHistoryItemDetail:K,closeExpandedText:ie}=ag({loadHistoryItemDetail:B,onSelectHistoryItemDetail:J}),{scrollContainerRef:ee,scrollContentRef:ve,tailSentinelRef:oe,topSentinelRef:ye,handleScroll:Me,handleWheel:de,handleTouchStart:Ce,handleTouchMove:Ee,handleTouchEnd:Y,preserveScrollPositionForResize:ue,serverManagedHistory:ke,effectiveTotalTurnCount:we,startIndex:De,visibleTurnAbsoluteOffset:Fe,hiddenCount:Ae,loadedHiddenCount:Oe,unloadedHiddenCount:V,showLoadAll:ce,handleLoadEarlierClick:xe,handleLoadAllClick:I}=og({threadId:e,turnsLength:r.length,totalTurnCount:n,loadingEarlier:v,onLoadEarlier:k,scrollRequestKey:f,bottomSpacer:b,onTailVisibilityChange:x,contentRevisionInputs:[r,a,l,R,m,i,d,P,N,L,S,b]}),O=c.useCallback((A,pe)=>{q(ze=>({...ze,[A]:!pe}))},[]),ae=c.useCallback((A,pe)=>{const ze=le[A.id];return ze!==void 0?ze:!!($&&lg(A.status)&&!pe.forceActive&&!pe.hasLiveActivity)},[le,$]),be=ke?r:r.slice(De),je=we+1,Te=s&&(!o||!be.some(A=>A.id===o)&&(P==null?void 0:P.id)!==o),fe=(P==null?void 0:P.id)??((st=be.at(-1))==null?void 0:st.id)??null,Be=Te&&fe!==null,_e=!!d&&(be.some(A=>A.id===d.turnId)||(P==null?void 0:P.id)===d.turnId),Qe=d&&_e?d.turnId:d&&Be?fe:null,et=P&&Qe===P.id?(d==null?void 0:d.items)??null:null,it=((d==null?void 0:d.items.length)??0)>0,tt=d&&Qe===null?d.items:null,Ke=c.useMemo(()=>d&&Qe===null&&d.items.length>0?ng(d.turnId,d.items):null,[d,Qe]),dt=Math.max(1,we+(P?1:0)),ft=!!m&&!!P&&P.status!=="failed"&&!et,Ve=m&&be.length>0?o&&be.some(A=>A.id===o)?o:((ct=be.findLast(A=>pl(A.status)))==null?void 0:ct.id)??(Be?fe:null):null,M=!!Ve,X=c.useMemo(()=>ml(m),[m]),ge=[...l.map(A=>({id:A.id,prompt:A.prompt,status:"Accepted",createdAt:A.createdAt,canCancel:!0})),...R.map(A=>({id:A.id,prompt:A.prompt,status:A.status==="steering"?"Steering":null,createdAt:A.createdAt,canCancel:!1}))].sort((A,pe)=>A.createdAt.localeCompare(pe.createdAt)),Ne=c.useMemo(()=>ef({answeredRequestNotes:N,pendingRequests:a,visibleTurns:be,optimisticTurn:P}),[N,P,a,be]),Pe=c.useMemo(()=>tf({activityNotes:L,visibleTurns:be,optimisticTurn:P}),[L,P,be]),rt=c.useCallback(()=>{const A=ee.current;if(!A)return null;const pe=A.getBoundingClientRect().top;return Array.from(A.querySelectorAll("[data-timeline-turn]")).find(ze=>ze.getBoundingClientRect().top>pe+8)??null},[ee]),nt=c.useCallback(()=>{const A=ee.current;if(!A)return null;const pe=A.getBoundingClientRect().top;return Array.from(A.querySelectorAll("[data-timeline-turn]")).findLast(ze=>ze.getBoundingClientRect().top<pe-8)??null},[ee]),$e=c.useCallback(()=>{j==null||j(!!nt())},[nt,j]),We=c.useCallback(()=>{y==null||y(!!rt())},[rt,y]),ut=c.useCallback(()=>{Me(),$e(),We()},[Me,We,$e]);return c.useEffect(()=>{$e(),We()},[We,$e,be]),c.useEffect(()=>{if(p===0)return;const A=ee.current,pe=nt(),ze=A?Array.from(A.querySelectorAll("[data-timeline-turn]")):[],Ge=pe?ze.indexOf(pe):-1,Ue=pe&&pe.dataset.turnId===T.current?ze[Ge-1]??null:pe;if(!A||!Ue)return;T.current=Ue.dataset.turnId??null;const mt=Ue.getBoundingClientRect().top-A.getBoundingClientRect().top;A.scrollTo({top:A.scrollTop+mt-8,behavior:"smooth"}),ze.indexOf(Ue)===0&&(j==null||j(!1))},[nt,j,p,ee]),c.useEffect(()=>{if(g===0)return;const A=ee.current,pe=rt(),ze=A?Array.from(A.querySelectorAll("[data-timeline-turn]")):[],Ge=pe?ze.indexOf(pe):-1,Ue=pe&&pe.dataset.turnId===F.current?ze[Ge+1]??null:pe;if(!A||!Ue)return;F.current=Ue.dataset.turnId??null;const mt=Ue.getBoundingClientRect().top-A.getBoundingClientRect().top;A.scrollTo({top:A.scrollTop+mt-8,behavior:"smooth"}),ze.indexOf(Ue)===ze.length-1&&(y==null||y(!1))},[rt,g,y,ee]),t.jsxs(t.Fragment,{children:[t.jsx("section",{className:`flex min-h-0 flex-1 flex-col ${w}`.trim(),children:t.jsx("div",{ref:ee,"data-testid":"thread-scroll-container",onScroll:ut,onWheel:de,onTouchStart:Ce,onTouchMove:Ee,onTouchEnd:Y,onTouchCancel:Y,className:"thread-graph-scroll-container min-h-0 flex-1 overflow-y-auto overscroll-contain",style:b>0?{paddingBottom:b}:void 0,children:t.jsxs("div",{ref:ve,className:"thread-graph-scroll-content",children:[t.jsx("div",{ref:ye,"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:[Ae>0&&t.jsx("button",{type:"button",onClick:xe,disabled:v,className:"thread-graph-history-button rounded-full border px-2.5 py-1.5 transition",children:v?"Loading earlier...":"Load 3 earlier"}),ce&&t.jsx("button",{type:"button",onClick:I,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 ",be.length," of ",we," turns",Ae>0?` · ${Ae} earlier hidden${Oe>0&&V>0?` (${Oe} loaded)`:""}`:""]})]})}),r.length===0&&!m&&!P&&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."}),(be.length>0||P||Pe.leading.length>0||Pe.trailing.length>0)&&t.jsxs("div",{className:"thread-graph-message-list",children:[Pe.leading.length>0?t.jsx(pr,{notes:Pe.leading,onOpenThread:D,onOpenLinkedThread:E}):null,be.map((A,pe)=>{var ze,Ge,Ue,mt,yt;return t.jsxs("div",{"data-timeline-turn":!0,"data-turn-id":A.id,children:[(((ze=Pe.beforeTurnId.get(A.id))==null?void 0:ze.length)??0)>0?t.jsx(pr,{notes:Pe.beforeTurnId.get(A.id)??[],onOpenThread:D,onOpenLinkedThread:E}):null,(((Ge=Ne.beforeTurnId.get(A.id))==null?void 0:Ge.length)??0)>0?t.jsx(Xn,{entries:Ne.beforeTurnId.get(A.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const Kt=ig(A,P),Xt=(i==null?void 0:i.turnId)===A.id?i:null,Mt=Qe===A.id?(d==null?void 0:d.items)??null:null,cr=Ve===A.id?m:"",ot=o===A.id||Be&&fe===A.id,dn=!!Xt||!!cr||!!(Mt&&Mt.length>0),cn=ae(Kt,{forceActive:ot,hasLiveActivity:dn});return t.jsx(Tn,{threadId:e,...z?{adapter:z}:{},turn:Kt,absoluteIndex:Fe+pe+1,isCollapsed:cn,livePlan:Xt,liveItems:Mt,liveOutput:cr,forceActive:ot,onToggleCollapse:O,onOpenExpandedText:W,onOpenCommandDetail:U,onOpenToolCallDetail:ne,onOpenDeferredHistoryItemDetail:K,onBeforeMessageResize:ue,...Z?{onSelectArtifact:Z}:{},scrollRootRef:ee,articleRef:void 0})})(),(((Ue=Pe.afterTurnId.get(A.id))==null?void 0:Ue.length)??0)>0?t.jsx(pr,{notes:Pe.afterTurnId.get(A.id)??[],onOpenThread:D,onOpenLinkedThread:E}):null,(mt=Ne.notesByTurnId.get(A.id))!=null&&mt.length||(yt=Ne.pendingRequestsByTurnId.get(A.id))!=null&&yt.length?t.jsx(rf,{notes:Ne.notesByTurnId.get(A.id)??[],requests:Ne.pendingRequestsByTurnId.get(A.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null]},A.id)}),P&&be.every(A=>A.id!==P.id)&&t.jsxs(t.Fragment,{children:[(((gt=Pe.beforeTurnId.get(P.id))==null?void 0:gt.length)??0)>0?t.jsx(pr,{notes:Pe.beforeTurnId.get(P.id)??[],onOpenThread:D,onOpenLinkedThread:E}):null,(((Rt=Ne.beforeTurnId.get(P.id))==null?void 0:Rt.length)??0)>0?t.jsx(Xn,{entries:Ne.beforeTurnId.get(P.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const A=ft?m:"",pe=o===P.id||Be&&fe===P.id,ze=!!(et&&et.length>0)||!!A,Ge=ae(P,{forceActive:pe,hasLiveActivity:ze});return t.jsx(Tn,{threadId:e,...z?{adapter:z}:{},turn:P,absoluteIndex:je,isCollapsed:Ge,livePlan:null,liveItems:et,liveOutput:A,forceActive:pe,onToggleCollapse:O,onOpenExpandedText:W,onOpenCommandDetail:U,onOpenToolCallDetail:ne,onOpenDeferredHistoryItemDetail:K,onBeforeMessageResize:ue,...Z?{onSelectArtifact:Z}:{},scrollRootRef:ee})})(),(((wt=Pe.afterTurnId.get(P.id))==null?void 0:wt.length)??0)>0?t.jsx(pr,{notes:Pe.afterTurnId.get(P.id)??[],onOpenThread:D,onOpenLinkedThread:E}):null]})]}),ge.length>0&&t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:ge.map(A=>t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(It,{threadId:e,item:{id:A.id,kind:"userMessage",text:A.prompt,status:A.status},scrollRootRef:ee,onBeforeMessageResize:ue,...z?{adapter:z}:{}}),e&&A.canCancel&&(z!=null&&z.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:H.has(A.id),onClick:()=>{var pe;G(ze=>new Set(ze).add(A.id)),Promise.resolve((pe=z.cancelPendingSteer)==null?void 0:pe.call(z,e,A.id)).catch(()=>{}).finally(()=>{G(ze=>{const Ge=new Set(ze);return Ge.delete(A.id),Ge})})},children:H.has(A.id)?"Canceling...":"Cancel"})}):null]},A.id))}),(Ne.trailing.length>0||Pe.trailing.length>0)&&t.jsx(nf,{entries:[...Pe.trailing.map(A=>({kind:"activity",id:A.id,createdAt:A.createdAt,note:A})),...Ne.trailing],respondingRequestId:h,onRespondToRequest:u??void 0,onOpenThread:D,onOpenLinkedThread:E}),S&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:t.jsx(It,{threadId:e,item:{id:"ephemeral-plan-decision-note",kind:"userMessage",text:S},scrollRootRef:ee,onBeforeMessageResize:ue})}),Ke&&tt&&tt.length>0&&t.jsx(Tn,{threadId:e,...z?{adapter:z}:{},turn:Ke,absoluteIndex:dt,isCollapsed:le[Ke.id]??!1,livePlan:(i==null?void 0:i.turnId)===Ke.id?i:null,liveItems:tt,liveOutput:"",forceActive:!0,onToggleCollapse:O,onOpenExpandedText:W,onOpenCommandDetail:U,onOpenToolCallDetail:ne,onOpenDeferredHistoryItemDetail:K,onBeforeMessageResize:ue,...Z?{onSelectArtifact:Z}:{},scrollRootRef:ee}),m&&!M&&!ft&&!it&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:X?t.jsx(ua,{threadId:e,item:X,scrollRootRef:ee,onOpenExpandedText:W,onOpenCommandDetail:U,onOpenToolCallDetail:ne,onOpenDeferredHistoryItemDetail:K,onBeforeMessageResize:ue,...Z?{onSelectArtifact:Z}:{},...z?{adapter:z}:{}}):t.jsx(It,{threadId:e,item:{id:"live-agent-message-fallback",kind:"agentMessage",text:m},scrollRootRef:ee,streaming:!0,onBeforeMessageResize:ue,...z?{adapter:z}:{}})}),t.jsx("div",{ref:oe,"aria-hidden":"true",className:"h-px w-full"})]})})}),t.jsx(bp,{open:C!==null,title:(C==null?void 0:C.title)??"Full text",text:(C==null?void 0:C.text)??"",onClose:ie})]})}var Cl=c.memo(dg);function cg(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}function Jn(e){return e.replace(/\r\n/g,`
3700
- `)}function Ms(e){const r=Jn(e),n=r.split(`
3700
+ `);for(;r.length>1&&((n=r.at(-1))==null?void 0:n.trim())==="";)r.pop();return r}function ft(e){const r=wf(e);return r.length===1?{firstLine:r[0]??"",showGap:!1,isTruncated:!1}:{firstLine:r[0]??"",showGap:!0,isTruncated:!0}}function jl(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($.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"}:r==="failed"||r==="failure"||r==="error"||r==="errored"?{className:"is-failed",icon:t.jsx($.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"}:cn(e)?{className:"is-pending",icon:t.jsx($.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 yf(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 jf(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 Kt({actions:e,children:r,className:n,headerMeta:a,icon:s,item:o,timeMeta:l,title:i,tone:d}){const h=jl(o.status);return t.jsxs("div",{className:`thread-graph-event thread-graph-history-event ${jf(d)} ${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:i}),o.status?t.jsxs(dn,{variant:"outline",className:`thread-graph-tool-badge ${h.className} rounded-full px-2 py-0.5 text-xs font-normal`,title:h.label,"aria-label":`Status: ${h.label}`,children:[h.icon,t.jsx("span",{className:"thread-graph-status-label",children:h.label})]}):null,a]}),e||l?t.jsxs("div",{className:"thread-graph-history-event-actions",children:[e,l]}):null]}),r?t.jsx("div",{className:"thread-graph-history-event-body",children:r}):null]})]})}function ur({actionLabel:e="Open details",actionTitle:r,autoOpen:n=!1,className:a,details:s,icon:o,item:l,onOpen:i,preview:d,timeMeta:h,title:u,tone:m}){const f=jl(l.status),[p,g]=c.useState(n?"item-1":void 0),k=c.useRef(n);return c.useLayoutEffect(()=>{n?g("item-1"):k.current&&g(void 0),k.current=n},[n,l.id]),t.jsx("div",{className:`thread-graph-event thread-graph-history-tool ${yf(m)} ${a??""}`,children:t.jsx(Lr,{type:"single",collapsible:!0,onValueChange:w=>{g(w||void 0)},className:"thread-graph-tool-accordion thread-graph-history-tool-accordion w-full overflow-hidden rounded-lg border",value:p??"",children:t.jsxs(Ir,{value:"item-1",className:"border-0",children:[t.jsxs(on,{"aria-label":`${p==="item-1"?"Collapse":"Expand"} ${u} 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:o}),t.jsx("span",{className:"min-w-0 truncate font-mono text-sm font-semibold",children:u}),t.jsxs(dn,{variant:"outline",className:`thread-graph-tool-badge ${f.className} ml-1 sm:ml-2 rounded-full px-2 py-0.5 text-xs font-normal`,title:f.label,"aria-label":`Status: ${f.label}`,children:[f.icon,t.jsx("span",{className:"thread-graph-status-label",children:f.label})]})]}),h?t.jsx("span",{className:"thread-graph-history-tool-time shrink-0",children:h}):null]}),t.jsxs(zr,{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(ir,{text:d.firstLine}),d.showGap?t.jsx("span",{className:"thread-graph-history-tool-ellipsis",children:"..."}):null]})]}),s?t.jsx("section",{children:s}):null,t.jsxs("button",{type:"button","aria-label":e,onClick:i,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($.ExternalLink,{className:"h-3.5 w-3.5"}),r]})]})]})})})}var Nf=c.memo(function({item:r,scrollRootRef:n,onBeforeResize:a,timeMeta:s}){return t.jsx(Kt,{className:"thread-graph-event-plan",icon:t.jsx($.ClipboardList,{className:"h-4 w-4"}),item:r,timeMeta:s,title:"plan",tone:"plan",children:t.jsx("div",{className:"thread-graph-history-event-prose",children:t.jsx(fl,{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}:{}})})})}),Cf=c.memo(function({item:r,timeMeta:n}){const a=cn(r.status)||r.text==="Compacting context",s=a?"Compacting context":"Context compacted",o=r.detailText&&r.detailText!==s?r.detailText:null;return t.jsxs(Kt,{className:"thread-graph-event-context",icon:t.jsx($.Archive,{className:"h-4 w-4"}),item:r,timeMeta:n,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:s}),a?t.jsx(Jr,{tone:"emerald"}):null]}),o?t.jsx("p",{className:"thread-graph-history-event-secondary",title:o,children:o}):null]})}),Sf=c.memo(function({item:r,timeMeta:n}){return t.jsx(Kt,{className:"thread-graph-event-generic",icon:t.jsx($.Info,{className:"h-4 w-4"}),item:r,timeMeta:n,title:r.kind,tone:"generic",children:t.jsx("pre",{className:"thread-graph-history-event-pre",children:t.jsx(ir,{text:r.text})})})}),Tf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:s}){const o=ft(n.previewText??n.text);return t.jsx(ur,{actionLabel:"Open full command",actionTitle:"Command Output",autoOpen:r,className:"thread-graph-event-command",icon:t.jsx($.Terminal,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Command Output"),preview:o,timeMeta:s,title:"command",tone:"command"})}),Ef=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:s}){const o=ft(n.text);return t.jsx(ur,{actionLabel:"Open full tool call",actionTitle:"Tool Call Details",autoOpen:r,className:"thread-graph-event-tool",icon:t.jsx($.Wrench,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Tool Call Details"),preview:o,timeMeta:s,title:"tool_call",tone:"tool"})}),Lf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:s}){const o=ft(n.text);return t.jsx(ur,{actionLabel:"Open agent details",actionTitle:"Agent Details",autoOpen:r,className:"thread-graph-event-agent-tool",icon:t.jsx($.Bot,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Agent Details"),preview:o,timeMeta:s,title:"agent",tone:"agent"})}),If=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:s}){const o=ft(n.text);return t.jsx(ur,{actionLabel:"Open skill details",actionTitle:"Skill Details",autoOpen:r,className:"thread-graph-event-skill-tool",icon:t.jsx($.Sparkles,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Skill Details"),preview:o,timeMeta:s,title:"skill",tone:"skill"})}),zf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:s}){var d,h;const o=((d=n.previewText)==null?void 0:d.trim())||n.text||"Web search",l=((h=n.detailText)==null?void 0:h.trim())||n.text||"Web search",i=ft(o);return t.jsx(ur,{actionLabel:"Open full web search",actionTitle:"Web Search Details",autoOpen:r,className:"thread-graph-event-search",icon:t.jsx($.Search,{className:"h-4 w-4"}),item:n,onOpen:()=>a("Web Search Details",l),preview:i,timeMeta:s,title:"web_search",tone:"search"})}),Pf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:s}){var d,h;const o=((d=n.previewText)==null?void 0:d.trim())||n.text||"File read",l=((h=n.detailText)==null?void 0:h.trim())||n.text||"File read",i=ft(o);return t.jsx(ur,{actionLabel:"Open full file read",actionTitle:"File Read Details",autoOpen:r,className:"thread-graph-event-file-read",icon:t.jsx($.FileText,{className:"h-4 w-4"}),item:n,onOpen:()=>a("File Read Details",l),preview:i,timeMeta:s,title:"file_read",tone:"fileRead"})}),Rf=c.memo(function({threadId:r,item:n,onOpen:a,getImageAssetUrl:s,timeMeta:o}){const l=n.assetPath??n.detailText??null,i=r&&l?(s==null?void 0:s({threadId:r,path:l}))??null:null;return t.jsxs(Kt,{className:"thread-graph-event-image",icon:t.jsx($.Image,{className:"h-4 w-4"}),item:n,timeMeta:o,title:"image",tone:"image",children:[i?t.jsx("button",{type:"button",onClick:()=>a("Image Path",l??n.text),className:"block w-full text-left",children:t.jsx("img",{src:i,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}),l?t.jsx("button",{type:"button",onClick:()=>a("Image Path",l),className:"thread-graph-history-event-path",title:l,children:l}):null]})}),Af=c.memo(function({item:r,onOpen:n,timeMeta:a}){var m,f,p;const s=(m=r.previewText)!=null&&m.trim()&&r.text.trim()!==r.previewText.trim()?r.text.trim():null,o=((f=r.detailText)==null?void 0:f.trim())||null,l=yl(s??((p=r.previewText)==null?void 0:p.trim())??r.text,48),i=kf(r),d=!!(o||r.hasDeferredDetail),h=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:s??l,children:l}),i.length>0&&t.jsx("div",{className:"inline-flex shrink-0 items-center justify-end gap-1.5 text-xs",children:i.map(g=>t.jsx("span",{className:`thread-graph-history-delta-badge ${g.startsWith("+")?"is-add":g.startsWith("-")?"is-remove":"is-neutral"}`,children:g},g))})]}),u=d?t.jsx("button",{type:"button","aria-label":"Open file change details",onClick:()=>n("File Change Details",o??r.text),className:"thread-graph-file-change-inline-button min-w-0 flex-1 text-left",title:s??l,children:h}):h;return t.jsx(Kt,{className:"thread-graph-event-file-change",headerMeta:u,icon:t.jsx($.FilePenLine,{className:"h-4 w-4"}),item:r,timeMeta:a,title:"file_change",tone:"fileChange"})}),Mf=c.memo(function({item:r,onSelect:n,timeMeta:a}){const s=ua(),[o,l]=c.useState(!1),i=r.artifact,d=i?s.renderArtifact({artifact:i,expanded:o,onToggleExpanded:()=>l(h=>!h)}):null;return t.jsx(Kt,{actions:t.jsxs("span",{className:"inline-flex items-center gap-2",children:[i&&!s.hasRendererForArtifact(i)?t.jsx("span",{className:"thread-graph-history-event-secondary",children:"No renderer"}):null,i&&n?t.jsxs("button",{type:"button","aria-label":`Open artifact inspector for ${i.title}`,onClick:()=>n(r,i),className:"thread-graph-history-event-action",children:[t.jsx($.PackageOpen,{className:"h-3.5 w-3.5"}),"Inspect"]}):null]}),className:"thread-graph-event-artifact",icon:t.jsx($.PackageOpen,{className:"h-4 w-4"}),item:r,timeMeta:a,title:(i==null?void 0:i.type)??"artifact",tone:"artifact",children:d??t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:()=>l(h=>!h),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:(i==null?void 0:i.title)??r.text}),t.jsx("span",{className:"thread-graph-history-event-secondary mt-1 block truncate",children:(i==null?void 0:i.summaryText)??r.previewText??r.text})]}),t.jsx("span",{className:"thread-graph-history-event-pill",children:o?"Hide":"Open"})]}),o?t.jsx("pre",{className:"thread-graph-history-event-pre max-h-80 overflow-auto",children:JSON.stringify((i==null?void 0:i.payload)??r,null,2)}):null]})})}),$f=c.memo(function({item:r,timeMeta:n}){var h,u;const a=((h=r.hookOutputEntries)==null?void 0:h.map(m=>m.text.trim()).filter(Boolean).join(`
3701
+ `).trim())??"",s=r.hookEventLabel?`${r.hookEventLabel} hook`:r.text,o=((u=r.hookStatusMessage)==null?void 0:u.trim())||(r.previewText&&r.previewText!==r.hookStatusMessage?r.previewText.trim():"")||r.text.trim(),i=ft(a||(o&&o!==s?o:s)),d=!!(a&&i.showGap);return t.jsx(Kt,{className:"thread-graph-event-hook",icon:t.jsx($.Webhook,{className:"h-4 w-4"}),item:r,timeMeta:n,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:a?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"thread-graph-history-event-secondary mr-2 font-sans text-[11px] uppercase",children:s}),t.jsx(ir,{text:i.firstLine})]}):t.jsx(ir,{text:i.firstLine&&i.firstLine!==s?`${s} · ${i.firstLine}`:s})}),d?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})})}),_f=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s,timeMeta:o}){const l=r.filter(d=>cn(d.status)).length,i=r.length===1?"1 command":`${r.length} commands`;return t.jsx(hr,{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(xf,{}),onToggleExpanded:a,runningIndicator:l>0?t.jsx(Jr,{}):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:i}),l>0?t.jsx("span",{className:"inline-flex items-center text-xs text-amber-100/90",children:t.jsx(Jr,{})}):null]}),timeMeta:o,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} command entries`,children:r.map((d,h)=>{const u=ft(d.text);return t.jsxs("button",{type:"button","aria-label":`Open grouped command ${h+1}`,onClick:()=>s(d,`Command Output ${h+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 ",h+1]}),d.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:d.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:u.firstLine}),u.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},d.id)})})}),Df=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s,timeMeta:o}){var u;const l=r.filter(m=>cn(m.status)).length,i=((u=r[0])==null?void 0:u.kind)??"toolCall",d=i==="agentToolCall"?"agent action":i==="skillToolCall"?"skill call":"tool call",h=r.length===1?`1 ${d}`:`${r.length} ${d}s`;return t.jsx(hr,{className:"thread-graph-history-group-tool",count:r.length,countBadgeClassName:"border-teal-200/35 text-teal-100",desktopIconClassName:"border-teal-300/30 bg-teal-300/[0.14] text-teal-100",expanded:n,expandedListClassName:"border-teal-300/12",icon:i==="agentToolCall"?t.jsx($.Bot,{className:"h-3.5 w-3.5"}):t.jsx($.Wrench,{className:"h-3.5 w-3.5"}),onToggleExpanded:a,runningIndicator:l>0?t.jsx(Jr,{}):null,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-teal-300/28 bg-teal-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-teal-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:h})]}),timeMeta:o,toggleAriaLabel:`${n?"Collapse":"Expand"} ${h}`,children:r.map((m,f)=>{const p=ft(m.text);return t.jsx("button",{type:"button","aria-label":`Open ${d} ${f+1}`,onClick:()=>s(m,`${d} ${f+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 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:p.firstLine}),m.status?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-xs",children:m.status}):null]})},m.id)})})}),Bf=c.memo(function({itemCount:r,expanded:n,onToggleExpanded:a,timeMeta:s,children:o}){const l=r===1?"1 operation":`${r} operations`;return t.jsx(hr,{className:"thread-graph-history-group-activity",count:r,countBadgeClassName:"border-slate-200/35 text-slate-100",desktopIconClassName:"border-slate-300/30 bg-slate-300/[0.14] text-slate-100",expanded:n,expandedListClassName:"border-slate-300/12",icon:t.jsx($.Bot,{className:"h-3.5 w-3.5"}),onToggleExpanded:a,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-sm font-medium text-stone-100",children:"Agent activity"}),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})]}),timeMeta:s,toggleAriaLabel:`${n?"Collapse":"Expand"} ${l}`,children:o})}),Gf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s,timeMeta:o}){const l=r.length===1?"1 search":`${r.length} searches`;return t.jsx(hr,{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(bf,{}),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:l})]}),timeMeta:o,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} web search entries`,children:r.map((i,d)=>{var f,p;const h=((f=i.previewText)==null?void 0:f.trim())||i.text||"Web search",u=ft(h),m=((p=i.detailText)==null?void 0:p.trim())||i.text||"Web search";return t.jsxs("button",{type:"button","aria-label":`Open grouped web search ${d+1}`,onClick:()=>s(`Web Search ${d+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 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 ",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:u.firstLine}),u.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},i.id)})})}),Ff=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s,timeMeta:o}){const l=r.length===1?"1 file read":`${r.length} file reads`;return t.jsx(hr,{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(gf,{}),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:l})]}),timeMeta:o,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} file read entries`,children:r.map((i,d)=>{var f,p;const h=((f=i.previewText)==null?void 0:f.trim())||i.text||"File read",u=ft(h),m=((p=i.detailText)==null?void 0:p.trim())||i.text||"File read";return t.jsxs("button",{type:"button","aria-label":`Open grouped file read ${d+1}`,onClick:()=>s(`File Read ${d+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 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 ",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:u.firstLine}),u.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},i.id)})})}),Hf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s,timeMeta:o}){const l=r.reduce((u,m)=>u+(m.changedFiles??0),0),i=r.reduce((u,m)=>u+(m.addedLines??0),0),d=r.reduce((u,m)=>u+(m.removedLines??0),0),h=r.length===1?"1 file change":`${r.length} file changes`;return t.jsx(hr,{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(ff,{}),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:h}),l>0?t.jsxs("span",{className:"thread-graph-history-detail-meta text-xs",children:[l," files"]}):null]}),timeMeta:o,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} file change entries`,trailingSummary:t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[i>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-add",children:["+",i]}):null,d>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-remove",children:["-",d]}):null]}),children:r.map((u,m)=>{var g,k,w,x;const f=((g=u.detailText)==null?void 0:g.trim())||((k=u.previewText)==null?void 0:k.trim())||u.text,p=(w=u.previewText)!=null&&w.trim()&&u.text.trim()!==u.previewText.trim()?u.text.trim():((x=u.previewText)==null?void 0:x.trim())||u.text;return t.jsx("button",{type:"button","aria-label":`Open grouped file change ${m+1}`,onClick:()=>s(`File Change ${m+1}`,f),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:p,children:yl(p,34)}),t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[(u.addedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-add",children:["+",u.addedLines]}):null,(u.removedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-remove",children:["-",u.removedLines]}):null]})]})},u.id)})})});function Of(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 Wf({status:e}){const r=Of(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(dn,{"aria-label":n,title:n.replace("Plan step status: ",""),className:a,children:r==="completed"?t.jsx($.CheckCircle2,{className:"h-3.5 w-3.5"}):r==="in_progress"?t.jsx($.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):r==="pending"?t.jsx($.Clock3,{className:"h-3.5 w-3.5"}):r==="failed"?t.jsx($.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(dn,{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(Wf,{status:r.status})]},`${e.turnId}-${n}`))})]})}function Vf({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 qf({absoluteIndex:e,body:r,collapsed:n,collapsedBody:a,error:s,footer:o,headerStatus:l,isActive:i=!1,refCallback:d,startedAt:h,timeLabel:u,timeTitle:m,tokenSummary:f}){return t.jsxs("article",{ref:d,"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.jsx("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:h??void 0,title:m,className:"thread-graph-turn-time shrink-0 text-[10px] sm:text-[11px]",children:u}),l,s?t.jsx("p",{className:"hidden truncate text-[11px] text-rose-200 sm:block",children:s}):null]}),f]})}),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 Kf(){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 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.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 Is(){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 Yf(){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 br(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 Nl(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 ar(e){return!Number.isFinite(e)||e<=0?"$0.0000":`$${e.toFixed(4)}`}function Br(e,r,n){const a=e??null;return!Number.isFinite(a??NaN)||a===null||r<=0||n<=0?null:a*n/r}function Cl(e){var d,h,u,m,f,p;const r=(d=e.tokenUsage)==null?void 0:d.total;if(!r)return[];const n=Math.max(r.inputTokens-r.cachedInputTokens-(r.cacheWriteInputTokens??0),0),a=Math.max(r.cachedInputTokens,0),s=Math.max(r.cacheWriteInputTokens??0,0),o=Math.max(r.reasoningOutputTokens,0),l=Math.max(r.outputTokens-o,0);return[n>0?{id:"in",label:"Input",tokenCompactValue:br(n),tokenRawValue:n,usdCompactValue:e.priceEstimate?ar(e.priceEstimate.inputUsd):"--",usdRawValue:((h=e.priceEstimate)==null?void 0:h.inputUsd)??null,className:"token-badge-in",icon:t.jsx(Kf,{})}:null,a>0?{id:"cache",label:"Cached input",tokenCompactValue:br(a),tokenRawValue:a,usdCompactValue:e.priceEstimate?ar(e.priceEstimate.cachedInputUsd):"--",usdRawValue:((u=e.priceEstimate)==null?void 0:u.cachedInputUsd)??null,className:"token-badge-cache",icon:t.jsx(Is,{})}:null,s>0?{id:"cache-write",label:"Cache write",tokenCompactValue:br(s),tokenRawValue:s,usdCompactValue:e.priceEstimate?ar(e.priceEstimate.cacheWriteInputUsd??0):"--",usdRawValue:((m=e.priceEstimate)==null?void 0:m.cacheWriteInputUsd)??null,className:"token-badge-cache",icon:t.jsx(Is,{})}:null,l>0?{id:"out",label:"Output",tokenCompactValue:br(l),tokenRawValue:l,usdCompactValue:e.priceEstimate?ar(Br(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),l)??0):"--",usdRawValue:Br((f=e.priceEstimate)==null?void 0:f.outputUsd,Math.max(r.outputTokens,0),l),className:"token-badge-out",icon:t.jsx(Xf,{})}:null,o>0?{id:"reason",label:"Reasoning",tokenCompactValue:br(o),tokenRawValue:o,usdCompactValue:e.priceEstimate?ar(Br(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),o)??0):"--",usdRawValue:Br((p=e.priceEstimate)==null?void 0:p.outputUsd,Math.max(r.outputTokens,0),o),className:"token-badge-reason",icon:t.jsx(Yf,{})}:null].filter(g=>g!==null)}function Zf(e){return Cl(e).map(r=>({id:r.id,label:r.tokenCompactValue,title:`${r.label}: ${r.tokenRawValue} tokens`,className:r.className,icon:r.icon}))}function Sl(e){return{label:e.priceEstimate?Nl(e.priceEstimate.totalUsd):"--",title:e.priceEstimate===null||e.priceEstimate===void 0?"Price estimate unavailable for this model.":`Estimated cost: ${ar(e.priceEstimate.totalUsd)}`,className:e.priceEstimate?"token-badge-total":"token-badge-empty"}}var Ln="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 Jf({turn:e}){const r=Cl(e),n=Sl(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,k=m.current;if(!g||!k)return;const w=g.getBoundingClientRect(),x=k.offsetWidth||k.getBoundingClientRect().width;if(x<=0)return;const j=window.innerWidth||document.documentElement.clientWidth,y=12,b=w.left+w.width/2-x/2,v=y,S=Math.max(v,j-y-x),N=Math.min(Math.max(b,v),S);d(Math.round(N-b))};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:`${Ln} 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:`${Ln} ${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:`${Ln} 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 Qf({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 zs(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 eg(e){switch(e.kind){case"fileChange":case"webSearch":case"image":case"contextCompaction":return!0;case"commandExecution":case"toolCall":return!ma(e.status);default:return!1}}function tg(e,r,n){if(!e||!yr(n))return e;const a=e.plan.findIndex(i=>zs(i.status)==="in_progress");if(a<0)return e;const s=e.plan.findIndex((i,d)=>d>a&&zs(i.status)==="pending");if(s<0||!r.some(i=>eg(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 rg(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 Ps({status:e}){const r=hl(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(Qf,{tone:"emerald"})})}function Rs({turn:e,variant:r="header"}){const n=hl(e.status),a=rg(e),s=Zf(e),o=Sl(e),l=yr(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(Ps,{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:Ut(e.startedAt),className:"timeline-meta-text shrink-0 text-[11px]",children:kt(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(Ps,{status:e.status}),t.jsx("span",{className:"timeline-meta-text min-w-0 truncate",children:a})]})}function ng(e,r){return e.createdAt??r}var pa=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,timeMeta:p,autoOpenToolDetails:g=!1}){var k,w,x;if(Zp(n.kind))return t.jsx(It,{threadId:r,item:n,scrollRootRef:a,timeLabel:m,timeTitle:f,...h?{onBeforeMessageResize:h}:{},...u?{adapter:u}:{}});if(n.kind==="reasoning")return t.jsx(It,{item:{...n,kind:"agentMessage",status:n.status??null},scrollRootRef:a,timeLabel:m,timeTitle:f,...h?{onBeforeMessageResize:h}:{}});if(n.kind==="artifact")return t.jsx(Mf,{item:n,timeMeta:p,...d?{onSelect:(j,y)=>d({item:j,artifact:y})}:{}});if(n.kind==="commandExecution")return t.jsx(Tf,{autoOpen:g,item:n,onOpen:o,timeMeta:p});if(n.kind==="toolCall")return t.jsx(Ef,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="agentToolCall")return t.jsx(Lf,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="skillToolCall")return t.jsx(If,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="webSearch"){const j=n,y=((k=j.detailText)==null?void 0:k.trim())||j.text||"Web search";return t.jsx(zf,{autoOpen:g,item:j,timeMeta:p,onOpen:()=>i(j,"Web Search Details",y,"Loading full web search details...","Unable to load full web search details.")})}if(n.kind==="fileRead"){const j=n,y=((w=j.detailText)==null?void 0:w.trim())||j.text||"File read";return t.jsx(Pf,{autoOpen:g,item:j,timeMeta:p,onOpen:()=>i(j,"File Read Details",y,"Loading full file read details...","Unable to load full file read details.")})}if(n.kind==="image")return t.jsx(Rf,{threadId:r,item:n,onOpen:s,getImageAssetUrl:u==null?void 0:u.getImageAssetUrl,timeMeta:p});if(n.kind==="plan")return t.jsx(Nf,{item:n,scrollRootRef:a,timeMeta:p,...h?{onBeforeResize:h}:{}});if(n.kind==="fileChange"){const j=n,y=((x=j.detailText)==null?void 0:x.trim())||j.text||"File change";return t.jsx(Af,{item:j,timeMeta:p,onOpen:()=>i(j,"File Change Details",y,"Loading full file change details...","Unable to load full file change details.")})}return n.kind==="contextCompaction"?t.jsx(Cf,{item:n,timeMeta:p}):n.kind==="hook"?t.jsx($f,{item:n,timeMeta:p}):t.jsx(Sf,{item:n,timeMeta:p})});function As(e){return e==="completed"||e==="failed"||e==="interrupted"}function ag(e){const r=Date.parse(e.createdAt??"");return Number.isFinite(r)?r:null}function sg(e){let r=null;for(const n of e){const a=ag(n);a!==null&&(r=r===null?a:Math.max(r,a))}return r}function og(e,r){const n=Date.parse(e??""),a=sg(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 lg(e,r){const n=Date.parse(e??""),a=Date.parse(r??"");if(!Number.isFinite(n)||!Number.isFinite(a))return r?kt(r):"Time unavailable";const s=Math.max(0,Math.round((a-n)/1e3)),o=Math.floor(s/3600),l=Math.floor(s%3600/60),i=s%60;return o>0?`${o}h ${l}m`:l>0?`${l}m ${i}s`:`${i}s`}function Nr({absoluteLabel:e,className:r="",timestamp:n,turnStartedAt:a}){const[s,o]=c.useState(!1);if(!n)return null;const l=Ut(n),i=lg(a,n),d=s?e:i;return t.jsx("span",{role:"button",tabIndex:0,className:`thread-graph-relative-time rounded-full px-1.5 py-0.5 ${r}`,title:s?i:l,"aria-label":`Toggle timestamp, currently ${d}`,onClick:h=>{h.stopPropagation(),o(u=>!u)},onKeyDown:h=>{h.key!=="Enter"&&h.key!==" "||(h.preventDefault(),h.stopPropagation(),o(u=>!u))},children:t.jsx("time",{dateTime:n,children:d})})}function Gt(e){var r;return e.kind==="item"?e.item.createdAt??null:e.kind==="agentActivityGroup"?e.entries[0]?Gt(e.entries[0]):null:((r=e.items.find(n=>n.createdAt))==null?void 0:r.createdAt)??null}function ig(e){const r=e.filter(o=>o.kind==="item"),n=r.map(o=>o.item).filter(o=>o.kind==="userMessage"),a=r.map(o=>o.item).reverse().find(o=>o.kind==="agentMessage"&&o.text.trim().length>0),s=e.filter(o=>o.kind!=="item"?!0:o.item.kind!=="userMessage"&&o.item.id!==(a==null?void 0:a.id));return{users:n,finalAgent:a,hiddenEntries:s}}var In=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:k,onBeforeMessageResize:w,scrollRootRef:x,articleRef:j,isLatestVisibleTurn:y=!1}){const b=!!l||!!d||!!(i&&i.length>0),v=h||yr(a.status)||b||y,S=v&&!yr(a.status)?{...a,status:"inProgress"}:a,N=c.useMemo(()=>tf(a.items,i),[i,a.items]),L=c.useMemo(()=>tg(l,N,a.status),[l,N,a.status]),R=c.useMemo(()=>rf(d,N),[d,N]),P=c.useMemo(()=>ef(N,v),[v,N]),Q=c.useMemo(()=>nf(P),[P]),D=h||yr(a.status)||b,Z=kt(a.startedAt),J=Ut(a.startedAt),z=c.useMemo(()=>gl(R),[R]),[te,se]=c.useState({}),_=c.useCallback(K=>{se(de=>({...de,[K]:!de[K]}))},[]),ie=t.jsx(Tl,{entries:Q,expandedGroups:te,onToggleGroupedItem:_,threadId:r,scrollRootRef:x,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,...w?{onBeforeMessageResize:w}:{},fallbackTimestamp:a.startedAt,fallbackTimeLabel:Z,fallbackTimeTitle:J,turnStartedAt:a.startedAt,autoOpenLatestToolDetails:D,...k?{onSelectArtifact:k}:{},...n?{adapter:n}:{}}),q=z?t.jsx(pa,{threadId:r,item:z,scrollRootRef:x,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,timeLabel:a.startedAt?t.jsx(Nr,{absoluteLabel:Z,timestamp:a.startedAt,turnStartedAt:a.startedAt}):Z,timeTitle:J,timeMeta:null,...k?{onSelectArtifact:k}:{},...n?{adapter:n}:{}}):null,H=!z&&R?t.jsx(It,{item:{id:"live-agent-message",kind:"agentMessage",text:R},scrollRootRef:x,timeLabel:a.startedAt?t.jsx(Nr,{absoluteLabel:Z,timestamp:a.startedAt,turnStartedAt:a.startedAt}):Z,timeTitle:J,streaming:!0,...w?{onBeforeMessageResize:w}:{}}):null,G=v?t.jsx(Rs,{turn:S,variant:"footer"}):null,T=c.useMemo(()=>ig(Q),[Q]),F=c.useMemo(()=>og(a.startedAt,N),[N,a.startedAt]),B=T.hiddenEntries.length>0,E=o&&B,W=As(a.status)&&B&&!E?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,!1),"aria-label":`${F}. Collapse turn ${s}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:F}),t.jsx($.ChevronDown,{className:"h-4 w-4 shrink-0 transition group-hover:translate-y-0.5"}),t.jsx("span",{className:"thread-graph-worked-rule h-px min-w-0 flex-1","aria-hidden":"true"})]}):null,U=As(a.status)&&B?t.jsxs("div",{className:"thread-graph-turn-collapsed-summary space-y-2",children:[T.users.map(K=>t.jsx(It,{threadId:r,item:K,scrollRootRef:x,timeLabel:K.createdAt?kt(K.createdAt):Z,timeTitle:K.createdAt?Ut(K.createdAt):J,...w?{onBeforeMessageResize:w}:{},...n?{adapter:n}:{}},K.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":`${F}. Expand turn ${s}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:F}),t.jsx($.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"})]}),T.finalAgent?t.jsx(It,{threadId:r,item:T.finalAgent,scrollRootRef:x,timeLabel:T.finalAgent.createdAt?t.jsx(Nr,{absoluteLabel:kt(T.finalAgent.createdAt),timestamp:T.finalAgent.createdAt,turnStartedAt:a.startedAt}):Z,timeTitle:T.finalAgent.createdAt?Ut(T.finalAgent.createdAt):J,...w?{onBeforeMessageResize:w}:{},...n?{adapter:n}:{}}):null]}):null,ae=t.jsx(Vf,{footer:G,history:t.jsxs(t.Fragment,{children:[W,ie]}),liveHookPrompt:q,liveOutput:H,livePlan:L});return t.jsx(qf,{absoluteIndex:s,body:ae,collapsed:E,collapsedBody:U,error:a.error,headerStatus:t.jsx(Rs,{turn:a}),isActive:v,refCallback:j,startedAt:a.startedAt,timeLabel:Z,timeTitle:J,tokenSummary:t.jsx(Jf,{turn:a})})});function Tl({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,turnStartedAt:k,autoOpenLatestToolDetails:w=!1}){var y;const x=((y=e.at(-1))==null?void 0:y.key)??null,j=c.useCallback(b=>b?t.jsx(Nr,{absoluteLabel:kt(b),timestamp:b,turnStartedAt:k??f}):null,[f,k]);return t.jsx(mf,{entries:e,expandedGroups:r,onToggleGroupedItem:n,renderCommandGroup:(b,v,S)=>t.jsx(_f,{items:b.items,expanded:v,onToggleExpanded:S,onOpen:l,timeMeta:j(Gt(b))},b.key),renderFileChangeGroup:(b,v,S)=>t.jsx(Hf,{items:b.items,expanded:v,onToggleExpanded:S,onOpen:o,timeMeta:j(Gt(b))},b.key),renderSearchGroup:(b,v,S)=>t.jsx(Gf,{items:b.items,expanded:v,onToggleExpanded:S,onOpen:o,timeMeta:j(Gt(b))},b.key),renderFileReadGroup:(b,v,S)=>t.jsx(Ff,{items:b.items,expanded:v,onToggleExpanded:S,onOpen:o,timeMeta:j(Gt(b))},b.key),renderToolCallGroup:(b,v,S)=>t.jsx(Df,{items:b.items,expanded:v,onToggleExpanded:S,onOpen:i,timeMeta:j(Gt(b))},b.key),renderAgentActivityGroup:(b,v,S)=>t.jsx(Bf,{itemCount:b.itemCount,expanded:v,onToggleExpanded:S,timeMeta:j(Gt(b.entries[0])),children:t.jsx(Tl,{entries:b.entries,expandedGroups:r,onToggleGroupedItem:n,threadId:a,scrollRootRef:s,onOpenExpandedText:o,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,...u?{onBeforeMessageResize:u}:{},fallbackTimestamp:f,fallbackTimeLabel:p,fallbackTimeTitle:g,turnStartedAt:k,autoOpenLatestToolDetails:!1,...h?{onSelectArtifact:h}:{},...m?{adapter:m}:{}})},b.key),renderItem:b=>{const v=ng(b.item,f??null),N=b.item.kind==="userMessage"?b.item.createdAt?kt(v):p:b.item.createdAt?t.jsx(Nr,{absoluteLabel:kt(v),timestamp:v,turnStartedAt:k??f}):p;return t.jsx(pa,{threadId:a,item:b.item,scrollRootRef:s,timeLabel:N,timeTitle:b.item.createdAt?Ut(v):g,timeMeta:j(v),autoOpenToolDetails:w&&b.key===x,onOpenExpandedText:o,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,...u?{onBeforeMessageResize:u}:{},...h?{onSelectArtifact:h}:{},...m?{adapter:m}:{}},b.key)}})}var Ms=3,dg=3,Qn=80;function vr(e,r=Qn){return e.scrollHeight-e.scrollTop-e.clientHeight<=r}function cg(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 hg(e){return e.map(n=>{const a=n.createdAt;return typeof a=="string"&&a.trim()?a:null}).filter(n=>!!n).sort()[0]??null}function ug(e,r){return{id:e,startedAt:hg(r),status:"inProgress",error:null,model:null,reasoningEffort:null,reasoningEffortAvailable:null,tokenUsage:null,priceEstimate:null,items:[]}}function $s(e,r,n){return{id:e.id,kind:e.kind,title:r,text:n}}function mg({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,k)=>{if(k&&r){r({item:p,detail:g});return}o({title:g.title,text:g.text})},[r]),d=c.useCallback(async({item:p,fallbackTitle:g,fallbackText:k,loadingText:w,errorText:x,useSelectionCallback:j})=>{if(!p.hasDeferredDetail||!e){i(p,$s(p,g,k),j);return}const y=a.current.get(p.id);if(y){i(p,y,j);return}const b=n.current+1;n.current=b,j&&r||o({title:g,text:w});try{const v=await e(p.id);if(a.current.set(p.id,v),n.current!==b)return;i(p,v,j)}catch(v){if(n.current!==b)return;i(p,$s(p,g,v instanceof Error?v.message:x),j)}},[e,r,i]),h=c.useCallback(async(p,g)=>{var k;await d({item:p,fallbackTitle:g,fallbackText:((k=p.detailText)==null?void 0:k.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 k;await d({item:p,fallbackTitle:g,fallbackText:((k=p.detailText)==null?void 0:k.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,k,w,x)=>{await d({item:p,fallbackTitle:g,fallbackText:k,loadingText:w,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 pg(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 fg({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),k=c.useRef(0),w=c.useRef(null),x=c.useRef(null),j=c.useRef(null),y=c.useRef(!0),b=c.useRef(!0),v=c.useRef(!1),S=c.useRef(!1),N=c.useRef(!1),L=c.useRef(!1),R=c.useRef(null),P=c.useRef(0),[Q,D]=c.useState(Ms),[Z,J]=c.useState(0),[z,te]=c.useState(!0),se=pg(d),_=typeof s=="function"||n!==void 0,ie=n??r,q=_?0:Math.max(0,r-Q),G=(_?Math.max(0,ie-r):0)+q,T=_?r:r-q,F=_?0:r-T,B=_?Math.max(0,ie-r):0,E=_?B+F:F,C=!_&&E>0&&Z>=2,W=_&&B>0&&F===0&&typeof s=="function",U=c.useCallback(()=>{const Y=h.current;if(!Y){w.current=null;return}w.current={scrollHeight:Y.scrollHeight,scrollTop:Y.scrollTop}},[]),ae=c.useCallback(()=>!W||a||N.current?!1:(U(),N.current=!0,L.current=!1,P.current=0,s==null||s(),!0),[W,a,s,U]),K=c.useCallback(()=>{const Y=h.current,me=x.current;if(!Y)return;const we=me?cg(Y,me):vr(Y);y.current=we,te(ye=>ye===we?ye:we)},[]),de=c.useCallback(()=>{const Y=h.current;if(Y){S.current=!0;const me=Y.scrollTop,we=k.current,ye=me-we;k.current=me,vr(Y,1)?(v.current=!1,b.current=!0):ye<-1?(v.current=!0,b.current=!1):ye>1&&(b.current=!v.current&&vr(Y,Qn)),me<=0&&S.current?L.current=!0:me>0&&(L.current=!1,P.current=0)}K()},[K]),ee=c.useCallback(()=>{const Y=h.current;Y&&(Y.scrollTop=Y.scrollHeight,k.current=Y.scrollTop,g.current=Y.scrollHeight,y.current=!0,te(me=>me||!0),v.current=!1,b.current=!0)},[]),ke=c.useCallback(()=>{const Y=h.current;Y&&(k.current=Y.scrollTop,g.current=Y.scrollHeight,b.current=!1,v.current=!0)},[]),le=c.useCallback(()=>{if(_&&F===0){ae();return}D(Y=>Math.min(r,Y+dg)),J(Y=>Y+1)},[F,_,ae,r]),je=c.useCallback(Y=>{const me=h.current;if(!(!me||Y.deltaY>=-8||me.scrollTop>0||!W)){if(!L.current){L.current=!0;return}ae()}},[W,ae]),Ae=c.useCallback(Y=>{var me;R.current=((me=Y.touches.item(0))==null?void 0:me.clientY)??null,P.current=0},[]),ce=c.useCallback(Y=>{var Be;const me=h.current,we=((Be=Y.touches.item(0))==null?void 0:Be.clientY)??null,ye=R.current;if(R.current=we,!me||we===null||ye===null||me.scrollTop>0||!W){P.current=0;return}const De=we-ye;if(De<=0){P.current=0;return}if(!L.current){L.current=!0,P.current=0;return}P.current+=De,P.current>=28&&ae()},[W,ae]),ne=c.useCallback(()=>{R.current=null,P.current=0},[]),Le=c.useCallback(()=>{D(r)},[r]);return c.useLayoutEffect(()=>{const Y=window.requestAnimationFrame(()=>{ee()});return()=>{window.cancelAnimationFrame(Y)}},[e,ee]),c.useEffect(()=>{N.current=!1,S.current=!1,L.current=!1,w.current=null},[e]),c.useEffect(()=>{a||(N.current=!1)},[a,r]),c.useLayoutEffect(()=>{const Y=w.current,me=h.current;if(!Y||!me||a)return;w.current=null;const we=me.scrollHeight-Y.scrollHeight;if(we<=0){g.current=me.scrollHeight,k.current=me.scrollTop;return}const ye=Y.scrollTop+we;me.scrollTop=ye,k.current=ye,g.current=me.scrollHeight,v.current=!0,b.current=!1,L.current=!1},[a,r]),c.useEffect(()=>{D(Y=>Y>=r-1?r:Math.max(Y,Ms))},[r]),c.useEffect(()=>{const Y=h.current;Y&&(g.current=Y.scrollHeight,k.current=Y.scrollTop,vr(Y,1)?(v.current=!1,b.current=!0):(v.current||!vr(Y,Qn))&&(b.current=!1)),K()},[se,K,Q]),c.useEffect(()=>{const Y=o!==m.current,me=f.current!==se;if(f.current=se,!(Y||me&&b.current&&!v.current))return;const ye=window.requestAnimationFrame(()=>{ee()});return o!==m.current&&(m.current=o),()=>{window.cancelAnimationFrame(ye)}},[se,z,ee,o]),c.useEffect(()=>{const Y=h.current,me=u.current;if(!Y||!me||typeof ResizeObserver>"u")return;g.current=Y.scrollHeight;const we=new ResizeObserver(()=>{const ye=Y.scrollHeight,De=g.current;if(g.current=ye,ye<=De)return;const Be=De>0&&De-Y.scrollTop-Y.clientHeight<=1;v.current||!(b.current||Be||y.current)||window.requestAnimationFrame(()=>{ee()})});return we.observe(me),()=>{we.disconnect()}},[ee]),c.useEffect(()=>{if(!b.current||v.current){p.current=l;return}if(l===p.current)return;p.current=l;const Y=window.requestAnimationFrame(()=>{ee()});return()=>{window.cancelAnimationFrame(Y)}},[l,ee]),c.useEffect(()=>{i==null||i(z)},[z,i]),{scrollContainerRef:h,scrollContentRef:u,tailSentinelRef:x,topSentinelRef:j,isTailVisible:z,handleScroll:de,handleWheel:je,handleTouchStart:Ae,handleTouchMove:ce,handleTouchEnd:ne,preserveScrollPositionForResize:ke,serverManagedHistory:_,effectiveTotalTurnCount:ie,startIndex:q,visibleTurnAbsoluteOffset:G,hiddenCount:E,loadedHiddenCount:F,unloadedHiddenCount:B,showLoadAll:C,handleLoadEarlierClick:le,handleLoadAllClick:Le}}function gg(e){return e==="completed"||e==="failed"||e==="interrupted"}function xg(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 bg({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,previousTurnScrollRequestKey:p=0,nextTurnScrollRequestKey:g=0,bottomSpacer:k=0,className:w="",onTailVisibilityChange:x,onPreviousTurnAvailabilityChange:j,onNextTurnAvailabilityChange:y,loadingEarlier:b=!1,onLoadEarlier:v,ephemeralUserNote:S=null,answeredRequestNotes:N=[],activityNotes:L=[],optimisticSteers:R=[],optimisticTurn:P=null,onLoadHistoryItemDetail:Q,onOpenThread:D,onSelectArtifact:Z,onSelectHistoryItemDetail:J,adapter:z,autoCollapseCompletedTurns:te}){var st,ct,xt,Rt,wt;const se=cl(),_=te??(se==null?void 0:se.autoCollapseCompletedTurns)??!1,[ie,q]=c.useState({}),[H,G]=c.useState(()=>new Set),T=c.useRef(null),F=c.useRef(null),B=(z==null?void 0:z.onLoadHistoryItemDetail)??Q,E=z==null?void 0:z.onOpenLinkedThread,{expandedText:C,openExpandedText:W,openCommandDetail:U,openToolCallDetail:ae,openDeferredHistoryItemDetail:K,closeExpandedText:de}=mg({loadHistoryItemDetail:B,onSelectHistoryItemDetail:J}),{scrollContainerRef:ee,scrollContentRef:ke,tailSentinelRef:le,topSentinelRef:je,handleScroll:Ae,handleWheel:ce,handleTouchStart:ne,handleTouchMove:Le,handleTouchEnd:Y,preserveScrollPositionForResize:me,serverManagedHistory:we,effectiveTotalTurnCount:ye,startIndex:De,visibleTurnAbsoluteOffset:Be,hiddenCount:_e,loadedHiddenCount:Oe,unloadedHiddenCount:V,showLoadAll:he,handleLoadEarlierClick:ve,handleLoadAllClick:I}=fg({threadId:e,turnsLength:r.length,totalTurnCount:n,loadingEarlier:b,onLoadEarlier:v,scrollRequestKey:f,bottomSpacer:k,onTailVisibilityChange:x,contentRevisionInputs:[r,a,l,R,m,i,d,P,N,L,S,k]}),O=c.useCallback((M,fe)=>{q(ze=>({...ze,[M]:!fe}))},[]),oe=c.useCallback((M,fe)=>{const ze=ie[M.id];return ze!==void 0?ze:!!(_&&gg(M.status)&&!fe.forceActive&&!fe.hasLiveActivity)},[ie,_]),ge=we?r:r.slice(De),Ne=ye+1,Ce=o&&(!s||!ge.some(M=>M.id===s)&&(P==null?void 0:P.id)!==s),xe=(P==null?void 0:P.id)??((st=ge.at(-1))==null?void 0:st.id)??null,Ge=Ce&&xe!==null,Me=!!d&&(ge.some(M=>M.id===d.turnId)||(P==null?void 0:P.id)===d.turnId),Qe=d&&Me?d.turnId:d&&Ge?xe:null,et=P&&Qe===P.id?(d==null?void 0:d.items)??null:null,it=((d==null?void 0:d.items.length)??0)>0,tt=d&&Qe===null?d.items:null,Ke=c.useMemo(()=>d&&Qe===null&&d.items.length>0?ug(d.turnId,d.items):null,[d,Qe]),dt=Math.max(1,ye+(P?1:0)),gt=!!m&&!!P&&P.status!=="failed"&&!et,Ve=m&&ge.length>0?s&&ge.some(M=>M.id===s)?s:((ct=ge.findLast(M=>ma(M.status)))==null?void 0:ct.id)??(Ge?xe:null):null,A=!!Ve,X=c.useMemo(()=>gl(m),[m]),be=[...l.map(M=>({id:M.id,prompt:M.prompt,status:"Accepted",createdAt:M.createdAt,canCancel:!0})),...R.map(M=>({id:M.id,prompt:M.prompt,status:M.status==="steering"?"Steering":null,createdAt:M.createdAt,canCancel:!1}))].sort((M,fe)=>M.createdAt.localeCompare(fe.createdAt)),Se=c.useMemo(()=>df({answeredRequestNotes:N,pendingRequests:a,visibleTurns:ge,optimisticTurn:P}),[N,P,a,ge]),Pe=c.useMemo(()=>cf({activityNotes:L,visibleTurns:ge,optimisticTurn:P}),[L,P,ge]),rt=c.useCallback(()=>{const M=ee.current;if(!M)return null;const fe=M.getBoundingClientRect().top;return Array.from(M.querySelectorAll("[data-timeline-turn]")).find(ze=>ze.getBoundingClientRect().top>fe+8)??null},[ee]),nt=c.useCallback(()=>{const M=ee.current;if(!M)return null;const fe=M.getBoundingClientRect().top;return Array.from(M.querySelectorAll("[data-timeline-turn]")).findLast(ze=>ze.getBoundingClientRect().top<fe-8)??null},[ee]),$e=c.useCallback(()=>{j==null||j(!!nt())},[nt,j]),We=c.useCallback(()=>{y==null||y(!!rt())},[rt,y]),ut=c.useCallback(()=>{Ae(),$e(),We()},[Ae,We,$e]);return c.useEffect(()=>{$e(),We()},[We,$e,ge]),c.useEffect(()=>{if(p===0)return;const M=ee.current,fe=nt(),ze=M?Array.from(M.querySelectorAll("[data-timeline-turn]")):[],Fe=fe?ze.indexOf(fe):-1,Ue=fe&&fe.dataset.turnId===T.current?ze[Fe-1]??null:fe;if(!M||!Ue)return;T.current=Ue.dataset.turnId??null;const mt=Ue.getBoundingClientRect().top-M.getBoundingClientRect().top;M.scrollTo({top:M.scrollTop+mt-8,behavior:"smooth"}),ze.indexOf(Ue)===0&&(j==null||j(!1))},[nt,j,p,ee]),c.useEffect(()=>{if(g===0)return;const M=ee.current,fe=rt(),ze=M?Array.from(M.querySelectorAll("[data-timeline-turn]")):[],Fe=fe?ze.indexOf(fe):-1,Ue=fe&&fe.dataset.turnId===F.current?ze[Fe+1]??null:fe;if(!M||!Ue)return;F.current=Ue.dataset.turnId??null;const mt=Ue.getBoundingClientRect().top-M.getBoundingClientRect().top;M.scrollTo({top:M.scrollTop+mt-8,behavior:"smooth"}),ze.indexOf(Ue)===ze.length-1&&(y==null||y(!1))},[rt,g,y,ee]),t.jsxs(t.Fragment,{children:[t.jsx("section",{className:`flex min-h-0 flex-1 flex-col ${w}`.trim(),children:t.jsx("div",{ref:ee,"data-testid":"thread-scroll-container",onScroll:ut,onWheel:ce,onTouchStart:ne,onTouchMove:Le,onTouchEnd:Y,onTouchCancel:Y,className:"thread-graph-scroll-container min-h-0 flex-1 overflow-y-auto overscroll-contain",style:k>0?{paddingBottom:k}:void 0,children:t.jsxs("div",{ref:ke,className:"thread-graph-scroll-content",children:[t.jsx("div",{ref:je,"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:[_e>0&&t.jsx("button",{type:"button",onClick:ve,disabled:b,className:"thread-graph-history-button rounded-full border px-2.5 py-1.5 transition",children:b?"Loading earlier...":"Load 3 earlier"}),he&&t.jsx("button",{type:"button",onClick:I,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 ",ge.length," of ",ye," turns",_e>0?` · ${_e} earlier hidden${Oe>0&&V>0?` (${Oe} loaded)`:""}`:""]})]})}),r.length===0&&!m&&!P&&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."}),(ge.length>0||P||Pe.leading.length>0||Pe.trailing.length>0)&&t.jsxs("div",{className:"thread-graph-message-list",children:[Pe.leading.length>0?t.jsx(xr,{notes:Pe.leading,onOpenThread:D,onOpenLinkedThread:E}):null,ge.map((M,fe)=>{var ze,Fe,Ue,mt,yt;return t.jsxs("div",{"data-timeline-turn":!0,"data-turn-id":M.id,children:[(((ze=Pe.beforeTurnId.get(M.id))==null?void 0:ze.length)??0)>0?t.jsx(xr,{notes:Pe.beforeTurnId.get(M.id)??[],onOpenThread:D,onOpenLinkedThread:E}):null,(((Fe=Se.beforeTurnId.get(M.id))==null?void 0:Fe.length)??0)>0?t.jsx(Jn,{entries:Se.beforeTurnId.get(M.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const Xt=xg(M,P),Yt=(i==null?void 0:i.turnId)===M.id?i:null,At=Qe===M.id?(d==null?void 0:d.items)??null:null,mr=Ve===M.id?m:"",ot=s===M.id||Ge&&xe===M.id,un=!!Yt||!!mr||!!(At&&At.length>0),mn=oe(Xt,{forceActive:ot,hasLiveActivity:un});return t.jsx(In,{threadId:e,...z?{adapter:z}:{},turn:Xt,absoluteIndex:Be+fe+1,isCollapsed:mn,livePlan:Yt,liveItems:At,liveOutput:mr,forceActive:ot,onToggleCollapse:O,onOpenExpandedText:W,onOpenCommandDetail:U,onOpenToolCallDetail:ae,onOpenDeferredHistoryItemDetail:K,onBeforeMessageResize:me,...Z?{onSelectArtifact:Z}:{},scrollRootRef:ee,articleRef:void 0})})(),(((Ue=Pe.afterTurnId.get(M.id))==null?void 0:Ue.length)??0)>0?t.jsx(xr,{notes:Pe.afterTurnId.get(M.id)??[],onOpenThread:D,onOpenLinkedThread:E}):null,(mt=Se.notesByTurnId.get(M.id))!=null&&mt.length||(yt=Se.pendingRequestsByTurnId.get(M.id))!=null&&yt.length?t.jsx(hf,{notes:Se.notesByTurnId.get(M.id)??[],requests:Se.pendingRequestsByTurnId.get(M.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null]},M.id)}),P&&ge.every(M=>M.id!==P.id)&&t.jsxs(t.Fragment,{children:[(((xt=Pe.beforeTurnId.get(P.id))==null?void 0:xt.length)??0)>0?t.jsx(xr,{notes:Pe.beforeTurnId.get(P.id)??[],onOpenThread:D,onOpenLinkedThread:E}):null,(((Rt=Se.beforeTurnId.get(P.id))==null?void 0:Rt.length)??0)>0?t.jsx(Jn,{entries:Se.beforeTurnId.get(P.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const M=gt?m:"",fe=s===P.id||Ge&&xe===P.id,ze=!!(et&&et.length>0)||!!M,Fe=oe(P,{forceActive:fe,hasLiveActivity:ze});return t.jsx(In,{threadId:e,...z?{adapter:z}:{},turn:P,absoluteIndex:Ne,isCollapsed:Fe,livePlan:null,liveItems:et,liveOutput:M,forceActive:fe,onToggleCollapse:O,onOpenExpandedText:W,onOpenCommandDetail:U,onOpenToolCallDetail:ae,onOpenDeferredHistoryItemDetail:K,onBeforeMessageResize:me,...Z?{onSelectArtifact:Z}:{},scrollRootRef:ee})})(),(((wt=Pe.afterTurnId.get(P.id))==null?void 0:wt.length)??0)>0?t.jsx(xr,{notes:Pe.afterTurnId.get(P.id)??[],onOpenThread:D,onOpenLinkedThread:E}):null]})]}),be.length>0&&t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:be.map(M=>t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(It,{threadId:e,item:{id:M.id,kind:"userMessage",text:M.prompt,status:M.status},scrollRootRef:ee,onBeforeMessageResize:me,...z?{adapter:z}:{}}),e&&M.canCancel&&(z!=null&&z.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:H.has(M.id),onClick:()=>{var fe;G(ze=>new Set(ze).add(M.id)),Promise.resolve((fe=z.cancelPendingSteer)==null?void 0:fe.call(z,e,M.id)).catch(()=>{}).finally(()=>{G(ze=>{const Fe=new Set(ze);return Fe.delete(M.id),Fe})})},children:H.has(M.id)?"Canceling...":"Cancel"})}):null]},M.id))}),(Se.trailing.length>0||Pe.trailing.length>0)&&t.jsx(uf,{entries:[...Pe.trailing.map(M=>({kind:"activity",id:M.id,createdAt:M.createdAt,note:M})),...Se.trailing],respondingRequestId:h,onRespondToRequest:u??void 0,onOpenThread:D,onOpenLinkedThread:E}),S&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:t.jsx(It,{threadId:e,item:{id:"ephemeral-plan-decision-note",kind:"userMessage",text:S},scrollRootRef:ee,onBeforeMessageResize:me})}),Ke&&tt&&tt.length>0&&t.jsx(In,{threadId:e,...z?{adapter:z}:{},turn:Ke,absoluteIndex:dt,isCollapsed:ie[Ke.id]??!1,livePlan:(i==null?void 0:i.turnId)===Ke.id?i:null,liveItems:tt,liveOutput:"",forceActive:!0,onToggleCollapse:O,onOpenExpandedText:W,onOpenCommandDetail:U,onOpenToolCallDetail:ae,onOpenDeferredHistoryItemDetail:K,onBeforeMessageResize:me,...Z?{onSelectArtifact:Z}:{},scrollRootRef:ee}),m&&!A&&!gt&&!it&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:X?t.jsx(pa,{threadId:e,item:X,scrollRootRef:ee,onOpenExpandedText:W,onOpenCommandDetail:U,onOpenToolCallDetail:ae,onOpenDeferredHistoryItemDetail:K,onBeforeMessageResize:me,...Z?{onSelectArtifact:Z}:{},...z?{adapter:z}:{}}):t.jsx(It,{threadId:e,item:{id:"live-agent-message-fallback",kind:"agentMessage",text:m},scrollRootRef:ee,streaming:!0,onBeforeMessageResize:me,...z?{adapter:z}:{}})}),t.jsx("div",{ref:le,"aria-hidden":"true",className:"h-px w-full"})]})})}),t.jsx(wp,{open:C!==null,title:(C==null?void 0:C.title)??"Full text",text:(C==null?void 0:C.text)??"",onClose:de})]})}var El=c.memo(bg);function vg(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}function ea(e){return e.replace(/\r\n/g,`
3702
+ `)}function _s(e){const r=ea(e),n=r.split(`
3701
3703
  `);return r.endsWith(`
3702
- `)&&n.at(-1)===""&&n.pop(),n}function hg(e){const r=e.trim();return r?/(?:[$%#>])\s*$/.test(r):!1}function ug(e,r){const n=r.trim();if(!n||e.length===0)return e;const[a,...o]=e;if(a===void 0)return e;const s=a.trim();return s===n||s.endsWith(` ${n}`)||s.endsWith(`$ ${n}`)||s.endsWith(`% ${n}`)||s.endsWith(`# ${n}`)||s.endsWith(`> ${n}`)?o:e}function mg(e,r,n){var d,h;const a=Ms(e),o=Ms(r);let s=0;for(;s<a.length&&s<o.length&&a[s]===o[s];)s+=1;let l=0;for(;l<a.length-s&&l<o.length-s&&a[a.length-1-l]===o[o.length-1-l];)l+=1;let i=o.slice(s,o.length-l);for(i=ug(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())===""||hg(i.at(-1)??""));)i.pop();return i.join(`
3703
- `).trimEnd()}function pg(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 As(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 En(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 ln(e){if(!e)return"";const r=e.replace(/[\\/]+$/,"");return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function ma(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 Ln(e){return Math.min(75,Math.max(25,e))}function fg(){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 gg({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 _s(){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 In({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 xg=120,bg=800,vg=4e3,kg=4500,wg="Shell connection timed out. Reconnecting...";function yg({isCurrentSocket:e,viewerId:r}){return!e||r?null:{connectionError:wg,isConnecting:!1,settleAttachPromise:!1,closeSocket:!0}}function jg({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 Cg({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:o}){return e?{shouldDetachShell:r,shouldScheduleReconnect:Ng({intentionalDisconnect:n,userDisconnectedShellId:a,shellId:o})}:null}function Sg({hasAttachSize:e,hasPendingRetry:r}){return!e&&!r}function Sl({shellId:e,terminalReady:r,isVisible:n,canAttachShell:a,userDisconnectedShellId:o,hasTerminal:s,attachSize:l,hasPendingAttachRetry:i,hasCurrentSocketForShell:d,hasReconnectTimer:h}){return!e||!r||!n||!a||o===e||!s?{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 Tg({hasShellId:e,terminalReady:r,workspacePathMissing:n,hasViewer:a,hasPendingAttach:o}){return!e||!r||n?{type:"reject"}:a?{type:"alreadyConnected"}:o?{type:"joinPending"}:{type:"startAttach"}}function Eg({shellId:e,userDisconnectedShellId:r}){return{shouldClearUserDisconnectedShellId:!!e&&r===e,intentionalDisconnect:!1,connectionError:null,isConnecting:!0,shouldIncrementReconnectKey:!0}}function Lg({hasShell:e}){return e?null:{viewerId:null,isConnecting:!1,settleAttachPromise:!1,connectionError:null,runtimePromptLabel:null,isCommandRunning:!1,shellSnapshot:"",lastCommandOutput:"",pendingCommand:null,shouldResetTerminal:!0}}function Ig({hasReconnectTimer:e,hasAttachTimeout:r,hasAttachRetry:n}){return{shouldClearReconnectTimer:e,shouldClearAttachTimeout:r,shouldClearAttachRetry:n,settleAttachPromise:!1}}function Tl({shellId:e,viewerId:r}){return e&&r?{type:"shell.detach",shellId:e,viewerId:r}:null}function zg({shellId:e,viewerId:r,hasSocket:n}){return{userDisconnectedShellId:e,intentionalDisconnect:!0,detachMessage:Tl({shellId:e,viewerId:r}),shouldCloseSocket:n,shouldClearSocketRef:!0,shouldClearLastSentSize:!0,shouldDetachShell:!!e}}function Pg({shellId:e,viewerId:r,socketReadyState:n,openReadyState:a,hasAttachRetryTimer:o,hasAttachTimeout:s,isCurrentSocket:l}){const i=Tl({shellId:e,viewerId:r});return{intentionalDisconnect:!0,shouldClearAttachRetry:o,detachMessage:i,shouldSendDetachMessage:!!(i&&n===a),shouldClearViewer:!0,isConnecting:!1,settleAttachPromise:l?!1:void 0,shouldClearAttachTimeout:s,shouldCloseSocket:!0,shouldClearSocketRef:l}}function Rg({size:e,previousSize:r,shellId:n,viewerId:a,syncBackendSize:o}){return o?(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:ma(n??ln(r),a),isCommandRunning:e.isCommandRunning===!0}}function Ag({currentSnapshot:e,data:r,replace:n,isCommandRunning:a,pendingCommand:o}){if(!r)return{nextSnapshot:e,nextPendingCommand:o,lastCommandOutput:null};const s=Jn(n?r:`${e}${r}`);return!n||a||!o?{nextSnapshot:s,nextPendingCommand:o,lastCommandOutput:null}:{nextSnapshot:s,nextPendingCommand:null,lastCommandOutput:mg(o.beforeSnapshot,s,o.command)}}function _g({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 o=String(e.payload.reason??"");return{viewerId:null,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:!1,connectionError:o==="replaced"?"This shell connection was taken over by another pane or device.":null,intentionalDisconnect:o==="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 El(e,r,n,a,o){const s=r.replace(/\r\n/g,`
3704
- `),l=s.split(`
3705
- `);s.endsWith(`
3704
+ `)&&n.at(-1)===""&&n.pop(),n}function kg(e){const r=e.trim();return r?/(?:[$%#>])\s*$/.test(r):!1}function wg(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 yg(e,r,n){var d,h;const a=_s(e),s=_s(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=wg(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())===""||kg(i.at(-1)??""));)i.pop();return i.join(`
3705
+ `).trimEnd()}function jg(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 Ds(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 zn(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 hn(e){if(!e)return"";const r=e.replace(/[\\/]+$/,"");return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function fa(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 Pn(e){return Math.min(75,Math.max(25,e))}function Ng(){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 Cg({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 Bs(){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 Rn({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 Sg=120,Tg=800,Eg=4e3,Lg=4500,Ig="Shell connection timed out. Reconnecting...";function zg({isCurrentSocket:e,viewerId:r}){return!e||r?null:{connectionError:Ig,isConnecting:!1,settleAttachPromise:!1,closeSocket:!0}}function Pg({isCurrentSocket:e,shellId:r,attachSize:n}){return e?{message:{type:"shell.attach",shellId:r,cols:n.cols,rows:n.rows},shouldScheduleAttachTimeout:!0}:null}function Rg({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:Rg({intentionalDisconnect:n,userDisconnectedShellId:a,shellId:s})}:null}function Mg({hasAttachSize:e,hasPendingRetry:r}){return!e&&!r}function Ll({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}:Mg({hasAttachSize:!1,hasPendingRetry:i})?{type:"scheduleRetry"}:{type:"skip"}}function $g({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 _g({shellId:e,userDisconnectedShellId:r}){return{shouldClearUserDisconnectedShellId:!!e&&r===e,intentionalDisconnect:!1,connectionError:null,isConnecting:!0,shouldIncrementReconnectKey:!0}}function Dg({hasShell:e}){return e?null:{viewerId:null,isConnecting:!1,settleAttachPromise:!1,connectionError:null,runtimePromptLabel:null,isCommandRunning:!1,shellSnapshot:"",lastCommandOutput:"",pendingCommand:null,shouldResetTerminal:!0}}function Bg({hasReconnectTimer:e,hasAttachTimeout:r,hasAttachRetry:n}){return{shouldClearReconnectTimer:e,shouldClearAttachTimeout:r,shouldClearAttachRetry:n,settleAttachPromise:!1}}function Il({shellId:e,viewerId:r}){return e&&r?{type:"shell.detach",shellId:e,viewerId:r}:null}function Gg({shellId:e,viewerId:r,hasSocket:n}){return{userDisconnectedShellId:e,intentionalDisconnect:!0,detachMessage:Il({shellId:e,viewerId:r}),shouldCloseSocket:n,shouldClearSocketRef:!0,shouldClearLastSentSize:!0,shouldDetachShell:!!e}}function Fg({shellId:e,viewerId:r,socketReadyState:n,openReadyState:a,hasAttachRetryTimer:s,hasAttachTimeout:o,isCurrentSocket:l}){const i=Il({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 Hg({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 Og(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:fa(n??hn(r),a),isCommandRunning:e.isCommandRunning===!0}}function Wg({currentSnapshot:e,data:r,replace:n,isCommandRunning:a,pendingCommand:s}){if(!r)return{nextSnapshot:e,nextPendingCommand:s,lastCommandOutput:null};const o=ea(n?r:`${e}${r}`);return!n||a||!s?{nextSnapshot:o,nextPendingCommand:s,lastCommandOutput:null}:{nextSnapshot:o,nextPendingCommand:null,lastCommandOutput:yg(s.beforeSnapshot,o,s.command)}}function Ug({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 zl(e,r,n,a,s){const o=r.replace(/\r\n/g,`
3706
+ `),l=o.split(`
3707
+ `);o.endsWith(`
3706
3708
  `)&&l.at(-1)===""&&l.pop();let d=l.join(`\r
3707
- `);if(n!==void 0&&a!==void 0){const u=(o!==void 0?Math.max(0,l.length-o):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 $s(e){return e?Array.from(e.querySelectorAll(".xterm-rows > div")).map(n=>n.textContent??"").filter((n,a,o)=>n.length>0||a<o.length-1).join(`
3708
- `).trimEnd():""}function $g({clearTimeout:e}){let r=null;const n=o=>{(o==null?void 0:o.timer)!==null&&(o==null?void 0:o.timer)!==void 0&&e(o.timer)};return{hasPending:()=>!!r,joinPending:()=>new Promise(o=>{r==null||r.waiters.push(o)}),start:({timeoutMs:o,setTimeout:s,onTimeout:l})=>new Promise(i=>{const d=s(()=>{r=null,l(),i(!1)},o);r={waiters:[i],timer:d}}),settle:o=>{const s=r;if(s){r=null,n(s);for(const l of s.waiters)l(o)}},clear:()=>{const o=r;r=null,n(o)}}}var Ds={status:"not_created",shellInputEnabled:!1,isConnecting:!1,isCommandRunning:!1,promptLabel:null,error:null,hasShell:!1};function bt(e){return e.status!=="exited"&&e.status!=="not_found"}function Dg({shell:e,workspacePathMissing:r}){return!!(e&&!r&&bt(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 Gg(e){return(e.activeShellId?e.shells.find(r=>r.id===e.activeShellId&&bt(r)):null)??(e.shell&&bt(e.shell)?e.shell:null)??e.shells.find(bt)??null}function Fg({activeRuntime:e,activeShell:r,busy:n,loading:a,status:o,workspacePathMissing:s}){const l=n||a||o==="creating"||s,i=e.shellInputEnabled?"Disconnect shell":r&&!bt(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&&!bt(r)?"border-stone-600 bg-stone-800/90 text-stone-100 hover:border-stone-500 hover:bg-stone-800":s?"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 Hg({activeRuntime:e,activeShell:r,connectionButtonDisabled:n,connectionButtonLabel:a,isMobileShell:o,busy:s,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?ma(ln(r.cwd),null):null),isMobileShell:o,hasShell:!!r,busy:s,loading:l,error:e.error??i}}function Ht(e){return e.current===null?!1:(window.clearTimeout(e.current),e.current=null,!0)}function Og({attachRetryTimerRef:e,setReconnectKey:r,delayMs:n=xg}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function Wg({reconnectTimerRef:e,setReconnectKey:r,delayMs:n=bg}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function Ug({shellSocket:e,socketRef:r,viewerIdRef:n,attachTimeoutRef:a,setConnectionError:o,setIsConnecting:s,settleAttachPromise:l,delayMs:i=vg}){a.current=window.setTimeout(()=>{var h,u,m;a.current=null;const d=yg({isCurrentSocket:!e.socket||((h=r.current)==null?void 0:h.socket)===e.socket,viewerId:n.current});d&&(o(d.connectionError),s(d.isConnecting),l(d.settleAttachPromise),d.closeSocket&&((u=e.close)==null||u.call(e),(m=e.socket)==null||m.close()))},i)}function Vg(e){return{...e,status:e.status==="attached"?"detached":e.status,attachedViewerId:null}}function qg({shellId:e,viewerId:r,shellSocket:n,attachRetryTimerRef:a,attachTimeoutRef:o,socketRef:s,openReadyState:l}){var i;return Pg({shellId:e,viewerId:r,socketReadyState:n.socket.readyState,openReadyState:l,hasAttachRetryTimer:a.current!==null,hasAttachTimeout:o.current!==null,isCurrentSocket:((i=s.current)==null?void 0:i.socket)===n.socket})}function Kg({closeApplication:e,shellId:r,attachTimeoutRef:n,socketRef:a,reconnectTimerRef:o,setViewerId:s,setIsConnecting:l,settleAttachPromise:i,onShellUpdate:d,setReconnectKey:h}){const u=e.closeAction;return u?(e.shouldClearAttachTimeout&&Ht(n),e.shouldClearSocketRef&&(a.current=null),s(e.viewerId),l(e.isConnecting),i(e.settleAttachPromise),u.shouldDetachShell&&d(r,Vg,"detached"),u.shouldScheduleReconnect&&Wg({reconnectTimerRef:o,setReconnectKey:h}),!0):!1}function Xg({cleanupAction:e,shellSocket:r,attachRetryTimerRef:n,attachTimeoutRef:a,socketRef:o,intentionalDisconnectRef:s,setViewerId:l,setIsConnecting:i,settleAttachPromise:d}){s.current=e.intentionalDisconnect,e.shouldClearAttachRetry&&Ht(n),e.shouldSendDetachMessage&&e.detachMessage&&r.send(e.detachMessage),l(null),i(e.isConnecting),e.settleAttachPromise!==void 0&&d(e.settleAttachPromise),e.shouldClearAttachTimeout&&Ht(a),r.socket.close(),e.shouldClearSocketRef&&(o.current=null)}function Yg({eventShellId:e,shellId:r,socketExists:n,isCurrentSocket:a}){return n&&!a?!1:e===r}function Zg(e){return Sl({...e,attachSize:void 0})}function Jg({attachSize:e,...r}){return Sl({...r,attachSize:e})}function Qg({isCurrentSocket:e,shellId:r,attachSize:n,hasAttachTimeout:a}){const o=jg({isCurrentSocket:e,shellId:r,attachSize:n});return{openAction:o,shouldClearAttachTimeout:!!(o&&a)}}function ex(e){const r=String(e.payload.viewerId??"");return{viewerId:r||null,settleAttachPromise:!!r,nextShell:n=>({...n,status:"attached",attachedViewerId:r})}}function tx({event:e,shellCwd:r,currentSnapshot:n,pendingCommand:a}){const o=Mg(e.payload,r),s=o.data?Ag({currentSnapshot:n,data:o.data,replace:o.replace,isCommandRunning:o.isCommandRunning,pendingCommand:a}):null;return{output:o,snapshotUpdate:s}}function rx({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:o,hasAttachTimeout:s}){const l=Cg({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:o});return{closeAction:l,shouldClearAttachTimeout:!!(l&&s),shouldClearSocketRef:!!l,viewerId:null,isConnecting:!1,settleAttachPromise:!1}}function nx(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 ax(e){return e.current}function sx({shell:e,shellAdapter:r,canAttachShell:n,terminalReady:a,reconnectKey:o,terminalRef:s,socketRef:l,viewerIdRef:i,shellIdRef:d,reconnectTimerRef:h,attachTimeoutRef:u,attachRetryTimerRef:m,isVisibleRef:f,intentionalDisconnectRef:p,userDisconnectedShellIdRef:g,shellSnapshotRef:b,pendingCommandRef:w,lastCommandOutputRef:x,snapshotCursorRef:j,syncTerminalSizeRef:y,setReconnectKey:v,setViewerId:k,setIsConnecting:S,setConnectionError:N,setRuntimePromptLabel:L,setIsCommandRunning:R,settleAttachPromise:P,onShellUpdate:Q}){const D=e==null?void 0:e.id,Z=e==null?void 0:e.cwd;c.useEffect(()=>{const J=s.current,z={shellId:D??null,terminalReady:a,isVisible:f.current,canAttachShell:n,userDisconnectedShellId:g.current,hasTerminal:!!J,hasPendingAttachRetry:m.current!==null,hasCurrentSocketForShell:!!(l.current&&d.current===D),hasReconnectTimer:h.current!==null};if(Zg(z).type==="skip")return;const se=y.current(),$=Jg({...z,attachSize:se});if($.type==="skip"||$.type==="measureSize")return;if($.type==="scheduleRetry"){Og({attachRetryTimerRef:m,setReconnectKey:v});return}if($.shouldClearAttachRetry&&Ht(m),$.type==="reuseSocket"||($.shouldClearReconnectTimer&&Ht(h),!D||!J))return;const le=$.attachSize;d.current=D,J.reset(),N(null),k(null),S(!0),p.current=!1;const q=r.connectSocket({onConnected:()=>{var F;const H=u.current,G=Qg({isCurrentSocket:((F=l.current)==null?void 0:F.socket)===q.socket,shellId:D,attachSize:le,hasAttachTimeout:H!==null}),T=G.openAction;T&&(q.send(T.message),G.shouldClearAttachTimeout&&H!==null&&Ht(u),T.shouldScheduleAttachTimeout&&Ug({shellSocket:q,socketRef:l,viewerIdRef:i,attachTimeoutRef:u,setConnectionError:N,setIsConnecting:S,settleAttachPromise:P}))},onShellEvent:H=>{var F;if(!Yg({eventShellId:H.shellId,shellId:D,socketExists:!!q.socket,isCurrentSocket:((F=l.current)==null?void 0:F.socket)===q.socket}))return;if(H.type==="shell.connected"){Ht(u);const B=ex(H);k(B.viewerId),S(!1),P(B.settleAttachPromise),Q(D,B.nextShell,"attached");return}if(H.type==="shell.output"){const{output:B,snapshotUpdate:E}=tx({event:H,shellCwd:Z,currentSnapshot:b.current,pendingCommand:w.current});j.current={cursorX:B.cursorX,cursorY:B.cursorY,paneHeight:B.paneHeight},L(B.promptLabel),R(B.isCommandRunning),E&&(b.current=E.nextSnapshot,w.current=E.nextPendingCommand,E.lastCommandOutput!==null&&(x.current=E.lastCommandOutput),B.replace?El(J,B.data,B.cursorX,B.cursorY,B.paneHeight):J.write(B.data));return}const T=_g({event:H,currentViewerId:i.current});T&&(T.viewerId!==void 0&&k(T.viewerId),T.isConnecting!==void 0&&S(T.isConnecting),T.settleAttachPromise!==void 0&&P(T.settleAttachPromise),T.isCommandRunning!==void 0&&R(T.isCommandRunning),T.connectionError!==void 0&&N(T.connectionError),T.intentionalDisconnect!==void 0&&(p.current=T.intentionalDisconnect),T.shellUpdate&&Q(D,B=>nx(B,T),T.shellUpdate.status),T.closeSocket&&q.socket.close())}});return l.current=q,q.socket.addEventListener("close",()=>{var T;const H=u.current,G=rx({isCurrentSocket:((T=l.current)==null?void 0:T.socket)===q.socket,hadViewer:!!i.current,intentionalDisconnect:p.current,userDisconnectedShellId:g.current,shellId:D,hasAttachTimeout:H!==null});Kg({closeApplication:G,shellId:D,attachTimeoutRef:u,socketRef:l,reconnectTimerRef:h,setViewerId:k,setIsConnecting:S,settleAttachPromise:P,onShellUpdate:Q,setReconnectKey:v})}),()=>{const H=ax(i),G=qg({shellId:D,viewerId:H,shellSocket:q,attachRetryTimerRef:m,attachTimeoutRef:u,socketRef:l,openReadyState:WebSocket.OPEN});Xg({cleanupAction:G,shellSocket:q,attachRetryTimerRef:m,attachTimeoutRef:u,socketRef:l,intentionalDisconnectRef:p,setViewerId:k,setIsConnecting:S,settleAttachPromise:P})}},[m,u,n,p,f,x,Q,w,o,h,N,R,S,v,L,k,P,Z,D,r,d,b,j,l,y,a,s,g,i])}function zn(e){return e.current}var Bs=c.forwardRef(function({paneId:r,shell:n,isActive:a,isVisible:o,isMobileShell:s,effectiveTheme:l,workspacePathMissing:i,shellAdapter:d,onActivate:h,onShellUpdate:u,onRuntimeStateChange:m,onFeedback:f},p){const g=c.useRef(null),b=c.useRef(null),w=c.useRef(null),x=c.useRef(null),j=c.useRef(null),y=c.useRef(null),v=c.useRef(null),k=c.useRef(null),S=c.useRef(!1),N=c.useRef(null),L=c.useRef(""),R=c.useRef(null),P=c.useRef(""),Q=c.useRef(null),D=c.useRef(null),Z=c.useRef({cursorX:void 0,cursorY:void 0,paneHeight:void 0}),J=c.useRef(!1),z=c.useRef(null),te=c.useRef(o),se=c.useRef(s),$=c.useRef(()=>!1),le=c.useRef(()=>null),q=c.useRef(()=>{}),H=c.useRef($g({clearTimeout:window.clearTimeout})),[G,T]=c.useState(null),[F,B]=c.useState(!1),[E,C]=c.useState(null),[W,U]=c.useState(!1),[ne,K]=c.useState(null),[ie,ee]=c.useState(null),[ve,oe]=c.useState(!1),[ye,Me]=c.useState(0),de=(n==null?void 0:n.status)??"not_created",Ce=Dg({shell:n,workspacePathMissing:i}),Ee=c.useMemo(()=>ma(ln(n==null?void 0:n.cwd),null),[n==null?void 0:n.cwd]),Y=ie??Ee,ue=c.useCallback(V=>{x.current=V,C(V)},[]),ke=c.useCallback(V=>{H.current.settle(V)},[]);c.useEffect(()=>{te.current=o},[o]),c.useEffect(()=>{se.current=s},[s]),c.useEffect(()=>{j.current=(n==null?void 0:n.id)??null},[n==null?void 0:n.id]);const we=c.useCallback(V=>{const ce=w.current,xe=j.current,I=x.current;return!ce||!xe||!I?!1:(ce.send({type:"shell.input",shellId:xe,viewerId:I,data:V}),!0)},[]);c.useEffect(()=>{$.current=we},[we]);const De=c.useCallback(()=>{const V=w.current,ce=j.current,xe=x.current;return!V||!ce||!xe?!1:(V.send({type:"shell.clear",shellId:ce,viewerId:xe}),!0)},[]),Fe=c.useCallback(()=>{if(!o||!G)return!1;const V=G.getBoundingClientRect();return V.width>0&&V.height>0},[o,G]),Ae=c.useCallback(V=>{const ce=g.current,xe=b.current;if(!ce||!xe||!Fe()||(xe.fit(),ce.cols<=0||ce.rows<=0))return null;const I={cols:ce.cols,rows:ce.rows},O=Rg({size:I,previousSize:D.current,shellId:j.current,viewerId:x.current,syncBackendSize:(V==null?void 0:V.syncBackendSize)!==!1});return(V==null?void 0:V.syncBackendSize)===!1||(D.current=O.nextLastSentSize,!O.message)||w.current&&w.current.send(O.message),I},[Fe]);c.useEffect(()=>{le.current=Ae},[Ae]);const Oe=c.useCallback(V=>{const ce=g.current;!ce||!Fe()||(Ae((V==null?void 0:V.syncBackendSize)===void 0?void 0:{syncBackendSize:V.syncBackendSize}),L.current&&!$s(G)?El(ce,L.current,Z.current.cursorX,Z.current.cursorY,Z.current.paneHeight):ce.scrollToBottom(),V!=null&&V.focus&&!s&&ce.focus())},[s,Fe,Ae,G]);return c.useEffect(()=>{q.current=()=>Oe()},[Oe]),c.useEffect(()=>{m({status:E?"attached":de,shellInputEnabled:!!(E&&n),isConnecting:W,isCommandRunning:ve,promptLabel:Y,error:ne,hasShell:!!n})},[ne,W,ve,m,Y,n,de,E]),c.useEffect(()=>{if(!G||g.current||J.current)return;let V=!1;return J.current=!0,(async()=>{const[{Terminal:ce},{FitAddon:xe}]=await Promise.all([Xe(()=>import("./terminal-vendor-C5bTa-Ka.js").then(ae=>ae.x),__vite__mapDeps([6,2,7])),Xe(()=>import("./terminal-vendor-C5bTa-Ka.js").then(ae=>ae.a),__vite__mapDeps([6,2,7]))]);if(V||!G){J.current=!1;return}const I=new ce({cursorBlink:!0,disableStdin:se.current,fontFamily:"IBM Plex Mono, SFMono-Regular, Menlo, monospace",fontSize:13,lineHeight:1.25,scrollback:3e3,theme:As(l)}),O=new xe;I.loadAddon(O),I.open(G),g.current=I,b.current=O,le.current(),I.attachCustomKeyEventHandler(ae=>{if(se.current||ae.type!=="keydown")return!0;if(ae.ctrlKey&&!ae.altKey&&!ae.metaKey&&!ae.shiftKey){const be=cg(ae.key);if(!be)return!0;if($.current(be))return ae.preventDefault(),!1}return!0}),B(!0),J.current=!1,Q.current=new ResizeObserver(()=>{q.current()}),Q.current.observe(G),z.current=I.onData(ae=>{se.current||$.current(ae)})})(),()=>{var ce,xe,I;V=!0,J.current=!1,(ce=z.current)==null||ce.dispose(),z.current=null,(xe=Q.current)==null||xe.disconnect(),Q.current=null,B(!1),(I=g.current)==null||I.dispose(),g.current=null,b.current=null,D.current=null}},[l,G]),c.useEffect(()=>{var ce;const V=Lg({hasShell:!!n});V&&(ue(V.viewerId),U(V.isConnecting),ke(V.settleAttachPromise),K(V.connectionError),ee(V.runtimePromptLabel),oe(V.isCommandRunning),L.current=V.shellSnapshot,P.current=V.lastCommandOutput,R.current=V.pendingCommand,V.shouldResetTerminal&&((ce=g.current)==null||ce.reset()))},[ue,ke,n]),c.useEffect(()=>{const V=g.current;V&&(V.options.theme=As(l))},[l]),c.useEffect(()=>{const V=g.current;V&&(V.options.disableStdin=s)},[s]),c.useEffect(()=>{if(!o||!F)return;const V=window.requestAnimationFrame(()=>{Oe({focus:a,syncBackendSize:!1}),!w.current&&(n!=null&&n.id)&&N.current!==n.id&&Me(ce=>ce+1)});return()=>{window.cancelAnimationFrame(V)}},[a,o,Oe,n==null?void 0:n.id,F]),sx({shell:n,shellAdapter:d,canAttachShell:Ce,terminalReady:F,reconnectKey:ye,terminalRef:g,socketRef:w,viewerIdRef:x,shellIdRef:j,reconnectTimerRef:y,attachTimeoutRef:v,attachRetryTimerRef:k,isVisibleRef:te,intentionalDisconnectRef:S,userDisconnectedShellIdRef:N,shellSnapshotRef:L,pendingCommandRef:R,lastCommandOutputRef:P,snapshotCursorRef:Z,syncTerminalSizeRef:le,setReconnectKey:Me,setViewerId:ue,setIsConnecting:U,setConnectionError:K,setRuntimePromptLabel:ee,setIsCommandRunning:oe,settleAttachPromise:ke,onShellUpdate:u}),c.useEffect(()=>()=>{const V=zn(y),ce=zn(v),xe=zn(k),I=Ig({hasReconnectTimer:V!==null,hasAttachTimeout:ce!==null,hasAttachRetry:xe!==null});I.shouldClearReconnectTimer&&V!==null&&window.clearTimeout(V),I.shouldClearAttachTimeout&&ce!==null&&window.clearTimeout(ce),I.shouldClearAttachRetry&&xe!==null&&window.clearTimeout(xe),ke(I.settleAttachPromise)},[ke]),c.useImperativeHandle(p,()=>({disconnect(){const V=w.current,ce=j.current,xe=x.current,I=zg({shellId:ce,viewerId:xe,hasSocket:!!V});N.current=I.userDisconnectedShellId,S.current=I.intentionalDisconnect,V&&I.detachMessage&&V.send(I.detachMessage),ue(null),U(!1),ke(!1),I.shouldCloseSocket&&(V==null||V.socket.close()),w.current=null,D.current=null,I.shouldDetachShell&&ce&&u(ce,O=>({...O,status:"detached",attachedViewerId:null}),"detached")},reconnect(){const V=Tg({hasShellId:!!j.current,terminalReady:F,workspacePathMissing:i,hasViewer:!!x.current,hasPendingAttach:H.current.hasPending()});if(V.type==="reject")return Promise.resolve(!1);if(V.type==="alreadyConnected")return Promise.resolve(!0);if(V.type==="joinPending")return H.current.joinPending();const ce=H.current.start({timeoutMs:kg,setTimeout:window.setTimeout,onTimeout:()=>{U(!1)}}),xe=Eg({shellId:j.current,userDisconnectedShellId:N.current});return xe.shouldClearUserDisconnectedShellId&&(N.current=null),S.current=xe.intentionalDisconnect,K(xe.connectionError),U(xe.isConnecting),Me(I=>I+1),ce},sendInput(V){return we(V)},sendCommand(V){const ce={command:V,beforeSnapshot:L.current};if(R.current=ce,V.trim()==="clear"){const O=De();return!O&&R.current===ce&&(R.current=null),O}const xe=V.endsWith(`
3709
+ `);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 Gs(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(`
3710
+ `).trimEnd():""}function Vg({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 Fs={status:"not_created",shellInputEnabled:!1,isConnecting:!1,isCommandRunning:!1,promptLabel:null,error:null,hasShell:!1};function vt(e){return e.status!=="exited"&&e.status!=="not_found"}function qg({shell:e,workspacePathMissing:r}){return!!(e&&!r&&vt(e))}function Kg(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 Xg(e){return(e.activeShellId?e.shells.find(r=>r.id===e.activeShellId&&vt(r)):null)??(e.shell&&vt(e.shell)?e.shell:null)??e.shells.find(vt)??null}function Yg({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&&!vt(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&&!vt(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 Zg({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?fa(hn(r.cwd),null):null),isMobileShell:s,hasShell:!!r,busy:o,loading:l,error:e.error??i}}function Ot(e){return e.current===null?!1:(window.clearTimeout(e.current),e.current=null,!0)}function Jg({attachRetryTimerRef:e,setReconnectKey:r,delayMs:n=Sg}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function Qg({reconnectTimerRef:e,setReconnectKey:r,delayMs:n=Tg}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function ex({shellSocket:e,socketRef:r,viewerIdRef:n,attachTimeoutRef:a,setConnectionError:s,setIsConnecting:o,settleAttachPromise:l,delayMs:i=Eg}){a.current=window.setTimeout(()=>{var h,u,m;a.current=null;const d=zg({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 tx(e){return{...e,status:e.status==="attached"?"detached":e.status,attachedViewerId:null}}function rx({shellId:e,viewerId:r,shellSocket:n,attachRetryTimerRef:a,attachTimeoutRef:s,socketRef:o,openReadyState:l}){var i;return Fg({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 nx({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&&Ot(n),e.shouldClearSocketRef&&(a.current=null),o(e.viewerId),l(e.isConnecting),i(e.settleAttachPromise),u.shouldDetachShell&&d(r,tx,"detached"),u.shouldScheduleReconnect&&Qg({reconnectTimerRef:s,setReconnectKey:h}),!0):!1}function ax({cleanupAction:e,shellSocket:r,attachRetryTimerRef:n,attachTimeoutRef:a,socketRef:s,intentionalDisconnectRef:o,setViewerId:l,setIsConnecting:i,settleAttachPromise:d}){o.current=e.intentionalDisconnect,e.shouldClearAttachRetry&&Ot(n),e.shouldSendDetachMessage&&e.detachMessage&&r.send(e.detachMessage),l(null),i(e.isConnecting),e.settleAttachPromise!==void 0&&d(e.settleAttachPromise),e.shouldClearAttachTimeout&&Ot(a),r.socket.close(),e.shouldClearSocketRef&&(s.current=null)}function sx({eventShellId:e,shellId:r,socketExists:n,isCurrentSocket:a}){return n&&!a?!1:e===r}function ox(e){return Ll({...e,attachSize:void 0})}function lx({attachSize:e,...r}){return Ll({...r,attachSize:e})}function ix({isCurrentSocket:e,shellId:r,attachSize:n,hasAttachTimeout:a}){const s=Pg({isCurrentSocket:e,shellId:r,attachSize:n});return{openAction:s,shouldClearAttachTimeout:!!(s&&a)}}function dx(e){const r=String(e.payload.viewerId??"");return{viewerId:r||null,settleAttachPromise:!!r,nextShell:n=>({...n,status:"attached",attachedViewerId:r})}}function cx({event:e,shellCwd:r,currentSnapshot:n,pendingCommand:a}){const s=Og(e.payload,r),o=s.data?Wg({currentSnapshot:n,data:s.data,replace:s.replace,isCommandRunning:s.isCommandRunning,pendingCommand:a}):null;return{output:s,snapshotUpdate:o}}function hx({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 ux(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 mx(e){return e.current}function px({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:k,pendingCommandRef:w,lastCommandOutputRef:x,snapshotCursorRef:j,syncTerminalSizeRef:y,setReconnectKey:b,setViewerId:v,setIsConnecting:S,setConnectionError:N,setRuntimePromptLabel:L,setIsCommandRunning:R,settleAttachPromise:P,onShellUpdate:Q}){const D=e==null?void 0:e.id,Z=e==null?void 0:e.cwd;c.useEffect(()=>{const J=o.current,z={shellId:D??null,terminalReady:a,isVisible:f.current,canAttachShell:n,userDisconnectedShellId:g.current,hasTerminal:!!J,hasPendingAttachRetry:m.current!==null,hasCurrentSocketForShell:!!(l.current&&d.current===D),hasReconnectTimer:h.current!==null};if(ox(z).type==="skip")return;const se=y.current(),_=lx({...z,attachSize:se});if(_.type==="skip"||_.type==="measureSize")return;if(_.type==="scheduleRetry"){Jg({attachRetryTimerRef:m,setReconnectKey:b});return}if(_.shouldClearAttachRetry&&Ot(m),_.type==="reuseSocket"||(_.shouldClearReconnectTimer&&Ot(h),!D||!J))return;const ie=_.attachSize;d.current=D,J.reset(),N(null),v(null),S(!0),p.current=!1;const q=r.connectSocket({onConnected:()=>{var F;const H=u.current,G=ix({isCurrentSocket:((F=l.current)==null?void 0:F.socket)===q.socket,shellId:D,attachSize:ie,hasAttachTimeout:H!==null}),T=G.openAction;T&&(q.send(T.message),G.shouldClearAttachTimeout&&H!==null&&Ot(u),T.shouldScheduleAttachTimeout&&ex({shellSocket:q,socketRef:l,viewerIdRef:i,attachTimeoutRef:u,setConnectionError:N,setIsConnecting:S,settleAttachPromise:P}))},onShellEvent:H=>{var F;if(!sx({eventShellId:H.shellId,shellId:D,socketExists:!!q.socket,isCurrentSocket:((F=l.current)==null?void 0:F.socket)===q.socket}))return;if(H.type==="shell.connected"){Ot(u);const B=dx(H);v(B.viewerId),S(!1),P(B.settleAttachPromise),Q(D,B.nextShell,"attached");return}if(H.type==="shell.output"){const{output:B,snapshotUpdate:E}=cx({event:H,shellCwd:Z,currentSnapshot:k.current,pendingCommand:w.current});j.current={cursorX:B.cursorX,cursorY:B.cursorY,paneHeight:B.paneHeight},L(B.promptLabel),R(B.isCommandRunning),E&&(k.current=E.nextSnapshot,w.current=E.nextPendingCommand,E.lastCommandOutput!==null&&(x.current=E.lastCommandOutput),B.replace?zl(J,B.data,B.cursorX,B.cursorY,B.paneHeight):J.write(B.data));return}const T=Ug({event:H,currentViewerId:i.current});T&&(T.viewerId!==void 0&&v(T.viewerId),T.isConnecting!==void 0&&S(T.isConnecting),T.settleAttachPromise!==void 0&&P(T.settleAttachPromise),T.isCommandRunning!==void 0&&R(T.isCommandRunning),T.connectionError!==void 0&&N(T.connectionError),T.intentionalDisconnect!==void 0&&(p.current=T.intentionalDisconnect),T.shellUpdate&&Q(D,B=>ux(B,T),T.shellUpdate.status),T.closeSocket&&q.socket.close())}});return l.current=q,q.socket.addEventListener("close",()=>{var T;const H=u.current,G=hx({isCurrentSocket:((T=l.current)==null?void 0:T.socket)===q.socket,hadViewer:!!i.current,intentionalDisconnect:p.current,userDisconnectedShellId:g.current,shellId:D,hasAttachTimeout:H!==null});nx({closeApplication:G,shellId:D,attachTimeoutRef:u,socketRef:l,reconnectTimerRef:h,setViewerId:v,setIsConnecting:S,settleAttachPromise:P,onShellUpdate:Q,setReconnectKey:b})}),()=>{const H=mx(i),G=rx({shellId:D,viewerId:H,shellSocket:q,attachRetryTimerRef:m,attachTimeoutRef:u,socketRef:l,openReadyState:WebSocket.OPEN});ax({cleanupAction:G,shellSocket:q,attachRetryTimerRef:m,attachTimeoutRef:u,socketRef:l,intentionalDisconnectRef:p,setViewerId:v,setIsConnecting:S,settleAttachPromise:P})}},[m,u,n,p,f,x,Q,w,s,h,N,R,S,b,L,v,P,Z,D,r,d,k,j,l,y,a,o,g,i])}function An(e){return e.current}var Hs=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),k=c.useRef(null),w=c.useRef(null),x=c.useRef(null),j=c.useRef(null),y=c.useRef(null),b=c.useRef(null),v=c.useRef(null),S=c.useRef(!1),N=c.useRef(null),L=c.useRef(""),R=c.useRef(null),P=c.useRef(""),Q=c.useRef(null),D=c.useRef(null),Z=c.useRef({cursorX:void 0,cursorY:void 0,paneHeight:void 0}),J=c.useRef(!1),z=c.useRef(null),te=c.useRef(s),se=c.useRef(o),_=c.useRef(()=>!1),ie=c.useRef(()=>null),q=c.useRef(()=>{}),H=c.useRef(Vg({clearTimeout:window.clearTimeout})),[G,T]=c.useState(null),[F,B]=c.useState(!1),[E,C]=c.useState(null),[W,U]=c.useState(!1),[ae,K]=c.useState(null),[de,ee]=c.useState(null),[ke,le]=c.useState(!1),[je,Ae]=c.useState(0),ce=(n==null?void 0:n.status)??"not_created",ne=qg({shell:n,workspacePathMissing:i}),Le=c.useMemo(()=>fa(hn(n==null?void 0:n.cwd),null),[n==null?void 0:n.cwd]),Y=de??Le,me=c.useCallback(V=>{x.current=V,C(V)},[]),we=c.useCallback(V=>{H.current.settle(V)},[]);c.useEffect(()=>{te.current=s},[s]),c.useEffect(()=>{se.current=o},[o]),c.useEffect(()=>{j.current=(n==null?void 0:n.id)??null},[n==null?void 0:n.id]);const ye=c.useCallback(V=>{const he=w.current,ve=j.current,I=x.current;return!he||!ve||!I?!1:(he.send({type:"shell.input",shellId:ve,viewerId:I,data:V}),!0)},[]);c.useEffect(()=>{_.current=ye},[ye]);const De=c.useCallback(()=>{const V=w.current,he=j.current,ve=x.current;return!V||!he||!ve?!1:(V.send({type:"shell.clear",shellId:he,viewerId:ve}),!0)},[]),Be=c.useCallback(()=>{if(!s||!G)return!1;const V=G.getBoundingClientRect();return V.width>0&&V.height>0},[s,G]),_e=c.useCallback(V=>{const he=g.current,ve=k.current;if(!he||!ve||!Be()||(ve.fit(),he.cols<=0||he.rows<=0))return null;const I={cols:he.cols,rows:he.rows},O=Hg({size:I,previousSize:D.current,shellId:j.current,viewerId:x.current,syncBackendSize:(V==null?void 0:V.syncBackendSize)!==!1});return(V==null?void 0:V.syncBackendSize)===!1||(D.current=O.nextLastSentSize,!O.message)||w.current&&w.current.send(O.message),I},[Be]);c.useEffect(()=>{ie.current=_e},[_e]);const Oe=c.useCallback(V=>{const he=g.current;!he||!Be()||(_e((V==null?void 0:V.syncBackendSize)===void 0?void 0:{syncBackendSize:V.syncBackendSize}),L.current&&!Gs(G)?zl(he,L.current,Z.current.cursorX,Z.current.cursorY,Z.current.paneHeight):he.scrollToBottom(),V!=null&&V.focus&&!o&&he.focus())},[o,Be,_e,G]);return c.useEffect(()=>{q.current=()=>Oe()},[Oe]),c.useEffect(()=>{m({status:E?"attached":ce,shellInputEnabled:!!(E&&n),isConnecting:W,isCommandRunning:ke,promptLabel:Y,error:ae,hasShell:!!n})},[ae,W,ke,m,Y,n,ce,E]),c.useEffect(()=>{if(!G||g.current||J.current)return;let V=!1;return J.current=!0,(async()=>{const[{Terminal:he},{FitAddon:ve}]=await Promise.all([Xe(()=>import("./terminal-vendor-C5bTa-Ka.js").then(oe=>oe.x),__vite__mapDeps([6,2,7])),Xe(()=>import("./terminal-vendor-C5bTa-Ka.js").then(oe=>oe.a),__vite__mapDeps([6,2,7]))]);if(V||!G){J.current=!1;return}const I=new he({cursorBlink:!0,disableStdin:se.current,fontFamily:"IBM Plex Mono, SFMono-Regular, Menlo, monospace",fontSize:13,lineHeight:1.25,scrollback:3e3,theme:Ds(l)}),O=new ve;I.loadAddon(O),I.open(G),g.current=I,k.current=O,ie.current(),I.attachCustomKeyEventHandler(oe=>{if(se.current||oe.type!=="keydown")return!0;if(oe.ctrlKey&&!oe.altKey&&!oe.metaKey&&!oe.shiftKey){const ge=vg(oe.key);if(!ge)return!0;if(_.current(ge))return oe.preventDefault(),!1}return!0}),B(!0),J.current=!1,Q.current=new ResizeObserver(()=>{q.current()}),Q.current.observe(G),z.current=I.onData(oe=>{se.current||_.current(oe)})})(),()=>{var he,ve,I;V=!0,J.current=!1,(he=z.current)==null||he.dispose(),z.current=null,(ve=Q.current)==null||ve.disconnect(),Q.current=null,B(!1),(I=g.current)==null||I.dispose(),g.current=null,k.current=null,D.current=null}},[l,G]),c.useEffect(()=>{var he;const V=Dg({hasShell:!!n});V&&(me(V.viewerId),U(V.isConnecting),we(V.settleAttachPromise),K(V.connectionError),ee(V.runtimePromptLabel),le(V.isCommandRunning),L.current=V.shellSnapshot,P.current=V.lastCommandOutput,R.current=V.pendingCommand,V.shouldResetTerminal&&((he=g.current)==null||he.reset()))},[me,we,n]),c.useEffect(()=>{const V=g.current;V&&(V.options.theme=Ds(l))},[l]),c.useEffect(()=>{const V=g.current;V&&(V.options.disableStdin=o)},[o]),c.useEffect(()=>{if(!s||!F)return;const V=window.requestAnimationFrame(()=>{Oe({focus:a,syncBackendSize:!1}),!w.current&&(n!=null&&n.id)&&N.current!==n.id&&Ae(he=>he+1)});return()=>{window.cancelAnimationFrame(V)}},[a,s,Oe,n==null?void 0:n.id,F]),px({shell:n,shellAdapter:d,canAttachShell:ne,terminalReady:F,reconnectKey:je,terminalRef:g,socketRef:w,viewerIdRef:x,shellIdRef:j,reconnectTimerRef:y,attachTimeoutRef:b,attachRetryTimerRef:v,isVisibleRef:te,intentionalDisconnectRef:S,userDisconnectedShellIdRef:N,shellSnapshotRef:L,pendingCommandRef:R,lastCommandOutputRef:P,snapshotCursorRef:Z,syncTerminalSizeRef:ie,setReconnectKey:Ae,setViewerId:me,setIsConnecting:U,setConnectionError:K,setRuntimePromptLabel:ee,setIsCommandRunning:le,settleAttachPromise:we,onShellUpdate:u}),c.useEffect(()=>()=>{const V=An(y),he=An(b),ve=An(v),I=Bg({hasReconnectTimer:V!==null,hasAttachTimeout:he!==null,hasAttachRetry:ve!==null});I.shouldClearReconnectTimer&&V!==null&&window.clearTimeout(V),I.shouldClearAttachTimeout&&he!==null&&window.clearTimeout(he),I.shouldClearAttachRetry&&ve!==null&&window.clearTimeout(ve),we(I.settleAttachPromise)},[we]),c.useImperativeHandle(p,()=>({disconnect(){const V=w.current,he=j.current,ve=x.current,I=Gg({shellId:he,viewerId:ve,hasSocket:!!V});N.current=I.userDisconnectedShellId,S.current=I.intentionalDisconnect,V&&I.detachMessage&&V.send(I.detachMessage),me(null),U(!1),we(!1),I.shouldCloseSocket&&(V==null||V.socket.close()),w.current=null,D.current=null,I.shouldDetachShell&&he&&u(he,O=>({...O,status:"detached",attachedViewerId:null}),"detached")},reconnect(){const V=$g({hasShellId:!!j.current,terminalReady:F,workspacePathMissing:i,hasViewer:!!x.current,hasPendingAttach:H.current.hasPending()});if(V.type==="reject")return Promise.resolve(!1);if(V.type==="alreadyConnected")return Promise.resolve(!0);if(V.type==="joinPending")return H.current.joinPending();const he=H.current.start({timeoutMs:Lg,setTimeout:window.setTimeout,onTimeout:()=>{U(!1)}}),ve=_g({shellId:j.current,userDisconnectedShellId:N.current});return ve.shouldClearUserDisconnectedShellId&&(N.current=null),S.current=ve.intentionalDisconnect,K(ve.connectionError),U(ve.isConnecting),Ae(I=>I+1),he},sendInput(V){return ye(V)},sendCommand(V){const he={command:V,beforeSnapshot:L.current};if(R.current=he,V.trim()==="clear"){const O=De();return!O&&R.current===he&&(R.current=null),O}const ve=V.endsWith(`
3709
3711
  `)?V:`${V}
3710
- `,I=we(xe);return!I&&R.current===ce&&(R.current=null),I},sendControl(V){return V==="clear"?De():we(pg(V))},async copyLastCommandOutput(){const V=P.current.trim()||$s(G);if(!V)return f==null||f("failed","Nothing to copy"),!1;try{return await navigator.clipboard.writeText(V),f==null||f("done","Copied"),!0}catch{return f==null||f("failed","Copy failed"),!1}},focus(){var V;(V=g.current)==null||V.focus()},refreshLayout(V){Oe(V)}}),[f,u,Oe,De,we,ue,ke,G,F,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:T,className:`h-full w-full px-2 py-2 sm:px-3 sm:py-3 ${s?"mobile-shell-selectable":""}`,onMouseDown:()=>{var V;h(),(V=g.current)==null||V.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"})]})}),ox=c.forwardRef(function({threadId:r,shellAdapter:n,isVisible:a=!0,showHeader:o=!0,showFloatingToolbox:s=!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),w=c.useRef(!1),[x,j]=c.useState(null),[y,v]=c.useState(!0),[k,S]=c.useState(!1),[N,L]=c.useState(null),[R,P]=c.useState("primary"),[Q,D]=c.useState(null),[Z,J]=c.useState(null),[z,te]=c.useState("single"),[se,$]=c.useState(50),[le,q]=c.useState(null),[H,G]=c.useState(""),[T,F]=c.useState(!1),[B,E]=c.useState(!1),[C,W]=c.useState(!1),[U,ne]=c.useState({primary:Ds,secondary:Ds}),[K,ie]=c.useState(null),ee=(x==null?void 0:x.state)??"not_created",ve=c.useMemo(()=>(x==null?void 0:x.shells)??[],[x==null?void 0:x.shells]),oe=c.useMemo(()=>ve.filter(bt),[ve]),ye=c.useMemo(()=>oe.find(M=>M.id===Q)??null,[oe,Q]),Me=c.useMemo(()=>oe.find(M=>M.id===Z)??null,[oe,Z]),de=R==="secondary"?Me:ye,Ce=U[R],Ee=(x==null?void 0:x.workspacePathStatus)==="missing",Y=R==="secondary"?f:m,ue=Fg({activeRuntime:Ce,activeShell:de,busy:k,loading:y,status:ee,workspacePathMissing:Ee}),ke=ue.disabled,we=ue.label,De=ue.className,Fe=(K==null?void 0:K.tone)==="done"?"shell-floating-feedback shell-floating-feedback-done":(K==null?void 0:K.tone)==="failed"?"shell-floating-feedback shell-floating-feedback-failed":"shell-floating-feedback",Ae=c.useCallback((M,X)=>{ie({tone:M,text:X}),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{ie(null),p.current=null},1800)},[]),Oe=c.useCallback((M,X,ge)=>{j(Ne=>{var nt;if(!Ne)return Ne;const Pe=Ne.shells.map($e=>$e.id===M?X($e):$e),rt=((nt=Ne.shell)==null?void 0:nt.id)===M?X(Ne.shell):Pe.find($e=>{var We;return $e.id===((We=Ne.shell)==null?void 0:We.id)})??Ne.shell;return{...Ne,...ge?{state:ge}:{},shell:rt,shells:Pe}})},[]),V=c.useCallback(async()=>{v(!0);try{const M=await n.fetchState(r);j(M),L(null)}catch(M){L(M instanceof Error?M.message:"Unable to load shell state.")}finally{v(!1)}},[n,r]);c.useEffect(()=>{V()},[V]),c.useEffect(()=>{const M=i==null?void 0:i(r);if(M==null){$(50);return}const X=typeof M=="number"?M:Number.parseFloat(String(M));$(Number.isFinite(X)?Ln(X):50)},[i,r]),c.useEffect(()=>{if(!x){D(null),J(null);return}const M=Gg(x);D(X=>X&&x.shells.some(ge=>ge.id===X&&bt(ge))?X:(M==null?void 0:M.id)??null),J(X=>{if(z!=="columns")return null;if(X&&x.shells.some(Ne=>Ne.id===X&&bt(Ne)))return X;const ge=x.shells.find(Ne=>bt(Ne)&&Ne.id!==(M==null?void 0:M.id));return(ge==null?void 0:ge.id)??null})},[x,z]),c.useEffect(()=>{z!=="columns"&&(P("primary"),J(null))},[z]),c.useEffect(()=>{if(z!=="columns"||Z||oe.length<2)return;const M=oe.find(X=>X.id!==(ye==null?void 0:ye.id))??null;M&&J(M.id)},[oe,ye==null?void 0:ye.id,Z,z]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const M=window.matchMedia("(max-width: 767px), (hover: none) and (pointer: coarse)"),X=()=>{F(M.matches),M.matches||(W(!1),E(!1))};return X(),M.addEventListener("change",X),()=>{M.removeEventListener("change",X)}},[]),c.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current),b.current!==null&&window.cancelAnimationFrame(b.current)},[]);const ce=c.useCallback((M,X)=>{ne(ge=>{const Ne=ge[M];return Bg(Ne,X)?ge:{...ge,[M]:X}})},[]),xe=c.useCallback(M=>ce("primary",M),[ce]),I=c.useCallback(M=>ce("secondary",M),[ce]),O=c.useCallback(M=>{var ge;if((ge=M.label)!=null&&ge.trim())return M.label.trim();const X=ve.findIndex(Ne=>Ne.id===M.id);return`Shell ${X>=0?X+1:""}`.trim()},[ve]),ae=c.useCallback(M=>{var X;q(M.id),G(((X=M.label)==null?void 0:X.trim())||O(M))},[O]),be=c.useCallback(()=>{q(null),G("")},[]),je=c.useCallback(async()=>{if(le){S(!0);try{const M=H.trim(),X=await n.updateShell(le,{label:M.length>0?M:null});j(ge=>{var Ne;return ge&&{...ge,state:ge.activeShellId===X.id?X.status:ge.state,shell:((Ne=ge.shell)==null?void 0:Ne.id)===X.id?X:ge.shell,shells:ge.shells.map(Pe=>Pe.id===X.id?X:Pe)}}),q(null),G(""),L(null)}catch(M){L(M instanceof Error?M.message:"Unable to rename shell.")}finally{S(!1)}}},[H,le,n]),Te=c.useCallback((M,X)=>{if(M==="primary"){D(X),J(ge=>ge===X?null:ge);return}J(X),D(ge=>ge===X?null:ge)},[]),fe=c.useCallback(M=>{var X,ge;if(M==="primary"){(X=m.current)==null||X.disconnect(),D(null),z==="columns"&&P("secondary");return}(ge=f.current)==null||ge.disconnect(),J(null),P("primary"),te("single")},[z]),Be=c.useCallback((M,X=R)=>{const ge=z==="columns"?X:"primary";Te(ge,M.id),z!=="columns"&&J(null),P(ge)},[R,Te,z]),_e=c.useCallback(async(M=R)=>{var X;if(!w.current){w.current=!0,S(!0);try{const ge=await n.createShell(r);j(ge);const Ne=ge.activeShellId??((X=ge.shell)==null?void 0:X.id)??null;if(Ne){const Pe=z==="columns"?M:"primary";Te(Pe,Ne),z!=="columns"&&J(null),P(Pe)}L(null)}catch(ge){L(ge instanceof Error?ge.message:"Unable to create shell.")}finally{w.current=!1,S(!1)}}},[R,Te,n,z,r]);c.useEffect(()=>{!a||!x||y||k||Ee||ee==="creating"||oe.length>0||_e("primary")},[k,_e,a,oe.length,y,x,ee,Ee]);const Qe=c.useCallback(async(M=(de==null?void 0:de.id)??"")=>{if(M){S(!0);try{await n.terminateShell(M),D(X=>X===M?null:X),J(X=>X===M?null:X),await V(),L(null)}catch(X){L(X instanceof Error?X.message:"Unable to terminate shell.")}finally{S(!1)}}},[de==null?void 0:de.id,V,n]),et=c.useCallback(async()=>{var M,X;if(!ke){if(Ce.shellInputEnabled){(M=Y.current)==null||M.disconnect();return}if(!de||de.status==="exited"||de.status==="not_found"){await _e(R);return}await((X=Y.current)==null?void 0:X.reconnect())}},[R,Y,Ce.shellInputEnabled,de,ke,_e]),it=c.useCallback(M=>{typeof window>"u"||d==null||d(r,Ln(M))},[d,r]),tt=c.useCallback(()=>{var M,X;(M=m.current)==null||M.refreshLayout({syncBackendSize:!0}),(X=f.current)==null||X.refreshLayout({syncBackendSize:!0})},[]),Ke=c.useCallback(M=>{var rt,nt;if(z!=="columns")return;const X=g.current;if(!X)return;M.preventDefault(),(nt=(rt=M.currentTarget).setPointerCapture)==null||nt.call(rt,M.pointerId);const ge=$e=>{const We=X.getBoundingClientRect();if(We.width<=0)return;const ut=Ln(($e-We.left)/We.width*100);$(ut),b.current!==null&&window.cancelAnimationFrame(b.current),b.current=window.requestAnimationFrame(()=>{b.current=null,tt()})},Ne=$e=>{ge($e.clientX)},Pe=$e=>{ge($e.clientX);const We=X.getBoundingClientRect();We.width>0&&it(($e.clientX-We.left)/We.width*100),window.removeEventListener("pointermove",Ne),window.removeEventListener("pointerup",Pe)};window.addEventListener("pointermove",Ne),window.addEventListener("pointerup",Pe,{once:!0})},[it,tt,z]),dt=c.useCallback((M,X)=>{Te(X,M.id),P(X)},[Te]),ft=c.useCallback(async()=>{var X;return await((X=Y.current)==null?void 0:X.copyLastCommandOutput())?!0:(Ae("failed","Nothing to copy"),!1)},[Y,Ae]);c.useEffect(()=>{h==null||h(Hg({activeRuntime:Ce,activeShell:de,connectionButtonDisabled:ke,connectionButtonLabel:we,isMobileShell:T,busy:k,loading:y,error:N}))},[Ce,de,k,ke,we,N,T,y,h]),c.useImperativeHandle(u,()=>({async toggleConnection(){await et()},sendInput(M){var X;return((X=Y.current)==null?void 0:X.sendInput(M))??!1},sendCommand(M){var X;return((X=Y.current)==null?void 0:X.sendCommand(M))??!1},sendControl(M){var X;return((X=Y.current)==null?void 0:X.sendControl(M))??!1},async copyLastCommandOutput(){var M;return await((M=Y.current)==null?void 0:M.copyLastCommandOutput())??!1},async terminate(){await Qe()},focus(){var M;(M=Y.current)==null||M.focus()},refreshLayout(M){var X,ge;(X=m.current)==null||X.refreshLayout(M),z==="columns"&&((ge=f.current)==null||ge.refreshLayout(M))}}),[Y,et,Qe,z]);const Ve=M=>t.jsx("div",{className:`rounded-md border px-2 py-1.5 text-xs ${M.id===(de==null?void 0:de.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:[le===M.id?t.jsx("form",{className:"min-w-0 flex-1",onSubmit:X=>{X.preventDefault(),je()},children:t.jsx("input",{value:H,onChange:X=>G(X.currentTarget.value),onKeyDown:X=>{X.key==="Escape"&&(X.preventDefault(),be())},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:()=>Be(M),onDoubleClick:()=>ae(M),className:"min-w-0 flex-1 text-left",title:M.tmuxSessionName,children:[t.jsx("span",{className:"block truncate",children:O(M)}),t.jsxs("span",{className:"block truncate text-[10px] text-[var(--theme-fg-muted)]",children:[En(M.status)," · ",ln(M.cwd)||M.cwd]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[le===M.id?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>void je(),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:be,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:()=>ae(M),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"}),z==="columns"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>dt(M,"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:()=>dt(M,"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:k,onClick:()=>void Qe(M.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"})]})]})},M.id);return t.jsxs("div",{className:"shell-panel flex min-h-0 flex-1 flex-col",children:[o&&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:Ce.promptLabel??(de==null?void 0:de.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":we,title:`${we} (${En(Ce.status)})`,disabled:ke,onClick:()=>void et(),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 ${De}`,children:t.jsx(gg,{connected:Ce.shellInputEnabled})}),de&&t.jsx("button",{type:"button",disabled:k,onClick:()=>void Qe(de.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"})]})]}),(N||y||Ee)&&t.jsxs("div",{className:"shell-banner mt-3 rounded-2xl border px-3 py-3 text-sm",children:[y&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!y&&Ee&&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."}),!y&&N&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:N})]})]}),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:de?O(de):"No live shell process"}),de&&t.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.12em] text-[var(--theme-fg-muted)]",children:En(Ce.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 ",oe.length]}),t.jsx("button",{type:"button","aria-expanded":B,"aria-label":B?"Hide shell processes":"Show shell processes",onClick:()=>E(M=>!M),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"})]})]}),B&&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:[oe.length," live"]})]}),t.jsxs("div",{className:"max-h-52 space-y-1 overflow-y-auto",children:[oe.map(Ve),oe.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:k||y||Ee,onClick:()=>void _e(R),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:"+"})})]}),ee==="not_created"||Ee?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."}),!Ee&&t.jsx("button",{type:"button",disabled:k||y,onClick:()=>void _e("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:[!o&&(N||y||Ee)&&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:[y&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!y&&Ee&&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."}),!y&&N&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:N})]}),t.jsxs("div",{ref:g,className:`relative grid h-full min-h-0 ${z==="columns"?"grid-cols-1 sm:grid-cols-[var(--shell-left)_0.35rem_var(--shell-right)]":"grid-cols-1"}`,style:z==="columns"?{"--shell-left":`${se}fr`,"--shell-right":`${100-se}fr`}:void 0,"data-shell-split-ratio":se,children:[t.jsx(Bs,{ref:m,paneId:"primary",shell:ye,isActive:R==="primary",isVisible:a,isMobileShell:T,effectiveTheme:l,workspacePathMissing:Ee,shellAdapter:n,onActivate:()=>P("primary"),onShellUpdate:Oe,onRuntimeStateChange:xe,onFeedback:Ae}),z==="columns"&&t.jsx("button",{type:"button",onClick:()=>fe("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"}),z==="columns"&&t.jsx("button",{type:"button","aria-label":"Resize shell panes",title:"Resize shell panes",onPointerDown:Ke,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"}),z==="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(Bs,{ref:f,paneId:"secondary",shell:Me,isActive:R==="secondary",isVisible:a,isMobileShell:T,effectiveTheme:l,workspacePathMissing:Ee,shellAdapter:n,onActivate:()=>P("secondary"),onShellUpdate:Oe,onRuntimeStateChange:I,onFeedback:Ae}),t.jsx("button",{type:"button",onClick:()=>fe("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"})]})]}),s&&T&&t.jsxs("div",{className:"pointer-events-none absolute bottom-3 right-3 z-20 flex flex-col items-end gap-2",children:[K&&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 ${Fe}`,children:K.text}),C&&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:()=>{Ae("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(_s,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:()=>void ft(),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(_s,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:!Ce.shellInputEnabled,onClick:()=>{var M;(M=Y.current)!=null&&M.sendControl("clear")?Ae("done","Cleared"):Ae("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(In,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!Ce.shellInputEnabled||!Ce.isCommandRunning,onClick:()=>{var M;(M=Y.current)!=null&&M.sendInput("")?Ae("done","Sent Ctrl-C"):Ae("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(In,{label:"CTRL-C",tone:"rose"})}),["ctrl_d","esc","tab","up","down"].map(M=>t.jsx("button",{type:"button",disabled:!Ce.shellInputEnabled,onClick:()=>{var X;(X=Y.current)!=null&&X.sendControl(M)?Ae("done",`Sent ${M.toUpperCase().replace("_","-")}`):Ae("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(In,{label:M.toUpperCase().replace("_","-"),tone:"stone"})},M))]})}),t.jsx("button",{type:"button","aria-expanded":C,"aria-label":C?"Close shell tools":"Open shell tools",onClick:()=>W(M=>!M),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(fg,{})})]})]}),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:[oe.length," live"]})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-1 overflow-y-auto",children:[oe.map(Ve),oe.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:k||y||Ee,onClick:()=>void _e(R),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:"+"})})]})]})]})})]})}),lx=c.lazy(async()=>({default:(await Promise.resolve().then(()=>(fu(),rl))).ThreadGraphWorkspacePanel}));function ix(){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 Ll(e){return t.jsx(c.Suspense,{fallback:t.jsx(ix,{}),children:t.jsx(lx,{...e})})}c.memo(Ll);function Cx({open:e,title:r,description:n,confirmLabel:a="Delete",busy:o=!1,onCancel:s,onConfirm:l}){return c.useEffect(()=>{if(!e)return;function i(d){d.key==="Escape"&&!o&&s()}return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[o,s,e]),e?Yr.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:s,disabled:o,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:s,disabled:o,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:s,disabled:o,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:o,className:"ui-action-danger rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:o?"Deleting...":a})]})]})]}),document.body):null}function dx(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 cx(e){switch(e){case"inProgress":return"running";case"completed":return"completed";case"interrupted":return"interrupted";case"failed":return"failed"}}function hx(e){switch(e){case"latest-3":return"Latest 3";case"latest-10":return"Latest 10";case"latest-20":return"Latest 20";case"all-loaded":return"All loaded";case"custom":return"Custom"}}function ux(e){switch(e){case"latest-3":return 3;case"latest-10":return 10;case"latest-20":return 20;default:return null}}function mx(e){return e==="read"?"View only":"Collaborator"}function px(e){switch(e){case"write":return"Workspace write";case"read":return"Workspace read";case"none":default:return"No workspace"}}function Sx({open:e,busy:r=!1,turnsState:n,shareAvailable:a=!1,shareUnavailableMessage:o="Relay sharing will be enabled after the relay permission model is connected.",shareState:s,initialMode:l="pdf",onCancel:i,onLoadTurns:d,onExport:h,onCreateShare:u,onRevokeShare:m,onOpenDeviceSharing:f}){var F,B,E;const p=c.useMemo(()=>{var C;return((C=n.data)==null?void 0:C.turns)??[]},[(F=n.data)==null?void 0:F.turns]),[g,b]=c.useState(l),[w,x]=c.useState("latest-10"),[j,y]=c.useState(()=>new Set),[v,k]=c.useState(!0),[S,N]=c.useState(""),[L,R]=c.useState("read"),[P,Q]=c.useState("none"),[D,Z]=c.useState(""),[J,z]=c.useState(()=>typeof document<"u"&&!document.documentElement.classList.contains("dark")?"light":"dark");if(c.useEffect(()=>{e&&(b(l),x("latest-10"),k(!0),N(""),R("read"),Q("none"),Z(""),d())},[l,d,e]),c.useEffect(()=>{e&&p.length>0&&y(new Set(p.slice(0,10).map(C=>C.turnId)))},[e,p]),c.useEffect(()=>{if(!e)return;function C(W){W.key==="Escape"&&!r&&i()}return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[r,i,e]),c.useEffect(()=>{if(!e)return;const C=document.querySelector(".thread-ui-shell"),W=()=>C?C.getAttribute("data-theme-effective")==="dark"||C.classList.contains("dark")||C.classList.contains("thread-ui-theme-dark")?"dark":"light":document.documentElement.classList.contains("dark")?"dark":"light";if(z(W()),!C)return;const U=new MutationObserver(()=>z(W()));return U.observe(C,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>U.disconnect()},[e]),!e)return null;const te=ux(w),se=te!==null?Math.min(te,((B=n.data)==null?void 0:B.totalTurnCount)??te):w==="all-loaded"?p.length:j.size,$=!r&&g!=="share"&&(te!==null||w==="all-loaded"||j.size>0),le=!r&&a&&!!u&&S.trim().length>0;function q(C){y(W=>{const U=new Set(W);return U.has(C)?U.delete(C):U.add(C),U})}function H(){if(g==="share")return;const C={format:g,...te!==null?{mode:"latest",limit:te}:w==="all-loaded"?{mode:"selected",turnIds:p.map(W=>W.turnId)}:{mode:"selected",turnIds:[...j]},profile:"review",options:{includeTokenAndPrice:v}};h(C)}function G(C){C.preventDefault(),le&&(u==null||u({targetIdentifier:S.trim(),threadAccess:L,workspaceAccess:P,label:D.trim()||null}))}const T=[{mode:"pdf",label:"PDF"},{mode:"html",label:"HTML"},{mode:"share",label:"Share"}];return Yr.createPortal(t.jsxs("div",{className:`thread-export-dialog-root thread-ui-theme-${J} fixed inset-0 z-[96] flex items-end justify-center p-0 sm:items-center sm:p-6`,"data-theme-effective":J,children:[t.jsx("button",{type:"button","aria-label":"Close thread actions",onClick:i,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":"Thread actions",className:"thread-export-dialog-panel relative z-[1] flex max-h-[min(48rem,calc(100vh-1rem))] w-full max-w-2xl flex-col rounded-t-[1.6rem] border shadow-2xl sm:rounded-[1.6rem]",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:"Thread actions"}),t.jsx("p",{className:"thread-export-dialog-subtitle mt-1 text-xs",children:"Export a review copy or share this thread."})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:i,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:T.map(C=>t.jsx("button",{type:"button",onClick:()=>b(C.mode),className:`rounded-full px-3 py-1.5 text-sm transition ${g===C.mode?"ui-status-warning":"thread-export-dialog-muted-action"}`,children:C.label},C.mode))}),g==="share"?t.jsxs("form",{id:"thread-actions-share-form",className:"mt-4 space-y-4",onSubmit:G,children:[a?null:t.jsx("p",{className:"thread-export-dialog-box thread-export-dialog-subtitle rounded-2xl border px-3 py-3 text-sm",children:o}),a&&f?t.jsxs("div",{className:"thread-export-dialog-box flex flex-wrap items-center justify-between gap-3 rounded-2xl border px-3 py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-export-dialog-strong text-sm font-medium",children:"Share this thread"}),t.jsx("p",{className:"thread-export-dialog-subtitle mt-1 text-xs",children:"Need broader access? Share the whole device from Relay Portal."})]}),t.jsx("button",{type:"button",className:"thread-export-dialog-secondary-button rounded-full border px-3 py-1.5 text-xs font-medium transition",disabled:r,onClick:f,children:"Share whole device"})]}):null,t.jsxs("label",{className:"thread-export-dialog-body-text block text-sm",children:["Relay identifier",t.jsx("input",{className:"thread-export-dialog-box mt-2 w-full rounded-xl border bg-transparent px-3 py-2 outline-none",disabled:!a||r,onChange:C=>N(C.target.value),placeholder:"username or email",value:S})]}),t.jsxs("fieldset",{className:"thread-export-dialog-box rounded-2xl border p-3",children:[t.jsx("legend",{className:"thread-export-dialog-subtitle px-1 text-xs",children:"Thread access"}),t.jsx("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[["read","View only"],["control","Collaborator"]].map(([C,W])=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex items-center gap-2 rounded-xl px-2.5 py-2 text-sm",children:[t.jsx("input",{type:"radio",checked:L===C,disabled:!a||r,onChange:()=>R(C)}),W]},C))})]}),t.jsxs("fieldset",{className:"thread-export-dialog-box rounded-2xl border p-3",children:[t.jsx("legend",{className:"thread-export-dialog-subtitle px-1 text-xs",children:"Workspace"}),t.jsx("div",{className:"mt-2 grid gap-2 sm:grid-cols-3",children:[["none","No access"],["read","Read files"],["write","Read and edit"]].map(([C,W])=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex items-center gap-2 rounded-xl px-2.5 py-2 text-sm",children:[t.jsx("input",{type:"radio",checked:P===C,disabled:!a||r,onChange:()=>Q(C)}),W]},C))})]}),t.jsxs("label",{className:"thread-export-dialog-body-text block text-sm",children:["Label",t.jsx("input",{className:"thread-export-dialog-box mt-2 w-full rounded-xl border bg-transparent px-3 py-2 outline-none",disabled:!a||r,onChange:C=>Z(C.target.value),placeholder:"optional",value:D})]}),t.jsxs("div",{className:"thread-export-dialog-box rounded-2xl border",children:[t.jsxs("div",{className:"thread-export-dialog-box-header flex items-center justify-between border-b px-3 py-2.5",children:[t.jsx("p",{className:"thread-export-dialog-strong text-sm font-medium",children:"Shared by me"}),t.jsx("span",{className:"thread-export-dialog-status-pill rounded-full border px-2 py-0.5 text-[10px]",children:(s==null?void 0:s.shares.length)??0})]}),(s==null?void 0:s.status)==="failed"?t.jsx("p",{className:"px-3 py-3 text-sm text-rose-500 dark:text-rose-200",children:s.error}):s!=null&&s.shares.length?t.jsx("div",{className:"divide-y",children:s.shares.map(C=>t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2.5 text-sm",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-export-dialog-strong truncate font-medium",children:C.targetUsername}),t.jsxs("p",{className:"thread-export-dialog-subtitle mt-0.5 text-xs",children:[C.label?`${C.label} · `:"",mx(C.threadAccess)," / ",px(C.workspaceAccess)]})]}),m?t.jsx("button",{type:"button",className:"thread-export-dialog-secondary-button rounded-full border px-3 py-1.5 text-xs transition",disabled:r,onClick:()=>void m(C.id),children:"Revoke"}):null]},C.id))}):t.jsx("p",{className:"thread-export-dialog-subtitle px-3 py-3 text-sm",children:"No active shares for this thread."})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"thread-export-dialog-body-text mt-4 block text-sm",children:["Turns",t.jsx("select",{className:"thread-export-dialog-box mt-2 w-full rounded-xl border bg-transparent px-3 py-2 outline-none",value:w,onChange:C=>x(C.target.value),children:["latest-3","latest-10","latest-20","all-loaded","custom"].map(C=>t.jsx("option",{value:C,children:hx(C)},C))})]}),w==="custom"?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 ",j.size," of ",((E=n.data)==null?void 0:E.totalTurnCount)??p.length]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>y(new Set(p.map(C=>C.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:()=>y(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:p.map(C=>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:j.has(C.turnId),onChange:()=>q(C.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 ",C.turnNumber]}),t.jsx("span",{className:"thread-export-dialog-subtitle shrink-0 text-xs",children:dx(C.startedAt)}),t.jsx("span",{className:"thread-export-dialog-body-text min-w-0 flex-1 truncate text-left",children:C.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:cx(C.status)})]},C.turnId))})]}):null,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:v,onChange:C=>k(C.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.jsx("p",{className:"thread-export-dialog-subtitle min-w-0 text-xs",children:g==="share"?a?"Share access is enforced by the relay server.":"Share permissions are not wired yet.":`${se} ${se===1?"turn":"turns"} selected.`}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:i,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"}),g==="share"?t.jsx("button",{type:"submit",form:"thread-actions-share-form",disabled:!le,className:"ui-status-warning rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:r?"Sharing...":"Share this thread"}):t.jsx("button",{type:"button",onClick:H,disabled:!$,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 fx({detail:e,adapter:r,timelineAdapter:n,TimelineComponent:a=Cl,liveOutput:o="",beforeTimelineContent:s,composerProps:l,timelineProps:i,transcriptItemCount:d,useFloatingMobileComposer:h=!1,floatingMobileComposerBottomOffset:u=0,composerHostRef:m}){const[f,p]=c.useState(!1),[g,b]=c.useState(0),[w,x]=c.useState(0),[j,y]=c.useState(0),[v,k]=c.useState(!1),S=c.useRef(null),N=i==null?void 0:i.onTailVisibilityChange,L=e.pendingRequests.length>0,R=c.useMemo(()=>{const H=e.pendingSteers??[],G=new Set(H.map(T=>T.clientRequestId).filter(T=>!!T));return[...H.filter(T=>T.delivery==="continuation").map(T=>({id:T.id,prompt:T.prompt,...T.id.startsWith("optimistic-")?{optimistic:!0}:{}})),...((i==null?void 0:i.optimisticSteers)??[]).filter(T=>!G.has(T.clientRequestId)).map(T=>({id:T.id,prompt:T.prompt,optimistic:!0}))]},[e.pendingSteers,i==null?void 0:i.optimisticSteers]),P=c.useMemo(()=>(e.pendingSteers??[]).filter(H=>H.delivery==="steer"),[e.pendingSteers]),Q=c.useMemo(()=>{var H;return l?{...l,pendingPrompts:R,...r.steerPendingPrompt&&((H=l.capabilities)!=null&&H.turns.steer)?{onSteerPendingPrompt:G=>{var T;return(T=r.steerPendingPrompt)==null?void 0:T.call(r,e.thread.id,G)}}:{},...r.cancelPendingSteer?{onCancelPendingPrompt:G=>{var T;return(T=r.cancelPendingSteer)==null?void 0:T.call(r,e.thread.id,G)}}:{}}:null},[r.cancelPendingSteer,r.steerPendingPrompt,l,e.thread.id,R]),D=c.useCallback(H=>{N==null||N(H)},[N]);c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const H=window.matchMedia("(max-width: 639px)"),G=()=>p(H.matches);return G(),H.addEventListener("change",G),()=>{H.removeEventListener("change",G)}},[]),c.useEffect(()=>{var G,T;if(typeof window>"u")return;const H=()=>{const F=window.visualViewport,B=F?Math.max(0,Math.round(window.innerHeight-F.height-F.offsetTop)):0,E=F?Math.max(0,Math.round(window.innerHeight-F.height)):B,C=Math.min(B,E),W=Math.max(0,Math.round(window.innerHeight*.52));y(Math.min(C,W))};return H(),(G=window.visualViewport)==null||G.addEventListener("resize",H),(T=window.visualViewport)==null||T.addEventListener("scroll",H),window.addEventListener("resize",H),()=>{var F,B;(F=window.visualViewport)==null||F.removeEventListener("resize",H),(B=window.visualViewport)==null||B.removeEventListener("scroll",H),window.removeEventListener("resize",H)}},[]),c.useLayoutEffect(()=>{const H=S.current;if(!H||!f){b(0);return}const G=()=>{b(Math.ceil(H.getBoundingClientRect().height))};if(G(),typeof ResizeObserver>"u")return;const T=new ResizeObserver(G);return T.observe(H),()=>{T.disconnect()}},[f,l,L]),c.useLayoutEffect(()=>{var F,B;const H=S.current;if(!H||!f){x(0);return}const G=()=>{const E=H.getBoundingClientRect();x(Math.max(0,Math.ceil(window.innerHeight-E.top)))};G(),window.addEventListener("resize",G),(F=window.visualViewport)==null||F.addEventListener("resize",G),(B=window.visualViewport)==null||B.addEventListener("scroll",G);let T=null;return typeof ResizeObserver<"u"&&(T=new ResizeObserver(G),T.observe(H)),()=>{var E,C;window.removeEventListener("resize",G),(E=window.visualViewport)==null||E.removeEventListener("resize",G),(C=window.visualViewport)==null||C.removeEventListener("scroll",G),T==null||T.disconnect()}},[f,j,v,l,L]),c.useEffect(()=>{if(!f){k(!1);return}const H=T=>{var B;const F=T.target;F instanceof HTMLElement&&((B=S.current)!=null&&B.contains(F))&&k(!0)},G=T=>{var B;const F=T.relatedTarget;F instanceof HTMLElement&&((B=S.current)!=null&&B.contains(F))||k(!1)};return document.addEventListener("focusin",H),document.addEventListener("focusout",G),()=>{document.removeEventListener("focusin",H),document.removeEventListener("focusout",G)}},[f]);const Z=c.useCallback(H=>{S.current=H,m&&(m.current=H)},[m]),J=f&&v?Math.max(0,j-u):0,z=Math.max(g,144),te=Math.max(w,z+J),se=f?te+12:0,$=se>0?{"--thread-graph-chat-scroll-bottom-spacer":`${se}px`}:void 0,le=h&&f?{bottom:`${u+J}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"}:void 0,q=c.useMemo(()=>{const H=e.thread.status==="running"||e.thread.activeTurnId!==null;return t.jsx(a,{threadId:e.thread.id,turns:e.turns,totalTurnCount:e.totalTurnCount??e.turns.length,pendingRequests:e.pendingRequests,activeTurnId:e.thread.activeTurnId,threadRunning:H,liveOutput:o,className:"thread-timeline-surface min-h-0 flex-1",...i,pendingSteers:P,optimisticSteers:[],adapter:n,onOpenThread:(i==null?void 0:i.onOpenThread)??r.openThread,onTailVisibilityChange:D})},[a,r.openThread,e.pendingRequests,e.thread.activeTurnId,e.thread.id,e.thread.status,e.totalTurnCount,e.turns,D,o,n,i,P]);return t.jsxs("div",{"data-testid":"chat-panel",className:"thread-graph-chat-panel relative flex h-full min-h-0 flex-col",style:$,children:[s,q,t.jsx("div",{className:"thread-chat-usage-footer hidden shrink-0 items-center px-4 py-1 text-[10px] leading-4 sm:flex",children:t.jsxs("span",{className:"min-w-0",children:[e.turns.length," turn",e.turns.length!==1?"s":"",t.jsx("span",{className:"mx-1 text-[var(--theme-border-contrast)]",children:"|"}),d," item",d!==1?"s":""]})}),Q?h?t.jsx("div",{ref:Z,className:"fixed inset-x-0 bottom-0 z-50 overflow-visible sm:hidden",style:le??{bottom:`${u}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"},children:t.jsx(Un,{...Q,activeView:"chat",edgeToEdgeMobile:!0,onSubmit:r.sendPrompt})}):t.jsx("div",{ref:Z,className:"thread-graph-composer-host shrink-0",children:t.jsx(Un,{...Q,activeView:"chat",onSubmit:r.sendPrompt})}):null]})}function gx(e){return e.turns.reduce((r,n)=>{var o,s;const a=(o=n.tokenUsage)==null?void 0:o.total;return a?{input:r.input+a.inputTokens,output:r.output+a.outputTokens,cache:r.cache+a.cachedInputTokens,cacheWrite:r.cacheWrite+(a.cacheWriteInputTokens??0),priceUsd:r.priceUsd+(((s=n.priceEstimate)==null?void 0:s.totalUsd)??0),pricedTurns:r.pricedTurns+(n.priceEstimate?1:0),turns:r.turns+1}:r},{input:0,output:0,cache:0,cacheWrite:0,priceUsd:0,pricedTurns:0,turns:0})}function Dr(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 xx(e){if(!e||e.turns<=0)return"waiting for agent usage";const r=`in ${Dr(e.input)} / out ${Dr(e.output)} / cache read ${Dr(e.cache)}`,n=e.cacheWrite>0?`${r} / cache write ${Dr(e.cacheWrite)}`:r;return e.pricedTurns>0?`${n} / cost ${yl(e.priceUsd)}`:n}function Tx({threads:e,detail:r,loading:n,error:a,status:o=null,plugins:s,adapter:l,metaContent:i,settingsContent:d,globalSettingsContent:h,settingsDialogOpen:u,onSettingsDialogOpenChange:m,mobileHeaderAction:f,appMenuButton:p,appNavigationMenu:g,workspaceReturnHref:b,onWorkspaceReturn:w,threadActionsButton:x,surfaceActions:j,floatingPanel:y,workspaceContent:v,workspaceTitle:k,workspaceActions:S,workspaceFeatures:N,workspaceFocusPathRequest:L=null,onNewThreadTitle:R,beforeTimelineContent:P,errorContent:Q,workspaceMissingContent:D,dialogs:Z,currentThreadId:J,currentWorkspaceId:z,currentWorkspaceLabel:te,onCloseAppNavigation:se,className:$="thread-detail-surface relative flex h-full min-h-0 flex-1 flex-col overflow-hidden",activeView:le="chat",liveOutput:q="",timelineProps:H,composerProps:G,shellComposerProps:T,useFloatingMobileComposer:F=!1,floatingMobileComposerBottomOffset:B=0,composerHostRef:E,shellPanelRef:C,shellEffectiveTheme:W="dark",shellThemeMode:U=W,onShellThemeModeChange:ne,onShellStateChange:K,shellUnavailableContent:ie,shellDisconnectedContent:ee,timelineComponent:ve=Cl,shellPanelComponent:oe=ox,shellContent:ye,loadingContent:Me,emptyContent:de}){const Ce=ca(),Ee=s??Ce??ia(),{getImageAssetUrl:Y,loadHistoryItemDetail:ue,openWorkspaceFile:ke,openThread:we,cancelPendingSteer:De}=l,Fe=c.useMemo(()=>({...Y?{getImageAssetUrl:ae=>Y(ae.path)}:{},onOpenLinkedThread:we,...ke?{onOpenWorkspaceFile:ke}:{},...ue?{onLoadHistoryItemDetail:ue}:{},...De?{cancelPendingSteer:De}:{}}),[De,Y,ue,ke,we]),Ae=Ee.getThreadPanels().some(ae=>ae.kind==="terminal"),Oe=c.useMemo(()=>r?gx(r):null,[r]),V=c.useMemo(()=>xx(Oe),[Oe]),ce=c.useMemo(()=>{var ae;return r?r.turns.reduce((be,je)=>be+je.items.length,((ae=r.liveItems)==null?void 0:ae.items.length)??0):0},[r]),xe=v??(r?t.jsx(Ll,{detail:r,status:o,plugins:Ee,workspaceAdapter:l.workspace??null,metaContent:i,settingsContent:d,activeView:le,features:N,focusPathRequest:L}):null),I=n?Me??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:$,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"&&(D??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:le==="chat"?"flex min-h-0 flex-1 flex-col":"hidden",children:t.jsx(fx,{detail:r,adapter:l,timelineAdapter:Fe,TimelineComponent:ve,liveOutput:q,transcriptItemCount:ce,useFloatingMobileComposer:F,floatingMobileComposerBottomOffset:B,...P?{beforeTimelineContent:P}:{},...G?{composerProps:G}:{},...H?{timelineProps:H}:{},...E?{composerHostRef:E}:{}})}),t.jsxs("div",{className:le==="shell"?"flex min-h-0 flex-1 flex-col":"hidden",children:[ye??(r.thread.isLoaded&&Ae&&l.shell?t.jsx(oe,{ref:C,threadId:r.thread.id,shellAdapter:l.shell,effectiveTheme:W,isVisible:le==="shell",showHeader:!1,showFloatingToolbox:!1,...K?{onStateChange:K}:{}}):r.thread.isLoaded&&!Ae?ie??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."})]})}):ee??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."})]})})),le==="shell"&&T&&!ye?t.jsx(Un,{...T,activeView:"shell",onSubmit:l.sendPrompt}):null]}),Z]}):de??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."}),O=t.jsx(xp,{threads:e,status:o,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:z??(r==null?void 0:r.thread.workspaceId),currentWorkspaceLabel:te??(r==null?void 0:r.workspace.label),sessionLabel:(r==null?void 0:r.thread.providerSessionId)??(r==null?void 0:r.thread.id),usageLabel:V,threadActionsButton:x,topbarActions:j,metaContent:i,settingsContent:d,globalSettingsContent:h,...u!==void 0?{settingsDialogOpen:u}:{},...m?{onSettingsDialogOpenChange:m}:{},mobileHeaderAction:f,effectiveTheme:W,themeMode:U,appMenuButton:p,appNavigationMenu:g,workspaceReturnHref:b,...w?{onWorkspaceReturn:w}:{},showMobileAppMenu:!!p,showMobileThreadNavToggle:!0,showMobileNewThreadShortcut:!1,onOpenThread:l.openThread,workspaceContent:xe,workspaceTitle:k??"Workspace",workspaceActions:S,...R?{onNewThreadTitle:R}:{},...se?{onCloseAppNavigation:se}:{},...ne?{onThemeModeChange:ne}:{},...l.getThreadHref?{getThreadHref:l.getThreadHref}:{},...l.getNewThreadHref?{getNewThreadHref:l.getNewThreadHref}:{},...l.renderNewThreadDialogContent?{renderNewThreadDialogContent:l.renderNewThreadDialogContent}:{},...l.renameThread?{onRenameThread:l.renameThread}:{},...l.deleteThread?{onDeleteThread:l.deleteThread}:{},children:I});return s?t.jsx(da.Provider,{value:Ee,children:O}):O}var bx={},vx=[];function Ex({adapter:e=bx,builtinPlugins:r=vx,children:n}){const[a,o]=c.useState(()=>Vn(r,[])),[s,l]=c.useState(!1),[i,d]=c.useState(null),h=c.useCallback(async()=>{l(!0),d(null);try{const y=e.fetchPlugins?await e.fetchPlugins():[];o(Vn(r,y))}catch(y){d(y instanceof Error?y.message:"Unable to load plugins.")}finally{l(!1)}},[e,r]);c.useEffect(()=>{h()},[h]);const u=c.useCallback(async(y,v)=>{if(e.updatePlugin){const k=await e.updatePlugin(y,{enabled:v});o(S=>S.map(N=>N.id===k.id?k:N));return}o(k=>k.map(S=>S.id===y?{...S,enabled:v}:S))},[e]),m=c.useCallback(async y=>{if(!e.importPlugin)throw new Error("Plugin import is not available.");const v=await e.importPlugin(y);o(k=>[...k.filter(N=>N.id!==v.id),v])},[e]),f=c.useCallback(async y=>{if(!e.deletePlugin)throw new Error("Plugin uninstall is not available.");const v=await e.deletePlugin(y);o(k=>k.filter(S=>S.id!==v.id))},[e]),p=c.useMemo(()=>{const y=new Set(a.filter(v=>v.enabled).map(v=>v.id));return r.filter(v=>y.has(v.manifest.id))},[r,a]),g=c.useCallback(y=>{var k;const v=p.find(S=>S.renderArtifact&&S.manifest.capabilities.artifactTypes.some(N=>N.type===y.artifact.type));return((k=v==null?void 0:v.renderArtifact)==null?void 0:k.call(v,y))??null},[p]),b=c.useCallback(y=>{for(const v of p)for(const k of v.inlineCodeRenderers??[]){if(!k.languages.includes(y.language.trim().toLowerCase()))continue;const S=k.render(y);if(S)return S}return null},[p]),w=c.useCallback(y=>p.some(v=>!!v.renderArtifact&&v.manifest.capabilities.artifactTypes.some(k=>k.type===y.type)),[p]),x=c.useCallback(()=>p.flatMap(y=>y.threadPanels??[]),[p]),j=c.useMemo(()=>({plugins:a,loading:s,error:i,refresh:h,importPluginManifest:m,setPluginEnabled:u,uninstallPlugin:f,renderArtifact:g,renderInlineCode:b,hasRendererForArtifact:w,getThreadPanels:x}),[i,x,w,m,s,a,h,g,b,u,f]);return t.jsx(da.Provider,{value:j,children:n})}export{tp as A,Cx as C,bp as L,Ex as P,Sx as T,ca as a,Tx as b,ox as c,Cl as d,xp as e,Wt as f,gp as g,rp as t,ll as u};
3712
+ `,I=ye(ve);return!I&&R.current===he&&(R.current=null),I},sendControl(V){return V==="clear"?De():ye(jg(V))},async copyLastCommandOutput(){const V=P.current.trim()||Gs(G);if(!V)return f==null||f("failed","Nothing to copy"),!1;try{return await navigator.clipboard.writeText(V),f==null||f("done","Copied"),!0}catch{return f==null||f("failed","Copy failed"),!1}},focus(){var V;(V=g.current)==null||V.focus()},refreshLayout(V){Oe(V)}}),[f,u,Oe,De,ye,me,we,G,F,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:T,className:`h-full w-full px-2 py-2 sm:px-3 sm:py-3 ${o?"mobile-shell-selectable":""}`,onMouseDown:()=>{var V;h(),(V=g.current)==null||V.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"})]})}),fx=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),k=c.useRef(null),w=c.useRef(!1),[x,j]=c.useState(null),[y,b]=c.useState(!0),[v,S]=c.useState(!1),[N,L]=c.useState(null),[R,P]=c.useState("primary"),[Q,D]=c.useState(null),[Z,J]=c.useState(null),[z,te]=c.useState("single"),[se,_]=c.useState(50),[ie,q]=c.useState(null),[H,G]=c.useState(""),[T,F]=c.useState(!1),[B,E]=c.useState(!1),[C,W]=c.useState(!1),[U,ae]=c.useState({primary:Fs,secondary:Fs}),[K,de]=c.useState(null),ee=(x==null?void 0:x.state)??"not_created",ke=c.useMemo(()=>(x==null?void 0:x.shells)??[],[x==null?void 0:x.shells]),le=c.useMemo(()=>ke.filter(vt),[ke]),je=c.useMemo(()=>le.find(A=>A.id===Q)??null,[le,Q]),Ae=c.useMemo(()=>le.find(A=>A.id===Z)??null,[le,Z]),ce=R==="secondary"?Ae:je,ne=U[R],Le=(x==null?void 0:x.workspacePathStatus)==="missing",Y=R==="secondary"?f:m,me=Yg({activeRuntime:ne,activeShell:ce,busy:v,loading:y,status:ee,workspacePathMissing:Le}),we=me.disabled,ye=me.label,De=me.className,Be=(K==null?void 0:K.tone)==="done"?"shell-floating-feedback shell-floating-feedback-done":(K==null?void 0:K.tone)==="failed"?"shell-floating-feedback shell-floating-feedback-failed":"shell-floating-feedback",_e=c.useCallback((A,X)=>{de({tone:A,text:X}),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{de(null),p.current=null},1800)},[]),Oe=c.useCallback((A,X,be)=>{j(Se=>{var nt;if(!Se)return Se;const Pe=Se.shells.map($e=>$e.id===A?X($e):$e),rt=((nt=Se.shell)==null?void 0:nt.id)===A?X(Se.shell):Pe.find($e=>{var We;return $e.id===((We=Se.shell)==null?void 0:We.id)})??Se.shell;return{...Se,...be?{state:be}:{},shell:rt,shells:Pe}})},[]),V=c.useCallback(async()=>{b(!0);try{const A=await n.fetchState(r);j(A),L(null)}catch(A){L(A instanceof Error?A.message:"Unable to load shell state.")}finally{b(!1)}},[n,r]);c.useEffect(()=>{V()},[V]),c.useEffect(()=>{const A=i==null?void 0:i(r);if(A==null){_(50);return}const X=typeof A=="number"?A:Number.parseFloat(String(A));_(Number.isFinite(X)?Pn(X):50)},[i,r]),c.useEffect(()=>{if(!x){D(null),J(null);return}const A=Xg(x);D(X=>X&&x.shells.some(be=>be.id===X&&vt(be))?X:(A==null?void 0:A.id)??null),J(X=>{if(z!=="columns")return null;if(X&&x.shells.some(Se=>Se.id===X&&vt(Se)))return X;const be=x.shells.find(Se=>vt(Se)&&Se.id!==(A==null?void 0:A.id));return(be==null?void 0:be.id)??null})},[x,z]),c.useEffect(()=>{z!=="columns"&&(P("primary"),J(null))},[z]),c.useEffect(()=>{if(z!=="columns"||Z||le.length<2)return;const A=le.find(X=>X.id!==(je==null?void 0:je.id))??null;A&&J(A.id)},[le,je==null?void 0:je.id,Z,z]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const A=window.matchMedia("(max-width: 767px), (hover: none) and (pointer: coarse)"),X=()=>{F(A.matches),A.matches||(W(!1),E(!1))};return X(),A.addEventListener("change",X),()=>{A.removeEventListener("change",X)}},[]),c.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current),k.current!==null&&window.cancelAnimationFrame(k.current)},[]);const he=c.useCallback((A,X)=>{ae(be=>{const Se=be[A];return Kg(Se,X)?be:{...be,[A]:X}})},[]),ve=c.useCallback(A=>he("primary",A),[he]),I=c.useCallback(A=>he("secondary",A),[he]),O=c.useCallback(A=>{var be;if((be=A.label)!=null&&be.trim())return A.label.trim();const X=ke.findIndex(Se=>Se.id===A.id);return`Shell ${X>=0?X+1:""}`.trim()},[ke]),oe=c.useCallback(A=>{var X;q(A.id),G(((X=A.label)==null?void 0:X.trim())||O(A))},[O]),ge=c.useCallback(()=>{q(null),G("")},[]),Ne=c.useCallback(async()=>{if(ie){S(!0);try{const A=H.trim(),X=await n.updateShell(ie,{label:A.length>0?A:null});j(be=>{var Se;return be&&{...be,state:be.activeShellId===X.id?X.status:be.state,shell:((Se=be.shell)==null?void 0:Se.id)===X.id?X:be.shell,shells:be.shells.map(Pe=>Pe.id===X.id?X:Pe)}}),q(null),G(""),L(null)}catch(A){L(A instanceof Error?A.message:"Unable to rename shell.")}finally{S(!1)}}},[H,ie,n]),Ce=c.useCallback((A,X)=>{if(A==="primary"){D(X),J(be=>be===X?null:be);return}J(X),D(be=>be===X?null:be)},[]),xe=c.useCallback(A=>{var X,be;if(A==="primary"){(X=m.current)==null||X.disconnect(),D(null),z==="columns"&&P("secondary");return}(be=f.current)==null||be.disconnect(),J(null),P("primary"),te("single")},[z]),Ge=c.useCallback((A,X=R)=>{const be=z==="columns"?X:"primary";Ce(be,A.id),z!=="columns"&&J(null),P(be)},[R,Ce,z]),Me=c.useCallback(async(A=R)=>{var X;if(!w.current){w.current=!0,S(!0);try{const be=await n.createShell(r);j(be);const Se=be.activeShellId??((X=be.shell)==null?void 0:X.id)??null;if(Se){const Pe=z==="columns"?A:"primary";Ce(Pe,Se),z!=="columns"&&J(null),P(Pe)}L(null)}catch(be){L(be instanceof Error?be.message:"Unable to create shell.")}finally{w.current=!1,S(!1)}}},[R,Ce,n,z,r]);c.useEffect(()=>{!a||!x||y||v||Le||ee==="creating"||le.length>0||Me("primary")},[v,Me,a,le.length,y,x,ee,Le]);const Qe=c.useCallback(async(A=(ce==null?void 0:ce.id)??"")=>{if(A){S(!0);try{await n.terminateShell(A),D(X=>X===A?null:X),J(X=>X===A?null:X),await V(),L(null)}catch(X){L(X instanceof Error?X.message:"Unable to terminate shell.")}finally{S(!1)}}},[ce==null?void 0:ce.id,V,n]),et=c.useCallback(async()=>{var A,X;if(!we){if(ne.shellInputEnabled){(A=Y.current)==null||A.disconnect();return}if(!ce||ce.status==="exited"||ce.status==="not_found"){await Me(R);return}await((X=Y.current)==null?void 0:X.reconnect())}},[R,Y,ne.shellInputEnabled,ce,we,Me]),it=c.useCallback(A=>{typeof window>"u"||d==null||d(r,Pn(A))},[d,r]),tt=c.useCallback(()=>{var A,X;(A=m.current)==null||A.refreshLayout({syncBackendSize:!0}),(X=f.current)==null||X.refreshLayout({syncBackendSize:!0})},[]),Ke=c.useCallback(A=>{var rt,nt;if(z!=="columns")return;const X=g.current;if(!X)return;A.preventDefault(),(nt=(rt=A.currentTarget).setPointerCapture)==null||nt.call(rt,A.pointerId);const be=$e=>{const We=X.getBoundingClientRect();if(We.width<=0)return;const ut=Pn(($e-We.left)/We.width*100);_(ut),k.current!==null&&window.cancelAnimationFrame(k.current),k.current=window.requestAnimationFrame(()=>{k.current=null,tt()})},Se=$e=>{be($e.clientX)},Pe=$e=>{be($e.clientX);const We=X.getBoundingClientRect();We.width>0&&it(($e.clientX-We.left)/We.width*100),window.removeEventListener("pointermove",Se),window.removeEventListener("pointerup",Pe)};window.addEventListener("pointermove",Se),window.addEventListener("pointerup",Pe,{once:!0})},[it,tt,z]),dt=c.useCallback((A,X)=>{Ce(X,A.id),P(X)},[Ce]),gt=c.useCallback(async()=>{var X;return await((X=Y.current)==null?void 0:X.copyLastCommandOutput())?!0:(_e("failed","Nothing to copy"),!1)},[Y,_e]);c.useEffect(()=>{h==null||h(Zg({activeRuntime:ne,activeShell:ce,connectionButtonDisabled:we,connectionButtonLabel:ye,isMobileShell:T,busy:v,loading:y,error:N}))},[ne,ce,v,we,ye,N,T,y,h]),c.useImperativeHandle(u,()=>({async toggleConnection(){await et()},sendInput(A){var X;return((X=Y.current)==null?void 0:X.sendInput(A))??!1},sendCommand(A){var X;return((X=Y.current)==null?void 0:X.sendCommand(A))??!1},sendControl(A){var X;return((X=Y.current)==null?void 0:X.sendControl(A))??!1},async copyLastCommandOutput(){var A;return await((A=Y.current)==null?void 0:A.copyLastCommandOutput())??!1},async terminate(){await Qe()},focus(){var A;(A=Y.current)==null||A.focus()},refreshLayout(A){var X,be;(X=m.current)==null||X.refreshLayout(A),z==="columns"&&((be=f.current)==null||be.refreshLayout(A))}}),[Y,et,Qe,z]);const Ve=A=>t.jsx("div",{className:`rounded-md border px-2 py-1.5 text-xs ${A.id===(ce==null?void 0:ce.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:[ie===A.id?t.jsx("form",{className:"min-w-0 flex-1",onSubmit:X=>{X.preventDefault(),Ne()},children:t.jsx("input",{value:H,onChange:X=>G(X.currentTarget.value),onKeyDown:X=>{X.key==="Escape"&&(X.preventDefault(),ge())},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:()=>Ge(A),onDoubleClick:()=>oe(A),className:"min-w-0 flex-1 text-left",title:A.tmuxSessionName,children:[t.jsx("span",{className:"block truncate",children:O(A)}),t.jsxs("span",{className:"block truncate text-[10px] text-[var(--theme-fg-muted)]",children:[zn(A.status)," · ",hn(A.cwd)||A.cwd]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[ie===A.id?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>void Ne(),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:ge,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:()=>oe(A),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"}),z==="columns"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>dt(A,"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:()=>dt(A,"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:v,onClick:()=>void Qe(A.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"})]})]})},A.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:ne.promptLabel??(ce==null?void 0:ce.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":ye,title:`${ye} (${zn(ne.status)})`,disabled:we,onClick:()=>void et(),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 ${De}`,children:t.jsx(Cg,{connected:ne.shellInputEnabled})}),ce&&t.jsx("button",{type:"button",disabled:v,onClick:()=>void Qe(ce.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"})]})]}),(N||y||Le)&&t.jsxs("div",{className:"shell-banner mt-3 rounded-2xl border px-3 py-3 text-sm",children:[y&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!y&&Le&&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."}),!y&&N&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:N})]})]}),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:ce?O(ce):"No live shell process"}),ce&&t.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.12em] text-[var(--theme-fg-muted)]",children:zn(ne.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 ",le.length]}),t.jsx("button",{type:"button","aria-expanded":B,"aria-label":B?"Hide shell processes":"Show shell processes",onClick:()=>E(A=>!A),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"})]})]}),B&&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:[le.length," live"]})]}),t.jsxs("div",{className:"max-h-52 space-y-1 overflow-y-auto",children:[le.map(Ve),le.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:v||y||Le,onClick:()=>void Me(R),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:"+"})})]}),ee==="not_created"||Le?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."}),!Le&&t.jsx("button",{type:"button",disabled:v||y,onClick:()=>void Me("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&&(N||y||Le)&&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:[y&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!y&&Le&&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."}),!y&&N&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:N})]}),t.jsxs("div",{ref:g,className:`relative grid h-full min-h-0 ${z==="columns"?"grid-cols-1 sm:grid-cols-[var(--shell-left)_0.35rem_var(--shell-right)]":"grid-cols-1"}`,style:z==="columns"?{"--shell-left":`${se}fr`,"--shell-right":`${100-se}fr`}:void 0,"data-shell-split-ratio":se,children:[t.jsx(Hs,{ref:m,paneId:"primary",shell:je,isActive:R==="primary",isVisible:a,isMobileShell:T,effectiveTheme:l,workspacePathMissing:Le,shellAdapter:n,onActivate:()=>P("primary"),onShellUpdate:Oe,onRuntimeStateChange:ve,onFeedback:_e}),z==="columns"&&t.jsx("button",{type:"button",onClick:()=>xe("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"}),z==="columns"&&t.jsx("button",{type:"button","aria-label":"Resize shell panes",title:"Resize shell panes",onPointerDown:Ke,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"}),z==="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(Hs,{ref:f,paneId:"secondary",shell:Ae,isActive:R==="secondary",isVisible:a,isMobileShell:T,effectiveTheme:l,workspacePathMissing:Le,shellAdapter:n,onActivate:()=>P("secondary"),onShellUpdate:Oe,onRuntimeStateChange:I,onFeedback:_e}),t.jsx("button",{type:"button",onClick:()=>xe("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&&T&&t.jsxs("div",{className:"pointer-events-none absolute bottom-3 right-3 z-20 flex flex-col items-end gap-2",children:[K&&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 ${Be}`,children:K.text}),C&&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:()=>{_e("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(Bs,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:()=>void gt(),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(Bs,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:!ne.shellInputEnabled,onClick:()=>{var A;(A=Y.current)!=null&&A.sendControl("clear")?_e("done","Cleared"):_e("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(Rn,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!ne.shellInputEnabled||!ne.isCommandRunning,onClick:()=>{var A;(A=Y.current)!=null&&A.sendInput("")?_e("done","Sent Ctrl-C"):_e("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(Rn,{label:"CTRL-C",tone:"rose"})}),["ctrl_d","esc","tab","up","down"].map(A=>t.jsx("button",{type:"button",disabled:!ne.shellInputEnabled,onClick:()=>{var X;(X=Y.current)!=null&&X.sendControl(A)?_e("done",`Sent ${A.toUpperCase().replace("_","-")}`):_e("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(Rn,{label:A.toUpperCase().replace("_","-"),tone:"stone"})},A))]})}),t.jsx("button",{type:"button","aria-expanded":C,"aria-label":C?"Close shell tools":"Open shell tools",onClick:()=>W(A=>!A),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(Ng,{})})]})]}),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:[le.length," live"]})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-1 overflow-y-auto",children:[le.map(Ve),le.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:v||y||Le,onClick:()=>void Me(R),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:"+"})})]})]})]})})]})}),gx=c.lazy(async()=>({default:(await Promise.resolve().then(()=>(bu(),sl))).ThreadGraphWorkspacePanel}));function xx(){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 Pl(e){return t.jsx(c.Suspense,{fallback:t.jsx(xx,{}),children:t.jsx(gx,{...e})})}c.memo(Pl);function $x({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?Qr.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 bx(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 vx(e){switch(e){case"inProgress":return"running";case"completed":return"completed";case"interrupted":return"interrupted";case"failed":return"failed"}}function kx(e){switch(e){case"latest-3":return"Latest 3";case"latest-10":return"Latest 10";case"latest-20":return"Latest 20";case"all-loaded":return"All loaded";case"custom":return"Custom"}}function wx(e){switch(e){case"latest-3":return 3;case"latest-10":return 10;case"latest-20":return 20;default:return null}}function yx(e){return e==="read"?"View only":"Collaborator"}function jx(e){switch(e){case"write":return"Workspace write";case"read":return"Workspace read";case"none":default:return"No workspace"}}function _x({open:e,busy:r=!1,turnsState:n,shareAvailable:a=!1,shareUnavailableMessage:s="Relay sharing will be enabled after the relay permission model is connected.",shareState:o,initialMode:l="pdf",onCancel:i,onLoadTurns:d,onExport:h,onCreateShare:u,onRevokeShare:m,onOpenDeviceSharing:f}){var F,B,E;const p=c.useMemo(()=>{var C;return((C=n.data)==null?void 0:C.turns)??[]},[(F=n.data)==null?void 0:F.turns]),[g,k]=c.useState(l),[w,x]=c.useState("latest-10"),[j,y]=c.useState(()=>new Set),[b,v]=c.useState(!0),[S,N]=c.useState(""),[L,R]=c.useState("read"),[P,Q]=c.useState("none"),[D,Z]=c.useState(""),[J,z]=c.useState(()=>typeof document<"u"&&!document.documentElement.classList.contains("dark")?"light":"dark");if(c.useEffect(()=>{e&&(k(l),x("latest-10"),v(!0),N(""),R("read"),Q("none"),Z(""),d())},[l,d,e]),c.useEffect(()=>{e&&p.length>0&&y(new Set(p.slice(0,10).map(C=>C.turnId)))},[e,p]),c.useEffect(()=>{if(!e)return;function C(W){W.key==="Escape"&&!r&&i()}return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[r,i,e]),c.useEffect(()=>{if(!e)return;const C=document.querySelector(".thread-ui-shell"),W=()=>C?C.getAttribute("data-theme-effective")==="dark"||C.classList.contains("dark")||C.classList.contains("thread-ui-theme-dark")?"dark":"light":document.documentElement.classList.contains("dark")?"dark":"light";if(z(W()),!C)return;const U=new MutationObserver(()=>z(W()));return U.observe(C,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>U.disconnect()},[e]),!e)return null;const te=wx(w),se=te!==null?Math.min(te,((B=n.data)==null?void 0:B.totalTurnCount)??te):w==="all-loaded"?p.length:j.size,_=!r&&g!=="share"&&(te!==null||w==="all-loaded"||j.size>0),ie=!r&&a&&!!u&&S.trim().length>0;function q(C){y(W=>{const U=new Set(W);return U.has(C)?U.delete(C):U.add(C),U})}function H(){if(g==="share")return;const C={format:g,...te!==null?{mode:"latest",limit:te}:w==="all-loaded"?{mode:"selected",turnIds:p.map(W=>W.turnId)}:{mode:"selected",turnIds:[...j]},profile:"review",options:{includeTokenAndPrice:b}};h(C)}function G(C){C.preventDefault(),ie&&(u==null||u({targetIdentifier:S.trim(),threadAccess:L,workspaceAccess:P,label:D.trim()||null}))}const T=[{mode:"pdf",label:"PDF"},{mode:"html",label:"HTML"},{mode:"share",label:"Share"}];return Qr.createPortal(t.jsxs("div",{className:`thread-export-dialog-root thread-ui-theme-${J} fixed inset-0 z-[96] flex items-end justify-center p-0 sm:items-center sm:p-6`,"data-theme-effective":J,children:[t.jsx("button",{type:"button","aria-label":"Close thread actions",onClick:i,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":"Thread actions",className:"thread-export-dialog-panel relative z-[1] flex max-h-[min(48rem,calc(100vh-1rem))] w-full max-w-2xl flex-col rounded-t-[1.6rem] border shadow-2xl sm:rounded-[1.6rem]",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:"Thread actions"}),t.jsx("p",{className:"thread-export-dialog-subtitle mt-1 text-xs",children:"Export a review copy or share this thread."})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:i,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:T.map(C=>t.jsx("button",{type:"button",onClick:()=>k(C.mode),className:`rounded-full px-3 py-1.5 text-sm transition ${g===C.mode?"ui-status-warning":"thread-export-dialog-muted-action"}`,children:C.label},C.mode))}),g==="share"?t.jsxs("form",{id:"thread-actions-share-form",className:"mt-4 space-y-4",onSubmit:G,children:[a?null:t.jsx("p",{className:"thread-export-dialog-box thread-export-dialog-subtitle rounded-2xl border px-3 py-3 text-sm",children:s}),a&&f?t.jsxs("div",{className:"thread-export-dialog-box flex flex-wrap items-center justify-between gap-3 rounded-2xl border px-3 py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-export-dialog-strong text-sm font-medium",children:"Share this thread"}),t.jsx("p",{className:"thread-export-dialog-subtitle mt-1 text-xs",children:"Need broader access? Share the whole device from Relay Portal."})]}),t.jsx("button",{type:"button",className:"thread-export-dialog-secondary-button rounded-full border px-3 py-1.5 text-xs font-medium transition",disabled:r,onClick:f,children:"Share whole device"})]}):null,t.jsxs("label",{className:"thread-export-dialog-body-text block text-sm",children:["Relay identifier",t.jsx("input",{className:"thread-export-dialog-box mt-2 w-full rounded-xl border bg-transparent px-3 py-2 outline-none",disabled:!a||r,onChange:C=>N(C.target.value),placeholder:"username or email",value:S})]}),t.jsxs("fieldset",{className:"thread-export-dialog-box rounded-2xl border p-3",children:[t.jsx("legend",{className:"thread-export-dialog-subtitle px-1 text-xs",children:"Thread access"}),t.jsx("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[["read","View only"],["control","Collaborator"]].map(([C,W])=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex items-center gap-2 rounded-xl px-2.5 py-2 text-sm",children:[t.jsx("input",{type:"radio",checked:L===C,disabled:!a||r,onChange:()=>R(C)}),W]},C))})]}),t.jsxs("fieldset",{className:"thread-export-dialog-box rounded-2xl border p-3",children:[t.jsx("legend",{className:"thread-export-dialog-subtitle px-1 text-xs",children:"Workspace"}),t.jsx("div",{className:"mt-2 grid gap-2 sm:grid-cols-3",children:[["none","No access"],["read","Read files"],["write","Read and edit"]].map(([C,W])=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex items-center gap-2 rounded-xl px-2.5 py-2 text-sm",children:[t.jsx("input",{type:"radio",checked:P===C,disabled:!a||r,onChange:()=>Q(C)}),W]},C))})]}),t.jsxs("label",{className:"thread-export-dialog-body-text block text-sm",children:["Label",t.jsx("input",{className:"thread-export-dialog-box mt-2 w-full rounded-xl border bg-transparent px-3 py-2 outline-none",disabled:!a||r,onChange:C=>Z(C.target.value),placeholder:"optional",value:D})]}),t.jsxs("div",{className:"thread-export-dialog-box rounded-2xl border",children:[t.jsxs("div",{className:"thread-export-dialog-box-header flex items-center justify-between border-b px-3 py-2.5",children:[t.jsx("p",{className:"thread-export-dialog-strong text-sm font-medium",children:"Shared by me"}),t.jsx("span",{className:"thread-export-dialog-status-pill rounded-full border px-2 py-0.5 text-[10px]",children:(o==null?void 0:o.shares.length)??0})]}),(o==null?void 0:o.status)==="failed"?t.jsx("p",{className:"px-3 py-3 text-sm text-rose-500 dark:text-rose-200",children:o.error}):o!=null&&o.shares.length?t.jsx("div",{className:"divide-y",children:o.shares.map(C=>t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2.5 text-sm",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-export-dialog-strong truncate font-medium",children:C.targetUsername}),t.jsxs("p",{className:"thread-export-dialog-subtitle mt-0.5 text-xs",children:[C.label?`${C.label} · `:"",yx(C.threadAccess)," / ",jx(C.workspaceAccess)]})]}),m?t.jsx("button",{type:"button",className:"thread-export-dialog-secondary-button rounded-full border px-3 py-1.5 text-xs transition",disabled:r,onClick:()=>void m(C.id),children:"Revoke"}):null]},C.id))}):t.jsx("p",{className:"thread-export-dialog-subtitle px-3 py-3 text-sm",children:"No active shares for this thread."})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"thread-export-dialog-body-text mt-4 block text-sm",children:["Turns",t.jsx("select",{className:"thread-export-dialog-box mt-2 w-full rounded-xl border bg-transparent px-3 py-2 outline-none",value:w,onChange:C=>x(C.target.value),children:["latest-3","latest-10","latest-20","all-loaded","custom"].map(C=>t.jsx("option",{value:C,children:kx(C)},C))})]}),w==="custom"?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 ",j.size," of ",((E=n.data)==null?void 0:E.totalTurnCount)??p.length]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>y(new Set(p.map(C=>C.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:()=>y(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:p.map(C=>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:j.has(C.turnId),onChange:()=>q(C.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 ",C.turnNumber]}),t.jsx("span",{className:"thread-export-dialog-subtitle shrink-0 text-xs",children:bx(C.startedAt)}),t.jsx("span",{className:"thread-export-dialog-body-text min-w-0 flex-1 truncate text-left",children:C.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:vx(C.status)})]},C.turnId))})]}):null,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:b,onChange:C=>v(C.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.jsx("p",{className:"thread-export-dialog-subtitle min-w-0 text-xs",children:g==="share"?a?"Share access is enforced by the relay server.":"Share permissions are not wired yet.":`${se} ${se===1?"turn":"turns"} selected.`}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:i,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"}),g==="share"?t.jsx("button",{type:"submit",form:"thread-actions-share-form",disabled:!ie,className:"ui-status-warning rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:r?"Sharing...":"Share this thread"}):t.jsx("button",{type:"button",onClick:H,disabled:!_,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 Nx({detail:e,adapter:r,timelineAdapter:n,TimelineComponent:a=El,liveOutput:s="",beforeTimelineContent:o,composerProps:l,timelineProps:i,transcriptItemCount:d,useFloatingMobileComposer:h=!1,floatingMobileComposerBottomOffset:u=0,composerHostRef:m}){const[f,p]=c.useState(!1),[g,k]=c.useState(0),[w,x]=c.useState(0),[j,y]=c.useState(0),[b,v]=c.useState(!1),S=c.useRef(null),N=i==null?void 0:i.onTailVisibilityChange,L=e.pendingRequests.length>0,R=c.useMemo(()=>{const H=e.pendingSteers??[],G=new Set(H.map(T=>T.clientRequestId).filter(T=>!!T));return[...H.filter(T=>T.delivery==="continuation").map(T=>({id:T.id,prompt:T.prompt,...T.id.startsWith("optimistic-")?{optimistic:!0}:{}})),...((i==null?void 0:i.optimisticSteers)??[]).filter(T=>!G.has(T.clientRequestId)).map(T=>({id:T.id,prompt:T.prompt,optimistic:!0}))]},[e.pendingSteers,i==null?void 0:i.optimisticSteers]),P=c.useMemo(()=>(e.pendingSteers??[]).filter(H=>H.delivery==="steer"),[e.pendingSteers]),Q=c.useMemo(()=>{var H;return l?{...l,pendingPrompts:R,...r.steerPendingPrompt&&((H=l.capabilities)!=null&&H.turns.steer)?{onSteerPendingPrompt:G=>{var T;return(T=r.steerPendingPrompt)==null?void 0:T.call(r,e.thread.id,G)}}:{},...r.cancelPendingSteer?{onCancelPendingPrompt:G=>{var T;return(T=r.cancelPendingSteer)==null?void 0:T.call(r,e.thread.id,G)}}:{}}:null},[r.cancelPendingSteer,r.steerPendingPrompt,l,e.thread.id,R]),D=c.useCallback(H=>{N==null||N(H)},[N]);c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const H=window.matchMedia("(max-width: 639px)"),G=()=>p(H.matches);return G(),H.addEventListener("change",G),()=>{H.removeEventListener("change",G)}},[]),c.useEffect(()=>{var G,T;if(typeof window>"u")return;const H=()=>{const F=window.visualViewport,B=F?Math.max(0,Math.round(window.innerHeight-F.height-F.offsetTop)):0,E=F?Math.max(0,Math.round(window.innerHeight-F.height)):B,C=Math.min(B,E),W=Math.max(0,Math.round(window.innerHeight*.52));y(Math.min(C,W))};return H(),(G=window.visualViewport)==null||G.addEventListener("resize",H),(T=window.visualViewport)==null||T.addEventListener("scroll",H),window.addEventListener("resize",H),()=>{var F,B;(F=window.visualViewport)==null||F.removeEventListener("resize",H),(B=window.visualViewport)==null||B.removeEventListener("scroll",H),window.removeEventListener("resize",H)}},[]),c.useLayoutEffect(()=>{const H=S.current;if(!H||!f){k(0);return}const G=()=>{k(Math.ceil(H.getBoundingClientRect().height))};if(G(),typeof ResizeObserver>"u")return;const T=new ResizeObserver(G);return T.observe(H),()=>{T.disconnect()}},[f,l,L]),c.useLayoutEffect(()=>{var F,B;const H=S.current;if(!H||!f){x(0);return}const G=()=>{const E=H.getBoundingClientRect();x(Math.max(0,Math.ceil(window.innerHeight-E.top)))};G(),window.addEventListener("resize",G),(F=window.visualViewport)==null||F.addEventListener("resize",G),(B=window.visualViewport)==null||B.addEventListener("scroll",G);let T=null;return typeof ResizeObserver<"u"&&(T=new ResizeObserver(G),T.observe(H)),()=>{var E,C;window.removeEventListener("resize",G),(E=window.visualViewport)==null||E.removeEventListener("resize",G),(C=window.visualViewport)==null||C.removeEventListener("scroll",G),T==null||T.disconnect()}},[f,j,b,l,L]),c.useEffect(()=>{if(!f){v(!1);return}const H=T=>{var B;const F=T.target;F instanceof HTMLElement&&((B=S.current)!=null&&B.contains(F))&&v(!0)},G=T=>{var B;const F=T.relatedTarget;F instanceof HTMLElement&&((B=S.current)!=null&&B.contains(F))||v(!1)};return document.addEventListener("focusin",H),document.addEventListener("focusout",G),()=>{document.removeEventListener("focusin",H),document.removeEventListener("focusout",G)}},[f]);const Z=c.useCallback(H=>{S.current=H,m&&(m.current=H)},[m]),J=f&&b?Math.max(0,j-u):0,z=Math.max(g,144),te=Math.max(w,z+J),se=f?te+12:0,_=se>0?{"--thread-graph-chat-scroll-bottom-spacer":`${se}px`}:void 0,ie=h&&f?{bottom:`${u+J}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"}:void 0,q=c.useMemo(()=>{const H=e.thread.status==="running"||e.thread.activeTurnId!==null;return t.jsx(a,{threadId:e.thread.id,turns:e.turns,totalTurnCount:e.totalTurnCount??e.turns.length,pendingRequests:e.pendingRequests,activeTurnId:e.thread.activeTurnId,threadRunning:H,liveOutput:s,className:"thread-timeline-surface min-h-0 flex-1",...i,pendingSteers:P,optimisticSteers:[],adapter:n,onOpenThread:(i==null?void 0:i.onOpenThread)??r.openThread,onTailVisibilityChange:D})},[a,r.openThread,e.pendingRequests,e.thread.activeTurnId,e.thread.id,e.thread.status,e.totalTurnCount,e.turns,D,s,n,i,P]);return t.jsxs("div",{"data-testid":"chat-panel",className:"thread-graph-chat-panel relative flex h-full min-h-0 flex-col",style:_,children:[o,q,t.jsx("div",{className:"thread-chat-usage-footer hidden shrink-0 items-center px-4 py-1 text-[10px] leading-4 sm:flex",children:t.jsxs("span",{className:"min-w-0",children:[e.turns.length," turn",e.turns.length!==1?"s":"",t.jsx("span",{className:"mx-1 text-[var(--theme-border-contrast)]",children:"|"}),d," item",d!==1?"s":""]})}),Q?h?t.jsx("div",{ref:Z,className:"fixed inset-x-0 bottom-0 z-50 overflow-visible sm:hidden",style:ie??{bottom:`${u}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"},children:t.jsx(Kn,{...Q,activeView:"chat",edgeToEdgeMobile:!0,onSubmit:r.sendPrompt})}):t.jsx("div",{ref:Z,className:"thread-graph-composer-host shrink-0",children:t.jsx(Kn,{...Q,activeView:"chat",onSubmit:r.sendPrompt})}):null]})}function Cx(e){return e.turns.reduce((r,n)=>{var s,o;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,cacheWrite:r.cacheWrite+(a.cacheWriteInputTokens??0),priceUsd:r.priceUsd+(((o=n.priceEstimate)==null?void 0:o.totalUsd)??0),pricedTurns:r.pricedTurns+(n.priceEstimate?1:0),turns:r.turns+1}:r},{input:0,output:0,cache:0,cacheWrite:0,priceUsd:0,pricedTurns:0,turns:0})}function Gr(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 Sx(e){if(!e||e.turns<=0)return"waiting for agent usage";const r=`in ${Gr(e.input)} / out ${Gr(e.output)} / cache read ${Gr(e.cache)}`,n=e.cacheWrite>0?`${r} / cache write ${Gr(e.cacheWrite)}`:r;return e.pricedTurns>0?`${n} / cost ${Nl(e.priceUsd)}`:n}function Tx(e){return!!(e&&typeof e=="object"&&typeof e.id=="string"&&typeof e.kind=="string")}function Ex(e){const r=n=>Array.isArray(n)?n.filter(Tx):[];return{...e,turns:Array.isArray(e.turns)?e.turns.map(n=>({...n,items:r(n.items)})):[],...e.liveItems?{liveItems:{...e.liveItems,items:r(e.liveItems.items)}}:{}}}function Dx({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:k,onWorkspaceReturn:w,threadActionsButton:x,surfaceActions:j,floatingPanel:y,workspaceContent:b,workspaceTitle:v,workspaceActions:S,workspaceFeatures:N,workspaceFocusPathRequest:L=null,onNewThreadTitle:R,beforeTimelineContent:P,errorContent:Q,workspaceMissingContent:D,dialogs:Z,currentThreadId:J,currentWorkspaceId:z,currentWorkspaceLabel:te,onCloseAppNavigation:se,className:_="thread-detail-surface relative flex h-full min-h-0 flex-1 flex-col overflow-hidden",activeView:ie="chat",liveOutput:q="",timelineProps:H,composerProps:G,shellComposerProps:T,useFloatingMobileComposer:F=!1,floatingMobileComposerBottomOffset:B=0,composerHostRef:E,shellPanelRef:C,shellEffectiveTheme:W="dark",shellThemeMode:U=W,onShellThemeModeChange:ae,onShellStateChange:K,shellUnavailableContent:de,shellDisconnectedContent:ee,timelineComponent:ke=El,shellPanelComponent:le=fx,shellContent:je,loadingContent:Ae,emptyContent:ce}){const ne=c.useMemo(()=>r?Ex(r):null,[r]),Le=ua(),Y=o??Le??ca(),{getImageAssetUrl:me,loadHistoryItemDetail:we,openWorkspaceFile:ye,openThread:De,cancelPendingSteer:Be}=l,_e=c.useMemo(()=>({...me?{getImageAssetUrl:ge=>me(ge.path)}:{},onOpenLinkedThread:De,...ye?{onOpenWorkspaceFile:ye}:{},...we?{onLoadHistoryItemDetail:we}:{},...Be?{cancelPendingSteer:Be}:{}}),[Be,me,we,ye,De]),Oe=Y.getThreadPanels().some(ge=>ge.kind==="terminal"),V=c.useMemo(()=>ne?Cx(ne):null,[ne]),he=c.useMemo(()=>Sx(V),[V]),ve=c.useMemo(()=>{var ge;return ne?ne.turns.reduce((Ne,Ce)=>Ne+Ce.items.length,((ge=ne.liveItems)==null?void 0:ge.items.length)??0):0},[ne]),I=b??(ne?t.jsx(Pl,{detail:ne,status:s,plugins:Y,workspaceAdapter:l.workspace??null,metaContent:i,settingsContent:d,activeView:ie,features:N,focusPathRequest:L}):null),O=n?Ae??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..."}):ne?t.jsxs("div",{className:_,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})),ne.workspacePathStatus==="missing"&&(D??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:ne.workspace.absPath})]})),t.jsx("div",{className:ie==="chat"?"flex min-h-0 flex-1 flex-col":"hidden",children:t.jsx(Nx,{detail:ne,adapter:l,timelineAdapter:_e,TimelineComponent:ke,liveOutput:q,transcriptItemCount:ve,useFloatingMobileComposer:F,floatingMobileComposerBottomOffset:B,...P?{beforeTimelineContent:P}:{},...G?{composerProps:G}:{},...H?{timelineProps:H}:{},...E?{composerHostRef:E}:{}})}),t.jsxs("div",{className:ie==="shell"?"flex min-h-0 flex-1 flex-col":"hidden",children:[je??(ne.thread.isLoaded&&Oe&&l.shell?t.jsx(le,{ref:C,threadId:ne.thread.id,shellAdapter:l.shell,effectiveTheme:W,isVisible:ie==="shell",showHeader:!1,showFloatingToolbox:!1,...K?{onStateChange:K}:{}}):ne.thread.isLoaded&&!Oe?de??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."})]})}):ee??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."})]})})),ie==="shell"&&T&&!je?t.jsx(Kn,{...T,activeView:"shell",onSubmit:l.sendPrompt}):null]}),Z]}):ce??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."}),oe=t.jsx(kp,{threads:e,status:s,loading:n,error:n?null:a,viewportConstrained:!0,currentThreadId:J??(ne==null?void 0:ne.thread.id),currentThreadLabel:ne==null?void 0:ne.thread.title,currentWorkspaceId:z??(ne==null?void 0:ne.thread.workspaceId),currentWorkspaceLabel:te??(ne==null?void 0:ne.workspace.label),sessionLabel:(ne==null?void 0:ne.thread.providerSessionId)??(ne==null?void 0:ne.thread.id),usageLabel:he,threadActionsButton:x,topbarActions:j,metaContent:i,settingsContent:d,globalSettingsContent:h,...u!==void 0?{settingsDialogOpen:u}:{},...m?{onSettingsDialogOpenChange:m}:{},mobileHeaderAction:f,effectiveTheme:W,themeMode:U,appMenuButton:p,appNavigationMenu:g,workspaceReturnHref:k,...w?{onWorkspaceReturn:w}:{},showMobileAppMenu:!!p,showMobileThreadNavToggle:!0,showMobileNewThreadShortcut:!1,onOpenThread:l.openThread,workspaceContent:I,workspaceTitle:v??"Workspace",workspaceActions:S,...R?{onNewThreadTitle:R}:{},...se?{onCloseAppNavigation:se}:{},...ae?{onThemeModeChange:ae}:{},...l.getThreadHref?{getThreadHref:l.getThreadHref}:{},...l.getNewThreadHref?{getNewThreadHref:l.getNewThreadHref}:{},...l.renderNewThreadDialogContent?{renderNewThreadDialogContent:l.renderNewThreadDialogContent}:{},...l.renameThread?{onRenameThread:l.renameThread}:{},...l.deleteThread?{onDeleteThread:l.deleteThread}:{},children:O});return o?t.jsx(ha.Provider,{value:Y,children:oe}):oe}var Lx={},Ix=[];function Bx({adapter:e=Lx,builtinPlugins:r=Ix,children:n}){const[a,s]=c.useState(()=>Xn(r,[])),[o,l]=c.useState(!1),[i,d]=c.useState(null),h=c.useCallback(async()=>{l(!0),d(null);try{const y=e.fetchPlugins?await e.fetchPlugins():[];s(Xn(r,y))}catch(y){d(y instanceof Error?y.message:"Unable to load plugins.")}finally{l(!1)}},[e,r]);c.useEffect(()=>{h()},[h]);const u=c.useCallback(async(y,b)=>{if(e.updatePlugin){const v=await e.updatePlugin(y,{enabled:b});s(S=>S.map(N=>N.id===v.id?v:N));return}s(v=>v.map(S=>S.id===y?{...S,enabled:b}:S))},[e]),m=c.useCallback(async y=>{if(!e.importPlugin)throw new Error("Plugin import is not available.");const b=await e.importPlugin(y);s(v=>[...v.filter(N=>N.id!==b.id),b])},[e]),f=c.useCallback(async y=>{if(!e.deletePlugin)throw new Error("Plugin uninstall is not available.");const b=await e.deletePlugin(y);s(v=>v.filter(S=>S.id!==b.id))},[e]),p=c.useMemo(()=>{const y=new Set(a.filter(b=>b.enabled).map(b=>b.id));return r.filter(b=>y.has(b.manifest.id))},[r,a]),g=c.useCallback(y=>{var v;const b=p.find(S=>S.renderArtifact&&S.manifest.capabilities.artifactTypes.some(N=>N.type===y.artifact.type));return((v=b==null?void 0:b.renderArtifact)==null?void 0:v.call(b,y))??null},[p]),k=c.useCallback(y=>{for(const b of p)for(const v of b.inlineCodeRenderers??[]){if(!v.languages.includes(y.language.trim().toLowerCase()))continue;const S=v.render(y);if(S)return S}return null},[p]),w=c.useCallback(y=>p.some(b=>!!b.renderArtifact&&b.manifest.capabilities.artifactTypes.some(v=>v.type===y.type)),[p]),x=c.useCallback(()=>p.flatMap(y=>y.threadPanels??[]),[p]),j=c.useMemo(()=>({plugins:a,loading:o,error:i,refresh:h,importPluginManifest:m,setPluginEnabled:u,uninstallPlugin:f,renderArtifact:g,renderInlineCode:k,hasRendererForArtifact:w,getThreadPanels:x}),[i,x,w,m,o,a,h,g,k,u,f]);return t.jsx(ha.Provider,{value:j,children:n})}export{ap as A,$x as C,wp as L,Bx as P,_x as T,ua as a,Dx as b,fx as c,El as d,kp as e,Ut as f,vp as g,sp as t,cl as u};