remote-codex 0.11.26 → 0.11.27

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-oEok_Crl.js","assets/markdown-vendor-BQJfKm05.js","assets/react-vendor-CgLzZcV4.js","assets/html-pp8916En.js","assets/javascript-wDzz0qaB.js","assets/css-CLj8gQPS.js","assets/terminal-vendor-B365Go3Z.js","assets/terminal-vendor-Beg8tuEN.css"])))=>i.map(i=>d[i]);
2
- import{l as B,R as $i,I as Di,C as Bi,S as Rs,H as Gi,T as Fi,a as Hi,b as Oi,c as Ui,d as Wi,e as Vi,D as Ki,P as qi,O as Xi,f as Yi,g as Zi,h as Ji,i as Qi,j as ed,k as td,m as rd,n as nd,A as ad,o as sd,p as od}from"./ui-vendor-CeKGesq3.js";import{r as c,R as ld,j as t,b as Or}from"./react-vendor-CgLzZcV4.js";import{u as id,a as dd,H as va,P as Mt,b as cd,M as As,R as hd,i as ud,C as md,B as pd,c as ka,g as _s}from"./graph-vendor-DVPtkh3h.js";import"./terminal-vendor-B365Go3Z.js";import{M as fd,r as gd,a as xd,b as bd}from"./markdown-vendor-BQJfKm05.js";const vd="modulepreload",kd=function(e){return"/"+e},wa={},Ke=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=kd(h),h in wa)return;wa[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":vd,u||(f.as="script"),f.crossOrigin="",f.href=h,d&&f.setAttribute("nonce",d),document.head.appendChild(f),u)return new Promise((p,g)=>{f.addEventListener("load",p),f.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${h}`)))})}))}function o(l){const i=new Event("vite:preloadError",{cancelable:!0});if(i.payload=l,window.dispatchEvent(i),!i.defaultPrevented)throw l}return s.then(l=>{for(const i of l||[])i.status==="rejected"&&o(i.reason);return r().catch(o)})};function Ms(e){var r,n,a="";if(typeof e=="string"||typeof e=="number")a+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(r=0;r<s;r++)e[r]&&(n=Ms(e[r]))&&(a&&(a+=" "),a+=n)}else for(n in e)e[n]&&(a&&(a+=" "),a+=n);return a}function $s(){for(var e,r,n=0,a="",s=arguments.length;n<s;n++)(e=arguments[n])&&(r=Ms(e))&&(a&&(a+=" "),a+=r);return a}const wd=(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},yd=(e,r)=>({classGroupId:e,validator:r}),Ds=(e=new Map,r=null,n)=>({nextPart:e,validators:r,classGroupId:n}),$r="-",ya=[],jd="arbitrary..",Nd=e=>{const r=Sd(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:a}=e;return{getClassGroupId:l=>{if(l.startsWith("[")&&l.endsWith("]"))return Cd(l);const i=l.split($r),d=i[0]===""&&i.length>1?1:0;return Bs(i,d,r)},getConflictingClassGroupIds:(l,i)=>{if(i){const d=a[l],h=n[l];return d?h?wd(h,d):d:h||ya}return n[l]||ya}}},Bs=(e,r,n)=>{if(e.length-r===0)return n.classGroupId;const s=e[r],o=n.nextPart.get(s);if(o){const h=Bs(e,r+1,o);if(h)return h}const l=n.validators;if(l===null)return;const i=r===0?e.join($r):e.slice(r).join($r),d=l.length;for(let h=0;h<d;h++){const u=l[h];if(u.validator(i))return u.classGroupId}},Cd=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?jd+a:void 0})(),Sd=e=>{const{theme:r,classGroups:n}=e;return Td(n,r)},Td=(e,r)=>{const n=Ds();for(const a in e){const s=e[a];Kn(s,n,a,r)}return n},Kn=(e,r,n,a)=>{const s=e.length;for(let o=0;o<s;o++){const l=e[o];Ed(l,r,n,a)}},Ed=(e,r,n,a)=>{if(typeof e=="string"){Ld(e,r,n);return}if(typeof e=="function"){Pd(e,r,n,a);return}zd(e,r,n,a)},Ld=(e,r,n)=>{const a=e===""?r:Gs(r,e);a.classGroupId=n},Pd=(e,r,n,a)=>{if(Id(e)){Kn(e(a),r,n,a);return}r.validators===null&&(r.validators=[]),r.validators.push(yd(n,e))},zd=(e,r,n,a)=>{const s=Object.entries(e),o=s.length;for(let l=0;l<o;l++){const[i,d]=s[l];Kn(d,Gs(r,i),n,a)}},Gs=(e,r)=>{let n=e;const a=r.split($r),s=a.length;for(let o=0;o<s;o++){const l=a[o];let i=n.nextPart.get(l);i||(i=Ds(),n.nextPart.set(l,i)),n=i}return n},Id=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Rd=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)}}},Sn="!",ja=":",Ad=[],Na=(e,r,n,a,s)=>({modifiers:e,hasImportantModifier:r,baseClassName:n,maybePostfixModifierPosition:a,isExternal:s}),_d=e=>{const{prefix:r,experimentalParseClassName:n}=e;let a=s=>{const o=[];let l=0,i=0,d=0,h;const u=s.length;for(let b=0;b<u;b++){const v=s[b];if(l===0&&i===0){if(v===ja){o.push(s.slice(d,b)),d=b+1;continue}if(v==="/"){h=b;continue}}v==="["?l++:v==="]"?l--:v==="("?i++:v===")"&&i--}const m=o.length===0?s:s.slice(d);let f=m,p=!1;m.endsWith(Sn)?(f=m.slice(0,-1),p=!0):m.startsWith(Sn)&&(f=m.slice(1),p=!0);const g=h&&h>d?h-d:void 0;return Na(o,p,f,g)};if(r){const s=r+ja,o=a;a=l=>l.startsWith(s)?o(l.slice(s.length)):Na(Ad,!1,l,void 0,!0)}if(n){const s=a;a=o=>n({className:o,parseClassName:s})}return a},Md=e=>{const r=new Map;return e.orderSensitiveModifiers.forEach((n,a)=>{r.set(n,1e6+a)}),n=>{const a=[];let s=[];for(let o=0;o<n.length;o++){const l=n[o],i=l[0]==="[",d=r.has(l);i||d?(s.length>0&&(s.sort(),a.push(...s),s=[]),a.push(l)):s.push(l)}return s.length>0&&(s.sort(),a.push(...s)),a}},$d=e=>({cache:Rd(e.cacheSize),parseClassName:_d(e),sortModifiers:Md(e),postfixLookupClassGroupIds:Dd(e),...Nd(e)}),Dd=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},Bd=/\s+/,Gd=(e,r)=>{const{parseClassName:n,getClassGroupId:a,getConflictingClassGroupIds:s,sortModifiers:o,postfixLookupClassGroupIds:l}=r,i=[],d=e.trim().split(Bd);let h="";for(let u=d.length-1;u>=0;u-=1){const m=d[u],{isExternal:f,modifiers:p,hasImportantModifier:g,baseClassName:b,maybePostfixModifierPosition:v}=n(m);if(f){h=m+(h.length>0?" "+h:h);continue}let x=!!v,y;if(x){const S=b.substring(0,v);y=a(S);const L=y&&l[y]?a(b):void 0;L&&L!==y&&(y=L,x=!1)}else y=a(b);if(!y){if(!x){h=m+(h.length>0?" "+h:h);continue}if(y=a(b),!y){h=m+(h.length>0?" "+h:h);continue}x=!1}const k=p.length===0?"":p.length===1?p[0]:o(p).join(":"),C=g?k+Sn:k,w=C+y;if(i.indexOf(w)>-1)continue;i.push(w);const j=s(y,x);for(let S=0;S<j.length;++S){const L=j[S];i.push(C+L)}h=m+(h.length>0?" "+h:h)}return h},Fd=(...e)=>{let r=0,n,a,s="";for(;r<e.length;)(n=e[r++])&&(a=Fs(n))&&(s&&(s+=" "),s+=a);return s},Fs=e=>{if(typeof e=="string")return e;let r,n="";for(let a=0;a<e.length;a++)e[a]&&(r=Fs(e[a]))&&(n&&(n+=" "),n+=r);return n},Hd=(e,...r)=>{let n,a,s,o;const l=d=>{const h=r.reduce((u,m)=>m(u),e());return n=$d(h),a=n.cache.get,s=n.cache.set,o=i,i(d)},i=d=>{const h=a(d);if(h)return h;const u=Gd(d,n);return s(d,u),u};return o=l,(...d)=>o(Fd(...d))},Od=[],Je=e=>{const r=n=>n[e]||Od;return r.isThemeGetter=!0,r},Hs=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Os=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Ud=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Wd=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Vd=/\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$/,Kd=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,qd=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Xd=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Nt=e=>Ud.test(e),Te=e=>!!e&&!Number.isNaN(Number(e)),mt=e=>!!e&&Number.isInteger(Number(e)),ln=e=>e.endsWith("%")&&Te(e.slice(0,-1)),bt=e=>Wd.test(e),Us=()=>!0,Yd=e=>Vd.test(e)&&!Kd.test(e),qn=()=>!1,Zd=e=>qd.test(e),Jd=e=>Xd.test(e),Qd=e=>!ce(e)&&!he(e),ec=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)),tc=e=>Lt(e,Ks,qn),ce=e=>Hs.test(e),Rt=e=>Lt(e,qs,Yd),Ca=e=>Lt(e,dc,Te),rc=e=>Lt(e,Ys,Us),nc=e=>Lt(e,Xs,qn),Sa=e=>Lt(e,Ws,qn),ac=e=>Lt(e,Vs,Jd),Nr=e=>Lt(e,Zs,Zd),he=e=>Os.test(e),or=e=>Ht(e,qs),sc=e=>Ht(e,Xs),Ta=e=>Ht(e,Ws),oc=e=>Ht(e,Ks),lc=e=>Ht(e,Vs),Cr=e=>Ht(e,Zs,!0),ic=e=>Ht(e,Ys,!0),Lt=(e,r,n)=>{const a=Hs.exec(e);return a?a[1]?r(a[1]):n(a[2]):!1},Ht=(e,r,n=!1)=>{const a=Os.exec(e);return a?a[1]?r(a[1]):n:!1},Ws=e=>e==="position"||e==="percentage",Vs=e=>e==="image"||e==="url",Ks=e=>e==="length"||e==="size"||e==="bg-size",qs=e=>e==="length",dc=e=>e==="number",Xs=e=>e==="family-name",Ys=e=>e==="number"||e==="weight",Zs=e=>e==="shadow",cc=()=>{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"),b=Je("perspective"),v=Je("aspect"),x=Je("ease"),y=Je("animate"),k=()=>["auto","avoid","all","avoid-page","page","left","right","column"],C=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],w=()=>[...C(),he,ce],j=()=>["auto","hidden","clip","visible","scroll"],S=()=>["auto","contain","none"],L=()=>[he,ce,d],P=()=>[Nt,"full","auto",...L()],K=()=>[mt,"none","subgrid",he,ce],F=()=>["auto",{span:["full",mt,he,ce]},mt,he,ce],R=()=>[mt,"auto",he,ce],J=()=>["auto","min","max","fr",he,ce],Z=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],D=()=>["start","end","center","stretch","center-safe","end-safe"],te=()=>["auto",...L()],oe=()=>[Nt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...L()],_=()=>[Nt,"screen","full","dvw","lvw","svw","min","max","fit",...L()],Y=()=>[Nt,"screen","full","lh","dvh","lvh","svh","min","max","fit",...L()],I=()=>[e,he,ce],q=()=>[...C(),Ta,Sa,{position:[he,ce]}],H=()=>["no-repeat",{repeat:["","x","y","space","round"]}],E=()=>["auto","cover","contain",oc,tc,{size:[he,ce]}],W=()=>[ln,or,Rt],O=()=>["","none","full",h,he,ce],N=()=>["",Te,or,Rt],T=()=>["solid","dashed","dotted","double"],U=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],X=()=>[Te,ln,Ta,Sa],ie=()=>["","none",g,he,ce],Q=()=>["none",Te,he,ce],de=()=>["none",Te,he,ce],re=()=>[Te,he,ce],xe=()=>[Nt,"full",...L()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[bt],breakpoint:[bt],color:[Us],container:[bt],"drop-shadow":[bt],ease:["in","out","in-out"],font:[Qd],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[bt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[bt],shadow:[bt],spacing:["px",Te],text:[bt],"text-shadow":[bt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Nt,ce,he,v]}],container:["container"],"container-type":[{"@container":["","normal","size",he,ce]}],"container-named":[ec],columns:[{columns:[Te,ce,he,i]}],"break-after":[{"break-after":k()}],"break-before":[{"break-before":k()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:w()}],overflow:[{overflow:j()}],"overflow-x":[{"overflow-x":j()}],"overflow-y":[{"overflow-y":j()}],overscroll:[{overscroll:S()}],"overscroll-x":[{"overscroll-x":S()}],"overscroll-y":[{"overscroll-y":S()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:P()}],"inset-x":[{"inset-x":P()}],"inset-y":[{"inset-y":P()}],start:[{"inset-s":P(),start:P()}],end:[{"inset-e":P(),end:P()}],"inset-bs":[{"inset-bs":P()}],"inset-be":[{"inset-be":P()}],top:[{top:P()}],right:[{right:P()}],bottom:[{bottom:P()}],left:[{left:P()}],visibility:["visible","invisible","collapse"],z:[{z:[mt,"auto",he,ce]}],basis:[{basis:[Nt,"full","auto",i,...L()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Te,Nt,"auto","initial","none",ce]}],grow:[{grow:["",Te,he,ce]}],shrink:[{shrink:["",Te,he,ce]}],order:[{order:[mt,"first","last","none",he,ce]}],"grid-cols":[{"grid-cols":K()}],"col-start-end":[{col:F()}],"col-start":[{"col-start":R()}],"col-end":[{"col-end":R()}],"grid-rows":[{"grid-rows":K()}],"row-start-end":[{row:F()}],"row-start":[{"row-start":R()}],"row-end":[{"row-end":R()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":J()}],"auto-rows":[{"auto-rows":J()}],gap:[{gap:L()}],"gap-x":[{"gap-x":L()}],"gap-y":[{"gap-y":L()}],"justify-content":[{justify:[...Z(),"normal"]}],"justify-items":[{"justify-items":[...D(),"normal"]}],"justify-self":[{"justify-self":["auto",...D()]}],"align-content":[{content:["normal",...Z()]}],"align-items":[{items:[...D(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...D(),{baseline:["","last"]}]}],"place-content":[{"place-content":Z()}],"place-items":[{"place-items":[...D(),"baseline"]}],"place-self":[{"place-self":["auto",...D()]}],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:oe()}],"inline-size":[{inline:["auto",..._()]}],"min-inline-size":[{"min-inline":["auto",..._()]}],"max-inline-size":[{"max-inline":["none",..._()]}],"block-size":[{block:["auto",...Y()]}],"min-block-size":[{"min-block":["auto",...Y()]}],"max-block-size":[{"max-block":["none",...Y()]}],w:[{w:[i,"screen",...oe()]}],"min-w":[{"min-w":[i,"screen","none",...oe()]}],"max-w":[{"max-w":[i,"screen","none","prose",{screen:[l]},...oe()]}],h:[{h:["screen","lh",...oe()]}],"min-h":[{"min-h":["screen","lh","none",...oe()]}],"max-h":[{"max-h":["screen","lh",...oe()]}],"font-size":[{text:["base",n,or,Rt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,ic,rc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",ln,ce]}],"font-family":[{font:[sc,nc,r]}],"font-features":[{"font-features":[ce]}],"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,he,ce]}],"line-clamp":[{"line-clamp":[Te,"none",he,Ca]}],leading:[{leading:[o,...L()]}],"list-image":[{"list-image":["none",he,ce]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",he,ce]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:I()}],"text-color":[{text:I()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...T(),"wavy"]}],"text-decoration-thickness":[{decoration:[Te,"from-font","auto",he,Rt]}],"text-decoration-color":[{decoration:I()}],"underline-offset":[{"underline-offset":[Te,"auto",he,ce]}],"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:[mt,he,ce]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",he,ce]}],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",he,ce]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:q()}],"bg-repeat":[{bg:H()}],"bg-size":[{bg:E()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},mt,he,ce],radial:["",he,ce],conic:[mt,he,ce]},lc,ac]}],"bg-color":[{bg:I()}],"gradient-from-pos":[{from:W()}],"gradient-via-pos":[{via:W()}],"gradient-to-pos":[{to:W()}],"gradient-from":[{from:I()}],"gradient-via":[{via:I()}],"gradient-to":[{to:I()}],rounded:[{rounded:O()}],"rounded-s":[{"rounded-s":O()}],"rounded-e":[{"rounded-e":O()}],"rounded-t":[{"rounded-t":O()}],"rounded-r":[{"rounded-r":O()}],"rounded-b":[{"rounded-b":O()}],"rounded-l":[{"rounded-l":O()}],"rounded-ss":[{"rounded-ss":O()}],"rounded-se":[{"rounded-se":O()}],"rounded-ee":[{"rounded-ee":O()}],"rounded-es":[{"rounded-es":O()}],"rounded-tl":[{"rounded-tl":O()}],"rounded-tr":[{"rounded-tr":O()}],"rounded-br":[{"rounded-br":O()}],"rounded-bl":[{"rounded-bl":O()}],"border-w":[{border:N()}],"border-w-x":[{"border-x":N()}],"border-w-y":[{"border-y":N()}],"border-w-s":[{"border-s":N()}],"border-w-e":[{"border-e":N()}],"border-w-bs":[{"border-bs":N()}],"border-w-be":[{"border-be":N()}],"border-w-t":[{"border-t":N()}],"border-w-r":[{"border-r":N()}],"border-w-b":[{"border-b":N()}],"border-w-l":[{"border-l":N()}],"divide-x":[{"divide-x":N()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":N()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...T(),"hidden","none"]}],"divide-style":[{divide:[...T(),"hidden","none"]}],"border-color":[{border:I()}],"border-color-x":[{"border-x":I()}],"border-color-y":[{"border-y":I()}],"border-color-s":[{"border-s":I()}],"border-color-e":[{"border-e":I()}],"border-color-bs":[{"border-bs":I()}],"border-color-be":[{"border-be":I()}],"border-color-t":[{"border-t":I()}],"border-color-r":[{"border-r":I()}],"border-color-b":[{"border-b":I()}],"border-color-l":[{"border-l":I()}],"divide-color":[{divide:I()}],"outline-style":[{outline:[...T(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Te,he,ce]}],"outline-w":[{outline:["",Te,or,Rt]}],"outline-color":[{outline:I()}],shadow:[{shadow:["","none",u,Cr,Nr]}],"shadow-color":[{shadow:I()}],"inset-shadow":[{"inset-shadow":["none",m,Cr,Nr]}],"inset-shadow-color":[{"inset-shadow":I()}],"ring-w":[{ring:N()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:I()}],"ring-offset-w":[{"ring-offset":[Te,Rt]}],"ring-offset-color":[{"ring-offset":I()}],"inset-ring-w":[{"inset-ring":N()}],"inset-ring-color":[{"inset-ring":I()}],"text-shadow":[{"text-shadow":["none",f,Cr,Nr]}],"text-shadow-color":[{"text-shadow":I()}],opacity:[{opacity:[Te,he,ce]}],"mix-blend":[{"mix-blend":[...U(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":U()}],"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":[Te]}],"mask-image-linear-from-pos":[{"mask-linear-from":X()}],"mask-image-linear-to-pos":[{"mask-linear-to":X()}],"mask-image-linear-from-color":[{"mask-linear-from":I()}],"mask-image-linear-to-color":[{"mask-linear-to":I()}],"mask-image-t-from-pos":[{"mask-t-from":X()}],"mask-image-t-to-pos":[{"mask-t-to":X()}],"mask-image-t-from-color":[{"mask-t-from":I()}],"mask-image-t-to-color":[{"mask-t-to":I()}],"mask-image-r-from-pos":[{"mask-r-from":X()}],"mask-image-r-to-pos":[{"mask-r-to":X()}],"mask-image-r-from-color":[{"mask-r-from":I()}],"mask-image-r-to-color":[{"mask-r-to":I()}],"mask-image-b-from-pos":[{"mask-b-from":X()}],"mask-image-b-to-pos":[{"mask-b-to":X()}],"mask-image-b-from-color":[{"mask-b-from":I()}],"mask-image-b-to-color":[{"mask-b-to":I()}],"mask-image-l-from-pos":[{"mask-l-from":X()}],"mask-image-l-to-pos":[{"mask-l-to":X()}],"mask-image-l-from-color":[{"mask-l-from":I()}],"mask-image-l-to-color":[{"mask-l-to":I()}],"mask-image-x-from-pos":[{"mask-x-from":X()}],"mask-image-x-to-pos":[{"mask-x-to":X()}],"mask-image-x-from-color":[{"mask-x-from":I()}],"mask-image-x-to-color":[{"mask-x-to":I()}],"mask-image-y-from-pos":[{"mask-y-from":X()}],"mask-image-y-to-pos":[{"mask-y-to":X()}],"mask-image-y-from-color":[{"mask-y-from":I()}],"mask-image-y-to-color":[{"mask-y-to":I()}],"mask-image-radial":[{"mask-radial":[he,ce]}],"mask-image-radial-from-pos":[{"mask-radial-from":X()}],"mask-image-radial-to-pos":[{"mask-radial-to":X()}],"mask-image-radial-from-color":[{"mask-radial-from":I()}],"mask-image-radial-to-color":[{"mask-radial-to":I()}],"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":C()}],"mask-image-conic-pos":[{"mask-conic":[Te]}],"mask-image-conic-from-pos":[{"mask-conic-from":X()}],"mask-image-conic-to-pos":[{"mask-conic-to":X()}],"mask-image-conic-from-color":[{"mask-conic-from":I()}],"mask-image-conic-to-color":[{"mask-conic-to":I()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:q()}],"mask-repeat":[{mask:H()}],"mask-size":[{mask:E()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",he,ce]}],filter:[{filter:["","none",he,ce]}],blur:[{blur:ie()}],brightness:[{brightness:[Te,he,ce]}],contrast:[{contrast:[Te,he,ce]}],"drop-shadow":[{"drop-shadow":["","none",p,Cr,Nr]}],"drop-shadow-color":[{"drop-shadow":I()}],grayscale:[{grayscale:["",Te,he,ce]}],"hue-rotate":[{"hue-rotate":[Te,he,ce]}],invert:[{invert:["",Te,he,ce]}],saturate:[{saturate:[Te,he,ce]}],sepia:[{sepia:["",Te,he,ce]}],"backdrop-filter":[{"backdrop-filter":["","none",he,ce]}],"backdrop-blur":[{"backdrop-blur":ie()}],"backdrop-brightness":[{"backdrop-brightness":[Te,he,ce]}],"backdrop-contrast":[{"backdrop-contrast":[Te,he,ce]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Te,he,ce]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Te,he,ce]}],"backdrop-invert":[{"backdrop-invert":["",Te,he,ce]}],"backdrop-opacity":[{"backdrop-opacity":[Te,he,ce]}],"backdrop-saturate":[{"backdrop-saturate":[Te,he,ce]}],"backdrop-sepia":[{"backdrop-sepia":["",Te,he,ce]}],"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",he,ce]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Te,"initial",he,ce]}],ease:[{ease:["linear","initial",x,he,ce]}],delay:[{delay:[Te,he,ce]}],animate:[{animate:["none",y,he,ce]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,he,ce]}],"perspective-origin":[{"perspective-origin":w()}],rotate:[{rotate:Q()}],"rotate-x":[{"rotate-x":Q()}],"rotate-y":[{"rotate-y":Q()}],"rotate-z":[{"rotate-z":Q()}],scale:[{scale:de()}],"scale-x":[{"scale-x":de()}],"scale-y":[{"scale-y":de()}],"scale-z":[{"scale-z":de()}],"scale-3d":["scale-3d"],skew:[{skew:re()}],"skew-x":[{"skew-x":re()}],"skew-y":[{"skew-y":re()}],transform:[{transform:[he,ce,"","none","gpu","cpu"]}],"transform-origin":[{origin:w()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:xe()}],"translate-x":[{"translate-x":xe()}],"translate-y":[{"translate-y":xe()}],"translate-z":[{"translate-z":xe()}],"translate-none":["translate-none"],zoom:[{zoom:[mt,he,ce]}],accent:[{accent:I()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:I()}],"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",he,ce]}],"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":I()}],"scrollbar-track-color":[{"scrollbar-track":I()}],"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",he,ce]}],fill:[{fill:["none",...I()]}],"stroke-w":[{stroke:[Te,or,Rt,Ca]}],stroke:[{stroke:["none",...I()]}],"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"]}},hc=Hd(cc),Ea=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,La=$s,br=(e,r)=>n=>{var a;if((r==null?void 0:r.variants)==null)return La(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=Ea(u)||Ea(m);return s[h][f]}),i=n&&Object.entries(n).reduce((h,u)=>{let[m,f]=u;return f===void 0||(h[m]=f),h},{}),d=r==null||(a=r.compoundVariants)===null||a===void 0?void 0:a.reduce((h,u)=>{let{class:m,className:f,...p}=u;return Object.entries(p).every(g=>{let[b,v]=g;return Array.isArray(v)?v.includes({...o,...i}[b]):{...o,...i}[b]===v})?[...h,m,f]:h},[]);return La(e,l,d,n==null?void 0:n.class,n==null?void 0:n.className)},Ur=c.createContext(null);Ur.displayName="PanelGroupContext";const We={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"},Xn=10,Bt=c.useLayoutEffect,Pa=ld.useId,uc=typeof Pa=="function"?Pa:()=>null;let mc=0;function Yn(e=null){const r=uc(),n=c.useRef(e||r||null);return n.current===null&&(n.current=""+mc++),e??n.current}function Js({children:e,className:r="",collapsedSize:n,collapsible:a,defaultSize:s,forwardedRef:o,id:l,maxSize:i,minSize:d,onCollapse:h,onExpand:u,onResize:m,order:f,style:p,tagName:g="div",...b}){const v=c.useContext(Ur);if(v===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:x,expandPanel:y,getPanelSize:k,getPanelStyle:C,groupId:w,isPanelCollapsed:j,reevaluatePanelConstraints:S,registerPanel:L,resizePanel:P,unregisterPanel:K}=v,F=Yn(l),R=c.useRef({callbacks:{onCollapse:h,onExpand:u,onResize:m},constraints:{collapsedSize:n,collapsible:a,defaultSize:s,maxSize:i,minSize:d},id:F,idIsFromProps:l!==void 0,order:f});c.useRef({didLogMissingDefaultSizeWarning:!1}),Bt(()=>{const{callbacks:Z,constraints:D}=R.current,te={...D};R.current.id=F,R.current.idIsFromProps=l!==void 0,R.current.order=f,Z.onCollapse=h,Z.onExpand=u,Z.onResize=m,D.collapsedSize=n,D.collapsible=a,D.defaultSize=s,D.maxSize=i,D.minSize=d,(te.collapsedSize!==D.collapsedSize||te.collapsible!==D.collapsible||te.maxSize!==D.maxSize||te.minSize!==D.minSize)&&S(R.current,te)}),Bt(()=>{const Z=R.current;return L(Z),()=>{K(Z)}},[f,F,L,K]),c.useImperativeHandle(o,()=>({collapse:()=>{x(R.current)},expand:Z=>{y(R.current,Z)},getId(){return F},getSize(){return k(R.current)},isCollapsed(){return j(R.current)},isExpanded(){return!j(R.current)},resize:Z=>{P(R.current,Z)}}),[x,y,k,j,F,P]);const J=C(R.current,s);return c.createElement(g,{...b,children:e,className:r,id:F,style:{...J,...p},[We.groupId]:w,[We.panel]:"",[We.panelCollapsible]:a||void 0,[We.panelId]:F,[We.panelSize]:parseFloat(""+J.flexGrow).toFixed(1)})}const Qs=c.forwardRef((e,r)=>c.createElement(Js,{...e,forwardedRef:r}));Js.displayName="Panel";Qs.displayName="forwardRef(Panel)";let Tn=null,Ir=-1,St=null;function pc(e,r,n){const a=(r&ao)!==0,s=(r&so)!==0,o=(r&oo)!==0,l=(r&lo)!==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 fc(){St!==null&&(document.head.removeChild(St),Tn=null,St=null,Ir=-1)}function dn(e,r,n){var a,s;const o=pc(e,r);if(Tn!==o){if(Tn=o,St===null&&(St=document.createElement("style"),document.head.appendChild(St)),Ir>=0){var l;(l=St.sheet)===null||l===void 0||l.removeRule(Ir)}Ir=(a=(s=St.sheet)===null||s===void 0?void 0:s.insertRule(`*{cursor: ${o} !important;}`))!==null&&a!==void 0?a:-1}}function eo(e){return e.type==="keydown"}function to(e){return e.type.startsWith("pointer")}function ro(e){return e.type.startsWith("mouse")}function Wr(e){if(to(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(ro(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function gc(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function xc(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 bc(e,r){if(e===r)throw new Error("Cannot compare node with itself");const n={a:Ra(e),b:Ra(r)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),r=n.b.pop(),a=e;Se(a,"Stacking order can only be calculated for elements with a common ancestor");const s={a:Ia(za(n.a)),b:Ia(za(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 vc=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function kc(e){var r;const n=getComputedStyle((r=no(e))!==null&&r!==void 0?r:e).display;return n==="flex"||n==="inline-flex"}function wc(e){const r=getComputedStyle(e);return!!(r.position==="fixed"||r.zIndex!=="auto"&&(r.position!=="static"||kc(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"||vc.test(r.willChange)||r.webkitOverflowScrolling==="touch")}function za(e){let r=e.length;for(;r--;){const n=e[r];if(Se(n,"Missing node"),wc(n))return n}return null}function Ia(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Ra(e){const r=[];for(;e;)r.push(e),e=no(e);return r}function no(e){const{parentNode:r}=e;return r&&r instanceof ShadowRoot?r.host:r}const ao=1,so=2,oo=4,lo=8,yc=gc()==="coarse";let ht=[],tr=!1,Tt=new Map,Vr=new Map;const fr=new Set;function jc(e,r,n,a,s){var o;const{ownerDocument:l}=r,i={direction:n,element:r,hitAreaMargins:a,setResizeHandlerState:s},d=(o=Tt.get(l))!==null&&o!==void 0?o:0;return Tt.set(l,d+1),fr.add(i),Dr(),function(){var u;Vr.delete(e),fr.delete(i);const m=(u=Tt.get(l))!==null&&u!==void 0?u:1;if(Tt.set(l,m-1),Dr(),m===1&&Tt.delete(l),ht.includes(i)){const f=ht.indexOf(i);f>=0&&ht.splice(f,1),Kr(),s("up",!0,null)}}}function Nc(e){const{target:r}=e,{x:n,y:a}=Wr(e);tr=!0,Zn({target:r,x:n,y:a}),Dr(),ht.length>0&&(Br("down",e),Kr(),e.preventDefault(),io(r)||e.stopImmediatePropagation())}function cn(e){const{x:r,y:n}=Wr(e);if(tr&&e.type!=="pointerleave"&&e.buttons===0&&(tr=!1,Br("up",e)),!tr){const{target:a}=e;Zn({target:a,x:r,y:n})}Br("move",e),Kr(),ht.length>0&&e.preventDefault()}function hn(e){const{target:r}=e,{x:n,y:a}=Wr(e);Vr.clear(),tr=!1,ht.length>0&&(e.preventDefault(),io(r)||e.stopImmediatePropagation()),Br("up",e),Zn({target:r,x:n,y:a}),Kr(),Dr()}function io(e){let r=e;for(;r;){if(r.hasAttribute(We.resizeHandle))return!0;r=r.parentElement}return!1}function Zn({target:e,x:r,y:n}){ht.splice(0);let a=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(a=e),fr.forEach(s=>{const{element:o,hitAreaMargins:l}=s,i=o.getBoundingClientRect(),{bottom:d,left:h,right:u,top:m}=i,f=yc?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)&&bc(a,o)>0){let g=a,b=!1;for(;g&&!g.contains(o);){if(xc(g.getBoundingClientRect(),i)){b=!0;break}g=g.parentElement}if(b)return}ht.push(s)}})}function un(e,r){Vr.set(e,r)}function Kr(){let e=!1,r=!1;ht.forEach(a=>{const{direction:s}=a;s==="horizontal"?e=!0:r=!0});let n=0;Vr.forEach(a=>{n|=a}),e&&r?dn("intersection",n):e?dn("horizontal",n):r?dn("vertical",n):fc()}let mn;function Dr(){var e;(e=mn)===null||e===void 0||e.abort(),mn=new AbortController;const r={capture:!0,signal:mn.signal};fr.size&&(tr?(ht.length>0&&Tt.forEach((n,a)=>{const{body:s}=a;n>0&&(s.addEventListener("contextmenu",hn,r),s.addEventListener("pointerleave",cn,r),s.addEventListener("pointermove",cn,r))}),Tt.forEach((n,a)=>{const{body:s}=a;s.addEventListener("pointerup",hn,r),s.addEventListener("pointercancel",hn,r)})):Tt.forEach((n,a)=>{const{body:s}=a;n>0&&(s.addEventListener("pointerdown",Nc,r),s.addEventListener("pointermove",cn,r))}))}function Br(e,r){fr.forEach(n=>{const{setResizeHandlerState:a}=n,s=ht.includes(n);a(e,s,r)})}function Cc(){const[e,r]=c.useState(0);return c.useCallback(()=>r(n=>n+1),[])}function Se(e,r){if(!e)throw console.error(r),Error(r)}function Ft(e,r,n=Xn){return e.toFixed(n)===r.toFixed(n)?0:e>r?1:-1}function vt(e,r,n=Xn){return Ft(e,r,n)===0}function it(e,r,n){return Ft(e,r,n)===0}function Sc(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(!it(s,o,n))return!1}return!0}function Qt({panelConstraints:e,panelIndex:r,size:n}){const a=e[r];Se(a!=null,`Panel constraints not found for index ${r}`);let{collapsedSize:s=0,collapsible:o,maxSize:l=100,minSize:i=0}=a;if(Ft(n,i)<0)if(o){const d=(s+i)/2;Ft(n,d)<0?n=s:n=i}else n=i;return n=Math.min(l,n),n=parseFloat(n.toFixed(Xn)),n}function cr({delta:e,initialLayout:r,panelConstraints:n,pivotIndices:a,prevLayout:s,trigger:o}){if(it(e,0))return r;const l=[...r],[i,d]=a;Se(i!=null,"Invalid first pivot index"),Se(d!=null,"Invalid second pivot index");let h=0;if(o==="keyboard"){{const m=e<0?d:i,f=n[m];Se(f,`Panel constraints not found for index ${m}`);const{collapsedSize:p=0,collapsible:g,minSize:b=0}=f;if(g){const v=r[m];if(Se(v!=null,`Previous layout not found for panel index ${m}`),it(v,p)){const x=b-v;Ft(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}{const m=e<0?i:d,f=n[m];Se(f,`No panel constraints found for index ${m}`);const{collapsedSize:p=0,collapsible:g,minSize:b=0}=f;if(g){const v=r[m];if(Se(v!=null,`Previous layout not found for panel index ${m}`),it(v,b)){const x=v-p;Ft(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];Se(b!=null,`Previous layout not found for panel index ${f}`);const x=Qt({panelConstraints:n,panelIndex:f,size:100})-b;if(p+=x,f+=m,f<0||f>=n.length)break}const g=Math.min(Math.abs(e),Math.abs(p));e=e<0?0-g:g}{let f=e<0?i:d;for(;f>=0&&f<n.length;){const p=Math.abs(e)-Math.abs(h),g=r[f];Se(g!=null,`Previous layout not found for panel index ${f}`);const b=g-p,v=Qt({panelConstraints:n,panelIndex:f,size:b});if(!it(g,v)&&(h+=g-v,l[f]=v,h.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?f--:f++}}if(Sc(s,l))return s;{const m=e<0?d:i,f=r[m];Se(f!=null,`Previous layout not found for panel index ${m}`);const p=f+h,g=Qt({panelConstraints:n,panelIndex:m,size:p});if(l[m]=g,!it(g,p)){let b=p-g,x=e<0?d:i;for(;x>=0&&x<n.length;){const y=l[x];Se(y!=null,`Previous layout not found for panel index ${x}`);const k=y+b,C=Qt({panelConstraints:n,panelIndex:x,size:k});if(it(y,C)||(b-=C-y,l[x]=C),it(b,0))break;e>0?x--:x++}}}const u=l.reduce((m,f)=>f+m,0);return it(u,100)?l:s}function Tc({layout:e,panelsArray:r,pivotIndices:n}){let a=0,s=100,o=0,l=0;const i=n[0];Se(i!=null,"No pivot index found"),r.forEach((m,f)=>{const{constraints:p}=m,{maxSize:g=100,minSize:b=0}=p;f===i?(a=b,s=g):(o+=b,l+=g)});const d=Math.min(s,100-o),h=Math.max(a,100-l),u=e[i];return{valueMax:d,valueMin:h,valueNow:u}}function gr(e,r=document){return Array.from(r.querySelectorAll(`[${We.resizeHandleId}][data-panel-group-id="${e}"]`))}function co(e,r,n=document){const s=gr(e,n).findIndex(o=>o.getAttribute(We.resizeHandleId)===r);return s??null}function ho(e,r,n){const a=co(e,r,n);return a!=null?[a,a+1]:[-1,-1]}function Ec(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function uo(e,r=document){if(Ec(r)&&r.dataset.panelGroupId==e)return r;const n=r.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function qr(e,r=document){const n=r.querySelector(`[${We.resizeHandleId}="${e}"]`);return n||null}function Lc(e,r,n,a=document){var s,o,l,i;const d=qr(r,a),h=gr(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 Pc({committedValuesRef:e,eagerValuesRef:r,groupId:n,layout:a,panelDataArray:s,panelGroupElement:o,setLayout:l}){c.useRef({didWarnAboutMissingResizeHandle:!1}),Bt(()=>{if(!o)return;const i=gr(n,o);for(let d=0;d<s.length-1;d++){const{valueMax:h,valueMin:u,valueNow:m}=Tc({layout:a,panelsArray:s,pivotIndices:[d,d+1]}),f=i[d];if(f!=null){const p=s[d];Se(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;Se(i,"Eager values not found");const{panelDataArray:d}=i,h=uo(n,o);Se(h!=null,`No group found for id "${n}"`);const u=gr(n,o);Se(u,`No resize handles found for group id "${n}"`);const m=u.map(f=>{const p=f.getAttribute(We.resizeHandleId);Se(p,"Resize handle element has no handle id attribute");const[g,b]=Lc(n,p,d,o);if(g==null||b==null)return()=>{};const v=x=>{if(!x.defaultPrevented)switch(x.key){case"Enter":{x.preventDefault();const y=d.findIndex(k=>k.id===g);if(y>=0){const k=d[y];Se(k,`No panel data found for index ${y}`);const C=a[y],{collapsedSize:w=0,collapsible:j,minSize:S=0}=k.constraints;if(C!=null&&j){const L=cr({delta:it(C,w)?S-w:w-C,initialLayout:a,panelConstraints:d.map(P=>P.constraints),pivotIndices:ho(n,p,o),prevLayout:a,trigger:"keyboard"});a!==L&&l(L)}}break}}};return f.addEventListener("keydown",v),()=>{f.removeEventListener("keydown",v)}});return()=>{m.forEach(f=>f())}},[o,e,r,n,a,s,l])}function Aa(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 mo(e,r){const n=e==="horizontal",{x:a,y:s}=Wr(r);return n?a:s}function zc(e,r,n,a,s){const o=n==="horizontal",l=qr(r,s);Se(l,`No resize handle element found for id "${r}"`);const i=l.getAttribute(We.groupId);Se(i,"Resize handle element has no group id attribute");let{initialCursorPosition:d}=a;const h=mo(n,e),u=uo(i,s);Se(u,`No group element found for id "${i}"`);const m=u.getBoundingClientRect(),f=o?m.width:m.height;return(h-d)/f*100}function Ic(e,r,n,a,s,o){if(eo(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:zc(e,r,n,a,o)}function Rc({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];Se(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];Se(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];Se(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||vt(m,h))&&!vt(a,h)&&p(),f&&(m==null||!vt(m,h))&&vt(a,h)&&f())}})}function Sr(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 Ac({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 _c(e,r=10){let n=null;return(...s)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...s)},r)}}function _a(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 po(e){return`react-resizable-panels:${e}`}function fo(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 go(e,r){try{const n=po(e),a=r.getItem(n);if(a){const s=JSON.parse(a);if(typeof s=="object"&&s!=null)return s}}catch{}return null}function Mc(e,r,n){var a,s;const o=(a=go(e,n))!==null&&a!==void 0?a:{},l=fo(r);return(s=o[l])!==null&&s!==void 0?s:null}function $c(e,r,n,a,s){var o;const l=po(e),i=fo(r),d=(o=go(e,s))!==null&&o!==void 0?o:{};d[i]={expandToSizes:Object.fromEntries(n.entries()),layout:a};try{s.setItem(l,JSON.stringify(d))}catch(h){console.error(h)}}function Ma({layout:e,panelConstraints:r}){const n=[...e],a=n.reduce((o,l)=>o+l,0);if(n.length!==r.length)throw Error(`Invalid ${r.length} panel layout: ${n.map(o=>`${o}%`).join(", ")}`);if(!it(a,100)&&n.length>0)for(let o=0;o<r.length;o++){const l=n[o];Se(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];Se(l!=null,`No layout data found for index ${o}`);const i=Qt({panelConstraints:r,panelIndex:o,size:l});l!=i&&(s+=l-i,n[o]=i)}if(!it(s,0))for(let o=0;o<r.length;o++){const l=n[o];Se(l!=null,`No layout data found for index ${o}`);const i=l+s,d=Qt({panelConstraints:r,panelIndex:o,size:i});if(l!==d&&(s-=d-l,n[o]=d,it(s,0)))break}return n}const Dc=100,hr={getItem:e=>(_a(hr),hr.getItem(e)),setItem:(e,r)=>{_a(hr),hr.setItem(e,r)}},$a={};function xo({autoSaveId:e=null,children:r,className:n="",direction:a,forwardedRef:s,id:o=null,onLayout:l=null,keyboardResizeBy:i=null,storage:d=hr,style:h,tagName:u="div",...m}){const f=Yn(o),p=c.useRef(null),[g,b]=c.useState(null),[v,x]=c.useState([]),y=Cc(),k=c.useRef({}),C=c.useRef(new Map),w=c.useRef(0),j=c.useRef({autoSaveId:e,direction:a,dragState:g,id:f,keyboardResizeBy:i,onLayout:l,storage:d}),S=c.useRef({layout:v,panelDataArray:[],panelDataArrayChanged:!1});c.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),c.useImperativeHandle(s,()=>({getId:()=>j.current.id,getLayout:()=>{const{layout:E}=S.current;return E},setLayout:E=>{const{onLayout:W}=j.current,{layout:O,panelDataArray:N}=S.current,T=Ma({layout:E,panelConstraints:N.map(U=>U.constraints)});Aa(O,T)||(x(T),S.current.layout=T,W&&W(T),qt(N,T,k.current))}}),[]),Bt(()=>{j.current.autoSaveId=e,j.current.direction=a,j.current.dragState=g,j.current.id=f,j.current.onLayout=l,j.current.storage=d}),Pc({committedValuesRef:j,eagerValuesRef:S,groupId:f,layout:v,panelDataArray:S.current.panelDataArray,setLayout:x,panelGroupElement:p.current}),c.useEffect(()=>{const{panelDataArray:E}=S.current;if(e){if(v.length===0||v.length!==E.length)return;let W=$a[e];W==null&&(W=_c($c,Dc),$a[e]=W);const O=[...E],N=new Map(C.current);W(e,O,N,v,d)}},[e,v,d]),c.useEffect(()=>{});const L=c.useCallback(E=>{const{onLayout:W}=j.current,{layout:O,panelDataArray:N}=S.current;if(E.constraints.collapsible){const T=N.map(Q=>Q.constraints),{collapsedSize:U=0,panelSize:X,pivotIndices:ie}=At(N,E,O);if(Se(X!=null,`Panel size not found for panel "${E.id}"`),!vt(X,U)){C.current.set(E.id,X);const de=Yt(N,E)===N.length-1?X-U:U-X,re=cr({delta:de,initialLayout:O,panelConstraints:T,pivotIndices:ie,prevLayout:O,trigger:"imperative-api"});Sr(O,re)||(x(re),S.current.layout=re,W&&W(re),qt(N,re,k.current))}}},[]),P=c.useCallback((E,W)=>{const{onLayout:O}=j.current,{layout:N,panelDataArray:T}=S.current;if(E.constraints.collapsible){const U=T.map(xe=>xe.constraints),{collapsedSize:X=0,panelSize:ie=0,minSize:Q=0,pivotIndices:de}=At(T,E,N),re=W??Q;if(vt(ie,X)){const xe=C.current.get(E.id),le=xe!=null&&xe>=re?xe:re,Pe=Yt(T,E)===T.length-1?ie-le:le-ie,se=cr({delta:Pe,initialLayout:N,panelConstraints:U,pivotIndices:de,prevLayout:N,trigger:"imperative-api"});Sr(N,se)||(x(se),S.current.layout=se,O&&O(se),qt(T,se,k.current))}}},[]),K=c.useCallback(E=>{const{layout:W,panelDataArray:O}=S.current,{panelSize:N}=At(O,E,W);return Se(N!=null,`Panel size not found for panel "${E.id}"`),N},[]),F=c.useCallback((E,W)=>{const{panelDataArray:O}=S.current,N=Yt(O,E);return Ac({defaultSize:W,dragState:g,layout:v,panelData:O,panelIndex:N})},[g,v]),R=c.useCallback(E=>{const{layout:W,panelDataArray:O}=S.current,{collapsedSize:N=0,collapsible:T,panelSize:U}=At(O,E,W);return Se(U!=null,`Panel size not found for panel "${E.id}"`),T===!0&&vt(U,N)},[]),J=c.useCallback(E=>{const{layout:W,panelDataArray:O}=S.current,{collapsedSize:N=0,collapsible:T,panelSize:U}=At(O,E,W);return Se(U!=null,`Panel size not found for panel "${E.id}"`),!T||Ft(U,N)>0},[]),Z=c.useCallback(E=>{const{panelDataArray:W}=S.current;W.push(E),W.sort((O,N)=>{const T=O.order,U=N.order;return T==null&&U==null?0:T==null?-1:U==null?1:T-U}),S.current.panelDataArrayChanged=!0,y()},[y]);Bt(()=>{if(S.current.panelDataArrayChanged){S.current.panelDataArrayChanged=!1;const{autoSaveId:E,onLayout:W,storage:O}=j.current,{layout:N,panelDataArray:T}=S.current;let U=null;if(E){const ie=Mc(E,T,O);ie&&(C.current=new Map(Object.entries(ie.expandToSizes)),U=ie.layout)}U==null&&(U=Rc({panelDataArray:T}));const X=Ma({layout:U,panelConstraints:T.map(ie=>ie.constraints)});Aa(N,X)||(x(X),S.current.layout=X,W&&W(X),qt(T,X,k.current))}}),Bt(()=>{const E=S.current;return()=>{E.layout=[]}},[]);const D=c.useCallback(E=>{let W=!1;const O=p.current;return O&&window.getComputedStyle(O,null).getPropertyValue("direction")==="rtl"&&(W=!0),function(T){T.preventDefault();const U=p.current;if(!U)return()=>null;const{direction:X,dragState:ie,id:Q,keyboardResizeBy:de,onLayout:re}=j.current,{layout:xe,panelDataArray:le}=S.current,{initialLayout:ve}=ie??{},Pe=ho(Q,E,U);let se=Ic(T,E,X,ie,de,U);const ye=X==="horizontal";ye&&W&&(se=-se);const je=le.map(ge=>ge.constraints),G=cr({delta:se,initialLayout:ve??xe,panelConstraints:je,pivotIndices:Pe,prevLayout:xe,trigger:eo(T)?"keyboard":"mouse-or-touch"}),me=!Sr(xe,G);(to(T)||ro(T))&&w.current!=se&&(w.current=se,!me&&se!==0?ye?un(E,se<0?ao:so):un(E,se<0?oo:lo):un(E,0)),me&&(x(G),S.current.layout=G,re&&re(G),qt(le,G,k.current))}},[]),te=c.useCallback((E,W)=>{const{onLayout:O}=j.current,{layout:N,panelDataArray:T}=S.current,U=T.map(xe=>xe.constraints),{panelSize:X,pivotIndices:ie}=At(T,E,N);Se(X!=null,`Panel size not found for panel "${E.id}"`);const de=Yt(T,E)===T.length-1?X-W:W-X,re=cr({delta:de,initialLayout:N,panelConstraints:U,pivotIndices:ie,prevLayout:N,trigger:"imperative-api"});Sr(N,re)||(x(re),S.current.layout=re,O&&O(re),qt(T,re,k.current))},[]),oe=c.useCallback((E,W)=>{const{layout:O,panelDataArray:N}=S.current,{collapsedSize:T=0,collapsible:U}=W,{collapsedSize:X=0,collapsible:ie,maxSize:Q=100,minSize:de=0}=E.constraints,{panelSize:re}=At(N,E,O);re!=null&&(U&&ie&&vt(re,T)?vt(T,X)||te(E,X):re<de?te(E,de):re>Q&&te(E,Q))},[te]),_=c.useCallback((E,W)=>{const{direction:O}=j.current,{layout:N}=S.current;if(!p.current)return;const T=qr(E,p.current);Se(T,`Drag handle element not found for id "${E}"`);const U=mo(O,W);b({dragHandleId:E,dragHandleRect:T.getBoundingClientRect(),initialCursorPosition:U,initialLayout:N})},[]),Y=c.useCallback(()=>{b(null)},[]),I=c.useCallback(E=>{const{panelDataArray:W}=S.current,O=Yt(W,E);O>=0&&(W.splice(O,1),delete k.current[E.id],S.current.panelDataArrayChanged=!0,y())},[y]),q=c.useMemo(()=>({collapsePanel:L,direction:a,dragState:g,expandPanel:P,getPanelSize:K,getPanelStyle:F,groupId:f,isPanelCollapsed:R,isPanelExpanded:J,reevaluatePanelConstraints:oe,registerPanel:Z,registerResizeHandle:D,resizePanel:te,startDragging:_,stopDragging:Y,unregisterPanel:I,panelGroupElement:p.current}),[L,g,a,P,K,F,f,R,J,oe,Z,D,te,_,Y,I]),H={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return c.createElement(Ur.Provider,{value:q},c.createElement(u,{...m,children:r,className:n,id:o,ref:p,style:{...H,...h},[We.group]:"",[We.groupDirection]:a,[We.groupId]:f}))}const bo=c.forwardRef((e,r)=>c.createElement(xo,{...e,forwardedRef:r}));xo.displayName="PanelGroup";bo.displayName="forwardRef(PanelGroup)";function Yt(e,r){return e.findIndex(n=>n===r||n.id===r.id)}function At(e,r,n){const a=Yt(e,r),o=a===e.length-1?[a-1,a]:[a,a+1],l=n[a];return{...r.constraints,panelSize:l,pivotIndices:o}}function Bc({disabled:e,handleId:r,resizeHandler:n,panelGroupElement:a}){c.useEffect(()=>{if(e||n==null||a==null)return;const s=qr(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(We.groupId);Se(i,`No group element found for id "${i}"`);const d=gr(i,a),h=co(i,r,a);Se(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 vo({children:e=null,className:r="",disabled:n=!1,hitAreaMargins:a,id:s,onBlur:o,onClick:l,onDragging:i,onFocus:d,onPointerDown:h,onPointerUp:u,style:m={},tabIndex:f=0,tagName:p="div",...g}){var b,v;const x=c.useRef(null),y=c.useRef({onClick:l,onDragging:i,onPointerDown:h,onPointerUp:u});c.useEffect(()=>{y.current.onClick=l,y.current.onDragging=i,y.current.onPointerDown=h,y.current.onPointerUp=u});const k=c.useContext(Ur);if(k===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:C,groupId:w,registerResizeHandle:j,startDragging:S,stopDragging:L,panelGroupElement:P}=k,K=Yn(s),[F,R]=c.useState("inactive"),[J,Z]=c.useState(!1),[D,te]=c.useState(null),oe=c.useRef({state:F});Bt(()=>{oe.current.state=F}),c.useEffect(()=>{if(n)te(null);else{const q=j(K);te(()=>q)}},[n,K,j]);const _=(b=a==null?void 0:a.coarse)!==null&&b!==void 0?b:15,Y=(v=a==null?void 0:a.fine)!==null&&v!==void 0?v:5;c.useEffect(()=>{if(n||D==null)return;const q=x.current;Se(q,"Element ref not attached");let H=!1;return jc(K,q,C,{coarse:_,fine:Y},(W,O,N)=>{if(!O){R("inactive");return}switch(W){case"down":{R("drag"),H=!1,Se(N,'Expected event to be defined for "down" action'),S(K,N);const{onDragging:T,onPointerDown:U}=y.current;T==null||T(!0),U==null||U();break}case"move":{const{state:T}=oe.current;H=!0,T!=="drag"&&R("hover"),Se(N,'Expected event to be defined for "move" action'),D(N);break}case"up":{R("hover"),L();const{onClick:T,onDragging:U,onPointerUp:X}=y.current;U==null||U(!1),X==null||X(),H||T==null||T();break}}})},[_,C,n,Y,j,K,D,S,L]),Bc({disabled:n,handleId:K,resizeHandler:D,panelGroupElement:P});const I={touchAction:"none",userSelect:"none"};return c.createElement(p,{...g,children:e,className:r,id:s,onBlur:()=>{Z(!1),o==null||o()},onFocus:()=>{Z(!0),d==null||d()},ref:x,role:"separator",style:{...I,...m},tabIndex:f,[We.groupDirection]:C,[We.groupId]:w,[We.resizeHandle]:"",[We.resizeHandleActive]:F==="drag"?"pointer":J?"keyboard":void 0,[We.resizeHandleEnabled]:!n,[We.resizeHandleId]:K,[We.resizeHandleState]:F})}vo.displayName="PanelResizeHandle";var Gc=Object.defineProperty,Fc=Object.getOwnPropertyNames,$e=(e,r)=>function(){return e&&(r=(0,e[Fc(e)[0]])(e=0)),r},Hc=(e,r)=>{for(var n in r)Gc(e,n,{get:r[n],enumerable:!0})};function nt(...e){return hc($s(e))}var Pt=$e({"src/components/graph-ui/utils.ts"(){}});function xr({asChild:e=!1,className:r,size:n,variant:a,...s}){const o=e?Rs:"button";return t.jsx(o,{"data-slot":"button",className:nt(ko({variant:a,size:n,className:r})),...s})}var ko,Xr=$e({"src/components/graph-ui/Button.tsx"(){Pt(),ko=br("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 wo(...e){return e.filter(Boolean).join(" ")}function En({className:e,...r}){return t.jsx(bo,{"data-slot":"resizable-panel-group",className:wo("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...r})}function er({...e}){return t.jsx(Qs,{"data-slot":"resizable-panel",...e})}function Ln({withHandle:e,className:r,...n}){return t.jsx(vo,{"data-slot":"resizable-handle",className:wo("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(B.GripVerticalIcon,{className:"size-2.5"})}):null})}var yo=$e({"src/components/graph-workspace/GraphResizablePanels.tsx"(){}});function Jn(...e){return e.filter(Boolean).join(" ")}function vr({...e}){return t.jsx($i,{"data-slot":"accordion",...e})}function kr({className:e,...r}){return t.jsx(Di,{"data-slot":"accordion-item",className:Jn("border-b last:border-b-0",e),...r})}function Yr({className:e,children:r,...n}){return t.jsx(Gi,{className:"flex",children:t.jsxs(Fi,{"data-slot":"accordion-trigger",className:Jn("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(B.ChevronDownIcon,{className:"pointer-events-none size-4 shrink-0 translate-y-0.5 text-[var(--theme-fg-muted)] transition-transform duration-200"})]})})}function wr({className:e,children:r,...n}){return t.jsx(Bi,{"data-slot":"accordion-content",className:"overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:t.jsx("div",{className:Jn("pb-4 pt-0",e),children:r})})}var yr=$e({"src/components/graph-workspace/GraphAccordion.tsx"(){}});function Oc(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 Uc(e){return e.trim().replace(/^\/+|\/+$/g,"").replace(/[^\w.-]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function jr(e){var r;return((r=e.split(".").pop())==null?void 0:r.toLowerCase())||""}function Wc(e){return e.split("/").filter(Boolean).at(-1)??e}function Zt(e){const r=e.kind==="directory"?"directory":"file",n=(e.children??[]).map(Zt);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 jo(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=jo(l,r,n,a);return i!==l&&(s=!0),i});return s?{...e,children:o}:e}function No(e){if(e.kind==="file")return e;for(const r of e.children){const n=No(r);if(n)return n}return null}function Pn(e,r){if(!e||r===null)return null;if(e.path===r)return e;for(const n of e.children){const a=Pn(n,r);if(a)return a}return null}function Co(e){return e.trim().replace(/\\/g,"/").replace(/^\.\/+/,"").replace(/^\/+/,"")}function Vc(e){const n=Co(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 zn(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=zn(o,r,n);return l!==o&&(a=!0),l});return a?{...e,children:s}:e}function In(e,r){return!e||!r?!1:e.path===r?!0:e.children.some(n=>In(n,r))}function Kc(e){if(!e)return null;const r=jr(e.path);return Qn.has(r)?{content:[e.content.endsWith(`
2
+ import{l as B,R as $i,I as Di,C as Bi,S as Rs,H as Gi,T as Fi,a as Hi,b as Oi,c as Ui,d as Wi,e as Vi,D as Ki,P as qi,O as Xi,f as Yi,g as Zi,h as Ji,i as Qi,j as ed,k as td,m as rd,n as nd,A as ad,o as sd,p as od}from"./ui-vendor-CeKGesq3.js";import{r as c,R as ld,j as t,b as Or}from"./react-vendor-CgLzZcV4.js";import{u as id,a as dd,H as va,P as Mt,b as cd,M as As,R as hd,i as ud,C as md,B as pd,c as ka,g as _s}from"./graph-vendor-DVPtkh3h.js";import"./terminal-vendor-B365Go3Z.js";import{M as fd,r as gd,a as xd,b as bd}from"./markdown-vendor-BQJfKm05.js";const vd="modulepreload",kd=function(e){return"/"+e},wa={},Ke=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=kd(h),h in wa)return;wa[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":vd,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 Ms(e){var r,n,a="";if(typeof e=="string"||typeof e=="number")a+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(r=0;r<o;r++)e[r]&&(n=Ms(e[r]))&&(a&&(a+=" "),a+=n)}else for(n in e)e[n]&&(a&&(a+=" "),a+=n);return a}function $s(){for(var e,r,n=0,a="",o=arguments.length;n<o;n++)(e=arguments[n])&&(r=Ms(e))&&(a&&(a+=" "),a+=r);return a}const wd=(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},yd=(e,r)=>({classGroupId:e,validator:r}),Ds=(e=new Map,r=null,n)=>({nextPart:e,validators:r,classGroupId:n}),Dr="-",ya=[],jd="arbitrary..",Nd=e=>{const r=Sd(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:a}=e;return{getClassGroupId:l=>{if(l.startsWith("[")&&l.endsWith("]"))return Cd(l);const i=l.split(Dr),d=i[0]===""&&i.length>1?1:0;return Bs(i,d,r)},getConflictingClassGroupIds:(l,i)=>{if(i){const d=a[l],h=n[l];return d?h?wd(h,d):d:h||ya}return n[l]||ya}}},Bs=(e,r,n)=>{if(e.length-r===0)return n.classGroupId;const o=e[r],s=n.nextPart.get(o);if(s){const h=Bs(e,r+1,s);if(h)return h}const l=n.validators;if(l===null)return;const i=r===0?e.join(Dr):e.slice(r).join(Dr),d=l.length;for(let h=0;h<d;h++){const u=l[h];if(u.validator(i))return u.classGroupId}},Cd=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?jd+a:void 0})(),Sd=e=>{const{theme:r,classGroups:n}=e;return Td(n,r)},Td=(e,r)=>{const n=Ds();for(const a in e){const o=e[a];Vn(o,n,a,r)}return n},Vn=(e,r,n,a)=>{const o=e.length;for(let s=0;s<o;s++){const l=e[s];Ed(l,r,n,a)}},Ed=(e,r,n,a)=>{if(typeof e=="string"){Ld(e,r,n);return}if(typeof e=="function"){Pd(e,r,n,a);return}zd(e,r,n,a)},Ld=(e,r,n)=>{const a=e===""?r:Gs(r,e);a.classGroupId=n},Pd=(e,r,n,a)=>{if(Id(e)){Vn(e(a),r,n,a);return}r.validators===null&&(r.validators=[]),r.validators.push(yd(n,e))},zd=(e,r,n,a)=>{const o=Object.entries(e),s=o.length;for(let l=0;l<s;l++){const[i,d]=o[l];Vn(d,Gs(r,i),n,a)}},Gs=(e,r)=>{let n=e;const a=r.split(Dr),o=a.length;for(let s=0;s<o;s++){const l=a[s];let i=n.nextPart.get(l);i||(i=Ds(),n.nextPart.set(l,i)),n=i}return n},Id=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Rd=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)}}},Cn="!",ja=":",Ad=[],Na=(e,r,n,a,o)=>({modifiers:e,hasImportantModifier:r,baseClassName:n,maybePostfixModifierPosition:a,isExternal:o}),_d=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===ja){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(Cn)?(f=m.slice(0,-1),p=!0):m.startsWith(Cn)&&(f=m.slice(1),p=!0);const g=h&&h>d?h-d:void 0;return Na(s,p,f,g)};if(r){const o=r+ja,s=a;a=l=>l.startsWith(o)?s(l.slice(o.length)):Na(Ad,!1,l,void 0,!0)}if(n){const o=a;a=s=>n({className:s,parseClassName:o})}return a},Md=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}},$d=e=>({cache:Rd(e.cacheSize),parseClassName:_d(e),sortModifiers:Md(e),postfixLookupClassGroupIds:Dd(e),...Nd(e)}),Dd=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},Bd=/\s+/,Gd=(e,r)=>{const{parseClassName:n,getClassGroupId:a,getConflictingClassGroupIds:o,sortModifiers:s,postfixLookupClassGroupIds:l}=r,i=[],d=e.trim().split(Bd);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,y;if(x){const S=b.substring(0,w);y=a(S);const L=y&&l[y]?a(b):void 0;L&&L!==y&&(y=L,x=!1)}else y=a(b);if(!y){if(!x){h=m+(h.length>0?" "+h:h);continue}if(y=a(b),!y){h=m+(h.length>0?" "+h:h);continue}x=!1}const k=p.length===0?"":p.length===1?p[0]:s(p).join(":"),j=g?k+Cn:k,v=j+y;if(i.indexOf(v)>-1)continue;i.push(v);const N=o(y,x);for(let S=0;S<N.length;++S){const L=N[S];i.push(j+L)}h=m+(h.length>0?" "+h:h)}return h},Fd=(...e)=>{let r=0,n,a,o="";for(;r<e.length;)(n=e[r++])&&(a=Fs(n))&&(o&&(o+=" "),o+=a);return o},Fs=e=>{if(typeof e=="string")return e;let r,n="";for(let a=0;a<e.length;a++)e[a]&&(r=Fs(e[a]))&&(n&&(n+=" "),n+=r);return n},Hd=(e,...r)=>{let n,a,o,s;const l=d=>{const h=r.reduce((u,m)=>m(u),e());return n=$d(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=Gd(d,n);return o(d,u),u};return s=l,(...d)=>s(Fd(...d))},Od=[],Je=e=>{const r=n=>n[e]||Od;return r.isThemeGetter=!0,r},Hs=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Os=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Ud=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Wd=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Vd=/\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$/,Kd=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,qd=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Xd=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Nt=e=>Ud.test(e),Te=e=>!!e&&!Number.isNaN(Number(e)),mt=e=>!!e&&Number.isInteger(Number(e)),on=e=>e.endsWith("%")&&Te(e.slice(0,-1)),bt=e=>Wd.test(e),Us=()=>!0,Yd=e=>Vd.test(e)&&!Kd.test(e),Kn=()=>!1,Zd=e=>qd.test(e),Jd=e=>Xd.test(e),Qd=e=>!ce(e)&&!he(e),ec=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)),tc=e=>Lt(e,Ks,Kn),ce=e=>Hs.test(e),Rt=e=>Lt(e,qs,Yd),Ca=e=>Lt(e,dc,Te),rc=e=>Lt(e,Ys,Us),nc=e=>Lt(e,Xs,Kn),Sa=e=>Lt(e,Ws,Kn),ac=e=>Lt(e,Vs,Jd),Cr=e=>Lt(e,Zs,Zd),he=e=>Os.test(e),or=e=>Ht(e,qs),sc=e=>Ht(e,Xs),Ta=e=>Ht(e,Ws),oc=e=>Ht(e,Ks),lc=e=>Ht(e,Vs),Sr=e=>Ht(e,Zs,!0),ic=e=>Ht(e,Ys,!0),Lt=(e,r,n)=>{const a=Hs.exec(e);return a?a[1]?r(a[1]):n(a[2]):!1},Ht=(e,r,n=!1)=>{const a=Os.exec(e);return a?a[1]?r(a[1]):n:!1},Ws=e=>e==="position"||e==="percentage",Vs=e=>e==="image"||e==="url",Ks=e=>e==="length"||e==="size"||e==="bg-size",qs=e=>e==="length",dc=e=>e==="number",Xs=e=>e==="family-name",Ys=e=>e==="number"||e==="weight",Zs=e=>e==="shadow",cc=()=>{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"),y=Je("animate"),k=()=>["auto","avoid","all","avoid-page","page","left","right","column"],j=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],v=()=>[...j(),he,ce],N=()=>["auto","hidden","clip","visible","scroll"],S=()=>["auto","contain","none"],L=()=>[he,ce,d],P=()=>[Nt,"full","auto",...L()],K=()=>[mt,"none","subgrid",he,ce],F=()=>["auto",{span:["full",mt,he,ce]},mt,he,ce],D=()=>[mt,"auto",he,ce],Z=()=>["auto","min","max","fr",he,ce],Y=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],$=()=>["start","end","center","stretch","center-safe","end-safe"],te=()=>["auto",...L()],oe=()=>[Nt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...L()],A=()=>[Nt,"screen","full","dvw","lvw","svw","min","max","fit",...L()],J=()=>[Nt,"screen","full","lh","dvh","lvh","svh","min","max","fit",...L()],I=()=>[e,he,ce],q=()=>[...j(),Ta,Sa,{position:[he,ce]}],O=()=>["no-repeat",{repeat:["","x","y","space","round"]}],T=()=>["auto","cover","contain",oc,tc,{size:[he,ce]}],U=()=>[on,or,Rt],H=()=>["","none","full",h,he,ce],C=()=>["",Te,or,Rt],E=()=>["solid","dashed","dotted","double"],X=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],W=()=>[Te,on,Ta,Sa],le=()=>["","none",g,he,ce],Q=()=>["none",Te,he,ce],de=()=>["none",Te,he,ce],re=()=>[Te,he,ce],xe=()=>[Nt,"full",...L()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[bt],breakpoint:[bt],color:[Us],container:[bt],"drop-shadow":[bt],ease:["in","out","in-out"],font:[Qd],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[bt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[bt],shadow:[bt],spacing:["px",Te],text:[bt],"text-shadow":[bt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Nt,ce,he,w]}],container:["container"],"container-type":[{"@container":["","normal","size",he,ce]}],"container-named":[ec],columns:[{columns:[Te,ce,he,i]}],"break-after":[{"break-after":k()}],"break-before":[{"break-before":k()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:v()}],overflow:[{overflow:N()}],"overflow-x":[{"overflow-x":N()}],"overflow-y":[{"overflow-y":N()}],overscroll:[{overscroll:S()}],"overscroll-x":[{"overscroll-x":S()}],"overscroll-y":[{"overscroll-y":S()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:P()}],"inset-x":[{"inset-x":P()}],"inset-y":[{"inset-y":P()}],start:[{"inset-s":P(),start:P()}],end:[{"inset-e":P(),end:P()}],"inset-bs":[{"inset-bs":P()}],"inset-be":[{"inset-be":P()}],top:[{top:P()}],right:[{right:P()}],bottom:[{bottom:P()}],left:[{left:P()}],visibility:["visible","invisible","collapse"],z:[{z:[mt,"auto",he,ce]}],basis:[{basis:[Nt,"full","auto",i,...L()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Te,Nt,"auto","initial","none",ce]}],grow:[{grow:["",Te,he,ce]}],shrink:[{shrink:["",Te,he,ce]}],order:[{order:[mt,"first","last","none",he,ce]}],"grid-cols":[{"grid-cols":K()}],"col-start-end":[{col:F()}],"col-start":[{"col-start":D()}],"col-end":[{"col-end":D()}],"grid-rows":[{"grid-rows":K()}],"row-start-end":[{row:F()}],"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:[...Y(),"normal"]}],"justify-items":[{"justify-items":[...$(),"normal"]}],"justify-self":[{"justify-self":["auto",...$()]}],"align-content":[{content:["normal",...Y()]}],"align-items":[{items:[...$(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...$(),{baseline:["","last"]}]}],"place-content":[{"place-content":Y()}],"place-items":[{"place-items":[...$(),"baseline"]}],"place-self":[{"place-self":["auto",...$()]}],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:oe()}],"inline-size":[{inline:["auto",...A()]}],"min-inline-size":[{"min-inline":["auto",...A()]}],"max-inline-size":[{"max-inline":["none",...A()]}],"block-size":[{block:["auto",...J()]}],"min-block-size":[{"min-block":["auto",...J()]}],"max-block-size":[{"max-block":["none",...J()]}],w:[{w:[i,"screen",...oe()]}],"min-w":[{"min-w":[i,"screen","none",...oe()]}],"max-w":[{"max-w":[i,"screen","none","prose",{screen:[l]},...oe()]}],h:[{h:["screen","lh",...oe()]}],"min-h":[{"min-h":["screen","lh","none",...oe()]}],"max-h":[{"max-h":["screen","lh",...oe()]}],"font-size":[{text:["base",n,or,Rt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,ic,rc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",on,ce]}],"font-family":[{font:[sc,nc,r]}],"font-features":[{"font-features":[ce]}],"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,he,ce]}],"line-clamp":[{"line-clamp":[Te,"none",he,Ca]}],leading:[{leading:[s,...L()]}],"list-image":[{"list-image":["none",he,ce]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",he,ce]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:I()}],"text-color":[{text:I()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...E(),"wavy"]}],"text-decoration-thickness":[{decoration:[Te,"from-font","auto",he,Rt]}],"text-decoration-color":[{decoration:I()}],"underline-offset":[{"underline-offset":[Te,"auto",he,ce]}],"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:[mt,he,ce]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",he,ce]}],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",he,ce]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:q()}],"bg-repeat":[{bg:O()}],"bg-size":[{bg:T()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},mt,he,ce],radial:["",he,ce],conic:[mt,he,ce]},lc,ac]}],"bg-color":[{bg:I()}],"gradient-from-pos":[{from:U()}],"gradient-via-pos":[{via:U()}],"gradient-to-pos":[{to:U()}],"gradient-from":[{from:I()}],"gradient-via":[{via:I()}],"gradient-to":[{to:I()}],rounded:[{rounded:H()}],"rounded-s":[{"rounded-s":H()}],"rounded-e":[{"rounded-e":H()}],"rounded-t":[{"rounded-t":H()}],"rounded-r":[{"rounded-r":H()}],"rounded-b":[{"rounded-b":H()}],"rounded-l":[{"rounded-l":H()}],"rounded-ss":[{"rounded-ss":H()}],"rounded-se":[{"rounded-se":H()}],"rounded-ee":[{"rounded-ee":H()}],"rounded-es":[{"rounded-es":H()}],"rounded-tl":[{"rounded-tl":H()}],"rounded-tr":[{"rounded-tr":H()}],"rounded-br":[{"rounded-br":H()}],"rounded-bl":[{"rounded-bl":H()}],"border-w":[{border:C()}],"border-w-x":[{"border-x":C()}],"border-w-y":[{"border-y":C()}],"border-w-s":[{"border-s":C()}],"border-w-e":[{"border-e":C()}],"border-w-bs":[{"border-bs":C()}],"border-w-be":[{"border-be":C()}],"border-w-t":[{"border-t":C()}],"border-w-r":[{"border-r":C()}],"border-w-b":[{"border-b":C()}],"border-w-l":[{"border-l":C()}],"divide-x":[{"divide-x":C()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":C()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...E(),"hidden","none"]}],"divide-style":[{divide:[...E(),"hidden","none"]}],"border-color":[{border:I()}],"border-color-x":[{"border-x":I()}],"border-color-y":[{"border-y":I()}],"border-color-s":[{"border-s":I()}],"border-color-e":[{"border-e":I()}],"border-color-bs":[{"border-bs":I()}],"border-color-be":[{"border-be":I()}],"border-color-t":[{"border-t":I()}],"border-color-r":[{"border-r":I()}],"border-color-b":[{"border-b":I()}],"border-color-l":[{"border-l":I()}],"divide-color":[{divide:I()}],"outline-style":[{outline:[...E(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Te,he,ce]}],"outline-w":[{outline:["",Te,or,Rt]}],"outline-color":[{outline:I()}],shadow:[{shadow:["","none",u,Sr,Cr]}],"shadow-color":[{shadow:I()}],"inset-shadow":[{"inset-shadow":["none",m,Sr,Cr]}],"inset-shadow-color":[{"inset-shadow":I()}],"ring-w":[{ring:C()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:I()}],"ring-offset-w":[{"ring-offset":[Te,Rt]}],"ring-offset-color":[{"ring-offset":I()}],"inset-ring-w":[{"inset-ring":C()}],"inset-ring-color":[{"inset-ring":I()}],"text-shadow":[{"text-shadow":["none",f,Sr,Cr]}],"text-shadow-color":[{"text-shadow":I()}],opacity:[{opacity:[Te,he,ce]}],"mix-blend":[{"mix-blend":[...X(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":X()}],"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":[Te]}],"mask-image-linear-from-pos":[{"mask-linear-from":W()}],"mask-image-linear-to-pos":[{"mask-linear-to":W()}],"mask-image-linear-from-color":[{"mask-linear-from":I()}],"mask-image-linear-to-color":[{"mask-linear-to":I()}],"mask-image-t-from-pos":[{"mask-t-from":W()}],"mask-image-t-to-pos":[{"mask-t-to":W()}],"mask-image-t-from-color":[{"mask-t-from":I()}],"mask-image-t-to-color":[{"mask-t-to":I()}],"mask-image-r-from-pos":[{"mask-r-from":W()}],"mask-image-r-to-pos":[{"mask-r-to":W()}],"mask-image-r-from-color":[{"mask-r-from":I()}],"mask-image-r-to-color":[{"mask-r-to":I()}],"mask-image-b-from-pos":[{"mask-b-from":W()}],"mask-image-b-to-pos":[{"mask-b-to":W()}],"mask-image-b-from-color":[{"mask-b-from":I()}],"mask-image-b-to-color":[{"mask-b-to":I()}],"mask-image-l-from-pos":[{"mask-l-from":W()}],"mask-image-l-to-pos":[{"mask-l-to":W()}],"mask-image-l-from-color":[{"mask-l-from":I()}],"mask-image-l-to-color":[{"mask-l-to":I()}],"mask-image-x-from-pos":[{"mask-x-from":W()}],"mask-image-x-to-pos":[{"mask-x-to":W()}],"mask-image-x-from-color":[{"mask-x-from":I()}],"mask-image-x-to-color":[{"mask-x-to":I()}],"mask-image-y-from-pos":[{"mask-y-from":W()}],"mask-image-y-to-pos":[{"mask-y-to":W()}],"mask-image-y-from-color":[{"mask-y-from":I()}],"mask-image-y-to-color":[{"mask-y-to":I()}],"mask-image-radial":[{"mask-radial":[he,ce]}],"mask-image-radial-from-pos":[{"mask-radial-from":W()}],"mask-image-radial-to-pos":[{"mask-radial-to":W()}],"mask-image-radial-from-color":[{"mask-radial-from":I()}],"mask-image-radial-to-color":[{"mask-radial-to":I()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":j()}],"mask-image-conic-pos":[{"mask-conic":[Te]}],"mask-image-conic-from-pos":[{"mask-conic-from":W()}],"mask-image-conic-to-pos":[{"mask-conic-to":W()}],"mask-image-conic-from-color":[{"mask-conic-from":I()}],"mask-image-conic-to-color":[{"mask-conic-to":I()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:q()}],"mask-repeat":[{mask:O()}],"mask-size":[{mask:T()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",he,ce]}],filter:[{filter:["","none",he,ce]}],blur:[{blur:le()}],brightness:[{brightness:[Te,he,ce]}],contrast:[{contrast:[Te,he,ce]}],"drop-shadow":[{"drop-shadow":["","none",p,Sr,Cr]}],"drop-shadow-color":[{"drop-shadow":I()}],grayscale:[{grayscale:["",Te,he,ce]}],"hue-rotate":[{"hue-rotate":[Te,he,ce]}],invert:[{invert:["",Te,he,ce]}],saturate:[{saturate:[Te,he,ce]}],sepia:[{sepia:["",Te,he,ce]}],"backdrop-filter":[{"backdrop-filter":["","none",he,ce]}],"backdrop-blur":[{"backdrop-blur":le()}],"backdrop-brightness":[{"backdrop-brightness":[Te,he,ce]}],"backdrop-contrast":[{"backdrop-contrast":[Te,he,ce]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Te,he,ce]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Te,he,ce]}],"backdrop-invert":[{"backdrop-invert":["",Te,he,ce]}],"backdrop-opacity":[{"backdrop-opacity":[Te,he,ce]}],"backdrop-saturate":[{"backdrop-saturate":[Te,he,ce]}],"backdrop-sepia":[{"backdrop-sepia":["",Te,he,ce]}],"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",he,ce]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Te,"initial",he,ce]}],ease:[{ease:["linear","initial",x,he,ce]}],delay:[{delay:[Te,he,ce]}],animate:[{animate:["none",y,he,ce]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,he,ce]}],"perspective-origin":[{"perspective-origin":v()}],rotate:[{rotate:Q()}],"rotate-x":[{"rotate-x":Q()}],"rotate-y":[{"rotate-y":Q()}],"rotate-z":[{"rotate-z":Q()}],scale:[{scale:de()}],"scale-x":[{"scale-x":de()}],"scale-y":[{"scale-y":de()}],"scale-z":[{"scale-z":de()}],"scale-3d":["scale-3d"],skew:[{skew:re()}],"skew-x":[{"skew-x":re()}],"skew-y":[{"skew-y":re()}],transform:[{transform:[he,ce,"","none","gpu","cpu"]}],"transform-origin":[{origin:v()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:xe()}],"translate-x":[{"translate-x":xe()}],"translate-y":[{"translate-y":xe()}],"translate-z":[{"translate-z":xe()}],"translate-none":["translate-none"],zoom:[{zoom:[mt,he,ce]}],accent:[{accent:I()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:I()}],"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",he,ce]}],"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":I()}],"scrollbar-track-color":[{"scrollbar-track":I()}],"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",he,ce]}],fill:[{fill:["none",...I()]}],"stroke-w":[{stroke:[Te,or,Rt,Ca]}],stroke:[{stroke:["none",...I()]}],"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"]}},hc=Hd(cc),Ea=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,La=$s,vr=(e,r)=>n=>{var a;if((r==null?void 0:r.variants)==null)return La(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=Ea(u)||Ea(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 La(e,l,d,n==null?void 0:n.class,n==null?void 0:n.className)},Ur=c.createContext(null);Ur.displayName="PanelGroupContext";const We={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},qn=10,Bt=c.useLayoutEffect,Pa=ld.useId,uc=typeof Pa=="function"?Pa:()=>null;let mc=0;function Xn(e=null){const r=uc(),n=c.useRef(e||r||null);return n.current===null&&(n.current=""+mc++),e??n.current}function Js({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(Ur);if(w===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:x,expandPanel:y,getPanelSize:k,getPanelStyle:j,groupId:v,isPanelCollapsed:N,reevaluatePanelConstraints:S,registerPanel:L,resizePanel:P,unregisterPanel:K}=w,F=Xn(l),D=c.useRef({callbacks:{onCollapse:h,onExpand:u,onResize:m},constraints:{collapsedSize:n,collapsible:a,defaultSize:o,maxSize:i,minSize:d},id:F,idIsFromProps:l!==void 0,order:f});c.useRef({didLogMissingDefaultSizeWarning:!1}),Bt(()=>{const{callbacks:Y,constraints:$}=D.current,te={...$};D.current.id=F,D.current.idIsFromProps=l!==void 0,D.current.order=f,Y.onCollapse=h,Y.onExpand=u,Y.onResize=m,$.collapsedSize=n,$.collapsible=a,$.defaultSize=o,$.maxSize=i,$.minSize=d,(te.collapsedSize!==$.collapsedSize||te.collapsible!==$.collapsible||te.maxSize!==$.maxSize||te.minSize!==$.minSize)&&S(D.current,te)}),Bt(()=>{const Y=D.current;return L(Y),()=>{K(Y)}},[f,F,L,K]),c.useImperativeHandle(s,()=>({collapse:()=>{x(D.current)},expand:Y=>{y(D.current,Y)},getId(){return F},getSize(){return k(D.current)},isCollapsed(){return N(D.current)},isExpanded(){return!N(D.current)},resize:Y=>{P(D.current,Y)}}),[x,y,k,N,F,P]);const Z=j(D.current,o);return c.createElement(g,{...b,children:e,className:r,id:F,style:{...Z,...p},[We.groupId]:v,[We.panel]:"",[We.panelCollapsible]:a||void 0,[We.panelId]:F,[We.panelSize]:parseFloat(""+Z.flexGrow).toFixed(1)})}const Qs=c.forwardRef((e,r)=>c.createElement(Js,{...e,forwardedRef:r}));Js.displayName="Panel";Qs.displayName="forwardRef(Panel)";let Sn=null,Rr=-1,St=null;function pc(e,r,n){const a=(r&ao)!==0,o=(r&so)!==0,s=(r&oo)!==0,l=(r&lo)!==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 fc(){St!==null&&(document.head.removeChild(St),Sn=null,St=null,Rr=-1)}function ln(e,r,n){var a,o;const s=pc(e,r);if(Sn!==s){if(Sn=s,St===null&&(St=document.createElement("style"),document.head.appendChild(St)),Rr>=0){var l;(l=St.sheet)===null||l===void 0||l.removeRule(Rr)}Rr=(a=(o=St.sheet)===null||o===void 0?void 0:o.insertRule(`*{cursor: ${s} !important;}`))!==null&&a!==void 0?a:-1}}function eo(e){return e.type==="keydown"}function to(e){return e.type.startsWith("pointer")}function ro(e){return e.type.startsWith("mouse")}function Wr(e){if(to(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(ro(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function gc(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function xc(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 bc(e,r){if(e===r)throw new Error("Cannot compare node with itself");const n={a:Ra(e),b:Ra(r)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),r=n.b.pop(),a=e;Se(a,"Stacking order can only be calculated for elements with a common ancestor");const o={a:Ia(za(n.a)),b:Ia(za(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 vc=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function kc(e){var r;const n=getComputedStyle((r=no(e))!==null&&r!==void 0?r:e).display;return n==="flex"||n==="inline-flex"}function wc(e){const r=getComputedStyle(e);return!!(r.position==="fixed"||r.zIndex!=="auto"&&(r.position!=="static"||kc(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"||vc.test(r.willChange)||r.webkitOverflowScrolling==="touch")}function za(e){let r=e.length;for(;r--;){const n=e[r];if(Se(n,"Missing node"),wc(n))return n}return null}function Ia(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Ra(e){const r=[];for(;e;)r.push(e),e=no(e);return r}function no(e){const{parentNode:r}=e;return r&&r instanceof ShadowRoot?r.host:r}const ao=1,so=2,oo=4,lo=8,yc=gc()==="coarse";let ht=[],tr=!1,Tt=new Map,Vr=new Map;const gr=new Set;function jc(e,r,n,a,o){var s;const{ownerDocument:l}=r,i={direction:n,element:r,hitAreaMargins:a,setResizeHandlerState:o},d=(s=Tt.get(l))!==null&&s!==void 0?s:0;return Tt.set(l,d+1),gr.add(i),Br(),function(){var u;Vr.delete(e),gr.delete(i);const m=(u=Tt.get(l))!==null&&u!==void 0?u:1;if(Tt.set(l,m-1),Br(),m===1&&Tt.delete(l),ht.includes(i)){const f=ht.indexOf(i);f>=0&&ht.splice(f,1),Kr(),o("up",!0,null)}}}function Nc(e){const{target:r}=e,{x:n,y:a}=Wr(e);tr=!0,Yn({target:r,x:n,y:a}),Br(),ht.length>0&&(Gr("down",e),Kr(),e.preventDefault(),io(r)||e.stopImmediatePropagation())}function dn(e){const{x:r,y:n}=Wr(e);if(tr&&e.type!=="pointerleave"&&e.buttons===0&&(tr=!1,Gr("up",e)),!tr){const{target:a}=e;Yn({target:a,x:r,y:n})}Gr("move",e),Kr(),ht.length>0&&e.preventDefault()}function cn(e){const{target:r}=e,{x:n,y:a}=Wr(e);Vr.clear(),tr=!1,ht.length>0&&(e.preventDefault(),io(r)||e.stopImmediatePropagation()),Gr("up",e),Yn({target:r,x:n,y:a}),Kr(),Br()}function io(e){let r=e;for(;r;){if(r.hasAttribute(We.resizeHandle))return!0;r=r.parentElement}return!1}function Yn({target:e,x:r,y:n}){ht.splice(0);let a=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(a=e),gr.forEach(o=>{const{element:s,hitAreaMargins:l}=o,i=s.getBoundingClientRect(),{bottom:d,left:h,right:u,top:m}=i,f=yc?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)&&bc(a,s)>0){let g=a,b=!1;for(;g&&!g.contains(s);){if(xc(g.getBoundingClientRect(),i)){b=!0;break}g=g.parentElement}if(b)return}ht.push(o)}})}function hn(e,r){Vr.set(e,r)}function Kr(){let e=!1,r=!1;ht.forEach(a=>{const{direction:o}=a;o==="horizontal"?e=!0:r=!0});let n=0;Vr.forEach(a=>{n|=a}),e&&r?ln("intersection",n):e?ln("horizontal",n):r?ln("vertical",n):fc()}let un;function Br(){var e;(e=un)===null||e===void 0||e.abort(),un=new AbortController;const r={capture:!0,signal:un.signal};gr.size&&(tr?(ht.length>0&&Tt.forEach((n,a)=>{const{body:o}=a;n>0&&(o.addEventListener("contextmenu",cn,r),o.addEventListener("pointerleave",dn,r),o.addEventListener("pointermove",dn,r))}),Tt.forEach((n,a)=>{const{body:o}=a;o.addEventListener("pointerup",cn,r),o.addEventListener("pointercancel",cn,r)})):Tt.forEach((n,a)=>{const{body:o}=a;n>0&&(o.addEventListener("pointerdown",Nc,r),o.addEventListener("pointermove",dn,r))}))}function Gr(e,r){gr.forEach(n=>{const{setResizeHandlerState:a}=n,o=ht.includes(n);a(e,o,r)})}function Cc(){const[e,r]=c.useState(0);return c.useCallback(()=>r(n=>n+1),[])}function Se(e,r){if(!e)throw console.error(r),Error(r)}function Ft(e,r,n=qn){return e.toFixed(n)===r.toFixed(n)?0:e>r?1:-1}function vt(e,r,n=qn){return Ft(e,r,n)===0}function it(e,r,n){return Ft(e,r,n)===0}function Sc(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(!it(o,s,n))return!1}return!0}function Qt({panelConstraints:e,panelIndex:r,size:n}){const a=e[r];Se(a!=null,`Panel constraints not found for index ${r}`);let{collapsedSize:o=0,collapsible:s,maxSize:l=100,minSize:i=0}=a;if(Ft(n,i)<0)if(s){const d=(o+i)/2;Ft(n,d)<0?n=o:n=i}else n=i;return n=Math.min(l,n),n=parseFloat(n.toFixed(qn)),n}function cr({delta:e,initialLayout:r,panelConstraints:n,pivotIndices:a,prevLayout:o,trigger:s}){if(it(e,0))return r;const l=[...r],[i,d]=a;Se(i!=null,"Invalid first pivot index"),Se(d!=null,"Invalid second pivot index");let h=0;if(s==="keyboard"){{const m=e<0?d:i,f=n[m];Se(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(Se(w!=null,`Previous layout not found for panel index ${m}`),it(w,p)){const x=b-w;Ft(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}{const m=e<0?i:d,f=n[m];Se(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(Se(w!=null,`Previous layout not found for panel index ${m}`),it(w,b)){const x=w-p;Ft(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];Se(b!=null,`Previous layout not found for panel index ${f}`);const x=Qt({panelConstraints:n,panelIndex:f,size:100})-b;if(p+=x,f+=m,f<0||f>=n.length)break}const g=Math.min(Math.abs(e),Math.abs(p));e=e<0?0-g:g}{let f=e<0?i:d;for(;f>=0&&f<n.length;){const p=Math.abs(e)-Math.abs(h),g=r[f];Se(g!=null,`Previous layout not found for panel index ${f}`);const b=g-p,w=Qt({panelConstraints:n,panelIndex:f,size:b});if(!it(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(Sc(o,l))return o;{const m=e<0?d:i,f=r[m];Se(f!=null,`Previous layout not found for panel index ${m}`);const p=f+h,g=Qt({panelConstraints:n,panelIndex:m,size:p});if(l[m]=g,!it(g,p)){let b=p-g,x=e<0?d:i;for(;x>=0&&x<n.length;){const y=l[x];Se(y!=null,`Previous layout not found for panel index ${x}`);const k=y+b,j=Qt({panelConstraints:n,panelIndex:x,size:k});if(it(y,j)||(b-=j-y,l[x]=j),it(b,0))break;e>0?x--:x++}}}const u=l.reduce((m,f)=>f+m,0);return it(u,100)?l:o}function Tc({layout:e,panelsArray:r,pivotIndices:n}){let a=0,o=100,s=0,l=0;const i=n[0];Se(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 xr(e,r=document){return Array.from(r.querySelectorAll(`[${We.resizeHandleId}][data-panel-group-id="${e}"]`))}function co(e,r,n=document){const o=xr(e,n).findIndex(s=>s.getAttribute(We.resizeHandleId)===r);return o??null}function ho(e,r,n){const a=co(e,r,n);return a!=null?[a,a+1]:[-1,-1]}function Ec(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function uo(e,r=document){if(Ec(r)&&r.dataset.panelGroupId==e)return r;const n=r.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function qr(e,r=document){const n=r.querySelector(`[${We.resizeHandleId}="${e}"]`);return n||null}function Lc(e,r,n,a=document){var o,s,l,i;const d=qr(r,a),h=xr(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 Pc({committedValuesRef:e,eagerValuesRef:r,groupId:n,layout:a,panelDataArray:o,panelGroupElement:s,setLayout:l}){c.useRef({didWarnAboutMissingResizeHandle:!1}),Bt(()=>{if(!s)return;const i=xr(n,s);for(let d=0;d<o.length-1;d++){const{valueMax:h,valueMin:u,valueNow:m}=Tc({layout:a,panelsArray:o,pivotIndices:[d,d+1]}),f=i[d];if(f!=null){const p=o[d];Se(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;Se(i,"Eager values not found");const{panelDataArray:d}=i,h=uo(n,s);Se(h!=null,`No group found for id "${n}"`);const u=xr(n,s);Se(u,`No resize handles found for group id "${n}"`);const m=u.map(f=>{const p=f.getAttribute(We.resizeHandleId);Se(p,"Resize handle element has no handle id attribute");const[g,b]=Lc(n,p,d,s);if(g==null||b==null)return()=>{};const w=x=>{if(!x.defaultPrevented)switch(x.key){case"Enter":{x.preventDefault();const y=d.findIndex(k=>k.id===g);if(y>=0){const k=d[y];Se(k,`No panel data found for index ${y}`);const j=a[y],{collapsedSize:v=0,collapsible:N,minSize:S=0}=k.constraints;if(j!=null&&N){const L=cr({delta:it(j,v)?S-v:v-j,initialLayout:a,panelConstraints:d.map(P=>P.constraints),pivotIndices:ho(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 Aa(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 mo(e,r){const n=e==="horizontal",{x:a,y:o}=Wr(r);return n?a:o}function zc(e,r,n,a,o){const s=n==="horizontal",l=qr(r,o);Se(l,`No resize handle element found for id "${r}"`);const i=l.getAttribute(We.groupId);Se(i,"Resize handle element has no group id attribute");let{initialCursorPosition:d}=a;const h=mo(n,e),u=uo(i,o);Se(u,`No group element found for id "${i}"`);const m=u.getBoundingClientRect(),f=s?m.width:m.height;return(h-d)/f*100}function Ic(e,r,n,a,o,s){if(eo(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:zc(e,r,n,a,s)}function Rc({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];Se(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];Se(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 qt(e,r,n){r.forEach((a,o)=>{const s=e[o];Se(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||vt(m,h))&&!vt(a,h)&&p(),f&&(m==null||!vt(m,h))&&vt(a,h)&&f())}})}function Tr(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 Ac({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 _c(e,r=10){let n=null;return(...o)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...o)},r)}}function _a(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 po(e){return`react-resizable-panels:${e}`}function fo(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 go(e,r){try{const n=po(e),a=r.getItem(n);if(a){const o=JSON.parse(a);if(typeof o=="object"&&o!=null)return o}}catch{}return null}function Mc(e,r,n){var a,o;const s=(a=go(e,n))!==null&&a!==void 0?a:{},l=fo(r);return(o=s[l])!==null&&o!==void 0?o:null}function $c(e,r,n,a,o){var s;const l=po(e),i=fo(r),d=(s=go(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 Ma({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(!it(a,100)&&n.length>0)for(let s=0;s<r.length;s++){const l=n[s];Se(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];Se(l!=null,`No layout data found for index ${s}`);const i=Qt({panelConstraints:r,panelIndex:s,size:l});l!=i&&(o+=l-i,n[s]=i)}if(!it(o,0))for(let s=0;s<r.length;s++){const l=n[s];Se(l!=null,`No layout data found for index ${s}`);const i=l+o,d=Qt({panelConstraints:r,panelIndex:s,size:i});if(l!==d&&(o-=d-l,n[s]=d,it(o,0)))break}return n}const Dc=100,hr={getItem:e=>(_a(hr),hr.getItem(e)),setItem:(e,r)=>{_a(hr),hr.setItem(e,r)}},$a={};function xo({autoSaveId:e=null,children:r,className:n="",direction:a,forwardedRef:o,id:s=null,onLayout:l=null,keyboardResizeBy:i=null,storage:d=hr,style:h,tagName:u="div",...m}){const f=Xn(s),p=c.useRef(null),[g,b]=c.useState(null),[w,x]=c.useState([]),y=Cc(),k=c.useRef({}),j=c.useRef(new Map),v=c.useRef(0),N=c.useRef({autoSaveId:e,direction:a,dragState:g,id:f,keyboardResizeBy:i,onLayout:l,storage:d}),S=c.useRef({layout:w,panelDataArray:[],panelDataArrayChanged:!1});c.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),c.useImperativeHandle(o,()=>({getId:()=>N.current.id,getLayout:()=>{const{layout:T}=S.current;return T},setLayout:T=>{const{onLayout:U}=N.current,{layout:H,panelDataArray:C}=S.current,E=Ma({layout:T,panelConstraints:C.map(X=>X.constraints)});Aa(H,E)||(x(E),S.current.layout=E,U&&U(E),qt(C,E,k.current))}}),[]),Bt(()=>{N.current.autoSaveId=e,N.current.direction=a,N.current.dragState=g,N.current.id=f,N.current.onLayout=l,N.current.storage=d}),Pc({committedValuesRef:N,eagerValuesRef:S,groupId:f,layout:w,panelDataArray:S.current.panelDataArray,setLayout:x,panelGroupElement:p.current}),c.useEffect(()=>{const{panelDataArray:T}=S.current;if(e){if(w.length===0||w.length!==T.length)return;let U=$a[e];U==null&&(U=_c($c,Dc),$a[e]=U);const H=[...T],C=new Map(j.current);U(e,H,C,w,d)}},[e,w,d]),c.useEffect(()=>{});const L=c.useCallback(T=>{const{onLayout:U}=N.current,{layout:H,panelDataArray:C}=S.current;if(T.constraints.collapsible){const E=C.map(Q=>Q.constraints),{collapsedSize:X=0,panelSize:W,pivotIndices:le}=At(C,T,H);if(Se(W!=null,`Panel size not found for panel "${T.id}"`),!vt(W,X)){j.current.set(T.id,W);const de=Yt(C,T)===C.length-1?W-X:X-W,re=cr({delta:de,initialLayout:H,panelConstraints:E,pivotIndices:le,prevLayout:H,trigger:"imperative-api"});Tr(H,re)||(x(re),S.current.layout=re,U&&U(re),qt(C,re,k.current))}}},[]),P=c.useCallback((T,U)=>{const{onLayout:H}=N.current,{layout:C,panelDataArray:E}=S.current;if(T.constraints.collapsible){const X=E.map(xe=>xe.constraints),{collapsedSize:W=0,panelSize:le=0,minSize:Q=0,pivotIndices:de}=At(E,T,C),re=U??Q;if(vt(le,W)){const xe=j.current.get(T.id),ie=xe!=null&&xe>=re?xe:re,Pe=Yt(E,T)===E.length-1?le-ie:ie-le,se=cr({delta:Pe,initialLayout:C,panelConstraints:X,pivotIndices:de,prevLayout:C,trigger:"imperative-api"});Tr(C,se)||(x(se),S.current.layout=se,H&&H(se),qt(E,se,k.current))}}},[]),K=c.useCallback(T=>{const{layout:U,panelDataArray:H}=S.current,{panelSize:C}=At(H,T,U);return Se(C!=null,`Panel size not found for panel "${T.id}"`),C},[]),F=c.useCallback((T,U)=>{const{panelDataArray:H}=S.current,C=Yt(H,T);return Ac({defaultSize:U,dragState:g,layout:w,panelData:H,panelIndex:C})},[g,w]),D=c.useCallback(T=>{const{layout:U,panelDataArray:H}=S.current,{collapsedSize:C=0,collapsible:E,panelSize:X}=At(H,T,U);return Se(X!=null,`Panel size not found for panel "${T.id}"`),E===!0&&vt(X,C)},[]),Z=c.useCallback(T=>{const{layout:U,panelDataArray:H}=S.current,{collapsedSize:C=0,collapsible:E,panelSize:X}=At(H,T,U);return Se(X!=null,`Panel size not found for panel "${T.id}"`),!E||Ft(X,C)>0},[]),Y=c.useCallback(T=>{const{panelDataArray:U}=S.current;U.push(T),U.sort((H,C)=>{const E=H.order,X=C.order;return E==null&&X==null?0:E==null?-1:X==null?1:E-X}),S.current.panelDataArrayChanged=!0,y()},[y]);Bt(()=>{if(S.current.panelDataArrayChanged){S.current.panelDataArrayChanged=!1;const{autoSaveId:T,onLayout:U,storage:H}=N.current,{layout:C,panelDataArray:E}=S.current;let X=null;if(T){const le=Mc(T,E,H);le&&(j.current=new Map(Object.entries(le.expandToSizes)),X=le.layout)}X==null&&(X=Rc({panelDataArray:E}));const W=Ma({layout:X,panelConstraints:E.map(le=>le.constraints)});Aa(C,W)||(x(W),S.current.layout=W,U&&U(W),qt(E,W,k.current))}}),Bt(()=>{const T=S.current;return()=>{T.layout=[]}},[]);const $=c.useCallback(T=>{let U=!1;const H=p.current;return H&&window.getComputedStyle(H,null).getPropertyValue("direction")==="rtl"&&(U=!0),function(E){E.preventDefault();const X=p.current;if(!X)return()=>null;const{direction:W,dragState:le,id:Q,keyboardResizeBy:de,onLayout:re}=N.current,{layout:xe,panelDataArray:ie}=S.current,{initialLayout:ve}=le??{},Pe=ho(Q,T,X);let se=Ic(E,T,W,le,de,X);const ye=W==="horizontal";ye&&U&&(se=-se);const je=ie.map(ge=>ge.constraints),G=cr({delta:se,initialLayout:ve??xe,panelConstraints:je,pivotIndices:Pe,prevLayout:xe,trigger:eo(E)?"keyboard":"mouse-or-touch"}),me=!Tr(xe,G);(to(E)||ro(E))&&v.current!=se&&(v.current=se,!me&&se!==0?ye?hn(T,se<0?ao:so):hn(T,se<0?oo:lo):hn(T,0)),me&&(x(G),S.current.layout=G,re&&re(G),qt(ie,G,k.current))}},[]),te=c.useCallback((T,U)=>{const{onLayout:H}=N.current,{layout:C,panelDataArray:E}=S.current,X=E.map(xe=>xe.constraints),{panelSize:W,pivotIndices:le}=At(E,T,C);Se(W!=null,`Panel size not found for panel "${T.id}"`);const de=Yt(E,T)===E.length-1?W-U:U-W,re=cr({delta:de,initialLayout:C,panelConstraints:X,pivotIndices:le,prevLayout:C,trigger:"imperative-api"});Tr(C,re)||(x(re),S.current.layout=re,H&&H(re),qt(E,re,k.current))},[]),oe=c.useCallback((T,U)=>{const{layout:H,panelDataArray:C}=S.current,{collapsedSize:E=0,collapsible:X}=U,{collapsedSize:W=0,collapsible:le,maxSize:Q=100,minSize:de=0}=T.constraints,{panelSize:re}=At(C,T,H);re!=null&&(X&&le&&vt(re,E)?vt(E,W)||te(T,W):re<de?te(T,de):re>Q&&te(T,Q))},[te]),A=c.useCallback((T,U)=>{const{direction:H}=N.current,{layout:C}=S.current;if(!p.current)return;const E=qr(T,p.current);Se(E,`Drag handle element not found for id "${T}"`);const X=mo(H,U);b({dragHandleId:T,dragHandleRect:E.getBoundingClientRect(),initialCursorPosition:X,initialLayout:C})},[]),J=c.useCallback(()=>{b(null)},[]),I=c.useCallback(T=>{const{panelDataArray:U}=S.current,H=Yt(U,T);H>=0&&(U.splice(H,1),delete k.current[T.id],S.current.panelDataArrayChanged=!0,y())},[y]),q=c.useMemo(()=>({collapsePanel:L,direction:a,dragState:g,expandPanel:P,getPanelSize:K,getPanelStyle:F,groupId:f,isPanelCollapsed:D,isPanelExpanded:Z,reevaluatePanelConstraints:oe,registerPanel:Y,registerResizeHandle:$,resizePanel:te,startDragging:A,stopDragging:J,unregisterPanel:I,panelGroupElement:p.current}),[L,g,a,P,K,F,f,D,Z,oe,Y,$,te,A,J,I]),O={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return c.createElement(Ur.Provider,{value:q},c.createElement(u,{...m,children:r,className:n,id:s,ref:p,style:{...O,...h},[We.group]:"",[We.groupDirection]:a,[We.groupId]:f}))}const bo=c.forwardRef((e,r)=>c.createElement(xo,{...e,forwardedRef:r}));xo.displayName="PanelGroup";bo.displayName="forwardRef(PanelGroup)";function Yt(e,r){return e.findIndex(n=>n===r||n.id===r.id)}function At(e,r,n){const a=Yt(e,r),s=a===e.length-1?[a-1,a]:[a,a+1],l=n[a];return{...r.constraints,panelSize:l,pivotIndices:s}}function Bc({disabled:e,handleId:r,resizeHandler:n,panelGroupElement:a}){c.useEffect(()=>{if(e||n==null||a==null)return;const o=qr(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(We.groupId);Se(i,`No group element found for id "${i}"`);const d=xr(i,a),h=co(i,r,a);Se(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 vo({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),y=c.useRef({onClick:l,onDragging:i,onPointerDown:h,onPointerUp:u});c.useEffect(()=>{y.current.onClick=l,y.current.onDragging=i,y.current.onPointerDown=h,y.current.onPointerUp=u});const k=c.useContext(Ur);if(k===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:j,groupId:v,registerResizeHandle:N,startDragging:S,stopDragging:L,panelGroupElement:P}=k,K=Xn(o),[F,D]=c.useState("inactive"),[Z,Y]=c.useState(!1),[$,te]=c.useState(null),oe=c.useRef({state:F});Bt(()=>{oe.current.state=F}),c.useEffect(()=>{if(n)te(null);else{const q=N(K);te(()=>q)}},[n,K,N]);const A=(b=a==null?void 0:a.coarse)!==null&&b!==void 0?b:15,J=(w=a==null?void 0:a.fine)!==null&&w!==void 0?w:5;c.useEffect(()=>{if(n||$==null)return;const q=x.current;Se(q,"Element ref not attached");let O=!1;return jc(K,q,j,{coarse:A,fine:J},(U,H,C)=>{if(!H){D("inactive");return}switch(U){case"down":{D("drag"),O=!1,Se(C,'Expected event to be defined for "down" action'),S(K,C);const{onDragging:E,onPointerDown:X}=y.current;E==null||E(!0),X==null||X();break}case"move":{const{state:E}=oe.current;O=!0,E!=="drag"&&D("hover"),Se(C,'Expected event to be defined for "move" action'),$(C);break}case"up":{D("hover"),L();const{onClick:E,onDragging:X,onPointerUp:W}=y.current;X==null||X(!1),W==null||W(),O||E==null||E();break}}})},[A,j,n,J,N,K,$,S,L]),Bc({disabled:n,handleId:K,resizeHandler:$,panelGroupElement:P});const I={touchAction:"none",userSelect:"none"};return c.createElement(p,{...g,children:e,className:r,id:o,onBlur:()=>{Y(!1),s==null||s()},onFocus:()=>{Y(!0),d==null||d()},ref:x,role:"separator",style:{...I,...m},tabIndex:f,[We.groupDirection]:j,[We.groupId]:v,[We.resizeHandle]:"",[We.resizeHandleActive]:F==="drag"?"pointer":Z?"keyboard":void 0,[We.resizeHandleEnabled]:!n,[We.resizeHandleId]:K,[We.resizeHandleState]:F})}vo.displayName="PanelResizeHandle";var Gc=Object.defineProperty,Fc=Object.getOwnPropertyNames,$e=(e,r)=>function(){return e&&(r=(0,e[Fc(e)[0]])(e=0)),r},Hc=(e,r)=>{for(var n in r)Gc(e,n,{get:r[n],enumerable:!0})};function nt(...e){return hc($s(e))}var Pt=$e({"src/components/graph-ui/utils.ts"(){}});function br({asChild:e=!1,className:r,size:n,variant:a,...o}){const s=e?Rs:"button";return t.jsx(s,{"data-slot":"button",className:nt(ko({variant:a,size:n,className:r})),...o})}var ko,Xr=$e({"src/components/graph-ui/Button.tsx"(){Pt(),ko=vr("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 wo(...e){return e.filter(Boolean).join(" ")}function Tn({className:e,...r}){return t.jsx(bo,{"data-slot":"resizable-panel-group",className:wo("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...r})}function er({...e}){return t.jsx(Qs,{"data-slot":"resizable-panel",...e})}function En({withHandle:e,className:r,...n}){return t.jsx(vo,{"data-slot":"resizable-handle",className:wo("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(B.GripVerticalIcon,{className:"size-2.5"})}):null})}var yo=$e({"src/components/graph-workspace/GraphResizablePanels.tsx"(){}});function Zn(...e){return e.filter(Boolean).join(" ")}function kr({...e}){return t.jsx($i,{"data-slot":"accordion",...e})}function wr({className:e,...r}){return t.jsx(Di,{"data-slot":"accordion-item",className:Zn("border-b last:border-b-0",e),...r})}function Yr({className:e,children:r,...n}){return t.jsx(Gi,{className:"flex",children:t.jsxs(Fi,{"data-slot":"accordion-trigger",className:Zn("flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium outline-none transition-all hover:underline disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",e),...n,children:[r,t.jsx(B.ChevronDownIcon,{className:"pointer-events-none size-4 shrink-0 translate-y-0.5 text-[var(--theme-fg-muted)] transition-transform duration-200"})]})})}function yr({className:e,children:r,...n}){return t.jsx(Bi,{"data-slot":"accordion-content",className:"overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:t.jsx("div",{className:Zn("pb-4 pt-0",e),children:r})})}var jr=$e({"src/components/graph-workspace/GraphAccordion.tsx"(){}});function Oc(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 Uc(e){return e.trim().replace(/^\/+|\/+$/g,"").replace(/[^\w.-]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function Nr(e){var r;return((r=e.split(".").pop())==null?void 0:r.toLowerCase())||""}function Wc(e){return e.split("/").filter(Boolean).at(-1)??e}function Zt(e){const r=e.kind==="directory"?"directory":"file",n=(e.children??[]).map(Zt);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 jo(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=jo(l,r,n,a);return i!==l&&(o=!0),i});return o?{...e,children:s}:e}function No(e){if(e.kind==="file")return e;for(const r of e.children){const n=No(r);if(n)return n}return null}function Ln(e,r){if(!e||r===null)return null;if(e.path===r)return e;for(const n of e.children){const a=Ln(n,r);if(a)return a}return null}function Co(e){return e.trim().replace(/\\/g,"/").replace(/^\.\/+/,"").replace(/^\/+/,"")}function Vc(e){const n=Co(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 Pn(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=Pn(s,r,n);return l!==s&&(a=!0),l});return a?{...e,children:o}:e}function zn(e,r){return!e||!r?!1:e.path===r?!0:e.children.some(n=>zn(n,r))}function Kc(e){if(!e)return null;const r=Nr(e.path);return Jn.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 qc(e){const r=jr(e);return r==="tsx"||r==="jsx"?"tsx":r==="yml"?"yaml":r||"text"}function Xc(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 Yc(e,r,n){const a=r.split("/").filter(Boolean),s=a.pop()??n.name;Xc(e,a).children.push({...n,name:n.name||s,path:r})}function Zc(e,r){return e.kind==="directory"&&r.kind!=="directory"?-1:e.kind!=="directory"&&r.kind==="directory"?1:e.name.localeCompare(r.name)}function So(e){e.children.sort(Zc);for(const r of e.children)So(r);return e}function Da(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=Uc(f)||m.id;o.children.push({id:`artifact:${m.id}`,name:`${p}.artifact`,path:`artifacts/${p}.artifact`,kind:"artifact",artifact:m,preview:m.summaryText??m.type,detail:JSON.stringify(m.payload,null,2),children:[]})}const l={id:"thread-events",name:"thread-events",path:"thread-events",kind:"directory",children:[]},i={id:"live",name:"live",path:"live",kind:"directory",children:[]};let d=0;const h=(m,f,p=!1)=>{d+=1;const g=f.kind.replace(/([A-Z])/g,"-$1").toLowerCase(),b=`${p?"live":`thread-events/${m}`}/${String(d).padStart(3,"0")}-${g}.json`,v="text"in f&&typeof f.text=="string"?f.text.slice(0,160):f.kind,x=f.kind==="artifact"&&f.artifact?f.artifact:null,y=x&&p?{id:`live-artifact:${x.id}`,name:x.title||x.id,path:b,kind:"live-artifact",artifact:x,item:f,preview:x.summaryText??x.type,detail:JSON.stringify(x.payload,null,2),children:[]}:{id:`event:${f.id}`,name:Wc(b),path:b,kind:"event",item:f,preview:v,detail:JSON.stringify(f,null,2),children:[]};if(p){i.children.push(y);return}Yc(l,b.replace(/^thread-events\//,""),y)};for(const m of e.turns)for(const f of m.items)(f.kind==="commandExecution"||f.kind==="webSearch"||f.kind==="fileRead"||f.kind==="fileChange"||f.kind==="agentToolCall"||f.kind==="skillToolCall"||f.kind==="toolCall"||f.kind==="hook"||f.kind==="plan"||f.kind==="reasoning")&&h(m.id,f);for(const m of((u=e.liveItems)==null?void 0:u.items)??[])h(e.thread.activeTurnId??"live",m,!0);return s.children.push(o,l,i),So(s)}function Jc(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 To(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=To(r);if(n)return n}return null}function Ba(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 Qn,Eo,Lo,ea=$e({"src/components/graph-workspace/workspaceTree.ts"(){Qn=new Set(["xyz","extxyz","cif","pdb"]),Eo=new Set(["png","jpg","jpeg","gif","webp","svg"]),Lo=new Set(["pdf"])}});function Jt({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 Po=$e({"src/components/graph-workspace/GraphWorkspaceCards.tsx"(){}});function Qc({className:e,decorative:r=!0,orientation:n="horizontal",...a}){return t.jsx(sd,{"data-slot":"separator",decorative:r,orientation:n,className:nt("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 eh=$e({"src/components/graph-ui/Separator.tsx"(){Pt()}});function th({className:e,orientation:r,...n}){return t.jsx("div",{role:"group","data-slot":"button-group","data-orientation":r,className:nt(zo({orientation:r}),e),...n})}function rh({className:e,orientation:r="vertical",...n}){return t.jsx(Qc,{"data-slot":"button-group-separator",orientation:r,className:nt("relative !m-0 self-stretch bg-input data-[orientation=vertical]:h-auto",e),...n})}var zo,Io=$e({"src/components/graph-ui/ButtonGroup.tsx"(){eh(),Pt(),zo=br("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 nh({delayDuration:e=0,...r}){return t.jsx(od,{"data-slot":"tooltip-provider",delayDuration:e,...r})}function ah({...e}){return t.jsx(nh,{children:t.jsx(ed,{"data-slot":"tooltip",...e})})}function sh({...e}){return t.jsx(td,{"data-slot":"tooltip-trigger",...e})}function oh({children:e,className:r,sideOffset:n=0,...a}){return t.jsx(rd,{children:t.jsxs(nd,{"data-slot":"tooltip-content",sideOffset:n,className:nt("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(ad,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}var lh=$e({"src/components/graph-ui/Tooltip.tsx"(){Pt()}});function ih(e){return(e==null?void 0:e.trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""))||"molecule"}function Ga(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 Xe({children:e,disabled:r,label:n,onClick:a}){return t.jsxs(ah,{children:[t.jsx(sh,{asChild:!0,children:t.jsx(xr,{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(oh,{children:t.jsx("p",{children:n})})]})}function Rn({children:e,className:r=""}){return t.jsx(th,{className:`thread-graph-molecule-button-group ${r}`,children:e})}var Ro=$e({"src/components/graph-workspace/GraphMoleculeViewerControls.tsx"(){Xr(),Io(),lh()}});function dh({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(Rn,{children:[t.jsx(Xe,{label:"Distance",children:t.jsx(B.AlignVerticalDistributeCenter,{className:"size-4"})}),t.jsx(Xe,{label:"Connectivity",children:t.jsx(B.Share2,{className:"size-4"})}),t.jsx(Xe,{label:"Angle",children:t.jsx(B.Waypoints,{className:"size-4"})}),t.jsx(Xe,{label:"Dihedral",children:t.jsx(B.Spline,{className:"size-4"})}),t.jsx(Xe,{label:"Add dummy atoms",children:t.jsx(B.Bubbles,{className:"size-4"})}),t.jsx(Xe,{label:"Delete atoms",children:t.jsx(B.CircleX,{className:"size-4"})}),t.jsx(Xe,{label:"Rotate",children:t.jsx(B.Rotate3d,{className:"size-4"})})]}),t.jsxs(Rn,{children:[t.jsx(Xe,{label:f?"Hide unit cell":"Show unit cell",disabled:!m,onClick:l,children:t.jsx(B.Boxes,{className:"size-4"})}),t.jsx(Xe,{label:"Clear selection",disabled:!p,onClick:r,children:t.jsx(B.Trash2,{className:"size-4"})}),t.jsx(Xe,{label:"Send selection",disabled:!p,onClick:a,children:t.jsx(B.Send,{className:"size-4"})}),t.jsx(Xe,{label:"Stage current selection",disabled:!p,onClick:o,children:t.jsx(B.Box,{className:"size-4"})}),t.jsx(Xe,{label:"Clear staged selections",disabled:!g,onClick:n,children:t.jsx(B.Eraser,{className:"size-4"})}),t.jsx(Xe,{label:"Send staged selections",disabled:!g,onClick:s,children:t.jsx(B.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 ch=$e({"src/components/graph-workspace/GraphMoleculeViewerLowerButtonGroup.tsx"(){Ro()}});function hh({currentIndex:e,exportContent:r,moleculeId:n,onScreenshot:a,viewerRef:s,xyzContent:o,xyzFormat:l}){const i=ih(n);async function d(){o&&await navigator.clipboard.writeText(o)}function h(){o&&Ga(o,`${i}_step_${e+1}.${l||"xyz"}`)}function u(){r&&Ga(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(Rn,{className:"ml-auto justify-end",children:[t.jsx(Xe,{label:"Copy current structure",onClick:()=>void d(),disabled:!o,children:t.jsx(B.Copy,{className:"size-3.5"})}),t.jsx(Xe,{label:"Download current structure",onClick:h,disabled:!o,children:t.jsx(B.Download,{className:"size-3.5"})}),t.jsx(Xe,{label:"Download full trajectory",onClick:u,disabled:!r,children:t.jsx(B.Box,{className:"size-3.5"})}),t.jsx(Xe,{label:"Copy screenshot",onClick:a,disabled:!s.current||!o,children:t.jsx(B.Camera,{className:"size-3.5"})}),t.jsx(rh,{className:"thread-graph-molecule-button-divider"}),t.jsx(Xe,{label:"Zoom in",onClick:m,disabled:!s.current||!o,children:t.jsx(B.ZoomIn,{className:"size-3.5"})}),t.jsx(Xe,{label:"Zoom out",onClick:f,disabled:!s.current||!o,children:t.jsx(B.ZoomOut,{className:"size-3.5"})}),t.jsx(Xe,{label:"Reset camera",onClick:p,disabled:!s.current||!o,children:t.jsx(B.RotateCcw,{className:"size-3.5"})})]})}var uh=$e({"src/components/graph-workspace/GraphMoleculeViewerUpperButtonGroup.tsx"(){Io(),Ro()}});async function mh(){if(typeof window>"u")throw new Error("3Dmol is only available in a browser environment.");return window["3Dmol"]?window["3Dmol"]:(Rr||(Rr=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)})),Rr)}var Rr,ph=$e({"src/components/graph-workspace/load3Dmol.ts"(){Rr=null}});function fh({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(Yi,{"data-slot":"slider",...r!==void 0?{defaultValue:r}:{},...s!==void 0?{value:s}:{},min:a,max:n,className:nt("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(Zi,{"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(Ji,{"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(Qi,{"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 gh=$e({"src/components/graph-ui/Slider.tsx"(){Pt()}});function xh(e){const r=e==null?void 0:e.trim().toLowerCase();return!r||r==="extxyz"?"xyz":r}function bh(e){var s,o;const r=e.replace(/\r\n/g,`
4
+ `],format:r==="extxyz"?"xyz":r,name:e.name,uuid:e.path}:null}function qc(e){const r=Nr(e);return r==="tsx"||r==="jsx"?"tsx":r==="yml"?"yaml":r||"text"}function Xc(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 Yc(e,r,n){const a=r.split("/").filter(Boolean),o=a.pop()??n.name;Xc(e,a).children.push({...n,name:n.name||o,path:r})}function Zc(e,r){return e.kind==="directory"&&r.kind!=="directory"?-1:e.kind!=="directory"&&r.kind==="directory"?1:e.name.localeCompare(r.name)}function So(e){e.children.sort(Zc);for(const r of e.children)So(r);return e}function Da(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=Uc(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,y=x&&p?{id:`live-artifact:${x.id}`,name:x.title||x.id,path:b,kind:"live-artifact",artifact:x,item:f,preview:x.summaryText??x.type,detail:JSON.stringify(x.payload,null,2),children:[]}:{id:`event:${f.id}`,name:Wc(b),path:b,kind:"event",item:f,preview:w,detail:JSON.stringify(f,null,2),children:[]};if(p){i.children.push(y);return}Yc(l,b.replace(/^thread-events\//,""),y)};for(const m of e.turns)for(const f of m.items)(f.kind==="commandExecution"||f.kind==="webSearch"||f.kind==="fileRead"||f.kind==="fileChange"||f.kind==="agentToolCall"||f.kind==="skillToolCall"||f.kind==="toolCall"||f.kind==="hook"||f.kind==="plan"||f.kind==="reasoning")&&h(m.id,f);for(const m of((u=e.liveItems)==null?void 0:u.items)??[])h(e.thread.activeTurnId??"live",m,!0);return o.children.push(s,l,i),So(o)}function Jc(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 To(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=To(r);if(n)return n}return null}function Ba(e){const r=e.split("/").filter(Boolean),n=[];for(let a=1;a<=r.length;a+=1)n.push(r.slice(0,a).join("/"));return n}var Jn,Eo,Lo,Qn=$e({"src/components/graph-workspace/workspaceTree.ts"(){Jn=new Set(["xyz","extxyz","cif","pdb"]),Eo=new Set(["png","jpg","jpeg","gif","webp","svg"]),Lo=new Set(["pdf"])}});function Jt({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 Po=$e({"src/components/graph-workspace/GraphWorkspaceCards.tsx"(){}});function Qc({className:e,decorative:r=!0,orientation:n="horizontal",...a}){return t.jsx(sd,{"data-slot":"separator",decorative:r,orientation:n,className:nt("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 eh=$e({"src/components/graph-ui/Separator.tsx"(){Pt()}});function th({className:e,orientation:r,...n}){return t.jsx("div",{role:"group","data-slot":"button-group","data-orientation":r,className:nt(zo({orientation:r}),e),...n})}function rh({className:e,orientation:r="vertical",...n}){return t.jsx(Qc,{"data-slot":"button-group-separator",orientation:r,className:nt("relative !m-0 self-stretch bg-input data-[orientation=vertical]:h-auto",e),...n})}var zo,Io=$e({"src/components/graph-ui/ButtonGroup.tsx"(){eh(),Pt(),zo=vr("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 nh({delayDuration:e=0,...r}){return t.jsx(od,{"data-slot":"tooltip-provider",delayDuration:e,...r})}function ah({...e}){return t.jsx(nh,{children:t.jsx(ed,{"data-slot":"tooltip",...e})})}function sh({...e}){return t.jsx(td,{"data-slot":"tooltip-trigger",...e})}function oh({children:e,className:r,sideOffset:n=0,...a}){return t.jsx(rd,{children:t.jsxs(nd,{"data-slot":"tooltip-content",sideOffset:n,className:nt("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(ad,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}var lh=$e({"src/components/graph-ui/Tooltip.tsx"(){Pt()}});function ih(e){return(e==null?void 0:e.trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""))||"molecule"}function Ga(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 Xe({children:e,disabled:r,label:n,onClick:a}){return t.jsxs(ah,{children:[t.jsx(sh,{asChild:!0,children:t.jsx(br,{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(oh,{children:t.jsx("p",{children:n})})]})}function In({children:e,className:r=""}){return t.jsx(th,{className:`thread-graph-molecule-button-group ${r}`,children:e})}var Ro=$e({"src/components/graph-workspace/GraphMoleculeViewerControls.tsx"(){Xr(),Io(),lh()}});function dh({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(In,{children:[t.jsx(Xe,{label:"Distance",children:t.jsx(B.AlignVerticalDistributeCenter,{className:"size-4"})}),t.jsx(Xe,{label:"Connectivity",children:t.jsx(B.Share2,{className:"size-4"})}),t.jsx(Xe,{label:"Angle",children:t.jsx(B.Waypoints,{className:"size-4"})}),t.jsx(Xe,{label:"Dihedral",children:t.jsx(B.Spline,{className:"size-4"})}),t.jsx(Xe,{label:"Add dummy atoms",children:t.jsx(B.Bubbles,{className:"size-4"})}),t.jsx(Xe,{label:"Delete atoms",children:t.jsx(B.CircleX,{className:"size-4"})}),t.jsx(Xe,{label:"Rotate",children:t.jsx(B.Rotate3d,{className:"size-4"})})]}),t.jsxs(In,{children:[t.jsx(Xe,{label:f?"Hide unit cell":"Show unit cell",disabled:!m,onClick:l,children:t.jsx(B.Boxes,{className:"size-4"})}),t.jsx(Xe,{label:"Clear selection",disabled:!p,onClick:r,children:t.jsx(B.Trash2,{className:"size-4"})}),t.jsx(Xe,{label:"Send selection",disabled:!p,onClick:a,children:t.jsx(B.Send,{className:"size-4"})}),t.jsx(Xe,{label:"Stage current selection",disabled:!p,onClick:s,children:t.jsx(B.Box,{className:"size-4"})}),t.jsx(Xe,{label:"Clear staged selections",disabled:!g,onClick:n,children:t.jsx(B.Eraser,{className:"size-4"})}),t.jsx(Xe,{label:"Send staged selections",disabled:!g,onClick:o,children:t.jsx(B.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 ch=$e({"src/components/graph-workspace/GraphMoleculeViewerLowerButtonGroup.tsx"(){Ro()}});function hh({currentIndex:e,exportContent:r,moleculeId:n,onScreenshot:a,viewerRef:o,xyzContent:s,xyzFormat:l}){const i=ih(n);async function d(){s&&await navigator.clipboard.writeText(s)}function h(){s&&Ga(s,`${i}_step_${e+1}.${l||"xyz"}`)}function u(){r&&Ga(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(In,{className:"ml-auto justify-end",children:[t.jsx(Xe,{label:"Copy current structure",onClick:()=>void d(),disabled:!s,children:t.jsx(B.Copy,{className:"size-3.5"})}),t.jsx(Xe,{label:"Download current structure",onClick:h,disabled:!s,children:t.jsx(B.Download,{className:"size-3.5"})}),t.jsx(Xe,{label:"Download full trajectory",onClick:u,disabled:!r,children:t.jsx(B.Box,{className:"size-3.5"})}),t.jsx(Xe,{label:"Copy screenshot",onClick:a,disabled:!o.current||!s,children:t.jsx(B.Camera,{className:"size-3.5"})}),t.jsx(rh,{className:"thread-graph-molecule-button-divider"}),t.jsx(Xe,{label:"Zoom in",onClick:m,disabled:!o.current||!s,children:t.jsx(B.ZoomIn,{className:"size-3.5"})}),t.jsx(Xe,{label:"Zoom out",onClick:f,disabled:!o.current||!s,children:t.jsx(B.ZoomOut,{className:"size-3.5"})}),t.jsx(Xe,{label:"Reset camera",onClick:p,disabled:!o.current||!s,children:t.jsx(B.RotateCcw,{className:"size-3.5"})})]})}var uh=$e({"src/components/graph-workspace/GraphMoleculeViewerUpperButtonGroup.tsx"(){Io(),Ro()}});async function mh(){if(typeof window>"u")throw new Error("3Dmol is only available in a browser environment.");return window["3Dmol"]?window["3Dmol"]:(Ar||(Ar=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)})),Ar)}var Ar,ph=$e({"src/components/graph-workspace/load3Dmol.ts"(){Ar=null}});function fh({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(Yi,{"data-slot":"slider",...r!==void 0?{defaultValue:r}:{},...o!==void 0?{value:o}:{},min:a,max:n,className:nt("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(Zi,{"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(Ji,{"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(Qi,{"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 gh=$e({"src/components/graph-ui/Slider.tsx"(){Pt()}});function xh(e){const r=e==null?void 0:e.trim().toLowerCase();return!r||r==="extxyz"?"xyz":r}function bh(e){var o,s;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&&((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(`
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(`
8
8
  `)}
9
9
  `),a+=i}return n.length>0?n:[e]}function Fa(e,r){return r!=="xyz"?e:e.flatMap(n=>bh(n))}function Ha(e){return e.map(r=>`${r.replace(/\s+$/g,"")}
10
- `).join("")}function vh(e){if(!e)return{format:"xyz",frames:[],exportContent:""};if(typeof e=="string"){const s=Fa([e],"xyz");return{frames:s,format:"xyz",exportContent:Ha(s)}}const r=xh(e.format),n=e.content.filter(s=>s.trim().length>0);return{frames:Fa(n,r),format:r,exportContent:Ha(n)}}var kh=$e({"src/components/graph-workspace/GraphMoleculeViewerData.ts"(){}});function wh({className:e="",moleculeId:r=null,onScreenshot:n,onSelectionChange:a,source:s,title:o="PyMOL-style (PDB/CIF)"}){const l=c.useRef(null),i=c.useRef(null),d=c.useRef(null),h=c.useRef(!1),u=c.useRef(!0),[m,f]=c.useState(null),[p,g]=c.useState(0),[b,v]=c.useState(null),[x,y]=c.useState(!1),[k,C]=c.useState({}),[w,j]=c.useState([]),[S,L]=c.useState({}),[P,K]=c.useState(!1),[F,R]=c.useState(!1),[J,Z]=c.useState(null),D=c.useMemo(()=>vh(s),[s]),te=D.frames,oe=D.format,_=te[p]??null,Y=te.length>0&&p===te.length-1,I=r??"current",q=Object.values(S).reduce((N,T)=>N+T.length,0),H=Object.keys(S).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 N=window.setInterval(()=>{g(T=>T>=te.length-1?(window.clearInterval(N),y(!1),T):T+1)},200);return()=>window.clearInterval(N)},[x,te.length]),c.useEffect(()=>{const N=l.current;if(!N||i.current)return;let T=!1;try{const X=document.createElement("canvas");if(!(X.getContext("webgl2")||X.getContext("webgl")||X.getContext("experimental-webgl"))){Z("WebGL is unavailable in this browser environment. Unable to render 3D viewer.");return}}catch{Z("WebGL is unavailable in this browser environment. Unable to render 3D viewer.");return}const U=()=>{var X,ie;(X=i.current)==null||X.resize(),(ie=i.current)==null||ie.render()};return mh().then(X=>{if(!(T||i.current))try{const ie=X.createViewer(N,{});i.current=ie,ie.setBackgroundColor("#f8fafc",.8),window.addEventListener("resize",U),window.setTimeout(U,100)}catch(ie){console.error("Failed to initialize 3Dmol viewer:",ie),Z("Failed to initialize 3D viewer. Please refresh or try another browser.")}}).catch(X=>{console.error("Failed to load 3Dmol viewer runtime:",X),Z("Failed to load 3D viewer runtime. Please refresh or try another browser.")}),()=>{T=!0,window.removeEventListener("resize",U),i.current=null,d.current=null}},[]),c.useEffect(()=>{const N=i.current;if(!(!N||!_))try{N.removeAllModels(),N.removeAllShapes(),N.removeAllLabels();const T=N.addModel(_,oe||"xyz");d.current=T,T.setStyle({},{stick:{radius:.2},sphere:{scale:.3}});const U=T.getCrystData(),X=!!(U&&typeof U=="object"&&Object.keys(U).length);K(X),R(X?u.current:!1),j([]),C({});const ie=_.split(`
11
- `).slice(2).map(Q=>Q.trim()).filter(Boolean).map(Q=>Q.split(/\s+/)[0]??"Atom");h.current||(N.zoomTo(),h.current=!0),T.setClickable({},!0,(Q,de,re)=>{const xe=Q.serial??Q.index;if(xe===void 0)return;const le=Q.atom||Q.elem||ie[xe]||"Atom";j(ve=>{const se=!!(re!=null&&re.shiftKey||re!=null&&re.metaKey||re!=null&&re.ctrlKey)?ve.includes(xe)?ve.filter(ye=>ye!==xe):[...ve,xe]:ve.length===1&&ve[0]===xe?[]:[xe];return C(ye=>{if(se.length===0)return{};const je={};return se.forEach(G=>{je[G]=ye[G]||ie[G]||le}),je}),se})}),T.setHoverable({},!0,(Q,de,re)=>{!re||!Q||v({x:re.clientX,y:re.clientY,label:`${Q.atom||Q.elem||"Atom"} (${Q.serial??Q.index??"?"})`,coords:{x:Q.x.toFixed(2),y:Q.y.toFixed(2),z:Q.z.toFixed(2)}})},()=>v(null)),N.render()}catch(T){console.error("Failed to render molecule:",T),Z("Unable to render this molecular structure.")}},[_,oe]),c.useEffect(()=>{const N=i.current,T=d.current;if(!(!N||!T)){try{N.removeUnitCell(T)}catch{}if(F&&P)try{N.addUnitCell(T,{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{K(!1),R(!1)}N.render()}},[P,F,_,oe]),c.useEffect(()=>{const N=i.current,T=d.current;!N||!T||!_||(T.setStyle({},{stick:{radius:.2},sphere:{scale:.3}}),w.length>0&&T.setStyle({serial:w},{stick:{radius:.3,color:"yellow"},sphere:{scale:.4,color:"yellow"}}),N.render(),a==null||a({moleculeId:r,atoms:w}))},[r,a,w,_]),c.useEffect(()=>{if(!_)return;let N=0;const T=()=>{var X,ie;const U=(ie=(X=i.current)==null?void 0:X.getView)==null?void 0:ie.call(X);if(Array.isArray(U)&&U.length>=8){const[Q,de,re,xe,le,ve,Pe,se]=U;if(typeof Q=="number"&&typeof de=="number"&&typeof re=="number"&&typeof xe=="number"&&typeof le=="number"&&typeof ve=="number"&&typeof Pe=="number"&&typeof se=="number"){const ye=Math.sqrt(le*le+ve*ve+Pe*Pe),je=ye>0?{x:le/ye,y:ve/ye,z:Pe/ye}:{x:0,y:0,z:0};f({position:{x:Q,y:de,z:re,qx:le,qy:ve,qz:Pe,qw:se},lookAt:je,zoom:xe})}}N=window.requestAnimationFrame(T)};return N=window.requestAnimationFrame(T),()=>window.cancelAnimationFrame(N)},[_]);const E=c.useCallback(async()=>{const N=i.current;if(!(N!=null&&N.pngURI))return;N.render();const T=N.pngURI();if(T){try{const X=await(await fetch(T)).blob(),ie=new ClipboardItem({[X.type||"image/png"]:X});await navigator.clipboard.write([ie])}catch{}n==null||n({moleculeId:r,image:T})}},[r,n]);function W(){P&&R(N=>{const T=!N;return u.current=T,T})}function O(){w.length!==0&&L(N=>{const T=N[I]??[];return{...N,[I]:Array.from(new Set([...T,...w]))}})}return t.jsxs("div",{className:`thread-graph-molecule-viewer flex h-full min-h-0 flex-col bg-white ${e}`,children:[t.jsxs("div",{className:"thread-graph-molecule-header flex shrink-0 items-center justify-between gap-3 border-b border-slate-200 px-3 py-2 sm:px-4 sm:py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"truncate text-sm font-semibold text-slate-900",children:o}),t.jsx("p",{className:"mt-1 hidden text-[11px] text-slate-400 sm:block",children:"cartoon + surface"})]}),t.jsx("span",{className:"shrink-0 text-[11px] text-slate-400",children:"workspace preview"})]}),t.jsxs("div",{className:"thread-graph-molecule-body min-h-0 flex-1",children:[t.jsxs("div",{ref:l,"data-testid":"molecule-viewer",className:"thread-graph-molecule-stage relative min-h-0 flex-1 overflow-hidden",children:[J?t.jsx("div",{"data-testid":"molecule-viewer-error",className:"thread-graph-molecule-error absolute inset-0 flex items-center justify-center bg-red-50 p-4 text-sm text-red-700",children:J}):null,!J&&!_?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(hh,{currentIndex:p,exportContent:D.exportContent,moleculeId:r,onScreenshot:()=>void E(),viewerRef:i,xyzContent:_,xyzFormat:oe})]}),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(xr,{type:"button",variant:"ghost",size:"icon",className:"thread-graph-molecule-button h-5 w-5",onClick:()=>{y(N=>{const T=!N;return T&&p===te.length-1&&g(0),T})},"aria-label":x?"Pause trajectory":"Play trajectory",title:x?"Pause trajectory":"Play trajectory",children:x&&p!==te.length-1?t.jsx(B.Pause,{className:"h-3 w-3"}):t.jsx(B.Play,{className:"h-3 w-3"})})]}),t.jsxs(xr,{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 ${Y?"animate-pulse bg-red-600":"bg-gray-300"}`}),"Live"]})]}),t.jsx(fh,{value:[p],max:te.length-1,step:1,onValueChange:N=>g(N[0]??0),"aria-label":"Trajectory frame"})]}):null,t.jsx(dh,{cameraInfo:m,onClearSelection:()=>j([]),onClearStaged:()=>L({}),onSendSelection:()=>a==null?void 0:a({moleculeId:r,atoms:w}),onSendStaged:()=>{Object.entries(S).forEach(([N,T])=>{a==null||a({moleculeId:N==="current"?r:N,atoms:T})})},onStageSelection:O,onToggleUnitCell:W,selectedAtomLabels:k,selectedSerials:w,stagedAtoms:q,stagedMolecules:H,unitCellAvailable:P,unitCellVisible:F})]})]})]})}var yh=$e({"src/components/graph-workspace/GraphMoleculeViewer.tsx"(){ch(),uh(),ph(),Xr(),gh(),kh()}});function jh(e){return!e.truncated&&e.size<=Ao&&e.content.split(`
12
- `).length<=_o}function Nh(e){return e&&(e.node.path||e.node.name)||null}function Ch(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 Sh({error:e,imageUrl:r,loadingMore:n,onSaveFile:a,onLoadMore:s,onCollapse:o,pdfUrl:l,previewFile:i,previewLoading:d,plugins:h,selectedTarget:u}){const[m,f]=c.useState(!1),[p,g]=c.useState(""),[b,v]=c.useState(null),[x,y]=c.useState(!1),k=(u==null?void 0:u.node)??null,C=k!=null&&k.artifact?h.renderArtifact({artifact:k.artifact,expanded:!0,onToggleExpanded:()=>{}}):null,w=Kc(i??null),j=(i==null?void 0:i.language)||qc((i==null?void 0:i.path)??""),S=i?jr(i.path):"",L=Nh(u),P=i!==null&&Qn.has(S),K=!!(i&&a)&&!P&&jh(i),F=(u==null?void 0:u.kind)==="live-molecule",R=!!(k!=null&&k.artifact&&C),J=!!w||R;c.useEffect(()=>{f(!1),g((i==null?void 0:i.content)??""),v(null)},[i==null?void 0:i.path,i==null?void 0:i.content]);async function Z(){if(!(!i||!a)){y(!0),v(null);try{await a({path:i.path,content:p}),f(!1)}catch(D){v(D instanceof Error?D.message:"Failed to save file.")}finally{y(!1)}}}return t.jsxs("section",{className:"thread-graph-viewer flex h-full min-h-0 flex-col overflow-hidden rounded-[12px]","data-preview-target-kind":(u==null?void 0:u.kind)??"none",children:[t.jsxs("div",{className:"thread-graph-viewer-header flex h-12 shrink-0 items-center justify-between gap-3 border-b px-3 sm:h-[60px] sm:px-5",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[t.jsx("h2",{className:"text-base font-semibold text-slate-900 sm:text-[18px] dark:text-slate-100",children:"Viewer"}),L?t.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-slate-500 dark:text-slate-400",children:L}):null]}),o?t.jsx("button",{type:"button",onClick:o,"data-testid":"collapse-viewer",className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-[#222733] dark:hover:text-slate-100",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(B.ChevronsRight,{className:"h-4 w-4"})}):null]}),t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[e?t.jsx("div",{className:"border-b border-rose-200 bg-rose-50 px-5 py-3 text-sm text-rose-700 dark:border-rose-400/25 dark:bg-rose-400/10 dark:text-rose-200",children:e}):null,u?u.kind==="workspace-file"&&d?t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center px-5 text-center text-sm text-slate-400 dark:text-slate-500",children:"Loading file preview..."}):u.kind==="workspace-file"&&w?t.jsx("div",{className:"thread-graph-molecule-preview min-h-0 flex-1 overflow-hidden",children:t.jsx(wh,{source:w,moleculeId:w.uuid??u.node.path,title:"PyMOL-style (PDB/CIF)"})}):u.kind==="workspace-file"&&r?t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-auto p-5",children:t.jsx("img",{src:r,alt:u.node.path||u.node.name,className:"max-h-full max-w-full object-contain"})}):u.kind==="workspace-file"&&l?t.jsx("div",{className:"thread-graph-file-preview-frame min-h-0 flex-1 overflow-hidden",children:t.jsx("iframe",{src:l,title:`PDF preview: ${u.node.path||u.node.name}`,className:"h-full w-full border-0"})}):u.kind==="workspace-file"&&i?t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs("div",{className:"thread-graph-file-preview-header flex min-h-12 items-center justify-between gap-3 border-b px-4 py-2",children:[t.jsxs("div",{className:"min-w-0 text-xs uppercase tracking-[0.12em]",children:[P?"molecule":j||S||"text"," |"," ",i.size.toLocaleString()," bytes",i.truncated?t.jsxs("span",{className:"ml-2 text-amber-500",children:["showing ",i.nextOffset.toLocaleString()," bytes"]}):null]}),K?t.jsx("div",{className:"flex shrink-0 items-center gap-1",children:m?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>{g(i.content),f(!1),v(null)},disabled:x,className:"thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition disabled:cursor-not-allowed disabled:opacity-50",title:"Cancel edits","aria-label":"Cancel edits",children:t.jsx(B.X,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:()=>void Z(),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(B.Save,{className:"h-4 w-4"})})]}):t.jsx("button",{type:"button",onClick:()=>{g(i.content),f(!0),v(null)},className:"thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition",title:"Edit file","aria-label":"Edit file",children:t.jsx(B.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:D=>g(D.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(Ar,{content:i.content}),i.truncated&&s?t.jsx("div",{className:"thread-graph-file-preview-footer flex justify-center border-t px-4 py-3",children:t.jsx("button",{type:"button",onClick:s,disabled:n,title:"Load more workspace preview","aria-label":"Load more workspace preview",className:"thread-graph-load-more-button rounded-md px-4 py-1.5 text-xs disabled:opacity-50",children:n?"Loading...":`Load more (${(i.size-i.nextOffset).toLocaleString()} bytes remaining)`})}):null]}):(u.kind==="live-molecule"||u.kind==="artifact")&&u.node.artifact?t.jsx("div",{className:J||F?"min-h-0 flex-1 overflow-hidden":"min-h-0 flex-1 overflow-auto p-3",children:C}):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(Jt,{label:"Workspace Data",children:t.jsx(Ar,{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(Ar,{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 Ao,_o,Ar,Th=$e({"src/components/graph-workspace/GraphWorkspacePreviewPane.tsx"(){ea(),Po(),yh(),Ao=50*1024,_o=1e3,Ar=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 Eh({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 Lh=$e({"src/components/graph-workspace/GraphEmptyGarbageDialog.tsx"(){}});function Mo(e){return`${Do}${e.workspaceId??"workspace"}:${e.threadId}`}function Ph(e){if(typeof window>"u")return[];try{const r=window.localStorage.getItem(Mo(e));if(!r)return[];const n=JSON.parse(r);return Array.isArray(n)?n.filter(a=>typeof a=="string"):[]}catch{return[]}}function Oa(e,r){if(!(typeof window>"u"))try{window.localStorage.setItem(Mo(e),JSON.stringify([...r]))}catch{}}function An(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=>An(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 Ua(e,r){if(e.kind==="directory")return r?t.jsx(B.FolderOpen,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"}):t.jsx(B.Folder,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"});const n=jr(e.name);return n==="zip"?t.jsx(B.FileArchive,{className:"h-4 w-4 text-amber-600"}):e.kind==="file"&&["png","jpg","jpeg","gif","webp","svg"].includes(n)?t.jsx(B.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(B.FileCode2,{className:"h-4 w-4 text-emerald-600"}):t.jsx(B.File,{className:"h-4 w-4 text-slate-400 dark:text-slate-500"})}function $o({depth:e,expandedPaths:r,loadingPaths:n,node:a,onDownload:s,onPreview:o,onSelect:l,onToggle:i,selectedNodeId:d}){const h=a.kind==="directory",u=h&&(a.path===""||r.has(a.path)),m=h&&n.has(a.path),f=d===a.id,p=`${e*.75+.5}rem`;return h?t.jsxs("div",{children:[t.jsxs("div",{className:"thread-graph-tree-row group flex items-center text-sm text-slate-600 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100",children:[t.jsxs("button",{type:"button",onClick:()=>i(a.path),className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 px-2 py-2 text-left sm:min-h-0 sm:py-1.5",style:{paddingLeft:p},children:[u?t.jsx(B.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}):t.jsx(B.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}),Ua(a,u),t.jsx("span",{className:"truncate",children:a.name}),m?t.jsx("span",{className:"ml-auto shrink-0 text-xs text-slate-400 dark:text-slate-500",children:"Loading"}):null]}),s?t.jsx("button",{type:"button",onClick:()=>s(a),className:"thread-graph-tree-action mr-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-slate-400 transition hover:bg-white hover:text-slate-900 sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100",title:a.path?`Download ${a.name}`:"Download workspace","aria-label":a.path?`Download ${a.name}`:"Download workspace",children:t.jsx(B.Download,{className:"h-3.5 w-3.5"})}):null]}),u?t.jsxs("div",{children:[a.children.map(g=>t.jsx($o,{depth:e+1,expandedPaths:r,loadingPaths:n,node:g,...s?{onDownload:s}:{},...o?{onPreview:o}:{},onSelect:l,onToggle:i,selectedNodeId:d},g.id)),a.truncated?t.jsx("div",{className:"px-2 py-1 text-xs text-slate-400 dark:text-slate-500",style:{paddingLeft:`${(e+1)*.75+.5}rem`},children:"More items not shown"}):null]}):null]}):t.jsxs("div",{className:`thread-graph-tree-row group flex items-center text-sm transition ${f?"is-selected":"text-slate-600 hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100"}`,children:[t.jsxs("button",{type:"button",onClick:()=>l(a.id),className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 px-2 py-2 text-left sm:min-h-0 sm:py-1.5",style:{paddingLeft:`${e*.75+2.2}rem`},children:[Ua(a,!1),t.jsx("span",{className:"truncate",children:a.name})]}),a.kind==="file"&&(o||s)?t.jsxs("div",{className:"mr-1 flex shrink-0 items-center gap-0.5",children:[o?t.jsx("button",{type:"button",onClick:()=>o(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${f?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Preview ${a.name}`,"aria-label":`Preview ${a.name}`,children:t.jsx(B.Eye,{className:"h-3.5 w-3.5"})}):null,s?t.jsx("button",{type:"button",onClick:()=>s(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${f?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Download ${a.name}`,"aria-label":`Download ${a.name}`,children:t.jsx(B.Download,{className:"h-3.5 w-3.5"})}):null]}):null]})}function zh({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(B.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 Ih({canEmptyGarbage:e,canUpload:r,onCollapse:n,expandedPaths:a,loadingPaths:s,loading:o,onDownload:l,onEmptyGarbage:i,onPreview:d,onRefresh:h,onSelect:u,onToggle:m,onUpload:f,explorerScrollTopRef:p,explorerScrollerRef:g,selectedNodeId:b,tree:v,liveNodes:x}){const y=c.useMemo(()=>({...v,children:v.children.filter(k=>k.path!=="live")}),[v]);return c.useLayoutEffect(()=>{const k=g.current;k&&(k.scrollTop=p.current)},[g,p]),t.jsxs("aside",{className:`${Bo} flex flex-col`,children:[t.jsxs("div",{className:Go,children:[t.jsx("div",{className:"min-w-0",children:t.jsx("h2",{className:Fo,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:Ho,title:"Collapse Explorer","aria-label":"Collapse Explorer",children:[t.jsx(B.ChevronsLeft,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Collapse Explorer"})]}):null,t.jsx("button",{type:"button",onClick:f,disabled:!r,className:Mr,title:r?"Upload file":"Upload is unavailable for this workspace","aria-label":"Upload file",children:t.jsx(B.Upload,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:h,className:Mr,title:"Refresh workspace","aria-label":"Refresh workspace",children:t.jsx(B.RefreshCw,{className:`h-4 w-4 ${o?"animate-spin":""}`})}),i?t.jsx("button",{type:"button",onClick:i,disabled:!e,className:Mr,title:e?"Empty garbage":"Garbage controls are unavailable","aria-label":"Empty garbage",children:t.jsx(B.Trash2,{className:"h-4 w-4"})}):null]})]}),t.jsxs("div",{ref:g,className:"thread-graph-workspace-tree-scroll min-h-0 flex-1 overflow-y-auto py-2",onScroll:k=>{p.current=k.currentTarget.scrollTop},children:[t.jsx(zh,{liveNodes:x??[],onSelect:u,selectedNodeId:b}),t.jsx("div",{className:Oo,children:"Workspace"}),t.jsx($o,{depth:0,expandedPaths:a,loadingPaths:s,node:y,...l?{onDownload:l}:{},...d?{onPreview:d}:{},onSelect:u,onToggle:m,selectedNodeId:b}),y.children.length===0?t.jsx("p",{className:Uo,children:"This workspace is empty. Agent tool runs execute inside the thread workspace, so files should appear here as the session works."}):null]})]})}function Rh({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:Da(r,n),[e,i,n,r,s,l]),u=i??h??Da(r,n),m=c.useMemo(()=>Jc(u),[u]),f=c.useMemo(()=>{var A;return((A=u.children.find($=>$.path==="live"))==null?void 0:A.children)??[]},[u]),p=To(u),[g,b]=c.useState(()=>(p==null?void 0:p.id)??null),[v,x]=c.useState(()=>new Set(["","artifacts","thread-events","live",...Ba((p==null?void 0:p.path)??"")])),[y,k]=c.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 639px)").matches?"viewer":null),[C,w]=c.useState(null),[j,S]=c.useState(!1),[L,P]=c.useState(()=>new Set),[K,F]=c.useState(!1),[R,J]=c.useState(!1),[Z,D]=c.useState(!1),[te,oe]=c.useState([]),[_,Y]=c.useState(null),[I,q]=c.useState(null),[H,E]=c.useState(null),[W,O]=c.useState(!1),N=c.useRef(null),T=c.useRef(null),U=c.useRef(0),X=c.useRef(null),ie=!!l,Q=(g?m.get(g):null)??p??null,de={threadId:r.thread.id,workspaceId:r.workspace.id??r.thread.workspaceId??null};c.useEffect(()=>{U.current=0,X.current=null,x(new Set(["","artifacts","thread-events","live",...Ph(de),...Ba((p==null?void 0:p.path)??"")]))},[de.threadId,de.workspaceId]);function re(){var $;const A=(($=T.current)==null?void 0:$.scrollTop)??U.current;U.current=A,X.current=A}function xe(){const A=X.current??U.current;if(!T.current)return;let ee=0;const pe=()=>{const ke=T.current;ke&&(ke.scrollTop=Math.min(A,Math.max(0,ke.scrollHeight-ke.clientHeight)),U.current=ke.scrollTop,ee+=1,ee<8?window.requestAnimationFrame(pe):X.current=null)};window.requestAnimationFrame(pe)}c.useLayoutEffect(()=>{y!=="explorer"&&xe()},[y,u]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const A=window.matchMedia("(max-width: 639px)"),$=()=>O(A.matches);return $(),typeof A.addEventListener=="function"?(A.addEventListener("change",$),()=>A.removeEventListener("change",$)):(A.addListener($),()=>A.removeListener($))},[]);async function le(A){if(!l)return;const $=A??(Q==null?void 0:Q.path)??null;S(!0),w(null);try{const ee=Zt(await l.listTree({...de,path:""}));let pe=i?An(ee,i):ee;if(i){const Ae=[...v].filter(Ne=>Ne).sort((Ne,De)=>Ne.split("/").length-De.split("/").length);for(const Ne of Ae){const De=Pn(i,Ne);if((De==null?void 0:De.kind)!=="directory"||!De.childrenLoaded)continue;const et=Zt(await l.listTree({...de,path:Ne}));pe=zn(pe,Ne,An(et,De))}}d(pe);const ke=No(pe);b(Ae=>{var De;const Ne=$??(Ae?(De=m.get(Ae))==null?void 0:De.path:null);return Ne&&In(pe,Ne)?`workspace:${Ne}`:(ke==null?void 0:ke.id)??Ae})}catch(ee){w(ee instanceof Error?ee.message:"Failed to load workspace"),d(null)}finally{S(!1)}}async function ve(A){if(!(!l||!i)){P($=>{if($.has(A))return $;const ee=new Set($);return ee.add(A),ee}),w(null);try{const $=Zt(await l.listTree({...de,path:A}));d(ee=>ee&&jo(ee,A,$.children,{truncated:$.truncated}))}catch($){w($ instanceof Error?$.message:"Failed to load directory")}finally{P($=>{if(!$.has(A))return $;const ee=new Set($);return ee.delete(A),ee})}}}async function Pe(A){const $=Co(A);if(!$)return;const ee=Vc($);if(k(null),x(pe=>{const ke=new Set(pe);ke.add("");for(const Ae of ee)ke.add(Ae);return Oa(de,ke),ke}),!l){In(u,$)&&b(`workspace:${$}`);return}S(!0),w(null);try{let pe=i??Zt(await l.listTree({...de,path:""}));for(const ke of ee){const Ae=Pn(pe,ke);if((Ae==null?void 0:Ae.kind)==="directory"&&Ae.childrenLoaded)continue;const Ne=Zt(await l.listTree({...de,path:ke}));pe=zn(pe,ke,Ne)}d(pe),b(`workspace:${$}`)}catch(pe){w(pe instanceof Error?pe.message:`Failed to open ${$}`)}finally{S(!1)}}c.useEffect(()=>{if(!(!l||!i))for(const A of m.values())A.path&&A.kind==="directory"&&v.has(A.path)&&A.hasChildren&&!A.childrenLoaded&&!L.has(A.path)&&ve(A.path)},[i,v,m,l]),c.useEffect(()=>{d(null),P(new Set),Y(null),q(null),E(null),w(null),le()},[ie,r.thread.id,r.workspace.id,r.thread.workspaceId]),c.useEffect(()=>{o&&Pe(o.path)},[o==null?void 0:o.requestId]),c.useEffect(()=>{l!=null&&l.subscribeWorkspaceChanged},[l,de.threadId,de.workspaceId]),c.useEffect(()=>{const A=l&&(Q==null?void 0:Q.kind)==="file"?Q.path:null;if(!A){Y(null),q(null),E(null);return}const $=A;let ee=!1;async function pe(){var ke;if(l){F(!0),w(null),Y(null),q(null),E(null);try{const Ae=jr($),Ne=(ke=l.getRawFileUrl)==null?void 0:ke.call(l,{...de,path:$});if(Ne&&Eo.has(Ae)){ee||q(Ne);return}if(Ne&&Lo.has(Ae)){ee||E(Ne);return}const De=await l.readFile({...de,path:$,limit:_r});ee||Y(De)}catch(Ae){ee||w(Ae instanceof Error?Ae.message:"Failed to read file")}finally{ee||F(!1)}}}return pe(),()=>{ee=!0}},[l,Q==null?void 0:Q.id]);async function se(){if(!(!l||!(_!=null&&_.truncated))){J(!0);try{const A=await l.readFile({...de,path:_.path,offset:_.nextOffset,limit:_r});Y($=>$&&{...$,content:$.content+A.content,truncated:A.truncated,nextOffset:A.nextOffset,size:A.size})}finally{J(!1)}}}async function ye(A){if(!(l!=null&&l.writeFile))return;w(null),await l.writeFile({...de,path:A.path,content:A.content}),await le(A.path);const $=await l.readFile({...de,path:A.path,limit:_r});Y($)}async function je(A){if(!(!(l!=null&&l.uploadFile)||!A)){S(!0),w(null);try{const $=await l.uploadFile({...de,path:A.name,file:A}),ee=$.kind==="archive"?$.paths[0]??null:$.file.path;await le(ee)}catch($){w($ instanceof Error?$.message:"Failed to upload file")}finally{S(!1)}}}async function G(A){var ee;const $=(ee=A.target.files)==null?void 0:ee[0];A.target.value="",$&&await je($)}function me(){if(!(l!=null&&l.uploadFile))return;const A=()=>{var $;return($=N.current)==null?void 0:$.click()};if(l.pickUploadFile){l.pickUploadFile({...de,defaultPick:A,upload:je});return}A()}function ge(A){var $;($=l==null?void 0:l.downloadNode)==null||$.call(l,{...de,path:A.path,kind:A.kind==="directory"?"directory":"file"})}function we(A){A.kind==="file"&&(re(),b(A.id),k("explorer"))}async function _e(){if(l!=null&&l.emptyGarbage){if(w(null),!l.listGarbage){oe([]),D(!0);return}try{const A=await l.listGarbage(de);oe(A.map($=>`garbage/${$}`))}catch(A){oe([]),w(A instanceof Error?A.message:"Failed to list garbage files")}finally{D(!0)}}}async function Re(){if(l!=null&&l.emptyGarbage){D(!1),w(null);try{await l.emptyGarbage(de),await le((Q==null?void 0:Q.path)??null)}catch(A){w(A instanceof Error?A.message:"Failed to empty garbage")}}}const Ee={...l!=null&&l.downloadNode?{onDownload:ge}:{},...l!=null&&l.emptyGarbage?{onEmptyGarbage:_e}:{},...l?{onRefresh:()=>void le((Q==null?void 0:Q.path)??null)}:{},...l!=null&&l.uploadFile?{onUpload:me}:{}};function Me(A){if(!A)return;const $=m.get(`workspace:${A}`),ee=($==null?void 0:$.kind)==="directory"&&$.hasChildren&&!$.childrenLoaded&&!L.has(A);x(pe=>{const ke=new Set(pe);return ke.has(A)?ke.delete(A):ke.add(A),Oa(de,ke),ke}),!v.has(A)&&ee&&ve(A)}const M=t.jsx(Ih,{canEmptyGarbage:!!(l!=null&&l.emptyGarbage),canUpload:!!(l!=null&&l.uploadFile),onCollapse:()=>{re(),k("explorer")},expandedPaths:v,loadingPaths:L,loading:j,explorerScrollTopRef:U,explorerScrollerRef:T,...Ee,onPreview:we,onSelect:A=>{b(A)},onToggle:Me,selectedNodeId:(Q==null?void 0:Q.id)??null,tree:u,liveNodes:f}),ue=t.jsx(Sh,{error:C,imageUrl:I,loadingMore:R,onLoadMore:se,...l!=null&&l.writeFile?{onSaveFile:ye}:{},onCollapse:()=>{re(),k("viewer")},pdfUrl:H,previewFile:_,previewLoading:K,plugins:a,selectedTarget:Ch(Q)});return y==="explorer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:ue}):y==="viewer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:M}):t.jsxs("div",{"data-testid":"workspace-panel",className:"flex h-full min-h-0 w-full overflow-hidden bg-transparent p-2",children:[Z?t.jsx(Eh,{files:te,onCancel:()=>D(!1),onConfirm:()=>void Re()}):null,W?t.jsxs(En,{direction:"vertical",className:"thread-graph-workspace-mobile-stack",children:[t.jsx(er,{defaultSize:42,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-explorer h-full min-h-0 overflow-hidden",children:M})}),t.jsx(Ln,{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(er,{defaultSize:58,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-viewer h-full min-h-0 overflow-hidden",children:ue})})]}):t.jsxs(En,{direction:"horizontal",className:"thread-graph-workspace-resizable",children:[t.jsx(er,{defaultSize:33,minSize:20,children:t.jsx("div",{className:"thread-graph-workspace-explorer-pane h-full min-h-0 overflow-hidden",children:M})}),t.jsx(Ln,{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(er,{defaultSize:67,minSize:30,children:t.jsx("div",{className:"thread-graph-workspace-viewer-pane h-full min-h-0 overflow-hidden",children:ue})})]}),t.jsx("input",{ref:N,type:"file","aria-label":"Workspace upload file input","data-testid":"workspace-upload-file-input",className:"hidden",onChange:A=>void G(A)})]})}var _r,Do,Bo,Go,Fo,Mr,Ho,Oo,Uo,Ah=$e({"src/components/graph-workspace/GraphWorkspaceExplorer.tsx"(){ea(),Th(),Lh(),yo(),_r=24e3,Do="remote-codex:graphchat:workspace:expanded:",Bo="thread-graph-explorer h-full min-h-0 overflow-hidden rounded-[12px]",Go="thread-graph-explorer-header flex h-[60px] shrink-0 items-center justify-between border-b px-4",Fo="text-[18px] font-semibold text-slate-900 dark:text-slate-100",Mr="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",Ho="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",Oo="thread-graph-workspace-label px-3 pb-1 pt-2 text-[11px] font-semibold tracking-normal text-slate-500 dark:text-slate-400",Uo="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 pn({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 Xt({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 _h({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 lr({value:e,title:r,icon:n,children:a}){return t.jsxs(kr,{value:e,className:"thread-guide-section border-b border-[var(--theme-border)] last:border-b-0",children:[t.jsx(Yr,{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(_h,{children:n}),r]})}),t.jsx(wr,{className:"space-y-3 pb-3",children:a})]})}function Mh(){return t.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[t.jsxs("div",{className:"shrink-0 border-b border-[var(--theme-border)] px-4 py-3",children:[t.jsx("h2",{className:"text-xs font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"What can I do?"}),t.jsx("p",{className:"mt-0.5 text-[11px] text-[var(--theme-fg-muted)]",children:"Upload files, ask in plain language, get results."})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-3 pb-6",children:t.jsxs(vr,{type:"multiple",defaultValue:["start","workspace","remote-codex"],className:"space-y-0",children:[t.jsxs(lr,{value:"start",title:"Getting Started",icon:t.jsx(B.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(Xt,{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(lr,{value:"workspace",title:"Workspace Explorer",icon:t.jsx(B.FolderOpen,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(B.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(B.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(B.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(B.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(B.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(Xt,{items:[t.jsxs(t.Fragment,{children:[t.jsx(pn,{children:".xyz .extxyz .cif"})," use the 3D molecule plugin."]}),t.jsxs(t.Fragment,{children:[t.jsx(pn,{children:".png .jpg .gif .svg .webp"})," use inline image preview."]}),t.jsxs(t.Fragment,{children:[t.jsx(pn,{children:".py .json .ts .md .csv"})," use text/code preview."]}),"Large files load in chunks when the workspace adapter supports it."]})]})]}),t.jsxs(lr,{value:"viewer",title:"Viewer",icon:t.jsx(B.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(Xt,{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(lr,{value:"usage",title:"Tool Usage & Chat",icon:t.jsx(B.BarChart2,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(B.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(Xt,{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(B.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(Xt,{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(lr,{value:"remote-codex",title:"Remote Codex Extras",icon:t.jsx(B.Code2,{className:"h-3 w-3"}),children:t.jsx(Xt,{items:["Slash toolbox: skills, MCP, hooks, goals, forks, model controls, provider settings","Rich message bubbles: reasoning, commands, searches, file reads, file changes, plans, action requests, artifacts","Plugin surfaces: terminal, XYZ molecule viewer, inline code renderers, and imported plugin panels","Thread metadata stays in the left rail and Workspace tab instead of replacing chat"]})})]})})]})}var $h=$e({"src/components/graph-workspace/GraphGuidePanel.tsx"(){yr()}});function Dh(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 Wa({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:Dh(r)})]})}function Bh({event:e}){return t.jsxs(kr,{value:e.id,className:"thread-tool-call mb-2 overflow-hidden rounded-lg border border-[var(--theme-border)] last:mb-0",children:[t.jsxs(Yr,{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(wr,{className:"px-3 pb-3",children:t.jsxs("div",{className:"space-y-2 px-3 pb-3 pt-1",children:[t.jsx(Wa,{label:"Input",value:e.preview}),t.jsx(Wa,{label:"Output",value:e.detail})]})})]})}function Gh({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(B.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(vr,{type:"single",collapsible:!0,value:s??"",onValueChange:i=>o(i||null),className:"space-y-0",children:n.slice(-50).map(i=>t.jsx(Bh,{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(B.RefreshCw,{className:"h-3 w-3"}),"Reload from workspace"]})]})}var Fh=$e({"src/components/graph-workspace/GraphToolUsagePanel.tsx"(){yr()}});function Va(e,r){const n=Math.max(e.measured.width??1,1),a=Math.max(e.measured.height??1,1),s=e.internals.positionAbsolute,o=r.internals.positionAbsolute,l=Math.max(r.measured.width??1,1),i=Math.max(r.measured.height??1,1),d=n/2,h=a/2,u=s.x+d,m=s.y+h,f=o.x+l/2,p=o.y+i/2,g=(f-u)/(2*d)-(p-m)/(2*h),b=(f-u)/(2*d)+(p-m)/(2*h),v=1/(Math.abs(g)+Math.abs(b)),x=v*g,y=v*b,k=d*(x+y)+u,C=h*(-x+y)+m;return{x:k,y:C}}function Ka(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?Mt.Left:o>=a+(e.measured.width??1)-1?Mt.Right:l<=s+1?Mt.Top:l>=n.y+(e.measured.height??1)-1?Mt.Bottom:Mt.Top}function Wo(e,r){const n=Va(e,r),a=Va(r,e),s=Ka(e,n),o=Ka(r,a);return{sx:n.x,sy:n.y,tx:a.x,ty:a.y,sourcePos:s,targetPos:o}}function Hh(e,r=900,n=620){if(!e||!Array.isArray(e))return{nodes:[],edges:[]};const a=(d,h,u,m)=>{const f=new Map,p=d.length;d.forEach((g,b)=>{const v=g.id.split("").reduce((x,y)=>{const k=(x<<5)-x+y.charCodeAt(0);return k&k},0);f.set(g.id,{x:Math.abs(v)%u+b*100%u,y:Math.abs(v>>16)%m+b*150%m,vx:0,vy:0})});for(let g=0;g<200;g+=1){for(let b=0;b<p;b+=1)for(let v=b+1;v<p;v+=1){const x=d[b],y=d[v];if(!x||!y)continue;const k=f.get(x.id),C=f.get(y.id);if(!k||!C)continue;const w=k.x-C.x,j=k.y-C.y,S=Math.sqrt(w*w+j*j)||1,P=(200-S)*.5,K=w/S*P,F=j/S*P;k.vx+=K,k.vy+=F,C.vx-=K,C.vy-=F}h.forEach(b=>{const v=f.get(b.source),x=f.get(b.target);if(!v||!x)return;const y=x.x-v.x,k=x.y-v.y,C=Math.sqrt(y*y+k*k)||1,j=(C-120)*.3,S=y/C*j,L=k/C*j;v.vx+=S,v.vy+=L,x.vx-=S,x.vy-=L}),f.forEach(b=>{b.x+=b.vx*.1,b.y+=b.vy*.1,b.vx*=.9,b.vy*=.9,b.x=Math.max(80,Math.min(u-80,b.x)),b.y=Math.max(80,Math.min(m-80,b.y))})}return f},s=new Set(e.map(d=>d.id)),o=[];e.forEach(d=>{if(!d.out_node_id)return;(Array.isArray(d.out_node_id)?d.out_node_id:[d.out_node_id]).forEach(u=>{s.has(u)&&o.push({id:`${d.id}-${u}`,source:d.id,target:u,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:As.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 ta=$e({"src/components/graph-chat/FloatingHelper.tsx"(){}});function Oh({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}=Wo(s,o),[f]=_s({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 Uh=$e({"src/components/graph-chat/FloatingConnectionLine.tsx"(){ta()}});function Wh({id:e,source:r,target:n,markerEnd:a,style:s}){const o=ka(r),l=ka(n);if(!o||!l)return null;const{sx:i,sy:d,tx:h,ty:u,sourcePos:m,targetPos:f}=Wo(o,l),[p]=_s({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 Vh=$e({"src/components/graph-chat/FloatingEdge.tsx"(){ta()}});function Kh({nodes:e}){const[r,n,a]=id([]),[s,o,l]=dd([]),i=c.useMemo(()=>Hh(e),[e]),d=c.useMemo(()=>({floating:Wh}),[]),h=c.useMemo(()=>({styledNode:({data:m,isConnectable:f})=>t.jsxs("div",{className:"thread-graph-flow-node",children:[m.label,t.jsx(va,{type:"target",position:Mt.Top,isConnectable:f,style:{opacity:0,pointerEvents:"none"}}),t.jsx(va,{type:"source",position:Mt.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=>cd({...m,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:As.Arrow}},f)),[o]);return t.jsx("div",{className:"thread-graph-flow h-full min-h-0",children:t.jsx(hd,{children:t.jsxs(ud,{nodes:r,edges:s,onNodesChange:a,onEdgesChange:l,onConnect:u,fitView:!0,nodeTypes:h,edgeTypes:d,connectionLineComponent:Oh,children:[t.jsx(md,{}),t.jsx(pd,{gap:16})]})})})}var qh=$e({"src/components/graph-chat/GraphVisualization.tsx"(){Uh(),Vh(),ta()}});function Xh(e){return{...Ko,...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 Yh(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 Zh(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:Gr(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:Gr(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 Gr(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 Jh(e){switch(e.kind){case"userMessage":return"User";case"agentMessage":return"Agent";default:return Gr(e.kind)}}function Qh(e){return(e.previewText??e.text??e.detailText??e.kind).replace(/\s+/g," ").slice(0,96)}function eu(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:Jh(d),description:Qh(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 Vo({detail:e,status:r,plugins:n,workspaceAdapter:a,metaContent:s,settingsContent:o,activeView:l="chat",features:i,focusPathRequest:d=null}){const h=c.useMemo(()=>Xh(i),[i]),u=qa(h,i==null?void 0:i.defaultTab),[m,f]=c.useState(u),p=c.useMemo(()=>Oc(e),[e]),g=c.useMemo(()=>Zh(e),[e]),b=c.useMemo(()=>{const w=new Map;for(const j of g)w.set(j.kind,(w.get(j.kind)??0)+1);return[...w.entries()].sort((j,S)=>S[1]-j[1])},[g]),v=n.getThreadPanels(),x=Math.max(...b.map(([,w])=>w),1),y=c.useMemo(()=>eu(e,g),[e,g]),k=c.useMemo(()=>{const w=[];return h.workspace&&w.push({id:"workspace",label:"Workspace",icon:null}),h.toolUsage&&w.push({id:"tools",label:"Tool Usage",icon:B.BarChart2}),h.guide&&w.push({id:"guide",label:"Guide",icon:B.BookOpen}),w},[h.guide,h.toolUsage,h.workspace]),C=c.useMemo(()=>{const w=[];return h.threadGraph&&w.push({id:"graph",label:"Thread graph",icon:B.GitBranch}),h.extensions&&w.push({id:"extensions",label:"Remote Codex extensions",icon:B.Wrench}),w},[h.extensions,h.threadGraph]);return c.useEffect(()=>{(!m||!Yh(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:[k.map(w=>{const j=w.icon;return t.jsxs("button",{type:"button",onClick:()=>f(w.id),className:`thread-graph-right-tab inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md px-3 text-xs font-medium transition ${m===w.id?"is-active":""}`,children:[j?t.jsx(j,{className:"h-3.5 w-3.5"}):null,w.label]},w.id)}),C.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:C.map(w=>{const j=w.icon;return t.jsx("button",{type:"button",onClick:()=>f(w.id),className:`thread-graph-right-tab inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-xs font-medium transition ${m===w.id?"is-active":""}`,title:w.label,"aria-label":w.label,children:t.jsx(j,{className:"h-3.5 w-3.5"})},w.id)})}):null]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[m==="workspace"?t.jsx(Rh,{activeView:l,detail:e,artifacts:p,plugins:n,status:r,focusPathRequest:d,workspaceAdapter:a??null}):null,m==="tools"?t.jsx(Gh,{formatToolKind:Gr,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(Kh,{nodes:y})}):null,m==="extensions"?t.jsx("div",{className:"h-full min-h-0 overflow-y-auto p-3",children:t.jsxs("div",{className:"grid gap-3",children:[t.jsx(Jt,{label:"Plugin Panels",children:v.length?t.jsx("div",{className:"flex flex-wrap gap-2",children:v.map(w=>t.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-1 text-xs text-[var(--theme-fg-soft)]",children:w.label},w.id))}):t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"No thread panels are enabled."})}),t.jsx(Jt,{label:"Enabled Renderers",children:t.jsx("div",{className:"flex flex-wrap gap-2",children:n.plugins.filter(w=>w.enabled).map(w=>t.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-1 text-xs text-[var(--theme-fg-soft)]",children:w.name},w.id))})}),t.jsx(Jt,{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(B.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(B.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(B.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(Jt,{label:"Thread Meta",children:s}):null,o?t.jsx(Jt,{label:"Settings",children:o}):null]})}):null,m==="guide"?t.jsx(Mh,{}):null]})]}):null}var Ko,qo,tu=$e({"src/components/ThreadGraphWorkspacePanel.tsx"(){Ah(),Po(),$h(),Fh(),ea(),qh(),Ko={workspace:!0,toolUsage:!0,guide:!0,threadGraph:!0,extensions:!0},qo=c.memo(Vo)}}),Xo={};Hc(Xo,{MemoizedThreadGraphWorkspacePanel:()=>qo,ThreadGraphWorkspacePanel:()=>Vo});var ru=$e({"src/workspace-panel.ts"(){tu()}});function nr(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))}nr(`.thread-ui-shell,
10
+ `).join("")}function vh(e){if(!e)return{format:"xyz",frames:[],exportContent:""};if(typeof e=="string"){const o=Fa([e],"xyz");return{frames:o,format:"xyz",exportContent:Ha(o)}}const r=xh(e.format),n=e.content.filter(o=>o.trim().length>0);return{frames:Fa(n,r),format:r,exportContent:Ha(n)}}var kh=$e({"src/components/graph-workspace/GraphMoleculeViewerData.ts"(){}});function wh({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,y]=c.useState(!1),[k,j]=c.useState({}),[v,N]=c.useState([]),[S,L]=c.useState({}),[P,K]=c.useState(!1),[F,D]=c.useState(!1),[Z,Y]=c.useState(null),$=c.useMemo(()=>vh(o),[o]),te=$.frames,oe=$.format,A=te[p]??null,J=te.length>0&&p===te.length-1,I=r??"current",q=Object.values(S).reduce((C,E)=>C+E.length,0),O=Object.keys(S).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 C=window.setInterval(()=>{g(E=>E>=te.length-1?(window.clearInterval(C),y(!1),E):E+1)},200);return()=>window.clearInterval(C)},[x,te.length]),c.useEffect(()=>{const C=l.current;if(!C||i.current)return;let E=!1;try{const W=document.createElement("canvas");if(!(W.getContext("webgl2")||W.getContext("webgl")||W.getContext("experimental-webgl"))){Y("WebGL is unavailable in this browser environment. Unable to render 3D viewer.");return}}catch{Y("WebGL is unavailable in this browser environment. Unable to render 3D viewer.");return}const X=()=>{var W,le;(W=i.current)==null||W.resize(),(le=i.current)==null||le.render()};return mh().then(W=>{if(!(E||i.current))try{const le=W.createViewer(C,{});i.current=le,le.setBackgroundColor("#f8fafc",.8),window.addEventListener("resize",X),window.setTimeout(X,100)}catch(le){console.error("Failed to initialize 3Dmol viewer:",le),Y("Failed to initialize 3D viewer. Please refresh or try another browser.")}}).catch(W=>{console.error("Failed to load 3Dmol viewer runtime:",W),Y("Failed to load 3D viewer runtime. Please refresh or try another browser.")}),()=>{E=!0,window.removeEventListener("resize",X),i.current=null,d.current=null}},[]),c.useEffect(()=>{const C=i.current;if(!(!C||!A))try{C.removeAllModels(),C.removeAllShapes(),C.removeAllLabels();const E=C.addModel(A,oe||"xyz");d.current=E,E.setStyle({},{stick:{radius:.2},sphere:{scale:.3}});const X=E.getCrystData(),W=!!(X&&typeof X=="object"&&Object.keys(X).length);K(W),D(W?u.current:!1),N([]),j({});const le=A.split(`
11
+ `).slice(2).map(Q=>Q.trim()).filter(Boolean).map(Q=>Q.split(/\s+/)[0]??"Atom");h.current||(C.zoomTo(),h.current=!0),E.setClickable({},!0,(Q,de,re)=>{const xe=Q.serial??Q.index;if(xe===void 0)return;const ie=Q.atom||Q.elem||le[xe]||"Atom";N(ve=>{const se=!!(re!=null&&re.shiftKey||re!=null&&re.metaKey||re!=null&&re.ctrlKey)?ve.includes(xe)?ve.filter(ye=>ye!==xe):[...ve,xe]:ve.length===1&&ve[0]===xe?[]:[xe];return j(ye=>{if(se.length===0)return{};const je={};return se.forEach(G=>{je[G]=ye[G]||le[G]||ie}),je}),se})}),E.setHoverable({},!0,(Q,de,re)=>{!re||!Q||w({x:re.clientX,y:re.clientY,label:`${Q.atom||Q.elem||"Atom"} (${Q.serial??Q.index??"?"})`,coords:{x:Q.x.toFixed(2),y:Q.y.toFixed(2),z:Q.z.toFixed(2)}})},()=>w(null)),C.render()}catch(E){console.error("Failed to render molecule:",E),Y("Unable to render this molecular structure.")}},[A,oe]),c.useEffect(()=>{const C=i.current,E=d.current;if(!(!C||!E)){try{C.removeUnitCell(E)}catch{}if(F&&P)try{C.addUnitCell(E,{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{K(!1),D(!1)}C.render()}},[P,F,A,oe]),c.useEffect(()=>{const C=i.current,E=d.current;!C||!E||!A||(E.setStyle({},{stick:{radius:.2},sphere:{scale:.3}}),v.length>0&&E.setStyle({serial:v},{stick:{radius:.3,color:"yellow"},sphere:{scale:.4,color:"yellow"}}),C.render(),a==null||a({moleculeId:r,atoms:v}))},[r,a,v,A]),c.useEffect(()=>{if(!A)return;let C=0;const E=()=>{var W,le;const X=(le=(W=i.current)==null?void 0:W.getView)==null?void 0:le.call(W);if(Array.isArray(X)&&X.length>=8){const[Q,de,re,xe,ie,ve,Pe,se]=X;if(typeof Q=="number"&&typeof de=="number"&&typeof re=="number"&&typeof xe=="number"&&typeof ie=="number"&&typeof ve=="number"&&typeof Pe=="number"&&typeof se=="number"){const ye=Math.sqrt(ie*ie+ve*ve+Pe*Pe),je=ye>0?{x:ie/ye,y:ve/ye,z:Pe/ye}:{x:0,y:0,z:0};f({position:{x:Q,y:de,z:re,qx:ie,qy:ve,qz:Pe,qw:se},lookAt:je,zoom:xe})}}C=window.requestAnimationFrame(E)};return C=window.requestAnimationFrame(E),()=>window.cancelAnimationFrame(C)},[A]);const T=c.useCallback(async()=>{const C=i.current;if(!(C!=null&&C.pngURI))return;C.render();const E=C.pngURI();if(E){try{const W=await(await fetch(E)).blob(),le=new ClipboardItem({[W.type||"image/png"]:W});await navigator.clipboard.write([le])}catch{}n==null||n({moleculeId:r,image:E})}},[r,n]);function U(){P&&D(C=>{const E=!C;return u.current=E,E})}function H(){v.length!==0&&L(C=>{const E=C[I]??[];return{...C,[I]:Array.from(new Set([...E,...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: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&&!A?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(hh,{currentIndex:p,exportContent:$.exportContent,moleculeId:r,onScreenshot:()=>void T(),viewerRef:i,xyzContent:A,xyzFormat:oe})]}),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(br,{type:"button",variant:"ghost",size:"icon",className:"thread-graph-molecule-button h-5 w-5",onClick:()=>{y(C=>{const E=!C;return E&&p===te.length-1&&g(0),E})},"aria-label":x?"Pause trajectory":"Play trajectory",title:x?"Pause trajectory":"Play trajectory",children:x&&p!==te.length-1?t.jsx(B.Pause,{className:"h-3 w-3"}):t.jsx(B.Play,{className:"h-3 w-3"})})]}),t.jsxs(br,{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 ${J?"animate-pulse bg-red-600":"bg-gray-300"}`}),"Live"]})]}),t.jsx(fh,{value:[p],max:te.length-1,step:1,onValueChange:C=>g(C[0]??0),"aria-label":"Trajectory frame"})]}):null,t.jsx(dh,{cameraInfo:m,onClearSelection:()=>N([]),onClearStaged:()=>L({}),onSendSelection:()=>a==null?void 0:a({moleculeId:r,atoms:v}),onSendStaged:()=>{Object.entries(S).forEach(([C,E])=>{a==null||a({moleculeId:C==="current"?r:C,atoms:E})})},onStageSelection:H,onToggleUnitCell:U,selectedAtomLabels:k,selectedSerials:v,stagedAtoms:q,stagedMolecules:O,unitCellAvailable:P,unitCellVisible:F})]})]})]})}var yh=$e({"src/components/graph-workspace/GraphMoleculeViewer.tsx"(){ch(),uh(),ph(),Xr(),gh(),kh()}});function jh(e){return!e.truncated&&e.size<=Ao&&e.content.split(`
12
+ `).length<=_o}function Nh(e){return e&&(e.node.path||e.node.name)||null}function Ch(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 Sh({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,y]=c.useState(!1),k=(u==null?void 0:u.node)??null,j=k!=null&&k.artifact?h.renderArtifact({artifact:k.artifact,expanded:!0,onToggleExpanded:()=>{}}):null,v=Kc(i??null),N=(i==null?void 0:i.language)||qc((i==null?void 0:i.path)??""),S=i?Nr(i.path):"",L=Nh(u),P=i!==null&&Jn.has(S),K=!!(i&&a)&&!P&&jh(i),F=(u==null?void 0:u.kind)==="live-molecule",D=!!(k!=null&&k.artifact&&j),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 Y(){if(!(!i||!a)){y(!0),w(null);try{await a({path:i.path,content:p}),f(!1)}catch($){w($ instanceof Error?$.message:"Failed to save file.")}finally{y(!1)}}}return t.jsxs("section",{className:"thread-graph-viewer flex h-full min-h-0 flex-col overflow-hidden rounded-[12px]","data-preview-target-kind":(u==null?void 0:u.kind)??"none",children:[t.jsxs("div",{className:"thread-graph-viewer-header flex h-12 shrink-0 items-center justify-between gap-3 border-b px-3 sm:h-[60px] sm:px-5",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[t.jsx("h2",{className:"text-base font-semibold text-slate-900 sm:text-[18px] dark:text-slate-100",children:"Viewer"}),L?t.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-slate-500 dark:text-slate-400",children:L}):null]}),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(B.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(wh,{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:[P?"molecule":N||S||"text"," |"," ",i.size.toLocaleString()," bytes",i.truncated?t.jsxs("span",{className:"ml-2 text-amber-500",children:["showing ",i.nextOffset.toLocaleString()," bytes"]}):null]}),K?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(B.X,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:()=>void Y(),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(B.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(B.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:$=>g($.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(_r,{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||F?"min-h-0 flex-1 overflow-hidden":"min-h-0 flex-1 overflow-auto p-3",children:j}):u.kind==="meta"?t.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-3",children:t.jsx("div",{className:"grid gap-3",children:t.jsx(Jt,{label:"Workspace Data",children:t.jsx(_r,{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(_r,{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 Ao,_o,_r,Th=$e({"src/components/graph-workspace/GraphWorkspacePreviewPane.tsx"(){Qn(),Po(),yh(),Ao=50*1024,_o=1e3,_r=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 Eh({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 Lh=$e({"src/components/graph-workspace/GraphEmptyGarbageDialog.tsx"(){}});function Mo(e){return`${Do}${e.workspaceId??"workspace"}:${e.threadId}`}function Ph(e){if(typeof window>"u")return[];try{const r=window.localStorage.getItem(Mo(e));if(!r)return[];const n=JSON.parse(r);return Array.isArray(n)?n.filter(a=>typeof a=="string"):[]}catch{return[]}}function Oa(e,r){if(!(typeof window>"u"))try{window.localStorage.setItem(Mo(e),JSON.stringify([...r]))}catch{}}function Rn(e,r){if(!r||e.path!==r.path||e.kind!=="directory")return e;const n=new Map(r.children.map(s=>[s.path,s])),a=e.children.map(s=>Rn(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 Ua(e,r){if(e.kind==="directory")return r?t.jsx(B.FolderOpen,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"}):t.jsx(B.Folder,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"});const n=Nr(e.name);return n==="zip"?t.jsx(B.FileArchive,{className:"h-4 w-4 text-amber-600"}):e.kind==="file"&&["png","jpg","jpeg","gif","webp","svg"].includes(n)?t.jsx(B.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(B.FileCode2,{className:"h-4 w-4 text-emerald-600"}):t.jsx(B.File,{className:"h-4 w-4 text-slate-400 dark:text-slate-500"})}function $o({depth:e,expandedPaths:r,loadingPaths:n,node:a,onDownload:o,onPreview:s,onSelect:l,onToggle:i,selectedNodeId:d}){const h=a.kind==="directory",u=h&&(a.path===""||r.has(a.path)),m=h&&n.has(a.path),f=d===a.id,p=`${e*.75+.5}rem`;return h?t.jsxs("div",{children:[t.jsxs("div",{className:"thread-graph-tree-row group flex items-center text-sm text-slate-600 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100",children:[t.jsxs("button",{type:"button",onClick:()=>i(a.path),className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 px-2 py-2 text-left sm:min-h-0 sm:py-1.5",style:{paddingLeft:p},children:[u?t.jsx(B.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}):t.jsx(B.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}),Ua(a,u),t.jsx("span",{className:"truncate",children:a.name}),m?t.jsx("span",{className:"ml-auto shrink-0 text-xs text-slate-400 dark:text-slate-500",children:"Loading"}):null]}),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(B.Download,{className:"h-3.5 w-3.5"})}):null]}),u?t.jsxs("div",{children:[a.children.map(g=>t.jsx($o,{depth:e+1,expandedPaths:r,loadingPaths:n,node:g,...o?{onDownload:o}:{},...s?{onPreview:s}:{},onSelect:l,onToggle:i,selectedNodeId:d},g.id)),a.truncated?t.jsx("div",{className:"px-2 py-1 text-xs text-slate-400 dark:text-slate-500",style:{paddingLeft:`${(e+1)*.75+.5}rem`},children:"More items not shown"}):null]}):null]}):t.jsxs("div",{className:`thread-graph-tree-row group flex items-center text-sm transition ${f?"is-selected":"text-slate-600 hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100"}`,children:[t.jsxs("button",{type:"button",onClick:()=>l(a.id),className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 px-2 py-2 text-left sm:min-h-0 sm:py-1.5",style:{paddingLeft:`${e*.75+2.2}rem`},children:[Ua(a,!1),t.jsx("span",{className:"truncate",children:a.name})]}),a.kind==="file"&&(s||o)?t.jsxs("div",{className:"mr-1 flex shrink-0 items-center gap-0.5",children:[s?t.jsx("button",{type:"button",onClick:()=>s(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${f?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Preview ${a.name}`,"aria-label":`Preview ${a.name}`,children:t.jsx(B.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 ${f?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Download ${a.name}`,"aria-label":`Download ${a.name}`,children:t.jsx(B.Download,{className:"h-3.5 w-3.5"})}):null]}):null]})}function zh({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(B.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 Ih({canEmptyGarbage:e,canUpload:r,onCollapse:n,expandedPaths:a,loadingPaths:o,loading:s,onDownload:l,onEmptyGarbage:i,onPreview:d,onRefresh:h,onSelect:u,onToggle:m,onUpload:f,explorerScrollTopRef:p,explorerScrollerRef:g,selectedNodeId:b,tree:w,liveNodes:x}){const y=c.useMemo(()=>({...w,children:w.children.filter(k=>k.path!=="live")}),[w]);return c.useLayoutEffect(()=>{const k=g.current;k&&(k.scrollTop=p.current)},[g,p]),t.jsxs("aside",{className:`${Bo} flex flex-col`,children:[t.jsxs("div",{className:Go,children:[t.jsx("div",{className:"min-w-0",children:t.jsx("h2",{className:Fo,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:Ho,title:"Collapse Explorer","aria-label":"Collapse Explorer",children:[t.jsx(B.ChevronsLeft,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Collapse Explorer"})]}):null,t.jsx("button",{type:"button",onClick:f,disabled:!r,className:$r,title:r?"Upload file":"Upload is unavailable for this workspace","aria-label":"Upload file",children:t.jsx(B.Upload,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:h,className:$r,title:"Refresh workspace","aria-label":"Refresh workspace",children:t.jsx(B.RefreshCw,{className:`h-4 w-4 ${s?"animate-spin":""}`})}),i?t.jsx("button",{type:"button",onClick:i,disabled:!e,className:$r,title:e?"Empty garbage":"Garbage controls are unavailable","aria-label":"Empty garbage",children:t.jsx(B.Trash2,{className:"h-4 w-4"})}):null]})]}),t.jsxs("div",{ref:g,className:"thread-graph-workspace-tree-scroll min-h-0 flex-1 overflow-y-auto py-2",onScroll:k=>{p.current=k.currentTarget.scrollTop},children:[t.jsx(zh,{liveNodes:x??[],onSelect:u,selectedNodeId:b}),t.jsx("div",{className:Oo,children:"Workspace"}),t.jsx($o,{depth:0,expandedPaths:a,loadingPaths:o,node:y,...l?{onDownload:l}:{},...d?{onPreview:d}:{},onSelect:u,onToggle:m,selectedNodeId:b}),y.children.length===0?t.jsx("p",{className:Uo,children:"This workspace is empty. Agent tool runs execute inside the thread workspace, so files should appear here as the session works."}):null]})]})}function Rh({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:Da(r,n),[e,i,n,r,o,l]),u=i??h??Da(r,n),m=c.useMemo(()=>Jc(u),[u]),f=c.useMemo(()=>{var R;return((R=u.children.find(M=>M.path==="live"))==null?void 0:R.children)??[]},[u]),p=To(u),[g,b]=c.useState(()=>(p==null?void 0:p.id)??null),[w,x]=c.useState(()=>new Set(["","artifacts","thread-events","live",...Ba((p==null?void 0:p.path)??"")])),[y,k]=c.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 639px)").matches?"viewer":null),[j,v]=c.useState(null),[N,S]=c.useState(!1),[L,P]=c.useState(()=>new Set),[K,F]=c.useState(!1),[D,Z]=c.useState(!1),[Y,$]=c.useState(!1),[te,oe]=c.useState([]),[A,J]=c.useState(null),[I,q]=c.useState(null),[O,T]=c.useState(null),[U,H]=c.useState(!1),C=c.useRef(null),E=c.useRef(null),X=c.useRef(0),W=c.useRef(null),le=!!l,Q=(g?m.get(g):null)??p??null,de={threadId:r.thread.id,workspaceId:r.workspace.id??r.thread.workspaceId??null};c.useEffect(()=>{X.current=0,W.current=null,x(new Set(["","artifacts","thread-events","live",...Ph(de),...Ba((p==null?void 0:p.path)??"")]))},[de.threadId,de.workspaceId]);function re(){var M;const R=((M=E.current)==null?void 0:M.scrollTop)??X.current;X.current=R,W.current=R}function xe(){const R=W.current??X.current;if(!E.current)return;let ee=0;const pe=()=>{const ke=E.current;ke&&(ke.scrollTop=Math.min(R,Math.max(0,ke.scrollHeight-ke.clientHeight)),X.current=ke.scrollTop,ee+=1,ee<8?window.requestAnimationFrame(pe):W.current=null)};window.requestAnimationFrame(pe)}c.useLayoutEffect(()=>{y!=="explorer"&&xe()},[y,u]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const R=window.matchMedia("(max-width: 639px)"),M=()=>H(R.matches);return M(),typeof R.addEventListener=="function"?(R.addEventListener("change",M),()=>R.removeEventListener("change",M)):(R.addListener(M),()=>R.removeListener(M))},[]);async function ie(R){if(!l)return;const M=R??(Q==null?void 0:Q.path)??null;S(!0),v(null);try{const ee=Zt(await l.listTree({...de,path:""}));let pe=i?Rn(ee,i):ee;if(i){const Ae=[...w].filter(Ne=>Ne).sort((Ne,De)=>Ne.split("/").length-De.split("/").length);for(const Ne of Ae){const De=Ln(i,Ne);if((De==null?void 0:De.kind)!=="directory"||!De.childrenLoaded)continue;const et=Zt(await l.listTree({...de,path:Ne}));pe=Pn(pe,Ne,Rn(et,De))}}d(pe);const ke=No(pe);b(Ae=>{var De;const Ne=M??(Ae?(De=m.get(Ae))==null?void 0:De.path:null);return Ne&&zn(pe,Ne)?`workspace:${Ne}`:(ke==null?void 0:ke.id)??Ae})}catch(ee){v(ee instanceof Error?ee.message:"Failed to load workspace"),d(null)}finally{S(!1)}}async function ve(R){if(!(!l||!i)){P(M=>{if(M.has(R))return M;const ee=new Set(M);return ee.add(R),ee}),v(null);try{const M=Zt(await l.listTree({...de,path:R}));d(ee=>ee&&jo(ee,R,M.children,{truncated:M.truncated}))}catch(M){v(M instanceof Error?M.message:"Failed to load directory")}finally{P(M=>{if(!M.has(R))return M;const ee=new Set(M);return ee.delete(R),ee})}}}async function Pe(R){const M=Co(R);if(!M)return;const ee=Vc(M);if(k(null),x(pe=>{const ke=new Set(pe);ke.add("");for(const Ae of ee)ke.add(Ae);return Oa(de,ke),ke}),!l){zn(u,M)&&b(`workspace:${M}`);return}S(!0),v(null);try{let pe=i??Zt(await l.listTree({...de,path:""}));for(const ke of ee){const Ae=Ln(pe,ke);if((Ae==null?void 0:Ae.kind)==="directory"&&Ae.childrenLoaded)continue;const Ne=Zt(await l.listTree({...de,path:ke}));pe=Pn(pe,ke,Ne)}d(pe),b(`workspace:${M}`)}catch(pe){v(pe instanceof Error?pe.message:`Failed to open ${M}`)}finally{S(!1)}}c.useEffect(()=>{if(!(!l||!i))for(const R of m.values())R.path&&R.kind==="directory"&&w.has(R.path)&&R.hasChildren&&!R.childrenLoaded&&!L.has(R.path)&&ve(R.path)},[i,w,m,l]),c.useEffect(()=>{d(null),P(new Set),J(null),q(null),T(null),v(null),ie()},[le,r.thread.id,r.workspace.id,r.thread.workspaceId]),c.useEffect(()=>{s&&Pe(s.path)},[s==null?void 0:s.requestId]),c.useEffect(()=>{l!=null&&l.subscribeWorkspaceChanged},[l,de.threadId,de.workspaceId]),c.useEffect(()=>{const R=l&&(Q==null?void 0:Q.kind)==="file"?Q.path:null;if(!R){J(null),q(null),T(null);return}const M=R;let ee=!1;async function pe(){var ke;if(l){F(!0),v(null),J(null),q(null),T(null);try{const Ae=Nr(M),Ne=(ke=l.getRawFileUrl)==null?void 0:ke.call(l,{...de,path:M});if(Ne&&Eo.has(Ae)){ee||q(Ne);return}if(Ne&&Lo.has(Ae)){ee||T(Ne);return}const De=await l.readFile({...de,path:M,limit:Mr});ee||J(De)}catch(Ae){ee||v(Ae instanceof Error?Ae.message:"Failed to read file")}finally{ee||F(!1)}}}return pe(),()=>{ee=!0}},[l,Q==null?void 0:Q.id]);async function se(){if(!(!l||!(A!=null&&A.truncated))){Z(!0);try{const R=await l.readFile({...de,path:A.path,offset:A.nextOffset,limit:Mr});J(M=>M&&{...M,content:M.content+R.content,truncated:R.truncated,nextOffset:R.nextOffset,size:R.size})}finally{Z(!1)}}}async function ye(R){if(!(l!=null&&l.writeFile))return;v(null),await l.writeFile({...de,path:R.path,content:R.content}),await ie(R.path);const M=await l.readFile({...de,path:R.path,limit:Mr});J(M)}async function je(R){if(!(!(l!=null&&l.uploadFile)||!R)){S(!0),v(null);try{const M=await l.uploadFile({...de,path:R.name,file:R}),ee=M.kind==="archive"?M.paths[0]??null:M.file.path;await ie(ee)}catch(M){v(M instanceof Error?M.message:"Failed to upload file")}finally{S(!1)}}}async function G(R){var ee;const M=(ee=R.target.files)==null?void 0:ee[0];R.target.value="",M&&await je(M)}function me(){if(!(l!=null&&l.uploadFile))return;const R=()=>{var M;return(M=C.current)==null?void 0:M.click()};if(l.pickUploadFile){l.pickUploadFile({...de,defaultPick:R,upload:je});return}R()}function ge(R){var M;(M=l==null?void 0:l.downloadNode)==null||M.call(l,{...de,path:R.path,kind:R.kind==="directory"?"directory":"file"})}function we(R){R.kind==="file"&&(re(),b(R.id),k("explorer"))}async function _e(){if(l!=null&&l.emptyGarbage){if(v(null),!l.listGarbage){oe([]),$(!0);return}try{const R=await l.listGarbage(de);oe(R.map(M=>`garbage/${M}`))}catch(R){oe([]),v(R instanceof Error?R.message:"Failed to list garbage files")}finally{$(!0)}}}async function Re(){if(l!=null&&l.emptyGarbage){$(!1),v(null);try{await l.emptyGarbage(de),await ie((Q==null?void 0:Q.path)??null)}catch(R){v(R instanceof Error?R.message:"Failed to empty garbage")}}}const Ee={...l!=null&&l.downloadNode?{onDownload:ge}:{},...l!=null&&l.emptyGarbage?{onEmptyGarbage:_e}:{},...l?{onRefresh:()=>void ie((Q==null?void 0:Q.path)??null)}:{},...l!=null&&l.uploadFile?{onUpload:me}:{}};function Me(R){if(!R)return;const M=m.get(`workspace:${R}`),ee=(M==null?void 0:M.kind)==="directory"&&M.hasChildren&&!M.childrenLoaded&&!L.has(R);x(pe=>{const ke=new Set(pe);return ke.has(R)?ke.delete(R):ke.add(R),Oa(de,ke),ke}),!w.has(R)&&ee&&ve(R)}const _=t.jsx(Ih,{canEmptyGarbage:!!(l!=null&&l.emptyGarbage),canUpload:!!(l!=null&&l.uploadFile),onCollapse:()=>{re(),k("explorer")},expandedPaths:w,loadingPaths:L,loading:N,explorerScrollTopRef:X,explorerScrollerRef:E,...Ee,onPreview:we,onSelect:R=>{b(R)},onToggle:Me,selectedNodeId:(Q==null?void 0:Q.id)??null,tree:u,liveNodes:f}),ue=t.jsx(Sh,{error:j,imageUrl:I,loadingMore:D,onLoadMore:se,...l!=null&&l.writeFile?{onSaveFile:ye}:{},onCollapse:()=>{re(),k("viewer")},pdfUrl:O,previewFile:A,previewLoading:K,plugins:a,selectedTarget:Ch(Q)});return y==="explorer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:ue}):y==="viewer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:_}):t.jsxs("div",{"data-testid":"workspace-panel",className:"flex h-full min-h-0 w-full overflow-hidden bg-transparent p-2",children:[Y?t.jsx(Eh,{files:te,onCancel:()=>$(!1),onConfirm:()=>void Re()}):null,U?t.jsxs(Tn,{direction:"vertical",className:"thread-graph-workspace-mobile-stack",children:[t.jsx(er,{defaultSize:42,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-explorer h-full min-h-0 overflow-hidden",children:_})}),t.jsx(En,{className:"thread-graph-workspace-resize-handle h-2 bg-transparent after:h-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(er,{defaultSize:58,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-viewer h-full min-h-0 overflow-hidden",children:ue})})]}):t.jsxs(Tn,{direction:"horizontal",className:"thread-graph-workspace-resizable",children:[t.jsx(er,{defaultSize:33,minSize:20,children:t.jsx("div",{className:"thread-graph-workspace-explorer-pane h-full min-h-0 overflow-hidden",children:_})}),t.jsx(En,{className:"thread-graph-workspace-resize-handle w-2 bg-transparent after:w-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(er,{defaultSize:67,minSize:30,children:t.jsx("div",{className:"thread-graph-workspace-viewer-pane h-full min-h-0 overflow-hidden",children:ue})})]}),t.jsx("input",{ref:C,type:"file","aria-label":"Workspace upload file input","data-testid":"workspace-upload-file-input",className:"hidden",onChange:R=>void G(R)})]})}var Mr,Do,Bo,Go,Fo,$r,Ho,Oo,Uo,Ah=$e({"src/components/graph-workspace/GraphWorkspaceExplorer.tsx"(){Qn(),Th(),Lh(),yo(),Mr=24e3,Do="remote-codex:graphchat:workspace:expanded:",Bo="thread-graph-explorer h-full min-h-0 overflow-hidden rounded-[12px]",Go="thread-graph-explorer-header flex h-[60px] shrink-0 items-center justify-between border-b px-4",Fo="text-[18px] font-semibold text-slate-900 dark:text-slate-100",$r="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",Ho="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",Oo="thread-graph-workspace-label px-3 pb-1 pt-2 text-[11px] font-semibold tracking-normal text-slate-500 dark:text-slate-400",Uo="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 mn({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 Xt({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 _h({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 lr({value:e,title:r,icon:n,children:a}){return t.jsxs(wr,{value:e,className:"thread-guide-section border-b border-[var(--theme-border)] last:border-b-0",children:[t.jsx(Yr,{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(_h,{children:n}),r]})}),t.jsx(yr,{className:"space-y-3 pb-3",children:a})]})}function Mh(){return t.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[t.jsxs("div",{className:"shrink-0 border-b border-[var(--theme-border)] px-4 py-3",children:[t.jsx("h2",{className:"text-xs font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"What can I do?"}),t.jsx("p",{className:"mt-0.5 text-[11px] text-[var(--theme-fg-muted)]",children:"Upload files, ask in plain language, get results."})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-3 pb-6",children:t.jsxs(kr,{type:"multiple",defaultValue:["start","workspace","remote-codex"],className:"space-y-0",children:[t.jsxs(lr,{value:"start",title:"Getting Started",icon:t.jsx(B.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(Xt,{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(lr,{value:"workspace",title:"Workspace Explorer",icon:t.jsx(B.FolderOpen,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(B.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(B.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(B.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(B.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(B.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(Xt,{items:[t.jsxs(t.Fragment,{children:[t.jsx(mn,{children:".xyz .extxyz .cif"})," use the 3D molecule plugin."]}),t.jsxs(t.Fragment,{children:[t.jsx(mn,{children:".png .jpg .gif .svg .webp"})," use inline image preview."]}),t.jsxs(t.Fragment,{children:[t.jsx(mn,{children:".py .json .ts .md .csv"})," use text/code preview."]}),"Large files load in chunks when the workspace adapter supports it."]})]})]}),t.jsxs(lr,{value:"viewer",title:"Viewer",icon:t.jsx(B.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(Xt,{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(lr,{value:"usage",title:"Tool Usage & Chat",icon:t.jsx(B.BarChart2,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(B.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(Xt,{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(B.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(Xt,{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(lr,{value:"remote-codex",title:"Remote Codex Extras",icon:t.jsx(B.Code2,{className:"h-3 w-3"}),children:t.jsx(Xt,{items:["Slash toolbox: skills, MCP, hooks, goals, forks, model controls, provider settings","Rich message bubbles: reasoning, commands, searches, file reads, file changes, plans, action requests, artifacts","Plugin surfaces: terminal, XYZ molecule viewer, inline code renderers, and imported plugin panels","Thread metadata stays in the left rail and Workspace tab instead of replacing chat"]})})]})})]})}var $h=$e({"src/components/graph-workspace/GraphGuidePanel.tsx"(){jr()}});function Dh(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 Wa({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:Dh(r)})]})}function Bh({event:e}){return t.jsxs(wr,{value:e.id,className:"thread-tool-call mb-2 overflow-hidden rounded-lg border border-[var(--theme-border)] last:mb-0",children:[t.jsxs(Yr,{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(yr,{className:"px-3 pb-3",children:t.jsxs("div",{className:"space-y-2 px-3 pb-3 pt-1",children:[t.jsx(Wa,{label:"Input",value:e.preview}),t.jsx(Wa,{label:"Output",value:e.detail})]})})]})}function Gh({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(B.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(kr,{type:"single",collapsible:!0,value:o??"",onValueChange:i=>s(i||null),className:"space-y-0",children:n.slice(-50).map(i=>t.jsx(Bh,{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(B.RefreshCw,{className:"h-3 w-3"}),"Reload from workspace"]})]})}var Fh=$e({"src/components/graph-workspace/GraphToolUsagePanel.tsx"(){jr()}});function Va(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,y=w*b,k=d*(x+y)+u,j=h*(-x+y)+m;return{x:k,y:j}}function Ka(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?Mt.Left:s>=a+(e.measured.width??1)-1?Mt.Right:l<=o+1?Mt.Top:l>=n.y+(e.measured.height??1)-1?Mt.Bottom:Mt.Top}function Wo(e,r){const n=Va(e,r),a=Va(r,e),o=Ka(e,n),s=Ka(r,a);return{sx:n.x,sy:n.y,tx:a.x,ty:a.y,sourcePos:o,targetPos:s}}function Hh(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,y)=>{const k=(x<<5)-x+y.charCodeAt(0);return k&k},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],y=d[w];if(!x||!y)continue;const k=f.get(x.id),j=f.get(y.id);if(!k||!j)continue;const v=k.x-j.x,N=k.y-j.y,S=Math.sqrt(v*v+N*N)||1,P=(200-S)*.5,K=v/S*P,F=N/S*P;k.vx+=K,k.vy+=F,j.vx-=K,j.vy-=F}h.forEach(b=>{const w=f.get(b.source),x=f.get(b.target);if(!w||!x)return;const y=x.x-w.x,k=x.y-w.y,j=Math.sqrt(y*y+k*k)||1,N=(j-120)*.3,S=y/j*N,L=k/j*N;w.vx+=S,w.vy+=L,x.vx-=S,x.vy-=L}),f.forEach(b=>{b.x+=b.vx*.1,b.y+=b.vy*.1,b.vx*=.9,b.vy*=.9,b.x=Math.max(80,Math.min(u-80,b.x)),b.y=Math.max(80,Math.min(m-80,b.y))})}return f},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:As.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 ea=$e({"src/components/graph-chat/FloatingHelper.tsx"(){}});function Oh({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}=Wo(o,s),[f]=_s({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 Uh=$e({"src/components/graph-chat/FloatingConnectionLine.tsx"(){ea()}});function Wh({id:e,source:r,target:n,markerEnd:a,style:o}){const s=ka(r),l=ka(n);if(!s||!l)return null;const{sx:i,sy:d,tx:h,ty:u,sourcePos:m,targetPos:f}=Wo(s,l),[p]=_s({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 Vh=$e({"src/components/graph-chat/FloatingEdge.tsx"(){ea()}});function Kh({nodes:e}){const[r,n,a]=id([]),[o,s,l]=dd([]),i=c.useMemo(()=>Hh(e),[e]),d=c.useMemo(()=>({floating:Wh}),[]),h=c.useMemo(()=>({styledNode:({data:m,isConnectable:f})=>t.jsxs("div",{className:"thread-graph-flow-node",children:[m.label,t.jsx(va,{type:"target",position:Mt.Top,isConnectable:f,style:{opacity:0,pointerEvents:"none"}}),t.jsx(va,{type:"source",position:Mt.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=>cd({...m,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:As.Arrow}},f)),[s]);return t.jsx("div",{className:"thread-graph-flow h-full min-h-0",children:t.jsx(hd,{children:t.jsxs(ud,{nodes:r,edges:o,onNodesChange:a,onEdgesChange:l,onConnect:u,fitView:!0,nodeTypes:h,edgeTypes:d,connectionLineComponent:Oh,children:[t.jsx(md,{}),t.jsx(pd,{gap:16})]})})})}var qh=$e({"src/components/graph-chat/GraphVisualization.tsx"(){Uh(),Vh(),ea()}});function Xh(e){return{...Ko,...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 Yh(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 Zh(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:Fr(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:Fr(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 Fr(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 Jh(e){switch(e.kind){case"userMessage":return"User";case"agentMessage":return"Agent";default:return Fr(e.kind)}}function Qh(e){return(e.previewText??e.text??e.detailText??e.kind).replace(/\s+/g," ").slice(0,96)}function eu(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:Jh(d),description:Qh(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 Vo({detail:e,status:r,plugins:n,workspaceAdapter:a,metaContent:o,settingsContent:s,activeView:l="chat",features:i,focusPathRequest:d=null}){const h=c.useMemo(()=>Xh(i),[i]),u=qa(h,i==null?void 0:i.defaultTab),[m,f]=c.useState(u),p=c.useMemo(()=>Oc(e),[e]),g=c.useMemo(()=>Zh(e),[e]),b=c.useMemo(()=>{const v=new Map;for(const N of g)v.set(N.kind,(v.get(N.kind)??0)+1);return[...v.entries()].sort((N,S)=>S[1]-N[1])},[g]),w=n.getThreadPanels(),x=Math.max(...b.map(([,v])=>v),1),y=c.useMemo(()=>eu(e,g),[e,g]),k=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:B.BarChart2}),h.guide&&v.push({id:"guide",label:"Guide",icon:B.BookOpen}),v},[h.guide,h.toolUsage,h.workspace]),j=c.useMemo(()=>{const v=[];return h.threadGraph&&v.push({id:"graph",label:"Thread graph",icon:B.GitBranch}),h.extensions&&v.push({id:"extensions",label:"Remote Codex extensions",icon:B.Wrench}),v},[h.extensions,h.threadGraph]);return c.useEffect(()=>{(!m||!Yh(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:[k.map(v=>{const N=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:[N?t.jsx(N,{className:"h-3.5 w-3.5"}):null,v.label]},v.id)}),j.length?t.jsx("div",{className:"thread-graph-right-tab-secondary ml-auto flex min-w-0 shrink items-center gap-1 border-l pl-2","aria-label":"Remote Codex workspace extensions",children:j.map(v=>{const N=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(N,{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(Rh,{activeView:l,detail:e,artifacts:p,plugins:n,status:r,focusPathRequest:d,workspaceAdapter:a??null}):null,m==="tools"?t.jsx(Gh,{formatToolKind:Fr,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(Kh,{nodes:y})}):null,m==="extensions"?t.jsx("div",{className:"h-full min-h-0 overflow-y-auto p-3",children:t.jsxs("div",{className:"grid gap-3",children:[t.jsx(Jt,{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(Jt,{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(Jt,{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(B.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(B.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(B.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(Jt,{label:"Thread Meta",children:o}):null,s?t.jsx(Jt,{label:"Settings",children:s}):null]})}):null,m==="guide"?t.jsx(Mh,{}):null]})]}):null}var Ko,qo,tu=$e({"src/components/ThreadGraphWorkspacePanel.tsx"(){Ah(),Po(),$h(),Fh(),Qn(),qh(),Ko={workspace:!0,toolUsage:!0,guide:!0,threadGraph:!0,extensions:!0},qo=c.memo(Vo)}}),Xo={};Hc(Xo,{MemoizedThreadGraphWorkspacePanel:()=>qo,ThreadGraphWorkspacePanel:()=>Vo});var ru=$e({"src/workspace-panel.ts"(){tu()}});function nr(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))}nr(`.thread-ui-shell,
14
14
  .thread-graph-dialog {
15
15
  color-scheme: light;
16
16
  --radius: 0.625rem;
@@ -3637,43 +3637,43 @@ import{l as B,R as $i,I as Di,C as Bi,S as Rs,H as Gi,T as Fi,a as Hi,b as Oi,c
3637
3637
  padding: 1.5rem;
3638
3638
  }
3639
3639
  }
3640
- `);function nu(e){return e.replace(/\u00a0/g," ")}function au(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 su(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 ou(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 lu({files:e,kindForFile:r,usedPlaceholders:n,buildClientId:a}){return e.map(s=>{const o=r(s),l=ku(s,o),i=su(o,wu(l),n);return n.add(i),{clientId:a(),kind:o,originalName:l,placeholder:i,file:s}})}function iu({prompt:e,attachments:r,files:n,selection:a,kindForFile:s,buildClientId:o}){const l=new Set(r.map(p=>p.placeholder)),i=lu({files:n,kindForFile:s,usedPlaceholders:l,buildClientId:o}),d=a?{start:a.start,end:a.end}:{start:e.length,end:e.length},h=ou(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 du({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 cu({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 Xa(e){return e?{type:"accept-files",preventDefault:!0,activateDragTarget:!0}:{type:"ignore",preventDefault:!1,activateDragTarget:!1}}function hu(e){return e.length>0?{type:"accept-files",preventDefault:!0,activateDragTarget:!0,files:e}:{type:"ignore",preventDefault:!1,activateDragTarget:!1}}function uu({key:e,metaKey:r,ctrlKey:n,busy:a,disabled:s}){const o=e==="Enter"&&(r||n);return{preventDefault:o,submit:o&&!a&&!s}}function mu({nextMode:e,previousOptimisticMode:r}){return{optimisticMode:e??null,rollbackMode:e?r:null,shouldRollbackMode:!!e,closeMenuOnSuccess:!0}}function Tr(e){return`${e.prompt}${e.attachments.map(r=>`${r.clientId}${r.kind}${r.placeholder}${r.originalName}`).join("")}`}function Ya(e){if(!e)return"Auto";switch(e){case"xhigh":return"xhigh";default:return e}}function pu(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 fu(e){if(!e)return"";const r=e/1e3;return Number.isInteger(r)?String(r):String(Number(r.toFixed(1)))}function _n(e){return e.replace(/\r\n/g,`
3641
- `)}function gu(e){const r=e.trim();return/^[A-Za-z0-9_-]+$/.test(r)?r:null}function xu(e){const n=_n(e).split(`
3642
- `).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 bu(e,r){return`[mcp_servers.${e}]
3640
+ `);function nu(e){return e.replace(/\u00a0/g," ")}function au(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 su(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 ou(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 lu({files:e,kindForFile:r,usedPlaceholders:n,buildClientId:a}){return e.map(o=>{const s=r(o),l=ku(o,s),i=su(s,wu(l),n);return n.add(i),{clientId:a(),kind:s,originalName:l,placeholder:i,file:o}})}function iu({prompt:e,attachments:r,files:n,selection:a,kindForFile:o,buildClientId:s}){const l=new Set(r.map(p=>p.placeholder)),i=lu({files:n,kindForFile:o,usedPlaceholders:l,buildClientId:s}),d=a?{start:a.start,end:a.end}:{start:e.length,end:e.length},h=ou(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 du({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 cu({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 Xa(e){return e?{type:"accept-files",preventDefault:!0,activateDragTarget:!0}:{type:"ignore",preventDefault:!1,activateDragTarget:!1}}function hu(e){return e.length>0?{type:"accept-files",preventDefault:!0,activateDragTarget:!0,files:e}:{type:"ignore",preventDefault:!1,activateDragTarget:!1}}function uu({key:e,metaKey:r,ctrlKey:n,busy:a,disabled:o}){const s=e==="Enter"&&(r||n);return{preventDefault:s,submit:s&&!a&&!o}}function mu({nextMode:e,previousOptimisticMode:r}){return{optimisticMode:e??null,rollbackMode:e?r:null,shouldRollbackMode:!!e,closeMenuOnSuccess:!0}}function Er(e){return`${e.prompt}${e.attachments.map(r=>`${r.clientId}${r.kind}${r.placeholder}${r.originalName}`).join("")}`}function Ya(e){if(!e)return"Auto";switch(e){case"xhigh":return"xhigh";default:return e}}function pu(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 fu(e){if(!e)return"";const r=e/1e3;return Number.isInteger(r)?String(r):String(Number(r.toFixed(1)))}function An(e){return e.replace(/\r\n/g,`
3641
+ `)}function gu(e){const r=e.trim();return/^[A-Za-z0-9_-]+$/.test(r)?r:null}function xu(e){const n=An(e).split(`
3642
+ `).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 bu(e,r){return`[mcp_servers.${e}]
3643
3643
  url = ${JSON.stringify(r.trim())}
3644
- `}function Za(e,r,n){var m,f;const a=_n(e),s=`${_n(n).trim()}
3645
- `,o=a.split(`
3646
- `),l=`[mcp_servers.${r}]`,i=`[mcp_servers.${r}.`;let d=-1,h=o.length;for(let p=0;p<o.length;p+=1)if((((m=o[p])==null?void 0:m.trim())??"")===l){d=p;break}if(d>=0){for(let b=d+1;b<o.length;b+=1){const v=((f=o[b])==null?void 0:f.trim())??"";if(v.startsWith("[")&&!(v===l||v.startsWith(i))){h=b;break}}const p=o.slice(0,d).join(`
3647
- `).trimEnd(),g=o.slice(h).join(`
3648
- `).trim();return[p,s.trimEnd(),g].filter(Boolean).join(`
3644
+ `}function Za(e,r,n){var m,f;const a=An(e),o=`${An(n).trim()}
3645
+ `,s=a.split(`
3646
+ `),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(`
3647
+ `).trimEnd(),g=s.slice(h).join(`
3648
+ `).trim();return[p,o.trimEnd(),g].filter(Boolean).join(`
3649
3649
 
3650
3650
  `).replace(/\n{3,}/g,`
3651
3651
 
3652
3652
  `).concat(`
3653
3653
  `)}const u=a.trimEnd();return u?`${u}
3654
3654
 
3655
- ${s}`:s}function Yo(e){return typeof e!="number"||Number.isNaN(e)?0:Math.max(0,Math.min(100,Math.round(e)))}function fn(e){const r=e/1e3;return Number.isInteger(r)?`${r}k`:`${Number(r.toFixed(1))}k`}function vu(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,`${fn(n)} used / ${fn(a)}`,`${fn(s)} left`,`${Yo(r.remainingPercent)}% context left`].join(" · ")}function ku(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 wu(e){return e.replace(/[\r\n[\]]+/g," ").replace(/\s+/g," ").trim()||"attachment"}function Mn(e){return e.type.startsWith("image/")?"photo":"file"}function $n(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 Ja(e,r){return $n(e,r).length>0}function yu(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function Qa(e){const r=e.placeholder.match(/^\[(?:PHOTO|FILE)\s+(.+)\]$/);return r!=null&&r[1]?r[1]:yu(e.originalName)}var Fr=[{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 ju({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 Nu({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 Cu(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.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 Su(){return t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",children:t.jsx("path",{d:"M8 3.25v9.5M3.25 8h9.5"})})}function Tu(){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 Eu(){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 Lu(){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 Dn(){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 Pu(e){switch(e){case"bearerToken":return"Token";case"oAuth":return"OAuth";case"notLoggedIn":return"Login";case"unsupported":return"Public";default:return"Unknown"}}function zu(e){switch(e){case"repo":return"Repo";case"system":return"System";case"admin":return"Admin";case"user":default:return"User"}}function Iu(e){var r;return((r=Fr.find(n=>n.value===e))==null?void 0:r.label)??e}function Ru(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 Au(e){switch(e){case"managed":return"Managed";case"modified":return"Modified";case"trusted":return"Trusted";case"untrusted":return"Review"}}function _u(e){switch(e){case"preToolUse":return"PreToolUse";case"permissionRequest":return"PermissionRequest";case"postToolUse":return"PostToolUse";case"preCompact":return"PreCompact";case"postCompact":return"PostCompact";case"sessionStart":return"SessionStart";case"userPromptSubmit":return"UserPromptSubmit";case"stop":return"Stop"}}function Mu(e){return e.source==="user"?"global":e.source==="project"?"project":null}function Zo(e){const r=Mu(e);return!r||e.handlerType!=="command"||!e.command||e.isManaged?null:{scope:r,eventName:e.eventName,matcher:e.matcher,command:e.command,timeoutSec:e.timeoutSec,statusMessage:e.statusMessage}}function $u(e){switch(e){case"active":return"Active";case"paused":return"Paused";case"budgetLimited":return"Budget";case"complete":return"Complete";default:return e}}function Du({contextUsage:e}){const r=(e==null?void 0:e.availability)??"unavailable",n=Yo(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 _t({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 Bu(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 Gu(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 Fu(e,{fastMode:r,compactBusy:n,goalComposeMode:a,goalStatus:s,busy:o}){switch(e.action){case"fast":return r?"On":"Off";case"compact":return n?"Busy":"Run";case"goal":return a?"Composing":s?$u(s):"Open";case"fork":return o?"Idle only":"Open";case"skills":case"mcp":case"hooks":return"View";case"prompt":return"Compose";case"unsupported":return"Unavailable";default:return""}}function Hu(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 Ou(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 Uu(e){if(!e)return"";const r=document.createElement("div");return r.innerHTML=e,r.textContent??""}function Wu(e){return!!e.querySelector("[style], font")}function $t(e){return e instanceof HTMLElement&&e.dataset.segmentType==="attachment"&&e.dataset.placeholder?e.dataset.placeholder:e.textContent??""}function Jo(e){let r="";for(const n of Array.from(e.childNodes))r+=$t(n);return r.replace(/\u00a0/g," ")}function es(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+=$t(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 Jo(e).length;if(a=d,d instanceof HTMLElement&&d.dataset.segmentType==="attachment"){const h=document.createRange();h.selectNodeContents(d);const u=$t(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=$t(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,$t(d).length);l+=$t(d).length}return l}function Vu(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:es(e,n.startContainer,n.startOffset),end:es(e,n.endContainer,n.endOffset)}}function ts(e,r){let n=Math.max(0,r);const a=Array.from(e.childNodes);for(const[s,o]of a.entries()){const i=$t(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 Ku(e,r){const n=ts(e,r.start),a=ts(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 qu(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}Xr();Pt();function Xu({className:e,...r}){return t.jsx("div",{"data-slot":"input-group",role:"group",className:nt("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 Yu=br("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 Zu({className:e,align:r="inline-start",...n}){return t.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":r,className:nt(Yu({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 Ju=br("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 kt({className:e,type:r="button",variant:n="ghost",size:a="xs",...s}){return t.jsx(xr,{type:r,"data-size":a,variant:n,className:nt(Ju({size:a}),e),...s})}function Qu({className:e,...r}){return t.jsx("span",{className:nt("flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*=size-])]:size-4",e),...r})}function em({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 tm({activeView:e,followTail:r,onToggleFollow:n}){return e!=="chat"?null:t.jsx("button",{type:"button","aria-label":"Jump to latest",title:r?"Latest turn is in view":"Jump to the latest messages",onClick:()=>n==null?void 0:n(),className:"absolute left-1/2 top-0 z-[90] inline-flex h-11 min-w-[7rem] -translate-x-1/2 -translate-y-full items-end justify-center bg-transparent pb-1 touch-manipulation sm:h-10",children:t.jsx("span",{className:`thread-jump-latest-badge pointer-events-none inline-flex h-4 min-w-[3.75rem] items-center justify-center rounded-[0.7rem] border shadow-sm transition ${r?"is-active border-sky-300/36 bg-sky-300/[0.03] text-sky-100/86":"border-stone-500/70 bg-stone-950/[0.08] text-stone-200/86"}`,children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m4 6 4 4 4-4"})})})})}function rm({activeView:e,layerClassName:r,formClassName:n,shellClassName:a,inputGroupClassName:s,error:o,followTail:l,photoInputRef:i,fileInputRef:d,onAppendAttachments:h,onToggleFollow:u,onSubmit:m,formRef:f,promptSlot:p,toolbarSlot:g,goalSlot:b,shellPromptSlot:v}){return t.jsxs("div",{className:r,children:[t.jsx(em,{photoInputRef:i,fileInputRef:d,onAppendAttachments:h}),t.jsx(tm,{activeView:e,followTail:l,onToggleFollow:u}),t.jsxs("form",{ref:f,"data-testid":e==="chat"?"chat-composer":void 0,onSubmit:m,className:n,children:[t.jsxs("div",{className:`${a} flex w-full flex-col overflow-visible rounded-[16px] sm:rounded-[18px]`,children:[t.jsxs(Xu,{className:s,children:[p,g]}),b,v]}),o?t.jsx("div",{className:"mt-2 rounded-2xl border border-rose-500/40 bg-rose-500/10 px-4 py-3 text-sm text-rose-200",children:o}):null]})]})}function nm({open:e,iconButtonClassName:r,menuClassName:n,menuItemClassName:a,onToggle:s,onPickPhoto:o,onPickFile:l}){return t.jsxs("div",{className:"relative",children:[t.jsx(kt,{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(Su,{})}),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 Qo=[{mode:"read-only",label:"Read only"},{mode:"workspace-write",label:"Workspace write"},{mode:"danger-full-access",label:"Danger"}];function rs(e){var r;return((r=Qo.find(n=>n.mode===e))==null?void 0:r.label)??"Default"}function am({openMenu:e,model:r,modelOptions:n,modelContextTitle:a,contextUsage:s,reasoningEffort:o,supportedEfforts:l,displayedCollaborationMode:i,sandboxMode:d,planModeAvailable:h,sandboxModeAvailable:u,settingsBusy:m,goalComposeMode:f,goalBusy:p,activeView:g,disabled:b,fastMode:v,sendButtonLabel:x,sendButtonClassName:y,modelControlsDisabled:k,effortControlsDisabled:C,effortControlTitle:w,inlineToggleClassName:j,menuItemClassName:S,planToggleActiveClassName:L,sendButtonBaseClassName:P,onSetOpenMenu:K,onUpdateSettings:F}){return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative min-w-0",children:[t.jsx(kt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="model","aria-label":r??"Select model",disabled:k||n.length===0,onClick:()=>K(R=>R==="model"?null:"model"),title:v?`Fast mode is on. Turn it off from the slash toolbox to edit model. ${a}`:a,className:`${j} relative min-w-0 max-w-[8.75rem] overflow-hidden rounded-full px-2.5 text-left text-stone-300 disabled:cursor-not-allowed disabled:text-stone-600 sm:max-w-[11rem]`,children:t.jsx("span",{className:"relative z-[1] block min-w-0 truncate whitespace-nowrap [direction:rtl]",children:r??"Select model"})}),r?t.jsx(Du,{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(R=>t.jsx("button",{type:"button",onClick:()=>F({model:R.model,reasoningEffort:R.defaultReasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${R.model===r?"ui-status-warning":`${S} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:R.model})},R.id))})})]}),t.jsxs("div",{className:"relative",children:[t.jsx(kt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="effort",disabled:C,onClick:()=>K(R=>R==="effort"?null:"effort"),title:w,className:`${j} rounded-full px-2 disabled:cursor-not-allowed disabled:text-stone-700 ${C?"text-stone-500":"text-stone-300 hover:text-stone-100"}`,children:Ya(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(R=>t.jsx("button",{type:"button",onClick:()=>F({reasoningEffort:R.reasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${R.reasoningEffort===o?"ui-status-warning":`${S} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:Ya(R.reasoningEffort)})},R.reasoningEffort))})})]}),u&&t.jsxs("div",{className:"relative",children:[t.jsx(kt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="sandbox","aria-label":`Sandbox: ${rs(d)}`,disabled:m,onClick:()=>K(R=>R==="sandbox"?null:"sandbox"),title:`Sandbox: ${rs(d)}`,className:`${j} rounded-full px-2.5 text-stone-300 disabled:cursor-not-allowed disabled:text-stone-700`,children:"Sandbox"}),e==="sandbox"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[9rem] max-w-[13rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:Qo.map(R=>t.jsx("button",{type:"button",onClick:()=>F({sandboxMode:R.mode}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${R.mode===d?"ui-status-warning":`${S} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:R.label})},R.mode))})})]}),h&&t.jsx(kt,{type:"button",variant:"ghost",size:"xs","aria-pressed":i==="plan",disabled:m,onClick:()=>F({collaborationMode:i==="plan"?"default":"plan"}),className:`${j} rounded-full px-2.5 ${i==="plan"?`${L} border !border-[oklch(0.78_0.16_86_/_0.76)] !bg-[oklch(0.44_0.095_82_/_0.72)] !text-[oklch(0.96_0.055_92)] shadow-[0_0_0_1px_oklch(0.78_0.16_86_/_0.24),0_0_18px_oklch(0.78_0.16_86_/_0.42),inset_0_0_0_1px_oklch(0.98_0.04_96_/_0.18)]`:"text-stone-500"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Plan"}),t.jsx(kt,{type:"submit",variant:"default",size:"icon-xs","aria-label":f?"Set goal":"Send Prompt",title:x,disabled:p||(g==="chat"?b:!1),className:`${P} h-9 w-9 rounded-full text-sm font-medium disabled:cursor-not-allowed sm:h-8 sm:w-8 ${y}`,children:t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-none stroke-current",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M8 13V3"}),t.jsx("path",{d:"m4 7 4-4 4 4"})]})})]})}function sm({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(Dn,{}),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(Dn,{}),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(_t,{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(_t,{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(_t,{label:"CTRL-D"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("esc"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(_t,{label:"ESC"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("tab"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(_t,{label:"TAB"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("up"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(_t,{label:"UP"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("down"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(_t,{label:"DOWN"})})]})})}function om({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 lm({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 im({hooksPanelMode:e,hooksState:r,hostConfigFilesAvailable:n,hookTrustAvailable:a,hookConfigBusy:s,hookConfigError:o,hookConfigSuccess:l,editingHookTarget:i,hookScope:d,hookEventName:h,hookMatcher:u,hookCommand:m,hookTimeoutSec:f,hookStatusMessage:p,composerChipButtonClassName:g,onResetHookForm:b,onSetHooksPanelMode:v,onClearHookConfigStatus:x,onSetEditingHookTarget:y,onSetHookScope:k,onSetHookEventName:C,onSetHookMatcher:w,onSetHookCommand:j,onSetHookTimeoutSec:S,onSetHookStatusMessage:L,onSaveHook:P,onStartEditingHook:K,onTrustHook:F,onUntrustHook:R}){var J,Z,D,te,oe;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"Hook config sources"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:((J=r.data)==null?void 0:J.projectHooksPath)??"<workspace hooks config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:_=>{_.stopPropagation(),b(),v("add"),x()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add Hook"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading hooks..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,o?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:o}):null,l?t.jsx("p",{className:"mb-2 rounded-xl border border-emerald-500/35 bg-emerald-500/10 px-3 py-3 text-sm text-emerald-100/90",children:l}):null,e==="add"||e==="edit"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[e==="edit"?t.jsxs("p",{className:"rounded-lg border border-stone-800 bg-stone-950 px-3 py-2 text-[11px] text-stone-400",children:["Editing"," ",_u((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:_=>k(_.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:_=>C(_.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:Fr.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:_=>w(_.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:_=>j(_.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:_=>S(_.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:()=>{v("list"),y(null)},className:`${g} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void P(),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"&&((Z=r.data)!=null&&Z.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"&&((D=r.data)!=null&&D.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:[Iu(_.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:[Zo(_)?t.jsx("button",{type:"button",onClick:Y=>{Y.stopPropagation(),K(_)},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:Y=>{Y.stopPropagation(),R(_)},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:Y=>{Y.stopPropagation(),F(_)},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:Au(_.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:Ru(_.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&&(((oe=r.data)==null?void 0:oe.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 dm({mcpPanelMode:e,mcpState:r,mcpConfigEditing:n,mcpConfigPath:a,mcpConfigError:s,mcpConfigSuccess:o,mcpConfigBusy:l,mcpHttpName:i,mcpHttpUrl:d,mcpRawBlock:h,composerPanelButtonClassName:u,composerChipButtonClassName:m,onSetMcpPanelMode:f,onClearMcpConfigStatus:p,onSetMcpHttpName:g,onSetMcpHttpUrl:b,onSetMcpRawBlock:v,onPrepareRawMcpBlock:x,onSaveHttpMcp:y,onSaveRawMcpBlock:k}){var C,w;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"MCP config source"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:a??"<provider config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),f("add"),p()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add MCP"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading MCP servers..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,s?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:s}):null,o?t.jsx("p",{className:"mb-2 rounded-xl border border-emerald-500/35 bg-emerald-500/10 px-3 py-3 text-sm text-emerald-100/90",children:o}):null,e==="add"?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:j=>{j.stopPropagation(),f("http"),p()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"HTTP / Streamable HTTP"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"Form"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Add an MCP server with a name and URL, then write the matching block into provider config."})]}),t.jsxs("button",{type:"button",onClick:j=>{j.stopPropagation(),x()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"stdio / raw block"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"TOML"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Write a single `[mcp_servers.name]` block, then save it back into provider config."})]})]}):null,e==="http"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"MCP name"}),t.jsx("input",{"aria-label":"MCP name",value:i,onChange:j=>g(j.target.value),placeholder:"openaiDeveloperDocs",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"URL"}),t.jsx("input",{"aria-label":"URL",value:d,onChange:j=>b(j.target.value),placeholder:"https://developers.openai.com/mcp",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void y(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write HTTP MCP"})]})]}):null,e==="stdio"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsx("label",{className:"block text-xs text-stone-400",children:"MCP block for provider config"}),t.jsx("textarea",{"aria-label":"MCP block for provider config",value:h,onChange:j=>v(j.target.value),rows:8,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void k(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write raw block"})]})]}):null,e==="list"&&((C=r.data)!=null&&C.servers.length)?t.jsx("div",{className:"space-y-2",children:r.data.servers.map(j=>t.jsxs("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:j.name}),t.jsxs("p",{className:"mt-0.5 text-xs text-stone-400",children:[j.tools.length," tools · ",j.resourceCount," ","resources · ",j.resourceTemplateCount," templates"]})]}),t.jsx("span",{className:"shrink-0 rounded-full border border-stone-700 px-2 py-1 text-[10px] uppercase tracking-[0.14em] text-stone-300",children:Pu(j.authStatus)})]}),j.tools.length>0?t.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-stone-500",children:j.tools.slice(0,4).map(S=>S.title??S.name).join(" · ")}):null]},j.name))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((w=r.data)==null?void 0:w.servers.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No MCP servers available right now."}):null]})}function cm({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:zu(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(Dn,{}),"$",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 hm({open:e,slashPanelView:r,availableToolboxItems:n,busy:a,forkBusy:s,forkTurnOptionsState:o,skillsState:l,copiedSkillName:i,hooksPanelMode:d,hooksState:h,hostConfigFilesAvailable:u,hookTrustAvailable:m,hookConfigBusy:f,hookConfigError:p,hookConfigSuccess:g,editingHookTarget:b,hookScope:v,hookEventName:x,hookMatcher:y,hookCommand:k,hookTimeoutSec:C,hookStatusMessage:w,mcpPanelMode:j,mcpState:S,mcpConfigEditing:L,mcpConfigPath:P,mcpConfigError:K,mcpConfigSuccess:F,mcpConfigBusy:R,mcpHttpName:J,mcpHttpUrl:Z,mcpRawBlock:D,iconButtonClassName:te,menuClassName:oe,menuItemClassName:_,panelButtonClassName:Y,chipButtonClassName:I,onToggle:q,onToolboxItemClick:H,toolboxItemDisabled:E,toolboxItemClassName:W,toolboxItemStatus:O,onSetSlashPanelView:N,onOpenForkTurns:T,onForkLatest:U,onForkTurn:X,onCopySkillInvokeName:ie,onResetHookForm:Q,onSetHooksPanelMode:de,onClearHookConfigStatus:re,onSetEditingHookTarget:xe,onSetHookScope:le,onSetHookEventName:ve,onSetHookMatcher:Pe,onSetHookCommand:se,onSetHookTimeoutSec:ye,onSetHookStatusMessage:je,onSaveHook:G,onStartEditingHook:me,onTrustHook:ge,onUntrustHook:we,onSetMcpPanelMode:_e,onClearMcpConfigStatus:Re,onSetMcpHttpName:Ee,onSetMcpHttpUrl:Me,onSetMcpRawBlock:M,onPrepareRawMcpBlock:ue,onSaveHttpMcp:A,onSaveRawMcpBlock:$}){return t.jsxs("div",{className:"relative",children:[t.jsx(kt,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Open slash toolbox",title:"Open slash toolbox",onClick:q,className:`${te} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx(Tu,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${oe} 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:ee=>{ee.stopPropagation()},onMouseDown:ee=>{ee.stopPropagation()},onPointerDown:ee=>{ee.stopPropagation()},onTouchStart:ee=>{ee.stopPropagation()},children:r==="root"?t.jsxs("div",{className:"p-2",children:[n.map((ee,pe)=>t.jsx("button",{type:"button",disabled:E(ee),onClick:ke=>H(ee,ke),className:`${W(ee)} ${pe===0?"mt-0":""}`,title:ee.description??ee.label,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:ee.command}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:O(ee)})]})},`${ee.action}:${ee.command}`)),n.length===0?t.jsx("p",{className:"px-3 py-2 text-sm text-stone-400",children:"No backend tools are available for this thread."}):null]}):t.jsx("div",{className:"max-h-80 overflow-auto",children:r==="fork"?t.jsx(om,{busy:a,forkBusy:s,composerMenuItemClassName:_,onForkLatest:U,onSelectForkTurnPanel:()=>(N("forkTurns"),T())}):r==="forkTurns"?t.jsx(lm,{forkTurnOptionsState:o,forkBusy:s,composerPanelButtonClassName:Y,onForkTurn:X}):r==="skills"?t.jsx(cm,{skillsState:l,copiedSkillName:i,composerChipButtonClassName:I,onCopySkillInvokeName:ie}):r==="hooks"?t.jsx(im,{hooksPanelMode:d,hooksState:h,hostConfigFilesAvailable:u,hookTrustAvailable:m,hookConfigBusy:f,hookConfigError:p,hookConfigSuccess:g,editingHookTarget:b,hookScope:v,hookEventName:x,hookMatcher:y,hookCommand:k,hookTimeoutSec:C,hookStatusMessage:w,composerChipButtonClassName:I,onResetHookForm:Q,onSetHooksPanelMode:de,onClearHookConfigStatus:re,onSetEditingHookTarget:xe,onSetHookScope:le,onSetHookEventName:ve,onSetHookMatcher:Pe,onSetHookCommand:se,onSetHookTimeoutSec:ye,onSetHookStatusMessage:je,onSaveHook:G,onStartEditingHook:me,onTrustHook:ge,onUntrustHook:we}):t.jsx(dm,{mcpPanelMode:j,mcpState:S,mcpConfigEditing:L,mcpConfigPath:P,mcpConfigError:K,mcpConfigSuccess:F,mcpConfigBusy:R,mcpHttpName:J,mcpHttpUrl:Z,mcpRawBlock:D,composerPanelButtonClassName:Y,composerChipButtonClassName:I,onSetMcpPanelMode:_e,onClearMcpConfigStatus:Re,onSetMcpHttpName:Ee,onSetMcpHttpUrl:Me,onSetMcpRawBlock:M,onPrepareRawMcpBlock:ue,onSaveHttpMcp:A,onSaveRawMcpBlock:$})})})]})}function um({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(Zu,{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(hm,{...i}):null,!e&&d?t.jsx(nm,{...d}):null,r&&t.jsx(kt,{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(Eu,{}):t.jsx(Cu,{})})]}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-end gap-1.5",children:[!e&&h?t.jsx(am,{...h}):null,e&&a?t.jsx(Qu,{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(Lu,{})}),s==="shellTools"&&u?t.jsx(sm,{...u}):null]})]})]})}function mm(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`attachment-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function pm(e){return[...e.filter(r=>Mn(r)==="photo"),...e.filter(r=>Mn(r)==="file")]}function fm({prompt:e,attachments:r,updateDraft:n,getSelection:a,selectionSnapshotRef:s,pendingSelectionRef:o,pendingInsertedAttachmentIdsRef:l,onInserted:i,buildClientId:d=mm}){const h=c.useCallback((f,p)=>{if(f.length===0)return!1;const g=iu({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(pm(f),Mn),[h]);return{appendAttachments:u,appendDroppedAttachments:m}}function ns(e){for(const r of e.values())URL.revokeObjectURL(r);e.clear()}function gm({attachments:e,isShellView:r}){const n=c.useRef(new Map),[a,s]=c.useState({});return c.useEffect(()=>{const o=n.current;if(r){ns(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()=>{ns(o)}},[]),a}var xm=180;function gn(e,r){return{prompt:e??"",attachments:r??[]}}function bm({isShellView:e,draftPrompt:r,draftAttachments:n,onDraftChange:a}){const[s,o]=c.useState({prompt:"",attachments:[]}),[l,i]=c.useState(()=>gn(r,n)),d=c.useRef(null),h=c.useRef(l),u=c.useRef(Tr(l)),m=!e&&r!==void 0&&n!==void 0&&typeof a=="function",f=m?Tr(gn(r,n)):"",p=c.useRef(f);c.useLayoutEffect(()=>{if(!m){p.current="";return}const k=gn(r,n),C=Tr(k);C!==p.current&&(p.current=C,u.current=C,h.current=k,d.current!==null&&(window.clearTimeout(d.current),d.current=null),i(k))},[n,r,m]);const g=c.useCallback(k=>{if(!m||!a)return;const C=Tr(k);C!==u.current&&(u.current=C,a(()=>({prompt:k.prompt,attachments:k.attachments})))},[m,a]);c.useEffect(()=>()=>{g(h.current),d.current!==null&&window.clearTimeout(d.current)},[g]);const b=c.useCallback((k,C)=>{if(m){if(d.current!==null&&(window.clearTimeout(d.current),d.current=null),C==="immediate"){g(k);return}d.current=window.setTimeout(()=>{d.current=null,g(h.current)},xm)}},[m,g]),v=c.useCallback((k=h.current)=>{b(k,"immediate")},[b]),x=c.useCallback((k,C="immediate")=>{if(m){const w=k(h.current);h.current=w,i(w),b(w,C);return}o(w=>k(w))},[m,b]),y=m?l:s;return{prompt:y.prompt,attachments:y.attachments,isDraftControlled:m,updateDraft:x,flushControlledDraftToHost:v}}function vm({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 km({prompt:e,goalTokenBudgetSource:r,promptRef:n,onOpenGoal:a,onUpdateGoal:s,updateDraft:o,closeMenu:l,resetSlashPanel:i}){const[d,h]=c.useState(!1),[u,m]=c.useState(""),[f,p]=c.useState(!1),[g,b]=c.useState(null),v=c.useCallback(async()=>{const k=e.trim();if(!k)return b("Goal objective cannot be empty."),!1;const C=u.trim(),w=pu(C);if(C.length>0&&(w===null||!Number.isInteger(w)||w<=0))return b("Token budget must be a positive number in thousands."),!1;if(!s)return b("/goal is unavailable in this view."),!1;p(!0),b(null);try{return await s({objective:k,status:"active",tokenBudget:w}),m(""),h(!1),o(()=>({prompt:"",attachments:[]})),!0}catch(j){return b(j instanceof Error?j.message:"Unable to set goal."),!1}finally{p(!1)}},[u,s,e,o]),x=c.useCallback(()=>{l(),i(),h(!0),m(fu(r==null?void 0:r.tokenBudget)),b(null),a==null||a(),requestAnimationFrame(()=>{var k;(k=n.current)==null||k.focus()})},[l,r==null?void 0:r.tokenBudget,a,n,i]),y=c.useCallback(()=>{h(!1),b(null)},[]);return{goalComposeMode:d,goalTokenBudget:u,goalBusy:f,goalLocalError:g,setGoalTokenBudget:m,submitGoal:v,enterGoalComposeMode:x,exitGoalComposeMode:y}}var xn=`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 ym({slashPanelView:e,hookCommandTemplates:r,onCreateHook:n,onUpdateHook:a,onTrustHook:s,onUntrustHook:o}){const[l,i]=c.useState("list"),[d,h]=c.useState("project"),[u,m]=c.useState("preToolUse"),[f,p]=c.useState("Bash"),[g,b]=c.useState(xn),[v,x]=c.useState("30"),[y,k]=c.useState("Running hook"),[C,w]=c.useState(null),[j,S]=c.useState(!1),[L,P]=c.useState(null),[K,F]=c.useState(null),R=c.useMemo(()=>wm(r),[r]),J=c.useCallback(q=>R.get(q)??R.get("preToolUse")??xn,[R]),Z=c.useMemo(()=>new Set([xn,...R.values()]),[R]),D=c.useCallback(()=>{P(null),F(null)},[]);c.useEffect(()=>{e!=="hooks"&&(i("list"),D())},[D,e]),c.useEffect(()=>{const q=Fr.find(H=>H.value===u);p(H=>{const E=H.trim(),W=new Set(Fr.map(O=>O.matcherHint).filter(Boolean));return E&&!W.has(E)?H:(q==null?void 0:q.matcherHint)??""}),b(H=>Z.has(H.trim())?J(u):H)},[J,Z,u]);const te=c.useCallback(()=>{w(null),h("project"),m("preToolUse"),p("Bash"),b(J("preToolUse")),x("30"),k("Running hook")},[J]),oe=c.useCallback(q=>{const H=Zo(q);if(!H){P("Only command hooks in global or project hooks.json can be edited here.");return}w(H),h(H.scope),m(H.eventName),p(H.matcher??""),b(H.command),x(H.timeoutSec?String(H.timeoutSec):""),k(H.statusMessage??""),P(null),F(null),i("edit")},[]),_=c.useCallback(async()=>{if(l==="edit"&&!a){P("Hook editing is unavailable in this view.");return}if(l!=="edit"&&!n){P("Hook editing is unavailable in this view.");return}if(l==="edit"&&!C){P("Select a hook to edit first.");return}const q=g.trim();if(!q){P("Hook command cannot be empty.");return}const H=v.trim(),E=H?Number(H):null;if(H&&(E===null||!Number.isInteger(E)||E<=0)){P("Timeout must be a positive number of seconds.");return}S(!0),P(null),F(null);try{const W={scope:d,eventName:u,matcher:f.trim()||null,command:q,timeoutSec:E,statusMessage:y.trim()||null};l==="edit"?await(a==null?void 0:a({...W,target:C})):await(n==null?void 0:n(W)),F(`${d==="project"?"Project":"Global"} hook ${l==="edit"?"updated":"written"} in hooks.json and trusted.`),i("list"),w(null)}catch(W){P(W instanceof Error?W.message:"Unable to write hooks.json.")}finally{S(!1)}},[C,g,u,f,d,y,v,l,n,a]),Y=c.useCallback(async q=>{if(!s||!q.currentHash){P("Hook trust is unavailable in this view.");return}S(!0),P(null),F(null);try{await s({key:q.key,currentHash:q.currentHash}),F("Hook trusted.")}catch(H){P(H instanceof Error?H.message:"Unable to trust hook.")}finally{S(!1)}},[s]),I=c.useCallback(async q=>{if(!o){P("Hook trust is unavailable in this view.");return}S(!0),P(null),F(null);try{await o({key:q.key}),F("Hook untrusted.")}catch(H){P(H instanceof Error?H.message:"Unable to untrust hook.")}finally{S(!1)}},[o]);return{hooksPanelMode:l,hookScope:d,hookEventName:u,hookMatcher:f,hookCommand:g,hookTimeoutSec:v,hookStatusMessage:y,editingHookTarget:C,hookConfigBusy:j,hookConfigError:L,hookConfigSuccess:K,setHooksPanelMode:i,setEditingHookTarget:w,setHookScope:h,setHookEventName:m,setHookMatcher:p,setHookCommand:b,setHookTimeoutSec:x,setHookStatusMessage:k,clearHookConfigStatus:D,resetHookForm:te,startEditingHook:oe,saveHook:_,trustHook:Y,untrustHook:I}}var jm=`[mcp_servers.example_stdio]
3655
+ ${o}`:o}function Yo(e){return typeof e!="number"||Number.isNaN(e)?0:Math.max(0,Math.min(100,Math.round(e)))}function pn(e){const r=e/1e3;return Number.isInteger(r)?`${r}k`:`${Number(r.toFixed(1))}k`}function vu(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,`${pn(n)} used / ${pn(a)}`,`${pn(o)} left`,`${Yo(r.remainingPercent)}% context left`].join(" · ")}function ku(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 wu(e){return e.replace(/[\r\n[\]]+/g," ").replace(/\s+/g," ").trim()||"attachment"}function _n(e){return e.type.startsWith("image/")?"photo":"file"}function Mn(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 Ja(e,r){return Mn(e,r).length>0}function yu(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function Qa(e){const r=e.placeholder.match(/^\[(?:PHOTO|FILE)\s+(.+)\]$/);return r!=null&&r[1]?r[1]:yu(e.originalName)}var Hr=[{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 ju({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 Nu({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 Cu(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.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 Su(){return t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",children:t.jsx("path",{d:"M8 3.25v9.5M3.25 8h9.5"})})}function Tu(){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 Eu(){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 Lu(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",className:"h-3.5 w-3.5 fill-current",children:[t.jsx("path",{fillRule:"evenodd",d:"M14.5 10C16.9853 10 19 7.98528 19 5.5C19 5.01783 18.9242 4.55338 18.7838 4.11791C18.6792 3.79367 18.2734 3.72683 18.0325 3.96772L15.3402 6.66002C15.2098 6.79041 15.0168 6.84163 14.8466 6.77074C14.1172 6.46695 13.5334 5.88351 13.2292 5.15431C13.1582 4.98403 13.2094 4.79088 13.3398 4.66042L16.0327 1.9676C16.2735 1.72672 16.2067 1.32092 15.8825 1.21636C15.4469 1.07588 14.9823 1 14.5 1C12.0147 1 10 3.01472 10 5.5C10 5.59783 10.0031 5.69494 10.0093 5.79122C10.065 6.66418 9.88174 7.59855 9.20974 8.15855L1.98017 14.1832C1.3591 14.7008 1 15.4674 1 16.2759C1 17.7804 2.21962 19 3.7241 19C4.53256 19 5.29925 18.6409 5.81681 18.0198L11.8414 10.7903C12.4014 10.1183 13.3358 9.93497 14.2088 9.99073C14.3051 9.99688 14.4022 10 14.5 10ZM5 16C5 16.5523 4.55228 17 4 17C3.44772 17 3 16.5523 3 16C3 15.4477 3.44772 15 4 15C4.55228 15 5 15.4477 5 16Z",clipRule:"evenodd"}),t.jsx("path",{d:"M14.5 11.5C14.6731 11.5 14.8445 11.4927 15.0138 11.4783L18.7678 15.2323C19.7441 16.2086 19.7441 17.7915 18.7678 18.7678C17.7915 19.7441 16.2086 19.7441 15.2323 18.7678L10.8216 14.3571L12.9938 11.7505C13.0455 11.6885 13.1413 11.6131 13.3357 11.5552C13.5378 11.4951 13.805 11.468 14.1132 11.4877C14.2413 11.4959 14.3702 11.5 14.5 11.5Z"}),t.jsx("path",{d:"M6.00003 4.58582L8.33056 6.91635C8.3027 6.95627 8.27496 6.98497 8.24946 7.00622L6.79994 8.21415L4.58582 6.00003H3.30905C3.11966 6.00003 2.94653 5.89303 2.86184 5.72364L1.1612 2.32237C1.06495 2.12987 1.10268 1.89739 1.25486 1.74521L1.74521 1.25486C1.89739 1.10268 2.12987 1.06495 2.32237 1.1612L5.72364 2.86184C5.89303 2.94653 6.00003 3.11966 6.00003 3.30905V4.58582Z"})]})}function $n(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5.5 3.25h5"}),t.jsx("path",{d:"M6.4 2h3.2a.9.9 0 0 1 .9.9v.35h1.3a1.2 1.2 0 0 1 1.2 1.2v7.35a1.2 1.2 0 0 1-1.2 1.2H4.2A1.2 1.2 0 0 1 3 11.8V4.45a1.2 1.2 0 0 1 1.2-1.2h1.3V2.9a.9.9 0 0 1 .9-.9Z"})]})}function Pu(e){switch(e){case"bearerToken":return"Token";case"oAuth":return"OAuth";case"notLoggedIn":return"Login";case"unsupported":return"Public";default:return"Unknown"}}function zu(e){switch(e){case"repo":return"Repo";case"system":return"System";case"admin":return"Admin";case"user":default:return"User"}}function Iu(e){var r;return((r=Hr.find(n=>n.value===e))==null?void 0:r.label)??e}function Ru(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 Au(e){switch(e){case"managed":return"Managed";case"modified":return"Modified";case"trusted":return"Trusted";case"untrusted":return"Review"}}function _u(e){switch(e){case"preToolUse":return"PreToolUse";case"permissionRequest":return"PermissionRequest";case"postToolUse":return"PostToolUse";case"preCompact":return"PreCompact";case"postCompact":return"PostCompact";case"sessionStart":return"SessionStart";case"userPromptSubmit":return"UserPromptSubmit";case"stop":return"Stop"}}function Mu(e){return e.source==="user"?"global":e.source==="project"?"project":null}function Zo(e){const r=Mu(e);return!r||e.handlerType!=="command"||!e.command||e.isManaged?null:{scope:r,eventName:e.eventName,matcher:e.matcher,command:e.command,timeoutSec:e.timeoutSec,statusMessage:e.statusMessage}}function $u(e){switch(e){case"active":return"Active";case"paused":return"Paused";case"budgetLimited":return"Budget";case"complete":return"Complete";default:return e}}function Du({contextUsage:e}){const r=(e==null?void 0:e.availability)??"unavailable",n=Yo(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 _t({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 Bu(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 Gu(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 Fu(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?$u(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 Hu(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 Ou(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 Uu(e){if(!e)return"";const r=document.createElement("div");return r.innerHTML=e,r.textContent??""}function Wu(e){return!!e.querySelector("[style], font")}function $t(e){return e instanceof HTMLElement&&e.dataset.segmentType==="attachment"&&e.dataset.placeholder?e.dataset.placeholder:e.textContent??""}function Jo(e){let r="";for(const n of Array.from(e.childNodes))r+=$t(n);return r.replace(/\u00a0/g," ")}function es(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+=$t(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 Jo(e).length;if(a=d,d instanceof HTMLElement&&d.dataset.segmentType==="attachment"){const h=document.createRange();h.selectNodeContents(d);const u=$t(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=$t(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,$t(d).length);l+=$t(d).length}return l}function Vu(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:es(e,n.startContainer,n.startOffset),end:es(e,n.endContainer,n.endOffset)}}function ts(e,r){let n=Math.max(0,r);const a=Array.from(e.childNodes);for(const[o,s]of a.entries()){const i=$t(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 Ku(e,r){const n=ts(e,r.start),a=ts(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 qu(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}Xr();Pt();function Xu({className:e,...r}){return t.jsx("div",{"data-slot":"input-group",role:"group",className:nt("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 Yu=vr("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 Zu({className:e,align:r="inline-start",...n}){return t.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":r,className:nt(Yu({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 Ju=vr("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 kt({className:e,type:r="button",variant:n="ghost",size:a="xs",...o}){return t.jsx(br,{type:r,"data-size":a,variant:n,className:nt(Ju({size:a}),e),...o})}function Qu({className:e,...r}){return t.jsx("span",{className:nt("flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*=size-])]:size-4",e),...r})}function em({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 tm({activeView:e,followTail:r,onToggleFollow:n}){return e!=="chat"?null:t.jsx("button",{type:"button","aria-label":"Jump to latest",title:r?"Latest turn is in view":"Jump to the latest messages",onClick:()=>n==null?void 0:n(),className:"absolute left-1/2 top-0 z-[90] inline-flex h-11 min-w-[7rem] -translate-x-1/2 -translate-y-full items-end justify-center bg-transparent pb-1 touch-manipulation sm:h-10",children:t.jsx("span",{className:`thread-jump-latest-badge pointer-events-none inline-flex h-4 min-w-[3.75rem] items-center justify-center rounded-[0.7rem] border shadow-sm transition ${r?"is-active border-sky-300/36 bg-sky-300/[0.03] text-sky-100/86":"border-stone-500/70 bg-stone-950/[0.08] text-stone-200/86"}`,children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m4 6 4 4 4-4"})})})})}function rm({activeView:e,layerClassName:r,formClassName:n,shellClassName:a,inputGroupClassName:o,error:s,followTail:l,photoInputRef:i,fileInputRef:d,onAppendAttachments:h,onToggleFollow:u,onSubmit:m,formRef:f,promptSlot:p,toolbarSlot:g,goalSlot:b,shellPromptSlot:w}){return t.jsxs("div",{className:r,children:[t.jsx(em,{photoInputRef:i,fileInputRef:d,onAppendAttachments:h}),t.jsx(tm,{activeView:e,followTail:l,onToggleFollow:u}),t.jsxs("form",{ref:f,"data-testid":e==="chat"?"chat-composer":void 0,onSubmit:m,className:n,children:[t.jsxs("div",{className:`${a} flex w-full flex-col overflow-visible rounded-[16px] sm:rounded-[18px]`,children:[t.jsxs(Xu,{className:o,children:[p,g]}),b,w]}),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 nm({open:e,iconButtonClassName:r,menuClassName:n,menuItemClassName:a,onToggle:o,onPickPhoto:s,onPickFile:l}){return t.jsxs("div",{className:"relative",children:[t.jsx(kt,{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(Su,{})}),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 Qo=[{mode:"read-only",label:"Read only"},{mode:"workspace-write",label:"Workspace write"},{mode:"danger-full-access",label:"Danger"}];function rs(e){var r;return((r=Qo.find(n=>n.mode===e))==null?void 0:r.label)??"Default"}function am({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:y,modelControlsDisabled:k,effortControlsDisabled:j,effortControlTitle:v,inlineToggleClassName:N,menuItemClassName:S,planToggleActiveClassName:L,sendButtonBaseClassName:P,onSetOpenMenu:K,onUpdateSettings:F}){return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative min-w-0",children:[t.jsx(kt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="model","aria-label":r??"Select model",disabled:k||n.length===0,onClick:()=>K(D=>D==="model"?null:"model"),title:w?`Fast mode is on. Turn it off from the slash toolbox to edit model. ${a}`:a,className:`${N} relative min-w-0 max-w-[8.75rem] overflow-hidden rounded-full px-2.5 text-left text-stone-300 disabled:cursor-not-allowed disabled:text-stone-600 sm:max-w-[11rem]`,children:t.jsx("span",{className:"relative z-[1] block min-w-0 truncate whitespace-nowrap [direction:rtl]",children:r??"Select model"})}),r?t.jsx(Du,{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:()=>F({model:D.model,reasoningEffort:D.defaultReasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${D.model===r?"ui-status-warning":`${S} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:D.model})},D.id))})})]}),t.jsxs("div",{className:"relative",children:[t.jsx(kt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="effort",disabled:j,onClick:()=>K(D=>D==="effort"?null:"effort"),title:v,className:`${N} rounded-full px-2 disabled:cursor-not-allowed disabled:text-stone-700 ${j?"text-stone-500":"text-stone-300 hover:text-stone-100"}`,children:Ya(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:()=>F({reasoningEffort:D.reasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${D.reasoningEffort===s?"ui-status-warning":`${S} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:Ya(D.reasoningEffort)})},D.reasoningEffort))})})]}),u&&t.jsxs("div",{className:"relative",children:[t.jsx(kt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="sandbox","aria-label":`Sandbox: ${rs(d)}`,disabled:m,onClick:()=>K(D=>D==="sandbox"?null:"sandbox"),title:`Sandbox: ${rs(d)}`,className:`${N} rounded-full px-2.5 text-stone-300 disabled:cursor-not-allowed disabled:text-stone-700`,children:"Sandbox"}),e==="sandbox"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[9rem] max-w-[13rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:Qo.map(D=>t.jsx("button",{type:"button",onClick:()=>F({sandboxMode:D.mode}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${D.mode===d?"ui-status-warning":`${S} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:D.label})},D.mode))})})]}),h&&t.jsx(kt,{type:"button",variant:"ghost",size:"xs","aria-pressed":i==="plan",disabled:m,onClick:()=>F({collaborationMode:i==="plan"?"default":"plan"}),className:`${N} rounded-full px-2.5 ${i==="plan"?`${L} border !border-[oklch(0.78_0.16_86_/_0.76)] !bg-[oklch(0.44_0.095_82_/_0.72)] !text-[oklch(0.96_0.055_92)] shadow-[0_0_0_1px_oklch(0.78_0.16_86_/_0.24),0_0_18px_oklch(0.78_0.16_86_/_0.42),inset_0_0_0_1px_oklch(0.98_0.04_96_/_0.18)]`:"text-stone-500"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Plan"}),t.jsx(kt,{type:"submit",variant:"default",size:"icon-xs","aria-label":f?"Set goal":"Send Prompt",title:x,disabled:p||(g==="chat"?b:!1),className:`${P} h-9 w-9 rounded-full text-sm font-medium disabled:cursor-not-allowed sm:h-8 sm:w-8 ${y}`,children:t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-none stroke-current",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M8 13V3"}),t.jsx("path",{d:"m4 7 4-4 4 4"})]})})]})}function sm({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($n,{}),t.jsx("span",{className:"text-[10px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:a,className:"inline-flex items-center justify-center rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-2 text-stone-100",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx($n,{}),t.jsx("span",{className:"text-[10px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:e,onClick:o,className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(_t,{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(_t,{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(_t,{label:"CTRL-D"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("esc"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(_t,{label:"ESC"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("tab"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(_t,{label:"TAB"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("up"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(_t,{label:"UP"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("down"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(_t,{label:"DOWN"})})]})})}function om({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 lm({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 im({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:y,onSetHookScope:k,onSetHookEventName:j,onSetHookMatcher:v,onSetHookCommand:N,onSetHookTimeoutSec:S,onSetHookStatusMessage:L,onSaveHook:P,onStartEditingHook:K,onTrustHook:F,onUntrustHook:D}){var Z,Y,$,te,oe;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:A=>{A.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"," ",_u((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:A=>k(A.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:A=>j(A.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:Hr.map(A=>t.jsx("option",{value:A.value,children:A.label},A.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:A=>v(A.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:A=>N(A.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:A=>S(A.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:A=>L(A.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"),y(null)},className:`${g} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void P(),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"&&((Y=r.data)!=null&&Y.warnings.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.warnings.map(A=>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:A},A))}):null,e==="list"&&(($=r.data)!=null&&$.errors.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.errors.map(A=>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:A.message}),t.jsx("p",{className:"mt-1 break-all text-rose-100/60",children:A.path})]},`${A.path}:${A.message}`))}):null,e==="list"&&((te=r.data)!=null&&te.hooks.length)?t.jsx("div",{className:"space-y-2",children:r.data.hooks.map(A=>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:[Iu(A.eventName),A.matcher?` · ${A.matcher}`:""]}),t.jsx("p",{className:"mt-0.5 truncate font-mono text-[11px] text-stone-400",children:A.command??A.handlerType}),A.statusMessage?t.jsx("p",{className:"mt-1 truncate text-[11px] text-stone-500",children:A.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:[Zo(A)?t.jsx("button",{type:"button",onClick:J=>{J.stopPropagation(),K(A)},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&&A.trustStatus==="trusted"&&!A.isManaged?t.jsx("button",{type:"button",disabled:o,onClick:J=>{J.stopPropagation(),D(A)},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,(A.trustStatus==="untrusted"||A.trustStatus==="modified")&&!A.isManaged&&a?t.jsx("button",{type:"button",disabled:o||!A.currentHash,onClick:J=>{J.stopPropagation(),F(A)},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:Au(A.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:Ru(A.source)}),t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:A.enabled?"Enabled":"Disabled"}),t.jsxs("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:[A.timeoutSec,"s"]})]})]},A.key))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((oe=r.data)==null?void 0:oe.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 dm({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:y,onSaveRawMcpBlock:k}){var j,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:N=>{N.stopPropagation(),f("add"),p()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add MCP"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading MCP servers..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,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:N=>{N.stopPropagation(),f("http"),p()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"HTTP / Streamable HTTP"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"Form"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Add an MCP server with a name and URL, then write the matching block into provider config."})]}),t.jsxs("button",{type:"button",onClick:N=>{N.stopPropagation(),x()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"stdio / raw block"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"TOML"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Write a single `[mcp_servers.name]` block, then save it back into provider config."})]})]}):null,e==="http"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"MCP name"}),t.jsx("input",{"aria-label":"MCP name",value:i,onChange:N=>g(N.target.value),placeholder:"openaiDeveloperDocs",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"URL"}),t.jsx("input",{"aria-label":"URL",value:d,onChange:N=>b(N.target.value),placeholder:"https://developers.openai.com/mcp",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void y(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write HTTP MCP"})]})]}):null,e==="stdio"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsx("label",{className:"block text-xs text-stone-400",children:"MCP block for provider config"}),t.jsx("textarea",{"aria-label":"MCP block for provider config",value:h,onChange:N=>w(N.target.value),rows:8,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void k(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write raw block"})]})]}):null,e==="list"&&((j=r.data)!=null&&j.servers.length)?t.jsx("div",{className:"space-y-2",children:r.data.servers.map(N=>t.jsxs("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:N.name}),t.jsxs("p",{className:"mt-0.5 text-xs text-stone-400",children:[N.tools.length," tools · ",N.resourceCount," ","resources · ",N.resourceTemplateCount," templates"]})]}),t.jsx("span",{className:"shrink-0 rounded-full border border-stone-700 px-2 py-1 text-[10px] uppercase tracking-[0.14em] text-stone-300",children:Pu(N.authStatus)})]}),N.tools.length>0?t.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-stone-500",children:N.tools.slice(0,4).map(S=>S.title??S.name).join(" · ")}):null]},N.name))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((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 cm({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:zu(d.scope)}),t.jsxs("button",{type:"button",className:`inline-flex items-center gap-1 rounded-full border px-2 py-1 normal-case tracking-normal transition ${r===d.name?"border-emerald-400/45 bg-emerald-400/12 text-emerald-100":`${n} border-stone-700 text-stone-300 hover:border-stone-500`}`,onClick:()=>void a(d.name),title:`Copy $${d.name}`,"aria-label":`Copy $${d.name}`,children:[t.jsx($n,{}),"$",d.name]})]}),t.jsx("p",{className:"text-xs leading-5 text-stone-400",children:((u=d.interface)==null?void 0:u.shortDescription)??d.shortDescription??d.description})]})},d.path)})}):null,(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 hm({open:e,slashPanelView:r,availableToolboxItems:n,busy:a,forkBusy:o,forkTurnOptionsState:s,skillsState:l,copiedSkillName:i,hooksPanelMode:d,hooksState:h,hostConfigFilesAvailable:u,hookTrustAvailable:m,hookConfigBusy:f,hookConfigError:p,hookConfigSuccess:g,editingHookTarget:b,hookScope:w,hookEventName:x,hookMatcher:y,hookCommand:k,hookTimeoutSec:j,hookStatusMessage:v,mcpPanelMode:N,mcpState:S,mcpConfigEditing:L,mcpConfigPath:P,mcpConfigError:K,mcpConfigSuccess:F,mcpConfigBusy:D,mcpHttpName:Z,mcpHttpUrl:Y,mcpRawBlock:$,iconButtonClassName:te,menuClassName:oe,menuItemClassName:A,panelButtonClassName:J,chipButtonClassName:I,onToggle:q,onToolboxItemClick:O,toolboxItemDisabled:T,toolboxItemClassName:U,toolboxItemStatus:H,onSetSlashPanelView:C,onOpenForkTurns:E,onForkLatest:X,onForkTurn:W,onCopySkillInvokeName:le,onResetHookForm:Q,onSetHooksPanelMode:de,onClearHookConfigStatus:re,onSetEditingHookTarget:xe,onSetHookScope:ie,onSetHookEventName:ve,onSetHookMatcher:Pe,onSetHookCommand:se,onSetHookTimeoutSec:ye,onSetHookStatusMessage:je,onSaveHook:G,onStartEditingHook:me,onTrustHook:ge,onUntrustHook:we,onSetMcpPanelMode:_e,onClearMcpConfigStatus:Re,onSetMcpHttpName:Ee,onSetMcpHttpUrl:Me,onSetMcpRawBlock:_,onPrepareRawMcpBlock:ue,onSaveHttpMcp:R,onSaveRawMcpBlock:M}){return t.jsxs("div",{className:"relative",children:[t.jsx(kt,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Open slash toolbox",title:"Open slash toolbox",onClick:q,className:`${te} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx(Tu,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${oe} 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:ee=>{ee.stopPropagation()},onMouseDown:ee=>{ee.stopPropagation()},onPointerDown:ee=>{ee.stopPropagation()},onTouchStart:ee=>{ee.stopPropagation()},children:r==="root"?t.jsxs("div",{className:"p-2",children:[n.map((ee,pe)=>t.jsx("button",{type:"button",disabled:T(ee),onClick:ke=>O(ee,ke),className:`${U(ee)} ${pe===0?"mt-0":""}`,title:ee.description??ee.label,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:ee.command}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:H(ee)})]})},`${ee.action}:${ee.command}`)),n.length===0?t.jsx("p",{className:"px-3 py-2 text-sm text-stone-400",children:"No backend tools are available for this thread."}):null]}):t.jsx("div",{className:"max-h-80 overflow-auto",children:r==="fork"?t.jsx(om,{busy:a,forkBusy:o,composerMenuItemClassName:A,onForkLatest:X,onSelectForkTurnPanel:()=>(C("forkTurns"),E())}):r==="forkTurns"?t.jsx(lm,{forkTurnOptionsState:s,forkBusy:o,composerPanelButtonClassName:J,onForkTurn:W}):r==="skills"?t.jsx(cm,{skillsState:l,copiedSkillName:i,composerChipButtonClassName:I,onCopySkillInvokeName:le}):r==="hooks"?t.jsx(im,{hooksPanelMode:d,hooksState:h,hostConfigFilesAvailable:u,hookTrustAvailable:m,hookConfigBusy:f,hookConfigError:p,hookConfigSuccess:g,editingHookTarget:b,hookScope:w,hookEventName:x,hookMatcher:y,hookCommand:k,hookTimeoutSec:j,hookStatusMessage:v,composerChipButtonClassName:I,onResetHookForm:Q,onSetHooksPanelMode:de,onClearHookConfigStatus:re,onSetEditingHookTarget:xe,onSetHookScope:ie,onSetHookEventName:ve,onSetHookMatcher:Pe,onSetHookCommand:se,onSetHookTimeoutSec:ye,onSetHookStatusMessage:je,onSaveHook:G,onStartEditingHook:me,onTrustHook:ge,onUntrustHook:we}):t.jsx(dm,{mcpPanelMode:N,mcpState:S,mcpConfigEditing:L,mcpConfigPath:P,mcpConfigError:K,mcpConfigSuccess:F,mcpConfigBusy:D,mcpHttpName:Z,mcpHttpUrl:Y,mcpRawBlock:$,composerPanelButtonClassName:J,composerChipButtonClassName:I,onSetMcpPanelMode:_e,onClearMcpConfigStatus:Re,onSetMcpHttpName:Ee,onSetMcpHttpUrl:Me,onSetMcpRawBlock:_,onPrepareRawMcpBlock:ue,onSaveHttpMcp:R,onSaveRawMcpBlock:M})})})]})}function um({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(Zu,{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(hm,{...i}):null,!e&&d?t.jsx(nm,{...d}):null,r&&t.jsx(kt,{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(Eu,{}):t.jsx(Cu,{})})]}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-end gap-1.5",children:[!e&&h?t.jsx(am,{...h}):null,e&&a?t.jsx(Qu,{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(Lu,{})}),o==="shellTools"&&u?t.jsx(sm,{...u}):null]})]})]})}function mm(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`attachment-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function pm(e){return[...e.filter(r=>_n(r)==="photo"),...e.filter(r=>_n(r)==="file")]}function fm({prompt:e,attachments:r,updateDraft:n,getSelection:a,selectionSnapshotRef:o,pendingSelectionRef:s,pendingInsertedAttachmentIdsRef:l,onInserted:i,buildClientId:d=mm}){const h=c.useCallback((f,p)=>{if(f.length===0)return!1;const g=iu({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(pm(f),_n),[h]);return{appendAttachments:u,appendDroppedAttachments:m}}function ns(e){for(const r of e.values())URL.revokeObjectURL(r);e.clear()}function gm({attachments:e,isShellView:r}){const n=c.useRef(new Map),[a,o]=c.useState({});return c.useEffect(()=>{const s=n.current;if(r){ns(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()=>{ns(s)}},[]),a}var xm=180;function fn(e,r){return{prompt:e??"",attachments:r??[]}}function bm({isShellView:e,draftPrompt:r,draftAttachments:n,onDraftChange:a}){const[o,s]=c.useState({prompt:"",attachments:[]}),[l,i]=c.useState(()=>fn(r,n)),d=c.useRef(null),h=c.useRef(l),u=c.useRef(Er(l)),m=!e&&r!==void 0&&n!==void 0&&typeof a=="function",f=m?Er(fn(r,n)):"",p=c.useRef(f);c.useLayoutEffect(()=>{if(!m){p.current="";return}const k=fn(r,n),j=Er(k);j!==p.current&&(p.current=j,u.current=j,h.current=k,d.current!==null&&(window.clearTimeout(d.current),d.current=null),i(k))},[n,r,m]);const g=c.useCallback(k=>{if(!m||!a)return;const j=Er(k);j!==u.current&&(u.current=j,a(()=>({prompt:k.prompt,attachments:k.attachments})))},[m,a]);c.useEffect(()=>()=>{g(h.current),d.current!==null&&window.clearTimeout(d.current)},[g]);const b=c.useCallback((k,j)=>{if(m){if(d.current!==null&&(window.clearTimeout(d.current),d.current=null),j==="immediate"){g(k);return}d.current=window.setTimeout(()=>{d.current=null,g(h.current)},xm)}},[m,g]),w=c.useCallback((k=h.current)=>{b(k,"immediate")},[b]),x=c.useCallback((k,j="immediate")=>{if(m){const v=k(h.current);h.current=v,i(v),b(v,j);return}s(v=>k(v))},[m,b]),y=m?l:o;return{prompt:y.prompt,attachments:y.attachments,isDraftControlled:m,updateDraft:x,flushControlledDraftToHost:w}}function vm({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 km({prompt:e,goalTokenBudgetSource:r,promptRef:n,onOpenGoal:a,onUpdateGoal:o,updateDraft:s,closeMenu:l,resetSlashPanel:i}){const[d,h]=c.useState(!1),[u,m]=c.useState(""),[f,p]=c.useState(!1),[g,b]=c.useState(null),w=c.useCallback(async()=>{const k=e.trim();if(!k)return b("Goal objective cannot be empty."),!1;const j=u.trim(),v=pu(j);if(j.length>0&&(v===null||!Number.isInteger(v)||v<=0))return b("Token budget must be a positive number in thousands."),!1;if(!o)return b("/goal is unavailable in this view."),!1;p(!0),b(null);try{return await o({objective:k,status:"active",tokenBudget:v}),m(""),h(!1),s(()=>({prompt:"",attachments:[]})),!0}catch(N){return b(N instanceof Error?N.message:"Unable to set goal."),!1}finally{p(!1)}},[u,o,e,s]),x=c.useCallback(()=>{l(),i(),h(!0),m(fu(r==null?void 0:r.tokenBudget)),b(null),a==null||a(),requestAnimationFrame(()=>{var k;(k=n.current)==null||k.focus()})},[l,r==null?void 0:r.tokenBudget,a,n,i]),y=c.useCallback(()=>{h(!1),b(null)},[]);return{goalComposeMode:d,goalTokenBudget:u,goalBusy:f,goalLocalError:g,setGoalTokenBudget:m,submitGoal:w,enterGoalComposeMode:x,exitGoalComposeMode:y}}var gn=`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 ym({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(gn),[w,x]=c.useState("30"),[y,k]=c.useState("Running hook"),[j,v]=c.useState(null),[N,S]=c.useState(!1),[L,P]=c.useState(null),[K,F]=c.useState(null),D=c.useMemo(()=>wm(r),[r]),Z=c.useCallback(q=>D.get(q)??D.get("preToolUse")??gn,[D]),Y=c.useMemo(()=>new Set([gn,...D.values()]),[D]),$=c.useCallback(()=>{P(null),F(null)},[]);c.useEffect(()=>{e!=="hooks"&&(i("list"),$())},[$,e]),c.useEffect(()=>{const q=Hr.find(O=>O.value===u);p(O=>{const T=O.trim(),U=new Set(Hr.map(H=>H.matcherHint).filter(Boolean));return T&&!U.has(T)?O:(q==null?void 0:q.matcherHint)??""}),b(O=>Y.has(O.trim())?Z(u):O)},[Z,Y,u]);const te=c.useCallback(()=>{v(null),h("project"),m("preToolUse"),p("Bash"),b(Z("preToolUse")),x("30"),k("Running hook")},[Z]),oe=c.useCallback(q=>{const O=Zo(q);if(!O){P("Only command hooks in global or project hooks.json can be edited here.");return}v(O),h(O.scope),m(O.eventName),p(O.matcher??""),b(O.command),x(O.timeoutSec?String(O.timeoutSec):""),k(O.statusMessage??""),P(null),F(null),i("edit")},[]),A=c.useCallback(async()=>{if(l==="edit"&&!a){P("Hook editing is unavailable in this view.");return}if(l!=="edit"&&!n){P("Hook editing is unavailable in this view.");return}if(l==="edit"&&!j){P("Select a hook to edit first.");return}const q=g.trim();if(!q){P("Hook command cannot be empty.");return}const O=w.trim(),T=O?Number(O):null;if(O&&(T===null||!Number.isInteger(T)||T<=0)){P("Timeout must be a positive number of seconds.");return}S(!0),P(null),F(null);try{const U={scope:d,eventName:u,matcher:f.trim()||null,command:q,timeoutSec:T,statusMessage:y.trim()||null};l==="edit"?await(a==null?void 0:a({...U,target:j})):await(n==null?void 0:n(U)),F(`${d==="project"?"Project":"Global"} hook ${l==="edit"?"updated":"written"} in hooks.json and trusted.`),i("list"),v(null)}catch(U){P(U instanceof Error?U.message:"Unable to write hooks.json.")}finally{S(!1)}},[j,g,u,f,d,y,w,l,n,a]),J=c.useCallback(async q=>{if(!o||!q.currentHash){P("Hook trust is unavailable in this view.");return}S(!0),P(null),F(null);try{await o({key:q.key,currentHash:q.currentHash}),F("Hook trusted.")}catch(O){P(O instanceof Error?O.message:"Unable to trust hook.")}finally{S(!1)}},[o]),I=c.useCallback(async q=>{if(!s){P("Hook trust is unavailable in this view.");return}S(!0),P(null),F(null);try{await s({key:q.key}),F("Hook untrusted.")}catch(O){P(O instanceof Error?O.message:"Unable to untrust hook.")}finally{S(!1)}},[s]);return{hooksPanelMode:l,hookScope:d,hookEventName:u,hookMatcher:f,hookCommand:g,hookTimeoutSec:w,hookStatusMessage:y,editingHookTarget:j,hookConfigBusy:N,hookConfigError:L,hookConfigSuccess:K,setHooksPanelMode:i,setEditingHookTarget:v,setHookScope:h,setHookEventName:m,setHookMatcher:p,setHookCommand:b,setHookTimeoutSec:x,setHookStatusMessage:k,clearHookConfigStatus:$,resetHookForm:te,startEditingHook:oe,saveHook:A,trustHook:J,untrustHook:I}}var jm=`[mcp_servers.example_stdio]
3656
3656
  command = "npx"
3657
3657
  args = ["-y", "your-mcp-server"]
3658
- `,as="MCP entry written to provider config. Restart the backend if it does not appear immediately.";function Nm({hostConfigFilesAvailable:e,onReadProviderConfig:r,onWriteProviderConfig:n,setMcpPanelMode:a,onOpenMcp:s}){const[o,l]=c.useState(""),[i,d]=c.useState(""),[h,u]=c.useState(""),[m,f]=c.useState(null),[p,g]=c.useState(!1),[b,v]=c.useState(null),[x,y]=c.useState(null),k=c.useCallback(()=>{v(null),y(null)},[]),C=c.useCallback(async()=>{if(!e||!r)throw new Error("Provider config editing is unavailable for this thread.");const P=await r();return f(P.path),P},[e,r]),w=c.useCallback(async P=>{if(!e||!n)throw new Error("Provider config editing is unavailable for this thread.");const K=await n(P);return f(K.path),K},[e,n]),j=c.useCallback(async()=>{const P=gu(o),K=i.trim();if(!P){v("MCP name must use only letters, numbers, underscore, or hyphen.");return}if(!/^https?:\/\//i.test(K)){v("HTTP MCP URL must start with http:// or https://");return}g(!0),v(null),y(null);try{const F=await C(),R=Za(F.content,P,bu(P,K));await w(R),y(as),a("list"),l(""),d(""),s==null||s()}catch(F){v(F instanceof Error?F.message:"Unable to update provider config.")}finally{g(!1)}},[C,o,i,s,a,w]),S=c.useCallback(async()=>{g(!0),v(null),y(null);try{await C(),u(P=>P||jm),a("stdio")}catch(P){v(P instanceof Error?P.message:"Unable to load provider config.")}finally{g(!1)}},[C,a]),L=c.useCallback(async()=>{const P=xu(h);if(!P){v("The raw MCP block must start with a header like [mcp_servers.name].");return}g(!0),v(null),y(null);try{const K=await C(),F=Za(K.content,P,h);await w(F),y(as),a("list"),s==null||s()}catch(K){v(K instanceof Error?K.message:"Unable to update provider config.")}finally{g(!1)}},[C,h,s,a,w]);return{mcpHttpName:o,mcpHttpUrl:i,mcpRawBlock:h,mcpConfigPath:m,mcpConfigBusy:p,mcpConfigError:b,mcpConfigSuccess:x,setMcpHttpName:l,setMcpHttpUrl:d,setMcpRawBlock:u,clearMcpConfigStatus:k,prepareRawMcpBlock:S,saveHttpMcp:j,saveRawMcpBlock:L}}function Cm({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 Sm(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=Qa(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=Qa(n),a.append(s,o),a}function Tm(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(Sm(a,r))}return n}function Em({promptRef:e,isShellView:r,prompt:n,promptSegments:a,attachmentPreviewUrls:s,previewSignature:o,editorSanitizeNonce:l,pendingSelectionRef:i,pendingInsertedAttachmentIdsRef:d,selectionSnapshotRef:h,renderedPreviewSignatureRef:u,renderedSanitizeNonceRef:m,serializeEditorPrompt:f,restoreSelection:p}){c.useLayoutEffect(()=>{const g=e.current;if(!g||r)return;const b=i.current,v=f()!==n||u.current!==o||m.current!==l;v&&(g.replaceChildren(Tm(a,s)),u.current=o,m.current=l),b!==null?(g.focus(),qu(g,d.current)||p(b),h.current=b):document.activeElement===g&&v&&p(h.current),i.current=null,d.current=[]},[s,l,r,o,n,e,a,d,i,u,m,p,h,f])}function Lm({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 Pm({promptRef:e,prompt:r,disabled:n,promptPlaceholder:a,canInterrupt:s,interruptLabel:o,composerPromptRegionClassName:l,graphChatInputClassName:i,onInterrupt:d,onInput:h,onPaste:u,onKeyDown:m,onKeyUp:f,onMouseUp:p,onBlur:g,onDragEnter:b,onDragOver:v,onDragLeave:x,onDrop:y}){return t.jsxs("div",{"data-slot":"input-group-control",className:`${l} relative w-full`,children:[t.jsxs("div",{className:i,children:[r.length===0&&t.jsx("span",{className:`pointer-events-none absolute left-3 top-3 truncate text-slate-500 sm:left-4 sm:top-4 dark:text-slate-400 ${s?"right-12":"right-3 sm:right-4"}`,children:a}),t.jsx("div",{ref:e,role:"textbox","aria-label":"Prompt","aria-multiline":"true",contentEditable:!n,suppressContentEditableWarning:!0,onInput:h,onPaste:u,onKeyDown:m,onKeyUp:f,onMouseUp:p,onBlur:g,onDragEnter:b,onDragOver:v,onDragLeave:x,onDrop:y,className:`relative z-[1] min-h-[4.25rem] whitespace-pre-wrap break-words pb-2 outline-none sm:min-h-[4.25rem] ${s?"pr-12":""} ${n?"cursor-not-allowed text-slate-500":""}`})]}),s?t.jsx(kt,{type:"button",variant:"ghost",size:"icon-xs","aria-label":o,title:o,onClick:k=>{k.preventDefault(),d==null||d()},className:"thread-graph-composer-stop-button ui-action-danger absolute right-2 top-2 z-30 h-8 w-8 rounded-full text-sm font-medium",children:t.jsx("span",{"aria-hidden":"true",className:"block h-2.5 w-2.5 rounded-[2px] bg-current"})}):null]})}function zm({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 Im({isShellView:e,promptRef:r,prompt:n,disabled:a,promptPlaceholder:s,canInterrupt:o,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,promptInputClassName:h,goalComposeMode:u,goalTokenBudget:m,goalLocalError:f,goalBusy:p,busy:g,sendButtonLabel:b,sendButtonClassName:v,onInterrupt:x,onPromptInput:y,onPromptPaste:k,onPromptKeyDown:C,onPromptKeyUp:w,onPromptMouseUp:j,onPromptBlur:S,onPromptDragEnter:L,onPromptDragOver:P,onPromptDragLeave:K,onPromptDrop:F,onGoalTokenBudgetChange:R,onCancelGoal:J,onShellPromptChange:Z}){return{promptSlot:e?null:t.jsx(Pm,{promptRef:r,prompt:n,disabled:a,promptPlaceholder:s,canInterrupt:o,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,onInterrupt:x,onInput:y,onPaste:k,onKeyDown:C,onKeyUp:w,onMouseUp:j,onBlur:S,onDragEnter:L,onDragOver:P,onDragLeave:K,onDrop:F}),goalSlot:u&&!e?t.jsx(Lm,{tokenBudget:m,error:f,onTokenBudgetChange:R,onCancel:J}):null,shellPromptSlot:e?t.jsx(zm,{prompt:n,promptPlaceholder:s,promptRegionClassName:i,promptInputClassName:h,interruptLabel:l,canInterrupt:o,sendButtonLabel:b,sendButtonClassName:v,sendDisabled:p||g,onPromptChange:Z,onPromptKeyDown:C,onInterrupt:x}):null}}function Rm({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=mu({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 Am({isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:s,toolbarClassName:o,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,inlineToggleClassName:m,planToggleActiveClassName:f,sendButtonBaseClassName:p,slashPanelView:g,availableToolboxItems:b,busy:v,settingsBusy:x,compactBusy:y,forkBusy:k,fastMode:C,goalComposeMode:w,goalBusy:j,goalStatus:S,activeView:L,disabled:P,model:K,modelOptions:F,modelContextTitle:R,contextUsage:J,reasoningEffort:Z,supportedEfforts:D,displayedCollaborationMode:te,sandboxMode:oe,sendButtonLabel:_,sendButtonClassName:Y,modelControlsDisabled:I,effortControlsDisabled:q,effortControlTitle:H,forkTurnOptionsState:E,skillsState:W,copiedSkillName:O,hooksPanelMode:N,hooksState:T,hookConfigBusy:U,hookConfigError:X,hookConfigSuccess:ie,editingHookTarget:Q,hookScope:de,hookEventName:re,hookMatcher:xe,hookCommand:le,hookTimeoutSec:ve,hookStatusMessage:Pe,mcpPanelMode:se,mcpState:ye,mcpConfigPath:je,mcpConfigError:G,mcpConfigSuccess:me,mcpConfigBusy:ge,mcpHttpName:we,mcpHttpUrl:_e,mcpRawBlock:Re,capabilities:Ee,shellControlState:Me,onToggleView:M,onDismissPromptFocus:ue,onSetOpenMenu:A,onToolboxItemClick:$,onSetSlashPanelView:ee,onOpenForkTurns:pe,onForkLatest:ke,onForkTurn:Ae,onCopySkillInvokeName:Ne,onResetHookForm:De,onSetHooksPanelMode:et,onClearHookConfigStatus:Ve,onSetEditingHookTarget:ot,onSetHookScope:Qe,onSetHookEventName:ut,onSetHookMatcher:at,onSetHookCommand:Oe,onSetHookTimeoutSec:Be,onSetHookStatusMessage:Ue,onSaveHook:tt,onStartEditingHook:z,onTrustHook:V,onUntrustHook:fe,onSetMcpPanelMode:Le,onClearMcpConfigStatus:ne,onSetMcpHttpName:Ge,onSetMcpHttpUrl:He,onSetMcpRawBlock:Fe,onPrepareRawMcpBlock:qe,onSaveHttpMcp:dt,onSaveRawMcpBlock:xt,onPickPhoto:lt,onPickFile:wt,onUpdateSettings:yt,onPasteShell:jt,onCopyShell:be,onClearShell:ze,onShellControl:rt}){const Ye=e?null:{open:s==="slash",slashPanelView:g,availableToolboxItems:b,busy:v,forkBusy:k,forkTurnOptionsState:E,skillsState:W,copiedSkillName:O,hooksPanelMode:N,hooksState:T,hostConfigFilesAvailable:Ee.hostConfigFiles,hookTrustAvailable:Ee.hookTrust,hookConfigBusy:U,hookConfigError:X,hookConfigSuccess:ie,editingHookTarget:Q,hookScope:de,hookEventName:re,hookMatcher:xe,hookCommand:le,hookTimeoutSec:ve,hookStatusMessage:Pe,mcpPanelMode:se,mcpState:ye,mcpConfigEditing:Ee.mcpConfigEditing,mcpConfigPath:je,mcpConfigError:G,mcpConfigSuccess:me,mcpConfigBusy:ge,mcpHttpName:we,mcpHttpUrl:_e,mcpRawBlock:Re,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,onToggle:()=>A(ct=>ct==="slash"?null:"slash"),onToolboxItemClick:$,toolboxItemDisabled:ct=>Hu(ct,{settingsBusy:x,compactBusy:y,busy:v,forkBusy:k}),toolboxItemClassName:ct=>Ou(ct,{fastMode:C,goalComposeMode:w,goalStatus:S,menuItemClassName:d}),toolboxItemStatus:ct=>Fu(ct,{fastMode:C,compactBusy:y,goalComposeMode:w,goalStatus:S,busy:v}),onSetSlashPanelView:ee,onOpenForkTurns:pe,onForkLatest:ke,onForkTurn:Ae,onCopySkillInvokeName:Ne,onResetHookForm:De,onSetHooksPanelMode:et,onClearHookConfigStatus:Ve,onSetEditingHookTarget:ot,onSetHookScope:Qe,onSetHookEventName:ut,onSetHookMatcher:at,onSetHookCommand:Oe,onSetHookTimeoutSec:Be,onSetHookStatusMessage:Ue,onSaveHook:tt,onStartEditingHook:z,onTrustHook:V,onUntrustHook:fe,onSetMcpPanelMode:Le,onClearMcpConfigStatus:ne,onSetMcpHttpName:Ge,onSetMcpHttpUrl:He,onSetMcpRawBlock:Fe,onPrepareRawMcpBlock:qe,onSaveHttpMcp:dt,onSaveRawMcpBlock:xt},Ut=e?null:{open:s==="attachments",iconButtonClassName:l,menuClassName:i,menuItemClassName:d,onToggle:()=>A(ct=>ct==="attachments"?null:"attachments"),onPickPhoto:lt,onPickFile:wt},Wt=e?null:{openMenu:s,model:K,modelOptions:F,modelContextTitle:R,contextUsage:J,reasoningEffort:Z,supportedEfforts:D,displayedCollaborationMode:te,sandboxMode:oe,planModeAvailable:Ee.planMode,sandboxModeAvailable:Ee.sandboxMode,settingsBusy:x,goalComposeMode:w,goalBusy:j,activeView:L,disabled:P,fastMode:C,sendButtonLabel:_,sendButtonClassName:Y,modelControlsDisabled:I,effortControlsDisabled:q,effortControlTitle:H,inlineToggleClassName:m,menuItemClassName:d,planToggleActiveClassName:f,sendButtonBaseClassName:p,onSetOpenMenu:A,onUpdateSettings:yt};return{isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:s,toolbarClassName:o,iconButtonClassName:l,slashToolboxProps:Ye,attachmentMenuProps:Ut,settingsToolbarProps:Wt,shellToolsPanelProps:s==="shellTools"?{busy:v,shellControlState:Me,onPaste:jt,onCopy:be,onClear:ze,onShellControl:rt}:null,shellControlState:Me,onToggleView:M,onDismissPromptFocus:ue,onSetOpenMenu:A}}function Bn({activeView:e,edgeToEdgeMobile:r=!1,busy:n=!1,settingsBusy:a=!1,compactBusy:s=!1,error:o,model:l=null,reasoningEffort:i=null,fastMode:d=!1,collaborationMode:h="default",sandboxMode:u=null,hideSandboxModeControl:m=!1,modelOptions:f=[],contextUsage:p=null,capabilities:g=null,toolboxItems:b=null,hookCommandTemplates:v=null,mcpConfigFormat:x="none",followTail:y=!1,threadConnected:k=!0,shellAvailable:C=!0,disabled:w=!1,disabledPlaceholder:j,shellControlState:S=null,draftPrompt:L,draftAttachments:P,onPickAttachment:K,skillsState:F={status:"idle",data:null,error:null},mcpState:R={status:"idle",data:null,error:null},hooksState:J={status:"idle",data:null,error:null},goalState:Z={status:"idle",data:null,error:null},forkTurnOptionsState:D={status:"idle",data:null,error:null},onDraftChange:te,onSubmit:oe,onInterrupt:_,onCompact:Y,onOpenSkills:I,onOpenMcp:q,onOpenHooks:H,onCreateHook:E,onUpdateHook:W,onTrustHook:O,onUntrustHook:N,onOpenGoal:T,onUpdateGoal:U,onOpenForkTurns:X,onForkLatest:ie,onForkTurn:Q,onReadProviderConfig:de,onWriteProviderConfig:re,onToggleFollow:xe,onUpdateSettings:le,onToggleView:ve,onShellCopy:Pe,onShellControl:se,canInterrupt:ye=!1}){var ba;const[je,G]=c.useState(null),[me,ge]=c.useState("root"),[we,_e]=c.useState("list"),Re=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)&&!!de&&!!re,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,de,re]),Ee=c.useMemo(()=>Bu(b,Re),[Re,b]),Me=c.useRef(null),M=c.useRef(null),ue=c.useRef(null),A=c.useRef(null),$=c.useRef(null),ee=c.useRef([]),pe=c.useRef(null),ke=c.useRef(""),Ae=c.useRef(0),Ne=e==="shell",De=C||Ne,et=!!(Ne&&(S!=null&&S.isMobileShell)),Ve=(S==null?void 0:S.promptLabel)??null,[ot,Qe]=c.useState(!1),[ut,at]=c.useState(0),{prompt:Oe,attachments:Be,isDraftControlled:Ue,updateDraft:tt,flushControlledDraftToHost:z}=bm({isShellView:Ne,draftPrompt:L,draftAttachments:P,onDraftChange:te}),V=gm({attachments:Be,isShellView:Ne}),{displayedCollaborationMode:fe,updateSettings:Le}=Rm({collaborationMode:h,onUpdateSettings:le,closeMenu:()=>G(null)}),{forkBusy:ne,forkLatest:Ge,forkTurn:He}=vm({slashPanelView:me,onForkLatest:ie,onForkTurn:Q,closeMenu:()=>G(null)}),{hooksPanelMode:Fe,hookScope:qe,hookEventName:dt,hookMatcher:xt,hookCommand:lt,hookTimeoutSec:wt,hookStatusMessage:yt,editingHookTarget:jt,hookConfigBusy:be,hookConfigError:ze,hookConfigSuccess:rt,setHooksPanelMode:Ye,setEditingHookTarget:Ut,setHookScope:Wt,setHookEventName:ia,setHookMatcher:ct,setHookCommand:yl,setHookTimeoutSec:jl,setHookStatusMessage:Nl,clearHookConfigStatus:da,resetHookForm:Cl,startEditingHook:Sl,saveHook:Tl,trustHook:El,untrustHook:Ll}=ym({slashPanelView:me,hookCommandTemplates:v,onCreateHook:E,onUpdateHook:W,onTrustHook:O,onUntrustHook:N}),{goalComposeMode:sr,goalTokenBudget:Pl,goalBusy:rn,goalLocalError:zl,setGoalTokenBudget:Il,submitGoal:Rl,enterGoalComposeMode:Al,exitGoalComposeMode:ca}=km({prompt:Oe,goalTokenBudgetSource:Z.data,promptRef:M,onOpenGoal:T,onUpdateGoal:U,updateDraft:tt,closeMenu:()=>G(null),resetSlashPanel:()=>ge("root")}),{mcpHttpName:_l,mcpHttpUrl:Ml,mcpRawBlock:$l,mcpConfigPath:Dl,mcpConfigBusy:Bl,mcpConfigError:Gl,mcpConfigSuccess:Fl,setMcpHttpName:Hl,setMcpHttpUrl:Ol,setMcpRawBlock:Ul,clearMcpConfigStatus:ha,prepareRawMcpBlock:Wl,saveHttpMcp:Vl,saveRawMcpBlock:Kl}=Nm({hostConfigFilesAvailable:Re.hostConfigFiles,onReadProviderConfig:de,onWriteProviderConfig:re,setMcpPanelMode:_e,onOpenMcp:q}),{copiedSkillName:ql,copySkillInvokeName:Xl}=Cm({openMenu:je,setOpenMenu:G,slashPanelView:me,setSlashPanelView:ge,setMcpPanelMode:_e,clearMcpConfigStatus:ha,clearHookConfigStatus:da}),Yl=c.useCallback(ae=>{tt(Ce=>{if(typeof ae=="function"){const Ie=ae(Ce.prompt,Ce.attachments);return{prompt:Ie.prompt,attachments:Ie.attachments??Ce.attachments}}return{prompt:ae,attachments:Ce.attachments}})},[tt]),nn=c.useMemo(()=>f.find(ae=>ae.model===l)??null,[l,f]),Zl=vu(l,p),ua=(nn==null?void 0:nn.supportedReasoningEfforts)??[],Jl=c.useMemo(()=>au(Oe,Be),[Be,Oe]),Ql=c.useMemo(()=>Object.entries(V).sort(([ae],[Ce])=>ae.localeCompare(Ce)).map(([ae,Ce])=>`${ae}:${Ce}`).join("|"),[V]);function ei(ae,Ce){Ce.stopPropagation();const Ie=Gu(ae,{fastMode:d,goalComposeMode:sr});switch(Ie.type){case"toggleFast":Le({fastMode:Ie.fastMode});break;case"runCompact":G(null),Y==null||Y();break;case"enterGoalCompose":Al();break;case"exitGoalCompose":ca(),G(null);break;case"openPanel":ge(Ie.panel),Ie.panel==="skills"?I==null||I():Ie.panel==="mcp"?q==null||q():Ie.panel==="hooks"&&(H==null||H());break;case"insertPrompt":on(Ie.text),ge("root"),G(null);break}}function Vt(){const ae=M.current;return ae?Vu(ae):null}const ti=c.useCallback(ae=>{const Ce=M.current;!Ce||!ae||Ku(Ce,ae)},[]),an=c.useCallback(()=>{const ae=M.current;return ae?Jo(ae):Oe},[Oe]),{appendAttachments:sn,appendDroppedAttachments:ma}=fm({prompt:Oe,attachments:Be,updateDraft:tt,getSelection:Vt,selectionSnapshotRef:pe,pendingSelectionRef:$,pendingInsertedAttachmentIdsRef:ee,onInserted:()=>G(null)}),pa=c.useCallback((ae,Ce)=>{var Ie;if(zt(),K){K({kind:ae,appendAttachments:(Ze,st=ae)=>sn(Ze,st),defaultPick:()=>{var Ze;return(Ze=Ce.current)==null?void 0:Ze.click()}});return}(Ie=Ce.current)==null||Ie.click()},[sn,zt,K]);function on(ae){if(!ae)return;const Ce=Vt()??pe.current,Ie=(Ce==null?void 0:Ce.start)??Oe.length,Ze=(Ce==null?void 0:Ce.end)??Ie,st=nu(ae),Kt=`${Oe.slice(0,Ie)}${st}${Oe.slice(Ze)}`;tt(Mi=>({prompt:Kt,attachments:Mi.attachments}));const It=Ie+st.length;$.current={start:It,end:It},pe.current={start:It,end:It}}Em({promptRef:M,isShellView:Ne,prompt:Oe,promptSegments:Jl,attachmentPreviewUrls:V,previewSignature:Ql,editorSanitizeNonce:ut,pendingSelectionRef:$,pendingInsertedAttachmentIdsRef:ee,selectionSnapshotRef:pe,renderedPreviewSignatureRef:ke,renderedSanitizeNonceRef:Ae,serializeEditorPrompt:an,restoreSelection:ti});function zt(){var ae;(ae=M.current)==null||ae.blur(),document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.blur()}async function ri(){var ae;if(zt(),G(null),!!((ae=navigator.clipboard)!=null&&ae.readText))try{const Ce=await navigator.clipboard.readText();on(Ce)}catch{return}}async function fa(){if(Ue&&z(),sr&&!Ne){await Rl();return}const ae=du({prompt:Oe,attachments:Be,isShellView:Ne});!ae||await oe(ae)===!1||tt(()=>({prompt:"",attachments:[]}))}async function ni(ae){ae.preventDefault(),await fa()}function ai(){const ae=an(),Ce=Vt();pe.current=Ce;const Ie=M.current;(Ie?Wu(Ie):!1)&&($.current=Ce,at(st=>st+1)),tt(st=>({prompt:ae,attachments:st.attachments.filter(Kt=>ae.includes(Kt.placeholder))}),"deferred")}function si(ae){var Ze,st,Kt,It;const Ce=$n((Ze=ae.clipboardData)==null?void 0:Ze.items,(st=ae.clipboardData)==null?void 0:st.files),Ie=cu({files:Ce,plainText:((Kt=ae.clipboardData)==null?void 0:Kt.getData("text/plain"))??"",htmlText:((It=ae.clipboardData)==null?void 0:It.getData("text/html"))??"",htmlToText:Uu});Ie.preventDefault&&ae.preventDefault(),Ie.type==="insert-text"?on(Ie.text):Ie.type==="append-files"&&ma(Ie.files)}function oi(ae){var Ie,Ze;const Ce=Xa(Ja((Ie=ae.dataTransfer)==null?void 0:Ie.items,(Ze=ae.dataTransfer)==null?void 0:Ze.files));Ce.preventDefault&&ae.preventDefault(),Ce.activateDragTarget&&Qe(!0)}function li(ae){var Ie,Ze;const Ce=Xa(Ja((Ie=ae.dataTransfer)==null?void 0:Ie.items,(Ze=ae.dataTransfer)==null?void 0:Ze.files));Ce.preventDefault&&ae.preventDefault(),Ce.activateDragTarget&&ae.dataTransfer&&(ae.dataTransfer.dropEffect="copy"),Ce.activateDragTarget&&Qe(!0)}function ii(ae){ae.currentTarget.contains(ae.relatedTarget)||Qe(!1)}function di(ae){var Ze,st;const Ce=$n((Ze=ae.dataTransfer)==null?void 0:Ze.items,(st=ae.dataTransfer)==null?void 0:st.files),Ie=hu(Ce);Ie.preventDefault&&ae.preventDefault(),Ie.type==="accept-files"&&(Qe(!1),ma(Ie.files??[]))}function ci(ae){if(e==="chat"&&ae.key==="/"&&!ae.metaKey&&!ae.ctrlKey&&!ae.altKey&&!n&&!w&&Ee.length>0&&an().trim().length===0){ae.preventDefault(),ge("root"),G("slash");return}const Ce=uu({key:ae.key,metaKey:ae.metaKey,ctrlKey:ae.ctrlKey,busy:n,disabled:w});Ce.preventDefault&&ae.preventDefault(),Ce.submit&&fa()}const{promptPlaceholder:hi,interruptLabel:ui,sendButtonLabel:ga,sendButtonClassName:xa,modelControlsDisabled:mi,effortControlsDisabled:pi,effortControlTitle:fi}=ju({goalComposeMode:sr,goalBusy:rn,threadConnected:k,busy:n,isShellView:Ne,disabledPlaceholder:j,settingsBusy:a,supportedEffortCount:ua.length,fastMode:d}),{composerLayerClassName:gi,formClassName:xi,composerShellClassName:bi,composerToolbarClassName:vi,composerIconButtonClassName:ki,composerMenuClassName:wi,composerMenuItemClassName:yi,composerInlineToggleClassName:ji,composerPanelButtonClassName:Ni,composerChipButtonClassName:Ci,composerPlanToggleActiveClassName:Si,composerSendButtonClassName:Ti,composerPromptRegionClassName:Ei,promptInputClassName:Li,graphChatInputGroupClassName:Pi,graphChatInputClassName:zi}=Nu({isShellView:Ne,edgeToEdgeMobile:r,isMobileShell:et,openMenu:je!==null,isDragTargetActive:ot,busy:n}),Ii=Am({isShellView:Ne,canToggleShellView:De,isMobileShell:et,shellPromptLabel:Ve,openMenu:je,toolbarClassName:vi,iconButtonClassName:ki,menuClassName:wi,menuItemClassName:yi,panelButtonClassName:Ni,chipButtonClassName:Ci,inlineToggleClassName:ji,planToggleActiveClassName:Si,sendButtonBaseClassName:Ti,slashPanelView:me,availableToolboxItems:Ee,busy:n,settingsBusy:a,compactBusy:s,forkBusy:ne,fastMode:d,goalComposeMode:sr,goalBusy:rn,goalStatus:(ba=Z.data)==null?void 0:ba.status,activeView:e,disabled:w,model:l,modelOptions:f,modelContextTitle:Zl,contextUsage:p,reasoningEffort:i,supportedEfforts:ua,displayedCollaborationMode:fe,sandboxMode:u,sendButtonLabel:ga,sendButtonClassName:xa,modelControlsDisabled:mi,effortControlsDisabled:pi,effortControlTitle:fi,forkTurnOptionsState:D,skillsState:F,copiedSkillName:ql,hooksPanelMode:Fe,hooksState:J,hookConfigBusy:be,hookConfigError:ze,hookConfigSuccess:rt,editingHookTarget:jt,hookScope:qe,hookEventName:dt,hookMatcher:xt,hookCommand:lt,hookTimeoutSec:wt,hookStatusMessage:yt,mcpPanelMode:we,mcpState:R,mcpConfigPath:Dl,mcpConfigError:Gl,mcpConfigSuccess:Fl,mcpConfigBusy:Bl,mcpHttpName:_l,mcpHttpUrl:Ml,mcpRawBlock:$l,capabilities:{hostConfigFiles:Re.hostConfigFiles,hookTrust:Re.hookTrust,mcpConfigEditing:Re.mcpConfigEditing,planMode:Re.planMode,sandboxMode:m?!1:Re.sandboxMode},shellControlState:S,onToggleView:ve,onDismissPromptFocus:zt,onSetOpenMenu:G,onToolboxItemClick:ei,onSetSlashPanelView:ge,onOpenForkTurns:()=>X==null?void 0:X(),onForkLatest:Ge,onForkTurn:He,onCopySkillInvokeName:Xl,onResetHookForm:Cl,onSetHooksPanelMode:Ye,onClearHookConfigStatus:da,onSetEditingHookTarget:Ut,onSetHookScope:Wt,onSetHookEventName:ia,onSetHookMatcher:ct,onSetHookCommand:yl,onSetHookTimeoutSec:jl,onSetHookStatusMessage:Nl,onSaveHook:Tl,onStartEditingHook:Sl,onTrustHook:El,onUntrustHook:Ll,onSetMcpPanelMode:_e,onClearMcpConfigStatus:ha,onSetMcpHttpName:Hl,onSetMcpHttpUrl:Ol,onSetMcpRawBlock:Ul,onPrepareRawMcpBlock:Wl,onSaveHttpMcp:Vl,onSaveRawMcpBlock:Kl,onPickPhoto:()=>pa("photo",ue),onPickFile:()=>pa("file",A),onUpdateSettings:ae=>void Le(ae),onPasteShell:()=>void ri(),onCopyShell:()=>{zt(),G(null),Pe==null||Pe()},onClearShell:()=>{zt(),G(null),oe({prompt:"clear"})},onShellControl:ae=>{zt(),G(null),se==null||se(ae)}}),{promptSlot:Ri,goalSlot:Ai,shellPromptSlot:_i}=Im({isShellView:Ne,promptRef:M,prompt:Oe,disabled:w,promptPlaceholder:hi,canInterrupt:ye,interruptLabel:ui,composerPromptRegionClassName:Ei,graphChatInputClassName:zi,promptInputClassName:Li,goalComposeMode:sr,goalTokenBudget:Pl,goalLocalError:zl,goalBusy:rn,busy:n,sendButtonLabel:ga,sendButtonClassName:xa,onInterrupt:_,onPromptInput:ai,onPromptPaste:si,onPromptKeyDown:ci,onPromptKeyUp:()=>{pe.current=Vt()},onPromptMouseUp:()=>{pe.current=Vt()},onPromptBlur:()=>{pe.current=Vt(),Qe(!1),Ue&&z()},onPromptDragEnter:oi,onPromptDragOver:li,onPromptDragLeave:ii,onPromptDrop:di,onGoalTokenBudgetChange:Il,onCancelGoal:ca,onShellPromptChange:Yl});return t.jsx(rm,{activeView:e,layerClassName:gi,formClassName:xi,shellClassName:bi,inputGroupClassName:Pi,error:o,followTail:y,photoInputRef:ue,fileInputRef:A,onAppendAttachments:sn,onToggleFollow:xe,onSubmit:ni,formRef:Me,promptSlot:Ri,toolbarSlot:t.jsx(um,{...Ii}),goalSlot:Ai,shellPromptSlot:_i})}var _m=c.createContext(null);function el(){return c.useContext(_m)}function ft(e){return e?new Date(e).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"}):"Time unavailable"}function Gt(e){return e?new Date(e).toLocaleString():"Time unavailable"}function Mm(e){switch(e){case"idle":return"Idle";case"running":return"Running";case"interrupted":return"Interrupted";case"failed":return"Failed";case"not_loaded":return"Not Loaded";case"system_error":return"System Error"}}function $m(e){switch(e){case"idle":return"ui-status-neutral";case"running":return"ui-status-info";case"interrupted":return"ui-status-warning";case"failed":case"system_error":return"ui-status-danger";case"not_loaded":return"ui-status-neutral"}}function tl(e){switch(e){case"sending":return"Sending";case"completed":return"Completed";case"interrupted":return"Interrupted";case"failed":return"Failed";case"inProgress":return"Running"}}function Dm({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 Or.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 Bm({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 Gm({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 Fm({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 Hm({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 Om({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 Um({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 Wm({children:e}){return t.jsx("div",{className:"thread-split-region min-h-0 flex-1 overflow-hidden p-0 sm:p-2",children:e})}yo();Pt();function ss({...e}){return t.jsx(Hi,{"data-slot":"dialog",...e})}function os({...e}){return t.jsx(Oi,{"data-slot":"dialog-trigger",...e})}function Vm({...e}){return t.jsx(qi,{"data-slot":"dialog-portal",...e})}function Km({className:e,...r}){return t.jsx(Xi,{"data-slot":"dialog-overlay",className:nt("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 ls({children:e,className:r,showCloseButton:n=!0,...a}){return t.jsxs(Vm,{"data-slot":"dialog-portal",children:[t.jsx(Km,{}),t.jsxs(Ui,{"data-slot":"dialog-content",className:nt("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(Wi,{"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(B.XIcon,{}),t.jsx("span",{className:"sr-only",children:"Close"})]}):null]})]})}function is({className:e,...r}){return t.jsx("div",{"data-slot":"dialog-header",className:nt("flex flex-col gap-2 text-center sm:text-left",e),...r})}function ds({className:e,...r}){return t.jsx(Vi,{"data-slot":"dialog-title",className:nt("text-lg font-semibold leading-none",e),...r})}function cs({className:e,...r}){return t.jsx(Ki,{"data-slot":"dialog-description",className:nt("text-sm text-muted-foreground",e),...r})}var qm=[{value:"system",label:"Follow system",icon:B.Monitor},{value:"dark",label:"Dark",icon:B.Moon},{value:"light",label:"Light",icon:B.Sun}];function Xm({thread:e,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a={},onOpenThread:s,getThreadHref:o,renderThreadLink:l,onBeginRenameThread:i,onDeleteThread:d,showDeleteButton:h=!1,showSessionCopyButton:u=!1,collapsed:m=!1}){const[f,p]=c.useState("idle"),g=c.useRef(null),b=a[e.workspaceId],v=b&&!n?b:null,x=r===e.id;c.useEffect(()=>()=>{g.current!==null&&window.clearTimeout(g.current)},[]);async function y(){const S=e.providerSessionId;if(S)try{await navigator.clipboard.writeText(S),p("copied"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>p("idle"),1200)}catch{p("failed"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>p("idle"),1600)}}const k=()=>s(e.id),C=`thread-graph-room-card group flex w-full items-center gap-3 rounded-xl border text-left transition ${x?"is-active":""} ${m?"justify-center px-2 py-2":"px-3 py-2.5"}`,w=t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`thread-graph-room-card-icon flex h-8 w-8 shrink-0 items-center justify-center rounded-full ${x?"is-active":""}`,children:t.jsx(B.MessageSquare,{className:"h-4 w-4"})}),t.jsxs("div",{className:`min-w-0 flex-1 ${m?"thread-desktop-collapsed-hidden":""}`,children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[t.jsx("p",{className:"thread-graph-room-card-title min-w-0 flex-1 truncate text-sm font-medium",title:e.title,children:e.title}),i&&!m?t.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),S.preventDefault(),i(e)},"aria-label":`Rename thread ${e.title}`,title:"Rename thread",className:"thread-card-quiet-button inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full transition",children:t.jsx(B.Pencil,{className:"h-3 w-3"})}):null,u&&e.providerSessionId?t.jsx("button",{type:"button","aria-label":"Copy session ID",title:f==="copied"?"Copied":f==="failed"?"Copy failed":"Copy session ID",onClick:S=>{S.stopPropagation(),S.preventDefault(),y()},className:"thread-card-quiet-button thread-card-session-copy-button inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition",children:t.jsx(B.Copy,{className:"h-3.5 w-3.5"})}):null]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2",children:[v?t.jsx("p",{className:"thread-graph-room-card-meta min-w-0 flex-1 truncate text-[11px] text-[var(--theme-fg-muted)]",title:v,children:v}):t.jsx("span",{className:"min-w-0 flex-1","aria-hidden":"true"}),t.jsx("span",{className:`shrink-0 rounded-full border px-1.5 py-0.5 text-[9px] uppercase tracking-normal ${$m(e.status)}`,children:Mm(e.status)}),t.jsx("time",{className:"shrink-0 text-[11px] text-[var(--theme-fg-muted)]",dateTime:e.lastTurnStartedAt??e.updatedAt,children:ft(e.lastTurnStartedAt??e.updatedAt)})]})]}),h&&d&&!m?t.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),S.preventDefault(),d(e)},"aria-label":`Delete thread ${e.title}`,className:"thread-card-danger-button shrink-0 rounded-full p-1 transition",title:"Delete thread",children:t.jsx(B.Trash2,{className:"h-3.5 w-3.5"})}):null]}),j=o==null?void 0:o(e.id);return l?t.jsx(t.Fragment,{children:l({thread:e,children:w,className:C,onClick:k})}):j?t.jsx("a",{href:j,onClick:S=>{S.preventDefault(),k()},title:m?e.title:void 0,className:C,children:w}):t.jsx("div",{role:"link",tabIndex:0,onClick:k,onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),k())},title:m?e.title:void 0,className:C,children:w})}function Ym({threads:e,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a={},onOpenThread:s,getThreadHref:o,renderThreadLink:l,onBeginRenameThread:i,onDeleteThread:d,scrollable:h=!1,maxHeightClassName:u="max-h-full",showDeleteButton:m=!1,showSessionCopyButton:f=!1,collapsed:p=!1}){const g=h?`min-h-0 min-w-0 overflow-x-hidden overflow-y-auto overscroll-contain pr-1 ${u}`:"";return t.jsx("div",{className:g,children:t.jsx("div",{className:"min-w-0 space-y-1",children:e.map(b=>t.jsx(Xm,{thread:b,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a,onOpenThread:s,showDeleteButton:m,showSessionCopyButton:f,collapsed:p,...o?{getThreadHref:o}:{},...l?{renderThreadLink:l}:{},...i?{onBeginRenameThread:i}:{},...d?{onDeleteThread:d}:{}},b.id))})})}function Zm({threads:e,status:r,loading:n=!1,error:a,viewportConstrained:s=!1,layoutMode:o="responsive",effectiveTheme:l,themeMode:i,onThemeModeChange:d,showMobileNewThreadShortcut:h=!0,settingsDialogOpen:u,onSettingsDialogOpenChange:m,mobileHeaderAction:f,currentThreadId:p,currentThreadLabel:g=null,currentWorkspaceId:b=null,currentWorkspaceLabel:v=null,sessionLabel:x=null,usageLabel:y=null,threadActionsButton:k,topbarActions:C,metaContent:w,settingsContent:j,globalSettingsContent:S,workspaceLabels:L={},workspaceReturnHref:P,onWorkspaceReturn:K,getThreadHref:F,onOpenThread:R,getNewThreadHref:J,newThreadHref:Z,newThreadLabel:D="New Chat",onNewThread:te,onNewThreadTitle:oe,renderNewThreadDialogContent:_,renderThreadLink:Y,onCloseAppNavigation:I,onRenameThread:q,onDeleteThread:H,workspaceContent:E,workspaceTitle:W="Workspace",workspaceActions:O,children:N}){const T=el(),U=typeof window<"u"?window.matchMedia("(max-width: 639px)").matches:o==="mobile",[X,ie]=c.useState(()=>typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)").matches:!1),Q=i??(T==null?void 0:T.themeMode)??"system",de=l??(T==null?void 0:T.effectiveTheme)??(Q==="system"?X?"dark":"light":Q),[re,xe]=c.useState(!1),[le,ve]=c.useState(!1),[Pe,se]=c.useState(!U),[ye,je]=c.useState(U),[G,me]=c.useState("chat"),[ge,we]=c.useState(null),[_e,Re]=c.useState(""),[Ee,Me]=c.useState(null),[M,ue]=c.useState(!1),[A,$]=c.useState(""),[ee,pe]=c.useState(!1),[ke,Ae]=c.useState(!1),[Ne,De]=c.useState("session");c.useEffect(()=>{if(typeof window>"u")return;const be=window.matchMedia("(max-width: 639px)"),ze=()=>{je(be.matches)};return ze(),be.addEventListener("change",ze),()=>{be.removeEventListener("change",ze)}},[]),c.useEffect(()=>{if(typeof window>"u")return;const be=window.matchMedia("(prefers-color-scheme: dark)"),ze=()=>{ie(be.matches)};return ze(),be.addEventListener("change",ze),()=>{be.removeEventListener("change",ze)}},[]);const et=c.useMemo(()=>[...b?e.filter(ze=>ze.workspaceId===b):e].sort((ze,rt)=>{if(ze.id===p)return-1;if(rt.id===p)return 1;const Ye=Date.parse(ze.lastTurnStartedAt??ze.updatedAt);return Date.parse(rt.lastTurnStartedAt??rt.updatedAt)-Ye}),[p,b,e]),Ve=Z??(J==null?void 0:J(b)),ot=v??b??"all",Qe=x??g??p??"default_session",ut=y??(r!=null&&r.state?`runtime ${r.state}`:"waiting for agent usage"),at=d??(T==null?void 0:T.setThemeMode),Oe=!!at,Be=()=>{xe(!1),I==null||I()};async function Ue(be){if(!q)return;const ze=_e.trim();if(ze){Me(be);try{await q(be,ze),we(null),Re("")}finally{Me(null)}}}function tt(be){we(be.id),Re(be.title)}function z(){we(null),Re("")}function V(be){R==null||R(be),Be()}function fe(){ue(!1),$("")}function Le(be){if(!Ve||!be.trim())return Ve;try{const ze=new URL(Ve,window.location.origin);return ze.searchParams.set("title",be.trim()),`${ze.pathname}${ze.search}${ze.hash}`}catch{const ze=Ve.includes("?")?"&":"?";return`${Ve}${ze}title=${encodeURIComponent(be.trim())}`}}async function ne(){const be=A.trim();pe(!0);try{if(be&&oe){await oe(be),$(""),ue(!1),Be();return}if(Ve){window.location.assign(Le(be)??Ve);return}await(te==null?void 0:te()),$(""),ue(!1),Be()}finally{pe(!1)}}function Ge(be,ze=!1){const rt=ze?t.jsxs(t.Fragment,{children:[t.jsx(B.Plus,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:D})]}):t.jsxs(t.Fragment,{children:[t.jsx(B.Plus,{className:"h-4 w-4"}),t.jsx("span",{children:D})]});return t.jsxs(ss,{open:M,onOpenChange:Ye=>{ee||ue(Ye)},children:[t.jsx(os,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":ze?D:void 0,title:D,className:be,children:rt})}),t.jsx(ls,{"data-testid":"create-thread-dialog","data-theme-effective":de,"data-theme-mode":Q,className:"thread-graph-create-thread-dialog thread-graph-dialog max-h-[min(86vh,42rem)] overflow-hidden p-4 sm:max-w-[34rem]",children:_?_({close:fe,closeNavigation:Be,currentWorkspaceId:b}):t.jsxs(t.Fragment,{children:[t.jsxs(is,{children:[t.jsx(ds,{children:"Create New Chat"}),t.jsx(cs,{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:A,onChange:Ye=>$(Ye.target.value),onKeyDown:Ye=>{Ye.key==="Enter"&&(Ye.preventDefault(),ne())},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 ne(),disabled:ee,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:ee?"Creating...":"Create"})]})]})})]})}function He(){if(!j&&!w&&!S&&!Oe)return null;const be=!!(j||w),ze=!!S,rt=Ne==="global"&&ze||!be&&ze?"global":"session";return t.jsxs(ss,{...u!==void 0?{open:u}:{},...m?{onOpenChange:m}:{},children:[t.jsx(os,{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(B.Settings,{className:"h-4 w-4"})})}),t.jsxs(ls,{"data-testid":"settings-dialog","data-theme-effective":de,"data-theme-mode":Q,className:"thread-graph-settings-dialog thread-graph-dialog",children:[t.jsxs(is,{children:[t.jsx(ds,{children:"Settings"}),t.jsx(cs,{children:"Manage this session and host-wide preferences."})]}),Oe?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:qm.map(Ye=>{const Ut=Ye.icon,Wt=Q===Ye.value;return t.jsxs("button",{type:"button","data-testid":`theme-mode-${Ye.value}`,"aria-pressed":Wt,disabled:!Oe,onClick:()=>at==null?void 0:at(Ye.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 ${Wt?"is-selected":""}`,children:[t.jsx(Ut,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:"truncate",children:Ye.label})]},Ye.value)})})]})}):null,t.jsxs("div",{className:"thread-graph-settings-tabs grid grid-cols-2 gap-1 rounded-lg border p-1",children:[t.jsx("button",{type:"button","aria-pressed":rt==="session",onClick:()=>De("session"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${rt==="session"?"is-active":""}`,children:"Session"}),t.jsx("button",{type:"button","aria-pressed":rt==="global",disabled:!ze,onClick:()=>De("global"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${rt==="global"?"is-active":""}`,children:"Global"})]}),t.jsx("div",{className:"thread-graph-settings-body mt-4 min-h-0 overflow-y-auto pr-1 text-sm",children:rt==="session"?t.jsxs("div",{className:"grid gap-4",children:[j?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:j}):null,w?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:w}):null,be?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:S})})]})]})}function Fe(be=!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)] ${be?"justify-center":""}`,children:[t.jsx(B.Rows3,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:be?"sr-only":"",children:"Rooms"}),!be&&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&&et.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,et.length>0?t.jsx(Ym,{threads:et,currentThreadId:p,currentWorkspaceId:b,workspaceLabels:L,onOpenThread:V,collapsed:be,...q?{onBeginRenameThread:tt}:{},showDeleteButton:!!H,...F?{getThreadHref:F}:{},...Y?{renderThreadLink:Y}:{},...H?{onDeleteThread:H}:{}}):null]})]})})}function qe(){return E?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:()=>se(!0),className:"thread-workspace-collapse-tab thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(B.ChevronsRight,{className:"h-4 w-4"})}),O?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:O})}):null,t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:E})]}):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:W}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:v??b??"Current context"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[O,t.jsx("button",{type:"button",onClick:()=>se(!0),className:"thread-workspace-small-toggle thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(B.ChevronsRight,{className:"h-4 w-4"})})]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:E??t.jsxs("div",{className:"grid h-full min-h-0 gap-3 overflow-y-auto p-3 text-sm text-[var(--theme-fg-soft)]",children:[t.jsxs("div",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:"Runtime"}),t.jsx("p",{className:"mt-2 text-[var(--theme-fg)]",children:(r==null?void 0:r.state)??"unknown"})]}),t.jsxs("div",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:"Workspace"}),t.jsx("p",{className:"mt-2 break-words text-[var(--theme-fg)]",children:v??b??"All threads"})]})]})})]})}const dt=!!E,xt=o==="mobile"||o==="responsive"&&ye,lt=xt,wt=lt&&!re,jt=!!(P||K)?t.jsx("a",{href:P??"#",onClick:be=>{K&&(be.preventDefault(),K())},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(B.ArrowLeft,{className:"h-4 w-4"})}):null;return t.jsxs(t.Fragment,{children:[t.jsx(Bm,{effectiveTheme:de,layoutMode:o,themeMode:Q,viewportConstrained:s,children:t.jsxs(Gm,{roomsRailCollapsed:le,children:[t.jsx(Fm,{open:re,onClose:()=>xe(!1)}),t.jsxs(Hm,{collapsed:le,mobileOpen:re,children:[t.jsx("div",{className:`thread-rooms-rail-header flex h-[calc(3.75rem+env(safe-area-inset-top))] shrink-0 items-end border-b border-[var(--theme-border)] px-4 pb-3 sm:h-16 sm:items-center sm:pb-0 ${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:()=>ve(be=>!be),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(B.PanelLeftOpen,{className:"h-4 w-4"}):t.jsx(B.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:(v??"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:v??"Remote Codex"}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:b??"Thread workspace"})]})]}),t.jsxs("div",{className:`flex shrink-0 items-center gap-1 ${le?"thread-desktop-collapsed-hidden":""}`,children:[He(),jt,t.jsx("button",{type:"button",onClick:()=>xe(!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(B.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:Ge(`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:Fe(le)})]}),t.jsxs(Om,{children:[t.jsx(Um,{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:[wt?t.jsx("button",{type:"button",onClick:()=>xe(!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(B.Menu,{className:"h-4 w-4"})}):null,t.jsxs("div",{className:"min-w-0",children:[lt?t.jsx("h1",{className:"thread-mobile-only-block min-w-0 truncate text-sm font-semibold leading-none text-[var(--theme-fg)]",children:g??"Shared Workspace"}):null,t.jsxs("div",{className:"relative flex min-w-0 items-center gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{Ae(be=>!be)},"aria-expanded":ke,"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:ot})]}),ke?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 be;Qe&&((be=navigator.clipboard)==null||be.writeText(Qe))},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:Qe})]}),t.jsxs("div",{className:"thread-topbar-meta-row mt-1 flex min-w-0 max-w-full items-center gap-2 text-xs leading-5",title:"Session token usage and estimated cost",children:[t.jsx("span",{className:"w-14 shrink-0",children:"Usage"}),t.jsx("span",{className:"truncate font-mono",children:ut})]})]}):null]})]})]}),t.jsxs("div",{className:"relative z-[1] inline-flex shrink-0 items-center gap-2",children:[k||C?t.jsxs("div",{className:"thread-graph-topbar-actions thread-desktop-only-inline-flex items-center rounded-lg border p-0.5 shadow-none",children:[k,C]}):null,lt&&k?t.jsx("div",{className:"thread-mobile-only-inline-flex",children:k}):null,lt&&dt?t.jsx("button",{type:"button",onClick:()=>me(be=>be==="workspace"?"chat":"workspace"),"aria-label":G==="workspace"?"Show chat":"Show workspace",title:G==="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:G==="workspace"?t.jsx(B.MessageSquare,{className:"h-4 w-4"}):t.jsx(B.Folder,{className:"h-4 w-4"})}):null,lt?f:null,lt&&h?Ge("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(Wm,{children:dt&&!Pe?xt?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 ${G==="chat"?"block":"thread-mobile-chat-hidden"}`,children:N}),t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${G==="workspace"?"block":"thread-mobile-workspace-hidden"}`,children:qe()})]}):t.jsxs(En,{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(er,{defaultSize:47,minSize:30,maxSize:75,className:"thread-split-chat-pane min-w-0 overflow-hidden",children:N}),t.jsx(Ln,{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(er,{defaultSize:53,minSize:30,maxSize:70,className:"thread-split-workspace-pane min-w-0 overflow-hidden",children:qe()})]}):t.jsxs("div",{className:"thread-split-container relative h-full min-h-0 overflow-hidden",children:[dt&&Pe?t.jsx("button",{type:"button",onClick:()=>se(!1),className:"thread-workspace-expand-fab thread-desktop-only-inline-flex",title:"Expand workspace","aria-label":"Expand workspace",children:t.jsx(B.ChevronsLeft,{className:"h-4 w-4"})}):null,N]})})]})]})}),t.jsx(Dm,{open:ge!==null,title:"Rename Thread",label:"Thread Title",value:_e,busy:Ee!==null,onChange:Re,onCancel:z,onSubmit:()=>ge?Ue(ge):void 0})]})}function Jm({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?Or.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 Qm=[/^(?: {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],ep=/^(?:\|?[^|\n]+\|[^|\n]+(?:\|[^|\n]+)*\|?\s*\n\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$)/m,tp=/!?\[[^\]\n]+\]\([^)]+\)/,rp=/`[^`\n]+`/,np=/(?:\*\*[^*\n]+\*\*|__[^_\n]+__)/,ap=/(^|[^\w])(?:\*[^*\n]+\*|_[^_\n]+_)(?=[^\w]|$)/,sp=/~~[^~\n]+~~/;function op(e){const r=e.trim();return r?Qm.some(n=>n.test(r))||ep.test(r)?!0:/[`[\]*_~!]/.test(r)?tp.test(r)||rp.test(r)||np.test(r)||ap.test(r)||sp.test(r):!1:!1}Xr();function Gn(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 ra(e=[]){const r=Gn(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 na=c.createContext(ra());function aa(){return c.useContext(na)??ra()}yr();function rl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function hs(e){return rl(e)?Object.entries(e):e==null||e===""?[]:[["value",e]]}function nl(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 lp(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)}):nl(r)}function us({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(B.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"};case"failed":return{className:"is-failed",icon:t.jsx(B.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"};default:return{className:"is-pending",icon:t.jsx(B.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),label:"Running"}}},[n]),l=c.useMemo(()=>hs(s),[s]),i=c.useMemo(()=>hs(a),[a]),d=c.useMemo(()=>typeof s=="string"?s.length>0:rl(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(vr,{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(kr,{value:"item-1",className:"border-0",children:[t.jsx(Yr,{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(B.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(wr,{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:": "}),nl(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:": "}),lp(f,p),g<l.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},f)),"}"]})]}):null]})]})})})}var ms=null;function ip(){return ms??(ms=Promise.all([Ke(()=>import("./core-oEok_Crl.js"),__vite__mapDeps([0,1,2])),Ke(()=>import("./engine-javascript-DBd1bXLz.js"),[]),Ke(()=>import("./ayu-light-BA47KaF1.js"),[]),Ke(()=>import("./ayu-dark-DYE7WIF3.js"),[]),Ke(()=>import("./javascript-wDzz0qaB.js"),[]),Ke(()=>import("./typescript-BPQ3VLAy.js"),[]),Ke(()=>import("./tsx-COt5Ahok.js"),[]),Ke(()=>import("./jsx-g9-lgVsj.js"),[]),Ke(()=>import("./python-B6aJPvgy.js"),[]),Ke(()=>import("./json-Cp-IABpG.js"),[]),Ke(()=>import("./shellscript-CEILq0vU.js").then(e=>e.b),[]),Ke(()=>import("./shellscript-CEILq0vU.js").then(e=>e.s),[]),Ke(()=>import("./yaml-Buea-lGh.js"),[]),Ke(()=>import("./toml-vGWfd6FD.js"),[]),Ke(()=>import("./markdown-Cvjx9yec.js"),[]),Ke(()=>import("./html-pp8916En.js"),__vite__mapDeps([3,4,5])),Ke(()=>import("./css-CLj8gQPS.js"),[]),Ke(()=>import("./sql-CRqJ_cUM.js"),[]),Ke(()=>import("./csv-fuZLfV_i.js"),[])]).then(([{createHighlighterCore:e},{createJavaScriptRegexEngine:r},n,a,s,o,l,i,d,h,u,m,f,p,g,b,v,x,y])=>e({engine:r(),themes:[n.default,a.default],langs:[s.default,o.default,l.default,i.default,d.default,h.default,u.default,m.default,f.default,p.default,g.default,b.default,v.default,x.default,y.default]}))),ms}function Zr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Fn(e){if(!e)return{};if(Zr(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 Hn(){return{finalResult:null,stdout:"",stderr:""}}function dp(e){return typeof e=="string"?{result:e}:e}function al(e){const r=Zr(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 ps(e){if(!e)return"pending";if(!Zr(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 cp(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=dp(d.result),m=r.get(h)??Hn();return Zr(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=Fn(d.args);if(typeof h=="string"&&r.has(h)){const f=al(r.get(h)??Hn());return`\`\`\`tool-merged
3658
+ `,as="MCP entry written to provider config. Restart the backend if it does not appear immediately.";function Nm({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,y]=c.useState(null),k=c.useCallback(()=>{w(null),y(null)},[]),j=c.useCallback(async()=>{if(!e||!r)throw new Error("Provider config editing is unavailable for this thread.");const P=await r();return f(P.path),P},[e,r]),v=c.useCallback(async P=>{if(!e||!n)throw new Error("Provider config editing is unavailable for this thread.");const K=await n(P);return f(K.path),K},[e,n]),N=c.useCallback(async()=>{const P=gu(s),K=i.trim();if(!P){w("MCP name must use only letters, numbers, underscore, or hyphen.");return}if(!/^https?:\/\//i.test(K)){w("HTTP MCP URL must start with http:// or https://");return}g(!0),w(null),y(null);try{const F=await j(),D=Za(F.content,P,bu(P,K));await v(D),y(as),a("list"),l(""),d(""),o==null||o()}catch(F){w(F instanceof Error?F.message:"Unable to update provider config.")}finally{g(!1)}},[j,s,i,o,a,v]),S=c.useCallback(async()=>{g(!0),w(null),y(null);try{await j(),u(P=>P||jm),a("stdio")}catch(P){w(P instanceof Error?P.message:"Unable to load provider config.")}finally{g(!1)}},[j,a]),L=c.useCallback(async()=>{const P=xu(h);if(!P){w("The raw MCP block must start with a header like [mcp_servers.name].");return}g(!0),w(null),y(null);try{const K=await j(),F=Za(K.content,P,h);await v(F),y(as),a("list"),o==null||o()}catch(K){w(K instanceof Error?K.message:"Unable to update provider config.")}finally{g(!1)}},[j,h,o,a,v]);return{mcpHttpName:s,mcpHttpUrl:i,mcpRawBlock:h,mcpConfigPath:m,mcpConfigBusy:p,mcpConfigError:b,mcpConfigSuccess:x,setMcpHttpName:l,setMcpHttpUrl:d,setMcpRawBlock:u,clearMcpConfigStatus:k,prepareRawMcpBlock:S,saveHttpMcp:N,saveRawMcpBlock:L}}function Cm({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 Sm(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=Qa(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=Qa(n),a.append(o,s),a}function Tm(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(Sm(a,r))}return n}function Em({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(Tm(a,o)),u.current=s,m.current=l),b!==null?(g.focus(),qu(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 Lm({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 Pm({promptRef:e,prompt:r,disabled:n,promptPlaceholder:a,canInterrupt:o,interruptLabel:s,composerPromptRegionClassName:l,graphChatInputClassName:i,onInterrupt:d,onInput:h,onPaste:u,onKeyDown:m,onKeyUp:f,onMouseUp:p,onBlur:g,onDragEnter:b,onDragOver:w,onDragLeave:x,onDrop:y}){return t.jsxs("div",{"data-slot":"input-group-control",className:`${l} relative w-full`,children:[t.jsxs("div",{className:i,children:[r.length===0&&t.jsx("span",{className:`pointer-events-none absolute left-3 top-3 truncate text-slate-500 sm:left-4 sm:top-4 dark:text-slate-400 ${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,suppressContentEditableWarning:!0,onInput:h,onPaste:u,onKeyDown:m,onKeyUp:f,onMouseUp:p,onBlur:g,onDragEnter:b,onDragOver:w,onDragLeave:x,onDrop:y,className:`relative z-[1] min-h-[4.25rem] whitespace-pre-wrap break-words pb-2 outline-none sm:min-h-[4.25rem] ${o?"pr-12":""} ${n?"cursor-not-allowed text-slate-500":""}`})]}),o?t.jsx(kt,{type:"button",variant:"ghost",size:"icon-xs","aria-label":s,title:s,onClick:k=>{k.preventDefault(),d==null||d()},className:"thread-graph-composer-stop-button ui-action-danger absolute right-2 top-2 z-30 h-8 w-8 rounded-full text-sm font-medium",children:t.jsx("span",{"aria-hidden":"true",className:"block h-2.5 w-2.5 rounded-[2px] bg-current"})}):null]})}function 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 Im({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:y,onPromptPaste:k,onPromptKeyDown:j,onPromptKeyUp:v,onPromptMouseUp:N,onPromptBlur:S,onPromptDragEnter:L,onPromptDragOver:P,onPromptDragLeave:K,onPromptDrop:F,onGoalTokenBudgetChange:D,onCancelGoal:Z,onShellPromptChange:Y}){return{promptSlot:e?null:t.jsx(Pm,{promptRef:r,prompt:n,disabled:a,promptPlaceholder:o,canInterrupt:s,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,onInterrupt:x,onInput:y,onPaste:k,onKeyDown:j,onKeyUp:v,onMouseUp:N,onBlur:S,onDragEnter:L,onDragOver:P,onDragLeave:K,onDrop:F}),goalSlot:u&&!e?t.jsx(Lm,{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:Y,onPromptKeyDown:j,onInterrupt:x}):null}}function Rm({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=mu({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 Am({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:y,forkBusy:k,fastMode:j,goalComposeMode:v,goalBusy:N,goalStatus:S,activeView:L,disabled:P,model:K,modelOptions:F,modelContextTitle:D,contextUsage:Z,reasoningEffort:Y,supportedEfforts:$,displayedCollaborationMode:te,sandboxMode:oe,sendButtonLabel:A,sendButtonClassName:J,modelControlsDisabled:I,effortControlsDisabled:q,effortControlTitle:O,forkTurnOptionsState:T,skillsState:U,copiedSkillName:H,hooksPanelMode:C,hooksState:E,hookConfigBusy:X,hookConfigError:W,hookConfigSuccess:le,editingHookTarget:Q,hookScope:de,hookEventName:re,hookMatcher:xe,hookCommand:ie,hookTimeoutSec:ve,hookStatusMessage:Pe,mcpPanelMode:se,mcpState:ye,mcpConfigPath:je,mcpConfigError:G,mcpConfigSuccess:me,mcpConfigBusy:ge,mcpHttpName:we,mcpHttpUrl:_e,mcpRawBlock:Re,capabilities:Ee,shellControlState:Me,onToggleView:_,onDismissPromptFocus:ue,onSetOpenMenu:R,onToolboxItemClick:M,onSetSlashPanelView:ee,onOpenForkTurns:pe,onForkLatest:ke,onForkTurn:Ae,onCopySkillInvokeName:Ne,onResetHookForm:De,onSetHooksPanelMode:et,onClearHookConfigStatus:Ve,onSetEditingHookTarget:ot,onSetHookScope:Qe,onSetHookEventName:ut,onSetHookMatcher:at,onSetHookCommand:Oe,onSetHookTimeoutSec:Be,onSetHookStatusMessage:Ue,onSaveHook:tt,onStartEditingHook:z,onTrustHook:V,onUntrustHook:fe,onSetMcpPanelMode:Le,onClearMcpConfigStatus:ne,onSetMcpHttpName:Ge,onSetMcpHttpUrl:He,onSetMcpRawBlock:Fe,onPrepareRawMcpBlock:qe,onSaveHttpMcp:dt,onSaveRawMcpBlock:xt,onPickPhoto:lt,onPickFile:wt,onUpdateSettings:yt,onPasteShell:jt,onCopyShell:be,onClearShell:ze,onShellControl:rt}){const Ye=e?null:{open:o==="slash",slashPanelView:g,availableToolboxItems:b,busy:w,forkBusy:k,forkTurnOptionsState:T,skillsState:U,copiedSkillName:H,hooksPanelMode:C,hooksState:E,hostConfigFilesAvailable:Ee.hostConfigFiles,hookTrustAvailable:Ee.hookTrust,hookConfigBusy:X,hookConfigError:W,hookConfigSuccess:le,editingHookTarget:Q,hookScope:de,hookEventName:re,hookMatcher:xe,hookCommand:ie,hookTimeoutSec:ve,hookStatusMessage:Pe,mcpPanelMode:se,mcpState:ye,mcpConfigEditing:Ee.mcpConfigEditing,mcpConfigPath:je,mcpConfigError:G,mcpConfigSuccess:me,mcpConfigBusy:ge,mcpHttpName:we,mcpHttpUrl:_e,mcpRawBlock:Re,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,onToggle:()=>R(ct=>ct==="slash"?null:"slash"),onToolboxItemClick:M,toolboxItemDisabled:ct=>Hu(ct,{settingsBusy:x,compactBusy:y,busy:w,forkBusy:k}),toolboxItemClassName:ct=>Ou(ct,{fastMode:j,goalComposeMode:v,goalStatus:S,menuItemClassName:d}),toolboxItemStatus:ct=>Fu(ct,{fastMode:j,compactBusy:y,goalComposeMode:v,goalStatus:S,busy:w}),onSetSlashPanelView:ee,onOpenForkTurns:pe,onForkLatest:ke,onForkTurn:Ae,onCopySkillInvokeName:Ne,onResetHookForm:De,onSetHooksPanelMode:et,onClearHookConfigStatus:Ve,onSetEditingHookTarget:ot,onSetHookScope:Qe,onSetHookEventName:ut,onSetHookMatcher:at,onSetHookCommand:Oe,onSetHookTimeoutSec:Be,onSetHookStatusMessage:Ue,onSaveHook:tt,onStartEditingHook:z,onTrustHook:V,onUntrustHook:fe,onSetMcpPanelMode:Le,onClearMcpConfigStatus:ne,onSetMcpHttpName:Ge,onSetMcpHttpUrl:He,onSetMcpRawBlock:Fe,onPrepareRawMcpBlock:qe,onSaveHttpMcp:dt,onSaveRawMcpBlock:xt},Ut=e?null:{open:o==="attachments",iconButtonClassName:l,menuClassName:i,menuItemClassName:d,onToggle:()=>R(ct=>ct==="attachments"?null:"attachments"),onPickPhoto:lt,onPickFile:wt},Wt=e?null:{openMenu:o,model:K,modelOptions:F,modelContextTitle:D,contextUsage:Z,reasoningEffort:Y,supportedEfforts:$,displayedCollaborationMode:te,sandboxMode:oe,planModeAvailable:Ee.planMode,sandboxModeAvailable:Ee.sandboxMode,settingsBusy:x,goalComposeMode:v,goalBusy:N,activeView:L,disabled:P,fastMode:j,sendButtonLabel:A,sendButtonClassName:J,modelControlsDisabled:I,effortControlsDisabled:q,effortControlTitle:O,inlineToggleClassName:m,menuItemClassName:d,planToggleActiveClassName:f,sendButtonBaseClassName:p,onSetOpenMenu:R,onUpdateSettings:yt};return{isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:o,toolbarClassName:s,iconButtonClassName:l,slashToolboxProps:Ye,attachmentMenuProps:Ut,settingsToolbarProps:Wt,shellToolsPanelProps:o==="shellTools"?{busy:w,shellControlState:Me,onPaste:jt,onCopy:be,onClear:ze,onShellControl:rt}:null,shellControlState:Me,onToggleView:_,onDismissPromptFocus:ue,onSetOpenMenu:R}}function Dn({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:y=!1,threadConnected:k=!0,shellAvailable:j=!0,disabled:v=!1,disabledPlaceholder:N,shellControlState:S=null,draftPrompt:L,draftAttachments:P,onPickAttachment:K,skillsState:F={status:"idle",data:null,error:null},mcpState:D={status:"idle",data:null,error:null},hooksState:Z={status:"idle",data:null,error:null},goalState:Y={status:"idle",data:null,error:null},forkTurnOptionsState:$={status:"idle",data:null,error:null},onDraftChange:te,onSubmit:oe,onInterrupt:A,onCompact:J,onOpenSkills:I,onOpenMcp:q,onOpenHooks:O,onCreateHook:T,onUpdateHook:U,onTrustHook:H,onUntrustHook:C,onOpenGoal:E,onUpdateGoal:X,onOpenForkTurns:W,onForkLatest:le,onForkTurn:Q,onReadProviderConfig:de,onWriteProviderConfig:re,onToggleFollow:xe,onUpdateSettings:ie,onToggleView:ve,onShellCopy:Pe,onShellControl:se,canInterrupt:ye=!1}){var ba;const[je,G]=c.useState(null),[me,ge]=c.useState("root"),[we,_e]=c.useState("list"),Re=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)&&!!de&&!!re,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,de,re]),Ee=c.useMemo(()=>Bu(b,Re),[Re,b]),Me=c.useRef(null),_=c.useRef(null),ue=c.useRef(null),R=c.useRef(null),M=c.useRef(null),ee=c.useRef([]),pe=c.useRef(null),ke=c.useRef(""),Ae=c.useRef(0),Ne=e==="shell",De=j||Ne,et=!!(Ne&&(S!=null&&S.isMobileShell)),Ve=(S==null?void 0:S.promptLabel)??null,[ot,Qe]=c.useState(!1),[ut,at]=c.useState(0),{prompt:Oe,attachments:Be,isDraftControlled:Ue,updateDraft:tt,flushControlledDraftToHost:z}=bm({isShellView:Ne,draftPrompt:L,draftAttachments:P,onDraftChange:te}),V=gm({attachments:Be,isShellView:Ne}),{displayedCollaborationMode:fe,updateSettings:Le}=Rm({collaborationMode:h,onUpdateSettings:ie,closeMenu:()=>G(null)}),{forkBusy:ne,forkLatest:Ge,forkTurn:He}=vm({slashPanelView:me,onForkLatest:le,onForkTurn:Q,closeMenu:()=>G(null)}),{hooksPanelMode:Fe,hookScope:qe,hookEventName:dt,hookMatcher:xt,hookCommand:lt,hookTimeoutSec:wt,hookStatusMessage:yt,editingHookTarget:jt,hookConfigBusy:be,hookConfigError:ze,hookConfigSuccess:rt,setHooksPanelMode:Ye,setEditingHookTarget:Ut,setHookScope:Wt,setHookEventName:ia,setHookMatcher:ct,setHookCommand:yl,setHookTimeoutSec:jl,setHookStatusMessage:Nl,clearHookConfigStatus:da,resetHookForm:Cl,startEditingHook:Sl,saveHook:Tl,trustHook:El,untrustHook:Ll}=ym({slashPanelView:me,hookCommandTemplates:w,onCreateHook:T,onUpdateHook:U,onTrustHook:H,onUntrustHook:C}),{goalComposeMode:sr,goalTokenBudget:Pl,goalBusy:tn,goalLocalError:zl,setGoalTokenBudget:Il,submitGoal:Rl,enterGoalComposeMode:Al,exitGoalComposeMode:ca}=km({prompt:Oe,goalTokenBudgetSource:Y.data,promptRef:_,onOpenGoal:E,onUpdateGoal:X,updateDraft:tt,closeMenu:()=>G(null),resetSlashPanel:()=>ge("root")}),{mcpHttpName:_l,mcpHttpUrl:Ml,mcpRawBlock:$l,mcpConfigPath:Dl,mcpConfigBusy:Bl,mcpConfigError:Gl,mcpConfigSuccess:Fl,setMcpHttpName:Hl,setMcpHttpUrl:Ol,setMcpRawBlock:Ul,clearMcpConfigStatus:ha,prepareRawMcpBlock:Wl,saveHttpMcp:Vl,saveRawMcpBlock:Kl}=Nm({hostConfigFilesAvailable:Re.hostConfigFiles,onReadProviderConfig:de,onWriteProviderConfig:re,setMcpPanelMode:_e,onOpenMcp:q}),{copiedSkillName:ql,copySkillInvokeName:Xl}=Cm({openMenu:je,setOpenMenu:G,slashPanelView:me,setSlashPanelView:ge,setMcpPanelMode:_e,clearMcpConfigStatus:ha,clearHookConfigStatus:da}),Yl=c.useCallback(ae=>{tt(Ce=>{if(typeof ae=="function"){const Ie=ae(Ce.prompt,Ce.attachments);return{prompt:Ie.prompt,attachments:Ie.attachments??Ce.attachments}}return{prompt:ae,attachments:Ce.attachments}})},[tt]),rn=c.useMemo(()=>f.find(ae=>ae.model===l)??null,[l,f]),Zl=vu(l,p),ua=(rn==null?void 0:rn.supportedReasoningEfforts)??[],Jl=c.useMemo(()=>au(Oe,Be),[Be,Oe]),Ql=c.useMemo(()=>Object.entries(V).sort(([ae],[Ce])=>ae.localeCompare(Ce)).map(([ae,Ce])=>`${ae}:${Ce}`).join("|"),[V]);function ei(ae,Ce){Ce.stopPropagation();const Ie=Gu(ae,{fastMode:d,goalComposeMode:sr});switch(Ie.type){case"toggleFast":Le({fastMode:Ie.fastMode});break;case"runCompact":G(null),J==null||J();break;case"enterGoalCompose":Al();break;case"exitGoalCompose":ca(),G(null);break;case"openPanel":ge(Ie.panel),Ie.panel==="skills"?I==null||I():Ie.panel==="mcp"?q==null||q():Ie.panel==="hooks"&&(O==null||O());break;case"insertPrompt":sn(Ie.text),ge("root"),G(null);break}}function Vt(){const ae=_.current;return ae?Vu(ae):null}const ti=c.useCallback(ae=>{const Ce=_.current;!Ce||!ae||Ku(Ce,ae)},[]),nn=c.useCallback(()=>{const ae=_.current;return ae?Jo(ae):Oe},[Oe]),{appendAttachments:an,appendDroppedAttachments:ma}=fm({prompt:Oe,attachments:Be,updateDraft:tt,getSelection:Vt,selectionSnapshotRef:pe,pendingSelectionRef:M,pendingInsertedAttachmentIdsRef:ee,onInserted:()=>G(null)}),pa=c.useCallback((ae,Ce)=>{var Ie;if(zt(),K){K({kind:ae,appendAttachments:(Ze,st=ae)=>an(Ze,st),defaultPick:()=>{var Ze;return(Ze=Ce.current)==null?void 0:Ze.click()}});return}(Ie=Ce.current)==null||Ie.click()},[an,zt,K]);function sn(ae){if(!ae)return;const Ce=Vt()??pe.current,Ie=(Ce==null?void 0:Ce.start)??Oe.length,Ze=(Ce==null?void 0:Ce.end)??Ie,st=nu(ae),Kt=`${Oe.slice(0,Ie)}${st}${Oe.slice(Ze)}`;tt(Mi=>({prompt:Kt,attachments:Mi.attachments}));const It=Ie+st.length;M.current={start:It,end:It},pe.current={start:It,end:It}}Em({promptRef:_,isShellView:Ne,prompt:Oe,promptSegments:Jl,attachmentPreviewUrls:V,previewSignature:Ql,editorSanitizeNonce:ut,pendingSelectionRef:M,pendingInsertedAttachmentIdsRef:ee,selectionSnapshotRef:pe,renderedPreviewSignatureRef:ke,renderedSanitizeNonceRef:Ae,serializeEditorPrompt:nn,restoreSelection:ti});function zt(){var ae;(ae=_.current)==null||ae.blur(),document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.blur()}async function ri(){var ae;if(zt(),G(null),!!((ae=navigator.clipboard)!=null&&ae.readText))try{const Ce=await navigator.clipboard.readText();sn(Ce)}catch{return}}async function fa(){if(Ue&&z(),sr&&!Ne){await Rl();return}const ae=du({prompt:Oe,attachments:Be,isShellView:Ne});!ae||await oe(ae)===!1||tt(()=>({prompt:"",attachments:[]}))}async function ni(ae){ae.preventDefault(),await fa()}function ai(){const ae=nn(),Ce=Vt();pe.current=Ce;const Ie=_.current;(Ie?Wu(Ie):!1)&&(M.current=Ce,at(st=>st+1)),tt(st=>({prompt:ae,attachments:st.attachments.filter(Kt=>ae.includes(Kt.placeholder))}),"deferred")}function si(ae){var Ze,st,Kt,It;const Ce=Mn((Ze=ae.clipboardData)==null?void 0:Ze.items,(st=ae.clipboardData)==null?void 0:st.files),Ie=cu({files:Ce,plainText:((Kt=ae.clipboardData)==null?void 0:Kt.getData("text/plain"))??"",htmlText:((It=ae.clipboardData)==null?void 0:It.getData("text/html"))??"",htmlToText:Uu});Ie.preventDefault&&ae.preventDefault(),Ie.type==="insert-text"?sn(Ie.text):Ie.type==="append-files"&&ma(Ie.files)}function oi(ae){var Ie,Ze;const Ce=Xa(Ja((Ie=ae.dataTransfer)==null?void 0:Ie.items,(Ze=ae.dataTransfer)==null?void 0:Ze.files));Ce.preventDefault&&ae.preventDefault(),Ce.activateDragTarget&&Qe(!0)}function li(ae){var Ie,Ze;const Ce=Xa(Ja((Ie=ae.dataTransfer)==null?void 0:Ie.items,(Ze=ae.dataTransfer)==null?void 0:Ze.files));Ce.preventDefault&&ae.preventDefault(),Ce.activateDragTarget&&ae.dataTransfer&&(ae.dataTransfer.dropEffect="copy"),Ce.activateDragTarget&&Qe(!0)}function ii(ae){ae.currentTarget.contains(ae.relatedTarget)||Qe(!1)}function di(ae){var Ze,st;const Ce=Mn((Ze=ae.dataTransfer)==null?void 0:Ze.items,(st=ae.dataTransfer)==null?void 0:st.files),Ie=hu(Ce);Ie.preventDefault&&ae.preventDefault(),Ie.type==="accept-files"&&(Qe(!1),ma(Ie.files??[]))}function ci(ae){if(e==="chat"&&ae.key==="/"&&!ae.metaKey&&!ae.ctrlKey&&!ae.altKey&&!n&&!v&&Ee.length>0&&nn().trim().length===0){ae.preventDefault(),ge("root"),G("slash");return}const Ce=uu({key:ae.key,metaKey:ae.metaKey,ctrlKey:ae.ctrlKey,busy:n,disabled:v});Ce.preventDefault&&ae.preventDefault(),Ce.submit&&fa()}const{promptPlaceholder:hi,interruptLabel:ui,sendButtonLabel:ga,sendButtonClassName:xa,modelControlsDisabled:mi,effortControlsDisabled:pi,effortControlTitle:fi}=ju({goalComposeMode:sr,goalBusy:tn,threadConnected:k,busy:n,isShellView:Ne,disabledPlaceholder:N,settingsBusy:a,supportedEffortCount:ua.length,fastMode:d}),{composerLayerClassName:gi,formClassName:xi,composerShellClassName:bi,composerToolbarClassName:vi,composerIconButtonClassName:ki,composerMenuClassName:wi,composerMenuItemClassName:yi,composerInlineToggleClassName:ji,composerPanelButtonClassName:Ni,composerChipButtonClassName:Ci,composerPlanToggleActiveClassName:Si,composerSendButtonClassName:Ti,composerPromptRegionClassName:Ei,promptInputClassName:Li,graphChatInputGroupClassName:Pi,graphChatInputClassName:zi}=Nu({isShellView:Ne,edgeToEdgeMobile:r,isMobileShell:et,openMenu:je!==null,isDragTargetActive:ot,busy:n}),Ii=Am({isShellView:Ne,canToggleShellView:De,isMobileShell:et,shellPromptLabel:Ve,openMenu:je,toolbarClassName:vi,iconButtonClassName:ki,menuClassName:wi,menuItemClassName:yi,panelButtonClassName:Ni,chipButtonClassName:Ci,inlineToggleClassName:ji,planToggleActiveClassName:Si,sendButtonBaseClassName:Ti,slashPanelView:me,availableToolboxItems:Ee,busy:n,settingsBusy:a,compactBusy:o,forkBusy:ne,fastMode:d,goalComposeMode:sr,goalBusy:tn,goalStatus:(ba=Y.data)==null?void 0:ba.status,activeView:e,disabled:v,model:l,modelOptions:f,modelContextTitle:Zl,contextUsage:p,reasoningEffort:i,supportedEfforts:ua,displayedCollaborationMode:fe,sandboxMode:u,sendButtonLabel:ga,sendButtonClassName:xa,modelControlsDisabled:mi,effortControlsDisabled:pi,effortControlTitle:fi,forkTurnOptionsState:$,skillsState:F,copiedSkillName:ql,hooksPanelMode:Fe,hooksState:Z,hookConfigBusy:be,hookConfigError:ze,hookConfigSuccess:rt,editingHookTarget:jt,hookScope:qe,hookEventName:dt,hookMatcher:xt,hookCommand:lt,hookTimeoutSec:wt,hookStatusMessage:yt,mcpPanelMode:we,mcpState:D,mcpConfigPath:Dl,mcpConfigError:Gl,mcpConfigSuccess:Fl,mcpConfigBusy:Bl,mcpHttpName:_l,mcpHttpUrl:Ml,mcpRawBlock:$l,capabilities:{hostConfigFiles:Re.hostConfigFiles,hookTrust:Re.hookTrust,mcpConfigEditing:Re.mcpConfigEditing,planMode:Re.planMode,sandboxMode:m?!1:Re.sandboxMode},shellControlState:S,onToggleView:ve,onDismissPromptFocus:zt,onSetOpenMenu:G,onToolboxItemClick:ei,onSetSlashPanelView:ge,onOpenForkTurns:()=>W==null?void 0:W(),onForkLatest:Ge,onForkTurn:He,onCopySkillInvokeName:Xl,onResetHookForm:Cl,onSetHooksPanelMode:Ye,onClearHookConfigStatus:da,onSetEditingHookTarget:Ut,onSetHookScope:Wt,onSetHookEventName:ia,onSetHookMatcher:ct,onSetHookCommand:yl,onSetHookTimeoutSec:jl,onSetHookStatusMessage:Nl,onSaveHook:Tl,onStartEditingHook:Sl,onTrustHook:El,onUntrustHook:Ll,onSetMcpPanelMode:_e,onClearMcpConfigStatus:ha,onSetMcpHttpName:Hl,onSetMcpHttpUrl:Ol,onSetMcpRawBlock:Ul,onPrepareRawMcpBlock:Wl,onSaveHttpMcp:Vl,onSaveRawMcpBlock:Kl,onPickPhoto:()=>pa("photo",ue),onPickFile:()=>pa("file",R),onUpdateSettings:ae=>void Le(ae),onPasteShell:()=>void ri(),onCopyShell:()=>{zt(),G(null),Pe==null||Pe()},onClearShell:()=>{zt(),G(null),oe({prompt:"clear"})},onShellControl:ae=>{zt(),G(null),se==null||se(ae)}}),{promptSlot:Ri,goalSlot:Ai,shellPromptSlot:_i}=Im({isShellView:Ne,promptRef:_,prompt:Oe,disabled:v,promptPlaceholder:hi,canInterrupt:ye,interruptLabel:ui,composerPromptRegionClassName:Ei,graphChatInputClassName:zi,promptInputClassName:Li,goalComposeMode:sr,goalTokenBudget:Pl,goalLocalError:zl,goalBusy:tn,busy:n,sendButtonLabel:ga,sendButtonClassName:xa,onInterrupt:A,onPromptInput:ai,onPromptPaste:si,onPromptKeyDown:ci,onPromptKeyUp:()=>{pe.current=Vt()},onPromptMouseUp:()=>{pe.current=Vt()},onPromptBlur:()=>{pe.current=Vt(),Qe(!1),Ue&&z()},onPromptDragEnter:oi,onPromptDragOver:li,onPromptDragLeave:ii,onPromptDrop:di,onGoalTokenBudgetChange:Il,onCancelGoal:ca,onShellPromptChange:Yl});return t.jsx(rm,{activeView:e,layerClassName:gi,formClassName:xi,shellClassName:bi,inputGroupClassName:Pi,error:s,followTail:y,photoInputRef:ue,fileInputRef:R,onAppendAttachments:an,onToggleFollow:xe,onSubmit:ni,formRef:Me,promptSlot:Ri,toolbarSlot:t.jsx(um,{...Ii}),goalSlot:Ai,shellPromptSlot:_i})}var _m=c.createContext(null);function el(){return c.useContext(_m)}function ft(e){return e?new Date(e).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"}):"Time unavailable"}function Gt(e){return e?new Date(e).toLocaleString():"Time unavailable"}function Mm(e){switch(e){case"idle":return"Idle";case"running":return"Running";case"interrupted":return"Interrupted";case"failed":return"Failed";case"not_loaded":return"Not Loaded";case"system_error":return"System Error"}}function $m(e){switch(e){case"idle":return"ui-status-neutral";case"running":return"ui-status-info";case"interrupted":return"ui-status-warning";case"failed":case"system_error":return"ui-status-danger";case"not_loaded":return"ui-status-neutral"}}function tl(e){switch(e){case"sending":return"Sending";case"completed":return"Completed";case"interrupted":return"Interrupted";case"failed":return"Failed";case"inProgress":return"Running"}}function Dm({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 Or.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 Bm({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 Gm({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 Fm({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 Hm({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 Om({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 Um({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 Wm({children:e}){return t.jsx("div",{className:"thread-split-region min-h-0 flex-1 overflow-hidden p-0 sm:p-2",children:e})}yo();Pt();function ss({...e}){return t.jsx(Hi,{"data-slot":"dialog",...e})}function os({...e}){return t.jsx(Oi,{"data-slot":"dialog-trigger",...e})}function Vm({...e}){return t.jsx(qi,{"data-slot":"dialog-portal",...e})}function Km({className:e,...r}){return t.jsx(Xi,{"data-slot":"dialog-overlay",className:nt("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 ls({children:e,className:r,showCloseButton:n=!0,...a}){return t.jsxs(Vm,{"data-slot":"dialog-portal",children:[t.jsx(Km,{}),t.jsxs(Ui,{"data-slot":"dialog-content",className:nt("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(Wi,{"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(B.XIcon,{}),t.jsx("span",{className:"sr-only",children:"Close"})]}):null]})]})}function is({className:e,...r}){return t.jsx("div",{"data-slot":"dialog-header",className:nt("flex flex-col gap-2 text-center sm:text-left",e),...r})}function ds({className:e,...r}){return t.jsx(Vi,{"data-slot":"dialog-title",className:nt("text-lg font-semibold leading-none",e),...r})}function cs({className:e,...r}){return t.jsx(Ki,{"data-slot":"dialog-description",className:nt("text-sm text-muted-foreground",e),...r})}var qm=[{value:"system",label:"Follow system",icon:B.Monitor},{value:"dark",label:"Dark",icon:B.Moon},{value:"light",label:"Light",icon:B.Sun}];function Xm({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 y(){const S=e.providerSessionId;if(S)try{await navigator.clipboard.writeText(S),p("copied"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>p("idle"),1200)}catch{p("failed"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>p("idle"),1600)}}const k=()=>o(e.id),j=`thread-graph-room-card group flex w-full items-center gap-3 rounded-xl border text-left transition ${x?"is-active":""} ${m?"justify-center px-2 py-2":"px-3 py-2.5"}`,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(B.MessageSquare,{className:"h-4 w-4"})}),t.jsxs("div",{className:`min-w-0 flex-1 ${m?"thread-desktop-collapsed-hidden":""}`,children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[t.jsx("p",{className:"thread-graph-room-card-title min-w-0 flex-1 truncate text-sm font-medium",title:e.title,children:e.title}),i&&!m?t.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),S.preventDefault(),i(e)},"aria-label":`Rename thread ${e.title}`,title:"Rename thread",className:"thread-card-quiet-button inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full transition",children:t.jsx(B.Pencil,{className:"h-3 w-3"})}):null,u&&e.providerSessionId?t.jsx("button",{type:"button","aria-label":"Copy session ID",title:f==="copied"?"Copied":f==="failed"?"Copy failed":"Copy session ID",onClick:S=>{S.stopPropagation(),S.preventDefault(),y()},className:"thread-card-quiet-button thread-card-session-copy-button inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition",children:t.jsx(B.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 ${$m(e.status)}`,children:Mm(e.status)}),t.jsx("time",{className:"shrink-0 text-[11px] text-[var(--theme-fg-muted)]",dateTime:e.lastTurnStartedAt??e.updatedAt,children:ft(e.lastTurnStartedAt??e.updatedAt)})]})]}),h&&d&&!m?t.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),S.preventDefault(),d(e)},"aria-label":`Delete thread ${e.title}`,className:"thread-card-danger-button shrink-0 rounded-full p-1 transition",title:"Delete thread",children:t.jsx(B.Trash2,{className:"h-3.5 w-3.5"})}):null]}),N=s==null?void 0:s(e.id);return l?t.jsx(t.Fragment,{children:l({thread:e,children:v,className:j,onClick:k})}):N?t.jsx("a",{href:N,onClick:S=>{S.preventDefault(),k()},title:m?e.title:void 0,className:j,children:v}):t.jsx("div",{role:"link",tabIndex:0,onClick:k,onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),k())},title:m?e.title:void 0,className:j,children:v})}function Ym({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(Xm,{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 Zm({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:y=null,threadActionsButton:k,topbarActions:j,metaContent:v,settingsContent:N,globalSettingsContent:S,workspaceLabels:L={},workspaceReturnHref:P,onWorkspaceReturn:K,getThreadHref:F,onOpenThread:D,getNewThreadHref:Z,newThreadHref:Y,newThreadLabel:$="New Chat",onNewThread:te,onNewThreadTitle:oe,renderNewThreadDialogContent:A,renderThreadLink:J,onCloseAppNavigation:I,onRenameThread:q,onDeleteThread:O,workspaceContent:T,workspaceTitle:U="Workspace",workspaceActions:H,children:C}){const E=el(),X=typeof window<"u"?window.matchMedia("(max-width: 639px)").matches:s==="mobile",[W,le]=c.useState(()=>typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)").matches:!1),Q=i??(E==null?void 0:E.themeMode)??"system",de=l??(E==null?void 0:E.effectiveTheme)??(Q==="system"?W?"dark":"light":Q),[re,xe]=c.useState(!1),[ie,ve]=c.useState(!1),[Pe,se]=c.useState(!X),[ye,je]=c.useState(X),[G,me]=c.useState("chat"),[ge,we]=c.useState(null),[_e,Re]=c.useState(""),[Ee,Me]=c.useState(null),[_,ue]=c.useState(!1),[R,M]=c.useState(""),[ee,pe]=c.useState(!1),[ke,Ae]=c.useState(!1),[Ne,De]=c.useState("session");c.useEffect(()=>{if(typeof window>"u")return;const be=window.matchMedia("(max-width: 639px)"),ze=()=>{je(be.matches)};return ze(),be.addEventListener("change",ze),()=>{be.removeEventListener("change",ze)}},[]),c.useEffect(()=>{if(typeof window>"u")return;const be=window.matchMedia("(prefers-color-scheme: dark)"),ze=()=>{le(be.matches)};return ze(),be.addEventListener("change",ze),()=>{be.removeEventListener("change",ze)}},[]);const et=c.useMemo(()=>[...b?e.filter(ze=>ze.workspaceId===b):e].sort((ze,rt)=>{if(ze.id===p)return-1;if(rt.id===p)return 1;const Ye=Date.parse(ze.lastTurnStartedAt??ze.updatedAt);return Date.parse(rt.lastTurnStartedAt??rt.updatedAt)-Ye}),[p,b,e]),Ve=Y??(Z==null?void 0:Z(b)),ot=w??b??"all",Qe=x??g??p??"default_session",ut=y??(r!=null&&r.state?`runtime ${r.state}`:"waiting for agent usage"),at=d??(E==null?void 0:E.setThemeMode),Oe=!!at,Be=()=>{xe(!1),I==null||I()};async function Ue(be){if(!q)return;const ze=_e.trim();if(ze){Me(be);try{await q(be,ze),we(null),Re("")}finally{Me(null)}}}function tt(be){we(be.id),Re(be.title)}function z(){we(null),Re("")}function V(be){D==null||D(be),Be()}function fe(){ue(!1),M("")}function Le(be){if(!Ve||!be.trim())return Ve;try{const ze=new URL(Ve,window.location.origin);return ze.searchParams.set("title",be.trim()),`${ze.pathname}${ze.search}${ze.hash}`}catch{const ze=Ve.includes("?")?"&":"?";return`${Ve}${ze}title=${encodeURIComponent(be.trim())}`}}async function ne(){const be=R.trim();pe(!0);try{if(be&&oe){await oe(be),M(""),ue(!1),Be();return}if(Ve){window.location.assign(Le(be)??Ve);return}await(te==null?void 0:te()),M(""),ue(!1),Be()}finally{pe(!1)}}function Ge(be,ze=!1){const rt=ze?t.jsxs(t.Fragment,{children:[t.jsx(B.Plus,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:$})]}):t.jsxs(t.Fragment,{children:[t.jsx(B.Plus,{className:"h-4 w-4"}),t.jsx("span",{children:$})]});return t.jsxs(ss,{open:_,onOpenChange:Ye=>{ee||ue(Ye)},children:[t.jsx(os,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":ze?$:void 0,title:$,className:be,children:rt})}),t.jsx(ls,{"data-testid":"create-thread-dialog","data-theme-effective":de,"data-theme-mode":Q,className:"thread-graph-create-thread-dialog thread-graph-dialog max-h-[min(86vh,42rem)] overflow-hidden p-4 sm:max-w-[34rem]",children:A?A({close:fe,closeNavigation:Be,currentWorkspaceId:b}):t.jsxs(t.Fragment,{children:[t.jsxs(is,{children:[t.jsx(ds,{children:"Create New Chat"}),t.jsx(cs,{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:R,onChange:Ye=>M(Ye.target.value),onKeyDown:Ye=>{Ye.key==="Enter"&&(Ye.preventDefault(),ne())},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 ne(),disabled:ee,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:ee?"Creating...":"Create"})]})]})})]})}function He(){if(!N&&!v&&!S&&!Oe)return null;const be=!!(N||v),ze=!!S,rt=Ne==="global"&&ze||!be&&ze?"global":"session";return t.jsxs(ss,{...u!==void 0?{open:u}:{},...m?{onOpenChange:m}:{},children:[t.jsx(os,{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(B.Settings,{className:"h-4 w-4"})})}),t.jsxs(ls,{"data-testid":"settings-dialog","data-theme-effective":de,"data-theme-mode":Q,className:"thread-graph-settings-dialog thread-graph-dialog",children:[t.jsxs(is,{children:[t.jsx(ds,{children:"Settings"}),t.jsx(cs,{children:"Manage this session and host-wide preferences."})]}),Oe?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:qm.map(Ye=>{const Ut=Ye.icon,Wt=Q===Ye.value;return t.jsxs("button",{type:"button","data-testid":`theme-mode-${Ye.value}`,"aria-pressed":Wt,disabled:!Oe,onClick:()=>at==null?void 0:at(Ye.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 ${Wt?"is-selected":""}`,children:[t.jsx(Ut,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:"truncate",children:Ye.label})]},Ye.value)})})]})}):null,t.jsxs("div",{className:"thread-graph-settings-tabs grid grid-cols-2 gap-1 rounded-lg border p-1",children:[t.jsx("button",{type:"button","aria-pressed":rt==="session",onClick:()=>De("session"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${rt==="session"?"is-active":""}`,children:"Session"}),t.jsx("button",{type:"button","aria-pressed":rt==="global",disabled:!ze,onClick:()=>De("global"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${rt==="global"?"is-active":""}`,children:"Global"})]}),t.jsx("div",{className:"thread-graph-settings-body mt-4 min-h-0 overflow-y-auto pr-1 text-sm",children:rt==="session"?t.jsxs("div",{className:"grid gap-4",children:[N?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:N}):null,v?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:v}):null,be?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:S})})]})]})}function Fe(be=!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)] ${be?"justify-center":""}`,children:[t.jsx(B.Rows3,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:be?"sr-only":"",children:"Rooms"}),!be&&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&&et.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,et.length>0?t.jsx(Ym,{threads:et,currentThreadId:p,currentWorkspaceId:b,workspaceLabels:L,onOpenThread:V,collapsed:be,...q?{onBeginRenameThread:tt}:{},showDeleteButton:!!O,...F?{getThreadHref:F}:{},...J?{renderThreadLink:J}:{},...O?{onDeleteThread:O}:{}}):null]})]})})}function qe(){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:()=>se(!0),className:"thread-workspace-collapse-tab thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(B.ChevronsRight,{className:"h-4 w-4"})}),H?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:H})}):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:U}),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:[H,t.jsx("button",{type:"button",onClick:()=>se(!0),className:"thread-workspace-small-toggle thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(B.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 dt=!!T,xt=s==="mobile"||s==="responsive"&&ye,lt=xt,wt=lt&&!re,jt=!!(P||K)?t.jsx("a",{href:P??"#",onClick:be=>{K&&(be.preventDefault(),K())},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(B.ArrowLeft,{className:"h-4 w-4"})}):null;return t.jsxs(t.Fragment,{children:[t.jsx(Bm,{effectiveTheme:de,layoutMode:s,themeMode:Q,viewportConstrained:o,children:t.jsxs(Gm,{roomsRailCollapsed:ie,children:[t.jsx(Fm,{open:re,onClose:()=>xe(!1)}),t.jsxs(Hm,{collapsed:ie,mobileOpen:re,children:[t.jsx("div",{className:`thread-rooms-rail-header flex h-[calc(3.75rem+env(safe-area-inset-top))] shrink-0 items-end border-b border-[var(--theme-border)] px-4 pb-3 sm:h-16 sm:items-center sm:pb-0 ${ie?"sm:w-full sm:justify-center sm:px-2":""}`,children:t.jsxs("div",{className:`flex w-full items-center gap-3 ${ie?"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:()=>ve(be=>!be),className:"thread-icon-button thread-desktop-only-flex h-9 w-9 shrink-0 items-center justify-center rounded-full",title:ie?"Expand rooms":"Collapse rooms","aria-label":ie?"Expand rooms":"Collapse rooms",children:ie?t.jsx(B.PanelLeftOpen,{className:"h-4 w-4"}):t.jsx(B.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)] ${ie?"thread-desktop-collapsed-hidden":""}`,children:(w??"R").charAt(0).toUpperCase()}),t.jsxs("div",{className:`min-w-0 ${ie?"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 ${ie?"thread-desktop-collapsed-hidden":""}`,children:[He(),jt,t.jsx("button",{type:"button",onClick:()=>xe(!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(B.X,{className:"h-4 w-4"})})]})]})}),t.jsx("div",{className:`thread-graph-new-room-strip flex shrink-0 items-center border-b ${ie?"h-12 w-full justify-center px-2 sm:h-12":"h-[68px] px-4"}`,children:Ge(`thread-graph-new-room-button inline-flex items-center justify-center rounded-xl font-medium transition ${ie?"h-9 w-9 p-0":"h-11 w-full gap-2 px-3 text-sm sm:h-9"}`,ie)}),t.jsx("div",{className:`flex min-h-0 flex-1 flex-col ${ie?"w-full px-2 py-2":"px-3 py-3"}`,children:Fe(ie)})]}),t.jsxs(Om,{children:[t.jsx(Um,{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:[wt?t.jsx("button",{type:"button",onClick:()=>xe(!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(B.Menu,{className:"h-4 w-4"})}):null,t.jsxs("div",{className:"min-w-0",children:[lt?t.jsx("h1",{className:"thread-mobile-only-block min-w-0 truncate text-sm font-semibold leading-none text-[var(--theme-fg)]",children:g??"Shared Workspace"}):null,t.jsxs("div",{className:"relative flex min-w-0 items-center gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{Ae(be=>!be)},"aria-expanded":ke,"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:ot})]}),ke?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 be;Qe&&((be=navigator.clipboard)==null||be.writeText(Qe))},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:Qe})]}),t.jsxs("div",{className:"thread-topbar-meta-row mt-1 flex min-w-0 max-w-full items-center gap-2 text-xs leading-5",title:"Session token usage and estimated cost",children:[t.jsx("span",{className:"w-14 shrink-0",children:"Usage"}),t.jsx("span",{className:"truncate font-mono",children:ut})]})]}):null]})]})]}),t.jsxs("div",{className:"relative z-[1] inline-flex shrink-0 items-center gap-2",children:[k||j?t.jsxs("div",{className:"thread-graph-topbar-actions thread-desktop-only-inline-flex items-center rounded-lg border p-0.5 shadow-none",children:[k,j]}):null,lt&&k?t.jsx("div",{className:"thread-mobile-only-inline-flex",children:k}):null,lt&&dt?t.jsx("button",{type:"button",onClick:()=>me(be=>be==="workspace"?"chat":"workspace"),"aria-label":G==="workspace"?"Show chat":"Show workspace",title:G==="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:G==="workspace"?t.jsx(B.MessageSquare,{className:"h-4 w-4"}):t.jsx(B.Folder,{className:"h-4 w-4"})}):null,lt?f:null,lt&&h?Ge("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(Wm,{children:dt&&!Pe?xt?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 ${G==="chat"?"block":"thread-mobile-chat-hidden"}`,children:C}),t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${G==="workspace"?"block":"thread-mobile-workspace-hidden"}`,children:qe()})]}):t.jsxs(Tn,{direction:"horizontal",className:"thread-split-container thread-graph-shell-resizable thread-graph-shell-desktop-split h-full min-h-0 overflow-hidden",children:[t.jsx(er,{defaultSize:47,minSize:30,maxSize:75,className:"thread-split-chat-pane min-w-0 overflow-hidden",children:C}),t.jsx(En,{className:"thread-resize-handle w-2 bg-transparent after:w-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(er,{defaultSize:53,minSize:30,maxSize:70,className:"thread-split-workspace-pane min-w-0 overflow-hidden",children:qe()})]}):t.jsxs("div",{className:"thread-split-container relative h-full min-h-0 overflow-hidden",children:[dt&&Pe?t.jsx("button",{type:"button",onClick:()=>se(!1),className:"thread-workspace-expand-fab thread-desktop-only-inline-flex",title:"Expand workspace","aria-label":"Expand workspace",children:t.jsx(B.ChevronsLeft,{className:"h-4 w-4"})}):null,C]})})]})]})}),t.jsx(Dm,{open:ge!==null,title:"Rename Thread",label:"Thread Title",value:_e,busy:Ee!==null,onChange:Re,onCancel:z,onSubmit:()=>ge?Ue(ge):void 0})]})}function Jm({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?Or.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 Qm=[/^(?: {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],ep=/^(?:\|?[^|\n]+\|[^|\n]+(?:\|[^|\n]+)*\|?\s*\n\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$)/m,tp=/!?\[[^\]\n]+\]\([^)]+\)/,rp=/`[^`\n]+`/,np=/(?:\*\*[^*\n]+\*\*|__[^_\n]+__)/,ap=/(^|[^\w])(?:\*[^*\n]+\*|_[^_\n]+_)(?=[^\w]|$)/,sp=/~~[^~\n]+~~/;function op(e){const r=e.trim();return r?Qm.some(n=>n.test(r))||ep.test(r)?!0:/[`[\]*_~!]/.test(r)?tp.test(r)||rp.test(r)||np.test(r)||ap.test(r)||sp.test(r):!1:!1}Xr();function Bn(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 ta(e=[]){const r=Bn(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 ra=c.createContext(ta());function na(){return c.useContext(ra)??ta()}jr();function rl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function hs(e){return rl(e)?Object.entries(e):e==null||e===""?[]:[["value",e]]}function nl(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 lp(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)}):nl(r)}function us({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(B.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"};case"failed":return{className:"is-failed",icon:t.jsx(B.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"};default:return{className:"is-pending",icon:t.jsx(B.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),label:"Running"}}},[n]),l=c.useMemo(()=>hs(o),[o]),i=c.useMemo(()=>hs(a),[a]),d=c.useMemo(()=>typeof o=="string"?o.length>0:rl(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(kr,{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(wr,{value:"item-1",className:"border-0",children:[t.jsx(Yr,{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(B.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(yr,{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:": "}),nl(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:": "}),lp(f,p),g<l.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},f)),"}"]})]}):null]})]})})})}var ms=null;function ip(){return ms??(ms=Promise.all([Ke(()=>import("./core-oEok_Crl.js"),__vite__mapDeps([0,1,2])),Ke(()=>import("./engine-javascript-DBd1bXLz.js"),[]),Ke(()=>import("./ayu-light-BA47KaF1.js"),[]),Ke(()=>import("./ayu-dark-DYE7WIF3.js"),[]),Ke(()=>import("./javascript-wDzz0qaB.js"),[]),Ke(()=>import("./typescript-BPQ3VLAy.js"),[]),Ke(()=>import("./tsx-COt5Ahok.js"),[]),Ke(()=>import("./jsx-g9-lgVsj.js"),[]),Ke(()=>import("./python-B6aJPvgy.js"),[]),Ke(()=>import("./json-Cp-IABpG.js"),[]),Ke(()=>import("./shellscript-CEILq0vU.js").then(e=>e.b),[]),Ke(()=>import("./shellscript-CEILq0vU.js").then(e=>e.s),[]),Ke(()=>import("./yaml-Buea-lGh.js"),[]),Ke(()=>import("./toml-vGWfd6FD.js"),[]),Ke(()=>import("./markdown-Cvjx9yec.js"),[]),Ke(()=>import("./html-pp8916En.js"),__vite__mapDeps([3,4,5])),Ke(()=>import("./css-CLj8gQPS.js"),[]),Ke(()=>import("./sql-CRqJ_cUM.js"),[]),Ke(()=>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,y])=>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,y.default]}))),ms}function Zr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Gn(e){if(!e)return{};if(Zr(e)&&Object.prototype.hasOwnProperty.call(e,"0"))try{const r=Object.keys(e).map(Number).filter(n=>Number.isFinite(n)).sort((n,a)=>n-a).map(n=>String(e[String(n)]??"")).join("");return JSON.parse(r)}catch{return e}if(typeof e=="string")try{return JSON.parse(e)}catch{return e}return e}function Fn(){return{finalResult:null,stdout:"",stderr:""}}function dp(e){return typeof e=="string"?{result:e}:e}function al(e){const r=Zr(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 ps(e){if(!e)return"pending";if(!Zr(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 cp(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=dp(d.result),m=r.get(h)??Fn();return Zr(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=Gn(d.args);if(typeof h=="string"&&r.has(h)){const f=al(r.get(h)??Fn());return`\`\`\`tool-merged
3659
3659
  ${JSON.stringify({call:{tool:u,args:m,call_id:h},result:f},null,2)}
3660
- \`\`\``}return l}catch{return l}}),resultMap:r}}var hp=["/api/","/assets/","/control-plane","/devices/","/relay/","/relay-account","/relay-admin","/relay-devices","/relay-portal","/threads","/workspaces"];function fs(e){return e.replace(/background-color:[^;"]+;?/g,"background-color: transparent;").replace(/background:[^;"]+;?/g,"background: transparent;")}function gs(e){return Array.isArray(e)?e.map(r=>String(r)).join(""):String(e??"")}function up(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 mp(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("/")||hp.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 pp({children:e,...r}){return fp(e)?t.jsx(t.Fragment,{children:e}):t.jsx("pre",{...r,children:e})}function fp(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 gp=c.memo(function({className:r="thread-graph-markdown",content:n,onOpenWorkspaceFile:a}){const s=c.useRef(null),o=aa(),[l,i]=c.useState(null),[d,h]=c.useState({}),[u,m]=c.useState(!1),{processedContent:f,resultMap:p}=c.useMemo(()=>cp(n),[n]);c.useEffect(()=>{let v=!0;return ip().then(x=>{v&&i(x)}).catch(()=>{}),()=>{v=!1}},[]),c.useEffect(()=>{const v=s.current,x=v==null?void 0:v.closest(".thread-ui-shell"),y=()=>x?x.getAttribute("data-theme-effective")==="dark"||x.classList.contains("dark")||x.classList.contains("thread-ui-theme-dark"):document.documentElement.classList.contains("dark");if(m(y()),!x)return;const k=new MutationObserver(()=>m(y()));return k.observe(x,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>k.disconnect()},[]);async function g(v,x){try{await navigator.clipboard.writeText(x),h(y=>({...y,[v]:"copied"})),window.setTimeout(()=>{h(y=>{const k={...y};return delete k[v],k})},1200)}catch{h(y=>({...y,[v]:"failed"}))}}const b=({children:v,className:x,inline:y,node:k,...C})=>{var R;const w=/language-(\w+(?:-\w+)*)/.exec(x||""),j=w?w[1]??"":"",S=gs(v).replace(/\n$/,""),{startLine:L,endLine:P}=up(k),K=y===!1||!!x||S.includes(`
3661
- `)||L!==P;if(j==="tool-merged"){let J={call:{tool:"Unknown",args:{},call_id:void 0},result:null};try{J=JSON.parse(S)}catch{J={call:{tool:"Error",args:{raw:S}},result:{status:"failed"}}}const Z=typeof J.call.tool=="string"?J.call.tool:"Unknown",D=typeof J.call.call_id=="string"?J.call.call_id:void 0;return t.jsx(us,{callId:D,toolName:Z,status:ps(J.result),parameters:Fn(J.call.args),result:J.result})}if(j==="tool-call"){let J={tool:"Unknown",args:{},call_id:void 0};try{J=JSON.parse(S)}catch{J={tool:"Error",args:{raw:S}}}const Z=typeof J.call_id=="string"?J.call_id:void 0,D=Z&&p.has(Z)?al(p.get(Z)??Hn()):void 0;return t.jsx(us,{callId:Z,toolName:typeof J.tool=="string"?J.tool:"Unknown",status:D?ps(D):"pending",parameters:Fn(J.args),result:D})}if(j==="tool-result")return null;if(["xyz","extxyz","cif","pdb"].includes(j)){const J=o.renderInlineCode({code:S,isIncomplete:!1,language:j});if(c.isValidElement(J))return J}if(K){const Z=(((R=l==null?void 0:l.getLoadedLanguages)==null?void 0:R.call(l))??[]).includes(j)?j:"text",D=u?"ayu-dark":"ayu-light",te=`${j||"text"}:${S.length}:${S.slice(0,32)}`;let oe="";if(l)try{oe=fs(l.codeToHtml(S,{lang:Z,theme:D}))}catch{oe=fs(l.codeToHtml(S,{lang:"text",theme:D}))}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(xr,{type:"button",onClick:()=>void g(te,S),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:t.jsx(B.Copy,{className:"h-3.5 w-3.5"})}),oe?t.jsx("div",{dangerouslySetInnerHTML:{__html:oe}}):t.jsx("pre",{children:t.jsx("code",{className:"whitespace-pre",children:S})})]})}const F=gs(v).replace(/`+/g,"");return t.jsx("code",{className:`thread-graph-inline-code rounded px-1 py-0.5 font-mono font-normal text-[0.9em] ${x||""}`,...C,children:F})};return t.jsx("div",{ref:s,className:`thread-graph-message-markdown ${r}`,children:t.jsx(fd,{remarkPlugins:[xd,bd],rehypePlugins:[gd],components:{a({href:v,children:x,...y}){const k=mp(v);return k&&a?t.jsx("a",{...y,href:v,className:"thread-inline-link",onClick:C=>{C.preventDefault(),a(k)},children:x}):t.jsx("a",{...y,href:v,className:"thread-inline-link",children:x})},code:b,pre:pp},children:f})})}),xs=4e3,xp=/\b(?:https?:\/\/|www\.)[^\s<>"'`]+/gi,bp=/[),.;:!?]+$/;function vp(e){return e.startsWith("www.")?`https://${e}`:e}function bs(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function kp(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 rr({text:e}){var a;const r=[];let n=0;for(const s of e.matchAll(xp)){const o=s[0],l=s.index??0,i=((a=o.match(bp))==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:vp(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 sl=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=op(r),g=!a&&r.length>xs,b=g&&!m?`${r.slice(0,xs).trimEnd()}
3660
+ \`\`\``}return l}catch{return l}}),resultMap:r}}var hp=["/api/","/assets/","/control-plane","/devices/","/relay/","/relay-account","/relay-admin","/relay-devices","/relay-portal","/threads","/workspaces"];function fs(e){return e.replace(/background-color:[^;"]+;?/g,"background-color: transparent;").replace(/background:[^;"]+;?/g,"background: transparent;")}function gs(e){return Array.isArray(e)?e.map(r=>String(r)).join(""):String(e??"")}function up(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 mp(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("/")||hp.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 pp({children:e,...r}){return fp(e)?t.jsx(t.Fragment,{children:e}):t.jsx("pre",{...r,children:e})}function fp(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 gp=c.memo(function({className:r="thread-graph-markdown",content:n,onOpenWorkspaceFile:a}){const o=c.useRef(null),s=na(),[l,i]=c.useState(null),[d,h]=c.useState({}),[u,m]=c.useState(!1),{processedContent:f,resultMap:p}=c.useMemo(()=>cp(n),[n]);c.useEffect(()=>{let w=!0;return ip().then(x=>{w&&i(x)}).catch(()=>{}),()=>{w=!1}},[]),c.useEffect(()=>{const w=o.current,x=w==null?void 0:w.closest(".thread-ui-shell"),y=()=>x?x.getAttribute("data-theme-effective")==="dark"||x.classList.contains("dark")||x.classList.contains("thread-ui-theme-dark"):document.documentElement.classList.contains("dark");if(m(y()),!x)return;const k=new MutationObserver(()=>m(y()));return k.observe(x,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>k.disconnect()},[]);async function g(w,x){try{await navigator.clipboard.writeText(x),h(y=>({...y,[w]:"copied"})),window.setTimeout(()=>{h(y=>{const k={...y};return delete k[w],k})},1200)}catch{h(y=>({...y,[w]:"failed"}))}}const b=({children:w,className:x,inline:y,node:k,...j})=>{var D;const v=/language-(\w+(?:-\w+)*)/.exec(x||""),N=v?v[1]??"":"",S=gs(w).replace(/\n$/,""),{startLine:L,endLine:P}=up(k),K=y===!1||!!x||S.includes(`
3661
+ `)||L!==P;if(N==="tool-merged"){let Z={call:{tool:"Unknown",args:{},call_id:void 0},result:null};try{Z=JSON.parse(S)}catch{Z={call:{tool:"Error",args:{raw:S}},result:{status:"failed"}}}const Y=typeof Z.call.tool=="string"?Z.call.tool:"Unknown",$=typeof Z.call.call_id=="string"?Z.call.call_id:void 0;return t.jsx(us,{callId:$,toolName:Y,status:ps(Z.result),parameters:Gn(Z.call.args),result:Z.result})}if(N==="tool-call"){let Z={tool:"Unknown",args:{},call_id:void 0};try{Z=JSON.parse(S)}catch{Z={tool:"Error",args:{raw:S}}}const Y=typeof Z.call_id=="string"?Z.call_id:void 0,$=Y&&p.has(Y)?al(p.get(Y)??Fn()):void 0;return t.jsx(us,{callId:Y,toolName:typeof Z.tool=="string"?Z.tool:"Unknown",status:$?ps($):"pending",parameters:Gn(Z.args),result:$})}if(N==="tool-result")return null;if(["xyz","extxyz","cif","pdb"].includes(N)){const Z=s.renderInlineCode({code:S,isIncomplete:!1,language:N});if(c.isValidElement(Z))return Z}if(K){const Y=(((D=l==null?void 0:l.getLoadedLanguages)==null?void 0:D.call(l))??[]).includes(N)?N:"text",$=u?"ayu-dark":"ayu-light",te=`${N||"text"}:${S.length}:${S.slice(0,32)}`;let oe="";if(l)try{oe=fs(l.codeToHtml(S,{lang:Y,theme:$}))}catch{oe=fs(l.codeToHtml(S,{lang:"text",theme:$}))}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(br,{type:"button",onClick:()=>void g(te,S),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:t.jsx(B.Copy,{className:"h-3.5 w-3.5"})}),oe?t.jsx("div",{dangerouslySetInnerHTML:{__html:oe}}):t.jsx("pre",{children:t.jsx("code",{className:"whitespace-pre",children:S})})]})}const F=gs(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||""}`,...j,children:F})};return t.jsx("div",{ref:o,className:`thread-graph-message-markdown ${r}`,children:t.jsx(fd,{remarkPlugins:[xd,bd],rehypePlugins:[gd],components:{a({href:w,children:x,...y}){const k=mp(w);return k&&a?t.jsx("a",{...y,href:w,className:"thread-inline-link",onClick:j=>{j.preventDefault(),a(k)},children:x}):t.jsx("a",{...y,href:w,className:"thread-inline-link",children:x})},code:b,pre:pp},children:f})})}),xs=4e3,xp=/\b(?:https?:\/\/|www\.)[^\s<>"'`]+/gi,bp=/[),.;:!?]+$/;function vp(e){return e.startsWith("www.")?`https://${e}`:e}function bs(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function kp(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 rr({text:e}){var a;const r=[];let n=0;for(const o of e.matchAll(xp)){const s=o[0],l=o.index??0,i=((a=s.match(bp))==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:vp(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 sl=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=op(r),g=!a&&r.length>xs,b=g&&!m?`${r.slice(0,xs).trimEnd()}
3662
3662
 
3663
- ...`:r,[v,x]=c.useState(a||typeof IntersectionObserver>"u"),y=c.useCallback(()=>{const k=n.current,C=h.current,w=(C==null?void 0:C.getBoundingClientRect().top)??null;i==null||i(),u.current=k&&w!==null?{root:k,top:w}:null,f(j=>!j)},[i,n]);return c.useLayoutEffect(()=>{const k=u.current,C=h.current;if(!k||!C)return;u.current=null;const w=()=>{const S=C.getBoundingClientRect().top;k.root.scrollTop+=S-k.top};w();const j=window.requestAnimationFrame(w);return()=>{window.cancelAnimationFrame(j)}},[m]),c.useEffect(()=>{if(a||typeof IntersectionObserver>"u"){x(!0);return}if(v||!h.current)return;const k=new IntersectionObserver(C=>{for(const w of C)if(w.isIntersecting){x(!0),k.disconnect();break}},{root:n.current,threshold:0});return k.observe(h.current),()=>{k.disconnect()}},[v,n,a]),t.jsxs("div",{ref:h,className:s,children:[v&&p?t.jsx(gp,{content:b,className:l,onOpenWorkspaceFile:d}):t.jsx("p",{className:o,children:t.jsx(rr,{text:b})}),g?t.jsx("button",{type:"button",onClick:y,className:"thread-graph-show-more timeline-meta-text mt-1.5 flex w-full items-center justify-center rounded-md border border-[var(--theme-border)] px-2 py-0.5 text-[10px] leading-4 transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)]",children:m?"Show less":`Show more (${r.length.toLocaleString()} chars)`}):null]})}),wp=c.memo(function({text:r,scrollRootRef:n,streaming:a=!1,onBeforeResize:s,onOpenWorkspaceFile:o}){return t.jsx(sl,{text:r,scrollRootRef:n,streaming:a,containerClassName:"thread-graph-message-prose",...s?{onBeforeResize:s}:{},...o?{onOpenWorkspaceFile:o}:{}})}),yp=c.memo(function({threadId:r,text:n,attachmentPreviewUrls:a,getImageAssetUrl:s}){const o=c.useMemo(()=>kp(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=bs(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=bs(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 jp(){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 vs({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(B.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):a?t.jsx(B.XCircle,{className:"h-3.5 w-3.5"}):s?t.jsx(B.CheckCircle2,{className:"h-3.5 w-3.5"}):t.jsx(B.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(jp,{}):l}),t.jsx("span",{className:"thread-graph-status-label",children:e})]})}function Np({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(vs,{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(vs,{status:o}):null,h]}):null]})})}yr();function Cp(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function Sp({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 Et=c.memo(function({threadId:r,item:n,scrollRootRef:a,streaming:s=!1,adapter:o,timeLabel:l,timeTitle:i,onBeforeMessageResize:d}){const[h,u]=c.useState("idle"),[m,f]=c.useState(!1),p=c.useRef(null),g=n.kind==="agentMessage"?n.reasoningItems??[]:[],b=g.map(S=>S.text.trim()).filter(Boolean).join(`
3663
+ ...`:r,[w,x]=c.useState(a||typeof IntersectionObserver>"u"),y=c.useCallback(()=>{const k=n.current,j=h.current,v=(j==null?void 0:j.getBoundingClientRect().top)??null;i==null||i(),u.current=k&&v!==null?{root:k,top:v}:null,f(N=>!N)},[i,n]);return c.useLayoutEffect(()=>{const k=u.current,j=h.current;if(!k||!j)return;u.current=null;const v=()=>{const S=j.getBoundingClientRect().top;k.root.scrollTop+=S-k.top};v();const N=window.requestAnimationFrame(v);return()=>{window.cancelAnimationFrame(N)}},[m]),c.useEffect(()=>{if(a||typeof IntersectionObserver>"u"){x(!0);return}if(w||!h.current)return;const k=new IntersectionObserver(j=>{for(const v of j)if(v.isIntersecting){x(!0),k.disconnect();break}},{root:n.current,threshold:0});return k.observe(h.current),()=>{k.disconnect()}},[w,n,a]),t.jsxs("div",{ref:h,className:o,children:[w&&p?t.jsx(gp,{content:b,className:l,onOpenWorkspaceFile:d}):t.jsx("p",{className:s,children:t.jsx(rr,{text:b})}),g?t.jsx("button",{type:"button",onClick:y,className:"thread-graph-show-more timeline-meta-text mt-1.5 flex w-full items-center justify-center rounded-md border border-[var(--theme-border)] px-2 py-0.5 text-[10px] leading-4 transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)]",children:m?"Show less":`Show more (${r.length.toLocaleString()} chars)`}):null]})}),wp=c.memo(function({text:r,scrollRootRef:n,streaming:a=!1,onBeforeResize:o,onOpenWorkspaceFile:s}){return t.jsx(sl,{text:r,scrollRootRef:n,streaming:a,containerClassName:"thread-graph-message-prose",...o?{onBeforeResize:o}:{},...s?{onOpenWorkspaceFile:s}:{}})}),yp=c.memo(function({threadId:r,text:n,attachmentPreviewUrls:a,getImageAssetUrl:o}){const s=c.useMemo(()=>kp(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=bs(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=bs(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 jp(){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 vs({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(B.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):a?t.jsx(B.XCircle,{className:"h-3.5 w-3.5"}):o?t.jsx(B.CheckCircle2,{className:"h-3.5 w-3.5"}):t.jsx(B.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(jp,{}):l}),t.jsx("span",{className:"thread-graph-status-label",children:e})]})}function Np({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(vs,{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(vs,{status:s}):null,h]}):null]})})}jr();function Cp(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function Sp({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 Et=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(S=>S.text.trim()).filter(Boolean).join(`
3664
3664
 
3665
- `),v=n.kind==="userMessage"&&(n.status==="Steering"||n.status==="Accepted"||n.status==="Awaiting response");c.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current)},[]);async function x(){try{await navigator.clipboard.writeText(n.text),u("copied"),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>u("idle"),1200)}catch{u("failed"),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>u("idle"),1600)}}function y(){d==null||d(),f(S=>!S)}const k=n.kind==="agentMessage"?t.jsx("button",{type:"button","aria-label":"Copy agent reply",title:h==="copied"?"Copied":h==="failed"?"Copy failed":"Copy agent reply",onClick:()=>void x(),className:`thread-graph-message-copy inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border transition ${h==="copied"?"ui-status-info":h==="failed"?"ui-status-danger":""}`,children:t.jsx(B.Copy,{className:"h-3.5 w-3.5"})}):null,C=g.some(S=>Cp(S.status)),w=n.kind==="agentMessage"&&b?t.jsxs("button",{type:"button","aria-label":m?"Hide chain of thought":"Show chain of thought","aria-expanded":m,title:m?"Hide CoT":"Show CoT",onClick:y,className:`thread-graph-thinking-toggle inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border px-2 text-xs font-medium transition ${m?"is-open":""}`,children:[t.jsx(B.Brain,{className:`h-3.5 w-3.5 ${C?"animate-pulse":""}`}),t.jsx("span",{children:"CoT"}),C?t.jsx(Sp,{tone:"sky"}):null]}):null,j=n.kind==="agentMessage"&&b?t.jsx("div",{className:"thread-graph-message-thinking mb-3",children:t.jsx(vr,{type:"single",collapsible:!0,className:"thread-graph-thinking-accordion w-full border-none",onValueChange:S=>f(!!S),...m?{value:"thoughts"}:{},children:t.jsx(kr,{value:"thoughts",className:"border-b-0",children:t.jsx(wr,{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(rr,{text:b})})})})})}):null;return t.jsx(Np,{kind:n.kind,status:v||n.kind==="agentMessage"?n.status:null,copyButton:k,metaControl:w,reasoning:j,timeLabel:l,timeTitle:i,children:n.kind==="agentMessage"?t.jsx(wp,{text:n.text,scrollRootRef:a,streaming:s,...d?{onBeforeResize:d}:{},...o!=null&&o.onOpenWorkspaceFile?{onOpenWorkspaceFile:o.onOpenWorkspaceFile}:{}}):t.jsx(yp,{threadId:r,text:n.text,attachmentPreviewUrls:n.attachmentPreviewUrls,getImageAssetUrl:o==null?void 0:o.getImageAssetUrl})})});function ks(e){return e.replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&")}function ol(e){const r=e.trim().match(/^<hook_prompt(?:\s+hook_run_id="([^"]+)")?>([\s\S]*)<\/hook_prompt>$/);if(!r)return null;const n=r[1]?ks(r[1]):null,a=ks(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 Tp(e){return e==="userMessage"||e==="agentMessage"}function Ep(e){return e==="commandExecution"||e==="webSearch"||e==="fileRead"||e==="fileChange"||e==="image"||e==="contextCompaction"}function Lp(e){return e==="agentMessage"||e==="reasoning"||e==="agentToolCall"||e==="skillToolCall"||e==="toolCall"||e==="plan"}function Pp(e,r){if(!r)return e;const n=[...e],a=n.findIndex(o=>o.kind==="userMessage");if(a<0)return n;for(let o=a+1;o<n.length;o+=1){const l=n[o];if(!l||l.kind!=="userMessage")continue;let i=o+1;for(;i<n.length&&Ep(n[i].kind);)i+=1;if(i===o+1)continue;const[d]=n.splice(o,1);n.splice(i-1,0,d),o=i-1}let s=!1;return n.map((o,l)=>o.kind!=="userMessage"?o:s?n.slice(l+1).some(d=>Lp(d.kind))?o:{...o,status:"Awaiting response"}:(s=!0,o))}function Ct(e){return typeof e.sequence=="number"&&Number.isFinite(e.sequence)}function Er(e){return Ct(e)?e.sequence:Number.POSITIVE_INFINITY}function ws(e){var h;const r=[];let n=0;for(;n<e.length&&((h=e[n])==null?void 0:h.kind)==="userMessage"&&!Ct(e[n]);)r.push(e[n]),n+=1;const a=e.slice(n);if(!a.some(Ct))return e;const s=a.map(u=>Er(u)).filter(Number.isFinite),o=s.length>0?Math.max(...s):0,l=[];let i=0;for(;i<a.length;){const u=a[i];if(Ct(u)){l.push({item:u,index:i,order:Er(u)}),i+=1;continue}const m=i;for(;i<a.length&&!Ct(a[i]);)i+=1;const f=a.slice(m,i),p=[...a.slice(0,m)].reverse().find(Ct),g=a.slice(i).find(Ct),b=p?Er(p):null,v=g?Er(g):null;f.forEach((x,y)=>{let k;if(b===null&&v!==null)k=v-(f.length-y)/(f.length+1);else if(b!==null&&v!==null&&v>b){const C=v-b;k=b+(y+1)/(f.length+1)*C}else k=o+1+y/(f.length+1);l.push({item:x,index:m+y,order:k})})}const d=l.sort((u,m)=>{const f=u.order-m.order;return f===0?u.index-m.index:f}).map(u=>u.item);return[...r,...d]}function zp(e,r){if(!r||r.length===0)return ws(e);const n=new Map(r.map(o=>[o.id,o])),a=e.map(o=>{const l=n.get(o.id);if(!l)return o;n.delete(o.id);const i={...o,...l,text:l.text||o.text},d=l.detailText??o.detailText,h=l.previewText??o.previewText,u=l.status??o.status,m=l.sequence??o.sequence;return d!==void 0&&(i.detailText=d),h!==void 0&&(i.previewText=h),u!==void 0&&(i.status=u),m!==void 0&&(i.sequence=m),i}),s=[...n.values()];return s.length===0&&!a.some(Ct)||(a.push(...s),!a.some(o=>typeof o.sequence=="number"&&Number.isFinite(o.sequence)))?a:ws(a)}function Ip(e,r){if(!e)return"";const n=r.filter(d=>d.kind==="agentMessage").map(d=>d.text).filter(d=>d.length>0),a=n.at(-1)??"";if(a){const d=e.lastIndexOf(a);if(d>=0){const h=e.slice(d+a.length);return h.trim()?h:""}}const s=n.join("");if(!s)return e;const o=Math.min(e.length,s.length);let l=0;for(;l<o&&e[l]===s[l];)l+=1;if(l===0)return e;const i=e.slice(l);return i.trim()?i:""}function ll(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function Hr(e){return e==="inProgress"||e==="sending"}function Rp(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"){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}r.push({kind:"searchGroup",key:l,items:o})}return r}function il(e,r){return[...e.map(n=>({id:n.id,startedAt:n.startedAt??""})),...r?[{id:r.id,startedAt:r.startedAt??""}]:[]]}function mr(e,r,n){const a=e.get(r)??[];a.push(n),e.set(r,a)}function dl(e,r){return e.find(n=>r&&n.startedAt&&r.localeCompare(n.startedAt)<=0)}function Ap({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)?mr(o,p.turnId,p):i.push(p);for(const p of r)p.turnId&&s.has(p.turnId)?mr(l,p.turnId,p):d.push(p);const h=il(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=dl(h,p.createdAt);if(!g){m.push(p);continue}mr(u,g.id,p)}return{notesByTurnId:o,pendingRequestsByTurnId:l,beforeTurnId:u,trailing:m}}function _p({activityNotes:e,visibleTurns:r,optimisticTurn:n}){const a=[...e].sort((m,f)=>m.createdAt.localeCompare(f.createdAt)),s=il(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)?mr(i,m.anchorTurnId,m):o.push(m);continue}const f=dl(s,m.createdAt);if(!f){!u||m.createdAt.localeCompare(u)<=0?o.push(m):d.push(m);continue}mr(l,f.id,m)}return{leading:o,beforeTurnId:l,afterTurnId:i,trailing:d}}function cl({request:e,busy:r=!1,onRespond:n}){const[a,s]=c.useState({}),[o,l]=c.useState({}),[i,d]=c.useState(null),h=e.questions[0]??null,u="__other__",m=e.kind==="planDecision"?"Plan":e.kind==="requestUserInput"?"Answer Required":e.title;function f(x){const y=/\s*\(recommended\)\s*$/i.test(x);return{rawLabel:x,displayLabel:x.replace(/\s*\(recommended\)\s*$/i,"").trim(),recommended:y}}function p(x){h&&(d(x),n==null||n(e.id,{answers:{[h.id]:{answers:[x]}}}))}function g(x){const y=a[x.id]??"";return Array.isArray(y)?y.map(k=>k===u?(o[x.id]??"").trim():k.trim()).filter(Boolean).join(", "):y===u?(o[x.id]??"").trim():y.trim()}function b(x){const y=a[x.id]??"";if(Array.isArray(y))return y.map(C=>C===u?(o[x.id]??"").trim():C.trim()).filter(Boolean);if(y===u){const C=(o[x.id]??"").trim();return C?[C]:[]}const k=y.trim();return k?[k]:[]}function v(x,y){s(k=>{const C=k[x],w=Array.isArray(C)?C:[],j=w.includes(y)?w.filter(S=>S!==y):[...w,y];return{...k,[x]:j}})}return t.jsxs("div",{className:"timeline-pending-card w-full rounded-[1rem] border px-3 py-3 sm:rounded-[1.2rem] sm:px-4",children:[t.jsx("div",{className:"flex items-center justify-between gap-3",children:t.jsxs("div",{children:[t.jsx("p",{className:"timeline-primary-text text-sm font-medium",children:m}),e.kind!=="planDecision"&&e.description&&t.jsx("p",{className:"timeline-soft-text mt-1 text-[13px] leading-5",children:e.description})]})}),t.jsx("div",{className:"mt-3 space-y-3",children:e.questions.map(x=>t.jsxs("div",{className:"timeline-question-section rounded-xl border p-2.5 sm:p-3",children:[t.jsx("p",{className:"timeline-meta-text text-xs uppercase tracking-[0.2em]",children:x.header}),t.jsx("p",{className:"timeline-primary-text mt-1 text-[13px] leading-5 sm:text-sm",children:x.question}),e.kind==="planDecision"&&x.options&&x.options.length>0?t.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:x.options.map((y,k)=>{const C=f(y.label),w=C.displayLabel.toLowerCase()==="implement";return t.jsxs("button",{type:"button",disabled:r,onClick:()=>p(y.label),className:`relative rounded-2xl border px-2.5 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${k===0?"ui-action-info":"border-stone-700 text-stone-200 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:y.description,children:[C.recommended?t.jsx("span",{"aria-hidden":"true",className:"absolute right-1.5 top-1 inline-flex h-3.5 w-3.5 items-center justify-center rounded-full bg-white/18 text-[10px] leading-none text-current",children:"✦"}):null,r&&i===y.label?w?"Starting...":"Saving...":C.displayLabel]},y.label)})}):x.options&&x.options.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[x.options.map(y=>{const k=f(y.label),C=a[x.id];return t.jsxs("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?v(x.id,y.label):s(w=>({...w,[x.id]:y.label})),className:`relative rounded-2xl border px-3 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${(x.multiSelect?Array.isArray(C)&&C.includes(y.label):C===y.label)?"ui-status-warning":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:y.description,children:[k.recommended?t.jsx("span",{"aria-hidden":"true",className:"absolute right-1.5 top-1 inline-flex h-3.5 w-3.5 items-center justify-center rounded-full bg-white/10 text-[10px] leading-none text-amber-100/90",children:"✦"}):null,k.displayLabel]},y.label)}),x.isOther&&(()=>{const y=a[x.id];return t.jsx("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?v(x.id,u):s(k=>({...k,[x.id]:u})),className:`rounded-2xl border px-3 py-1.5 text-[12px] leading-4 transition sm:text-[13px] ${(x.multiSelect?Array.isArray(y)&&y.includes(u):y===u)?"ui-status-info":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Not from above"})})()]}),x.isOther&&(()=>{const y=a[x.id];return(x.multiSelect?Array.isArray(y)&&y.includes(u):y===u)?t.jsx("input",{"aria-label":`${x.header} custom answer`,value:o[x.id]??"",onChange:C=>l(w=>({...w,[x.id]:C.target.value})),placeholder:"Enter a custom answer",className:"mt-3 w-full rounded-xl border border-stone-700 bg-stone-900 px-3 py-2 text-sm text-stone-100 outline-none transition focus:border-sky-300"}):null})()]}):t.jsx("input",{"aria-label":x.header,value:a[x.id]??"",onChange:y=>s(k=>({...k,[x.id]:y.target.value})),className:"mt-3 w-full rounded-xl border border-stone-700 bg-stone-900 px-3 py-2 text-sm text-stone-100 outline-none transition focus:border-amber-300"})]},x.id))}),e.kind!=="planDecision"&&t.jsx("div",{className:"mt-3 flex justify-end",children:t.jsx("button",{type:"button",disabled:r||e.questions.some(x=>!g(x)),onClick:()=>void(n==null?void 0:n(e.id,{answers:Object.fromEntries(e.questions.map(x=>[x.id,{answers:b(x)}]))})),className:"ui-action-info rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:r?"Submitting...":"Submit"})})]})}function hl({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 ul({note:e,onOpenThread:r,onOpenLinkedThread:n}){const a=e.kind==="forkCreated"?"Fork":e.kind==="forkSource"?"Fork source":"System",s=e.kind==="forkCreated"?`Thread forked from Turn ${e.turnIndex??"?"}`:e.kind==="forkSource"?`Forked from ${e.linkedThreadTitle??"source thread"} at Turn ${e.turnIndex??"?"}`:e.text??"";return t.jsxs("div",{className:"timeline-activity-card w-full rounded-2xl border px-3 py-2.5",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("p",{className:"timeline-meta-text text-[11px] uppercase tracking-[0.2em]",children:a}),t.jsx("time",{dateTime:e.createdAt,title:Gt(e.createdAt),className:"timeline-meta-text text-[10px]",children:ft(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 ir({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(ul,{note:a,onOpenThread:r,onOpenLinkedThread:n},a.id))})}function On({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(hl,{note:a.note},a.id):t.jsx(cl,{request:a.request,busy:r===a.request.id,onRespond:n},a.id))})}function Mp({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(On,{entries:s,respondingRequestId:n,onRespondToRequest:a})}function $p({entries:e,respondingRequestId:r,onRespondToRequest:n,onOpenThread:a,onOpenLinkedThread:s}){return e.length===0?null:t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:[...e].sort((o,l)=>o.createdAt.localeCompare(l.createdAt)).map(o=>o.kind==="activity"?t.jsx(ul,{note:o.note,onOpenThread:a,onOpenLinkedThread:s},o.id):o.kind==="note"?t.jsx(hl,{note:o.note},o.id):t.jsx(cl,{request:o.request,busy:r===o.request.id,onRespond:n},o.id))})}function Dp({entries:e,expandedGroups:r,onToggleGroupedItem:n,renderCommandGroup:a,renderFileChangeGroup:s,renderFileReadGroup:o,renderItem:l,renderSearchGroup:i}){return t.jsx(t.Fragment,{children:e.map(d=>{const h=r[d.key]??!1,u=()=>n(d.key);return d.kind==="commandGroup"?a(d,h,u):d.kind==="fileChangeGroup"?s(d,h,u):d.kind==="searchGroup"?i(d,h,u):d.kind==="fileReadGroup"?o(d,h,u):l(d)})})}function Jr({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]})]})})}yr();Pt();var Bp=br("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 Qr({asChild:e=!1,className:r,variant:n,...a}){const s=e?Rs:"span";return t.jsx(s,{"data-slot":"badge",className:nt(Bp({variant:n,className:r})),...a})}function en(e){if(!e)return!1;const r=e.trim().toLowerCase();return r==="running"||r==="in_progress"||r==="in progress"||r==="pending"}function Gp(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.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 Fp(){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 Hp(){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 Op(){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 Up(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 ml(e,r=42){const n=Up(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 Wp(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 Un({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 Vp(e){var n;const r=e.replace(/\r\n/g,`
3665
+ `),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 y(){d==null||d(),f(S=>!S)}const k=n.kind==="agentMessage"?t.jsx("button",{type:"button","aria-label":"Copy agent reply",title:h==="copied"?"Copied":h==="failed"?"Copy failed":"Copy agent reply",onClick:()=>void x(),className:`thread-graph-message-copy inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border transition ${h==="copied"?"ui-status-info":h==="failed"?"ui-status-danger":""}`,children:t.jsx(B.Copy,{className:"h-3.5 w-3.5"})}):null,j=g.some(S=>Cp(S.status)),v=n.kind==="agentMessage"&&b?t.jsxs("button",{type:"button","aria-label":m?"Hide chain of thought":"Show chain of thought","aria-expanded":m,title:m?"Hide CoT":"Show CoT",onClick:y,className:`thread-graph-thinking-toggle inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border px-2 text-xs font-medium transition ${m?"is-open":""}`,children:[t.jsx(B.Brain,{className:`h-3.5 w-3.5 ${j?"animate-pulse":""}`}),t.jsx("span",{children:"CoT"}),j?t.jsx(Sp,{tone:"sky"}):null]}):null,N=n.kind==="agentMessage"&&b?t.jsx("div",{className:"thread-graph-message-thinking mb-3",children:t.jsx(kr,{type:"single",collapsible:!0,className:"thread-graph-thinking-accordion w-full border-none",onValueChange:S=>f(!!S),...m?{value:"thoughts"}:{},children:t.jsx(wr,{value:"thoughts",className:"border-b-0",children:t.jsx(yr,{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(rr,{text:b})})})})})}):null;return t.jsx(Np,{kind:n.kind,status:w||n.kind==="agentMessage"?n.status:null,copyButton:k,metaControl:v,reasoning:N,timeLabel:l,timeTitle:i,children:n.kind==="agentMessage"?t.jsx(wp,{text:n.text,scrollRootRef:a,streaming:o,...d?{onBeforeResize:d}:{},...s!=null&&s.onOpenWorkspaceFile?{onOpenWorkspaceFile:s.onOpenWorkspaceFile}:{}}):t.jsx(yp,{threadId:r,text:n.text,attachmentPreviewUrls:n.attachmentPreviewUrls,getImageAssetUrl:s==null?void 0:s.getImageAssetUrl})})});function ks(e){return e.replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&")}function ol(e){const r=e.trim().match(/^<hook_prompt(?:\s+hook_run_id="([^"]+)")?>([\s\S]*)<\/hook_prompt>$/);if(!r)return null;const n=r[1]?ks(r[1]):null,a=ks(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 Tp(e){return e==="userMessage"||e==="agentMessage"}function Ep(e){return e==="commandExecution"||e==="webSearch"||e==="fileRead"||e==="fileChange"||e==="image"||e==="contextCompaction"}function Lp(e){return e==="agentMessage"||e==="reasoning"||e==="agentToolCall"||e==="skillToolCall"||e==="toolCall"||e==="plan"}function Pp(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&&Ep(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=>Lp(d.kind))?s:{...s,status:"Awaiting response"}:(o=!0,s))}function Ct(e){return typeof e.sequence=="number"&&Number.isFinite(e.sequence)}function Lr(e){return Ct(e)?e.sequence:Number.POSITIVE_INFINITY}function ws(e){var h;const r=[];let n=0;for(;n<e.length&&((h=e[n])==null?void 0:h.kind)==="userMessage"&&!Ct(e[n]);)r.push(e[n]),n+=1;const a=e.slice(n);if(!a.some(Ct))return e;const o=a.map(u=>Lr(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(Ct(u)){l.push({item:u,index:i,order:Lr(u)}),i+=1;continue}const m=i;for(;i<a.length&&!Ct(a[i]);)i+=1;const f=a.slice(m,i),p=[...a.slice(0,m)].reverse().find(Ct),g=a.slice(i).find(Ct),b=p?Lr(p):null,w=g?Lr(g):null;f.forEach((x,y)=>{let k;if(b===null&&w!==null)k=w-(f.length-y)/(f.length+1);else if(b!==null&&w!==null&&w>b){const j=w-b;k=b+(y+1)/(f.length+1)*j}else k=s+1+y/(f.length+1);l.push({item:x,index:m+y,order:k})})}const d=l.sort((u,m)=>{const f=u.order-m.order;return f===0?u.index-m.index:f}).map(u=>u.item);return[...r,...d]}function zp(e,r){if(!r||r.length===0)return ws(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(Ct)||(a.push(...o),!a.some(s=>typeof s.sequence=="number"&&Number.isFinite(s.sequence)))?a:ws(a)}function Ip(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 ll(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function mr(e){return e==="inProgress"||e==="sending"}function Rp(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 il(e,r){return[...e.map(n=>({id:n.id,startedAt:n.startedAt??""})),...r?[{id:r.id,startedAt:r.startedAt??""}]:[]]}function pr(e,r,n){const a=e.get(r)??[];a.push(n),e.set(r,a)}function dl(e,r){return e.find(n=>r&&n.startedAt&&r.localeCompare(n.startedAt)<=0)}function Ap({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)?pr(s,p.turnId,p):i.push(p);for(const p of r)p.turnId&&o.has(p.turnId)?pr(l,p.turnId,p):d.push(p);const h=il(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=dl(h,p.createdAt);if(!g){m.push(p);continue}pr(u,g.id,p)}return{notesByTurnId:s,pendingRequestsByTurnId:l,beforeTurnId:u,trailing:m}}function _p({activityNotes:e,visibleTurns:r,optimisticTurn:n}){const a=[...e].sort((m,f)=>m.createdAt.localeCompare(f.createdAt)),o=il(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)?pr(i,m.anchorTurnId,m):s.push(m);continue}const f=dl(o,m.createdAt);if(!f){!u||m.createdAt.localeCompare(u)<=0?s.push(m):d.push(m);continue}pr(l,f.id,m)}return{leading:s,beforeTurnId:l,afterTurnId:i,trailing:d}}function cl({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 y=/\s*\(recommended\)\s*$/i.test(x);return{rawLabel:x,displayLabel:x.replace(/\s*\(recommended\)\s*$/i,"").trim(),recommended:y}}function p(x){h&&(d(x),n==null||n(e.id,{answers:{[h.id]:{answers:[x]}}}))}function g(x){const y=a[x.id]??"";return Array.isArray(y)?y.map(k=>k===u?(s[x.id]??"").trim():k.trim()).filter(Boolean).join(", "):y===u?(s[x.id]??"").trim():y.trim()}function b(x){const y=a[x.id]??"";if(Array.isArray(y))return y.map(j=>j===u?(s[x.id]??"").trim():j.trim()).filter(Boolean);if(y===u){const j=(s[x.id]??"").trim();return j?[j]:[]}const k=y.trim();return k?[k]:[]}function w(x,y){o(k=>{const j=k[x],v=Array.isArray(j)?j:[],N=v.includes(y)?v.filter(S=>S!==y):[...v,y];return{...k,[x]:N}})}return t.jsxs("div",{className:"timeline-pending-card w-full rounded-[1rem] border px-3 py-3 sm:rounded-[1.2rem] sm:px-4",children:[t.jsx("div",{className:"flex items-center justify-between gap-3",children:t.jsxs("div",{children:[t.jsx("p",{className:"timeline-primary-text text-sm font-medium",children:m}),e.kind!=="planDecision"&&e.description&&t.jsx("p",{className:"timeline-soft-text mt-1 text-[13px] leading-5",children:e.description})]})}),t.jsx("div",{className:"mt-3 space-y-3",children:e.questions.map(x=>t.jsxs("div",{className:"timeline-question-section rounded-xl border p-2.5 sm:p-3",children:[t.jsx("p",{className:"timeline-meta-text text-xs uppercase tracking-[0.2em]",children:x.header}),t.jsx("p",{className:"timeline-primary-text mt-1 text-[13px] leading-5 sm:text-sm",children:x.question}),e.kind==="planDecision"&&x.options&&x.options.length>0?t.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:x.options.map((y,k)=>{const j=f(y.label),v=j.displayLabel.toLowerCase()==="implement";return t.jsxs("button",{type:"button",disabled:r,onClick:()=>p(y.label),className:`relative rounded-2xl border px-2.5 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${k===0?"ui-action-info":"border-stone-700 text-stone-200 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:y.description,children:[j.recommended?t.jsx("span",{"aria-hidden":"true",className:"absolute right-1.5 top-1 inline-flex h-3.5 w-3.5 items-center justify-center rounded-full bg-white/18 text-[10px] leading-none text-current",children:"✦"}):null,r&&i===y.label?v?"Starting...":"Saving...":j.displayLabel]},y.label)})}):x.options&&x.options.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[x.options.map(y=>{const k=f(y.label),j=a[x.id];return t.jsxs("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?w(x.id,y.label):o(v=>({...v,[x.id]:y.label})),className:`relative rounded-2xl border px-3 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${(x.multiSelect?Array.isArray(j)&&j.includes(y.label):j===y.label)?"ui-status-warning":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:y.description,children:[k.recommended?t.jsx("span",{"aria-hidden":"true",className:"absolute right-1.5 top-1 inline-flex h-3.5 w-3.5 items-center justify-center rounded-full bg-white/10 text-[10px] leading-none text-amber-100/90",children:"✦"}):null,k.displayLabel]},y.label)}),x.isOther&&(()=>{const y=a[x.id];return t.jsx("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?w(x.id,u):o(k=>({...k,[x.id]:u})),className:`rounded-2xl border px-3 py-1.5 text-[12px] leading-4 transition sm:text-[13px] ${(x.multiSelect?Array.isArray(y)&&y.includes(u):y===u)?"ui-status-info":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Not from above"})})()]}),x.isOther&&(()=>{const y=a[x.id];return(x.multiSelect?Array.isArray(y)&&y.includes(u):y===u)?t.jsx("input",{"aria-label":`${x.header} custom answer`,value:s[x.id]??"",onChange:j=>l(v=>({...v,[x.id]:j.target.value})),placeholder:"Enter a custom answer",className:"mt-3 w-full rounded-xl border border-stone-700 bg-stone-900 px-3 py-2 text-sm text-stone-100 outline-none transition focus:border-sky-300"}):null})()]}):t.jsx("input",{"aria-label":x.header,value:a[x.id]??"",onChange:y=>o(k=>({...k,[x.id]:y.target.value})),className:"mt-3 w-full rounded-xl border border-stone-700 bg-stone-900 px-3 py-2 text-sm text-stone-100 outline-none transition focus:border-amber-300"})]},x.id))}),e.kind!=="planDecision"&&t.jsx("div",{className:"mt-3 flex justify-end",children:t.jsx("button",{type:"button",disabled:r||e.questions.some(x=>!g(x)),onClick:()=>void(n==null?void 0:n(e.id,{answers:Object.fromEntries(e.questions.map(x=>[x.id,{answers:b(x)}]))})),className:"ui-action-info rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:r?"Submitting...":"Submit"})})]})}function hl({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 ul({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:Gt(e.createdAt),className:"timeline-meta-text text-[10px]",children:ft(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 ir({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(ul,{note:a,onOpenThread:r,onOpenLinkedThread:n},a.id))})}function Hn({entries:e,respondingRequestId:r,onRespondToRequest:n}){return e.length===0?null:t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:e.map(a=>a.kind==="note"?t.jsx(hl,{note:a.note},a.id):t.jsx(cl,{request:a.request,busy:r===a.request.id,onRespond:n},a.id))})}function Mp({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(Hn,{entries:o,respondingRequestId:n,onRespondToRequest:a})}function $p({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(ul,{note:s.note,onOpenThread:a,onOpenLinkedThread:o},s.id):s.kind==="note"?t.jsx(hl,{note:s.note},s.id):t.jsx(cl,{request:s.request,busy:r===s.request.id,onRespond:n},s.id))})}function Dp({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 Jr({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]})]})})}jr();Pt();var Bp=vr("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 Qr({asChild:e=!1,className:r,variant:n,...a}){const o=e?Rs:"span";return t.jsx(o,{"data-slot":"badge",className:nt(Bp({variant:n,className:r})),...a})}function aa(e){if(!e)return!1;const r=e.trim().toLowerCase();return r==="running"||r==="in_progress"||r==="in progress"||r==="pending"}function Gp(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.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 Fp(){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 Hp(){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 Op(){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 Up(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 ml(e,r=42){const n=Up(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 Wp(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 On({tone:e="amber"}){const r=e==="emerald"?"bg-sky-200/90":e==="sky"?"bg-sky-300/90":"bg-amber-200/90";return t.jsx("span",{className:"ml-1.5 inline-flex items-center gap-1","aria-hidden":"true",children:[0,1,2].map(n=>t.jsx("span",{className:`h-1.5 w-1.5 animate-pulse rounded-full ${r}`,style:{animationDelay:`${n*180}ms`}},n))})}function Vp(e){var n;const r=e.replace(/\r\n/g,`
3666
3666
  `).split(`
3667
- `);for(;r.length>1&&((n=r.at(-1))==null?void 0:n.trim())==="";)r.pop();return r}function gt(e){const r=Vp(e);return r.length===1?{firstLine:r[0]??"",showGap:!1,isTruncated:!1}:{firstLine:r[0]??"",showGap:!0,isTruncated:!0}}function pl(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(B.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"}:r==="failed"||r==="failure"||r==="error"||r==="errored"?{className:"is-failed",icon:t.jsx(B.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"}:en(e)?{className:"is-pending",icon:t.jsx(B.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 Kp(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 qp(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 Ot({actions:e,children:r,className:n,headerMeta:a,icon:s,item:o,timeMeta:l,title:i,tone:d}){const h=pl(o.status);return t.jsxs("div",{className:`thread-graph-event thread-graph-history-event ${qp(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(Qr,{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 ar({actionLabel:e="Open details",actionTitle:r,className:n,details:a,icon:s,item:o,onOpen:l,preview:i,timeMeta:d,title:h,tone:u}){const m=pl(o.status),[f,p]=c.useState(en(o.status)?"item-1":void 0);return t.jsx("div",{className:`thread-graph-event thread-graph-history-tool ${Kp(u)} ${n??""}`,children:t.jsx(vr,{type:"single",collapsible:!0,onValueChange:g=>p(g||void 0),className:"thread-graph-tool-accordion thread-graph-history-tool-accordion w-full overflow-hidden rounded-lg border",...f!==void 0?{value:f}:{},children:t.jsxs(kr,{value:"item-1",className:"border-0",children:[t.jsxs(Yr,{"aria-label":`${f==="item-1"?"Collapse":"Expand"} ${h} 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:h}),t.jsxs(Qr,{variant:"outline",className:`thread-graph-tool-badge ${m.className} ml-1 sm:ml-2 rounded-full px-2 py-0.5 text-xs font-normal`,title:m.label,"aria-label":`Status: ${m.label}`,children:[m.icon,t.jsx("span",{className:"thread-graph-status-label",children:m.label})]})]}),d?t.jsx("span",{className:"thread-graph-history-tool-time shrink-0",children:d}):null]}),t.jsxs(wr,{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(rr,{text:i.firstLine}),i.showGap?t.jsx("span",{className:"thread-graph-history-tool-ellipsis",children:"..."}):null]})]}),a?t.jsx("section",{children:a}):null,t.jsxs("button",{type:"button","aria-label":e,onClick:l,className:"thread-graph-history-tool-open inline-flex items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium transition",children:[t.jsx(B.ExternalLink,{className:"h-3.5 w-3.5"}),r]})]})]})})})}var Xp=c.memo(function({item:r,scrollRootRef:n,onBeforeResize:a,timeMeta:s}){return t.jsx(Ot,{className:"thread-graph-event-plan",icon:t.jsx(B.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(sl,{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}:{}})})})}),Yp=c.memo(function({item:r,timeMeta:n}){const a=en(r.status)||r.text==="Compacting context",s=a?"Compacting context":"Context compacted",o=r.detailText&&r.detailText!==s?r.detailText:null;return t.jsxs(Ot,{className:"thread-graph-event-context",icon:t.jsx(B.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(Un,{tone:"emerald"}):null]}),o?t.jsx("p",{className:"thread-graph-history-event-secondary",title:o,children:o}):null]})}),Zp=c.memo(function({item:r,timeMeta:n}){return t.jsx(Ot,{className:"thread-graph-event-generic",icon:t.jsx(B.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(rr,{text:r.text})})})}),Jp=c.memo(function({item:r,onOpen:n,timeMeta:a}){const s=gt(r.previewText??r.text);return t.jsx(ar,{actionLabel:"Open full command",actionTitle:"Command Output",className:"thread-graph-event-command",icon:t.jsx(B.Terminal,{className:"h-4 w-4"}),item:r,onOpen:()=>n(r,"Command Output"),preview:s,timeMeta:a,title:"command",tone:"command"})}),Qp=c.memo(function({item:r,onOpen:n,timeMeta:a}){const s=gt(r.text);return t.jsx(ar,{actionLabel:"Open full tool call",actionTitle:"Tool Call Details",className:"thread-graph-event-tool",icon:t.jsx(B.Wrench,{className:"h-4 w-4"}),item:r,onOpen:()=>n(r,"Tool Call Details"),preview:s,timeMeta:a,title:"tool_call",tone:"tool"})}),ef=c.memo(function({item:r,onOpen:n,timeMeta:a}){const s=gt(r.text);return t.jsx(ar,{actionLabel:"Open agent details",actionTitle:"Agent Details",className:"thread-graph-event-agent-tool",icon:t.jsx(B.Bot,{className:"h-4 w-4"}),item:r,onOpen:()=>n(r,"Agent Details"),preview:s,timeMeta:a,title:"agent",tone:"agent"})}),tf=c.memo(function({item:r,onOpen:n,timeMeta:a}){const s=gt(r.text);return t.jsx(ar,{actionLabel:"Open skill details",actionTitle:"Skill Details",className:"thread-graph-event-skill-tool",icon:t.jsx(B.Sparkles,{className:"h-4 w-4"}),item:r,onOpen:()=>n(r,"Skill Details"),preview:s,timeMeta:a,title:"skill",tone:"skill"})}),rf=c.memo(function({item:r,onOpen:n,timeMeta:a}){var i,d;const s=((i=r.previewText)==null?void 0:i.trim())||r.text||"Web search",o=((d=r.detailText)==null?void 0:d.trim())||r.text||"Web search",l=gt(s);return t.jsx(ar,{actionLabel:"Open full web search",actionTitle:"Web Search Details",className:"thread-graph-event-search",icon:t.jsx(B.Search,{className:"h-4 w-4"}),item:r,onOpen:()=>n("Web Search Details",o),preview:l,timeMeta:a,title:"web_search",tone:"search"})}),nf=c.memo(function({item:r,onOpen:n,timeMeta:a}){var i,d;const s=((i=r.previewText)==null?void 0:i.trim())||r.text||"File read",o=((d=r.detailText)==null?void 0:d.trim())||r.text||"File read",l=gt(s);return t.jsx(ar,{actionLabel:"Open full file read",actionTitle:"File Read Details",className:"thread-graph-event-file-read",icon:t.jsx(B.FileText,{className:"h-4 w-4"}),item:r,onOpen:()=>n("File Read Details",o),preview:l,timeMeta:a,title:"file_read",tone:"fileRead"})}),af=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(Ot,{className:"thread-graph-event-image",icon:t.jsx(B.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]})}),sf=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=ml(s??((p=r.previewText)==null?void 0:p.trim())??r.text,48),i=Wp(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(Ot,{className:"thread-graph-event-file-change",headerMeta:u,icon:t.jsx(B.FilePenLine,{className:"h-4 w-4"}),item:r,timeMeta:a,title:"file_change",tone:"fileChange"})}),of=c.memo(function({item:r,onSelect:n,timeMeta:a}){const s=aa(),[o,l]=c.useState(!1),i=r.artifact,d=i?s.renderArtifact({artifact:i,expanded:o,onToggleExpanded:()=>l(h=>!h)}):null;return t.jsx(Ot,{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(B.PackageOpen,{className:"h-3.5 w-3.5"}),"Inspect"]}):null]}),className:"thread-graph-event-artifact",icon:t.jsx(B.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]})})}),lf=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(`
3668
- `).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=gt(a||(o&&o!==s?o:s)),d=!!(a&&i.showGap);return t.jsx(Ot,{className:"thread-graph-event-hook",icon:t.jsx(B.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(rr,{text:i.firstLine})]}):t.jsx(rr,{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]})})}),df=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s,timeMeta:o}){const l=r.filter(d=>en(d.status)).length,i=r.length===1?"1 command":`${r.length} commands`;return t.jsx(Jr,{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(Hp,{}),onToggleExpanded:a,runningIndicator:l>0?t.jsx(Un,{}):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(Un,{})}):null]}),timeMeta:o,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} command entries`,children:r.map((d,h)=>{const u=gt(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)})})}),cf=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(Jr,{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(Op,{}),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=gt(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)})})}),hf=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(Jr,{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(Fp,{}),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=gt(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)})})}),uf=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(Jr,{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(Gp,{}),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,b,v,x;const f=((g=u.detailText)==null?void 0:g.trim())||((b=u.previewText)==null?void 0:b.trim())||u.text,p=(v=u.previewText)!=null&&v.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:ml(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 mf(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 pf({status:e}){const r=mf(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(Qr,{"aria-label":n,title:n.replace("Plan step status: ",""),className:a,children:r==="completed"?t.jsx(B.CheckCircle2,{className:"h-3.5 w-3.5"}):r==="in_progress"?t.jsx(B.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):r==="pending"?t.jsx(B.Clock3,{className:"h-3.5 w-3.5"}):r==="failed"?t.jsx(B.XCircle,{className:"h-3.5 w-3.5"}):t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.14em]",children:"?"})})}function ff({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(Qr,{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(pf,{status:r.status})]},`${e.turnId}-${n}`))})]})}function gf({footer:e,history:r,liveHookPrompt:n,liveOutput:a,livePlan:s}){return t.jsxs(t.Fragment,{children:[r,s?t.jsx(ff,{livePlan:s}):null,n??a??null,e]})}function xf({absoluteIndex:e,body:r,collapsed:n,collapsedBody:a,error:s,footer:o,headerStatus:l,isActive:i=!1,onToggleCollapse:d,refCallback:h,startedAt:u,timeLabel:m,timeTitle:f,tokenSummary:p}){return t.jsxs("article",{ref:h,"data-testid":"chat-turn","data-turn-active":i?"true":"false",className:"thread-graph-turn px-3 py-2 sm:px-5 sm:py-3",children:[t.jsxs("div",{className:"thread-graph-turn-header flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0 flex flex-1 items-start gap-1.5",children:[t.jsxs("div",{className:"min-w-0 flex flex-1 items-center gap-1.5 overflow-hidden",children:[t.jsxs("span",{className:"thread-graph-turn-index rounded-[0.6rem] border px-1.5 py-0.5 text-[10px] uppercase tracking-[0.16em]",children:["Turn ",e]}),t.jsx("time",{dateTime:u??void 0,title:f,className:"thread-graph-turn-time shrink-0 text-[10px] sm:text-[11px]",children:m}),l,s?t.jsx("p",{className:"hidden truncate text-[11px] text-rose-200 sm:block",children:s}):null]}),p]}),t.jsx("button",{type:"button","aria-label":`${n?"Expand":"Collapse"} turn ${e}`,title:n?"Expand turn":"Collapse turn",onClick:d,className:"thread-graph-turn-collapse inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-md transition",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:n?t.jsx("path",{d:"m4.5 10 3.5-3.5L11.5 10"}):t.jsx("path",{d:"m4.5 6 3.5 3.5L11.5 6"})})})]}),s?t.jsx("p",{className:"mt-1 text-[11px] text-rose-200 sm:hidden",children:s}):null,t.jsxs("div",{className:"thread-graph-turn-body mt-2 space-y-2",children:[n?a:r,n?null:o]})]})}function 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 2.75v8"}),t.jsx("path",{d:"m4.75 7.5 3.25 3.25L11.25 7.5"})]})}function vf(){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 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.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 wf(){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 Lr(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 sa(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 ur(e){return!Number.isFinite(e)||e<=0?"$0.0000":`$${e.toFixed(4)}`}function Pr(e,r,n){const a=e??null;return!Number.isFinite(a??NaN)||a===null||r<=0||n<=0?null:a*n/r}function fl(e){var i,d,h,u,m;const r=(i=e.tokenUsage)==null?void 0:i.total;if(!r)return[];const n=Math.max(r.inputTokens-r.cachedInputTokens,0),a=Math.max(r.cachedInputTokens,0),s=Math.max(r.reasoningOutputTokens,0),o=Math.max(r.outputTokens-s,0);return[n>0?{id:"in",label:"Input",tokenCompactValue:Lr(n),tokenRawValue:n,usdCompactValue:e.priceEstimate?ur(e.priceEstimate.inputUsd):"--",usdRawValue:((d=e.priceEstimate)==null?void 0:d.inputUsd)??null,className:"token-badge-in",icon:t.jsx(bf,{})}:null,a>0?{id:"cache",label:"Cached input",tokenCompactValue:Lr(a),tokenRawValue:a,usdCompactValue:e.priceEstimate?ur(e.priceEstimate.cachedInputUsd):"--",usdRawValue:((h=e.priceEstimate)==null?void 0:h.cachedInputUsd)??null,className:"token-badge-cache",icon:t.jsx(kf,{})}:null,o>0?{id:"out",label:"Output",tokenCompactValue:Lr(o),tokenRawValue:o,usdCompactValue:e.priceEstimate?ur(Pr(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),o)??0):"--",usdRawValue:Pr((u=e.priceEstimate)==null?void 0:u.outputUsd,Math.max(r.outputTokens,0),o),className:"token-badge-out",icon:t.jsx(vf,{})}:null,s>0?{id:"reason",label:"Reasoning",tokenCompactValue:Lr(s),tokenRawValue:s,usdCompactValue:e.priceEstimate?ur(Pr(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),s)??0):"--",usdRawValue:Pr((m=e.priceEstimate)==null?void 0:m.outputUsd,Math.max(r.outputTokens,0),s),className:"token-badge-reason",icon:t.jsx(wf,{})}:null].filter(f=>f!==null)}function yf(e){return fl(e).map(r=>({id:r.id,label:r.tokenCompactValue,title:`${r.label}: ${r.tokenRawValue} tokens`,className:r.className,icon:r.icon}))}function gl(e){return{label:e.priceEstimate?sa(e.priceEstimate.totalUsd):"--",title:e.priceEstimate===null||e.priceEstimate===void 0?"Price estimate unavailable for this model.":`Estimated cost: ${ur(e.priceEstimate.totalUsd)}`,className:e.priceEstimate?"token-badge-total":"token-badge-empty"}}var bn="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=fl(e),n=gl(e),[a,s]=c.useState(!1),[o,l]=c.useState(!1),[i,d]=c.useState(0),h=c.useRef(null),u=c.useRef(null),m=c.useRef(null);if(c.useLayoutEffect(()=>{if(!a||r.length===0){d(0);return}const p=()=>{const g=h.current,b=m.current;if(!g||!b)return;const v=g.getBoundingClientRect(),x=b.offsetWidth||b.getBoundingClientRect().width;if(x<=0)return;const y=window.innerWidth||document.documentElement.clientWidth,k=12,C=v.left+v.width/2-x/2,w=k,j=Math.max(w,y-k-x),S=Math.min(Math.max(C,w),j);d(Math.round(S-C))};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:`${bn} 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:`${bn} ${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:`${bn} 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 Nf({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 ys(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 Cf(e){switch(e.kind){case"fileChange":case"webSearch":case"image":case"contextCompaction":return!0;case"commandExecution":case"toolCall":return!ll(e.status);default:return!1}}function Sf(e,r,n){if(!e||!Hr(n))return e;const a=e.plan.findIndex(i=>ys(i.status)==="in_progress");if(a<0)return e;const s=e.plan.findIndex((i,d)=>d>a&&ys(i.status)==="pending");if(s<0||!r.some(i=>Cf(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 Tf(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 js({status:e}){const r=tl(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(Nf,{tone:"emerald"})})}function Ns({turn:e,variant:r="header"}){const n=tl(e.status),a=Tf(e),s=yf(e),o=gl(e),l=Hr(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(js,{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:Gt(e.startedAt),className:"timeline-meta-text shrink-0 text-[11px]",children:ft(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(js,{status:e.status}),t.jsx("span",{className:"timeline-meta-text min-w-0 truncate",children:a})]})}function Ef(e,r){return e.createdAt??r}var oa=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}){var g,b,v;if(Tp(n.kind))return t.jsx(Et,{threadId:r,item:n,scrollRootRef:a,timeLabel:m,timeTitle:f,...h?{onBeforeMessageResize:h}:{},...u?{adapter:u}:{}});if(n.kind==="reasoning")return t.jsx(Et,{item:{...n,kind:"agentMessage",status:n.status??null},scrollRootRef:a,timeLabel:m,timeTitle:f,...h?{onBeforeMessageResize:h}:{}});if(n.kind==="artifact")return t.jsx(of,{item:n,timeMeta:p,...d?{onSelect:(x,y)=>d({item:x,artifact:y})}:{}});if(n.kind==="commandExecution")return t.jsx(Jp,{item:n,onOpen:o,timeMeta:p});if(n.kind==="toolCall")return t.jsx(Qp,{item:n,onOpen:l,timeMeta:p});if(n.kind==="agentToolCall")return t.jsx(ef,{item:n,onOpen:l,timeMeta:p});if(n.kind==="skillToolCall")return t.jsx(tf,{item:n,onOpen:l,timeMeta:p});if(n.kind==="webSearch"){const x=n,y=((g=x.detailText)==null?void 0:g.trim())||x.text||"Web search";return t.jsx(rf,{item:x,timeMeta:p,onOpen:()=>i(x,"Web Search Details",y,"Loading full web search details...","Unable to load full web search details.")})}if(n.kind==="fileRead"){const x=n,y=((b=x.detailText)==null?void 0:b.trim())||x.text||"File read";return t.jsx(nf,{item:x,timeMeta:p,onOpen:()=>i(x,"File Read Details",y,"Loading full file read details...","Unable to load full file read details.")})}if(n.kind==="image")return t.jsx(af,{threadId:r,item:n,onOpen:s,getImageAssetUrl:u==null?void 0:u.getImageAssetUrl,timeMeta:p});if(n.kind==="plan")return t.jsx(Xp,{item:n,scrollRootRef:a,timeMeta:p,...h?{onBeforeResize:h}:{}});if(n.kind==="fileChange"){const x=n,y=((v=x.detailText)==null?void 0:v.trim())||x.text||"File change";return t.jsx(sf,{item:x,timeMeta:p,onOpen:()=>i(x,"File Change Details",y,"Loading full file change details...","Unable to load full file change details.")})}return n.kind==="contextCompaction"?t.jsx(Yp,{item:n,timeMeta:p}):n.kind==="hook"?t.jsx(lf,{item:n,timeMeta:p}):t.jsx(Zp,{item:n,timeMeta:p})});function Lf(e){return e==="completed"||e==="failed"||e==="interrupted"}function Pf(e){const r=Date.parse(e.createdAt??"");return Number.isFinite(r)?r:null}function zf(e){let r=null;for(const n of e){const a=Pf(n);a!==null&&(r=r===null?a:Math.max(r,a))}return r}function If(e,r){const n=Date.parse(e??""),a=zf(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 Rf(e,r){const n=Date.parse(e??""),a=Date.parse(r??"");if(!Number.isFinite(n)||!Number.isFinite(a))return r?ft(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 pr({absoluteLabel:e,className:r="",timestamp:n,turnStartedAt:a}){const[s,o]=c.useState(!1);if(!n)return null;const l=Gt(n),i=Rf(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 text-[10px] leading-none transition sm:text-[11px] ${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 zr(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 Af(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 vn=c.memo(function({threadId:r,adapter:n,turn:a,absoluteIndex:s,isCollapsed:o,livePlan:l,liveItems:i,liveOutput:d,forceActive:h=!1,onToggleCollapse:u,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,onSelectArtifact:b,onBeforeMessageResize:v,scrollRootRef:x,articleRef:y,isLatestVisibleTurn:k=!1}){const C=!!l||!!d||!!(i&&i.length>0),w=h||Hr(a.status)||C||k,j=w&&!Hr(a.status)?{...a,status:"inProgress"}:a,S=c.useMemo(()=>zp(a.items,i),[i,a.items]),L=c.useMemo(()=>Sf(l,S,a.status),[l,S,a.status]),P=c.useMemo(()=>Ip(d,S),[d,S]),K=c.useMemo(()=>Pp(S,w),[w,S]),F=c.useMemo(()=>Rp(K),[K]),R=ft(a.startedAt),J=Gt(a.startedAt),Z=c.useMemo(()=>ol(P),[P]),[D,te]=c.useState({}),oe=c.useCallback(U=>{te(X=>({...X,[U]:!X[U]}))},[]),_=t.jsx(_f,{entries:F,expandedGroups:D,onToggleGroupedItem:oe,threadId:r,scrollRootRef:x,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,...v?{onBeforeMessageResize:v}:{},fallbackTimestamp:a.startedAt,fallbackTimeLabel:R,fallbackTimeTitle:J,turnStartedAt:a.startedAt,...b?{onSelectArtifact:b}:{},...n?{adapter:n}:{}}),Y=Z?t.jsx(oa,{threadId:r,item:Z,scrollRootRef:x,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,timeLabel:a.startedAt?t.jsx(pr,{absoluteLabel:R,timestamp:a.startedAt,turnStartedAt:a.startedAt}):R,timeTitle:J,timeMeta:null,...b?{onSelectArtifact:b}:{},...n?{adapter:n}:{}}):null,I=!Z&&P?t.jsx(Et,{item:{id:"live-agent-message",kind:"agentMessage",text:P},scrollRootRef:x,timeLabel:a.startedAt?t.jsx(pr,{absoluteLabel:R,timestamp:a.startedAt,turnStartedAt:a.startedAt}):R,timeTitle:J,streaming:!0,...v?{onBeforeMessageResize:v}:{}}):null,q=w?t.jsx(Ns,{turn:j,variant:"footer"}):null,H=c.useMemo(()=>Af(F),[F]),E=c.useMemo(()=>If(a.startedAt,S),[S,a.startedAt]),W=H.hiddenEntries.length>0,O=o&&W,N=Lf(a.status)&&W?t.jsxs("div",{className:"thread-graph-turn-collapsed-summary space-y-2",children:[H.users.map(U=>t.jsx(Et,{threadId:r,item:U,scrollRootRef:x,timeLabel:U.createdAt?ft(U.createdAt):R,timeTitle:U.createdAt?Gt(U.createdAt):J,...v?{onBeforeMessageResize:v}:{},...n?{adapter:n}:{}},U.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":`${E}. Expand turn ${s}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:E}),t.jsx(B.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"})]}),H.finalAgent?t.jsx(Et,{threadId:r,item:H.finalAgent,scrollRootRef:x,timeLabel:H.finalAgent.createdAt?t.jsx(pr,{absoluteLabel:ft(H.finalAgent.createdAt),timestamp:H.finalAgent.createdAt,turnStartedAt:a.startedAt}):R,timeTitle:H.finalAgent.createdAt?Gt(H.finalAgent.createdAt):J,...v?{onBeforeMessageResize:v}:{},...n?{adapter:n}:{}}):null]}):null,T=t.jsx(gf,{footer:q,history:_,liveHookPrompt:Y,liveOutput:I,livePlan:L});return t.jsx(xf,{absoluteIndex:s,body:T,collapsed:O,collapsedBody:N,error:a.error,headerStatus:t.jsx(Ns,{turn:a}),isActive:w,onToggleCollapse:()=>u(a.id,O),refCallback:y,startedAt:a.startedAt,timeLabel:R,timeTitle:J,tokenSummary:t.jsx(jf,{turn:a})})});function _f({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:b}){const v=c.useCallback(x=>x?t.jsx(pr,{absoluteLabel:ft(x),timestamp:x,turnStartedAt:b??f}):null,[f,b]);return t.jsx(Dp,{entries:e,expandedGroups:r,onToggleGroupedItem:n,renderCommandGroup:(x,y,k)=>t.jsx(df,{items:x.items,expanded:y,onToggleExpanded:k,onOpen:l,timeMeta:v(zr(x))},x.key),renderFileChangeGroup:(x,y,k)=>t.jsx(uf,{items:x.items,expanded:y,onToggleExpanded:k,onOpen:o,timeMeta:v(zr(x))},x.key),renderSearchGroup:(x,y,k)=>t.jsx(cf,{items:x.items,expanded:y,onToggleExpanded:k,onOpen:o,timeMeta:v(zr(x))},x.key),renderFileReadGroup:(x,y,k)=>t.jsx(hf,{items:x.items,expanded:y,onToggleExpanded:k,onOpen:o,timeMeta:v(zr(x))},x.key),renderItem:x=>{const y=Ef(x.item,f??null),C=x.item.kind==="userMessage"?x.item.createdAt?ft(y):p:x.item.createdAt?t.jsx(pr,{absoluteLabel:ft(y),timestamp:y,turnStartedAt:b??f}):p;return t.jsx(oa,{threadId:a,item:x.item,scrollRootRef:s,timeLabel:C,timeTitle:x.item.createdAt?Gt(y):g,timeMeta:v(y),onOpenExpandedText:o,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,...u?{onBeforeMessageResize:u}:{},...h?{onSelectArtifact:h}:{},...m?{adapter:m}:{}},x.key)}})}var Cs=3,Mf=3,Wn=80;function dr(e,r=Wn){return e.scrollHeight-e.scrollTop-e.clientHeight<=r}function $f(e,r){const n=e.getBoundingClientRect(),a=r.getBoundingClientRect(),s=Math.max(n.top,a.top),o=Math.min(n.bottom,a.bottom);return Math.max(0,o-s)>0}function Df(e){return e.map(n=>{const a=n.createdAt;return typeof a=="string"&&a.trim()?a:null}).filter(n=>!!n).sort()[0]??null}function Bf(e,r){return{id:e,startedAt:Df(r),status:"inProgress",error:null,model:null,reasoningEffort:null,reasoningEffortAvailable:null,tokenUsage:null,priceEstimate:null,items:[]}}function Ss(e,r,n){return{id:e.id,kind:e.kind,title:r,text:n}}function Gf({loadHistoryItemDetail:e,onSelectHistoryItemDetail:r}){const n=c.useRef(0),a=c.useRef(new Map),[s,o]=c.useState(null),l=c.useCallback((p,g)=>{o({title:p,text:g})},[]),i=c.useCallback((p,g,b)=>{if(b&&r){r({item:p,detail:g});return}o({title:g.title,text:g.text})},[r]),d=c.useCallback(async({item:p,fallbackTitle:g,fallbackText:b,loadingText:v,errorText:x,useSelectionCallback:y})=>{if(!p.hasDeferredDetail||!e){i(p,Ss(p,g,b),y);return}const k=a.current.get(p.id);if(k){i(p,k,y);return}const C=n.current+1;n.current=C,y&&r||o({title:g,text:v});try{const w=await e(p.id);if(a.current.set(p.id,w),n.current!==C)return;i(p,w,y)}catch(w){if(n.current!==C)return;i(p,Ss(p,g,w instanceof Error?w.message:x),y)}},[e,r,i]),h=c.useCallback(async(p,g)=>{var b;await d({item:p,fallbackTitle:g,fallbackText:((b=p.detailText)==null?void 0:b.trim())||p.text||"Command output",loadingText:"Loading full command output...",errorText:"Unable to load full command output.",useSelectionCallback:!0})},[d]),u=c.useCallback(async(p,g)=>{var b;await d({item:p,fallbackTitle:g,fallbackText:((b=p.detailText)==null?void 0:b.trim())||p.text||"Tool call",loadingText:"Loading full tool call details...",errorText:"Unable to load full tool call details.",useSelectionCallback:!0})},[d]),m=c.useCallback(async(p,g,b,v,x)=>{await d({item:p,fallbackTitle:g,fallbackText:b,loadingText:v,errorText:x,useSelectionCallback:!1})},[d]),f=c.useCallback(()=>{n.current+=1,o(null)},[]);return{expandedText:s,openExpandedText:l,openCommandDetail:h,openToolCallDetail:u,openDeferredHistoryItemDetail:m,closeExpandedText:f}}function Ff(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 Hf({threadId:e,turnsLength:r,totalTurnCount:n,loadingEarlier:a,onLoadEarlier:s,scrollRequestKey:o,bottomSpacer:l,onTailVisibilityChange:i,contentRevisionInputs:d}){const h=c.useRef(null),u=c.useRef(null),m=c.useRef(o),f=c.useRef(null),p=c.useRef(l),g=c.useRef(0),b=c.useRef(0),v=c.useRef(null),x=c.useRef(null),y=c.useRef(null),k=c.useRef(!0),C=c.useRef(!0),w=c.useRef(!1),j=c.useRef(!1),S=c.useRef(!1),L=c.useRef(!1),P=c.useRef(null),K=c.useRef(0),[F,R]=c.useState(Cs),[J,Z]=c.useState(0),[D,te]=c.useState(!0),oe=Ff(d),_=typeof s=="function"||n!==void 0,Y=n??r,I=_?0:Math.max(0,r-F),H=(_?Math.max(0,Y-r):0)+I,E=_?r:r-I,W=_?0:r-E,O=_?Math.max(0,Y-r):0,N=_?O+W:W,T=!_&&N>0&&J>=2,U=_&&O>0&&W===0&&typeof s=="function",X=c.useCallback(()=>{const G=h.current;if(!G){v.current=null;return}v.current={scrollHeight:G.scrollHeight,scrollTop:G.scrollTop}},[]),ie=c.useCallback(()=>!U||a||S.current?!1:(X(),S.current=!0,L.current=!1,K.current=0,s==null||s(),!0),[U,a,s,X]),Q=c.useCallback(()=>{const G=h.current,me=x.current;if(!G)return;const ge=me?$f(G,me):dr(G);k.current=ge,te(we=>we===ge?we:ge)},[]),de=c.useCallback(()=>{const G=h.current;if(G){j.current=!0;const me=G.scrollTop,ge=b.current,we=me-ge;b.current=me,dr(G,1)?(w.current=!1,C.current=!0):we<-1?(w.current=!0,C.current=!1):we>1&&(C.current=!w.current&&dr(G,Wn)),me<=0&&j.current?L.current=!0:me>0&&(L.current=!1,K.current=0)}Q()},[Q]),re=c.useCallback(()=>{const G=h.current;G&&(G.scrollTop=G.scrollHeight,b.current=G.scrollTop,g.current=G.scrollHeight,k.current=!0,te(me=>me||!0),w.current=!1,C.current=!0)},[]),xe=c.useCallback(()=>{const G=h.current;G&&(b.current=G.scrollTop,g.current=G.scrollHeight,C.current=!1,w.current=!0)},[]),le=c.useCallback(()=>{if(_&&W===0){ie();return}R(G=>Math.min(r,G+Mf)),Z(G=>G+1)},[W,_,ie,r]),ve=c.useCallback(G=>{const me=h.current;if(!(!me||G.deltaY>=-8||me.scrollTop>0||!U)){if(!L.current){L.current=!0;return}ie()}},[U,ie]),Pe=c.useCallback(G=>{var me;P.current=((me=G.touches.item(0))==null?void 0:me.clientY)??null,K.current=0},[]),se=c.useCallback(G=>{var Re;const me=h.current,ge=((Re=G.touches.item(0))==null?void 0:Re.clientY)??null,we=P.current;if(P.current=ge,!me||ge===null||we===null||me.scrollTop>0||!U){K.current=0;return}const _e=ge-we;if(_e<=0){K.current=0;return}if(!L.current){L.current=!0,K.current=0;return}K.current+=_e,K.current>=28&&ie()},[U,ie]),ye=c.useCallback(()=>{P.current=null,K.current=0},[]),je=c.useCallback(()=>{R(r)},[r]);return c.useLayoutEffect(()=>{const G=window.requestAnimationFrame(()=>{re()});return()=>{window.cancelAnimationFrame(G)}},[e,re]),c.useEffect(()=>{S.current=!1,j.current=!1,L.current=!1,v.current=null},[e]),c.useEffect(()=>{a||(S.current=!1)},[a,r]),c.useLayoutEffect(()=>{const G=v.current,me=h.current;if(!G||!me||a)return;v.current=null;const ge=me.scrollHeight-G.scrollHeight;if(ge<=0){g.current=me.scrollHeight,b.current=me.scrollTop;return}const we=G.scrollTop+ge;me.scrollTop=we,b.current=we,g.current=me.scrollHeight,w.current=!0,C.current=!1,L.current=!1},[a,r]),c.useEffect(()=>{R(G=>G>=r-1?r:Math.max(G,Cs))},[r]),c.useEffect(()=>{const G=h.current;G&&(g.current=G.scrollHeight,b.current=G.scrollTop,dr(G,1)?(w.current=!1,C.current=!0):(w.current||!dr(G,Wn))&&(C.current=!1)),Q()},[oe,Q,F]),c.useEffect(()=>{const G=o!==m.current,me=f.current!==oe;if(f.current=oe,!(G||me&&C.current&&!w.current))return;const we=window.requestAnimationFrame(()=>{re()});return o!==m.current&&(m.current=o),()=>{window.cancelAnimationFrame(we)}},[oe,D,re,o]),c.useEffect(()=>{const G=h.current,me=u.current;if(!G||!me||typeof ResizeObserver>"u")return;g.current=G.scrollHeight;const ge=new ResizeObserver(()=>{const we=G.scrollHeight,_e=g.current;if(g.current=we,we<=_e)return;const Re=_e>0&&_e-G.scrollTop-G.clientHeight<=1;w.current||!(C.current||Re||k.current)||window.requestAnimationFrame(()=>{re()})});return ge.observe(me),()=>{ge.disconnect()}},[re]),c.useEffect(()=>{if(!C.current||w.current){p.current=l;return}if(l===p.current)return;p.current=l;const G=window.requestAnimationFrame(()=>{re()});return()=>{window.cancelAnimationFrame(G)}},[l,re]),c.useEffect(()=>{i==null||i(D)},[D,i]),{scrollContainerRef:h,scrollContentRef:u,tailSentinelRef:x,topSentinelRef:y,isTailVisible:D,handleScroll:de,handleWheel:ve,handleTouchStart:Pe,handleTouchMove:se,handleTouchEnd:ye,preserveScrollPositionForResize:xe,serverManagedHistory:_,effectiveTotalTurnCount:Y,startIndex:I,visibleTurnAbsoluteOffset:H,hiddenCount:N,loadedHiddenCount:W,unloadedHiddenCount:O,showLoadAll:T,handleLoadEarlierClick:le,handleLoadAllClick:je}}function Of(e){return e==="completed"||e==="failed"||e==="interrupted"}function Uf(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 Wf({threadId:e,turns:r,totalTurnCount:n,pendingRequests:a=[],activeTurnId:s=null,threadRunning:o=!1,pendingSteers:l=[],livePlan:i=null,liveItems:d=null,respondingRequestId:h=null,onRespondToRequest:u,liveOutput:m,scrollRequestKey:f=0,bottomSpacer:p=0,className:g="",onTailVisibilityChange:b,loadingEarlier:v=!1,onLoadEarlier:x,ephemeralUserNote:y=null,answeredRequestNotes:k=[],activityNotes:C=[],optimisticSteers:w=[],optimisticTurn:j=null,onLoadHistoryItemDetail:S,onOpenThread:L,onSelectArtifact:P,onSelectHistoryItemDetail:K,adapter:F,autoCollapseCompletedTurns:R}){var tt,z,V,fe,Le;const J=el(),Z=R??(J==null?void 0:J.autoCollapseCompletedTurns)??!1,[D,te]=c.useState({}),[oe,_]=c.useState(()=>new Set),Y=(F==null?void 0:F.onLoadHistoryItemDetail)??S,I=F==null?void 0:F.onOpenLinkedThread,{expandedText:q,openExpandedText:H,openCommandDetail:E,openToolCallDetail:W,openDeferredHistoryItemDetail:O,closeExpandedText:N}=Gf({loadHistoryItemDetail:Y,onSelectHistoryItemDetail:K}),{scrollContainerRef:T,scrollContentRef:U,tailSentinelRef:X,topSentinelRef:ie,handleScroll:Q,handleWheel:de,handleTouchStart:re,handleTouchMove:xe,handleTouchEnd:le,preserveScrollPositionForResize:ve,serverManagedHistory:Pe,effectiveTotalTurnCount:se,startIndex:ye,visibleTurnAbsoluteOffset:je,hiddenCount:G,loadedHiddenCount:me,unloadedHiddenCount:ge,showLoadAll:we,handleLoadEarlierClick:_e,handleLoadAllClick:Re}=Hf({threadId:e,turnsLength:r.length,totalTurnCount:n,loadingEarlier:v,onLoadEarlier:x,scrollRequestKey:f,bottomSpacer:p,onTailVisibilityChange:b,contentRevisionInputs:[r,a,l,w,m,i,d,j,k,C,y,p]}),Ee=c.useCallback((ne,Ge)=>{te(He=>({...He,[ne]:!Ge}))},[]),Me=c.useCallback((ne,Ge)=>{const He=D[ne.id];return He!==void 0?He:!!(Z&&Of(ne.status)&&!Ge.forceActive&&!Ge.hasLiveActivity)},[D,Z]),M=Pe?r:r.slice(ye),ue=se+1,A=o&&(!s||!M.some(ne=>ne.id===s)&&(j==null?void 0:j.id)!==s),$=(j==null?void 0:j.id)??((tt=M.at(-1))==null?void 0:tt.id)??null,ee=A&&$!==null,pe=!!d&&(M.some(ne=>ne.id===d.turnId)||(j==null?void 0:j.id)===d.turnId),ke=d&&pe?d.turnId:d&&ee?$:null,Ae=j&&ke===j.id?(d==null?void 0:d.items)??null:null,Ne=((d==null?void 0:d.items.length)??0)>0,De=d&&ke===null?d.items:null,et=c.useMemo(()=>d&&ke===null&&d.items.length>0?Bf(d.turnId,d.items):null,[d,ke]),Ve=Math.max(1,se+(j?1:0)),ot=!!m&&!!j&&j.status!=="failed"&&!Ae,Qe=m&&M.length>0?s&&M.some(ne=>ne.id===s)?s:((z=M.findLast(ne=>ll(ne.status)))==null?void 0:z.id)??(ee?$:null):null,ut=!!Qe,at=c.useMemo(()=>ol(m),[m]),Oe=[...l.map(ne=>({id:ne.id,prompt:ne.prompt,status:"Accepted",createdAt:ne.createdAt,canCancel:!0})),...w.map(ne=>({id:ne.id,prompt:ne.prompt,status:ne.status==="steering"?"Steering":null,createdAt:ne.createdAt,canCancel:!1}))].sort((ne,Ge)=>ne.createdAt.localeCompare(Ge.createdAt)),Be=c.useMemo(()=>Ap({answeredRequestNotes:k,pendingRequests:a,visibleTurns:M,optimisticTurn:j}),[k,j,a,M]),Ue=c.useMemo(()=>_p({activityNotes:C,visibleTurns:M,optimisticTurn:j}),[C,j,M]);return t.jsxs(t.Fragment,{children:[t.jsx("section",{className:`flex min-h-0 flex-1 flex-col ${g}`.trim(),children:t.jsx("div",{ref:T,"data-testid":"thread-scroll-container",onScroll:Q,onWheel:de,onTouchStart:re,onTouchMove:xe,onTouchEnd:le,onTouchCancel:le,className:"thread-graph-scroll-container min-h-0 flex-1 overflow-y-auto overscroll-contain",style:p>0?{paddingBottom:p}:void 0,children:t.jsxs("div",{ref:U,className:"thread-graph-scroll-content",children:[t.jsx("div",{ref:ie,"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:[G>0&&t.jsx("button",{type:"button",onClick:_e,disabled:v,className:"thread-graph-history-button rounded-full border px-2.5 py-1.5 transition",children:v?"Loading earlier...":"Load 3 earlier"}),we&&t.jsx("button",{type:"button",onClick:Re,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 ",M.length," of ",se," turns",G>0?` · ${G} earlier hidden${me>0&&ge>0?` (${me} loaded)`:""}`:""]})]})}),r.length===0&&!m&&!j&&t.jsx("div",{className:"thread-graph-empty-state px-3 py-8 text-sm sm:px-5",children:"Send the first prompt to start the thread."}),(M.length>0||j||Ue.leading.length>0||Ue.trailing.length>0)&&t.jsxs("div",{className:"thread-graph-message-list",children:[Ue.leading.length>0?t.jsx(ir,{notes:Ue.leading,onOpenThread:L,onOpenLinkedThread:I}):null,M.map((ne,Ge)=>{var He,Fe,qe,dt,xt;return t.jsxs("div",{children:[(((He=Ue.beforeTurnId.get(ne.id))==null?void 0:He.length)??0)>0?t.jsx(ir,{notes:Ue.beforeTurnId.get(ne.id)??[],onOpenThread:L,onOpenLinkedThread:I}):null,(((Fe=Be.beforeTurnId.get(ne.id))==null?void 0:Fe.length)??0)>0?t.jsx(On,{entries:Be.beforeTurnId.get(ne.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const lt=Uf(ne,j),wt=(i==null?void 0:i.turnId)===ne.id?i:null,yt=ke===ne.id?(d==null?void 0:d.items)??null:null,jt=Qe===ne.id?m:"",be=s===ne.id||ee&&$===ne.id,ze=!!wt||!!jt||!!(yt&&yt.length>0),rt=Me(lt,{forceActive:be,hasLiveActivity:ze});return t.jsx(vn,{threadId:e,...F?{adapter:F}:{},turn:lt,absoluteIndex:je+Ge+1,isCollapsed:rt,livePlan:wt,liveItems:yt,liveOutput:jt,forceActive:be,onToggleCollapse:Ee,onOpenExpandedText:H,onOpenCommandDetail:E,onOpenToolCallDetail:W,onOpenDeferredHistoryItemDetail:O,onBeforeMessageResize:ve,...P?{onSelectArtifact:P}:{},scrollRootRef:T,articleRef:void 0})})(),(((qe=Ue.afterTurnId.get(ne.id))==null?void 0:qe.length)??0)>0?t.jsx(ir,{notes:Ue.afterTurnId.get(ne.id)??[],onOpenThread:L,onOpenLinkedThread:I}):null,(dt=Be.notesByTurnId.get(ne.id))!=null&&dt.length||(xt=Be.pendingRequestsByTurnId.get(ne.id))!=null&&xt.length?t.jsx(Mp,{notes:Be.notesByTurnId.get(ne.id)??[],requests:Be.pendingRequestsByTurnId.get(ne.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null]},ne.id)}),j&&M.every(ne=>ne.id!==j.id)&&t.jsxs(t.Fragment,{children:[(((V=Ue.beforeTurnId.get(j.id))==null?void 0:V.length)??0)>0?t.jsx(ir,{notes:Ue.beforeTurnId.get(j.id)??[],onOpenThread:L,onOpenLinkedThread:I}):null,(((fe=Be.beforeTurnId.get(j.id))==null?void 0:fe.length)??0)>0?t.jsx(On,{entries:Be.beforeTurnId.get(j.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const ne=ot?m:"",Ge=s===j.id||ee&&$===j.id,He=!!(Ae&&Ae.length>0)||!!ne,Fe=Me(j,{forceActive:Ge,hasLiveActivity:He});return t.jsx(vn,{threadId:e,...F?{adapter:F}:{},turn:j,absoluteIndex:ue,isCollapsed:Fe,livePlan:null,liveItems:Ae,liveOutput:ne,forceActive:Ge,onToggleCollapse:Ee,onOpenExpandedText:H,onOpenCommandDetail:E,onOpenToolCallDetail:W,onOpenDeferredHistoryItemDetail:O,onBeforeMessageResize:ve,...P?{onSelectArtifact:P}:{},scrollRootRef:T})})(),(((Le=Ue.afterTurnId.get(j.id))==null?void 0:Le.length)??0)>0?t.jsx(ir,{notes:Ue.afterTurnId.get(j.id)??[],onOpenThread:L,onOpenLinkedThread:I}):null]})]}),Oe.length>0&&t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:Oe.map(ne=>t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Et,{threadId:e,item:{id:ne.id,kind:"userMessage",text:ne.prompt,status:ne.status},scrollRootRef:T,onBeforeMessageResize:ve,...F?{adapter:F}:{}}),e&&ne.canCancel&&(F!=null&&F.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:oe.has(ne.id),onClick:()=>{var Ge;_(He=>new Set(He).add(ne.id)),Promise.resolve((Ge=F.cancelPendingSteer)==null?void 0:Ge.call(F,e,ne.id)).catch(()=>{}).finally(()=>{_(He=>{const Fe=new Set(He);return Fe.delete(ne.id),Fe})})},children:oe.has(ne.id)?"Canceling...":"Cancel"})}):null]},ne.id))}),(Be.trailing.length>0||Ue.trailing.length>0)&&t.jsx($p,{entries:[...Ue.trailing.map(ne=>({kind:"activity",id:ne.id,createdAt:ne.createdAt,note:ne})),...Be.trailing],respondingRequestId:h,onRespondToRequest:u??void 0,onOpenThread:L,onOpenLinkedThread:I}),y&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:t.jsx(Et,{threadId:e,item:{id:"ephemeral-plan-decision-note",kind:"userMessage",text:y},scrollRootRef:T,onBeforeMessageResize:ve})}),et&&De&&De.length>0&&t.jsx(vn,{threadId:e,...F?{adapter:F}:{},turn:et,absoluteIndex:Ve,isCollapsed:D[et.id]??!1,livePlan:(i==null?void 0:i.turnId)===et.id?i:null,liveItems:De,liveOutput:"",forceActive:!0,onToggleCollapse:Ee,onOpenExpandedText:H,onOpenCommandDetail:E,onOpenToolCallDetail:W,onOpenDeferredHistoryItemDetail:O,onBeforeMessageResize:ve,...P?{onSelectArtifact:P}:{},scrollRootRef:T}),m&&!ut&&!ot&&!Ne&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:at?t.jsx(oa,{threadId:e,item:at,scrollRootRef:T,onOpenExpandedText:H,onOpenCommandDetail:E,onOpenToolCallDetail:W,onOpenDeferredHistoryItemDetail:O,onBeforeMessageResize:ve,...P?{onSelectArtifact:P}:{},...F?{adapter:F}:{}}):t.jsx(Et,{threadId:e,item:{id:"live-agent-message-fallback",kind:"agentMessage",text:m},scrollRootRef:T,streaming:!0,onBeforeMessageResize:ve,...F?{adapter:F}:{}})}),t.jsx("div",{ref:X,"aria-hidden":"true",className:"h-px w-full"})]})})}),t.jsx(Jm,{open:q!==null,title:(q==null?void 0:q.title)??"Full text",text:(q==null?void 0:q.text)??"",onClose:N})]})}var xl=c.memo(Wf);function Vf(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}function Vn(e){return e.replace(/\r\n/g,`
3669
- `)}function Ts(e){const r=Vn(e),n=r.split(`
3667
+ `);for(;r.length>1&&((n=r.at(-1))==null?void 0:n.trim())==="";)r.pop();return r}function gt(e){const r=Vp(e);return r.length===1?{firstLine:r[0]??"",showGap:!1,isTruncated:!1}:{firstLine:r[0]??"",showGap:!0,isTruncated:!0}}function pl(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(B.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"}:r==="failed"||r==="failure"||r==="error"||r==="errored"?{className:"is-failed",icon:t.jsx(B.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"}:aa(e)?{className:"is-pending",icon:t.jsx(B.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 Kp(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 qp(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 Ot({actions:e,children:r,className:n,headerMeta:a,icon:o,item:s,timeMeta:l,title:i,tone:d}){const h=pl(s.status);return t.jsxs("div",{className:`thread-graph-event thread-graph-history-event ${qp(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(Qr,{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 ar({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=pl(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 ${Kp(m)} ${a??""}`,children:t.jsx(kr,{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(wr,{value:"item-1",className:"border-0",children:[t.jsxs(Yr,{"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(Qr,{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(yr,{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(rr,{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(B.ExternalLink,{className:"h-3.5 w-3.5"}),r]})]})]})})})}var Xp=c.memo(function({item:r,scrollRootRef:n,onBeforeResize:a,timeMeta:o}){return t.jsx(Ot,{className:"thread-graph-event-plan",icon:t.jsx(B.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(sl,{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}:{}})})})}),Yp=c.memo(function({item:r,timeMeta:n}){const a=aa(r.status)||r.text==="Compacting context",o=a?"Compacting context":"Context compacted",s=r.detailText&&r.detailText!==o?r.detailText:null;return t.jsxs(Ot,{className:"thread-graph-event-context",icon:t.jsx(B.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(On,{tone:"emerald"}):null]}),s?t.jsx("p",{className:"thread-graph-history-event-secondary",title:s,children:s}):null]})}),Zp=c.memo(function({item:r,timeMeta:n}){return t.jsx(Ot,{className:"thread-graph-event-generic",icon:t.jsx(B.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(rr,{text:r.text})})})}),Jp=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=gt(n.previewText??n.text);return t.jsx(ar,{actionLabel:"Open full command",actionTitle:"Command Output",autoOpen:r,className:"thread-graph-event-command",icon:t.jsx(B.Terminal,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Command Output"),preview:s,timeMeta:o,title:"command",tone:"command"})}),Qp=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=gt(n.text);return t.jsx(ar,{actionLabel:"Open full tool call",actionTitle:"Tool Call Details",autoOpen:r,className:"thread-graph-event-tool",icon:t.jsx(B.Wrench,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Tool Call Details"),preview:s,timeMeta:o,title:"tool_call",tone:"tool"})}),ef=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=gt(n.text);return t.jsx(ar,{actionLabel:"Open agent details",actionTitle:"Agent Details",autoOpen:r,className:"thread-graph-event-agent-tool",icon:t.jsx(B.Bot,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Agent Details"),preview:s,timeMeta:o,title:"agent",tone:"agent"})}),tf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=gt(n.text);return t.jsx(ar,{actionLabel:"Open skill details",actionTitle:"Skill Details",autoOpen:r,className:"thread-graph-event-skill-tool",icon:t.jsx(B.Sparkles,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Skill Details"),preview:s,timeMeta:o,title:"skill",tone:"skill"})}),rf=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=gt(s);return t.jsx(ar,{actionLabel:"Open full web search",actionTitle:"Web Search Details",autoOpen:r,className:"thread-graph-event-search",icon:t.jsx(B.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=gt(s);return t.jsx(ar,{actionLabel:"Open full file read",actionTitle:"File Read Details",autoOpen:r,className:"thread-graph-event-file-read",icon:t.jsx(B.FileText,{className:"h-4 w-4"}),item:n,onOpen:()=>a("File Read Details",l),preview:i,timeMeta:o,title:"file_read",tone:"fileRead"})}),af=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(Ot,{className:"thread-graph-event-image",icon:t.jsx(B.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=ml(o??((p=r.previewText)==null?void 0:p.trim())??r.text,48),i=Wp(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(Ot,{className:"thread-graph-event-file-change",headerMeta:u,icon:t.jsx(B.FilePenLine,{className:"h-4 w-4"}),item:r,timeMeta:a,title:"file_change",tone:"fileChange"})}),of=c.memo(function({item:r,onSelect:n,timeMeta:a}){const o=na(),[s,l]=c.useState(!1),i=r.artifact,d=i?o.renderArtifact({artifact:i,expanded:s,onToggleExpanded:()=>l(h=>!h)}):null;return t.jsx(Ot,{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(B.PackageOpen,{className:"h-3.5 w-3.5"}),"Inspect"]}):null]}),className:"thread-graph-event-artifact",icon:t.jsx(B.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]})})}),lf=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(`
3668
+ `).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=gt(a||(s&&s!==o?s:o)),d=!!(a&&i.showGap);return t.jsx(Ot,{className:"thread-graph-event-hook",icon:t.jsx(B.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(rr,{text:i.firstLine})]}):t.jsx(rr,{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]})})}),df=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o,timeMeta:s}){const l=r.filter(d=>aa(d.status)).length,i=r.length===1?"1 command":`${r.length} commands`;return t.jsx(Jr,{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(Hp,{}),onToggleExpanded:a,runningIndicator:l>0?t.jsx(On,{}):null,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-amber-300/28 bg-amber-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-amber-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:i}),l>0?t.jsx("span",{className:"inline-flex items-center text-xs text-amber-100/90",children:t.jsx(On,{})}):null]}),timeMeta:s,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} command entries`,children:r.map((d,h)=>{const u=gt(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)})})}),cf=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(Jr,{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(Op,{}),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=gt(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)})})}),hf=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(Jr,{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(Fp,{}),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=gt(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)})})}),uf=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(Jr,{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(Gp,{}),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:ml(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 mf(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 pf({status:e}){const r=mf(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(Qr,{"aria-label":n,title:n.replace("Plan step status: ",""),className:a,children:r==="completed"?t.jsx(B.CheckCircle2,{className:"h-3.5 w-3.5"}):r==="in_progress"?t.jsx(B.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):r==="pending"?t.jsx(B.Clock3,{className:"h-3.5 w-3.5"}):r==="failed"?t.jsx(B.XCircle,{className:"h-3.5 w-3.5"}):t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.14em]",children:"?"})})}function ff({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(Qr,{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(pf,{status:r.status})]},`${e.turnId}-${n}`))})]})}function gf({footer:e,history:r,liveHookPrompt:n,liveOutput:a,livePlan:o}){return t.jsxs(t.Fragment,{children:[r,o?t.jsx(ff,{livePlan:o}):null,n??a??null,e]})}function xf({absoluteIndex:e,body:r,collapsed:n,collapsedBody:a,error:o,footer:s,headerStatus:l,isActive:i=!1,onToggleCollapse:d,refCallback:h,startedAt:u,timeLabel:m,timeTitle:f,tokenSummary:p}){return t.jsxs("article",{ref:h,"data-testid":"chat-turn","data-turn-active":i?"true":"false",className:"thread-graph-turn px-3 py-2 sm:px-5 sm:py-3",children:[t.jsxs("div",{className:"thread-graph-turn-header flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0 flex flex-1 items-start gap-1.5",children:[t.jsxs("div",{className:"min-w-0 flex flex-1 items-center gap-1.5 overflow-hidden",children:[t.jsxs("span",{className:"thread-graph-turn-index rounded-[0.6rem] border px-1.5 py-0.5 text-[10px] uppercase tracking-[0.16em]",children:["Turn ",e]}),t.jsx("time",{dateTime:u??void 0,title:f,className:"thread-graph-turn-time shrink-0 text-[10px] sm:text-[11px]",children:m}),l,o?t.jsx("p",{className:"hidden truncate text-[11px] text-rose-200 sm:block",children:o}):null]}),p]}),t.jsx("button",{type:"button","aria-label":`${n?"Expand":"Collapse"} turn ${e}`,title:n?"Expand turn":"Collapse turn",onClick:d,className:"thread-graph-turn-collapse inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-md transition",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:n?t.jsx("path",{d:"m4.5 10 3.5-3.5L11.5 10"}):t.jsx("path",{d:"m4.5 6 3.5 3.5L11.5 6"})})})]}),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 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 2.75v8"}),t.jsx("path",{d:"m4.75 7.5 3.25 3.25L11.25 7.5"})]})}function vf(){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 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.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 wf(){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 Pr(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 sa(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 ur(e){return!Number.isFinite(e)||e<=0?"$0.0000":`$${e.toFixed(4)}`}function zr(e,r,n){const a=e??null;return!Number.isFinite(a??NaN)||a===null||r<=0||n<=0?null:a*n/r}function fl(e){var i,d,h,u,m;const r=(i=e.tokenUsage)==null?void 0:i.total;if(!r)return[];const n=Math.max(r.inputTokens-r.cachedInputTokens,0),a=Math.max(r.cachedInputTokens,0),o=Math.max(r.reasoningOutputTokens,0),s=Math.max(r.outputTokens-o,0);return[n>0?{id:"in",label:"Input",tokenCompactValue:Pr(n),tokenRawValue:n,usdCompactValue:e.priceEstimate?ur(e.priceEstimate.inputUsd):"--",usdRawValue:((d=e.priceEstimate)==null?void 0:d.inputUsd)??null,className:"token-badge-in",icon:t.jsx(bf,{})}:null,a>0?{id:"cache",label:"Cached input",tokenCompactValue:Pr(a),tokenRawValue:a,usdCompactValue:e.priceEstimate?ur(e.priceEstimate.cachedInputUsd):"--",usdRawValue:((h=e.priceEstimate)==null?void 0:h.cachedInputUsd)??null,className:"token-badge-cache",icon:t.jsx(kf,{})}:null,s>0?{id:"out",label:"Output",tokenCompactValue:Pr(s),tokenRawValue:s,usdCompactValue:e.priceEstimate?ur(zr(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),s)??0):"--",usdRawValue:zr((u=e.priceEstimate)==null?void 0:u.outputUsd,Math.max(r.outputTokens,0),s),className:"token-badge-out",icon:t.jsx(vf,{})}:null,o>0?{id:"reason",label:"Reasoning",tokenCompactValue:Pr(o),tokenRawValue:o,usdCompactValue:e.priceEstimate?ur(zr(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),o)??0):"--",usdRawValue:zr((m=e.priceEstimate)==null?void 0:m.outputUsd,Math.max(r.outputTokens,0),o),className:"token-badge-reason",icon:t.jsx(wf,{})}:null].filter(f=>f!==null)}function yf(e){return fl(e).map(r=>({id:r.id,label:r.tokenCompactValue,title:`${r.label}: ${r.tokenRawValue} tokens`,className:r.className,icon:r.icon}))}function gl(e){return{label:e.priceEstimate?sa(e.priceEstimate.totalUsd):"--",title:e.priceEstimate===null||e.priceEstimate===void 0?"Price estimate unavailable for this model.":`Estimated cost: ${ur(e.priceEstimate.totalUsd)}`,className:e.priceEstimate?"token-badge-total":"token-badge-empty"}}var xn="inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-normal leading-none sm:text-[11px]";function jf({turn:e}){const r=fl(e),n=gl(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 y=window.innerWidth||document.documentElement.clientWidth,k=12,j=w.left+w.width/2-x/2,v=k,N=Math.max(v,y-k-x),S=Math.min(Math.max(j,v),N);d(Math.round(S-j))};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:`${xn} appearance-none whitespace-nowrap bg-transparent !text-[10px] !font-normal !leading-none transition hover:bg-[var(--theme-hover)] sm:!text-[11px] ${n.className}`,title:n.title,children:n.label}),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:`${xn} ${p.className}`,title:`${p.label}: ${p.usdCompactValue}, ${p.tokenRawValue} tokens`,children:[p.icon,t.jsx("span",{className:"thread-token-badge-value font-medium",children:p.tokenCompactValue})]},p.id))]}),t.jsxs("div",{ref:h,className:"relative shrink-0 md:hidden",children:[n?t.jsx("button",{type:"button","aria-label":"Show token and price details","aria-expanded":a,onClick:()=>o(p=>!p),className:`${xn} appearance-none whitespace-nowrap bg-transparent !text-[10px] !font-normal !leading-none transition hover:bg-[var(--theme-hover)] sm:!text-[11px] ${n.className}`,title:n.title,children:n.label}):null,a&&r.length>0?t.jsx("div",{ref:m,className:"absolute left-1/2 top-full z-30 mt-1.5",style:{transform:`translateX(${i}px) translateX(-50%)`},children:f()}):null]})]})}function Nf({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 ys(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 Cf(e){switch(e.kind){case"fileChange":case"webSearch":case"image":case"contextCompaction":return!0;case"commandExecution":case"toolCall":return!ll(e.status);default:return!1}}function Sf(e,r,n){if(!e||!mr(n))return e;const a=e.plan.findIndex(i=>ys(i.status)==="in_progress");if(a<0)return e;const o=e.plan.findIndex((i,d)=>d>a&&ys(i.status)==="pending");if(o<0||!r.some(i=>Cf(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 Tf(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 js({status:e}){const r=tl(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(Nf,{tone:"emerald"})})}function Ns({turn:e,variant:r="header"}){const n=tl(e.status),a=Tf(e),o=yf(e),s=gl(e),l=mr(e.status),i=e.status==="failed"?"border-rose-300/20 bg-rose-300/[0.06] text-rose-100":l?"border-sky-300/22 bg-sky-300/[0.08] text-sky-100":"border-stone-700/90 bg-stone-900/70 text-stone-200";if(r==="footer")return t.jsxs("div",{className:`flex w-full flex-col gap-1.5 rounded-[0.95rem] border px-3 py-2 text-xs ${i}`,children:[t.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(js,{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:Gt(e.startedAt),className:"timeline-meta-text shrink-0 text-[11px]",children:ft(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(js,{status:e.status}),t.jsx("span",{className:"timeline-meta-text min-w-0 truncate",children:a})]})}function Ef(e,r){return e.createdAt??r}var oa=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(Tp(n.kind))return t.jsx(Et,{threadId:r,item:n,scrollRootRef:a,timeLabel:m,timeTitle:f,...h?{onBeforeMessageResize:h}:{},...u?{adapter:u}:{}});if(n.kind==="reasoning")return t.jsx(Et,{item:{...n,kind:"agentMessage",status:n.status??null},scrollRootRef:a,timeLabel:m,timeTitle:f,...h?{onBeforeMessageResize:h}:{}});if(n.kind==="artifact")return t.jsx(of,{item:n,timeMeta:p,...d?{onSelect:(y,k)=>d({item:y,artifact:k})}:{}});if(n.kind==="commandExecution")return t.jsx(Jp,{autoOpen:g,item:n,onOpen:s,timeMeta:p});if(n.kind==="toolCall")return t.jsx(Qp,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="agentToolCall")return t.jsx(ef,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="skillToolCall")return t.jsx(tf,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="webSearch"){const y=n,k=((b=y.detailText)==null?void 0:b.trim())||y.text||"Web search";return t.jsx(rf,{autoOpen:g,item:y,timeMeta:p,onOpen:()=>i(y,"Web Search Details",k,"Loading full web search details...","Unable to load full web search details.")})}if(n.kind==="fileRead"){const y=n,k=((w=y.detailText)==null?void 0:w.trim())||y.text||"File read";return t.jsx(nf,{autoOpen:g,item:y,timeMeta:p,onOpen:()=>i(y,"File Read Details",k,"Loading full file read details...","Unable to load full file read details.")})}if(n.kind==="image")return t.jsx(af,{threadId:r,item:n,onOpen:o,getImageAssetUrl:u==null?void 0:u.getImageAssetUrl,timeMeta:p});if(n.kind==="plan")return t.jsx(Xp,{item:n,scrollRootRef:a,timeMeta:p,...h?{onBeforeResize:h}:{}});if(n.kind==="fileChange"){const y=n,k=((x=y.detailText)==null?void 0:x.trim())||y.text||"File change";return t.jsx(sf,{item:y,timeMeta:p,onOpen:()=>i(y,"File Change Details",k,"Loading full file change details...","Unable to load full file change details.")})}return n.kind==="contextCompaction"?t.jsx(Yp,{item:n,timeMeta:p}):n.kind==="hook"?t.jsx(lf,{item:n,timeMeta:p}):t.jsx(Zp,{item:n,timeMeta:p})});function Lf(e){return e==="completed"||e==="failed"||e==="interrupted"}function Pf(e){const r=Date.parse(e.createdAt??"");return Number.isFinite(r)?r:null}function zf(e){let r=null;for(const n of e){const a=Pf(n);a!==null&&(r=r===null?a:Math.max(r,a))}return r}function If(e,r){const n=Date.parse(e??""),a=zf(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 Rf(e,r){const n=Date.parse(e??""),a=Date.parse(r??"");if(!Number.isFinite(n)||!Number.isFinite(a))return r?ft(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 fr({absoluteLabel:e,className:r="",timestamp:n,turnStartedAt:a}){const[o,s]=c.useState(!1);if(!n)return null;const l=Gt(n),i=Rf(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 Ir(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 Af(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 bn=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:y,isLatestVisibleTurn:k=!1}){const j=!!l||!!d||!!(i&&i.length>0),v=h||mr(a.status)||j||k,N=v&&!mr(a.status)?{...a,status:"inProgress"}:a,S=c.useMemo(()=>zp(a.items,i),[i,a.items]),L=c.useMemo(()=>Sf(l,S,a.status),[l,S,a.status]),P=c.useMemo(()=>Ip(d,S),[d,S]),K=c.useMemo(()=>Pp(S,v),[v,S]),F=c.useMemo(()=>Rp(K),[K]),D=h||mr(a.status)||j,Z=ft(a.startedAt),Y=Gt(a.startedAt),$=c.useMemo(()=>ol(P),[P]),[te,oe]=c.useState({}),A=c.useCallback(W=>{oe(le=>({...le,[W]:!le[W]}))},[]),J=t.jsx(_f,{entries:F,expandedGroups:te,onToggleGroupedItem:A,threadId:r,scrollRootRef:x,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,...w?{onBeforeMessageResize:w}:{},fallbackTimestamp:a.startedAt,fallbackTimeLabel:Z,fallbackTimeTitle:Y,turnStartedAt:a.startedAt,autoOpenLatestToolDetails:D,...b?{onSelectArtifact:b}:{},...n?{adapter:n}:{}}),I=$?t.jsx(oa,{threadId:r,item:$,scrollRootRef:x,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,timeLabel:a.startedAt?t.jsx(fr,{absoluteLabel:Z,timestamp:a.startedAt,turnStartedAt:a.startedAt}):Z,timeTitle:Y,timeMeta:null,...b?{onSelectArtifact:b}:{},...n?{adapter:n}:{}}):null,q=!$&&P?t.jsx(Et,{item:{id:"live-agent-message",kind:"agentMessage",text:P},scrollRootRef:x,timeLabel:a.startedAt?t.jsx(fr,{absoluteLabel:Z,timestamp:a.startedAt,turnStartedAt:a.startedAt}):Z,timeTitle:Y,streaming:!0,...w?{onBeforeMessageResize:w}:{}}):null,O=v?t.jsx(Ns,{turn:N,variant:"footer"}):null,T=c.useMemo(()=>Af(F),[F]),U=c.useMemo(()=>If(a.startedAt,S),[S,a.startedAt]),H=T.hiddenEntries.length>0,C=s&&H,E=Lf(a.status)&&H?t.jsxs("div",{className:"thread-graph-turn-collapsed-summary space-y-2",children:[T.users.map(W=>t.jsx(Et,{threadId:r,item:W,scrollRootRef:x,timeLabel:W.createdAt?ft(W.createdAt):Z,timeTitle:W.createdAt?Gt(W.createdAt):Y,...w?{onBeforeMessageResize:w}:{},...n?{adapter:n}:{}},W.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":`${U}. Expand turn ${o}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:U}),t.jsx(B.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(Et,{threadId:r,item:T.finalAgent,scrollRootRef:x,timeLabel:T.finalAgent.createdAt?t.jsx(fr,{absoluteLabel:ft(T.finalAgent.createdAt),timestamp:T.finalAgent.createdAt,turnStartedAt:a.startedAt}):Z,timeTitle:T.finalAgent.createdAt?Gt(T.finalAgent.createdAt):Y,...w?{onBeforeMessageResize:w}:{},...n?{adapter:n}:{}}):null]}):null,X=t.jsx(gf,{footer:O,history:J,liveHookPrompt:I,liveOutput:q,livePlan:L});return t.jsx(xf,{absoluteIndex:o,body:X,collapsed:C,collapsedBody:E,error:a.error,headerStatus:t.jsx(Ns,{turn:a}),isActive:v,onToggleCollapse:()=>u(a.id,C),refCallback:y,startedAt:a.startedAt,timeLabel:Z,timeTitle:Y,tokenSummary:t.jsx(jf,{turn:a})})});function _f({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 k;const x=((k=e.at(-1))==null?void 0:k.key)??null,y=c.useCallback(j=>j?t.jsx(fr,{absoluteLabel:ft(j),timestamp:j,turnStartedAt:b??f}):null,[f,b]);return t.jsx(Dp,{entries:e,expandedGroups:r,onToggleGroupedItem:n,renderCommandGroup:(j,v,N)=>t.jsx(df,{items:j.items,expanded:v,onToggleExpanded:N,onOpen:l,timeMeta:y(Ir(j))},j.key),renderFileChangeGroup:(j,v,N)=>t.jsx(uf,{items:j.items,expanded:v,onToggleExpanded:N,onOpen:s,timeMeta:y(Ir(j))},j.key),renderSearchGroup:(j,v,N)=>t.jsx(cf,{items:j.items,expanded:v,onToggleExpanded:N,onOpen:s,timeMeta:y(Ir(j))},j.key),renderFileReadGroup:(j,v,N)=>t.jsx(hf,{items:j.items,expanded:v,onToggleExpanded:N,onOpen:s,timeMeta:y(Ir(j))},j.key),renderItem:j=>{const v=Ef(j.item,f??null),S=j.item.kind==="userMessage"?j.item.createdAt?ft(v):p:j.item.createdAt?t.jsx(fr,{absoluteLabel:ft(v),timestamp:v,turnStartedAt:b??f}):p;return t.jsx(oa,{threadId:a,item:j.item,scrollRootRef:o,timeLabel:S,timeTitle:j.item.createdAt?Gt(v):g,timeMeta:y(v),autoOpenToolDetails:w&&j.key===x,onOpenExpandedText:s,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,...u?{onBeforeMessageResize:u}:{},...h?{onSelectArtifact:h}:{},...m?{adapter:m}:{}},j.key)}})}var Cs=3,Mf=3,Un=80;function dr(e,r=Un){return e.scrollHeight-e.scrollTop-e.clientHeight<=r}function $f(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 Df(e){return e.map(n=>{const a=n.createdAt;return typeof a=="string"&&a.trim()?a:null}).filter(n=>!!n).sort()[0]??null}function Bf(e,r){return{id:e,startedAt:Df(r),status:"inProgress",error:null,model:null,reasoningEffort:null,reasoningEffortAvailable:null,tokenUsage:null,priceEstimate:null,items:[]}}function Ss(e,r,n){return{id:e.id,kind:e.kind,title:r,text:n}}function Gf({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:y})=>{if(!p.hasDeferredDetail||!e){i(p,Ss(p,g,b),y);return}const k=a.current.get(p.id);if(k){i(p,k,y);return}const j=n.current+1;n.current=j,y&&r||s({title:g,text:w});try{const v=await e(p.id);if(a.current.set(p.id,v),n.current!==j)return;i(p,v,y)}catch(v){if(n.current!==j)return;i(p,Ss(p,g,v instanceof Error?v.message:x),y)}},[e,r,i]),h=c.useCallback(async(p,g)=>{var b;await d({item:p,fallbackTitle:g,fallbackText:((b=p.detailText)==null?void 0:b.trim())||p.text||"Command output",loadingText:"Loading full command output...",errorText:"Unable to load full command output.",useSelectionCallback:!0})},[d]),u=c.useCallback(async(p,g)=>{var b;await d({item:p,fallbackTitle:g,fallbackText:((b=p.detailText)==null?void 0:b.trim())||p.text||"Tool call",loadingText:"Loading full tool call details...",errorText:"Unable to load full tool call details.",useSelectionCallback:!0})},[d]),m=c.useCallback(async(p,g,b,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 Ff(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 Hf({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),y=c.useRef(null),k=c.useRef(!0),j=c.useRef(!0),v=c.useRef(!1),N=c.useRef(!1),S=c.useRef(!1),L=c.useRef(!1),P=c.useRef(null),K=c.useRef(0),[F,D]=c.useState(Cs),[Z,Y]=c.useState(0),[$,te]=c.useState(!0),oe=Ff(d),A=typeof o=="function"||n!==void 0,J=n??r,I=A?0:Math.max(0,r-F),O=(A?Math.max(0,J-r):0)+I,T=A?r:r-I,U=A?0:r-T,H=A?Math.max(0,J-r):0,C=A?H+U:U,E=!A&&C>0&&Z>=2,X=A&&H>0&&U===0&&typeof o=="function",W=c.useCallback(()=>{const G=h.current;if(!G){w.current=null;return}w.current={scrollHeight:G.scrollHeight,scrollTop:G.scrollTop}},[]),le=c.useCallback(()=>!X||a||S.current?!1:(W(),S.current=!0,L.current=!1,K.current=0,o==null||o(),!0),[X,a,o,W]),Q=c.useCallback(()=>{const G=h.current,me=x.current;if(!G)return;const ge=me?$f(G,me):dr(G);k.current=ge,te(we=>we===ge?we:ge)},[]),de=c.useCallback(()=>{const G=h.current;if(G){N.current=!0;const me=G.scrollTop,ge=b.current,we=me-ge;b.current=me,dr(G,1)?(v.current=!1,j.current=!0):we<-1?(v.current=!0,j.current=!1):we>1&&(j.current=!v.current&&dr(G,Un)),me<=0&&N.current?L.current=!0:me>0&&(L.current=!1,K.current=0)}Q()},[Q]),re=c.useCallback(()=>{const G=h.current;G&&(G.scrollTop=G.scrollHeight,b.current=G.scrollTop,g.current=G.scrollHeight,k.current=!0,te(me=>me||!0),v.current=!1,j.current=!0)},[]),xe=c.useCallback(()=>{const G=h.current;G&&(b.current=G.scrollTop,g.current=G.scrollHeight,j.current=!1,v.current=!0)},[]),ie=c.useCallback(()=>{if(A&&U===0){le();return}D(G=>Math.min(r,G+Mf)),Y(G=>G+1)},[U,A,le,r]),ve=c.useCallback(G=>{const me=h.current;if(!(!me||G.deltaY>=-8||me.scrollTop>0||!X)){if(!L.current){L.current=!0;return}le()}},[X,le]),Pe=c.useCallback(G=>{var me;P.current=((me=G.touches.item(0))==null?void 0:me.clientY)??null,K.current=0},[]),se=c.useCallback(G=>{var Re;const me=h.current,ge=((Re=G.touches.item(0))==null?void 0:Re.clientY)??null,we=P.current;if(P.current=ge,!me||ge===null||we===null||me.scrollTop>0||!X){K.current=0;return}const _e=ge-we;if(_e<=0){K.current=0;return}if(!L.current){L.current=!0,K.current=0;return}K.current+=_e,K.current>=28&&le()},[X,le]),ye=c.useCallback(()=>{P.current=null,K.current=0},[]),je=c.useCallback(()=>{D(r)},[r]);return c.useLayoutEffect(()=>{const G=window.requestAnimationFrame(()=>{re()});return()=>{window.cancelAnimationFrame(G)}},[e,re]),c.useEffect(()=>{S.current=!1,N.current=!1,L.current=!1,w.current=null},[e]),c.useEffect(()=>{a||(S.current=!1)},[a,r]),c.useLayoutEffect(()=>{const G=w.current,me=h.current;if(!G||!me||a)return;w.current=null;const ge=me.scrollHeight-G.scrollHeight;if(ge<=0){g.current=me.scrollHeight,b.current=me.scrollTop;return}const we=G.scrollTop+ge;me.scrollTop=we,b.current=we,g.current=me.scrollHeight,v.current=!0,j.current=!1,L.current=!1},[a,r]),c.useEffect(()=>{D(G=>G>=r-1?r:Math.max(G,Cs))},[r]),c.useEffect(()=>{const G=h.current;G&&(g.current=G.scrollHeight,b.current=G.scrollTop,dr(G,1)?(v.current=!1,j.current=!0):(v.current||!dr(G,Un))&&(j.current=!1)),Q()},[oe,Q,F]),c.useEffect(()=>{const G=s!==m.current,me=f.current!==oe;if(f.current=oe,!(G||me&&j.current&&!v.current))return;const we=window.requestAnimationFrame(()=>{re()});return s!==m.current&&(m.current=s),()=>{window.cancelAnimationFrame(we)}},[oe,$,re,s]),c.useEffect(()=>{const G=h.current,me=u.current;if(!G||!me||typeof ResizeObserver>"u")return;g.current=G.scrollHeight;const ge=new ResizeObserver(()=>{const we=G.scrollHeight,_e=g.current;if(g.current=we,we<=_e)return;const Re=_e>0&&_e-G.scrollTop-G.clientHeight<=1;v.current||!(j.current||Re||k.current)||window.requestAnimationFrame(()=>{re()})});return ge.observe(me),()=>{ge.disconnect()}},[re]),c.useEffect(()=>{if(!j.current||v.current){p.current=l;return}if(l===p.current)return;p.current=l;const G=window.requestAnimationFrame(()=>{re()});return()=>{window.cancelAnimationFrame(G)}},[l,re]),c.useEffect(()=>{i==null||i($)},[$,i]),{scrollContainerRef:h,scrollContentRef:u,tailSentinelRef:x,topSentinelRef:y,isTailVisible:$,handleScroll:de,handleWheel:ve,handleTouchStart:Pe,handleTouchMove:se,handleTouchEnd:ye,preserveScrollPositionForResize:xe,serverManagedHistory:A,effectiveTotalTurnCount:J,startIndex:I,visibleTurnAbsoluteOffset:O,hiddenCount:C,loadedHiddenCount:U,unloadedHiddenCount:H,showLoadAll:E,handleLoadEarlierClick:ie,handleLoadAllClick:je}}function Of(e){return e==="completed"||e==="failed"||e==="interrupted"}function Uf(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 Wf({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,bottomSpacer:p=0,className:g="",onTailVisibilityChange:b,loadingEarlier:w=!1,onLoadEarlier:x,ephemeralUserNote:y=null,answeredRequestNotes:k=[],activityNotes:j=[],optimisticSteers:v=[],optimisticTurn:N=null,onLoadHistoryItemDetail:S,onOpenThread:L,onSelectArtifact:P,onSelectHistoryItemDetail:K,adapter:F,autoCollapseCompletedTurns:D}){var tt,z,V,fe,Le;const Z=el(),Y=D??(Z==null?void 0:Z.autoCollapseCompletedTurns)??!1,[$,te]=c.useState({}),[oe,A]=c.useState(()=>new Set),J=(F==null?void 0:F.onLoadHistoryItemDetail)??S,I=F==null?void 0:F.onOpenLinkedThread,{expandedText:q,openExpandedText:O,openCommandDetail:T,openToolCallDetail:U,openDeferredHistoryItemDetail:H,closeExpandedText:C}=Gf({loadHistoryItemDetail:J,onSelectHistoryItemDetail:K}),{scrollContainerRef:E,scrollContentRef:X,tailSentinelRef:W,topSentinelRef:le,handleScroll:Q,handleWheel:de,handleTouchStart:re,handleTouchMove:xe,handleTouchEnd:ie,preserveScrollPositionForResize:ve,serverManagedHistory:Pe,effectiveTotalTurnCount:se,startIndex:ye,visibleTurnAbsoluteOffset:je,hiddenCount:G,loadedHiddenCount:me,unloadedHiddenCount:ge,showLoadAll:we,handleLoadEarlierClick:_e,handleLoadAllClick:Re}=Hf({threadId:e,turnsLength:r.length,totalTurnCount:n,loadingEarlier:w,onLoadEarlier:x,scrollRequestKey:f,bottomSpacer:p,onTailVisibilityChange:b,contentRevisionInputs:[r,a,l,v,m,i,d,N,k,j,y,p]}),Ee=c.useCallback((ne,Ge)=>{te(He=>({...He,[ne]:!Ge}))},[]),Me=c.useCallback((ne,Ge)=>{const He=$[ne.id];return He!==void 0?He:!!(Y&&Of(ne.status)&&!Ge.forceActive&&!Ge.hasLiveActivity)},[$,Y]),_=Pe?r:r.slice(ye),ue=se+1,R=s&&(!o||!_.some(ne=>ne.id===o)&&(N==null?void 0:N.id)!==o),M=(N==null?void 0:N.id)??((tt=_.at(-1))==null?void 0:tt.id)??null,ee=R&&M!==null,pe=!!d&&(_.some(ne=>ne.id===d.turnId)||(N==null?void 0:N.id)===d.turnId),ke=d&&pe?d.turnId:d&&ee?M:null,Ae=N&&ke===N.id?(d==null?void 0:d.items)??null:null,Ne=((d==null?void 0:d.items.length)??0)>0,De=d&&ke===null?d.items:null,et=c.useMemo(()=>d&&ke===null&&d.items.length>0?Bf(d.turnId,d.items):null,[d,ke]),Ve=Math.max(1,se+(N?1:0)),ot=!!m&&!!N&&N.status!=="failed"&&!Ae,Qe=m&&_.length>0?o&&_.some(ne=>ne.id===o)?o:((z=_.findLast(ne=>ll(ne.status)))==null?void 0:z.id)??(ee?M:null):null,ut=!!Qe,at=c.useMemo(()=>ol(m),[m]),Oe=[...l.map(ne=>({id:ne.id,prompt:ne.prompt,status:"Accepted",createdAt:ne.createdAt,canCancel:!0})),...v.map(ne=>({id:ne.id,prompt:ne.prompt,status:ne.status==="steering"?"Steering":null,createdAt:ne.createdAt,canCancel:!1}))].sort((ne,Ge)=>ne.createdAt.localeCompare(Ge.createdAt)),Be=c.useMemo(()=>Ap({answeredRequestNotes:k,pendingRequests:a,visibleTurns:_,optimisticTurn:N}),[k,N,a,_]),Ue=c.useMemo(()=>_p({activityNotes:j,visibleTurns:_,optimisticTurn:N}),[j,N,_]);return t.jsxs(t.Fragment,{children:[t.jsx("section",{className:`flex min-h-0 flex-1 flex-col ${g}`.trim(),children:t.jsx("div",{ref:E,"data-testid":"thread-scroll-container",onScroll:Q,onWheel:de,onTouchStart:re,onTouchMove:xe,onTouchEnd:ie,onTouchCancel:ie,className:"thread-graph-scroll-container min-h-0 flex-1 overflow-y-auto overscroll-contain",style:p>0?{paddingBottom:p}:void 0,children:t.jsxs("div",{ref:X,className:"thread-graph-scroll-content",children:[t.jsx("div",{ref:le,"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:[G>0&&t.jsx("button",{type:"button",onClick:_e,disabled:w,className:"thread-graph-history-button rounded-full border px-2.5 py-1.5 transition",children:w?"Loading earlier...":"Load 3 earlier"}),we&&t.jsx("button",{type:"button",onClick:Re,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 ",_.length," of ",se," turns",G>0?` · ${G} earlier hidden${me>0&&ge>0?` (${me} loaded)`:""}`:""]})]})}),r.length===0&&!m&&!N&&t.jsx("div",{className:"thread-graph-empty-state px-3 py-8 text-sm sm:px-5",children:"Send the first prompt to start the thread."}),(_.length>0||N||Ue.leading.length>0||Ue.trailing.length>0)&&t.jsxs("div",{className:"thread-graph-message-list",children:[Ue.leading.length>0?t.jsx(ir,{notes:Ue.leading,onOpenThread:L,onOpenLinkedThread:I}):null,_.map((ne,Ge)=>{var He,Fe,qe,dt,xt;return t.jsxs("div",{children:[(((He=Ue.beforeTurnId.get(ne.id))==null?void 0:He.length)??0)>0?t.jsx(ir,{notes:Ue.beforeTurnId.get(ne.id)??[],onOpenThread:L,onOpenLinkedThread:I}):null,(((Fe=Be.beforeTurnId.get(ne.id))==null?void 0:Fe.length)??0)>0?t.jsx(Hn,{entries:Be.beforeTurnId.get(ne.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const lt=Uf(ne,N),wt=(i==null?void 0:i.turnId)===ne.id?i:null,yt=ke===ne.id?(d==null?void 0:d.items)??null:null,jt=Qe===ne.id?m:"",be=o===ne.id||ee&&M===ne.id,ze=!!wt||!!jt||!!(yt&&yt.length>0),rt=Me(lt,{forceActive:be,hasLiveActivity:ze});return t.jsx(bn,{threadId:e,...F?{adapter:F}:{},turn:lt,absoluteIndex:je+Ge+1,isCollapsed:rt,livePlan:wt,liveItems:yt,liveOutput:jt,forceActive:be,onToggleCollapse:Ee,onOpenExpandedText:O,onOpenCommandDetail:T,onOpenToolCallDetail:U,onOpenDeferredHistoryItemDetail:H,onBeforeMessageResize:ve,...P?{onSelectArtifact:P}:{},scrollRootRef:E,articleRef:void 0})})(),(((qe=Ue.afterTurnId.get(ne.id))==null?void 0:qe.length)??0)>0?t.jsx(ir,{notes:Ue.afterTurnId.get(ne.id)??[],onOpenThread:L,onOpenLinkedThread:I}):null,(dt=Be.notesByTurnId.get(ne.id))!=null&&dt.length||(xt=Be.pendingRequestsByTurnId.get(ne.id))!=null&&xt.length?t.jsx(Mp,{notes:Be.notesByTurnId.get(ne.id)??[],requests:Be.pendingRequestsByTurnId.get(ne.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null]},ne.id)}),N&&_.every(ne=>ne.id!==N.id)&&t.jsxs(t.Fragment,{children:[(((V=Ue.beforeTurnId.get(N.id))==null?void 0:V.length)??0)>0?t.jsx(ir,{notes:Ue.beforeTurnId.get(N.id)??[],onOpenThread:L,onOpenLinkedThread:I}):null,(((fe=Be.beforeTurnId.get(N.id))==null?void 0:fe.length)??0)>0?t.jsx(Hn,{entries:Be.beforeTurnId.get(N.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const ne=ot?m:"",Ge=o===N.id||ee&&M===N.id,He=!!(Ae&&Ae.length>0)||!!ne,Fe=Me(N,{forceActive:Ge,hasLiveActivity:He});return t.jsx(bn,{threadId:e,...F?{adapter:F}:{},turn:N,absoluteIndex:ue,isCollapsed:Fe,livePlan:null,liveItems:Ae,liveOutput:ne,forceActive:Ge,onToggleCollapse:Ee,onOpenExpandedText:O,onOpenCommandDetail:T,onOpenToolCallDetail:U,onOpenDeferredHistoryItemDetail:H,onBeforeMessageResize:ve,...P?{onSelectArtifact:P}:{},scrollRootRef:E})})(),(((Le=Ue.afterTurnId.get(N.id))==null?void 0:Le.length)??0)>0?t.jsx(ir,{notes:Ue.afterTurnId.get(N.id)??[],onOpenThread:L,onOpenLinkedThread:I}):null]})]}),Oe.length>0&&t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:Oe.map(ne=>t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Et,{threadId:e,item:{id:ne.id,kind:"userMessage",text:ne.prompt,status:ne.status},scrollRootRef:E,onBeforeMessageResize:ve,...F?{adapter:F}:{}}),e&&ne.canCancel&&(F!=null&&F.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:oe.has(ne.id),onClick:()=>{var Ge;A(He=>new Set(He).add(ne.id)),Promise.resolve((Ge=F.cancelPendingSteer)==null?void 0:Ge.call(F,e,ne.id)).catch(()=>{}).finally(()=>{A(He=>{const Fe=new Set(He);return Fe.delete(ne.id),Fe})})},children:oe.has(ne.id)?"Canceling...":"Cancel"})}):null]},ne.id))}),(Be.trailing.length>0||Ue.trailing.length>0)&&t.jsx($p,{entries:[...Ue.trailing.map(ne=>({kind:"activity",id:ne.id,createdAt:ne.createdAt,note:ne})),...Be.trailing],respondingRequestId:h,onRespondToRequest:u??void 0,onOpenThread:L,onOpenLinkedThread:I}),y&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:t.jsx(Et,{threadId:e,item:{id:"ephemeral-plan-decision-note",kind:"userMessage",text:y},scrollRootRef:E,onBeforeMessageResize:ve})}),et&&De&&De.length>0&&t.jsx(bn,{threadId:e,...F?{adapter:F}:{},turn:et,absoluteIndex:Ve,isCollapsed:$[et.id]??!1,livePlan:(i==null?void 0:i.turnId)===et.id?i:null,liveItems:De,liveOutput:"",forceActive:!0,onToggleCollapse:Ee,onOpenExpandedText:O,onOpenCommandDetail:T,onOpenToolCallDetail:U,onOpenDeferredHistoryItemDetail:H,onBeforeMessageResize:ve,...P?{onSelectArtifact:P}:{},scrollRootRef:E}),m&&!ut&&!ot&&!Ne&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:at?t.jsx(oa,{threadId:e,item:at,scrollRootRef:E,onOpenExpandedText:O,onOpenCommandDetail:T,onOpenToolCallDetail:U,onOpenDeferredHistoryItemDetail:H,onBeforeMessageResize:ve,...P?{onSelectArtifact:P}:{},...F?{adapter:F}:{}}):t.jsx(Et,{threadId:e,item:{id:"live-agent-message-fallback",kind:"agentMessage",text:m},scrollRootRef:E,streaming:!0,onBeforeMessageResize:ve,...F?{adapter:F}:{}})}),t.jsx("div",{ref:W,"aria-hidden":"true",className:"h-px w-full"})]})})}),t.jsx(Jm,{open:q!==null,title:(q==null?void 0:q.title)??"Full text",text:(q==null?void 0:q.text)??"",onClose:C})]})}var xl=c.memo(Wf);function Vf(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}function Wn(e){return e.replace(/\r\n/g,`
3669
+ `)}function Ts(e){const r=Wn(e),n=r.split(`
3670
3670
  `);return r.endsWith(`
3671
- `)&&n.at(-1)===""&&n.pop(),n}function Kf(e){const r=e.trim();return r?/(?:[$%#>])\s*$/.test(r):!1}function qf(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 Xf(e,r,n){var d,h;const a=Ts(e),s=Ts(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=qf(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())===""||Kf(i.at(-1)??""));)i.pop();return i.join(`
3672
- `).trimEnd()}function Yf(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 Es(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 kn(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 tn(e){if(!e)return"";const r=e.replace(/[\\/]+$/,"");return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function la(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 wn(e){return Math.min(75,Math.max(25,e))}function Zf(){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 Jf({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 Ls(){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 yn({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 Qf=120,eg=800,tg=4e3,rg=4500,ng="Shell connection timed out. Reconnecting...";function ag({isCurrentSocket:e,viewerId:r}){return!e||r?null:{connectionError:ng,isConnecting:!1,settleAttachPromise:!1,closeSocket:!0}}function sg({isCurrentSocket:e,shellId:r,attachSize:n}){return e?{message:{type:"shell.attach",shellId:r,cols:n.cols,rows:n.rows},shouldScheduleAttachTimeout:!0}:null}function og({intentionalDisconnect:e,userDisconnectedShellId:r,shellId:n}){return!e&&r!==n}function lg({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:s}){return e?{shouldDetachShell:r,shouldScheduleReconnect:og({intentionalDisconnect:n,userDisconnectedShellId:a,shellId:s})}:null}function ig({hasAttachSize:e,hasPendingRetry:r}){return!e&&!r}function bl({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}:ig({hasAttachSize:!1,hasPendingRetry:i})?{type:"scheduleRetry"}:{type:"skip"}}function dg({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 cg({shellId:e,userDisconnectedShellId:r}){return{shouldClearUserDisconnectedShellId:!!e&&r===e,intentionalDisconnect:!1,connectionError:null,isConnecting:!0,shouldIncrementReconnectKey:!0}}function hg({hasShell:e}){return e?null:{viewerId:null,isConnecting:!1,settleAttachPromise:!1,connectionError:null,runtimePromptLabel:null,isCommandRunning:!1,shellSnapshot:"",lastCommandOutput:"",pendingCommand:null,shouldResetTerminal:!0}}function ug({hasReconnectTimer:e,hasAttachTimeout:r,hasAttachRetry:n}){return{shouldClearReconnectTimer:e,shouldClearAttachTimeout:r,shouldClearAttachRetry:n,settleAttachPromise:!1}}function vl({shellId:e,viewerId:r}){return e&&r?{type:"shell.detach",shellId:e,viewerId:r}:null}function mg({shellId:e,viewerId:r,hasSocket:n}){return{userDisconnectedShellId:e,intentionalDisconnect:!0,detachMessage:vl({shellId:e,viewerId:r}),shouldCloseSocket:n,shouldClearSocketRef:!0,shouldClearLastSentSize:!0,shouldDetachShell:!!e}}function pg({shellId:e,viewerId:r,socketReadyState:n,openReadyState:a,hasAttachRetryTimer:s,hasAttachTimeout:o,isCurrentSocket:l}){const i=vl({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 fg({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 gg(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:la(n??tn(r),a),isCommandRunning:e.isCommandRunning===!0}}function xg({currentSnapshot:e,data:r,replace:n,isCommandRunning:a,pendingCommand:s}){if(!r)return{nextSnapshot:e,nextPendingCommand:s,lastCommandOutput:null};const o=Vn(n?r:`${e}${r}`);return!n||a||!s?{nextSnapshot:o,nextPendingCommand:s,lastCommandOutput:null}:{nextSnapshot:o,nextPendingCommand:null,lastCommandOutput:Xf(s.beforeSnapshot,o,s.command)}}function bg({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 kl(e,r,n,a,s){const o=r.replace(/\r\n/g,`
3673
- `),l=o.split(`
3674
- `);o.endsWith(`
3671
+ `)&&n.at(-1)===""&&n.pop(),n}function Kf(e){const r=e.trim();return r?/(?:[$%#>])\s*$/.test(r):!1}function qf(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 Xf(e,r,n){var d,h;const a=Ts(e),o=Ts(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=qf(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())===""||Kf(i.at(-1)??""));)i.pop();return i.join(`
3672
+ `).trimEnd()}function Yf(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 Es(e){return{background:e==="light"?"#f2ede5":"#0c1117",foreground:e==="light"?"#3f3a36":"#d6dde6",cursor:e==="light"?"#3f3a36":"#d6dde6",black:e==="light"?"#d8cfc2":"#0f1720",brightBlack:e==="light"?"#8a7f73":"#475569",red:"#f87171",brightRed:"#fb7185",green:e==="light"?"#16a34a":"#86efac",brightGreen:e==="light"?"#22c55e":"#4ade80",yellow:"#fbbf24",brightYellow:"#fcd34d",blue:e==="light"?"#2563eb":"#93c5fd",brightBlue:e==="light"?"#3b82f6":"#60a5fa",magenta:e==="light"?"#7c3aed":"#c4b5fd",brightMagenta:e==="light"?"#8b5cf6":"#a78bfa",cyan:e==="light"?"#0891b2":"#67e8f9",brightCyan:e==="light"?"#06b6d4":"#22d3ee",white:e==="light"?"#5b5148":"#e2e8f0",brightWhite:e==="light"?"#2c2723":"#f8fafc"}}function vn(e){switch(e){case"not_created":return"Not created";case"creating":return"Creating";case"running":return"Running";case"attached":return"Attached";case"detached":return"Detached";case"exited":return"Exited";case"not_found":return"Missing";case"workspace_missing":return"Workspace missing"}}function en(e){if(!e)return"";const r=e.replace(/[\\/]+$/,"");return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function la(e,r){const n=[r==null?void 0:r.trim(),e==null?void 0:e.trim()].filter(Boolean);return n.length>0?n.join(" "):null}function kn(e){return Math.min(75,Math.max(25,e))}function Zf(){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 Jf({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 Ls(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5.5 3.25h5"}),t.jsx("path",{d:"M6.4 2h3.2a.9.9 0 0 1 .9.9v.35h1.3a1.2 1.2 0 0 1 1.2 1.2v7.35a1.2 1.2 0 0 1-1.2 1.2H4.2A1.2 1.2 0 0 1 3 11.8V4.45a1.2 1.2 0 0 1 1.2-1.2h1.3V2.9a.9.9 0 0 1 .9-.9Z"})]})}function wn({label:e,tone:r="stone"}){const n=r==="rose"?"border-rose-300/35 bg-rose-300/14 text-rose-600 dark:text-rose-50":r==="sky"?"border-sky-300/35 bg-sky-300/14 text-sky-600 dark:text-sky-50":"shell-control-chip border";return t.jsx("span",{className:`inline-flex min-w-[3.45rem] items-center justify-center rounded-full border px-2.5 py-1.5 text-[11px] font-medium tracking-[0.12em] ${n}`,children:e})}var Qf=120,eg=800,tg=4e3,rg=4500,ng="Shell connection timed out. Reconnecting...";function ag({isCurrentSocket:e,viewerId:r}){return!e||r?null:{connectionError:ng,isConnecting:!1,settleAttachPromise:!1,closeSocket:!0}}function sg({isCurrentSocket:e,shellId:r,attachSize:n}){return e?{message:{type:"shell.attach",shellId:r,cols:n.cols,rows:n.rows},shouldScheduleAttachTimeout:!0}:null}function og({intentionalDisconnect:e,userDisconnectedShellId:r,shellId:n}){return!e&&r!==n}function lg({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:o}){return e?{shouldDetachShell:r,shouldScheduleReconnect:og({intentionalDisconnect:n,userDisconnectedShellId:a,shellId:o})}:null}function ig({hasAttachSize:e,hasPendingRetry:r}){return!e&&!r}function bl({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}:ig({hasAttachSize:!1,hasPendingRetry:i})?{type:"scheduleRetry"}:{type:"skip"}}function dg({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 cg({shellId:e,userDisconnectedShellId:r}){return{shouldClearUserDisconnectedShellId:!!e&&r===e,intentionalDisconnect:!1,connectionError:null,isConnecting:!0,shouldIncrementReconnectKey:!0}}function hg({hasShell:e}){return e?null:{viewerId:null,isConnecting:!1,settleAttachPromise:!1,connectionError:null,runtimePromptLabel:null,isCommandRunning:!1,shellSnapshot:"",lastCommandOutput:"",pendingCommand:null,shouldResetTerminal:!0}}function ug({hasReconnectTimer:e,hasAttachTimeout:r,hasAttachRetry:n}){return{shouldClearReconnectTimer:e,shouldClearAttachTimeout:r,shouldClearAttachRetry:n,settleAttachPromise:!1}}function vl({shellId:e,viewerId:r}){return e&&r?{type:"shell.detach",shellId:e,viewerId:r}:null}function mg({shellId:e,viewerId:r,hasSocket:n}){return{userDisconnectedShellId:e,intentionalDisconnect:!0,detachMessage:vl({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=vl({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 fg({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 gg(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:la(n??en(r),a),isCommandRunning:e.isCommandRunning===!0}}function xg({currentSnapshot:e,data:r,replace:n,isCommandRunning:a,pendingCommand:o}){if(!r)return{nextSnapshot:e,nextPendingCommand:o,lastCommandOutput:null};const s=Wn(n?r:`${e}${r}`);return!n||a||!o?{nextSnapshot:s,nextPendingCommand:o,lastCommandOutput:null}:{nextSnapshot:s,nextPendingCommand:null,lastCommandOutput:Xf(o.beforeSnapshot,s,o.command)}}function bg({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 kl(e,r,n,a,o){const s=r.replace(/\r\n/g,`
3673
+ `),l=s.split(`
3674
+ `);s.endsWith(`
3675
3675
  `)&&l.at(-1)===""&&l.pop();let d=l.join(`\r
3676
- `);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 Ps(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(`
3677
- `).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 zs={status:"not_created",shellInputEnabled:!1,isConnecting:!1,isCommandRunning:!1,promptLabel:null,error:null,hasShell:!1};function pt(e){return e.status!=="exited"&&e.status!=="not_found"}function kg({shell:e,workspacePathMissing:r}){return!!(e&&!r&&pt(e))}function wg(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 yg(e){return(e.activeShellId?e.shells.find(r=>r.id===e.activeShellId&&pt(r)):null)??(e.shell&&pt(e.shell)?e.shell:null)??e.shells.find(pt)??null}function jg({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&&!pt(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&&!pt(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 Ng({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?la(tn(r.cwd),null):null),isMobileShell:s,hasShell:!!r,busy:o,loading:l,error:e.error??i}}function Dt(e){return e.current===null?!1:(window.clearTimeout(e.current),e.current=null,!0)}function Cg({attachRetryTimerRef:e,setReconnectKey:r,delayMs:n=Qf}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function Sg({reconnectTimerRef:e,setReconnectKey:r,delayMs:n=eg}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function Tg({shellSocket:e,socketRef:r,viewerIdRef:n,attachTimeoutRef:a,setConnectionError:s,setIsConnecting:o,settleAttachPromise:l,delayMs:i=tg}){a.current=window.setTimeout(()=>{var h,u,m;a.current=null;const d=ag({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 Eg(e){return{...e,status:e.status==="attached"?"detached":e.status,attachedViewerId:null}}function Lg({shellId:e,viewerId:r,shellSocket:n,attachRetryTimerRef:a,attachTimeoutRef:s,socketRef:o,openReadyState:l}){var i;return pg({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 Pg({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&&Dt(n),e.shouldClearSocketRef&&(a.current=null),o(e.viewerId),l(e.isConnecting),i(e.settleAttachPromise),u.shouldDetachShell&&d(r,Eg,"detached"),u.shouldScheduleReconnect&&Sg({reconnectTimerRef:s,setReconnectKey:h}),!0):!1}function zg({cleanupAction:e,shellSocket:r,attachRetryTimerRef:n,attachTimeoutRef:a,socketRef:s,intentionalDisconnectRef:o,setViewerId:l,setIsConnecting:i,settleAttachPromise:d}){o.current=e.intentionalDisconnect,e.shouldClearAttachRetry&&Dt(n),e.shouldSendDetachMessage&&e.detachMessage&&r.send(e.detachMessage),l(null),i(e.isConnecting),e.settleAttachPromise!==void 0&&d(e.settleAttachPromise),e.shouldClearAttachTimeout&&Dt(a),r.socket.close(),e.shouldClearSocketRef&&(s.current=null)}function Ig({eventShellId:e,shellId:r,socketExists:n,isCurrentSocket:a}){return n&&!a?!1:e===r}function Rg(e){return bl({...e,attachSize:void 0})}function Ag({attachSize:e,...r}){return bl({...r,attachSize:e})}function _g({isCurrentSocket:e,shellId:r,attachSize:n,hasAttachTimeout:a}){const s=sg({isCurrentSocket:e,shellId:r,attachSize:n});return{openAction:s,shouldClearAttachTimeout:!!(s&&a)}}function Mg(e){const r=String(e.payload.viewerId??"");return{viewerId:r||null,settleAttachPromise:!!r,nextShell:n=>({...n,status:"attached",attachedViewerId:r})}}function $g({event:e,shellCwd:r,currentSnapshot:n,pendingCommand:a}){const s=gg(e.payload,r),o=s.data?xg({currentSnapshot:n,data:s.data,replace:s.replace,isCommandRunning:s.isCommandRunning,pendingCommand:a}):null;return{output:s,snapshotUpdate:o}}function Dg({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:s,hasAttachTimeout:o}){const l=lg({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 Bg(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 Gg(e){return e.current}function Fg({shell:e,shellAdapter:r,canAttachShell:n,terminalReady:a,reconnectKey:s,terminalRef:o,socketRef:l,viewerIdRef:i,shellIdRef:d,reconnectTimerRef:h,attachTimeoutRef:u,attachRetryTimerRef:m,isVisibleRef:f,intentionalDisconnectRef:p,userDisconnectedShellIdRef:g,shellSnapshotRef:b,pendingCommandRef:v,lastCommandOutputRef:x,snapshotCursorRef:y,syncTerminalSizeRef:k,setReconnectKey:C,setViewerId:w,setIsConnecting:j,setConnectionError:S,setRuntimePromptLabel:L,setIsCommandRunning:P,settleAttachPromise:K,onShellUpdate:F}){const R=e==null?void 0:e.id,J=e==null?void 0:e.cwd;c.useEffect(()=>{const Z=o.current,D={shellId:R??null,terminalReady:a,isVisible:f.current,canAttachShell:n,userDisconnectedShellId:g.current,hasTerminal:!!Z,hasPendingAttachRetry:m.current!==null,hasCurrentSocketForShell:!!(l.current&&d.current===R),hasReconnectTimer:h.current!==null};if(Rg(D).type==="skip")return;const oe=k.current(),_=Ag({...D,attachSize:oe});if(_.type==="skip"||_.type==="measureSize")return;if(_.type==="scheduleRetry"){Cg({attachRetryTimerRef:m,setReconnectKey:C});return}if(_.shouldClearAttachRetry&&Dt(m),_.type==="reuseSocket"||(_.shouldClearReconnectTimer&&Dt(h),!R||!Z))return;const Y=_.attachSize;d.current=R,Z.reset(),S(null),w(null),j(!0),p.current=!1;const I=r.connectSocket({onConnected:()=>{var W;const q=u.current,H=_g({isCurrentSocket:((W=l.current)==null?void 0:W.socket)===I.socket,shellId:R,attachSize:Y,hasAttachTimeout:q!==null}),E=H.openAction;E&&(I.send(E.message),H.shouldClearAttachTimeout&&q!==null&&Dt(u),E.shouldScheduleAttachTimeout&&Tg({shellSocket:I,socketRef:l,viewerIdRef:i,attachTimeoutRef:u,setConnectionError:S,setIsConnecting:j,settleAttachPromise:K}))},onShellEvent:q=>{var W;if(!Ig({eventShellId:q.shellId,shellId:R,socketExists:!!I.socket,isCurrentSocket:((W=l.current)==null?void 0:W.socket)===I.socket}))return;if(q.type==="shell.connected"){Dt(u);const O=Mg(q);w(O.viewerId),j(!1),K(O.settleAttachPromise),F(R,O.nextShell,"attached");return}if(q.type==="shell.output"){const{output:O,snapshotUpdate:N}=$g({event:q,shellCwd:J,currentSnapshot:b.current,pendingCommand:v.current});y.current={cursorX:O.cursorX,cursorY:O.cursorY,paneHeight:O.paneHeight},L(O.promptLabel),P(O.isCommandRunning),N&&(b.current=N.nextSnapshot,v.current=N.nextPendingCommand,N.lastCommandOutput!==null&&(x.current=N.lastCommandOutput),O.replace?kl(Z,O.data,O.cursorX,O.cursorY,O.paneHeight):Z.write(O.data));return}const E=bg({event:q,currentViewerId:i.current});E&&(E.viewerId!==void 0&&w(E.viewerId),E.isConnecting!==void 0&&j(E.isConnecting),E.settleAttachPromise!==void 0&&K(E.settleAttachPromise),E.isCommandRunning!==void 0&&P(E.isCommandRunning),E.connectionError!==void 0&&S(E.connectionError),E.intentionalDisconnect!==void 0&&(p.current=E.intentionalDisconnect),E.shellUpdate&&F(R,O=>Bg(O,E),E.shellUpdate.status),E.closeSocket&&I.socket.close())}});return l.current=I,I.socket.addEventListener("close",()=>{var E;const q=u.current,H=Dg({isCurrentSocket:((E=l.current)==null?void 0:E.socket)===I.socket,hadViewer:!!i.current,intentionalDisconnect:p.current,userDisconnectedShellId:g.current,shellId:R,hasAttachTimeout:q!==null});Pg({closeApplication:H,shellId:R,attachTimeoutRef:u,socketRef:l,reconnectTimerRef:h,setViewerId:w,setIsConnecting:j,settleAttachPromise:K,onShellUpdate:F,setReconnectKey:C})}),()=>{const q=Gg(i),H=Lg({shellId:R,viewerId:q,shellSocket:I,attachRetryTimerRef:m,attachTimeoutRef:u,socketRef:l,openReadyState:WebSocket.OPEN});zg({cleanupAction:H,shellSocket:I,attachRetryTimerRef:m,attachTimeoutRef:u,socketRef:l,intentionalDisconnectRef:p,setViewerId:w,setIsConnecting:j,settleAttachPromise:K})}},[m,u,n,p,f,x,F,v,s,h,S,P,j,C,L,w,K,J,R,r,d,b,y,l,k,a,o,g,i])}function jn(e){return e.current}var Is=c.forwardRef(function({paneId:r,shell:n,isActive:a,isVisible:s,isMobileShell:o,effectiveTheme:l,workspacePathMissing:i,shellAdapter:d,onActivate:h,onShellUpdate:u,onRuntimeStateChange:m,onFeedback:f},p){const g=c.useRef(null),b=c.useRef(null),v=c.useRef(null),x=c.useRef(null),y=c.useRef(null),k=c.useRef(null),C=c.useRef(null),w=c.useRef(null),j=c.useRef(!1),S=c.useRef(null),L=c.useRef(""),P=c.useRef(null),K=c.useRef(""),F=c.useRef(null),R=c.useRef(null),J=c.useRef({cursorX:void 0,cursorY:void 0,paneHeight:void 0}),Z=c.useRef(!1),D=c.useRef(null),te=c.useRef(s),oe=c.useRef(o),_=c.useRef(()=>!1),Y=c.useRef(()=>null),I=c.useRef(()=>{}),q=c.useRef(vg({clearTimeout:window.clearTimeout})),[H,E]=c.useState(null),[W,O]=c.useState(!1),[N,T]=c.useState(null),[U,X]=c.useState(!1),[ie,Q]=c.useState(null),[de,re]=c.useState(null),[xe,le]=c.useState(!1),[ve,Pe]=c.useState(0),se=(n==null?void 0:n.status)??"not_created",ye=kg({shell:n,workspacePathMissing:i}),je=c.useMemo(()=>la(tn(n==null?void 0:n.cwd),null),[n==null?void 0:n.cwd]),G=de??je,me=c.useCallback(M=>{x.current=M,T(M)},[]),ge=c.useCallback(M=>{q.current.settle(M)},[]);c.useEffect(()=>{te.current=s},[s]),c.useEffect(()=>{oe.current=o},[o]),c.useEffect(()=>{y.current=(n==null?void 0:n.id)??null},[n==null?void 0:n.id]);const we=c.useCallback(M=>{const ue=v.current,A=y.current,$=x.current;return!ue||!A||!$?!1:(ue.send({type:"shell.input",shellId:A,viewerId:$,data:M}),!0)},[]);c.useEffect(()=>{_.current=we},[we]);const _e=c.useCallback(()=>{const M=v.current,ue=y.current,A=x.current;return!M||!ue||!A?!1:(M.send({type:"shell.clear",shellId:ue,viewerId:A}),!0)},[]),Re=c.useCallback(()=>{if(!s||!H)return!1;const M=H.getBoundingClientRect();return M.width>0&&M.height>0},[s,H]),Ee=c.useCallback(M=>{const ue=g.current,A=b.current;if(!ue||!A||!Re()||(A.fit(),ue.cols<=0||ue.rows<=0))return null;const $={cols:ue.cols,rows:ue.rows},ee=fg({size:$,previousSize:R.current,shellId:y.current,viewerId:x.current,syncBackendSize:(M==null?void 0:M.syncBackendSize)!==!1});return(M==null?void 0:M.syncBackendSize)===!1||(R.current=ee.nextLastSentSize,!ee.message)||v.current&&v.current.send(ee.message),$},[Re]);c.useEffect(()=>{Y.current=Ee},[Ee]);const Me=c.useCallback(M=>{const ue=g.current;!ue||!Re()||(Ee((M==null?void 0:M.syncBackendSize)===void 0?void 0:{syncBackendSize:M.syncBackendSize}),L.current&&!Ps(H)?kl(ue,L.current,J.current.cursorX,J.current.cursorY,J.current.paneHeight):ue.scrollToBottom(),M!=null&&M.focus&&!o&&ue.focus())},[o,Re,Ee,H]);return c.useEffect(()=>{I.current=()=>Me()},[Me]),c.useEffect(()=>{m({status:N?"attached":se,shellInputEnabled:!!(N&&n),isConnecting:U,isCommandRunning:xe,promptLabel:G,error:ie,hasShell:!!n})},[ie,U,xe,m,G,n,se,N]),c.useEffect(()=>{if(!H||g.current||Z.current)return;let M=!1;return Z.current=!0,(async()=>{const[{Terminal:ue},{FitAddon:A}]=await Promise.all([Ke(()=>import("./terminal-vendor-B365Go3Z.js").then(pe=>pe.x),__vite__mapDeps([6,2,7])),Ke(()=>import("./terminal-vendor-B365Go3Z.js").then(pe=>pe.a),__vite__mapDeps([6,2,7]))]);if(M||!H){Z.current=!1;return}const $=new ue({cursorBlink:!0,disableStdin:oe.current,fontFamily:"IBM Plex Mono, SFMono-Regular, Menlo, monospace",fontSize:13,lineHeight:1.25,scrollback:3e3,theme:Es(l)}),ee=new A;$.loadAddon(ee),$.open(H),g.current=$,b.current=ee,Y.current(),$.attachCustomKeyEventHandler(pe=>{if(oe.current||pe.type!=="keydown")return!0;if(pe.ctrlKey&&!pe.altKey&&!pe.metaKey&&!pe.shiftKey){const ke=Vf(pe.key);if(!ke)return!0;if(_.current(ke))return pe.preventDefault(),!1}return!0}),O(!0),Z.current=!1,F.current=new ResizeObserver(()=>{I.current()}),F.current.observe(H),D.current=$.onData(pe=>{oe.current||_.current(pe)})})(),()=>{var ue,A,$;M=!0,Z.current=!1,(ue=D.current)==null||ue.dispose(),D.current=null,(A=F.current)==null||A.disconnect(),F.current=null,O(!1),($=g.current)==null||$.dispose(),g.current=null,b.current=null,R.current=null}},[l,H]),c.useEffect(()=>{var ue;const M=hg({hasShell:!!n});M&&(me(M.viewerId),X(M.isConnecting),ge(M.settleAttachPromise),Q(M.connectionError),re(M.runtimePromptLabel),le(M.isCommandRunning),L.current=M.shellSnapshot,K.current=M.lastCommandOutput,P.current=M.pendingCommand,M.shouldResetTerminal&&((ue=g.current)==null||ue.reset()))},[me,ge,n]),c.useEffect(()=>{const M=g.current;M&&(M.options.theme=Es(l))},[l]),c.useEffect(()=>{const M=g.current;M&&(M.options.disableStdin=o)},[o]),c.useEffect(()=>{if(!s||!W)return;const M=window.requestAnimationFrame(()=>{Me({focus:a,syncBackendSize:!1}),!v.current&&(n!=null&&n.id)&&S.current!==n.id&&Pe(ue=>ue+1)});return()=>{window.cancelAnimationFrame(M)}},[a,s,Me,n==null?void 0:n.id,W]),Fg({shell:n,shellAdapter:d,canAttachShell:ye,terminalReady:W,reconnectKey:ve,terminalRef:g,socketRef:v,viewerIdRef:x,shellIdRef:y,reconnectTimerRef:k,attachTimeoutRef:C,attachRetryTimerRef:w,isVisibleRef:te,intentionalDisconnectRef:j,userDisconnectedShellIdRef:S,shellSnapshotRef:L,pendingCommandRef:P,lastCommandOutputRef:K,snapshotCursorRef:J,syncTerminalSizeRef:Y,setReconnectKey:Pe,setViewerId:me,setIsConnecting:X,setConnectionError:Q,setRuntimePromptLabel:re,setIsCommandRunning:le,settleAttachPromise:ge,onShellUpdate:u}),c.useEffect(()=>()=>{const M=jn(k),ue=jn(C),A=jn(w),$=ug({hasReconnectTimer:M!==null,hasAttachTimeout:ue!==null,hasAttachRetry:A!==null});$.shouldClearReconnectTimer&&M!==null&&window.clearTimeout(M),$.shouldClearAttachTimeout&&ue!==null&&window.clearTimeout(ue),$.shouldClearAttachRetry&&A!==null&&window.clearTimeout(A),ge($.settleAttachPromise)},[ge]),c.useImperativeHandle(p,()=>({disconnect(){const M=v.current,ue=y.current,A=x.current,$=mg({shellId:ue,viewerId:A,hasSocket:!!M});S.current=$.userDisconnectedShellId,j.current=$.intentionalDisconnect,M&&$.detachMessage&&M.send($.detachMessage),me(null),X(!1),ge(!1),$.shouldCloseSocket&&(M==null||M.socket.close()),v.current=null,R.current=null,$.shouldDetachShell&&ue&&u(ue,ee=>({...ee,status:"detached",attachedViewerId:null}),"detached")},reconnect(){const M=dg({hasShellId:!!y.current,terminalReady:W,workspacePathMissing:i,hasViewer:!!x.current,hasPendingAttach:q.current.hasPending()});if(M.type==="reject")return Promise.resolve(!1);if(M.type==="alreadyConnected")return Promise.resolve(!0);if(M.type==="joinPending")return q.current.joinPending();const ue=q.current.start({timeoutMs:rg,setTimeout:window.setTimeout,onTimeout:()=>{X(!1)}}),A=cg({shellId:y.current,userDisconnectedShellId:S.current});return A.shouldClearUserDisconnectedShellId&&(S.current=null),j.current=A.intentionalDisconnect,Q(A.connectionError),X(A.isConnecting),Pe($=>$+1),ue},sendInput(M){return we(M)},sendCommand(M){const ue={command:M,beforeSnapshot:L.current};if(P.current=ue,M.trim()==="clear"){const ee=_e();return!ee&&P.current===ue&&(P.current=null),ee}const A=M.endsWith(`
3678
- `)?M:`${M}
3679
- `,$=we(A);return!$&&P.current===ue&&(P.current=null),$},sendControl(M){return M==="clear"?_e():we(Yf(M))},async copyLastCommandOutput(){const M=K.current.trim()||Ps(H);if(!M)return f==null||f("failed","Nothing to copy"),!1;try{return await navigator.clipboard.writeText(M),f==null||f("done","Copied"),!0}catch{return f==null||f("failed","Copy failed"),!1}},focus(){var M;(M=g.current)==null||M.focus()},refreshLayout(M){Me(M)}}),[f,u,Me,_e,we,me,ge,H,W,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:E,className:`h-full w-full px-2 py-2 sm:px-3 sm:py-3 ${o?"mobile-shell-selectable":""}`,onMouseDown:()=>{var M;h(),(M=g.current)==null||M.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"})]})}),Hg=c.forwardRef(function({threadId:r,shellAdapter:n,isVisible:a=!0,showHeader:s=!0,showFloatingToolbox:o=!0,effectiveTheme:l="dark",loadSplitRatio:i,saveSplitRatio:d,onStateChange:h},u){const m=c.useRef(null),f=c.useRef(null),p=c.useRef(null),g=c.useRef(null),b=c.useRef(null),v=c.useRef(!1),[x,y]=c.useState(null),[k,C]=c.useState(!0),[w,j]=c.useState(!1),[S,L]=c.useState(null),[P,K]=c.useState("primary"),[F,R]=c.useState(null),[J,Z]=c.useState(null),[D,te]=c.useState("single"),[oe,_]=c.useState(50),[Y,I]=c.useState(null),[q,H]=c.useState(""),[E,W]=c.useState(!1),[O,N]=c.useState(!1),[T,U]=c.useState(!1),[X,ie]=c.useState({primary:zs,secondary:zs}),[Q,de]=c.useState(null),re=(x==null?void 0:x.state)??"not_created",xe=c.useMemo(()=>(x==null?void 0:x.shells)??[],[x==null?void 0:x.shells]),le=c.useMemo(()=>xe.filter(pt),[xe]),ve=c.useMemo(()=>le.find(z=>z.id===F)??null,[le,F]),Pe=c.useMemo(()=>le.find(z=>z.id===J)??null,[le,J]),se=P==="secondary"?Pe:ve,ye=X[P],je=(x==null?void 0:x.workspacePathStatus)==="missing",G=P==="secondary"?f:m,me=jg({activeRuntime:ye,activeShell:se,busy:w,loading:k,status:re,workspacePathMissing:je}),ge=me.disabled,we=me.label,_e=me.className,Re=(Q==null?void 0:Q.tone)==="done"?"shell-floating-feedback shell-floating-feedback-done":(Q==null?void 0:Q.tone)==="failed"?"shell-floating-feedback shell-floating-feedback-failed":"shell-floating-feedback",Ee=c.useCallback((z,V)=>{de({tone:z,text:V}),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{de(null),p.current=null},1800)},[]),Me=c.useCallback((z,V,fe)=>{y(Le=>{var He;if(!Le)return Le;const ne=Le.shells.map(Fe=>Fe.id===z?V(Fe):Fe),Ge=((He=Le.shell)==null?void 0:He.id)===z?V(Le.shell):ne.find(Fe=>{var qe;return Fe.id===((qe=Le.shell)==null?void 0:qe.id)})??Le.shell;return{...Le,...fe?{state:fe}:{},shell:Ge,shells:ne}})},[]),M=c.useCallback(async()=>{C(!0);try{const z=await n.fetchState(r);y(z),L(null)}catch(z){L(z instanceof Error?z.message:"Unable to load shell state.")}finally{C(!1)}},[n,r]);c.useEffect(()=>{M()},[M]),c.useEffect(()=>{const z=i==null?void 0:i(r);if(z==null){_(50);return}const V=typeof z=="number"?z:Number.parseFloat(String(z));_(Number.isFinite(V)?wn(V):50)},[i,r]),c.useEffect(()=>{if(!x){R(null),Z(null);return}const z=yg(x);R(V=>V&&x.shells.some(fe=>fe.id===V&&pt(fe))?V:(z==null?void 0:z.id)??null),Z(V=>{if(D!=="columns")return null;if(V&&x.shells.some(Le=>Le.id===V&&pt(Le)))return V;const fe=x.shells.find(Le=>pt(Le)&&Le.id!==(z==null?void 0:z.id));return(fe==null?void 0:fe.id)??null})},[x,D]),c.useEffect(()=>{D!=="columns"&&(K("primary"),Z(null))},[D]),c.useEffect(()=>{if(D!=="columns"||J||le.length<2)return;const z=le.find(V=>V.id!==(ve==null?void 0:ve.id))??null;z&&Z(z.id)},[le,ve==null?void 0:ve.id,J,D]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const z=window.matchMedia("(max-width: 767px), (hover: none) and (pointer: coarse)"),V=()=>{W(z.matches),z.matches||(U(!1),N(!1))};return V(),z.addEventListener("change",V),()=>{z.removeEventListener("change",V)}},[]),c.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current),b.current!==null&&window.cancelAnimationFrame(b.current)},[]);const ue=c.useCallback((z,V)=>{ie(fe=>{const Le=fe[z];return wg(Le,V)?fe:{...fe,[z]:V}})},[]),A=c.useCallback(z=>ue("primary",z),[ue]),$=c.useCallback(z=>ue("secondary",z),[ue]),ee=c.useCallback(z=>{var fe;if((fe=z.label)!=null&&fe.trim())return z.label.trim();const V=xe.findIndex(Le=>Le.id===z.id);return`Shell ${V>=0?V+1:""}`.trim()},[xe]),pe=c.useCallback(z=>{var V;I(z.id),H(((V=z.label)==null?void 0:V.trim())||ee(z))},[ee]),ke=c.useCallback(()=>{I(null),H("")},[]),Ae=c.useCallback(async()=>{if(Y){j(!0);try{const z=q.trim(),V=await n.updateShell(Y,{label:z.length>0?z:null});y(fe=>{var Le;return fe&&{...fe,state:fe.activeShellId===V.id?V.status:fe.state,shell:((Le=fe.shell)==null?void 0:Le.id)===V.id?V:fe.shell,shells:fe.shells.map(ne=>ne.id===V.id?V:ne)}}),I(null),H(""),L(null)}catch(z){L(z instanceof Error?z.message:"Unable to rename shell.")}finally{j(!1)}}},[q,Y,n]),Ne=c.useCallback((z,V)=>{if(z==="primary"){R(V),Z(fe=>fe===V?null:fe);return}Z(V),R(fe=>fe===V?null:fe)},[]),De=c.useCallback(z=>{var V,fe;if(z==="primary"){(V=m.current)==null||V.disconnect(),R(null),D==="columns"&&K("secondary");return}(fe=f.current)==null||fe.disconnect(),Z(null),K("primary"),te("single")},[D]),et=c.useCallback((z,V=P)=>{const fe=D==="columns"?V:"primary";Ne(fe,z.id),D!=="columns"&&Z(null),K(fe)},[P,Ne,D]),Ve=c.useCallback(async(z=P)=>{var V;if(!v.current){v.current=!0,j(!0);try{const fe=await n.createShell(r);y(fe);const Le=fe.activeShellId??((V=fe.shell)==null?void 0:V.id)??null;if(Le){const ne=D==="columns"?z:"primary";Ne(ne,Le),D!=="columns"&&Z(null),K(ne)}L(null)}catch(fe){L(fe instanceof Error?fe.message:"Unable to create shell.")}finally{v.current=!1,j(!1)}}},[P,Ne,n,D,r]);c.useEffect(()=>{!a||!x||k||w||je||re==="creating"||le.length>0||Ve("primary")},[w,Ve,a,le.length,k,x,re,je]);const ot=c.useCallback(async(z=(se==null?void 0:se.id)??"")=>{if(z){j(!0);try{await n.terminateShell(z),R(V=>V===z?null:V),Z(V=>V===z?null:V),await M(),L(null)}catch(V){L(V instanceof Error?V.message:"Unable to terminate shell.")}finally{j(!1)}}},[se==null?void 0:se.id,M,n]),Qe=c.useCallback(async()=>{var z,V;if(!ge){if(ye.shellInputEnabled){(z=G.current)==null||z.disconnect();return}if(!se||se.status==="exited"||se.status==="not_found"){await Ve(P);return}await((V=G.current)==null?void 0:V.reconnect())}},[P,G,ye.shellInputEnabled,se,ge,Ve]),ut=c.useCallback(z=>{typeof window>"u"||d==null||d(r,wn(z))},[d,r]),at=c.useCallback(()=>{var z,V;(z=m.current)==null||z.refreshLayout({syncBackendSize:!0}),(V=f.current)==null||V.refreshLayout({syncBackendSize:!0})},[]),Oe=c.useCallback(z=>{var Ge,He;if(D!=="columns")return;const V=g.current;if(!V)return;z.preventDefault(),(He=(Ge=z.currentTarget).setPointerCapture)==null||He.call(Ge,z.pointerId);const fe=Fe=>{const qe=V.getBoundingClientRect();if(qe.width<=0)return;const dt=wn((Fe-qe.left)/qe.width*100);_(dt),b.current!==null&&window.cancelAnimationFrame(b.current),b.current=window.requestAnimationFrame(()=>{b.current=null,at()})},Le=Fe=>{fe(Fe.clientX)},ne=Fe=>{fe(Fe.clientX);const qe=V.getBoundingClientRect();qe.width>0&&ut((Fe.clientX-qe.left)/qe.width*100),window.removeEventListener("pointermove",Le),window.removeEventListener("pointerup",ne)};window.addEventListener("pointermove",Le),window.addEventListener("pointerup",ne,{once:!0})},[ut,at,D]),Be=c.useCallback((z,V)=>{Ne(V,z.id),K(V)},[Ne]),Ue=c.useCallback(async()=>{var V;return await((V=G.current)==null?void 0:V.copyLastCommandOutput())?!0:(Ee("failed","Nothing to copy"),!1)},[G,Ee]);c.useEffect(()=>{h==null||h(Ng({activeRuntime:ye,activeShell:se,connectionButtonDisabled:ge,connectionButtonLabel:we,isMobileShell:E,busy:w,loading:k,error:S}))},[ye,se,w,ge,we,S,E,k,h]),c.useImperativeHandle(u,()=>({async toggleConnection(){await Qe()},sendInput(z){var V;return((V=G.current)==null?void 0:V.sendInput(z))??!1},sendCommand(z){var V;return((V=G.current)==null?void 0:V.sendCommand(z))??!1},sendControl(z){var V;return((V=G.current)==null?void 0:V.sendControl(z))??!1},async copyLastCommandOutput(){var z;return await((z=G.current)==null?void 0:z.copyLastCommandOutput())??!1},async terminate(){await ot()},focus(){var z;(z=G.current)==null||z.focus()},refreshLayout(z){var V,fe;(V=m.current)==null||V.refreshLayout(z),D==="columns"&&((fe=f.current)==null||fe.refreshLayout(z))}}),[G,Qe,ot,D]);const tt=z=>t.jsx("div",{className:`rounded-md border px-2 py-1.5 text-xs ${z.id===(se==null?void 0:se.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:[Y===z.id?t.jsx("form",{className:"min-w-0 flex-1",onSubmit:V=>{V.preventDefault(),Ae()},children:t.jsx("input",{value:q,onChange:V=>H(V.currentTarget.value),onKeyDown:V=>{V.key==="Escape"&&(V.preventDefault(),ke())},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:()=>et(z),onDoubleClick:()=>pe(z),className:"min-w-0 flex-1 text-left",title:z.tmuxSessionName,children:[t.jsx("span",{className:"block truncate",children:ee(z)}),t.jsxs("span",{className:"block truncate text-[10px] text-[var(--theme-fg-muted)]",children:[kn(z.status)," · ",tn(z.cwd)||z.cwd]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Y===z.id?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>void Ae(),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:ke,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:()=>pe(z),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"}),D==="columns"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>Be(z,"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:()=>Be(z,"secondary"),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Open in right pane",children:"R"})]}),t.jsx("button",{type:"button",disabled:w,onClick:()=>void ot(z.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"})]})]})},z.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:ye.promptLabel??(se==null?void 0:se.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} (${kn(ye.status)})`,disabled:ge,onClick:()=>void Qe(),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 ${_e}`,children:t.jsx(Jf,{connected:ye.shellInputEnabled})}),se&&t.jsx("button",{type:"button",disabled:w,onClick:()=>void ot(se.id),className:"rounded-full border border-rose-300/35 bg-rose-300/12 px-3 py-2 text-sm text-rose-600 transition hover:bg-rose-300/18 dark:text-rose-100 disabled:cursor-not-allowed disabled:opacity-60",children:"Terminate"})]})]}),(S||k||je)&&t.jsxs("div",{className:"shell-banner mt-3 rounded-2xl border px-3 py-3 text-sm",children:[k&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!k&&je&&t.jsx("p",{className:"text-rose-600 dark:text-rose-100",children:"Workspace path is missing on this machine. Restore the path before creating a shell."}),!k&&S&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:S})]})]}),t.jsx("div",{className:"min-h-0 flex-1",children:t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("div",{className:"shell-terminal-bar flex shrink-0 items-center gap-2 border-b px-2 py-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-1",children:[t.jsx("span",{className:"min-w-0 truncate text-xs text-[var(--theme-fg-soft)]",children:se?ee(se):"No live shell process"}),se&&t.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.12em] text-[var(--theme-fg-muted)]",children:kn(ye.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":O,"aria-label":O?"Hide shell processes":"Show shell processes",onClick:()=>N(z=>!z),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"})]})]}),O&&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(tt),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:w||k||je,onClick:()=>void Ve(P),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:"+"})})]}),re==="not_created"||je?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."}),!je&&t.jsx("button",{type:"button",disabled:w||k,onClick:()=>void Ve("primary"),className:"mt-5 rounded-md border border-sky-300/35 bg-sky-300/12 px-3 py-2 text-sm text-sky-50 disabled:cursor-not-allowed disabled:opacity-50",children:"New Shell"})]})}):t.jsxs("div",{className:"grid h-full min-h-0 grid-cols-1 gap-2 p-2 sm:grid-cols-[minmax(0,1fr)_16rem] sm:p-3",children:[t.jsxs("div",{className:"shell-terminal-frame relative min-h-0 overflow-hidden rounded-[1.4rem] border shadow-inner",children:[!s&&(S||k||je)&&t.jsxs("div",{className:"shell-banner absolute left-2 right-2 top-2 z-10 rounded-2xl border px-3 py-3 text-sm backdrop-blur sm:left-3 sm:right-3 sm:top-3",children:[k&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!k&&je&&t.jsx("p",{className:"text-rose-600 dark:text-rose-100",children:"Workspace path is missing on this machine. Restore the path before creating a shell."}),!k&&S&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:S})]}),t.jsxs("div",{ref:g,className:`relative grid h-full min-h-0 ${D==="columns"?"grid-cols-1 sm:grid-cols-[var(--shell-left)_0.35rem_var(--shell-right)]":"grid-cols-1"}`,style:D==="columns"?{"--shell-left":`${oe}fr`,"--shell-right":`${100-oe}fr`}:void 0,"data-shell-split-ratio":oe,children:[t.jsx(Is,{ref:m,paneId:"primary",shell:ve,isActive:P==="primary",isVisible:a,isMobileShell:E,effectiveTheme:l,workspacePathMissing:je,shellAdapter:n,onActivate:()=>K("primary"),onShellUpdate:Me,onRuntimeStateChange:A,onFeedback:Ee}),D==="columns"&&t.jsx("button",{type:"button",onClick:()=>De("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"}),D==="columns"&&t.jsx("button",{type:"button","aria-label":"Resize shell panes",title:"Resize shell panes",onPointerDown:Oe,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"}),D==="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(Is,{ref:f,paneId:"secondary",shell:Pe,isActive:P==="secondary",isVisible:a,isMobileShell:E,effectiveTheme:l,workspacePathMissing:je,shellAdapter:n,onActivate:()=>K("secondary"),onShellUpdate:Me,onRuntimeStateChange:$,onFeedback:Ee}),t.jsx("button",{type:"button",onClick:()=>De("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&&E&&t.jsxs("div",{className:"pointer-events-none absolute bottom-3 right-3 z-20 flex flex-col items-end gap-2",children:[Q&&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 ${Re}`,children:Q.text}),T&&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:()=>{Ee("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(Ls,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:()=>void Ue(),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(Ls,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:!ye.shellInputEnabled,onClick:()=>{var z;(z=G.current)!=null&&z.sendControl("clear")?Ee("done","Cleared"):Ee("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(yn,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!ye.shellInputEnabled||!ye.isCommandRunning,onClick:()=>{var z;(z=G.current)!=null&&z.sendInput("")?Ee("done","Sent Ctrl-C"):Ee("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(yn,{label:"CTRL-C",tone:"rose"})}),["ctrl_d","esc","tab","up","down"].map(z=>t.jsx("button",{type:"button",disabled:!ye.shellInputEnabled,onClick:()=>{var V;(V=G.current)!=null&&V.sendControl(z)?Ee("done",`Sent ${z.toUpperCase().replace("_","-")}`):Ee("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(yn,{label:z.toUpperCase().replace("_","-"),tone:"stone"})},z))]})}),t.jsx("button",{type:"button","aria-expanded":T,"aria-label":T?"Close shell tools":"Open shell tools",onClick:()=>U(z=>!z),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(Zf,{})})]})]}),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(tt),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:w||k||je,onClick:()=>void Ve(P),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:"+"})})]})]})]})})]})}),Og=c.lazy(async()=>({default:(await Promise.resolve().then(()=>(ru(),Xo))).ThreadGraphWorkspacePanel}));function Ug(){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 wl(e){return t.jsx(c.Suspense,{fallback:t.jsx(Ug,{}),children:t.jsx(Og,{...e})})}c.memo(wl);function ix({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?Or.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 Wg(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 Vg(e){switch(e){case"inProgress":return"running";case"completed":return"completed";case"interrupted":return"interrupted";case"failed":return"failed"}}function Kg(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 qg(e){switch(e){case"latest-3":return 3;case"latest-10":return 10;case"latest-20":return 20;default:return null}}function Xg(e){return e==="read"?"View only":"Collaborator"}function Yg(e){switch(e){case"write":return"Workspace write";case"read":return"Workspace read";case"none":default:return"No workspace"}}function dx({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}){var E,W,O;const f=c.useMemo(()=>{var N;return((N=n.data)==null?void 0:N.turns)??[]},[(E=n.data)==null?void 0:E.turns]),[p,g]=c.useState(l),[b,v]=c.useState("latest-10"),[x,y]=c.useState(()=>new Set),[k,C]=c.useState(!0),[w,j]=c.useState(""),[S,L]=c.useState("read"),[P,K]=c.useState("none"),[F,R]=c.useState(""),[J,Z]=c.useState(()=>typeof document<"u"&&!document.documentElement.classList.contains("dark")?"light":"dark");if(c.useEffect(()=>{e&&(g(l),v("latest-10"),C(!0),j(""),L("read"),K("none"),R(""),d())},[l,d,e]),c.useEffect(()=>{e&&f.length>0&&y(new Set(f.slice(0,10).map(N=>N.turnId)))},[e,f]),c.useEffect(()=>{if(!e)return;function N(T){T.key==="Escape"&&!r&&i()}return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[r,i,e]),c.useEffect(()=>{if(!e)return;const N=document.querySelector(".thread-ui-shell"),T=()=>N?N.getAttribute("data-theme-effective")==="dark"||N.classList.contains("dark")||N.classList.contains("thread-ui-theme-dark")?"dark":"light":document.documentElement.classList.contains("dark")?"dark":"light";if(Z(T()),!N)return;const U=new MutationObserver(()=>Z(T()));return U.observe(N,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>U.disconnect()},[e]),!e)return null;const D=qg(b),te=D!==null?Math.min(D,((W=n.data)==null?void 0:W.totalTurnCount)??D):b==="all-loaded"?f.length:x.size,oe=!r&&p!=="share"&&(D!==null||b==="all-loaded"||x.size>0),_=!r&&a&&!!u&&w.trim().length>0;function Y(N){y(T=>{const U=new Set(T);return U.has(N)?U.delete(N):U.add(N),U})}function I(){if(p==="share")return;const N={format:p,...D!==null?{mode:"latest",limit:D}:b==="all-loaded"?{mode:"selected",turnIds:f.map(T=>T.turnId)}:{mode:"selected",turnIds:[...x]},profile:"review",options:{includeTokenAndPrice:k}};h(N)}function q(N){N.preventDefault(),_&&(u==null||u({targetIdentifier:w.trim(),threadAccess:S,workspaceAccess:P,label:F.trim()||null}))}const H=[{mode:"pdf",label:"PDF"},{mode:"html",label:"HTML"},{mode:"share",label:"Share"}];return Or.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 relay session."})]}),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:H.map(N=>t.jsx("button",{type:"button",onClick:()=>g(N.mode),className:`rounded-full px-3 py-1.5 text-sm transition ${p===N.mode?"ui-status-warning":"thread-export-dialog-muted-action"}`,children:N.label},N.mode))}),p==="share"?t.jsxs("form",{id:"thread-actions-share-form",className:"mt-4 space-y-4",onSubmit:q,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}),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:N=>j(N.target.value),placeholder:"username or email",value:w})]}),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(([N,T])=>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:S===N,disabled:!a||r,onChange:()=>L(N)}),T]},N))})]}),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(([N,T])=>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===N,disabled:!a||r,onChange:()=>K(N)}),T]},N))})]}),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:N=>R(N.target.value),placeholder:"optional",value:F})]}),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(N=>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:N.targetUsername}),t.jsxs("p",{className:"thread-export-dialog-subtitle mt-0.5 text-xs",children:[N.label?`${N.label} · `:"",Xg(N.threadAccess)," / ",Yg(N.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(N.id),children:"Revoke"}):null]},N.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:b,onChange:N=>v(N.target.value),children:["latest-3","latest-10","latest-20","all-loaded","custom"].map(N=>t.jsx("option",{value:N,children:Kg(N)},N))})]}),b==="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 ",x.size," of ",((O=n.data)==null?void 0:O.totalTurnCount)??f.length]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>y(new Set(f.map(N=>N.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:f.map(N=>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:x.has(N.turnId),onChange:()=>Y(N.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 ",N.turnNumber]}),t.jsx("span",{className:"thread-export-dialog-subtitle shrink-0 text-xs",children:Wg(N.startedAt)}),t.jsx("span",{className:"thread-export-dialog-body-text min-w-0 flex-1 truncate text-left",children:N.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:Vg(N.status)})]},N.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:k,onChange:N=>C(N.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:p==="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:p==="share"?a?"Share access is enforced by the relay server.":"Share permissions are not wired yet.":`${te} ${te===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"}),p==="share"?t.jsx("button",{type:"submit",form:"thread-actions-share-form",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?"Sharing...":"Share session"}):t.jsx("button",{type:"button",onClick:I,disabled:!oe,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 ${p.toUpperCase()}`})]})]})]})]}),document.body)}function Nn(e){if(e===void 0)return"-";if(Math.abs(e)>1e4){const r=Math.abs(e)>=1e5?0:1;return`${(e/1e3).toLocaleString(void 0,{maximumFractionDigits:r})}k`}return e.toLocaleString()}function Zg(e){const r=`in ${Nn(e.input)} / out ${Nn(e.output)} / cache ${Nn(e.cache)}`;return e.pricedTurns>0?`${r} / cost ${sa(e.priceUsd)}`:r}function Jg({detail:e,adapter:r,timelineAdapter:n,TimelineComponent:a=xl,liveOutput:s="",beforeTimelineContent:o,composerProps:l,timelineProps:i,threadUsageSummary:d,transcriptItemCount:h,useFloatingMobileComposer:u=!1,floatingMobileComposerBottomOffset:m=0,composerHostRef:f}){const[p,g]=c.useState(!1),[b,v]=c.useState(0),[x,y]=c.useState(0),[k,C]=c.useState(0),[w,j]=c.useState(!1),S=c.useRef(null),L=i==null?void 0:i.onTailVisibilityChange,P=e.pendingRequests.length>0,K=c.useCallback(Y=>{L==null||L(Y)},[L]);c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const Y=window.matchMedia("(max-width: 639px)"),I=()=>g(Y.matches);return I(),Y.addEventListener("change",I),()=>{Y.removeEventListener("change",I)}},[]),c.useEffect(()=>{var I,q;if(typeof window>"u")return;const Y=()=>{const H=window.visualViewport,E=H?Math.max(0,Math.round(window.innerHeight-H.height-H.offsetTop)):0,W=H?Math.max(0,Math.round(window.innerHeight-H.height)):E,O=Math.min(E,W),N=Math.max(0,Math.round(window.innerHeight*.52));C(Math.min(O,N))};return Y(),(I=window.visualViewport)==null||I.addEventListener("resize",Y),(q=window.visualViewport)==null||q.addEventListener("scroll",Y),window.addEventListener("resize",Y),()=>{var H,E;(H=window.visualViewport)==null||H.removeEventListener("resize",Y),(E=window.visualViewport)==null||E.removeEventListener("scroll",Y),window.removeEventListener("resize",Y)}},[]),c.useLayoutEffect(()=>{const Y=S.current;if(!Y||!p){v(0);return}const I=()=>{v(Math.ceil(Y.getBoundingClientRect().height))};if(I(),typeof ResizeObserver>"u")return;const q=new ResizeObserver(I);return q.observe(Y),()=>{q.disconnect()}},[p,l,P]),c.useLayoutEffect(()=>{var H,E;const Y=S.current;if(!Y||!p){y(0);return}const I=()=>{const W=Y.getBoundingClientRect();y(Math.max(0,Math.ceil(window.innerHeight-W.top)))};I(),window.addEventListener("resize",I),(H=window.visualViewport)==null||H.addEventListener("resize",I),(E=window.visualViewport)==null||E.addEventListener("scroll",I);let q=null;return typeof ResizeObserver<"u"&&(q=new ResizeObserver(I),q.observe(Y)),()=>{var W,O;window.removeEventListener("resize",I),(W=window.visualViewport)==null||W.removeEventListener("resize",I),(O=window.visualViewport)==null||O.removeEventListener("scroll",I),q==null||q.disconnect()}},[p,k,w,l,P]),c.useEffect(()=>{if(!p){j(!1);return}const Y=q=>{var E;const H=q.target;H instanceof HTMLElement&&((E=S.current)!=null&&E.contains(H))&&j(!0)},I=q=>{var E;const H=q.relatedTarget;H instanceof HTMLElement&&((E=S.current)!=null&&E.contains(H))||j(!1)};return document.addEventListener("focusin",Y),document.addEventListener("focusout",I),()=>{document.removeEventListener("focusin",Y),document.removeEventListener("focusout",I)}},[p]);const F=c.useCallback(Y=>{S.current=Y,f&&(f.current=Y)},[f]),R=p&&w?Math.max(0,k-m):0,J=Math.max(b,144),Z=Math.max(x,J+R),D=p?Z+12:0,te=D>0?{"--thread-graph-chat-scroll-bottom-spacer":`${D}px`}:void 0,oe=u&&p?{bottom:`${m+R}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"}:void 0,_=c.useMemo(()=>{const Y=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:Y,liveOutput:s,className:"thread-timeline-surface min-h-0 flex-1",...i,adapter:n,onOpenThread:(i==null?void 0:i.onOpenThread)??r.openThread,onTailVisibilityChange:K})},[a,r.openThread,e.pendingRequests,e.thread.activeTurnId,e.thread.id,e.thread.status,e.totalTurnCount,e.turns,K,s,n,i]);return t.jsxs("div",{"data-testid":"chat-panel",className:"thread-graph-chat-panel relative flex h-full min-h-0 flex-col",style:te,children:[o,_,t.jsxs("div",{className:"thread-chat-usage-footer hidden shrink-0 items-center justify-between gap-3 px-4 py-1 text-[10px] leading-4 sm:flex",children:[t.jsxs("span",{className:"min-w-0 truncate",children:[e.turns.length," turn",e.turns.length!==1?"s":"",t.jsx("span",{className:"mx-1 text-[var(--theme-border-contrast)]",children:"|"}),h," item",h!==1?"s":""]}),t.jsxs("span",{className:"shrink-0",children:["Usage"," ",d&&d.turns>0?Zg(d):"waiting for agent usage"]})]}),l?u?t.jsx("div",{ref:F,className:"fixed inset-x-0 bottom-0 z-50 overflow-visible sm:hidden",style:oe??{bottom:`${m}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"},children:t.jsx(Bn,{...l,activeView:"chat",edgeToEdgeMobile:!0,onSubmit:r.sendPrompt})}):t.jsx("div",{ref:F,className:"thread-graph-composer-host shrink-0",children:t.jsx(Bn,{...l,activeView:"chat",onSubmit:r.sendPrompt})}):null]})}function Qg(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,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,priceUsd:0,pricedTurns:0,turns:0})}function Cn(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 ex(e){if(!e||e.turns<=0)return"waiting for agent usage";const r=`in ${Cn(e.input)} / out ${Cn(e.output)} / cache ${Cn(e.cache)}`;return e.pricedTurns>0?`${r} / cost ${sa(e.priceUsd)}`:r}function cx({threads:e,detail:r,loading:n,error:a,status:s=null,plugins:o,adapter:l,metaContent:i,settingsContent:d,globalSettingsContent:h,settingsDialogOpen:u,onSettingsDialogOpenChange:m,mobileHeaderAction:f,appMenuButton:p,appNavigationMenu:g,workspaceReturnHref:b,onWorkspaceReturn:v,threadActionsButton:x,surfaceActions:y,floatingPanel:k,workspaceContent:C,workspaceTitle:w,workspaceActions:j,workspaceFeatures:S,workspaceFocusPathRequest:L=null,onNewThreadTitle:P,beforeTimelineContent:K,errorContent:F,workspaceMissingContent:R,dialogs:J,currentThreadId:Z,currentWorkspaceId:D,currentWorkspaceLabel:te,onCloseAppNavigation:oe,className:_="thread-detail-surface relative flex h-full min-h-0 flex-1 flex-col overflow-hidden",activeView:Y="chat",liveOutput:I="",timelineProps:q,composerProps:H,shellComposerProps:E,useFloatingMobileComposer:W=!1,floatingMobileComposerBottomOffset:O=0,composerHostRef:N,shellPanelRef:T,shellEffectiveTheme:U="dark",shellThemeMode:X=U,onShellThemeModeChange:ie,onShellStateChange:Q,shellUnavailableContent:de,shellDisconnectedContent:re,timelineComponent:xe=xl,shellPanelComponent:le=Hg,shellContent:ve,loadingContent:Pe,emptyContent:se}){const ye=aa(),je=o??ye??ra(),{getImageAssetUrl:G,loadHistoryItemDetail:me,openWorkspaceFile:ge,openThread:we,cancelPendingSteer:_e}=l,Re=c.useMemo(()=>({...G?{getImageAssetUrl:pe=>G(pe.path)}:{},onOpenLinkedThread:we,...ge?{onOpenWorkspaceFile:ge}:{},...me?{onLoadHistoryItemDetail:me}:{},..._e?{cancelPendingSteer:_e}:{}}),[_e,G,me,ge,we]),Ee=je.getThreadPanels().some(pe=>pe.kind==="terminal"),Me=c.useMemo(()=>r?Qg(r):null,[r]),M=c.useMemo(()=>ex(Me),[Me]),ue=c.useMemo(()=>{var pe;return r?r.turns.reduce((ke,Ae)=>ke+Ae.items.length,((pe=r.liveItems)==null?void 0:pe.items.length)??0):0},[r]),A=C??(r?t.jsx(wl,{detail:r,status:s,plugins:je,workspaceAdapter:l.workspace??null,metaContent:i,settingsContent:d,activeView:Y,features:S,focusPathRequest:L}):null),$=n?Pe??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:[k?t.jsx("div",{className:"fixed right-3 top-20 z-50 lg:absolute lg:right-4 lg:top-16",children:k}):null,a&&!n&&(F??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"&&(R??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:Y==="chat"?"flex min-h-0 flex-1 flex-col":"hidden",children:t.jsx(Jg,{detail:r,adapter:l,timelineAdapter:Re,TimelineComponent:xe,liveOutput:I,threadUsageSummary:Me,transcriptItemCount:ue,useFloatingMobileComposer:W,floatingMobileComposerBottomOffset:O,...K?{beforeTimelineContent:K}:{},...H?{composerProps:H}:{},...q?{timelineProps:q}:{},...N?{composerHostRef:N}:{}})}),t.jsxs("div",{className:Y==="shell"?"flex min-h-0 flex-1 flex-col":"hidden",children:[ve??(r.thread.isLoaded&&Ee&&l.shell?t.jsx(le,{ref:T,threadId:r.thread.id,shellAdapter:l.shell,effectiveTheme:U,isVisible:Y==="shell",showHeader:!1,showFloatingToolbox:!1,...Q?{onStateChange:Q}:{}}):r.thread.isLoaded&&!Ee?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."})]})}):re??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."})]})})),Y==="shell"&&E&&!ve?t.jsx(Bn,{...E,activeView:"shell",onSubmit:l.sendPrompt}):null]}),J]}):se??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."}),ee=t.jsx(Zm,{threads:e,status:s,loading:n,error:n?null:a,viewportConstrained:!0,currentThreadId:Z??(r==null?void 0:r.thread.id),currentThreadLabel:r==null?void 0:r.thread.title,currentWorkspaceId:D??(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:M,threadActionsButton:x,topbarActions:y,metaContent:i,settingsContent:d,globalSettingsContent:h,...u!==void 0?{settingsDialogOpen:u}:{},...m?{onSettingsDialogOpenChange:m}:{},mobileHeaderAction:f,effectiveTheme:U,themeMode:X,appMenuButton:p,appNavigationMenu:g,workspaceReturnHref:b,...v?{onWorkspaceReturn:v}:{},showMobileAppMenu:!!p,showMobileThreadNavToggle:!0,showMobileNewThreadShortcut:!1,onOpenThread:l.openThread,workspaceContent:A,workspaceTitle:w??"Workspace",workspaceActions:j,...P?{onNewThreadTitle:P}:{},...oe?{onCloseAppNavigation:oe}:{},...ie?{onThemeModeChange:ie}:{},...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:$});return o?t.jsx(na.Provider,{value:je,children:ee}):ee}var tx={},rx=[];function hx({adapter:e=tx,builtinPlugins:r=rx,children:n}){const[a,s]=c.useState(()=>Gn(r,[])),[o,l]=c.useState(!1),[i,d]=c.useState(null),h=c.useCallback(async()=>{l(!0),d(null);try{const k=e.fetchPlugins?await e.fetchPlugins():[];s(Gn(r,k))}catch(k){d(k instanceof Error?k.message:"Unable to load plugins.")}finally{l(!1)}},[e,r]);c.useEffect(()=>{h()},[h]);const u=c.useCallback(async(k,C)=>{if(e.updatePlugin){const w=await e.updatePlugin(k,{enabled:C});s(j=>j.map(S=>S.id===w.id?w:S));return}s(w=>w.map(j=>j.id===k?{...j,enabled:C}:j))},[e]),m=c.useCallback(async k=>{if(!e.importPlugin)throw new Error("Plugin import is not available.");const C=await e.importPlugin(k);s(w=>[...w.filter(S=>S.id!==C.id),C])},[e]),f=c.useCallback(async k=>{if(!e.deletePlugin)throw new Error("Plugin uninstall is not available.");const C=await e.deletePlugin(k);s(w=>w.filter(j=>j.id!==C.id))},[e]),p=c.useMemo(()=>{const k=new Set(a.filter(C=>C.enabled).map(C=>C.id));return r.filter(C=>k.has(C.manifest.id))},[r,a]),g=c.useCallback(k=>{var w;const C=p.find(j=>j.renderArtifact&&j.manifest.capabilities.artifactTypes.some(S=>S.type===k.artifact.type));return((w=C==null?void 0:C.renderArtifact)==null?void 0:w.call(C,k))??null},[p]),b=c.useCallback(k=>{for(const C of p)for(const w of C.inlineCodeRenderers??[]){if(!w.languages.includes(k.language.trim().toLowerCase()))continue;const j=w.render(k);if(j)return j}return null},[p]),v=c.useCallback(k=>p.some(C=>!!C.renderArtifact&&C.manifest.capabilities.artifactTypes.some(w=>w.type===k.type)),[p]),x=c.useCallback(()=>p.flatMap(k=>k.threadPanels??[]),[p]),y=c.useMemo(()=>({plugins:a,loading:o,error:i,refresh:h,importPluginManifest:m,setPluginEnabled:u,uninstallPlugin:f,renderArtifact:g,renderInlineCode:b,hasRendererForArtifact:v,getThreadPanels:x}),[i,x,v,m,o,a,h,g,b,u,f]);return t.jsx(na.Provider,{value:y,children:n})}export{_m as A,ix as C,Jm as L,hx as P,dx as T,aa as a,cx as b,Hg as c,xl as d,Zm as e,Gt as f,Ym as g,Mm as t,el as u};
3676
+ `);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 Ps(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(`
3677
+ `).trimEnd():""}function vg({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 zs={status:"not_created",shellInputEnabled:!1,isConnecting:!1,isCommandRunning:!1,promptLabel:null,error:null,hasShell:!1};function pt(e){return e.status!=="exited"&&e.status!=="not_found"}function kg({shell:e,workspacePathMissing:r}){return!!(e&&!r&&pt(e))}function wg(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 yg(e){return(e.activeShellId?e.shells.find(r=>r.id===e.activeShellId&&pt(r)):null)??(e.shell&&pt(e.shell)?e.shell:null)??e.shells.find(pt)??null}function jg({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&&!pt(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&&!pt(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 Ng({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?la(en(r.cwd),null):null),isMobileShell:o,hasShell:!!r,busy:s,loading:l,error:e.error??i}}function Dt(e){return e.current===null?!1:(window.clearTimeout(e.current),e.current=null,!0)}function Cg({attachRetryTimerRef:e,setReconnectKey:r,delayMs:n=Qf}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function Sg({reconnectTimerRef:e,setReconnectKey:r,delayMs:n=eg}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function Tg({shellSocket:e,socketRef:r,viewerIdRef:n,attachTimeoutRef:a,setConnectionError:o,setIsConnecting:s,settleAttachPromise:l,delayMs:i=tg}){a.current=window.setTimeout(()=>{var h,u,m;a.current=null;const d=ag({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 Eg(e){return{...e,status:e.status==="attached"?"detached":e.status,attachedViewerId:null}}function Lg({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 Pg({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&&Dt(n),e.shouldClearSocketRef&&(a.current=null),s(e.viewerId),l(e.isConnecting),i(e.settleAttachPromise),u.shouldDetachShell&&d(r,Eg,"detached"),u.shouldScheduleReconnect&&Sg({reconnectTimerRef:o,setReconnectKey:h}),!0):!1}function zg({cleanupAction:e,shellSocket:r,attachRetryTimerRef:n,attachTimeoutRef:a,socketRef:o,intentionalDisconnectRef:s,setViewerId:l,setIsConnecting:i,settleAttachPromise:d}){s.current=e.intentionalDisconnect,e.shouldClearAttachRetry&&Dt(n),e.shouldSendDetachMessage&&e.detachMessage&&r.send(e.detachMessage),l(null),i(e.isConnecting),e.settleAttachPromise!==void 0&&d(e.settleAttachPromise),e.shouldClearAttachTimeout&&Dt(a),r.socket.close(),e.shouldClearSocketRef&&(o.current=null)}function Ig({eventShellId:e,shellId:r,socketExists:n,isCurrentSocket:a}){return n&&!a?!1:e===r}function Rg(e){return bl({...e,attachSize:void 0})}function Ag({attachSize:e,...r}){return bl({...r,attachSize:e})}function _g({isCurrentSocket:e,shellId:r,attachSize:n,hasAttachTimeout:a}){const o=sg({isCurrentSocket:e,shellId:r,attachSize:n});return{openAction:o,shouldClearAttachTimeout:!!(o&&a)}}function Mg(e){const r=String(e.payload.viewerId??"");return{viewerId:r||null,settleAttachPromise:!!r,nextShell:n=>({...n,status:"attached",attachedViewerId:r})}}function $g({event:e,shellCwd:r,currentSnapshot:n,pendingCommand:a}){const o=gg(e.payload,r),s=o.data?xg({currentSnapshot:n,data:o.data,replace:o.replace,isCommandRunning:o.isCommandRunning,pendingCommand:a}):null;return{output:o,snapshotUpdate:s}}function Dg({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:o,hasAttachTimeout:s}){const l=lg({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 Bg(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 Gg(e){return e.current}function Fg({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:y,syncTerminalSizeRef:k,setReconnectKey:j,setViewerId:v,setIsConnecting:N,setConnectionError:S,setRuntimePromptLabel:L,setIsCommandRunning:P,settleAttachPromise:K,onShellUpdate:F}){const D=e==null?void 0:e.id,Z=e==null?void 0:e.cwd;c.useEffect(()=>{const Y=s.current,$={shellId:D??null,terminalReady:a,isVisible:f.current,canAttachShell:n,userDisconnectedShellId:g.current,hasTerminal:!!Y,hasPendingAttachRetry:m.current!==null,hasCurrentSocketForShell:!!(l.current&&d.current===D),hasReconnectTimer:h.current!==null};if(Rg($).type==="skip")return;const oe=k.current(),A=Ag({...$,attachSize:oe});if(A.type==="skip"||A.type==="measureSize")return;if(A.type==="scheduleRetry"){Cg({attachRetryTimerRef:m,setReconnectKey:j});return}if(A.shouldClearAttachRetry&&Dt(m),A.type==="reuseSocket"||(A.shouldClearReconnectTimer&&Dt(h),!D||!Y))return;const J=A.attachSize;d.current=D,Y.reset(),S(null),v(null),N(!0),p.current=!1;const I=r.connectSocket({onConnected:()=>{var U;const q=u.current,O=_g({isCurrentSocket:((U=l.current)==null?void 0:U.socket)===I.socket,shellId:D,attachSize:J,hasAttachTimeout:q!==null}),T=O.openAction;T&&(I.send(T.message),O.shouldClearAttachTimeout&&q!==null&&Dt(u),T.shouldScheduleAttachTimeout&&Tg({shellSocket:I,socketRef:l,viewerIdRef:i,attachTimeoutRef:u,setConnectionError:S,setIsConnecting:N,settleAttachPromise:K}))},onShellEvent:q=>{var U;if(!Ig({eventShellId:q.shellId,shellId:D,socketExists:!!I.socket,isCurrentSocket:((U=l.current)==null?void 0:U.socket)===I.socket}))return;if(q.type==="shell.connected"){Dt(u);const H=Mg(q);v(H.viewerId),N(!1),K(H.settleAttachPromise),F(D,H.nextShell,"attached");return}if(q.type==="shell.output"){const{output:H,snapshotUpdate:C}=$g({event:q,shellCwd:Z,currentSnapshot:b.current,pendingCommand:w.current});y.current={cursorX:H.cursorX,cursorY:H.cursorY,paneHeight:H.paneHeight},L(H.promptLabel),P(H.isCommandRunning),C&&(b.current=C.nextSnapshot,w.current=C.nextPendingCommand,C.lastCommandOutput!==null&&(x.current=C.lastCommandOutput),H.replace?kl(Y,H.data,H.cursorX,H.cursorY,H.paneHeight):Y.write(H.data));return}const T=bg({event:q,currentViewerId:i.current});T&&(T.viewerId!==void 0&&v(T.viewerId),T.isConnecting!==void 0&&N(T.isConnecting),T.settleAttachPromise!==void 0&&K(T.settleAttachPromise),T.isCommandRunning!==void 0&&P(T.isCommandRunning),T.connectionError!==void 0&&S(T.connectionError),T.intentionalDisconnect!==void 0&&(p.current=T.intentionalDisconnect),T.shellUpdate&&F(D,H=>Bg(H,T),T.shellUpdate.status),T.closeSocket&&I.socket.close())}});return l.current=I,I.socket.addEventListener("close",()=>{var T;const q=u.current,O=Dg({isCurrentSocket:((T=l.current)==null?void 0:T.socket)===I.socket,hadViewer:!!i.current,intentionalDisconnect:p.current,userDisconnectedShellId:g.current,shellId:D,hasAttachTimeout:q!==null});Pg({closeApplication:O,shellId:D,attachTimeoutRef:u,socketRef:l,reconnectTimerRef:h,setViewerId:v,setIsConnecting:N,settleAttachPromise:K,onShellUpdate:F,setReconnectKey:j})}),()=>{const q=Gg(i),O=Lg({shellId:D,viewerId:q,shellSocket:I,attachRetryTimerRef:m,attachTimeoutRef:u,socketRef:l,openReadyState:WebSocket.OPEN});zg({cleanupAction:O,shellSocket:I,attachRetryTimerRef:m,attachTimeoutRef:u,socketRef:l,intentionalDisconnectRef:p,setViewerId:v,setIsConnecting:N,settleAttachPromise:K})}},[m,u,n,p,f,x,F,w,o,h,S,P,N,j,L,v,K,Z,D,r,d,b,y,l,k,a,s,g,i])}function yn(e){return e.current}var Is=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),y=c.useRef(null),k=c.useRef(null),j=c.useRef(null),v=c.useRef(null),N=c.useRef(!1),S=c.useRef(null),L=c.useRef(""),P=c.useRef(null),K=c.useRef(""),F=c.useRef(null),D=c.useRef(null),Z=c.useRef({cursorX:void 0,cursorY:void 0,paneHeight:void 0}),Y=c.useRef(!1),$=c.useRef(null),te=c.useRef(o),oe=c.useRef(s),A=c.useRef(()=>!1),J=c.useRef(()=>null),I=c.useRef(()=>{}),q=c.useRef(vg({clearTimeout:window.clearTimeout})),[O,T]=c.useState(null),[U,H]=c.useState(!1),[C,E]=c.useState(null),[X,W]=c.useState(!1),[le,Q]=c.useState(null),[de,re]=c.useState(null),[xe,ie]=c.useState(!1),[ve,Pe]=c.useState(0),se=(n==null?void 0:n.status)??"not_created",ye=kg({shell:n,workspacePathMissing:i}),je=c.useMemo(()=>la(en(n==null?void 0:n.cwd),null),[n==null?void 0:n.cwd]),G=de??je,me=c.useCallback(_=>{x.current=_,E(_)},[]),ge=c.useCallback(_=>{q.current.settle(_)},[]);c.useEffect(()=>{te.current=o},[o]),c.useEffect(()=>{oe.current=s},[s]),c.useEffect(()=>{y.current=(n==null?void 0:n.id)??null},[n==null?void 0:n.id]);const we=c.useCallback(_=>{const ue=w.current,R=y.current,M=x.current;return!ue||!R||!M?!1:(ue.send({type:"shell.input",shellId:R,viewerId:M,data:_}),!0)},[]);c.useEffect(()=>{A.current=we},[we]);const _e=c.useCallback(()=>{const _=w.current,ue=y.current,R=x.current;return!_||!ue||!R?!1:(_.send({type:"shell.clear",shellId:ue,viewerId:R}),!0)},[]),Re=c.useCallback(()=>{if(!o||!O)return!1;const _=O.getBoundingClientRect();return _.width>0&&_.height>0},[o,O]),Ee=c.useCallback(_=>{const ue=g.current,R=b.current;if(!ue||!R||!Re()||(R.fit(),ue.cols<=0||ue.rows<=0))return null;const M={cols:ue.cols,rows:ue.rows},ee=fg({size:M,previousSize:D.current,shellId:y.current,viewerId:x.current,syncBackendSize:(_==null?void 0:_.syncBackendSize)!==!1});return(_==null?void 0:_.syncBackendSize)===!1||(D.current=ee.nextLastSentSize,!ee.message)||w.current&&w.current.send(ee.message),M},[Re]);c.useEffect(()=>{J.current=Ee},[Ee]);const Me=c.useCallback(_=>{const ue=g.current;!ue||!Re()||(Ee((_==null?void 0:_.syncBackendSize)===void 0?void 0:{syncBackendSize:_.syncBackendSize}),L.current&&!Ps(O)?kl(ue,L.current,Z.current.cursorX,Z.current.cursorY,Z.current.paneHeight):ue.scrollToBottom(),_!=null&&_.focus&&!s&&ue.focus())},[s,Re,Ee,O]);return c.useEffect(()=>{I.current=()=>Me()},[Me]),c.useEffect(()=>{m({status:C?"attached":se,shellInputEnabled:!!(C&&n),isConnecting:X,isCommandRunning:xe,promptLabel:G,error:le,hasShell:!!n})},[le,X,xe,m,G,n,se,C]),c.useEffect(()=>{if(!O||g.current||Y.current)return;let _=!1;return Y.current=!0,(async()=>{const[{Terminal:ue},{FitAddon:R}]=await Promise.all([Ke(()=>import("./terminal-vendor-B365Go3Z.js").then(pe=>pe.x),__vite__mapDeps([6,2,7])),Ke(()=>import("./terminal-vendor-B365Go3Z.js").then(pe=>pe.a),__vite__mapDeps([6,2,7]))]);if(_||!O){Y.current=!1;return}const M=new ue({cursorBlink:!0,disableStdin:oe.current,fontFamily:"IBM Plex Mono, SFMono-Regular, Menlo, monospace",fontSize:13,lineHeight:1.25,scrollback:3e3,theme:Es(l)}),ee=new R;M.loadAddon(ee),M.open(O),g.current=M,b.current=ee,J.current(),M.attachCustomKeyEventHandler(pe=>{if(oe.current||pe.type!=="keydown")return!0;if(pe.ctrlKey&&!pe.altKey&&!pe.metaKey&&!pe.shiftKey){const ke=Vf(pe.key);if(!ke)return!0;if(A.current(ke))return pe.preventDefault(),!1}return!0}),H(!0),Y.current=!1,F.current=new ResizeObserver(()=>{I.current()}),F.current.observe(O),$.current=M.onData(pe=>{oe.current||A.current(pe)})})(),()=>{var ue,R,M;_=!0,Y.current=!1,(ue=$.current)==null||ue.dispose(),$.current=null,(R=F.current)==null||R.disconnect(),F.current=null,H(!1),(M=g.current)==null||M.dispose(),g.current=null,b.current=null,D.current=null}},[l,O]),c.useEffect(()=>{var ue;const _=hg({hasShell:!!n});_&&(me(_.viewerId),W(_.isConnecting),ge(_.settleAttachPromise),Q(_.connectionError),re(_.runtimePromptLabel),ie(_.isCommandRunning),L.current=_.shellSnapshot,K.current=_.lastCommandOutput,P.current=_.pendingCommand,_.shouldResetTerminal&&((ue=g.current)==null||ue.reset()))},[me,ge,n]),c.useEffect(()=>{const _=g.current;_&&(_.options.theme=Es(l))},[l]),c.useEffect(()=>{const _=g.current;_&&(_.options.disableStdin=s)},[s]),c.useEffect(()=>{if(!o||!U)return;const _=window.requestAnimationFrame(()=>{Me({focus:a,syncBackendSize:!1}),!w.current&&(n!=null&&n.id)&&S.current!==n.id&&Pe(ue=>ue+1)});return()=>{window.cancelAnimationFrame(_)}},[a,o,Me,n==null?void 0:n.id,U]),Fg({shell:n,shellAdapter:d,canAttachShell:ye,terminalReady:U,reconnectKey:ve,terminalRef:g,socketRef:w,viewerIdRef:x,shellIdRef:y,reconnectTimerRef:k,attachTimeoutRef:j,attachRetryTimerRef:v,isVisibleRef:te,intentionalDisconnectRef:N,userDisconnectedShellIdRef:S,shellSnapshotRef:L,pendingCommandRef:P,lastCommandOutputRef:K,snapshotCursorRef:Z,syncTerminalSizeRef:J,setReconnectKey:Pe,setViewerId:me,setIsConnecting:W,setConnectionError:Q,setRuntimePromptLabel:re,setIsCommandRunning:ie,settleAttachPromise:ge,onShellUpdate:u}),c.useEffect(()=>()=>{const _=yn(k),ue=yn(j),R=yn(v),M=ug({hasReconnectTimer:_!==null,hasAttachTimeout:ue!==null,hasAttachRetry:R!==null});M.shouldClearReconnectTimer&&_!==null&&window.clearTimeout(_),M.shouldClearAttachTimeout&&ue!==null&&window.clearTimeout(ue),M.shouldClearAttachRetry&&R!==null&&window.clearTimeout(R),ge(M.settleAttachPromise)},[ge]),c.useImperativeHandle(p,()=>({disconnect(){const _=w.current,ue=y.current,R=x.current,M=mg({shellId:ue,viewerId:R,hasSocket:!!_});S.current=M.userDisconnectedShellId,N.current=M.intentionalDisconnect,_&&M.detachMessage&&_.send(M.detachMessage),me(null),W(!1),ge(!1),M.shouldCloseSocket&&(_==null||_.socket.close()),w.current=null,D.current=null,M.shouldDetachShell&&ue&&u(ue,ee=>({...ee,status:"detached",attachedViewerId:null}),"detached")},reconnect(){const _=dg({hasShellId:!!y.current,terminalReady:U,workspacePathMissing:i,hasViewer:!!x.current,hasPendingAttach:q.current.hasPending()});if(_.type==="reject")return Promise.resolve(!1);if(_.type==="alreadyConnected")return Promise.resolve(!0);if(_.type==="joinPending")return q.current.joinPending();const ue=q.current.start({timeoutMs:rg,setTimeout:window.setTimeout,onTimeout:()=>{W(!1)}}),R=cg({shellId:y.current,userDisconnectedShellId:S.current});return R.shouldClearUserDisconnectedShellId&&(S.current=null),N.current=R.intentionalDisconnect,Q(R.connectionError),W(R.isConnecting),Pe(M=>M+1),ue},sendInput(_){return we(_)},sendCommand(_){const ue={command:_,beforeSnapshot:L.current};if(P.current=ue,_.trim()==="clear"){const ee=_e();return!ee&&P.current===ue&&(P.current=null),ee}const R=_.endsWith(`
3678
+ `)?_:`${_}
3679
+ `,M=we(R);return!M&&P.current===ue&&(P.current=null),M},sendControl(_){return _==="clear"?_e():we(Yf(_))},async copyLastCommandOutput(){const _=K.current.trim()||Ps(O);if(!_)return f==null||f("failed","Nothing to copy"),!1;try{return await navigator.clipboard.writeText(_),f==null||f("done","Copied"),!0}catch{return f==null||f("failed","Copy failed"),!1}},focus(){var _;(_=g.current)==null||_.focus()},refreshLayout(_){Me(_)}}),[f,u,Me,_e,we,me,ge,O,U,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 _;h(),(_=g.current)==null||_.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"})]})}),Hg=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,y]=c.useState(null),[k,j]=c.useState(!0),[v,N]=c.useState(!1),[S,L]=c.useState(null),[P,K]=c.useState("primary"),[F,D]=c.useState(null),[Z,Y]=c.useState(null),[$,te]=c.useState("single"),[oe,A]=c.useState(50),[J,I]=c.useState(null),[q,O]=c.useState(""),[T,U]=c.useState(!1),[H,C]=c.useState(!1),[E,X]=c.useState(!1),[W,le]=c.useState({primary:zs,secondary:zs}),[Q,de]=c.useState(null),re=(x==null?void 0:x.state)??"not_created",xe=c.useMemo(()=>(x==null?void 0:x.shells)??[],[x==null?void 0:x.shells]),ie=c.useMemo(()=>xe.filter(pt),[xe]),ve=c.useMemo(()=>ie.find(z=>z.id===F)??null,[ie,F]),Pe=c.useMemo(()=>ie.find(z=>z.id===Z)??null,[ie,Z]),se=P==="secondary"?Pe:ve,ye=W[P],je=(x==null?void 0:x.workspacePathStatus)==="missing",G=P==="secondary"?f:m,me=jg({activeRuntime:ye,activeShell:se,busy:v,loading:k,status:re,workspacePathMissing:je}),ge=me.disabled,we=me.label,_e=me.className,Re=(Q==null?void 0:Q.tone)==="done"?"shell-floating-feedback shell-floating-feedback-done":(Q==null?void 0:Q.tone)==="failed"?"shell-floating-feedback shell-floating-feedback-failed":"shell-floating-feedback",Ee=c.useCallback((z,V)=>{de({tone:z,text:V}),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{de(null),p.current=null},1800)},[]),Me=c.useCallback((z,V,fe)=>{y(Le=>{var He;if(!Le)return Le;const ne=Le.shells.map(Fe=>Fe.id===z?V(Fe):Fe),Ge=((He=Le.shell)==null?void 0:He.id)===z?V(Le.shell):ne.find(Fe=>{var qe;return Fe.id===((qe=Le.shell)==null?void 0:qe.id)})??Le.shell;return{...Le,...fe?{state:fe}:{},shell:Ge,shells:ne}})},[]),_=c.useCallback(async()=>{j(!0);try{const z=await n.fetchState(r);y(z),L(null)}catch(z){L(z instanceof Error?z.message:"Unable to load shell state.")}finally{j(!1)}},[n,r]);c.useEffect(()=>{_()},[_]),c.useEffect(()=>{const z=i==null?void 0:i(r);if(z==null){A(50);return}const V=typeof z=="number"?z:Number.parseFloat(String(z));A(Number.isFinite(V)?kn(V):50)},[i,r]),c.useEffect(()=>{if(!x){D(null),Y(null);return}const z=yg(x);D(V=>V&&x.shells.some(fe=>fe.id===V&&pt(fe))?V:(z==null?void 0:z.id)??null),Y(V=>{if($!=="columns")return null;if(V&&x.shells.some(Le=>Le.id===V&&pt(Le)))return V;const fe=x.shells.find(Le=>pt(Le)&&Le.id!==(z==null?void 0:z.id));return(fe==null?void 0:fe.id)??null})},[x,$]),c.useEffect(()=>{$!=="columns"&&(K("primary"),Y(null))},[$]),c.useEffect(()=>{if($!=="columns"||Z||ie.length<2)return;const z=ie.find(V=>V.id!==(ve==null?void 0:ve.id))??null;z&&Y(z.id)},[ie,ve==null?void 0:ve.id,Z,$]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const z=window.matchMedia("(max-width: 767px), (hover: none) and (pointer: coarse)"),V=()=>{U(z.matches),z.matches||(X(!1),C(!1))};return V(),z.addEventListener("change",V),()=>{z.removeEventListener("change",V)}},[]),c.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current),b.current!==null&&window.cancelAnimationFrame(b.current)},[]);const ue=c.useCallback((z,V)=>{le(fe=>{const Le=fe[z];return wg(Le,V)?fe:{...fe,[z]:V}})},[]),R=c.useCallback(z=>ue("primary",z),[ue]),M=c.useCallback(z=>ue("secondary",z),[ue]),ee=c.useCallback(z=>{var fe;if((fe=z.label)!=null&&fe.trim())return z.label.trim();const V=xe.findIndex(Le=>Le.id===z.id);return`Shell ${V>=0?V+1:""}`.trim()},[xe]),pe=c.useCallback(z=>{var V;I(z.id),O(((V=z.label)==null?void 0:V.trim())||ee(z))},[ee]),ke=c.useCallback(()=>{I(null),O("")},[]),Ae=c.useCallback(async()=>{if(J){N(!0);try{const z=q.trim(),V=await n.updateShell(J,{label:z.length>0?z:null});y(fe=>{var Le;return fe&&{...fe,state:fe.activeShellId===V.id?V.status:fe.state,shell:((Le=fe.shell)==null?void 0:Le.id)===V.id?V:fe.shell,shells:fe.shells.map(ne=>ne.id===V.id?V:ne)}}),I(null),O(""),L(null)}catch(z){L(z instanceof Error?z.message:"Unable to rename shell.")}finally{N(!1)}}},[q,J,n]),Ne=c.useCallback((z,V)=>{if(z==="primary"){D(V),Y(fe=>fe===V?null:fe);return}Y(V),D(fe=>fe===V?null:fe)},[]),De=c.useCallback(z=>{var V,fe;if(z==="primary"){(V=m.current)==null||V.disconnect(),D(null),$==="columns"&&K("secondary");return}(fe=f.current)==null||fe.disconnect(),Y(null),K("primary"),te("single")},[$]),et=c.useCallback((z,V=P)=>{const fe=$==="columns"?V:"primary";Ne(fe,z.id),$!=="columns"&&Y(null),K(fe)},[P,Ne,$]),Ve=c.useCallback(async(z=P)=>{var V;if(!w.current){w.current=!0,N(!0);try{const fe=await n.createShell(r);y(fe);const Le=fe.activeShellId??((V=fe.shell)==null?void 0:V.id)??null;if(Le){const ne=$==="columns"?z:"primary";Ne(ne,Le),$!=="columns"&&Y(null),K(ne)}L(null)}catch(fe){L(fe instanceof Error?fe.message:"Unable to create shell.")}finally{w.current=!1,N(!1)}}},[P,Ne,n,$,r]);c.useEffect(()=>{!a||!x||k||v||je||re==="creating"||ie.length>0||Ve("primary")},[v,Ve,a,ie.length,k,x,re,je]);const ot=c.useCallback(async(z=(se==null?void 0:se.id)??"")=>{if(z){N(!0);try{await n.terminateShell(z),D(V=>V===z?null:V),Y(V=>V===z?null:V),await _(),L(null)}catch(V){L(V instanceof Error?V.message:"Unable to terminate shell.")}finally{N(!1)}}},[se==null?void 0:se.id,_,n]),Qe=c.useCallback(async()=>{var z,V;if(!ge){if(ye.shellInputEnabled){(z=G.current)==null||z.disconnect();return}if(!se||se.status==="exited"||se.status==="not_found"){await Ve(P);return}await((V=G.current)==null?void 0:V.reconnect())}},[P,G,ye.shellInputEnabled,se,ge,Ve]),ut=c.useCallback(z=>{typeof window>"u"||d==null||d(r,kn(z))},[d,r]),at=c.useCallback(()=>{var z,V;(z=m.current)==null||z.refreshLayout({syncBackendSize:!0}),(V=f.current)==null||V.refreshLayout({syncBackendSize:!0})},[]),Oe=c.useCallback(z=>{var Ge,He;if($!=="columns")return;const V=g.current;if(!V)return;z.preventDefault(),(He=(Ge=z.currentTarget).setPointerCapture)==null||He.call(Ge,z.pointerId);const fe=Fe=>{const qe=V.getBoundingClientRect();if(qe.width<=0)return;const dt=kn((Fe-qe.left)/qe.width*100);A(dt),b.current!==null&&window.cancelAnimationFrame(b.current),b.current=window.requestAnimationFrame(()=>{b.current=null,at()})},Le=Fe=>{fe(Fe.clientX)},ne=Fe=>{fe(Fe.clientX);const qe=V.getBoundingClientRect();qe.width>0&&ut((Fe.clientX-qe.left)/qe.width*100),window.removeEventListener("pointermove",Le),window.removeEventListener("pointerup",ne)};window.addEventListener("pointermove",Le),window.addEventListener("pointerup",ne,{once:!0})},[ut,at,$]),Be=c.useCallback((z,V)=>{Ne(V,z.id),K(V)},[Ne]),Ue=c.useCallback(async()=>{var V;return await((V=G.current)==null?void 0:V.copyLastCommandOutput())?!0:(Ee("failed","Nothing to copy"),!1)},[G,Ee]);c.useEffect(()=>{h==null||h(Ng({activeRuntime:ye,activeShell:se,connectionButtonDisabled:ge,connectionButtonLabel:we,isMobileShell:T,busy:v,loading:k,error:S}))},[ye,se,v,ge,we,S,T,k,h]),c.useImperativeHandle(u,()=>({async toggleConnection(){await Qe()},sendInput(z){var V;return((V=G.current)==null?void 0:V.sendInput(z))??!1},sendCommand(z){var V;return((V=G.current)==null?void 0:V.sendCommand(z))??!1},sendControl(z){var V;return((V=G.current)==null?void 0:V.sendControl(z))??!1},async copyLastCommandOutput(){var z;return await((z=G.current)==null?void 0:z.copyLastCommandOutput())??!1},async terminate(){await ot()},focus(){var z;(z=G.current)==null||z.focus()},refreshLayout(z){var V,fe;(V=m.current)==null||V.refreshLayout(z),$==="columns"&&((fe=f.current)==null||fe.refreshLayout(z))}}),[G,Qe,ot,$]);const tt=z=>t.jsx("div",{className:`rounded-md border px-2 py-1.5 text-xs ${z.id===(se==null?void 0:se.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:[J===z.id?t.jsx("form",{className:"min-w-0 flex-1",onSubmit:V=>{V.preventDefault(),Ae()},children:t.jsx("input",{value:q,onChange:V=>O(V.currentTarget.value),onKeyDown:V=>{V.key==="Escape"&&(V.preventDefault(),ke())},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:()=>et(z),onDoubleClick:()=>pe(z),className:"min-w-0 flex-1 text-left",title:z.tmuxSessionName,children:[t.jsx("span",{className:"block truncate",children:ee(z)}),t.jsxs("span",{className:"block truncate text-[10px] text-[var(--theme-fg-muted)]",children:[vn(z.status)," · ",en(z.cwd)||z.cwd]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[J===z.id?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>void Ae(),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:ke,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:()=>pe(z),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"}),$==="columns"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>Be(z,"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:()=>Be(z,"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 ot(z.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"})]})]})},z.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:ye.promptLabel??(se==null?void 0:se.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} (${vn(ye.status)})`,disabled:ge,onClick:()=>void Qe(),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 ${_e}`,children:t.jsx(Jf,{connected:ye.shellInputEnabled})}),se&&t.jsx("button",{type:"button",disabled:v,onClick:()=>void ot(se.id),className:"rounded-full border border-rose-300/35 bg-rose-300/12 px-3 py-2 text-sm text-rose-600 transition hover:bg-rose-300/18 dark:text-rose-100 disabled:cursor-not-allowed disabled:opacity-60",children:"Terminate"})]})]}),(S||k||je)&&t.jsxs("div",{className:"shell-banner mt-3 rounded-2xl border px-3 py-3 text-sm",children:[k&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!k&&je&&t.jsx("p",{className:"text-rose-600 dark:text-rose-100",children:"Workspace path is missing on this machine. Restore the path before creating a shell."}),!k&&S&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:S})]})]}),t.jsx("div",{className:"min-h-0 flex-1",children:t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("div",{className:"shell-terminal-bar flex shrink-0 items-center gap-2 border-b px-2 py-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-1",children:[t.jsx("span",{className:"min-w-0 truncate text-xs text-[var(--theme-fg-soft)]",children:se?ee(se):"No live shell process"}),se&&t.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.12em] text-[var(--theme-fg-muted)]",children:vn(ye.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 ",ie.length]}),t.jsx("button",{type:"button","aria-expanded":H,"aria-label":H?"Hide shell processes":"Show shell processes",onClick:()=>C(z=>!z),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"})]})]}),H&&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:[ie.length," live"]})]}),t.jsxs("div",{className:"max-h-52 space-y-1 overflow-y-auto",children:[ie.map(tt),ie.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||k||je,onClick:()=>void Ve(P),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:"+"})})]}),re==="not_created"||je?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."}),!je&&t.jsx("button",{type:"button",disabled:v||k,onClick:()=>void Ve("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&&(S||k||je)&&t.jsxs("div",{className:"shell-banner absolute left-2 right-2 top-2 z-10 rounded-2xl border px-3 py-3 text-sm backdrop-blur sm:left-3 sm:right-3 sm:top-3",children:[k&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!k&&je&&t.jsx("p",{className:"text-rose-600 dark:text-rose-100",children:"Workspace path is missing on this machine. Restore the path before creating a shell."}),!k&&S&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:S})]}),t.jsxs("div",{ref:g,className:`relative grid h-full min-h-0 ${$==="columns"?"grid-cols-1 sm:grid-cols-[var(--shell-left)_0.35rem_var(--shell-right)]":"grid-cols-1"}`,style:$==="columns"?{"--shell-left":`${oe}fr`,"--shell-right":`${100-oe}fr`}:void 0,"data-shell-split-ratio":oe,children:[t.jsx(Is,{ref:m,paneId:"primary",shell:ve,isActive:P==="primary",isVisible:a,isMobileShell:T,effectiveTheme:l,workspacePathMissing:je,shellAdapter:n,onActivate:()=>K("primary"),onShellUpdate:Me,onRuntimeStateChange:R,onFeedback:Ee}),$==="columns"&&t.jsx("button",{type:"button",onClick:()=>De("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"}),$==="columns"&&t.jsx("button",{type:"button","aria-label":"Resize shell panes",title:"Resize shell panes",onPointerDown:Oe,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"}),$==="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(Is,{ref:f,paneId:"secondary",shell:Pe,isActive:P==="secondary",isVisible:a,isMobileShell:T,effectiveTheme:l,workspacePathMissing:je,shellAdapter:n,onActivate:()=>K("secondary"),onShellUpdate:Me,onRuntimeStateChange:M,onFeedback:Ee}),t.jsx("button",{type:"button",onClick:()=>De("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:[Q&&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 ${Re}`,children:Q.text}),E&&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:()=>{Ee("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(Ls,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:()=>void Ue(),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(Ls,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:!ye.shellInputEnabled,onClick:()=>{var z;(z=G.current)!=null&&z.sendControl("clear")?Ee("done","Cleared"):Ee("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(wn,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!ye.shellInputEnabled||!ye.isCommandRunning,onClick:()=>{var z;(z=G.current)!=null&&z.sendInput("")?Ee("done","Sent Ctrl-C"):Ee("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(wn,{label:"CTRL-C",tone:"rose"})}),["ctrl_d","esc","tab","up","down"].map(z=>t.jsx("button",{type:"button",disabled:!ye.shellInputEnabled,onClick:()=>{var V;(V=G.current)!=null&&V.sendControl(z)?Ee("done",`Sent ${z.toUpperCase().replace("_","-")}`):Ee("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(wn,{label:z.toUpperCase().replace("_","-"),tone:"stone"})},z))]})}),t.jsx("button",{type:"button","aria-expanded":E,"aria-label":E?"Close shell tools":"Open shell tools",onClick:()=>X(z=>!z),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(Zf,{})})]})]}),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:[ie.length," live"]})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-1 overflow-y-auto",children:[ie.map(tt),ie.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||k||je,onClick:()=>void Ve(P),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:"+"})})]})]})]})})]})}),Og=c.lazy(async()=>({default:(await Promise.resolve().then(()=>(ru(),Xo))).ThreadGraphWorkspacePanel}));function Ug(){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 wl(e){return t.jsx(c.Suspense,{fallback:t.jsx(Ug,{}),children:t.jsx(Og,{...e})})}c.memo(wl);function ix({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?Or.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 Wg(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 Vg(e){switch(e){case"inProgress":return"running";case"completed":return"completed";case"interrupted":return"interrupted";case"failed":return"failed"}}function Kg(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 qg(e){switch(e){case"latest-3":return 3;case"latest-10":return 10;case"latest-20":return 20;default:return null}}function Xg(e){return e==="read"?"View only":"Collaborator"}function Yg(e){switch(e){case"write":return"Workspace write";case"read":return"Workspace read";case"none":default:return"No workspace"}}function dx({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}){var T,U,H;const f=c.useMemo(()=>{var C;return((C=n.data)==null?void 0:C.turns)??[]},[(T=n.data)==null?void 0:T.turns]),[p,g]=c.useState(l),[b,w]=c.useState("latest-10"),[x,y]=c.useState(()=>new Set),[k,j]=c.useState(!0),[v,N]=c.useState(""),[S,L]=c.useState("read"),[P,K]=c.useState("none"),[F,D]=c.useState(""),[Z,Y]=c.useState(()=>typeof document<"u"&&!document.documentElement.classList.contains("dark")?"light":"dark");if(c.useEffect(()=>{e&&(g(l),w("latest-10"),j(!0),N(""),L("read"),K("none"),D(""),d())},[l,d,e]),c.useEffect(()=>{e&&f.length>0&&y(new Set(f.slice(0,10).map(C=>C.turnId)))},[e,f]),c.useEffect(()=>{if(!e)return;function C(E){E.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"),E=()=>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(Y(E()),!C)return;const X=new MutationObserver(()=>Y(E()));return X.observe(C,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>X.disconnect()},[e]),!e)return null;const $=qg(b),te=$!==null?Math.min($,((U=n.data)==null?void 0:U.totalTurnCount)??$):b==="all-loaded"?f.length:x.size,oe=!r&&p!=="share"&&($!==null||b==="all-loaded"||x.size>0),A=!r&&a&&!!u&&v.trim().length>0;function J(C){y(E=>{const X=new Set(E);return X.has(C)?X.delete(C):X.add(C),X})}function I(){if(p==="share")return;const C={format:p,...$!==null?{mode:"latest",limit:$}:b==="all-loaded"?{mode:"selected",turnIds:f.map(E=>E.turnId)}:{mode:"selected",turnIds:[...x]},profile:"review",options:{includeTokenAndPrice:k}};h(C)}function q(C){C.preventDefault(),A&&(u==null||u({targetIdentifier:v.trim(),threadAccess:S,workspaceAccess:P,label:F.trim()||null}))}const O=[{mode:"pdf",label:"PDF"},{mode:"html",label:"HTML"},{mode:"share",label:"Share"}];return Or.createPortal(t.jsxs("div",{className:`thread-export-dialog-root thread-ui-theme-${Z} fixed inset-0 z-[96] flex items-end justify-center p-0 sm:items-center sm:p-6`,"data-theme-effective":Z,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 relay session."})]}),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:O.map(C=>t.jsx("button",{type:"button",onClick:()=>g(C.mode),className:`rounded-full px-3 py-1.5 text-sm transition ${p===C.mode?"ui-status-warning":"thread-export-dialog-muted-action"}`,children:C.label},C.mode))}),p==="share"?t.jsxs("form",{id:"thread-actions-share-form",className:"mt-4 space-y-4",onSubmit:q,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}),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:v})]}),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,E])=>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:S===C,disabled:!a||r,onChange:()=>L(C)}),E]},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,E])=>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:()=>K(C)}),E]},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=>D(C.target.value),placeholder:"optional",value:F})]}),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} · `:"",Xg(C.threadAccess)," / ",Yg(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:b,onChange:C=>w(C.target.value),children:["latest-3","latest-10","latest-20","all-loaded","custom"].map(C=>t.jsx("option",{value:C,children:Kg(C)},C))})]}),b==="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 ",x.size," of ",((H=n.data)==null?void 0:H.totalTurnCount)??f.length]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>y(new Set(f.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:f.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:x.has(C.turnId),onChange:()=>J(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:Wg(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:Vg(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:k,onChange:C=>j(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:p==="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:p==="share"?a?"Share access is enforced by the relay server.":"Share permissions are not wired yet.":`${te} ${te===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"}),p==="share"?t.jsx("button",{type:"submit",form:"thread-actions-share-form",disabled:!A,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 session"}):t.jsx("button",{type:"button",onClick:I,disabled:!oe,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 ${p.toUpperCase()}`})]})]})]})]}),document.body)}function jn(e){if(e===void 0)return"-";if(Math.abs(e)>1e4){const r=Math.abs(e)>=1e5?0:1;return`${(e/1e3).toLocaleString(void 0,{maximumFractionDigits:r})}k`}return e.toLocaleString()}function Zg(e){const r=`in ${jn(e.input)} / out ${jn(e.output)} / cache ${jn(e.cache)}`;return e.pricedTurns>0?`${r} / cost ${sa(e.priceUsd)}`:r}function Jg({detail:e,adapter:r,timelineAdapter:n,TimelineComponent:a=xl,liveOutput:o="",beforeTimelineContent:s,composerProps:l,timelineProps:i,threadUsageSummary:d,transcriptItemCount:h,useFloatingMobileComposer:u=!1,floatingMobileComposerBottomOffset:m=0,composerHostRef:f}){const[p,g]=c.useState(!1),[b,w]=c.useState(0),[x,y]=c.useState(0),[k,j]=c.useState(0),[v,N]=c.useState(!1),S=c.useRef(null),L=i==null?void 0:i.onTailVisibilityChange,P=e.pendingRequests.length>0,K=c.useCallback(J=>{L==null||L(J)},[L]);c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const J=window.matchMedia("(max-width: 639px)"),I=()=>g(J.matches);return I(),J.addEventListener("change",I),()=>{J.removeEventListener("change",I)}},[]),c.useEffect(()=>{var I,q;if(typeof window>"u")return;const J=()=>{const O=window.visualViewport,T=O?Math.max(0,Math.round(window.innerHeight-O.height-O.offsetTop)):0,U=O?Math.max(0,Math.round(window.innerHeight-O.height)):T,H=Math.min(T,U),C=Math.max(0,Math.round(window.innerHeight*.52));j(Math.min(H,C))};return J(),(I=window.visualViewport)==null||I.addEventListener("resize",J),(q=window.visualViewport)==null||q.addEventListener("scroll",J),window.addEventListener("resize",J),()=>{var O,T;(O=window.visualViewport)==null||O.removeEventListener("resize",J),(T=window.visualViewport)==null||T.removeEventListener("scroll",J),window.removeEventListener("resize",J)}},[]),c.useLayoutEffect(()=>{const J=S.current;if(!J||!p){w(0);return}const I=()=>{w(Math.ceil(J.getBoundingClientRect().height))};if(I(),typeof ResizeObserver>"u")return;const q=new ResizeObserver(I);return q.observe(J),()=>{q.disconnect()}},[p,l,P]),c.useLayoutEffect(()=>{var O,T;const J=S.current;if(!J||!p){y(0);return}const I=()=>{const U=J.getBoundingClientRect();y(Math.max(0,Math.ceil(window.innerHeight-U.top)))};I(),window.addEventListener("resize",I),(O=window.visualViewport)==null||O.addEventListener("resize",I),(T=window.visualViewport)==null||T.addEventListener("scroll",I);let q=null;return typeof ResizeObserver<"u"&&(q=new ResizeObserver(I),q.observe(J)),()=>{var U,H;window.removeEventListener("resize",I),(U=window.visualViewport)==null||U.removeEventListener("resize",I),(H=window.visualViewport)==null||H.removeEventListener("scroll",I),q==null||q.disconnect()}},[p,k,v,l,P]),c.useEffect(()=>{if(!p){N(!1);return}const J=q=>{var T;const O=q.target;O instanceof HTMLElement&&((T=S.current)!=null&&T.contains(O))&&N(!0)},I=q=>{var T;const O=q.relatedTarget;O instanceof HTMLElement&&((T=S.current)!=null&&T.contains(O))||N(!1)};return document.addEventListener("focusin",J),document.addEventListener("focusout",I),()=>{document.removeEventListener("focusin",J),document.removeEventListener("focusout",I)}},[p]);const F=c.useCallback(J=>{S.current=J,f&&(f.current=J)},[f]),D=p&&v?Math.max(0,k-m):0,Z=Math.max(b,144),Y=Math.max(x,Z+D),$=p?Y+12:0,te=$>0?{"--thread-graph-chat-scroll-bottom-spacer":`${$}px`}:void 0,oe=u&&p?{bottom:`${m+D}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"}:void 0,A=c.useMemo(()=>{const J=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:J,liveOutput:o,className:"thread-timeline-surface min-h-0 flex-1",...i,adapter:n,onOpenThread:(i==null?void 0:i.onOpenThread)??r.openThread,onTailVisibilityChange:K})},[a,r.openThread,e.pendingRequests,e.thread.activeTurnId,e.thread.id,e.thread.status,e.totalTurnCount,e.turns,K,o,n,i]);return t.jsxs("div",{"data-testid":"chat-panel",className:"thread-graph-chat-panel relative flex h-full min-h-0 flex-col",style:te,children:[s,A,t.jsxs("div",{className:"thread-chat-usage-footer hidden shrink-0 items-center justify-between gap-3 px-4 py-1 text-[10px] leading-4 sm:flex",children:[t.jsxs("span",{className:"min-w-0 truncate",children:[e.turns.length," turn",e.turns.length!==1?"s":"",t.jsx("span",{className:"mx-1 text-[var(--theme-border-contrast)]",children:"|"}),h," item",h!==1?"s":""]}),t.jsxs("span",{className:"shrink-0",children:["Usage"," ",d&&d.turns>0?Zg(d):"waiting for agent usage"]})]}),l?u?t.jsx("div",{ref:F,className:"fixed inset-x-0 bottom-0 z-50 overflow-visible sm:hidden",style:oe??{bottom:`${m}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"},children:t.jsx(Dn,{...l,activeView:"chat",edgeToEdgeMobile:!0,onSubmit:r.sendPrompt})}):t.jsx("div",{ref:F,className:"thread-graph-composer-host shrink-0",children:t.jsx(Dn,{...l,activeView:"chat",onSubmit:r.sendPrompt})}):null]})}function Qg(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,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,priceUsd:0,pricedTurns:0,turns:0})}function Nn(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?"0":e>=1e6?`${(e/1e6).toFixed(e>=1e7?0:1)}m`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(Math.round(e))}function ex(e){if(!e||e.turns<=0)return"waiting for agent usage";const r=`in ${Nn(e.input)} / out ${Nn(e.output)} / cache ${Nn(e.cache)}`;return e.pricedTurns>0?`${r} / cost ${sa(e.priceUsd)}`:r}function cx({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:y,floatingPanel:k,workspaceContent:j,workspaceTitle:v,workspaceActions:N,workspaceFeatures:S,workspaceFocusPathRequest:L=null,onNewThreadTitle:P,beforeTimelineContent:K,errorContent:F,workspaceMissingContent:D,dialogs:Z,currentThreadId:Y,currentWorkspaceId:$,currentWorkspaceLabel:te,onCloseAppNavigation:oe,className:A="thread-detail-surface relative flex h-full min-h-0 flex-1 flex-col overflow-hidden",activeView:J="chat",liveOutput:I="",timelineProps:q,composerProps:O,shellComposerProps:T,useFloatingMobileComposer:U=!1,floatingMobileComposerBottomOffset:H=0,composerHostRef:C,shellPanelRef:E,shellEffectiveTheme:X="dark",shellThemeMode:W=X,onShellThemeModeChange:le,onShellStateChange:Q,shellUnavailableContent:de,shellDisconnectedContent:re,timelineComponent:xe=xl,shellPanelComponent:ie=Hg,shellContent:ve,loadingContent:Pe,emptyContent:se}){const ye=na(),je=s??ye??ta(),{getImageAssetUrl:G,loadHistoryItemDetail:me,openWorkspaceFile:ge,openThread:we,cancelPendingSteer:_e}=l,Re=c.useMemo(()=>({...G?{getImageAssetUrl:pe=>G(pe.path)}:{},onOpenLinkedThread:we,...ge?{onOpenWorkspaceFile:ge}:{},...me?{onLoadHistoryItemDetail:me}:{},..._e?{cancelPendingSteer:_e}:{}}),[_e,G,me,ge,we]),Ee=je.getThreadPanels().some(pe=>pe.kind==="terminal"),Me=c.useMemo(()=>r?Qg(r):null,[r]),_=c.useMemo(()=>ex(Me),[Me]),ue=c.useMemo(()=>{var pe;return r?r.turns.reduce((ke,Ae)=>ke+Ae.items.length,((pe=r.liveItems)==null?void 0:pe.items.length)??0):0},[r]),R=j??(r?t.jsx(wl,{detail:r,status:o,plugins:je,workspaceAdapter:l.workspace??null,metaContent:i,settingsContent:d,activeView:J,features:S,focusPathRequest:L}):null),M=n?Pe??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:A,children:[k?t.jsx("div",{className:"fixed right-3 top-20 z-50 lg:absolute lg:right-4 lg:top-16",children:k}):null,a&&!n&&(F??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:J==="chat"?"flex min-h-0 flex-1 flex-col":"hidden",children:t.jsx(Jg,{detail:r,adapter:l,timelineAdapter:Re,TimelineComponent:xe,liveOutput:I,threadUsageSummary:Me,transcriptItemCount:ue,useFloatingMobileComposer:U,floatingMobileComposerBottomOffset:H,...K?{beforeTimelineContent:K}:{},...O?{composerProps:O}:{},...q?{timelineProps:q}:{},...C?{composerHostRef:C}:{}})}),t.jsxs("div",{className:J==="shell"?"flex min-h-0 flex-1 flex-col":"hidden",children:[ve??(r.thread.isLoaded&&Ee&&l.shell?t.jsx(ie,{ref:E,threadId:r.thread.id,shellAdapter:l.shell,effectiveTheme:X,isVisible:J==="shell",showHeader:!1,showFloatingToolbox:!1,...Q?{onStateChange:Q}:{}}):r.thread.isLoaded&&!Ee?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."})]})}):re??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."})]})})),J==="shell"&&T&&!ve?t.jsx(Dn,{...T,activeView:"shell",onSubmit:l.sendPrompt}):null]}),Z]}):se??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."}),ee=t.jsx(Zm,{threads:e,status:o,loading:n,error:n?null:a,viewportConstrained:!0,currentThreadId:Y??(r==null?void 0:r.thread.id),currentThreadLabel:r==null?void 0:r.thread.title,currentWorkspaceId:$??(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:_,threadActionsButton:x,topbarActions:y,metaContent:i,settingsContent:d,globalSettingsContent:h,...u!==void 0?{settingsDialogOpen:u}:{},...m?{onSettingsDialogOpenChange:m}:{},mobileHeaderAction:f,effectiveTheme:X,themeMode:W,appMenuButton:p,appNavigationMenu:g,workspaceReturnHref:b,...w?{onWorkspaceReturn:w}:{},showMobileAppMenu:!!p,showMobileThreadNavToggle:!0,showMobileNewThreadShortcut:!1,onOpenThread:l.openThread,workspaceContent:R,workspaceTitle:v??"Workspace",workspaceActions:N,...P?{onNewThreadTitle:P}:{},...oe?{onCloseAppNavigation:oe}:{},...le?{onThemeModeChange:le}:{},...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:M});return s?t.jsx(ra.Provider,{value:je,children:ee}):ee}var tx={},rx=[];function hx({adapter:e=tx,builtinPlugins:r=rx,children:n}){const[a,o]=c.useState(()=>Bn(r,[])),[s,l]=c.useState(!1),[i,d]=c.useState(null),h=c.useCallback(async()=>{l(!0),d(null);try{const k=e.fetchPlugins?await e.fetchPlugins():[];o(Bn(r,k))}catch(k){d(k instanceof Error?k.message:"Unable to load plugins.")}finally{l(!1)}},[e,r]);c.useEffect(()=>{h()},[h]);const u=c.useCallback(async(k,j)=>{if(e.updatePlugin){const v=await e.updatePlugin(k,{enabled:j});o(N=>N.map(S=>S.id===v.id?v:S));return}o(v=>v.map(N=>N.id===k?{...N,enabled:j}:N))},[e]),m=c.useCallback(async k=>{if(!e.importPlugin)throw new Error("Plugin import is not available.");const j=await e.importPlugin(k);o(v=>[...v.filter(S=>S.id!==j.id),j])},[e]),f=c.useCallback(async k=>{if(!e.deletePlugin)throw new Error("Plugin uninstall is not available.");const j=await e.deletePlugin(k);o(v=>v.filter(N=>N.id!==j.id))},[e]),p=c.useMemo(()=>{const k=new Set(a.filter(j=>j.enabled).map(j=>j.id));return r.filter(j=>k.has(j.manifest.id))},[r,a]),g=c.useCallback(k=>{var v;const j=p.find(N=>N.renderArtifact&&N.manifest.capabilities.artifactTypes.some(S=>S.type===k.artifact.type));return((v=j==null?void 0:j.renderArtifact)==null?void 0:v.call(j,k))??null},[p]),b=c.useCallback(k=>{for(const j of p)for(const v of j.inlineCodeRenderers??[]){if(!v.languages.includes(k.language.trim().toLowerCase()))continue;const N=v.render(k);if(N)return N}return null},[p]),w=c.useCallback(k=>p.some(j=>!!j.renderArtifact&&j.manifest.capabilities.artifactTypes.some(v=>v.type===k.type)),[p]),x=c.useCallback(()=>p.flatMap(k=>k.threadPanels??[]),[p]),y=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(ra.Provider,{value:y,children:n})}export{_m as A,ix as C,Jm as L,hx as P,dx as T,na as a,cx as b,Hg as c,xl as d,Zm as e,Gt as f,Ym as g,Mm as t,el as u};