remote-codex 0.11.34 → 0.11.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/supervisor-web/dist/assets/{index-PHqiYl42.js → index-C14vD5Hp.js} +1 -1
- package/apps/supervisor-web/dist/assets/index-DYIjFImB.css +1 -0
- package/apps/supervisor-web/dist/assets/{thread-ui-DoKAPILv.js → thread-ui-CK1xSLOW.js} +26 -26
- package/apps/supervisor-web/dist/index.html +3 -3
- package/package.json +1 -1
- package/apps/supervisor-web/dist/assets/index-BTG-ELMo.css +0 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/core-DODVy7wn.js","assets/markdown-vendor-RZk8L7-L.js","assets/react-vendor-Dfg_6BLf.js","assets/html-pp8916En.js","assets/javascript-wDzz0qaB.js","assets/css-CLj8gQPS.js","assets/terminal-vendor-C5bTa-Ka.js","assets/terminal-vendor-Beg8tuEN.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{l as B,R as qi,I as Xi,C as Yi,S as Hs,H as Zi,T as Ji,a as Qi,b as ed,c as td,d as rd,e as nd,D as ad,P as sd,O as od,f as ld,g as id,h as dd,i as cd,j as hd,k as ud,m as md,n as pd,A as fd,o as gd,p as xd}from"./ui-vendor-CuR8GHb0.js";import{r as c,R as bd,j as t,b as Zr}from"./react-vendor-Dfg_6BLf.js";import{u as vd,a as kd,H as Sa,P as Gt,b as wd,M as Os,R as yd,i as jd,C as Nd,B as Cd,c as Ta,g as Ws}from"./graph-vendor-DVQUpZ8C.js";import"./terminal-vendor-C5bTa-Ka.js";import{M as Sd,r as Td,a as Ed,b as Ld}from"./markdown-vendor-RZk8L7-L.js";const Id="modulepreload",zd=function(e){return"/"+e},Ea={},Xe=function(r,n,a){let o=Promise.resolve();if(n&&n.length>0){let l=function(h){return Promise.all(h.map(u=>Promise.resolve(u).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),d=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));o=l(n.map(h=>{if(h=zd(h),h in Ea)return;Ea[h]=!0;const u=h.endsWith(".css"),m=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${m}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":Id,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 Us(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=Us(e[r]))&&(a&&(a+=" "),a+=n)}else for(n in e)e[n]&&(a&&(a+=" "),a+=n);return a}function Vs(){for(var e,r,n=0,a="",o=arguments.length;n<o;n++)(e=arguments[n])&&(r=Us(e))&&(a&&(a+=" "),a+=r);return a}const Pd=(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},Rd=(e,r)=>({classGroupId:e,validator:r}),Ks=(e=new Map,r=null,n)=>({nextPart:e,validators:r,classGroupId:n}),Vr="-",La=[],Md="arbitrary..",Ad=e=>{const r=_d(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:a}=e;return{getClassGroupId:l=>{if(l.startsWith("[")&&l.endsWith("]"))return $d(l);const i=l.split(Vr),d=i[0]===""&&i.length>1?1:0;return qs(i,d,r)},getConflictingClassGroupIds:(l,i)=>{if(i){const d=a[l],h=n[l];return d?h?Pd(h,d):d:h||La}return n[l]||La}}},qs=(e,r,n)=>{if(e.length-r===0)return n.classGroupId;const o=e[r],s=n.nextPart.get(o);if(s){const h=qs(e,r+1,s);if(h)return h}const l=n.validators;if(l===null)return;const i=r===0?e.join(Vr):e.slice(r).join(Vr),d=l.length;for(let h=0;h<d;h++){const u=l[h];if(u.validator(i))return u.classGroupId}},$d=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?Md+a:void 0})(),_d=e=>{const{theme:r,classGroups:n}=e;return Dd(n,r)},Dd=(e,r)=>{const n=Ks();for(const a in e){const o=e[a];ea(o,n,a,r)}return n},ea=(e,r,n,a)=>{const o=e.length;for(let s=0;s<o;s++){const l=e[s];Bd(l,r,n,a)}},Bd=(e,r,n,a)=>{if(typeof e=="string"){Gd(e,r,n);return}if(typeof e=="function"){Fd(e,r,n,a);return}Hd(e,r,n,a)},Gd=(e,r,n)=>{const a=e===""?r:Xs(r,e);a.classGroupId=n},Fd=(e,r,n,a)=>{if(Od(e)){ea(e(a),r,n,a);return}r.validators===null&&(r.validators=[]),r.validators.push(Rd(n,e))},Hd=(e,r,n,a)=>{const o=Object.entries(e),s=o.length;for(let l=0;l<s;l++){const[i,d]=o[l];ea(d,Xs(r,i),n,a)}},Xs=(e,r)=>{let n=e;const a=r.split(Vr),o=a.length;for(let s=0;s<o;s++){const l=a[s];let i=n.nextPart.get(l);i||(i=Ks(),n.nextPart.set(l,i)),n=i}return n},Od=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Wd=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)}}},Rn="!",Ia=":",Ud=[],za=(e,r,n,a,o)=>({modifiers:e,hasImportantModifier:r,baseClassName:n,maybePostfixModifierPosition:a,isExternal:o}),Vd=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 v=o[b];if(l===0&&i===0){if(v===Ia){s.push(o.slice(d,b)),d=b+1;continue}if(v==="/"){h=b;continue}}v==="["?l++:v==="]"?l--:v==="("?i++:v===")"&&i--}const m=s.length===0?o:o.slice(d);let f=m,p=!1;m.endsWith(Rn)?(f=m.slice(0,-1),p=!0):m.startsWith(Rn)&&(f=m.slice(1),p=!0);const g=h&&h>d?h-d:void 0;return za(s,p,f,g)};if(r){const o=r+Ia,s=a;a=l=>l.startsWith(o)?s(l.slice(o.length)):za(Ud,!1,l,void 0,!0)}if(n){const o=a;a=s=>n({className:s,parseClassName:o})}return a},Kd=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}},qd=e=>({cache:Wd(e.cacheSize),parseClassName:Vd(e),sortModifiers:Kd(e),postfixLookupClassGroupIds:Xd(e),...Ad(e)}),Xd=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},Yd=/\s+/,Zd=(e,r)=>{const{parseClassName:n,getClassGroupId:a,getConflictingClassGroupIds:o,sortModifiers:s,postfixLookupClassGroupIds:l}=r,i=[],d=e.trim().split(Yd);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,j;if(x){const N=b.substring(0,v);j=a(N);const L=j&&l[j]?a(b):void 0;L&&L!==j&&(j=L,x=!1)}else j=a(b);if(!j){if(!x){h=m+(h.length>0?" "+h:h);continue}if(j=a(b),!j){h=m+(h.length>0?" "+h:h);continue}x=!1}const w=p.length===0?"":p.length===1?p[0]:s(p).join(":"),y=g?w+Rn:w,k=y+j;if(i.indexOf(k)>-1)continue;i.push(k);const S=o(j,x);for(let N=0;N<S.length;++N){const L=S[N];i.push(y+L)}h=m+(h.length>0?" "+h:h)}return h},Jd=(...e)=>{let r=0,n,a,o="";for(;r<e.length;)(n=e[r++])&&(a=Ys(n))&&(o&&(o+=" "),o+=a);return o},Ys=e=>{if(typeof e=="string")return e;let r,n="";for(let a=0;a<e.length;a++)e[a]&&(r=Ys(e[a]))&&(n&&(n+=" "),n+=r);return n},Qd=(e,...r)=>{let n,a,o,s;const l=d=>{const h=r.reduce((u,m)=>m(u),e());return n=qd(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=Zd(d,n);return o(d,u),u};return s=l,(...d)=>s(Jd(...d))},ec=[],Qe=e=>{const r=n=>n[e]||ec;return r.isThemeGetter=!0,r},Zs=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Js=/^\((?:(\w[\w-]*):)?(.+)\)$/i,tc=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,rc=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,nc=/\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$/,ac=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,sc=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,oc=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,St=e=>tc.test(e),Pe=e=>!!e&&!Number.isNaN(Number(e)),ft=e=>!!e&&Number.isInteger(Number(e)),xn=e=>e.endsWith("%")&&Pe(e.slice(0,-1)),wt=e=>rc.test(e),Qs=()=>!0,lc=e=>nc.test(e)&&!ac.test(e),ta=()=>!1,ic=e=>sc.test(e),dc=e=>oc.test(e),cc=e=>!he(e)&&!me(e),hc=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)),uc=e=>zt(e,ro,ta),he=e=>Zs.test(e),_t=e=>zt(e,no,lc),Pa=e=>zt(e,kc,Pe),mc=e=>zt(e,so,Qs),pc=e=>zt(e,ao,ta),Ra=e=>zt(e,eo,ta),fc=e=>zt(e,to,dc),zr=e=>zt(e,oo,ic),me=e=>Js.test(e),ur=e=>Vt(e,no),gc=e=>Vt(e,ao),Ma=e=>Vt(e,eo),xc=e=>Vt(e,ro),bc=e=>Vt(e,to),Pr=e=>Vt(e,oo,!0),vc=e=>Vt(e,so,!0),zt=(e,r,n)=>{const a=Zs.exec(e);return a?a[1]?r(a[1]):n(a[2]):!1},Vt=(e,r,n=!1)=>{const a=Js.exec(e);return a?a[1]?r(a[1]):n:!1},eo=e=>e==="position"||e==="percentage",to=e=>e==="image"||e==="url",ro=e=>e==="length"||e==="size"||e==="bg-size",no=e=>e==="length",kc=e=>e==="number",ao=e=>e==="family-name",so=e=>e==="number"||e==="weight",oo=e=>e==="shadow",wc=()=>{const e=Qe("color"),r=Qe("font"),n=Qe("text"),a=Qe("font-weight"),o=Qe("tracking"),s=Qe("leading"),l=Qe("breakpoint"),i=Qe("container"),d=Qe("spacing"),h=Qe("radius"),u=Qe("shadow"),m=Qe("inset-shadow"),f=Qe("text-shadow"),p=Qe("drop-shadow"),g=Qe("blur"),b=Qe("perspective"),v=Qe("aspect"),x=Qe("ease"),j=Qe("animate"),w=()=>["auto","avoid","all","avoid-page","page","left","right","column"],y=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],k=()=>[...y(),me,he],S=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto","contain","none"],L=()=>[me,he,d],R=()=>[St,"full","auto",...L()],P=()=>[ft,"none","subgrid",me,he],J=()=>["auto",{span:["full",ft,me,he]},ft,me,he],D=()=>[ft,"auto",me,he],Y=()=>["auto","min","max","fr",me,he],Z=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],I=()=>["start","end","center","stretch","center-safe","end-safe"],re=()=>["auto",...L()],oe=()=>[St,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...L()],$=()=>[St,"screen","full","dvw","lvw","svw","min","max","fit",...L()],Q=()=>[St,"screen","full","lh","dvh","lvh","svh","min","max","fit",...L()],_=()=>[e,me,he],ee=()=>[...y(),Ma,Ra,{position:[me,he]}],W=()=>["no-repeat",{repeat:["","x","y","space","round"]}],T=()=>["auto","cover","contain",xc,uc,{size:[me,he]}],K=()=>[xn,ur,_t],G=()=>["","none","full",h,me,he],E=()=>["",Pe,ur,_t],C=()=>["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"],H=()=>[Pe,xn,Ma,Ra],se=()=>["","none",g,me,he],q=()=>["none",Pe,me,he],de=()=>["none",Pe,me,he],te=()=>[Pe,me,he],be=()=>[St,"full",...L()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[wt],breakpoint:[wt],color:[Qs],container:[wt],"drop-shadow":[wt],ease:["in","out","in-out"],font:[cc],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[wt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[wt],shadow:[wt],spacing:["px",Pe],text:[wt],"text-shadow":[wt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",St,he,me,v]}],container:["container"],"container-type":[{"@container":["","normal","size",me,he]}],"container-named":[hc],columns:[{columns:[Pe,he,me,i]}],"break-after":[{"break-after":w()}],"break-before":[{"break-before":w()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:k()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:N()}],"overscroll-x":[{"overscroll-x":N()}],"overscroll-y":[{"overscroll-y":N()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:R()}],"inset-x":[{"inset-x":R()}],"inset-y":[{"inset-y":R()}],start:[{"inset-s":R(),start:R()}],end:[{"inset-e":R(),end:R()}],"inset-bs":[{"inset-bs":R()}],"inset-be":[{"inset-be":R()}],top:[{top:R()}],right:[{right:R()}],bottom:[{bottom:R()}],left:[{left:R()}],visibility:["visible","invisible","collapse"],z:[{z:[ft,"auto",me,he]}],basis:[{basis:[St,"full","auto",i,...L()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Pe,St,"auto","initial","none",he]}],grow:[{grow:["",Pe,me,he]}],shrink:[{shrink:["",Pe,me,he]}],order:[{order:[ft,"first","last","none",me,he]}],"grid-cols":[{"grid-cols":P()}],"col-start-end":[{col:J()}],"col-start":[{"col-start":D()}],"col-end":[{"col-end":D()}],"grid-rows":[{"grid-rows":P()}],"row-start-end":[{row:J()}],"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":Y()}],"auto-rows":[{"auto-rows":Y()}],gap:[{gap:L()}],"gap-x":[{"gap-x":L()}],"gap-y":[{"gap-y":L()}],"justify-content":[{justify:[...Z(),"normal"]}],"justify-items":[{"justify-items":[...I(),"normal"]}],"justify-self":[{"justify-self":["auto",...I()]}],"align-content":[{content:["normal",...Z()]}],"align-items":[{items:[...I(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...I(),{baseline:["","last"]}]}],"place-content":[{"place-content":Z()}],"place-items":[{"place-items":[...I(),"baseline"]}],"place-self":[{"place-self":["auto",...I()]}],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:re()}],mx:[{mx:re()}],my:[{my:re()}],ms:[{ms:re()}],me:[{me:re()}],mbs:[{mbs:re()}],mbe:[{mbe:re()}],mt:[{mt:re()}],mr:[{mr:re()}],mb:[{mb:re()}],ml:[{ml:re()}],"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",...Q()]}],"min-block-size":[{"min-block":["auto",...Q()]}],"max-block-size":[{"max-block":["none",...Q()]}],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,ur,_t]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,vc,mc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",xn,he]}],"font-family":[{font:[gc,pc,r]}],"font-features":[{"font-features":[he]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,me,he]}],"line-clamp":[{"line-clamp":[Pe,"none",me,Pa]}],leading:[{leading:[s,...L()]}],"list-image":[{"list-image":["none",me,he]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",me,he]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:_()}],"text-color":[{text:_()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...C(),"wavy"]}],"text-decoration-thickness":[{decoration:[Pe,"from-font","auto",me,_t]}],"text-decoration-color":[{decoration:_()}],"underline-offset":[{"underline-offset":[Pe,"auto",me,he]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:L()}],"tab-size":[{tab:[ft,me,he]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",me,he]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",me,he]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:ee()}],"bg-repeat":[{bg:W()}],"bg-size":[{bg:T()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},ft,me,he],radial:["",me,he],conic:[ft,me,he]},bc,fc]}],"bg-color":[{bg:_()}],"gradient-from-pos":[{from:K()}],"gradient-via-pos":[{via:K()}],"gradient-to-pos":[{to:K()}],"gradient-from":[{from:_()}],"gradient-via":[{via:_()}],"gradient-to":[{to:_()}],rounded:[{rounded:G()}],"rounded-s":[{"rounded-s":G()}],"rounded-e":[{"rounded-e":G()}],"rounded-t":[{"rounded-t":G()}],"rounded-r":[{"rounded-r":G()}],"rounded-b":[{"rounded-b":G()}],"rounded-l":[{"rounded-l":G()}],"rounded-ss":[{"rounded-ss":G()}],"rounded-se":[{"rounded-se":G()}],"rounded-ee":[{"rounded-ee":G()}],"rounded-es":[{"rounded-es":G()}],"rounded-tl":[{"rounded-tl":G()}],"rounded-tr":[{"rounded-tr":G()}],"rounded-br":[{"rounded-br":G()}],"rounded-bl":[{"rounded-bl":G()}],"border-w":[{border:E()}],"border-w-x":[{"border-x":E()}],"border-w-y":[{"border-y":E()}],"border-w-s":[{"border-s":E()}],"border-w-e":[{"border-e":E()}],"border-w-bs":[{"border-bs":E()}],"border-w-be":[{"border-be":E()}],"border-w-t":[{"border-t":E()}],"border-w-r":[{"border-r":E()}],"border-w-b":[{"border-b":E()}],"border-w-l":[{"border-l":E()}],"divide-x":[{"divide-x":E()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":E()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...C(),"hidden","none"]}],"divide-style":[{divide:[...C(),"hidden","none"]}],"border-color":[{border:_()}],"border-color-x":[{"border-x":_()}],"border-color-y":[{"border-y":_()}],"border-color-s":[{"border-s":_()}],"border-color-e":[{"border-e":_()}],"border-color-bs":[{"border-bs":_()}],"border-color-be":[{"border-be":_()}],"border-color-t":[{"border-t":_()}],"border-color-r":[{"border-r":_()}],"border-color-b":[{"border-b":_()}],"border-color-l":[{"border-l":_()}],"divide-color":[{divide:_()}],"outline-style":[{outline:[...C(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Pe,me,he]}],"outline-w":[{outline:["",Pe,ur,_t]}],"outline-color":[{outline:_()}],shadow:[{shadow:["","none",u,Pr,zr]}],"shadow-color":[{shadow:_()}],"inset-shadow":[{"inset-shadow":["none",m,Pr,zr]}],"inset-shadow-color":[{"inset-shadow":_()}],"ring-w":[{ring:E()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:_()}],"ring-offset-w":[{"ring-offset":[Pe,_t]}],"ring-offset-color":[{"ring-offset":_()}],"inset-ring-w":[{"inset-ring":E()}],"inset-ring-color":[{"inset-ring":_()}],"text-shadow":[{"text-shadow":["none",f,Pr,zr]}],"text-shadow-color":[{"text-shadow":_()}],opacity:[{opacity:[Pe,me,he]}],"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":[Pe]}],"mask-image-linear-from-pos":[{"mask-linear-from":H()}],"mask-image-linear-to-pos":[{"mask-linear-to":H()}],"mask-image-linear-from-color":[{"mask-linear-from":_()}],"mask-image-linear-to-color":[{"mask-linear-to":_()}],"mask-image-t-from-pos":[{"mask-t-from":H()}],"mask-image-t-to-pos":[{"mask-t-to":H()}],"mask-image-t-from-color":[{"mask-t-from":_()}],"mask-image-t-to-color":[{"mask-t-to":_()}],"mask-image-r-from-pos":[{"mask-r-from":H()}],"mask-image-r-to-pos":[{"mask-r-to":H()}],"mask-image-r-from-color":[{"mask-r-from":_()}],"mask-image-r-to-color":[{"mask-r-to":_()}],"mask-image-b-from-pos":[{"mask-b-from":H()}],"mask-image-b-to-pos":[{"mask-b-to":H()}],"mask-image-b-from-color":[{"mask-b-from":_()}],"mask-image-b-to-color":[{"mask-b-to":_()}],"mask-image-l-from-pos":[{"mask-l-from":H()}],"mask-image-l-to-pos":[{"mask-l-to":H()}],"mask-image-l-from-color":[{"mask-l-from":_()}],"mask-image-l-to-color":[{"mask-l-to":_()}],"mask-image-x-from-pos":[{"mask-x-from":H()}],"mask-image-x-to-pos":[{"mask-x-to":H()}],"mask-image-x-from-color":[{"mask-x-from":_()}],"mask-image-x-to-color":[{"mask-x-to":_()}],"mask-image-y-from-pos":[{"mask-y-from":H()}],"mask-image-y-to-pos":[{"mask-y-to":H()}],"mask-image-y-from-color":[{"mask-y-from":_()}],"mask-image-y-to-color":[{"mask-y-to":_()}],"mask-image-radial":[{"mask-radial":[me,he]}],"mask-image-radial-from-pos":[{"mask-radial-from":H()}],"mask-image-radial-to-pos":[{"mask-radial-to":H()}],"mask-image-radial-from-color":[{"mask-radial-from":_()}],"mask-image-radial-to-color":[{"mask-radial-to":_()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":y()}],"mask-image-conic-pos":[{"mask-conic":[Pe]}],"mask-image-conic-from-pos":[{"mask-conic-from":H()}],"mask-image-conic-to-pos":[{"mask-conic-to":H()}],"mask-image-conic-from-color":[{"mask-conic-from":_()}],"mask-image-conic-to-color":[{"mask-conic-to":_()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:ee()}],"mask-repeat":[{mask:W()}],"mask-size":[{mask:T()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",me,he]}],filter:[{filter:["","none",me,he]}],blur:[{blur:se()}],brightness:[{brightness:[Pe,me,he]}],contrast:[{contrast:[Pe,me,he]}],"drop-shadow":[{"drop-shadow":["","none",p,Pr,zr]}],"drop-shadow-color":[{"drop-shadow":_()}],grayscale:[{grayscale:["",Pe,me,he]}],"hue-rotate":[{"hue-rotate":[Pe,me,he]}],invert:[{invert:["",Pe,me,he]}],saturate:[{saturate:[Pe,me,he]}],sepia:[{sepia:["",Pe,me,he]}],"backdrop-filter":[{"backdrop-filter":["","none",me,he]}],"backdrop-blur":[{"backdrop-blur":se()}],"backdrop-brightness":[{"backdrop-brightness":[Pe,me,he]}],"backdrop-contrast":[{"backdrop-contrast":[Pe,me,he]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Pe,me,he]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Pe,me,he]}],"backdrop-invert":[{"backdrop-invert":["",Pe,me,he]}],"backdrop-opacity":[{"backdrop-opacity":[Pe,me,he]}],"backdrop-saturate":[{"backdrop-saturate":[Pe,me,he]}],"backdrop-sepia":[{"backdrop-sepia":["",Pe,me,he]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":L()}],"border-spacing-x":[{"border-spacing-x":L()}],"border-spacing-y":[{"border-spacing-y":L()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",me,he]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Pe,"initial",me,he]}],ease:[{ease:["linear","initial",x,me,he]}],delay:[{delay:[Pe,me,he]}],animate:[{animate:["none",j,me,he]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,me,he]}],"perspective-origin":[{"perspective-origin":k()}],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:te()}],"skew-x":[{"skew-x":te()}],"skew-y":[{"skew-y":te()}],transform:[{transform:[me,he,"","none","gpu","cpu"]}],"transform-origin":[{origin:k()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:be()}],"translate-x":[{"translate-x":be()}],"translate-y":[{"translate-y":be()}],"translate-z":[{"translate-z":be()}],"translate-none":["translate-none"],zoom:[{zoom:[ft,me,he]}],accent:[{accent:_()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:_()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",me,he]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":_()}],"scrollbar-track-color":[{"scrollbar-track":_()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":L()}],"scroll-mx":[{"scroll-mx":L()}],"scroll-my":[{"scroll-my":L()}],"scroll-ms":[{"scroll-ms":L()}],"scroll-me":[{"scroll-me":L()}],"scroll-mbs":[{"scroll-mbs":L()}],"scroll-mbe":[{"scroll-mbe":L()}],"scroll-mt":[{"scroll-mt":L()}],"scroll-mr":[{"scroll-mr":L()}],"scroll-mb":[{"scroll-mb":L()}],"scroll-ml":[{"scroll-ml":L()}],"scroll-p":[{"scroll-p":L()}],"scroll-px":[{"scroll-px":L()}],"scroll-py":[{"scroll-py":L()}],"scroll-ps":[{"scroll-ps":L()}],"scroll-pe":[{"scroll-pe":L()}],"scroll-pbs":[{"scroll-pbs":L()}],"scroll-pbe":[{"scroll-pbe":L()}],"scroll-pt":[{"scroll-pt":L()}],"scroll-pr":[{"scroll-pr":L()}],"scroll-pb":[{"scroll-pb":L()}],"scroll-pl":[{"scroll-pl":L()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",me,he]}],fill:[{fill:["none",..._()]}],"stroke-w":[{stroke:[Pe,ur,_t,Pa]}],stroke:[{stroke:["none",..._()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},yc=Qd(wc),Aa=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,$a=Vs,Cr=(e,r)=>n=>{var a;if((r==null?void 0:r.variants)==null)return $a(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants: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=Aa(u)||Aa(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,v]=g;return Array.isArray(v)?v.includes({...s,...i}[b]):{...s,...i}[b]===v})?[...h,m,f]:h},[]);return $a(e,l,d,n==null?void 0:n.class,n==null?void 0:n.className)},Jr=c.createContext(null);Jr.displayName="PanelGroupContext";const qe={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},ra=10,Ot=c.useLayoutEffect,_a=bd.useId,jc=typeof _a=="function"?_a:()=>null;let Nc=0;function na(e=null){const r=jc(),n=c.useRef(e||r||null);return n.current===null&&(n.current=""+Nc++),e??n.current}function lo({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 v=c.useContext(Jr);if(v===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:x,expandPanel:j,getPanelSize:w,getPanelStyle:y,groupId:k,isPanelCollapsed:S,reevaluatePanelConstraints:N,registerPanel:L,resizePanel:R,unregisterPanel:P}=v,J=na(l),D=c.useRef({callbacks:{onCollapse:h,onExpand:u,onResize:m},constraints:{collapsedSize:n,collapsible:a,defaultSize:o,maxSize:i,minSize:d},id:J,idIsFromProps:l!==void 0,order:f});c.useRef({didLogMissingDefaultSizeWarning:!1}),Ot(()=>{const{callbacks:Z,constraints:I}=D.current,re={...I};D.current.id=J,D.current.idIsFromProps=l!==void 0,D.current.order=f,Z.onCollapse=h,Z.onExpand=u,Z.onResize=m,I.collapsedSize=n,I.collapsible=a,I.defaultSize=o,I.maxSize=i,I.minSize=d,(re.collapsedSize!==I.collapsedSize||re.collapsible!==I.collapsible||re.maxSize!==I.maxSize||re.minSize!==I.minSize)&&N(D.current,re)}),Ot(()=>{const Z=D.current;return L(Z),()=>{P(Z)}},[f,J,L,P]),c.useImperativeHandle(s,()=>({collapse:()=>{x(D.current)},expand:Z=>{j(D.current,Z)},getId(){return J},getSize(){return w(D.current)},isCollapsed(){return S(D.current)},isExpanded(){return!S(D.current)},resize:Z=>{R(D.current,Z)}}),[x,j,w,S,J,R]);const Y=y(D.current,o);return c.createElement(g,{...b,children:e,className:r,id:J,style:{...Y,...p},[qe.groupId]:k,[qe.panel]:"",[qe.panelCollapsible]:a||void 0,[qe.panelId]:J,[qe.panelSize]:parseFloat(""+Y.flexGrow).toFixed(1)})}const io=c.forwardRef((e,r)=>c.createElement(lo,{...e,forwardedRef:r}));lo.displayName="Panel";io.displayName="forwardRef(Panel)";let Mn=null,Gr=-1,Et=null;function Cc(e,r,n){const a=(r&po)!==0,o=(r&fo)!==0,s=(r&go)!==0,l=(r&xo)!==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 Sc(){Et!==null&&(document.head.removeChild(Et),Mn=null,Et=null,Gr=-1)}function bn(e,r,n){var a,o;const s=Cc(e,r);if(Mn!==s){if(Mn=s,Et===null&&(Et=document.createElement("style"),document.head.appendChild(Et)),Gr>=0){var l;(l=Et.sheet)===null||l===void 0||l.removeRule(Gr)}Gr=(a=(o=Et.sheet)===null||o===void 0?void 0:o.insertRule(`*{cursor: ${s} !important;}`))!==null&&a!==void 0?a:-1}}function co(e){return e.type==="keydown"}function ho(e){return e.type.startsWith("pointer")}function uo(e){return e.type.startsWith("mouse")}function Qr(e){if(ho(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(uo(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function Tc(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function Ec(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 Lc(e,r){if(e===r)throw new Error("Cannot compare node with itself");const n={a:Ga(e),b:Ga(r)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),r=n.b.pop(),a=e;ze(a,"Stacking order can only be calculated for elements with a common ancestor");const o={a:Ba(Da(n.a)),b:Ba(Da(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 Ic=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function zc(e){var r;const n=getComputedStyle((r=mo(e))!==null&&r!==void 0?r:e).display;return n==="flex"||n==="inline-flex"}function Pc(e){const r=getComputedStyle(e);return!!(r.position==="fixed"||r.zIndex!=="auto"&&(r.position!=="static"||zc(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"||Ic.test(r.willChange)||r.webkitOverflowScrolling==="touch")}function Da(e){let r=e.length;for(;r--;){const n=e[r];if(ze(n,"Missing node"),Pc(n))return n}return null}function Ba(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Ga(e){const r=[];for(;e;)r.push(e),e=mo(e);return r}function mo(e){const{parentNode:r}=e;return r&&r instanceof ShadowRoot?r.host:r}const po=1,fo=2,go=4,xo=8,Rc=Tc()==="coarse";let mt=[],or=!1,Lt=new Map,en=new Map;const yr=new Set;function Mc(e,r,n,a,o){var s;const{ownerDocument:l}=r,i={direction:n,element:r,hitAreaMargins:a,setResizeHandlerState:o},d=(s=Lt.get(l))!==null&&s!==void 0?s:0;return Lt.set(l,d+1),yr.add(i),Kr(),function(){var u;en.delete(e),yr.delete(i);const m=(u=Lt.get(l))!==null&&u!==void 0?u:1;if(Lt.set(l,m-1),Kr(),m===1&&Lt.delete(l),mt.includes(i)){const f=mt.indexOf(i);f>=0&&mt.splice(f,1),tn(),o("up",!0,null)}}}function Ac(e){const{target:r}=e,{x:n,y:a}=Qr(e);or=!0,aa({target:r,x:n,y:a}),Kr(),mt.length>0&&(qr("down",e),tn(),e.preventDefault(),bo(r)||e.stopImmediatePropagation())}function vn(e){const{x:r,y:n}=Qr(e);if(or&&e.type!=="pointerleave"&&e.buttons===0&&(or=!1,qr("up",e)),!or){const{target:a}=e;aa({target:a,x:r,y:n})}qr("move",e),tn(),mt.length>0&&e.preventDefault()}function kn(e){const{target:r}=e,{x:n,y:a}=Qr(e);en.clear(),or=!1,mt.length>0&&(e.preventDefault(),bo(r)||e.stopImmediatePropagation()),qr("up",e),aa({target:r,x:n,y:a}),tn(),Kr()}function bo(e){let r=e;for(;r;){if(r.hasAttribute(qe.resizeHandle))return!0;r=r.parentElement}return!1}function aa({target:e,x:r,y:n}){mt.splice(0);let a=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(a=e),yr.forEach(o=>{const{element:s,hitAreaMargins:l}=o,i=s.getBoundingClientRect(),{bottom:d,left:h,right:u,top:m}=i,f=Rc?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)&&Lc(a,s)>0){let g=a,b=!1;for(;g&&!g.contains(s);){if(Ec(g.getBoundingClientRect(),i)){b=!0;break}g=g.parentElement}if(b)return}mt.push(o)}})}function wn(e,r){en.set(e,r)}function tn(){let e=!1,r=!1;mt.forEach(a=>{const{direction:o}=a;o==="horizontal"?e=!0:r=!0});let n=0;en.forEach(a=>{n|=a}),e&&r?bn("intersection",n):e?bn("horizontal",n):r?bn("vertical",n):Sc()}let yn;function Kr(){var e;(e=yn)===null||e===void 0||e.abort(),yn=new AbortController;const r={capture:!0,signal:yn.signal};yr.size&&(or?(mt.length>0&&Lt.forEach((n,a)=>{const{body:o}=a;n>0&&(o.addEventListener("contextmenu",kn,r),o.addEventListener("pointerleave",vn,r),o.addEventListener("pointermove",vn,r))}),Lt.forEach((n,a)=>{const{body:o}=a;o.addEventListener("pointerup",kn,r),o.addEventListener("pointercancel",kn,r)})):Lt.forEach((n,a)=>{const{body:o}=a;n>0&&(o.addEventListener("pointerdown",Ac,r),o.addEventListener("pointermove",vn,r))}))}function qr(e,r){yr.forEach(n=>{const{setResizeHandlerState:a}=n,o=mt.includes(n);a(e,o,r)})}function $c(){const[e,r]=c.useState(0);return c.useCallback(()=>r(n=>n+1),[])}function ze(e,r){if(!e)throw console.error(r),Error(r)}function Ut(e,r,n=ra){return e.toFixed(n)===r.toFixed(n)?0:e>r?1:-1}function yt(e,r,n=ra){return Ut(e,r,n)===0}function dt(e,r,n){return Ut(e,r,n)===0}function _c(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(!dt(o,s,n))return!1}return!0}function ar({panelConstraints:e,panelIndex:r,size:n}){const a=e[r];ze(a!=null,`Panel constraints not found for index ${r}`);let{collapsedSize:o=0,collapsible:s,maxSize:l=100,minSize:i=0}=a;if(Ut(n,i)<0)if(s){const d=(o+i)/2;Ut(n,d)<0?n=o:n=i}else n=i;return n=Math.min(l,n),n=parseFloat(n.toFixed(ra)),n}function xr({delta:e,initialLayout:r,panelConstraints:n,pivotIndices:a,prevLayout:o,trigger:s}){if(dt(e,0))return r;const l=[...r],[i,d]=a;ze(i!=null,"Invalid first pivot index"),ze(d!=null,"Invalid second pivot index");let h=0;if(s==="keyboard"){{const m=e<0?d:i,f=n[m];ze(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(ze(v!=null,`Previous layout not found for panel index ${m}`),dt(v,p)){const x=b-v;Ut(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}{const m=e<0?i:d,f=n[m];ze(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(ze(v!=null,`Previous layout not found for panel index ${m}`),dt(v,b)){const x=v-p;Ut(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}}{const m=e<0?1:-1;let f=e<0?d:i,p=0;for(;;){const b=r[f];ze(b!=null,`Previous layout not found for panel index ${f}`);const x=ar({panelConstraints:n,panelIndex:f,size:100})-b;if(p+=x,f+=m,f<0||f>=n.length)break}const g=Math.min(Math.abs(e),Math.abs(p));e=e<0?0-g:g}{let f=e<0?i:d;for(;f>=0&&f<n.length;){const p=Math.abs(e)-Math.abs(h),g=r[f];ze(g!=null,`Previous layout not found for panel index ${f}`);const b=g-p,v=ar({panelConstraints:n,panelIndex:f,size:b});if(!dt(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(_c(o,l))return o;{const m=e<0?d:i,f=r[m];ze(f!=null,`Previous layout not found for panel index ${m}`);const p=f+h,g=ar({panelConstraints:n,panelIndex:m,size:p});if(l[m]=g,!dt(g,p)){let b=p-g,x=e<0?d:i;for(;x>=0&&x<n.length;){const j=l[x];ze(j!=null,`Previous layout not found for panel index ${x}`);const w=j+b,y=ar({panelConstraints:n,panelIndex:x,size:w});if(dt(j,y)||(b-=y-j,l[x]=y),dt(b,0))break;e>0?x--:x++}}}const u=l.reduce((m,f)=>f+m,0);return dt(u,100)?l:o}function Dc({layout:e,panelsArray:r,pivotIndices:n}){let a=0,o=100,s=0,l=0;const i=n[0];ze(i!=null,"No pivot index found"),r.forEach((m,f)=>{const{constraints:p}=m,{maxSize:g=100,minSize:b=0}=p;f===i?(a=b,o=g):(s+=b,l+=g)});const d=Math.min(o,100-s),h=Math.max(a,100-l),u=e[i];return{valueMax:d,valueMin:h,valueNow:u}}function jr(e,r=document){return Array.from(r.querySelectorAll(`[${qe.resizeHandleId}][data-panel-group-id="${e}"]`))}function vo(e,r,n=document){const o=jr(e,n).findIndex(s=>s.getAttribute(qe.resizeHandleId)===r);return o??null}function ko(e,r,n){const a=vo(e,r,n);return a!=null?[a,a+1]:[-1,-1]}function Bc(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function wo(e,r=document){if(Bc(r)&&r.dataset.panelGroupId==e)return r;const n=r.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function rn(e,r=document){const n=r.querySelector(`[${qe.resizeHandleId}="${e}"]`);return n||null}function Gc(e,r,n,a=document){var o,s,l,i;const d=rn(r,a),h=jr(e,a),u=d?h.indexOf(d):-1,m=(o=(s=n[u])===null||s===void 0?void 0:s.id)!==null&&o!==void 0?o:null,f=(l=(i=n[u+1])===null||i===void 0?void 0:i.id)!==null&&l!==void 0?l:null;return[m,f]}function Fc({committedValuesRef:e,eagerValuesRef:r,groupId:n,layout:a,panelDataArray:o,panelGroupElement:s,setLayout:l}){c.useRef({didWarnAboutMissingResizeHandle:!1}),Ot(()=>{if(!s)return;const i=jr(n,s);for(let d=0;d<o.length-1;d++){const{valueMax:h,valueMin:u,valueNow:m}=Dc({layout:a,panelsArray:o,pivotIndices:[d,d+1]}),f=i[d];if(f!=null){const p=o[d];ze(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;ze(i,"Eager values not found");const{panelDataArray:d}=i,h=wo(n,s);ze(h!=null,`No group found for id "${n}"`);const u=jr(n,s);ze(u,`No resize handles found for group id "${n}"`);const m=u.map(f=>{const p=f.getAttribute(qe.resizeHandleId);ze(p,"Resize handle element has no handle id attribute");const[g,b]=Gc(n,p,d,s);if(g==null||b==null)return()=>{};const v=x=>{if(!x.defaultPrevented)switch(x.key){case"Enter":{x.preventDefault();const j=d.findIndex(w=>w.id===g);if(j>=0){const w=d[j];ze(w,`No panel data found for index ${j}`);const y=a[j],{collapsedSize:k=0,collapsible:S,minSize:N=0}=w.constraints;if(y!=null&&S){const L=xr({delta:dt(y,k)?N-k:k-y,initialLayout:a,panelConstraints:d.map(R=>R.constraints),pivotIndices:ko(n,p,s),prevLayout:a,trigger:"keyboard"});a!==L&&l(L)}}break}}};return f.addEventListener("keydown",v),()=>{f.removeEventListener("keydown",v)}});return()=>{m.forEach(f=>f())}},[s,e,r,n,a,o,l])}function Fa(e,r){if(e.length!==r.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==r[n])return!1;return!0}function yo(e,r){const n=e==="horizontal",{x:a,y:o}=Qr(r);return n?a:o}function Hc(e,r,n,a,o){const s=n==="horizontal",l=rn(r,o);ze(l,`No resize handle element found for id "${r}"`);const i=l.getAttribute(qe.groupId);ze(i,"Resize handle element has no group id attribute");let{initialCursorPosition:d}=a;const h=yo(n,e),u=wo(i,o);ze(u,`No group element found for id "${i}"`);const m=u.getBoundingClientRect(),f=s?m.width:m.height;return(h-d)/f*100}function Oc(e,r,n,a,o,s){if(co(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:Hc(e,r,n,a,s)}function Wc({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];ze(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];ze(l,`Panel constraints not found for index ${s}`);const{defaultSize:i}=l;if(i!=null)continue;const d=e.length-a,h=o/d;a++,r[s]=h,o-=h}return r}function Jt(e,r,n){r.forEach((a,o)=>{const s=e[o];ze(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||yt(m,h))&&!yt(a,h)&&p(),f&&(m==null||!yt(m,h))&&yt(a,h)&&f())}})}function Rr(e,r){if(e.length!==r.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=r[n])return!1;return!0}function Uc({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 Vc(e,r=10){let n=null;return(...o)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...o)},r)}}function Ha(e){try{if(typeof localStorage<"u")e.getItem=r=>localStorage.getItem(r),e.setItem=(r,n)=>{localStorage.setItem(r,n)};else throw new Error("localStorage not supported in this environment")}catch(r){console.error(r),e.getItem=()=>null,e.setItem=()=>{}}}function jo(e){return`react-resizable-panels:${e}`}function No(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 Co(e,r){try{const n=jo(e),a=r.getItem(n);if(a){const o=JSON.parse(a);if(typeof o=="object"&&o!=null)return o}}catch{}return null}function Kc(e,r,n){var a,o;const s=(a=Co(e,n))!==null&&a!==void 0?a:{},l=No(r);return(o=s[l])!==null&&o!==void 0?o:null}function qc(e,r,n,a,o){var s;const l=jo(e),i=No(r),d=(s=Co(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 Oa({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(!dt(a,100)&&n.length>0)for(let s=0;s<r.length;s++){const l=n[s];ze(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];ze(l!=null,`No layout data found for index ${s}`);const i=ar({panelConstraints:r,panelIndex:s,size:l});l!=i&&(o+=l-i,n[s]=i)}if(!dt(o,0))for(let s=0;s<r.length;s++){const l=n[s];ze(l!=null,`No layout data found for index ${s}`);const i=l+o,d=ar({panelConstraints:r,panelIndex:s,size:i});if(l!==d&&(o-=d-l,n[s]=d,dt(o,0)))break}return n}const Xc=100,br={getItem:e=>(Ha(br),br.getItem(e)),setItem:(e,r)=>{Ha(br),br.setItem(e,r)}},Wa={};function So({autoSaveId:e=null,children:r,className:n="",direction:a,forwardedRef:o,id:s=null,onLayout:l=null,keyboardResizeBy:i=null,storage:d=br,style:h,tagName:u="div",...m}){const f=na(s),p=c.useRef(null),[g,b]=c.useState(null),[v,x]=c.useState([]),j=$c(),w=c.useRef({}),y=c.useRef(new Map),k=c.useRef(0),S=c.useRef({autoSaveId:e,direction:a,dragState:g,id:f,keyboardResizeBy:i,onLayout:l,storage:d}),N=c.useRef({layout:v,panelDataArray:[],panelDataArrayChanged:!1});c.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),c.useImperativeHandle(o,()=>({getId:()=>S.current.id,getLayout:()=>{const{layout:T}=N.current;return T},setLayout:T=>{const{onLayout:K}=S.current,{layout:G,panelDataArray:E}=N.current,C=Oa({layout:T,panelConstraints:E.map(U=>U.constraints)});Fa(G,C)||(x(C),N.current.layout=C,K&&K(C),Jt(E,C,w.current))}}),[]),Ot(()=>{S.current.autoSaveId=e,S.current.direction=a,S.current.dragState=g,S.current.id=f,S.current.onLayout=l,S.current.storage=d}),Fc({committedValuesRef:S,eagerValuesRef:N,groupId:f,layout:v,panelDataArray:N.current.panelDataArray,setLayout:x,panelGroupElement:p.current}),c.useEffect(()=>{const{panelDataArray:T}=N.current;if(e){if(v.length===0||v.length!==T.length)return;let K=Wa[e];K==null&&(K=Vc(qc,Xc),Wa[e]=K);const G=[...T],E=new Map(y.current);K(e,G,E,v,d)}},[e,v,d]),c.useEffect(()=>{});const L=c.useCallback(T=>{const{onLayout:K}=S.current,{layout:G,panelDataArray:E}=N.current;if(T.constraints.collapsible){const C=E.map(q=>q.constraints),{collapsedSize:U=0,panelSize:H,pivotIndices:se}=Dt(E,T,G);if(ze(H!=null,`Panel size not found for panel "${T.id}"`),!yt(H,U)){y.current.set(T.id,H);const de=er(E,T)===E.length-1?H-U:U-H,te=xr({delta:de,initialLayout:G,panelConstraints:C,pivotIndices:se,prevLayout:G,trigger:"imperative-api"});Rr(G,te)||(x(te),N.current.layout=te,K&&K(te),Jt(E,te,w.current))}}},[]),R=c.useCallback((T,K)=>{const{onLayout:G}=S.current,{layout:E,panelDataArray:C}=N.current;if(T.constraints.collapsible){const U=C.map(be=>be.constraints),{collapsedSize:H=0,panelSize:se=0,minSize:q=0,pivotIndices:de}=Dt(C,T,E),te=K??q;if(yt(se,H)){const be=y.current.get(T.id),ie=be!=null&&be>=te?be:te,Ae=er(C,T)===C.length-1?se-ie:ie-se,ce=xr({delta:Ae,initialLayout:E,panelConstraints:U,pivotIndices:de,prevLayout:E,trigger:"imperative-api"});Rr(E,ce)||(x(ce),N.current.layout=ce,G&&G(ce),Jt(C,ce,w.current))}}},[]),P=c.useCallback(T=>{const{layout:K,panelDataArray:G}=N.current,{panelSize:E}=Dt(G,T,K);return ze(E!=null,`Panel size not found for panel "${T.id}"`),E},[]),J=c.useCallback((T,K)=>{const{panelDataArray:G}=N.current,E=er(G,T);return Uc({defaultSize:K,dragState:g,layout:v,panelData:G,panelIndex:E})},[g,v]),D=c.useCallback(T=>{const{layout:K,panelDataArray:G}=N.current,{collapsedSize:E=0,collapsible:C,panelSize:U}=Dt(G,T,K);return ze(U!=null,`Panel size not found for panel "${T.id}"`),C===!0&&yt(U,E)},[]),Y=c.useCallback(T=>{const{layout:K,panelDataArray:G}=N.current,{collapsedSize:E=0,collapsible:C,panelSize:U}=Dt(G,T,K);return ze(U!=null,`Panel size not found for panel "${T.id}"`),!C||Ut(U,E)>0},[]),Z=c.useCallback(T=>{const{panelDataArray:K}=N.current;K.push(T),K.sort((G,E)=>{const C=G.order,U=E.order;return C==null&&U==null?0:C==null?-1:U==null?1:C-U}),N.current.panelDataArrayChanged=!0,j()},[j]);Ot(()=>{if(N.current.panelDataArrayChanged){N.current.panelDataArrayChanged=!1;const{autoSaveId:T,onLayout:K,storage:G}=S.current,{layout:E,panelDataArray:C}=N.current;let U=null;if(T){const se=Kc(T,C,G);se&&(y.current=new Map(Object.entries(se.expandToSizes)),U=se.layout)}U==null&&(U=Wc({panelDataArray:C}));const H=Oa({layout:U,panelConstraints:C.map(se=>se.constraints)});Fa(E,H)||(x(H),N.current.layout=H,K&&K(H),Jt(C,H,w.current))}}),Ot(()=>{const T=N.current;return()=>{T.layout=[]}},[]);const I=c.useCallback(T=>{let K=!1;const G=p.current;return G&&window.getComputedStyle(G,null).getPropertyValue("direction")==="rtl"&&(K=!0),function(C){C.preventDefault();const U=p.current;if(!U)return()=>null;const{direction:H,dragState:se,id:q,keyboardResizeBy:de,onLayout:te}=S.current,{layout:be,panelDataArray:ie}=N.current,{initialLayout:ye}=se??{},Ae=ko(q,T,U);let ce=Oc(C,T,H,se,de,U);const Ce=H==="horizontal";Ce&&K&&(ce=-ce);const Le=ie.map(ve=>ve.constraints),X=xr({delta:ce,initialLayout:ye??be,panelConstraints:Le,pivotIndices:Ae,prevLayout:be,trigger:co(C)?"keyboard":"mouse-or-touch"}),ue=!Rr(be,X);(ho(C)||uo(C))&&k.current!=ce&&(k.current=ce,!ue&&ce!==0?Ce?wn(T,ce<0?po:fo):wn(T,ce<0?go:xo):wn(T,0)),ue&&(x(X),N.current.layout=X,te&&te(X),Jt(ie,X,w.current))}},[]),re=c.useCallback((T,K)=>{const{onLayout:G}=S.current,{layout:E,panelDataArray:C}=N.current,U=C.map(be=>be.constraints),{panelSize:H,pivotIndices:se}=Dt(C,T,E);ze(H!=null,`Panel size not found for panel "${T.id}"`);const de=er(C,T)===C.length-1?H-K:K-H,te=xr({delta:de,initialLayout:E,panelConstraints:U,pivotIndices:se,prevLayout:E,trigger:"imperative-api"});Rr(E,te)||(x(te),N.current.layout=te,G&&G(te),Jt(C,te,w.current))},[]),oe=c.useCallback((T,K)=>{const{layout:G,panelDataArray:E}=N.current,{collapsedSize:C=0,collapsible:U}=K,{collapsedSize:H=0,collapsible:se,maxSize:q=100,minSize:de=0}=T.constraints,{panelSize:te}=Dt(E,T,G);te!=null&&(U&&se&&yt(te,C)?yt(C,H)||re(T,H):te<de?re(T,de):te>q&&re(T,q))},[re]),$=c.useCallback((T,K)=>{const{direction:G}=S.current,{layout:E}=N.current;if(!p.current)return;const C=rn(T,p.current);ze(C,`Drag handle element not found for id "${T}"`);const U=yo(G,K);b({dragHandleId:T,dragHandleRect:C.getBoundingClientRect(),initialCursorPosition:U,initialLayout:E})},[]),Q=c.useCallback(()=>{b(null)},[]),_=c.useCallback(T=>{const{panelDataArray:K}=N.current,G=er(K,T);G>=0&&(K.splice(G,1),delete w.current[T.id],N.current.panelDataArrayChanged=!0,j())},[j]),ee=c.useMemo(()=>({collapsePanel:L,direction:a,dragState:g,expandPanel:R,getPanelSize:P,getPanelStyle:J,groupId:f,isPanelCollapsed:D,isPanelExpanded:Y,reevaluatePanelConstraints:oe,registerPanel:Z,registerResizeHandle:I,resizePanel:re,startDragging:$,stopDragging:Q,unregisterPanel:_,panelGroupElement:p.current}),[L,g,a,R,P,J,f,D,Y,oe,Z,I,re,$,Q,_]),W={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return c.createElement(Jr.Provider,{value:ee},c.createElement(u,{...m,children:r,className:n,id:s,ref:p,style:{...W,...h},[qe.group]:"",[qe.groupDirection]:a,[qe.groupId]:f}))}const To=c.forwardRef((e,r)=>c.createElement(So,{...e,forwardedRef:r}));So.displayName="PanelGroup";To.displayName="forwardRef(PanelGroup)";function er(e,r){return e.findIndex(n=>n===r||n.id===r.id)}function Dt(e,r,n){const a=er(e,r),s=a===e.length-1?[a-1,a]:[a,a+1],l=n[a];return{...r.constraints,panelSize:l,pivotIndices:s}}function Yc({disabled:e,handleId:r,resizeHandler:n,panelGroupElement:a}){c.useEffect(()=>{if(e||n==null||a==null)return;const o=rn(r,a);if(o==null)return;const s=l=>{if(!l.defaultPrevented)switch(l.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{l.preventDefault(),n(l);break}case"F6":{l.preventDefault();const i=o.getAttribute(qe.groupId);ze(i,`No group element found for id "${i}"`);const d=jr(i,a),h=vo(i,r,a);ze(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 Eo({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,v;const x=c.useRef(null),j=c.useRef({onClick:l,onDragging:i,onPointerDown:h,onPointerUp:u});c.useEffect(()=>{j.current.onClick=l,j.current.onDragging=i,j.current.onPointerDown=h,j.current.onPointerUp=u});const w=c.useContext(Jr);if(w===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:y,groupId:k,registerResizeHandle:S,startDragging:N,stopDragging:L,panelGroupElement:R}=w,P=na(o),[J,D]=c.useState("inactive"),[Y,Z]=c.useState(!1),[I,re]=c.useState(null),oe=c.useRef({state:J});Ot(()=>{oe.current.state=J}),c.useEffect(()=>{if(n)re(null);else{const ee=S(P);re(()=>ee)}},[n,P,S]);const $=(b=a==null?void 0:a.coarse)!==null&&b!==void 0?b:15,Q=(v=a==null?void 0:a.fine)!==null&&v!==void 0?v:5;c.useEffect(()=>{if(n||I==null)return;const ee=x.current;ze(ee,"Element ref not attached");let W=!1;return Mc(P,ee,y,{coarse:$,fine:Q},(K,G,E)=>{if(!G){D("inactive");return}switch(K){case"down":{D("drag"),W=!1,ze(E,'Expected event to be defined for "down" action'),N(P,E);const{onDragging:C,onPointerDown:U}=j.current;C==null||C(!0),U==null||U();break}case"move":{const{state:C}=oe.current;W=!0,C!=="drag"&&D("hover"),ze(E,'Expected event to be defined for "move" action'),I(E);break}case"up":{D("hover"),L();const{onClick:C,onDragging:U,onPointerUp:H}=j.current;U==null||U(!1),H==null||H(),W||C==null||C();break}}})},[$,y,n,Q,S,P,I,N,L]),Yc({disabled:n,handleId:P,resizeHandler:I,panelGroupElement:R});const _={touchAction:"none",userSelect:"none"};return c.createElement(p,{...g,children:e,className:r,id:o,onBlur:()=>{Z(!1),s==null||s()},onFocus:()=>{Z(!0),d==null||d()},ref:x,role:"separator",style:{..._,...m},tabIndex:f,[qe.groupDirection]:y,[qe.groupId]:k,[qe.resizeHandle]:"",[qe.resizeHandleActive]:J==="drag"?"pointer":Y?"keyboard":void 0,[qe.resizeHandleEnabled]:!n,[qe.resizeHandleId]:P,[qe.resizeHandleState]:J})}Eo.displayName="PanelResizeHandle";var Zc=Object.defineProperty,Jc=Object.getOwnPropertyNames,Oe=(e,r)=>function(){return e&&(r=(0,e[Jc(e)[0]])(e=0)),r},Qc=(e,r)=>{for(var n in r)Zc(e,n,{get:r[n],enumerable:!0})};function rt(...e){return yc(Vs(e))}var Pt=Oe({"src/components/graph-ui/utils.ts"(){}});function Nr({asChild:e=!1,className:r,size:n,variant:a,...o}){const s=e?Hs:"button";return t.jsx(s,{"data-slot":"button",className:rt(Lo({variant:a,size:n,className:r})),...o})}var Lo,nn=Oe({"src/components/graph-ui/Button.tsx"(){Pt(),Lo=Cr("inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium outline-none transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}})}});function Io(...e){return e.filter(Boolean).join(" ")}function An({className:e,...r}){return t.jsx(To,{"data-slot":"resizable-panel-group",className:Io("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...r})}function sr({...e}){return t.jsx(io,{"data-slot":"resizable-panel",...e})}function $n({withHandle:e,className:r,...n}){return t.jsx(Eo,{"data-slot":"resizable-handle",className:Io("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 zo=Oe({"src/components/graph-workspace/GraphResizablePanels.tsx"(){}});function sa(...e){return e.filter(Boolean).join(" ")}function Sr({...e}){return t.jsx(qi,{"data-slot":"accordion",...e})}function Tr({className:e,...r}){return t.jsx(Xi,{"data-slot":"accordion-item",className:sa("border-b last:border-b-0",e),...r})}function an({className:e,children:r,...n}){return t.jsx(Zi,{className:"flex",children:t.jsxs(Ji,{"data-slot":"accordion-trigger",className:sa("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 Er({className:e,children:r,...n}){return t.jsx(Yi,{"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:sa("pb-4 pt-0",e),children:r})})}var Lr=Oe({"src/components/graph-workspace/GraphAccordion.tsx"(){}});function eh(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 th(e){return e.trim().replace(/^\/+|\/+$/g,"").replace(/[^\w.-]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function Ir(e){var r;return((r=e.split(".").pop())==null?void 0:r.toLowerCase())||""}function rh(e){return e.split("/").filter(Boolean).at(-1)??e}function tr(e){const r=e.kind==="directory"?"directory":"file",n=(e.children??[]).map(tr);return{id:`workspace:${e.path}`,name:e.name,path:e.path,kind:r,...e.size!==void 0?{size:e.size}:{},...e.hasChildren!==void 0?{hasChildren:e.hasChildren}:r==="directory"?{hasChildren:n.length>0}:{},...e.childrenLoaded!==void 0?{childrenLoaded:e.childrenLoaded}:r==="directory"?{childrenLoaded:e.children!==void 0}:{},...e.truncated!==void 0?{truncated:e.truncated}:{},workspaceNode:e,children:n}}function Po(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=Po(l,r,n,a);return i!==l&&(o=!0),i});return o?{...e,children:s}:e}function Ro(e){if(e.kind==="file")return e;for(const r of e.children){const n=Ro(r);if(n)return n}return null}function _n(e,r){if(!e||r===null)return null;if(e.path===r)return e;for(const n of e.children){const a=_n(n,r);if(a)return a}return null}function Mo(e){return e.trim().replace(/\\/g,"/").replace(/^\.\/+/,"").replace(/^\/+/,"")}function nh(e){const n=Mo(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 Dn(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=Dn(s,r,n);return l!==s&&(a=!0),l});return a?{...e,children:o}:e}function Bn(e,r){return!e||!r?!1:e.path===r?!0:e.children.some(n=>Bn(n,r))}function ah(e){if(!e)return null;const r=Ir(e.path);return oa.has(r)?{content:[e.content.endsWith(`
|
|
2
|
+
import{l as D,R as Ki,I as qi,C as Xi,S as Gs,H as Yi,T as Zi,a as Ji,b as Qi,c as ed,d as td,e as rd,D as nd,P as ad,O as sd,f as od,g as ld,h as id,i as dd,j as cd,k as hd,m as ud,n as md,A as pd,o as fd,p as gd}from"./ui-vendor-CuR8GHb0.js";import{r as c,R as xd,j as t,b as Yr}from"./react-vendor-Dfg_6BLf.js";import{u as bd,a as vd,H as Na,P as Gt,b as kd,M as Fs,R as wd,i as yd,C as jd,B as Nd,c as Ca,g as Hs}from"./graph-vendor-DVQUpZ8C.js";import"./terminal-vendor-C5bTa-Ka.js";import{M as Cd,r as Sd,a as Td,b as Ed}from"./markdown-vendor-RZk8L7-L.js";const Ld="modulepreload",Id=function(e){return"/"+e},Sa={},Xe=function(r,n,a){let o=Promise.resolve();if(n&&n.length>0){let l=function(h){return Promise.all(h.map(u=>Promise.resolve(u).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),d=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));o=l(n.map(h=>{if(h=Id(h),h in Sa)return;Sa[h]=!0;const u=h.endsWith(".css"),m=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${m}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":Ld,u||(f.as="script"),f.crossOrigin="",f.href=h,d&&f.setAttribute("nonce",d),document.head.appendChild(f),u)return new Promise((p,g)=>{f.addEventListener("load",p),f.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${h}`)))})}))}function s(l){const i=new Event("vite:preloadError",{cancelable:!0});if(i.payload=l,window.dispatchEvent(i),!i.defaultPrevented)throw l}return o.then(l=>{for(const i of l||[])i.status==="rejected"&&s(i.reason);return r().catch(s)})};function Os(e){var r,n,a="";if(typeof e=="string"||typeof e=="number")a+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(r=0;r<o;r++)e[r]&&(n=Os(e[r]))&&(a&&(a+=" "),a+=n)}else for(n in e)e[n]&&(a&&(a+=" "),a+=n);return a}function Ws(){for(var e,r,n=0,a="",o=arguments.length;n<o;n++)(e=arguments[n])&&(r=Os(e))&&(a&&(a+=" "),a+=r);return a}const zd=(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},Pd=(e,r)=>({classGroupId:e,validator:r}),Us=(e=new Map,r=null,n)=>({nextPart:e,validators:r,classGroupId:n}),Ur="-",Ta=[],Rd="arbitrary..",Md=e=>{const r=_d(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:a}=e;return{getClassGroupId:l=>{if(l.startsWith("[")&&l.endsWith("]"))return Ad(l);const i=l.split(Ur),d=i[0]===""&&i.length>1?1:0;return Vs(i,d,r)},getConflictingClassGroupIds:(l,i)=>{if(i){const d=a[l],h=n[l];return d?h?zd(h,d):d:h||Ta}return n[l]||Ta}}},Vs=(e,r,n)=>{if(e.length-r===0)return n.classGroupId;const o=e[r],s=n.nextPart.get(o);if(s){const h=Vs(e,r+1,s);if(h)return h}const l=n.validators;if(l===null)return;const i=r===0?e.join(Ur):e.slice(r).join(Ur),d=l.length;for(let h=0;h<d;h++){const u=l[h];if(u.validator(i))return u.classGroupId}},Ad=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?Rd+a:void 0})(),_d=e=>{const{theme:r,classGroups:n}=e;return $d(n,r)},$d=(e,r)=>{const n=Us();for(const a in e){const o=e[a];Qn(o,n,a,r)}return n},Qn=(e,r,n,a)=>{const o=e.length;for(let s=0;s<o;s++){const l=e[s];Dd(l,r,n,a)}},Dd=(e,r,n,a)=>{if(typeof e=="string"){Bd(e,r,n);return}if(typeof e=="function"){Gd(e,r,n,a);return}Fd(e,r,n,a)},Bd=(e,r,n)=>{const a=e===""?r:Ks(r,e);a.classGroupId=n},Gd=(e,r,n,a)=>{if(Hd(e)){Qn(e(a),r,n,a);return}r.validators===null&&(r.validators=[]),r.validators.push(Pd(n,e))},Fd=(e,r,n,a)=>{const o=Object.entries(e),s=o.length;for(let l=0;l<s;l++){const[i,d]=o[l];Qn(d,Ks(r,i),n,a)}},Ks=(e,r)=>{let n=e;const a=r.split(Ur),o=a.length;for(let s=0;s<o;s++){const l=a[s];let i=n.nextPart.get(l);i||(i=Us(),n.nextPart.set(l,i)),n=i}return n},Hd=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Od=e=>{if(e<1)return{get:()=>{},set:()=>{}};let r=0,n=Object.create(null),a=Object.create(null);const o=(s,l)=>{n[s]=l,r++,r>e&&(r=0,a=n,n=Object.create(null))};return{get(s){let l=n[s];if(l!==void 0)return l;if((l=a[s])!==void 0)return o(s,l),l},set(s,l){s in n?n[s]=l:o(s,l)}}},Pn="!",Ea=":",Wd=[],La=(e,r,n,a,o)=>({modifiers:e,hasImportantModifier:r,baseClassName:n,maybePostfixModifierPosition:a,isExternal:o}),Ud=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 k=o[b];if(l===0&&i===0){if(k===Ea){s.push(o.slice(d,b)),d=b+1;continue}if(k==="/"){h=b;continue}}k==="["?l++:k==="]"?l--:k==="("?i++:k===")"&&i--}const m=s.length===0?o:o.slice(d);let f=m,p=!1;m.endsWith(Pn)?(f=m.slice(0,-1),p=!0):m.startsWith(Pn)&&(f=m.slice(1),p=!0);const g=h&&h>d?h-d:void 0;return La(s,p,f,g)};if(r){const o=r+Ea,s=a;a=l=>l.startsWith(o)?s(l.slice(o.length)):La(Wd,!1,l,void 0,!0)}if(n){const o=a;a=s=>n({className:s,parseClassName:o})}return a},Vd=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}},Kd=e=>({cache:Od(e.cacheSize),parseClassName:Ud(e),sortModifiers:Vd(e),postfixLookupClassGroupIds:qd(e),...Md(e)}),qd=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},Xd=/\s+/,Yd=(e,r)=>{const{parseClassName:n,getClassGroupId:a,getConflictingClassGroupIds:o,sortModifiers:s,postfixLookupClassGroupIds:l}=r,i=[],d=e.trim().split(Xd);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:k}=n(m);if(f){h=m+(h.length>0?" "+h:h);continue}let x=!!k,j;if(x){const N=b.substring(0,k);j=a(N);const I=j&&l[j]?a(b):void 0;I&&I!==j&&(j=I,x=!1)}else j=a(b);if(!j){if(!x){h=m+(h.length>0?" "+h:h);continue}if(j=a(b),!j){h=m+(h.length>0?" "+h:h);continue}x=!1}const w=p.length===0?"":p.length===1?p[0]:s(p).join(":"),y=g?w+Pn:w,v=y+j;if(i.indexOf(v)>-1)continue;i.push(v);const S=o(j,x);for(let N=0;N<S.length;++N){const I=S[N];i.push(y+I)}h=m+(h.length>0?" "+h:h)}return h},Zd=(...e)=>{let r=0,n,a,o="";for(;r<e.length;)(n=e[r++])&&(a=qs(n))&&(o&&(o+=" "),o+=a);return o},qs=e=>{if(typeof e=="string")return e;let r,n="";for(let a=0;a<e.length;a++)e[a]&&(r=qs(e[a]))&&(n&&(n+=" "),n+=r);return n},Jd=(e,...r)=>{let n,a,o,s;const l=d=>{const h=r.reduce((u,m)=>m(u),e());return n=Kd(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=Yd(d,n);return o(d,u),u};return s=l,(...d)=>s(Zd(...d))},Qd=[],Qe=e=>{const r=n=>n[e]||Qd;return r.isThemeGetter=!0,r},Xs=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Ys=/^\((?:(\w[\w-]*):)?(.+)\)$/i,ec=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,tc=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,rc=/\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$/,nc=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,ac=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,sc=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,St=e=>ec.test(e),Pe=e=>!!e&&!Number.isNaN(Number(e)),ft=e=>!!e&&Number.isInteger(Number(e)),gn=e=>e.endsWith("%")&&Pe(e.slice(0,-1)),wt=e=>tc.test(e),Zs=()=>!0,oc=e=>rc.test(e)&&!nc.test(e),ea=()=>!1,lc=e=>ac.test(e),ic=e=>sc.test(e),dc=e=>!he(e)&&!me(e),cc=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)),hc=e=>zt(e,eo,ea),he=e=>Xs.test(e),$t=e=>zt(e,to,oc),Ia=e=>zt(e,vc,Pe),uc=e=>zt(e,no,Zs),mc=e=>zt(e,ro,ea),za=e=>zt(e,Js,ea),pc=e=>zt(e,Qs,ic),zr=e=>zt(e,ao,lc),me=e=>Ys.test(e),ur=e=>Vt(e,to),fc=e=>Vt(e,ro),Pa=e=>Vt(e,Js),gc=e=>Vt(e,eo),xc=e=>Vt(e,Qs),Pr=e=>Vt(e,ao,!0),bc=e=>Vt(e,no,!0),zt=(e,r,n)=>{const a=Xs.exec(e);return a?a[1]?r(a[1]):n(a[2]):!1},Vt=(e,r,n=!1)=>{const a=Ys.exec(e);return a?a[1]?r(a[1]):n:!1},Js=e=>e==="position"||e==="percentage",Qs=e=>e==="image"||e==="url",eo=e=>e==="length"||e==="size"||e==="bg-size",to=e=>e==="length",vc=e=>e==="number",ro=e=>e==="family-name",no=e=>e==="number"||e==="weight",ao=e=>e==="shadow",kc=()=>{const e=Qe("color"),r=Qe("font"),n=Qe("text"),a=Qe("font-weight"),o=Qe("tracking"),s=Qe("leading"),l=Qe("breakpoint"),i=Qe("container"),d=Qe("spacing"),h=Qe("radius"),u=Qe("shadow"),m=Qe("inset-shadow"),f=Qe("text-shadow"),p=Qe("drop-shadow"),g=Qe("blur"),b=Qe("perspective"),k=Qe("aspect"),x=Qe("ease"),j=Qe("animate"),w=()=>["auto","avoid","all","avoid-page","page","left","right","column"],y=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],v=()=>[...y(),me,he],S=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto","contain","none"],I=()=>[me,he,d],M=()=>[St,"full","auto",...I()],R=()=>[ft,"none","subgrid",me,he],Q=()=>["auto",{span:["full",ft,me,he]},ft,me,he],$=()=>[ft,"auto",me,he],Y=()=>["auto","min","max","fr",me,he],Z=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],P=()=>["start","end","center","stretch","center-safe","end-safe"],te=()=>["auto",...I()],oe=()=>[St,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...I()],T=()=>[St,"screen","full","dvw","lvw","svw","min","max","fit",...I()],re=()=>[St,"screen","full","lh","dvh","lvh","svh","min","max","fit",...I()],B=()=>[e,me,he],J=()=>[...y(),Pa,za,{position:[me,he]}],K=()=>["no-repeat",{repeat:["","x","y","space","round"]}],L=()=>["auto","cover","contain",gc,hc,{size:[me,he]}],q=()=>[gn,ur,$t],G=()=>["","none","full",h,me,he],E=()=>["",Pe,ur,$t],C=()=>["solid","dashed","dotted","double"],W=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],H=()=>[Pe,gn,Pa,za],se=()=>["","none",g,me,he],V=()=>["none",Pe,me,he],de=()=>["none",Pe,me,he],ee=()=>[Pe,me,he],be=()=>[St,"full",...I()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[wt],breakpoint:[wt],color:[Zs],container:[wt],"drop-shadow":[wt],ease:["in","out","in-out"],font:[dc],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[wt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[wt],shadow:[wt],spacing:["px",Pe],text:[wt],"text-shadow":[wt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",St,he,me,k]}],container:["container"],"container-type":[{"@container":["","normal","size",me,he]}],"container-named":[cc],columns:[{columns:[Pe,he,me,i]}],"break-after":[{"break-after":w()}],"break-before":[{"break-before":w()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:v()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:N()}],"overscroll-x":[{"overscroll-x":N()}],"overscroll-y":[{"overscroll-y":N()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:M()}],"inset-x":[{"inset-x":M()}],"inset-y":[{"inset-y":M()}],start:[{"inset-s":M(),start:M()}],end:[{"inset-e":M(),end:M()}],"inset-bs":[{"inset-bs":M()}],"inset-be":[{"inset-be":M()}],top:[{top:M()}],right:[{right:M()}],bottom:[{bottom:M()}],left:[{left:M()}],visibility:["visible","invisible","collapse"],z:[{z:[ft,"auto",me,he]}],basis:[{basis:[St,"full","auto",i,...I()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Pe,St,"auto","initial","none",he]}],grow:[{grow:["",Pe,me,he]}],shrink:[{shrink:["",Pe,me,he]}],order:[{order:[ft,"first","last","none",me,he]}],"grid-cols":[{"grid-cols":R()}],"col-start-end":[{col:Q()}],"col-start":[{"col-start":$()}],"col-end":[{"col-end":$()}],"grid-rows":[{"grid-rows":R()}],"row-start-end":[{row:Q()}],"row-start":[{"row-start":$()}],"row-end":[{"row-end":$()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":Y()}],"auto-rows":[{"auto-rows":Y()}],gap:[{gap:I()}],"gap-x":[{"gap-x":I()}],"gap-y":[{"gap-y":I()}],"justify-content":[{justify:[...Z(),"normal"]}],"justify-items":[{"justify-items":[...P(),"normal"]}],"justify-self":[{"justify-self":["auto",...P()]}],"align-content":[{content:["normal",...Z()]}],"align-items":[{items:[...P(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...P(),{baseline:["","last"]}]}],"place-content":[{"place-content":Z()}],"place-items":[{"place-items":[...P(),"baseline"]}],"place-self":[{"place-self":["auto",...P()]}],p:[{p:I()}],px:[{px:I()}],py:[{py:I()}],ps:[{ps:I()}],pe:[{pe:I()}],pbs:[{pbs:I()}],pbe:[{pbe:I()}],pt:[{pt:I()}],pr:[{pr:I()}],pb:[{pb:I()}],pl:[{pl:I()}],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":I()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":I()}],"space-y-reverse":["space-y-reverse"],size:[{size:oe()}],"inline-size":[{inline:["auto",...T()]}],"min-inline-size":[{"min-inline":["auto",...T()]}],"max-inline-size":[{"max-inline":["none",...T()]}],"block-size":[{block:["auto",...re()]}],"min-block-size":[{"min-block":["auto",...re()]}],"max-block-size":[{"max-block":["none",...re()]}],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,ur,$t]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,bc,uc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",gn,he]}],"font-family":[{font:[fc,mc,r]}],"font-features":[{"font-features":[he]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,me,he]}],"line-clamp":[{"line-clamp":[Pe,"none",me,Ia]}],leading:[{leading:[s,...I()]}],"list-image":[{"list-image":["none",me,he]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",me,he]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:B()}],"text-color":[{text:B()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...C(),"wavy"]}],"text-decoration-thickness":[{decoration:[Pe,"from-font","auto",me,$t]}],"text-decoration-color":[{decoration:B()}],"underline-offset":[{"underline-offset":[Pe,"auto",me,he]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:I()}],"tab-size":[{tab:[ft,me,he]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",me,he]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",me,he]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:J()}],"bg-repeat":[{bg:K()}],"bg-size":[{bg:L()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},ft,me,he],radial:["",me,he],conic:[ft,me,he]},xc,pc]}],"bg-color":[{bg:B()}],"gradient-from-pos":[{from:q()}],"gradient-via-pos":[{via:q()}],"gradient-to-pos":[{to:q()}],"gradient-from":[{from:B()}],"gradient-via":[{via:B()}],"gradient-to":[{to:B()}],rounded:[{rounded:G()}],"rounded-s":[{"rounded-s":G()}],"rounded-e":[{"rounded-e":G()}],"rounded-t":[{"rounded-t":G()}],"rounded-r":[{"rounded-r":G()}],"rounded-b":[{"rounded-b":G()}],"rounded-l":[{"rounded-l":G()}],"rounded-ss":[{"rounded-ss":G()}],"rounded-se":[{"rounded-se":G()}],"rounded-ee":[{"rounded-ee":G()}],"rounded-es":[{"rounded-es":G()}],"rounded-tl":[{"rounded-tl":G()}],"rounded-tr":[{"rounded-tr":G()}],"rounded-br":[{"rounded-br":G()}],"rounded-bl":[{"rounded-bl":G()}],"border-w":[{border:E()}],"border-w-x":[{"border-x":E()}],"border-w-y":[{"border-y":E()}],"border-w-s":[{"border-s":E()}],"border-w-e":[{"border-e":E()}],"border-w-bs":[{"border-bs":E()}],"border-w-be":[{"border-be":E()}],"border-w-t":[{"border-t":E()}],"border-w-r":[{"border-r":E()}],"border-w-b":[{"border-b":E()}],"border-w-l":[{"border-l":E()}],"divide-x":[{"divide-x":E()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":E()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...C(),"hidden","none"]}],"divide-style":[{divide:[...C(),"hidden","none"]}],"border-color":[{border:B()}],"border-color-x":[{"border-x":B()}],"border-color-y":[{"border-y":B()}],"border-color-s":[{"border-s":B()}],"border-color-e":[{"border-e":B()}],"border-color-bs":[{"border-bs":B()}],"border-color-be":[{"border-be":B()}],"border-color-t":[{"border-t":B()}],"border-color-r":[{"border-r":B()}],"border-color-b":[{"border-b":B()}],"border-color-l":[{"border-l":B()}],"divide-color":[{divide:B()}],"outline-style":[{outline:[...C(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Pe,me,he]}],"outline-w":[{outline:["",Pe,ur,$t]}],"outline-color":[{outline:B()}],shadow:[{shadow:["","none",u,Pr,zr]}],"shadow-color":[{shadow:B()}],"inset-shadow":[{"inset-shadow":["none",m,Pr,zr]}],"inset-shadow-color":[{"inset-shadow":B()}],"ring-w":[{ring:E()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:B()}],"ring-offset-w":[{"ring-offset":[Pe,$t]}],"ring-offset-color":[{"ring-offset":B()}],"inset-ring-w":[{"inset-ring":E()}],"inset-ring-color":[{"inset-ring":B()}],"text-shadow":[{"text-shadow":["none",f,Pr,zr]}],"text-shadow-color":[{"text-shadow":B()}],opacity:[{opacity:[Pe,me,he]}],"mix-blend":[{"mix-blend":[...W(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":W()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Pe]}],"mask-image-linear-from-pos":[{"mask-linear-from":H()}],"mask-image-linear-to-pos":[{"mask-linear-to":H()}],"mask-image-linear-from-color":[{"mask-linear-from":B()}],"mask-image-linear-to-color":[{"mask-linear-to":B()}],"mask-image-t-from-pos":[{"mask-t-from":H()}],"mask-image-t-to-pos":[{"mask-t-to":H()}],"mask-image-t-from-color":[{"mask-t-from":B()}],"mask-image-t-to-color":[{"mask-t-to":B()}],"mask-image-r-from-pos":[{"mask-r-from":H()}],"mask-image-r-to-pos":[{"mask-r-to":H()}],"mask-image-r-from-color":[{"mask-r-from":B()}],"mask-image-r-to-color":[{"mask-r-to":B()}],"mask-image-b-from-pos":[{"mask-b-from":H()}],"mask-image-b-to-pos":[{"mask-b-to":H()}],"mask-image-b-from-color":[{"mask-b-from":B()}],"mask-image-b-to-color":[{"mask-b-to":B()}],"mask-image-l-from-pos":[{"mask-l-from":H()}],"mask-image-l-to-pos":[{"mask-l-to":H()}],"mask-image-l-from-color":[{"mask-l-from":B()}],"mask-image-l-to-color":[{"mask-l-to":B()}],"mask-image-x-from-pos":[{"mask-x-from":H()}],"mask-image-x-to-pos":[{"mask-x-to":H()}],"mask-image-x-from-color":[{"mask-x-from":B()}],"mask-image-x-to-color":[{"mask-x-to":B()}],"mask-image-y-from-pos":[{"mask-y-from":H()}],"mask-image-y-to-pos":[{"mask-y-to":H()}],"mask-image-y-from-color":[{"mask-y-from":B()}],"mask-image-y-to-color":[{"mask-y-to":B()}],"mask-image-radial":[{"mask-radial":[me,he]}],"mask-image-radial-from-pos":[{"mask-radial-from":H()}],"mask-image-radial-to-pos":[{"mask-radial-to":H()}],"mask-image-radial-from-color":[{"mask-radial-from":B()}],"mask-image-radial-to-color":[{"mask-radial-to":B()}],"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":y()}],"mask-image-conic-pos":[{"mask-conic":[Pe]}],"mask-image-conic-from-pos":[{"mask-conic-from":H()}],"mask-image-conic-to-pos":[{"mask-conic-to":H()}],"mask-image-conic-from-color":[{"mask-conic-from":B()}],"mask-image-conic-to-color":[{"mask-conic-to":B()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:J()}],"mask-repeat":[{mask:K()}],"mask-size":[{mask:L()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",me,he]}],filter:[{filter:["","none",me,he]}],blur:[{blur:se()}],brightness:[{brightness:[Pe,me,he]}],contrast:[{contrast:[Pe,me,he]}],"drop-shadow":[{"drop-shadow":["","none",p,Pr,zr]}],"drop-shadow-color":[{"drop-shadow":B()}],grayscale:[{grayscale:["",Pe,me,he]}],"hue-rotate":[{"hue-rotate":[Pe,me,he]}],invert:[{invert:["",Pe,me,he]}],saturate:[{saturate:[Pe,me,he]}],sepia:[{sepia:["",Pe,me,he]}],"backdrop-filter":[{"backdrop-filter":["","none",me,he]}],"backdrop-blur":[{"backdrop-blur":se()}],"backdrop-brightness":[{"backdrop-brightness":[Pe,me,he]}],"backdrop-contrast":[{"backdrop-contrast":[Pe,me,he]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Pe,me,he]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Pe,me,he]}],"backdrop-invert":[{"backdrop-invert":["",Pe,me,he]}],"backdrop-opacity":[{"backdrop-opacity":[Pe,me,he]}],"backdrop-saturate":[{"backdrop-saturate":[Pe,me,he]}],"backdrop-sepia":[{"backdrop-sepia":["",Pe,me,he]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":I()}],"border-spacing-x":[{"border-spacing-x":I()}],"border-spacing-y":[{"border-spacing-y":I()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",me,he]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Pe,"initial",me,he]}],ease:[{ease:["linear","initial",x,me,he]}],delay:[{delay:[Pe,me,he]}],animate:[{animate:["none",j,me,he]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,me,he]}],"perspective-origin":[{"perspective-origin":v()}],rotate:[{rotate:V()}],"rotate-x":[{"rotate-x":V()}],"rotate-y":[{"rotate-y":V()}],"rotate-z":[{"rotate-z":V()}],scale:[{scale:de()}],"scale-x":[{"scale-x":de()}],"scale-y":[{"scale-y":de()}],"scale-z":[{"scale-z":de()}],"scale-3d":["scale-3d"],skew:[{skew:ee()}],"skew-x":[{"skew-x":ee()}],"skew-y":[{"skew-y":ee()}],transform:[{transform:[me,he,"","none","gpu","cpu"]}],"transform-origin":[{origin:v()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:be()}],"translate-x":[{"translate-x":be()}],"translate-y":[{"translate-y":be()}],"translate-z":[{"translate-z":be()}],"translate-none":["translate-none"],zoom:[{zoom:[ft,me,he]}],accent:[{accent:B()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:B()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",me,he]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":B()}],"scrollbar-track-color":[{"scrollbar-track":B()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":I()}],"scroll-mx":[{"scroll-mx":I()}],"scroll-my":[{"scroll-my":I()}],"scroll-ms":[{"scroll-ms":I()}],"scroll-me":[{"scroll-me":I()}],"scroll-mbs":[{"scroll-mbs":I()}],"scroll-mbe":[{"scroll-mbe":I()}],"scroll-mt":[{"scroll-mt":I()}],"scroll-mr":[{"scroll-mr":I()}],"scroll-mb":[{"scroll-mb":I()}],"scroll-ml":[{"scroll-ml":I()}],"scroll-p":[{"scroll-p":I()}],"scroll-px":[{"scroll-px":I()}],"scroll-py":[{"scroll-py":I()}],"scroll-ps":[{"scroll-ps":I()}],"scroll-pe":[{"scroll-pe":I()}],"scroll-pbs":[{"scroll-pbs":I()}],"scroll-pbe":[{"scroll-pbe":I()}],"scroll-pt":[{"scroll-pt":I()}],"scroll-pr":[{"scroll-pr":I()}],"scroll-pb":[{"scroll-pb":I()}],"scroll-pl":[{"scroll-pl":I()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",me,he]}],fill:[{fill:["none",...B()]}],"stroke-w":[{stroke:[Pe,ur,$t,Ia]}],stroke:[{stroke:["none",...B()]}],"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"]}},wc=Jd(kc),Ra=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Ma=Ws,Cr=(e,r)=>n=>{var a;if((r==null?void 0:r.variants)==null)return Ma(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:s}=r,l=Object.keys(o).map(h=>{const u=n==null?void 0:n[h],m=s==null?void 0:s[h];if(u===null)return null;const f=Ra(u)||Ra(m);return o[h][f]}),i=n&&Object.entries(n).reduce((h,u)=>{let[m,f]=u;return f===void 0||(h[m]=f),h},{}),d=r==null||(a=r.compoundVariants)===null||a===void 0?void 0:a.reduce((h,u)=>{let{class:m,className:f,...p}=u;return Object.entries(p).every(g=>{let[b,k]=g;return Array.isArray(k)?k.includes({...s,...i}[b]):{...s,...i}[b]===k})?[...h,m,f]:h},[]);return Ma(e,l,d,n==null?void 0:n.class,n==null?void 0:n.className)},Zr=c.createContext(null);Zr.displayName="PanelGroupContext";const qe={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},ta=10,Ot=c.useLayoutEffect,Aa=xd.useId,yc=typeof Aa=="function"?Aa:()=>null;let jc=0;function ra(e=null){const r=yc(),n=c.useRef(e||r||null);return n.current===null&&(n.current=""+jc++),e??n.current}function so({children:e,className:r="",collapsedSize:n,collapsible:a,defaultSize:o,forwardedRef:s,id:l,maxSize:i,minSize:d,onCollapse:h,onExpand:u,onResize:m,order:f,style:p,tagName:g="div",...b}){const k=c.useContext(Zr);if(k===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:x,expandPanel:j,getPanelSize:w,getPanelStyle:y,groupId:v,isPanelCollapsed:S,reevaluatePanelConstraints:N,registerPanel:I,resizePanel:M,unregisterPanel:R}=k,Q=ra(l),$=c.useRef({callbacks:{onCollapse:h,onExpand:u,onResize:m},constraints:{collapsedSize:n,collapsible:a,defaultSize:o,maxSize:i,minSize:d},id:Q,idIsFromProps:l!==void 0,order:f});c.useRef({didLogMissingDefaultSizeWarning:!1}),Ot(()=>{const{callbacks:Z,constraints:P}=$.current,te={...P};$.current.id=Q,$.current.idIsFromProps=l!==void 0,$.current.order=f,Z.onCollapse=h,Z.onExpand=u,Z.onResize=m,P.collapsedSize=n,P.collapsible=a,P.defaultSize=o,P.maxSize=i,P.minSize=d,(te.collapsedSize!==P.collapsedSize||te.collapsible!==P.collapsible||te.maxSize!==P.maxSize||te.minSize!==P.minSize)&&N($.current,te)}),Ot(()=>{const Z=$.current;return I(Z),()=>{R(Z)}},[f,Q,I,R]),c.useImperativeHandle(s,()=>({collapse:()=>{x($.current)},expand:Z=>{j($.current,Z)},getId(){return Q},getSize(){return w($.current)},isCollapsed(){return S($.current)},isExpanded(){return!S($.current)},resize:Z=>{M($.current,Z)}}),[x,j,w,S,Q,M]);const Y=y($.current,o);return c.createElement(g,{...b,children:e,className:r,id:Q,style:{...Y,...p},[qe.groupId]:v,[qe.panel]:"",[qe.panelCollapsible]:a||void 0,[qe.panelId]:Q,[qe.panelSize]:parseFloat(""+Y.flexGrow).toFixed(1)})}const oo=c.forwardRef((e,r)=>c.createElement(so,{...e,forwardedRef:r}));so.displayName="Panel";oo.displayName="forwardRef(Panel)";let Rn=null,Br=-1,Et=null;function Nc(e,r,n){const a=(r&uo)!==0,o=(r&mo)!==0,s=(r&po)!==0,l=(r&fo)!==0;if(r){if(a)return s?"se-resize":l?"ne-resize":"e-resize";if(o)return s?"sw-resize":l?"nw-resize":"w-resize";if(s)return"s-resize";if(l)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function Cc(){Et!==null&&(document.head.removeChild(Et),Rn=null,Et=null,Br=-1)}function xn(e,r,n){var a,o;const s=Nc(e,r);if(Rn!==s){if(Rn=s,Et===null&&(Et=document.createElement("style"),document.head.appendChild(Et)),Br>=0){var l;(l=Et.sheet)===null||l===void 0||l.removeRule(Br)}Br=(a=(o=Et.sheet)===null||o===void 0?void 0:o.insertRule(`*{cursor: ${s} !important;}`))!==null&&a!==void 0?a:-1}}function lo(e){return e.type==="keydown"}function io(e){return e.type.startsWith("pointer")}function co(e){return e.type.startsWith("mouse")}function Jr(e){if(io(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(co(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function Sc(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function Tc(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 Ec(e,r){if(e===r)throw new Error("Cannot compare node with itself");const n={a:Da(e),b:Da(r)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),r=n.b.pop(),a=e;Ie(a,"Stacking order can only be calculated for elements with a common ancestor");const o={a:$a(_a(n.a)),b:$a(_a(n.b))};if(o.a===o.b){const s=a.childNodes,l={a:n.a.at(-1),b:n.b.at(-1)};let i=s.length;for(;i--;){const d=s[i];if(d===l.a)return 1;if(d===l.b)return-1}}return Math.sign(o.a-o.b)}const Lc=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Ic(e){var r;const n=getComputedStyle((r=ho(e))!==null&&r!==void 0?r:e).display;return n==="flex"||n==="inline-flex"}function zc(e){const r=getComputedStyle(e);return!!(r.position==="fixed"||r.zIndex!=="auto"&&(r.position!=="static"||Ic(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"||Lc.test(r.willChange)||r.webkitOverflowScrolling==="touch")}function _a(e){let r=e.length;for(;r--;){const n=e[r];if(Ie(n,"Missing node"),zc(n))return n}return null}function $a(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Da(e){const r=[];for(;e;)r.push(e),e=ho(e);return r}function ho(e){const{parentNode:r}=e;return r&&r instanceof ShadowRoot?r.host:r}const uo=1,mo=2,po=4,fo=8,Pc=Sc()==="coarse";let mt=[],or=!1,Lt=new Map,Qr=new Map;const yr=new Set;function Rc(e,r,n,a,o){var s;const{ownerDocument:l}=r,i={direction:n,element:r,hitAreaMargins:a,setResizeHandlerState:o},d=(s=Lt.get(l))!==null&&s!==void 0?s:0;return Lt.set(l,d+1),yr.add(i),Vr(),function(){var u;Qr.delete(e),yr.delete(i);const m=(u=Lt.get(l))!==null&&u!==void 0?u:1;if(Lt.set(l,m-1),Vr(),m===1&&Lt.delete(l),mt.includes(i)){const f=mt.indexOf(i);f>=0&&mt.splice(f,1),en(),o("up",!0,null)}}}function Mc(e){const{target:r}=e,{x:n,y:a}=Jr(e);or=!0,na({target:r,x:n,y:a}),Vr(),mt.length>0&&(Kr("down",e),en(),e.preventDefault(),go(r)||e.stopImmediatePropagation())}function bn(e){const{x:r,y:n}=Jr(e);if(or&&e.type!=="pointerleave"&&e.buttons===0&&(or=!1,Kr("up",e)),!or){const{target:a}=e;na({target:a,x:r,y:n})}Kr("move",e),en(),mt.length>0&&e.preventDefault()}function vn(e){const{target:r}=e,{x:n,y:a}=Jr(e);Qr.clear(),or=!1,mt.length>0&&(e.preventDefault(),go(r)||e.stopImmediatePropagation()),Kr("up",e),na({target:r,x:n,y:a}),en(),Vr()}function go(e){let r=e;for(;r;){if(r.hasAttribute(qe.resizeHandle))return!0;r=r.parentElement}return!1}function na({target:e,x:r,y:n}){mt.splice(0);let a=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(a=e),yr.forEach(o=>{const{element:s,hitAreaMargins:l}=o,i=s.getBoundingClientRect(),{bottom:d,left:h,right:u,top:m}=i,f=Pc?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)&&Ec(a,s)>0){let g=a,b=!1;for(;g&&!g.contains(s);){if(Tc(g.getBoundingClientRect(),i)){b=!0;break}g=g.parentElement}if(b)return}mt.push(o)}})}function kn(e,r){Qr.set(e,r)}function en(){let e=!1,r=!1;mt.forEach(a=>{const{direction:o}=a;o==="horizontal"?e=!0:r=!0});let n=0;Qr.forEach(a=>{n|=a}),e&&r?xn("intersection",n):e?xn("horizontal",n):r?xn("vertical",n):Cc()}let wn;function Vr(){var e;(e=wn)===null||e===void 0||e.abort(),wn=new AbortController;const r={capture:!0,signal:wn.signal};yr.size&&(or?(mt.length>0&&Lt.forEach((n,a)=>{const{body:o}=a;n>0&&(o.addEventListener("contextmenu",vn,r),o.addEventListener("pointerleave",bn,r),o.addEventListener("pointermove",bn,r))}),Lt.forEach((n,a)=>{const{body:o}=a;o.addEventListener("pointerup",vn,r),o.addEventListener("pointercancel",vn,r)})):Lt.forEach((n,a)=>{const{body:o}=a;n>0&&(o.addEventListener("pointerdown",Mc,r),o.addEventListener("pointermove",bn,r))}))}function Kr(e,r){yr.forEach(n=>{const{setResizeHandlerState:a}=n,o=mt.includes(n);a(e,o,r)})}function Ac(){const[e,r]=c.useState(0);return c.useCallback(()=>r(n=>n+1),[])}function Ie(e,r){if(!e)throw console.error(r),Error(r)}function Ut(e,r,n=ta){return e.toFixed(n)===r.toFixed(n)?0:e>r?1:-1}function yt(e,r,n=ta){return Ut(e,r,n)===0}function dt(e,r,n){return Ut(e,r,n)===0}function _c(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(!dt(o,s,n))return!1}return!0}function ar({panelConstraints:e,panelIndex:r,size:n}){const a=e[r];Ie(a!=null,`Panel constraints not found for index ${r}`);let{collapsedSize:o=0,collapsible:s,maxSize:l=100,minSize:i=0}=a;if(Ut(n,i)<0)if(s){const d=(o+i)/2;Ut(n,d)<0?n=o:n=i}else n=i;return n=Math.min(l,n),n=parseFloat(n.toFixed(ta)),n}function xr({delta:e,initialLayout:r,panelConstraints:n,pivotIndices:a,prevLayout:o,trigger:s}){if(dt(e,0))return r;const l=[...r],[i,d]=a;Ie(i!=null,"Invalid first pivot index"),Ie(d!=null,"Invalid second pivot index");let h=0;if(s==="keyboard"){{const m=e<0?d:i,f=n[m];Ie(f,`Panel constraints not found for index ${m}`);const{collapsedSize:p=0,collapsible:g,minSize:b=0}=f;if(g){const k=r[m];if(Ie(k!=null,`Previous layout not found for panel index ${m}`),dt(k,p)){const x=b-k;Ut(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}{const m=e<0?i:d,f=n[m];Ie(f,`No panel constraints found for index ${m}`);const{collapsedSize:p=0,collapsible:g,minSize:b=0}=f;if(g){const k=r[m];if(Ie(k!=null,`Previous layout not found for panel index ${m}`),dt(k,b)){const x=k-p;Ut(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}}{const m=e<0?1:-1;let f=e<0?d:i,p=0;for(;;){const b=r[f];Ie(b!=null,`Previous layout not found for panel index ${f}`);const x=ar({panelConstraints:n,panelIndex:f,size:100})-b;if(p+=x,f+=m,f<0||f>=n.length)break}const g=Math.min(Math.abs(e),Math.abs(p));e=e<0?0-g:g}{let f=e<0?i:d;for(;f>=0&&f<n.length;){const p=Math.abs(e)-Math.abs(h),g=r[f];Ie(g!=null,`Previous layout not found for panel index ${f}`);const b=g-p,k=ar({panelConstraints:n,panelIndex:f,size:b});if(!dt(g,k)&&(h+=g-k,l[f]=k,h.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?f--:f++}}if(_c(o,l))return o;{const m=e<0?d:i,f=r[m];Ie(f!=null,`Previous layout not found for panel index ${m}`);const p=f+h,g=ar({panelConstraints:n,panelIndex:m,size:p});if(l[m]=g,!dt(g,p)){let b=p-g,x=e<0?d:i;for(;x>=0&&x<n.length;){const j=l[x];Ie(j!=null,`Previous layout not found for panel index ${x}`);const w=j+b,y=ar({panelConstraints:n,panelIndex:x,size:w});if(dt(j,y)||(b-=y-j,l[x]=y),dt(b,0))break;e>0?x--:x++}}}const u=l.reduce((m,f)=>f+m,0);return dt(u,100)?l:o}function $c({layout:e,panelsArray:r,pivotIndices:n}){let a=0,o=100,s=0,l=0;const i=n[0];Ie(i!=null,"No pivot index found"),r.forEach((m,f)=>{const{constraints:p}=m,{maxSize:g=100,minSize:b=0}=p;f===i?(a=b,o=g):(s+=b,l+=g)});const d=Math.min(o,100-s),h=Math.max(a,100-l),u=e[i];return{valueMax:d,valueMin:h,valueNow:u}}function jr(e,r=document){return Array.from(r.querySelectorAll(`[${qe.resizeHandleId}][data-panel-group-id="${e}"]`))}function xo(e,r,n=document){const o=jr(e,n).findIndex(s=>s.getAttribute(qe.resizeHandleId)===r);return o??null}function bo(e,r,n){const a=xo(e,r,n);return a!=null?[a,a+1]:[-1,-1]}function Dc(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function vo(e,r=document){if(Dc(r)&&r.dataset.panelGroupId==e)return r;const n=r.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function tn(e,r=document){const n=r.querySelector(`[${qe.resizeHandleId}="${e}"]`);return n||null}function Bc(e,r,n,a=document){var o,s,l,i;const d=tn(r,a),h=jr(e,a),u=d?h.indexOf(d):-1,m=(o=(s=n[u])===null||s===void 0?void 0:s.id)!==null&&o!==void 0?o:null,f=(l=(i=n[u+1])===null||i===void 0?void 0:i.id)!==null&&l!==void 0?l:null;return[m,f]}function Gc({committedValuesRef:e,eagerValuesRef:r,groupId:n,layout:a,panelDataArray:o,panelGroupElement:s,setLayout:l}){c.useRef({didWarnAboutMissingResizeHandle:!1}),Ot(()=>{if(!s)return;const i=jr(n,s);for(let d=0;d<o.length-1;d++){const{valueMax:h,valueMin:u,valueNow:m}=$c({layout:a,panelsArray:o,pivotIndices:[d,d+1]}),f=i[d];if(f!=null){const p=o[d];Ie(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;Ie(i,"Eager values not found");const{panelDataArray:d}=i,h=vo(n,s);Ie(h!=null,`No group found for id "${n}"`);const u=jr(n,s);Ie(u,`No resize handles found for group id "${n}"`);const m=u.map(f=>{const p=f.getAttribute(qe.resizeHandleId);Ie(p,"Resize handle element has no handle id attribute");const[g,b]=Bc(n,p,d,s);if(g==null||b==null)return()=>{};const k=x=>{if(!x.defaultPrevented)switch(x.key){case"Enter":{x.preventDefault();const j=d.findIndex(w=>w.id===g);if(j>=0){const w=d[j];Ie(w,`No panel data found for index ${j}`);const y=a[j],{collapsedSize:v=0,collapsible:S,minSize:N=0}=w.constraints;if(y!=null&&S){const I=xr({delta:dt(y,v)?N-v:v-y,initialLayout:a,panelConstraints:d.map(M=>M.constraints),pivotIndices:bo(n,p,s),prevLayout:a,trigger:"keyboard"});a!==I&&l(I)}}break}}};return f.addEventListener("keydown",k),()=>{f.removeEventListener("keydown",k)}});return()=>{m.forEach(f=>f())}},[s,e,r,n,a,o,l])}function Ba(e,r){if(e.length!==r.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==r[n])return!1;return!0}function ko(e,r){const n=e==="horizontal",{x:a,y:o}=Jr(r);return n?a:o}function Fc(e,r,n,a,o){const s=n==="horizontal",l=tn(r,o);Ie(l,`No resize handle element found for id "${r}"`);const i=l.getAttribute(qe.groupId);Ie(i,"Resize handle element has no group id attribute");let{initialCursorPosition:d}=a;const h=ko(n,e),u=vo(i,o);Ie(u,`No group element found for id "${i}"`);const m=u.getBoundingClientRect(),f=s?m.width:m.height;return(h-d)/f*100}function Hc(e,r,n,a,o,s){if(lo(e)){const l=n==="horizontal";let i=0;e.shiftKey?i=100:o!=null?i=o:i=10;let d=0;switch(e.key){case"ArrowDown":d=l?0:i;break;case"ArrowLeft":d=l?-i:0;break;case"ArrowRight":d=l?i:0;break;case"ArrowUp":d=l?0:-i;break;case"End":d=100;break;case"Home":d=-100;break}return d}else return a==null?0:Fc(e,r,n,a,s)}function Oc({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];Ie(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];Ie(l,`Panel constraints not found for index ${s}`);const{defaultSize:i}=l;if(i!=null)continue;const d=e.length-a,h=o/d;a++,r[s]=h,o-=h}return r}function Jt(e,r,n){r.forEach((a,o)=>{const s=e[o];Ie(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||yt(m,h))&&!yt(a,h)&&p(),f&&(m==null||!yt(m,h))&&yt(a,h)&&f())}})}function Rr(e,r){if(e.length!==r.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=r[n])return!1;return!0}function Wc({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 Uc(e,r=10){let n=null;return(...o)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...o)},r)}}function Ga(e){try{if(typeof localStorage<"u")e.getItem=r=>localStorage.getItem(r),e.setItem=(r,n)=>{localStorage.setItem(r,n)};else throw new Error("localStorage not supported in this environment")}catch(r){console.error(r),e.getItem=()=>null,e.setItem=()=>{}}}function wo(e){return`react-resizable-panels:${e}`}function yo(e){return e.map(r=>{const{constraints:n,id:a,idIsFromProps:o,order:s}=r;return o?a:s?`${s}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((r,n)=>r.localeCompare(n)).join(",")}function jo(e,r){try{const n=wo(e),a=r.getItem(n);if(a){const o=JSON.parse(a);if(typeof o=="object"&&o!=null)return o}}catch{}return null}function Vc(e,r,n){var a,o;const s=(a=jo(e,n))!==null&&a!==void 0?a:{},l=yo(r);return(o=s[l])!==null&&o!==void 0?o:null}function Kc(e,r,n,a,o){var s;const l=wo(e),i=yo(r),d=(s=jo(e,o))!==null&&s!==void 0?s:{};d[i]={expandToSizes:Object.fromEntries(n.entries()),layout:a};try{o.setItem(l,JSON.stringify(d))}catch(h){console.error(h)}}function Fa({layout:e,panelConstraints:r}){const n=[...e],a=n.reduce((s,l)=>s+l,0);if(n.length!==r.length)throw Error(`Invalid ${r.length} panel layout: ${n.map(s=>`${s}%`).join(", ")}`);if(!dt(a,100)&&n.length>0)for(let s=0;s<r.length;s++){const l=n[s];Ie(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];Ie(l!=null,`No layout data found for index ${s}`);const i=ar({panelConstraints:r,panelIndex:s,size:l});l!=i&&(o+=l-i,n[s]=i)}if(!dt(o,0))for(let s=0;s<r.length;s++){const l=n[s];Ie(l!=null,`No layout data found for index ${s}`);const i=l+o,d=ar({panelConstraints:r,panelIndex:s,size:i});if(l!==d&&(o-=d-l,n[s]=d,dt(o,0)))break}return n}const qc=100,br={getItem:e=>(Ga(br),br.getItem(e)),setItem:(e,r)=>{Ga(br),br.setItem(e,r)}},Ha={};function No({autoSaveId:e=null,children:r,className:n="",direction:a,forwardedRef:o,id:s=null,onLayout:l=null,keyboardResizeBy:i=null,storage:d=br,style:h,tagName:u="div",...m}){const f=ra(s),p=c.useRef(null),[g,b]=c.useState(null),[k,x]=c.useState([]),j=Ac(),w=c.useRef({}),y=c.useRef(new Map),v=c.useRef(0),S=c.useRef({autoSaveId:e,direction:a,dragState:g,id:f,keyboardResizeBy:i,onLayout:l,storage:d}),N=c.useRef({layout:k,panelDataArray:[],panelDataArrayChanged:!1});c.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),c.useImperativeHandle(o,()=>({getId:()=>S.current.id,getLayout:()=>{const{layout:L}=N.current;return L},setLayout:L=>{const{onLayout:q}=S.current,{layout:G,panelDataArray:E}=N.current,C=Fa({layout:L,panelConstraints:E.map(W=>W.constraints)});Ba(G,C)||(x(C),N.current.layout=C,q&&q(C),Jt(E,C,w.current))}}),[]),Ot(()=>{S.current.autoSaveId=e,S.current.direction=a,S.current.dragState=g,S.current.id=f,S.current.onLayout=l,S.current.storage=d}),Gc({committedValuesRef:S,eagerValuesRef:N,groupId:f,layout:k,panelDataArray:N.current.panelDataArray,setLayout:x,panelGroupElement:p.current}),c.useEffect(()=>{const{panelDataArray:L}=N.current;if(e){if(k.length===0||k.length!==L.length)return;let q=Ha[e];q==null&&(q=Uc(Kc,qc),Ha[e]=q);const G=[...L],E=new Map(y.current);q(e,G,E,k,d)}},[e,k,d]),c.useEffect(()=>{});const I=c.useCallback(L=>{const{onLayout:q}=S.current,{layout:G,panelDataArray:E}=N.current;if(L.constraints.collapsible){const C=E.map(V=>V.constraints),{collapsedSize:W=0,panelSize:H,pivotIndices:se}=Dt(E,L,G);if(Ie(H!=null,`Panel size not found for panel "${L.id}"`),!yt(H,W)){y.current.set(L.id,H);const de=er(E,L)===E.length-1?H-W:W-H,ee=xr({delta:de,initialLayout:G,panelConstraints:C,pivotIndices:se,prevLayout:G,trigger:"imperative-api"});Rr(G,ee)||(x(ee),N.current.layout=ee,q&&q(ee),Jt(E,ee,w.current))}}},[]),M=c.useCallback((L,q)=>{const{onLayout:G}=S.current,{layout:E,panelDataArray:C}=N.current;if(L.constraints.collapsible){const W=C.map(be=>be.constraints),{collapsedSize:H=0,panelSize:se=0,minSize:V=0,pivotIndices:de}=Dt(C,L,E),ee=q??V;if(yt(se,H)){const be=y.current.get(L.id),ie=be!=null&&be>=ee?be:ee,Ae=er(C,L)===C.length-1?se-ie:ie-se,ce=xr({delta:Ae,initialLayout:E,panelConstraints:W,pivotIndices:de,prevLayout:E,trigger:"imperative-api"});Rr(E,ce)||(x(ce),N.current.layout=ce,G&&G(ce),Jt(C,ce,w.current))}}},[]),R=c.useCallback(L=>{const{layout:q,panelDataArray:G}=N.current,{panelSize:E}=Dt(G,L,q);return Ie(E!=null,`Panel size not found for panel "${L.id}"`),E},[]),Q=c.useCallback((L,q)=>{const{panelDataArray:G}=N.current,E=er(G,L);return Wc({defaultSize:q,dragState:g,layout:k,panelData:G,panelIndex:E})},[g,k]),$=c.useCallback(L=>{const{layout:q,panelDataArray:G}=N.current,{collapsedSize:E=0,collapsible:C,panelSize:W}=Dt(G,L,q);return Ie(W!=null,`Panel size not found for panel "${L.id}"`),C===!0&&yt(W,E)},[]),Y=c.useCallback(L=>{const{layout:q,panelDataArray:G}=N.current,{collapsedSize:E=0,collapsible:C,panelSize:W}=Dt(G,L,q);return Ie(W!=null,`Panel size not found for panel "${L.id}"`),!C||Ut(W,E)>0},[]),Z=c.useCallback(L=>{const{panelDataArray:q}=N.current;q.push(L),q.sort((G,E)=>{const C=G.order,W=E.order;return C==null&&W==null?0:C==null?-1:W==null?1:C-W}),N.current.panelDataArrayChanged=!0,j()},[j]);Ot(()=>{if(N.current.panelDataArrayChanged){N.current.panelDataArrayChanged=!1;const{autoSaveId:L,onLayout:q,storage:G}=S.current,{layout:E,panelDataArray:C}=N.current;let W=null;if(L){const se=Vc(L,C,G);se&&(y.current=new Map(Object.entries(se.expandToSizes)),W=se.layout)}W==null&&(W=Oc({panelDataArray:C}));const H=Fa({layout:W,panelConstraints:C.map(se=>se.constraints)});Ba(E,H)||(x(H),N.current.layout=H,q&&q(H),Jt(C,H,w.current))}}),Ot(()=>{const L=N.current;return()=>{L.layout=[]}},[]);const P=c.useCallback(L=>{let q=!1;const G=p.current;return G&&window.getComputedStyle(G,null).getPropertyValue("direction")==="rtl"&&(q=!0),function(C){C.preventDefault();const W=p.current;if(!W)return()=>null;const{direction:H,dragState:se,id:V,keyboardResizeBy:de,onLayout:ee}=S.current,{layout:be,panelDataArray:ie}=N.current,{initialLayout:ye}=se??{},Ae=bo(V,L,W);let ce=Hc(C,L,H,se,de,W);const Ce=H==="horizontal";Ce&&q&&(ce=-ce);const Le=ie.map(ve=>ve.constraints),X=xr({delta:ce,initialLayout:ye??be,panelConstraints:Le,pivotIndices:Ae,prevLayout:be,trigger:lo(C)?"keyboard":"mouse-or-touch"}),ue=!Rr(be,X);(io(C)||co(C))&&v.current!=ce&&(v.current=ce,!ue&&ce!==0?Ce?kn(L,ce<0?uo:mo):kn(L,ce<0?po:fo):kn(L,0)),ue&&(x(X),N.current.layout=X,ee&&ee(X),Jt(ie,X,w.current))}},[]),te=c.useCallback((L,q)=>{const{onLayout:G}=S.current,{layout:E,panelDataArray:C}=N.current,W=C.map(be=>be.constraints),{panelSize:H,pivotIndices:se}=Dt(C,L,E);Ie(H!=null,`Panel size not found for panel "${L.id}"`);const de=er(C,L)===C.length-1?H-q:q-H,ee=xr({delta:de,initialLayout:E,panelConstraints:W,pivotIndices:se,prevLayout:E,trigger:"imperative-api"});Rr(E,ee)||(x(ee),N.current.layout=ee,G&&G(ee),Jt(C,ee,w.current))},[]),oe=c.useCallback((L,q)=>{const{layout:G,panelDataArray:E}=N.current,{collapsedSize:C=0,collapsible:W}=q,{collapsedSize:H=0,collapsible:se,maxSize:V=100,minSize:de=0}=L.constraints,{panelSize:ee}=Dt(E,L,G);ee!=null&&(W&&se&&yt(ee,C)?yt(C,H)||te(L,H):ee<de?te(L,de):ee>V&&te(L,V))},[te]),T=c.useCallback((L,q)=>{const{direction:G}=S.current,{layout:E}=N.current;if(!p.current)return;const C=tn(L,p.current);Ie(C,`Drag handle element not found for id "${L}"`);const W=ko(G,q);b({dragHandleId:L,dragHandleRect:C.getBoundingClientRect(),initialCursorPosition:W,initialLayout:E})},[]),re=c.useCallback(()=>{b(null)},[]),B=c.useCallback(L=>{const{panelDataArray:q}=N.current,G=er(q,L);G>=0&&(q.splice(G,1),delete w.current[L.id],N.current.panelDataArrayChanged=!0,j())},[j]),J=c.useMemo(()=>({collapsePanel:I,direction:a,dragState:g,expandPanel:M,getPanelSize:R,getPanelStyle:Q,groupId:f,isPanelCollapsed:$,isPanelExpanded:Y,reevaluatePanelConstraints:oe,registerPanel:Z,registerResizeHandle:P,resizePanel:te,startDragging:T,stopDragging:re,unregisterPanel:B,panelGroupElement:p.current}),[I,g,a,M,R,Q,f,$,Y,oe,Z,P,te,T,re,B]),K={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return c.createElement(Zr.Provider,{value:J},c.createElement(u,{...m,children:r,className:n,id:s,ref:p,style:{...K,...h},[qe.group]:"",[qe.groupDirection]:a,[qe.groupId]:f}))}const Co=c.forwardRef((e,r)=>c.createElement(No,{...e,forwardedRef:r}));No.displayName="PanelGroup";Co.displayName="forwardRef(PanelGroup)";function er(e,r){return e.findIndex(n=>n===r||n.id===r.id)}function Dt(e,r,n){const a=er(e,r),s=a===e.length-1?[a-1,a]:[a,a+1],l=n[a];return{...r.constraints,panelSize:l,pivotIndices:s}}function Xc({disabled:e,handleId:r,resizeHandler:n,panelGroupElement:a}){c.useEffect(()=>{if(e||n==null||a==null)return;const o=tn(r,a);if(o==null)return;const s=l=>{if(!l.defaultPrevented)switch(l.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{l.preventDefault(),n(l);break}case"F6":{l.preventDefault();const i=o.getAttribute(qe.groupId);Ie(i,`No group element found for id "${i}"`);const d=jr(i,a),h=xo(i,r,a);Ie(h!==null,`No resize element found for id "${r}"`);const u=l.shiftKey?h>0?h-1:d.length-1:h+1<d.length?h+1:0;d[u].focus();break}}};return o.addEventListener("keydown",s),()=>{o.removeEventListener("keydown",s)}},[a,e,r,n])}function So({children:e=null,className:r="",disabled:n=!1,hitAreaMargins:a,id:o,onBlur:s,onClick:l,onDragging:i,onFocus:d,onPointerDown:h,onPointerUp:u,style:m={},tabIndex:f=0,tagName:p="div",...g}){var b,k;const x=c.useRef(null),j=c.useRef({onClick:l,onDragging:i,onPointerDown:h,onPointerUp:u});c.useEffect(()=>{j.current.onClick=l,j.current.onDragging=i,j.current.onPointerDown=h,j.current.onPointerUp=u});const w=c.useContext(Zr);if(w===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:y,groupId:v,registerResizeHandle:S,startDragging:N,stopDragging:I,panelGroupElement:M}=w,R=ra(o),[Q,$]=c.useState("inactive"),[Y,Z]=c.useState(!1),[P,te]=c.useState(null),oe=c.useRef({state:Q});Ot(()=>{oe.current.state=Q}),c.useEffect(()=>{if(n)te(null);else{const J=S(R);te(()=>J)}},[n,R,S]);const T=(b=a==null?void 0:a.coarse)!==null&&b!==void 0?b:15,re=(k=a==null?void 0:a.fine)!==null&&k!==void 0?k:5;c.useEffect(()=>{if(n||P==null)return;const J=x.current;Ie(J,"Element ref not attached");let K=!1;return Rc(R,J,y,{coarse:T,fine:re},(q,G,E)=>{if(!G){$("inactive");return}switch(q){case"down":{$("drag"),K=!1,Ie(E,'Expected event to be defined for "down" action'),N(R,E);const{onDragging:C,onPointerDown:W}=j.current;C==null||C(!0),W==null||W();break}case"move":{const{state:C}=oe.current;K=!0,C!=="drag"&&$("hover"),Ie(E,'Expected event to be defined for "move" action'),P(E);break}case"up":{$("hover"),I();const{onClick:C,onDragging:W,onPointerUp:H}=j.current;W==null||W(!1),H==null||H(),K||C==null||C();break}}})},[T,y,n,re,S,R,P,N,I]),Xc({disabled:n,handleId:R,resizeHandler:P,panelGroupElement:M});const B={touchAction:"none",userSelect:"none"};return c.createElement(p,{...g,children:e,className:r,id:o,onBlur:()=>{Z(!1),s==null||s()},onFocus:()=>{Z(!0),d==null||d()},ref:x,role:"separator",style:{...B,...m},tabIndex:f,[qe.groupDirection]:y,[qe.groupId]:v,[qe.resizeHandle]:"",[qe.resizeHandleActive]:Q==="drag"?"pointer":Y?"keyboard":void 0,[qe.resizeHandleEnabled]:!n,[qe.resizeHandleId]:R,[qe.resizeHandleState]:Q})}So.displayName="PanelResizeHandle";var Yc=Object.defineProperty,Zc=Object.getOwnPropertyNames,Oe=(e,r)=>function(){return e&&(r=(0,e[Zc(e)[0]])(e=0)),r},Jc=(e,r)=>{for(var n in r)Yc(e,n,{get:r[n],enumerable:!0})};function rt(...e){return wc(Ws(e))}var Pt=Oe({"src/components/graph-ui/utils.ts"(){}});function Nr({asChild:e=!1,className:r,size:n,variant:a,...o}){const s=e?Gs:"button";return t.jsx(s,{"data-slot":"button",className:rt(To({variant:a,size:n,className:r})),...o})}var To,rn=Oe({"src/components/graph-ui/Button.tsx"(){Pt(),To=Cr("inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium outline-none transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}})}});function Eo(...e){return e.filter(Boolean).join(" ")}function Mn({className:e,...r}){return t.jsx(Co,{"data-slot":"resizable-panel-group",className:Eo("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...r})}function sr({...e}){return t.jsx(oo,{"data-slot":"resizable-panel",...e})}function An({withHandle:e,className:r,...n}){return t.jsx(So,{"data-slot":"resizable-handle",className:Eo("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",r),...n,children:e?t.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:t.jsx(D.GripVerticalIcon,{className:"size-2.5"})}):null})}var Lo=Oe({"src/components/graph-workspace/GraphResizablePanels.tsx"(){}});function aa(...e){return e.filter(Boolean).join(" ")}function Sr({...e}){return t.jsx(Ki,{"data-slot":"accordion",...e})}function Tr({className:e,...r}){return t.jsx(qi,{"data-slot":"accordion-item",className:aa("border-b last:border-b-0",e),...r})}function nn({className:e,children:r,...n}){return t.jsx(Yi,{className:"flex",children:t.jsxs(Zi,{"data-slot":"accordion-trigger",className:aa("flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium outline-none transition-all hover:underline disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",e),...n,children:[r,t.jsx(D.ChevronDownIcon,{className:"pointer-events-none size-4 shrink-0 translate-y-0.5 text-[var(--theme-fg-muted)] transition-transform duration-200"})]})})}function Er({className:e,children:r,...n}){return t.jsx(Xi,{"data-slot":"accordion-content",className:"overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:t.jsx("div",{className:aa("pb-4 pt-0",e),children:r})})}var Lr=Oe({"src/components/graph-workspace/GraphAccordion.tsx"(){}});function Qc(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 eh(e){return e.trim().replace(/^\/+|\/+$/g,"").replace(/[^\w.-]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function Ir(e){var r;return((r=e.split(".").pop())==null?void 0:r.toLowerCase())||""}function th(e){return e.split("/").filter(Boolean).at(-1)??e}function tr(e){const r=e.kind==="directory"?"directory":"file",n=(e.children??[]).map(tr);return{id:`workspace:${e.path}`,name:e.name,path:e.path,kind:r,...e.size!==void 0?{size:e.size}:{},...e.hasChildren!==void 0?{hasChildren:e.hasChildren}:r==="directory"?{hasChildren:n.length>0}:{},...e.childrenLoaded!==void 0?{childrenLoaded:e.childrenLoaded}:r==="directory"?{childrenLoaded:e.children!==void 0}:{},...e.truncated!==void 0?{truncated:e.truncated}:{},workspaceNode:e,children:n}}function Io(e,r,n,a={}){if(e.path===r)return{...e,children:n,hasChildren:n.length>0,childrenLoaded:!0,truncated:a.truncated??e.truncated};if(e.children.length===0)return e;let o=!1;const s=e.children.map(l=>{const i=Io(l,r,n,a);return i!==l&&(o=!0),i});return o?{...e,children:s}:e}function zo(e){if(e.kind==="file")return e;for(const r of e.children){const n=zo(r);if(n)return n}return null}function _n(e,r){if(!e||r===null)return null;if(e.path===r)return e;for(const n of e.children){const a=_n(n,r);if(a)return a}return null}function Po(e){return e.trim().replace(/\\/g,"/").replace(/^\.\/+/,"").replace(/^\/+/,"")}function rh(e){const n=Po(e).split("/").filter(Boolean);n.pop();const a=[];let o="";for(const s of n)o=o?`${o}/${s}`:s,a.push(o);return a}function $n(e,r,n){if(e.path===r)return n;if(e.children.length===0)return e;let a=!1;const o=e.children.map(s=>{const l=$n(s,r,n);return l!==s&&(a=!0),l});return a?{...e,children:o}:e}function Dn(e,r){return!e||!r?!1:e.path===r?!0:e.children.some(n=>Dn(n,r))}function nh(e){if(!e)return null;const r=Ir(e.path);return sa.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 sh(e){const r=Ir(e);return r==="tsx"||r==="jsx"?"tsx":r==="yml"?"yaml":r||"text"}function oh(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 lh(e,r,n){const a=r.split("/").filter(Boolean),o=a.pop()??n.name;oh(e,a).children.push({...n,name:n.name||o,path:r})}function ih(e,r){return e.kind==="directory"&&r.kind!=="directory"?-1:e.kind!=="directory"&&r.kind==="directory"?1:e.name.localeCompare(r.name)}function Ao(e){e.children.sort(ih);for(const r of e.children)Ao(r);return e}function Ua(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=th(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`,v="text"in f&&typeof f.text=="string"?f.text.slice(0,160):f.kind,x=f.kind==="artifact"&&f.artifact?f.artifact:null,j=x&&p?{id:`live-artifact:${x.id}`,name:x.title||x.id,path:b,kind:"live-artifact",artifact:x,item:f,preview:x.summaryText??x.type,detail:JSON.stringify(x.payload,null,2),children:[]}:{id:`event:${f.id}`,name:rh(b),path:b,kind:"event",item:f,preview:v,detail:JSON.stringify(f,null,2),children:[]};if(p){i.children.push(j);return}lh(l,b.replace(/^thread-events\//,""),j)};for(const m of e.turns)for(const f of m.items)(f.kind==="commandExecution"||f.kind==="webSearch"||f.kind==="fileRead"||f.kind==="fileChange"||f.kind==="agentToolCall"||f.kind==="skillToolCall"||f.kind==="toolCall"||f.kind==="hook"||f.kind==="plan"||f.kind==="reasoning")&&h(m.id,f);for(const m of((u=e.liveItems)==null?void 0:u.items)??[])h(e.thread.activeTurnId??"live",m,!0);return o.children.push(s,l,i),Ao(o)}function dh(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 $o(e){if(e.kind==="artifact"||e.kind==="live-artifact"||e.kind==="event"||e.kind==="file")return e;for(const r of e.children){const n=$o(r);if(n)return n}return null}function Va(e){const r=e.split("/").filter(Boolean),n=[];for(let a=1;a<=r.length;a+=1)n.push(r.slice(0,a).join("/"));return n}var oa,_o,Do,la=Oe({"src/components/graph-workspace/workspaceTree.ts"(){oa=new Set(["xyz","extxyz","cif","pdb"]),_o=new Set(["png","jpg","jpeg","gif","webp","svg"]),Do=new Set(["pdf"])}});function rr({label:e,children:r}){return t.jsxs("section",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:e}),t.jsx("div",{className:"mt-2 text-sm text-[var(--theme-fg)]",children:r})]})}var Bo=Oe({"src/components/graph-workspace/GraphWorkspaceCards.tsx"(){}});function ch({className:e,decorative:r=!0,orientation:n="horizontal",...a}){return t.jsx(gd,{"data-slot":"separator",decorative:r,orientation:n,className:rt("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 hh=Oe({"src/components/graph-ui/Separator.tsx"(){Pt()}});function uh({className:e,orientation:r,...n}){return t.jsx("div",{role:"group","data-slot":"button-group","data-orientation":r,className:rt(Go({orientation:r}),e),...n})}function mh({className:e,orientation:r="vertical",...n}){return t.jsx(ch,{"data-slot":"button-group-separator",orientation:r,className:rt("relative !m-0 self-stretch bg-input data-[orientation=vertical]:h-auto",e),...n})}var Go,Fo=Oe({"src/components/graph-ui/ButtonGroup.tsx"(){hh(),Pt(),Go=Cr("flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}})}});function ph({delayDuration:e=0,...r}){return t.jsx(xd,{"data-slot":"tooltip-provider",delayDuration:e,...r})}function fh({...e}){return t.jsx(ph,{children:t.jsx(hd,{"data-slot":"tooltip",...e})})}function gh({...e}){return t.jsx(ud,{"data-slot":"tooltip-trigger",...e})}function xh({children:e,className:r,sideOffset:n=0,...a}){return t.jsx(md,{children:t.jsxs(pd,{"data-slot":"tooltip-content",sideOffset:n,className:rt("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(fd,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}var bh=Oe({"src/components/graph-ui/Tooltip.tsx"(){Pt()}});function vh(e){return(e==null?void 0:e.trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""))||"molecule"}function Ka(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 Ze({children:e,disabled:r,label:n,onClick:a}){return t.jsxs(fh,{children:[t.jsx(gh,{asChild:!0,children:t.jsx(Nr,{type:"button",variant:"outline",size:"icon",className:"thread-graph-molecule-button size-8",disabled:r,onClick:a,title:n,"aria-label":n,children:e})}),t.jsx(xh,{children:t.jsx("p",{children:n})})]})}function Gn({children:e,className:r=""}){return t.jsx(uh,{className:`thread-graph-molecule-button-group ${r}`,children:e})}var Ho=Oe({"src/components/graph-workspace/GraphMoleculeViewerControls.tsx"(){nn(),Fo(),bh()}});function kh({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(Gn,{children:[t.jsx(Ze,{label:"Distance",children:t.jsx(B.AlignVerticalDistributeCenter,{className:"size-4"})}),t.jsx(Ze,{label:"Connectivity",children:t.jsx(B.Share2,{className:"size-4"})}),t.jsx(Ze,{label:"Angle",children:t.jsx(B.Waypoints,{className:"size-4"})}),t.jsx(Ze,{label:"Dihedral",children:t.jsx(B.Spline,{className:"size-4"})}),t.jsx(Ze,{label:"Add dummy atoms",children:t.jsx(B.Bubbles,{className:"size-4"})}),t.jsx(Ze,{label:"Delete atoms",children:t.jsx(B.CircleX,{className:"size-4"})}),t.jsx(Ze,{label:"Rotate",children:t.jsx(B.Rotate3d,{className:"size-4"})})]}),t.jsxs(Gn,{children:[t.jsx(Ze,{label:f?"Hide unit cell":"Show unit cell",disabled:!m,onClick:l,children:t.jsx(B.Boxes,{className:"size-4"})}),t.jsx(Ze,{label:"Clear selection",disabled:!p,onClick:r,children:t.jsx(B.Trash2,{className:"size-4"})}),t.jsx(Ze,{label:"Send selection",disabled:!p,onClick:a,children:t.jsx(B.Send,{className:"size-4"})}),t.jsx(Ze,{label:"Stage current selection",disabled:!p,onClick:s,children:t.jsx(B.Box,{className:"size-4"})}),t.jsx(Ze,{label:"Clear staged selections",disabled:!g,onClick:n,children:t.jsx(B.Eraser,{className:"size-4"})}),t.jsx(Ze,{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 wh=Oe({"src/components/graph-workspace/GraphMoleculeViewerLowerButtonGroup.tsx"(){Ho()}});function yh({currentIndex:e,exportContent:r,moleculeId:n,onScreenshot:a,viewerRef:o,xyzContent:s,xyzFormat:l}){const i=vh(n);async function d(){s&&await navigator.clipboard.writeText(s)}function h(){s&&Ka(s,`${i}_step_${e+1}.${l||"xyz"}`)}function u(){r&&Ka(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(Gn,{className:"ml-auto justify-end",children:[t.jsx(Ze,{label:"Copy current structure",onClick:()=>void d(),disabled:!s,children:t.jsx(B.Copy,{className:"size-3.5"})}),t.jsx(Ze,{label:"Download current structure",onClick:h,disabled:!s,children:t.jsx(B.Download,{className:"size-3.5"})}),t.jsx(Ze,{label:"Download full trajectory",onClick:u,disabled:!r,children:t.jsx(B.Box,{className:"size-3.5"})}),t.jsx(Ze,{label:"Copy screenshot",onClick:a,disabled:!o.current||!s,children:t.jsx(B.Camera,{className:"size-3.5"})}),t.jsx(mh,{className:"thread-graph-molecule-button-divider"}),t.jsx(Ze,{label:"Zoom in",onClick:m,disabled:!o.current||!s,children:t.jsx(B.ZoomIn,{className:"size-3.5"})}),t.jsx(Ze,{label:"Zoom out",onClick:f,disabled:!o.current||!s,children:t.jsx(B.ZoomOut,{className:"size-3.5"})}),t.jsx(Ze,{label:"Reset camera",onClick:p,disabled:!o.current||!s,children:t.jsx(B.RotateCcw,{className:"size-3.5"})})]})}var jh=Oe({"src/components/graph-workspace/GraphMoleculeViewerUpperButtonGroup.tsx"(){Fo(),Ho()}});async function Nh(){if(typeof window>"u")throw new Error("3Dmol is only available in a browser environment.");return window["3Dmol"]?window["3Dmol"]:(Fr||(Fr=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)})),Fr)}var Fr,Ch=Oe({"src/components/graph-workspace/load3Dmol.ts"(){Fr=null}});function Sh({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(ld,{"data-slot":"slider",...r!==void 0?{defaultValue:r}:{},...o!==void 0?{value:o}:{},min:a,max:n,className:rt("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(id,{"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(dd,{"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(cd,{"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 Th=Oe({"src/components/graph-ui/Slider.tsx"(){Pt()}});function Eh(e){const r=e==null?void 0:e.trim().toLowerCase();return!r||r==="extxyz"?"xyz":r}function Lh(e){var o,s;const r=e.replace(/\r\n/g,`
|
|
4
|
+
`],format:r==="extxyz"?"xyz":r,name:e.name,uuid:e.path}:null}function ah(e){const r=Ir(e);return r==="tsx"||r==="jsx"?"tsx":r==="yml"?"yaml":r||"text"}function sh(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 oh(e,r,n){const a=r.split("/").filter(Boolean),o=a.pop()??n.name;sh(e,a).children.push({...n,name:n.name||o,path:r})}function lh(e,r){return e.kind==="directory"&&r.kind!=="directory"?-1:e.kind!=="directory"&&r.kind==="directory"?1:e.name.localeCompare(r.name)}function Ro(e){e.children.sort(lh);for(const r of e.children)Ro(r);return e}function Oa(e,r,n,a){var u;const o={id:"root",name:e.workspace.label??"Workspace",path:"",kind:"directory",children:[]},s={id:"artifacts",name:"artifacts",path:"artifacts",kind:"directory",children:[]};for(const m of r){const f=m.title||m.id,p=eh(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`,k="text"in f&&typeof f.text=="string"?f.text.slice(0,160):f.kind,x=f.kind==="artifact"&&f.artifact?f.artifact:null,j=x&&p?{id:`live-artifact:${x.id}`,name:x.title||x.id,path:b,kind:"live-artifact",artifact:x,item:f,preview:x.summaryText??x.type,detail:JSON.stringify(x.payload,null,2),children:[]}:{id:`event:${f.id}`,name:th(b),path:b,kind:"event",item:f,preview:k,detail:JSON.stringify(f,null,2),children:[]};if(p){i.children.push(j);return}oh(l,b.replace(/^thread-events\//,""),j)};for(const m of e.turns)for(const f of m.items)(f.kind==="commandExecution"||f.kind==="webSearch"||f.kind==="fileRead"||f.kind==="fileChange"||f.kind==="agentToolCall"||f.kind==="skillToolCall"||f.kind==="toolCall"||f.kind==="hook"||f.kind==="plan"||f.kind==="reasoning")&&h(m.id,f);for(const m of((u=e.liveItems)==null?void 0:u.items)??[])h(e.thread.activeTurnId??"live",m,!0);return o.children.push(s,l,i),Ro(o)}function ih(e){const r=new Map,n=a=>{r.set(a.id,a);for(const o of a.children)n(o)};return n(e),r}function Mo(e){if(e.kind==="artifact"||e.kind==="live-artifact"||e.kind==="event"||e.kind==="file")return e;for(const r of e.children){const n=Mo(r);if(n)return n}return null}function Wa(e){const r=e.split("/").filter(Boolean),n=[];for(let a=1;a<=r.length;a+=1)n.push(r.slice(0,a).join("/"));return n}var sa,Ao,_o,oa=Oe({"src/components/graph-workspace/workspaceTree.ts"(){sa=new Set(["xyz","extxyz","cif","pdb"]),Ao=new Set(["png","jpg","jpeg","gif","webp","svg"]),_o=new Set(["pdf"])}});function rr({label:e,children:r}){return t.jsxs("section",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:e}),t.jsx("div",{className:"mt-2 text-sm text-[var(--theme-fg)]",children:r})]})}var $o=Oe({"src/components/graph-workspace/GraphWorkspaceCards.tsx"(){}});function dh({className:e,decorative:r=!0,orientation:n="horizontal",...a}){return t.jsx(fd,{"data-slot":"separator",decorative:r,orientation:n,className:rt("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 ch=Oe({"src/components/graph-ui/Separator.tsx"(){Pt()}});function hh({className:e,orientation:r,...n}){return t.jsx("div",{role:"group","data-slot":"button-group","data-orientation":r,className:rt(Do({orientation:r}),e),...n})}function uh({className:e,orientation:r="vertical",...n}){return t.jsx(dh,{"data-slot":"button-group-separator",orientation:r,className:rt("relative !m-0 self-stretch bg-input data-[orientation=vertical]:h-auto",e),...n})}var Do,Bo=Oe({"src/components/graph-ui/ButtonGroup.tsx"(){ch(),Pt(),Do=Cr("flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}})}});function mh({delayDuration:e=0,...r}){return t.jsx(gd,{"data-slot":"tooltip-provider",delayDuration:e,...r})}function ph({...e}){return t.jsx(mh,{children:t.jsx(cd,{"data-slot":"tooltip",...e})})}function fh({...e}){return t.jsx(hd,{"data-slot":"tooltip-trigger",...e})}function gh({children:e,className:r,sideOffset:n=0,...a}){return t.jsx(ud,{children:t.jsxs(md,{"data-slot":"tooltip-content",sideOffset:n,className:rt("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(pd,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}var xh=Oe({"src/components/graph-ui/Tooltip.tsx"(){Pt()}});function bh(e){return(e==null?void 0:e.trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""))||"molecule"}function Ua(e,r){const n=new Blob([e],{type:"text/plain"}),a=URL.createObjectURL(n),o=document.createElement("a");o.href=a,o.download=r,o.click(),URL.revokeObjectURL(a)}function Ze({children:e,disabled:r,label:n,onClick:a}){return t.jsxs(ph,{children:[t.jsx(fh,{asChild:!0,children:t.jsx(Nr,{type:"button",variant:"outline",size:"icon",className:"thread-graph-molecule-button size-8",disabled:r,onClick:a,title:n,"aria-label":n,children:e})}),t.jsx(gh,{children:t.jsx("p",{children:n})})]})}function Bn({children:e,className:r=""}){return t.jsx(hh,{className:`thread-graph-molecule-button-group ${r}`,children:e})}var Go=Oe({"src/components/graph-workspace/GraphMoleculeViewerControls.tsx"(){rn(),Bo(),xh()}});function vh({cameraInfo:e,onClearSelection:r,onClearStaged:n,onSendSelection:a,onSendStaged:o,onStageSelection:s,onToggleUnitCell:l,selectedAtomLabels:i,selectedSerials:d,stagedAtoms:h,stagedMolecules:u,unitCellAvailable:m,unitCellVisible:f}){const p=d.length>0,g=h>0;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex w-full justify-between gap-2 overflow-x-auto",children:[t.jsxs(Bn,{children:[t.jsx(Ze,{label:"Distance",children:t.jsx(D.AlignVerticalDistributeCenter,{className:"size-4"})}),t.jsx(Ze,{label:"Connectivity",children:t.jsx(D.Share2,{className:"size-4"})}),t.jsx(Ze,{label:"Angle",children:t.jsx(D.Waypoints,{className:"size-4"})}),t.jsx(Ze,{label:"Dihedral",children:t.jsx(D.Spline,{className:"size-4"})}),t.jsx(Ze,{label:"Add dummy atoms",children:t.jsx(D.Bubbles,{className:"size-4"})}),t.jsx(Ze,{label:"Delete atoms",children:t.jsx(D.CircleX,{className:"size-4"})}),t.jsx(Ze,{label:"Rotate",children:t.jsx(D.Rotate3d,{className:"size-4"})})]}),t.jsxs(Bn,{children:[t.jsx(Ze,{label:f?"Hide unit cell":"Show unit cell",disabled:!m,onClick:l,children:t.jsx(D.Boxes,{className:"size-4"})}),t.jsx(Ze,{label:"Clear selection",disabled:!p,onClick:r,children:t.jsx(D.Trash2,{className:"size-4"})}),t.jsx(Ze,{label:"Send selection",disabled:!p,onClick:a,children:t.jsx(D.Send,{className:"size-4"})}),t.jsx(Ze,{label:"Stage current selection",disabled:!p,onClick:s,children:t.jsx(D.Box,{className:"size-4"})}),t.jsx(Ze,{label:"Clear staged selections",disabled:!g,onClick:n,children:t.jsx(D.Eraser,{className:"size-4"})}),t.jsx(Ze,{label:"Send staged selections",disabled:!g,onClick:o,children:t.jsx(D.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 kh=Oe({"src/components/graph-workspace/GraphMoleculeViewerLowerButtonGroup.tsx"(){Go()}});function wh({currentIndex:e,exportContent:r,moleculeId:n,onScreenshot:a,viewerRef:o,xyzContent:s,xyzFormat:l}){const i=bh(n);async function d(){s&&await navigator.clipboard.writeText(s)}function h(){s&&Ua(s,`${i}_step_${e+1}.${l||"xyz"}`)}function u(){r&&Ua(r,`${i}_trajectory.${l||"xyz"}`)}function m(){o.current&&(o.current.zoom(1.2),o.current.render())}function f(){o.current&&(o.current.zoom(.8),o.current.render())}function p(){o.current&&(o.current.zoomTo(),o.current.setCameraParameters({}),o.current.render())}return t.jsxs(Bn,{className:"ml-auto justify-end",children:[t.jsx(Ze,{label:"Copy current structure",onClick:()=>void d(),disabled:!s,children:t.jsx(D.Copy,{className:"size-3.5"})}),t.jsx(Ze,{label:"Download current structure",onClick:h,disabled:!s,children:t.jsx(D.Download,{className:"size-3.5"})}),t.jsx(Ze,{label:"Download full trajectory",onClick:u,disabled:!r,children:t.jsx(D.Box,{className:"size-3.5"})}),t.jsx(Ze,{label:"Copy screenshot",onClick:a,disabled:!o.current||!s,children:t.jsx(D.Camera,{className:"size-3.5"})}),t.jsx(uh,{className:"thread-graph-molecule-button-divider"}),t.jsx(Ze,{label:"Zoom in",onClick:m,disabled:!o.current||!s,children:t.jsx(D.ZoomIn,{className:"size-3.5"})}),t.jsx(Ze,{label:"Zoom out",onClick:f,disabled:!o.current||!s,children:t.jsx(D.ZoomOut,{className:"size-3.5"})}),t.jsx(Ze,{label:"Reset camera",onClick:p,disabled:!o.current||!s,children:t.jsx(D.RotateCcw,{className:"size-3.5"})})]})}var yh=Oe({"src/components/graph-workspace/GraphMoleculeViewerUpperButtonGroup.tsx"(){Bo(),Go()}});async function jh(){if(typeof window>"u")throw new Error("3Dmol is only available in a browser environment.");return window["3Dmol"]?window["3Dmol"]:(Gr||(Gr=new Promise((e,r)=>{const n=document.querySelector('script[data-remote-codex-3dmol="true"]'),a=()=>{if(window["3Dmol"]){e(window["3Dmol"]);return}r(new Error("3Dmol loaded without exposing the expected global."))};if(n){n.addEventListener("load",a,{once:!0}),n.addEventListener("error",()=>r(new Error("Unable to load 3Dmol viewer runtime.")),{once:!0});return}const o=document.createElement("script");o.src="/vendor/3Dmol-min.js",o.async=!0,o.dataset.remoteCodex3dmol="true",o.addEventListener("load",a,{once:!0}),o.addEventListener("error",()=>r(new Error("Unable to load 3Dmol viewer runtime.")),{once:!0}),document.head.appendChild(o)})),Gr)}var Gr,Nh=Oe({"src/components/graph-workspace/load3Dmol.ts"(){Gr=null}});function Ch({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(od,{"data-slot":"slider",...r!==void 0?{defaultValue:r}:{},...o!==void 0?{value:o}:{},min:a,max:n,className:rt("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(ld,{"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(id,{"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(dd,{"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 Sh=Oe({"src/components/graph-ui/Slider.tsx"(){Pt()}});function Th(e){const r=e==null?void 0:e.trim().toLowerCase();return!r||r==="extxyz"?"xyz":r}function Eh(e){var o,s;const r=e.replace(/\r\n/g,`
|
|
5
5
|
`).replace(/\r/g,`
|
|
6
6
|
`).split(`
|
|
7
7
|
`),n=[];let a=0;for(;a<r.length;){for(;a<r.length&&((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
|
-
`),a+=i}return n.length>0?n:[e]}function
|
|
10
|
-
`).join("")}function
|
|
11
|
-
`).slice(2).map(
|
|
12
|
-
`).length<=Wo}function Ah(e){return e&&(e.node.path||e.node.name)||null}function $h(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 _h({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,v]=c.useState(null),[x,j]=c.useState(!1),w=(u==null?void 0:u.node)??null,y=w!=null&&w.artifact?h.renderArtifact({artifact:w.artifact,expanded:!0,onToggleExpanded:()=>{}}):null,k=ah(i??null),S=(i==null?void 0:i.language)||sh((i==null?void 0:i.path)??""),N=i?Ir(i.path):"",L=Ah(u),R=i!==null&&oa.has(N),P=!!(i&&a)&&!R&&Mh(i),J=(u==null?void 0:u.kind)==="live-molecule",D=!!(w!=null&&w.artifact&&y),Y=!!k||D;c.useEffect(()=>{f(!1),g((i==null?void 0:i.content)??""),v(null)},[i==null?void 0:i.path,i==null?void 0:i.content]);async function Z(){if(!(!i||!a)){j(!0),v(null);try{await a({path:i.path,content:p}),f(!1)}catch(I){v(I instanceof Error?I.message:"Failed to save file.")}finally{j(!1)}}}return t.jsxs("section",{className:"thread-graph-viewer flex h-full min-h-0 flex-col overflow-hidden rounded-[12px]","data-preview-target-kind":(u==null?void 0:u.kind)??"none",children:[t.jsxs("div",{className:"thread-graph-viewer-header flex h-12 shrink-0 items-center justify-between gap-3 border-b px-3 sm:h-[60px] sm:px-5",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[t.jsx("h2",{className:"text-base font-semibold text-slate-900 sm:text-[18px] dark:text-slate-100",children:"Viewer"}),L?t.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-slate-500 dark:text-slate-400",children:L}):null]}),s?t.jsx("button",{type:"button",onClick:s,"data-testid":"collapse-viewer",className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-[#222733] dark:hover:text-slate-100",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(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"&&k?t.jsx("div",{className:"thread-graph-molecule-preview min-h-0 flex-1 overflow-hidden",children:t.jsx(Ph,{source:k,moleculeId:k.uuid??u.node.path,title:"PyMOL-style (PDB/CIF)"})}):u.kind==="workspace-file"&&r?t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-auto p-5",children:t.jsx("img",{src:r,alt:u.node.path||u.node.name,className:"max-h-full max-w-full object-contain"})}):u.kind==="workspace-file"&&l?t.jsx("div",{className:"thread-graph-file-preview-frame min-h-0 flex-1 overflow-hidden",children:t.jsx("iframe",{src:l,title:`PDF preview: ${u.node.path||u.node.name}`,className:"h-full w-full border-0"})}):u.kind==="workspace-file"&&i?t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs("div",{className:"thread-graph-file-preview-header flex min-h-12 items-center justify-between gap-3 border-b px-4 py-2",children:[t.jsxs("div",{className:"min-w-0 text-xs uppercase tracking-[0.12em]",children:[R?"molecule":S||N||"text"," |"," ",i.size.toLocaleString()," bytes",i.truncated?t.jsxs("span",{className:"ml-2 text-amber-500",children:["showing ",i.nextOffset.toLocaleString()," bytes"]}):null]}),P?t.jsx("div",{className:"flex shrink-0 items-center gap-1",children:m?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>{g(i.content),f(!1),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:I=>g(I.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(Hr,{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:Y||J?"min-h-0 flex-1 overflow-hidden":"min-h-0 flex-1 overflow-auto p-3",children:y}):u.kind==="meta"?t.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-3",children:t.jsx("div",{className:"grid gap-3",children:t.jsx(rr,{label:"Workspace Data",children:t.jsx(Hr,{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(Hr,{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 Oo,Wo,Hr,Dh=Oe({"src/components/graph-workspace/GraphWorkspacePreviewPane.tsx"(){la(),Bo(),Rh(),Oo=50*1024,Wo=1e3,Hr=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 Bh({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 Gh=Oe({"src/components/graph-workspace/GraphEmptyGarbageDialog.tsx"(){}});function Uo(e){return`${Ko}${e.workspaceId??"workspace"}:${e.threadId}`}function Fh(e){if(typeof window>"u")return[];try{const r=window.localStorage.getItem(Uo(e));if(!r)return[];const n=JSON.parse(r);return Array.isArray(n)?n.filter(a=>typeof a=="string"):[]}catch{return[]}}function Ya(e,r){if(!(typeof window>"u"))try{window.localStorage.setItem(Uo(e),JSON.stringify([...r]))}catch{}}function Fn(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=>Fn(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 Za(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=Ir(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 Vo({depth:e,expandedPaths:r,loadingPaths:n,node:a,onCopyPath:o,onDownload:s,onPreview:l,onSelect:i,onToggle:d,selectedNodeId:h}){const u=a.kind==="directory",m=u&&(a.path===""||r.has(a.path)),f=u&&n.has(a.path),p=h===a.id,g=`${e*.75+.5}rem`;return u?t.jsxs("div",{children:[t.jsxs("div",{className:"thread-graph-tree-row group flex items-center text-sm text-slate-600 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100",children:[t.jsxs("button",{type:"button",onClick:()=>d(a.path),className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 px-2 py-2 text-left sm:min-h-0 sm:py-1.5",style:{paddingLeft:g},children:[m?t.jsx(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"}),Za(a,m),t.jsx("span",{className:"truncate",children:a.name}),f?t.jsx("span",{className:"ml-auto shrink-0 text-xs text-slate-400 dark:text-slate-500",children:"Loading"}):null]}),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,o&&a.path?t.jsx("button",{type:"button",onClick:()=>o(a),className:"thread-graph-tree-action mr-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-slate-400 transition hover:bg-white hover:text-slate-900 sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100",title:`Copy path for ${a.name}`,"aria-label":`Copy path for ${a.name}`,children:t.jsx(B.Copy,{className:"h-3.5 w-3.5"})}):null]}),m?t.jsxs("div",{children:[a.children.map(b=>t.jsx(Vo,{depth:e+1,expandedPaths:r,loadingPaths:n,node:b,...o?{onCopyPath:o}:{},...s?{onDownload:s}:{},...l?{onPreview:l}:{},onSelect:i,onToggle:d,selectedNodeId:h},b.id)),a.truncated?t.jsx("div",{className:"px-2 py-1 text-xs text-slate-400 dark:text-slate-500",style:{paddingLeft:`${(e+1)*.75+.5}rem`},children:"More items not shown"}):null]}):null]}):t.jsxs("div",{className:`thread-graph-tree-row group flex items-center text-sm transition ${p?"is-selected":"text-slate-600 hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100"}`,children:[t.jsxs("button",{type:"button",onClick:()=>i(a.id),className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 px-2 py-2 text-left sm:min-h-0 sm:py-1.5",style:{paddingLeft:`${e*.75+2.2}rem`},children:[Za(a,!1),t.jsx("span",{className:"truncate",children:a.name})]}),a.kind==="file"&&(l||s||o)?t.jsxs("div",{className:"mr-1 flex shrink-0 items-center gap-0.5",children:[l?t.jsx("button",{type:"button",onClick:()=>l(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${p?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Preview ${a.name}`,"aria-label":`Preview ${a.name}`,children:t.jsx(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 ${p?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Download ${a.name}`,"aria-label":`Download ${a.name}`,children:t.jsx(B.Download,{className:"h-3.5 w-3.5"})}):null,o?t.jsx("button",{type:"button",onClick:()=>o(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${p?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Copy path for ${a.name}`,"aria-label":`Copy path for ${a.name}`,children:t.jsx(B.Copy,{className:"h-3.5 w-3.5"})}):null]}):null]})}function Hh({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 Oh({canEmptyGarbage:e,canUpload:r,onCollapse:n,expandedPaths:a,loadingPaths:o,loading:s,onDownload:l,onCopyPath:i,onEmptyGarbage:d,onPreview:h,onRefresh:u,onSelect:m,onToggle:f,onUpload:p,explorerScrollTopRef:g,explorerScrollerRef:b,selectedNodeId:v,tree:x,liveNodes:j}){const w=c.useMemo(()=>({...x,children:x.children.filter(y=>y.path!=="live")}),[x]);return c.useLayoutEffect(()=>{const y=b.current;y&&(y.scrollTop=g.current)},[b,g]),t.jsxs("aside",{className:`${qo} flex flex-col`,children:[t.jsxs("div",{className:Xo,children:[t.jsx("div",{className:"min-w-0",children:t.jsx("h2",{className:Yo,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:Zo,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:p,disabled:!r,className:Wr,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:u,className:Wr,title:"Refresh workspace","aria-label":"Refresh workspace",children:t.jsx(B.RefreshCw,{className:`h-4 w-4 ${s?"animate-spin":""}`})}),d?t.jsx("button",{type:"button",onClick:d,disabled:!e,className:Wr,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:b,className:"thread-graph-workspace-tree-scroll min-h-0 flex-1 overflow-y-auto py-2",onScroll:y=>{g.current=y.currentTarget.scrollTop},children:[t.jsx(Hh,{liveNodes:j??[],onSelect:m,selectedNodeId:v}),t.jsx("div",{className:Jo,children:"Workspace"}),t.jsx(Vo,{depth:0,expandedPaths:a,loadingPaths:o,node:w,...i?{onCopyPath:i}:{},...l?{onDownload:l}:{},...h?{onPreview:h}:{},onSelect:m,onToggle:f,selectedNodeId:v}),w.children.length===0?t.jsx("p",{className:Qo,children:"This workspace is empty. Agent tool runs execute inside the thread workspace, so files should appear here as the session works."}):null]})]})}function Wh({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:Ua(r,n),[e,i,n,r,o,l]),u=i??h??Ua(r,n),m=c.useMemo(()=>dh(u),[u]),f=c.useMemo(()=>{var z;return((z=u.children.find(O=>O.path==="live"))==null?void 0:z.children)??[]},[u]),p=$o(u),[g,b]=c.useState(()=>(p==null?void 0:p.id)??null),[v,x]=c.useState(()=>new Set(["","artifacts","thread-events","live",...Va((p==null?void 0:p.path)??"")])),[j,w]=c.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 639px)").matches?"viewer":null),[y,k]=c.useState(null),[S,N]=c.useState(!1),[L,R]=c.useState(()=>new Set),[P,J]=c.useState(!1),[D,Y]=c.useState(!1),[Z,I]=c.useState(!1),[re,oe]=c.useState([]),[$,Q]=c.useState(null),[_,ee]=c.useState(null),[W,T]=c.useState(null),[K,G]=c.useState(!1),E=c.useRef(null),C=c.useRef(null),U=c.useRef(0),H=c.useRef(null),se=!!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,H.current=null,x(new Set(["","artifacts","thread-events","live",...Fh(de),...Va((p==null?void 0:p.path)??"")]))},[de.threadId,de.workspaceId]);function te(){var O;const z=((O=C.current)==null?void 0:O.scrollTop)??U.current;U.current=z,H.current=z}function be(){const z=H.current??U.current;if(!C.current)return;let ne=0;const ge=()=>{const Te=C.current;Te&&(Te.scrollTop=Math.min(z,Math.max(0,Te.scrollHeight-Te.clientHeight)),U.current=Te.scrollTop,ne+=1,ne<8?window.requestAnimationFrame(ge):H.current=null)};window.requestAnimationFrame(ge)}c.useLayoutEffect(()=>{j!=="explorer"&&be()},[j,u]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const z=window.matchMedia("(max-width: 639px)"),O=()=>G(z.matches);return O(),typeof z.addEventListener=="function"?(z.addEventListener("change",O),()=>z.removeEventListener("change",O)):(z.addListener(O),()=>z.removeListener(O))},[]);async function ie(z){if(!l)return;const O=z??(q==null?void 0:q.path)??null;N(!0),k(null);try{const ne=tr(await l.listTree({...de,path:""}));let ge=i?Fn(ne,i):ne;if(i){const Ee=[...v].filter(fe=>fe).sort((fe,De)=>fe.split("/").length-De.split("/").length);for(const fe of Ee){const De=_n(i,fe);if((De==null?void 0:De.kind)!=="directory"||!De.childrenLoaded)continue;const Be=tr(await l.listTree({...de,path:fe}));ge=Dn(ge,fe,Fn(Be,De))}}d(ge);const Te=Ro(ge);b(Ee=>{var De;const fe=O??(Ee?(De=m.get(Ee))==null?void 0:De.path:null);return fe&&Bn(ge,fe)?`workspace:${fe}`:(Te==null?void 0:Te.id)??Ee})}catch(ne){k(ne instanceof Error?ne.message:"Failed to load workspace"),d(null)}finally{N(!1)}}async function ye(z){if(!(!l||!i)){R(O=>{if(O.has(z))return O;const ne=new Set(O);return ne.add(z),ne}),k(null);try{const O=tr(await l.listTree({...de,path:z}));d(ne=>ne&&Po(ne,z,O.children,{truncated:O.truncated}))}catch(O){k(O instanceof Error?O.message:"Failed to load directory")}finally{R(O=>{if(!O.has(z))return O;const ne=new Set(O);return ne.delete(z),ne})}}}async function Ae(z){const O=Mo(z);if(!O)return;const ne=nh(O);if(w(null),x(ge=>{const Te=new Set(ge);Te.add("");for(const Ee of ne)Te.add(Ee);return Ya(de,Te),Te}),!l){Bn(u,O)&&b(`workspace:${O}`);return}N(!0),k(null);try{let ge=i??tr(await l.listTree({...de,path:""}));for(const Te of ne){const Ee=_n(ge,Te);if((Ee==null?void 0:Ee.kind)==="directory"&&Ee.childrenLoaded)continue;const fe=tr(await l.listTree({...de,path:Te}));ge=Dn(ge,Te,fe)}d(ge),b(`workspace:${O}`)}catch(ge){k(ge instanceof Error?ge.message:`Failed to open ${O}`)}finally{N(!1)}}c.useEffect(()=>{if(!(!l||!i))for(const z of m.values())z.path&&z.kind==="directory"&&v.has(z.path)&&z.hasChildren&&!z.childrenLoaded&&!L.has(z.path)&&ye(z.path)},[i,v,m,l]),c.useEffect(()=>{d(null),R(new Set),Q(null),ee(null),T(null),k(null),ie()},[se,r.thread.id,r.workspace.id,r.thread.workspaceId]),c.useEffect(()=>{s&&Ae(s.path)},[s==null?void 0:s.requestId]),c.useEffect(()=>{l!=null&&l.subscribeWorkspaceChanged},[l,de.threadId,de.workspaceId]),c.useEffect(()=>{const z=l&&(q==null?void 0:q.kind)==="file"?q.path:null;if(!z){Q(null),ee(null),T(null);return}const O=z;let ne=!1;async function ge(){var Te;if(l){J(!0),k(null),Q(null),ee(null),T(null);try{const Ee=Ir(O),fe=(Te=l.getRawFileUrl)==null?void 0:Te.call(l,{...de,path:O});if(fe&&_o.has(Ee)){ne||ee(fe);return}if(fe&&Do.has(Ee)){ne||T(fe);return}const De=await l.readFile({...de,path:O,limit:Or});ne||Q(De)}catch(Ee){ne||k(Ee instanceof Error?Ee.message:"Failed to read file")}finally{ne||J(!1)}}}return ge(),()=>{ne=!0}},[l,q==null?void 0:q.id]);async function ce(){if(!(!l||!($!=null&&$.truncated))){Y(!0);try{const z=await l.readFile({...de,path:$.path,offset:$.nextOffset,limit:Or});Q(O=>O&&{...O,content:O.content+z.content,truncated:z.truncated,nextOffset:z.nextOffset,size:z.size})}finally{Y(!1)}}}async function Ce(z){if(!(l!=null&&l.writeFile))return;k(null),await l.writeFile({...de,path:z.path,content:z.content}),await ie(z.path);const O=await l.readFile({...de,path:z.path,limit:Or});Q(O)}async function Le(z){if(!(!(l!=null&&l.uploadFile)||!z)){N(!0),k(null);try{const O=await l.uploadFile({...de,path:z.name,file:z}),ne=O.kind==="archive"?O.paths[0]??null:O.file.path;await ie(ne)}catch(O){k(O instanceof Error?O.message:"Failed to upload file")}finally{N(!1)}}}async function X(z){var ne;const O=(ne=z.target.files)==null?void 0:ne[0];z.target.value="",O&&await Le(O)}function ue(){if(!(l!=null&&l.uploadFile))return;const z=()=>{var O;return(O=E.current)==null?void 0:O.click()};if(l.pickUploadFile){l.pickUploadFile({...de,defaultPick:z,upload:Le});return}z()}function ve(z){var O;(O=l==null?void 0:l.downloadNode)==null||O.call(l,{...de,path:z.path,kind:z.kind==="directory"?"directory":"file"})}function ke(z){if(!z.path||typeof navigator>"u"||!navigator.clipboard)return;const O=r.workspace.absPath.replace(/\/+$/,""),ne=z.path.startsWith("/")?z.path:O?`${O}/${z.path.replace(/^\/+/,"")}`:z.path;navigator.clipboard.writeText(ne).catch(ge=>{k(ge instanceof Error?ge.message:"Failed to copy file path")})}function _e(z){z.kind==="file"&&(te(),b(z.id),w("explorer"))}async function He(){if(l!=null&&l.emptyGarbage){if(k(null),!l.listGarbage){oe([]),I(!0);return}try{const z=await l.listGarbage(de);oe(z.map(O=>`garbage/${O}`))}catch(z){oe([]),k(z instanceof Error?z.message:"Failed to list garbage files")}finally{I(!0)}}}async function $e(){if(l!=null&&l.emptyGarbage){I(!1),k(null);try{await l.emptyGarbage(de),await ie((q==null?void 0:q.path)??null)}catch(z){k(z instanceof Error?z.message:"Failed to empty garbage")}}}const Ie={onCopyPath:ke,...l!=null&&l.downloadNode?{onDownload:ve}:{},...l!=null&&l.emptyGarbage?{onEmptyGarbage:He}:{},...l?{onRefresh:()=>void ie((q==null?void 0:q.path)??null)}:{},...l!=null&&l.uploadFile?{onUpload:ue}:{}};function F(z){if(!z)return;const O=m.get(`workspace:${z}`),ne=(O==null?void 0:O.kind)==="directory"&&O.hasChildren&&!O.childrenLoaded&&!L.has(z);x(ge=>{const Te=new Set(ge);return Te.has(z)?Te.delete(z):Te.add(z),Ya(de,Te),Te}),!v.has(z)&&ne&&ye(z)}const le=t.jsx(Oh,{canEmptyGarbage:!!(l!=null&&l.emptyGarbage),canUpload:!!(l!=null&&l.uploadFile),onCollapse:()=>{te(),w("explorer")},expandedPaths:v,loadingPaths:L,loading:S,explorerScrollTopRef:U,explorerScrollerRef:C,...Ie,onPreview:_e,onSelect:z=>{b(z)},onToggle:F,selectedNodeId:(q==null?void 0:q.id)??null,tree:u,liveNodes:f}),we=t.jsx(_h,{error:y,imageUrl:_,loadingMore:D,onLoadMore:ce,...l!=null&&l.writeFile?{onSaveFile:Ce}:{},onCollapse:()=>{te(),w("viewer")},pdfUrl:W,previewFile:$,previewLoading:P,plugins:a,selectedTarget:$h(q)});return j==="explorer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:we}):j==="viewer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:le}):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(Bh,{files:re,onCancel:()=>I(!1),onConfirm:()=>void $e()}):null,K?t.jsxs(An,{direction:"vertical",className:"thread-graph-workspace-mobile-stack",children:[t.jsx(sr,{defaultSize:42,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-explorer h-full min-h-0 overflow-hidden",children:le})}),t.jsx($n,{className:"thread-graph-workspace-resize-handle h-2 bg-transparent after:h-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(sr,{defaultSize:58,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-viewer h-full min-h-0 overflow-hidden",children:we})})]}):t.jsxs(An,{direction:"horizontal",className:"thread-graph-workspace-resizable",children:[t.jsx(sr,{defaultSize:33,minSize:20,children:t.jsx("div",{className:"thread-graph-workspace-explorer-pane h-full min-h-0 overflow-hidden",children:le})}),t.jsx($n,{className:"thread-graph-workspace-resize-handle w-2 bg-transparent after:w-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(sr,{defaultSize:67,minSize:30,children:t.jsx("div",{className:"thread-graph-workspace-viewer-pane h-full min-h-0 overflow-hidden",children:we})})]}),t.jsx("input",{ref:E,type:"file","aria-label":"Workspace upload file input","data-testid":"workspace-upload-file-input",className:"hidden",onChange:z=>void X(z)})]})}var Or,Ko,qo,Xo,Yo,Wr,Zo,Jo,Qo,Uh=Oe({"src/components/graph-workspace/GraphWorkspaceExplorer.tsx"(){la(),Dh(),Gh(),zo(),Or=24e3,Ko="remote-codex:graphchat:workspace:expanded:",qo="thread-graph-explorer h-full min-h-0 overflow-hidden rounded-[12px]",Xo="thread-graph-explorer-header flex h-[60px] shrink-0 items-center justify-between border-b px-4",Yo="text-[18px] font-semibold text-slate-900 dark:text-slate-100",Wr="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",Zo="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",Jo="thread-graph-workspace-label px-3 pb-1 pt-2 text-[11px] font-semibold tracking-normal text-slate-500 dark:text-slate-400",Qo="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 jn({children:e}){return t.jsx("span",{className:"thread-guide-tag inline-flex items-center rounded px-1.5 py-0.5 font-mono text-[10px]",children:e})}function Qt({items:e}){return t.jsx("ul",{className:"space-y-1 text-[12px] text-[var(--theme-fg-muted)]",children:e.map((r,n)=>t.jsxs("li",{className:"flex gap-2",children:[t.jsx("span",{className:"mt-[6px] h-1 w-1 shrink-0 rounded-full bg-[var(--theme-border-contrast)]"}),t.jsx("span",{children:r})]},n))})}function Vh({children:e}){return t.jsx("span",{className:"thread-guide-icon flex h-5 w-5 shrink-0 items-center justify-center rounded-md",children:e})}function mr({value:e,title:r,icon:n,children:a}){return t.jsxs(Tr,{value:e,className:"thread-guide-section border-b border-[var(--theme-border)] last:border-b-0",children:[t.jsx(an,{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(Vh,{children:n}),r]})}),t.jsx(Er,{className:"space-y-3 pb-3",children:a})]})}function Kh(){return t.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[t.jsxs("div",{className:"shrink-0 border-b border-[var(--theme-border)] px-4 py-3",children:[t.jsx("h2",{className:"text-xs font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"What can I do?"}),t.jsx("p",{className:"mt-0.5 text-[11px] text-[var(--theme-fg-muted)]",children:"Upload files, ask in plain language, get results."})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-3 pb-6",children:t.jsxs(Sr,{type:"multiple",defaultValue:["start","workspace","remote-codex"],className:"space-y-0",children:[t.jsxs(mr,{value:"start",title:"Getting Started",icon:t.jsx(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(Qt,{items:["Upload data files via the Workspace panel","Type a question or task in plain language","The agent calls tools, writes results to the workspace, and explains what it found","Agent-produced files appear in the workspace automatically when the host reports changes"]})]}),t.jsxs(mr,{value:"workspace",title:"Workspace Explorer",icon:t.jsx(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(Qt,{items:[t.jsxs(t.Fragment,{children:[t.jsx(jn,{children:".xyz .extxyz .cif"})," use the 3D molecule plugin."]}),t.jsxs(t.Fragment,{children:[t.jsx(jn,{children:".png .jpg .gif .svg .webp"})," use inline image preview."]}),t.jsxs(t.Fragment,{children:[t.jsx(jn,{children:".py .json .ts .md .csv"})," use text/code preview."]}),"Large files load in chunks when the workspace adapter supports it."]})]})]}),t.jsxs(mr,{value:"viewer",title:"Viewer",icon:t.jsx(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(Qt,{items:["Expand one artifact at a time for inspection","Fallback JSON preview is available for unknown artifact types","3D molecule artifacts remain interactive when the XYZ plugin is enabled"]})]}),t.jsxs(mr,{value:"usage",title:"Tool Usage & Chat",icon:t.jsx(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(Qt,{items:["Bar chart of tool and command counts for this thread","Expandable call log: inspect every input and output","Recent live events appear with persisted history"]})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(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(Qt,{items:["New Chat creates a fresh Remote Codex thread with its own workspace","Interrupt, compact, goal controls, and model controls remain in the composer","Shell view stays available when a shell adapter is attached"]})]})]})]}),t.jsx(mr,{value:"remote-codex",title:"Remote Codex Extras",icon:t.jsx(B.Code2,{className:"h-3 w-3"}),children:t.jsx(Qt,{items:["Slash toolbox: skills, MCP, hooks, goals, forks, model controls, provider settings","Rich message bubbles: reasoning, commands, searches, file reads, file changes, plans, action requests, artifacts","Plugin surfaces: terminal, XYZ molecule viewer, inline code renderers, and imported plugin panels","Thread metadata stays in the left rail and Workspace tab instead of replacing chat"]})})]})})]})}var qh=Oe({"src/components/graph-workspace/GraphGuidePanel.tsx"(){Lr()}});function Xh(e){if(e==null)return"—";if(typeof e=="string")return e.length>2e3?`${e.slice(0,2e3)}
|
|
13
|
-
...(truncated)`:e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Ja({label:e,value:r}){return t.jsxs("div",{children:[t.jsx("p",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:e}),t.jsx("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap break-words rounded bg-[var(--theme-surface-strong)] p-2 text-[11px] leading-relaxed text-[var(--theme-fg-soft)]",children:Xh(r)})]})}function Yh({event:e}){return t.jsxs(Tr,{value:e.id,className:"thread-tool-call mb-2 overflow-hidden rounded-lg border border-[var(--theme-border)] last:mb-0",children:[t.jsxs(an,{className:"px-3 py-2 text-xs font-medium text-[var(--theme-fg)] hover:bg-[var(--theme-hover)] hover:no-underline [&[data-state=open]]:bg-[var(--theme-hover)]",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full bg-[var(--theme-accent-strong)]"}),t.jsx("span",{className:"truncate font-mono text-xs font-medium text-[var(--theme-fg)]",children:e.label}),e.status?t.jsx("span",{className:"shrink-0 rounded-full border border-[var(--theme-border)] px-1.5 py-0.5 text-[9px] uppercase tracking-[0.12em] text-[var(--theme-fg-muted)]",children:e.status}):null]}),t.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:e.turnId?t.jsx("span",{className:"max-w-20 truncate text-[10px] text-[var(--theme-fg-muted)]",children:e.turnId}):null})]}),t.jsx(Er,{className:"px-3 pb-3",children:t.jsxs("div",{className:"space-y-2 px-3 pb-3 pt-1",children:[t.jsx(Ja,{label:"Input",value:e.preview}),t.jsx(Ja,{label:"Output",value:e.detail})]})})]})}function Zh({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(Sr,{type:"single",collapsible:!0,value:o??"",onValueChange:i=>s(i||null),className:"space-y-0",children:n.slice(-50).map(i=>t.jsx(Yh,{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 Jh=Oe({"src/components/graph-workspace/GraphToolUsagePanel.tsx"(){Lr()}});function Qa(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),v=1/(Math.abs(g)+Math.abs(b)),x=v*g,j=v*b,w=d*(x+j)+u,y=h*(-x+j)+m;return{x:w,y}}function es(e,r){const n={...e.internals.positionAbsolute,...e},a=Math.round(n.x),o=Math.round(n.y),s=Math.round(r.x),l=Math.round(r.y);return s<=a+1?Gt.Left:s>=a+(e.measured.width??1)-1?Gt.Right:l<=o+1?Gt.Top:l>=n.y+(e.measured.height??1)-1?Gt.Bottom:Gt.Top}function el(e,r){const n=Qa(e,r),a=Qa(r,e),o=es(e,n),s=es(r,a);return{sx:n.x,sy:n.y,tx:a.x,ty:a.y,sourcePos:o,targetPos:s}}function Qh(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,j)=>{const w=(x<<5)-x+j.charCodeAt(0);return w&w},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],j=d[v];if(!x||!j)continue;const w=f.get(x.id),y=f.get(j.id);if(!w||!y)continue;const k=w.x-y.x,S=w.y-y.y,N=Math.sqrt(k*k+S*S)||1,R=(200-N)*.5,P=k/N*R,J=S/N*R;w.vx+=P,w.vy+=J,y.vx-=P,y.vy-=J}h.forEach(b=>{const v=f.get(b.source),x=f.get(b.target);if(!v||!x)return;const j=x.x-v.x,w=x.y-v.y,y=Math.sqrt(j*j+w*w)||1,S=(y-120)*.3,N=j/y*S,L=w/y*S;v.vx+=N,v.vy+=L,x.vx-=N,x.vy-=L}),f.forEach(b=>{b.x+=b.vx*.1,b.y+=b.vy*.1,b.vx*=.9,b.vy*=.9,b.x=Math.max(80,Math.min(u-80,b.x)),b.y=Math.max(80,Math.min(m-80,b.y))})}return f},o=new Set(e.map(d=>d.id)),s=[];e.forEach(d=>{if(!d.out_node_id)return;(Array.isArray(d.out_node_id)?d.out_node_id:[d.out_node_id]).forEach(u=>{o.has(u)&&s.push({id:`${d.id}-${u}`,source:d.id,target:u,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:Os.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 ia=Oe({"src/components/graph-chat/FloatingHelper.tsx"(){}});function eu({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}=el(o,s),[f]=Ws({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 tu=Oe({"src/components/graph-chat/FloatingConnectionLine.tsx"(){ia()}});function ru({id:e,source:r,target:n,markerEnd:a,style:o}){const s=Ta(r),l=Ta(n);if(!s||!l)return null;const{sx:i,sy:d,tx:h,ty:u,sourcePos:m,targetPos:f}=el(s,l),[p]=Ws({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 nu=Oe({"src/components/graph-chat/FloatingEdge.tsx"(){ia()}});function au({nodes:e}){const[r,n,a]=vd([]),[o,s,l]=kd([]),i=c.useMemo(()=>Qh(e),[e]),d=c.useMemo(()=>({floating:ru}),[]),h=c.useMemo(()=>({styledNode:({data:m,isConnectable:f})=>t.jsxs("div",{className:"thread-graph-flow-node",children:[m.label,t.jsx(Sa,{type:"target",position:Gt.Top,isConnectable:f,style:{opacity:0,pointerEvents:"none"}}),t.jsx(Sa,{type:"source",position:Gt.Bottom,isConnectable:f,style:{opacity:0,pointerEvents:"none"}})]})}),[]);c.useEffect(()=>{n(i.nodes),s(i.edges)},[i.edges,i.nodes,s,n]);const u=c.useCallback(m=>s(f=>wd({...m,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:Os.Arrow}},f)),[s]);return t.jsx("div",{className:"thread-graph-flow h-full min-h-0",children:t.jsx(yd,{children:t.jsxs(jd,{nodes:r,edges:o,onNodesChange:a,onEdgesChange:l,onConnect:u,fitView:!0,nodeTypes:h,edgeTypes:d,connectionLineComponent:eu,children:[t.jsx(Nd,{}),t.jsx(Cd,{gap:16})]})})})}var su=Oe({"src/components/graph-chat/GraphVisualization.tsx"(){tu(),nu(),ia()}});function ou(e){return{...rl,...e}}function ts(e,r){const n=a=>{switch(a){case"workspace":return e.workspace;case"tools":return e.toolUsage;case"guide":return e.guide;case"graph":return e.threadGraph;case"extensions":return e.extensions}};return r&&n(r)?r:["workspace","tools","guide","graph","extensions"].find(n)??null}function lu(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 iu(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:Xr(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:Xr(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 Xr(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 du(e){switch(e.kind){case"userMessage":return"User";case"agentMessage":return"Agent";default:return Xr(e.kind)}}function cu(e){return(e.previewText??e.text??e.detailText??e.kind).replace(/\s+/g," ").slice(0,96)}function hu(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:du(d),description:cu(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 tl({detail:e,status:r,plugins:n,workspaceAdapter:a,metaContent:o,settingsContent:s,activeView:l="chat",features:i,focusPathRequest:d=null}){const h=c.useMemo(()=>ou(i),[i]),u=ts(h,i==null?void 0:i.defaultTab),[m,f]=c.useState(u),p=c.useMemo(()=>eh(e),[e]),g=c.useMemo(()=>iu(e),[e]),b=c.useMemo(()=>{const k=new Map;for(const S of g)k.set(S.kind,(k.get(S.kind)??0)+1);return[...k.entries()].sort((S,N)=>N[1]-S[1])},[g]),v=n.getThreadPanels(),x=Math.max(...b.map(([,k])=>k),1),j=c.useMemo(()=>hu(e,g),[e,g]),w=c.useMemo(()=>{const k=[];return h.workspace&&k.push({id:"workspace",label:"Workspace",icon:null}),h.toolUsage&&k.push({id:"tools",label:"Tool Usage",icon:B.BarChart2}),h.guide&&k.push({id:"guide",label:"Guide",icon:B.BookOpen}),k},[h.guide,h.toolUsage,h.workspace]),y=c.useMemo(()=>{const k=[];return h.threadGraph&&k.push({id:"graph",label:"Thread graph",icon:B.GitBranch}),h.extensions&&k.push({id:"extensions",label:"Remote Codex extensions",icon:B.Wrench}),k},[h.extensions,h.threadGraph]);return c.useEffect(()=>{(!m||!lu(h,m))&&f(ts(h,i==null?void 0:i.defaultTab))},[m,i==null?void 0:i.defaultTab,h]),c.useEffect(()=>{d&&h.workspace&&f("workspace")},[h.workspace,d==null?void 0:d.requestId]),m?t.jsxs("div",{className:"thread-graph-right-panel flex h-full min-h-0 flex-col overflow-hidden",children:[t.jsxs("div",{className:"thread-graph-right-tabs flex shrink-0 items-center gap-1 overflow-hidden border-b px-3 py-2",children:[w.map(k=>{const S=k.icon;return t.jsxs("button",{type:"button",onClick:()=>f(k.id),className:`thread-graph-right-tab inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md px-3 text-xs font-medium transition ${m===k.id?"is-active":""}`,children:[S?t.jsx(S,{className:"h-3.5 w-3.5"}):null,k.label]},k.id)}),y.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:y.map(k=>{const S=k.icon;return t.jsx("button",{type:"button",onClick:()=>f(k.id),className:`thread-graph-right-tab inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-xs font-medium transition ${m===k.id?"is-active":""}`,title:k.label,"aria-label":k.label,children:t.jsx(S,{className:"h-3.5 w-3.5"})},k.id)})}):null]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[m==="workspace"?t.jsx(Wh,{activeView:l,detail:e,artifacts:p,plugins:n,status:r,focusPathRequest:d,workspaceAdapter:a??null}):null,m==="tools"?t.jsx(Zh,{formatToolKind:Xr,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(au,{nodes:j})}):null,m==="extensions"?t.jsx("div",{className:"h-full min-h-0 overflow-y-auto p-3",children:t.jsxs("div",{className:"grid gap-3",children:[t.jsx(rr,{label:"Plugin Panels",children:v.length?t.jsx("div",{className:"flex flex-wrap gap-2",children:v.map(k=>t.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-1 text-xs text-[var(--theme-fg-soft)]",children:k.label},k.id))}):t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"No thread panels are enabled."})}),t.jsx(rr,{label:"Enabled Renderers",children:t.jsx("div",{className:"flex flex-wrap gap-2",children:n.plugins.filter(k=>k.enabled).map(k=>t.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-1 text-xs text-[var(--theme-fg-soft)]",children:k.name},k.id))})}),t.jsx(rr,{label:"Remote Codex Tools",children:t.jsxs("div",{className:"grid gap-2 text-[var(--theme-fg-muted)]",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(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(rr,{label:"Thread Meta",children:o}):null,s?t.jsx(rr,{label:"Settings",children:s}):null]})}):null,m==="guide"?t.jsx(Kh,{}):null]})]}):null}var rl,nl,uu=Oe({"src/components/ThreadGraphWorkspacePanel.tsx"(){Uh(),Bo(),qh(),Jh(),la(),su(),rl={workspace:!0,toolUsage:!0,guide:!0,threadGraph:!0,extensions:!0},nl=c.memo(tl)}}),al={};Qc(al,{MemoizedThreadGraphWorkspacePanel:()=>nl,ThreadGraphWorkspacePanel:()=>tl});var mu=Oe({"src/workspace-panel.ts"(){uu()}});function ir(e,{insertAt:r}={}){if(!e||typeof document>"u")return;const n=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css",r==="top"&&n.firstChild?n.insertBefore(a,n.firstChild):n.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}ir(`.thread-ui-shell,
|
|
9
|
+
`),a+=i}return n.length>0?n:[e]}function Va(e,r){return r!=="xyz"?e:e.flatMap(n=>Eh(n))}function Ka(e){return e.map(r=>`${r.replace(/\s+$/g,"")}
|
|
10
|
+
`).join("")}function Lh(e){if(!e)return{format:"xyz",frames:[],exportContent:""};if(typeof e=="string"){const o=Va([e],"xyz");return{frames:o,format:"xyz",exportContent:Ka(o)}}const r=Th(e.format),n=e.content.filter(o=>o.trim().length>0);return{frames:Va(n,r),format:r,exportContent:Ka(n)}}var Ih=Oe({"src/components/graph-workspace/GraphMoleculeViewerData.ts"(){}});function zh({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,k]=c.useState(null),[x,j]=c.useState(!1),[w,y]=c.useState({}),[v,S]=c.useState([]),[N,I]=c.useState({}),[M,R]=c.useState(!1),[Q,$]=c.useState(!1),[Y,Z]=c.useState(null),P=c.useMemo(()=>Lh(o),[o]),te=P.frames,oe=P.format,T=te[p]??null,re=te.length>0&&p===te.length-1,B=r??"current",J=Object.values(N).reduce((E,C)=>E+C.length,0),K=Object.keys(N).length;c.useEffect(()=>{if(te.length===0){g(0);return}g(te.length-1)},[te.length]),c.useEffect(()=>{if(!x||te.length<=1)return;const E=window.setInterval(()=>{g(C=>C>=te.length-1?(window.clearInterval(E),j(!1),C):C+1)},200);return()=>window.clearInterval(E)},[x,te.length]),c.useEffect(()=>{const E=l.current;if(!E||i.current)return;let C=!1;try{const H=document.createElement("canvas");if(!(H.getContext("webgl2")||H.getContext("webgl")||H.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 W=()=>{var H,se;(H=i.current)==null||H.resize(),(se=i.current)==null||se.render()};return jh().then(H=>{if(!(C||i.current))try{const se=H.createViewer(E,{});i.current=se,se.setBackgroundColor("#f8fafc",.8),window.addEventListener("resize",W),window.setTimeout(W,100)}catch(se){console.error("Failed to initialize 3Dmol viewer:",se),Z("Failed to initialize 3D viewer. Please refresh or try another browser.")}}).catch(H=>{console.error("Failed to load 3Dmol viewer runtime:",H),Z("Failed to load 3D viewer runtime. Please refresh or try another browser.")}),()=>{C=!0,window.removeEventListener("resize",W),i.current=null,d.current=null}},[]),c.useEffect(()=>{const E=i.current;if(!(!E||!T))try{E.removeAllModels(),E.removeAllShapes(),E.removeAllLabels();const C=E.addModel(T,oe||"xyz");d.current=C,C.setStyle({},{stick:{radius:.2},sphere:{scale:.3}});const W=C.getCrystData(),H=!!(W&&typeof W=="object"&&Object.keys(W).length);R(H),$(H?u.current:!1),S([]),y({});const se=T.split(`
|
|
11
|
+
`).slice(2).map(V=>V.trim()).filter(Boolean).map(V=>V.split(/\s+/)[0]??"Atom");h.current||(E.zoomTo(),h.current=!0),C.setClickable({},!0,(V,de,ee)=>{const be=V.serial??V.index;if(be===void 0)return;const ie=V.atom||V.elem||se[be]||"Atom";S(ye=>{const ce=!!(ee!=null&&ee.shiftKey||ee!=null&&ee.metaKey||ee!=null&&ee.ctrlKey)?ye.includes(be)?ye.filter(Ce=>Ce!==be):[...ye,be]:ye.length===1&&ye[0]===be?[]:[be];return y(Ce=>{if(ce.length===0)return{};const Le={};return ce.forEach(X=>{Le[X]=Ce[X]||se[X]||ie}),Le}),ce})}),C.setHoverable({},!0,(V,de,ee)=>{!ee||!V||k({x:ee.clientX,y:ee.clientY,label:`${V.atom||V.elem||"Atom"} (${V.serial??V.index??"?"})`,coords:{x:V.x.toFixed(2),y:V.y.toFixed(2),z:V.z.toFixed(2)}})},()=>k(null)),E.render()}catch(C){console.error("Failed to render molecule:",C),Z("Unable to render this molecular structure.")}},[T,oe]),c.useEffect(()=>{const E=i.current,C=d.current;if(!(!E||!C)){try{E.removeUnitCell(C)}catch{}if(Q&&M)try{E.addUnitCell(C,{box:{color:"black",opacity:1,linewidth:5},astyle:{radius:.12,mid:.85,color:"red",opacity:.6},bstyle:{radius:.12,mid:.85,color:"green",opacity:.6},cstyle:{radius:.12,mid:.85,color:"blue",opacity:.6},alabel:"a",blabel:"b",clabel:"c"})}catch{R(!1),$(!1)}E.render()}},[M,Q,T,oe]),c.useEffect(()=>{const E=i.current,C=d.current;!E||!C||!T||(C.setStyle({},{stick:{radius:.2},sphere:{scale:.3}}),v.length>0&&C.setStyle({serial:v},{stick:{radius:.3,color:"yellow"},sphere:{scale:.4,color:"yellow"}}),E.render(),a==null||a({moleculeId:r,atoms:v}))},[r,a,v,T]),c.useEffect(()=>{if(!T)return;let E=0;const C=()=>{var H,se;const W=(se=(H=i.current)==null?void 0:H.getView)==null?void 0:se.call(H);if(Array.isArray(W)&&W.length>=8){const[V,de,ee,be,ie,ye,Ae,ce]=W;if(typeof V=="number"&&typeof de=="number"&&typeof ee=="number"&&typeof be=="number"&&typeof ie=="number"&&typeof ye=="number"&&typeof Ae=="number"&&typeof ce=="number"){const Ce=Math.sqrt(ie*ie+ye*ye+Ae*Ae),Le=Ce>0?{x:ie/Ce,y:ye/Ce,z:Ae/Ce}:{x:0,y:0,z:0};f({position:{x:V,y:de,z:ee,qx:ie,qy:ye,qz:Ae,qw:ce},lookAt:Le,zoom:be})}}E=window.requestAnimationFrame(C)};return E=window.requestAnimationFrame(C),()=>window.cancelAnimationFrame(E)},[T]);const L=c.useCallback(async()=>{const E=i.current;if(!(E!=null&&E.pngURI))return;E.render();const C=E.pngURI();if(C){try{const H=await(await fetch(C)).blob(),se=new ClipboardItem({[H.type||"image/png"]:H});await navigator.clipboard.write([se])}catch{}n==null||n({moleculeId:r,image:C})}},[r,n]);function q(){M&&$(E=>{const C=!E;return u.current=C,C})}function G(){v.length!==0&&I(E=>{const C=E[B]??[];return{...E,[B]:Array.from(new Set([...C,...v]))}})}return t.jsxs("div",{className:`thread-graph-molecule-viewer flex h-full min-h-0 flex-col bg-white ${e}`,children:[t.jsxs("div",{className:"thread-graph-molecule-header flex shrink-0 items-center justify-between gap-3 border-b border-slate-200 px-3 py-2 sm:px-4 sm:py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"truncate text-sm font-semibold text-slate-900",children: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:[Y?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:Y}):null,!Y&&!T?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(wh,{currentIndex:p,exportContent:P.exportContent,moleculeId:r,onScreenshot:()=>void L(),viewerRef:i,xyzContent:T,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(Nr,{type:"button",variant:"ghost",size:"icon",className:"thread-graph-molecule-button h-5 w-5",onClick:()=>{j(E=>{const C=!E;return C&&p===te.length-1&&g(0),C})},"aria-label":x?"Pause trajectory":"Play trajectory",title:x?"Pause trajectory":"Play trajectory",children:x&&p!==te.length-1?t.jsx(D.Pause,{className:"h-3 w-3"}):t.jsx(D.Play,{className:"h-3 w-3"})})]}),t.jsxs(Nr,{type:"button",variant:"ghost",onClick:()=>g(te.length-1),className:"thread-graph-molecule-live-button",children:[t.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${re?"animate-pulse bg-red-600":"bg-gray-300"}`}),"Live"]})]}),t.jsx(Ch,{value:[p],max:te.length-1,step:1,onValueChange:E=>g(E[0]??0),"aria-label":"Trajectory frame"})]}):null,t.jsx(vh,{cameraInfo:m,onClearSelection:()=>S([]),onClearStaged:()=>I({}),onSendSelection:()=>a==null?void 0:a({moleculeId:r,atoms:v}),onSendStaged:()=>{Object.entries(N).forEach(([E,C])=>{a==null||a({moleculeId:E==="current"?r:E,atoms:C})})},onStageSelection:G,onToggleUnitCell:q,selectedAtomLabels:w,selectedSerials:v,stagedAtoms:J,stagedMolecules:K,unitCellAvailable:M,unitCellVisible:Q})]})]})]})}var Ph=Oe({"src/components/graph-workspace/GraphMoleculeViewer.tsx"(){kh(),yh(),Nh(),rn(),Sh(),Ih()}});function Rh(e){return!e.truncated&&e.size<=Fo&&e.content.split(`
|
|
12
|
+
`).length<=Ho}function Mh(e){return e&&(e.node.path||e.node.name)||null}function Ah(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 _h({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,k]=c.useState(null),[x,j]=c.useState(!1),w=(u==null?void 0:u.node)??null,y=w!=null&&w.artifact?h.renderArtifact({artifact:w.artifact,expanded:!0,onToggleExpanded:()=>{}}):null,v=nh(i??null),S=(i==null?void 0:i.language)||ah((i==null?void 0:i.path)??""),N=i?Ir(i.path):"",I=Mh(u),M=i!==null&&sa.has(N),R=!!(i&&a)&&!M&&Rh(i),Q=(u==null?void 0:u.kind)==="live-molecule",$=!!(w!=null&&w.artifact&&y),Y=!!v||$;c.useEffect(()=>{f(!1),g((i==null?void 0:i.content)??""),k(null)},[i==null?void 0:i.path,i==null?void 0:i.content]);async function Z(){if(!(!i||!a)){j(!0),k(null);try{await a({path:i.path,content:p}),f(!1)}catch(P){k(P instanceof Error?P.message:"Failed to save file.")}finally{j(!1)}}}return t.jsxs("section",{className:"thread-graph-viewer flex h-full min-h-0 flex-col overflow-hidden rounded-[12px]","data-preview-target-kind":(u==null?void 0:u.kind)??"none",children:[t.jsxs("div",{className:"thread-graph-viewer-header flex h-12 shrink-0 items-center justify-between gap-3 border-b px-3 sm:h-[60px] sm:px-5",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[t.jsx("h2",{className:"text-base font-semibold text-slate-900 sm:text-[18px] dark:text-slate-100",children:"Viewer"}),I?t.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-slate-500 dark:text-slate-400",children:I}):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(D.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(zh,{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:[M?"molecule":S||N||"text"," |"," ",i.size.toLocaleString()," bytes",i.truncated?t.jsxs("span",{className:"ml-2 text-amber-500",children:["showing ",i.nextOffset.toLocaleString()," bytes"]}):null]}),R?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),k(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(D.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(D.Save,{className:"h-4 w-4"})})]}):t.jsx("button",{type:"button",onClick:()=>{g(i.content),f(!0),k(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(D.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:P=>g(P.currentTarget.value),spellCheck:!1,"aria-label":"Workspace file editor",className:"thread-graph-file-editor min-h-0 flex-1 resize-none border-0 bg-transparent p-4 font-mono text-[12px] leading-5 text-slate-900 outline-none dark:text-slate-100"}):t.jsx(Fr,{content:i.content}),i.truncated&&o?t.jsx("div",{className:"thread-graph-file-preview-footer flex justify-center border-t px-4 py-3",children:t.jsx("button",{type:"button",onClick:o,disabled:n,title:"Load more workspace preview","aria-label":"Load more workspace preview",className:"thread-graph-load-more-button rounded-md px-4 py-1.5 text-xs disabled:opacity-50",children:n?"Loading...":`Load more (${(i.size-i.nextOffset).toLocaleString()} bytes remaining)`})}):null]}):(u.kind==="live-molecule"||u.kind==="artifact")&&u.node.artifact?t.jsx("div",{className:Y||Q?"min-h-0 flex-1 overflow-hidden":"min-h-0 flex-1 overflow-auto p-3",children:y}):u.kind==="meta"?t.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-3",children:t.jsx("div",{className:"grid gap-3",children:t.jsx(rr,{label:"Workspace Data",children:t.jsx(Fr,{content:u.node.detail??""})})})}):t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsx("div",{className:"thread-graph-file-preview-header border-b px-4 py-3 text-xs uppercase tracking-[0.12em]",children:u.node.kind}),t.jsx(Fr,{content:u.node.detail??u.node.preview??u.node.name})]}):t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center px-5 text-center text-sm text-slate-400 dark:text-slate-500",children:"Pick a live molecule, workspace file, artifact, or thread event to preview it."})]})]})}var Fo,Ho,Fr,$h=Oe({"src/components/graph-workspace/GraphWorkspacePreviewPane.tsx"(){oa(),$o(),Ph(),Fo=50*1024,Ho=1e3,Fr=c.memo(function({content:r}){return t.jsx("div",{className:"thread-graph-code-preview min-h-0 flex-1 overflow-auto",children:t.jsx("pre",{className:"thread-graph-plain-code-preview",children:t.jsx("code",{children:r})})})})}});function Dh({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 Bh=Oe({"src/components/graph-workspace/GraphEmptyGarbageDialog.tsx"(){}});function Oo(e){return`${Uo}${e.workspaceId??"workspace"}:${e.threadId}`}function Gh(e){if(typeof window>"u")return[];try{const r=window.localStorage.getItem(Oo(e));if(!r)return[];const n=JSON.parse(r);return Array.isArray(n)?n.filter(a=>typeof a=="string"):[]}catch{return[]}}function qa(e,r){if(!(typeof window>"u"))try{window.localStorage.setItem(Oo(e),JSON.stringify([...r]))}catch{}}function Gn(e,r){if(!r||e.path!==r.path||e.kind!=="directory")return e;const n=new Map(r.children.map(s=>[s.path,s])),a=e.children.map(s=>Gn(s,n.get(s.path)??null)),o=e.childrenLoaded&&e.children.length>0;return{...e,children:o||!r.childrenLoaded?a:r.children,childrenLoaded:e.childrenLoaded||r.childrenLoaded,truncated:e.truncated??r.truncated}}function Xa(e,r){if(e.kind==="directory")return r?t.jsx(D.FolderOpen,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"}):t.jsx(D.Folder,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"});const n=Ir(e.name);return n==="zip"?t.jsx(D.FileArchive,{className:"h-4 w-4 text-amber-600"}):e.kind==="file"&&["png","jpg","jpeg","gif","webp","svg"].includes(n)?t.jsx(D.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(D.FileCode2,{className:"h-4 w-4 text-emerald-600"}):t.jsx(D.File,{className:"h-4 w-4 text-slate-400 dark:text-slate-500"})}function Wo({depth:e,expandedPaths:r,loadingPaths:n,node:a,onCopyPath:o,onDownload:s,onPreview:l,onSelect:i,onToggle:d,selectedNodeId:h}){const u=a.kind==="directory",m=u&&(a.path===""||r.has(a.path)),f=u&&n.has(a.path),p=h===a.id,g=`${e*.75+.5}rem`;return u?t.jsxs("div",{children:[t.jsxs("div",{className:"thread-graph-tree-row group flex items-center text-sm text-slate-600 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100",children:[t.jsxs("button",{type:"button",onClick:()=>d(a.path),className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 px-2 py-2 text-left sm:min-h-0 sm:py-1.5",style:{paddingLeft:g},children:[m?t.jsx(D.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}):t.jsx(D.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}),Xa(a,m),t.jsx("span",{className:"truncate",children:a.name}),f?t.jsx("span",{className:"ml-auto shrink-0 text-xs text-slate-400 dark:text-slate-500",children:"Loading"}):null]}),s?t.jsx("button",{type:"button",onClick:()=>s(a),className:"thread-graph-tree-action mr-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-slate-400 transition hover:bg-white hover:text-slate-900 sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100",title:a.path?`Download ${a.name}`:"Download workspace","aria-label":a.path?`Download ${a.name}`:"Download workspace",children:t.jsx(D.Download,{className:"h-3.5 w-3.5"})}):null,o&&a.path?t.jsx("button",{type:"button",onClick:()=>o(a),className:"thread-graph-tree-action mr-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-slate-400 transition hover:bg-white hover:text-slate-900 sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100",title:`Copy path for ${a.name}`,"aria-label":`Copy path for ${a.name}`,children:t.jsx(D.Copy,{className:"h-3.5 w-3.5"})}):null]}),m?t.jsxs("div",{children:[a.children.map(b=>t.jsx(Wo,{depth:e+1,expandedPaths:r,loadingPaths:n,node:b,...o?{onCopyPath:o}:{},...s?{onDownload:s}:{},...l?{onPreview:l}:{},onSelect:i,onToggle:d,selectedNodeId:h},b.id)),a.truncated?t.jsx("div",{className:"px-2 py-1 text-xs text-slate-400 dark:text-slate-500",style:{paddingLeft:`${(e+1)*.75+.5}rem`},children:"More items not shown"}):null]}):null]}):t.jsxs("div",{className:`thread-graph-tree-row group flex items-center text-sm transition ${p?"is-selected":"text-slate-600 hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100"}`,children:[t.jsxs("button",{type:"button",onClick:()=>i(a.id),className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 px-2 py-2 text-left sm:min-h-0 sm:py-1.5",style:{paddingLeft:`${e*.75+2.2}rem`},children:[Xa(a,!1),t.jsx("span",{className:"truncate",children:a.name})]}),a.kind==="file"&&(l||s||o)?t.jsxs("div",{className:"mr-1 flex shrink-0 items-center gap-0.5",children:[l?t.jsx("button",{type:"button",onClick:()=>l(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${p?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Preview ${a.name}`,"aria-label":`Preview ${a.name}`,children:t.jsx(D.Eye,{className:"h-3.5 w-3.5"})}):null,s?t.jsx("button",{type:"button",onClick:()=>s(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${p?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Download ${a.name}`,"aria-label":`Download ${a.name}`,children:t.jsx(D.Download,{className:"h-3.5 w-3.5"})}):null,o?t.jsx("button",{type:"button",onClick:()=>o(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${p?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Copy path for ${a.name}`,"aria-label":`Copy path for ${a.name}`,children:t.jsx(D.Copy,{className:"h-3.5 w-3.5"})}):null]}):null]})}function Fh({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(D.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 Hh({canEmptyGarbage:e,canUpload:r,onCollapse:n,expandedPaths:a,loadingPaths:o,loading:s,onDownload:l,onCopyPath:i,onEmptyGarbage:d,onPreview:h,onRefresh:u,onSelect:m,onToggle:f,onUpload:p,explorerScrollTopRef:g,explorerScrollerRef:b,selectedNodeId:k,tree:x,liveNodes:j}){const w=c.useMemo(()=>({...x,children:x.children.filter(y=>y.path!=="live")}),[x]);return c.useLayoutEffect(()=>{const y=b.current;y&&(y.scrollTop=g.current)},[b,g]),t.jsxs("aside",{className:`${Vo} flex flex-col`,children:[t.jsxs("div",{className:Ko,children:[t.jsx("div",{className:"min-w-0",children:t.jsx("h2",{className:qo,children:"Explorer"})}),t.jsxs("div",{className:"flex items-center gap-1",children:[n?t.jsxs("button",{type:"button","data-testid":"collapse-explorer",onClick:n,className:Xo,title:"Collapse Explorer","aria-label":"Collapse Explorer",children:[t.jsx(D.ChevronsLeft,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Collapse Explorer"})]}):null,t.jsx("button",{type:"button",onClick:p,disabled:!r,className:Or,title:r?"Upload file":"Upload is unavailable for this workspace","aria-label":"Upload file",children:t.jsx(D.Upload,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:u,className:Or,title:"Refresh workspace","aria-label":"Refresh workspace",children:t.jsx(D.RefreshCw,{className:`h-4 w-4 ${s?"animate-spin":""}`})}),d?t.jsx("button",{type:"button",onClick:d,disabled:!e,className:Or,title:e?"Empty garbage":"Garbage controls are unavailable","aria-label":"Empty garbage",children:t.jsx(D.Trash2,{className:"h-4 w-4"})}):null]})]}),t.jsxs("div",{ref:b,className:"thread-graph-workspace-tree-scroll min-h-0 flex-1 overflow-y-auto py-2",onScroll:y=>{g.current=y.currentTarget.scrollTop},children:[t.jsx(Fh,{liveNodes:j??[],onSelect:m,selectedNodeId:k}),t.jsx("div",{className:Yo,children:"Workspace"}),t.jsx(Wo,{depth:0,expandedPaths:a,loadingPaths:o,node:w,...i?{onCopyPath:i}:{},...l?{onDownload:l}:{},...h?{onPreview:h}:{},onSelect:m,onToggle:f,selectedNodeId:k}),w.children.length===0?t.jsx("p",{className:Zo,children:"This workspace is empty. Agent tool runs execute inside the thread workspace, so files should appear here as the session works."}):null]})]})}function Oh({activeView:e,detail:r,artifacts:n,plugins:a,status:o,focusPathRequest:s,workspaceAdapter:l}){const[i,d]=c.useState(null),h=c.useMemo(()=>l&&i?null:Oa(r,n),[e,i,n,r,o,l]),u=i??h??Oa(r,n),m=c.useMemo(()=>ih(u),[u]),f=c.useMemo(()=>{var z;return((z=u.children.find(O=>O.path==="live"))==null?void 0:z.children)??[]},[u]),p=Mo(u),[g,b]=c.useState(()=>(p==null?void 0:p.id)??null),[k,x]=c.useState(()=>new Set(["","artifacts","thread-events","live",...Wa((p==null?void 0:p.path)??"")])),[j,w]=c.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 639px)").matches?"viewer":null),[y,v]=c.useState(null),[S,N]=c.useState(!1),[I,M]=c.useState(()=>new Set),[R,Q]=c.useState(!1),[$,Y]=c.useState(!1),[Z,P]=c.useState(!1),[te,oe]=c.useState([]),[T,re]=c.useState(null),[B,J]=c.useState(null),[K,L]=c.useState(null),[q,G]=c.useState(!1),E=c.useRef(null),C=c.useRef(null),W=c.useRef(0),H=c.useRef(null),se=!!l,V=(g?m.get(g):null)??p??null,de={threadId:r.thread.id,workspaceId:r.workspace.id??r.thread.workspaceId??null};c.useEffect(()=>{W.current=0,H.current=null,x(new Set(["","artifacts","thread-events","live",...Gh(de),...Wa((p==null?void 0:p.path)??"")]))},[de.threadId,de.workspaceId]);function ee(){var O;const z=((O=C.current)==null?void 0:O.scrollTop)??W.current;W.current=z,H.current=z}function be(){const z=H.current??W.current;if(!C.current)return;let ne=0;const ge=()=>{const Te=C.current;Te&&(Te.scrollTop=Math.min(z,Math.max(0,Te.scrollHeight-Te.clientHeight)),W.current=Te.scrollTop,ne+=1,ne<8?window.requestAnimationFrame(ge):H.current=null)};window.requestAnimationFrame(ge)}c.useLayoutEffect(()=>{j!=="explorer"&&be()},[j,u]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const z=window.matchMedia("(max-width: 639px)"),O=()=>G(z.matches);return O(),typeof z.addEventListener=="function"?(z.addEventListener("change",O),()=>z.removeEventListener("change",O)):(z.addListener(O),()=>z.removeListener(O))},[]);async function ie(z){if(!l)return;const O=z??(V==null?void 0:V.path)??null;N(!0),v(null);try{const ne=tr(await l.listTree({...de,path:""}));let ge=i?Gn(ne,i):ne;if(i){const Ee=[...k].filter(fe=>fe).sort((fe,De)=>fe.split("/").length-De.split("/").length);for(const fe of Ee){const De=_n(i,fe);if((De==null?void 0:De.kind)!=="directory"||!De.childrenLoaded)continue;const Be=tr(await l.listTree({...de,path:fe}));ge=$n(ge,fe,Gn(Be,De))}}d(ge);const Te=zo(ge);b(Ee=>{var De;const fe=O??(Ee?(De=m.get(Ee))==null?void 0:De.path:null);return fe&&Dn(ge,fe)?`workspace:${fe}`:(Te==null?void 0:Te.id)??Ee})}catch(ne){v(ne instanceof Error?ne.message:"Failed to load workspace"),d(null)}finally{N(!1)}}async function ye(z){if(!(!l||!i)){M(O=>{if(O.has(z))return O;const ne=new Set(O);return ne.add(z),ne}),v(null);try{const O=tr(await l.listTree({...de,path:z}));d(ne=>ne&&Io(ne,z,O.children,{truncated:O.truncated}))}catch(O){v(O instanceof Error?O.message:"Failed to load directory")}finally{M(O=>{if(!O.has(z))return O;const ne=new Set(O);return ne.delete(z),ne})}}}async function Ae(z){const O=Po(z);if(!O)return;const ne=rh(O);if(w(null),x(ge=>{const Te=new Set(ge);Te.add("");for(const Ee of ne)Te.add(Ee);return qa(de,Te),Te}),!l){Dn(u,O)&&b(`workspace:${O}`);return}N(!0),v(null);try{let ge=i??tr(await l.listTree({...de,path:""}));for(const Te of ne){const Ee=_n(ge,Te);if((Ee==null?void 0:Ee.kind)==="directory"&&Ee.childrenLoaded)continue;const fe=tr(await l.listTree({...de,path:Te}));ge=$n(ge,Te,fe)}d(ge),b(`workspace:${O}`)}catch(ge){v(ge instanceof Error?ge.message:`Failed to open ${O}`)}finally{N(!1)}}c.useEffect(()=>{if(!(!l||!i))for(const z of m.values())z.path&&z.kind==="directory"&&k.has(z.path)&&z.hasChildren&&!z.childrenLoaded&&!I.has(z.path)&&ye(z.path)},[i,k,m,l]),c.useEffect(()=>{d(null),M(new Set),re(null),J(null),L(null),v(null),ie()},[se,r.thread.id,r.workspace.id,r.thread.workspaceId]),c.useEffect(()=>{s&&Ae(s.path)},[s==null?void 0:s.requestId]),c.useEffect(()=>{l!=null&&l.subscribeWorkspaceChanged},[l,de.threadId,de.workspaceId]),c.useEffect(()=>{const z=l&&(V==null?void 0:V.kind)==="file"?V.path:null;if(!z){re(null),J(null),L(null);return}const O=z;let ne=!1;async function ge(){var Te;if(l){Q(!0),v(null),re(null),J(null),L(null);try{const Ee=Ir(O),fe=(Te=l.getRawFileUrl)==null?void 0:Te.call(l,{...de,path:O});if(fe&&Ao.has(Ee)){ne||J(fe);return}if(fe&&_o.has(Ee)){ne||L(fe);return}const De=await l.readFile({...de,path:O,limit:Hr});ne||re(De)}catch(Ee){ne||v(Ee instanceof Error?Ee.message:"Failed to read file")}finally{ne||Q(!1)}}}return ge(),()=>{ne=!0}},[l,V==null?void 0:V.id]);async function ce(){if(!(!l||!(T!=null&&T.truncated))){Y(!0);try{const z=await l.readFile({...de,path:T.path,offset:T.nextOffset,limit:Hr});re(O=>O&&{...O,content:O.content+z.content,truncated:z.truncated,nextOffset:z.nextOffset,size:z.size})}finally{Y(!1)}}}async function Ce(z){if(!(l!=null&&l.writeFile))return;v(null),await l.writeFile({...de,path:z.path,content:z.content}),await ie(z.path);const O=await l.readFile({...de,path:z.path,limit:Hr});re(O)}async function Le(z){if(!(!(l!=null&&l.uploadFile)||!z)){N(!0),v(null);try{const O=await l.uploadFile({...de,path:z.name,file:z}),ne=O.kind==="archive"?O.paths[0]??null:O.file.path;await ie(ne)}catch(O){v(O instanceof Error?O.message:"Failed to upload file")}finally{N(!1)}}}async function X(z){var ne;const O=(ne=z.target.files)==null?void 0:ne[0];z.target.value="",O&&await Le(O)}function ue(){if(!(l!=null&&l.uploadFile))return;const z=()=>{var O;return(O=E.current)==null?void 0:O.click()};if(l.pickUploadFile){l.pickUploadFile({...de,defaultPick:z,upload:Le});return}z()}function ve(z){var O;(O=l==null?void 0:l.downloadNode)==null||O.call(l,{...de,path:z.path,kind:z.kind==="directory"?"directory":"file"})}function ke(z){if(!z.path||typeof navigator>"u"||!navigator.clipboard)return;const O=r.workspace.absPath.replace(/\/+$/,""),ne=z.path.startsWith("/")?z.path:O?`${O}/${z.path.replace(/^\/+/,"")}`:z.path;navigator.clipboard.writeText(ne).catch(ge=>{v(ge instanceof Error?ge.message:"Failed to copy file path")})}function $e(z){z.kind==="file"&&(ee(),b(z.id),w("explorer"))}async function He(){if(l!=null&&l.emptyGarbage){if(v(null),!l.listGarbage){oe([]),P(!0);return}try{const z=await l.listGarbage(de);oe(z.map(O=>`garbage/${O}`))}catch(z){oe([]),v(z instanceof Error?z.message:"Failed to list garbage files")}finally{P(!0)}}}async function _e(){if(l!=null&&l.emptyGarbage){P(!1),v(null);try{await l.emptyGarbage(de),await ie((V==null?void 0:V.path)??null)}catch(z){v(z instanceof Error?z.message:"Failed to empty garbage")}}}const ze={onCopyPath:ke,...l!=null&&l.downloadNode?{onDownload:ve}:{},...l!=null&&l.emptyGarbage?{onEmptyGarbage:He}:{},...l?{onRefresh:()=>void ie((V==null?void 0:V.path)??null)}:{},...l!=null&&l.uploadFile?{onUpload:ue}:{}};function F(z){if(!z)return;const O=m.get(`workspace:${z}`),ne=(O==null?void 0:O.kind)==="directory"&&O.hasChildren&&!O.childrenLoaded&&!I.has(z);x(ge=>{const Te=new Set(ge);return Te.has(z)?Te.delete(z):Te.add(z),qa(de,Te),Te}),!k.has(z)&&ne&&ye(z)}const le=t.jsx(Hh,{canEmptyGarbage:!!(l!=null&&l.emptyGarbage),canUpload:!!(l!=null&&l.uploadFile),onCollapse:()=>{ee(),w("explorer")},expandedPaths:k,loadingPaths:I,loading:S,explorerScrollTopRef:W,explorerScrollerRef:C,...ze,onPreview:$e,onSelect:z=>{b(z)},onToggle:F,selectedNodeId:(V==null?void 0:V.id)??null,tree:u,liveNodes:f}),we=t.jsx(_h,{error:y,imageUrl:B,loadingMore:$,onLoadMore:ce,...l!=null&&l.writeFile?{onSaveFile:Ce}:{},onCollapse:()=>{ee(),w("viewer")},pdfUrl:K,previewFile:T,previewLoading:R,plugins:a,selectedTarget:Ah(V)});return j==="explorer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:we}):j==="viewer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:le}):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(Dh,{files:te,onCancel:()=>P(!1),onConfirm:()=>void _e()}):null,q?t.jsxs(Mn,{direction:"vertical",className:"thread-graph-workspace-mobile-stack",children:[t.jsx(sr,{defaultSize:42,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-explorer h-full min-h-0 overflow-hidden",children:le})}),t.jsx(An,{className:"thread-graph-workspace-resize-handle h-2 bg-transparent after:h-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(sr,{defaultSize:58,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-viewer h-full min-h-0 overflow-hidden",children:we})})]}):t.jsxs(Mn,{direction:"horizontal",className:"thread-graph-workspace-resizable",children:[t.jsx(sr,{defaultSize:33,minSize:20,children:t.jsx("div",{className:"thread-graph-workspace-explorer-pane h-full min-h-0 overflow-hidden",children:le})}),t.jsx(An,{className:"thread-graph-workspace-resize-handle w-2 bg-transparent after:w-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(sr,{defaultSize:67,minSize:30,children:t.jsx("div",{className:"thread-graph-workspace-viewer-pane h-full min-h-0 overflow-hidden",children:we})})]}),t.jsx("input",{ref:E,type:"file","aria-label":"Workspace upload file input","data-testid":"workspace-upload-file-input",className:"hidden",onChange:z=>void X(z)})]})}var Hr,Uo,Vo,Ko,qo,Or,Xo,Yo,Zo,Wh=Oe({"src/components/graph-workspace/GraphWorkspaceExplorer.tsx"(){oa(),$h(),Bh(),Lo(),Hr=24e3,Uo="remote-codex:graphchat:workspace:expanded:",Vo="thread-graph-explorer h-full min-h-0 overflow-hidden rounded-[12px]",Ko="thread-graph-explorer-header flex h-[60px] shrink-0 items-center justify-between border-b px-4",qo="text-[18px] font-semibold text-slate-900 dark:text-slate-100",Or="thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition disabled:cursor-not-allowed disabled:opacity-50",Xo="thread-graph-explorer-collapse-button flex h-8 w-8 items-center justify-center rounded-full text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-[#222733] dark:hover:text-slate-100",Yo="thread-graph-workspace-label px-3 pb-1 pt-2 text-[11px] font-semibold tracking-normal text-slate-500 dark:text-slate-400",Zo="thread-graph-workspace-empty mx-4 mt-3 rounded-lg border border-dashed border-slate-200 bg-slate-50 px-3 py-4 text-sm text-slate-500 dark:border-[#303642] dark:bg-[#1b1f29] dark:text-slate-400"}});function yn({children:e}){return t.jsx("span",{className:"thread-guide-tag inline-flex items-center rounded px-1.5 py-0.5 font-mono text-[10px]",children:e})}function Qt({items:e}){return t.jsx("ul",{className:"space-y-1 text-[12px] text-[var(--theme-fg-muted)]",children:e.map((r,n)=>t.jsxs("li",{className:"flex gap-2",children:[t.jsx("span",{className:"mt-[6px] h-1 w-1 shrink-0 rounded-full bg-[var(--theme-border-contrast)]"}),t.jsx("span",{children:r})]},n))})}function Uh({children:e}){return t.jsx("span",{className:"thread-guide-icon flex h-5 w-5 shrink-0 items-center justify-center rounded-md",children:e})}function mr({value:e,title:r,icon:n,children:a}){return t.jsxs(Tr,{value:e,className:"thread-guide-section border-b border-[var(--theme-border)] last:border-b-0",children:[t.jsx(nn,{className:"py-3 hover:no-underline [&[data-state=open]]:pb-2",children:t.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-[var(--theme-fg)]",children:[t.jsx(Uh,{children:n}),r]})}),t.jsx(Er,{className:"space-y-3 pb-3",children:a})]})}function Vh(){return t.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[t.jsxs("div",{className:"shrink-0 border-b border-[var(--theme-border)] px-4 py-3",children:[t.jsx("h2",{className:"text-xs font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"What can I do?"}),t.jsx("p",{className:"mt-0.5 text-[11px] text-[var(--theme-fg-muted)]",children:"Upload files, ask in plain language, get results."})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-3 pb-6",children:t.jsxs(Sr,{type:"multiple",defaultValue:["start","workspace","remote-codex"],className:"space-y-0",children:[t.jsxs(mr,{value:"start",title:"Getting Started",icon:t.jsx(D.Zap,{className:"h-3 w-3"}),children:[t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"graphchat connects a language model to your files and a set of tools. Each Remote Codex thread has its own isolated workspace."}),t.jsx(Qt,{items:["Upload data files via the Workspace panel","Type a question or task in plain language","The agent calls tools, writes results to the workspace, and explains what it found","Agent-produced files appear in the workspace automatically when the host reports changes"]})]}),t.jsxs(mr,{value:"workspace",title:"Workspace Explorer",icon:t.jsx(D.FolderOpen,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(D.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(D.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(D.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(D.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(D.RefreshCw,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Refresh"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Resync the file tree manually after shell commands, external changes, or agent tool runs."})]})]}),t.jsxs("div",{className:"rounded-lg border border-[var(--theme-border)] p-2.5",children:[t.jsx("p",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"Preview surfaces"}),t.jsx(Qt,{items:[t.jsxs(t.Fragment,{children:[t.jsx(yn,{children:".xyz .extxyz .cif"})," use the 3D molecule plugin."]}),t.jsxs(t.Fragment,{children:[t.jsx(yn,{children:".png .jpg .gif .svg .webp"})," use inline image preview."]}),t.jsxs(t.Fragment,{children:[t.jsx(yn,{children:".py .json .ts .md .csv"})," use text/code preview."]}),"Large files load in chunks when the workspace adapter supports it."]})]})]}),t.jsxs(mr,{value:"viewer",title:"Viewer",icon:t.jsx(D.FileImage,{className:"h-3 w-3"}),children:[t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Viewer is the GraphChat-style artifact surface. It opens Remote Codex artifacts through the same frontend plugin renderers used in rich message bubbles, and previews workspace files from Explorer."}),t.jsx(Qt,{items:["Expand one artifact at a time for inspection","Fallback JSON preview is available for unknown artifact types","3D molecule artifacts remain interactive when the XYZ plugin is enabled"]})]}),t.jsxs(mr,{value:"usage",title:"Tool Usage & Chat",icon:t.jsx(D.BarChart2,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(D.BarChart2,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Usage tab"}),t.jsx(Qt,{items:["Bar chart of tool and command counts for this thread","Expandable call log: inspect every input and output","Recent live events appear with persisted history"]})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(D.MessageSquare,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Chat controls"}),t.jsx(Qt,{items:["New Chat creates a fresh Remote Codex thread with its own workspace","Interrupt, compact, goal controls, and model controls remain in the composer","Shell view stays available when a shell adapter is attached"]})]})]})]}),t.jsx(mr,{value:"remote-codex",title:"Remote Codex Extras",icon:t.jsx(D.Code2,{className:"h-3 w-3"}),children:t.jsx(Qt,{items:["Slash toolbox: skills, MCP, hooks, goals, forks, model controls, provider settings","Rich message bubbles: reasoning, commands, searches, file reads, file changes, plans, action requests, artifacts","Plugin surfaces: terminal, XYZ molecule viewer, inline code renderers, and imported plugin panels","Thread metadata stays in the left rail and Workspace tab instead of replacing chat"]})})]})})]})}var Kh=Oe({"src/components/graph-workspace/GraphGuidePanel.tsx"(){Lr()}});function qh(e){if(e==null)return"—";if(typeof e=="string")return e.length>2e3?`${e.slice(0,2e3)}
|
|
13
|
+
...(truncated)`:e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Ya({label:e,value:r}){return t.jsxs("div",{children:[t.jsx("p",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:e}),t.jsx("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap break-words rounded bg-[var(--theme-surface-strong)] p-2 text-[11px] leading-relaxed text-[var(--theme-fg-soft)]",children:qh(r)})]})}function Xh({event:e}){return t.jsxs(Tr,{value:e.id,className:"thread-tool-call mb-2 overflow-hidden rounded-lg border border-[var(--theme-border)] last:mb-0",children:[t.jsxs(nn,{className:"px-3 py-2 text-xs font-medium text-[var(--theme-fg)] hover:bg-[var(--theme-hover)] hover:no-underline [&[data-state=open]]:bg-[var(--theme-hover)]",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full bg-[var(--theme-accent-strong)]"}),t.jsx("span",{className:"truncate font-mono text-xs font-medium text-[var(--theme-fg)]",children:e.label}),e.status?t.jsx("span",{className:"shrink-0 rounded-full border border-[var(--theme-border)] px-1.5 py-0.5 text-[9px] uppercase tracking-[0.12em] text-[var(--theme-fg-muted)]",children:e.status}):null]}),t.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:e.turnId?t.jsx("span",{className:"max-w-20 truncate text-[10px] text-[var(--theme-fg-muted)]",children:e.turnId}):null})]}),t.jsx(Er,{className:"px-3 pb-3",children:t.jsxs("div",{className:"space-y-2 px-3 pb-3 pt-1",children:[t.jsx(Ya,{label:"Input",value:e.preview}),t.jsx(Ya,{label:"Output",value:e.detail})]})})]})}function Yh({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(D.RefreshCw,{className:"h-3 w-3"}),"Reload"]})]}),t.jsx("div",{className:"space-y-2",children:r.map(([i,d])=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"w-40 shrink-0 truncate text-right font-mono text-[11px] text-[var(--theme-fg-muted)]",title:e(i),children:e(i)}),t.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[t.jsx("div",{className:"relative h-4 flex-1 overflow-hidden rounded-sm bg-[var(--theme-muted)]",children:t.jsx("div",{className:"h-full rounded-sm bg-[var(--theme-accent-strong)] transition-all duration-300",style:{width:`${d/a*100}%`}})}),t.jsx("span",{className:"w-5 shrink-0 text-right text-[11px] font-medium text-[var(--theme-fg-soft)]",children:d})]})]},i))})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:[t.jsx("h2",{className:"mb-3 text-xs font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"Call log"}),t.jsx(Sr,{type:"single",collapsible:!0,value:o??"",onValueChange:i=>s(i||null),className:"space-y-0",children:n.slice(-50).map(i=>t.jsx(Xh,{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(D.RefreshCw,{className:"h-3 w-3"}),"Reload from workspace"]})]})}var Zh=Oe({"src/components/graph-workspace/GraphToolUsagePanel.tsx"(){Lr()}});function Za(e,r){const n=Math.max(e.measured.width??1,1),a=Math.max(e.measured.height??1,1),o=e.internals.positionAbsolute,s=r.internals.positionAbsolute,l=Math.max(r.measured.width??1,1),i=Math.max(r.measured.height??1,1),d=n/2,h=a/2,u=o.x+d,m=o.y+h,f=s.x+l/2,p=s.y+i/2,g=(f-u)/(2*d)-(p-m)/(2*h),b=(f-u)/(2*d)+(p-m)/(2*h),k=1/(Math.abs(g)+Math.abs(b)),x=k*g,j=k*b,w=d*(x+j)+u,y=h*(-x+j)+m;return{x:w,y}}function Ja(e,r){const n={...e.internals.positionAbsolute,...e},a=Math.round(n.x),o=Math.round(n.y),s=Math.round(r.x),l=Math.round(r.y);return s<=a+1?Gt.Left:s>=a+(e.measured.width??1)-1?Gt.Right:l<=o+1?Gt.Top:l>=n.y+(e.measured.height??1)-1?Gt.Bottom:Gt.Top}function Jo(e,r){const n=Za(e,r),a=Za(r,e),o=Ja(e,n),s=Ja(r,a);return{sx:n.x,sy:n.y,tx:a.x,ty:a.y,sourcePos:o,targetPos:s}}function Jh(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 k=g.id.split("").reduce((x,j)=>{const w=(x<<5)-x+j.charCodeAt(0);return w&w},0);f.set(g.id,{x:Math.abs(k)%u+b*100%u,y:Math.abs(k>>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 k=b+1;k<p;k+=1){const x=d[b],j=d[k];if(!x||!j)continue;const w=f.get(x.id),y=f.get(j.id);if(!w||!y)continue;const v=w.x-y.x,S=w.y-y.y,N=Math.sqrt(v*v+S*S)||1,M=(200-N)*.5,R=v/N*M,Q=S/N*M;w.vx+=R,w.vy+=Q,y.vx-=R,y.vy-=Q}h.forEach(b=>{const k=f.get(b.source),x=f.get(b.target);if(!k||!x)return;const j=x.x-k.x,w=x.y-k.y,y=Math.sqrt(j*j+w*w)||1,S=(y-120)*.3,N=j/y*S,I=w/y*S;k.vx+=N,k.vy+=I,x.vx-=N,x.vy-=I}),f.forEach(b=>{b.x+=b.vx*.1,b.y+=b.vy*.1,b.vx*=.9,b.vy*=.9,b.x=Math.max(80,Math.min(u-80,b.x)),b.y=Math.max(80,Math.min(m-80,b.y))})}return f},o=new Set(e.map(d=>d.id)),s=[];e.forEach(d=>{if(!d.out_node_id)return;(Array.isArray(d.out_node_id)?d.out_node_id:[d.out_node_id]).forEach(u=>{o.has(u)&&s.push({id:`${d.id}-${u}`,source:d.id,target:u,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:Fs.Arrow}})})});const l=a(e,s,r,n);return{nodes:e.map(d=>({id:d.id,type:"styledNode",position:l.get(d.id)??{x:100,y:100},data:{label:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-sm font-semibold",children:d.name}),d.description?t.jsx("div",{className:"mt-1 max-w-32 overflow-hidden text-ellipsis text-xs text-slate-500 dark:text-slate-400",children:d.description}):null]})}})),edges:s}}var la=Oe({"src/components/graph-chat/FloatingHelper.tsx"(){}});function Qh({toX:e,toY:r,fromPosition:n,toPosition:a,fromNode:o}){if(!o)return null;const s={id:"connection-target",measured:{width:1,height:1},internals:{positionAbsolute:{x:e,y:r}}},{sx:l,sy:i,tx:d,ty:h,sourcePos:u,targetPos:m}=Jo(o,s),[f]=Hs({sourceX:l,sourceY:i,sourcePosition:u||n,targetPosition:m||a,targetX:d||e,targetY:h||r});return t.jsxs("g",{children:[t.jsx("path",{fill:"none",stroke:"currentColor",strokeWidth:1.5,className:"animated",d:f}),t.jsx("circle",{cx:d||e,cy:h||r,fill:"var(--theme-panel)",r:3,stroke:"currentColor",strokeWidth:1.5})]})}var eu=Oe({"src/components/graph-chat/FloatingConnectionLine.tsx"(){la()}});function tu({id:e,source:r,target:n,markerEnd:a,style:o}){const s=Ca(r),l=Ca(n);if(!s||!l)return null;const{sx:i,sy:d,tx:h,ty:u,sourcePos:m,targetPos:f}=Jo(s,l),[p]=Hs({sourceX:i,sourceY:d,sourcePosition:m,targetPosition:f,targetX:h,targetY:u});return t.jsx("path",{id:e,className:"react-flow__edge-path",d:p,markerEnd:a,style:o})}var ru=Oe({"src/components/graph-chat/FloatingEdge.tsx"(){la()}});function nu({nodes:e}){const[r,n,a]=bd([]),[o,s,l]=vd([]),i=c.useMemo(()=>Jh(e),[e]),d=c.useMemo(()=>({floating:tu}),[]),h=c.useMemo(()=>({styledNode:({data:m,isConnectable:f})=>t.jsxs("div",{className:"thread-graph-flow-node",children:[m.label,t.jsx(Na,{type:"target",position:Gt.Top,isConnectable:f,style:{opacity:0,pointerEvents:"none"}}),t.jsx(Na,{type:"source",position:Gt.Bottom,isConnectable:f,style:{opacity:0,pointerEvents:"none"}})]})}),[]);c.useEffect(()=>{n(i.nodes),s(i.edges)},[i.edges,i.nodes,s,n]);const u=c.useCallback(m=>s(f=>kd({...m,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:Fs.Arrow}},f)),[s]);return t.jsx("div",{className:"thread-graph-flow h-full min-h-0",children:t.jsx(wd,{children:t.jsxs(yd,{nodes:r,edges:o,onNodesChange:a,onEdgesChange:l,onConnect:u,fitView:!0,nodeTypes:h,edgeTypes:d,connectionLineComponent:Qh,children:[t.jsx(jd,{}),t.jsx(Nd,{gap:16})]})})})}var au=Oe({"src/components/graph-chat/GraphVisualization.tsx"(){eu(),ru(),la()}});function su(e){return{...el,...e}}function Qa(e,r){const n=a=>{switch(a){case"workspace":return e.workspace;case"tools":return e.toolUsage;case"guide":return e.guide;case"graph":return e.threadGraph;case"extensions":return e.extensions}};return r&&n(r)?r:["workspace","tools","guide","graph","extensions"].find(n)??null}function ou(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 lu(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:qr(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:qr(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 qr(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 iu(e){switch(e.kind){case"userMessage":return"User";case"agentMessage":return"Agent";default:return qr(e.kind)}}function du(e){return(e.previewText??e.text??e.detailText??e.kind).replace(/\s+/g," ").slice(0,96)}function cu(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:iu(d),description:du(d),out_node_id:u}),i=h,d.kind==="artifact"&&d.artifact&&n.push({id:`artifact:${d.artifact.id}`,name:d.artifact.title||d.artifact.type,description:d.artifact.summaryText??d.artifact.type,out_node_id:h})}}const o=new Set(n.map(s=>s.id));for(const s of r){const l=`tool:${s.id}`;o.has(l)||o.has(`item:${s.id}`)||n.push({id:l,name:s.label,description:s.preview,out_node_id:s.turnId?`turn:${s.turnId}`:`thread:${e.thread.id}`})}return n.slice(0,120)}function Qo({detail:e,status:r,plugins:n,workspaceAdapter:a,metaContent:o,settingsContent:s,activeView:l="chat",features:i,focusPathRequest:d=null}){const h=c.useMemo(()=>su(i),[i]),u=Qa(h,i==null?void 0:i.defaultTab),[m,f]=c.useState(u),p=c.useMemo(()=>Qc(e),[e]),g=c.useMemo(()=>lu(e),[e]),b=c.useMemo(()=>{const v=new Map;for(const S of g)v.set(S.kind,(v.get(S.kind)??0)+1);return[...v.entries()].sort((S,N)=>N[1]-S[1])},[g]),k=n.getThreadPanels(),x=Math.max(...b.map(([,v])=>v),1),j=c.useMemo(()=>cu(e,g),[e,g]),w=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:D.BarChart2}),h.guide&&v.push({id:"guide",label:"Guide",icon:D.BookOpen}),v},[h.guide,h.toolUsage,h.workspace]),y=c.useMemo(()=>{const v=[];return h.threadGraph&&v.push({id:"graph",label:"Thread graph",icon:D.GitBranch}),h.extensions&&v.push({id:"extensions",label:"Remote Codex extensions",icon:D.Wrench}),v},[h.extensions,h.threadGraph]);return c.useEffect(()=>{(!m||!ou(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:[w.map(v=>{const S=v.icon;return t.jsxs("button",{type:"button",onClick:()=>f(v.id),className:`thread-graph-right-tab inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md px-3 text-xs font-medium transition ${m===v.id?"is-active":""}`,children:[S?t.jsx(S,{className:"h-3.5 w-3.5"}):null,v.label]},v.id)}),y.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:y.map(v=>{const S=v.icon;return t.jsx("button",{type:"button",onClick:()=>f(v.id),className:`thread-graph-right-tab inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-xs font-medium transition ${m===v.id?"is-active":""}`,title:v.label,"aria-label":v.label,children:t.jsx(S,{className:"h-3.5 w-3.5"})},v.id)})}):null]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[m==="workspace"?t.jsx(Oh,{activeView:l,detail:e,artifacts:p,plugins:n,status:r,focusPathRequest:d,workspaceAdapter:a??null}):null,m==="tools"?t.jsx(Yh,{formatToolKind:qr,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(nu,{nodes:j})}):null,m==="extensions"?t.jsx("div",{className:"h-full min-h-0 overflow-y-auto p-3",children:t.jsxs("div",{className:"grid gap-3",children:[t.jsx(rr,{label:"Plugin Panels",children:k.length?t.jsx("div",{className:"flex flex-wrap gap-2",children:k.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(rr,{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(rr,{label:"Remote Codex Tools",children:t.jsxs("div",{className:"grid gap-2 text-[var(--theme-fg-muted)]",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(D.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(D.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(D.Trash2,{className:"mt-0.5 h-4 w-4 shrink-0"}),t.jsx("p",{children:"Destructive actions stay explicit: delete thread, interrupt, compact, and hook trust controls remain host governed."})]})]})}),o?t.jsx(rr,{label:"Thread Meta",children:o}):null,s?t.jsx(rr,{label:"Settings",children:s}):null]})}):null,m==="guide"?t.jsx(Vh,{}):null]})]}):null}var el,tl,hu=Oe({"src/components/ThreadGraphWorkspacePanel.tsx"(){Wh(),$o(),Kh(),Zh(),oa(),au(),el={workspace:!0,toolUsage:!0,guide:!0,threadGraph:!0,extensions:!0},tl=c.memo(Qo)}}),rl={};Jc(rl,{MemoizedThreadGraphWorkspacePanel:()=>tl,ThreadGraphWorkspacePanel:()=>Qo});var uu=Oe({"src/workspace-panel.ts"(){hu()}});function ir(e,{insertAt:r}={}){if(!e||typeof document>"u")return;const n=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css",r==="top"&&n.firstChild?n.insertBefore(a,n.firstChild):n.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}ir(`.thread-ui-shell,
|
|
14
14
|
.thread-graph-dialog {
|
|
15
15
|
color-scheme: light;
|
|
16
16
|
--radius: 0.625rem;
|
|
@@ -3635,13 +3635,13 @@ import{l as B,R as qi,I as Xi,C as Yi,S as Hs,H as Zi,T as Ji,a as Qi,b as ed,c
|
|
|
3635
3635
|
padding: 1.5rem;
|
|
3636
3636
|
}
|
|
3637
3637
|
}
|
|
3638
|
-
`);function
|
|
3639
|
-
`)}function
|
|
3640
|
-
`).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
|
|
3638
|
+
`);function mu(e){return e.replace(/\u00a0/g," ")}function pu(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 fu(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 gu(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 xu({files:e,kindForFile:r,usedPlaceholders:n,buildClientId:a}){return e.map(o=>{const s=r(o),l=Iu(o,s),i=fu(s,zu(l),n);return n.add(i),{clientId:a(),kind:s,originalName:l,placeholder:i,file:o}})}function bu({prompt:e,attachments:r,files:n,selection:a,kindForFile:o,buildClientId:s}){const l=new Set(r.map(p=>p.placeholder)),i=xu({files:n,kindForFile:o,usedPlaceholders:l,buildClientId:s}),d=a?{start:a.start,end:a.end}:{start:e.length,end:e.length},h=gu(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 vu({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 ku({files:e,plainText:r,htmlText:n,htmlToText:a}){if(e.length>0)return{type:"append-files",preventDefault:!0,files:e};const o=r||a(n);return!o&&!n?{type:"ignore",preventDefault:!1}:{type:"insert-text",preventDefault:!0,text:o}}function es(e){return e?{type:"accept-files",preventDefault:!0,activateDragTarget:!0}:{type:"ignore",preventDefault:!1,activateDragTarget:!1}}function wu(e){return e.length>0?{type:"accept-files",preventDefault:!0,activateDragTarget:!0,files:e}:{type:"ignore",preventDefault:!1,activateDragTarget:!1}}function yu({key:e,metaKey:r,ctrlKey:n,busy:a,disabled:o}){const s=e==="Enter"&&(r||n);return{preventDefault:s,submit:s&&!a&&!o}}function ju({nextMode:e,previousOptimisticMode:r}){return{optimisticMode:e??null,rollbackMode:e?r:null,shouldRollbackMode:!!e,closeMenuOnSuccess:!0}}function Mr(e){return`${e.prompt}${e.attachments.map(r=>`${r.clientId}${r.kind}${r.placeholder}${r.originalName}`).join("")}`}function ts(e){if(!e)return"Auto";switch(e){case"xhigh":return"xhigh";default:return e}}function Nu(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 Cu(e){if(!e)return"";const r=e/1e3;return Number.isInteger(r)?String(r):String(Number(r.toFixed(1)))}function Fn(e){return e.replace(/\r\n/g,`
|
|
3639
|
+
`)}function Su(e){const r=e.trim();return/^[A-Za-z0-9_-]+$/.test(r)?r:null}function Tu(e){const n=Fn(e).split(`
|
|
3640
|
+
`).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 Eu(e,r){return`[mcp_servers.${e}]
|
|
3641
3641
|
url = ${JSON.stringify(r.trim())}
|
|
3642
|
-
`}function
|
|
3642
|
+
`}function rs(e,r,n){var m,f;const a=Fn(e),o=`${Fn(n).trim()}
|
|
3643
3643
|
`,s=a.split(`
|
|
3644
|
-
`),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
|
|
3644
|
+
`),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 k=((f=s[b])==null?void 0:f.trim())??"";if(k.startsWith("[")&&!(k===l||k.startsWith(i))){h=b;break}}const p=s.slice(0,d).join(`
|
|
3645
3645
|
`).trimEnd(),g=s.slice(h).join(`
|
|
3646
3646
|
`).trim();return[p,o.trimEnd(),g].filter(Boolean).join(`
|
|
3647
3647
|
|
|
@@ -3650,28 +3650,28 @@ url = ${JSON.stringify(r.trim())}
|
|
|
3650
3650
|
`).concat(`
|
|
3651
3651
|
`)}const u=a.trimEnd();return u?`${u}
|
|
3652
3652
|
|
|
3653
|
-
${o}`:o}function sl(e){return typeof e!="number"||Number.isNaN(e)?0:Math.max(0,Math.min(100,Math.round(e)))}function Nn(e){const r=e/1e3;return Number.isInteger(r)?`${r}k`:`${Number(r.toFixed(1))}k`}function Iu(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,`${Nn(n)} used / ${Nn(a)}`,`${Nn(o)} left`,`${sl(r.remainingPercent)}% context left`].join(" · ")}function zu(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 Pu(e){return e.replace(/[\r\n[\]]+/g," ").replace(/\s+/g," ").trim()||"attachment"}function On(e){return e.type.startsWith("image/")?"photo":"file"}function Wn(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 ss(e,r){return Wn(e,r).length>0}function Ru(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function os(e){const r=e.placeholder.match(/^\[(?:PHOTO|FILE)\s+(.+)\]$/);return r!=null&&r[1]?r[1]:Ru(e.originalName)}var Yr=[{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 Mu({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 Au({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 $u(){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 _u(){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 Du(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.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 Bu(){return t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.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 Gu(){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 Un(){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 Fu(e){switch(e){case"bearerToken":return"Token";case"oAuth":return"OAuth";case"notLoggedIn":return"Login";case"unsupported":return"Public";default:return"Unknown"}}function Hu(e){switch(e){case"repo":return"Repo";case"system":return"System";case"admin":return"Admin";case"user":default:return"User"}}function Ou(e){var r;return((r=Yr.find(n=>n.value===e))==null?void 0:r.label)??e}function Wu(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 Uu(e){switch(e){case"managed":return"Managed";case"modified":return"Modified";case"trusted":return"Trusted";case"untrusted":return"Review"}}function Vu(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 Ku(e){return e.source==="user"?"global":e.source==="project"?"project":null}function ol(e){const r=Ku(e);return!r||e.handlerType!=="command"||!e.command||e.isManaged?null:{scope:r,eventName:e.eventName,matcher:e.matcher,command:e.command,timeoutSec:e.timeoutSec,statusMessage:e.statusMessage}}function qu(e){switch(e){case"active":return"Active";case"paused":return"Paused";case"budgetLimited":return"Budget";case"complete":return"Complete";default:return e}}function Xu({contextUsage:e}){const r=(e==null?void 0:e.availability)??"unavailable",n=sl(e==null?void 0:e.remainingPercent);if(r!=="available")return null;const a=n<=20?"rgba(251,113,133,0.90)":n<=40?"rgba(252,211,77,0.85)":"rgba(125,211,252,0.80)";return t.jsx("span",{"aria-hidden":"true",className:"thread-context-progress-track pointer-events-none mt-0.5 block",children:t.jsx("span",{className:"thread-context-progress-fill block",style:{width:`${n}%`,backgroundColor:a}})})}function Bt({label:e,tone:r="stone"}){const n=r==="rose"?"border-rose-300/35 bg-rose-300/14 text-rose-50":r==="sky"?"border-sky-300/35 bg-sky-300/14 text-sky-50":"border-stone-700/90 bg-stone-900/80 text-stone-100";return t.jsx("span",{className:`inline-flex min-w-[3rem] items-center justify-center rounded-full border px-2 py-1.5 text-[10px] font-medium tracking-[0.12em] ${n}`,children:e})}function Yu(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 Zu(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 Ju(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?qu(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 Qu(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 em(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 tm(e){if(!e)return"";const r=document.createElement("div");return r.innerHTML=e,r.textContent??""}function rm(e){return!!e.querySelector("[style], font")}function Ft(e){return e instanceof HTMLElement&&e.dataset.segmentType==="attachment"&&e.dataset.placeholder?e.dataset.placeholder:e.textContent??""}function ll(e){let r="";for(const n of Array.from(e.childNodes))r+=Ft(n);return r.replace(/\u00a0/g," ")}function ls(e,r,n){var i;let a=null,o=n;if(r===e){const d=Array.from(e.childNodes);let h=0;for(let u=0;u<Math.min(n,d.length);u+=1){const m=d[u];m&&(h+=Ft(m).length)}return h}if(r.nodeType===Node.TEXT_NODE)a=r;else{const d=Array.from(e.childNodes).find(h=>h.contains(r));if(!d)return ll(e).length;if(a=d,d instanceof HTMLElement&&d.dataset.segmentType==="attachment"){const h=document.createRange();h.selectNodeContents(d);const u=Ft(d).length;try{h.setEnd(r,n);const m=h.toString().length,f=((i=d.textContent)==null?void 0:i.length)??0;f===0?o=u:o=Math.round(Math.min(1,m/f)*u)}catch{o=u}}else{const h=document.createRange();h.selectNodeContents(d);try{h.setEnd(r,n),o=h.toString().length}catch{o=Ft(d).length}}}const s=Array.from(e.childNodes);let l=0;for(const d of s){if(d===a)return d.nodeType===Node.TEXT_NODE?l+o:l+Math.min(o,Ft(d).length);l+=Ft(d).length}return l}function nm(e){const r=window.getSelection();if(!r||r.rangeCount===0)return null;const n=r.getRangeAt(0);return!e.contains(n.startContainer)||!e.contains(n.endContainer)?null:{start:ls(e,n.startContainer,n.startOffset),end:ls(e,n.endContainer,n.endOffset)}}function is(e,r){let n=Math.max(0,r);const a=Array.from(e.childNodes);for(const[o,s]of a.entries()){const i=Ft(s).length;if(s.nodeType===Node.TEXT_NODE){if(n<=i)return{node:s,offset:n};n-=i;continue}if(s instanceof HTMLElement&&s.dataset.segmentType==="attachment"){if(n===0)return{node:e,offset:o};if(n<=i){const d=a[o+1];return n===i&&(d==null?void 0:d.nodeType)===Node.TEXT_NODE?{node:d,offset:0}:{node:e,offset:o+1}}n-=i;continue}if(n<=i)return{node:e,offset:o+1};n-=i}return{node:e,offset:e.childNodes.length}}function am(e,r){const n=is(e,r.start),a=is(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 sm(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}nn();Pt();function om({className:e,...r}){return t.jsx("div",{"data-slot":"input-group",role:"group",className:rt("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 lm=Cr("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*=size-])]:size-4",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.45rem]","block-start":"order-first w-full justify-start px-3 pt-3","block-end":"order-last w-full justify-start px-3 pb-3"}},defaultVariants:{align:"inline-start"}});function im({className:e,align:r="inline-start",...n}){return t.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":r,className:rt(lm({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 dm=Cr("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*=size-])]:size-3.5",sm:"h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function jt({className:e,type:r="button",variant:n="ghost",size:a="xs",...o}){return t.jsx(Nr,{type:r,"data-size":a,variant:n,className:rt(dm({size:a}),e),...o})}function cm({className:e,...r}){return t.jsx("span",{className:rt("flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*=size-])]:size-4",e),...r})}function hm({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 um(e){if(!e)return"reset time unavailable";const r=new Date(e);return Number.isNaN(r.getTime())?"reset time unavailable":`resets ${r.toLocaleString()}`}function mm({usage:e}){if(!e||e.authKind!=="subscription"||e.windows.length===0)return null;const r=e.windows.slice(0,2),n=r.map(a=>{const o=Math.max(0,100-a.usedPercent);return`${a.label}: ${o}% remaining, ${um(a.resetsAt)}`}).join(". ");return t.jsx("button",{type:"button",className:"thread-subscription-usage pointer-events-auto absolute bottom-1 right-2 inline-flex h-4 items-center gap-1 rounded-[0.55rem] border border-stone-500/45 bg-stone-950/15 px-1 text-[8px] leading-none text-stone-200/80 opacity-70 shadow-sm transition hover:border-sky-300/45 hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-sky-200/70 sm:right-3","aria-label":`${e.provider} subscription usage. ${n}`,title:`${n}${e.stale?". Last known values.":""}`,children:r.map(a=>{const o=Math.max(0,Math.min(100,100-a.usedPercent)),s=o<=10?"bg-rose-400":o<=25?"bg-amber-300":"bg-sky-300";return t.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[t.jsx("span",{className:"font-semibold",children:a.label}),t.jsx("span",{className:"h-0.5 w-3.5 overflow-hidden rounded-full bg-stone-600/60",children:t.jsx("span",{className:`block h-full rounded-full ${s}`,style:{width:`${o}%`}})}),t.jsxs("span",{className:"tabular-nums",children:[Math.round(o),"%"]})]},a.id)})})}function pm({activeView:e,followTail:r,onToggleFollow:n,canJumpToPreviousTurn:a,onJumpToPreviousTurn:o,canJumpToNextTurn:s,onJumpToNextTurn:l,subscriptionUsage:i}){return e!=="chat"?null:t.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-[90] h-11 -translate-y-full bg-transparent touch-manipulation sm:h-10",children:[t.jsxs("span",{role:"group","aria-label":"Timeline navigation",className:`thread-jump-latest-badge pointer-events-auto absolute bottom-1 left-1/2 inline-flex h-5 min-w-[7.5rem] -translate-x-1/2 overflow-hidden rounded-[0.7rem] border shadow-sm transition ${r?"is-active border-sky-300/36 bg-sky-300/[0.03] text-sky-100/86":"border-stone-500/70 bg-stone-950/[0.08] text-stone-200/86"}`,children:[t.jsx("button",{type:"button","aria-label":"Jump to previous turn",title:a?"Jump to the start of the previous turn":"No earlier turn",disabled:!a,onClick:()=>o==null?void 0:o(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70 disabled:cursor-default disabled:opacity-35",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3.5 12h9M8 10V5M6 7l2-2 2 2"})})}),t.jsx("span",{"aria-hidden":"true",className:"w-px bg-current opacity-20"}),t.jsx("button",{type:"button","aria-label":"Jump to latest",title:r?"Latest messages are in view":"Jump to the bottom",onClick:()=>n==null?void 0:n(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m4 5.5 4 4 4-4M3.5 12.5h9"})})}),t.jsx("span",{"aria-hidden":"true",className:"w-px bg-current opacity-20"}),t.jsx("button",{type:"button","aria-label":"Jump to next turn",title:s?"Jump to the start of the next turn":"No later turn",disabled:!s,onClick:()=>l==null?void 0:l(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70 disabled:cursor-default disabled:opacity-35",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3.5 4h9M8 6v5m-2-2 2 2 2-2"})})})]}),t.jsx(mm,{usage:i})]})}function fm({activeView:e,layerClassName:r,formClassName:n,shellClassName:a,inputGroupClassName:o,error:s,followTail:l,photoInputRef:i,fileInputRef:d,onAppendAttachments:h,onToggleFollow:u,canJumpToPreviousTurn:m,onJumpToPreviousTurn:f,canJumpToNextTurn:p,onJumpToNextTurn:g,subscriptionUsage:b,onSubmit:v,formRef:x,promptSlot:j,toolbarSlot:w,goalSlot:y,shellPromptSlot:k}){return t.jsxs("div",{className:r,children:[t.jsx(hm,{photoInputRef:i,fileInputRef:d,onAppendAttachments:h}),t.jsx(pm,{activeView:e,followTail:l,onToggleFollow:u,canJumpToPreviousTurn:m,onJumpToPreviousTurn:f,canJumpToNextTurn:p,onJumpToNextTurn:g,subscriptionUsage:b}),t.jsxs("form",{ref:x,"data-testid":e==="chat"?"chat-composer":void 0,onSubmit:v,className:n,children:[t.jsxs("div",{className:`${a} flex w-full flex-col overflow-visible rounded-[16px] sm:rounded-[18px]`,children:[t.jsxs(om,{className:o,children:[j,w]}),y,k]}),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 gm({open:e,iconButtonClassName:r,menuClassName:n,menuItemClassName:a,onToggle:o,onPickPhoto:s,onPickFile:l}){return t.jsxs("div",{className:"relative",children:[t.jsx(jt,{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(_u,{})}),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 il=[{mode:"read-only",label:"Read only"},{mode:"workspace-write",label:"Workspace write"},{mode:"danger-full-access",label:"Danger"}];function ds(e){var r;return((r=il.find(n=>n.mode===e))==null?void 0:r.label)??"Default"}function xm({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:v,sendButtonLabel:x,sendButtonClassName:j,modelControlsDisabled:w,effortControlsDisabled:y,effortControlTitle:k,inlineToggleClassName:S,menuItemClassName:N,planToggleActiveClassName:L,sendButtonBaseClassName:R,onSetOpenMenu:P,onUpdateSettings:J}){return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative min-w-0",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="model","aria-label":r??"Select model",disabled:w||n.length===0,onClick:()=>P(D=>D==="model"?null:"model"),title:v?`Fast mode is on. Turn it off from the slash toolbox to edit model. ${a}`:a,className:`${S} relative min-w-0 max-w-[8.75rem] overflow-hidden rounded-full px-2.5 text-left text-stone-300 disabled:cursor-not-allowed disabled:text-stone-600 sm:max-w-[11rem]`,children:t.jsx("span",{className:"relative z-[1] block min-w-0 truncate whitespace-nowrap [direction:rtl]",children:r??"Select model"})}),r?t.jsx(Xu,{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:()=>J({model:D.model,reasoningEffort:D.defaultReasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${D.model===r?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:D.model})},D.id))})})]}),t.jsxs("div",{className:"relative",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="effort",disabled:y,onClick:()=>P(D=>D==="effort"?null:"effort"),title:k,className:`${S} rounded-full px-2 disabled:cursor-not-allowed disabled:text-stone-700 ${y?"text-stone-500":"text-stone-300 hover:text-stone-100"}`,children:ns(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:()=>J({reasoningEffort:D.reasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${D.reasoningEffort===s?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:ns(D.reasoningEffort)})},D.reasoningEffort))})})]}),u&&t.jsxs("div",{className:"relative",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="sandbox","aria-label":`Sandbox: ${ds(d)}`,disabled:m,onClick:()=>P(D=>D==="sandbox"?null:"sandbox"),title:`Sandbox: ${ds(d)}`,className:`${S} rounded-full px-2.5 text-stone-300 disabled:cursor-not-allowed disabled:text-stone-700`,children:"Sandbox"}),e==="sandbox"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[9rem] max-w-[13rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:il.map(D=>t.jsx("button",{type:"button",onClick:()=>J({sandboxMode:D.mode}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${D.mode===d?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:D.label})},D.mode))})})]}),h&&t.jsx(jt,{type:"button",variant:"ghost",size:"xs","aria-pressed":i==="plan",disabled:m,onClick:()=>J({collaborationMode:i==="plan"?"default":"plan"}),className:`${S} rounded-full px-2.5 ${i==="plan"?`${L} border !border-[oklch(0.78_0.16_86_/_0.76)] !bg-[oklch(0.44_0.095_82_/_0.72)] !text-[oklch(0.96_0.055_92)] shadow-[0_0_0_1px_oklch(0.78_0.16_86_/_0.24),0_0_18px_oklch(0.78_0.16_86_/_0.42),inset_0_0_0_1px_oklch(0.98_0.04_96_/_0.18)]`:"text-stone-500"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Plan"}),t.jsx(jt,{type:"submit",variant:"default",size:"icon-xs","aria-label":f?"Set goal":"Send Prompt",title:x,disabled:p||(g==="chat"?b:!1),className:`${R} h-9 w-9 rounded-full text-sm font-medium disabled:cursor-not-allowed sm:h-8 sm:w-8 ${j}`,children:t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-none stroke-current",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M8 13V3"}),t.jsx("path",{d:"m4 7 4-4 4 4"})]})})]})}function bm({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(Un,{}),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(Un,{}),t.jsx("span",{className:"text-[10px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:e,onClick:o,className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!l||!i,onClick:()=>s("ctrl_c"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CTRL-C",tone:"rose"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("ctrl_d"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CTRL-D"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("esc"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"ESC"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("tab"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"TAB"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("up"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"UP"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("down"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"DOWN"})})]})})}function vm({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 km({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 wm({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:v,onClearHookConfigStatus:x,onSetEditingHookTarget:j,onSetHookScope:w,onSetHookEventName:y,onSetHookMatcher:k,onSetHookCommand:S,onSetHookTimeoutSec:N,onSetHookStatusMessage:L,onSaveHook:R,onStartEditingHook:P,onTrustHook:J,onUntrustHook:D}){var Y,Z,I,re,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:((Y=r.data)==null?void 0:Y.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,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"," ",Vu((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:$=>w($.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:$=>y($.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:Yr.map($=>t.jsx("option",{value:$.value,children:$.label},$.value))})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"Matcher"}),t.jsx("input",{"aria-label":"Hook matcher",value:u,onChange:$=>k($.target.value),placeholder:"Bash",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"Command"}),t.jsx("textarea",{"aria-label":"Hook command",value:m,onChange:$=>S($.target.value),rows:3,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 font-mono text-xs text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("label",{className:"block text-xs text-stone-400",children:["Timeout",t.jsx("input",{"aria-label":"Hook timeout seconds",value:f,onChange:$=>N($.target.value),inputMode:"numeric",className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50"})]}),t.jsxs("label",{className:"block text-xs text-stone-400",children:["Status message",t.jsx("input",{"aria-label":"Hook status message",value:p,onChange:$=>L($.target.value),className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50"})]})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>{v("list"),j(null)},className:`${g} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void R(),disabled:o,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:o?"Saving...":e==="edit"?"Update Hook":"Write Hook"})]})]}):null,e==="list"&&((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"&&((I=r.data)!=null&&I.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"&&((re=r.data)!=null&&re.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:[Ou($.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:[ol($)?t.jsx("button",{type:"button",onClick:Q=>{Q.stopPropagation(),P($)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-sky-100 transition hover:border-sky-300/35 hover:bg-sky-300/10`,children:"Edit"}):null,a&&$.trustStatus==="trusted"&&!$.isManaged?t.jsx("button",{type:"button",disabled:o,onClick:Q=>{Q.stopPropagation(),D($)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-amber-100 transition hover:border-amber-300/35 hover:bg-amber-300/10 disabled:cursor-not-allowed disabled:opacity-50`,children:"Untrust"}):null,($.trustStatus==="untrusted"||$.trustStatus==="modified")&&!$.isManaged&&a?t.jsx("button",{type:"button",disabled:o||!$.currentHash,onClick:Q=>{Q.stopPropagation(),J($)},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:Uu($.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:Wu($.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 Ur(e){return e.localGoalId??`${e.createdAt}:${e.objective}`}function ym(e,r){const n=e?[e,...r]:r,a=new Set;return n.filter(o=>{const s=Ur(o);return a.has(s)?!1:(a.add(s),!0)})}function jm(e){if(e<60)return`${e}s`;const r=Math.floor(e/60);return r<60?`${r}m`:`${Math.floor(r/60)}h ${r%60}m`}function Nm(e){switch(e){case"budgetLimited":return"Budget limited";case"complete":return"Complete";case"terminated":return"Terminated";case"paused":return"Paused";default:return"Active"}}function Cm({goalState:e,goalHistory:r,busy:n,onBack:a,onUpdateGoal:o}){const s=ym(e.data,r),l=e.data?Ur(e.data):null;return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-h-11 items-center justify-between gap-3 border-b border-[var(--theme-border)] px-3 py-2",children:[t.jsx("button",{type:"button",onClick:a,className:"min-h-9 rounded-lg px-2 text-xs font-medium text-[var(--theme-fg-muted)] transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--theme-accent-border)]",children:"Back"}),t.jsx("span",{className:"text-xs font-semibold text-[var(--theme-fg)]",children:"Goals"})]}),e.error?t.jsx("p",{className:"m-3 rounded-lg border border-[var(--status-danger-border)] bg-[var(--status-danger-bg)] px-3 py-2 text-xs text-[var(--status-danger-fg)]",children:e.error}):null,e.status==="loading"&&s.length===0?t.jsxs("div",{className:"space-y-2 p-3",role:"status","aria-label":"Loading goals",children:[t.jsx("div",{className:"h-12 animate-pulse rounded-lg bg-[var(--theme-muted)] motion-reduce:animate-none"}),t.jsx("div",{className:"h-12 animate-pulse rounded-lg bg-[var(--theme-muted)] motion-reduce:animate-none"})]}):s.length===0?t.jsx("p",{className:"px-4 py-5 text-center text-sm text-[var(--theme-fg-muted)]",children:"No goals in this thread yet."}):t.jsx("div",{className:"max-h-72 divide-y divide-[var(--theme-border)] overflow-y-auto",children:s.map(i=>{const d=Ur(i)===l&&["active","paused","budgetLimited"].includes(i.status);return t.jsxs("div",{className:"px-3 py-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx("p",{className:"min-w-0 flex-1 text-sm font-medium leading-5 text-[var(--theme-fg)]",children:i.objective}),t.jsx("span",{className:"shrink-0 rounded-full border border-[var(--theme-border)] px-2 py-1 text-[10px] font-medium text-[var(--theme-fg-muted)]",children:Nm(i.status)})]}),t.jsxs("p",{className:"mt-1.5 text-[11px] text-[var(--theme-fg-muted)]",children:[jm(i.timeUsedSeconds)," · ",i.tokensUsed.toLocaleString()," tokens"]}),d&&o?t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsx("button",{type:"button",disabled:n||i.status==="active",onClick:()=>void o({status:"active"}),className:"min-h-9 rounded-lg border border-[var(--theme-border)] px-3 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:opacity-45",children:"Continue"}),t.jsx("button",{type:"button",disabled:n||i.status==="paused",onClick:()=>void o({status:"paused"}),className:"min-h-9 rounded-lg border border-[var(--theme-border)] px-3 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:opacity-45",children:"Pause"}),t.jsx("button",{type:"button",disabled:n,onClick:()=>void o({status:"terminated"}),className:"min-h-9 rounded-lg px-3 text-xs font-medium text-[var(--status-danger-fg)] transition hover:bg-[var(--status-danger-bg)] disabled:cursor-not-allowed disabled:opacity-45",children:"Terminate"})]}):null]},Ur(i))})})]})}function Sm({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:v,onPrepareRawMcpBlock:x,onSaveHttpMcp:j,onSaveRawMcpBlock:w}){var y,k;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"MCP config source"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:a??"<provider config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),f("add"),p()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add MCP"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading MCP servers..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,o?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:o}):null,s?t.jsx("p",{className:"mb-2 rounded-xl border border-emerald-500/35 bg-emerald-500/10 px-3 py-3 text-sm text-emerald-100/90",children:s}):null,e==="add"?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:S=>{S.stopPropagation(),f("http"),p()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"HTTP / Streamable HTTP"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"Form"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Add an MCP server with a name and URL, then write the matching block into provider config."})]}),t.jsxs("button",{type:"button",onClick:S=>{S.stopPropagation(),x()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"stdio / raw block"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"TOML"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Write a single `[mcp_servers.name]` block, then save it back into provider config."})]})]}):null,e==="http"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"MCP name"}),t.jsx("input",{"aria-label":"MCP name",value:i,onChange:S=>g(S.target.value),placeholder:"openaiDeveloperDocs",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"URL"}),t.jsx("input",{"aria-label":"URL",value:d,onChange:S=>b(S.target.value),placeholder:"https://developers.openai.com/mcp",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void j(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write HTTP MCP"})]})]}):null,e==="stdio"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsx("label",{className:"block text-xs text-stone-400",children:"MCP block for provider config"}),t.jsx("textarea",{"aria-label":"MCP block for provider config",value:h,onChange:S=>v(S.target.value),rows:8,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void w(),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"&&((y=r.data)!=null&&y.servers.length)?t.jsx("div",{className:"space-y-2",children:r.data.servers.map(S=>t.jsxs("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:S.name}),t.jsxs("p",{className:"mt-0.5 text-xs text-stone-400",children:[S.tools.length," tools · ",S.resourceCount," ","resources · ",S.resourceTemplateCount," templates"]})]}),t.jsx("span",{className:"shrink-0 rounded-full border border-stone-700 px-2 py-1 text-[10px] uppercase tracking-[0.14em] text-stone-300",children:Fu(S.authStatus)})]}),S.tools.length>0?t.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-stone-500",children:S.tools.slice(0,4).map(N=>N.title??N.name).join(" · ")}):null]},S.name))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((k=r.data)==null?void 0:k.servers.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No MCP servers available right now."}):null]})}function Tm({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:Hu(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(Un,{}),"$",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 Em({open:e,slashPanelView:r,availableToolboxItems:n,busy:a,forkBusy:o,forkTurnOptionsState:s,skillsState:l,goalState:i,goalHistory:d,goalBusy:h,copiedSkillName:u,hooksPanelMode:m,hooksState:f,hostConfigFilesAvailable:p,hookTrustAvailable:g,hookConfigBusy:b,hookConfigError:v,hookConfigSuccess:x,editingHookTarget:j,hookScope:w,hookEventName:y,hookMatcher:k,hookCommand:S,hookTimeoutSec:N,hookStatusMessage:L,mcpPanelMode:R,mcpState:P,mcpConfigEditing:J,mcpConfigPath:D,mcpConfigError:Y,mcpConfigSuccess:Z,mcpConfigBusy:I,mcpHttpName:re,mcpHttpUrl:oe,mcpRawBlock:$,iconButtonClassName:Q,menuClassName:_,menuItemClassName:ee,panelButtonClassName:W,chipButtonClassName:T,onToggle:K,onToolboxItemClick:G,toolboxItemDisabled:E,toolboxItemClassName:C,toolboxItemStatus:U,onSetSlashPanelView:H,onViewGoals:se,onUpdateGoal:q,onOpenForkTurns:de,onForkLatest:te,onForkTurn:be,onCopySkillInvokeName:ie,onResetHookForm:ye,onSetHooksPanelMode:Ae,onClearHookConfigStatus:ce,onSetEditingHookTarget:Ce,onSetHookScope:Le,onSetHookEventName:X,onSetHookMatcher:ue,onSetHookCommand:ve,onSetHookTimeoutSec:ke,onSetHookStatusMessage:_e,onSaveHook:He,onStartEditingHook:$e,onTrustHook:Ie,onUntrustHook:F,onSetMcpPanelMode:le,onClearMcpConfigStatus:we,onSetMcpHttpName:z,onSetMcpHttpUrl:O,onSetMcpRawBlock:ne,onPrepareRawMcpBlock:ge,onSaveHttpMcp:Te,onSaveRawMcpBlock:Ee}){return t.jsxs("div",{className:"relative",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Open slash toolbox",title:"Open slash toolbox",onClick:K,className:`${Q} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx(Du,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${_} absolute bottom-full left-0 z-40 mb-2 w-72 overflow-hidden rounded-2xl border bg-stone-900/72 shadow-2xl shadow-stone-950/20 backdrop-blur-xl`,onClick:fe=>{fe.stopPropagation()},onMouseDown:fe=>{fe.stopPropagation()},onPointerDown:fe=>{fe.stopPropagation()},onTouchStart:fe=>{fe.stopPropagation()},children:r==="root"?t.jsxs("div",{className:"p-2",children:[n.map((fe,De)=>fe.action==="goal"?t.jsxs("div",{className:`mt-1 flex min-h-11 overflow-hidden rounded-xl border border-[var(--theme-border)] ${De===0?"mt-0":""}`,title:fe.description??fe.label,children:[t.jsx("button",{type:"button",disabled:E(fe),onClick:()=>{H("goals"),se==null||se()},className:"min-w-0 flex-1 px-3 py-2.5 text-left text-sm text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--theme-accent-border)] disabled:cursor-not-allowed disabled:opacity-45","aria-label":"View goals",children:t.jsx("span",{children:fe.command})}),t.jsx("button",{type:"button",disabled:E(fe),onClick:Be=>G(fe,Be),className:"min-w-14 border-l border-[var(--theme-border)] px-3 text-xs font-semibold text-[var(--theme-fg-muted)] transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)] focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--theme-accent-border)] disabled:cursor-not-allowed disabled:opacity-45","aria-label":"Open goal composer",children:"Open"})]},`${fe.action}:${fe.command}`):t.jsx("button",{type:"button",disabled:E(fe),onClick:Be=>G(fe,Be),className:`${C(fe)} ${De===0?"mt-0":""}`,title:fe.description??fe.label,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:fe.command}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:U(fe)})]})},`${fe.action}:${fe.command}`)),n.length===0?t.jsx("p",{className:"px-3 py-2 text-sm text-stone-400",children:"No backend tools are available for this thread."}):null]}):t.jsx("div",{className:"max-h-80 overflow-auto",children:r==="goals"?t.jsx(Cm,{goalState:i,goalHistory:d,busy:h,onBack:()=>H("root"),onUpdateGoal:q}):r==="fork"?t.jsx(vm,{busy:a,forkBusy:o,composerMenuItemClassName:ee,onForkLatest:te,onSelectForkTurnPanel:()=>(H("forkTurns"),de())}):r==="forkTurns"?t.jsx(km,{forkTurnOptionsState:s,forkBusy:o,composerPanelButtonClassName:W,onForkTurn:be}):r==="skills"?t.jsx(Tm,{skillsState:l,copiedSkillName:u,composerChipButtonClassName:T,onCopySkillInvokeName:ie}):r==="hooks"?t.jsx(wm,{hooksPanelMode:m,hooksState:f,hostConfigFilesAvailable:p,hookTrustAvailable:g,hookConfigBusy:b,hookConfigError:v,hookConfigSuccess:x,editingHookTarget:j,hookScope:w,hookEventName:y,hookMatcher:k,hookCommand:S,hookTimeoutSec:N,hookStatusMessage:L,composerChipButtonClassName:T,onResetHookForm:ye,onSetHooksPanelMode:Ae,onClearHookConfigStatus:ce,onSetEditingHookTarget:Ce,onSetHookScope:Le,onSetHookEventName:X,onSetHookMatcher:ue,onSetHookCommand:ve,onSetHookTimeoutSec:ke,onSetHookStatusMessage:_e,onSaveHook:He,onStartEditingHook:$e,onTrustHook:Ie,onUntrustHook:F}):t.jsx(Sm,{mcpPanelMode:R,mcpState:P,mcpConfigEditing:J,mcpConfigPath:D,mcpConfigError:Y,mcpConfigSuccess:Z,mcpConfigBusy:I,mcpHttpName:re,mcpHttpUrl:oe,mcpRawBlock:$,composerPanelButtonClassName:W,composerChipButtonClassName:T,onSetMcpPanelMode:le,onClearMcpConfigStatus:we,onSetMcpHttpName:z,onSetMcpHttpUrl:O,onSetMcpRawBlock:ne,onPrepareRawMcpBlock:ge,onSaveHttpMcp:Te,onSaveRawMcpBlock:Ee})})})]})}function Lm({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(im,{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(Em,{...i}):null,!e&&d?t.jsx(gm,{...d}):null,r&&t.jsx(jt,{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(Bu,{}):t.jsx($u,{})})]}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-end gap-1.5",children:[!e&&h?t.jsx(xm,{...h}):null,e&&a?t.jsx(cm,{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(Gu,{})}),o==="shellTools"&&u?t.jsx(bm,{...u}):null]})]})]})}function Im(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`attachment-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function zm(e){return[...e.filter(r=>On(r)==="photo"),...e.filter(r=>On(r)==="file")]}function Pm({prompt:e,attachments:r,updateDraft:n,getSelection:a,selectionSnapshotRef:o,pendingSelectionRef:s,pendingInsertedAttachmentIdsRef:l,onInserted:i,buildClientId:d=Im}){const h=c.useCallback((f,p)=>{if(f.length===0)return!1;const g=vu({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(zm(f),On),[h]);return{appendAttachments:u,appendDroppedAttachments:m}}function cs(e){for(const r of e.values())URL.revokeObjectURL(r);e.clear()}function Rm({attachments:e,isShellView:r}){const n=c.useRef(new Map),[a,o]=c.useState({});return c.useEffect(()=>{const s=n.current;if(r){cs(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()=>{cs(s)}},[]),a}var Mm=180;function Cn(e,r){return{prompt:e??"",attachments:r??[]}}function Am({isShellView:e,draftPrompt:r,draftAttachments:n,onDraftChange:a}){const[o,s]=c.useState({prompt:"",attachments:[]}),[l,i]=c.useState(()=>Cn(r,n)),d=c.useRef(null),h=c.useRef(l),u=c.useRef(Mr(l)),m=!e&&r!==void 0&&n!==void 0&&typeof a=="function",f=m?Mr(Cn(r,n)):"",p=c.useRef(f);c.useLayoutEffect(()=>{if(!m){p.current="";return}const w=Cn(r,n),y=Mr(w);y!==p.current&&(p.current=y,u.current=y,h.current=w,d.current!==null&&(window.clearTimeout(d.current),d.current=null),i(w))},[n,r,m]);const g=c.useCallback(w=>{if(!m||!a)return;const y=Mr(w);y!==u.current&&(u.current=y,a(()=>({prompt:w.prompt,attachments:w.attachments})))},[m,a]);c.useEffect(()=>()=>{g(h.current),d.current!==null&&window.clearTimeout(d.current)},[g]);const b=c.useCallback((w,y)=>{if(m){if(d.current!==null&&(window.clearTimeout(d.current),d.current=null),y==="immediate"){g(w);return}d.current=window.setTimeout(()=>{d.current=null,g(h.current)},Mm)}},[m,g]),v=c.useCallback((w=h.current)=>{b(w,"immediate")},[b]),x=c.useCallback((w,y="immediate")=>{if(m){const k=w(h.current);h.current=k,i(k),b(k,y);return}s(k=>w(k))},[m,b]),j=m?l:o;return{prompt:j.prompt,attachments:j.attachments,isDraftControlled:m,updateDraft:x,flushControlledDraftToHost:v}}function $m({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 _m({prompt:e,goalTokenBudgetSource:r,promptRef:n,onOpenGoal:a,onPrepareGoalSubmit:o,onUpdateGoal:s,updateDraft:l,closeMenu:i,resetSlashPanel:d}){const[h,u]=c.useState(!1),[m,f]=c.useState(""),[p,g]=c.useState(!1),[b,v]=c.useState(null),x=c.useCallback(async()=>{const y=e.trim();if(!y)return v("Goal objective cannot be empty."),!1;const k=m.trim(),S=Cu(k);if(k.length>0&&(S===null||!Number.isInteger(S)||S<=0))return v("Token budget must be a positive number in thousands."),!1;if(!s)return v("/goal is unavailable in this view."),!1;g(!0),v(null);try{return o&&await o({objective:y,tokenBudget:S})===!1?!1:(await s({objective:y,status:"active",tokenBudget:S}),f(""),u(!1),l(()=>({prompt:"",attachments:[]})),!0)}catch(N){return v(N instanceof Error?N.message:"Unable to set goal."),!1}finally{g(!1)}},[m,o,s,e,l]),j=c.useCallback(()=>{i(),d(),u(!0),f(Su(r==null?void 0:r.tokenBudget)),v(null),a==null||a(),requestAnimationFrame(()=>{var y;(y=n.current)==null||y.focus()})},[i,r==null?void 0:r.tokenBudget,a,n,d]),w=c.useCallback(()=>{u(!1),v(null)},[]);return{goalComposeMode:h,goalTokenBudget:m,goalBusy:p,goalLocalError:b,setGoalTokenBudget:f,submitGoal:x,enterGoalComposeMode:j,exitGoalComposeMode:w}}var Sn=`node -e "process.stdin.resume(); process.stdin.on('end', () => console.error('hook ran'))"`;function Dm(e){const r=new Map;for(const n of e??[])r.set(n.eventName,n.command);return r}function Bm({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(Sn),[v,x]=c.useState("30"),[j,w]=c.useState("Running hook"),[y,k]=c.useState(null),[S,N]=c.useState(!1),[L,R]=c.useState(null),[P,J]=c.useState(null),D=c.useMemo(()=>Dm(r),[r]),Y=c.useCallback(ee=>D.get(ee)??D.get("preToolUse")??Sn,[D]),Z=c.useMemo(()=>new Set([Sn,...D.values()]),[D]),I=c.useCallback(()=>{R(null),J(null)},[]);c.useEffect(()=>{e!=="hooks"&&(i("list"),I())},[I,e]),c.useEffect(()=>{const ee=Yr.find(W=>W.value===u);p(W=>{const T=W.trim(),K=new Set(Yr.map(G=>G.matcherHint).filter(Boolean));return T&&!K.has(T)?W:(ee==null?void 0:ee.matcherHint)??""}),b(W=>Z.has(W.trim())?Y(u):W)},[Y,Z,u]);const re=c.useCallback(()=>{k(null),h("project"),m("preToolUse"),p("Bash"),b(Y("preToolUse")),x("30"),w("Running hook")},[Y]),oe=c.useCallback(ee=>{const W=ol(ee);if(!W){R("Only command hooks in global or project hooks.json can be edited here.");return}k(W),h(W.scope),m(W.eventName),p(W.matcher??""),b(W.command),x(W.timeoutSec?String(W.timeoutSec):""),w(W.statusMessage??""),R(null),J(null),i("edit")},[]),$=c.useCallback(async()=>{if(l==="edit"&&!a){R("Hook editing is unavailable in this view.");return}if(l!=="edit"&&!n){R("Hook editing is unavailable in this view.");return}if(l==="edit"&&!y){R("Select a hook to edit first.");return}const ee=g.trim();if(!ee){R("Hook command cannot be empty.");return}const W=v.trim(),T=W?Number(W):null;if(W&&(T===null||!Number.isInteger(T)||T<=0)){R("Timeout must be a positive number of seconds.");return}N(!0),R(null),J(null);try{const K={scope:d,eventName:u,matcher:f.trim()||null,command:ee,timeoutSec:T,statusMessage:j.trim()||null};l==="edit"?await(a==null?void 0:a({...K,target:y})):await(n==null?void 0:n(K)),J(`${d==="project"?"Project":"Global"} hook ${l==="edit"?"updated":"written"} in hooks.json and trusted.`),i("list"),k(null)}catch(K){R(K instanceof Error?K.message:"Unable to write hooks.json.")}finally{N(!1)}},[y,g,u,f,d,j,v,l,n,a]),Q=c.useCallback(async ee=>{if(!o||!ee.currentHash){R("Hook trust is unavailable in this view.");return}N(!0),R(null),J(null);try{await o({key:ee.key,currentHash:ee.currentHash}),J("Hook trusted.")}catch(W){R(W instanceof Error?W.message:"Unable to trust hook.")}finally{N(!1)}},[o]),_=c.useCallback(async ee=>{if(!s){R("Hook trust is unavailable in this view.");return}N(!0),R(null),J(null);try{await s({key:ee.key}),J("Hook untrusted.")}catch(W){R(W instanceof Error?W.message:"Unable to untrust hook.")}finally{N(!1)}},[s]);return{hooksPanelMode:l,hookScope:d,hookEventName:u,hookMatcher:f,hookCommand:g,hookTimeoutSec:v,hookStatusMessage:j,editingHookTarget:y,hookConfigBusy:S,hookConfigError:L,hookConfigSuccess:P,setHooksPanelMode:i,setEditingHookTarget:k,setHookScope:h,setHookEventName:m,setHookMatcher:p,setHookCommand:b,setHookTimeoutSec:x,setHookStatusMessage:w,clearHookConfigStatus:I,resetHookForm:re,startEditingHook:oe,saveHook:$,trustHook:Q,untrustHook:_}}var Gm=`[mcp_servers.example_stdio]
|
|
3653
|
+
${o}`:o}function nl(e){return typeof e!="number"||Number.isNaN(e)?0:Math.max(0,Math.min(100,Math.round(e)))}function jn(e){const r=e/1e3;return Number.isInteger(r)?`${r}k`:`${Number(r.toFixed(1))}k`}function Lu(e,r){if(!e)return"Select model";if((r==null?void 0:r.availability)!=="available"||typeof r.tokensInContextWindow!="number"||typeof r.modelContextWindow!="number")return`${e} · context unavailable`;const n=Math.max(r.tokensInContextWindow,0),a=Math.max(r.modelContextWindow,0),o=Math.max(a-n,0);return[e,`${jn(n)} used / ${jn(a)}`,`${jn(o)} left`,`${nl(r.remainingPercent)}% context left`].join(" · ")}function Iu(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 zu(e){return e.replace(/[\r\n[\]]+/g," ").replace(/\s+/g," ").trim()||"attachment"}function Hn(e){return e.type.startsWith("image/")?"photo":"file"}function On(e,r){const n=[];if(e)for(const a of Array.from(e)){if(a.kind!=="file")continue;const o=a.getAsFile();o&&n.push(o)}return n.length>0?n:r?Array.from(r):[]}function ns(e,r){return On(e,r).length>0}function Pu(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function as(e){const r=e.placeholder.match(/^\[(?:PHOTO|FILE)\s+(.+)\]$/);return r!=null&&r[1]?r[1]:Pu(e.originalName)}var Xr=[{value:"preToolUse",label:"PreToolUse",matcherHint:"Bash"},{value:"permissionRequest",label:"PermissionRequest",matcherHint:"Bash"},{value:"postToolUse",label:"PostToolUse",matcherHint:"Bash"},{value:"sessionStart",label:"SessionStart",matcherHint:"startup|resume"},{value:"userPromptSubmit",label:"UserPromptSubmit",matcherHint:""},{value:"stop",label:"Stop",matcherHint:""},{value:"preCompact",label:"PreCompact",matcherHint:""},{value:"postCompact",label:"PostCompact",matcherHint:""}];function Ru({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 Mu({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 Au(){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 _u(){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 $u(){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 Du(){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 Bu(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",className:"h-3.5 w-3.5 fill-current",children:[t.jsx("path",{fillRule:"evenodd",d:"M14.5 10C16.9853 10 19 7.98528 19 5.5C19 5.01783 18.9242 4.55338 18.7838 4.11791C18.6792 3.79367 18.2734 3.72683 18.0325 3.96772L15.3402 6.66002C15.2098 6.79041 15.0168 6.84163 14.8466 6.77074C14.1172 6.46695 13.5334 5.88351 13.2292 5.15431C13.1582 4.98403 13.2094 4.79088 13.3398 4.66042L16.0327 1.9676C16.2735 1.72672 16.2067 1.32092 15.8825 1.21636C15.4469 1.07588 14.9823 1 14.5 1C12.0147 1 10 3.01472 10 5.5C10 5.59783 10.0031 5.69494 10.0093 5.79122C10.065 6.66418 9.88174 7.59855 9.20974 8.15855L1.98017 14.1832C1.3591 14.7008 1 15.4674 1 16.2759C1 17.7804 2.21962 19 3.7241 19C4.53256 19 5.29925 18.6409 5.81681 18.0198L11.8414 10.7903C12.4014 10.1183 13.3358 9.93497 14.2088 9.99073C14.3051 9.99688 14.4022 10 14.5 10ZM5 16C5 16.5523 4.55228 17 4 17C3.44772 17 3 16.5523 3 16C3 15.4477 3.44772 15 4 15C4.55228 15 5 15.4477 5 16Z",clipRule:"evenodd"}),t.jsx("path",{d:"M14.5 11.5C14.6731 11.5 14.8445 11.4927 15.0138 11.4783L18.7678 15.2323C19.7441 16.2086 19.7441 17.7915 18.7678 18.7678C17.7915 19.7441 16.2086 19.7441 15.2323 18.7678L10.8216 14.3571L12.9938 11.7505C13.0455 11.6885 13.1413 11.6131 13.3357 11.5552C13.5378 11.4951 13.805 11.468 14.1132 11.4877C14.2413 11.4959 14.3702 11.5 14.5 11.5Z"}),t.jsx("path",{d:"M6.00003 4.58582L8.33056 6.91635C8.3027 6.95627 8.27496 6.98497 8.24946 7.00622L6.79994 8.21415L4.58582 6.00003H3.30905C3.11966 6.00003 2.94653 5.89303 2.86184 5.72364L1.1612 2.32237C1.06495 2.12987 1.10268 1.89739 1.25486 1.74521L1.74521 1.25486C1.89739 1.10268 2.12987 1.06495 2.32237 1.1612L5.72364 2.86184C5.89303 2.94653 6.00003 3.11966 6.00003 3.30905V4.58582Z"})]})}function Wn(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5.5 3.25h5"}),t.jsx("path",{d:"M6.4 2h3.2a.9.9 0 0 1 .9.9v.35h1.3a1.2 1.2 0 0 1 1.2 1.2v7.35a1.2 1.2 0 0 1-1.2 1.2H4.2A1.2 1.2 0 0 1 3 11.8V4.45a1.2 1.2 0 0 1 1.2-1.2h1.3V2.9a.9.9 0 0 1 .9-.9Z"})]})}function Gu(e){switch(e){case"bearerToken":return"Token";case"oAuth":return"OAuth";case"notLoggedIn":return"Login";case"unsupported":return"Public";default:return"Unknown"}}function Fu(e){switch(e){case"repo":return"Repo";case"system":return"System";case"admin":return"Admin";case"user":default:return"User"}}function Hu(e){var r;return((r=Xr.find(n=>n.value===e))==null?void 0:r.label)??e}function Ou(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 Wu(e){switch(e){case"managed":return"Managed";case"modified":return"Modified";case"trusted":return"Trusted";case"untrusted":return"Review"}}function Uu(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 Vu(e){return e.source==="user"?"global":e.source==="project"?"project":null}function al(e){const r=Vu(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 Ku(e){switch(e){case"active":return"Active";case"paused":return"Paused";case"budgetLimited":return"Budget";case"complete":return"Complete";default:return e}}function qu({contextUsage:e}){const r=(e==null?void 0:e.availability)??"unavailable",n=nl(e==null?void 0:e.remainingPercent);if(r!=="available")return null;const a=n<=20?"rgba(251,113,133,0.90)":n<=40?"rgba(252,211,77,0.85)":"rgba(125,211,252,0.80)";return t.jsx("span",{"aria-hidden":"true",className:"thread-context-progress-track pointer-events-none mt-0.5 block",children:t.jsx("span",{className:"thread-context-progress-fill block",style:{width:`${n}%`,backgroundColor:a}})})}function Bt({label:e,tone:r="stone"}){const n=r==="rose"?"border-rose-300/35 bg-rose-300/14 text-rose-50":r==="sky"?"border-sky-300/35 bg-sky-300/14 text-sky-50":"border-stone-700/90 bg-stone-900/80 text-stone-100";return t.jsx("span",{className:`inline-flex min-w-[3rem] items-center justify-center rounded-full border px-2 py-1.5 text-[10px] font-medium tracking-[0.12em] ${n}`,children:e})}function Xu(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 Yu(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 Zu(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?Ku(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 Ju(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 Qu(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 em(e){if(!e)return"";const r=document.createElement("div");return r.innerHTML=e,r.textContent??""}function tm(e){return!!e.querySelector("[style], font")}function Ft(e){return e instanceof HTMLElement&&e.dataset.segmentType==="attachment"&&e.dataset.placeholder?e.dataset.placeholder:e.textContent??""}function sl(e){let r="";for(const n of Array.from(e.childNodes))r+=Ft(n);return r.replace(/\u00a0/g," ")}function ss(e,r,n){var i;let a=null,o=n;if(r===e){const d=Array.from(e.childNodes);let h=0;for(let u=0;u<Math.min(n,d.length);u+=1){const m=d[u];m&&(h+=Ft(m).length)}return h}if(r.nodeType===Node.TEXT_NODE)a=r;else{const d=Array.from(e.childNodes).find(h=>h.contains(r));if(!d)return sl(e).length;if(a=d,d instanceof HTMLElement&&d.dataset.segmentType==="attachment"){const h=document.createRange();h.selectNodeContents(d);const u=Ft(d).length;try{h.setEnd(r,n);const m=h.toString().length,f=((i=d.textContent)==null?void 0:i.length)??0;f===0?o=u:o=Math.round(Math.min(1,m/f)*u)}catch{o=u}}else{const h=document.createRange();h.selectNodeContents(d);try{h.setEnd(r,n),o=h.toString().length}catch{o=Ft(d).length}}}const s=Array.from(e.childNodes);let l=0;for(const d of s){if(d===a)return d.nodeType===Node.TEXT_NODE?l+o:l+Math.min(o,Ft(d).length);l+=Ft(d).length}return l}function rm(e){const r=window.getSelection();if(!r||r.rangeCount===0)return null;const n=r.getRangeAt(0);return!e.contains(n.startContainer)||!e.contains(n.endContainer)?null:{start:ss(e,n.startContainer,n.startOffset),end:ss(e,n.endContainer,n.endOffset)}}function os(e,r){let n=Math.max(0,r);const a=Array.from(e.childNodes);for(const[o,s]of a.entries()){const i=Ft(s).length;if(s.nodeType===Node.TEXT_NODE){if(n<=i)return{node:s,offset:n};n-=i;continue}if(s instanceof HTMLElement&&s.dataset.segmentType==="attachment"){if(n===0)return{node:e,offset:o};if(n<=i){const d=a[o+1];return n===i&&(d==null?void 0:d.nodeType)===Node.TEXT_NODE?{node:d,offset:0}:{node:e,offset:o+1}}n-=i;continue}if(n<=i)return{node:e,offset:o+1};n-=i}return{node:e,offset:e.childNodes.length}}function nm(e,r){const n=os(e,r.start),a=os(e,r.end),o=document.createRange();o.setStart(n.node,n.offset),o.setEnd(a.node,a.offset);const s=window.getSelection();s==null||s.removeAllRanges(),s==null||s.addRange(o)}function am(e,r){if(r.length===0)return!1;const n=r.at(-1);if(!n)return!1;const a=Array.from(e.childNodes).find(i=>i instanceof HTMLElement&&i.dataset.segmentType==="attachment"&&i.dataset.clientId===n);if(!(a instanceof HTMLElement))return!1;const o=document.createRange(),s=a.nextSibling;(s==null?void 0:s.nodeType)===Node.TEXT_NODE?o.setStart(s,0):o.setStartAfter(a),o.collapse(!0);const l=window.getSelection();return l==null||l.removeAllRanges(),l==null||l.addRange(o),!0}rn();Pt();function sm({className:e,...r}){return t.jsx("div",{"data-slot":"input-group",role:"group",className:rt("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 om=Cr("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*=size-])]:size-4",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.45rem]","block-start":"order-first w-full justify-start px-3 pt-3","block-end":"order-last w-full justify-start px-3 pb-3"}},defaultVariants:{align:"inline-start"}});function lm({className:e,align:r="inline-start",...n}){return t.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":r,className:rt(om({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 im=Cr("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*=size-])]:size-3.5",sm:"h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function jt({className:e,type:r="button",variant:n="ghost",size:a="xs",...o}){return t.jsx(Nr,{type:r,"data-size":a,variant:n,className:rt(im({size:a}),e),...o})}function dm({className:e,...r}){return t.jsx("span",{className:rt("flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*=size-])]:size-4",e),...r})}function cm({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 hm(e){if(!e)return"reset time unavailable";const r=new Date(e);return Number.isNaN(r.getTime())?"reset time unavailable":`resets ${r.toLocaleString()}`}function um({usage:e}){if(!e||e.authKind!=="subscription"||e.windows.length===0)return null;const r=e.windows.slice(0,2),n=r.map(a=>{const o=Math.max(0,100-a.usedPercent);return`${a.label}: ${o}% remaining, ${hm(a.resetsAt)}`}).join(". ");return t.jsx("button",{type:"button",className:"thread-subscription-usage pointer-events-auto absolute bottom-1 right-2 inline-flex h-4 items-center gap-1 rounded-[0.55rem] border border-stone-500/50 bg-stone-950/20 px-1 text-[8px] font-normal leading-none text-stone-200/90 opacity-80 shadow-sm transition hover:border-sky-300/45 hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-sky-200/70 sm:right-3","aria-label":`${e.provider} subscription usage. ${n}`,title:`${n}${e.stale?". Last known values.":""}`,children:r.map(a=>{const o=Math.max(0,Math.min(100,100-a.usedPercent)),s=o<=10?"bg-rose-400":o<=25?"bg-amber-300":"bg-sky-300";return t.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[t.jsx("span",{children:a.label}),t.jsx("span",{className:"h-0.5 w-3.5 overflow-hidden rounded-full bg-stone-600/60",children:t.jsx("span",{className:`block h-full rounded-full ${s}`,style:{width:`${o}%`}})}),t.jsxs("span",{className:"tabular-nums",children:[Math.round(o),"%"]})]},a.id)})})}function mm({activeView:e,followTail:r,onToggleFollow:n,canJumpToPreviousTurn:a,onJumpToPreviousTurn:o,canJumpToNextTurn:s,onJumpToNextTurn:l,subscriptionUsage:i}){return e!=="chat"?null:t.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-[90] h-11 -translate-y-full bg-transparent touch-manipulation sm:h-10",children:[t.jsxs("span",{role:"group","aria-label":"Timeline navigation",className:`thread-jump-latest-badge pointer-events-auto absolute bottom-1 left-1/2 inline-flex h-5 min-w-[7.5rem] -translate-x-1/2 overflow-hidden rounded-[0.7rem] border shadow-sm transition ${r?"is-active border-sky-300/36 bg-sky-300/[0.03] text-sky-100/86":"border-stone-500/70 bg-stone-950/[0.08] text-stone-200/86"}`,children:[t.jsx("button",{type:"button","aria-label":"Jump to previous turn",title:a?"Jump to the start of the previous turn":"No earlier turn",disabled:!a,onClick:()=>o==null?void 0:o(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70 disabled:cursor-default disabled:opacity-35",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3.5 12h9M8 10V5M6 7l2-2 2 2"})})}),t.jsx("span",{"aria-hidden":"true",className:"w-px bg-current opacity-20"}),t.jsx("button",{type:"button","aria-label":"Jump to latest",title:r?"Latest messages are in view":"Jump to the bottom",onClick:()=>n==null?void 0:n(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m4 5.5 4 4 4-4M3.5 12.5h9"})})}),t.jsx("span",{"aria-hidden":"true",className:"w-px bg-current opacity-20"}),t.jsx("button",{type:"button","aria-label":"Jump to next turn",title:s?"Jump to the start of the next turn":"No later turn",disabled:!s,onClick:()=>l==null?void 0:l(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70 disabled:cursor-default disabled:opacity-35",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3.5 4h9M8 6v5m-2-2 2 2 2-2"})})})]}),t.jsx(um,{usage:i})]})}function pm({activeView:e,layerClassName:r,formClassName:n,shellClassName:a,inputGroupClassName:o,error:s,followTail:l,photoInputRef:i,fileInputRef:d,onAppendAttachments:h,onToggleFollow:u,canJumpToPreviousTurn:m,onJumpToPreviousTurn:f,canJumpToNextTurn:p,onJumpToNextTurn:g,subscriptionUsage:b,onSubmit:k,formRef:x,promptSlot:j,toolbarSlot:w,goalSlot:y,shellPromptSlot:v}){return t.jsxs("div",{className:r,children:[t.jsx(cm,{photoInputRef:i,fileInputRef:d,onAppendAttachments:h}),t.jsx(mm,{activeView:e,followTail:l,onToggleFollow:u,canJumpToPreviousTurn:m,onJumpToPreviousTurn:f,canJumpToNextTurn:p,onJumpToNextTurn:g,subscriptionUsage:b}),t.jsxs("form",{ref:x,"data-testid":e==="chat"?"chat-composer":void 0,onSubmit:k,className:n,children:[t.jsxs("div",{className:`${a} flex w-full flex-col overflow-visible rounded-[16px] sm:rounded-[18px]`,children:[t.jsxs(sm,{className:o,children:[j,w]}),y,v]}),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 fm({open:e,iconButtonClassName:r,menuClassName:n,menuItemClassName:a,onToggle:o,onPickPhoto:s,onPickFile:l}){return t.jsxs("div",{className:"relative",children:[t.jsx(jt,{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(_u,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${n} absolute bottom-full left-0 mb-2 w-32 overflow-hidden rounded-2xl border bg-stone-900/72 shadow-2xl shadow-stone-950/20`,children:t.jsxs("div",{className:"p-2",children:[t.jsx("button",{type:"button",onClick:s,className:`${a} block w-full rounded-xl px-3 py-2 text-left text-sm transition`,children:"Photo"}),t.jsx("button",{type:"button",onClick:l,className:`${a} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition`,children:"File"})]})})]})}var ol=[{mode:"read-only",label:"Read only"},{mode:"workspace-write",label:"Workspace write"},{mode:"danger-full-access",label:"Danger"}];function ls(e){var r;return((r=ol.find(n=>n.mode===e))==null?void 0:r.label)??"Default"}function gm({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:k,sendButtonLabel:x,sendButtonClassName:j,modelControlsDisabled:w,effortControlsDisabled:y,effortControlTitle:v,inlineToggleClassName:S,menuItemClassName:N,planToggleActiveClassName:I,sendButtonBaseClassName:M,onSetOpenMenu:R,onUpdateSettings:Q}){return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative min-w-0",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="model","aria-label":r??"Select model",disabled:w||n.length===0,onClick:()=>R($=>$==="model"?null:"model"),title:k?`Fast mode is on. Turn it off from the slash toolbox to edit model. ${a}`:a,className:`${S} relative min-w-0 max-w-[8.75rem] overflow-hidden rounded-full px-2.5 text-left text-stone-300 disabled:cursor-not-allowed disabled:text-stone-600 sm:max-w-[11rem]`,children:t.jsx("span",{className:"relative z-[1] block min-w-0 truncate whitespace-nowrap [direction:rtl]",children:r??"Select model"})}),r?t.jsx(qu,{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($=>t.jsx("button",{type:"button",onClick:()=>Q({model:$.model,reasoningEffort:$.defaultReasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${$.model===r?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:$.model})},$.id))})})]}),t.jsxs("div",{className:"relative",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="effort",disabled:y,onClick:()=>R($=>$==="effort"?null:"effort"),title:v,className:`${S} rounded-full px-2 disabled:cursor-not-allowed disabled:text-stone-700 ${y?"text-stone-500":"text-stone-300 hover:text-stone-100"}`,children:ts(s)}),e==="effort"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[8rem] max-w-[12rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:l.map($=>t.jsx("button",{type:"button",onClick:()=>Q({reasoningEffort:$.reasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${$.reasoningEffort===s?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:ts($.reasoningEffort)})},$.reasoningEffort))})})]}),u&&t.jsxs("div",{className:"relative",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="sandbox","aria-label":`Sandbox: ${ls(d)}`,disabled:m,onClick:()=>R($=>$==="sandbox"?null:"sandbox"),title:`Sandbox: ${ls(d)}`,className:`${S} rounded-full px-2.5 text-stone-300 disabled:cursor-not-allowed disabled:text-stone-700`,children:"Sandbox"}),e==="sandbox"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[9rem] max-w-[13rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:ol.map($=>t.jsx("button",{type:"button",onClick:()=>Q({sandboxMode:$.mode}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${$.mode===d?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:$.label})},$.mode))})})]}),h&&t.jsx(jt,{type:"button",variant:"ghost",size:"xs","aria-pressed":i==="plan",disabled:m,onClick:()=>Q({collaborationMode:i==="plan"?"default":"plan"}),className:`${S} rounded-full px-2.5 ${i==="plan"?`${I} 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(jt,{type:"submit",variant:"default",size:"icon-xs","aria-label":f?"Set goal":"Send Prompt",title:x,disabled:p||(g==="chat"?b:!1),className:`${M} h-9 w-9 rounded-full text-sm font-medium disabled:cursor-not-allowed sm:h-8 sm:w-8 ${j}`,children:t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-none stroke-current",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M8 13V3"}),t.jsx("path",{d:"m4 7 4-4 4 4"})]})})]})}function xm({busy:e,shellControlState:r,onPaste:n,onCopy:a,onClear:o,onShellControl:s}){const l=!!(r!=null&&r.shellInputEnabled),i=!!(r!=null&&r.isCommandRunning);return t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute right-0 top-full z-40 mt-2 w-[11.5rem] max-w-[calc(100vw-1.5rem)] rounded-[1rem] border border-stone-700/90 bg-stone-950/96 p-2 shadow-2xl shadow-stone-950/40 sm:w-48",onMouseDown:d=>{d.stopPropagation()},onPointerDown:d=>{d.stopPropagation()},onTouchStart:d=>{d.stopPropagation()},children:t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx("button",{type:"button",onClick:n,className:"inline-flex items-center justify-center rounded-full border border-sky-300/35 bg-sky-300/12 px-2 py-2 text-sky-50",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Wn,{}),t.jsx("span",{className:"text-[10px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:a,className:"inline-flex items-center justify-center rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-2 text-stone-100",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Wn,{}),t.jsx("span",{className:"text-[10px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:e,onClick:o,className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!l||!i,onClick:()=>s("ctrl_c"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CTRL-C",tone:"rose"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("ctrl_d"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CTRL-D"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("esc"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"ESC"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("tab"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"TAB"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("up"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"UP"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("down"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"DOWN"})})]})})}function bm({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 vm({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 km({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:k,onClearHookConfigStatus:x,onSetEditingHookTarget:j,onSetHookScope:w,onSetHookEventName:y,onSetHookMatcher:v,onSetHookCommand:S,onSetHookTimeoutSec:N,onSetHookStatusMessage:I,onSaveHook:M,onStartEditingHook:R,onTrustHook:Q,onUntrustHook:$}){var Y,Z,P,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:((Y=r.data)==null?void 0:Y.projectHooksPath)??"<workspace hooks config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:T=>{T.stopPropagation(),b(),k("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"," ",Uu((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:T=>w(T.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:T=>y(T.target.value),className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-2.5 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50",children:Xr.map(T=>t.jsx("option",{value:T.value,children:T.label},T.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:T=>v(T.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:T=>S(T.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:T=>N(T.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:T=>I(T.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:()=>{k("list"),j(null)},className:`${g} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void M(),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"&&((Z=r.data)!=null&&Z.warnings.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.warnings.map(T=>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:T},T))}):null,e==="list"&&((P=r.data)!=null&&P.errors.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.errors.map(T=>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:T.message}),t.jsx("p",{className:"mt-1 break-all text-rose-100/60",children:T.path})]},`${T.path}:${T.message}`))}):null,e==="list"&&((te=r.data)!=null&&te.hooks.length)?t.jsx("div",{className:"space-y-2",children:r.data.hooks.map(T=>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:[Hu(T.eventName),T.matcher?` · ${T.matcher}`:""]}),t.jsx("p",{className:"mt-0.5 truncate font-mono text-[11px] text-stone-400",children:T.command??T.handlerType}),T.statusMessage?t.jsx("p",{className:"mt-1 truncate text-[11px] text-stone-500",children:T.statusMessage}):null]}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.08em] text-stone-500",children:[al(T)?t.jsx("button",{type:"button",onClick:re=>{re.stopPropagation(),R(T)},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&&T.trustStatus==="trusted"&&!T.isManaged?t.jsx("button",{type:"button",disabled:o,onClick:re=>{re.stopPropagation(),$(T)},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,(T.trustStatus==="untrusted"||T.trustStatus==="modified")&&!T.isManaged&&a?t.jsx("button",{type:"button",disabled:o||!T.currentHash,onClick:re=>{re.stopPropagation(),Q(T)},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:Wu(T.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:Ou(T.source)}),t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:T.enabled?"Enabled":"Disabled"}),t.jsxs("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:[T.timeoutSec,"s"]})]})]},T.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 Wr(e){return e.localGoalId??`${e.createdAt}:${e.objective}`}function wm(e,r){const n=e?[e,...r]:r,a=new Set;return n.filter(o=>{const s=Wr(o);return a.has(s)?!1:(a.add(s),!0)})}function ym(e){if(e<60)return`${e}s`;const r=Math.floor(e/60);return r<60?`${r}m`:`${Math.floor(r/60)}h ${r%60}m`}function jm(e){switch(e){case"budgetLimited":return"Budget limited";case"complete":return"Complete";case"terminated":return"Terminated";case"paused":return"Paused";default:return"Active"}}function Nm({goalState:e,goalHistory:r,busy:n,onBack:a,onUpdateGoal:o}){const s=wm(e.data,r),l=e.data?Wr(e.data):null;return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-h-11 items-center justify-between gap-3 border-b border-[var(--theme-border)] px-3 py-2",children:[t.jsx("button",{type:"button",onClick:a,className:"min-h-9 rounded-lg px-2 text-xs font-medium text-[var(--theme-fg-muted)] transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--theme-accent-border)]",children:"Back"}),t.jsx("span",{className:"text-xs font-semibold text-[var(--theme-fg)]",children:"Goals"})]}),e.error?t.jsx("p",{className:"m-3 rounded-lg border border-[var(--status-danger-border)] bg-[var(--status-danger-bg)] px-3 py-2 text-xs text-[var(--status-danger-fg)]",children:e.error}):null,e.status==="loading"&&s.length===0?t.jsxs("div",{className:"space-y-2 p-3",role:"status","aria-label":"Loading goals",children:[t.jsx("div",{className:"h-12 animate-pulse rounded-lg bg-[var(--theme-muted)] motion-reduce:animate-none"}),t.jsx("div",{className:"h-12 animate-pulse rounded-lg bg-[var(--theme-muted)] motion-reduce:animate-none"})]}):s.length===0?t.jsx("p",{className:"px-4 py-5 text-center text-sm text-[var(--theme-fg-muted)]",children:"No goals in this thread yet."}):t.jsx("div",{className:"max-h-72 divide-y divide-[var(--theme-border)] overflow-y-auto",children:s.map(i=>{const d=Wr(i)===l&&["active","paused","budgetLimited"].includes(i.status);return t.jsxs("div",{className:"px-3 py-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx("p",{className:"min-w-0 flex-1 text-sm font-medium leading-5 text-[var(--theme-fg)]",children:i.objective}),t.jsx("span",{className:"shrink-0 rounded-full border border-[var(--theme-border)] px-2 py-1 text-[10px] font-medium text-[var(--theme-fg-muted)]",children:jm(i.status)})]}),t.jsxs("p",{className:"mt-1.5 text-[11px] text-[var(--theme-fg-muted)]",children:[ym(i.timeUsedSeconds)," · ",i.tokensUsed.toLocaleString()," tokens"]}),d&&o?t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsx("button",{type:"button",disabled:n||i.status==="active",onClick:()=>void o({status:"active"}),className:"min-h-9 rounded-lg border border-[var(--theme-border)] px-3 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:opacity-45",children:"Continue"}),t.jsx("button",{type:"button",disabled:n||i.status==="paused",onClick:()=>void o({status:"paused"}),className:"min-h-9 rounded-lg border border-[var(--theme-border)] px-3 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:opacity-45",children:"Pause"}),t.jsx("button",{type:"button",disabled:n,onClick:()=>void o({status:"terminated"}),className:"min-h-9 rounded-lg px-3 text-xs font-medium text-[var(--status-danger-fg)] transition hover:bg-[var(--status-danger-bg)] disabled:cursor-not-allowed disabled:opacity-45",children:"Terminate"})]}):null]},Wr(i))})})]})}function Cm({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:k,onPrepareRawMcpBlock:x,onSaveHttpMcp:j,onSaveRawMcpBlock:w}){var y,v;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"MCP config source"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:a??"<provider config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),f("add"),p()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add MCP"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading MCP servers..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,o?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:o}):null,s?t.jsx("p",{className:"mb-2 rounded-xl border border-emerald-500/35 bg-emerald-500/10 px-3 py-3 text-sm text-emerald-100/90",children:s}):null,e==="add"?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:S=>{S.stopPropagation(),f("http"),p()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"HTTP / Streamable HTTP"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"Form"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Add an MCP server with a name and URL, then write the matching block into provider config."})]}),t.jsxs("button",{type:"button",onClick:S=>{S.stopPropagation(),x()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"stdio / raw block"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"TOML"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Write a single `[mcp_servers.name]` block, then save it back into provider config."})]})]}):null,e==="http"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"MCP name"}),t.jsx("input",{"aria-label":"MCP name",value:i,onChange:S=>g(S.target.value),placeholder:"openaiDeveloperDocs",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"URL"}),t.jsx("input",{"aria-label":"URL",value:d,onChange:S=>b(S.target.value),placeholder:"https://developers.openai.com/mcp",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void j(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write HTTP MCP"})]})]}):null,e==="stdio"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsx("label",{className:"block text-xs text-stone-400",children:"MCP block for provider config"}),t.jsx("textarea",{"aria-label":"MCP block for provider config",value:h,onChange:S=>k(S.target.value),rows:8,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void w(),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"&&((y=r.data)!=null&&y.servers.length)?t.jsx("div",{className:"space-y-2",children:r.data.servers.map(S=>t.jsxs("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:S.name}),t.jsxs("p",{className:"mt-0.5 text-xs text-stone-400",children:[S.tools.length," tools · ",S.resourceCount," ","resources · ",S.resourceTemplateCount," templates"]})]}),t.jsx("span",{className:"shrink-0 rounded-full border border-stone-700 px-2 py-1 text-[10px] uppercase tracking-[0.14em] text-stone-300",children:Gu(S.authStatus)})]}),S.tools.length>0?t.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-stone-500",children:S.tools.slice(0,4).map(N=>N.title??N.name).join(" · ")}):null]},S.name))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((v=r.data)==null?void 0:v.servers.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No MCP servers available right now."}):null]})}function Sm({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:Fu(d.scope)}),t.jsxs("button",{type:"button",className:`inline-flex items-center gap-1 rounded-full border px-2 py-1 normal-case tracking-normal transition ${r===d.name?"border-emerald-400/45 bg-emerald-400/12 text-emerald-100":`${n} border-stone-700 text-stone-300 hover:border-stone-500`}`,onClick:()=>void a(d.name),title:`Copy $${d.name}`,"aria-label":`Copy $${d.name}`,children:[t.jsx(Wn,{}),"$",d.name]})]}),t.jsx("p",{className:"text-xs leading-5 text-stone-400",children:((u=d.interface)==null?void 0:u.shortDescription)??d.shortDescription??d.description})]})},d.path)})}):null,(s=e.data)!=null&&s.errors.length?t.jsx("div",{className:"mt-2 space-y-2",children:e.data.errors.map(d=>t.jsxs("div",{className:"rounded-xl border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-100/85",children:[t.jsx("p",{className:"font-medium",children:d.message}),t.jsx("p",{className:"mt-1 break-all text-amber-100/60",children:d.path})]},`${d.path}:${d.message}`))}):null,e.status!=="loading"&&!e.error&&(((l=e.data)==null?void 0:l.skills.length)??0)===0&&(((i=e.data)==null?void 0:i.errors.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No skills available right now."}):null]})}function Tm({open:e,slashPanelView:r,availableToolboxItems:n,busy:a,forkBusy:o,forkTurnOptionsState:s,skillsState:l,goalState:i,goalHistory:d,goalBusy:h,copiedSkillName:u,hooksPanelMode:m,hooksState:f,hostConfigFilesAvailable:p,hookTrustAvailable:g,hookConfigBusy:b,hookConfigError:k,hookConfigSuccess:x,editingHookTarget:j,hookScope:w,hookEventName:y,hookMatcher:v,hookCommand:S,hookTimeoutSec:N,hookStatusMessage:I,mcpPanelMode:M,mcpState:R,mcpConfigEditing:Q,mcpConfigPath:$,mcpConfigError:Y,mcpConfigSuccess:Z,mcpConfigBusy:P,mcpHttpName:te,mcpHttpUrl:oe,mcpRawBlock:T,iconButtonClassName:re,menuClassName:B,menuItemClassName:J,panelButtonClassName:K,chipButtonClassName:L,onToggle:q,onToolboxItemClick:G,toolboxItemDisabled:E,toolboxItemClassName:C,toolboxItemStatus:W,onSetSlashPanelView:H,onViewGoals:se,onUpdateGoal:V,onOpenForkTurns:de,onForkLatest:ee,onForkTurn:be,onCopySkillInvokeName:ie,onResetHookForm:ye,onSetHooksPanelMode:Ae,onClearHookConfigStatus:ce,onSetEditingHookTarget:Ce,onSetHookScope:Le,onSetHookEventName:X,onSetHookMatcher:ue,onSetHookCommand:ve,onSetHookTimeoutSec:ke,onSetHookStatusMessage:$e,onSaveHook:He,onStartEditingHook:_e,onTrustHook:ze,onUntrustHook:F,onSetMcpPanelMode:le,onClearMcpConfigStatus:we,onSetMcpHttpName:z,onSetMcpHttpUrl:O,onSetMcpRawBlock:ne,onPrepareRawMcpBlock:ge,onSaveHttpMcp:Te,onSaveRawMcpBlock:Ee}){return t.jsxs("div",{className:"relative",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Open slash toolbox",title:"Open slash toolbox",onClick:q,className:`${re} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx($u,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${B} absolute bottom-full left-0 z-40 mb-2 w-72 overflow-hidden rounded-2xl border bg-stone-900/72 shadow-2xl shadow-stone-950/20 backdrop-blur-xl`,onClick:fe=>{fe.stopPropagation()},onMouseDown:fe=>{fe.stopPropagation()},onPointerDown:fe=>{fe.stopPropagation()},onTouchStart:fe=>{fe.stopPropagation()},children:r==="root"?t.jsxs("div",{className:"p-2",children:[n.map((fe,De)=>fe.action==="goal"?t.jsxs("div",{className:`mt-1 flex min-h-11 overflow-hidden rounded-xl border border-[var(--theme-border)] ${De===0?"mt-0":""}`,title:fe.description??fe.label,children:[t.jsx("button",{type:"button",disabled:E(fe),onClick:()=>{H("goals"),se==null||se()},className:"min-w-0 flex-1 px-3 py-2.5 text-left text-sm text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--theme-accent-border)] disabled:cursor-not-allowed disabled:opacity-45","aria-label":"View goals",children:t.jsx("span",{children:fe.command})}),t.jsx("button",{type:"button",disabled:E(fe),onClick:Be=>G(fe,Be),className:"min-w-14 border-l border-[var(--theme-border)] px-3 text-xs font-semibold text-[var(--theme-fg-muted)] transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)] focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--theme-accent-border)] disabled:cursor-not-allowed disabled:opacity-45","aria-label":"Open goal composer",children:"Open"})]},`${fe.action}:${fe.command}`):t.jsx("button",{type:"button",disabled:E(fe),onClick:Be=>G(fe,Be),className:`${C(fe)} ${De===0?"mt-0":""}`,title:fe.description??fe.label,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:fe.command}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:W(fe)})]})},`${fe.action}:${fe.command}`)),n.length===0?t.jsx("p",{className:"px-3 py-2 text-sm text-stone-400",children:"No backend tools are available for this thread."}):null]}):t.jsx("div",{className:"max-h-80 overflow-auto",children:r==="goals"?t.jsx(Nm,{goalState:i,goalHistory:d,busy:h,onBack:()=>H("root"),onUpdateGoal:V}):r==="fork"?t.jsx(bm,{busy:a,forkBusy:o,composerMenuItemClassName:J,onForkLatest:ee,onSelectForkTurnPanel:()=>(H("forkTurns"),de())}):r==="forkTurns"?t.jsx(vm,{forkTurnOptionsState:s,forkBusy:o,composerPanelButtonClassName:K,onForkTurn:be}):r==="skills"?t.jsx(Sm,{skillsState:l,copiedSkillName:u,composerChipButtonClassName:L,onCopySkillInvokeName:ie}):r==="hooks"?t.jsx(km,{hooksPanelMode:m,hooksState:f,hostConfigFilesAvailable:p,hookTrustAvailable:g,hookConfigBusy:b,hookConfigError:k,hookConfigSuccess:x,editingHookTarget:j,hookScope:w,hookEventName:y,hookMatcher:v,hookCommand:S,hookTimeoutSec:N,hookStatusMessage:I,composerChipButtonClassName:L,onResetHookForm:ye,onSetHooksPanelMode:Ae,onClearHookConfigStatus:ce,onSetEditingHookTarget:Ce,onSetHookScope:Le,onSetHookEventName:X,onSetHookMatcher:ue,onSetHookCommand:ve,onSetHookTimeoutSec:ke,onSetHookStatusMessage:$e,onSaveHook:He,onStartEditingHook:_e,onTrustHook:ze,onUntrustHook:F}):t.jsx(Cm,{mcpPanelMode:M,mcpState:R,mcpConfigEditing:Q,mcpConfigPath:$,mcpConfigError:Y,mcpConfigSuccess:Z,mcpConfigBusy:P,mcpHttpName:te,mcpHttpUrl:oe,mcpRawBlock:T,composerPanelButtonClassName:K,composerChipButtonClassName:L,onSetMcpPanelMode:le,onClearMcpConfigStatus:we,onSetMcpHttpName:z,onSetMcpHttpUrl:O,onSetMcpRawBlock:ne,onPrepareRawMcpBlock:ge,onSaveHttpMcp:Te,onSaveRawMcpBlock:Ee})})})]})}function Em({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(lm,{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(Tm,{...i}):null,!e&&d?t.jsx(fm,{...d}):null,r&&t.jsx(jt,{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(Du,{}):t.jsx(Au,{})})]}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-end gap-1.5",children:[!e&&h?t.jsx(gm,{...h}):null,e&&a?t.jsx(dm,{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(Bu,{})}),o==="shellTools"&&u?t.jsx(xm,{...u}):null]})]})]})}function Lm(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`attachment-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function Im(e){return[...e.filter(r=>Hn(r)==="photo"),...e.filter(r=>Hn(r)==="file")]}function zm({prompt:e,attachments:r,updateDraft:n,getSelection:a,selectionSnapshotRef:o,pendingSelectionRef:s,pendingInsertedAttachmentIdsRef:l,onInserted:i,buildClientId:d=Lm}){const h=c.useCallback((f,p)=>{if(f.length===0)return!1;const g=bu({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(Im(f),Hn),[h]);return{appendAttachments:u,appendDroppedAttachments:m}}function is(e){for(const r of e.values())URL.revokeObjectURL(r);e.clear()}function Pm({attachments:e,isShellView:r}){const n=c.useRef(new Map),[a,o]=c.useState({});return c.useEffect(()=>{const s=n.current;if(r){is(s),o({});return}const l={},i=new Set;for(const d of e){if(d.kind!=="photo")continue;i.add(d.clientId);let h=s.get(d.clientId);h||(h=URL.createObjectURL(d.file),s.set(d.clientId,h)),l[d.clientId]=h}for(const[d,h]of s.entries())i.has(d)||(URL.revokeObjectURL(h),s.delete(d));o(l)},[e,r]),c.useEffect(()=>{const s=n.current;return()=>{is(s)}},[]),a}var Rm=180;function Nn(e,r){return{prompt:e??"",attachments:r??[]}}function Mm({isShellView:e,draftPrompt:r,draftAttachments:n,onDraftChange:a}){const[o,s]=c.useState({prompt:"",attachments:[]}),[l,i]=c.useState(()=>Nn(r,n)),d=c.useRef(null),h=c.useRef(l),u=c.useRef(Mr(l)),m=!e&&r!==void 0&&n!==void 0&&typeof a=="function",f=m?Mr(Nn(r,n)):"",p=c.useRef(f);c.useLayoutEffect(()=>{if(!m){p.current="";return}const w=Nn(r,n),y=Mr(w);y!==p.current&&(p.current=y,u.current=y,h.current=w,d.current!==null&&(window.clearTimeout(d.current),d.current=null),i(w))},[n,r,m]);const g=c.useCallback(w=>{if(!m||!a)return;const y=Mr(w);y!==u.current&&(u.current=y,a(()=>({prompt:w.prompt,attachments:w.attachments})))},[m,a]);c.useEffect(()=>()=>{g(h.current),d.current!==null&&window.clearTimeout(d.current)},[g]);const b=c.useCallback((w,y)=>{if(m){if(d.current!==null&&(window.clearTimeout(d.current),d.current=null),y==="immediate"){g(w);return}d.current=window.setTimeout(()=>{d.current=null,g(h.current)},Rm)}},[m,g]),k=c.useCallback((w=h.current)=>{b(w,"immediate")},[b]),x=c.useCallback((w,y="immediate")=>{if(m){const v=w(h.current);h.current=v,i(v),b(v,y);return}s(v=>w(v))},[m,b]),j=m?l:o;return{prompt:j.prompt,attachments:j.attachments,isDraftControlled:m,updateDraft:x,flushControlledDraftToHost:k}}function Am({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 _m({prompt:e,goalTokenBudgetSource:r,promptRef:n,onOpenGoal:a,onPrepareGoalSubmit:o,onUpdateGoal:s,updateDraft:l,closeMenu:i,resetSlashPanel:d}){const[h,u]=c.useState(!1),[m,f]=c.useState(""),[p,g]=c.useState(!1),[b,k]=c.useState(null),x=c.useCallback(async()=>{const y=e.trim();if(!y)return k("Goal objective cannot be empty."),!1;const v=m.trim(),S=Nu(v);if(v.length>0&&(S===null||!Number.isInteger(S)||S<=0))return k("Token budget must be a positive number in thousands."),!1;if(!s)return k("/goal is unavailable in this view."),!1;g(!0),k(null);try{return o&&await o({objective:y,tokenBudget:S})===!1?!1:(await s({objective:y,status:"active",tokenBudget:S}),f(""),u(!1),l(()=>({prompt:"",attachments:[]})),!0)}catch(N){return k(N instanceof Error?N.message:"Unable to set goal."),!1}finally{g(!1)}},[m,o,s,e,l]),j=c.useCallback(()=>{i(),d(),u(!0),f(Cu(r==null?void 0:r.tokenBudget)),k(null),a==null||a(),requestAnimationFrame(()=>{var y;(y=n.current)==null||y.focus()})},[i,r==null?void 0:r.tokenBudget,a,n,d]),w=c.useCallback(()=>{u(!1),k(null)},[]);return{goalComposeMode:h,goalTokenBudget:m,goalBusy:p,goalLocalError:b,setGoalTokenBudget:f,submitGoal:x,enterGoalComposeMode:j,exitGoalComposeMode:w}}var Cn=`node -e "process.stdin.resume(); process.stdin.on('end', () => console.error('hook ran'))"`;function $m(e){const r=new Map;for(const n of e??[])r.set(n.eventName,n.command);return r}function Dm({slashPanelView:e,hookCommandTemplates:r,onCreateHook:n,onUpdateHook:a,onTrustHook:o,onUntrustHook:s}){const[l,i]=c.useState("list"),[d,h]=c.useState("project"),[u,m]=c.useState("preToolUse"),[f,p]=c.useState("Bash"),[g,b]=c.useState(Cn),[k,x]=c.useState("30"),[j,w]=c.useState("Running hook"),[y,v]=c.useState(null),[S,N]=c.useState(!1),[I,M]=c.useState(null),[R,Q]=c.useState(null),$=c.useMemo(()=>$m(r),[r]),Y=c.useCallback(J=>$.get(J)??$.get("preToolUse")??Cn,[$]),Z=c.useMemo(()=>new Set([Cn,...$.values()]),[$]),P=c.useCallback(()=>{M(null),Q(null)},[]);c.useEffect(()=>{e!=="hooks"&&(i("list"),P())},[P,e]),c.useEffect(()=>{const J=Xr.find(K=>K.value===u);p(K=>{const L=K.trim(),q=new Set(Xr.map(G=>G.matcherHint).filter(Boolean));return L&&!q.has(L)?K:(J==null?void 0:J.matcherHint)??""}),b(K=>Z.has(K.trim())?Y(u):K)},[Y,Z,u]);const te=c.useCallback(()=>{v(null),h("project"),m("preToolUse"),p("Bash"),b(Y("preToolUse")),x("30"),w("Running hook")},[Y]),oe=c.useCallback(J=>{const K=al(J);if(!K){M("Only command hooks in global or project hooks.json can be edited here.");return}v(K),h(K.scope),m(K.eventName),p(K.matcher??""),b(K.command),x(K.timeoutSec?String(K.timeoutSec):""),w(K.statusMessage??""),M(null),Q(null),i("edit")},[]),T=c.useCallback(async()=>{if(l==="edit"&&!a){M("Hook editing is unavailable in this view.");return}if(l!=="edit"&&!n){M("Hook editing is unavailable in this view.");return}if(l==="edit"&&!y){M("Select a hook to edit first.");return}const J=g.trim();if(!J){M("Hook command cannot be empty.");return}const K=k.trim(),L=K?Number(K):null;if(K&&(L===null||!Number.isInteger(L)||L<=0)){M("Timeout must be a positive number of seconds.");return}N(!0),M(null),Q(null);try{const q={scope:d,eventName:u,matcher:f.trim()||null,command:J,timeoutSec:L,statusMessage:j.trim()||null};l==="edit"?await(a==null?void 0:a({...q,target:y})):await(n==null?void 0:n(q)),Q(`${d==="project"?"Project":"Global"} hook ${l==="edit"?"updated":"written"} in hooks.json and trusted.`),i("list"),v(null)}catch(q){M(q instanceof Error?q.message:"Unable to write hooks.json.")}finally{N(!1)}},[y,g,u,f,d,j,k,l,n,a]),re=c.useCallback(async J=>{if(!o||!J.currentHash){M("Hook trust is unavailable in this view.");return}N(!0),M(null),Q(null);try{await o({key:J.key,currentHash:J.currentHash}),Q("Hook trusted.")}catch(K){M(K instanceof Error?K.message:"Unable to trust hook.")}finally{N(!1)}},[o]),B=c.useCallback(async J=>{if(!s){M("Hook trust is unavailable in this view.");return}N(!0),M(null),Q(null);try{await s({key:J.key}),Q("Hook untrusted.")}catch(K){M(K instanceof Error?K.message:"Unable to untrust hook.")}finally{N(!1)}},[s]);return{hooksPanelMode:l,hookScope:d,hookEventName:u,hookMatcher:f,hookCommand:g,hookTimeoutSec:k,hookStatusMessage:j,editingHookTarget:y,hookConfigBusy:S,hookConfigError:I,hookConfigSuccess:R,setHooksPanelMode:i,setEditingHookTarget:v,setHookScope:h,setHookEventName:m,setHookMatcher:p,setHookCommand:b,setHookTimeoutSec:x,setHookStatusMessage:w,clearHookConfigStatus:P,resetHookForm:te,startEditingHook:oe,saveHook:T,trustHook:re,untrustHook:B}}var Bm=`[mcp_servers.example_stdio]
|
|
3654
3654
|
command = "npx"
|
|
3655
3655
|
args = ["-y", "your-mcp-server"]
|
|
3656
|
-
`,hs="MCP entry written to provider config. Restart the backend if it does not appear immediately.";function Fm({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,v]=c.useState(null),[x,j]=c.useState(null),w=c.useCallback(()=>{v(null),j(null)},[]),y=c.useCallback(async()=>{if(!e||!r)throw new Error("Provider config editing is unavailable for this thread.");const R=await r();return f(R.path),R},[e,r]),k=c.useCallback(async R=>{if(!e||!n)throw new Error("Provider config editing is unavailable for this thread.");const P=await n(R);return f(P.path),P},[e,n]),S=c.useCallback(async()=>{const R=Tu(s),P=i.trim();if(!R){v("MCP name must use only letters, numbers, underscore, or hyphen.");return}if(!/^https?:\/\//i.test(P)){v("HTTP MCP URL must start with http:// or https://");return}g(!0),v(null),j(null);try{const J=await y(),D=as(J.content,R,Lu(R,P));await k(D),j(hs),a("list"),l(""),d(""),o==null||o()}catch(J){v(J instanceof Error?J.message:"Unable to update provider config.")}finally{g(!1)}},[y,s,i,o,a,k]),N=c.useCallback(async()=>{g(!0),v(null),j(null);try{await y(),u(R=>R||Gm),a("stdio")}catch(R){v(R instanceof Error?R.message:"Unable to load provider config.")}finally{g(!1)}},[y,a]),L=c.useCallback(async()=>{const R=Eu(h);if(!R){v("The raw MCP block must start with a header like [mcp_servers.name].");return}g(!0),v(null),j(null);try{const P=await y(),J=as(P.content,R,h);await k(J),j(hs),a("list"),o==null||o()}catch(P){v(P instanceof Error?P.message:"Unable to update provider config.")}finally{g(!1)}},[y,h,o,a,k]);return{mcpHttpName:s,mcpHttpUrl:i,mcpRawBlock:h,mcpConfigPath:m,mcpConfigBusy:p,mcpConfigError:b,mcpConfigSuccess:x,setMcpHttpName:l,setMcpHttpUrl:d,setMcpRawBlock:u,clearMcpConfigStatus:w,prepareRawMcpBlock:N,saveHttpMcp:S,saveRawMcpBlock:L}}function Hm({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 Om(e,r){const{attachment:n}=e,a=document.createElement("span");if(a.dataset.segmentType="attachment",a.dataset.clientId=n.clientId,a.dataset.placeholder=n.placeholder,a.contentEditable="false",a.className="thread-composer-attachment-chip mx-[0.12rem] inline-flex max-w-full align-baseline",n.kind==="photo"){a.classList.add("thread-composer-attachment-chip-photo","rounded-[0.95rem]","border","border-sky-300/35","bg-sky-300/10","p-1","shadow-sm","shadow-stone-950/20");const l=r[n.clientId];if(l){const d=document.createElement("img");d.src=l,d.alt=n.originalName||"Pasted image",d.className="thread-composer-attachment-thumb h-[4.5rem] w-[6rem] rounded-[0.7rem] bg-stone-950 object-contain",d.draggable=!1,a.append(d)}else{const d=document.createElement("span");d.className="thread-composer-attachment-thumb inline-block h-[4.5rem] w-[6rem] rounded-[0.7rem] bg-stone-900/80",d.setAttribute("aria-hidden","true"),a.append(d)}const i=document.createElement("span");return i.className="thread-composer-attachment-caption ml-2 inline-flex max-w-[8rem] items-center text-[10px] font-medium tracking-[0.08em] text-sky-50",i.textContent=os(n),a.append(i),a}a.classList.add("items-center","gap-2","rounded-[0.95rem]","border","border-emerald-300/35","bg-emerald-300/10","px-2.5","py-2","text-[10px]","font-medium","tracking-[0.08em]","text-emerald-50","shadow-sm","shadow-stone-950/20");const 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=os(n),a.append(o,s),a}function Wm(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(Om(a,r))}return n}function Um({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,v=f()!==n||u.current!==s||m.current!==l;v&&(g.replaceChildren(Wm(a,o)),u.current=s,m.current=l),b!==null?(g.focus(),sm(g,d.current)||p(b),h.current=b):document.activeElement===g&&v&&p(h.current),i.current=null,d.current=[]},[o,l,r,s,n,e,a,d,i,u,m,p,h,f])}function Vm({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 Km({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:v,onDragLeave:x,onDrop:j}){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:v,onDragLeave:x,onDrop:j,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(jt,{type:"button",variant:"ghost",size:"icon-xs","aria-label":s,title:s,onClick:w=>{w.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 qm({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 Xm({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:v,onInterrupt:x,onPromptInput:j,onPromptPaste:w,onPromptKeyDown:y,onPromptKeyUp:k,onPromptMouseUp:S,onPromptBlur:N,onPromptDragEnter:L,onPromptDragOver:R,onPromptDragLeave:P,onPromptDrop:J,onGoalTokenBudgetChange:D,onCancelGoal:Y,onShellPromptChange:Z}){return{promptSlot:e?null:t.jsx(Km,{promptRef:r,prompt:n,disabled:a,promptPlaceholder:o,canInterrupt:s,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,onInterrupt:x,onInput:j,onPaste:w,onKeyDown:y,onKeyUp:k,onMouseUp:S,onBlur:N,onDragEnter:L,onDragOver:R,onDragLeave:P,onDrop:J}),goalSlot:u&&!e?t.jsx(Vm,{tokenBudget:m,error:f,onTokenBudgetChange:D,onCancel:Y}):null,shellPromptSlot:e?t.jsx(qm,{prompt:n,promptPlaceholder:o,promptRegionClassName:i,promptInputClassName:h,interruptLabel:l,canInterrupt:s,sendButtonLabel:b,sendButtonClassName:v,sendDisabled:p||g,onPromptChange:Z,onPromptKeyDown:y,onInterrupt:x}):null}}function Ym({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=Nu({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 Zm({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:v,settingsBusy:x,compactBusy:j,forkBusy:w,fastMode:y,goalComposeMode:k,goalBusy:S,goalStatus:N,activeView:L,disabled:R,model:P,modelOptions:J,modelContextTitle:D,contextUsage:Y,reasoningEffort:Z,supportedEfforts:I,displayedCollaborationMode:re,sandboxMode:oe,sendButtonLabel:$,sendButtonClassName:Q,modelControlsDisabled:_,effortControlsDisabled:ee,effortControlTitle:W,forkTurnOptionsState:T,skillsState:K,goalState:G,goalHistory:E,copiedSkillName:C,hooksPanelMode:U,hooksState:H,hookConfigBusy:se,hookConfigError:q,hookConfigSuccess:de,editingHookTarget:te,hookScope:be,hookEventName:ie,hookMatcher:ye,hookCommand:Ae,hookTimeoutSec:ce,hookStatusMessage:Ce,mcpPanelMode:Le,mcpState:X,mcpConfigPath:ue,mcpConfigError:ve,mcpConfigSuccess:ke,mcpConfigBusy:_e,mcpHttpName:He,mcpHttpUrl:$e,mcpRawBlock:Ie,capabilities:F,shellControlState:le,onToggleView:we,onDismissPromptFocus:z,onSetOpenMenu:O,onToolboxItemClick:ne,onSetSlashPanelView:ge,onViewGoals:Te,onUpdateGoal:Ee,onOpenForkTurns:fe,onForkLatest:De,onForkTurn:Be,onCopySkillInvokeName:et,onResetHookForm:Ve,onSetHooksPanelMode:pt,onClearHookConfigStatus:nt,onSetEditingHookTarget:We,onSetHookScope:ot,onSetHookEventName:ht,onSetHookMatcher:ut,onSetHookCommand:M,onSetHookTimeoutSec:V,onSetHookStatusMessage:xe,onSaveHook:je,onStartEditingHook:Ne,onTrustHook:Ye,onUntrustHook:tt,onSetMcpPanelMode:Fe,onClearMcpConfigStatus:Ke,onSetMcpHttpName:lt,onSetMcpHttpUrl:vt,onSetMcpRawBlock:it,onPrepareRawMcpBlock:Nt,onSaveHttpMcp:Rt,onSaveRawMcpBlock:Ct,onPickPhoto:A,onPickFile:pe,onUpdateSettings:Re,onPasteShell:Ge,onCopyShell:Ue,onClearShell:ct,onShellControl:kt}){const qt=e?null:{open:o==="slash",slashPanelView:g,availableToolboxItems:b,busy:v,forkBusy:w,forkTurnOptionsState:T,skillsState:K,goalState:G,goalHistory:E,goalBusy:S,copiedSkillName:C,hooksPanelMode:U,hooksState:H,hostConfigFilesAvailable:F.hostConfigFiles,hookTrustAvailable:F.hookTrust,hookConfigBusy:se,hookConfigError:q,hookConfigSuccess:de,editingHookTarget:te,hookScope:be,hookEventName:ie,hookMatcher:ye,hookCommand:Ae,hookTimeoutSec:ce,hookStatusMessage:Ce,mcpPanelMode:Le,mcpState:X,mcpConfigEditing:F.mcpConfigEditing,mcpConfigPath:ue,mcpConfigError:ve,mcpConfigSuccess:ke,mcpConfigBusy:_e,mcpHttpName:He,mcpHttpUrl:$e,mcpRawBlock:Ie,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,onToggle:()=>O(at=>at==="slash"?null:"slash"),onToolboxItemClick:ne,toolboxItemDisabled:at=>Qu(at,{settingsBusy:x,compactBusy:j,busy:v,forkBusy:w}),toolboxItemClassName:at=>em(at,{fastMode:y,goalComposeMode:k,goalStatus:N,menuItemClassName:d}),toolboxItemStatus:at=>Ju(at,{fastMode:y,compactBusy:j,goalComposeMode:k,goalStatus:N,busy:v}),onSetSlashPanelView:ge,onViewGoals:Te,onUpdateGoal:Ee,onOpenForkTurns:fe,onForkLatest:De,onForkTurn:Be,onCopySkillInvokeName:et,onResetHookForm:Ve,onSetHooksPanelMode:pt,onClearHookConfigStatus:nt,onSetEditingHookTarget:We,onSetHookScope:ot,onSetHookEventName:ht,onSetHookMatcher:ut,onSetHookCommand:M,onSetHookTimeoutSec:V,onSetHookStatusMessage:xe,onSaveHook:je,onStartEditingHook:Ne,onTrustHook:Ye,onUntrustHook:tt,onSetMcpPanelMode:Fe,onClearMcpConfigStatus:Ke,onSetMcpHttpName:lt,onSetMcpHttpUrl:vt,onSetMcpRawBlock:it,onPrepareRawMcpBlock:Nt,onSaveHttpMcp:Rt,onSaveRawMcpBlock:Ct},Xt=e?null:{open:o==="attachments",iconButtonClassName:l,menuClassName:i,menuItemClassName:d,onToggle:()=>O(at=>at==="attachments"?null:"attachments"),onPickPhoto:A,onPickFile:pe},Mt=e?null:{openMenu:o,model:P,modelOptions:J,modelContextTitle:D,contextUsage:Y,reasoningEffort:Z,supportedEfforts:I,displayedCollaborationMode:re,sandboxMode:oe,planModeAvailable:F.planMode,sandboxModeAvailable:F.sandboxMode,settingsBusy:x,goalComposeMode:k,goalBusy:S,activeView:L,disabled:R,fastMode:y,sendButtonLabel:$,sendButtonClassName:Q,modelControlsDisabled:_,effortControlsDisabled:ee,effortControlTitle:W,inlineToggleClassName:m,menuItemClassName:d,planToggleActiveClassName:f,sendButtonBaseClassName:p,onSetOpenMenu:O,onUpdateSettings:Re};return{isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:o,toolbarClassName:s,iconButtonClassName:l,slashToolboxProps:qt,attachmentMenuProps:Xt,settingsToolbarProps:Mt,shellToolsPanelProps:o==="shellTools"?{busy:v,shellControlState:le,onPaste:Ge,onCopy:Ue,onClear:ct,onShellControl:kt}:null,shellControlState:le,onToggleView:we,onDismissPromptFocus:z,onSetOpenMenu:O}}function Vn({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:v=null,mcpConfigFormat:x="none",followTail:j=!1,threadConnected:w=!0,shellAvailable:y=!0,disabled:k=!1,disabledPlaceholder:S,shellControlState:N=null,draftPrompt:L,draftAttachments:R,onPickAttachment:P,skillsState:J={status:"idle",data:null,error:null},mcpState:D={status:"idle",data:null,error:null},hooksState:Y={status:"idle",data:null,error:null},goalState:Z={status:"idle",data:null,error:null},goalHistory:I=[],forkTurnOptionsState:re={status:"idle",data:null,error:null},onDraftChange:oe,onSubmit:$,onInterrupt:Q,onCompact:_,onOpenSkills:ee,onOpenMcp:W,onOpenHooks:T,onCreateHook:K,onUpdateHook:G,onTrustHook:E,onUntrustHook:C,onOpenGoal:U,onPrepareGoalSubmit:H,onUpdateGoal:se,onOpenForkTurns:q,onForkLatest:de,onForkTurn:te,onReadProviderConfig:be,onWriteProviderConfig:ie,onToggleFollow:ye,canJumpToPreviousTurn:Ae,onJumpToPreviousTurn:ce,canJumpToNextTurn:Ce,onJumpToNextTurn:Le,subscriptionUsage:X,onUpdateSettings:ue,onToggleView:ve,onShellCopy:ke,onShellControl:_e,canInterrupt:He=!1}){var Ca;const[$e,Ie]=c.useState(null),[F,le]=c.useState("root"),we=c.useRef(!1),[z,O]=c.useState("list"),ne=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)&&!!be&&!!ie,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,be,ie]),ge=c.useMemo(()=>Yu(b,ne),[ne,b]),Te=c.useRef(null),Ee=c.useRef(null),fe=c.useRef(null),De=c.useRef(null),Be=c.useRef(null),et=c.useRef([]),Ve=c.useRef(null),pt=c.useRef(""),nt=c.useRef(0),We=e==="shell",ot=y||We,ht=!!(We&&(N!=null&&N.isMobileShell)),ut=(N==null?void 0:N.promptLabel)??null,[M,V]=c.useState(!1),[xe,je]=c.useState(0),{prompt:Ne,attachments:Ye,isDraftControlled:tt,updateDraft:Fe,flushControlledDraftToHost:Ke}=Am({isShellView:We,draftPrompt:L,draftAttachments:R,onDraftChange:oe}),lt=Rm({attachments:Ye,isShellView:We}),{displayedCollaborationMode:vt,updateSettings:it}=Ym({collaborationMode:h,onUpdateSettings:ue,closeMenu:()=>Ie(null)}),{forkBusy:Nt,forkLatest:Rt,forkTurn:Ct}=$m({slashPanelView:F,onForkLatest:de,onForkTurn:te,closeMenu:()=>Ie(null)}),{hooksPanelMode:A,hookScope:pe,hookEventName:Re,hookMatcher:Ge,hookCommand:Ue,hookTimeoutSec:ct,hookStatusMessage:kt,editingHookTarget:qt,hookConfigBusy:Xt,hookConfigError:Mt,hookConfigSuccess:cr,setHooksPanelMode:at,setEditingHookTarget:cn,setHookScope:hn,setHookEventName:zl,setHookMatcher:Pl,setHookCommand:Rl,setHookTimeoutSec:Ml,setHookStatusMessage:Al,clearHookConfigStatus:ga,resetHookForm:$l,startEditingHook:_l,saveHook:Dl,trustHook:Bl,untrustHook:Gl}=Bm({slashPanelView:F,hookCommandTemplates:v,onCreateHook:K,onUpdateHook:G,onTrustHook:E,onUntrustHook:C}),{goalComposeMode:hr,goalTokenBudget:Fl,goalBusy:un,goalLocalError:Hl,setGoalTokenBudget:Ol,submitGoal:Wl,enterGoalComposeMode:Ul,exitGoalComposeMode:xa}=_m({prompt:Ne,goalTokenBudgetSource:Z.data,promptRef:Ee,onOpenGoal:U,onPrepareGoalSubmit:H,onUpdateGoal:se,updateDraft:Fe,closeMenu:()=>Ie(null),resetSlashPanel:()=>le("root")}),{mcpHttpName:Vl,mcpHttpUrl:Kl,mcpRawBlock:ql,mcpConfigPath:Xl,mcpConfigBusy:Yl,mcpConfigError:Zl,mcpConfigSuccess:Jl,setMcpHttpName:Ql,setMcpHttpUrl:ei,setMcpRawBlock:ti,clearMcpConfigStatus:ba,prepareRawMcpBlock:ri,saveHttpMcp:ni,saveRawMcpBlock:ai}=Fm({hostConfigFilesAvailable:ne.hostConfigFiles,onReadProviderConfig:be,onWriteProviderConfig:ie,setMcpPanelMode:O,onOpenMcp:W}),{copiedSkillName:si,copySkillInvokeName:oi}=Hm({openMenu:$e,setOpenMenu:Ie,slashPanelView:F,setSlashPanelView:le,setMcpPanelMode:O,clearMcpConfigStatus:ba,clearHookConfigStatus:ga}),li=c.useCallback(ae=>{Fe(Se=>{if(typeof ae=="function"){const Me=ae(Se.prompt,Se.attachments);return{prompt:Me.prompt,attachments:Me.attachments??Se.attachments}}return{prompt:ae,attachments:Se.attachments}})},[Fe]),mn=c.useMemo(()=>f.find(ae=>ae.model===l)??null,[l,f]),ii=Iu(l,p),va=(mn==null?void 0:mn.supportedReasoningEfforts)??[],di=c.useMemo(()=>fu(Ne,Ye),[Ye,Ne]),ci=c.useMemo(()=>Object.entries(lt).sort(([ae],[Se])=>ae.localeCompare(Se)).map(([ae,Se])=>`${ae}:${Se}`).join("|"),[lt]);function hi(ae,Se){Se.stopPropagation();const Me=Zu(ae,{fastMode:d,goalComposeMode:hr});switch(Me.type){case"toggleFast":it({fastMode:Me.fastMode});break;case"runCompact":Ie(null),_==null||_();break;case"enterGoalCompose":Ul();break;case"exitGoalCompose":xa(),Ie(null);break;case"openPanel":le(Me.panel),Me.panel==="skills"?ee==null||ee():Me.panel==="mcp"?W==null||W():Me.panel==="hooks"&&(T==null||T());break;case"insertPrompt":gn(Me.text),le("root"),Ie(null);break}}function Yt(){const ae=Ee.current;return ae?nm(ae):null}const ui=c.useCallback(ae=>{const Se=Ee.current;!Se||!ae||am(Se,ae)},[]),pn=c.useCallback(()=>{const ae=Ee.current;return ae?ll(ae):Ne},[Ne]),{appendAttachments:fn,appendDroppedAttachments:ka}=Pm({prompt:Ne,attachments:Ye,updateDraft:Fe,getSelection:Yt,selectionSnapshotRef:Ve,pendingSelectionRef:Be,pendingInsertedAttachmentIdsRef:et,onInserted:()=>Ie(null)}),wa=c.useCallback((ae,Se)=>{var Me;if(At(),P){P({kind:ae,appendAttachments:(Je,st=ae)=>fn(Je,st),defaultPick:()=>{var Je;return(Je=Se.current)==null?void 0:Je.click()}});return}(Me=Se.current)==null||Me.click()},[fn,At,P]);function gn(ae){if(!ae)return;const Se=Yt()??Ve.current,Me=(Se==null?void 0:Se.start)??Ne.length,Je=(Se==null?void 0:Se.end)??Me,st=pu(ae),Zt=`${Ne.slice(0,Me)}${st}${Ne.slice(Je)}`;Fe(Ki=>({prompt:Zt,attachments:Ki.attachments}));const $t=Me+st.length;Be.current={start:$t,end:$t},Ve.current={start:$t,end:$t}}Um({promptRef:Ee,isShellView:We,prompt:Ne,promptSegments:di,attachmentPreviewUrls:lt,previewSignature:ci,editorSanitizeNonce:xe,pendingSelectionRef:Be,pendingInsertedAttachmentIdsRef:et,selectionSnapshotRef:Ve,renderedPreviewSignatureRef:pt,renderedSanitizeNonceRef:nt,serializeEditorPrompt:pn,restoreSelection:ui});function At(){var ae;(ae=Ee.current)==null||ae.blur(),document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.blur()}async function mi(){var ae;if(At(),Ie(null),!!((ae=navigator.clipboard)!=null&&ae.readText))try{const Se=await navigator.clipboard.readText();gn(Se)}catch{return}}async function ya(){if(!we.current){we.current=!0;try{if(tt&&Ke(),hr&&!We){await Wl();return}const ae=ku({prompt:Ne,attachments:Ye,isShellView:We});if(!ae||await $(ae)===!1)return;Fe(()=>({prompt:"",attachments:[]}))}finally{we.current=!1}}}async function pi(ae){ae.preventDefault(),await ya()}function fi(){const ae=pn(),Se=Yt();Ve.current=Se;const Me=Ee.current;(Me?rm(Me):!1)&&(Be.current=Se,je(st=>st+1)),Fe(st=>({prompt:ae,attachments:st.attachments.filter(Zt=>ae.includes(Zt.placeholder))}),"deferred")}function gi(ae){var Je,st,Zt,$t;const Se=Wn((Je=ae.clipboardData)==null?void 0:Je.items,(st=ae.clipboardData)==null?void 0:st.files),Me=wu({files:Se,plainText:((Zt=ae.clipboardData)==null?void 0:Zt.getData("text/plain"))??"",htmlText:(($t=ae.clipboardData)==null?void 0:$t.getData("text/html"))??"",htmlToText:tm});Me.preventDefault&&ae.preventDefault(),Me.type==="insert-text"?gn(Me.text):Me.type==="append-files"&&ka(Me.files)}function xi(ae){var Me,Je;const Se=rs(ss((Me=ae.dataTransfer)==null?void 0:Me.items,(Je=ae.dataTransfer)==null?void 0:Je.files));Se.preventDefault&&ae.preventDefault(),Se.activateDragTarget&&V(!0)}function bi(ae){var Me,Je;const Se=rs(ss((Me=ae.dataTransfer)==null?void 0:Me.items,(Je=ae.dataTransfer)==null?void 0:Je.files));Se.preventDefault&&ae.preventDefault(),Se.activateDragTarget&&ae.dataTransfer&&(ae.dataTransfer.dropEffect="copy"),Se.activateDragTarget&&V(!0)}function vi(ae){ae.currentTarget.contains(ae.relatedTarget)||V(!1)}function ki(ae){var Je,st;const Se=Wn((Je=ae.dataTransfer)==null?void 0:Je.items,(st=ae.dataTransfer)==null?void 0:st.files),Me=yu(Se);Me.preventDefault&&ae.preventDefault(),Me.type==="accept-files"&&(V(!1),ka(Me.files??[]))}function wi(ae){if(ae.key==="Enter"&&ae.repeat){ae.preventDefault();return}if(e==="chat"&&ae.key==="/"&&!ae.metaKey&&!ae.ctrlKey&&!ae.altKey&&!n&&!k&&ge.length>0&&pn().trim().length===0){ae.preventDefault(),le("root"),Ie("slash");return}const Se=ju({key:ae.key,metaKey:ae.metaKey,ctrlKey:ae.ctrlKey,busy:n,disabled:k});Se.preventDefault&&ae.preventDefault(),Se.submit&&ya()}const{promptPlaceholder:yi,interruptLabel:ji,sendButtonLabel:ja,sendButtonClassName:Na,modelControlsDisabled:Ni,effortControlsDisabled:Ci,effortControlTitle:Si}=Mu({goalComposeMode:hr,goalBusy:un,threadConnected:w,busy:n,isShellView:We,disabledPlaceholder:S,settingsBusy:a,supportedEffortCount:va.length,fastMode:d}),{composerLayerClassName:Ti,formClassName:Ei,composerShellClassName:Li,composerToolbarClassName:Ii,composerIconButtonClassName:zi,composerMenuClassName:Pi,composerMenuItemClassName:Ri,composerInlineToggleClassName:Mi,composerPanelButtonClassName:Ai,composerChipButtonClassName:$i,composerPlanToggleActiveClassName:_i,composerSendButtonClassName:Di,composerPromptRegionClassName:Bi,promptInputClassName:Gi,graphChatInputGroupClassName:Fi,graphChatInputClassName:Hi}=Au({isShellView:We,edgeToEdgeMobile:r,isMobileShell:ht,openMenu:$e!==null,isDragTargetActive:M,busy:n}),Oi=Zm({isShellView:We,canToggleShellView:ot,isMobileShell:ht,shellPromptLabel:ut,openMenu:$e,toolbarClassName:Ii,iconButtonClassName:zi,menuClassName:Pi,menuItemClassName:Ri,panelButtonClassName:Ai,chipButtonClassName:$i,inlineToggleClassName:Mi,planToggleActiveClassName:_i,sendButtonBaseClassName:Di,slashPanelView:F,availableToolboxItems:ge,busy:n,settingsBusy:a,compactBusy:o,forkBusy:Nt,fastMode:d,goalComposeMode:hr,goalBusy:un,goalStatus:(Ca=Z.data)==null?void 0:Ca.status,activeView:e,disabled:k,model:l,modelOptions:f,modelContextTitle:ii,contextUsage:p,reasoningEffort:i,supportedEfforts:va,displayedCollaborationMode:vt,sandboxMode:u,sendButtonLabel:ja,sendButtonClassName:Na,modelControlsDisabled:Ni,effortControlsDisabled:Ci,effortControlTitle:Si,forkTurnOptionsState:re,skillsState:J,goalState:Z,goalHistory:I,copiedSkillName:si,hooksPanelMode:A,hooksState:Y,hookConfigBusy:Xt,hookConfigError:Mt,hookConfigSuccess:cr,editingHookTarget:qt,hookScope:pe,hookEventName:Re,hookMatcher:Ge,hookCommand:Ue,hookTimeoutSec:ct,hookStatusMessage:kt,mcpPanelMode:z,mcpState:D,mcpConfigPath:Xl,mcpConfigError:Zl,mcpConfigSuccess:Jl,mcpConfigBusy:Yl,mcpHttpName:Vl,mcpHttpUrl:Kl,mcpRawBlock:ql,capabilities:{hostConfigFiles:ne.hostConfigFiles,hookTrust:ne.hookTrust,mcpConfigEditing:ne.mcpConfigEditing,planMode:ne.planMode,sandboxMode:m?!1:ne.sandboxMode},shellControlState:N,onToggleView:ve,onDismissPromptFocus:At,onSetOpenMenu:Ie,onToolboxItemClick:hi,onSetSlashPanelView:le,onViewGoals:U,onUpdateGoal:se,onOpenForkTurns:()=>q==null?void 0:q(),onForkLatest:Rt,onForkTurn:Ct,onCopySkillInvokeName:oi,onResetHookForm:$l,onSetHooksPanelMode:at,onClearHookConfigStatus:ga,onSetEditingHookTarget:cn,onSetHookScope:hn,onSetHookEventName:zl,onSetHookMatcher:Pl,onSetHookCommand:Rl,onSetHookTimeoutSec:Ml,onSetHookStatusMessage:Al,onSaveHook:Dl,onStartEditingHook:_l,onTrustHook:Bl,onUntrustHook:Gl,onSetMcpPanelMode:O,onClearMcpConfigStatus:ba,onSetMcpHttpName:Ql,onSetMcpHttpUrl:ei,onSetMcpRawBlock:ti,onPrepareRawMcpBlock:ri,onSaveHttpMcp:ni,onSaveRawMcpBlock:ai,onPickPhoto:()=>wa("photo",fe),onPickFile:()=>wa("file",De),onUpdateSettings:ae=>void it(ae),onPasteShell:()=>void mi(),onCopyShell:()=>{At(),Ie(null),ke==null||ke()},onClearShell:()=>{At(),Ie(null),$({prompt:"clear"})},onShellControl:ae=>{At(),Ie(null),_e==null||_e(ae)}}),{promptSlot:Wi,goalSlot:Ui,shellPromptSlot:Vi}=Xm({isShellView:We,promptRef:Ee,prompt:Ne,disabled:k,promptPlaceholder:yi,canInterrupt:He,interruptLabel:ji,composerPromptRegionClassName:Bi,graphChatInputClassName:Hi,promptInputClassName:Gi,goalComposeMode:hr,goalTokenBudget:Fl,goalLocalError:Hl,goalBusy:un,busy:n,sendButtonLabel:ja,sendButtonClassName:Na,onInterrupt:Q,onPromptInput:fi,onPromptPaste:gi,onPromptKeyDown:wi,onPromptKeyUp:()=>{Ve.current=Yt()},onPromptMouseUp:()=>{Ve.current=Yt()},onPromptBlur:()=>{Ve.current=Yt(),V(!1),tt&&Ke()},onPromptDragEnter:xi,onPromptDragOver:bi,onPromptDragLeave:vi,onPromptDrop:ki,onGoalTokenBudgetChange:Ol,onCancelGoal:xa,onShellPromptChange:li});return t.jsx(fm,{activeView:e,layerClassName:Ti,formClassName:Ei,shellClassName:Li,inputGroupClassName:Fi,error:s,followTail:j,photoInputRef:fe,fileInputRef:De,onAppendAttachments:fn,onToggleFollow:ye,canJumpToPreviousTurn:Ae,onJumpToPreviousTurn:ce,canJumpToNextTurn:Ce,onJumpToNextTurn:Le,subscriptionUsage:X,onSubmit:pi,formRef:Te,promptSlot:Wi,toolbarSlot:t.jsx(Lm,{...Oi}),goalSlot:Ui,shellPromptSlot:Vi})}var Jm=c.createContext(null);function dl(){return c.useContext(Jm)}function xt(e){return e?new Date(e).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"}):"Time unavailable"}function Wt(e){return e?new Date(e).toLocaleString():"Time unavailable"}function Qm(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 ep(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 cl(e){switch(e){case"sending":return"Sending";case"completed":return"Completed";case"interrupted":return"Interrupted";case"failed":return"Failed";case"inProgress":return"Running"}}function tp({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 Zr.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 rp({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 np({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 ap({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 sp({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 op({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 lp({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 ip({children:e}){return t.jsx("div",{className:"thread-split-region min-h-0 flex-1 overflow-hidden p-0 sm:p-2",children:e})}zo();Pt();function us({...e}){return t.jsx(Qi,{"data-slot":"dialog",...e})}function ms({...e}){return t.jsx(ed,{"data-slot":"dialog-trigger",...e})}function dp({...e}){return t.jsx(sd,{"data-slot":"dialog-portal",...e})}function cp({className:e,...r}){return t.jsx(od,{"data-slot":"dialog-overlay",className:rt("fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",e),...r})}function ps({children:e,className:r,showCloseButton:n=!0,...a}){return t.jsxs(dp,{"data-slot":"dialog-portal",children:[t.jsx(cp,{}),t.jsxs(td,{"data-slot":"dialog-content",className:rt("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(rd,{"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 fs({className:e,...r}){return t.jsx("div",{"data-slot":"dialog-header",className:rt("flex flex-col gap-2 text-center sm:text-left",e),...r})}function gs({className:e,...r}){return t.jsx(nd,{"data-slot":"dialog-title",className:rt("text-lg font-semibold leading-none",e),...r})}function xs({className:e,...r}){return t.jsx(ad,{"data-slot":"dialog-description",className:rt("text-sm text-muted-foreground",e),...r})}var hp=[{value:"system",label:"Follow system",icon:B.Monitor},{value:"dark",label:"Dark",icon:B.Moon},{value:"light",label:"Light",icon:B.Sun}];function up({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],v=b&&!n?b:null,x=r===e.id;c.useEffect(()=>()=>{g.current!==null&&window.clearTimeout(g.current)},[]);async function j(){const N=e.providerSessionId;if(N)try{await navigator.clipboard.writeText(N),p("copied"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>p("idle"),1200)}catch{p("failed"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>p("idle"),1600)}}const w=()=>o(e.id),y=`thread-graph-room-card group flex w-full items-center gap-3 rounded-xl border text-left transition ${x?"is-active":""} ${m?"justify-center px-2 py-2":"px-3 py-2.5"}`,k=t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`thread-graph-room-card-icon flex h-8 w-8 shrink-0 items-center justify-center rounded-full ${x?"is-active":""}`,children:t.jsx(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:N=>{N.stopPropagation(),N.preventDefault(),i(e)},"aria-label":`Rename thread ${e.title}`,title:"Rename thread",className:"thread-card-quiet-button inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full transition",children:t.jsx(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:N=>{N.stopPropagation(),N.preventDefault(),j()},className:"thread-card-quiet-button thread-card-session-copy-button inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition",children: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 ${ep(e.status)}`,children:Qm(e.status)}),t.jsx("time",{className:"shrink-0 text-[11px] text-[var(--theme-fg-muted)]",dateTime:e.lastTurnStartedAt??e.updatedAt,children:xt(e.lastTurnStartedAt??e.updatedAt)})]})]}),h&&d&&!m?t.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),N.preventDefault(),d(e)},"aria-label":`Delete thread ${e.title}`,className:"thread-card-danger-button shrink-0 rounded-full p-1 transition",title:"Delete thread",children:t.jsx(B.Trash2,{className:"h-3.5 w-3.5"})}):null]}),S=s==null?void 0:s(e.id);return l?t.jsx(t.Fragment,{children:l({thread:e,children:k,className:y,onClick:w})}):S?t.jsx("a",{href:S,onClick:N=>{N.preventDefault(),w()},title:m?e.title:void 0,className:y,children:k}):t.jsx("div",{role:"link",tabIndex:0,onClick:w,onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),w())},title:m?e.title:void 0,className:y,children:k})}function mp({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(up,{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 pp({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:v=null,sessionLabel:x=null,usageLabel:j=null,threadActionsButton:w,topbarActions:y,metaContent:k,settingsContent:S,globalSettingsContent:N,workspaceLabels:L={},workspaceReturnHref:R,onWorkspaceReturn:P,getThreadHref:J,onOpenThread:D,getNewThreadHref:Y,newThreadHref:Z,newThreadLabel:I="New Chat",onNewThread:re,onNewThreadTitle:oe,renderNewThreadDialogContent:$,renderThreadLink:Q,onCloseAppNavigation:_,onRenameThread:ee,onDeleteThread:W,workspaceContent:T,workspaceTitle:K="Workspace",workspaceActions:G,children:E}){const C=dl(),U=typeof window<"u"?window.matchMedia("(max-width: 639px)").matches:s==="mobile",[H,se]=c.useState(()=>typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)").matches:!1),q=i??(C==null?void 0:C.themeMode)??"system",de=l??(C==null?void 0:C.effectiveTheme)??(q==="system"?H?"dark":"light":q),[te,be]=c.useState(!1),[ie,ye]=c.useState(!1),[Ae,ce]=c.useState(!U),[Ce,Le]=c.useState(U),[X,ue]=c.useState("chat"),[ve,ke]=c.useState(null),[_e,He]=c.useState(""),[$e,Ie]=c.useState(null),[F,le]=c.useState(!1),[we,z]=c.useState(""),[O,ne]=c.useState(!1),[ge,Te]=c.useState(!1),[Ee,fe]=c.useState("session");c.useEffect(()=>{if(typeof window>"u")return;const A=window.matchMedia("(max-width: 639px)"),pe=()=>{Le(A.matches)};return pe(),A.addEventListener("change",pe),()=>{A.removeEventListener("change",pe)}},[]),c.useEffect(()=>{if(typeof window>"u")return;const A=window.matchMedia("(prefers-color-scheme: dark)"),pe=()=>{se(A.matches)};return pe(),A.addEventListener("change",pe),()=>{A.removeEventListener("change",pe)}},[]);const De=c.useMemo(()=>[...b?e.filter(pe=>pe.workspaceId===b):e].sort((pe,Re)=>{if(pe.id===p)return-1;if(Re.id===p)return 1;const Ge=Date.parse(pe.lastTurnStartedAt??pe.updatedAt);return Date.parse(Re.lastTurnStartedAt??Re.updatedAt)-Ge}),[p,b,e]),Be=Z??(Y==null?void 0:Y(b)),et=v??b??"all",Ve=x??g??p??"default_session",pt=j??(r!=null&&r.state?`runtime ${r.state}`:"waiting for agent usage"),nt=d??(C==null?void 0:C.setThemeMode),We=!!nt,ot=()=>{be(!1),_==null||_()};async function ht(A){if(!ee)return;const pe=_e.trim();if(pe){Ie(A);try{await ee(A,pe),ke(null),He("")}finally{Ie(null)}}}function ut(A){ke(A.id),He(A.title)}function M(){ke(null),He("")}function V(A){D==null||D(A),ot()}function xe(){le(!1),z("")}function je(A){if(!Be||!A.trim())return Be;try{const pe=new URL(Be,window.location.origin);return pe.searchParams.set("title",A.trim()),`${pe.pathname}${pe.search}${pe.hash}`}catch{const pe=Be.includes("?")?"&":"?";return`${Be}${pe}title=${encodeURIComponent(A.trim())}`}}async function Ne(){const A=we.trim();ne(!0);try{if(A&&oe){await oe(A),z(""),le(!1),ot();return}if(Be){window.location.assign(je(A)??Be);return}await(re==null?void 0:re()),z(""),le(!1),ot()}finally{ne(!1)}}function Ye(A,pe=!1){const Re=pe?t.jsxs(t.Fragment,{children:[t.jsx(B.Plus,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:I})]}):t.jsxs(t.Fragment,{children:[t.jsx(B.Plus,{className:"h-4 w-4"}),t.jsx("span",{children:I})]});return t.jsxs(us,{open:F,onOpenChange:Ge=>{O||le(Ge)},children:[t.jsx(ms,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":pe?I:void 0,title:I,className:A,children:Re})}),t.jsx(ps,{"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:xe,closeNavigation:ot,currentWorkspaceId:b}):t.jsxs(t.Fragment,{children:[t.jsxs(fs,{children:[t.jsx(gs,{children:"Create New Chat"}),t.jsx(xs,{children:"Name the room so it is easy to find later."})]}),t.jsxs("div",{className:"grid gap-3",children:[t.jsx("input",{id:"thread-graph-create-thread-title",name:"thread-title",value:we,onChange:Ge=>z(Ge.target.value),onKeyDown:Ge=>{Ge.key==="Enter"&&(Ge.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:O,className:"thread-graph-create-thread-submit inline-flex h-10 items-center justify-center rounded-md px-4 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:O?"Creating...":"Create"})]})]})})]})}function tt(){if(!S&&!k&&!N&&!We)return null;const A=!!(S||k),pe=!!N,Re=A&&pe,Ge=Ee==="global"&&pe||!A&&pe?"global":"session";return t.jsxs(us,{...u!==void 0?{open:u}:{},...m?{onOpenChange:m}:{},children:[t.jsx(ms,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":"Open settings",title:"Settings",className:"thread-icon-button inline-flex h-10 w-10 items-center justify-center rounded-full sm:h-9 sm:w-9",children:t.jsx(B.Settings,{className:"h-4 w-4"})})}),t.jsxs(ps,{"data-testid":"settings-dialog","data-theme-effective":de,"data-theme-mode":q,className:"thread-graph-settings-dialog thread-graph-dialog",children:[t.jsxs(fs,{children:[t.jsx(gs,{children:"Settings"}),t.jsx(xs,{children:"Manage this session and host-wide preferences."})]}),We?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:hp.map(Ue=>{const ct=Ue.icon,kt=q===Ue.value;return t.jsxs("button",{type:"button","data-testid":`theme-mode-${Ue.value}`,"aria-pressed":kt,disabled:!We,onClick:()=>nt==null?void 0:nt(Ue.value),className:`thread-graph-theme-mode-button inline-flex min-h-9 items-center justify-center gap-1.5 rounded-md px-2 text-xs font-medium transition ${kt?"is-selected":""}`,children:[t.jsx(ct,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:"truncate",children:Ue.label})]},Ue.value)})})]})}):null,Re?t.jsxs("div",{className:"thread-graph-settings-tabs grid grid-cols-2 gap-1 rounded-lg border p-1",children:[t.jsx("button",{type:"button","aria-pressed":Ge==="session",onClick:()=>fe("session"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Ge==="session"?"is-active":""}`,children:"Session"}),t.jsx("button",{type:"button","aria-pressed":Ge==="global",onClick:()=>fe("global"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Ge==="global"?"is-active":""}`,children:"Global"})]}):null,t.jsx("div",{className:"thread-graph-settings-body mt-4 min-h-0 overflow-y-auto pr-1 text-sm",children:Ge==="session"?t.jsxs("div",{className:"grid gap-4",children:[S?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:S}):null,k?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:k}):null,A?null:t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3 text-[var(--theme-fg-muted)]",children:"No session settings are available."})]}):t.jsx("div",{className:"thread-graph-settings-global-content",children:N})})]})]})}function Fe(A=!1){return t.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:t.jsxs("section",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs("div",{className:`mb-3 flex items-center gap-2 px-2 text-xs font-medium tracking-normal text-[var(--theme-fg-muted)] ${A?"justify-center":""}`,children:[t.jsx(B.Rows3,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:A?"sr-only":"",children:"Rooms"}),!A&&n?t.jsx("span",{className:"ml-auto text-xs text-[var(--theme-fg-muted)]",children:"Refreshing..."}):null]}),t.jsxs("div",{className:"min-h-0 min-w-0 flex-1 overflow-x-hidden overflow-y-auto px-1",children:[a?t.jsx("div",{className:"rounded-xl border border-rose-500/30 bg-rose-500/10 px-3 py-3 text-sm text-rose-900 dark:text-rose-100",children:a}):null,!a&&De.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,De.length>0?t.jsx(mp,{threads:De,currentThreadId:p,currentWorkspaceId:b,workspaceLabels:L,onOpenThread:V,collapsed:A,...ee?{onBeginRenameThread:ut}:{},showDeleteButton:!!W,...J?{getThreadHref:J}:{},...Q?{renderThreadLink:Q}:{},...W?{onDeleteThread:W}:{}}):null]})]})})}function Ke(){return T?t.jsxs("div",{className:"thread-workspace-panel relative flex h-full min-h-0 flex-col overflow-hidden rounded-[12px] border",children:[t.jsx("button",{type:"button",onClick:()=>ce(!0),className:"thread-workspace-collapse-tab thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(B.ChevronsRight,{className:"h-4 w-4"})}),G?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:G})}):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:K}),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:[G,t.jsx("button",{type:"button",onClick:()=>ce(!0),className:"thread-workspace-small-toggle thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(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:v??b??"All threads"})]})]})})]})}const lt=!!T,vt=s==="mobile"||s==="responsive"&&Ce,it=vt,Nt=it&&!te,Ct=!!(R||P)?t.jsx("a",{href:R??"#",onClick:A=>{P&&(A.preventDefault(),P())},className:"thread-icon-button inline-flex h-10 w-10 items-center justify-center rounded-full sm:h-9 sm:w-9",title:"Back to workspace","aria-label":"Back to workspace",children:t.jsx(B.ArrowLeft,{className:"h-4 w-4"})}):null;return t.jsxs(t.Fragment,{children:[t.jsx(rp,{effectiveTheme:de,layoutMode:s,themeMode:q,viewportConstrained:o,children:t.jsxs(np,{roomsRailCollapsed:ie,children:[t.jsx(ap,{open:te,onClose:()=>be(!1)}),t.jsxs(sp,{collapsed:ie,mobileOpen:te,children:[t.jsx("div",{className:`thread-rooms-rail-header flex h-[calc(3rem+env(safe-area-inset-top))] shrink-0 items-end border-b border-[var(--theme-border)] px-4 pb-2 sm:h-16 sm:items-center sm:pb-0 ${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:()=>ye(A=>!A),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:(v??"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: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 ${ie?"thread-desktop-collapsed-hidden":""}`,children:[tt(),Ct,t.jsx("button",{type:"button",onClick:()=>be(!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:Ye(`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(op,{children:[t.jsx(lp,{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:[Nt?t.jsx("button",{type:"button",onClick:()=>be(!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:[t.jsx("h1",{className:"min-w-0 truncate text-sm font-semibold leading-tight text-[var(--theme-fg)] sm:text-base",title:g??"Shared Workspace",children:g??"Shared Workspace"}),t.jsxs("div",{className:"relative mt-0.5 flex min-w-0 items-center gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{Te(A=>!A)},"aria-expanded":ge,"aria-haspopup":"dialog",className:"thread-topbar-meta-row flex min-w-0 max-w-full items-center gap-1 text-left text-[11px] leading-none sm:text-xs",title:"Session and usage",children:[t.jsx("span",{className:"shrink-0",children:"Room"}),t.jsx("span",{className:"truncate font-mono",children:et})]}),ge?t.jsxs("div",{className:"thread-topbar-details-popover absolute left-0 top-[calc(100%+0.5rem)] z-50 w-[min(28rem,calc(100vw-1.5rem))] rounded-lg border p-2.5 shadow-lg",role:"dialog","aria-label":"Session and usage",children:[t.jsxs("button",{type:"button",onClick:()=>{var A;Ve&&((A=navigator.clipboard)==null||A.writeText(Ve))},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:Ve})]}),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:pt})]})]}):null]})]})]}),t.jsxs("div",{className:"relative z-[1] inline-flex shrink-0 items-center gap-2",children:[w||y?t.jsxs("div",{className:"thread-graph-topbar-actions thread-desktop-only-inline-flex items-center rounded-lg border p-0.5 shadow-none",children:[w,y]}):null,it&&w?t.jsx("div",{className:"thread-mobile-only-inline-flex",children:w}):null,it&<?t.jsx("button",{type:"button",onClick:()=>ue(A=>A==="workspace"?"chat":"workspace"),"aria-label":X==="workspace"?"Show chat":"Show workspace",title:X==="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:X==="workspace"?t.jsx(B.MessageSquare,{className:"h-4 w-4"}):t.jsx(B.Folder,{className:"h-4 w-4"})}):null,it?f:null,it&&h?Ye("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(ip,{children:lt&&!Ae?vt?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 ${X==="chat"?"block":"thread-mobile-chat-hidden"}`,children:E}),t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${X==="workspace"?"block":"thread-mobile-workspace-hidden"}`,children:Ke()})]}):t.jsxs(An,{direction:"horizontal",className:"thread-split-container thread-graph-shell-resizable thread-graph-shell-desktop-split h-full min-h-0 overflow-hidden",children:[t.jsx(sr,{defaultSize:47,minSize:30,maxSize:75,className:"thread-split-chat-pane min-w-0 overflow-hidden",children:E}),t.jsx($n,{className:"thread-resize-handle w-2 bg-transparent after:w-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(sr,{defaultSize:53,minSize:30,maxSize:70,className:"thread-split-workspace-pane min-w-0 overflow-hidden",children:Ke()})]}):t.jsxs("div",{className:"thread-split-container relative h-full min-h-0 overflow-hidden",children:[lt&&Ae?t.jsx("button",{type:"button",onClick:()=>ce(!1),className:"thread-workspace-expand-fab thread-desktop-only-inline-flex",title:"Expand workspace","aria-label":"Expand workspace",children:t.jsx(B.ChevronsLeft,{className:"h-4 w-4"})}):null,E]})})]})]})}),t.jsx(tp,{open:ve!==null,title:"Rename Thread",label:"Thread Title",value:_e,busy:$e!==null,onChange:He,onCancel:M,onSubmit:()=>ve?ht(ve):void 0})]})}function fp({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?Zr.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 gp=[/^(?: {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],xp=/^(?:\|?[^|\n]+\|[^|\n]+(?:\|[^|\n]+)*\|?\s*\n\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$)/m,bp=/!?\[[^\]\n]+\]\([^)]+\)/,vp=/`[^`\n]+`/,kp=/(?:\*\*[^*\n]+\*\*|__[^_\n]+__)/,wp=/(^|[^\w])(?:\*[^*\n]+\*|_[^_\n]+_)(?=[^\w]|$)/,yp=/~~[^~\n]+~~/;function jp(e){const r=e.trim();return r?gp.some(n=>n.test(r))||xp.test(r)?!0:/[`[\]*_~!]/.test(r)?bp.test(r)||vp.test(r)||kp.test(r)||wp.test(r)||yp.test(r):!1:!1}nn();function Kn(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 da(e=[]){const r=Kn(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 ca=c.createContext(da());function ha(){return c.useContext(ca)??da()}Lr();function hl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function bs(e){return hl(e)?Object.entries(e):e==null||e===""?[]:[["value",e]]}function ul(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 Np(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)}):ul(r)}function vs({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(()=>bs(o),[o]),i=c.useMemo(()=>bs(a),[a]),d=c.useMemo(()=>typeof o=="string"?o.length>0:hl(o)?["stdout","stderr","result"].some(f=>{const p=o[f];return typeof p=="string"&&p.length>0}):!1,[o]),h=n==="pending"||d,[u,m]=c.useState(h?"item-1":void 0);return c.useEffect(()=>{h&&m("item-1")},[e,h]),t.jsx("div",{className:"thread-graph-tool-call my-2 w-full font-sans not-prose",children:t.jsx(Sr,{type:"single",collapsible:!0,onValueChange:f=>m(f||void 0),className:"thread-graph-tool-accordion w-full overflow-hidden rounded-lg border",...u!==void 0?{value:u}:{},children:t.jsxs(Tr,{value:"item-1",className:"border-0",children:[t.jsx(an,{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(Er,{className:"thread-graph-tool-content px-4 pb-4 pt-1",children:[t.jsxs("section",{children:[t.jsx("h4",{children:"Parameters"}),t.jsxs("div",{className:"thread-graph-tool-json",children:["{",t.jsx("br",{}),i.length>0?i.map(([f,p],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',f,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),ul(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:": "}),Np(f,p),g<l.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},f)),"}"]})]}):null]})]})})})}var ks=null;function Cp(){return ks??(ks=Promise.all([Xe(()=>import("./core-DODVy7wn.js"),__vite__mapDeps([0,1,2])),Xe(()=>import("./engine-javascript-DBd1bXLz.js"),[]),Xe(()=>import("./ayu-light-BA47KaF1.js"),[]),Xe(()=>import("./ayu-dark-DYE7WIF3.js"),[]),Xe(()=>import("./javascript-wDzz0qaB.js"),[]),Xe(()=>import("./typescript-BPQ3VLAy.js"),[]),Xe(()=>import("./tsx-COt5Ahok.js"),[]),Xe(()=>import("./jsx-g9-lgVsj.js"),[]),Xe(()=>import("./python-B6aJPvgy.js"),[]),Xe(()=>import("./json-Cp-IABpG.js"),[]),Xe(()=>import("./shellscript-CEILq0vU.js").then(e=>e.b),[]),Xe(()=>import("./shellscript-CEILq0vU.js").then(e=>e.s),[]),Xe(()=>import("./yaml-Buea-lGh.js"),[]),Xe(()=>import("./toml-vGWfd6FD.js"),[]),Xe(()=>import("./markdown-Cvjx9yec.js"),[]),Xe(()=>import("./html-pp8916En.js"),__vite__mapDeps([3,4,5])),Xe(()=>import("./css-CLj8gQPS.js"),[]),Xe(()=>import("./sql-CRqJ_cUM.js"),[]),Xe(()=>import("./csv-fuZLfV_i.js"),[])]).then(([{createHighlighterCore:e},{createJavaScriptRegexEngine:r},n,a,o,s,l,i,d,h,u,m,f,p,g,b,v,x,j])=>e({engine:r(),themes:[n.default,a.default],langs:[o.default,s.default,l.default,i.default,d.default,h.default,u.default,m.default,f.default,p.default,g.default,b.default,v.default,x.default,j.default]}))),ks}function sn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function qn(e){if(!e)return{};if(sn(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 Xn(){return{finalResult:null,stdout:"",stderr:""}}function Sp(e){return typeof e=="string"?{result:e}:e}function ml(e){const r=sn(e.finalResult)?{...e.finalResult}:e.finalResult!=null?{result:e.finalResult}:{};return e.stdout&&(r.stdout=e.stdout),e.stderr&&(r.stderr=e.stderr),!("status"in r)&&(e.stdout||e.stderr)&&(r.status="pending"),r}function ws(e){if(!e)return"pending";if(!sn(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 Tp(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=Sp(d.result),m=r.get(h)??Xn();return sn(u)&&u.status==="stream"&&typeof u.chunk=="string"?u.stream==="stderr"?m.stderr+=u.chunk:m.stdout+=u.chunk:m.finalResult=u,r.set(h,m),""}catch{return l}}),o=/```tool-call\s*([\s\S]*?)\s*```/g;return{processedContent:a.replace(o,(l,i)=>{try{const d=JSON.parse(i),h=d.call_id,u=d.tool;if(typeof u!="string")return l;const m=qn(d.args);if(typeof h=="string"&&r.has(h)){const f=ml(r.get(h)??Xn());return`\`\`\`tool-merged
|
|
3656
|
+
`,ds="MCP entry written to provider config. Restart the backend if it does not appear immediately.";function Gm({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,k]=c.useState(null),[x,j]=c.useState(null),w=c.useCallback(()=>{k(null),j(null)},[]),y=c.useCallback(async()=>{if(!e||!r)throw new Error("Provider config editing is unavailable for this thread.");const M=await r();return f(M.path),M},[e,r]),v=c.useCallback(async M=>{if(!e||!n)throw new Error("Provider config editing is unavailable for this thread.");const R=await n(M);return f(R.path),R},[e,n]),S=c.useCallback(async()=>{const M=Su(s),R=i.trim();if(!M){k("MCP name must use only letters, numbers, underscore, or hyphen.");return}if(!/^https?:\/\//i.test(R)){k("HTTP MCP URL must start with http:// or https://");return}g(!0),k(null),j(null);try{const Q=await y(),$=rs(Q.content,M,Eu(M,R));await v($),j(ds),a("list"),l(""),d(""),o==null||o()}catch(Q){k(Q instanceof Error?Q.message:"Unable to update provider config.")}finally{g(!1)}},[y,s,i,o,a,v]),N=c.useCallback(async()=>{g(!0),k(null),j(null);try{await y(),u(M=>M||Bm),a("stdio")}catch(M){k(M instanceof Error?M.message:"Unable to load provider config.")}finally{g(!1)}},[y,a]),I=c.useCallback(async()=>{const M=Tu(h);if(!M){k("The raw MCP block must start with a header like [mcp_servers.name].");return}g(!0),k(null),j(null);try{const R=await y(),Q=rs(R.content,M,h);await v(Q),j(ds),a("list"),o==null||o()}catch(R){k(R instanceof Error?R.message:"Unable to update provider config.")}finally{g(!1)}},[y,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:w,prepareRawMcpBlock:N,saveHttpMcp:S,saveRawMcpBlock:I}}function Fm({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 Hm(e,r){const{attachment:n}=e,a=document.createElement("span");if(a.dataset.segmentType="attachment",a.dataset.clientId=n.clientId,a.dataset.placeholder=n.placeholder,a.contentEditable="false",a.className="thread-composer-attachment-chip mx-[0.12rem] inline-flex max-w-full align-baseline",n.kind==="photo"){a.classList.add("thread-composer-attachment-chip-photo","rounded-[0.95rem]","border","border-sky-300/35","bg-sky-300/10","p-1","shadow-sm","shadow-stone-950/20");const l=r[n.clientId];if(l){const d=document.createElement("img");d.src=l,d.alt=n.originalName||"Pasted image",d.className="thread-composer-attachment-thumb h-[4.5rem] w-[6rem] rounded-[0.7rem] bg-stone-950 object-contain",d.draggable=!1,a.append(d)}else{const d=document.createElement("span");d.className="thread-composer-attachment-thumb inline-block h-[4.5rem] w-[6rem] rounded-[0.7rem] bg-stone-900/80",d.setAttribute("aria-hidden","true"),a.append(d)}const i=document.createElement("span");return i.className="thread-composer-attachment-caption ml-2 inline-flex max-w-[8rem] items-center text-[10px] font-medium tracking-[0.08em] text-sky-50",i.textContent=as(n),a.append(i),a}a.classList.add("items-center","gap-2","rounded-[0.95rem]","border","border-emerald-300/35","bg-emerald-300/10","px-2.5","py-2","text-[10px]","font-medium","tracking-[0.08em]","text-emerald-50","shadow-sm","shadow-stone-950/20");const o=document.createElement("span");o.className="inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-emerald-200/25 bg-emerald-300/12 text-[9px]",o.textContent="FILE";const s=document.createElement("span");return s.className="inline-flex max-w-[10rem] truncate",s.textContent=as(n),a.append(o,s),a}function Om(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(Hm(a,r))}return n}function Wm({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,k=f()!==n||u.current!==s||m.current!==l;k&&(g.replaceChildren(Om(a,o)),u.current=s,m.current=l),b!==null?(g.focus(),am(g,d.current)||p(b),h.current=b):document.activeElement===g&&k&&p(h.current),i.current=null,d.current=[]},[o,l,r,s,n,e,a,d,i,u,m,p,h,f])}function Um({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 Vm({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:k,onDragLeave:x,onDrop:j}){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:k,onDragLeave:x,onDrop:j,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(jt,{type:"button",variant:"ghost",size:"icon-xs","aria-label":s,title:s,onClick:w=>{w.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 Km({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 qm({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:k,onInterrupt:x,onPromptInput:j,onPromptPaste:w,onPromptKeyDown:y,onPromptKeyUp:v,onPromptMouseUp:S,onPromptBlur:N,onPromptDragEnter:I,onPromptDragOver:M,onPromptDragLeave:R,onPromptDrop:Q,onGoalTokenBudgetChange:$,onCancelGoal:Y,onShellPromptChange:Z}){return{promptSlot:e?null:t.jsx(Vm,{promptRef:r,prompt:n,disabled:a,promptPlaceholder:o,canInterrupt:s,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,onInterrupt:x,onInput:j,onPaste:w,onKeyDown:y,onKeyUp:v,onMouseUp:S,onBlur:N,onDragEnter:I,onDragOver:M,onDragLeave:R,onDrop:Q}),goalSlot:u&&!e?t.jsx(Um,{tokenBudget:m,error:f,onTokenBudgetChange:$,onCancel:Y}):null,shellPromptSlot:e?t.jsx(Km,{prompt:n,promptPlaceholder:o,promptRegionClassName:i,promptInputClassName:h,interruptLabel:l,canInterrupt:s,sendButtonLabel:b,sendButtonClassName:k,sendDisabled:p||g,onPromptChange:Z,onPromptKeyDown:y,onInterrupt:x}):null}}function Xm({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=ju({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 Ym({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:k,settingsBusy:x,compactBusy:j,forkBusy:w,fastMode:y,goalComposeMode:v,goalBusy:S,goalStatus:N,activeView:I,disabled:M,model:R,modelOptions:Q,modelContextTitle:$,contextUsage:Y,reasoningEffort:Z,supportedEfforts:P,displayedCollaborationMode:te,sandboxMode:oe,sendButtonLabel:T,sendButtonClassName:re,modelControlsDisabled:B,effortControlsDisabled:J,effortControlTitle:K,forkTurnOptionsState:L,skillsState:q,goalState:G,goalHistory:E,copiedSkillName:C,hooksPanelMode:W,hooksState:H,hookConfigBusy:se,hookConfigError:V,hookConfigSuccess:de,editingHookTarget:ee,hookScope:be,hookEventName:ie,hookMatcher:ye,hookCommand:Ae,hookTimeoutSec:ce,hookStatusMessage:Ce,mcpPanelMode:Le,mcpState:X,mcpConfigPath:ue,mcpConfigError:ve,mcpConfigSuccess:ke,mcpConfigBusy:$e,mcpHttpName:He,mcpHttpUrl:_e,mcpRawBlock:ze,capabilities:F,shellControlState:le,onToggleView:we,onDismissPromptFocus:z,onSetOpenMenu:O,onToolboxItemClick:ne,onSetSlashPanelView:ge,onViewGoals:Te,onUpdateGoal:Ee,onOpenForkTurns:fe,onForkLatest:De,onForkTurn:Be,onCopySkillInvokeName:et,onResetHookForm:Ve,onSetHooksPanelMode:pt,onClearHookConfigStatus:nt,onSetEditingHookTarget:We,onSetHookScope:ot,onSetHookEventName:ht,onSetHookMatcher:ut,onSetHookCommand:A,onSetHookTimeoutSec:U,onSetHookStatusMessage:xe,onSaveHook:je,onStartEditingHook:Ne,onTrustHook:Ye,onUntrustHook:tt,onSetMcpPanelMode:Fe,onClearMcpConfigStatus:Ke,onSetMcpHttpName:lt,onSetMcpHttpUrl:vt,onSetMcpRawBlock:it,onPrepareRawMcpBlock:Nt,onSaveHttpMcp:Rt,onSaveRawMcpBlock:Ct,onPickPhoto:_,onPickFile:pe,onUpdateSettings:Re,onPasteShell:Ge,onCopyShell:Ue,onClearShell:ct,onShellControl:kt}){const qt=e?null:{open:o==="slash",slashPanelView:g,availableToolboxItems:b,busy:k,forkBusy:w,forkTurnOptionsState:L,skillsState:q,goalState:G,goalHistory:E,goalBusy:S,copiedSkillName:C,hooksPanelMode:W,hooksState:H,hostConfigFilesAvailable:F.hostConfigFiles,hookTrustAvailable:F.hookTrust,hookConfigBusy:se,hookConfigError:V,hookConfigSuccess:de,editingHookTarget:ee,hookScope:be,hookEventName:ie,hookMatcher:ye,hookCommand:Ae,hookTimeoutSec:ce,hookStatusMessage:Ce,mcpPanelMode:Le,mcpState:X,mcpConfigEditing:F.mcpConfigEditing,mcpConfigPath:ue,mcpConfigError:ve,mcpConfigSuccess:ke,mcpConfigBusy:$e,mcpHttpName:He,mcpHttpUrl:_e,mcpRawBlock:ze,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,onToggle:()=>O(at=>at==="slash"?null:"slash"),onToolboxItemClick:ne,toolboxItemDisabled:at=>Ju(at,{settingsBusy:x,compactBusy:j,busy:k,forkBusy:w}),toolboxItemClassName:at=>Qu(at,{fastMode:y,goalComposeMode:v,goalStatus:N,menuItemClassName:d}),toolboxItemStatus:at=>Zu(at,{fastMode:y,compactBusy:j,goalComposeMode:v,goalStatus:N,busy:k}),onSetSlashPanelView:ge,onViewGoals:Te,onUpdateGoal:Ee,onOpenForkTurns:fe,onForkLatest:De,onForkTurn:Be,onCopySkillInvokeName:et,onResetHookForm:Ve,onSetHooksPanelMode:pt,onClearHookConfigStatus:nt,onSetEditingHookTarget:We,onSetHookScope:ot,onSetHookEventName:ht,onSetHookMatcher:ut,onSetHookCommand:A,onSetHookTimeoutSec:U,onSetHookStatusMessage:xe,onSaveHook:je,onStartEditingHook:Ne,onTrustHook:Ye,onUntrustHook:tt,onSetMcpPanelMode:Fe,onClearMcpConfigStatus:Ke,onSetMcpHttpName:lt,onSetMcpHttpUrl:vt,onSetMcpRawBlock:it,onPrepareRawMcpBlock:Nt,onSaveHttpMcp:Rt,onSaveRawMcpBlock:Ct},Xt=e?null:{open:o==="attachments",iconButtonClassName:l,menuClassName:i,menuItemClassName:d,onToggle:()=>O(at=>at==="attachments"?null:"attachments"),onPickPhoto:_,onPickFile:pe},Mt=e?null:{openMenu:o,model:R,modelOptions:Q,modelContextTitle:$,contextUsage:Y,reasoningEffort:Z,supportedEfforts:P,displayedCollaborationMode:te,sandboxMode:oe,planModeAvailable:F.planMode,sandboxModeAvailable:F.sandboxMode,settingsBusy:x,goalComposeMode:v,goalBusy:S,activeView:I,disabled:M,fastMode:y,sendButtonLabel:T,sendButtonClassName:re,modelControlsDisabled:B,effortControlsDisabled:J,effortControlTitle:K,inlineToggleClassName:m,menuItemClassName:d,planToggleActiveClassName:f,sendButtonBaseClassName:p,onSetOpenMenu:O,onUpdateSettings:Re};return{isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:o,toolbarClassName:s,iconButtonClassName:l,slashToolboxProps:qt,attachmentMenuProps:Xt,settingsToolbarProps:Mt,shellToolsPanelProps:o==="shellTools"?{busy:k,shellControlState:le,onPaste:Ge,onCopy:Ue,onClear:ct,onShellControl:kt}:null,shellControlState:le,onToggleView:we,onDismissPromptFocus:z,onSetOpenMenu:O}}function Un({activeView:e,edgeToEdgeMobile:r=!1,busy:n=!1,settingsBusy:a=!1,compactBusy:o=!1,error:s,model:l=null,reasoningEffort:i=null,fastMode:d=!1,collaborationMode:h="default",sandboxMode:u=null,hideSandboxModeControl:m=!1,modelOptions:f=[],contextUsage:p=null,capabilities:g=null,toolboxItems:b=null,hookCommandTemplates:k=null,mcpConfigFormat:x="none",followTail:j=!1,threadConnected:w=!0,shellAvailable:y=!0,disabled:v=!1,disabledPlaceholder:S,shellControlState:N=null,draftPrompt:I,draftAttachments:M,onPickAttachment:R,skillsState:Q={status:"idle",data:null,error:null},mcpState:$={status:"idle",data:null,error:null},hooksState:Y={status:"idle",data:null,error:null},goalState:Z={status:"idle",data:null,error:null},goalHistory:P=[],forkTurnOptionsState:te={status:"idle",data:null,error:null},onDraftChange:oe,onSubmit:T,onInterrupt:re,onCompact:B,onOpenSkills:J,onOpenMcp:K,onOpenHooks:L,onCreateHook:q,onUpdateHook:G,onTrustHook:E,onUntrustHook:C,onOpenGoal:W,onPrepareGoalSubmit:H,onUpdateGoal:se,onOpenForkTurns:V,onForkLatest:de,onForkTurn:ee,onReadProviderConfig:be,onWriteProviderConfig:ie,onToggleFollow:ye,canJumpToPreviousTurn:Ae,onJumpToPreviousTurn:ce,canJumpToNextTurn:Ce,onJumpToNextTurn:Le,subscriptionUsage:X,onUpdateSettings:ue,onToggleView:ve,onShellCopy:ke,onShellControl:$e,canInterrupt:He=!1}){var ja;const[_e,ze]=c.useState(null),[F,le]=c.useState("root"),we=c.useRef(!1),[z,O]=c.useState("list"),ne=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)&&!!be&&!!ie,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,be,ie]),ge=c.useMemo(()=>Xu(b,ne),[ne,b]),Te=c.useRef(null),Ee=c.useRef(null),fe=c.useRef(null),De=c.useRef(null),Be=c.useRef(null),et=c.useRef([]),Ve=c.useRef(null),pt=c.useRef(""),nt=c.useRef(0),We=e==="shell",ot=y||We,ht=!!(We&&(N!=null&&N.isMobileShell)),ut=(N==null?void 0:N.promptLabel)??null,[A,U]=c.useState(!1),[xe,je]=c.useState(0),{prompt:Ne,attachments:Ye,isDraftControlled:tt,updateDraft:Fe,flushControlledDraftToHost:Ke}=Mm({isShellView:We,draftPrompt:I,draftAttachments:M,onDraftChange:oe}),lt=Pm({attachments:Ye,isShellView:We}),{displayedCollaborationMode:vt,updateSettings:it}=Xm({collaborationMode:h,onUpdateSettings:ue,closeMenu:()=>ze(null)}),{forkBusy:Nt,forkLatest:Rt,forkTurn:Ct}=Am({slashPanelView:F,onForkLatest:de,onForkTurn:ee,closeMenu:()=>ze(null)}),{hooksPanelMode:_,hookScope:pe,hookEventName:Re,hookMatcher:Ge,hookCommand:Ue,hookTimeoutSec:ct,hookStatusMessage:kt,editingHookTarget:qt,hookConfigBusy:Xt,hookConfigError:Mt,hookConfigSuccess:cr,setHooksPanelMode:at,setEditingHookTarget:dn,setHookScope:cn,setHookEventName:Il,setHookMatcher:zl,setHookCommand:Pl,setHookTimeoutSec:Rl,setHookStatusMessage:Ml,clearHookConfigStatus:pa,resetHookForm:Al,startEditingHook:_l,saveHook:$l,trustHook:Dl,untrustHook:Bl}=Dm({slashPanelView:F,hookCommandTemplates:k,onCreateHook:q,onUpdateHook:G,onTrustHook:E,onUntrustHook:C}),{goalComposeMode:hr,goalTokenBudget:Gl,goalBusy:hn,goalLocalError:Fl,setGoalTokenBudget:Hl,submitGoal:Ol,enterGoalComposeMode:Wl,exitGoalComposeMode:fa}=_m({prompt:Ne,goalTokenBudgetSource:Z.data,promptRef:Ee,onOpenGoal:W,onPrepareGoalSubmit:H,onUpdateGoal:se,updateDraft:Fe,closeMenu:()=>ze(null),resetSlashPanel:()=>le("root")}),{mcpHttpName:Ul,mcpHttpUrl:Vl,mcpRawBlock:Kl,mcpConfigPath:ql,mcpConfigBusy:Xl,mcpConfigError:Yl,mcpConfigSuccess:Zl,setMcpHttpName:Jl,setMcpHttpUrl:Ql,setMcpRawBlock:ei,clearMcpConfigStatus:ga,prepareRawMcpBlock:ti,saveHttpMcp:ri,saveRawMcpBlock:ni}=Gm({hostConfigFilesAvailable:ne.hostConfigFiles,onReadProviderConfig:be,onWriteProviderConfig:ie,setMcpPanelMode:O,onOpenMcp:K}),{copiedSkillName:ai,copySkillInvokeName:si}=Fm({openMenu:_e,setOpenMenu:ze,slashPanelView:F,setSlashPanelView:le,setMcpPanelMode:O,clearMcpConfigStatus:ga,clearHookConfigStatus:pa}),oi=c.useCallback(ae=>{Fe(Se=>{if(typeof ae=="function"){const Me=ae(Se.prompt,Se.attachments);return{prompt:Me.prompt,attachments:Me.attachments??Se.attachments}}return{prompt:ae,attachments:Se.attachments}})},[Fe]),un=c.useMemo(()=>f.find(ae=>ae.model===l)??null,[l,f]),li=Lu(l,p),xa=(un==null?void 0:un.supportedReasoningEfforts)??[],ii=c.useMemo(()=>pu(Ne,Ye),[Ye,Ne]),di=c.useMemo(()=>Object.entries(lt).sort(([ae],[Se])=>ae.localeCompare(Se)).map(([ae,Se])=>`${ae}:${Se}`).join("|"),[lt]);function ci(ae,Se){Se.stopPropagation();const Me=Yu(ae,{fastMode:d,goalComposeMode:hr});switch(Me.type){case"toggleFast":it({fastMode:Me.fastMode});break;case"runCompact":ze(null),B==null||B();break;case"enterGoalCompose":Wl();break;case"exitGoalCompose":fa(),ze(null);break;case"openPanel":le(Me.panel),Me.panel==="skills"?J==null||J():Me.panel==="mcp"?K==null||K():Me.panel==="hooks"&&(L==null||L());break;case"insertPrompt":fn(Me.text),le("root"),ze(null);break}}function Yt(){const ae=Ee.current;return ae?rm(ae):null}const hi=c.useCallback(ae=>{const Se=Ee.current;!Se||!ae||nm(Se,ae)},[]),mn=c.useCallback(()=>{const ae=Ee.current;return ae?sl(ae):Ne},[Ne]),{appendAttachments:pn,appendDroppedAttachments:ba}=zm({prompt:Ne,attachments:Ye,updateDraft:Fe,getSelection:Yt,selectionSnapshotRef:Ve,pendingSelectionRef:Be,pendingInsertedAttachmentIdsRef:et,onInserted:()=>ze(null)}),va=c.useCallback((ae,Se)=>{var Me;if(At(),R){R({kind:ae,appendAttachments:(Je,st=ae)=>pn(Je,st),defaultPick:()=>{var Je;return(Je=Se.current)==null?void 0:Je.click()}});return}(Me=Se.current)==null||Me.click()},[pn,At,R]);function fn(ae){if(!ae)return;const Se=Yt()??Ve.current,Me=(Se==null?void 0:Se.start)??Ne.length,Je=(Se==null?void 0:Se.end)??Me,st=mu(ae),Zt=`${Ne.slice(0,Me)}${st}${Ne.slice(Je)}`;Fe(Vi=>({prompt:Zt,attachments:Vi.attachments}));const _t=Me+st.length;Be.current={start:_t,end:_t},Ve.current={start:_t,end:_t}}Wm({promptRef:Ee,isShellView:We,prompt:Ne,promptSegments:ii,attachmentPreviewUrls:lt,previewSignature:di,editorSanitizeNonce:xe,pendingSelectionRef:Be,pendingInsertedAttachmentIdsRef:et,selectionSnapshotRef:Ve,renderedPreviewSignatureRef:pt,renderedSanitizeNonceRef:nt,serializeEditorPrompt:mn,restoreSelection:hi});function At(){var ae;(ae=Ee.current)==null||ae.blur(),document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.blur()}async function ui(){var ae;if(At(),ze(null),!!((ae=navigator.clipboard)!=null&&ae.readText))try{const Se=await navigator.clipboard.readText();fn(Se)}catch{return}}async function ka(){if(!we.current){we.current=!0;try{if(tt&&Ke(),hr&&!We){await Ol();return}const ae=vu({prompt:Ne,attachments:Ye,isShellView:We});if(!ae||await T(ae)===!1)return;Fe(()=>({prompt:"",attachments:[]}))}finally{we.current=!1}}}async function mi(ae){ae.preventDefault(),await ka()}function pi(){const ae=mn(),Se=Yt();Ve.current=Se;const Me=Ee.current;(Me?tm(Me):!1)&&(Be.current=Se,je(st=>st+1)),Fe(st=>({prompt:ae,attachments:st.attachments.filter(Zt=>ae.includes(Zt.placeholder))}),"deferred")}function fi(ae){var Je,st,Zt,_t;const Se=On((Je=ae.clipboardData)==null?void 0:Je.items,(st=ae.clipboardData)==null?void 0:st.files),Me=ku({files:Se,plainText:((Zt=ae.clipboardData)==null?void 0:Zt.getData("text/plain"))??"",htmlText:((_t=ae.clipboardData)==null?void 0:_t.getData("text/html"))??"",htmlToText:em});Me.preventDefault&&ae.preventDefault(),Me.type==="insert-text"?fn(Me.text):Me.type==="append-files"&&ba(Me.files)}function gi(ae){var Me,Je;const Se=es(ns((Me=ae.dataTransfer)==null?void 0:Me.items,(Je=ae.dataTransfer)==null?void 0:Je.files));Se.preventDefault&&ae.preventDefault(),Se.activateDragTarget&&U(!0)}function xi(ae){var Me,Je;const Se=es(ns((Me=ae.dataTransfer)==null?void 0:Me.items,(Je=ae.dataTransfer)==null?void 0:Je.files));Se.preventDefault&&ae.preventDefault(),Se.activateDragTarget&&ae.dataTransfer&&(ae.dataTransfer.dropEffect="copy"),Se.activateDragTarget&&U(!0)}function bi(ae){ae.currentTarget.contains(ae.relatedTarget)||U(!1)}function vi(ae){var Je,st;const Se=On((Je=ae.dataTransfer)==null?void 0:Je.items,(st=ae.dataTransfer)==null?void 0:st.files),Me=wu(Se);Me.preventDefault&&ae.preventDefault(),Me.type==="accept-files"&&(U(!1),ba(Me.files??[]))}function ki(ae){if(ae.key==="Enter"&&ae.repeat){ae.preventDefault();return}if(e==="chat"&&ae.key==="/"&&!ae.metaKey&&!ae.ctrlKey&&!ae.altKey&&!n&&!v&&ge.length>0&&mn().trim().length===0){ae.preventDefault(),le("root"),ze("slash");return}const Se=yu({key:ae.key,metaKey:ae.metaKey,ctrlKey:ae.ctrlKey,busy:n,disabled:v});Se.preventDefault&&ae.preventDefault(),Se.submit&&ka()}const{promptPlaceholder:wi,interruptLabel:yi,sendButtonLabel:wa,sendButtonClassName:ya,modelControlsDisabled:ji,effortControlsDisabled:Ni,effortControlTitle:Ci}=Ru({goalComposeMode:hr,goalBusy:hn,threadConnected:w,busy:n,isShellView:We,disabledPlaceholder:S,settingsBusy:a,supportedEffortCount:xa.length,fastMode:d}),{composerLayerClassName:Si,formClassName:Ti,composerShellClassName:Ei,composerToolbarClassName:Li,composerIconButtonClassName:Ii,composerMenuClassName:zi,composerMenuItemClassName:Pi,composerInlineToggleClassName:Ri,composerPanelButtonClassName:Mi,composerChipButtonClassName:Ai,composerPlanToggleActiveClassName:_i,composerSendButtonClassName:$i,composerPromptRegionClassName:Di,promptInputClassName:Bi,graphChatInputGroupClassName:Gi,graphChatInputClassName:Fi}=Mu({isShellView:We,edgeToEdgeMobile:r,isMobileShell:ht,openMenu:_e!==null,isDragTargetActive:A,busy:n}),Hi=Ym({isShellView:We,canToggleShellView:ot,isMobileShell:ht,shellPromptLabel:ut,openMenu:_e,toolbarClassName:Li,iconButtonClassName:Ii,menuClassName:zi,menuItemClassName:Pi,panelButtonClassName:Mi,chipButtonClassName:Ai,inlineToggleClassName:Ri,planToggleActiveClassName:_i,sendButtonBaseClassName:$i,slashPanelView:F,availableToolboxItems:ge,busy:n,settingsBusy:a,compactBusy:o,forkBusy:Nt,fastMode:d,goalComposeMode:hr,goalBusy:hn,goalStatus:(ja=Z.data)==null?void 0:ja.status,activeView:e,disabled:v,model:l,modelOptions:f,modelContextTitle:li,contextUsage:p,reasoningEffort:i,supportedEfforts:xa,displayedCollaborationMode:vt,sandboxMode:u,sendButtonLabel:wa,sendButtonClassName:ya,modelControlsDisabled:ji,effortControlsDisabled:Ni,effortControlTitle:Ci,forkTurnOptionsState:te,skillsState:Q,goalState:Z,goalHistory:P,copiedSkillName:ai,hooksPanelMode:_,hooksState:Y,hookConfigBusy:Xt,hookConfigError:Mt,hookConfigSuccess:cr,editingHookTarget:qt,hookScope:pe,hookEventName:Re,hookMatcher:Ge,hookCommand:Ue,hookTimeoutSec:ct,hookStatusMessage:kt,mcpPanelMode:z,mcpState:$,mcpConfigPath:ql,mcpConfigError:Yl,mcpConfigSuccess:Zl,mcpConfigBusy:Xl,mcpHttpName:Ul,mcpHttpUrl:Vl,mcpRawBlock:Kl,capabilities:{hostConfigFiles:ne.hostConfigFiles,hookTrust:ne.hookTrust,mcpConfigEditing:ne.mcpConfigEditing,planMode:ne.planMode,sandboxMode:m?!1:ne.sandboxMode},shellControlState:N,onToggleView:ve,onDismissPromptFocus:At,onSetOpenMenu:ze,onToolboxItemClick:ci,onSetSlashPanelView:le,onViewGoals:W,onUpdateGoal:se,onOpenForkTurns:()=>V==null?void 0:V(),onForkLatest:Rt,onForkTurn:Ct,onCopySkillInvokeName:si,onResetHookForm:Al,onSetHooksPanelMode:at,onClearHookConfigStatus:pa,onSetEditingHookTarget:dn,onSetHookScope:cn,onSetHookEventName:Il,onSetHookMatcher:zl,onSetHookCommand:Pl,onSetHookTimeoutSec:Rl,onSetHookStatusMessage:Ml,onSaveHook:$l,onStartEditingHook:_l,onTrustHook:Dl,onUntrustHook:Bl,onSetMcpPanelMode:O,onClearMcpConfigStatus:ga,onSetMcpHttpName:Jl,onSetMcpHttpUrl:Ql,onSetMcpRawBlock:ei,onPrepareRawMcpBlock:ti,onSaveHttpMcp:ri,onSaveRawMcpBlock:ni,onPickPhoto:()=>va("photo",fe),onPickFile:()=>va("file",De),onUpdateSettings:ae=>void it(ae),onPasteShell:()=>void ui(),onCopyShell:()=>{At(),ze(null),ke==null||ke()},onClearShell:()=>{At(),ze(null),T({prompt:"clear"})},onShellControl:ae=>{At(),ze(null),$e==null||$e(ae)}}),{promptSlot:Oi,goalSlot:Wi,shellPromptSlot:Ui}=qm({isShellView:We,promptRef:Ee,prompt:Ne,disabled:v,promptPlaceholder:wi,canInterrupt:He,interruptLabel:yi,composerPromptRegionClassName:Di,graphChatInputClassName:Fi,promptInputClassName:Bi,goalComposeMode:hr,goalTokenBudget:Gl,goalLocalError:Fl,goalBusy:hn,busy:n,sendButtonLabel:wa,sendButtonClassName:ya,onInterrupt:re,onPromptInput:pi,onPromptPaste:fi,onPromptKeyDown:ki,onPromptKeyUp:()=>{Ve.current=Yt()},onPromptMouseUp:()=>{Ve.current=Yt()},onPromptBlur:()=>{Ve.current=Yt(),U(!1),tt&&Ke()},onPromptDragEnter:gi,onPromptDragOver:xi,onPromptDragLeave:bi,onPromptDrop:vi,onGoalTokenBudgetChange:Hl,onCancelGoal:fa,onShellPromptChange:oi});return t.jsx(pm,{activeView:e,layerClassName:Si,formClassName:Ti,shellClassName:Ei,inputGroupClassName:Gi,error:s,followTail:j,photoInputRef:fe,fileInputRef:De,onAppendAttachments:pn,onToggleFollow:ye,canJumpToPreviousTurn:Ae,onJumpToPreviousTurn:ce,canJumpToNextTurn:Ce,onJumpToNextTurn:Le,subscriptionUsage:X,onSubmit:mi,formRef:Te,promptSlot:Oi,toolbarSlot:t.jsx(Em,{...Hi}),goalSlot:Wi,shellPromptSlot:Ui})}var Zm=c.createContext(null);function ll(){return c.useContext(Zm)}function xt(e){return e?new Date(e).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"}):"Time unavailable"}function Wt(e){return e?new Date(e).toLocaleString():"Time unavailable"}function Jm(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 Qm(e){switch(e){case"idle":return"ui-status-neutral";case"running":return"ui-status-info";case"interrupted":return"ui-status-warning";case"failed":case"system_error":return"ui-status-danger";case"not_loaded":return"ui-status-neutral"}}function il(e){switch(e){case"sending":return"Sending";case"completed":return"Completed";case"interrupted":return"Interrupted";case"failed":return"Failed";case"inProgress":return"Running"}}function ep({open:e,title:r,label:n,value:a,busy:o=!1,onChange:s,onCancel:l,onSubmit:i}){if(c.useEffect(()=>{if(!e)return;function h(u){u.key==="Escape"&&!o&&l()}return window.addEventListener("keydown",h),()=>{window.removeEventListener("keydown",h)}},[o,l,e]),!e)return null;function d(h){h.preventDefault(),i()}return Yr.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[95] flex items-center justify-center p-4 sm:p-6",children:[t.jsx("button",{type:"button","aria-label":"Close rename dialog",onClick:l,disabled:o,className:"absolute inset-0 bg-stone-950/78 backdrop-blur-sm disabled:cursor-not-allowed"}),t.jsxs("form",{role:"dialog","aria-modal":"true","aria-label":r,onSubmit:d,className:"relative z-[1] w-full max-w-md rounded-[1.6rem] border border-stone-700 bg-stone-900 p-5 shadow-2xl shadow-stone-950/40 sm:p-6",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium text-stone-100",children:r}),t.jsx("p",{className:"mt-1 text-sm text-stone-500",children:"Changes are saved only after confirmation."})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:l,disabled:o,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-stone-700 text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsxs("div",{className:"mt-5",children:[t.jsx("label",{htmlFor:"rename-dialog-input",className:"text-sm font-medium text-stone-200",children:n}),t.jsx("input",{id:"rename-dialog-input","aria-label":n,autoFocus:!0,value:a,onChange:h=>s(h.target.value),className:"mt-2 w-full rounded-2xl border border-stone-700 bg-stone-950 px-4 py-3 text-stone-100 outline-none transition focus:border-amber-300"})]}),t.jsxs("div",{className:"mt-5 flex items-center justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:l,disabled:o,className:"rounded-full border border-stone-700 px-4 py-2 text-sm font-medium text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),t.jsx("button",{type:"submit",disabled:o||!a.trim(),className:"ui-action-success rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:"Save"})]})]})]}),document.body)}function tp({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 rp({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 np({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 ap({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 sp({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 op({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 lp({children:e}){return t.jsx("div",{className:"thread-split-region min-h-0 flex-1 overflow-hidden p-0 sm:p-2",children:e})}Lo();Pt();function cs({...e}){return t.jsx(Ji,{"data-slot":"dialog",...e})}function hs({...e}){return t.jsx(Qi,{"data-slot":"dialog-trigger",...e})}function ip({...e}){return t.jsx(ad,{"data-slot":"dialog-portal",...e})}function dp({className:e,...r}){return t.jsx(sd,{"data-slot":"dialog-overlay",className:rt("fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",e),...r})}function us({children:e,className:r,showCloseButton:n=!0,...a}){return t.jsxs(ip,{"data-slot":"dialog-portal",children:[t.jsx(dp,{}),t.jsxs(ed,{"data-slot":"dialog-content",className:rt("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(td,{"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(D.XIcon,{}),t.jsx("span",{className:"sr-only",children:"Close"})]}):null]})]})}function ms({className:e,...r}){return t.jsx("div",{"data-slot":"dialog-header",className:rt("flex flex-col gap-2 text-center sm:text-left",e),...r})}function ps({className:e,...r}){return t.jsx(rd,{"data-slot":"dialog-title",className:rt("text-lg font-semibold leading-none",e),...r})}function fs({className:e,...r}){return t.jsx(nd,{"data-slot":"dialog-description",className:rt("text-sm text-muted-foreground",e),...r})}var cp=[{value:"system",label:"Follow system",icon:D.Monitor},{value:"dark",label:"Dark",icon:D.Moon},{value:"light",label:"Light",icon:D.Sun}];function hp({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],k=b&&!n?b:null,x=r===e.id;c.useEffect(()=>()=>{g.current!==null&&window.clearTimeout(g.current)},[]);async function j(){const N=e.providerSessionId;if(N)try{await navigator.clipboard.writeText(N),p("copied"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>p("idle"),1200)}catch{p("failed"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>p("idle"),1600)}}const w=()=>o(e.id),y=`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(D.MessageSquare,{className:"h-4 w-4"})}),t.jsxs("div",{className:`min-w-0 flex-1 ${m?"thread-desktop-collapsed-hidden":""}`,children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[t.jsx("p",{className:"thread-graph-room-card-title min-w-0 flex-1 truncate text-sm font-medium",title:e.title,children:e.title}),i&&!m?t.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),N.preventDefault(),i(e)},"aria-label":`Rename thread ${e.title}`,title:"Rename thread",className:"thread-card-quiet-button inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full transition",children:t.jsx(D.Pencil,{className:"h-3 w-3"})}):null,u&&e.providerSessionId?t.jsx("button",{type:"button","aria-label":"Copy session ID",title:f==="copied"?"Copied":f==="failed"?"Copy failed":"Copy session ID",onClick:N=>{N.stopPropagation(),N.preventDefault(),j()},className:"thread-card-quiet-button thread-card-session-copy-button inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition",children:t.jsx(D.Copy,{className:"h-3.5 w-3.5"})}):null]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2",children:[k?t.jsx("p",{className:"thread-graph-room-card-meta min-w-0 flex-1 truncate text-[11px] text-[var(--theme-fg-muted)]",title:k,children:k}):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 ${Qm(e.status)}`,children:Jm(e.status)}),t.jsx("time",{className:"shrink-0 text-[11px] text-[var(--theme-fg-muted)]",dateTime:e.lastTurnStartedAt??e.updatedAt,children:xt(e.lastTurnStartedAt??e.updatedAt)})]})]}),h&&d&&!m?t.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),N.preventDefault(),d(e)},"aria-label":`Delete thread ${e.title}`,className:"thread-card-danger-button shrink-0 rounded-full p-1 transition",title:"Delete thread",children:t.jsx(D.Trash2,{className:"h-3.5 w-3.5"})}):null]}),S=s==null?void 0:s(e.id);return l?t.jsx(t.Fragment,{children:l({thread:e,children:v,className:y,onClick:w})}):S?t.jsx("a",{href:S,onClick:N=>{N.preventDefault(),w()},title:m?e.title:void 0,className:y,children:v}):t.jsx("div",{role:"link",tabIndex:0,onClick:w,onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),w())},title:m?e.title:void 0,className:y,children:v})}function up({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(hp,{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 mp({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:k=null,sessionLabel:x=null,usageLabel:j=null,threadActionsButton:w,topbarActions:y,metaContent:v,settingsContent:S,globalSettingsContent:N,workspaceLabels:I={},workspaceReturnHref:M,onWorkspaceReturn:R,getThreadHref:Q,onOpenThread:$,getNewThreadHref:Y,newThreadHref:Z,newThreadLabel:P="New Chat",onNewThread:te,onNewThreadTitle:oe,renderNewThreadDialogContent:T,renderThreadLink:re,onCloseAppNavigation:B,onRenameThread:J,onDeleteThread:K,workspaceContent:L,workspaceTitle:q="Workspace",workspaceActions:G,children:E}){const C=ll(),W=typeof window<"u"?window.matchMedia("(max-width: 639px)").matches:s==="mobile",[H,se]=c.useState(()=>typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)").matches:!1),V=i??(C==null?void 0:C.themeMode)??"system",de=l??(C==null?void 0:C.effectiveTheme)??(V==="system"?H?"dark":"light":V),[ee,be]=c.useState(!1),[ie,ye]=c.useState(!1),[Ae,ce]=c.useState(!W),[Ce,Le]=c.useState(W),[X,ue]=c.useState("chat"),[ve,ke]=c.useState(null),[$e,He]=c.useState(""),[_e,ze]=c.useState(null),[F,le]=c.useState(!1),[we,z]=c.useState(""),[O,ne]=c.useState(!1),[ge,Te]=c.useState(!1),[Ee,fe]=c.useState("session");c.useEffect(()=>{if(typeof window>"u")return;const _=window.matchMedia("(max-width: 639px)"),pe=()=>{Le(_.matches)};return pe(),_.addEventListener("change",pe),()=>{_.removeEventListener("change",pe)}},[]),c.useEffect(()=>{if(typeof window>"u")return;const _=window.matchMedia("(prefers-color-scheme: dark)"),pe=()=>{se(_.matches)};return pe(),_.addEventListener("change",pe),()=>{_.removeEventListener("change",pe)}},[]);const De=c.useMemo(()=>[...b?e.filter(pe=>pe.workspaceId===b):e].sort((pe,Re)=>{if(pe.id===p)return-1;if(Re.id===p)return 1;const Ge=Date.parse(pe.lastTurnStartedAt??pe.updatedAt);return Date.parse(Re.lastTurnStartedAt??Re.updatedAt)-Ge}),[p,b,e]),Be=Z??(Y==null?void 0:Y(b)),et=k??b??"all",Ve=x??g??p??"default_session",pt=j??(r!=null&&r.state?`runtime ${r.state}`:"waiting for agent usage"),nt=d??(C==null?void 0:C.setThemeMode),We=!!nt,ot=()=>{be(!1),B==null||B()};async function ht(_){if(!J)return;const pe=$e.trim();if(pe){ze(_);try{await J(_,pe),ke(null),He("")}finally{ze(null)}}}function ut(_){ke(_.id),He(_.title)}function A(){ke(null),He("")}function U(_){$==null||$(_),ot()}function xe(){le(!1),z("")}function je(_){if(!Be||!_.trim())return Be;try{const pe=new URL(Be,window.location.origin);return pe.searchParams.set("title",_.trim()),`${pe.pathname}${pe.search}${pe.hash}`}catch{const pe=Be.includes("?")?"&":"?";return`${Be}${pe}title=${encodeURIComponent(_.trim())}`}}async function Ne(){const _=we.trim();ne(!0);try{if(_&&oe){await oe(_),z(""),le(!1),ot();return}if(Be){window.location.assign(je(_)??Be);return}await(te==null?void 0:te()),z(""),le(!1),ot()}finally{ne(!1)}}function Ye(_,pe=!1){const Re=pe?t.jsxs(t.Fragment,{children:[t.jsx(D.Plus,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:P})]}):t.jsxs(t.Fragment,{children:[t.jsx(D.Plus,{className:"h-4 w-4"}),t.jsx("span",{children:P})]});return t.jsxs(cs,{open:F,onOpenChange:Ge=>{O||le(Ge)},children:[t.jsx(hs,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":pe?P:void 0,title:P,className:_,children:Re})}),t.jsx(us,{"data-testid":"create-thread-dialog","data-theme-effective":de,"data-theme-mode":V,className:"thread-graph-create-thread-dialog thread-graph-dialog max-h-[min(86vh,42rem)] overflow-hidden p-4 sm:max-w-[34rem]",children:T?T({close:xe,closeNavigation:ot,currentWorkspaceId:b}):t.jsxs(t.Fragment,{children:[t.jsxs(ms,{children:[t.jsx(ps,{children:"Create New Chat"}),t.jsx(fs,{children:"Name the room so it is easy to find later."})]}),t.jsxs("div",{className:"grid gap-3",children:[t.jsx("input",{id:"thread-graph-create-thread-title",name:"thread-title",value:we,onChange:Ge=>z(Ge.target.value),onKeyDown:Ge=>{Ge.key==="Enter"&&(Ge.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:O,className:"thread-graph-create-thread-submit inline-flex h-10 items-center justify-center rounded-md px-4 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:O?"Creating...":"Create"})]})]})})]})}function tt(){if(!S&&!v&&!N&&!We)return null;const _=!!(S||v),pe=!!N,Re=_&&pe,Ge=Ee==="global"&&pe||!_&&pe?"global":"session";return t.jsxs(cs,{...u!==void 0?{open:u}:{},...m?{onOpenChange:m}:{},children:[t.jsx(hs,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":"Open settings",title:"Settings",className:"thread-icon-button inline-flex h-10 w-10 items-center justify-center rounded-full sm:h-9 sm:w-9",children:t.jsx(D.Settings,{className:"h-4 w-4"})})}),t.jsxs(us,{"data-testid":"settings-dialog","data-theme-effective":de,"data-theme-mode":V,className:"thread-graph-settings-dialog thread-graph-dialog",children:[t.jsxs(ms,{children:[t.jsx(ps,{children:"Settings"}),t.jsx(fs,{children:"Manage this session and host-wide preferences."})]}),We?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:cp.map(Ue=>{const ct=Ue.icon,kt=V===Ue.value;return t.jsxs("button",{type:"button","data-testid":`theme-mode-${Ue.value}`,"aria-pressed":kt,disabled:!We,onClick:()=>nt==null?void 0:nt(Ue.value),className:`thread-graph-theme-mode-button inline-flex min-h-9 items-center justify-center gap-1.5 rounded-md px-2 text-xs font-medium transition ${kt?"is-selected":""}`,children:[t.jsx(ct,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:"truncate",children:Ue.label})]},Ue.value)})})]})}):null,Re?t.jsxs("div",{className:"thread-graph-settings-tabs grid grid-cols-2 gap-1 rounded-lg border p-1",children:[t.jsx("button",{type:"button","aria-pressed":Ge==="session",onClick:()=>fe("session"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Ge==="session"?"is-active":""}`,children:"Session"}),t.jsx("button",{type:"button","aria-pressed":Ge==="global",onClick:()=>fe("global"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Ge==="global"?"is-active":""}`,children:"Global"})]}):null,t.jsx("div",{className:"thread-graph-settings-body mt-4 min-h-0 overflow-y-auto pr-1 text-sm",children:Ge==="session"?t.jsxs("div",{className:"grid gap-4",children:[S?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:S}):null,v?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:v}):null,_?null:t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3 text-[var(--theme-fg-muted)]",children:"No session settings are available."})]}):t.jsx("div",{className:"thread-graph-settings-global-content",children:N})})]})]})}function Fe(_=!1){return t.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:t.jsxs("section",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs("div",{className:`mb-3 flex items-center gap-2 px-2 text-xs font-medium tracking-normal text-[var(--theme-fg-muted)] ${_?"justify-center":""}`,children:[t.jsx(D.Rows3,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:_?"sr-only":"",children:"Rooms"}),!_&&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&&De.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,De.length>0?t.jsx(up,{threads:De,currentThreadId:p,currentWorkspaceId:b,workspaceLabels:I,onOpenThread:U,collapsed:_,...J?{onBeginRenameThread:ut}:{},showDeleteButton:!!K,...Q?{getThreadHref:Q}:{},...re?{renderThreadLink:re}:{},...K?{onDeleteThread:K}:{}}):null]})]})})}function Ke(){return L?t.jsxs("div",{className:"thread-workspace-panel relative flex h-full min-h-0 flex-col overflow-hidden rounded-[12px] border",children:[t.jsx("button",{type:"button",onClick:()=>ce(!0),className:"thread-workspace-collapse-tab thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(D.ChevronsRight,{className:"h-4 w-4"})}),G?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:G})}):null,t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:L})]}):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:q}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:k??b??"Current context"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[G,t.jsx("button",{type:"button",onClick:()=>ce(!0),className:"thread-workspace-small-toggle thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(D.ChevronsRight,{className:"h-4 w-4"})})]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:L??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:k??b??"All threads"})]})]})})]})}const lt=!!L,vt=s==="mobile"||s==="responsive"&&Ce,it=vt,Nt=it&&!ee,Ct=!!(M||R)?t.jsx("a",{href:M??"#",onClick:_=>{R&&(_.preventDefault(),R())},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(D.ArrowLeft,{className:"h-4 w-4"})}):null;return t.jsxs(t.Fragment,{children:[t.jsx(tp,{effectiveTheme:de,layoutMode:s,themeMode:V,viewportConstrained:o,children:t.jsxs(rp,{roomsRailCollapsed:ie,children:[t.jsx(np,{open:ee,onClose:()=>be(!1)}),t.jsxs(ap,{collapsed:ie,mobileOpen:ee,children:[t.jsx("div",{className:`thread-rooms-rail-header flex h-[calc(3rem+env(safe-area-inset-top))] shrink-0 items-end border-b border-[var(--theme-border)] px-4 pb-2 sm:h-16 sm:items-center sm:pb-0 ${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:()=>ye(_=>!_),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(D.PanelLeftOpen,{className:"h-4 w-4"}):t.jsx(D.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:(k??"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:k??"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:[tt(),Ct,t.jsx("button",{type:"button",onClick:()=>be(!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(D.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:Ye(`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(sp,{children:[t.jsx(op,{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:[Nt?t.jsx("button",{type:"button",onClick:()=>be(!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(D.Menu,{className:"h-4 w-4"})}):null,t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"min-w-0 truncate text-sm font-semibold leading-tight text-[var(--theme-fg)] sm:text-base",title:g??"Shared Workspace",children:g??"Shared Workspace"}),t.jsxs("div",{className:"relative mt-0.5 flex min-w-0 items-center gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{Te(_=>!_)},"aria-expanded":ge,"aria-haspopup":"dialog",className:"thread-topbar-meta-row flex min-w-0 max-w-full items-center gap-1 text-left text-[11px] leading-none sm:text-xs",title:"Session and usage",children:[t.jsx("span",{className:"shrink-0",children:"Room"}),t.jsx("span",{className:"truncate font-mono",children:et})]}),ge?t.jsxs("div",{className:"thread-topbar-details-popover absolute left-0 top-[calc(100%+0.5rem)] z-50 w-[min(28rem,calc(100vw-1.5rem))] rounded-lg border p-2.5 shadow-lg",role:"dialog","aria-label":"Session and usage",children:[t.jsxs("button",{type:"button",onClick:()=>{var _;Ve&&((_=navigator.clipboard)==null||_.writeText(Ve))},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:Ve})]}),t.jsxs("div",{className:"thread-topbar-meta-row mt-1 flex min-w-0 max-w-full items-start gap-2 text-xs leading-5",title:"Session token usage and estimated cost",children:[t.jsx("span",{className:"w-14 shrink-0",children:"Usage"}),t.jsx("span",{className:"min-w-0 whitespace-normal break-words font-mono",children:pt})]})]}):null]})]})]}),t.jsxs("div",{className:"relative z-[1] inline-flex shrink-0 items-center gap-2",children:[w||y?t.jsxs("div",{className:"thread-graph-topbar-actions thread-desktop-only-inline-flex items-center rounded-lg border p-0.5 shadow-none",children:[w,y]}):null,it&&w?t.jsx("div",{className:"thread-mobile-only-inline-flex",children:w}):null,it&<?t.jsx("button",{type:"button",onClick:()=>ue(_=>_==="workspace"?"chat":"workspace"),"aria-label":X==="workspace"?"Show chat":"Show workspace",title:X==="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:X==="workspace"?t.jsx(D.MessageSquare,{className:"h-4 w-4"}):t.jsx(D.Folder,{className:"h-4 w-4"})}):null,it?f:null,it&&h?Ye("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(lp,{children:lt&&!Ae?vt?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 ${X==="chat"?"block":"thread-mobile-chat-hidden"}`,children:E}),t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${X==="workspace"?"block":"thread-mobile-workspace-hidden"}`,children:Ke()})]}):t.jsxs(Mn,{direction:"horizontal",className:"thread-split-container thread-graph-shell-resizable thread-graph-shell-desktop-split h-full min-h-0 overflow-hidden",children:[t.jsx(sr,{defaultSize:47,minSize:30,maxSize:75,className:"thread-split-chat-pane min-w-0 overflow-hidden",children:E}),t.jsx(An,{className:"thread-resize-handle w-2 bg-transparent after:w-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(sr,{defaultSize:53,minSize:30,maxSize:70,className:"thread-split-workspace-pane min-w-0 overflow-hidden",children:Ke()})]}):t.jsxs("div",{className:"thread-split-container relative h-full min-h-0 overflow-hidden",children:[lt&&Ae?t.jsx("button",{type:"button",onClick:()=>ce(!1),className:"thread-workspace-expand-fab thread-desktop-only-inline-flex",title:"Expand workspace","aria-label":"Expand workspace",children:t.jsx(D.ChevronsLeft,{className:"h-4 w-4"})}):null,E]})})]})]})}),t.jsx(ep,{open:ve!==null,title:"Rename Thread",label:"Thread Title",value:$e,busy:_e!==null,onChange:He,onCancel:A,onSubmit:()=>ve?ht(ve):void 0})]})}function pp({open:e,title:r,text:n,onClose:a}){return c.useEffect(()=>{if(!e)return;function o(s){s.key==="Escape"&&a()}return window.addEventListener("keydown",o),()=>{window.removeEventListener("keydown",o)}},[a,e]),e?Yr.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[90] flex items-center justify-center p-4 sm:p-6",children:[t.jsx("button",{type:"button","aria-label":"Close full text",onClick:a,className:"absolute inset-0 bg-stone-950/78 backdrop-blur-sm"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":r,className:"relative z-[1] flex max-h-[min(82vh,52rem)] w-full max-w-4xl flex-col overflow-hidden rounded-[1.8rem] border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-stone-800 px-4 py-3 sm:px-5",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:r}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:a,className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-stone-700 text-stone-300 transition hover:bg-stone-800",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-4 py-4 sm:px-5",children:t.jsx("pre",{className:"whitespace-pre-wrap break-words text-sm leading-6 text-stone-200",children:n})})]})]}),document.body):null}var fp=[/^(?: {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],gp=/^(?:\|?[^|\n]+\|[^|\n]+(?:\|[^|\n]+)*\|?\s*\n\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$)/m,xp=/!?\[[^\]\n]+\]\([^)]+\)/,bp=/`[^`\n]+`/,vp=/(?:\*\*[^*\n]+\*\*|__[^_\n]+__)/,kp=/(^|[^\w])(?:\*[^*\n]+\*|_[^_\n]+_)(?=[^\w]|$)/,wp=/~~[^~\n]+~~/;function yp(e){const r=e.trim();return r?fp.some(n=>n.test(r))||gp.test(r)?!0:/[`[\]*_~!]/.test(r)?xp.test(r)||bp.test(r)||vp.test(r)||kp.test(r)||wp.test(r):!1:!1}rn();function Vn(e,r){const n=new Map(r.map(s=>[s.id,s])),a=e.map(s=>{var l,i;return{...s.manifest,enabled:((l=n.get(s.manifest.id))==null?void 0:l.enabled)??!0,source:((i=n.get(s.manifest.id))==null?void 0:i.source)??"builtin"}}),o=new Set(e.map(s=>s.manifest.id));for(const s of r)o.has(s.id)||a.push(s);return a}function ia(e=[]){const r=Vn(e,[]),n=e;return{plugins:r,loading:!1,error:null,async refresh(){},async importPluginManifest(){},async setPluginEnabled(){},async uninstallPlugin(){},renderArtifact:s=>{var i;const l=n.find(d=>d.renderArtifact&&d.manifest.capabilities.artifactTypes.some(h=>h.type===s.artifact.type));return((i=l==null?void 0:l.renderArtifact)==null?void 0:i.call(l,s))??null},renderInlineCode:s=>{for(const l of n)for(const i of l.inlineCodeRenderers??[]){if(!i.languages.includes(s.language.trim().toLowerCase()))continue;const d=i.render(s);if(d)return d}return null},hasRendererForArtifact:s=>n.some(l=>!!l.renderArtifact&&l.manifest.capabilities.artifactTypes.some(i=>i.type===s.type)),getThreadPanels:()=>n.flatMap(s=>s.threadPanels??[])}}var da=c.createContext(ia());function ca(){return c.useContext(da)??ia()}Lr();function dl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function gs(e){return dl(e)?Object.entries(e):e==null||e===""?[]:[["value",e]]}function cl(e){return typeof e=="string"?t.jsxs("span",{className:"thread-graph-tool-string",children:['"',e,'"']}):typeof e=="number"?t.jsx("span",{className:"thread-graph-tool-number",children:e}):typeof e=="boolean"?t.jsx("span",{className:"thread-graph-tool-boolean",children:String(e)}):e===null?t.jsx("span",{className:"thread-graph-tool-null",children:"null"}):typeof e=="object"?t.jsx("span",{className:"thread-graph-tool-object",children:JSON.stringify(e)}):t.jsx("span",{children:String(e)})}function jp(e,r){return typeof r=="string"&&(e==="stdout"||e==="stderr"||e==="result")?t.jsx("pre",{className:"thread-graph-tool-output",children:r||"(empty)"}):typeof r=="object"&&r!==null?t.jsx("pre",{className:"thread-graph-tool-output",children:JSON.stringify(r,null,2)}):cl(r)}function xs({callId:e,toolName:r,status:n,parameters:a,result:o}){const s=c.useMemo(()=>{switch(n){case"completed":return{className:"is-completed",icon:t.jsx(D.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"};case"failed":return{className:"is-failed",icon:t.jsx(D.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"};default:return{className:"is-pending",icon:t.jsx(D.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),label:"Running"}}},[n]),l=c.useMemo(()=>gs(o),[o]),i=c.useMemo(()=>gs(a),[a]),d=c.useMemo(()=>typeof o=="string"?o.length>0:dl(o)?["stdout","stderr","result"].some(f=>{const p=o[f];return typeof p=="string"&&p.length>0}):!1,[o]),h=n==="pending"||d,[u,m]=c.useState(h?"item-1":void 0);return c.useEffect(()=>{h&&m("item-1")},[e,h]),t.jsx("div",{className:"thread-graph-tool-call my-2 w-full font-sans not-prose",children:t.jsx(Sr,{type:"single",collapsible:!0,onValueChange:f=>m(f||void 0),className:"thread-graph-tool-accordion w-full overflow-hidden rounded-lg border",...u!==void 0?{value:u}:{},children:t.jsxs(Tr,{value:"item-1",className:"border-0",children:[t.jsx(nn,{className:"thread-graph-tool-trigger px-4 py-3 hover:no-underline",children:t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(D.Wrench,{className:"h-4 w-4 shrink-0"}),t.jsx("span",{className:"min-w-0 truncate font-mono text-sm font-semibold",children:r}),t.jsxs("span",{className:`thread-graph-tool-badge ${s.className}`,title:s.label,"aria-label":`Status: ${s.label}`,children:[s.icon,t.jsx("span",{className:"thread-graph-status-label",children:s.label})]})]})}),t.jsxs(Er,{className:"thread-graph-tool-content px-4 pb-4 pt-1",children:[t.jsxs("section",{children:[t.jsx("h4",{children:"Parameters"}),t.jsxs("div",{className:"thread-graph-tool-json",children:["{",t.jsx("br",{}),i.length>0?i.map(([f,p],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',f,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),cl(p),g<i.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},f)):t.jsx("div",{children:t.jsx("span",{className:"thread-graph-tool-null",children:"empty"})}),"}"]})]}),l.length>0?t.jsxs("section",{children:[t.jsx("h4",{children:"Result"}),t.jsxs("div",{className:"thread-graph-tool-json",children:["{",t.jsx("br",{}),l.map(([f,p],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',f,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),jp(f,p),g<l.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},f)),"}"]})]}):null]})]})})})}var bs=null;function Np(){return bs??(bs=Promise.all([Xe(()=>import("./core-DODVy7wn.js"),__vite__mapDeps([0,1,2])),Xe(()=>import("./engine-javascript-DBd1bXLz.js"),[]),Xe(()=>import("./ayu-light-BA47KaF1.js"),[]),Xe(()=>import("./ayu-dark-DYE7WIF3.js"),[]),Xe(()=>import("./javascript-wDzz0qaB.js"),[]),Xe(()=>import("./typescript-BPQ3VLAy.js"),[]),Xe(()=>import("./tsx-COt5Ahok.js"),[]),Xe(()=>import("./jsx-g9-lgVsj.js"),[]),Xe(()=>import("./python-B6aJPvgy.js"),[]),Xe(()=>import("./json-Cp-IABpG.js"),[]),Xe(()=>import("./shellscript-CEILq0vU.js").then(e=>e.b),[]),Xe(()=>import("./shellscript-CEILq0vU.js").then(e=>e.s),[]),Xe(()=>import("./yaml-Buea-lGh.js"),[]),Xe(()=>import("./toml-vGWfd6FD.js"),[]),Xe(()=>import("./markdown-Cvjx9yec.js"),[]),Xe(()=>import("./html-pp8916En.js"),__vite__mapDeps([3,4,5])),Xe(()=>import("./css-CLj8gQPS.js"),[]),Xe(()=>import("./sql-CRqJ_cUM.js"),[]),Xe(()=>import("./csv-fuZLfV_i.js"),[])]).then(([{createHighlighterCore:e},{createJavaScriptRegexEngine:r},n,a,o,s,l,i,d,h,u,m,f,p,g,b,k,x,j])=>e({engine:r(),themes:[n.default,a.default],langs:[o.default,s.default,l.default,i.default,d.default,h.default,u.default,m.default,f.default,p.default,g.default,b.default,k.default,x.default,j.default]}))),bs}function an(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Kn(e){if(!e)return{};if(an(e)&&Object.prototype.hasOwnProperty.call(e,"0"))try{const r=Object.keys(e).map(Number).filter(n=>Number.isFinite(n)).sort((n,a)=>n-a).map(n=>String(e[String(n)]??"")).join("");return JSON.parse(r)}catch{return e}if(typeof e=="string")try{return JSON.parse(e)}catch{return e}return e}function qn(){return{finalResult:null,stdout:"",stderr:""}}function Cp(e){return typeof e=="string"?{result:e}:e}function hl(e){const r=an(e.finalResult)?{...e.finalResult}:e.finalResult!=null?{result:e.finalResult}:{};return e.stdout&&(r.stdout=e.stdout),e.stderr&&(r.stderr=e.stderr),!("status"in r)&&(e.stdout||e.stderr)&&(r.status="pending"),r}function vs(e){if(!e)return"pending";if(!an(e))return"completed";const r=e.status;return r==="stream"||r==="pending"||r==="running"?"pending":r==="failed"||r==="error"||r==="timed_out"||typeof e.exit_code=="number"&&e.exit_code!==0?"failed":"completed"}function Sp(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=Cp(d.result),m=r.get(h)??qn();return an(u)&&u.status==="stream"&&typeof u.chunk=="string"?u.stream==="stderr"?m.stderr+=u.chunk:m.stdout+=u.chunk:m.finalResult=u,r.set(h,m),""}catch{return l}}),o=/```tool-call\s*([\s\S]*?)\s*```/g;return{processedContent:a.replace(o,(l,i)=>{try{const d=JSON.parse(i),h=d.call_id,u=d.tool;if(typeof u!="string")return l;const m=Kn(d.args);if(typeof h=="string"&&r.has(h)){const f=hl(r.get(h)??qn());return`\`\`\`tool-merged
|
|
3657
3657
|
${JSON.stringify({call:{tool:u,args:m,call_id:h},result:f},null,2)}
|
|
3658
|
-
\`\`\``}return l}catch{return l}}),resultMap:r}}var
|
|
3659
|
-
`)||
|
|
3658
|
+
\`\`\``}return l}catch{return l}}),resultMap:r}}var Tp=["/api/","/assets/","/control-plane","/devices/","/relay/","/relay-account","/relay-admin","/relay-devices","/relay-portal","/threads","/workspaces"];function ks(e){return e.replace(/background-color:[^;"]+;?/g,"background-color: transparent;").replace(/background:[^;"]+;?/g,"background: transparent;")}function ws(e){return Array.isArray(e)?e.map(r=>String(r)).join(""):String(e??"")}function Ep(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 Lp(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("/")||Tp.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 Ip({children:e,...r}){return zp(e)?t.jsx(t.Fragment,{children:e}):t.jsx("pre",{...r,children:e})}function zp(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 Pp=c.memo(function({className:r="thread-graph-markdown",content:n,onOpenWorkspaceFile:a}){const o=c.useRef(null),s=ca(),[l,i]=c.useState(null),[d,h]=c.useState({}),[u,m]=c.useState(!1),{processedContent:f,resultMap:p}=c.useMemo(()=>Sp(n),[n]);c.useEffect(()=>{let k=!0;return Np().then(x=>{k&&i(x)}).catch(()=>{}),()=>{k=!1}},[]),c.useEffect(()=>{const k=o.current,x=k==null?void 0:k.closest(".thread-ui-shell"),j=()=>x?x.getAttribute("data-theme-effective")==="dark"||x.classList.contains("dark")||x.classList.contains("thread-ui-theme-dark"):document.documentElement.classList.contains("dark");if(m(j()),!x)return;const w=new MutationObserver(()=>m(j()));return w.observe(x,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>w.disconnect()},[]);async function g(k,x){try{await navigator.clipboard.writeText(x),h(j=>({...j,[k]:"copied"})),window.setTimeout(()=>{h(j=>{const w={...j};return delete w[k],w})},1200)}catch{h(j=>({...j,[k]:"failed"}))}}const b=({children:k,className:x,inline:j,node:w,...y})=>{var $;const v=/language-(\w+(?:-\w+)*)/.exec(x||""),S=v?v[1]??"":"",N=ws(k).replace(/\n$/,""),{startLine:I,endLine:M}=Ep(w),R=j===!1||!!x||N.includes(`
|
|
3659
|
+
`)||I!==M;if(S==="tool-merged"){let Y={call:{tool:"Unknown",args:{},call_id:void 0},result:null};try{Y=JSON.parse(N)}catch{Y={call:{tool:"Error",args:{raw:N}},result:{status:"failed"}}}const Z=typeof Y.call.tool=="string"?Y.call.tool:"Unknown",P=typeof Y.call.call_id=="string"?Y.call.call_id:void 0;return t.jsx(xs,{callId:P,toolName:Z,status:vs(Y.result),parameters:Kn(Y.call.args),result:Y.result})}if(S==="tool-call"){let Y={tool:"Unknown",args:{},call_id:void 0};try{Y=JSON.parse(N)}catch{Y={tool:"Error",args:{raw:N}}}const Z=typeof Y.call_id=="string"?Y.call_id:void 0,P=Z&&p.has(Z)?hl(p.get(Z)??qn()):void 0;return t.jsx(xs,{callId:Z,toolName:typeof Y.tool=="string"?Y.tool:"Unknown",status:P?vs(P):"pending",parameters:Kn(Y.args),result:P})}if(S==="tool-result")return null;if(["xyz","extxyz","cif","pdb"].includes(S)){const Y=s.renderInlineCode({code:N,isIncomplete:!1,language:S});if(c.isValidElement(Y))return Y}if(R){const Z=((($=l==null?void 0:l.getLoadedLanguages)==null?void 0:$.call(l))??[]).includes(S)?S:"text",P=u?"ayu-dark":"ayu-light",te=`${S||"text"}:${N.length}:${N.slice(0,32)}`;let oe="";if(l)try{oe=ks(l.codeToHtml(N,{lang:Z,theme:P}))}catch{oe=ks(l.codeToHtml(N,{lang:"text",theme:P}))}return t.jsxs("div",{className:"thread-graph-code-block not-prose relative my-3 overflow-auto rounded-xl border p-3 text-sm shadow-sm",children:[t.jsx(Nr,{type:"button",onClick:()=>void g(te,N),variant:"ghost",size:"sm",className:"thread-graph-code-copy absolute right-2 top-2 z-10 rounded-md p-1.5",title:d[te]==="copied"?"Copied":d[te]==="failed"?"Copy failed":"Copy","aria-label":"Copy code",children:t.jsx(D.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:N})})]})}const Q=ws(k).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||""}`,...y,children:Q})};return t.jsx("div",{ref:o,className:`thread-graph-message-markdown ${r}`,children:t.jsx(Cd,{remarkPlugins:[Td,Ed],rehypePlugins:[Sd],components:{a({href:k,children:x,...j}){const w=Lp(k);return w&&a?t.jsx("a",{...j,href:k,className:"thread-inline-link",onClick:y=>{y.preventDefault(),a(w)},children:x}):t.jsx("a",{...j,href:k,className:"thread-inline-link",children:x})},code:b,pre:Ip},children:f})})}),ys=2400,Rp=/\b(?:https?:\/\/|www\.)[^\s<>"'`]+/gi,Mp=/[),.;:!?]+$/;function Ap(e){return e.startsWith("www.")?`https://${e}`:e}function js(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function _p(e){var s;if(!e)return[];const r=/\[(PHOTO|FILE)\s+([^\]]+)\]/g,n=[];let a=0,o=0;for(const l of e.matchAll(r)){const i=l.index??0;i>a&&(n.push({type:"text",key:`text-${o}`,text:e.slice(a,i)}),o+=1);const d=l[1],h=((s=l[2])==null?void 0:s.trim())??"";d==="PHOTO"&&h?n.push({type:"photo",key:`photo-${o}`,path:h}):d==="FILE"&&h?n.push({type:"file",key:`file-${o}`,path:h}):n.push({type:"text",key:`text-${o}`,text:l[0]}),o+=1,a=i+l[0].length}return a<e.length&&n.push({type:"text",key:`text-${o}`,text:e.slice(a)}),n}function lr({text:e}){var a;const r=[];let n=0;for(const o of e.matchAll(Rp)){const s=o[0],l=o.index??0,i=((a=s.match(Mp))==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:Ap(d),target:"_blank",rel:"noreferrer",className:"thread-inline-link",children:d},`${l}-${d}`)),i&&r.push(i),n=l+s.length)}return n<e.length&&r.push(e.slice(n)),t.jsx(t.Fragment,{children:r.length>0?r:e})}var ul=c.memo(function({text:r,scrollRootRef:n,streaming:a=!1,containerClassName:o="",plainTextClassName:s="thread-graph-plain-text whitespace-pre-wrap break-words text-[15px] leading-6",markdownClassName:l="thread-graph-markdown",onBeforeResize:i,onOpenWorkspaceFile:d}){const h=c.useRef(null),u=c.useRef(null),[m,f]=c.useState(!1),p=yp(r),g=!a&&r.length>ys,b=g&&!m?`${r.slice(0,ys).trimEnd()}
|
|
3660
3660
|
|
|
3661
|
-
...`:r,[
|
|
3661
|
+
...`:r,[k,x]=c.useState(a||typeof IntersectionObserver>"u"),j=c.useCallback(()=>{const w=n.current,y=h.current,v=(y==null?void 0:y.getBoundingClientRect().top)??null;i==null||i(),u.current=w&&v!==null?{root:w,top:v}:null,f(S=>!S)},[i,n]);return c.useLayoutEffect(()=>{const w=u.current,y=h.current;if(!w||!y)return;u.current=null;const v=()=>{const N=y.getBoundingClientRect().top;w.root.scrollTop+=N-w.top};v();const S=window.requestAnimationFrame(v);return()=>{window.cancelAnimationFrame(S)}},[m]),c.useEffect(()=>{if(a||typeof IntersectionObserver>"u"){x(!0);return}if(k||!h.current)return;const w=new IntersectionObserver(y=>{for(const v of y)if(v.isIntersecting){x(!0),w.disconnect();break}},{root:n.current,threshold:0});return w.observe(h.current),()=>{w.disconnect()}},[k,n,a]),t.jsxs("div",{ref:h,className:o,children:[k&&p?t.jsx(Pp,{content:b,className:l,onOpenWorkspaceFile:d}):t.jsx("p",{className:s,children:t.jsx(lr,{text:b})}),g?t.jsx("button",{type:"button",onClick:j,className:"thread-graph-show-more timeline-meta-text mt-1.5 flex w-full items-center justify-center rounded-md border border-[var(--theme-border)] px-2 py-0.5 text-[10px] leading-4 transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)]",children:m?"Show less":`Show more (${r.length.toLocaleString()} chars)`}):null]})}),$p=c.memo(function({text:r,scrollRootRef:n,streaming:a=!1,onBeforeResize:o,onOpenWorkspaceFile:s}){return t.jsx(ul,{text:r,scrollRootRef:n,streaming:a,containerClassName:"thread-graph-message-prose",...o?{onBeforeResize:o}:{},...s?{onOpenWorkspaceFile:s}:{}})}),Dp=c.memo(function({threadId:r,text:n,attachmentPreviewUrls:a,getImageAssetUrl:o}){const s=c.useMemo(()=>_p(n),[n]);return t.jsx("div",{className:"thread-graph-message-prose whitespace-pre-wrap break-words text-[15px] leading-6",children:s.map(l=>{if(l.type==="text")return t.jsx("span",{children:l.text},l.key);if(l.type==="photo"){const d=(a==null?void 0:a[l.path])??(r?(o==null?void 0:o({threadId:r,path:l.path}))??null:null),h=js(l.path)||"Attached image";return t.jsx("span",{className:"mx-[0.14rem] inline-flex align-middle",children:t.jsxs("span",{className:"inline-flex max-w-full flex-col rounded-[1rem] border border-sky-300/28 bg-sky-300/[0.08] p-1.5 shadow-sm shadow-stone-950/20",children:[d?t.jsx("img",{src:d,alt:h,className:"h-[4.5rem] w-[6rem] rounded-[0.75rem] bg-stone-950 object-contain",loading:"lazy"}):t.jsx("span",{className:"inline-flex h-[4.5rem] w-[6rem] items-center justify-center rounded-[0.75rem] bg-stone-950 text-[10px] text-sky-100",children:"PHOTO"}),t.jsx("span",{className:"mt-1 max-w-[7rem] truncate text-[10px] font-medium tracking-[0.08em] text-sky-50",title:l.path,children:h})]})},l.key)}const i=js(l.path)||"Attached file";return t.jsx("span",{className:"mx-[0.14rem] inline-flex align-middle",children:t.jsxs("span",{className:"inline-flex max-w-[12rem] items-center gap-2 rounded-[0.95rem] border border-emerald-300/28 bg-emerald-300/[0.08] px-2.5 py-2 text-[10px] font-medium tracking-[0.08em] text-emerald-50 shadow-sm shadow-stone-950/20",title:l.path,children:[t.jsx("span",{className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-emerald-200/20 bg-emerald-300/12 text-[9px]",children:"FILE"}),t.jsx("span",{className:"min-w-0 truncate",children:i})]})},l.key)})})});function Bp(){return t.jsx("span",{className:"ml-1.5 inline-flex items-center gap-1","aria-hidden":"true",children:[0,1,2].map(e=>t.jsx("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-sky-200/90",style:{animationDelay:`${e*180}ms`}},e))})}function Ns({status:e}){if(!e)return null;const r=e.toLowerCase(),n=r.includes("running")||r.includes("generating")||r.includes("steering"),a=r.includes("failed")||r.includes("error"),o=r.includes("accepted")||r.includes("complete"),s=n?"ui-status-warning":a?"ui-status-danger":o?"ui-status-success":"ui-status-neutral",l=n?t.jsx(D.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):a?t.jsx(D.XCircle,{className:"h-3.5 w-3.5"}):o?t.jsx(D.CheckCircle2,{className:"h-3.5 w-3.5"}):t.jsx(D.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(Bp,{}):l}),t.jsx("span",{className:"thread-graph-status-label",children:e})]})}function Gp({children:e,copyButton:r,kind:n,metaControl:a,reasoning:o,status:s,timeLabel:l,timeTitle:i}){const d=n==="userMessage",h=l?t.jsx("span",{title:i??void 0,className:"thread-graph-message-time text-[10px] leading-none sm:text-[11px]",children:l}):null;return t.jsx("div",{"data-testid":"chat-message","data-role":d?"user":"assistant",className:"thread-graph-message flex justify-start",children:t.jsxs("div",{className:`thread-graph-message-bubble min-w-0 w-full max-w-full ${d?"is-user":"is-assistant"}`,children:[d?null:t.jsxs("div",{className:"thread-graph-message-header mb-2 flex min-w-0 items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"thread-graph-message-sender rounded-full px-2.5 py-1 text-xs font-semibold tracking-[0.02em]",children:"Assistant"}),t.jsx(Ns,{status:s??"Complete"})]}),a?t.jsx("div",{className:"thread-graph-message-header-meta flex min-w-0 flex-1 justify-center",children:a}):null,r||h?t.jsxs("div",{className:"thread-graph-message-header-actions flex shrink-0 items-center gap-1.5 sm:gap-2",children:[r,h]}):null]}),o,t.jsx("div",{className:`thread-graph-message-content min-w-0 ${d?"is-user":"is-assistant"}`,children:e}),d&&(s||h)?t.jsxs("div",{className:"mt-1 flex items-center justify-end gap-2",children:[s?t.jsx(Ns,{status:s}):null,h]}):null]})})}Lr();function Fp(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function Hp({tone:e="amber"}){const r=e==="sky"?"bg-sky-300/90":"bg-amber-200/90";return t.jsx("span",{className:"ml-1.5 inline-flex items-center gap-1","aria-hidden":"true",children:[0,1,2].map(n=>t.jsx("span",{className:`h-1.5 w-1.5 animate-pulse rounded-full ${r}`,style:{animationDelay:`${n*180}ms`}},n))})}var It=c.memo(function({threadId:r,item:n,scrollRootRef:a,streaming:o=!1,adapter:s,timeLabel:l,timeTitle:i,onBeforeMessageResize:d}){const[h,u]=c.useState("idle"),[m,f]=c.useState(!1),p=c.useRef(null),g=n.kind==="agentMessage"?n.reasoningItems??[]:[],b=g.map(N=>N.text.trim()).filter(Boolean).join(`
|
|
3662
3662
|
|
|
3663
|
-
`),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 j(){d==null||d(),f(N=>!N)}const w=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,y=g.some(N=>Hp(N.status)),k=n.kind==="agentMessage"&&b?t.jsxs("button",{type:"button","aria-label":m?"Hide chain of thought":"Show chain of thought","aria-expanded":m,title:m?"Hide CoT":"Show CoT",onClick:j,className:`thread-graph-thinking-toggle inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border px-2 text-xs font-medium transition ${m?"is-open":""}`,children:[t.jsx(B.Brain,{className:`h-3.5 w-3.5 ${y?"animate-pulse":""}`}),t.jsx("span",{children:"CoT"}),y?t.jsx(Op,{tone:"sky"}):null]}):null,S=n.kind==="agentMessage"&&b?t.jsx("div",{className:"thread-graph-message-thinking mb-3",children:t.jsx(Sr,{type:"single",collapsible:!0,className:"thread-graph-thinking-accordion w-full border-none",onValueChange:N=>f(!!N),...m?{value:"thoughts"}:{},children:t.jsx(Tr,{value:"thoughts",className:"border-b-0",children:t.jsx(Er,{className:"thread-graph-thinking-content pb-0",children:t.jsx("pre",{className:"thread-graph-thinking-body my-1 max-h-56 overflow-auto whitespace-pre-wrap break-words rounded-xl border p-3 text-[12px] leading-5",children:t.jsx(lr,{text:b})})})})})}):null;return t.jsx(Fp,{kind:n.kind,status:v||n.kind==="agentMessage"?n.status:null,copyButton:w,metaControl:k,reasoning:S,timeLabel:l,timeTitle:i,children:n.kind==="agentMessage"?t.jsx(Dp,{text:n.text,scrollRootRef:a,streaming:o,...d?{onBeforeResize:d}:{},...s!=null&&s.onOpenWorkspaceFile?{onOpenWorkspaceFile:s.onOpenWorkspaceFile}:{}}):t.jsx(Bp,{threadId:r,text:n.text,attachmentPreviewUrls:n.attachmentPreviewUrls,getImageAssetUrl:s==null?void 0:s.getImageAssetUrl})})});function Ts(e){return e.replace(/"/g,'"').replace(/'/g,"'").replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&")}function fl(e){const r=e.trim().match(/^<hook_prompt(?:\s+hook_run_id="([^"]+)")?>([\s\S]*)<\/hook_prompt>$/);if(!r)return null;const n=r[1]?Ts(r[1]):null,a=Ts(r[2]??"").trim(),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 Wp(e){return e==="userMessage"||e==="agentMessage"}function Up(e){return e==="commandExecution"||e==="webSearch"||e==="fileRead"||e==="fileChange"||e==="image"||e==="contextCompaction"}function Vp(e){return e==="agentMessage"||e==="reasoning"||e==="agentToolCall"||e==="skillToolCall"||e==="toolCall"||e==="plan"}function Kp(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&&Up(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=>Vp(d.kind))?s:{...s,status:"Awaiting response"}:(o=!0,s))}function Tt(e){return typeof e.sequence=="number"&&Number.isFinite(e.sequence)}function Ar(e){return Tt(e)?e.sequence:Number.POSITIVE_INFINITY}function Es(e){var h;const r=[];let n=0;for(;n<e.length&&((h=e[n])==null?void 0:h.kind)==="userMessage"&&!Tt(e[n]);)r.push(e[n]),n+=1;const a=e.slice(n);if(!a.some(Tt))return e;const o=a.map(u=>Ar(u)).filter(Number.isFinite),s=o.length>0?Math.max(...o):0,l=[];let i=0;for(;i<a.length;){const u=a[i];if(Tt(u)){l.push({item:u,index:i,order:Ar(u)}),i+=1;continue}const m=i;for(;i<a.length&&!Tt(a[i]);)i+=1;const f=a.slice(m,i),p=[...a.slice(0,m)].reverse().find(Tt),g=a.slice(i).find(Tt),b=p?Ar(p):null,v=g?Ar(g):null;f.forEach((x,j)=>{let w;if(b===null&&v!==null)w=v-(f.length-j)/(f.length+1);else if(b!==null&&v!==null&&v>b){const y=v-b;w=b+(j+1)/(f.length+1)*y}else w=s+1+j/(f.length+1);l.push({item:x,index:m+j,order:w})})}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 qp(e,r){if(!r||r.length===0)return Es(e);const n=new Map(r.map(s=>[s.id,s])),a=e.map(s=>{const l=n.get(s.id);if(!l)return s;n.delete(s.id);const i={...s,...l,text:l.text||s.text},d=l.detailText??s.detailText,h=l.previewText??s.previewText,u=l.status??s.status,m=l.sequence??s.sequence;return d!==void 0&&(i.detailText=d),h!==void 0&&(i.previewText=h),u!==void 0&&(i.status=u),m!==void 0&&(i.sequence=m),i}),o=[...n.values()];return o.length===0&&!a.some(Tt)||(a.push(...o),!a.some(s=>typeof s.sequence=="number"&&Number.isFinite(s.sequence)))?a:Es(a)}function Xp(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 gl(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function vr(e){return e==="inProgress"||e==="sending"}function Yp(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 xl(e,r){return[...e.map(n=>({id:n.id,startedAt:n.startedAt??""})),...r?[{id:r.id,startedAt:r.startedAt??""}]:[]]}function kr(e,r,n){const a=e.get(r)??[];a.push(n),e.set(r,a)}function bl(e,r){return e.find(n=>r&&n.startedAt&&r.localeCompare(n.startedAt)<=0)}function Zp({answeredRequestNotes:e,pendingRequests:r,visibleTurns:n,optimisticTurn:a}){const o=new Set(n.map(p=>p.id)),s=new Map,l=new Map,i=[],d=[];for(const p of e)p.turnId&&o.has(p.turnId)?kr(s,p.turnId,p):i.push(p);for(const p of r)p.turnId&&o.has(p.turnId)?kr(l,p.turnId,p):d.push(p);const h=xl(n,a),u=new Map,m=[],f=[...i.map(p=>({kind:"note",id:p.id,createdAt:p.createdAt??"",note:p})),...d.map(p=>({kind:"request",id:p.id,createdAt:p.createdAt,request:p}))].sort((p,g)=>p.createdAt.localeCompare(g.createdAt));for(const p of f){const g=bl(h,p.createdAt);if(!g){m.push(p);continue}kr(u,g.id,p)}return{notesByTurnId:s,pendingRequestsByTurnId:l,beforeTurnId:u,trailing:m}}function Jp({activityNotes:e,visibleTurns:r,optimisticTurn:n}){const a=[...e].sort((m,f)=>m.createdAt.localeCompare(f.createdAt)),o=xl(r,n),s=[],l=new Map,i=new Map,d=[],u=o.map(m=>m.startedAt).filter(m=>!!m).sort().at(-1)??null;for(const m of a){if(m.anchorTurnId==="__leading__"){s.push(m);continue}if(m.anchorTurnId){o.some(p=>p.id===m.anchorTurnId)?kr(i,m.anchorTurnId,m):s.push(m);continue}const f=bl(o,m.createdAt);if(!f){!u||m.createdAt.localeCompare(u)<=0?s.push(m):d.push(m);continue}kr(l,f.id,m)}return{leading:s,beforeTurnId:l,afterTurnId:i,trailing:d}}function vl({request:e,busy:r=!1,onRespond:n}){const[a,o]=c.useState({}),[s,l]=c.useState({}),[i,d]=c.useState(null),h=e.questions[0]??null,u="__other__",m=e.kind==="planDecision"?"Plan":e.kind==="requestUserInput"?"Answer Required":e.title;function f(x){const j=/\s*\(recommended\)\s*$/i.test(x);return{rawLabel:x,displayLabel:x.replace(/\s*\(recommended\)\s*$/i,"").trim(),recommended:j}}function p(x){h&&(d(x),n==null||n(e.id,{answers:{[h.id]:{answers:[x]}}}))}function g(x){const j=a[x.id]??"";return Array.isArray(j)?j.map(w=>w===u?(s[x.id]??"").trim():w.trim()).filter(Boolean).join(", "):j===u?(s[x.id]??"").trim():j.trim()}function b(x){const j=a[x.id]??"";if(Array.isArray(j))return j.map(y=>y===u?(s[x.id]??"").trim():y.trim()).filter(Boolean);if(j===u){const y=(s[x.id]??"").trim();return y?[y]:[]}const w=j.trim();return w?[w]:[]}function v(x,j){o(w=>{const y=w[x],k=Array.isArray(y)?y:[],S=k.includes(j)?k.filter(N=>N!==j):[...k,j];return{...w,[x]:S}})}return t.jsxs("div",{className:"timeline-pending-card w-full rounded-[1rem] border px-3 py-3 sm:rounded-[1.2rem] sm:px-4",children:[t.jsx("div",{className:"flex items-center justify-between gap-3",children:t.jsxs("div",{children:[t.jsx("p",{className:"timeline-primary-text text-sm font-medium",children:m}),e.kind!=="planDecision"&&e.description&&t.jsx("p",{className:"timeline-soft-text mt-1 text-[13px] leading-5",children:e.description})]})}),t.jsx("div",{className:"mt-3 space-y-3",children:e.questions.map(x=>t.jsxs("div",{className:"timeline-question-section rounded-xl border p-2.5 sm:p-3",children:[t.jsx("p",{className:"timeline-meta-text text-xs uppercase tracking-[0.2em]",children:x.header}),t.jsx("p",{className:"timeline-primary-text mt-1 text-[13px] leading-5 sm:text-sm",children:x.question}),e.kind==="planDecision"&&x.options&&x.options.length>0?t.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:x.options.map((j,w)=>{const y=f(j.label),k=y.displayLabel.toLowerCase()==="implement";return t.jsxs("button",{type:"button",disabled:r,onClick:()=>p(j.label),className:`relative rounded-2xl border px-2.5 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${w===0?"ui-action-info":"border-stone-700 text-stone-200 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:j.description,children:[y.recommended?t.jsx("span",{"aria-hidden":"true",className:"absolute right-1.5 top-1 inline-flex h-3.5 w-3.5 items-center justify-center rounded-full bg-white/18 text-[10px] leading-none text-current",children:"✦"}):null,r&&i===j.label?k?"Starting...":"Saving...":y.displayLabel]},j.label)})}):x.options&&x.options.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[x.options.map(j=>{const w=f(j.label),y=a[x.id];return t.jsxs("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?v(x.id,j.label):o(k=>({...k,[x.id]:j.label})),className:`relative rounded-2xl border px-3 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${(x.multiSelect?Array.isArray(y)&&y.includes(j.label):y===j.label)?"ui-status-warning":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:j.description,children:[w.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,w.displayLabel]},j.label)}),x.isOther&&(()=>{const j=a[x.id];return t.jsx("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?v(x.id,u):o(w=>({...w,[x.id]:u})),className:`rounded-2xl border px-3 py-1.5 text-[12px] leading-4 transition sm:text-[13px] ${(x.multiSelect?Array.isArray(j)&&j.includes(u):j===u)?"ui-status-info":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Not from above"})})()]}),x.isOther&&(()=>{const j=a[x.id];return(x.multiSelect?Array.isArray(j)&&j.includes(u):j===u)?t.jsx("input",{"aria-label":`${x.header} custom answer`,value:s[x.id]??"",onChange:y=>l(k=>({...k,[x.id]:y.target.value})),placeholder:"Enter a custom answer",className:"mt-3 w-full rounded-xl border border-stone-700 bg-stone-900 px-3 py-2 text-sm text-stone-100 outline-none transition focus:border-sky-300"}):null})()]}):t.jsx("input",{"aria-label":x.header,value:a[x.id]??"",onChange:j=>o(w=>({...w,[x.id]:j.target.value})),className:"mt-3 w-full rounded-xl border border-stone-700 bg-stone-900 px-3 py-2 text-sm text-stone-100 outline-none transition focus:border-amber-300"})]},x.id))}),e.kind!=="planDecision"&&t.jsx("div",{className:"mt-3 flex justify-end",children:t.jsx("button",{type:"button",disabled:r||e.questions.some(x=>!g(x)),onClick:()=>void(n==null?void 0:n(e.id,{answers:Object.fromEntries(e.questions.map(x=>[x.id,{answers:b(x)}]))})),className:"ui-action-info rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:r?"Submitting...":"Submit"})})]})}function kl({note:e}){return t.jsxs("div",{className:"timeline-note-card w-full rounded-2xl border px-3 py-2.5",children:[t.jsx("p",{className:"timeline-meta-text text-[11px] uppercase tracking-[0.2em]",children:e.title}),t.jsx("div",{className:"mt-1 space-y-1",children:e.summaryLines.map((r,n)=>t.jsxs("p",{className:"timeline-primary-text text-[13px] leading-5",children:["You selected ",r]},`${e.id}-${n}`))})]})}function wl({note:e,onOpenThread:r,onOpenLinkedThread:n}){const a=e.kind==="forkCreated"?"Fork":e.kind==="forkSource"?"Fork source":"System",o=e.kind==="forkCreated"?`Thread forked from Turn ${e.turnIndex??"?"}`:e.kind==="forkSource"?`Forked from ${e.linkedThreadTitle??"source thread"} at Turn ${e.turnIndex??"?"}`:e.text??"";return t.jsxs("div",{className:"timeline-activity-card w-full rounded-2xl border px-3 py-2.5",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("p",{className:"timeline-meta-text text-[11px] uppercase tracking-[0.2em]",children:a}),t.jsx("time",{dateTime:e.createdAt,title:Wt(e.createdAt),className:"timeline-meta-text text-[10px]",children:xt(e.createdAt)})]}),t.jsx("p",{className:"timeline-primary-text mt-1 text-[13px] leading-5",children:o}),e.linkedThreadId?t.jsx("button",{type:"button",onClick:()=>{const s=e.linkedThreadId;s&&(n==null||n(s),r==null||r(s))},className:"relative z-10 mt-2 inline-flex cursor-pointer rounded-full border border-amber-300/30 px-3 py-1.5 text-xs text-amber-100 transition hover:bg-amber-300/10",children:e.kind==="forkCreated"?"Open fork":"Back to source"}):null]})}function pr({notes:e,onOpenThread:r,onOpenLinkedThread:n}){return e.length===0?null:t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:e.map(a=>t.jsx(wl,{note:a,onOpenThread:r,onOpenLinkedThread:n},a.id))})}function Yn({entries:e,respondingRequestId:r,onRespondToRequest:n}){return e.length===0?null:t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:e.map(a=>a.kind==="note"?t.jsx(kl,{note:a.note},a.id):t.jsx(vl,{request:a.request,busy:r===a.request.id,onRespond:n},a.id))})}function Qp({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(Yn,{entries:o,respondingRequestId:n,onRespondToRequest:a})}function ef({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(wl,{note:s.note,onOpenThread:a,onOpenLinkedThread:o},s.id):s.kind==="note"?t.jsx(kl,{note:s.note},s.id):t.jsx(vl,{request:s.request,busy:r===s.request.id,onRespond:n},s.id))})}function tf({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 on({children:e,className:r,count:n,countBadgeClassName:a,desktopIconClassName:o,expanded:s,expandedListClassName:l,icon:i,onToggleExpanded:d,runningIndicator:h,summary:u,timeMeta:m,toggleAriaLabel:f,trailingSummary:p}){return t.jsx("div",{className:`thread-graph-history-group ${r} relative min-w-0 w-full overflow-hidden rounded-[0.9rem] border px-3 py-2.5`,children:t.jsxs("div",{className:"flex items-start gap-2.5",children:[t.jsxs("div",{className:"thread-graph-history-group-icon mt-0.5 flex shrink-0 items-center",children:[t.jsxs("span",{className:`relative inline-flex h-8 w-8 items-center justify-center rounded-[0.9rem] border shadow-sm shadow-stone-950/20 ${o}`,children:[i,t.jsx("span",{className:`absolute -right-1 -top-1 inline-flex min-w-[1.1rem] items-center justify-center rounded-full border bg-stone-950/90 px-1 text-[9px] font-semibold leading-4 ${a}`,children:n})]}),h]}),t.jsxs("div",{className:"thread-graph-history-group-card min-w-0 flex-1 rounded-[0.85rem] border px-3 py-2",children:[t.jsxs("button",{type:"button","aria-expanded":s,"aria-label":f,onClick:d,className:"thread-graph-history-group-toggle flex w-full min-w-0 items-center justify-between gap-3 text-left",children:[t.jsx("div",{className:"thread-graph-history-group-summary min-w-0 flex flex-1 flex-wrap items-center gap-2 pr-1",children:u}),p||m?t.jsxs("div",{className:"inline-flex shrink-0 items-center gap-2",children:[p,m]}):null]}),s?t.jsx("div",{className:`thread-graph-history-group-list mt-3 space-y-2 border-t pt-3 ${l}`,children:e}):null]})]})})}Lr();Pt();var rf=Cr("inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden whitespace-nowrap rounded-md border px-2 py-0.5 text-xs font-medium outline-none transition-[color,box-shadow] focus-visible:ring-[3px] [&>svg]:pointer-events-none [&>svg]:size-3",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-white",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function ln({asChild:e=!1,className:r,variant:n,...a}){const o=e?Hs:"span";return t.jsx(o,{"data-slot":"badge",className:rt(rf({variant:n,className:r})),...a})}function ua(e){if(!e)return!1;const r=e.trim().toLowerCase();return r==="running"||r==="in_progress"||r==="in progress"||r==="pending"}function nf(){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 af(){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 sf(){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 of(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.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 lf(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 yl(e,r=42){const n=lf(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 df(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 Zn({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 cf(e){var n;const r=e.replace(/\r\n/g,`
|
|
3663
|
+
`),k=n.kind==="userMessage"&&(n.status==="Steering"||n.status==="Accepted"||n.status==="Awaiting response");c.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current)},[]);async function x(){try{await navigator.clipboard.writeText(n.text),u("copied"),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>u("idle"),1200)}catch{u("failed"),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>u("idle"),1600)}}function j(){d==null||d(),f(N=>!N)}const w=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(D.Copy,{className:"h-3.5 w-3.5"})}):null,y=g.some(N=>Fp(N.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:j,className:`thread-graph-thinking-toggle inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border px-2 text-xs font-medium transition ${m?"is-open":""}`,children:[t.jsx(D.Brain,{className:`h-3.5 w-3.5 ${y?"animate-pulse":""}`}),t.jsx("span",{children:"CoT"}),y?t.jsx(Hp,{tone:"sky"}):null]}):null,S=n.kind==="agentMessage"&&b?t.jsx("div",{className:"thread-graph-message-thinking mb-3",children:t.jsx(Sr,{type:"single",collapsible:!0,className:"thread-graph-thinking-accordion w-full border-none",onValueChange:N=>f(!!N),...m?{value:"thoughts"}:{},children:t.jsx(Tr,{value:"thoughts",className:"border-b-0",children:t.jsx(Er,{className:"thread-graph-thinking-content pb-0",children:t.jsx("pre",{className:"thread-graph-thinking-body my-1 max-h-56 overflow-auto whitespace-pre-wrap break-words rounded-xl border p-3 text-[12px] leading-5",children:t.jsx(lr,{text:b})})})})})}):null;return t.jsx(Gp,{kind:n.kind,status:k||n.kind==="agentMessage"?n.status:null,copyButton:w,metaControl:v,reasoning:S,timeLabel:l,timeTitle:i,children:n.kind==="agentMessage"?t.jsx($p,{text:n.text,scrollRootRef:a,streaming:o,...d?{onBeforeResize:d}:{},...s!=null&&s.onOpenWorkspaceFile?{onOpenWorkspaceFile:s.onOpenWorkspaceFile}:{}}):t.jsx(Dp,{threadId:r,text:n.text,attachmentPreviewUrls:n.attachmentPreviewUrls,getImageAssetUrl:s==null?void 0:s.getImageAssetUrl})})});function Cs(e){return e.replace(/"/g,'"').replace(/'/g,"'").replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&")}function ml(e){const r=e.trim().match(/^<hook_prompt(?:\s+hook_run_id="([^"]+)")?>([\s\S]*)<\/hook_prompt>$/);if(!r)return null;const n=r[1]?Cs(r[1]):null,a=Cs(r[2]??"").trim(),o=(n==null?void 0:n.split(":")[0])??"hook",s=o==="stop"?"Stop":o,l=(n==null?void 0:n.split(":").slice(2).join(":"))||null;return{id:`live-hook-prompt:${n??"unknown"}`,kind:"hook",text:`${s} hook`,previewText:a||`${s} hook`,detailText:a||null,status:"Completed",hookEventName:o,hookEventLabel:s,hookHandlerType:"command",hookScope:"turn",hookSource:l?"project":null,hookSourcePath:l,hookStatusMessage:null,hookOutputEntries:a?[{kind:"warning",text:a}]:[]}}function Op(e){return e==="userMessage"||e==="agentMessage"}function Wp(e){return e==="commandExecution"||e==="webSearch"||e==="fileRead"||e==="fileChange"||e==="image"||e==="contextCompaction"}function Up(e){return e==="agentMessage"||e==="reasoning"||e==="agentToolCall"||e==="skillToolCall"||e==="toolCall"||e==="plan"}function Vp(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&&Wp(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=>Up(d.kind))?s:{...s,status:"Awaiting response"}:(o=!0,s))}function Tt(e){return typeof e.sequence=="number"&&Number.isFinite(e.sequence)}function Ar(e){return Tt(e)?e.sequence:Number.POSITIVE_INFINITY}function Ss(e){var h;const r=[];let n=0;for(;n<e.length&&((h=e[n])==null?void 0:h.kind)==="userMessage"&&!Tt(e[n]);)r.push(e[n]),n+=1;const a=e.slice(n);if(!a.some(Tt))return e;const o=a.map(u=>Ar(u)).filter(Number.isFinite),s=o.length>0?Math.max(...o):0,l=[];let i=0;for(;i<a.length;){const u=a[i];if(Tt(u)){l.push({item:u,index:i,order:Ar(u)}),i+=1;continue}const m=i;for(;i<a.length&&!Tt(a[i]);)i+=1;const f=a.slice(m,i),p=[...a.slice(0,m)].reverse().find(Tt),g=a.slice(i).find(Tt),b=p?Ar(p):null,k=g?Ar(g):null;f.forEach((x,j)=>{let w;if(b===null&&k!==null)w=k-(f.length-j)/(f.length+1);else if(b!==null&&k!==null&&k>b){const y=k-b;w=b+(j+1)/(f.length+1)*y}else w=s+1+j/(f.length+1);l.push({item:x,index:m+j,order:w})})}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 Kp(e,r){if(!r||r.length===0)return Ss(e);const n=new Map(r.map(s=>[s.id,s])),a=e.map(s=>{const l=n.get(s.id);if(!l)return s;n.delete(s.id);const i={...s,...l,text:l.text||s.text},d=l.detailText??s.detailText,h=l.previewText??s.previewText,u=l.status??s.status,m=l.sequence??s.sequence;return d!==void 0&&(i.detailText=d),h!==void 0&&(i.previewText=h),u!==void 0&&(i.status=u),m!==void 0&&(i.sequence=m),i}),o=[...n.values()];return o.length===0&&!a.some(Tt)||(a.push(...o),!a.some(s=>typeof s.sequence=="number"&&Number.isFinite(s.sequence)))?a:Ss(a)}function qp(e,r){if(!e)return"";const n=r.filter(d=>d.kind==="agentMessage").map(d=>d.text).filter(d=>d.length>0),a=n.at(-1)??"";if(a){const d=e.lastIndexOf(a);if(d>=0){const h=e.slice(d+a.length);return h.trim()?h:""}}const o=n.join("");if(!o)return e;const s=Math.min(e.length,o.length);let l=0;for(;l<s&&e[l]===o[l];)l+=1;if(l===0)return e;const i=e.slice(l);return i.trim()?i:""}function pl(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function vr(e){return e==="inProgress"||e==="sending"}function Xp(e){var a;const r=[];let n=0;for(;n<e.length;){const o=e[n];if(!o)break;if(o.kind!=="commandExecution"&&o.kind!=="fileChange"&&o.kind!=="webSearch"&&o.kind!=="fileRead"){r.push({kind:"item",key:o.id,item:o}),n+=1;continue}const s=[];for(;n<e.length&&((a=e[n])==null?void 0:a.kind)===o.kind;)s.push(e[n]),n+=1;if(s.length===1){r.push({kind:"item",key:s[0].id,item:s[0]});continue}const l=s.map(i=>i.id).join(":");if(o.kind==="commandExecution"){r.push({kind:"commandGroup",key:l,items:s});continue}if(o.kind==="fileChange"){r.push({kind:"fileChangeGroup",key:l,items:s});continue}if(o.kind==="fileRead"){r.push({kind:"fileReadGroup",key:l,items:s});continue}r.push({kind:"searchGroup",key:l,items:s})}return r}function fl(e,r){return[...e.map(n=>({id:n.id,startedAt:n.startedAt??""})),...r?[{id:r.id,startedAt:r.startedAt??""}]:[]]}function kr(e,r,n){const a=e.get(r)??[];a.push(n),e.set(r,a)}function gl(e,r){return e.find(n=>r&&n.startedAt&&r.localeCompare(n.startedAt)<=0)}function Yp({answeredRequestNotes:e,pendingRequests:r,visibleTurns:n,optimisticTurn:a}){const o=new Set(n.map(p=>p.id)),s=new Map,l=new Map,i=[],d=[];for(const p of e)p.turnId&&o.has(p.turnId)?kr(s,p.turnId,p):i.push(p);for(const p of r)p.turnId&&o.has(p.turnId)?kr(l,p.turnId,p):d.push(p);const h=fl(n,a),u=new Map,m=[],f=[...i.map(p=>({kind:"note",id:p.id,createdAt:p.createdAt??"",note:p})),...d.map(p=>({kind:"request",id:p.id,createdAt:p.createdAt,request:p}))].sort((p,g)=>p.createdAt.localeCompare(g.createdAt));for(const p of f){const g=gl(h,p.createdAt);if(!g){m.push(p);continue}kr(u,g.id,p)}return{notesByTurnId:s,pendingRequestsByTurnId:l,beforeTurnId:u,trailing:m}}function Zp({activityNotes:e,visibleTurns:r,optimisticTurn:n}){const a=[...e].sort((m,f)=>m.createdAt.localeCompare(f.createdAt)),o=fl(r,n),s=[],l=new Map,i=new Map,d=[],u=o.map(m=>m.startedAt).filter(m=>!!m).sort().at(-1)??null;for(const m of a){if(m.anchorTurnId==="__leading__"){s.push(m);continue}if(m.anchorTurnId){o.some(p=>p.id===m.anchorTurnId)?kr(i,m.anchorTurnId,m):s.push(m);continue}const f=gl(o,m.createdAt);if(!f){!u||m.createdAt.localeCompare(u)<=0?s.push(m):d.push(m);continue}kr(l,f.id,m)}return{leading:s,beforeTurnId:l,afterTurnId:i,trailing:d}}function xl({request:e,busy:r=!1,onRespond:n}){const[a,o]=c.useState({}),[s,l]=c.useState({}),[i,d]=c.useState(null),h=e.questions[0]??null,u="__other__",m=e.kind==="planDecision"?"Plan":e.kind==="requestUserInput"?"Answer Required":e.title;function f(x){const j=/\s*\(recommended\)\s*$/i.test(x);return{rawLabel:x,displayLabel:x.replace(/\s*\(recommended\)\s*$/i,"").trim(),recommended:j}}function p(x){h&&(d(x),n==null||n(e.id,{answers:{[h.id]:{answers:[x]}}}))}function g(x){const j=a[x.id]??"";return Array.isArray(j)?j.map(w=>w===u?(s[x.id]??"").trim():w.trim()).filter(Boolean).join(", "):j===u?(s[x.id]??"").trim():j.trim()}function b(x){const j=a[x.id]??"";if(Array.isArray(j))return j.map(y=>y===u?(s[x.id]??"").trim():y.trim()).filter(Boolean);if(j===u){const y=(s[x.id]??"").trim();return y?[y]:[]}const w=j.trim();return w?[w]:[]}function k(x,j){o(w=>{const y=w[x],v=Array.isArray(y)?y:[],S=v.includes(j)?v.filter(N=>N!==j):[...v,j];return{...w,[x]:S}})}return t.jsxs("div",{className:"timeline-pending-card w-full rounded-[1rem] border px-3 py-3 sm:rounded-[1.2rem] sm:px-4",children:[t.jsx("div",{className:"flex items-center justify-between gap-3",children:t.jsxs("div",{children:[t.jsx("p",{className:"timeline-primary-text text-sm font-medium",children:m}),e.kind!=="planDecision"&&e.description&&t.jsx("p",{className:"timeline-soft-text mt-1 text-[13px] leading-5",children:e.description})]})}),t.jsx("div",{className:"mt-3 space-y-3",children:e.questions.map(x=>t.jsxs("div",{className:"timeline-question-section rounded-xl border p-2.5 sm:p-3",children:[t.jsx("p",{className:"timeline-meta-text text-xs uppercase tracking-[0.2em]",children:x.header}),t.jsx("p",{className:"timeline-primary-text mt-1 text-[13px] leading-5 sm:text-sm",children:x.question}),e.kind==="planDecision"&&x.options&&x.options.length>0?t.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:x.options.map((j,w)=>{const y=f(j.label),v=y.displayLabel.toLowerCase()==="implement";return t.jsxs("button",{type:"button",disabled:r,onClick:()=>p(j.label),className:`relative rounded-2xl border px-2.5 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${w===0?"ui-action-info":"border-stone-700 text-stone-200 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:j.description,children:[y.recommended?t.jsx("span",{"aria-hidden":"true",className:"absolute right-1.5 top-1 inline-flex h-3.5 w-3.5 items-center justify-center rounded-full bg-white/18 text-[10px] leading-none text-current",children:"✦"}):null,r&&i===j.label?v?"Starting...":"Saving...":y.displayLabel]},j.label)})}):x.options&&x.options.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[x.options.map(j=>{const w=f(j.label),y=a[x.id];return t.jsxs("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?k(x.id,j.label):o(v=>({...v,[x.id]:j.label})),className:`relative rounded-2xl border px-3 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${(x.multiSelect?Array.isArray(y)&&y.includes(j.label):y===j.label)?"ui-status-warning":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:j.description,children:[w.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,w.displayLabel]},j.label)}),x.isOther&&(()=>{const j=a[x.id];return t.jsx("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?k(x.id,u):o(w=>({...w,[x.id]:u})),className:`rounded-2xl border px-3 py-1.5 text-[12px] leading-4 transition sm:text-[13px] ${(x.multiSelect?Array.isArray(j)&&j.includes(u):j===u)?"ui-status-info":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Not from above"})})()]}),x.isOther&&(()=>{const j=a[x.id];return(x.multiSelect?Array.isArray(j)&&j.includes(u):j===u)?t.jsx("input",{"aria-label":`${x.header} custom answer`,value:s[x.id]??"",onChange:y=>l(v=>({...v,[x.id]:y.target.value})),placeholder:"Enter a custom answer",className:"mt-3 w-full rounded-xl border border-stone-700 bg-stone-900 px-3 py-2 text-sm text-stone-100 outline-none transition focus:border-sky-300"}):null})()]}):t.jsx("input",{"aria-label":x.header,value:a[x.id]??"",onChange:j=>o(w=>({...w,[x.id]:j.target.value})),className:"mt-3 w-full rounded-xl border border-stone-700 bg-stone-900 px-3 py-2 text-sm text-stone-100 outline-none transition focus:border-amber-300"})]},x.id))}),e.kind!=="planDecision"&&t.jsx("div",{className:"mt-3 flex justify-end",children:t.jsx("button",{type:"button",disabled:r||e.questions.some(x=>!g(x)),onClick:()=>void(n==null?void 0:n(e.id,{answers:Object.fromEntries(e.questions.map(x=>[x.id,{answers:b(x)}]))})),className:"ui-action-info rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:r?"Submitting...":"Submit"})})]})}function bl({note:e}){return t.jsxs("div",{className:"timeline-note-card w-full rounded-2xl border px-3 py-2.5",children:[t.jsx("p",{className:"timeline-meta-text text-[11px] uppercase tracking-[0.2em]",children:e.title}),t.jsx("div",{className:"mt-1 space-y-1",children:e.summaryLines.map((r,n)=>t.jsxs("p",{className:"timeline-primary-text text-[13px] leading-5",children:["You selected ",r]},`${e.id}-${n}`))})]})}function vl({note:e,onOpenThread:r,onOpenLinkedThread:n}){const a=e.kind==="forkCreated"?"Fork":e.kind==="forkSource"?"Fork source":"System",o=e.kind==="forkCreated"?`Thread forked from Turn ${e.turnIndex??"?"}`:e.kind==="forkSource"?`Forked from ${e.linkedThreadTitle??"source thread"} at Turn ${e.turnIndex??"?"}`:e.text??"";return t.jsxs("div",{className:"timeline-activity-card w-full rounded-2xl border px-3 py-2.5",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("p",{className:"timeline-meta-text text-[11px] uppercase tracking-[0.2em]",children:a}),t.jsx("time",{dateTime:e.createdAt,title:Wt(e.createdAt),className:"timeline-meta-text text-[10px]",children:xt(e.createdAt)})]}),t.jsx("p",{className:"timeline-primary-text mt-1 text-[13px] leading-5",children:o}),e.linkedThreadId?t.jsx("button",{type:"button",onClick:()=>{const s=e.linkedThreadId;s&&(n==null||n(s),r==null||r(s))},className:"relative z-10 mt-2 inline-flex cursor-pointer rounded-full border border-amber-300/30 px-3 py-1.5 text-xs text-amber-100 transition hover:bg-amber-300/10",children:e.kind==="forkCreated"?"Open fork":"Back to source"}):null]})}function pr({notes:e,onOpenThread:r,onOpenLinkedThread:n}){return e.length===0?null:t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:e.map(a=>t.jsx(vl,{note:a,onOpenThread:r,onOpenLinkedThread:n},a.id))})}function Xn({entries:e,respondingRequestId:r,onRespondToRequest:n}){return e.length===0?null:t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:e.map(a=>a.kind==="note"?t.jsx(bl,{note:a.note},a.id):t.jsx(xl,{request:a.request,busy:r===a.request.id,onRespond:n},a.id))})}function Jp({notes:e,requests:r,respondingRequestId:n,onRespondToRequest:a}){const o=[...e.map(s=>({kind:"note",id:s.id,createdAt:s.createdAt??"",note:s})),...r.map(s=>({kind:"request",id:s.id,createdAt:s.createdAt,request:s}))].sort((s,l)=>s.createdAt.localeCompare(l.createdAt));return t.jsx(Xn,{entries:o,respondingRequestId:n,onRespondToRequest:a})}function Qp({entries:e,respondingRequestId:r,onRespondToRequest:n,onOpenThread:a,onOpenLinkedThread:o}){return e.length===0?null:t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:[...e].sort((s,l)=>s.createdAt.localeCompare(l.createdAt)).map(s=>s.kind==="activity"?t.jsx(vl,{note:s.note,onOpenThread:a,onOpenLinkedThread:o},s.id):s.kind==="note"?t.jsx(bl,{note:s.note},s.id):t.jsx(xl,{request:s.request,busy:r===s.request.id,onRespond:n},s.id))})}function ef({entries:e,expandedGroups:r,onToggleGroupedItem:n,renderCommandGroup:a,renderFileChangeGroup:o,renderFileReadGroup:s,renderItem:l,renderSearchGroup:i}){return t.jsx(t.Fragment,{children:e.map(d=>{const h=r[d.key]??!1,u=()=>n(d.key);return d.kind==="commandGroup"?a(d,h,u):d.kind==="fileChangeGroup"?o(d,h,u):d.kind==="searchGroup"?i(d,h,u):d.kind==="fileReadGroup"?s(d,h,u):l(d)})})}function sn({children:e,className:r,count:n,countBadgeClassName:a,desktopIconClassName:o,expanded:s,expandedListClassName:l,icon:i,onToggleExpanded:d,runningIndicator:h,summary:u,timeMeta:m,toggleAriaLabel:f,trailingSummary:p}){return t.jsx("div",{className:`thread-graph-history-group ${r} relative min-w-0 w-full overflow-hidden rounded-[0.9rem] border px-3 py-2.5`,children:t.jsxs("div",{className:"flex items-start gap-2.5",children:[t.jsxs("div",{className:"thread-graph-history-group-icon mt-0.5 flex shrink-0 items-center",children:[t.jsxs("span",{className:`relative inline-flex h-8 w-8 items-center justify-center rounded-[0.9rem] border shadow-sm shadow-stone-950/20 ${o}`,children:[i,t.jsx("span",{className:`absolute -right-1 -top-1 inline-flex min-w-[1.1rem] items-center justify-center rounded-full border bg-stone-950/90 px-1 text-[9px] font-semibold leading-4 ${a}`,children:n})]}),h]}),t.jsxs("div",{className:"thread-graph-history-group-card min-w-0 flex-1 rounded-[0.85rem] border px-3 py-2",children:[t.jsxs("button",{type:"button","aria-expanded":s,"aria-label":f,onClick:d,className:"thread-graph-history-group-toggle flex w-full min-w-0 items-center justify-between gap-3 text-left",children:[t.jsx("div",{className:"thread-graph-history-group-summary min-w-0 flex flex-1 flex-wrap items-center gap-2 pr-1",children:u}),p||m?t.jsxs("div",{className:"inline-flex shrink-0 items-center gap-2",children:[p,m]}):null]}),s?t.jsx("div",{className:`thread-graph-history-group-list mt-3 space-y-2 border-t pt-3 ${l}`,children:e}):null]})]})})}Lr();Pt();var tf=Cr("inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden whitespace-nowrap rounded-md border px-2 py-0.5 text-xs font-medium outline-none transition-[color,box-shadow] focus-visible:ring-[3px] [&>svg]:pointer-events-none [&>svg]:size-3",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-white",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function on({asChild:e=!1,className:r,variant:n,...a}){const o=e?Gs:"span";return t.jsx(o,{"data-slot":"badge",className:rt(tf({variant:n,className:r})),...a})}function ha(e){if(!e)return!1;const r=e.trim().toLowerCase();return r==="running"||r==="in_progress"||r==="in progress"||r==="pending"}function rf(){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 nf(){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 af(){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 sf(){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 of(e){const r=e.trim();if(!r)return"";const n=r.match(/(, \+\d+ more.*)$/),a=(n==null?void 0:n[1])??"",s=(a?r.slice(0,-a.length):r).replace(/\\/g,"/");if(!s.startsWith("/"))return`${s.replace(/^\.\//,"")}${a}`;const l=["/apps/","/packages/","/src/","/test/","/tests/","/docs/","/config/","/scripts/","/e2e/","/.agents/","/.codex/"];for(const i of l){const d=s.indexOf(i);if(d>=0)return`${s.slice(d+1)}${a}`}return r}function kl(e,r=42){const n=of(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 lf(e){var a;const r=[];if(typeof e.changedFiles=="number"&&e.changedFiles>0&&r.push(`${e.changedFiles} ${e.changedFiles===1?"file":"files"}`),typeof e.addedLines=="number"&&e.addedLines>0&&r.push(`+${e.addedLines}`),typeof e.removedLines=="number"&&e.removedLines>0&&r.push(`-${e.removedLines}`),r.length>0)return r;const n=(a=e.previewText)==null?void 0:a.trim();return n?n.replace(/\bfiles changed\b/gi,"files").replace(/\bfile changed\b/gi,"file").split("·").map(o=>o.trim()).filter(Boolean):[]}function Yn({tone:e="amber"}){const r=e==="emerald"?"bg-sky-200/90":e==="sky"?"bg-sky-300/90":"bg-amber-200/90";return t.jsx("span",{className:"ml-1.5 inline-flex items-center gap-1","aria-hidden":"true",children:[0,1,2].map(n=>t.jsx("span",{className:`h-1.5 w-1.5 animate-pulse rounded-full ${r}`,style:{animationDelay:`${n*180}ms`}},n))})}function df(e){var n;const r=e.replace(/\r\n/g,`
|
|
3664
3664
|
`).split(`
|
|
3665
|
-
`);for(;r.length>1&&((n=r.at(-1))==null?void 0:n.trim())==="";)r.pop();return r}function bt(e){const r=cf(e);return r.length===1?{firstLine:r[0]??"",showGap:!1,isTruncated:!1}:{firstLine:r[0]??"",showGap:!0,isTruncated:!0}}function jl(e){const r=(e==null?void 0:e.trim().toLowerCase())??"";return r==="completed"||r==="complete"||r==="success"||r==="succeeded"?{className:"is-completed",icon:t.jsx(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"}:ua(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 hf(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 uf(e){switch(e){case"plan":return"is-plan";case"context":return"is-context";case"generic":return"is-generic";case"image":return"is-image";case"fileChange":return"is-file-change";case"artifact":return"is-artifact";case"hook":return"is-hook"}}function Kt({actions:e,children:r,className:n,headerMeta:a,icon:o,item:s,timeMeta:l,title:i,tone:d}){const h=jl(s.status);return t.jsxs("div",{className:`thread-graph-event thread-graph-history-event ${uf(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(ln,{variant:"outline",className:`thread-graph-tool-badge ${h.className} rounded-full px-2 py-0.5 text-xs font-normal`,title:h.label,"aria-label":`Status: ${h.label}`,children:[h.icon,t.jsx("span",{className:"thread-graph-status-label",children:h.label})]}):null,a]}),e||l?t.jsxs("div",{className:"thread-graph-history-event-actions",children:[e,l]}):null]}),r?t.jsx("div",{className:"thread-graph-history-event-body",children:r}):null]})]})}function dr({actionLabel:e="Open details",actionTitle:r,autoOpen:n=!1,className:a,details:o,icon:s,item:l,onOpen:i,preview:d,timeMeta:h,title:u,tone:m}){const f=jl(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 ${hf(m)} ${a??""}`,children:t.jsx(Sr,{type:"single",collapsible:!0,onValueChange:v=>{g(v||void 0)},className:"thread-graph-tool-accordion thread-graph-history-tool-accordion w-full overflow-hidden rounded-lg border",value:p??"",children:t.jsxs(Tr,{value:"item-1",className:"border-0",children:[t.jsxs(an,{"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(ln,{variant:"outline",className:`thread-graph-tool-badge ${f.className} ml-1 sm:ml-2 rounded-full px-2 py-0.5 text-xs font-normal`,title:f.label,"aria-label":`Status: ${f.label}`,children:[f.icon,t.jsx("span",{className:"thread-graph-status-label",children:f.label})]})]}),h?t.jsx("span",{className:"thread-graph-history-tool-time shrink-0",children:h}):null]}),t.jsxs(Er,{className:"thread-graph-tool-content thread-graph-history-tool-content px-4 pb-4 pt-1",children:[t.jsxs("section",{children:[t.jsx("h4",{children:"Summary"}),t.jsxs("div",{className:"thread-graph-history-tool-summary",children:[t.jsx(lr,{text:d.firstLine}),d.showGap?t.jsx("span",{className:"thread-graph-history-tool-ellipsis",children:"..."}):null]})]}),o?t.jsx("section",{children:o}):null,t.jsxs("button",{type:"button","aria-label":e,onClick:i,className:"thread-graph-history-tool-open inline-flex items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium transition",children:[t.jsx(B.ExternalLink,{className:"h-3.5 w-3.5"}),r]})]})]})})})}var mf=c.memo(function({item:r,scrollRootRef:n,onBeforeResize:a,timeMeta:o}){return t.jsx(Kt,{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(pl,{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}:{}})})})}),pf=c.memo(function({item:r,timeMeta:n}){const a=ua(r.status)||r.text==="Compacting context",o=a?"Compacting context":"Context compacted",s=r.detailText&&r.detailText!==o?r.detailText:null;return t.jsxs(Kt,{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(Zn,{tone:"emerald"}):null]}),s?t.jsx("p",{className:"thread-graph-history-event-secondary",title:s,children:s}):null]})}),ff=c.memo(function({item:r,timeMeta:n}){return t.jsx(Kt,{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(lr,{text:r.text})})})}),gf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=bt(n.previewText??n.text);return t.jsx(dr,{actionLabel:"Open full command",actionTitle:"Command Output",autoOpen:r,className:"thread-graph-event-command",icon:t.jsx(B.Terminal,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Command Output"),preview:s,timeMeta:o,title:"command",tone:"command"})}),xf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=bt(n.text);return t.jsx(dr,{actionLabel:"Open full tool call",actionTitle:"Tool Call Details",autoOpen:r,className:"thread-graph-event-tool",icon:t.jsx(B.Wrench,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Tool Call Details"),preview:s,timeMeta:o,title:"tool_call",tone:"tool"})}),bf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=bt(n.text);return t.jsx(dr,{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"})}),vf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=bt(n.text);return t.jsx(dr,{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"})}),kf=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=bt(s);return t.jsx(dr,{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"})}),wf=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=bt(s);return t.jsx(dr,{actionLabel:"Open full file read",actionTitle:"File Read Details",autoOpen:r,className:"thread-graph-event-file-read",icon:t.jsx(B.FileText,{className:"h-4 w-4"}),item:n,onOpen:()=>a("File Read Details",l),preview:i,timeMeta:o,title:"file_read",tone:"fileRead"})}),yf=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(Kt,{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]})}),jf=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=yl(o??((p=r.previewText)==null?void 0:p.trim())??r.text,48),i=df(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(Kt,{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"})}),Nf=c.memo(function({item:r,onSelect:n,timeMeta:a}){const o=ha(),[s,l]=c.useState(!1),i=r.artifact,d=i?o.renderArtifact({artifact:i,expanded:s,onToggleExpanded:()=>l(h=>!h)}):null;return t.jsx(Kt,{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]})})}),Cf=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(`
|
|
3666
|
-
`).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=bt(a||(s&&s!==o?s:o)),d=!!(a&&i.showGap);return t.jsx(Kt,{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(lr,{text:i.firstLine})]}):t.jsx(lr,{text:i.firstLine&&i.firstLine!==o?`${o} · ${i.firstLine}`:o})}),d?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})})}),Sf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o,timeMeta:s}){const l=r.filter(d=>ua(d.status)).length,i=r.length===1?"1 command":`${r.length} commands`;return t.jsx(on,{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(sf,{}),onToggleExpanded:a,runningIndicator:l>0?t.jsx(Zn,{}):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(Zn,{})}):null]}),timeMeta:s,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} command entries`,children:r.map((d,h)=>{const u=bt(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)})})}),Tf=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(on,{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(of,{}),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=bt(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)})})}),Ef=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(on,{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(af,{}),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=bt(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)})})}),Lf=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(on,{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(nf,{}),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,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:()=>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:yl(p,34)}),t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[(u.addedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-add",children:["+",u.addedLines]}):null,(u.removedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-remove",children:["-",u.removedLines]}):null]})]})},u.id)})})});function If(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 zf({status:e}){const r=If(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(ln,{"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 Pf({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(ln,{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(zf,{status:r.status})]},`${e.turnId}-${n}`))})]})}function Rf({footer:e,history:r,liveHookPrompt:n,liveOutput:a,livePlan:o}){return t.jsxs(t.Fragment,{children:[r,o?t.jsx(Pf,{livePlan:o}):null,n??a??null,e]})}function Mf({absoluteIndex:e,body:r,collapsed:n,collapsedBody:a,error:o,footer:s,headerStatus:l,isActive:i=!1,refCallback:d,startedAt:h,timeLabel:u,timeTitle:m,tokenSummary:f}){return t.jsxs("article",{ref:d,"data-testid":"chat-turn","data-turn-active":i?"true":"false",className:"thread-graph-turn px-3 py-2 sm:px-5 sm:py-3",children:[t.jsx("div",{className:"thread-graph-turn-header flex items-start justify-between gap-2",children:t.jsxs("div",{className:"min-w-0 flex flex-1 items-start gap-1.5",children:[t.jsxs("div",{className:"min-w-0 flex flex-1 items-center gap-1.5 overflow-hidden",children:[t.jsxs("span",{className:"thread-graph-turn-index rounded-[0.6rem] border px-1.5 py-0.5 text-[10px] uppercase tracking-[0.16em]",children:["Turn ",e]}),t.jsx("time",{dateTime:h??void 0,title:m,className:"thread-graph-turn-time shrink-0 text-[10px] sm:text-[11px]",children:u}),l,o?t.jsx("p",{className:"hidden truncate text-[11px] text-rose-200 sm:block",children:o}):null]}),f]})}),o?t.jsx("p",{className:"mt-1 text-[11px] text-rose-200 sm:hidden",children:o}):null,t.jsxs("div",{className:"thread-graph-turn-body mt-2 space-y-2",children:[n?a:r,n?null:s]})]})}function Af(){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 $f(){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 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.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 _f(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.45",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M6.2 3.2a2.3 2.3 0 0 0-2.95 3.5A2.4 2.4 0 0 0 4.5 11h.2c.25 1.1 1.1 1.8 2.3 1.8h1.8c1.2 0 2.05-.7 2.3-1.8h.2A2.4 2.4 0 0 0 12.75 6.7 2.3 2.3 0 0 0 9.8 3.2"}),t.jsx("path",{d:"M6.3 6.15c.45-.42 1.02-.65 1.7-.65s1.25.23 1.7.65"}),t.jsx("path",{d:"M8 5.5v4.75"}),t.jsx("path",{d:"M6.75 9.05 8 10.25l1.25-1.2"})]})}function fr(e){if(!Number.isFinite(e)||e<=0)return"0";if(e>=1e6){const r=e>=1e7?Math.round(e/1e6):e/1e6;return`${String(r.toFixed(1)).replace(/\.0$/,"")}m`}if(e>=1e3){const r=e>=1e4?Math.round(e/1e3):e/1e3;return`${String(r.toFixed(1)).replace(/\.0$/,"")}k`}return String(Math.round(e))}function ma(e){return!Number.isFinite(e)||e<=0?"$0":e>=100?`$${Math.round(e)}`:e>=10?`$${String(e.toFixed(1)).replace(/\.0$/,"")}`:e>=1?`$${String(e.toFixed(2)).replace(/0$/,"").replace(/\.$/,"")}`:e>=.1?`$${e.toFixed(2)}`:e>=.01?`$${e.toFixed(3)}`:e>=.001?`$${e.toFixed(4)}`:"<$0.001"}function nr(e){return!Number.isFinite(e)||e<=0?"$0.0000":`$${e.toFixed(4)}`}function $r(e,r,n){const a=e??null;return!Number.isFinite(a??NaN)||a===null||r<=0||n<=0?null:a*n/r}function Nl(e){var d,h,u,m,f,p;const r=(d=e.tokenUsage)==null?void 0:d.total;if(!r)return[];const n=Math.max(r.inputTokens-r.cachedInputTokens-(r.cacheWriteInputTokens??0),0),a=Math.max(r.cachedInputTokens,0),o=Math.max(r.cacheWriteInputTokens??0,0),s=Math.max(r.reasoningOutputTokens,0),l=Math.max(r.outputTokens-s,0);return[n>0?{id:"in",label:"Input",tokenCompactValue:fr(n),tokenRawValue:n,usdCompactValue:e.priceEstimate?nr(e.priceEstimate.inputUsd):"--",usdRawValue:((h=e.priceEstimate)==null?void 0:h.inputUsd)??null,className:"token-badge-in",icon:t.jsx(Af,{})}:null,a>0?{id:"cache",label:"Cached input",tokenCompactValue:fr(a),tokenRawValue:a,usdCompactValue:e.priceEstimate?nr(e.priceEstimate.cachedInputUsd):"--",usdRawValue:((u=e.priceEstimate)==null?void 0:u.cachedInputUsd)??null,className:"token-badge-cache",icon:t.jsx(Ls,{})}:null,o>0?{id:"cache-write",label:"Cache write",tokenCompactValue:fr(o),tokenRawValue:o,usdCompactValue:e.priceEstimate?nr(e.priceEstimate.cacheWriteInputUsd??0):"--",usdRawValue:((m=e.priceEstimate)==null?void 0:m.cacheWriteInputUsd)??null,className:"token-badge-cache",icon:t.jsx(Ls,{})}:null,l>0?{id:"out",label:"Output",tokenCompactValue:fr(l),tokenRawValue:l,usdCompactValue:e.priceEstimate?nr($r(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),l)??0):"--",usdRawValue:$r((f=e.priceEstimate)==null?void 0:f.outputUsd,Math.max(r.outputTokens,0),l),className:"token-badge-out",icon:t.jsx($f,{})}:null,s>0?{id:"reason",label:"Reasoning",tokenCompactValue:fr(s),tokenRawValue:s,usdCompactValue:e.priceEstimate?nr($r(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),s)??0):"--",usdRawValue:$r((p=e.priceEstimate)==null?void 0:p.outputUsd,Math.max(r.outputTokens,0),s),className:"token-badge-reason",icon:t.jsx(_f,{})}:null].filter(g=>g!==null)}function Df(e){return Nl(e).map(r=>({id:r.id,label:r.tokenCompactValue,title:`${r.label}: ${r.tokenRawValue} tokens`,className:r.className,icon:r.icon}))}function Cl(e){return{label:e.priceEstimate?ma(e.priceEstimate.totalUsd):"--",title:e.priceEstimate===null||e.priceEstimate===void 0?"Price estimate unavailable for this model.":`Estimated cost: ${nr(e.priceEstimate.totalUsd)}`,className:e.priceEstimate?"token-badge-total":"token-badge-empty"}}var Tn="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 Bf({turn:e}){const r=Nl(e),n=Cl(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 v=g.getBoundingClientRect(),x=b.offsetWidth||b.getBoundingClientRect().width;if(x<=0)return;const j=window.innerWidth||document.documentElement.clientWidth,w=12,y=v.left+v.width/2-x/2,k=w,S=Math.max(k,j-w-x),N=Math.min(Math.max(y,k),S);d(Math.round(N-y))};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:`${Tn} 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:`${Tn} ${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:`${Tn} 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 Gf({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 Is(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 Ff(e){switch(e.kind){case"fileChange":case"webSearch":case"image":case"contextCompaction":return!0;case"commandExecution":case"toolCall":return!gl(e.status);default:return!1}}function Hf(e,r,n){if(!e||!vr(n))return e;const a=e.plan.findIndex(i=>Is(i.status)==="in_progress");if(a<0)return e;const o=e.plan.findIndex((i,d)=>d>a&&Is(i.status)==="pending");if(o<0||!r.some(i=>Ff(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 Of(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 zs({status:e}){const r=cl(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(Gf,{tone:"emerald"})})}function Ps({turn:e,variant:r="header"}){const n=cl(e.status),a=Of(e),o=Df(e),s=Cl(e),l=vr(e.status),i=e.status==="failed"?"border-rose-300/20 bg-rose-300/[0.06] text-rose-100":l?"border-sky-300/22 bg-sky-300/[0.08] text-sky-100":"border-stone-700/90 bg-stone-900/70 text-stone-200";if(r==="footer")return t.jsxs("div",{className:`flex w-full flex-col gap-1.5 rounded-[0.95rem] border px-3 py-2 text-xs ${i}`,children:[t.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(zs,{status:e.status}),t.jsx("span",{className:"timeline-soft-text min-w-0 truncate",children:a})]}),e.startedAt&&t.jsx("time",{dateTime:e.startedAt,title:Wt(e.startedAt),className:"timeline-meta-text shrink-0 text-[11px]",children:xt(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(zs,{status:e.status}),t.jsx("span",{className:"timeline-meta-text min-w-0 truncate",children:a})]})}function Wf(e,r){return e.createdAt??r}var pa=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,v,x;if(Wp(n.kind))return t.jsx(It,{threadId:r,item:n,scrollRootRef:a,timeLabel:m,timeTitle:f,...h?{onBeforeMessageResize:h}:{},...u?{adapter:u}:{}});if(n.kind==="reasoning")return t.jsx(It,{item:{...n,kind:"agentMessage",status:n.status??null},scrollRootRef:a,timeLabel:m,timeTitle:f,...h?{onBeforeMessageResize:h}:{}});if(n.kind==="artifact")return t.jsx(Nf,{item:n,timeMeta:p,...d?{onSelect:(j,w)=>d({item:j,artifact:w})}:{}});if(n.kind==="commandExecution")return t.jsx(gf,{autoOpen:g,item:n,onOpen:s,timeMeta:p});if(n.kind==="toolCall")return t.jsx(xf,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="agentToolCall")return t.jsx(bf,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="skillToolCall")return t.jsx(vf,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="webSearch"){const j=n,w=((b=j.detailText)==null?void 0:b.trim())||j.text||"Web search";return t.jsx(kf,{autoOpen:g,item:j,timeMeta:p,onOpen:()=>i(j,"Web Search Details",w,"Loading full web search details...","Unable to load full web search details.")})}if(n.kind==="fileRead"){const j=n,w=((v=j.detailText)==null?void 0:v.trim())||j.text||"File read";return t.jsx(wf,{autoOpen:g,item:j,timeMeta:p,onOpen:()=>i(j,"File Read Details",w,"Loading full file read details...","Unable to load full file read details.")})}if(n.kind==="image")return t.jsx(yf,{threadId:r,item:n,onOpen:o,getImageAssetUrl:u==null?void 0:u.getImageAssetUrl,timeMeta:p});if(n.kind==="plan")return t.jsx(mf,{item:n,scrollRootRef:a,timeMeta:p,...h?{onBeforeResize:h}:{}});if(n.kind==="fileChange"){const j=n,w=((x=j.detailText)==null?void 0:x.trim())||j.text||"File change";return t.jsx(jf,{item:j,timeMeta:p,onOpen:()=>i(j,"File Change Details",w,"Loading full file change details...","Unable to load full file change details.")})}return n.kind==="contextCompaction"?t.jsx(pf,{item:n,timeMeta:p}):n.kind==="hook"?t.jsx(Cf,{item:n,timeMeta:p}):t.jsx(ff,{item:n,timeMeta:p})});function Rs(e){return e==="completed"||e==="failed"||e==="interrupted"}function Uf(e){const r=Date.parse(e.createdAt??"");return Number.isFinite(r)?r:null}function Vf(e){let r=null;for(const n of e){const a=Uf(n);a!==null&&(r=r===null?a:Math.max(r,a))}return r}function Kf(e,r){const n=Date.parse(e??""),a=Vf(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 qf(e,r){const n=Date.parse(e??""),a=Date.parse(r??"");if(!Number.isFinite(n)||!Number.isFinite(a))return r?xt(r):"Time unavailable";const o=Math.max(0,Math.round((a-n)/1e3)),s=Math.floor(o/3600),l=Math.floor(o%3600/60),i=o%60;return s>0?`${s}h ${l}m`:l>0?`${l}m ${i}s`:`${i}s`}function wr({absoluteLabel:e,className:r="",timestamp:n,turnStartedAt:a}){const[o,s]=c.useState(!1);if(!n)return null;const l=Wt(n),i=qf(a,n),d=o?e:i;return t.jsx("span",{role:"button",tabIndex:0,className:`thread-graph-relative-time rounded-full px-1.5 py-0.5 text-[10px] leading-none transition sm:text-[11px] ${r}`,title:o?i:l,"aria-label":`Toggle timestamp, currently ${d}`,onClick:h=>{h.stopPropagation(),s(u=>!u)},onKeyDown:h=>{h.key!=="Enter"&&h.key!==" "||(h.preventDefault(),h.stopPropagation(),s(u=>!u))},children:t.jsx("time",{dateTime:n,children:d})})}function _r(e){var r;return e.kind==="item"?e.item.createdAt??null:((r=e.items.find(n=>n.createdAt))==null?void 0:r.createdAt)??null}function Xf(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 En=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:v,scrollRootRef:x,articleRef:j,isLatestVisibleTurn:w=!1}){const y=!!l||!!d||!!(i&&i.length>0),k=h||vr(a.status)||y||w,S=k&&!vr(a.status)?{...a,status:"inProgress"}:a,N=c.useMemo(()=>qp(a.items,i),[i,a.items]),L=c.useMemo(()=>Hf(l,N,a.status),[l,N,a.status]),R=c.useMemo(()=>Xp(d,N),[d,N]),P=c.useMemo(()=>Kp(N,k),[k,N]),J=c.useMemo(()=>Yp(P),[P]),D=h||vr(a.status)||y,Y=xt(a.startedAt),Z=Wt(a.startedAt),I=c.useMemo(()=>fl(R),[R]),[re,oe]=c.useState({}),$=c.useCallback(q=>{oe(de=>({...de,[q]:!de[q]}))},[]),Q=t.jsx(Yf,{entries:J,expandedGroups:re,onToggleGroupedItem:$,threadId:r,scrollRootRef:x,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,...v?{onBeforeMessageResize:v}:{},fallbackTimestamp:a.startedAt,fallbackTimeLabel:Y,fallbackTimeTitle:Z,turnStartedAt:a.startedAt,autoOpenLatestToolDetails:D,...b?{onSelectArtifact:b}:{},...n?{adapter:n}:{}}),_=I?t.jsx(pa,{threadId:r,item:I,scrollRootRef:x,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,timeLabel:a.startedAt?t.jsx(wr,{absoluteLabel:Y,timestamp:a.startedAt,turnStartedAt:a.startedAt}):Y,timeTitle:Z,timeMeta:null,...b?{onSelectArtifact:b}:{},...n?{adapter:n}:{}}):null,ee=!I&&R?t.jsx(It,{item:{id:"live-agent-message",kind:"agentMessage",text:R},scrollRootRef:x,timeLabel:a.startedAt?t.jsx(wr,{absoluteLabel:Y,timestamp:a.startedAt,turnStartedAt:a.startedAt}):Y,timeTitle:Z,streaming:!0,...v?{onBeforeMessageResize:v}:{}}):null,W=k?t.jsx(Ps,{turn:S,variant:"footer"}):null,T=c.useMemo(()=>Xf(J),[J]),K=c.useMemo(()=>Kf(a.startedAt,N),[N,a.startedAt]),G=T.hiddenEntries.length>0,E=s&&G,U=Rs(a.status)&&G&&!E?t.jsxs("button",{type:"button",className:"thread-graph-worked-summary group flex w-full items-center gap-2 py-2 text-left text-sm transition",onClick:()=>u(a.id,!1),"aria-label":`${K}. Collapse turn ${o}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:K}),t.jsx(B.ChevronDown,{className:"h-4 w-4 shrink-0 transition group-hover:translate-y-0.5"}),t.jsx("span",{className:"thread-graph-worked-rule h-px min-w-0 flex-1","aria-hidden":"true"})]}):null,H=Rs(a.status)&&G?t.jsxs("div",{className:"thread-graph-turn-collapsed-summary space-y-2",children:[T.users.map(q=>t.jsx(It,{threadId:r,item:q,scrollRootRef:x,timeLabel:q.createdAt?xt(q.createdAt):Y,timeTitle:q.createdAt?Wt(q.createdAt):Z,...v?{onBeforeMessageResize:v}:{},...n?{adapter:n}:{}},q.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":`${K}. Expand turn ${o}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:K}),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(It,{threadId:r,item:T.finalAgent,scrollRootRef:x,timeLabel:T.finalAgent.createdAt?t.jsx(wr,{absoluteLabel:xt(T.finalAgent.createdAt),timestamp:T.finalAgent.createdAt,turnStartedAt:a.startedAt}):Y,timeTitle:T.finalAgent.createdAt?Wt(T.finalAgent.createdAt):Z,...v?{onBeforeMessageResize:v}:{},...n?{adapter:n}:{}}):null]}):null,se=t.jsx(Rf,{footer:W,history:t.jsxs(t.Fragment,{children:[U,Q]}),liveHookPrompt:_,liveOutput:ee,livePlan:L});return t.jsx(Mf,{absoluteIndex:o,body:se,collapsed:E,collapsedBody:H,error:a.error,headerStatus:t.jsx(Ps,{turn:a}),isActive:k,refCallback:j,startedAt:a.startedAt,timeLabel:Y,timeTitle:Z,tokenSummary:t.jsx(Bf,{turn:a})})});function Yf({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:v=!1}){var w;const x=((w=e.at(-1))==null?void 0:w.key)??null,j=c.useCallback(y=>y?t.jsx(wr,{absoluteLabel:xt(y),timestamp:y,turnStartedAt:b??f}):null,[f,b]);return t.jsx(tf,{entries:e,expandedGroups:r,onToggleGroupedItem:n,renderCommandGroup:(y,k,S)=>t.jsx(Sf,{items:y.items,expanded:k,onToggleExpanded:S,onOpen:l,timeMeta:j(_r(y))},y.key),renderFileChangeGroup:(y,k,S)=>t.jsx(Lf,{items:y.items,expanded:k,onToggleExpanded:S,onOpen:s,timeMeta:j(_r(y))},y.key),renderSearchGroup:(y,k,S)=>t.jsx(Tf,{items:y.items,expanded:k,onToggleExpanded:S,onOpen:s,timeMeta:j(_r(y))},y.key),renderFileReadGroup:(y,k,S)=>t.jsx(Ef,{items:y.items,expanded:k,onToggleExpanded:S,onOpen:s,timeMeta:j(_r(y))},y.key),renderItem:y=>{const k=Wf(y.item,f??null),N=y.item.kind==="userMessage"?y.item.createdAt?xt(k):p:y.item.createdAt?t.jsx(wr,{absoluteLabel:xt(k),timestamp:k,turnStartedAt:b??f}):p;return t.jsx(pa,{threadId:a,item:y.item,scrollRootRef:o,timeLabel:N,timeTitle:y.item.createdAt?Wt(k):g,timeMeta:j(k),autoOpenToolDetails:v&&y.key===x,onOpenExpandedText:s,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,...u?{onBeforeMessageResize:u}:{},...h?{onSelectArtifact:h}:{},...m?{adapter:m}:{}},y.key)}})}var Ms=3,Zf=3,Jn=80;function gr(e,r=Jn){return e.scrollHeight-e.scrollTop-e.clientHeight<=r}function Jf(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 Qf(e){return e.map(n=>{const a=n.createdAt;return typeof a=="string"&&a.trim()?a:null}).filter(n=>!!n).sort()[0]??null}function eg(e,r){return{id:e,startedAt:Qf(r),status:"inProgress",error:null,model:null,reasoningEffort:null,reasoningEffortAvailable:null,tokenUsage:null,priceEstimate:null,items:[]}}function As(e,r,n){return{id:e.id,kind:e.kind,title:r,text:n}}function tg({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:v,errorText:x,useSelectionCallback:j})=>{if(!p.hasDeferredDetail||!e){i(p,As(p,g,b),j);return}const w=a.current.get(p.id);if(w){i(p,w,j);return}const y=n.current+1;n.current=y,j&&r||s({title:g,text:v});try{const k=await e(p.id);if(a.current.set(p.id,k),n.current!==y)return;i(p,k,j)}catch(k){if(n.current!==y)return;i(p,As(p,g,k instanceof Error?k.message:x),j)}},[e,r,i]),h=c.useCallback(async(p,g)=>{var b;await d({item:p,fallbackTitle:g,fallbackText:((b=p.detailText)==null?void 0:b.trim())||p.text||"Command output",loadingText:"Loading full command output...",errorText:"Unable to load full command output.",useSelectionCallback:!0})},[d]),u=c.useCallback(async(p,g)=>{var b;await d({item:p,fallbackTitle:g,fallbackText:((b=p.detailText)==null?void 0:b.trim())||p.text||"Tool call",loadingText:"Loading full tool call details...",errorText:"Unable to load full tool call details.",useSelectionCallback:!0})},[d]),m=c.useCallback(async(p,g,b,v,x)=>{await d({item:p,fallbackTitle:g,fallbackText:b,loadingText:v,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 rg(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 ng({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),v=c.useRef(null),x=c.useRef(null),j=c.useRef(null),w=c.useRef(!0),y=c.useRef(!0),k=c.useRef(!1),S=c.useRef(!1),N=c.useRef(!1),L=c.useRef(!1),R=c.useRef(null),P=c.useRef(0),[J,D]=c.useState(Ms),[Y,Z]=c.useState(0),[I,re]=c.useState(!0),oe=rg(d),$=typeof o=="function"||n!==void 0,Q=n??r,_=$?0:Math.max(0,r-J),W=($?Math.max(0,Q-r):0)+_,T=$?r:r-_,K=$?0:r-T,G=$?Math.max(0,Q-r):0,E=$?G+K:K,C=!$&&E>0&&Y>=2,U=$&&G>0&&K===0&&typeof o=="function",H=c.useCallback(()=>{const X=h.current;if(!X){v.current=null;return}v.current={scrollHeight:X.scrollHeight,scrollTop:X.scrollTop}},[]),se=c.useCallback(()=>!U||a||N.current?!1:(H(),N.current=!0,L.current=!1,P.current=0,o==null||o(),!0),[U,a,o,H]),q=c.useCallback(()=>{const X=h.current,ue=x.current;if(!X)return;const ve=ue?Jf(X,ue):gr(X);w.current=ve,re(ke=>ke===ve?ke:ve)},[]),de=c.useCallback(()=>{const X=h.current;if(X){S.current=!0;const ue=X.scrollTop,ve=b.current,ke=ue-ve;b.current=ue,gr(X,1)?(k.current=!1,y.current=!0):ke<-1?(k.current=!0,y.current=!1):ke>1&&(y.current=!k.current&&gr(X,Jn)),ue<=0&&S.current?L.current=!0:ue>0&&(L.current=!1,P.current=0)}q()},[q]),te=c.useCallback(()=>{const X=h.current;X&&(X.scrollTop=X.scrollHeight,b.current=X.scrollTop,g.current=X.scrollHeight,w.current=!0,re(ue=>ue||!0),k.current=!1,y.current=!0)},[]),be=c.useCallback(()=>{const X=h.current;X&&(b.current=X.scrollTop,g.current=X.scrollHeight,y.current=!1,k.current=!0)},[]),ie=c.useCallback(()=>{if($&&K===0){se();return}D(X=>Math.min(r,X+Zf)),Z(X=>X+1)},[K,$,se,r]),ye=c.useCallback(X=>{const ue=h.current;if(!(!ue||X.deltaY>=-8||ue.scrollTop>0||!U)){if(!L.current){L.current=!0;return}se()}},[U,se]),Ae=c.useCallback(X=>{var ue;R.current=((ue=X.touches.item(0))==null?void 0:ue.clientY)??null,P.current=0},[]),ce=c.useCallback(X=>{var He;const ue=h.current,ve=((He=X.touches.item(0))==null?void 0:He.clientY)??null,ke=R.current;if(R.current=ve,!ue||ve===null||ke===null||ue.scrollTop>0||!U){P.current=0;return}const _e=ve-ke;if(_e<=0){P.current=0;return}if(!L.current){L.current=!0,P.current=0;return}P.current+=_e,P.current>=28&&se()},[U,se]),Ce=c.useCallback(()=>{R.current=null,P.current=0},[]),Le=c.useCallback(()=>{D(r)},[r]);return c.useLayoutEffect(()=>{const X=window.requestAnimationFrame(()=>{te()});return()=>{window.cancelAnimationFrame(X)}},[e,te]),c.useEffect(()=>{N.current=!1,S.current=!1,L.current=!1,v.current=null},[e]),c.useEffect(()=>{a||(N.current=!1)},[a,r]),c.useLayoutEffect(()=>{const X=v.current,ue=h.current;if(!X||!ue||a)return;v.current=null;const ve=ue.scrollHeight-X.scrollHeight;if(ve<=0){g.current=ue.scrollHeight,b.current=ue.scrollTop;return}const ke=X.scrollTop+ve;ue.scrollTop=ke,b.current=ke,g.current=ue.scrollHeight,k.current=!0,y.current=!1,L.current=!1},[a,r]),c.useEffect(()=>{D(X=>X>=r-1?r:Math.max(X,Ms))},[r]),c.useEffect(()=>{const X=h.current;X&&(g.current=X.scrollHeight,b.current=X.scrollTop,gr(X,1)?(k.current=!1,y.current=!0):(k.current||!gr(X,Jn))&&(y.current=!1)),q()},[oe,q,J]),c.useEffect(()=>{const X=s!==m.current,ue=f.current!==oe;if(f.current=oe,!(X||ue&&y.current&&!k.current))return;const ke=window.requestAnimationFrame(()=>{te()});return s!==m.current&&(m.current=s),()=>{window.cancelAnimationFrame(ke)}},[oe,I,te,s]),c.useEffect(()=>{const X=h.current,ue=u.current;if(!X||!ue||typeof ResizeObserver>"u")return;g.current=X.scrollHeight;const ve=new ResizeObserver(()=>{const ke=X.scrollHeight,_e=g.current;if(g.current=ke,ke<=_e)return;const He=_e>0&&_e-X.scrollTop-X.clientHeight<=1;k.current||!(y.current||He||w.current)||window.requestAnimationFrame(()=>{te()})});return ve.observe(ue),()=>{ve.disconnect()}},[te]),c.useEffect(()=>{if(!y.current||k.current){p.current=l;return}if(l===p.current)return;p.current=l;const X=window.requestAnimationFrame(()=>{te()});return()=>{window.cancelAnimationFrame(X)}},[l,te]),c.useEffect(()=>{i==null||i(I)},[I,i]),{scrollContainerRef:h,scrollContentRef:u,tailSentinelRef:x,topSentinelRef:j,isTailVisible:I,handleScroll:de,handleWheel:ye,handleTouchStart:Ae,handleTouchMove:ce,handleTouchEnd:Ce,preserveScrollPositionForResize:be,serverManagedHistory:$,effectiveTotalTurnCount:Q,startIndex:_,visibleTurnAbsoluteOffset:W,hiddenCount:E,loadedHiddenCount:K,unloadedHiddenCount:G,showLoadAll:C,handleLoadEarlierClick:ie,handleLoadAllClick:Le}}function ag(e){return e==="completed"||e==="failed"||e==="interrupted"}function sg(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 og({threadId:e,turns:r,totalTurnCount:n,pendingRequests:a=[],activeTurnId:o=null,threadRunning:s=!1,pendingSteers:l=[],livePlan:i=null,liveItems:d=null,respondingRequestId:h=null,onRespondToRequest:u,liveOutput:m,scrollRequestKey:f=0,previousTurnScrollRequestKey:p=0,nextTurnScrollRequestKey:g=0,bottomSpacer:b=0,className:v="",onTailVisibilityChange:x,onPreviousTurnAvailabilityChange:j,onNextTurnAvailabilityChange:w,loadingEarlier:y=!1,onLoadEarlier:k,ephemeralUserNote:S=null,answeredRequestNotes:N=[],activityNotes:L=[],optimisticSteers:R=[],optimisticTurn:P=null,onLoadHistoryItemDetail:J,onOpenThread:D,onSelectArtifact:Y,onSelectHistoryItemDetail:Z,adapter:I,autoCollapseCompletedTurns:re}){var vt,it,Nt,Rt,Ct;const oe=dl(),$=re??(oe==null?void 0:oe.autoCollapseCompletedTurns)??!1,[Q,_]=c.useState({}),[ee,W]=c.useState(()=>new Set),T=c.useRef(null),K=c.useRef(null),G=(I==null?void 0:I.onLoadHistoryItemDetail)??J,E=I==null?void 0:I.onOpenLinkedThread,{expandedText:C,openExpandedText:U,openCommandDetail:H,openToolCallDetail:se,openDeferredHistoryItemDetail:q,closeExpandedText:de}=tg({loadHistoryItemDetail:G,onSelectHistoryItemDetail:Z}),{scrollContainerRef:te,scrollContentRef:be,tailSentinelRef:ie,topSentinelRef:ye,handleScroll:Ae,handleWheel:ce,handleTouchStart:Ce,handleTouchMove:Le,handleTouchEnd:X,preserveScrollPositionForResize:ue,serverManagedHistory:ve,effectiveTotalTurnCount:ke,startIndex:_e,visibleTurnAbsoluteOffset:He,hiddenCount:$e,loadedHiddenCount:Ie,unloadedHiddenCount:F,showLoadAll:le,handleLoadEarlierClick:we,handleLoadAllClick:z}=ng({threadId:e,turnsLength:r.length,totalTurnCount:n,loadingEarlier:y,onLoadEarlier:k,scrollRequestKey:f,bottomSpacer:b,onTailVisibilityChange:x,contentRevisionInputs:[r,a,l,R,m,i,d,P,N,L,S,b]}),O=c.useCallback((A,pe)=>{_(Re=>({...Re,[A]:!pe}))},[]),ne=c.useCallback((A,pe)=>{const Re=Q[A.id];return Re!==void 0?Re:!!($&&ag(A.status)&&!pe.forceActive&&!pe.hasLiveActivity)},[Q,$]),ge=ve?r:r.slice(_e),Te=ke+1,Ee=s&&(!o||!ge.some(A=>A.id===o)&&(P==null?void 0:P.id)!==o),fe=(P==null?void 0:P.id)??((vt=ge.at(-1))==null?void 0:vt.id)??null,De=Ee&&fe!==null,Be=!!d&&(ge.some(A=>A.id===d.turnId)||(P==null?void 0:P.id)===d.turnId),et=d&&Be?d.turnId:d&&De?fe:null,Ve=P&&et===P.id?(d==null?void 0:d.items)??null:null,pt=((d==null?void 0:d.items.length)??0)>0,nt=d&&et===null?d.items:null,We=c.useMemo(()=>d&&et===null&&d.items.length>0?eg(d.turnId,d.items):null,[d,et]),ot=Math.max(1,ke+(P?1:0)),ht=!!m&&!!P&&P.status!=="failed"&&!Ve,ut=m&&ge.length>0?o&&ge.some(A=>A.id===o)?o:((it=ge.findLast(A=>gl(A.status)))==null?void 0:it.id)??(De?fe:null):null,M=!!ut,V=c.useMemo(()=>fl(m),[m]),xe=[...l.map(A=>({id:A.id,prompt:A.prompt,status:"Accepted",createdAt:A.createdAt,canCancel:!0})),...R.map(A=>({id:A.id,prompt:A.prompt,status:A.status==="steering"?"Steering":null,createdAt:A.createdAt,canCancel:!1}))].sort((A,pe)=>A.createdAt.localeCompare(pe.createdAt)),je=c.useMemo(()=>Zp({answeredRequestNotes:N,pendingRequests:a,visibleTurns:ge,optimisticTurn:P}),[N,P,a,ge]),Ne=c.useMemo(()=>Jp({activityNotes:L,visibleTurns:ge,optimisticTurn:P}),[L,P,ge]),Ye=c.useCallback(()=>{const A=te.current;if(!A)return null;const pe=A.getBoundingClientRect().top;return Array.from(A.querySelectorAll("[data-timeline-turn]")).find(Re=>Re.getBoundingClientRect().top>pe+8)??null},[te]),tt=c.useCallback(()=>{const A=te.current;if(!A)return null;const pe=A.getBoundingClientRect().top;return Array.from(A.querySelectorAll("[data-timeline-turn]")).findLast(Re=>Re.getBoundingClientRect().top<pe-8)??null},[te]),Fe=c.useCallback(()=>{j==null||j(!!tt())},[tt,j]),Ke=c.useCallback(()=>{w==null||w(!!Ye())},[Ye,w]),lt=c.useCallback(()=>{Ae(),Fe(),Ke()},[Ae,Ke,Fe]);return c.useEffect(()=>{Fe(),Ke()},[Ke,Fe,ge]),c.useEffect(()=>{if(p===0)return;const A=te.current,pe=tt(),Re=A?Array.from(A.querySelectorAll("[data-timeline-turn]")):[],Ge=pe?Re.indexOf(pe):-1,Ue=pe&&pe.dataset.turnId===T.current?Re[Ge-1]??null:pe;if(!A||!Ue)return;T.current=Ue.dataset.turnId??null;const ct=Ue.getBoundingClientRect().top-A.getBoundingClientRect().top;A.scrollTo({top:A.scrollTop+ct-8,behavior:"smooth"}),Re.indexOf(Ue)===0&&(j==null||j(!1))},[tt,j,p,te]),c.useEffect(()=>{if(g===0)return;const A=te.current,pe=Ye(),Re=A?Array.from(A.querySelectorAll("[data-timeline-turn]")):[],Ge=pe?Re.indexOf(pe):-1,Ue=pe&&pe.dataset.turnId===K.current?Re[Ge+1]??null:pe;if(!A||!Ue)return;K.current=Ue.dataset.turnId??null;const ct=Ue.getBoundingClientRect().top-A.getBoundingClientRect().top;A.scrollTo({top:A.scrollTop+ct-8,behavior:"smooth"}),Re.indexOf(Ue)===Re.length-1&&(w==null||w(!1))},[Ye,g,w,te]),t.jsxs(t.Fragment,{children:[t.jsx("section",{className:`flex min-h-0 flex-1 flex-col ${v}`.trim(),children:t.jsx("div",{ref:te,"data-testid":"thread-scroll-container",onScroll:lt,onWheel:ce,onTouchStart:Ce,onTouchMove:Le,onTouchEnd:X,onTouchCancel:X,className:"thread-graph-scroll-container min-h-0 flex-1 overflow-y-auto overscroll-contain",style:b>0?{paddingBottom:b}:void 0,children:t.jsxs("div",{ref:be,className:"thread-graph-scroll-content",children:[t.jsx("div",{ref:ye,"aria-hidden":"true",className:"h-px"}),r.length>0&&t.jsx("div",{className:"thread-graph-history-control px-3 pb-1 pt-2 sm:px-5 sm:pb-1.5 sm:pt-3",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 text-xs sm:text-sm",children:[$e>0&&t.jsx("button",{type:"button",onClick:we,disabled:y,className:"thread-graph-history-button rounded-full border px-2.5 py-1.5 transition",children:y?"Loading earlier...":"Load 3 earlier"}),le&&t.jsx("button",{type:"button",onClick:z,className:"rounded-full border border-amber-300/40 px-2.5 py-1.5 text-amber-200 transition hover:bg-amber-300/10",children:"Load full history"}),t.jsxs("p",{className:"timeline-meta-text",children:["Showing ",ge.length," of ",ke," turns",$e>0?` · ${$e} earlier hidden${Ie>0&&F>0?` (${Ie} loaded)`:""}`:""]})]})}),r.length===0&&!m&&!P&&t.jsx("div",{className:"thread-graph-empty-state px-3 py-8 text-sm sm:px-5",children:"Send the first prompt to start the thread."}),(ge.length>0||P||Ne.leading.length>0||Ne.trailing.length>0)&&t.jsxs("div",{className:"thread-graph-message-list",children:[Ne.leading.length>0?t.jsx(pr,{notes:Ne.leading,onOpenThread:D,onOpenLinkedThread:E}):null,ge.map((A,pe)=>{var Re,Ge,Ue,ct,kt;return t.jsxs("div",{"data-timeline-turn":!0,"data-turn-id":A.id,children:[(((Re=Ne.beforeTurnId.get(A.id))==null?void 0:Re.length)??0)>0?t.jsx(pr,{notes:Ne.beforeTurnId.get(A.id)??[],onOpenThread:D,onOpenLinkedThread:E}):null,(((Ge=je.beforeTurnId.get(A.id))==null?void 0:Ge.length)??0)>0?t.jsx(Yn,{entries:je.beforeTurnId.get(A.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const qt=sg(A,P),Xt=(i==null?void 0:i.turnId)===A.id?i:null,Mt=et===A.id?(d==null?void 0:d.items)??null:null,cr=ut===A.id?m:"",at=o===A.id||De&&fe===A.id,cn=!!Xt||!!cr||!!(Mt&&Mt.length>0),hn=ne(qt,{forceActive:at,hasLiveActivity:cn});return t.jsx(En,{threadId:e,...I?{adapter:I}:{},turn:qt,absoluteIndex:He+pe+1,isCollapsed:hn,livePlan:Xt,liveItems:Mt,liveOutput:cr,forceActive:at,onToggleCollapse:O,onOpenExpandedText:U,onOpenCommandDetail:H,onOpenToolCallDetail:se,onOpenDeferredHistoryItemDetail:q,onBeforeMessageResize:ue,...Y?{onSelectArtifact:Y}:{},scrollRootRef:te,articleRef:void 0})})(),(((Ue=Ne.afterTurnId.get(A.id))==null?void 0:Ue.length)??0)>0?t.jsx(pr,{notes:Ne.afterTurnId.get(A.id)??[],onOpenThread:D,onOpenLinkedThread:E}):null,(ct=je.notesByTurnId.get(A.id))!=null&&ct.length||(kt=je.pendingRequestsByTurnId.get(A.id))!=null&&kt.length?t.jsx(Qp,{notes:je.notesByTurnId.get(A.id)??[],requests:je.pendingRequestsByTurnId.get(A.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null]},A.id)}),P&&ge.every(A=>A.id!==P.id)&&t.jsxs(t.Fragment,{children:[(((Nt=Ne.beforeTurnId.get(P.id))==null?void 0:Nt.length)??0)>0?t.jsx(pr,{notes:Ne.beforeTurnId.get(P.id)??[],onOpenThread:D,onOpenLinkedThread:E}):null,(((Rt=je.beforeTurnId.get(P.id))==null?void 0:Rt.length)??0)>0?t.jsx(Yn,{entries:je.beforeTurnId.get(P.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const A=ht?m:"",pe=o===P.id||De&&fe===P.id,Re=!!(Ve&&Ve.length>0)||!!A,Ge=ne(P,{forceActive:pe,hasLiveActivity:Re});return t.jsx(En,{threadId:e,...I?{adapter:I}:{},turn:P,absoluteIndex:Te,isCollapsed:Ge,livePlan:null,liveItems:Ve,liveOutput:A,forceActive:pe,onToggleCollapse:O,onOpenExpandedText:U,onOpenCommandDetail:H,onOpenToolCallDetail:se,onOpenDeferredHistoryItemDetail:q,onBeforeMessageResize:ue,...Y?{onSelectArtifact:Y}:{},scrollRootRef:te})})(),(((Ct=Ne.afterTurnId.get(P.id))==null?void 0:Ct.length)??0)>0?t.jsx(pr,{notes:Ne.afterTurnId.get(P.id)??[],onOpenThread:D,onOpenLinkedThread:E}):null]})]}),xe.length>0&&t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:xe.map(A=>t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(It,{threadId:e,item:{id:A.id,kind:"userMessage",text:A.prompt,status:A.status},scrollRootRef:te,onBeforeMessageResize:ue,...I?{adapter:I}:{}}),e&&A.canCancel&&(I!=null&&I.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:ee.has(A.id),onClick:()=>{var pe;W(Re=>new Set(Re).add(A.id)),Promise.resolve((pe=I.cancelPendingSteer)==null?void 0:pe.call(I,e,A.id)).catch(()=>{}).finally(()=>{W(Re=>{const Ge=new Set(Re);return Ge.delete(A.id),Ge})})},children:ee.has(A.id)?"Canceling...":"Cancel"})}):null]},A.id))}),(je.trailing.length>0||Ne.trailing.length>0)&&t.jsx(ef,{entries:[...Ne.trailing.map(A=>({kind:"activity",id:A.id,createdAt:A.createdAt,note:A})),...je.trailing],respondingRequestId:h,onRespondToRequest:u??void 0,onOpenThread:D,onOpenLinkedThread:E}),S&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:t.jsx(It,{threadId:e,item:{id:"ephemeral-plan-decision-note",kind:"userMessage",text:S},scrollRootRef:te,onBeforeMessageResize:ue})}),We&&nt&&nt.length>0&&t.jsx(En,{threadId:e,...I?{adapter:I}:{},turn:We,absoluteIndex:ot,isCollapsed:Q[We.id]??!1,livePlan:(i==null?void 0:i.turnId)===We.id?i:null,liveItems:nt,liveOutput:"",forceActive:!0,onToggleCollapse:O,onOpenExpandedText:U,onOpenCommandDetail:H,onOpenToolCallDetail:se,onOpenDeferredHistoryItemDetail:q,onBeforeMessageResize:ue,...Y?{onSelectArtifact:Y}:{},scrollRootRef:te}),m&&!M&&!ht&&!pt&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:V?t.jsx(pa,{threadId:e,item:V,scrollRootRef:te,onOpenExpandedText:U,onOpenCommandDetail:H,onOpenToolCallDetail:se,onOpenDeferredHistoryItemDetail:q,onBeforeMessageResize:ue,...Y?{onSelectArtifact:Y}:{},...I?{adapter:I}:{}}):t.jsx(It,{threadId:e,item:{id:"live-agent-message-fallback",kind:"agentMessage",text:m},scrollRootRef:te,streaming:!0,onBeforeMessageResize:ue,...I?{adapter:I}:{}})}),t.jsx("div",{ref:ie,"aria-hidden":"true",className:"h-px w-full"})]})})}),t.jsx(fp,{open:C!==null,title:(C==null?void 0:C.title)??"Full text",text:(C==null?void 0:C.text)??"",onClose:de})]})}var Sl=c.memo(og);function lg(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}function Qn(e){return e.replace(/\r\n/g,`
|
|
3667
|
-
`)}function
|
|
3665
|
+
`);for(;r.length>1&&((n=r.at(-1))==null?void 0:n.trim())==="";)r.pop();return r}function bt(e){const r=df(e);return r.length===1?{firstLine:r[0]??"",showGap:!1,isTruncated:!1}:{firstLine:r[0]??"",showGap:!0,isTruncated:!0}}function wl(e){const r=(e==null?void 0:e.trim().toLowerCase())??"";return r==="completed"||r==="complete"||r==="success"||r==="succeeded"?{className:"is-completed",icon:t.jsx(D.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"}:r==="failed"||r==="failure"||r==="error"||r==="errored"?{className:"is-failed",icon:t.jsx(D.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"}:ha(e)?{className:"is-pending",icon:t.jsx(D.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 cf(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 hf(e){switch(e){case"plan":return"is-plan";case"context":return"is-context";case"generic":return"is-generic";case"image":return"is-image";case"fileChange":return"is-file-change";case"artifact":return"is-artifact";case"hook":return"is-hook"}}function Kt({actions:e,children:r,className:n,headerMeta:a,icon:o,item:s,timeMeta:l,title:i,tone:d}){const h=wl(s.status);return t.jsxs("div",{className:`thread-graph-event thread-graph-history-event ${hf(d)} ${n??""}`,children:[t.jsx("div",{className:"thread-graph-history-event-icon","aria-hidden":"true",children:o}),t.jsxs("div",{className:"thread-graph-history-event-card",children:[t.jsxs("div",{className:"thread-graph-history-event-header",children:[t.jsxs("div",{className:"thread-graph-history-event-heading flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-event-title min-w-0 truncate font-mono text-sm font-semibold",children:i}),s.status?t.jsxs(on,{variant:"outline",className:`thread-graph-tool-badge ${h.className} rounded-full px-2 py-0.5 text-xs font-normal`,title:h.label,"aria-label":`Status: ${h.label}`,children:[h.icon,t.jsx("span",{className:"thread-graph-status-label",children:h.label})]}):null,a]}),e||l?t.jsxs("div",{className:"thread-graph-history-event-actions",children:[e,l]}):null]}),r?t.jsx("div",{className:"thread-graph-history-event-body",children:r}):null]})]})}function dr({actionLabel:e="Open details",actionTitle:r,autoOpen:n=!1,className:a,details:o,icon:s,item:l,onOpen:i,preview:d,timeMeta:h,title:u,tone:m}){const f=wl(l.status),[p,g]=c.useState(n?"item-1":void 0),b=c.useRef(n);return c.useLayoutEffect(()=>{n?g("item-1"):b.current&&g(void 0),b.current=n},[n,l.id]),t.jsx("div",{className:`thread-graph-event thread-graph-history-tool ${cf(m)} ${a??""}`,children:t.jsx(Sr,{type:"single",collapsible:!0,onValueChange:k=>{g(k||void 0)},className:"thread-graph-tool-accordion thread-graph-history-tool-accordion w-full overflow-hidden rounded-lg border",value:p??"",children:t.jsxs(Tr,{value:"item-1",className:"border-0",children:[t.jsxs(nn,{"aria-label":`${p==="item-1"?"Collapse":"Expand"} ${u} history item`,className:"thread-graph-tool-trigger thread-graph-history-tool-trigger px-4 py-3 hover:no-underline",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-tool-icon shrink-0",children:s}),t.jsx("span",{className:"min-w-0 truncate font-mono text-sm font-semibold",children:u}),t.jsxs(on,{variant:"outline",className:`thread-graph-tool-badge ${f.className} ml-1 sm:ml-2 rounded-full px-2 py-0.5 text-xs font-normal`,title:f.label,"aria-label":`Status: ${f.label}`,children:[f.icon,t.jsx("span",{className:"thread-graph-status-label",children:f.label})]})]}),h?t.jsx("span",{className:"thread-graph-history-tool-time shrink-0",children:h}):null]}),t.jsxs(Er,{className:"thread-graph-tool-content thread-graph-history-tool-content px-4 pb-4 pt-1",children:[t.jsxs("section",{children:[t.jsx("h4",{children:"Summary"}),t.jsxs("div",{className:"thread-graph-history-tool-summary",children:[t.jsx(lr,{text:d.firstLine}),d.showGap?t.jsx("span",{className:"thread-graph-history-tool-ellipsis",children:"..."}):null]})]}),o?t.jsx("section",{children:o}):null,t.jsxs("button",{type:"button","aria-label":e,onClick:i,className:"thread-graph-history-tool-open inline-flex items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium transition",children:[t.jsx(D.ExternalLink,{className:"h-3.5 w-3.5"}),r]})]})]})})})}var uf=c.memo(function({item:r,scrollRootRef:n,onBeforeResize:a,timeMeta:o}){return t.jsx(Kt,{className:"thread-graph-event-plan",icon:t.jsx(D.ClipboardList,{className:"h-4 w-4"}),item:r,timeMeta:o,title:"plan",tone:"plan",children:t.jsx("div",{className:"thread-graph-history-event-prose",children:t.jsx(ul,{text:r.text,scrollRootRef:n,plainTextClassName:"thread-graph-plain-text whitespace-pre-wrap break-words text-sm leading-6",markdownClassName:"thread-graph-markdown text-sm",...a?{onBeforeResize:a}:{}})})})}),mf=c.memo(function({item:r,timeMeta:n}){const a=ha(r.status)||r.text==="Compacting context",o=a?"Compacting context":"Context compacted",s=r.detailText&&r.detailText!==o?r.detailText:null;return t.jsxs(Kt,{className:"thread-graph-event-context",icon:t.jsx(D.Archive,{className:"h-4 w-4"}),item:r,timeMeta:n,title:"context",tone:"context",children:[t.jsxs("div",{className:"thread-graph-history-event-line",children:[t.jsx("span",{className:"thread-graph-history-event-primary",children:o}),a?t.jsx(Yn,{tone:"emerald"}):null]}),s?t.jsx("p",{className:"thread-graph-history-event-secondary",title:s,children:s}):null]})}),pf=c.memo(function({item:r,timeMeta:n}){return t.jsx(Kt,{className:"thread-graph-event-generic",icon:t.jsx(D.Info,{className:"h-4 w-4"}),item:r,timeMeta:n,title:r.kind,tone:"generic",children:t.jsx("pre",{className:"thread-graph-history-event-pre",children:t.jsx(lr,{text:r.text})})})}),ff=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=bt(n.previewText??n.text);return t.jsx(dr,{actionLabel:"Open full command",actionTitle:"Command Output",autoOpen:r,className:"thread-graph-event-command",icon:t.jsx(D.Terminal,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Command Output"),preview:s,timeMeta:o,title:"command",tone:"command"})}),gf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=bt(n.text);return t.jsx(dr,{actionLabel:"Open full tool call",actionTitle:"Tool Call Details",autoOpen:r,className:"thread-graph-event-tool",icon:t.jsx(D.Wrench,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Tool Call Details"),preview:s,timeMeta:o,title:"tool_call",tone:"tool"})}),xf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=bt(n.text);return t.jsx(dr,{actionLabel:"Open agent details",actionTitle:"Agent Details",autoOpen:r,className:"thread-graph-event-agent-tool",icon:t.jsx(D.Bot,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Agent Details"),preview:s,timeMeta:o,title:"agent",tone:"agent"})}),bf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=bt(n.text);return t.jsx(dr,{actionLabel:"Open skill details",actionTitle:"Skill Details",autoOpen:r,className:"thread-graph-event-skill-tool",icon:t.jsx(D.Sparkles,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Skill Details"),preview:s,timeMeta:o,title:"skill",tone:"skill"})}),vf=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=bt(s);return t.jsx(dr,{actionLabel:"Open full web search",actionTitle:"Web Search Details",autoOpen:r,className:"thread-graph-event-search",icon:t.jsx(D.Search,{className:"h-4 w-4"}),item:n,onOpen:()=>a("Web Search Details",l),preview:i,timeMeta:o,title:"web_search",tone:"search"})}),kf=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=bt(s);return t.jsx(dr,{actionLabel:"Open full file read",actionTitle:"File Read Details",autoOpen:r,className:"thread-graph-event-file-read",icon:t.jsx(D.FileText,{className:"h-4 w-4"}),item:n,onOpen:()=>a("File Read Details",l),preview:i,timeMeta:o,title:"file_read",tone:"fileRead"})}),wf=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(Kt,{className:"thread-graph-event-image",icon:t.jsx(D.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]})}),yf=c.memo(function({item:r,onOpen:n,timeMeta:a}){var m,f,p;const o=(m=r.previewText)!=null&&m.trim()&&r.text.trim()!==r.previewText.trim()?r.text.trim():null,s=((f=r.detailText)==null?void 0:f.trim())||null,l=kl(o??((p=r.previewText)==null?void 0:p.trim())??r.text,48),i=lf(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(Kt,{className:"thread-graph-event-file-change",headerMeta:u,icon:t.jsx(D.FilePenLine,{className:"h-4 w-4"}),item:r,timeMeta:a,title:"file_change",tone:"fileChange"})}),jf=c.memo(function({item:r,onSelect:n,timeMeta:a}){const o=ca(),[s,l]=c.useState(!1),i=r.artifact,d=i?o.renderArtifact({artifact:i,expanded:s,onToggleExpanded:()=>l(h=>!h)}):null;return t.jsx(Kt,{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(D.PackageOpen,{className:"h-3.5 w-3.5"}),"Inspect"]}):null]}),className:"thread-graph-event-artifact",icon:t.jsx(D.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]})})}),Nf=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(`
|
|
3666
|
+
`).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=bt(a||(s&&s!==o?s:o)),d=!!(a&&i.showGap);return t.jsx(Kt,{className:"thread-graph-event-hook",icon:t.jsx(D.Webhook,{className:"h-4 w-4"}),item:r,timeMeta:n,title:r.hookEventLabel?`${r.hookEventLabel}_hook`:"hook",tone:"hook",children:t.jsxs("div",{className:"thread-graph-history-event-line",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:a?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"thread-graph-history-event-secondary mr-2 font-sans text-[11px] uppercase",children:o}),t.jsx(lr,{text:i.firstLine})]}):t.jsx(lr,{text:i.firstLine&&i.firstLine!==o?`${o} · ${i.firstLine}`:o})}),d?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})})}),Cf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o,timeMeta:s}){const l=r.filter(d=>ha(d.status)).length,i=r.length===1?"1 command":`${r.length} commands`;return t.jsx(sn,{className:"thread-graph-history-group-command",count:r.length,countBadgeClassName:"border-amber-200/35 text-amber-100",desktopIconClassName:"border-amber-300/30 bg-amber-300/[0.14] text-amber-100",expanded:n,expandedListClassName:"border-amber-300/12",icon:t.jsx(af,{}),onToggleExpanded:a,runningIndicator:l>0?t.jsx(Yn,{}):null,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-amber-300/28 bg-amber-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-amber-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:i}),l>0?t.jsx("span",{className:"inline-flex items-center text-xs text-amber-100/90",children:t.jsx(Yn,{})}):null]}),timeMeta:s,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} command entries`,children:r.map((d,h)=>{const u=bt(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)})})}),Sf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o,timeMeta:s}){const l=r.length===1?"1 search":`${r.length} searches`;return t.jsx(sn,{className:"thread-graph-history-group-search",count:r.length,countBadgeClassName:"border-sky-200/35 text-sky-100",desktopIconClassName:"border-sky-300/30 bg-sky-300/[0.14] text-sky-100",expanded:n,expandedListClassName:"border-sky-300/12",icon:t.jsx(sf,{}),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=bt(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)})})}),Tf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o,timeMeta:s}){const l=r.length===1?"1 file read":`${r.length} file reads`;return t.jsx(sn,{className:"thread-graph-history-group-file-read",count:r.length,countBadgeClassName:"border-cyan-200/35 text-cyan-100",desktopIconClassName:"border-cyan-300/30 bg-cyan-300/[0.14] text-cyan-100",expanded:n,expandedListClassName:"border-cyan-300/12",icon:t.jsx(nf,{}),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=bt(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)})})}),Ef=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o,timeMeta:s}){const l=r.reduce((u,m)=>u+(m.changedFiles??0),0),i=r.reduce((u,m)=>u+(m.addedLines??0),0),d=r.reduce((u,m)=>u+(m.removedLines??0),0),h=r.length===1?"1 file change":`${r.length} file changes`;return t.jsx(sn,{className:"thread-graph-history-group-file-change",count:r.length,countBadgeClassName:"border-lime-200/35 text-lime-100",desktopIconClassName:"border-lime-300/30 bg-lime-300/[0.14] text-lime-100",expanded:n,expandedListClassName:"border-lime-300/12",icon:t.jsx(rf,{}),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,k,x;const f=((g=u.detailText)==null?void 0:g.trim())||((b=u.previewText)==null?void 0:b.trim())||u.text,p=(k=u.previewText)!=null&&k.trim()&&u.text.trim()!==u.previewText.trim()?u.text.trim():((x=u.previewText)==null?void 0:x.trim())||u.text;return t.jsx("button",{type:"button","aria-label":`Open grouped file change ${m+1}`,onClick:()=>o(`File Change ${m+1}`,f),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-detail-text min-w-0 flex-1 text-sm leading-6",title:p,children:kl(p,34)}),t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[(u.addedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-add",children:["+",u.addedLines]}):null,(u.removedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-remove",children:["-",u.removedLines]}):null]})]})},u.id)})})});function Lf(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 If({status:e}){const r=Lf(e),n=r==="completed"?"Plan step status: Completed":r==="in_progress"?"Plan step status: In progress":r==="pending"?"Plan step status: Pending":r==="failed"?"Plan step status: Failed":`Plan step status: ${e}`,a=r==="completed"?"thread-graph-plan-status is-completed":r==="in_progress"?"thread-graph-plan-status is-running":r==="pending"?"thread-graph-plan-status is-pending":r==="failed"?"thread-graph-plan-status is-failed":"thread-graph-plan-status is-unknown";return t.jsx(on,{"aria-label":n,title:n.replace("Plan step status: ",""),className:a,children:r==="completed"?t.jsx(D.CheckCircle2,{className:"h-3.5 w-3.5"}):r==="in_progress"?t.jsx(D.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):r==="pending"?t.jsx(D.Clock3,{className:"h-3.5 w-3.5"}):r==="failed"?t.jsx(D.XCircle,{className:"h-3.5 w-3.5"}):t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.14em]",children:"?"})})}function zf({livePlan:e}){return t.jsxs("div",{className:"thread-graph-plan-card rounded-xl border px-3 py-3",children:[t.jsxs("div",{className:"thread-graph-plan-header flex flex-wrap items-center justify-between gap-2",children:[t.jsx("p",{className:"text-sm font-semibold",children:"Plan update"}),t.jsx(on,{className:"thread-graph-plan-badge",children:"Live"})]}),e.explanation?t.jsx("p",{className:"thread-graph-plan-explanation mt-3 text-sm",children:e.explanation}):null,t.jsx("div",{className:"mt-3 space-y-2",children:e.plan.map((r,n)=>t.jsxs("div",{className:"thread-graph-plan-step flex items-center justify-between gap-3 rounded-lg border px-3 py-2 text-sm",children:[t.jsx("span",{className:"thread-graph-plan-step-text min-w-0 flex-1",children:r.step}),t.jsx(If,{status:r.status})]},`${e.turnId}-${n}`))})]})}function Pf({footer:e,history:r,liveHookPrompt:n,liveOutput:a,livePlan:o}){return t.jsxs(t.Fragment,{children:[r,o?t.jsx(zf,{livePlan:o}):null,n??a??null,e]})}function Rf({absoluteIndex:e,body:r,collapsed:n,collapsedBody:a,error:o,footer:s,headerStatus:l,isActive:i=!1,refCallback:d,startedAt:h,timeLabel:u,timeTitle:m,tokenSummary:f}){return t.jsxs("article",{ref:d,"data-testid":"chat-turn","data-turn-active":i?"true":"false",className:"thread-graph-turn px-3 py-2 sm:px-5 sm:py-3",children:[t.jsx("div",{className:"thread-graph-turn-header flex items-start justify-between gap-2",children:t.jsxs("div",{className:"min-w-0 flex flex-1 items-start gap-1.5",children:[t.jsxs("div",{className:"min-w-0 flex flex-1 items-center gap-1.5 overflow-hidden",children:[t.jsxs("span",{className:"thread-graph-turn-index rounded-[0.6rem] border px-1.5 py-0.5 text-[10px] uppercase tracking-[0.16em]",children:["Turn ",e]}),t.jsx("time",{dateTime:h??void 0,title:m,className:"thread-graph-turn-time shrink-0 text-[10px] sm:text-[11px]",children:u}),l,o?t.jsx("p",{className:"hidden truncate text-[11px] text-rose-200 sm:block",children:o}):null]}),f]})}),o?t.jsx("p",{className:"mt-1 text-[11px] text-rose-200 sm:hidden",children:o}):null,t.jsxs("div",{className:"thread-graph-turn-body mt-2 space-y-2",children:[n?a:r,n?null:s]})]})}function Mf(){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 Af(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M8 13.25v-8"}),t.jsx("path",{d:"m11.25 8.5-3.25-3.25L4.75 8.5"})]})}function Ts(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.45",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M3.25 5.25 8 2.75l4.75 2.5L8 7.75l-4.75-2.5Z"}),t.jsx("path",{d:"M3.25 8 8 10.5 12.75 8"}),t.jsx("path",{d:"M3.25 10.75 8 13.25l4.75-2.5"}),t.jsx("path",{d:"M3.25 5.25v5.5"}),t.jsx("path",{d:"M12.75 5.25v5.5"})]})}function _f(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.45",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M6.2 3.2a2.3 2.3 0 0 0-2.95 3.5A2.4 2.4 0 0 0 4.5 11h.2c.25 1.1 1.1 1.8 2.3 1.8h1.8c1.2 0 2.05-.7 2.3-1.8h.2A2.4 2.4 0 0 0 12.75 6.7 2.3 2.3 0 0 0 9.8 3.2"}),t.jsx("path",{d:"M6.3 6.15c.45-.42 1.02-.65 1.7-.65s1.25.23 1.7.65"}),t.jsx("path",{d:"M8 5.5v4.75"}),t.jsx("path",{d:"M6.75 9.05 8 10.25l1.25-1.2"})]})}function fr(e){if(!Number.isFinite(e)||e<=0)return"0";if(e>=1e6){const r=e>=1e7?Math.round(e/1e6):e/1e6;return`${String(r.toFixed(1)).replace(/\.0$/,"")}m`}if(e>=1e3){const r=e>=1e4?Math.round(e/1e3):e/1e3;return`${String(r.toFixed(1)).replace(/\.0$/,"")}k`}return String(Math.round(e))}function yl(e){return!Number.isFinite(e)||e<=0?"$0":e>=100?`$${Math.round(e)}`:e>=10?`$${String(e.toFixed(1)).replace(/\.0$/,"")}`:e>=1?`$${String(e.toFixed(2)).replace(/0$/,"").replace(/\.$/,"")}`:e>=.1?`$${e.toFixed(2)}`:e>=.01?`$${e.toFixed(3)}`:e>=.001?`$${e.toFixed(4)}`:"<$0.001"}function nr(e){return!Number.isFinite(e)||e<=0?"$0.0000":`$${e.toFixed(4)}`}function _r(e,r,n){const a=e??null;return!Number.isFinite(a??NaN)||a===null||r<=0||n<=0?null:a*n/r}function jl(e){var d,h,u,m,f,p;const r=(d=e.tokenUsage)==null?void 0:d.total;if(!r)return[];const n=Math.max(r.inputTokens-r.cachedInputTokens-(r.cacheWriteInputTokens??0),0),a=Math.max(r.cachedInputTokens,0),o=Math.max(r.cacheWriteInputTokens??0,0),s=Math.max(r.reasoningOutputTokens,0),l=Math.max(r.outputTokens-s,0);return[n>0?{id:"in",label:"Input",tokenCompactValue:fr(n),tokenRawValue:n,usdCompactValue:e.priceEstimate?nr(e.priceEstimate.inputUsd):"--",usdRawValue:((h=e.priceEstimate)==null?void 0:h.inputUsd)??null,className:"token-badge-in",icon:t.jsx(Mf,{})}:null,a>0?{id:"cache",label:"Cached input",tokenCompactValue:fr(a),tokenRawValue:a,usdCompactValue:e.priceEstimate?nr(e.priceEstimate.cachedInputUsd):"--",usdRawValue:((u=e.priceEstimate)==null?void 0:u.cachedInputUsd)??null,className:"token-badge-cache",icon:t.jsx(Ts,{})}:null,o>0?{id:"cache-write",label:"Cache write",tokenCompactValue:fr(o),tokenRawValue:o,usdCompactValue:e.priceEstimate?nr(e.priceEstimate.cacheWriteInputUsd??0):"--",usdRawValue:((m=e.priceEstimate)==null?void 0:m.cacheWriteInputUsd)??null,className:"token-badge-cache",icon:t.jsx(Ts,{})}:null,l>0?{id:"out",label:"Output",tokenCompactValue:fr(l),tokenRawValue:l,usdCompactValue:e.priceEstimate?nr(_r(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),l)??0):"--",usdRawValue:_r((f=e.priceEstimate)==null?void 0:f.outputUsd,Math.max(r.outputTokens,0),l),className:"token-badge-out",icon:t.jsx(Af,{})}:null,s>0?{id:"reason",label:"Reasoning",tokenCompactValue:fr(s),tokenRawValue:s,usdCompactValue:e.priceEstimate?nr(_r(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),s)??0):"--",usdRawValue:_r((p=e.priceEstimate)==null?void 0:p.outputUsd,Math.max(r.outputTokens,0),s),className:"token-badge-reason",icon:t.jsx(_f,{})}:null].filter(g=>g!==null)}function $f(e){return jl(e).map(r=>({id:r.id,label:r.tokenCompactValue,title:`${r.label}: ${r.tokenRawValue} tokens`,className:r.className,icon:r.icon}))}function Nl(e){return{label:e.priceEstimate?yl(e.priceEstimate.totalUsd):"--",title:e.priceEstimate===null||e.priceEstimate===void 0?"Price estimate unavailable for this model.":`Estimated cost: ${nr(e.priceEstimate.totalUsd)}`,className:e.priceEstimate?"token-badge-total":"token-badge-empty"}}var Sn="inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-normal leading-none sm:text-[11px]";function Df({turn:e}){const r=jl(e),n=Nl(e),[a,o]=c.useState(!1),[s,l]=c.useState(!1),[i,d]=c.useState(0),h=c.useRef(null),u=c.useRef(null),m=c.useRef(null);if(c.useLayoutEffect(()=>{if(!a||r.length===0){d(0);return}const p=()=>{const g=h.current,b=m.current;if(!g||!b)return;const k=g.getBoundingClientRect(),x=b.offsetWidth||b.getBoundingClientRect().width;if(x<=0)return;const j=window.innerWidth||document.documentElement.clientWidth,w=12,y=k.left+k.width/2-x/2,v=w,S=Math.max(v,j-w-x),N=Math.min(Math.max(y,v),S);d(Math.round(N-y))};return p(),window.addEventListener("resize",p),()=>{window.removeEventListener("resize",p)}},[r.length,a]),c.useEffect(()=>{if(!a&&!s)return;const p=g=>{g.target instanceof Node&&(h.current&&!h.current.contains(g.target)&&o(!1),u.current&&!u.current.contains(g.target)&&l(!1))};return document.addEventListener("pointerdown",p),()=>{document.removeEventListener("pointerdown",p)}},[s,a]),!n&&r.length===0)return null;const f=()=>t.jsx("div",{className:"thread-token-popover min-w-[12rem] rounded-2xl border p-2.5 shadow-2xl shadow-black/20 backdrop-blur",children:t.jsx("div",{className:"space-y-1",children:r.map(p=>t.jsxs("div",{className:"thread-token-popover-row flex items-center justify-between gap-3 rounded-xl border px-2.5 py-1.5 text-[11px]",title:`${p.label}: ${p.tokenRawValue} tokens`,children:[t.jsxs("span",{className:"thread-token-popover-text inline-flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"inline-flex shrink-0",children:p.icon}),t.jsx("span",{className:"thread-token-popover-strong font-medium",children:p.usdCompactValue})]}),t.jsx("span",{className:"thread-token-popover-text shrink-0 font-medium",children:p.tokenCompactValue})]},p.id))})});return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"hidden shrink-0 items-center gap-1.5 md:inline-flex",children:[n?t.jsxs("div",{ref:u,className:"relative shrink-0",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[t.jsx("button",{type:"button","aria-label":"Show token and price details","aria-expanded":s,onFocus:()=>l(!0),onBlur:()=>l(!1),className:`${Sn} appearance-none whitespace-nowrap bg-transparent !text-[10px] !font-normal !leading-none transition hover:bg-[var(--theme-hover)] sm:!text-[11px] ${n.className}`,title:n.title,children:n.label}),s&&r.length>0?t.jsx("div",{className:"absolute left-1/2 top-full z-30 mt-1.5 -translate-x-1/2",children:f()}):null]}):null,r.map(p=>t.jsxs("span",{className:`${Sn} ${p.className}`,title:`${p.label}: ${p.usdCompactValue}, ${p.tokenRawValue} tokens`,children:[p.icon,t.jsx("span",{className:"thread-token-badge-value font-medium",children:p.tokenCompactValue})]},p.id))]}),t.jsxs("div",{ref:h,className:"relative shrink-0 md:hidden",children:[n?t.jsx("button",{type:"button","aria-label":"Show token and price details","aria-expanded":a,onClick:()=>o(p=>!p),className:`${Sn} appearance-none whitespace-nowrap bg-transparent !text-[10px] !font-normal !leading-none transition hover:bg-[var(--theme-hover)] sm:!text-[11px] ${n.className}`,title:n.title,children:n.label}):null,a&&r.length>0?t.jsx("div",{ref:m,className:"absolute left-1/2 top-full z-30 mt-1.5",style:{transform:`translateX(${i}px) translateX(-50%)`},children:f()}):null]})]})}function Bf({tone:e="amber"}){const r=e==="emerald"?"bg-sky-200/90":e==="sky"?"bg-sky-300/90":"bg-amber-200/90";return t.jsx("span",{className:"ml-1.5 inline-flex items-center gap-1","aria-hidden":"true",children:[0,1,2].map(n=>t.jsx("span",{className:`h-1.5 w-1.5 rounded-full animate-pulse ${r}`,style:{animationDelay:`${n*180}ms`}},n))})}function Es(e){const r=e.trim().toLowerCase();return r==="completed"||r==="done"||r==="complete"?"completed":r==="in_progress"||r==="in progress"||r==="inprogress"||r==="running"||r==="active"?"in_progress":r==="pending"||r==="todo"||r==="not_started"||r==="not started"||r==="queued"?"pending":r==="failed"||r==="error"?"failed":"other"}function Gf(e){switch(e.kind){case"fileChange":case"webSearch":case"image":case"contextCompaction":return!0;case"commandExecution":case"toolCall":return!pl(e.status);default:return!1}}function Ff(e,r,n){if(!e||!vr(n))return e;const a=e.plan.findIndex(i=>Es(i.status)==="in_progress");if(a<0)return e;const o=e.plan.findIndex((i,d)=>d>a&&Es(i.status)==="pending");if(o<0||!r.some(i=>Gf(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 Hf(e){var a;const r=(a=e.model)!=null&&a.trim()?e.model.trim():"--";let n="--";return e.reasoningEffortAvailable===null||e.reasoningEffortAvailable===void 0?n="--":e.reasoningEffortAvailable===!1?n="-":n=e.reasoningEffort??"--",[r,n].join(" · ")}function Ls({status:e}){const r=il(e);return e==="completed"?t.jsx("span",{"aria-label":r,title:r,className:"timeline-status-icon timeline-status-icon-success inline-flex h-4 w-4 items-center justify-center",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m3.75 8.25 2.5 2.5 6-6"})})}):e==="failed"?t.jsx("span",{"aria-label":r,title:r,className:"timeline-status-icon timeline-status-icon-failed inline-flex h-4 w-4 items-center justify-center",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m5 5 6 6M11 5l-6 6"})})}):e==="interrupted"?t.jsx("span",{"aria-label":r,title:r,className:"timeline-status-icon timeline-status-icon-warning inline-flex h-4 w-4 items-center justify-center",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M6 4.5v7M10 4.5v7"})})}):t.jsx("span",{"aria-label":r,title:r,className:"inline-flex min-w-[1.25rem] items-center justify-center text-sky-200",children:t.jsx(Bf,{tone:"emerald"})})}function Is({turn:e,variant:r="header"}){const n=il(e.status),a=Hf(e),o=$f(e),s=Nl(e),l=vr(e.status),i=e.status==="failed"?"border-rose-300/20 bg-rose-300/[0.06] text-rose-100":l?"border-sky-300/22 bg-sky-300/[0.08] text-sky-100":"border-stone-700/90 bg-stone-900/70 text-stone-200";if(r==="footer")return t.jsxs("div",{className:`flex w-full flex-col gap-1.5 rounded-[0.95rem] border px-3 py-2 text-xs ${i}`,children:[t.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Ls,{status:e.status}),t.jsx("span",{className:"timeline-soft-text min-w-0 truncate",children:a})]}),e.startedAt&&t.jsx("time",{dateTime:e.startedAt,title:Wt(e.startedAt),className:"timeline-meta-text shrink-0 text-[11px]",children:xt(e.startedAt)})]}),(s||o.length>0)&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 pl-6",children:[s?t.jsx("span",{className:`inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${s.className}`,title:s.title,children:s.label}):null,o.map(h=>t.jsxs("span",{className:`inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${h.className}`,title:h.title,children:[h.icon?t.jsx("span",{className:"mr-1",children:h.icon}):null,h.label]},h.id))]})]});const d=`${n} · ${a}`;return t.jsxs("span",{className:`inline-flex min-w-0 items-center gap-1.5 rounded-full border px-2 py-1 text-[10px] sm:text-[11px] ${i}`,title:d,children:[t.jsx(Ls,{status:e.status}),t.jsx("span",{className:"timeline-meta-text min-w-0 truncate",children:a})]})}function Of(e,r){return e.createdAt??r}var ua=c.memo(function({threadId:r,item:n,scrollRootRef:a,onOpenExpandedText:o,onOpenCommandDetail:s,onOpenToolCallDetail:l,onOpenDeferredHistoryItemDetail:i,onSelectArtifact:d,onBeforeMessageResize:h,adapter:u,timeLabel:m,timeTitle:f,timeMeta:p,autoOpenToolDetails:g=!1}){var b,k,x;if(Op(n.kind))return t.jsx(It,{threadId:r,item:n,scrollRootRef:a,timeLabel:m,timeTitle:f,...h?{onBeforeMessageResize:h}:{},...u?{adapter:u}:{}});if(n.kind==="reasoning")return t.jsx(It,{item:{...n,kind:"agentMessage",status:n.status??null},scrollRootRef:a,timeLabel:m,timeTitle:f,...h?{onBeforeMessageResize:h}:{}});if(n.kind==="artifact")return t.jsx(jf,{item:n,timeMeta:p,...d?{onSelect:(j,w)=>d({item:j,artifact:w})}:{}});if(n.kind==="commandExecution")return t.jsx(ff,{autoOpen:g,item:n,onOpen:s,timeMeta:p});if(n.kind==="toolCall")return t.jsx(gf,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="agentToolCall")return t.jsx(xf,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="skillToolCall")return t.jsx(bf,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="webSearch"){const j=n,w=((b=j.detailText)==null?void 0:b.trim())||j.text||"Web search";return t.jsx(vf,{autoOpen:g,item:j,timeMeta:p,onOpen:()=>i(j,"Web Search Details",w,"Loading full web search details...","Unable to load full web search details.")})}if(n.kind==="fileRead"){const j=n,w=((k=j.detailText)==null?void 0:k.trim())||j.text||"File read";return t.jsx(kf,{autoOpen:g,item:j,timeMeta:p,onOpen:()=>i(j,"File Read Details",w,"Loading full file read details...","Unable to load full file read details.")})}if(n.kind==="image")return t.jsx(wf,{threadId:r,item:n,onOpen:o,getImageAssetUrl:u==null?void 0:u.getImageAssetUrl,timeMeta:p});if(n.kind==="plan")return t.jsx(uf,{item:n,scrollRootRef:a,timeMeta:p,...h?{onBeforeResize:h}:{}});if(n.kind==="fileChange"){const j=n,w=((x=j.detailText)==null?void 0:x.trim())||j.text||"File change";return t.jsx(yf,{item:j,timeMeta:p,onOpen:()=>i(j,"File Change Details",w,"Loading full file change details...","Unable to load full file change details.")})}return n.kind==="contextCompaction"?t.jsx(mf,{item:n,timeMeta:p}):n.kind==="hook"?t.jsx(Nf,{item:n,timeMeta:p}):t.jsx(pf,{item:n,timeMeta:p})});function zs(e){return e==="completed"||e==="failed"||e==="interrupted"}function Wf(e){const r=Date.parse(e.createdAt??"");return Number.isFinite(r)?r:null}function Uf(e){let r=null;for(const n of e){const a=Wf(n);a!==null&&(r=r===null?a:Math.max(r,a))}return r}function Vf(e,r){const n=Date.parse(e??""),a=Uf(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 Kf(e,r){const n=Date.parse(e??""),a=Date.parse(r??"");if(!Number.isFinite(n)||!Number.isFinite(a))return r?xt(r):"Time unavailable";const o=Math.max(0,Math.round((a-n)/1e3)),s=Math.floor(o/3600),l=Math.floor(o%3600/60),i=o%60;return s>0?`${s}h ${l}m`:l>0?`${l}m ${i}s`:`${i}s`}function wr({absoluteLabel:e,className:r="",timestamp:n,turnStartedAt:a}){const[o,s]=c.useState(!1);if(!n)return null;const l=Wt(n),i=Kf(a,n),d=o?e:i;return t.jsx("span",{role:"button",tabIndex:0,className:`thread-graph-relative-time rounded-full px-1.5 py-0.5 text-[10px] leading-none transition sm:text-[11px] ${r}`,title:o?i:l,"aria-label":`Toggle timestamp, currently ${d}`,onClick:h=>{h.stopPropagation(),s(u=>!u)},onKeyDown:h=>{h.key!=="Enter"&&h.key!==" "||(h.preventDefault(),h.stopPropagation(),s(u=>!u))},children:t.jsx("time",{dateTime:n,children:d})})}function $r(e){var r;return e.kind==="item"?e.item.createdAt??null:((r=e.items.find(n=>n.createdAt))==null?void 0:r.createdAt)??null}function qf(e){const r=e.filter(s=>s.kind==="item"),n=r.map(s=>s.item).filter(s=>s.kind==="userMessage"),a=r.map(s=>s.item).reverse().find(s=>s.kind==="agentMessage"&&s.text.trim().length>0),o=e.filter(s=>s.kind!=="item"?!0:s.item.kind!=="userMessage"&&s.item.id!==(a==null?void 0:a.id));return{users:n,finalAgent:a,hiddenEntries:o}}var Tn=c.memo(function({threadId:r,adapter:n,turn:a,absoluteIndex:o,isCollapsed:s,livePlan:l,liveItems:i,liveOutput:d,forceActive:h=!1,onToggleCollapse:u,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,onSelectArtifact:b,onBeforeMessageResize:k,scrollRootRef:x,articleRef:j,isLatestVisibleTurn:w=!1}){const y=!!l||!!d||!!(i&&i.length>0),v=h||vr(a.status)||y||w,S=v&&!vr(a.status)?{...a,status:"inProgress"}:a,N=c.useMemo(()=>Kp(a.items,i),[i,a.items]),I=c.useMemo(()=>Ff(l,N,a.status),[l,N,a.status]),M=c.useMemo(()=>qp(d,N),[d,N]),R=c.useMemo(()=>Vp(N,v),[v,N]),Q=c.useMemo(()=>Xp(R),[R]),$=h||vr(a.status)||y,Y=xt(a.startedAt),Z=Wt(a.startedAt),P=c.useMemo(()=>ml(M),[M]),[te,oe]=c.useState({}),T=c.useCallback(V=>{oe(de=>({...de,[V]:!de[V]}))},[]),re=t.jsx(Xf,{entries:Q,expandedGroups:te,onToggleGroupedItem:T,threadId:r,scrollRootRef:x,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,...k?{onBeforeMessageResize:k}:{},fallbackTimestamp:a.startedAt,fallbackTimeLabel:Y,fallbackTimeTitle:Z,turnStartedAt:a.startedAt,autoOpenLatestToolDetails:$,...b?{onSelectArtifact:b}:{},...n?{adapter:n}:{}}),B=P?t.jsx(ua,{threadId:r,item:P,scrollRootRef:x,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,timeLabel:a.startedAt?t.jsx(wr,{absoluteLabel:Y,timestamp:a.startedAt,turnStartedAt:a.startedAt}):Y,timeTitle:Z,timeMeta:null,...b?{onSelectArtifact:b}:{},...n?{adapter:n}:{}}):null,J=!P&&M?t.jsx(It,{item:{id:"live-agent-message",kind:"agentMessage",text:M},scrollRootRef:x,timeLabel:a.startedAt?t.jsx(wr,{absoluteLabel:Y,timestamp:a.startedAt,turnStartedAt:a.startedAt}):Y,timeTitle:Z,streaming:!0,...k?{onBeforeMessageResize:k}:{}}):null,K=v?t.jsx(Is,{turn:S,variant:"footer"}):null,L=c.useMemo(()=>qf(Q),[Q]),q=c.useMemo(()=>Vf(a.startedAt,N),[N,a.startedAt]),G=L.hiddenEntries.length>0,E=s&&G,W=zs(a.status)&&G&&!E?t.jsxs("button",{type:"button",className:"thread-graph-worked-summary group flex w-full items-center gap-2 py-2 text-left text-sm transition",onClick:()=>u(a.id,!1),"aria-label":`${q}. Collapse turn ${o}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:q}),t.jsx(D.ChevronDown,{className:"h-4 w-4 shrink-0 transition group-hover:translate-y-0.5"}),t.jsx("span",{className:"thread-graph-worked-rule h-px min-w-0 flex-1","aria-hidden":"true"})]}):null,H=zs(a.status)&&G?t.jsxs("div",{className:"thread-graph-turn-collapsed-summary space-y-2",children:[L.users.map(V=>t.jsx(It,{threadId:r,item:V,scrollRootRef:x,timeLabel:V.createdAt?xt(V.createdAt):Y,timeTitle:V.createdAt?Wt(V.createdAt):Z,...k?{onBeforeMessageResize:k}:{},...n?{adapter:n}:{}},V.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":`${q}. Expand turn ${o}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:q}),t.jsx(D.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"})]}),L.finalAgent?t.jsx(It,{threadId:r,item:L.finalAgent,scrollRootRef:x,timeLabel:L.finalAgent.createdAt?t.jsx(wr,{absoluteLabel:xt(L.finalAgent.createdAt),timestamp:L.finalAgent.createdAt,turnStartedAt:a.startedAt}):Y,timeTitle:L.finalAgent.createdAt?Wt(L.finalAgent.createdAt):Z,...k?{onBeforeMessageResize:k}:{},...n?{adapter:n}:{}}):null]}):null,se=t.jsx(Pf,{footer:K,history:t.jsxs(t.Fragment,{children:[W,re]}),liveHookPrompt:B,liveOutput:J,livePlan:I});return t.jsx(Rf,{absoluteIndex:o,body:se,collapsed:E,collapsedBody:H,error:a.error,headerStatus:t.jsx(Is,{turn:a}),isActive:v,refCallback:j,startedAt:a.startedAt,timeLabel:Y,timeTitle:Z,tokenSummary:t.jsx(Df,{turn:a})})});function Xf({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:k=!1}){var w;const x=((w=e.at(-1))==null?void 0:w.key)??null,j=c.useCallback(y=>y?t.jsx(wr,{absoluteLabel:xt(y),timestamp:y,turnStartedAt:b??f}):null,[f,b]);return t.jsx(ef,{entries:e,expandedGroups:r,onToggleGroupedItem:n,renderCommandGroup:(y,v,S)=>t.jsx(Cf,{items:y.items,expanded:v,onToggleExpanded:S,onOpen:l,timeMeta:j($r(y))},y.key),renderFileChangeGroup:(y,v,S)=>t.jsx(Ef,{items:y.items,expanded:v,onToggleExpanded:S,onOpen:s,timeMeta:j($r(y))},y.key),renderSearchGroup:(y,v,S)=>t.jsx(Sf,{items:y.items,expanded:v,onToggleExpanded:S,onOpen:s,timeMeta:j($r(y))},y.key),renderFileReadGroup:(y,v,S)=>t.jsx(Tf,{items:y.items,expanded:v,onToggleExpanded:S,onOpen:s,timeMeta:j($r(y))},y.key),renderItem:y=>{const v=Of(y.item,f??null),N=y.item.kind==="userMessage"?y.item.createdAt?xt(v):p:y.item.createdAt?t.jsx(wr,{absoluteLabel:xt(v),timestamp:v,turnStartedAt:b??f}):p;return t.jsx(ua,{threadId:a,item:y.item,scrollRootRef:o,timeLabel:N,timeTitle:y.item.createdAt?Wt(v):g,timeMeta:j(v),autoOpenToolDetails:k&&y.key===x,onOpenExpandedText:s,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,...u?{onBeforeMessageResize:u}:{},...h?{onSelectArtifact:h}:{},...m?{adapter:m}:{}},y.key)}})}var Ps=3,Yf=3,Zn=80;function gr(e,r=Zn){return e.scrollHeight-e.scrollTop-e.clientHeight<=r}function Zf(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 Jf(e){return e.map(n=>{const a=n.createdAt;return typeof a=="string"&&a.trim()?a:null}).filter(n=>!!n).sort()[0]??null}function Qf(e,r){return{id:e,startedAt:Jf(r),status:"inProgress",error:null,model:null,reasoningEffort:null,reasoningEffortAvailable:null,tokenUsage:null,priceEstimate:null,items:[]}}function Rs(e,r,n){return{id:e.id,kind:e.kind,title:r,text:n}}function eg({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:k,errorText:x,useSelectionCallback:j})=>{if(!p.hasDeferredDetail||!e){i(p,Rs(p,g,b),j);return}const w=a.current.get(p.id);if(w){i(p,w,j);return}const y=n.current+1;n.current=y,j&&r||s({title:g,text:k});try{const v=await e(p.id);if(a.current.set(p.id,v),n.current!==y)return;i(p,v,j)}catch(v){if(n.current!==y)return;i(p,Rs(p,g,v instanceof Error?v.message:x),j)}},[e,r,i]),h=c.useCallback(async(p,g)=>{var b;await d({item:p,fallbackTitle:g,fallbackText:((b=p.detailText)==null?void 0:b.trim())||p.text||"Command output",loadingText:"Loading full command output...",errorText:"Unable to load full command output.",useSelectionCallback:!0})},[d]),u=c.useCallback(async(p,g)=>{var b;await d({item:p,fallbackTitle:g,fallbackText:((b=p.detailText)==null?void 0:b.trim())||p.text||"Tool call",loadingText:"Loading full tool call details...",errorText:"Unable to load full tool call details.",useSelectionCallback:!0})},[d]),m=c.useCallback(async(p,g,b,k,x)=>{await d({item:p,fallbackTitle:g,fallbackText:b,loadingText:k,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 tg(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 rg({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),k=c.useRef(null),x=c.useRef(null),j=c.useRef(null),w=c.useRef(!0),y=c.useRef(!0),v=c.useRef(!1),S=c.useRef(!1),N=c.useRef(!1),I=c.useRef(!1),M=c.useRef(null),R=c.useRef(0),[Q,$]=c.useState(Ps),[Y,Z]=c.useState(0),[P,te]=c.useState(!0),oe=tg(d),T=typeof o=="function"||n!==void 0,re=n??r,B=T?0:Math.max(0,r-Q),K=(T?Math.max(0,re-r):0)+B,L=T?r:r-B,q=T?0:r-L,G=T?Math.max(0,re-r):0,E=T?G+q:q,C=!T&&E>0&&Y>=2,W=T&&G>0&&q===0&&typeof o=="function",H=c.useCallback(()=>{const X=h.current;if(!X){k.current=null;return}k.current={scrollHeight:X.scrollHeight,scrollTop:X.scrollTop}},[]),se=c.useCallback(()=>!W||a||N.current?!1:(H(),N.current=!0,I.current=!1,R.current=0,o==null||o(),!0),[W,a,o,H]),V=c.useCallback(()=>{const X=h.current,ue=x.current;if(!X)return;const ve=ue?Zf(X,ue):gr(X);w.current=ve,te(ke=>ke===ve?ke:ve)},[]),de=c.useCallback(()=>{const X=h.current;if(X){S.current=!0;const ue=X.scrollTop,ve=b.current,ke=ue-ve;b.current=ue,gr(X,1)?(v.current=!1,y.current=!0):ke<-1?(v.current=!0,y.current=!1):ke>1&&(y.current=!v.current&&gr(X,Zn)),ue<=0&&S.current?I.current=!0:ue>0&&(I.current=!1,R.current=0)}V()},[V]),ee=c.useCallback(()=>{const X=h.current;X&&(X.scrollTop=X.scrollHeight,b.current=X.scrollTop,g.current=X.scrollHeight,w.current=!0,te(ue=>ue||!0),v.current=!1,y.current=!0)},[]),be=c.useCallback(()=>{const X=h.current;X&&(b.current=X.scrollTop,g.current=X.scrollHeight,y.current=!1,v.current=!0)},[]),ie=c.useCallback(()=>{if(T&&q===0){se();return}$(X=>Math.min(r,X+Yf)),Z(X=>X+1)},[q,T,se,r]),ye=c.useCallback(X=>{const ue=h.current;if(!(!ue||X.deltaY>=-8||ue.scrollTop>0||!W)){if(!I.current){I.current=!0;return}se()}},[W,se]),Ae=c.useCallback(X=>{var ue;M.current=((ue=X.touches.item(0))==null?void 0:ue.clientY)??null,R.current=0},[]),ce=c.useCallback(X=>{var He;const ue=h.current,ve=((He=X.touches.item(0))==null?void 0:He.clientY)??null,ke=M.current;if(M.current=ve,!ue||ve===null||ke===null||ue.scrollTop>0||!W){R.current=0;return}const $e=ve-ke;if($e<=0){R.current=0;return}if(!I.current){I.current=!0,R.current=0;return}R.current+=$e,R.current>=28&&se()},[W,se]),Ce=c.useCallback(()=>{M.current=null,R.current=0},[]),Le=c.useCallback(()=>{$(r)},[r]);return c.useLayoutEffect(()=>{const X=window.requestAnimationFrame(()=>{ee()});return()=>{window.cancelAnimationFrame(X)}},[e,ee]),c.useEffect(()=>{N.current=!1,S.current=!1,I.current=!1,k.current=null},[e]),c.useEffect(()=>{a||(N.current=!1)},[a,r]),c.useLayoutEffect(()=>{const X=k.current,ue=h.current;if(!X||!ue||a)return;k.current=null;const ve=ue.scrollHeight-X.scrollHeight;if(ve<=0){g.current=ue.scrollHeight,b.current=ue.scrollTop;return}const ke=X.scrollTop+ve;ue.scrollTop=ke,b.current=ke,g.current=ue.scrollHeight,v.current=!0,y.current=!1,I.current=!1},[a,r]),c.useEffect(()=>{$(X=>X>=r-1?r:Math.max(X,Ps))},[r]),c.useEffect(()=>{const X=h.current;X&&(g.current=X.scrollHeight,b.current=X.scrollTop,gr(X,1)?(v.current=!1,y.current=!0):(v.current||!gr(X,Zn))&&(y.current=!1)),V()},[oe,V,Q]),c.useEffect(()=>{const X=s!==m.current,ue=f.current!==oe;if(f.current=oe,!(X||ue&&y.current&&!v.current))return;const ke=window.requestAnimationFrame(()=>{ee()});return s!==m.current&&(m.current=s),()=>{window.cancelAnimationFrame(ke)}},[oe,P,ee,s]),c.useEffect(()=>{const X=h.current,ue=u.current;if(!X||!ue||typeof ResizeObserver>"u")return;g.current=X.scrollHeight;const ve=new ResizeObserver(()=>{const ke=X.scrollHeight,$e=g.current;if(g.current=ke,ke<=$e)return;const He=$e>0&&$e-X.scrollTop-X.clientHeight<=1;v.current||!(y.current||He||w.current)||window.requestAnimationFrame(()=>{ee()})});return ve.observe(ue),()=>{ve.disconnect()}},[ee]),c.useEffect(()=>{if(!y.current||v.current){p.current=l;return}if(l===p.current)return;p.current=l;const X=window.requestAnimationFrame(()=>{ee()});return()=>{window.cancelAnimationFrame(X)}},[l,ee]),c.useEffect(()=>{i==null||i(P)},[P,i]),{scrollContainerRef:h,scrollContentRef:u,tailSentinelRef:x,topSentinelRef:j,isTailVisible:P,handleScroll:de,handleWheel:ye,handleTouchStart:Ae,handleTouchMove:ce,handleTouchEnd:Ce,preserveScrollPositionForResize:be,serverManagedHistory:T,effectiveTotalTurnCount:re,startIndex:B,visibleTurnAbsoluteOffset:K,hiddenCount:E,loadedHiddenCount:q,unloadedHiddenCount:G,showLoadAll:C,handleLoadEarlierClick:ie,handleLoadAllClick:Le}}function ng(e){return e==="completed"||e==="failed"||e==="interrupted"}function ag(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 sg({threadId:e,turns:r,totalTurnCount:n,pendingRequests:a=[],activeTurnId:o=null,threadRunning:s=!1,pendingSteers:l=[],livePlan:i=null,liveItems:d=null,respondingRequestId:h=null,onRespondToRequest:u,liveOutput:m,scrollRequestKey:f=0,previousTurnScrollRequestKey:p=0,nextTurnScrollRequestKey:g=0,bottomSpacer:b=0,className:k="",onTailVisibilityChange:x,onPreviousTurnAvailabilityChange:j,onNextTurnAvailabilityChange:w,loadingEarlier:y=!1,onLoadEarlier:v,ephemeralUserNote:S=null,answeredRequestNotes:N=[],activityNotes:I=[],optimisticSteers:M=[],optimisticTurn:R=null,onLoadHistoryItemDetail:Q,onOpenThread:$,onSelectArtifact:Y,onSelectHistoryItemDetail:Z,adapter:P,autoCollapseCompletedTurns:te}){var vt,it,Nt,Rt,Ct;const oe=ll(),T=te??(oe==null?void 0:oe.autoCollapseCompletedTurns)??!1,[re,B]=c.useState({}),[J,K]=c.useState(()=>new Set),L=c.useRef(null),q=c.useRef(null),G=(P==null?void 0:P.onLoadHistoryItemDetail)??Q,E=P==null?void 0:P.onOpenLinkedThread,{expandedText:C,openExpandedText:W,openCommandDetail:H,openToolCallDetail:se,openDeferredHistoryItemDetail:V,closeExpandedText:de}=eg({loadHistoryItemDetail:G,onSelectHistoryItemDetail:Z}),{scrollContainerRef:ee,scrollContentRef:be,tailSentinelRef:ie,topSentinelRef:ye,handleScroll:Ae,handleWheel:ce,handleTouchStart:Ce,handleTouchMove:Le,handleTouchEnd:X,preserveScrollPositionForResize:ue,serverManagedHistory:ve,effectiveTotalTurnCount:ke,startIndex:$e,visibleTurnAbsoluteOffset:He,hiddenCount:_e,loadedHiddenCount:ze,unloadedHiddenCount:F,showLoadAll:le,handleLoadEarlierClick:we,handleLoadAllClick:z}=rg({threadId:e,turnsLength:r.length,totalTurnCount:n,loadingEarlier:y,onLoadEarlier:v,scrollRequestKey:f,bottomSpacer:b,onTailVisibilityChange:x,contentRevisionInputs:[r,a,l,M,m,i,d,R,N,I,S,b]}),O=c.useCallback((_,pe)=>{B(Re=>({...Re,[_]:!pe}))},[]),ne=c.useCallback((_,pe)=>{const Re=re[_.id];return Re!==void 0?Re:!!(T&&ng(_.status)&&!pe.forceActive&&!pe.hasLiveActivity)},[re,T]),ge=ve?r:r.slice($e),Te=ke+1,Ee=s&&(!o||!ge.some(_=>_.id===o)&&(R==null?void 0:R.id)!==o),fe=(R==null?void 0:R.id)??((vt=ge.at(-1))==null?void 0:vt.id)??null,De=Ee&&fe!==null,Be=!!d&&(ge.some(_=>_.id===d.turnId)||(R==null?void 0:R.id)===d.turnId),et=d&&Be?d.turnId:d&&De?fe:null,Ve=R&&et===R.id?(d==null?void 0:d.items)??null:null,pt=((d==null?void 0:d.items.length)??0)>0,nt=d&&et===null?d.items:null,We=c.useMemo(()=>d&&et===null&&d.items.length>0?Qf(d.turnId,d.items):null,[d,et]),ot=Math.max(1,ke+(R?1:0)),ht=!!m&&!!R&&R.status!=="failed"&&!Ve,ut=m&&ge.length>0?o&&ge.some(_=>_.id===o)?o:((it=ge.findLast(_=>pl(_.status)))==null?void 0:it.id)??(De?fe:null):null,A=!!ut,U=c.useMemo(()=>ml(m),[m]),xe=[...l.map(_=>({id:_.id,prompt:_.prompt,status:"Accepted",createdAt:_.createdAt,canCancel:!0})),...M.map(_=>({id:_.id,prompt:_.prompt,status:_.status==="steering"?"Steering":null,createdAt:_.createdAt,canCancel:!1}))].sort((_,pe)=>_.createdAt.localeCompare(pe.createdAt)),je=c.useMemo(()=>Yp({answeredRequestNotes:N,pendingRequests:a,visibleTurns:ge,optimisticTurn:R}),[N,R,a,ge]),Ne=c.useMemo(()=>Zp({activityNotes:I,visibleTurns:ge,optimisticTurn:R}),[I,R,ge]),Ye=c.useCallback(()=>{const _=ee.current;if(!_)return null;const pe=_.getBoundingClientRect().top;return Array.from(_.querySelectorAll("[data-timeline-turn]")).find(Re=>Re.getBoundingClientRect().top>pe+8)??null},[ee]),tt=c.useCallback(()=>{const _=ee.current;if(!_)return null;const pe=_.getBoundingClientRect().top;return Array.from(_.querySelectorAll("[data-timeline-turn]")).findLast(Re=>Re.getBoundingClientRect().top<pe-8)??null},[ee]),Fe=c.useCallback(()=>{j==null||j(!!tt())},[tt,j]),Ke=c.useCallback(()=>{w==null||w(!!Ye())},[Ye,w]),lt=c.useCallback(()=>{Ae(),Fe(),Ke()},[Ae,Ke,Fe]);return c.useEffect(()=>{Fe(),Ke()},[Ke,Fe,ge]),c.useEffect(()=>{if(p===0)return;const _=ee.current,pe=tt(),Re=_?Array.from(_.querySelectorAll("[data-timeline-turn]")):[],Ge=pe?Re.indexOf(pe):-1,Ue=pe&&pe.dataset.turnId===L.current?Re[Ge-1]??null:pe;if(!_||!Ue)return;L.current=Ue.dataset.turnId??null;const ct=Ue.getBoundingClientRect().top-_.getBoundingClientRect().top;_.scrollTo({top:_.scrollTop+ct-8,behavior:"smooth"}),Re.indexOf(Ue)===0&&(j==null||j(!1))},[tt,j,p,ee]),c.useEffect(()=>{if(g===0)return;const _=ee.current,pe=Ye(),Re=_?Array.from(_.querySelectorAll("[data-timeline-turn]")):[],Ge=pe?Re.indexOf(pe):-1,Ue=pe&&pe.dataset.turnId===q.current?Re[Ge+1]??null:pe;if(!_||!Ue)return;q.current=Ue.dataset.turnId??null;const ct=Ue.getBoundingClientRect().top-_.getBoundingClientRect().top;_.scrollTo({top:_.scrollTop+ct-8,behavior:"smooth"}),Re.indexOf(Ue)===Re.length-1&&(w==null||w(!1))},[Ye,g,w,ee]),t.jsxs(t.Fragment,{children:[t.jsx("section",{className:`flex min-h-0 flex-1 flex-col ${k}`.trim(),children:t.jsx("div",{ref:ee,"data-testid":"thread-scroll-container",onScroll:lt,onWheel:ce,onTouchStart:Ce,onTouchMove:Le,onTouchEnd:X,onTouchCancel:X,className:"thread-graph-scroll-container min-h-0 flex-1 overflow-y-auto overscroll-contain",style:b>0?{paddingBottom:b}:void 0,children:t.jsxs("div",{ref:be,className:"thread-graph-scroll-content",children:[t.jsx("div",{ref:ye,"aria-hidden":"true",className:"h-px"}),r.length>0&&t.jsx("div",{className:"thread-graph-history-control px-3 pb-1 pt-2 sm:px-5 sm:pb-1.5 sm:pt-3",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 text-xs sm:text-sm",children:[_e>0&&t.jsx("button",{type:"button",onClick:we,disabled:y,className:"thread-graph-history-button rounded-full border px-2.5 py-1.5 transition",children:y?"Loading earlier...":"Load 3 earlier"}),le&&t.jsx("button",{type:"button",onClick:z,className:"rounded-full border border-amber-300/40 px-2.5 py-1.5 text-amber-200 transition hover:bg-amber-300/10",children:"Load full history"}),t.jsxs("p",{className:"timeline-meta-text",children:["Showing ",ge.length," of ",ke," turns",_e>0?` · ${_e} earlier hidden${ze>0&&F>0?` (${ze} loaded)`:""}`:""]})]})}),r.length===0&&!m&&!R&&t.jsx("div",{className:"thread-graph-empty-state px-3 py-8 text-sm sm:px-5",children:"Send the first prompt to start the thread."}),(ge.length>0||R||Ne.leading.length>0||Ne.trailing.length>0)&&t.jsxs("div",{className:"thread-graph-message-list",children:[Ne.leading.length>0?t.jsx(pr,{notes:Ne.leading,onOpenThread:$,onOpenLinkedThread:E}):null,ge.map((_,pe)=>{var Re,Ge,Ue,ct,kt;return t.jsxs("div",{"data-timeline-turn":!0,"data-turn-id":_.id,children:[(((Re=Ne.beforeTurnId.get(_.id))==null?void 0:Re.length)??0)>0?t.jsx(pr,{notes:Ne.beforeTurnId.get(_.id)??[],onOpenThread:$,onOpenLinkedThread:E}):null,(((Ge=je.beforeTurnId.get(_.id))==null?void 0:Ge.length)??0)>0?t.jsx(Xn,{entries:je.beforeTurnId.get(_.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const qt=ag(_,R),Xt=(i==null?void 0:i.turnId)===_.id?i:null,Mt=et===_.id?(d==null?void 0:d.items)??null:null,cr=ut===_.id?m:"",at=o===_.id||De&&fe===_.id,dn=!!Xt||!!cr||!!(Mt&&Mt.length>0),cn=ne(qt,{forceActive:at,hasLiveActivity:dn});return t.jsx(Tn,{threadId:e,...P?{adapter:P}:{},turn:qt,absoluteIndex:He+pe+1,isCollapsed:cn,livePlan:Xt,liveItems:Mt,liveOutput:cr,forceActive:at,onToggleCollapse:O,onOpenExpandedText:W,onOpenCommandDetail:H,onOpenToolCallDetail:se,onOpenDeferredHistoryItemDetail:V,onBeforeMessageResize:ue,...Y?{onSelectArtifact:Y}:{},scrollRootRef:ee,articleRef:void 0})})(),(((Ue=Ne.afterTurnId.get(_.id))==null?void 0:Ue.length)??0)>0?t.jsx(pr,{notes:Ne.afterTurnId.get(_.id)??[],onOpenThread:$,onOpenLinkedThread:E}):null,(ct=je.notesByTurnId.get(_.id))!=null&&ct.length||(kt=je.pendingRequestsByTurnId.get(_.id))!=null&&kt.length?t.jsx(Jp,{notes:je.notesByTurnId.get(_.id)??[],requests:je.pendingRequestsByTurnId.get(_.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null]},_.id)}),R&&ge.every(_=>_.id!==R.id)&&t.jsxs(t.Fragment,{children:[(((Nt=Ne.beforeTurnId.get(R.id))==null?void 0:Nt.length)??0)>0?t.jsx(pr,{notes:Ne.beforeTurnId.get(R.id)??[],onOpenThread:$,onOpenLinkedThread:E}):null,(((Rt=je.beforeTurnId.get(R.id))==null?void 0:Rt.length)??0)>0?t.jsx(Xn,{entries:je.beforeTurnId.get(R.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const _=ht?m:"",pe=o===R.id||De&&fe===R.id,Re=!!(Ve&&Ve.length>0)||!!_,Ge=ne(R,{forceActive:pe,hasLiveActivity:Re});return t.jsx(Tn,{threadId:e,...P?{adapter:P}:{},turn:R,absoluteIndex:Te,isCollapsed:Ge,livePlan:null,liveItems:Ve,liveOutput:_,forceActive:pe,onToggleCollapse:O,onOpenExpandedText:W,onOpenCommandDetail:H,onOpenToolCallDetail:se,onOpenDeferredHistoryItemDetail:V,onBeforeMessageResize:ue,...Y?{onSelectArtifact:Y}:{},scrollRootRef:ee})})(),(((Ct=Ne.afterTurnId.get(R.id))==null?void 0:Ct.length)??0)>0?t.jsx(pr,{notes:Ne.afterTurnId.get(R.id)??[],onOpenThread:$,onOpenLinkedThread:E}):null]})]}),xe.length>0&&t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:xe.map(_=>t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(It,{threadId:e,item:{id:_.id,kind:"userMessage",text:_.prompt,status:_.status},scrollRootRef:ee,onBeforeMessageResize:ue,...P?{adapter:P}:{}}),e&&_.canCancel&&(P!=null&&P.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:J.has(_.id),onClick:()=>{var pe;K(Re=>new Set(Re).add(_.id)),Promise.resolve((pe=P.cancelPendingSteer)==null?void 0:pe.call(P,e,_.id)).catch(()=>{}).finally(()=>{K(Re=>{const Ge=new Set(Re);return Ge.delete(_.id),Ge})})},children:J.has(_.id)?"Canceling...":"Cancel"})}):null]},_.id))}),(je.trailing.length>0||Ne.trailing.length>0)&&t.jsx(Qp,{entries:[...Ne.trailing.map(_=>({kind:"activity",id:_.id,createdAt:_.createdAt,note:_})),...je.trailing],respondingRequestId:h,onRespondToRequest:u??void 0,onOpenThread:$,onOpenLinkedThread:E}),S&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:t.jsx(It,{threadId:e,item:{id:"ephemeral-plan-decision-note",kind:"userMessage",text:S},scrollRootRef:ee,onBeforeMessageResize:ue})}),We&&nt&&nt.length>0&&t.jsx(Tn,{threadId:e,...P?{adapter:P}:{},turn:We,absoluteIndex:ot,isCollapsed:re[We.id]??!1,livePlan:(i==null?void 0:i.turnId)===We.id?i:null,liveItems:nt,liveOutput:"",forceActive:!0,onToggleCollapse:O,onOpenExpandedText:W,onOpenCommandDetail:H,onOpenToolCallDetail:se,onOpenDeferredHistoryItemDetail:V,onBeforeMessageResize:ue,...Y?{onSelectArtifact:Y}:{},scrollRootRef:ee}),m&&!A&&!ht&&!pt&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:U?t.jsx(ua,{threadId:e,item:U,scrollRootRef:ee,onOpenExpandedText:W,onOpenCommandDetail:H,onOpenToolCallDetail:se,onOpenDeferredHistoryItemDetail:V,onBeforeMessageResize:ue,...Y?{onSelectArtifact:Y}:{},...P?{adapter:P}:{}}):t.jsx(It,{threadId:e,item:{id:"live-agent-message-fallback",kind:"agentMessage",text:m},scrollRootRef:ee,streaming:!0,onBeforeMessageResize:ue,...P?{adapter:P}:{}})}),t.jsx("div",{ref:ie,"aria-hidden":"true",className:"h-px w-full"})]})})}),t.jsx(pp,{open:C!==null,title:(C==null?void 0:C.title)??"Full text",text:(C==null?void 0:C.text)??"",onClose:de})]})}var Cl=c.memo(sg);function og(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}function Jn(e){return e.replace(/\r\n/g,`
|
|
3667
|
+
`)}function Ms(e){const r=Jn(e),n=r.split(`
|
|
3668
3668
|
`);return r.endsWith(`
|
|
3669
|
-
`)&&n.at(-1)===""&&n.pop(),n}function
|
|
3670
|
-
`).trimEnd()}function hg(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 _s(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 Ln(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 dn(e){if(!e)return"";const r=e.replace(/[\\/]+$/,"");return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function fa(e,r){const n=[r==null?void 0:r.trim(),e==null?void 0:e.trim()].filter(Boolean);return n.length>0?n.join(" "):null}function In(e){return Math.min(75,Math.max(25,e))}function ug(){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 mg({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 Ds(){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 zn({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 pg=120,fg=800,gg=4e3,xg=4500,bg="Shell connection timed out. Reconnecting...";function vg({isCurrentSocket:e,viewerId:r}){return!e||r?null:{connectionError:bg,isConnecting:!1,settleAttachPromise:!1,closeSocket:!0}}function kg({isCurrentSocket:e,shellId:r,attachSize:n}){return e?{message:{type:"shell.attach",shellId:r,cols:n.cols,rows:n.rows},shouldScheduleAttachTimeout:!0}:null}function wg({intentionalDisconnect:e,userDisconnectedShellId:r,shellId:n}){return!e&&r!==n}function yg({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:o}){return e?{shouldDetachShell:r,shouldScheduleReconnect:wg({intentionalDisconnect:n,userDisconnectedShellId:a,shellId:o})}:null}function jg({hasAttachSize:e,hasPendingRetry:r}){return!e&&!r}function Tl({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}:jg({hasAttachSize:!1,hasPendingRetry:i})?{type:"scheduleRetry"}:{type:"skip"}}function Ng({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 Sg({hasShell:e}){return e?null:{viewerId:null,isConnecting:!1,settleAttachPromise:!1,connectionError:null,runtimePromptLabel:null,isCommandRunning:!1,shellSnapshot:"",lastCommandOutput:"",pendingCommand:null,shouldResetTerminal:!0}}function Tg({hasReconnectTimer:e,hasAttachTimeout:r,hasAttachRetry:n}){return{shouldClearReconnectTimer:e,shouldClearAttachTimeout:r,shouldClearAttachRetry:n,settleAttachPromise:!1}}function El({shellId:e,viewerId:r}){return e&&r?{type:"shell.detach",shellId:e,viewerId:r}:null}function Eg({shellId:e,viewerId:r,hasSocket:n}){return{userDisconnectedShellId:e,intentionalDisconnect:!0,detachMessage:El({shellId:e,viewerId:r}),shouldCloseSocket:n,shouldClearSocketRef:!0,shouldClearLastSentSize:!0,shouldDetachShell:!!e}}function Lg({shellId:e,viewerId:r,socketReadyState:n,openReadyState:a,hasAttachRetryTimer:o,hasAttachTimeout:s,isCurrentSocket:l}){const i=El({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 Ig({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 zg(e,r){const n=typeof e.cwdBaseName=="string"?e.cwdBaseName:null,a=typeof e.envPrefix=="string"?e.envPrefix:null;return{data:typeof e.data=="string"?e.data:"",replace:e.replace===!0,cursorX:typeof e.cursorX=="number"?e.cursorX:void 0,cursorY:typeof e.cursorY=="number"?e.cursorY:void 0,paneHeight:typeof e.paneHeight=="number"?e.paneHeight:void 0,promptLabel:fa(n??dn(r),a),isCommandRunning:e.isCommandRunning===!0}}function Pg({currentSnapshot:e,data:r,replace:n,isCommandRunning:a,pendingCommand:o}){if(!r)return{nextSnapshot:e,nextPendingCommand:o,lastCommandOutput:null};const s=Qn(n?r:`${e}${r}`);return!n||a||!o?{nextSnapshot:s,nextPendingCommand:o,lastCommandOutput:null}:{nextSnapshot:s,nextPendingCommand:null,lastCommandOutput:cg(o.beforeSnapshot,s,o.command)}}function Rg({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 Ll(e,r,n,a,o){const s=r.replace(/\r\n/g,`
|
|
3669
|
+
`)&&n.at(-1)===""&&n.pop(),n}function lg(e){const r=e.trim();return r?/(?:[$%#>])\s*$/.test(r):!1}function ig(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 dg(e,r,n){var d,h;const a=Ms(e),o=Ms(r);let s=0;for(;s<a.length&&s<o.length&&a[s]===o[s];)s+=1;let l=0;for(;l<a.length-s&&l<o.length-s&&a[a.length-1-l]===o[o.length-1-l];)l+=1;let i=o.slice(s,o.length-l);for(i=ig(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())===""||lg(i.at(-1)??""));)i.pop();return i.join(`
|
|
3670
|
+
`).trimEnd()}function cg(e){switch(e){case"ctrl_c":return"";case"ctrl_d":return"";case"esc":return"\x1B";case"tab":return" ";case"up":return"\x1B[A";case"down":return"\x1B[B"}}function As(e){return{background:e==="light"?"#f2ede5":"#0c1117",foreground:e==="light"?"#3f3a36":"#d6dde6",cursor:e==="light"?"#3f3a36":"#d6dde6",black:e==="light"?"#d8cfc2":"#0f1720",brightBlack:e==="light"?"#8a7f73":"#475569",red:"#f87171",brightRed:"#fb7185",green:e==="light"?"#16a34a":"#86efac",brightGreen:e==="light"?"#22c55e":"#4ade80",yellow:"#fbbf24",brightYellow:"#fcd34d",blue:e==="light"?"#2563eb":"#93c5fd",brightBlue:e==="light"?"#3b82f6":"#60a5fa",magenta:e==="light"?"#7c3aed":"#c4b5fd",brightMagenta:e==="light"?"#8b5cf6":"#a78bfa",cyan:e==="light"?"#0891b2":"#67e8f9",brightCyan:e==="light"?"#06b6d4":"#22d3ee",white:e==="light"?"#5b5148":"#e2e8f0",brightWhite:e==="light"?"#2c2723":"#f8fafc"}}function En(e){switch(e){case"not_created":return"Not created";case"creating":return"Creating";case"running":return"Running";case"attached":return"Attached";case"detached":return"Detached";case"exited":return"Exited";case"not_found":return"Missing";case"workspace_missing":return"Workspace missing"}}function ln(e){if(!e)return"";const r=e.replace(/[\\/]+$/,"");return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function ma(e,r){const n=[r==null?void 0:r.trim(),e==null?void 0:e.trim()].filter(Boolean);return n.length>0?n.join(" "):null}function Ln(e){return Math.min(75,Math.max(25,e))}function hg(){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 ug({connected:e}){return e?t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",className:"h-4.5 w-4.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M13.19 8.688a4.5 4.5 0 0 1 1.242 7.244l-4.5 4.5a4.5 4.5 0 0 1-6.364-6.364l1.757-1.757m13.35-.622 1.757-1.757a4.5 4.5 0 0 0-6.364-6.364l-4.5 4.5a4.5 4.5 0 0 0 1.242 7.244"})}):t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",className:"h-4.5 w-4.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M13.181 8.68a4.503 4.503 0 0 1 1.903 6.405m-9.768-2.782L3.56 14.06a4.5 4.5 0 0 0 6.364 6.365l3.129-3.129m5.614-5.615 1.757-1.757a4.5 4.5 0 0 0-6.364-6.365l-4.5 4.5c-.258.26-.479.541-.661.84m1.903 6.405a4.495 4.495 0 0 1-1.242-.88 4.483 4.483 0 0 1-1.062-1.683m6.587 2.345 5.907 5.907m-5.907-5.907L8.898 8.898M2.991 2.99 8.898 8.9"})})}function _s(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5.5 3.25h5"}),t.jsx("path",{d:"M6.4 2h3.2a.9.9 0 0 1 .9.9v.35h1.3a1.2 1.2 0 0 1 1.2 1.2v7.35a1.2 1.2 0 0 1-1.2 1.2H4.2A1.2 1.2 0 0 1 3 11.8V4.45a1.2 1.2 0 0 1 1.2-1.2h1.3V2.9a.9.9 0 0 1 .9-.9Z"})]})}function In({label:e,tone:r="stone"}){const n=r==="rose"?"border-rose-300/35 bg-rose-300/14 text-rose-600 dark:text-rose-50":r==="sky"?"border-sky-300/35 bg-sky-300/14 text-sky-600 dark:text-sky-50":"shell-control-chip border";return t.jsx("span",{className:`inline-flex min-w-[3.45rem] items-center justify-center rounded-full border px-2.5 py-1.5 text-[11px] font-medium tracking-[0.12em] ${n}`,children:e})}var mg=120,pg=800,fg=4e3,gg=4500,xg="Shell connection timed out. Reconnecting...";function bg({isCurrentSocket:e,viewerId:r}){return!e||r?null:{connectionError:xg,isConnecting:!1,settleAttachPromise:!1,closeSocket:!0}}function vg({isCurrentSocket:e,shellId:r,attachSize:n}){return e?{message:{type:"shell.attach",shellId:r,cols:n.cols,rows:n.rows},shouldScheduleAttachTimeout:!0}:null}function kg({intentionalDisconnect:e,userDisconnectedShellId:r,shellId:n}){return!e&&r!==n}function wg({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:o}){return e?{shouldDetachShell:r,shouldScheduleReconnect:kg({intentionalDisconnect:n,userDisconnectedShellId:a,shellId:o})}:null}function yg({hasAttachSize:e,hasPendingRetry:r}){return!e&&!r}function Sl({shellId:e,terminalReady:r,isVisible:n,canAttachShell:a,userDisconnectedShellId:o,hasTerminal:s,attachSize:l,hasPendingAttachRetry:i,hasCurrentSocketForShell:d,hasReconnectTimer:h}){return!e||!r||!n||!a||o===e||!s?{type:"skip"}:l===void 0?{type:"measureSize"}:l?d?{type:"reuseSocket",shouldClearAttachRetry:i}:{type:"startAttach",attachSize:l,shouldClearAttachRetry:i,shouldClearReconnectTimer:h}:yg({hasAttachSize:!1,hasPendingRetry:i})?{type:"scheduleRetry"}:{type:"skip"}}function jg({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 Ng({shellId:e,userDisconnectedShellId:r}){return{shouldClearUserDisconnectedShellId:!!e&&r===e,intentionalDisconnect:!1,connectionError:null,isConnecting:!0,shouldIncrementReconnectKey:!0}}function Cg({hasShell:e}){return e?null:{viewerId:null,isConnecting:!1,settleAttachPromise:!1,connectionError:null,runtimePromptLabel:null,isCommandRunning:!1,shellSnapshot:"",lastCommandOutput:"",pendingCommand:null,shouldResetTerminal:!0}}function Sg({hasReconnectTimer:e,hasAttachTimeout:r,hasAttachRetry:n}){return{shouldClearReconnectTimer:e,shouldClearAttachTimeout:r,shouldClearAttachRetry:n,settleAttachPromise:!1}}function Tl({shellId:e,viewerId:r}){return e&&r?{type:"shell.detach",shellId:e,viewerId:r}:null}function Tg({shellId:e,viewerId:r,hasSocket:n}){return{userDisconnectedShellId:e,intentionalDisconnect:!0,detachMessage:Tl({shellId:e,viewerId:r}),shouldCloseSocket:n,shouldClearSocketRef:!0,shouldClearLastSentSize:!0,shouldDetachShell:!!e}}function Eg({shellId:e,viewerId:r,socketReadyState:n,openReadyState:a,hasAttachRetryTimer:o,hasAttachTimeout:s,isCurrentSocket:l}){const i=Tl({shellId:e,viewerId:r});return{intentionalDisconnect:!0,shouldClearAttachRetry:o,detachMessage:i,shouldSendDetachMessage:!!(i&&n===a),shouldClearViewer:!0,isConnecting:!1,settleAttachPromise:l?!1:void 0,shouldClearAttachTimeout:s,shouldCloseSocket:!0,shouldClearSocketRef:l}}function Lg({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 Ig(e,r){const n=typeof e.cwdBaseName=="string"?e.cwdBaseName:null,a=typeof e.envPrefix=="string"?e.envPrefix:null;return{data:typeof e.data=="string"?e.data:"",replace:e.replace===!0,cursorX:typeof e.cursorX=="number"?e.cursorX:void 0,cursorY:typeof e.cursorY=="number"?e.cursorY:void 0,paneHeight:typeof e.paneHeight=="number"?e.paneHeight:void 0,promptLabel:ma(n??ln(r),a),isCommandRunning:e.isCommandRunning===!0}}function zg({currentSnapshot:e,data:r,replace:n,isCommandRunning:a,pendingCommand:o}){if(!r)return{nextSnapshot:e,nextPendingCommand:o,lastCommandOutput:null};const s=Jn(n?r:`${e}${r}`);return!n||a||!o?{nextSnapshot:s,nextPendingCommand:o,lastCommandOutput:null}:{nextSnapshot:s,nextPendingCommand:null,lastCommandOutput:dg(o.beforeSnapshot,s,o.command)}}function Pg({event:e,currentViewerId:r}){if(e.type==="shell.output")return null;if(e.type==="shell.connected"){const a=String(e.payload.viewerId??"");return{viewerId:a||null,isConnecting:!1,settleAttachPromise:!!a,isCommandRunning:void 0,connectionError:void 0,intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:{status:"attached",attachedViewerId:a}}}if(e.type==="shell.error")return{viewerId:void 0,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:void 0,connectionError:String(e.payload.message??"Shell connection failed."),intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:e.payload.code==="viewer_conflict"?{status:"detached",attachedViewerId:null}:void 0};if(e.type==="shell.detached"){const a=String(e.payload.viewerId??"");if(!a||a!==r)return null;const o=String(e.payload.reason??"");return{viewerId:null,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:!1,connectionError:o==="replaced"?"This shell connection was taken over by another pane or device.":null,intentionalDisconnect:o==="replaced"?!0:void 0,closeSocket:!0,shellUpdate:{status:"detached",attachedViewerId:null}}}if(e.type==="shell.exited")return{viewerId:null,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:!1,connectionError:void 0,intentionalDisconnect:!0,closeSocket:!0,shellUpdate:{status:e.payload.state==="exited"?"exited":"not_found",attachedViewerId:null}};const n=e.payload.state;return{viewerId:n==="attached"?void 0:null,isConnecting:n==="attached"?void 0:!1,settleAttachPromise:n==="attached"?void 0:!1,isCommandRunning:n==="attached"?void 0:!1,connectionError:void 0,intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:{status:n,attachedViewerId:n==="attached"?void 0:null}}}function El(e,r,n,a,o){const s=r.replace(/\r\n/g,`
|
|
3671
3671
|
`),l=s.split(`
|
|
3672
3672
|
`);s.endsWith(`
|
|
3673
3673
|
`)&&l.at(-1)===""&&l.pop();let d=l.join(`\r
|
|
3674
|
-
`);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
|
|
3675
|
-
`).trimEnd():""}function Mg({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 Gs={status:"not_created",shellInputEnabled:!1,isConnecting:!1,isCommandRunning:!1,promptLabel:null,error:null,hasShell:!1};function gt(e){return e.status!=="exited"&&e.status!=="not_found"}function Ag({shell:e,workspacePathMissing:r}){return!!(e&&!r&>(e))}function $g(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 _g(e){return(e.activeShellId?e.shells.find(r=>r.id===e.activeShellId&>(r)):null)??(e.shell&>(e.shell)?e.shell:null)??e.shells.find(gt)??null}function Dg({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&&!gt(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&&!gt(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 Bg({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?fa(dn(r.cwd),null):null),isMobileShell:o,hasShell:!!r,busy:s,loading:l,error:e.error??i}}function Ht(e){return e.current===null?!1:(window.clearTimeout(e.current),e.current=null,!0)}function Gg({attachRetryTimerRef:e,setReconnectKey:r,delayMs:n=pg}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function Fg({reconnectTimerRef:e,setReconnectKey:r,delayMs:n=fg}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function Hg({shellSocket:e,socketRef:r,viewerIdRef:n,attachTimeoutRef:a,setConnectionError:o,setIsConnecting:s,settleAttachPromise:l,delayMs:i=gg}){a.current=window.setTimeout(()=>{var h,u,m;a.current=null;const d=vg({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 Og(e){return{...e,status:e.status==="attached"?"detached":e.status,attachedViewerId:null}}function Wg({shellId:e,viewerId:r,shellSocket:n,attachRetryTimerRef:a,attachTimeoutRef:o,socketRef:s,openReadyState:l}){var i;return Lg({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 Ug({closeApplication:e,shellId:r,attachTimeoutRef:n,socketRef:a,reconnectTimerRef:o,setViewerId:s,setIsConnecting:l,settleAttachPromise:i,onShellUpdate:d,setReconnectKey:h}){const u=e.closeAction;return u?(e.shouldClearAttachTimeout&&Ht(n),e.shouldClearSocketRef&&(a.current=null),s(e.viewerId),l(e.isConnecting),i(e.settleAttachPromise),u.shouldDetachShell&&d(r,Og,"detached"),u.shouldScheduleReconnect&&Fg({reconnectTimerRef:o,setReconnectKey:h}),!0):!1}function Vg({cleanupAction:e,shellSocket:r,attachRetryTimerRef:n,attachTimeoutRef:a,socketRef:o,intentionalDisconnectRef:s,setViewerId:l,setIsConnecting:i,settleAttachPromise:d}){s.current=e.intentionalDisconnect,e.shouldClearAttachRetry&&Ht(n),e.shouldSendDetachMessage&&e.detachMessage&&r.send(e.detachMessage),l(null),i(e.isConnecting),e.settleAttachPromise!==void 0&&d(e.settleAttachPromise),e.shouldClearAttachTimeout&&Ht(a),r.socket.close(),e.shouldClearSocketRef&&(o.current=null)}function Kg({eventShellId:e,shellId:r,socketExists:n,isCurrentSocket:a}){return n&&!a?!1:e===r}function qg(e){return Tl({...e,attachSize:void 0})}function Xg({attachSize:e,...r}){return Tl({...r,attachSize:e})}function Yg({isCurrentSocket:e,shellId:r,attachSize:n,hasAttachTimeout:a}){const o=kg({isCurrentSocket:e,shellId:r,attachSize:n});return{openAction:o,shouldClearAttachTimeout:!!(o&&a)}}function Zg(e){const r=String(e.payload.viewerId??"");return{viewerId:r||null,settleAttachPromise:!!r,nextShell:n=>({...n,status:"attached",attachedViewerId:r})}}function Jg({event:e,shellCwd:r,currentSnapshot:n,pendingCommand:a}){const o=zg(e.payload,r),s=o.data?Pg({currentSnapshot:n,data:o.data,replace:o.replace,isCommandRunning:o.isCommandRunning,pendingCommand:a}):null;return{output:o,snapshotUpdate:s}}function Qg({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:o,hasAttachTimeout:s}){const l=yg({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 ex(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 tx(e){return e.current}function rx({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:v,lastCommandOutputRef:x,snapshotCursorRef:j,syncTerminalSizeRef:w,setReconnectKey:y,setViewerId:k,setIsConnecting:S,setConnectionError:N,setRuntimePromptLabel:L,setIsCommandRunning:R,settleAttachPromise:P,onShellUpdate:J}){const D=e==null?void 0:e.id,Y=e==null?void 0:e.cwd;c.useEffect(()=>{const Z=s.current,I={shellId:D??null,terminalReady:a,isVisible:f.current,canAttachShell:n,userDisconnectedShellId:g.current,hasTerminal:!!Z,hasPendingAttachRetry:m.current!==null,hasCurrentSocketForShell:!!(l.current&&d.current===D),hasReconnectTimer:h.current!==null};if(qg(I).type==="skip")return;const oe=w.current(),$=Xg({...I,attachSize:oe});if($.type==="skip"||$.type==="measureSize")return;if($.type==="scheduleRetry"){Gg({attachRetryTimerRef:m,setReconnectKey:y});return}if($.shouldClearAttachRetry&&Ht(m),$.type==="reuseSocket"||($.shouldClearReconnectTimer&&Ht(h),!D||!Z))return;const Q=$.attachSize;d.current=D,Z.reset(),N(null),k(null),S(!0),p.current=!1;const _=r.connectSocket({onConnected:()=>{var K;const ee=u.current,W=Yg({isCurrentSocket:((K=l.current)==null?void 0:K.socket)===_.socket,shellId:D,attachSize:Q,hasAttachTimeout:ee!==null}),T=W.openAction;T&&(_.send(T.message),W.shouldClearAttachTimeout&&ee!==null&&Ht(u),T.shouldScheduleAttachTimeout&&Hg({shellSocket:_,socketRef:l,viewerIdRef:i,attachTimeoutRef:u,setConnectionError:N,setIsConnecting:S,settleAttachPromise:P}))},onShellEvent:ee=>{var K;if(!Kg({eventShellId:ee.shellId,shellId:D,socketExists:!!_.socket,isCurrentSocket:((K=l.current)==null?void 0:K.socket)===_.socket}))return;if(ee.type==="shell.connected"){Ht(u);const G=Zg(ee);k(G.viewerId),S(!1),P(G.settleAttachPromise),J(D,G.nextShell,"attached");return}if(ee.type==="shell.output"){const{output:G,snapshotUpdate:E}=Jg({event:ee,shellCwd:Y,currentSnapshot:b.current,pendingCommand:v.current});j.current={cursorX:G.cursorX,cursorY:G.cursorY,paneHeight:G.paneHeight},L(G.promptLabel),R(G.isCommandRunning),E&&(b.current=E.nextSnapshot,v.current=E.nextPendingCommand,E.lastCommandOutput!==null&&(x.current=E.lastCommandOutput),G.replace?Ll(Z,G.data,G.cursorX,G.cursorY,G.paneHeight):Z.write(G.data));return}const T=Rg({event:ee,currentViewerId:i.current});T&&(T.viewerId!==void 0&&k(T.viewerId),T.isConnecting!==void 0&&S(T.isConnecting),T.settleAttachPromise!==void 0&&P(T.settleAttachPromise),T.isCommandRunning!==void 0&&R(T.isCommandRunning),T.connectionError!==void 0&&N(T.connectionError),T.intentionalDisconnect!==void 0&&(p.current=T.intentionalDisconnect),T.shellUpdate&&J(D,G=>ex(G,T),T.shellUpdate.status),T.closeSocket&&_.socket.close())}});return l.current=_,_.socket.addEventListener("close",()=>{var T;const ee=u.current,W=Qg({isCurrentSocket:((T=l.current)==null?void 0:T.socket)===_.socket,hadViewer:!!i.current,intentionalDisconnect:p.current,userDisconnectedShellId:g.current,shellId:D,hasAttachTimeout:ee!==null});Ug({closeApplication:W,shellId:D,attachTimeoutRef:u,socketRef:l,reconnectTimerRef:h,setViewerId:k,setIsConnecting:S,settleAttachPromise:P,onShellUpdate:J,setReconnectKey:y})}),()=>{const ee=tx(i),W=Wg({shellId:D,viewerId:ee,shellSocket:_,attachRetryTimerRef:m,attachTimeoutRef:u,socketRef:l,openReadyState:WebSocket.OPEN});Vg({cleanupAction:W,shellSocket:_,attachRetryTimerRef:m,attachTimeoutRef:u,socketRef:l,intentionalDisconnectRef:p,setViewerId:k,setIsConnecting:S,settleAttachPromise:P})}},[m,u,n,p,f,x,J,v,o,h,N,R,S,y,L,k,P,Y,D,r,d,b,j,l,w,a,s,g,i])}function Pn(e){return e.current}var Fs=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),v=c.useRef(null),x=c.useRef(null),j=c.useRef(null),w=c.useRef(null),y=c.useRef(null),k=c.useRef(null),S=c.useRef(!1),N=c.useRef(null),L=c.useRef(""),R=c.useRef(null),P=c.useRef(""),J=c.useRef(null),D=c.useRef(null),Y=c.useRef({cursorX:void 0,cursorY:void 0,paneHeight:void 0}),Z=c.useRef(!1),I=c.useRef(null),re=c.useRef(o),oe=c.useRef(s),$=c.useRef(()=>!1),Q=c.useRef(()=>null),_=c.useRef(()=>{}),ee=c.useRef(Mg({clearTimeout:window.clearTimeout})),[W,T]=c.useState(null),[K,G]=c.useState(!1),[E,C]=c.useState(null),[U,H]=c.useState(!1),[se,q]=c.useState(null),[de,te]=c.useState(null),[be,ie]=c.useState(!1),[ye,Ae]=c.useState(0),ce=(n==null?void 0:n.status)??"not_created",Ce=Ag({shell:n,workspacePathMissing:i}),Le=c.useMemo(()=>fa(dn(n==null?void 0:n.cwd),null),[n==null?void 0:n.cwd]),X=de??Le,ue=c.useCallback(F=>{x.current=F,C(F)},[]),ve=c.useCallback(F=>{ee.current.settle(F)},[]);c.useEffect(()=>{re.current=o},[o]),c.useEffect(()=>{oe.current=s},[s]),c.useEffect(()=>{j.current=(n==null?void 0:n.id)??null},[n==null?void 0:n.id]);const ke=c.useCallback(F=>{const le=v.current,we=j.current,z=x.current;return!le||!we||!z?!1:(le.send({type:"shell.input",shellId:we,viewerId:z,data:F}),!0)},[]);c.useEffect(()=>{$.current=ke},[ke]);const _e=c.useCallback(()=>{const F=v.current,le=j.current,we=x.current;return!F||!le||!we?!1:(F.send({type:"shell.clear",shellId:le,viewerId:we}),!0)},[]),He=c.useCallback(()=>{if(!o||!W)return!1;const F=W.getBoundingClientRect();return F.width>0&&F.height>0},[o,W]),$e=c.useCallback(F=>{const le=g.current,we=b.current;if(!le||!we||!He()||(we.fit(),le.cols<=0||le.rows<=0))return null;const z={cols:le.cols,rows:le.rows},O=Ig({size:z,previousSize:D.current,shellId:j.current,viewerId:x.current,syncBackendSize:(F==null?void 0:F.syncBackendSize)!==!1});return(F==null?void 0:F.syncBackendSize)===!1||(D.current=O.nextLastSentSize,!O.message)||v.current&&v.current.send(O.message),z},[He]);c.useEffect(()=>{Q.current=$e},[$e]);const Ie=c.useCallback(F=>{const le=g.current;!le||!He()||($e((F==null?void 0:F.syncBackendSize)===void 0?void 0:{syncBackendSize:F.syncBackendSize}),L.current&&!Bs(W)?Ll(le,L.current,Y.current.cursorX,Y.current.cursorY,Y.current.paneHeight):le.scrollToBottom(),F!=null&&F.focus&&!s&&le.focus())},[s,He,$e,W]);return c.useEffect(()=>{_.current=()=>Ie()},[Ie]),c.useEffect(()=>{m({status:E?"attached":ce,shellInputEnabled:!!(E&&n),isConnecting:U,isCommandRunning:be,promptLabel:X,error:se,hasShell:!!n})},[se,U,be,m,X,n,ce,E]),c.useEffect(()=>{if(!W||g.current||Z.current)return;let F=!1;return Z.current=!0,(async()=>{const[{Terminal:le},{FitAddon:we}]=await Promise.all([Xe(()=>import("./terminal-vendor-C5bTa-Ka.js").then(ne=>ne.x),__vite__mapDeps([6,2,7])),Xe(()=>import("./terminal-vendor-C5bTa-Ka.js").then(ne=>ne.a),__vite__mapDeps([6,2,7]))]);if(F||!W){Z.current=!1;return}const z=new le({cursorBlink:!0,disableStdin:oe.current,fontFamily:"IBM Plex Mono, SFMono-Regular, Menlo, monospace",fontSize:13,lineHeight:1.25,scrollback:3e3,theme:_s(l)}),O=new we;z.loadAddon(O),z.open(W),g.current=z,b.current=O,Q.current(),z.attachCustomKeyEventHandler(ne=>{if(oe.current||ne.type!=="keydown")return!0;if(ne.ctrlKey&&!ne.altKey&&!ne.metaKey&&!ne.shiftKey){const ge=lg(ne.key);if(!ge)return!0;if($.current(ge))return ne.preventDefault(),!1}return!0}),G(!0),Z.current=!1,J.current=new ResizeObserver(()=>{_.current()}),J.current.observe(W),I.current=z.onData(ne=>{oe.current||$.current(ne)})})(),()=>{var le,we,z;F=!0,Z.current=!1,(le=I.current)==null||le.dispose(),I.current=null,(we=J.current)==null||we.disconnect(),J.current=null,G(!1),(z=g.current)==null||z.dispose(),g.current=null,b.current=null,D.current=null}},[l,W]),c.useEffect(()=>{var le;const F=Sg({hasShell:!!n});F&&(ue(F.viewerId),H(F.isConnecting),ve(F.settleAttachPromise),q(F.connectionError),te(F.runtimePromptLabel),ie(F.isCommandRunning),L.current=F.shellSnapshot,P.current=F.lastCommandOutput,R.current=F.pendingCommand,F.shouldResetTerminal&&((le=g.current)==null||le.reset()))},[ue,ve,n]),c.useEffect(()=>{const F=g.current;F&&(F.options.theme=_s(l))},[l]),c.useEffect(()=>{const F=g.current;F&&(F.options.disableStdin=s)},[s]),c.useEffect(()=>{if(!o||!K)return;const F=window.requestAnimationFrame(()=>{Ie({focus:a,syncBackendSize:!1}),!v.current&&(n!=null&&n.id)&&N.current!==n.id&&Ae(le=>le+1)});return()=>{window.cancelAnimationFrame(F)}},[a,o,Ie,n==null?void 0:n.id,K]),rx({shell:n,shellAdapter:d,canAttachShell:Ce,terminalReady:K,reconnectKey:ye,terminalRef:g,socketRef:v,viewerIdRef:x,shellIdRef:j,reconnectTimerRef:w,attachTimeoutRef:y,attachRetryTimerRef:k,isVisibleRef:re,intentionalDisconnectRef:S,userDisconnectedShellIdRef:N,shellSnapshotRef:L,pendingCommandRef:R,lastCommandOutputRef:P,snapshotCursorRef:Y,syncTerminalSizeRef:Q,setReconnectKey:Ae,setViewerId:ue,setIsConnecting:H,setConnectionError:q,setRuntimePromptLabel:te,setIsCommandRunning:ie,settleAttachPromise:ve,onShellUpdate:u}),c.useEffect(()=>()=>{const F=Pn(w),le=Pn(y),we=Pn(k),z=Tg({hasReconnectTimer:F!==null,hasAttachTimeout:le!==null,hasAttachRetry:we!==null});z.shouldClearReconnectTimer&&F!==null&&window.clearTimeout(F),z.shouldClearAttachTimeout&&le!==null&&window.clearTimeout(le),z.shouldClearAttachRetry&&we!==null&&window.clearTimeout(we),ve(z.settleAttachPromise)},[ve]),c.useImperativeHandle(p,()=>({disconnect(){const F=v.current,le=j.current,we=x.current,z=Eg({shellId:le,viewerId:we,hasSocket:!!F});N.current=z.userDisconnectedShellId,S.current=z.intentionalDisconnect,F&&z.detachMessage&&F.send(z.detachMessage),ue(null),H(!1),ve(!1),z.shouldCloseSocket&&(F==null||F.socket.close()),v.current=null,D.current=null,z.shouldDetachShell&&le&&u(le,O=>({...O,status:"detached",attachedViewerId:null}),"detached")},reconnect(){const F=Ng({hasShellId:!!j.current,terminalReady:K,workspacePathMissing:i,hasViewer:!!x.current,hasPendingAttach:ee.current.hasPending()});if(F.type==="reject")return Promise.resolve(!1);if(F.type==="alreadyConnected")return Promise.resolve(!0);if(F.type==="joinPending")return ee.current.joinPending();const le=ee.current.start({timeoutMs:xg,setTimeout:window.setTimeout,onTimeout:()=>{H(!1)}}),we=Cg({shellId:j.current,userDisconnectedShellId:N.current});return we.shouldClearUserDisconnectedShellId&&(N.current=null),S.current=we.intentionalDisconnect,q(we.connectionError),H(we.isConnecting),Ae(z=>z+1),le},sendInput(F){return ke(F)},sendCommand(F){const le={command:F,beforeSnapshot:L.current};if(R.current=le,F.trim()==="clear"){const O=_e();return!O&&R.current===le&&(R.current=null),O}const we=F.endsWith(`
|
|
3674
|
+
`);if(n!==void 0&&a!==void 0){const u=(o!==void 0?Math.max(0,l.length-o):0)+a,m=Math.max(0,l.length-u-1);m>0&&(d+=`\x1B[${m}A`),d+=`\r\x1B[${n+1}G`}e.reset(),e.write(d,()=>{e.scrollToBottom()})}function $s(e){return e?Array.from(e.querySelectorAll(".xterm-rows > div")).map(n=>n.textContent??"").filter((n,a,o)=>n.length>0||a<o.length-1).join(`
|
|
3675
|
+
`).trimEnd():""}function Rg({clearTimeout:e}){let r=null;const n=o=>{(o==null?void 0:o.timer)!==null&&(o==null?void 0:o.timer)!==void 0&&e(o.timer)};return{hasPending:()=>!!r,joinPending:()=>new Promise(o=>{r==null||r.waiters.push(o)}),start:({timeoutMs:o,setTimeout:s,onTimeout:l})=>new Promise(i=>{const d=s(()=>{r=null,l(),i(!1)},o);r={waiters:[i],timer:d}}),settle:o=>{const s=r;if(s){r=null,n(s);for(const l of s.waiters)l(o)}},clear:()=>{const o=r;r=null,n(o)}}}var Ds={status:"not_created",shellInputEnabled:!1,isConnecting:!1,isCommandRunning:!1,promptLabel:null,error:null,hasShell:!1};function gt(e){return e.status!=="exited"&&e.status!=="not_found"}function Mg({shell:e,workspacePathMissing:r}){return!!(e&&!r&>(e))}function Ag(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 _g(e){return(e.activeShellId?e.shells.find(r=>r.id===e.activeShellId&>(r)):null)??(e.shell&>(e.shell)?e.shell:null)??e.shells.find(gt)??null}function $g({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&&!gt(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&&!gt(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 Dg({activeRuntime:e,activeShell:r,connectionButtonDisabled:n,connectionButtonLabel:a,isMobileShell:o,busy:s,loading:l,error:i}){return{status:e.status,connectionButtonDisabled:n,connectionButtonLabel:a,shellInputEnabled:e.shellInputEnabled,isConnecting:e.isConnecting,isCommandRunning:e.isCommandRunning,promptLabel:e.promptLabel??(r?ma(ln(r.cwd),null):null),isMobileShell:o,hasShell:!!r,busy:s,loading:l,error:e.error??i}}function Ht(e){return e.current===null?!1:(window.clearTimeout(e.current),e.current=null,!0)}function Bg({attachRetryTimerRef:e,setReconnectKey:r,delayMs:n=mg}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function Gg({reconnectTimerRef:e,setReconnectKey:r,delayMs:n=pg}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function Fg({shellSocket:e,socketRef:r,viewerIdRef:n,attachTimeoutRef:a,setConnectionError:o,setIsConnecting:s,settleAttachPromise:l,delayMs:i=fg}){a.current=window.setTimeout(()=>{var h,u,m;a.current=null;const d=bg({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 Hg(e){return{...e,status:e.status==="attached"?"detached":e.status,attachedViewerId:null}}function Og({shellId:e,viewerId:r,shellSocket:n,attachRetryTimerRef:a,attachTimeoutRef:o,socketRef:s,openReadyState:l}){var i;return Eg({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 Wg({closeApplication:e,shellId:r,attachTimeoutRef:n,socketRef:a,reconnectTimerRef:o,setViewerId:s,setIsConnecting:l,settleAttachPromise:i,onShellUpdate:d,setReconnectKey:h}){const u=e.closeAction;return u?(e.shouldClearAttachTimeout&&Ht(n),e.shouldClearSocketRef&&(a.current=null),s(e.viewerId),l(e.isConnecting),i(e.settleAttachPromise),u.shouldDetachShell&&d(r,Hg,"detached"),u.shouldScheduleReconnect&&Gg({reconnectTimerRef:o,setReconnectKey:h}),!0):!1}function Ug({cleanupAction:e,shellSocket:r,attachRetryTimerRef:n,attachTimeoutRef:a,socketRef:o,intentionalDisconnectRef:s,setViewerId:l,setIsConnecting:i,settleAttachPromise:d}){s.current=e.intentionalDisconnect,e.shouldClearAttachRetry&&Ht(n),e.shouldSendDetachMessage&&e.detachMessage&&r.send(e.detachMessage),l(null),i(e.isConnecting),e.settleAttachPromise!==void 0&&d(e.settleAttachPromise),e.shouldClearAttachTimeout&&Ht(a),r.socket.close(),e.shouldClearSocketRef&&(o.current=null)}function Vg({eventShellId:e,shellId:r,socketExists:n,isCurrentSocket:a}){return n&&!a?!1:e===r}function Kg(e){return Sl({...e,attachSize:void 0})}function qg({attachSize:e,...r}){return Sl({...r,attachSize:e})}function Xg({isCurrentSocket:e,shellId:r,attachSize:n,hasAttachTimeout:a}){const o=vg({isCurrentSocket:e,shellId:r,attachSize:n});return{openAction:o,shouldClearAttachTimeout:!!(o&&a)}}function Yg(e){const r=String(e.payload.viewerId??"");return{viewerId:r||null,settleAttachPromise:!!r,nextShell:n=>({...n,status:"attached",attachedViewerId:r})}}function Zg({event:e,shellCwd:r,currentSnapshot:n,pendingCommand:a}){const o=Ig(e.payload,r),s=o.data?zg({currentSnapshot:n,data:o.data,replace:o.replace,isCommandRunning:o.isCommandRunning,pendingCommand:a}):null;return{output:o,snapshotUpdate:s}}function Jg({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:o,hasAttachTimeout:s}){const l=wg({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 Qg(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 ex(e){return e.current}function tx({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:k,lastCommandOutputRef:x,snapshotCursorRef:j,syncTerminalSizeRef:w,setReconnectKey:y,setViewerId:v,setIsConnecting:S,setConnectionError:N,setRuntimePromptLabel:I,setIsCommandRunning:M,settleAttachPromise:R,onShellUpdate:Q}){const $=e==null?void 0:e.id,Y=e==null?void 0:e.cwd;c.useEffect(()=>{const Z=s.current,P={shellId:$??null,terminalReady:a,isVisible:f.current,canAttachShell:n,userDisconnectedShellId:g.current,hasTerminal:!!Z,hasPendingAttachRetry:m.current!==null,hasCurrentSocketForShell:!!(l.current&&d.current===$),hasReconnectTimer:h.current!==null};if(Kg(P).type==="skip")return;const oe=w.current(),T=qg({...P,attachSize:oe});if(T.type==="skip"||T.type==="measureSize")return;if(T.type==="scheduleRetry"){Bg({attachRetryTimerRef:m,setReconnectKey:y});return}if(T.shouldClearAttachRetry&&Ht(m),T.type==="reuseSocket"||(T.shouldClearReconnectTimer&&Ht(h),!$||!Z))return;const re=T.attachSize;d.current=$,Z.reset(),N(null),v(null),S(!0),p.current=!1;const B=r.connectSocket({onConnected:()=>{var q;const J=u.current,K=Xg({isCurrentSocket:((q=l.current)==null?void 0:q.socket)===B.socket,shellId:$,attachSize:re,hasAttachTimeout:J!==null}),L=K.openAction;L&&(B.send(L.message),K.shouldClearAttachTimeout&&J!==null&&Ht(u),L.shouldScheduleAttachTimeout&&Fg({shellSocket:B,socketRef:l,viewerIdRef:i,attachTimeoutRef:u,setConnectionError:N,setIsConnecting:S,settleAttachPromise:R}))},onShellEvent:J=>{var q;if(!Vg({eventShellId:J.shellId,shellId:$,socketExists:!!B.socket,isCurrentSocket:((q=l.current)==null?void 0:q.socket)===B.socket}))return;if(J.type==="shell.connected"){Ht(u);const G=Yg(J);v(G.viewerId),S(!1),R(G.settleAttachPromise),Q($,G.nextShell,"attached");return}if(J.type==="shell.output"){const{output:G,snapshotUpdate:E}=Zg({event:J,shellCwd:Y,currentSnapshot:b.current,pendingCommand:k.current});j.current={cursorX:G.cursorX,cursorY:G.cursorY,paneHeight:G.paneHeight},I(G.promptLabel),M(G.isCommandRunning),E&&(b.current=E.nextSnapshot,k.current=E.nextPendingCommand,E.lastCommandOutput!==null&&(x.current=E.lastCommandOutput),G.replace?El(Z,G.data,G.cursorX,G.cursorY,G.paneHeight):Z.write(G.data));return}const L=Pg({event:J,currentViewerId:i.current});L&&(L.viewerId!==void 0&&v(L.viewerId),L.isConnecting!==void 0&&S(L.isConnecting),L.settleAttachPromise!==void 0&&R(L.settleAttachPromise),L.isCommandRunning!==void 0&&M(L.isCommandRunning),L.connectionError!==void 0&&N(L.connectionError),L.intentionalDisconnect!==void 0&&(p.current=L.intentionalDisconnect),L.shellUpdate&&Q($,G=>Qg(G,L),L.shellUpdate.status),L.closeSocket&&B.socket.close())}});return l.current=B,B.socket.addEventListener("close",()=>{var L;const J=u.current,K=Jg({isCurrentSocket:((L=l.current)==null?void 0:L.socket)===B.socket,hadViewer:!!i.current,intentionalDisconnect:p.current,userDisconnectedShellId:g.current,shellId:$,hasAttachTimeout:J!==null});Wg({closeApplication:K,shellId:$,attachTimeoutRef:u,socketRef:l,reconnectTimerRef:h,setViewerId:v,setIsConnecting:S,settleAttachPromise:R,onShellUpdate:Q,setReconnectKey:y})}),()=>{const J=ex(i),K=Og({shellId:$,viewerId:J,shellSocket:B,attachRetryTimerRef:m,attachTimeoutRef:u,socketRef:l,openReadyState:WebSocket.OPEN});Ug({cleanupAction:K,shellSocket:B,attachRetryTimerRef:m,attachTimeoutRef:u,socketRef:l,intentionalDisconnectRef:p,setViewerId:v,setIsConnecting:S,settleAttachPromise:R})}},[m,u,n,p,f,x,Q,k,o,h,N,M,S,y,I,v,R,Y,$,r,d,b,j,l,w,a,s,g,i])}function zn(e){return e.current}var Bs=c.forwardRef(function({paneId:r,shell:n,isActive:a,isVisible:o,isMobileShell:s,effectiveTheme:l,workspacePathMissing:i,shellAdapter:d,onActivate:h,onShellUpdate:u,onRuntimeStateChange:m,onFeedback:f},p){const g=c.useRef(null),b=c.useRef(null),k=c.useRef(null),x=c.useRef(null),j=c.useRef(null),w=c.useRef(null),y=c.useRef(null),v=c.useRef(null),S=c.useRef(!1),N=c.useRef(null),I=c.useRef(""),M=c.useRef(null),R=c.useRef(""),Q=c.useRef(null),$=c.useRef(null),Y=c.useRef({cursorX:void 0,cursorY:void 0,paneHeight:void 0}),Z=c.useRef(!1),P=c.useRef(null),te=c.useRef(o),oe=c.useRef(s),T=c.useRef(()=>!1),re=c.useRef(()=>null),B=c.useRef(()=>{}),J=c.useRef(Rg({clearTimeout:window.clearTimeout})),[K,L]=c.useState(null),[q,G]=c.useState(!1),[E,C]=c.useState(null),[W,H]=c.useState(!1),[se,V]=c.useState(null),[de,ee]=c.useState(null),[be,ie]=c.useState(!1),[ye,Ae]=c.useState(0),ce=(n==null?void 0:n.status)??"not_created",Ce=Mg({shell:n,workspacePathMissing:i}),Le=c.useMemo(()=>ma(ln(n==null?void 0:n.cwd),null),[n==null?void 0:n.cwd]),X=de??Le,ue=c.useCallback(F=>{x.current=F,C(F)},[]),ve=c.useCallback(F=>{J.current.settle(F)},[]);c.useEffect(()=>{te.current=o},[o]),c.useEffect(()=>{oe.current=s},[s]),c.useEffect(()=>{j.current=(n==null?void 0:n.id)??null},[n==null?void 0:n.id]);const ke=c.useCallback(F=>{const le=k.current,we=j.current,z=x.current;return!le||!we||!z?!1:(le.send({type:"shell.input",shellId:we,viewerId:z,data:F}),!0)},[]);c.useEffect(()=>{T.current=ke},[ke]);const $e=c.useCallback(()=>{const F=k.current,le=j.current,we=x.current;return!F||!le||!we?!1:(F.send({type:"shell.clear",shellId:le,viewerId:we}),!0)},[]),He=c.useCallback(()=>{if(!o||!K)return!1;const F=K.getBoundingClientRect();return F.width>0&&F.height>0},[o,K]),_e=c.useCallback(F=>{const le=g.current,we=b.current;if(!le||!we||!He()||(we.fit(),le.cols<=0||le.rows<=0))return null;const z={cols:le.cols,rows:le.rows},O=Lg({size:z,previousSize:$.current,shellId:j.current,viewerId:x.current,syncBackendSize:(F==null?void 0:F.syncBackendSize)!==!1});return(F==null?void 0:F.syncBackendSize)===!1||($.current=O.nextLastSentSize,!O.message)||k.current&&k.current.send(O.message),z},[He]);c.useEffect(()=>{re.current=_e},[_e]);const ze=c.useCallback(F=>{const le=g.current;!le||!He()||(_e((F==null?void 0:F.syncBackendSize)===void 0?void 0:{syncBackendSize:F.syncBackendSize}),I.current&&!$s(K)?El(le,I.current,Y.current.cursorX,Y.current.cursorY,Y.current.paneHeight):le.scrollToBottom(),F!=null&&F.focus&&!s&&le.focus())},[s,He,_e,K]);return c.useEffect(()=>{B.current=()=>ze()},[ze]),c.useEffect(()=>{m({status:E?"attached":ce,shellInputEnabled:!!(E&&n),isConnecting:W,isCommandRunning:be,promptLabel:X,error:se,hasShell:!!n})},[se,W,be,m,X,n,ce,E]),c.useEffect(()=>{if(!K||g.current||Z.current)return;let F=!1;return Z.current=!0,(async()=>{const[{Terminal:le},{FitAddon:we}]=await Promise.all([Xe(()=>import("./terminal-vendor-C5bTa-Ka.js").then(ne=>ne.x),__vite__mapDeps([6,2,7])),Xe(()=>import("./terminal-vendor-C5bTa-Ka.js").then(ne=>ne.a),__vite__mapDeps([6,2,7]))]);if(F||!K){Z.current=!1;return}const z=new le({cursorBlink:!0,disableStdin:oe.current,fontFamily:"IBM Plex Mono, SFMono-Regular, Menlo, monospace",fontSize:13,lineHeight:1.25,scrollback:3e3,theme:As(l)}),O=new we;z.loadAddon(O),z.open(K),g.current=z,b.current=O,re.current(),z.attachCustomKeyEventHandler(ne=>{if(oe.current||ne.type!=="keydown")return!0;if(ne.ctrlKey&&!ne.altKey&&!ne.metaKey&&!ne.shiftKey){const ge=og(ne.key);if(!ge)return!0;if(T.current(ge))return ne.preventDefault(),!1}return!0}),G(!0),Z.current=!1,Q.current=new ResizeObserver(()=>{B.current()}),Q.current.observe(K),P.current=z.onData(ne=>{oe.current||T.current(ne)})})(),()=>{var le,we,z;F=!0,Z.current=!1,(le=P.current)==null||le.dispose(),P.current=null,(we=Q.current)==null||we.disconnect(),Q.current=null,G(!1),(z=g.current)==null||z.dispose(),g.current=null,b.current=null,$.current=null}},[l,K]),c.useEffect(()=>{var le;const F=Cg({hasShell:!!n});F&&(ue(F.viewerId),H(F.isConnecting),ve(F.settleAttachPromise),V(F.connectionError),ee(F.runtimePromptLabel),ie(F.isCommandRunning),I.current=F.shellSnapshot,R.current=F.lastCommandOutput,M.current=F.pendingCommand,F.shouldResetTerminal&&((le=g.current)==null||le.reset()))},[ue,ve,n]),c.useEffect(()=>{const F=g.current;F&&(F.options.theme=As(l))},[l]),c.useEffect(()=>{const F=g.current;F&&(F.options.disableStdin=s)},[s]),c.useEffect(()=>{if(!o||!q)return;const F=window.requestAnimationFrame(()=>{ze({focus:a,syncBackendSize:!1}),!k.current&&(n!=null&&n.id)&&N.current!==n.id&&Ae(le=>le+1)});return()=>{window.cancelAnimationFrame(F)}},[a,o,ze,n==null?void 0:n.id,q]),tx({shell:n,shellAdapter:d,canAttachShell:Ce,terminalReady:q,reconnectKey:ye,terminalRef:g,socketRef:k,viewerIdRef:x,shellIdRef:j,reconnectTimerRef:w,attachTimeoutRef:y,attachRetryTimerRef:v,isVisibleRef:te,intentionalDisconnectRef:S,userDisconnectedShellIdRef:N,shellSnapshotRef:I,pendingCommandRef:M,lastCommandOutputRef:R,snapshotCursorRef:Y,syncTerminalSizeRef:re,setReconnectKey:Ae,setViewerId:ue,setIsConnecting:H,setConnectionError:V,setRuntimePromptLabel:ee,setIsCommandRunning:ie,settleAttachPromise:ve,onShellUpdate:u}),c.useEffect(()=>()=>{const F=zn(w),le=zn(y),we=zn(v),z=Sg({hasReconnectTimer:F!==null,hasAttachTimeout:le!==null,hasAttachRetry:we!==null});z.shouldClearReconnectTimer&&F!==null&&window.clearTimeout(F),z.shouldClearAttachTimeout&&le!==null&&window.clearTimeout(le),z.shouldClearAttachRetry&&we!==null&&window.clearTimeout(we),ve(z.settleAttachPromise)},[ve]),c.useImperativeHandle(p,()=>({disconnect(){const F=k.current,le=j.current,we=x.current,z=Tg({shellId:le,viewerId:we,hasSocket:!!F});N.current=z.userDisconnectedShellId,S.current=z.intentionalDisconnect,F&&z.detachMessage&&F.send(z.detachMessage),ue(null),H(!1),ve(!1),z.shouldCloseSocket&&(F==null||F.socket.close()),k.current=null,$.current=null,z.shouldDetachShell&&le&&u(le,O=>({...O,status:"detached",attachedViewerId:null}),"detached")},reconnect(){const F=jg({hasShellId:!!j.current,terminalReady:q,workspacePathMissing:i,hasViewer:!!x.current,hasPendingAttach:J.current.hasPending()});if(F.type==="reject")return Promise.resolve(!1);if(F.type==="alreadyConnected")return Promise.resolve(!0);if(F.type==="joinPending")return J.current.joinPending();const le=J.current.start({timeoutMs:gg,setTimeout:window.setTimeout,onTimeout:()=>{H(!1)}}),we=Ng({shellId:j.current,userDisconnectedShellId:N.current});return we.shouldClearUserDisconnectedShellId&&(N.current=null),S.current=we.intentionalDisconnect,V(we.connectionError),H(we.isConnecting),Ae(z=>z+1),le},sendInput(F){return ke(F)},sendCommand(F){const le={command:F,beforeSnapshot:I.current};if(M.current=le,F.trim()==="clear"){const O=$e();return!O&&M.current===le&&(M.current=null),O}const we=F.endsWith(`
|
|
3676
3676
|
`)?F:`${F}
|
|
3677
|
-
`,z=ke(we);return!z&&R.current===le&&(R.current=null),z},sendControl(F){return F==="clear"?_e():ke(hg(F))},async copyLastCommandOutput(){const F=P.current.trim()||Bs(W);if(!F)return f==null||f("failed","Nothing to copy"),!1;try{return await navigator.clipboard.writeText(F),f==null||f("done","Copied"),!0}catch{return f==null||f("failed","Copy failed"),!1}},focus(){var F;(F=g.current)==null||F.focus()},refreshLayout(F){Ie(F)}}),[f,u,Ie,_e,ke,ue,ve,W,K,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 F;h(),(F=g.current)==null||F.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"})]})}),nx=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),v=c.useRef(!1),[x,j]=c.useState(null),[w,y]=c.useState(!0),[k,S]=c.useState(!1),[N,L]=c.useState(null),[R,P]=c.useState("primary"),[J,D]=c.useState(null),[Y,Z]=c.useState(null),[I,re]=c.useState("single"),[oe,$]=c.useState(50),[Q,_]=c.useState(null),[ee,W]=c.useState(""),[T,K]=c.useState(!1),[G,E]=c.useState(!1),[C,U]=c.useState(!1),[H,se]=c.useState({primary:Gs,secondary:Gs}),[q,de]=c.useState(null),te=(x==null?void 0:x.state)??"not_created",be=c.useMemo(()=>(x==null?void 0:x.shells)??[],[x==null?void 0:x.shells]),ie=c.useMemo(()=>be.filter(gt),[be]),ye=c.useMemo(()=>ie.find(M=>M.id===J)??null,[ie,J]),Ae=c.useMemo(()=>ie.find(M=>M.id===Y)??null,[ie,Y]),ce=R==="secondary"?Ae:ye,Ce=H[R],Le=(x==null?void 0:x.workspacePathStatus)==="missing",X=R==="secondary"?f:m,ue=Dg({activeRuntime:Ce,activeShell:ce,busy:k,loading:w,status:te,workspacePathMissing:Le}),ve=ue.disabled,ke=ue.label,_e=ue.className,He=(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",$e=c.useCallback((M,V)=>{de({tone:M,text:V}),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{de(null),p.current=null},1800)},[]),Ie=c.useCallback((M,V,xe)=>{j(je=>{var tt;if(!je)return je;const Ne=je.shells.map(Fe=>Fe.id===M?V(Fe):Fe),Ye=((tt=je.shell)==null?void 0:tt.id)===M?V(je.shell):Ne.find(Fe=>{var Ke;return Fe.id===((Ke=je.shell)==null?void 0:Ke.id)})??je.shell;return{...je,...xe?{state:xe}:{},shell:Ye,shells:Ne}})},[]),F=c.useCallback(async()=>{y(!0);try{const M=await n.fetchState(r);j(M),L(null)}catch(M){L(M instanceof Error?M.message:"Unable to load shell state.")}finally{y(!1)}},[n,r]);c.useEffect(()=>{F()},[F]),c.useEffect(()=>{const M=i==null?void 0:i(r);if(M==null){$(50);return}const V=typeof M=="number"?M:Number.parseFloat(String(M));$(Number.isFinite(V)?In(V):50)},[i,r]),c.useEffect(()=>{if(!x){D(null),Z(null);return}const M=_g(x);D(V=>V&&x.shells.some(xe=>xe.id===V&>(xe))?V:(M==null?void 0:M.id)??null),Z(V=>{if(I!=="columns")return null;if(V&&x.shells.some(je=>je.id===V&>(je)))return V;const xe=x.shells.find(je=>gt(je)&&je.id!==(M==null?void 0:M.id));return(xe==null?void 0:xe.id)??null})},[x,I]),c.useEffect(()=>{I!=="columns"&&(P("primary"),Z(null))},[I]),c.useEffect(()=>{if(I!=="columns"||Y||ie.length<2)return;const M=ie.find(V=>V.id!==(ye==null?void 0:ye.id))??null;M&&Z(M.id)},[ie,ye==null?void 0:ye.id,Y,I]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const M=window.matchMedia("(max-width: 767px), (hover: none) and (pointer: coarse)"),V=()=>{K(M.matches),M.matches||(U(!1),E(!1))};return V(),M.addEventListener("change",V),()=>{M.removeEventListener("change",V)}},[]),c.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current),b.current!==null&&window.cancelAnimationFrame(b.current)},[]);const le=c.useCallback((M,V)=>{se(xe=>{const je=xe[M];return $g(je,V)?xe:{...xe,[M]:V}})},[]),we=c.useCallback(M=>le("primary",M),[le]),z=c.useCallback(M=>le("secondary",M),[le]),O=c.useCallback(M=>{var xe;if((xe=M.label)!=null&&xe.trim())return M.label.trim();const V=be.findIndex(je=>je.id===M.id);return`Shell ${V>=0?V+1:""}`.trim()},[be]),ne=c.useCallback(M=>{var V;_(M.id),W(((V=M.label)==null?void 0:V.trim())||O(M))},[O]),ge=c.useCallback(()=>{_(null),W("")},[]),Te=c.useCallback(async()=>{if(Q){S(!0);try{const M=ee.trim(),V=await n.updateShell(Q,{label:M.length>0?M:null});j(xe=>{var je;return xe&&{...xe,state:xe.activeShellId===V.id?V.status:xe.state,shell:((je=xe.shell)==null?void 0:je.id)===V.id?V:xe.shell,shells:xe.shells.map(Ne=>Ne.id===V.id?V:Ne)}}),_(null),W(""),L(null)}catch(M){L(M instanceof Error?M.message:"Unable to rename shell.")}finally{S(!1)}}},[ee,Q,n]),Ee=c.useCallback((M,V)=>{if(M==="primary"){D(V),Z(xe=>xe===V?null:xe);return}Z(V),D(xe=>xe===V?null:xe)},[]),fe=c.useCallback(M=>{var V,xe;if(M==="primary"){(V=m.current)==null||V.disconnect(),D(null),I==="columns"&&P("secondary");return}(xe=f.current)==null||xe.disconnect(),Z(null),P("primary"),re("single")},[I]),De=c.useCallback((M,V=R)=>{const xe=I==="columns"?V:"primary";Ee(xe,M.id),I!=="columns"&&Z(null),P(xe)},[R,Ee,I]),Be=c.useCallback(async(M=R)=>{var V;if(!v.current){v.current=!0,S(!0);try{const xe=await n.createShell(r);j(xe);const je=xe.activeShellId??((V=xe.shell)==null?void 0:V.id)??null;if(je){const Ne=I==="columns"?M:"primary";Ee(Ne,je),I!=="columns"&&Z(null),P(Ne)}L(null)}catch(xe){L(xe instanceof Error?xe.message:"Unable to create shell.")}finally{v.current=!1,S(!1)}}},[R,Ee,n,I,r]);c.useEffect(()=>{!a||!x||w||k||Le||te==="creating"||ie.length>0||Be("primary")},[k,Be,a,ie.length,w,x,te,Le]);const et=c.useCallback(async(M=(ce==null?void 0:ce.id)??"")=>{if(M){S(!0);try{await n.terminateShell(M),D(V=>V===M?null:V),Z(V=>V===M?null:V),await F(),L(null)}catch(V){L(V instanceof Error?V.message:"Unable to terminate shell.")}finally{S(!1)}}},[ce==null?void 0:ce.id,F,n]),Ve=c.useCallback(async()=>{var M,V;if(!ve){if(Ce.shellInputEnabled){(M=X.current)==null||M.disconnect();return}if(!ce||ce.status==="exited"||ce.status==="not_found"){await Be(R);return}await((V=X.current)==null?void 0:V.reconnect())}},[R,X,Ce.shellInputEnabled,ce,ve,Be]),pt=c.useCallback(M=>{typeof window>"u"||d==null||d(r,In(M))},[d,r]),nt=c.useCallback(()=>{var M,V;(M=m.current)==null||M.refreshLayout({syncBackendSize:!0}),(V=f.current)==null||V.refreshLayout({syncBackendSize:!0})},[]),We=c.useCallback(M=>{var Ye,tt;if(I!=="columns")return;const V=g.current;if(!V)return;M.preventDefault(),(tt=(Ye=M.currentTarget).setPointerCapture)==null||tt.call(Ye,M.pointerId);const xe=Fe=>{const Ke=V.getBoundingClientRect();if(Ke.width<=0)return;const lt=In((Fe-Ke.left)/Ke.width*100);$(lt),b.current!==null&&window.cancelAnimationFrame(b.current),b.current=window.requestAnimationFrame(()=>{b.current=null,nt()})},je=Fe=>{xe(Fe.clientX)},Ne=Fe=>{xe(Fe.clientX);const Ke=V.getBoundingClientRect();Ke.width>0&&pt((Fe.clientX-Ke.left)/Ke.width*100),window.removeEventListener("pointermove",je),window.removeEventListener("pointerup",Ne)};window.addEventListener("pointermove",je),window.addEventListener("pointerup",Ne,{once:!0})},[pt,nt,I]),ot=c.useCallback((M,V)=>{Ee(V,M.id),P(V)},[Ee]),ht=c.useCallback(async()=>{var V;return await((V=X.current)==null?void 0:V.copyLastCommandOutput())?!0:($e("failed","Nothing to copy"),!1)},[X,$e]);c.useEffect(()=>{h==null||h(Bg({activeRuntime:Ce,activeShell:ce,connectionButtonDisabled:ve,connectionButtonLabel:ke,isMobileShell:T,busy:k,loading:w,error:N}))},[Ce,ce,k,ve,ke,N,T,w,h]),c.useImperativeHandle(u,()=>({async toggleConnection(){await Ve()},sendInput(M){var V;return((V=X.current)==null?void 0:V.sendInput(M))??!1},sendCommand(M){var V;return((V=X.current)==null?void 0:V.sendCommand(M))??!1},sendControl(M){var V;return((V=X.current)==null?void 0:V.sendControl(M))??!1},async copyLastCommandOutput(){var M;return await((M=X.current)==null?void 0:M.copyLastCommandOutput())??!1},async terminate(){await et()},focus(){var M;(M=X.current)==null||M.focus()},refreshLayout(M){var V,xe;(V=m.current)==null||V.refreshLayout(M),I==="columns"&&((xe=f.current)==null||xe.refreshLayout(M))}}),[X,Ve,et,I]);const ut=M=>t.jsx("div",{className:`rounded-md border px-2 py-1.5 text-xs ${M.id===(ce==null?void 0:ce.id)?"border-sky-300/40 bg-sky-300/12 text-sky-50":"border-stone-800 bg-stone-900/40 text-stone-300"}`,children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[Q===M.id?t.jsx("form",{className:"min-w-0 flex-1",onSubmit:V=>{V.preventDefault(),Te()},children:t.jsx("input",{value:ee,onChange:V=>W(V.currentTarget.value),onKeyDown:V=>{V.key==="Escape"&&(V.preventDefault(),ge())},autoFocus:!0,className:"w-full rounded border border-sky-300/35 bg-stone-950/70 px-2 py-1 text-xs text-stone-100 outline-none","aria-label":"Shell name"})}):t.jsxs("button",{type:"button",onClick:()=>De(M),onDoubleClick:()=>ne(M),className:"min-w-0 flex-1 text-left",title:M.tmuxSessionName,children:[t.jsx("span",{className:"block truncate",children:O(M)}),t.jsxs("span",{className:"block truncate text-[10px] text-[var(--theme-fg-muted)]",children:[Ln(M.status)," · ",dn(M.cwd)||M.cwd]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Q===M.id?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>void Te(),className:"rounded border border-sky-300/35 bg-sky-300/12 px-1.5 py-1 text-[10px] text-sky-50",title:"Save shell name",children:"Save"}),t.jsx("button",{type:"button",onClick:ge,className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200",title:"Cancel rename",children:"Cancel"})]}):t.jsx("button",{type:"button",onClick:()=>ne(M),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Rename shell",children:"Rename"}),I==="columns"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>ot(M,"primary"),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Open in left pane",children:"L"}),t.jsx("button",{type:"button",onClick:()=>ot(M,"secondary"),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Open in right pane",children:"R"})]}),t.jsx("button",{type:"button",disabled:k,onClick:()=>void et(M.id),className:"rounded border border-rose-300/35 bg-rose-300/12 px-1.5 py-1 text-[10px] text-rose-100 disabled:cursor-not-allowed disabled:opacity-50",title:"Kill shell process",children:"Kill"})]})]})},M.id);return t.jsxs("div",{className:"shell-panel flex min-h-0 flex-1 flex-col",children:[o&&t.jsxs("div",{className:"shell-header shrink-0 border-b px-3 py-3 sm:px-5",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs uppercase tracking-[0.24em] text-[var(--theme-fg-muted)]",children:"Shell"}),t.jsx("p",{className:"mt-1 truncate text-sm text-[var(--theme-fg-soft)]",children:Ce.promptLabel??(ce==null?void 0:ce.cwd)??"Create a terminal for this thread."})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("button",{type:"button","aria-label":ke,title:`${ke} (${Ln(Ce.status)})`,disabled:ve,onClick:()=>void Ve(),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(mg,{connected:Ce.shellInputEnabled})}),ce&&t.jsx("button",{type:"button",disabled:k,onClick:()=>void et(ce.id),className:"rounded-full border border-rose-300/35 bg-rose-300/12 px-3 py-2 text-sm text-rose-600 transition hover:bg-rose-300/18 dark:text-rose-100 disabled:cursor-not-allowed disabled:opacity-60",children:"Terminate"})]})]}),(N||w||Le)&&t.jsxs("div",{className:"shell-banner mt-3 rounded-2xl border px-3 py-3 text-sm",children:[w&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!w&&Le&&t.jsx("p",{className:"text-rose-600 dark:text-rose-100",children:"Workspace path is missing on this machine. Restore the path before creating a shell."}),!w&&N&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:N})]})]}),t.jsx("div",{className:"min-h-0 flex-1",children:t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("div",{className:"shell-terminal-bar flex shrink-0 items-center gap-2 border-b px-2 py-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-1",children:[t.jsx("span",{className:"min-w-0 truncate text-xs text-[var(--theme-fg-soft)]",children:ce?O(ce):"No live shell process"}),ce&&t.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.12em] text-[var(--theme-fg-muted)]",children:Ln(Ce.status)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.jsxs("span",{className:"hidden text-xs text-[var(--theme-fg-muted)] sm:inline",children:["Live ",ie.length]}),t.jsx("button",{type:"button","aria-expanded":G,"aria-label":G?"Hide shell processes":"Show shell processes",onClick:()=>E(M=>!M),className:"rounded-md border border-stone-700/80 bg-stone-900/50 px-2.5 py-1.5 text-xs text-stone-200 sm:hidden",children:"Processes"})]})]}),G&&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(ut),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:k||w||Le,onClick:()=>void Be(R),className:"inline-flex h-8 w-8 items-center justify-center rounded-md border border-sky-300/35 bg-sky-300/12 text-base leading-none text-sky-50 disabled:cursor-not-allowed disabled:opacity-50",children:"+"})})]}),te==="not_created"||Le?t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"shell-empty-state max-w-md rounded-[1.6rem] border px-6 py-8",children:[t.jsx("p",{className:"text-base font-medium text-[var(--theme-fg)]",children:"Durable thread shell"}),t.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--theme-fg-muted)]",children:"The shell runs under a supervisor-managed PTY and reconnects after browser disconnects. Create it explicitly when you want to inspect or take over the workspace."}),!Le&&t.jsx("button",{type:"button",disabled:k||w,onClick:()=>void Be("primary"),className:"mt-5 rounded-md border border-sky-300/35 bg-sky-300/12 px-3 py-2 text-sm text-sky-50 disabled:cursor-not-allowed disabled:opacity-50",children:"New Shell"})]})}):t.jsxs("div",{className:"grid h-full min-h-0 grid-cols-1 gap-2 p-2 sm:grid-cols-[minmax(0,1fr)_16rem] sm:p-3",children:[t.jsxs("div",{className:"shell-terminal-frame relative min-h-0 overflow-hidden rounded-[1.4rem] border shadow-inner",children:[!o&&(N||w||Le)&&t.jsxs("div",{className:"shell-banner absolute left-2 right-2 top-2 z-10 rounded-2xl border px-3 py-3 text-sm backdrop-blur sm:left-3 sm:right-3 sm:top-3",children:[w&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!w&&Le&&t.jsx("p",{className:"text-rose-600 dark:text-rose-100",children:"Workspace path is missing on this machine. Restore the path before creating a shell."}),!w&&N&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:N})]}),t.jsxs("div",{ref:g,className:`relative grid h-full min-h-0 ${I==="columns"?"grid-cols-1 sm:grid-cols-[var(--shell-left)_0.35rem_var(--shell-right)]":"grid-cols-1"}`,style:I==="columns"?{"--shell-left":`${oe}fr`,"--shell-right":`${100-oe}fr`}:void 0,"data-shell-split-ratio":oe,children:[t.jsx(Fs,{ref:m,paneId:"primary",shell:ye,isActive:R==="primary",isVisible:a,isMobileShell:T,effectiveTheme:l,workspacePathMissing:Le,shellAdapter:n,onActivate:()=>P("primary"),onShellUpdate:Ie,onRuntimeStateChange:we,onFeedback:$e}),I==="columns"&&t.jsx("button",{type:"button",onClick:()=>fe("primary"),className:"absolute left-2 top-2 z-10 rounded-md border border-stone-700/80 bg-stone-950/70 px-2 py-1 text-[10px] text-stone-200 hover:border-rose-300/40",title:"Close left pane",children:"Close"}),I==="columns"&&t.jsx("button",{type:"button","aria-label":"Resize shell panes",title:"Resize shell panes",onPointerDown:We,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"}),I==="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(Fs,{ref:f,paneId:"secondary",shell:Ae,isActive:R==="secondary",isVisible:a,isMobileShell:T,effectiveTheme:l,workspacePathMissing:Le,shellAdapter:n,onActivate:()=>P("secondary"),onShellUpdate:Ie,onRuntimeStateChange:z,onFeedback:$e}),t.jsx("button",{type:"button",onClick:()=>fe("secondary"),className:"absolute left-2 top-2 z-10 rounded-md border border-stone-700/80 bg-stone-950/70 px-2 py-1 text-[10px] text-stone-200 hover:border-rose-300/40",title:"Close right pane",children:"Close"})]})]}),s&&T&&t.jsxs("div",{className:"pointer-events-none absolute bottom-3 right-3 z-20 flex flex-col items-end gap-2",children:[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 ${He}`,children:q.text}),C&&t.jsx("div",{className:"shell-toolbox pointer-events-auto rounded-[1.2rem] border p-2 shadow-2xl backdrop-blur",children:t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx("button",{type:"button",onClick:()=>{$e("idle","Use the prompt box tools to paste")},className:"inline-flex items-center justify-center rounded-full border border-sky-300/35 bg-sky-300/12 px-2.5 py-2 text-sky-600 dark:text-sky-50",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Ds,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:()=>void ht(),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(Ds,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:!Ce.shellInputEnabled,onClick:()=>{var M;(M=X.current)!=null&&M.sendControl("clear")?$e("done","Cleared"):$e("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(zn,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!Ce.shellInputEnabled||!Ce.isCommandRunning,onClick:()=>{var M;(M=X.current)!=null&&M.sendInput("")?$e("done","Sent Ctrl-C"):$e("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(zn,{label:"CTRL-C",tone:"rose"})}),["ctrl_d","esc","tab","up","down"].map(M=>t.jsx("button",{type:"button",disabled:!Ce.shellInputEnabled,onClick:()=>{var V;(V=X.current)!=null&&V.sendControl(M)?$e("done",`Sent ${M.toUpperCase().replace("_","-")}`):$e("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(zn,{label:M.toUpperCase().replace("_","-"),tone:"stone"})},M))]})}),t.jsx("button",{type:"button","aria-expanded":C,"aria-label":C?"Close shell tools":"Open shell tools",onClick:()=>U(M=>!M),className:"shell-toolbox-trigger pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-2xl backdrop-blur transition",children:t.jsx(ug,{})})]})]}),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(ut),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:k||w||Le,onClick:()=>void Be(R),className:"inline-flex h-8 w-8 items-center justify-center rounded-md border border-sky-300/35 bg-sky-300/12 text-base leading-none text-sky-50 disabled:cursor-not-allowed disabled:opacity-50",children:"+"})})]})]})]})})]})}),ax=c.lazy(async()=>({default:(await Promise.resolve().then(()=>(mu(),al))).ThreadGraphWorkspacePanel}));function sx(){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 Il(e){return t.jsx(c.Suspense,{fallback:t.jsx(sx,{}),children:t.jsx(ax,{...e})})}c.memo(Il);function jx({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?Zr.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 ox(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 lx(e){switch(e){case"inProgress":return"running";case"completed":return"completed";case"interrupted":return"interrupted";case"failed":return"failed"}}function ix(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 dx(e){switch(e){case"latest-3":return 3;case"latest-10":return 10;case"latest-20":return 20;default:return null}}function cx(e){return e==="read"?"View only":"Collaborator"}function hx(e){switch(e){case"write":return"Workspace write";case"read":return"Workspace read";case"none":default:return"No workspace"}}function Nx({open:e,busy:r=!1,turnsState:n,shareAvailable:a=!1,shareUnavailableMessage:o="Relay sharing will be enabled after the relay permission model is connected.",shareState:s,initialMode:l="pdf",onCancel:i,onLoadTurns:d,onExport:h,onCreateShare:u,onRevokeShare:m,onOpenDeviceSharing:f}){var K,G,E;const p=c.useMemo(()=>{var C;return((C=n.data)==null?void 0:C.turns)??[]},[(K=n.data)==null?void 0:K.turns]),[g,b]=c.useState(l),[v,x]=c.useState("latest-10"),[j,w]=c.useState(()=>new Set),[y,k]=c.useState(!0),[S,N]=c.useState(""),[L,R]=c.useState("read"),[P,J]=c.useState("none"),[D,Y]=c.useState(""),[Z,I]=c.useState(()=>typeof document<"u"&&!document.documentElement.classList.contains("dark")?"light":"dark");if(c.useEffect(()=>{e&&(b(l),x("latest-10"),k(!0),N(""),R("read"),J("none"),Y(""),d())},[l,d,e]),c.useEffect(()=>{e&&p.length>0&&w(new Set(p.slice(0,10).map(C=>C.turnId)))},[e,p]),c.useEffect(()=>{if(!e)return;function C(U){U.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"),U=()=>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(I(U()),!C)return;const H=new MutationObserver(()=>I(U()));return H.observe(C,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>H.disconnect()},[e]),!e)return null;const re=dx(v),oe=re!==null?Math.min(re,((G=n.data)==null?void 0:G.totalTurnCount)??re):v==="all-loaded"?p.length:j.size,$=!r&&g!=="share"&&(re!==null||v==="all-loaded"||j.size>0),Q=!r&&a&&!!u&&S.trim().length>0;function _(C){w(U=>{const H=new Set(U);return H.has(C)?H.delete(C):H.add(C),H})}function ee(){if(g==="share")return;const C={format:g,...re!==null?{mode:"latest",limit:re}:v==="all-loaded"?{mode:"selected",turnIds:p.map(U=>U.turnId)}:{mode:"selected",turnIds:[...j]},profile:"review",options:{includeTokenAndPrice:y}};h(C)}function W(C){C.preventDefault(),Q&&(u==null||u({targetIdentifier:S.trim(),threadAccess:L,workspaceAccess:P,label:D.trim()||null}))}const T=[{mode:"pdf",label:"PDF"},{mode:"html",label:"HTML"},{mode:"share",label:"Share"}];return Zr.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 thread."})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:i,disabled:r,className:"thread-export-dialog-icon-button inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border transition disabled:cursor-not-allowed disabled:opacity-60",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-auto px-5 py-4",children:[t.jsx("div",{className:"thread-export-dialog-segment inline-flex rounded-full border p-1",children:T.map(C=>t.jsx("button",{type:"button",onClick:()=>b(C.mode),className:`rounded-full px-3 py-1.5 text-sm transition ${g===C.mode?"ui-status-warning":"thread-export-dialog-muted-action"}`,children:C.label},C.mode))}),g==="share"?t.jsxs("form",{id:"thread-actions-share-form",className:"mt-4 space-y-4",onSubmit:W,children:[a?null:t.jsx("p",{className:"thread-export-dialog-box thread-export-dialog-subtitle rounded-2xl border px-3 py-3 text-sm",children:o}),a&&f?t.jsxs("div",{className:"thread-export-dialog-box flex flex-wrap items-center justify-between gap-3 rounded-2xl border px-3 py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-export-dialog-strong text-sm font-medium",children:"Share this thread"}),t.jsx("p",{className:"thread-export-dialog-subtitle mt-1 text-xs",children:"Need broader access? Share the whole device from Relay Portal."})]}),t.jsx("button",{type:"button",className:"thread-export-dialog-secondary-button rounded-full border px-3 py-1.5 text-xs font-medium transition",disabled:r,onClick:f,children:"Share whole device"})]}):null,t.jsxs("label",{className:"thread-export-dialog-body-text block text-sm",children:["Relay identifier",t.jsx("input",{className:"thread-export-dialog-box mt-2 w-full rounded-xl border bg-transparent px-3 py-2 outline-none",disabled:!a||r,onChange:C=>N(C.target.value),placeholder:"username or email",value:S})]}),t.jsxs("fieldset",{className:"thread-export-dialog-box rounded-2xl border p-3",children:[t.jsx("legend",{className:"thread-export-dialog-subtitle px-1 text-xs",children:"Thread access"}),t.jsx("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[["read","View only"],["control","Collaborator"]].map(([C,U])=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex items-center gap-2 rounded-xl px-2.5 py-2 text-sm",children:[t.jsx("input",{type:"radio",checked:L===C,disabled:!a||r,onChange:()=>R(C)}),U]},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,U])=>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:()=>J(C)}),U]},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=>Y(C.target.value),placeholder:"optional",value:D})]}),t.jsxs("div",{className:"thread-export-dialog-box rounded-2xl border",children:[t.jsxs("div",{className:"thread-export-dialog-box-header flex items-center justify-between border-b px-3 py-2.5",children:[t.jsx("p",{className:"thread-export-dialog-strong text-sm font-medium",children:"Shared by me"}),t.jsx("span",{className:"thread-export-dialog-status-pill rounded-full border px-2 py-0.5 text-[10px]",children:(s==null?void 0:s.shares.length)??0})]}),(s==null?void 0:s.status)==="failed"?t.jsx("p",{className:"px-3 py-3 text-sm text-rose-500 dark:text-rose-200",children:s.error}):s!=null&&s.shares.length?t.jsx("div",{className:"divide-y",children:s.shares.map(C=>t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2.5 text-sm",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-export-dialog-strong truncate font-medium",children:C.targetUsername}),t.jsxs("p",{className:"thread-export-dialog-subtitle mt-0.5 text-xs",children:[C.label?`${C.label} · `:"",cx(C.threadAccess)," / ",hx(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:v,onChange:C=>x(C.target.value),children:["latest-3","latest-10","latest-20","all-loaded","custom"].map(C=>t.jsx("option",{value:C,children:ix(C)},C))})]}),v==="custom"?t.jsxs("div",{className:"thread-export-dialog-box mt-4 rounded-2xl border",children:[t.jsxs("div",{className:"thread-export-dialog-box-header flex flex-wrap items-center justify-between gap-2 border-b px-3 py-2.5",children:[t.jsxs("p",{className:"thread-export-dialog-subtitle text-xs",children:["Selected ",j.size," of ",((E=n.data)==null?void 0:E.totalTurnCount)??p.length]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>w(new Set(p.map(C=>C.turnId))),className:"thread-export-dialog-secondary-button rounded-full border px-2.5 py-1 text-xs transition",children:"Select all"}),t.jsx("button",{type:"button",onClick:()=>w(new Set),className:"thread-export-dialog-secondary-button rounded-full border px-2.5 py-1 text-xs transition",children:"Clear"})]})]}),n.status==="loading"?t.jsx("p",{className:"thread-export-dialog-subtitle px-3 py-6 text-sm",children:"Loading turns..."}):n.status==="failed"?t.jsx("p",{className:"px-3 py-6 text-sm text-rose-500 dark:text-rose-200",children:n.error}):t.jsx("div",{className:"max-h-80 overflow-auto p-2",children:p.map(C=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex cursor-pointer items-center gap-3 rounded-xl px-2.5 py-2 text-sm transition",children:[t.jsx("input",{type:"checkbox",checked:j.has(C.turnId),onChange:()=>_(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:ox(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:lx(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:y,onChange:C=>k(C.target.checked),className:"thread-export-dialog-checkbox h-4 w-4"}),"Token and price"]}),t.jsx("p",{className:"thread-export-dialog-box thread-export-dialog-subtitle flex items-center rounded-xl border px-3 py-2 text-xs",children:g==="html"?"HTML keeps the chat timeline styling and omits raw command output.":"Review exports keep message text readable and omit tool activity."})]})]})]}),t.jsxs("div",{className:"thread-export-dialog-footer flex items-center justify-between gap-3 border-t px-5 py-4",children:[t.jsx("p",{className:"thread-export-dialog-subtitle min-w-0 text-xs",children:g==="share"?a?"Share access is enforced by the relay server.":"Share permissions are not wired yet.":`${oe} ${oe===1?"turn":"turns"} selected.`}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:i,disabled:r,className:"thread-export-dialog-secondary-button rounded-full border px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),g==="share"?t.jsx("button",{type:"submit",form:"thread-actions-share-form",disabled:!Q,className:"ui-status-warning rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:r?"Sharing...":"Share this thread"}):t.jsx("button",{type:"button",onClick:ee,disabled:!$,className:"ui-status-warning rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:r?"Exporting...":`Export ${g.toUpperCase()}`})]})]})]})]}),document.body)}function Dr(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 ux(e){const r=`in ${Dr(e.input)} / out ${Dr(e.output)} / cache read ${Dr(e.cache)}`,n=e.cacheWrite>0?`${r} / cache write ${Dr(e.cacheWrite)}`:r;return e.pricedTurns>0?`${n} / cost ${ma(e.priceUsd)}`:n}function mx({detail:e,adapter:r,timelineAdapter:n,TimelineComponent:a=Sl,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,v]=c.useState(0),[x,j]=c.useState(0),[w,y]=c.useState(0),[k,S]=c.useState(!1),N=c.useRef(null),L=i==null?void 0:i.onTailVisibilityChange,R=e.pendingRequests.length>0,P=c.useCallback(Q=>{L==null||L(Q)},[L]);c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const Q=window.matchMedia("(max-width: 639px)"),_=()=>g(Q.matches);return _(),Q.addEventListener("change",_),()=>{Q.removeEventListener("change",_)}},[]),c.useEffect(()=>{var _,ee;if(typeof window>"u")return;const Q=()=>{const W=window.visualViewport,T=W?Math.max(0,Math.round(window.innerHeight-W.height-W.offsetTop)):0,K=W?Math.max(0,Math.round(window.innerHeight-W.height)):T,G=Math.min(T,K),E=Math.max(0,Math.round(window.innerHeight*.52));y(Math.min(G,E))};return Q(),(_=window.visualViewport)==null||_.addEventListener("resize",Q),(ee=window.visualViewport)==null||ee.addEventListener("scroll",Q),window.addEventListener("resize",Q),()=>{var W,T;(W=window.visualViewport)==null||W.removeEventListener("resize",Q),(T=window.visualViewport)==null||T.removeEventListener("scroll",Q),window.removeEventListener("resize",Q)}},[]),c.useLayoutEffect(()=>{const Q=N.current;if(!Q||!p){v(0);return}const _=()=>{v(Math.ceil(Q.getBoundingClientRect().height))};if(_(),typeof ResizeObserver>"u")return;const ee=new ResizeObserver(_);return ee.observe(Q),()=>{ee.disconnect()}},[p,l,R]),c.useLayoutEffect(()=>{var W,T;const Q=N.current;if(!Q||!p){j(0);return}const _=()=>{const K=Q.getBoundingClientRect();j(Math.max(0,Math.ceil(window.innerHeight-K.top)))};_(),window.addEventListener("resize",_),(W=window.visualViewport)==null||W.addEventListener("resize",_),(T=window.visualViewport)==null||T.addEventListener("scroll",_);let ee=null;return typeof ResizeObserver<"u"&&(ee=new ResizeObserver(_),ee.observe(Q)),()=>{var K,G;window.removeEventListener("resize",_),(K=window.visualViewport)==null||K.removeEventListener("resize",_),(G=window.visualViewport)==null||G.removeEventListener("scroll",_),ee==null||ee.disconnect()}},[p,w,k,l,R]),c.useEffect(()=>{if(!p){S(!1);return}const Q=ee=>{var T;const W=ee.target;W instanceof HTMLElement&&((T=N.current)!=null&&T.contains(W))&&S(!0)},_=ee=>{var T;const W=ee.relatedTarget;W instanceof HTMLElement&&((T=N.current)!=null&&T.contains(W))||S(!1)};return document.addEventListener("focusin",Q),document.addEventListener("focusout",_),()=>{document.removeEventListener("focusin",Q),document.removeEventListener("focusout",_)}},[p]);const J=c.useCallback(Q=>{N.current=Q,f&&(f.current=Q)},[f]),D=p&&k?Math.max(0,w-m):0,Y=Math.max(b,144),Z=Math.max(x,Y+D),I=p?Z+12:0,re=I>0?{"--thread-graph-chat-scroll-bottom-spacer":`${I}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,$=c.useMemo(()=>{const Q=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:Q,liveOutput:o,className:"thread-timeline-surface min-h-0 flex-1",...i,adapter:n,onOpenThread:(i==null?void 0:i.onOpenThread)??r.openThread,onTailVisibilityChange:P})},[a,r.openThread,e.pendingRequests,e.thread.activeTurnId,e.thread.id,e.thread.status,e.totalTurnCount,e.turns,P,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:re,children:[s,$,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?ux(d):"waiting for agent usage"]})]}),l?u?t.jsx("div",{ref:J,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(Vn,{...l,activeView:"chat",edgeToEdgeMobile:!0,onSubmit:r.sendPrompt})}):t.jsx("div",{ref:J,className:"thread-graph-composer-host shrink-0",children:t.jsx(Vn,{...l,activeView:"chat",onSubmit:r.sendPrompt})}):null]})}function px(e){return e.turns.reduce((r,n)=>{var o,s;const a=(o=n.tokenUsage)==null?void 0:o.total;return a?{input:r.input+a.inputTokens,output:r.output+a.outputTokens,cache:r.cache+a.cachedInputTokens,cacheWrite:r.cacheWrite+(a.cacheWriteInputTokens??0),priceUsd:r.priceUsd+(((s=n.priceEstimate)==null?void 0:s.totalUsd)??0),pricedTurns:r.pricedTurns+(n.priceEstimate?1:0),turns:r.turns+1}:r},{input:0,output:0,cache:0,cacheWrite:0,priceUsd:0,pricedTurns:0,turns:0})}function Br(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 fx(e){if(!e||e.turns<=0)return"waiting for agent usage";const r=`in ${Br(e.input)} / out ${Br(e.output)} / cache read ${Br(e.cache)}`,n=e.cacheWrite>0?`${r} / cache write ${Br(e.cacheWrite)}`:r;return e.pricedTurns>0?`${n} / cost ${ma(e.priceUsd)}`:n}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:v,threadActionsButton:x,surfaceActions:j,floatingPanel:w,workspaceContent:y,workspaceTitle:k,workspaceActions:S,workspaceFeatures:N,workspaceFocusPathRequest:L=null,onNewThreadTitle:R,beforeTimelineContent:P,errorContent:J,workspaceMissingContent:D,dialogs:Y,currentThreadId:Z,currentWorkspaceId:I,currentWorkspaceLabel:re,onCloseAppNavigation:oe,className:$="thread-detail-surface relative flex h-full min-h-0 flex-1 flex-col overflow-hidden",activeView:Q="chat",liveOutput:_="",timelineProps:ee,composerProps:W,shellComposerProps:T,useFloatingMobileComposer:K=!1,floatingMobileComposerBottomOffset:G=0,composerHostRef:E,shellPanelRef:C,shellEffectiveTheme:U="dark",shellThemeMode:H=U,onShellThemeModeChange:se,onShellStateChange:q,shellUnavailableContent:de,shellDisconnectedContent:te,timelineComponent:be=Sl,shellPanelComponent:ie=nx,shellContent:ye,loadingContent:Ae,emptyContent:ce}){const Ce=ha(),Le=s??Ce??da(),{getImageAssetUrl:X,loadHistoryItemDetail:ue,openWorkspaceFile:ve,openThread:ke,cancelPendingSteer:_e}=l,He=c.useMemo(()=>({...X?{getImageAssetUrl:ne=>X(ne.path)}:{},onOpenLinkedThread:ke,...ve?{onOpenWorkspaceFile:ve}:{},...ue?{onLoadHistoryItemDetail:ue}:{},..._e?{cancelPendingSteer:_e}:{}}),[_e,X,ue,ve,ke]),$e=Le.getThreadPanels().some(ne=>ne.kind==="terminal"),Ie=c.useMemo(()=>r?px(r):null,[r]),F=c.useMemo(()=>fx(Ie),[Ie]),le=c.useMemo(()=>{var ne;return r?r.turns.reduce((ge,Te)=>ge+Te.items.length,((ne=r.liveItems)==null?void 0:ne.items.length)??0):0},[r]),we=y??(r?t.jsx(Il,{detail:r,status:o,plugins:Le,workspaceAdapter:l.workspace??null,metaContent:i,settingsContent:d,activeView:Q,features:N,focusPathRequest:L}):null),z=n?Ae??t.jsx("div",{className:"flex flex-1 items-center justify-center px-6 py-12 text-center text-[var(--theme-fg-muted)]",children:"Loading thread detail..."}):r?t.jsxs("div",{className:$,children:[w?t.jsx("div",{className:"fixed right-3 top-20 z-50 lg:absolute lg:right-4 lg:top-16",children:w}):null,a&&!n&&(J??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:Q==="chat"?"flex min-h-0 flex-1 flex-col":"hidden",children:t.jsx(mx,{detail:r,adapter:l,timelineAdapter:He,TimelineComponent:be,liveOutput:_,threadUsageSummary:Ie,transcriptItemCount:le,useFloatingMobileComposer:K,floatingMobileComposerBottomOffset:G,...P?{beforeTimelineContent:P}:{},...W?{composerProps:W}:{},...ee?{timelineProps:ee}:{},...E?{composerHostRef:E}:{}})}),t.jsxs("div",{className:Q==="shell"?"flex min-h-0 flex-1 flex-col":"hidden",children:[ye??(r.thread.isLoaded&&$e&&l.shell?t.jsx(ie,{ref:C,threadId:r.thread.id,shellAdapter:l.shell,effectiveTheme:U,isVisible:Q==="shell",showHeader:!1,showFloatingToolbox:!1,...q?{onStateChange:q}:{}}):r.thread.isLoaded&&!$e?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."})]})}):te??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."})]})})),Q==="shell"&&T&&!ye?t.jsx(Vn,{...T,activeView:"shell",onSubmit:l.sendPrompt}):null]}),Y]}):ce??t.jsx("div",{className:"flex flex-1 items-center justify-center px-6 py-12 text-center text-[var(--theme-fg-muted)]",children:"Select a thread to inspect."}),O=t.jsx(pp,{threads:e,status:o,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:I??(r==null?void 0:r.thread.workspaceId),currentWorkspaceLabel:re??(r==null?void 0:r.workspace.label),sessionLabel:(r==null?void 0:r.thread.providerSessionId)??(r==null?void 0:r.thread.id),usageLabel:F,threadActionsButton:x,topbarActions:j,metaContent:i,settingsContent:d,globalSettingsContent:h,...u!==void 0?{settingsDialogOpen:u}:{},...m?{onSettingsDialogOpenChange:m}:{},mobileHeaderAction:f,effectiveTheme:U,themeMode:H,appMenuButton:p,appNavigationMenu:g,workspaceReturnHref:b,...v?{onWorkspaceReturn:v}:{},showMobileAppMenu:!!p,showMobileThreadNavToggle:!0,showMobileNewThreadShortcut:!1,onOpenThread:l.openThread,workspaceContent:we,workspaceTitle:k??"Workspace",workspaceActions:S,...R?{onNewThreadTitle:R}:{},...oe?{onCloseAppNavigation:oe}:{},...se?{onThemeModeChange:se}:{},...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:z});return s?t.jsx(ca.Provider,{value:Le,children:O}):O}var gx={},xx=[];function Sx({adapter:e=gx,builtinPlugins:r=xx,children:n}){const[a,o]=c.useState(()=>Kn(r,[])),[s,l]=c.useState(!1),[i,d]=c.useState(null),h=c.useCallback(async()=>{l(!0),d(null);try{const w=e.fetchPlugins?await e.fetchPlugins():[];o(Kn(r,w))}catch(w){d(w instanceof Error?w.message:"Unable to load plugins.")}finally{l(!1)}},[e,r]);c.useEffect(()=>{h()},[h]);const u=c.useCallback(async(w,y)=>{if(e.updatePlugin){const k=await e.updatePlugin(w,{enabled:y});o(S=>S.map(N=>N.id===k.id?k:N));return}o(k=>k.map(S=>S.id===w?{...S,enabled:y}:S))},[e]),m=c.useCallback(async w=>{if(!e.importPlugin)throw new Error("Plugin import is not available.");const y=await e.importPlugin(w);o(k=>[...k.filter(N=>N.id!==y.id),y])},[e]),f=c.useCallback(async w=>{if(!e.deletePlugin)throw new Error("Plugin uninstall is not available.");const y=await e.deletePlugin(w);o(k=>k.filter(S=>S.id!==y.id))},[e]),p=c.useMemo(()=>{const w=new Set(a.filter(y=>y.enabled).map(y=>y.id));return r.filter(y=>w.has(y.manifest.id))},[r,a]),g=c.useCallback(w=>{var k;const y=p.find(S=>S.renderArtifact&&S.manifest.capabilities.artifactTypes.some(N=>N.type===w.artifact.type));return((k=y==null?void 0:y.renderArtifact)==null?void 0:k.call(y,w))??null},[p]),b=c.useCallback(w=>{for(const y of p)for(const k of y.inlineCodeRenderers??[]){if(!k.languages.includes(w.language.trim().toLowerCase()))continue;const S=k.render(w);if(S)return S}return null},[p]),v=c.useCallback(w=>p.some(y=>!!y.renderArtifact&&y.manifest.capabilities.artifactTypes.some(k=>k.type===w.type)),[p]),x=c.useCallback(()=>p.flatMap(w=>w.threadPanels??[]),[p]),j=c.useMemo(()=>({plugins:a,loading:s,error:i,refresh:h,importPluginManifest:m,setPluginEnabled:u,uninstallPlugin:f,renderArtifact:g,renderInlineCode:b,hasRendererForArtifact:v,getThreadPanels:x}),[i,x,v,m,s,a,h,g,b,u,f]);return t.jsx(ca.Provider,{value:j,children:n})}export{Jm as A,jx as C,fp as L,Sx as P,Nx as T,ha as a,Cx as b,nx as c,Sl as d,pp as e,Wt as f,mp as g,Qm as t,dl as u};
|
|
3677
|
+
`,z=ke(we);return!z&&M.current===le&&(M.current=null),z},sendControl(F){return F==="clear"?$e():ke(cg(F))},async copyLastCommandOutput(){const F=R.current.trim()||$s(K);if(!F)return f==null||f("failed","Nothing to copy"),!1;try{return await navigator.clipboard.writeText(F),f==null||f("done","Copied"),!0}catch{return f==null||f("failed","Copy failed"),!1}},focus(){var F;(F=g.current)==null||F.focus()},refreshLayout(F){ze(F)}}),[f,u,ze,$e,ke,ue,ve,K,q,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:L,className:`h-full w-full px-2 py-2 sm:px-3 sm:py-3 ${s?"mobile-shell-selectable":""}`,onMouseDown:()=>{var F;h(),(F=g.current)==null||F.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"})]})}),rx=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),k=c.useRef(!1),[x,j]=c.useState(null),[w,y]=c.useState(!0),[v,S]=c.useState(!1),[N,I]=c.useState(null),[M,R]=c.useState("primary"),[Q,$]=c.useState(null),[Y,Z]=c.useState(null),[P,te]=c.useState("single"),[oe,T]=c.useState(50),[re,B]=c.useState(null),[J,K]=c.useState(""),[L,q]=c.useState(!1),[G,E]=c.useState(!1),[C,W]=c.useState(!1),[H,se]=c.useState({primary:Ds,secondary:Ds}),[V,de]=c.useState(null),ee=(x==null?void 0:x.state)??"not_created",be=c.useMemo(()=>(x==null?void 0:x.shells)??[],[x==null?void 0:x.shells]),ie=c.useMemo(()=>be.filter(gt),[be]),ye=c.useMemo(()=>ie.find(A=>A.id===Q)??null,[ie,Q]),Ae=c.useMemo(()=>ie.find(A=>A.id===Y)??null,[ie,Y]),ce=M==="secondary"?Ae:ye,Ce=H[M],Le=(x==null?void 0:x.workspacePathStatus)==="missing",X=M==="secondary"?f:m,ue=$g({activeRuntime:Ce,activeShell:ce,busy:v,loading:w,status:ee,workspacePathMissing:Le}),ve=ue.disabled,ke=ue.label,$e=ue.className,He=(V==null?void 0:V.tone)==="done"?"shell-floating-feedback shell-floating-feedback-done":(V==null?void 0:V.tone)==="failed"?"shell-floating-feedback shell-floating-feedback-failed":"shell-floating-feedback",_e=c.useCallback((A,U)=>{de({tone:A,text:U}),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{de(null),p.current=null},1800)},[]),ze=c.useCallback((A,U,xe)=>{j(je=>{var tt;if(!je)return je;const Ne=je.shells.map(Fe=>Fe.id===A?U(Fe):Fe),Ye=((tt=je.shell)==null?void 0:tt.id)===A?U(je.shell):Ne.find(Fe=>{var Ke;return Fe.id===((Ke=je.shell)==null?void 0:Ke.id)})??je.shell;return{...je,...xe?{state:xe}:{},shell:Ye,shells:Ne}})},[]),F=c.useCallback(async()=>{y(!0);try{const A=await n.fetchState(r);j(A),I(null)}catch(A){I(A instanceof Error?A.message:"Unable to load shell state.")}finally{y(!1)}},[n,r]);c.useEffect(()=>{F()},[F]),c.useEffect(()=>{const A=i==null?void 0:i(r);if(A==null){T(50);return}const U=typeof A=="number"?A:Number.parseFloat(String(A));T(Number.isFinite(U)?Ln(U):50)},[i,r]),c.useEffect(()=>{if(!x){$(null),Z(null);return}const A=_g(x);$(U=>U&&x.shells.some(xe=>xe.id===U&>(xe))?U:(A==null?void 0:A.id)??null),Z(U=>{if(P!=="columns")return null;if(U&&x.shells.some(je=>je.id===U&>(je)))return U;const xe=x.shells.find(je=>gt(je)&&je.id!==(A==null?void 0:A.id));return(xe==null?void 0:xe.id)??null})},[x,P]),c.useEffect(()=>{P!=="columns"&&(R("primary"),Z(null))},[P]),c.useEffect(()=>{if(P!=="columns"||Y||ie.length<2)return;const A=ie.find(U=>U.id!==(ye==null?void 0:ye.id))??null;A&&Z(A.id)},[ie,ye==null?void 0:ye.id,Y,P]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const A=window.matchMedia("(max-width: 767px), (hover: none) and (pointer: coarse)"),U=()=>{q(A.matches),A.matches||(W(!1),E(!1))};return U(),A.addEventListener("change",U),()=>{A.removeEventListener("change",U)}},[]),c.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current),b.current!==null&&window.cancelAnimationFrame(b.current)},[]);const le=c.useCallback((A,U)=>{se(xe=>{const je=xe[A];return Ag(je,U)?xe:{...xe,[A]:U}})},[]),we=c.useCallback(A=>le("primary",A),[le]),z=c.useCallback(A=>le("secondary",A),[le]),O=c.useCallback(A=>{var xe;if((xe=A.label)!=null&&xe.trim())return A.label.trim();const U=be.findIndex(je=>je.id===A.id);return`Shell ${U>=0?U+1:""}`.trim()},[be]),ne=c.useCallback(A=>{var U;B(A.id),K(((U=A.label)==null?void 0:U.trim())||O(A))},[O]),ge=c.useCallback(()=>{B(null),K("")},[]),Te=c.useCallback(async()=>{if(re){S(!0);try{const A=J.trim(),U=await n.updateShell(re,{label:A.length>0?A:null});j(xe=>{var je;return xe&&{...xe,state:xe.activeShellId===U.id?U.status:xe.state,shell:((je=xe.shell)==null?void 0:je.id)===U.id?U:xe.shell,shells:xe.shells.map(Ne=>Ne.id===U.id?U:Ne)}}),B(null),K(""),I(null)}catch(A){I(A instanceof Error?A.message:"Unable to rename shell.")}finally{S(!1)}}},[J,re,n]),Ee=c.useCallback((A,U)=>{if(A==="primary"){$(U),Z(xe=>xe===U?null:xe);return}Z(U),$(xe=>xe===U?null:xe)},[]),fe=c.useCallback(A=>{var U,xe;if(A==="primary"){(U=m.current)==null||U.disconnect(),$(null),P==="columns"&&R("secondary");return}(xe=f.current)==null||xe.disconnect(),Z(null),R("primary"),te("single")},[P]),De=c.useCallback((A,U=M)=>{const xe=P==="columns"?U:"primary";Ee(xe,A.id),P!=="columns"&&Z(null),R(xe)},[M,Ee,P]),Be=c.useCallback(async(A=M)=>{var U;if(!k.current){k.current=!0,S(!0);try{const xe=await n.createShell(r);j(xe);const je=xe.activeShellId??((U=xe.shell)==null?void 0:U.id)??null;if(je){const Ne=P==="columns"?A:"primary";Ee(Ne,je),P!=="columns"&&Z(null),R(Ne)}I(null)}catch(xe){I(xe instanceof Error?xe.message:"Unable to create shell.")}finally{k.current=!1,S(!1)}}},[M,Ee,n,P,r]);c.useEffect(()=>{!a||!x||w||v||Le||ee==="creating"||ie.length>0||Be("primary")},[v,Be,a,ie.length,w,x,ee,Le]);const et=c.useCallback(async(A=(ce==null?void 0:ce.id)??"")=>{if(A){S(!0);try{await n.terminateShell(A),$(U=>U===A?null:U),Z(U=>U===A?null:U),await F(),I(null)}catch(U){I(U instanceof Error?U.message:"Unable to terminate shell.")}finally{S(!1)}}},[ce==null?void 0:ce.id,F,n]),Ve=c.useCallback(async()=>{var A,U;if(!ve){if(Ce.shellInputEnabled){(A=X.current)==null||A.disconnect();return}if(!ce||ce.status==="exited"||ce.status==="not_found"){await Be(M);return}await((U=X.current)==null?void 0:U.reconnect())}},[M,X,Ce.shellInputEnabled,ce,ve,Be]),pt=c.useCallback(A=>{typeof window>"u"||d==null||d(r,Ln(A))},[d,r]),nt=c.useCallback(()=>{var A,U;(A=m.current)==null||A.refreshLayout({syncBackendSize:!0}),(U=f.current)==null||U.refreshLayout({syncBackendSize:!0})},[]),We=c.useCallback(A=>{var Ye,tt;if(P!=="columns")return;const U=g.current;if(!U)return;A.preventDefault(),(tt=(Ye=A.currentTarget).setPointerCapture)==null||tt.call(Ye,A.pointerId);const xe=Fe=>{const Ke=U.getBoundingClientRect();if(Ke.width<=0)return;const lt=Ln((Fe-Ke.left)/Ke.width*100);T(lt),b.current!==null&&window.cancelAnimationFrame(b.current),b.current=window.requestAnimationFrame(()=>{b.current=null,nt()})},je=Fe=>{xe(Fe.clientX)},Ne=Fe=>{xe(Fe.clientX);const Ke=U.getBoundingClientRect();Ke.width>0&&pt((Fe.clientX-Ke.left)/Ke.width*100),window.removeEventListener("pointermove",je),window.removeEventListener("pointerup",Ne)};window.addEventListener("pointermove",je),window.addEventListener("pointerup",Ne,{once:!0})},[pt,nt,P]),ot=c.useCallback((A,U)=>{Ee(U,A.id),R(U)},[Ee]),ht=c.useCallback(async()=>{var U;return await((U=X.current)==null?void 0:U.copyLastCommandOutput())?!0:(_e("failed","Nothing to copy"),!1)},[X,_e]);c.useEffect(()=>{h==null||h(Dg({activeRuntime:Ce,activeShell:ce,connectionButtonDisabled:ve,connectionButtonLabel:ke,isMobileShell:L,busy:v,loading:w,error:N}))},[Ce,ce,v,ve,ke,N,L,w,h]),c.useImperativeHandle(u,()=>({async toggleConnection(){await Ve()},sendInput(A){var U;return((U=X.current)==null?void 0:U.sendInput(A))??!1},sendCommand(A){var U;return((U=X.current)==null?void 0:U.sendCommand(A))??!1},sendControl(A){var U;return((U=X.current)==null?void 0:U.sendControl(A))??!1},async copyLastCommandOutput(){var A;return await((A=X.current)==null?void 0:A.copyLastCommandOutput())??!1},async terminate(){await et()},focus(){var A;(A=X.current)==null||A.focus()},refreshLayout(A){var U,xe;(U=m.current)==null||U.refreshLayout(A),P==="columns"&&((xe=f.current)==null||xe.refreshLayout(A))}}),[X,Ve,et,P]);const ut=A=>t.jsx("div",{className:`rounded-md border px-2 py-1.5 text-xs ${A.id===(ce==null?void 0:ce.id)?"border-sky-300/40 bg-sky-300/12 text-sky-50":"border-stone-800 bg-stone-900/40 text-stone-300"}`,children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[re===A.id?t.jsx("form",{className:"min-w-0 flex-1",onSubmit:U=>{U.preventDefault(),Te()},children:t.jsx("input",{value:J,onChange:U=>K(U.currentTarget.value),onKeyDown:U=>{U.key==="Escape"&&(U.preventDefault(),ge())},autoFocus:!0,className:"w-full rounded border border-sky-300/35 bg-stone-950/70 px-2 py-1 text-xs text-stone-100 outline-none","aria-label":"Shell name"})}):t.jsxs("button",{type:"button",onClick:()=>De(A),onDoubleClick:()=>ne(A),className:"min-w-0 flex-1 text-left",title:A.tmuxSessionName,children:[t.jsx("span",{className:"block truncate",children:O(A)}),t.jsxs("span",{className:"block truncate text-[10px] text-[var(--theme-fg-muted)]",children:[En(A.status)," · ",ln(A.cwd)||A.cwd]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[re===A.id?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>void Te(),className:"rounded border border-sky-300/35 bg-sky-300/12 px-1.5 py-1 text-[10px] text-sky-50",title:"Save shell name",children:"Save"}),t.jsx("button",{type:"button",onClick:ge,className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200",title:"Cancel rename",children:"Cancel"})]}):t.jsx("button",{type:"button",onClick:()=>ne(A),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Rename shell",children:"Rename"}),P==="columns"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>ot(A,"primary"),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Open in left pane",children:"L"}),t.jsx("button",{type:"button",onClick:()=>ot(A,"secondary"),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Open in right pane",children:"R"})]}),t.jsx("button",{type:"button",disabled:v,onClick:()=>void et(A.id),className:"rounded border border-rose-300/35 bg-rose-300/12 px-1.5 py-1 text-[10px] text-rose-100 disabled:cursor-not-allowed disabled:opacity-50",title:"Kill shell process",children:"Kill"})]})]})},A.id);return t.jsxs("div",{className:"shell-panel flex min-h-0 flex-1 flex-col",children:[o&&t.jsxs("div",{className:"shell-header shrink-0 border-b px-3 py-3 sm:px-5",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs uppercase tracking-[0.24em] text-[var(--theme-fg-muted)]",children:"Shell"}),t.jsx("p",{className:"mt-1 truncate text-sm text-[var(--theme-fg-soft)]",children:Ce.promptLabel??(ce==null?void 0:ce.cwd)??"Create a terminal for this thread."})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("button",{type:"button","aria-label":ke,title:`${ke} (${En(Ce.status)})`,disabled:ve,onClick:()=>void Ve(),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(ug,{connected:Ce.shellInputEnabled})}),ce&&t.jsx("button",{type:"button",disabled:v,onClick:()=>void et(ce.id),className:"rounded-full border border-rose-300/35 bg-rose-300/12 px-3 py-2 text-sm text-rose-600 transition hover:bg-rose-300/18 dark:text-rose-100 disabled:cursor-not-allowed disabled:opacity-60",children:"Terminate"})]})]}),(N||w||Le)&&t.jsxs("div",{className:"shell-banner mt-3 rounded-2xl border px-3 py-3 text-sm",children:[w&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!w&&Le&&t.jsx("p",{className:"text-rose-600 dark:text-rose-100",children:"Workspace path is missing on this machine. Restore the path before creating a shell."}),!w&&N&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:N})]})]}),t.jsx("div",{className:"min-h-0 flex-1",children:t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("div",{className:"shell-terminal-bar flex shrink-0 items-center gap-2 border-b px-2 py-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-1",children:[t.jsx("span",{className:"min-w-0 truncate text-xs text-[var(--theme-fg-soft)]",children:ce?O(ce):"No live shell process"}),ce&&t.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.12em] text-[var(--theme-fg-muted)]",children:En(Ce.status)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.jsxs("span",{className:"hidden text-xs text-[var(--theme-fg-muted)] sm:inline",children:["Live ",ie.length]}),t.jsx("button",{type:"button","aria-expanded":G,"aria-label":G?"Hide shell processes":"Show shell processes",onClick:()=>E(A=>!A),className:"rounded-md border border-stone-700/80 bg-stone-900/50 px-2.5 py-1.5 text-xs text-stone-200 sm:hidden",children:"Processes"})]})]}),G&&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(ut),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||w||Le,onClick:()=>void Be(M),className:"inline-flex h-8 w-8 items-center justify-center rounded-md border border-sky-300/35 bg-sky-300/12 text-base leading-none text-sky-50 disabled:cursor-not-allowed disabled:opacity-50",children:"+"})})]}),ee==="not_created"||Le?t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"shell-empty-state max-w-md rounded-[1.6rem] border px-6 py-8",children:[t.jsx("p",{className:"text-base font-medium text-[var(--theme-fg)]",children:"Durable thread shell"}),t.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--theme-fg-muted)]",children:"The shell runs under a supervisor-managed PTY and reconnects after browser disconnects. Create it explicitly when you want to inspect or take over the workspace."}),!Le&&t.jsx("button",{type:"button",disabled:v||w,onClick:()=>void Be("primary"),className:"mt-5 rounded-md border border-sky-300/35 bg-sky-300/12 px-3 py-2 text-sm text-sky-50 disabled:cursor-not-allowed disabled:opacity-50",children:"New Shell"})]})}):t.jsxs("div",{className:"grid h-full min-h-0 grid-cols-1 gap-2 p-2 sm:grid-cols-[minmax(0,1fr)_16rem] sm:p-3",children:[t.jsxs("div",{className:"shell-terminal-frame relative min-h-0 overflow-hidden rounded-[1.4rem] border shadow-inner",children:[!o&&(N||w||Le)&&t.jsxs("div",{className:"shell-banner absolute left-2 right-2 top-2 z-10 rounded-2xl border px-3 py-3 text-sm backdrop-blur sm:left-3 sm:right-3 sm:top-3",children:[w&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!w&&Le&&t.jsx("p",{className:"text-rose-600 dark:text-rose-100",children:"Workspace path is missing on this machine. Restore the path before creating a shell."}),!w&&N&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:N})]}),t.jsxs("div",{ref:g,className:`relative grid h-full min-h-0 ${P==="columns"?"grid-cols-1 sm:grid-cols-[var(--shell-left)_0.35rem_var(--shell-right)]":"grid-cols-1"}`,style:P==="columns"?{"--shell-left":`${oe}fr`,"--shell-right":`${100-oe}fr`}:void 0,"data-shell-split-ratio":oe,children:[t.jsx(Bs,{ref:m,paneId:"primary",shell:ye,isActive:M==="primary",isVisible:a,isMobileShell:L,effectiveTheme:l,workspacePathMissing:Le,shellAdapter:n,onActivate:()=>R("primary"),onShellUpdate:ze,onRuntimeStateChange:we,onFeedback:_e}),P==="columns"&&t.jsx("button",{type:"button",onClick:()=>fe("primary"),className:"absolute left-2 top-2 z-10 rounded-md border border-stone-700/80 bg-stone-950/70 px-2 py-1 text-[10px] text-stone-200 hover:border-rose-300/40",title:"Close left pane",children:"Close"}),P==="columns"&&t.jsx("button",{type:"button","aria-label":"Resize shell panes",title:"Resize shell panes",onPointerDown:We,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"}),P==="columns"&&t.jsxs("div",{className:"relative min-h-0 border-t border-stone-800/80 sm:border-l sm:border-t-0",children:[t.jsx(Bs,{ref:f,paneId:"secondary",shell:Ae,isActive:M==="secondary",isVisible:a,isMobileShell:L,effectiveTheme:l,workspacePathMissing:Le,shellAdapter:n,onActivate:()=>R("secondary"),onShellUpdate:ze,onRuntimeStateChange:z,onFeedback:_e}),t.jsx("button",{type:"button",onClick:()=>fe("secondary"),className:"absolute left-2 top-2 z-10 rounded-md border border-stone-700/80 bg-stone-950/70 px-2 py-1 text-[10px] text-stone-200 hover:border-rose-300/40",title:"Close right pane",children:"Close"})]})]}),s&&L&&t.jsxs("div",{className:"pointer-events-none absolute bottom-3 right-3 z-20 flex flex-col items-end gap-2",children:[V&&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 ${He}`,children:V.text}),C&&t.jsx("div",{className:"shell-toolbox pointer-events-auto rounded-[1.2rem] border p-2 shadow-2xl backdrop-blur",children:t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx("button",{type:"button",onClick:()=>{_e("idle","Use the prompt box tools to paste")},className:"inline-flex items-center justify-center rounded-full border border-sky-300/35 bg-sky-300/12 px-2.5 py-2 text-sky-600 dark:text-sky-50",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(_s,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:()=>void ht(),className:"shell-toolbox-copy inline-flex items-center justify-center rounded-full border px-2.5 py-2",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(_s,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:!Ce.shellInputEnabled,onClick:()=>{var A;(A=X.current)!=null&&A.sendControl("clear")?_e("done","Cleared"):_e("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(In,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!Ce.shellInputEnabled||!Ce.isCommandRunning,onClick:()=>{var A;(A=X.current)!=null&&A.sendInput("")?_e("done","Sent Ctrl-C"):_e("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(In,{label:"CTRL-C",tone:"rose"})}),["ctrl_d","esc","tab","up","down"].map(A=>t.jsx("button",{type:"button",disabled:!Ce.shellInputEnabled,onClick:()=>{var U;(U=X.current)!=null&&U.sendControl(A)?_e("done",`Sent ${A.toUpperCase().replace("_","-")}`):_e("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(In,{label:A.toUpperCase().replace("_","-"),tone:"stone"})},A))]})}),t.jsx("button",{type:"button","aria-expanded":C,"aria-label":C?"Close shell tools":"Open shell tools",onClick:()=>W(A=>!A),className:"shell-toolbox-trigger pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-2xl backdrop-blur transition",children:t.jsx(hg,{})})]})]}),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(ut),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||w||Le,onClick:()=>void Be(M),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:"+"})})]})]})]})})]})}),nx=c.lazy(async()=>({default:(await Promise.resolve().then(()=>(uu(),rl))).ThreadGraphWorkspacePanel}));function ax(){return t.jsx("div",{className:"flex h-full min-h-0 flex-1 items-center justify-center px-4 text-sm text-[var(--theme-fg-muted)]",children:"Loading workspace..."})}function Ll(e){return t.jsx(c.Suspense,{fallback:t.jsx(ax,{}),children:t.jsx(nx,{...e})})}c.memo(Ll);function wx({open:e,title:r,description:n,confirmLabel:a="Delete",busy:o=!1,onCancel:s,onConfirm:l}){return c.useEffect(()=>{if(!e)return;function i(d){d.key==="Escape"&&!o&&s()}return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[o,s,e]),e?Yr.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[95] flex items-center justify-center p-4 sm:p-6",children:[t.jsx("button",{type:"button","aria-label":"Close confirmation dialog",onClick:s,disabled:o,className:"absolute inset-0 bg-stone-950/78 backdrop-blur-sm disabled:cursor-not-allowed"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":r,className:"relative z-[1] w-full max-w-md rounded-[1.6rem] border border-stone-700 bg-stone-900 p-5 shadow-2xl shadow-stone-950/40 sm:p-6",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium text-stone-100",children:r}),t.jsx("p",{className:"mt-2 text-sm leading-6 text-stone-400",children:n})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:s,disabled:o,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-stone-700 text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsxs("div",{className:"mt-5 flex items-center justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:s,disabled:o,className:"rounded-full border border-stone-700 px-4 py-2 text-sm font-medium text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),t.jsx("button",{type:"button",onClick:()=>void l(),disabled:o,className:"ui-action-danger rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:o?"Deleting...":a})]})]})]}),document.body):null}function sx(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 ox(e){switch(e){case"inProgress":return"running";case"completed":return"completed";case"interrupted":return"interrupted";case"failed":return"failed"}}function lx(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 ix(e){switch(e){case"latest-3":return 3;case"latest-10":return 10;case"latest-20":return 20;default:return null}}function dx(e){return e==="read"?"View only":"Collaborator"}function cx(e){switch(e){case"write":return"Workspace write";case"read":return"Workspace read";case"none":default:return"No workspace"}}function yx({open:e,busy:r=!1,turnsState:n,shareAvailable:a=!1,shareUnavailableMessage:o="Relay sharing will be enabled after the relay permission model is connected.",shareState:s,initialMode:l="pdf",onCancel:i,onLoadTurns:d,onExport:h,onCreateShare:u,onRevokeShare:m,onOpenDeviceSharing:f}){var q,G,E;const p=c.useMemo(()=>{var C;return((C=n.data)==null?void 0:C.turns)??[]},[(q=n.data)==null?void 0:q.turns]),[g,b]=c.useState(l),[k,x]=c.useState("latest-10"),[j,w]=c.useState(()=>new Set),[y,v]=c.useState(!0),[S,N]=c.useState(""),[I,M]=c.useState("read"),[R,Q]=c.useState("none"),[$,Y]=c.useState(""),[Z,P]=c.useState(()=>typeof document<"u"&&!document.documentElement.classList.contains("dark")?"light":"dark");if(c.useEffect(()=>{e&&(b(l),x("latest-10"),v(!0),N(""),M("read"),Q("none"),Y(""),d())},[l,d,e]),c.useEffect(()=>{e&&p.length>0&&w(new Set(p.slice(0,10).map(C=>C.turnId)))},[e,p]),c.useEffect(()=>{if(!e)return;function C(W){W.key==="Escape"&&!r&&i()}return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[r,i,e]),c.useEffect(()=>{if(!e)return;const C=document.querySelector(".thread-ui-shell"),W=()=>C?C.getAttribute("data-theme-effective")==="dark"||C.classList.contains("dark")||C.classList.contains("thread-ui-theme-dark")?"dark":"light":document.documentElement.classList.contains("dark")?"dark":"light";if(P(W()),!C)return;const H=new MutationObserver(()=>P(W()));return H.observe(C,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>H.disconnect()},[e]),!e)return null;const te=ix(k),oe=te!==null?Math.min(te,((G=n.data)==null?void 0:G.totalTurnCount)??te):k==="all-loaded"?p.length:j.size,T=!r&&g!=="share"&&(te!==null||k==="all-loaded"||j.size>0),re=!r&&a&&!!u&&S.trim().length>0;function B(C){w(W=>{const H=new Set(W);return H.has(C)?H.delete(C):H.add(C),H})}function J(){if(g==="share")return;const C={format:g,...te!==null?{mode:"latest",limit:te}:k==="all-loaded"?{mode:"selected",turnIds:p.map(W=>W.turnId)}:{mode:"selected",turnIds:[...j]},profile:"review",options:{includeTokenAndPrice:y}};h(C)}function K(C){C.preventDefault(),re&&(u==null||u({targetIdentifier:S.trim(),threadAccess:I,workspaceAccess:R,label:$.trim()||null}))}const L=[{mode:"pdf",label:"PDF"},{mode:"html",label:"HTML"},{mode:"share",label:"Share"}];return Yr.createPortal(t.jsxs("div",{className:`thread-export-dialog-root thread-ui-theme-${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 thread."})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:i,disabled:r,className:"thread-export-dialog-icon-button inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border transition disabled:cursor-not-allowed disabled:opacity-60",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-auto px-5 py-4",children:[t.jsx("div",{className:"thread-export-dialog-segment inline-flex rounded-full border p-1",children:L.map(C=>t.jsx("button",{type:"button",onClick:()=>b(C.mode),className:`rounded-full px-3 py-1.5 text-sm transition ${g===C.mode?"ui-status-warning":"thread-export-dialog-muted-action"}`,children:C.label},C.mode))}),g==="share"?t.jsxs("form",{id:"thread-actions-share-form",className:"mt-4 space-y-4",onSubmit:K,children:[a?null:t.jsx("p",{className:"thread-export-dialog-box thread-export-dialog-subtitle rounded-2xl border px-3 py-3 text-sm",children:o}),a&&f?t.jsxs("div",{className:"thread-export-dialog-box flex flex-wrap items-center justify-between gap-3 rounded-2xl border px-3 py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-export-dialog-strong text-sm font-medium",children:"Share this thread"}),t.jsx("p",{className:"thread-export-dialog-subtitle mt-1 text-xs",children:"Need broader access? Share the whole device from Relay Portal."})]}),t.jsx("button",{type:"button",className:"thread-export-dialog-secondary-button rounded-full border px-3 py-1.5 text-xs font-medium transition",disabled:r,onClick:f,children:"Share whole device"})]}):null,t.jsxs("label",{className:"thread-export-dialog-body-text block text-sm",children:["Relay identifier",t.jsx("input",{className:"thread-export-dialog-box mt-2 w-full rounded-xl border bg-transparent px-3 py-2 outline-none",disabled:!a||r,onChange:C=>N(C.target.value),placeholder:"username or email",value:S})]}),t.jsxs("fieldset",{className:"thread-export-dialog-box rounded-2xl border p-3",children:[t.jsx("legend",{className:"thread-export-dialog-subtitle px-1 text-xs",children:"Thread access"}),t.jsx("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[["read","View only"],["control","Collaborator"]].map(([C,W])=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex items-center gap-2 rounded-xl px-2.5 py-2 text-sm",children:[t.jsx("input",{type:"radio",checked:I===C,disabled:!a||r,onChange:()=>M(C)}),W]},C))})]}),t.jsxs("fieldset",{className:"thread-export-dialog-box rounded-2xl border p-3",children:[t.jsx("legend",{className:"thread-export-dialog-subtitle px-1 text-xs",children:"Workspace"}),t.jsx("div",{className:"mt-2 grid gap-2 sm:grid-cols-3",children:[["none","No access"],["read","Read files"],["write","Read and edit"]].map(([C,W])=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex items-center gap-2 rounded-xl px-2.5 py-2 text-sm",children:[t.jsx("input",{type:"radio",checked:R===C,disabled:!a||r,onChange:()=>Q(C)}),W]},C))})]}),t.jsxs("label",{className:"thread-export-dialog-body-text block text-sm",children:["Label",t.jsx("input",{className:"thread-export-dialog-box mt-2 w-full rounded-xl border bg-transparent px-3 py-2 outline-none",disabled:!a||r,onChange:C=>Y(C.target.value),placeholder:"optional",value:$})]}),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} · `:"",dx(C.threadAccess)," / ",cx(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:k,onChange:C=>x(C.target.value),children:["latest-3","latest-10","latest-20","all-loaded","custom"].map(C=>t.jsx("option",{value:C,children:lx(C)},C))})]}),k==="custom"?t.jsxs("div",{className:"thread-export-dialog-box mt-4 rounded-2xl border",children:[t.jsxs("div",{className:"thread-export-dialog-box-header flex flex-wrap items-center justify-between gap-2 border-b px-3 py-2.5",children:[t.jsxs("p",{className:"thread-export-dialog-subtitle text-xs",children:["Selected ",j.size," of ",((E=n.data)==null?void 0:E.totalTurnCount)??p.length]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>w(new Set(p.map(C=>C.turnId))),className:"thread-export-dialog-secondary-button rounded-full border px-2.5 py-1 text-xs transition",children:"Select all"}),t.jsx("button",{type:"button",onClick:()=>w(new Set),className:"thread-export-dialog-secondary-button rounded-full border px-2.5 py-1 text-xs transition",children:"Clear"})]})]}),n.status==="loading"?t.jsx("p",{className:"thread-export-dialog-subtitle px-3 py-6 text-sm",children:"Loading turns..."}):n.status==="failed"?t.jsx("p",{className:"px-3 py-6 text-sm text-rose-500 dark:text-rose-200",children:n.error}):t.jsx("div",{className:"max-h-80 overflow-auto p-2",children:p.map(C=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex cursor-pointer items-center gap-3 rounded-xl px-2.5 py-2 text-sm transition",children:[t.jsx("input",{type:"checkbox",checked:j.has(C.turnId),onChange:()=>B(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:sx(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:ox(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:y,onChange:C=>v(C.target.checked),className:"thread-export-dialog-checkbox h-4 w-4"}),"Token and price"]}),t.jsx("p",{className:"thread-export-dialog-box thread-export-dialog-subtitle flex items-center rounded-xl border px-3 py-2 text-xs",children:g==="html"?"HTML keeps the chat timeline styling and omits raw command output.":"Review exports keep message text readable and omit tool activity."})]})]})]}),t.jsxs("div",{className:"thread-export-dialog-footer flex items-center justify-between gap-3 border-t px-5 py-4",children:[t.jsx("p",{className:"thread-export-dialog-subtitle min-w-0 text-xs",children:g==="share"?a?"Share access is enforced by the relay server.":"Share permissions are not wired yet.":`${oe} ${oe===1?"turn":"turns"} selected.`}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:i,disabled:r,className:"thread-export-dialog-secondary-button rounded-full border px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),g==="share"?t.jsx("button",{type:"submit",form:"thread-actions-share-form",disabled:!re,className:"ui-status-warning rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:r?"Sharing...":"Share this thread"}):t.jsx("button",{type:"button",onClick:J,disabled:!T,className:"ui-status-warning rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:r?"Exporting...":`Export ${g.toUpperCase()}`})]})]})]})]}),document.body)}function hx({detail:e,adapter:r,timelineAdapter:n,TimelineComponent:a=Cl,liveOutput:o="",beforeTimelineContent:s,composerProps:l,timelineProps:i,transcriptItemCount:d,useFloatingMobileComposer:h=!1,floatingMobileComposerBottomOffset:u=0,composerHostRef:m}){const[f,p]=c.useState(!1),[g,b]=c.useState(0),[k,x]=c.useState(0),[j,w]=c.useState(0),[y,v]=c.useState(!1),S=c.useRef(null),N=i==null?void 0:i.onTailVisibilityChange,I=e.pendingRequests.length>0,M=c.useCallback(T=>{N==null||N(T)},[N]);c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const T=window.matchMedia("(max-width: 639px)"),re=()=>p(T.matches);return re(),T.addEventListener("change",re),()=>{T.removeEventListener("change",re)}},[]),c.useEffect(()=>{var re,B;if(typeof window>"u")return;const T=()=>{const J=window.visualViewport,K=J?Math.max(0,Math.round(window.innerHeight-J.height-J.offsetTop)):0,L=J?Math.max(0,Math.round(window.innerHeight-J.height)):K,q=Math.min(K,L),G=Math.max(0,Math.round(window.innerHeight*.52));w(Math.min(q,G))};return T(),(re=window.visualViewport)==null||re.addEventListener("resize",T),(B=window.visualViewport)==null||B.addEventListener("scroll",T),window.addEventListener("resize",T),()=>{var J,K;(J=window.visualViewport)==null||J.removeEventListener("resize",T),(K=window.visualViewport)==null||K.removeEventListener("scroll",T),window.removeEventListener("resize",T)}},[]),c.useLayoutEffect(()=>{const T=S.current;if(!T||!f){b(0);return}const re=()=>{b(Math.ceil(T.getBoundingClientRect().height))};if(re(),typeof ResizeObserver>"u")return;const B=new ResizeObserver(re);return B.observe(T),()=>{B.disconnect()}},[f,l,I]),c.useLayoutEffect(()=>{var J,K;const T=S.current;if(!T||!f){x(0);return}const re=()=>{const L=T.getBoundingClientRect();x(Math.max(0,Math.ceil(window.innerHeight-L.top)))};re(),window.addEventListener("resize",re),(J=window.visualViewport)==null||J.addEventListener("resize",re),(K=window.visualViewport)==null||K.addEventListener("scroll",re);let B=null;return typeof ResizeObserver<"u"&&(B=new ResizeObserver(re),B.observe(T)),()=>{var L,q;window.removeEventListener("resize",re),(L=window.visualViewport)==null||L.removeEventListener("resize",re),(q=window.visualViewport)==null||q.removeEventListener("scroll",re),B==null||B.disconnect()}},[f,j,y,l,I]),c.useEffect(()=>{if(!f){v(!1);return}const T=B=>{var K;const J=B.target;J instanceof HTMLElement&&((K=S.current)!=null&&K.contains(J))&&v(!0)},re=B=>{var K;const J=B.relatedTarget;J instanceof HTMLElement&&((K=S.current)!=null&&K.contains(J))||v(!1)};return document.addEventListener("focusin",T),document.addEventListener("focusout",re),()=>{document.removeEventListener("focusin",T),document.removeEventListener("focusout",re)}},[f]);const R=c.useCallback(T=>{S.current=T,m&&(m.current=T)},[m]),Q=f&&y?Math.max(0,j-u):0,$=Math.max(g,144),Y=Math.max(k,$+Q),Z=f?Y+12:0,P=Z>0?{"--thread-graph-chat-scroll-bottom-spacer":`${Z}px`}:void 0,te=h&&f?{bottom:`${u+Q}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"}:void 0,oe=c.useMemo(()=>{const T=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:T,liveOutput:o,className:"thread-timeline-surface min-h-0 flex-1",...i,adapter:n,onOpenThread:(i==null?void 0:i.onOpenThread)??r.openThread,onTailVisibilityChange:M})},[a,r.openThread,e.pendingRequests,e.thread.activeTurnId,e.thread.id,e.thread.status,e.totalTurnCount,e.turns,M,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:P,children:[s,oe,t.jsx("div",{className:"thread-chat-usage-footer hidden shrink-0 items-center px-4 py-1 text-[10px] leading-4 sm:flex",children:t.jsxs("span",{className:"min-w-0",children:[e.turns.length," turn",e.turns.length!==1?"s":"",t.jsx("span",{className:"mx-1 text-[var(--theme-border-contrast)]",children:"|"}),d," item",d!==1?"s":""]})}),l?h?t.jsx("div",{ref:R,className:"fixed inset-x-0 bottom-0 z-50 overflow-visible sm:hidden",style:te??{bottom:`${u}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"},children:t.jsx(Un,{...l,activeView:"chat",edgeToEdgeMobile:!0,onSubmit:r.sendPrompt})}):t.jsx("div",{ref:R,className:"thread-graph-composer-host shrink-0",children:t.jsx(Un,{...l,activeView:"chat",onSubmit:r.sendPrompt})}):null]})}function ux(e){return e.turns.reduce((r,n)=>{var o,s;const a=(o=n.tokenUsage)==null?void 0:o.total;return a?{input:r.input+a.inputTokens,output:r.output+a.outputTokens,cache:r.cache+a.cachedInputTokens,cacheWrite:r.cacheWrite+(a.cacheWriteInputTokens??0),priceUsd:r.priceUsd+(((s=n.priceEstimate)==null?void 0:s.totalUsd)??0),pricedTurns:r.pricedTurns+(n.priceEstimate?1:0),turns:r.turns+1}:r},{input:0,output:0,cache:0,cacheWrite:0,priceUsd:0,pricedTurns:0,turns:0})}function Dr(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?"0":e>=1e6?`${(e/1e6).toFixed(e>=1e7?0:1)}m`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(Math.round(e))}function mx(e){if(!e||e.turns<=0)return"waiting for agent usage";const r=`in ${Dr(e.input)} / out ${Dr(e.output)} / cache read ${Dr(e.cache)}`,n=e.cacheWrite>0?`${r} / cache write ${Dr(e.cacheWrite)}`:r;return e.pricedTurns>0?`${n} / cost ${yl(e.priceUsd)}`:n}function jx({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:k,threadActionsButton:x,surfaceActions:j,floatingPanel:w,workspaceContent:y,workspaceTitle:v,workspaceActions:S,workspaceFeatures:N,workspaceFocusPathRequest:I=null,onNewThreadTitle:M,beforeTimelineContent:R,errorContent:Q,workspaceMissingContent:$,dialogs:Y,currentThreadId:Z,currentWorkspaceId:P,currentWorkspaceLabel:te,onCloseAppNavigation:oe,className:T="thread-detail-surface relative flex h-full min-h-0 flex-1 flex-col overflow-hidden",activeView:re="chat",liveOutput:B="",timelineProps:J,composerProps:K,shellComposerProps:L,useFloatingMobileComposer:q=!1,floatingMobileComposerBottomOffset:G=0,composerHostRef:E,shellPanelRef:C,shellEffectiveTheme:W="dark",shellThemeMode:H=W,onShellThemeModeChange:se,onShellStateChange:V,shellUnavailableContent:de,shellDisconnectedContent:ee,timelineComponent:be=Cl,shellPanelComponent:ie=rx,shellContent:ye,loadingContent:Ae,emptyContent:ce}){const Ce=ca(),Le=s??Ce??ia(),{getImageAssetUrl:X,loadHistoryItemDetail:ue,openWorkspaceFile:ve,openThread:ke,cancelPendingSteer:$e}=l,He=c.useMemo(()=>({...X?{getImageAssetUrl:ne=>X(ne.path)}:{},onOpenLinkedThread:ke,...ve?{onOpenWorkspaceFile:ve}:{},...ue?{onLoadHistoryItemDetail:ue}:{},...$e?{cancelPendingSteer:$e}:{}}),[$e,X,ue,ve,ke]),_e=Le.getThreadPanels().some(ne=>ne.kind==="terminal"),ze=c.useMemo(()=>r?ux(r):null,[r]),F=c.useMemo(()=>mx(ze),[ze]),le=c.useMemo(()=>{var ne;return r?r.turns.reduce((ge,Te)=>ge+Te.items.length,((ne=r.liveItems)==null?void 0:ne.items.length)??0):0},[r]),we=y??(r?t.jsx(Ll,{detail:r,status:o,plugins:Le,workspaceAdapter:l.workspace??null,metaContent:i,settingsContent:d,activeView:re,features:N,focusPathRequest:I}):null),z=n?Ae??t.jsx("div",{className:"flex flex-1 items-center justify-center px-6 py-12 text-center text-[var(--theme-fg-muted)]",children:"Loading thread detail..."}):r?t.jsxs("div",{className:T,children:[w?t.jsx("div",{className:"fixed right-3 top-20 z-50 lg:absolute lg:right-4 lg:top-16",children:w}):null,a&&!n&&(Q??t.jsx("div",{className:"shrink-0 border-b border-rose-500/20 bg-rose-500/10 px-5 py-4 text-sm text-rose-100 sm:px-6",children:a})),r.workspacePathStatus==="missing"&&($??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:re==="chat"?"flex min-h-0 flex-1 flex-col":"hidden",children:t.jsx(hx,{detail:r,adapter:l,timelineAdapter:He,TimelineComponent:be,liveOutput:B,transcriptItemCount:le,useFloatingMobileComposer:q,floatingMobileComposerBottomOffset:G,...R?{beforeTimelineContent:R}:{},...K?{composerProps:K}:{},...J?{timelineProps:J}:{},...E?{composerHostRef:E}:{}})}),t.jsxs("div",{className:re==="shell"?"flex min-h-0 flex-1 flex-col":"hidden",children:[ye??(r.thread.isLoaded&&_e&&l.shell?t.jsx(ie,{ref:C,threadId:r.thread.id,shellAdapter:l.shell,effectiveTheme:W,isVisible:re==="shell",showHeader:!1,showFloatingToolbox:!1,...V?{onStateChange:V}:{}}):r.thread.isLoaded&&!_e?de??t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center p-4 sm:p-6",children:t.jsxs("div",{className:"thread-empty-surface max-w-md rounded-[1.6rem] border px-6 py-8 text-center",children:[t.jsx("p",{className:"text-base font-medium text-[var(--theme-fg)]",children:"Terminal plugin disabled"}),t.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--theme-fg-muted)]",children:"Enable the Terminal plugin in Settings to use the shell panel."})]})}):ee??t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center p-4 sm:p-6",children:t.jsxs("div",{className:"thread-empty-surface max-w-md rounded-[1.6rem] border px-6 py-8 text-center",children:[t.jsx("p",{className:"text-base font-medium text-[var(--theme-fg)]",children:"Thread disconnected"}),t.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--theme-fg-soft)]",children:"Reconnect this thread before creating or attaching a shell."})]})})),re==="shell"&&L&&!ye?t.jsx(Un,{...L,activeView:"shell",onSubmit:l.sendPrompt}):null]}),Y]}):ce??t.jsx("div",{className:"flex flex-1 items-center justify-center px-6 py-12 text-center text-[var(--theme-fg-muted)]",children:"Select a thread to inspect."}),O=t.jsx(mp,{threads:e,status:o,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:P??(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:F,threadActionsButton:x,topbarActions:j,metaContent:i,settingsContent:d,globalSettingsContent:h,...u!==void 0?{settingsDialogOpen:u}:{},...m?{onSettingsDialogOpenChange:m}:{},mobileHeaderAction:f,effectiveTheme:W,themeMode:H,appMenuButton:p,appNavigationMenu:g,workspaceReturnHref:b,...k?{onWorkspaceReturn:k}:{},showMobileAppMenu:!!p,showMobileThreadNavToggle:!0,showMobileNewThreadShortcut:!1,onOpenThread:l.openThread,workspaceContent:we,workspaceTitle:v??"Workspace",workspaceActions:S,...M?{onNewThreadTitle:M}:{},...oe?{onCloseAppNavigation:oe}:{},...se?{onThemeModeChange:se}:{},...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:z});return s?t.jsx(da.Provider,{value:Le,children:O}):O}var px={},fx=[];function Nx({adapter:e=px,builtinPlugins:r=fx,children:n}){const[a,o]=c.useState(()=>Vn(r,[])),[s,l]=c.useState(!1),[i,d]=c.useState(null),h=c.useCallback(async()=>{l(!0),d(null);try{const w=e.fetchPlugins?await e.fetchPlugins():[];o(Vn(r,w))}catch(w){d(w instanceof Error?w.message:"Unable to load plugins.")}finally{l(!1)}},[e,r]);c.useEffect(()=>{h()},[h]);const u=c.useCallback(async(w,y)=>{if(e.updatePlugin){const v=await e.updatePlugin(w,{enabled:y});o(S=>S.map(N=>N.id===v.id?v:N));return}o(v=>v.map(S=>S.id===w?{...S,enabled:y}:S))},[e]),m=c.useCallback(async w=>{if(!e.importPlugin)throw new Error("Plugin import is not available.");const y=await e.importPlugin(w);o(v=>[...v.filter(N=>N.id!==y.id),y])},[e]),f=c.useCallback(async w=>{if(!e.deletePlugin)throw new Error("Plugin uninstall is not available.");const y=await e.deletePlugin(w);o(v=>v.filter(S=>S.id!==y.id))},[e]),p=c.useMemo(()=>{const w=new Set(a.filter(y=>y.enabled).map(y=>y.id));return r.filter(y=>w.has(y.manifest.id))},[r,a]),g=c.useCallback(w=>{var v;const y=p.find(S=>S.renderArtifact&&S.manifest.capabilities.artifactTypes.some(N=>N.type===w.artifact.type));return((v=y==null?void 0:y.renderArtifact)==null?void 0:v.call(y,w))??null},[p]),b=c.useCallback(w=>{for(const y of p)for(const v of y.inlineCodeRenderers??[]){if(!v.languages.includes(w.language.trim().toLowerCase()))continue;const S=v.render(w);if(S)return S}return null},[p]),k=c.useCallback(w=>p.some(y=>!!y.renderArtifact&&y.manifest.capabilities.artifactTypes.some(v=>v.type===w.type)),[p]),x=c.useCallback(()=>p.flatMap(w=>w.threadPanels??[]),[p]),j=c.useMemo(()=>({plugins:a,loading:s,error:i,refresh:h,importPluginManifest:m,setPluginEnabled:u,uninstallPlugin:f,renderArtifact:g,renderInlineCode:b,hasRendererForArtifact:k,getThreadPanels:x}),[i,x,k,m,s,a,h,g,b,u,f]);return t.jsx(da.Provider,{value:j,children:n})}export{Zm as A,wx as C,pp as L,Nx as P,yx as T,ca as a,jx as b,rx as c,Cl as d,mp as e,Wt as f,up as g,Jm as t,ll as u};
|