remote-codex 0.11.42 → 0.11.43
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/relay-server/dist/index.js +25 -4
- package/apps/supervisor-api/dist/index.js +62 -9
- package/apps/supervisor-web/dist/assets/frontend-DNAQzqc-.js +1704 -0
- package/apps/supervisor-web/dist/assets/{index-BvxWpPKW.js → index-BT0SM9C-.js} +7 -7
- package/apps/supervisor-web/dist/assets/styles-BEieA99i.css +1 -0
- package/apps/supervisor-web/dist/assets/{thread-ui-BLThton-.js → thread-ui-Dmrigdek.js} +28 -26
- package/apps/supervisor-web/dist/index.html +2 -2
- package/package.json +1 -1
- package/packages/claude/src/runtimeAdapter.test.ts +12 -5
- package/packages/claude/src/runtimeAdapter.ts +72 -9
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/core-DODVy7wn.js","assets/markdown-vendor-RZk8L7-L.js","assets/react-vendor-Dfg_6BLf.js","assets/html-pp8916En.js","assets/javascript-wDzz0qaB.js","assets/css-CLj8gQPS.js","assets/terminal-vendor-C5bTa-Ka.js","assets/terminal-vendor-Beg8tuEN.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{l as $,R as Qi,I as ed,C as td,S as Os,H as rd,T as nd,a as ad,b as sd,c as od,d as ld,e as id,D as dd,P as cd,O as hd,f as ud,g as md,h as pd,i as fd,j as gd,k as xd,m as bd,n as vd,A as kd,o as wd,p as yd}from"./ui-vendor-CuR8GHb0.js";import{r as c,R as jd,j as t,b as Qr}from"./react-vendor-Dfg_6BLf.js";import{u as Nd,a as Cd,H as Sa,P as Ft,b as Sd,M as Ws,R as Td,i as Ed,C as Ld,B as Id,c as Ta,g as Us}from"./graph-vendor-DVQUpZ8C.js";import"./terminal-vendor-C5bTa-Ka.js";import{M as zd,r as Pd,a as Rd,b as Ad}from"./markdown-vendor-RZk8L7-L.js";const Md="modulepreload",$d=function(e){return"/"+e},Ea={},Xe=function(r,n,a){let s=Promise.resolve();if(n&&n.length>0){let l=function(h){return Promise.all(h.map(u=>Promise.resolve(u).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),d=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));s=l(n.map(h=>{if(h=$d(h),h in Ea)return;Ea[h]=!0;const u=h.endsWith(".css"),m=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${m}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":Md,u||(f.as="script"),f.crossOrigin="",f.href=h,d&&f.setAttribute("nonce",d),document.head.appendChild(f),u)return new Promise((p,g)=>{f.addEventListener("load",p),f.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${h}`)))})}))}function o(l){const i=new Event("vite:preloadError",{cancelable:!0});if(i.payload=l,window.dispatchEvent(i),!i.defaultPrevented)throw l}return s.then(l=>{for(const i of l||[])i.status==="rejected"&&o(i.reason);return r().catch(o)})};function Vs(e){var r,n,a="";if(typeof e=="string"||typeof e=="number")a+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(r=0;r<s;r++)e[r]&&(n=Vs(e[r]))&&(a&&(a+=" "),a+=n)}else for(n in e)e[n]&&(a&&(a+=" "),a+=n);return a}function qs(){for(var e,r,n=0,a="",s=arguments.length;n<s;n++)(e=arguments[n])&&(r=Vs(e))&&(a&&(a+=" "),a+=r);return a}const _d=(e,r)=>{const n=new Array(e.length+r.length);for(let a=0;a<e.length;a++)n[a]=e[a];for(let a=0;a<r.length;a++)n[e.length+a]=r[a];return n},Dd=(e,r)=>({classGroupId:e,validator:r}),Ks=(e=new Map,r=null,n)=>({nextPart:e,validators:r,classGroupId:n}),qr="-",La=[],Bd="arbitrary..",Gd=e=>{const r=Hd(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:a}=e;return{getClassGroupId:l=>{if(l.startsWith("[")&&l.endsWith("]"))return Fd(l);const i=l.split(qr),d=i[0]===""&&i.length>1?1:0;return Xs(i,d,r)},getConflictingClassGroupIds:(l,i)=>{if(i){const d=a[l],h=n[l];return d?h?_d(h,d):d:h||La}return n[l]||La}}},Xs=(e,r,n)=>{if(e.length-r===0)return n.classGroupId;const s=e[r],o=n.nextPart.get(s);if(o){const h=Xs(e,r+1,o);if(h)return h}const l=n.validators;if(l===null)return;const i=r===0?e.join(qr):e.slice(r).join(qr),d=l.length;for(let h=0;h<d;h++){const u=l[h];if(u.validator(i))return u.classGroupId}},Fd=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const r=e.slice(1,-1),n=r.indexOf(":"),a=r.slice(0,n);return a?Bd+a:void 0})(),Hd=e=>{const{theme:r,classGroups:n}=e;return Od(n,r)},Od=(e,r)=>{const n=Ks();for(const a in e){const s=e[a];ta(s,n,a,r)}return n},ta=(e,r,n,a)=>{const s=e.length;for(let o=0;o<s;o++){const l=e[o];Wd(l,r,n,a)}},Wd=(e,r,n,a)=>{if(typeof e=="string"){Ud(e,r,n);return}if(typeof e=="function"){Vd(e,r,n,a);return}qd(e,r,n,a)},Ud=(e,r,n)=>{const a=e===""?r:Ys(r,e);a.classGroupId=n},Vd=(e,r,n,a)=>{if(Kd(e)){ta(e(a),r,n,a);return}r.validators===null&&(r.validators=[]),r.validators.push(Dd(n,e))},qd=(e,r,n,a)=>{const s=Object.entries(e),o=s.length;for(let l=0;l<o;l++){const[i,d]=s[l];ta(d,Ys(r,i),n,a)}},Ys=(e,r)=>{let n=e;const a=r.split(qr),s=a.length;for(let o=0;o<s;o++){const l=a[o];let i=n.nextPart.get(l);i||(i=Ks(),n.nextPart.set(l,i)),n=i}return n},Kd=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Xd=e=>{if(e<1)return{get:()=>{},set:()=>{}};let r=0,n=Object.create(null),a=Object.create(null);const s=(o,l)=>{n[o]=l,r++,r>e&&(r=0,a=n,n=Object.create(null))};return{get(o){let l=n[o];if(l!==void 0)return l;if((l=a[o])!==void 0)return s(o,l),l},set(o,l){o in n?n[o]=l:s(o,l)}}},Mn="!",Ia=":",Yd=[],za=(e,r,n,a,s)=>({modifiers:e,hasImportantModifier:r,baseClassName:n,maybePostfixModifierPosition:a,isExternal:s}),Zd=e=>{const{prefix:r,experimentalParseClassName:n}=e;let a=s=>{const o=[];let l=0,i=0,d=0,h;const u=s.length;for(let k=0;k<u;k++){const w=s[k];if(l===0&&i===0){if(w===Ia){o.push(s.slice(d,k)),d=k+1;continue}if(w==="/"){h=k;continue}}w==="["?l++:w==="]"?l--:w==="("?i++:w===")"&&i--}const m=o.length===0?s:s.slice(d);let f=m,p=!1;m.endsWith(Mn)?(f=m.slice(0,-1),p=!0):m.startsWith(Mn)&&(f=m.slice(1),p=!0);const g=h&&h>d?h-d:void 0;return za(o,p,f,g)};if(r){const s=r+Ia,o=a;a=l=>l.startsWith(s)?o(l.slice(s.length)):za(Yd,!1,l,void 0,!0)}if(n){const s=a;a=o=>n({className:o,parseClassName:s})}return a},Jd=e=>{const r=new Map;return e.orderSensitiveModifiers.forEach((n,a)=>{r.set(n,1e6+a)}),n=>{const a=[];let s=[];for(let o=0;o<n.length;o++){const l=n[o],i=l[0]==="[",d=r.has(l);i||d?(s.length>0&&(s.sort(),a.push(...s),s=[]),a.push(l)):s.push(l)}return s.length>0&&(s.sort(),a.push(...s)),a}},Qd=e=>({cache:Xd(e.cacheSize),parseClassName:Zd(e),sortModifiers:Jd(e),postfixLookupClassGroupIds:ec(e),...Gd(e)}),ec=e=>{const r=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let a=0;a<n.length;a++)r[n[a]]=!0;return r},tc=/\s+/,rc=(e,r)=>{const{parseClassName:n,getClassGroupId:a,getConflictingClassGroupIds:s,sortModifiers:o,postfixLookupClassGroupIds:l}=r,i=[],d=e.trim().split(tc);let h="";for(let u=d.length-1;u>=0;u-=1){const m=d[u],{isExternal:f,modifiers:p,hasImportantModifier:g,baseClassName:k,maybePostfixModifierPosition:w}=n(m);if(f){h=m+(h.length>0?" "+h:h);continue}let x=!!w,j;if(x){const N=k.substring(0,w);j=a(N);const L=j&&l[j]?a(k):void 0;L&&L!==j&&(j=L,x=!1)}else j=a(k);if(!j){if(!x){h=m+(h.length>0?" "+h:h);continue}if(j=a(k),!j){h=m+(h.length>0?" "+h:h);continue}x=!1}const y=p.length===0?"":p.length===1?p[0]:o(p).join(":"),b=g?y+Mn:y,v=b+j;if(i.indexOf(v)>-1)continue;i.push(v);const S=s(j,x);for(let N=0;N<S.length;++N){const L=S[N];i.push(b+L)}h=m+(h.length>0?" "+h:h)}return h},nc=(...e)=>{let r=0,n,a,s="";for(;r<e.length;)(n=e[r++])&&(a=Zs(n))&&(s&&(s+=" "),s+=a);return s},Zs=e=>{if(typeof e=="string")return e;let r,n="";for(let a=0;a<e.length;a++)e[a]&&(r=Zs(e[a]))&&(n&&(n+=" "),n+=r);return n},ac=(e,...r)=>{let n,a,s,o;const l=d=>{const h=r.reduce((u,m)=>m(u),e());return n=Qd(h),a=n.cache.get,s=n.cache.set,o=i,i(d)},i=d=>{const h=a(d);if(h)return h;const u=rc(d,n);return s(d,u),u};return o=l,(...d)=>o(nc(...d))},sc=[],Je=e=>{const r=n=>n[e]||sc;return r.isThemeGetter=!0,r},Js=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Qs=/^\((?:(\w[\w-]*):)?(.+)\)$/i,oc=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,lc=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,ic=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,dc=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,cc=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,hc=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,St=e=>oc.test(e),Ie=e=>!!e&&!Number.isNaN(Number(e)),bt=e=>!!e&&Number.isInteger(Number(e)),vn=e=>e.endsWith("%")&&Ie(e.slice(0,-1)),jt=e=>lc.test(e),eo=()=>!0,uc=e=>ic.test(e)&&!dc.test(e),ra=()=>!1,mc=e=>cc.test(e),pc=e=>hc.test(e),fc=e=>!ue(e)&&!pe(e),gc=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),xc=e=>zt(e,no,ra),ue=e=>Js.test(e),_t=e=>zt(e,ao,uc),Pa=e=>zt(e,Cc,Ie),bc=e=>zt(e,oo,eo),vc=e=>zt(e,so,ra),Ra=e=>zt(e,to,ra),kc=e=>zt(e,ro,pc),Ar=e=>zt(e,lo,mc),pe=e=>Qs.test(e),fr=e=>qt(e,ao),wc=e=>qt(e,so),Aa=e=>qt(e,to),yc=e=>qt(e,no),jc=e=>qt(e,ro),Mr=e=>qt(e,lo,!0),Nc=e=>qt(e,oo,!0),zt=(e,r,n)=>{const a=Js.exec(e);return a?a[1]?r(a[1]):n(a[2]):!1},qt=(e,r,n=!1)=>{const a=Qs.exec(e);return a?a[1]?r(a[1]):n:!1},to=e=>e==="position"||e==="percentage",ro=e=>e==="image"||e==="url",no=e=>e==="length"||e==="size"||e==="bg-size",ao=e=>e==="length",Cc=e=>e==="number",so=e=>e==="family-name",oo=e=>e==="number"||e==="weight",lo=e=>e==="shadow",Sc=()=>{const e=Je("color"),r=Je("font"),n=Je("text"),a=Je("font-weight"),s=Je("tracking"),o=Je("leading"),l=Je("breakpoint"),i=Je("container"),d=Je("spacing"),h=Je("radius"),u=Je("shadow"),m=Je("inset-shadow"),f=Je("text-shadow"),p=Je("drop-shadow"),g=Je("blur"),k=Je("perspective"),w=Je("aspect"),x=Je("ease"),j=Je("animate"),y=()=>["auto","avoid","all","avoid-page","page","left","right","column"],b=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],v=()=>[...b(),pe,ue],S=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto","contain","none"],L=()=>[pe,ue,d],R=()=>[St,"full","auto",...L()],P=()=>[bt,"none","subgrid",pe,ue],Q=()=>["auto",{span:["full",bt,pe,ue]},bt,pe,ue],D=()=>[bt,"auto",pe,ue],Z=()=>["auto","min","max","fr",pe,ue],J=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],z=()=>["start","end","center","stretch","center-safe","end-safe"],te=()=>["auto",...L()],se=()=>[St,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...L()],_=()=>[St,"screen","full","dvw","lvw","svw","min","max","fit",...L()],ie=()=>[St,"screen","full","lh","dvh","lvh","svh","min","max","fit",...L()],q=()=>[e,pe,ue],H=()=>[...b(),Aa,Ra,{position:[pe,ue]}],G=()=>["no-repeat",{repeat:["","x","y","space","round"]}],T=()=>["auto","cover","contain",yc,xc,{size:[pe,ue]}],F=()=>[vn,fr,_t],B=()=>["","none","full",h,pe,ue],E=()=>["",Ie,fr,_t],C=()=>["solid","dashed","dotted","double"],W=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],U=()=>[Ie,vn,Aa,Ra],ae=()=>["","none",g,pe,ue],K=()=>["none",Ie,pe,ue],de=()=>["none",Ie,pe,ue],ee=()=>[Ie,pe,ue],ke=()=>[St,"full",...L()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[jt],breakpoint:[jt],color:[eo],container:[jt],"drop-shadow":[jt],ease:["in","out","in-out"],font:[fc],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[jt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[jt],shadow:[jt],spacing:["px",Ie],text:[jt],"text-shadow":[jt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",St,ue,pe,w]}],container:["container"],"container-type":[{"@container":["","normal","size",pe,ue]}],"container-named":[gc],columns:[{columns:[Ie,ue,pe,i]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:v()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:N()}],"overscroll-x":[{"overscroll-x":N()}],"overscroll-y":[{"overscroll-y":N()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:R()}],"inset-x":[{"inset-x":R()}],"inset-y":[{"inset-y":R()}],start:[{"inset-s":R(),start:R()}],end:[{"inset-e":R(),end:R()}],"inset-bs":[{"inset-bs":R()}],"inset-be":[{"inset-be":R()}],top:[{top:R()}],right:[{right:R()}],bottom:[{bottom:R()}],left:[{left:R()}],visibility:["visible","invisible","collapse"],z:[{z:[bt,"auto",pe,ue]}],basis:[{basis:[St,"full","auto",i,...L()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ie,St,"auto","initial","none",ue]}],grow:[{grow:["",Ie,pe,ue]}],shrink:[{shrink:["",Ie,pe,ue]}],order:[{order:[bt,"first","last","none",pe,ue]}],"grid-cols":[{"grid-cols":P()}],"col-start-end":[{col:Q()}],"col-start":[{"col-start":D()}],"col-end":[{"col-end":D()}],"grid-rows":[{"grid-rows":P()}],"row-start-end":[{row:Q()}],"row-start":[{"row-start":D()}],"row-end":[{"row-end":D()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":Z()}],"auto-rows":[{"auto-rows":Z()}],gap:[{gap:L()}],"gap-x":[{"gap-x":L()}],"gap-y":[{"gap-y":L()}],"justify-content":[{justify:[...J(),"normal"]}],"justify-items":[{"justify-items":[...z(),"normal"]}],"justify-self":[{"justify-self":["auto",...z()]}],"align-content":[{content:["normal",...J()]}],"align-items":[{items:[...z(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...z(),{baseline:["","last"]}]}],"place-content":[{"place-content":J()}],"place-items":[{"place-items":[...z(),"baseline"]}],"place-self":[{"place-self":["auto",...z()]}],p:[{p:L()}],px:[{px:L()}],py:[{py:L()}],ps:[{ps:L()}],pe:[{pe:L()}],pbs:[{pbs:L()}],pbe:[{pbe:L()}],pt:[{pt:L()}],pr:[{pr:L()}],pb:[{pb:L()}],pl:[{pl:L()}],m:[{m:te()}],mx:[{mx:te()}],my:[{my:te()}],ms:[{ms:te()}],me:[{me:te()}],mbs:[{mbs:te()}],mbe:[{mbe:te()}],mt:[{mt:te()}],mr:[{mr:te()}],mb:[{mb:te()}],ml:[{ml:te()}],"space-x":[{"space-x":L()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":L()}],"space-y-reverse":["space-y-reverse"],size:[{size:se()}],"inline-size":[{inline:["auto",..._()]}],"min-inline-size":[{"min-inline":["auto",..._()]}],"max-inline-size":[{"max-inline":["none",..._()]}],"block-size":[{block:["auto",...ie()]}],"min-block-size":[{"min-block":["auto",...ie()]}],"max-block-size":[{"max-block":["none",...ie()]}],w:[{w:[i,"screen",...se()]}],"min-w":[{"min-w":[i,"screen","none",...se()]}],"max-w":[{"max-w":[i,"screen","none","prose",{screen:[l]},...se()]}],h:[{h:["screen","lh",...se()]}],"min-h":[{"min-h":["screen","lh","none",...se()]}],"max-h":[{"max-h":["screen","lh",...se()]}],"font-size":[{text:["base",n,fr,_t]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,Nc,bc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",vn,ue]}],"font-family":[{font:[wc,vc,r]}],"font-features":[{"font-features":[ue]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[s,pe,ue]}],"line-clamp":[{"line-clamp":[Ie,"none",pe,Pa]}],leading:[{leading:[o,...L()]}],"list-image":[{"list-image":["none",pe,ue]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",pe,ue]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:q()}],"text-color":[{text:q()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...C(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ie,"from-font","auto",pe,_t]}],"text-decoration-color":[{decoration:q()}],"underline-offset":[{"underline-offset":[Ie,"auto",pe,ue]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:L()}],"tab-size":[{tab:[bt,pe,ue]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",pe,ue]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",pe,ue]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:H()}],"bg-repeat":[{bg:G()}],"bg-size":[{bg:T()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},bt,pe,ue],radial:["",pe,ue],conic:[bt,pe,ue]},jc,kc]}],"bg-color":[{bg:q()}],"gradient-from-pos":[{from:F()}],"gradient-via-pos":[{via:F()}],"gradient-to-pos":[{to:F()}],"gradient-from":[{from:q()}],"gradient-via":[{via:q()}],"gradient-to":[{to:q()}],rounded:[{rounded:B()}],"rounded-s":[{"rounded-s":B()}],"rounded-e":[{"rounded-e":B()}],"rounded-t":[{"rounded-t":B()}],"rounded-r":[{"rounded-r":B()}],"rounded-b":[{"rounded-b":B()}],"rounded-l":[{"rounded-l":B()}],"rounded-ss":[{"rounded-ss":B()}],"rounded-se":[{"rounded-se":B()}],"rounded-ee":[{"rounded-ee":B()}],"rounded-es":[{"rounded-es":B()}],"rounded-tl":[{"rounded-tl":B()}],"rounded-tr":[{"rounded-tr":B()}],"rounded-br":[{"rounded-br":B()}],"rounded-bl":[{"rounded-bl":B()}],"border-w":[{border:E()}],"border-w-x":[{"border-x":E()}],"border-w-y":[{"border-y":E()}],"border-w-s":[{"border-s":E()}],"border-w-e":[{"border-e":E()}],"border-w-bs":[{"border-bs":E()}],"border-w-be":[{"border-be":E()}],"border-w-t":[{"border-t":E()}],"border-w-r":[{"border-r":E()}],"border-w-b":[{"border-b":E()}],"border-w-l":[{"border-l":E()}],"divide-x":[{"divide-x":E()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":E()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...C(),"hidden","none"]}],"divide-style":[{divide:[...C(),"hidden","none"]}],"border-color":[{border:q()}],"border-color-x":[{"border-x":q()}],"border-color-y":[{"border-y":q()}],"border-color-s":[{"border-s":q()}],"border-color-e":[{"border-e":q()}],"border-color-bs":[{"border-bs":q()}],"border-color-be":[{"border-be":q()}],"border-color-t":[{"border-t":q()}],"border-color-r":[{"border-r":q()}],"border-color-b":[{"border-b":q()}],"border-color-l":[{"border-l":q()}],"divide-color":[{divide:q()}],"outline-style":[{outline:[...C(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ie,pe,ue]}],"outline-w":[{outline:["",Ie,fr,_t]}],"outline-color":[{outline:q()}],shadow:[{shadow:["","none",u,Mr,Ar]}],"shadow-color":[{shadow:q()}],"inset-shadow":[{"inset-shadow":["none",m,Mr,Ar]}],"inset-shadow-color":[{"inset-shadow":q()}],"ring-w":[{ring:E()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:q()}],"ring-offset-w":[{"ring-offset":[Ie,_t]}],"ring-offset-color":[{"ring-offset":q()}],"inset-ring-w":[{"inset-ring":E()}],"inset-ring-color":[{"inset-ring":q()}],"text-shadow":[{"text-shadow":["none",f,Mr,Ar]}],"text-shadow-color":[{"text-shadow":q()}],opacity:[{opacity:[Ie,pe,ue]}],"mix-blend":[{"mix-blend":[...W(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":W()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Ie]}],"mask-image-linear-from-pos":[{"mask-linear-from":U()}],"mask-image-linear-to-pos":[{"mask-linear-to":U()}],"mask-image-linear-from-color":[{"mask-linear-from":q()}],"mask-image-linear-to-color":[{"mask-linear-to":q()}],"mask-image-t-from-pos":[{"mask-t-from":U()}],"mask-image-t-to-pos":[{"mask-t-to":U()}],"mask-image-t-from-color":[{"mask-t-from":q()}],"mask-image-t-to-color":[{"mask-t-to":q()}],"mask-image-r-from-pos":[{"mask-r-from":U()}],"mask-image-r-to-pos":[{"mask-r-to":U()}],"mask-image-r-from-color":[{"mask-r-from":q()}],"mask-image-r-to-color":[{"mask-r-to":q()}],"mask-image-b-from-pos":[{"mask-b-from":U()}],"mask-image-b-to-pos":[{"mask-b-to":U()}],"mask-image-b-from-color":[{"mask-b-from":q()}],"mask-image-b-to-color":[{"mask-b-to":q()}],"mask-image-l-from-pos":[{"mask-l-from":U()}],"mask-image-l-to-pos":[{"mask-l-to":U()}],"mask-image-l-from-color":[{"mask-l-from":q()}],"mask-image-l-to-color":[{"mask-l-to":q()}],"mask-image-x-from-pos":[{"mask-x-from":U()}],"mask-image-x-to-pos":[{"mask-x-to":U()}],"mask-image-x-from-color":[{"mask-x-from":q()}],"mask-image-x-to-color":[{"mask-x-to":q()}],"mask-image-y-from-pos":[{"mask-y-from":U()}],"mask-image-y-to-pos":[{"mask-y-to":U()}],"mask-image-y-from-color":[{"mask-y-from":q()}],"mask-image-y-to-color":[{"mask-y-to":q()}],"mask-image-radial":[{"mask-radial":[pe,ue]}],"mask-image-radial-from-pos":[{"mask-radial-from":U()}],"mask-image-radial-to-pos":[{"mask-radial-to":U()}],"mask-image-radial-from-color":[{"mask-radial-from":q()}],"mask-image-radial-to-color":[{"mask-radial-to":q()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[Ie]}],"mask-image-conic-from-pos":[{"mask-conic-from":U()}],"mask-image-conic-to-pos":[{"mask-conic-to":U()}],"mask-image-conic-from-color":[{"mask-conic-from":q()}],"mask-image-conic-to-color":[{"mask-conic-to":q()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:H()}],"mask-repeat":[{mask:G()}],"mask-size":[{mask:T()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",pe,ue]}],filter:[{filter:["","none",pe,ue]}],blur:[{blur:ae()}],brightness:[{brightness:[Ie,pe,ue]}],contrast:[{contrast:[Ie,pe,ue]}],"drop-shadow":[{"drop-shadow":["","none",p,Mr,Ar]}],"drop-shadow-color":[{"drop-shadow":q()}],grayscale:[{grayscale:["",Ie,pe,ue]}],"hue-rotate":[{"hue-rotate":[Ie,pe,ue]}],invert:[{invert:["",Ie,pe,ue]}],saturate:[{saturate:[Ie,pe,ue]}],sepia:[{sepia:["",Ie,pe,ue]}],"backdrop-filter":[{"backdrop-filter":["","none",pe,ue]}],"backdrop-blur":[{"backdrop-blur":ae()}],"backdrop-brightness":[{"backdrop-brightness":[Ie,pe,ue]}],"backdrop-contrast":[{"backdrop-contrast":[Ie,pe,ue]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ie,pe,ue]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ie,pe,ue]}],"backdrop-invert":[{"backdrop-invert":["",Ie,pe,ue]}],"backdrop-opacity":[{"backdrop-opacity":[Ie,pe,ue]}],"backdrop-saturate":[{"backdrop-saturate":[Ie,pe,ue]}],"backdrop-sepia":[{"backdrop-sepia":["",Ie,pe,ue]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":L()}],"border-spacing-x":[{"border-spacing-x":L()}],"border-spacing-y":[{"border-spacing-y":L()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",pe,ue]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ie,"initial",pe,ue]}],ease:[{ease:["linear","initial",x,pe,ue]}],delay:[{delay:[Ie,pe,ue]}],animate:[{animate:["none",j,pe,ue]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[k,pe,ue]}],"perspective-origin":[{"perspective-origin":v()}],rotate:[{rotate:K()}],"rotate-x":[{"rotate-x":K()}],"rotate-y":[{"rotate-y":K()}],"rotate-z":[{"rotate-z":K()}],scale:[{scale:de()}],"scale-x":[{"scale-x":de()}],"scale-y":[{"scale-y":de()}],"scale-z":[{"scale-z":de()}],"scale-3d":["scale-3d"],skew:[{skew:ee()}],"skew-x":[{"skew-x":ee()}],"skew-y":[{"skew-y":ee()}],transform:[{transform:[pe,ue,"","none","gpu","cpu"]}],"transform-origin":[{origin:v()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ke()}],"translate-x":[{"translate-x":ke()}],"translate-y":[{"translate-y":ke()}],"translate-z":[{"translate-z":ke()}],"translate-none":["translate-none"],zoom:[{zoom:[bt,pe,ue]}],accent:[{accent:q()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:q()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",pe,ue]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":q()}],"scrollbar-track-color":[{"scrollbar-track":q()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":L()}],"scroll-mx":[{"scroll-mx":L()}],"scroll-my":[{"scroll-my":L()}],"scroll-ms":[{"scroll-ms":L()}],"scroll-me":[{"scroll-me":L()}],"scroll-mbs":[{"scroll-mbs":L()}],"scroll-mbe":[{"scroll-mbe":L()}],"scroll-mt":[{"scroll-mt":L()}],"scroll-mr":[{"scroll-mr":L()}],"scroll-mb":[{"scroll-mb":L()}],"scroll-ml":[{"scroll-ml":L()}],"scroll-p":[{"scroll-p":L()}],"scroll-px":[{"scroll-px":L()}],"scroll-py":[{"scroll-py":L()}],"scroll-ps":[{"scroll-ps":L()}],"scroll-pe":[{"scroll-pe":L()}],"scroll-pbs":[{"scroll-pbs":L()}],"scroll-pbe":[{"scroll-pbe":L()}],"scroll-pt":[{"scroll-pt":L()}],"scroll-pr":[{"scroll-pr":L()}],"scroll-pb":[{"scroll-pb":L()}],"scroll-pl":[{"scroll-pl":L()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",pe,ue]}],fill:[{fill:["none",...q()]}],"stroke-w":[{stroke:[Ie,fr,_t,Pa]}],stroke:[{stroke:["none",...q()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Tc=ac(Sc),Ma=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,$a=qs,Er=(e,r)=>n=>{var a;if((r==null?void 0:r.variants)==null)return $a(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:s,defaultVariants:o}=r,l=Object.keys(s).map(h=>{const u=n==null?void 0:n[h],m=o==null?void 0:o[h];if(u===null)return null;const f=Ma(u)||Ma(m);return s[h][f]}),i=n&&Object.entries(n).reduce((h,u)=>{let[m,f]=u;return f===void 0||(h[m]=f),h},{}),d=r==null||(a=r.compoundVariants)===null||a===void 0?void 0:a.reduce((h,u)=>{let{class:m,className:f,...p}=u;return Object.entries(p).every(g=>{let[k,w]=g;return Array.isArray(w)?w.includes({...o,...i}[k]):{...o,...i}[k]===w})?[...h,m,f]:h},[]);return $a(e,l,d,n==null?void 0:n.class,n==null?void 0:n.className)},en=c.createContext(null);en.displayName="PanelGroupContext";const qe={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},na=10,Wt=c.useLayoutEffect,_a=jd.useId,Ec=typeof _a=="function"?_a:()=>null;let Lc=0;function aa(e=null){const r=Ec(),n=c.useRef(e||r||null);return n.current===null&&(n.current=""+Lc++),e??n.current}function io({children:e,className:r="",collapsedSize:n,collapsible:a,defaultSize:s,forwardedRef:o,id:l,maxSize:i,minSize:d,onCollapse:h,onExpand:u,onResize:m,order:f,style:p,tagName:g="div",...k}){const w=c.useContext(en);if(w===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:x,expandPanel:j,getPanelSize:y,getPanelStyle:b,groupId:v,isPanelCollapsed:S,reevaluatePanelConstraints:N,registerPanel:L,resizePanel:R,unregisterPanel:P}=w,Q=aa(l),D=c.useRef({callbacks:{onCollapse:h,onExpand:u,onResize:m},constraints:{collapsedSize:n,collapsible:a,defaultSize:s,maxSize:i,minSize:d},id:Q,idIsFromProps:l!==void 0,order:f});c.useRef({didLogMissingDefaultSizeWarning:!1}),Wt(()=>{const{callbacks:J,constraints:z}=D.current,te={...z};D.current.id=Q,D.current.idIsFromProps=l!==void 0,D.current.order=f,J.onCollapse=h,J.onExpand=u,J.onResize=m,z.collapsedSize=n,z.collapsible=a,z.defaultSize=s,z.maxSize=i,z.minSize=d,(te.collapsedSize!==z.collapsedSize||te.collapsible!==z.collapsible||te.maxSize!==z.maxSize||te.minSize!==z.minSize)&&N(D.current,te)}),Wt(()=>{const J=D.current;return L(J),()=>{P(J)}},[f,Q,L,P]),c.useImperativeHandle(o,()=>({collapse:()=>{x(D.current)},expand:J=>{j(D.current,J)},getId(){return Q},getSize(){return y(D.current)},isCollapsed(){return S(D.current)},isExpanded(){return!S(D.current)},resize:J=>{R(D.current,J)}}),[x,j,y,S,Q,R]);const Z=b(D.current,s);return c.createElement(g,{...k,children:e,className:r,id:Q,style:{...Z,...p},[qe.groupId]:v,[qe.panel]:"",[qe.panelCollapsible]:a||void 0,[qe.panelId]:Q,[qe.panelSize]:parseFloat(""+Z.flexGrow).toFixed(1)})}const co=c.forwardRef((e,r)=>c.createElement(io,{...e,forwardedRef:r}));io.displayName="Panel";co.displayName="forwardRef(Panel)";let $n=null,Fr=-1,Et=null;function Ic(e,r,n){const a=(r&fo)!==0,s=(r&go)!==0,o=(r&xo)!==0,l=(r&bo)!==0;if(r){if(a)return o?"se-resize":l?"ne-resize":"e-resize";if(s)return o?"sw-resize":l?"nw-resize":"w-resize";if(o)return"s-resize";if(l)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function zc(){Et!==null&&(document.head.removeChild(Et),$n=null,Et=null,Fr=-1)}function kn(e,r,n){var a,s;const o=Ic(e,r);if($n!==o){if($n=o,Et===null&&(Et=document.createElement("style"),document.head.appendChild(Et)),Fr>=0){var l;(l=Et.sheet)===null||l===void 0||l.removeRule(Fr)}Fr=(a=(s=Et.sheet)===null||s===void 0?void 0:s.insertRule(`*{cursor: ${o} !important;}`))!==null&&a!==void 0?a:-1}}function ho(e){return e.type==="keydown"}function uo(e){return e.type.startsWith("pointer")}function mo(e){return e.type.startsWith("mouse")}function tn(e){if(uo(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(mo(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function Pc(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function Rc(e,r,n){return e.x<r.x+r.width&&e.x+e.width>r.x&&e.y<r.y+r.height&&e.y+e.height>r.y}function Ac(e,r){if(e===r)throw new Error("Cannot compare node with itself");const n={a:Ga(e),b:Ga(r)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),r=n.b.pop(),a=e;Ee(a,"Stacking order can only be calculated for elements with a common ancestor");const s={a:Ba(Da(n.a)),b:Ba(Da(n.b))};if(s.a===s.b){const o=a.childNodes,l={a:n.a.at(-1),b:n.b.at(-1)};let i=o.length;for(;i--;){const d=o[i];if(d===l.a)return 1;if(d===l.b)return-1}}return Math.sign(s.a-s.b)}const Mc=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function $c(e){var r;const n=getComputedStyle((r=po(e))!==null&&r!==void 0?r:e).display;return n==="flex"||n==="inline-flex"}function _c(e){const r=getComputedStyle(e);return!!(r.position==="fixed"||r.zIndex!=="auto"&&(r.position!=="static"||$c(e))||+r.opacity<1||"transform"in r&&r.transform!=="none"||"webkitTransform"in r&&r.webkitTransform!=="none"||"mixBlendMode"in r&&r.mixBlendMode!=="normal"||"filter"in r&&r.filter!=="none"||"webkitFilter"in r&&r.webkitFilter!=="none"||"isolation"in r&&r.isolation==="isolate"||Mc.test(r.willChange)||r.webkitOverflowScrolling==="touch")}function Da(e){let r=e.length;for(;r--;){const n=e[r];if(Ee(n,"Missing node"),_c(n))return n}return null}function Ba(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Ga(e){const r=[];for(;e;)r.push(e),e=po(e);return r}function po(e){const{parentNode:r}=e;return r&&r instanceof ShadowRoot?r.host:r}const fo=1,go=2,xo=4,bo=8,Dc=Pc()==="coarse";let pt=[],lr=!1,Lt=new Map,rn=new Map;const Cr=new Set;function Bc(e,r,n,a,s){var o;const{ownerDocument:l}=r,i={direction:n,element:r,hitAreaMargins:a,setResizeHandlerState:s},d=(o=Lt.get(l))!==null&&o!==void 0?o:0;return Lt.set(l,d+1),Cr.add(i),Kr(),function(){var u;rn.delete(e),Cr.delete(i);const m=(u=Lt.get(l))!==null&&u!==void 0?u:1;if(Lt.set(l,m-1),Kr(),m===1&&Lt.delete(l),pt.includes(i)){const f=pt.indexOf(i);f>=0&&pt.splice(f,1),nn(),s("up",!0,null)}}}function Gc(e){const{target:r}=e,{x:n,y:a}=tn(e);lr=!0,sa({target:r,x:n,y:a}),Kr(),pt.length>0&&(Xr("down",e),nn(),e.preventDefault(),vo(r)||e.stopImmediatePropagation())}function wn(e){const{x:r,y:n}=tn(e);if(lr&&e.type!=="pointerleave"&&e.buttons===0&&(lr=!1,Xr("up",e)),!lr){const{target:a}=e;sa({target:a,x:r,y:n})}Xr("move",e),nn(),pt.length>0&&e.preventDefault()}function yn(e){const{target:r}=e,{x:n,y:a}=tn(e);rn.clear(),lr=!1,pt.length>0&&(e.preventDefault(),vo(r)||e.stopImmediatePropagation()),Xr("up",e),sa({target:r,x:n,y:a}),nn(),Kr()}function vo(e){let r=e;for(;r;){if(r.hasAttribute(qe.resizeHandle))return!0;r=r.parentElement}return!1}function sa({target:e,x:r,y:n}){pt.splice(0);let a=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(a=e),Cr.forEach(s=>{const{element:o,hitAreaMargins:l}=s,i=o.getBoundingClientRect(),{bottom:d,left:h,right:u,top:m}=i,f=Dc?l.coarse:l.fine;if(r>=h-f&&r<=u+f&&n>=m-f&&n<=d+f){if(a!==null&&document.contains(a)&&o!==a&&!o.contains(a)&&!a.contains(o)&&Ac(a,o)>0){let g=a,k=!1;for(;g&&!g.contains(o);){if(Rc(g.getBoundingClientRect(),i)){k=!0;break}g=g.parentElement}if(k)return}pt.push(s)}})}function jn(e,r){rn.set(e,r)}function nn(){let e=!1,r=!1;pt.forEach(a=>{const{direction:s}=a;s==="horizontal"?e=!0:r=!0});let n=0;rn.forEach(a=>{n|=a}),e&&r?kn("intersection",n):e?kn("horizontal",n):r?kn("vertical",n):zc()}let Nn;function Kr(){var e;(e=Nn)===null||e===void 0||e.abort(),Nn=new AbortController;const r={capture:!0,signal:Nn.signal};Cr.size&&(lr?(pt.length>0&&Lt.forEach((n,a)=>{const{body:s}=a;n>0&&(s.addEventListener("contextmenu",yn,r),s.addEventListener("pointerleave",wn,r),s.addEventListener("pointermove",wn,r))}),Lt.forEach((n,a)=>{const{body:s}=a;s.addEventListener("pointerup",yn,r),s.addEventListener("pointercancel",yn,r)})):Lt.forEach((n,a)=>{const{body:s}=a;n>0&&(s.addEventListener("pointerdown",Gc,r),s.addEventListener("pointermove",wn,r))}))}function Xr(e,r){Cr.forEach(n=>{const{setResizeHandlerState:a}=n,s=pt.includes(n);a(e,s,r)})}function Fc(){const[e,r]=c.useState(0);return c.useCallback(()=>r(n=>n+1),[])}function Ee(e,r){if(!e)throw console.error(r),Error(r)}function Vt(e,r,n=na){return e.toFixed(n)===r.toFixed(n)?0:e>r?1:-1}function Nt(e,r,n=na){return Vt(e,r,n)===0}function ht(e,r,n){return Vt(e,r,n)===0}function Hc(e,r,n){if(e.length!==r.length)return!1;for(let a=0;a<e.length;a++){const s=e[a],o=r[a];if(!ht(s,o,n))return!1}return!0}function sr({panelConstraints:e,panelIndex:r,size:n}){const a=e[r];Ee(a!=null,`Panel constraints not found for index ${r}`);let{collapsedSize:s=0,collapsible:o,maxSize:l=100,minSize:i=0}=a;if(Vt(n,i)<0)if(o){const d=(s+i)/2;Vt(n,d)<0?n=s:n=i}else n=i;return n=Math.min(l,n),n=parseFloat(n.toFixed(na)),n}function kr({delta:e,initialLayout:r,panelConstraints:n,pivotIndices:a,prevLayout:s,trigger:o}){if(ht(e,0))return r;const l=[...r],[i,d]=a;Ee(i!=null,"Invalid first pivot index"),Ee(d!=null,"Invalid second pivot index");let h=0;if(o==="keyboard"){{const m=e<0?d:i,f=n[m];Ee(f,`Panel constraints not found for index ${m}`);const{collapsedSize:p=0,collapsible:g,minSize:k=0}=f;if(g){const w=r[m];if(Ee(w!=null,`Previous layout not found for panel index ${m}`),ht(w,p)){const x=k-w;Vt(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}{const m=e<0?i:d,f=n[m];Ee(f,`No panel constraints found for index ${m}`);const{collapsedSize:p=0,collapsible:g,minSize:k=0}=f;if(g){const w=r[m];if(Ee(w!=null,`Previous layout not found for panel index ${m}`),ht(w,k)){const x=w-p;Vt(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}}{const m=e<0?1:-1;let f=e<0?d:i,p=0;for(;;){const k=r[f];Ee(k!=null,`Previous layout not found for panel index ${f}`);const x=sr({panelConstraints:n,panelIndex:f,size:100})-k;if(p+=x,f+=m,f<0||f>=n.length)break}const g=Math.min(Math.abs(e),Math.abs(p));e=e<0?0-g:g}{let f=e<0?i:d;for(;f>=0&&f<n.length;){const p=Math.abs(e)-Math.abs(h),g=r[f];Ee(g!=null,`Previous layout not found for panel index ${f}`);const k=g-p,w=sr({panelConstraints:n,panelIndex:f,size:k});if(!ht(g,w)&&(h+=g-w,l[f]=w,h.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?f--:f++}}if(Hc(s,l))return s;{const m=e<0?d:i,f=r[m];Ee(f!=null,`Previous layout not found for panel index ${m}`);const p=f+h,g=sr({panelConstraints:n,panelIndex:m,size:p});if(l[m]=g,!ht(g,p)){let k=p-g,x=e<0?d:i;for(;x>=0&&x<n.length;){const j=l[x];Ee(j!=null,`Previous layout not found for panel index ${x}`);const y=j+k,b=sr({panelConstraints:n,panelIndex:x,size:y});if(ht(j,b)||(k-=b-j,l[x]=b),ht(k,0))break;e>0?x--:x++}}}const u=l.reduce((m,f)=>f+m,0);return ht(u,100)?l:s}function Oc({layout:e,panelsArray:r,pivotIndices:n}){let a=0,s=100,o=0,l=0;const i=n[0];Ee(i!=null,"No pivot index found"),r.forEach((m,f)=>{const{constraints:p}=m,{maxSize:g=100,minSize:k=0}=p;f===i?(a=k,s=g):(o+=k,l+=g)});const d=Math.min(s,100-o),h=Math.max(a,100-l),u=e[i];return{valueMax:d,valueMin:h,valueNow:u}}function Sr(e,r=document){return Array.from(r.querySelectorAll(`[${qe.resizeHandleId}][data-panel-group-id="${e}"]`))}function ko(e,r,n=document){const s=Sr(e,n).findIndex(o=>o.getAttribute(qe.resizeHandleId)===r);return s??null}function wo(e,r,n){const a=ko(e,r,n);return a!=null?[a,a+1]:[-1,-1]}function Wc(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function yo(e,r=document){if(Wc(r)&&r.dataset.panelGroupId==e)return r;const n=r.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function an(e,r=document){const n=r.querySelector(`[${qe.resizeHandleId}="${e}"]`);return n||null}function Uc(e,r,n,a=document){var s,o,l,i;const d=an(r,a),h=Sr(e,a),u=d?h.indexOf(d):-1,m=(s=(o=n[u])===null||o===void 0?void 0:o.id)!==null&&s!==void 0?s:null,f=(l=(i=n[u+1])===null||i===void 0?void 0:i.id)!==null&&l!==void 0?l:null;return[m,f]}function Vc({committedValuesRef:e,eagerValuesRef:r,groupId:n,layout:a,panelDataArray:s,panelGroupElement:o,setLayout:l}){c.useRef({didWarnAboutMissingResizeHandle:!1}),Wt(()=>{if(!o)return;const i=Sr(n,o);for(let d=0;d<s.length-1;d++){const{valueMax:h,valueMin:u,valueNow:m}=Oc({layout:a,panelsArray:s,pivotIndices:[d,d+1]}),f=i[d];if(f!=null){const p=s[d];Ee(p,`No panel data found for index "${d}"`),f.setAttribute("aria-controls",p.id),f.setAttribute("aria-valuemax",""+Math.round(h)),f.setAttribute("aria-valuemin",""+Math.round(u)),f.setAttribute("aria-valuenow",m!=null?""+Math.round(m):"")}}return()=>{i.forEach((d,h)=>{d.removeAttribute("aria-controls"),d.removeAttribute("aria-valuemax"),d.removeAttribute("aria-valuemin"),d.removeAttribute("aria-valuenow")})}},[n,a,s,o]),c.useEffect(()=>{if(!o)return;const i=r.current;Ee(i,"Eager values not found");const{panelDataArray:d}=i,h=yo(n,o);Ee(h!=null,`No group found for id "${n}"`);const u=Sr(n,o);Ee(u,`No resize handles found for group id "${n}"`);const m=u.map(f=>{const p=f.getAttribute(qe.resizeHandleId);Ee(p,"Resize handle element has no handle id attribute");const[g,k]=Uc(n,p,d,o);if(g==null||k==null)return()=>{};const w=x=>{if(!x.defaultPrevented)switch(x.key){case"Enter":{x.preventDefault();const j=d.findIndex(y=>y.id===g);if(j>=0){const y=d[j];Ee(y,`No panel data found for index ${j}`);const b=a[j],{collapsedSize:v=0,collapsible:S,minSize:N=0}=y.constraints;if(b!=null&&S){const L=kr({delta:ht(b,v)?N-v:v-b,initialLayout:a,panelConstraints:d.map(R=>R.constraints),pivotIndices:wo(n,p,o),prevLayout:a,trigger:"keyboard"});a!==L&&l(L)}}break}}};return f.addEventListener("keydown",w),()=>{f.removeEventListener("keydown",w)}});return()=>{m.forEach(f=>f())}},[o,e,r,n,a,s,l])}function Fa(e,r){if(e.length!==r.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==r[n])return!1;return!0}function jo(e,r){const n=e==="horizontal",{x:a,y:s}=tn(r);return n?a:s}function qc(e,r,n,a,s){const o=n==="horizontal",l=an(r,s);Ee(l,`No resize handle element found for id "${r}"`);const i=l.getAttribute(qe.groupId);Ee(i,"Resize handle element has no group id attribute");let{initialCursorPosition:d}=a;const h=jo(n,e),u=yo(i,s);Ee(u,`No group element found for id "${i}"`);const m=u.getBoundingClientRect(),f=o?m.width:m.height;return(h-d)/f*100}function Kc(e,r,n,a,s,o){if(ho(e)){const l=n==="horizontal";let i=0;e.shiftKey?i=100:s!=null?i=s:i=10;let d=0;switch(e.key){case"ArrowDown":d=l?0:i;break;case"ArrowLeft":d=l?-i:0;break;case"ArrowRight":d=l?i:0;break;case"ArrowUp":d=l?0:-i;break;case"End":d=100;break;case"Home":d=-100;break}return d}else return a==null?0:qc(e,r,n,a,o)}function Xc({panelDataArray:e}){const r=Array(e.length),n=e.map(o=>o.constraints);let a=0,s=100;for(let o=0;o<e.length;o++){const l=n[o];Ee(l,`Panel constraints not found for index ${o}`);const{defaultSize:i}=l;i!=null&&(a++,r[o]=i,s-=i)}for(let o=0;o<e.length;o++){const l=n[o];Ee(l,`Panel constraints not found for index ${o}`);const{defaultSize:i}=l;if(i!=null)continue;const d=e.length-a,h=s/d;a++,r[o]=h,s-=h}return r}function Qt(e,r,n){r.forEach((a,s)=>{const o=e[s];Ee(o,`Panel data not found for index ${s}`);const{callbacks:l,constraints:i,id:d}=o,{collapsedSize:h=0,collapsible:u}=i,m=n[d];if(m==null||a!==m){n[d]=a;const{onCollapse:f,onExpand:p,onResize:g}=l;g&&g(a,m),u&&(f||p)&&(p&&(m==null||Nt(m,h))&&!Nt(a,h)&&p(),f&&(m==null||!Nt(m,h))&&Nt(a,h)&&f())}})}function $r(e,r){if(e.length!==r.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=r[n])return!1;return!0}function Yc({defaultSize:e,dragState:r,layout:n,panelData:a,panelIndex:s,precision:o=3}){const l=n[s];let i;return l==null?i=e!=null?e.toFixed(o):"1":a.length===1?i="1":i=l.toFixed(o),{flexBasis:0,flexGrow:i,flexShrink:1,overflow:"hidden",pointerEvents:r!==null?"none":void 0}}function Zc(e,r=10){let n=null;return(...s)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...s)},r)}}function Ha(e){try{if(typeof localStorage<"u")e.getItem=r=>localStorage.getItem(r),e.setItem=(r,n)=>{localStorage.setItem(r,n)};else throw new Error("localStorage not supported in this environment")}catch(r){console.error(r),e.getItem=()=>null,e.setItem=()=>{}}}function No(e){return`react-resizable-panels:${e}`}function Co(e){return e.map(r=>{const{constraints:n,id:a,idIsFromProps:s,order:o}=r;return s?a:o?`${o}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((r,n)=>r.localeCompare(n)).join(",")}function So(e,r){try{const n=No(e),a=r.getItem(n);if(a){const s=JSON.parse(a);if(typeof s=="object"&&s!=null)return s}}catch{}return null}function Jc(e,r,n){var a,s;const o=(a=So(e,n))!==null&&a!==void 0?a:{},l=Co(r);return(s=o[l])!==null&&s!==void 0?s:null}function Qc(e,r,n,a,s){var o;const l=No(e),i=Co(r),d=(o=So(e,s))!==null&&o!==void 0?o:{};d[i]={expandToSizes:Object.fromEntries(n.entries()),layout:a};try{s.setItem(l,JSON.stringify(d))}catch(h){console.error(h)}}function Oa({layout:e,panelConstraints:r}){const n=[...e],a=n.reduce((o,l)=>o+l,0);if(n.length!==r.length)throw Error(`Invalid ${r.length} panel layout: ${n.map(o=>`${o}%`).join(", ")}`);if(!ht(a,100)&&n.length>0)for(let o=0;o<r.length;o++){const l=n[o];Ee(l!=null,`No layout data found for index ${o}`);const i=100/a*l;n[o]=i}let s=0;for(let o=0;o<r.length;o++){const l=n[o];Ee(l!=null,`No layout data found for index ${o}`);const i=sr({panelConstraints:r,panelIndex:o,size:l});l!=i&&(s+=l-i,n[o]=i)}if(!ht(s,0))for(let o=0;o<r.length;o++){const l=n[o];Ee(l!=null,`No layout data found for index ${o}`);const i=l+s,d=sr({panelConstraints:r,panelIndex:o,size:i});if(l!==d&&(s-=d-l,n[o]=d,ht(s,0)))break}return n}const eh=100,wr={getItem:e=>(Ha(wr),wr.getItem(e)),setItem:(e,r)=>{Ha(wr),wr.setItem(e,r)}},Wa={};function To({autoSaveId:e=null,children:r,className:n="",direction:a,forwardedRef:s,id:o=null,onLayout:l=null,keyboardResizeBy:i=null,storage:d=wr,style:h,tagName:u="div",...m}){const f=aa(o),p=c.useRef(null),[g,k]=c.useState(null),[w,x]=c.useState([]),j=Fc(),y=c.useRef({}),b=c.useRef(new Map),v=c.useRef(0),S=c.useRef({autoSaveId:e,direction:a,dragState:g,id:f,keyboardResizeBy:i,onLayout:l,storage:d}),N=c.useRef({layout:w,panelDataArray:[],panelDataArrayChanged:!1});c.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),c.useImperativeHandle(s,()=>({getId:()=>S.current.id,getLayout:()=>{const{layout:T}=N.current;return T},setLayout:T=>{const{onLayout:F}=S.current,{layout:B,panelDataArray:E}=N.current,C=Oa({layout:T,panelConstraints:E.map(W=>W.constraints)});Fa(B,C)||(x(C),N.current.layout=C,F&&F(C),Qt(E,C,y.current))}}),[]),Wt(()=>{S.current.autoSaveId=e,S.current.direction=a,S.current.dragState=g,S.current.id=f,S.current.onLayout=l,S.current.storage=d}),Vc({committedValuesRef:S,eagerValuesRef:N,groupId:f,layout:w,panelDataArray:N.current.panelDataArray,setLayout:x,panelGroupElement:p.current}),c.useEffect(()=>{const{panelDataArray:T}=N.current;if(e){if(w.length===0||w.length!==T.length)return;let F=Wa[e];F==null&&(F=Zc(Qc,eh),Wa[e]=F);const B=[...T],E=new Map(b.current);F(e,B,E,w,d)}},[e,w,d]),c.useEffect(()=>{});const L=c.useCallback(T=>{const{onLayout:F}=S.current,{layout:B,panelDataArray:E}=N.current;if(T.constraints.collapsible){const C=E.map(K=>K.constraints),{collapsedSize:W=0,panelSize:U,pivotIndices:ae}=Dt(E,T,B);if(Ee(U!=null,`Panel size not found for panel "${T.id}"`),!Nt(U,W)){b.current.set(T.id,U);const de=tr(E,T)===E.length-1?U-W:W-U,ee=kr({delta:de,initialLayout:B,panelConstraints:C,pivotIndices:ae,prevLayout:B,trigger:"imperative-api"});$r(B,ee)||(x(ee),N.current.layout=ee,F&&F(ee),Qt(E,ee,y.current))}}},[]),R=c.useCallback((T,F)=>{const{onLayout:B}=S.current,{layout:E,panelDataArray:C}=N.current;if(T.constraints.collapsible){const W=C.map(ke=>ke.constraints),{collapsedSize:U=0,panelSize:ae=0,minSize:K=0,pivotIndices:de}=Dt(C,T,E),ee=F??K;if(Nt(ae,U)){const ke=b.current.get(T.id),le=ke!=null&&ke>=ee?ke:ee,Ae=tr(C,T)===C.length-1?ae-le:le-ae,ce=kr({delta:Ae,initialLayout:E,panelConstraints:W,pivotIndices:de,prevLayout:E,trigger:"imperative-api"});$r(E,ce)||(x(ce),N.current.layout=ce,B&&B(ce),Qt(C,ce,y.current))}}},[]),P=c.useCallback(T=>{const{layout:F,panelDataArray:B}=N.current,{panelSize:E}=Dt(B,T,F);return Ee(E!=null,`Panel size not found for panel "${T.id}"`),E},[]),Q=c.useCallback((T,F)=>{const{panelDataArray:B}=N.current,E=tr(B,T);return Yc({defaultSize:F,dragState:g,layout:w,panelData:B,panelIndex:E})},[g,w]),D=c.useCallback(T=>{const{layout:F,panelDataArray:B}=N.current,{collapsedSize:E=0,collapsible:C,panelSize:W}=Dt(B,T,F);return Ee(W!=null,`Panel size not found for panel "${T.id}"`),C===!0&&Nt(W,E)},[]),Z=c.useCallback(T=>{const{layout:F,panelDataArray:B}=N.current,{collapsedSize:E=0,collapsible:C,panelSize:W}=Dt(B,T,F);return Ee(W!=null,`Panel size not found for panel "${T.id}"`),!C||Vt(W,E)>0},[]),J=c.useCallback(T=>{const{panelDataArray:F}=N.current;F.push(T),F.sort((B,E)=>{const C=B.order,W=E.order;return C==null&&W==null?0:C==null?-1:W==null?1:C-W}),N.current.panelDataArrayChanged=!0,j()},[j]);Wt(()=>{if(N.current.panelDataArrayChanged){N.current.panelDataArrayChanged=!1;const{autoSaveId:T,onLayout:F,storage:B}=S.current,{layout:E,panelDataArray:C}=N.current;let W=null;if(T){const ae=Jc(T,C,B);ae&&(b.current=new Map(Object.entries(ae.expandToSizes)),W=ae.layout)}W==null&&(W=Xc({panelDataArray:C}));const U=Oa({layout:W,panelConstraints:C.map(ae=>ae.constraints)});Fa(E,U)||(x(U),N.current.layout=U,F&&F(U),Qt(C,U,y.current))}}),Wt(()=>{const T=N.current;return()=>{T.layout=[]}},[]);const z=c.useCallback(T=>{let F=!1;const B=p.current;return B&&window.getComputedStyle(B,null).getPropertyValue("direction")==="rtl"&&(F=!0),function(C){C.preventDefault();const W=p.current;if(!W)return()=>null;const{direction:U,dragState:ae,id:K,keyboardResizeBy:de,onLayout:ee}=S.current,{layout:ke,panelDataArray:le}=N.current,{initialLayout:je}=ae??{},Ae=wo(K,T,W);let ce=Kc(C,T,U,ae,de,W);const ne=U==="horizontal";ne&&F&&(ce=-ce);const Le=le.map(we=>we.constraints),Y=kr({delta:ce,initialLayout:je??ke,panelConstraints:Le,pivotIndices:Ae,prevLayout:ke,trigger:ho(C)?"keyboard":"mouse-or-touch"}),me=!$r(ke,Y);(uo(C)||mo(C))&&v.current!=ce&&(v.current=ce,!me&&ce!==0?ne?jn(T,ce<0?fo:go):jn(T,ce<0?xo:bo):jn(T,0)),me&&(x(Y),N.current.layout=Y,ee&&ee(Y),Qt(le,Y,y.current))}},[]),te=c.useCallback((T,F)=>{const{onLayout:B}=S.current,{layout:E,panelDataArray:C}=N.current,W=C.map(ke=>ke.constraints),{panelSize:U,pivotIndices:ae}=Dt(C,T,E);Ee(U!=null,`Panel size not found for panel "${T.id}"`);const de=tr(C,T)===C.length-1?U-F:F-U,ee=kr({delta:de,initialLayout:E,panelConstraints:W,pivotIndices:ae,prevLayout:E,trigger:"imperative-api"});$r(E,ee)||(x(ee),N.current.layout=ee,B&&B(ee),Qt(C,ee,y.current))},[]),se=c.useCallback((T,F)=>{const{layout:B,panelDataArray:E}=N.current,{collapsedSize:C=0,collapsible:W}=F,{collapsedSize:U=0,collapsible:ae,maxSize:K=100,minSize:de=0}=T.constraints,{panelSize:ee}=Dt(E,T,B);ee!=null&&(W&&ae&&Nt(ee,C)?Nt(C,U)||te(T,U):ee<de?te(T,de):ee>K&&te(T,K))},[te]),_=c.useCallback((T,F)=>{const{direction:B}=S.current,{layout:E}=N.current;if(!p.current)return;const C=an(T,p.current);Ee(C,`Drag handle element not found for id "${T}"`);const W=jo(B,F);k({dragHandleId:T,dragHandleRect:C.getBoundingClientRect(),initialCursorPosition:W,initialLayout:E})},[]),ie=c.useCallback(()=>{k(null)},[]),q=c.useCallback(T=>{const{panelDataArray:F}=N.current,B=tr(F,T);B>=0&&(F.splice(B,1),delete y.current[T.id],N.current.panelDataArrayChanged=!0,j())},[j]),H=c.useMemo(()=>({collapsePanel:L,direction:a,dragState:g,expandPanel:R,getPanelSize:P,getPanelStyle:Q,groupId:f,isPanelCollapsed:D,isPanelExpanded:Z,reevaluatePanelConstraints:se,registerPanel:J,registerResizeHandle:z,resizePanel:te,startDragging:_,stopDragging:ie,unregisterPanel:q,panelGroupElement:p.current}),[L,g,a,R,P,Q,f,D,Z,se,J,z,te,_,ie,q]),G={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return c.createElement(en.Provider,{value:H},c.createElement(u,{...m,children:r,className:n,id:o,ref:p,style:{...G,...h},[qe.group]:"",[qe.groupDirection]:a,[qe.groupId]:f}))}const Eo=c.forwardRef((e,r)=>c.createElement(To,{...e,forwardedRef:r}));To.displayName="PanelGroup";Eo.displayName="forwardRef(PanelGroup)";function tr(e,r){return e.findIndex(n=>n===r||n.id===r.id)}function Dt(e,r,n){const a=tr(e,r),o=a===e.length-1?[a-1,a]:[a,a+1],l=n[a];return{...r.constraints,panelSize:l,pivotIndices:o}}function th({disabled:e,handleId:r,resizeHandler:n,panelGroupElement:a}){c.useEffect(()=>{if(e||n==null||a==null)return;const s=an(r,a);if(s==null)return;const o=l=>{if(!l.defaultPrevented)switch(l.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{l.preventDefault(),n(l);break}case"F6":{l.preventDefault();const i=s.getAttribute(qe.groupId);Ee(i,`No group element found for id "${i}"`);const d=Sr(i,a),h=ko(i,r,a);Ee(h!==null,`No resize element found for id "${r}"`);const u=l.shiftKey?h>0?h-1:d.length-1:h+1<d.length?h+1:0;d[u].focus();break}}};return s.addEventListener("keydown",o),()=>{s.removeEventListener("keydown",o)}},[a,e,r,n])}function Lo({children:e=null,className:r="",disabled:n=!1,hitAreaMargins:a,id:s,onBlur:o,onClick:l,onDragging:i,onFocus:d,onPointerDown:h,onPointerUp:u,style:m={},tabIndex:f=0,tagName:p="div",...g}){var k,w;const x=c.useRef(null),j=c.useRef({onClick:l,onDragging:i,onPointerDown:h,onPointerUp:u});c.useEffect(()=>{j.current.onClick=l,j.current.onDragging=i,j.current.onPointerDown=h,j.current.onPointerUp=u});const y=c.useContext(en);if(y===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:b,groupId:v,registerResizeHandle:S,startDragging:N,stopDragging:L,panelGroupElement:R}=y,P=aa(s),[Q,D]=c.useState("inactive"),[Z,J]=c.useState(!1),[z,te]=c.useState(null),se=c.useRef({state:Q});Wt(()=>{se.current.state=Q}),c.useEffect(()=>{if(n)te(null);else{const H=S(P);te(()=>H)}},[n,P,S]);const _=(k=a==null?void 0:a.coarse)!==null&&k!==void 0?k:15,ie=(w=a==null?void 0:a.fine)!==null&&w!==void 0?w:5;c.useEffect(()=>{if(n||z==null)return;const H=x.current;Ee(H,"Element ref not attached");let G=!1;return Bc(P,H,b,{coarse:_,fine:ie},(F,B,E)=>{if(!B){D("inactive");return}switch(F){case"down":{D("drag"),G=!1,Ee(E,'Expected event to be defined for "down" action'),N(P,E);const{onDragging:C,onPointerDown:W}=j.current;C==null||C(!0),W==null||W();break}case"move":{const{state:C}=se.current;G=!0,C!=="drag"&&D("hover"),Ee(E,'Expected event to be defined for "move" action'),z(E);break}case"up":{D("hover"),L();const{onClick:C,onDragging:W,onPointerUp:U}=j.current;W==null||W(!1),U==null||U(),G||C==null||C();break}}})},[_,b,n,ie,S,P,z,N,L]),th({disabled:n,handleId:P,resizeHandler:z,panelGroupElement:R});const q={touchAction:"none",userSelect:"none"};return c.createElement(p,{...g,children:e,className:r,id:s,onBlur:()=>{J(!1),o==null||o()},onFocus:()=>{J(!0),d==null||d()},ref:x,role:"separator",style:{...q,...m},tabIndex:f,[qe.groupDirection]:b,[qe.groupId]:v,[qe.resizeHandle]:"",[qe.resizeHandleActive]:Q==="drag"?"pointer":Z?"keyboard":void 0,[qe.resizeHandleEnabled]:!n,[qe.resizeHandleId]:P,[qe.resizeHandleState]:Q})}Lo.displayName="PanelResizeHandle";var rh=Object.defineProperty,nh=Object.getOwnPropertyNames,He=(e,r)=>function(){return e&&(r=(0,e[nh(e)[0]])(e=0)),r},ah=(e,r)=>{for(var n in r)rh(e,n,{get:r[n],enumerable:!0})};function at(...e){return Tc(qs(e))}var Pt=He({"src/components/graph-ui/utils.ts"(){}});function Tr({asChild:e=!1,className:r,size:n,variant:a,...s}){const o=e?Os:"button";return t.jsx(o,{"data-slot":"button",className:at(Io({variant:a,size:n,className:r})),...s})}var Io,sn=He({"src/components/graph-ui/Button.tsx"(){Pt(),Io=Er("inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium outline-none transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}})}});function zo(...e){return e.filter(Boolean).join(" ")}function _n({className:e,...r}){return t.jsx(Eo,{"data-slot":"resizable-panel-group",className:zo("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...r})}function or({...e}){return t.jsx(co,{"data-slot":"resizable-panel",...e})}function Dn({withHandle:e,className:r,...n}){return t.jsx(Lo,{"data-slot":"resizable-handle",className:zo("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",r),...n,children:e?t.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:t.jsx($.GripVerticalIcon,{className:"size-2.5"})}):null})}var Po=He({"src/components/graph-workspace/GraphResizablePanels.tsx"(){}});function oa(...e){return e.filter(Boolean).join(" ")}function Lr({...e}){return t.jsx(Qi,{"data-slot":"accordion",...e})}function Ir({className:e,...r}){return t.jsx(ed,{"data-slot":"accordion-item",className:oa("border-b last:border-b-0",e),...r})}function on({className:e,children:r,...n}){return t.jsx(rd,{className:"flex",children:t.jsxs(nd,{"data-slot":"accordion-trigger",className:oa("flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium outline-none transition-all hover:underline disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",e),...n,children:[r,t.jsx($.ChevronDownIcon,{className:"pointer-events-none size-4 shrink-0 translate-y-0.5 text-[var(--theme-fg-muted)] transition-transform duration-200"})]})})}function zr({className:e,children:r,...n}){return t.jsx(td,{"data-slot":"accordion-content",className:"overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:t.jsx("div",{className:oa("pb-4 pt-0",e),children:r})})}var Pr=He({"src/components/graph-workspace/GraphAccordion.tsx"(){}});function sh(e){var n;const r=[];for(const a of e.turns)for(const s of a.items)s.kind==="artifact"&&s.artifact&&r.push(s.artifact);for(const a of((n=e.liveItems)==null?void 0:n.items)??[])a.kind==="artifact"&&a.artifact&&r.push(a.artifact);return r}function oh(e){return e.trim().replace(/^\/+|\/+$/g,"").replace(/[^\w.-]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function Rr(e){var r;return((r=e.split(".").pop())==null?void 0:r.toLowerCase())||""}function lh(e){return e.split("/").filter(Boolean).at(-1)??e}function rr(e){const r=e.kind==="directory"?"directory":"file",n=(e.children??[]).map(rr);return{id:`workspace:${e.path}`,name:e.name,path:e.path,kind:r,...e.size!==void 0?{size:e.size}:{},...e.hasChildren!==void 0?{hasChildren:e.hasChildren}:r==="directory"?{hasChildren:n.length>0}:{},...e.childrenLoaded!==void 0?{childrenLoaded:e.childrenLoaded}:r==="directory"?{childrenLoaded:e.children!==void 0}:{},...e.truncated!==void 0?{truncated:e.truncated}:{},workspaceNode:e,children:n}}function Ro(e,r,n,a={}){if(e.path===r)return{...e,children:n,hasChildren:n.length>0,childrenLoaded:!0,truncated:a.truncated??e.truncated};if(e.children.length===0)return e;let s=!1;const o=e.children.map(l=>{const i=Ro(l,r,n,a);return i!==l&&(s=!0),i});return s?{...e,children:o}:e}function Ao(e){if(e.kind==="file")return e;for(const r of e.children){const n=Ao(r);if(n)return n}return null}function Bn(e,r){if(!e||r===null)return null;if(e.path===r)return e;for(const n of e.children){const a=Bn(n,r);if(a)return a}return null}function Mo(e){return e.trim().replace(/\\/g,"/").replace(/^\.\/+/,"").replace(/^\/+/,"")}function ih(e){const n=Mo(e).split("/").filter(Boolean);n.pop();const a=[];let s="";for(const o of n)s=s?`${s}/${o}`:o,a.push(s);return a}function Gn(e,r,n){if(e.path===r)return n;if(e.children.length===0)return e;let a=!1;const s=e.children.map(o=>{const l=Gn(o,r,n);return l!==o&&(a=!0),l});return a?{...e,children:s}:e}function Fn(e,r){return!e||!r?!1:e.path===r?!0:e.children.some(n=>Fn(n,r))}function dh(e){if(!e)return null;const r=Rr(e.path);return la.has(r)?{content:[e.content.endsWith(`
|
|
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","assets/styles-BEieA99i.css","assets/frontend-DNAQzqc-.js","assets/ui-vendor-CuR8GHb0.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{l as _,R as nd,I as ad,C as sd,S as Us,H as od,T as ld,a as id,b as dd,c as cd,d as hd,e as ud,D as md,P as pd,O as fd,f as gd,g as xd,h as bd,i as vd,j as kd,k as wd,m as yd,n as jd,A as Nd,o as Cd,p as Sd}from"./ui-vendor-CuR8GHb0.js";import{r as c,R as Td,j as t,b as Qr}from"./react-vendor-Dfg_6BLf.js";import{u as Ed,a as Ld,H as Ea,P as Ft,b as Id,M as Vs,R as zd,i as Pd,C as Rd,B as Ad,c as La,g as qs}from"./graph-vendor-DVQUpZ8C.js";import"./terminal-vendor-C5bTa-Ka.js";import{M as Md,r as _d,a as $d,b as Dd}from"./markdown-vendor-RZk8L7-L.js";const Bd="modulepreload",Gd=function(e){return"/"+e},Ia={},Ve=function(r,n,a){let s=Promise.resolve();if(n&&n.length>0){let l=function(h){return Promise.all(h.map(u=>Promise.resolve(u).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),d=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));s=l(n.map(h=>{if(h=Gd(h),h in Ia)return;Ia[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":Bd,u||(f.as="script"),f.crossOrigin="",f.href=h,d&&f.setAttribute("nonce",d),document.head.appendChild(f),u)return new Promise((p,g)=>{f.addEventListener("load",p),f.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${h}`)))})}))}function o(l){const i=new Event("vite:preloadError",{cancelable:!0});if(i.payload=l,window.dispatchEvent(i),!i.defaultPrevented)throw l}return s.then(l=>{for(const i of l||[])i.status==="rejected"&&o(i.reason);return r().catch(o)})};function Xs(e){var r,n,a="";if(typeof e=="string"||typeof e=="number")a+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(r=0;r<s;r++)e[r]&&(n=Xs(e[r]))&&(a&&(a+=" "),a+=n)}else for(n in e)e[n]&&(a&&(a+=" "),a+=n);return a}function Ks(){for(var e,r,n=0,a="",s=arguments.length;n<s;n++)(e=arguments[n])&&(r=Xs(e))&&(a&&(a+=" "),a+=r);return a}const Fd=(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},Hd=(e,r)=>({classGroupId:e,validator:r}),Ys=(e=new Map,r=null,n)=>({nextPart:e,validators:r,classGroupId:n}),qr="-",za=[],Od="arbitrary..",Wd=e=>{const r=Vd(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:a}=e;return{getClassGroupId:l=>{if(l.startsWith("[")&&l.endsWith("]"))return Ud(l);const i=l.split(qr),d=i[0]===""&&i.length>1?1:0;return Zs(i,d,r)},getConflictingClassGroupIds:(l,i)=>{if(i){const d=a[l],h=n[l];return d?h?Fd(h,d):d:h||za}return n[l]||za}}},Zs=(e,r,n)=>{if(e.length-r===0)return n.classGroupId;const s=e[r],o=n.nextPart.get(s);if(o){const h=Zs(e,r+1,o);if(h)return h}const l=n.validators;if(l===null)return;const i=r===0?e.join(qr):e.slice(r).join(qr),d=l.length;for(let h=0;h<d;h++){const u=l[h];if(u.validator(i))return u.classGroupId}},Ud=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?Od+a:void 0})(),Vd=e=>{const{theme:r,classGroups:n}=e;return qd(n,r)},qd=(e,r)=>{const n=Ys();for(const a in e){const s=e[a];na(s,n,a,r)}return n},na=(e,r,n,a)=>{const s=e.length;for(let o=0;o<s;o++){const l=e[o];Xd(l,r,n,a)}},Xd=(e,r,n,a)=>{if(typeof e=="string"){Kd(e,r,n);return}if(typeof e=="function"){Yd(e,r,n,a);return}Zd(e,r,n,a)},Kd=(e,r,n)=>{const a=e===""?r:Js(r,e);a.classGroupId=n},Yd=(e,r,n,a)=>{if(Jd(e)){na(e(a),r,n,a);return}r.validators===null&&(r.validators=[]),r.validators.push(Hd(n,e))},Zd=(e,r,n,a)=>{const s=Object.entries(e),o=s.length;for(let l=0;l<o;l++){const[i,d]=s[l];na(d,Js(r,i),n,a)}},Js=(e,r)=>{let n=e;const a=r.split(qr),s=a.length;for(let o=0;o<s;o++){const l=a[o];let i=n.nextPart.get(l);i||(i=Ys(),n.nextPart.set(l,i)),n=i}return n},Jd=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Qd=e=>{if(e<1)return{get:()=>{},set:()=>{}};let r=0,n=Object.create(null),a=Object.create(null);const s=(o,l)=>{n[o]=l,r++,r>e&&(r=0,a=n,n=Object.create(null))};return{get(o){let l=n[o];if(l!==void 0)return l;if((l=a[o])!==void 0)return s(o,l),l},set(o,l){o in n?n[o]=l:s(o,l)}}},$n="!",Pa=":",ec=[],Ra=(e,r,n,a,s)=>({modifiers:e,hasImportantModifier:r,baseClassName:n,maybePostfixModifierPosition:a,isExternal:s}),tc=e=>{const{prefix:r,experimentalParseClassName:n}=e;let a=s=>{const o=[];let l=0,i=0,d=0,h;const u=s.length;for(let k=0;k<u;k++){const w=s[k];if(l===0&&i===0){if(w===Pa){o.push(s.slice(d,k)),d=k+1;continue}if(w==="/"){h=k;continue}}w==="["?l++:w==="]"?l--:w==="("?i++:w===")"&&i--}const m=o.length===0?s:s.slice(d);let f=m,p=!1;m.endsWith($n)?(f=m.slice(0,-1),p=!0):m.startsWith($n)&&(f=m.slice(1),p=!0);const g=h&&h>d?h-d:void 0;return Ra(o,p,f,g)};if(r){const s=r+Pa,o=a;a=l=>l.startsWith(s)?o(l.slice(s.length)):Ra(ec,!1,l,void 0,!0)}if(n){const s=a;a=o=>n({className:o,parseClassName:s})}return a},rc=e=>{const r=new Map;return e.orderSensitiveModifiers.forEach((n,a)=>{r.set(n,1e6+a)}),n=>{const a=[];let s=[];for(let o=0;o<n.length;o++){const l=n[o],i=l[0]==="[",d=r.has(l);i||d?(s.length>0&&(s.sort(),a.push(...s),s=[]),a.push(l)):s.push(l)}return s.length>0&&(s.sort(),a.push(...s)),a}},nc=e=>({cache:Qd(e.cacheSize),parseClassName:tc(e),sortModifiers:rc(e),postfixLookupClassGroupIds:ac(e),...Wd(e)}),ac=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},sc=/\s+/,oc=(e,r)=>{const{parseClassName:n,getClassGroupId:a,getConflictingClassGroupIds:s,sortModifiers:o,postfixLookupClassGroupIds:l}=r,i=[],d=e.trim().split(sc);let h="";for(let u=d.length-1;u>=0;u-=1){const m=d[u],{isExternal:f,modifiers:p,hasImportantModifier:g,baseClassName:k,maybePostfixModifierPosition:w}=n(m);if(f){h=m+(h.length>0?" "+h:h);continue}let x=!!w,j;if(x){const N=k.substring(0,w);j=a(N);const L=j&&l[j]?a(k):void 0;L&&L!==j&&(j=L,x=!1)}else j=a(k);if(!j){if(!x){h=m+(h.length>0?" "+h:h);continue}if(j=a(k),!j){h=m+(h.length>0?" "+h:h);continue}x=!1}const y=p.length===0?"":p.length===1?p[0]:o(p).join(":"),b=g?y+$n:y,v=b+j;if(i.indexOf(v)>-1)continue;i.push(v);const S=s(j,x);for(let N=0;N<S.length;++N){const L=S[N];i.push(b+L)}h=m+(h.length>0?" "+h:h)}return h},lc=(...e)=>{let r=0,n,a,s="";for(;r<e.length;)(n=e[r++])&&(a=Qs(n))&&(s&&(s+=" "),s+=a);return s},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},ic=(e,...r)=>{let n,a,s,o;const l=d=>{const h=r.reduce((u,m)=>m(u),e());return n=nc(h),a=n.cache.get,s=n.cache.set,o=i,i(d)},i=d=>{const h=a(d);if(h)return h;const u=oc(d,n);return s(d,u),u};return o=l,(...d)=>o(lc(...d))},dc=[],Je=e=>{const r=n=>n[e]||dc;return r.isThemeGetter=!0,r},eo=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,to=/^\((?:(\w[\w-]*):)?(.+)\)$/i,cc=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,hc=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,uc=/\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$/,mc=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,pc=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,fc=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,St=e=>cc.test(e),Ie=e=>!!e&&!Number.isNaN(Number(e)),bt=e=>!!e&&Number.isInteger(Number(e)),vn=e=>e.endsWith("%")&&Ie(e.slice(0,-1)),jt=e=>hc.test(e),ro=()=>!0,gc=e=>uc.test(e)&&!mc.test(e),aa=()=>!1,xc=e=>pc.test(e),bc=e=>fc.test(e),vc=e=>!ue(e)&&!pe(e),kc=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)),wc=e=>zt(e,so,aa),ue=e=>eo.test(e),$t=e=>zt(e,oo,gc),Aa=e=>zt(e,Lc,Ie),yc=e=>zt(e,io,ro),jc=e=>zt(e,lo,aa),Ma=e=>zt(e,no,aa),Nc=e=>zt(e,ao,bc),Ar=e=>zt(e,co,xc),pe=e=>to.test(e),fr=e=>qt(e,oo),Cc=e=>qt(e,lo),_a=e=>qt(e,no),Sc=e=>qt(e,so),Tc=e=>qt(e,ao),Mr=e=>qt(e,co,!0),Ec=e=>qt(e,io,!0),zt=(e,r,n)=>{const a=eo.exec(e);return a?a[1]?r(a[1]):n(a[2]):!1},qt=(e,r,n=!1)=>{const a=to.exec(e);return a?a[1]?r(a[1]):n:!1},no=e=>e==="position"||e==="percentage",ao=e=>e==="image"||e==="url",so=e=>e==="length"||e==="size"||e==="bg-size",oo=e=>e==="length",Lc=e=>e==="number",lo=e=>e==="family-name",io=e=>e==="number"||e==="weight",co=e=>e==="shadow",Ic=()=>{const e=Je("color"),r=Je("font"),n=Je("text"),a=Je("font-weight"),s=Je("tracking"),o=Je("leading"),l=Je("breakpoint"),i=Je("container"),d=Je("spacing"),h=Je("radius"),u=Je("shadow"),m=Je("inset-shadow"),f=Je("text-shadow"),p=Je("drop-shadow"),g=Je("blur"),k=Je("perspective"),w=Je("aspect"),x=Je("ease"),j=Je("animate"),y=()=>["auto","avoid","all","avoid-page","page","left","right","column"],b=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],v=()=>[...b(),pe,ue],S=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto","contain","none"],L=()=>[pe,ue,d],R=()=>[St,"full","auto",...L()],P=()=>[bt,"none","subgrid",pe,ue],Q=()=>["auto",{span:["full",bt,pe,ue]},bt,pe,ue],K=()=>[bt,"auto",pe,ue],J=()=>["auto","min","max","fr",pe,ue],B=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],z=()=>["start","end","center","stretch","center-safe","end-safe"],te=()=>["auto",...L()],se=()=>[St,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...L()],$=()=>[St,"screen","full","dvw","lvw","svw","min","max","fit",...L()],ie=()=>[St,"screen","full","lh","dvh","lvh","svh","min","max","fit",...L()],q=()=>[e,pe,ue],H=()=>[...b(),_a,Ma,{position:[pe,ue]}],G=()=>["no-repeat",{repeat:["","x","y","space","round"]}],T=()=>["auto","cover","contain",Sc,wc,{size:[pe,ue]}],F=()=>[vn,fr,$t],D=()=>["","none","full",h,pe,ue],E=()=>["",Ie,fr,$t],C=()=>["solid","dashed","dotted","double"],W=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],U=()=>[Ie,vn,_a,Ma],ae=()=>["","none",g,pe,ue],X=()=>["none",Ie,pe,ue],de=()=>["none",Ie,pe,ue],ee=()=>[Ie,pe,ue],ke=()=>[St,"full",...L()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[jt],breakpoint:[jt],color:[ro],container:[jt],"drop-shadow":[jt],ease:["in","out","in-out"],font:[vc],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[jt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[jt],shadow:[jt],spacing:["px",Ie],text:[jt],"text-shadow":[jt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",St,ue,pe,w]}],container:["container"],"container-type":[{"@container":["","normal","size",pe,ue]}],"container-named":[kc],columns:[{columns:[Ie,ue,pe,i]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:v()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:N()}],"overscroll-x":[{"overscroll-x":N()}],"overscroll-y":[{"overscroll-y":N()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:R()}],"inset-x":[{"inset-x":R()}],"inset-y":[{"inset-y":R()}],start:[{"inset-s":R(),start:R()}],end:[{"inset-e":R(),end:R()}],"inset-bs":[{"inset-bs":R()}],"inset-be":[{"inset-be":R()}],top:[{top:R()}],right:[{right:R()}],bottom:[{bottom:R()}],left:[{left:R()}],visibility:["visible","invisible","collapse"],z:[{z:[bt,"auto",pe,ue]}],basis:[{basis:[St,"full","auto",i,...L()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ie,St,"auto","initial","none",ue]}],grow:[{grow:["",Ie,pe,ue]}],shrink:[{shrink:["",Ie,pe,ue]}],order:[{order:[bt,"first","last","none",pe,ue]}],"grid-cols":[{"grid-cols":P()}],"col-start-end":[{col:Q()}],"col-start":[{"col-start":K()}],"col-end":[{"col-end":K()}],"grid-rows":[{"grid-rows":P()}],"row-start-end":[{row:Q()}],"row-start":[{"row-start":K()}],"row-end":[{"row-end":K()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":J()}],"auto-rows":[{"auto-rows":J()}],gap:[{gap:L()}],"gap-x":[{"gap-x":L()}],"gap-y":[{"gap-y":L()}],"justify-content":[{justify:[...B(),"normal"]}],"justify-items":[{"justify-items":[...z(),"normal"]}],"justify-self":[{"justify-self":["auto",...z()]}],"align-content":[{content:["normal",...B()]}],"align-items":[{items:[...z(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...z(),{baseline:["","last"]}]}],"place-content":[{"place-content":B()}],"place-items":[{"place-items":[...z(),"baseline"]}],"place-self":[{"place-self":["auto",...z()]}],p:[{p:L()}],px:[{px:L()}],py:[{py:L()}],ps:[{ps:L()}],pe:[{pe:L()}],pbs:[{pbs:L()}],pbe:[{pbe:L()}],pt:[{pt:L()}],pr:[{pr:L()}],pb:[{pb:L()}],pl:[{pl:L()}],m:[{m:te()}],mx:[{mx:te()}],my:[{my:te()}],ms:[{ms:te()}],me:[{me:te()}],mbs:[{mbs:te()}],mbe:[{mbe:te()}],mt:[{mt:te()}],mr:[{mr:te()}],mb:[{mb:te()}],ml:[{ml:te()}],"space-x":[{"space-x":L()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":L()}],"space-y-reverse":["space-y-reverse"],size:[{size:se()}],"inline-size":[{inline:["auto",...$()]}],"min-inline-size":[{"min-inline":["auto",...$()]}],"max-inline-size":[{"max-inline":["none",...$()]}],"block-size":[{block:["auto",...ie()]}],"min-block-size":[{"min-block":["auto",...ie()]}],"max-block-size":[{"max-block":["none",...ie()]}],w:[{w:[i,"screen",...se()]}],"min-w":[{"min-w":[i,"screen","none",...se()]}],"max-w":[{"max-w":[i,"screen","none","prose",{screen:[l]},...se()]}],h:[{h:["screen","lh",...se()]}],"min-h":[{"min-h":["screen","lh","none",...se()]}],"max-h":[{"max-h":["screen","lh",...se()]}],"font-size":[{text:["base",n,fr,$t]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,Ec,yc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",vn,ue]}],"font-family":[{font:[Cc,jc,r]}],"font-features":[{"font-features":[ue]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[s,pe,ue]}],"line-clamp":[{"line-clamp":[Ie,"none",pe,Aa]}],leading:[{leading:[o,...L()]}],"list-image":[{"list-image":["none",pe,ue]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",pe,ue]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:q()}],"text-color":[{text:q()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...C(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ie,"from-font","auto",pe,$t]}],"text-decoration-color":[{decoration:q()}],"underline-offset":[{"underline-offset":[Ie,"auto",pe,ue]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:L()}],"tab-size":[{tab:[bt,pe,ue]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",pe,ue]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",pe,ue]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:H()}],"bg-repeat":[{bg:G()}],"bg-size":[{bg:T()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},bt,pe,ue],radial:["",pe,ue],conic:[bt,pe,ue]},Tc,Nc]}],"bg-color":[{bg:q()}],"gradient-from-pos":[{from:F()}],"gradient-via-pos":[{via:F()}],"gradient-to-pos":[{to:F()}],"gradient-from":[{from:q()}],"gradient-via":[{via:q()}],"gradient-to":[{to:q()}],rounded:[{rounded:D()}],"rounded-s":[{"rounded-s":D()}],"rounded-e":[{"rounded-e":D()}],"rounded-t":[{"rounded-t":D()}],"rounded-r":[{"rounded-r":D()}],"rounded-b":[{"rounded-b":D()}],"rounded-l":[{"rounded-l":D()}],"rounded-ss":[{"rounded-ss":D()}],"rounded-se":[{"rounded-se":D()}],"rounded-ee":[{"rounded-ee":D()}],"rounded-es":[{"rounded-es":D()}],"rounded-tl":[{"rounded-tl":D()}],"rounded-tr":[{"rounded-tr":D()}],"rounded-br":[{"rounded-br":D()}],"rounded-bl":[{"rounded-bl":D()}],"border-w":[{border:E()}],"border-w-x":[{"border-x":E()}],"border-w-y":[{"border-y":E()}],"border-w-s":[{"border-s":E()}],"border-w-e":[{"border-e":E()}],"border-w-bs":[{"border-bs":E()}],"border-w-be":[{"border-be":E()}],"border-w-t":[{"border-t":E()}],"border-w-r":[{"border-r":E()}],"border-w-b":[{"border-b":E()}],"border-w-l":[{"border-l":E()}],"divide-x":[{"divide-x":E()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":E()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...C(),"hidden","none"]}],"divide-style":[{divide:[...C(),"hidden","none"]}],"border-color":[{border:q()}],"border-color-x":[{"border-x":q()}],"border-color-y":[{"border-y":q()}],"border-color-s":[{"border-s":q()}],"border-color-e":[{"border-e":q()}],"border-color-bs":[{"border-bs":q()}],"border-color-be":[{"border-be":q()}],"border-color-t":[{"border-t":q()}],"border-color-r":[{"border-r":q()}],"border-color-b":[{"border-b":q()}],"border-color-l":[{"border-l":q()}],"divide-color":[{divide:q()}],"outline-style":[{outline:[...C(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ie,pe,ue]}],"outline-w":[{outline:["",Ie,fr,$t]}],"outline-color":[{outline:q()}],shadow:[{shadow:["","none",u,Mr,Ar]}],"shadow-color":[{shadow:q()}],"inset-shadow":[{"inset-shadow":["none",m,Mr,Ar]}],"inset-shadow-color":[{"inset-shadow":q()}],"ring-w":[{ring:E()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:q()}],"ring-offset-w":[{"ring-offset":[Ie,$t]}],"ring-offset-color":[{"ring-offset":q()}],"inset-ring-w":[{"inset-ring":E()}],"inset-ring-color":[{"inset-ring":q()}],"text-shadow":[{"text-shadow":["none",f,Mr,Ar]}],"text-shadow-color":[{"text-shadow":q()}],opacity:[{opacity:[Ie,pe,ue]}],"mix-blend":[{"mix-blend":[...W(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":W()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Ie]}],"mask-image-linear-from-pos":[{"mask-linear-from":U()}],"mask-image-linear-to-pos":[{"mask-linear-to":U()}],"mask-image-linear-from-color":[{"mask-linear-from":q()}],"mask-image-linear-to-color":[{"mask-linear-to":q()}],"mask-image-t-from-pos":[{"mask-t-from":U()}],"mask-image-t-to-pos":[{"mask-t-to":U()}],"mask-image-t-from-color":[{"mask-t-from":q()}],"mask-image-t-to-color":[{"mask-t-to":q()}],"mask-image-r-from-pos":[{"mask-r-from":U()}],"mask-image-r-to-pos":[{"mask-r-to":U()}],"mask-image-r-from-color":[{"mask-r-from":q()}],"mask-image-r-to-color":[{"mask-r-to":q()}],"mask-image-b-from-pos":[{"mask-b-from":U()}],"mask-image-b-to-pos":[{"mask-b-to":U()}],"mask-image-b-from-color":[{"mask-b-from":q()}],"mask-image-b-to-color":[{"mask-b-to":q()}],"mask-image-l-from-pos":[{"mask-l-from":U()}],"mask-image-l-to-pos":[{"mask-l-to":U()}],"mask-image-l-from-color":[{"mask-l-from":q()}],"mask-image-l-to-color":[{"mask-l-to":q()}],"mask-image-x-from-pos":[{"mask-x-from":U()}],"mask-image-x-to-pos":[{"mask-x-to":U()}],"mask-image-x-from-color":[{"mask-x-from":q()}],"mask-image-x-to-color":[{"mask-x-to":q()}],"mask-image-y-from-pos":[{"mask-y-from":U()}],"mask-image-y-to-pos":[{"mask-y-to":U()}],"mask-image-y-from-color":[{"mask-y-from":q()}],"mask-image-y-to-color":[{"mask-y-to":q()}],"mask-image-radial":[{"mask-radial":[pe,ue]}],"mask-image-radial-from-pos":[{"mask-radial-from":U()}],"mask-image-radial-to-pos":[{"mask-radial-to":U()}],"mask-image-radial-from-color":[{"mask-radial-from":q()}],"mask-image-radial-to-color":[{"mask-radial-to":q()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[Ie]}],"mask-image-conic-from-pos":[{"mask-conic-from":U()}],"mask-image-conic-to-pos":[{"mask-conic-to":U()}],"mask-image-conic-from-color":[{"mask-conic-from":q()}],"mask-image-conic-to-color":[{"mask-conic-to":q()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:H()}],"mask-repeat":[{mask:G()}],"mask-size":[{mask:T()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",pe,ue]}],filter:[{filter:["","none",pe,ue]}],blur:[{blur:ae()}],brightness:[{brightness:[Ie,pe,ue]}],contrast:[{contrast:[Ie,pe,ue]}],"drop-shadow":[{"drop-shadow":["","none",p,Mr,Ar]}],"drop-shadow-color":[{"drop-shadow":q()}],grayscale:[{grayscale:["",Ie,pe,ue]}],"hue-rotate":[{"hue-rotate":[Ie,pe,ue]}],invert:[{invert:["",Ie,pe,ue]}],saturate:[{saturate:[Ie,pe,ue]}],sepia:[{sepia:["",Ie,pe,ue]}],"backdrop-filter":[{"backdrop-filter":["","none",pe,ue]}],"backdrop-blur":[{"backdrop-blur":ae()}],"backdrop-brightness":[{"backdrop-brightness":[Ie,pe,ue]}],"backdrop-contrast":[{"backdrop-contrast":[Ie,pe,ue]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ie,pe,ue]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ie,pe,ue]}],"backdrop-invert":[{"backdrop-invert":["",Ie,pe,ue]}],"backdrop-opacity":[{"backdrop-opacity":[Ie,pe,ue]}],"backdrop-saturate":[{"backdrop-saturate":[Ie,pe,ue]}],"backdrop-sepia":[{"backdrop-sepia":["",Ie,pe,ue]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":L()}],"border-spacing-x":[{"border-spacing-x":L()}],"border-spacing-y":[{"border-spacing-y":L()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",pe,ue]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ie,"initial",pe,ue]}],ease:[{ease:["linear","initial",x,pe,ue]}],delay:[{delay:[Ie,pe,ue]}],animate:[{animate:["none",j,pe,ue]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[k,pe,ue]}],"perspective-origin":[{"perspective-origin":v()}],rotate:[{rotate:X()}],"rotate-x":[{"rotate-x":X()}],"rotate-y":[{"rotate-y":X()}],"rotate-z":[{"rotate-z":X()}],scale:[{scale:de()}],"scale-x":[{"scale-x":de()}],"scale-y":[{"scale-y":de()}],"scale-z":[{"scale-z":de()}],"scale-3d":["scale-3d"],skew:[{skew:ee()}],"skew-x":[{"skew-x":ee()}],"skew-y":[{"skew-y":ee()}],transform:[{transform:[pe,ue,"","none","gpu","cpu"]}],"transform-origin":[{origin:v()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ke()}],"translate-x":[{"translate-x":ke()}],"translate-y":[{"translate-y":ke()}],"translate-z":[{"translate-z":ke()}],"translate-none":["translate-none"],zoom:[{zoom:[bt,pe,ue]}],accent:[{accent:q()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:q()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",pe,ue]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":q()}],"scrollbar-track-color":[{"scrollbar-track":q()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":L()}],"scroll-mx":[{"scroll-mx":L()}],"scroll-my":[{"scroll-my":L()}],"scroll-ms":[{"scroll-ms":L()}],"scroll-me":[{"scroll-me":L()}],"scroll-mbs":[{"scroll-mbs":L()}],"scroll-mbe":[{"scroll-mbe":L()}],"scroll-mt":[{"scroll-mt":L()}],"scroll-mr":[{"scroll-mr":L()}],"scroll-mb":[{"scroll-mb":L()}],"scroll-ml":[{"scroll-ml":L()}],"scroll-p":[{"scroll-p":L()}],"scroll-px":[{"scroll-px":L()}],"scroll-py":[{"scroll-py":L()}],"scroll-ps":[{"scroll-ps":L()}],"scroll-pe":[{"scroll-pe":L()}],"scroll-pbs":[{"scroll-pbs":L()}],"scroll-pbe":[{"scroll-pbe":L()}],"scroll-pt":[{"scroll-pt":L()}],"scroll-pr":[{"scroll-pr":L()}],"scroll-pb":[{"scroll-pb":L()}],"scroll-pl":[{"scroll-pl":L()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",pe,ue]}],fill:[{fill:["none",...q()]}],"stroke-w":[{stroke:[Ie,fr,$t,Aa]}],stroke:[{stroke:["none",...q()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},zc=ic(Ic),$a=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Da=Ks,Er=(e,r)=>n=>{var a;if((r==null?void 0:r.variants)==null)return Da(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:s,defaultVariants:o}=r,l=Object.keys(s).map(h=>{const u=n==null?void 0:n[h],m=o==null?void 0:o[h];if(u===null)return null;const f=$a(u)||$a(m);return s[h][f]}),i=n&&Object.entries(n).reduce((h,u)=>{let[m,f]=u;return f===void 0||(h[m]=f),h},{}),d=r==null||(a=r.compoundVariants)===null||a===void 0?void 0:a.reduce((h,u)=>{let{class:m,className:f,...p}=u;return Object.entries(p).every(g=>{let[k,w]=g;return Array.isArray(w)?w.includes({...o,...i}[k]):{...o,...i}[k]===w})?[...h,m,f]:h},[]);return Da(e,l,d,n==null?void 0:n.class,n==null?void 0:n.className)},en=c.createContext(null);en.displayName="PanelGroupContext";const Xe={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"},sa=10,Wt=c.useLayoutEffect,Ba=Td.useId,Pc=typeof Ba=="function"?Ba:()=>null;let Rc=0;function oa(e=null){const r=Pc(),n=c.useRef(e||r||null);return n.current===null&&(n.current=""+Rc++),e??n.current}function ho({children:e,className:r="",collapsedSize:n,collapsible:a,defaultSize:s,forwardedRef:o,id:l,maxSize:i,minSize:d,onCollapse:h,onExpand:u,onResize:m,order:f,style:p,tagName:g="div",...k}){const w=c.useContext(en);if(w===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:x,expandPanel:j,getPanelSize:y,getPanelStyle:b,groupId:v,isPanelCollapsed:S,reevaluatePanelConstraints:N,registerPanel:L,resizePanel:R,unregisterPanel:P}=w,Q=oa(l),K=c.useRef({callbacks:{onCollapse:h,onExpand:u,onResize:m},constraints:{collapsedSize:n,collapsible:a,defaultSize:s,maxSize:i,minSize:d},id:Q,idIsFromProps:l!==void 0,order:f});c.useRef({didLogMissingDefaultSizeWarning:!1}),Wt(()=>{const{callbacks:B,constraints:z}=K.current,te={...z};K.current.id=Q,K.current.idIsFromProps=l!==void 0,K.current.order=f,B.onCollapse=h,B.onExpand=u,B.onResize=m,z.collapsedSize=n,z.collapsible=a,z.defaultSize=s,z.maxSize=i,z.minSize=d,(te.collapsedSize!==z.collapsedSize||te.collapsible!==z.collapsible||te.maxSize!==z.maxSize||te.minSize!==z.minSize)&&N(K.current,te)}),Wt(()=>{const B=K.current;return L(B),()=>{P(B)}},[f,Q,L,P]),c.useImperativeHandle(o,()=>({collapse:()=>{x(K.current)},expand:B=>{j(K.current,B)},getId(){return Q},getSize(){return y(K.current)},isCollapsed(){return S(K.current)},isExpanded(){return!S(K.current)},resize:B=>{R(K.current,B)}}),[x,j,y,S,Q,R]);const J=b(K.current,s);return c.createElement(g,{...k,children:e,className:r,id:Q,style:{...J,...p},[Xe.groupId]:v,[Xe.panel]:"",[Xe.panelCollapsible]:a||void 0,[Xe.panelId]:Q,[Xe.panelSize]:parseFloat(""+J.flexGrow).toFixed(1)})}const uo=c.forwardRef((e,r)=>c.createElement(ho,{...e,forwardedRef:r}));ho.displayName="Panel";uo.displayName="forwardRef(Panel)";let Dn=null,Fr=-1,Et=null;function Ac(e,r,n){const a=(r&xo)!==0,s=(r&bo)!==0,o=(r&vo)!==0,l=(r&ko)!==0;if(r){if(a)return o?"se-resize":l?"ne-resize":"e-resize";if(s)return o?"sw-resize":l?"nw-resize":"w-resize";if(o)return"s-resize";if(l)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function Mc(){Et!==null&&(document.head.removeChild(Et),Dn=null,Et=null,Fr=-1)}function kn(e,r,n){var a,s;const o=Ac(e,r);if(Dn!==o){if(Dn=o,Et===null&&(Et=document.createElement("style"),document.head.appendChild(Et)),Fr>=0){var l;(l=Et.sheet)===null||l===void 0||l.removeRule(Fr)}Fr=(a=(s=Et.sheet)===null||s===void 0?void 0:s.insertRule(`*{cursor: ${o} !important;}`))!==null&&a!==void 0?a:-1}}function mo(e){return e.type==="keydown"}function po(e){return e.type.startsWith("pointer")}function fo(e){return e.type.startsWith("mouse")}function tn(e){if(po(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(fo(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function _c(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function $c(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 Dc(e,r){if(e===r)throw new Error("Cannot compare node with itself");const n={a:Ha(e),b:Ha(r)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),r=n.b.pop(),a=e;Ee(a,"Stacking order can only be calculated for elements with a common ancestor");const s={a:Fa(Ga(n.a)),b:Fa(Ga(n.b))};if(s.a===s.b){const o=a.childNodes,l={a:n.a.at(-1),b:n.b.at(-1)};let i=o.length;for(;i--;){const d=o[i];if(d===l.a)return 1;if(d===l.b)return-1}}return Math.sign(s.a-s.b)}const Bc=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Gc(e){var r;const n=getComputedStyle((r=go(e))!==null&&r!==void 0?r:e).display;return n==="flex"||n==="inline-flex"}function Fc(e){const r=getComputedStyle(e);return!!(r.position==="fixed"||r.zIndex!=="auto"&&(r.position!=="static"||Gc(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"||Bc.test(r.willChange)||r.webkitOverflowScrolling==="touch")}function Ga(e){let r=e.length;for(;r--;){const n=e[r];if(Ee(n,"Missing node"),Fc(n))return n}return null}function Fa(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Ha(e){const r=[];for(;e;)r.push(e),e=go(e);return r}function go(e){const{parentNode:r}=e;return r&&r instanceof ShadowRoot?r.host:r}const xo=1,bo=2,vo=4,ko=8,Hc=_c()==="coarse";let pt=[],lr=!1,Lt=new Map,rn=new Map;const Cr=new Set;function Oc(e,r,n,a,s){var o;const{ownerDocument:l}=r,i={direction:n,element:r,hitAreaMargins:a,setResizeHandlerState:s},d=(o=Lt.get(l))!==null&&o!==void 0?o:0;return Lt.set(l,d+1),Cr.add(i),Xr(),function(){var u;rn.delete(e),Cr.delete(i);const m=(u=Lt.get(l))!==null&&u!==void 0?u:1;if(Lt.set(l,m-1),Xr(),m===1&&Lt.delete(l),pt.includes(i)){const f=pt.indexOf(i);f>=0&&pt.splice(f,1),nn(),s("up",!0,null)}}}function Wc(e){const{target:r}=e,{x:n,y:a}=tn(e);lr=!0,la({target:r,x:n,y:a}),Xr(),pt.length>0&&(Kr("down",e),nn(),e.preventDefault(),wo(r)||e.stopImmediatePropagation())}function wn(e){const{x:r,y:n}=tn(e);if(lr&&e.type!=="pointerleave"&&e.buttons===0&&(lr=!1,Kr("up",e)),!lr){const{target:a}=e;la({target:a,x:r,y:n})}Kr("move",e),nn(),pt.length>0&&e.preventDefault()}function yn(e){const{target:r}=e,{x:n,y:a}=tn(e);rn.clear(),lr=!1,pt.length>0&&(e.preventDefault(),wo(r)||e.stopImmediatePropagation()),Kr("up",e),la({target:r,x:n,y:a}),nn(),Xr()}function wo(e){let r=e;for(;r;){if(r.hasAttribute(Xe.resizeHandle))return!0;r=r.parentElement}return!1}function la({target:e,x:r,y:n}){pt.splice(0);let a=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(a=e),Cr.forEach(s=>{const{element:o,hitAreaMargins:l}=s,i=o.getBoundingClientRect(),{bottom:d,left:h,right:u,top:m}=i,f=Hc?l.coarse:l.fine;if(r>=h-f&&r<=u+f&&n>=m-f&&n<=d+f){if(a!==null&&document.contains(a)&&o!==a&&!o.contains(a)&&!a.contains(o)&&Dc(a,o)>0){let g=a,k=!1;for(;g&&!g.contains(o);){if($c(g.getBoundingClientRect(),i)){k=!0;break}g=g.parentElement}if(k)return}pt.push(s)}})}function jn(e,r){rn.set(e,r)}function nn(){let e=!1,r=!1;pt.forEach(a=>{const{direction:s}=a;s==="horizontal"?e=!0:r=!0});let n=0;rn.forEach(a=>{n|=a}),e&&r?kn("intersection",n):e?kn("horizontal",n):r?kn("vertical",n):Mc()}let Nn;function Xr(){var e;(e=Nn)===null||e===void 0||e.abort(),Nn=new AbortController;const r={capture:!0,signal:Nn.signal};Cr.size&&(lr?(pt.length>0&&Lt.forEach((n,a)=>{const{body:s}=a;n>0&&(s.addEventListener("contextmenu",yn,r),s.addEventListener("pointerleave",wn,r),s.addEventListener("pointermove",wn,r))}),Lt.forEach((n,a)=>{const{body:s}=a;s.addEventListener("pointerup",yn,r),s.addEventListener("pointercancel",yn,r)})):Lt.forEach((n,a)=>{const{body:s}=a;n>0&&(s.addEventListener("pointerdown",Wc,r),s.addEventListener("pointermove",wn,r))}))}function Kr(e,r){Cr.forEach(n=>{const{setResizeHandlerState:a}=n,s=pt.includes(n);a(e,s,r)})}function Uc(){const[e,r]=c.useState(0);return c.useCallback(()=>r(n=>n+1),[])}function Ee(e,r){if(!e)throw console.error(r),Error(r)}function Vt(e,r,n=sa){return e.toFixed(n)===r.toFixed(n)?0:e>r?1:-1}function Nt(e,r,n=sa){return Vt(e,r,n)===0}function ht(e,r,n){return Vt(e,r,n)===0}function Vc(e,r,n){if(e.length!==r.length)return!1;for(let a=0;a<e.length;a++){const s=e[a],o=r[a];if(!ht(s,o,n))return!1}return!0}function sr({panelConstraints:e,panelIndex:r,size:n}){const a=e[r];Ee(a!=null,`Panel constraints not found for index ${r}`);let{collapsedSize:s=0,collapsible:o,maxSize:l=100,minSize:i=0}=a;if(Vt(n,i)<0)if(o){const d=(s+i)/2;Vt(n,d)<0?n=s:n=i}else n=i;return n=Math.min(l,n),n=parseFloat(n.toFixed(sa)),n}function kr({delta:e,initialLayout:r,panelConstraints:n,pivotIndices:a,prevLayout:s,trigger:o}){if(ht(e,0))return r;const l=[...r],[i,d]=a;Ee(i!=null,"Invalid first pivot index"),Ee(d!=null,"Invalid second pivot index");let h=0;if(o==="keyboard"){{const m=e<0?d:i,f=n[m];Ee(f,`Panel constraints not found for index ${m}`);const{collapsedSize:p=0,collapsible:g,minSize:k=0}=f;if(g){const w=r[m];if(Ee(w!=null,`Previous layout not found for panel index ${m}`),ht(w,p)){const x=k-w;Vt(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}{const m=e<0?i:d,f=n[m];Ee(f,`No panel constraints found for index ${m}`);const{collapsedSize:p=0,collapsible:g,minSize:k=0}=f;if(g){const w=r[m];if(Ee(w!=null,`Previous layout not found for panel index ${m}`),ht(w,k)){const x=w-p;Vt(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}}{const m=e<0?1:-1;let f=e<0?d:i,p=0;for(;;){const k=r[f];Ee(k!=null,`Previous layout not found for panel index ${f}`);const x=sr({panelConstraints:n,panelIndex:f,size:100})-k;if(p+=x,f+=m,f<0||f>=n.length)break}const g=Math.min(Math.abs(e),Math.abs(p));e=e<0?0-g:g}{let f=e<0?i:d;for(;f>=0&&f<n.length;){const p=Math.abs(e)-Math.abs(h),g=r[f];Ee(g!=null,`Previous layout not found for panel index ${f}`);const k=g-p,w=sr({panelConstraints:n,panelIndex:f,size:k});if(!ht(g,w)&&(h+=g-w,l[f]=w,h.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?f--:f++}}if(Vc(s,l))return s;{const m=e<0?d:i,f=r[m];Ee(f!=null,`Previous layout not found for panel index ${m}`);const p=f+h,g=sr({panelConstraints:n,panelIndex:m,size:p});if(l[m]=g,!ht(g,p)){let k=p-g,x=e<0?d:i;for(;x>=0&&x<n.length;){const j=l[x];Ee(j!=null,`Previous layout not found for panel index ${x}`);const y=j+k,b=sr({panelConstraints:n,panelIndex:x,size:y});if(ht(j,b)||(k-=b-j,l[x]=b),ht(k,0))break;e>0?x--:x++}}}const u=l.reduce((m,f)=>f+m,0);return ht(u,100)?l:s}function qc({layout:e,panelsArray:r,pivotIndices:n}){let a=0,s=100,o=0,l=0;const i=n[0];Ee(i!=null,"No pivot index found"),r.forEach((m,f)=>{const{constraints:p}=m,{maxSize:g=100,minSize:k=0}=p;f===i?(a=k,s=g):(o+=k,l+=g)});const d=Math.min(s,100-o),h=Math.max(a,100-l),u=e[i];return{valueMax:d,valueMin:h,valueNow:u}}function Sr(e,r=document){return Array.from(r.querySelectorAll(`[${Xe.resizeHandleId}][data-panel-group-id="${e}"]`))}function yo(e,r,n=document){const s=Sr(e,n).findIndex(o=>o.getAttribute(Xe.resizeHandleId)===r);return s??null}function jo(e,r,n){const a=yo(e,r,n);return a!=null?[a,a+1]:[-1,-1]}function Xc(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function No(e,r=document){if(Xc(r)&&r.dataset.panelGroupId==e)return r;const n=r.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function an(e,r=document){const n=r.querySelector(`[${Xe.resizeHandleId}="${e}"]`);return n||null}function Kc(e,r,n,a=document){var s,o,l,i;const d=an(r,a),h=Sr(e,a),u=d?h.indexOf(d):-1,m=(s=(o=n[u])===null||o===void 0?void 0:o.id)!==null&&s!==void 0?s:null,f=(l=(i=n[u+1])===null||i===void 0?void 0:i.id)!==null&&l!==void 0?l:null;return[m,f]}function Yc({committedValuesRef:e,eagerValuesRef:r,groupId:n,layout:a,panelDataArray:s,panelGroupElement:o,setLayout:l}){c.useRef({didWarnAboutMissingResizeHandle:!1}),Wt(()=>{if(!o)return;const i=Sr(n,o);for(let d=0;d<s.length-1;d++){const{valueMax:h,valueMin:u,valueNow:m}=qc({layout:a,panelsArray:s,pivotIndices:[d,d+1]}),f=i[d];if(f!=null){const p=s[d];Ee(p,`No panel data found for index "${d}"`),f.setAttribute("aria-controls",p.id),f.setAttribute("aria-valuemax",""+Math.round(h)),f.setAttribute("aria-valuemin",""+Math.round(u)),f.setAttribute("aria-valuenow",m!=null?""+Math.round(m):"")}}return()=>{i.forEach((d,h)=>{d.removeAttribute("aria-controls"),d.removeAttribute("aria-valuemax"),d.removeAttribute("aria-valuemin"),d.removeAttribute("aria-valuenow")})}},[n,a,s,o]),c.useEffect(()=>{if(!o)return;const i=r.current;Ee(i,"Eager values not found");const{panelDataArray:d}=i,h=No(n,o);Ee(h!=null,`No group found for id "${n}"`);const u=Sr(n,o);Ee(u,`No resize handles found for group id "${n}"`);const m=u.map(f=>{const p=f.getAttribute(Xe.resizeHandleId);Ee(p,"Resize handle element has no handle id attribute");const[g,k]=Kc(n,p,d,o);if(g==null||k==null)return()=>{};const w=x=>{if(!x.defaultPrevented)switch(x.key){case"Enter":{x.preventDefault();const j=d.findIndex(y=>y.id===g);if(j>=0){const y=d[j];Ee(y,`No panel data found for index ${j}`);const b=a[j],{collapsedSize:v=0,collapsible:S,minSize:N=0}=y.constraints;if(b!=null&&S){const L=kr({delta:ht(b,v)?N-v:v-b,initialLayout:a,panelConstraints:d.map(R=>R.constraints),pivotIndices:jo(n,p,o),prevLayout:a,trigger:"keyboard"});a!==L&&l(L)}}break}}};return f.addEventListener("keydown",w),()=>{f.removeEventListener("keydown",w)}});return()=>{m.forEach(f=>f())}},[o,e,r,n,a,s,l])}function Oa(e,r){if(e.length!==r.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==r[n])return!1;return!0}function Co(e,r){const n=e==="horizontal",{x:a,y:s}=tn(r);return n?a:s}function Zc(e,r,n,a,s){const o=n==="horizontal",l=an(r,s);Ee(l,`No resize handle element found for id "${r}"`);const i=l.getAttribute(Xe.groupId);Ee(i,"Resize handle element has no group id attribute");let{initialCursorPosition:d}=a;const h=Co(n,e),u=No(i,s);Ee(u,`No group element found for id "${i}"`);const m=u.getBoundingClientRect(),f=o?m.width:m.height;return(h-d)/f*100}function Jc(e,r,n,a,s,o){if(mo(e)){const l=n==="horizontal";let i=0;e.shiftKey?i=100:s!=null?i=s:i=10;let d=0;switch(e.key){case"ArrowDown":d=l?0:i;break;case"ArrowLeft":d=l?-i:0;break;case"ArrowRight":d=l?i:0;break;case"ArrowUp":d=l?0:-i;break;case"End":d=100;break;case"Home":d=-100;break}return d}else return a==null?0:Zc(e,r,n,a,o)}function Qc({panelDataArray:e}){const r=Array(e.length),n=e.map(o=>o.constraints);let a=0,s=100;for(let o=0;o<e.length;o++){const l=n[o];Ee(l,`Panel constraints not found for index ${o}`);const{defaultSize:i}=l;i!=null&&(a++,r[o]=i,s-=i)}for(let o=0;o<e.length;o++){const l=n[o];Ee(l,`Panel constraints not found for index ${o}`);const{defaultSize:i}=l;if(i!=null)continue;const d=e.length-a,h=s/d;a++,r[o]=h,s-=h}return r}function Qt(e,r,n){r.forEach((a,s)=>{const o=e[s];Ee(o,`Panel data not found for index ${s}`);const{callbacks:l,constraints:i,id:d}=o,{collapsedSize:h=0,collapsible:u}=i,m=n[d];if(m==null||a!==m){n[d]=a;const{onCollapse:f,onExpand:p,onResize:g}=l;g&&g(a,m),u&&(f||p)&&(p&&(m==null||Nt(m,h))&&!Nt(a,h)&&p(),f&&(m==null||!Nt(m,h))&&Nt(a,h)&&f())}})}function _r(e,r){if(e.length!==r.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=r[n])return!1;return!0}function eh({defaultSize:e,dragState:r,layout:n,panelData:a,panelIndex:s,precision:o=3}){const l=n[s];let i;return l==null?i=e!=null?e.toFixed(o):"1":a.length===1?i="1":i=l.toFixed(o),{flexBasis:0,flexGrow:i,flexShrink:1,overflow:"hidden",pointerEvents:r!==null?"none":void 0}}function th(e,r=10){let n=null;return(...s)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...s)},r)}}function Wa(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 So(e){return`react-resizable-panels:${e}`}function To(e){return e.map(r=>{const{constraints:n,id:a,idIsFromProps:s,order:o}=r;return s?a:o?`${o}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((r,n)=>r.localeCompare(n)).join(",")}function Eo(e,r){try{const n=So(e),a=r.getItem(n);if(a){const s=JSON.parse(a);if(typeof s=="object"&&s!=null)return s}}catch{}return null}function rh(e,r,n){var a,s;const o=(a=Eo(e,n))!==null&&a!==void 0?a:{},l=To(r);return(s=o[l])!==null&&s!==void 0?s:null}function nh(e,r,n,a,s){var o;const l=So(e),i=To(r),d=(o=Eo(e,s))!==null&&o!==void 0?o:{};d[i]={expandToSizes:Object.fromEntries(n.entries()),layout:a};try{s.setItem(l,JSON.stringify(d))}catch(h){console.error(h)}}function Ua({layout:e,panelConstraints:r}){const n=[...e],a=n.reduce((o,l)=>o+l,0);if(n.length!==r.length)throw Error(`Invalid ${r.length} panel layout: ${n.map(o=>`${o}%`).join(", ")}`);if(!ht(a,100)&&n.length>0)for(let o=0;o<r.length;o++){const l=n[o];Ee(l!=null,`No layout data found for index ${o}`);const i=100/a*l;n[o]=i}let s=0;for(let o=0;o<r.length;o++){const l=n[o];Ee(l!=null,`No layout data found for index ${o}`);const i=sr({panelConstraints:r,panelIndex:o,size:l});l!=i&&(s+=l-i,n[o]=i)}if(!ht(s,0))for(let o=0;o<r.length;o++){const l=n[o];Ee(l!=null,`No layout data found for index ${o}`);const i=l+s,d=sr({panelConstraints:r,panelIndex:o,size:i});if(l!==d&&(s-=d-l,n[o]=d,ht(s,0)))break}return n}const ah=100,wr={getItem:e=>(Wa(wr),wr.getItem(e)),setItem:(e,r)=>{Wa(wr),wr.setItem(e,r)}},Va={};function Lo({autoSaveId:e=null,children:r,className:n="",direction:a,forwardedRef:s,id:o=null,onLayout:l=null,keyboardResizeBy:i=null,storage:d=wr,style:h,tagName:u="div",...m}){const f=oa(o),p=c.useRef(null),[g,k]=c.useState(null),[w,x]=c.useState([]),j=Uc(),y=c.useRef({}),b=c.useRef(new Map),v=c.useRef(0),S=c.useRef({autoSaveId:e,direction:a,dragState:g,id:f,keyboardResizeBy:i,onLayout:l,storage:d}),N=c.useRef({layout:w,panelDataArray:[],panelDataArrayChanged:!1});c.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),c.useImperativeHandle(s,()=>({getId:()=>S.current.id,getLayout:()=>{const{layout:T}=N.current;return T},setLayout:T=>{const{onLayout:F}=S.current,{layout:D,panelDataArray:E}=N.current,C=Ua({layout:T,panelConstraints:E.map(W=>W.constraints)});Oa(D,C)||(x(C),N.current.layout=C,F&&F(C),Qt(E,C,y.current))}}),[]),Wt(()=>{S.current.autoSaveId=e,S.current.direction=a,S.current.dragState=g,S.current.id=f,S.current.onLayout=l,S.current.storage=d}),Yc({committedValuesRef:S,eagerValuesRef:N,groupId:f,layout:w,panelDataArray:N.current.panelDataArray,setLayout:x,panelGroupElement:p.current}),c.useEffect(()=>{const{panelDataArray:T}=N.current;if(e){if(w.length===0||w.length!==T.length)return;let F=Va[e];F==null&&(F=th(nh,ah),Va[e]=F);const D=[...T],E=new Map(b.current);F(e,D,E,w,d)}},[e,w,d]),c.useEffect(()=>{});const L=c.useCallback(T=>{const{onLayout:F}=S.current,{layout:D,panelDataArray:E}=N.current;if(T.constraints.collapsible){const C=E.map(X=>X.constraints),{collapsedSize:W=0,panelSize:U,pivotIndices:ae}=Dt(E,T,D);if(Ee(U!=null,`Panel size not found for panel "${T.id}"`),!Nt(U,W)){b.current.set(T.id,U);const de=tr(E,T)===E.length-1?U-W:W-U,ee=kr({delta:de,initialLayout:D,panelConstraints:C,pivotIndices:ae,prevLayout:D,trigger:"imperative-api"});_r(D,ee)||(x(ee),N.current.layout=ee,F&&F(ee),Qt(E,ee,y.current))}}},[]),R=c.useCallback((T,F)=>{const{onLayout:D}=S.current,{layout:E,panelDataArray:C}=N.current;if(T.constraints.collapsible){const W=C.map(ke=>ke.constraints),{collapsedSize:U=0,panelSize:ae=0,minSize:X=0,pivotIndices:de}=Dt(C,T,E),ee=F??X;if(Nt(ae,U)){const ke=b.current.get(T.id),le=ke!=null&&ke>=ee?ke:ee,Ae=tr(C,T)===C.length-1?ae-le:le-ae,ce=kr({delta:Ae,initialLayout:E,panelConstraints:W,pivotIndices:de,prevLayout:E,trigger:"imperative-api"});_r(E,ce)||(x(ce),N.current.layout=ce,D&&D(ce),Qt(C,ce,y.current))}}},[]),P=c.useCallback(T=>{const{layout:F,panelDataArray:D}=N.current,{panelSize:E}=Dt(D,T,F);return Ee(E!=null,`Panel size not found for panel "${T.id}"`),E},[]),Q=c.useCallback((T,F)=>{const{panelDataArray:D}=N.current,E=tr(D,T);return eh({defaultSize:F,dragState:g,layout:w,panelData:D,panelIndex:E})},[g,w]),K=c.useCallback(T=>{const{layout:F,panelDataArray:D}=N.current,{collapsedSize:E=0,collapsible:C,panelSize:W}=Dt(D,T,F);return Ee(W!=null,`Panel size not found for panel "${T.id}"`),C===!0&&Nt(W,E)},[]),J=c.useCallback(T=>{const{layout:F,panelDataArray:D}=N.current,{collapsedSize:E=0,collapsible:C,panelSize:W}=Dt(D,T,F);return Ee(W!=null,`Panel size not found for panel "${T.id}"`),!C||Vt(W,E)>0},[]),B=c.useCallback(T=>{const{panelDataArray:F}=N.current;F.push(T),F.sort((D,E)=>{const C=D.order,W=E.order;return C==null&&W==null?0:C==null?-1:W==null?1:C-W}),N.current.panelDataArrayChanged=!0,j()},[j]);Wt(()=>{if(N.current.panelDataArrayChanged){N.current.panelDataArrayChanged=!1;const{autoSaveId:T,onLayout:F,storage:D}=S.current,{layout:E,panelDataArray:C}=N.current;let W=null;if(T){const ae=rh(T,C,D);ae&&(b.current=new Map(Object.entries(ae.expandToSizes)),W=ae.layout)}W==null&&(W=Qc({panelDataArray:C}));const U=Ua({layout:W,panelConstraints:C.map(ae=>ae.constraints)});Oa(E,U)||(x(U),N.current.layout=U,F&&F(U),Qt(C,U,y.current))}}),Wt(()=>{const T=N.current;return()=>{T.layout=[]}},[]);const z=c.useCallback(T=>{let F=!1;const D=p.current;return D&&window.getComputedStyle(D,null).getPropertyValue("direction")==="rtl"&&(F=!0),function(C){C.preventDefault();const W=p.current;if(!W)return()=>null;const{direction:U,dragState:ae,id:X,keyboardResizeBy:de,onLayout:ee}=S.current,{layout:ke,panelDataArray:le}=N.current,{initialLayout:je}=ae??{},Ae=jo(X,T,W);let ce=Jc(C,T,U,ae,de,W);const ne=U==="horizontal";ne&&F&&(ce=-ce);const Le=le.map(we=>we.constraints),Z=kr({delta:ce,initialLayout:je??ke,panelConstraints:Le,pivotIndices:Ae,prevLayout:ke,trigger:mo(C)?"keyboard":"mouse-or-touch"}),me=!_r(ke,Z);(po(C)||fo(C))&&v.current!=ce&&(v.current=ce,!me&&ce!==0?ne?jn(T,ce<0?xo:bo):jn(T,ce<0?vo:ko):jn(T,0)),me&&(x(Z),N.current.layout=Z,ee&&ee(Z),Qt(le,Z,y.current))}},[]),te=c.useCallback((T,F)=>{const{onLayout:D}=S.current,{layout:E,panelDataArray:C}=N.current,W=C.map(ke=>ke.constraints),{panelSize:U,pivotIndices:ae}=Dt(C,T,E);Ee(U!=null,`Panel size not found for panel "${T.id}"`);const de=tr(C,T)===C.length-1?U-F:F-U,ee=kr({delta:de,initialLayout:E,panelConstraints:W,pivotIndices:ae,prevLayout:E,trigger:"imperative-api"});_r(E,ee)||(x(ee),N.current.layout=ee,D&&D(ee),Qt(C,ee,y.current))},[]),se=c.useCallback((T,F)=>{const{layout:D,panelDataArray:E}=N.current,{collapsedSize:C=0,collapsible:W}=F,{collapsedSize:U=0,collapsible:ae,maxSize:X=100,minSize:de=0}=T.constraints,{panelSize:ee}=Dt(E,T,D);ee!=null&&(W&&ae&&Nt(ee,C)?Nt(C,U)||te(T,U):ee<de?te(T,de):ee>X&&te(T,X))},[te]),$=c.useCallback((T,F)=>{const{direction:D}=S.current,{layout:E}=N.current;if(!p.current)return;const C=an(T,p.current);Ee(C,`Drag handle element not found for id "${T}"`);const W=Co(D,F);k({dragHandleId:T,dragHandleRect:C.getBoundingClientRect(),initialCursorPosition:W,initialLayout:E})},[]),ie=c.useCallback(()=>{k(null)},[]),q=c.useCallback(T=>{const{panelDataArray:F}=N.current,D=tr(F,T);D>=0&&(F.splice(D,1),delete y.current[T.id],N.current.panelDataArrayChanged=!0,j())},[j]),H=c.useMemo(()=>({collapsePanel:L,direction:a,dragState:g,expandPanel:R,getPanelSize:P,getPanelStyle:Q,groupId:f,isPanelCollapsed:K,isPanelExpanded:J,reevaluatePanelConstraints:se,registerPanel:B,registerResizeHandle:z,resizePanel:te,startDragging:$,stopDragging:ie,unregisterPanel:q,panelGroupElement:p.current}),[L,g,a,R,P,Q,f,K,J,se,B,z,te,$,ie,q]),G={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return c.createElement(en.Provider,{value:H},c.createElement(u,{...m,children:r,className:n,id:o,ref:p,style:{...G,...h},[Xe.group]:"",[Xe.groupDirection]:a,[Xe.groupId]:f}))}const Io=c.forwardRef((e,r)=>c.createElement(Lo,{...e,forwardedRef:r}));Lo.displayName="PanelGroup";Io.displayName="forwardRef(PanelGroup)";function tr(e,r){return e.findIndex(n=>n===r||n.id===r.id)}function Dt(e,r,n){const a=tr(e,r),o=a===e.length-1?[a-1,a]:[a,a+1],l=n[a];return{...r.constraints,panelSize:l,pivotIndices:o}}function sh({disabled:e,handleId:r,resizeHandler:n,panelGroupElement:a}){c.useEffect(()=>{if(e||n==null||a==null)return;const s=an(r,a);if(s==null)return;const o=l=>{if(!l.defaultPrevented)switch(l.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{l.preventDefault(),n(l);break}case"F6":{l.preventDefault();const i=s.getAttribute(Xe.groupId);Ee(i,`No group element found for id "${i}"`);const d=Sr(i,a),h=yo(i,r,a);Ee(h!==null,`No resize element found for id "${r}"`);const u=l.shiftKey?h>0?h-1:d.length-1:h+1<d.length?h+1:0;d[u].focus();break}}};return s.addEventListener("keydown",o),()=>{s.removeEventListener("keydown",o)}},[a,e,r,n])}function zo({children:e=null,className:r="",disabled:n=!1,hitAreaMargins:a,id:s,onBlur:o,onClick:l,onDragging:i,onFocus:d,onPointerDown:h,onPointerUp:u,style:m={},tabIndex:f=0,tagName:p="div",...g}){var k,w;const x=c.useRef(null),j=c.useRef({onClick:l,onDragging:i,onPointerDown:h,onPointerUp:u});c.useEffect(()=>{j.current.onClick=l,j.current.onDragging=i,j.current.onPointerDown=h,j.current.onPointerUp=u});const y=c.useContext(en);if(y===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:b,groupId:v,registerResizeHandle:S,startDragging:N,stopDragging:L,panelGroupElement:R}=y,P=oa(s),[Q,K]=c.useState("inactive"),[J,B]=c.useState(!1),[z,te]=c.useState(null),se=c.useRef({state:Q});Wt(()=>{se.current.state=Q}),c.useEffect(()=>{if(n)te(null);else{const H=S(P);te(()=>H)}},[n,P,S]);const $=(k=a==null?void 0:a.coarse)!==null&&k!==void 0?k:15,ie=(w=a==null?void 0:a.fine)!==null&&w!==void 0?w:5;c.useEffect(()=>{if(n||z==null)return;const H=x.current;Ee(H,"Element ref not attached");let G=!1;return Oc(P,H,b,{coarse:$,fine:ie},(F,D,E)=>{if(!D){K("inactive");return}switch(F){case"down":{K("drag"),G=!1,Ee(E,'Expected event to be defined for "down" action'),N(P,E);const{onDragging:C,onPointerDown:W}=j.current;C==null||C(!0),W==null||W();break}case"move":{const{state:C}=se.current;G=!0,C!=="drag"&&K("hover"),Ee(E,'Expected event to be defined for "move" action'),z(E);break}case"up":{K("hover"),L();const{onClick:C,onDragging:W,onPointerUp:U}=j.current;W==null||W(!1),U==null||U(),G||C==null||C();break}}})},[$,b,n,ie,S,P,z,N,L]),sh({disabled:n,handleId:P,resizeHandler:z,panelGroupElement:R});const q={touchAction:"none",userSelect:"none"};return c.createElement(p,{...g,children:e,className:r,id:s,onBlur:()=>{B(!1),o==null||o()},onFocus:()=>{B(!0),d==null||d()},ref:x,role:"separator",style:{...q,...m},tabIndex:f,[Xe.groupDirection]:b,[Xe.groupId]:v,[Xe.resizeHandle]:"",[Xe.resizeHandleActive]:Q==="drag"?"pointer":J?"keyboard":void 0,[Xe.resizeHandleEnabled]:!n,[Xe.resizeHandleId]:P,[Xe.resizeHandleState]:Q})}zo.displayName="PanelResizeHandle";var oh=Object.defineProperty,lh=Object.getOwnPropertyNames,He=(e,r)=>function(){return e&&(r=(0,e[lh(e)[0]])(e=0)),r},ih=(e,r)=>{for(var n in r)oh(e,n,{get:r[n],enumerable:!0})};function at(...e){return zc(Ks(e))}var Pt=He({"src/components/graph-ui/utils.ts"(){}});function Tr({asChild:e=!1,className:r,size:n,variant:a,...s}){const o=e?Us:"button";return t.jsx(o,{"data-slot":"button",className:at(Po({variant:a,size:n,className:r})),...s})}var Po,sn=He({"src/components/graph-ui/Button.tsx"(){Pt(),Po=Er("inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium outline-none transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}})}});function Ro(...e){return e.filter(Boolean).join(" ")}function Bn({className:e,...r}){return t.jsx(Io,{"data-slot":"resizable-panel-group",className:Ro("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...r})}function or({...e}){return t.jsx(uo,{"data-slot":"resizable-panel",...e})}function Gn({withHandle:e,className:r,...n}){return t.jsx(zo,{"data-slot":"resizable-handle",className:Ro("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",r),...n,children:e?t.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:t.jsx(_.GripVerticalIcon,{className:"size-2.5"})}):null})}var Ao=He({"src/components/graph-workspace/GraphResizablePanels.tsx"(){}});function ia(...e){return e.filter(Boolean).join(" ")}function Lr({...e}){return t.jsx(nd,{"data-slot":"accordion",...e})}function Ir({className:e,...r}){return t.jsx(ad,{"data-slot":"accordion-item",className:ia("border-b last:border-b-0",e),...r})}function on({className:e,children:r,...n}){return t.jsx(od,{className:"flex",children:t.jsxs(ld,{"data-slot":"accordion-trigger",className:ia("flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium outline-none transition-all hover:underline disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",e),...n,children:[r,t.jsx(_.ChevronDownIcon,{className:"pointer-events-none size-4 shrink-0 translate-y-0.5 text-[var(--theme-fg-muted)] transition-transform duration-200"})]})})}function zr({className:e,children:r,...n}){return t.jsx(sd,{"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:ia("pb-4 pt-0",e),children:r})})}var Pr=He({"src/components/graph-workspace/GraphAccordion.tsx"(){}});function dh(e){var n;const r=[];for(const a of e.turns)for(const s of a.items)s.kind==="artifact"&&s.artifact&&r.push(s.artifact);for(const a of((n=e.liveItems)==null?void 0:n.items)??[])a.kind==="artifact"&&a.artifact&&r.push(a.artifact);return r}function ch(e){return e.trim().replace(/^\/+|\/+$/g,"").replace(/[^\w.-]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function Rr(e){var r;return((r=e.split(".").pop())==null?void 0:r.toLowerCase())||""}function hh(e){return e.split("/").filter(Boolean).at(-1)??e}function rr(e){const r=e.kind==="directory"?"directory":"file",n=(e.children??[]).map(rr);return{id:`workspace:${e.path}`,name:e.name,path:e.path,kind:r,...e.size!==void 0?{size:e.size}:{},...e.hasChildren!==void 0?{hasChildren:e.hasChildren}:r==="directory"?{hasChildren:n.length>0}:{},...e.childrenLoaded!==void 0?{childrenLoaded:e.childrenLoaded}:r==="directory"?{childrenLoaded:e.children!==void 0}:{},...e.truncated!==void 0?{truncated:e.truncated}:{},workspaceNode:e,children:n}}function Mo(e,r,n,a={}){if(e.path===r)return{...e,children:n,hasChildren:n.length>0,childrenLoaded:!0,truncated:a.truncated??e.truncated};if(e.children.length===0)return e;let s=!1;const o=e.children.map(l=>{const i=Mo(l,r,n,a);return i!==l&&(s=!0),i});return s?{...e,children:o}:e}function _o(e){if(e.kind==="file")return e;for(const r of e.children){const n=_o(r);if(n)return n}return null}function Fn(e,r){if(!e||r===null)return null;if(e.path===r)return e;for(const n of e.children){const a=Fn(n,r);if(a)return a}return null}function $o(e){return e.trim().replace(/\\/g,"/").replace(/^\.\/+/,"").replace(/^\/+/,"")}function uh(e){const n=$o(e).split("/").filter(Boolean);n.pop();const a=[];let s="";for(const o of n)s=s?`${s}/${o}`:o,a.push(s);return a}function Hn(e,r,n){if(e.path===r)return n;if(e.children.length===0)return e;let a=!1;const s=e.children.map(o=>{const l=Hn(o,r,n);return l!==o&&(a=!0),l});return a?{...e,children:s}:e}function On(e,r){return!e||!r?!1:e.path===r?!0:e.children.some(n=>On(n,r))}function mh(e){if(!e)return null;const r=Rr(e.path);return da.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 ch(e){const r=Rr(e);return r==="tsx"||r==="jsx"?"tsx":r==="yml"?"yaml":r||"text"}function hh(e,r){let n=e,a="";for(const s of r){a=a?`${a}/${s}`:s;let o=n.children.find(l=>l.kind==="directory"&&l.name===s);o||(o={id:`dir:${a}`,name:s,path:a,kind:"directory",children:[]},n.children.push(o)),n=o}return n}function uh(e,r,n){const a=r.split("/").filter(Boolean),s=a.pop()??n.name;hh(e,a).children.push({...n,name:n.name||s,path:r})}function mh(e,r){return e.kind==="directory"&&r.kind!=="directory"?-1:e.kind!=="directory"&&r.kind==="directory"?1:e.name.localeCompare(r.name)}function $o(e){e.children.sort(mh);for(const r of e.children)$o(r);return e}function Ua(e,r,n,a){var u;const s={id:"root",name:e.workspace.label??"Workspace",path:"",kind:"directory",children:[]},o={id:"artifacts",name:"artifacts",path:"artifacts",kind:"directory",children:[]};for(const m of r){const f=m.title||m.id,p=oh(f)||m.id;o.children.push({id:`artifact:${m.id}`,name:`${p}.artifact`,path:`artifacts/${p}.artifact`,kind:"artifact",artifact:m,preview:m.summaryText??m.type,detail:JSON.stringify(m.payload,null,2),children:[]})}const l={id:"thread-events",name:"thread-events",path:"thread-events",kind:"directory",children:[]},i={id:"live",name:"live",path:"live",kind:"directory",children:[]};let d=0;const h=(m,f,p=!1)=>{d+=1;const g=f.kind.replace(/([A-Z])/g,"-$1").toLowerCase(),k=`${p?"live":`thread-events/${m}`}/${String(d).padStart(3,"0")}-${g}.json`,w="text"in f&&typeof f.text=="string"?f.text.slice(0,160):f.kind,x=f.kind==="artifact"&&f.artifact?f.artifact:null,j=x&&p?{id:`live-artifact:${x.id}`,name:x.title||x.id,path:k,kind:"live-artifact",artifact:x,item:f,preview:x.summaryText??x.type,detail:JSON.stringify(x.payload,null,2),children:[]}:{id:`event:${f.id}`,name:lh(k),path:k,kind:"event",item:f,preview:w,detail:JSON.stringify(f,null,2),children:[]};if(p){i.children.push(j);return}uh(l,k.replace(/^thread-events\//,""),j)};for(const m of e.turns)for(const f of m.items)(f.kind==="commandExecution"||f.kind==="webSearch"||f.kind==="fileRead"||f.kind==="fileChange"||f.kind==="agentToolCall"||f.kind==="skillToolCall"||f.kind==="toolCall"||f.kind==="hook"||f.kind==="plan"||f.kind==="reasoning")&&h(m.id,f);for(const m of((u=e.liveItems)==null?void 0:u.items)??[])h(e.thread.activeTurnId??"live",m,!0);return s.children.push(o,l,i),$o(s)}function ph(e){const r=new Map,n=a=>{r.set(a.id,a);for(const s of a.children)n(s)};return n(e),r}function _o(e){if(e.kind==="artifact"||e.kind==="live-artifact"||e.kind==="event"||e.kind==="file")return e;for(const r of e.children){const n=_o(r);if(n)return n}return null}function Va(e){const r=e.split("/").filter(Boolean),n=[];for(let a=1;a<=r.length;a+=1)n.push(r.slice(0,a).join("/"));return n}var la,Do,Bo,ia=He({"src/components/graph-workspace/workspaceTree.ts"(){la=new Set(["xyz","extxyz","cif","pdb"]),Do=new Set(["png","jpg","jpeg","gif","webp","svg"]),Bo=new Set(["pdf"])}});function nr({label:e,children:r}){return t.jsxs("section",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:e}),t.jsx("div",{className:"mt-2 text-sm text-[var(--theme-fg)]",children:r})]})}var Go=He({"src/components/graph-workspace/GraphWorkspaceCards.tsx"(){}});function fh({className:e,decorative:r=!0,orientation:n="horizontal",...a}){return t.jsx(wd,{"data-slot":"separator",decorative:r,orientation:n,className:at("shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",e),...a})}var gh=He({"src/components/graph-ui/Separator.tsx"(){Pt()}});function xh({className:e,orientation:r,...n}){return t.jsx("div",{role:"group","data-slot":"button-group","data-orientation":r,className:at(Fo({orientation:r}),e),...n})}function bh({className:e,orientation:r="vertical",...n}){return t.jsx(fh,{"data-slot":"button-group-separator",orientation:r,className:at("relative !m-0 self-stretch bg-input data-[orientation=vertical]:h-auto",e),...n})}var Fo,Ho=He({"src/components/graph-ui/ButtonGroup.tsx"(){gh(),Pt(),Fo=Er("flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}})}});function vh({delayDuration:e=0,...r}){return t.jsx(yd,{"data-slot":"tooltip-provider",delayDuration:e,...r})}function kh({...e}){return t.jsx(vh,{children:t.jsx(gd,{"data-slot":"tooltip",...e})})}function wh({...e}){return t.jsx(xd,{"data-slot":"tooltip-trigger",...e})}function yh({children:e,className:r,sideOffset:n=0,...a}){return t.jsx(bd,{children:t.jsxs(vd,{"data-slot":"tooltip-content",sideOffset:n,className:at("z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md bg-foreground px-3 py-1.5 text-balance text-xs text-background animate-in fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",r),...a,children:[e,t.jsx(kd,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}var jh=He({"src/components/graph-ui/Tooltip.tsx"(){Pt()}});function Nh(e){return(e==null?void 0:e.trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""))||"molecule"}function qa(e,r){const n=new Blob([e],{type:"text/plain"}),a=URL.createObjectURL(n),s=document.createElement("a");s.href=a,s.download=r,s.click(),URL.revokeObjectURL(a)}function Ye({children:e,disabled:r,label:n,onClick:a}){return t.jsxs(kh,{children:[t.jsx(wh,{asChild:!0,children:t.jsx(Tr,{type:"button",variant:"outline",size:"icon",className:"thread-graph-molecule-button size-8",disabled:r,onClick:a,title:n,"aria-label":n,children:e})}),t.jsx(yh,{children:t.jsx("p",{children:n})})]})}function Hn({children:e,className:r=""}){return t.jsx(xh,{className:`thread-graph-molecule-button-group ${r}`,children:e})}var Oo=He({"src/components/graph-workspace/GraphMoleculeViewerControls.tsx"(){sn(),Ho(),jh()}});function Ch({cameraInfo:e,onClearSelection:r,onClearStaged:n,onSendSelection:a,onSendStaged:s,onStageSelection:o,onToggleUnitCell:l,selectedAtomLabels:i,selectedSerials:d,stagedAtoms:h,stagedMolecules:u,unitCellAvailable:m,unitCellVisible:f}){const p=d.length>0,g=h>0;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex w-full justify-between gap-2 overflow-x-auto",children:[t.jsxs(Hn,{children:[t.jsx(Ye,{label:"Distance",children:t.jsx($.AlignVerticalDistributeCenter,{className:"size-4"})}),t.jsx(Ye,{label:"Connectivity",children:t.jsx($.Share2,{className:"size-4"})}),t.jsx(Ye,{label:"Angle",children:t.jsx($.Waypoints,{className:"size-4"})}),t.jsx(Ye,{label:"Dihedral",children:t.jsx($.Spline,{className:"size-4"})}),t.jsx(Ye,{label:"Add dummy atoms",children:t.jsx($.Bubbles,{className:"size-4"})}),t.jsx(Ye,{label:"Delete atoms",children:t.jsx($.CircleX,{className:"size-4"})}),t.jsx(Ye,{label:"Rotate",children:t.jsx($.Rotate3d,{className:"size-4"})})]}),t.jsxs(Hn,{children:[t.jsx(Ye,{label:f?"Hide unit cell":"Show unit cell",disabled:!m,onClick:l,children:t.jsx($.Boxes,{className:"size-4"})}),t.jsx(Ye,{label:"Clear selection",disabled:!p,onClick:r,children:t.jsx($.Trash2,{className:"size-4"})}),t.jsx(Ye,{label:"Send selection",disabled:!p,onClick:a,children:t.jsx($.Send,{className:"size-4"})}),t.jsx(Ye,{label:"Stage current selection",disabled:!p,onClick:o,children:t.jsx($.Box,{className:"size-4"})}),t.jsx(Ye,{label:"Clear staged selections",disabled:!g,onClick:n,children:t.jsx($.Eraser,{className:"size-4"})}),t.jsx(Ye,{label:"Send staged selections",disabled:!g,onClick:s,children:t.jsx($.ArrowUpRight,{className:"size-4"})})]})]}),e?t.jsxs("div",{className:"thread-graph-molecule-camera",children:[t.jsxs("div",{children:[t.jsx("strong",{children:"XYZ: "}),"x=",e.position.x.toFixed(1)," y=",e.position.y.toFixed(1)," z=",e.position.z.toFixed(1),t.jsx("br",{}),t.jsx("strong",{children:"Quat: "}),"qx=",e.position.qx.toFixed(2)," qy=",e.position.qy.toFixed(2)," qz=",e.position.qz.toFixed(2)," qw=",e.position.qw.toFixed(2)]}),t.jsx("div",{className:"thread-graph-molecule-camera-divider"}),t.jsxs("div",{className:"flex flex-col gap-1 text-[10px]",children:[t.jsxs("div",{children:["Selected atoms:"," ",d.length>0?d.map(k=>`${i[k]??"Atom"}(${k})`).join(", "):"None"]}),t.jsxs("div",{children:["Staged: ",u," molecule(s), ",h," atom(s)"]})]})]}):null]})}var Sh=He({"src/components/graph-workspace/GraphMoleculeViewerLowerButtonGroup.tsx"(){Oo()}});function Th({currentIndex:e,exportContent:r,moleculeId:n,onScreenshot:a,viewerRef:s,xyzContent:o,xyzFormat:l}){const i=Nh(n);async function d(){o&&await navigator.clipboard.writeText(o)}function h(){o&&qa(o,`${i}_step_${e+1}.${l||"xyz"}`)}function u(){r&&qa(r,`${i}_trajectory.${l||"xyz"}`)}function m(){s.current&&(s.current.zoom(1.2),s.current.render())}function f(){s.current&&(s.current.zoom(.8),s.current.render())}function p(){s.current&&(s.current.zoomTo(),s.current.setCameraParameters({}),s.current.render())}return t.jsxs(Hn,{className:"ml-auto justify-end",children:[t.jsx(Ye,{label:"Copy current structure",onClick:()=>void d(),disabled:!o,children:t.jsx($.Copy,{className:"size-3.5"})}),t.jsx(Ye,{label:"Download current structure",onClick:h,disabled:!o,children:t.jsx($.Download,{className:"size-3.5"})}),t.jsx(Ye,{label:"Download full trajectory",onClick:u,disabled:!r,children:t.jsx($.Box,{className:"size-3.5"})}),t.jsx(Ye,{label:"Copy screenshot",onClick:a,disabled:!s.current||!o,children:t.jsx($.Camera,{className:"size-3.5"})}),t.jsx(bh,{className:"thread-graph-molecule-button-divider"}),t.jsx(Ye,{label:"Zoom in",onClick:m,disabled:!s.current||!o,children:t.jsx($.ZoomIn,{className:"size-3.5"})}),t.jsx(Ye,{label:"Zoom out",onClick:f,disabled:!s.current||!o,children:t.jsx($.ZoomOut,{className:"size-3.5"})}),t.jsx(Ye,{label:"Reset camera",onClick:p,disabled:!s.current||!o,children:t.jsx($.RotateCcw,{className:"size-3.5"})})]})}var Eh=He({"src/components/graph-workspace/GraphMoleculeViewerUpperButtonGroup.tsx"(){Ho(),Oo()}});async function Lh(){if(typeof window>"u")throw new Error("3Dmol is only available in a browser environment.");return window["3Dmol"]?window["3Dmol"]:(Hr||(Hr=new Promise((e,r)=>{const n=document.querySelector('script[data-remote-codex-3dmol="true"]'),a=()=>{if(window["3Dmol"]){e(window["3Dmol"]);return}r(new Error("3Dmol loaded without exposing the expected global."))};if(n){n.addEventListener("load",a,{once:!0}),n.addEventListener("error",()=>r(new Error("Unable to load 3Dmol viewer runtime.")),{once:!0});return}const s=document.createElement("script");s.src="/vendor/3Dmol-min.js",s.async=!0,s.dataset.remoteCodex3dmol="true",s.addEventListener("load",a,{once:!0}),s.addEventListener("error",()=>r(new Error("Unable to load 3Dmol viewer runtime.")),{once:!0}),document.head.appendChild(s)})),Hr)}var Hr,Ih=He({"src/components/graph-workspace/load3Dmol.ts"(){Hr=null}});function zh({className:e,defaultValue:r,max:n=100,min:a=0,value:s,...o}){const l=c.useMemo(()=>Array.isArray(s)?s:Array.isArray(r)?r:[a,n],[r,n,a,s]);return t.jsxs(ud,{"data-slot":"slider",...r!==void 0?{defaultValue:r}:{},...s!==void 0?{value:s}:{},min:a,max:n,className:at("relative flex w-full touch-none select-none items-center data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",e),...o,children:[t.jsx(md,{"data-slot":"slider-track",className:"relative grow overflow-hidden rounded-full bg-muted data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5",children:t.jsx(pd,{"data-slot":"slider-range",className:"absolute bg-primary data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"})}),Array.from({length:l.length},(i,d)=>t.jsx(fd,{"data-slot":"slider-thumb",className:"block size-4 shrink-0 rounded-full border border-primary bg-white shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:outline-hidden focus-visible:ring-4 disabled:pointer-events-none disabled:opacity-50"},d))]})}var Ph=He({"src/components/graph-ui/Slider.tsx"(){Pt()}});function Rh(e){const r=e==null?void 0:e.trim().toLowerCase();return!r||r==="extxyz"?"xyz":r}function Ah(e){var s,o;const r=e.replace(/\r\n/g,`
|
|
4
|
+
`],format:r==="extxyz"?"xyz":r,name:e.name,uuid:e.path}:null}function ph(e){const r=Rr(e);return r==="tsx"||r==="jsx"?"tsx":r==="yml"?"yaml":r||"text"}function fh(e,r){let n=e,a="";for(const s of r){a=a?`${a}/${s}`:s;let o=n.children.find(l=>l.kind==="directory"&&l.name===s);o||(o={id:`dir:${a}`,name:s,path:a,kind:"directory",children:[]},n.children.push(o)),n=o}return n}function gh(e,r,n){const a=r.split("/").filter(Boolean),s=a.pop()??n.name;fh(e,a).children.push({...n,name:n.name||s,path:r})}function xh(e,r){return e.kind==="directory"&&r.kind!=="directory"?-1:e.kind!=="directory"&&r.kind==="directory"?1:e.name.localeCompare(r.name)}function Do(e){e.children.sort(xh);for(const r of e.children)Do(r);return e}function qa(e,r,n,a){var u;const s={id:"root",name:e.workspace.label??"Workspace",path:"",kind:"directory",children:[]},o={id:"artifacts",name:"artifacts",path:"artifacts",kind:"directory",children:[]};for(const m of r){const f=m.title||m.id,p=ch(f)||m.id;o.children.push({id:`artifact:${m.id}`,name:`${p}.artifact`,path:`artifacts/${p}.artifact`,kind:"artifact",artifact:m,preview:m.summaryText??m.type,detail:JSON.stringify(m.payload,null,2),children:[]})}const l={id:"thread-events",name:"thread-events",path:"thread-events",kind:"directory",children:[]},i={id:"live",name:"live",path:"live",kind:"directory",children:[]};let d=0;const h=(m,f,p=!1)=>{d+=1;const g=f.kind.replace(/([A-Z])/g,"-$1").toLowerCase(),k=`${p?"live":`thread-events/${m}`}/${String(d).padStart(3,"0")}-${g}.json`,w="text"in f&&typeof f.text=="string"?f.text.slice(0,160):f.kind,x=f.kind==="artifact"&&f.artifact?f.artifact:null,j=x&&p?{id:`live-artifact:${x.id}`,name:x.title||x.id,path:k,kind:"live-artifact",artifact:x,item:f,preview:x.summaryText??x.type,detail:JSON.stringify(x.payload,null,2),children:[]}:{id:`event:${f.id}`,name:hh(k),path:k,kind:"event",item:f,preview:w,detail:JSON.stringify(f,null,2),children:[]};if(p){i.children.push(j);return}gh(l,k.replace(/^thread-events\//,""),j)};for(const m of e.turns)for(const f of m.items)(f.kind==="commandExecution"||f.kind==="webSearch"||f.kind==="fileRead"||f.kind==="fileChange"||f.kind==="agentToolCall"||f.kind==="skillToolCall"||f.kind==="toolCall"||f.kind==="hook"||f.kind==="plan"||f.kind==="reasoning")&&h(m.id,f);for(const m of((u=e.liveItems)==null?void 0:u.items)??[])h(e.thread.activeTurnId??"live",m,!0);return s.children.push(o,l,i),Do(s)}function bh(e){const r=new Map,n=a=>{r.set(a.id,a);for(const s of a.children)n(s)};return n(e),r}function Bo(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=Bo(r);if(n)return n}return null}function Xa(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 da,Go,Fo,ca=He({"src/components/graph-workspace/workspaceTree.ts"(){da=new Set(["xyz","extxyz","cif","pdb"]),Go=new Set(["png","jpg","jpeg","gif","webp","svg"]),Fo=new Set(["pdf"])}});function nr({label:e,children:r}){return t.jsxs("section",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:e}),t.jsx("div",{className:"mt-2 text-sm text-[var(--theme-fg)]",children:r})]})}var Ho=He({"src/components/graph-workspace/GraphWorkspaceCards.tsx"(){}});function vh({className:e,decorative:r=!0,orientation:n="horizontal",...a}){return t.jsx(Cd,{"data-slot":"separator",decorative:r,orientation:n,className:at("shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",e),...a})}var kh=He({"src/components/graph-ui/Separator.tsx"(){Pt()}});function wh({className:e,orientation:r,...n}){return t.jsx("div",{role:"group","data-slot":"button-group","data-orientation":r,className:at(Oo({orientation:r}),e),...n})}function yh({className:e,orientation:r="vertical",...n}){return t.jsx(vh,{"data-slot":"button-group-separator",orientation:r,className:at("relative !m-0 self-stretch bg-input data-[orientation=vertical]:h-auto",e),...n})}var Oo,Wo=He({"src/components/graph-ui/ButtonGroup.tsx"(){kh(),Pt(),Oo=Er("flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}})}});function jh({delayDuration:e=0,...r}){return t.jsx(Sd,{"data-slot":"tooltip-provider",delayDuration:e,...r})}function Nh({...e}){return t.jsx(jh,{children:t.jsx(kd,{"data-slot":"tooltip",...e})})}function Ch({...e}){return t.jsx(wd,{"data-slot":"tooltip-trigger",...e})}function Sh({children:e,className:r,sideOffset:n=0,...a}){return t.jsx(yd,{children:t.jsxs(jd,{"data-slot":"tooltip-content",sideOffset:n,className:at("z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md bg-foreground px-3 py-1.5 text-balance text-xs text-background animate-in fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",r),...a,children:[e,t.jsx(Nd,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}var Th=He({"src/components/graph-ui/Tooltip.tsx"(){Pt()}});function Eh(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),s=document.createElement("a");s.href=a,s.download=r,s.click(),URL.revokeObjectURL(a)}function Ye({children:e,disabled:r,label:n,onClick:a}){return t.jsxs(Nh,{children:[t.jsx(Ch,{asChild:!0,children:t.jsx(Tr,{type:"button",variant:"outline",size:"icon",className:"thread-graph-molecule-button size-8",disabled:r,onClick:a,title:n,"aria-label":n,children:e})}),t.jsx(Sh,{children:t.jsx("p",{children:n})})]})}function Wn({children:e,className:r=""}){return t.jsx(wh,{className:`thread-graph-molecule-button-group ${r}`,children:e})}var Uo=He({"src/components/graph-workspace/GraphMoleculeViewerControls.tsx"(){sn(),Wo(),Th()}});function Lh({cameraInfo:e,onClearSelection:r,onClearStaged:n,onSendSelection:a,onSendStaged:s,onStageSelection:o,onToggleUnitCell:l,selectedAtomLabels:i,selectedSerials:d,stagedAtoms:h,stagedMolecules:u,unitCellAvailable:m,unitCellVisible:f}){const p=d.length>0,g=h>0;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex w-full justify-between gap-2 overflow-x-auto",children:[t.jsxs(Wn,{children:[t.jsx(Ye,{label:"Distance",children:t.jsx(_.AlignVerticalDistributeCenter,{className:"size-4"})}),t.jsx(Ye,{label:"Connectivity",children:t.jsx(_.Share2,{className:"size-4"})}),t.jsx(Ye,{label:"Angle",children:t.jsx(_.Waypoints,{className:"size-4"})}),t.jsx(Ye,{label:"Dihedral",children:t.jsx(_.Spline,{className:"size-4"})}),t.jsx(Ye,{label:"Add dummy atoms",children:t.jsx(_.Bubbles,{className:"size-4"})}),t.jsx(Ye,{label:"Delete atoms",children:t.jsx(_.CircleX,{className:"size-4"})}),t.jsx(Ye,{label:"Rotate",children:t.jsx(_.Rotate3d,{className:"size-4"})})]}),t.jsxs(Wn,{children:[t.jsx(Ye,{label:f?"Hide unit cell":"Show unit cell",disabled:!m,onClick:l,children:t.jsx(_.Boxes,{className:"size-4"})}),t.jsx(Ye,{label:"Clear selection",disabled:!p,onClick:r,children:t.jsx(_.Trash2,{className:"size-4"})}),t.jsx(Ye,{label:"Send selection",disabled:!p,onClick:a,children:t.jsx(_.Send,{className:"size-4"})}),t.jsx(Ye,{label:"Stage current selection",disabled:!p,onClick:o,children:t.jsx(_.Box,{className:"size-4"})}),t.jsx(Ye,{label:"Clear staged selections",disabled:!g,onClick:n,children:t.jsx(_.Eraser,{className:"size-4"})}),t.jsx(Ye,{label:"Send staged selections",disabled:!g,onClick:s,children:t.jsx(_.ArrowUpRight,{className:"size-4"})})]})]}),e?t.jsxs("div",{className:"thread-graph-molecule-camera",children:[t.jsxs("div",{children:[t.jsx("strong",{children:"XYZ: "}),"x=",e.position.x.toFixed(1)," y=",e.position.y.toFixed(1)," z=",e.position.z.toFixed(1),t.jsx("br",{}),t.jsx("strong",{children:"Quat: "}),"qx=",e.position.qx.toFixed(2)," qy=",e.position.qy.toFixed(2)," qz=",e.position.qz.toFixed(2)," qw=",e.position.qw.toFixed(2)]}),t.jsx("div",{className:"thread-graph-molecule-camera-divider"}),t.jsxs("div",{className:"flex flex-col gap-1 text-[10px]",children:[t.jsxs("div",{children:["Selected atoms:"," ",d.length>0?d.map(k=>`${i[k]??"Atom"}(${k})`).join(", "):"None"]}),t.jsxs("div",{children:["Staged: ",u," molecule(s), ",h," atom(s)"]})]})]}):null]})}var Ih=He({"src/components/graph-workspace/GraphMoleculeViewerLowerButtonGroup.tsx"(){Uo()}});function zh({currentIndex:e,exportContent:r,moleculeId:n,onScreenshot:a,viewerRef:s,xyzContent:o,xyzFormat:l}){const i=Eh(n);async function d(){o&&await navigator.clipboard.writeText(o)}function h(){o&&Ka(o,`${i}_step_${e+1}.${l||"xyz"}`)}function u(){r&&Ka(r,`${i}_trajectory.${l||"xyz"}`)}function m(){s.current&&(s.current.zoom(1.2),s.current.render())}function f(){s.current&&(s.current.zoom(.8),s.current.render())}function p(){s.current&&(s.current.zoomTo(),s.current.setCameraParameters({}),s.current.render())}return t.jsxs(Wn,{className:"ml-auto justify-end",children:[t.jsx(Ye,{label:"Copy current structure",onClick:()=>void d(),disabled:!o,children:t.jsx(_.Copy,{className:"size-3.5"})}),t.jsx(Ye,{label:"Download current structure",onClick:h,disabled:!o,children:t.jsx(_.Download,{className:"size-3.5"})}),t.jsx(Ye,{label:"Download full trajectory",onClick:u,disabled:!r,children:t.jsx(_.Box,{className:"size-3.5"})}),t.jsx(Ye,{label:"Copy screenshot",onClick:a,disabled:!s.current||!o,children:t.jsx(_.Camera,{className:"size-3.5"})}),t.jsx(yh,{className:"thread-graph-molecule-button-divider"}),t.jsx(Ye,{label:"Zoom in",onClick:m,disabled:!s.current||!o,children:t.jsx(_.ZoomIn,{className:"size-3.5"})}),t.jsx(Ye,{label:"Zoom out",onClick:f,disabled:!s.current||!o,children:t.jsx(_.ZoomOut,{className:"size-3.5"})}),t.jsx(Ye,{label:"Reset camera",onClick:p,disabled:!s.current||!o,children:t.jsx(_.RotateCcw,{className:"size-3.5"})})]})}var Ph=He({"src/components/graph-workspace/GraphMoleculeViewerUpperButtonGroup.tsx"(){Wo(),Uo()}});async function Rh(){if(typeof window>"u")throw new Error("3Dmol is only available in a browser environment.");return window["3Dmol"]?window["3Dmol"]:(Hr||(Hr=new Promise((e,r)=>{const n=document.querySelector('script[data-remote-codex-3dmol="true"]'),a=()=>{if(window["3Dmol"]){e(window["3Dmol"]);return}r(new Error("3Dmol loaded without exposing the expected global."))};if(n){n.addEventListener("load",a,{once:!0}),n.addEventListener("error",()=>r(new Error("Unable to load 3Dmol viewer runtime.")),{once:!0});return}const s=document.createElement("script");s.src="/vendor/3Dmol-min.js",s.async=!0,s.dataset.remoteCodex3dmol="true",s.addEventListener("load",a,{once:!0}),s.addEventListener("error",()=>r(new Error("Unable to load 3Dmol viewer runtime.")),{once:!0}),document.head.appendChild(s)})),Hr)}var Hr,Ah=He({"src/components/graph-workspace/load3Dmol.ts"(){Hr=null}});function Mh({className:e,defaultValue:r,max:n=100,min:a=0,value:s,...o}){const l=c.useMemo(()=>Array.isArray(s)?s:Array.isArray(r)?r:[a,n],[r,n,a,s]);return t.jsxs(gd,{"data-slot":"slider",...r!==void 0?{defaultValue:r}:{},...s!==void 0?{value:s}:{},min:a,max:n,className:at("relative flex w-full touch-none select-none items-center data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",e),...o,children:[t.jsx(xd,{"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(bd,{"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(vd,{"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 _h=He({"src/components/graph-ui/Slider.tsx"(){Pt()}});function $h(e){const r=e==null?void 0:e.trim().toLowerCase();return!r||r==="extxyz"?"xyz":r}function Dh(e){var s,o;const r=e.replace(/\r\n/g,`
|
|
5
5
|
`).replace(/\r/g,`
|
|
6
6
|
`).split(`
|
|
7
7
|
`),n=[];let a=0;for(;a<r.length;){for(;a<r.length&&((s=r[a])==null?void 0:s.trim())==="";)a+=1;if(a>=r.length)break;const l=Number.parseInt(((o=r[a])==null?void 0:o.trim())??"",10);if(!Number.isFinite(l)||l<0)return[e];const i=l+2;if(a+i>r.length)return[e];n.push(`${r.slice(a,a+i).join(`
|
|
8
8
|
`)}
|
|
9
|
-
`),a+=i}return n.length>0?n:[e]}function
|
|
10
|
-
`).join("")}function
|
|
11
|
-
`).slice(2).map(
|
|
12
|
-
`).length<=Uo}function Gh(e){return e&&(e.node.path||e.node.name)||null}function Fh(e){if(!e)return null;switch(e.kind){case"live-artifact":return{kind:"live-molecule",node:e};case"file":return{kind:"workspace-file",node:e};case"artifact":return{kind:"artifact",node:e};case"event":return{kind:"event",node:e};case"meta":return{kind:"meta",node:e};case"directory":return null}}function Hh({error:e,imageUrl:r,loadingMore:n,onSaveFile:a,onLoadMore:s,onCollapse:o,pdfUrl:l,previewFile:i,previewLoading:d,plugins:h,selectedTarget:u}){const[m,f]=c.useState(!1),[p,g]=c.useState(""),[k,w]=c.useState(null),[x,j]=c.useState(!1),y=(u==null?void 0:u.node)??null,b=y!=null&&y.artifact?h.renderArtifact({artifact:y.artifact,expanded:!0,onToggleExpanded:()=>{}}):null,v=dh(i??null),S=(i==null?void 0:i.language)||ch((i==null?void 0:i.path)??""),N=i?Rr(i.path):"",L=Gh(u),R=i!==null&&la.has(N),P=!!(i&&a)&&!R&&Bh(i),Q=(u==null?void 0:u.kind)==="live-molecule",D=!!(y!=null&&y.artifact&&b),Z=!!v||D;c.useEffect(()=>{f(!1),g((i==null?void 0:i.content)??""),w(null)},[i==null?void 0:i.path,i==null?void 0:i.content]);async function J(){if(!(!i||!a)){j(!0),w(null);try{await a({path:i.path,content:p}),f(!1)}catch(z){w(z instanceof Error?z.message:"Failed to save file.")}finally{j(!1)}}}return t.jsxs("section",{className:"thread-graph-viewer flex h-full min-h-0 flex-col overflow-hidden rounded-[12px]","data-preview-target-kind":(u==null?void 0:u.kind)??"none",children:[t.jsxs("div",{className:"thread-graph-viewer-header flex h-12 shrink-0 items-center justify-between gap-3 border-b px-3 sm:h-[60px] sm:px-5",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[t.jsx("h2",{className:"text-base font-semibold text-slate-900 sm:text-[18px] dark:text-slate-100",children:"Viewer"}),L?t.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-slate-500 dark:text-slate-400",children:L}):null]}),o?t.jsx("button",{type:"button",onClick:o,"data-testid":"collapse-viewer",className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-[#222733] dark:hover:text-slate-100",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx($.ChevronsRight,{className:"h-4 w-4"})}):null]}),t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[e?t.jsx("div",{className:"border-b border-rose-200 bg-rose-50 px-5 py-3 text-sm text-rose-700 dark:border-rose-400/25 dark:bg-rose-400/10 dark:text-rose-200",children:e}):null,u?u.kind==="workspace-file"&&d?t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center px-5 text-center text-sm text-slate-400 dark:text-slate-500",children:"Loading file preview..."}):u.kind==="workspace-file"&&v?t.jsx("div",{className:"thread-graph-molecule-preview min-h-0 flex-1 overflow-hidden",children:t.jsx(_h,{source:v,moleculeId:v.uuid??u.node.path,title:"PyMOL-style (PDB/CIF)"})}):u.kind==="workspace-file"&&r?t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-auto p-5",children:t.jsx("img",{src:r,alt:u.node.path||u.node.name,className:"max-h-full max-w-full object-contain"})}):u.kind==="workspace-file"&&l?t.jsx("div",{className:"thread-graph-file-preview-frame min-h-0 flex-1 overflow-hidden",children:t.jsx("iframe",{src:l,title:`PDF preview: ${u.node.path||u.node.name}`,className:"h-full w-full border-0"})}):u.kind==="workspace-file"&&i?t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs("div",{className:"thread-graph-file-preview-header flex min-h-12 items-center justify-between gap-3 border-b px-4 py-2",children:[t.jsxs("div",{className:"min-w-0 text-xs uppercase tracking-[0.12em]",children:[R?"molecule":S||N||"text"," |"," ",i.size.toLocaleString()," bytes",i.truncated?t.jsxs("span",{className:"ml-2 text-amber-500",children:["showing ",i.nextOffset.toLocaleString()," bytes"]}):null]}),P?t.jsx("div",{className:"flex shrink-0 items-center gap-1",children:m?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>{g(i.content),f(!1),w(null)},disabled:x,className:"thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition disabled:cursor-not-allowed disabled:opacity-50",title:"Cancel edits","aria-label":"Cancel edits",children:t.jsx($.X,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:()=>void J(),disabled:x||p===i.content,className:"thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition disabled:cursor-not-allowed disabled:opacity-50",title:"Save file","aria-label":"Save file",children:t.jsx($.Save,{className:"h-4 w-4"})})]}):t.jsx("button",{type:"button",onClick:()=>{g(i.content),f(!0),w(null)},className:"thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition",title:"Edit file","aria-label":"Edit file",children:t.jsx($.Pencil,{className:"h-4 w-4"})})}):null]}),k?t.jsx("div",{className:"border-b border-rose-200 bg-rose-50 px-4 py-2 text-sm text-rose-700 dark:border-rose-400/25 dark:bg-rose-400/10 dark:text-rose-200",children:k}):null,m?t.jsx("textarea",{value:p,onChange:z=>g(z.currentTarget.value),spellCheck:!1,"aria-label":"Workspace file editor",className:"thread-graph-file-editor min-h-0 flex-1 resize-none border-0 bg-transparent p-4 font-mono text-[12px] leading-5 text-slate-900 outline-none dark:text-slate-100"}):t.jsx(Or,{content:i.content}),i.truncated&&s?t.jsx("div",{className:"thread-graph-file-preview-footer flex justify-center border-t px-4 py-3",children:t.jsx("button",{type:"button",onClick:s,disabled:n,title:"Load more workspace preview","aria-label":"Load more workspace preview",className:"thread-graph-load-more-button rounded-md px-4 py-1.5 text-xs disabled:opacity-50",children:n?"Loading...":`Load more (${(i.size-i.nextOffset).toLocaleString()} bytes remaining)`})}):null]}):(u.kind==="live-molecule"||u.kind==="artifact")&&u.node.artifact?t.jsx("div",{className:Z||Q?"min-h-0 flex-1 overflow-hidden":"min-h-0 flex-1 overflow-auto p-3",children:b}):u.kind==="meta"?t.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-3",children:t.jsx("div",{className:"grid gap-3",children:t.jsx(nr,{label:"Workspace Data",children:t.jsx(Or,{content:u.node.detail??""})})})}):t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsx("div",{className:"thread-graph-file-preview-header border-b px-4 py-3 text-xs uppercase tracking-[0.12em]",children:u.node.kind}),t.jsx(Or,{content:u.node.detail??u.node.preview??u.node.name})]}):t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center px-5 text-center text-sm text-slate-400 dark:text-slate-500",children:"Pick a live molecule, workspace file, artifact, or thread event to preview it."})]})]})}var Wo,Uo,Or,Oh=He({"src/components/graph-workspace/GraphWorkspacePreviewPane.tsx"(){ia(),Go(),Dh(),Wo=50*1024,Uo=1e3,Or=c.memo(function({content:r}){return t.jsx("div",{className:"thread-graph-code-preview min-h-0 flex-1 overflow-auto",children:t.jsx("pre",{className:"thread-graph-plain-code-preview",children:t.jsx("code",{children:r})})})})}});function Wh({files:e,onCancel:r,onConfirm:n}){return t.jsx("div",{className:"thread-graph-dialog-backdrop fixed inset-0 z-50 flex items-center justify-center bg-black/40 px-4",children:t.jsxs("div",{className:"thread-graph-dialog w-full max-w-sm rounded-xl border bg-[var(--theme-panel)] p-6 shadow-xl",children:[t.jsx("h3",{className:"text-base font-semibold text-[var(--theme-fg)]",children:"Empty garbage?"}),t.jsxs("p",{className:"mt-1 text-sm leading-5 text-[var(--theme-fg-muted)]",children:["Permanently delete all files in the"," ",t.jsx("code",{className:"rounded bg-[var(--theme-muted)] px-1 text-xs text-[var(--theme-fg-soft)]",children:"garbage/"})," ","folder."]}),e.length===0?t.jsx("p",{className:"mt-3 text-sm text-[var(--theme-fg-muted)]",children:"Garbage is empty."}):t.jsx("ul",{className:"mt-3 max-h-40 overflow-y-auto rounded-md border border-[var(--theme-border)] bg-[var(--theme-surface)] p-2 text-xs text-[var(--theme-fg-soft)]",children:e.map(a=>t.jsx("li",{className:"truncate py-0.5",title:a,children:a},a))}),t.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:r,className:"thread-secondary-action rounded-md px-3 py-1.5 text-sm",children:"Cancel"}),e.length>0?t.jsx("button",{type:"button",onClick:n,className:"ui-action-danger rounded-md px-3 py-1.5 text-sm font-medium",children:"Yes, empty garbage"}):null]})]})})}var Uh=He({"src/components/graph-workspace/GraphEmptyGarbageDialog.tsx"(){}});function Vo(e){return`${Ko}${e.workspaceId??"workspace"}:${e.threadId}`}function Vh(e){if(typeof window>"u")return[];try{const r=window.localStorage.getItem(Vo(e));if(!r)return[];const n=JSON.parse(r);return Array.isArray(n)?n.filter(a=>typeof a=="string"):[]}catch{return[]}}function Ya(e,r){if(!(typeof window>"u"))try{window.localStorage.setItem(Vo(e),JSON.stringify([...r]))}catch{}}function On(e,r){if(!r||e.path!==r.path||e.kind!=="directory")return e;const n=new Map(r.children.map(o=>[o.path,o])),a=e.children.map(o=>On(o,n.get(o.path)??null)),s=e.childrenLoaded&&e.children.length>0;return{...e,children:s||!r.childrenLoaded?a:r.children,childrenLoaded:e.childrenLoaded||r.childrenLoaded,truncated:e.truncated??r.truncated}}function Za(e,r){if(e.kind==="directory")return r?t.jsx($.FolderOpen,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"}):t.jsx($.Folder,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"});const n=Rr(e.name);return n==="zip"?t.jsx($.FileArchive,{className:"h-4 w-4 text-amber-600"}):e.kind==="file"&&["png","jpg","jpeg","gif","webp","svg"].includes(n)?t.jsx($.FileImage,{className:"h-4 w-4 text-sky-500"}):e.kind==="artifact"||["xyz","extxyz","cif","pdf","json","ts","tsx","js","jsx","md","yaml","yml","py"].includes(n)?t.jsx($.FileCode2,{className:"h-4 w-4 text-emerald-600"}):t.jsx($.File,{className:"h-4 w-4 text-slate-400 dark:text-slate-500"})}function qo({depth:e,expandedPaths:r,loadingPaths:n,node:a,onCopyPath:s,onDownload:o,onPreview:l,onSelect:i,onToggle:d,selectedNodeId:h}){const u=a.kind==="directory",m=u&&(a.path===""||r.has(a.path)),f=u&&n.has(a.path),p=h===a.id,g=`${e*.75+.5}rem`;return u?t.jsxs("div",{children:[t.jsxs("div",{className:"thread-graph-tree-row group flex items-center text-sm text-slate-600 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100",children:[t.jsxs("button",{type:"button",onClick:()=>d(a.path),className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 px-2 py-2 text-left sm:min-h-0 sm:py-1.5",style:{paddingLeft:g},children:[m?t.jsx($.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}):t.jsx($.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}),Za(a,m),t.jsx("span",{className:"truncate",children:a.name}),f?t.jsx("span",{className:"ml-auto shrink-0 text-xs text-slate-400 dark:text-slate-500",children:"Loading"}):null]}),o?t.jsx("button",{type:"button",onClick:()=>o(a),className:"thread-graph-tree-action mr-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-slate-400 transition hover:bg-white hover:text-slate-900 sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100",title:a.path?`Download ${a.name}`:"Download workspace","aria-label":a.path?`Download ${a.name}`:"Download workspace",children:t.jsx($.Download,{className:"h-3.5 w-3.5"})}):null,s&&a.path?t.jsx("button",{type:"button",onClick:()=>s(a),className:"thread-graph-tree-action mr-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-slate-400 transition hover:bg-white hover:text-slate-900 sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100",title:`Copy path for ${a.name}`,"aria-label":`Copy path for ${a.name}`,children:t.jsx($.Copy,{className:"h-3.5 w-3.5"})}):null]}),m?t.jsxs("div",{children:[a.children.map(k=>t.jsx(qo,{depth:e+1,expandedPaths:r,loadingPaths:n,node:k,...s?{onCopyPath:s}:{},...o?{onDownload:o}:{},...l?{onPreview:l}:{},onSelect:i,onToggle:d,selectedNodeId:h},k.id)),a.truncated?t.jsx("div",{className:"px-2 py-1 text-xs text-slate-400 dark:text-slate-500",style:{paddingLeft:`${(e+1)*.75+.5}rem`},children:"More items not shown"}):null]}):null]}):t.jsxs("div",{className:`thread-graph-tree-row group flex items-center text-sm transition ${p?"is-selected":"text-slate-600 hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100"}`,children:[t.jsxs("button",{type:"button",onClick:()=>i(a.id),className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 px-2 py-2 text-left sm:min-h-0 sm:py-1.5",style:{paddingLeft:`${e*.75+2.2}rem`},children:[Za(a,!1),t.jsx("span",{className:"truncate",children:a.name})]}),a.kind==="file"&&(l||o||s)?t.jsxs("div",{className:"mr-1 flex shrink-0 items-center gap-0.5",children:[l?t.jsx("button",{type:"button",onClick:()=>l(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${p?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Preview ${a.name}`,"aria-label":`Preview ${a.name}`,children:t.jsx($.Eye,{className:"h-3.5 w-3.5"})}):null,o?t.jsx("button",{type:"button",onClick:()=>o(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${p?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Download ${a.name}`,"aria-label":`Download ${a.name}`,children:t.jsx($.Download,{className:"h-3.5 w-3.5"})}):null,s?t.jsx("button",{type:"button",onClick:()=>s(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${p?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Copy path for ${a.name}`,"aria-label":`Copy path for ${a.name}`,children:t.jsx($.Copy,{className:"h-3.5 w-3.5"})}):null]}):null]})}function qh({liveNodes:e,onSelect:r,selectedNodeId:n}){return e.length===0?null:t.jsxs("div",{className:"border-b border-slate-200 py-2 dark:border-[#2a2f3a]",children:[t.jsx("div",{className:"thread-graph-workspace-label px-3 pb-1 text-[11px] font-semibold tracking-normal text-slate-500 dark:text-slate-400",children:"Live"}),t.jsx("div",{className:"space-y-0.5",children:e.map(a=>{var o;const s=n===a.id;return t.jsxs("button",{type:"button","data-testid":"live-molecule-item","data-molecule-id":((o=a.artifact)==null?void 0:o.id)??a.id,onClick:()=>r(a.id),className:`thread-graph-tree-row flex min-h-9 w-full items-center gap-2 px-3 py-2 text-left text-sm transition sm:min-h-0 sm:py-1.5 ${s?"is-selected":"text-slate-600 hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100"}`,children:[t.jsx($.FileCode2,{className:`h-4 w-4 shrink-0 ${s?"text-current":"text-emerald-600 dark:text-emerald-300"}`}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:a.name})]},a.id)})})]})}function Kh({canEmptyGarbage:e,canUpload:r,onCollapse:n,expandedPaths:a,loadingPaths:s,loading:o,onDownload:l,onCopyPath:i,onEmptyGarbage:d,onPreview:h,onRefresh:u,onSelect:m,onToggle:f,onUpload:p,explorerScrollTopRef:g,explorerScrollerRef:k,selectedNodeId:w,tree:x,liveNodes:j}){const y=c.useMemo(()=>({...x,children:x.children.filter(b=>b.path!=="live")}),[x]);return c.useLayoutEffect(()=>{const b=k.current;b&&(b.scrollTop=g.current)},[k,g]),t.jsxs("aside",{className:`${Xo} flex flex-col`,children:[t.jsxs("div",{className:Yo,children:[t.jsx("div",{className:"min-w-0",children:t.jsx("h2",{className:Zo,children:"Explorer"})}),t.jsxs("div",{className:"flex items-center gap-1",children:[n?t.jsxs("button",{type:"button","data-testid":"collapse-explorer",onClick:n,className:Jo,title:"Collapse Explorer","aria-label":"Collapse Explorer",children:[t.jsx($.ChevronsLeft,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Collapse Explorer"})]}):null,t.jsx("button",{type:"button",onClick:p,disabled:!r,className:Ur,title:r?"Upload file":"Upload is unavailable for this workspace","aria-label":"Upload file",children:t.jsx($.Upload,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:u,className:Ur,title:"Refresh workspace","aria-label":"Refresh workspace",children:t.jsx($.RefreshCw,{className:`h-4 w-4 ${o?"animate-spin":""}`})}),d?t.jsx("button",{type:"button",onClick:d,disabled:!e,className:Ur,title:e?"Empty garbage":"Garbage controls are unavailable","aria-label":"Empty garbage",children:t.jsx($.Trash2,{className:"h-4 w-4"})}):null]})]}),t.jsxs("div",{ref:k,className:"thread-graph-workspace-tree-scroll min-h-0 flex-1 overflow-y-auto py-2",onScroll:b=>{g.current=b.currentTarget.scrollTop},children:[t.jsx(qh,{liveNodes:j??[],onSelect:m,selectedNodeId:w}),t.jsx("div",{className:Qo,children:"Workspace"}),t.jsx(qo,{depth:0,expandedPaths:a,loadingPaths:s,node:y,...i?{onCopyPath:i}:{},...l?{onDownload:l}:{},...h?{onPreview:h}:{},onSelect:m,onToggle:f,selectedNodeId:w}),y.children.length===0?t.jsx("p",{className:el,children:"This workspace is empty. Agent tool runs execute inside the thread workspace, so files should appear here as the session works."}):null]})]})}function Xh({activeView:e,detail:r,artifacts:n,plugins:a,status:s,focusPathRequest:o,workspaceAdapter:l}){const[i,d]=c.useState(null),h=c.useMemo(()=>l&&i?null:Ua(r,n),[e,i,n,r,s,l]),u=i??h??Ua(r,n),m=c.useMemo(()=>ph(u),[u]),f=c.useMemo(()=>{var I;return((I=u.children.find(O=>O.path==="live"))==null?void 0:I.children)??[]},[u]),p=_o(u),[g,k]=c.useState(()=>(p==null?void 0:p.id)??null),[w,x]=c.useState(()=>new Set(["","artifacts","thread-events","live",...Va((p==null?void 0:p.path)??"")])),[j,y]=c.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 639px)").matches?"viewer":null),[b,v]=c.useState(null),[S,N]=c.useState(!1),[L,R]=c.useState(()=>new Set),[P,Q]=c.useState(!1),[D,Z]=c.useState(!1),[J,z]=c.useState(!1),[te,se]=c.useState([]),[_,ie]=c.useState(null),[q,H]=c.useState(null),[G,T]=c.useState(null),[F,B]=c.useState(!1),E=c.useRef(null),C=c.useRef(null),W=c.useRef(0),U=c.useRef(null),ae=!!l,K=(g?m.get(g):null)??p??null,de={threadId:r.thread.id,workspaceId:r.workspace.id??r.thread.workspaceId??null};c.useEffect(()=>{W.current=0,U.current=null,x(new Set(["","artifacts","thread-events","live",...Vh(de),...Va((p==null?void 0:p.path)??"")]))},[de.threadId,de.workspaceId]);function ee(){var O;const I=((O=C.current)==null?void 0:O.scrollTop)??W.current;W.current=I,U.current=I}function ke(){const I=U.current??W.current;if(!C.current)return;let oe=0;const ge=()=>{const Ne=C.current;Ne&&(Ne.scrollTop=Math.min(I,Math.max(0,Ne.scrollHeight-Ne.clientHeight)),W.current=Ne.scrollTop,oe+=1,oe<8?window.requestAnimationFrame(ge):U.current=null)};window.requestAnimationFrame(ge)}c.useLayoutEffect(()=>{j!=="explorer"&&ke()},[j,u]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const I=window.matchMedia("(max-width: 639px)"),O=()=>B(I.matches);return O(),typeof I.addEventListener=="function"?(I.addEventListener("change",O),()=>I.removeEventListener("change",O)):(I.addListener(O),()=>I.removeListener(O))},[]);async function le(I){if(!l)return;const O=I??(K==null?void 0:K.path)??null;N(!0),v(null);try{const oe=rr(await l.listTree({...de,path:""}));let ge=i?On(oe,i):oe;if(i){const Ce=[...w].filter(xe=>xe).sort((xe,Ge)=>xe.split("/").length-Ge.split("/").length);for(const xe of Ce){const Ge=Bn(i,xe);if((Ge==null?void 0:Ge.kind)!=="directory"||!Ge.childrenLoaded)continue;const Me=rr(await l.listTree({...de,path:xe}));ge=Gn(ge,xe,On(Me,Ge))}}d(ge);const Ne=Ao(ge);k(Ce=>{var Ge;const xe=O??(Ce?(Ge=m.get(Ce))==null?void 0:Ge.path:null);return xe&&Fn(ge,xe)?`workspace:${xe}`:(Ne==null?void 0:Ne.id)??Ce})}catch(oe){v(oe instanceof Error?oe.message:"Failed to load workspace"),d(null)}finally{N(!1)}}async function je(I){if(!(!l||!i)){R(O=>{if(O.has(I))return O;const oe=new Set(O);return oe.add(I),oe}),v(null);try{const O=rr(await l.listTree({...de,path:I}));d(oe=>oe&&Ro(oe,I,O.children,{truncated:O.truncated}))}catch(O){v(O instanceof Error?O.message:"Failed to load directory")}finally{R(O=>{if(!O.has(I))return O;const oe=new Set(O);return oe.delete(I),oe})}}}async function Ae(I){const O=Mo(I);if(!O)return;const oe=ih(O);if(y(null),x(ge=>{const Ne=new Set(ge);Ne.add("");for(const Ce of oe)Ne.add(Ce);return Ya(de,Ne),Ne}),!l){Fn(u,O)&&k(`workspace:${O}`);return}N(!0),v(null);try{let ge=i??rr(await l.listTree({...de,path:""}));for(const Ne of oe){const Ce=Bn(ge,Ne);if((Ce==null?void 0:Ce.kind)==="directory"&&Ce.childrenLoaded)continue;const xe=rr(await l.listTree({...de,path:Ne}));ge=Gn(ge,Ne,xe)}d(ge),k(`workspace:${O}`)}catch(ge){v(ge instanceof Error?ge.message:`Failed to open ${O}`)}finally{N(!1)}}c.useEffect(()=>{if(!(!l||!i))for(const I of m.values())I.path&&I.kind==="directory"&&w.has(I.path)&&I.hasChildren&&!I.childrenLoaded&&!L.has(I.path)&&je(I.path)},[i,w,m,l]),c.useEffect(()=>{d(null),R(new Set),ie(null),H(null),T(null),v(null),le()},[ae,r.thread.id,r.workspace.id,r.thread.workspaceId]),c.useEffect(()=>{o&&Ae(o.path)},[o==null?void 0:o.requestId]),c.useEffect(()=>{l!=null&&l.subscribeWorkspaceChanged},[l,de.threadId,de.workspaceId]),c.useEffect(()=>{const I=l&&(K==null?void 0:K.kind)==="file"?K.path:null;if(!I){ie(null),H(null),T(null);return}const O=I;let oe=!1;async function ge(){var Ne;if(l){Q(!0),v(null),ie(null),H(null),T(null);try{const Ce=Rr(O),xe=(Ne=l.getRawFileUrl)==null?void 0:Ne.call(l,{...de,path:O});if(xe&&Do.has(Ce)){oe||H(xe);return}if(xe&&Bo.has(Ce)){oe||T(xe);return}const Ge=await l.readFile({...de,path:O,limit:Wr});oe||ie(Ge)}catch(Ce){oe||v(Ce instanceof Error?Ce.message:"Failed to read file")}finally{oe||Q(!1)}}}return ge(),()=>{oe=!0}},[l,K==null?void 0:K.id]);async function ce(){if(!(!l||!(_!=null&&_.truncated))){Z(!0);try{const I=await l.readFile({...de,path:_.path,offset:_.nextOffset,limit:Wr});ie(O=>O&&{...O,content:O.content+I.content,truncated:I.truncated,nextOffset:I.nextOffset,size:I.size})}finally{Z(!1)}}}async function ne(I){if(!(l!=null&&l.writeFile))return;v(null),await l.writeFile({...de,path:I.path,content:I.content}),await le(I.path);const O=await l.readFile({...de,path:I.path,limit:Wr});ie(O)}async function Le(I){if(!(!(l!=null&&l.uploadFile)||!I)){N(!0),v(null);try{const O=await l.uploadFile({...de,path:I.name,file:I}),oe=O.kind==="archive"?O.paths[0]??null:O.file.path;await le(oe)}catch(O){v(O instanceof Error?O.message:"Failed to upload file")}finally{N(!1)}}}async function Y(I){var oe;const O=(oe=I.target.files)==null?void 0:oe[0];I.target.value="",O&&await Le(O)}function me(){if(!(l!=null&&l.uploadFile))return;const I=()=>{var O;return(O=E.current)==null?void 0:O.click()};if(l.pickUploadFile){l.pickUploadFile({...de,defaultPick:I,upload:Le});return}I()}function we(I){var O;(O=l==null?void 0:l.downloadNode)==null||O.call(l,{...de,path:I.path,kind:I.kind==="directory"?"directory":"file"})}function ye(I){if(!I.path||typeof navigator>"u"||!navigator.clipboard)return;const O=r.workspace.absPath.replace(/\/+$/,""),oe=I.path.startsWith("/")?I.path:O?`${O}/${I.path.replace(/^\/+/,"")}`:I.path;navigator.clipboard.writeText(oe).catch(ge=>{v(ge instanceof Error?ge.message:"Failed to copy file path")})}function De(I){I.kind==="file"&&(ee(),k(I.id),y("explorer"))}async function Be(){if(l!=null&&l.emptyGarbage){if(v(null),!l.listGarbage){se([]),z(!0);return}try{const I=await l.listGarbage(de);se(I.map(O=>`garbage/${O}`))}catch(I){se([]),v(I instanceof Error?I.message:"Failed to list garbage files")}finally{z(!0)}}}async function _e(){if(l!=null&&l.emptyGarbage){z(!1),v(null);try{await l.emptyGarbage(de),await le((K==null?void 0:K.path)??null)}catch(I){v(I instanceof Error?I.message:"Failed to empty garbage")}}}const Oe={onCopyPath:ye,...l!=null&&l.downloadNode?{onDownload:we}:{},...l!=null&&l.emptyGarbage?{onEmptyGarbage:Be}:{},...l?{onRefresh:()=>void le((K==null?void 0:K.path)??null)}:{},...l!=null&&l.uploadFile?{onUpload:me}:{}};function V(I){if(!I)return;const O=m.get(`workspace:${I}`),oe=(O==null?void 0:O.kind)==="directory"&&O.hasChildren&&!O.childrenLoaded&&!L.has(I);x(ge=>{const Ne=new Set(ge);return Ne.has(I)?Ne.delete(I):Ne.add(I),Ya(de,Ne),Ne}),!w.has(I)&&oe&&je(I)}const he=t.jsx(Kh,{canEmptyGarbage:!!(l!=null&&l.emptyGarbage),canUpload:!!(l!=null&&l.uploadFile),onCollapse:()=>{ee(),y("explorer")},expandedPaths:w,loadingPaths:L,loading:S,explorerScrollTopRef:W,explorerScrollerRef:C,...Oe,onPreview:De,onSelect:I=>{k(I)},onToggle:V,selectedNodeId:(K==null?void 0:K.id)??null,tree:u,liveNodes:f}),ve=t.jsx(Hh,{error:b,imageUrl:q,loadingMore:D,onLoadMore:ce,...l!=null&&l.writeFile?{onSaveFile:ne}:{},onCollapse:()=>{ee(),y("viewer")},pdfUrl:G,previewFile:_,previewLoading:P,plugins:a,selectedTarget:Fh(K)});return j==="explorer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:ve}):j==="viewer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:he}):t.jsxs("div",{"data-testid":"workspace-panel",className:"flex h-full min-h-0 w-full overflow-hidden bg-transparent p-2",children:[J?t.jsx(Wh,{files:te,onCancel:()=>z(!1),onConfirm:()=>void _e()}):null,F?t.jsxs(_n,{direction:"vertical",className:"thread-graph-workspace-mobile-stack",children:[t.jsx(or,{defaultSize:42,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-explorer h-full min-h-0 overflow-hidden",children:he})}),t.jsx(Dn,{className:"thread-graph-workspace-resize-handle h-2 bg-transparent after:h-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(or,{defaultSize:58,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-viewer h-full min-h-0 overflow-hidden",children:ve})})]}):t.jsxs(_n,{direction:"horizontal",className:"thread-graph-workspace-resizable",children:[t.jsx(or,{defaultSize:33,minSize:20,children:t.jsx("div",{className:"thread-graph-workspace-explorer-pane h-full min-h-0 overflow-hidden",children:he})}),t.jsx(Dn,{className:"thread-graph-workspace-resize-handle w-2 bg-transparent after:w-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(or,{defaultSize:67,minSize:30,children:t.jsx("div",{className:"thread-graph-workspace-viewer-pane h-full min-h-0 overflow-hidden",children:ve})})]}),t.jsx("input",{ref:E,type:"file","aria-label":"Workspace upload file input","data-testid":"workspace-upload-file-input",className:"hidden",onChange:I=>void Y(I)})]})}var Wr,Ko,Xo,Yo,Zo,Ur,Jo,Qo,el,Yh=He({"src/components/graph-workspace/GraphWorkspaceExplorer.tsx"(){ia(),Oh(),Uh(),Po(),Wr=24e3,Ko="remote-codex:graphchat:workspace:expanded:",Xo="thread-graph-explorer h-full min-h-0 overflow-hidden rounded-[12px]",Yo="thread-graph-explorer-header flex h-[60px] shrink-0 items-center justify-between border-b px-4",Zo="text-[18px] font-semibold text-slate-900 dark:text-slate-100",Ur="thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition disabled:cursor-not-allowed disabled:opacity-50",Jo="thread-graph-explorer-collapse-button flex h-8 w-8 items-center justify-center rounded-full text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-[#222733] dark:hover:text-slate-100",Qo="thread-graph-workspace-label px-3 pb-1 pt-2 text-[11px] font-semibold tracking-normal text-slate-500 dark:text-slate-400",el="thread-graph-workspace-empty mx-4 mt-3 rounded-lg border border-dashed border-slate-200 bg-slate-50 px-3 py-4 text-sm text-slate-500 dark:border-[#303642] dark:bg-[#1b1f29] dark:text-slate-400"}});function Cn({children:e}){return t.jsx("span",{className:"thread-guide-tag inline-flex items-center rounded px-1.5 py-0.5 font-mono text-[10px]",children:e})}function er({items:e}){return t.jsx("ul",{className:"space-y-1 text-[12px] text-[var(--theme-fg-muted)]",children:e.map((r,n)=>t.jsxs("li",{className:"flex gap-2",children:[t.jsx("span",{className:"mt-[6px] h-1 w-1 shrink-0 rounded-full bg-[var(--theme-border-contrast)]"}),t.jsx("span",{children:r})]},n))})}function Zh({children:e}){return t.jsx("span",{className:"thread-guide-icon flex h-5 w-5 shrink-0 items-center justify-center rounded-md",children:e})}function gr({value:e,title:r,icon:n,children:a}){return t.jsxs(Ir,{value:e,className:"thread-guide-section border-b border-[var(--theme-border)] last:border-b-0",children:[t.jsx(on,{className:"py-3 hover:no-underline [&[data-state=open]]:pb-2",children:t.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-[var(--theme-fg)]",children:[t.jsx(Zh,{children:n}),r]})}),t.jsx(zr,{className:"space-y-3 pb-3",children:a})]})}function Jh(){return t.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[t.jsxs("div",{className:"shrink-0 border-b border-[var(--theme-border)] px-4 py-3",children:[t.jsx("h2",{className:"text-xs font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"What can I do?"}),t.jsx("p",{className:"mt-0.5 text-[11px] text-[var(--theme-fg-muted)]",children:"Upload files, ask in plain language, get results."})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-3 pb-6",children:t.jsxs(Lr,{type:"multiple",defaultValue:["start","workspace","remote-codex"],className:"space-y-0",children:[t.jsxs(gr,{value:"start",title:"Getting Started",icon:t.jsx($.Zap,{className:"h-3 w-3"}),children:[t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"graphchat connects a language model to your files and a set of tools. Each Remote Codex thread has its own isolated workspace."}),t.jsx(er,{items:["Upload data files via the Workspace panel","Type a question or task in plain language","The agent calls tools, writes results to the workspace, and explains what it found","Agent-produced files appear in the workspace automatically when the host reports changes"]})]}),t.jsxs(gr,{value:"workspace",title:"Workspace Explorer",icon:t.jsx($.FolderOpen,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx($.Upload,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Upload"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Upload files through the Workspace panel when the host exposes workspace upload support. Composer attachments stay available for prompt context."})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx($.Plus,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"New files and folders"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Remote Codex normally creates files through tools and shell commands. They appear in Explorer after workspace refreshes."})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx($.MoveRight,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Move and organize"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Use the agent or terminal to reorganize files. Explorer keeps the GraphChat file tree and preview flow."})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx($.Trash2,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-rose-400"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Garbage folder"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"If the host exposes garbage controls, Explorer can permanently empty unwanted workspace files."})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx($.RefreshCw,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Refresh"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Resync the file tree manually after shell commands, external changes, or agent tool runs."})]})]}),t.jsxs("div",{className:"rounded-lg border border-[var(--theme-border)] p-2.5",children:[t.jsx("p",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"Preview surfaces"}),t.jsx(er,{items:[t.jsxs(t.Fragment,{children:[t.jsx(Cn,{children:".xyz .extxyz .cif"})," use the 3D molecule plugin."]}),t.jsxs(t.Fragment,{children:[t.jsx(Cn,{children:".png .jpg .gif .svg .webp"})," use inline image preview."]}),t.jsxs(t.Fragment,{children:[t.jsx(Cn,{children:".py .json .ts .md .csv"})," use text/code preview."]}),"Large files load in chunks when the workspace adapter supports it."]})]})]}),t.jsxs(gr,{value:"viewer",title:"Viewer",icon:t.jsx($.FileImage,{className:"h-3 w-3"}),children:[t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Viewer is the GraphChat-style artifact surface. It opens Remote Codex artifacts through the same frontend plugin renderers used in rich message bubbles, and previews workspace files from Explorer."}),t.jsx(er,{items:["Expand one artifact at a time for inspection","Fallback JSON preview is available for unknown artifact types","3D molecule artifacts remain interactive when the XYZ plugin is enabled"]})]}),t.jsxs(gr,{value:"usage",title:"Tool Usage & Chat",icon:t.jsx($.BarChart2,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx($.BarChart2,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Usage tab"}),t.jsx(er,{items:["Bar chart of tool and command counts for this thread","Expandable call log: inspect every input and output","Recent live events appear with persisted history"]})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx($.MessageSquare,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Chat controls"}),t.jsx(er,{items:["New Chat creates a fresh Remote Codex thread with its own workspace","Interrupt, compact, goal controls, and model controls remain in the composer","Shell view stays available when a shell adapter is attached"]})]})]})]}),t.jsx(gr,{value:"remote-codex",title:"Remote Codex Extras",icon:t.jsx($.Code2,{className:"h-3 w-3"}),children:t.jsx(er,{items:["Slash toolbox: skills, MCP, hooks, goals, forks, model controls, provider settings","Rich message bubbles: reasoning, commands, searches, file reads, file changes, plans, action requests, artifacts","Plugin surfaces: terminal, XYZ molecule viewer, inline code renderers, and imported plugin panels","Thread metadata stays in the left rail and Workspace tab instead of replacing chat"]})})]})})]})}var Qh=He({"src/components/graph-workspace/GraphGuidePanel.tsx"(){Pr()}});function eu(e){if(e==null)return"—";if(typeof e=="string")return e.length>2e3?`${e.slice(0,2e3)}
|
|
13
|
-
...(truncated)`:e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Ja({label:e,value:r}){return t.jsxs("div",{children:[t.jsx("p",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:e}),t.jsx("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap break-words rounded bg-[var(--theme-surface-strong)] p-2 text-[11px] leading-relaxed text-[var(--theme-fg-soft)]",children:eu(r)})]})}function tu({event:e}){return t.jsxs(Ir,{value:e.id,className:"thread-tool-call mb-2 overflow-hidden rounded-lg border border-[var(--theme-border)] last:mb-0",children:[t.jsxs(on,{className:"px-3 py-2 text-xs font-medium text-[var(--theme-fg)] hover:bg-[var(--theme-hover)] hover:no-underline [&[data-state=open]]:bg-[var(--theme-hover)]",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full bg-[var(--theme-accent-strong)]"}),t.jsx("span",{className:"truncate font-mono text-xs font-medium text-[var(--theme-fg)]",children:e.label}),e.status?t.jsx("span",{className:"shrink-0 rounded-full border border-[var(--theme-border)] px-1.5 py-0.5 text-[9px] uppercase tracking-[0.12em] text-[var(--theme-fg-muted)]",children:e.status}):null]}),t.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:e.turnId?t.jsx("span",{className:"max-w-20 truncate text-[10px] text-[var(--theme-fg-muted)]",children:e.turnId}):null})]}),t.jsx(zr,{className:"px-3 pb-3",children:t.jsxs("div",{className:"space-y-2 px-3 pb-3 pt-1",children:[t.jsx(Ja,{label:"Input",value:e.preview}),t.jsx(Ja,{label:"Output",value:e.detail})]})})]})}function ru({formatToolKind:e,toolCounts:r,toolEvents:n,maxToolCount:a}){const[s,o]=c.useState(()=>{var i;return((i=n.at(-1))==null?void 0:i.id)??null}),l=c.useRef(null);return c.useEffect(()=>{o(i=>{var d;return i??((d=n.at(-1))==null?void 0:d.id)??null})},[n]),c.useEffect(()=>{var i;(i=l.current)==null||i.scrollIntoView({behavior:"smooth",block:"nearest"})},[n.length]),r.length?t.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[t.jsxs("div",{className:"shrink-0 border-b border-[var(--theme-border)] p-4",children:[t.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[t.jsx("h2",{className:"text-xs font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"Calls this session"}),t.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-[var(--theme-fg-muted)] opacity-60",disabled:!0,title:"Remote Codex streams tool history from thread events",children:[t.jsx($.RefreshCw,{className:"h-3 w-3"}),"Reload"]})]}),t.jsx("div",{className:"space-y-2",children:r.map(([i,d])=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"w-40 shrink-0 truncate text-right font-mono text-[11px] text-[var(--theme-fg-muted)]",title:e(i),children:e(i)}),t.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[t.jsx("div",{className:"relative h-4 flex-1 overflow-hidden rounded-sm bg-[var(--theme-muted)]",children:t.jsx("div",{className:"h-full rounded-sm bg-[var(--theme-accent-strong)] transition-all duration-300",style:{width:`${d/a*100}%`}})}),t.jsx("span",{className:"w-5 shrink-0 text-right text-[11px] font-medium text-[var(--theme-fg-soft)]",children:d})]})]},i))})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:[t.jsx("h2",{className:"mb-3 text-xs font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"Call log"}),t.jsx(Lr,{type:"single",collapsible:!0,value:s??"",onValueChange:i=>o(i||null),className:"space-y-0",children:n.slice(-50).map(i=>t.jsx(tu,{event:i},i.id))}),t.jsx("div",{ref:l})]})]}):t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 text-sm text-[var(--theme-fg-muted)]",children:[t.jsx("span",{children:"No tool calls yet. Run the agent to see usage."}),t.jsxs("span",{className:"inline-flex items-center gap-1 rounded px-2 py-1 text-xs",children:[t.jsx($.RefreshCw,{className:"h-3 w-3"}),"Reload from workspace"]})]})}var nu=He({"src/components/graph-workspace/GraphToolUsagePanel.tsx"(){Pr()}});function Qa(e,r){const n=Math.max(e.measured.width??1,1),a=Math.max(e.measured.height??1,1),s=e.internals.positionAbsolute,o=r.internals.positionAbsolute,l=Math.max(r.measured.width??1,1),i=Math.max(r.measured.height??1,1),d=n/2,h=a/2,u=s.x+d,m=s.y+h,f=o.x+l/2,p=o.y+i/2,g=(f-u)/(2*d)-(p-m)/(2*h),k=(f-u)/(2*d)+(p-m)/(2*h),w=1/(Math.abs(g)+Math.abs(k)),x=w*g,j=w*k,y=d*(x+j)+u,b=h*(-x+j)+m;return{x:y,y:b}}function es(e,r){const n={...e.internals.positionAbsolute,...e},a=Math.round(n.x),s=Math.round(n.y),o=Math.round(r.x),l=Math.round(r.y);return o<=a+1?Ft.Left:o>=a+(e.measured.width??1)-1?Ft.Right:l<=s+1?Ft.Top:l>=n.y+(e.measured.height??1)-1?Ft.Bottom:Ft.Top}function tl(e,r){const n=Qa(e,r),a=Qa(r,e),s=es(e,n),o=es(r,a);return{sx:n.x,sy:n.y,tx:a.x,ty:a.y,sourcePos:s,targetPos:o}}function au(e,r=900,n=620){if(!e||!Array.isArray(e))return{nodes:[],edges:[]};const a=(d,h,u,m)=>{const f=new Map,p=d.length;d.forEach((g,k)=>{const w=g.id.split("").reduce((x,j)=>{const y=(x<<5)-x+j.charCodeAt(0);return y&y},0);f.set(g.id,{x:Math.abs(w)%u+k*100%u,y:Math.abs(w>>16)%m+k*150%m,vx:0,vy:0})});for(let g=0;g<200;g+=1){for(let k=0;k<p;k+=1)for(let w=k+1;w<p;w+=1){const x=d[k],j=d[w];if(!x||!j)continue;const y=f.get(x.id),b=f.get(j.id);if(!y||!b)continue;const v=y.x-b.x,S=y.y-b.y,N=Math.sqrt(v*v+S*S)||1,R=(200-N)*.5,P=v/N*R,Q=S/N*R;y.vx+=P,y.vy+=Q,b.vx-=P,b.vy-=Q}h.forEach(k=>{const w=f.get(k.source),x=f.get(k.target);if(!w||!x)return;const j=x.x-w.x,y=x.y-w.y,b=Math.sqrt(j*j+y*y)||1,S=(b-120)*.3,N=j/b*S,L=y/b*S;w.vx+=N,w.vy+=L,x.vx-=N,x.vy-=L}),f.forEach(k=>{k.x+=k.vx*.1,k.y+=k.vy*.1,k.vx*=.9,k.vy*=.9,k.x=Math.max(80,Math.min(u-80,k.x)),k.y=Math.max(80,Math.min(m-80,k.y))})}return f},s=new Set(e.map(d=>d.id)),o=[];e.forEach(d=>{if(!d.out_node_id)return;(Array.isArray(d.out_node_id)?d.out_node_id:[d.out_node_id]).forEach(u=>{s.has(u)&&o.push({id:`${d.id}-${u}`,source:d.id,target:u,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:Ws.Arrow}})})});const l=a(e,o,r,n);return{nodes:e.map(d=>({id:d.id,type:"styledNode",position:l.get(d.id)??{x:100,y:100},data:{label:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-sm font-semibold",children:d.name}),d.description?t.jsx("div",{className:"mt-1 max-w-32 overflow-hidden text-ellipsis text-xs text-slate-500 dark:text-slate-400",children:d.description}):null]})}})),edges:o}}var da=He({"src/components/graph-chat/FloatingHelper.tsx"(){}});function su({toX:e,toY:r,fromPosition:n,toPosition:a,fromNode:s}){if(!s)return null;const o={id:"connection-target",measured:{width:1,height:1},internals:{positionAbsolute:{x:e,y:r}}},{sx:l,sy:i,tx:d,ty:h,sourcePos:u,targetPos:m}=tl(s,o),[f]=Us({sourceX:l,sourceY:i,sourcePosition:u||n,targetPosition:m||a,targetX:d||e,targetY:h||r});return t.jsxs("g",{children:[t.jsx("path",{fill:"none",stroke:"currentColor",strokeWidth:1.5,className:"animated",d:f}),t.jsx("circle",{cx:d||e,cy:h||r,fill:"var(--theme-panel)",r:3,stroke:"currentColor",strokeWidth:1.5})]})}var ou=He({"src/components/graph-chat/FloatingConnectionLine.tsx"(){da()}});function lu({id:e,source:r,target:n,markerEnd:a,style:s}){const o=Ta(r),l=Ta(n);if(!o||!l)return null;const{sx:i,sy:d,tx:h,ty:u,sourcePos:m,targetPos:f}=tl(o,l),[p]=Us({sourceX:i,sourceY:d,sourcePosition:m,targetPosition:f,targetX:h,targetY:u});return t.jsx("path",{id:e,className:"react-flow__edge-path",d:p,markerEnd:a,style:s})}var iu=He({"src/components/graph-chat/FloatingEdge.tsx"(){da()}});function du({nodes:e}){const[r,n,a]=Nd([]),[s,o,l]=Cd([]),i=c.useMemo(()=>au(e),[e]),d=c.useMemo(()=>({floating:lu}),[]),h=c.useMemo(()=>({styledNode:({data:m,isConnectable:f})=>t.jsxs("div",{className:"thread-graph-flow-node",children:[m.label,t.jsx(Sa,{type:"target",position:Ft.Top,isConnectable:f,style:{opacity:0,pointerEvents:"none"}}),t.jsx(Sa,{type:"source",position:Ft.Bottom,isConnectable:f,style:{opacity:0,pointerEvents:"none"}})]})}),[]);c.useEffect(()=>{n(i.nodes),o(i.edges)},[i.edges,i.nodes,o,n]);const u=c.useCallback(m=>o(f=>Sd({...m,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:Ws.Arrow}},f)),[o]);return t.jsx("div",{className:"thread-graph-flow h-full min-h-0",children:t.jsx(Td,{children:t.jsxs(Ed,{nodes:r,edges:s,onNodesChange:a,onEdgesChange:l,onConnect:u,fitView:!0,nodeTypes:h,edgeTypes:d,connectionLineComponent:su,children:[t.jsx(Ld,{}),t.jsx(Id,{gap:16})]})})})}var cu=He({"src/components/graph-chat/GraphVisualization.tsx"(){ou(),iu(),da()}});function hu(e){return{...nl,...e}}function ts(e,r){const n=a=>{switch(a){case"workspace":return e.workspace;case"tools":return e.toolUsage;case"guide":return e.guide;case"graph":return e.threadGraph;case"extensions":return e.extensions}};return r&&n(r)?r:["workspace","tools","guide","graph","extensions"].find(n)??null}function uu(e,r){switch(r){case"workspace":return e.workspace;case"tools":return e.toolUsage;case"guide":return e.guide;case"graph":return e.threadGraph;case"extensions":return e.extensions}}function mu(e){var s;const r=[],n=new Set(["toolCall","commandExecution","webSearch","fileRead","fileChange","agentToolCall","skillToolCall","hook"]);let a=0;for(const o of e.turns)for(const l of o.items)n.has(l.kind)&&(r.push({id:l.id,kind:l.kind,label:Yr(l.kind),preview:l.previewText??l.text??l.kind,detail:l.detailText??l.text??l.previewText??l.kind,turnId:l.sourceTurnId??o.id,status:l.status??null,sequence:a}),a+=1);for(const o of((s=e.liveItems)==null?void 0:s.items)??[])n.has(o.kind)&&(r.push({id:o.id,kind:o.kind,label:Yr(o.kind),preview:o.previewText??o.text??o.kind,detail:o.detailText??o.text??o.previewText??o.kind,turnId:o.sourceTurnId??null,status:o.status??null,sequence:a}),a+=1);return r}function Yr(e){switch(e){case"toolCall":return"Tool call";case"agentToolCall":return"Agent tool";case"skillToolCall":return"Skill tool";case"commandExecution":return"Command";case"webSearch":return"Search";case"fileRead":return"File read";case"fileChange":return"File change";case"hook":return"Hook";default:return e.replace(/([A-Z])/g," $1").replace(/^./,r=>r.toUpperCase())}}function pu(e){switch(e.kind){case"userMessage":return"User";case"agentMessage":return"Agent";default:return Yr(e.kind)}}function fu(e){return(e.previewText??e.text??e.detailText??e.kind).replace(/\s+/g," ").slice(0,96)}function gu(e,r){const n=[{id:`thread:${e.thread.id}`,name:e.thread.title||"Thread",description:e.thread.model??e.thread.status},{id:`workspace:${e.workspace.id}`,name:e.workspace.label??"Workspace",description:e.workspace.absPath,out_node_id:`thread:${e.thread.id}`}];let a=null;for(const o of e.turns){const l=`turn:${o.id}`;n.push({id:l,name:`Turn ${n.filter(d=>d.id.startsWith("turn:")).length+1}`,description:o.status,out_node_id:a?[`thread:${e.thread.id}`,a]:`thread:${e.thread.id}`}),a=l;let i=null;for(const d of o.items){const h=`item:${d.id}`,u=[l];i&&u.push(i),n.push({id:h,name:pu(d),description:fu(d),out_node_id:u}),i=h,d.kind==="artifact"&&d.artifact&&n.push({id:`artifact:${d.artifact.id}`,name:d.artifact.title||d.artifact.type,description:d.artifact.summaryText??d.artifact.type,out_node_id:h})}}const s=new Set(n.map(o=>o.id));for(const o of r){const l=`tool:${o.id}`;s.has(l)||s.has(`item:${o.id}`)||n.push({id:l,name:o.label,description:o.preview,out_node_id:o.turnId?`turn:${o.turnId}`:`thread:${e.thread.id}`})}return n.slice(0,120)}function rl({detail:e,status:r,plugins:n,workspaceAdapter:a,metaContent:s,settingsContent:o,activeView:l="chat",features:i,focusPathRequest:d=null}){const h=c.useMemo(()=>hu(i),[i]),u=ts(h,i==null?void 0:i.defaultTab),[m,f]=c.useState(u),p=c.useMemo(()=>sh(e),[e]),g=c.useMemo(()=>mu(e),[e]),k=c.useMemo(()=>{const v=new Map;for(const S of g)v.set(S.kind,(v.get(S.kind)??0)+1);return[...v.entries()].sort((S,N)=>N[1]-S[1])},[g]),w=n.getThreadPanels(),x=Math.max(...k.map(([,v])=>v),1),j=c.useMemo(()=>gu(e,g),[e,g]),y=c.useMemo(()=>{const v=[];return h.workspace&&v.push({id:"workspace",label:"Workspace",icon:null}),h.toolUsage&&v.push({id:"tools",label:"Tool Usage",icon:$.BarChart2}),h.guide&&v.push({id:"guide",label:"Guide",icon:$.BookOpen}),v},[h.guide,h.toolUsage,h.workspace]),b=c.useMemo(()=>{const v=[];return h.threadGraph&&v.push({id:"graph",label:"Thread graph",icon:$.GitBranch}),h.extensions&&v.push({id:"extensions",label:"Remote Codex extensions",icon:$.Wrench}),v},[h.extensions,h.threadGraph]);return c.useEffect(()=>{(!m||!uu(h,m))&&f(ts(h,i==null?void 0:i.defaultTab))},[m,i==null?void 0:i.defaultTab,h]),c.useEffect(()=>{d&&h.workspace&&f("workspace")},[h.workspace,d==null?void 0:d.requestId]),m?t.jsxs("div",{className:"thread-graph-right-panel flex h-full min-h-0 flex-col overflow-hidden",children:[t.jsxs("div",{className:"thread-graph-right-tabs flex shrink-0 items-center gap-1 overflow-hidden border-b px-3 py-2",children:[y.map(v=>{const S=v.icon;return t.jsxs("button",{type:"button",onClick:()=>f(v.id),className:`thread-graph-right-tab inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md px-3 text-xs font-medium transition ${m===v.id?"is-active":""}`,children:[S?t.jsx(S,{className:"h-3.5 w-3.5"}):null,v.label]},v.id)}),b.length?t.jsx("div",{className:"thread-graph-right-tab-secondary ml-auto flex min-w-0 shrink items-center gap-1 border-l pl-2","aria-label":"Remote Codex workspace extensions",children:b.map(v=>{const S=v.icon;return t.jsx("button",{type:"button",onClick:()=>f(v.id),className:`thread-graph-right-tab inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-xs font-medium transition ${m===v.id?"is-active":""}`,title:v.label,"aria-label":v.label,children:t.jsx(S,{className:"h-3.5 w-3.5"})},v.id)})}):null]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[m==="workspace"?t.jsx(Xh,{activeView:l,detail:e,artifacts:p,plugins:n,status:r,focusPathRequest:d,workspaceAdapter:a??null}):null,m==="tools"?t.jsx(ru,{formatToolKind:Yr,toolCounts:k,toolEvents:g,maxToolCount:x}):null,m==="graph"?t.jsx("div",{className:"thread-graph-visualization-panel h-full min-h-0 p-3",children:t.jsx(du,{nodes:j})}):null,m==="extensions"?t.jsx("div",{className:"h-full min-h-0 overflow-y-auto p-3",children:t.jsxs("div",{className:"grid gap-3",children:[t.jsx(nr,{label:"Plugin Panels",children:w.length?t.jsx("div",{className:"flex flex-wrap gap-2",children:w.map(v=>t.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-1 text-xs text-[var(--theme-fg-soft)]",children:v.label},v.id))}):t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"No thread panels are enabled."})}),t.jsx(nr,{label:"Enabled Renderers",children:t.jsx("div",{className:"flex flex-wrap gap-2",children:n.plugins.filter(v=>v.enabled).map(v=>t.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-1 text-xs text-[var(--theme-fg-soft)]",children:v.name},v.id))})}),t.jsx(nr,{label:"Remote Codex Tools",children:t.jsxs("div",{className:"grid gap-2 text-[var(--theme-fg-muted)]",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx($.Terminal,{className:"mt-0.5 h-4 w-4 shrink-0"}),t.jsx("p",{children:"Terminal stays available when the Terminal plugin and shell adapter are attached."})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx($.Paperclip,{className:"mt-0.5 h-4 w-4 shrink-0"}),t.jsx("p",{children:"Composer attachments, slash panels, hooks, MCP, goals, and fork controls remain part of the chat surface."})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx($.Trash2,{className:"mt-0.5 h-4 w-4 shrink-0"}),t.jsx("p",{children:"Destructive actions stay explicit: delete thread, interrupt, compact, and hook trust controls remain host governed."})]})]})}),s?t.jsx(nr,{label:"Thread Meta",children:s}):null,o?t.jsx(nr,{label:"Settings",children:o}):null]})}):null,m==="guide"?t.jsx(Jh,{}):null]})]}):null}var nl,al,xu=He({"src/components/ThreadGraphWorkspacePanel.tsx"(){Yh(),Go(),Qh(),nu(),ia(),cu(),nl={workspace:!0,toolUsage:!0,guide:!0,threadGraph:!0,extensions:!0},al=c.memo(rl)}}),sl={};ah(sl,{MemoizedThreadGraphWorkspacePanel:()=>al,ThreadGraphWorkspacePanel:()=>rl});var bu=He({"src/workspace-panel.ts"(){xu()}});function cr(e,{insertAt:r}={}){if(!e||typeof document>"u")return;const n=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css",r==="top"&&n.firstChild?n.insertBefore(a,n.firstChild):n.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}cr(`.thread-ui-shell,
|
|
9
|
+
`),a+=i}return n.length>0?n:[e]}function Ya(e,r){return r!=="xyz"?e:e.flatMap(n=>Dh(n))}function Za(e){return e.map(r=>`${r.replace(/\s+$/g,"")}
|
|
10
|
+
`).join("")}function Bh(e){if(!e)return{format:"xyz",frames:[],exportContent:""};if(typeof e=="string"){const s=Ya([e],"xyz");return{frames:s,format:"xyz",exportContent:Za(s)}}const r=$h(e.format),n=e.content.filter(s=>s.trim().length>0);return{frames:Ya(n,r),format:r,exportContent:Za(n)}}var Gh=He({"src/components/graph-workspace/GraphMoleculeViewerData.ts"(){}});function Fh({className:e="",moleculeId:r=null,onScreenshot:n,onSelectionChange:a,source:s,title:o="PyMOL-style (PDB/CIF)"}){const l=c.useRef(null),i=c.useRef(null),d=c.useRef(null),h=c.useRef(!1),u=c.useRef(!0),[m,f]=c.useState(null),[p,g]=c.useState(0),[k,w]=c.useState(null),[x,j]=c.useState(!1),[y,b]=c.useState({}),[v,S]=c.useState([]),[N,L]=c.useState({}),[R,P]=c.useState(!1),[Q,K]=c.useState(!1),[J,B]=c.useState(null),z=c.useMemo(()=>Bh(s),[s]),te=z.frames,se=z.format,$=te[p]??null,ie=te.length>0&&p===te.length-1,q=r??"current",H=Object.values(N).reduce((E,C)=>E+C.length,0),G=Object.keys(N).length;c.useEffect(()=>{if(te.length===0){g(0);return}g(te.length-1)},[te.length]),c.useEffect(()=>{if(!x||te.length<=1)return;const E=window.setInterval(()=>{g(C=>C>=te.length-1?(window.clearInterval(E),j(!1),C):C+1)},200);return()=>window.clearInterval(E)},[x,te.length]),c.useEffect(()=>{const E=l.current;if(!E||i.current)return;let C=!1;try{const U=document.createElement("canvas");if(!(U.getContext("webgl2")||U.getContext("webgl")||U.getContext("experimental-webgl"))){B("WebGL is unavailable in this browser environment. Unable to render 3D viewer.");return}}catch{B("WebGL is unavailable in this browser environment. Unable to render 3D viewer.");return}const W=()=>{var U,ae;(U=i.current)==null||U.resize(),(ae=i.current)==null||ae.render()};return Rh().then(U=>{if(!(C||i.current))try{const ae=U.createViewer(E,{});i.current=ae,ae.setBackgroundColor("#f8fafc",.8),window.addEventListener("resize",W),window.setTimeout(W,100)}catch(ae){console.error("Failed to initialize 3Dmol viewer:",ae),B("Failed to initialize 3D viewer. Please refresh or try another browser.")}}).catch(U=>{console.error("Failed to load 3Dmol viewer runtime:",U),B("Failed to load 3D viewer runtime. Please refresh or try another browser.")}),()=>{C=!0,window.removeEventListener("resize",W),i.current=null,d.current=null}},[]),c.useEffect(()=>{const E=i.current;if(!(!E||!$))try{E.removeAllModels(),E.removeAllShapes(),E.removeAllLabels();const C=E.addModel($,se||"xyz");d.current=C,C.setStyle({},{stick:{radius:.2},sphere:{scale:.3}});const W=C.getCrystData(),U=!!(W&&typeof W=="object"&&Object.keys(W).length);P(U),K(U?u.current:!1),S([]),b({});const ae=$.split(`
|
|
11
|
+
`).slice(2).map(X=>X.trim()).filter(Boolean).map(X=>X.split(/\s+/)[0]??"Atom");h.current||(E.zoomTo(),h.current=!0),C.setClickable({},!0,(X,de,ee)=>{const ke=X.serial??X.index;if(ke===void 0)return;const le=X.atom||X.elem||ae[ke]||"Atom";S(je=>{const ce=!!(ee!=null&&ee.shiftKey||ee!=null&&ee.metaKey||ee!=null&&ee.ctrlKey)?je.includes(ke)?je.filter(ne=>ne!==ke):[...je,ke]:je.length===1&&je[0]===ke?[]:[ke];return b(ne=>{if(ce.length===0)return{};const Le={};return ce.forEach(Z=>{Le[Z]=ne[Z]||ae[Z]||le}),Le}),ce})}),C.setHoverable({},!0,(X,de,ee)=>{!ee||!X||w({x:ee.clientX,y:ee.clientY,label:`${X.atom||X.elem||"Atom"} (${X.serial??X.index??"?"})`,coords:{x:X.x.toFixed(2),y:X.y.toFixed(2),z:X.z.toFixed(2)}})},()=>w(null)),E.render()}catch(C){console.error("Failed to render molecule:",C),B("Unable to render this molecular structure.")}},[$,se]),c.useEffect(()=>{const E=i.current,C=d.current;if(!(!E||!C)){try{E.removeUnitCell(C)}catch{}if(Q&&R)try{E.addUnitCell(C,{box:{color:"black",opacity:1,linewidth:5},astyle:{radius:.12,mid:.85,color:"red",opacity:.6},bstyle:{radius:.12,mid:.85,color:"green",opacity:.6},cstyle:{radius:.12,mid:.85,color:"blue",opacity:.6},alabel:"a",blabel:"b",clabel:"c"})}catch{P(!1),K(!1)}E.render()}},[R,Q,$,se]),c.useEffect(()=>{const E=i.current,C=d.current;!E||!C||!$||(C.setStyle({},{stick:{radius:.2},sphere:{scale:.3}}),v.length>0&&C.setStyle({serial:v},{stick:{radius:.3,color:"yellow"},sphere:{scale:.4,color:"yellow"}}),E.render(),a==null||a({moleculeId:r,atoms:v}))},[r,a,v,$]),c.useEffect(()=>{if(!$)return;let E=0;const C=()=>{var U,ae;const W=(ae=(U=i.current)==null?void 0:U.getView)==null?void 0:ae.call(U);if(Array.isArray(W)&&W.length>=8){const[X,de,ee,ke,le,je,Ae,ce]=W;if(typeof X=="number"&&typeof de=="number"&&typeof ee=="number"&&typeof ke=="number"&&typeof le=="number"&&typeof je=="number"&&typeof Ae=="number"&&typeof ce=="number"){const ne=Math.sqrt(le*le+je*je+Ae*Ae),Le=ne>0?{x:le/ne,y:je/ne,z:Ae/ne}:{x:0,y:0,z:0};f({position:{x:X,y:de,z:ee,qx:le,qy:je,qz:Ae,qw:ce},lookAt:Le,zoom:ke})}}E=window.requestAnimationFrame(C)};return E=window.requestAnimationFrame(C),()=>window.cancelAnimationFrame(E)},[$]);const T=c.useCallback(async()=>{const E=i.current;if(!(E!=null&&E.pngURI))return;E.render();const C=E.pngURI();if(C){try{const U=await(await fetch(C)).blob(),ae=new ClipboardItem({[U.type||"image/png"]:U});await navigator.clipboard.write([ae])}catch{}n==null||n({moleculeId:r,image:C})}},[r,n]);function F(){R&&K(E=>{const C=!E;return u.current=C,C})}function D(){v.length!==0&&L(E=>{const C=E[q]??[];return{...E,[q]:Array.from(new Set([...C,...v]))}})}return t.jsxs("div",{className:`thread-graph-molecule-viewer flex h-full min-h-0 flex-col bg-white ${e}`,children:[t.jsxs("div",{className:"thread-graph-molecule-header flex shrink-0 items-center justify-between gap-3 border-b border-slate-200 px-3 py-2 sm:px-4 sm:py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"truncate text-sm font-semibold text-slate-900",children:o}),t.jsx("p",{className:"mt-1 hidden text-[11px] text-slate-400 sm:block",children:"cartoon + surface"})]}),t.jsx("span",{className:"shrink-0 text-[11px] text-slate-400",children:"workspace preview"})]}),t.jsxs("div",{className:"thread-graph-molecule-body min-h-0 flex-1",children:[t.jsxs("div",{ref:l,"data-testid":"molecule-viewer",className:"thread-graph-molecule-stage relative min-h-0 flex-1 overflow-hidden",children:[J?t.jsx("div",{"data-testid":"molecule-viewer-error",className:"thread-graph-molecule-error absolute inset-0 flex items-center justify-center bg-red-50 p-4 text-sm text-red-700",children:J}):null,!J&&!$?t.jsx("div",{className:"thread-graph-molecule-empty absolute inset-0 flex items-center justify-center p-4 text-sm text-slate-400",children:"No molecule data available."}):null,k?t.jsxs("div",{className:"thread-graph-molecule-tooltip pointer-events-none fixed z-[1000] rounded-md border border-gray-300 bg-white/95 px-2 py-1.5 text-[10px] text-gray-800 shadow-md",style:{left:k.x-20,top:k.y-50},children:[t.jsx("div",{className:"mb-0.5 font-semibold text-gray-900",children:k.label}),t.jsxs("div",{className:"space-x-2 text-gray-600",children:[t.jsxs("span",{children:["x: ",k.coords.x]}),t.jsxs("span",{children:["y: ",k.coords.y]}),t.jsxs("span",{children:["z: ",k.coords.z]})]})]}):null]}),t.jsxs("div",{className:"thread-graph-molecule-controls shrink-0",children:[t.jsxs("div",{className:"thread-graph-molecule-control-row",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-graph-molecule-control-title",children:"Ball & Stick"}),t.jsx("p",{className:"thread-graph-molecule-control-subtitle",children:"XYZ / PDB / CIF preview"})]}),t.jsx(zh,{currentIndex:p,exportContent:z.exportContent,moleculeId:r,onScreenshot:()=>void T(),viewerRef:i,xyzContent:$,xyzFormat:se})]}),te.length>1?t.jsxs("div",{className:"thread-graph-molecule-trajectory",children:[t.jsxs("div",{className:"mb-2 flex justify-between gap-3 text-xs",children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:["Trajectory ",p+1," / ",te.length,t.jsx(Tr,{type:"button",variant:"ghost",size:"icon",className:"thread-graph-molecule-button h-5 w-5",onClick:()=>{j(E=>{const C=!E;return C&&p===te.length-1&&g(0),C})},"aria-label":x?"Pause trajectory":"Play trajectory",title:x?"Pause trajectory":"Play trajectory",children:x&&p!==te.length-1?t.jsx(_.Pause,{className:"h-3 w-3"}):t.jsx(_.Play,{className:"h-3 w-3"})})]}),t.jsxs(Tr,{type:"button",variant:"ghost",onClick:()=>g(te.length-1),className:"thread-graph-molecule-live-button",children:[t.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${ie?"animate-pulse bg-red-600":"bg-gray-300"}`}),"Live"]})]}),t.jsx(Mh,{value:[p],max:te.length-1,step:1,onValueChange:E=>g(E[0]??0),"aria-label":"Trajectory frame"})]}):null,t.jsx(Lh,{cameraInfo:m,onClearSelection:()=>S([]),onClearStaged:()=>L({}),onSendSelection:()=>a==null?void 0:a({moleculeId:r,atoms:v}),onSendStaged:()=>{Object.entries(N).forEach(([E,C])=>{a==null||a({moleculeId:E==="current"?r:E,atoms:C})})},onStageSelection:D,onToggleUnitCell:F,selectedAtomLabels:y,selectedSerials:v,stagedAtoms:H,stagedMolecules:G,unitCellAvailable:R,unitCellVisible:Q})]})]})]})}var Hh=He({"src/components/graph-workspace/GraphMoleculeViewer.tsx"(){Ih(),Ph(),Ah(),sn(),_h(),Gh()}});function Oh(e){return!e.truncated&&e.size<=Vo&&e.content.split(`
|
|
12
|
+
`).length<=qo}function Wh(e){return e&&(e.node.path||e.node.name)||null}function Uh(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 Vh({error:e,imageUrl:r,loadingMore:n,onSaveFile:a,onLoadMore:s,onCollapse:o,pdfUrl:l,previewFile:i,previewLoading:d,plugins:h,selectedTarget:u}){const[m,f]=c.useState(!1),[p,g]=c.useState(""),[k,w]=c.useState(null),[x,j]=c.useState(!1),y=(u==null?void 0:u.node)??null,b=y!=null&&y.artifact?h.renderArtifact({artifact:y.artifact,expanded:!0,onToggleExpanded:()=>{}}):null,v=mh(i??null),S=(i==null?void 0:i.language)||ph((i==null?void 0:i.path)??""),N=i?Rr(i.path):"",L=Wh(u),R=i!==null&&da.has(N),P=!!(i&&a)&&!R&&Oh(i),Q=(u==null?void 0:u.kind)==="live-molecule",K=!!(y!=null&&y.artifact&&b),J=!!v||K;c.useEffect(()=>{f(!1),g((i==null?void 0:i.content)??""),w(null)},[i==null?void 0:i.path,i==null?void 0:i.content]);async function B(){if(!(!i||!a)){j(!0),w(null);try{await a({path:i.path,content:p}),f(!1)}catch(z){w(z instanceof Error?z.message:"Failed to save file.")}finally{j(!1)}}}return t.jsxs("section",{className:"thread-graph-viewer flex h-full min-h-0 flex-col overflow-hidden rounded-[12px]","data-preview-target-kind":(u==null?void 0:u.kind)??"none",children:[t.jsxs("div",{className:"thread-graph-viewer-header flex h-12 shrink-0 items-center justify-between gap-3 border-b px-3 sm:h-[60px] sm:px-5",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[t.jsx("h2",{className:"text-base font-semibold text-slate-900 sm:text-[18px] dark:text-slate-100",children:"Viewer"}),L?t.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-slate-500 dark:text-slate-400",children:L}):null]}),o?t.jsx("button",{type:"button",onClick:o,"data-testid":"collapse-viewer",className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-[#222733] dark:hover:text-slate-100",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(_.ChevronsRight,{className:"h-4 w-4"})}):null]}),t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[e?t.jsx("div",{className:"border-b border-rose-200 bg-rose-50 px-5 py-3 text-sm text-rose-700 dark:border-rose-400/25 dark:bg-rose-400/10 dark:text-rose-200",children:e}):null,u?u.kind==="workspace-file"&&d?t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center px-5 text-center text-sm text-slate-400 dark:text-slate-500",children:"Loading file preview..."}):u.kind==="workspace-file"&&v?t.jsx("div",{className:"thread-graph-molecule-preview min-h-0 flex-1 overflow-hidden",children:t.jsx(Fh,{source:v,moleculeId:v.uuid??u.node.path,title:"PyMOL-style (PDB/CIF)"})}):u.kind==="workspace-file"&&r?t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-auto p-5",children:t.jsx("img",{src:r,alt:u.node.path||u.node.name,className:"max-h-full max-w-full object-contain"})}):u.kind==="workspace-file"&&l?t.jsx("div",{className:"thread-graph-file-preview-frame min-h-0 flex-1 overflow-hidden",children:t.jsx("iframe",{src:l,title:`PDF preview: ${u.node.path||u.node.name}`,className:"h-full w-full border-0"})}):u.kind==="workspace-file"&&i?t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs("div",{className:"thread-graph-file-preview-header flex min-h-12 items-center justify-between gap-3 border-b px-4 py-2",children:[t.jsxs("div",{className:"min-w-0 text-xs uppercase tracking-[0.12em]",children:[R?"molecule":S||N||"text"," |"," ",i.size.toLocaleString()," bytes",i.truncated?t.jsxs("span",{className:"ml-2 text-amber-500",children:["showing ",i.nextOffset.toLocaleString()," bytes"]}):null]}),P?t.jsx("div",{className:"flex shrink-0 items-center gap-1",children:m?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>{g(i.content),f(!1),w(null)},disabled:x,className:"thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition disabled:cursor-not-allowed disabled:opacity-50",title:"Cancel edits","aria-label":"Cancel edits",children:t.jsx(_.X,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:()=>void B(),disabled:x||p===i.content,className:"thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition disabled:cursor-not-allowed disabled:opacity-50",title:"Save file","aria-label":"Save file",children:t.jsx(_.Save,{className:"h-4 w-4"})})]}):t.jsx("button",{type:"button",onClick:()=>{g(i.content),f(!0),w(null)},className:"thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition",title:"Edit file","aria-label":"Edit file",children:t.jsx(_.Pencil,{className:"h-4 w-4"})})}):null]}),k?t.jsx("div",{className:"border-b border-rose-200 bg-rose-50 px-4 py-2 text-sm text-rose-700 dark:border-rose-400/25 dark:bg-rose-400/10 dark:text-rose-200",children:k}):null,m?t.jsx("textarea",{value:p,onChange:z=>g(z.currentTarget.value),spellCheck:!1,"aria-label":"Workspace file editor",className:"thread-graph-file-editor min-h-0 flex-1 resize-none border-0 bg-transparent p-4 font-mono text-[12px] leading-5 text-slate-900 outline-none dark:text-slate-100"}):t.jsx(Or,{content:i.content}),i.truncated&&s?t.jsx("div",{className:"thread-graph-file-preview-footer flex justify-center border-t px-4 py-3",children:t.jsx("button",{type:"button",onClick:s,disabled:n,title:"Load more workspace preview","aria-label":"Load more workspace preview",className:"thread-graph-load-more-button rounded-md px-4 py-1.5 text-xs disabled:opacity-50",children:n?"Loading...":`Load more (${(i.size-i.nextOffset).toLocaleString()} bytes remaining)`})}):null]}):(u.kind==="live-molecule"||u.kind==="artifact")&&u.node.artifact?t.jsx("div",{className:J||Q?"min-h-0 flex-1 overflow-hidden":"min-h-0 flex-1 overflow-auto p-3",children:b}):u.kind==="meta"?t.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-3",children:t.jsx("div",{className:"grid gap-3",children:t.jsx(nr,{label:"Workspace Data",children:t.jsx(Or,{content:u.node.detail??""})})})}):t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsx("div",{className:"thread-graph-file-preview-header border-b px-4 py-3 text-xs uppercase tracking-[0.12em]",children:u.node.kind}),t.jsx(Or,{content:u.node.detail??u.node.preview??u.node.name})]}):t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center px-5 text-center text-sm text-slate-400 dark:text-slate-500",children:"Pick a live molecule, workspace file, artifact, or thread event to preview it."})]})]})}var Vo,qo,Or,qh=He({"src/components/graph-workspace/GraphWorkspacePreviewPane.tsx"(){ca(),Ho(),Hh(),Vo=50*1024,qo=1e3,Or=c.memo(function({content:r}){return t.jsx("div",{className:"thread-graph-code-preview min-h-0 flex-1 overflow-auto",children:t.jsx("pre",{className:"thread-graph-plain-code-preview",children:t.jsx("code",{children:r})})})})}});function Xh({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 Kh=He({"src/components/graph-workspace/GraphEmptyGarbageDialog.tsx"(){}});function Xo(e){return`${Yo}${e.workspaceId??"workspace"}:${e.threadId}`}function Yh(e){if(typeof window>"u")return[];try{const r=window.localStorage.getItem(Xo(e));if(!r)return[];const n=JSON.parse(r);return Array.isArray(n)?n.filter(a=>typeof a=="string"):[]}catch{return[]}}function Ja(e,r){if(!(typeof window>"u"))try{window.localStorage.setItem(Xo(e),JSON.stringify([...r]))}catch{}}function Un(e,r){if(!r||e.path!==r.path||e.kind!=="directory")return e;const n=new Map(r.children.map(o=>[o.path,o])),a=e.children.map(o=>Un(o,n.get(o.path)??null)),s=e.childrenLoaded&&e.children.length>0;return{...e,children:s||!r.childrenLoaded?a:r.children,childrenLoaded:e.childrenLoaded||r.childrenLoaded,truncated:e.truncated??r.truncated}}function Qa(e,r){if(e.kind==="directory")return r?t.jsx(_.FolderOpen,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"}):t.jsx(_.Folder,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"});const n=Rr(e.name);return n==="zip"?t.jsx(_.FileArchive,{className:"h-4 w-4 text-amber-600"}):e.kind==="file"&&["png","jpg","jpeg","gif","webp","svg"].includes(n)?t.jsx(_.FileImage,{className:"h-4 w-4 text-sky-500"}):e.kind==="artifact"||["xyz","extxyz","cif","pdf","json","ts","tsx","js","jsx","md","yaml","yml","py"].includes(n)?t.jsx(_.FileCode2,{className:"h-4 w-4 text-emerald-600"}):t.jsx(_.File,{className:"h-4 w-4 text-slate-400 dark:text-slate-500"})}function Ko({depth:e,expandedPaths:r,loadingPaths:n,node:a,onCopyPath:s,onDownload:o,onPreview:l,onSelect:i,onToggle:d,selectedNodeId:h}){const u=a.kind==="directory",m=u&&(a.path===""||r.has(a.path)),f=u&&n.has(a.path),p=h===a.id,g=`${e*.75+.5}rem`;return u?t.jsxs("div",{children:[t.jsxs("div",{className:"thread-graph-tree-row group flex items-center text-sm text-slate-600 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100",children:[t.jsxs("button",{type:"button",onClick:()=>d(a.path),className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 px-2 py-2 text-left sm:min-h-0 sm:py-1.5",style:{paddingLeft:g},children:[m?t.jsx(_.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}):t.jsx(_.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}),Qa(a,m),t.jsx("span",{className:"truncate",children:a.name}),f?t.jsx("span",{className:"ml-auto shrink-0 text-xs text-slate-400 dark:text-slate-500",children:"Loading"}):null]}),o?t.jsx("button",{type:"button",onClick:()=>o(a),className:"thread-graph-tree-action mr-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-slate-400 transition hover:bg-white hover:text-slate-900 sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100",title:a.path?`Download ${a.name}`:"Download workspace","aria-label":a.path?`Download ${a.name}`:"Download workspace",children:t.jsx(_.Download,{className:"h-3.5 w-3.5"})}):null,s&&a.path?t.jsx("button",{type:"button",onClick:()=>s(a),className:"thread-graph-tree-action mr-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-slate-400 transition hover:bg-white hover:text-slate-900 sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100",title:`Copy path for ${a.name}`,"aria-label":`Copy path for ${a.name}`,children:t.jsx(_.Copy,{className:"h-3.5 w-3.5"})}):null]}),m?t.jsxs("div",{children:[a.children.map(k=>t.jsx(Ko,{depth:e+1,expandedPaths:r,loadingPaths:n,node:k,...s?{onCopyPath:s}:{},...o?{onDownload:o}:{},...l?{onPreview:l}:{},onSelect:i,onToggle:d,selectedNodeId:h},k.id)),a.truncated?t.jsx("div",{className:"px-2 py-1 text-xs text-slate-400 dark:text-slate-500",style:{paddingLeft:`${(e+1)*.75+.5}rem`},children:"More items not shown"}):null]}):null]}):t.jsxs("div",{className:`thread-graph-tree-row group flex items-center text-sm transition ${p?"is-selected":"text-slate-600 hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100"}`,children:[t.jsxs("button",{type:"button",onClick:()=>i(a.id),className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 px-2 py-2 text-left sm:min-h-0 sm:py-1.5",style:{paddingLeft:`${e*.75+2.2}rem`},children:[Qa(a,!1),t.jsx("span",{className:"truncate",children:a.name})]}),a.kind==="file"&&(l||o||s)?t.jsxs("div",{className:"mr-1 flex shrink-0 items-center gap-0.5",children:[l?t.jsx("button",{type:"button",onClick:()=>l(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${p?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Preview ${a.name}`,"aria-label":`Preview ${a.name}`,children:t.jsx(_.Eye,{className:"h-3.5 w-3.5"})}):null,o?t.jsx("button",{type:"button",onClick:()=>o(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${p?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Download ${a.name}`,"aria-label":`Download ${a.name}`,children:t.jsx(_.Download,{className:"h-3.5 w-3.5"})}):null,s?t.jsx("button",{type:"button",onClick:()=>s(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${p?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Copy path for ${a.name}`,"aria-label":`Copy path for ${a.name}`,children:t.jsx(_.Copy,{className:"h-3.5 w-3.5"})}):null]}):null]})}function Zh({liveNodes:e,onSelect:r,selectedNodeId:n}){return e.length===0?null:t.jsxs("div",{className:"border-b border-slate-200 py-2 dark:border-[#2a2f3a]",children:[t.jsx("div",{className:"thread-graph-workspace-label px-3 pb-1 text-[11px] font-semibold tracking-normal text-slate-500 dark:text-slate-400",children:"Live"}),t.jsx("div",{className:"space-y-0.5",children:e.map(a=>{var o;const s=n===a.id;return t.jsxs("button",{type:"button","data-testid":"live-molecule-item","data-molecule-id":((o=a.artifact)==null?void 0:o.id)??a.id,onClick:()=>r(a.id),className:`thread-graph-tree-row flex min-h-9 w-full items-center gap-2 px-3 py-2 text-left text-sm transition sm:min-h-0 sm:py-1.5 ${s?"is-selected":"text-slate-600 hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100"}`,children:[t.jsx(_.FileCode2,{className:`h-4 w-4 shrink-0 ${s?"text-current":"text-emerald-600 dark:text-emerald-300"}`}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:a.name})]},a.id)})})]})}function Jh({canEmptyGarbage:e,canUpload:r,onCollapse:n,expandedPaths:a,loadingPaths:s,loading:o,onDownload:l,onCopyPath:i,onEmptyGarbage:d,onPreview:h,onRefresh:u,onSelect:m,onToggle:f,onUpload:p,explorerScrollTopRef:g,explorerScrollerRef:k,selectedNodeId:w,tree:x,liveNodes:j}){const y=c.useMemo(()=>({...x,children:x.children.filter(b=>b.path!=="live")}),[x]);return c.useLayoutEffect(()=>{const b=k.current;b&&(b.scrollTop=g.current)},[k,g]),t.jsxs("aside",{className:`${Zo} flex flex-col`,children:[t.jsxs("div",{className:Jo,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:el,title:"Collapse Explorer","aria-label":"Collapse Explorer",children:[t.jsx(_.ChevronsLeft,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Collapse Explorer"})]}):null,t.jsx("button",{type:"button",onClick:p,disabled:!r,className:Ur,title:r?"Upload file":"Upload is unavailable for this workspace","aria-label":"Upload file",children:t.jsx(_.Upload,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:u,className:Ur,title:"Refresh workspace","aria-label":"Refresh workspace",children:t.jsx(_.RefreshCw,{className:`h-4 w-4 ${o?"animate-spin":""}`})}),d?t.jsx("button",{type:"button",onClick:d,disabled:!e,className:Ur,title:e?"Empty garbage":"Garbage controls are unavailable","aria-label":"Empty garbage",children:t.jsx(_.Trash2,{className:"h-4 w-4"})}):null]})]}),t.jsxs("div",{ref:k,className:"thread-graph-workspace-tree-scroll min-h-0 flex-1 overflow-y-auto py-2",onScroll:b=>{g.current=b.currentTarget.scrollTop},children:[t.jsx(Zh,{liveNodes:j??[],onSelect:m,selectedNodeId:w}),t.jsx("div",{className:tl,children:"Workspace"}),t.jsx(Ko,{depth:0,expandedPaths:a,loadingPaths:s,node:y,...i?{onCopyPath:i}:{},...l?{onDownload:l}:{},...h?{onPreview:h}:{},onSelect:m,onToggle:f,selectedNodeId:w}),y.children.length===0?t.jsx("p",{className:rl,children:"This workspace is empty. Agent tool runs execute inside the thread workspace, so files should appear here as the session works."}):null]})]})}function Qh({activeView:e,detail:r,artifacts:n,plugins:a,status:s,focusPathRequest:o,workspaceAdapter:l}){const[i,d]=c.useState(null),h=c.useMemo(()=>l&&i?null:qa(r,n),[e,i,n,r,s,l]),u=i??h??qa(r,n),m=c.useMemo(()=>bh(u),[u]),f=c.useMemo(()=>{var I;return((I=u.children.find(O=>O.path==="live"))==null?void 0:I.children)??[]},[u]),p=Bo(u),[g,k]=c.useState(()=>(p==null?void 0:p.id)??null),[w,x]=c.useState(()=>new Set(["","artifacts","thread-events","live",...Xa((p==null?void 0:p.path)??"")])),[j,y]=c.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 639px)").matches?"viewer":null),[b,v]=c.useState(null),[S,N]=c.useState(!1),[L,R]=c.useState(()=>new Set),[P,Q]=c.useState(!1),[K,J]=c.useState(!1),[B,z]=c.useState(!1),[te,se]=c.useState([]),[$,ie]=c.useState(null),[q,H]=c.useState(null),[G,T]=c.useState(null),[F,D]=c.useState(!1),E=c.useRef(null),C=c.useRef(null),W=c.useRef(0),U=c.useRef(null),ae=!!l,X=(g?m.get(g):null)??p??null,de={threadId:r.thread.id,workspaceId:r.workspace.id??r.thread.workspaceId??null};c.useEffect(()=>{W.current=0,U.current=null,x(new Set(["","artifacts","thread-events","live",...Yh(de),...Xa((p==null?void 0:p.path)??"")]))},[de.threadId,de.workspaceId]);function ee(){var O;const I=((O=C.current)==null?void 0:O.scrollTop)??W.current;W.current=I,U.current=I}function ke(){const I=U.current??W.current;if(!C.current)return;let oe=0;const ge=()=>{const Ne=C.current;Ne&&(Ne.scrollTop=Math.min(I,Math.max(0,Ne.scrollHeight-Ne.clientHeight)),W.current=Ne.scrollTop,oe+=1,oe<8?window.requestAnimationFrame(ge):U.current=null)};window.requestAnimationFrame(ge)}c.useLayoutEffect(()=>{j!=="explorer"&&ke()},[j,u]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const I=window.matchMedia("(max-width: 639px)"),O=()=>D(I.matches);return O(),typeof I.addEventListener=="function"?(I.addEventListener("change",O),()=>I.removeEventListener("change",O)):(I.addListener(O),()=>I.removeListener(O))},[]);async function le(I){if(!l)return;const O=I??(X==null?void 0:X.path)??null;N(!0),v(null);try{const oe=rr(await l.listTree({...de,path:""}));let ge=i?Un(oe,i):oe;if(i){const Ce=[...w].filter(xe=>xe).sort((xe,Ge)=>xe.split("/").length-Ge.split("/").length);for(const xe of Ce){const Ge=Fn(i,xe);if((Ge==null?void 0:Ge.kind)!=="directory"||!Ge.childrenLoaded)continue;const Me=rr(await l.listTree({...de,path:xe}));ge=Hn(ge,xe,Un(Me,Ge))}}d(ge);const Ne=_o(ge);k(Ce=>{var Ge;const xe=O??(Ce?(Ge=m.get(Ce))==null?void 0:Ge.path:null);return xe&&On(ge,xe)?`workspace:${xe}`:(Ne==null?void 0:Ne.id)??Ce})}catch(oe){v(oe instanceof Error?oe.message:"Failed to load workspace"),d(null)}finally{N(!1)}}async function je(I){if(!(!l||!i)){R(O=>{if(O.has(I))return O;const oe=new Set(O);return oe.add(I),oe}),v(null);try{const O=rr(await l.listTree({...de,path:I}));d(oe=>oe&&Mo(oe,I,O.children,{truncated:O.truncated}))}catch(O){v(O instanceof Error?O.message:"Failed to load directory")}finally{R(O=>{if(!O.has(I))return O;const oe=new Set(O);return oe.delete(I),oe})}}}async function Ae(I){const O=$o(I);if(!O)return;const oe=uh(O);if(y(null),x(ge=>{const Ne=new Set(ge);Ne.add("");for(const Ce of oe)Ne.add(Ce);return Ja(de,Ne),Ne}),!l){On(u,O)&&k(`workspace:${O}`);return}N(!0),v(null);try{let ge=i??rr(await l.listTree({...de,path:""}));for(const Ne of oe){const Ce=Fn(ge,Ne);if((Ce==null?void 0:Ce.kind)==="directory"&&Ce.childrenLoaded)continue;const xe=rr(await l.listTree({...de,path:Ne}));ge=Hn(ge,Ne,xe)}d(ge),k(`workspace:${O}`)}catch(ge){v(ge instanceof Error?ge.message:`Failed to open ${O}`)}finally{N(!1)}}c.useEffect(()=>{if(!(!l||!i))for(const I of m.values())I.path&&I.kind==="directory"&&w.has(I.path)&&I.hasChildren&&!I.childrenLoaded&&!L.has(I.path)&&je(I.path)},[i,w,m,l]),c.useEffect(()=>{d(null),R(new Set),ie(null),H(null),T(null),v(null),le()},[ae,r.thread.id,r.workspace.id,r.thread.workspaceId]),c.useEffect(()=>{o&&Ae(o.path)},[o==null?void 0:o.requestId]),c.useEffect(()=>{l!=null&&l.subscribeWorkspaceChanged},[l,de.threadId,de.workspaceId]),c.useEffect(()=>{const I=l&&(X==null?void 0:X.kind)==="file"?X.path:null;if(!I){ie(null),H(null),T(null);return}const O=I;let oe=!1;async function ge(){var Ne;if(l){Q(!0),v(null),ie(null),H(null),T(null);try{const Ce=Rr(O),xe=(Ne=l.getRawFileUrl)==null?void 0:Ne.call(l,{...de,path:O});if(xe&&Go.has(Ce)){oe||H(xe);return}if(xe&&Fo.has(Ce)){oe||T(xe);return}const Ge=await l.readFile({...de,path:O,limit:Wr});oe||ie(Ge)}catch(Ce){oe||v(Ce instanceof Error?Ce.message:"Failed to read file")}finally{oe||Q(!1)}}}return ge(),()=>{oe=!0}},[l,X==null?void 0:X.id]);async function ce(){if(!(!l||!($!=null&&$.truncated))){J(!0);try{const I=await l.readFile({...de,path:$.path,offset:$.nextOffset,limit:Wr});ie(O=>O&&{...O,content:O.content+I.content,truncated:I.truncated,nextOffset:I.nextOffset,size:I.size})}finally{J(!1)}}}async function ne(I){if(!(l!=null&&l.writeFile))return;v(null),await l.writeFile({...de,path:I.path,content:I.content}),await le(I.path);const O=await l.readFile({...de,path:I.path,limit:Wr});ie(O)}async function Le(I){if(!(!(l!=null&&l.uploadFile)||!I)){N(!0),v(null);try{const O=await l.uploadFile({...de,path:I.name,file:I}),oe=O.kind==="archive"?O.paths[0]??null:O.file.path;await le(oe)}catch(O){v(O instanceof Error?O.message:"Failed to upload file")}finally{N(!1)}}}async function Z(I){var oe;const O=(oe=I.target.files)==null?void 0:oe[0];I.target.value="",O&&await Le(O)}function me(){if(!(l!=null&&l.uploadFile))return;const I=()=>{var O;return(O=E.current)==null?void 0:O.click()};if(l.pickUploadFile){l.pickUploadFile({...de,defaultPick:I,upload:Le});return}I()}function we(I){var O;(O=l==null?void 0:l.downloadNode)==null||O.call(l,{...de,path:I.path,kind:I.kind==="directory"?"directory":"file"})}function ye(I){if(!I.path||typeof navigator>"u"||!navigator.clipboard)return;const O=r.workspace.absPath.replace(/\/+$/,""),oe=I.path.startsWith("/")?I.path:O?`${O}/${I.path.replace(/^\/+/,"")}`:I.path;navigator.clipboard.writeText(oe).catch(ge=>{v(ge instanceof Error?ge.message:"Failed to copy file path")})}function De(I){I.kind==="file"&&(ee(),k(I.id),y("explorer"))}async function Be(){if(l!=null&&l.emptyGarbage){if(v(null),!l.listGarbage){se([]),z(!0);return}try{const I=await l.listGarbage(de);se(I.map(O=>`garbage/${O}`))}catch(I){se([]),v(I instanceof Error?I.message:"Failed to list garbage files")}finally{z(!0)}}}async function $e(){if(l!=null&&l.emptyGarbage){z(!1),v(null);try{await l.emptyGarbage(de),await le((X==null?void 0:X.path)??null)}catch(I){v(I instanceof Error?I.message:"Failed to empty garbage")}}}const Oe={onCopyPath:ye,...l!=null&&l.downloadNode?{onDownload:we}:{},...l!=null&&l.emptyGarbage?{onEmptyGarbage:Be}:{},...l?{onRefresh:()=>void le((X==null?void 0:X.path)??null)}:{},...l!=null&&l.uploadFile?{onUpload:me}:{}};function V(I){if(!I)return;const O=m.get(`workspace:${I}`),oe=(O==null?void 0:O.kind)==="directory"&&O.hasChildren&&!O.childrenLoaded&&!L.has(I);x(ge=>{const Ne=new Set(ge);return Ne.has(I)?Ne.delete(I):Ne.add(I),Ja(de,Ne),Ne}),!w.has(I)&&oe&&je(I)}const he=t.jsx(Jh,{canEmptyGarbage:!!(l!=null&&l.emptyGarbage),canUpload:!!(l!=null&&l.uploadFile),onCollapse:()=>{ee(),y("explorer")},expandedPaths:w,loadingPaths:L,loading:S,explorerScrollTopRef:W,explorerScrollerRef:C,...Oe,onPreview:De,onSelect:I=>{k(I)},onToggle:V,selectedNodeId:(X==null?void 0:X.id)??null,tree:u,liveNodes:f}),ve=t.jsx(Vh,{error:b,imageUrl:q,loadingMore:K,onLoadMore:ce,...l!=null&&l.writeFile?{onSaveFile:ne}:{},onCollapse:()=>{ee(),y("viewer")},pdfUrl:G,previewFile:$,previewLoading:P,plugins:a,selectedTarget:Uh(X)});return j==="explorer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:ve}):j==="viewer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:he}):t.jsxs("div",{"data-testid":"workspace-panel",className:"flex h-full min-h-0 w-full overflow-hidden bg-transparent p-2",children:[B?t.jsx(Xh,{files:te,onCancel:()=>z(!1),onConfirm:()=>void $e()}):null,F?t.jsxs(Bn,{direction:"vertical",className:"thread-graph-workspace-mobile-stack",children:[t.jsx(or,{defaultSize:42,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-explorer h-full min-h-0 overflow-hidden",children:he})}),t.jsx(Gn,{className:"thread-graph-workspace-resize-handle h-2 bg-transparent after:h-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(or,{defaultSize:58,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-viewer h-full min-h-0 overflow-hidden",children:ve})})]}):t.jsxs(Bn,{direction:"horizontal",className:"thread-graph-workspace-resizable",children:[t.jsx(or,{defaultSize:33,minSize:20,children:t.jsx("div",{className:"thread-graph-workspace-explorer-pane h-full min-h-0 overflow-hidden",children:he})}),t.jsx(Gn,{className:"thread-graph-workspace-resize-handle w-2 bg-transparent after:w-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(or,{defaultSize:67,minSize:30,children:t.jsx("div",{className:"thread-graph-workspace-viewer-pane h-full min-h-0 overflow-hidden",children:ve})})]}),t.jsx("input",{ref:E,type:"file","aria-label":"Workspace upload file input","data-testid":"workspace-upload-file-input",className:"hidden",onChange:I=>void Z(I)})]})}var Wr,Yo,Zo,Jo,Qo,Ur,el,tl,rl,eu=He({"src/components/graph-workspace/GraphWorkspaceExplorer.tsx"(){ca(),qh(),Kh(),Ao(),Wr=24e3,Yo="remote-codex:graphchat:workspace:expanded:",Zo="thread-graph-explorer h-full min-h-0 overflow-hidden rounded-[12px]",Jo="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",Ur="thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition disabled:cursor-not-allowed disabled:opacity-50",el="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",tl="thread-graph-workspace-label px-3 pb-1 pt-2 text-[11px] font-semibold tracking-normal text-slate-500 dark:text-slate-400",rl="thread-graph-workspace-empty mx-4 mt-3 rounded-lg border border-dashed border-slate-200 bg-slate-50 px-3 py-4 text-sm text-slate-500 dark:border-[#303642] dark:bg-[#1b1f29] dark:text-slate-400"}});function Cn({children:e}){return t.jsx("span",{className:"thread-guide-tag inline-flex items-center rounded px-1.5 py-0.5 font-mono text-[10px]",children:e})}function er({items:e}){return t.jsx("ul",{className:"space-y-1 text-[12px] text-[var(--theme-fg-muted)]",children:e.map((r,n)=>t.jsxs("li",{className:"flex gap-2",children:[t.jsx("span",{className:"mt-[6px] h-1 w-1 shrink-0 rounded-full bg-[var(--theme-border-contrast)]"}),t.jsx("span",{children:r})]},n))})}function tu({children:e}){return t.jsx("span",{className:"thread-guide-icon flex h-5 w-5 shrink-0 items-center justify-center rounded-md",children:e})}function gr({value:e,title:r,icon:n,children:a}){return t.jsxs(Ir,{value:e,className:"thread-guide-section border-b border-[var(--theme-border)] last:border-b-0",children:[t.jsx(on,{className:"py-3 hover:no-underline [&[data-state=open]]:pb-2",children:t.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-[var(--theme-fg)]",children:[t.jsx(tu,{children:n}),r]})}),t.jsx(zr,{className:"space-y-3 pb-3",children:a})]})}function ru(){return t.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[t.jsxs("div",{className:"shrink-0 border-b border-[var(--theme-border)] px-4 py-3",children:[t.jsx("h2",{className:"text-xs font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"What can I do?"}),t.jsx("p",{className:"mt-0.5 text-[11px] text-[var(--theme-fg-muted)]",children:"Upload files, ask in plain language, get results."})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-3 pb-6",children:t.jsxs(Lr,{type:"multiple",defaultValue:["start","workspace","remote-codex"],className:"space-y-0",children:[t.jsxs(gr,{value:"start",title:"Getting Started",icon:t.jsx(_.Zap,{className:"h-3 w-3"}),children:[t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"graphchat connects a language model to your files and a set of tools. Each Remote Codex thread has its own isolated workspace."}),t.jsx(er,{items:["Upload data files via the Workspace panel","Type a question or task in plain language","The agent calls tools, writes results to the workspace, and explains what it found","Agent-produced files appear in the workspace automatically when the host reports changes"]})]}),t.jsxs(gr,{value:"workspace",title:"Workspace Explorer",icon:t.jsx(_.FolderOpen,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(_.Upload,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Upload"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Upload files through the Workspace panel when the host exposes workspace upload support. Composer attachments stay available for prompt context."})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(_.Plus,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"New files and folders"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Remote Codex normally creates files through tools and shell commands. They appear in Explorer after workspace refreshes."})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(_.MoveRight,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Move and organize"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Use the agent or terminal to reorganize files. Explorer keeps the GraphChat file tree and preview flow."})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(_.Trash2,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-rose-400"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Garbage folder"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"If the host exposes garbage controls, Explorer can permanently empty unwanted workspace files."})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(_.RefreshCw,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Refresh"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Resync the file tree manually after shell commands, external changes, or agent tool runs."})]})]}),t.jsxs("div",{className:"rounded-lg border border-[var(--theme-border)] p-2.5",children:[t.jsx("p",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"Preview surfaces"}),t.jsx(er,{items:[t.jsxs(t.Fragment,{children:[t.jsx(Cn,{children:".xyz .extxyz .cif"})," use the 3D molecule plugin."]}),t.jsxs(t.Fragment,{children:[t.jsx(Cn,{children:".png .jpg .gif .svg .webp"})," use inline image preview."]}),t.jsxs(t.Fragment,{children:[t.jsx(Cn,{children:".py .json .ts .md .csv"})," use text/code preview."]}),"Large files load in chunks when the workspace adapter supports it."]})]})]}),t.jsxs(gr,{value:"viewer",title:"Viewer",icon:t.jsx(_.FileImage,{className:"h-3 w-3"}),children:[t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Viewer is the GraphChat-style artifact surface. It opens Remote Codex artifacts through the same frontend plugin renderers used in rich message bubbles, and previews workspace files from Explorer."}),t.jsx(er,{items:["Expand one artifact at a time for inspection","Fallback JSON preview is available for unknown artifact types","3D molecule artifacts remain interactive when the XYZ plugin is enabled"]})]}),t.jsxs(gr,{value:"usage",title:"Tool Usage & Chat",icon:t.jsx(_.BarChart2,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(_.BarChart2,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Usage tab"}),t.jsx(er,{items:["Bar chart of tool and command counts for this thread","Expandable call log: inspect every input and output","Recent live events appear with persisted history"]})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(_.MessageSquare,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Chat controls"}),t.jsx(er,{items:["New Chat creates a fresh Remote Codex thread with its own workspace","Interrupt, compact, goal controls, and model controls remain in the composer","Shell view stays available when a shell adapter is attached"]})]})]})]}),t.jsx(gr,{value:"remote-codex",title:"Remote Codex Extras",icon:t.jsx(_.Code2,{className:"h-3 w-3"}),children:t.jsx(er,{items:["Slash toolbox: skills, MCP, hooks, goals, forks, model controls, provider settings","Rich message bubbles: reasoning, commands, searches, file reads, file changes, plans, action requests, artifacts","Plugin surfaces: terminal, XYZ molecule viewer, inline code renderers, and imported plugin panels","Thread metadata stays in the left rail and Workspace tab instead of replacing chat"]})})]})})]})}var nu=He({"src/components/graph-workspace/GraphGuidePanel.tsx"(){Pr()}});function au(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 es({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:au(r)})]})}function su({event:e}){return t.jsxs(Ir,{value:e.id,className:"thread-tool-call mb-2 overflow-hidden rounded-lg border border-[var(--theme-border)] last:mb-0",children:[t.jsxs(on,{className:"px-3 py-2 text-xs font-medium text-[var(--theme-fg)] hover:bg-[var(--theme-hover)] hover:no-underline [&[data-state=open]]:bg-[var(--theme-hover)]",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full bg-[var(--theme-accent-strong)]"}),t.jsx("span",{className:"truncate font-mono text-xs font-medium text-[var(--theme-fg)]",children:e.label}),e.status?t.jsx("span",{className:"shrink-0 rounded-full border border-[var(--theme-border)] px-1.5 py-0.5 text-[9px] uppercase tracking-[0.12em] text-[var(--theme-fg-muted)]",children:e.status}):null]}),t.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:e.turnId?t.jsx("span",{className:"max-w-20 truncate text-[10px] text-[var(--theme-fg-muted)]",children:e.turnId}):null})]}),t.jsx(zr,{className:"px-3 pb-3",children:t.jsxs("div",{className:"space-y-2 px-3 pb-3 pt-1",children:[t.jsx(es,{label:"Input",value:e.preview}),t.jsx(es,{label:"Output",value:e.detail})]})})]})}function ou({formatToolKind:e,toolCounts:r,toolEvents:n,maxToolCount:a}){const[s,o]=c.useState(()=>{var i;return((i=n.at(-1))==null?void 0:i.id)??null}),l=c.useRef(null);return c.useEffect(()=>{o(i=>{var d;return i??((d=n.at(-1))==null?void 0:d.id)??null})},[n]),c.useEffect(()=>{var i;(i=l.current)==null||i.scrollIntoView({behavior:"smooth",block:"nearest"})},[n.length]),r.length?t.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[t.jsxs("div",{className:"shrink-0 border-b border-[var(--theme-border)] p-4",children:[t.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[t.jsx("h2",{className:"text-xs font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"Calls this session"}),t.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-[var(--theme-fg-muted)] opacity-60",disabled:!0,title:"Remote Codex streams tool history from thread events",children:[t.jsx(_.RefreshCw,{className:"h-3 w-3"}),"Reload"]})]}),t.jsx("div",{className:"space-y-2",children:r.map(([i,d])=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"w-40 shrink-0 truncate text-right font-mono text-[11px] text-[var(--theme-fg-muted)]",title:e(i),children:e(i)}),t.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[t.jsx("div",{className:"relative h-4 flex-1 overflow-hidden rounded-sm bg-[var(--theme-muted)]",children:t.jsx("div",{className:"h-full rounded-sm bg-[var(--theme-accent-strong)] transition-all duration-300",style:{width:`${d/a*100}%`}})}),t.jsx("span",{className:"w-5 shrink-0 text-right text-[11px] font-medium text-[var(--theme-fg-soft)]",children:d})]})]},i))})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:[t.jsx("h2",{className:"mb-3 text-xs font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"Call log"}),t.jsx(Lr,{type:"single",collapsible:!0,value:s??"",onValueChange:i=>o(i||null),className:"space-y-0",children:n.slice(-50).map(i=>t.jsx(su,{event:i},i.id))}),t.jsx("div",{ref:l})]})]}):t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 text-sm text-[var(--theme-fg-muted)]",children:[t.jsx("span",{children:"No tool calls yet. Run the agent to see usage."}),t.jsxs("span",{className:"inline-flex items-center gap-1 rounded px-2 py-1 text-xs",children:[t.jsx(_.RefreshCw,{className:"h-3 w-3"}),"Reload from workspace"]})]})}var lu=He({"src/components/graph-workspace/GraphToolUsagePanel.tsx"(){Pr()}});function ts(e,r){const n=Math.max(e.measured.width??1,1),a=Math.max(e.measured.height??1,1),s=e.internals.positionAbsolute,o=r.internals.positionAbsolute,l=Math.max(r.measured.width??1,1),i=Math.max(r.measured.height??1,1),d=n/2,h=a/2,u=s.x+d,m=s.y+h,f=o.x+l/2,p=o.y+i/2,g=(f-u)/(2*d)-(p-m)/(2*h),k=(f-u)/(2*d)+(p-m)/(2*h),w=1/(Math.abs(g)+Math.abs(k)),x=w*g,j=w*k,y=d*(x+j)+u,b=h*(-x+j)+m;return{x:y,y:b}}function rs(e,r){const n={...e.internals.positionAbsolute,...e},a=Math.round(n.x),s=Math.round(n.y),o=Math.round(r.x),l=Math.round(r.y);return o<=a+1?Ft.Left:o>=a+(e.measured.width??1)-1?Ft.Right:l<=s+1?Ft.Top:l>=n.y+(e.measured.height??1)-1?Ft.Bottom:Ft.Top}function nl(e,r){const n=ts(e,r),a=ts(r,e),s=rs(e,n),o=rs(r,a);return{sx:n.x,sy:n.y,tx:a.x,ty:a.y,sourcePos:s,targetPos:o}}function iu(e,r=900,n=620){if(!e||!Array.isArray(e))return{nodes:[],edges:[]};const a=(d,h,u,m)=>{const f=new Map,p=d.length;d.forEach((g,k)=>{const w=g.id.split("").reduce((x,j)=>{const y=(x<<5)-x+j.charCodeAt(0);return y&y},0);f.set(g.id,{x:Math.abs(w)%u+k*100%u,y:Math.abs(w>>16)%m+k*150%m,vx:0,vy:0})});for(let g=0;g<200;g+=1){for(let k=0;k<p;k+=1)for(let w=k+1;w<p;w+=1){const x=d[k],j=d[w];if(!x||!j)continue;const y=f.get(x.id),b=f.get(j.id);if(!y||!b)continue;const v=y.x-b.x,S=y.y-b.y,N=Math.sqrt(v*v+S*S)||1,R=(200-N)*.5,P=v/N*R,Q=S/N*R;y.vx+=P,y.vy+=Q,b.vx-=P,b.vy-=Q}h.forEach(k=>{const w=f.get(k.source),x=f.get(k.target);if(!w||!x)return;const j=x.x-w.x,y=x.y-w.y,b=Math.sqrt(j*j+y*y)||1,S=(b-120)*.3,N=j/b*S,L=y/b*S;w.vx+=N,w.vy+=L,x.vx-=N,x.vy-=L}),f.forEach(k=>{k.x+=k.vx*.1,k.y+=k.vy*.1,k.vx*=.9,k.vy*=.9,k.x=Math.max(80,Math.min(u-80,k.x)),k.y=Math.max(80,Math.min(m-80,k.y))})}return f},s=new Set(e.map(d=>d.id)),o=[];e.forEach(d=>{if(!d.out_node_id)return;(Array.isArray(d.out_node_id)?d.out_node_id:[d.out_node_id]).forEach(u=>{s.has(u)&&o.push({id:`${d.id}-${u}`,source:d.id,target:u,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:Vs.Arrow}})})});const l=a(e,o,r,n);return{nodes:e.map(d=>({id:d.id,type:"styledNode",position:l.get(d.id)??{x:100,y:100},data:{label:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-sm font-semibold",children:d.name}),d.description?t.jsx("div",{className:"mt-1 max-w-32 overflow-hidden text-ellipsis text-xs text-slate-500 dark:text-slate-400",children:d.description}):null]})}})),edges:o}}var ha=He({"src/components/graph-chat/FloatingHelper.tsx"(){}});function du({toX:e,toY:r,fromPosition:n,toPosition:a,fromNode:s}){if(!s)return null;const o={id:"connection-target",measured:{width:1,height:1},internals:{positionAbsolute:{x:e,y:r}}},{sx:l,sy:i,tx:d,ty:h,sourcePos:u,targetPos:m}=nl(s,o),[f]=qs({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 cu=He({"src/components/graph-chat/FloatingConnectionLine.tsx"(){ha()}});function hu({id:e,source:r,target:n,markerEnd:a,style:s}){const o=La(r),l=La(n);if(!o||!l)return null;const{sx:i,sy:d,tx:h,ty:u,sourcePos:m,targetPos:f}=nl(o,l),[p]=qs({sourceX:i,sourceY:d,sourcePosition:m,targetPosition:f,targetX:h,targetY:u});return t.jsx("path",{id:e,className:"react-flow__edge-path",d:p,markerEnd:a,style:s})}var uu=He({"src/components/graph-chat/FloatingEdge.tsx"(){ha()}});function mu({nodes:e}){const[r,n,a]=Ed([]),[s,o,l]=Ld([]),i=c.useMemo(()=>iu(e),[e]),d=c.useMemo(()=>({floating:hu}),[]),h=c.useMemo(()=>({styledNode:({data:m,isConnectable:f})=>t.jsxs("div",{className:"thread-graph-flow-node",children:[m.label,t.jsx(Ea,{type:"target",position:Ft.Top,isConnectable:f,style:{opacity:0,pointerEvents:"none"}}),t.jsx(Ea,{type:"source",position:Ft.Bottom,isConnectable:f,style:{opacity:0,pointerEvents:"none"}})]})}),[]);c.useEffect(()=>{n(i.nodes),o(i.edges)},[i.edges,i.nodes,o,n]);const u=c.useCallback(m=>o(f=>Id({...m,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:Vs.Arrow}},f)),[o]);return t.jsx("div",{className:"thread-graph-flow h-full min-h-0",children:t.jsx(zd,{children:t.jsxs(Pd,{nodes:r,edges:s,onNodesChange:a,onEdgesChange:l,onConnect:u,fitView:!0,nodeTypes:h,edgeTypes:d,connectionLineComponent:du,children:[t.jsx(Rd,{}),t.jsx(Ad,{gap:16})]})})})}var pu=He({"src/components/graph-chat/GraphVisualization.tsx"(){cu(),uu(),ha()}});function fu(e){return{...sl,...e}}function ns(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 gu(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 xu(e){var s;const r=[],n=new Set(["toolCall","commandExecution","webSearch","fileRead","fileChange","agentToolCall","skillToolCall","hook"]);let a=0;for(const o of e.turns)for(const l of o.items)n.has(l.kind)&&(r.push({id:l.id,kind:l.kind,label:Yr(l.kind),preview:l.previewText??l.text??l.kind,detail:l.detailText??l.text??l.previewText??l.kind,turnId:l.sourceTurnId??o.id,status:l.status??null,sequence:a}),a+=1);for(const o of((s=e.liveItems)==null?void 0:s.items)??[])n.has(o.kind)&&(r.push({id:o.id,kind:o.kind,label:Yr(o.kind),preview:o.previewText??o.text??o.kind,detail:o.detailText??o.text??o.previewText??o.kind,turnId:o.sourceTurnId??null,status:o.status??null,sequence:a}),a+=1);return r}function Yr(e){switch(e){case"toolCall":return"Tool call";case"agentToolCall":return"Agent tool";case"skillToolCall":return"Skill tool";case"commandExecution":return"Command";case"webSearch":return"Search";case"fileRead":return"File read";case"fileChange":return"File change";case"hook":return"Hook";default:return e.replace(/([A-Z])/g," $1").replace(/^./,r=>r.toUpperCase())}}function bu(e){switch(e.kind){case"userMessage":return"User";case"agentMessage":return"Agent";default:return Yr(e.kind)}}function vu(e){return(e.previewText??e.text??e.detailText??e.kind).replace(/\s+/g," ").slice(0,96)}function ku(e,r){const n=[{id:`thread:${e.thread.id}`,name:e.thread.title||"Thread",description:e.thread.model??e.thread.status},{id:`workspace:${e.workspace.id}`,name:e.workspace.label??"Workspace",description:e.workspace.absPath,out_node_id:`thread:${e.thread.id}`}];let a=null;for(const o of e.turns){const l=`turn:${o.id}`;n.push({id:l,name:`Turn ${n.filter(d=>d.id.startsWith("turn:")).length+1}`,description:o.status,out_node_id:a?[`thread:${e.thread.id}`,a]:`thread:${e.thread.id}`}),a=l;let i=null;for(const d of o.items){const h=`item:${d.id}`,u=[l];i&&u.push(i),n.push({id:h,name:bu(d),description:vu(d),out_node_id:u}),i=h,d.kind==="artifact"&&d.artifact&&n.push({id:`artifact:${d.artifact.id}`,name:d.artifact.title||d.artifact.type,description:d.artifact.summaryText??d.artifact.type,out_node_id:h})}}const s=new Set(n.map(o=>o.id));for(const o of r){const l=`tool:${o.id}`;s.has(l)||s.has(`item:${o.id}`)||n.push({id:l,name:o.label,description:o.preview,out_node_id:o.turnId?`turn:${o.turnId}`:`thread:${e.thread.id}`})}return n.slice(0,120)}function al({detail:e,status:r,plugins:n,workspaceAdapter:a,metaContent:s,settingsContent:o,activeView:l="chat",features:i,focusPathRequest:d=null}){const h=c.useMemo(()=>fu(i),[i]),u=ns(h,i==null?void 0:i.defaultTab),[m,f]=c.useState(u),p=c.useMemo(()=>dh(e),[e]),g=c.useMemo(()=>xu(e),[e]),k=c.useMemo(()=>{const v=new Map;for(const S of g)v.set(S.kind,(v.get(S.kind)??0)+1);return[...v.entries()].sort((S,N)=>N[1]-S[1])},[g]),w=n.getThreadPanels(),x=Math.max(...k.map(([,v])=>v),1),j=c.useMemo(()=>ku(e,g),[e,g]),y=c.useMemo(()=>{const v=[];return h.workspace&&v.push({id:"workspace",label:"Workspace",icon:null}),h.toolUsage&&v.push({id:"tools",label:"Tool Usage",icon:_.BarChart2}),h.guide&&v.push({id:"guide",label:"Guide",icon:_.BookOpen}),v},[h.guide,h.toolUsage,h.workspace]),b=c.useMemo(()=>{const v=[];return h.threadGraph&&v.push({id:"graph",label:"Thread graph",icon:_.GitBranch}),h.extensions&&v.push({id:"extensions",label:"Remote Codex extensions",icon:_.Wrench}),v},[h.extensions,h.threadGraph]);return c.useEffect(()=>{(!m||!gu(h,m))&&f(ns(h,i==null?void 0:i.defaultTab))},[m,i==null?void 0:i.defaultTab,h]),c.useEffect(()=>{d&&h.workspace&&f("workspace")},[h.workspace,d==null?void 0:d.requestId]),m?t.jsxs("div",{className:"thread-graph-right-panel flex h-full min-h-0 flex-col overflow-hidden",children:[t.jsxs("div",{className:"thread-graph-right-tabs flex shrink-0 items-center gap-1 overflow-hidden border-b px-3 py-2",children:[y.map(v=>{const S=v.icon;return t.jsxs("button",{type:"button",onClick:()=>f(v.id),className:`thread-graph-right-tab inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md px-3 text-xs font-medium transition ${m===v.id?"is-active":""}`,children:[S?t.jsx(S,{className:"h-3.5 w-3.5"}):null,v.label]},v.id)}),b.length?t.jsx("div",{className:"thread-graph-right-tab-secondary ml-auto flex min-w-0 shrink items-center gap-1 border-l pl-2","aria-label":"Remote Codex workspace extensions",children:b.map(v=>{const S=v.icon;return t.jsx("button",{type:"button",onClick:()=>f(v.id),className:`thread-graph-right-tab inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-xs font-medium transition ${m===v.id?"is-active":""}`,title:v.label,"aria-label":v.label,children:t.jsx(S,{className:"h-3.5 w-3.5"})},v.id)})}):null]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[m==="workspace"?t.jsx(Qh,{activeView:l,detail:e,artifacts:p,plugins:n,status:r,focusPathRequest:d,workspaceAdapter:a??null}):null,m==="tools"?t.jsx(ou,{formatToolKind:Yr,toolCounts:k,toolEvents:g,maxToolCount:x}):null,m==="graph"?t.jsx("div",{className:"thread-graph-visualization-panel h-full min-h-0 p-3",children:t.jsx(mu,{nodes:j})}):null,m==="extensions"?t.jsx("div",{className:"h-full min-h-0 overflow-y-auto p-3",children:t.jsxs("div",{className:"grid gap-3",children:[t.jsx(nr,{label:"Plugin Panels",children:w.length?t.jsx("div",{className:"flex flex-wrap gap-2",children:w.map(v=>t.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-1 text-xs text-[var(--theme-fg-soft)]",children:v.label},v.id))}):t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"No thread panels are enabled."})}),t.jsx(nr,{label:"Enabled Renderers",children:t.jsx("div",{className:"flex flex-wrap gap-2",children:n.plugins.filter(v=>v.enabled).map(v=>t.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-1 text-xs text-[var(--theme-fg-soft)]",children:v.name},v.id))})}),t.jsx(nr,{label:"Remote Codex Tools",children:t.jsxs("div",{className:"grid gap-2 text-[var(--theme-fg-muted)]",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(_.Terminal,{className:"mt-0.5 h-4 w-4 shrink-0"}),t.jsx("p",{children:"Terminal stays available when the Terminal plugin and shell adapter are attached."})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(_.Paperclip,{className:"mt-0.5 h-4 w-4 shrink-0"}),t.jsx("p",{children:"Composer attachments, slash panels, hooks, MCP, goals, and fork controls remain part of the chat surface."})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(_.Trash2,{className:"mt-0.5 h-4 w-4 shrink-0"}),t.jsx("p",{children:"Destructive actions stay explicit: delete thread, interrupt, compact, and hook trust controls remain host governed."})]})]})}),s?t.jsx(nr,{label:"Thread Meta",children:s}):null,o?t.jsx(nr,{label:"Settings",children:o}):null]})}):null,m==="guide"?t.jsx(ru,{}):null]})]}):null}var sl,ol,wu=He({"src/components/ThreadGraphWorkspacePanel.tsx"(){eu(),Ho(),nu(),lu(),ca(),pu(),sl={workspace:!0,toolUsage:!0,guide:!0,threadGraph:!0,extensions:!0},ol=c.memo(al)}}),ll={};ih(ll,{MemoizedThreadGraphWorkspacePanel:()=>ol,ThreadGraphWorkspacePanel:()=>al});var yu=He({"src/workspace-panel.ts"(){wu()}});function cr(e,{insertAt:r}={}){if(!e||typeof document>"u")return;const n=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css",r==="top"&&n.firstChild?n.insertBefore(a,n.firstChild):n.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}cr(`.thread-ui-shell,
|
|
14
14
|
.thread-graph-dialog {
|
|
15
15
|
color-scheme: light;
|
|
16
16
|
--radius: 0.625rem;
|
|
@@ -3670,11 +3670,11 @@ import{l as $,R as Qi,I as ed,C as td,S as Os,H as rd,T as nd,a as ad,b as sd,c
|
|
|
3670
3670
|
padding: 1.5rem;
|
|
3671
3671
|
}
|
|
3672
3672
|
}
|
|
3673
|
-
`);function
|
|
3674
|
-
`)}function
|
|
3675
|
-
`).map(s=>s.trim()).filter(Boolean).find(s=>/^\[mcp_servers\.[^\]]+\]$/.test(s));if(!n)return null;const a=n.match(/^\[mcp_servers\.([A-Za-z0-9_-]+)\]$/);return(a==null?void 0:a[1])??null}function
|
|
3673
|
+
`);function ju(e){return e.replace(/\u00a0/g," ")}function Nu(e,r){if(!e)return[];const n=[],a=[...r].sort((l,i)=>i.placeholder.length-l.placeholder.length);let s=0,o=0;for(;s<e.length;){const l=a.find(h=>e.startsWith(h.placeholder,s));if(l){n.push({type:"attachment",key:`${l.clientId}-${s}`,attachment:l}),s+=l.placeholder.length;continue}let i=e.length;for(const h of a){const u=e.indexOf(h.placeholder,s);u!==-1&&u<i&&(i=u)}const d=e.slice(s,i);d&&(n.push({type:"text",key:`text-${o}`,text:d}),o+=1),s=i}return n}function Cu(e,r,n){const a=e==="photo"?"PHOTO":"FILE";let s=0;for(;;){const o=s===0?r:`${r} (${s+1})`,l=`[${a} ${o}]`;if(!n.has(l))return l;s+=1}}function Su(e,r,n){const a=r.start>0?e[r.start-1]:"",s=r.end<e.length?e[r.end]:"",o=!!(a&&!/\s/.test(a)),l=!s||!/\s/.test(s);return`${o?" ":""}${n.join(" ")}${l?" ":""}`}function Tu({files:e,kindForFile:r,usedPlaceholders:n,buildClientId:a}){return e.map(s=>{const o=r(s),l=Gu(s,o),i=Cu(o,Fu(l),n);return n.add(i),{clientId:a(),kind:o,originalName:l,placeholder:i,file:s}})}function Eu({prompt:e,attachments:r,files:n,selection:a,kindForFile:s,buildClientId:o}){const l=new Set(r.map(p=>p.placeholder)),i=Tu({files:n,kindForFile:s,usedPlaceholders:l,buildClientId:o}),d=a?{start:a.start,end:a.end}:{start:e.length,end:e.length},h=Su(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 Lu({prompt:e,attachments:r,isShellView:n}){if(n)return{prompt:e};const a=e.trim();if(!a)return null;const s=r.filter(o=>a.includes(o.placeholder));return s.length>0?{prompt:a,attachments:s}:{prompt:a}}function Iu({files:e,plainText:r,htmlText:n,htmlToText:a}){if(e.length>0)return{type:"append-files",preventDefault:!0,files:e};const s=r||a(n);return!s&&!n?{type:"ignore",preventDefault:!1}:{type:"insert-text",preventDefault:!0,text:s}}function as(e){return e?{type:"accept-files",preventDefault:!0,activateDragTarget:!0}:{type:"ignore",preventDefault:!1,activateDragTarget:!1}}function zu(e){return e.length>0?{type:"accept-files",preventDefault:!0,activateDragTarget:!0,files:e}:{type:"ignore",preventDefault:!1,activateDragTarget:!1}}function Pu({key:e,metaKey:r,ctrlKey:n,busy:a,disabled:s}){const o=e==="Enter"&&(r||n);return{preventDefault:o,submit:o&&!a&&!s}}function Ru({nextMode:e,previousOptimisticMode:r}){return{optimisticMode:e??null,rollbackMode:e?r:null,shouldRollbackMode:!!e,closeMenuOnSuccess:!0}}function $r(e){return`${e.prompt}${e.attachments.map(r=>`${r.clientId}${r.kind}${r.placeholder}${r.originalName}`).join("")}`}function ss(e){if(!e)return"Auto";switch(e){case"xhigh":return"xhigh";default:return e}}function Au(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 Mu(e){if(!e)return"";const r=e/1e3;return Number.isInteger(r)?String(r):String(Number(r.toFixed(1)))}function Vn(e){return e.replace(/\r\n/g,`
|
|
3674
|
+
`)}function _u(e){const r=e.trim();return/^[A-Za-z0-9_-]+$/.test(r)?r:null}function $u(e){const n=Vn(e).split(`
|
|
3675
|
+
`).map(s=>s.trim()).filter(Boolean).find(s=>/^\[mcp_servers\.[^\]]+\]$/.test(s));if(!n)return null;const a=n.match(/^\[mcp_servers\.([A-Za-z0-9_-]+)\]$/);return(a==null?void 0:a[1])??null}function Du(e,r){return`[mcp_servers.${e}]
|
|
3676
3676
|
url = ${JSON.stringify(r.trim())}
|
|
3677
|
-
`}function
|
|
3677
|
+
`}function os(e,r,n){var m,f;const a=Vn(e),s=`${Vn(n).trim()}
|
|
3678
3678
|
`,o=a.split(`
|
|
3679
3679
|
`),l=`[mcp_servers.${r}]`,i=`[mcp_servers.${r}.`;let d=-1,h=o.length;for(let p=0;p<o.length;p+=1)if((((m=o[p])==null?void 0:m.trim())??"")===l){d=p;break}if(d>=0){for(let k=d+1;k<o.length;k+=1){const w=((f=o[k])==null?void 0:f.trim())??"";if(w.startsWith("[")&&!(w===l||w.startsWith(i))){h=k;break}}const p=o.slice(0,d).join(`
|
|
3680
3680
|
`).trimEnd(),g=o.slice(h).join(`
|
|
@@ -3685,28 +3685,30 @@ url = ${JSON.stringify(r.trim())}
|
|
|
3685
3685
|
`).concat(`
|
|
3686
3686
|
`)}const u=a.trimEnd();return u?`${u}
|
|
3687
3687
|
|
|
3688
|
-
${s}`:s}function ol(e){return typeof e!="number"||Number.isNaN(e)?0:Math.max(0,Math.min(100,Math.round(e)))}function Sn(e){const r=e/1e3;return Number.isInteger(r)?`${r}k`:`${Number(r.toFixed(1))}k`}function Mu(e,r){if(!e)return"Select model";if((r==null?void 0:r.availability)!=="available"||typeof r.tokensInContextWindow!="number"||typeof r.modelContextWindow!="number")return`${e} · context unavailable`;const n=Math.max(r.tokensInContextWindow,0),a=Math.max(r.modelContextWindow,0),s=Math.max(a-n,0);return[e,`${Sn(n)} used / ${Sn(a)}`,`${Sn(s)} left`,`${ol(r.remainingPercent)}% context left`].join(" · ")}function $u(e,r){const n=e.name.trim();if(n)return n;const a=r==="photo"?e.type.includes("png")?".png":e.type.includes("heic")?".heic":e.type.includes("heif")?".heif":e.type.includes("webp")?".webp":".jpg":"";return`${r==="photo"?"photo":"file"}-${Date.now()}${a}`}function _u(e){return e.replace(/[\r\n[\]]+/g," ").replace(/\s+/g," ").trim()||"attachment"}function Un(e){return e.type.startsWith("image/")?"photo":"file"}function Vn(e,r){const n=[];if(e)for(const a of Array.from(e)){if(a.kind!=="file")continue;const s=a.getAsFile();s&&n.push(s)}return n.length>0?n:r?Array.from(r):[]}function ss(e,r){return Vn(e,r).length>0}function Du(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function os(e){const r=e.placeholder.match(/^\[(?:PHOTO|FILE)\s+(.+)\]$/);return r!=null&&r[1]?r[1]:Du(e.originalName)}var Zr=[{value:"preToolUse",label:"PreToolUse",matcherHint:"Bash"},{value:"permissionRequest",label:"PermissionRequest",matcherHint:"Bash"},{value:"postToolUse",label:"PostToolUse",matcherHint:"Bash"},{value:"sessionStart",label:"SessionStart",matcherHint:"startup|resume"},{value:"userPromptSubmit",label:"UserPromptSubmit",matcherHint:""},{value:"stop",label:"Stop",matcherHint:""},{value:"preCompact",label:"PreCompact",matcherHint:""},{value:"postCompact",label:"PostCompact",matcherHint:""}];function Bu({goalComposeMode:e,goalBusy:r,threadConnected:n,busy:a,isShellView:s,disabledPlaceholder:o,settingsBusy:l,supportedEffortCount:i,fastMode:d}){const h=e?"Describe the goal the backend should continue working toward...":o??(s?"Send shell input to the attached terminal...":"Ask the backend to inspect, modify, or explain code..."),u=e?r?"Setting...":"Set goal":!n&&a?"Connecting...":n&&a&&!s?"Sending...":"Send",m=n?e?"ui-action-info":"ui-action-primary":"ui-action-danger",f=l;return{promptPlaceholder:h,interruptLabel:s?"Send Ctrl-C":"Stop Current Turn",sendButtonLabel:u,sendButtonClassName:m,modelControlsDisabled:f,effortControlsDisabled:f||i===0,effortControlTitle:d?"Fast mode is on. Turn it off from the slash toolbox to edit reasoning.":i===0?"The selected model does not expose adjustable reasoning effort.":"Select reasoning effort"}}function Gu({isShellView:e,edgeToEdgeMobile:r,isMobileShell:n,openMenu:a,isDragTargetActive:s,busy:o}){const l=e?"thread-composer-layer thread-shell-composer-layer":"thread-graph-composer-layer",i=e?"thread-composer-form":"thread-graph-composer-form",d=e?"thread-composer-form-floating":"thread-graph-composer-form-floating",h=e?"thread-composer-input":"thread-graph-composer-input";return{composerLayerClassName:a?`${l} relative z-[80] shrink-0`:`${l} relative z-20 shrink-0`,formClassName:e?r||n?`${i} ${d} relative z-20 shrink-0 border-t border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`:`${i} relative z-20 shrink-0 border-t border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`:`${i} ${r?d:""} relative z-20 shrink-0 border-t px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`,composerShellClassName:e?"thread-composer-shell":"thread-graph-composer-shell",composerToolbarClassName:e?"thread-composer-toolbar":"thread-graph-composer-toolbar",composerInputClassName:h,composerIconButtonClassName:e?"thread-composer-icon-button":"thread-graph-composer-icon-button",composerMenuClassName:e?"thread-composer-menu":"thread-graph-composer-menu",composerMenuItemClassName:e?"thread-composer-menu-item":"thread-graph-composer-menu-item",composerInlineToggleClassName:e?"thread-composer-inline-toggle":"thread-graph-composer-inline-toggle",composerPanelButtonClassName:e?"thread-composer-panel-button":"thread-graph-composer-panel-button",composerChipButtonClassName:e?"thread-composer-chip-button":"thread-graph-composer-chip-button",composerPlanToggleActiveClassName:e?"thread-composer-plan-toggle-active":"thread-graph-composer-plan-toggle-active",composerSendButtonClassName:e?"thread-composer-send-button":"thread-graph-composer-send-button",composerPromptRegionClassName:e?"thread-composer-prompt-region":"thread-graph-composer-prompt-region",promptInputClassName:`${h} min-h-[5.25rem] w-full px-4 pr-14 pt-3 outline-none transition sm:min-h-[5.75rem] ${s?"is-drag-target border-sky-300/80 bg-sky-300/[0.08] shadow-[0_0_0_1px_rgba(125,211,252,0.2)]":""}`,graphChatInputGroupClassName:`thread-graph-composer-input-group relative border-0 bg-transparent shadow-none ring-0 ${o?"bg-amber-50/40 dark:bg-amber-400/10":"bg-transparent"}`,graphChatInputClassName:`${h} min-h-[68px] max-h-32 w-full overflow-y-auto px-3 pt-3 text-[16px] leading-relaxed text-slate-800 outline-none transition sm:min-h-[92px] sm:max-h-40 sm:px-4 sm:pt-4 sm:text-[14px] dark:text-slate-100 ${s?"is-drag-target bg-sky-300/[0.08] shadow-[0_0_0_1px_rgba(125,211,252,0.2)]":""}`}}function Fu(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"m4 5 2 2-2 2"}),t.jsx("path",{d:"M7.75 9.5h4.25"})]})}function Hu(){return t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",children:t.jsx("path",{d:"M8 3.25v9.5M3.25 8h9.5"})})}function Ou(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M10.75 2.5 5.25 13.5"}),t.jsx("path",{d:"M4.25 5.25h2.25"}),t.jsx("path",{d:"M9.5 10.75h2.25"})]})}function Wu(){return t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3 4.5A1.75 1.75 0 0 1 4.75 2.75h6.5A1.75 1.75 0 0 1 13 4.5v4A1.75 1.75 0 0 1 11.25 10.25H8l-2.75 2v-2H4.75A1.75 1.75 0 0 1 3 8.5v-4Z"})})}function Uu(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",className:"h-3.5 w-3.5 fill-current",children:[t.jsx("path",{fillRule:"evenodd",d:"M14.5 10C16.9853 10 19 7.98528 19 5.5C19 5.01783 18.9242 4.55338 18.7838 4.11791C18.6792 3.79367 18.2734 3.72683 18.0325 3.96772L15.3402 6.66002C15.2098 6.79041 15.0168 6.84163 14.8466 6.77074C14.1172 6.46695 13.5334 5.88351 13.2292 5.15431C13.1582 4.98403 13.2094 4.79088 13.3398 4.66042L16.0327 1.9676C16.2735 1.72672 16.2067 1.32092 15.8825 1.21636C15.4469 1.07588 14.9823 1 14.5 1C12.0147 1 10 3.01472 10 5.5C10 5.59783 10.0031 5.69494 10.0093 5.79122C10.065 6.66418 9.88174 7.59855 9.20974 8.15855L1.98017 14.1832C1.3591 14.7008 1 15.4674 1 16.2759C1 17.7804 2.21962 19 3.7241 19C4.53256 19 5.29925 18.6409 5.81681 18.0198L11.8414 10.7903C12.4014 10.1183 13.3358 9.93497 14.2088 9.99073C14.3051 9.99688 14.4022 10 14.5 10ZM5 16C5 16.5523 4.55228 17 4 17C3.44772 17 3 16.5523 3 16C3 15.4477 3.44772 15 4 15C4.55228 15 5 15.4477 5 16Z",clipRule:"evenodd"}),t.jsx("path",{d:"M14.5 11.5C14.6731 11.5 14.8445 11.4927 15.0138 11.4783L18.7678 15.2323C19.7441 16.2086 19.7441 17.7915 18.7678 18.7678C17.7915 19.7441 16.2086 19.7441 15.2323 18.7678L10.8216 14.3571L12.9938 11.7505C13.0455 11.6885 13.1413 11.6131 13.3357 11.5552C13.5378 11.4951 13.805 11.468 14.1132 11.4877C14.2413 11.4959 14.3702 11.5 14.5 11.5Z"}),t.jsx("path",{d:"M6.00003 4.58582L8.33056 6.91635C8.3027 6.95627 8.27496 6.98497 8.24946 7.00622L6.79994 8.21415L4.58582 6.00003H3.30905C3.11966 6.00003 2.94653 5.89303 2.86184 5.72364L1.1612 2.32237C1.06495 2.12987 1.10268 1.89739 1.25486 1.74521L1.74521 1.25486C1.89739 1.10268 2.12987 1.06495 2.32237 1.1612L5.72364 2.86184C5.89303 2.94653 6.00003 3.11966 6.00003 3.30905V4.58582Z"})]})}function qn(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5.5 3.25h5"}),t.jsx("path",{d:"M6.4 2h3.2a.9.9 0 0 1 .9.9v.35h1.3a1.2 1.2 0 0 1 1.2 1.2v7.35a1.2 1.2 0 0 1-1.2 1.2H4.2A1.2 1.2 0 0 1 3 11.8V4.45a1.2 1.2 0 0 1 1.2-1.2h1.3V2.9a.9.9 0 0 1 .9-.9Z"})]})}function Vu(e){switch(e){case"bearerToken":return"Token";case"oAuth":return"OAuth";case"notLoggedIn":return"Login";case"unsupported":return"Public";default:return"Unknown"}}function qu(e){switch(e){case"repo":return"Repo";case"system":return"System";case"admin":return"Admin";case"user":default:return"User"}}function Ku(e){var r;return((r=Zr.find(n=>n.value===e))==null?void 0:r.label)??e}function Xu(e){var r;switch(e){case"cloudRequirements":return"Cloud";case"legacyManagedConfigFile":case"legacyManagedConfigMdm":return"Managed";case"sessionFlags":return"Session";default:return((r=e[0])==null?void 0:r.toUpperCase())+e.slice(1)}}function Yu(e){switch(e){case"managed":return"Managed";case"modified":return"Modified";case"trusted":return"Trusted";case"untrusted":return"Review"}}function Zu(e){switch(e){case"preToolUse":return"PreToolUse";case"permissionRequest":return"PermissionRequest";case"postToolUse":return"PostToolUse";case"preCompact":return"PreCompact";case"postCompact":return"PostCompact";case"sessionStart":return"SessionStart";case"userPromptSubmit":return"UserPromptSubmit";case"stop":return"Stop"}}function Ju(e){return e.source==="user"?"global":e.source==="project"?"project":null}function ll(e){const r=Ju(e);return!r||e.handlerType!=="command"||!e.command||e.isManaged?null:{scope:r,eventName:e.eventName,matcher:e.matcher,command:e.command,timeoutSec:e.timeoutSec,statusMessage:e.statusMessage}}function Qu(e){switch(e){case"active":return"Active";case"paused":return"Paused";case"budgetLimited":return"Budget";case"complete":return"Complete";default:return e}}function em({contextUsage:e}){const r=(e==null?void 0:e.availability)??"unavailable",n=ol(e==null?void 0:e.remainingPercent);if(r!=="available")return null;const a=n<=20?"rgba(251,113,133,0.90)":n<=40?"rgba(252,211,77,0.85)":"rgba(125,211,252,0.80)";return t.jsx("span",{"aria-hidden":"true",className:"thread-context-progress-track pointer-events-none mt-0.5 block",children:t.jsx("span",{className:"thread-context-progress-fill block",style:{width:`${n}%`,backgroundColor:a}})})}function Bt({label:e,tone:r="stone"}){const n=r==="rose"?"border-rose-300/35 bg-rose-300/14 text-rose-50":r==="sky"?"border-sky-300/35 bg-sky-300/14 text-sky-50":"border-stone-700/90 bg-stone-900/80 text-stone-100";return t.jsx("span",{className:`inline-flex min-w-[3rem] items-center justify-center rounded-full border px-2 py-1.5 text-[10px] font-medium tracking-[0.12em] ${n}`,children:e})}function tm(e,r){return(e??[]).filter(n=>{switch(n.action){case"fast":return r.fast;case"compact":return r.compact;case"goal":return r.goal;case"fork":return r.fork;case"skills":return r.skills;case"mcp":return r.mcp;case"hooks":return r.hooks;case"prompt":case"unsupported":return!0;default:return!1}})}function rm(e,{fastMode:r,goalComposeMode:n}){switch(e.action){case"fast":return{type:"toggleFast",fastMode:!r};case"compact":return{type:"runCompact"};case"goal":return n?{type:"exitGoalCompose"}:{type:"enterGoalCompose"};case"fork":case"skills":case"mcp":case"hooks":return{type:"openPanel",panel:e.action};case"prompt":return{type:"insertPrompt",text:`${e.command} `};default:return{type:"noop"}}}function nm(e,{fastMode:r,compactBusy:n,goalComposeMode:a,goalStatus:s,busy:o}){switch(e.action){case"fast":return r?"On":"Off";case"compact":return n?"Busy":"Run";case"goal":return a?"Composing":s?Qu(s):"Open";case"fork":return o?"Idle only":"Open";case"skills":case"mcp":case"hooks":return"View";case"prompt":return"Compose";case"unsupported":return"Unavailable";default:return""}}function am(e,{settingsBusy:r,compactBusy:n,busy:a,forkBusy:s}){switch(e.action){case"fast":return r;case"compact":return n||a;case"fork":return a||s;case"unsupported":return!0;default:return!1}}function sm(e,{fastMode:r,goalComposeMode:n,goalStatus:a,menuItemClassName:s}){return`${e.action==="fast"&&r||e.action==="goal"&&(n||a==="active")?"ui-status-warning":s} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`}function om(e){if(!e)return"";const r=document.createElement("div");return r.innerHTML=e,r.textContent??""}function lm(e){return!!e.querySelector("[style], font")}function Ht(e){return e instanceof HTMLElement&&e.dataset.segmentType==="attachment"&&e.dataset.placeholder?e.dataset.placeholder:e.textContent??""}function il(e){let r="";for(const n of Array.from(e.childNodes))r+=Ht(n);return r.replace(/\u00a0/g," ")}function ls(e,r,n){var i;let a=null,s=n;if(r===e){const d=Array.from(e.childNodes);let h=0;for(let u=0;u<Math.min(n,d.length);u+=1){const m=d[u];m&&(h+=Ht(m).length)}return h}if(r.nodeType===Node.TEXT_NODE)a=r;else{const d=Array.from(e.childNodes).find(h=>h.contains(r));if(!d)return il(e).length;if(a=d,d instanceof HTMLElement&&d.dataset.segmentType==="attachment"){const h=document.createRange();h.selectNodeContents(d);const u=Ht(d).length;try{h.setEnd(r,n);const m=h.toString().length,f=((i=d.textContent)==null?void 0:i.length)??0;f===0?s=u:s=Math.round(Math.min(1,m/f)*u)}catch{s=u}}else{const h=document.createRange();h.selectNodeContents(d);try{h.setEnd(r,n),s=h.toString().length}catch{s=Ht(d).length}}}const o=Array.from(e.childNodes);let l=0;for(const d of o){if(d===a)return d.nodeType===Node.TEXT_NODE?l+s:l+Math.min(s,Ht(d).length);l+=Ht(d).length}return l}function im(e){const r=window.getSelection();if(!r||r.rangeCount===0)return null;const n=r.getRangeAt(0);return!e.contains(n.startContainer)||!e.contains(n.endContainer)?null:{start:ls(e,n.startContainer,n.startOffset),end:ls(e,n.endContainer,n.endOffset)}}function is(e,r){let n=Math.max(0,r);const a=Array.from(e.childNodes);for(const[s,o]of a.entries()){const i=Ht(o).length;if(o.nodeType===Node.TEXT_NODE){if(n<=i)return{node:o,offset:n};n-=i;continue}if(o instanceof HTMLElement&&o.dataset.segmentType==="attachment"){if(n===0)return{node:e,offset:s};if(n<=i){const d=a[s+1];return n===i&&(d==null?void 0:d.nodeType)===Node.TEXT_NODE?{node:d,offset:0}:{node:e,offset:s+1}}n-=i;continue}if(n<=i)return{node:e,offset:s+1};n-=i}return{node:e,offset:e.childNodes.length}}function dm(e,r){const n=is(e,r.start),a=is(e,r.end),s=document.createRange();s.setStart(n.node,n.offset),s.setEnd(a.node,a.offset);const o=window.getSelection();o==null||o.removeAllRanges(),o==null||o.addRange(s)}function cm(e,r){if(r.length===0)return!1;const n=r.at(-1);if(!n)return!1;const a=Array.from(e.childNodes).find(i=>i instanceof HTMLElement&&i.dataset.segmentType==="attachment"&&i.dataset.clientId===n);if(!(a instanceof HTMLElement))return!1;const s=document.createRange(),o=a.nextSibling;(o==null?void 0:o.nodeType)===Node.TEXT_NODE?s.setStart(o,0):s.setStartAfter(a),s.collapse(!0);const l=window.getSelection();return l==null||l.removeAllRanges(),l==null||l.addRange(s),!0}sn();Pt();function hm({className:e,...r}){return t.jsx("div",{"data-slot":"input-group",role:"group",className:at("group/input-group relative flex w-full min-w-0 items-center rounded-md border shadow-xs outline-none transition-[color,box-shadow]","h-9 has-[>textarea]:h-auto","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col",e),...r})}var um=Er("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*=size-])]:size-4",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.45rem]","block-start":"order-first w-full justify-start px-3 pt-3","block-end":"order-last w-full justify-start px-3 pb-3"}},defaultVariants:{align:"inline-start"}});function mm({className:e,align:r="inline-start",...n}){return t.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":r,className:at(um({align:r}),e),onClick:a=>{var o;if(a.target.closest("button"))return;const s=(o=a.currentTarget.parentElement)==null?void 0:o.querySelector('[data-slot="input-group-control"] [contenteditable="true"], [data-slot="input-group-control"] textarea, [data-slot="input-group-control"] input, [data-slot="input-group-control"]');s==null||s.focus()},...n})}var pm=Er("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*=size-])]:size-3.5",sm:"h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function Ct({className:e,type:r="button",variant:n="ghost",size:a="xs",...s}){return t.jsx(Tr,{type:r,"data-size":a,variant:n,className:at(pm({size:a}),e),...s})}function fm({className:e,...r}){return t.jsx("span",{className:at("flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*=size-])]:size-4",e),...r})}function gm({photoInputRef:e,fileInputRef:r,onAppendAttachments:n}){function a(s,o){n(s.target.files,o),s.target.value=""}return t.jsxs(t.Fragment,{children:[t.jsx("input",{ref:e,type:"file",accept:"image/*",multiple:!0,tabIndex:-1,className:"sr-only",onChange:s=>a(s,"photo")}),t.jsx("input",{ref:r,type:"file",multiple:!0,tabIndex:-1,className:"sr-only",onChange:s=>a(s,"file")})]})}function xm(e){if(!e)return"reset time unavailable";const r=new Date(e);return Number.isNaN(r.getTime())?"reset time unavailable":`resets ${r.toLocaleString()}`}function bm({usage:e}){const[r,n]=c.useState(!1);if(!e||e.authKind!=="subscription"||e.windows.length===0)return null;const a=e.windows.slice(0,2),s=a.map(o=>{const l=Math.max(0,100-o.usedPercent);return`${o.label}: ${l}% remaining, ${xm(o.resetsAt)}`}).join(". ");return t.jsxs("button",{type:"button",className:`thread-subscription-usage group pointer-events-auto absolute bottom-0 right-2 inline-flex h-4 items-center gap-1 rounded-t-md border border-b-0 border-stone-500/50 bg-stone-950 px-1 text-[7px] font-normal leading-none text-stone-200 shadow-sm transition-[border-color,background-color,opacity] duration-200 hover:border-stone-400/75 hover:bg-stone-900 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-sky-200/70 sm:right-3 sm:text-[7px] ${e.stale?"opacity-70":"opacity-95"}`,"aria-label":`${e.provider} subscription usage. ${s}`,"aria-expanded":r,onClick:()=>n(o=>!o),children:[a.map(o=>{const l=Math.max(0,Math.min(100,100-o.usedPercent)),i=Math.round(18+l/100*190);return t.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[t.jsx("span",{className:"font-normal tracking-[-0.01em]",children:o.label}),t.jsx("span",{"data-subscription-window-track":"true",className:"h-0.5 w-7 overflow-hidden rounded-full bg-stone-600/55 sm:w-9",children:t.jsx("span",{className:"block h-full rounded-full transition-[width] duration-500 ease-out",style:{width:`${l}%`,backgroundImage:`linear-gradient(90deg, oklch(68% 0.17 ${i}), oklch(82% 0.13 ${Math.min(i+18,235)}))`}})})]},o.id)}),t.jsxs("span",{"aria-hidden":!r,className:`pointer-events-none absolute right-0 bottom-full mb-1 whitespace-nowrap rounded-md border border-stone-600/65 bg-stone-950/95 px-1.5 py-1 text-[9px] font-normal leading-none text-stone-100 shadow-lg transition-[opacity,transform] duration-200 group-hover:translate-y-0 group-hover:opacity-100 group-focus-visible:translate-y-0 group-focus-visible:opacity-100 ${r?"translate-y-0 opacity-100":"translate-y-0.5 opacity-0"}`,children:[a.map((o,l)=>t.jsxs("span",{children:[l>0?" · ":"",o.label," ",Math.round(100-o.usedPercent),"%"]},o.id)),e.stale?" · last known":""]})]})}function vm({activeView:e,followTail:r,onToggleFollow:n,canJumpToPreviousTurn:a,onJumpToPreviousTurn:s,canJumpToNextTurn:o,onJumpToNextTurn:l,subscriptionUsage:i}){return e!=="chat"?null:t.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-[90] h-11 -translate-y-full bg-transparent touch-manipulation sm:h-10",children:[t.jsxs("span",{role:"group","aria-label":"Timeline navigation",className:`thread-jump-latest-badge pointer-events-auto absolute bottom-1 left-1/2 inline-flex h-5 min-w-[7.5rem] -translate-x-1/2 overflow-hidden rounded-[0.7rem] border shadow-sm transition ${r?"is-active border-sky-300/36 bg-sky-300/[0.03] text-sky-100/86":"border-stone-500/70 bg-stone-950/[0.08] text-stone-200/86"}`,children:[t.jsx("button",{type:"button","aria-label":"Jump to previous turn",title:a?"Jump to the start of the previous turn":"No earlier turn",disabled:!a,onClick:()=>s==null?void 0:s(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70 disabled:cursor-default disabled:opacity-35",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3.5 12h9M8 10V5M6 7l2-2 2 2"})})}),t.jsx("span",{"aria-hidden":"true",className:"w-px bg-current opacity-20"}),t.jsx("button",{type:"button","aria-label":"Jump to latest",title:r?"Latest messages are in view":"Jump to the bottom",onClick:()=>n==null?void 0:n(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m4 5.5 4 4 4-4M3.5 12.5h9"})})}),t.jsx("span",{"aria-hidden":"true",className:"w-px bg-current opacity-20"}),t.jsx("button",{type:"button","aria-label":"Jump to next turn",title:o?"Jump to the start of the next turn":"No later turn",disabled:!o,onClick:()=>l==null?void 0:l(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70 disabled:cursor-default disabled:opacity-35",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3.5 4h9M8 6v5m-2-2 2 2 2-2"})})})]}),t.jsx(bm,{usage:i})]})}function km({activeView:e,layerClassName:r,formClassName:n,shellClassName:a,inputGroupClassName:s,error:o,followTail:l,photoInputRef:i,fileInputRef:d,onAppendAttachments:h,onToggleFollow:u,canJumpToPreviousTurn:m,onJumpToPreviousTurn:f,canJumpToNextTurn:p,onJumpToNextTurn:g,subscriptionUsage:k,onSubmit:w,formRef:x,promptSlot:j,pendingQueueSlot:y,toolbarSlot:b,goalSlot:v,shellPromptSlot:S}){return t.jsxs("div",{className:r,children:[t.jsx(gm,{photoInputRef:i,fileInputRef:d,onAppendAttachments:h}),t.jsx(vm,{activeView:e,followTail:l,onToggleFollow:u,canJumpToPreviousTurn:m,onJumpToPreviousTurn:f,canJumpToNextTurn:p,onJumpToNextTurn:g,subscriptionUsage:k}),y,t.jsxs("form",{ref:x,"data-testid":e==="chat"?"chat-composer":void 0,onSubmit:w,className:n,children:[t.jsxs("div",{className:`${a} flex w-full flex-col overflow-visible rounded-[16px] sm:rounded-[18px]`,children:[t.jsxs(hm,{className:s,children:[j,b]}),v,S]}),o?t.jsx("div",{className:"mt-2 rounded-2xl border border-rose-500/40 bg-rose-500/10 px-4 py-3 text-sm text-rose-200",children:o}):null]})]})}function wm({prompts:e,onSteer:r,onCancel:n}){const[a,s]=c.useState(()=>new Set);async function o(l,i){if(!(!i||a.has(l))){s(d=>new Set(d).add(l));try{await i(l)}catch{}finally{s(d=>{const h=new Set(d);return h.delete(l),h})}}}return t.jsxs("section",{"aria-label":"Queued prompts",className:"thread-composer-pending-queue mx-auto mb-2 w-full max-w-4xl overflow-hidden rounded-xl border",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 text-[11px] font-medium text-[var(--theme-fg-muted)]",children:[t.jsx("span",{children:"Queued"}),t.jsx("span",{children:e.length})]}),t.jsx("div",{className:"max-h-36 overflow-y-auto",children:e.map(l=>{const i=a.has(l.id);return t.jsxs("div",{className:"thread-composer-pending-row flex min-h-10 items-center gap-2 border-t px-3 py-2",children:[t.jsx("p",{className:"min-w-0 flex-1 truncate text-sm text-[var(--theme-fg)]",title:l.prompt,children:l.prompt}),l.optimistic?t.jsxs("span",{className:"inline-flex h-8 items-center gap-1.5 px-1.5 text-xs text-[var(--theme-fg-muted)]",children:[t.jsx($.Loader2,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":"true"}),"Queueing"]}):t.jsxs(t.Fragment,{children:[r?t.jsxs("button",{type:"button",disabled:i,onClick:()=>void o(l.id,r),className:"thread-composer-steer-button inline-flex h-8 items-center gap-1.5 rounded-lg border px-2.5 text-xs font-medium transition disabled:cursor-wait disabled:opacity-60",children:[i?t.jsx($.Loader2,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":"true"}):t.jsx($.CornerUpRight,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Steer"]}):null,n?t.jsx("button",{type:"button",disabled:i,"aria-label":"Remove queued prompt",title:"Remove from queue",onClick:()=>void o(l.id,n),className:"thread-composer-queue-remove inline-flex h-8 w-8 items-center justify-center rounded-lg transition disabled:cursor-wait disabled:opacity-60",children:t.jsx($.X,{className:"h-4 w-4","aria-hidden":"true"})}):null]})]},l.id)})})]})}function ym({open:e,iconButtonClassName:r,menuClassName:n,menuItemClassName:a,onToggle:s,onPickPhoto:o,onPickFile:l}){return t.jsxs("div",{className:"relative",children:[t.jsx(Ct,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Add attachment",title:"Add attachment",onClick:s,className:`${r} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx(Hu,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${n} absolute bottom-full left-0 mb-2 w-32 overflow-hidden rounded-2xl border bg-stone-900/72 shadow-2xl shadow-stone-950/20`,children:t.jsxs("div",{className:"p-2",children:[t.jsx("button",{type:"button",onClick:o,className:`${a} block w-full rounded-xl px-3 py-2 text-left text-sm transition`,children:"Photo"}),t.jsx("button",{type:"button",onClick:l,className:`${a} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition`,children:"File"})]})})]})}var dl=[{mode:"read-only",label:"Read only"},{mode:"workspace-write",label:"Workspace write"},{mode:"danger-full-access",label:"Danger"}];function ds(e){var r;return((r=dl.find(n=>n.mode===e))==null?void 0:r.label)??"Default"}function jm({openMenu:e,model:r,modelOptions:n,modelContextTitle:a,contextUsage:s,reasoningEffort:o,supportedEfforts:l,displayedCollaborationMode:i,sandboxMode:d,planModeAvailable:h,sandboxModeAvailable:u,settingsBusy:m,goalComposeMode:f,goalBusy:p,activeView:g,disabled:k,fastMode:w,sendButtonLabel:x,sendButtonClassName:j,modelControlsDisabled:y,effortControlsDisabled:b,effortControlTitle:v,inlineToggleClassName:S,menuItemClassName:N,planToggleActiveClassName:L,sendButtonBaseClassName:R,onSetOpenMenu:P,onUpdateSettings:Q}){return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative min-w-0",children:[t.jsx(Ct,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="model","aria-label":r??"Select model",disabled:y||n.length===0,onClick:()=>P(D=>D==="model"?null:"model"),title:w?`Fast mode is on. Turn it off from the slash toolbox to edit model. ${a}`:a,className:`${S} relative min-w-0 max-w-[8.75rem] overflow-hidden rounded-full px-2.5 text-left text-stone-300 disabled:cursor-not-allowed disabled:text-stone-600 sm:max-w-[11rem]`,children:t.jsx("span",{className:"relative z-[1] block min-w-0 truncate whitespace-nowrap [direction:rtl]",children:r??"Select model"})}),r?t.jsx(em,{contextUsage:s}):null,e==="model"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[9rem] max-w-[14rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:n.map(D=>t.jsx("button",{type:"button",onClick:()=>Q({model:D.model,reasoningEffort:D.defaultReasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${D.model===r?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:D.model})},D.id))})})]}),t.jsxs("div",{className:"relative",children:[t.jsx(Ct,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="effort",disabled:b,onClick:()=>P(D=>D==="effort"?null:"effort"),title:v,className:`${S} rounded-full px-2 disabled:cursor-not-allowed disabled:text-stone-700 ${b?"text-stone-500":"text-stone-300 hover:text-stone-100"}`,children:ns(o)}),e==="effort"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[8rem] max-w-[12rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:l.map(D=>t.jsx("button",{type:"button",onClick:()=>Q({reasoningEffort:D.reasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${D.reasoningEffort===o?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:ns(D.reasoningEffort)})},D.reasoningEffort))})})]}),u&&t.jsxs("div",{className:"relative",children:[t.jsx(Ct,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="sandbox","aria-label":`Sandbox: ${ds(d)}`,disabled:m,onClick:()=>P(D=>D==="sandbox"?null:"sandbox"),title:`Sandbox: ${ds(d)}`,className:`${S} rounded-full px-2.5 text-stone-300 disabled:cursor-not-allowed disabled:text-stone-700`,children:"Sandbox"}),e==="sandbox"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[9rem] max-w-[13rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:dl.map(D=>t.jsx("button",{type:"button",onClick:()=>Q({sandboxMode:D.mode}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${D.mode===d?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:D.label})},D.mode))})})]}),h&&t.jsx(Ct,{type:"button",variant:"ghost",size:"xs","aria-pressed":i==="plan",disabled:m,onClick:()=>Q({collaborationMode:i==="plan"?"default":"plan"}),className:`${S} rounded-full px-2.5 ${i==="plan"?`${L} border !border-[oklch(0.78_0.16_86_/_0.76)] !bg-[oklch(0.44_0.095_82_/_0.72)] !text-[oklch(0.96_0.055_92)] shadow-[0_0_0_1px_oklch(0.78_0.16_86_/_0.24),0_0_18px_oklch(0.78_0.16_86_/_0.42),inset_0_0_0_1px_oklch(0.98_0.04_96_/_0.18)]`:"text-stone-500"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Plan"}),t.jsx(Ct,{type:"submit",variant:"default",size:"icon-xs","aria-label":f?"Set goal":"Send Prompt",title:x,disabled:p||(g==="chat"?k:!1),className:`${R} h-9 w-9 rounded-full text-sm font-medium disabled:cursor-not-allowed sm:h-8 sm:w-8 ${j}`,children:t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-none stroke-current",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M8 13V3"}),t.jsx("path",{d:"m4 7 4-4 4 4"})]})})]})}function Nm({busy:e,shellControlState:r,onPaste:n,onCopy:a,onClear:s,onShellControl:o}){const l=!!(r!=null&&r.shellInputEnabled),i=!!(r!=null&&r.isCommandRunning);return t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute right-0 top-full z-40 mt-2 w-[11.5rem] max-w-[calc(100vw-1.5rem)] rounded-[1rem] border border-stone-700/90 bg-stone-950/96 p-2 shadow-2xl shadow-stone-950/40 sm:w-48",onMouseDown:d=>{d.stopPropagation()},onPointerDown:d=>{d.stopPropagation()},onTouchStart:d=>{d.stopPropagation()},children:t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx("button",{type:"button",onClick:n,className:"inline-flex items-center justify-center rounded-full border border-sky-300/35 bg-sky-300/12 px-2 py-2 text-sky-50",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(qn,{}),t.jsx("span",{className:"text-[10px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:a,className:"inline-flex items-center justify-center rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-2 text-stone-100",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(qn,{}),t.jsx("span",{className:"text-[10px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:e,onClick:s,className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!l||!i,onClick:()=>o("ctrl_c"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CTRL-C",tone:"rose"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("ctrl_d"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CTRL-D"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("esc"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"ESC"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("tab"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"TAB"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("up"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"UP"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("down"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"DOWN"})})]})})}function Cm({busy:e,forkBusy:r,composerMenuItemClassName:n,onForkLatest:a,onSelectForkTurnPanel:s}){return t.jsxs("div",{className:"p-2",children:[t.jsx("button",{type:"button",disabled:e||r,onClick:()=>void a(),className:`${n} block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:"Fork from latest"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:r?"Forking":"Run"})]})}),t.jsx("button",{type:"button",disabled:e||r,onClick:o=>{o.stopPropagation(),s()},className:`${n} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:"Fork from selected turn"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:"Pick"})]})}),e?t.jsx("p",{className:"mt-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Fork is only available while the thread is idle."}):null]})}function Sm({forkTurnOptionsState:e,forkBusy:r,composerPanelButtonClassName:n,onForkTurn:a}){var s,o;return t.jsxs("div",{className:"p-2",children:[e.status==="loading"&&!e.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading turns..."}):null,e.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:e.error}):null,(s=e.data)!=null&&s.length?t.jsx("div",{className:"space-y-2",children:e.data.map(l=>t.jsx("button",{type:"button",disabled:r,onClick:()=>void a(l.turnId),className:`${n} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("span",{className:"text-sm text-stone-100",children:["Turn ",l.turnIndex]}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:r?"Forking":l.status})]})},l.turnId))}):null,e.status!=="loading"&&!e.error&&(((o=e.data)==null?void 0:o.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No turns available to fork yet."}):null]})}function Tm({hooksPanelMode:e,hooksState:r,hostConfigFilesAvailable:n,hookTrustAvailable:a,hookConfigBusy:s,hookConfigError:o,hookConfigSuccess:l,editingHookTarget:i,hookScope:d,hookEventName:h,hookMatcher:u,hookCommand:m,hookTimeoutSec:f,hookStatusMessage:p,composerChipButtonClassName:g,onResetHookForm:k,onSetHooksPanelMode:w,onClearHookConfigStatus:x,onSetEditingHookTarget:j,onSetHookScope:y,onSetHookEventName:b,onSetHookMatcher:v,onSetHookCommand:S,onSetHookTimeoutSec:N,onSetHookStatusMessage:L,onSaveHook:R,onStartEditingHook:P,onTrustHook:Q,onUntrustHook:D}){var Z,J,z,te,se;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"Hook config sources"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:((Z=r.data)==null?void 0:Z.projectHooksPath)??"<workspace hooks config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:_=>{_.stopPropagation(),k(),w("add"),x()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add Hook"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading hooks..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,o?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:o}):null,l?t.jsx("p",{className:"mb-2 rounded-xl border border-emerald-500/35 bg-emerald-500/10 px-3 py-3 text-sm text-emerald-100/90",children:l}):null,e==="add"||e==="edit"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[e==="edit"?t.jsxs("p",{className:"rounded-lg border border-stone-800 bg-stone-950 px-3 py-2 text-[11px] text-stone-400",children:["Editing"," ",Zu((i==null?void 0:i.eventName)??h)," ","in ",(i==null?void 0:i.scope)==="global"?"global":"project"," ","hooks.json"]}):null,t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("label",{className:"block text-xs text-stone-400",children:["Scope",t.jsxs("select",{"aria-label":"Hook scope",value:d,onChange:_=>y(_.target.value),disabled:e==="edit",className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-2.5 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50",children:[t.jsx("option",{value:"project",children:"Project"}),t.jsx("option",{value:"global",children:"Global"})]})]}),t.jsxs("label",{className:"block text-xs text-stone-400",children:["Event",t.jsx("select",{"aria-label":"Hook event",value:h,onChange:_=>b(_.target.value),className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-2.5 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50",children:Zr.map(_=>t.jsx("option",{value:_.value,children:_.label},_.value))})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"Matcher"}),t.jsx("input",{"aria-label":"Hook matcher",value:u,onChange:_=>v(_.target.value),placeholder:"Bash",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"Command"}),t.jsx("textarea",{"aria-label":"Hook command",value:m,onChange:_=>S(_.target.value),rows:3,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 font-mono text-xs text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("label",{className:"block text-xs text-stone-400",children:["Timeout",t.jsx("input",{"aria-label":"Hook timeout seconds",value:f,onChange:_=>N(_.target.value),inputMode:"numeric",className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50"})]}),t.jsxs("label",{className:"block text-xs text-stone-400",children:["Status message",t.jsx("input",{"aria-label":"Hook status message",value:p,onChange:_=>L(_.target.value),className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50"})]})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>{w("list"),j(null)},className:`${g} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void R(),disabled:s,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:s?"Saving...":e==="edit"?"Update Hook":"Write Hook"})]})]}):null,e==="list"&&((J=r.data)!=null&&J.warnings.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.warnings.map(_=>t.jsx("p",{className:"rounded-xl border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-100/85",children:_},_))}):null,e==="list"&&((z=r.data)!=null&&z.errors.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.errors.map(_=>t.jsxs("div",{className:"rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-2 text-xs text-rose-100/90",children:[t.jsx("p",{className:"font-medium",children:_.message}),t.jsx("p",{className:"mt-1 break-all text-rose-100/60",children:_.path})]},`${_.path}:${_.message}`))}):null,e==="list"&&((te=r.data)!=null&&te.hooks.length)?t.jsx("div",{className:"space-y-2",children:r.data.hooks.map(_=>t.jsxs("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("p",{className:"truncate text-sm font-medium text-stone-100",children:[Ku(_.eventName),_.matcher?` · ${_.matcher}`:""]}),t.jsx("p",{className:"mt-0.5 truncate font-mono text-[11px] text-stone-400",children:_.command??_.handlerType}),_.statusMessage?t.jsx("p",{className:"mt-1 truncate text-[11px] text-stone-500",children:_.statusMessage}):null]}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.08em] text-stone-500",children:[ll(_)?t.jsx("button",{type:"button",onClick:ie=>{ie.stopPropagation(),P(_)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-sky-100 transition hover:border-sky-300/35 hover:bg-sky-300/10`,children:"Edit"}):null,a&&_.trustStatus==="trusted"&&!_.isManaged?t.jsx("button",{type:"button",disabled:s,onClick:ie=>{ie.stopPropagation(),D(_)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-amber-100 transition hover:border-amber-300/35 hover:bg-amber-300/10 disabled:cursor-not-allowed disabled:opacity-50`,children:"Untrust"}):null,(_.trustStatus==="untrusted"||_.trustStatus==="modified")&&!_.isManaged&&a?t.jsx("button",{type:"button",disabled:s||!_.currentHash,onClick:ie=>{ie.stopPropagation(),Q(_)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-emerald-100 transition hover:border-emerald-300/35 hover:bg-emerald-300/10 disabled:cursor-not-allowed disabled:opacity-50`,children:"Trust"}):null,t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-0.5 text-stone-300",children:Yu(_.trustStatus)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.14em] text-stone-500",children:[t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:Xu(_.source)}),t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:_.enabled?"Enabled":"Disabled"}),t.jsxs("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:[_.timeoutSec,"s"]})]})]},_.key))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((se=r.data)==null?void 0:se.hooks.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No hooks configured for this workspace."}):null]})}function Vr(e){return e.localGoalId??`${e.createdAt}:${e.objective}`}function Em(e,r){const n=e?[e,...r]:r,a=new Set;return n.filter(s=>{const o=Vr(s);return a.has(o)?!1:(a.add(o),!0)})}function Lm(e){if(e<60)return`${e}s`;const r=Math.floor(e/60);return r<60?`${r}m`:`${Math.floor(r/60)}h ${r%60}m`}function Im(e){switch(e){case"budgetLimited":return"Budget limited";case"complete":return"Complete";case"terminated":return"Terminated";case"paused":return"Paused";default:return"Active"}}function zm({goalState:e,goalHistory:r,busy:n,onBack:a,onUpdateGoal:s}){const o=Em(e.data,r),l=e.data?Vr(e.data):null;return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-h-11 items-center justify-between gap-3 border-b border-[var(--theme-border)] px-3 py-2",children:[t.jsx("button",{type:"button",onClick:a,className:"min-h-9 rounded-lg px-2 text-xs font-medium text-[var(--theme-fg-muted)] transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--theme-accent-border)]",children:"Back"}),t.jsx("span",{className:"text-xs font-semibold text-[var(--theme-fg)]",children:"Goals"})]}),e.error?t.jsx("p",{className:"m-3 rounded-lg border border-[var(--status-danger-border)] bg-[var(--status-danger-bg)] px-3 py-2 text-xs text-[var(--status-danger-fg)]",children:e.error}):null,e.status==="loading"&&o.length===0?t.jsxs("div",{className:"space-y-2 p-3",role:"status","aria-label":"Loading goals",children:[t.jsx("div",{className:"h-12 animate-pulse rounded-lg bg-[var(--theme-muted)] motion-reduce:animate-none"}),t.jsx("div",{className:"h-12 animate-pulse rounded-lg bg-[var(--theme-muted)] motion-reduce:animate-none"})]}):o.length===0?t.jsx("p",{className:"px-4 py-5 text-center text-sm text-[var(--theme-fg-muted)]",children:"No goals in this thread yet."}):t.jsx("div",{className:"max-h-72 divide-y divide-[var(--theme-border)] overflow-y-auto",children:o.map(i=>{const d=Vr(i)===l&&["active","paused","budgetLimited"].includes(i.status);return t.jsxs("div",{className:"px-3 py-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx("p",{className:"min-w-0 flex-1 text-sm font-medium leading-5 text-[var(--theme-fg)]",children:i.objective}),t.jsx("span",{className:"shrink-0 rounded-full border border-[var(--theme-border)] px-2 py-1 text-[10px] font-medium text-[var(--theme-fg-muted)]",children:Im(i.status)})]}),t.jsxs("p",{className:"mt-1.5 text-[11px] text-[var(--theme-fg-muted)]",children:[Lm(i.timeUsedSeconds)," · ",i.tokensUsed.toLocaleString()," tokens"]}),d&&s?t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsx("button",{type:"button",disabled:n||i.status==="active",onClick:()=>void s({status:"active"}),className:"min-h-9 rounded-lg border border-[var(--theme-border)] px-3 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:opacity-45",children:"Continue"}),t.jsx("button",{type:"button",disabled:n||i.status==="paused",onClick:()=>void s({status:"paused"}),className:"min-h-9 rounded-lg border border-[var(--theme-border)] px-3 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:opacity-45",children:"Pause"}),t.jsx("button",{type:"button",disabled:n,onClick:()=>void s({status:"terminated"}),className:"min-h-9 rounded-lg px-3 text-xs font-medium text-[var(--status-danger-fg)] transition hover:bg-[var(--status-danger-bg)] disabled:cursor-not-allowed disabled:opacity-45",children:"Terminate"})]}):null]},Vr(i))})})]})}function Pm({mcpPanelMode:e,mcpState:r,mcpConfigEditing:n,mcpConfigPath:a,mcpConfigError:s,mcpConfigSuccess:o,mcpConfigBusy:l,mcpHttpName:i,mcpHttpUrl:d,mcpRawBlock:h,composerPanelButtonClassName:u,composerChipButtonClassName:m,onSetMcpPanelMode:f,onClearMcpConfigStatus:p,onSetMcpHttpName:g,onSetMcpHttpUrl:k,onSetMcpRawBlock:w,onPrepareRawMcpBlock:x,onSaveHttpMcp:j,onSaveRawMcpBlock:y}){var b,v;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"MCP config source"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:a??"<provider config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),f("add"),p()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add MCP"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading MCP servers..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,s?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:s}):null,o?t.jsx("p",{className:"mb-2 rounded-xl border border-emerald-500/35 bg-emerald-500/10 px-3 py-3 text-sm text-emerald-100/90",children:o}):null,e==="add"?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:S=>{S.stopPropagation(),f("http"),p()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"HTTP / Streamable HTTP"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"Form"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Add an MCP server with a name and URL, then write the matching block into provider config."})]}),t.jsxs("button",{type:"button",onClick:S=>{S.stopPropagation(),x()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"stdio / raw block"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"TOML"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Write a single `[mcp_servers.name]` block, then save it back into provider config."})]})]}):null,e==="http"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"MCP name"}),t.jsx("input",{"aria-label":"MCP name",value:i,onChange:S=>g(S.target.value),placeholder:"openaiDeveloperDocs",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"URL"}),t.jsx("input",{"aria-label":"URL",value:d,onChange:S=>k(S.target.value),placeholder:"https://developers.openai.com/mcp",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void j(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write HTTP MCP"})]})]}):null,e==="stdio"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsx("label",{className:"block text-xs text-stone-400",children:"MCP block for provider config"}),t.jsx("textarea",{"aria-label":"MCP block for provider config",value:h,onChange:S=>w(S.target.value),rows:8,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void y(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write raw block"})]})]}):null,e==="list"&&((b=r.data)!=null&&b.servers.length)?t.jsx("div",{className:"space-y-2",children:r.data.servers.map(S=>t.jsxs("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:S.name}),t.jsxs("p",{className:"mt-0.5 text-xs text-stone-400",children:[S.tools.length," tools · ",S.resourceCount," ","resources · ",S.resourceTemplateCount," templates"]})]}),t.jsx("span",{className:"shrink-0 rounded-full border border-stone-700 px-2 py-1 text-[10px] uppercase tracking-[0.14em] text-stone-300",children:Vu(S.authStatus)})]}),S.tools.length>0?t.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-stone-500",children:S.tools.slice(0,4).map(N=>N.title??N.name).join(" · ")}):null]},S.name))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((v=r.data)==null?void 0:v.servers.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No MCP servers available right now."}):null]})}function Rm({skillsState:e,copiedSkillName:r,composerChipButtonClassName:n,onCopySkillInvokeName:a}){var s,o,l,i;return t.jsxs("div",{className:"p-2",children:[e.status==="loading"&&!e.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading skills..."}):null,e.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:e.error}):null,(s=e.data)!=null&&s.skills.length?t.jsx("div",{className:"space-y-2",children:e.data.skills.map(d=>{var h,u;return t.jsx("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:((h=d.interface)==null?void 0:h.displayName)??d.name}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.14em]",children:[t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1 text-stone-400",children:qu(d.scope)}),t.jsxs("button",{type:"button",className:`inline-flex items-center gap-1 rounded-full border px-2 py-1 normal-case tracking-normal transition ${r===d.name?"border-emerald-400/45 bg-emerald-400/12 text-emerald-100":`${n} border-stone-700 text-stone-300 hover:border-stone-500`}`,onClick:()=>void a(d.name),title:`Copy $${d.name}`,"aria-label":`Copy $${d.name}`,children:[t.jsx(qn,{}),"$",d.name]})]}),t.jsx("p",{className:"text-xs leading-5 text-stone-400",children:((u=d.interface)==null?void 0:u.shortDescription)??d.shortDescription??d.description})]})},d.path)})}):null,(o=e.data)!=null&&o.errors.length?t.jsx("div",{className:"mt-2 space-y-2",children:e.data.errors.map(d=>t.jsxs("div",{className:"rounded-xl border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-100/85",children:[t.jsx("p",{className:"font-medium",children:d.message}),t.jsx("p",{className:"mt-1 break-all text-amber-100/60",children:d.path})]},`${d.path}:${d.message}`))}):null,e.status!=="loading"&&!e.error&&(((l=e.data)==null?void 0:l.skills.length)??0)===0&&(((i=e.data)==null?void 0:i.errors.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No skills available right now."}):null]})}function Am({open:e,slashPanelView:r,availableToolboxItems:n,busy:a,forkBusy:s,forkTurnOptionsState:o,skillsState:l,goalState:i,goalHistory:d,goalBusy:h,copiedSkillName:u,hooksPanelMode:m,hooksState:f,hostConfigFilesAvailable:p,hookTrustAvailable:g,hookConfigBusy:k,hookConfigError:w,hookConfigSuccess:x,editingHookTarget:j,hookScope:y,hookEventName:b,hookMatcher:v,hookCommand:S,hookTimeoutSec:N,hookStatusMessage:L,mcpPanelMode:R,mcpState:P,mcpConfigEditing:Q,mcpConfigPath:D,mcpConfigError:Z,mcpConfigSuccess:J,mcpConfigBusy:z,mcpHttpName:te,mcpHttpUrl:se,mcpRawBlock:_,iconButtonClassName:ie,menuClassName:q,menuItemClassName:H,panelButtonClassName:G,chipButtonClassName:T,onToggle:F,onToolboxItemClick:B,toolboxItemDisabled:E,toolboxItemClassName:C,toolboxItemStatus:W,onSetSlashPanelView:U,onViewGoals:ae,onUpdateGoal:K,onOpenForkTurns:de,onForkLatest:ee,onForkTurn:ke,onCopySkillInvokeName:le,onResetHookForm:je,onSetHooksPanelMode:Ae,onClearHookConfigStatus:ce,onSetEditingHookTarget:ne,onSetHookScope:Le,onSetHookEventName:Y,onSetHookMatcher:me,onSetHookCommand:we,onSetHookTimeoutSec:ye,onSetHookStatusMessage:De,onSaveHook:Be,onStartEditingHook:_e,onTrustHook:Oe,onUntrustHook:V,onSetMcpPanelMode:he,onClearMcpConfigStatus:ve,onSetMcpHttpName:I,onSetMcpHttpUrl:O,onSetMcpRawBlock:oe,onPrepareRawMcpBlock:ge,onSaveHttpMcp:Ne,onSaveRawMcpBlock:Ce}){return t.jsxs("div",{className:"relative",children:[t.jsx(Ct,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Open slash toolbox",title:"Open slash toolbox",onClick:F,className:`${ie} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx(Ou,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${q} absolute bottom-full left-0 z-40 mb-2 w-72 overflow-hidden rounded-2xl border bg-stone-900/72 shadow-2xl shadow-stone-950/20 backdrop-blur-xl`,onClick:xe=>{xe.stopPropagation()},onMouseDown:xe=>{xe.stopPropagation()},onPointerDown:xe=>{xe.stopPropagation()},onTouchStart:xe=>{xe.stopPropagation()},children:r==="root"?t.jsxs("div",{className:"p-2",children:[n.map((xe,Ge)=>xe.action==="goal"?t.jsxs("div",{className:`mt-1 flex min-h-11 overflow-hidden rounded-xl border border-[var(--theme-border)] ${Ge===0?"mt-0":""}`,title:xe.description??xe.label,children:[t.jsx("button",{type:"button",disabled:E(xe),onClick:()=>{U("goals"),ae==null||ae()},className:"min-w-0 flex-1 px-3 py-2.5 text-left text-sm text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--theme-accent-border)] disabled:cursor-not-allowed disabled:opacity-45","aria-label":"View goals",children:t.jsx("span",{children:xe.command})}),t.jsx("button",{type:"button",disabled:E(xe),onClick:Me=>B(xe,Me),className:"min-w-14 border-l border-[var(--theme-border)] px-3 text-xs font-semibold text-[var(--theme-fg-muted)] transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)] focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--theme-accent-border)] disabled:cursor-not-allowed disabled:opacity-45","aria-label":"Open goal composer",children:"Open"})]},`${xe.action}:${xe.command}`):t.jsx("button",{type:"button",disabled:E(xe),onClick:Me=>B(xe,Me),className:`${C(xe)} ${Ge===0?"mt-0":""}`,title:xe.description??xe.label,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:xe.command}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:W(xe)})]})},`${xe.action}:${xe.command}`)),n.length===0?t.jsx("p",{className:"px-3 py-2 text-sm text-stone-400",children:"No backend tools are available for this thread."}):null]}):t.jsx("div",{className:"max-h-80 overflow-auto",children:r==="goals"?t.jsx(zm,{goalState:i,goalHistory:d,busy:h,onBack:()=>U("root"),onUpdateGoal:K}):r==="fork"?t.jsx(Cm,{busy:a,forkBusy:s,composerMenuItemClassName:H,onForkLatest:ee,onSelectForkTurnPanel:()=>(U("forkTurns"),de())}):r==="forkTurns"?t.jsx(Sm,{forkTurnOptionsState:o,forkBusy:s,composerPanelButtonClassName:G,onForkTurn:ke}):r==="skills"?t.jsx(Rm,{skillsState:l,copiedSkillName:u,composerChipButtonClassName:T,onCopySkillInvokeName:le}):r==="hooks"?t.jsx(Tm,{hooksPanelMode:m,hooksState:f,hostConfigFilesAvailable:p,hookTrustAvailable:g,hookConfigBusy:k,hookConfigError:w,hookConfigSuccess:x,editingHookTarget:j,hookScope:y,hookEventName:b,hookMatcher:v,hookCommand:S,hookTimeoutSec:N,hookStatusMessage:L,composerChipButtonClassName:T,onResetHookForm:je,onSetHooksPanelMode:Ae,onClearHookConfigStatus:ce,onSetEditingHookTarget:ne,onSetHookScope:Le,onSetHookEventName:Y,onSetHookMatcher:me,onSetHookCommand:we,onSetHookTimeoutSec:ye,onSetHookStatusMessage:De,onSaveHook:Be,onStartEditingHook:_e,onTrustHook:Oe,onUntrustHook:V}):t.jsx(Pm,{mcpPanelMode:R,mcpState:P,mcpConfigEditing:Q,mcpConfigPath:D,mcpConfigError:Z,mcpConfigSuccess:J,mcpConfigBusy:z,mcpHttpName:te,mcpHttpUrl:se,mcpRawBlock:_,composerPanelButtonClassName:G,composerChipButtonClassName:T,onSetMcpPanelMode:he,onClearMcpConfigStatus:ve,onSetMcpHttpName:I,onSetMcpHttpUrl:O,onSetMcpRawBlock:oe,onPrepareRawMcpBlock:ge,onSaveHttpMcp:Ne,onSaveRawMcpBlock:Ce})})})]})}function Mm({isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:s,toolbarClassName:o,iconButtonClassName:l,slashToolboxProps:i,attachmentMenuProps:d,settingsToolbarProps:h,shellToolsPanelProps:u,onToggleView:m,onDismissPromptFocus:f,onSetOpenMenu:p}){return t.jsxs(mm,{align:"block-end",className:`${o} relative z-30 mb-0 flex items-center gap-2 text-xs`,children:[t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[!e&&i?t.jsx(Am,{...i}):null,!e&&d?t.jsx(ym,{...d}):null,r&&t.jsx(Ct,{type:"button",variant:"ghost",size:"icon-xs","aria-label":e?"Switch to chat":"Switch to shell",title:e?"Switch to chat":"Switch to shell",onClick:()=>m==null?void 0:m(),className:`${l} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:e?t.jsx(Wu,{}):t.jsx(Fu,{})})]}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-end gap-1.5",children:[!e&&h?t.jsx(jm,{...h}):null,e&&a?t.jsx(fm,{className:"min-w-0 max-w-[12rem] truncate rounded-full px-1.5 py-1 text-stone-400",title:a,children:a}):null,n&&t.jsxs("div",{className:"relative",children:[t.jsx("button",{type:"button","data-composer-menu-trigger":"true","aria-label":s==="shellTools"?"Close shell tools":"Open shell tools","aria-haspopup":"menu","aria-expanded":s==="shellTools",title:s==="shellTools"?"Close shell tools":"Open shell tools",onClick:()=>{f(),p(g=>g==="shellTools"?null:"shellTools")},className:"inline-flex h-7 w-7 items-center justify-center rounded-full border border-stone-700 bg-stone-900/92 text-stone-200 transition hover:bg-stone-800",children:t.jsx(Uu,{})}),s==="shellTools"&&u?t.jsx(Nm,{...u}):null]})]})]})}function $m(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`attachment-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function _m(e){return[...e.filter(r=>Un(r)==="photo"),...e.filter(r=>Un(r)==="file")]}function Dm({prompt:e,attachments:r,updateDraft:n,getSelection:a,selectionSnapshotRef:s,pendingSelectionRef:o,pendingInsertedAttachmentIdsRef:l,onInserted:i,buildClientId:d=$m}){const h=c.useCallback((f,p)=>{if(f.length===0)return!1;const g=Nu({prompt:e,attachments:r,files:f,selection:a()??s.current,kindForFile:p,buildClientId:d});return n(()=>g.draft),o.current=g.selection,s.current=g.selection,l.current=g.insertedAttachmentIds,i==null||i(),!0},[r,d,a,i,l,o,e,s,n]),u=c.useCallback((f,p)=>!f||f.length===0?!1:h(Array.from(f),()=>p),[h]),m=c.useCallback(f=>h(_m(f),Un),[h]);return{appendAttachments:u,appendDroppedAttachments:m}}function cs(e){for(const r of e.values())URL.revokeObjectURL(r);e.clear()}function Bm({attachments:e,isShellView:r}){const n=c.useRef(new Map),[a,s]=c.useState({});return c.useEffect(()=>{const o=n.current;if(r){cs(o),s({});return}const l={},i=new Set;for(const d of e){if(d.kind!=="photo")continue;i.add(d.clientId);let h=o.get(d.clientId);h||(h=URL.createObjectURL(d.file),o.set(d.clientId,h)),l[d.clientId]=h}for(const[d,h]of o.entries())i.has(d)||(URL.revokeObjectURL(h),o.delete(d));s(l)},[e,r]),c.useEffect(()=>{const o=n.current;return()=>{cs(o)}},[]),a}var Gm=180;function Tn(e,r){return{prompt:e??"",attachments:r??[]}}function Fm({isShellView:e,draftPrompt:r,draftAttachments:n,onDraftChange:a}){const[s,o]=c.useState({prompt:"",attachments:[]}),[l,i]=c.useState(()=>Tn(r,n)),d=c.useRef(null),h=c.useRef(l),u=c.useRef(_r(l)),m=!e&&r!==void 0&&n!==void 0&&typeof a=="function",f=m?_r(Tn(r,n)):"",p=c.useRef(f);c.useLayoutEffect(()=>{if(!m){p.current="";return}const y=Tn(r,n),b=_r(y);b!==p.current&&(p.current=b,u.current=b,h.current=y,d.current!==null&&(window.clearTimeout(d.current),d.current=null),i(y))},[n,r,m]);const g=c.useCallback(y=>{if(!m||!a)return;const b=_r(y);b!==u.current&&(u.current=b,a(()=>({prompt:y.prompt,attachments:y.attachments})))},[m,a]);c.useEffect(()=>()=>{g(h.current),d.current!==null&&window.clearTimeout(d.current)},[g]);const k=c.useCallback((y,b)=>{if(m){if(d.current!==null&&(window.clearTimeout(d.current),d.current=null),b==="immediate"){g(y);return}d.current=window.setTimeout(()=>{d.current=null,g(h.current)},Gm)}},[m,g]),w=c.useCallback((y=h.current)=>{k(y,"immediate")},[k]),x=c.useCallback((y,b="immediate")=>{if(m){const v=y(h.current);h.current=v,i(v),k(v,b);return}o(v=>y(v))},[m,k]),j=m?l:s;return{prompt:j.prompt,attachments:j.attachments,isDraftControlled:m,updateDraft:x,flushControlledDraftToHost:w}}function Hm({slashPanelView:e,onForkLatest:r,onForkTurn:n,closeMenu:a}){const[s,o]=c.useState(!1);c.useEffect(()=>{e!=="forkTurns"&&o(!1)},[e]);const l=c.useCallback(async()=>{if(r){o(!0);try{await r(),a()}finally{o(!1)}}},[a,r]),i=c.useCallback(async d=>{if(n){o(!0);try{await n(d),a()}finally{o(!1)}}},[a,n]);return{forkBusy:s,forkLatest:l,forkTurn:i}}function Om({prompt:e,goalTokenBudgetSource:r,promptRef:n,onOpenGoal:a,onPrepareGoalSubmit:s,onUpdateGoal:o,updateDraft:l,closeMenu:i,resetSlashPanel:d}){const[h,u]=c.useState(!1),[m,f]=c.useState(""),[p,g]=c.useState(!1),[k,w]=c.useState(null),x=c.useCallback(async()=>{const b=e.trim();if(!b)return w("Goal objective cannot be empty."),!1;const v=m.trim(),S=Iu(v);if(v.length>0&&(S===null||!Number.isInteger(S)||S<=0))return w("Token budget must be a positive number in thousands."),!1;if(!o)return w("/goal is unavailable in this view."),!1;g(!0),w(null);try{return s&&await s({objective:b,tokenBudget:S})===!1?!1:(await o({objective:b,status:"active",tokenBudget:S}),f(""),u(!1),l(()=>({prompt:"",attachments:[]})),!0)}catch(N){return w(N instanceof Error?N.message:"Unable to set goal."),!1}finally{g(!1)}},[m,s,o,e,l]),j=c.useCallback(()=>{i(),d(),u(!0),f(zu(r==null?void 0:r.tokenBudget)),w(null),a==null||a(),requestAnimationFrame(()=>{var b;(b=n.current)==null||b.focus()})},[i,r==null?void 0:r.tokenBudget,a,n,d]),y=c.useCallback(()=>{u(!1),w(null)},[]);return{goalComposeMode:h,goalTokenBudget:m,goalBusy:p,goalLocalError:k,setGoalTokenBudget:f,submitGoal:x,enterGoalComposeMode:j,exitGoalComposeMode:y}}var En=`node -e "process.stdin.resume(); process.stdin.on('end', () => console.error('hook ran'))"`;function Wm(e){const r=new Map;for(const n of e??[])r.set(n.eventName,n.command);return r}function Um({slashPanelView:e,hookCommandTemplates:r,onCreateHook:n,onUpdateHook:a,onTrustHook:s,onUntrustHook:o}){const[l,i]=c.useState("list"),[d,h]=c.useState("project"),[u,m]=c.useState("preToolUse"),[f,p]=c.useState("Bash"),[g,k]=c.useState(En),[w,x]=c.useState("30"),[j,y]=c.useState("Running hook"),[b,v]=c.useState(null),[S,N]=c.useState(!1),[L,R]=c.useState(null),[P,Q]=c.useState(null),D=c.useMemo(()=>Wm(r),[r]),Z=c.useCallback(H=>D.get(H)??D.get("preToolUse")??En,[D]),J=c.useMemo(()=>new Set([En,...D.values()]),[D]),z=c.useCallback(()=>{R(null),Q(null)},[]);c.useEffect(()=>{e!=="hooks"&&(i("list"),z())},[z,e]),c.useEffect(()=>{const H=Zr.find(G=>G.value===u);p(G=>{const T=G.trim(),F=new Set(Zr.map(B=>B.matcherHint).filter(Boolean));return T&&!F.has(T)?G:(H==null?void 0:H.matcherHint)??""}),k(G=>J.has(G.trim())?Z(u):G)},[Z,J,u]);const te=c.useCallback(()=>{v(null),h("project"),m("preToolUse"),p("Bash"),k(Z("preToolUse")),x("30"),y("Running hook")},[Z]),se=c.useCallback(H=>{const G=ll(H);if(!G){R("Only command hooks in global or project hooks.json can be edited here.");return}v(G),h(G.scope),m(G.eventName),p(G.matcher??""),k(G.command),x(G.timeoutSec?String(G.timeoutSec):""),y(G.statusMessage??""),R(null),Q(null),i("edit")},[]),_=c.useCallback(async()=>{if(l==="edit"&&!a){R("Hook editing is unavailable in this view.");return}if(l!=="edit"&&!n){R("Hook editing is unavailable in this view.");return}if(l==="edit"&&!b){R("Select a hook to edit first.");return}const H=g.trim();if(!H){R("Hook command cannot be empty.");return}const G=w.trim(),T=G?Number(G):null;if(G&&(T===null||!Number.isInteger(T)||T<=0)){R("Timeout must be a positive number of seconds.");return}N(!0),R(null),Q(null);try{const F={scope:d,eventName:u,matcher:f.trim()||null,command:H,timeoutSec:T,statusMessage:j.trim()||null};l==="edit"?await(a==null?void 0:a({...F,target:b})):await(n==null?void 0:n(F)),Q(`${d==="project"?"Project":"Global"} hook ${l==="edit"?"updated":"written"} in hooks.json and trusted.`),i("list"),v(null)}catch(F){R(F instanceof Error?F.message:"Unable to write hooks.json.")}finally{N(!1)}},[b,g,u,f,d,j,w,l,n,a]),ie=c.useCallback(async H=>{if(!s||!H.currentHash){R("Hook trust is unavailable in this view.");return}N(!0),R(null),Q(null);try{await s({key:H.key,currentHash:H.currentHash}),Q("Hook trusted.")}catch(G){R(G instanceof Error?G.message:"Unable to trust hook.")}finally{N(!1)}},[s]),q=c.useCallback(async H=>{if(!o){R("Hook trust is unavailable in this view.");return}N(!0),R(null),Q(null);try{await o({key:H.key}),Q("Hook untrusted.")}catch(G){R(G instanceof Error?G.message:"Unable to untrust hook.")}finally{N(!1)}},[o]);return{hooksPanelMode:l,hookScope:d,hookEventName:u,hookMatcher:f,hookCommand:g,hookTimeoutSec:w,hookStatusMessage:j,editingHookTarget:b,hookConfigBusy:S,hookConfigError:L,hookConfigSuccess:P,setHooksPanelMode:i,setEditingHookTarget:v,setHookScope:h,setHookEventName:m,setHookMatcher:p,setHookCommand:k,setHookTimeoutSec:x,setHookStatusMessage:y,clearHookConfigStatus:z,resetHookForm:te,startEditingHook:se,saveHook:_,trustHook:ie,untrustHook:q}}var Vm=`[mcp_servers.example_stdio]
|
|
3688
|
+
${s}`:s}function il(e){return typeof e!="number"||Number.isNaN(e)?0:Math.max(0,Math.min(100,Math.round(e)))}function Sn(e){const r=e/1e3;return Number.isInteger(r)?`${r}k`:`${Number(r.toFixed(1))}k`}function Bu(e,r){if(!e)return"Select model";if((r==null?void 0:r.availability)!=="available"||typeof r.tokensInContextWindow!="number"||typeof r.modelContextWindow!="number")return`${e} · context unavailable`;const n=Math.max(r.tokensInContextWindow,0),a=Math.max(r.modelContextWindow,0),s=Math.max(a-n,0);return[e,`${Sn(n)} used / ${Sn(a)}`,`${Sn(s)} left`,`${il(r.remainingPercent)}% context left`].join(" · ")}function Gu(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 Fu(e){return e.replace(/[\r\n[\]]+/g," ").replace(/\s+/g," ").trim()||"attachment"}function qn(e){return e.type.startsWith("image/")?"photo":"file"}function Xn(e,r){const n=[];if(e)for(const a of Array.from(e)){if(a.kind!=="file")continue;const s=a.getAsFile();s&&n.push(s)}return n.length>0?n:r?Array.from(r):[]}function ls(e,r){return Xn(e,r).length>0}function Hu(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function is(e){const r=e.placeholder.match(/^\[(?:PHOTO|FILE)\s+(.+)\]$/);return r!=null&&r[1]?r[1]:Hu(e.originalName)}var Zr=[{value:"preToolUse",label:"PreToolUse",matcherHint:"Bash"},{value:"permissionRequest",label:"PermissionRequest",matcherHint:"Bash"},{value:"postToolUse",label:"PostToolUse",matcherHint:"Bash"},{value:"sessionStart",label:"SessionStart",matcherHint:"startup|resume"},{value:"userPromptSubmit",label:"UserPromptSubmit",matcherHint:""},{value:"stop",label:"Stop",matcherHint:""},{value:"preCompact",label:"PreCompact",matcherHint:""},{value:"postCompact",label:"PostCompact",matcherHint:""}];function Ou({goalComposeMode:e,goalBusy:r,threadConnected:n,busy:a,isShellView:s,disabledPlaceholder:o,settingsBusy:l,supportedEffortCount:i,fastMode:d}){const h=e?"Describe the goal the backend should continue working toward...":o??(s?"Send shell input to the attached terminal...":"Ask the backend to inspect, modify, or explain code..."),u=e?r?"Setting...":"Set goal":!n&&a?"Connecting...":n&&a&&!s?"Sending...":"Send",m=n?e?"ui-action-info":"ui-action-primary":"ui-action-danger",f=l;return{promptPlaceholder:h,interruptLabel:s?"Send Ctrl-C":"Stop Current Turn",sendButtonLabel:u,sendButtonClassName:m,modelControlsDisabled:f,effortControlsDisabled:f||i===0,effortControlTitle:d?"Fast mode is on. Turn it off from the slash toolbox to edit reasoning.":i===0?"The selected model does not expose adjustable reasoning effort.":"Select reasoning effort"}}function Wu({isShellView:e,edgeToEdgeMobile:r,isMobileShell:n,openMenu:a,isDragTargetActive:s,busy:o}){const l=e?"thread-composer-layer thread-shell-composer-layer":"thread-graph-composer-layer",i=e?"thread-composer-form":"thread-graph-composer-form",d=e?"thread-composer-form-floating":"thread-graph-composer-form-floating",h=e?"thread-composer-input":"thread-graph-composer-input";return{composerLayerClassName:a?`${l} relative z-[80] shrink-0`:`${l} relative z-20 shrink-0`,formClassName:e?r||n?`${i} ${d} relative z-20 shrink-0 border-t border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`:`${i} relative z-20 shrink-0 border-t border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`:`${i} ${r?d:""} relative z-20 shrink-0 border-t px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`,composerShellClassName:e?"thread-composer-shell":"thread-graph-composer-shell",composerToolbarClassName:e?"thread-composer-toolbar":"thread-graph-composer-toolbar",composerInputClassName:h,composerIconButtonClassName:e?"thread-composer-icon-button":"thread-graph-composer-icon-button",composerMenuClassName:e?"thread-composer-menu":"thread-graph-composer-menu",composerMenuItemClassName:e?"thread-composer-menu-item":"thread-graph-composer-menu-item",composerInlineToggleClassName:e?"thread-composer-inline-toggle":"thread-graph-composer-inline-toggle",composerPanelButtonClassName:e?"thread-composer-panel-button":"thread-graph-composer-panel-button",composerChipButtonClassName:e?"thread-composer-chip-button":"thread-graph-composer-chip-button",composerPlanToggleActiveClassName:e?"thread-composer-plan-toggle-active":"thread-graph-composer-plan-toggle-active",composerSendButtonClassName:e?"thread-composer-send-button":"thread-graph-composer-send-button",composerPromptRegionClassName:e?"thread-composer-prompt-region":"thread-graph-composer-prompt-region",promptInputClassName:`${h} min-h-[5.25rem] w-full px-4 pr-14 pt-3 outline-none transition sm:min-h-[5.75rem] ${s?"is-drag-target border-sky-300/80 bg-sky-300/[0.08] shadow-[0_0_0_1px_rgba(125,211,252,0.2)]":""}`,graphChatInputGroupClassName:`thread-graph-composer-input-group relative border-0 bg-transparent shadow-none ring-0 ${o?"bg-amber-50/40 dark:bg-amber-400/10":"bg-transparent"}`,graphChatInputClassName:`${h} min-h-[68px] max-h-32 w-full overflow-y-auto px-3 pt-3 text-[16px] leading-relaxed text-slate-800 outline-none transition sm:min-h-[92px] sm:max-h-40 sm:px-4 sm:pt-4 sm:text-[14px] dark:text-slate-100 ${s?"is-drag-target bg-sky-300/[0.08] shadow-[0_0_0_1px_rgba(125,211,252,0.2)]":""}`}}function Uu(){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 Vu(){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 qu(){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 Xu(){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 Ku(){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 Kn(){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 Yu(e){switch(e){case"bearerToken":return"Token";case"oAuth":return"OAuth";case"notLoggedIn":return"Login";case"unsupported":return"Public";default:return"Unknown"}}function Zu(e){switch(e){case"repo":return"Repo";case"system":return"System";case"admin":return"Admin";case"user":default:return"User"}}function Ju(e){var r;return((r=Zr.find(n=>n.value===e))==null?void 0:r.label)??e}function Qu(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 em(e){switch(e){case"managed":return"Managed";case"modified":return"Modified";case"trusted":return"Trusted";case"untrusted":return"Review"}}function tm(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 rm(e){return e.source==="user"?"global":e.source==="project"?"project":null}function dl(e){const r=rm(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 nm(e){switch(e){case"active":return"Active";case"paused":return"Paused";case"budgetLimited":return"Budget";case"complete":return"Complete";default:return e}}function am({contextUsage:e}){const r=(e==null?void 0:e.availability)??"unavailable",n=il(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 sm(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 om(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 lm(e,{fastMode:r,compactBusy:n,goalComposeMode:a,goalStatus:s,busy:o}){switch(e.action){case"fast":return r?"On":"Off";case"compact":return n?"Busy":"Run";case"goal":return a?"Composing":s?nm(s):"Open";case"fork":return o?"Idle only":"Open";case"skills":case"mcp":case"hooks":return"View";case"prompt":return"Compose";case"unsupported":return"Unavailable";default:return""}}function im(e,{settingsBusy:r,compactBusy:n,busy:a,forkBusy:s}){switch(e.action){case"fast":return r;case"compact":return n||a;case"fork":return a||s;case"unsupported":return!0;default:return!1}}function dm(e,{fastMode:r,goalComposeMode:n,goalStatus:a,menuItemClassName:s}){return`${e.action==="fast"&&r||e.action==="goal"&&(n||a==="active")?"ui-status-warning":s} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`}function cm(e){if(!e)return"";const r=document.createElement("div");return r.innerHTML=e,r.textContent??""}function hm(e){return!!e.querySelector("[style], font")}function Ht(e){return e instanceof HTMLElement&&e.dataset.segmentType==="attachment"&&e.dataset.placeholder?e.dataset.placeholder:e.textContent??""}function cl(e){let r="";for(const n of Array.from(e.childNodes))r+=Ht(n);return r.replace(/\u00a0/g," ")}function ds(e,r,n){var i;let a=null,s=n;if(r===e){const d=Array.from(e.childNodes);let h=0;for(let u=0;u<Math.min(n,d.length);u+=1){const m=d[u];m&&(h+=Ht(m).length)}return h}if(r.nodeType===Node.TEXT_NODE)a=r;else{const d=Array.from(e.childNodes).find(h=>h.contains(r));if(!d)return cl(e).length;if(a=d,d instanceof HTMLElement&&d.dataset.segmentType==="attachment"){const h=document.createRange();h.selectNodeContents(d);const u=Ht(d).length;try{h.setEnd(r,n);const m=h.toString().length,f=((i=d.textContent)==null?void 0:i.length)??0;f===0?s=u:s=Math.round(Math.min(1,m/f)*u)}catch{s=u}}else{const h=document.createRange();h.selectNodeContents(d);try{h.setEnd(r,n),s=h.toString().length}catch{s=Ht(d).length}}}const o=Array.from(e.childNodes);let l=0;for(const d of o){if(d===a)return d.nodeType===Node.TEXT_NODE?l+s:l+Math.min(s,Ht(d).length);l+=Ht(d).length}return l}function um(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:ds(e,n.startContainer,n.startOffset),end:ds(e,n.endContainer,n.endOffset)}}function cs(e,r){let n=Math.max(0,r);const a=Array.from(e.childNodes);for(const[s,o]of a.entries()){const i=Ht(o).length;if(o.nodeType===Node.TEXT_NODE){if(n<=i)return{node:o,offset:n};n-=i;continue}if(o instanceof HTMLElement&&o.dataset.segmentType==="attachment"){if(n===0)return{node:e,offset:s};if(n<=i){const d=a[s+1];return n===i&&(d==null?void 0:d.nodeType)===Node.TEXT_NODE?{node:d,offset:0}:{node:e,offset:s+1}}n-=i;continue}if(n<=i)return{node:e,offset:s+1};n-=i}return{node:e,offset:e.childNodes.length}}function mm(e,r){const n=cs(e,r.start),a=cs(e,r.end),s=document.createRange();s.setStart(n.node,n.offset),s.setEnd(a.node,a.offset);const o=window.getSelection();o==null||o.removeAllRanges(),o==null||o.addRange(s)}function pm(e,r){if(r.length===0)return!1;const n=r.at(-1);if(!n)return!1;const a=Array.from(e.childNodes).find(i=>i instanceof HTMLElement&&i.dataset.segmentType==="attachment"&&i.dataset.clientId===n);if(!(a instanceof HTMLElement))return!1;const s=document.createRange(),o=a.nextSibling;(o==null?void 0:o.nodeType)===Node.TEXT_NODE?s.setStart(o,0):s.setStartAfter(a),s.collapse(!0);const l=window.getSelection();return l==null||l.removeAllRanges(),l==null||l.addRange(s),!0}sn();Pt();function fm({className:e,...r}){return t.jsx("div",{"data-slot":"input-group",role:"group",className:at("group/input-group relative flex w-full min-w-0 items-center rounded-md border shadow-xs outline-none transition-[color,box-shadow]","h-9 has-[>textarea]:h-auto","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col",e),...r})}var gm=Er("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*=size-])]:size-4",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.45rem]","block-start":"order-first w-full justify-start px-3 pt-3","block-end":"order-last w-full justify-start px-3 pb-3"}},defaultVariants:{align:"inline-start"}});function xm({className:e,align:r="inline-start",...n}){return t.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":r,className:at(gm({align:r}),e),onClick:a=>{var o;if(a.target.closest("button"))return;const s=(o=a.currentTarget.parentElement)==null?void 0:o.querySelector('[data-slot="input-group-control"] [contenteditable="true"], [data-slot="input-group-control"] textarea, [data-slot="input-group-control"] input, [data-slot="input-group-control"]');s==null||s.focus()},...n})}var bm=Er("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*=size-])]:size-3.5",sm:"h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function Ct({className:e,type:r="button",variant:n="ghost",size:a="xs",...s}){return t.jsx(Tr,{type:r,"data-size":a,variant:n,className:at(bm({size:a}),e),...s})}function vm({className:e,...r}){return t.jsx("span",{className:at("flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*=size-])]:size-4",e),...r})}function km({photoInputRef:e,fileInputRef:r,onAppendAttachments:n}){function a(s,o){n(s.target.files,o),s.target.value=""}return t.jsxs(t.Fragment,{children:[t.jsx("input",{ref:e,type:"file",accept:"image/*",multiple:!0,tabIndex:-1,className:"sr-only",onChange:s=>a(s,"photo")}),t.jsx("input",{ref:r,type:"file",multiple:!0,tabIndex:-1,className:"sr-only",onChange:s=>a(s,"file")})]})}function wm(e){if(!e)return"reset time unavailable";const r=new Date(e);return Number.isNaN(r.getTime())?"reset time unavailable":`resets ${r.toLocaleString()}`}function ym({usage:e}){const[r,n]=c.useState(!1);if(!e||e.authKind!=="subscription"||e.windows.length===0)return null;const a=e.windows.slice(0,2),s=a.map(o=>{const l=Math.max(0,100-o.usedPercent);return`${o.label}: ${l}% remaining, ${wm(o.resetsAt)}`}).join(". ");return t.jsxs("button",{type:"button",className:`thread-subscription-usage group pointer-events-auto absolute bottom-0 right-2 inline-flex h-4 items-center gap-1 rounded-t-md border border-b-0 border-stone-500/50 bg-stone-950 px-1 text-[7px] font-normal leading-none text-stone-200 shadow-sm transition-[border-color,background-color,opacity] duration-200 hover:border-stone-400/75 hover:bg-stone-900 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-sky-200/70 sm:right-3 sm:text-[7px] ${e.stale?"opacity-70":"opacity-95"}`,"aria-label":`${e.provider} subscription usage. ${s}`,"aria-expanded":r,onClick:()=>n(o=>!o),children:[a.map(o=>{const l=Math.max(0,Math.min(100,100-o.usedPercent)),i=Math.round(18+l/100*190);return t.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[t.jsx("span",{className:"font-normal tracking-[-0.01em]",children:o.label}),t.jsx("span",{"data-subscription-window-track":"true",className:"h-0.5 w-7 overflow-hidden rounded-full bg-stone-600/55 sm:w-9",children:t.jsx("span",{className:"block h-full rounded-full transition-[width] duration-500 ease-out",style:{width:`${l}%`,backgroundImage:`linear-gradient(90deg, oklch(68% 0.17 ${i}), oklch(82% 0.13 ${Math.min(i+18,235)}))`}})})]},o.id)}),t.jsxs("span",{"aria-hidden":!r,className:`pointer-events-none absolute right-0 bottom-full mb-1 whitespace-nowrap rounded-md border border-stone-600/65 bg-stone-950/95 px-1.5 py-1 text-[9px] font-normal leading-none text-stone-100 shadow-lg transition-[opacity,transform] duration-200 group-hover:translate-y-0 group-hover:opacity-100 group-focus-visible:translate-y-0 group-focus-visible:opacity-100 ${r?"translate-y-0 opacity-100":"translate-y-0.5 opacity-0"}`,children:[a.map((o,l)=>t.jsxs("span",{children:[l>0?" · ":"",o.label," ",Math.round(100-o.usedPercent),"%"]},o.id)),e.stale?" · last known":""]})]})}function jm({activeView:e,followTail:r,onToggleFollow:n,canJumpToPreviousTurn:a,onJumpToPreviousTurn:s,canJumpToNextTurn:o,onJumpToNextTurn:l,subscriptionUsage:i}){return e!=="chat"?null:t.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-[90] h-11 -translate-y-full bg-transparent touch-manipulation sm:h-10",children:[t.jsxs("span",{role:"group","aria-label":"Timeline navigation",className:`thread-jump-latest-badge pointer-events-auto absolute bottom-1 left-1/2 inline-flex h-5 min-w-[7.5rem] -translate-x-1/2 overflow-hidden rounded-[0.7rem] border shadow-sm transition ${r?"is-active border-sky-300/36 bg-sky-300/[0.03] text-sky-100/86":"border-stone-500/70 bg-stone-950/[0.08] text-stone-200/86"}`,children:[t.jsx("button",{type:"button","aria-label":"Jump to previous turn",title:a?"Jump to the start of the previous turn":"No earlier turn",disabled:!a,onClick:()=>s==null?void 0:s(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70 disabled:cursor-default disabled:opacity-35",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3.5 12h9M8 10V5M6 7l2-2 2 2"})})}),t.jsx("span",{"aria-hidden":"true",className:"w-px bg-current opacity-20"}),t.jsx("button",{type:"button","aria-label":"Jump to latest",title:r?"Latest messages are in view":"Jump to the bottom",onClick:()=>n==null?void 0:n(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m4 5.5 4 4 4-4M3.5 12.5h9"})})}),t.jsx("span",{"aria-hidden":"true",className:"w-px bg-current opacity-20"}),t.jsx("button",{type:"button","aria-label":"Jump to next turn",title:o?"Jump to the start of the next turn":"No later turn",disabled:!o,onClick:()=>l==null?void 0:l(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70 disabled:cursor-default disabled:opacity-35",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3.5 4h9M8 6v5m-2-2 2 2 2-2"})})})]}),t.jsx(ym,{usage:i})]})}function Nm({activeView:e,layerClassName:r,formClassName:n,shellClassName:a,inputGroupClassName:s,error:o,followTail:l,photoInputRef:i,fileInputRef:d,onAppendAttachments:h,onToggleFollow:u,canJumpToPreviousTurn:m,onJumpToPreviousTurn:f,canJumpToNextTurn:p,onJumpToNextTurn:g,subscriptionUsage:k,onSubmit:w,formRef:x,promptSlot:j,pendingQueueSlot:y,toolbarSlot:b,goalSlot:v,shellPromptSlot:S}){return t.jsxs("div",{className:r,children:[t.jsx(km,{photoInputRef:i,fileInputRef:d,onAppendAttachments:h}),t.jsx(jm,{activeView:e,followTail:l,onToggleFollow:u,canJumpToPreviousTurn:m,onJumpToPreviousTurn:f,canJumpToNextTurn:p,onJumpToNextTurn:g,subscriptionUsage:k}),y,t.jsxs("form",{ref:x,"data-testid":e==="chat"?"chat-composer":void 0,onSubmit:w,className:n,children:[t.jsxs("div",{className:`${a} flex w-full flex-col overflow-visible rounded-[16px] sm:rounded-[18px]`,children:[t.jsxs(fm,{className:s,children:[j,b]}),v,S]}),o?t.jsx("div",{className:"mt-2 rounded-2xl border border-rose-500/40 bg-rose-500/10 px-4 py-3 text-sm text-rose-200",children:o}):null]})]})}function Cm({prompts:e,onSteer:r,onCancel:n}){const[a,s]=c.useState(()=>new Set);async function o(l,i){if(!(!i||a.has(l))){s(d=>new Set(d).add(l));try{await i(l)}catch{}finally{s(d=>{const h=new Set(d);return h.delete(l),h})}}}return t.jsxs("section",{"aria-label":"Queued prompts",className:"thread-composer-pending-queue mx-auto mb-2 w-full max-w-4xl overflow-hidden rounded-xl border",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 text-[11px] font-medium text-[var(--theme-fg-muted)]",children:[t.jsx("span",{children:"Queued"}),t.jsx("span",{children:e.length})]}),t.jsx("div",{className:"max-h-36 overflow-y-auto",children:e.map(l=>{const i=a.has(l.id);return t.jsxs("div",{className:"thread-composer-pending-row flex min-h-10 items-center gap-2 border-t px-3 py-2",children:[t.jsx("p",{className:"min-w-0 flex-1 truncate text-sm text-[var(--theme-fg)]",title:l.prompt,children:l.prompt}),l.optimistic?t.jsxs("span",{className:"inline-flex h-8 items-center gap-1.5 px-1.5 text-xs text-[var(--theme-fg-muted)]",children:[t.jsx(_.Loader2,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":"true"}),"Queueing"]}):t.jsxs(t.Fragment,{children:[r?t.jsxs("button",{type:"button",disabled:i,onClick:()=>void o(l.id,r),className:"thread-composer-steer-button inline-flex h-8 items-center gap-1.5 rounded-lg border px-2.5 text-xs font-medium transition disabled:cursor-wait disabled:opacity-60",children:[i?t.jsx(_.Loader2,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":"true"}):t.jsx(_.CornerUpRight,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Steer"]}):null,n?t.jsx("button",{type:"button",disabled:i,"aria-label":"Remove queued prompt",title:"Remove from queue",onClick:()=>void o(l.id,n),className:"thread-composer-queue-remove inline-flex h-8 w-8 items-center justify-center rounded-lg transition disabled:cursor-wait disabled:opacity-60",children:t.jsx(_.X,{className:"h-4 w-4","aria-hidden":"true"})}):null]})]},l.id)})})]})}function Sm({open:e,iconButtonClassName:r,menuClassName:n,menuItemClassName:a,onToggle:s,onPickPhoto:o,onPickFile:l}){return t.jsxs("div",{className:"relative",children:[t.jsx(Ct,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Add attachment",title:"Add attachment",onClick:s,className:`${r} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx(Vu,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${n} absolute bottom-full left-0 mb-2 w-32 overflow-hidden rounded-2xl border bg-stone-900/72 shadow-2xl shadow-stone-950/20`,children:t.jsxs("div",{className:"p-2",children:[t.jsx("button",{type:"button",onClick:o,className:`${a} block w-full rounded-xl px-3 py-2 text-left text-sm transition`,children:"Photo"}),t.jsx("button",{type:"button",onClick:l,className:`${a} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition`,children:"File"})]})})]})}var hl=[{mode:"read-only",label:"Read only"},{mode:"workspace-write",label:"Workspace write"},{mode:"danger-full-access",label:"Danger"}];function hs(e){var r;return((r=hl.find(n=>n.mode===e))==null?void 0:r.label)??"Default"}function Tm({openMenu:e,model:r,modelOptions:n,modelContextTitle:a,contextUsage:s,reasoningEffort:o,supportedEfforts:l,displayedCollaborationMode:i,sandboxMode:d,planModeAvailable:h,sandboxModeAvailable:u,settingsBusy:m,goalComposeMode:f,goalBusy:p,activeView:g,disabled:k,fastMode:w,sendButtonLabel:x,sendButtonClassName:j,modelControlsDisabled:y,effortControlsDisabled:b,effortControlTitle:v,inlineToggleClassName:S,menuItemClassName:N,planToggleActiveClassName:L,sendButtonBaseClassName:R,onSetOpenMenu:P,onUpdateSettings:Q}){var J;const K=(((J=n.find(B=>B.model===r))==null?void 0:J.displayName)||r||"Select model").replace(/\s+\([^)]+\)\s*$/,"");return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative min-w-0",children:[t.jsx(Ct,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="model","aria-label":r??"Select model",disabled:y||n.length===0,onClick:()=>P(B=>B==="model"?null:"model"),title:w?`Fast mode is on. Turn it off from the slash toolbox to edit model. ${a}`:a,className:`${S} relative min-w-0 max-w-[8.75rem] overflow-hidden rounded-full px-2.5 text-left text-stone-300 disabled:cursor-not-allowed disabled:text-stone-600 sm:max-w-[11rem]`,children:t.jsx("span",{className:"relative z-[1] block min-w-0 truncate whitespace-nowrap [direction:rtl]",children:K})}),r?t.jsx(am,{contextUsage:s}):null,e==="model"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[9rem] max-w-[14rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:n.map(B=>t.jsx("button",{type:"button",onClick:()=>Q({model:B.model,reasoningEffort:B.defaultReasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${B.model===r?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:B.displayName||B.model})},B.id))})})]}),t.jsxs("div",{className:"relative",children:[t.jsx(Ct,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="effort",disabled:b,onClick:()=>P(B=>B==="effort"?null:"effort"),title:v,className:`${S} rounded-full px-2 disabled:cursor-not-allowed disabled:text-stone-700 ${b?"text-stone-500":"text-stone-300 hover:text-stone-100"}`,children:ss(o)}),e==="effort"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[8rem] max-w-[12rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:l.map(B=>t.jsx("button",{type:"button",onClick:()=>Q({reasoningEffort:B.reasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${B.reasoningEffort===o?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:ss(B.reasoningEffort)})},B.reasoningEffort))})})]}),u&&t.jsxs("div",{className:"relative",children:[t.jsx(Ct,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="sandbox","aria-label":`Sandbox: ${hs(d)}`,disabled:m,onClick:()=>P(B=>B==="sandbox"?null:"sandbox"),title:`Sandbox: ${hs(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:hl.map(B=>t.jsx("button",{type:"button",onClick:()=>Q({sandboxMode:B.mode}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${B.mode===d?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:B.label})},B.mode))})})]}),h&&t.jsx(Ct,{type:"button",variant:"ghost",size:"xs","aria-pressed":i==="plan",disabled:m,onClick:()=>Q({collaborationMode:i==="plan"?"default":"plan"}),className:`${S} rounded-full px-2.5 ${i==="plan"?`${L} border !border-[oklch(0.78_0.16_86_/_0.76)] !bg-[oklch(0.44_0.095_82_/_0.72)] !text-[oklch(0.96_0.055_92)] shadow-[0_0_0_1px_oklch(0.78_0.16_86_/_0.24),0_0_18px_oklch(0.78_0.16_86_/_0.42),inset_0_0_0_1px_oklch(0.98_0.04_96_/_0.18)]`:"text-stone-500"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Plan"}),t.jsx(Ct,{type:"submit",variant:"default",size:"icon-xs","aria-label":f?"Set goal":"Send Prompt",title:x,disabled:p||(g==="chat"?k:!1),className:`${R} h-9 w-9 rounded-full text-sm font-medium disabled:cursor-not-allowed sm:h-8 sm:w-8 ${j}`,children:t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-none stroke-current",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M8 13V3"}),t.jsx("path",{d:"m4 7 4-4 4 4"})]})})]})}function Em({busy:e,shellControlState:r,onPaste:n,onCopy:a,onClear:s,onShellControl:o}){const l=!!(r!=null&&r.shellInputEnabled),i=!!(r!=null&&r.isCommandRunning);return t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute right-0 top-full z-40 mt-2 w-[11.5rem] max-w-[calc(100vw-1.5rem)] rounded-[1rem] border border-stone-700/90 bg-stone-950/96 p-2 shadow-2xl shadow-stone-950/40 sm:w-48",onMouseDown:d=>{d.stopPropagation()},onPointerDown:d=>{d.stopPropagation()},onTouchStart:d=>{d.stopPropagation()},children:t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx("button",{type:"button",onClick:n,className:"inline-flex items-center justify-center rounded-full border border-sky-300/35 bg-sky-300/12 px-2 py-2 text-sky-50",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Kn,{}),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(Kn,{}),t.jsx("span",{className:"text-[10px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:e,onClick:s,className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!l||!i,onClick:()=>o("ctrl_c"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CTRL-C",tone:"rose"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("ctrl_d"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CTRL-D"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("esc"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"ESC"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("tab"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"TAB"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("up"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"UP"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("down"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"DOWN"})})]})})}function Lm({busy:e,forkBusy:r,composerMenuItemClassName:n,onForkLatest:a,onSelectForkTurnPanel:s}){return t.jsxs("div",{className:"p-2",children:[t.jsx("button",{type:"button",disabled:e||r,onClick:()=>void a(),className:`${n} block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:"Fork from latest"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:r?"Forking":"Run"})]})}),t.jsx("button",{type:"button",disabled:e||r,onClick:o=>{o.stopPropagation(),s()},className:`${n} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:"Fork from selected turn"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:"Pick"})]})}),e?t.jsx("p",{className:"mt-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Fork is only available while the thread is idle."}):null]})}function Im({forkTurnOptionsState:e,forkBusy:r,composerPanelButtonClassName:n,onForkTurn:a}){var s,o;return t.jsxs("div",{className:"p-2",children:[e.status==="loading"&&!e.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading turns..."}):null,e.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:e.error}):null,(s=e.data)!=null&&s.length?t.jsx("div",{className:"space-y-2",children:e.data.map(l=>t.jsx("button",{type:"button",disabled:r,onClick:()=>void a(l.turnId),className:`${n} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("span",{className:"text-sm text-stone-100",children:["Turn ",l.turnIndex]}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:r?"Forking":l.status})]})},l.turnId))}):null,e.status!=="loading"&&!e.error&&(((o=e.data)==null?void 0:o.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No turns available to fork yet."}):null]})}function zm({hooksPanelMode:e,hooksState:r,hostConfigFilesAvailable:n,hookTrustAvailable:a,hookConfigBusy:s,hookConfigError:o,hookConfigSuccess:l,editingHookTarget:i,hookScope:d,hookEventName:h,hookMatcher:u,hookCommand:m,hookTimeoutSec:f,hookStatusMessage:p,composerChipButtonClassName:g,onResetHookForm:k,onSetHooksPanelMode:w,onClearHookConfigStatus:x,onSetEditingHookTarget:j,onSetHookScope:y,onSetHookEventName:b,onSetHookMatcher:v,onSetHookCommand:S,onSetHookTimeoutSec:N,onSetHookStatusMessage:L,onSaveHook:R,onStartEditingHook:P,onTrustHook:Q,onUntrustHook:K}){var J,B,z,te,se;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"Hook config sources"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:((J=r.data)==null?void 0:J.projectHooksPath)??"<workspace hooks config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:$=>{$.stopPropagation(),k(),w("add"),x()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add Hook"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading hooks..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,o?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:o}):null,l?t.jsx("p",{className:"mb-2 rounded-xl border border-emerald-500/35 bg-emerald-500/10 px-3 py-3 text-sm text-emerald-100/90",children:l}):null,e==="add"||e==="edit"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[e==="edit"?t.jsxs("p",{className:"rounded-lg border border-stone-800 bg-stone-950 px-3 py-2 text-[11px] text-stone-400",children:["Editing"," ",tm((i==null?void 0:i.eventName)??h)," ","in ",(i==null?void 0:i.scope)==="global"?"global":"project"," ","hooks.json"]}):null,t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("label",{className:"block text-xs text-stone-400",children:["Scope",t.jsxs("select",{"aria-label":"Hook scope",value:d,onChange:$=>y($.target.value),disabled:e==="edit",className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-2.5 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50",children:[t.jsx("option",{value:"project",children:"Project"}),t.jsx("option",{value:"global",children:"Global"})]})]}),t.jsxs("label",{className:"block text-xs text-stone-400",children:["Event",t.jsx("select",{"aria-label":"Hook event",value:h,onChange:$=>b($.target.value),className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-2.5 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50",children:Zr.map($=>t.jsx("option",{value:$.value,children:$.label},$.value))})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"Matcher"}),t.jsx("input",{"aria-label":"Hook matcher",value:u,onChange:$=>v($.target.value),placeholder:"Bash",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"Command"}),t.jsx("textarea",{"aria-label":"Hook command",value:m,onChange:$=>S($.target.value),rows:3,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 font-mono text-xs text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("label",{className:"block text-xs text-stone-400",children:["Timeout",t.jsx("input",{"aria-label":"Hook timeout seconds",value:f,onChange:$=>N($.target.value),inputMode:"numeric",className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50"})]}),t.jsxs("label",{className:"block text-xs text-stone-400",children:["Status message",t.jsx("input",{"aria-label":"Hook status message",value:p,onChange:$=>L($.target.value),className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50"})]})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>{w("list"),j(null)},className:`${g} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void R(),disabled:s,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:s?"Saving...":e==="edit"?"Update Hook":"Write Hook"})]})]}):null,e==="list"&&((B=r.data)!=null&&B.warnings.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.warnings.map($=>t.jsx("p",{className:"rounded-xl border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-100/85",children:$},$))}):null,e==="list"&&((z=r.data)!=null&&z.errors.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.errors.map($=>t.jsxs("div",{className:"rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-2 text-xs text-rose-100/90",children:[t.jsx("p",{className:"font-medium",children:$.message}),t.jsx("p",{className:"mt-1 break-all text-rose-100/60",children:$.path})]},`${$.path}:${$.message}`))}):null,e==="list"&&((te=r.data)!=null&&te.hooks.length)?t.jsx("div",{className:"space-y-2",children:r.data.hooks.map($=>t.jsxs("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("p",{className:"truncate text-sm font-medium text-stone-100",children:[Ju($.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:[dl($)?t.jsx("button",{type:"button",onClick:ie=>{ie.stopPropagation(),P($)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-sky-100 transition hover:border-sky-300/35 hover:bg-sky-300/10`,children:"Edit"}):null,a&&$.trustStatus==="trusted"&&!$.isManaged?t.jsx("button",{type:"button",disabled:s,onClick:ie=>{ie.stopPropagation(),K($)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-amber-100 transition hover:border-amber-300/35 hover:bg-amber-300/10 disabled:cursor-not-allowed disabled:opacity-50`,children:"Untrust"}):null,($.trustStatus==="untrusted"||$.trustStatus==="modified")&&!$.isManaged&&a?t.jsx("button",{type:"button",disabled:s||!$.currentHash,onClick:ie=>{ie.stopPropagation(),Q($)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-emerald-100 transition hover:border-emerald-300/35 hover:bg-emerald-300/10 disabled:cursor-not-allowed disabled:opacity-50`,children:"Trust"}):null,t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-0.5 text-stone-300",children:em($.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:Qu($.source)}),t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:$.enabled?"Enabled":"Disabled"}),t.jsxs("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:[$.timeoutSec,"s"]})]})]},$.key))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((se=r.data)==null?void 0:se.hooks.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No hooks configured for this workspace."}):null]})}function Vr(e){return e.localGoalId??`${e.createdAt}:${e.objective}`}function Pm(e,r){const n=e?[e,...r]:r,a=new Set;return n.filter(s=>{const o=Vr(s);return a.has(o)?!1:(a.add(o),!0)})}function Rm(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 Am(e){switch(e){case"budgetLimited":return"Budget limited";case"complete":return"Complete";case"terminated":return"Terminated";case"paused":return"Paused";default:return"Active"}}function Mm({goalState:e,goalHistory:r,busy:n,onBack:a,onUpdateGoal:s}){const o=Pm(e.data,r),l=e.data?Vr(e.data):null;return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-h-11 items-center justify-between gap-3 border-b border-[var(--theme-border)] px-3 py-2",children:[t.jsx("button",{type:"button",onClick:a,className:"min-h-9 rounded-lg px-2 text-xs font-medium text-[var(--theme-fg-muted)] transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--theme-accent-border)]",children:"Back"}),t.jsx("span",{className:"text-xs font-semibold text-[var(--theme-fg)]",children:"Goals"})]}),e.error?t.jsx("p",{className:"m-3 rounded-lg border border-[var(--status-danger-border)] bg-[var(--status-danger-bg)] px-3 py-2 text-xs text-[var(--status-danger-fg)]",children:e.error}):null,e.status==="loading"&&o.length===0?t.jsxs("div",{className:"space-y-2 p-3",role:"status","aria-label":"Loading goals",children:[t.jsx("div",{className:"h-12 animate-pulse rounded-lg bg-[var(--theme-muted)] motion-reduce:animate-none"}),t.jsx("div",{className:"h-12 animate-pulse rounded-lg bg-[var(--theme-muted)] motion-reduce:animate-none"})]}):o.length===0?t.jsx("p",{className:"px-4 py-5 text-center text-sm text-[var(--theme-fg-muted)]",children:"No goals in this thread yet."}):t.jsx("div",{className:"max-h-72 divide-y divide-[var(--theme-border)] overflow-y-auto",children:o.map(i=>{const d=Vr(i)===l&&["active","paused","budgetLimited"].includes(i.status);return t.jsxs("div",{className:"px-3 py-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx("p",{className:"min-w-0 flex-1 text-sm font-medium leading-5 text-[var(--theme-fg)]",children:i.objective}),t.jsx("span",{className:"shrink-0 rounded-full border border-[var(--theme-border)] px-2 py-1 text-[10px] font-medium text-[var(--theme-fg-muted)]",children:Am(i.status)})]}),t.jsxs("p",{className:"mt-1.5 text-[11px] text-[var(--theme-fg-muted)]",children:[Rm(i.timeUsedSeconds)," · ",i.tokensUsed.toLocaleString()," tokens"]}),d&&s?t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsx("button",{type:"button",disabled:n||i.status==="active",onClick:()=>void s({status:"active"}),className:"min-h-9 rounded-lg border border-[var(--theme-border)] px-3 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:opacity-45",children:"Continue"}),t.jsx("button",{type:"button",disabled:n||i.status==="paused",onClick:()=>void s({status:"paused"}),className:"min-h-9 rounded-lg border border-[var(--theme-border)] px-3 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:opacity-45",children:"Pause"}),t.jsx("button",{type:"button",disabled:n,onClick:()=>void s({status:"terminated"}),className:"min-h-9 rounded-lg px-3 text-xs font-medium text-[var(--status-danger-fg)] transition hover:bg-[var(--status-danger-bg)] disabled:cursor-not-allowed disabled:opacity-45",children:"Terminate"})]}):null]},Vr(i))})})]})}function _m({mcpPanelMode:e,mcpState:r,mcpConfigEditing:n,mcpConfigPath:a,mcpConfigError:s,mcpConfigSuccess:o,mcpConfigBusy:l,mcpHttpName:i,mcpHttpUrl:d,mcpRawBlock:h,composerPanelButtonClassName:u,composerChipButtonClassName:m,onSetMcpPanelMode:f,onClearMcpConfigStatus:p,onSetMcpHttpName:g,onSetMcpHttpUrl:k,onSetMcpRawBlock:w,onPrepareRawMcpBlock:x,onSaveHttpMcp:j,onSaveRawMcpBlock:y}){var b,v;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"MCP config source"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:a??"<provider config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),f("add"),p()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add MCP"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading MCP servers..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,s?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:s}):null,o?t.jsx("p",{className:"mb-2 rounded-xl border border-emerald-500/35 bg-emerald-500/10 px-3 py-3 text-sm text-emerald-100/90",children:o}):null,e==="add"?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:S=>{S.stopPropagation(),f("http"),p()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"HTTP / Streamable HTTP"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"Form"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Add an MCP server with a name and URL, then write the matching block into provider config."})]}),t.jsxs("button",{type:"button",onClick:S=>{S.stopPropagation(),x()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"stdio / raw block"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"TOML"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Write a single `[mcp_servers.name]` block, then save it back into provider config."})]})]}):null,e==="http"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"MCP name"}),t.jsx("input",{"aria-label":"MCP name",value:i,onChange:S=>g(S.target.value),placeholder:"openaiDeveloperDocs",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"URL"}),t.jsx("input",{"aria-label":"URL",value:d,onChange:S=>k(S.target.value),placeholder:"https://developers.openai.com/mcp",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void j(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write HTTP MCP"})]})]}):null,e==="stdio"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsx("label",{className:"block text-xs text-stone-400",children:"MCP block for provider config"}),t.jsx("textarea",{"aria-label":"MCP block for provider config",value:h,onChange:S=>w(S.target.value),rows:8,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void y(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write raw block"})]})]}):null,e==="list"&&((b=r.data)!=null&&b.servers.length)?t.jsx("div",{className:"space-y-2",children:r.data.servers.map(S=>t.jsxs("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:S.name}),t.jsxs("p",{className:"mt-0.5 text-xs text-stone-400",children:[S.tools.length," tools · ",S.resourceCount," ","resources · ",S.resourceTemplateCount," templates"]})]}),t.jsx("span",{className:"shrink-0 rounded-full border border-stone-700 px-2 py-1 text-[10px] uppercase tracking-[0.14em] text-stone-300",children:Yu(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 $m({skillsState:e,copiedSkillName:r,composerChipButtonClassName:n,onCopySkillInvokeName:a}){var s,o,l,i;return t.jsxs("div",{className:"p-2",children:[e.status==="loading"&&!e.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading skills..."}):null,e.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:e.error}):null,(s=e.data)!=null&&s.skills.length?t.jsx("div",{className:"space-y-2",children:e.data.skills.map(d=>{var h,u;return t.jsx("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:((h=d.interface)==null?void 0:h.displayName)??d.name}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.14em]",children:[t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1 text-stone-400",children:Zu(d.scope)}),t.jsxs("button",{type:"button",className:`inline-flex items-center gap-1 rounded-full border px-2 py-1 normal-case tracking-normal transition ${r===d.name?"border-emerald-400/45 bg-emerald-400/12 text-emerald-100":`${n} border-stone-700 text-stone-300 hover:border-stone-500`}`,onClick:()=>void a(d.name),title:`Copy $${d.name}`,"aria-label":`Copy $${d.name}`,children:[t.jsx(Kn,{}),"$",d.name]})]}),t.jsx("p",{className:"text-xs leading-5 text-stone-400",children:((u=d.interface)==null?void 0:u.shortDescription)??d.shortDescription??d.description})]})},d.path)})}):null,(o=e.data)!=null&&o.errors.length?t.jsx("div",{className:"mt-2 space-y-2",children:e.data.errors.map(d=>t.jsxs("div",{className:"rounded-xl border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-100/85",children:[t.jsx("p",{className:"font-medium",children:d.message}),t.jsx("p",{className:"mt-1 break-all text-amber-100/60",children:d.path})]},`${d.path}:${d.message}`))}):null,e.status!=="loading"&&!e.error&&(((l=e.data)==null?void 0:l.skills.length)??0)===0&&(((i=e.data)==null?void 0:i.errors.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No skills available right now."}):null]})}function Dm({open:e,slashPanelView:r,availableToolboxItems:n,busy:a,forkBusy:s,forkTurnOptionsState:o,skillsState:l,goalState:i,goalHistory:d,goalBusy:h,copiedSkillName:u,hooksPanelMode:m,hooksState:f,hostConfigFilesAvailable:p,hookTrustAvailable:g,hookConfigBusy:k,hookConfigError:w,hookConfigSuccess:x,editingHookTarget:j,hookScope:y,hookEventName:b,hookMatcher:v,hookCommand:S,hookTimeoutSec:N,hookStatusMessage:L,mcpPanelMode:R,mcpState:P,mcpConfigEditing:Q,mcpConfigPath:K,mcpConfigError:J,mcpConfigSuccess:B,mcpConfigBusy:z,mcpHttpName:te,mcpHttpUrl:se,mcpRawBlock:$,iconButtonClassName:ie,menuClassName:q,menuItemClassName:H,panelButtonClassName:G,chipButtonClassName:T,onToggle:F,onToolboxItemClick:D,toolboxItemDisabled:E,toolboxItemClassName:C,toolboxItemStatus:W,onSetSlashPanelView:U,onViewGoals:ae,onUpdateGoal:X,onOpenForkTurns:de,onForkLatest:ee,onForkTurn:ke,onCopySkillInvokeName:le,onResetHookForm:je,onSetHooksPanelMode:Ae,onClearHookConfigStatus:ce,onSetEditingHookTarget:ne,onSetHookScope:Le,onSetHookEventName:Z,onSetHookMatcher:me,onSetHookCommand:we,onSetHookTimeoutSec:ye,onSetHookStatusMessage:De,onSaveHook:Be,onStartEditingHook:$e,onTrustHook:Oe,onUntrustHook:V,onSetMcpPanelMode:he,onClearMcpConfigStatus:ve,onSetMcpHttpName:I,onSetMcpHttpUrl:O,onSetMcpRawBlock:oe,onPrepareRawMcpBlock:ge,onSaveHttpMcp:Ne,onSaveRawMcpBlock:Ce}){return t.jsxs("div",{className:"relative",children:[t.jsx(Ct,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Open slash toolbox",title:"Open slash toolbox",onClick:F,className:`${ie} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx(qu,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${q} absolute bottom-full left-0 z-40 mb-2 w-72 overflow-hidden rounded-2xl border bg-stone-900/72 shadow-2xl shadow-stone-950/20 backdrop-blur-xl`,onClick:xe=>{xe.stopPropagation()},onMouseDown:xe=>{xe.stopPropagation()},onPointerDown:xe=>{xe.stopPropagation()},onTouchStart:xe=>{xe.stopPropagation()},children:r==="root"?t.jsxs("div",{className:"p-2",children:[n.map((xe,Ge)=>xe.action==="goal"?t.jsxs("div",{className:`mt-1 flex min-h-11 overflow-hidden rounded-xl border border-[var(--theme-border)] ${Ge===0?"mt-0":""}`,title:xe.description??xe.label,children:[t.jsx("button",{type:"button",disabled:E(xe),onClick:()=>{U("goals"),ae==null||ae()},className:"min-w-0 flex-1 px-3 py-2.5 text-left text-sm text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--theme-accent-border)] disabled:cursor-not-allowed disabled:opacity-45","aria-label":"View goals",children:t.jsx("span",{children:xe.command})}),t.jsx("button",{type:"button",disabled:E(xe),onClick:Me=>D(xe,Me),className:"min-w-14 border-l border-[var(--theme-border)] px-3 text-xs font-semibold text-[var(--theme-fg-muted)] transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)] focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--theme-accent-border)] disabled:cursor-not-allowed disabled:opacity-45","aria-label":"Open goal composer",children:"Open"})]},`${xe.action}:${xe.command}`):t.jsx("button",{type:"button",disabled:E(xe),onClick:Me=>D(xe,Me),className:`${C(xe)} ${Ge===0?"mt-0":""}`,title:xe.description??xe.label,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:xe.command}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:W(xe)})]})},`${xe.action}:${xe.command}`)),n.length===0?t.jsx("p",{className:"px-3 py-2 text-sm text-stone-400",children:"No backend tools are available for this thread."}):null]}):t.jsx("div",{className:"max-h-80 overflow-auto",children:r==="goals"?t.jsx(Mm,{goalState:i,goalHistory:d,busy:h,onBack:()=>U("root"),onUpdateGoal:X}):r==="fork"?t.jsx(Lm,{busy:a,forkBusy:s,composerMenuItemClassName:H,onForkLatest:ee,onSelectForkTurnPanel:()=>(U("forkTurns"),de())}):r==="forkTurns"?t.jsx(Im,{forkTurnOptionsState:o,forkBusy:s,composerPanelButtonClassName:G,onForkTurn:ke}):r==="skills"?t.jsx($m,{skillsState:l,copiedSkillName:u,composerChipButtonClassName:T,onCopySkillInvokeName:le}):r==="hooks"?t.jsx(zm,{hooksPanelMode:m,hooksState:f,hostConfigFilesAvailable:p,hookTrustAvailable:g,hookConfigBusy:k,hookConfigError:w,hookConfigSuccess:x,editingHookTarget:j,hookScope:y,hookEventName:b,hookMatcher:v,hookCommand:S,hookTimeoutSec:N,hookStatusMessage:L,composerChipButtonClassName:T,onResetHookForm:je,onSetHooksPanelMode:Ae,onClearHookConfigStatus:ce,onSetEditingHookTarget:ne,onSetHookScope:Le,onSetHookEventName:Z,onSetHookMatcher:me,onSetHookCommand:we,onSetHookTimeoutSec:ye,onSetHookStatusMessage:De,onSaveHook:Be,onStartEditingHook:$e,onTrustHook:Oe,onUntrustHook:V}):t.jsx(_m,{mcpPanelMode:R,mcpState:P,mcpConfigEditing:Q,mcpConfigPath:K,mcpConfigError:J,mcpConfigSuccess:B,mcpConfigBusy:z,mcpHttpName:te,mcpHttpUrl:se,mcpRawBlock:$,composerPanelButtonClassName:G,composerChipButtonClassName:T,onSetMcpPanelMode:he,onClearMcpConfigStatus:ve,onSetMcpHttpName:I,onSetMcpHttpUrl:O,onSetMcpRawBlock:oe,onPrepareRawMcpBlock:ge,onSaveHttpMcp:Ne,onSaveRawMcpBlock:Ce})})})]})}function Bm({isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:s,toolbarClassName:o,iconButtonClassName:l,slashToolboxProps:i,attachmentMenuProps:d,settingsToolbarProps:h,shellToolsPanelProps:u,onToggleView:m,onDismissPromptFocus:f,onSetOpenMenu:p}){return t.jsxs(xm,{align:"block-end",className:`${o} relative z-30 mb-0 flex items-center gap-2 text-xs`,children:[t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[!e&&i?t.jsx(Dm,{...i}):null,!e&&d?t.jsx(Sm,{...d}):null,r&&t.jsx(Ct,{type:"button",variant:"ghost",size:"icon-xs","aria-label":e?"Switch to chat":"Switch to shell",title:e?"Switch to chat":"Switch to shell",onClick:()=>m==null?void 0:m(),className:`${l} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:e?t.jsx(Xu,{}):t.jsx(Uu,{})})]}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-end gap-1.5",children:[!e&&h?t.jsx(Tm,{...h}):null,e&&a?t.jsx(vm,{className:"min-w-0 max-w-[12rem] truncate rounded-full px-1.5 py-1 text-stone-400",title:a,children:a}):null,n&&t.jsxs("div",{className:"relative",children:[t.jsx("button",{type:"button","data-composer-menu-trigger":"true","aria-label":s==="shellTools"?"Close shell tools":"Open shell tools","aria-haspopup":"menu","aria-expanded":s==="shellTools",title:s==="shellTools"?"Close shell tools":"Open shell tools",onClick:()=>{f(),p(g=>g==="shellTools"?null:"shellTools")},className:"inline-flex h-7 w-7 items-center justify-center rounded-full border border-stone-700 bg-stone-900/92 text-stone-200 transition hover:bg-stone-800",children:t.jsx(Ku,{})}),s==="shellTools"&&u?t.jsx(Em,{...u}):null]})]})]})}function Gm(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`attachment-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function Fm(e){return[...e.filter(r=>qn(r)==="photo"),...e.filter(r=>qn(r)==="file")]}function Hm({prompt:e,attachments:r,updateDraft:n,getSelection:a,selectionSnapshotRef:s,pendingSelectionRef:o,pendingInsertedAttachmentIdsRef:l,onInserted:i,buildClientId:d=Gm}){const h=c.useCallback((f,p)=>{if(f.length===0)return!1;const g=Eu({prompt:e,attachments:r,files:f,selection:a()??s.current,kindForFile:p,buildClientId:d});return n(()=>g.draft),o.current=g.selection,s.current=g.selection,l.current=g.insertedAttachmentIds,i==null||i(),!0},[r,d,a,i,l,o,e,s,n]),u=c.useCallback((f,p)=>!f||f.length===0?!1:h(Array.from(f),()=>p),[h]),m=c.useCallback(f=>h(Fm(f),qn),[h]);return{appendAttachments:u,appendDroppedAttachments:m}}function us(e){for(const r of e.values())URL.revokeObjectURL(r);e.clear()}function Om({attachments:e,isShellView:r}){const n=c.useRef(new Map),[a,s]=c.useState({});return c.useEffect(()=>{const o=n.current;if(r){us(o),s({});return}const l={},i=new Set;for(const d of e){if(d.kind!=="photo")continue;i.add(d.clientId);let h=o.get(d.clientId);h||(h=URL.createObjectURL(d.file),o.set(d.clientId,h)),l[d.clientId]=h}for(const[d,h]of o.entries())i.has(d)||(URL.revokeObjectURL(h),o.delete(d));s(l)},[e,r]),c.useEffect(()=>{const o=n.current;return()=>{us(o)}},[]),a}var Wm=180;function Tn(e,r){return{prompt:e??"",attachments:r??[]}}function Um({isShellView:e,draftPrompt:r,draftAttachments:n,onDraftChange:a}){const[s,o]=c.useState({prompt:"",attachments:[]}),[l,i]=c.useState(()=>Tn(r,n)),d=c.useRef(null),h=c.useRef(l),u=c.useRef($r(l)),m=!e&&r!==void 0&&n!==void 0&&typeof a=="function",f=m?$r(Tn(r,n)):"",p=c.useRef(f);c.useLayoutEffect(()=>{if(!m){p.current="";return}const y=Tn(r,n),b=$r(y);b!==p.current&&(p.current=b,u.current=b,h.current=y,d.current!==null&&(window.clearTimeout(d.current),d.current=null),i(y))},[n,r,m]);const g=c.useCallback(y=>{if(!m||!a)return;const b=$r(y);b!==u.current&&(u.current=b,a(()=>({prompt:y.prompt,attachments:y.attachments})))},[m,a]);c.useEffect(()=>()=>{g(h.current),d.current!==null&&window.clearTimeout(d.current)},[g]);const k=c.useCallback((y,b)=>{if(m){if(d.current!==null&&(window.clearTimeout(d.current),d.current=null),b==="immediate"){g(y);return}d.current=window.setTimeout(()=>{d.current=null,g(h.current)},Wm)}},[m,g]),w=c.useCallback((y=h.current)=>{k(y,"immediate")},[k]),x=c.useCallback((y,b="immediate")=>{if(m){const v=y(h.current);h.current=v,i(v),k(v,b);return}o(v=>y(v))},[m,k]),j=m?l:s;return{prompt:j.prompt,attachments:j.attachments,isDraftControlled:m,updateDraft:x,flushControlledDraftToHost:w}}function Vm({slashPanelView:e,onForkLatest:r,onForkTurn:n,closeMenu:a}){const[s,o]=c.useState(!1);c.useEffect(()=>{e!=="forkTurns"&&o(!1)},[e]);const l=c.useCallback(async()=>{if(r){o(!0);try{await r(),a()}finally{o(!1)}}},[a,r]),i=c.useCallback(async d=>{if(n){o(!0);try{await n(d),a()}finally{o(!1)}}},[a,n]);return{forkBusy:s,forkLatest:l,forkTurn:i}}function qm({prompt:e,goalTokenBudgetSource:r,promptRef:n,onOpenGoal:a,onPrepareGoalSubmit:s,onUpdateGoal:o,updateDraft:l,closeMenu:i,resetSlashPanel:d}){const[h,u]=c.useState(!1),[m,f]=c.useState(""),[p,g]=c.useState(!1),[k,w]=c.useState(null),x=c.useCallback(async()=>{const b=e.trim();if(!b)return w("Goal objective cannot be empty."),!1;const v=m.trim(),S=Au(v);if(v.length>0&&(S===null||!Number.isInteger(S)||S<=0))return w("Token budget must be a positive number in thousands."),!1;if(!o)return w("/goal is unavailable in this view."),!1;g(!0),w(null);try{return s&&await s({objective:b,tokenBudget:S})===!1?!1:(await o({objective:b,status:"active",tokenBudget:S}),f(""),u(!1),l(()=>({prompt:"",attachments:[]})),!0)}catch(N){return w(N instanceof Error?N.message:"Unable to set goal."),!1}finally{g(!1)}},[m,s,o,e,l]),j=c.useCallback(()=>{i(),d(),u(!0),f(Mu(r==null?void 0:r.tokenBudget)),w(null),a==null||a(),requestAnimationFrame(()=>{var b;(b=n.current)==null||b.focus()})},[i,r==null?void 0:r.tokenBudget,a,n,d]),y=c.useCallback(()=>{u(!1),w(null)},[]);return{goalComposeMode:h,goalTokenBudget:m,goalBusy:p,goalLocalError:k,setGoalTokenBudget:f,submitGoal:x,enterGoalComposeMode:j,exitGoalComposeMode:y}}var En=`node -e "process.stdin.resume(); process.stdin.on('end', () => console.error('hook ran'))"`;function Xm(e){const r=new Map;for(const n of e??[])r.set(n.eventName,n.command);return r}function Km({slashPanelView:e,hookCommandTemplates:r,onCreateHook:n,onUpdateHook:a,onTrustHook:s,onUntrustHook:o}){const[l,i]=c.useState("list"),[d,h]=c.useState("project"),[u,m]=c.useState("preToolUse"),[f,p]=c.useState("Bash"),[g,k]=c.useState(En),[w,x]=c.useState("30"),[j,y]=c.useState("Running hook"),[b,v]=c.useState(null),[S,N]=c.useState(!1),[L,R]=c.useState(null),[P,Q]=c.useState(null),K=c.useMemo(()=>Xm(r),[r]),J=c.useCallback(H=>K.get(H)??K.get("preToolUse")??En,[K]),B=c.useMemo(()=>new Set([En,...K.values()]),[K]),z=c.useCallback(()=>{R(null),Q(null)},[]);c.useEffect(()=>{e!=="hooks"&&(i("list"),z())},[z,e]),c.useEffect(()=>{const H=Zr.find(G=>G.value===u);p(G=>{const T=G.trim(),F=new Set(Zr.map(D=>D.matcherHint).filter(Boolean));return T&&!F.has(T)?G:(H==null?void 0:H.matcherHint)??""}),k(G=>B.has(G.trim())?J(u):G)},[J,B,u]);const te=c.useCallback(()=>{v(null),h("project"),m("preToolUse"),p("Bash"),k(J("preToolUse")),x("30"),y("Running hook")},[J]),se=c.useCallback(H=>{const G=dl(H);if(!G){R("Only command hooks in global or project hooks.json can be edited here.");return}v(G),h(G.scope),m(G.eventName),p(G.matcher??""),k(G.command),x(G.timeoutSec?String(G.timeoutSec):""),y(G.statusMessage??""),R(null),Q(null),i("edit")},[]),$=c.useCallback(async()=>{if(l==="edit"&&!a){R("Hook editing is unavailable in this view.");return}if(l!=="edit"&&!n){R("Hook editing is unavailable in this view.");return}if(l==="edit"&&!b){R("Select a hook to edit first.");return}const H=g.trim();if(!H){R("Hook command cannot be empty.");return}const G=w.trim(),T=G?Number(G):null;if(G&&(T===null||!Number.isInteger(T)||T<=0)){R("Timeout must be a positive number of seconds.");return}N(!0),R(null),Q(null);try{const F={scope:d,eventName:u,matcher:f.trim()||null,command:H,timeoutSec:T,statusMessage:j.trim()||null};l==="edit"?await(a==null?void 0:a({...F,target:b})):await(n==null?void 0:n(F)),Q(`${d==="project"?"Project":"Global"} hook ${l==="edit"?"updated":"written"} in hooks.json and trusted.`),i("list"),v(null)}catch(F){R(F instanceof Error?F.message:"Unable to write hooks.json.")}finally{N(!1)}},[b,g,u,f,d,j,w,l,n,a]),ie=c.useCallback(async H=>{if(!s||!H.currentHash){R("Hook trust is unavailable in this view.");return}N(!0),R(null),Q(null);try{await s({key:H.key,currentHash:H.currentHash}),Q("Hook trusted.")}catch(G){R(G instanceof Error?G.message:"Unable to trust hook.")}finally{N(!1)}},[s]),q=c.useCallback(async H=>{if(!o){R("Hook trust is unavailable in this view.");return}N(!0),R(null),Q(null);try{await o({key:H.key}),Q("Hook untrusted.")}catch(G){R(G instanceof Error?G.message:"Unable to untrust hook.")}finally{N(!1)}},[o]);return{hooksPanelMode:l,hookScope:d,hookEventName:u,hookMatcher:f,hookCommand:g,hookTimeoutSec:w,hookStatusMessage:j,editingHookTarget:b,hookConfigBusy:S,hookConfigError:L,hookConfigSuccess:P,setHooksPanelMode:i,setEditingHookTarget:v,setHookScope:h,setHookEventName:m,setHookMatcher:p,setHookCommand:k,setHookTimeoutSec:x,setHookStatusMessage:y,clearHookConfigStatus:z,resetHookForm:te,startEditingHook:se,saveHook:$,trustHook:ie,untrustHook:q}}var Ym=`[mcp_servers.example_stdio]
|
|
3689
3689
|
command = "npx"
|
|
3690
3690
|
args = ["-y", "your-mcp-server"]
|
|
3691
|
-
`,hs="MCP entry written to provider config. Restart the backend if it does not appear immediately.";function qm({hostConfigFilesAvailable:e,onReadProviderConfig:r,onWriteProviderConfig:n,setMcpPanelMode:a,onOpenMcp:s}){const[o,l]=c.useState(""),[i,d]=c.useState(""),[h,u]=c.useState(""),[m,f]=c.useState(null),[p,g]=c.useState(!1),[k,w]=c.useState(null),[x,j]=c.useState(null),y=c.useCallback(()=>{w(null),j(null)},[]),b=c.useCallback(async()=>{if(!e||!r)throw new Error("Provider config editing is unavailable for this thread.");const R=await r();return f(R.path),R},[e,r]),v=c.useCallback(async R=>{if(!e||!n)throw new Error("Provider config editing is unavailable for this thread.");const P=await n(R);return f(P.path),P},[e,n]),S=c.useCallback(async()=>{const R=Pu(o),P=i.trim();if(!R){w("MCP name must use only letters, numbers, underscore, or hyphen.");return}if(!/^https?:\/\//i.test(P)){w("HTTP MCP URL must start with http:// or https://");return}g(!0),w(null),j(null);try{const Q=await b(),D=as(Q.content,R,Au(R,P));await v(D),j(hs),a("list"),l(""),d(""),s==null||s()}catch(Q){w(Q instanceof Error?Q.message:"Unable to update provider config.")}finally{g(!1)}},[b,o,i,s,a,v]),N=c.useCallback(async()=>{g(!0),w(null),j(null);try{await b(),u(R=>R||Vm),a("stdio")}catch(R){w(R instanceof Error?R.message:"Unable to load provider config.")}finally{g(!1)}},[b,a]),L=c.useCallback(async()=>{const R=Ru(h);if(!R){w("The raw MCP block must start with a header like [mcp_servers.name].");return}g(!0),w(null),j(null);try{const P=await b(),Q=as(P.content,R,h);await v(Q),j(hs),a("list"),s==null||s()}catch(P){w(P instanceof Error?P.message:"Unable to update provider config.")}finally{g(!1)}},[b,h,s,a,v]);return{mcpHttpName:o,mcpHttpUrl:i,mcpRawBlock:h,mcpConfigPath:m,mcpConfigBusy:p,mcpConfigError:k,mcpConfigSuccess:x,setMcpHttpName:l,setMcpHttpUrl:d,setMcpRawBlock:u,clearMcpConfigStatus:y,prepareRawMcpBlock:N,saveHttpMcp:S,saveRawMcpBlock:L}}function Km({openMenu:e,setOpenMenu:r,slashPanelView:n,setSlashPanelView:a,setMcpPanelMode:s,clearMcpConfigStatus:o,clearHookConfigStatus:l}){const[i,d]=c.useState(null);c.useEffect(()=>{e!=="slash"&&(a("root"),s("list"),o(),l())},[l,o,e,s,a]),c.useEffect(()=>{n!=="mcp"&&(s("list"),o())},[o,s,n]),c.useEffect(()=>{if(!i)return;const u=window.setTimeout(()=>{d(m=>m===i?null:m)},1400);return()=>{window.clearTimeout(u)}},[i]),c.useEffect(()=>{function u(m){(typeof m.composedPath=="function"?m.composedPath():[]).some(g=>g instanceof HTMLElement&&(g.dataset.composerMenuSurface==="true"||g.dataset.composerMenuTrigger==="true"))||e&&r(null)}if(e)return window.addEventListener("pointerdown",u),()=>{window.removeEventListener("pointerdown",u)}},[e,r]);const h=c.useCallback(async u=>{try{await navigator.clipboard.writeText(`$${u}`),d(u)}catch{d(null)}},[]);return{copiedSkillName:i,copySkillInvokeName:h}}function Xm(e,r){const{attachment:n}=e,a=document.createElement("span");if(a.dataset.segmentType="attachment",a.dataset.clientId=n.clientId,a.dataset.placeholder=n.placeholder,a.contentEditable="false",a.className="thread-composer-attachment-chip mx-[0.12rem] inline-flex max-w-full align-baseline",n.kind==="photo"){a.classList.add("thread-composer-attachment-chip-photo","rounded-[0.95rem]","border","border-sky-300/35","bg-sky-300/10","p-1","shadow-sm","shadow-stone-950/20");const l=r[n.clientId];if(l){const d=document.createElement("img");d.src=l,d.alt=n.originalName||"Pasted image",d.className="thread-composer-attachment-thumb h-[4.5rem] w-[6rem] rounded-[0.7rem] bg-stone-950 object-contain",d.draggable=!1,a.append(d)}else{const d=document.createElement("span");d.className="thread-composer-attachment-thumb inline-block h-[4.5rem] w-[6rem] rounded-[0.7rem] bg-stone-900/80",d.setAttribute("aria-hidden","true"),a.append(d)}const i=document.createElement("span");return i.className="thread-composer-attachment-caption ml-2 inline-flex max-w-[8rem] items-center text-[10px] font-medium tracking-[0.08em] text-sky-50",i.textContent=os(n),a.append(i),a}a.classList.add("items-center","gap-2","rounded-[0.95rem]","border","border-emerald-300/35","bg-emerald-300/10","px-2.5","py-2","text-[10px]","font-medium","tracking-[0.08em]","text-emerald-50","shadow-sm","shadow-stone-950/20");const s=document.createElement("span");s.className="inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-emerald-200/25 bg-emerald-300/12 text-[9px]",s.textContent="FILE";const o=document.createElement("span");return o.className="inline-flex max-w-[10rem] truncate",o.textContent=os(n),a.append(s,o),a}function Ym(e,r){const n=document.createDocumentFragment();for(const a of e){if(a.type==="text"){n.append(document.createTextNode(a.text===" "?" ":a.text));continue}n.append(Xm(a,r))}return n}function Zm({promptRef:e,isShellView:r,prompt:n,promptSegments:a,attachmentPreviewUrls:s,previewSignature:o,editorSanitizeNonce:l,pendingSelectionRef:i,pendingInsertedAttachmentIdsRef:d,selectionSnapshotRef:h,renderedPreviewSignatureRef:u,renderedSanitizeNonceRef:m,serializeEditorPrompt:f,restoreSelection:p}){c.useLayoutEffect(()=>{const g=e.current;if(!g||r)return;const k=i.current,w=f()!==n||u.current!==o||m.current!==l;w&&(g.replaceChildren(Ym(a,s)),u.current=o,m.current=l),k!==null?(g.focus(),cm(g,d.current)||p(k),h.current=k):document.activeElement===g&&w&&p(h.current),i.current=null,d.current=[]},[s,l,r,o,n,e,a,d,i,u,m,p,h,f])}function Jm({tokenBudget:e,error:r,onTokenBudgetChange:n,onCancel:a}){return t.jsxs("div",{className:"thread-goal-compose-card relative z-20 mb-1.5 flex flex-wrap items-center gap-2 rounded-2xl border px-3 py-2 text-xs shadow-sm",children:[t.jsx("span",{className:"thread-goal-compose-label font-medium uppercase tracking-[0.16em]",children:"Goal"}),t.jsxs("label",{className:"thread-goal-compose-field flex items-center gap-2",children:[t.jsx("span",{children:"Max tokens (k)"}),t.jsx("input",{"aria-label":"Goal token budget",value:e,onChange:s=>n(s.target.value),inputMode:"numeric",placeholder:"Optional",className:"thread-goal-compose-input h-7 w-24 rounded-full border px-3 text-xs outline-none"})]}),r?t.jsx("span",{className:"thread-goal-compose-error min-w-0 flex-1",children:r}):null,t.jsx("button",{type:"button",onClick:a,className:"thread-goal-compose-cancel rounded-full border px-2.5 py-1 text-[11px] transition",children:"Cancel"})]})}function Qm({promptRef:e,prompt:r,disabled:n,promptPlaceholder:a,canInterrupt:s,interruptLabel:o,composerPromptRegionClassName:l,graphChatInputClassName:i,onInterrupt:d,onInput:h,onPointerDown:u,onPaste:m,onKeyDown:f,onKeyUp:p,onMouseUp:g,onBlur:k,onDragEnter:w,onDragOver:x,onDragLeave:j,onDrop:y}){return t.jsxs("div",{"data-slot":"input-group-control",className:`${l} relative w-full`,children:[t.jsxs("div",{className:i,children:[r.length===0&&t.jsx("span",{className:`pointer-events-none absolute left-3 top-3 truncate text-slate-500 sm:left-4 sm:top-4 dark:text-slate-400 ${s?"right-12":"right-3 sm:right-4"}`,children:a}),t.jsx("div",{ref:e,role:"textbox","aria-label":"Prompt","aria-multiline":"true",contentEditable:!n,inputMode:"text",suppressContentEditableWarning:!0,onPointerDown:b=>{!n&&document.activeElement!==b.currentTarget&&b.currentTarget.focus({preventScroll:!0}),u==null||u(b)},onInput:h,onPaste:m,onKeyDown:f,onKeyUp:p,onMouseUp:g,onBlur:k,onDragEnter:w,onDragOver:x,onDragLeave:j,onDrop:y,className:`relative z-[1] min-h-[4.25rem] whitespace-pre-wrap break-words pb-2 outline-none sm:min-h-[4.25rem] ${s?"pr-12":""} ${n?"cursor-not-allowed text-slate-500":""}`})]}),s?t.jsx(Ct,{type:"button",variant:"ghost",size:"icon-xs","aria-label":o,title:o,onClick:b=>{b.preventDefault(),d==null||d()},className:"thread-graph-composer-stop-button ui-action-danger absolute right-2 top-2 z-30 h-8 w-8 rounded-full text-sm font-medium",children:t.jsx("span",{"aria-hidden":"true",className:"block h-2.5 w-2.5 rounded-[2px] bg-current"})}):null]})}function ep({prompt:e,promptPlaceholder:r,promptRegionClassName:n,promptInputClassName:a,interruptLabel:s,canInterrupt:o,sendButtonLabel:l,sendButtonClassName:i,sendDisabled:d,onPromptChange:h,onPromptKeyDown:u,onInterrupt:m}){return t.jsxs("div",{className:`${n} relative`,children:[t.jsx("textarea",{"aria-label":"Prompt",disabled:!1,value:e,onChange:f=>h(f.target.value),onKeyDown:u,rows:2,placeholder:r,className:`${a} resize-y pb-10`}),t.jsx("button",{type:"button","aria-label":s,title:s,onClick:()=>void(m==null?void 0:m()),disabled:!o,className:`absolute right-2.5 top-2.5 inline-flex h-8 w-8 items-center justify-center rounded-full border transition ${o?"border-rose-300/55 bg-rose-300/[0.14] text-rose-50 shadow-lg shadow-rose-950/20 hover:bg-rose-300/[0.22]":"cursor-not-allowed border-stone-700/30 bg-stone-400/[0.02] text-stone-500/55 opacity-55"}`,children:t.jsx("span",{"aria-hidden":"true",className:"block h-2.5 w-2.5 rounded-[2px] bg-current"})}),t.jsx("button",{type:"submit","aria-label":"Send Shell Input",onMouseDown:f=>{f.preventDefault()},onPointerDown:f=>{f.preventDefault()},onTouchStart:f=>{f.preventDefault()},disabled:d,className:`absolute bottom-2.5 right-2.5 rounded-full px-3.5 py-1.5 text-sm font-medium shadow-lg shadow-stone-950/30 transition disabled:cursor-not-allowed disabled:bg-stone-700 disabled:text-stone-300 ${i}`,children:l})]})}function tp({isShellView:e,promptRef:r,prompt:n,disabled:a,promptPlaceholder:s,canInterrupt:o,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,promptInputClassName:h,goalComposeMode:u,goalTokenBudget:m,goalLocalError:f,goalBusy:p,busy:g,sendButtonLabel:k,sendButtonClassName:w,onInterrupt:x,onPromptInput:j,onPromptPaste:y,onPromptKeyDown:b,onPromptKeyUp:v,onPromptMouseUp:S,onPromptBlur:N,onPromptDragEnter:L,onPromptDragOver:R,onPromptDragLeave:P,onPromptDrop:Q,onGoalTokenBudgetChange:D,onCancelGoal:Z,onShellPromptChange:J}){return{promptSlot:e?null:t.jsx(Qm,{promptRef:r,prompt:n,disabled:a,promptPlaceholder:s,canInterrupt:o,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,onInterrupt:x,onInput:j,onPaste:y,onKeyDown:b,onKeyUp:v,onMouseUp:S,onBlur:N,onDragEnter:L,onDragOver:R,onDragLeave:P,onDrop:Q}),goalSlot:u&&!e?t.jsx(Jm,{tokenBudget:m,error:f,onTokenBudgetChange:D,onCancel:Z}):null,shellPromptSlot:e?t.jsx(ep,{prompt:n,promptPlaceholder:s,promptRegionClassName:i,promptInputClassName:h,interruptLabel:l,canInterrupt:o,sendButtonLabel:k,sendButtonClassName:w,sendDisabled:p||g,onPromptChange:J,onPromptKeyDown:b,onInterrupt:x}):null}}function rp({collaborationMode:e,onUpdateSettings:r,closeMenu:n}){const[a,s]=c.useState(null),o=a??e;c.useEffect(()=>{s(null)},[e]);const l=c.useCallback(async i=>{const d=Lu({nextMode:i.collaborationMode,previousOptimisticMode:a});d.optimisticMode&&s(d.optimisticMode);try{await(r==null?void 0:r(i)),d.closeMenuOnSuccess&&n()}catch(h){throw d.shouldRollbackMode&&s(d.rollbackMode),h}},[n,r,a]);return{displayedCollaborationMode:o,updateSettings:l}}function np({isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:s,toolbarClassName:o,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,inlineToggleClassName:m,planToggleActiveClassName:f,sendButtonBaseClassName:p,slashPanelView:g,availableToolboxItems:k,busy:w,settingsBusy:x,compactBusy:j,forkBusy:y,fastMode:b,goalComposeMode:v,goalBusy:S,goalStatus:N,activeView:L,disabled:R,model:P,modelOptions:Q,modelContextTitle:D,contextUsage:Z,reasoningEffort:J,supportedEfforts:z,displayedCollaborationMode:te,sandboxMode:se,sendButtonLabel:_,sendButtonClassName:ie,modelControlsDisabled:q,effortControlsDisabled:H,effortControlTitle:G,forkTurnOptionsState:T,skillsState:F,goalState:B,goalHistory:E,copiedSkillName:C,hooksPanelMode:W,hooksState:U,hookConfigBusy:ae,hookConfigError:K,hookConfigSuccess:de,editingHookTarget:ee,hookScope:ke,hookEventName:le,hookMatcher:je,hookCommand:Ae,hookTimeoutSec:ce,hookStatusMessage:ne,mcpPanelMode:Le,mcpState:Y,mcpConfigPath:me,mcpConfigError:we,mcpConfigSuccess:ye,mcpConfigBusy:De,mcpHttpName:Be,mcpHttpUrl:_e,mcpRawBlock:Oe,capabilities:V,shellControlState:he,onToggleView:ve,onDismissPromptFocus:I,onSetOpenMenu:O,onToolboxItemClick:oe,onSetSlashPanelView:ge,onViewGoals:Ne,onUpdateGoal:Ce,onOpenForkTurns:xe,onForkLatest:Ge,onForkTurn:Me,onCopySkillInvokeName:Qe,onResetHookForm:et,onSetHooksPanelMode:it,onClearHookConfigStatus:tt,onSetEditingHookTarget:Ke,onSetHookScope:dt,onSetHookEventName:gt,onSetHookMatcher:Ve,onSetHookCommand:A,onSetHookTimeoutSec:X,onSetHookStatusMessage:be,onSaveHook:Se,onStartEditingHook:Pe,onTrustHook:rt,onUntrustHook:nt,onSetMcpPanelMode:$e,onClearMcpConfigStatus:We,onSetMcpHttpName:ut,onSetMcpHttpUrl:st,onSetMcpRawBlock:ct,onPrepareRawMcpBlock:xt,onSaveHttpMcp:Rt,onSaveRawMcpBlock:wt,onPickPhoto:M,onPickFile:fe,onUpdateSettings:ze,onPasteShell:Fe,onCopyShell:Ue,onClearShell:mt,onShellControl:yt}){const Xt=e?null:{open:s==="slash",slashPanelView:g,availableToolboxItems:k,busy:w,forkBusy:y,forkTurnOptionsState:T,skillsState:F,goalState:B,goalHistory:E,goalBusy:S,copiedSkillName:C,hooksPanelMode:W,hooksState:U,hostConfigFilesAvailable:V.hostConfigFiles,hookTrustAvailable:V.hookTrust,hookConfigBusy:ae,hookConfigError:K,hookConfigSuccess:de,editingHookTarget:ee,hookScope:ke,hookEventName:le,hookMatcher:je,hookCommand:Ae,hookTimeoutSec:ce,hookStatusMessage:ne,mcpPanelMode:Le,mcpState:Y,mcpConfigEditing:V.mcpConfigEditing,mcpConfigPath:me,mcpConfigError:we,mcpConfigSuccess:ye,mcpConfigBusy:De,mcpHttpName:Be,mcpHttpUrl:_e,mcpRawBlock:Oe,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,onToggle:()=>O(ot=>ot==="slash"?null:"slash"),onToolboxItemClick:oe,toolboxItemDisabled:ot=>am(ot,{settingsBusy:x,compactBusy:j,busy:w,forkBusy:y}),toolboxItemClassName:ot=>sm(ot,{fastMode:b,goalComposeMode:v,goalStatus:N,menuItemClassName:d}),toolboxItemStatus:ot=>nm(ot,{fastMode:b,compactBusy:j,goalComposeMode:v,goalStatus:N,busy:w}),onSetSlashPanelView:ge,onViewGoals:Ne,onUpdateGoal:Ce,onOpenForkTurns:xe,onForkLatest:Ge,onForkTurn:Me,onCopySkillInvokeName:Qe,onResetHookForm:et,onSetHooksPanelMode:it,onClearHookConfigStatus:tt,onSetEditingHookTarget:Ke,onSetHookScope:dt,onSetHookEventName:gt,onSetHookMatcher:Ve,onSetHookCommand:A,onSetHookTimeoutSec:X,onSetHookStatusMessage:be,onSaveHook:Se,onStartEditingHook:Pe,onTrustHook:rt,onUntrustHook:nt,onSetMcpPanelMode:$e,onClearMcpConfigStatus:We,onSetMcpHttpName:ut,onSetMcpHttpUrl:st,onSetMcpRawBlock:ct,onPrepareRawMcpBlock:xt,onSaveHttpMcp:Rt,onSaveRawMcpBlock:wt},Yt=e?null:{open:s==="attachments",iconButtonClassName:l,menuClassName:i,menuItemClassName:d,onToggle:()=>O(ot=>ot==="attachments"?null:"attachments"),onPickPhoto:M,onPickFile:fe},At=e?null:{openMenu:s,model:P,modelOptions:Q,modelContextTitle:D,contextUsage:Z,reasoningEffort:J,supportedEfforts:z,displayedCollaborationMode:te,sandboxMode:se,planModeAvailable:V.planMode,sandboxModeAvailable:V.sandboxMode,settingsBusy:x,goalComposeMode:v,goalBusy:S,activeView:L,disabled:R,fastMode:b,sendButtonLabel:_,sendButtonClassName:ie,modelControlsDisabled:q,effortControlsDisabled:H,effortControlTitle:G,inlineToggleClassName:m,menuItemClassName:d,planToggleActiveClassName:f,sendButtonBaseClassName:p,onSetOpenMenu:O,onUpdateSettings:ze};return{isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:s,toolbarClassName:o,iconButtonClassName:l,slashToolboxProps:Xt,attachmentMenuProps:Yt,settingsToolbarProps:At,shellToolsPanelProps:s==="shellTools"?{busy:w,shellControlState:he,onPaste:Fe,onCopy:Ue,onClear:mt,onShellControl:yt}:null,shellControlState:he,onToggleView:ve,onDismissPromptFocus:I,onSetOpenMenu:O}}function Kn({activeView:e,edgeToEdgeMobile:r=!1,busy:n=!1,settingsBusy:a=!1,compactBusy:s=!1,error:o,model:l=null,reasoningEffort:i=null,fastMode:d=!1,collaborationMode:h="default",sandboxMode:u=null,hideSandboxModeControl:m=!1,modelOptions:f=[],contextUsage:p=null,capabilities:g=null,toolboxItems:k=null,hookCommandTemplates:w=null,mcpConfigFormat:x="none",followTail:j=!1,threadConnected:y=!0,shellAvailable:b=!0,disabled:v=!1,disabledPlaceholder:S,shellControlState:N=null,draftPrompt:L,draftAttachments:R,onPickAttachment:P,skillsState:Q={status:"idle",data:null,error:null},mcpState:D={status:"idle",data:null,error:null},hooksState:Z={status:"idle",data:null,error:null},goalState:J={status:"idle",data:null,error:null},goalHistory:z=[],forkTurnOptionsState:te={status:"idle",data:null,error:null},onDraftChange:se,onSubmit:_,onInterrupt:ie,onCompact:q,onOpenSkills:H,onOpenMcp:G,onOpenHooks:T,onCreateHook:F,onUpdateHook:B,onTrustHook:E,onUntrustHook:C,onOpenGoal:W,onPrepareGoalSubmit:U,onUpdateGoal:ae,onOpenForkTurns:K,onForkLatest:de,onForkTurn:ee,onReadProviderConfig:ke,onWriteProviderConfig:le,onToggleFollow:je,canJumpToPreviousTurn:Ae,onJumpToPreviousTurn:ce,canJumpToNextTurn:ne,onJumpToNextTurn:Le,subscriptionUsage:Y,onUpdateSettings:me,onToggleView:we,onShellCopy:ye,onShellControl:De,canInterrupt:Be=!1,pendingPrompts:_e=[],onSteerPendingPrompt:Oe,onCancelPendingPrompt:V}){var Ca;const[he,ve]=c.useState(null),[I,O]=c.useState("root"),oe=c.useRef(!1),[ge,Ne]=c.useState("list"),Ce=c.useMemo(()=>({fast:(g==null?void 0:g.controls.performanceMode)??!1,compact:(g==null?void 0:g.turns.compact)??!1,goal:(g==null?void 0:g.controls.goals)??!1,fork:(g==null?void 0:g.branching.fork)??!1,skills:(g==null?void 0:g.management.skills)??!1,mcp:(g==null?void 0:g.management.mcpStatus)??!1,hooks:(g==null?void 0:g.management.hooks)??!1,hostConfigFiles:(g==null?void 0:g.management.hostConfigFiles)??!1,mcpConfigEditing:x==="codex-toml"&&!!(g!=null&&g.management.hostConfigFiles)&&!!ke&&!!le,hookTrust:(g==null?void 0:g.management.hookTrust)??!1,planMode:(g==null?void 0:g.controls.planMode)??!1,sandboxMode:(g==null?void 0:g.controls.sandboxMode)??!1}),[g,x,ke,le]),xe=c.useMemo(()=>tm(k,Ce),[Ce,k]),Ge=c.useRef(null),Me=c.useRef(null),Qe=c.useRef(null),et=c.useRef(null),it=c.useRef(null),tt=c.useRef([]),Ke=c.useRef(null),dt=c.useRef(""),gt=c.useRef(0),Ve=e==="shell",A=b||Ve,X=!!(Ve&&(N!=null&&N.isMobileShell)),be=(N==null?void 0:N.promptLabel)??null,[Se,Pe]=c.useState(!1),[rt,nt]=c.useState(0),{prompt:$e,attachments:We,isDraftControlled:ut,updateDraft:st,flushControlledDraftToHost:ct}=Fm({isShellView:Ve,draftPrompt:L,draftAttachments:R,onDraftChange:se}),xt=Bm({attachments:We,isShellView:Ve}),{displayedCollaborationMode:Rt,updateSettings:wt}=rp({collaborationMode:h,onUpdateSettings:me,closeMenu:()=>ve(null)}),{forkBusy:M,forkLatest:fe,forkTurn:ze}=Hm({slashPanelView:I,onForkLatest:de,onForkTurn:ee,closeMenu:()=>ve(null)}),{hooksPanelMode:Fe,hookScope:Ue,hookEventName:mt,hookMatcher:yt,hookCommand:Xt,hookTimeoutSec:Yt,hookStatusMessage:At,editingHookTarget:mr,hookConfigBusy:ot,hookConfigError:un,hookConfigSuccess:mn,setHooksPanelMode:Rl,setEditingHookTarget:Al,setHookScope:Ml,setHookEventName:$l,setHookMatcher:_l,setHookCommand:Dl,setHookTimeoutSec:Bl,setHookStatusMessage:Gl,clearHookConfigStatus:ga,resetHookForm:Fl,startEditingHook:Hl,saveHook:Ol,trustHook:Wl,untrustHook:Ul}=Um({slashPanelView:I,hookCommandTemplates:w,onCreateHook:F,onUpdateHook:B,onTrustHook:E,onUntrustHook:C}),{goalComposeMode:pr,goalTokenBudget:Vl,goalBusy:pn,goalLocalError:ql,setGoalTokenBudget:Kl,submitGoal:Xl,enterGoalComposeMode:Yl,exitGoalComposeMode:xa}=Om({prompt:$e,goalTokenBudgetSource:J.data,promptRef:Me,onOpenGoal:W,onPrepareGoalSubmit:U,onUpdateGoal:ae,updateDraft:st,closeMenu:()=>ve(null),resetSlashPanel:()=>O("root")}),{mcpHttpName:Zl,mcpHttpUrl:Jl,mcpRawBlock:Ql,mcpConfigPath:ei,mcpConfigBusy:ti,mcpConfigError:ri,mcpConfigSuccess:ni,setMcpHttpName:ai,setMcpHttpUrl:si,setMcpRawBlock:oi,clearMcpConfigStatus:ba,prepareRawMcpBlock:li,saveHttpMcp:ii,saveRawMcpBlock:di}=qm({hostConfigFilesAvailable:Ce.hostConfigFiles,onReadProviderConfig:ke,onWriteProviderConfig:le,setMcpPanelMode:Ne,onOpenMcp:G}),{copiedSkillName:ci,copySkillInvokeName:hi}=Km({openMenu:he,setOpenMenu:ve,slashPanelView:I,setSlashPanelView:O,setMcpPanelMode:Ne,clearMcpConfigStatus:ba,clearHookConfigStatus:ga}),ui=c.useCallback(re=>{st(Te=>{if(typeof re=="function"){const Re=re(Te.prompt,Te.attachments);return{prompt:Re.prompt,attachments:Re.attachments??Te.attachments}}return{prompt:re,attachments:Te.attachments}})},[st]),fn=c.useMemo(()=>f.find(re=>re.model===l)??null,[l,f]),mi=Mu(l,p),va=(fn==null?void 0:fn.supportedReasoningEfforts)??[],pi=c.useMemo(()=>ku($e,We),[We,$e]),fi=c.useMemo(()=>Object.entries(xt).sort(([re],[Te])=>re.localeCompare(Te)).map(([re,Te])=>`${re}:${Te}`).join("|"),[xt]);function gi(re,Te){Te.stopPropagation();const Re=rm(re,{fastMode:d,goalComposeMode:pr});switch(Re.type){case"toggleFast":wt({fastMode:Re.fastMode});break;case"runCompact":ve(null),q==null||q();break;case"enterGoalCompose":Yl();break;case"exitGoalCompose":xa(),ve(null);break;case"openPanel":O(Re.panel),Re.panel==="skills"?H==null||H():Re.panel==="mcp"?G==null||G():Re.panel==="hooks"&&(T==null||T());break;case"insertPrompt":bn(Re.text),O("root"),ve(null);break}}function Zt(){const re=Me.current;return re?im(re):null}const xi=c.useCallback(re=>{const Te=Me.current;!Te||!re||dm(Te,re)},[]),gn=c.useCallback(()=>{const re=Me.current;return re?il(re):$e},[$e]),{appendAttachments:xn,appendDroppedAttachments:ka}=Dm({prompt:$e,attachments:We,updateDraft:st,getSelection:Zt,selectionSnapshotRef:Ke,pendingSelectionRef:it,pendingInsertedAttachmentIdsRef:tt,onInserted:()=>ve(null)}),wa=c.useCallback((re,Te)=>{var Re;if(Mt(),P){P({kind:re,appendAttachments:(Ze,lt=re)=>xn(Ze,lt),defaultPick:()=>{var Ze;return(Ze=Te.current)==null?void 0:Ze.click()}});return}(Re=Te.current)==null||Re.click()},[xn,Mt,P]);function bn(re){if(!re)return;const Te=Zt()??Ke.current,Re=(Te==null?void 0:Te.start)??$e.length,Ze=(Te==null?void 0:Te.end)??Re,lt=vu(re),Jt=`${$e.slice(0,Re)}${lt}${$e.slice(Ze)}`;st(Ji=>({prompt:Jt,attachments:Ji.attachments}));const $t=Re+lt.length;it.current={start:$t,end:$t},Ke.current={start:$t,end:$t}}Zm({promptRef:Me,isShellView:Ve,prompt:$e,promptSegments:pi,attachmentPreviewUrls:xt,previewSignature:fi,editorSanitizeNonce:rt,pendingSelectionRef:it,pendingInsertedAttachmentIdsRef:tt,selectionSnapshotRef:Ke,renderedPreviewSignatureRef:dt,renderedSanitizeNonceRef:gt,serializeEditorPrompt:gn,restoreSelection:xi});function Mt(){var re;(re=Me.current)==null||re.blur(),document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.blur()}async function bi(){var re;if(Mt(),ve(null),!!((re=navigator.clipboard)!=null&&re.readText))try{const Te=await navigator.clipboard.readText();bn(Te)}catch{return}}async function ya(){if(!oe.current){oe.current=!0;try{if(ut&&ct(),pr&&!Ve){await Xl();return}const re=Cu({prompt:$e,attachments:We,isShellView:Ve});if(!re||await _(re)===!1)return;st(()=>({prompt:"",attachments:[]}))}finally{oe.current=!1}}}async function vi(re){re.preventDefault(),await ya()}function ki(){const re=gn(),Te=Zt();Ke.current=Te;const Re=Me.current;(Re?lm(Re):!1)&&(it.current=Te,nt(lt=>lt+1)),st(lt=>({prompt:re,attachments:lt.attachments.filter(Jt=>re.includes(Jt.placeholder))}),"deferred")}function wi(re){var Ze,lt,Jt,$t;const Te=Vn((Ze=re.clipboardData)==null?void 0:Ze.items,(lt=re.clipboardData)==null?void 0:lt.files),Re=Su({files:Te,plainText:((Jt=re.clipboardData)==null?void 0:Jt.getData("text/plain"))??"",htmlText:(($t=re.clipboardData)==null?void 0:$t.getData("text/html"))??"",htmlToText:om});Re.preventDefault&&re.preventDefault(),Re.type==="insert-text"?bn(Re.text):Re.type==="append-files"&&ka(Re.files)}function yi(re){var Re,Ze;const Te=rs(ss((Re=re.dataTransfer)==null?void 0:Re.items,(Ze=re.dataTransfer)==null?void 0:Ze.files));Te.preventDefault&&re.preventDefault(),Te.activateDragTarget&&Pe(!0)}function ji(re){var Re,Ze;const Te=rs(ss((Re=re.dataTransfer)==null?void 0:Re.items,(Ze=re.dataTransfer)==null?void 0:Ze.files));Te.preventDefault&&re.preventDefault(),Te.activateDragTarget&&re.dataTransfer&&(re.dataTransfer.dropEffect="copy"),Te.activateDragTarget&&Pe(!0)}function Ni(re){re.currentTarget.contains(re.relatedTarget)||Pe(!1)}function Ci(re){var Ze,lt;const Te=Vn((Ze=re.dataTransfer)==null?void 0:Ze.items,(lt=re.dataTransfer)==null?void 0:lt.files),Re=Tu(Te);Re.preventDefault&&re.preventDefault(),Re.type==="accept-files"&&(Pe(!1),ka(Re.files??[]))}function Si(re){if(re.key==="Enter"&&re.repeat){re.preventDefault();return}if(e==="chat"&&re.key==="/"&&!re.metaKey&&!re.ctrlKey&&!re.altKey&&!n&&!v&&xe.length>0&&gn().trim().length===0){re.preventDefault(),O("root"),ve("slash");return}const Te=Eu({key:re.key,metaKey:re.metaKey,ctrlKey:re.ctrlKey,busy:n,disabled:v});Te.preventDefault&&re.preventDefault(),Te.submit&&ya()}const{promptPlaceholder:Ti,interruptLabel:Ei,sendButtonLabel:ja,sendButtonClassName:Na,modelControlsDisabled:Li,effortControlsDisabled:Ii,effortControlTitle:zi}=Bu({goalComposeMode:pr,goalBusy:pn,threadConnected:y,busy:n,isShellView:Ve,disabledPlaceholder:S,settingsBusy:a,supportedEffortCount:va.length,fastMode:d}),{composerLayerClassName:Pi,formClassName:Ri,composerShellClassName:Ai,composerToolbarClassName:Mi,composerIconButtonClassName:$i,composerMenuClassName:_i,composerMenuItemClassName:Di,composerInlineToggleClassName:Bi,composerPanelButtonClassName:Gi,composerChipButtonClassName:Fi,composerPlanToggleActiveClassName:Hi,composerSendButtonClassName:Oi,composerPromptRegionClassName:Wi,promptInputClassName:Ui,graphChatInputGroupClassName:Vi,graphChatInputClassName:qi}=Gu({isShellView:Ve,edgeToEdgeMobile:r,isMobileShell:X,openMenu:he!==null,isDragTargetActive:Se,busy:n}),Ki=np({isShellView:Ve,canToggleShellView:A,isMobileShell:X,shellPromptLabel:be,openMenu:he,toolbarClassName:Mi,iconButtonClassName:$i,menuClassName:_i,menuItemClassName:Di,panelButtonClassName:Gi,chipButtonClassName:Fi,inlineToggleClassName:Bi,planToggleActiveClassName:Hi,sendButtonBaseClassName:Oi,slashPanelView:I,availableToolboxItems:xe,busy:n,settingsBusy:a,compactBusy:s,forkBusy:M,fastMode:d,goalComposeMode:pr,goalBusy:pn,goalStatus:(Ca=J.data)==null?void 0:Ca.status,activeView:e,disabled:v,model:l,modelOptions:f,modelContextTitle:mi,contextUsage:p,reasoningEffort:i,supportedEfforts:va,displayedCollaborationMode:Rt,sandboxMode:u,sendButtonLabel:ja,sendButtonClassName:Na,modelControlsDisabled:Li,effortControlsDisabled:Ii,effortControlTitle:zi,forkTurnOptionsState:te,skillsState:Q,goalState:J,goalHistory:z,copiedSkillName:ci,hooksPanelMode:Fe,hooksState:Z,hookConfigBusy:ot,hookConfigError:un,hookConfigSuccess:mn,editingHookTarget:mr,hookScope:Ue,hookEventName:mt,hookMatcher:yt,hookCommand:Xt,hookTimeoutSec:Yt,hookStatusMessage:At,mcpPanelMode:ge,mcpState:D,mcpConfigPath:ei,mcpConfigError:ri,mcpConfigSuccess:ni,mcpConfigBusy:ti,mcpHttpName:Zl,mcpHttpUrl:Jl,mcpRawBlock:Ql,capabilities:{hostConfigFiles:Ce.hostConfigFiles,hookTrust:Ce.hookTrust,mcpConfigEditing:Ce.mcpConfigEditing,planMode:Ce.planMode,sandboxMode:m?!1:Ce.sandboxMode},shellControlState:N,onToggleView:we,onDismissPromptFocus:Mt,onSetOpenMenu:ve,onToolboxItemClick:gi,onSetSlashPanelView:O,onViewGoals:W,onUpdateGoal:ae,onOpenForkTurns:()=>K==null?void 0:K(),onForkLatest:fe,onForkTurn:ze,onCopySkillInvokeName:hi,onResetHookForm:Fl,onSetHooksPanelMode:Rl,onClearHookConfigStatus:ga,onSetEditingHookTarget:Al,onSetHookScope:Ml,onSetHookEventName:$l,onSetHookMatcher:_l,onSetHookCommand:Dl,onSetHookTimeoutSec:Bl,onSetHookStatusMessage:Gl,onSaveHook:Ol,onStartEditingHook:Hl,onTrustHook:Wl,onUntrustHook:Ul,onSetMcpPanelMode:Ne,onClearMcpConfigStatus:ba,onSetMcpHttpName:ai,onSetMcpHttpUrl:si,onSetMcpRawBlock:oi,onPrepareRawMcpBlock:li,onSaveHttpMcp:ii,onSaveRawMcpBlock:di,onPickPhoto:()=>wa("photo",Qe),onPickFile:()=>wa("file",et),onUpdateSettings:re=>void wt(re),onPasteShell:()=>void bi(),onCopyShell:()=>{Mt(),ve(null),ye==null||ye()},onClearShell:()=>{Mt(),ve(null),_({prompt:"clear"})},onShellControl:re=>{Mt(),ve(null),De==null||De(re)}}),{promptSlot:Xi,goalSlot:Yi,shellPromptSlot:Zi}=tp({isShellView:Ve,promptRef:Me,prompt:$e,disabled:v,promptPlaceholder:Ti,canInterrupt:Be,interruptLabel:Ei,composerPromptRegionClassName:Wi,graphChatInputClassName:qi,promptInputClassName:Ui,goalComposeMode:pr,goalTokenBudget:Vl,goalLocalError:ql,goalBusy:pn,busy:n,sendButtonLabel:ja,sendButtonClassName:Na,onInterrupt:ie,onPromptInput:ki,onPromptPaste:wi,onPromptKeyDown:Si,onPromptKeyUp:()=>{Ke.current=Zt()},onPromptMouseUp:()=>{Ke.current=Zt()},onPromptBlur:()=>{Ke.current=Zt(),Pe(!1),ut&&ct()},onPromptDragEnter:yi,onPromptDragOver:ji,onPromptDragLeave:Ni,onPromptDrop:Ci,onGoalTokenBudgetChange:Kl,onCancelGoal:xa,onShellPromptChange:ui});return t.jsx(km,{activeView:e,layerClassName:Pi,formClassName:Ri,shellClassName:Ai,inputGroupClassName:Vi,error:o,followTail:j,photoInputRef:Qe,fileInputRef:et,onAppendAttachments:xn,onToggleFollow:je,canJumpToPreviousTurn:Ae,onJumpToPreviousTurn:ce,canJumpToNextTurn:ne,onJumpToNextTurn:Le,subscriptionUsage:Y,onSubmit:vi,formRef:Ge,promptSlot:Xi,pendingQueueSlot:!Ve&&_e.length>0?t.jsx(wm,{prompts:_e,onSteer:Oe,onCancel:V}):null,toolbarSlot:t.jsx(Mm,{...Ki}),goalSlot:Yi,shellPromptSlot:Zi})}var ap=c.createContext(null);function cl(){return c.useContext(ap)}function kt(e){return e?new Date(e).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"}):"Time unavailable"}function Ut(e){return e?new Date(e).toLocaleString():"Time unavailable"}function sp(e){switch(e){case"idle":return"Idle";case"running":return"Running";case"interrupted":return"Interrupted";case"failed":return"Failed";case"not_loaded":return"Not Loaded";case"system_error":return"System Error"}}function op(e){switch(e){case"idle":return"ui-status-neutral";case"running":return"ui-status-info";case"interrupted":return"ui-status-warning";case"failed":case"system_error":return"ui-status-danger";case"not_loaded":return"ui-status-neutral"}}function hl(e){switch(e){case"sending":return"Sending";case"completed":return"Completed";case"interrupted":return"Interrupted";case"failed":return"Failed";case"inProgress":return"Running"}}function lp({open:e,title:r,label:n,value:a,busy:s=!1,onChange:o,onCancel:l,onSubmit:i}){if(c.useEffect(()=>{if(!e)return;function h(u){u.key==="Escape"&&!s&&l()}return window.addEventListener("keydown",h),()=>{window.removeEventListener("keydown",h)}},[s,l,e]),!e)return null;function d(h){h.preventDefault(),i()}return Qr.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[95] flex items-center justify-center p-4 sm:p-6",children:[t.jsx("button",{type:"button","aria-label":"Close rename dialog",onClick:l,disabled:s,className:"absolute inset-0 bg-stone-950/78 backdrop-blur-sm disabled:cursor-not-allowed"}),t.jsxs("form",{role:"dialog","aria-modal":"true","aria-label":r,onSubmit:d,className:"relative z-[1] w-full max-w-md rounded-[1.6rem] border border-stone-700 bg-stone-900 p-5 shadow-2xl shadow-stone-950/40 sm:p-6",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium text-stone-100",children:r}),t.jsx("p",{className:"mt-1 text-sm text-stone-500",children:"Changes are saved only after confirmation."})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:l,disabled:s,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-stone-700 text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsxs("div",{className:"mt-5",children:[t.jsx("label",{htmlFor:"rename-dialog-input",className:"text-sm font-medium text-stone-200",children:n}),t.jsx("input",{id:"rename-dialog-input","aria-label":n,autoFocus:!0,value:a,onChange:h=>o(h.target.value),className:"mt-2 w-full rounded-2xl border border-stone-700 bg-stone-950 px-4 py-3 text-stone-100 outline-none transition focus:border-amber-300"})]}),t.jsxs("div",{className:"mt-5 flex items-center justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:l,disabled:s,className:"rounded-full border border-stone-700 px-4 py-2 text-sm font-medium text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),t.jsx("button",{type:"submit",disabled:s||!a.trim(),className:"ui-action-success rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:"Save"})]})]})]}),document.body)}function ip({children:e,effectiveTheme:r,layoutMode:n,themeMode:a,viewportConstrained:s}){return t.jsx("div",{className:`thread-ui-shell ${r==="dark"?"thread-ui-theme-dark dark":""} ${s?"thread-ui-viewport-constrained":""} ${s?"h-[100svh] max-h-[100svh] min-h-0 overflow-hidden overscroll-none":"min-h-[100svh] overflow-hidden"} bg-[#f6f8fb] text-slate-900 transition-colors duration-200 sm:p-2`,"data-theme-effective":r,"data-theme-mode":a??r,"data-thread-layout":n,children:e})}function dp({children:e,roomsRailCollapsed:r}){return t.jsx("div",{className:`thread-shell-frame relative h-full min-h-0 ${r?"is-rail-collapsed sm:grid-cols-[56px_minmax(0,1fr)]":"sm:grid-cols-[264px_minmax(0,1fr)]"}`,children:e})}function cp({onClose:e,open:r}){return r?t.jsx("button",{type:"button","aria-hidden":"true",tabIndex:-1,className:"thread-mobile-only-block thread-mobile-scrim fixed inset-0 z-40 bg-slate-950/35 backdrop-blur-[1px]",onClick:e}):null}function hp({children:e,collapsed:r,mobileOpen:n}){return t.jsx("aside",{className:`thread-graph-rooms-surface thread-rooms-rail fixed inset-y-0 left-0 z-50 flex min-h-0 min-w-0 w-[min(20rem,calc(100vw-2rem))] flex-col overflow-x-hidden border-r border-slate-200/80 bg-white shadow-[0_20px_50px_rgba(15,23,42,0.18)] transition-transform duration-200 ease-out sm:static sm:z-auto sm:w-auto sm:translate-x-0 sm:rounded-[12px] sm:border sm:shadow-[0_10px_30px_rgba(15,23,42,0.04)] ${n?"translate-x-0":"pointer-events-none -translate-x-full sm:pointer-events-auto"} ${r?"thread-ui-rail-collapsed sm:items-center":""}`,style:{paddingTop:"var(--android-safe-area-top, 0px)"},children:e})}function up({children:e}){return t.jsx("main",{className:"thread-shell-main h-full min-h-0 min-w-0 overflow-hidden",children:t.jsx("div",{className:"thread-main-panel thread-shell-card flex h-full min-h-0 flex-col overflow-hidden bg-white shadow-[0_10px_30px_rgba(15,23,42,0.04)] sm:rounded-[12px] sm:border sm:border-slate-200/80",children:e})})}function mp({children:e}){return t.jsx("div",{className:"thread-topbar-surface flex shrink-0 flex-col border-b border-slate-200 bg-white pt-[env(safe-area-inset-top)] sm:pt-0",children:e})}function pp({children:e}){return t.jsx("div",{className:"thread-split-region min-h-0 flex-1 overflow-hidden p-0 sm:p-2",children:e})}Po();Pt();function us({...e}){return t.jsx(ad,{"data-slot":"dialog",...e})}function ms({...e}){return t.jsx(sd,{"data-slot":"dialog-trigger",...e})}function fp({...e}){return t.jsx(cd,{"data-slot":"dialog-portal",...e})}function gp({className:e,...r}){return t.jsx(hd,{"data-slot":"dialog-overlay",className:at("fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",e),...r})}function ps({children:e,className:r,showCloseButton:n=!0,...a}){return t.jsxs(fp,{"data-slot":"dialog-portal",children:[t.jsx(gp,{}),t.jsxs(od,{"data-slot":"dialog-content",className:at("fixed left-[50%] top-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg",r),...a,children:[e,n?t.jsxs(ld,{"data-slot":"dialog-close",className:"absolute right-4 top-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[t.jsx($.XIcon,{}),t.jsx("span",{className:"sr-only",children:"Close"})]}):null]})]})}function fs({className:e,...r}){return t.jsx("div",{"data-slot":"dialog-header",className:at("flex flex-col gap-2 text-center sm:text-left",e),...r})}function gs({className:e,...r}){return t.jsx(id,{"data-slot":"dialog-title",className:at("text-lg font-semibold leading-none",e),...r})}function xs({className:e,...r}){return t.jsx(dd,{"data-slot":"dialog-description",className:at("text-sm text-muted-foreground",e),...r})}var xp=[{value:"system",label:"Follow system",icon:$.Monitor},{value:"dark",label:"Dark",icon:$.Moon},{value:"light",label:"Light",icon:$.Sun}];function bp({thread:e,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a={},onOpenThread:s,getThreadHref:o,renderThreadLink:l,onBeginRenameThread:i,onDeleteThread:d,showDeleteButton:h=!1,showSessionCopyButton:u=!1,collapsed:m=!1}){const[f,p]=c.useState("idle"),g=c.useRef(null),k=a[e.workspaceId],w=k&&!n?k:null,x=r===e.id;c.useEffect(()=>()=>{g.current!==null&&window.clearTimeout(g.current)},[]);async function j(){const N=e.providerSessionId;if(N)try{await navigator.clipboard.writeText(N),p("copied"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>p("idle"),1200)}catch{p("failed"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>p("idle"),1600)}}const y=()=>s(e.id),b=`thread-graph-room-card group flex w-full items-center gap-3 rounded-xl border text-left transition ${x?"is-active":""} ${m?"justify-center px-2 py-2":"px-3 py-2.5"}`,v=t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`thread-graph-room-card-icon flex h-8 w-8 shrink-0 items-center justify-center rounded-full ${x?"is-active":""}`,children:t.jsx($.MessageSquare,{className:"h-4 w-4"})}),t.jsxs("div",{className:`min-w-0 flex-1 ${m?"thread-desktop-collapsed-hidden":""}`,children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[t.jsx("p",{className:"thread-graph-room-card-title min-w-0 flex-1 truncate text-sm font-medium",title:e.title,children:e.title}),i&&!m?t.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),N.preventDefault(),i(e)},"aria-label":`Rename thread ${e.title}`,title:"Rename thread",className:"thread-card-quiet-button inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full transition",children:t.jsx($.Pencil,{className:"h-3 w-3"})}):null,u&&e.providerSessionId?t.jsx("button",{type:"button","aria-label":"Copy session ID",title:f==="copied"?"Copied":f==="failed"?"Copy failed":"Copy session ID",onClick:N=>{N.stopPropagation(),N.preventDefault(),j()},className:"thread-card-quiet-button thread-card-session-copy-button inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition",children:f==="copied"?t.jsx($.Check,{className:"h-3.5 w-3.5"}):t.jsx($.Copy,{className:"h-3.5 w-3.5"})}):null]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2",children:[w?t.jsx("p",{className:"thread-graph-room-card-meta min-w-0 flex-1 truncate text-[11px] text-[var(--theme-fg-muted)]",title:w,children:w}):t.jsx("span",{className:"min-w-0 flex-1","aria-hidden":"true"}),t.jsx("span",{className:`shrink-0 rounded-full border px-1.5 py-0.5 text-[9px] uppercase tracking-normal ${op(e.status)}`,children:sp(e.status)}),t.jsx("time",{className:"shrink-0 text-[11px] text-[var(--theme-fg-muted)]",dateTime:e.lastTurnStartedAt??e.updatedAt,children:kt(e.lastTurnStartedAt??e.updatedAt)})]})]}),h&&d&&!m?t.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),N.preventDefault(),d(e)},"aria-label":`Delete thread ${e.title}`,className:"thread-card-danger-button shrink-0 rounded-full p-1 transition",title:"Delete thread",children:t.jsx($.Trash2,{className:"h-3.5 w-3.5"})}):null]}),S=o==null?void 0:o(e.id);return l?t.jsx(t.Fragment,{children:l({thread:e,children:v,className:b,onClick:y})}):S?t.jsx("a",{href:S,onClick:N=>{N.preventDefault(),y()},title:m?e.title:void 0,className:b,children:v}):t.jsx("div",{role:"link",tabIndex:0,onClick:y,onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),y())},title:m?e.title:void 0,className:b,children:v})}function vp({threads:e,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a={},onOpenThread:s,getThreadHref:o,renderThreadLink:l,onBeginRenameThread:i,onDeleteThread:d,scrollable:h=!1,maxHeightClassName:u="max-h-full",showDeleteButton:m=!1,showSessionCopyButton:f=!1,collapsed:p=!1}){const g=h?`min-h-0 min-w-0 overflow-x-hidden overflow-y-auto overscroll-contain pr-1 ${u}`:"";return t.jsx("div",{className:g,children:t.jsx("div",{className:"min-w-0 space-y-1",children:e.map(k=>t.jsx(bp,{thread:k,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a,onOpenThread:s,showDeleteButton:m,showSessionCopyButton:f,collapsed:p,...o?{getThreadHref:o}:{},...l?{renderThreadLink:l}:{},...i?{onBeginRenameThread:i}:{},...d?{onDeleteThread:d}:{}},k.id))})})}function kp({threads:e,status:r,loading:n=!1,error:a,viewportConstrained:s=!1,layoutMode:o="responsive",effectiveTheme:l,themeMode:i,onThemeModeChange:d,showMobileNewThreadShortcut:h=!0,settingsDialogOpen:u,onSettingsDialogOpenChange:m,mobileHeaderAction:f,currentThreadId:p,currentThreadLabel:g=null,currentWorkspaceId:k=null,currentWorkspaceLabel:w=null,sessionLabel:x=null,usageLabel:j=null,threadActionsButton:y,topbarActions:b,metaContent:v,settingsContent:S,globalSettingsContent:N,workspaceLabels:L={},workspaceReturnHref:R,onWorkspaceReturn:P,getThreadHref:Q,onOpenThread:D,getNewThreadHref:Z,newThreadHref:J,newThreadLabel:z="New Chat",onNewThread:te,onNewThreadTitle:se,renderNewThreadDialogContent:_,renderThreadLink:ie,onCloseAppNavigation:q,onRenameThread:H,onDeleteThread:G,workspaceContent:T,workspaceTitle:F="Workspace",workspaceActions:B,children:E}){const C=cl(),W=typeof window<"u"?window.matchMedia("(max-width: 639px)").matches:o==="mobile",[U,ae]=c.useState(()=>typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)").matches:!1),K=i??(C==null?void 0:C.themeMode)??"system",de=l??(C==null?void 0:C.effectiveTheme)??(K==="system"?U?"dark":"light":K),[ee,ke]=c.useState(!1),[le,je]=c.useState(!1),[Ae,ce]=c.useState(!W),[ne,Le]=c.useState(W),[Y,me]=c.useState("chat"),[we,ye]=c.useState(null),[De,Be]=c.useState(""),[_e,Oe]=c.useState(null),[V,he]=c.useState(!1),[ve,I]=c.useState(""),[O,oe]=c.useState(!1),[ge,Ne]=c.useState(!1),[Ce,xe]=c.useState("session");c.useEffect(()=>{if(typeof window>"u")return;const M=window.matchMedia("(max-width: 639px)"),fe=()=>{Le(M.matches)};return fe(),M.addEventListener("change",fe),()=>{M.removeEventListener("change",fe)}},[]),c.useEffect(()=>{if(typeof window>"u")return;const M=window.matchMedia("(prefers-color-scheme: dark)"),fe=()=>{ae(M.matches)};return fe(),M.addEventListener("change",fe),()=>{M.removeEventListener("change",fe)}},[]);const Ge=c.useMemo(()=>[...k?e.filter(fe=>fe.workspaceId===k):e].sort((fe,ze)=>{if(fe.id===p)return-1;if(ze.id===p)return 1;const Fe=Date.parse(fe.lastTurnStartedAt??fe.updatedAt);return Date.parse(ze.lastTurnStartedAt??ze.updatedAt)-Fe}),[p,k,e]),Me=J??(Z==null?void 0:Z(k)),Qe=w??k??"all",et=x??g??p??"default_session",it=j??(r!=null&&r.state?`runtime ${r.state}`:"waiting for agent usage"),tt=d??(C==null?void 0:C.setThemeMode),Ke=!!tt,dt=()=>{ke(!1),q==null||q()};async function gt(M){if(!H)return;const fe=De.trim();if(fe){Oe(M);try{await H(M,fe),ye(null),Be("")}finally{Oe(null)}}}function Ve(M){ye(M.id),Be(M.title)}function A(){ye(null),Be("")}function X(M){D==null||D(M),dt()}function be(){he(!1),I("")}function Se(M){if(!Me||!M.trim())return Me;try{const fe=new URL(Me,window.location.origin);return fe.searchParams.set("title",M.trim()),`${fe.pathname}${fe.search}${fe.hash}`}catch{const fe=Me.includes("?")?"&":"?";return`${Me}${fe}title=${encodeURIComponent(M.trim())}`}}async function Pe(){const M=ve.trim();oe(!0);try{if(M&&se){await se(M),I(""),he(!1),dt();return}if(Me){window.location.assign(Se(M)??Me);return}await(te==null?void 0:te()),I(""),he(!1),dt()}finally{oe(!1)}}function rt(M,fe=!1){const ze=fe?t.jsxs(t.Fragment,{children:[t.jsx($.Plus,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:z})]}):t.jsxs(t.Fragment,{children:[t.jsx($.Plus,{className:"h-4 w-4"}),t.jsx("span",{children:z})]});return t.jsxs(us,{open:V,onOpenChange:Fe=>{O||he(Fe)},children:[t.jsx(ms,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":fe?z:void 0,title:z,className:M,children:ze})}),t.jsx(ps,{"data-testid":"create-thread-dialog","data-theme-effective":de,"data-theme-mode":K,className:"thread-graph-create-thread-dialog thread-graph-dialog max-h-[min(86vh,42rem)] overflow-hidden p-4 sm:max-w-[34rem]",children:_?_({close:be,closeNavigation:dt,currentWorkspaceId:k}):t.jsxs(t.Fragment,{children:[t.jsxs(fs,{children:[t.jsx(gs,{children:"Create New Chat"}),t.jsx(xs,{children:"Name the room so it is easy to find later."})]}),t.jsxs("div",{className:"grid gap-3",children:[t.jsx("input",{id:"thread-graph-create-thread-title",name:"thread-title",value:ve,onChange:Fe=>I(Fe.target.value),onKeyDown:Fe=>{Fe.key==="Enter"&&(Fe.preventDefault(),Pe())},placeholder:"Chat name","aria-label":"Chat name",autoComplete:"off",className:"thread-graph-create-thread-input h-10 rounded-md border px-3 text-sm outline-none transition"}),t.jsx("button",{type:"button",onClick:()=>void Pe(),disabled:O,className:"thread-graph-create-thread-submit inline-flex h-10 items-center justify-center rounded-md px-4 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:O?"Creating...":"Create"})]})]})})]})}function nt(){if(!S&&!v&&!N&&!Ke)return null;const M=!!(S||v),fe=!!N,ze=M&&fe,Fe=Ce==="global"&&fe||!M&&fe?"global":"session";return t.jsxs(us,{...u!==void 0?{open:u}:{},...m?{onOpenChange:m}:{},children:[t.jsx(ms,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":"Open settings",title:"Settings",className:"thread-icon-button inline-flex h-10 w-10 items-center justify-center rounded-full sm:h-9 sm:w-9",children:t.jsx($.Settings,{className:"h-4 w-4"})})}),t.jsxs(ps,{"data-testid":"settings-dialog","data-theme-effective":de,"data-theme-mode":K,className:"thread-graph-settings-dialog thread-graph-dialog",children:[t.jsxs(fs,{children:[t.jsx(gs,{children:"Settings"}),t.jsx(xs,{children:"Manage this session and host-wide preferences."})]}),Ke?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"font-medium text-[var(--theme-fg)]",children:"Appearance"}),t.jsxs("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:["Current theme: ",de]})]}),t.jsx("div",{className:"thread-graph-theme-mode-group grid grid-cols-3 gap-1 rounded-lg border p-1",role:"group","aria-label":"Theme mode",children:xp.map(Ue=>{const mt=Ue.icon,yt=K===Ue.value;return t.jsxs("button",{type:"button","data-testid":`theme-mode-${Ue.value}`,"aria-pressed":yt,disabled:!Ke,onClick:()=>tt==null?void 0:tt(Ue.value),className:`thread-graph-theme-mode-button inline-flex min-h-9 items-center justify-center gap-1.5 rounded-md px-2 text-xs font-medium transition ${yt?"is-selected":""}`,children:[t.jsx(mt,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:"truncate",children:Ue.label})]},Ue.value)})})]})}):null,ze?t.jsxs("div",{className:"thread-graph-settings-tabs grid grid-cols-2 gap-1 rounded-lg border p-1",children:[t.jsx("button",{type:"button","aria-pressed":Fe==="session",onClick:()=>xe("session"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Fe==="session"?"is-active":""}`,children:"Session"}),t.jsx("button",{type:"button","aria-pressed":Fe==="global",onClick:()=>xe("global"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Fe==="global"?"is-active":""}`,children:"Global"})]}):null,t.jsx("div",{className:"thread-graph-settings-body mt-4 min-h-0 overflow-y-auto pr-1 text-sm",children:Fe==="session"?t.jsxs("div",{className:"grid gap-4",children:[S?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:S}):null,v?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:v}):null,M?null:t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3 text-[var(--theme-fg-muted)]",children:"No session settings are available."})]}):t.jsx("div",{className:"thread-graph-settings-global-content",children:N})})]})]})}function $e(M=!1){return t.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:t.jsxs("section",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs("div",{className:`mb-3 flex items-center gap-2 px-2 text-xs font-medium tracking-normal text-[var(--theme-fg-muted)] ${M?"justify-center":""}`,children:[t.jsx($.Rows3,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:M?"sr-only":"",children:"Rooms"}),!M&&n?t.jsx("span",{className:"ml-auto text-xs text-[var(--theme-fg-muted)]",children:"Refreshing..."}):null]}),t.jsxs("div",{className:"min-h-0 min-w-0 flex-1 overflow-x-hidden overflow-y-auto px-1",children:[a?t.jsx("div",{className:"rounded-xl border border-rose-500/30 bg-rose-500/10 px-3 py-3 text-sm text-rose-900 dark:text-rose-100",children:a}):null,!a&&Ge.length===0&&!n?t.jsx("div",{className:"rounded-xl border border-dashed border-[var(--theme-border)] bg-[var(--theme-surface)] px-4 py-6 text-sm text-[var(--theme-fg-muted)]",children:"No threads available in this view."}):null,Ge.length>0?t.jsx(vp,{threads:Ge,currentThreadId:p,currentWorkspaceId:k,workspaceLabels:L,onOpenThread:X,collapsed:M,...H?{onBeginRenameThread:Ve}:{},showDeleteButton:!!G,...Q?{getThreadHref:Q}:{},...ie?{renderThreadLink:ie}:{},...G?{onDeleteThread:G}:{}}):null]})]})})}function We(){return T?t.jsxs("div",{className:"thread-workspace-panel relative flex h-full min-h-0 flex-col overflow-hidden rounded-[12px] border",children:[t.jsx("button",{type:"button",onClick:()=>ce(!0),className:"thread-workspace-collapse-tab thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx($.ChevronsRight,{className:"h-4 w-4"})}),B?t.jsx("div",{className:"pointer-events-none absolute right-12 top-2 z-20 flex items-center gap-1",children:t.jsx("div",{className:"pointer-events-auto",children:B})}):null,t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:T})]}):t.jsxs("div",{className:"thread-workspace-panel flex h-full min-h-0 flex-col overflow-hidden rounded-[12px] border",children:[t.jsxs("div",{className:"thread-workspace-panel-header flex h-12 shrink-0 items-center justify-between gap-3 border-b border-[var(--theme-border)] px-3 sm:h-[60px] sm:px-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-base font-semibold text-[var(--theme-fg)] sm:text-[18px]",children:F}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:w??k??"Current context"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[B,t.jsx("button",{type:"button",onClick:()=>ce(!0),className:"thread-workspace-small-toggle thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx($.ChevronsRight,{className:"h-4 w-4"})})]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:T??t.jsxs("div",{className:"grid h-full min-h-0 gap-3 overflow-y-auto p-3 text-sm text-[var(--theme-fg-soft)]",children:[t.jsxs("div",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:"Runtime"}),t.jsx("p",{className:"mt-2 text-[var(--theme-fg)]",children:(r==null?void 0:r.state)??"unknown"})]}),t.jsxs("div",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:"Workspace"}),t.jsx("p",{className:"mt-2 break-words text-[var(--theme-fg)]",children:w??k??"All threads"})]})]})})]})}const ut=!!T,st=o==="mobile"||o==="responsive"&&ne,ct=st,xt=ct&&!ee,wt=!!(R||P)?t.jsx("a",{href:R??"#",onClick:M=>{P&&(M.preventDefault(),P())},className:"thread-icon-button inline-flex h-10 w-10 items-center justify-center rounded-full sm:h-9 sm:w-9",title:"Back to workspace","aria-label":"Back to workspace",children:t.jsx($.ArrowLeft,{className:"h-4 w-4"})}):null;return t.jsxs(t.Fragment,{children:[t.jsx(ip,{effectiveTheme:de,layoutMode:o,themeMode:K,viewportConstrained:s,children:t.jsxs(dp,{roomsRailCollapsed:le,children:[t.jsx(cp,{open:ee,onClose:()=>ke(!1)}),t.jsxs(hp,{collapsed:le,mobileOpen:ee,children:[t.jsx("div",{className:`thread-rooms-rail-header flex h-[calc(3rem+env(safe-area-inset-top))] shrink-0 items-end border-b border-[var(--theme-border)] px-4 pb-2 sm:h-16 sm:items-center sm:pb-0 ${le?"sm:w-full sm:justify-center sm:px-2":""}`,children:t.jsxs("div",{className:`flex w-full items-center gap-3 ${le?"sm:justify-center":"justify-between"}`,children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[t.jsx("button",{type:"button",onClick:()=>je(M=>!M),className:"thread-icon-button thread-desktop-only-flex h-9 w-9 shrink-0 items-center justify-center rounded-full",title:le?"Expand rooms":"Collapse rooms","aria-label":le?"Expand rooms":"Collapse rooms",children:le?t.jsx($.PanelLeftOpen,{className:"h-4 w-4"}):t.jsx($.PanelLeftClose,{className:"h-4 w-4"})}),t.jsx("div",{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-[var(--theme-accent-solid)] text-sm font-semibold text-[var(--theme-accent-solid-fg)] ${le?"thread-desktop-collapsed-hidden":""}`,children:(w??"R").charAt(0).toUpperCase()}),t.jsxs("div",{className:`min-w-0 ${le?"thread-desktop-collapsed-hidden":""}`,children:[t.jsx("p",{className:"truncate text-sm font-semibold text-[var(--theme-fg)]",children:w??"Remote Codex"}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:k??"Thread workspace"})]})]}),t.jsxs("div",{className:`flex shrink-0 items-center gap-1 ${le?"thread-desktop-collapsed-hidden":""}`,children:[nt(),wt,t.jsx("button",{type:"button",onClick:()=>ke(!1),"aria-label":"Close rooms",title:"Close rooms",className:"thread-icon-button thread-mobile-only-inline-flex h-10 w-10 items-center justify-center rounded-full",children:t.jsx($.X,{className:"h-4 w-4"})})]})]})}),t.jsx("div",{className:`thread-graph-new-room-strip flex shrink-0 items-center border-b ${le?"h-12 w-full justify-center px-2 sm:h-12":"h-[68px] px-4"}`,children:rt(`thread-graph-new-room-button inline-flex items-center justify-center rounded-xl font-medium transition ${le?"h-9 w-9 p-0":"h-11 w-full gap-2 px-3 text-sm sm:h-9"}`,le)}),t.jsx("div",{className:`flex min-h-0 flex-1 flex-col ${le?"w-full px-2 py-2":"px-3 py-3"}`,children:$e(le)})]}),t.jsxs(up,{children:[t.jsx(mp,{children:t.jsx("div",{className:"thread-topbar-row flex min-h-12 items-center px-3 py-1.5 sm:min-h-12 sm:px-4",children:t.jsxs("div",{className:"flex w-full items-center justify-between gap-3 sm:gap-4",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:gap-3",children:[xt?t.jsx("button",{type:"button",onClick:()=>ke(!0),"aria-label":"Open rooms",title:"Open rooms",className:"thread-icon-button thread-mobile-only-inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-full",children:t.jsx($.Menu,{className:"h-4 w-4"})}):null,t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"min-w-0 truncate text-sm font-semibold leading-tight text-[var(--theme-fg)] sm:text-base",title:g??"Shared Workspace",children:g??"Shared Workspace"}),t.jsxs("div",{className:"relative mt-0.5 flex min-w-0 items-center gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{Ne(M=>!M)},"aria-expanded":ge,"aria-haspopup":"dialog",className:"thread-topbar-meta-row flex min-w-0 max-w-full items-center gap-1 text-left text-[11px] leading-none sm:text-xs",title:"Session and usage",children:[t.jsx("span",{className:"shrink-0",children:"Room"}),t.jsx("span",{className:"truncate font-mono",children:Qe})]}),ge?t.jsxs("div",{className:"thread-topbar-details-popover absolute left-0 top-[calc(100%+0.5rem)] z-50 w-[min(28rem,calc(100vw-1.5rem))] rounded-lg border p-2.5 shadow-lg",role:"dialog","aria-label":"Session and usage",children:[t.jsxs("button",{type:"button",onClick:()=>{var M;et&&((M=navigator.clipboard)==null||M.writeText(et))},className:"thread-topbar-meta-row flex min-w-0 max-w-full items-center gap-2 text-left text-xs leading-5",title:"Copy session ID",children:[t.jsx("span",{className:"w-14 shrink-0",children:"Session"}),t.jsx("span",{className:"truncate font-mono",children:et})]}),t.jsxs("div",{className:"thread-topbar-meta-row mt-1 flex min-w-0 max-w-full items-start gap-2 text-xs leading-5",title:"Session token usage and estimated cost",children:[t.jsx("span",{className:"w-14 shrink-0",children:"Usage"}),t.jsx("span",{className:"min-w-0 whitespace-normal break-words font-mono",children:it})]})]}):null]})]})]}),t.jsxs("div",{className:"relative z-[1] inline-flex shrink-0 items-center gap-2",children:[y||b?t.jsxs("div",{className:"thread-graph-topbar-actions thread-desktop-only-inline-flex items-center rounded-lg border p-0.5 shadow-none",children:[y,b]}):null,ct&&y?t.jsx("div",{className:"thread-mobile-only-inline-flex",children:y}):null,ct&&ut?t.jsx("button",{type:"button",onClick:()=>me(M=>M==="workspace"?"chat":"workspace"),"aria-label":Y==="workspace"?"Show chat":"Show workspace",title:Y==="workspace"?"Show chat":"Show workspace",className:"thread-icon-button thread-mobile-only-inline-flex h-10 w-10 items-center justify-center rounded-full",children:Y==="workspace"?t.jsx($.MessageSquare,{className:"h-4 w-4"}):t.jsx($.Folder,{className:"h-4 w-4"})}):null,ct?f:null,ct&&h?rt("thread-secondary-action inline-flex h-10 items-center justify-center gap-2 rounded-lg border px-3 text-sm font-medium sm:h-9"):null]})]})})}),t.jsx(pp,{children:ut&&!Ae?st?t.jsxs("div",{className:"thread-split-container thread-graph-shell-mobile-split h-full min-h-0 overflow-hidden",children:[t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${Y==="chat"?"block":"thread-mobile-chat-hidden"}`,children:E}),t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${Y==="workspace"?"block":"thread-mobile-workspace-hidden"}`,children:We()})]}):t.jsxs(_n,{direction:"horizontal",className:"thread-split-container thread-graph-shell-resizable thread-graph-shell-desktop-split h-full min-h-0 overflow-hidden",children:[t.jsx(or,{defaultSize:47,minSize:30,maxSize:75,className:"thread-split-chat-pane min-w-0 overflow-hidden",children:E}),t.jsx(Dn,{className:"thread-resize-handle w-2 bg-transparent after:w-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(or,{defaultSize:53,minSize:30,maxSize:70,className:"thread-split-workspace-pane min-w-0 overflow-hidden",children:We()})]}):t.jsxs("div",{className:"thread-split-container relative h-full min-h-0 overflow-hidden",children:[ut&&Ae?t.jsx("button",{type:"button",onClick:()=>ce(!1),className:"thread-workspace-expand-fab thread-desktop-only-inline-flex",title:"Expand workspace","aria-label":"Expand workspace",children:t.jsx($.ChevronsLeft,{className:"h-4 w-4"})}):null,E]})})]})]})}),t.jsx(lp,{open:we!==null,title:"Rename Thread",label:"Thread Title",value:De,busy:_e!==null,onChange:Be,onCancel:A,onSubmit:()=>we?gt(we):void 0})]})}function wp({open:e,title:r,text:n,onClose:a}){return c.useEffect(()=>{if(!e)return;function s(o){o.key==="Escape"&&a()}return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[a,e]),e?Qr.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[90] flex items-center justify-center p-4 sm:p-6",children:[t.jsx("button",{type:"button","aria-label":"Close full text",onClick:a,className:"absolute inset-0 bg-stone-950/78 backdrop-blur-sm"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":r,className:"relative z-[1] flex max-h-[min(82vh,52rem)] w-full max-w-4xl flex-col overflow-hidden rounded-[1.8rem] border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-stone-800 px-4 py-3 sm:px-5",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:r}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:a,className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-stone-700 text-stone-300 transition hover:bg-stone-800",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-4 py-4 sm:px-5",children:t.jsx("pre",{className:"whitespace-pre-wrap break-words text-sm leading-6 text-stone-200",children:n})})]})]}),document.body):null}var yp=[/^(?: {0,3})#{1,6}\s+\S/m,/^(?: {0,3})>{1,}\s*\S/m,/^(?: {0,3})(?:[-+*]|\d{1,9}[.)])\s+(?:\[[ xX]\]\s+)?\S/m,/^(?: {0,3})(?:```|~~~)/m,/^(?: {0,3})(?:[-*_]\s*){3,}$/m],jp=/^(?:\|?[^|\n]+\|[^|\n]+(?:\|[^|\n]+)*\|?\s*\n\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$)/m,Np=/!?\[[^\]\n]+\]\([^)]+\)/,Cp=/`[^`\n]+`/,Sp=/(?:\*\*[^*\n]+\*\*|__[^_\n]+__)/,Tp=/(^|[^\w])(?:\*[^*\n]+\*|_[^_\n]+_)(?=[^\w]|$)/,Ep=/~~[^~\n]+~~/;function Lp(e){const r=e.trim();return r?yp.some(n=>n.test(r))||jp.test(r)?!0:/[`[\]*_~!]/.test(r)?Np.test(r)||Cp.test(r)||Sp.test(r)||Tp.test(r)||Ep.test(r):!1:!1}sn();function Xn(e,r){const n=new Map(r.map(o=>[o.id,o])),a=e.map(o=>{var l,i;return{...o.manifest,enabled:((l=n.get(o.manifest.id))==null?void 0:l.enabled)??!0,source:((i=n.get(o.manifest.id))==null?void 0:i.source)??"builtin"}}),s=new Set(e.map(o=>o.manifest.id));for(const o of r)s.has(o.id)||a.push(o);return a}function ca(e=[]){const r=Xn(e,[]),n=e;return{plugins:r,loading:!1,error:null,async refresh(){},async importPluginManifest(){},async setPluginEnabled(){},async uninstallPlugin(){},renderArtifact:o=>{var i;const l=n.find(d=>d.renderArtifact&&d.manifest.capabilities.artifactTypes.some(h=>h.type===o.artifact.type));return((i=l==null?void 0:l.renderArtifact)==null?void 0:i.call(l,o))??null},renderInlineCode:o=>{for(const l of n)for(const i of l.inlineCodeRenderers??[]){if(!i.languages.includes(o.language.trim().toLowerCase()))continue;const d=i.render(o);if(d)return d}return null},hasRendererForArtifact:o=>n.some(l=>!!l.renderArtifact&&l.manifest.capabilities.artifactTypes.some(i=>i.type===o.type)),getThreadPanels:()=>n.flatMap(o=>o.threadPanels??[])}}var ha=c.createContext(ca());function ua(){return c.useContext(ha)??ca()}Pr();function ul(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function bs(e){return ul(e)?Object.entries(e):e==null||e===""?[]:[["value",e]]}function ml(e){return typeof e=="string"?t.jsxs("span",{className:"thread-graph-tool-string",children:['"',e,'"']}):typeof e=="number"?t.jsx("span",{className:"thread-graph-tool-number",children:e}):typeof e=="boolean"?t.jsx("span",{className:"thread-graph-tool-boolean",children:String(e)}):e===null?t.jsx("span",{className:"thread-graph-tool-null",children:"null"}):typeof e=="object"?t.jsx("span",{className:"thread-graph-tool-object",children:JSON.stringify(e)}):t.jsx("span",{children:String(e)})}function Ip(e,r){return typeof r=="string"&&(e==="stdout"||e==="stderr"||e==="result")?t.jsx("pre",{className:"thread-graph-tool-output",children:r||"(empty)"}):typeof r=="object"&&r!==null?t.jsx("pre",{className:"thread-graph-tool-output",children:JSON.stringify(r,null,2)}):ml(r)}function vs({callId:e,toolName:r,status:n,parameters:a,result:s}){const o=c.useMemo(()=>{switch(n){case"completed":return{className:"is-completed",icon:t.jsx($.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"};case"failed":return{className:"is-failed",icon:t.jsx($.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"};default:return{className:"is-pending",icon:t.jsx($.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),label:"Running"}}},[n]),l=c.useMemo(()=>bs(s),[s]),i=c.useMemo(()=>bs(a),[a]),d=c.useMemo(()=>typeof s=="string"?s.length>0:ul(s)?["stdout","stderr","result"].some(f=>{const p=s[f];return typeof p=="string"&&p.length>0}):!1,[s]),h=n==="pending"||d,[u,m]=c.useState(h?"item-1":void 0);return c.useEffect(()=>{h&&m("item-1")},[e,h]),t.jsx("div",{className:"thread-graph-tool-call my-2 w-full font-sans not-prose",children:t.jsx(Lr,{type:"single",collapsible:!0,onValueChange:f=>m(f||void 0),className:"thread-graph-tool-accordion w-full overflow-hidden rounded-lg border",...u!==void 0?{value:u}:{},children:t.jsxs(Ir,{value:"item-1",className:"border-0",children:[t.jsx(on,{className:"thread-graph-tool-trigger px-4 py-3 hover:no-underline",children:t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx($.Wrench,{className:"h-4 w-4 shrink-0"}),t.jsx("span",{className:"min-w-0 truncate font-mono text-sm font-semibold",children:r}),t.jsxs("span",{className:`thread-graph-tool-badge ${o.className}`,title:o.label,"aria-label":`Status: ${o.label}`,children:[o.icon,t.jsx("span",{className:"thread-graph-status-label",children:o.label})]})]})}),t.jsxs(zr,{className:"thread-graph-tool-content px-4 pb-4 pt-1",children:[t.jsxs("section",{children:[t.jsx("h4",{children:"Parameters"}),t.jsxs("div",{className:"thread-graph-tool-json",children:["{",t.jsx("br",{}),i.length>0?i.map(([f,p],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',f,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),ml(p),g<i.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},f)):t.jsx("div",{children:t.jsx("span",{className:"thread-graph-tool-null",children:"empty"})}),"}"]})]}),l.length>0?t.jsxs("section",{children:[t.jsx("h4",{children:"Result"}),t.jsxs("div",{className:"thread-graph-tool-json",children:["{",t.jsx("br",{}),l.map(([f,p],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',f,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),Ip(f,p),g<l.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},f)),"}"]})]}):null]})]})})})}var ks=null;function zp(){return ks??(ks=Promise.all([Xe(()=>import("./core-DODVy7wn.js"),__vite__mapDeps([0,1,2])),Xe(()=>import("./engine-javascript-DBd1bXLz.js"),[]),Xe(()=>import("./ayu-light-BA47KaF1.js"),[]),Xe(()=>import("./ayu-dark-DYE7WIF3.js"),[]),Xe(()=>import("./javascript-wDzz0qaB.js"),[]),Xe(()=>import("./typescript-BPQ3VLAy.js"),[]),Xe(()=>import("./tsx-COt5Ahok.js"),[]),Xe(()=>import("./jsx-g9-lgVsj.js"),[]),Xe(()=>import("./python-B6aJPvgy.js"),[]),Xe(()=>import("./json-Cp-IABpG.js"),[]),Xe(()=>import("./shellscript-CEILq0vU.js").then(e=>e.b),[]),Xe(()=>import("./shellscript-CEILq0vU.js").then(e=>e.s),[]),Xe(()=>import("./yaml-Buea-lGh.js"),[]),Xe(()=>import("./toml-vGWfd6FD.js"),[]),Xe(()=>import("./markdown-Cvjx9yec.js"),[]),Xe(()=>import("./html-pp8916En.js"),__vite__mapDeps([3,4,5])),Xe(()=>import("./css-CLj8gQPS.js"),[]),Xe(()=>import("./sql-CRqJ_cUM.js"),[]),Xe(()=>import("./csv-fuZLfV_i.js"),[])]).then(([{createHighlighterCore:e},{createJavaScriptRegexEngine:r},n,a,s,o,l,i,d,h,u,m,f,p,g,k,w,x,j])=>e({engine:r(),themes:[n.default,a.default],langs:[s.default,o.default,l.default,i.default,d.default,h.default,u.default,m.default,f.default,p.default,g.default,k.default,w.default,x.default,j.default]}))),ks}function ln(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Yn(e){if(!e)return{};if(ln(e)&&Object.prototype.hasOwnProperty.call(e,"0"))try{const r=Object.keys(e).map(Number).filter(n=>Number.isFinite(n)).sort((n,a)=>n-a).map(n=>String(e[String(n)]??"")).join("");return JSON.parse(r)}catch{return e}if(typeof e=="string")try{return JSON.parse(e)}catch{return e}return e}function Zn(){return{finalResult:null,stdout:"",stderr:""}}function Pp(e){return typeof e=="string"?{result:e}:e}function pl(e){const r=ln(e.finalResult)?{...e.finalResult}:e.finalResult!=null?{result:e.finalResult}:{};return e.stdout&&(r.stdout=e.stdout),e.stderr&&(r.stderr=e.stderr),!("status"in r)&&(e.stdout||e.stderr)&&(r.status="pending"),r}function ws(e){if(!e)return"pending";if(!ln(e))return"completed";const r=e.status;return r==="stream"||r==="pending"||r==="running"?"pending":r==="failed"||r==="error"||r==="timed_out"||typeof e.exit_code=="number"&&e.exit_code!==0?"failed":"completed"}function Rp(e){const r=new Map,n=/```tool-result\s*([\s\S]*?)\s*```/g,a=e.replace(n,(l,i)=>{try{const d=JSON.parse(i),h=d.call_id;if(typeof h!="string")return l;const u=Pp(d.result),m=r.get(h)??Zn();return ln(u)&&u.status==="stream"&&typeof u.chunk=="string"?u.stream==="stderr"?m.stderr+=u.chunk:m.stdout+=u.chunk:m.finalResult=u,r.set(h,m),""}catch{return l}}),s=/```tool-call\s*([\s\S]*?)\s*```/g;return{processedContent:a.replace(s,(l,i)=>{try{const d=JSON.parse(i),h=d.call_id,u=d.tool;if(typeof u!="string")return l;const m=Yn(d.args);if(typeof h=="string"&&r.has(h)){const f=pl(r.get(h)??Zn());return`\`\`\`tool-merged
|
|
3691
|
+
`,ms="MCP entry written to provider config. Restart the backend if it does not appear immediately.";function Zm({hostConfigFilesAvailable:e,onReadProviderConfig:r,onWriteProviderConfig:n,setMcpPanelMode:a,onOpenMcp:s}){const[o,l]=c.useState(""),[i,d]=c.useState(""),[h,u]=c.useState(""),[m,f]=c.useState(null),[p,g]=c.useState(!1),[k,w]=c.useState(null),[x,j]=c.useState(null),y=c.useCallback(()=>{w(null),j(null)},[]),b=c.useCallback(async()=>{if(!e||!r)throw new Error("Provider config editing is unavailable for this thread.");const R=await r();return f(R.path),R},[e,r]),v=c.useCallback(async R=>{if(!e||!n)throw new Error("Provider config editing is unavailable for this thread.");const P=await n(R);return f(P.path),P},[e,n]),S=c.useCallback(async()=>{const R=_u(o),P=i.trim();if(!R){w("MCP name must use only letters, numbers, underscore, or hyphen.");return}if(!/^https?:\/\//i.test(P)){w("HTTP MCP URL must start with http:// or https://");return}g(!0),w(null),j(null);try{const Q=await b(),K=os(Q.content,R,Du(R,P));await v(K),j(ms),a("list"),l(""),d(""),s==null||s()}catch(Q){w(Q instanceof Error?Q.message:"Unable to update provider config.")}finally{g(!1)}},[b,o,i,s,a,v]),N=c.useCallback(async()=>{g(!0),w(null),j(null);try{await b(),u(R=>R||Ym),a("stdio")}catch(R){w(R instanceof Error?R.message:"Unable to load provider config.")}finally{g(!1)}},[b,a]),L=c.useCallback(async()=>{const R=$u(h);if(!R){w("The raw MCP block must start with a header like [mcp_servers.name].");return}g(!0),w(null),j(null);try{const P=await b(),Q=os(P.content,R,h);await v(Q),j(ms),a("list"),s==null||s()}catch(P){w(P instanceof Error?P.message:"Unable to update provider config.")}finally{g(!1)}},[b,h,s,a,v]);return{mcpHttpName:o,mcpHttpUrl:i,mcpRawBlock:h,mcpConfigPath:m,mcpConfigBusy:p,mcpConfigError:k,mcpConfigSuccess:x,setMcpHttpName:l,setMcpHttpUrl:d,setMcpRawBlock:u,clearMcpConfigStatus:y,prepareRawMcpBlock:N,saveHttpMcp:S,saveRawMcpBlock:L}}function Jm({openMenu:e,setOpenMenu:r,slashPanelView:n,setSlashPanelView:a,setMcpPanelMode:s,clearMcpConfigStatus:o,clearHookConfigStatus:l}){const[i,d]=c.useState(null);c.useEffect(()=>{e!=="slash"&&(a("root"),s("list"),o(),l())},[l,o,e,s,a]),c.useEffect(()=>{n!=="mcp"&&(s("list"),o())},[o,s,n]),c.useEffect(()=>{if(!i)return;const u=window.setTimeout(()=>{d(m=>m===i?null:m)},1400);return()=>{window.clearTimeout(u)}},[i]),c.useEffect(()=>{function u(m){(typeof m.composedPath=="function"?m.composedPath():[]).some(g=>g instanceof HTMLElement&&(g.dataset.composerMenuSurface==="true"||g.dataset.composerMenuTrigger==="true"))||e&&r(null)}if(e)return window.addEventListener("pointerdown",u),()=>{window.removeEventListener("pointerdown",u)}},[e,r]);const h=c.useCallback(async u=>{try{await navigator.clipboard.writeText(`$${u}`),d(u)}catch{d(null)}},[]);return{copiedSkillName:i,copySkillInvokeName:h}}function Qm(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=is(n),a.append(i),a}a.classList.add("items-center","gap-2","rounded-[0.95rem]","border","border-emerald-300/35","bg-emerald-300/10","px-2.5","py-2","text-[10px]","font-medium","tracking-[0.08em]","text-emerald-50","shadow-sm","shadow-stone-950/20");const s=document.createElement("span");s.className="inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-emerald-200/25 bg-emerald-300/12 text-[9px]",s.textContent="FILE";const o=document.createElement("span");return o.className="inline-flex max-w-[10rem] truncate",o.textContent=is(n),a.append(s,o),a}function ep(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(Qm(a,r))}return n}function tp({promptRef:e,isShellView:r,prompt:n,promptSegments:a,attachmentPreviewUrls:s,previewSignature:o,editorSanitizeNonce:l,pendingSelectionRef:i,pendingInsertedAttachmentIdsRef:d,selectionSnapshotRef:h,renderedPreviewSignatureRef:u,renderedSanitizeNonceRef:m,serializeEditorPrompt:f,restoreSelection:p}){c.useLayoutEffect(()=>{const g=e.current;if(!g||r)return;const k=i.current,w=f()!==n||u.current!==o||m.current!==l;w&&(g.replaceChildren(ep(a,s)),u.current=o,m.current=l),k!==null?(g.focus(),pm(g,d.current)||p(k),h.current=k):document.activeElement===g&&w&&p(h.current),i.current=null,d.current=[]},[s,l,r,o,n,e,a,d,i,u,m,p,h,f])}function rp({tokenBudget:e,error:r,onTokenBudgetChange:n,onCancel:a}){return t.jsxs("div",{className:"thread-goal-compose-card relative z-20 mb-1.5 flex flex-wrap items-center gap-2 rounded-2xl border px-3 py-2 text-xs shadow-sm",children:[t.jsx("span",{className:"thread-goal-compose-label font-medium uppercase tracking-[0.16em]",children:"Goal"}),t.jsxs("label",{className:"thread-goal-compose-field flex items-center gap-2",children:[t.jsx("span",{children:"Max tokens (k)"}),t.jsx("input",{"aria-label":"Goal token budget",value:e,onChange:s=>n(s.target.value),inputMode:"numeric",placeholder:"Optional",className:"thread-goal-compose-input h-7 w-24 rounded-full border px-3 text-xs outline-none"})]}),r?t.jsx("span",{className:"thread-goal-compose-error min-w-0 flex-1",children:r}):null,t.jsx("button",{type:"button",onClick:a,className:"thread-goal-compose-cancel rounded-full border px-2.5 py-1 text-[11px] transition",children:"Cancel"})]})}function np(){var r,n;return!!((n=(r=window.webkit)==null?void 0:r.messageHandlers)!=null&&n.remoteCodex)}function ap({promptRef:e,prompt:r,disabled:n,promptPlaceholder:a,canInterrupt:s,interruptLabel:o,composerPromptRegionClassName:l,graphChatInputClassName:i,onInterrupt:d,onInput:h,onPointerDown:u,onPaste:m,onKeyDown:f,onKeyUp:p,onMouseUp:g,onBlur:k,onDragEnter:w,onDragOver:x,onDragLeave:j,onDrop:y}){return t.jsxs("div",{"data-slot":"input-group-control",className:`${l} relative w-full`,children:[t.jsxs("div",{className:i,children:[r.length===0&&t.jsx("span",{className:`pointer-events-none absolute left-3 top-3 truncate text-slate-500 sm:left-4 sm:top-4 dark:text-slate-400 ${s?"right-12":"right-3 sm:right-4"}`,children:a}),t.jsx("div",{ref:e,role:"textbox","aria-label":"Prompt","aria-multiline":"true",contentEditable:!n,inputMode:"text",suppressContentEditableWarning:!0,onPointerDown:b=>{!n&&document.activeElement!==b.currentTarget&&np()&&b.currentTarget.focus({preventScroll:!0}),u==null||u(b)},onInput:h,onPaste:m,onKeyDown:f,onKeyUp:p,onMouseUp:g,onBlur:k,onDragEnter:w,onDragOver:x,onDragLeave:j,onDrop:y,className:`relative z-[1] min-h-[4.25rem] whitespace-pre-wrap break-words pb-2 outline-none sm:min-h-[4.25rem] ${s?"pr-12":""} ${n?"cursor-not-allowed text-slate-500":""}`})]}),s?t.jsx(Ct,{type:"button",variant:"ghost",size:"icon-xs","aria-label":o,title:o,onClick:b=>{b.preventDefault(),d==null||d()},className:"thread-graph-composer-stop-button ui-action-danger absolute right-2 top-2 z-30 h-8 w-8 rounded-full text-sm font-medium",children:t.jsx("span",{"aria-hidden":"true",className:"block h-2.5 w-2.5 rounded-[2px] bg-current"})}):null]})}function sp({prompt:e,promptPlaceholder:r,promptRegionClassName:n,promptInputClassName:a,interruptLabel:s,canInterrupt:o,sendButtonLabel:l,sendButtonClassName:i,sendDisabled:d,onPromptChange:h,onPromptKeyDown:u,onInterrupt:m}){return t.jsxs("div",{className:`${n} relative`,children:[t.jsx("textarea",{"aria-label":"Prompt",disabled:!1,value:e,onChange:f=>h(f.target.value),onKeyDown:u,rows:2,placeholder:r,className:`${a} resize-y pb-10`}),t.jsx("button",{type:"button","aria-label":s,title:s,onClick:()=>void(m==null?void 0:m()),disabled:!o,className:`absolute right-2.5 top-2.5 inline-flex h-8 w-8 items-center justify-center rounded-full border transition ${o?"border-rose-300/55 bg-rose-300/[0.14] text-rose-50 shadow-lg shadow-rose-950/20 hover:bg-rose-300/[0.22]":"cursor-not-allowed border-stone-700/30 bg-stone-400/[0.02] text-stone-500/55 opacity-55"}`,children:t.jsx("span",{"aria-hidden":"true",className:"block h-2.5 w-2.5 rounded-[2px] bg-current"})}),t.jsx("button",{type:"submit","aria-label":"Send Shell Input",onMouseDown:f=>{f.preventDefault()},onPointerDown:f=>{f.preventDefault()},onTouchStart:f=>{f.preventDefault()},disabled:d,className:`absolute bottom-2.5 right-2.5 rounded-full px-3.5 py-1.5 text-sm font-medium shadow-lg shadow-stone-950/30 transition disabled:cursor-not-allowed disabled:bg-stone-700 disabled:text-stone-300 ${i}`,children:l})]})}function op({isShellView:e,promptRef:r,prompt:n,disabled:a,promptPlaceholder:s,canInterrupt:o,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,promptInputClassName:h,goalComposeMode:u,goalTokenBudget:m,goalLocalError:f,goalBusy:p,busy:g,sendButtonLabel:k,sendButtonClassName:w,onInterrupt:x,onPromptInput:j,onPromptPaste:y,onPromptKeyDown:b,onPromptKeyUp:v,onPromptMouseUp:S,onPromptBlur:N,onPromptDragEnter:L,onPromptDragOver:R,onPromptDragLeave:P,onPromptDrop:Q,onGoalTokenBudgetChange:K,onCancelGoal:J,onShellPromptChange:B}){return{promptSlot:e?null:t.jsx(ap,{promptRef:r,prompt:n,disabled:a,promptPlaceholder:s,canInterrupt:o,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,onInterrupt:x,onInput:j,onPaste:y,onKeyDown:b,onKeyUp:v,onMouseUp:S,onBlur:N,onDragEnter:L,onDragOver:R,onDragLeave:P,onDrop:Q}),goalSlot:u&&!e?t.jsx(rp,{tokenBudget:m,error:f,onTokenBudgetChange:K,onCancel:J}):null,shellPromptSlot:e?t.jsx(sp,{prompt:n,promptPlaceholder:s,promptRegionClassName:i,promptInputClassName:h,interruptLabel:l,canInterrupt:o,sendButtonLabel:k,sendButtonClassName:w,sendDisabled:p||g,onPromptChange:B,onPromptKeyDown:b,onInterrupt:x}):null}}function lp({collaborationMode:e,onUpdateSettings:r,closeMenu:n}){const[a,s]=c.useState(null),o=a??e;c.useEffect(()=>{s(null)},[e]);const l=c.useCallback(async i=>{const d=Ru({nextMode:i.collaborationMode,previousOptimisticMode:a});d.optimisticMode&&s(d.optimisticMode);try{await(r==null?void 0:r(i)),d.closeMenuOnSuccess&&n()}catch(h){throw d.shouldRollbackMode&&s(d.rollbackMode),h}},[n,r,a]);return{displayedCollaborationMode:o,updateSettings:l}}function ip({isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:s,toolbarClassName:o,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,inlineToggleClassName:m,planToggleActiveClassName:f,sendButtonBaseClassName:p,slashPanelView:g,availableToolboxItems:k,busy:w,settingsBusy:x,compactBusy:j,forkBusy:y,fastMode:b,goalComposeMode:v,goalBusy:S,goalStatus:N,activeView:L,disabled:R,model:P,modelOptions:Q,modelContextTitle:K,contextUsage:J,reasoningEffort:B,supportedEfforts:z,displayedCollaborationMode:te,sandboxMode:se,sendButtonLabel:$,sendButtonClassName:ie,modelControlsDisabled:q,effortControlsDisabled:H,effortControlTitle:G,forkTurnOptionsState:T,skillsState:F,goalState:D,goalHistory:E,copiedSkillName:C,hooksPanelMode:W,hooksState:U,hookConfigBusy:ae,hookConfigError:X,hookConfigSuccess:de,editingHookTarget:ee,hookScope:ke,hookEventName:le,hookMatcher:je,hookCommand:Ae,hookTimeoutSec:ce,hookStatusMessage:ne,mcpPanelMode:Le,mcpState:Z,mcpConfigPath:me,mcpConfigError:we,mcpConfigSuccess:ye,mcpConfigBusy:De,mcpHttpName:Be,mcpHttpUrl:$e,mcpRawBlock:Oe,capabilities:V,shellControlState:he,onToggleView:ve,onDismissPromptFocus:I,onSetOpenMenu:O,onToolboxItemClick:oe,onSetSlashPanelView:ge,onViewGoals:Ne,onUpdateGoal:Ce,onOpenForkTurns:xe,onForkLatest:Ge,onForkTurn:Me,onCopySkillInvokeName:Qe,onResetHookForm:et,onSetHooksPanelMode:it,onClearHookConfigStatus:tt,onSetEditingHookTarget:Ke,onSetHookScope:dt,onSetHookEventName:gt,onSetHookMatcher:qe,onSetHookCommand:A,onSetHookTimeoutSec:Y,onSetHookStatusMessage:be,onSaveHook:Se,onStartEditingHook:Pe,onTrustHook:rt,onUntrustHook:nt,onSetMcpPanelMode:_e,onClearMcpConfigStatus:We,onSetMcpHttpName:ut,onSetMcpHttpUrl:st,onSetMcpRawBlock:ct,onPrepareRawMcpBlock:xt,onSaveHttpMcp:Rt,onSaveRawMcpBlock:wt,onPickPhoto:M,onPickFile:fe,onUpdateSettings:ze,onPasteShell:Fe,onCopyShell:Ue,onClearShell:mt,onShellControl:yt}){const Kt=e?null:{open:s==="slash",slashPanelView:g,availableToolboxItems:k,busy:w,forkBusy:y,forkTurnOptionsState:T,skillsState:F,goalState:D,goalHistory:E,goalBusy:S,copiedSkillName:C,hooksPanelMode:W,hooksState:U,hostConfigFilesAvailable:V.hostConfigFiles,hookTrustAvailable:V.hookTrust,hookConfigBusy:ae,hookConfigError:X,hookConfigSuccess:de,editingHookTarget:ee,hookScope:ke,hookEventName:le,hookMatcher:je,hookCommand:Ae,hookTimeoutSec:ce,hookStatusMessage:ne,mcpPanelMode:Le,mcpState:Z,mcpConfigEditing:V.mcpConfigEditing,mcpConfigPath:me,mcpConfigError:we,mcpConfigSuccess:ye,mcpConfigBusy:De,mcpHttpName:Be,mcpHttpUrl:$e,mcpRawBlock:Oe,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,onToggle:()=>O(ot=>ot==="slash"?null:"slash"),onToolboxItemClick:oe,toolboxItemDisabled:ot=>im(ot,{settingsBusy:x,compactBusy:j,busy:w,forkBusy:y}),toolboxItemClassName:ot=>dm(ot,{fastMode:b,goalComposeMode:v,goalStatus:N,menuItemClassName:d}),toolboxItemStatus:ot=>lm(ot,{fastMode:b,compactBusy:j,goalComposeMode:v,goalStatus:N,busy:w}),onSetSlashPanelView:ge,onViewGoals:Ne,onUpdateGoal:Ce,onOpenForkTurns:xe,onForkLatest:Ge,onForkTurn:Me,onCopySkillInvokeName:Qe,onResetHookForm:et,onSetHooksPanelMode:it,onClearHookConfigStatus:tt,onSetEditingHookTarget:Ke,onSetHookScope:dt,onSetHookEventName:gt,onSetHookMatcher:qe,onSetHookCommand:A,onSetHookTimeoutSec:Y,onSetHookStatusMessage:be,onSaveHook:Se,onStartEditingHook:Pe,onTrustHook:rt,onUntrustHook:nt,onSetMcpPanelMode:_e,onClearMcpConfigStatus:We,onSetMcpHttpName:ut,onSetMcpHttpUrl:st,onSetMcpRawBlock:ct,onPrepareRawMcpBlock:xt,onSaveHttpMcp:Rt,onSaveRawMcpBlock:wt},Yt=e?null:{open:s==="attachments",iconButtonClassName:l,menuClassName:i,menuItemClassName:d,onToggle:()=>O(ot=>ot==="attachments"?null:"attachments"),onPickPhoto:M,onPickFile:fe},At=e?null:{openMenu:s,model:P,modelOptions:Q,modelContextTitle:K,contextUsage:J,reasoningEffort:B,supportedEfforts:z,displayedCollaborationMode:te,sandboxMode:se,planModeAvailable:V.planMode,sandboxModeAvailable:V.sandboxMode,settingsBusy:x,goalComposeMode:v,goalBusy:S,activeView:L,disabled:R,fastMode:b,sendButtonLabel:$,sendButtonClassName:ie,modelControlsDisabled:q,effortControlsDisabled:H,effortControlTitle:G,inlineToggleClassName:m,menuItemClassName:d,planToggleActiveClassName:f,sendButtonBaseClassName:p,onSetOpenMenu:O,onUpdateSettings:ze};return{isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:s,toolbarClassName:o,iconButtonClassName:l,slashToolboxProps:Kt,attachmentMenuProps:Yt,settingsToolbarProps:At,shellToolsPanelProps:s==="shellTools"?{busy:w,shellControlState:he,onPaste:Fe,onCopy:Ue,onClear:mt,onShellControl:yt}:null,shellControlState:he,onToggleView:ve,onDismissPromptFocus:I,onSetOpenMenu:O}}function Yn({activeView:e,edgeToEdgeMobile:r=!1,busy:n=!1,settingsBusy:a=!1,compactBusy:s=!1,error:o,model:l=null,reasoningEffort:i=null,fastMode:d=!1,collaborationMode:h="default",sandboxMode:u=null,hideSandboxModeControl:m=!1,modelOptions:f=[],contextUsage:p=null,capabilities:g=null,toolboxItems:k=null,hookCommandTemplates:w=null,mcpConfigFormat:x="none",followTail:j=!1,threadConnected:y=!0,shellAvailable:b=!0,disabled:v=!1,disabledPlaceholder:S,shellControlState:N=null,draftPrompt:L,draftAttachments:R,onPickAttachment:P,skillsState:Q={status:"idle",data:null,error:null},mcpState:K={status:"idle",data:null,error:null},hooksState:J={status:"idle",data:null,error:null},goalState:B={status:"idle",data:null,error:null},goalHistory:z=[],forkTurnOptionsState:te={status:"idle",data:null,error:null},onDraftChange:se,onSubmit:$,onInterrupt:ie,onCompact:q,onOpenSkills:H,onOpenMcp:G,onOpenHooks:T,onCreateHook:F,onUpdateHook:D,onTrustHook:E,onUntrustHook:C,onOpenGoal:W,onPrepareGoalSubmit:U,onUpdateGoal:ae,onOpenForkTurns:X,onForkLatest:de,onForkTurn:ee,onReadProviderConfig:ke,onWriteProviderConfig:le,onToggleFollow:je,canJumpToPreviousTurn:Ae,onJumpToPreviousTurn:ce,canJumpToNextTurn:ne,onJumpToNextTurn:Le,subscriptionUsage:Z,onUpdateSettings:me,onToggleView:we,onShellCopy:ye,onShellControl:De,canInterrupt:Be=!1,pendingPrompts:$e=[],onSteerPendingPrompt:Oe,onCancelPendingPrompt:V}){var Ta;const[he,ve]=c.useState(null),[I,O]=c.useState("root"),oe=c.useRef(!1),[ge,Ne]=c.useState("list"),Ce=c.useMemo(()=>({fast:(g==null?void 0:g.controls.performanceMode)??!1,compact:(g==null?void 0:g.turns.compact)??!1,goal:(g==null?void 0:g.controls.goals)??!1,fork:(g==null?void 0:g.branching.fork)??!1,skills:(g==null?void 0:g.management.skills)??!1,mcp:(g==null?void 0:g.management.mcpStatus)??!1,hooks:(g==null?void 0:g.management.hooks)??!1,hostConfigFiles:(g==null?void 0:g.management.hostConfigFiles)??!1,mcpConfigEditing:x==="codex-toml"&&!!(g!=null&&g.management.hostConfigFiles)&&!!ke&&!!le,hookTrust:(g==null?void 0:g.management.hookTrust)??!1,planMode:(g==null?void 0:g.controls.planMode)??!1,sandboxMode:(g==null?void 0:g.controls.sandboxMode)??!1}),[g,x,ke,le]),xe=c.useMemo(()=>sm(k,Ce),[Ce,k]),Ge=c.useRef(null),Me=c.useRef(null),Qe=c.useRef(null),et=c.useRef(null),it=c.useRef(null),tt=c.useRef([]),Ke=c.useRef(null),dt=c.useRef(""),gt=c.useRef(0),qe=e==="shell",A=b||qe,Y=!!(qe&&(N!=null&&N.isMobileShell)),be=(N==null?void 0:N.promptLabel)??null,[Se,Pe]=c.useState(!1),[rt,nt]=c.useState(0),{prompt:_e,attachments:We,isDraftControlled:ut,updateDraft:st,flushControlledDraftToHost:ct}=Um({isShellView:qe,draftPrompt:L,draftAttachments:R,onDraftChange:se}),xt=Om({attachments:We,isShellView:qe}),{displayedCollaborationMode:Rt,updateSettings:wt}=lp({collaborationMode:h,onUpdateSettings:me,closeMenu:()=>ve(null)}),{forkBusy:M,forkLatest:fe,forkTurn:ze}=Vm({slashPanelView:I,onForkLatest:de,onForkTurn:ee,closeMenu:()=>ve(null)}),{hooksPanelMode:Fe,hookScope:Ue,hookEventName:mt,hookMatcher:yt,hookCommand:Kt,hookTimeoutSec:Yt,hookStatusMessage:At,editingHookTarget:mr,hookConfigBusy:ot,hookConfigError:un,hookConfigSuccess:mn,setHooksPanelMode:$l,setEditingHookTarget:Dl,setHookScope:Bl,setHookEventName:Gl,setHookMatcher:Fl,setHookCommand:Hl,setHookTimeoutSec:Ol,setHookStatusMessage:Wl,clearHookConfigStatus:ba,resetHookForm:Ul,startEditingHook:Vl,saveHook:ql,trustHook:Xl,untrustHook:Kl}=Km({slashPanelView:I,hookCommandTemplates:w,onCreateHook:F,onUpdateHook:D,onTrustHook:E,onUntrustHook:C}),{goalComposeMode:pr,goalTokenBudget:Yl,goalBusy:pn,goalLocalError:Zl,setGoalTokenBudget:Jl,submitGoal:Ql,enterGoalComposeMode:ei,exitGoalComposeMode:va}=qm({prompt:_e,goalTokenBudgetSource:B.data,promptRef:Me,onOpenGoal:W,onPrepareGoalSubmit:U,onUpdateGoal:ae,updateDraft:st,closeMenu:()=>ve(null),resetSlashPanel:()=>O("root")}),{mcpHttpName:ti,mcpHttpUrl:ri,mcpRawBlock:ni,mcpConfigPath:ai,mcpConfigBusy:si,mcpConfigError:oi,mcpConfigSuccess:li,setMcpHttpName:ii,setMcpHttpUrl:di,setMcpRawBlock:ci,clearMcpConfigStatus:ka,prepareRawMcpBlock:hi,saveHttpMcp:ui,saveRawMcpBlock:mi}=Zm({hostConfigFilesAvailable:Ce.hostConfigFiles,onReadProviderConfig:ke,onWriteProviderConfig:le,setMcpPanelMode:Ne,onOpenMcp:G}),{copiedSkillName:pi,copySkillInvokeName:fi}=Jm({openMenu:he,setOpenMenu:ve,slashPanelView:I,setSlashPanelView:O,setMcpPanelMode:Ne,clearMcpConfigStatus:ka,clearHookConfigStatus:ba}),gi=c.useCallback(re=>{st(Te=>{if(typeof re=="function"){const Re=re(Te.prompt,Te.attachments);return{prompt:Re.prompt,attachments:Re.attachments??Te.attachments}}return{prompt:re,attachments:Te.attachments}})},[st]),fn=c.useMemo(()=>f.find(re=>re.model===l)??null,[l,f]),xi=Bu(l,p),wa=(fn==null?void 0:fn.supportedReasoningEfforts)??[],bi=c.useMemo(()=>Nu(_e,We),[We,_e]),vi=c.useMemo(()=>Object.entries(xt).sort(([re],[Te])=>re.localeCompare(Te)).map(([re,Te])=>`${re}:${Te}`).join("|"),[xt]);function ki(re,Te){Te.stopPropagation();const Re=om(re,{fastMode:d,goalComposeMode:pr});switch(Re.type){case"toggleFast":wt({fastMode:Re.fastMode});break;case"runCompact":ve(null),q==null||q();break;case"enterGoalCompose":ei();break;case"exitGoalCompose":va(),ve(null);break;case"openPanel":O(Re.panel),Re.panel==="skills"?H==null||H():Re.panel==="mcp"?G==null||G():Re.panel==="hooks"&&(T==null||T());break;case"insertPrompt":bn(Re.text),O("root"),ve(null);break}}function Zt(){const re=Me.current;return re?um(re):null}const wi=c.useCallback(re=>{const Te=Me.current;!Te||!re||mm(Te,re)},[]),gn=c.useCallback(()=>{const re=Me.current;return re?cl(re):_e},[_e]),{appendAttachments:xn,appendDroppedAttachments:ya}=Hm({prompt:_e,attachments:We,updateDraft:st,getSelection:Zt,selectionSnapshotRef:Ke,pendingSelectionRef:it,pendingInsertedAttachmentIdsRef:tt,onInserted:()=>ve(null)}),ja=c.useCallback((re,Te)=>{var Re;if(Mt(),P){P({kind:re,appendAttachments:(Ze,lt=re)=>xn(Ze,lt),defaultPick:()=>{var Ze;return(Ze=Te.current)==null?void 0:Ze.click()}});return}(Re=Te.current)==null||Re.click()},[xn,Mt,P]);function bn(re){if(!re)return;const Te=Zt()??Ke.current,Re=(Te==null?void 0:Te.start)??_e.length,Ze=(Te==null?void 0:Te.end)??Re,lt=ju(re),Jt=`${_e.slice(0,Re)}${lt}${_e.slice(Ze)}`;st(rd=>({prompt:Jt,attachments:rd.attachments}));const _t=Re+lt.length;it.current={start:_t,end:_t},Ke.current={start:_t,end:_t}}tp({promptRef:Me,isShellView:qe,prompt:_e,promptSegments:bi,attachmentPreviewUrls:xt,previewSignature:vi,editorSanitizeNonce:rt,pendingSelectionRef:it,pendingInsertedAttachmentIdsRef:tt,selectionSnapshotRef:Ke,renderedPreviewSignatureRef:dt,renderedSanitizeNonceRef:gt,serializeEditorPrompt:gn,restoreSelection:wi});function Mt(){var re;(re=Me.current)==null||re.blur(),document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.blur()}async function yi(){var re;if(Mt(),ve(null),!!((re=navigator.clipboard)!=null&&re.readText))try{const Te=await navigator.clipboard.readText();bn(Te)}catch{return}}async function Na(){if(!oe.current){oe.current=!0;try{if(ut&&ct(),pr&&!qe){await Ql();return}const re=Lu({prompt:_e,attachments:We,isShellView:qe});if(!re||await $(re)===!1)return;st(()=>({prompt:"",attachments:[]}))}finally{oe.current=!1}}}async function ji(re){re.preventDefault(),await Na()}function Ni(){const re=gn(),Te=Zt();Ke.current=Te;const Re=Me.current;(Re?hm(Re):!1)&&(it.current=Te,nt(lt=>lt+1)),st(lt=>({prompt:re,attachments:lt.attachments.filter(Jt=>re.includes(Jt.placeholder))}),"deferred")}function Ci(re){var Ze,lt,Jt,_t;const Te=Xn((Ze=re.clipboardData)==null?void 0:Ze.items,(lt=re.clipboardData)==null?void 0:lt.files),Re=Iu({files:Te,plainText:((Jt=re.clipboardData)==null?void 0:Jt.getData("text/plain"))??"",htmlText:((_t=re.clipboardData)==null?void 0:_t.getData("text/html"))??"",htmlToText:cm});Re.preventDefault&&re.preventDefault(),Re.type==="insert-text"?bn(Re.text):Re.type==="append-files"&&ya(Re.files)}function Si(re){var Re,Ze;const Te=as(ls((Re=re.dataTransfer)==null?void 0:Re.items,(Ze=re.dataTransfer)==null?void 0:Ze.files));Te.preventDefault&&re.preventDefault(),Te.activateDragTarget&&Pe(!0)}function Ti(re){var Re,Ze;const Te=as(ls((Re=re.dataTransfer)==null?void 0:Re.items,(Ze=re.dataTransfer)==null?void 0:Ze.files));Te.preventDefault&&re.preventDefault(),Te.activateDragTarget&&re.dataTransfer&&(re.dataTransfer.dropEffect="copy"),Te.activateDragTarget&&Pe(!0)}function Ei(re){re.currentTarget.contains(re.relatedTarget)||Pe(!1)}function Li(re){var Ze,lt;const Te=Xn((Ze=re.dataTransfer)==null?void 0:Ze.items,(lt=re.dataTransfer)==null?void 0:lt.files),Re=zu(Te);Re.preventDefault&&re.preventDefault(),Re.type==="accept-files"&&(Pe(!1),ya(Re.files??[]))}function Ii(re){if(re.key==="Enter"&&re.repeat){re.preventDefault();return}if(e==="chat"&&re.key==="/"&&!re.metaKey&&!re.ctrlKey&&!re.altKey&&!n&&!v&&xe.length>0&&gn().trim().length===0){re.preventDefault(),O("root"),ve("slash");return}const Te=Pu({key:re.key,metaKey:re.metaKey,ctrlKey:re.ctrlKey,busy:n,disabled:v});Te.preventDefault&&re.preventDefault(),Te.submit&&Na()}const{promptPlaceholder:zi,interruptLabel:Pi,sendButtonLabel:Ca,sendButtonClassName:Sa,modelControlsDisabled:Ri,effortControlsDisabled:Ai,effortControlTitle:Mi}=Ou({goalComposeMode:pr,goalBusy:pn,threadConnected:y,busy:n,isShellView:qe,disabledPlaceholder:S,settingsBusy:a,supportedEffortCount:wa.length,fastMode:d}),{composerLayerClassName:_i,formClassName:$i,composerShellClassName:Di,composerToolbarClassName:Bi,composerIconButtonClassName:Gi,composerMenuClassName:Fi,composerMenuItemClassName:Hi,composerInlineToggleClassName:Oi,composerPanelButtonClassName:Wi,composerChipButtonClassName:Ui,composerPlanToggleActiveClassName:Vi,composerSendButtonClassName:qi,composerPromptRegionClassName:Xi,promptInputClassName:Ki,graphChatInputGroupClassName:Yi,graphChatInputClassName:Zi}=Wu({isShellView:qe,edgeToEdgeMobile:r,isMobileShell:Y,openMenu:he!==null,isDragTargetActive:Se,busy:n}),Ji=ip({isShellView:qe,canToggleShellView:A,isMobileShell:Y,shellPromptLabel:be,openMenu:he,toolbarClassName:Bi,iconButtonClassName:Gi,menuClassName:Fi,menuItemClassName:Hi,panelButtonClassName:Wi,chipButtonClassName:Ui,inlineToggleClassName:Oi,planToggleActiveClassName:Vi,sendButtonBaseClassName:qi,slashPanelView:I,availableToolboxItems:xe,busy:n,settingsBusy:a,compactBusy:s,forkBusy:M,fastMode:d,goalComposeMode:pr,goalBusy:pn,goalStatus:(Ta=B.data)==null?void 0:Ta.status,activeView:e,disabled:v,model:l,modelOptions:f,modelContextTitle:xi,contextUsage:p,reasoningEffort:i,supportedEfforts:wa,displayedCollaborationMode:Rt,sandboxMode:u,sendButtonLabel:Ca,sendButtonClassName:Sa,modelControlsDisabled:Ri,effortControlsDisabled:Ai,effortControlTitle:Mi,forkTurnOptionsState:te,skillsState:Q,goalState:B,goalHistory:z,copiedSkillName:pi,hooksPanelMode:Fe,hooksState:J,hookConfigBusy:ot,hookConfigError:un,hookConfigSuccess:mn,editingHookTarget:mr,hookScope:Ue,hookEventName:mt,hookMatcher:yt,hookCommand:Kt,hookTimeoutSec:Yt,hookStatusMessage:At,mcpPanelMode:ge,mcpState:K,mcpConfigPath:ai,mcpConfigError:oi,mcpConfigSuccess:li,mcpConfigBusy:si,mcpHttpName:ti,mcpHttpUrl:ri,mcpRawBlock:ni,capabilities:{hostConfigFiles:Ce.hostConfigFiles,hookTrust:Ce.hookTrust,mcpConfigEditing:Ce.mcpConfigEditing,planMode:Ce.planMode,sandboxMode:m?!1:Ce.sandboxMode},shellControlState:N,onToggleView:we,onDismissPromptFocus:Mt,onSetOpenMenu:ve,onToolboxItemClick:ki,onSetSlashPanelView:O,onViewGoals:W,onUpdateGoal:ae,onOpenForkTurns:()=>X==null?void 0:X(),onForkLatest:fe,onForkTurn:ze,onCopySkillInvokeName:fi,onResetHookForm:Ul,onSetHooksPanelMode:$l,onClearHookConfigStatus:ba,onSetEditingHookTarget:Dl,onSetHookScope:Bl,onSetHookEventName:Gl,onSetHookMatcher:Fl,onSetHookCommand:Hl,onSetHookTimeoutSec:Ol,onSetHookStatusMessage:Wl,onSaveHook:ql,onStartEditingHook:Vl,onTrustHook:Xl,onUntrustHook:Kl,onSetMcpPanelMode:Ne,onClearMcpConfigStatus:ka,onSetMcpHttpName:ii,onSetMcpHttpUrl:di,onSetMcpRawBlock:ci,onPrepareRawMcpBlock:hi,onSaveHttpMcp:ui,onSaveRawMcpBlock:mi,onPickPhoto:()=>ja("photo",Qe),onPickFile:()=>ja("file",et),onUpdateSettings:re=>void wt(re),onPasteShell:()=>void yi(),onCopyShell:()=>{Mt(),ve(null),ye==null||ye()},onClearShell:()=>{Mt(),ve(null),$({prompt:"clear"})},onShellControl:re=>{Mt(),ve(null),De==null||De(re)}}),{promptSlot:Qi,goalSlot:ed,shellPromptSlot:td}=op({isShellView:qe,promptRef:Me,prompt:_e,disabled:v,promptPlaceholder:zi,canInterrupt:Be,interruptLabel:Pi,composerPromptRegionClassName:Xi,graphChatInputClassName:Zi,promptInputClassName:Ki,goalComposeMode:pr,goalTokenBudget:Yl,goalLocalError:Zl,goalBusy:pn,busy:n,sendButtonLabel:Ca,sendButtonClassName:Sa,onInterrupt:ie,onPromptInput:Ni,onPromptPaste:Ci,onPromptKeyDown:Ii,onPromptKeyUp:()=>{Ke.current=Zt()},onPromptMouseUp:()=>{Ke.current=Zt()},onPromptBlur:()=>{Ke.current=Zt(),Pe(!1),ut&&ct()},onPromptDragEnter:Si,onPromptDragOver:Ti,onPromptDragLeave:Ei,onPromptDrop:Li,onGoalTokenBudgetChange:Jl,onCancelGoal:va,onShellPromptChange:gi});return t.jsx(Nm,{activeView:e,layerClassName:_i,formClassName:$i,shellClassName:Di,inputGroupClassName:Yi,error:o,followTail:j,photoInputRef:Qe,fileInputRef:et,onAppendAttachments:xn,onToggleFollow:je,canJumpToPreviousTurn:Ae,onJumpToPreviousTurn:ce,canJumpToNextTurn:ne,onJumpToNextTurn:Le,subscriptionUsage:Z,onSubmit:ji,formRef:Ge,promptSlot:Qi,pendingQueueSlot:!qe&&$e.length>0?t.jsx(Cm,{prompts:$e,onSteer:Oe,onCancel:V}):null,toolbarSlot:t.jsx(Bm,{...Ji}),goalSlot:ed,shellPromptSlot:td})}var dp=c.createContext(null);function ul(){return c.useContext(dp)}function kt(e){return e?new Date(e).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"}):"Time unavailable"}function Ut(e){return e?new Date(e).toLocaleString():"Time unavailable"}function cp(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 hp(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 ml(e){switch(e){case"sending":return"Sending";case"completed":return"Completed";case"interrupted":return"Interrupted";case"failed":return"Failed";case"inProgress":return"Running"}}function up({open:e,title:r,label:n,value:a,busy:s=!1,onChange:o,onCancel:l,onSubmit:i}){if(c.useEffect(()=>{if(!e)return;function h(u){u.key==="Escape"&&!s&&l()}return window.addEventListener("keydown",h),()=>{window.removeEventListener("keydown",h)}},[s,l,e]),!e)return null;function d(h){h.preventDefault(),i()}return Qr.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[95] flex items-center justify-center p-4 sm:p-6",children:[t.jsx("button",{type:"button","aria-label":"Close rename dialog",onClick:l,disabled:s,className:"absolute inset-0 bg-stone-950/78 backdrop-blur-sm disabled:cursor-not-allowed"}),t.jsxs("form",{role:"dialog","aria-modal":"true","aria-label":r,onSubmit:d,className:"relative z-[1] w-full max-w-md rounded-[1.6rem] border border-stone-700 bg-stone-900 p-5 shadow-2xl shadow-stone-950/40 sm:p-6",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium text-stone-100",children:r}),t.jsx("p",{className:"mt-1 text-sm text-stone-500",children:"Changes are saved only after confirmation."})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:l,disabled:s,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-stone-700 text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsxs("div",{className:"mt-5",children:[t.jsx("label",{htmlFor:"rename-dialog-input",className:"text-sm font-medium text-stone-200",children:n}),t.jsx("input",{id:"rename-dialog-input","aria-label":n,autoFocus:!0,value:a,onChange:h=>o(h.target.value),className:"mt-2 w-full rounded-2xl border border-stone-700 bg-stone-950 px-4 py-3 text-stone-100 outline-none transition focus:border-amber-300"})]}),t.jsxs("div",{className:"mt-5 flex items-center justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:l,disabled:s,className:"rounded-full border border-stone-700 px-4 py-2 text-sm font-medium text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),t.jsx("button",{type:"submit",disabled:s||!a.trim(),className:"ui-action-success rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:"Save"})]})]})]}),document.body)}function mp({children:e,effectiveTheme:r,layoutMode:n,themeMode:a,viewportConstrained:s}){return t.jsx("div",{className:`thread-ui-shell ${r==="dark"?"thread-ui-theme-dark dark":""} ${s?"thread-ui-viewport-constrained":""} ${s?"h-[100svh] max-h-[100svh] min-h-0 overflow-hidden overscroll-none":"min-h-[100svh] overflow-hidden"} bg-[#f6f8fb] text-slate-900 transition-colors duration-200 sm:p-2`,"data-theme-effective":r,"data-theme-mode":a??r,"data-thread-layout":n,children:e})}function pp({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 fp({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 gp({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 xp({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 bp({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 vp({children:e}){return t.jsx("div",{className:"thread-split-region min-h-0 flex-1 overflow-hidden p-0 sm:p-2",children:e})}Ao();Pt();function ps({...e}){return t.jsx(id,{"data-slot":"dialog",...e})}function fs({...e}){return t.jsx(dd,{"data-slot":"dialog-trigger",...e})}function kp({...e}){return t.jsx(pd,{"data-slot":"dialog-portal",...e})}function wp({className:e,...r}){return t.jsx(fd,{"data-slot":"dialog-overlay",className:at("fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",e),...r})}function gs({children:e,className:r,showCloseButton:n=!0,...a}){return t.jsxs(kp,{"data-slot":"dialog-portal",children:[t.jsx(wp,{}),t.jsxs(cd,{"data-slot":"dialog-content",className:at("fixed left-[50%] top-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg",r),...a,children:[e,n?t.jsxs(hd,{"data-slot":"dialog-close",className:"absolute right-4 top-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[t.jsx(_.XIcon,{}),t.jsx("span",{className:"sr-only",children:"Close"})]}):null]})]})}function xs({className:e,...r}){return t.jsx("div",{"data-slot":"dialog-header",className:at("flex flex-col gap-2 text-center sm:text-left",e),...r})}function bs({className:e,...r}){return t.jsx(ud,{"data-slot":"dialog-title",className:at("text-lg font-semibold leading-none",e),...r})}function vs({className:e,...r}){return t.jsx(md,{"data-slot":"dialog-description",className:at("text-sm text-muted-foreground",e),...r})}var yp=[{value:"system",label:"Follow system",icon:_.Monitor},{value:"dark",label:"Dark",icon:_.Moon},{value:"light",label:"Light",icon:_.Sun}];function jp({thread:e,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a={},onOpenThread:s,getThreadHref:o,renderThreadLink:l,onBeginRenameThread:i,onDeleteThread:d,showDeleteButton:h=!1,showSessionCopyButton:u=!1,collapsed:m=!1}){const[f,p]=c.useState("idle"),g=c.useRef(null),k=a[e.workspaceId],w=k&&!n?k:null,x=r===e.id;c.useEffect(()=>()=>{g.current!==null&&window.clearTimeout(g.current)},[]);async function j(){const N=e.providerSessionId;if(N)try{await navigator.clipboard.writeText(N),p("copied"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>p("idle"),1200)}catch{p("failed"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>p("idle"),1600)}}const y=()=>s(e.id),b=`thread-graph-room-card group flex w-full items-center gap-3 rounded-xl border text-left transition ${x?"is-active":""} ${m?"justify-center px-2 py-2":"px-3 py-2.5"}`,v=t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`thread-graph-room-card-icon flex h-8 w-8 shrink-0 items-center justify-center rounded-full ${x?"is-active":""}`,children:t.jsx(_.MessageSquare,{className:"h-4 w-4"})}),t.jsxs("div",{className:`min-w-0 flex-1 ${m?"thread-desktop-collapsed-hidden":""}`,children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[t.jsx("p",{className:"thread-graph-room-card-title min-w-0 flex-1 truncate text-sm font-medium",title:e.title,children:e.title}),i&&!m?t.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),N.preventDefault(),i(e)},"aria-label":`Rename thread ${e.title}`,title:"Rename thread",className:"thread-card-quiet-button inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full transition",children:t.jsx(_.Pencil,{className:"h-3 w-3"})}):null,u&&e.providerSessionId?t.jsx("button",{type:"button","aria-label":"Copy session ID",title:f==="copied"?"Copied":f==="failed"?"Copy failed":"Copy session ID",onClick:N=>{N.stopPropagation(),N.preventDefault(),j()},className:"thread-card-quiet-button thread-card-session-copy-button inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition",children:f==="copied"?t.jsx(_.Check,{className:"h-3.5 w-3.5"}):t.jsx(_.Copy,{className:"h-3.5 w-3.5"})}):null]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2",children:[w?t.jsx("p",{className:"thread-graph-room-card-meta min-w-0 flex-1 truncate text-[11px] text-[var(--theme-fg-muted)]",title:w,children:w}):t.jsx("span",{className:"min-w-0 flex-1","aria-hidden":"true"}),t.jsx("span",{className:`shrink-0 rounded-full border px-1.5 py-0.5 text-[9px] uppercase tracking-normal ${hp(e.status)}`,children:cp(e.status)}),t.jsx("time",{className:"shrink-0 text-[11px] text-[var(--theme-fg-muted)]",dateTime:e.lastTurnStartedAt??e.updatedAt,children:kt(e.lastTurnStartedAt??e.updatedAt)})]})]}),h&&d&&!m?t.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),N.preventDefault(),d(e)},"aria-label":`Delete thread ${e.title}`,className:"thread-card-danger-button shrink-0 rounded-full p-1 transition",title:"Delete thread",children:t.jsx(_.Trash2,{className:"h-3.5 w-3.5"})}):null]}),S=o==null?void 0:o(e.id);return l?t.jsx(t.Fragment,{children:l({thread:e,children:v,className:b,onClick:y})}):S?t.jsx("a",{href:S,onClick:N=>{N.preventDefault(),y()},title:m?e.title:void 0,className:b,children:v}):t.jsx("div",{role:"link",tabIndex:0,onClick:y,onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),y())},title:m?e.title:void 0,className:b,children:v})}function Np({threads:e,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a={},onOpenThread:s,getThreadHref:o,renderThreadLink:l,onBeginRenameThread:i,onDeleteThread:d,scrollable:h=!1,maxHeightClassName:u="max-h-full",showDeleteButton:m=!1,showSessionCopyButton:f=!1,collapsed:p=!1}){const g=h?`min-h-0 min-w-0 overflow-x-hidden overflow-y-auto overscroll-contain pr-1 ${u}`:"";return t.jsx("div",{className:g,children:t.jsx("div",{className:"min-w-0 space-y-1",children:e.map(k=>t.jsx(jp,{thread:k,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a,onOpenThread:s,showDeleteButton:m,showSessionCopyButton:f,collapsed:p,...o?{getThreadHref:o}:{},...l?{renderThreadLink:l}:{},...i?{onBeginRenameThread:i}:{},...d?{onDeleteThread:d}:{}},k.id))})})}function Cp({threads:e,status:r,loading:n=!1,error:a,viewportConstrained:s=!1,layoutMode:o="responsive",effectiveTheme:l,themeMode:i,onThemeModeChange:d,showMobileNewThreadShortcut:h=!0,settingsDialogOpen:u,onSettingsDialogOpenChange:m,mobileHeaderAction:f,currentThreadId:p,currentThreadLabel:g=null,currentWorkspaceId:k=null,currentWorkspaceLabel:w=null,sessionLabel:x=null,usageLabel:j=null,threadActionsButton:y,topbarActions:b,metaContent:v,settingsContent:S,globalSettingsContent:N,workspaceLabels:L={},workspaceReturnHref:R,onWorkspaceReturn:P,getThreadHref:Q,onOpenThread:K,getNewThreadHref:J,newThreadHref:B,newThreadLabel:z="New Chat",onNewThread:te,onNewThreadTitle:se,renderNewThreadDialogContent:$,renderThreadLink:ie,onCloseAppNavigation:q,onRenameThread:H,onDeleteThread:G,workspaceContent:T,workspaceTitle:F="Workspace",workspaceActions:D,children:E}){const C=ul(),W=typeof window<"u"?window.matchMedia("(max-width: 639px)").matches:o==="mobile",[U,ae]=c.useState(()=>typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)").matches:!1),X=i??(C==null?void 0:C.themeMode)??"system",de=l??(C==null?void 0:C.effectiveTheme)??(X==="system"?U?"dark":"light":X),[ee,ke]=c.useState(!1),[le,je]=c.useState(!1),[Ae,ce]=c.useState(!W),[ne,Le]=c.useState(W),[Z,me]=c.useState("chat"),[we,ye]=c.useState(null),[De,Be]=c.useState(""),[$e,Oe]=c.useState(null),[V,he]=c.useState(!1),[ve,I]=c.useState(""),[O,oe]=c.useState(!1),[ge,Ne]=c.useState(!1),[Ce,xe]=c.useState("session");c.useEffect(()=>{if(typeof window>"u")return;const M=window.matchMedia("(max-width: 639px)"),fe=()=>{Le(M.matches)};return fe(),M.addEventListener("change",fe),()=>{M.removeEventListener("change",fe)}},[]),c.useEffect(()=>{if(typeof window>"u")return;const M=window.matchMedia("(prefers-color-scheme: dark)"),fe=()=>{ae(M.matches)};return fe(),M.addEventListener("change",fe),()=>{M.removeEventListener("change",fe)}},[]);const Ge=c.useMemo(()=>[...k?e.filter(fe=>fe.workspaceId===k):e].sort((fe,ze)=>{if(fe.id===p)return-1;if(ze.id===p)return 1;const Fe=Date.parse(fe.lastTurnStartedAt??fe.updatedAt);return Date.parse(ze.lastTurnStartedAt??ze.updatedAt)-Fe}),[p,k,e]),Me=B??(J==null?void 0:J(k)),Qe=w??k??"all",et=x??g??p??"default_session",it=j??(r!=null&&r.state?`runtime ${r.state}`:"waiting for agent usage"),tt=d??(C==null?void 0:C.setThemeMode),Ke=!!tt,dt=()=>{ke(!1),q==null||q()};async function gt(M){if(!H)return;const fe=De.trim();if(fe){Oe(M);try{await H(M,fe),ye(null),Be("")}finally{Oe(null)}}}function qe(M){ye(M.id),Be(M.title)}function A(){ye(null),Be("")}function Y(M){K==null||K(M),dt()}function be(){he(!1),I("")}function Se(M){if(!Me||!M.trim())return Me;try{const fe=new URL(Me,window.location.origin);return fe.searchParams.set("title",M.trim()),`${fe.pathname}${fe.search}${fe.hash}`}catch{const fe=Me.includes("?")?"&":"?";return`${Me}${fe}title=${encodeURIComponent(M.trim())}`}}async function Pe(){const M=ve.trim();oe(!0);try{if(M&&se){await se(M),I(""),he(!1),dt();return}if(Me){window.location.assign(Se(M)??Me);return}await(te==null?void 0:te()),I(""),he(!1),dt()}finally{oe(!1)}}function rt(M,fe=!1){const ze=fe?t.jsxs(t.Fragment,{children:[t.jsx(_.Plus,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:z})]}):t.jsxs(t.Fragment,{children:[t.jsx(_.Plus,{className:"h-4 w-4"}),t.jsx("span",{children:z})]});return t.jsxs(ps,{open:V,onOpenChange:Fe=>{O||he(Fe)},children:[t.jsx(fs,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":fe?z:void 0,title:z,className:M,children:ze})}),t.jsx(gs,{"data-testid":"create-thread-dialog","data-theme-effective":de,"data-theme-mode":X,className:"thread-graph-create-thread-dialog thread-graph-dialog max-h-[min(86vh,42rem)] overflow-hidden p-4 sm:max-w-[34rem]",children:$?$({close:be,closeNavigation:dt,currentWorkspaceId:k}):t.jsxs(t.Fragment,{children:[t.jsxs(xs,{children:[t.jsx(bs,{children:"Create New Chat"}),t.jsx(vs,{children:"Name the room so it is easy to find later."})]}),t.jsxs("div",{className:"grid gap-3",children:[t.jsx("input",{id:"thread-graph-create-thread-title",name:"thread-title",value:ve,onChange:Fe=>I(Fe.target.value),onKeyDown:Fe=>{Fe.key==="Enter"&&(Fe.preventDefault(),Pe())},placeholder:"Chat name","aria-label":"Chat name",autoComplete:"off",className:"thread-graph-create-thread-input h-10 rounded-md border px-3 text-sm outline-none transition"}),t.jsx("button",{type:"button",onClick:()=>void Pe(),disabled:O,className:"thread-graph-create-thread-submit inline-flex h-10 items-center justify-center rounded-md px-4 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:O?"Creating...":"Create"})]})]})})]})}function nt(){if(!S&&!v&&!N&&!Ke)return null;const M=!!(S||v),fe=!!N,ze=M&&fe,Fe=Ce==="global"&&fe||!M&&fe?"global":"session";return t.jsxs(ps,{...u!==void 0?{open:u}:{},...m?{onOpenChange:m}:{},children:[t.jsx(fs,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":"Open settings",title:"Settings",className:"thread-icon-button inline-flex h-10 w-10 items-center justify-center rounded-full sm:h-9 sm:w-9",children:t.jsx(_.Settings,{className:"h-4 w-4"})})}),t.jsxs(gs,{"data-testid":"settings-dialog","data-theme-effective":de,"data-theme-mode":X,className:"thread-graph-settings-dialog thread-graph-dialog",children:[t.jsxs(xs,{children:[t.jsx(bs,{children:"Settings"}),t.jsx(vs,{children:"Manage this session and host-wide preferences."})]}),Ke?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"font-medium text-[var(--theme-fg)]",children:"Appearance"}),t.jsxs("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:["Current theme: ",de]})]}),t.jsx("div",{className:"thread-graph-theme-mode-group grid grid-cols-3 gap-1 rounded-lg border p-1",role:"group","aria-label":"Theme mode",children:yp.map(Ue=>{const mt=Ue.icon,yt=X===Ue.value;return t.jsxs("button",{type:"button","data-testid":`theme-mode-${Ue.value}`,"aria-pressed":yt,disabled:!Ke,onClick:()=>tt==null?void 0:tt(Ue.value),className:`thread-graph-theme-mode-button inline-flex min-h-9 items-center justify-center gap-1.5 rounded-md px-2 text-xs font-medium transition ${yt?"is-selected":""}`,children:[t.jsx(mt,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:"truncate",children:Ue.label})]},Ue.value)})})]})}):null,ze?t.jsxs("div",{className:"thread-graph-settings-tabs grid grid-cols-2 gap-1 rounded-lg border p-1",children:[t.jsx("button",{type:"button","aria-pressed":Fe==="session",onClick:()=>xe("session"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Fe==="session"?"is-active":""}`,children:"Session"}),t.jsx("button",{type:"button","aria-pressed":Fe==="global",onClick:()=>xe("global"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Fe==="global"?"is-active":""}`,children:"Global"})]}):null,t.jsx("div",{className:"thread-graph-settings-body mt-4 min-h-0 overflow-y-auto pr-1 text-sm",children:Fe==="session"?t.jsxs("div",{className:"grid gap-4",children:[S?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:S}):null,v?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:v}):null,M?null:t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3 text-[var(--theme-fg-muted)]",children:"No session settings are available."})]}):t.jsx("div",{className:"thread-graph-settings-global-content",children:N})})]})]})}function _e(M=!1){return t.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:t.jsxs("section",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs("div",{className:`mb-3 flex items-center gap-2 px-2 text-xs font-medium tracking-normal text-[var(--theme-fg-muted)] ${M?"justify-center":""}`,children:[t.jsx(_.Rows3,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:M?"sr-only":"",children:"Rooms"}),!M&&n?t.jsx("span",{className:"ml-auto text-xs text-[var(--theme-fg-muted)]",children:"Refreshing..."}):null]}),t.jsxs("div",{className:"min-h-0 min-w-0 flex-1 overflow-x-hidden overflow-y-auto px-1",children:[a?t.jsx("div",{className:"rounded-xl border border-rose-500/30 bg-rose-500/10 px-3 py-3 text-sm text-rose-900 dark:text-rose-100",children:a}):null,!a&&Ge.length===0&&!n?t.jsx("div",{className:"rounded-xl border border-dashed border-[var(--theme-border)] bg-[var(--theme-surface)] px-4 py-6 text-sm text-[var(--theme-fg-muted)]",children:"No threads available in this view."}):null,Ge.length>0?t.jsx(Np,{threads:Ge,currentThreadId:p,currentWorkspaceId:k,workspaceLabels:L,onOpenThread:Y,collapsed:M,...H?{onBeginRenameThread:qe}:{},showDeleteButton:!!G,...Q?{getThreadHref:Q}:{},...ie?{renderThreadLink:ie}:{},...G?{onDeleteThread:G}:{}}):null]})]})})}function We(){return T?t.jsxs("div",{className:"thread-workspace-panel relative flex h-full min-h-0 flex-col overflow-hidden rounded-[12px] border",children:[t.jsx("button",{type:"button",onClick:()=>ce(!0),className:"thread-workspace-collapse-tab thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(_.ChevronsRight,{className:"h-4 w-4"})}),D?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:D})}):null,t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:T})]}):t.jsxs("div",{className:"thread-workspace-panel flex h-full min-h-0 flex-col overflow-hidden rounded-[12px] border",children:[t.jsxs("div",{className:"thread-workspace-panel-header flex h-12 shrink-0 items-center justify-between gap-3 border-b border-[var(--theme-border)] px-3 sm:h-[60px] sm:px-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-base font-semibold text-[var(--theme-fg)] sm:text-[18px]",children:F}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:w??k??"Current context"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[D,t.jsx("button",{type:"button",onClick:()=>ce(!0),className:"thread-workspace-small-toggle thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(_.ChevronsRight,{className:"h-4 w-4"})})]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:T??t.jsxs("div",{className:"grid h-full min-h-0 gap-3 overflow-y-auto p-3 text-sm text-[var(--theme-fg-soft)]",children:[t.jsxs("div",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:"Runtime"}),t.jsx("p",{className:"mt-2 text-[var(--theme-fg)]",children:(r==null?void 0:r.state)??"unknown"})]}),t.jsxs("div",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:"Workspace"}),t.jsx("p",{className:"mt-2 break-words text-[var(--theme-fg)]",children:w??k??"All threads"})]})]})})]})}const ut=!!T,st=o==="mobile"||o==="responsive"&&ne,ct=st,xt=ct&&!ee,wt=!!(R||P)?t.jsx("a",{href:R??"#",onClick:M=>{P&&(M.preventDefault(),P())},className:"thread-icon-button inline-flex h-10 w-10 items-center justify-center rounded-full sm:h-9 sm:w-9",title:"Back to workspace","aria-label":"Back to workspace",children:t.jsx(_.ArrowLeft,{className:"h-4 w-4"})}):null;return t.jsxs(t.Fragment,{children:[t.jsx(mp,{effectiveTheme:de,layoutMode:o,themeMode:X,viewportConstrained:s,children:t.jsxs(pp,{roomsRailCollapsed:le,children:[t.jsx(fp,{open:ee,onClose:()=>ke(!1)}),t.jsxs(gp,{collapsed:le,mobileOpen:ee,children:[t.jsx("div",{className:`thread-rooms-rail-header flex h-[calc(3rem+env(safe-area-inset-top))] shrink-0 items-end border-b border-[var(--theme-border)] px-4 pb-2 sm:h-16 sm:items-center sm:pb-0 ${le?"sm:w-full sm:justify-center sm:px-2":""}`,children:t.jsxs("div",{className:`flex w-full items-center gap-3 ${le?"sm:justify-center":"justify-between"}`,children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[t.jsx("button",{type:"button",onClick:()=>je(M=>!M),className:"thread-icon-button thread-desktop-only-flex h-9 w-9 shrink-0 items-center justify-center rounded-full",title:le?"Expand rooms":"Collapse rooms","aria-label":le?"Expand rooms":"Collapse rooms",children:le?t.jsx(_.PanelLeftOpen,{className:"h-4 w-4"}):t.jsx(_.PanelLeftClose,{className:"h-4 w-4"})}),t.jsx("div",{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-[var(--theme-accent-solid)] text-sm font-semibold text-[var(--theme-accent-solid-fg)] ${le?"thread-desktop-collapsed-hidden":""}`,children:(w??"R").charAt(0).toUpperCase()}),t.jsxs("div",{className:`min-w-0 ${le?"thread-desktop-collapsed-hidden":""}`,children:[t.jsx("p",{className:"truncate text-sm font-semibold text-[var(--theme-fg)]",children:w??"Remote Codex"}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:k??"Thread workspace"})]})]}),t.jsxs("div",{className:`flex shrink-0 items-center gap-1 ${le?"thread-desktop-collapsed-hidden":""}`,children:[nt(),wt,t.jsx("button",{type:"button",onClick:()=>ke(!1),"aria-label":"Close rooms",title:"Close rooms",className:"thread-icon-button thread-mobile-only-inline-flex h-10 w-10 items-center justify-center rounded-full",children:t.jsx(_.X,{className:"h-4 w-4"})})]})]})}),t.jsx("div",{className:`thread-graph-new-room-strip flex shrink-0 items-center border-b ${le?"h-12 w-full justify-center px-2 sm:h-12":"h-[68px] px-4"}`,children:rt(`thread-graph-new-room-button inline-flex items-center justify-center rounded-xl font-medium transition ${le?"h-9 w-9 p-0":"h-11 w-full gap-2 px-3 text-sm sm:h-9"}`,le)}),t.jsx("div",{className:`flex min-h-0 flex-1 flex-col ${le?"w-full px-2 py-2":"px-3 py-3"}`,children:_e(le)})]}),t.jsxs(xp,{children:[t.jsx(bp,{children:t.jsx("div",{className:"thread-topbar-row flex min-h-12 items-center px-3 py-1.5 sm:min-h-12 sm:px-4",children:t.jsxs("div",{className:"flex w-full items-center justify-between gap-3 sm:gap-4",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:gap-3",children:[xt?t.jsx("button",{type:"button",onClick:()=>ke(!0),"aria-label":"Open rooms",title:"Open rooms",className:"thread-icon-button thread-mobile-only-inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-full",children:t.jsx(_.Menu,{className:"h-4 w-4"})}):null,t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"min-w-0 truncate text-sm font-semibold leading-tight text-[var(--theme-fg)] sm:text-base",title:g??"Shared Workspace",children:g??"Shared Workspace"}),t.jsxs("div",{className:"relative mt-0.5 flex min-w-0 items-center gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{Ne(M=>!M)},"aria-expanded":ge,"aria-haspopup":"dialog",className:"thread-topbar-meta-row flex min-w-0 max-w-full items-center gap-1 text-left text-[11px] leading-none sm:text-xs",title:"Session and usage",children:[t.jsx("span",{className:"shrink-0",children:"Room"}),t.jsx("span",{className:"truncate font-mono",children:Qe})]}),ge?t.jsxs("div",{className:"thread-topbar-details-popover absolute left-0 top-[calc(100%+0.5rem)] z-50 w-[min(28rem,calc(100vw-1.5rem))] rounded-lg border p-2.5 shadow-lg",role:"dialog","aria-label":"Session and usage",children:[t.jsxs("button",{type:"button",onClick:()=>{var M;et&&((M=navigator.clipboard)==null||M.writeText(et))},className:"thread-topbar-meta-row flex min-w-0 max-w-full items-center gap-2 text-left text-xs leading-5",title:"Copy session ID",children:[t.jsx("span",{className:"w-14 shrink-0",children:"Session"}),t.jsx("span",{className:"truncate font-mono",children:et})]}),t.jsxs("div",{className:"thread-topbar-meta-row mt-1 flex min-w-0 max-w-full items-start gap-2 text-xs leading-5",title:"Session token usage and estimated cost",children:[t.jsx("span",{className:"w-14 shrink-0",children:"Usage"}),t.jsx("span",{className:"min-w-0 whitespace-normal break-words font-mono",children:it})]})]}):null]})]})]}),t.jsxs("div",{className:"relative z-[1] inline-flex shrink-0 items-center gap-2",children:[y||b?t.jsxs("div",{className:"thread-graph-topbar-actions thread-desktop-only-inline-flex items-center rounded-lg border p-0.5 shadow-none",children:[y,b]}):null,ct&&y?t.jsx("div",{className:"thread-mobile-only-inline-flex",children:y}):null,ct&&ut?t.jsx("button",{type:"button",onClick:()=>me(M=>M==="workspace"?"chat":"workspace"),"aria-label":Z==="workspace"?"Show chat":"Show workspace",title:Z==="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:Z==="workspace"?t.jsx(_.MessageSquare,{className:"h-4 w-4"}):t.jsx(_.Folder,{className:"h-4 w-4"})}):null,ct?f:null,ct&&h?rt("thread-secondary-action inline-flex h-10 items-center justify-center gap-2 rounded-lg border px-3 text-sm font-medium sm:h-9"):null]})]})})}),t.jsx(vp,{children:ut&&!Ae?st?t.jsxs("div",{className:"thread-split-container thread-graph-shell-mobile-split h-full min-h-0 overflow-hidden",children:[t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${Z==="chat"?"block":"thread-mobile-chat-hidden"}`,children:E}),t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${Z==="workspace"?"block":"thread-mobile-workspace-hidden"}`,children:We()})]}):t.jsxs(Bn,{direction:"horizontal",className:"thread-split-container thread-graph-shell-resizable thread-graph-shell-desktop-split h-full min-h-0 overflow-hidden",children:[t.jsx(or,{defaultSize:47,minSize:30,maxSize:75,className:"thread-split-chat-pane min-w-0 overflow-hidden",children:E}),t.jsx(Gn,{className:"thread-resize-handle w-2 bg-transparent after:w-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(or,{defaultSize:53,minSize:30,maxSize:70,className:"thread-split-workspace-pane min-w-0 overflow-hidden",children:We()})]}):t.jsxs("div",{className:"thread-split-container relative h-full min-h-0 overflow-hidden",children:[ut&&Ae?t.jsx("button",{type:"button",onClick:()=>ce(!1),className:"thread-workspace-expand-fab thread-desktop-only-inline-flex",title:"Expand workspace","aria-label":"Expand workspace",children:t.jsx(_.ChevronsLeft,{className:"h-4 w-4"})}):null,E]})})]})]})}),t.jsx(up,{open:we!==null,title:"Rename Thread",label:"Thread Title",value:De,busy:$e!==null,onChange:Be,onCancel:A,onSubmit:()=>we?gt(we):void 0})]})}function Sp({open:e,title:r,text:n,onClose:a}){return c.useEffect(()=>{if(!e)return;function s(o){o.key==="Escape"&&a()}return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[a,e]),e?Qr.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[90] flex items-center justify-center p-4 sm:p-6",children:[t.jsx("button",{type:"button","aria-label":"Close full text",onClick:a,className:"absolute inset-0 bg-stone-950/78 backdrop-blur-sm"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":r,className:"relative z-[1] flex max-h-[min(82vh,52rem)] w-full max-w-4xl flex-col overflow-hidden rounded-[1.8rem] border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-stone-800 px-4 py-3 sm:px-5",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:r}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:a,className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-stone-700 text-stone-300 transition hover:bg-stone-800",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-4 py-4 sm:px-5",children:t.jsx("pre",{className:"whitespace-pre-wrap break-words text-sm leading-6 text-stone-200",children:n})})]})]}),document.body):null}var Tp=[/^(?: {0,3})#{1,6}\s+\S/m,/^(?: {0,3})>{1,}\s*\S/m,/^(?: {0,3})(?:[-+*]|\d{1,9}[.)])\s+(?:\[[ xX]\]\s+)?\S/m,/^(?: {0,3})(?:```|~~~)/m,/^(?: {0,3})(?:[-*_]\s*){3,}$/m],Ep=/^(?:\|?[^|\n]+\|[^|\n]+(?:\|[^|\n]+)*\|?\s*\n\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$)/m,Lp=/!?\[[^\]\n]+\]\([^)]+\)/,Ip=/`[^`\n]+`/,zp=/(?:\*\*[^*\n]+\*\*|__[^_\n]+__)/,Pp=/(^|[^\w])(?:\*[^*\n]+\*|_[^_\n]+_)(?=[^\w]|$)/,Rp=/~~[^~\n]+~~/;function Ap(e){const r=e.trim();return r?Tp.some(n=>n.test(r))||Ep.test(r)?!0:/[`[\]*_~!]/.test(r)?Lp.test(r)||Ip.test(r)||zp.test(r)||Pp.test(r)||Rp.test(r):!1:!1}sn();function Zn(e,r){const n=new Map(r.map(o=>[o.id,o])),a=e.map(o=>{var l,i;return{...o.manifest,enabled:((l=n.get(o.manifest.id))==null?void 0:l.enabled)??!0,source:((i=n.get(o.manifest.id))==null?void 0:i.source)??"builtin"}}),s=new Set(e.map(o=>o.manifest.id));for(const o of r)s.has(o.id)||a.push(o);return a}function ua(e=[]){const r=Zn(e,[]),n=e;return{plugins:r,loading:!1,error:null,async refresh(){},async importPluginManifest(){},async setPluginEnabled(){},async uninstallPlugin(){},renderArtifact:o=>{var i;const l=n.find(d=>d.renderArtifact&&d.manifest.capabilities.artifactTypes.some(h=>h.type===o.artifact.type));return((i=l==null?void 0:l.renderArtifact)==null?void 0:i.call(l,o))??null},renderInlineCode:o=>{for(const l of n)for(const i of l.inlineCodeRenderers??[]){if(!i.languages.includes(o.language.trim().toLowerCase()))continue;const d=i.render(o);if(d)return d}return null},hasRendererForArtifact:o=>n.some(l=>!!l.renderArtifact&&l.manifest.capabilities.artifactTypes.some(i=>i.type===o.type)),getThreadPanels:()=>n.flatMap(o=>o.threadPanels??[])}}var ma=c.createContext(ua());function pa(){return c.useContext(ma)??ua()}Pr();function pl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ks(e){return pl(e)?Object.entries(e):e==null||e===""?[]:[["value",e]]}function fl(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 Mp(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)}):fl(r)}function ws({callId:e,toolName:r,status:n,parameters:a,result:s}){const o=c.useMemo(()=>{switch(n){case"completed":return{className:"is-completed",icon:t.jsx(_.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"};case"failed":return{className:"is-failed",icon:t.jsx(_.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"};default:return{className:"is-pending",icon:t.jsx(_.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),label:"Running"}}},[n]),l=c.useMemo(()=>ks(s),[s]),i=c.useMemo(()=>ks(a),[a]),d=c.useMemo(()=>typeof s=="string"?s.length>0:pl(s)?["stdout","stderr","result"].some(f=>{const p=s[f];return typeof p=="string"&&p.length>0}):!1,[s]),h=n==="pending"||d,[u,m]=c.useState(h?"item-1":void 0);return c.useEffect(()=>{h&&m("item-1")},[e,h]),t.jsx("div",{className:"thread-graph-tool-call my-2 w-full font-sans not-prose",children:t.jsx(Lr,{type:"single",collapsible:!0,onValueChange:f=>m(f||void 0),className:"thread-graph-tool-accordion w-full overflow-hidden rounded-lg border",...u!==void 0?{value:u}:{},children:t.jsxs(Ir,{value:"item-1",className:"border-0",children:[t.jsx(on,{className:"thread-graph-tool-trigger px-4 py-3 hover:no-underline",children:t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(_.Wrench,{className:"h-4 w-4 shrink-0"}),t.jsx("span",{className:"min-w-0 truncate font-mono text-sm font-semibold",children:r}),t.jsxs("span",{className:`thread-graph-tool-badge ${o.className}`,title:o.label,"aria-label":`Status: ${o.label}`,children:[o.icon,t.jsx("span",{className:"thread-graph-status-label",children:o.label})]})]})}),t.jsxs(zr,{className:"thread-graph-tool-content px-4 pb-4 pt-1",children:[t.jsxs("section",{children:[t.jsx("h4",{children:"Parameters"}),t.jsxs("div",{className:"thread-graph-tool-json",children:["{",t.jsx("br",{}),i.length>0?i.map(([f,p],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',f,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),fl(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:": "}),Mp(f,p),g<l.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},f)),"}"]})]}):null]})]})})})}var ys=null;function _p(){return ys??(ys=Promise.all([Ve(()=>import("./core-DODVy7wn.js"),__vite__mapDeps([0,1,2])),Ve(()=>import("./engine-javascript-DBd1bXLz.js"),[]),Ve(()=>import("./ayu-light-BA47KaF1.js"),[]),Ve(()=>import("./ayu-dark-DYE7WIF3.js"),[]),Ve(()=>import("./javascript-wDzz0qaB.js"),[]),Ve(()=>import("./typescript-BPQ3VLAy.js"),[]),Ve(()=>import("./tsx-COt5Ahok.js"),[]),Ve(()=>import("./jsx-g9-lgVsj.js"),[]),Ve(()=>import("./python-B6aJPvgy.js"),[]),Ve(()=>import("./json-Cp-IABpG.js"),[]),Ve(()=>import("./shellscript-CEILq0vU.js").then(e=>e.b),[]),Ve(()=>import("./shellscript-CEILq0vU.js").then(e=>e.s),[]),Ve(()=>import("./yaml-Buea-lGh.js"),[]),Ve(()=>import("./toml-vGWfd6FD.js"),[]),Ve(()=>import("./markdown-Cvjx9yec.js"),[]),Ve(()=>import("./html-pp8916En.js"),__vite__mapDeps([3,4,5])),Ve(()=>import("./css-CLj8gQPS.js"),[]),Ve(()=>import("./sql-CRqJ_cUM.js"),[]),Ve(()=>import("./csv-fuZLfV_i.js"),[])]).then(([{createHighlighterCore:e},{createJavaScriptRegexEngine:r},n,a,s,o,l,i,d,h,u,m,f,p,g,k,w,x,j])=>e({engine:r(),themes:[n.default,a.default],langs:[s.default,o.default,l.default,i.default,d.default,h.default,u.default,m.default,f.default,p.default,g.default,k.default,w.default,x.default,j.default]}))),ys}function ln(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Jn(e){if(!e)return{};if(ln(e)&&Object.prototype.hasOwnProperty.call(e,"0"))try{const r=Object.keys(e).map(Number).filter(n=>Number.isFinite(n)).sort((n,a)=>n-a).map(n=>String(e[String(n)]??"")).join("");return JSON.parse(r)}catch{return e}if(typeof e=="string")try{return JSON.parse(e)}catch{return e}return e}function Qn(){return{finalResult:null,stdout:"",stderr:""}}function $p(e){return typeof e=="string"?{result:e}:e}function gl(e){const r=ln(e.finalResult)?{...e.finalResult}:e.finalResult!=null?{result:e.finalResult}:{};return e.stdout&&(r.stdout=e.stdout),e.stderr&&(r.stderr=e.stderr),!("status"in r)&&(e.stdout||e.stderr)&&(r.status="pending"),r}function js(e){if(!e)return"pending";if(!ln(e))return"completed";const r=e.status;return r==="stream"||r==="pending"||r==="running"?"pending":r==="failed"||r==="error"||r==="timed_out"||typeof e.exit_code=="number"&&e.exit_code!==0?"failed":"completed"}function Dp(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=$p(d.result),m=r.get(h)??Qn();return ln(u)&&u.status==="stream"&&typeof u.chunk=="string"?u.stream==="stderr"?m.stderr+=u.chunk:m.stdout+=u.chunk:m.finalResult=u,r.set(h,m),""}catch{return l}}),s=/```tool-call\s*([\s\S]*?)\s*```/g;return{processedContent:a.replace(s,(l,i)=>{try{const d=JSON.parse(i),h=d.call_id,u=d.tool;if(typeof u!="string")return l;const m=Jn(d.args);if(typeof h=="string"&&r.has(h)){const f=gl(r.get(h)??Qn());return`\`\`\`tool-merged
|
|
3692
3692
|
${JSON.stringify({call:{tool:u,args:m,call_id:h},result:f},null,2)}
|
|
3693
|
-
\`\`\``}return l}catch{return l}}),resultMap:r}}var
|
|
3694
|
-
`)||L!==R;if(S==="tool-merged"){let
|
|
3693
|
+
\`\`\``}return l}catch{return l}}),resultMap:r}}var Bp=["/api/","/assets/","/control-plane","/devices/","/relay/","/relay-account","/relay-admin","/relay-devices","/relay-portal","/threads","/workspaces"];function Ns(e){return e.replace(/background-color:[^;"]+;?/g,"background-color: transparent;").replace(/background:[^;"]+;?/g,"background: transparent;")}function Cs(e){return Array.isArray(e)?e.map(r=>String(r)).join(""):String(e??"")}function Gp(e){if(!e||typeof e!="object"||!("position"in e))return{startLine:void 0,endLine:void 0};const r=e.position;if(!r||typeof r!="object")return{startLine:void 0,endLine:void 0};const n=r.start,a=r.end,s=n&&typeof n=="object"?n.line:void 0,o=a&&typeof a=="object"?a.line:void 0;return{startLine:typeof s=="number"?s:void 0,endLine:typeof o=="number"?o:void 0}}function Fp(e){if(!e)return null;let r=e.trim();if(!r)return null;try{if(typeof window>"u")return null;const o=new URL(r,window.location.origin);if(o.origin!==window.location.origin&&o.protocol!=="file:")return null;r=(o.protocol==="file:",o.pathname)}catch{}try{r=decodeURIComponent(r)}catch{}if(!r.startsWith("/")||Bp.some(o=>r===o||r.startsWith(o)))return null;const n=r.match(/:(\d+)(?::\d+)?$/),a=n?Number.parseInt(n[1]??"",10):void 0,s=n?r.slice(0,-n[0].length):r;return!s||s==="/"?null:{path:s,...Number.isFinite(a)?{line:a}:{}}}function Hp({children:e,...r}){return Op(e)?t.jsx(t.Fragment,{children:e}):t.jsx("pre",{...r,children:e})}function Op(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 Wp=c.memo(function({className:r="thread-graph-markdown",content:n,onOpenWorkspaceFile:a}){const s=c.useRef(null),o=pa(),[l,i]=c.useState(null),[d,h]=c.useState({}),[u,m]=c.useState(!1),{processedContent:f,resultMap:p}=c.useMemo(()=>Dp(n),[n]);c.useEffect(()=>{let w=!0;return _p().then(x=>{w&&i(x)}).catch(()=>{}),()=>{w=!1}},[]),c.useEffect(()=>{const w=s.current,x=w==null?void 0:w.closest(".thread-ui-shell"),j=()=>x?x.getAttribute("data-theme-effective")==="dark"||x.classList.contains("dark")||x.classList.contains("thread-ui-theme-dark"):document.documentElement.classList.contains("dark");if(m(j()),!x)return;const y=new MutationObserver(()=>m(j()));return y.observe(x,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>y.disconnect()},[]);async function g(w,x){try{await navigator.clipboard.writeText(x),h(j=>({...j,[w]:"copied"})),window.setTimeout(()=>{h(j=>{const y={...j};return delete y[w],y})},1200)}catch{h(j=>({...j,[w]:"failed"}))}}const k=({children:w,className:x,inline:j,node:y,...b})=>{var K;const v=/language-(\w+(?:-\w+)*)/.exec(x||""),S=v?v[1]??"":"",N=Cs(w).replace(/\n$/,""),{startLine:L,endLine:R}=Gp(y),P=j===!1||!!x||N.includes(`
|
|
3694
|
+
`)||L!==R;if(S==="tool-merged"){let J={call:{tool:"Unknown",args:{},call_id:void 0},result:null};try{J=JSON.parse(N)}catch{J={call:{tool:"Error",args:{raw:N}},result:{status:"failed"}}}const B=typeof J.call.tool=="string"?J.call.tool:"Unknown",z=typeof J.call.call_id=="string"?J.call.call_id:void 0;return t.jsx(ws,{callId:z,toolName:B,status:js(J.result),parameters:Jn(J.call.args),result:J.result})}if(S==="tool-call"){let J={tool:"Unknown",args:{},call_id:void 0};try{J=JSON.parse(N)}catch{J={tool:"Error",args:{raw:N}}}const B=typeof J.call_id=="string"?J.call_id:void 0,z=B&&p.has(B)?gl(p.get(B)??Qn()):void 0;return t.jsx(ws,{callId:B,toolName:typeof J.tool=="string"?J.tool:"Unknown",status:z?js(z):"pending",parameters:Jn(J.args),result:z})}if(S==="tool-result")return null;if(["xyz","extxyz","cif","pdb"].includes(S)){const J=o.renderInlineCode({code:N,isIncomplete:!1,language:S});if(c.isValidElement(J))return J}if(P){const B=(((K=l==null?void 0:l.getLoadedLanguages)==null?void 0:K.call(l))??[]).includes(S)?S:"text",z=u?"ayu-dark":"ayu-light",te=`${S||"text"}:${N.length}:${N.slice(0,32)}`;let se="";if(l)try{se=Ns(l.codeToHtml(N,{lang:B,theme:z}))}catch{se=Ns(l.codeToHtml(N,{lang:"text",theme:z}))}return t.jsxs("div",{className:"thread-graph-code-block not-prose relative my-3 overflow-auto rounded-xl border p-3 text-sm shadow-sm",children:[t.jsx(Tr,{type:"button",onClick:()=>void g(te,N),variant:"ghost",size:"sm",className:"thread-graph-code-copy absolute right-2 top-2 z-10 rounded-md p-1.5",title:d[te]==="copied"?"Copied":d[te]==="failed"?"Copy failed":"Copy","aria-label":"Copy code",children:d[te]==="copied"?t.jsx(_.Check,{className:"h-3.5 w-3.5"}):t.jsx(_.Copy,{className:"h-3.5 w-3.5"})}),se?t.jsx("div",{dangerouslySetInnerHTML:{__html:se}}):t.jsx("pre",{children:t.jsx("code",{className:"whitespace-pre",children:N})})]})}const Q=Cs(w).replace(/`+/g,"");return t.jsx("code",{className:`thread-graph-inline-code rounded px-1 py-0.5 font-mono font-normal text-[0.9em] ${x||""}`,...b,children:Q})};return t.jsx("div",{ref:s,className:`thread-graph-message-markdown ${r}`,children:t.jsx(Md,{remarkPlugins:[$d,Dd],rehypePlugins:[_d],components:{a({href:w,children:x,...j}){const y=Fp(w);return y&&a?t.jsx("a",{...j,href:w,className:"thread-inline-link",onClick:b=>{b.preventDefault(),a(y)},children:x}):t.jsx("a",{...j,href:w,className:"thread-inline-link",children:x})},code:k,pre:Hp},children:f})})}),Ss=2400,Up=/\b(?:https?:\/\/|www\.)[^\s<>"'`]+/gi,Vp=/[),.;:!?]+$/;function qp(e){return e.startsWith("www.")?`https://${e}`:e}function Ts(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function Xp(e){var o;if(!e)return[];const r=/\[(PHOTO|FILE)\s+([^\]]+)\]/g,n=[];let a=0,s=0;for(const l of e.matchAll(r)){const i=l.index??0;i>a&&(n.push({type:"text",key:`text-${s}`,text:e.slice(a,i)}),s+=1);const d=l[1],h=((o=l[2])==null?void 0:o.trim())??"";d==="PHOTO"&&h?n.push({type:"photo",key:`photo-${s}`,path:h}):d==="FILE"&&h?n.push({type:"file",key:`file-${s}`,path:h}):n.push({type:"text",key:`text-${s}`,text:l[0]}),s+=1,a=i+l[0].length}return a<e.length&&n.push({type:"text",key:`text-${s}`,text:e.slice(a)}),n}function ir({text:e}){var a;const r=[];let n=0;for(const s of e.matchAll(Up)){const o=s[0],l=s.index??0,i=((a=o.match(Vp))==null?void 0:a[0])??"",d=i?o.slice(0,-i.length):o;d&&(l>n&&r.push(e.slice(n,l)),r.push(t.jsx("a",{href:qp(d),target:"_blank",rel:"noreferrer",className:"thread-inline-link",children:d},`${l}-${d}`)),i&&r.push(i),n=l+o.length)}return n<e.length&&r.push(e.slice(n)),t.jsx(t.Fragment,{children:r.length>0?r:e})}var xl=c.memo(function({text:r,scrollRootRef:n,streaming:a=!1,containerClassName:s="",plainTextClassName:o="thread-graph-plain-text whitespace-pre-wrap break-words text-[15px] leading-6",markdownClassName:l="thread-graph-markdown",onBeforeResize:i,onOpenWorkspaceFile:d}){const h=c.useRef(null),u=c.useRef(null),[m,f]=c.useState(!1),p=Ap(r),g=!a&&r.length>Ss,k=g&&!m?`${r.slice(0,Ss).trimEnd()}
|
|
3695
3695
|
|
|
3696
|
-
...`:r,[w,x]=c.useState(a||typeof IntersectionObserver>"u"),j=c.useCallback(()=>{const y=n.current,b=h.current,v=(b==null?void 0:b.getBoundingClientRect().top)??null;i==null||i(),u.current=y&&v!==null?{root:y,top:v}:null,f(S=>!S)},[i,n]);return c.useLayoutEffect(()=>{const y=u.current,b=h.current;if(!y||!b)return;u.current=null;const v=()=>{const N=b.getBoundingClientRect().top;y.root.scrollTop+=N-y.top};v();const S=window.requestAnimationFrame(v);return()=>{window.cancelAnimationFrame(S)}},[m]),c.useEffect(()=>{if(a||typeof IntersectionObserver>"u"){x(!0);return}if(w||!h.current)return;const y=new IntersectionObserver(b=>{for(const v of b)if(v.isIntersecting){x(!0),y.disconnect();break}},{root:n.current,threshold:0});return y.observe(h.current),()=>{y.disconnect()}},[w,n,a]),t.jsxs("div",{ref:h,className:s,children:[w&&p?t.jsx(
|
|
3696
|
+
...`:r,[w,x]=c.useState(a||typeof IntersectionObserver>"u"),j=c.useCallback(()=>{const y=n.current,b=h.current,v=(b==null?void 0:b.getBoundingClientRect().top)??null;i==null||i(),u.current=y&&v!==null?{root:y,top:v}:null,f(S=>!S)},[i,n]);return c.useLayoutEffect(()=>{const y=u.current,b=h.current;if(!y||!b)return;u.current=null;const v=()=>{const N=b.getBoundingClientRect().top;y.root.scrollTop+=N-y.top};v();const S=window.requestAnimationFrame(v);return()=>{window.cancelAnimationFrame(S)}},[m]),c.useEffect(()=>{if(a||typeof IntersectionObserver>"u"){x(!0);return}if(w||!h.current)return;const y=new IntersectionObserver(b=>{for(const v of b)if(v.isIntersecting){x(!0),y.disconnect();break}},{root:n.current,threshold:0});return y.observe(h.current),()=>{y.disconnect()}},[w,n,a]),t.jsxs("div",{ref:h,className:s,children:[w&&p?t.jsx(Wp,{content:k,className:l,onOpenWorkspaceFile:d}):t.jsx("p",{className:o,children:t.jsx(ir,{text:k})}),g?t.jsx("button",{type:"button",onClick:j,className:"thread-graph-show-more timeline-meta-text mt-1.5 flex w-full items-center justify-center rounded-md border border-[var(--theme-border)] px-2 py-0.5 text-[10px] leading-4 transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)]",children:m?"Show less":`Show more (${r.length.toLocaleString()} chars)`}):null]})}),Kp=c.memo(function({text:r,scrollRootRef:n,streaming:a=!1,onBeforeResize:s,onOpenWorkspaceFile:o}){return t.jsx(xl,{text:r,scrollRootRef:n,streaming:a,containerClassName:"thread-graph-message-prose",...s?{onBeforeResize:s}:{},...o?{onOpenWorkspaceFile:o}:{}})}),Yp=c.memo(function({threadId:r,text:n,attachmentPreviewUrls:a,getImageAssetUrl:s}){const o=c.useMemo(()=>Xp(n),[n]);return t.jsx("div",{className:"thread-graph-message-prose whitespace-pre-wrap break-words text-[15px] leading-6",children:o.map(l=>{if(l.type==="text")return t.jsx("span",{children:l.text},l.key);if(l.type==="photo"){const d=(a==null?void 0:a[l.path])??(r?(s==null?void 0:s({threadId:r,path:l.path}))??null:null),h=Ts(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=Ts(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 Zp(){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 Es({status:e}){if(!e)return null;const r=e.toLowerCase(),n=r.includes("running")||r.includes("generating")||r.includes("steering"),a=r.includes("failed")||r.includes("error"),s=r.includes("accepted")||r.includes("complete"),o=n?"ui-status-warning":a?"ui-status-danger":s?"ui-status-success":"ui-status-neutral",l=n?t.jsx(_.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):a?t.jsx(_.XCircle,{className:"h-3.5 w-3.5"}):s?t.jsx(_.CheckCircle2,{className:"h-3.5 w-3.5"}):t.jsx(_.Circle,{className:"h-3.5 w-3.5"});return t.jsxs("span",{className:`thread-graph-message-status inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs font-normal ${o}`,title:e,"aria-label":`Status: ${e}`,children:[t.jsx("span",{className:"thread-graph-message-status-icon inline-flex shrink-0",children:n?t.jsx(Zp,{}):l}),t.jsx("span",{className:"thread-graph-status-label",children:e})]})}function Jp({children:e,copyButton:r,kind:n,metaControl:a,reasoning:s,status:o,timeLabel:l,timeTitle:i}){const d=n==="userMessage",h=l?t.jsx("span",{title:i??void 0,className:"thread-graph-message-time text-[10px] leading-none sm:text-[11px]",children:l}):null;return t.jsx("div",{"data-testid":"chat-message","data-role":d?"user":"assistant",className:"thread-graph-message flex justify-start",children:t.jsxs("div",{className:`thread-graph-message-bubble min-w-0 w-full max-w-full ${d?"is-user":"is-assistant"}`,children:[d?null:t.jsxs("div",{className:"thread-graph-message-header mb-2 flex min-w-0 items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"thread-graph-message-sender rounded-full px-2.5 py-1 text-xs font-semibold tracking-[0.02em]",children:"Assistant"}),t.jsx(Es,{status:o??"Complete"})]}),a?t.jsx("div",{className:"thread-graph-message-header-meta flex min-w-0 flex-1 justify-center",children:a}):null,r||h?t.jsxs("div",{className:"thread-graph-message-header-actions flex shrink-0 items-center gap-1.5 sm:gap-2",children:[r,h]}):null]}),s,t.jsx("div",{className:`thread-graph-message-content min-w-0 ${d?"is-user":"is-assistant"}`,children:e}),d&&(o||h)?t.jsxs("div",{className:"mt-1 flex items-center justify-end gap-2",children:[o?t.jsx(Es,{status:o}):null,h]}):null]})})}Pr();function Qp(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function ef({tone:e="amber"}){const r=e==="sky"?"bg-sky-300/90":"bg-amber-200/90";return t.jsx("span",{className:"ml-1.5 inline-flex items-center gap-1","aria-hidden":"true",children:[0,1,2].map(n=>t.jsx("span",{className:`h-1.5 w-1.5 animate-pulse rounded-full ${r}`,style:{animationDelay:`${n*180}ms`}},n))})}var It=c.memo(function({threadId:r,item:n,scrollRootRef:a,streaming:s=!1,adapter:o,timeLabel:l,timeTitle:i,onBeforeMessageResize:d}){const[h,u]=c.useState("idle"),[m,f]=c.useState(!1),p=c.useRef(null),g=n.kind==="agentMessage"?n.reasoningItems??[]:[],k=g.map(N=>N.text.trim()).filter(Boolean).join(`
|
|
3697
3697
|
|
|
3698
|
-
`),w=n.kind==="userMessage"&&(n.status==="Steering"||n.status==="Accepted"||n.status==="Awaiting response");c.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current)},[]);async function x(){try{await navigator.clipboard.writeText(n.text),u("copied"),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>u("idle"),1200)}catch{u("failed"),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>u("idle"),1600)}}function j(){d==null||d(),f(N=>!N)}const y=n.kind==="agentMessage"?t.jsx("button",{type:"button","aria-label":"Copy agent reply",title:h==="copied"?"Copied":h==="failed"?"Copy failed":"Copy agent reply",onClick:()=>void x(),className:`thread-graph-message-copy inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border transition ${h==="copied"?"ui-status-info":h==="failed"?"ui-status-danger":""}`,children:h==="copied"?t.jsx($.Check,{className:"h-3.5 w-3.5"}):t.jsx($.Copy,{className:"h-3.5 w-3.5"})}):null,b=g.some(N=>Kp(N.status)),v=n.kind==="agentMessage"&&k?t.jsxs("button",{type:"button","aria-label":m?"Hide chain of thought":"Show chain of thought","aria-expanded":m,title:m?"Hide CoT":"Show CoT",onClick:j,className:`thread-graph-thinking-toggle inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border px-2 text-xs font-medium transition ${m?"is-open":""}`,children:[t.jsx($.Brain,{className:`h-3.5 w-3.5 ${b?"animate-pulse":""}`}),t.jsx("span",{children:"CoT"}),b?t.jsx(Xp,{tone:"sky"}):null]}):null,S=n.kind==="agentMessage"&&k?t.jsx("div",{className:"thread-graph-message-thinking mb-3",children:t.jsx(Lr,{type:"single",collapsible:!0,className:"thread-graph-thinking-accordion w-full border-none",onValueChange:N=>f(!!N),...m?{value:"thoughts"}:{},children:t.jsx(Ir,{value:"thoughts",className:"border-b-0",children:t.jsx(zr,{className:"thread-graph-thinking-content pb-0",children:t.jsx("pre",{className:"thread-graph-thinking-body my-1 max-h-56 overflow-auto whitespace-pre-wrap break-words rounded-xl border p-3 text-[12px] leading-5",children:t.jsx(ir,{text:k})})})})})}):null;return t.jsx(qp,{kind:n.kind,status:w||n.kind==="agentMessage"?n.status:null,copyButton:y,metaControl:v,reasoning:S,timeLabel:l,timeTitle:i,children:n.kind==="agentMessage"?t.jsx(Wp,{text:n.text,scrollRootRef:a,streaming:s,...d?{onBeforeResize:d}:{},...o!=null&&o.onOpenWorkspaceFile?{onOpenWorkspaceFile:o.onOpenWorkspaceFile}:{}}):t.jsx(Up,{threadId:r,text:n.text,attachmentPreviewUrls:n.attachmentPreviewUrls,getImageAssetUrl:o==null?void 0:o.getImageAssetUrl})})});function Yp(e){return!!(e&&typeof e.id=="string"&&typeof e.kind=="string")}function dr(e){return e.filter(Yp)}function Ts(e){return e.replace(/"/g,'"').replace(/'/g,"'").replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&")}function gl(e){const r=e.trim().match(/^<hook_prompt(?:\s+hook_run_id="([^"]+)")?>([\s\S]*)<\/hook_prompt>$/);if(!r)return null;const n=r[1]?Ts(r[1]):null,a=Ts(r[2]??"").trim(),s=(n==null?void 0:n.split(":")[0])??"hook",o=s==="stop"?"Stop":s,l=(n==null?void 0:n.split(":").slice(2).join(":"))||null;return{id:`live-hook-prompt:${n??"unknown"}`,kind:"hook",text:`${o} hook`,previewText:a||`${o} hook`,detailText:a||null,status:"Completed",hookEventName:s,hookEventLabel:o,hookHandlerType:"command",hookScope:"turn",hookSource:l?"project":null,hookSourcePath:l,hookStatusMessage:null,hookOutputEntries:a?[{kind:"warning",text:a}]:[]}}function Zp(e){return e==="userMessage"||e==="agentMessage"}function Jp(e){return e==="commandExecution"||e==="webSearch"||e==="fileRead"||e==="fileChange"||e==="image"||e==="contextCompaction"}function Qp(e){return e==="agentMessage"||e==="reasoning"||e==="agentToolCall"||e==="skillToolCall"||e==="toolCall"||e==="plan"}function ef(e,r){const n=dr(e);if(!r)return n;const a=[...n],s=a.findIndex(l=>l.kind==="userMessage");if(s<0)return a;for(let l=s+1;l<a.length;l+=1){const i=a[l];if(!i||i.kind!=="userMessage")continue;let d=l+1;for(;d<a.length&&Jp(a[d].kind);)d+=1;if(d===l+1)continue;const[h]=a.splice(l,1);a.splice(d-1,0,h),l=d-1}let o=!1;return a.map((l,i)=>l.kind!=="userMessage"?l:o?a.slice(i+1).some(h=>Qp(h.kind))?l:{...l,status:"Awaiting response"}:(o=!0,l))}function Tt(e){return typeof e.sequence=="number"&&Number.isFinite(e.sequence)}function Dr(e){return Tt(e)?e.sequence:Number.POSITIVE_INFINITY}function Es(e){var u;const r=dr(e),n=[];let a=0;for(;a<r.length&&((u=r[a])==null?void 0:u.kind)==="userMessage"&&!Tt(r[a]);)n.push(r[a]),a+=1;const s=r.slice(a);if(!s.some(Tt))return r;const o=s.map(m=>Dr(m)).filter(Number.isFinite),l=o.length>0?Math.max(...o):0,i=[];let d=0;for(;d<s.length;){const m=s[d];if(Tt(m)){i.push({item:m,index:d,order:Dr(m)}),d+=1;continue}const f=d;for(;d<s.length&&!Tt(s[d]);)d+=1;const p=s.slice(f,d),g=[...s.slice(0,f)].reverse().find(Tt),k=s.slice(d).find(Tt),w=g?Dr(g):null,x=k?Dr(k):null;p.forEach((j,y)=>{let b;if(w===null&&x!==null)b=x-(p.length-y)/(p.length+1);else if(w!==null&&x!==null&&x>w){const v=x-w;b=w+(y+1)/(p.length+1)*v}else b=l+1+y/(p.length+1);i.push({item:j,index:f+y,order:b})})}const h=i.sort((m,f)=>{const p=m.order-f.order;return p===0?m.index-f.index:p}).map(m=>m.item);return[...n,...h]}function tf(e,r){const n=dr(e),a=dr(r??[]);if(a.length===0)return Es(n);const s=new Map(a.map(i=>[i.id,i])),o=n.map(i=>{const d=s.get(i.id);if(!d)return i;s.delete(i.id);const h={...i,...d,text:d.text||i.text},u=d.detailText??i.detailText,m=d.previewText??i.previewText,f=d.status??i.status,p=d.sequence??i.sequence;return u!==void 0&&(h.detailText=u),m!==void 0&&(h.previewText=m),f!==void 0&&(h.status=f),p!==void 0&&(h.sequence=p),h}),l=[...s.values()];return l.length===0&&!o.some(Tt)||(o.push(...l),!o.some(i=>typeof i.sequence=="number"&&Number.isFinite(i.sequence)))?o:Es(o)}function rf(e,r){if(!e)return"";const n=dr(r).filter(d=>d.kind==="agentMessage").map(d=>d.text).filter(d=>d.length>0),a=n.at(-1)??"";if(a){const d=e.lastIndexOf(a);if(d>=0){const h=e.slice(d+a.length);return h.trim()?h:""}}const s=n.join("");if(!s)return e;const o=Math.min(e.length,s.length);let l=0;for(;l<o&&e[l]===s[l];)l+=1;if(l===0)return e;const i=e.slice(l);return i.trim()?i:""}function ma(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function yr(e){return e==="inProgress"||e==="sending"}function nf(e){return lf(af(dr(e)))}function af(e){var a;const r=[];let n=0;for(;n<e.length;){const s=e[n];if(!s)break;if(s.kind!=="commandExecution"&&s.kind!=="fileChange"&&s.kind!=="webSearch"&&s.kind!=="fileRead"&&s.kind!=="toolCall"&&s.kind!=="agentToolCall"&&s.kind!=="skillToolCall"){r.push({kind:"item",key:s.id,item:s}),n+=1;continue}const o=[];for(;n<e.length&&((a=e[n])==null?void 0:a.kind)===s.kind;)o.push(e[n]),n+=1;if(o.length===1){r.push({kind:"item",key:o[0].id,item:o[0]});continue}const l=o.map(i=>i.id).join(":");if(s.kind==="commandExecution"){r.push({kind:"commandGroup",key:l,items:o});continue}if(s.kind==="fileChange"){r.push({kind:"fileChangeGroup",key:l,items:o});continue}if(s.kind==="fileRead"){r.push({kind:"fileReadGroup",key:l,items:o});continue}if(s.kind==="toolCall"){r.push({kind:"toolCallGroup",key:l,items:o});continue}if(s.kind==="agentToolCall"){r.push({kind:"agentToolCallGroup",key:l,items:o});continue}if(s.kind==="skillToolCall"){r.push({kind:"skillToolCallGroup",key:l,items:o});continue}r.push({kind:"searchGroup",key:l,items:o})}return r}function Ls(e){return e.kind!=="item"?e.kind!=="agentActivityGroup":e.item.kind==="commandExecution"||e.item.kind==="fileChange"||e.item.kind==="webSearch"||e.item.kind==="fileRead"||e.item.kind==="toolCall"||e.item.kind==="agentToolCall"||e.item.kind==="skillToolCall"}function sf(e){return(e==null?void 0:e.kind)==="item"&&e.item.kind==="agentMessage"&&e.item.text.trim().length>0&&!ma(e.item.status)}function of(e){return e.kind==="item"?1:e.kind==="agentActivityGroup"?e.itemCount:e.items.length}function lf(e){const r=[];let n=0;for(;n<e.length;){if(!Ls(e[n])){r.push(e[n]),n+=1;continue}const a=n;for(;n<e.length&&Ls(e[n]);)n+=1;const s=e.slice(a,n),o=s.reduce((l,i)=>l+of(i),0);if(o>1&&sf(e[n])){r.push({kind:"agentActivityGroup",key:`agent-activity:${s.map(l=>l.key).join(":")}`,entries:s,itemCount:o});continue}r.push(...s)}return r}function xl(e,r){return[...e.map(n=>({id:n.id,startedAt:n.startedAt??""})),...r?[{id:r.id,startedAt:r.startedAt??""}]:[]]}function jr(e,r,n){const a=e.get(r)??[];a.push(n),e.set(r,a)}function bl(e,r){return e.find(n=>r&&n.startedAt&&r.localeCompare(n.startedAt)<=0)}function df({answeredRequestNotes:e,pendingRequests:r,visibleTurns:n,optimisticTurn:a}){const s=new Set(n.map(p=>p.id)),o=new Map,l=new Map,i=[],d=[];for(const p of e)p.turnId&&s.has(p.turnId)?jr(o,p.turnId,p):i.push(p);for(const p of r)p.turnId&&s.has(p.turnId)?jr(l,p.turnId,p):d.push(p);const h=xl(n,a),u=new Map,m=[],f=[...i.map(p=>({kind:"note",id:p.id,createdAt:p.createdAt??"",note:p})),...d.map(p=>({kind:"request",id:p.id,createdAt:p.createdAt,request:p}))].sort((p,g)=>p.createdAt.localeCompare(g.createdAt));for(const p of f){const g=bl(h,p.createdAt);if(!g){m.push(p);continue}jr(u,g.id,p)}return{notesByTurnId:o,pendingRequestsByTurnId:l,beforeTurnId:u,trailing:m}}function cf({activityNotes:e,visibleTurns:r,optimisticTurn:n}){const a=[...e].sort((m,f)=>m.createdAt.localeCompare(f.createdAt)),s=xl(r,n),o=[],l=new Map,i=new Map,d=[],u=s.map(m=>m.startedAt).filter(m=>!!m).sort().at(-1)??null;for(const m of a){if(m.anchorTurnId==="__leading__"){o.push(m);continue}if(m.anchorTurnId){s.some(p=>p.id===m.anchorTurnId)?jr(i,m.anchorTurnId,m):o.push(m);continue}const f=bl(s,m.createdAt);if(!f){!u||m.createdAt.localeCompare(u)<=0?o.push(m):d.push(m);continue}jr(l,f.id,m)}return{leading:o,beforeTurnId:l,afterTurnId:i,trailing:d}}function vl({request:e,busy:r=!1,onRespond:n}){const[a,s]=c.useState({}),[o,l]=c.useState({}),[i,d]=c.useState(null),h=e.questions[0]??null,u="__other__",m=e.kind==="planDecision"?"Plan":e.kind==="requestUserInput"?"Answer Required":e.title;function f(x){const j=/\s*\(recommended\)\s*$/i.test(x);return{rawLabel:x,displayLabel:x.replace(/\s*\(recommended\)\s*$/i,"").trim(),recommended:j}}function p(x){h&&(d(x),n==null||n(e.id,{answers:{[h.id]:{answers:[x]}}}))}function g(x){const j=a[x.id]??"";return Array.isArray(j)?j.map(y=>y===u?(o[x.id]??"").trim():y.trim()).filter(Boolean).join(", "):j===u?(o[x.id]??"").trim():j.trim()}function k(x){const j=a[x.id]??"";if(Array.isArray(j))return j.map(b=>b===u?(o[x.id]??"").trim():b.trim()).filter(Boolean);if(j===u){const b=(o[x.id]??"").trim();return b?[b]:[]}const y=j.trim();return y?[y]:[]}function w(x,j){s(y=>{const b=y[x],v=Array.isArray(b)?b:[],S=v.includes(j)?v.filter(N=>N!==j):[...v,j];return{...y,[x]:S}})}return t.jsxs("div",{className:"timeline-pending-card w-full rounded-[1rem] border px-3 py-3 sm:rounded-[1.2rem] sm:px-4",children:[t.jsx("div",{className:"flex items-center justify-between gap-3",children:t.jsxs("div",{children:[t.jsx("p",{className:"timeline-primary-text text-sm font-medium",children:m}),e.kind!=="planDecision"&&e.description&&t.jsx("p",{className:"timeline-soft-text mt-1 text-[13px] leading-5",children:e.description})]})}),t.jsx("div",{className:"mt-3 space-y-3",children:e.questions.map(x=>t.jsxs("div",{className:"timeline-question-section rounded-xl border p-2.5 sm:p-3",children:[t.jsx("p",{className:"timeline-meta-text text-xs uppercase tracking-[0.2em]",children:x.header}),t.jsx("p",{className:"timeline-primary-text mt-1 text-[13px] leading-5 sm:text-sm",children:x.question}),e.kind==="planDecision"&&x.options&&x.options.length>0?t.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:x.options.map((j,y)=>{const b=f(j.label),v=b.displayLabel.toLowerCase()==="implement";return t.jsxs("button",{type:"button",disabled:r,onClick:()=>p(j.label),className:`relative rounded-2xl border px-2.5 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${y===0?"ui-action-info":"border-stone-700 text-stone-200 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:j.description,children:[b.recommended?t.jsx("span",{"aria-hidden":"true",className:"absolute right-1.5 top-1 inline-flex h-3.5 w-3.5 items-center justify-center rounded-full bg-white/18 text-[10px] leading-none text-current",children:"✦"}):null,r&&i===j.label?v?"Starting...":"Saving...":b.displayLabel]},j.label)})}):x.options&&x.options.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[x.options.map(j=>{const y=f(j.label),b=a[x.id];return t.jsxs("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?w(x.id,j.label):s(v=>({...v,[x.id]:j.label})),className:`relative rounded-2xl border px-3 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${(x.multiSelect?Array.isArray(b)&&b.includes(j.label):b===j.label)?"ui-status-warning":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:j.description,children:[y.recommended?t.jsx("span",{"aria-hidden":"true",className:"absolute right-1.5 top-1 inline-flex h-3.5 w-3.5 items-center justify-center rounded-full bg-white/10 text-[10px] leading-none text-amber-100/90",children:"✦"}):null,y.displayLabel]},j.label)}),x.isOther&&(()=>{const j=a[x.id];return t.jsx("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?w(x.id,u):s(y=>({...y,[x.id]:u})),className:`rounded-2xl border px-3 py-1.5 text-[12px] leading-4 transition sm:text-[13px] ${(x.multiSelect?Array.isArray(j)&&j.includes(u):j===u)?"ui-status-info":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Not from above"})})()]}),x.isOther&&(()=>{const j=a[x.id];return(x.multiSelect?Array.isArray(j)&&j.includes(u):j===u)?t.jsx("input",{"aria-label":`${x.header} custom answer`,value:o[x.id]??"",onChange:b=>l(v=>({...v,[x.id]:b.target.value})),placeholder:"Enter a custom answer",className:"mt-3 w-full rounded-xl border border-stone-700 bg-stone-900 px-3 py-2 text-sm text-stone-100 outline-none transition focus:border-sky-300"}):null})()]}):t.jsx("input",{"aria-label":x.header,value:a[x.id]??"",onChange:j=>s(y=>({...y,[x.id]:j.target.value})),className:"mt-3 w-full rounded-xl border border-stone-700 bg-stone-900 px-3 py-2 text-sm text-stone-100 outline-none transition focus:border-amber-300"})]},x.id))}),e.kind!=="planDecision"&&t.jsx("div",{className:"mt-3 flex justify-end",children:t.jsx("button",{type:"button",disabled:r||e.questions.some(x=>!g(x)),onClick:()=>void(n==null?void 0:n(e.id,{answers:Object.fromEntries(e.questions.map(x=>[x.id,{answers:k(x)}]))})),className:"ui-action-info rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:r?"Submitting...":"Submit"})})]})}function kl({note:e}){return t.jsxs("div",{className:"timeline-note-card w-full rounded-2xl border px-3 py-2.5",children:[t.jsx("p",{className:"timeline-meta-text text-[11px] uppercase tracking-[0.2em]",children:e.title}),t.jsx("div",{className:"mt-1 space-y-1",children:e.summaryLines.map((r,n)=>t.jsxs("p",{className:"timeline-primary-text text-[13px] leading-5",children:["You selected ",r]},`${e.id}-${n}`))})]})}function wl({note:e,onOpenThread:r,onOpenLinkedThread:n}){const a=e.kind==="forkCreated"?"Fork":e.kind==="forkSource"?"Fork source":e.kind==="goal"?"Goal":"System",s=e.kind==="forkCreated"?`Thread forked from Turn ${e.turnIndex??"?"}`:e.kind==="forkSource"?`Forked from ${e.linkedThreadTitle??"source thread"} at Turn ${e.turnIndex??"?"}`:e.text??"";return t.jsxs("div",{className:"timeline-activity-card w-full rounded-2xl border px-3 py-2.5",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("p",{className:"timeline-meta-text text-[11px] uppercase tracking-[0.2em]",children:a}),t.jsx("time",{dateTime:e.createdAt,title:Ut(e.createdAt),className:"timeline-meta-text text-[10px]",children:kt(e.createdAt)})]}),t.jsx("p",{className:"timeline-primary-text mt-1 text-[13px] leading-5",children:s}),e.linkedThreadId?t.jsx("button",{type:"button",onClick:()=>{const o=e.linkedThreadId;o&&(n==null||n(o),r==null||r(o))},className:"relative z-10 mt-2 inline-flex cursor-pointer rounded-full border border-amber-300/30 px-3 py-1.5 text-xs text-amber-100 transition hover:bg-amber-300/10",children:e.kind==="forkCreated"?"Open fork":"Back to source"}):null]})}function xr({notes:e,onOpenThread:r,onOpenLinkedThread:n}){return e.length===0?null:t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:e.map(a=>t.jsx(wl,{note:a,onOpenThread:r,onOpenLinkedThread:n},a.id))})}function Jn({entries:e,respondingRequestId:r,onRespondToRequest:n}){return e.length===0?null:t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:e.map(a=>a.kind==="note"?t.jsx(kl,{note:a.note},a.id):t.jsx(vl,{request:a.request,busy:r===a.request.id,onRespond:n},a.id))})}function hf({notes:e,requests:r,respondingRequestId:n,onRespondToRequest:a}){const s=[...e.map(o=>({kind:"note",id:o.id,createdAt:o.createdAt??"",note:o})),...r.map(o=>({kind:"request",id:o.id,createdAt:o.createdAt,request:o}))].sort((o,l)=>o.createdAt.localeCompare(l.createdAt));return t.jsx(Jn,{entries:s,respondingRequestId:n,onRespondToRequest:a})}function uf({entries:e,respondingRequestId:r,onRespondToRequest:n,onOpenThread:a,onOpenLinkedThread:s}){return e.length===0?null:t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:[...e].sort((o,l)=>o.createdAt.localeCompare(l.createdAt)).map(o=>o.kind==="activity"?t.jsx(wl,{note:o.note,onOpenThread:a,onOpenLinkedThread:s},o.id):o.kind==="note"?t.jsx(kl,{note:o.note},o.id):t.jsx(vl,{request:o.request,busy:r===o.request.id,onRespond:n},o.id))})}function mf({entries:e,expandedGroups:r,onToggleGroupedItem:n,renderCommandGroup:a,renderFileChangeGroup:s,renderFileReadGroup:o,renderItem:l,renderSearchGroup:i,renderToolCallGroup:d,renderAgentActivityGroup:h}){return t.jsx(t.Fragment,{children:e.map(u=>{const m=r[u.key]??!1,f=()=>n(u.key);return u.kind==="commandGroup"?a(u,m,f):u.kind==="fileChangeGroup"?s(u,m,f):u.kind==="searchGroup"?i(u,m,f):u.kind==="fileReadGroup"?o(u,m,f):u.kind==="toolCallGroup"||u.kind==="agentToolCallGroup"||u.kind==="skillToolCallGroup"?d(u,m,f):u.kind==="agentActivityGroup"?h(u,m,f):l(u)})})}function hr({children:e,className:r,count:n,countBadgeClassName:a,desktopIconClassName:s,expanded:o,expandedListClassName:l,icon:i,onToggleExpanded:d,runningIndicator:h,summary:u,timeMeta:m,toggleAriaLabel:f,trailingSummary:p}){return t.jsx("div",{className:`thread-graph-history-group ${r} relative min-w-0 w-full overflow-hidden rounded-[0.9rem] border px-3 py-2.5`,children:t.jsxs("div",{className:"flex items-start gap-2.5",children:[t.jsxs("div",{className:"thread-graph-history-group-icon mt-0.5 flex shrink-0 items-center",children:[t.jsxs("span",{className:`relative inline-flex h-8 w-8 items-center justify-center rounded-[0.9rem] border shadow-sm shadow-stone-950/20 ${s}`,children:[i,t.jsx("span",{className:`absolute -right-1 -top-1 inline-flex min-w-[1.1rem] items-center justify-center rounded-full border bg-stone-950/90 px-1 text-[9px] font-semibold leading-4 ${a}`,children:n})]}),h]}),t.jsxs("div",{className:"thread-graph-history-group-card min-w-0 flex-1 rounded-[0.85rem] border px-3 py-2",children:[t.jsxs("button",{type:"button","aria-expanded":o,"aria-label":f,onClick:d,className:"thread-graph-history-group-toggle flex w-full min-w-0 items-center justify-between gap-3 text-left",children:[t.jsx("div",{className:"thread-graph-history-group-summary min-w-0 flex flex-1 flex-wrap items-center gap-2 pr-1",children:u}),p||m?t.jsxs("div",{className:"inline-flex shrink-0 items-center gap-2",children:[p,m]}):null]}),o?t.jsx("div",{className:`thread-graph-history-group-list mt-3 space-y-2 border-t pt-3 ${l}`,children:e}):null]})]})})}Pr();Pt();var pf=Er("inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden whitespace-nowrap rounded-md border px-2 py-0.5 text-xs font-medium outline-none transition-[color,box-shadow] focus-visible:ring-[3px] [&>svg]:pointer-events-none [&>svg]:size-3",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-white",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function dn({asChild:e=!1,className:r,variant:n,...a}){const s=e?Os:"span";return t.jsx(s,{"data-slot":"badge",className:at(pf({variant:n,className:r})),...a})}function cn(e){if(!e)return!1;const r=e.trim().toLowerCase();return r==="running"||r==="in_progress"||r==="in progress"||r==="pending"}function ff(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5 2.75h4l2 2v6.5a1.5 1.5 0 0 1-1.5 1.5h-4A1.5 1.5 0 0 1 4 11.25v-7A1.5 1.5 0 0 1 5.5 2.75Z"}),t.jsx("path",{d:"M9 2.75v2h2"}),t.jsx("path",{d:"M6.2 8h3.6"}),t.jsx("path",{d:"M6.2 10h1.7"})]})}function gf(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5 2.75h4l2 2v6.5a1.5 1.5 0 0 1-1.5 1.5h-4A1.5 1.5 0 0 1 4 11.25v-7A1.5 1.5 0 0 1 5.5 2.75Z"}),t.jsx("path",{d:"M9 2.75v2h2"}),t.jsx("path",{d:"M6.15 7.25h3.7"}),t.jsx("path",{d:"M6.15 9.25h2.8"}),t.jsx("path",{d:"m10.4 10.7 1.2 1.2"}),t.jsx("circle",{cx:"9.25",cy:"9.55",r:"1.45"})]})}function xf(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"2.75",y:"3",width:"8.5",height:"3",rx:"1.1"}),t.jsx("rect",{x:"4.25",y:"6.5",width:"8.5",height:"3",rx:"1.1"}),t.jsx("rect",{x:"5.75",y:"10",width:"7.5",height:"3",rx:"1.1"}),t.jsx("path",{d:"m6.25 4.5 1 1-1 1"}),t.jsx("path",{d:"M7.9 5.5h1.7"}),t.jsx("path",{d:"m7.75 8 1 1-1 1"}),t.jsx("path",{d:"M9.4 9h1.7"})]})}function bf(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"6",cy:"6",r:"2.3"}),t.jsx("path",{d:"m8 8 1.6 1.6"}),t.jsx("circle",{cx:"9.3",cy:"8.8",r:"2"}),t.jsx("path",{d:"m10.75 10.25 1.65 1.65"}),t.jsx("circle",{cx:"11.2",cy:"4.75",r:"1.8"}),t.jsx("path",{d:"m12.45 6 1.1 1.1"})]})}function vf(e){const r=e.trim();if(!r)return"";const n=r.match(/(, \+\d+ more.*)$/),a=(n==null?void 0:n[1])??"",o=(a?r.slice(0,-a.length):r).replace(/\\/g,"/");if(!o.startsWith("/"))return`${o.replace(/^\.\//,"")}${a}`;const l=["/apps/","/packages/","/src/","/test/","/tests/","/docs/","/config/","/scripts/","/e2e/","/.agents/","/.codex/"];for(const i of l){const d=o.indexOf(i);if(d>=0)return`${o.slice(d+1)}${a}`}return r}function yl(e,r=42){const n=vf(e);if(!n)return"";const a=n.match(/(, \+\d+ more.*)$/),s=(a==null?void 0:a[1])??"",o=s?n.slice(0,-s.length):n;if(o.length<=r)return`${o}${s}`;const i=o.replace(/\\/g,"/").split("/").filter(Boolean);if(i.length>1){const d=[];let h=s.length+4;for(let u=i.length-1;u>=0;u-=1){const m=i[u],f=h+m.length+(d.length>0?1:0);if(d.length>0&&f>r)break;d.unshift(m),h=f}if(d.length>0)return`.../${d.join("/")}${s}`}return`...${o.slice(-(r-s.length-3))}${s}`}function kf(e){var a;const r=[];if(typeof e.changedFiles=="number"&&e.changedFiles>0&&r.push(`${e.changedFiles} ${e.changedFiles===1?"file":"files"}`),typeof e.addedLines=="number"&&e.addedLines>0&&r.push(`+${e.addedLines}`),typeof e.removedLines=="number"&&e.removedLines>0&&r.push(`-${e.removedLines}`),r.length>0)return r;const n=(a=e.previewText)==null?void 0:a.trim();return n?n.replace(/\bfiles changed\b/gi,"files").replace(/\bfile changed\b/gi,"file").split("·").map(s=>s.trim()).filter(Boolean):[]}function Jr({tone:e="amber"}){const r=e==="emerald"?"bg-sky-200/90":e==="sky"?"bg-sky-300/90":"bg-amber-200/90";return t.jsx("span",{className:"ml-1.5 inline-flex items-center gap-1","aria-hidden":"true",children:[0,1,2].map(n=>t.jsx("span",{className:`h-1.5 w-1.5 animate-pulse rounded-full ${r}`,style:{animationDelay:`${n*180}ms`}},n))})}function wf(e){var n;const r=e.replace(/\r\n/g,`
|
|
3698
|
+
`),w=n.kind==="userMessage"&&(n.status==="Steering"||n.status==="Accepted"||n.status==="Awaiting response");c.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current)},[]);async function x(){try{await navigator.clipboard.writeText(n.text),u("copied"),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>u("idle"),1200)}catch{u("failed"),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>u("idle"),1600)}}function j(){d==null||d(),f(N=>!N)}const y=n.kind==="agentMessage"?t.jsx("button",{type:"button","aria-label":"Copy agent reply",title:h==="copied"?"Copied":h==="failed"?"Copy failed":"Copy agent reply",onClick:()=>void x(),className:`thread-graph-message-copy inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border transition ${h==="copied"?"ui-status-info":h==="failed"?"ui-status-danger":""}`,children:h==="copied"?t.jsx(_.Check,{className:"h-3.5 w-3.5"}):t.jsx(_.Copy,{className:"h-3.5 w-3.5"})}):null,b=g.some(N=>Qp(N.status)),v=n.kind==="agentMessage"&&k?t.jsxs("button",{type:"button","aria-label":m?"Hide chain of thought":"Show chain of thought","aria-expanded":m,title:m?"Hide CoT":"Show CoT",onClick:j,className:`thread-graph-thinking-toggle inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border px-2 text-xs font-medium transition ${m?"is-open":""}`,children:[t.jsx(_.Brain,{className:`h-3.5 w-3.5 ${b?"animate-pulse":""}`}),t.jsx("span",{children:"CoT"}),b?t.jsx(ef,{tone:"sky"}):null]}):null,S=n.kind==="agentMessage"&&k?t.jsx("div",{className:"thread-graph-message-thinking mb-3",children:t.jsx(Lr,{type:"single",collapsible:!0,className:"thread-graph-thinking-accordion w-full border-none",onValueChange:N=>f(!!N),...m?{value:"thoughts"}:{},children:t.jsx(Ir,{value:"thoughts",className:"border-b-0",children:t.jsx(zr,{className:"thread-graph-thinking-content pb-0",children:t.jsx("pre",{className:"thread-graph-thinking-body my-1 max-h-56 overflow-auto whitespace-pre-wrap break-words rounded-xl border p-3 text-[12px] leading-5",children:t.jsx(ir,{text:k})})})})})}):null;return t.jsx(Jp,{kind:n.kind,status:w||n.kind==="agentMessage"?n.status:null,copyButton:y,metaControl:v,reasoning:S,timeLabel:l,timeTitle:i,children:n.kind==="agentMessage"?t.jsx(Kp,{text:n.text,scrollRootRef:a,streaming:s,...d?{onBeforeResize:d}:{},...o!=null&&o.onOpenWorkspaceFile?{onOpenWorkspaceFile:o.onOpenWorkspaceFile}:{}}):t.jsx(Yp,{threadId:r,text:n.text,attachmentPreviewUrls:n.attachmentPreviewUrls,getImageAssetUrl:o==null?void 0:o.getImageAssetUrl})})});function tf(e){return!!(e&&typeof e.id=="string"&&typeof e.kind=="string")}function dr(e){return e.filter(tf)}function Ls(e){return e.replace(/"/g,'"').replace(/'/g,"'").replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&")}function bl(e){const r=e.trim().match(/^<hook_prompt(?:\s+hook_run_id="([^"]+)")?>([\s\S]*)<\/hook_prompt>$/);if(!r)return null;const n=r[1]?Ls(r[1]):null,a=Ls(r[2]??"").trim(),s=(n==null?void 0:n.split(":")[0])??"hook",o=s==="stop"?"Stop":s,l=(n==null?void 0:n.split(":").slice(2).join(":"))||null;return{id:`live-hook-prompt:${n??"unknown"}`,kind:"hook",text:`${o} hook`,previewText:a||`${o} hook`,detailText:a||null,status:"Completed",hookEventName:s,hookEventLabel:o,hookHandlerType:"command",hookScope:"turn",hookSource:l?"project":null,hookSourcePath:l,hookStatusMessage:null,hookOutputEntries:a?[{kind:"warning",text:a}]:[]}}function rf(e){return e==="userMessage"||e==="agentMessage"}function nf(e){return e==="commandExecution"||e==="webSearch"||e==="fileRead"||e==="fileChange"||e==="image"||e==="contextCompaction"}function af(e){return e==="agentMessage"||e==="reasoning"||e==="agentToolCall"||e==="skillToolCall"||e==="toolCall"||e==="plan"}function sf(e,r){const n=dr(e);if(!r)return n;const a=[...n],s=a.findIndex(l=>l.kind==="userMessage");if(s<0)return a;for(let l=s+1;l<a.length;l+=1){const i=a[l];if(!i||i.kind!=="userMessage")continue;let d=l+1;for(;d<a.length&&nf(a[d].kind);)d+=1;if(d===l+1)continue;const[h]=a.splice(l,1);a.splice(d-1,0,h),l=d-1}let o=!1;return a.map((l,i)=>l.kind!=="userMessage"?l:o?a.slice(i+1).some(h=>af(h.kind))?l:{...l,status:"Awaiting response"}:(o=!0,l))}function Tt(e){return typeof e.sequence=="number"&&Number.isFinite(e.sequence)}function Dr(e){return Tt(e)?e.sequence:Number.POSITIVE_INFINITY}function Is(e){var u;const r=dr(e),n=[];let a=0;for(;a<r.length&&((u=r[a])==null?void 0:u.kind)==="userMessage"&&!Tt(r[a]);)n.push(r[a]),a+=1;const s=r.slice(a);if(!s.some(Tt))return r;const o=s.map(m=>Dr(m)).filter(Number.isFinite),l=o.length>0?Math.max(...o):0,i=[];let d=0;for(;d<s.length;){const m=s[d];if(Tt(m)){i.push({item:m,index:d,order:Dr(m)}),d+=1;continue}const f=d;for(;d<s.length&&!Tt(s[d]);)d+=1;const p=s.slice(f,d),g=[...s.slice(0,f)].reverse().find(Tt),k=s.slice(d).find(Tt),w=g?Dr(g):null,x=k?Dr(k):null;p.forEach((j,y)=>{let b;if(w===null&&x!==null)b=x-(p.length-y)/(p.length+1);else if(w!==null&&x!==null&&x>w){const v=x-w;b=w+(y+1)/(p.length+1)*v}else b=l+1+y/(p.length+1);i.push({item:j,index:f+y,order:b})})}const h=i.sort((m,f)=>{const p=m.order-f.order;return p===0?m.index-f.index:p}).map(m=>m.item);return[...n,...h]}function of(e,r){const n=dr(e),a=dr(r??[]);if(a.length===0)return Is(n);const s=new Map(a.map(i=>[i.id,i])),o=n.map(i=>{const d=s.get(i.id);if(!d)return i;s.delete(i.id);const h={...i,...d,text:d.text||i.text},u=d.detailText??i.detailText,m=d.previewText??i.previewText,f=d.status??i.status,p=d.sequence??i.sequence;return u!==void 0&&(h.detailText=u),m!==void 0&&(h.previewText=m),f!==void 0&&(h.status=f),p!==void 0&&(h.sequence=p),h}),l=[...s.values()];return l.length===0&&!o.some(Tt)||(o.push(...l),!o.some(i=>typeof i.sequence=="number"&&Number.isFinite(i.sequence)))?o:Is(o)}function lf(e,r){if(!e)return"";const n=dr(r).filter(d=>d.kind==="agentMessage").map(d=>d.text).filter(d=>d.length>0),a=n.at(-1)??"";if(a){const d=e.lastIndexOf(a);if(d>=0){const h=e.slice(d+a.length);return h.trim()?h:""}}const s=n.join("");if(!s)return e;const o=Math.min(e.length,s.length);let l=0;for(;l<o&&e[l]===s[l];)l+=1;if(l===0)return e;const i=e.slice(l);return i.trim()?i:""}function fa(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function yr(e){return e==="inProgress"||e==="sending"}function df(e){return mf(cf(dr(e)))}function cf(e){var a;const r=[];let n=0;for(;n<e.length;){const s=e[n];if(!s)break;if(s.kind!=="commandExecution"&&s.kind!=="fileChange"&&s.kind!=="webSearch"&&s.kind!=="fileRead"&&s.kind!=="toolCall"&&s.kind!=="agentToolCall"&&s.kind!=="skillToolCall"){r.push({kind:"item",key:s.id,item:s}),n+=1;continue}const o=[];for(;n<e.length&&((a=e[n])==null?void 0:a.kind)===s.kind;)o.push(e[n]),n+=1;if(o.length===1){r.push({kind:"item",key:o[0].id,item:o[0]});continue}const l=o.map(i=>i.id).join(":");if(s.kind==="commandExecution"){r.push({kind:"commandGroup",key:l,items:o});continue}if(s.kind==="fileChange"){r.push({kind:"fileChangeGroup",key:l,items:o});continue}if(s.kind==="fileRead"){r.push({kind:"fileReadGroup",key:l,items:o});continue}if(s.kind==="toolCall"){r.push({kind:"toolCallGroup",key:l,items:o});continue}if(s.kind==="agentToolCall"){r.push({kind:"agentToolCallGroup",key:l,items:o});continue}if(s.kind==="skillToolCall"){r.push({kind:"skillToolCallGroup",key:l,items:o});continue}r.push({kind:"searchGroup",key:l,items:o})}return r}function zs(e){return e.kind!=="item"?e.kind!=="agentActivityGroup":e.item.kind==="commandExecution"||e.item.kind==="fileChange"||e.item.kind==="webSearch"||e.item.kind==="fileRead"||e.item.kind==="toolCall"||e.item.kind==="agentToolCall"||e.item.kind==="skillToolCall"}function hf(e){return(e==null?void 0:e.kind)==="item"&&e.item.kind==="agentMessage"&&e.item.text.trim().length>0&&!fa(e.item.status)}function uf(e){return e.kind==="item"?1:e.kind==="agentActivityGroup"?e.itemCount:e.items.length}function mf(e){const r=[];let n=0;for(;n<e.length;){if(!zs(e[n])){r.push(e[n]),n+=1;continue}const a=n;for(;n<e.length&&zs(e[n]);)n+=1;const s=e.slice(a,n),o=s.reduce((l,i)=>l+uf(i),0);if(s.length>1&&hf(e[n])){r.push({kind:"agentActivityGroup",key:`agent-activity:${s.map(l=>l.key).join(":")}`,entries:s,itemCount:o});continue}r.push(...s)}return r}function vl(e,r){return[...e.map(n=>({id:n.id,startedAt:n.startedAt??""})),...r?[{id:r.id,startedAt:r.startedAt??""}]:[]]}function jr(e,r,n){const a=e.get(r)??[];a.push(n),e.set(r,a)}function kl(e,r){return e.find(n=>r&&n.startedAt&&r.localeCompare(n.startedAt)<=0)}function pf({answeredRequestNotes:e,pendingRequests:r,visibleTurns:n,optimisticTurn:a}){const s=new Set(n.map(p=>p.id)),o=new Map,l=new Map,i=[],d=[];for(const p of e)p.turnId&&s.has(p.turnId)?jr(o,p.turnId,p):i.push(p);for(const p of r)p.turnId&&s.has(p.turnId)?jr(l,p.turnId,p):d.push(p);const h=vl(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=kl(h,p.createdAt);if(!g){m.push(p);continue}jr(u,g.id,p)}return{notesByTurnId:o,pendingRequestsByTurnId:l,beforeTurnId:u,trailing:m}}function ff({activityNotes:e,visibleTurns:r,optimisticTurn:n}){const a=[...e].sort((m,f)=>m.createdAt.localeCompare(f.createdAt)),s=vl(r,n),o=[],l=new Map,i=new Map,d=[],u=s.map(m=>m.startedAt).filter(m=>!!m).sort().at(-1)??null;for(const m of a){if(m.anchorTurnId==="__leading__"){o.push(m);continue}if(m.anchorTurnId){s.some(p=>p.id===m.anchorTurnId)?jr(i,m.anchorTurnId,m):o.push(m);continue}const f=kl(s,m.createdAt);if(!f){!u||m.createdAt.localeCompare(u)<=0?o.push(m):d.push(m);continue}jr(l,f.id,m)}return{leading:o,beforeTurnId:l,afterTurnId:i,trailing:d}}function wl({request:e,busy:r=!1,onRespond:n}){const[a,s]=c.useState({}),[o,l]=c.useState({}),[i,d]=c.useState(null),h=e.questions[0]??null,u="__other__",m=e.kind==="planDecision"?"Plan":e.kind==="requestUserInput"?"Answer Required":e.title;function f(x){const j=/\s*\(recommended\)\s*$/i.test(x);return{rawLabel:x,displayLabel:x.replace(/\s*\(recommended\)\s*$/i,"").trim(),recommended:j}}function p(x){h&&(d(x),n==null||n(e.id,{answers:{[h.id]:{answers:[x]}}}))}function g(x){const j=a[x.id]??"";return Array.isArray(j)?j.map(y=>y===u?(o[x.id]??"").trim():y.trim()).filter(Boolean).join(", "):j===u?(o[x.id]??"").trim():j.trim()}function k(x){const j=a[x.id]??"";if(Array.isArray(j))return j.map(b=>b===u?(o[x.id]??"").trim():b.trim()).filter(Boolean);if(j===u){const b=(o[x.id]??"").trim();return b?[b]:[]}const y=j.trim();return y?[y]:[]}function w(x,j){s(y=>{const b=y[x],v=Array.isArray(b)?b:[],S=v.includes(j)?v.filter(N=>N!==j):[...v,j];return{...y,[x]:S}})}return t.jsxs("div",{className:"timeline-pending-card w-full rounded-[1rem] border px-3 py-3 sm:rounded-[1.2rem] sm:px-4",children:[t.jsx("div",{className:"flex items-center justify-between gap-3",children:t.jsxs("div",{children:[t.jsx("p",{className:"timeline-primary-text text-sm font-medium",children:m}),e.kind!=="planDecision"&&e.description&&t.jsx("p",{className:"timeline-soft-text mt-1 text-[13px] leading-5",children:e.description})]})}),t.jsx("div",{className:"mt-3 space-y-3",children:e.questions.map(x=>t.jsxs("div",{className:"timeline-question-section rounded-xl border p-2.5 sm:p-3",children:[t.jsx("p",{className:"timeline-meta-text text-xs uppercase tracking-[0.2em]",children:x.header}),t.jsx("p",{className:"timeline-primary-text mt-1 text-[13px] leading-5 sm:text-sm",children:x.question}),e.kind==="planDecision"&&x.options&&x.options.length>0?t.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:x.options.map((j,y)=>{const b=f(j.label),v=b.displayLabel.toLowerCase()==="implement";return t.jsxs("button",{type:"button",disabled:r,onClick:()=>p(j.label),className:`relative rounded-2xl border px-2.5 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${y===0?"ui-action-info":"border-stone-700 text-stone-200 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:j.description,children:[b.recommended?t.jsx("span",{"aria-hidden":"true",className:"absolute right-1.5 top-1 inline-flex h-3.5 w-3.5 items-center justify-center rounded-full bg-white/18 text-[10px] leading-none text-current",children:"✦"}):null,r&&i===j.label?v?"Starting...":"Saving...":b.displayLabel]},j.label)})}):x.options&&x.options.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[x.options.map(j=>{const y=f(j.label),b=a[x.id];return t.jsxs("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?w(x.id,j.label):s(v=>({...v,[x.id]:j.label})),className:`relative rounded-2xl border px-3 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${(x.multiSelect?Array.isArray(b)&&b.includes(j.label):b===j.label)?"ui-status-warning":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:j.description,children:[y.recommended?t.jsx("span",{"aria-hidden":"true",className:"absolute right-1.5 top-1 inline-flex h-3.5 w-3.5 items-center justify-center rounded-full bg-white/10 text-[10px] leading-none text-amber-100/90",children:"✦"}):null,y.displayLabel]},j.label)}),x.isOther&&(()=>{const j=a[x.id];return t.jsx("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?w(x.id,u):s(y=>({...y,[x.id]:u})),className:`rounded-2xl border px-3 py-1.5 text-[12px] leading-4 transition sm:text-[13px] ${(x.multiSelect?Array.isArray(j)&&j.includes(u):j===u)?"ui-status-info":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Not from above"})})()]}),x.isOther&&(()=>{const j=a[x.id];return(x.multiSelect?Array.isArray(j)&&j.includes(u):j===u)?t.jsx("input",{"aria-label":`${x.header} custom answer`,value:o[x.id]??"",onChange:b=>l(v=>({...v,[x.id]:b.target.value})),placeholder:"Enter a custom answer",className:"mt-3 w-full rounded-xl border border-stone-700 bg-stone-900 px-3 py-2 text-sm text-stone-100 outline-none transition focus:border-sky-300"}):null})()]}):t.jsx("input",{"aria-label":x.header,value:a[x.id]??"",onChange:j=>s(y=>({...y,[x.id]:j.target.value})),className:"mt-3 w-full rounded-xl border border-stone-700 bg-stone-900 px-3 py-2 text-sm text-stone-100 outline-none transition focus:border-amber-300"})]},x.id))}),e.kind!=="planDecision"&&t.jsx("div",{className:"mt-3 flex justify-end",children:t.jsx("button",{type:"button",disabled:r||e.questions.some(x=>!g(x)),onClick:()=>void(n==null?void 0:n(e.id,{answers:Object.fromEntries(e.questions.map(x=>[x.id,{answers:k(x)}]))})),className:"ui-action-info rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:r?"Submitting...":"Submit"})})]})}function yl({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 jl({note:e,onOpenThread:r,onOpenLinkedThread:n}){const a=e.kind==="forkCreated"?"Fork":e.kind==="forkSource"?"Fork source":e.kind==="goal"?"Goal":"System",s=e.kind==="forkCreated"?`Thread forked from Turn ${e.turnIndex??"?"}`:e.kind==="forkSource"?`Forked from ${e.linkedThreadTitle??"source thread"} at Turn ${e.turnIndex??"?"}`:e.text??"";return t.jsxs("div",{className:"timeline-activity-card w-full rounded-2xl border px-3 py-2.5",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("p",{className:"timeline-meta-text text-[11px] uppercase tracking-[0.2em]",children:a}),t.jsx("time",{dateTime:e.createdAt,title:Ut(e.createdAt),className:"timeline-meta-text text-[10px]",children:kt(e.createdAt)})]}),t.jsx("p",{className:"timeline-primary-text mt-1 text-[13px] leading-5",children:s}),e.linkedThreadId?t.jsx("button",{type:"button",onClick:()=>{const o=e.linkedThreadId;o&&(n==null||n(o),r==null||r(o))},className:"relative z-10 mt-2 inline-flex cursor-pointer rounded-full border border-amber-300/30 px-3 py-1.5 text-xs text-amber-100 transition hover:bg-amber-300/10",children:e.kind==="forkCreated"?"Open fork":"Back to source"}):null]})}function xr({notes:e,onOpenThread:r,onOpenLinkedThread:n}){return e.length===0?null:t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:e.map(a=>t.jsx(jl,{note:a,onOpenThread:r,onOpenLinkedThread:n},a.id))})}function ea({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(yl,{note:a.note},a.id):t.jsx(wl,{request:a.request,busy:r===a.request.id,onRespond:n},a.id))})}function gf({notes:e,requests:r,respondingRequestId:n,onRespondToRequest:a}){const s=[...e.map(o=>({kind:"note",id:o.id,createdAt:o.createdAt??"",note:o})),...r.map(o=>({kind:"request",id:o.id,createdAt:o.createdAt,request:o}))].sort((o,l)=>o.createdAt.localeCompare(l.createdAt));return t.jsx(ea,{entries:s,respondingRequestId:n,onRespondToRequest:a})}function xf({entries:e,respondingRequestId:r,onRespondToRequest:n,onOpenThread:a,onOpenLinkedThread:s}){return e.length===0?null:t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:[...e].sort((o,l)=>o.createdAt.localeCompare(l.createdAt)).map(o=>o.kind==="activity"?t.jsx(jl,{note:o.note,onOpenThread:a,onOpenLinkedThread:s},o.id):o.kind==="note"?t.jsx(yl,{note:o.note},o.id):t.jsx(wl,{request:o.request,busy:r===o.request.id,onRespond:n},o.id))})}function bf({entries:e,expandedGroups:r,onToggleGroupedItem:n,renderCommandGroup:a,renderFileChangeGroup:s,renderFileReadGroup:o,renderItem:l,renderSearchGroup:i,renderToolCallGroup:d,renderAgentActivityGroup:h}){return t.jsx(t.Fragment,{children:e.map(u=>{const m=r[u.key]??!1,f=()=>n(u.key);return u.kind==="commandGroup"?a(u,m,f):u.kind==="fileChangeGroup"?s(u,m,f):u.kind==="searchGroup"?i(u,m,f):u.kind==="fileReadGroup"?o(u,m,f):u.kind==="toolCallGroup"||u.kind==="agentToolCallGroup"||u.kind==="skillToolCallGroup"?d(u,m,f):u.kind==="agentActivityGroup"?h(u,m,f):l(u)})})}function hr({children:e,className:r,count:n,countBadgeClassName:a,desktopIconClassName:s,expanded:o,expandedListClassName:l,icon:i,onToggleExpanded:d,runningIndicator:h,summary:u,timeMeta:m,toggleAriaLabel:f,trailingSummary:p}){return t.jsx("div",{className:`thread-graph-history-group ${r} relative min-w-0 w-full overflow-hidden rounded-[0.9rem] border px-3 py-2.5`,children:t.jsxs("div",{className:"flex items-start gap-2.5",children:[t.jsxs("div",{className:"thread-graph-history-group-icon mt-0.5 flex shrink-0 items-center",children:[t.jsxs("span",{className:`relative inline-flex h-8 w-8 items-center justify-center rounded-[0.9rem] border shadow-sm shadow-stone-950/20 ${s}`,children:[i,t.jsx("span",{className:`absolute -right-1 -top-1 inline-flex min-w-[1.1rem] items-center justify-center rounded-full border bg-stone-950/90 px-1 text-[9px] font-semibold leading-4 ${a}`,children:n})]}),h]}),t.jsxs("div",{className:"thread-graph-history-group-card min-w-0 flex-1 rounded-[0.85rem] border px-3 py-2",children:[t.jsxs("button",{type:"button","aria-expanded":o,"aria-label":f,onClick:d,className:"thread-graph-history-group-toggle flex w-full min-w-0 items-center justify-between gap-3 text-left",children:[t.jsx("div",{className:"thread-graph-history-group-summary min-w-0 flex flex-1 flex-wrap items-center gap-2 pr-1",children:u}),p||m?t.jsxs("div",{className:"inline-flex shrink-0 items-center gap-2",children:[p,m]}):null]}),o?t.jsx("div",{className:`thread-graph-history-group-list mt-3 space-y-2 border-t pt-3 ${l}`,children:e}):null]})]})})}Pr();Pt();var vf=Er("inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden whitespace-nowrap rounded-md border px-2 py-0.5 text-xs font-medium outline-none transition-[color,box-shadow] focus-visible:ring-[3px] [&>svg]:pointer-events-none [&>svg]:size-3",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-white",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function dn({asChild:e=!1,className:r,variant:n,...a}){const s=e?Us:"span";return t.jsx(s,{"data-slot":"badge",className:at(vf({variant:n,className:r})),...a})}function cn(e){if(!e)return!1;const r=e.trim().toLowerCase();return r==="running"||r==="in_progress"||r==="in progress"||r==="pending"}function kf(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.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 wf(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.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 yf(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.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 jf(){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 Nf(e){const r=e.trim();if(!r)return"";const n=r.match(/(, \+\d+ more.*)$/),a=(n==null?void 0:n[1])??"",o=(a?r.slice(0,-a.length):r).replace(/\\/g,"/");if(!o.startsWith("/"))return`${o.replace(/^\.\//,"")}${a}`;const l=["/apps/","/packages/","/src/","/test/","/tests/","/docs/","/config/","/scripts/","/e2e/","/.agents/","/.codex/"];for(const i of l){const d=o.indexOf(i);if(d>=0)return`${o.slice(d+1)}${a}`}return r}function Nl(e,r=42){const n=Nf(e);if(!n)return"";const a=n.match(/(, \+\d+ more.*)$/),s=(a==null?void 0:a[1])??"",o=s?n.slice(0,-s.length):n;if(o.length<=r)return`${o}${s}`;const i=o.replace(/\\/g,"/").split("/").filter(Boolean);if(i.length>1){const d=[];let h=s.length+4;for(let u=i.length-1;u>=0;u-=1){const m=i[u],f=h+m.length+(d.length>0?1:0);if(d.length>0&&f>r)break;d.unshift(m),h=f}if(d.length>0)return`.../${d.join("/")}${s}`}return`...${o.slice(-(r-s.length-3))}${s}`}function Cf(e){var a;const r=[];if(typeof e.changedFiles=="number"&&e.changedFiles>0&&r.push(`${e.changedFiles} ${e.changedFiles===1?"file":"files"}`),typeof e.addedLines=="number"&&e.addedLines>0&&r.push(`+${e.addedLines}`),typeof e.removedLines=="number"&&e.removedLines>0&&r.push(`-${e.removedLines}`),r.length>0)return r;const n=(a=e.previewText)==null?void 0:a.trim();return n?n.replace(/\bfiles changed\b/gi,"files").replace(/\bfile changed\b/gi,"file").split("·").map(s=>s.trim()).filter(Boolean):[]}function Jr({tone:e="amber"}){const r=e==="emerald"?"bg-sky-200/90":e==="sky"?"bg-sky-300/90":"bg-amber-200/90";return t.jsx("span",{className:"ml-1.5 inline-flex items-center gap-1","aria-hidden":"true",children:[0,1,2].map(n=>t.jsx("span",{className:`h-1.5 w-1.5 animate-pulse rounded-full ${r}`,style:{animationDelay:`${n*180}ms`}},n))})}function Sf(e){var n;const r=e.replace(/\r\n/g,`
|
|
3699
3699
|
`).split(`
|
|
3700
|
-
`);for(;r.length>1&&((n=r.at(-1))==null?void 0:n.trim())==="";)r.pop();return r}function ft(e){const r=wf(e);return r.length===1?{firstLine:r[0]??"",showGap:!1,isTruncated:!1}:{firstLine:r[0]??"",showGap:!0,isTruncated:!0}}function jl(e){const r=(e==null?void 0:e.trim().toLowerCase())??"";return r==="completed"||r==="complete"||r==="success"||r==="succeeded"?{className:"is-completed",icon:t.jsx($.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"}:r==="failed"||r==="failure"||r==="error"||r==="errored"?{className:"is-failed",icon:t.jsx($.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"}:cn(e)?{className:"is-pending",icon:t.jsx($.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),label:(e==null?void 0:e.trim())||"Running"}:{className:"is-neutral",icon:null,label:(e==null?void 0:e.trim())||"Event"}}function yf(e){switch(e){case"command":return"is-command";case"tool":return"is-tool";case"agent":return"is-agent";case"skill":return"is-skill";case"search":return"is-search";case"fileRead":return"is-file-read"}}function jf(e){switch(e){case"plan":return"is-plan";case"context":return"is-context";case"generic":return"is-generic";case"image":return"is-image";case"fileChange":return"is-file-change";case"artifact":return"is-artifact";case"hook":return"is-hook"}}function Kt({actions:e,children:r,className:n,headerMeta:a,icon:s,item:o,timeMeta:l,title:i,tone:d}){const h=jl(o.status);return t.jsxs("div",{className:`thread-graph-event thread-graph-history-event ${jf(d)} ${n??""}`,children:[t.jsx("div",{className:"thread-graph-history-event-icon","aria-hidden":"true",children:s}),t.jsxs("div",{className:"thread-graph-history-event-card",children:[t.jsxs("div",{className:"thread-graph-history-event-header",children:[t.jsxs("div",{className:"thread-graph-history-event-heading flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-event-title min-w-0 truncate font-mono text-sm font-semibold",children:i}),o.status?t.jsxs(dn,{variant:"outline",className:`thread-graph-tool-badge ${h.className} rounded-full px-2 py-0.5 text-xs font-normal`,title:h.label,"aria-label":`Status: ${h.label}`,children:[h.icon,t.jsx("span",{className:"thread-graph-status-label",children:h.label})]}):null,a]}),e||l?t.jsxs("div",{className:"thread-graph-history-event-actions",children:[e,l]}):null]}),r?t.jsx("div",{className:"thread-graph-history-event-body",children:r}):null]})]})}function ur({actionLabel:e="Open details",actionTitle:r,autoOpen:n=!1,className:a,details:s,icon:o,item:l,onOpen:i,preview:d,timeMeta:h,title:u,tone:m}){const f=jl(l.status),[p,g]=c.useState(n?"item-1":void 0),k=c.useRef(n);return c.useLayoutEffect(()=>{n?g("item-1"):k.current&&g(void 0),k.current=n},[n,l.id]),t.jsx("div",{className:`thread-graph-event thread-graph-history-tool ${yf(m)} ${a??""}`,children:t.jsx(Lr,{type:"single",collapsible:!0,onValueChange:w=>{g(w||void 0)},className:"thread-graph-tool-accordion thread-graph-history-tool-accordion w-full overflow-hidden rounded-lg border",value:p??"",children:t.jsxs(Ir,{value:"item-1",className:"border-0",children:[t.jsxs(on,{"aria-label":`${p==="item-1"?"Collapse":"Expand"} ${u} history item`,className:"thread-graph-tool-trigger thread-graph-history-tool-trigger px-4 py-3 hover:no-underline",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-tool-icon shrink-0",children:o}),t.jsx("span",{className:"min-w-0 truncate font-mono text-sm font-semibold",children:u}),t.jsxs(dn,{variant:"outline",className:`thread-graph-tool-badge ${f.className} ml-1 sm:ml-2 rounded-full px-2 py-0.5 text-xs font-normal`,title:f.label,"aria-label":`Status: ${f.label}`,children:[f.icon,t.jsx("span",{className:"thread-graph-status-label",children:f.label})]})]}),h?t.jsx("span",{className:"thread-graph-history-tool-time shrink-0",children:h}):null]}),t.jsxs(zr,{className:"thread-graph-tool-content thread-graph-history-tool-content px-4 pb-4 pt-1",children:[t.jsxs("section",{children:[t.jsx("h4",{children:"Summary"}),t.jsxs("div",{className:"thread-graph-history-tool-summary",children:[t.jsx(ir,{text:d.firstLine}),d.showGap?t.jsx("span",{className:"thread-graph-history-tool-ellipsis",children:"..."}):null]})]}),s?t.jsx("section",{children:s}):null,t.jsxs("button",{type:"button","aria-label":e,onClick:i,className:"thread-graph-history-tool-open inline-flex items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium transition",children:[t.jsx($.ExternalLink,{className:"h-3.5 w-3.5"}),r]})]})]})})})}var Nf=c.memo(function({item:r,scrollRootRef:n,onBeforeResize:a,timeMeta:s}){return t.jsx(Kt,{className:"thread-graph-event-plan",icon:t.jsx($.ClipboardList,{className:"h-4 w-4"}),item:r,timeMeta:s,title:"plan",tone:"plan",children:t.jsx("div",{className:"thread-graph-history-event-prose",children:t.jsx(fl,{text:r.text,scrollRootRef:n,plainTextClassName:"thread-graph-plain-text whitespace-pre-wrap break-words text-sm leading-6",markdownClassName:"thread-graph-markdown text-sm",...a?{onBeforeResize:a}:{}})})})}),Cf=c.memo(function({item:r,timeMeta:n}){const a=cn(r.status)||r.text==="Compacting context",s=a?"Compacting context":"Context compacted",o=r.detailText&&r.detailText!==s?r.detailText:null;return t.jsxs(Kt,{className:"thread-graph-event-context",icon:t.jsx($.Archive,{className:"h-4 w-4"}),item:r,timeMeta:n,title:"context",tone:"context",children:[t.jsxs("div",{className:"thread-graph-history-event-line",children:[t.jsx("span",{className:"thread-graph-history-event-primary",children:s}),a?t.jsx(Jr,{tone:"emerald"}):null]}),o?t.jsx("p",{className:"thread-graph-history-event-secondary",title:o,children:o}):null]})}),Sf=c.memo(function({item:r,timeMeta:n}){return t.jsx(Kt,{className:"thread-graph-event-generic",icon:t.jsx($.Info,{className:"h-4 w-4"}),item:r,timeMeta:n,title:r.kind,tone:"generic",children:t.jsx("pre",{className:"thread-graph-history-event-pre",children:t.jsx(ir,{text:r.text})})})}),Tf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:s}){const o=ft(n.previewText??n.text);return t.jsx(ur,{actionLabel:"Open full command",actionTitle:"Command Output",autoOpen:r,className:"thread-graph-event-command",icon:t.jsx($.Terminal,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Command Output"),preview:o,timeMeta:s,title:"command",tone:"command"})}),Ef=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:s}){const o=ft(n.text);return t.jsx(ur,{actionLabel:"Open full tool call",actionTitle:"Tool Call Details",autoOpen:r,className:"thread-graph-event-tool",icon:t.jsx($.Wrench,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Tool Call Details"),preview:o,timeMeta:s,title:"tool_call",tone:"tool"})}),Lf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:s}){const o=ft(n.text);return t.jsx(ur,{actionLabel:"Open agent details",actionTitle:"Agent Details",autoOpen:r,className:"thread-graph-event-agent-tool",icon:t.jsx($.Bot,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Agent Details"),preview:o,timeMeta:s,title:"agent",tone:"agent"})}),If=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:s}){const o=ft(n.text);return t.jsx(ur,{actionLabel:"Open skill details",actionTitle:"Skill Details",autoOpen:r,className:"thread-graph-event-skill-tool",icon:t.jsx($.Sparkles,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Skill Details"),preview:o,timeMeta:s,title:"skill",tone:"skill"})}),zf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:s}){var d,h;const o=((d=n.previewText)==null?void 0:d.trim())||n.text||"Web search",l=((h=n.detailText)==null?void 0:h.trim())||n.text||"Web search",i=ft(o);return t.jsx(ur,{actionLabel:"Open full web search",actionTitle:"Web Search Details",autoOpen:r,className:"thread-graph-event-search",icon:t.jsx($.Search,{className:"h-4 w-4"}),item:n,onOpen:()=>a("Web Search Details",l),preview:i,timeMeta:s,title:"web_search",tone:"search"})}),Pf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:s}){var d,h;const o=((d=n.previewText)==null?void 0:d.trim())||n.text||"File read",l=((h=n.detailText)==null?void 0:h.trim())||n.text||"File read",i=ft(o);return t.jsx(ur,{actionLabel:"Open full file read",actionTitle:"File Read Details",autoOpen:r,className:"thread-graph-event-file-read",icon:t.jsx($.FileText,{className:"h-4 w-4"}),item:n,onOpen:()=>a("File Read Details",l),preview:i,timeMeta:s,title:"file_read",tone:"fileRead"})}),Rf=c.memo(function({threadId:r,item:n,onOpen:a,getImageAssetUrl:s,timeMeta:o}){const l=n.assetPath??n.detailText??null,i=r&&l?(s==null?void 0:s({threadId:r,path:l}))??null:null;return t.jsxs(Kt,{className:"thread-graph-event-image",icon:t.jsx($.Image,{className:"h-4 w-4"}),item:n,timeMeta:o,title:"image",tone:"image",children:[i?t.jsx("button",{type:"button",onClick:()=>a("Image Path",l??n.text),className:"block w-full text-left",children:t.jsx("img",{src:i,alt:n.text||"Image preview",className:"thread-graph-history-event-image",loading:"lazy"})}):t.jsx("div",{className:"thread-graph-history-event-summary",children:n.text}),l?t.jsx("button",{type:"button",onClick:()=>a("Image Path",l),className:"thread-graph-history-event-path",title:l,children:l}):null]})}),Af=c.memo(function({item:r,onOpen:n,timeMeta:a}){var m,f,p;const s=(m=r.previewText)!=null&&m.trim()&&r.text.trim()!==r.previewText.trim()?r.text.trim():null,o=((f=r.detailText)==null?void 0:f.trim())||null,l=yl(s??((p=r.previewText)==null?void 0:p.trim())??r.text,48),i=kf(r),d=!!(o||r.hasDeferredDetail),h=t.jsxs("div",{className:"thread-graph-event-line thread-graph-file-change-inline flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip text-sm",title:s??l,children:l}),i.length>0&&t.jsx("div",{className:"inline-flex shrink-0 items-center justify-end gap-1.5 text-xs",children:i.map(g=>t.jsx("span",{className:`thread-graph-history-delta-badge ${g.startsWith("+")?"is-add":g.startsWith("-")?"is-remove":"is-neutral"}`,children:g},g))})]}),u=d?t.jsx("button",{type:"button","aria-label":"Open file change details",onClick:()=>n("File Change Details",o??r.text),className:"thread-graph-file-change-inline-button min-w-0 flex-1 text-left",title:s??l,children:h}):h;return t.jsx(Kt,{className:"thread-graph-event-file-change",headerMeta:u,icon:t.jsx($.FilePenLine,{className:"h-4 w-4"}),item:r,timeMeta:a,title:"file_change",tone:"fileChange"})}),Mf=c.memo(function({item:r,onSelect:n,timeMeta:a}){const s=ua(),[o,l]=c.useState(!1),i=r.artifact,d=i?s.renderArtifact({artifact:i,expanded:o,onToggleExpanded:()=>l(h=>!h)}):null;return t.jsx(Kt,{actions:t.jsxs("span",{className:"inline-flex items-center gap-2",children:[i&&!s.hasRendererForArtifact(i)?t.jsx("span",{className:"thread-graph-history-event-secondary",children:"No renderer"}):null,i&&n?t.jsxs("button",{type:"button","aria-label":`Open artifact inspector for ${i.title}`,onClick:()=>n(r,i),className:"thread-graph-history-event-action",children:[t.jsx($.PackageOpen,{className:"h-3.5 w-3.5"}),"Inspect"]}):null]}),className:"thread-graph-event-artifact",icon:t.jsx($.PackageOpen,{className:"h-4 w-4"}),item:r,timeMeta:a,title:(i==null?void 0:i.type)??"artifact",tone:"artifact",children:d??t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:()=>l(h=>!h),className:"thread-graph-history-event-summary is-clickable flex w-full items-center justify-between gap-3 text-left",children:[t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"thread-graph-history-event-primary block truncate",children:(i==null?void 0:i.title)??r.text}),t.jsx("span",{className:"thread-graph-history-event-secondary mt-1 block truncate",children:(i==null?void 0:i.summaryText)??r.previewText??r.text})]}),t.jsx("span",{className:"thread-graph-history-event-pill",children:o?"Hide":"Open"})]}),o?t.jsx("pre",{className:"thread-graph-history-event-pre max-h-80 overflow-auto",children:JSON.stringify((i==null?void 0:i.payload)??r,null,2)}):null]})})}),$f=c.memo(function({item:r,timeMeta:n}){var h,u;const a=((h=r.hookOutputEntries)==null?void 0:h.map(m=>m.text.trim()).filter(Boolean).join(`
|
|
3701
|
-
`).trim())??"",s=r.hookEventLabel?`${r.hookEventLabel} hook`:r.text,o=((u=r.hookStatusMessage)==null?void 0:u.trim())||(r.previewText&&r.previewText!==r.hookStatusMessage?r.previewText.trim():"")||r.text.trim(),i=ft(a||(o&&o!==s?o:s)),d=!!(a&&i.showGap);return t.jsx(Kt,{className:"thread-graph-event-hook",icon:t.jsx($.Webhook,{className:"h-4 w-4"}),item:r,timeMeta:n,title:r.hookEventLabel?`${r.hookEventLabel}_hook`:"hook",tone:"hook",children:t.jsxs("div",{className:"thread-graph-history-event-line",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:a?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"thread-graph-history-event-secondary mr-2 font-sans text-[11px] uppercase",children:s}),t.jsx(ir,{text:i.firstLine})]}):t.jsx(ir,{text:i.firstLine&&i.firstLine!==s?`${s} · ${i.firstLine}`:s})}),d?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})})}),_f=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s,timeMeta:o}){const l=r.filter(d=>cn(d.status)).length,i=r.length===1?"1 command":`${r.length} commands`;return t.jsx(hr,{className:"thread-graph-history-group-command",count:r.length,countBadgeClassName:"border-amber-200/35 text-amber-100",desktopIconClassName:"border-amber-300/30 bg-amber-300/[0.14] text-amber-100",expanded:n,expandedListClassName:"border-amber-300/12",icon:t.jsx(xf,{}),onToggleExpanded:a,runningIndicator:l>0?t.jsx(Jr,{}):null,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-amber-300/28 bg-amber-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-amber-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:i}),l>0?t.jsx("span",{className:"inline-flex items-center text-xs text-amber-100/90",children:t.jsx(Jr,{})}):null]}),timeMeta:o,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} command entries`,children:r.map((d,h)=>{const u=ft(d.text);return t.jsxs("button",{type:"button","aria-label":`Open grouped command ${h+1}`,onClick:()=>s(d,`Command Output ${h+1}`),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"rounded-full border border-amber-300/18 bg-amber-300/[0.07] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-amber-100",children:["Step ",h+1]}),d.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:d.status})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2 text-sm leading-6",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:u.firstLine}),u.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},d.id)})})}),Df=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s,timeMeta:o}){var u;const l=r.filter(m=>cn(m.status)).length,i=((u=r[0])==null?void 0:u.kind)??"toolCall",d=i==="agentToolCall"?"agent action":i==="skillToolCall"?"skill call":"tool call",h=r.length===1?`1 ${d}`:`${r.length} ${d}s`;return t.jsx(hr,{className:"thread-graph-history-group-tool",count:r.length,countBadgeClassName:"border-teal-200/35 text-teal-100",desktopIconClassName:"border-teal-300/30 bg-teal-300/[0.14] text-teal-100",expanded:n,expandedListClassName:"border-teal-300/12",icon:i==="agentToolCall"?t.jsx($.Bot,{className:"h-3.5 w-3.5"}):t.jsx($.Wrench,{className:"h-3.5 w-3.5"}),onToggleExpanded:a,runningIndicator:l>0?t.jsx(Jr,{}):null,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-teal-300/28 bg-teal-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-teal-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:h})]}),timeMeta:o,toggleAriaLabel:`${n?"Collapse":"Expand"} ${h}`,children:r.map((m,f)=>{const p=ft(m.text);return t.jsx("button",{type:"button","aria-label":`Open ${d} ${f+1}`,onClick:()=>s(m,`${d} ${f+1}`),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:t.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-sm leading-6",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:p.firstLine}),m.status?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-xs",children:m.status}):null]})},m.id)})})}),Bf=c.memo(function({itemCount:r,expanded:n,onToggleExpanded:a,timeMeta:s,children:o}){const l=r===1?"1 operation":`${r} operations`;return t.jsx(hr,{className:"thread-graph-history-group-activity",count:r,countBadgeClassName:"border-slate-200/35 text-slate-100",desktopIconClassName:"border-slate-300/30 bg-slate-300/[0.14] text-slate-100",expanded:n,expandedListClassName:"border-slate-300/12",icon:t.jsx($.Bot,{className:"h-3.5 w-3.5"}),onToggleExpanded:a,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-sm font-medium text-stone-100",children:"Agent activity"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:l})]}),timeMeta:s,toggleAriaLabel:`${n?"Collapse":"Expand"} ${l}`,children:o})}),Gf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s,timeMeta:o}){const l=r.length===1?"1 search":`${r.length} searches`;return t.jsx(hr,{className:"thread-graph-history-group-search",count:r.length,countBadgeClassName:"border-sky-200/35 text-sky-100",desktopIconClassName:"border-sky-300/30 bg-sky-300/[0.14] text-sky-100",expanded:n,expandedListClassName:"border-sky-300/12",icon:t.jsx(bf,{}),onToggleExpanded:a,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-sky-300/28 bg-sky-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-sky-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:l})]}),timeMeta:o,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} web search entries`,children:r.map((i,d)=>{var f,p;const h=((f=i.previewText)==null?void 0:f.trim())||i.text||"Web search",u=ft(h),m=((p=i.detailText)==null?void 0:p.trim())||i.text||"Web search";return t.jsxs("button",{type:"button","aria-label":`Open grouped web search ${d+1}`,onClick:()=>s(`Web Search ${d+1}`,m),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"rounded-full border border-sky-300/18 bg-sky-300/[0.07] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-sky-100",children:["Search ",d+1]}),i.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:i.status})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2 text-sm leading-6",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:u.firstLine}),u.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},i.id)})})}),Ff=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s,timeMeta:o}){const l=r.length===1?"1 file read":`${r.length} file reads`;return t.jsx(hr,{className:"thread-graph-history-group-file-read",count:r.length,countBadgeClassName:"border-cyan-200/35 text-cyan-100",desktopIconClassName:"border-cyan-300/30 bg-cyan-300/[0.14] text-cyan-100",expanded:n,expandedListClassName:"border-cyan-300/12",icon:t.jsx(gf,{}),onToggleExpanded:a,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-cyan-300/28 bg-cyan-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-cyan-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:l})]}),timeMeta:o,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} file read entries`,children:r.map((i,d)=>{var f,p;const h=((f=i.previewText)==null?void 0:f.trim())||i.text||"File read",u=ft(h),m=((p=i.detailText)==null?void 0:p.trim())||i.text||"File read";return t.jsxs("button",{type:"button","aria-label":`Open grouped file read ${d+1}`,onClick:()=>s(`File Read ${d+1}`,m),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"rounded-full border border-cyan-300/18 bg-cyan-300/[0.07] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-cyan-100",children:["Read ",d+1]}),i.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:i.status})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2 text-sm leading-6",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:u.firstLine}),u.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},i.id)})})}),Hf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s,timeMeta:o}){const l=r.reduce((u,m)=>u+(m.changedFiles??0),0),i=r.reduce((u,m)=>u+(m.addedLines??0),0),d=r.reduce((u,m)=>u+(m.removedLines??0),0),h=r.length===1?"1 file change":`${r.length} file changes`;return t.jsx(hr,{className:"thread-graph-history-group-file-change",count:r.length,countBadgeClassName:"border-lime-200/35 text-lime-100",desktopIconClassName:"border-lime-300/30 bg-lime-300/[0.14] text-lime-100",expanded:n,expandedListClassName:"border-lime-300/12",icon:t.jsx(ff,{}),onToggleExpanded:a,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-lime-300/28 bg-lime-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-lime-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:h}),l>0?t.jsxs("span",{className:"thread-graph-history-detail-meta text-xs",children:[l," files"]}):null]}),timeMeta:o,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} file change entries`,trailingSummary:t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[i>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-add",children:["+",i]}):null,d>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-remove",children:["-",d]}):null]}),children:r.map((u,m)=>{var g,k,w,x;const f=((g=u.detailText)==null?void 0:g.trim())||((k=u.previewText)==null?void 0:k.trim())||u.text,p=(w=u.previewText)!=null&&w.trim()&&u.text.trim()!==u.previewText.trim()?u.text.trim():((x=u.previewText)==null?void 0:x.trim())||u.text;return t.jsx("button",{type:"button","aria-label":`Open grouped file change ${m+1}`,onClick:()=>s(`File Change ${m+1}`,f),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-detail-text min-w-0 flex-1 text-sm leading-6",title:p,children:yl(p,34)}),t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[(u.addedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-add",children:["+",u.addedLines]}):null,(u.removedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-remove",children:["-",u.removedLines]}):null]})]})},u.id)})})});function Of(e){const r=e.trim().toLowerCase();return r==="completed"||r==="done"||r==="complete"?"completed":r==="in_progress"||r==="in-progress"||r==="running"||r==="active"?"in_progress":r==="failed"||r==="error"||r==="cancelled"?"failed":r==="pending"||r==="todo"?"pending":"unknown"}function Wf({status:e}){const r=Of(e),n=r==="completed"?"Plan step status: Completed":r==="in_progress"?"Plan step status: In progress":r==="pending"?"Plan step status: Pending":r==="failed"?"Plan step status: Failed":`Plan step status: ${e}`,a=r==="completed"?"thread-graph-plan-status is-completed":r==="in_progress"?"thread-graph-plan-status is-running":r==="pending"?"thread-graph-plan-status is-pending":r==="failed"?"thread-graph-plan-status is-failed":"thread-graph-plan-status is-unknown";return t.jsx(dn,{"aria-label":n,title:n.replace("Plan step status: ",""),className:a,children:r==="completed"?t.jsx($.CheckCircle2,{className:"h-3.5 w-3.5"}):r==="in_progress"?t.jsx($.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):r==="pending"?t.jsx($.Clock3,{className:"h-3.5 w-3.5"}):r==="failed"?t.jsx($.XCircle,{className:"h-3.5 w-3.5"}):t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.14em]",children:"?"})})}function Uf({livePlan:e}){return t.jsxs("div",{className:"thread-graph-plan-card rounded-xl border px-3 py-3",children:[t.jsxs("div",{className:"thread-graph-plan-header flex flex-wrap items-center justify-between gap-2",children:[t.jsx("p",{className:"text-sm font-semibold",children:"Plan update"}),t.jsx(dn,{className:"thread-graph-plan-badge",children:"Live"})]}),e.explanation?t.jsx("p",{className:"thread-graph-plan-explanation mt-3 text-sm",children:e.explanation}):null,t.jsx("div",{className:"mt-3 space-y-2",children:e.plan.map((r,n)=>t.jsxs("div",{className:"thread-graph-plan-step flex items-center justify-between gap-3 rounded-lg border px-3 py-2 text-sm",children:[t.jsx("span",{className:"thread-graph-plan-step-text min-w-0 flex-1",children:r.step}),t.jsx(Wf,{status:r.status})]},`${e.turnId}-${n}`))})]})}function Vf({footer:e,history:r,liveHookPrompt:n,liveOutput:a,livePlan:s}){return t.jsxs(t.Fragment,{children:[r,s?t.jsx(Uf,{livePlan:s}):null,n??a??null,e]})}function qf({absoluteIndex:e,body:r,collapsed:n,collapsedBody:a,error:s,footer:o,headerStatus:l,isActive:i=!1,refCallback:d,startedAt:h,timeLabel:u,timeTitle:m,tokenSummary:f}){return t.jsxs("article",{ref:d,"data-testid":"chat-turn","data-turn-active":i?"true":"false",className:"thread-graph-turn px-3 py-2 sm:px-5 sm:py-3",children:[t.jsx("div",{className:"thread-graph-turn-header flex items-start justify-between gap-2",children:t.jsxs("div",{className:"min-w-0 flex flex-1 items-start gap-1.5",children:[t.jsxs("div",{className:"min-w-0 flex flex-1 items-center gap-1.5 overflow-hidden",children:[t.jsxs("span",{className:"thread-graph-turn-index rounded-[0.6rem] border px-1.5 py-0.5 text-[10px] uppercase tracking-[0.16em]",children:["Turn ",e]}),t.jsx("time",{dateTime:h??void 0,title:m,className:"thread-graph-turn-time shrink-0 text-[10px] sm:text-[11px]",children:u}),l,s?t.jsx("p",{className:"hidden truncate text-[11px] text-rose-200 sm:block",children:s}):null]}),f]})}),s?t.jsx("p",{className:"mt-1 text-[11px] text-rose-200 sm:hidden",children:s}):null,t.jsxs("div",{className:"thread-graph-turn-body mt-2 space-y-2",children:[n?a:r,n?null:o]})]})}function Kf(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M8 2.75v8"}),t.jsx("path",{d:"m4.75 7.5 3.25 3.25L11.25 7.5"})]})}function Xf(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M8 13.25v-8"}),t.jsx("path",{d:"m11.25 8.5-3.25-3.25L4.75 8.5"})]})}function Is(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.45",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M3.25 5.25 8 2.75l4.75 2.5L8 7.75l-4.75-2.5Z"}),t.jsx("path",{d:"M3.25 8 8 10.5 12.75 8"}),t.jsx("path",{d:"M3.25 10.75 8 13.25l4.75-2.5"}),t.jsx("path",{d:"M3.25 5.25v5.5"}),t.jsx("path",{d:"M12.75 5.25v5.5"})]})}function Yf(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.45",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M6.2 3.2a2.3 2.3 0 0 0-2.95 3.5A2.4 2.4 0 0 0 4.5 11h.2c.25 1.1 1.1 1.8 2.3 1.8h1.8c1.2 0 2.05-.7 2.3-1.8h.2A2.4 2.4 0 0 0 12.75 6.7 2.3 2.3 0 0 0 9.8 3.2"}),t.jsx("path",{d:"M6.3 6.15c.45-.42 1.02-.65 1.7-.65s1.25.23 1.7.65"}),t.jsx("path",{d:"M8 5.5v4.75"}),t.jsx("path",{d:"M6.75 9.05 8 10.25l1.25-1.2"})]})}function br(e){if(!Number.isFinite(e)||e<=0)return"0";if(e>=1e6){const r=e>=1e7?Math.round(e/1e6):e/1e6;return`${String(r.toFixed(1)).replace(/\.0$/,"")}m`}if(e>=1e3){const r=e>=1e4?Math.round(e/1e3):e/1e3;return`${String(r.toFixed(1)).replace(/\.0$/,"")}k`}return String(Math.round(e))}function Nl(e){return!Number.isFinite(e)||e<=0?"$0":e>=100?`$${Math.round(e)}`:e>=10?`$${String(e.toFixed(1)).replace(/\.0$/,"")}`:e>=1?`$${String(e.toFixed(2)).replace(/0$/,"").replace(/\.$/,"")}`:e>=.1?`$${e.toFixed(2)}`:e>=.01?`$${e.toFixed(3)}`:e>=.001?`$${e.toFixed(4)}`:"<$0.001"}function ar(e){return!Number.isFinite(e)||e<=0?"$0.0000":`$${e.toFixed(4)}`}function Br(e,r,n){const a=e??null;return!Number.isFinite(a??NaN)||a===null||r<=0||n<=0?null:a*n/r}function Cl(e){var d,h,u,m,f,p;const r=(d=e.tokenUsage)==null?void 0:d.total;if(!r)return[];const n=Math.max(r.inputTokens-r.cachedInputTokens-(r.cacheWriteInputTokens??0),0),a=Math.max(r.cachedInputTokens,0),s=Math.max(r.cacheWriteInputTokens??0,0),o=Math.max(r.reasoningOutputTokens,0),l=Math.max(r.outputTokens-o,0);return[n>0?{id:"in",label:"Input",tokenCompactValue:br(n),tokenRawValue:n,usdCompactValue:e.priceEstimate?ar(e.priceEstimate.inputUsd):"--",usdRawValue:((h=e.priceEstimate)==null?void 0:h.inputUsd)??null,className:"token-badge-in",icon:t.jsx(Kf,{})}:null,a>0?{id:"cache",label:"Cached input",tokenCompactValue:br(a),tokenRawValue:a,usdCompactValue:e.priceEstimate?ar(e.priceEstimate.cachedInputUsd):"--",usdRawValue:((u=e.priceEstimate)==null?void 0:u.cachedInputUsd)??null,className:"token-badge-cache",icon:t.jsx(Is,{})}:null,s>0?{id:"cache-write",label:"Cache write",tokenCompactValue:br(s),tokenRawValue:s,usdCompactValue:e.priceEstimate?ar(e.priceEstimate.cacheWriteInputUsd??0):"--",usdRawValue:((m=e.priceEstimate)==null?void 0:m.cacheWriteInputUsd)??null,className:"token-badge-cache",icon:t.jsx(Is,{})}:null,l>0?{id:"out",label:"Output",tokenCompactValue:br(l),tokenRawValue:l,usdCompactValue:e.priceEstimate?ar(Br(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),l)??0):"--",usdRawValue:Br((f=e.priceEstimate)==null?void 0:f.outputUsd,Math.max(r.outputTokens,0),l),className:"token-badge-out",icon:t.jsx(Xf,{})}:null,o>0?{id:"reason",label:"Reasoning",tokenCompactValue:br(o),tokenRawValue:o,usdCompactValue:e.priceEstimate?ar(Br(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),o)??0):"--",usdRawValue:Br((p=e.priceEstimate)==null?void 0:p.outputUsd,Math.max(r.outputTokens,0),o),className:"token-badge-reason",icon:t.jsx(Yf,{})}:null].filter(g=>g!==null)}function Zf(e){return Cl(e).map(r=>({id:r.id,label:r.tokenCompactValue,title:`${r.label}: ${r.tokenRawValue} tokens`,className:r.className,icon:r.icon}))}function Sl(e){return{label:e.priceEstimate?Nl(e.priceEstimate.totalUsd):"--",title:e.priceEstimate===null||e.priceEstimate===void 0?"Price estimate unavailable for this model.":`Estimated cost: ${ar(e.priceEstimate.totalUsd)}`,className:e.priceEstimate?"token-badge-total":"token-badge-empty"}}var Ln="inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-normal leading-none sm:text-[11px]";function Jf({turn:e}){const r=Cl(e),n=Sl(e),[a,s]=c.useState(!1),[o,l]=c.useState(!1),[i,d]=c.useState(0),h=c.useRef(null),u=c.useRef(null),m=c.useRef(null);if(c.useLayoutEffect(()=>{if(!a||r.length===0){d(0);return}const p=()=>{const g=h.current,k=m.current;if(!g||!k)return;const w=g.getBoundingClientRect(),x=k.offsetWidth||k.getBoundingClientRect().width;if(x<=0)return;const j=window.innerWidth||document.documentElement.clientWidth,y=12,b=w.left+w.width/2-x/2,v=y,S=Math.max(v,j-y-x),N=Math.min(Math.max(b,v),S);d(Math.round(N-b))};return p(),window.addEventListener("resize",p),()=>{window.removeEventListener("resize",p)}},[r.length,a]),c.useEffect(()=>{if(!a&&!o)return;const p=g=>{g.target instanceof Node&&(h.current&&!h.current.contains(g.target)&&s(!1),u.current&&!u.current.contains(g.target)&&l(!1))};return document.addEventListener("pointerdown",p),()=>{document.removeEventListener("pointerdown",p)}},[o,a]),!n&&r.length===0)return null;const f=()=>t.jsx("div",{className:"thread-token-popover min-w-[12rem] rounded-2xl border p-2.5 shadow-2xl shadow-black/20 backdrop-blur",children:t.jsx("div",{className:"space-y-1",children:r.map(p=>t.jsxs("div",{className:"thread-token-popover-row flex items-center justify-between gap-3 rounded-xl border px-2.5 py-1.5 text-[11px]",title:`${p.label}: ${p.tokenRawValue} tokens`,children:[t.jsxs("span",{className:"thread-token-popover-text inline-flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"inline-flex shrink-0",children:p.icon}),t.jsx("span",{className:"thread-token-popover-strong font-medium",children:p.usdCompactValue})]}),t.jsx("span",{className:"thread-token-popover-text shrink-0 font-medium",children:p.tokenCompactValue})]},p.id))})});return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"hidden shrink-0 items-center gap-1.5 md:inline-flex",children:[n?t.jsxs("div",{ref:u,className:"relative shrink-0",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[t.jsx("button",{type:"button","aria-label":"Show token and price details","aria-expanded":o,onFocus:()=>l(!0),onBlur:()=>l(!1),className:`${Ln} appearance-none whitespace-nowrap bg-transparent !text-[10px] !font-normal !leading-none transition hover:bg-[var(--theme-hover)] sm:!text-[11px] ${n.className}`,title:n.title,children:n.label}),o&&r.length>0?t.jsx("div",{className:"absolute left-1/2 top-full z-30 mt-1.5 -translate-x-1/2",children:f()}):null]}):null,r.map(p=>t.jsxs("span",{className:`${Ln} ${p.className}`,title:`${p.label}: ${p.usdCompactValue}, ${p.tokenRawValue} tokens`,children:[p.icon,t.jsx("span",{className:"thread-token-badge-value font-medium",children:p.tokenCompactValue})]},p.id))]}),t.jsxs("div",{ref:h,className:"relative shrink-0 md:hidden",children:[n?t.jsx("button",{type:"button","aria-label":"Show token and price details","aria-expanded":a,onClick:()=>s(p=>!p),className:`${Ln} appearance-none whitespace-nowrap bg-transparent !text-[10px] !font-normal !leading-none transition hover:bg-[var(--theme-hover)] sm:!text-[11px] ${n.className}`,title:n.title,children:n.label}):null,a&&r.length>0?t.jsx("div",{ref:m,className:"absolute left-1/2 top-full z-30 mt-1.5",style:{transform:`translateX(${i}px) translateX(-50%)`},children:f()}):null]})]})}function Qf({tone:e="amber"}){const r=e==="emerald"?"bg-sky-200/90":e==="sky"?"bg-sky-300/90":"bg-amber-200/90";return t.jsx("span",{className:"ml-1.5 inline-flex items-center gap-1","aria-hidden":"true",children:[0,1,2].map(n=>t.jsx("span",{className:`h-1.5 w-1.5 rounded-full animate-pulse ${r}`,style:{animationDelay:`${n*180}ms`}},n))})}function zs(e){const r=e.trim().toLowerCase();return r==="completed"||r==="done"||r==="complete"?"completed":r==="in_progress"||r==="in progress"||r==="inprogress"||r==="running"||r==="active"?"in_progress":r==="pending"||r==="todo"||r==="not_started"||r==="not started"||r==="queued"?"pending":r==="failed"||r==="error"?"failed":"other"}function eg(e){switch(e.kind){case"fileChange":case"webSearch":case"image":case"contextCompaction":return!0;case"commandExecution":case"toolCall":return!ma(e.status);default:return!1}}function tg(e,r,n){if(!e||!yr(n))return e;const a=e.plan.findIndex(i=>zs(i.status)==="in_progress");if(a<0)return e;const s=e.plan.findIndex((i,d)=>d>a&&zs(i.status)==="pending");if(s<0||!r.some(i=>eg(i)))return e;const l=e.plan.map((i,d)=>d===a?{...i,status:"completed"}:d===s?{...i,status:"in_progress"}:i);return{...e,plan:l}}function rg(e){var a;const r=(a=e.model)!=null&&a.trim()?e.model.trim():"--";let n="--";return e.reasoningEffortAvailable===null||e.reasoningEffortAvailable===void 0?n="--":e.reasoningEffortAvailable===!1?n="-":n=e.reasoningEffort??"--",[r,n].join(" · ")}function Ps({status:e}){const r=hl(e);return e==="completed"?t.jsx("span",{"aria-label":r,title:r,className:"timeline-status-icon timeline-status-icon-success inline-flex h-4 w-4 items-center justify-center",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m3.75 8.25 2.5 2.5 6-6"})})}):e==="failed"?t.jsx("span",{"aria-label":r,title:r,className:"timeline-status-icon timeline-status-icon-failed inline-flex h-4 w-4 items-center justify-center",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m5 5 6 6M11 5l-6 6"})})}):e==="interrupted"?t.jsx("span",{"aria-label":r,title:r,className:"timeline-status-icon timeline-status-icon-warning inline-flex h-4 w-4 items-center justify-center",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M6 4.5v7M10 4.5v7"})})}):t.jsx("span",{"aria-label":r,title:r,className:"inline-flex min-w-[1.25rem] items-center justify-center text-sky-200",children:t.jsx(Qf,{tone:"emerald"})})}function Rs({turn:e,variant:r="header"}){const n=hl(e.status),a=rg(e),s=Zf(e),o=Sl(e),l=yr(e.status),i=e.status==="failed"?"border-rose-300/20 bg-rose-300/[0.06] text-rose-100":l?"border-sky-300/22 bg-sky-300/[0.08] text-sky-100":"border-stone-700/90 bg-stone-900/70 text-stone-200";if(r==="footer")return t.jsxs("div",{className:`flex w-full flex-col gap-1.5 rounded-[0.95rem] border px-3 py-2 text-xs ${i}`,children:[t.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Ps,{status:e.status}),t.jsx("span",{className:"timeline-soft-text min-w-0 truncate",children:a})]}),e.startedAt&&t.jsx("time",{dateTime:e.startedAt,title:Ut(e.startedAt),className:"timeline-meta-text shrink-0 text-[11px]",children:kt(e.startedAt)})]}),(o||s.length>0)&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 pl-6",children:[o?t.jsx("span",{className:`inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${o.className}`,title:o.title,children:o.label}):null,s.map(h=>t.jsxs("span",{className:`inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${h.className}`,title:h.title,children:[h.icon?t.jsx("span",{className:"mr-1",children:h.icon}):null,h.label]},h.id))]})]});const d=`${n} · ${a}`;return t.jsxs("span",{className:`inline-flex min-w-0 items-center gap-1.5 rounded-full border px-2 py-1 text-[10px] sm:text-[11px] ${i}`,title:d,children:[t.jsx(Ps,{status:e.status}),t.jsx("span",{className:"timeline-meta-text min-w-0 truncate",children:a})]})}function ng(e,r){return e.createdAt??r}var pa=c.memo(function({threadId:r,item:n,scrollRootRef:a,onOpenExpandedText:s,onOpenCommandDetail:o,onOpenToolCallDetail:l,onOpenDeferredHistoryItemDetail:i,onSelectArtifact:d,onBeforeMessageResize:h,adapter:u,timeLabel:m,timeTitle:f,timeMeta:p,autoOpenToolDetails:g=!1}){var k,w,x;if(Zp(n.kind))return t.jsx(It,{threadId:r,item:n,scrollRootRef:a,timeLabel:m,timeTitle:f,...h?{onBeforeMessageResize:h}:{},...u?{adapter:u}:{}});if(n.kind==="reasoning")return t.jsx(It,{item:{...n,kind:"agentMessage",status:n.status??null},scrollRootRef:a,timeLabel:m,timeTitle:f,...h?{onBeforeMessageResize:h}:{}});if(n.kind==="artifact")return t.jsx(Mf,{item:n,timeMeta:p,...d?{onSelect:(j,y)=>d({item:j,artifact:y})}:{}});if(n.kind==="commandExecution")return t.jsx(Tf,{autoOpen:g,item:n,onOpen:o,timeMeta:p});if(n.kind==="toolCall")return t.jsx(Ef,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="agentToolCall")return t.jsx(Lf,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="skillToolCall")return t.jsx(If,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="webSearch"){const j=n,y=((k=j.detailText)==null?void 0:k.trim())||j.text||"Web search";return t.jsx(zf,{autoOpen:g,item:j,timeMeta:p,onOpen:()=>i(j,"Web Search Details",y,"Loading full web search details...","Unable to load full web search details.")})}if(n.kind==="fileRead"){const j=n,y=((w=j.detailText)==null?void 0:w.trim())||j.text||"File read";return t.jsx(Pf,{autoOpen:g,item:j,timeMeta:p,onOpen:()=>i(j,"File Read Details",y,"Loading full file read details...","Unable to load full file read details.")})}if(n.kind==="image")return t.jsx(Rf,{threadId:r,item:n,onOpen:s,getImageAssetUrl:u==null?void 0:u.getImageAssetUrl,timeMeta:p});if(n.kind==="plan")return t.jsx(Nf,{item:n,scrollRootRef:a,timeMeta:p,...h?{onBeforeResize:h}:{}});if(n.kind==="fileChange"){const j=n,y=((x=j.detailText)==null?void 0:x.trim())||j.text||"File change";return t.jsx(Af,{item:j,timeMeta:p,onOpen:()=>i(j,"File Change Details",y,"Loading full file change details...","Unable to load full file change details.")})}return n.kind==="contextCompaction"?t.jsx(Cf,{item:n,timeMeta:p}):n.kind==="hook"?t.jsx($f,{item:n,timeMeta:p}):t.jsx(Sf,{item:n,timeMeta:p})});function As(e){return e==="completed"||e==="failed"||e==="interrupted"}function ag(e){const r=Date.parse(e.createdAt??"");return Number.isFinite(r)?r:null}function sg(e){let r=null;for(const n of e){const a=ag(n);a!==null&&(r=r===null?a:Math.max(r,a))}return r}function og(e,r){const n=Date.parse(e??""),a=sg(r);if(!Number.isFinite(n)||a===null||a<n)return"Worked";const s=Math.max(1,Math.round((a-n)/1e3)),o=Math.floor(s/3600),l=Math.floor(s%3600/60),i=s%60;return o>0?`Worked for ${o}h ${l}m`:l>0?`Worked for ${l}m ${i}s`:`Worked for ${i}s`}function lg(e,r){const n=Date.parse(e??""),a=Date.parse(r??"");if(!Number.isFinite(n)||!Number.isFinite(a))return r?kt(r):"Time unavailable";const s=Math.max(0,Math.round((a-n)/1e3)),o=Math.floor(s/3600),l=Math.floor(s%3600/60),i=s%60;return o>0?`${o}h ${l}m`:l>0?`${l}m ${i}s`:`${i}s`}function Nr({absoluteLabel:e,className:r="",timestamp:n,turnStartedAt:a}){const[s,o]=c.useState(!1);if(!n)return null;const l=Ut(n),i=lg(a,n),d=s?e:i;return t.jsx("span",{role:"button",tabIndex:0,className:`thread-graph-relative-time rounded-full px-1.5 py-0.5 ${r}`,title:s?i:l,"aria-label":`Toggle timestamp, currently ${d}`,onClick:h=>{h.stopPropagation(),o(u=>!u)},onKeyDown:h=>{h.key!=="Enter"&&h.key!==" "||(h.preventDefault(),h.stopPropagation(),o(u=>!u))},children:t.jsx("time",{dateTime:n,children:d})})}function Gt(e){var r;return e.kind==="item"?e.item.createdAt??null:e.kind==="agentActivityGroup"?e.entries[0]?Gt(e.entries[0]):null:((r=e.items.find(n=>n.createdAt))==null?void 0:r.createdAt)??null}function ig(e){const r=e.filter(o=>o.kind==="item"),n=r.map(o=>o.item).filter(o=>o.kind==="userMessage"),a=r.map(o=>o.item).reverse().find(o=>o.kind==="agentMessage"&&o.text.trim().length>0),s=e.filter(o=>o.kind!=="item"?!0:o.item.kind!=="userMessage"&&o.item.id!==(a==null?void 0:a.id));return{users:n,finalAgent:a,hiddenEntries:s}}var In=c.memo(function({threadId:r,adapter:n,turn:a,absoluteIndex:s,isCollapsed:o,livePlan:l,liveItems:i,liveOutput:d,forceActive:h=!1,onToggleCollapse:u,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,onSelectArtifact:k,onBeforeMessageResize:w,scrollRootRef:x,articleRef:j,isLatestVisibleTurn:y=!1}){const b=!!l||!!d||!!(i&&i.length>0),v=h||yr(a.status)||b||y,S=v&&!yr(a.status)?{...a,status:"inProgress"}:a,N=c.useMemo(()=>tf(a.items,i),[i,a.items]),L=c.useMemo(()=>tg(l,N,a.status),[l,N,a.status]),R=c.useMemo(()=>rf(d,N),[d,N]),P=c.useMemo(()=>ef(N,v),[v,N]),Q=c.useMemo(()=>nf(P),[P]),D=h||yr(a.status)||b,Z=kt(a.startedAt),J=Ut(a.startedAt),z=c.useMemo(()=>gl(R),[R]),[te,se]=c.useState({}),_=c.useCallback(K=>{se(de=>({...de,[K]:!de[K]}))},[]),ie=t.jsx(Tl,{entries:Q,expandedGroups:te,onToggleGroupedItem:_,threadId:r,scrollRootRef:x,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,...w?{onBeforeMessageResize:w}:{},fallbackTimestamp:a.startedAt,fallbackTimeLabel:Z,fallbackTimeTitle:J,turnStartedAt:a.startedAt,autoOpenLatestToolDetails:D,...k?{onSelectArtifact:k}:{},...n?{adapter:n}:{}}),q=z?t.jsx(pa,{threadId:r,item:z,scrollRootRef:x,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,timeLabel:a.startedAt?t.jsx(Nr,{absoluteLabel:Z,timestamp:a.startedAt,turnStartedAt:a.startedAt}):Z,timeTitle:J,timeMeta:null,...k?{onSelectArtifact:k}:{},...n?{adapter:n}:{}}):null,H=!z&&R?t.jsx(It,{item:{id:"live-agent-message",kind:"agentMessage",text:R},scrollRootRef:x,timeLabel:a.startedAt?t.jsx(Nr,{absoluteLabel:Z,timestamp:a.startedAt,turnStartedAt:a.startedAt}):Z,timeTitle:J,streaming:!0,...w?{onBeforeMessageResize:w}:{}}):null,G=v?t.jsx(Rs,{turn:S,variant:"footer"}):null,T=c.useMemo(()=>ig(Q),[Q]),F=c.useMemo(()=>og(a.startedAt,N),[N,a.startedAt]),B=T.hiddenEntries.length>0,E=o&&B,W=As(a.status)&&B&&!E?t.jsxs("button",{type:"button",className:"thread-graph-worked-summary group flex w-full items-center gap-2 py-2 text-left text-sm transition",onClick:()=>u(a.id,!1),"aria-label":`${F}. Collapse turn ${s}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:F}),t.jsx($.ChevronDown,{className:"h-4 w-4 shrink-0 transition group-hover:translate-y-0.5"}),t.jsx("span",{className:"thread-graph-worked-rule h-px min-w-0 flex-1","aria-hidden":"true"})]}):null,U=As(a.status)&&B?t.jsxs("div",{className:"thread-graph-turn-collapsed-summary space-y-2",children:[T.users.map(K=>t.jsx(It,{threadId:r,item:K,scrollRootRef:x,timeLabel:K.createdAt?kt(K.createdAt):Z,timeTitle:K.createdAt?Ut(K.createdAt):J,...w?{onBeforeMessageResize:w}:{},...n?{adapter:n}:{}},K.id)),t.jsxs("button",{type:"button",className:"thread-graph-worked-summary group flex w-full items-center gap-2 py-2 text-left text-sm transition",onClick:()=>u(a.id,!0),"aria-label":`${F}. Expand turn ${s}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:F}),t.jsx($.ChevronRight,{className:"h-4 w-4 shrink-0 transition group-hover:translate-x-0.5"}),t.jsx("span",{className:"thread-graph-worked-rule h-px min-w-0 flex-1","aria-hidden":"true"})]}),T.finalAgent?t.jsx(It,{threadId:r,item:T.finalAgent,scrollRootRef:x,timeLabel:T.finalAgent.createdAt?t.jsx(Nr,{absoluteLabel:kt(T.finalAgent.createdAt),timestamp:T.finalAgent.createdAt,turnStartedAt:a.startedAt}):Z,timeTitle:T.finalAgent.createdAt?Ut(T.finalAgent.createdAt):J,...w?{onBeforeMessageResize:w}:{},...n?{adapter:n}:{}}):null]}):null,ae=t.jsx(Vf,{footer:G,history:t.jsxs(t.Fragment,{children:[W,ie]}),liveHookPrompt:q,liveOutput:H,livePlan:L});return t.jsx(qf,{absoluteIndex:s,body:ae,collapsed:E,collapsedBody:U,error:a.error,headerStatus:t.jsx(Rs,{turn:a}),isActive:v,refCallback:j,startedAt:a.startedAt,timeLabel:Z,timeTitle:J,tokenSummary:t.jsx(Jf,{turn:a})})});function Tl({entries:e,expandedGroups:r,onToggleGroupedItem:n,threadId:a,scrollRootRef:s,onOpenExpandedText:o,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,onSelectArtifact:h,onBeforeMessageResize:u,adapter:m,fallbackTimestamp:f,fallbackTimeLabel:p,fallbackTimeTitle:g,turnStartedAt:k,autoOpenLatestToolDetails:w=!1}){var y;const x=((y=e.at(-1))==null?void 0:y.key)??null,j=c.useCallback(b=>b?t.jsx(Nr,{absoluteLabel:kt(b),timestamp:b,turnStartedAt:k??f}):null,[f,k]);return t.jsx(mf,{entries:e,expandedGroups:r,onToggleGroupedItem:n,renderCommandGroup:(b,v,S)=>t.jsx(_f,{items:b.items,expanded:v,onToggleExpanded:S,onOpen:l,timeMeta:j(Gt(b))},b.key),renderFileChangeGroup:(b,v,S)=>t.jsx(Hf,{items:b.items,expanded:v,onToggleExpanded:S,onOpen:o,timeMeta:j(Gt(b))},b.key),renderSearchGroup:(b,v,S)=>t.jsx(Gf,{items:b.items,expanded:v,onToggleExpanded:S,onOpen:o,timeMeta:j(Gt(b))},b.key),renderFileReadGroup:(b,v,S)=>t.jsx(Ff,{items:b.items,expanded:v,onToggleExpanded:S,onOpen:o,timeMeta:j(Gt(b))},b.key),renderToolCallGroup:(b,v,S)=>t.jsx(Df,{items:b.items,expanded:v,onToggleExpanded:S,onOpen:i,timeMeta:j(Gt(b))},b.key),renderAgentActivityGroup:(b,v,S)=>t.jsx(Bf,{itemCount:b.itemCount,expanded:v,onToggleExpanded:S,timeMeta:j(Gt(b.entries[0])),children:t.jsx(Tl,{entries:b.entries,expandedGroups:r,onToggleGroupedItem:n,threadId:a,scrollRootRef:s,onOpenExpandedText:o,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,...u?{onBeforeMessageResize:u}:{},fallbackTimestamp:f,fallbackTimeLabel:p,fallbackTimeTitle:g,turnStartedAt:k,autoOpenLatestToolDetails:!1,...h?{onSelectArtifact:h}:{},...m?{adapter:m}:{}})},b.key),renderItem:b=>{const v=ng(b.item,f??null),N=b.item.kind==="userMessage"?b.item.createdAt?kt(v):p:b.item.createdAt?t.jsx(Nr,{absoluteLabel:kt(v),timestamp:v,turnStartedAt:k??f}):p;return t.jsx(pa,{threadId:a,item:b.item,scrollRootRef:s,timeLabel:N,timeTitle:b.item.createdAt?Ut(v):g,timeMeta:j(v),autoOpenToolDetails:w&&b.key===x,onOpenExpandedText:o,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,...u?{onBeforeMessageResize:u}:{},...h?{onSelectArtifact:h}:{},...m?{adapter:m}:{}},b.key)}})}var Ms=3,dg=3,Qn=80;function vr(e,r=Qn){return e.scrollHeight-e.scrollTop-e.clientHeight<=r}function cg(e,r){const n=e.getBoundingClientRect(),a=r.getBoundingClientRect(),s=Math.max(n.top,a.top),o=Math.min(n.bottom,a.bottom);return Math.max(0,o-s)>0}function hg(e){return e.map(n=>{const a=n.createdAt;return typeof a=="string"&&a.trim()?a:null}).filter(n=>!!n).sort()[0]??null}function ug(e,r){return{id:e,startedAt:hg(r),status:"inProgress",error:null,model:null,reasoningEffort:null,reasoningEffortAvailable:null,tokenUsage:null,priceEstimate:null,items:[]}}function $s(e,r,n){return{id:e.id,kind:e.kind,title:r,text:n}}function mg({loadHistoryItemDetail:e,onSelectHistoryItemDetail:r}){const n=c.useRef(0),a=c.useRef(new Map),[s,o]=c.useState(null),l=c.useCallback((p,g)=>{o({title:p,text:g})},[]),i=c.useCallback((p,g,k)=>{if(k&&r){r({item:p,detail:g});return}o({title:g.title,text:g.text})},[r]),d=c.useCallback(async({item:p,fallbackTitle:g,fallbackText:k,loadingText:w,errorText:x,useSelectionCallback:j})=>{if(!p.hasDeferredDetail||!e){i(p,$s(p,g,k),j);return}const y=a.current.get(p.id);if(y){i(p,y,j);return}const b=n.current+1;n.current=b,j&&r||o({title:g,text:w});try{const v=await e(p.id);if(a.current.set(p.id,v),n.current!==b)return;i(p,v,j)}catch(v){if(n.current!==b)return;i(p,$s(p,g,v instanceof Error?v.message:x),j)}},[e,r,i]),h=c.useCallback(async(p,g)=>{var k;await d({item:p,fallbackTitle:g,fallbackText:((k=p.detailText)==null?void 0:k.trim())||p.text||"Command output",loadingText:"Loading full command output...",errorText:"Unable to load full command output.",useSelectionCallback:!0})},[d]),u=c.useCallback(async(p,g)=>{var k;await d({item:p,fallbackTitle:g,fallbackText:((k=p.detailText)==null?void 0:k.trim())||p.text||"Tool call",loadingText:"Loading full tool call details...",errorText:"Unable to load full tool call details.",useSelectionCallback:!0})},[d]),m=c.useCallback(async(p,g,k,w,x)=>{await d({item:p,fallbackTitle:g,fallbackText:k,loadingText:w,errorText:x,useSelectionCallback:!1})},[d]),f=c.useCallback(()=>{n.current+=1,o(null)},[]);return{expandedText:s,openExpandedText:l,openCommandDetail:h,openToolCallDetail:u,openDeferredHistoryItemDetail:m,closeExpandedText:f}}function pg(e){const r=c.useRef(null),n=c.useRef(0),a=r.current;return(a===null||a.length!==e.length||e.some((o,l)=>!Object.is(o,a[l])))&&(n.current+=1,r.current=e),n.current}function fg({threadId:e,turnsLength:r,totalTurnCount:n,loadingEarlier:a,onLoadEarlier:s,scrollRequestKey:o,bottomSpacer:l,onTailVisibilityChange:i,contentRevisionInputs:d}){const h=c.useRef(null),u=c.useRef(null),m=c.useRef(o),f=c.useRef(null),p=c.useRef(l),g=c.useRef(0),k=c.useRef(0),w=c.useRef(null),x=c.useRef(null),j=c.useRef(null),y=c.useRef(!0),b=c.useRef(!0),v=c.useRef(!1),S=c.useRef(!1),N=c.useRef(!1),L=c.useRef(!1),R=c.useRef(null),P=c.useRef(0),[Q,D]=c.useState(Ms),[Z,J]=c.useState(0),[z,te]=c.useState(!0),se=pg(d),_=typeof s=="function"||n!==void 0,ie=n??r,q=_?0:Math.max(0,r-Q),G=(_?Math.max(0,ie-r):0)+q,T=_?r:r-q,F=_?0:r-T,B=_?Math.max(0,ie-r):0,E=_?B+F:F,C=!_&&E>0&&Z>=2,W=_&&B>0&&F===0&&typeof s=="function",U=c.useCallback(()=>{const Y=h.current;if(!Y){w.current=null;return}w.current={scrollHeight:Y.scrollHeight,scrollTop:Y.scrollTop}},[]),ae=c.useCallback(()=>!W||a||N.current?!1:(U(),N.current=!0,L.current=!1,P.current=0,s==null||s(),!0),[W,a,s,U]),K=c.useCallback(()=>{const Y=h.current,me=x.current;if(!Y)return;const we=me?cg(Y,me):vr(Y);y.current=we,te(ye=>ye===we?ye:we)},[]),de=c.useCallback(()=>{const Y=h.current;if(Y){S.current=!0;const me=Y.scrollTop,we=k.current,ye=me-we;k.current=me,vr(Y,1)?(v.current=!1,b.current=!0):ye<-1?(v.current=!0,b.current=!1):ye>1&&(b.current=!v.current&&vr(Y,Qn)),me<=0&&S.current?L.current=!0:me>0&&(L.current=!1,P.current=0)}K()},[K]),ee=c.useCallback(()=>{const Y=h.current;Y&&(Y.scrollTop=Y.scrollHeight,k.current=Y.scrollTop,g.current=Y.scrollHeight,y.current=!0,te(me=>me||!0),v.current=!1,b.current=!0)},[]),ke=c.useCallback(()=>{const Y=h.current;Y&&(k.current=Y.scrollTop,g.current=Y.scrollHeight,b.current=!1,v.current=!0)},[]),le=c.useCallback(()=>{if(_&&F===0){ae();return}D(Y=>Math.min(r,Y+dg)),J(Y=>Y+1)},[F,_,ae,r]),je=c.useCallback(Y=>{const me=h.current;if(!(!me||Y.deltaY>=-8||me.scrollTop>0||!W)){if(!L.current){L.current=!0;return}ae()}},[W,ae]),Ae=c.useCallback(Y=>{var me;R.current=((me=Y.touches.item(0))==null?void 0:me.clientY)??null,P.current=0},[]),ce=c.useCallback(Y=>{var Be;const me=h.current,we=((Be=Y.touches.item(0))==null?void 0:Be.clientY)??null,ye=R.current;if(R.current=we,!me||we===null||ye===null||me.scrollTop>0||!W){P.current=0;return}const De=we-ye;if(De<=0){P.current=0;return}if(!L.current){L.current=!0,P.current=0;return}P.current+=De,P.current>=28&&ae()},[W,ae]),ne=c.useCallback(()=>{R.current=null,P.current=0},[]),Le=c.useCallback(()=>{D(r)},[r]);return c.useLayoutEffect(()=>{const Y=window.requestAnimationFrame(()=>{ee()});return()=>{window.cancelAnimationFrame(Y)}},[e,ee]),c.useEffect(()=>{N.current=!1,S.current=!1,L.current=!1,w.current=null},[e]),c.useEffect(()=>{a||(N.current=!1)},[a,r]),c.useLayoutEffect(()=>{const Y=w.current,me=h.current;if(!Y||!me||a)return;w.current=null;const we=me.scrollHeight-Y.scrollHeight;if(we<=0){g.current=me.scrollHeight,k.current=me.scrollTop;return}const ye=Y.scrollTop+we;me.scrollTop=ye,k.current=ye,g.current=me.scrollHeight,v.current=!0,b.current=!1,L.current=!1},[a,r]),c.useEffect(()=>{D(Y=>Y>=r-1?r:Math.max(Y,Ms))},[r]),c.useEffect(()=>{const Y=h.current;Y&&(g.current=Y.scrollHeight,k.current=Y.scrollTop,vr(Y,1)?(v.current=!1,b.current=!0):(v.current||!vr(Y,Qn))&&(b.current=!1)),K()},[se,K,Q]),c.useEffect(()=>{const Y=o!==m.current,me=f.current!==se;if(f.current=se,!(Y||me&&b.current&&!v.current))return;const ye=window.requestAnimationFrame(()=>{ee()});return o!==m.current&&(m.current=o),()=>{window.cancelAnimationFrame(ye)}},[se,z,ee,o]),c.useEffect(()=>{const Y=h.current,me=u.current;if(!Y||!me||typeof ResizeObserver>"u")return;g.current=Y.scrollHeight;const we=new ResizeObserver(()=>{const ye=Y.scrollHeight,De=g.current;if(g.current=ye,ye<=De)return;const Be=De>0&&De-Y.scrollTop-Y.clientHeight<=1;v.current||!(b.current||Be||y.current)||window.requestAnimationFrame(()=>{ee()})});return we.observe(me),()=>{we.disconnect()}},[ee]),c.useEffect(()=>{if(!b.current||v.current){p.current=l;return}if(l===p.current)return;p.current=l;const Y=window.requestAnimationFrame(()=>{ee()});return()=>{window.cancelAnimationFrame(Y)}},[l,ee]),c.useEffect(()=>{i==null||i(z)},[z,i]),{scrollContainerRef:h,scrollContentRef:u,tailSentinelRef:x,topSentinelRef:j,isTailVisible:z,handleScroll:de,handleWheel:je,handleTouchStart:Ae,handleTouchMove:ce,handleTouchEnd:ne,preserveScrollPositionForResize:ke,serverManagedHistory:_,effectiveTotalTurnCount:ie,startIndex:q,visibleTurnAbsoluteOffset:G,hiddenCount:E,loadedHiddenCount:F,unloadedHiddenCount:B,showLoadAll:C,handleLoadEarlierClick:le,handleLoadAllClick:Le}}function gg(e){return e==="completed"||e==="failed"||e==="interrupted"}function xg(e,r){if(!r||r.id!==e.id||r.items.length===0)return e;const n=new Set(e.items.map(s=>s.id)),a=r.items.filter(s=>!n.has(s.id));return a.length===0?e:{...e,items:[...a,...e.items]}}function bg({threadId:e,turns:r,totalTurnCount:n,pendingRequests:a=[],activeTurnId:s=null,threadRunning:o=!1,pendingSteers:l=[],livePlan:i=null,liveItems:d=null,respondingRequestId:h=null,onRespondToRequest:u,liveOutput:m,scrollRequestKey:f=0,previousTurnScrollRequestKey:p=0,nextTurnScrollRequestKey:g=0,bottomSpacer:k=0,className:w="",onTailVisibilityChange:x,onPreviousTurnAvailabilityChange:j,onNextTurnAvailabilityChange:y,loadingEarlier:b=!1,onLoadEarlier:v,ephemeralUserNote:S=null,answeredRequestNotes:N=[],activityNotes:L=[],optimisticSteers:R=[],optimisticTurn:P=null,onLoadHistoryItemDetail:Q,onOpenThread:D,onSelectArtifact:Z,onSelectHistoryItemDetail:J,adapter:z,autoCollapseCompletedTurns:te}){var st,ct,xt,Rt,wt;const se=cl(),_=te??(se==null?void 0:se.autoCollapseCompletedTurns)??!1,[ie,q]=c.useState({}),[H,G]=c.useState(()=>new Set),T=c.useRef(null),F=c.useRef(null),B=(z==null?void 0:z.onLoadHistoryItemDetail)??Q,E=z==null?void 0:z.onOpenLinkedThread,{expandedText:C,openExpandedText:W,openCommandDetail:U,openToolCallDetail:ae,openDeferredHistoryItemDetail:K,closeExpandedText:de}=mg({loadHistoryItemDetail:B,onSelectHistoryItemDetail:J}),{scrollContainerRef:ee,scrollContentRef:ke,tailSentinelRef:le,topSentinelRef:je,handleScroll:Ae,handleWheel:ce,handleTouchStart:ne,handleTouchMove:Le,handleTouchEnd:Y,preserveScrollPositionForResize:me,serverManagedHistory:we,effectiveTotalTurnCount:ye,startIndex:De,visibleTurnAbsoluteOffset:Be,hiddenCount:_e,loadedHiddenCount:Oe,unloadedHiddenCount:V,showLoadAll:he,handleLoadEarlierClick:ve,handleLoadAllClick:I}=fg({threadId:e,turnsLength:r.length,totalTurnCount:n,loadingEarlier:b,onLoadEarlier:v,scrollRequestKey:f,bottomSpacer:k,onTailVisibilityChange:x,contentRevisionInputs:[r,a,l,R,m,i,d,P,N,L,S,k]}),O=c.useCallback((M,fe)=>{q(ze=>({...ze,[M]:!fe}))},[]),oe=c.useCallback((M,fe)=>{const ze=ie[M.id];return ze!==void 0?ze:!!(_&&gg(M.status)&&!fe.forceActive&&!fe.hasLiveActivity)},[ie,_]),ge=we?r:r.slice(De),Ne=ye+1,Ce=o&&(!s||!ge.some(M=>M.id===s)&&(P==null?void 0:P.id)!==s),xe=(P==null?void 0:P.id)??((st=ge.at(-1))==null?void 0:st.id)??null,Ge=Ce&&xe!==null,Me=!!d&&(ge.some(M=>M.id===d.turnId)||(P==null?void 0:P.id)===d.turnId),Qe=d&&Me?d.turnId:d&&Ge?xe:null,et=P&&Qe===P.id?(d==null?void 0:d.items)??null:null,it=((d==null?void 0:d.items.length)??0)>0,tt=d&&Qe===null?d.items:null,Ke=c.useMemo(()=>d&&Qe===null&&d.items.length>0?ug(d.turnId,d.items):null,[d,Qe]),dt=Math.max(1,ye+(P?1:0)),gt=!!m&&!!P&&P.status!=="failed"&&!et,Ve=m&&ge.length>0?s&&ge.some(M=>M.id===s)?s:((ct=ge.findLast(M=>ma(M.status)))==null?void 0:ct.id)??(Ge?xe:null):null,A=!!Ve,X=c.useMemo(()=>gl(m),[m]),be=[...l.map(M=>({id:M.id,prompt:M.prompt,status:"Accepted",createdAt:M.createdAt,canCancel:!0})),...R.map(M=>({id:M.id,prompt:M.prompt,status:M.status==="steering"?"Steering":null,createdAt:M.createdAt,canCancel:!1}))].sort((M,fe)=>M.createdAt.localeCompare(fe.createdAt)),Se=c.useMemo(()=>df({answeredRequestNotes:N,pendingRequests:a,visibleTurns:ge,optimisticTurn:P}),[N,P,a,ge]),Pe=c.useMemo(()=>cf({activityNotes:L,visibleTurns:ge,optimisticTurn:P}),[L,P,ge]),rt=c.useCallback(()=>{const M=ee.current;if(!M)return null;const fe=M.getBoundingClientRect().top;return Array.from(M.querySelectorAll("[data-timeline-turn]")).find(ze=>ze.getBoundingClientRect().top>fe+8)??null},[ee]),nt=c.useCallback(()=>{const M=ee.current;if(!M)return null;const fe=M.getBoundingClientRect().top;return Array.from(M.querySelectorAll("[data-timeline-turn]")).findLast(ze=>ze.getBoundingClientRect().top<fe-8)??null},[ee]),$e=c.useCallback(()=>{j==null||j(!!nt())},[nt,j]),We=c.useCallback(()=>{y==null||y(!!rt())},[rt,y]),ut=c.useCallback(()=>{Ae(),$e(),We()},[Ae,We,$e]);return c.useEffect(()=>{$e(),We()},[We,$e,ge]),c.useEffect(()=>{if(p===0)return;const M=ee.current,fe=nt(),ze=M?Array.from(M.querySelectorAll("[data-timeline-turn]")):[],Fe=fe?ze.indexOf(fe):-1,Ue=fe&&fe.dataset.turnId===T.current?ze[Fe-1]??null:fe;if(!M||!Ue)return;T.current=Ue.dataset.turnId??null;const mt=Ue.getBoundingClientRect().top-M.getBoundingClientRect().top;M.scrollTo({top:M.scrollTop+mt-8,behavior:"smooth"}),ze.indexOf(Ue)===0&&(j==null||j(!1))},[nt,j,p,ee]),c.useEffect(()=>{if(g===0)return;const M=ee.current,fe=rt(),ze=M?Array.from(M.querySelectorAll("[data-timeline-turn]")):[],Fe=fe?ze.indexOf(fe):-1,Ue=fe&&fe.dataset.turnId===F.current?ze[Fe+1]??null:fe;if(!M||!Ue)return;F.current=Ue.dataset.turnId??null;const mt=Ue.getBoundingClientRect().top-M.getBoundingClientRect().top;M.scrollTo({top:M.scrollTop+mt-8,behavior:"smooth"}),ze.indexOf(Ue)===ze.length-1&&(y==null||y(!1))},[rt,g,y,ee]),t.jsxs(t.Fragment,{children:[t.jsx("section",{className:`flex min-h-0 flex-1 flex-col ${w}`.trim(),children:t.jsx("div",{ref:ee,"data-testid":"thread-scroll-container",onScroll:ut,onWheel:ce,onTouchStart:ne,onTouchMove:Le,onTouchEnd:Y,onTouchCancel:Y,className:"thread-graph-scroll-container min-h-0 flex-1 overflow-y-auto overscroll-contain",style:k>0?{paddingBottom:k}:void 0,children:t.jsxs("div",{ref:ke,className:"thread-graph-scroll-content",children:[t.jsx("div",{ref:je,"aria-hidden":"true",className:"h-px"}),r.length>0&&t.jsx("div",{className:"thread-graph-history-control px-3 pb-1 pt-2 sm:px-5 sm:pb-1.5 sm:pt-3",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 text-xs sm:text-sm",children:[_e>0&&t.jsx("button",{type:"button",onClick:ve,disabled:b,className:"thread-graph-history-button rounded-full border px-2.5 py-1.5 transition",children:b?"Loading earlier...":"Load 3 earlier"}),he&&t.jsx("button",{type:"button",onClick:I,className:"rounded-full border border-amber-300/40 px-2.5 py-1.5 text-amber-200 transition hover:bg-amber-300/10",children:"Load full history"}),t.jsxs("p",{className:"timeline-meta-text",children:["Showing ",ge.length," of ",ye," turns",_e>0?` · ${_e} earlier hidden${Oe>0&&V>0?` (${Oe} loaded)`:""}`:""]})]})}),r.length===0&&!m&&!P&&t.jsx("div",{className:"thread-graph-empty-state px-3 py-8 text-sm sm:px-5",children:"Send the first prompt to start the thread."}),(ge.length>0||P||Pe.leading.length>0||Pe.trailing.length>0)&&t.jsxs("div",{className:"thread-graph-message-list",children:[Pe.leading.length>0?t.jsx(xr,{notes:Pe.leading,onOpenThread:D,onOpenLinkedThread:E}):null,ge.map((M,fe)=>{var ze,Fe,Ue,mt,yt;return t.jsxs("div",{"data-timeline-turn":!0,"data-turn-id":M.id,children:[(((ze=Pe.beforeTurnId.get(M.id))==null?void 0:ze.length)??0)>0?t.jsx(xr,{notes:Pe.beforeTurnId.get(M.id)??[],onOpenThread:D,onOpenLinkedThread:E}):null,(((Fe=Se.beforeTurnId.get(M.id))==null?void 0:Fe.length)??0)>0?t.jsx(Jn,{entries:Se.beforeTurnId.get(M.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const Xt=xg(M,P),Yt=(i==null?void 0:i.turnId)===M.id?i:null,At=Qe===M.id?(d==null?void 0:d.items)??null:null,mr=Ve===M.id?m:"",ot=s===M.id||Ge&&xe===M.id,un=!!Yt||!!mr||!!(At&&At.length>0),mn=oe(Xt,{forceActive:ot,hasLiveActivity:un});return t.jsx(In,{threadId:e,...z?{adapter:z}:{},turn:Xt,absoluteIndex:Be+fe+1,isCollapsed:mn,livePlan:Yt,liveItems:At,liveOutput:mr,forceActive:ot,onToggleCollapse:O,onOpenExpandedText:W,onOpenCommandDetail:U,onOpenToolCallDetail:ae,onOpenDeferredHistoryItemDetail:K,onBeforeMessageResize:me,...Z?{onSelectArtifact:Z}:{},scrollRootRef:ee,articleRef:void 0})})(),(((Ue=Pe.afterTurnId.get(M.id))==null?void 0:Ue.length)??0)>0?t.jsx(xr,{notes:Pe.afterTurnId.get(M.id)??[],onOpenThread:D,onOpenLinkedThread:E}):null,(mt=Se.notesByTurnId.get(M.id))!=null&&mt.length||(yt=Se.pendingRequestsByTurnId.get(M.id))!=null&&yt.length?t.jsx(hf,{notes:Se.notesByTurnId.get(M.id)??[],requests:Se.pendingRequestsByTurnId.get(M.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null]},M.id)}),P&&ge.every(M=>M.id!==P.id)&&t.jsxs(t.Fragment,{children:[(((xt=Pe.beforeTurnId.get(P.id))==null?void 0:xt.length)??0)>0?t.jsx(xr,{notes:Pe.beforeTurnId.get(P.id)??[],onOpenThread:D,onOpenLinkedThread:E}):null,(((Rt=Se.beforeTurnId.get(P.id))==null?void 0:Rt.length)??0)>0?t.jsx(Jn,{entries:Se.beforeTurnId.get(P.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const M=gt?m:"",fe=s===P.id||Ge&&xe===P.id,ze=!!(et&&et.length>0)||!!M,Fe=oe(P,{forceActive:fe,hasLiveActivity:ze});return t.jsx(In,{threadId:e,...z?{adapter:z}:{},turn:P,absoluteIndex:Ne,isCollapsed:Fe,livePlan:null,liveItems:et,liveOutput:M,forceActive:fe,onToggleCollapse:O,onOpenExpandedText:W,onOpenCommandDetail:U,onOpenToolCallDetail:ae,onOpenDeferredHistoryItemDetail:K,onBeforeMessageResize:me,...Z?{onSelectArtifact:Z}:{},scrollRootRef:ee})})(),(((wt=Pe.afterTurnId.get(P.id))==null?void 0:wt.length)??0)>0?t.jsx(xr,{notes:Pe.afterTurnId.get(P.id)??[],onOpenThread:D,onOpenLinkedThread:E}):null]})]}),be.length>0&&t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:be.map(M=>t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(It,{threadId:e,item:{id:M.id,kind:"userMessage",text:M.prompt,status:M.status},scrollRootRef:ee,onBeforeMessageResize:me,...z?{adapter:z}:{}}),e&&M.canCancel&&(z!=null&&z.cancelPendingSteer)?t.jsx("div",{className:"flex justify-end px-1",children:t.jsx("button",{type:"button",className:"thread-graph-history-button rounded-full border px-2.5 py-1 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",disabled:H.has(M.id),onClick:()=>{var fe;G(ze=>new Set(ze).add(M.id)),Promise.resolve((fe=z.cancelPendingSteer)==null?void 0:fe.call(z,e,M.id)).catch(()=>{}).finally(()=>{G(ze=>{const Fe=new Set(ze);return Fe.delete(M.id),Fe})})},children:H.has(M.id)?"Canceling...":"Cancel"})}):null]},M.id))}),(Se.trailing.length>0||Pe.trailing.length>0)&&t.jsx(uf,{entries:[...Pe.trailing.map(M=>({kind:"activity",id:M.id,createdAt:M.createdAt,note:M})),...Se.trailing],respondingRequestId:h,onRespondToRequest:u??void 0,onOpenThread:D,onOpenLinkedThread:E}),S&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:t.jsx(It,{threadId:e,item:{id:"ephemeral-plan-decision-note",kind:"userMessage",text:S},scrollRootRef:ee,onBeforeMessageResize:me})}),Ke&&tt&&tt.length>0&&t.jsx(In,{threadId:e,...z?{adapter:z}:{},turn:Ke,absoluteIndex:dt,isCollapsed:ie[Ke.id]??!1,livePlan:(i==null?void 0:i.turnId)===Ke.id?i:null,liveItems:tt,liveOutput:"",forceActive:!0,onToggleCollapse:O,onOpenExpandedText:W,onOpenCommandDetail:U,onOpenToolCallDetail:ae,onOpenDeferredHistoryItemDetail:K,onBeforeMessageResize:me,...Z?{onSelectArtifact:Z}:{},scrollRootRef:ee}),m&&!A&&!gt&&!it&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:X?t.jsx(pa,{threadId:e,item:X,scrollRootRef:ee,onOpenExpandedText:W,onOpenCommandDetail:U,onOpenToolCallDetail:ae,onOpenDeferredHistoryItemDetail:K,onBeforeMessageResize:me,...Z?{onSelectArtifact:Z}:{},...z?{adapter:z}:{}}):t.jsx(It,{threadId:e,item:{id:"live-agent-message-fallback",kind:"agentMessage",text:m},scrollRootRef:ee,streaming:!0,onBeforeMessageResize:me,...z?{adapter:z}:{}})}),t.jsx("div",{ref:le,"aria-hidden":"true",className:"h-px w-full"})]})})}),t.jsx(wp,{open:C!==null,title:(C==null?void 0:C.title)??"Full text",text:(C==null?void 0:C.text)??"",onClose:de})]})}var El=c.memo(bg);function vg(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}function ea(e){return e.replace(/\r\n/g,`
|
|
3702
|
-
`)}function
|
|
3700
|
+
`);for(;r.length>1&&((n=r.at(-1))==null?void 0:n.trim())==="";)r.pop();return r}function ft(e){const r=Sf(e);return r.length===1?{firstLine:r[0]??"",showGap:!1,isTruncated:!1}:{firstLine:r[0]??"",showGap:!0,isTruncated:!0}}function Cl(e){const r=(e==null?void 0:e.trim().toLowerCase())??"";return r==="completed"||r==="complete"||r==="success"||r==="succeeded"?{className:"is-completed",icon:t.jsx(_.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"}:r==="failed"||r==="failure"||r==="error"||r==="errored"?{className:"is-failed",icon:t.jsx(_.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"}:cn(e)?{className:"is-pending",icon:t.jsx(_.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),label:(e==null?void 0:e.trim())||"Running"}:{className:"is-neutral",icon:null,label:(e==null?void 0:e.trim())||"Event"}}function Tf(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 Ef(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 Xt({actions:e,children:r,className:n,headerMeta:a,icon:s,item:o,timeMeta:l,title:i,tone:d}){const h=Cl(o.status);return t.jsxs("div",{className:`thread-graph-event thread-graph-history-event ${Ef(d)} ${n??""}`,children:[t.jsx("div",{className:"thread-graph-history-event-icon","aria-hidden":"true",children:s}),t.jsxs("div",{className:"thread-graph-history-event-card",children:[t.jsxs("div",{className:"thread-graph-history-event-header",children:[t.jsxs("div",{className:"thread-graph-history-event-heading flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-event-title min-w-0 truncate font-mono text-sm font-semibold",children:i}),o.status?t.jsxs(dn,{variant:"outline",className:`thread-graph-tool-badge ${h.className} rounded-full px-2 py-0.5 text-xs font-normal`,title:h.label,"aria-label":`Status: ${h.label}`,children:[h.icon,t.jsx("span",{className:"thread-graph-status-label",children:h.label})]}):null,a]}),e||l?t.jsxs("div",{className:"thread-graph-history-event-actions",children:[e,l]}):null]}),r?t.jsx("div",{className:"thread-graph-history-event-body",children:r}):null]})]})}function ur({actionLabel:e="Open details",actionTitle:r,autoOpen:n=!1,className:a,details:s,icon:o,item:l,onOpen:i,preview:d,timeMeta:h,title:u,tone:m}){const f=Cl(l.status),[p,g]=c.useState(n?"item-1":void 0),k=c.useRef(n);return c.useLayoutEffect(()=>{n?g("item-1"):k.current&&g(void 0),k.current=n},[n,l.id]),t.jsx("div",{className:`thread-graph-event thread-graph-history-tool ${Tf(m)} ${a??""}`,children:t.jsx(Lr,{type:"single",collapsible:!0,onValueChange:w=>{g(w||void 0)},className:"thread-graph-tool-accordion thread-graph-history-tool-accordion w-full overflow-hidden rounded-lg border",value:p??"",children:t.jsxs(Ir,{value:"item-1",className:"border-0",children:[t.jsxs(on,{"aria-label":`${p==="item-1"?"Collapse":"Expand"} ${u} history item`,className:"thread-graph-tool-trigger thread-graph-history-tool-trigger px-4 py-3 hover:no-underline",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-tool-icon shrink-0",children:o}),t.jsx("span",{className:"min-w-0 truncate font-mono text-sm font-semibold",children:u}),t.jsxs(dn,{variant:"outline",className:`thread-graph-tool-badge ${f.className} ml-1 sm:ml-2 rounded-full px-2 py-0.5 text-xs font-normal`,title:f.label,"aria-label":`Status: ${f.label}`,children:[f.icon,t.jsx("span",{className:"thread-graph-status-label",children:f.label})]})]}),h?t.jsx("span",{className:"thread-graph-history-tool-time shrink-0",children:h}):null]}),t.jsxs(zr,{className:"thread-graph-tool-content thread-graph-history-tool-content px-4 pb-4 pt-1",children:[t.jsxs("section",{children:[t.jsx("h4",{children:"Summary"}),t.jsxs("div",{className:"thread-graph-history-tool-summary",children:[t.jsx(ir,{text:d.firstLine}),d.showGap?t.jsx("span",{className:"thread-graph-history-tool-ellipsis",children:"..."}):null]})]}),s?t.jsx("section",{children:s}):null,t.jsxs("button",{type:"button","aria-label":e,onClick:i,className:"thread-graph-history-tool-open inline-flex items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium transition",children:[t.jsx(_.ExternalLink,{className:"h-3.5 w-3.5"}),r]})]})]})})})}var Lf=c.memo(function({item:r,scrollRootRef:n,onBeforeResize:a,timeMeta:s}){return t.jsx(Xt,{className:"thread-graph-event-plan",icon:t.jsx(_.ClipboardList,{className:"h-4 w-4"}),item:r,timeMeta:s,title:"plan",tone:"plan",children:t.jsx("div",{className:"thread-graph-history-event-prose",children:t.jsx(xl,{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}:{}})})})}),If=c.memo(function({item:r,timeMeta:n}){const a=cn(r.status)||r.text==="Compacting context",s=a?"Compacting context":"Context compacted",o=r.detailText&&r.detailText!==s?r.detailText:null;return t.jsxs(Xt,{className:"thread-graph-event-context",icon:t.jsx(_.Archive,{className:"h-4 w-4"}),item:r,timeMeta:n,title:"context",tone:"context",children:[t.jsxs("div",{className:"thread-graph-history-event-line",children:[t.jsx("span",{className:"thread-graph-history-event-primary",children:s}),a?t.jsx(Jr,{tone:"emerald"}):null]}),o?t.jsx("p",{className:"thread-graph-history-event-secondary",title:o,children:o}):null]})}),zf=c.memo(function({item:r,timeMeta:n}){return t.jsx(Xt,{className:"thread-graph-event-generic",icon:t.jsx(_.Info,{className:"h-4 w-4"}),item:r,timeMeta:n,title:r.kind,tone:"generic",children:t.jsx("pre",{className:"thread-graph-history-event-pre",children:t.jsx(ir,{text:r.text})})})}),Pf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:s}){const o=ft(n.previewText??n.text);return t.jsx(ur,{actionLabel:"Open full command",actionTitle:"Command Output",autoOpen:r,className:"thread-graph-event-command",icon:t.jsx(_.Terminal,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Command Output"),preview:o,timeMeta:s,title:"command",tone:"command"})}),Rf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:s}){const o=ft(n.text);return t.jsx(ur,{actionLabel:"Open full tool call",actionTitle:"Tool Call Details",autoOpen:r,className:"thread-graph-event-tool",icon:t.jsx(_.Wrench,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Tool Call Details"),preview:o,timeMeta:s,title:"tool_call",tone:"tool"})}),Af=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:s}){const o=ft(n.text);return t.jsx(ur,{actionLabel:"Open agent details",actionTitle:"Agent Details",autoOpen:r,className:"thread-graph-event-agent-tool",icon:t.jsx(_.Bot,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Agent Details"),preview:o,timeMeta:s,title:"agent",tone:"agent"})}),Mf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:s}){const o=ft(n.text);return t.jsx(ur,{actionLabel:"Open skill details",actionTitle:"Skill Details",autoOpen:r,className:"thread-graph-event-skill-tool",icon:t.jsx(_.Sparkles,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Skill Details"),preview:o,timeMeta:s,title:"skill",tone:"skill"})}),_f=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:s}){var d,h;const o=((d=n.previewText)==null?void 0:d.trim())||n.text||"Web search",l=((h=n.detailText)==null?void 0:h.trim())||n.text||"Web search",i=ft(o);return t.jsx(ur,{actionLabel:"Open full web search",actionTitle:"Web Search Details",autoOpen:r,className:"thread-graph-event-search",icon:t.jsx(_.Search,{className:"h-4 w-4"}),item:n,onOpen:()=>a("Web Search Details",l),preview:i,timeMeta:s,title:"web_search",tone:"search"})}),$f=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:s}){var d,h;const o=((d=n.previewText)==null?void 0:d.trim())||n.text||"File read",l=((h=n.detailText)==null?void 0:h.trim())||n.text||"File read",i=ft(o);return t.jsx(ur,{actionLabel:"Open full file read",actionTitle:"File Read Details",autoOpen:r,className:"thread-graph-event-file-read",icon:t.jsx(_.FileText,{className:"h-4 w-4"}),item:n,onOpen:()=>a("File Read Details",l),preview:i,timeMeta:s,title:"file_read",tone:"fileRead"})}),Df=c.memo(function({threadId:r,item:n,onOpen:a,getImageAssetUrl:s,timeMeta:o}){const l=n.assetPath??n.detailText??null,i=r&&l?(s==null?void 0:s({threadId:r,path:l}))??null:null;return t.jsxs(Xt,{className:"thread-graph-event-image",icon:t.jsx(_.Image,{className:"h-4 w-4"}),item:n,timeMeta:o,title:"image",tone:"image",children:[i?t.jsx("button",{type:"button",onClick:()=>a("Image Path",l??n.text),className:"block w-full text-left",children:t.jsx("img",{src:i,alt:n.text||"Image preview",className:"thread-graph-history-event-image",loading:"lazy"})}):t.jsx("div",{className:"thread-graph-history-event-summary",children:n.text}),l?t.jsx("button",{type:"button",onClick:()=>a("Image Path",l),className:"thread-graph-history-event-path",title:l,children:l}):null]})}),Bf=c.memo(function({item:r,onOpen:n,timeMeta:a}){var m,f,p;const s=(m=r.previewText)!=null&&m.trim()&&r.text.trim()!==r.previewText.trim()?r.text.trim():null,o=((f=r.detailText)==null?void 0:f.trim())||null,l=Nl(s??((p=r.previewText)==null?void 0:p.trim())??r.text,48),i=Cf(r),d=!!(o||r.hasDeferredDetail),h=t.jsxs("div",{className:"thread-graph-event-line thread-graph-file-change-inline flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip text-sm",title:s??l,children:l}),i.length>0&&t.jsx("div",{className:"inline-flex shrink-0 items-center justify-end gap-1.5 text-xs",children:i.map(g=>t.jsx("span",{className:`thread-graph-history-delta-badge ${g.startsWith("+")?"is-add":g.startsWith("-")?"is-remove":"is-neutral"}`,children:g},g))})]}),u=d?t.jsx("button",{type:"button","aria-label":"Open file change details",onClick:()=>n("File Change Details",o??r.text),className:"thread-graph-file-change-inline-button min-w-0 flex-1 text-left",title:s??l,children:h}):h;return t.jsx(Xt,{className:"thread-graph-event-file-change",headerMeta:u,icon:t.jsx(_.FilePenLine,{className:"h-4 w-4"}),item:r,timeMeta:a,title:"file_change",tone:"fileChange"})}),Gf=c.memo(function({item:r,onSelect:n,timeMeta:a}){const s=pa(),[o,l]=c.useState(!1),i=r.artifact,d=i?s.renderArtifact({artifact:i,expanded:o,onToggleExpanded:()=>l(h=>!h)}):null;return t.jsx(Xt,{actions:t.jsxs("span",{className:"inline-flex items-center gap-2",children:[i&&!s.hasRendererForArtifact(i)?t.jsx("span",{className:"thread-graph-history-event-secondary",children:"No renderer"}):null,i&&n?t.jsxs("button",{type:"button","aria-label":`Open artifact inspector for ${i.title}`,onClick:()=>n(r,i),className:"thread-graph-history-event-action",children:[t.jsx(_.PackageOpen,{className:"h-3.5 w-3.5"}),"Inspect"]}):null]}),className:"thread-graph-event-artifact",icon:t.jsx(_.PackageOpen,{className:"h-4 w-4"}),item:r,timeMeta:a,title:(i==null?void 0:i.type)??"artifact",tone:"artifact",children:d??t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:()=>l(h=>!h),className:"thread-graph-history-event-summary is-clickable flex w-full items-center justify-between gap-3 text-left",children:[t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"thread-graph-history-event-primary block truncate",children:(i==null?void 0:i.title)??r.text}),t.jsx("span",{className:"thread-graph-history-event-secondary mt-1 block truncate",children:(i==null?void 0:i.summaryText)??r.previewText??r.text})]}),t.jsx("span",{className:"thread-graph-history-event-pill",children:o?"Hide":"Open"})]}),o?t.jsx("pre",{className:"thread-graph-history-event-pre max-h-80 overflow-auto",children:JSON.stringify((i==null?void 0:i.payload)??r,null,2)}):null]})})}),Ff=c.memo(function({item:r,timeMeta:n}){var h,u;const a=((h=r.hookOutputEntries)==null?void 0:h.map(m=>m.text.trim()).filter(Boolean).join(`
|
|
3701
|
+
`).trim())??"",s=r.hookEventLabel?`${r.hookEventLabel} hook`:r.text,o=((u=r.hookStatusMessage)==null?void 0:u.trim())||(r.previewText&&r.previewText!==r.hookStatusMessage?r.previewText.trim():"")||r.text.trim(),i=ft(a||(o&&o!==s?o:s)),d=!!(a&&i.showGap);return t.jsx(Xt,{className:"thread-graph-event-hook",icon:t.jsx(_.Webhook,{className:"h-4 w-4"}),item:r,timeMeta:n,title:r.hookEventLabel?`${r.hookEventLabel}_hook`:"hook",tone:"hook",children:t.jsxs("div",{className:"thread-graph-history-event-line",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:a?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"thread-graph-history-event-secondary mr-2 font-sans text-[11px] uppercase",children:s}),t.jsx(ir,{text:i.firstLine})]}):t.jsx(ir,{text:i.firstLine&&i.firstLine!==s?`${s} · ${i.firstLine}`:s})}),d?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})})}),Hf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s,timeMeta:o}){const l=r.filter(d=>cn(d.status)).length,i=r.length===1?"1 command":`${r.length} commands`;return t.jsx(hr,{className:"thread-graph-history-group-command",count:r.length,countBadgeClassName:"border-amber-200/35 text-amber-100",desktopIconClassName:"border-amber-300/30 bg-amber-300/[0.14] text-amber-100",expanded:n,expandedListClassName:"border-amber-300/12",icon:t.jsx(yf,{}),onToggleExpanded:a,runningIndicator:l>0?t.jsx(Jr,{}):null,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:i}),l>0?t.jsx("span",{className:"inline-flex items-center text-xs text-amber-100/90",children:t.jsx(Jr,{})}):null]}),timeMeta:o,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} command entries`,children:r.map((d,h)=>{const u=ft(d.text);return t.jsxs("button",{type:"button","aria-label":`Open grouped command ${h+1}`,onClick:()=>s(d,`Command Output ${h+1}`),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"rounded-full border border-amber-300/18 bg-amber-300/[0.07] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-amber-100",children:["Step ",h+1]}),d.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:d.status})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2 text-sm leading-6",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:u.firstLine}),u.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},d.id)})})}),Of=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s,timeMeta:o}){var u;const l=r.filter(m=>cn(m.status)).length,i=((u=r[0])==null?void 0:u.kind)??"toolCall",d=i==="agentToolCall"?"agent action":i==="skillToolCall"?"skill call":"tool call",h=r.length===1?`1 ${d}`:`${r.length} ${d}s`;return t.jsx(hr,{className:"thread-graph-history-group-tool",count:r.length,countBadgeClassName:"border-teal-200/35 text-teal-100",desktopIconClassName:"border-teal-300/30 bg-teal-300/[0.14] text-teal-100",expanded:n,expandedListClassName:"border-teal-300/12",icon:i==="agentToolCall"?t.jsx(_.Bot,{className:"h-3.5 w-3.5"}):t.jsx(_.Wrench,{className:"h-3.5 w-3.5"}),onToggleExpanded:a,runningIndicator:l>0?t.jsx(Jr,{}):null,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-teal-300/28 bg-teal-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-teal-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:h})]}),timeMeta:o,toggleAriaLabel:`${n?"Collapse":"Expand"} ${h}`,children:r.map((m,f)=>{const p=ft(m.text);return t.jsx("button",{type:"button","aria-label":`Open ${d} ${f+1}`,onClick:()=>s(m,`${d} ${f+1}`),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:t.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-sm leading-6",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:p.firstLine}),m.status?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-xs",children:m.status}):null]})},m.id)})})}),Wf=c.memo(function({itemCount:r,expanded:n,onToggleExpanded:a,timeMeta:s,children:o}){const l=r===1?"1 operation":`${r} operations`;return t.jsx(hr,{className:"thread-graph-history-group-activity",count:r,countBadgeClassName:"border-slate-200/35 text-slate-100",desktopIconClassName:"border-slate-300/30 bg-slate-300/[0.14] text-slate-100",expanded:n,expandedListClassName:"border-slate-300/12",icon:t.jsx(_.Bot,{className:"h-3.5 w-3.5"}),onToggleExpanded:a,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-sm font-medium text-stone-100",children:"Agent activity"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:l})]}),timeMeta:s,toggleAriaLabel:`${n?"Collapse":"Expand"} ${l}`,children:o})}),Uf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s,timeMeta:o}){const l=r.length===1?"1 search":`${r.length} searches`;return t.jsx(hr,{className:"thread-graph-history-group-search",count:r.length,countBadgeClassName:"border-sky-200/35 text-sky-100",desktopIconClassName:"border-sky-300/30 bg-sky-300/[0.14] text-sky-100",expanded:n,expandedListClassName:"border-sky-300/12",icon:t.jsx(jf,{}),onToggleExpanded:a,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-sky-300/28 bg-sky-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-sky-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:l})]}),timeMeta:o,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} web search entries`,children:r.map((i,d)=>{var f,p;const h=((f=i.previewText)==null?void 0:f.trim())||i.text||"Web search",u=ft(h),m=((p=i.detailText)==null?void 0:p.trim())||i.text||"Web search";return t.jsxs("button",{type:"button","aria-label":`Open grouped web search ${d+1}`,onClick:()=>s(`Web Search ${d+1}`,m),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"rounded-full border border-sky-300/18 bg-sky-300/[0.07] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-sky-100",children:["Search ",d+1]}),i.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:i.status})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2 text-sm leading-6",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:u.firstLine}),u.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},i.id)})})}),Vf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s,timeMeta:o}){const l=r.length===1?"1 file read":`${r.length} file reads`;return t.jsx(hr,{className:"thread-graph-history-group-file-read",count:r.length,countBadgeClassName:"border-cyan-200/35 text-cyan-100",desktopIconClassName:"border-cyan-300/30 bg-cyan-300/[0.14] text-cyan-100",expanded:n,expandedListClassName:"border-cyan-300/12",icon:t.jsx(wf,{}),onToggleExpanded:a,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-cyan-300/28 bg-cyan-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-cyan-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:l})]}),timeMeta:o,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} file read entries`,children:r.map((i,d)=>{var f,p;const h=((f=i.previewText)==null?void 0:f.trim())||i.text||"File read",u=ft(h),m=((p=i.detailText)==null?void 0:p.trim())||i.text||"File read";return t.jsxs("button",{type:"button","aria-label":`Open grouped file read ${d+1}`,onClick:()=>s(`File Read ${d+1}`,m),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"rounded-full border border-cyan-300/18 bg-cyan-300/[0.07] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-cyan-100",children:["Read ",d+1]}),i.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:i.status})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2 text-sm leading-6",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:u.firstLine}),u.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},i.id)})})}),qf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s,timeMeta:o}){const l=r.reduce((u,m)=>u+(m.changedFiles??0),0),i=r.reduce((u,m)=>u+(m.addedLines??0),0),d=r.reduce((u,m)=>u+(m.removedLines??0),0),h=r.length===1?"1 file change":`${r.length} file changes`;return t.jsx(hr,{className:"thread-graph-history-group-file-change",count:r.length,countBadgeClassName:"border-lime-200/35 text-lime-100",desktopIconClassName:"border-lime-300/30 bg-lime-300/[0.14] text-lime-100",expanded:n,expandedListClassName:"border-lime-300/12",icon:t.jsx(kf,{}),onToggleExpanded:a,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-lime-300/28 bg-lime-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-lime-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:h}),l>0?t.jsxs("span",{className:"thread-graph-history-detail-meta text-xs",children:[l," files"]}):null]}),timeMeta:o,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} file change entries`,trailingSummary:t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[i>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-add",children:["+",i]}):null,d>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-remove",children:["-",d]}):null]}),children:r.map((u,m)=>{var g,k,w,x;const f=((g=u.detailText)==null?void 0:g.trim())||((k=u.previewText)==null?void 0:k.trim())||u.text,p=(w=u.previewText)!=null&&w.trim()&&u.text.trim()!==u.previewText.trim()?u.text.trim():((x=u.previewText)==null?void 0:x.trim())||u.text;return t.jsx("button",{type:"button","aria-label":`Open grouped file change ${m+1}`,onClick:()=>s(`File Change ${m+1}`,f),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-detail-text min-w-0 flex-1 text-sm leading-6",title:p,children:Nl(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 Xf(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 Kf({status:e}){const r=Xf(e),n=r==="completed"?"Plan step status: Completed":r==="in_progress"?"Plan step status: In progress":r==="pending"?"Plan step status: Pending":r==="failed"?"Plan step status: Failed":`Plan step status: ${e}`,a=r==="completed"?"thread-graph-plan-status is-completed":r==="in_progress"?"thread-graph-plan-status is-running":r==="pending"?"thread-graph-plan-status is-pending":r==="failed"?"thread-graph-plan-status is-failed":"thread-graph-plan-status is-unknown";return t.jsx(dn,{"aria-label":n,title:n.replace("Plan step status: ",""),className:a,children:r==="completed"?t.jsx(_.CheckCircle2,{className:"h-3.5 w-3.5"}):r==="in_progress"?t.jsx(_.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):r==="pending"?t.jsx(_.Clock3,{className:"h-3.5 w-3.5"}):r==="failed"?t.jsx(_.XCircle,{className:"h-3.5 w-3.5"}):t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.14em]",children:"?"})})}function Yf({livePlan:e}){return t.jsxs("div",{className:"thread-graph-plan-card rounded-xl border px-3 py-3",children:[t.jsxs("div",{className:"thread-graph-plan-header flex flex-wrap items-center justify-between gap-2",children:[t.jsx("p",{className:"text-sm font-semibold",children:"Plan update"}),t.jsx(dn,{className:"thread-graph-plan-badge",children:"Live"})]}),e.explanation?t.jsx("p",{className:"thread-graph-plan-explanation mt-3 text-sm",children:e.explanation}):null,t.jsx("div",{className:"mt-3 space-y-2",children:e.plan.map((r,n)=>t.jsxs("div",{className:"thread-graph-plan-step flex items-center justify-between gap-3 rounded-lg border px-3 py-2 text-sm",children:[t.jsx("span",{className:"thread-graph-plan-step-text min-w-0 flex-1",children:r.step}),t.jsx(Kf,{status:r.status})]},`${e.turnId}-${n}`))})]})}function Zf({footer:e,history:r,liveHookPrompt:n,liveOutput:a,livePlan:s}){return t.jsxs(t.Fragment,{children:[r,s?t.jsx(Yf,{livePlan:s}):null,n??a??null,e]})}function Jf({absoluteIndex:e,body:r,collapsed:n,collapsedBody:a,error:s,footer:o,headerStatus:l,isActive:i=!1,refCallback:d,startedAt:h,timeLabel:u,timeTitle:m,tokenSummary:f}){return t.jsxs("article",{ref:d,"data-testid":"chat-turn","data-turn-active":i?"true":"false",className:"thread-graph-turn px-3 py-2 sm:px-5 sm:py-3",children:[t.jsx("div",{className:"thread-graph-turn-header flex items-start justify-between gap-2",children:t.jsxs("div",{className:"min-w-0 flex flex-1 items-start gap-1.5",children:[t.jsxs("div",{className:"min-w-0 flex flex-1 items-center gap-1.5 overflow-hidden",children:[t.jsxs("span",{className:"thread-graph-turn-index rounded-[0.6rem] border px-1.5 py-0.5 text-[10px] uppercase tracking-[0.16em]",children:["Turn ",e]}),t.jsx("time",{dateTime:h??void 0,title:m,className:"thread-graph-turn-time shrink-0 text-[10px] sm:text-[11px]",children:u}),l,s?t.jsx("p",{className:"hidden truncate text-[11px] text-rose-200 sm:block",children:s}):null]}),f]})}),s?t.jsx("p",{className:"mt-1 text-[11px] text-rose-200 sm:hidden",children:s}):null,t.jsxs("div",{className:"thread-graph-turn-body mt-2 space-y-2",children:[n?a:r,n?null:o]})]})}function Qf(){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 eg(){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 Ps(){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 tg(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.45",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M6.2 3.2a2.3 2.3 0 0 0-2.95 3.5A2.4 2.4 0 0 0 4.5 11h.2c.25 1.1 1.1 1.8 2.3 1.8h1.8c1.2 0 2.05-.7 2.3-1.8h.2A2.4 2.4 0 0 0 12.75 6.7 2.3 2.3 0 0 0 9.8 3.2"}),t.jsx("path",{d:"M6.3 6.15c.45-.42 1.02-.65 1.7-.65s1.25.23 1.7.65"}),t.jsx("path",{d:"M8 5.5v4.75"}),t.jsx("path",{d:"M6.75 9.05 8 10.25l1.25-1.2"})]})}function br(e){if(!Number.isFinite(e)||e<=0)return"0";if(e>=1e6){const r=e>=1e7?Math.round(e/1e6):e/1e6;return`${String(r.toFixed(1)).replace(/\.0$/,"")}m`}if(e>=1e3){const r=e>=1e4?Math.round(e/1e3):e/1e3;return`${String(r.toFixed(1)).replace(/\.0$/,"")}k`}return String(Math.round(e))}function Sl(e){return!Number.isFinite(e)||e<=0?"$0":e>=100?`$${Math.round(e)}`:e>=10?`$${String(e.toFixed(1)).replace(/\.0$/,"")}`:e>=1?`$${String(e.toFixed(2)).replace(/0$/,"").replace(/\.$/,"")}`:e>=.1?`$${e.toFixed(2)}`:e>=.01?`$${e.toFixed(3)}`:e>=.001?`$${e.toFixed(4)}`:"<$0.001"}function ar(e){return!Number.isFinite(e)||e<=0?"$0.0000":`$${e.toFixed(4)}`}function Br(e,r,n){const a=e??null;return!Number.isFinite(a??NaN)||a===null||r<=0||n<=0?null:a*n/r}function Tl(e){var d,h,u,m,f,p;const r=(d=e.tokenUsage)==null?void 0:d.total;if(!r)return[];const n=Math.max(r.inputTokens-r.cachedInputTokens-(r.cacheWriteInputTokens??0),0),a=Math.max(r.cachedInputTokens,0),s=Math.max(r.cacheWriteInputTokens??0,0),o=Math.max(r.reasoningOutputTokens,0),l=Math.max(r.outputTokens-o,0);return[n>0?{id:"in",label:"Input",tokenCompactValue:br(n),tokenRawValue:n,usdCompactValue:e.priceEstimate?ar(e.priceEstimate.inputUsd):"--",usdRawValue:((h=e.priceEstimate)==null?void 0:h.inputUsd)??null,className:"token-badge-in",icon:t.jsx(Qf,{})}:null,a>0?{id:"cache",label:"Cached input",tokenCompactValue:br(a),tokenRawValue:a,usdCompactValue:e.priceEstimate?ar(e.priceEstimate.cachedInputUsd):"--",usdRawValue:((u=e.priceEstimate)==null?void 0:u.cachedInputUsd)??null,className:"token-badge-cache",icon:t.jsx(Ps,{})}:null,s>0?{id:"cache-write",label:"Cache write",tokenCompactValue:br(s),tokenRawValue:s,usdCompactValue:e.priceEstimate?ar(e.priceEstimate.cacheWriteInputUsd??0):"--",usdRawValue:((m=e.priceEstimate)==null?void 0:m.cacheWriteInputUsd)??null,className:"token-badge-cache",icon:t.jsx(Ps,{})}:null,l>0?{id:"out",label:"Output",tokenCompactValue:br(l),tokenRawValue:l,usdCompactValue:e.priceEstimate?ar(Br(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),l)??0):"--",usdRawValue:Br((f=e.priceEstimate)==null?void 0:f.outputUsd,Math.max(r.outputTokens,0),l),className:"token-badge-out",icon:t.jsx(eg,{})}:null,o>0?{id:"reason",label:"Reasoning",tokenCompactValue:br(o),tokenRawValue:o,usdCompactValue:e.priceEstimate?ar(Br(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),o)??0):"--",usdRawValue:Br((p=e.priceEstimate)==null?void 0:p.outputUsd,Math.max(r.outputTokens,0),o),className:"token-badge-reason",icon:t.jsx(tg,{})}:null].filter(g=>g!==null)}function rg(e){return Tl(e).map(r=>({id:r.id,label:r.tokenCompactValue,title:`${r.label}: ${r.tokenRawValue} tokens`,className:r.className,icon:r.icon}))}function El(e){return{label:e.priceEstimate?Sl(e.priceEstimate.totalUsd):"--",title:e.priceEstimate===null||e.priceEstimate===void 0?"Price estimate unavailable for this model.":`Estimated cost: ${ar(e.priceEstimate.totalUsd)}`,className:e.priceEstimate?"token-badge-total":"token-badge-empty"}}var Ln="inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-normal leading-none sm:text-[11px]";function ng({turn:e}){const r=Tl(e),n=El(e),[a,s]=c.useState(!1),[o,l]=c.useState(!1),[i,d]=c.useState(0),h=c.useRef(null),u=c.useRef(null),m=c.useRef(null);if(c.useLayoutEffect(()=>{if(!a||r.length===0){d(0);return}const p=()=>{const g=h.current,k=m.current;if(!g||!k)return;const w=g.getBoundingClientRect(),x=k.offsetWidth||k.getBoundingClientRect().width;if(x<=0)return;const j=window.innerWidth||document.documentElement.clientWidth,y=12,b=w.left+w.width/2-x/2,v=y,S=Math.max(v,j-y-x),N=Math.min(Math.max(b,v),S);d(Math.round(N-b))};return p(),window.addEventListener("resize",p),()=>{window.removeEventListener("resize",p)}},[r.length,a]),c.useEffect(()=>{if(!a&&!o)return;const p=g=>{g.target instanceof Node&&(h.current&&!h.current.contains(g.target)&&s(!1),u.current&&!u.current.contains(g.target)&&l(!1))};return document.addEventListener("pointerdown",p),()=>{document.removeEventListener("pointerdown",p)}},[o,a]),!n&&r.length===0)return null;const f=()=>t.jsx("div",{className:"thread-token-popover min-w-[12rem] rounded-2xl border p-2.5 shadow-2xl shadow-black/20 backdrop-blur",children:t.jsx("div",{className:"space-y-1",children:r.map(p=>t.jsxs("div",{className:"thread-token-popover-row flex items-center justify-between gap-3 rounded-xl border px-2.5 py-1.5 text-[11px]",title:`${p.label}: ${p.tokenRawValue} tokens`,children:[t.jsxs("span",{className:"thread-token-popover-text inline-flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"inline-flex shrink-0",children:p.icon}),t.jsx("span",{className:"thread-token-popover-strong font-medium",children:p.usdCompactValue})]}),t.jsx("span",{className:"thread-token-popover-text shrink-0 font-medium",children:p.tokenCompactValue})]},p.id))})});return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"hidden shrink-0 items-center gap-1.5 md:inline-flex",children:[n?t.jsxs("div",{ref:u,className:"relative shrink-0",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[t.jsx("button",{type:"button","aria-label":"Show token and price details","aria-expanded":o,onFocus:()=>l(!0),onBlur:()=>l(!1),className:`${Ln} appearance-none whitespace-nowrap bg-transparent !text-[10px] !font-normal !leading-none transition hover:bg-[var(--theme-hover)] sm:!text-[11px] ${n.className}`,title:n.title,children:n.label}),o&&r.length>0?t.jsx("div",{className:"absolute left-1/2 top-full z-30 mt-1.5 -translate-x-1/2",children:f()}):null]}):null,r.map(p=>t.jsxs("span",{className:`${Ln} ${p.className}`,title:`${p.label}: ${p.usdCompactValue}, ${p.tokenRawValue} tokens`,children:[p.icon,t.jsx("span",{className:"thread-token-badge-value font-medium",children:p.tokenCompactValue})]},p.id))]}),t.jsxs("div",{ref:h,className:"relative shrink-0 md:hidden",children:[n?t.jsx("button",{type:"button","aria-label":"Show token and price details","aria-expanded":a,onClick:()=>s(p=>!p),className:`${Ln} appearance-none whitespace-nowrap bg-transparent !text-[10px] !font-normal !leading-none transition hover:bg-[var(--theme-hover)] sm:!text-[11px] ${n.className}`,title:n.title,children:n.label}):null,a&&r.length>0?t.jsx("div",{ref:m,className:"absolute left-1/2 top-full z-30 mt-1.5",style:{transform:`translateX(${i}px) translateX(-50%)`},children:f()}):null]})]})}function ag({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 Rs(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 sg(e){switch(e.kind){case"fileChange":case"webSearch":case"image":case"contextCompaction":return!0;case"commandExecution":case"toolCall":return!fa(e.status);default:return!1}}function og(e,r,n){if(!e||!yr(n))return e;const a=e.plan.findIndex(i=>Rs(i.status)==="in_progress");if(a<0)return e;const s=e.plan.findIndex((i,d)=>d>a&&Rs(i.status)==="pending");if(s<0||!r.some(i=>sg(i)))return e;const l=e.plan.map((i,d)=>d===a?{...i,status:"completed"}:d===s?{...i,status:"in_progress"}:i);return{...e,plan:l}}function lg(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 As({status:e}){const r=ml(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(ag,{tone:"emerald"})})}function Ms({turn:e,variant:r="header"}){const n=ml(e.status),a=lg(e),s=rg(e),o=El(e),l=yr(e.status),i=e.status==="failed"?"border-rose-300/20 bg-rose-300/[0.06] text-rose-100":l?"border-sky-300/22 bg-sky-300/[0.08] text-sky-100":"border-stone-700/90 bg-stone-900/70 text-stone-200";if(r==="footer")return t.jsxs("div",{className:`flex w-full flex-col gap-1.5 rounded-[0.95rem] border px-3 py-2 text-xs ${i}`,children:[t.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(As,{status:e.status}),t.jsx("span",{className:"timeline-soft-text min-w-0 truncate",children:a})]}),e.startedAt&&t.jsx("time",{dateTime:e.startedAt,title:Ut(e.startedAt),className:"timeline-meta-text shrink-0 text-[11px]",children:kt(e.startedAt)})]}),(o||s.length>0)&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 pl-6",children:[o?t.jsx("span",{className:`inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${o.className}`,title:o.title,children:o.label}):null,s.map(h=>t.jsxs("span",{className:`inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${h.className}`,title:h.title,children:[h.icon?t.jsx("span",{className:"mr-1",children:h.icon}):null,h.label]},h.id))]})]});const d=`${n} · ${a}`;return t.jsxs("span",{className:`inline-flex min-w-0 items-center gap-1.5 rounded-full border px-2 py-1 text-[10px] sm:text-[11px] ${i}`,title:d,children:[t.jsx(As,{status:e.status}),t.jsx("span",{className:"timeline-meta-text min-w-0 truncate",children:a})]})}function ig(e,r){return e.createdAt??r}var ga=c.memo(function({threadId:r,item:n,scrollRootRef:a,onOpenExpandedText:s,onOpenCommandDetail:o,onOpenToolCallDetail:l,onOpenDeferredHistoryItemDetail:i,onSelectArtifact:d,onBeforeMessageResize:h,adapter:u,timeLabel:m,timeTitle:f,timeMeta:p,autoOpenToolDetails:g=!1}){var k,w,x;if(rf(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(Gf,{item:n,timeMeta:p,...d?{onSelect:(j,y)=>d({item:j,artifact:y})}:{}});if(n.kind==="commandExecution")return t.jsx(Pf,{autoOpen:g,item:n,onOpen:o,timeMeta:p});if(n.kind==="toolCall")return t.jsx(Rf,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="agentToolCall")return t.jsx(Af,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="skillToolCall")return t.jsx(Mf,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="webSearch"){const j=n,y=((k=j.detailText)==null?void 0:k.trim())||j.text||"Web search";return t.jsx(_f,{autoOpen:g,item:j,timeMeta:p,onOpen:()=>i(j,"Web Search Details",y,"Loading full web search details...","Unable to load full web search details.")})}if(n.kind==="fileRead"){const j=n,y=((w=j.detailText)==null?void 0:w.trim())||j.text||"File read";return t.jsx($f,{autoOpen:g,item:j,timeMeta:p,onOpen:()=>i(j,"File Read Details",y,"Loading full file read details...","Unable to load full file read details.")})}if(n.kind==="image")return t.jsx(Df,{threadId:r,item:n,onOpen:s,getImageAssetUrl:u==null?void 0:u.getImageAssetUrl,timeMeta:p});if(n.kind==="plan")return t.jsx(Lf,{item:n,scrollRootRef:a,timeMeta:p,...h?{onBeforeResize:h}:{}});if(n.kind==="fileChange"){const j=n,y=((x=j.detailText)==null?void 0:x.trim())||j.text||"File change";return t.jsx(Bf,{item:j,timeMeta:p,onOpen:()=>i(j,"File Change Details",y,"Loading full file change details...","Unable to load full file change details.")})}return n.kind==="contextCompaction"?t.jsx(If,{item:n,timeMeta:p}):n.kind==="hook"?t.jsx(Ff,{item:n,timeMeta:p}):t.jsx(zf,{item:n,timeMeta:p})});function _s(e){return e==="completed"||e==="failed"||e==="interrupted"}function dg(e){const r=Date.parse(e.createdAt??"");return Number.isFinite(r)?r:null}function cg(e){let r=null;for(const n of e){const a=dg(n);a!==null&&(r=r===null?a:Math.max(r,a))}return r}function hg(e,r){const n=Date.parse(e??""),a=cg(r);if(!Number.isFinite(n)||a===null||a<n)return"Worked";const s=Math.max(1,Math.round((a-n)/1e3)),o=Math.floor(s/3600),l=Math.floor(s%3600/60),i=s%60;return o>0?`Worked for ${o}h ${l}m`:l>0?`Worked for ${l}m ${i}s`:`Worked for ${i}s`}function ug(e,r){const n=Date.parse(e??""),a=Date.parse(r??"");if(!Number.isFinite(n)||!Number.isFinite(a))return r?kt(r):"Time unavailable";const s=Math.max(0,Math.round((a-n)/1e3)),o=Math.floor(s/3600),l=Math.floor(s%3600/60),i=s%60;return o>0?`${o}h ${l}m`:l>0?`${l}m ${i}s`:`${i}s`}function Nr({absoluteLabel:e,className:r="",timestamp:n,turnStartedAt:a}){const[s,o]=c.useState(!1);if(!n)return null;const l=Ut(n),i=ug(a,n),d=s?e:i;return t.jsx("span",{role:"button",tabIndex:0,className:`thread-graph-relative-time rounded-full px-1.5 py-0.5 ${r}`,title:s?i:l,"aria-label":`Toggle timestamp, currently ${d}`,onClick:h=>{h.stopPropagation(),o(u=>!u)},onKeyDown:h=>{h.key!=="Enter"&&h.key!==" "||(h.preventDefault(),h.stopPropagation(),o(u=>!u))},children:t.jsx("time",{dateTime:n,children:d})})}function Gt(e){var r;return e.kind==="item"?e.item.createdAt??null:e.kind==="agentActivityGroup"?e.entries[0]?Gt(e.entries[0]):null:((r=e.items.find(n=>n.createdAt))==null?void 0:r.createdAt)??null}function mg(e){const r=e.filter(o=>o.kind==="item"),n=r.map(o=>o.item).filter(o=>o.kind==="userMessage"),a=r.map(o=>o.item).reverse().find(o=>o.kind==="agentMessage"&&o.text.trim().length>0),s=e.filter(o=>o.kind!=="item"?!0:o.item.kind!=="userMessage"&&o.item.id!==(a==null?void 0:a.id));return{users:n,finalAgent:a,hiddenEntries:s}}var In=c.memo(function({threadId:r,adapter:n,turn:a,absoluteIndex:s,isCollapsed:o,livePlan:l,liveItems:i,liveOutput:d,forceActive:h=!1,onToggleCollapse:u,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,onSelectArtifact:k,onBeforeMessageResize:w,scrollRootRef:x,articleRef:j,isLatestVisibleTurn:y=!1}){const b=!!l||!!d||!!(i&&i.length>0),v=h||yr(a.status)||b||y,S=v&&!yr(a.status)?{...a,status:"inProgress"}:a,N=c.useMemo(()=>of(a.items,i),[i,a.items]),L=c.useMemo(()=>og(l,N,a.status),[l,N,a.status]),R=c.useMemo(()=>lf(d,N),[d,N]),P=c.useMemo(()=>sf(N,v),[v,N]),Q=c.useMemo(()=>df(P),[P]),K=h||yr(a.status)||b,J=kt(a.startedAt),B=Ut(a.startedAt),z=c.useMemo(()=>bl(R),[R]),[te,se]=c.useState({}),$=c.useCallback(X=>{se(de=>({...de,[X]:!de[X]}))},[]),ie=t.jsx(Ll,{entries:Q,expandedGroups:te,onToggleGroupedItem:$,threadId:r,scrollRootRef:x,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,...w?{onBeforeMessageResize:w}:{},fallbackTimestamp:a.startedAt,fallbackTimeLabel:J,fallbackTimeTitle:B,turnStartedAt:a.startedAt,autoOpenLatestToolDetails:K,...k?{onSelectArtifact:k}:{},...n?{adapter:n}:{}}),q=z?t.jsx(ga,{threadId:r,item:z,scrollRootRef:x,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,timeLabel:a.startedAt?t.jsx(Nr,{absoluteLabel:J,timestamp:a.startedAt,turnStartedAt:a.startedAt}):J,timeTitle:B,timeMeta:null,...k?{onSelectArtifact:k}:{},...n?{adapter:n}:{}}):null,H=!z&&R?t.jsx(It,{item:{id:"live-agent-message",kind:"agentMessage",text:R},scrollRootRef:x,timeLabel:a.startedAt?t.jsx(Nr,{absoluteLabel:J,timestamp:a.startedAt,turnStartedAt:a.startedAt}):J,timeTitle:B,streaming:!0,...w?{onBeforeMessageResize:w}:{}}):null,G=v?t.jsx(Ms,{turn:S,variant:"footer"}):null,T=c.useMemo(()=>mg(Q),[Q]),F=c.useMemo(()=>hg(a.startedAt,N),[N,a.startedAt]),D=T.hiddenEntries.length>0,E=o&&D,W=_s(a.status)&&D&&!E?t.jsxs("button",{type:"button",className:"thread-graph-worked-summary group flex w-full items-center gap-2 py-2 text-left text-sm transition",onClick:()=>u(a.id,!1),"aria-label":`${F}. Collapse turn ${s}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:F}),t.jsx(_.ChevronDown,{className:"h-4 w-4 shrink-0 transition group-hover:translate-y-0.5"}),t.jsx("span",{className:"thread-graph-worked-rule h-px min-w-0 flex-1","aria-hidden":"true"})]}):null,U=_s(a.status)&&D?t.jsxs("div",{className:"thread-graph-turn-collapsed-summary space-y-2",children:[T.users.map(X=>t.jsx(It,{threadId:r,item:X,scrollRootRef:x,timeLabel:X.createdAt?kt(X.createdAt):J,timeTitle:X.createdAt?Ut(X.createdAt):B,...w?{onBeforeMessageResize:w}:{},...n?{adapter:n}:{}},X.id)),t.jsxs("button",{type:"button",className:"thread-graph-worked-summary group flex w-full items-center gap-2 py-2 text-left text-sm transition",onClick:()=>u(a.id,!0),"aria-label":`${F}. Expand turn ${s}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:F}),t.jsx(_.ChevronRight,{className:"h-4 w-4 shrink-0 transition group-hover:translate-x-0.5"}),t.jsx("span",{className:"thread-graph-worked-rule h-px min-w-0 flex-1","aria-hidden":"true"})]}),T.finalAgent?t.jsx(It,{threadId:r,item:T.finalAgent,scrollRootRef:x,timeLabel:T.finalAgent.createdAt?t.jsx(Nr,{absoluteLabel:kt(T.finalAgent.createdAt),timestamp:T.finalAgent.createdAt,turnStartedAt:a.startedAt}):J,timeTitle:T.finalAgent.createdAt?Ut(T.finalAgent.createdAt):B,...w?{onBeforeMessageResize:w}:{},...n?{adapter:n}:{}}):null]}):null,ae=t.jsx(Zf,{footer:G,history:t.jsxs(t.Fragment,{children:[W,ie]}),liveHookPrompt:q,liveOutput:H,livePlan:L});return t.jsx(Jf,{absoluteIndex:s,body:ae,collapsed:E,collapsedBody:U,error:a.error,headerStatus:t.jsx(Ms,{turn:a}),isActive:v,refCallback:j,startedAt:a.startedAt,timeLabel:J,timeTitle:B,tokenSummary:t.jsx(ng,{turn:a})})});function Ll({entries:e,expandedGroups:r,onToggleGroupedItem:n,threadId:a,scrollRootRef:s,onOpenExpandedText:o,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,onSelectArtifact:h,onBeforeMessageResize:u,adapter:m,fallbackTimestamp:f,fallbackTimeLabel:p,fallbackTimeTitle:g,turnStartedAt:k,autoOpenLatestToolDetails:w=!1}){var y;const x=((y=e.at(-1))==null?void 0:y.key)??null,j=c.useCallback(b=>b?t.jsx(Nr,{absoluteLabel:kt(b),timestamp:b,turnStartedAt:k??f}):null,[f,k]);return t.jsx(bf,{entries:e,expandedGroups:r,onToggleGroupedItem:n,renderCommandGroup:(b,v,S)=>t.jsx(Hf,{items:b.items,expanded:v,onToggleExpanded:S,onOpen:l,timeMeta:j(Gt(b))},b.key),renderFileChangeGroup:(b,v,S)=>t.jsx(qf,{items:b.items,expanded:v,onToggleExpanded:S,onOpen:o,timeMeta:j(Gt(b))},b.key),renderSearchGroup:(b,v,S)=>t.jsx(Uf,{items:b.items,expanded:v,onToggleExpanded:S,onOpen:o,timeMeta:j(Gt(b))},b.key),renderFileReadGroup:(b,v,S)=>t.jsx(Vf,{items:b.items,expanded:v,onToggleExpanded:S,onOpen:o,timeMeta:j(Gt(b))},b.key),renderToolCallGroup:(b,v,S)=>t.jsx(Of,{items:b.items,expanded:v,onToggleExpanded:S,onOpen:i,timeMeta:j(Gt(b))},b.key),renderAgentActivityGroup:(b,v,S)=>t.jsx(Wf,{itemCount:b.itemCount,expanded:v,onToggleExpanded:S,timeMeta:j(Gt(b.entries[0])),children:t.jsx(Ll,{entries:b.entries,expandedGroups:r,onToggleGroupedItem:n,threadId:a,scrollRootRef:s,onOpenExpandedText:o,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,...u?{onBeforeMessageResize:u}:{},fallbackTimestamp:f,fallbackTimeLabel:p,fallbackTimeTitle:g,turnStartedAt:k,autoOpenLatestToolDetails:!1,...h?{onSelectArtifact:h}:{},...m?{adapter:m}:{}})},b.key),renderItem:b=>{const v=ig(b.item,f??null),N=b.item.kind==="userMessage"?b.item.createdAt?kt(v):p:b.item.createdAt?t.jsx(Nr,{absoluteLabel:kt(v),timestamp:v,turnStartedAt:k??f}):p;return t.jsx(ga,{threadId:a,item:b.item,scrollRootRef:s,timeLabel:N,timeTitle:b.item.createdAt?Ut(v):g,timeMeta:j(v),autoOpenToolDetails:w&&b.key===x,onOpenExpandedText:o,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,...u?{onBeforeMessageResize:u}:{},...h?{onSelectArtifact:h}:{},...m?{adapter:m}:{}},b.key)}})}var $s=3,pg=3,ta=80;function vr(e,r=ta){return e.scrollHeight-e.scrollTop-e.clientHeight<=r}function fg(e,r){const n=e.getBoundingClientRect(),a=r.getBoundingClientRect(),s=Math.max(n.top,a.top),o=Math.min(n.bottom,a.bottom);return Math.max(0,o-s)>0}function gg(e){return e.map(n=>{const a=n.createdAt;return typeof a=="string"&&a.trim()?a:null}).filter(n=>!!n).sort()[0]??null}function xg(e,r){return{id:e,startedAt:gg(r),status:"inProgress",error:null,model:null,reasoningEffort:null,reasoningEffortAvailable:null,tokenUsage:null,priceEstimate:null,items:[]}}function Ds(e,r,n){return{id:e.id,kind:e.kind,title:r,text:n}}function bg({loadHistoryItemDetail:e,onSelectHistoryItemDetail:r}){const n=c.useRef(0),a=c.useRef(new Map),[s,o]=c.useState(null),l=c.useCallback((p,g)=>{o({title:p,text:g})},[]),i=c.useCallback((p,g,k)=>{if(k&&r){r({item:p,detail:g});return}o({title:g.title,text:g.text})},[r]),d=c.useCallback(async({item:p,fallbackTitle:g,fallbackText:k,loadingText:w,errorText:x,useSelectionCallback:j})=>{if(!p.hasDeferredDetail||!e){i(p,Ds(p,g,k),j);return}const y=a.current.get(p.id);if(y){i(p,y,j);return}const b=n.current+1;n.current=b,j&&r||o({title:g,text:w});try{const v=await e(p.id);if(a.current.set(p.id,v),n.current!==b)return;i(p,v,j)}catch(v){if(n.current!==b)return;i(p,Ds(p,g,v instanceof Error?v.message:x),j)}},[e,r,i]),h=c.useCallback(async(p,g)=>{var k;await d({item:p,fallbackTitle:g,fallbackText:((k=p.detailText)==null?void 0:k.trim())||p.text||"Command output",loadingText:"Loading full command output...",errorText:"Unable to load full command output.",useSelectionCallback:!0})},[d]),u=c.useCallback(async(p,g)=>{var k;await d({item:p,fallbackTitle:g,fallbackText:((k=p.detailText)==null?void 0:k.trim())||p.text||"Tool call",loadingText:"Loading full tool call details...",errorText:"Unable to load full tool call details.",useSelectionCallback:!0})},[d]),m=c.useCallback(async(p,g,k,w,x)=>{await d({item:p,fallbackTitle:g,fallbackText:k,loadingText:w,errorText:x,useSelectionCallback:!1})},[d]),f=c.useCallback(()=>{n.current+=1,o(null)},[]);return{expandedText:s,openExpandedText:l,openCommandDetail:h,openToolCallDetail:u,openDeferredHistoryItemDetail:m,closeExpandedText:f}}function vg(e){const r=c.useRef(null),n=c.useRef(0),a=r.current;return(a===null||a.length!==e.length||e.some((o,l)=>!Object.is(o,a[l])))&&(n.current+=1,r.current=e),n.current}function kg({threadId:e,turnsLength:r,totalTurnCount:n,loadingEarlier:a,onLoadEarlier:s,scrollRequestKey:o,bottomSpacer:l,onTailVisibilityChange:i,contentRevisionInputs:d}){const h=c.useRef(null),u=c.useRef(null),m=c.useRef(o),f=c.useRef(null),p=c.useRef(l),g=c.useRef(0),k=c.useRef(0),w=c.useRef(null),x=c.useRef(null),j=c.useRef(null),y=c.useRef(!0),b=c.useRef(!0),v=c.useRef(!1),S=c.useRef(!1),N=c.useRef(!1),L=c.useRef(!1),R=c.useRef(null),P=c.useRef(0),[Q,K]=c.useState($s),[J,B]=c.useState(0),[z,te]=c.useState(!0),se=vg(d),$=typeof s=="function"||n!==void 0,ie=n??r,q=$?0:Math.max(0,r-Q),G=($?Math.max(0,ie-r):0)+q,T=$?r:r-q,F=$?0:r-T,D=$?Math.max(0,ie-r):0,E=$?D+F:F,C=!$&&E>0&&J>=2,W=$&&D>0&&F===0&&typeof s=="function",U=c.useCallback(()=>{const Z=h.current;if(!Z){w.current=null;return}w.current={scrollHeight:Z.scrollHeight,scrollTop:Z.scrollTop}},[]),ae=c.useCallback(()=>!W||a||N.current?!1:(U(),N.current=!0,L.current=!1,P.current=0,s==null||s(),!0),[W,a,s,U]),X=c.useCallback(()=>{const Z=h.current,me=x.current;if(!Z)return;const we=me?fg(Z,me):vr(Z);y.current=we,te(ye=>ye===we?ye:we)},[]),de=c.useCallback(()=>{const Z=h.current;if(Z){S.current=!0;const me=Z.scrollTop,we=k.current,ye=me-we;k.current=me,vr(Z,1)?(v.current=!1,b.current=!0):ye<-1?(v.current=!0,b.current=!1):ye>1&&(b.current=!v.current&&vr(Z,ta)),me<=0&&S.current?L.current=!0:me>0&&(L.current=!1,P.current=0)}X()},[X]),ee=c.useCallback(()=>{const Z=h.current;Z&&(Z.scrollTop=Z.scrollHeight,k.current=Z.scrollTop,g.current=Z.scrollHeight,y.current=!0,te(me=>me||!0),v.current=!1,b.current=!0)},[]),ke=c.useCallback(()=>{const Z=h.current;Z&&(k.current=Z.scrollTop,g.current=Z.scrollHeight,b.current=!1,v.current=!0)},[]),le=c.useCallback(()=>{if($&&F===0){ae();return}K(Z=>Math.min(r,Z+pg)),B(Z=>Z+1)},[F,$,ae,r]),je=c.useCallback(Z=>{const me=h.current;if(!(!me||Z.deltaY>=-8||me.scrollTop>0||!W)){if(!L.current){L.current=!0;return}ae()}},[W,ae]),Ae=c.useCallback(Z=>{var me;R.current=((me=Z.touches.item(0))==null?void 0:me.clientY)??null,P.current=0},[]),ce=c.useCallback(Z=>{var Be;const me=h.current,we=((Be=Z.touches.item(0))==null?void 0:Be.clientY)??null,ye=R.current;if(R.current=we,!me||we===null||ye===null||me.scrollTop>0||!W){P.current=0;return}const De=we-ye;if(De<=0){P.current=0;return}if(!L.current){L.current=!0,P.current=0;return}P.current+=De,P.current>=28&&ae()},[W,ae]),ne=c.useCallback(()=>{R.current=null,P.current=0},[]),Le=c.useCallback(()=>{K(r)},[r]);return c.useLayoutEffect(()=>{const Z=window.requestAnimationFrame(()=>{ee()});return()=>{window.cancelAnimationFrame(Z)}},[e,ee]),c.useEffect(()=>{N.current=!1,S.current=!1,L.current=!1,w.current=null},[e]),c.useEffect(()=>{a||(N.current=!1)},[a,r]),c.useLayoutEffect(()=>{const Z=w.current,me=h.current;if(!Z||!me||a)return;w.current=null;const we=me.scrollHeight-Z.scrollHeight;if(we<=0){g.current=me.scrollHeight,k.current=me.scrollTop;return}const ye=Z.scrollTop+we;me.scrollTop=ye,k.current=ye,g.current=me.scrollHeight,v.current=!0,b.current=!1,L.current=!1},[a,r]),c.useEffect(()=>{K(Z=>Z>=r-1?r:Math.max(Z,$s))},[r]),c.useEffect(()=>{const Z=h.current;Z&&(g.current=Z.scrollHeight,k.current=Z.scrollTop,vr(Z,1)?(v.current=!1,b.current=!0):(v.current||!vr(Z,ta))&&(b.current=!1)),X()},[se,X,Q]),c.useEffect(()=>{const Z=o!==m.current,me=f.current!==se;if(f.current=se,!(Z||me&&b.current&&!v.current))return;const ye=window.requestAnimationFrame(()=>{ee()});return o!==m.current&&(m.current=o),()=>{window.cancelAnimationFrame(ye)}},[se,z,ee,o]),c.useEffect(()=>{const Z=h.current,me=u.current;if(!Z||!me||typeof ResizeObserver>"u")return;g.current=Z.scrollHeight;const we=new ResizeObserver(()=>{const ye=Z.scrollHeight,De=g.current;if(g.current=ye,ye<=De)return;const Be=De>0&&De-Z.scrollTop-Z.clientHeight<=1;v.current||!(b.current||Be||y.current)||window.requestAnimationFrame(()=>{ee()})});return we.observe(me),()=>{we.disconnect()}},[ee]),c.useEffect(()=>{if(!b.current||v.current){p.current=l;return}if(l===p.current)return;p.current=l;const Z=window.requestAnimationFrame(()=>{ee()});return()=>{window.cancelAnimationFrame(Z)}},[l,ee]),c.useEffect(()=>{i==null||i(z)},[z,i]),{scrollContainerRef:h,scrollContentRef:u,tailSentinelRef:x,topSentinelRef:j,isTailVisible:z,handleScroll:de,handleWheel:je,handleTouchStart:Ae,handleTouchMove:ce,handleTouchEnd:ne,preserveScrollPositionForResize:ke,serverManagedHistory:$,effectiveTotalTurnCount:ie,startIndex:q,visibleTurnAbsoluteOffset:G,hiddenCount:E,loadedHiddenCount:F,unloadedHiddenCount:D,showLoadAll:C,handleLoadEarlierClick:le,handleLoadAllClick:Le}}function wg(e){return e==="completed"||e==="failed"||e==="interrupted"}function yg(e,r){if(!r||r.id!==e.id||r.items.length===0)return e;const n=new Set(e.items.map(s=>s.id)),a=r.items.filter(s=>!n.has(s.id));return a.length===0?e:{...e,items:[...a,...e.items]}}function jg({threadId:e,turns:r,totalTurnCount:n,pendingRequests:a=[],activeTurnId:s=null,threadRunning:o=!1,pendingSteers:l=[],livePlan:i=null,liveItems:d=null,respondingRequestId:h=null,onRespondToRequest:u,liveOutput:m,scrollRequestKey:f=0,previousTurnScrollRequestKey:p=0,nextTurnScrollRequestKey:g=0,bottomSpacer:k=0,className:w="",onTailVisibilityChange:x,onPreviousTurnAvailabilityChange:j,onNextTurnAvailabilityChange:y,loadingEarlier:b=!1,onLoadEarlier:v,ephemeralUserNote:S=null,answeredRequestNotes:N=[],activityNotes:L=[],optimisticSteers:R=[],optimisticTurn:P=null,onLoadHistoryItemDetail:Q,onOpenThread:K,onSelectArtifact:J,onSelectHistoryItemDetail:B,adapter:z,autoCollapseCompletedTurns:te}){var st,ct,xt,Rt,wt;const se=ul(),$=te??(se==null?void 0:se.autoCollapseCompletedTurns)??!1,[ie,q]=c.useState({}),[H,G]=c.useState(()=>new Set),T=c.useRef(null),F=c.useRef(null),D=(z==null?void 0:z.onLoadHistoryItemDetail)??Q,E=z==null?void 0:z.onOpenLinkedThread,{expandedText:C,openExpandedText:W,openCommandDetail:U,openToolCallDetail:ae,openDeferredHistoryItemDetail:X,closeExpandedText:de}=bg({loadHistoryItemDetail:D,onSelectHistoryItemDetail:B}),{scrollContainerRef:ee,scrollContentRef:ke,tailSentinelRef:le,topSentinelRef:je,handleScroll:Ae,handleWheel:ce,handleTouchStart:ne,handleTouchMove:Le,handleTouchEnd:Z,preserveScrollPositionForResize:me,serverManagedHistory:we,effectiveTotalTurnCount:ye,startIndex:De,visibleTurnAbsoluteOffset:Be,hiddenCount:$e,loadedHiddenCount:Oe,unloadedHiddenCount:V,showLoadAll:he,handleLoadEarlierClick:ve,handleLoadAllClick:I}=kg({threadId:e,turnsLength:r.length,totalTurnCount:n,loadingEarlier:b,onLoadEarlier:v,scrollRequestKey:f,bottomSpacer:k,onTailVisibilityChange:x,contentRevisionInputs:[r,a,l,R,m,i,d,P,N,L,S,k]}),O=c.useCallback((M,fe)=>{q(ze=>({...ze,[M]:!fe}))},[]),oe=c.useCallback((M,fe)=>{const ze=ie[M.id];return ze!==void 0?ze:!!($&&wg(M.status)&&!fe.forceActive&&!fe.hasLiveActivity)},[ie,$]),ge=we?r:r.slice(De),Ne=ye+1,Ce=o&&(!s||!ge.some(M=>M.id===s)&&(P==null?void 0:P.id)!==s),xe=(P==null?void 0:P.id)??((st=ge.at(-1))==null?void 0:st.id)??null,Ge=Ce&&xe!==null,Me=!!d&&(ge.some(M=>M.id===d.turnId)||(P==null?void 0:P.id)===d.turnId),Qe=d&&Me?d.turnId:d&&Ge?xe:null,et=P&&Qe===P.id?(d==null?void 0:d.items)??null:null,it=((d==null?void 0:d.items.length)??0)>0,tt=d&&Qe===null?d.items:null,Ke=c.useMemo(()=>d&&Qe===null&&d.items.length>0?xg(d.turnId,d.items):null,[d,Qe]),dt=Math.max(1,ye+(P?1:0)),gt=!!m&&!!P&&P.status!=="failed"&&!et,qe=m&&ge.length>0?s&&ge.some(M=>M.id===s)?s:((ct=ge.findLast(M=>fa(M.status)))==null?void 0:ct.id)??(Ge?xe:null):null,A=!!qe,Y=c.useMemo(()=>bl(m),[m]),be=[...l.map(M=>({id:M.id,prompt:M.prompt,status:"Accepted",createdAt:M.createdAt,canCancel:!0})),...R.map(M=>({id:M.id,prompt:M.prompt,status:M.status==="steering"?"Steering":null,createdAt:M.createdAt,canCancel:!1}))].sort((M,fe)=>M.createdAt.localeCompare(fe.createdAt)),Se=c.useMemo(()=>pf({answeredRequestNotes:N,pendingRequests:a,visibleTurns:ge,optimisticTurn:P}),[N,P,a,ge]),Pe=c.useMemo(()=>ff({activityNotes:L,visibleTurns:ge,optimisticTurn:P}),[L,P,ge]),rt=c.useCallback(()=>{const M=ee.current;if(!M)return null;const fe=M.getBoundingClientRect().top;return Array.from(M.querySelectorAll("[data-timeline-turn]")).find(ze=>ze.getBoundingClientRect().top>fe+8)??null},[ee]),nt=c.useCallback(()=>{const M=ee.current;if(!M)return null;const fe=M.getBoundingClientRect().top;return Array.from(M.querySelectorAll("[data-timeline-turn]")).findLast(ze=>ze.getBoundingClientRect().top<fe-8)??null},[ee]),_e=c.useCallback(()=>{j==null||j(!!nt())},[nt,j]),We=c.useCallback(()=>{y==null||y(!!rt())},[rt,y]),ut=c.useCallback(()=>{Ae(),_e(),We()},[Ae,We,_e]);return c.useEffect(()=>{_e(),We()},[We,_e,ge]),c.useEffect(()=>{if(p===0)return;const M=ee.current,fe=nt(),ze=M?Array.from(M.querySelectorAll("[data-timeline-turn]")):[],Fe=fe?ze.indexOf(fe):-1,Ue=fe&&fe.dataset.turnId===T.current?ze[Fe-1]??null:fe;if(!M||!Ue)return;T.current=Ue.dataset.turnId??null;const mt=Ue.getBoundingClientRect().top-M.getBoundingClientRect().top;M.scrollTo({top:M.scrollTop+mt-8,behavior:"smooth"}),ze.indexOf(Ue)===0&&(j==null||j(!1))},[nt,j,p,ee]),c.useEffect(()=>{if(g===0)return;const M=ee.current,fe=rt(),ze=M?Array.from(M.querySelectorAll("[data-timeline-turn]")):[],Fe=fe?ze.indexOf(fe):-1,Ue=fe&&fe.dataset.turnId===F.current?ze[Fe+1]??null:fe;if(!M||!Ue)return;F.current=Ue.dataset.turnId??null;const mt=Ue.getBoundingClientRect().top-M.getBoundingClientRect().top;M.scrollTo({top:M.scrollTop+mt-8,behavior:"smooth"}),ze.indexOf(Ue)===ze.length-1&&(y==null||y(!1))},[rt,g,y,ee]),t.jsxs(t.Fragment,{children:[t.jsx("section",{className:`flex min-h-0 flex-1 flex-col ${w}`.trim(),children:t.jsx("div",{ref:ee,"data-testid":"thread-scroll-container",onScroll:ut,onWheel:ce,onTouchStart:ne,onTouchMove:Le,onTouchEnd:Z,onTouchCancel:Z,className:"thread-graph-scroll-container min-h-0 flex-1 overflow-y-auto overscroll-contain",style:k>0?{paddingBottom:k}:void 0,children:t.jsxs("div",{ref:ke,className:"thread-graph-scroll-content",children:[t.jsx("div",{ref:je,"aria-hidden":"true",className:"h-px"}),r.length>0&&t.jsx("div",{className:"thread-graph-history-control px-3 pb-1 pt-2 sm:px-5 sm:pb-1.5 sm:pt-3",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 text-xs sm:text-sm",children:[$e>0&&t.jsx("button",{type:"button",onClick:ve,disabled:b,className:"thread-graph-history-button rounded-full border px-2.5 py-1.5 transition",children:b?"Loading earlier...":"Load 3 earlier"}),he&&t.jsx("button",{type:"button",onClick:I,className:"rounded-full border border-amber-300/40 px-2.5 py-1.5 text-amber-200 transition hover:bg-amber-300/10",children:"Load full history"}),t.jsxs("p",{className:"timeline-meta-text",children:["Showing ",ge.length," of ",ye," turns",$e>0?` · ${$e} earlier hidden${Oe>0&&V>0?` (${Oe} loaded)`:""}`:""]})]})}),r.length===0&&!m&&!P&&t.jsx("div",{className:"thread-graph-empty-state px-3 py-8 text-sm sm:px-5",children:"Send the first prompt to start the thread."}),(ge.length>0||P||Pe.leading.length>0||Pe.trailing.length>0)&&t.jsxs("div",{className:"thread-graph-message-list",children:[Pe.leading.length>0?t.jsx(xr,{notes:Pe.leading,onOpenThread:K,onOpenLinkedThread:E}):null,ge.map((M,fe)=>{var ze,Fe,Ue,mt,yt;return t.jsxs("div",{"data-timeline-turn":!0,"data-turn-id":M.id,children:[(((ze=Pe.beforeTurnId.get(M.id))==null?void 0:ze.length)??0)>0?t.jsx(xr,{notes:Pe.beforeTurnId.get(M.id)??[],onOpenThread:K,onOpenLinkedThread:E}):null,(((Fe=Se.beforeTurnId.get(M.id))==null?void 0:Fe.length)??0)>0?t.jsx(ea,{entries:Se.beforeTurnId.get(M.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const Kt=yg(M,P),Yt=(i==null?void 0:i.turnId)===M.id?i:null,At=Qe===M.id?(d==null?void 0:d.items)??null:null,mr=qe===M.id?m:"",ot=s===M.id||Ge&&xe===M.id,un=!!Yt||!!mr||!!(At&&At.length>0),mn=oe(Kt,{forceActive:ot,hasLiveActivity:un});return t.jsx(In,{threadId:e,...z?{adapter:z}:{},turn:Kt,absoluteIndex:Be+fe+1,isCollapsed:mn,livePlan:Yt,liveItems:At,liveOutput:mr,forceActive:ot,onToggleCollapse:O,onOpenExpandedText:W,onOpenCommandDetail:U,onOpenToolCallDetail:ae,onOpenDeferredHistoryItemDetail:X,onBeforeMessageResize:me,...J?{onSelectArtifact:J}:{},scrollRootRef:ee,articleRef:void 0})})(),(((Ue=Pe.afterTurnId.get(M.id))==null?void 0:Ue.length)??0)>0?t.jsx(xr,{notes:Pe.afterTurnId.get(M.id)??[],onOpenThread:K,onOpenLinkedThread:E}):null,(mt=Se.notesByTurnId.get(M.id))!=null&&mt.length||(yt=Se.pendingRequestsByTurnId.get(M.id))!=null&&yt.length?t.jsx(gf,{notes:Se.notesByTurnId.get(M.id)??[],requests:Se.pendingRequestsByTurnId.get(M.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null]},M.id)}),P&&ge.every(M=>M.id!==P.id)&&t.jsxs(t.Fragment,{children:[(((xt=Pe.beforeTurnId.get(P.id))==null?void 0:xt.length)??0)>0?t.jsx(xr,{notes:Pe.beforeTurnId.get(P.id)??[],onOpenThread:K,onOpenLinkedThread:E}):null,(((Rt=Se.beforeTurnId.get(P.id))==null?void 0:Rt.length)??0)>0?t.jsx(ea,{entries:Se.beforeTurnId.get(P.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const M=gt?m:"",fe=s===P.id||Ge&&xe===P.id,ze=!!(et&&et.length>0)||!!M,Fe=oe(P,{forceActive:fe,hasLiveActivity:ze});return t.jsx(In,{threadId:e,...z?{adapter:z}:{},turn:P,absoluteIndex:Ne,isCollapsed:Fe,livePlan:null,liveItems:et,liveOutput:M,forceActive:fe,onToggleCollapse:O,onOpenExpandedText:W,onOpenCommandDetail:U,onOpenToolCallDetail:ae,onOpenDeferredHistoryItemDetail:X,onBeforeMessageResize:me,...J?{onSelectArtifact:J}:{},scrollRootRef:ee})})(),(((wt=Pe.afterTurnId.get(P.id))==null?void 0:wt.length)??0)>0?t.jsx(xr,{notes:Pe.afterTurnId.get(P.id)??[],onOpenThread:K,onOpenLinkedThread:E}):null]})]}),be.length>0&&t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:be.map(M=>t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(It,{threadId:e,item:{id:M.id,kind:"userMessage",text:M.prompt,status:M.status},scrollRootRef:ee,onBeforeMessageResize:me,...z?{adapter:z}:{}}),e&&M.canCancel&&(z!=null&&z.cancelPendingSteer)?t.jsx("div",{className:"flex justify-end px-1",children:t.jsx("button",{type:"button",className:"thread-graph-history-button rounded-full border px-2.5 py-1 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",disabled:H.has(M.id),onClick:()=>{var fe;G(ze=>new Set(ze).add(M.id)),Promise.resolve((fe=z.cancelPendingSteer)==null?void 0:fe.call(z,e,M.id)).catch(()=>{}).finally(()=>{G(ze=>{const Fe=new Set(ze);return Fe.delete(M.id),Fe})})},children:H.has(M.id)?"Canceling...":"Cancel"})}):null]},M.id))}),(Se.trailing.length>0||Pe.trailing.length>0)&&t.jsx(xf,{entries:[...Pe.trailing.map(M=>({kind:"activity",id:M.id,createdAt:M.createdAt,note:M})),...Se.trailing],respondingRequestId:h,onRespondToRequest:u??void 0,onOpenThread:K,onOpenLinkedThread:E}),S&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:t.jsx(It,{threadId:e,item:{id:"ephemeral-plan-decision-note",kind:"userMessage",text:S},scrollRootRef:ee,onBeforeMessageResize:me})}),Ke&&tt&&tt.length>0&&t.jsx(In,{threadId:e,...z?{adapter:z}:{},turn:Ke,absoluteIndex:dt,isCollapsed:ie[Ke.id]??!1,livePlan:(i==null?void 0:i.turnId)===Ke.id?i:null,liveItems:tt,liveOutput:"",forceActive:!0,onToggleCollapse:O,onOpenExpandedText:W,onOpenCommandDetail:U,onOpenToolCallDetail:ae,onOpenDeferredHistoryItemDetail:X,onBeforeMessageResize:me,...J?{onSelectArtifact:J}:{},scrollRootRef:ee}),m&&!A&&!gt&&!it&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:Y?t.jsx(ga,{threadId:e,item:Y,scrollRootRef:ee,onOpenExpandedText:W,onOpenCommandDetail:U,onOpenToolCallDetail:ae,onOpenDeferredHistoryItemDetail:X,onBeforeMessageResize:me,...J?{onSelectArtifact:J}:{},...z?{adapter:z}:{}}):t.jsx(It,{threadId:e,item:{id:"live-agent-message-fallback",kind:"agentMessage",text:m},scrollRootRef:ee,streaming:!0,onBeforeMessageResize:me,...z?{adapter:z}:{}})}),t.jsx("div",{ref:le,"aria-hidden":"true",className:"h-px w-full"})]})})}),t.jsx(Sp,{open:C!==null,title:(C==null?void 0:C.title)??"Full text",text:(C==null?void 0:C.text)??"",onClose:de})]})}var Il=c.memo(jg);function Ng(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}function ra(e){return e.replace(/\r\n/g,`
|
|
3702
|
+
`)}function Bs(e){const r=ra(e),n=r.split(`
|
|
3703
3703
|
`);return r.endsWith(`
|
|
3704
|
-
`)&&n.at(-1)===""&&n.pop(),n}function
|
|
3705
|
-
`).trimEnd()}function jg(e){switch(e){case"ctrl_c":return"";case"ctrl_d":return"";case"esc":return"\x1B";case"tab":return" ";case"up":return"\x1B[A";case"down":return"\x1B[B"}}function Ds(e){return{background:e==="light"?"#f2ede5":"#0c1117",foreground:e==="light"?"#3f3a36":"#d6dde6",cursor:e==="light"?"#3f3a36":"#d6dde6",black:e==="light"?"#d8cfc2":"#0f1720",brightBlack:e==="light"?"#8a7f73":"#475569",red:"#f87171",brightRed:"#fb7185",green:e==="light"?"#16a34a":"#86efac",brightGreen:e==="light"?"#22c55e":"#4ade80",yellow:"#fbbf24",brightYellow:"#fcd34d",blue:e==="light"?"#2563eb":"#93c5fd",brightBlue:e==="light"?"#3b82f6":"#60a5fa",magenta:e==="light"?"#7c3aed":"#c4b5fd",brightMagenta:e==="light"?"#8b5cf6":"#a78bfa",cyan:e==="light"?"#0891b2":"#67e8f9",brightCyan:e==="light"?"#06b6d4":"#22d3ee",white:e==="light"?"#5b5148":"#e2e8f0",brightWhite:e==="light"?"#2c2723":"#f8fafc"}}function zn(e){switch(e){case"not_created":return"Not created";case"creating":return"Creating";case"running":return"Running";case"attached":return"Attached";case"detached":return"Detached";case"exited":return"Exited";case"not_found":return"Missing";case"workspace_missing":return"Workspace missing"}}function hn(e){if(!e)return"";const r=e.replace(/[\\/]+$/,"");return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function fa(e,r){const n=[r==null?void 0:r.trim(),e==null?void 0:e.trim()].filter(Boolean);return n.length>0?n.join(" "):null}function Pn(e){return Math.min(75,Math.max(25,e))}function Ng(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",className:"h-4 w-4 fill-current",children:[t.jsx("path",{fillRule:"evenodd",d:"M14.5 10C16.9853 10 19 7.98528 19 5.5C19 5.01783 18.9242 4.55338 18.7838 4.11791C18.6792 3.79367 18.2734 3.72683 18.0325 3.96772L15.3402 6.66002C15.2098 6.79041 15.0168 6.84163 14.8466 6.77074C14.1172 6.46695 13.5334 5.88351 13.2292 5.15431C13.1582 4.98403 13.2094 4.79088 13.3398 4.66042L16.0327 1.9676C16.2735 1.72672 16.2067 1.32092 15.8825 1.21636C15.4469 1.07588 14.9823 1 14.5 1C12.0147 1 10 3.01472 10 5.5C10 5.59783 10.0031 5.69494 10.0093 5.79122C10.065 6.66418 9.88174 7.59855 9.20974 8.15855L1.98017 14.1832C1.3591 14.7008 1 15.4674 1 16.2759C1 17.7804 2.21962 19 3.7241 19C4.53256 19 5.29925 18.6409 5.81681 18.0198L11.8414 10.7903C12.4014 10.1183 13.3358 9.93497 14.2088 9.99073C14.3051 9.99688 14.4022 10 14.5 10ZM5 16C5 16.5523 4.55228 17 4 17C3.44772 17 3 16.5523 3 16C3 15.4477 3.44772 15 4 15C4.55228 15 5 15.4477 5 16Z",clipRule:"evenodd"}),t.jsx("path",{d:"M14.5 11.5C14.6731 11.5 14.8445 11.4927 15.0138 11.4783L18.7678 15.2323C19.7441 16.2086 19.7441 17.7915 18.7678 18.7678C17.7915 19.7441 16.2086 19.7441 15.2323 18.7678L10.8216 14.3571L12.9938 11.7505C13.0455 11.6885 13.1413 11.6131 13.3357 11.5552C13.5378 11.4951 13.805 11.468 14.1132 11.4877C14.2413 11.4959 14.3702 11.5 14.5 11.5Z"}),t.jsx("path",{d:"M6.00003 4.58582L8.33056 6.91635C8.3027 6.95627 8.27496 6.98497 8.24946 7.00622L6.79994 8.21415L4.58582 6.00003H3.30905C3.11966 6.00003 2.94653 5.89303 2.86184 5.72364L1.1612 2.32237C1.06495 2.12987 1.10268 1.89739 1.25486 1.74521L1.74521 1.25486C1.89739 1.10268 2.12987 1.06495 2.32237 1.1612L5.72364 2.86184C5.89303 2.94653 6.00003 3.11966 6.00003 3.30905V4.58582Z"})]})}function Cg({connected:e}){return e?t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",className:"h-4.5 w-4.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M13.19 8.688a4.5 4.5 0 0 1 1.242 7.244l-4.5 4.5a4.5 4.5 0 0 1-6.364-6.364l1.757-1.757m13.35-.622 1.757-1.757a4.5 4.5 0 0 0-6.364-6.364l-4.5 4.5a4.5 4.5 0 0 0 1.242 7.244"})}):t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",className:"h-4.5 w-4.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M13.181 8.68a4.503 4.503 0 0 1 1.903 6.405m-9.768-2.782L3.56 14.06a4.5 4.5 0 0 0 6.364 6.365l3.129-3.129m5.614-5.615 1.757-1.757a4.5 4.5 0 0 0-6.364-6.365l-4.5 4.5c-.258.26-.479.541-.661.84m1.903 6.405a4.495 4.495 0 0 1-1.242-.88 4.483 4.483 0 0 1-1.062-1.683m6.587 2.345 5.907 5.907m-5.907-5.907L8.898 8.898M2.991 2.99 8.898 8.9"})})}function Bs(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5.5 3.25h5"}),t.jsx("path",{d:"M6.4 2h3.2a.9.9 0 0 1 .9.9v.35h1.3a1.2 1.2 0 0 1 1.2 1.2v7.35a1.2 1.2 0 0 1-1.2 1.2H4.2A1.2 1.2 0 0 1 3 11.8V4.45a1.2 1.2 0 0 1 1.2-1.2h1.3V2.9a.9.9 0 0 1 .9-.9Z"})]})}function Rn({label:e,tone:r="stone"}){const n=r==="rose"?"border-rose-300/35 bg-rose-300/14 text-rose-600 dark:text-rose-50":r==="sky"?"border-sky-300/35 bg-sky-300/14 text-sky-600 dark:text-sky-50":"shell-control-chip border";return t.jsx("span",{className:`inline-flex min-w-[3.45rem] items-center justify-center rounded-full border px-2.5 py-1.5 text-[11px] font-medium tracking-[0.12em] ${n}`,children:e})}var Sg=120,Tg=800,Eg=4e3,Lg=4500,Ig="Shell connection timed out. Reconnecting...";function zg({isCurrentSocket:e,viewerId:r}){return!e||r?null:{connectionError:Ig,isConnecting:!1,settleAttachPromise:!1,closeSocket:!0}}function Pg({isCurrentSocket:e,shellId:r,attachSize:n}){return e?{message:{type:"shell.attach",shellId:r,cols:n.cols,rows:n.rows},shouldScheduleAttachTimeout:!0}:null}function Rg({intentionalDisconnect:e,userDisconnectedShellId:r,shellId:n}){return!e&&r!==n}function Ag({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:s}){return e?{shouldDetachShell:r,shouldScheduleReconnect:Rg({intentionalDisconnect:n,userDisconnectedShellId:a,shellId:s})}:null}function Mg({hasAttachSize:e,hasPendingRetry:r}){return!e&&!r}function Ll({shellId:e,terminalReady:r,isVisible:n,canAttachShell:a,userDisconnectedShellId:s,hasTerminal:o,attachSize:l,hasPendingAttachRetry:i,hasCurrentSocketForShell:d,hasReconnectTimer:h}){return!e||!r||!n||!a||s===e||!o?{type:"skip"}:l===void 0?{type:"measureSize"}:l?d?{type:"reuseSocket",shouldClearAttachRetry:i}:{type:"startAttach",attachSize:l,shouldClearAttachRetry:i,shouldClearReconnectTimer:h}:Mg({hasAttachSize:!1,hasPendingRetry:i})?{type:"scheduleRetry"}:{type:"skip"}}function $g({hasShellId:e,terminalReady:r,workspacePathMissing:n,hasViewer:a,hasPendingAttach:s}){return!e||!r||n?{type:"reject"}:a?{type:"alreadyConnected"}:s?{type:"joinPending"}:{type:"startAttach"}}function _g({shellId:e,userDisconnectedShellId:r}){return{shouldClearUserDisconnectedShellId:!!e&&r===e,intentionalDisconnect:!1,connectionError:null,isConnecting:!0,shouldIncrementReconnectKey:!0}}function Dg({hasShell:e}){return e?null:{viewerId:null,isConnecting:!1,settleAttachPromise:!1,connectionError:null,runtimePromptLabel:null,isCommandRunning:!1,shellSnapshot:"",lastCommandOutput:"",pendingCommand:null,shouldResetTerminal:!0}}function Bg({hasReconnectTimer:e,hasAttachTimeout:r,hasAttachRetry:n}){return{shouldClearReconnectTimer:e,shouldClearAttachTimeout:r,shouldClearAttachRetry:n,settleAttachPromise:!1}}function Il({shellId:e,viewerId:r}){return e&&r?{type:"shell.detach",shellId:e,viewerId:r}:null}function Gg({shellId:e,viewerId:r,hasSocket:n}){return{userDisconnectedShellId:e,intentionalDisconnect:!0,detachMessage:Il({shellId:e,viewerId:r}),shouldCloseSocket:n,shouldClearSocketRef:!0,shouldClearLastSentSize:!0,shouldDetachShell:!!e}}function Fg({shellId:e,viewerId:r,socketReadyState:n,openReadyState:a,hasAttachRetryTimer:s,hasAttachTimeout:o,isCurrentSocket:l}){const i=Il({shellId:e,viewerId:r});return{intentionalDisconnect:!0,shouldClearAttachRetry:s,detachMessage:i,shouldSendDetachMessage:!!(i&&n===a),shouldClearViewer:!0,isConnecting:!1,settleAttachPromise:l?!1:void 0,shouldClearAttachTimeout:o,shouldCloseSocket:!0,shouldClearSocketRef:l}}function Hg({size:e,previousSize:r,shellId:n,viewerId:a,syncBackendSize:s}){return s?(r==null?void 0:r.cols)===e.cols&&r.rows===e.rows?{nextLastSentSize:r,message:null}:{nextLastSentSize:e,message:n&&a?{type:"shell.resize",shellId:n,viewerId:a,cols:e.cols,rows:e.rows}:null}:{nextLastSentSize:r??e,message:null}}function Og(e,r){const n=typeof e.cwdBaseName=="string"?e.cwdBaseName:null,a=typeof e.envPrefix=="string"?e.envPrefix:null;return{data:typeof e.data=="string"?e.data:"",replace:e.replace===!0,cursorX:typeof e.cursorX=="number"?e.cursorX:void 0,cursorY:typeof e.cursorY=="number"?e.cursorY:void 0,paneHeight:typeof e.paneHeight=="number"?e.paneHeight:void 0,promptLabel:fa(n??hn(r),a),isCommandRunning:e.isCommandRunning===!0}}function Wg({currentSnapshot:e,data:r,replace:n,isCommandRunning:a,pendingCommand:s}){if(!r)return{nextSnapshot:e,nextPendingCommand:s,lastCommandOutput:null};const o=ea(n?r:`${e}${r}`);return!n||a||!s?{nextSnapshot:o,nextPendingCommand:s,lastCommandOutput:null}:{nextSnapshot:o,nextPendingCommand:null,lastCommandOutput:yg(s.beforeSnapshot,o,s.command)}}function Ug({event:e,currentViewerId:r}){if(e.type==="shell.output")return null;if(e.type==="shell.connected"){const a=String(e.payload.viewerId??"");return{viewerId:a||null,isConnecting:!1,settleAttachPromise:!!a,isCommandRunning:void 0,connectionError:void 0,intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:{status:"attached",attachedViewerId:a}}}if(e.type==="shell.error")return{viewerId:void 0,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:void 0,connectionError:String(e.payload.message??"Shell connection failed."),intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:e.payload.code==="viewer_conflict"?{status:"detached",attachedViewerId:null}:void 0};if(e.type==="shell.detached"){const a=String(e.payload.viewerId??"");if(!a||a!==r)return null;const s=String(e.payload.reason??"");return{viewerId:null,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:!1,connectionError:s==="replaced"?"This shell connection was taken over by another pane or device.":null,intentionalDisconnect:s==="replaced"?!0:void 0,closeSocket:!0,shellUpdate:{status:"detached",attachedViewerId:null}}}if(e.type==="shell.exited")return{viewerId:null,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:!1,connectionError:void 0,intentionalDisconnect:!0,closeSocket:!0,shellUpdate:{status:e.payload.state==="exited"?"exited":"not_found",attachedViewerId:null}};const n=e.payload.state;return{viewerId:n==="attached"?void 0:null,isConnecting:n==="attached"?void 0:!1,settleAttachPromise:n==="attached"?void 0:!1,isCommandRunning:n==="attached"?void 0:!1,connectionError:void 0,intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:{status:n,attachedViewerId:n==="attached"?void 0:null}}}function zl(e,r,n,a,s){const o=r.replace(/\r\n/g,`
|
|
3704
|
+
`)&&n.at(-1)===""&&n.pop(),n}function Cg(e){const r=e.trim();return r?/(?:[$%#>])\s*$/.test(r):!1}function Sg(e,r){const n=r.trim();if(!n||e.length===0)return e;const[a,...s]=e;if(a===void 0)return e;const o=a.trim();return o===n||o.endsWith(` ${n}`)||o.endsWith(`$ ${n}`)||o.endsWith(`% ${n}`)||o.endsWith(`# ${n}`)||o.endsWith(`> ${n}`)?s:e}function Tg(e,r,n){var d,h;const a=Bs(e),s=Bs(r);let o=0;for(;o<a.length&&o<s.length&&a[o]===s[o];)o+=1;let l=0;for(;l<a.length-o&&l<s.length-o&&a[a.length-1-l]===s[s.length-1-l];)l+=1;let i=s.slice(o,s.length-l);for(i=Sg(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())===""||Cg(i.at(-1)??""));)i.pop();return i.join(`
|
|
3705
|
+
`).trimEnd()}function Eg(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 Gs(e){return{background:e==="light"?"#f2ede5":"#0c1117",foreground:e==="light"?"#3f3a36":"#d6dde6",cursor:e==="light"?"#3f3a36":"#d6dde6",black:e==="light"?"#d8cfc2":"#0f1720",brightBlack:e==="light"?"#8a7f73":"#475569",red:"#f87171",brightRed:"#fb7185",green:e==="light"?"#16a34a":"#86efac",brightGreen:e==="light"?"#22c55e":"#4ade80",yellow:"#fbbf24",brightYellow:"#fcd34d",blue:e==="light"?"#2563eb":"#93c5fd",brightBlue:e==="light"?"#3b82f6":"#60a5fa",magenta:e==="light"?"#7c3aed":"#c4b5fd",brightMagenta:e==="light"?"#8b5cf6":"#a78bfa",cyan:e==="light"?"#0891b2":"#67e8f9",brightCyan:e==="light"?"#06b6d4":"#22d3ee",white:e==="light"?"#5b5148":"#e2e8f0",brightWhite:e==="light"?"#2c2723":"#f8fafc"}}function zn(e){switch(e){case"not_created":return"Not created";case"creating":return"Creating";case"running":return"Running";case"attached":return"Attached";case"detached":return"Detached";case"exited":return"Exited";case"not_found":return"Missing";case"workspace_missing":return"Workspace missing"}}function hn(e){if(!e)return"";const r=e.replace(/[\\/]+$/,"");return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function xa(e,r){const n=[r==null?void 0:r.trim(),e==null?void 0:e.trim()].filter(Boolean);return n.length>0?n.join(" "):null}function Pn(e){return Math.min(75,Math.max(25,e))}function Lg(){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 Ig({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 Fs(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5.5 3.25h5"}),t.jsx("path",{d:"M6.4 2h3.2a.9.9 0 0 1 .9.9v.35h1.3a1.2 1.2 0 0 1 1.2 1.2v7.35a1.2 1.2 0 0 1-1.2 1.2H4.2A1.2 1.2 0 0 1 3 11.8V4.45a1.2 1.2 0 0 1 1.2-1.2h1.3V2.9a.9.9 0 0 1 .9-.9Z"})]})}function Rn({label:e,tone:r="stone"}){const n=r==="rose"?"border-rose-300/35 bg-rose-300/14 text-rose-600 dark:text-rose-50":r==="sky"?"border-sky-300/35 bg-sky-300/14 text-sky-600 dark:text-sky-50":"shell-control-chip border";return t.jsx("span",{className:`inline-flex min-w-[3.45rem] items-center justify-center rounded-full border px-2.5 py-1.5 text-[11px] font-medium tracking-[0.12em] ${n}`,children:e})}var zg=120,Pg=800,Rg=4e3,Ag=4500,Mg="Shell connection timed out. Reconnecting...";function _g({isCurrentSocket:e,viewerId:r}){return!e||r?null:{connectionError:Mg,isConnecting:!1,settleAttachPromise:!1,closeSocket:!0}}function $g({isCurrentSocket:e,shellId:r,attachSize:n}){return e?{message:{type:"shell.attach",shellId:r,cols:n.cols,rows:n.rows},shouldScheduleAttachTimeout:!0}:null}function Dg({intentionalDisconnect:e,userDisconnectedShellId:r,shellId:n}){return!e&&r!==n}function Bg({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:s}){return e?{shouldDetachShell:r,shouldScheduleReconnect:Dg({intentionalDisconnect:n,userDisconnectedShellId:a,shellId:s})}:null}function Gg({hasAttachSize:e,hasPendingRetry:r}){return!e&&!r}function zl({shellId:e,terminalReady:r,isVisible:n,canAttachShell:a,userDisconnectedShellId:s,hasTerminal:o,attachSize:l,hasPendingAttachRetry:i,hasCurrentSocketForShell:d,hasReconnectTimer:h}){return!e||!r||!n||!a||s===e||!o?{type:"skip"}:l===void 0?{type:"measureSize"}:l?d?{type:"reuseSocket",shouldClearAttachRetry:i}:{type:"startAttach",attachSize:l,shouldClearAttachRetry:i,shouldClearReconnectTimer:h}:Gg({hasAttachSize:!1,hasPendingRetry:i})?{type:"scheduleRetry"}:{type:"skip"}}function Fg({hasShellId:e,terminalReady:r,workspacePathMissing:n,hasViewer:a,hasPendingAttach:s}){return!e||!r||n?{type:"reject"}:a?{type:"alreadyConnected"}:s?{type:"joinPending"}:{type:"startAttach"}}function Hg({shellId:e,userDisconnectedShellId:r}){return{shouldClearUserDisconnectedShellId:!!e&&r===e,intentionalDisconnect:!1,connectionError:null,isConnecting:!0,shouldIncrementReconnectKey:!0}}function Og({hasShell:e}){return e?null:{viewerId:null,isConnecting:!1,settleAttachPromise:!1,connectionError:null,runtimePromptLabel:null,isCommandRunning:!1,shellSnapshot:"",lastCommandOutput:"",pendingCommand:null,shouldResetTerminal:!0}}function Wg({hasReconnectTimer:e,hasAttachTimeout:r,hasAttachRetry:n}){return{shouldClearReconnectTimer:e,shouldClearAttachTimeout:r,shouldClearAttachRetry:n,settleAttachPromise:!1}}function Pl({shellId:e,viewerId:r}){return e&&r?{type:"shell.detach",shellId:e,viewerId:r}:null}function Ug({shellId:e,viewerId:r,hasSocket:n}){return{userDisconnectedShellId:e,intentionalDisconnect:!0,detachMessage:Pl({shellId:e,viewerId:r}),shouldCloseSocket:n,shouldClearSocketRef:!0,shouldClearLastSentSize:!0,shouldDetachShell:!!e}}function Vg({shellId:e,viewerId:r,socketReadyState:n,openReadyState:a,hasAttachRetryTimer:s,hasAttachTimeout:o,isCurrentSocket:l}){const i=Pl({shellId:e,viewerId:r});return{intentionalDisconnect:!0,shouldClearAttachRetry:s,detachMessage:i,shouldSendDetachMessage:!!(i&&n===a),shouldClearViewer:!0,isConnecting:!1,settleAttachPromise:l?!1:void 0,shouldClearAttachTimeout:o,shouldCloseSocket:!0,shouldClearSocketRef:l}}function qg({size:e,previousSize:r,shellId:n,viewerId:a,syncBackendSize:s}){return s?(r==null?void 0:r.cols)===e.cols&&r.rows===e.rows?{nextLastSentSize:r,message:null}:{nextLastSentSize:e,message:n&&a?{type:"shell.resize",shellId:n,viewerId:a,cols:e.cols,rows:e.rows}:null}:{nextLastSentSize:r??e,message:null}}function Xg(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:xa(n??hn(r),a),isCommandRunning:e.isCommandRunning===!0}}function Kg({currentSnapshot:e,data:r,replace:n,isCommandRunning:a,pendingCommand:s}){if(!r)return{nextSnapshot:e,nextPendingCommand:s,lastCommandOutput:null};const o=ra(n?r:`${e}${r}`);return!n||a||!s?{nextSnapshot:o,nextPendingCommand:s,lastCommandOutput:null}:{nextSnapshot:o,nextPendingCommand:null,lastCommandOutput:Tg(s.beforeSnapshot,o,s.command)}}function Yg({event:e,currentViewerId:r}){if(e.type==="shell.output")return null;if(e.type==="shell.connected"){const a=String(e.payload.viewerId??"");return{viewerId:a||null,isConnecting:!1,settleAttachPromise:!!a,isCommandRunning:void 0,connectionError:void 0,intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:{status:"attached",attachedViewerId:a}}}if(e.type==="shell.error")return{viewerId:void 0,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:void 0,connectionError:String(e.payload.message??"Shell connection failed."),intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:e.payload.code==="viewer_conflict"?{status:"detached",attachedViewerId:null}:void 0};if(e.type==="shell.detached"){const a=String(e.payload.viewerId??"");if(!a||a!==r)return null;const s=String(e.payload.reason??"");return{viewerId:null,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:!1,connectionError:s==="replaced"?"This shell connection was taken over by another pane or device.":null,intentionalDisconnect:s==="replaced"?!0:void 0,closeSocket:!0,shellUpdate:{status:"detached",attachedViewerId:null}}}if(e.type==="shell.exited")return{viewerId:null,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:!1,connectionError:void 0,intentionalDisconnect:!0,closeSocket:!0,shellUpdate:{status:e.payload.state==="exited"?"exited":"not_found",attachedViewerId:null}};const n=e.payload.state;return{viewerId:n==="attached"?void 0:null,isConnecting:n==="attached"?void 0:!1,settleAttachPromise:n==="attached"?void 0:!1,isCommandRunning:n==="attached"?void 0:!1,connectionError:void 0,intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:{status:n,attachedViewerId:n==="attached"?void 0:null}}}function Rl(e,r,n,a,s){const o=r.replace(/\r\n/g,`
|
|
3706
3706
|
`),l=o.split(`
|
|
3707
3707
|
`);o.endsWith(`
|
|
3708
3708
|
`)&&l.at(-1)===""&&l.pop();let d=l.join(`\r
|
|
3709
|
-
`);if(n!==void 0&&a!==void 0){const u=(s!==void 0?Math.max(0,l.length-s):0)+a,m=Math.max(0,l.length-u-1);m>0&&(d+=`\x1B[${m}A`),d+=`\r\x1B[${n+1}G`}e.reset(),e.write(d,()=>{e.scrollToBottom()})}function
|
|
3710
|
-
`).trimEnd():""}function Vg({clearTimeout:e}){let r=null;const n=s=>{(s==null?void 0:s.timer)!==null&&(s==null?void 0:s.timer)!==void 0&&e(s.timer)};return{hasPending:()=>!!r,joinPending:()=>new Promise(s=>{r==null||r.waiters.push(s)}),start:({timeoutMs:s,setTimeout:o,onTimeout:l})=>new Promise(i=>{const d=o(()=>{r=null,l(),i(!1)},s);r={waiters:[i],timer:d}}),settle:s=>{const o=r;if(o){r=null,n(o);for(const l of o.waiters)l(s)}},clear:()=>{const s=r;r=null,n(s)}}}var Fs={status:"not_created",shellInputEnabled:!1,isConnecting:!1,isCommandRunning:!1,promptLabel:null,error:null,hasShell:!1};function vt(e){return e.status!=="exited"&&e.status!=="not_found"}function qg({shell:e,workspacePathMissing:r}){return!!(e&&!r&&vt(e))}function Kg(e,r){return e.status===r.status&&e.shellInputEnabled===r.shellInputEnabled&&e.isConnecting===r.isConnecting&&e.isCommandRunning===r.isCommandRunning&&e.promptLabel===r.promptLabel&&e.error===r.error&&e.hasShell===r.hasShell}function Xg(e){return(e.activeShellId?e.shells.find(r=>r.id===e.activeShellId&&vt(r)):null)??(e.shell&&vt(e.shell)?e.shell:null)??e.shells.find(vt)??null}function Yg({activeRuntime:e,activeShell:r,busy:n,loading:a,status:s,workspacePathMissing:o}){const l=n||a||s==="creating"||o,i=e.shellInputEnabled?"Disconnect shell":r&&!vt(r)?"Restart shell":r?"Connect shell":"Create shell",d=e.shellInputEnabled?"border-emerald-300/45 bg-emerald-300/18 text-emerald-50 ring-1 ring-emerald-300/20 hover:bg-emerald-300/24":r&&!vt(r)?"border-stone-600 bg-stone-800/90 text-stone-100 hover:border-stone-500 hover:bg-stone-800":o?"border-rose-300/35 bg-rose-300/12 text-rose-100":"border-stone-600 bg-stone-800/90 text-stone-100 hover:border-stone-500 hover:bg-stone-800";return{disabled:l,label:i,className:d}}function Zg({activeRuntime:e,activeShell:r,connectionButtonDisabled:n,connectionButtonLabel:a,isMobileShell:s,busy:o,loading:l,error:i}){return{status:e.status,connectionButtonDisabled:n,connectionButtonLabel:a,shellInputEnabled:e.shellInputEnabled,isConnecting:e.isConnecting,isCommandRunning:e.isCommandRunning,promptLabel:e.promptLabel??(r?fa(hn(r.cwd),null):null),isMobileShell:s,hasShell:!!r,busy:o,loading:l,error:e.error??i}}function Ot(e){return e.current===null?!1:(window.clearTimeout(e.current),e.current=null,!0)}function Jg({attachRetryTimerRef:e,setReconnectKey:r,delayMs:n=Sg}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function Qg({reconnectTimerRef:e,setReconnectKey:r,delayMs:n=Tg}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function ex({shellSocket:e,socketRef:r,viewerIdRef:n,attachTimeoutRef:a,setConnectionError:s,setIsConnecting:o,settleAttachPromise:l,delayMs:i=Eg}){a.current=window.setTimeout(()=>{var h,u,m;a.current=null;const d=zg({isCurrentSocket:!e.socket||((h=r.current)==null?void 0:h.socket)===e.socket,viewerId:n.current});d&&(s(d.connectionError),o(d.isConnecting),l(d.settleAttachPromise),d.closeSocket&&((u=e.close)==null||u.call(e),(m=e.socket)==null||m.close()))},i)}function tx(e){return{...e,status:e.status==="attached"?"detached":e.status,attachedViewerId:null}}function rx({shellId:e,viewerId:r,shellSocket:n,attachRetryTimerRef:a,attachTimeoutRef:s,socketRef:o,openReadyState:l}){var i;return Fg({shellId:e,viewerId:r,socketReadyState:n.socket.readyState,openReadyState:l,hasAttachRetryTimer:a.current!==null,hasAttachTimeout:s.current!==null,isCurrentSocket:((i=o.current)==null?void 0:i.socket)===n.socket})}function nx({closeApplication:e,shellId:r,attachTimeoutRef:n,socketRef:a,reconnectTimerRef:s,setViewerId:o,setIsConnecting:l,settleAttachPromise:i,onShellUpdate:d,setReconnectKey:h}){const u=e.closeAction;return u?(e.shouldClearAttachTimeout&&Ot(n),e.shouldClearSocketRef&&(a.current=null),o(e.viewerId),l(e.isConnecting),i(e.settleAttachPromise),u.shouldDetachShell&&d(r,tx,"detached"),u.shouldScheduleReconnect&&Qg({reconnectTimerRef:s,setReconnectKey:h}),!0):!1}function ax({cleanupAction:e,shellSocket:r,attachRetryTimerRef:n,attachTimeoutRef:a,socketRef:s,intentionalDisconnectRef:o,setViewerId:l,setIsConnecting:i,settleAttachPromise:d}){o.current=e.intentionalDisconnect,e.shouldClearAttachRetry&&Ot(n),e.shouldSendDetachMessage&&e.detachMessage&&r.send(e.detachMessage),l(null),i(e.isConnecting),e.settleAttachPromise!==void 0&&d(e.settleAttachPromise),e.shouldClearAttachTimeout&&Ot(a),r.socket.close(),e.shouldClearSocketRef&&(s.current=null)}function sx({eventShellId:e,shellId:r,socketExists:n,isCurrentSocket:a}){return n&&!a?!1:e===r}function ox(e){return Ll({...e,attachSize:void 0})}function lx({attachSize:e,...r}){return Ll({...r,attachSize:e})}function ix({isCurrentSocket:e,shellId:r,attachSize:n,hasAttachTimeout:a}){const s=Pg({isCurrentSocket:e,shellId:r,attachSize:n});return{openAction:s,shouldClearAttachTimeout:!!(s&&a)}}function dx(e){const r=String(e.payload.viewerId??"");return{viewerId:r||null,settleAttachPromise:!!r,nextShell:n=>({...n,status:"attached",attachedViewerId:r})}}function cx({event:e,shellCwd:r,currentSnapshot:n,pendingCommand:a}){const s=Og(e.payload,r),o=s.data?Wg({currentSnapshot:n,data:s.data,replace:s.replace,isCommandRunning:s.isCommandRunning,pendingCommand:a}):null;return{output:s,snapshotUpdate:o}}function hx({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:s,hasAttachTimeout:o}){const l=Ag({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:s});return{closeAction:l,shouldClearAttachTimeout:!!(l&&o),shouldClearSocketRef:!!l,viewerId:null,isConnecting:!1,settleAttachPromise:!1}}function ux(e,r){return r.shellUpdate?{...e,status:r.shellUpdate.status==="attached"||r.shellUpdate.status==="detached"||r.shellUpdate.status==="exited"||r.shellUpdate.status==="not_found"?r.shellUpdate.status:e.status,attachedViewerId:r.shellUpdate.attachedViewerId===void 0?e.attachedViewerId:r.shellUpdate.attachedViewerId}:e}function mx(e){return e.current}function px({shell:e,shellAdapter:r,canAttachShell:n,terminalReady:a,reconnectKey:s,terminalRef:o,socketRef:l,viewerIdRef:i,shellIdRef:d,reconnectTimerRef:h,attachTimeoutRef:u,attachRetryTimerRef:m,isVisibleRef:f,intentionalDisconnectRef:p,userDisconnectedShellIdRef:g,shellSnapshotRef:k,pendingCommandRef:w,lastCommandOutputRef:x,snapshotCursorRef:j,syncTerminalSizeRef:y,setReconnectKey:b,setViewerId:v,setIsConnecting:S,setConnectionError:N,setRuntimePromptLabel:L,setIsCommandRunning:R,settleAttachPromise:P,onShellUpdate:Q}){const D=e==null?void 0:e.id,Z=e==null?void 0:e.cwd;c.useEffect(()=>{const J=o.current,z={shellId:D??null,terminalReady:a,isVisible:f.current,canAttachShell:n,userDisconnectedShellId:g.current,hasTerminal:!!J,hasPendingAttachRetry:m.current!==null,hasCurrentSocketForShell:!!(l.current&&d.current===D),hasReconnectTimer:h.current!==null};if(ox(z).type==="skip")return;const se=y.current(),_=lx({...z,attachSize:se});if(_.type==="skip"||_.type==="measureSize")return;if(_.type==="scheduleRetry"){Jg({attachRetryTimerRef:m,setReconnectKey:b});return}if(_.shouldClearAttachRetry&&Ot(m),_.type==="reuseSocket"||(_.shouldClearReconnectTimer&&Ot(h),!D||!J))return;const ie=_.attachSize;d.current=D,J.reset(),N(null),v(null),S(!0),p.current=!1;const q=r.connectSocket({onConnected:()=>{var F;const H=u.current,G=ix({isCurrentSocket:((F=l.current)==null?void 0:F.socket)===q.socket,shellId:D,attachSize:ie,hasAttachTimeout:H!==null}),T=G.openAction;T&&(q.send(T.message),G.shouldClearAttachTimeout&&H!==null&&Ot(u),T.shouldScheduleAttachTimeout&&ex({shellSocket:q,socketRef:l,viewerIdRef:i,attachTimeoutRef:u,setConnectionError:N,setIsConnecting:S,settleAttachPromise:P}))},onShellEvent:H=>{var F;if(!sx({eventShellId:H.shellId,shellId:D,socketExists:!!q.socket,isCurrentSocket:((F=l.current)==null?void 0:F.socket)===q.socket}))return;if(H.type==="shell.connected"){Ot(u);const B=dx(H);v(B.viewerId),S(!1),P(B.settleAttachPromise),Q(D,B.nextShell,"attached");return}if(H.type==="shell.output"){const{output:B,snapshotUpdate:E}=cx({event:H,shellCwd:Z,currentSnapshot:k.current,pendingCommand:w.current});j.current={cursorX:B.cursorX,cursorY:B.cursorY,paneHeight:B.paneHeight},L(B.promptLabel),R(B.isCommandRunning),E&&(k.current=E.nextSnapshot,w.current=E.nextPendingCommand,E.lastCommandOutput!==null&&(x.current=E.lastCommandOutput),B.replace?zl(J,B.data,B.cursorX,B.cursorY,B.paneHeight):J.write(B.data));return}const T=Ug({event:H,currentViewerId:i.current});T&&(T.viewerId!==void 0&&v(T.viewerId),T.isConnecting!==void 0&&S(T.isConnecting),T.settleAttachPromise!==void 0&&P(T.settleAttachPromise),T.isCommandRunning!==void 0&&R(T.isCommandRunning),T.connectionError!==void 0&&N(T.connectionError),T.intentionalDisconnect!==void 0&&(p.current=T.intentionalDisconnect),T.shellUpdate&&Q(D,B=>ux(B,T),T.shellUpdate.status),T.closeSocket&&q.socket.close())}});return l.current=q,q.socket.addEventListener("close",()=>{var T;const H=u.current,G=hx({isCurrentSocket:((T=l.current)==null?void 0:T.socket)===q.socket,hadViewer:!!i.current,intentionalDisconnect:p.current,userDisconnectedShellId:g.current,shellId:D,hasAttachTimeout:H!==null});nx({closeApplication:G,shellId:D,attachTimeoutRef:u,socketRef:l,reconnectTimerRef:h,setViewerId:v,setIsConnecting:S,settleAttachPromise:P,onShellUpdate:Q,setReconnectKey:b})}),()=>{const H=mx(i),G=rx({shellId:D,viewerId:H,shellSocket:q,attachRetryTimerRef:m,attachTimeoutRef:u,socketRef:l,openReadyState:WebSocket.OPEN});ax({cleanupAction:G,shellSocket:q,attachRetryTimerRef:m,attachTimeoutRef:u,socketRef:l,intentionalDisconnectRef:p,setViewerId:v,setIsConnecting:S,settleAttachPromise:P})}},[m,u,n,p,f,x,Q,w,s,h,N,R,S,b,L,v,P,Z,D,r,d,k,j,l,y,a,o,g,i])}function An(e){return e.current}var Hs=c.forwardRef(function({paneId:r,shell:n,isActive:a,isVisible:s,isMobileShell:o,effectiveTheme:l,workspacePathMissing:i,shellAdapter:d,onActivate:h,onShellUpdate:u,onRuntimeStateChange:m,onFeedback:f},p){const g=c.useRef(null),k=c.useRef(null),w=c.useRef(null),x=c.useRef(null),j=c.useRef(null),y=c.useRef(null),b=c.useRef(null),v=c.useRef(null),S=c.useRef(!1),N=c.useRef(null),L=c.useRef(""),R=c.useRef(null),P=c.useRef(""),Q=c.useRef(null),D=c.useRef(null),Z=c.useRef({cursorX:void 0,cursorY:void 0,paneHeight:void 0}),J=c.useRef(!1),z=c.useRef(null),te=c.useRef(s),se=c.useRef(o),_=c.useRef(()=>!1),ie=c.useRef(()=>null),q=c.useRef(()=>{}),H=c.useRef(Vg({clearTimeout:window.clearTimeout})),[G,T]=c.useState(null),[F,B]=c.useState(!1),[E,C]=c.useState(null),[W,U]=c.useState(!1),[ae,K]=c.useState(null),[de,ee]=c.useState(null),[ke,le]=c.useState(!1),[je,Ae]=c.useState(0),ce=(n==null?void 0:n.status)??"not_created",ne=qg({shell:n,workspacePathMissing:i}),Le=c.useMemo(()=>fa(hn(n==null?void 0:n.cwd),null),[n==null?void 0:n.cwd]),Y=de??Le,me=c.useCallback(V=>{x.current=V,C(V)},[]),we=c.useCallback(V=>{H.current.settle(V)},[]);c.useEffect(()=>{te.current=s},[s]),c.useEffect(()=>{se.current=o},[o]),c.useEffect(()=>{j.current=(n==null?void 0:n.id)??null},[n==null?void 0:n.id]);const ye=c.useCallback(V=>{const he=w.current,ve=j.current,I=x.current;return!he||!ve||!I?!1:(he.send({type:"shell.input",shellId:ve,viewerId:I,data:V}),!0)},[]);c.useEffect(()=>{_.current=ye},[ye]);const De=c.useCallback(()=>{const V=w.current,he=j.current,ve=x.current;return!V||!he||!ve?!1:(V.send({type:"shell.clear",shellId:he,viewerId:ve}),!0)},[]),Be=c.useCallback(()=>{if(!s||!G)return!1;const V=G.getBoundingClientRect();return V.width>0&&V.height>0},[s,G]),_e=c.useCallback(V=>{const he=g.current,ve=k.current;if(!he||!ve||!Be()||(ve.fit(),he.cols<=0||he.rows<=0))return null;const I={cols:he.cols,rows:he.rows},O=Hg({size:I,previousSize:D.current,shellId:j.current,viewerId:x.current,syncBackendSize:(V==null?void 0:V.syncBackendSize)!==!1});return(V==null?void 0:V.syncBackendSize)===!1||(D.current=O.nextLastSentSize,!O.message)||w.current&&w.current.send(O.message),I},[Be]);c.useEffect(()=>{ie.current=_e},[_e]);const Oe=c.useCallback(V=>{const he=g.current;!he||!Be()||(_e((V==null?void 0:V.syncBackendSize)===void 0?void 0:{syncBackendSize:V.syncBackendSize}),L.current&&!Gs(G)?zl(he,L.current,Z.current.cursorX,Z.current.cursorY,Z.current.paneHeight):he.scrollToBottom(),V!=null&&V.focus&&!o&&he.focus())},[o,Be,_e,G]);return c.useEffect(()=>{q.current=()=>Oe()},[Oe]),c.useEffect(()=>{m({status:E?"attached":ce,shellInputEnabled:!!(E&&n),isConnecting:W,isCommandRunning:ke,promptLabel:Y,error:ae,hasShell:!!n})},[ae,W,ke,m,Y,n,ce,E]),c.useEffect(()=>{if(!G||g.current||J.current)return;let V=!1;return J.current=!0,(async()=>{const[{Terminal:he},{FitAddon:ve}]=await Promise.all([Xe(()=>import("./terminal-vendor-C5bTa-Ka.js").then(oe=>oe.x),__vite__mapDeps([6,2,7])),Xe(()=>import("./terminal-vendor-C5bTa-Ka.js").then(oe=>oe.a),__vite__mapDeps([6,2,7]))]);if(V||!G){J.current=!1;return}const I=new he({cursorBlink:!0,disableStdin:se.current,fontFamily:"IBM Plex Mono, SFMono-Regular, Menlo, monospace",fontSize:13,lineHeight:1.25,scrollback:3e3,theme:Ds(l)}),O=new ve;I.loadAddon(O),I.open(G),g.current=I,k.current=O,ie.current(),I.attachCustomKeyEventHandler(oe=>{if(se.current||oe.type!=="keydown")return!0;if(oe.ctrlKey&&!oe.altKey&&!oe.metaKey&&!oe.shiftKey){const ge=vg(oe.key);if(!ge)return!0;if(_.current(ge))return oe.preventDefault(),!1}return!0}),B(!0),J.current=!1,Q.current=new ResizeObserver(()=>{q.current()}),Q.current.observe(G),z.current=I.onData(oe=>{se.current||_.current(oe)})})(),()=>{var he,ve,I;V=!0,J.current=!1,(he=z.current)==null||he.dispose(),z.current=null,(ve=Q.current)==null||ve.disconnect(),Q.current=null,B(!1),(I=g.current)==null||I.dispose(),g.current=null,k.current=null,D.current=null}},[l,G]),c.useEffect(()=>{var he;const V=Dg({hasShell:!!n});V&&(me(V.viewerId),U(V.isConnecting),we(V.settleAttachPromise),K(V.connectionError),ee(V.runtimePromptLabel),le(V.isCommandRunning),L.current=V.shellSnapshot,P.current=V.lastCommandOutput,R.current=V.pendingCommand,V.shouldResetTerminal&&((he=g.current)==null||he.reset()))},[me,we,n]),c.useEffect(()=>{const V=g.current;V&&(V.options.theme=Ds(l))},[l]),c.useEffect(()=>{const V=g.current;V&&(V.options.disableStdin=o)},[o]),c.useEffect(()=>{if(!s||!F)return;const V=window.requestAnimationFrame(()=>{Oe({focus:a,syncBackendSize:!1}),!w.current&&(n!=null&&n.id)&&N.current!==n.id&&Ae(he=>he+1)});return()=>{window.cancelAnimationFrame(V)}},[a,s,Oe,n==null?void 0:n.id,F]),px({shell:n,shellAdapter:d,canAttachShell:ne,terminalReady:F,reconnectKey:je,terminalRef:g,socketRef:w,viewerIdRef:x,shellIdRef:j,reconnectTimerRef:y,attachTimeoutRef:b,attachRetryTimerRef:v,isVisibleRef:te,intentionalDisconnectRef:S,userDisconnectedShellIdRef:N,shellSnapshotRef:L,pendingCommandRef:R,lastCommandOutputRef:P,snapshotCursorRef:Z,syncTerminalSizeRef:ie,setReconnectKey:Ae,setViewerId:me,setIsConnecting:U,setConnectionError:K,setRuntimePromptLabel:ee,setIsCommandRunning:le,settleAttachPromise:we,onShellUpdate:u}),c.useEffect(()=>()=>{const V=An(y),he=An(b),ve=An(v),I=Bg({hasReconnectTimer:V!==null,hasAttachTimeout:he!==null,hasAttachRetry:ve!==null});I.shouldClearReconnectTimer&&V!==null&&window.clearTimeout(V),I.shouldClearAttachTimeout&&he!==null&&window.clearTimeout(he),I.shouldClearAttachRetry&&ve!==null&&window.clearTimeout(ve),we(I.settleAttachPromise)},[we]),c.useImperativeHandle(p,()=>({disconnect(){const V=w.current,he=j.current,ve=x.current,I=Gg({shellId:he,viewerId:ve,hasSocket:!!V});N.current=I.userDisconnectedShellId,S.current=I.intentionalDisconnect,V&&I.detachMessage&&V.send(I.detachMessage),me(null),U(!1),we(!1),I.shouldCloseSocket&&(V==null||V.socket.close()),w.current=null,D.current=null,I.shouldDetachShell&&he&&u(he,O=>({...O,status:"detached",attachedViewerId:null}),"detached")},reconnect(){const V=$g({hasShellId:!!j.current,terminalReady:F,workspacePathMissing:i,hasViewer:!!x.current,hasPendingAttach:H.current.hasPending()});if(V.type==="reject")return Promise.resolve(!1);if(V.type==="alreadyConnected")return Promise.resolve(!0);if(V.type==="joinPending")return H.current.joinPending();const he=H.current.start({timeoutMs:Lg,setTimeout:window.setTimeout,onTimeout:()=>{U(!1)}}),ve=_g({shellId:j.current,userDisconnectedShellId:N.current});return ve.shouldClearUserDisconnectedShellId&&(N.current=null),S.current=ve.intentionalDisconnect,K(ve.connectionError),U(ve.isConnecting),Ae(I=>I+1),he},sendInput(V){return ye(V)},sendCommand(V){const he={command:V,beforeSnapshot:L.current};if(R.current=he,V.trim()==="clear"){const O=De();return!O&&R.current===he&&(R.current=null),O}const ve=V.endsWith(`
|
|
3709
|
+
`);if(n!==void 0&&a!==void 0){const u=(s!==void 0?Math.max(0,l.length-s):0)+a,m=Math.max(0,l.length-u-1);m>0&&(d+=`\x1B[${m}A`),d+=`\r\x1B[${n+1}G`}e.reset(),e.write(d,()=>{e.scrollToBottom()})}function Hs(e){return e?Array.from(e.querySelectorAll(".xterm-rows > div")).map(n=>n.textContent??"").filter((n,a,s)=>n.length>0||a<s.length-1).join(`
|
|
3710
|
+
`).trimEnd():""}function Zg({clearTimeout:e}){let r=null;const n=s=>{(s==null?void 0:s.timer)!==null&&(s==null?void 0:s.timer)!==void 0&&e(s.timer)};return{hasPending:()=>!!r,joinPending:()=>new Promise(s=>{r==null||r.waiters.push(s)}),start:({timeoutMs:s,setTimeout:o,onTimeout:l})=>new Promise(i=>{const d=o(()=>{r=null,l(),i(!1)},s);r={waiters:[i],timer:d}}),settle:s=>{const o=r;if(o){r=null,n(o);for(const l of o.waiters)l(s)}},clear:()=>{const s=r;r=null,n(s)}}}var Os={status:"not_created",shellInputEnabled:!1,isConnecting:!1,isCommandRunning:!1,promptLabel:null,error:null,hasShell:!1};function vt(e){return e.status!=="exited"&&e.status!=="not_found"}function Jg({shell:e,workspacePathMissing:r}){return!!(e&&!r&&vt(e))}function Qg(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 ex(e){return(e.activeShellId?e.shells.find(r=>r.id===e.activeShellId&&vt(r)):null)??(e.shell&&vt(e.shell)?e.shell:null)??e.shells.find(vt)??null}function tx({activeRuntime:e,activeShell:r,busy:n,loading:a,status:s,workspacePathMissing:o}){const l=n||a||s==="creating"||o,i=e.shellInputEnabled?"Disconnect shell":r&&!vt(r)?"Restart shell":r?"Connect shell":"Create shell",d=e.shellInputEnabled?"border-emerald-300/45 bg-emerald-300/18 text-emerald-50 ring-1 ring-emerald-300/20 hover:bg-emerald-300/24":r&&!vt(r)?"border-stone-600 bg-stone-800/90 text-stone-100 hover:border-stone-500 hover:bg-stone-800":o?"border-rose-300/35 bg-rose-300/12 text-rose-100":"border-stone-600 bg-stone-800/90 text-stone-100 hover:border-stone-500 hover:bg-stone-800";return{disabled:l,label:i,className:d}}function rx({activeRuntime:e,activeShell:r,connectionButtonDisabled:n,connectionButtonLabel:a,isMobileShell:s,busy:o,loading:l,error:i}){return{status:e.status,connectionButtonDisabled:n,connectionButtonLabel:a,shellInputEnabled:e.shellInputEnabled,isConnecting:e.isConnecting,isCommandRunning:e.isCommandRunning,promptLabel:e.promptLabel??(r?xa(hn(r.cwd),null):null),isMobileShell:s,hasShell:!!r,busy:o,loading:l,error:e.error??i}}function Ot(e){return e.current===null?!1:(window.clearTimeout(e.current),e.current=null,!0)}function nx({attachRetryTimerRef:e,setReconnectKey:r,delayMs:n=zg}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function ax({reconnectTimerRef:e,setReconnectKey:r,delayMs:n=Pg}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function sx({shellSocket:e,socketRef:r,viewerIdRef:n,attachTimeoutRef:a,setConnectionError:s,setIsConnecting:o,settleAttachPromise:l,delayMs:i=Rg}){a.current=window.setTimeout(()=>{var h,u,m;a.current=null;const d=_g({isCurrentSocket:!e.socket||((h=r.current)==null?void 0:h.socket)===e.socket,viewerId:n.current});d&&(s(d.connectionError),o(d.isConnecting),l(d.settleAttachPromise),d.closeSocket&&((u=e.close)==null||u.call(e),(m=e.socket)==null||m.close()))},i)}function ox(e){return{...e,status:e.status==="attached"?"detached":e.status,attachedViewerId:null}}function lx({shellId:e,viewerId:r,shellSocket:n,attachRetryTimerRef:a,attachTimeoutRef:s,socketRef:o,openReadyState:l}){var i;return Vg({shellId:e,viewerId:r,socketReadyState:n.socket.readyState,openReadyState:l,hasAttachRetryTimer:a.current!==null,hasAttachTimeout:s.current!==null,isCurrentSocket:((i=o.current)==null?void 0:i.socket)===n.socket})}function ix({closeApplication:e,shellId:r,attachTimeoutRef:n,socketRef:a,reconnectTimerRef:s,setViewerId:o,setIsConnecting:l,settleAttachPromise:i,onShellUpdate:d,setReconnectKey:h}){const u=e.closeAction;return u?(e.shouldClearAttachTimeout&&Ot(n),e.shouldClearSocketRef&&(a.current=null),o(e.viewerId),l(e.isConnecting),i(e.settleAttachPromise),u.shouldDetachShell&&d(r,ox,"detached"),u.shouldScheduleReconnect&&ax({reconnectTimerRef:s,setReconnectKey:h}),!0):!1}function dx({cleanupAction:e,shellSocket:r,attachRetryTimerRef:n,attachTimeoutRef:a,socketRef:s,intentionalDisconnectRef:o,setViewerId:l,setIsConnecting:i,settleAttachPromise:d}){o.current=e.intentionalDisconnect,e.shouldClearAttachRetry&&Ot(n),e.shouldSendDetachMessage&&e.detachMessage&&r.send(e.detachMessage),l(null),i(e.isConnecting),e.settleAttachPromise!==void 0&&d(e.settleAttachPromise),e.shouldClearAttachTimeout&&Ot(a),r.socket.close(),e.shouldClearSocketRef&&(s.current=null)}function cx({eventShellId:e,shellId:r,socketExists:n,isCurrentSocket:a}){return n&&!a?!1:e===r}function hx(e){return zl({...e,attachSize:void 0})}function ux({attachSize:e,...r}){return zl({...r,attachSize:e})}function mx({isCurrentSocket:e,shellId:r,attachSize:n,hasAttachTimeout:a}){const s=$g({isCurrentSocket:e,shellId:r,attachSize:n});return{openAction:s,shouldClearAttachTimeout:!!(s&&a)}}function px(e){const r=String(e.payload.viewerId??"");return{viewerId:r||null,settleAttachPromise:!!r,nextShell:n=>({...n,status:"attached",attachedViewerId:r})}}function fx({event:e,shellCwd:r,currentSnapshot:n,pendingCommand:a}){const s=Xg(e.payload,r),o=s.data?Kg({currentSnapshot:n,data:s.data,replace:s.replace,isCommandRunning:s.isCommandRunning,pendingCommand:a}):null;return{output:s,snapshotUpdate:o}}function gx({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:s,hasAttachTimeout:o}){const l=Bg({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:s});return{closeAction:l,shouldClearAttachTimeout:!!(l&&o),shouldClearSocketRef:!!l,viewerId:null,isConnecting:!1,settleAttachPromise:!1}}function xx(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 bx(e){return e.current}function vx({shell:e,shellAdapter:r,canAttachShell:n,terminalReady:a,reconnectKey:s,terminalRef:o,socketRef:l,viewerIdRef:i,shellIdRef:d,reconnectTimerRef:h,attachTimeoutRef:u,attachRetryTimerRef:m,isVisibleRef:f,intentionalDisconnectRef:p,userDisconnectedShellIdRef:g,shellSnapshotRef:k,pendingCommandRef:w,lastCommandOutputRef:x,snapshotCursorRef:j,syncTerminalSizeRef:y,setReconnectKey:b,setViewerId:v,setIsConnecting:S,setConnectionError:N,setRuntimePromptLabel:L,setIsCommandRunning:R,settleAttachPromise:P,onShellUpdate:Q}){const K=e==null?void 0:e.id,J=e==null?void 0:e.cwd;c.useEffect(()=>{const B=o.current,z={shellId:K??null,terminalReady:a,isVisible:f.current,canAttachShell:n,userDisconnectedShellId:g.current,hasTerminal:!!B,hasPendingAttachRetry:m.current!==null,hasCurrentSocketForShell:!!(l.current&&d.current===K),hasReconnectTimer:h.current!==null};if(hx(z).type==="skip")return;const se=y.current(),$=ux({...z,attachSize:se});if($.type==="skip"||$.type==="measureSize")return;if($.type==="scheduleRetry"){nx({attachRetryTimerRef:m,setReconnectKey:b});return}if($.shouldClearAttachRetry&&Ot(m),$.type==="reuseSocket"||($.shouldClearReconnectTimer&&Ot(h),!K||!B))return;const ie=$.attachSize;d.current=K,B.reset(),N(null),v(null),S(!0),p.current=!1;const q=r.connectSocket({onConnected:()=>{var F;const H=u.current,G=mx({isCurrentSocket:((F=l.current)==null?void 0:F.socket)===q.socket,shellId:K,attachSize:ie,hasAttachTimeout:H!==null}),T=G.openAction;T&&(q.send(T.message),G.shouldClearAttachTimeout&&H!==null&&Ot(u),T.shouldScheduleAttachTimeout&&sx({shellSocket:q,socketRef:l,viewerIdRef:i,attachTimeoutRef:u,setConnectionError:N,setIsConnecting:S,settleAttachPromise:P}))},onShellEvent:H=>{var F;if(!cx({eventShellId:H.shellId,shellId:K,socketExists:!!q.socket,isCurrentSocket:((F=l.current)==null?void 0:F.socket)===q.socket}))return;if(H.type==="shell.connected"){Ot(u);const D=px(H);v(D.viewerId),S(!1),P(D.settleAttachPromise),Q(K,D.nextShell,"attached");return}if(H.type==="shell.output"){const{output:D,snapshotUpdate:E}=fx({event:H,shellCwd:J,currentSnapshot:k.current,pendingCommand:w.current});j.current={cursorX:D.cursorX,cursorY:D.cursorY,paneHeight:D.paneHeight},L(D.promptLabel),R(D.isCommandRunning),E&&(k.current=E.nextSnapshot,w.current=E.nextPendingCommand,E.lastCommandOutput!==null&&(x.current=E.lastCommandOutput),D.replace?Rl(B,D.data,D.cursorX,D.cursorY,D.paneHeight):B.write(D.data));return}const T=Yg({event:H,currentViewerId:i.current});T&&(T.viewerId!==void 0&&v(T.viewerId),T.isConnecting!==void 0&&S(T.isConnecting),T.settleAttachPromise!==void 0&&P(T.settleAttachPromise),T.isCommandRunning!==void 0&&R(T.isCommandRunning),T.connectionError!==void 0&&N(T.connectionError),T.intentionalDisconnect!==void 0&&(p.current=T.intentionalDisconnect),T.shellUpdate&&Q(K,D=>xx(D,T),T.shellUpdate.status),T.closeSocket&&q.socket.close())}});return l.current=q,q.socket.addEventListener("close",()=>{var T;const H=u.current,G=gx({isCurrentSocket:((T=l.current)==null?void 0:T.socket)===q.socket,hadViewer:!!i.current,intentionalDisconnect:p.current,userDisconnectedShellId:g.current,shellId:K,hasAttachTimeout:H!==null});ix({closeApplication:G,shellId:K,attachTimeoutRef:u,socketRef:l,reconnectTimerRef:h,setViewerId:v,setIsConnecting:S,settleAttachPromise:P,onShellUpdate:Q,setReconnectKey:b})}),()=>{const H=bx(i),G=lx({shellId:K,viewerId:H,shellSocket:q,attachRetryTimerRef:m,attachTimeoutRef:u,socketRef:l,openReadyState:WebSocket.OPEN});dx({cleanupAction:G,shellSocket:q,attachRetryTimerRef:m,attachTimeoutRef:u,socketRef:l,intentionalDisconnectRef:p,setViewerId:v,setIsConnecting:S,settleAttachPromise:P})}},[m,u,n,p,f,x,Q,w,s,h,N,R,S,b,L,v,P,J,K,r,d,k,j,l,y,a,o,g,i])}function An(e){return e.current}var Ws=c.forwardRef(function({paneId:r,shell:n,isActive:a,isVisible:s,isMobileShell:o,effectiveTheme:l,workspacePathMissing:i,shellAdapter:d,onActivate:h,onShellUpdate:u,onRuntimeStateChange:m,onFeedback:f},p){const g=c.useRef(null),k=c.useRef(null),w=c.useRef(null),x=c.useRef(null),j=c.useRef(null),y=c.useRef(null),b=c.useRef(null),v=c.useRef(null),S=c.useRef(!1),N=c.useRef(null),L=c.useRef(""),R=c.useRef(null),P=c.useRef(""),Q=c.useRef(null),K=c.useRef(null),J=c.useRef({cursorX:void 0,cursorY:void 0,paneHeight:void 0}),B=c.useRef(!1),z=c.useRef(null),te=c.useRef(s),se=c.useRef(o),$=c.useRef(()=>!1),ie=c.useRef(()=>null),q=c.useRef(()=>{}),H=c.useRef(Zg({clearTimeout:window.clearTimeout})),[G,T]=c.useState(null),[F,D]=c.useState(!1),[E,C]=c.useState(null),[W,U]=c.useState(!1),[ae,X]=c.useState(null),[de,ee]=c.useState(null),[ke,le]=c.useState(!1),[je,Ae]=c.useState(0),ce=(n==null?void 0:n.status)??"not_created",ne=Jg({shell:n,workspacePathMissing:i}),Le=c.useMemo(()=>xa(hn(n==null?void 0:n.cwd),null),[n==null?void 0:n.cwd]),Z=de??Le,me=c.useCallback(V=>{x.current=V,C(V)},[]),we=c.useCallback(V=>{H.current.settle(V)},[]);c.useEffect(()=>{te.current=s},[s]),c.useEffect(()=>{se.current=o},[o]),c.useEffect(()=>{j.current=(n==null?void 0:n.id)??null},[n==null?void 0:n.id]);const ye=c.useCallback(V=>{const he=w.current,ve=j.current,I=x.current;return!he||!ve||!I?!1:(he.send({type:"shell.input",shellId:ve,viewerId:I,data:V}),!0)},[]);c.useEffect(()=>{$.current=ye},[ye]);const De=c.useCallback(()=>{const V=w.current,he=j.current,ve=x.current;return!V||!he||!ve?!1:(V.send({type:"shell.clear",shellId:he,viewerId:ve}),!0)},[]),Be=c.useCallback(()=>{if(!s||!G)return!1;const V=G.getBoundingClientRect();return V.width>0&&V.height>0},[s,G]),$e=c.useCallback(V=>{const he=g.current,ve=k.current;if(!he||!ve||!Be()||(ve.fit(),he.cols<=0||he.rows<=0))return null;const I={cols:he.cols,rows:he.rows},O=qg({size:I,previousSize:K.current,shellId:j.current,viewerId:x.current,syncBackendSize:(V==null?void 0:V.syncBackendSize)!==!1});return(V==null?void 0:V.syncBackendSize)===!1||(K.current=O.nextLastSentSize,!O.message)||w.current&&w.current.send(O.message),I},[Be]);c.useEffect(()=>{ie.current=$e},[$e]);const Oe=c.useCallback(V=>{const he=g.current;!he||!Be()||($e((V==null?void 0:V.syncBackendSize)===void 0?void 0:{syncBackendSize:V.syncBackendSize}),L.current&&!Hs(G)?Rl(he,L.current,J.current.cursorX,J.current.cursorY,J.current.paneHeight):he.scrollToBottom(),V!=null&&V.focus&&!o&&he.focus())},[o,Be,$e,G]);return c.useEffect(()=>{q.current=()=>Oe()},[Oe]),c.useEffect(()=>{m({status:E?"attached":ce,shellInputEnabled:!!(E&&n),isConnecting:W,isCommandRunning:ke,promptLabel:Z,error:ae,hasShell:!!n})},[ae,W,ke,m,Z,n,ce,E]),c.useEffect(()=>{if(!G||g.current||B.current)return;let V=!1;return B.current=!0,(async()=>{const[{Terminal:he},{FitAddon:ve}]=await Promise.all([Ve(()=>import("./terminal-vendor-C5bTa-Ka.js").then(oe=>oe.x),__vite__mapDeps([6,2,7])),Ve(()=>import("./terminal-vendor-C5bTa-Ka.js").then(oe=>oe.a),__vite__mapDeps([6,2,7]))]);if(V||!G){B.current=!1;return}const I=new he({cursorBlink:!0,disableStdin:se.current,fontFamily:"IBM Plex Mono, SFMono-Regular, Menlo, monospace",fontSize:13,lineHeight:1.25,scrollback:3e3,theme:Gs(l)}),O=new ve;I.loadAddon(O),I.open(G),g.current=I,k.current=O,ie.current(),I.attachCustomKeyEventHandler(oe=>{if(se.current||oe.type!=="keydown")return!0;if(oe.ctrlKey&&!oe.altKey&&!oe.metaKey&&!oe.shiftKey){const ge=Ng(oe.key);if(!ge)return!0;if($.current(ge))return oe.preventDefault(),!1}return!0}),D(!0),B.current=!1,Q.current=new ResizeObserver(()=>{q.current()}),Q.current.observe(G),z.current=I.onData(oe=>{se.current||$.current(oe)})})(),()=>{var he,ve,I;V=!0,B.current=!1,(he=z.current)==null||he.dispose(),z.current=null,(ve=Q.current)==null||ve.disconnect(),Q.current=null,D(!1),(I=g.current)==null||I.dispose(),g.current=null,k.current=null,K.current=null}},[l,G]),c.useEffect(()=>{var he;const V=Og({hasShell:!!n});V&&(me(V.viewerId),U(V.isConnecting),we(V.settleAttachPromise),X(V.connectionError),ee(V.runtimePromptLabel),le(V.isCommandRunning),L.current=V.shellSnapshot,P.current=V.lastCommandOutput,R.current=V.pendingCommand,V.shouldResetTerminal&&((he=g.current)==null||he.reset()))},[me,we,n]),c.useEffect(()=>{const V=g.current;V&&(V.options.theme=Gs(l))},[l]),c.useEffect(()=>{const V=g.current;V&&(V.options.disableStdin=o)},[o]),c.useEffect(()=>{if(!s||!F)return;const V=window.requestAnimationFrame(()=>{Oe({focus:a,syncBackendSize:!1}),!w.current&&(n!=null&&n.id)&&N.current!==n.id&&Ae(he=>he+1)});return()=>{window.cancelAnimationFrame(V)}},[a,s,Oe,n==null?void 0:n.id,F]),vx({shell:n,shellAdapter:d,canAttachShell:ne,terminalReady:F,reconnectKey:je,terminalRef:g,socketRef:w,viewerIdRef:x,shellIdRef:j,reconnectTimerRef:y,attachTimeoutRef:b,attachRetryTimerRef:v,isVisibleRef:te,intentionalDisconnectRef:S,userDisconnectedShellIdRef:N,shellSnapshotRef:L,pendingCommandRef:R,lastCommandOutputRef:P,snapshotCursorRef:J,syncTerminalSizeRef:ie,setReconnectKey:Ae,setViewerId:me,setIsConnecting:U,setConnectionError:X,setRuntimePromptLabel:ee,setIsCommandRunning:le,settleAttachPromise:we,onShellUpdate:u}),c.useEffect(()=>()=>{const V=An(y),he=An(b),ve=An(v),I=Wg({hasReconnectTimer:V!==null,hasAttachTimeout:he!==null,hasAttachRetry:ve!==null});I.shouldClearReconnectTimer&&V!==null&&window.clearTimeout(V),I.shouldClearAttachTimeout&&he!==null&&window.clearTimeout(he),I.shouldClearAttachRetry&&ve!==null&&window.clearTimeout(ve),we(I.settleAttachPromise)},[we]),c.useImperativeHandle(p,()=>({disconnect(){const V=w.current,he=j.current,ve=x.current,I=Ug({shellId:he,viewerId:ve,hasSocket:!!V});N.current=I.userDisconnectedShellId,S.current=I.intentionalDisconnect,V&&I.detachMessage&&V.send(I.detachMessage),me(null),U(!1),we(!1),I.shouldCloseSocket&&(V==null||V.socket.close()),w.current=null,K.current=null,I.shouldDetachShell&&he&&u(he,O=>({...O,status:"detached",attachedViewerId:null}),"detached")},reconnect(){const V=Fg({hasShellId:!!j.current,terminalReady:F,workspacePathMissing:i,hasViewer:!!x.current,hasPendingAttach:H.current.hasPending()});if(V.type==="reject")return Promise.resolve(!1);if(V.type==="alreadyConnected")return Promise.resolve(!0);if(V.type==="joinPending")return H.current.joinPending();const he=H.current.start({timeoutMs:Ag,setTimeout:window.setTimeout,onTimeout:()=>{U(!1)}}),ve=Hg({shellId:j.current,userDisconnectedShellId:N.current});return ve.shouldClearUserDisconnectedShellId&&(N.current=null),S.current=ve.intentionalDisconnect,X(ve.connectionError),U(ve.isConnecting),Ae(I=>I+1),he},sendInput(V){return ye(V)},sendCommand(V){const he={command:V,beforeSnapshot:L.current};if(R.current=he,V.trim()==="clear"){const O=De();return!O&&R.current===he&&(R.current=null),O}const ve=V.endsWith(`
|
|
3711
3711
|
`)?V:`${V}
|
|
3712
|
-
`,I=ye(ve);return!I&&R.current===he&&(R.current=null),I},sendControl(V){return V==="clear"?De():ye(jg(V))},async copyLastCommandOutput(){const V=P.current.trim()||Gs(G);if(!V)return f==null||f("failed","Nothing to copy"),!1;try{return await navigator.clipboard.writeText(V),f==null||f("done","Copied"),!0}catch{return f==null||f("failed","Copy failed"),!1}},focus(){var V;(V=g.current)==null||V.focus()},refreshLayout(V){Oe(V)}}),[f,u,Oe,De,ye,me,we,G,F,i]),t.jsxs("div",{className:`relative min-h-0 flex-1 overflow-hidden ${a?"shell-pane-active":""}`,onMouseDown:h,"data-pane-id":r,children:[t.jsx("div",{ref:T,className:`h-full w-full px-2 py-2 sm:px-3 sm:py-3 ${o?"mobile-shell-selectable":""}`,onMouseDown:()=>{var V;h(),(V=g.current)==null||V.focus()}}),a&&t.jsx("div",{className:"pointer-events-none absolute right-2 top-2 rounded-md border border-sky-300/30 bg-sky-300/10 px-2 py-1 text-[10px] uppercase tracking-[0.12em] text-sky-100",children:"Active"})]})}),fx=c.forwardRef(function({threadId:r,shellAdapter:n,isVisible:a=!0,showHeader:s=!0,showFloatingToolbox:o=!0,effectiveTheme:l="dark",loadSplitRatio:i,saveSplitRatio:d,onStateChange:h},u){const m=c.useRef(null),f=c.useRef(null),p=c.useRef(null),g=c.useRef(null),k=c.useRef(null),w=c.useRef(!1),[x,j]=c.useState(null),[y,b]=c.useState(!0),[v,S]=c.useState(!1),[N,L]=c.useState(null),[R,P]=c.useState("primary"),[Q,D]=c.useState(null),[Z,J]=c.useState(null),[z,te]=c.useState("single"),[se,_]=c.useState(50),[ie,q]=c.useState(null),[H,G]=c.useState(""),[T,F]=c.useState(!1),[B,E]=c.useState(!1),[C,W]=c.useState(!1),[U,ae]=c.useState({primary:Fs,secondary:Fs}),[K,de]=c.useState(null),ee=(x==null?void 0:x.state)??"not_created",ke=c.useMemo(()=>(x==null?void 0:x.shells)??[],[x==null?void 0:x.shells]),le=c.useMemo(()=>ke.filter(vt),[ke]),je=c.useMemo(()=>le.find(A=>A.id===Q)??null,[le,Q]),Ae=c.useMemo(()=>le.find(A=>A.id===Z)??null,[le,Z]),ce=R==="secondary"?Ae:je,ne=U[R],Le=(x==null?void 0:x.workspacePathStatus)==="missing",Y=R==="secondary"?f:m,me=Yg({activeRuntime:ne,activeShell:ce,busy:v,loading:y,status:ee,workspacePathMissing:Le}),we=me.disabled,ye=me.label,De=me.className,Be=(K==null?void 0:K.tone)==="done"?"shell-floating-feedback shell-floating-feedback-done":(K==null?void 0:K.tone)==="failed"?"shell-floating-feedback shell-floating-feedback-failed":"shell-floating-feedback",_e=c.useCallback((A,X)=>{de({tone:A,text:X}),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{de(null),p.current=null},1800)},[]),Oe=c.useCallback((A,X,be)=>{j(Se=>{var nt;if(!Se)return Se;const Pe=Se.shells.map($e=>$e.id===A?X($e):$e),rt=((nt=Se.shell)==null?void 0:nt.id)===A?X(Se.shell):Pe.find($e=>{var We;return $e.id===((We=Se.shell)==null?void 0:We.id)})??Se.shell;return{...Se,...be?{state:be}:{},shell:rt,shells:Pe}})},[]),V=c.useCallback(async()=>{b(!0);try{const A=await n.fetchState(r);j(A),L(null)}catch(A){L(A instanceof Error?A.message:"Unable to load shell state.")}finally{b(!1)}},[n,r]);c.useEffect(()=>{V()},[V]),c.useEffect(()=>{const A=i==null?void 0:i(r);if(A==null){_(50);return}const X=typeof A=="number"?A:Number.parseFloat(String(A));_(Number.isFinite(X)?Pn(X):50)},[i,r]),c.useEffect(()=>{if(!x){D(null),J(null);return}const A=Xg(x);D(X=>X&&x.shells.some(be=>be.id===X&&vt(be))?X:(A==null?void 0:A.id)??null),J(X=>{if(z!=="columns")return null;if(X&&x.shells.some(Se=>Se.id===X&&vt(Se)))return X;const be=x.shells.find(Se=>vt(Se)&&Se.id!==(A==null?void 0:A.id));return(be==null?void 0:be.id)??null})},[x,z]),c.useEffect(()=>{z!=="columns"&&(P("primary"),J(null))},[z]),c.useEffect(()=>{if(z!=="columns"||Z||le.length<2)return;const A=le.find(X=>X.id!==(je==null?void 0:je.id))??null;A&&J(A.id)},[le,je==null?void 0:je.id,Z,z]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const A=window.matchMedia("(max-width: 767px), (hover: none) and (pointer: coarse)"),X=()=>{F(A.matches),A.matches||(W(!1),E(!1))};return X(),A.addEventListener("change",X),()=>{A.removeEventListener("change",X)}},[]),c.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current),k.current!==null&&window.cancelAnimationFrame(k.current)},[]);const he=c.useCallback((A,X)=>{ae(be=>{const Se=be[A];return Kg(Se,X)?be:{...be,[A]:X}})},[]),ve=c.useCallback(A=>he("primary",A),[he]),I=c.useCallback(A=>he("secondary",A),[he]),O=c.useCallback(A=>{var be;if((be=A.label)!=null&&be.trim())return A.label.trim();const X=ke.findIndex(Se=>Se.id===A.id);return`Shell ${X>=0?X+1:""}`.trim()},[ke]),oe=c.useCallback(A=>{var X;q(A.id),G(((X=A.label)==null?void 0:X.trim())||O(A))},[O]),ge=c.useCallback(()=>{q(null),G("")},[]),Ne=c.useCallback(async()=>{if(ie){S(!0);try{const A=H.trim(),X=await n.updateShell(ie,{label:A.length>0?A:null});j(be=>{var Se;return be&&{...be,state:be.activeShellId===X.id?X.status:be.state,shell:((Se=be.shell)==null?void 0:Se.id)===X.id?X:be.shell,shells:be.shells.map(Pe=>Pe.id===X.id?X:Pe)}}),q(null),G(""),L(null)}catch(A){L(A instanceof Error?A.message:"Unable to rename shell.")}finally{S(!1)}}},[H,ie,n]),Ce=c.useCallback((A,X)=>{if(A==="primary"){D(X),J(be=>be===X?null:be);return}J(X),D(be=>be===X?null:be)},[]),xe=c.useCallback(A=>{var X,be;if(A==="primary"){(X=m.current)==null||X.disconnect(),D(null),z==="columns"&&P("secondary");return}(be=f.current)==null||be.disconnect(),J(null),P("primary"),te("single")},[z]),Ge=c.useCallback((A,X=R)=>{const be=z==="columns"?X:"primary";Ce(be,A.id),z!=="columns"&&J(null),P(be)},[R,Ce,z]),Me=c.useCallback(async(A=R)=>{var X;if(!w.current){w.current=!0,S(!0);try{const be=await n.createShell(r);j(be);const Se=be.activeShellId??((X=be.shell)==null?void 0:X.id)??null;if(Se){const Pe=z==="columns"?A:"primary";Ce(Pe,Se),z!=="columns"&&J(null),P(Pe)}L(null)}catch(be){L(be instanceof Error?be.message:"Unable to create shell.")}finally{w.current=!1,S(!1)}}},[R,Ce,n,z,r]);c.useEffect(()=>{!a||!x||y||v||Le||ee==="creating"||le.length>0||Me("primary")},[v,Me,a,le.length,y,x,ee,Le]);const Qe=c.useCallback(async(A=(ce==null?void 0:ce.id)??"")=>{if(A){S(!0);try{await n.terminateShell(A),D(X=>X===A?null:X),J(X=>X===A?null:X),await V(),L(null)}catch(X){L(X instanceof Error?X.message:"Unable to terminate shell.")}finally{S(!1)}}},[ce==null?void 0:ce.id,V,n]),et=c.useCallback(async()=>{var A,X;if(!we){if(ne.shellInputEnabled){(A=Y.current)==null||A.disconnect();return}if(!ce||ce.status==="exited"||ce.status==="not_found"){await Me(R);return}await((X=Y.current)==null?void 0:X.reconnect())}},[R,Y,ne.shellInputEnabled,ce,we,Me]),it=c.useCallback(A=>{typeof window>"u"||d==null||d(r,Pn(A))},[d,r]),tt=c.useCallback(()=>{var A,X;(A=m.current)==null||A.refreshLayout({syncBackendSize:!0}),(X=f.current)==null||X.refreshLayout({syncBackendSize:!0})},[]),Ke=c.useCallback(A=>{var rt,nt;if(z!=="columns")return;const X=g.current;if(!X)return;A.preventDefault(),(nt=(rt=A.currentTarget).setPointerCapture)==null||nt.call(rt,A.pointerId);const be=$e=>{const We=X.getBoundingClientRect();if(We.width<=0)return;const ut=Pn(($e-We.left)/We.width*100);_(ut),k.current!==null&&window.cancelAnimationFrame(k.current),k.current=window.requestAnimationFrame(()=>{k.current=null,tt()})},Se=$e=>{be($e.clientX)},Pe=$e=>{be($e.clientX);const We=X.getBoundingClientRect();We.width>0&&it(($e.clientX-We.left)/We.width*100),window.removeEventListener("pointermove",Se),window.removeEventListener("pointerup",Pe)};window.addEventListener("pointermove",Se),window.addEventListener("pointerup",Pe,{once:!0})},[it,tt,z]),dt=c.useCallback((A,X)=>{Ce(X,A.id),P(X)},[Ce]),gt=c.useCallback(async()=>{var X;return await((X=Y.current)==null?void 0:X.copyLastCommandOutput())?!0:(_e("failed","Nothing to copy"),!1)},[Y,_e]);c.useEffect(()=>{h==null||h(Zg({activeRuntime:ne,activeShell:ce,connectionButtonDisabled:we,connectionButtonLabel:ye,isMobileShell:T,busy:v,loading:y,error:N}))},[ne,ce,v,we,ye,N,T,y,h]),c.useImperativeHandle(u,()=>({async toggleConnection(){await et()},sendInput(A){var X;return((X=Y.current)==null?void 0:X.sendInput(A))??!1},sendCommand(A){var X;return((X=Y.current)==null?void 0:X.sendCommand(A))??!1},sendControl(A){var X;return((X=Y.current)==null?void 0:X.sendControl(A))??!1},async copyLastCommandOutput(){var A;return await((A=Y.current)==null?void 0:A.copyLastCommandOutput())??!1},async terminate(){await Qe()},focus(){var A;(A=Y.current)==null||A.focus()},refreshLayout(A){var X,be;(X=m.current)==null||X.refreshLayout(A),z==="columns"&&((be=f.current)==null||be.refreshLayout(A))}}),[Y,et,Qe,z]);const Ve=A=>t.jsx("div",{className:`rounded-md border px-2 py-1.5 text-xs ${A.id===(ce==null?void 0:ce.id)?"border-sky-300/40 bg-sky-300/12 text-sky-50":"border-stone-800 bg-stone-900/40 text-stone-300"}`,children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[ie===A.id?t.jsx("form",{className:"min-w-0 flex-1",onSubmit:X=>{X.preventDefault(),Ne()},children:t.jsx("input",{value:H,onChange:X=>G(X.currentTarget.value),onKeyDown:X=>{X.key==="Escape"&&(X.preventDefault(),ge())},autoFocus:!0,className:"w-full rounded border border-sky-300/35 bg-stone-950/70 px-2 py-1 text-xs text-stone-100 outline-none","aria-label":"Shell name"})}):t.jsxs("button",{type:"button",onClick:()=>Ge(A),onDoubleClick:()=>oe(A),className:"min-w-0 flex-1 text-left",title:A.tmuxSessionName,children:[t.jsx("span",{className:"block truncate",children:O(A)}),t.jsxs("span",{className:"block truncate text-[10px] text-[var(--theme-fg-muted)]",children:[zn(A.status)," · ",hn(A.cwd)||A.cwd]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[ie===A.id?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>void Ne(),className:"rounded border border-sky-300/35 bg-sky-300/12 px-1.5 py-1 text-[10px] text-sky-50",title:"Save shell name",children:"Save"}),t.jsx("button",{type:"button",onClick:ge,className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200",title:"Cancel rename",children:"Cancel"})]}):t.jsx("button",{type:"button",onClick:()=>oe(A),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Rename shell",children:"Rename"}),z==="columns"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>dt(A,"primary"),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Open in left pane",children:"L"}),t.jsx("button",{type:"button",onClick:()=>dt(A,"secondary"),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Open in right pane",children:"R"})]}),t.jsx("button",{type:"button",disabled:v,onClick:()=>void Qe(A.id),className:"rounded border border-rose-300/35 bg-rose-300/12 px-1.5 py-1 text-[10px] text-rose-100 disabled:cursor-not-allowed disabled:opacity-50",title:"Kill shell process",children:"Kill"})]})]})},A.id);return t.jsxs("div",{className:"shell-panel flex min-h-0 flex-1 flex-col",children:[s&&t.jsxs("div",{className:"shell-header shrink-0 border-b px-3 py-3 sm:px-5",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs uppercase tracking-[0.24em] text-[var(--theme-fg-muted)]",children:"Shell"}),t.jsx("p",{className:"mt-1 truncate text-sm text-[var(--theme-fg-soft)]",children:ne.promptLabel??(ce==null?void 0:ce.cwd)??"Create a terminal for this thread."})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("button",{type:"button","aria-label":ye,title:`${ye} (${zn(ne.status)})`,disabled:we,onClick:()=>void et(),className:`inline-flex h-10 w-10 items-center justify-center rounded-full border shadow-lg shadow-stone-950/25 transition disabled:cursor-not-allowed disabled:opacity-60 ${De}`,children:t.jsx(Cg,{connected:ne.shellInputEnabled})}),ce&&t.jsx("button",{type:"button",disabled:v,onClick:()=>void Qe(ce.id),className:"rounded-full border border-rose-300/35 bg-rose-300/12 px-3 py-2 text-sm text-rose-600 transition hover:bg-rose-300/18 dark:text-rose-100 disabled:cursor-not-allowed disabled:opacity-60",children:"Terminate"})]})]}),(N||y||Le)&&t.jsxs("div",{className:"shell-banner mt-3 rounded-2xl border px-3 py-3 text-sm",children:[y&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!y&&Le&&t.jsx("p",{className:"text-rose-600 dark:text-rose-100",children:"Workspace path is missing on this machine. Restore the path before creating a shell."}),!y&&N&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:N})]})]}),t.jsx("div",{className:"min-h-0 flex-1",children:t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("div",{className:"shell-terminal-bar flex shrink-0 items-center gap-2 border-b px-2 py-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-1",children:[t.jsx("span",{className:"min-w-0 truncate text-xs text-[var(--theme-fg-soft)]",children:ce?O(ce):"No live shell process"}),ce&&t.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.12em] text-[var(--theme-fg-muted)]",children:zn(ne.status)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.jsxs("span",{className:"hidden text-xs text-[var(--theme-fg-muted)] sm:inline",children:["Live ",le.length]}),t.jsx("button",{type:"button","aria-expanded":B,"aria-label":B?"Hide shell processes":"Show shell processes",onClick:()=>E(A=>!A),className:"rounded-md border border-stone-700/80 bg-stone-900/50 px-2.5 py-1.5 text-xs text-stone-200 sm:hidden",children:"Processes"})]})]}),B&&t.jsxs("div",{className:"shrink-0 border-b border-stone-800/80 bg-stone-950/55 p-2 sm:hidden",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsx("p",{className:"text-xs uppercase tracking-[0.16em] text-[var(--theme-fg-muted)]",children:"Processes"}),t.jsxs("span",{className:"text-[10px] text-[var(--theme-fg-muted)]",children:[le.length," live"]})]}),t.jsxs("div",{className:"max-h-52 space-y-1 overflow-y-auto",children:[le.map(Ve),le.length===0&&t.jsx("p",{className:"px-2 py-3 text-xs text-[var(--theme-fg-muted)]",children:"No live shell processes"})]}),t.jsx("div",{className:"mt-2 flex justify-end border-t border-stone-800/80 pt-2",children:t.jsx("button",{type:"button","aria-label":"New shell",title:"New shell",disabled:v||y||Le,onClick:()=>void Me(R),className:"inline-flex h-8 w-8 items-center justify-center rounded-md border border-sky-300/35 bg-sky-300/12 text-base leading-none text-sky-50 disabled:cursor-not-allowed disabled:opacity-50",children:"+"})})]}),ee==="not_created"||Le?t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"shell-empty-state max-w-md rounded-[1.6rem] border px-6 py-8",children:[t.jsx("p",{className:"text-base font-medium text-[var(--theme-fg)]",children:"Durable thread shell"}),t.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--theme-fg-muted)]",children:"The shell runs under a supervisor-managed PTY and reconnects after browser disconnects. Create it explicitly when you want to inspect or take over the workspace."}),!Le&&t.jsx("button",{type:"button",disabled:v||y,onClick:()=>void Me("primary"),className:"mt-5 rounded-md border border-sky-300/35 bg-sky-300/12 px-3 py-2 text-sm text-sky-50 disabled:cursor-not-allowed disabled:opacity-50",children:"New Shell"})]})}):t.jsxs("div",{className:"grid h-full min-h-0 grid-cols-1 gap-2 p-2 sm:grid-cols-[minmax(0,1fr)_16rem] sm:p-3",children:[t.jsxs("div",{className:"shell-terminal-frame relative min-h-0 overflow-hidden rounded-[1.4rem] border shadow-inner",children:[!s&&(N||y||Le)&&t.jsxs("div",{className:"shell-banner absolute left-2 right-2 top-2 z-10 rounded-2xl border px-3 py-3 text-sm backdrop-blur sm:left-3 sm:right-3 sm:top-3",children:[y&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!y&&Le&&t.jsx("p",{className:"text-rose-600 dark:text-rose-100",children:"Workspace path is missing on this machine. Restore the path before creating a shell."}),!y&&N&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:N})]}),t.jsxs("div",{ref:g,className:`relative grid h-full min-h-0 ${z==="columns"?"grid-cols-1 sm:grid-cols-[var(--shell-left)_0.35rem_var(--shell-right)]":"grid-cols-1"}`,style:z==="columns"?{"--shell-left":`${se}fr`,"--shell-right":`${100-se}fr`}:void 0,"data-shell-split-ratio":se,children:[t.jsx(Hs,{ref:m,paneId:"primary",shell:je,isActive:R==="primary",isVisible:a,isMobileShell:T,effectiveTheme:l,workspacePathMissing:Le,shellAdapter:n,onActivate:()=>P("primary"),onShellUpdate:Oe,onRuntimeStateChange:ve,onFeedback:_e}),z==="columns"&&t.jsx("button",{type:"button",onClick:()=>xe("primary"),className:"absolute left-2 top-2 z-10 rounded-md border border-stone-700/80 bg-stone-950/70 px-2 py-1 text-[10px] text-stone-200 hover:border-rose-300/40",title:"Close left pane",children:"Close"}),z==="columns"&&t.jsx("button",{type:"button","aria-label":"Resize shell panes",title:"Resize shell panes",onPointerDown:Ke,className:"hidden cursor-col-resize border-x border-stone-800/80 bg-stone-900/60 transition hover:border-sky-300/40 hover:bg-sky-300/10 sm:block"}),z==="columns"&&t.jsxs("div",{className:"relative min-h-0 border-t border-stone-800/80 sm:border-l sm:border-t-0",children:[t.jsx(Hs,{ref:f,paneId:"secondary",shell:Ae,isActive:R==="secondary",isVisible:a,isMobileShell:T,effectiveTheme:l,workspacePathMissing:Le,shellAdapter:n,onActivate:()=>P("secondary"),onShellUpdate:Oe,onRuntimeStateChange:I,onFeedback:_e}),t.jsx("button",{type:"button",onClick:()=>xe("secondary"),className:"absolute left-2 top-2 z-10 rounded-md border border-stone-700/80 bg-stone-950/70 px-2 py-1 text-[10px] text-stone-200 hover:border-rose-300/40",title:"Close right pane",children:"Close"})]})]}),o&&T&&t.jsxs("div",{className:"pointer-events-none absolute bottom-3 right-3 z-20 flex flex-col items-end gap-2",children:[K&&t.jsx("div",{className:`pointer-events-auto rounded-full border px-3 py-1.5 text-[11px] shadow-lg shadow-stone-950/30 backdrop-blur ${Be}`,children:K.text}),C&&t.jsx("div",{className:"shell-toolbox pointer-events-auto rounded-[1.2rem] border p-2 shadow-2xl backdrop-blur",children:t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx("button",{type:"button",onClick:()=>{_e("idle","Use the prompt box tools to paste")},className:"inline-flex items-center justify-center rounded-full border border-sky-300/35 bg-sky-300/12 px-2.5 py-2 text-sky-600 dark:text-sky-50",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Bs,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:()=>void gt(),className:"shell-toolbox-copy inline-flex items-center justify-center rounded-full border px-2.5 py-2",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Bs,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:!ne.shellInputEnabled,onClick:()=>{var A;(A=Y.current)!=null&&A.sendControl("clear")?_e("done","Cleared"):_e("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(Rn,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!ne.shellInputEnabled||!ne.isCommandRunning,onClick:()=>{var A;(A=Y.current)!=null&&A.sendInput("")?_e("done","Sent Ctrl-C"):_e("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(Rn,{label:"CTRL-C",tone:"rose"})}),["ctrl_d","esc","tab","up","down"].map(A=>t.jsx("button",{type:"button",disabled:!ne.shellInputEnabled,onClick:()=>{var X;(X=Y.current)!=null&&X.sendControl(A)?_e("done",`Sent ${A.toUpperCase().replace("_","-")}`):_e("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(Rn,{label:A.toUpperCase().replace("_","-"),tone:"stone"})},A))]})}),t.jsx("button",{type:"button","aria-expanded":C,"aria-label":C?"Close shell tools":"Open shell tools",onClick:()=>W(A=>!A),className:"shell-toolbox-trigger pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-2xl backdrop-blur transition",children:t.jsx(Ng,{})})]})]}),t.jsxs("aside",{className:"hidden min-h-0 overflow-hidden rounded-[1rem] border border-stone-800/80 bg-stone-950/30 p-2 sm:flex sm:flex-col",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsx("p",{className:"text-xs uppercase tracking-[0.16em] text-[var(--theme-fg-muted)]",children:"Processes"}),t.jsxs("span",{className:"text-[10px] text-[var(--theme-fg-muted)]",children:[le.length," live"]})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-1 overflow-y-auto",children:[le.map(Ve),le.length===0&&t.jsx("p",{className:"px-2 py-3 text-xs text-[var(--theme-fg-muted)]",children:"No live shell processes"})]}),t.jsx("div",{className:"mt-2 flex justify-end border-t border-stone-800/80 pt-2",children:t.jsx("button",{type:"button","aria-label":"New shell",title:"New shell",disabled:v||y||Le,onClick:()=>void Me(R),className:"inline-flex h-8 w-8 items-center justify-center rounded-md border border-sky-300/35 bg-sky-300/12 text-base leading-none text-sky-50 disabled:cursor-not-allowed disabled:opacity-50",children:"+"})})]})]})]})})]})}),gx=c.lazy(async()=>({default:(await Promise.resolve().then(()=>(bu(),sl))).ThreadGraphWorkspacePanel}));function xx(){return t.jsx("div",{className:"flex h-full min-h-0 flex-1 items-center justify-center px-4 text-sm text-[var(--theme-fg-muted)]",children:"Loading workspace..."})}function Pl(e){return t.jsx(c.Suspense,{fallback:t.jsx(xx,{}),children:t.jsx(gx,{...e})})}c.memo(Pl);function $x({open:e,title:r,description:n,confirmLabel:a="Delete",busy:s=!1,onCancel:o,onConfirm:l}){return c.useEffect(()=>{if(!e)return;function i(d){d.key==="Escape"&&!s&&o()}return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[s,o,e]),e?Qr.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[95] flex items-center justify-center p-4 sm:p-6",children:[t.jsx("button",{type:"button","aria-label":"Close confirmation dialog",onClick:o,disabled:s,className:"absolute inset-0 bg-stone-950/78 backdrop-blur-sm disabled:cursor-not-allowed"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":r,className:"relative z-[1] w-full max-w-md rounded-[1.6rem] border border-stone-700 bg-stone-900 p-5 shadow-2xl shadow-stone-950/40 sm:p-6",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium text-stone-100",children:r}),t.jsx("p",{className:"mt-2 text-sm leading-6 text-stone-400",children:n})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:o,disabled:s,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-stone-700 text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsxs("div",{className:"mt-5 flex items-center justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:o,disabled:s,className:"rounded-full border border-stone-700 px-4 py-2 text-sm font-medium text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),t.jsx("button",{type:"button",onClick:()=>void l(),disabled:s,className:"ui-action-danger rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:s?"Deleting...":a})]})]})]}),document.body):null}function bx(e){if(!e)return"No time";const r=new Date(e);return Number.isNaN(r.getTime())?e:r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function vx(e){switch(e){case"inProgress":return"running";case"completed":return"completed";case"interrupted":return"interrupted";case"failed":return"failed"}}function kx(e){switch(e){case"latest-3":return"Latest 3";case"latest-10":return"Latest 10";case"latest-20":return"Latest 20";case"all-loaded":return"All loaded";case"custom":return"Custom"}}function wx(e){switch(e){case"latest-3":return 3;case"latest-10":return 10;case"latest-20":return 20;default:return null}}function yx(e){return e==="read"?"View only":"Collaborator"}function jx(e){switch(e){case"write":return"Workspace write";case"read":return"Workspace read";case"none":default:return"No workspace"}}function _x({open:e,busy:r=!1,turnsState:n,shareAvailable:a=!1,shareUnavailableMessage:s="Relay sharing will be enabled after the relay permission model is connected.",shareState:o,initialMode:l="pdf",onCancel:i,onLoadTurns:d,onExport:h,onCreateShare:u,onRevokeShare:m,onOpenDeviceSharing:f}){var F,B,E;const p=c.useMemo(()=>{var C;return((C=n.data)==null?void 0:C.turns)??[]},[(F=n.data)==null?void 0:F.turns]),[g,k]=c.useState(l),[w,x]=c.useState("latest-10"),[j,y]=c.useState(()=>new Set),[b,v]=c.useState(!0),[S,N]=c.useState(""),[L,R]=c.useState("read"),[P,Q]=c.useState("none"),[D,Z]=c.useState(""),[J,z]=c.useState(()=>typeof document<"u"&&!document.documentElement.classList.contains("dark")?"light":"dark");if(c.useEffect(()=>{e&&(k(l),x("latest-10"),v(!0),N(""),R("read"),Q("none"),Z(""),d())},[l,d,e]),c.useEffect(()=>{e&&p.length>0&&y(new Set(p.slice(0,10).map(C=>C.turnId)))},[e,p]),c.useEffect(()=>{if(!e)return;function C(W){W.key==="Escape"&&!r&&i()}return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[r,i,e]),c.useEffect(()=>{if(!e)return;const C=document.querySelector(".thread-ui-shell"),W=()=>C?C.getAttribute("data-theme-effective")==="dark"||C.classList.contains("dark")||C.classList.contains("thread-ui-theme-dark")?"dark":"light":document.documentElement.classList.contains("dark")?"dark":"light";if(z(W()),!C)return;const U=new MutationObserver(()=>z(W()));return U.observe(C,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>U.disconnect()},[e]),!e)return null;const te=wx(w),se=te!==null?Math.min(te,((B=n.data)==null?void 0:B.totalTurnCount)??te):w==="all-loaded"?p.length:j.size,_=!r&&g!=="share"&&(te!==null||w==="all-loaded"||j.size>0),ie=!r&&a&&!!u&&S.trim().length>0;function q(C){y(W=>{const U=new Set(W);return U.has(C)?U.delete(C):U.add(C),U})}function H(){if(g==="share")return;const C={format:g,...te!==null?{mode:"latest",limit:te}:w==="all-loaded"?{mode:"selected",turnIds:p.map(W=>W.turnId)}:{mode:"selected",turnIds:[...j]},profile:"review",options:{includeTokenAndPrice:b}};h(C)}function G(C){C.preventDefault(),ie&&(u==null||u({targetIdentifier:S.trim(),threadAccess:L,workspaceAccess:P,label:D.trim()||null}))}const T=[{mode:"pdf",label:"PDF"},{mode:"html",label:"HTML"},{mode:"share",label:"Share"}];return Qr.createPortal(t.jsxs("div",{className:`thread-export-dialog-root thread-ui-theme-${J} fixed inset-0 z-[96] flex items-end justify-center p-0 sm:items-center sm:p-6`,"data-theme-effective":J,children:[t.jsx("button",{type:"button","aria-label":"Close thread actions",onClick:i,disabled:r,className:"thread-export-dialog-backdrop absolute inset-0 backdrop-blur-sm disabled:cursor-not-allowed"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Thread actions",className:"thread-export-dialog-panel relative z-[1] flex max-h-[min(48rem,calc(100vh-1rem))] w-full max-w-2xl flex-col rounded-t-[1.6rem] border shadow-2xl sm:rounded-[1.6rem]",children:[t.jsxs("div",{className:"thread-export-dialog-header flex items-start justify-between gap-3 border-b px-5 py-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-export-dialog-title text-sm font-semibold",children:"Thread actions"}),t.jsx("p",{className:"thread-export-dialog-subtitle mt-1 text-xs",children:"Export a review copy or share this thread."})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:i,disabled:r,className:"thread-export-dialog-icon-button inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border transition disabled:cursor-not-allowed disabled:opacity-60",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-auto px-5 py-4",children:[t.jsx("div",{className:"thread-export-dialog-segment inline-flex rounded-full border p-1",children:T.map(C=>t.jsx("button",{type:"button",onClick:()=>k(C.mode),className:`rounded-full px-3 py-1.5 text-sm transition ${g===C.mode?"ui-status-warning":"thread-export-dialog-muted-action"}`,children:C.label},C.mode))}),g==="share"?t.jsxs("form",{id:"thread-actions-share-form",className:"mt-4 space-y-4",onSubmit:G,children:[a?null:t.jsx("p",{className:"thread-export-dialog-box thread-export-dialog-subtitle rounded-2xl border px-3 py-3 text-sm",children:s}),a&&f?t.jsxs("div",{className:"thread-export-dialog-box flex flex-wrap items-center justify-between gap-3 rounded-2xl border px-3 py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-export-dialog-strong text-sm font-medium",children:"Share this thread"}),t.jsx("p",{className:"thread-export-dialog-subtitle mt-1 text-xs",children:"Need broader access? Share the whole device from Relay Portal."})]}),t.jsx("button",{type:"button",className:"thread-export-dialog-secondary-button rounded-full border px-3 py-1.5 text-xs font-medium transition",disabled:r,onClick:f,children:"Share whole device"})]}):null,t.jsxs("label",{className:"thread-export-dialog-body-text block text-sm",children:["Relay identifier",t.jsx("input",{className:"thread-export-dialog-box mt-2 w-full rounded-xl border bg-transparent px-3 py-2 outline-none",disabled:!a||r,onChange:C=>N(C.target.value),placeholder:"username or email",value:S})]}),t.jsxs("fieldset",{className:"thread-export-dialog-box rounded-2xl border p-3",children:[t.jsx("legend",{className:"thread-export-dialog-subtitle px-1 text-xs",children:"Thread access"}),t.jsx("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[["read","View only"],["control","Collaborator"]].map(([C,W])=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex items-center gap-2 rounded-xl px-2.5 py-2 text-sm",children:[t.jsx("input",{type:"radio",checked:L===C,disabled:!a||r,onChange:()=>R(C)}),W]},C))})]}),t.jsxs("fieldset",{className:"thread-export-dialog-box rounded-2xl border p-3",children:[t.jsx("legend",{className:"thread-export-dialog-subtitle px-1 text-xs",children:"Workspace"}),t.jsx("div",{className:"mt-2 grid gap-2 sm:grid-cols-3",children:[["none","No access"],["read","Read files"],["write","Read and edit"]].map(([C,W])=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex items-center gap-2 rounded-xl px-2.5 py-2 text-sm",children:[t.jsx("input",{type:"radio",checked:P===C,disabled:!a||r,onChange:()=>Q(C)}),W]},C))})]}),t.jsxs("label",{className:"thread-export-dialog-body-text block text-sm",children:["Label",t.jsx("input",{className:"thread-export-dialog-box mt-2 w-full rounded-xl border bg-transparent px-3 py-2 outline-none",disabled:!a||r,onChange:C=>Z(C.target.value),placeholder:"optional",value:D})]}),t.jsxs("div",{className:"thread-export-dialog-box rounded-2xl border",children:[t.jsxs("div",{className:"thread-export-dialog-box-header flex items-center justify-between border-b px-3 py-2.5",children:[t.jsx("p",{className:"thread-export-dialog-strong text-sm font-medium",children:"Shared by me"}),t.jsx("span",{className:"thread-export-dialog-status-pill rounded-full border px-2 py-0.5 text-[10px]",children:(o==null?void 0:o.shares.length)??0})]}),(o==null?void 0:o.status)==="failed"?t.jsx("p",{className:"px-3 py-3 text-sm text-rose-500 dark:text-rose-200",children:o.error}):o!=null&&o.shares.length?t.jsx("div",{className:"divide-y",children:o.shares.map(C=>t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2.5 text-sm",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-export-dialog-strong truncate font-medium",children:C.targetUsername}),t.jsxs("p",{className:"thread-export-dialog-subtitle mt-0.5 text-xs",children:[C.label?`${C.label} · `:"",yx(C.threadAccess)," / ",jx(C.workspaceAccess)]})]}),m?t.jsx("button",{type:"button",className:"thread-export-dialog-secondary-button rounded-full border px-3 py-1.5 text-xs transition",disabled:r,onClick:()=>void m(C.id),children:"Revoke"}):null]},C.id))}):t.jsx("p",{className:"thread-export-dialog-subtitle px-3 py-3 text-sm",children:"No active shares for this thread."})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"thread-export-dialog-body-text mt-4 block text-sm",children:["Turns",t.jsx("select",{className:"thread-export-dialog-box mt-2 w-full rounded-xl border bg-transparent px-3 py-2 outline-none",value:w,onChange:C=>x(C.target.value),children:["latest-3","latest-10","latest-20","all-loaded","custom"].map(C=>t.jsx("option",{value:C,children:kx(C)},C))})]}),w==="custom"?t.jsxs("div",{className:"thread-export-dialog-box mt-4 rounded-2xl border",children:[t.jsxs("div",{className:"thread-export-dialog-box-header flex flex-wrap items-center justify-between gap-2 border-b px-3 py-2.5",children:[t.jsxs("p",{className:"thread-export-dialog-subtitle text-xs",children:["Selected ",j.size," of ",((E=n.data)==null?void 0:E.totalTurnCount)??p.length]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>y(new Set(p.map(C=>C.turnId))),className:"thread-export-dialog-secondary-button rounded-full border px-2.5 py-1 text-xs transition",children:"Select all"}),t.jsx("button",{type:"button",onClick:()=>y(new Set),className:"thread-export-dialog-secondary-button rounded-full border px-2.5 py-1 text-xs transition",children:"Clear"})]})]}),n.status==="loading"?t.jsx("p",{className:"thread-export-dialog-subtitle px-3 py-6 text-sm",children:"Loading turns..."}):n.status==="failed"?t.jsx("p",{className:"px-3 py-6 text-sm text-rose-500 dark:text-rose-200",children:n.error}):t.jsx("div",{className:"max-h-80 overflow-auto p-2",children:p.map(C=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex cursor-pointer items-center gap-3 rounded-xl px-2.5 py-2 text-sm transition",children:[t.jsx("input",{type:"checkbox",checked:j.has(C.turnId),onChange:()=>q(C.turnId),className:"thread-export-dialog-checkbox h-4 w-4"}),t.jsxs("span",{className:"thread-export-dialog-strong shrink-0 text-xs font-medium",children:["Turn ",C.turnNumber]}),t.jsx("span",{className:"thread-export-dialog-subtitle shrink-0 text-xs",children:bx(C.startedAt)}),t.jsx("span",{className:"thread-export-dialog-body-text min-w-0 flex-1 truncate text-left",children:C.userPromptPreview}),t.jsx("span",{className:"thread-export-dialog-status-pill hidden shrink-0 rounded-full border px-2 py-0.5 text-[10px] sm:inline",children:vx(C.status)})]},C.turnId))})]}):null,t.jsxs("div",{className:"thread-export-dialog-body-text mt-4 grid gap-2 text-sm sm:grid-cols-2",children:[t.jsxs("label",{className:"thread-export-dialog-box flex items-center gap-2 rounded-xl border px-3 py-2",children:[t.jsx("input",{type:"checkbox",checked:b,onChange:C=>v(C.target.checked),className:"thread-export-dialog-checkbox h-4 w-4"}),"Token and price"]}),t.jsx("p",{className:"thread-export-dialog-box thread-export-dialog-subtitle flex items-center rounded-xl border px-3 py-2 text-xs",children:g==="html"?"HTML keeps the chat timeline styling and omits raw command output.":"Review exports keep message text readable and omit tool activity."})]})]})]}),t.jsxs("div",{className:"thread-export-dialog-footer flex items-center justify-between gap-3 border-t px-5 py-4",children:[t.jsx("p",{className:"thread-export-dialog-subtitle min-w-0 text-xs",children:g==="share"?a?"Share access is enforced by the relay server.":"Share permissions are not wired yet.":`${se} ${se===1?"turn":"turns"} selected.`}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:i,disabled:r,className:"thread-export-dialog-secondary-button rounded-full border px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),g==="share"?t.jsx("button",{type:"submit",form:"thread-actions-share-form",disabled:!ie,className:"ui-status-warning rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:r?"Sharing...":"Share this thread"}):t.jsx("button",{type:"button",onClick:H,disabled:!_,className:"ui-status-warning rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:r?"Exporting...":`Export ${g.toUpperCase()}`})]})]})]})]}),document.body)}function Nx({detail:e,adapter:r,timelineAdapter:n,TimelineComponent:a=El,liveOutput:s="",beforeTimelineContent:o,composerProps:l,timelineProps:i,transcriptItemCount:d,useFloatingMobileComposer:h=!1,floatingMobileComposerBottomOffset:u=0,composerHostRef:m}){const[f,p]=c.useState(!1),[g,k]=c.useState(0),[w,x]=c.useState(0),[j,y]=c.useState(0),[b,v]=c.useState(!1),S=c.useRef(null),N=i==null?void 0:i.onTailVisibilityChange,L=e.pendingRequests.length>0,R=c.useMemo(()=>{const H=e.pendingSteers??[],G=new Set(H.map(T=>T.clientRequestId).filter(T=>!!T));return[...H.filter(T=>T.delivery==="continuation").map(T=>({id:T.id,prompt:T.prompt,...T.id.startsWith("optimistic-")?{optimistic:!0}:{}})),...((i==null?void 0:i.optimisticSteers)??[]).filter(T=>!G.has(T.clientRequestId)).map(T=>({id:T.id,prompt:T.prompt,optimistic:!0}))]},[e.pendingSteers,i==null?void 0:i.optimisticSteers]),P=c.useMemo(()=>(e.pendingSteers??[]).filter(H=>H.delivery==="steer"),[e.pendingSteers]),Q=c.useMemo(()=>{var H;return l?{...l,pendingPrompts:R,...r.steerPendingPrompt&&((H=l.capabilities)!=null&&H.turns.steer)?{onSteerPendingPrompt:G=>{var T;return(T=r.steerPendingPrompt)==null?void 0:T.call(r,e.thread.id,G)}}:{},...r.cancelPendingSteer?{onCancelPendingPrompt:G=>{var T;return(T=r.cancelPendingSteer)==null?void 0:T.call(r,e.thread.id,G)}}:{}}:null},[r.cancelPendingSteer,r.steerPendingPrompt,l,e.thread.id,R]),D=c.useCallback(H=>{N==null||N(H)},[N]);c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const H=window.matchMedia("(max-width: 639px)"),G=()=>p(H.matches);return G(),H.addEventListener("change",G),()=>{H.removeEventListener("change",G)}},[]),c.useEffect(()=>{var G,T;if(typeof window>"u")return;const H=()=>{const F=window.visualViewport,B=F?Math.max(0,Math.round(window.innerHeight-F.height-F.offsetTop)):0,E=F?Math.max(0,Math.round(window.innerHeight-F.height)):B,C=Math.min(B,E),W=Math.max(0,Math.round(window.innerHeight*.52));y(Math.min(C,W))};return H(),(G=window.visualViewport)==null||G.addEventListener("resize",H),(T=window.visualViewport)==null||T.addEventListener("scroll",H),window.addEventListener("resize",H),()=>{var F,B;(F=window.visualViewport)==null||F.removeEventListener("resize",H),(B=window.visualViewport)==null||B.removeEventListener("scroll",H),window.removeEventListener("resize",H)}},[]),c.useLayoutEffect(()=>{const H=S.current;if(!H||!f){k(0);return}const G=()=>{k(Math.ceil(H.getBoundingClientRect().height))};if(G(),typeof ResizeObserver>"u")return;const T=new ResizeObserver(G);return T.observe(H),()=>{T.disconnect()}},[f,l,L]),c.useLayoutEffect(()=>{var F,B;const H=S.current;if(!H||!f){x(0);return}const G=()=>{const E=H.getBoundingClientRect();x(Math.max(0,Math.ceil(window.innerHeight-E.top)))};G(),window.addEventListener("resize",G),(F=window.visualViewport)==null||F.addEventListener("resize",G),(B=window.visualViewport)==null||B.addEventListener("scroll",G);let T=null;return typeof ResizeObserver<"u"&&(T=new ResizeObserver(G),T.observe(H)),()=>{var E,C;window.removeEventListener("resize",G),(E=window.visualViewport)==null||E.removeEventListener("resize",G),(C=window.visualViewport)==null||C.removeEventListener("scroll",G),T==null||T.disconnect()}},[f,j,b,l,L]),c.useEffect(()=>{if(!f){v(!1);return}const H=T=>{var B;const F=T.target;F instanceof HTMLElement&&((B=S.current)!=null&&B.contains(F))&&v(!0)},G=T=>{var B;const F=T.relatedTarget;F instanceof HTMLElement&&((B=S.current)!=null&&B.contains(F))||v(!1)};return document.addEventListener("focusin",H),document.addEventListener("focusout",G),()=>{document.removeEventListener("focusin",H),document.removeEventListener("focusout",G)}},[f]);const Z=c.useCallback(H=>{S.current=H,m&&(m.current=H)},[m]),J=f&&b?Math.max(0,j-u):0,z=Math.max(g,144),te=Math.max(w,z+J),se=f?te+12:0,_=se>0?{"--thread-graph-chat-scroll-bottom-spacer":`${se}px`}:void 0,ie=h&&f?{bottom:`${u+J}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"}:void 0,q=c.useMemo(()=>{const H=e.thread.status==="running"||e.thread.activeTurnId!==null;return t.jsx(a,{threadId:e.thread.id,turns:e.turns,totalTurnCount:e.totalTurnCount??e.turns.length,pendingRequests:e.pendingRequests,activeTurnId:e.thread.activeTurnId,threadRunning:H,liveOutput:s,className:"thread-timeline-surface min-h-0 flex-1",...i,pendingSteers:P,optimisticSteers:[],adapter:n,onOpenThread:(i==null?void 0:i.onOpenThread)??r.openThread,onTailVisibilityChange:D})},[a,r.openThread,e.pendingRequests,e.thread.activeTurnId,e.thread.id,e.thread.status,e.totalTurnCount,e.turns,D,s,n,i,P]);return t.jsxs("div",{"data-testid":"chat-panel",className:"thread-graph-chat-panel relative flex h-full min-h-0 flex-col",style:_,children:[o,q,t.jsx("div",{className:"thread-chat-usage-footer hidden shrink-0 items-center px-4 py-1 text-[10px] leading-4 sm:flex",children:t.jsxs("span",{className:"min-w-0",children:[e.turns.length," turn",e.turns.length!==1?"s":"",t.jsx("span",{className:"mx-1 text-[var(--theme-border-contrast)]",children:"|"}),d," item",d!==1?"s":""]})}),Q?h?t.jsx("div",{ref:Z,className:"fixed inset-x-0 bottom-0 z-50 overflow-visible sm:hidden",style:ie??{bottom:`${u}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"},children:t.jsx(Kn,{...Q,activeView:"chat",edgeToEdgeMobile:!0,onSubmit:r.sendPrompt})}):t.jsx("div",{ref:Z,className:"thread-graph-composer-host shrink-0",children:t.jsx(Kn,{...Q,activeView:"chat",onSubmit:r.sendPrompt})}):null]})}function Cx(e){return e.turns.reduce((r,n)=>{var s,o;const a=(s=n.tokenUsage)==null?void 0:s.total;return a?{input:r.input+a.inputTokens,output:r.output+a.outputTokens,cache:r.cache+a.cachedInputTokens,cacheWrite:r.cacheWrite+(a.cacheWriteInputTokens??0),priceUsd:r.priceUsd+(((o=n.priceEstimate)==null?void 0:o.totalUsd)??0),pricedTurns:r.pricedTurns+(n.priceEstimate?1:0),turns:r.turns+1}:r},{input:0,output:0,cache:0,cacheWrite:0,priceUsd:0,pricedTurns:0,turns:0})}function Gr(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?"0":e>=1e6?`${(e/1e6).toFixed(e>=1e7?0:1)}m`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(Math.round(e))}function Sx(e){if(!e||e.turns<=0)return"waiting for agent usage";const r=`in ${Gr(e.input)} / out ${Gr(e.output)} / cache read ${Gr(e.cache)}`,n=e.cacheWrite>0?`${r} / cache write ${Gr(e.cacheWrite)}`:r;return e.pricedTurns>0?`${n} / cost ${Nl(e.priceUsd)}`:n}function Tx(e){return!!(e&&typeof e=="object"&&typeof e.id=="string"&&typeof e.kind=="string")}function Ex(e){const r=n=>Array.isArray(n)?n.filter(Tx):[];return{...e,turns:Array.isArray(e.turns)?e.turns.map(n=>({...n,items:r(n.items)})):[],...e.liveItems?{liveItems:{...e.liveItems,items:r(e.liveItems.items)}}:{}}}function Dx({threads:e,detail:r,loading:n,error:a,status:s=null,plugins:o,adapter:l,metaContent:i,settingsContent:d,globalSettingsContent:h,settingsDialogOpen:u,onSettingsDialogOpenChange:m,mobileHeaderAction:f,appMenuButton:p,appNavigationMenu:g,workspaceReturnHref:k,onWorkspaceReturn:w,threadActionsButton:x,surfaceActions:j,floatingPanel:y,workspaceContent:b,workspaceTitle:v,workspaceActions:S,workspaceFeatures:N,workspaceFocusPathRequest:L=null,onNewThreadTitle:R,beforeTimelineContent:P,errorContent:Q,workspaceMissingContent:D,dialogs:Z,currentThreadId:J,currentWorkspaceId:z,currentWorkspaceLabel:te,onCloseAppNavigation:se,className:_="thread-detail-surface relative flex h-full min-h-0 flex-1 flex-col overflow-hidden",activeView:ie="chat",liveOutput:q="",timelineProps:H,composerProps:G,shellComposerProps:T,useFloatingMobileComposer:F=!1,floatingMobileComposerBottomOffset:B=0,composerHostRef:E,shellPanelRef:C,shellEffectiveTheme:W="dark",shellThemeMode:U=W,onShellThemeModeChange:ae,onShellStateChange:K,shellUnavailableContent:de,shellDisconnectedContent:ee,timelineComponent:ke=El,shellPanelComponent:le=fx,shellContent:je,loadingContent:Ae,emptyContent:ce}){const ne=c.useMemo(()=>r?Ex(r):null,[r]),Le=ua(),Y=o??Le??ca(),{getImageAssetUrl:me,loadHistoryItemDetail:we,openWorkspaceFile:ye,openThread:De,cancelPendingSteer:Be}=l,_e=c.useMemo(()=>({...me?{getImageAssetUrl:ge=>me(ge.path)}:{},onOpenLinkedThread:De,...ye?{onOpenWorkspaceFile:ye}:{},...we?{onLoadHistoryItemDetail:we}:{},...Be?{cancelPendingSteer:Be}:{}}),[Be,me,we,ye,De]),Oe=Y.getThreadPanels().some(ge=>ge.kind==="terminal"),V=c.useMemo(()=>ne?Cx(ne):null,[ne]),he=c.useMemo(()=>Sx(V),[V]),ve=c.useMemo(()=>{var ge;return ne?ne.turns.reduce((Ne,Ce)=>Ne+Ce.items.length,((ge=ne.liveItems)==null?void 0:ge.items.length)??0):0},[ne]),I=b??(ne?t.jsx(Pl,{detail:ne,status:s,plugins:Y,workspaceAdapter:l.workspace??null,metaContent:i,settingsContent:d,activeView:ie,features:N,focusPathRequest:L}):null),O=n?Ae??t.jsx("div",{className:"flex flex-1 items-center justify-center px-6 py-12 text-center text-[var(--theme-fg-muted)]",children:"Loading thread detail..."}):ne?t.jsxs("div",{className:_,children:[y?t.jsx("div",{className:"fixed right-3 top-20 z-50 lg:absolute lg:right-4 lg:top-16",children:y}):null,a&&!n&&(Q??t.jsx("div",{className:"shrink-0 border-b border-rose-500/20 bg-rose-500/10 px-5 py-4 text-sm text-rose-100 sm:px-6",children:a})),ne.workspacePathStatus==="missing"&&(D??t.jsxs("div",{className:"shrink-0 border-b border-rose-500/20 bg-rose-500/10 px-5 py-4 text-sm text-rose-100 sm:px-6",children:[t.jsx("p",{className:"font-medium text-rose-50",children:"Workspace path missing"}),t.jsx("p",{className:"mt-1 break-words text-rose-100/90",children:ne.workspace.absPath})]})),t.jsx("div",{className:ie==="chat"?"flex min-h-0 flex-1 flex-col":"hidden",children:t.jsx(Nx,{detail:ne,adapter:l,timelineAdapter:_e,TimelineComponent:ke,liveOutput:q,transcriptItemCount:ve,useFloatingMobileComposer:F,floatingMobileComposerBottomOffset:B,...P?{beforeTimelineContent:P}:{},...G?{composerProps:G}:{},...H?{timelineProps:H}:{},...E?{composerHostRef:E}:{}})}),t.jsxs("div",{className:ie==="shell"?"flex min-h-0 flex-1 flex-col":"hidden",children:[je??(ne.thread.isLoaded&&Oe&&l.shell?t.jsx(le,{ref:C,threadId:ne.thread.id,shellAdapter:l.shell,effectiveTheme:W,isVisible:ie==="shell",showHeader:!1,showFloatingToolbox:!1,...K?{onStateChange:K}:{}}):ne.thread.isLoaded&&!Oe?de??t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center p-4 sm:p-6",children:t.jsxs("div",{className:"thread-empty-surface max-w-md rounded-[1.6rem] border px-6 py-8 text-center",children:[t.jsx("p",{className:"text-base font-medium text-[var(--theme-fg)]",children:"Terminal plugin disabled"}),t.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--theme-fg-muted)]",children:"Enable the Terminal plugin in Settings to use the shell panel."})]})}):ee??t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center p-4 sm:p-6",children:t.jsxs("div",{className:"thread-empty-surface max-w-md rounded-[1.6rem] border px-6 py-8 text-center",children:[t.jsx("p",{className:"text-base font-medium text-[var(--theme-fg)]",children:"Thread disconnected"}),t.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--theme-fg-soft)]",children:"Reconnect this thread before creating or attaching a shell."})]})})),ie==="shell"&&T&&!je?t.jsx(Kn,{...T,activeView:"shell",onSubmit:l.sendPrompt}):null]}),Z]}):ce??t.jsx("div",{className:"flex flex-1 items-center justify-center px-6 py-12 text-center text-[var(--theme-fg-muted)]",children:"Select a thread to inspect."}),oe=t.jsx(kp,{threads:e,status:s,loading:n,error:n?null:a,viewportConstrained:!0,currentThreadId:J??(ne==null?void 0:ne.thread.id),currentThreadLabel:ne==null?void 0:ne.thread.title,currentWorkspaceId:z??(ne==null?void 0:ne.thread.workspaceId),currentWorkspaceLabel:te??(ne==null?void 0:ne.workspace.label),sessionLabel:(ne==null?void 0:ne.thread.providerSessionId)??(ne==null?void 0:ne.thread.id),usageLabel:he,threadActionsButton:x,topbarActions:j,metaContent:i,settingsContent:d,globalSettingsContent:h,...u!==void 0?{settingsDialogOpen:u}:{},...m?{onSettingsDialogOpenChange:m}:{},mobileHeaderAction:f,effectiveTheme:W,themeMode:U,appMenuButton:p,appNavigationMenu:g,workspaceReturnHref:k,...w?{onWorkspaceReturn:w}:{},showMobileAppMenu:!!p,showMobileThreadNavToggle:!0,showMobileNewThreadShortcut:!1,onOpenThread:l.openThread,workspaceContent:I,workspaceTitle:v??"Workspace",workspaceActions:S,...R?{onNewThreadTitle:R}:{},...se?{onCloseAppNavigation:se}:{},...ae?{onThemeModeChange:ae}:{},...l.getThreadHref?{getThreadHref:l.getThreadHref}:{},...l.getNewThreadHref?{getNewThreadHref:l.getNewThreadHref}:{},...l.renderNewThreadDialogContent?{renderNewThreadDialogContent:l.renderNewThreadDialogContent}:{},...l.renameThread?{onRenameThread:l.renameThread}:{},...l.deleteThread?{onDeleteThread:l.deleteThread}:{},children:O});return o?t.jsx(ha.Provider,{value:Y,children:oe}):oe}var Lx={},Ix=[];function Bx({adapter:e=Lx,builtinPlugins:r=Ix,children:n}){const[a,s]=c.useState(()=>Xn(r,[])),[o,l]=c.useState(!1),[i,d]=c.useState(null),h=c.useCallback(async()=>{l(!0),d(null);try{const y=e.fetchPlugins?await e.fetchPlugins():[];s(Xn(r,y))}catch(y){d(y instanceof Error?y.message:"Unable to load plugins.")}finally{l(!1)}},[e,r]);c.useEffect(()=>{h()},[h]);const u=c.useCallback(async(y,b)=>{if(e.updatePlugin){const v=await e.updatePlugin(y,{enabled:b});s(S=>S.map(N=>N.id===v.id?v:N));return}s(v=>v.map(S=>S.id===y?{...S,enabled:b}:S))},[e]),m=c.useCallback(async y=>{if(!e.importPlugin)throw new Error("Plugin import is not available.");const b=await e.importPlugin(y);s(v=>[...v.filter(N=>N.id!==b.id),b])},[e]),f=c.useCallback(async y=>{if(!e.deletePlugin)throw new Error("Plugin uninstall is not available.");const b=await e.deletePlugin(y);s(v=>v.filter(S=>S.id!==b.id))},[e]),p=c.useMemo(()=>{const y=new Set(a.filter(b=>b.enabled).map(b=>b.id));return r.filter(b=>y.has(b.manifest.id))},[r,a]),g=c.useCallback(y=>{var v;const b=p.find(S=>S.renderArtifact&&S.manifest.capabilities.artifactTypes.some(N=>N.type===y.artifact.type));return((v=b==null?void 0:b.renderArtifact)==null?void 0:v.call(b,y))??null},[p]),k=c.useCallback(y=>{for(const b of p)for(const v of b.inlineCodeRenderers??[]){if(!v.languages.includes(y.language.trim().toLowerCase()))continue;const S=v.render(y);if(S)return S}return null},[p]),w=c.useCallback(y=>p.some(b=>!!b.renderArtifact&&b.manifest.capabilities.artifactTypes.some(v=>v.type===y.type)),[p]),x=c.useCallback(()=>p.flatMap(y=>y.threadPanels??[]),[p]),j=c.useMemo(()=>({plugins:a,loading:o,error:i,refresh:h,importPluginManifest:m,setPluginEnabled:u,uninstallPlugin:f,renderArtifact:g,renderInlineCode:k,hasRendererForArtifact:w,getThreadPanels:x}),[i,x,w,m,o,a,h,g,k,u,f]);return t.jsx(ha.Provider,{value:j,children:n})}export{ap as A,$x as C,wp as L,Bx as P,_x as T,ua as a,Dx as b,fx as c,El as d,kp as e,Ut as f,vp as g,sp as t,cl as u};
|
|
3712
|
+
`,I=ye(ve);return!I&&R.current===he&&(R.current=null),I},sendControl(V){return V==="clear"?De():ye(Eg(V))},async copyLastCommandOutput(){const V=P.current.trim()||Hs(G);if(!V)return f==null||f("failed","Nothing to copy"),!1;try{return await navigator.clipboard.writeText(V),f==null||f("done","Copied"),!0}catch{return f==null||f("failed","Copy failed"),!1}},focus(){var V;(V=g.current)==null||V.focus()},refreshLayout(V){Oe(V)}}),[f,u,Oe,De,ye,me,we,G,F,i]),t.jsxs("div",{className:`relative min-h-0 flex-1 overflow-hidden ${a?"shell-pane-active":""}`,onMouseDown:h,"data-pane-id":r,children:[t.jsx("div",{ref:T,className:`h-full w-full px-2 py-2 sm:px-3 sm:py-3 ${o?"mobile-shell-selectable":""}`,onMouseDown:()=>{var V;h(),(V=g.current)==null||V.focus()}}),a&&t.jsx("div",{className:"pointer-events-none absolute right-2 top-2 rounded-md border border-sky-300/30 bg-sky-300/10 px-2 py-1 text-[10px] uppercase tracking-[0.12em] text-sky-100",children:"Active"})]})}),kx=c.forwardRef(function({threadId:r,shellAdapter:n,isVisible:a=!0,showHeader:s=!0,showFloatingToolbox:o=!0,effectiveTheme:l="dark",loadSplitRatio:i,saveSplitRatio:d,onStateChange:h},u){const m=c.useRef(null),f=c.useRef(null),p=c.useRef(null),g=c.useRef(null),k=c.useRef(null),w=c.useRef(!1),[x,j]=c.useState(null),[y,b]=c.useState(!0),[v,S]=c.useState(!1),[N,L]=c.useState(null),[R,P]=c.useState("primary"),[Q,K]=c.useState(null),[J,B]=c.useState(null),[z,te]=c.useState("single"),[se,$]=c.useState(50),[ie,q]=c.useState(null),[H,G]=c.useState(""),[T,F]=c.useState(!1),[D,E]=c.useState(!1),[C,W]=c.useState(!1),[U,ae]=c.useState({primary:Os,secondary:Os}),[X,de]=c.useState(null),ee=(x==null?void 0:x.state)??"not_created",ke=c.useMemo(()=>(x==null?void 0:x.shells)??[],[x==null?void 0:x.shells]),le=c.useMemo(()=>ke.filter(vt),[ke]),je=c.useMemo(()=>le.find(A=>A.id===Q)??null,[le,Q]),Ae=c.useMemo(()=>le.find(A=>A.id===J)??null,[le,J]),ce=R==="secondary"?Ae:je,ne=U[R],Le=(x==null?void 0:x.workspacePathStatus)==="missing",Z=R==="secondary"?f:m,me=tx({activeRuntime:ne,activeShell:ce,busy:v,loading:y,status:ee,workspacePathMissing:Le}),we=me.disabled,ye=me.label,De=me.className,Be=(X==null?void 0:X.tone)==="done"?"shell-floating-feedback shell-floating-feedback-done":(X==null?void 0:X.tone)==="failed"?"shell-floating-feedback shell-floating-feedback-failed":"shell-floating-feedback",$e=c.useCallback((A,Y)=>{de({tone:A,text:Y}),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{de(null),p.current=null},1800)},[]),Oe=c.useCallback((A,Y,be)=>{j(Se=>{var nt;if(!Se)return Se;const Pe=Se.shells.map(_e=>_e.id===A?Y(_e):_e),rt=((nt=Se.shell)==null?void 0:nt.id)===A?Y(Se.shell):Pe.find(_e=>{var We;return _e.id===((We=Se.shell)==null?void 0:We.id)})??Se.shell;return{...Se,...be?{state:be}:{},shell:rt,shells:Pe}})},[]),V=c.useCallback(async()=>{b(!0);try{const A=await n.fetchState(r);j(A),L(null)}catch(A){L(A instanceof Error?A.message:"Unable to load shell state.")}finally{b(!1)}},[n,r]);c.useEffect(()=>{V()},[V]),c.useEffect(()=>{const A=i==null?void 0:i(r);if(A==null){$(50);return}const Y=typeof A=="number"?A:Number.parseFloat(String(A));$(Number.isFinite(Y)?Pn(Y):50)},[i,r]),c.useEffect(()=>{if(!x){K(null),B(null);return}const A=ex(x);K(Y=>Y&&x.shells.some(be=>be.id===Y&&vt(be))?Y:(A==null?void 0:A.id)??null),B(Y=>{if(z!=="columns")return null;if(Y&&x.shells.some(Se=>Se.id===Y&&vt(Se)))return Y;const be=x.shells.find(Se=>vt(Se)&&Se.id!==(A==null?void 0:A.id));return(be==null?void 0:be.id)??null})},[x,z]),c.useEffect(()=>{z!=="columns"&&(P("primary"),B(null))},[z]),c.useEffect(()=>{if(z!=="columns"||J||le.length<2)return;const A=le.find(Y=>Y.id!==(je==null?void 0:je.id))??null;A&&B(A.id)},[le,je==null?void 0:je.id,J,z]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const A=window.matchMedia("(max-width: 767px), (hover: none) and (pointer: coarse)"),Y=()=>{F(A.matches),A.matches||(W(!1),E(!1))};return Y(),A.addEventListener("change",Y),()=>{A.removeEventListener("change",Y)}},[]),c.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current),k.current!==null&&window.cancelAnimationFrame(k.current)},[]);const he=c.useCallback((A,Y)=>{ae(be=>{const Se=be[A];return Qg(Se,Y)?be:{...be,[A]:Y}})},[]),ve=c.useCallback(A=>he("primary",A),[he]),I=c.useCallback(A=>he("secondary",A),[he]),O=c.useCallback(A=>{var be;if((be=A.label)!=null&&be.trim())return A.label.trim();const Y=ke.findIndex(Se=>Se.id===A.id);return`Shell ${Y>=0?Y+1:""}`.trim()},[ke]),oe=c.useCallback(A=>{var Y;q(A.id),G(((Y=A.label)==null?void 0:Y.trim())||O(A))},[O]),ge=c.useCallback(()=>{q(null),G("")},[]),Ne=c.useCallback(async()=>{if(ie){S(!0);try{const A=H.trim(),Y=await n.updateShell(ie,{label:A.length>0?A:null});j(be=>{var Se;return be&&{...be,state:be.activeShellId===Y.id?Y.status:be.state,shell:((Se=be.shell)==null?void 0:Se.id)===Y.id?Y:be.shell,shells:be.shells.map(Pe=>Pe.id===Y.id?Y:Pe)}}),q(null),G(""),L(null)}catch(A){L(A instanceof Error?A.message:"Unable to rename shell.")}finally{S(!1)}}},[H,ie,n]),Ce=c.useCallback((A,Y)=>{if(A==="primary"){K(Y),B(be=>be===Y?null:be);return}B(Y),K(be=>be===Y?null:be)},[]),xe=c.useCallback(A=>{var Y,be;if(A==="primary"){(Y=m.current)==null||Y.disconnect(),K(null),z==="columns"&&P("secondary");return}(be=f.current)==null||be.disconnect(),B(null),P("primary"),te("single")},[z]),Ge=c.useCallback((A,Y=R)=>{const be=z==="columns"?Y:"primary";Ce(be,A.id),z!=="columns"&&B(null),P(be)},[R,Ce,z]),Me=c.useCallback(async(A=R)=>{var Y;if(!w.current){w.current=!0,S(!0);try{const be=await n.createShell(r);j(be);const Se=be.activeShellId??((Y=be.shell)==null?void 0:Y.id)??null;if(Se){const Pe=z==="columns"?A:"primary";Ce(Pe,Se),z!=="columns"&&B(null),P(Pe)}L(null)}catch(be){L(be instanceof Error?be.message:"Unable to create shell.")}finally{w.current=!1,S(!1)}}},[R,Ce,n,z,r]);c.useEffect(()=>{!a||!x||y||v||Le||ee==="creating"||le.length>0||Me("primary")},[v,Me,a,le.length,y,x,ee,Le]);const Qe=c.useCallback(async(A=(ce==null?void 0:ce.id)??"")=>{if(A){S(!0);try{await n.terminateShell(A),K(Y=>Y===A?null:Y),B(Y=>Y===A?null:Y),await V(),L(null)}catch(Y){L(Y instanceof Error?Y.message:"Unable to terminate shell.")}finally{S(!1)}}},[ce==null?void 0:ce.id,V,n]),et=c.useCallback(async()=>{var A,Y;if(!we){if(ne.shellInputEnabled){(A=Z.current)==null||A.disconnect();return}if(!ce||ce.status==="exited"||ce.status==="not_found"){await Me(R);return}await((Y=Z.current)==null?void 0:Y.reconnect())}},[R,Z,ne.shellInputEnabled,ce,we,Me]),it=c.useCallback(A=>{typeof window>"u"||d==null||d(r,Pn(A))},[d,r]),tt=c.useCallback(()=>{var A,Y;(A=m.current)==null||A.refreshLayout({syncBackendSize:!0}),(Y=f.current)==null||Y.refreshLayout({syncBackendSize:!0})},[]),Ke=c.useCallback(A=>{var rt,nt;if(z!=="columns")return;const Y=g.current;if(!Y)return;A.preventDefault(),(nt=(rt=A.currentTarget).setPointerCapture)==null||nt.call(rt,A.pointerId);const be=_e=>{const We=Y.getBoundingClientRect();if(We.width<=0)return;const ut=Pn((_e-We.left)/We.width*100);$(ut),k.current!==null&&window.cancelAnimationFrame(k.current),k.current=window.requestAnimationFrame(()=>{k.current=null,tt()})},Se=_e=>{be(_e.clientX)},Pe=_e=>{be(_e.clientX);const We=Y.getBoundingClientRect();We.width>0&&it((_e.clientX-We.left)/We.width*100),window.removeEventListener("pointermove",Se),window.removeEventListener("pointerup",Pe)};window.addEventListener("pointermove",Se),window.addEventListener("pointerup",Pe,{once:!0})},[it,tt,z]),dt=c.useCallback((A,Y)=>{Ce(Y,A.id),P(Y)},[Ce]),gt=c.useCallback(async()=>{var Y;return await((Y=Z.current)==null?void 0:Y.copyLastCommandOutput())?!0:($e("failed","Nothing to copy"),!1)},[Z,$e]);c.useEffect(()=>{h==null||h(rx({activeRuntime:ne,activeShell:ce,connectionButtonDisabled:we,connectionButtonLabel:ye,isMobileShell:T,busy:v,loading:y,error:N}))},[ne,ce,v,we,ye,N,T,y,h]),c.useImperativeHandle(u,()=>({async toggleConnection(){await et()},sendInput(A){var Y;return((Y=Z.current)==null?void 0:Y.sendInput(A))??!1},sendCommand(A){var Y;return((Y=Z.current)==null?void 0:Y.sendCommand(A))??!1},sendControl(A){var Y;return((Y=Z.current)==null?void 0:Y.sendControl(A))??!1},async copyLastCommandOutput(){var A;return await((A=Z.current)==null?void 0:A.copyLastCommandOutput())??!1},async terminate(){await Qe()},focus(){var A;(A=Z.current)==null||A.focus()},refreshLayout(A){var Y,be;(Y=m.current)==null||Y.refreshLayout(A),z==="columns"&&((be=f.current)==null||be.refreshLayout(A))}}),[Z,et,Qe,z]);const qe=A=>t.jsx("div",{className:`rounded-md border px-2 py-1.5 text-xs ${A.id===(ce==null?void 0:ce.id)?"border-sky-300/40 bg-sky-300/12 text-sky-50":"border-stone-800 bg-stone-900/40 text-stone-300"}`,children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[ie===A.id?t.jsx("form",{className:"min-w-0 flex-1",onSubmit:Y=>{Y.preventDefault(),Ne()},children:t.jsx("input",{value:H,onChange:Y=>G(Y.currentTarget.value),onKeyDown:Y=>{Y.key==="Escape"&&(Y.preventDefault(),ge())},autoFocus:!0,className:"w-full rounded border border-sky-300/35 bg-stone-950/70 px-2 py-1 text-xs text-stone-100 outline-none","aria-label":"Shell name"})}):t.jsxs("button",{type:"button",onClick:()=>Ge(A),onDoubleClick:()=>oe(A),className:"min-w-0 flex-1 text-left",title:A.tmuxSessionName,children:[t.jsx("span",{className:"block truncate",children:O(A)}),t.jsxs("span",{className:"block truncate text-[10px] text-[var(--theme-fg-muted)]",children:[zn(A.status)," · ",hn(A.cwd)||A.cwd]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[ie===A.id?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>void Ne(),className:"rounded border border-sky-300/35 bg-sky-300/12 px-1.5 py-1 text-[10px] text-sky-50",title:"Save shell name",children:"Save"}),t.jsx("button",{type:"button",onClick:ge,className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200",title:"Cancel rename",children:"Cancel"})]}):t.jsx("button",{type:"button",onClick:()=>oe(A),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Rename shell",children:"Rename"}),z==="columns"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>dt(A,"primary"),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Open in left pane",children:"L"}),t.jsx("button",{type:"button",onClick:()=>dt(A,"secondary"),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Open in right pane",children:"R"})]}),t.jsx("button",{type:"button",disabled:v,onClick:()=>void Qe(A.id),className:"rounded border border-rose-300/35 bg-rose-300/12 px-1.5 py-1 text-[10px] text-rose-100 disabled:cursor-not-allowed disabled:opacity-50",title:"Kill shell process",children:"Kill"})]})]})},A.id);return t.jsxs("div",{className:"shell-panel flex min-h-0 flex-1 flex-col",children:[s&&t.jsxs("div",{className:"shell-header shrink-0 border-b px-3 py-3 sm:px-5",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs uppercase tracking-[0.24em] text-[var(--theme-fg-muted)]",children:"Shell"}),t.jsx("p",{className:"mt-1 truncate text-sm text-[var(--theme-fg-soft)]",children:ne.promptLabel??(ce==null?void 0:ce.cwd)??"Create a terminal for this thread."})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("button",{type:"button","aria-label":ye,title:`${ye} (${zn(ne.status)})`,disabled:we,onClick:()=>void et(),className:`inline-flex h-10 w-10 items-center justify-center rounded-full border shadow-lg shadow-stone-950/25 transition disabled:cursor-not-allowed disabled:opacity-60 ${De}`,children:t.jsx(Ig,{connected:ne.shellInputEnabled})}),ce&&t.jsx("button",{type:"button",disabled:v,onClick:()=>void Qe(ce.id),className:"rounded-full border border-rose-300/35 bg-rose-300/12 px-3 py-2 text-sm text-rose-600 transition hover:bg-rose-300/18 dark:text-rose-100 disabled:cursor-not-allowed disabled:opacity-60",children:"Terminate"})]})]}),(N||y||Le)&&t.jsxs("div",{className:"shell-banner mt-3 rounded-2xl border px-3 py-3 text-sm",children:[y&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!y&&Le&&t.jsx("p",{className:"text-rose-600 dark:text-rose-100",children:"Workspace path is missing on this machine. Restore the path before creating a shell."}),!y&&N&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:N})]})]}),t.jsx("div",{className:"min-h-0 flex-1",children:t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("div",{className:"shell-terminal-bar flex shrink-0 items-center gap-2 border-b px-2 py-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-1",children:[t.jsx("span",{className:"min-w-0 truncate text-xs text-[var(--theme-fg-soft)]",children:ce?O(ce):"No live shell process"}),ce&&t.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.12em] text-[var(--theme-fg-muted)]",children:zn(ne.status)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.jsxs("span",{className:"hidden text-xs text-[var(--theme-fg-muted)] sm:inline",children:["Live ",le.length]}),t.jsx("button",{type:"button","aria-expanded":D,"aria-label":D?"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"})]})]}),D&&t.jsxs("div",{className:"shrink-0 border-b border-stone-800/80 bg-stone-950/55 p-2 sm:hidden",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsx("p",{className:"text-xs uppercase tracking-[0.16em] text-[var(--theme-fg-muted)]",children:"Processes"}),t.jsxs("span",{className:"text-[10px] text-[var(--theme-fg-muted)]",children:[le.length," live"]})]}),t.jsxs("div",{className:"max-h-52 space-y-1 overflow-y-auto",children:[le.map(qe),le.length===0&&t.jsx("p",{className:"px-2 py-3 text-xs text-[var(--theme-fg-muted)]",children:"No live shell processes"})]}),t.jsx("div",{className:"mt-2 flex justify-end border-t border-stone-800/80 pt-2",children:t.jsx("button",{type:"button","aria-label":"New shell",title:"New shell",disabled:v||y||Le,onClick:()=>void Me(R),className:"inline-flex h-8 w-8 items-center justify-center rounded-md border border-sky-300/35 bg-sky-300/12 text-base leading-none text-sky-50 disabled:cursor-not-allowed disabled:opacity-50",children:"+"})})]}),ee==="not_created"||Le?t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"shell-empty-state max-w-md rounded-[1.6rem] border px-6 py-8",children:[t.jsx("p",{className:"text-base font-medium text-[var(--theme-fg)]",children:"Durable thread shell"}),t.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--theme-fg-muted)]",children:"The shell runs under a supervisor-managed PTY and reconnects after browser disconnects. Create it explicitly when you want to inspect or take over the workspace."}),!Le&&t.jsx("button",{type:"button",disabled:v||y,onClick:()=>void Me("primary"),className:"mt-5 rounded-md border border-sky-300/35 bg-sky-300/12 px-3 py-2 text-sm text-sky-50 disabled:cursor-not-allowed disabled:opacity-50",children:"New Shell"})]})}):t.jsxs("div",{className:"grid h-full min-h-0 grid-cols-1 gap-2 p-2 sm:grid-cols-[minmax(0,1fr)_16rem] sm:p-3",children:[t.jsxs("div",{className:"shell-terminal-frame relative min-h-0 overflow-hidden rounded-[1.4rem] border shadow-inner",children:[!s&&(N||y||Le)&&t.jsxs("div",{className:"shell-banner absolute left-2 right-2 top-2 z-10 rounded-2xl border px-3 py-3 text-sm backdrop-blur sm:left-3 sm:right-3 sm:top-3",children:[y&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!y&&Le&&t.jsx("p",{className:"text-rose-600 dark:text-rose-100",children:"Workspace path is missing on this machine. Restore the path before creating a shell."}),!y&&N&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:N})]}),t.jsxs("div",{ref:g,className:`relative grid h-full min-h-0 ${z==="columns"?"grid-cols-1 sm:grid-cols-[var(--shell-left)_0.35rem_var(--shell-right)]":"grid-cols-1"}`,style:z==="columns"?{"--shell-left":`${se}fr`,"--shell-right":`${100-se}fr`}:void 0,"data-shell-split-ratio":se,children:[t.jsx(Ws,{ref:m,paneId:"primary",shell:je,isActive:R==="primary",isVisible:a,isMobileShell:T,effectiveTheme:l,workspacePathMissing:Le,shellAdapter:n,onActivate:()=>P("primary"),onShellUpdate:Oe,onRuntimeStateChange:ve,onFeedback:$e}),z==="columns"&&t.jsx("button",{type:"button",onClick:()=>xe("primary"),className:"absolute left-2 top-2 z-10 rounded-md border border-stone-700/80 bg-stone-950/70 px-2 py-1 text-[10px] text-stone-200 hover:border-rose-300/40",title:"Close left pane",children:"Close"}),z==="columns"&&t.jsx("button",{type:"button","aria-label":"Resize shell panes",title:"Resize shell panes",onPointerDown:Ke,className:"hidden cursor-col-resize border-x border-stone-800/80 bg-stone-900/60 transition hover:border-sky-300/40 hover:bg-sky-300/10 sm:block"}),z==="columns"&&t.jsxs("div",{className:"relative min-h-0 border-t border-stone-800/80 sm:border-l sm:border-t-0",children:[t.jsx(Ws,{ref:f,paneId:"secondary",shell:Ae,isActive:R==="secondary",isVisible:a,isMobileShell:T,effectiveTheme:l,workspacePathMissing:Le,shellAdapter:n,onActivate:()=>P("secondary"),onShellUpdate:Oe,onRuntimeStateChange:I,onFeedback:$e}),t.jsx("button",{type:"button",onClick:()=>xe("secondary"),className:"absolute left-2 top-2 z-10 rounded-md border border-stone-700/80 bg-stone-950/70 px-2 py-1 text-[10px] text-stone-200 hover:border-rose-300/40",title:"Close right pane",children:"Close"})]})]}),o&&T&&t.jsxs("div",{className:"pointer-events-none absolute bottom-3 right-3 z-20 flex flex-col items-end gap-2",children:[X&&t.jsx("div",{className:`pointer-events-auto rounded-full border px-3 py-1.5 text-[11px] shadow-lg shadow-stone-950/30 backdrop-blur ${Be}`,children:X.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(Fs,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:()=>void gt(),className:"shell-toolbox-copy inline-flex items-center justify-center rounded-full border px-2.5 py-2",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Fs,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:!ne.shellInputEnabled,onClick:()=>{var A;(A=Z.current)!=null&&A.sendControl("clear")?$e("done","Cleared"):$e("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(Rn,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!ne.shellInputEnabled||!ne.isCommandRunning,onClick:()=>{var A;(A=Z.current)!=null&&A.sendInput("")?$e("done","Sent Ctrl-C"):$e("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(Rn,{label:"CTRL-C",tone:"rose"})}),["ctrl_d","esc","tab","up","down"].map(A=>t.jsx("button",{type:"button",disabled:!ne.shellInputEnabled,onClick:()=>{var Y;(Y=Z.current)!=null&&Y.sendControl(A)?$e("done",`Sent ${A.toUpperCase().replace("_","-")}`):$e("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(Rn,{label:A.toUpperCase().replace("_","-"),tone:"stone"})},A))]})}),t.jsx("button",{type:"button","aria-expanded":C,"aria-label":C?"Close shell tools":"Open shell tools",onClick:()=>W(A=>!A),className:"shell-toolbox-trigger pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-2xl backdrop-blur transition",children:t.jsx(Lg,{})})]})]}),t.jsxs("aside",{className:"hidden min-h-0 overflow-hidden rounded-[1rem] border border-stone-800/80 bg-stone-950/30 p-2 sm:flex sm:flex-col",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsx("p",{className:"text-xs uppercase tracking-[0.16em] text-[var(--theme-fg-muted)]",children:"Processes"}),t.jsxs("span",{className:"text-[10px] text-[var(--theme-fg-muted)]",children:[le.length," live"]})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-1 overflow-y-auto",children:[le.map(qe),le.length===0&&t.jsx("p",{className:"px-2 py-3 text-xs text-[var(--theme-fg-muted)]",children:"No live shell processes"})]}),t.jsx("div",{className:"mt-2 flex justify-end border-t border-stone-800/80 pt-2",children:t.jsx("button",{type:"button","aria-label":"New shell",title:"New shell",disabled:v||y||Le,onClick:()=>void Me(R),className:"inline-flex h-8 w-8 items-center justify-center rounded-md border border-sky-300/35 bg-sky-300/12 text-base leading-none text-sky-50 disabled:cursor-not-allowed disabled:opacity-50",children:"+"})})]})]})]})})]})}),wx=c.lazy(async()=>({default:(await Promise.resolve().then(()=>(yu(),ll))).ThreadGraphWorkspacePanel}));function yx(){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 Al(e){return t.jsx(c.Suspense,{fallback:t.jsx(yx,{}),children:t.jsx(wx,{...e})})}c.memo(Al);function Jx({open:e,title:r,description:n,confirmLabel:a="Delete",busy:s=!1,onCancel:o,onConfirm:l}){return c.useEffect(()=>{if(!e)return;function i(d){d.key==="Escape"&&!s&&o()}return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[s,o,e]),e?Qr.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[95] flex items-center justify-center p-4 sm:p-6",children:[t.jsx("button",{type:"button","aria-label":"Close confirmation dialog",onClick:o,disabled:s,className:"absolute inset-0 bg-stone-950/78 backdrop-blur-sm disabled:cursor-not-allowed"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":r,className:"relative z-[1] w-full max-w-md rounded-[1.6rem] border border-stone-700 bg-stone-900 p-5 shadow-2xl shadow-stone-950/40 sm:p-6",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium text-stone-100",children:r}),t.jsx("p",{className:"mt-2 text-sm leading-6 text-stone-400",children:n})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:o,disabled:s,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-stone-700 text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsxs("div",{className:"mt-5 flex items-center justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:o,disabled:s,className:"rounded-full border border-stone-700 px-4 py-2 text-sm font-medium text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),t.jsx("button",{type:"button",onClick:()=>void l(),disabled:s,className:"ui-action-danger rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:s?"Deleting...":a})]})]})]}),document.body):null}function jx(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 Nx(e){switch(e){case"inProgress":return"running";case"completed":return"completed";case"interrupted":return"interrupted";case"failed":return"failed"}}function Cx(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 Sx(e){switch(e){case"latest-3":return 3;case"latest-10":return 10;case"latest-20":return 20;default:return null}}function Tx(e){return e==="read"?"View only":"Collaborator"}function Ex(e){switch(e){case"write":return"Workspace write";case"read":return"Workspace read";case"none":default:return"No workspace"}}function Qx({open:e,busy:r=!1,turnsState:n,shareAvailable:a=!1,shareUnavailableMessage:s="Relay sharing will be enabled after the relay permission model is connected.",shareState:o,initialMode:l="pdf",onCancel:i,onLoadTurns:d,onExport:h,onCreateShare:u,onRevokeShare:m,onOpenDeviceSharing:f}){var F,D,E;const p=c.useMemo(()=>{var C;return((C=n.data)==null?void 0:C.turns)??[]},[(F=n.data)==null?void 0:F.turns]),[g,k]=c.useState(l),[w,x]=c.useState("latest-10"),[j,y]=c.useState(()=>new Set),[b,v]=c.useState(!0),[S,N]=c.useState(""),[L,R]=c.useState("read"),[P,Q]=c.useState("none"),[K,J]=c.useState(""),[B,z]=c.useState(()=>typeof document<"u"&&!document.documentElement.classList.contains("dark")?"light":"dark");if(c.useEffect(()=>{e&&(k(l),x("latest-10"),v(!0),N(""),R("read"),Q("none"),J(""),d())},[l,d,e]),c.useEffect(()=>{e&&p.length>0&&y(new Set(p.slice(0,10).map(C=>C.turnId)))},[e,p]),c.useEffect(()=>{if(!e)return;function C(W){W.key==="Escape"&&!r&&i()}return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[r,i,e]),c.useEffect(()=>{if(!e)return;const C=document.querySelector(".thread-ui-shell"),W=()=>C?C.getAttribute("data-theme-effective")==="dark"||C.classList.contains("dark")||C.classList.contains("thread-ui-theme-dark")?"dark":"light":document.documentElement.classList.contains("dark")?"dark":"light";if(z(W()),!C)return;const U=new MutationObserver(()=>z(W()));return U.observe(C,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>U.disconnect()},[e]),!e)return null;const te=Sx(w),se=te!==null?Math.min(te,((D=n.data)==null?void 0:D.totalTurnCount)??te):w==="all-loaded"?p.length:j.size,$=!r&&g!=="share"&&(te!==null||w==="all-loaded"||j.size>0),ie=!r&&a&&!!u&&S.trim().length>0;function q(C){y(W=>{const U=new Set(W);return U.has(C)?U.delete(C):U.add(C),U})}function H(){if(g==="share")return;const C={format:g,...te!==null?{mode:"latest",limit:te}:w==="all-loaded"?{mode:"selected",turnIds:p.map(W=>W.turnId)}:{mode:"selected",turnIds:[...j]},profile:"review",options:{includeTokenAndPrice:b}};h(C)}function G(C){C.preventDefault(),ie&&(u==null||u({targetIdentifier:S.trim(),threadAccess:L,workspaceAccess:P,label:K.trim()||null}))}const T=[{mode:"pdf",label:"PDF"},{mode:"html",label:"HTML"},{mode:"share",label:"Share"}];return Qr.createPortal(t.jsxs("div",{className:`thread-export-dialog-root thread-ui-theme-${B} fixed inset-0 z-[96] flex items-end justify-center p-0 sm:items-center sm:p-6`,"data-theme-effective":B,children:[t.jsx("button",{type:"button","aria-label":"Close thread actions",onClick:i,disabled:r,className:"thread-export-dialog-backdrop absolute inset-0 backdrop-blur-sm disabled:cursor-not-allowed"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Thread actions",className:"thread-export-dialog-panel relative z-[1] flex max-h-[min(48rem,calc(100vh-1rem))] w-full max-w-2xl flex-col rounded-t-[1.6rem] border shadow-2xl sm:rounded-[1.6rem]",children:[t.jsxs("div",{className:"thread-export-dialog-header flex items-start justify-between gap-3 border-b px-5 py-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-export-dialog-title text-sm font-semibold",children:"Thread actions"}),t.jsx("p",{className:"thread-export-dialog-subtitle mt-1 text-xs",children:"Export a review copy or share this thread."})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:i,disabled:r,className:"thread-export-dialog-icon-button inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border transition disabled:cursor-not-allowed disabled:opacity-60",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-auto px-5 py-4",children:[t.jsx("div",{className:"thread-export-dialog-segment inline-flex rounded-full border p-1",children:T.map(C=>t.jsx("button",{type:"button",onClick:()=>k(C.mode),className:`rounded-full px-3 py-1.5 text-sm transition ${g===C.mode?"ui-status-warning":"thread-export-dialog-muted-action"}`,children:C.label},C.mode))}),g==="share"?t.jsxs("form",{id:"thread-actions-share-form",className:"mt-4 space-y-4",onSubmit:G,children:[a?null:t.jsx("p",{className:"thread-export-dialog-box thread-export-dialog-subtitle rounded-2xl border px-3 py-3 text-sm",children:s}),a&&f?t.jsxs("div",{className:"thread-export-dialog-box flex flex-wrap items-center justify-between gap-3 rounded-2xl border px-3 py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-export-dialog-strong text-sm font-medium",children:"Share this thread"}),t.jsx("p",{className:"thread-export-dialog-subtitle mt-1 text-xs",children:"Need broader access? Share the whole device from Relay Portal."})]}),t.jsx("button",{type:"button",className:"thread-export-dialog-secondary-button rounded-full border px-3 py-1.5 text-xs font-medium transition",disabled:r,onClick:f,children:"Share whole device"})]}):null,t.jsxs("label",{className:"thread-export-dialog-body-text block text-sm",children:["Relay identifier",t.jsx("input",{className:"thread-export-dialog-box mt-2 w-full rounded-xl border bg-transparent px-3 py-2 outline-none",disabled:!a||r,onChange:C=>N(C.target.value),placeholder:"username or email",value:S})]}),t.jsxs("fieldset",{className:"thread-export-dialog-box rounded-2xl border p-3",children:[t.jsx("legend",{className:"thread-export-dialog-subtitle px-1 text-xs",children:"Thread access"}),t.jsx("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[["read","View only"],["control","Collaborator"]].map(([C,W])=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex items-center gap-2 rounded-xl px-2.5 py-2 text-sm",children:[t.jsx("input",{type:"radio",checked:L===C,disabled:!a||r,onChange:()=>R(C)}),W]},C))})]}),t.jsxs("fieldset",{className:"thread-export-dialog-box rounded-2xl border p-3",children:[t.jsx("legend",{className:"thread-export-dialog-subtitle px-1 text-xs",children:"Workspace"}),t.jsx("div",{className:"mt-2 grid gap-2 sm:grid-cols-3",children:[["none","No access"],["read","Read files"],["write","Read and edit"]].map(([C,W])=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex items-center gap-2 rounded-xl px-2.5 py-2 text-sm",children:[t.jsx("input",{type:"radio",checked:P===C,disabled:!a||r,onChange:()=>Q(C)}),W]},C))})]}),t.jsxs("label",{className:"thread-export-dialog-body-text block text-sm",children:["Label",t.jsx("input",{className:"thread-export-dialog-box mt-2 w-full rounded-xl border bg-transparent px-3 py-2 outline-none",disabled:!a||r,onChange:C=>J(C.target.value),placeholder:"optional",value:K})]}),t.jsxs("div",{className:"thread-export-dialog-box rounded-2xl border",children:[t.jsxs("div",{className:"thread-export-dialog-box-header flex items-center justify-between border-b px-3 py-2.5",children:[t.jsx("p",{className:"thread-export-dialog-strong text-sm font-medium",children:"Shared by me"}),t.jsx("span",{className:"thread-export-dialog-status-pill rounded-full border px-2 py-0.5 text-[10px]",children:(o==null?void 0:o.shares.length)??0})]}),(o==null?void 0:o.status)==="failed"?t.jsx("p",{className:"px-3 py-3 text-sm text-rose-500 dark:text-rose-200",children:o.error}):o!=null&&o.shares.length?t.jsx("div",{className:"divide-y",children:o.shares.map(C=>t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2.5 text-sm",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-export-dialog-strong truncate font-medium",children:C.targetUsername}),t.jsxs("p",{className:"thread-export-dialog-subtitle mt-0.5 text-xs",children:[C.label?`${C.label} · `:"",Tx(C.threadAccess)," / ",Ex(C.workspaceAccess)]})]}),m?t.jsx("button",{type:"button",className:"thread-export-dialog-secondary-button rounded-full border px-3 py-1.5 text-xs transition",disabled:r,onClick:()=>void m(C.id),children:"Revoke"}):null]},C.id))}):t.jsx("p",{className:"thread-export-dialog-subtitle px-3 py-3 text-sm",children:"No active shares for this thread."})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"thread-export-dialog-body-text mt-4 block text-sm",children:["Turns",t.jsx("select",{className:"thread-export-dialog-box mt-2 w-full rounded-xl border bg-transparent px-3 py-2 outline-none",value:w,onChange:C=>x(C.target.value),children:["latest-3","latest-10","latest-20","all-loaded","custom"].map(C=>t.jsx("option",{value:C,children:Cx(C)},C))})]}),w==="custom"?t.jsxs("div",{className:"thread-export-dialog-box mt-4 rounded-2xl border",children:[t.jsxs("div",{className:"thread-export-dialog-box-header flex flex-wrap items-center justify-between gap-2 border-b px-3 py-2.5",children:[t.jsxs("p",{className:"thread-export-dialog-subtitle text-xs",children:["Selected ",j.size," of ",((E=n.data)==null?void 0:E.totalTurnCount)??p.length]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>y(new Set(p.map(C=>C.turnId))),className:"thread-export-dialog-secondary-button rounded-full border px-2.5 py-1 text-xs transition",children:"Select all"}),t.jsx("button",{type:"button",onClick:()=>y(new Set),className:"thread-export-dialog-secondary-button rounded-full border px-2.5 py-1 text-xs transition",children:"Clear"})]})]}),n.status==="loading"?t.jsx("p",{className:"thread-export-dialog-subtitle px-3 py-6 text-sm",children:"Loading turns..."}):n.status==="failed"?t.jsx("p",{className:"px-3 py-6 text-sm text-rose-500 dark:text-rose-200",children:n.error}):t.jsx("div",{className:"max-h-80 overflow-auto p-2",children:p.map(C=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex cursor-pointer items-center gap-3 rounded-xl px-2.5 py-2 text-sm transition",children:[t.jsx("input",{type:"checkbox",checked:j.has(C.turnId),onChange:()=>q(C.turnId),className:"thread-export-dialog-checkbox h-4 w-4"}),t.jsxs("span",{className:"thread-export-dialog-strong shrink-0 text-xs font-medium",children:["Turn ",C.turnNumber]}),t.jsx("span",{className:"thread-export-dialog-subtitle shrink-0 text-xs",children:jx(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:Nx(C.status)})]},C.turnId))})]}):null,t.jsxs("div",{className:"thread-export-dialog-body-text mt-4 grid gap-2 text-sm sm:grid-cols-2",children:[t.jsxs("label",{className:"thread-export-dialog-box flex items-center gap-2 rounded-xl border px-3 py-2",children:[t.jsx("input",{type:"checkbox",checked:b,onChange:C=>v(C.target.checked),className:"thread-export-dialog-checkbox h-4 w-4"}),"Token and price"]}),t.jsx("p",{className:"thread-export-dialog-box thread-export-dialog-subtitle flex items-center rounded-xl border px-3 py-2 text-xs",children:g==="html"?"HTML keeps the chat timeline styling and omits raw command output.":"Review exports keep message text readable and omit tool activity."})]})]})]}),t.jsxs("div",{className:"thread-export-dialog-footer flex items-center justify-between gap-3 border-t px-5 py-4",children:[t.jsx("p",{className:"thread-export-dialog-subtitle min-w-0 text-xs",children:g==="share"?a?"Share access is enforced by the relay server.":"Share permissions are not wired yet.":`${se} ${se===1?"turn":"turns"} selected.`}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:i,disabled:r,className:"thread-export-dialog-secondary-button rounded-full border px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),g==="share"?t.jsx("button",{type:"submit",form:"thread-actions-share-form",disabled:!ie,className:"ui-status-warning rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:r?"Sharing...":"Share this thread"}):t.jsx("button",{type:"button",onClick:H,disabled:!$,className:"ui-status-warning rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:r?"Exporting...":`Export ${g.toUpperCase()}`})]})]})]})]}),document.body)}function Lx({detail:e,adapter:r,timelineAdapter:n,TimelineComponent:a=Il,liveOutput:s="",beforeTimelineContent:o,composerProps:l,timelineProps:i,transcriptItemCount:d,useFloatingMobileComposer:h=!1,floatingMobileComposerBottomOffset:u=0,composerHostRef:m}){const[f,p]=c.useState(!1),[g,k]=c.useState(0),[w,x]=c.useState(0),[j,y]=c.useState(0),[b,v]=c.useState(!1),S=c.useRef(null),N=i==null?void 0:i.onTailVisibilityChange,L=e.pendingRequests.length>0,R=c.useMemo(()=>{const H=e.pendingSteers??[],G=new Set(H.map(T=>T.clientRequestId).filter(T=>!!T));return[...H.filter(T=>T.delivery==="continuation").map(T=>({id:T.id,prompt:T.prompt,...T.id.startsWith("optimistic-")?{optimistic:!0}:{}})),...((i==null?void 0:i.optimisticSteers)??[]).filter(T=>!G.has(T.clientRequestId)).map(T=>({id:T.id,prompt:T.prompt,optimistic:!0}))]},[e.pendingSteers,i==null?void 0:i.optimisticSteers]),P=c.useMemo(()=>(e.pendingSteers??[]).filter(H=>H.delivery==="steer"),[e.pendingSteers]),Q=c.useMemo(()=>{var H;return l?{...l,pendingPrompts:R,...r.steerPendingPrompt&&((H=l.capabilities)!=null&&H.turns.steer)?{onSteerPendingPrompt:G=>{var T;return(T=r.steerPendingPrompt)==null?void 0:T.call(r,e.thread.id,G)}}:{},...r.cancelPendingSteer?{onCancelPendingPrompt:G=>{var T;return(T=r.cancelPendingSteer)==null?void 0:T.call(r,e.thread.id,G)}}:{}}:null},[r.cancelPendingSteer,r.steerPendingPrompt,l,e.thread.id,R]),K=c.useCallback(H=>{N==null||N(H)},[N]);c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const H=window.matchMedia("(max-width: 639px)"),G=()=>p(H.matches);return G(),H.addEventListener("change",G),()=>{H.removeEventListener("change",G)}},[]),c.useEffect(()=>{var G,T;if(typeof window>"u")return;const H=()=>{const F=window.visualViewport,D=F?Math.max(0,Math.round(window.innerHeight-F.height-F.offsetTop)):0,E=F?Math.max(0,Math.round(window.innerHeight-F.height)):D,C=Math.min(D,E),W=Math.max(0,Math.round(window.innerHeight*.52));y(Math.min(C,W))};return H(),(G=window.visualViewport)==null||G.addEventListener("resize",H),(T=window.visualViewport)==null||T.addEventListener("scroll",H),window.addEventListener("resize",H),()=>{var F,D;(F=window.visualViewport)==null||F.removeEventListener("resize",H),(D=window.visualViewport)==null||D.removeEventListener("scroll",H),window.removeEventListener("resize",H)}},[]),c.useLayoutEffect(()=>{const H=S.current;if(!H||!f){k(0);return}const G=()=>{k(Math.ceil(H.getBoundingClientRect().height))};if(G(),typeof ResizeObserver>"u")return;const T=new ResizeObserver(G);return T.observe(H),()=>{T.disconnect()}},[f,l,L]),c.useLayoutEffect(()=>{var F,D;const H=S.current;if(!H||!f){x(0);return}const G=()=>{const E=H.getBoundingClientRect();x(Math.max(0,Math.ceil(window.innerHeight-E.top)))};G(),window.addEventListener("resize",G),(F=window.visualViewport)==null||F.addEventListener("resize",G),(D=window.visualViewport)==null||D.addEventListener("scroll",G);let T=null;return typeof ResizeObserver<"u"&&(T=new ResizeObserver(G),T.observe(H)),()=>{var E,C;window.removeEventListener("resize",G),(E=window.visualViewport)==null||E.removeEventListener("resize",G),(C=window.visualViewport)==null||C.removeEventListener("scroll",G),T==null||T.disconnect()}},[f,j,b,l,L]),c.useEffect(()=>{if(!f){v(!1);return}const H=T=>{var D;const F=T.target;F instanceof HTMLElement&&((D=S.current)!=null&&D.contains(F))&&v(!0)},G=T=>{var D;const F=T.relatedTarget;F instanceof HTMLElement&&((D=S.current)!=null&&D.contains(F))||v(!1)};return document.addEventListener("focusin",H),document.addEventListener("focusout",G),()=>{document.removeEventListener("focusin",H),document.removeEventListener("focusout",G)}},[f]);const J=c.useCallback(H=>{S.current=H,m&&(m.current=H)},[m]),B=f&&b?Math.max(0,j-u):0,z=Math.max(g,144),te=Math.max(w,z+B),se=f?te+12:0,$=se>0?{"--thread-graph-chat-scroll-bottom-spacer":`${se}px`}:void 0,ie=h&&f?{bottom:`${u+B}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"}:void 0,q=c.useMemo(()=>{const H=e.thread.status==="running"||e.thread.activeTurnId!==null;return t.jsx(a,{threadId:e.thread.id,turns:e.turns,totalTurnCount:e.totalTurnCount??e.turns.length,pendingRequests:e.pendingRequests,activeTurnId:e.thread.activeTurnId,threadRunning:H,liveOutput:s,className:"thread-timeline-surface min-h-0 flex-1",...i,pendingSteers:P,optimisticSteers:[],adapter:n,onOpenThread:(i==null?void 0:i.onOpenThread)??r.openThread,onTailVisibilityChange:K})},[a,r.openThread,e.pendingRequests,e.thread.activeTurnId,e.thread.id,e.thread.status,e.totalTurnCount,e.turns,K,s,n,i,P]);return t.jsxs("div",{"data-testid":"chat-panel",className:"thread-graph-chat-panel relative flex h-full min-h-0 flex-col",style:$,children:[o,q,t.jsx("div",{className:"thread-chat-usage-footer hidden shrink-0 items-center px-4 py-1 text-[10px] leading-4 sm:flex",children:t.jsxs("span",{className:"min-w-0",children:[e.turns.length," turn",e.turns.length!==1?"s":"",t.jsx("span",{className:"mx-1 text-[var(--theme-border-contrast)]",children:"|"}),d," item",d!==1?"s":""]})}),Q?h?t.jsx("div",{ref:J,className:"fixed inset-x-0 bottom-0 z-50 overflow-visible sm:hidden",style:ie??{bottom:`${u}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"},children:t.jsx(Yn,{...Q,activeView:"chat",edgeToEdgeMobile:!0,onSubmit:r.sendPrompt})}):t.jsx("div",{ref:J,className:"thread-graph-composer-host shrink-0",children:t.jsx(Yn,{...Q,activeView:"chat",onSubmit:r.sendPrompt})}):null]})}function Ix(e){return e.turns.reduce((r,n)=>{var s,o;const a=(s=n.tokenUsage)==null?void 0:s.total;return a?{input:r.input+a.inputTokens,output:r.output+a.outputTokens,cache:r.cache+a.cachedInputTokens,cacheWrite:r.cacheWrite+(a.cacheWriteInputTokens??0),priceUsd:r.priceUsd+(((o=n.priceEstimate)==null?void 0:o.totalUsd)??0),pricedTurns:r.pricedTurns+(n.priceEstimate?1:0),turns:r.turns+1}:r},{input:0,output:0,cache:0,cacheWrite:0,priceUsd:0,pricedTurns:0,turns:0})}function Gr(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?"0":e>=1e6?`${(e/1e6).toFixed(e>=1e7?0:1)}m`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(Math.round(e))}function zx(e){if(!e||e.turns<=0)return"waiting for agent usage";const r=`in ${Gr(e.input)} / out ${Gr(e.output)} / cache read ${Gr(e.cache)}`,n=e.cacheWrite>0?`${r} / cache write ${Gr(e.cacheWrite)}`:r;return e.pricedTurns>0?`${n} / cost ${Sl(e.priceUsd)}`:n}function Px(e){return!!(e&&typeof e=="object"&&typeof e.id=="string"&&typeof e.kind=="string")}function Rx(e){const r=n=>Array.isArray(n)?n.filter(Px):[];return{...e,turns:Array.isArray(e.turns)?e.turns.map(n=>({...n,items:r(n.items)})):[],...e.liveItems?{liveItems:{...e.liveItems,items:r(e.liveItems.items)}}:{}}}function eb({threads:e,detail:r,loading:n,error:a,status:s=null,plugins:o,adapter:l,metaContent:i,settingsContent:d,globalSettingsContent:h,settingsDialogOpen:u,onSettingsDialogOpenChange:m,mobileHeaderAction:f,appMenuButton:p,appNavigationMenu:g,workspaceReturnHref:k,onWorkspaceReturn:w,threadActionsButton:x,surfaceActions:j,floatingPanel:y,workspaceContent:b,workspaceTitle:v,workspaceActions:S,workspaceFeatures:N,workspaceFocusPathRequest:L=null,onNewThreadTitle:R,beforeTimelineContent:P,errorContent:Q,workspaceMissingContent:K,dialogs:J,currentThreadId:B,currentWorkspaceId:z,currentWorkspaceLabel:te,onCloseAppNavigation:se,className:$="thread-detail-surface relative flex h-full min-h-0 flex-1 flex-col overflow-hidden",activeView:ie="chat",liveOutput:q="",timelineProps:H,composerProps:G,shellComposerProps:T,useFloatingMobileComposer:F=!1,floatingMobileComposerBottomOffset:D=0,composerHostRef:E,shellPanelRef:C,shellEffectiveTheme:W="dark",shellThemeMode:U=W,onShellThemeModeChange:ae,onShellStateChange:X,shellUnavailableContent:de,shellDisconnectedContent:ee,timelineComponent:ke=Il,shellPanelComponent:le=kx,shellContent:je,loadingContent:Ae,emptyContent:ce}){const ne=c.useMemo(()=>r?Rx(r):null,[r]),Le=pa(),Z=o??Le??ua(),{getImageAssetUrl:me,loadHistoryItemDetail:we,openWorkspaceFile:ye,openThread:De,cancelPendingSteer:Be}=l,$e=c.useMemo(()=>({...me?{getImageAssetUrl:ge=>me(ge.path)}:{},onOpenLinkedThread:De,...ye?{onOpenWorkspaceFile:ye}:{},...we?{onLoadHistoryItemDetail:we}:{},...Be?{cancelPendingSteer:Be}:{}}),[Be,me,we,ye,De]),Oe=Z.getThreadPanels().some(ge=>ge.kind==="terminal"),V=c.useMemo(()=>ne?Ix(ne):null,[ne]),he=c.useMemo(()=>zx(V),[V]),ve=c.useMemo(()=>{var ge;return ne?ne.turns.reduce((Ne,Ce)=>Ne+Ce.items.length,((ge=ne.liveItems)==null?void 0:ge.items.length)??0):0},[ne]),I=b??(ne?t.jsx(Al,{detail:ne,status:s,plugins:Z,workspaceAdapter:l.workspace??null,metaContent:i,settingsContent:d,activeView:ie,features:N,focusPathRequest:L}):null),O=n?Ae??t.jsx("div",{className:"flex flex-1 items-center justify-center px-6 py-12 text-center text-[var(--theme-fg-muted)]",children:"Loading thread detail..."}):ne?t.jsxs("div",{className:$,children:[y?t.jsx("div",{className:"fixed right-3 top-20 z-50 lg:absolute lg:right-4 lg:top-16",children:y}):null,a&&!n&&(Q??t.jsx("div",{className:"shrink-0 border-b border-rose-500/20 bg-rose-500/10 px-5 py-4 text-sm text-rose-100 sm:px-6",children:a})),ne.workspacePathStatus==="missing"&&(K??t.jsxs("div",{className:"shrink-0 border-b border-rose-500/20 bg-rose-500/10 px-5 py-4 text-sm text-rose-100 sm:px-6",children:[t.jsx("p",{className:"font-medium text-rose-50",children:"Workspace path missing"}),t.jsx("p",{className:"mt-1 break-words text-rose-100/90",children:ne.workspace.absPath})]})),t.jsx("div",{className:ie==="chat"?"flex min-h-0 flex-1 flex-col":"hidden",children:t.jsx(Lx,{detail:ne,adapter:l,timelineAdapter:$e,TimelineComponent:ke,liveOutput:q,transcriptItemCount:ve,useFloatingMobileComposer:F,floatingMobileComposerBottomOffset:D,...P?{beforeTimelineContent:P}:{},...G?{composerProps:G}:{},...H?{timelineProps:H}:{},...E?{composerHostRef:E}:{}})}),t.jsxs("div",{className:ie==="shell"?"flex min-h-0 flex-1 flex-col":"hidden",children:[je??(ne.thread.isLoaded&&Oe&&l.shell?t.jsx(le,{ref:C,threadId:ne.thread.id,shellAdapter:l.shell,effectiveTheme:W,isVisible:ie==="shell",showHeader:!1,showFloatingToolbox:!1,...X?{onStateChange:X}:{}}):ne.thread.isLoaded&&!Oe?de??t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center p-4 sm:p-6",children:t.jsxs("div",{className:"thread-empty-surface max-w-md rounded-[1.6rem] border px-6 py-8 text-center",children:[t.jsx("p",{className:"text-base font-medium text-[var(--theme-fg)]",children:"Terminal plugin disabled"}),t.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--theme-fg-muted)]",children:"Enable the Terminal plugin in Settings to use the shell panel."})]})}):ee??t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center p-4 sm:p-6",children:t.jsxs("div",{className:"thread-empty-surface max-w-md rounded-[1.6rem] border px-6 py-8 text-center",children:[t.jsx("p",{className:"text-base font-medium text-[var(--theme-fg)]",children:"Thread disconnected"}),t.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--theme-fg-soft)]",children:"Reconnect this thread before creating or attaching a shell."})]})})),ie==="shell"&&T&&!je?t.jsx(Yn,{...T,activeView:"shell",onSubmit:l.sendPrompt}):null]}),J]}):ce??t.jsx("div",{className:"flex flex-1 items-center justify-center px-6 py-12 text-center text-[var(--theme-fg-muted)]",children:"Select a thread to inspect."}),oe=t.jsx(Cp,{threads:e,status:s,loading:n,error:n?null:a,viewportConstrained:!0,currentThreadId:B??(ne==null?void 0:ne.thread.id),currentThreadLabel:ne==null?void 0:ne.thread.title,currentWorkspaceId:z??(ne==null?void 0:ne.thread.workspaceId),currentWorkspaceLabel:te??(ne==null?void 0:ne.workspace.label),sessionLabel:(ne==null?void 0:ne.thread.providerSessionId)??(ne==null?void 0:ne.thread.id),usageLabel:he,threadActionsButton:x,topbarActions:j,metaContent:i,settingsContent:d,globalSettingsContent:h,...u!==void 0?{settingsDialogOpen:u}:{},...m?{onSettingsDialogOpenChange:m}:{},mobileHeaderAction:f,effectiveTheme:W,themeMode:U,appMenuButton:p,appNavigationMenu:g,workspaceReturnHref:k,...w?{onWorkspaceReturn:w}:{},showMobileAppMenu:!!p,showMobileThreadNavToggle:!0,showMobileNewThreadShortcut:!1,onOpenThread:l.openThread,workspaceContent:I,workspaceTitle:v??"Workspace",workspaceActions:S,...R?{onNewThreadTitle:R}:{},...se?{onCloseAppNavigation:se}:{},...ae?{onThemeModeChange:ae}:{},...l.getThreadHref?{getThreadHref:l.getThreadHref}:{},...l.getNewThreadHref?{getNewThreadHref:l.getNewThreadHref}:{},...l.renderNewThreadDialogContent?{renderNewThreadDialogContent:l.renderNewThreadDialogContent}:{},...l.renameThread?{onRenameThread:l.renameThread}:{},...l.deleteThread?{onDeleteThread:l.deleteThread}:{},children:O});return o?t.jsx(ma.Provider,{value:Z,children:oe}):oe}var Ax={},Mx=[];function tb({adapter:e=Ax,builtinPlugins:r=Mx,children:n}){const[a,s]=c.useState(()=>Zn(r,[])),[o,l]=c.useState(!1),[i,d]=c.useState(null),h=c.useCallback(async()=>{l(!0),d(null);try{const y=e.fetchPlugins?await e.fetchPlugins():[];s(Zn(r,y))}catch(y){d(y instanceof Error?y.message:"Unable to load plugins.")}finally{l(!1)}},[e,r]);c.useEffect(()=>{h()},[h]);const u=c.useCallback(async(y,b)=>{if(e.updatePlugin){const v=await e.updatePlugin(y,{enabled:b});s(S=>S.map(N=>N.id===v.id?v:N));return}s(v=>v.map(S=>S.id===y?{...S,enabled:b}:S))},[e]),m=c.useCallback(async y=>{if(!e.importPlugin)throw new Error("Plugin import is not available.");const b=await e.importPlugin(y);s(v=>[...v.filter(N=>N.id!==b.id),b])},[e]),f=c.useCallback(async y=>{if(!e.deletePlugin)throw new Error("Plugin uninstall is not available.");const b=await e.deletePlugin(y);s(v=>v.filter(S=>S.id!==b.id))},[e]),p=c.useMemo(()=>{const y=new Set(a.filter(b=>b.enabled).map(b=>b.id));return r.filter(b=>y.has(b.manifest.id))},[r,a]),g=c.useCallback(y=>{var v;const b=p.find(S=>S.renderArtifact&&S.manifest.capabilities.artifactTypes.some(N=>N.type===y.artifact.type));return((v=b==null?void 0:b.renderArtifact)==null?void 0:v.call(b,y))??null},[p]),k=c.useCallback(y=>{for(const b of p)for(const v of b.inlineCodeRenderers??[]){if(!v.languages.includes(y.language.trim().toLowerCase()))continue;const S=v.render(y);if(S)return S}return null},[p]),w=c.useCallback(y=>p.some(b=>!!b.renderArtifact&&b.manifest.capabilities.artifactTypes.some(v=>v.type===y.type)),[p]),x=c.useCallback(()=>p.flatMap(y=>y.threadPanels??[]),[p]),j=c.useMemo(()=>({plugins:a,loading:o,error:i,refresh:h,importPluginManifest:m,setPluginEnabled:u,uninstallPlugin:f,renderArtifact:g,renderInlineCode:k,hasRendererForArtifact:w,getThreadPanels:x}),[i,x,w,m,o,a,h,g,k,u,f]);return t.jsx(ma.Provider,{value:j,children:n})}const Mn="chemistry.molecule3d",_x={id:"remote-codex.xyz-viewer",name:"XYZ Molecule Viewer",version:"0.1.0",description:"A draft built-in plugin for previewing xyz, extxyz, cif, and pdb molecular structures with 3Dmol.js.",remoteCodex:"^0.11.0",capabilities:{artifactTypes:[{type:Mn,title:"3D Molecule",fileExtensions:["xyz","extxyz","cif","pdb"]}],timelineRenderers:[Mn],threadPanels:[{id:"xyz-viewer",label:"Molecules",artifactTypes:[Mn]}],modelHints:[{id:"render-molecule",text:"XYZ Molecule Viewer is enabled. When outputting a molecular structure, you must call remote_codex_render_molecule; do not output plain xyz, pdb, cif, or extxyz text. Do not invent coordinates unless asked for an example."}],mcpServers:[{id:"remote-codex-plugin-mcp",name:"remote_codex_plugins",command:"node",args:["bin/remote-codex-plugin-mcp.mjs"]}],frontend:{entry:"./dist/index.js",style:"./src/styles.css"}}};var $x="remote-codex.terminal",Dx={id:$x,name:"Terminal",version:"0.1.0",description:"Built-in durable terminal panel backed by the supervisor PTY host.",remoteCodex:"^0.11.0",capabilities:{artifactTypes:[],timelineRenderers:[],threadPanels:[{id:"terminal",label:"Terminal",kind:"terminal",artifactTypes:[]}],frontend:{entry:"./dist/index.js"},backend:{entry:"./dist/backend.js"}}};function _n(e){return typeof e=="string"&&e.trim()!==""&&Number.isFinite(Number(e))}function Bx(e){const r=e.split(/\r?\n/).map(s=>s.trim()).filter(Boolean),n=Number(r[0]);if(!Number.isInteger(n)||n<=0||n>1e5)return!1;const a=r.slice(2);return a.length<n?!1:a.slice(0,n).every(s=>{const o=s.split(/\s+/);return o.length>=4&&/^([A-Za-z][A-Za-z]?|\d+)$/.test(o[0]??"")&&_n(o[1])&&_n(o[2])&&_n(o[3])})}function Gx(e){return e.split(/\r?\n/).some(r=>/^(ATOM|HETATM)\s+/i.test(r))}function Fx(e){return/\bdata_[^\s]*/i.test(e)&&/_atom_site\./i.test(e)}function Hx(e,r){switch(r){case"xyz":case"extxyz":return Bx(e);case"pdb":return Gx(e);case"cif":return Fx(e);default:return!1}}var Ml=c.lazy(async()=>(await Ve(()=>Promise.resolve({}),__vite__mapDeps([8])),{default:(await Ve(()=>import("./frontend-DNAQzqc-.js"),__vite__mapDeps([9,2,10]))).XyzMoleculeViewer}));function _l(){return t.jsx("div",{className:"flex h-full min-h-[12rem] items-center justify-center rounded-[0.9rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-4 text-sm text-[var(--theme-fg-muted)]",children:"Loading molecule viewer..."})}function Ox(e){return!e||typeof e!="object"?!1:Array.isArray(e.content)}function Wx(e){return e.trim().toLowerCase()==="extxyz"?"xyz":e.trim().toLowerCase()}function Ux({artifact:e,expanded:r,onToggleExpanded:n}){const a=Ox(e.payload)?e.payload:null;return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:n,className:"flex w-full items-center justify-between gap-3 text-left",children:[t.jsxs("span",{children:[t.jsx("span",{className:"block text-sm font-medium text-[var(--theme-fg)]",children:e.title}),t.jsx("span",{className:"mt-1 block text-xs text-[var(--theme-fg-muted)]",children:e.summaryText??e.type})]}),t.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-1 text-[10px] uppercase tracking-[0.16em] text-[var(--theme-fg-muted)]",children:r?"Hide":"Open"})]}),r&&a&&t.jsx("div",{className:"h-[min(56vh,34rem)] min-h-[26rem]",children:t.jsx(c.Suspense,{fallback:t.jsx(_l,{}),children:t.jsx(Ml,{source:a,moleculeId:e.id,title:e.title})})}),r&&!a&&t.jsx("pre",{className:"max-h-80 overflow-auto rounded-[0.9rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] p-3 text-xs text-[var(--theme-fg-soft)]",children:JSON.stringify(e.payload,null,2)})]})}function Vx({code:e,isIncomplete:r,language:n}){const[a,s]=c.useState(!0),[o,l]=c.useState(!1),i=Wx(n),d=c.useMemo(()=>({content:[e.endsWith(`
|
|
3713
|
+
`)?e:`${e}
|
|
3714
|
+
`],format:i,name:`${i.toUpperCase()} structure`,uuid:`inline:${i}:${e.length}`}),[e,i]);return r||!Hx(e,i)?null:t.jsxs("div",{className:"my-3 overflow-hidden rounded-[1rem] border border-[var(--theme-border)] bg-[var(--theme-surface)]",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-[var(--theme-border)] px-3 py-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("p",{className:"text-sm font-medium text-[var(--theme-fg)]",children:[i.toUpperCase()," molecule"]}),t.jsx("p",{className:"mt-0.5 text-xs text-[var(--theme-fg-muted)]",children:"Rendered from message source"})]}),t.jsxs("div",{className:"inline-flex shrink-0 items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>l(h=>!h),className:"rounded-full border border-[var(--theme-border)] px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.16em] text-[var(--theme-fg-muted)] transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)]",children:o?"Hide source":"Source"}),t.jsx("button",{type:"button",onClick:()=>s(h=>!h),className:"rounded-full border border-[var(--theme-border)] px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.16em] text-[var(--theme-fg-muted)] transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)]",children:a?"Collapse":"Open"})]})]}),a&&t.jsx("div",{className:"h-[min(52vh,32rem)] min-h-[24rem]",children:t.jsx(c.Suspense,{fallback:t.jsx(_l,{}),children:t.jsx(Ml,{source:d,moleculeId:d.uuid,title:`${i.toUpperCase()} molecule`})})}),o&&t.jsx("pre",{className:"max-h-96 overflow-auto border-t border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-3 text-xs leading-5 text-[var(--theme-fg-soft)]",children:e})]})}var rb=[{manifest:Dx,threadPanels:[{id:"terminal",kind:"terminal",label:"Terminal"}]},{manifest:_x,renderArtifact:e=>t.jsx(Ux,{...e}),inlineCodeRenderers:[{languages:["xyz","extxyz","cif","pdb"],render:e=>t.jsx(Vx,{...e})}]}];export{dp as A,Jx as C,Sp as L,tb as P,Qx as T,pa as a,eb as b,kx as c,Il as d,Cp as e,Ut as f,Np as g,rb as h,cp as t,ul as u};
|