remote-codex 0.11.51 → 0.11.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/supervisor-api/dist/index.js +511 -71
- package/apps/supervisor-web/dist/assets/index-Bnury8uP.js +22 -0
- package/apps/supervisor-web/dist/assets/{thread-ui-BbtcUwps.js → thread-ui-C5pxOmDJ.js} +33 -33
- package/apps/supervisor-web/dist/index.html +2 -2
- package/bin/remote-codex.mjs +13 -2
- package/package.json +1 -1
- package/packages/acp/src/runtimeAdapter.test.ts +14 -1
- package/packages/codex/src/appServerManager.test.ts +2 -2
- package/packages/codex/src/historyItems.test.ts +9 -0
- package/packages/codex/src/historyItems.ts +20 -8
- package/packages/codex/src/local-session-store.test.ts +455 -0
- package/packages/codex/src/local-session-store.ts +505 -40
- package/scripts/windows/build-device-manager.ps1 +0 -7
- package/apps/supervisor-web/dist/assets/index-7LiZQ3aJ.js +0 -22
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/core-B0prQzhr.js","assets/markdown-vendor-BG6PurxI.js","assets/react-vendor-Dfg_6BLf.js","assets/html-pp8916En.js","assets/javascript-wDzz0qaB.js","assets/css-CLj8gQPS.js","assets/ruby-B6AkvBWc.js","assets/xml-sdJ4AIDG.js","assets/java-CylS5w8V.js","assets/sql-CRqJ_cUM.js","assets/typescript-BPQ3VLAy.js","assets/jsx-g9-lgVsj.js","assets/tsx-COt5Ahok.js","assets/cpp-DIPi6g--.js","assets/c-BIGW1oBm.js","assets/shellscript-DfDnw5Jg.js","assets/yaml-Buea-lGh.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 P,R as bd,I as vd,C as kd,S as Qs,H as wd,T as yd,a as jd,b as Nd,c as Cd,d as Sd,e as Td,D as Ed,P as Ld,O as Id,f as zd,g as Pd,h as Rd,i as _d,j as Md,k as Ad,m as $d,n as Dd,A as Bd,o as Gd,p as Hd}from"./ui-vendor-CuR8GHb0.js";import{r as c,R as Fd,j as t,b as Lr}from"./react-vendor-Dfg_6BLf.js";import{u as Od,a as Wd,H as Ma,P as Ot,b as Ud,M as eo,R as Vd,i as Xd,C as qd,B as Kd,c as Aa,g as to}from"./graph-vendor-DVQUpZ8C.js";import"./terminal-vendor-C5bTa-Ka.js";import{M as ro,r as Yd,a as no,b as Zd}from"./markdown-vendor-BG6PurxI.js";const Jd="modulepreload",Qd=function(e){return"/"+e},$a={},Be=function(r,n,a){let s=Promise.resolve();if(n&&n.length>0){let l=function(h){return Promise.all(h.map(m=>Promise.resolve(m).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};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=Qd(h),h in $a)return;$a[h]=!0;const m=h.endsWith(".css"),u=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${u}`))return;const p=document.createElement("link");if(p.rel=m?"stylesheet":Jd,m||(p.as="script"),p.crossOrigin="",p.href=h,d&&p.setAttribute("nonce",d),document.head.appendChild(p),m)return new Promise((f,g)=>{p.addEventListener("load",f),p.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 ao(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=ao(e[r]))&&(a&&(a+=" "),a+=n)}else for(n in e)e[n]&&(a&&(a+=" "),a+=n);return a}function so(){for(var e,r,n=0,a="",s=arguments.length;n<s;n++)(e=arguments[n])&&(r=ao(e))&&(a&&(a+=" "),a+=r);return a}const ec=(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},tc=(e,r)=>({classGroupId:e,validator:r}),oo=(e=new Map,r=null,n)=>({nextPart:e,validators:r,classGroupId:n}),Jr="-",Da=[],rc="arbitrary..",nc=e=>{const r=sc(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:a}=e;return{getClassGroupId:l=>{if(l.startsWith("[")&&l.endsWith("]"))return ac(l);const i=l.split(Jr),d=i[0]===""&&i.length>1?1:0;return lo(i,d,r)},getConflictingClassGroupIds:(l,i)=>{if(i){const d=a[l],h=n[l];return d?h?ec(h,d):d:h||Da}return n[l]||Da}}},lo=(e,r,n)=>{if(e.length-r===0)return n.classGroupId;const s=e[r],o=n.nextPart.get(s);if(o){const h=lo(e,r+1,o);if(h)return h}const l=n.validators;if(l===null)return;const i=r===0?e.join(Jr):e.slice(r).join(Jr),d=l.length;for(let h=0;h<d;h++){const m=l[h];if(m.validator(i))return m.classGroupId}},ac=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?rc+a:void 0})(),sc=e=>{const{theme:r,classGroups:n}=e;return oc(n,r)},oc=(e,r)=>{const n=oo();for(const a in e){const s=e[a];ia(s,n,a,r)}return n},ia=(e,r,n,a)=>{const s=e.length;for(let o=0;o<s;o++){const l=e[o];lc(l,r,n,a)}},lc=(e,r,n,a)=>{if(typeof e=="string"){ic(e,r,n);return}if(typeof e=="function"){dc(e,r,n,a);return}cc(e,r,n,a)},ic=(e,r,n)=>{const a=e===""?r:io(r,e);a.classGroupId=n},dc=(e,r,n,a)=>{if(hc(e)){ia(e(a),r,n,a);return}r.validators===null&&(r.validators=[]),r.validators.push(tc(n,e))},cc=(e,r,n,a)=>{const s=Object.entries(e),o=s.length;for(let l=0;l<o;l++){const[i,d]=s[l];ia(d,io(r,i),n,a)}},io=(e,r)=>{let n=e;const a=r.split(Jr),s=a.length;for(let o=0;o<s;o++){const l=a[o];let i=n.nextPart.get(l);i||(i=oo(),n.nextPart.set(l,i)),n=i}return n},hc=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,uc=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)}}},Gn="!",Ba=":",mc=[],Ga=(e,r,n,a,s)=>({modifiers:e,hasImportantModifier:r,baseClassName:n,maybePostfixModifierPosition:a,isExternal:s}),pc=e=>{const{prefix:r,experimentalParseClassName:n}=e;let a=s=>{const o=[];let l=0,i=0,d=0,h;const m=s.length;for(let x=0;x<m;x++){const j=s[x];if(l===0&&i===0){if(j===Ba){o.push(s.slice(d,x)),d=x+1;continue}if(j==="/"){h=x;continue}}j==="["?l++:j==="]"?l--:j==="("?i++:j===")"&&i--}const u=o.length===0?s:s.slice(d);let p=u,f=!1;u.endsWith(Gn)?(p=u.slice(0,-1),f=!0):u.startsWith(Gn)&&(p=u.slice(1),f=!0);const g=h&&h>d?h-d:void 0;return Ga(o,f,p,g)};if(r){const s=r+Ba,o=a;a=l=>l.startsWith(s)?o(l.slice(s.length)):Ga(mc,!1,l,void 0,!0)}if(n){const s=a;a=o=>n({className:o,parseClassName:s})}return a},fc=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}},gc=e=>({cache:uc(e.cacheSize),parseClassName:pc(e),sortModifiers:fc(e),postfixLookupClassGroupIds:xc(e),...nc(e)}),xc=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},bc=/\s+/,vc=(e,r)=>{const{parseClassName:n,getClassGroupId:a,getConflictingClassGroupIds:s,sortModifiers:o,postfixLookupClassGroupIds:l}=r,i=[],d=e.trim().split(bc);let h="";for(let m=d.length-1;m>=0;m-=1){const u=d[m],{isExternal:p,modifiers:f,hasImportantModifier:g,baseClassName:x,maybePostfixModifierPosition:j}=n(u);if(p){h=u+(h.length>0?" "+h:h);continue}let b=!!j,k;if(b){const N=x.substring(0,j);k=a(N);const E=k&&l[k]?a(x):void 0;E&&E!==k&&(k=E,b=!1)}else k=a(x);if(!k){if(!b){h=u+(h.length>0?" "+h:h);continue}if(k=a(x),!k){h=u+(h.length>0?" "+h:h);continue}b=!1}const y=f.length===0?"":f.length===1?f[0]:o(f).join(":"),v=g?y+Gn:y,w=v+k;if(i.indexOf(w)>-1)continue;i.push(w);const C=s(k,b);for(let N=0;N<C.length;++N){const E=C[N];i.push(v+E)}h=u+(h.length>0?" "+h:h)}return h},kc=(...e)=>{let r=0,n,a,s="";for(;r<e.length;)(n=e[r++])&&(a=co(n))&&(s&&(s+=" "),s+=a);return s},co=e=>{if(typeof e=="string")return e;let r,n="";for(let a=0;a<e.length;a++)e[a]&&(r=co(e[a]))&&(n&&(n+=" "),n+=r);return n},wc=(e,...r)=>{let n,a,s,o;const l=d=>{const h=r.reduce((m,u)=>u(m),e());return n=gc(h),a=n.cache.get,s=n.cache.set,o=i,i(d)},i=d=>{const h=a(d);if(h)return h;const m=vc(d,n);return s(d,m),m};return o=l,(...d)=>o(kc(...d))},yc=[],tt=e=>{const r=n=>n[e]||yc;return r.isThemeGetter=!0,r},ho=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,uo=/^\((?:(\w[\w-]*):)?(.+)\)$/i,jc=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Nc=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Cc=/\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$/,Sc=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Tc=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Ec=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Lt=e=>jc.test(e),Pe=e=>!!e&&!Number.isNaN(Number(e)),kt=e=>!!e&&Number.isInteger(Number(e)),yn=e=>e.endsWith("%")&&Pe(e.slice(0,-1)),Nt=e=>Nc.test(e),mo=()=>!0,Lc=e=>Cc.test(e)&&!Sc.test(e),da=()=>!1,Ic=e=>Tc.test(e),zc=e=>Ec.test(e),Pc=e=>!ue(e)&&!pe(e),Rc=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)),_c=e=>_t(e,go,da),ue=e=>ho.test(e),Bt=e=>_t(e,xo,Lc),Ha=e=>_t(e,Fc,Pe),Mc=e=>_t(e,vo,mo),Ac=e=>_t(e,bo,da),Fa=e=>_t(e,po,da),$c=e=>_t(e,fo,zc),Ar=e=>_t(e,ko,Ic),pe=e=>uo.test(e),gr=e=>Kt(e,xo),Dc=e=>Kt(e,bo),Oa=e=>Kt(e,po),Bc=e=>Kt(e,go),Gc=e=>Kt(e,fo),$r=e=>Kt(e,ko,!0),Hc=e=>Kt(e,vo,!0),_t=(e,r,n)=>{const a=ho.exec(e);return a?a[1]?r(a[1]):n(a[2]):!1},Kt=(e,r,n=!1)=>{const a=uo.exec(e);return a?a[1]?r(a[1]):n:!1},po=e=>e==="position"||e==="percentage",fo=e=>e==="image"||e==="url",go=e=>e==="length"||e==="size"||e==="bg-size",xo=e=>e==="length",Fc=e=>e==="number",bo=e=>e==="family-name",vo=e=>e==="number"||e==="weight",ko=e=>e==="shadow",Oc=()=>{const e=tt("color"),r=tt("font"),n=tt("text"),a=tt("font-weight"),s=tt("tracking"),o=tt("leading"),l=tt("breakpoint"),i=tt("container"),d=tt("spacing"),h=tt("radius"),m=tt("shadow"),u=tt("inset-shadow"),p=tt("text-shadow"),f=tt("drop-shadow"),g=tt("blur"),x=tt("perspective"),j=tt("aspect"),b=tt("ease"),k=tt("animate"),y=()=>["auto","avoid","all","avoid-page","page","left","right","column"],v=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],w=()=>[...v(),pe,ue],C=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto","contain","none"],E=()=>[pe,ue,d],R=()=>[Lt,"full","auto",...E()],_=()=>[kt,"none","subgrid",pe,ue],Y=()=>["auto",{span:["full",kt,pe,ue]},kt,pe,ue],W=()=>[kt,"auto",pe,ue],re=()=>["auto","min","max","fr",pe,ue],F=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],A=()=>["start","end","center","stretch","center-safe","end-safe"],J=()=>["auto",...E()],Z=()=>[Lt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...E()],M=()=>[Lt,"screen","full","dvw","lvw","svw","min","max","fit",...E()],ie=()=>[Lt,"screen","full","lh","dvh","lvh","svh","min","max","fit",...E()],O=()=>[e,pe,ue],G=()=>[...v(),Oa,Fa,{position:[pe,ue]}],H=()=>["no-repeat",{repeat:["","x","y","space","round"]}],T=()=>["auto","cover","contain",Bc,_c,{size:[pe,ue]}],$=()=>[yn,gr,Bt],D=()=>["","none","full",h,pe,ue],L=()=>["",Pe,gr,Bt],S=()=>["solid","dashed","dotted","double"],U=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],B=()=>[Pe,yn,Oa,Fa],le=()=>["","none",g,pe,ue],K=()=>["none",Pe,pe,ue],de=()=>["none",Pe,pe,ue],ee=()=>[Pe,pe,ue],ve=()=>[Lt,"full",...E()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Nt],breakpoint:[Nt],color:[mo],container:[Nt],"drop-shadow":[Nt],ease:["in","out","in-out"],font:[Pc],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Nt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Nt],shadow:[Nt],spacing:["px",Pe],text:[Nt],"text-shadow":[Nt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Lt,ue,pe,j]}],container:["container"],"container-type":[{"@container":["","normal","size",pe,ue]}],"container-named":[Rc],columns:[{columns:[Pe,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:w()}],overflow:[{overflow:C()}],"overflow-x":[{"overflow-x":C()}],"overflow-y":[{"overflow-y":C()}],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:[kt,"auto",pe,ue]}],basis:[{basis:[Lt,"full","auto",i,...E()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Pe,Lt,"auto","initial","none",ue]}],grow:[{grow:["",Pe,pe,ue]}],shrink:[{shrink:["",Pe,pe,ue]}],order:[{order:[kt,"first","last","none",pe,ue]}],"grid-cols":[{"grid-cols":_()}],"col-start-end":[{col:Y()}],"col-start":[{"col-start":W()}],"col-end":[{"col-end":W()}],"grid-rows":[{"grid-rows":_()}],"row-start-end":[{row:Y()}],"row-start":[{"row-start":W()}],"row-end":[{"row-end":W()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":re()}],"auto-rows":[{"auto-rows":re()}],gap:[{gap:E()}],"gap-x":[{"gap-x":E()}],"gap-y":[{"gap-y":E()}],"justify-content":[{justify:[...F(),"normal"]}],"justify-items":[{"justify-items":[...A(),"normal"]}],"justify-self":[{"justify-self":["auto",...A()]}],"align-content":[{content:["normal",...F()]}],"align-items":[{items:[...A(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...A(),{baseline:["","last"]}]}],"place-content":[{"place-content":F()}],"place-items":[{"place-items":[...A(),"baseline"]}],"place-self":[{"place-self":["auto",...A()]}],p:[{p:E()}],px:[{px:E()}],py:[{py:E()}],ps:[{ps:E()}],pe:[{pe:E()}],pbs:[{pbs:E()}],pbe:[{pbe:E()}],pt:[{pt:E()}],pr:[{pr:E()}],pb:[{pb:E()}],pl:[{pl:E()}],m:[{m:J()}],mx:[{mx:J()}],my:[{my:J()}],ms:[{ms:J()}],me:[{me:J()}],mbs:[{mbs:J()}],mbe:[{mbe:J()}],mt:[{mt:J()}],mr:[{mr:J()}],mb:[{mb:J()}],ml:[{ml:J()}],"space-x":[{"space-x":E()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":E()}],"space-y-reverse":["space-y-reverse"],size:[{size:Z()}],"inline-size":[{inline:["auto",...M()]}],"min-inline-size":[{"min-inline":["auto",...M()]}],"max-inline-size":[{"max-inline":["none",...M()]}],"block-size":[{block:["auto",...ie()]}],"min-block-size":[{"min-block":["auto",...ie()]}],"max-block-size":[{"max-block":["none",...ie()]}],w:[{w:[i,"screen",...Z()]}],"min-w":[{"min-w":[i,"screen","none",...Z()]}],"max-w":[{"max-w":[i,"screen","none","prose",{screen:[l]},...Z()]}],h:[{h:["screen","lh",...Z()]}],"min-h":[{"min-h":["screen","lh","none",...Z()]}],"max-h":[{"max-h":["screen","lh",...Z()]}],"font-size":[{text:["base",n,gr,Bt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,Hc,Mc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",yn,ue]}],"font-family":[{font:[Dc,Ac,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":[Pe,"none",pe,Ha]}],leading:[{leading:[o,...E()]}],"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:O()}],"text-color":[{text:O()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...S(),"wavy"]}],"text-decoration-thickness":[{decoration:[Pe,"from-font","auto",pe,Bt]}],"text-decoration-color":[{decoration:O()}],"underline-offset":[{"underline-offset":[Pe,"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:E()}],"tab-size":[{tab:[kt,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:G()}],"bg-repeat":[{bg:H()}],"bg-size":[{bg:T()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},kt,pe,ue],radial:["",pe,ue],conic:[kt,pe,ue]},Gc,$c]}],"bg-color":[{bg:O()}],"gradient-from-pos":[{from:$()}],"gradient-via-pos":[{via:$()}],"gradient-to-pos":[{to:$()}],"gradient-from":[{from:O()}],"gradient-via":[{via:O()}],"gradient-to":[{to:O()}],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:L()}],"border-w-x":[{"border-x":L()}],"border-w-y":[{"border-y":L()}],"border-w-s":[{"border-s":L()}],"border-w-e":[{"border-e":L()}],"border-w-bs":[{"border-bs":L()}],"border-w-be":[{"border-be":L()}],"border-w-t":[{"border-t":L()}],"border-w-r":[{"border-r":L()}],"border-w-b":[{"border-b":L()}],"border-w-l":[{"border-l":L()}],"divide-x":[{"divide-x":L()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":L()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...S(),"hidden","none"]}],"divide-style":[{divide:[...S(),"hidden","none"]}],"border-color":[{border:O()}],"border-color-x":[{"border-x":O()}],"border-color-y":[{"border-y":O()}],"border-color-s":[{"border-s":O()}],"border-color-e":[{"border-e":O()}],"border-color-bs":[{"border-bs":O()}],"border-color-be":[{"border-be":O()}],"border-color-t":[{"border-t":O()}],"border-color-r":[{"border-r":O()}],"border-color-b":[{"border-b":O()}],"border-color-l":[{"border-l":O()}],"divide-color":[{divide:O()}],"outline-style":[{outline:[...S(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Pe,pe,ue]}],"outline-w":[{outline:["",Pe,gr,Bt]}],"outline-color":[{outline:O()}],shadow:[{shadow:["","none",m,$r,Ar]}],"shadow-color":[{shadow:O()}],"inset-shadow":[{"inset-shadow":["none",u,$r,Ar]}],"inset-shadow-color":[{"inset-shadow":O()}],"ring-w":[{ring:L()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:O()}],"ring-offset-w":[{"ring-offset":[Pe,Bt]}],"ring-offset-color":[{"ring-offset":O()}],"inset-ring-w":[{"inset-ring":L()}],"inset-ring-color":[{"inset-ring":O()}],"text-shadow":[{"text-shadow":["none",p,$r,Ar]}],"text-shadow-color":[{"text-shadow":O()}],opacity:[{opacity:[Pe,pe,ue]}],"mix-blend":[{"mix-blend":[...U(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":U()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Pe]}],"mask-image-linear-from-pos":[{"mask-linear-from":B()}],"mask-image-linear-to-pos":[{"mask-linear-to":B()}],"mask-image-linear-from-color":[{"mask-linear-from":O()}],"mask-image-linear-to-color":[{"mask-linear-to":O()}],"mask-image-t-from-pos":[{"mask-t-from":B()}],"mask-image-t-to-pos":[{"mask-t-to":B()}],"mask-image-t-from-color":[{"mask-t-from":O()}],"mask-image-t-to-color":[{"mask-t-to":O()}],"mask-image-r-from-pos":[{"mask-r-from":B()}],"mask-image-r-to-pos":[{"mask-r-to":B()}],"mask-image-r-from-color":[{"mask-r-from":O()}],"mask-image-r-to-color":[{"mask-r-to":O()}],"mask-image-b-from-pos":[{"mask-b-from":B()}],"mask-image-b-to-pos":[{"mask-b-to":B()}],"mask-image-b-from-color":[{"mask-b-from":O()}],"mask-image-b-to-color":[{"mask-b-to":O()}],"mask-image-l-from-pos":[{"mask-l-from":B()}],"mask-image-l-to-pos":[{"mask-l-to":B()}],"mask-image-l-from-color":[{"mask-l-from":O()}],"mask-image-l-to-color":[{"mask-l-to":O()}],"mask-image-x-from-pos":[{"mask-x-from":B()}],"mask-image-x-to-pos":[{"mask-x-to":B()}],"mask-image-x-from-color":[{"mask-x-from":O()}],"mask-image-x-to-color":[{"mask-x-to":O()}],"mask-image-y-from-pos":[{"mask-y-from":B()}],"mask-image-y-to-pos":[{"mask-y-to":B()}],"mask-image-y-from-color":[{"mask-y-from":O()}],"mask-image-y-to-color":[{"mask-y-to":O()}],"mask-image-radial":[{"mask-radial":[pe,ue]}],"mask-image-radial-from-pos":[{"mask-radial-from":B()}],"mask-image-radial-to-pos":[{"mask-radial-to":B()}],"mask-image-radial-from-color":[{"mask-radial-from":O()}],"mask-image-radial-to-color":[{"mask-radial-to":O()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":v()}],"mask-image-conic-pos":[{"mask-conic":[Pe]}],"mask-image-conic-from-pos":[{"mask-conic-from":B()}],"mask-image-conic-to-pos":[{"mask-conic-to":B()}],"mask-image-conic-from-color":[{"mask-conic-from":O()}],"mask-image-conic-to-color":[{"mask-conic-to":O()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:G()}],"mask-repeat":[{mask:H()}],"mask-size":[{mask:T()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",pe,ue]}],filter:[{filter:["","none",pe,ue]}],blur:[{blur:le()}],brightness:[{brightness:[Pe,pe,ue]}],contrast:[{contrast:[Pe,pe,ue]}],"drop-shadow":[{"drop-shadow":["","none",f,$r,Ar]}],"drop-shadow-color":[{"drop-shadow":O()}],grayscale:[{grayscale:["",Pe,pe,ue]}],"hue-rotate":[{"hue-rotate":[Pe,pe,ue]}],invert:[{invert:["",Pe,pe,ue]}],saturate:[{saturate:[Pe,pe,ue]}],sepia:[{sepia:["",Pe,pe,ue]}],"backdrop-filter":[{"backdrop-filter":["","none",pe,ue]}],"backdrop-blur":[{"backdrop-blur":le()}],"backdrop-brightness":[{"backdrop-brightness":[Pe,pe,ue]}],"backdrop-contrast":[{"backdrop-contrast":[Pe,pe,ue]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Pe,pe,ue]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Pe,pe,ue]}],"backdrop-invert":[{"backdrop-invert":["",Pe,pe,ue]}],"backdrop-opacity":[{"backdrop-opacity":[Pe,pe,ue]}],"backdrop-saturate":[{"backdrop-saturate":[Pe,pe,ue]}],"backdrop-sepia":[{"backdrop-sepia":["",Pe,pe,ue]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":E()}],"border-spacing-x":[{"border-spacing-x":E()}],"border-spacing-y":[{"border-spacing-y":E()}],"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:[Pe,"initial",pe,ue]}],ease:[{ease:["linear","initial",b,pe,ue]}],delay:[{delay:[Pe,pe,ue]}],animate:[{animate:["none",k,pe,ue]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[x,pe,ue]}],"perspective-origin":[{"perspective-origin":w()}],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:w()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ve()}],"translate-x":[{"translate-x":ve()}],"translate-y":[{"translate-y":ve()}],"translate-z":[{"translate-z":ve()}],"translate-none":["translate-none"],zoom:[{zoom:[kt,pe,ue]}],accent:[{accent:O()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:O()}],"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":O()}],"scrollbar-track-color":[{"scrollbar-track":O()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":E()}],"scroll-mx":[{"scroll-mx":E()}],"scroll-my":[{"scroll-my":E()}],"scroll-ms":[{"scroll-ms":E()}],"scroll-me":[{"scroll-me":E()}],"scroll-mbs":[{"scroll-mbs":E()}],"scroll-mbe":[{"scroll-mbe":E()}],"scroll-mt":[{"scroll-mt":E()}],"scroll-mr":[{"scroll-mr":E()}],"scroll-mb":[{"scroll-mb":E()}],"scroll-ml":[{"scroll-ml":E()}],"scroll-p":[{"scroll-p":E()}],"scroll-px":[{"scroll-px":E()}],"scroll-py":[{"scroll-py":E()}],"scroll-ps":[{"scroll-ps":E()}],"scroll-pe":[{"scroll-pe":E()}],"scroll-pbs":[{"scroll-pbs":E()}],"scroll-pbe":[{"scroll-pbe":E()}],"scroll-pt":[{"scroll-pt":E()}],"scroll-pr":[{"scroll-pr":E()}],"scroll-pb":[{"scroll-pb":E()}],"scroll-pl":[{"scroll-pl":E()}],"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",...O()]}],"stroke-w":[{stroke:[Pe,gr,Bt,Ha]}],stroke:[{stroke:["none",...O()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Wc=wc(Oc),Wa=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Ua=so,Ir=(e,r)=>n=>{var a;if((r==null?void 0:r.variants)==null)return Ua(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 m=n==null?void 0:n[h],u=o==null?void 0:o[h];if(m===null)return null;const p=Wa(m)||Wa(u);return s[h][p]}),i=n&&Object.entries(n).reduce((h,m)=>{let[u,p]=m;return p===void 0||(h[u]=p),h},{}),d=r==null||(a=r.compoundVariants)===null||a===void 0?void 0:a.reduce((h,m)=>{let{class:u,className:p,...f}=m;return Object.entries(f).every(g=>{let[x,j]=g;return Array.isArray(j)?j.includes({...o,...i}[x]):{...o,...i}[x]===j})?[...h,u,p]:h},[]);return Ua(e,l,d,n==null?void 0:n.class,n==null?void 0:n.className)},an=c.createContext(null);an.displayName="PanelGroupContext";const Ke={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"},ca=10,Vt=c.useLayoutEffect,Va=Fd.useId,Uc=typeof Va=="function"?Va:()=>null;let Vc=0;function ha(e=null){const r=Uc(),n=c.useRef(e||r||null);return n.current===null&&(n.current=""+Vc++),e??n.current}function wo({children:e,className:r="",collapsedSize:n,collapsible:a,defaultSize:s,forwardedRef:o,id:l,maxSize:i,minSize:d,onCollapse:h,onExpand:m,onResize:u,order:p,style:f,tagName:g="div",...x}){const j=c.useContext(an);if(j===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:b,expandPanel:k,getPanelSize:y,getPanelStyle:v,groupId:w,isPanelCollapsed:C,reevaluatePanelConstraints:N,registerPanel:E,resizePanel:R,unregisterPanel:_}=j,Y=ha(l),W=c.useRef({callbacks:{onCollapse:h,onExpand:m,onResize:u},constraints:{collapsedSize:n,collapsible:a,defaultSize:s,maxSize:i,minSize:d},id:Y,idIsFromProps:l!==void 0,order:p});c.useRef({didLogMissingDefaultSizeWarning:!1}),Vt(()=>{const{callbacks:F,constraints:A}=W.current,J={...A};W.current.id=Y,W.current.idIsFromProps=l!==void 0,W.current.order=p,F.onCollapse=h,F.onExpand=m,F.onResize=u,A.collapsedSize=n,A.collapsible=a,A.defaultSize=s,A.maxSize=i,A.minSize=d,(J.collapsedSize!==A.collapsedSize||J.collapsible!==A.collapsible||J.maxSize!==A.maxSize||J.minSize!==A.minSize)&&N(W.current,J)}),Vt(()=>{const F=W.current;return E(F),()=>{_(F)}},[p,Y,E,_]),c.useImperativeHandle(o,()=>({collapse:()=>{b(W.current)},expand:F=>{k(W.current,F)},getId(){return Y},getSize(){return y(W.current)},isCollapsed(){return C(W.current)},isExpanded(){return!C(W.current)},resize:F=>{R(W.current,F)}}),[b,k,y,C,Y,R]);const re=v(W.current,s);return c.createElement(g,{...x,children:e,className:r,id:Y,style:{...re,...f},[Ke.groupId]:w,[Ke.panel]:"",[Ke.panelCollapsible]:a||void 0,[Ke.panelId]:Y,[Ke.panelSize]:parseFloat(""+re.flexGrow).toFixed(1)})}const yo=c.forwardRef((e,r)=>c.createElement(wo,{...e,forwardedRef:r}));wo.displayName="Panel";yo.displayName="forwardRef(Panel)";let Hn=null,Wr=-1,zt=null;function Xc(e,r,n){const a=(r&To)!==0,s=(r&Eo)!==0,o=(r&Lo)!==0,l=(r&Io)!==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 qc(){zt!==null&&(document.head.removeChild(zt),Hn=null,zt=null,Wr=-1)}function jn(e,r,n){var a,s;const o=Xc(e,r);if(Hn!==o){if(Hn=o,zt===null&&(zt=document.createElement("style"),document.head.appendChild(zt)),Wr>=0){var l;(l=zt.sheet)===null||l===void 0||l.removeRule(Wr)}Wr=(a=(s=zt.sheet)===null||s===void 0?void 0:s.insertRule(`*{cursor: ${o} !important;}`))!==null&&a!==void 0?a:-1}}function jo(e){return e.type==="keydown"}function No(e){return e.type.startsWith("pointer")}function Co(e){return e.type.startsWith("mouse")}function sn(e){if(No(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Co(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function Kc(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function Yc(e,r,n){return e.x<r.x+r.width&&e.x+e.width>r.x&&e.y<r.y+r.height&&e.y+e.height>r.y}function Zc(e,r){if(e===r)throw new Error("Cannot compare node with itself");const n={a:Ka(e),b:Ka(r)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),r=n.b.pop(),a=e;ze(a,"Stacking order can only be calculated for elements with a common ancestor");const s={a:qa(Xa(n.a)),b:qa(Xa(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 Jc=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Qc(e){var r;const n=getComputedStyle((r=So(e))!==null&&r!==void 0?r:e).display;return n==="flex"||n==="inline-flex"}function eh(e){const r=getComputedStyle(e);return!!(r.position==="fixed"||r.zIndex!=="auto"&&(r.position!=="static"||Qc(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"||Jc.test(r.willChange)||r.webkitOverflowScrolling==="touch")}function Xa(e){let r=e.length;for(;r--;){const n=e[r];if(ze(n,"Missing node"),eh(n))return n}return null}function qa(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Ka(e){const r=[];for(;e;)r.push(e),e=So(e);return r}function So(e){const{parentNode:r}=e;return r&&r instanceof ShadowRoot?r.host:r}const To=1,Eo=2,Lo=4,Io=8,th=Kc()==="coarse";let gt=[],ir=!1,Pt=new Map,on=new Map;const Sr=new Set;function rh(e,r,n,a,s){var o;const{ownerDocument:l}=r,i={direction:n,element:r,hitAreaMargins:a,setResizeHandlerState:s},d=(o=Pt.get(l))!==null&&o!==void 0?o:0;return Pt.set(l,d+1),Sr.add(i),Qr(),function(){var m;on.delete(e),Sr.delete(i);const u=(m=Pt.get(l))!==null&&m!==void 0?m:1;if(Pt.set(l,u-1),Qr(),u===1&&Pt.delete(l),gt.includes(i)){const p=gt.indexOf(i);p>=0&>.splice(p,1),ln(),s("up",!0,null)}}}function nh(e){const{target:r}=e,{x:n,y:a}=sn(e);ir=!0,ua({target:r,x:n,y:a}),Qr(),gt.length>0&&(en("down",e),ln(),e.preventDefault(),zo(r)||e.stopImmediatePropagation())}function Nn(e){const{x:r,y:n}=sn(e);if(ir&&e.type!=="pointerleave"&&e.buttons===0&&(ir=!1,en("up",e)),!ir){const{target:a}=e;ua({target:a,x:r,y:n})}en("move",e),ln(),gt.length>0&&e.preventDefault()}function Cn(e){const{target:r}=e,{x:n,y:a}=sn(e);on.clear(),ir=!1,gt.length>0&&(e.preventDefault(),zo(r)||e.stopImmediatePropagation()),en("up",e),ua({target:r,x:n,y:a}),ln(),Qr()}function zo(e){let r=e;for(;r;){if(r.hasAttribute(Ke.resizeHandle))return!0;r=r.parentElement}return!1}function ua({target:e,x:r,y:n}){gt.splice(0);let a=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(a=e),Sr.forEach(s=>{const{element:o,hitAreaMargins:l}=s,i=o.getBoundingClientRect(),{bottom:d,left:h,right:m,top:u}=i,p=th?l.coarse:l.fine;if(r>=h-p&&r<=m+p&&n>=u-p&&n<=d+p){if(a!==null&&document.contains(a)&&o!==a&&!o.contains(a)&&!a.contains(o)&&Zc(a,o)>0){let g=a,x=!1;for(;g&&!g.contains(o);){if(Yc(g.getBoundingClientRect(),i)){x=!0;break}g=g.parentElement}if(x)return}gt.push(s)}})}function Sn(e,r){on.set(e,r)}function ln(){let e=!1,r=!1;gt.forEach(a=>{const{direction:s}=a;s==="horizontal"?e=!0:r=!0});let n=0;on.forEach(a=>{n|=a}),e&&r?jn("intersection",n):e?jn("horizontal",n):r?jn("vertical",n):qc()}let Tn;function Qr(){var e;(e=Tn)===null||e===void 0||e.abort(),Tn=new AbortController;const r={capture:!0,signal:Tn.signal};Sr.size&&(ir?(gt.length>0&&Pt.forEach((n,a)=>{const{body:s}=a;n>0&&(s.addEventListener("contextmenu",Cn,r),s.addEventListener("pointerleave",Nn,r),s.addEventListener("pointermove",Nn,r))}),Pt.forEach((n,a)=>{const{body:s}=a;s.addEventListener("pointerup",Cn,r),s.addEventListener("pointercancel",Cn,r)})):Pt.forEach((n,a)=>{const{body:s}=a;n>0&&(s.addEventListener("pointerdown",nh,r),s.addEventListener("pointermove",Nn,r))}))}function en(e,r){Sr.forEach(n=>{const{setResizeHandlerState:a}=n,s=gt.includes(n);a(e,s,r)})}function ah(){const[e,r]=c.useState(0);return c.useCallback(()=>r(n=>n+1),[])}function ze(e,r){if(!e)throw console.error(r),Error(r)}function qt(e,r,n=ca){return e.toFixed(n)===r.toFixed(n)?0:e>r?1:-1}function Ct(e,r,n=ca){return qt(e,r,n)===0}function mt(e,r,n){return qt(e,r,n)===0}function sh(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(!mt(s,o,n))return!1}return!0}function or({panelConstraints:e,panelIndex:r,size:n}){const a=e[r];ze(a!=null,`Panel constraints not found for index ${r}`);let{collapsedSize:s=0,collapsible:o,maxSize:l=100,minSize:i=0}=a;if(qt(n,i)<0)if(o){const d=(s+i)/2;qt(n,d)<0?n=s:n=i}else n=i;return n=Math.min(l,n),n=parseFloat(n.toFixed(ca)),n}function wr({delta:e,initialLayout:r,panelConstraints:n,pivotIndices:a,prevLayout:s,trigger:o}){if(mt(e,0))return r;const l=[...r],[i,d]=a;ze(i!=null,"Invalid first pivot index"),ze(d!=null,"Invalid second pivot index");let h=0;if(o==="keyboard"){{const u=e<0?d:i,p=n[u];ze(p,`Panel constraints not found for index ${u}`);const{collapsedSize:f=0,collapsible:g,minSize:x=0}=p;if(g){const j=r[u];if(ze(j!=null,`Previous layout not found for panel index ${u}`),mt(j,f)){const b=x-j;qt(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}{const u=e<0?i:d,p=n[u];ze(p,`No panel constraints found for index ${u}`);const{collapsedSize:f=0,collapsible:g,minSize:x=0}=p;if(g){const j=r[u];if(ze(j!=null,`Previous layout not found for panel index ${u}`),mt(j,x)){const b=j-f;qt(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}}{const u=e<0?1:-1;let p=e<0?d:i,f=0;for(;;){const x=r[p];ze(x!=null,`Previous layout not found for panel index ${p}`);const b=or({panelConstraints:n,panelIndex:p,size:100})-x;if(f+=b,p+=u,p<0||p>=n.length)break}const g=Math.min(Math.abs(e),Math.abs(f));e=e<0?0-g:g}{let p=e<0?i:d;for(;p>=0&&p<n.length;){const f=Math.abs(e)-Math.abs(h),g=r[p];ze(g!=null,`Previous layout not found for panel index ${p}`);const x=g-f,j=or({panelConstraints:n,panelIndex:p,size:x});if(!mt(g,j)&&(h+=g-j,l[p]=j,h.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?p--:p++}}if(sh(s,l))return s;{const u=e<0?d:i,p=r[u];ze(p!=null,`Previous layout not found for panel index ${u}`);const f=p+h,g=or({panelConstraints:n,panelIndex:u,size:f});if(l[u]=g,!mt(g,f)){let x=f-g,b=e<0?d:i;for(;b>=0&&b<n.length;){const k=l[b];ze(k!=null,`Previous layout not found for panel index ${b}`);const y=k+x,v=or({panelConstraints:n,panelIndex:b,size:y});if(mt(k,v)||(x-=v-k,l[b]=v),mt(x,0))break;e>0?b--:b++}}}const m=l.reduce((u,p)=>p+u,0);return mt(m,100)?l:s}function oh({layout:e,panelsArray:r,pivotIndices:n}){let a=0,s=100,o=0,l=0;const i=n[0];ze(i!=null,"No pivot index found"),r.forEach((u,p)=>{const{constraints:f}=u,{maxSize:g=100,minSize:x=0}=f;p===i?(a=x,s=g):(o+=x,l+=g)});const d=Math.min(s,100-o),h=Math.max(a,100-l),m=e[i];return{valueMax:d,valueMin:h,valueNow:m}}function Tr(e,r=document){return Array.from(r.querySelectorAll(`[${Ke.resizeHandleId}][data-panel-group-id="${e}"]`))}function Po(e,r,n=document){const s=Tr(e,n).findIndex(o=>o.getAttribute(Ke.resizeHandleId)===r);return s??null}function Ro(e,r,n){const a=Po(e,r,n);return a!=null?[a,a+1]:[-1,-1]}function lh(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function _o(e,r=document){if(lh(r)&&r.dataset.panelGroupId==e)return r;const n=r.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function dn(e,r=document){const n=r.querySelector(`[${Ke.resizeHandleId}="${e}"]`);return n||null}function ih(e,r,n,a=document){var s,o,l,i;const d=dn(r,a),h=Tr(e,a),m=d?h.indexOf(d):-1,u=(s=(o=n[m])===null||o===void 0?void 0:o.id)!==null&&s!==void 0?s:null,p=(l=(i=n[m+1])===null||i===void 0?void 0:i.id)!==null&&l!==void 0?l:null;return[u,p]}function dh({committedValuesRef:e,eagerValuesRef:r,groupId:n,layout:a,panelDataArray:s,panelGroupElement:o,setLayout:l}){c.useRef({didWarnAboutMissingResizeHandle:!1}),Vt(()=>{if(!o)return;const i=Tr(n,o);for(let d=0;d<s.length-1;d++){const{valueMax:h,valueMin:m,valueNow:u}=oh({layout:a,panelsArray:s,pivotIndices:[d,d+1]}),p=i[d];if(p!=null){const f=s[d];ze(f,`No panel data found for index "${d}"`),p.setAttribute("aria-controls",f.id),p.setAttribute("aria-valuemax",""+Math.round(h)),p.setAttribute("aria-valuemin",""+Math.round(m)),p.setAttribute("aria-valuenow",u!=null?""+Math.round(u):"")}}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;ze(i,"Eager values not found");const{panelDataArray:d}=i,h=_o(n,o);ze(h!=null,`No group found for id "${n}"`);const m=Tr(n,o);ze(m,`No resize handles found for group id "${n}"`);const u=m.map(p=>{const f=p.getAttribute(Ke.resizeHandleId);ze(f,"Resize handle element has no handle id attribute");const[g,x]=ih(n,f,d,o);if(g==null||x==null)return()=>{};const j=b=>{if(!b.defaultPrevented)switch(b.key){case"Enter":{b.preventDefault();const k=d.findIndex(y=>y.id===g);if(k>=0){const y=d[k];ze(y,`No panel data found for index ${k}`);const v=a[k],{collapsedSize:w=0,collapsible:C,minSize:N=0}=y.constraints;if(v!=null&&C){const E=wr({delta:mt(v,w)?N-w:w-v,initialLayout:a,panelConstraints:d.map(R=>R.constraints),pivotIndices:Ro(n,f,o),prevLayout:a,trigger:"keyboard"});a!==E&&l(E)}}break}}};return p.addEventListener("keydown",j),()=>{p.removeEventListener("keydown",j)}});return()=>{u.forEach(p=>p())}},[o,e,r,n,a,s,l])}function Ya(e,r){if(e.length!==r.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==r[n])return!1;return!0}function Mo(e,r){const n=e==="horizontal",{x:a,y:s}=sn(r);return n?a:s}function ch(e,r,n,a,s){const o=n==="horizontal",l=dn(r,s);ze(l,`No resize handle element found for id "${r}"`);const i=l.getAttribute(Ke.groupId);ze(i,"Resize handle element has no group id attribute");let{initialCursorPosition:d}=a;const h=Mo(n,e),m=_o(i,s);ze(m,`No group element found for id "${i}"`);const u=m.getBoundingClientRect(),p=o?u.width:u.height;return(h-d)/p*100}function hh(e,r,n,a,s,o){if(jo(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:ch(e,r,n,a,o)}function uh({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];ze(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];ze(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 er(e,r,n){r.forEach((a,s)=>{const o=e[s];ze(o,`Panel data not found for index ${s}`);const{callbacks:l,constraints:i,id:d}=o,{collapsedSize:h=0,collapsible:m}=i,u=n[d];if(u==null||a!==u){n[d]=a;const{onCollapse:p,onExpand:f,onResize:g}=l;g&&g(a,u),m&&(p||f)&&(f&&(u==null||Ct(u,h))&&!Ct(a,h)&&f(),p&&(u==null||!Ct(u,h))&&Ct(a,h)&&p())}})}function Dr(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 mh({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 ph(e,r=10){let n=null;return(...s)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...s)},r)}}function Za(e){try{if(typeof localStorage<"u")e.getItem=r=>localStorage.getItem(r),e.setItem=(r,n)=>{localStorage.setItem(r,n)};else throw new Error("localStorage not supported in this environment")}catch(r){console.error(r),e.getItem=()=>null,e.setItem=()=>{}}}function Ao(e){return`react-resizable-panels:${e}`}function $o(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 Do(e,r){try{const n=Ao(e),a=r.getItem(n);if(a){const s=JSON.parse(a);if(typeof s=="object"&&s!=null)return s}}catch{}return null}function fh(e,r,n){var a,s;const o=(a=Do(e,n))!==null&&a!==void 0?a:{},l=$o(r);return(s=o[l])!==null&&s!==void 0?s:null}function gh(e,r,n,a,s){var o;const l=Ao(e),i=$o(r),d=(o=Do(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 Ja({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(!mt(a,100)&&n.length>0)for(let o=0;o<r.length;o++){const l=n[o];ze(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];ze(l!=null,`No layout data found for index ${o}`);const i=or({panelConstraints:r,panelIndex:o,size:l});l!=i&&(s+=l-i,n[o]=i)}if(!mt(s,0))for(let o=0;o<r.length;o++){const l=n[o];ze(l!=null,`No layout data found for index ${o}`);const i=l+s,d=or({panelConstraints:r,panelIndex:o,size:i});if(l!==d&&(s-=d-l,n[o]=d,mt(s,0)))break}return n}const xh=100,yr={getItem:e=>(Za(yr),yr.getItem(e)),setItem:(e,r)=>{Za(yr),yr.setItem(e,r)}},Qa={};function Bo({autoSaveId:e=null,children:r,className:n="",direction:a,forwardedRef:s,id:o=null,onLayout:l=null,keyboardResizeBy:i=null,storage:d=yr,style:h,tagName:m="div",...u}){const p=ha(o),f=c.useRef(null),[g,x]=c.useState(null),[j,b]=c.useState([]),k=ah(),y=c.useRef({}),v=c.useRef(new Map),w=c.useRef(0),C=c.useRef({autoSaveId:e,direction:a,dragState:g,id:p,keyboardResizeBy:i,onLayout:l,storage:d}),N=c.useRef({layout:j,panelDataArray:[],panelDataArrayChanged:!1});c.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),c.useImperativeHandle(s,()=>({getId:()=>C.current.id,getLayout:()=>{const{layout:T}=N.current;return T},setLayout:T=>{const{onLayout:$}=C.current,{layout:D,panelDataArray:L}=N.current,S=Ja({layout:T,panelConstraints:L.map(U=>U.constraints)});Ya(D,S)||(b(S),N.current.layout=S,$&&$(S),er(L,S,y.current))}}),[]),Vt(()=>{C.current.autoSaveId=e,C.current.direction=a,C.current.dragState=g,C.current.id=p,C.current.onLayout=l,C.current.storage=d}),dh({committedValuesRef:C,eagerValuesRef:N,groupId:p,layout:j,panelDataArray:N.current.panelDataArray,setLayout:b,panelGroupElement:f.current}),c.useEffect(()=>{const{panelDataArray:T}=N.current;if(e){if(j.length===0||j.length!==T.length)return;let $=Qa[e];$==null&&($=ph(gh,xh),Qa[e]=$);const D=[...T],L=new Map(v.current);$(e,D,L,j,d)}},[e,j,d]),c.useEffect(()=>{});const E=c.useCallback(T=>{const{onLayout:$}=C.current,{layout:D,panelDataArray:L}=N.current;if(T.constraints.collapsible){const S=L.map(K=>K.constraints),{collapsedSize:U=0,panelSize:B,pivotIndices:le}=Gt(L,T,D);if(ze(B!=null,`Panel size not found for panel "${T.id}"`),!Ct(B,U)){v.current.set(T.id,B);const de=rr(L,T)===L.length-1?B-U:U-B,ee=wr({delta:de,initialLayout:D,panelConstraints:S,pivotIndices:le,prevLayout:D,trigger:"imperative-api"});Dr(D,ee)||(b(ee),N.current.layout=ee,$&&$(ee),er(L,ee,y.current))}}},[]),R=c.useCallback((T,$)=>{const{onLayout:D}=C.current,{layout:L,panelDataArray:S}=N.current;if(T.constraints.collapsible){const U=S.map(ve=>ve.constraints),{collapsedSize:B=0,panelSize:le=0,minSize:K=0,pivotIndices:de}=Gt(S,T,L),ee=$??K;if(Ct(le,B)){const ve=v.current.get(T.id),be=ve!=null&&ve>=ee?ve:ee,we=rr(S,T)===S.length-1?le-be:be-le,fe=wr({delta:we,initialLayout:L,panelConstraints:U,pivotIndices:de,prevLayout:L,trigger:"imperative-api"});Dr(L,fe)||(b(fe),N.current.layout=fe,D&&D(fe),er(S,fe,y.current))}}},[]),_=c.useCallback(T=>{const{layout:$,panelDataArray:D}=N.current,{panelSize:L}=Gt(D,T,$);return ze(L!=null,`Panel size not found for panel "${T.id}"`),L},[]),Y=c.useCallback((T,$)=>{const{panelDataArray:D}=N.current,L=rr(D,T);return mh({defaultSize:$,dragState:g,layout:j,panelData:D,panelIndex:L})},[g,j]),W=c.useCallback(T=>{const{layout:$,panelDataArray:D}=N.current,{collapsedSize:L=0,collapsible:S,panelSize:U}=Gt(D,T,$);return ze(U!=null,`Panel size not found for panel "${T.id}"`),S===!0&&Ct(U,L)},[]),re=c.useCallback(T=>{const{layout:$,panelDataArray:D}=N.current,{collapsedSize:L=0,collapsible:S,panelSize:U}=Gt(D,T,$);return ze(U!=null,`Panel size not found for panel "${T.id}"`),!S||qt(U,L)>0},[]),F=c.useCallback(T=>{const{panelDataArray:$}=N.current;$.push(T),$.sort((D,L)=>{const S=D.order,U=L.order;return S==null&&U==null?0:S==null?-1:U==null?1:S-U}),N.current.panelDataArrayChanged=!0,k()},[k]);Vt(()=>{if(N.current.panelDataArrayChanged){N.current.panelDataArrayChanged=!1;const{autoSaveId:T,onLayout:$,storage:D}=C.current,{layout:L,panelDataArray:S}=N.current;let U=null;if(T){const le=fh(T,S,D);le&&(v.current=new Map(Object.entries(le.expandToSizes)),U=le.layout)}U==null&&(U=uh({panelDataArray:S}));const B=Ja({layout:U,panelConstraints:S.map(le=>le.constraints)});Ya(L,B)||(b(B),N.current.layout=B,$&&$(B),er(S,B,y.current))}}),Vt(()=>{const T=N.current;return()=>{T.layout=[]}},[]);const A=c.useCallback(T=>{let $=!1;const D=f.current;return D&&window.getComputedStyle(D,null).getPropertyValue("direction")==="rtl"&&($=!0),function(S){S.preventDefault();const U=f.current;if(!U)return()=>null;const{direction:B,dragState:le,id:K,keyboardResizeBy:de,onLayout:ee}=C.current,{layout:ve,panelDataArray:be}=N.current,{initialLayout:ye}=le??{},we=Ro(K,T,U);let fe=hh(S,T,B,le,de,U);const Te=B==="horizontal";Te&&$&&(fe=-fe);const oe=be.map(ke=>ke.constraints),Q=wr({delta:fe,initialLayout:ye??ve,panelConstraints:oe,pivotIndices:we,prevLayout:ve,trigger:jo(S)?"keyboard":"mouse-or-touch"}),me=!Dr(ve,Q);(No(S)||Co(S))&&w.current!=fe&&(w.current=fe,!me&&fe!==0?Te?Sn(T,fe<0?To:Eo):Sn(T,fe<0?Lo:Io):Sn(T,0)),me&&(b(Q),N.current.layout=Q,ee&&ee(Q),er(be,Q,y.current))}},[]),J=c.useCallback((T,$)=>{const{onLayout:D}=C.current,{layout:L,panelDataArray:S}=N.current,U=S.map(ve=>ve.constraints),{panelSize:B,pivotIndices:le}=Gt(S,T,L);ze(B!=null,`Panel size not found for panel "${T.id}"`);const de=rr(S,T)===S.length-1?B-$:$-B,ee=wr({delta:de,initialLayout:L,panelConstraints:U,pivotIndices:le,prevLayout:L,trigger:"imperative-api"});Dr(L,ee)||(b(ee),N.current.layout=ee,D&&D(ee),er(S,ee,y.current))},[]),Z=c.useCallback((T,$)=>{const{layout:D,panelDataArray:L}=N.current,{collapsedSize:S=0,collapsible:U}=$,{collapsedSize:B=0,collapsible:le,maxSize:K=100,minSize:de=0}=T.constraints,{panelSize:ee}=Gt(L,T,D);ee!=null&&(U&&le&&Ct(ee,S)?Ct(S,B)||J(T,B):ee<de?J(T,de):ee>K&&J(T,K))},[J]),M=c.useCallback((T,$)=>{const{direction:D}=C.current,{layout:L}=N.current;if(!f.current)return;const S=dn(T,f.current);ze(S,`Drag handle element not found for id "${T}"`);const U=Mo(D,$);x({dragHandleId:T,dragHandleRect:S.getBoundingClientRect(),initialCursorPosition:U,initialLayout:L})},[]),ie=c.useCallback(()=>{x(null)},[]),O=c.useCallback(T=>{const{panelDataArray:$}=N.current,D=rr($,T);D>=0&&($.splice(D,1),delete y.current[T.id],N.current.panelDataArrayChanged=!0,k())},[k]),G=c.useMemo(()=>({collapsePanel:E,direction:a,dragState:g,expandPanel:R,getPanelSize:_,getPanelStyle:Y,groupId:p,isPanelCollapsed:W,isPanelExpanded:re,reevaluatePanelConstraints:Z,registerPanel:F,registerResizeHandle:A,resizePanel:J,startDragging:M,stopDragging:ie,unregisterPanel:O,panelGroupElement:f.current}),[E,g,a,R,_,Y,p,W,re,Z,F,A,J,M,ie,O]),H={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return c.createElement(an.Provider,{value:G},c.createElement(m,{...u,children:r,className:n,id:o,ref:f,style:{...H,...h},[Ke.group]:"",[Ke.groupDirection]:a,[Ke.groupId]:p}))}const Go=c.forwardRef((e,r)=>c.createElement(Bo,{...e,forwardedRef:r}));Bo.displayName="PanelGroup";Go.displayName="forwardRef(PanelGroup)";function rr(e,r){return e.findIndex(n=>n===r||n.id===r.id)}function Gt(e,r,n){const a=rr(e,r),o=a===e.length-1?[a-1,a]:[a,a+1],l=n[a];return{...r.constraints,panelSize:l,pivotIndices:o}}function bh({disabled:e,handleId:r,resizeHandler:n,panelGroupElement:a}){c.useEffect(()=>{if(e||n==null||a==null)return;const s=dn(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(Ke.groupId);ze(i,`No group element found for id "${i}"`);const d=Tr(i,a),h=Po(i,r,a);ze(h!==null,`No resize element found for id "${r}"`);const m=l.shiftKey?h>0?h-1:d.length-1:h+1<d.length?h+1:0;d[m].focus();break}}};return s.addEventListener("keydown",o),()=>{s.removeEventListener("keydown",o)}},[a,e,r,n])}function Ho({children:e=null,className:r="",disabled:n=!1,hitAreaMargins:a,id:s,onBlur:o,onClick:l,onDragging:i,onFocus:d,onPointerDown:h,onPointerUp:m,style:u={},tabIndex:p=0,tagName:f="div",...g}){var x,j;const b=c.useRef(null),k=c.useRef({onClick:l,onDragging:i,onPointerDown:h,onPointerUp:m});c.useEffect(()=>{k.current.onClick=l,k.current.onDragging=i,k.current.onPointerDown=h,k.current.onPointerUp=m});const y=c.useContext(an);if(y===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:v,groupId:w,registerResizeHandle:C,startDragging:N,stopDragging:E,panelGroupElement:R}=y,_=ha(s),[Y,W]=c.useState("inactive"),[re,F]=c.useState(!1),[A,J]=c.useState(null),Z=c.useRef({state:Y});Vt(()=>{Z.current.state=Y}),c.useEffect(()=>{if(n)J(null);else{const G=C(_);J(()=>G)}},[n,_,C]);const M=(x=a==null?void 0:a.coarse)!==null&&x!==void 0?x:15,ie=(j=a==null?void 0:a.fine)!==null&&j!==void 0?j:5;c.useEffect(()=>{if(n||A==null)return;const G=b.current;ze(G,"Element ref not attached");let H=!1;return rh(_,G,v,{coarse:M,fine:ie},($,D,L)=>{if(!D){W("inactive");return}switch($){case"down":{W("drag"),H=!1,ze(L,'Expected event to be defined for "down" action'),N(_,L);const{onDragging:S,onPointerDown:U}=k.current;S==null||S(!0),U==null||U();break}case"move":{const{state:S}=Z.current;H=!0,S!=="drag"&&W("hover"),ze(L,'Expected event to be defined for "move" action'),A(L);break}case"up":{W("hover"),E();const{onClick:S,onDragging:U,onPointerUp:B}=k.current;U==null||U(!1),B==null||B(),H||S==null||S();break}}})},[M,v,n,ie,C,_,A,N,E]),bh({disabled:n,handleId:_,resizeHandler:A,panelGroupElement:R});const O={touchAction:"none",userSelect:"none"};return c.createElement(f,{...g,children:e,className:r,id:s,onBlur:()=>{F(!1),o==null||o()},onFocus:()=>{F(!0),d==null||d()},ref:b,role:"separator",style:{...O,...u},tabIndex:p,[Ke.groupDirection]:v,[Ke.groupId]:w,[Ke.resizeHandle]:"",[Ke.resizeHandleActive]:Y==="drag"?"pointer":re?"keyboard":void 0,[Ke.resizeHandleEnabled]:!n,[Ke.resizeHandleId]:_,[Ke.resizeHandleState]:Y})}Ho.displayName="PanelResizeHandle";var vh=Object.defineProperty,kh=Object.getOwnPropertyNames,Oe=(e,r)=>function(){return e&&(r=(0,e[kh(e)[0]])(e=0)),r},wh=(e,r)=>{for(var n in r)vh(e,n,{get:r[n],enumerable:!0})};function st(...e){return Wc(so(e))}var Mt=Oe({"src/components/graph-ui/utils.ts"(){}});function Er({asChild:e=!1,className:r,size:n,variant:a,...s}){const o=e?Qs:"button";return t.jsx(o,{"data-slot":"button",className:st(Fo({variant:a,size:n,className:r})),...s})}var Fo,cn=Oe({"src/components/graph-ui/Button.tsx"(){Mt(),Fo=Ir("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 Oo(...e){return e.filter(Boolean).join(" ")}function Fn({className:e,...r}){return t.jsx(Go,{"data-slot":"resizable-panel-group",className:Oo("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...r})}function lr({...e}){return t.jsx(yo,{"data-slot":"resizable-panel",...e})}function On({withHandle:e,className:r,...n}){return t.jsx(Ho,{"data-slot":"resizable-handle",className:Oo("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(P.GripVerticalIcon,{className:"size-2.5"})}):null})}var Wo=Oe({"src/components/graph-workspace/GraphResizablePanels.tsx"(){}});function ma(...e){return e.filter(Boolean).join(" ")}function zr({...e}){return t.jsx(bd,{"data-slot":"accordion",...e})}function Pr({className:e,...r}){return t.jsx(vd,{"data-slot":"accordion-item",className:ma("border-b last:border-b-0",e),...r})}function hn({className:e,children:r,...n}){return t.jsx(wd,{className:"flex",children:t.jsxs(yd,{"data-slot":"accordion-trigger",className:ma("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(P.ChevronDownIcon,{className:"pointer-events-none size-4 shrink-0 translate-y-0.5 text-[var(--theme-fg-muted)] transition-transform duration-200"})]})})}function Rr({className:e,children:r,...n}){return t.jsx(kd,{"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:ma("pb-4 pt-0",e),children:r})})}var _r=Oe({"src/components/graph-workspace/GraphAccordion.tsx"(){}});function Uo(){return Wn??(Wn=Promise.all([Be(()=>import("./core-B0prQzhr.js"),__vite__mapDeps([0,1,2])),Be(()=>import("./engine-javascript-DBd1bXLz.js"),[]),Be(()=>import("./ayu-light-BA47KaF1.js"),[]),Be(()=>import("./ayu-dark-DYE7WIF3.js"),[]),Be(()=>import("./javascript-wDzz0qaB.js"),[]),Be(()=>import("./typescript-BPQ3VLAy.js"),[]),Be(()=>import("./tsx-COt5Ahok.js"),[]),Be(()=>import("./jsx-g9-lgVsj.js"),[]),Be(()=>import("./python-B6aJPvgy.js"),[]),Be(()=>import("./json-Cp-IABpG.js"),[]),Be(()=>import("./shellscript-DfDnw5Jg.js").then(e=>e.b),[]),Be(()=>import("./shellscript-DfDnw5Jg.js").then(e=>e.a),[]),Be(()=>import("./yaml-Buea-lGh.js"),[]),Be(()=>import("./toml-vGWfd6FD.js"),[]),Be(()=>import("./markdown-Cvjx9yec.js"),[]),Be(()=>import("./html-pp8916En.js"),__vite__mapDeps([3,4,5])),Be(()=>import("./css-CLj8gQPS.js"),[]),Be(()=>import("./sql-CRqJ_cUM.js"),[]),Be(()=>import("./csv-fuZLfV_i.js"),[]),Be(()=>import("./ruby-B6AkvBWc.js"),__vite__mapDeps([6,3,4,5,7,8,9,10,11,12,13,14,15,16])),Be(()=>import("./rust-B1yitclQ.js"),[]),Be(()=>import("./go-C27-OAKa.js"),[]),Be(()=>import("./java-CylS5w8V.js"),[]),Be(()=>import("./c-BIGW1oBm.js"),[]),Be(()=>import("./cpp-DIPi6g--.js"),__vite__mapDeps([13,14,9])),Be(()=>import("./csharp-DSvCPggb.js"),[]),Be(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([7,8]))]).then(([{createHighlighterCore:e},{createJavaScriptRegexEngine:r},n,a,s,o,l,i,d,h,m,u,p,f,g,x,j,b,k,y,v,w,C,N,E,R,_])=>e({engine:r(),themes:[n.default,a.default],langs:[s.default,o.default,l.default,i.default,d.default,h.default,m.default,u.default,p.default,f.default,g.default,x.default,j.default,b.default,k.default,y.default,v.default,w.default,C.default,N.default,E.default,R.default,_.default]}))),Wn}var Wn,Vo=Oe({"src/components/graph-chat/graphChatShiki.ts"(){Wn=null}});function yh(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 jh(e){return e.trim().replace(/^\/+|\/+$/g,"").replace(/[^\w.-]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function Mr(e){var r;return((r=e.split(".").pop())==null?void 0:r.toLowerCase())||""}function Nh(e){return e.split("/").filter(Boolean).at(-1)??e}function nr(e){const r=e.kind==="directory"?"directory":"file",n=(e.children??[]).map(nr);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 Xo(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=Xo(l,r,n,a);return i!==l&&(s=!0),i});return s?{...e,children:o}:e}function qo(e){if(e.kind==="file")return e;for(const r of e.children){const n=qo(r);if(n)return n}return null}function Un(e,r){if(!e||r===null)return null;if(e.path===r)return e;for(const n of e.children){const a=Un(n,r);if(a)return a}return null}function Vn(e){return e.trim().replace(/\\/g,"/").replace(/^\.\/+/,"").replace(/^\/+/,"")}function Ch(e,r){const n=Vn(e),a=Vn(r).replace(/\/+$/,"");return!a||n===a?n===a?"":n:n.startsWith(`${a}/`)?n.slice(a.length+1):n}function Sh(e){const n=Vn(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 Xn(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=Xn(o,r,n);return l!==o&&(a=!0),l});return a?{...e,children:s}:e}function qn(e,r){return!e||!r?!1:e.path===r?!0:e.children.some(n=>qn(n,r))}function Th(e){if(!e)return null;const r=Mr(e.path);return pa.has(r)?{content:[e.content.endsWith(`
|
|
2
|
+
import{l as R,R as kd,I as wd,C as yd,S as ro,H as jd,T as Nd,a as Cd,b as Sd,c as Td,d as Ed,e as Ld,D as Id,P as zd,O as Pd,f as Rd,g as Ad,h as _d,i as Md,j as $d,k as Dd,m as Bd,n as Gd,A as Fd,o as Hd,p as Od}from"./ui-vendor-CuR8GHb0.js";import{r as c,R as Wd,j as t,b as Lr}from"./react-vendor-Dfg_6BLf.js";import{u as Ud,a as Vd,H as Da,P as Wt,b as Xd,M as no,R as qd,i as Kd,C as Yd,B as Zd,c as Ba,g as ao}from"./graph-vendor-DVQUpZ8C.js";import"./terminal-vendor-C5bTa-Ka.js";import{M as so,r as Jd,a as oo,b as Qd}from"./markdown-vendor-BG6PurxI.js";const ec="modulepreload",tc=function(e){return"/"+e},Ga={},De=function(r,n,a){let s=Promise.resolve();if(n&&n.length>0){let l=function(h){return Promise.all(h.map(m=>Promise.resolve(m).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};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=tc(h),h in Ga)return;Ga[h]=!0;const m=h.endsWith(".css"),u=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${u}`))return;const p=document.createElement("link");if(p.rel=m?"stylesheet":ec,m||(p.as="script"),p.crossOrigin="",p.href=h,d&&p.setAttribute("nonce",d),document.head.appendChild(p),m)return new Promise((f,g)=>{p.addEventListener("load",f),p.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 lo(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=lo(e[r]))&&(a&&(a+=" "),a+=n)}else for(n in e)e[n]&&(a&&(a+=" "),a+=n);return a}function io(){for(var e,r,n=0,a="",s=arguments.length;n<s;n++)(e=arguments[n])&&(r=lo(e))&&(a&&(a+=" "),a+=r);return a}const rc=(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},nc=(e,r)=>({classGroupId:e,validator:r}),co=(e=new Map,r=null,n)=>({nextPart:e,validators:r,classGroupId:n}),Qr="-",Fa=[],ac="arbitrary..",sc=e=>{const r=lc(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:a}=e;return{getClassGroupId:l=>{if(l.startsWith("[")&&l.endsWith("]"))return oc(l);const i=l.split(Qr),d=i[0]===""&&i.length>1?1:0;return ho(i,d,r)},getConflictingClassGroupIds:(l,i)=>{if(i){const d=a[l],h=n[l];return d?h?rc(h,d):d:h||Fa}return n[l]||Fa}}},ho=(e,r,n)=>{if(e.length-r===0)return n.classGroupId;const s=e[r],o=n.nextPart.get(s);if(o){const h=ho(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 m=l[h];if(m.validator(i))return m.classGroupId}},oc=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?ac+a:void 0})(),lc=e=>{const{theme:r,classGroups:n}=e;return ic(n,r)},ic=(e,r)=>{const n=co();for(const a in e){const s=e[a];ha(s,n,a,r)}return n},ha=(e,r,n,a)=>{const s=e.length;for(let o=0;o<s;o++){const l=e[o];dc(l,r,n,a)}},dc=(e,r,n,a)=>{if(typeof e=="string"){cc(e,r,n);return}if(typeof e=="function"){hc(e,r,n,a);return}uc(e,r,n,a)},cc=(e,r,n)=>{const a=e===""?r:uo(r,e);a.classGroupId=n},hc=(e,r,n,a)=>{if(mc(e)){ha(e(a),r,n,a);return}r.validators===null&&(r.validators=[]),r.validators.push(nc(n,e))},uc=(e,r,n,a)=>{const s=Object.entries(e),o=s.length;for(let l=0;l<o;l++){const[i,d]=s[l];ha(d,uo(r,i),n,a)}},uo=(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=co(),n.nextPart.set(l,i)),n=i}return n},mc=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,pc=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)}}},On="!",Ha=":",fc=[],Oa=(e,r,n,a,s)=>({modifiers:e,hasImportantModifier:r,baseClassName:n,maybePostfixModifierPosition:a,isExternal:s}),gc=e=>{const{prefix:r,experimentalParseClassName:n}=e;let a=s=>{const o=[];let l=0,i=0,d=0,h;const m=s.length;for(let b=0;b<m;b++){const j=s[b];if(l===0&&i===0){if(j===Ha){o.push(s.slice(d,b)),d=b+1;continue}if(j==="/"){h=b;continue}}j==="["?l++:j==="]"?l--:j==="("?i++:j===")"&&i--}const u=o.length===0?s:s.slice(d);let p=u,f=!1;u.endsWith(On)?(p=u.slice(0,-1),f=!0):u.startsWith(On)&&(p=u.slice(1),f=!0);const g=h&&h>d?h-d:void 0;return Oa(o,f,p,g)};if(r){const s=r+Ha,o=a;a=l=>l.startsWith(s)?o(l.slice(s.length)):Oa(fc,!1,l,void 0,!0)}if(n){const s=a;a=o=>n({className:o,parseClassName:s})}return a},xc=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}},bc=e=>({cache:pc(e.cacheSize),parseClassName:gc(e),sortModifiers:xc(e),postfixLookupClassGroupIds:vc(e),...sc(e)}),vc=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},kc=/\s+/,wc=(e,r)=>{const{parseClassName:n,getClassGroupId:a,getConflictingClassGroupIds:s,sortModifiers:o,postfixLookupClassGroupIds:l}=r,i=[],d=e.trim().split(kc);let h="";for(let m=d.length-1;m>=0;m-=1){const u=d[m],{isExternal:p,modifiers:f,hasImportantModifier:g,baseClassName:b,maybePostfixModifierPosition:j}=n(u);if(p){h=u+(h.length>0?" "+h:h);continue}let x=!!j,k;if(x){const S=b.substring(0,j);k=a(S);const T=k&&l[k]?a(b):void 0;T&&T!==k&&(k=T,x=!1)}else k=a(b);if(!k){if(!x){h=u+(h.length>0?" "+h:h);continue}if(k=a(b),!k){h=u+(h.length>0?" "+h:h);continue}x=!1}const w=f.length===0?"":f.length===1?f[0]:o(f).join(":"),v=g?w+On:w,y=v+k;if(i.indexOf(y)>-1)continue;i.push(y);const N=s(k,x);for(let S=0;S<N.length;++S){const T=N[S];i.push(v+T)}h=u+(h.length>0?" "+h:h)}return h},yc=(...e)=>{let r=0,n,a,s="";for(;r<e.length;)(n=e[r++])&&(a=mo(n))&&(s&&(s+=" "),s+=a);return s},mo=e=>{if(typeof e=="string")return e;let r,n="";for(let a=0;a<e.length;a++)e[a]&&(r=mo(e[a]))&&(n&&(n+=" "),n+=r);return n},jc=(e,...r)=>{let n,a,s,o;const l=d=>{const h=r.reduce((m,u)=>u(m),e());return n=bc(h),a=n.cache.get,s=n.cache.set,o=i,i(d)},i=d=>{const h=a(d);if(h)return h;const m=wc(d,n);return s(d,m),m};return o=l,(...d)=>o(yc(...d))},Nc=[],et=e=>{const r=n=>n[e]||Nc;return r.isThemeGetter=!0,r},po=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,fo=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Cc=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Sc=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Tc=/\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$/,Ec=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Lc=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Ic=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,It=e=>Cc.test(e),ze=e=>!!e&&!Number.isNaN(Number(e)),bt=e=>!!e&&Number.isInteger(Number(e)),Nn=e=>e.endsWith("%")&&ze(e.slice(0,-1)),Nt=e=>Sc.test(e),go=()=>!0,zc=e=>Tc.test(e)&&!Ec.test(e),ua=()=>!1,Pc=e=>Lc.test(e),Rc=e=>Ic.test(e),Ac=e=>!ue(e)&&!pe(e),_c=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)),Mc=e=>_t(e,vo,ua),ue=e=>po.test(e),Gt=e=>_t(e,ko,zc),Wa=e=>_t(e,Wc,ze),$c=e=>_t(e,yo,go),Dc=e=>_t(e,wo,ua),Ua=e=>_t(e,xo,ua),Bc=e=>_t(e,bo,Rc),$r=e=>_t(e,jo,Pc),pe=e=>fo.test(e),gr=e=>Yt(e,ko),Gc=e=>Yt(e,wo),Va=e=>Yt(e,xo),Fc=e=>Yt(e,vo),Hc=e=>Yt(e,bo),Dr=e=>Yt(e,jo,!0),Oc=e=>Yt(e,yo,!0),_t=(e,r,n)=>{const a=po.exec(e);return a?a[1]?r(a[1]):n(a[2]):!1},Yt=(e,r,n=!1)=>{const a=fo.exec(e);return a?a[1]?r(a[1]):n:!1},xo=e=>e==="position"||e==="percentage",bo=e=>e==="image"||e==="url",vo=e=>e==="length"||e==="size"||e==="bg-size",ko=e=>e==="length",Wc=e=>e==="number",wo=e=>e==="family-name",yo=e=>e==="number"||e==="weight",jo=e=>e==="shadow",Uc=()=>{const e=et("color"),r=et("font"),n=et("text"),a=et("font-weight"),s=et("tracking"),o=et("leading"),l=et("breakpoint"),i=et("container"),d=et("spacing"),h=et("radius"),m=et("shadow"),u=et("inset-shadow"),p=et("text-shadow"),f=et("drop-shadow"),g=et("blur"),b=et("perspective"),j=et("aspect"),x=et("ease"),k=et("animate"),w=()=>["auto","avoid","all","avoid-page","page","left","right","column"],v=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],y=()=>[...v(),pe,ue],N=()=>["auto","hidden","clip","visible","scroll"],S=()=>["auto","contain","none"],T=()=>[pe,ue,d],M=()=>[It,"full","auto",...T()],A=()=>[bt,"none","subgrid",pe,ue],J=()=>["auto",{span:["full",bt,pe,ue]},bt,pe,ue],W=()=>[bt,"auto",pe,ue],re=()=>["auto","min","max","fr",pe,ue],O=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],P=()=>["start","end","center","stretch","center-safe","end-safe"],Y=()=>["auto",...T()],Z=()=>[It,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...T()],_=()=>[It,"screen","full","dvw","lvw","svw","min","max","fit",...T()],ie=()=>[It,"screen","full","lh","dvh","lvh","svh","min","max","fit",...T()],H=()=>[e,pe,ue],B=()=>[...v(),Va,Ua,{position:[pe,ue]}],F=()=>["no-repeat",{repeat:["","x","y","space","round"]}],E=()=>["auto","cover","contain",Fc,Mc,{size:[pe,ue]}],D=()=>[Nn,gr,Gt],$=()=>["","none","full",h,pe,ue],L=()=>["",ze,gr,Gt],C=()=>["solid","dashed","dotted","double"],U=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],G=()=>[ze,Nn,Va,Ua],le=()=>["","none",g,pe,ue],ee=()=>["none",ze,pe,ue],ce=()=>["none",ze,pe,ue],q=()=>[ze,pe,ue],ve=()=>[It,"full",...T()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Nt],breakpoint:[Nt],color:[go],container:[Nt],"drop-shadow":[Nt],ease:["in","out","in-out"],font:[Ac],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Nt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Nt],shadow:[Nt],spacing:["px",ze],text:[Nt],"text-shadow":[Nt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",It,ue,pe,j]}],container:["container"],"container-type":[{"@container":["","normal","size",pe,ue]}],"container-named":[_c],columns:[{columns:[ze,ue,pe,i]}],"break-after":[{"break-after":w()}],"break-before":[{"break-before":w()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:y()}],overflow:[{overflow:N()}],"overflow-x":[{"overflow-x":N()}],"overflow-y":[{"overflow-y":N()}],overscroll:[{overscroll:S()}],"overscroll-x":[{"overscroll-x":S()}],"overscroll-y":[{"overscroll-y":S()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:M()}],"inset-x":[{"inset-x":M()}],"inset-y":[{"inset-y":M()}],start:[{"inset-s":M(),start:M()}],end:[{"inset-e":M(),end:M()}],"inset-bs":[{"inset-bs":M()}],"inset-be":[{"inset-be":M()}],top:[{top:M()}],right:[{right:M()}],bottom:[{bottom:M()}],left:[{left:M()}],visibility:["visible","invisible","collapse"],z:[{z:[bt,"auto",pe,ue]}],basis:[{basis:[It,"full","auto",i,...T()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[ze,It,"auto","initial","none",ue]}],grow:[{grow:["",ze,pe,ue]}],shrink:[{shrink:["",ze,pe,ue]}],order:[{order:[bt,"first","last","none",pe,ue]}],"grid-cols":[{"grid-cols":A()}],"col-start-end":[{col:J()}],"col-start":[{"col-start":W()}],"col-end":[{"col-end":W()}],"grid-rows":[{"grid-rows":A()}],"row-start-end":[{row:J()}],"row-start":[{"row-start":W()}],"row-end":[{"row-end":W()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":re()}],"auto-rows":[{"auto-rows":re()}],gap:[{gap:T()}],"gap-x":[{"gap-x":T()}],"gap-y":[{"gap-y":T()}],"justify-content":[{justify:[...O(),"normal"]}],"justify-items":[{"justify-items":[...P(),"normal"]}],"justify-self":[{"justify-self":["auto",...P()]}],"align-content":[{content:["normal",...O()]}],"align-items":[{items:[...P(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...P(),{baseline:["","last"]}]}],"place-content":[{"place-content":O()}],"place-items":[{"place-items":[...P(),"baseline"]}],"place-self":[{"place-self":["auto",...P()]}],p:[{p:T()}],px:[{px:T()}],py:[{py:T()}],ps:[{ps:T()}],pe:[{pe:T()}],pbs:[{pbs:T()}],pbe:[{pbe:T()}],pt:[{pt:T()}],pr:[{pr:T()}],pb:[{pb:T()}],pl:[{pl:T()}],m:[{m:Y()}],mx:[{mx:Y()}],my:[{my:Y()}],ms:[{ms:Y()}],me:[{me:Y()}],mbs:[{mbs:Y()}],mbe:[{mbe:Y()}],mt:[{mt:Y()}],mr:[{mr:Y()}],mb:[{mb:Y()}],ml:[{ml:Y()}],"space-x":[{"space-x":T()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":T()}],"space-y-reverse":["space-y-reverse"],size:[{size:Z()}],"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",...Z()]}],"min-w":[{"min-w":[i,"screen","none",...Z()]}],"max-w":[{"max-w":[i,"screen","none","prose",{screen:[l]},...Z()]}],h:[{h:["screen","lh",...Z()]}],"min-h":[{"min-h":["screen","lh","none",...Z()]}],"max-h":[{"max-h":["screen","lh",...Z()]}],"font-size":[{text:["base",n,gr,Gt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,Oc,$c]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Nn,ue]}],"font-family":[{font:[Gc,Dc,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":[ze,"none",pe,Wa]}],leading:[{leading:[o,...T()]}],"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:H()}],"text-color":[{text:H()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...C(),"wavy"]}],"text-decoration-thickness":[{decoration:[ze,"from-font","auto",pe,Gt]}],"text-decoration-color":[{decoration:H()}],"underline-offset":[{"underline-offset":[ze,"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:T()}],"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:B()}],"bg-repeat":[{bg:F()}],"bg-size":[{bg:E()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},bt,pe,ue],radial:["",pe,ue],conic:[bt,pe,ue]},Hc,Bc]}],"bg-color":[{bg:H()}],"gradient-from-pos":[{from:D()}],"gradient-via-pos":[{via:D()}],"gradient-to-pos":[{to:D()}],"gradient-from":[{from:H()}],"gradient-via":[{via:H()}],"gradient-to":[{to:H()}],rounded:[{rounded:$()}],"rounded-s":[{"rounded-s":$()}],"rounded-e":[{"rounded-e":$()}],"rounded-t":[{"rounded-t":$()}],"rounded-r":[{"rounded-r":$()}],"rounded-b":[{"rounded-b":$()}],"rounded-l":[{"rounded-l":$()}],"rounded-ss":[{"rounded-ss":$()}],"rounded-se":[{"rounded-se":$()}],"rounded-ee":[{"rounded-ee":$()}],"rounded-es":[{"rounded-es":$()}],"rounded-tl":[{"rounded-tl":$()}],"rounded-tr":[{"rounded-tr":$()}],"rounded-br":[{"rounded-br":$()}],"rounded-bl":[{"rounded-bl":$()}],"border-w":[{border:L()}],"border-w-x":[{"border-x":L()}],"border-w-y":[{"border-y":L()}],"border-w-s":[{"border-s":L()}],"border-w-e":[{"border-e":L()}],"border-w-bs":[{"border-bs":L()}],"border-w-be":[{"border-be":L()}],"border-w-t":[{"border-t":L()}],"border-w-r":[{"border-r":L()}],"border-w-b":[{"border-b":L()}],"border-w-l":[{"border-l":L()}],"divide-x":[{"divide-x":L()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":L()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...C(),"hidden","none"]}],"divide-style":[{divide:[...C(),"hidden","none"]}],"border-color":[{border:H()}],"border-color-x":[{"border-x":H()}],"border-color-y":[{"border-y":H()}],"border-color-s":[{"border-s":H()}],"border-color-e":[{"border-e":H()}],"border-color-bs":[{"border-bs":H()}],"border-color-be":[{"border-be":H()}],"border-color-t":[{"border-t":H()}],"border-color-r":[{"border-r":H()}],"border-color-b":[{"border-b":H()}],"border-color-l":[{"border-l":H()}],"divide-color":[{divide:H()}],"outline-style":[{outline:[...C(),"none","hidden"]}],"outline-offset":[{"outline-offset":[ze,pe,ue]}],"outline-w":[{outline:["",ze,gr,Gt]}],"outline-color":[{outline:H()}],shadow:[{shadow:["","none",m,Dr,$r]}],"shadow-color":[{shadow:H()}],"inset-shadow":[{"inset-shadow":["none",u,Dr,$r]}],"inset-shadow-color":[{"inset-shadow":H()}],"ring-w":[{ring:L()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:H()}],"ring-offset-w":[{"ring-offset":[ze,Gt]}],"ring-offset-color":[{"ring-offset":H()}],"inset-ring-w":[{"inset-ring":L()}],"inset-ring-color":[{"inset-ring":H()}],"text-shadow":[{"text-shadow":["none",p,Dr,$r]}],"text-shadow-color":[{"text-shadow":H()}],opacity:[{opacity:[ze,pe,ue]}],"mix-blend":[{"mix-blend":[...U(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":U()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[ze]}],"mask-image-linear-from-pos":[{"mask-linear-from":G()}],"mask-image-linear-to-pos":[{"mask-linear-to":G()}],"mask-image-linear-from-color":[{"mask-linear-from":H()}],"mask-image-linear-to-color":[{"mask-linear-to":H()}],"mask-image-t-from-pos":[{"mask-t-from":G()}],"mask-image-t-to-pos":[{"mask-t-to":G()}],"mask-image-t-from-color":[{"mask-t-from":H()}],"mask-image-t-to-color":[{"mask-t-to":H()}],"mask-image-r-from-pos":[{"mask-r-from":G()}],"mask-image-r-to-pos":[{"mask-r-to":G()}],"mask-image-r-from-color":[{"mask-r-from":H()}],"mask-image-r-to-color":[{"mask-r-to":H()}],"mask-image-b-from-pos":[{"mask-b-from":G()}],"mask-image-b-to-pos":[{"mask-b-to":G()}],"mask-image-b-from-color":[{"mask-b-from":H()}],"mask-image-b-to-color":[{"mask-b-to":H()}],"mask-image-l-from-pos":[{"mask-l-from":G()}],"mask-image-l-to-pos":[{"mask-l-to":G()}],"mask-image-l-from-color":[{"mask-l-from":H()}],"mask-image-l-to-color":[{"mask-l-to":H()}],"mask-image-x-from-pos":[{"mask-x-from":G()}],"mask-image-x-to-pos":[{"mask-x-to":G()}],"mask-image-x-from-color":[{"mask-x-from":H()}],"mask-image-x-to-color":[{"mask-x-to":H()}],"mask-image-y-from-pos":[{"mask-y-from":G()}],"mask-image-y-to-pos":[{"mask-y-to":G()}],"mask-image-y-from-color":[{"mask-y-from":H()}],"mask-image-y-to-color":[{"mask-y-to":H()}],"mask-image-radial":[{"mask-radial":[pe,ue]}],"mask-image-radial-from-pos":[{"mask-radial-from":G()}],"mask-image-radial-to-pos":[{"mask-radial-to":G()}],"mask-image-radial-from-color":[{"mask-radial-from":H()}],"mask-image-radial-to-color":[{"mask-radial-to":H()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":v()}],"mask-image-conic-pos":[{"mask-conic":[ze]}],"mask-image-conic-from-pos":[{"mask-conic-from":G()}],"mask-image-conic-to-pos":[{"mask-conic-to":G()}],"mask-image-conic-from-color":[{"mask-conic-from":H()}],"mask-image-conic-to-color":[{"mask-conic-to":H()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:B()}],"mask-repeat":[{mask:F()}],"mask-size":[{mask:E()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",pe,ue]}],filter:[{filter:["","none",pe,ue]}],blur:[{blur:le()}],brightness:[{brightness:[ze,pe,ue]}],contrast:[{contrast:[ze,pe,ue]}],"drop-shadow":[{"drop-shadow":["","none",f,Dr,$r]}],"drop-shadow-color":[{"drop-shadow":H()}],grayscale:[{grayscale:["",ze,pe,ue]}],"hue-rotate":[{"hue-rotate":[ze,pe,ue]}],invert:[{invert:["",ze,pe,ue]}],saturate:[{saturate:[ze,pe,ue]}],sepia:[{sepia:["",ze,pe,ue]}],"backdrop-filter":[{"backdrop-filter":["","none",pe,ue]}],"backdrop-blur":[{"backdrop-blur":le()}],"backdrop-brightness":[{"backdrop-brightness":[ze,pe,ue]}],"backdrop-contrast":[{"backdrop-contrast":[ze,pe,ue]}],"backdrop-grayscale":[{"backdrop-grayscale":["",ze,pe,ue]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[ze,pe,ue]}],"backdrop-invert":[{"backdrop-invert":["",ze,pe,ue]}],"backdrop-opacity":[{"backdrop-opacity":[ze,pe,ue]}],"backdrop-saturate":[{"backdrop-saturate":[ze,pe,ue]}],"backdrop-sepia":[{"backdrop-sepia":["",ze,pe,ue]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":T()}],"border-spacing-x":[{"border-spacing-x":T()}],"border-spacing-y":[{"border-spacing-y":T()}],"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:[ze,"initial",pe,ue]}],ease:[{ease:["linear","initial",x,pe,ue]}],delay:[{delay:[ze,pe,ue]}],animate:[{animate:["none",k,pe,ue]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,pe,ue]}],"perspective-origin":[{"perspective-origin":y()}],rotate:[{rotate:ee()}],"rotate-x":[{"rotate-x":ee()}],"rotate-y":[{"rotate-y":ee()}],"rotate-z":[{"rotate-z":ee()}],scale:[{scale:ce()}],"scale-x":[{"scale-x":ce()}],"scale-y":[{"scale-y":ce()}],"scale-z":[{"scale-z":ce()}],"scale-3d":["scale-3d"],skew:[{skew:q()}],"skew-x":[{"skew-x":q()}],"skew-y":[{"skew-y":q()}],transform:[{transform:[pe,ue,"","none","gpu","cpu"]}],"transform-origin":[{origin:y()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ve()}],"translate-x":[{"translate-x":ve()}],"translate-y":[{"translate-y":ve()}],"translate-z":[{"translate-z":ve()}],"translate-none":["translate-none"],zoom:[{zoom:[bt,pe,ue]}],accent:[{accent:H()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:H()}],"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":H()}],"scrollbar-track-color":[{"scrollbar-track":H()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":T()}],"scroll-mx":[{"scroll-mx":T()}],"scroll-my":[{"scroll-my":T()}],"scroll-ms":[{"scroll-ms":T()}],"scroll-me":[{"scroll-me":T()}],"scroll-mbs":[{"scroll-mbs":T()}],"scroll-mbe":[{"scroll-mbe":T()}],"scroll-mt":[{"scroll-mt":T()}],"scroll-mr":[{"scroll-mr":T()}],"scroll-mb":[{"scroll-mb":T()}],"scroll-ml":[{"scroll-ml":T()}],"scroll-p":[{"scroll-p":T()}],"scroll-px":[{"scroll-px":T()}],"scroll-py":[{"scroll-py":T()}],"scroll-ps":[{"scroll-ps":T()}],"scroll-pe":[{"scroll-pe":T()}],"scroll-pbs":[{"scroll-pbs":T()}],"scroll-pbe":[{"scroll-pbe":T()}],"scroll-pt":[{"scroll-pt":T()}],"scroll-pr":[{"scroll-pr":T()}],"scroll-pb":[{"scroll-pb":T()}],"scroll-pl":[{"scroll-pl":T()}],"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",...H()]}],"stroke-w":[{stroke:[ze,gr,Gt,Wa]}],stroke:[{stroke:["none",...H()]}],"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"]}},Vc=jc(Uc),Xa=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,qa=io,Ir=(e,r)=>n=>{var a;if((r==null?void 0:r.variants)==null)return qa(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 m=n==null?void 0:n[h],u=o==null?void 0:o[h];if(m===null)return null;const p=Xa(m)||Xa(u);return s[h][p]}),i=n&&Object.entries(n).reduce((h,m)=>{let[u,p]=m;return p===void 0||(h[u]=p),h},{}),d=r==null||(a=r.compoundVariants)===null||a===void 0?void 0:a.reduce((h,m)=>{let{class:u,className:p,...f}=m;return Object.entries(f).every(g=>{let[b,j]=g;return Array.isArray(j)?j.includes({...o,...i}[b]):{...o,...i}[b]===j})?[...h,u,p]:h},[]);return qa(e,l,d,n==null?void 0:n.class,n==null?void 0:n.className)},sn=c.createContext(null);sn.displayName="PanelGroupContext";const Ke={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"},ma=10,Xt=c.useLayoutEffect,Ka=Wd.useId,Xc=typeof Ka=="function"?Ka:()=>null;let qc=0;function pa(e=null){const r=Xc(),n=c.useRef(e||r||null);return n.current===null&&(n.current=""+qc++),e??n.current}function No({children:e,className:r="",collapsedSize:n,collapsible:a,defaultSize:s,forwardedRef:o,id:l,maxSize:i,minSize:d,onCollapse:h,onExpand:m,onResize:u,order:p,style:f,tagName:g="div",...b}){const j=c.useContext(sn);if(j===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:x,expandPanel:k,getPanelSize:w,getPanelStyle:v,groupId:y,isPanelCollapsed:N,reevaluatePanelConstraints:S,registerPanel:T,resizePanel:M,unregisterPanel:A}=j,J=pa(l),W=c.useRef({callbacks:{onCollapse:h,onExpand:m,onResize:u},constraints:{collapsedSize:n,collapsible:a,defaultSize:s,maxSize:i,minSize:d},id:J,idIsFromProps:l!==void 0,order:p});c.useRef({didLogMissingDefaultSizeWarning:!1}),Xt(()=>{const{callbacks:O,constraints:P}=W.current,Y={...P};W.current.id=J,W.current.idIsFromProps=l!==void 0,W.current.order=p,O.onCollapse=h,O.onExpand=m,O.onResize=u,P.collapsedSize=n,P.collapsible=a,P.defaultSize=s,P.maxSize=i,P.minSize=d,(Y.collapsedSize!==P.collapsedSize||Y.collapsible!==P.collapsible||Y.maxSize!==P.maxSize||Y.minSize!==P.minSize)&&S(W.current,Y)}),Xt(()=>{const O=W.current;return T(O),()=>{A(O)}},[p,J,T,A]),c.useImperativeHandle(o,()=>({collapse:()=>{x(W.current)},expand:O=>{k(W.current,O)},getId(){return J},getSize(){return w(W.current)},isCollapsed(){return N(W.current)},isExpanded(){return!N(W.current)},resize:O=>{M(W.current,O)}}),[x,k,w,N,J,M]);const re=v(W.current,s);return c.createElement(g,{...b,children:e,className:r,id:J,style:{...re,...f},[Ke.groupId]:y,[Ke.panel]:"",[Ke.panelCollapsible]:a||void 0,[Ke.panelId]:J,[Ke.panelSize]:parseFloat(""+re.flexGrow).toFixed(1)})}const Co=c.forwardRef((e,r)=>c.createElement(No,{...e,forwardedRef:r}));No.displayName="Panel";Co.displayName="forwardRef(Panel)";let Wn=null,Ur=-1,Pt=null;function Kc(e,r,n){const a=(r&Io)!==0,s=(r&zo)!==0,o=(r&Po)!==0,l=(r&Ro)!==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 Yc(){Pt!==null&&(document.head.removeChild(Pt),Wn=null,Pt=null,Ur=-1)}function Cn(e,r,n){var a,s;const o=Kc(e,r);if(Wn!==o){if(Wn=o,Pt===null&&(Pt=document.createElement("style"),document.head.appendChild(Pt)),Ur>=0){var l;(l=Pt.sheet)===null||l===void 0||l.removeRule(Ur)}Ur=(a=(s=Pt.sheet)===null||s===void 0?void 0:s.insertRule(`*{cursor: ${o} !important;}`))!==null&&a!==void 0?a:-1}}function So(e){return e.type==="keydown"}function To(e){return e.type.startsWith("pointer")}function Eo(e){return e.type.startsWith("mouse")}function on(e){if(To(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Eo(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function Zc(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function Jc(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 Qc(e,r){if(e===r)throw new Error("Cannot compare node with itself");const n={a:Ja(e),b:Ja(r)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),r=n.b.pop(),a=e;Ie(a,"Stacking order can only be calculated for elements with a common ancestor");const s={a:Za(Ya(n.a)),b:Za(Ya(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 eh=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function th(e){var r;const n=getComputedStyle((r=Lo(e))!==null&&r!==void 0?r:e).display;return n==="flex"||n==="inline-flex"}function rh(e){const r=getComputedStyle(e);return!!(r.position==="fixed"||r.zIndex!=="auto"&&(r.position!=="static"||th(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"||eh.test(r.willChange)||r.webkitOverflowScrolling==="touch")}function Ya(e){let r=e.length;for(;r--;){const n=e[r];if(Ie(n,"Missing node"),rh(n))return n}return null}function Za(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Ja(e){const r=[];for(;e;)r.push(e),e=Lo(e);return r}function Lo(e){const{parentNode:r}=e;return r&&r instanceof ShadowRoot?r.host:r}const Io=1,zo=2,Po=4,Ro=8,nh=Zc()==="coarse";let ft=[],dr=!1,Rt=new Map,ln=new Map;const Sr=new Set;function ah(e,r,n,a,s){var o;const{ownerDocument:l}=r,i={direction:n,element:r,hitAreaMargins:a,setResizeHandlerState:s},d=(o=Rt.get(l))!==null&&o!==void 0?o:0;return Rt.set(l,d+1),Sr.add(i),en(),function(){var m;ln.delete(e),Sr.delete(i);const u=(m=Rt.get(l))!==null&&m!==void 0?m:1;if(Rt.set(l,u-1),en(),u===1&&Rt.delete(l),ft.includes(i)){const p=ft.indexOf(i);p>=0&&ft.splice(p,1),dn(),s("up",!0,null)}}}function sh(e){const{target:r}=e,{x:n,y:a}=on(e);dr=!0,fa({target:r,x:n,y:a}),en(),ft.length>0&&(tn("down",e),dn(),e.preventDefault(),Ao(r)||e.stopImmediatePropagation())}function Sn(e){const{x:r,y:n}=on(e);if(dr&&e.type!=="pointerleave"&&e.buttons===0&&(dr=!1,tn("up",e)),!dr){const{target:a}=e;fa({target:a,x:r,y:n})}tn("move",e),dn(),ft.length>0&&e.preventDefault()}function Tn(e){const{target:r}=e,{x:n,y:a}=on(e);ln.clear(),dr=!1,ft.length>0&&(e.preventDefault(),Ao(r)||e.stopImmediatePropagation()),tn("up",e),fa({target:r,x:n,y:a}),dn(),en()}function Ao(e){let r=e;for(;r;){if(r.hasAttribute(Ke.resizeHandle))return!0;r=r.parentElement}return!1}function fa({target:e,x:r,y:n}){ft.splice(0);let a=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(a=e),Sr.forEach(s=>{const{element:o,hitAreaMargins:l}=s,i=o.getBoundingClientRect(),{bottom:d,left:h,right:m,top:u}=i,p=nh?l.coarse:l.fine;if(r>=h-p&&r<=m+p&&n>=u-p&&n<=d+p){if(a!==null&&document.contains(a)&&o!==a&&!o.contains(a)&&!a.contains(o)&&Qc(a,o)>0){let g=a,b=!1;for(;g&&!g.contains(o);){if(Jc(g.getBoundingClientRect(),i)){b=!0;break}g=g.parentElement}if(b)return}ft.push(s)}})}function En(e,r){ln.set(e,r)}function dn(){let e=!1,r=!1;ft.forEach(a=>{const{direction:s}=a;s==="horizontal"?e=!0:r=!0});let n=0;ln.forEach(a=>{n|=a}),e&&r?Cn("intersection",n):e?Cn("horizontal",n):r?Cn("vertical",n):Yc()}let Ln;function en(){var e;(e=Ln)===null||e===void 0||e.abort(),Ln=new AbortController;const r={capture:!0,signal:Ln.signal};Sr.size&&(dr?(ft.length>0&&Rt.forEach((n,a)=>{const{body:s}=a;n>0&&(s.addEventListener("contextmenu",Tn,r),s.addEventListener("pointerleave",Sn,r),s.addEventListener("pointermove",Sn,r))}),Rt.forEach((n,a)=>{const{body:s}=a;s.addEventListener("pointerup",Tn,r),s.addEventListener("pointercancel",Tn,r)})):Rt.forEach((n,a)=>{const{body:s}=a;n>0&&(s.addEventListener("pointerdown",sh,r),s.addEventListener("pointermove",Sn,r))}))}function tn(e,r){Sr.forEach(n=>{const{setResizeHandlerState:a}=n,s=ft.includes(n);a(e,s,r)})}function oh(){const[e,r]=c.useState(0);return c.useCallback(()=>r(n=>n+1),[])}function Ie(e,r){if(!e)throw console.error(r),Error(r)}function Kt(e,r,n=ma){return e.toFixed(n)===r.toFixed(n)?0:e>r?1:-1}function Ct(e,r,n=ma){return Kt(e,r,n)===0}function ut(e,r,n){return Kt(e,r,n)===0}function lh(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(!ut(s,o,n))return!1}return!0}function lr({panelConstraints:e,panelIndex:r,size:n}){const a=e[r];Ie(a!=null,`Panel constraints not found for index ${r}`);let{collapsedSize:s=0,collapsible:o,maxSize:l=100,minSize:i=0}=a;if(Kt(n,i)<0)if(o){const d=(s+i)/2;Kt(n,d)<0?n=s:n=i}else n=i;return n=Math.min(l,n),n=parseFloat(n.toFixed(ma)),n}function wr({delta:e,initialLayout:r,panelConstraints:n,pivotIndices:a,prevLayout:s,trigger:o}){if(ut(e,0))return r;const l=[...r],[i,d]=a;Ie(i!=null,"Invalid first pivot index"),Ie(d!=null,"Invalid second pivot index");let h=0;if(o==="keyboard"){{const u=e<0?d:i,p=n[u];Ie(p,`Panel constraints not found for index ${u}`);const{collapsedSize:f=0,collapsible:g,minSize:b=0}=p;if(g){const j=r[u];if(Ie(j!=null,`Previous layout not found for panel index ${u}`),ut(j,f)){const x=b-j;Kt(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}{const u=e<0?i:d,p=n[u];Ie(p,`No panel constraints found for index ${u}`);const{collapsedSize:f=0,collapsible:g,minSize:b=0}=p;if(g){const j=r[u];if(Ie(j!=null,`Previous layout not found for panel index ${u}`),ut(j,b)){const x=j-f;Kt(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}}{const u=e<0?1:-1;let p=e<0?d:i,f=0;for(;;){const b=r[p];Ie(b!=null,`Previous layout not found for panel index ${p}`);const x=lr({panelConstraints:n,panelIndex:p,size:100})-b;if(f+=x,p+=u,p<0||p>=n.length)break}const g=Math.min(Math.abs(e),Math.abs(f));e=e<0?0-g:g}{let p=e<0?i:d;for(;p>=0&&p<n.length;){const f=Math.abs(e)-Math.abs(h),g=r[p];Ie(g!=null,`Previous layout not found for panel index ${p}`);const b=g-f,j=lr({panelConstraints:n,panelIndex:p,size:b});if(!ut(g,j)&&(h+=g-j,l[p]=j,h.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?p--:p++}}if(lh(s,l))return s;{const u=e<0?d:i,p=r[u];Ie(p!=null,`Previous layout not found for panel index ${u}`);const f=p+h,g=lr({panelConstraints:n,panelIndex:u,size:f});if(l[u]=g,!ut(g,f)){let b=f-g,x=e<0?d:i;for(;x>=0&&x<n.length;){const k=l[x];Ie(k!=null,`Previous layout not found for panel index ${x}`);const w=k+b,v=lr({panelConstraints:n,panelIndex:x,size:w});if(ut(k,v)||(b-=v-k,l[x]=v),ut(b,0))break;e>0?x--:x++}}}const m=l.reduce((u,p)=>p+u,0);return ut(m,100)?l:s}function ih({layout:e,panelsArray:r,pivotIndices:n}){let a=0,s=100,o=0,l=0;const i=n[0];Ie(i!=null,"No pivot index found"),r.forEach((u,p)=>{const{constraints:f}=u,{maxSize:g=100,minSize:b=0}=f;p===i?(a=b,s=g):(o+=b,l+=g)});const d=Math.min(s,100-o),h=Math.max(a,100-l),m=e[i];return{valueMax:d,valueMin:h,valueNow:m}}function Tr(e,r=document){return Array.from(r.querySelectorAll(`[${Ke.resizeHandleId}][data-panel-group-id="${e}"]`))}function _o(e,r,n=document){const s=Tr(e,n).findIndex(o=>o.getAttribute(Ke.resizeHandleId)===r);return s??null}function Mo(e,r,n){const a=_o(e,r,n);return a!=null?[a,a+1]:[-1,-1]}function dh(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function $o(e,r=document){if(dh(r)&&r.dataset.panelGroupId==e)return r;const n=r.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function cn(e,r=document){const n=r.querySelector(`[${Ke.resizeHandleId}="${e}"]`);return n||null}function ch(e,r,n,a=document){var s,o,l,i;const d=cn(r,a),h=Tr(e,a),m=d?h.indexOf(d):-1,u=(s=(o=n[m])===null||o===void 0?void 0:o.id)!==null&&s!==void 0?s:null,p=(l=(i=n[m+1])===null||i===void 0?void 0:i.id)!==null&&l!==void 0?l:null;return[u,p]}function hh({committedValuesRef:e,eagerValuesRef:r,groupId:n,layout:a,panelDataArray:s,panelGroupElement:o,setLayout:l}){c.useRef({didWarnAboutMissingResizeHandle:!1}),Xt(()=>{if(!o)return;const i=Tr(n,o);for(let d=0;d<s.length-1;d++){const{valueMax:h,valueMin:m,valueNow:u}=ih({layout:a,panelsArray:s,pivotIndices:[d,d+1]}),p=i[d];if(p!=null){const f=s[d];Ie(f,`No panel data found for index "${d}"`),p.setAttribute("aria-controls",f.id),p.setAttribute("aria-valuemax",""+Math.round(h)),p.setAttribute("aria-valuemin",""+Math.round(m)),p.setAttribute("aria-valuenow",u!=null?""+Math.round(u):"")}}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;Ie(i,"Eager values not found");const{panelDataArray:d}=i,h=$o(n,o);Ie(h!=null,`No group found for id "${n}"`);const m=Tr(n,o);Ie(m,`No resize handles found for group id "${n}"`);const u=m.map(p=>{const f=p.getAttribute(Ke.resizeHandleId);Ie(f,"Resize handle element has no handle id attribute");const[g,b]=ch(n,f,d,o);if(g==null||b==null)return()=>{};const j=x=>{if(!x.defaultPrevented)switch(x.key){case"Enter":{x.preventDefault();const k=d.findIndex(w=>w.id===g);if(k>=0){const w=d[k];Ie(w,`No panel data found for index ${k}`);const v=a[k],{collapsedSize:y=0,collapsible:N,minSize:S=0}=w.constraints;if(v!=null&&N){const T=wr({delta:ut(v,y)?S-y:y-v,initialLayout:a,panelConstraints:d.map(M=>M.constraints),pivotIndices:Mo(n,f,o),prevLayout:a,trigger:"keyboard"});a!==T&&l(T)}}break}}};return p.addEventListener("keydown",j),()=>{p.removeEventListener("keydown",j)}});return()=>{u.forEach(p=>p())}},[o,e,r,n,a,s,l])}function Qa(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 Do(e,r){const n=e==="horizontal",{x:a,y:s}=on(r);return n?a:s}function uh(e,r,n,a,s){const o=n==="horizontal",l=cn(r,s);Ie(l,`No resize handle element found for id "${r}"`);const i=l.getAttribute(Ke.groupId);Ie(i,"Resize handle element has no group id attribute");let{initialCursorPosition:d}=a;const h=Do(n,e),m=$o(i,s);Ie(m,`No group element found for id "${i}"`);const u=m.getBoundingClientRect(),p=o?u.width:u.height;return(h-d)/p*100}function mh(e,r,n,a,s,o){if(So(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:uh(e,r,n,a,o)}function ph({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];Ie(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];Ie(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 tr(e,r,n){r.forEach((a,s)=>{const o=e[s];Ie(o,`Panel data not found for index ${s}`);const{callbacks:l,constraints:i,id:d}=o,{collapsedSize:h=0,collapsible:m}=i,u=n[d];if(u==null||a!==u){n[d]=a;const{onCollapse:p,onExpand:f,onResize:g}=l;g&&g(a,u),m&&(p||f)&&(f&&(u==null||Ct(u,h))&&!Ct(a,h)&&f(),p&&(u==null||!Ct(u,h))&&Ct(a,h)&&p())}})}function Br(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 fh({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 gh(e,r=10){let n=null;return(...s)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...s)},r)}}function es(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 Bo(e){return`react-resizable-panels:${e}`}function Go(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 Fo(e,r){try{const n=Bo(e),a=r.getItem(n);if(a){const s=JSON.parse(a);if(typeof s=="object"&&s!=null)return s}}catch{}return null}function xh(e,r,n){var a,s;const o=(a=Fo(e,n))!==null&&a!==void 0?a:{},l=Go(r);return(s=o[l])!==null&&s!==void 0?s:null}function bh(e,r,n,a,s){var o;const l=Bo(e),i=Go(r),d=(o=Fo(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 ts({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(!ut(a,100)&&n.length>0)for(let o=0;o<r.length;o++){const l=n[o];Ie(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];Ie(l!=null,`No layout data found for index ${o}`);const i=lr({panelConstraints:r,panelIndex:o,size:l});l!=i&&(s+=l-i,n[o]=i)}if(!ut(s,0))for(let o=0;o<r.length;o++){const l=n[o];Ie(l!=null,`No layout data found for index ${o}`);const i=l+s,d=lr({panelConstraints:r,panelIndex:o,size:i});if(l!==d&&(s-=d-l,n[o]=d,ut(s,0)))break}return n}const vh=100,yr={getItem:e=>(es(yr),yr.getItem(e)),setItem:(e,r)=>{es(yr),yr.setItem(e,r)}},rs={};function Ho({autoSaveId:e=null,children:r,className:n="",direction:a,forwardedRef:s,id:o=null,onLayout:l=null,keyboardResizeBy:i=null,storage:d=yr,style:h,tagName:m="div",...u}){const p=pa(o),f=c.useRef(null),[g,b]=c.useState(null),[j,x]=c.useState([]),k=oh(),w=c.useRef({}),v=c.useRef(new Map),y=c.useRef(0),N=c.useRef({autoSaveId:e,direction:a,dragState:g,id:p,keyboardResizeBy:i,onLayout:l,storage:d}),S=c.useRef({layout:j,panelDataArray:[],panelDataArrayChanged:!1});c.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),c.useImperativeHandle(s,()=>({getId:()=>N.current.id,getLayout:()=>{const{layout:E}=S.current;return E},setLayout:E=>{const{onLayout:D}=N.current,{layout:$,panelDataArray:L}=S.current,C=ts({layout:E,panelConstraints:L.map(U=>U.constraints)});Qa($,C)||(x(C),S.current.layout=C,D&&D(C),tr(L,C,w.current))}}),[]),Xt(()=>{N.current.autoSaveId=e,N.current.direction=a,N.current.dragState=g,N.current.id=p,N.current.onLayout=l,N.current.storage=d}),hh({committedValuesRef:N,eagerValuesRef:S,groupId:p,layout:j,panelDataArray:S.current.panelDataArray,setLayout:x,panelGroupElement:f.current}),c.useEffect(()=>{const{panelDataArray:E}=S.current;if(e){if(j.length===0||j.length!==E.length)return;let D=rs[e];D==null&&(D=gh(bh,vh),rs[e]=D);const $=[...E],L=new Map(v.current);D(e,$,L,j,d)}},[e,j,d]),c.useEffect(()=>{});const T=c.useCallback(E=>{const{onLayout:D}=N.current,{layout:$,panelDataArray:L}=S.current;if(E.constraints.collapsible){const C=L.map(ee=>ee.constraints),{collapsedSize:U=0,panelSize:G,pivotIndices:le}=Ft(L,E,$);if(Ie(G!=null,`Panel size not found for panel "${E.id}"`),!Ct(G,U)){v.current.set(E.id,G);const ce=nr(L,E)===L.length-1?G-U:U-G,q=wr({delta:ce,initialLayout:$,panelConstraints:C,pivotIndices:le,prevLayout:$,trigger:"imperative-api"});Br($,q)||(x(q),S.current.layout=q,D&&D(q),tr(L,q,w.current))}}},[]),M=c.useCallback((E,D)=>{const{onLayout:$}=N.current,{layout:L,panelDataArray:C}=S.current;if(E.constraints.collapsible){const U=C.map(ve=>ve.constraints),{collapsedSize:G=0,panelSize:le=0,minSize:ee=0,pivotIndices:ce}=Ft(C,E,L),q=D??ee;if(Ct(le,G)){const ve=v.current.get(E.id),ke=ve!=null&&ve>=q?ve:q,ye=nr(C,E)===C.length-1?le-ke:ke-le,fe=wr({delta:ye,initialLayout:L,panelConstraints:U,pivotIndices:ce,prevLayout:L,trigger:"imperative-api"});Br(L,fe)||(x(fe),S.current.layout=fe,$&&$(fe),tr(C,fe,w.current))}}},[]),A=c.useCallback(E=>{const{layout:D,panelDataArray:$}=S.current,{panelSize:L}=Ft($,E,D);return Ie(L!=null,`Panel size not found for panel "${E.id}"`),L},[]),J=c.useCallback((E,D)=>{const{panelDataArray:$}=S.current,L=nr($,E);return fh({defaultSize:D,dragState:g,layout:j,panelData:$,panelIndex:L})},[g,j]),W=c.useCallback(E=>{const{layout:D,panelDataArray:$}=S.current,{collapsedSize:L=0,collapsible:C,panelSize:U}=Ft($,E,D);return Ie(U!=null,`Panel size not found for panel "${E.id}"`),C===!0&&Ct(U,L)},[]),re=c.useCallback(E=>{const{layout:D,panelDataArray:$}=S.current,{collapsedSize:L=0,collapsible:C,panelSize:U}=Ft($,E,D);return Ie(U!=null,`Panel size not found for panel "${E.id}"`),!C||Kt(U,L)>0},[]),O=c.useCallback(E=>{const{panelDataArray:D}=S.current;D.push(E),D.sort(($,L)=>{const C=$.order,U=L.order;return C==null&&U==null?0:C==null?-1:U==null?1:C-U}),S.current.panelDataArrayChanged=!0,k()},[k]);Xt(()=>{if(S.current.panelDataArrayChanged){S.current.panelDataArrayChanged=!1;const{autoSaveId:E,onLayout:D,storage:$}=N.current,{layout:L,panelDataArray:C}=S.current;let U=null;if(E){const le=xh(E,C,$);le&&(v.current=new Map(Object.entries(le.expandToSizes)),U=le.layout)}U==null&&(U=ph({panelDataArray:C}));const G=ts({layout:U,panelConstraints:C.map(le=>le.constraints)});Qa(L,G)||(x(G),S.current.layout=G,D&&D(G),tr(C,G,w.current))}}),Xt(()=>{const E=S.current;return()=>{E.layout=[]}},[]);const P=c.useCallback(E=>{let D=!1;const $=f.current;return $&&window.getComputedStyle($,null).getPropertyValue("direction")==="rtl"&&(D=!0),function(C){C.preventDefault();const U=f.current;if(!U)return()=>null;const{direction:G,dragState:le,id:ee,keyboardResizeBy:ce,onLayout:q}=N.current,{layout:ve,panelDataArray:ke}=S.current,{initialLayout:je}=le??{},ye=Mo(ee,E,U);let fe=mh(C,E,G,le,ce,U);const Te=G==="horizontal";Te&&D&&(fe=-fe);const oe=ke.map(we=>we.constraints),Q=wr({delta:fe,initialLayout:je??ve,panelConstraints:oe,pivotIndices:ye,prevLayout:ve,trigger:So(C)?"keyboard":"mouse-or-touch"}),me=!Br(ve,Q);(To(C)||Eo(C))&&y.current!=fe&&(y.current=fe,!me&&fe!==0?Te?En(E,fe<0?Io:zo):En(E,fe<0?Po:Ro):En(E,0)),me&&(x(Q),S.current.layout=Q,q&&q(Q),tr(ke,Q,w.current))}},[]),Y=c.useCallback((E,D)=>{const{onLayout:$}=N.current,{layout:L,panelDataArray:C}=S.current,U=C.map(ve=>ve.constraints),{panelSize:G,pivotIndices:le}=Ft(C,E,L);Ie(G!=null,`Panel size not found for panel "${E.id}"`);const ce=nr(C,E)===C.length-1?G-D:D-G,q=wr({delta:ce,initialLayout:L,panelConstraints:U,pivotIndices:le,prevLayout:L,trigger:"imperative-api"});Br(L,q)||(x(q),S.current.layout=q,$&&$(q),tr(C,q,w.current))},[]),Z=c.useCallback((E,D)=>{const{layout:$,panelDataArray:L}=S.current,{collapsedSize:C=0,collapsible:U}=D,{collapsedSize:G=0,collapsible:le,maxSize:ee=100,minSize:ce=0}=E.constraints,{panelSize:q}=Ft(L,E,$);q!=null&&(U&&le&&Ct(q,C)?Ct(C,G)||Y(E,G):q<ce?Y(E,ce):q>ee&&Y(E,ee))},[Y]),_=c.useCallback((E,D)=>{const{direction:$}=N.current,{layout:L}=S.current;if(!f.current)return;const C=cn(E,f.current);Ie(C,`Drag handle element not found for id "${E}"`);const U=Do($,D);b({dragHandleId:E,dragHandleRect:C.getBoundingClientRect(),initialCursorPosition:U,initialLayout:L})},[]),ie=c.useCallback(()=>{b(null)},[]),H=c.useCallback(E=>{const{panelDataArray:D}=S.current,$=nr(D,E);$>=0&&(D.splice($,1),delete w.current[E.id],S.current.panelDataArrayChanged=!0,k())},[k]),B=c.useMemo(()=>({collapsePanel:T,direction:a,dragState:g,expandPanel:M,getPanelSize:A,getPanelStyle:J,groupId:p,isPanelCollapsed:W,isPanelExpanded:re,reevaluatePanelConstraints:Z,registerPanel:O,registerResizeHandle:P,resizePanel:Y,startDragging:_,stopDragging:ie,unregisterPanel:H,panelGroupElement:f.current}),[T,g,a,M,A,J,p,W,re,Z,O,P,Y,_,ie,H]),F={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return c.createElement(sn.Provider,{value:B},c.createElement(m,{...u,children:r,className:n,id:o,ref:f,style:{...F,...h},[Ke.group]:"",[Ke.groupDirection]:a,[Ke.groupId]:p}))}const Oo=c.forwardRef((e,r)=>c.createElement(Ho,{...e,forwardedRef:r}));Ho.displayName="PanelGroup";Oo.displayName="forwardRef(PanelGroup)";function nr(e,r){return e.findIndex(n=>n===r||n.id===r.id)}function Ft(e,r,n){const a=nr(e,r),o=a===e.length-1?[a-1,a]:[a,a+1],l=n[a];return{...r.constraints,panelSize:l,pivotIndices:o}}function kh({disabled:e,handleId:r,resizeHandler:n,panelGroupElement:a}){c.useEffect(()=>{if(e||n==null||a==null)return;const s=cn(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(Ke.groupId);Ie(i,`No group element found for id "${i}"`);const d=Tr(i,a),h=_o(i,r,a);Ie(h!==null,`No resize element found for id "${r}"`);const m=l.shiftKey?h>0?h-1:d.length-1:h+1<d.length?h+1:0;d[m].focus();break}}};return s.addEventListener("keydown",o),()=>{s.removeEventListener("keydown",o)}},[a,e,r,n])}function Wo({children:e=null,className:r="",disabled:n=!1,hitAreaMargins:a,id:s,onBlur:o,onClick:l,onDragging:i,onFocus:d,onPointerDown:h,onPointerUp:m,style:u={},tabIndex:p=0,tagName:f="div",...g}){var b,j;const x=c.useRef(null),k=c.useRef({onClick:l,onDragging:i,onPointerDown:h,onPointerUp:m});c.useEffect(()=>{k.current.onClick=l,k.current.onDragging=i,k.current.onPointerDown=h,k.current.onPointerUp=m});const w=c.useContext(sn);if(w===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:v,groupId:y,registerResizeHandle:N,startDragging:S,stopDragging:T,panelGroupElement:M}=w,A=pa(s),[J,W]=c.useState("inactive"),[re,O]=c.useState(!1),[P,Y]=c.useState(null),Z=c.useRef({state:J});Xt(()=>{Z.current.state=J}),c.useEffect(()=>{if(n)Y(null);else{const B=N(A);Y(()=>B)}},[n,A,N]);const _=(b=a==null?void 0:a.coarse)!==null&&b!==void 0?b:15,ie=(j=a==null?void 0:a.fine)!==null&&j!==void 0?j:5;c.useEffect(()=>{if(n||P==null)return;const B=x.current;Ie(B,"Element ref not attached");let F=!1;return ah(A,B,v,{coarse:_,fine:ie},(D,$,L)=>{if(!$){W("inactive");return}switch(D){case"down":{W("drag"),F=!1,Ie(L,'Expected event to be defined for "down" action'),S(A,L);const{onDragging:C,onPointerDown:U}=k.current;C==null||C(!0),U==null||U();break}case"move":{const{state:C}=Z.current;F=!0,C!=="drag"&&W("hover"),Ie(L,'Expected event to be defined for "move" action'),P(L);break}case"up":{W("hover"),T();const{onClick:C,onDragging:U,onPointerUp:G}=k.current;U==null||U(!1),G==null||G(),F||C==null||C();break}}})},[_,v,n,ie,N,A,P,S,T]),kh({disabled:n,handleId:A,resizeHandler:P,panelGroupElement:M});const H={touchAction:"none",userSelect:"none"};return c.createElement(f,{...g,children:e,className:r,id:s,onBlur:()=>{O(!1),o==null||o()},onFocus:()=>{O(!0),d==null||d()},ref:x,role:"separator",style:{...H,...u},tabIndex:p,[Ke.groupDirection]:v,[Ke.groupId]:y,[Ke.resizeHandle]:"",[Ke.resizeHandleActive]:J==="drag"?"pointer":re?"keyboard":void 0,[Ke.resizeHandleEnabled]:!n,[Ke.resizeHandleId]:A,[Ke.resizeHandleState]:J})}Wo.displayName="PanelResizeHandle";var wh=Object.defineProperty,yh=Object.getOwnPropertyNames,We=(e,r)=>function(){return e&&(r=(0,e[yh(e)[0]])(e=0)),r},jh=(e,r)=>{for(var n in r)wh(e,n,{get:r[n],enumerable:!0})};function ot(...e){return Vc(io(e))}var Mt=We({"src/components/graph-ui/utils.ts"(){}});function Er({asChild:e=!1,className:r,size:n,variant:a,...s}){const o=e?ro:"button";return t.jsx(o,{"data-slot":"button",className:ot(Uo({variant:a,size:n,className:r})),...s})}var Uo,hn=We({"src/components/graph-ui/Button.tsx"(){Mt(),Uo=Ir("inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium outline-none transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}})}});function Vo(...e){return e.filter(Boolean).join(" ")}function Un({className:e,...r}){return t.jsx(Oo,{"data-slot":"resizable-panel-group",className:Vo("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...r})}function ir({...e}){return t.jsx(Co,{"data-slot":"resizable-panel",...e})}function Vn({withHandle:e,className:r,...n}){return t.jsx(Wo,{"data-slot":"resizable-handle",className:Vo("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",r),...n,children:e?t.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:t.jsx(R.GripVerticalIcon,{className:"size-2.5"})}):null})}var Xo=We({"src/components/graph-workspace/GraphResizablePanels.tsx"(){}});function ga(...e){return e.filter(Boolean).join(" ")}function zr({...e}){return t.jsx(kd,{"data-slot":"accordion",...e})}function Pr({className:e,...r}){return t.jsx(wd,{"data-slot":"accordion-item",className:ga("border-b last:border-b-0",e),...r})}function un({className:e,children:r,...n}){return t.jsx(jd,{className:"flex",children:t.jsxs(Nd,{"data-slot":"accordion-trigger",className:ga("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(R.ChevronDownIcon,{className:"pointer-events-none size-4 shrink-0 translate-y-0.5 text-[var(--theme-fg-muted)] transition-transform duration-200"})]})})}function Rr({className:e,children:r,...n}){return t.jsx(yd,{"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:ga("pb-4 pt-0",e),children:r})})}var Ar=We({"src/components/graph-workspace/GraphAccordion.tsx"(){}});function qo(){return Xn??(Xn=Promise.all([De(()=>import("./core-B0prQzhr.js"),__vite__mapDeps([0,1,2])),De(()=>import("./engine-javascript-DBd1bXLz.js"),[]),De(()=>import("./ayu-light-BA47KaF1.js"),[]),De(()=>import("./ayu-dark-DYE7WIF3.js"),[]),De(()=>import("./javascript-wDzz0qaB.js"),[]),De(()=>import("./typescript-BPQ3VLAy.js"),[]),De(()=>import("./tsx-COt5Ahok.js"),[]),De(()=>import("./jsx-g9-lgVsj.js"),[]),De(()=>import("./python-B6aJPvgy.js"),[]),De(()=>import("./json-Cp-IABpG.js"),[]),De(()=>import("./shellscript-DfDnw5Jg.js").then(e=>e.b),[]),De(()=>import("./shellscript-DfDnw5Jg.js").then(e=>e.a),[]),De(()=>import("./yaml-Buea-lGh.js"),[]),De(()=>import("./toml-vGWfd6FD.js"),[]),De(()=>import("./markdown-Cvjx9yec.js"),[]),De(()=>import("./html-pp8916En.js"),__vite__mapDeps([3,4,5])),De(()=>import("./css-CLj8gQPS.js"),[]),De(()=>import("./sql-CRqJ_cUM.js"),[]),De(()=>import("./csv-fuZLfV_i.js"),[]),De(()=>import("./ruby-B6AkvBWc.js"),__vite__mapDeps([6,3,4,5,7,8,9,10,11,12,13,14,15,16])),De(()=>import("./rust-B1yitclQ.js"),[]),De(()=>import("./go-C27-OAKa.js"),[]),De(()=>import("./java-CylS5w8V.js"),[]),De(()=>import("./c-BIGW1oBm.js"),[]),De(()=>import("./cpp-DIPi6g--.js"),__vite__mapDeps([13,14,9])),De(()=>import("./csharp-DSvCPggb.js"),[]),De(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([7,8]))]).then(([{createHighlighterCore:e},{createJavaScriptRegexEngine:r},n,a,s,o,l,i,d,h,m,u,p,f,g,b,j,x,k,w,v,y,N,S,T,M,A])=>e({engine:r(),themes:[n.default,a.default],langs:[s.default,o.default,l.default,i.default,d.default,h.default,m.default,u.default,p.default,f.default,g.default,b.default,j.default,x.default,k.default,w.default,v.default,y.default,N.default,S.default,T.default,M.default,A.default]}))),Xn}var Xn,Ko=We({"src/components/graph-chat/graphChatShiki.ts"(){Xn=null}});function Nh(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 _r(e){var r;return((r=e.split(".").pop())==null?void 0:r.toLowerCase())||""}function Sh(e){return e.split("/").filter(Boolean).at(-1)??e}function ar(e){const r=e.kind==="directory"?"directory":"file",n=(e.children??[]).map(ar);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 Yo(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=Yo(l,r,n,a);return i!==l&&(s=!0),i});return s?{...e,children:o}:e}function Zo(e){if(e.kind==="file")return e;for(const r of e.children){const n=Zo(r);if(n)return n}return null}function qn(e,r){if(!e||r===null)return null;if(e.path===r)return e;for(const n of e.children){const a=qn(n,r);if(a)return a}return null}function Kn(e){return e.trim().replace(/\\/g,"/").replace(/^\.\/+/,"").replace(/^\/+/,"")}function Th(e,r){const n=Kn(e),a=Kn(r).replace(/\/+$/,"");return!a||n===a?n===a?"":n:n.startsWith(`${a}/`)?n.slice(a.length+1):n}function Eh(e){const n=Kn(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 Yn(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=Yn(o,r,n);return l!==o&&(a=!0),l});return a?{...e,children:s}:e}function Zn(e,r){return!e||!r?!1:e.path===r?!0:e.children.some(n=>Zn(n,r))}function Lh(e){if(!e)return null;const r=_r(e.path);return xa.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 Eh(e){const r=Mr(e);return r==="tsx"||r==="jsx"?"tsx":r==="yml"?"yaml":r||"text"}function Lh(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 Ih(e,r,n){const a=r.split("/").filter(Boolean),s=a.pop()??n.name;Lh(e,a).children.push({...n,name:n.name||s,path:r})}function zh(e,r){return e.kind==="directory"&&r.kind!=="directory"?-1:e.kind!=="directory"&&r.kind==="directory"?1:e.name.localeCompare(r.name)}function Ko(e){e.children.sort(zh);for(const r of e.children)Ko(r);return e}function es(e,r,n,a){var m;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 u of r){const p=u.title||u.id,f=jh(p)||u.id;o.children.push({id:`artifact:${u.id}`,name:`${f}.artifact`,path:`artifacts/${f}.artifact`,kind:"artifact",artifact:u,preview:u.summaryText??u.type,detail:JSON.stringify(u.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=(u,p,f=!1)=>{d+=1;const g=p.kind.replace(/([A-Z])/g,"-$1").toLowerCase(),x=`${f?"live":`thread-events/${u}`}/${String(d).padStart(3,"0")}-${g}.json`,j="text"in p&&typeof p.text=="string"?p.text.slice(0,160):p.kind,b=p.kind==="artifact"&&p.artifact?p.artifact:null,k=b&&f?{id:`live-artifact:${b.id}`,name:b.title||b.id,path:x,kind:"live-artifact",artifact:b,item:p,preview:b.summaryText??b.type,detail:JSON.stringify(b.payload,null,2),children:[]}:{id:`event:${p.id}`,name:Nh(x),path:x,kind:"event",item:p,preview:j,detail:JSON.stringify(p,null,2),children:[]};if(f){i.children.push(k);return}Ih(l,x.replace(/^thread-events\//,""),k)};for(const u of e.turns)for(const p of u.items)(p.kind==="commandExecution"||p.kind==="webSearch"||p.kind==="fileRead"||p.kind==="fileChange"||p.kind==="agentToolCall"||p.kind==="skillToolCall"||p.kind==="toolCall"||p.kind==="hook"||p.kind==="plan"||p.kind==="reasoning")&&h(u.id,p);for(const u of((m=e.liveItems)==null?void 0:m.items)??[])h(e.thread.activeTurnId??"live",u,!0);return s.children.push(o,l,i),Ko(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 Yo(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=Yo(r);if(n)return n}return null}function ts(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 pa,Zo,Jo,fa=Oe({"src/components/graph-workspace/workspaceTree.ts"(){pa=new Set(["xyz","extxyz","cif","pdb"]),Zo=new Set(["png","jpg","jpeg","gif","webp","svg"]),Jo=new Set(["pdf"])}});function ar({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 Qo=Oe({"src/components/graph-workspace/GraphWorkspaceCards.tsx"(){}});function Rh({className:e,decorative:r=!0,orientation:n="horizontal",...a}){return t.jsx(Gd,{"data-slot":"separator",decorative:r,orientation:n,className:st("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 _h=Oe({"src/components/graph-ui/Separator.tsx"(){Mt()}});function Mh({className:e,orientation:r,...n}){return t.jsx("div",{role:"group","data-slot":"button-group","data-orientation":r,className:st(el({orientation:r}),e),...n})}function Ah({className:e,orientation:r="vertical",...n}){return t.jsx(Rh,{"data-slot":"button-group-separator",orientation:r,className:st("relative !m-0 self-stretch bg-input data-[orientation=vertical]:h-auto",e),...n})}var el,tl=Oe({"src/components/graph-ui/ButtonGroup.tsx"(){_h(),Mt(),el=Ir("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 $h({delayDuration:e=0,...r}){return t.jsx(Hd,{"data-slot":"tooltip-provider",delayDuration:e,...r})}function Dh({...e}){return t.jsx($h,{children:t.jsx(Md,{"data-slot":"tooltip",...e})})}function Bh({...e}){return t.jsx(Ad,{"data-slot":"tooltip-trigger",...e})}function Gh({children:e,className:r,sideOffset:n=0,...a}){return t.jsx($d,{children:t.jsxs(Dd,{"data-slot":"tooltip-content",sideOffset:n,className:st("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(Bd,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}var Hh=Oe({"src/components/graph-ui/Tooltip.tsx"(){Mt()}});function Fh(e){return(e==null?void 0:e.trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""))||"molecule"}function rs(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 Je({children:e,disabled:r,label:n,onClick:a}){return t.jsxs(Dh,{children:[t.jsx(Bh,{asChild:!0,children:t.jsx(Er,{type:"button",variant:"outline",size:"icon",className:"thread-graph-molecule-button size-8",disabled:r,onClick:a,title:n,"aria-label":n,children:e})}),t.jsx(Gh,{children:t.jsx("p",{children:n})})]})}function Kn({children:e,className:r=""}){return t.jsx(Mh,{className:`thread-graph-molecule-button-group ${r}`,children:e})}var rl=Oe({"src/components/graph-workspace/GraphMoleculeViewerControls.tsx"(){cn(),tl(),Hh()}});function Oh({cameraInfo:e,onClearSelection:r,onClearStaged:n,onSendSelection:a,onSendStaged:s,onStageSelection:o,onToggleUnitCell:l,selectedAtomLabels:i,selectedSerials:d,stagedAtoms:h,stagedMolecules:m,unitCellAvailable:u,unitCellVisible:p}){const f=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(Kn,{children:[t.jsx(Je,{label:"Distance",children:t.jsx(P.AlignVerticalDistributeCenter,{className:"size-4"})}),t.jsx(Je,{label:"Connectivity",children:t.jsx(P.Share2,{className:"size-4"})}),t.jsx(Je,{label:"Angle",children:t.jsx(P.Waypoints,{className:"size-4"})}),t.jsx(Je,{label:"Dihedral",children:t.jsx(P.Spline,{className:"size-4"})}),t.jsx(Je,{label:"Add dummy atoms",children:t.jsx(P.Bubbles,{className:"size-4"})}),t.jsx(Je,{label:"Delete atoms",children:t.jsx(P.CircleX,{className:"size-4"})}),t.jsx(Je,{label:"Rotate",children:t.jsx(P.Rotate3d,{className:"size-4"})})]}),t.jsxs(Kn,{children:[t.jsx(Je,{label:p?"Hide unit cell":"Show unit cell",disabled:!u,onClick:l,children:t.jsx(P.Boxes,{className:"size-4"})}),t.jsx(Je,{label:"Clear selection",disabled:!f,onClick:r,children:t.jsx(P.Trash2,{className:"size-4"})}),t.jsx(Je,{label:"Send selection",disabled:!f,onClick:a,children:t.jsx(P.Send,{className:"size-4"})}),t.jsx(Je,{label:"Stage current selection",disabled:!f,onClick:o,children:t.jsx(P.Box,{className:"size-4"})}),t.jsx(Je,{label:"Clear staged selections",disabled:!g,onClick:n,children:t.jsx(P.Eraser,{className:"size-4"})}),t.jsx(Je,{label:"Send staged selections",disabled:!g,onClick:s,children:t.jsx(P.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(x=>`${i[x]??"Atom"}(${x})`).join(", "):"None"]}),t.jsxs("div",{children:["Staged: ",m," molecule(s), ",h," atom(s)"]})]})]}):null]})}var Wh=Oe({"src/components/graph-workspace/GraphMoleculeViewerLowerButtonGroup.tsx"(){rl()}});function Uh({currentIndex:e,exportContent:r,moleculeId:n,onScreenshot:a,viewerRef:s,xyzContent:o,xyzFormat:l}){const i=Fh(n);async function d(){o&&await navigator.clipboard.writeText(o)}function h(){o&&rs(o,`${i}_step_${e+1}.${l||"xyz"}`)}function m(){r&&rs(r,`${i}_trajectory.${l||"xyz"}`)}function u(){s.current&&(s.current.zoom(1.2),s.current.render())}function p(){s.current&&(s.current.zoom(.8),s.current.render())}function f(){s.current&&(s.current.zoomTo(),s.current.setCameraParameters({}),s.current.render())}return t.jsxs(Kn,{className:"ml-auto justify-end",children:[t.jsx(Je,{label:"Copy current structure",onClick:()=>void d(),disabled:!o,children:t.jsx(P.Copy,{className:"size-3.5"})}),t.jsx(Je,{label:"Download current structure",onClick:h,disabled:!o,children:t.jsx(P.Download,{className:"size-3.5"})}),t.jsx(Je,{label:"Download full trajectory",onClick:m,disabled:!r,children:t.jsx(P.Box,{className:"size-3.5"})}),t.jsx(Je,{label:"Copy screenshot",onClick:a,disabled:!s.current||!o,children:t.jsx(P.Camera,{className:"size-3.5"})}),t.jsx(Ah,{className:"thread-graph-molecule-button-divider"}),t.jsx(Je,{label:"Zoom in",onClick:u,disabled:!s.current||!o,children:t.jsx(P.ZoomIn,{className:"size-3.5"})}),t.jsx(Je,{label:"Zoom out",onClick:p,disabled:!s.current||!o,children:t.jsx(P.ZoomOut,{className:"size-3.5"})}),t.jsx(Je,{label:"Reset camera",onClick:f,disabled:!s.current||!o,children:t.jsx(P.RotateCcw,{className:"size-3.5"})})]})}var Vh=Oe({"src/components/graph-workspace/GraphMoleculeViewerUpperButtonGroup.tsx"(){tl(),rl()}});async function Xh(){if(typeof window>"u")throw new Error("3Dmol is only available in a browser environment.");return window["3Dmol"]?window["3Dmol"]:(Ur||(Ur=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)})),Ur)}var Ur,qh=Oe({"src/components/graph-workspace/load3Dmol.ts"(){Ur=null}});function Kh({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(zd,{"data-slot":"slider",...r!==void 0?{defaultValue:r}:{},...s!==void 0?{value:s}:{},min:a,max:n,className:st("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(Pd,{"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(Rd,{"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(_d,{"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 Yh=Oe({"src/components/graph-ui/Slider.tsx"(){Mt()}});function Zh(e){const r=e==null?void 0:e.trim().toLowerCase();return!r||r==="extxyz"?"xyz":r}function Jh(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 Ih(e){const r=_r(e);return r==="tsx"||r==="jsx"?"tsx":r==="yml"?"yaml":r||"text"}function zh(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 Ph(e,r,n){const a=r.split("/").filter(Boolean),s=a.pop()??n.name;zh(e,a).children.push({...n,name:n.name||s,path:r})}function Rh(e,r){return e.kind==="directory"&&r.kind!=="directory"?-1:e.kind!=="directory"&&r.kind==="directory"?1:e.name.localeCompare(r.name)}function Jo(e){e.children.sort(Rh);for(const r of e.children)Jo(r);return e}function ns(e,r,n,a){var m;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 u of r){const p=u.title||u.id,f=Ch(p)||u.id;o.children.push({id:`artifact:${u.id}`,name:`${f}.artifact`,path:`artifacts/${f}.artifact`,kind:"artifact",artifact:u,preview:u.summaryText??u.type,detail:JSON.stringify(u.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=(u,p,f=!1)=>{d+=1;const g=p.kind.replace(/([A-Z])/g,"-$1").toLowerCase(),b=`${f?"live":`thread-events/${u}`}/${String(d).padStart(3,"0")}-${g}.json`,j="text"in p&&typeof p.text=="string"?p.text.slice(0,160):p.kind,x=p.kind==="artifact"&&p.artifact?p.artifact:null,k=x&&f?{id:`live-artifact:${x.id}`,name:x.title||x.id,path:b,kind:"live-artifact",artifact:x,item:p,preview:x.summaryText??x.type,detail:JSON.stringify(x.payload,null,2),children:[]}:{id:`event:${p.id}`,name:Sh(b),path:b,kind:"event",item:p,preview:j,detail:JSON.stringify(p,null,2),children:[]};if(f){i.children.push(k);return}Ph(l,b.replace(/^thread-events\//,""),k)};for(const u of e.turns)for(const p of u.items)(p.kind==="commandExecution"||p.kind==="webSearch"||p.kind==="fileRead"||p.kind==="fileChange"||p.kind==="agentToolCall"||p.kind==="skillToolCall"||p.kind==="toolCall"||p.kind==="hook"||p.kind==="plan"||p.kind==="reasoning")&&h(u.id,p);for(const u of((m=e.liveItems)==null?void 0:m.items)??[])h(e.thread.activeTurnId??"live",u,!0);return s.children.push(o,l,i),Jo(s)}function Ah(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 Qo(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=Qo(r);if(n)return n}return null}function as(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 xa,el,tl,ba=We({"src/components/graph-workspace/workspaceTree.ts"(){xa=new Set(["xyz","extxyz","cif","pdb"]),el=new Set(["png","jpg","jpeg","gif","webp","svg"]),tl=new Set(["pdf"])}});function sr({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 rl=We({"src/components/graph-workspace/GraphWorkspaceCards.tsx"(){}});function _h({className:e,decorative:r=!0,orientation:n="horizontal",...a}){return t.jsx(Hd,{"data-slot":"separator",decorative:r,orientation:n,className:ot("shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",e),...a})}var Mh=We({"src/components/graph-ui/Separator.tsx"(){Mt()}});function $h({className:e,orientation:r,...n}){return t.jsx("div",{role:"group","data-slot":"button-group","data-orientation":r,className:ot(nl({orientation:r}),e),...n})}function Dh({className:e,orientation:r="vertical",...n}){return t.jsx(_h,{"data-slot":"button-group-separator",orientation:r,className:ot("relative !m-0 self-stretch bg-input data-[orientation=vertical]:h-auto",e),...n})}var nl,al=We({"src/components/graph-ui/ButtonGroup.tsx"(){Mh(),Mt(),nl=Ir("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 Bh({delayDuration:e=0,...r}){return t.jsx(Od,{"data-slot":"tooltip-provider",delayDuration:e,...r})}function Gh({...e}){return t.jsx(Bh,{children:t.jsx($d,{"data-slot":"tooltip",...e})})}function Fh({...e}){return t.jsx(Dd,{"data-slot":"tooltip-trigger",...e})}function Hh({children:e,className:r,sideOffset:n=0,...a}){return t.jsx(Bd,{children:t.jsxs(Gd,{"data-slot":"tooltip-content",sideOffset:n,className:ot("z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md bg-foreground px-3 py-1.5 text-balance text-xs text-background animate-in fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",r),...a,children:[e,t.jsx(Fd,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}var Oh=We({"src/components/graph-ui/Tooltip.tsx"(){Mt()}});function Wh(e){return(e==null?void 0:e.trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""))||"molecule"}function ss(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 Je({children:e,disabled:r,label:n,onClick:a}){return t.jsxs(Gh,{children:[t.jsx(Fh,{asChild:!0,children:t.jsx(Er,{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(Hh,{children:t.jsx("p",{children:n})})]})}function Jn({children:e,className:r=""}){return t.jsx($h,{className:`thread-graph-molecule-button-group ${r}`,children:e})}var sl=We({"src/components/graph-workspace/GraphMoleculeViewerControls.tsx"(){hn(),al(),Oh()}});function Uh({cameraInfo:e,onClearSelection:r,onClearStaged:n,onSendSelection:a,onSendStaged:s,onStageSelection:o,onToggleUnitCell:l,selectedAtomLabels:i,selectedSerials:d,stagedAtoms:h,stagedMolecules:m,unitCellAvailable:u,unitCellVisible:p}){const f=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(Jn,{children:[t.jsx(Je,{label:"Distance",children:t.jsx(R.AlignVerticalDistributeCenter,{className:"size-4"})}),t.jsx(Je,{label:"Connectivity",children:t.jsx(R.Share2,{className:"size-4"})}),t.jsx(Je,{label:"Angle",children:t.jsx(R.Waypoints,{className:"size-4"})}),t.jsx(Je,{label:"Dihedral",children:t.jsx(R.Spline,{className:"size-4"})}),t.jsx(Je,{label:"Add dummy atoms",children:t.jsx(R.Bubbles,{className:"size-4"})}),t.jsx(Je,{label:"Delete atoms",children:t.jsx(R.CircleX,{className:"size-4"})}),t.jsx(Je,{label:"Rotate",children:t.jsx(R.Rotate3d,{className:"size-4"})})]}),t.jsxs(Jn,{children:[t.jsx(Je,{label:p?"Hide unit cell":"Show unit cell",disabled:!u,onClick:l,children:t.jsx(R.Boxes,{className:"size-4"})}),t.jsx(Je,{label:"Clear selection",disabled:!f,onClick:r,children:t.jsx(R.Trash2,{className:"size-4"})}),t.jsx(Je,{label:"Send selection",disabled:!f,onClick:a,children:t.jsx(R.Send,{className:"size-4"})}),t.jsx(Je,{label:"Stage current selection",disabled:!f,onClick:o,children:t.jsx(R.Box,{className:"size-4"})}),t.jsx(Je,{label:"Clear staged selections",disabled:!g,onClick:n,children:t.jsx(R.Eraser,{className:"size-4"})}),t.jsx(Je,{label:"Send staged selections",disabled:!g,onClick:s,children:t.jsx(R.ArrowUpRight,{className:"size-4"})})]})]}),e?t.jsxs("div",{className:"thread-graph-molecule-camera",children:[t.jsxs("div",{children:[t.jsx("strong",{children:"XYZ: "}),"x=",e.position.x.toFixed(1)," y=",e.position.y.toFixed(1)," z=",e.position.z.toFixed(1),t.jsx("br",{}),t.jsx("strong",{children:"Quat: "}),"qx=",e.position.qx.toFixed(2)," qy=",e.position.qy.toFixed(2)," qz=",e.position.qz.toFixed(2)," qw=",e.position.qw.toFixed(2)]}),t.jsx("div",{className:"thread-graph-molecule-camera-divider"}),t.jsxs("div",{className:"flex flex-col gap-1 text-[10px]",children:[t.jsxs("div",{children:["Selected atoms:"," ",d.length>0?d.map(b=>`${i[b]??"Atom"}(${b})`).join(", "):"None"]}),t.jsxs("div",{children:["Staged: ",m," molecule(s), ",h," atom(s)"]})]})]}):null]})}var Vh=We({"src/components/graph-workspace/GraphMoleculeViewerLowerButtonGroup.tsx"(){sl()}});function Xh({currentIndex:e,exportContent:r,moleculeId:n,onScreenshot:a,viewerRef:s,xyzContent:o,xyzFormat:l}){const i=Wh(n);async function d(){o&&await navigator.clipboard.writeText(o)}function h(){o&&ss(o,`${i}_step_${e+1}.${l||"xyz"}`)}function m(){r&&ss(r,`${i}_trajectory.${l||"xyz"}`)}function u(){s.current&&(s.current.zoom(1.2),s.current.render())}function p(){s.current&&(s.current.zoom(.8),s.current.render())}function f(){s.current&&(s.current.zoomTo(),s.current.setCameraParameters({}),s.current.render())}return t.jsxs(Jn,{className:"ml-auto justify-end",children:[t.jsx(Je,{label:"Copy current structure",onClick:()=>void d(),disabled:!o,children:t.jsx(R.Copy,{className:"size-3.5"})}),t.jsx(Je,{label:"Download current structure",onClick:h,disabled:!o,children:t.jsx(R.Download,{className:"size-3.5"})}),t.jsx(Je,{label:"Download full trajectory",onClick:m,disabled:!r,children:t.jsx(R.Box,{className:"size-3.5"})}),t.jsx(Je,{label:"Copy screenshot",onClick:a,disabled:!s.current||!o,children:t.jsx(R.Camera,{className:"size-3.5"})}),t.jsx(Dh,{className:"thread-graph-molecule-button-divider"}),t.jsx(Je,{label:"Zoom in",onClick:u,disabled:!s.current||!o,children:t.jsx(R.ZoomIn,{className:"size-3.5"})}),t.jsx(Je,{label:"Zoom out",onClick:p,disabled:!s.current||!o,children:t.jsx(R.ZoomOut,{className:"size-3.5"})}),t.jsx(Je,{label:"Reset camera",onClick:f,disabled:!s.current||!o,children:t.jsx(R.RotateCcw,{className:"size-3.5"})})]})}var qh=We({"src/components/graph-workspace/GraphMoleculeViewerUpperButtonGroup.tsx"(){al(),sl()}});async function Kh(){if(typeof window>"u")throw new Error("3Dmol is only available in a browser environment.");return window["3Dmol"]?window["3Dmol"]:(Vr||(Vr=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)})),Vr)}var Vr,Yh=We({"src/components/graph-workspace/load3Dmol.ts"(){Vr=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(Rd,{"data-slot":"slider",...r!==void 0?{defaultValue:r}:{},...s!==void 0?{value:s}:{},min:a,max:n,className:ot("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(Ad,{"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(_d,{"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(Md,{"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 Jh=We({"src/components/graph-ui/Slider.tsx"(){Mt()}});function Qh(e){const r=e==null?void 0:e.trim().toLowerCase();return!r||r==="extxyz"?"xyz":r}function eu(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<=sl}function ou(e){return e&&(e.node.path||e.node.name)||null}function lu(e){return Math.min(xa,Math.max(ga,e))}function iu({alt:e,onClose:r,src:n}){const a=c.useRef(null),s=c.useRef(null),o=c.useRef(null),[l,i]=c.useState(1),[d,h]=c.useState({x:0,y:0}),[m,u]=c.useState(!1);c.useEffect(()=>{var v;const k=document.body.style.overflow;document.body.style.overflow="hidden",(v=s.current)==null||v.focus();const y=w=>{w.key==="Escape"&&r()};return window.addEventListener("keydown",y),()=>{document.body.style.overflow=k,window.removeEventListener("keydown",y)}},[r]);function p(){i(1),h({x:0,y:0})}function f(k,y,v){const w=lu(k);if(w!==l){if(typeof y=="number"&&typeof v=="number"&&a.current){const C=a.current.getBoundingClientRect(),N=y-(C.left+C.width/2),E=v-(C.top+C.height/2),R=w/l;h(_=>({x:N-(N-_.x)*R,y:E-(E-_.y)*R}))}i(w)}}function g(k){k.preventDefault();const y=k.deltaY<0?1:-1;f(l+y*Vr,k.clientX,k.clientY)}function x(k){l<=1||k.button!==0||(k.currentTarget.setPointerCapture(k.pointerId),o.current={pointerId:k.pointerId,startClientX:k.clientX,startClientY:k.clientY,startOffsetX:d.x,startOffsetY:d.y},u(!0))}function j(k){const y=o.current;!y||y.pointerId!==k.pointerId||h({x:y.startOffsetX+k.clientX-y.startClientX,y:y.startOffsetY+k.clientY-y.startClientY})}function b(k){var y;((y=o.current)==null?void 0:y.pointerId)===k.pointerId&&(o.current=null,u(!1))}return Lr.createPortal(t.jsxs("div",{className:"thread-graph-image-lightbox",role:"dialog","aria-modal":"true","aria-label":`Image preview: ${e||"workspace image"}`,children:[t.jsxs("div",{className:"thread-graph-image-lightbox-toolbar",role:"toolbar","aria-label":"Image zoom controls",children:[t.jsx("button",{type:"button",onClick:()=>f(l-Vr),disabled:l<=ga,title:"Zoom out","aria-label":"Zoom out",children:t.jsx(P.Minus,{className:"h-4 w-4"})}),t.jsxs("button",{type:"button",onClick:p,className:"thread-graph-image-lightbox-scale",title:"Reset zoom","aria-label":`Reset zoom, currently ${Math.round(l*100)}%`,children:[t.jsx(P.RotateCcw,{className:"h-3.5 w-3.5"}),t.jsxs("span",{children:[Math.round(l*100),"%"]})]}),t.jsx("button",{type:"button",onClick:()=>f(l+Vr),disabled:l>=xa,title:"Zoom in","aria-label":"Zoom in",children:t.jsx(P.Plus,{className:"h-4 w-4"})}),t.jsx("span",{className:"thread-graph-image-lightbox-divider","aria-hidden":"true"}),t.jsx("button",{ref:s,type:"button",onClick:r,title:"Close image preview","aria-label":"Close image preview",children:t.jsx(P.X,{className:"h-4 w-4"})})]}),t.jsx("div",{ref:a,className:"thread-graph-image-lightbox-viewport",onClick:k=>{k.target===k.currentTarget&&r()},onWheel:g,children:t.jsx("img",{src:n,alt:e,draggable:!1,className:m?"is-dragging":"",onPointerDown:x,onPointerMove:j,onPointerUp:b,onPointerCancel:b,style:{transform:`translate3d(${d.x}px, ${d.y}px, 0) scale(${l})`}})})]}),document.body)}function nl({alt:e,className:r,loading:n,src:a}){const s=c.useRef(null),[o,l]=c.useState(!1);function i(){l(!1),window.requestAnimationFrame(()=>{var d;return(d=s.current)==null?void 0:d.focus()})}return t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:s,type:"button",className:"thread-graph-zoomable-image-trigger",onClick:()=>l(!0),title:"Open image preview","aria-label":`Open image preview: ${e||"workspace image"}`,children:t.jsx("img",{src:a,alt:e,className:r,loading:n})}),o?t.jsx(iu,{src:a,alt:e,onClose:i}):null]})}function du(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 cu({error:e,imageUrl:r,loadingMore:n,onSaveFile:a,onOpenWorkspaceFile:s,onLoadMore:o,onCollapse:l,pdfUrl:i,previewFile:d,previewLoading:h,plugins:m,resolveWorkspaceFileUrl:u,selectedTarget:p,workspaceRootPath:f}){const[g,x]=c.useState(!1),[j,b]=c.useState(""),[k,y]=c.useState(null),[v,w]=c.useState(!1),[C,N]=c.useState("preview"),E=(p==null?void 0:p.node)??null,R=E!=null&&E.artifact?m.renderArtifact({artifact:E.artifact,expanded:!0,onToggleExpanded:()=>{}}):null,_=Th(d??null),Y=(d==null?void 0:d.language)||Eh((d==null?void 0:d.path)??""),W=d?Mr(d.path):"",re=ol.has(W),F=ou(p),A=d!==null&&pa.has(W),J=!!(d&&a)&&!A&&su(d),Z=(p==null?void 0:p.kind)==="live-molecule",M=!!(E!=null&&E.artifact&&R),ie=!!_||M;c.useEffect(()=>{x(!1),b((d==null?void 0:d.content)??""),y(null),N("preview")},[d==null?void 0:d.path,d==null?void 0:d.content]);async function O(){if(!(!d||!a)){w(!0),y(null);try{await a({path:d.path,content:j}),x(!1)}catch(G){y(G instanceof Error?G.message:"Failed to save file.")}finally{w(!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":(p==null?void 0:p.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"}),F?t.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-slate-500 dark:text-slate-400",children:F}):null]}),l?t.jsx("button",{type:"button",onClick:l,"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(P.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,p?p.kind==="workspace-file"&&h?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..."}):p.kind==="workspace-file"&&_?t.jsx("div",{className:"thread-graph-molecule-preview min-h-0 flex-1 overflow-hidden",children:t.jsx(tu,{source:_,moleculeId:_.uuid??p.node.path,title:"PyMOL-style (PDB/CIF)"})}):p.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(nl,{src:r,alt:p.node.path||p.node.name,className:"max-h-full max-w-full object-contain"})}):p.kind==="workspace-file"&&i?t.jsx("div",{className:"thread-graph-file-preview-frame min-h-0 flex-1 overflow-hidden",children:t.jsx("iframe",{src:i,title:`PDF preview: ${p.node.path||p.node.name}`,className:"h-full w-full border-0"})}):p.kind==="workspace-file"&&d?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 flex-wrap items-center justify-between gap-2 border-b px-4 py-2",children:[t.jsxs("div",{className:"min-w-0 text-xs uppercase tracking-[0.12em]",children:[A?"molecule":Y||W||"text"," ","| ",d.size.toLocaleString()," bytes",d.truncated?t.jsxs("span",{className:"ml-2 text-amber-500",children:["showing ",d.nextOffset.toLocaleString()," bytes"]}):null]}),re||J?t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[re&&!g?t.jsxs("div",{className:"thread-graph-markdown-view-switch inline-flex items-center rounded-md border p-0.5",role:"group","aria-label":"Markdown view",children:[t.jsxs("button",{type:"button",onClick:()=>N("preview"),className:`inline-flex h-7 items-center gap-1 rounded px-2 text-xs transition ${C==="preview"?"is-active":""}`,"aria-pressed":C==="preview",children:[t.jsx(P.BookOpen,{className:"h-3.5 w-3.5"}),t.jsx("span",{children:"Preview"})]}),t.jsxs("button",{type:"button",onClick:()=>N("source"),className:`inline-flex h-7 items-center gap-1 rounded px-2 text-xs transition ${C==="source"?"is-active":""}`,"aria-pressed":C==="source",children:[t.jsx(P.Code2,{className:"h-3.5 w-3.5"}),t.jsx("span",{children:"Source"})]})]}):null,J?t.jsx("div",{className:"flex shrink-0 items-center gap-1",children:g?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>{b(d.content),x(!1),y(null)},disabled:v,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(P.X,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:()=>void O(),disabled:v||j===d.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(P.Save,{className:"h-4 w-4"})})]}):t.jsx("button",{type:"button",onClick:()=>{b(d.content),N("source"),x(!0),y(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(P.Pencil,{className:"h-4 w-4"})})}):null]}):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,g?t.jsx("textarea",{value:j,onChange:G=>b(G.currentTarget.value),spellCheck:!1,"aria-label":"Workspace file editor",className:"thread-graph-file-editor min-h-0 flex-1 resize-none border-0 bg-transparent p-4 font-mono text-[12px] leading-5 text-slate-900 outline-none dark:text-slate-100"}):re&&C==="preview"?t.jsx(ll,{content:d.content,markdownPath:d.path,...s?{onOpenWorkspaceFile:s}:{},...u?{resolveWorkspaceFileUrl:u}:{},...f?{workspaceRootPath:f}:{}}):t.jsx(Xr,{content:d.content,language:Y}),d.truncated&&o?t.jsx("div",{className:"thread-graph-file-preview-footer flex justify-center border-t px-4 py-3",children:t.jsx("button",{type:"button",onClick:o,disabled:n,title:"Load more workspace preview","aria-label":"Load more workspace preview",className:"thread-graph-load-more-button rounded-md px-4 py-1.5 text-xs disabled:opacity-50",children:n?"Loading...":`Load more (${(d.size-d.nextOffset).toLocaleString()} bytes remaining)`})}):null]}):(p.kind==="live-molecule"||p.kind==="artifact")&&p.node.artifact?t.jsx("div",{className:ie||Z?"min-h-0 flex-1 overflow-hidden":"min-h-0 flex-1 overflow-auto p-3",children:R}):p.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(ar,{label:"Workspace Data",children:t.jsx(Xr,{content:p.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:p.node.kind}),t.jsx(Xr,{content:p.node.detail??p.node.preview??p.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 al,sl,ol,ga,xa,Vr,ls,Xr,ll,hu=Oe({"src/components/graph-workspace/GraphWorkspacePreviewPane.tsx"(){Vo(),fa(),Qo(),ru(),al=50*1024,sl=1e3,ol=new Set(["md","markdown"]),ga=.5,xa=5,Vr=.25,ls={cs:"csharp",jsonl:"json",md:"markdown",rb:"ruby",rs:"rust",sh:"bash",yml:"yaml"},Xr=c.memo(function({content:r,language:n="text"}){const a=c.useRef(null),[s,o]=c.useState(null),[l,i]=c.useState(!1);c.useEffect(()=>{let m=!0;return Uo().then(u=>{m&&o(u)}).catch(()=>{}),()=>{m=!1}},[]),c.useEffect(()=>{var f;const m=(f=a.current)==null?void 0:f.closest(".thread-ui-shell"),u=()=>m?m.getAttribute("data-theme-effective")==="dark"||m.classList.contains("dark")||m.classList.contains("thread-ui-theme-dark"):document.documentElement.classList.contains("dark");if(i(u()),!m)return;const p=new MutationObserver(()=>i(u()));return p.observe(m,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>p.disconnect()},[]);const d=c.useMemo(()=>{var f;if(!s)return"";const m=((f=s.getLoadedLanguages)==null?void 0:f.call(s))??[],u=ls[n]??n,p=m.includes(u)?u:"text";try{return ss(s.codeToHtml(r,{lang:p,theme:l?"ayu-dark":"ayu-light"}))}catch{return ss(s.codeToHtml(r,{lang:"text",theme:l?"ayu-dark":"ayu-light"}))}},[r,l,s,n]),h=r.split(`
|
|
13
|
-
`);return t.jsx("div",{ref:a,className:"thread-graph-code-preview min-h-0 flex-1 overflow-auto",role:"region","aria-label":"Source code",children:d?t.jsx("div",{className:"thread-graph-highlighted-code-preview",dangerouslySetInnerHTML:{__html:d}}):t.jsx("pre",{className:"thread-graph-plain-code-preview",children:t.jsx("code",{children:h.map((m,u)=>t.jsxs("span",{className:"thread-graph-code-line",children:[t.jsx("span",{className:"thread-graph-code-line-number","aria-hidden":"true",children:u+1}),t.jsx("span",{children:m||" "})]},u))})})})}),ll=c.memo(function({content:r,markdownPath:n,onOpenWorkspaceFile:a,resolveWorkspaceFileUrl:s,workspaceRootPath:o}){const l=i=>i?au({markdownPath:n,resourceUrl:i,workspaceRootPath:o??""}):null;return t.jsx("div",{className:"thread-graph-markdown thread-graph-markdown-preview min-h-0 flex-1 overflow-auto px-5 py-4 sm:px-7 sm:py-6",children:t.jsx(ro,{remarkPlugins:[no],components:{a({href:i,children:d,...h}){const m=l(i);return m&&a?t.jsx("a",{...h,href:(s==null?void 0:s(m))??i,onClick:u=>{u.preventDefault(),a(m)},children:d}):t.jsx("a",{...h,href:i,children:d})},img({src:i,alt:d,...h}){const m=l(i),u=m?(s==null?void 0:s(m))??i:i;return u?t.jsx(nl,{src:u,alt:d??"",loading:"lazy",className:h.className}):null}},children:r})})})}});function uu({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 mu=Oe({"src/components/graph-workspace/GraphEmptyGarbageDialog.tsx"(){}});function il(e){return`${cl}${e.workspaceId??"workspace"}:${e.threadId}`}function pu(e){if(typeof window>"u")return[];try{const r=window.localStorage.getItem(il(e));if(!r)return[];const n=JSON.parse(r);return Array.isArray(n)?n.filter(a=>typeof a=="string"):[]}catch{return[]}}function is(e,r){if(!(typeof window>"u"))try{window.localStorage.setItem(il(e),JSON.stringify([...r]))}catch{}}function Yn(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=>Yn(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 ds(e,r){if(e.kind==="directory")return r?t.jsx(P.FolderOpen,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"}):t.jsx(P.Folder,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"});const n=Mr(e.name);return n==="zip"?t.jsx(P.FileArchive,{className:"h-4 w-4 text-amber-600"}):e.kind==="file"&&["png","jpg","jpeg","gif","webp","svg"].includes(n)?t.jsx(P.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(P.FileCode2,{className:"h-4 w-4 text-emerald-600"}):t.jsx(P.File,{className:"h-4 w-4 text-slate-400 dark:text-slate-500"})}function dl({depth:e,expandedPaths:r,loadingPaths:n,node:a,onCopyPath:s,onDownload:o,onPreview:l,onSelect:i,onToggle:d,selectedNodeId:h}){const m=a.kind==="directory",u=m&&(a.path===""||r.has(a.path)),p=m&&n.has(a.path),f=h===a.id,g=`${e*Kr+.5}rem`;return m?t.jsxs("div",{children:[t.jsxs("div",{className:"thread-graph-tree-row group relative 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:[u?t.jsx(P.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}):t.jsx(P.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}),ds(a,u),t.jsx("span",{className:"truncate",children:a.name}),p?t.jsx("span",{className:"ml-auto shrink-0 text-xs text-slate-400 dark:text-slate-500",children:"Loading"}):null]}),o||s&&a.path?t.jsxs("div",{className:"thread-graph-tree-actions absolute inset-y-0 right-1 flex items-center gap-0.5 pl-1",children:[o?t.jsx("button",{type:"button",onClick:()=>o(a),className:"thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-slate-400 transition hover:bg-white hover:text-slate-900 sm:h-7 sm:w-7 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(P.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 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 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(P.Copy,{className:"h-3.5 w-3.5"})}):null]}):null]}),u?t.jsxs("div",{children:[a.children.map(x=>t.jsx(dl,{depth:e+1,expandedPaths:r,loadingPaths:n,node:x,...s?{onCopyPath:s}:{},...o?{onDownload:o}:{},...l?{onPreview:l}:{},onSelect:i,onToggle:d,selectedNodeId:h},x.id)),a.truncated?t.jsx("div",{className:"px-2 py-1 text-xs text-slate-400 dark:text-slate-500",style:{paddingLeft:`${(e+1)*Kr+.5}rem`},children:"More items not shown"}):null]}):null]}):t.jsxs("div",{className:`thread-graph-tree-row group relative flex items-center text-sm transition ${f?"is-selected":"text-slate-600 hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100"}`,children:[t.jsxs("button",{type:"button",onClick:()=>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*Kr+1.9}rem`},children:[ds(a,!1),t.jsx("span",{className:"truncate",children:a.name})]}),a.kind==="file"&&(l||o||s)?t.jsxs("div",{className:"thread-graph-tree-actions absolute inset-y-0 right-1 flex items-center gap-0.5 pl-1",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 ${f?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Preview ${a.name}`,"aria-label":`Preview ${a.name}`,children:t.jsx(P.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 ${f?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Download ${a.name}`,"aria-label":`Download ${a.name}`,children:t.jsx(P.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 ${f?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Copy path for ${a.name}`,"aria-label":`Copy path for ${a.name}`,children:t.jsx(P.Copy,{className:"h-3.5 w-3.5"})}):null]}):null]})}function fu({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(P.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 gu({canEmptyGarbage:e,canUpload:r,onCollapse:n,expandedPaths:a,loadingPaths:s,loading:o,onDownload:l,onCopyPath:i,onEmptyGarbage:d,onPreview:h,onRefresh:m,onSelect:u,onToggle:p,onUpload:f,explorerScrollTopRef:g,explorerScrollerRef:x,selectedNodeId:j,tree:b,liveNodes:k}){const y=c.useMemo(()=>({...b,children:b.children.filter(v=>v.path!=="live")}),[b]);return c.useLayoutEffect(()=>{const v=x.current;v&&(v.scrollTop=g.current)},[x,g]),t.jsxs("aside",{className:`${hl} flex flex-col`,children:[t.jsxs("div",{className:ul,children:[t.jsx("div",{className:"min-w-0",children:t.jsx("h2",{className:ml,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:pl,title:"Collapse Explorer","aria-label":"Collapse Explorer",children:[t.jsx(P.ChevronsLeft,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Collapse Explorer"})]}):null,t.jsx("button",{type:"button",onClick:f,disabled:!r,className:Yr,title:r?"Upload file":"Upload is unavailable for this workspace","aria-label":"Upload file",children:t.jsx(P.Upload,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:m,className:Yr,title:"Refresh workspace","aria-label":"Refresh workspace",children:t.jsx(P.RefreshCw,{className:`h-4 w-4 ${o?"animate-spin":""}`})}),d?t.jsx("button",{type:"button",onClick:d,disabled:!e,className:Yr,title:e?"Empty garbage":"Garbage controls are unavailable","aria-label":"Empty garbage",children:t.jsx(P.Trash2,{className:"h-4 w-4"})}):null]})]}),t.jsxs("div",{ref:x,className:"thread-graph-workspace-tree-scroll min-h-0 flex-1 overflow-y-auto py-2",onScroll:v=>{g.current=v.currentTarget.scrollTop},children:[t.jsx(fu,{liveNodes:k??[],onSelect:u,selectedNodeId:j}),t.jsx("div",{className:fl,children:"Workspace"}),t.jsx(dl,{depth:0,expandedPaths:a,loadingPaths:s,node:y,...i?{onCopyPath:i}:{},...l?{onDownload:l}:{},...h?{onPreview:h}:{},onSelect:u,onToggle:p,selectedNodeId:j}),y.children.length===0?t.jsx("p",{className:gl,children:"This workspace is empty. Agent tool runs execute inside the thread workspace, so files should appear here as the session works."}):null]})]})}function xu({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:es(r,n),[e,i,n,r,s,l]),m=i??h??es(r,n),u=c.useMemo(()=>Ph(m),[m]),p=c.useMemo(()=>{var I;return((I=m.children.find(V=>V.path==="live"))==null?void 0:I.children)??[]},[m]),f=Yo(m),[g,x]=c.useState(()=>(f==null?void 0:f.id)??null),[j,b]=c.useState(()=>new Set(["","artifacts","thread-events","live",...ts((f==null?void 0:f.path)??"")])),[k,y]=c.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 639px)").matches?"viewer":null),[v,w]=c.useState(null),[C,N]=c.useState(!1),[E,R]=c.useState(()=>new Set),[_,Y]=c.useState(!1),[W,re]=c.useState(!1),[F,A]=c.useState(!1),[J,Z]=c.useState([]),[M,ie]=c.useState(null),[O,G]=c.useState(null),[H,T]=c.useState(null),[$,D]=c.useState(!1),L=c.useRef(null),S=c.useRef(null),U=c.useRef(0),B=c.useRef(null),le=!!l,K=(g?u.get(g):null)??f??null,de={threadId:r.thread.id,workspaceId:r.workspace.id??r.thread.workspaceId??null};c.useEffect(()=>{U.current=0,B.current=null,b(new Set(["","artifacts","thread-events","live",...pu(de),...ts((f==null?void 0:f.path)??"")]))},[de.threadId,de.workspaceId]);function ee(){var V;const I=((V=S.current)==null?void 0:V.scrollTop)??U.current;U.current=I,B.current=I}function ve(){const I=B.current??U.current;if(!S.current)return;let ae=0;const ge=()=>{const je=S.current;je&&(je.scrollTop=Math.min(I,Math.max(0,je.scrollHeight-je.clientHeight)),U.current=je.scrollTop,ae+=1,ae<8?window.requestAnimationFrame(ge):B.current=null)};window.requestAnimationFrame(ge)}c.useLayoutEffect(()=>{k!=="explorer"&&ve()},[k,m]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const I=window.matchMedia("(max-width: 639px)"),V=()=>D(I.matches);return V(),typeof I.addEventListener=="function"?(I.addEventListener("change",V),()=>I.removeEventListener("change",V)):(I.addListener(V),()=>I.removeListener(V))},[]);async function be(I){if(!l)return;const V=I??(K==null?void 0:K.path)??null;N(!0),w(null);try{const ae=nr(await l.listTree({...de,path:""}));let ge=i?Yn(ae,i):ae;if(i){const Ie=[...j].filter(ce=>ce).sort((ce,He)=>ce.split("/").length-He.split("/").length);for(const ce of Ie){const He=Un(i,ce);if((He==null?void 0:He.kind)!=="directory"||!He.childrenLoaded)continue;const qe=nr(await l.listTree({...de,path:ce}));ge=Xn(ge,ce,Yn(qe,He))}}d(ge);const je=qo(ge);x(Ie=>{var He;const ce=V??(Ie?(He=u.get(Ie))==null?void 0:He.path:null);return ce&&qn(ge,ce)?`workspace:${ce}`:(je==null?void 0:je.id)??Ie})}catch(ae){w(ae instanceof Error?ae.message:"Failed to load workspace"),d(null)}finally{N(!1)}}async function ye(I){if(!(!l||!i)){R(V=>{if(V.has(I))return V;const ae=new Set(V);return ae.add(I),ae}),w(null);try{const V=nr(await l.listTree({...de,path:I}));d(ae=>ae&&Xo(ae,I,V.children,{truncated:V.truncated}))}catch(V){w(V instanceof Error?V.message:"Failed to load directory")}finally{R(V=>{if(!V.has(I))return V;const ae=new Set(V);return ae.delete(I),ae})}}}async function we(I){const V=Ch(I,r.workspace.absPath);if(!V)return;const ae=Sh(V);if(y(null),b(ge=>{const je=new Set(ge);je.add("");for(const Ie of ae)je.add(Ie);return is(de,je),je}),!l){qn(m,V)&&x(`workspace:${V}`);return}N(!0),w(null);try{let ge=i??nr(await l.listTree({...de,path:""}));for(const je of ae){const Ie=Un(ge,je);if((Ie==null?void 0:Ie.kind)==="directory"&&Ie.childrenLoaded)continue;const ce=nr(await l.listTree({...de,path:je}));ge=Xn(ge,je,ce)}d(ge),x(`workspace:${V}`)}catch(ge){w(ge instanceof Error?ge.message:`Failed to open ${V}`)}finally{N(!1)}}c.useEffect(()=>{if(!(!l||!i))for(const I of u.values())I.path&&I.kind==="directory"&&j.has(I.path)&&I.hasChildren&&!I.childrenLoaded&&!E.has(I.path)&&ye(I.path)},[i,j,u,l]),c.useEffect(()=>{d(null),R(new Set),ie(null),G(null),T(null),w(null),be()},[le,r.thread.id,r.workspace.id,r.thread.workspaceId]),c.useEffect(()=>{o&&we(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),G(null),T(null);return}const V=I;let ae=!1;async function ge(){var je;if(l){Y(!0),w(null),ie(null),G(null),T(null);try{const Ie=Mr(V),ce=(je=l.getRawFileUrl)==null?void 0:je.call(l,{...de,path:V});if(ce&&Zo.has(Ie)){ae||G(ce);return}if(ce&&Jo.has(Ie)){ae||T(ce);return}const He=await l.readFile({...de,path:V,limit:qr});ae||ie(He)}catch(Ie){ae||w(Ie instanceof Error?Ie.message:"Failed to read file")}finally{ae||Y(!1)}}}return ge(),()=>{ae=!0}},[l,K==null?void 0:K.id]);async function fe(){if(!(!l||!(M!=null&&M.truncated))){re(!0);try{const I=await l.readFile({...de,path:M.path,offset:M.nextOffset,limit:qr});ie(V=>V&&{...V,content:V.content+I.content,truncated:I.truncated,nextOffset:I.nextOffset,size:I.size})}finally{re(!1)}}}async function Te(I){if(!(l!=null&&l.writeFile))return;w(null),await l.writeFile({...de,path:I.path,content:I.content}),await be(I.path);const V=await l.readFile({...de,path:I.path,limit:qr});ie(V)}async function oe(I){if(!(!(l!=null&&l.uploadFile)||!I)){N(!0),w(null);try{const V=await l.uploadFile({...de,path:I.name,file:I}),ae=V.kind==="archive"?V.paths[0]??null:V.file.path;await be(ae)}catch(V){w(V instanceof Error?V.message:"Failed to upload file")}finally{N(!1)}}}async function Q(I){var ae;const V=(ae=I.target.files)==null?void 0:ae[0];I.target.value="",V&&await oe(V)}function me(){if(!(l!=null&&l.uploadFile))return;const I=()=>{var V;return(V=L.current)==null?void 0:V.click()};if(l.pickUploadFile){l.pickUploadFile({...de,defaultPick:I,upload:oe});return}I()}function ke(I){var V;(V=l==null?void 0:l.downloadNode)==null||V.call(l,{...de,path:I.path,kind:I.kind==="directory"?"directory":"file"})}function Ne(I){if(!I.path||typeof navigator>"u"||!navigator.clipboard)return;const V=r.workspace.absPath.replace(/\/+$/,""),ae=I.path.startsWith("/")?I.path:V?`${V}/${I.path.replace(/^\/+/,"")}`:I.path;navigator.clipboard.writeText(ae).catch(ge=>{w(ge instanceof Error?ge.message:"Failed to copy file path")})}function Ae(I){I.kind==="file"&&(ee(),x(I.id),y("explorer"))}async function Ge(){if(l!=null&&l.emptyGarbage){if(w(null),!l.listGarbage){Z([]),A(!0);return}try{const I=await l.listGarbage(de);Z(I.map(V=>`garbage/${V}`))}catch(I){Z([]),w(I instanceof Error?I.message:"Failed to list garbage files")}finally{A(!0)}}}async function Me(){if(l!=null&&l.emptyGarbage){A(!1),w(null);try{await l.emptyGarbage(de),await be((K==null?void 0:K.path)??null)}catch(I){w(I instanceof Error?I.message:"Failed to empty garbage")}}}const Fe={onCopyPath:Ne,...l!=null&&l.downloadNode?{onDownload:ke}:{},...l!=null&&l.emptyGarbage?{onEmptyGarbage:Ge}:{},...l?{onRefresh:()=>void be((K==null?void 0:K.path)??null)}:{},...l!=null&&l.uploadFile?{onUpload:me}:{}};function X(I){if(!I)return;const V=u.get(`workspace:${I}`),ae=(V==null?void 0:V.kind)==="directory"&&V.hasChildren&&!V.childrenLoaded&&!E.has(I);b(ge=>{const je=new Set(ge);return je.has(I)?je.delete(I):je.add(I),is(de,je),je}),!j.has(I)&&ae&&ye(I)}const he=t.jsx(gu,{canEmptyGarbage:!!(l!=null&&l.emptyGarbage),canUpload:!!(l!=null&&l.uploadFile),onCollapse:()=>{ee(),y("explorer")},expandedPaths:j,loadingPaths:E,loading:C,explorerScrollTopRef:U,explorerScrollerRef:S,...Fe,onPreview:Ae,onSelect:I=>{x(I)},onToggle:X,selectedNodeId:(K==null?void 0:K.id)??null,tree:m,liveNodes:p}),Ce=t.jsx(cu,{error:v,imageUrl:O,loadingMore:W,onOpenWorkspaceFile:I=>{we(I)},onLoadMore:fe,...l!=null&&l.writeFile?{onSaveFile:Te}:{},onCollapse:()=>{ee(),y("viewer")},pdfUrl:H,previewFile:M,previewLoading:_,plugins:a,...l!=null&&l.getRawFileUrl?{resolveWorkspaceFileUrl:I=>{var V;return((V=l.getRawFileUrl)==null?void 0:V.call(l,{...de,path:I}))??null}}:{},selectedTarget:du(K),workspaceRootPath:r.workspace.absPath});return k==="explorer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:Ce}):k==="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:[F?t.jsx(uu,{files:J,onCancel:()=>A(!1),onConfirm:()=>void Me()}):null,$?t.jsxs(Fn,{direction:"vertical",className:"thread-graph-workspace-mobile-stack",children:[t.jsx(lr,{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(On,{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(lr,{defaultSize:58,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-viewer h-full min-h-0 overflow-hidden",children:Ce})})]}):t.jsxs(Fn,{direction:"horizontal",className:"thread-graph-workspace-resizable",children:[t.jsx(lr,{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(On,{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(lr,{defaultSize:67,minSize:30,children:t.jsx("div",{className:"thread-graph-workspace-viewer-pane h-full min-h-0 overflow-hidden",children:Ce})})]}),t.jsx("input",{ref:L,type:"file","aria-label":"Workspace upload file input","data-testid":"workspace-upload-file-input",className:"hidden",onChange:I=>void Q(I)})]})}var qr,cl,Kr,hl,ul,ml,Yr,pl,fl,gl,bu=Oe({"src/components/graph-workspace/GraphWorkspaceExplorer.tsx"(){fa(),hu(),mu(),Wo(),qr=24e3,cl="remote-codex:graphchat:workspace:expanded:",Kr=.5,hl="thread-graph-explorer h-full min-h-0 overflow-hidden rounded-[12px]",ul="thread-graph-explorer-header flex h-[60px] shrink-0 items-center justify-between border-b px-4",ml="text-[18px] font-semibold text-slate-900 dark:text-slate-100",Yr="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",pl="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",fl="thread-graph-workspace-label px-3 pb-1 pt-2 text-[11px] font-semibold tracking-normal text-slate-500 dark:text-slate-400",gl="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 En({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 tr({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 vu({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 xr({value:e,title:r,icon:n,children:a}){return t.jsxs(Pr,{value:e,className:"thread-guide-section border-b border-[var(--theme-border)] last:border-b-0",children:[t.jsx(hn,{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(vu,{children:n}),r]})}),t.jsx(Rr,{className:"space-y-3 pb-3",children:a})]})}function ku(){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(zr,{type:"multiple",defaultValue:["start","workspace","remote-codex"],className:"space-y-0",children:[t.jsxs(xr,{value:"start",title:"Getting Started",icon:t.jsx(P.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(tr,{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(xr,{value:"workspace",title:"Workspace Explorer",icon:t.jsx(P.FolderOpen,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(P.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(P.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(P.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(P.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(P.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(tr,{items:[t.jsxs(t.Fragment,{children:[t.jsx(En,{children:".xyz .extxyz .cif"})," use the 3D molecule plugin."]}),t.jsxs(t.Fragment,{children:[t.jsx(En,{children:".png .jpg .gif .svg .webp"})," use inline image preview."]}),t.jsxs(t.Fragment,{children:[t.jsx(En,{children:".py .json .ts .md .csv"})," use text/code preview."]}),"Large files load in chunks when the workspace adapter supports it."]})]})]}),t.jsxs(xr,{value:"viewer",title:"Viewer",icon:t.jsx(P.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(tr,{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(xr,{value:"usage",title:"Tool Usage & Chat",icon:t.jsx(P.BarChart2,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(P.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(tr,{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(P.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(tr,{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(xr,{value:"remote-codex",title:"Remote Codex Extras",icon:t.jsx(P.Code2,{className:"h-3 w-3"}),children:t.jsx(tr,{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 wu=Oe({"src/components/graph-workspace/GraphGuidePanel.tsx"(){_r()}});function yu(e){if(e==null)return"—";if(typeof e=="string")return e.length>2e3?`${e.slice(0,2e3)}
|
|
14
|
-
...(truncated)`:e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function cs({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:yu(r)})]})}function ju({event:e}){return t.jsxs(Pr,{value:e.id,className:"thread-tool-call mb-2 overflow-hidden rounded-lg border border-[var(--theme-border)] last:mb-0",children:[t.jsxs(hn,{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(Rr,{className:"px-3 pb-3",children:t.jsxs("div",{className:"space-y-2 px-3 pb-3 pt-1",children:[t.jsx(cs,{label:"Input",value:e.preview}),t.jsx(cs,{label:"Output",value:e.detail})]})})]})}function Nu({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(P.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(zr,{type:"single",collapsible:!0,value:s??"",onValueChange:i=>o(i||null),className:"space-y-0",children:n.slice(-50).map(i=>t.jsx(ju,{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(P.RefreshCw,{className:"h-3 w-3"}),"Reload from workspace"]})]})}var Cu=Oe({"src/components/graph-workspace/GraphToolUsagePanel.tsx"(){_r()}});function hs(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,m=s.x+d,u=s.y+h,p=o.x+l/2,f=o.y+i/2,g=(p-m)/(2*d)-(f-u)/(2*h),x=(p-m)/(2*d)+(f-u)/(2*h),j=1/(Math.abs(g)+Math.abs(x)),b=j*g,k=j*x,y=d*(b+k)+m,v=h*(-b+k)+u;return{x:y,y:v}}function us(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?Ot.Left:o>=a+(e.measured.width??1)-1?Ot.Right:l<=s+1?Ot.Top:l>=n.y+(e.measured.height??1)-1?Ot.Bottom:Ot.Top}function xl(e,r){const n=hs(e,r),a=hs(r,e),s=us(e,n),o=us(r,a);return{sx:n.x,sy:n.y,tx:a.x,ty:a.y,sourcePos:s,targetPos:o}}function Su(e,r=900,n=620){if(!e||!Array.isArray(e))return{nodes:[],edges:[]};const a=(d,h,m,u)=>{const p=new Map,f=d.length;d.forEach((g,x)=>{const j=g.id.split("").reduce((b,k)=>{const y=(b<<5)-b+k.charCodeAt(0);return y&y},0);p.set(g.id,{x:Math.abs(j)%m+x*100%m,y:Math.abs(j>>16)%u+x*150%u,vx:0,vy:0})});for(let g=0;g<200;g+=1){for(let x=0;x<f;x+=1)for(let j=x+1;j<f;j+=1){const b=d[x],k=d[j];if(!b||!k)continue;const y=p.get(b.id),v=p.get(k.id);if(!y||!v)continue;const w=y.x-v.x,C=y.y-v.y,N=Math.sqrt(w*w+C*C)||1,R=(200-N)*.5,_=w/N*R,Y=C/N*R;y.vx+=_,y.vy+=Y,v.vx-=_,v.vy-=Y}h.forEach(x=>{const j=p.get(x.source),b=p.get(x.target);if(!j||!b)return;const k=b.x-j.x,y=b.y-j.y,v=Math.sqrt(k*k+y*y)||1,C=(v-120)*.3,N=k/v*C,E=y/v*C;j.vx+=N,j.vy+=E,b.vx-=N,b.vy-=E}),p.forEach(x=>{x.x+=x.vx*.1,x.y+=x.vy*.1,x.vx*=.9,x.vy*=.9,x.x=Math.max(80,Math.min(m-80,x.x)),x.y=Math.max(80,Math.min(u-80,x.y))})}return p},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(m=>{s.has(m)&&o.push({id:`${d.id}-${m}`,source:d.id,target:m,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:eo.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 ba=Oe({"src/components/graph-chat/FloatingHelper.tsx"(){}});function Tu({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:m,targetPos:u}=xl(s,o),[p]=to({sourceX:l,sourceY:i,sourcePosition:m||n,targetPosition:u||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:p}),t.jsx("circle",{cx:d||e,cy:h||r,fill:"var(--theme-panel)",r:3,stroke:"currentColor",strokeWidth:1.5})]})}var Eu=Oe({"src/components/graph-chat/FloatingConnectionLine.tsx"(){ba()}});function Lu({id:e,source:r,target:n,markerEnd:a,style:s}){const o=Aa(r),l=Aa(n);if(!o||!l)return null;const{sx:i,sy:d,tx:h,ty:m,sourcePos:u,targetPos:p}=xl(o,l),[f]=to({sourceX:i,sourceY:d,sourcePosition:u,targetPosition:p,targetX:h,targetY:m});return t.jsx("path",{id:e,className:"react-flow__edge-path",d:f,markerEnd:a,style:s})}var Iu=Oe({"src/components/graph-chat/FloatingEdge.tsx"(){ba()}});function zu({nodes:e}){const[r,n,a]=Od([]),[s,o,l]=Wd([]),i=c.useMemo(()=>Su(e),[e]),d=c.useMemo(()=>({floating:Lu}),[]),h=c.useMemo(()=>({styledNode:({data:u,isConnectable:p})=>t.jsxs("div",{className:"thread-graph-flow-node",children:[u.label,t.jsx(Ma,{type:"target",position:Ot.Top,isConnectable:p,style:{opacity:0,pointerEvents:"none"}}),t.jsx(Ma,{type:"source",position:Ot.Bottom,isConnectable:p,style:{opacity:0,pointerEvents:"none"}})]})}),[]);c.useEffect(()=>{n(i.nodes),o(i.edges)},[i.edges,i.nodes,o,n]);const m=c.useCallback(u=>o(p=>Ud({...u,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:eo.Arrow}},p)),[o]);return t.jsx("div",{className:"thread-graph-flow h-full min-h-0",children:t.jsx(Vd,{children:t.jsxs(Xd,{nodes:r,edges:s,onNodesChange:a,onEdgesChange:l,onConnect:m,fitView:!0,nodeTypes:h,edgeTypes:d,connectionLineComponent:Tu,children:[t.jsx(qd,{}),t.jsx(Kd,{gap:16})]})})})}var Pu=Oe({"src/components/graph-chat/GraphVisualization.tsx"(){Eu(),Iu(),ba()}});function Ru(e){return{...vl,...e}}function ms(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 _u(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:tn(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:tn(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 tn(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 Au(e){switch(e.kind){case"userMessage":return"User";case"agentMessage":return"Agent";default:return tn(e.kind)}}function $u(e){return(e.previewText??e.text??e.detailText??e.kind).replace(/\s+/g," ").slice(0,96)}function Du(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}`,m=[l];i&&m.push(i),n.push({id:h,name:Au(d),description:$u(d),out_node_id:m}),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 bl({detail:e,status:r,plugins:n,workspaceAdapter:a,metaContent:s,settingsContent:o,activeView:l="chat",features:i,focusPathRequest:d=null}){const h=c.useMemo(()=>Ru(i),[i]),m=ms(h,i==null?void 0:i.defaultTab),[u,p]=c.useState(m),f=c.useMemo(()=>yh(e),[e]),g=c.useMemo(()=>Mu(e),[e]),x=c.useMemo(()=>{const w=new Map;for(const C of g)w.set(C.kind,(w.get(C.kind)??0)+1);return[...w.entries()].sort((C,N)=>N[1]-C[1])},[g]),j=n.getThreadPanels(),b=Math.max(...x.map(([,w])=>w),1),k=c.useMemo(()=>Du(e,g),[e,g]),y=c.useMemo(()=>{const w=[];return h.workspace&&w.push({id:"workspace",label:"Workspace",icon:null}),h.toolUsage&&w.push({id:"tools",label:"Tool Usage",icon:P.BarChart2}),h.guide&&w.push({id:"guide",label:"Guide",icon:P.BookOpen}),w},[h.guide,h.toolUsage,h.workspace]),v=c.useMemo(()=>{const w=[];return h.threadGraph&&w.push({id:"graph",label:"Thread graph",icon:P.GitBranch}),h.extensions&&w.push({id:"extensions",label:"Remote Codex extensions",icon:P.Wrench}),w},[h.extensions,h.threadGraph]);return c.useEffect(()=>{(!u||!_u(h,u))&&p(ms(h,i==null?void 0:i.defaultTab))},[u,i==null?void 0:i.defaultTab,h]),c.useEffect(()=>{d&&h.workspace&&p("workspace")},[h.workspace,d==null?void 0:d.requestId]),u?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(w=>{const C=w.icon;return t.jsxs("button",{type:"button",onClick:()=>p(w.id),className:`thread-graph-right-tab inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md px-3 text-xs font-medium transition ${u===w.id?"is-active":""}`,children:[C?t.jsx(C,{className:"h-3.5 w-3.5"}):null,w.label]},w.id)}),v.length?t.jsx("div",{className:"thread-graph-right-tab-secondary ml-auto flex min-w-0 shrink items-center gap-1 border-l pl-2","aria-label":"Remote Codex workspace extensions",children:v.map(w=>{const C=w.icon;return t.jsx("button",{type:"button",onClick:()=>p(w.id),className:`thread-graph-right-tab inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-xs font-medium transition ${u===w.id?"is-active":""}`,title:w.label,"aria-label":w.label,children:t.jsx(C,{className:"h-3.5 w-3.5"})},w.id)})}):null]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[u==="workspace"?t.jsx(xu,{activeView:l,detail:e,artifacts:f,plugins:n,status:r,focusPathRequest:d,workspaceAdapter:a??null}):null,u==="tools"?t.jsx(Nu,{formatToolKind:tn,toolCounts:x,toolEvents:g,maxToolCount:b}):null,u==="graph"?t.jsx("div",{className:"thread-graph-visualization-panel h-full min-h-0 p-3",children:t.jsx(zu,{nodes:k})}):null,u==="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(ar,{label:"Plugin Panels",children:j.length?t.jsx("div",{className:"flex flex-wrap gap-2",children:j.map(w=>t.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-1 text-xs text-[var(--theme-fg-soft)]",children:w.label},w.id))}):t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"No thread panels are enabled."})}),t.jsx(ar,{label:"Enabled Renderers",children:t.jsx("div",{className:"flex flex-wrap gap-2",children:n.plugins.filter(w=>w.enabled).map(w=>t.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-1 text-xs text-[var(--theme-fg-soft)]",children:w.name},w.id))})}),t.jsx(ar,{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(P.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(P.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(P.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(ar,{label:"Thread Meta",children:s}):null,o?t.jsx(ar,{label:"Settings",children:o}):null]})}):null,u==="guide"?t.jsx(ku,{}):null]})]}):null}var vl,kl,Bu=Oe({"src/components/ThreadGraphWorkspacePanel.tsx"(){bu(),Qo(),wu(),Cu(),fa(),Pu(),vl={workspace:!0,toolUsage:!0,guide:!0,threadGraph:!0,extensions:!0},kl=c.memo(bl)}}),wl={};wh(wl,{MemoizedThreadGraphWorkspacePanel:()=>kl,ThreadGraphWorkspacePanel:()=>bl});var Gu=Oe({"src/workspace-panel.ts"(){Bu()}});function hr(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))}hr(`.thread-ui-shell,
|
|
9
|
+
`),a+=i}return n.length>0?n:[e]}function os(e,r){return r!=="xyz"?e:e.flatMap(n=>eu(n))}function ls(e){return e.map(r=>`${r.replace(/\s+$/g,"")}
|
|
10
|
+
`).join("")}function tu(e){if(!e)return{format:"xyz",frames:[],exportContent:""};if(typeof e=="string"){const s=os([e],"xyz");return{frames:s,format:"xyz",exportContent:ls(s)}}const r=Qh(e.format),n=e.content.filter(s=>s.trim().length>0);return{frames:os(n,r),format:r,exportContent:ls(n)}}var ru=We({"src/components/graph-workspace/GraphMoleculeViewerData.ts"(){}});function nu({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),m=c.useRef(!0),[u,p]=c.useState(null),[f,g]=c.useState(0),[b,j]=c.useState(null),[x,k]=c.useState(!1),[w,v]=c.useState({}),[y,N]=c.useState([]),[S,T]=c.useState({}),[M,A]=c.useState(!1),[J,W]=c.useState(!1),[re,O]=c.useState(null),P=c.useMemo(()=>tu(s),[s]),Y=P.frames,Z=P.format,_=Y[f]??null,ie=Y.length>0&&f===Y.length-1,H=r??"current",B=Object.values(S).reduce((L,C)=>L+C.length,0),F=Object.keys(S).length;c.useEffect(()=>{if(Y.length===0){g(0);return}g(Y.length-1)},[Y.length]),c.useEffect(()=>{if(!x||Y.length<=1)return;const L=window.setInterval(()=>{g(C=>C>=Y.length-1?(window.clearInterval(L),k(!1),C):C+1)},200);return()=>window.clearInterval(L)},[x,Y.length]),c.useEffect(()=>{const L=l.current;if(!L||i.current)return;let C=!1;try{const G=document.createElement("canvas");if(!(G.getContext("webgl2")||G.getContext("webgl")||G.getContext("experimental-webgl"))){O("WebGL is unavailable in this browser environment. Unable to render 3D viewer.");return}}catch{O("WebGL is unavailable in this browser environment. Unable to render 3D viewer.");return}const U=()=>{var G,le;(G=i.current)==null||G.resize(),(le=i.current)==null||le.render()};return Kh().then(G=>{if(!(C||i.current))try{const le=G.createViewer(L,{});i.current=le,le.setBackgroundColor("#f8fafc",.8),window.addEventListener("resize",U),window.setTimeout(U,100)}catch(le){console.error("Failed to initialize 3Dmol viewer:",le),O("Failed to initialize 3D viewer. Please refresh or try another browser.")}}).catch(G=>{console.error("Failed to load 3Dmol viewer runtime:",G),O("Failed to load 3D viewer runtime. Please refresh or try another browser.")}),()=>{C=!0,window.removeEventListener("resize",U),i.current=null,d.current=null}},[]),c.useEffect(()=>{const L=i.current;if(!(!L||!_))try{L.removeAllModels(),L.removeAllShapes(),L.removeAllLabels();const C=L.addModel(_,Z||"xyz");d.current=C,C.setStyle({},{stick:{radius:.2},sphere:{scale:.3}});const U=C.getCrystData(),G=!!(U&&typeof U=="object"&&Object.keys(U).length);A(G),W(G?m.current:!1),N([]),v({});const le=_.split(`
|
|
11
|
+
`).slice(2).map(ee=>ee.trim()).filter(Boolean).map(ee=>ee.split(/\s+/)[0]??"Atom");h.current||(L.zoomTo(),h.current=!0),C.setClickable({},!0,(ee,ce,q)=>{const ve=ee.serial??ee.index;if(ve===void 0)return;const ke=ee.atom||ee.elem||le[ve]||"Atom";N(je=>{const fe=!!(q!=null&&q.shiftKey||q!=null&&q.metaKey||q!=null&&q.ctrlKey)?je.includes(ve)?je.filter(Te=>Te!==ve):[...je,ve]:je.length===1&&je[0]===ve?[]:[ve];return v(Te=>{if(fe.length===0)return{};const oe={};return fe.forEach(Q=>{oe[Q]=Te[Q]||le[Q]||ke}),oe}),fe})}),C.setHoverable({},!0,(ee,ce,q)=>{!q||!ee||j({x:q.clientX,y:q.clientY,label:`${ee.atom||ee.elem||"Atom"} (${ee.serial??ee.index??"?"})`,coords:{x:ee.x.toFixed(2),y:ee.y.toFixed(2),z:ee.z.toFixed(2)}})},()=>j(null)),L.render()}catch(C){console.error("Failed to render molecule:",C),O("Unable to render this molecular structure.")}},[_,Z]),c.useEffect(()=>{const L=i.current,C=d.current;if(!(!L||!C)){try{L.removeUnitCell(C)}catch{}if(J&&M)try{L.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{A(!1),W(!1)}L.render()}},[M,J,_,Z]),c.useEffect(()=>{const L=i.current,C=d.current;!L||!C||!_||(C.setStyle({},{stick:{radius:.2},sphere:{scale:.3}}),y.length>0&&C.setStyle({serial:y},{stick:{radius:.3,color:"yellow"},sphere:{scale:.4,color:"yellow"}}),L.render(),a==null||a({moleculeId:r,atoms:y}))},[r,a,y,_]),c.useEffect(()=>{if(!_)return;let L=0;const C=()=>{var G,le;const U=(le=(G=i.current)==null?void 0:G.getView)==null?void 0:le.call(G);if(Array.isArray(U)&&U.length>=8){const[ee,ce,q,ve,ke,je,ye,fe]=U;if(typeof ee=="number"&&typeof ce=="number"&&typeof q=="number"&&typeof ve=="number"&&typeof ke=="number"&&typeof je=="number"&&typeof ye=="number"&&typeof fe=="number"){const Te=Math.sqrt(ke*ke+je*je+ye*ye),oe=Te>0?{x:ke/Te,y:je/Te,z:ye/Te}:{x:0,y:0,z:0};p({position:{x:ee,y:ce,z:q,qx:ke,qy:je,qz:ye,qw:fe},lookAt:oe,zoom:ve})}}L=window.requestAnimationFrame(C)};return L=window.requestAnimationFrame(C),()=>window.cancelAnimationFrame(L)},[_]);const E=c.useCallback(async()=>{const L=i.current;if(!(L!=null&&L.pngURI))return;L.render();const C=L.pngURI();if(C){try{const G=await(await fetch(C)).blob(),le=new ClipboardItem({[G.type||"image/png"]:G});await navigator.clipboard.write([le])}catch{}n==null||n({moleculeId:r,image:C})}},[r,n]);function D(){M&&W(L=>{const C=!L;return m.current=C,C})}function $(){y.length!==0&&T(L=>{const C=L[H]??[];return{...L,[H]:Array.from(new Set([...C,...y]))}})}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:[re?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:re}):null,!re&&!_?t.jsx("div",{className:"thread-graph-molecule-empty absolute inset-0 flex items-center justify-center p-4 text-sm text-slate-400",children:"No molecule data available."}):null,b?t.jsxs("div",{className:"thread-graph-molecule-tooltip pointer-events-none fixed z-[1000] rounded-md border border-gray-300 bg-white/95 px-2 py-1.5 text-[10px] text-gray-800 shadow-md",style:{left:b.x-20,top:b.y-50},children:[t.jsx("div",{className:"mb-0.5 font-semibold text-gray-900",children:b.label}),t.jsxs("div",{className:"space-x-2 text-gray-600",children:[t.jsxs("span",{children:["x: ",b.coords.x]}),t.jsxs("span",{children:["y: ",b.coords.y]}),t.jsxs("span",{children:["z: ",b.coords.z]})]})]}):null]}),t.jsxs("div",{className:"thread-graph-molecule-controls shrink-0",children:[t.jsxs("div",{className:"thread-graph-molecule-control-row",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-graph-molecule-control-title",children:"Ball & Stick"}),t.jsx("p",{className:"thread-graph-molecule-control-subtitle",children:"XYZ / PDB / CIF preview"})]}),t.jsx(Xh,{currentIndex:f,exportContent:P.exportContent,moleculeId:r,onScreenshot:()=>void E(),viewerRef:i,xyzContent:_,xyzFormat:Z})]}),Y.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 ",f+1," / ",Y.length,t.jsx(Er,{type:"button",variant:"ghost",size:"icon",className:"thread-graph-molecule-button h-5 w-5",onClick:()=>{k(L=>{const C=!L;return C&&f===Y.length-1&&g(0),C})},"aria-label":x?"Pause trajectory":"Play trajectory",title:x?"Pause trajectory":"Play trajectory",children:x&&f!==Y.length-1?t.jsx(R.Pause,{className:"h-3 w-3"}):t.jsx(R.Play,{className:"h-3 w-3"})})]}),t.jsxs(Er,{type:"button",variant:"ghost",onClick:()=>g(Y.length-1),className:"thread-graph-molecule-live-button",children:[t.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${ie?"animate-pulse bg-red-600":"bg-gray-300"}`}),"Live"]})]}),t.jsx(Zh,{value:[f],max:Y.length-1,step:1,onValueChange:L=>g(L[0]??0),"aria-label":"Trajectory frame"})]}):null,t.jsx(Uh,{cameraInfo:u,onClearSelection:()=>N([]),onClearStaged:()=>T({}),onSendSelection:()=>a==null?void 0:a({moleculeId:r,atoms:y}),onSendStaged:()=>{Object.entries(S).forEach(([L,C])=>{a==null||a({moleculeId:L==="current"?r:L,atoms:C})})},onStageSelection:$,onToggleUnitCell:D,selectedAtomLabels:w,selectedSerials:y,stagedAtoms:B,stagedMolecules:F,unitCellAvailable:M,unitCellVisible:J})]})]})]})}var au=We({"src/components/graph-workspace/GraphMoleculeViewer.tsx"(){Vh(),qh(),Yh(),hn(),Jh(),ru()}});function is(e){return e.replace(/background-color:[^;"]+;?/g,"background-color: transparent;").replace(/background:[^;"]+;?/g,"background: transparent;")}function su(e){try{return decodeURIComponent(e)}catch{return e}}function ds(e){const r=[];for(const n of e.replace(/\\/g,"/").split("/"))if(!(!n||n===".")){if(n===".."){if(r.length===0)return null;r.pop();continue}r.push(n)}return r.join("/")}function ou({markdownPath:e,resourceUrl:r,workspaceRootPath:n=""}){const a=r.trim(),s=/^[a-zA-Z]:[\\/]/.test(a);if(!a||a.startsWith("#")||a.startsWith("//")||!s&&/^[a-zA-Z][a-zA-Z\d+.-]*:/.test(a)){if(!/^https?:/i.test(a)||typeof window>"u")return null;try{const g=new URL(a);if(g.origin!==window.location.origin)return null;r=g.pathname}catch{return null}}const o=su(r.trim().split(/[?#]/,1)[0]??"");if(!o)return null;const l=n.trim().replace(/\\/g,"/").replace(/\/+$/,""),i=o.replace(/\\/g,"/");if(i.startsWith("/")||/^[a-zA-Z]:\//.test(i)){if(l&&i!==l&&!i.startsWith(`${l}/`))return null;const b=l&&(i===l||i.startsWith(`${l}/`))?i.slice(l.length):i;return ds(b)}const h=e.replace(/\\/g,"/"),m=h.startsWith("/")||/^[a-zA-Z]:\//.test(h);if(m&&l&&h!==l&&!h.startsWith(`${l}/`))return null;const u=m&&l?h.slice(l.length).replace(/^\/+/,""):h.replace(/^\/+/,""),p=u.lastIndexOf("/"),f=p>=0?u.slice(0,p):"";return ds(f?`${f}/${o}`:o)}function lu(e){return!e.truncated&&e.size<=ll&&e.content.split(`
|
|
12
|
+
`).length<=il}function iu(e){return e&&(e.node.path||e.node.name)||null}function du(e){return Math.min(ka,Math.max(va,e))}function cu({alt:e,onClose:r,src:n}){const a=c.useRef(null),s=c.useRef(null),o=c.useRef(null),[l,i]=c.useState(1),[d,h]=c.useState({x:0,y:0}),[m,u]=c.useState(!1);c.useEffect(()=>{var v;const k=document.body.style.overflow;document.body.style.overflow="hidden",(v=s.current)==null||v.focus();const w=y=>{y.key==="Escape"&&r()};return window.addEventListener("keydown",w),()=>{document.body.style.overflow=k,window.removeEventListener("keydown",w)}},[r]);function p(){i(1),h({x:0,y:0})}function f(k,w,v){const y=du(k);if(y!==l){if(typeof w=="number"&&typeof v=="number"&&a.current){const N=a.current.getBoundingClientRect(),S=w-(N.left+N.width/2),T=v-(N.top+N.height/2),M=y/l;h(A=>({x:S-(S-A.x)*M,y:T-(T-A.y)*M}))}i(y)}}function g(k){k.preventDefault();const w=k.deltaY<0?1:-1;f(l+w*Xr,k.clientX,k.clientY)}function b(k){l<=1||k.button!==0||(k.currentTarget.setPointerCapture(k.pointerId),o.current={pointerId:k.pointerId,startClientX:k.clientX,startClientY:k.clientY,startOffsetX:d.x,startOffsetY:d.y},u(!0))}function j(k){const w=o.current;!w||w.pointerId!==k.pointerId||h({x:w.startOffsetX+k.clientX-w.startClientX,y:w.startOffsetY+k.clientY-w.startClientY})}function x(k){var w;((w=o.current)==null?void 0:w.pointerId)===k.pointerId&&(o.current=null,u(!1))}return Lr.createPortal(t.jsxs("div",{className:"thread-graph-image-lightbox",role:"dialog","aria-modal":"true","aria-label":`Image preview: ${e||"workspace image"}`,children:[t.jsxs("div",{className:"thread-graph-image-lightbox-toolbar",role:"toolbar","aria-label":"Image zoom controls",children:[t.jsx("button",{type:"button",onClick:()=>f(l-Xr),disabled:l<=va,title:"Zoom out","aria-label":"Zoom out",children:t.jsx(R.Minus,{className:"h-4 w-4"})}),t.jsxs("button",{type:"button",onClick:p,className:"thread-graph-image-lightbox-scale",title:"Reset zoom","aria-label":`Reset zoom, currently ${Math.round(l*100)}%`,children:[t.jsx(R.RotateCcw,{className:"h-3.5 w-3.5"}),t.jsxs("span",{children:[Math.round(l*100),"%"]})]}),t.jsx("button",{type:"button",onClick:()=>f(l+Xr),disabled:l>=ka,title:"Zoom in","aria-label":"Zoom in",children:t.jsx(R.Plus,{className:"h-4 w-4"})}),t.jsx("span",{className:"thread-graph-image-lightbox-divider","aria-hidden":"true"}),t.jsx("button",{ref:s,type:"button",onClick:r,title:"Close image preview","aria-label":"Close image preview",children:t.jsx(R.X,{className:"h-4 w-4"})})]}),t.jsx("div",{ref:a,className:"thread-graph-image-lightbox-viewport",onClick:k=>{k.target===k.currentTarget&&r()},onWheel:g,children:t.jsx("img",{src:n,alt:e,draggable:!1,className:m?"is-dragging":"",onPointerDown:b,onPointerMove:j,onPointerUp:x,onPointerCancel:x,style:{transform:`translate3d(${d.x}px, ${d.y}px, 0) scale(${l})`}})})]}),document.body)}function ol({alt:e,className:r,loading:n,src:a}){const s=c.useRef(null),[o,l]=c.useState(!1);function i(){l(!1),window.requestAnimationFrame(()=>{var d;return(d=s.current)==null?void 0:d.focus()})}return t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:s,type:"button",className:"thread-graph-zoomable-image-trigger",onClick:()=>l(!0),title:"Open image preview","aria-label":`Open image preview: ${e||"workspace image"}`,children:t.jsx("img",{src:a,alt:e,className:r,loading:n})}),o?t.jsx(cu,{src:a,alt:e,onClose:i}):null]})}function hu(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 uu({error:e,imageUrl:r,loadingMore:n,onSaveFile:a,onOpenWorkspaceFile:s,onLoadMore:o,onCollapse:l,pdfUrl:i,previewFile:d,previewLoading:h,plugins:m,resolveWorkspaceFileUrl:u,selectedTarget:p,workspaceRootPath:f}){const[g,b]=c.useState(!1),[j,x]=c.useState(""),[k,w]=c.useState(null),[v,y]=c.useState(!1),[N,S]=c.useState("preview"),T=(p==null?void 0:p.node)??null,M=T!=null&&T.artifact?m.renderArtifact({artifact:T.artifact,expanded:!0,onToggleExpanded:()=>{}}):null,A=Lh(d??null),J=(d==null?void 0:d.language)||Ih((d==null?void 0:d.path)??""),W=d?_r(d.path):"",re=dl.has(W),O=iu(p),P=d!==null&&xa.has(W),Y=!!(d&&a)&&!P&&lu(d),Z=(p==null?void 0:p.kind)==="live-molecule",_=!!(T!=null&&T.artifact&&M),ie=!!A||_;c.useEffect(()=>{b(!1),x((d==null?void 0:d.content)??""),w(null),S("preview")},[d==null?void 0:d.path,d==null?void 0:d.content]);async function H(){if(!(!d||!a)){y(!0),w(null);try{await a({path:d.path,content:j}),b(!1)}catch(B){w(B instanceof Error?B.message:"Failed to save file.")}finally{y(!1)}}}return t.jsxs("section",{className:"thread-graph-viewer flex h-full min-h-0 flex-col overflow-hidden rounded-[12px]","data-preview-target-kind":(p==null?void 0:p.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"}),O?t.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-slate-500 dark:text-slate-400",children:O}):null]}),l?t.jsx("button",{type:"button",onClick:l,"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(R.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,p?p.kind==="workspace-file"&&h?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..."}):p.kind==="workspace-file"&&A?t.jsx("div",{className:"thread-graph-molecule-preview min-h-0 flex-1 overflow-hidden",children:t.jsx(nu,{source:A,moleculeId:A.uuid??p.node.path,title:"PyMOL-style (PDB/CIF)"})}):p.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(ol,{src:r,alt:p.node.path||p.node.name,className:"max-h-full max-w-full object-contain"})}):p.kind==="workspace-file"&&i?t.jsx("div",{className:"thread-graph-file-preview-frame min-h-0 flex-1 overflow-hidden",children:t.jsx("iframe",{src:i,title:`PDF preview: ${p.node.path||p.node.name}`,className:"h-full w-full border-0"})}):p.kind==="workspace-file"&&d?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 flex-wrap items-center justify-between gap-2 border-b px-4 py-2",children:[t.jsxs("div",{className:"min-w-0 text-xs uppercase tracking-[0.12em]",children:[P?"molecule":J||W||"text"," ","| ",d.size.toLocaleString()," bytes",d.truncated?t.jsxs("span",{className:"ml-2 text-amber-500",children:["showing ",d.nextOffset.toLocaleString()," bytes"]}):null]}),re||Y?t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[re&&!g?t.jsxs("div",{className:"thread-graph-markdown-view-switch inline-flex items-center rounded-md border p-0.5",role:"group","aria-label":"Markdown view",children:[t.jsxs("button",{type:"button",onClick:()=>S("preview"),className:`inline-flex h-7 items-center gap-1 rounded px-2 text-xs transition ${N==="preview"?"is-active":""}`,"aria-pressed":N==="preview",children:[t.jsx(R.BookOpen,{className:"h-3.5 w-3.5"}),t.jsx("span",{children:"Preview"})]}),t.jsxs("button",{type:"button",onClick:()=>S("source"),className:`inline-flex h-7 items-center gap-1 rounded px-2 text-xs transition ${N==="source"?"is-active":""}`,"aria-pressed":N==="source",children:[t.jsx(R.Code2,{className:"h-3.5 w-3.5"}),t.jsx("span",{children:"Source"})]})]}):null,Y?t.jsx("div",{className:"flex shrink-0 items-center gap-1",children:g?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>{x(d.content),b(!1),w(null)},disabled:v,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(R.X,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:()=>void H(),disabled:v||j===d.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(R.Save,{className:"h-4 w-4"})})]}):t.jsx("button",{type:"button",onClick:()=>{x(d.content),S("source"),b(!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(R.Pencil,{className:"h-4 w-4"})})}):null]}):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,g?t.jsx("textarea",{value:j,onChange:B=>x(B.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"}):re&&N==="preview"?t.jsx(cl,{content:d.content,markdownPath:d.path,...s?{onOpenWorkspaceFile:s}:{},...u?{resolveWorkspaceFileUrl:u}:{},...f?{workspaceRootPath:f}:{}}):t.jsx(qr,{content:d.content,language:J}),d.truncated&&o?t.jsx("div",{className:"thread-graph-file-preview-footer flex justify-center border-t px-4 py-3",children:t.jsx("button",{type:"button",onClick:o,disabled:n,title:"Load more workspace preview","aria-label":"Load more workspace preview",className:"thread-graph-load-more-button rounded-md px-4 py-1.5 text-xs disabled:opacity-50",children:n?"Loading...":`Load more (${(d.size-d.nextOffset).toLocaleString()} bytes remaining)`})}):null]}):(p.kind==="live-molecule"||p.kind==="artifact")&&p.node.artifact?t.jsx("div",{className:ie||Z?"min-h-0 flex-1 overflow-hidden":"min-h-0 flex-1 overflow-auto p-3",children:M}):p.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(sr,{label:"Workspace Data",children:t.jsx(qr,{content:p.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:p.node.kind}),t.jsx(qr,{content:p.node.detail??p.node.preview??p.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 ll,il,dl,va,ka,Xr,cs,qr,cl,mu=We({"src/components/graph-workspace/GraphWorkspacePreviewPane.tsx"(){Ko(),ba(),rl(),au(),ll=50*1024,il=1e3,dl=new Set(["md","markdown"]),va=.5,ka=5,Xr=.25,cs={cs:"csharp",jsonl:"json",md:"markdown",rb:"ruby",rs:"rust",sh:"bash",yml:"yaml"},qr=c.memo(function({content:r,language:n="text"}){const a=c.useRef(null),[s,o]=c.useState(null),[l,i]=c.useState(!1);c.useEffect(()=>{let m=!0;return qo().then(u=>{m&&o(u)}).catch(()=>{}),()=>{m=!1}},[]),c.useEffect(()=>{var f;const m=(f=a.current)==null?void 0:f.closest(".thread-ui-shell"),u=()=>m?m.getAttribute("data-theme-effective")==="dark"||m.classList.contains("dark")||m.classList.contains("thread-ui-theme-dark"):document.documentElement.classList.contains("dark");if(i(u()),!m)return;const p=new MutationObserver(()=>i(u()));return p.observe(m,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>p.disconnect()},[]);const d=c.useMemo(()=>{var f;if(!s)return"";const m=((f=s.getLoadedLanguages)==null?void 0:f.call(s))??[],u=cs[n]??n,p=m.includes(u)?u:"text";try{return is(s.codeToHtml(r,{lang:p,theme:l?"ayu-dark":"ayu-light"}))}catch{return is(s.codeToHtml(r,{lang:"text",theme:l?"ayu-dark":"ayu-light"}))}},[r,l,s,n]),h=r.split(`
|
|
13
|
+
`);return t.jsx("div",{ref:a,className:"thread-graph-code-preview min-h-0 flex-1 overflow-auto",role:"region","aria-label":"Source code",children:d?t.jsx("div",{className:"thread-graph-highlighted-code-preview",dangerouslySetInnerHTML:{__html:d}}):t.jsx("pre",{className:"thread-graph-plain-code-preview",children:t.jsx("code",{children:h.map((m,u)=>t.jsxs("span",{className:"thread-graph-code-line",children:[t.jsx("span",{className:"thread-graph-code-line-number","aria-hidden":"true",children:u+1}),t.jsx("span",{children:m||" "})]},u))})})})}),cl=c.memo(function({content:r,markdownPath:n,onOpenWorkspaceFile:a,resolveWorkspaceFileUrl:s,workspaceRootPath:o}){const l=i=>i?ou({markdownPath:n,resourceUrl:i,workspaceRootPath:o??""}):null;return t.jsx("div",{className:"thread-graph-markdown thread-graph-markdown-preview min-h-0 flex-1 overflow-auto px-5 py-4 sm:px-7 sm:py-6",children:t.jsx(so,{remarkPlugins:[oo],components:{a({href:i,children:d,...h}){const m=l(i);return m&&a?t.jsx("a",{...h,href:(s==null?void 0:s(m))??i,onClick:u=>{u.preventDefault(),a(m)},children:d}):t.jsx("a",{...h,href:i,children:d})},img({src:i,alt:d,...h}){const m=l(i),u=m?(s==null?void 0:s(m))??i:i;return u?t.jsx(ol,{src:u,alt:d??"",loading:"lazy",className:h.className}):null}},children:r})})})}});function pu({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 fu=We({"src/components/graph-workspace/GraphEmptyGarbageDialog.tsx"(){}});function hl(e){return`${ml}${e.workspaceId??"workspace"}:${e.threadId}`}function gu(e){if(typeof window>"u")return[];try{const r=window.localStorage.getItem(hl(e));if(!r)return[];const n=JSON.parse(r);return Array.isArray(n)?n.filter(a=>typeof a=="string"):[]}catch{return[]}}function hs(e,r){if(!(typeof window>"u"))try{window.localStorage.setItem(hl(e),JSON.stringify([...r]))}catch{}}function Qn(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=>Qn(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 us(e,r){if(e.kind==="directory")return r?t.jsx(R.FolderOpen,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"}):t.jsx(R.Folder,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"});const n=_r(e.name);return n==="zip"?t.jsx(R.FileArchive,{className:"h-4 w-4 text-amber-600"}):e.kind==="file"&&["png","jpg","jpeg","gif","webp","svg"].includes(n)?t.jsx(R.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(R.FileCode2,{className:"h-4 w-4 text-emerald-600"}):t.jsx(R.File,{className:"h-4 w-4 text-slate-400 dark:text-slate-500"})}function ul({depth:e,expandedPaths:r,loadingPaths:n,node:a,onCopyPath:s,onDownload:o,onPreview:l,onSelect:i,onToggle:d,selectedNodeId:h}){const m=a.kind==="directory",u=m&&(a.path===""||r.has(a.path)),p=m&&n.has(a.path),f=h===a.id,g=`${e*Yr+.5}rem`;return m?t.jsxs("div",{children:[t.jsxs("div",{className:"thread-graph-tree-row group relative 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:[u?t.jsx(R.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}):t.jsx(R.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}),us(a,u),t.jsx("span",{className:"truncate",children:a.name}),p?t.jsx("span",{className:"ml-auto shrink-0 text-xs text-slate-400 dark:text-slate-500",children:"Loading"}):null]}),o||s&&a.path?t.jsxs("div",{className:"thread-graph-tree-actions absolute inset-y-0 right-1 flex items-center gap-0.5 pl-1",children:[o?t.jsx("button",{type:"button",onClick:()=>o(a),className:"thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-slate-400 transition hover:bg-white hover:text-slate-900 sm:h-7 sm:w-7 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(R.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 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 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(R.Copy,{className:"h-3.5 w-3.5"})}):null]}):null]}),u?t.jsxs("div",{children:[a.children.map(b=>t.jsx(ul,{depth:e+1,expandedPaths:r,loadingPaths:n,node:b,...s?{onCopyPath:s}:{},...o?{onDownload:o}:{},...l?{onPreview:l}:{},onSelect:i,onToggle:d,selectedNodeId:h},b.id)),a.truncated?t.jsx("div",{className:"px-2 py-1 text-xs text-slate-400 dark:text-slate-500",style:{paddingLeft:`${(e+1)*Yr+.5}rem`},children:"More items not shown"}):null]}):null]}):t.jsxs("div",{className:`thread-graph-tree-row group relative flex items-center text-sm transition ${f?"is-selected":"text-slate-600 hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100"}`,children:[t.jsxs("button",{type:"button",onClick:()=>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*Yr+1.9}rem`},children:[us(a,!1),t.jsx("span",{className:"truncate",children:a.name})]}),a.kind==="file"&&(l||o||s)?t.jsxs("div",{className:"thread-graph-tree-actions absolute inset-y-0 right-1 flex items-center gap-0.5 pl-1",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 ${f?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Preview ${a.name}`,"aria-label":`Preview ${a.name}`,children:t.jsx(R.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 ${f?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Download ${a.name}`,"aria-label":`Download ${a.name}`,children:t.jsx(R.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 ${f?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Copy path for ${a.name}`,"aria-label":`Copy path for ${a.name}`,children:t.jsx(R.Copy,{className:"h-3.5 w-3.5"})}):null]}):null]})}function xu({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(R.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 bu({canEmptyGarbage:e,canUpload:r,onCollapse:n,expandedPaths:a,loadingPaths:s,loading:o,onDownload:l,onCopyPath:i,onEmptyGarbage:d,onPreview:h,onRefresh:m,onSelect:u,onToggle:p,onUpload:f,explorerScrollTopRef:g,explorerScrollerRef:b,selectedNodeId:j,tree:x,liveNodes:k}){const w=c.useMemo(()=>({...x,children:x.children.filter(v=>v.path!=="live")}),[x]);return c.useLayoutEffect(()=>{const v=b.current;v&&(v.scrollTop=g.current)},[b,g]),t.jsxs("aside",{className:`${pl} flex flex-col`,children:[t.jsxs("div",{className:fl,children:[t.jsx("div",{className:"min-w-0",children:t.jsx("h2",{className:gl,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:xl,title:"Collapse Explorer","aria-label":"Collapse Explorer",children:[t.jsx(R.ChevronsLeft,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Collapse Explorer"})]}):null,t.jsx("button",{type:"button",onClick:f,disabled:!r,className:Zr,title:r?"Upload file":"Upload is unavailable for this workspace","aria-label":"Upload file",children:t.jsx(R.Upload,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:m,className:Zr,title:"Refresh workspace","aria-label":"Refresh workspace",children:t.jsx(R.RefreshCw,{className:`h-4 w-4 ${o?"animate-spin":""}`})}),d?t.jsx("button",{type:"button",onClick:d,disabled:!e,className:Zr,title:e?"Empty garbage":"Garbage controls are unavailable","aria-label":"Empty garbage",children:t.jsx(R.Trash2,{className:"h-4 w-4"})}):null]})]}),t.jsxs("div",{ref:b,className:"thread-graph-workspace-tree-scroll min-h-0 flex-1 overflow-y-auto py-2",onScroll:v=>{g.current=v.currentTarget.scrollTop},children:[t.jsx(xu,{liveNodes:k??[],onSelect:u,selectedNodeId:j}),t.jsx("div",{className:bl,children:"Workspace"}),t.jsx(ul,{depth:0,expandedPaths:a,loadingPaths:s,node:w,...i?{onCopyPath:i}:{},...l?{onDownload:l}:{},...h?{onPreview:h}:{},onSelect:u,onToggle:p,selectedNodeId:j}),w.children.length===0?t.jsx("p",{className:vl,children:"This workspace is empty. Agent tool runs execute inside the thread workspace, so files should appear here as the session works."}):null]})]})}function vu({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:ns(r,n),[e,i,n,r,s,l]),m=i??h??ns(r,n),u=c.useMemo(()=>Ah(m),[m]),p=c.useMemo(()=>{var I;return((I=m.children.find(V=>V.path==="live"))==null?void 0:I.children)??[]},[m]),f=Qo(m),[g,b]=c.useState(()=>(f==null?void 0:f.id)??null),[j,x]=c.useState(()=>new Set(["","artifacts","thread-events","live",...as((f==null?void 0:f.path)??"")])),[k,w]=c.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 639px)").matches?"viewer":null),[v,y]=c.useState(null),[N,S]=c.useState(!1),[T,M]=c.useState(()=>new Set),[A,J]=c.useState(!1),[W,re]=c.useState(!1),[O,P]=c.useState(!1),[Y,Z]=c.useState([]),[_,ie]=c.useState(null),[H,B]=c.useState(null),[F,E]=c.useState(null),[D,$]=c.useState(!1),L=c.useRef(null),C=c.useRef(null),U=c.useRef(0),G=c.useRef(null),le=!!l,ee=(g?u.get(g):null)??f??null,ce={threadId:r.thread.id,workspaceId:r.workspace.id??r.thread.workspaceId??null};c.useEffect(()=>{U.current=0,G.current=null,x(new Set(["","artifacts","thread-events","live",...gu(ce),...as((f==null?void 0:f.path)??"")]))},[ce.threadId,ce.workspaceId]);function q(){var V;const I=((V=C.current)==null?void 0:V.scrollTop)??U.current;U.current=I,G.current=I}function ve(){const I=G.current??U.current;if(!C.current)return;let se=0;const ge=()=>{const Ne=C.current;Ne&&(Ne.scrollTop=Math.min(I,Math.max(0,Ne.scrollHeight-Ne.clientHeight)),U.current=Ne.scrollTop,se+=1,se<8?window.requestAnimationFrame(ge):G.current=null)};window.requestAnimationFrame(ge)}c.useLayoutEffect(()=>{k!=="explorer"&&ve()},[k,m]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const I=window.matchMedia("(max-width: 639px)"),V=()=>$(I.matches);return V(),typeof I.addEventListener=="function"?(I.addEventListener("change",V),()=>I.removeEventListener("change",V)):(I.addListener(V),()=>I.removeListener(V))},[]);async function ke(I){if(!l)return;const V=I??(ee==null?void 0:ee.path)??null;S(!0),y(null);try{const se=ar(await l.listTree({...ce,path:""}));let ge=i?Qn(se,i):se;if(i){const Le=[...j].filter(de=>de).sort((de,Ge)=>de.split("/").length-Ge.split("/").length);for(const de of Le){const Ge=qn(i,de);if((Ge==null?void 0:Ge.kind)!=="directory"||!Ge.childrenLoaded)continue;const qe=ar(await l.listTree({...ce,path:de}));ge=Yn(ge,de,Qn(qe,Ge))}}d(ge);const Ne=Zo(ge);b(Le=>{var Ge;const de=V??(Le?(Ge=u.get(Le))==null?void 0:Ge.path:null);return de&&Zn(ge,de)?`workspace:${de}`:(Ne==null?void 0:Ne.id)??Le})}catch(se){y(se instanceof Error?se.message:"Failed to load workspace"),d(null)}finally{S(!1)}}async function je(I){if(!(!l||!i)){M(V=>{if(V.has(I))return V;const se=new Set(V);return se.add(I),se}),y(null);try{const V=ar(await l.listTree({...ce,path:I}));d(se=>se&&Yo(se,I,V.children,{truncated:V.truncated}))}catch(V){y(V instanceof Error?V.message:"Failed to load directory")}finally{M(V=>{if(!V.has(I))return V;const se=new Set(V);return se.delete(I),se})}}}async function ye(I){const V=Th(I,r.workspace.absPath);if(!V)return;const se=Eh(V);if(w(null),x(ge=>{const Ne=new Set(ge);Ne.add("");for(const Le of se)Ne.add(Le);return hs(ce,Ne),Ne}),!l){Zn(m,V)&&b(`workspace:${V}`);return}S(!0),y(null);try{let ge=i??ar(await l.listTree({...ce,path:""}));for(const Ne of se){const Le=qn(ge,Ne);if((Le==null?void 0:Le.kind)==="directory"&&Le.childrenLoaded)continue;const de=ar(await l.listTree({...ce,path:Ne}));ge=Yn(ge,Ne,de)}d(ge),b(`workspace:${V}`)}catch(ge){y(ge instanceof Error?ge.message:`Failed to open ${V}`)}finally{S(!1)}}c.useEffect(()=>{if(!(!l||!i))for(const I of u.values())I.path&&I.kind==="directory"&&j.has(I.path)&&I.hasChildren&&!I.childrenLoaded&&!T.has(I.path)&&je(I.path)},[i,j,u,l]),c.useEffect(()=>{d(null),M(new Set),ie(null),B(null),E(null),y(null),ke()},[le,r.thread.id,r.workspace.id,r.thread.workspaceId]),c.useEffect(()=>{o&&ye(o.path)},[o==null?void 0:o.requestId]),c.useEffect(()=>{l!=null&&l.subscribeWorkspaceChanged},[l,ce.threadId,ce.workspaceId]),c.useEffect(()=>{const I=l&&(ee==null?void 0:ee.kind)==="file"?ee.path:null;if(!I){ie(null),B(null),E(null);return}const V=I;let se=!1;async function ge(){var Ne;if(l){J(!0),y(null),ie(null),B(null),E(null);try{const Le=_r(V),de=(Ne=l.getRawFileUrl)==null?void 0:Ne.call(l,{...ce,path:V});if(de&&el.has(Le)){se||B(de);return}if(de&&tl.has(Le)){se||E(de);return}const Ge=await l.readFile({...ce,path:V,limit:Kr});se||ie(Ge)}catch(Le){se||y(Le instanceof Error?Le.message:"Failed to read file")}finally{se||J(!1)}}}return ge(),()=>{se=!0}},[l,ee==null?void 0:ee.id]);async function fe(){if(!(!l||!(_!=null&&_.truncated))){re(!0);try{const I=await l.readFile({...ce,path:_.path,offset:_.nextOffset,limit:Kr});ie(V=>V&&{...V,content:V.content+I.content,truncated:I.truncated,nextOffset:I.nextOffset,size:I.size})}finally{re(!1)}}}async function Te(I){if(!(l!=null&&l.writeFile))return;y(null),await l.writeFile({...ce,path:I.path,content:I.content}),await ke(I.path);const V=await l.readFile({...ce,path:I.path,limit:Kr});ie(V)}async function oe(I){if(!(!(l!=null&&l.uploadFile)||!I)){S(!0),y(null);try{const V=await l.uploadFile({...ce,path:I.name,file:I}),se=V.kind==="archive"?V.paths[0]??null:V.file.path;await ke(se)}catch(V){y(V instanceof Error?V.message:"Failed to upload file")}finally{S(!1)}}}async function Q(I){var se;const V=(se=I.target.files)==null?void 0:se[0];I.target.value="",V&&await oe(V)}function me(){if(!(l!=null&&l.uploadFile))return;const I=()=>{var V;return(V=L.current)==null?void 0:V.click()};if(l.pickUploadFile){l.pickUploadFile({...ce,defaultPick:I,upload:oe});return}I()}function we(I){var V;(V=l==null?void 0:l.downloadNode)==null||V.call(l,{...ce,path:I.path,kind:I.kind==="directory"?"directory":"file"})}function Ce(I){if(!I.path||typeof navigator>"u"||!navigator.clipboard)return;const V=r.workspace.absPath.replace(/\/+$/,""),se=I.path.startsWith("/")?I.path:V?`${V}/${I.path.replace(/^\/+/,"")}`:I.path;navigator.clipboard.writeText(se).catch(ge=>{y(ge instanceof Error?ge.message:"Failed to copy file path")})}function Me(I){I.kind==="file"&&(q(),b(I.id),w("explorer"))}async function Be(){if(l!=null&&l.emptyGarbage){if(y(null),!l.listGarbage){Z([]),P(!0);return}try{const I=await l.listGarbage(ce);Z(I.map(V=>`garbage/${V}`))}catch(I){Z([]),y(I instanceof Error?I.message:"Failed to list garbage files")}finally{P(!0)}}}async function Ae(){if(l!=null&&l.emptyGarbage){P(!1),y(null);try{await l.emptyGarbage(ce),await ke((ee==null?void 0:ee.path)??null)}catch(I){y(I instanceof Error?I.message:"Failed to empty garbage")}}}const He={onCopyPath:Ce,...l!=null&&l.downloadNode?{onDownload:we}:{},...l!=null&&l.emptyGarbage?{onEmptyGarbage:Be}:{},...l?{onRefresh:()=>void ke((ee==null?void 0:ee.path)??null)}:{},...l!=null&&l.uploadFile?{onUpload:me}:{}};function X(I){if(!I)return;const V=u.get(`workspace:${I}`),se=(V==null?void 0:V.kind)==="directory"&&V.hasChildren&&!V.childrenLoaded&&!T.has(I);x(ge=>{const Ne=new Set(ge);return Ne.has(I)?Ne.delete(I):Ne.add(I),hs(ce,Ne),Ne}),!j.has(I)&&se&&je(I)}const he=t.jsx(bu,{canEmptyGarbage:!!(l!=null&&l.emptyGarbage),canUpload:!!(l!=null&&l.uploadFile),onCollapse:()=>{q(),w("explorer")},expandedPaths:j,loadingPaths:T,loading:N,explorerScrollTopRef:U,explorerScrollerRef:C,...He,onPreview:Me,onSelect:I=>{b(I)},onToggle:X,selectedNodeId:(ee==null?void 0:ee.id)??null,tree:m,liveNodes:p}),Se=t.jsx(uu,{error:v,imageUrl:H,loadingMore:W,onOpenWorkspaceFile:I=>{ye(I)},onLoadMore:fe,...l!=null&&l.writeFile?{onSaveFile:Te}:{},onCollapse:()=>{q(),w("viewer")},pdfUrl:F,previewFile:_,previewLoading:A,plugins:a,...l!=null&&l.getRawFileUrl?{resolveWorkspaceFileUrl:I=>{var V;return((V=l.getRawFileUrl)==null?void 0:V.call(l,{...ce,path:I}))??null}}:{},selectedTarget:hu(ee),workspaceRootPath:r.workspace.absPath});return k==="explorer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:Se}):k==="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:[O?t.jsx(pu,{files:Y,onCancel:()=>P(!1),onConfirm:()=>void Ae()}):null,D?t.jsxs(Un,{direction:"vertical",className:"thread-graph-workspace-mobile-stack",children:[t.jsx(ir,{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(Vn,{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(ir,{defaultSize:58,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-viewer h-full min-h-0 overflow-hidden",children:Se})})]}):t.jsxs(Un,{direction:"horizontal",className:"thread-graph-workspace-resizable",children:[t.jsx(ir,{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(Vn,{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(ir,{defaultSize:67,minSize:30,children:t.jsx("div",{className:"thread-graph-workspace-viewer-pane h-full min-h-0 overflow-hidden",children:Se})})]}),t.jsx("input",{ref:L,type:"file","aria-label":"Workspace upload file input","data-testid":"workspace-upload-file-input",className:"hidden",onChange:I=>void Q(I)})]})}var Kr,ml,Yr,pl,fl,gl,Zr,xl,bl,vl,ku=We({"src/components/graph-workspace/GraphWorkspaceExplorer.tsx"(){ba(),mu(),fu(),Xo(),Kr=24e3,ml="remote-codex:graphchat:workspace:expanded:",Yr=.5,pl="thread-graph-explorer h-full min-h-0 overflow-hidden rounded-[12px]",fl="thread-graph-explorer-header flex h-[60px] shrink-0 items-center justify-between border-b px-4",gl="text-[18px] font-semibold text-slate-900 dark:text-slate-100",Zr="thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition disabled:cursor-not-allowed disabled:opacity-50",xl="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",bl="thread-graph-workspace-label px-3 pb-1 pt-2 text-[11px] font-semibold tracking-normal text-slate-500 dark:text-slate-400",vl="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 In({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 rr({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 wu({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 xr({value:e,title:r,icon:n,children:a}){return t.jsxs(Pr,{value:e,className:"thread-guide-section border-b border-[var(--theme-border)] last:border-b-0",children:[t.jsx(un,{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(wu,{children:n}),r]})}),t.jsx(Rr,{className:"space-y-3 pb-3",children:a})]})}function yu(){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(zr,{type:"multiple",defaultValue:["start","workspace","remote-codex"],className:"space-y-0",children:[t.jsxs(xr,{value:"start",title:"Getting Started",icon:t.jsx(R.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(rr,{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(xr,{value:"workspace",title:"Workspace Explorer",icon:t.jsx(R.FolderOpen,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(R.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(R.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(R.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(R.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(R.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(rr,{items:[t.jsxs(t.Fragment,{children:[t.jsx(In,{children:".xyz .extxyz .cif"})," use the 3D molecule plugin."]}),t.jsxs(t.Fragment,{children:[t.jsx(In,{children:".png .jpg .gif .svg .webp"})," use inline image preview."]}),t.jsxs(t.Fragment,{children:[t.jsx(In,{children:".py .json .ts .md .csv"})," use text/code preview."]}),"Large files load in chunks when the workspace adapter supports it."]})]})]}),t.jsxs(xr,{value:"viewer",title:"Viewer",icon:t.jsx(R.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(rr,{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(xr,{value:"usage",title:"Tool Usage & Chat",icon:t.jsx(R.BarChart2,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(R.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(rr,{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(R.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(rr,{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(xr,{value:"remote-codex",title:"Remote Codex Extras",icon:t.jsx(R.Code2,{className:"h-3 w-3"}),children:t.jsx(rr,{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 ju=We({"src/components/graph-workspace/GraphGuidePanel.tsx"(){Ar()}});function Nu(e){if(e==null)return"—";if(typeof e=="string")return e.length>2e3?`${e.slice(0,2e3)}
|
|
14
|
+
...(truncated)`:e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function ms({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:Nu(r)})]})}function Cu({event:e}){return t.jsxs(Pr,{value:e.id,className:"thread-tool-call mb-2 overflow-hidden rounded-lg border border-[var(--theme-border)] last:mb-0",children:[t.jsxs(un,{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(Rr,{className:"px-3 pb-3",children:t.jsxs("div",{className:"space-y-2 px-3 pb-3 pt-1",children:[t.jsx(ms,{label:"Input",value:e.preview}),t.jsx(ms,{label:"Output",value:e.detail})]})})]})}function Su({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(R.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(zr,{type:"single",collapsible:!0,value:s??"",onValueChange:i=>o(i||null),className:"space-y-0",children:n.slice(-50).map(i=>t.jsx(Cu,{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(R.RefreshCw,{className:"h-3 w-3"}),"Reload from workspace"]})]})}var Tu=We({"src/components/graph-workspace/GraphToolUsagePanel.tsx"(){Ar()}});function ps(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,m=s.x+d,u=s.y+h,p=o.x+l/2,f=o.y+i/2,g=(p-m)/(2*d)-(f-u)/(2*h),b=(p-m)/(2*d)+(f-u)/(2*h),j=1/(Math.abs(g)+Math.abs(b)),x=j*g,k=j*b,w=d*(x+k)+m,v=h*(-x+k)+u;return{x:w,y:v}}function fs(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?Wt.Left:o>=a+(e.measured.width??1)-1?Wt.Right:l<=s+1?Wt.Top:l>=n.y+(e.measured.height??1)-1?Wt.Bottom:Wt.Top}function kl(e,r){const n=ps(e,r),a=ps(r,e),s=fs(e,n),o=fs(r,a);return{sx:n.x,sy:n.y,tx:a.x,ty:a.y,sourcePos:s,targetPos:o}}function Eu(e,r=900,n=620){if(!e||!Array.isArray(e))return{nodes:[],edges:[]};const a=(d,h,m,u)=>{const p=new Map,f=d.length;d.forEach((g,b)=>{const j=g.id.split("").reduce((x,k)=>{const w=(x<<5)-x+k.charCodeAt(0);return w&w},0);p.set(g.id,{x:Math.abs(j)%m+b*100%m,y:Math.abs(j>>16)%u+b*150%u,vx:0,vy:0})});for(let g=0;g<200;g+=1){for(let b=0;b<f;b+=1)for(let j=b+1;j<f;j+=1){const x=d[b],k=d[j];if(!x||!k)continue;const w=p.get(x.id),v=p.get(k.id);if(!w||!v)continue;const y=w.x-v.x,N=w.y-v.y,S=Math.sqrt(y*y+N*N)||1,M=(200-S)*.5,A=y/S*M,J=N/S*M;w.vx+=A,w.vy+=J,v.vx-=A,v.vy-=J}h.forEach(b=>{const j=p.get(b.source),x=p.get(b.target);if(!j||!x)return;const k=x.x-j.x,w=x.y-j.y,v=Math.sqrt(k*k+w*w)||1,N=(v-120)*.3,S=k/v*N,T=w/v*N;j.vx+=S,j.vy+=T,x.vx-=S,x.vy-=T}),p.forEach(b=>{b.x+=b.vx*.1,b.y+=b.vy*.1,b.vx*=.9,b.vy*=.9,b.x=Math.max(80,Math.min(m-80,b.x)),b.y=Math.max(80,Math.min(u-80,b.y))})}return p},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(m=>{s.has(m)&&o.push({id:`${d.id}-${m}`,source:d.id,target:m,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:no.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 wa=We({"src/components/graph-chat/FloatingHelper.tsx"(){}});function Lu({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:m,targetPos:u}=kl(s,o),[p]=ao({sourceX:l,sourceY:i,sourcePosition:m||n,targetPosition:u||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:p}),t.jsx("circle",{cx:d||e,cy:h||r,fill:"var(--theme-panel)",r:3,stroke:"currentColor",strokeWidth:1.5})]})}var Iu=We({"src/components/graph-chat/FloatingConnectionLine.tsx"(){wa()}});function zu({id:e,source:r,target:n,markerEnd:a,style:s}){const o=Ba(r),l=Ba(n);if(!o||!l)return null;const{sx:i,sy:d,tx:h,ty:m,sourcePos:u,targetPos:p}=kl(o,l),[f]=ao({sourceX:i,sourceY:d,sourcePosition:u,targetPosition:p,targetX:h,targetY:m});return t.jsx("path",{id:e,className:"react-flow__edge-path",d:f,markerEnd:a,style:s})}var Pu=We({"src/components/graph-chat/FloatingEdge.tsx"(){wa()}});function Ru({nodes:e}){const[r,n,a]=Ud([]),[s,o,l]=Vd([]),i=c.useMemo(()=>Eu(e),[e]),d=c.useMemo(()=>({floating:zu}),[]),h=c.useMemo(()=>({styledNode:({data:u,isConnectable:p})=>t.jsxs("div",{className:"thread-graph-flow-node",children:[u.label,t.jsx(Da,{type:"target",position:Wt.Top,isConnectable:p,style:{opacity:0,pointerEvents:"none"}}),t.jsx(Da,{type:"source",position:Wt.Bottom,isConnectable:p,style:{opacity:0,pointerEvents:"none"}})]})}),[]);c.useEffect(()=>{n(i.nodes),o(i.edges)},[i.edges,i.nodes,o,n]);const m=c.useCallback(u=>o(p=>Xd({...u,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:no.Arrow}},p)),[o]);return t.jsx("div",{className:"thread-graph-flow h-full min-h-0",children:t.jsx(qd,{children:t.jsxs(Kd,{nodes:r,edges:s,onNodesChange:a,onEdgesChange:l,onConnect:m,fitView:!0,nodeTypes:h,edgeTypes:d,connectionLineComponent:Lu,children:[t.jsx(Yd,{}),t.jsx(Zd,{gap:16})]})})})}var Au=We({"src/components/graph-chat/GraphVisualization.tsx"(){Iu(),Pu(),wa()}});function _u(e){return{...yl,...e}}function gs(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 Mu(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 $u(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:rn(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:rn(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 rn(e){switch(e){case"toolCall":return"Tool call";case"agentToolCall":return"Agent tool";case"skillToolCall":return"Skill tool";case"commandExecution":return"Command";case"webSearch":return"Search";case"fileRead":return"File read";case"fileChange":return"File change";case"hook":return"Hook";default:return e.replace(/([A-Z])/g," $1").replace(/^./,r=>r.toUpperCase())}}function Du(e){switch(e.kind){case"userMessage":return"User";case"agentMessage":return"Agent";default:return rn(e.kind)}}function Bu(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}`,m=[l];i&&m.push(i),n.push({id:h,name:Du(d),description:Bu(d),out_node_id:m}),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 wl({detail:e,status:r,plugins:n,workspaceAdapter:a,metaContent:s,settingsContent:o,activeView:l="chat",features:i,focusPathRequest:d=null}){const h=c.useMemo(()=>_u(i),[i]),m=gs(h,i==null?void 0:i.defaultTab),[u,p]=c.useState(m),f=c.useMemo(()=>Nh(e),[e]),g=c.useMemo(()=>$u(e),[e]),b=c.useMemo(()=>{const y=new Map;for(const N of g)y.set(N.kind,(y.get(N.kind)??0)+1);return[...y.entries()].sort((N,S)=>S[1]-N[1])},[g]),j=n.getThreadPanels(),x=Math.max(...b.map(([,y])=>y),1),k=c.useMemo(()=>Gu(e,g),[e,g]),w=c.useMemo(()=>{const y=[];return h.workspace&&y.push({id:"workspace",label:"Workspace",icon:null}),h.toolUsage&&y.push({id:"tools",label:"Tool Usage",icon:R.BarChart2}),h.guide&&y.push({id:"guide",label:"Guide",icon:R.BookOpen}),y},[h.guide,h.toolUsage,h.workspace]),v=c.useMemo(()=>{const y=[];return h.threadGraph&&y.push({id:"graph",label:"Thread graph",icon:R.GitBranch}),h.extensions&&y.push({id:"extensions",label:"Remote Codex extensions",icon:R.Wrench}),y},[h.extensions,h.threadGraph]);return c.useEffect(()=>{(!u||!Mu(h,u))&&p(gs(h,i==null?void 0:i.defaultTab))},[u,i==null?void 0:i.defaultTab,h]),c.useEffect(()=>{d&&h.workspace&&p("workspace")},[h.workspace,d==null?void 0:d.requestId]),u?t.jsxs("div",{className:"thread-graph-right-panel flex h-full min-h-0 flex-col overflow-hidden",children:[t.jsxs("div",{className:"thread-graph-right-tabs flex shrink-0 items-center gap-1 overflow-hidden border-b px-3 py-2",children:[w.map(y=>{const N=y.icon;return t.jsxs("button",{type:"button",onClick:()=>p(y.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 ${u===y.id?"is-active":""}`,children:[N?t.jsx(N,{className:"h-3.5 w-3.5"}):null,y.label]},y.id)}),v.length?t.jsx("div",{className:"thread-graph-right-tab-secondary ml-auto flex min-w-0 shrink items-center gap-1 border-l pl-2","aria-label":"Remote Codex workspace extensions",children:v.map(y=>{const N=y.icon;return t.jsx("button",{type:"button",onClick:()=>p(y.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 ${u===y.id?"is-active":""}`,title:y.label,"aria-label":y.label,children:t.jsx(N,{className:"h-3.5 w-3.5"})},y.id)})}):null]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[u==="workspace"?t.jsx(vu,{activeView:l,detail:e,artifacts:f,plugins:n,status:r,focusPathRequest:d,workspaceAdapter:a??null}):null,u==="tools"?t.jsx(Su,{formatToolKind:rn,toolCounts:b,toolEvents:g,maxToolCount:x}):null,u==="graph"?t.jsx("div",{className:"thread-graph-visualization-panel h-full min-h-0 p-3",children:t.jsx(Ru,{nodes:k})}):null,u==="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(sr,{label:"Plugin Panels",children:j.length?t.jsx("div",{className:"flex flex-wrap gap-2",children:j.map(y=>t.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-1 text-xs text-[var(--theme-fg-soft)]",children:y.label},y.id))}):t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"No thread panels are enabled."})}),t.jsx(sr,{label:"Enabled Renderers",children:t.jsx("div",{className:"flex flex-wrap gap-2",children:n.plugins.filter(y=>y.enabled).map(y=>t.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-1 text-xs text-[var(--theme-fg-soft)]",children:y.name},y.id))})}),t.jsx(sr,{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(R.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(R.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(R.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(sr,{label:"Thread Meta",children:s}):null,o?t.jsx(sr,{label:"Settings",children:o}):null]})}):null,u==="guide"?t.jsx(yu,{}):null]})]}):null}var yl,jl,Fu=We({"src/components/ThreadGraphWorkspacePanel.tsx"(){ku(),rl(),ju(),Tu(),ba(),Au(),yl={workspace:!0,toolUsage:!0,guide:!0,threadGraph:!0,extensions:!0},jl=c.memo(wl)}}),Nl={};jh(Nl,{MemoizedThreadGraphWorkspacePanel:()=>jl,ThreadGraphWorkspacePanel:()=>wl});var Hu=We({"src/workspace-panel.ts"(){Fu()}});function ur(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))}ur(`.thread-ui-shell,
|
|
15
15
|
.thread-graph-dialog {
|
|
16
16
|
color-scheme: light;
|
|
17
17
|
--radius: 0.625rem;
|
|
@@ -672,7 +672,7 @@ import{l as P,R as bd,I as vd,C as kd,S as Qs,H as wd,T as yd,a as jd,b as Nd,c
|
|
|
672
672
|
border-color: #465164;
|
|
673
673
|
background: #2b313d;
|
|
674
674
|
}
|
|
675
|
-
`);
|
|
675
|
+
`);ur(`.thread-ui-shell .thread-detail-surface {
|
|
676
676
|
border-color: transparent;
|
|
677
677
|
background: var(--theme-surface);
|
|
678
678
|
box-shadow: none;
|
|
@@ -920,7 +920,7 @@ import{l as P,R as bd,I as vd,C as kd,S as Qs,H as wd,T as yd,a as jd,b as Nd,c
|
|
|
920
920
|
.thread-ui-shell .thread-graph-history-group-list {
|
|
921
921
|
border-color: var(--theme-border);
|
|
922
922
|
}
|
|
923
|
-
`);
|
|
923
|
+
`);ur(`.thread-ui-shell .thread-workspace-panel {
|
|
924
924
|
background: var(--theme-panel);
|
|
925
925
|
}
|
|
926
926
|
.thread-ui-shell .thread-workspace-card {
|
|
@@ -1398,7 +1398,7 @@ import{l as P,R as bd,I as vd,C as kd,S as Qs,H as wd,T as yd,a as jd,b as Nd,c
|
|
|
1398
1398
|
display: inline-flex;
|
|
1399
1399
|
transform: translateY(-50%);
|
|
1400
1400
|
}
|
|
1401
|
-
`);
|
|
1401
|
+
`);ur(`.thread-ui-shell .thread-graph-panel-expand-fab.left-3 {
|
|
1402
1402
|
left: 0.75rem;
|
|
1403
1403
|
}
|
|
1404
1404
|
.thread-ui-shell .thread-graph-panel-expand-fab.right-3 {
|
|
@@ -2989,7 +2989,7 @@ import{l as P,R as bd,I as vd,C as kd,S as Qs,H as wd,T as yd,a as jd,b as Nd,c
|
|
|
2989
2989
|
padding: 0.375rem 1rem;
|
|
2990
2990
|
}
|
|
2991
2991
|
}
|
|
2992
|
-
`);
|
|
2992
|
+
`);ur(`.thread-ui-shell .timeline-soft-text,
|
|
2993
2993
|
.thread-ui-shell .thread-message-prose :where(blockquote) {
|
|
2994
2994
|
color: var(--theme-fg-soft);
|
|
2995
2995
|
}
|
|
@@ -3801,7 +3801,7 @@ import{l as P,R as bd,I as vd,C as kd,S as Qs,H as wd,T as yd,a as jd,b as Nd,c
|
|
|
3801
3801
|
.thread-ui-shell[data-theme-effective=light] .thread-graph-plan-step-text {
|
|
3802
3802
|
color: rgb(15 23 42) !important;
|
|
3803
3803
|
}
|
|
3804
|
-
`);
|
|
3804
|
+
`);ur(`.thread-export-dialog-root {
|
|
3805
3805
|
--export-bg: rgb(248 250 252);
|
|
3806
3806
|
--export-panel: rgb(255 255 255);
|
|
3807
3807
|
--export-surface: rgb(241 245 249);
|
|
@@ -3930,13 +3930,13 @@ import{l as P,R as bd,I as vd,C as kd,S as Qs,H as wd,T as yd,a as jd,b as Nd,c
|
|
|
3930
3930
|
padding: 1.5rem;
|
|
3931
3931
|
}
|
|
3932
3932
|
}
|
|
3933
|
-
`);function
|
|
3934
|
-
`)}function
|
|
3935
|
-
`).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
|
|
3933
|
+
`);function Ou(e){return e.replace(/\u00a0/g," ")}function Wu(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 m=e.indexOf(h.placeholder,s);m!==-1&&m<i&&(i=m)}const d=e.slice(s,i);d&&(n.push({type:"text",key:`text-${o}`,text:d}),o+=1),s=i}return n}function Uu(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 Vu(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 Xu({files:e,kindForFile:r,usedPlaceholders:n,buildClientId:a}){return e.map(s=>{const o=r(s),l=om(s,o),i=Uu(o,lm(l),n);return n.add(i),{clientId:a(),kind:o,originalName:l,placeholder:i,file:s}})}function qu({prompt:e,attachments:r,files:n,selection:a,kindForFile:s,buildClientId:o}){const l=new Set(r.map(f=>f.placeholder)),i=Xu({files:n,kindForFile:s,usedPlaceholders:l,buildClientId:o}),d=a?{start:a.start,end:a.end}:{start:e.length,end:e.length},h=Vu(e,d,i.map(f=>f.placeholder)),m=`${e.slice(0,d.start)}${h}${e.slice(d.end)}`,u=h.endsWith(" ")?1:0,p=d.start+h.length-u;return{draft:{prompt:m,attachments:[...r,...i]},selection:{start:p,end:p},insertedAttachmentIds:i.map(f=>f.clientId)}}function Ku({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 Yu({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 xs(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 Ju({key:e,metaKey:r,ctrlKey:n,busy:a,disabled:s}){const o=e==="Enter"&&(r||n);return{preventDefault:o,submit:o&&!a&&!s}}function Qu({nextMode:e,previousOptimisticMode:r}){return{optimisticMode:e??null,rollbackMode:e?r:null,shouldRollbackMode:!!e,closeMenuOnSuccess:!0}}function Gr(e){return`${e.prompt}${e.attachments.map(r=>`${r.clientId}${r.kind}${r.placeholder}${r.originalName}`).join("")}`}function Fr(e){if(!e)return"Auto";switch(e){case"xhigh":return"xhigh";default:return e}}function em(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 tm(e){if(!e)return"";const r=e/1e3;return Number.isInteger(r)?String(r):String(Number(r.toFixed(1)))}function ea(e){return e.replace(/\r\n/g,`
|
|
3934
|
+
`)}function rm(e){const r=e.trim();return/^[A-Za-z0-9_-]+$/.test(r)?r:null}function nm(e){const n=ea(e).split(`
|
|
3935
|
+
`).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 am(e,r){return`[mcp_servers.${e}]
|
|
3936
3936
|
url = ${JSON.stringify(r.trim())}
|
|
3937
|
-
`}function
|
|
3937
|
+
`}function bs(e,r,n){var u,p;const a=ea(e),s=`${ea(n).trim()}
|
|
3938
3938
|
`,o=a.split(`
|
|
3939
|
-
`),l=`[mcp_servers.${r}]`,i=`[mcp_servers.${r}.`;let d=-1,h=o.length;for(let f=0;f<o.length;f+=1)if((((u=o[f])==null?void 0:u.trim())??"")===l){d=f;break}if(d>=0){for(let
|
|
3939
|
+
`),l=`[mcp_servers.${r}]`,i=`[mcp_servers.${r}.`;let d=-1,h=o.length;for(let f=0;f<o.length;f+=1)if((((u=o[f])==null?void 0:u.trim())??"")===l){d=f;break}if(d>=0){for(let b=d+1;b<o.length;b+=1){const j=((p=o[b])==null?void 0:p.trim())??"";if(j.startsWith("[")&&!(j===l||j.startsWith(i))){h=b;break}}const f=o.slice(0,d).join(`
|
|
3940
3940
|
`).trimEnd(),g=o.slice(h).join(`
|
|
3941
3941
|
`).trim();return[f,s.trimEnd(),g].filter(Boolean).join(`
|
|
3942
3942
|
|
|
@@ -3945,30 +3945,30 @@ url = ${JSON.stringify(r.trim())}
|
|
|
3945
3945
|
`).concat(`
|
|
3946
3946
|
`)}const m=a.trimEnd();return m?`${m}
|
|
3947
3947
|
|
|
3948
|
-
${s}`:s}function yl(e){return typeof e!="number"||Number.isNaN(e)?0:Math.max(0,Math.min(100,Math.round(e)))}function Ln(e){const r=e/1e3;return Number.isInteger(r)?`${r}k`:`${Number(r.toFixed(1))}k`}function nm(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,`${Ln(n)} used / ${Ln(a)}`,`${Ln(s)} left`,`${yl(r.remainingPercent)}% context left`].join(" · ")}function am(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 sm(e){return e.replace(/[\r\n[\]]+/g," ").replace(/\s+/g," ").trim()||"attachment"}function Jn(e){return e.type.startsWith("image/")?"photo":"file"}function Qn(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 gs(e,r){return Qn(e,r).length>0}function om(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function xs(e){const r=e.placeholder.match(/^\[(?:PHOTO|FILE)\s+(.+)\]$/);return r!=null&&r[1]?r[1]:om(e.originalName)}var rn=[{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 lm({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..."),m=e?r?"Setting...":"Set goal":!n&&a?"Connecting...":n&&a&&!s?"Sending...":"Send",u=n?e?"ui-action-info":"ui-action-primary":"ui-action-danger",p=l;return{promptPlaceholder:h,interruptLabel:s?"Send Ctrl-C":"Stop Current Turn",sendButtonLabel:m,sendButtonClassName:u,modelControlsDisabled:p,effortControlsDisabled:p||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 im({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 dm(){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 cm(){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 hm(){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 um(){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 mm(){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 ea(){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 pm(e){switch(e){case"bearerToken":return"Token";case"oAuth":return"OAuth";case"notLoggedIn":return"Login";case"unsupported":return"Public";default:return"Unknown"}}function fm(e){switch(e){case"repo":return"Repo";case"system":return"System";case"admin":return"Admin";case"user":default:return"User"}}function gm(e){var r;return((r=rn.find(n=>n.value===e))==null?void 0:r.label)??e}function xm(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 bm(e){switch(e){case"managed":return"Managed";case"modified":return"Modified";case"trusted":return"Trusted";case"untrusted":return"Review"}}function vm(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 km(e){return e.source==="user"?"global":e.source==="project"?"project":null}function jl(e){const r=km(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 wm(e){switch(e){case"active":return"Active";case"paused":return"Paused";case"budgetLimited":return"Budget";case"complete":return"Complete";default:return e}}function ym({contextUsage:e}){const r=(e==null?void 0:e.availability)??"unavailable",n=yl(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 Ht({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 jm(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 Nm(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 Cm(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?wm(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 Sm(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 Tm(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 Em(e){if(!e)return"";const r=document.createElement("div");return r.innerHTML=e,r.textContent??""}function Lm(e){return!!e.querySelector("[style], font")}function Wt(e){return e instanceof HTMLElement&&e.dataset.segmentType==="attachment"&&e.dataset.placeholder?e.dataset.placeholder:e.textContent??""}function Nl(e){let r="";for(const n of Array.from(e.childNodes))r+=Wt(n);return r.replace(/\u00a0/g," ")}function bs(e,r,n){var i;let a=null,s=n;if(r===e){const d=Array.from(e.childNodes);let h=0;for(let m=0;m<Math.min(n,d.length);m+=1){const u=d[m];u&&(h+=Wt(u).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 Nl(e).length;if(a=d,d instanceof HTMLElement&&d.dataset.segmentType==="attachment"){const h=document.createRange();h.selectNodeContents(d);const m=Wt(d).length;try{h.setEnd(r,n);const u=h.toString().length,p=((i=d.textContent)==null?void 0:i.length)??0;p===0?s=m:s=Math.round(Math.min(1,u/p)*m)}catch{s=m}}else{const h=document.createRange();h.selectNodeContents(d);try{h.setEnd(r,n),s=h.toString().length}catch{s=Wt(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,Wt(d).length);l+=Wt(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:bs(e,n.startContainer,n.startOffset),end:bs(e,n.endContainer,n.endOffset)}}function vs(e,r){let n=Math.max(0,r);const a=Array.from(e.childNodes);for(const[s,o]of a.entries()){const i=Wt(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 zm(e,r){const n=vs(e,r.start),a=vs(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}cn();Mt();function Rm({className:e,...r}){return t.jsx("div",{"data-slot":"input-group",role:"group",className:st("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 _m=Ir("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:st(_m({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 Am=Ir("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 St({className:e,type:r="button",variant:n="ghost",size:a="xs",...s}){return t.jsx(Er,{type:r,"data-size":a,variant:n,className:st(Am({size:a}),e),...s})}function $m({className:e,...r}){return t.jsx("span",{className:st("flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*=size-])]:size-4",e),...r})}function Dm({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 Bm(e){if(!e)return"reset time unavailable";const r=new Date(e);return Number.isNaN(r.getTime())?"reset time unavailable":`resets ${r.toLocaleString()}`}function Gm({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, ${Bm(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 Hm({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(Gm,{usage:i})]})}function Fm({activeView:e,layerClassName:r,formClassName:n,shellClassName:a,inputGroupClassName:s,error:o,followTail:l,photoInputRef:i,fileInputRef:d,onAppendAttachments:h,onToggleFollow:m,canJumpToPreviousTurn:u,onJumpToPreviousTurn:p,canJumpToNextTurn:f,onJumpToNextTurn:g,subscriptionUsage:x,onSubmit:j,formRef:b,promptSlot:k,pendingQueueSlot:y,toolbarSlot:v,goalSlot:w,shellPromptSlot:C}){return t.jsxs("div",{className:r,children:[t.jsx(Dm,{photoInputRef:i,fileInputRef:d,onAppendAttachments:h}),t.jsx(Hm,{activeView:e,followTail:l,onToggleFollow:m,canJumpToPreviousTurn:u,onJumpToPreviousTurn:p,canJumpToNextTurn:f,onJumpToNextTurn:g,subscriptionUsage:x}),y,t.jsxs("form",{ref:b,"data-testid":e==="chat"?"chat-composer":void 0,onSubmit:j,className:n,children:[t.jsxs("div",{className:`${a} flex w-full flex-col overflow-visible rounded-[16px] sm:rounded-[18px]`,children:[t.jsxs(Rm,{className:s,children:[k,v]}),w,C]}),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 Om({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(P.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(P.Loader2,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":"true"}):t.jsx(P.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(P.X,{className:"h-4 w-4","aria-hidden":"true"})}):null]})]},l.id)})})]})}function Wm({open:e,iconButtonClassName:r,menuClassName:n,menuItemClassName:a,onToggle:s,onPickPhoto:o,onPickFile:l}){return t.jsxs("div",{className:"relative",children:[t.jsx(St,{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(cm,{})}),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 Cl=[{mode:"read-only",label:"Read only"},{mode:"workspace-write",label:"Workspace write"},{mode:"danger-full-access",label:"Danger"}];function ks(e){var r;return((r=Cl.find(n=>n.mode===e))==null?void 0:r.label)??"Default"}function Um(e){switch(e){case"read-only":return"RO";case"workspace-write":return"WW";case"danger-full-access":return"Full";default:return"Sandbox"}}function Vm({openMenu:e,model:r,agentLabel:n,modelOptions:a,modelContextTitle:s,contextUsage:o,reasoningEffort:l,supportedEfforts:i,displayedCollaborationMode:d,sandboxMode:h,planModeAvailable:m,sandboxModeAvailable:u,settingsBusy:p,goalComposeMode:f,goalBusy:g,activeView:x,disabled:j,fastMode:b,sendButtonLabel:k,sendButtonClassName:y,modelControlsDisabled:v,effortControlsDisabled:w,effortControlTitle:C,inlineToggleClassName:N,menuItemClassName:E,planToggleActiveClassName:R,sendButtonBaseClassName:_,onSetOpenMenu:Y,onUpdateSettings:W}){var J;const[re,F]=c.useState(null),A=(((J=a.find(Z=>Z.model===r))==null?void 0:J.displayName)||r||"Select model").replace(/\s+\([^)]+\)\s*$/,"");return t.jsxs(t.Fragment,{children:[n?t.jsx(St,{type:"button",variant:"ghost",size:"xs",disabled:!0,"aria-label":`Agent: ${n}`,title:`${n} is fixed for this thread`,className:`${N} max-w-[7.5rem] cursor-default rounded-full px-2.5 text-stone-500 disabled:opacity-100 sm:max-w-[9rem]`,children:t.jsx("span",{className:"block min-w-0 truncate whitespace-nowrap",children:n})}):null,t.jsxs("div",{className:"relative min-w-0",children:[t.jsx(St,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="model","aria-label":`Model and effort: ${A}, ${Gr(l)}`,disabled:v||a.length===0,onClick:()=>{F(null),Y(Z=>Z==="model"?null:"model")},title:b?`Fast mode is on. Turn it off from the slash toolbox to edit model. ${s}`:s,className:`${N} relative min-w-0 max-w-[10rem] overflow-hidden rounded-full px-2.5 text-left text-stone-300 disabled:cursor-not-allowed disabled:text-stone-600 sm:max-w-[14rem]`,children:t.jsxs("span",{className:"relative z-[1] block min-w-0 truncate whitespace-nowrap",children:[A," · ",Gr(l)]})}),r?t.jsx(ym,{contextUsage:o}):null,e==="model"&&t.jsxs("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full right-0 mb-2 w-[13.5rem] rounded-xl border border-stone-700 bg-stone-900 p-1.5 shadow-2xl shadow-stone-950/40",children:[t.jsxs("button",{type:"button",onClick:()=>F("model"),className:`${E} flex w-full items-center justify-between rounded-lg px-3 py-2 text-left text-stone-300`,children:[t.jsx("span",{children:"Model"}),t.jsxs("span",{className:"flex min-w-0 items-center gap-1 text-stone-500",children:[t.jsx("span",{className:"max-w-[7rem] truncate",children:A}),t.jsx(P.ChevronRight,{className:"h-3.5 w-3.5 shrink-0"})]})]}),t.jsxs("button",{type:"button",disabled:w,title:C,onClick:()=>F("effort"),className:`${E} flex w-full items-center justify-between rounded-lg px-3 py-2 text-left text-stone-300 disabled:cursor-not-allowed disabled:text-stone-600`,children:[t.jsx("span",{children:"Effort"}),t.jsxs("span",{className:"flex items-center gap-1 text-stone-500",children:[Gr(l),t.jsx(P.ChevronRight,{className:"h-3.5 w-3.5"})]})]}),re==="model"?t.jsxs("div",{className:"mt-1 w-full overflow-hidden border-t border-stone-700 bg-stone-900 p-1.5 sm:absolute sm:bottom-0 sm:left-[calc(100%+0.5rem)] sm:mt-0 sm:w-[13rem] sm:rounded-xl sm:border sm:shadow-2xl sm:shadow-stone-950/40",children:[t.jsx("p",{className:"px-3 py-1.5 text-xs text-stone-500",children:"Model"}),t.jsx("div",{className:"max-h-72 overflow-auto",children:a.map(Z=>{const M=Z.model===r;return t.jsxs("button",{type:"button",onClick:()=>{const ie=l&&Z.supportedReasoningEfforts.some(O=>O.reasoningEffort===l)?l:Z.defaultReasoningEffort;W({model:Z.model,reasoningEffort:ie}),Y(()=>null)},className:`${E} flex w-full items-center justify-between rounded-lg px-3 py-2 text-left ${M?"ui-status-warning":"text-stone-300"}`,children:[t.jsx("span",{className:"truncate text-sm font-medium",children:Z.displayName||Z.model}),M?t.jsx(P.Check,{className:"h-3.5 w-3.5 shrink-0"}):null]},Z.id)})})]}):null,re==="effort"?t.jsxs("div",{className:"mt-1 w-full overflow-hidden border-t border-stone-700 bg-stone-900 p-1.5 sm:absolute sm:bottom-0 sm:left-[calc(100%+0.5rem)] sm:mt-0 sm:w-[11rem] sm:rounded-xl sm:border sm:shadow-2xl sm:shadow-stone-950/40",children:[t.jsx("p",{className:"px-3 py-1.5 text-xs text-stone-500",children:"Effort"}),i.map(Z=>{const M=Z.reasoningEffort===l;return t.jsxs("button",{type:"button",onClick:()=>{W({reasoningEffort:Z.reasoningEffort}),Y(()=>null)},className:`${E} flex w-full items-center justify-between rounded-lg px-3 py-2 text-left ${M?"ui-status-warning":"text-stone-300"}`,children:[t.jsx("span",{className:"text-sm font-medium",children:Gr(Z.reasoningEffort)}),M?t.jsx(P.Check,{className:"h-3.5 w-3.5"}):null]},Z.reasoningEffort)}),i.some(Z=>Z.reasoningEffort==="ultra")?t.jsx("p",{className:"px-3 pb-1 pt-2 text-xs leading-4 text-stone-500",children:"Higher effort can consume usage limits faster."}):null]}):null]})]}),u&&t.jsxs("div",{className:"relative",children:[t.jsx(St,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="sandbox","aria-label":`Sandbox: ${ks(h)}`,disabled:p,onClick:()=>Y(Z=>Z==="sandbox"?null:"sandbox"),title:`Sandbox: ${ks(h)}`,className:`${N} rounded-full px-2.5 text-stone-300 disabled:cursor-not-allowed disabled:text-stone-700`,children:Um(h)}),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:Cl.map(Z=>t.jsx("button",{type:"button",onClick:()=>W({sandboxMode:Z.mode}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${Z.mode===h?"ui-status-warning":`${E} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:Z.label})},Z.mode))})})]}),m&&t.jsx(St,{type:"button",variant:"ghost",size:"xs","aria-pressed":d==="plan",disabled:p,onClick:()=>W({collaborationMode:d==="plan"?"default":"plan"}),className:`${N} rounded-full px-2.5 ${d==="plan"?`${R} 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(St,{type:"submit",variant:"default",size:"icon-xs","aria-label":f?"Set goal":"Send Prompt",title:k,disabled:g||(x==="chat"?j:!1),className:`${_} h-9 w-9 rounded-full text-sm font-medium disabled:cursor-not-allowed sm:h-8 sm:w-8 ${y}`,children:t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-none stroke-current",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M8 13V3"}),t.jsx("path",{d:"m4 7 4-4 4 4"})]})})]})}function Xm({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(ea,{}),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(ea,{}),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(Ht,{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(Ht,{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(Ht,{label:"CTRL-D"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("esc"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Ht,{label:"ESC"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("tab"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Ht,{label:"TAB"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("up"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Ht,{label:"UP"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("down"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Ht,{label:"DOWN"})})]})})}function qm({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 Km({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 Ym({hooksPanelMode:e,hooksState:r,hostConfigFilesAvailable:n,hookTrustAvailable:a,hookConfigBusy:s,hookConfigError:o,hookConfigSuccess:l,editingHookTarget:i,hookScope:d,hookEventName:h,hookMatcher:m,hookCommand:u,hookTimeoutSec:p,hookStatusMessage:f,composerChipButtonClassName:g,onResetHookForm:x,onSetHooksPanelMode:j,onClearHookConfigStatus:b,onSetEditingHookTarget:k,onSetHookScope:y,onSetHookEventName:v,onSetHookMatcher:w,onSetHookCommand:C,onSetHookTimeoutSec:N,onSetHookStatusMessage:E,onSaveHook:R,onStartEditingHook:_,onTrustHook:Y,onUntrustHook:W}){var re,F,A,J,Z;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:((re=r.data)==null?void 0:re.projectHooksPath)??"<workspace hooks config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),x(),j("add"),b()},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"," ",vm((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:M=>y(M.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:M=>v(M.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:rn.map(M=>t.jsx("option",{value:M.value,children:M.label},M.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:m,onChange:M=>w(M.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:u,onChange:M=>C(M.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:p,onChange:M=>N(M.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:f,onChange:M=>E(M.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:()=>{j("list"),k(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"&&((F=r.data)!=null&&F.warnings.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.warnings.map(M=>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:M},M))}):null,e==="list"&&((A=r.data)!=null&&A.errors.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.errors.map(M=>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:M.message}),t.jsx("p",{className:"mt-1 break-all text-rose-100/60",children:M.path})]},`${M.path}:${M.message}`))}):null,e==="list"&&((J=r.data)!=null&&J.hooks.length)?t.jsx("div",{className:"space-y-2",children:r.data.hooks.map(M=>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:[gm(M.eventName),M.matcher?` · ${M.matcher}`:""]}),t.jsx("p",{className:"mt-0.5 truncate font-mono text-[11px] text-stone-400",children:M.command??M.handlerType}),M.statusMessage?t.jsx("p",{className:"mt-1 truncate text-[11px] text-stone-500",children:M.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:[jl(M)?t.jsx("button",{type:"button",onClick:ie=>{ie.stopPropagation(),_(M)},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&&M.trustStatus==="trusted"&&!M.isManaged?t.jsx("button",{type:"button",disabled:s,onClick:ie=>{ie.stopPropagation(),W(M)},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,(M.trustStatus==="untrusted"||M.trustStatus==="modified")&&!M.isManaged&&a?t.jsx("button",{type:"button",disabled:s||!M.currentHash,onClick:ie=>{ie.stopPropagation(),Y(M)},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:bm(M.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:xm(M.source)}),t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:M.enabled?"Enabled":"Disabled"}),t.jsxs("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:[M.timeoutSec,"s"]})]})]},M.key))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((Z=r.data)==null?void 0:Z.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 Zr(e){return e.localGoalId??`${e.createdAt}:${e.objective}`}function Zm(e,r){const n=e?[e,...r]:r,a=new Set;return n.filter(s=>{const o=Zr(s);return a.has(o)?!1:(a.add(o),!0)})}function Jm(e){if(e<60)return`${e}s`;const r=Math.floor(e/60);return r<60?`${r}m`:`${Math.floor(r/60)}h ${r%60}m`}function Qm(e){switch(e){case"budgetLimited":return"Budget limited";case"complete":return"Complete";case"terminated":return"Terminated";case"paused":return"Paused";default:return"Active"}}function ep({goalState:e,goalHistory:r,busy:n,onBack:a,onUpdateGoal:s}){const o=Zm(e.data,r),l=e.data?Zr(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=Zr(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:Qm(i.status)})]}),t.jsxs("p",{className:"mt-1.5 text-[11px] text-[var(--theme-fg-muted)]",children:[Jm(i.timeUsedSeconds)," · ",i.tokensUsed.toLocaleString()," tokens"]}),d&&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]},Zr(i))})})]})}function tp({mcpPanelMode:e,mcpState:r,mcpConfigEditing:n,mcpConfigPath:a,mcpConfigError:s,mcpConfigSuccess:o,mcpConfigBusy:l,mcpHttpName:i,mcpHttpUrl:d,mcpRawBlock:h,composerPanelButtonClassName:m,composerChipButtonClassName:u,onSetMcpPanelMode:p,onClearMcpConfigStatus:f,onSetMcpHttpName:g,onSetMcpHttpUrl:x,onSetMcpRawBlock:j,onPrepareRawMcpBlock:b,onSaveHttpMcp:k,onSaveRawMcpBlock:y}){var v,w;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"MCP config source"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:a??"<provider config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:C=>{C.stopPropagation(),p("add"),f()},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:C=>{C.stopPropagation(),p("http"),f()},className:`${m} 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:C=>{C.stopPropagation(),b()},className:`${m} 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:C=>g(C.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:C=>x(C.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:()=>p("add"),className:`${u} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void k(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write 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:C=>j(C.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:()=>p("add"),className:`${u} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void y(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write raw block"})]})]}):null,e==="list"&&((v=r.data)!=null&&v.servers.length)?t.jsx("div",{className:"space-y-2",children:r.data.servers.map(C=>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:C.name}),t.jsxs("p",{className:"mt-0.5 text-xs text-stone-400",children:[C.tools.length," tools · ",C.resourceCount," ","resources · ",C.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:pm(C.authStatus)})]}),C.tools.length>0?t.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-stone-500",children:C.tools.slice(0,4).map(N=>N.title??N.name).join(" · ")}):null]},C.name))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((w=r.data)==null?void 0:w.servers.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No MCP servers available right now."}):null]})}function rp({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,m;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:fm(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(ea,{}),"$",d.name]})]}),t.jsx("p",{className:"text-xs leading-5 text-stone-400",children:((m=d.interface)==null?void 0:m.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 np({open:e,slashPanelView:r,availableToolboxItems:n,busy:a,forkBusy:s,forkTurnOptionsState:o,skillsState:l,goalState:i,goalHistory:d,goalBusy:h,copiedSkillName:m,hooksPanelMode:u,hooksState:p,hostConfigFilesAvailable:f,hookTrustAvailable:g,hookConfigBusy:x,hookConfigError:j,hookConfigSuccess:b,editingHookTarget:k,hookScope:y,hookEventName:v,hookMatcher:w,hookCommand:C,hookTimeoutSec:N,hookStatusMessage:E,mcpPanelMode:R,mcpState:_,mcpConfigEditing:Y,mcpConfigPath:W,mcpConfigError:re,mcpConfigSuccess:F,mcpConfigBusy:A,mcpHttpName:J,mcpHttpUrl:Z,mcpRawBlock:M,iconButtonClassName:ie,menuClassName:O,menuItemClassName:G,panelButtonClassName:H,chipButtonClassName:T,onToggle:$,onToolboxItemClick:D,toolboxItemDisabled:L,toolboxItemClassName:S,toolboxItemStatus:U,onSetSlashPanelView:B,onViewGoals:le,onUpdateGoal:K,onOpenForkTurns:de,onForkLatest:ee,onForkTurn:ve,onCopySkillInvokeName:be,onResetHookForm:ye,onSetHooksPanelMode:we,onClearHookConfigStatus:fe,onSetEditingHookTarget:Te,onSetHookScope:oe,onSetHookEventName:Q,onSetHookMatcher:me,onSetHookCommand:ke,onSetHookTimeoutSec:Ne,onSetHookStatusMessage:Ae,onSaveHook:Ge,onStartEditingHook:Me,onTrustHook:Fe,onUntrustHook:X,onSetMcpPanelMode:he,onClearMcpConfigStatus:Ce,onSetMcpHttpName:I,onSetMcpHttpUrl:V,onSetMcpRawBlock:ae,onPrepareRawMcpBlock:ge,onSaveHttpMcp:je,onSaveRawMcpBlock:Ie}){return t.jsxs("div",{className:"relative",children:[t.jsx(St,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Open slash toolbox",title:"Open slash toolbox",onClick:$,className:`${ie} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx(hm,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${O} 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:ce=>{ce.stopPropagation()},onMouseDown:ce=>{ce.stopPropagation()},onPointerDown:ce=>{ce.stopPropagation()},onTouchStart:ce=>{ce.stopPropagation()},children:r==="root"?t.jsxs("div",{className:"p-2",children:[n.map((ce,He)=>ce.action==="goal"?t.jsxs("div",{className:`mt-1 flex min-h-11 overflow-hidden rounded-xl border border-[var(--theme-border)] ${He===0?"mt-0":""}`,title:ce.description??ce.label,children:[t.jsx("button",{type:"button",disabled:L(ce),onClick:()=>{B("goals"),le==null||le()},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:ce.command})}),t.jsx("button",{type:"button",disabled:L(ce),onClick:qe=>D(ce,qe),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"})]},`${ce.action}:${ce.command}`):t.jsx("button",{type:"button",disabled:L(ce),onClick:qe=>D(ce,qe),className:`${S(ce)} ${He===0?"mt-0":""}`,title:ce.description??ce.label,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:ce.command}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:U(ce)})]})},`${ce.action}:${ce.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(ep,{goalState:i,goalHistory:d,busy:h,onBack:()=>B("root"),onUpdateGoal:K}):r==="fork"?t.jsx(qm,{busy:a,forkBusy:s,composerMenuItemClassName:G,onForkLatest:ee,onSelectForkTurnPanel:()=>(B("forkTurns"),de())}):r==="forkTurns"?t.jsx(Km,{forkTurnOptionsState:o,forkBusy:s,composerPanelButtonClassName:H,onForkTurn:ve}):r==="skills"?t.jsx(rp,{skillsState:l,copiedSkillName:m,composerChipButtonClassName:T,onCopySkillInvokeName:be}):r==="hooks"?t.jsx(Ym,{hooksPanelMode:u,hooksState:p,hostConfigFilesAvailable:f,hookTrustAvailable:g,hookConfigBusy:x,hookConfigError:j,hookConfigSuccess:b,editingHookTarget:k,hookScope:y,hookEventName:v,hookMatcher:w,hookCommand:C,hookTimeoutSec:N,hookStatusMessage:E,composerChipButtonClassName:T,onResetHookForm:ye,onSetHooksPanelMode:we,onClearHookConfigStatus:fe,onSetEditingHookTarget:Te,onSetHookScope:oe,onSetHookEventName:Q,onSetHookMatcher:me,onSetHookCommand:ke,onSetHookTimeoutSec:Ne,onSetHookStatusMessage:Ae,onSaveHook:Ge,onStartEditingHook:Me,onTrustHook:Fe,onUntrustHook:X}):t.jsx(tp,{mcpPanelMode:R,mcpState:_,mcpConfigEditing:Y,mcpConfigPath:W,mcpConfigError:re,mcpConfigSuccess:F,mcpConfigBusy:A,mcpHttpName:J,mcpHttpUrl:Z,mcpRawBlock:M,composerPanelButtonClassName:H,composerChipButtonClassName:T,onSetMcpPanelMode:he,onClearMcpConfigStatus:Ce,onSetMcpHttpName:I,onSetMcpHttpUrl:V,onSetMcpRawBlock:ae,onPrepareRawMcpBlock:ge,onSaveHttpMcp:je,onSaveRawMcpBlock:Ie})})})]})}function ap({isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:s,toolbarClassName:o,iconButtonClassName:l,slashToolboxProps:i,attachmentMenuProps:d,settingsToolbarProps:h,shellToolsPanelProps:m,onToggleView:u,onDismissPromptFocus:p,onSetOpenMenu:f}){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(np,{...i}):null,!e&&d?t.jsx(Wm,{...d}):null,r&&t.jsx(St,{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:()=>u==null?void 0:u(),className:`${l} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:e?t.jsx(um,{}):t.jsx(dm,{})})]}),t.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center justify-end gap-1.5",children:[!e&&h?t.jsx(Vm,{...h}):null,e&&a?t.jsx($m,{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:()=>{p(),f(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(mm,{})}),s==="shellTools"&&m?t.jsx(Xm,{...m}):null]})]})]})}function sp(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`attachment-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function op(e){return[...e.filter(r=>Jn(r)==="photo"),...e.filter(r=>Jn(r)==="file")]}function lp({prompt:e,attachments:r,updateDraft:n,getSelection:a,selectionSnapshotRef:s,pendingSelectionRef:o,pendingInsertedAttachmentIdsRef:l,onInserted:i,buildClientId:d=sp}){const h=c.useCallback((p,f)=>{if(p.length===0)return!1;const g=Vu({prompt:e,attachments:r,files:p,selection:a()??s.current,kindForFile:f,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]),m=c.useCallback((p,f)=>!p||p.length===0?!1:h(Array.from(p),()=>f),[h]),u=c.useCallback(p=>h(op(p),Jn),[h]);return{appendAttachments:m,appendDroppedAttachments:u}}function ws(e){for(const r of e.values())URL.revokeObjectURL(r);e.clear()}function ip({attachments:e,isShellView:r}){const n=c.useRef(new Map),[a,s]=c.useState({});return c.useEffect(()=>{const o=n.current;if(r){ws(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()=>{ws(o)}},[]),a}var dp=180;function In(e,r){return{prompt:e??"",attachments:r??[]}}function cp({isShellView:e,draftPrompt:r,draftAttachments:n,onDraftChange:a}){const[s,o]=c.useState({prompt:"",attachments:[]}),[l,i]=c.useState(()=>In(r,n)),d=c.useRef(null),h=c.useRef(l),m=c.useRef(Br(l)),u=!e&&r!==void 0&&n!==void 0&&typeof a=="function",p=u?Br(In(r,n)):"",f=c.useRef(p);c.useLayoutEffect(()=>{if(!u){f.current="";return}const y=In(r,n),v=Br(y);v!==f.current&&(f.current=v,m.current=v,h.current=y,d.current!==null&&(window.clearTimeout(d.current),d.current=null),i(y))},[n,r,u]);const g=c.useCallback(y=>{if(!u||!a)return;const v=Br(y);v!==m.current&&(m.current=v,a(()=>({prompt:y.prompt,attachments:y.attachments})))},[u,a]);c.useEffect(()=>()=>{g(h.current),d.current!==null&&window.clearTimeout(d.current)},[g]);const x=c.useCallback((y,v)=>{if(u){if(d.current!==null&&(window.clearTimeout(d.current),d.current=null),v==="immediate"){g(y);return}d.current=window.setTimeout(()=>{d.current=null,g(h.current)},dp)}},[u,g]),j=c.useCallback((y=h.current)=>{x(y,"immediate")},[x]),b=c.useCallback((y,v="immediate")=>{if(u){const w=y(h.current);h.current=w,i(w),x(w,v);return}o(w=>y(w))},[u,x]),k=u?l:s;return{prompt:k.prompt,attachments:k.attachments,isDraftControlled:u,updateDraft:b,flushControlledDraftToHost:j}}function hp({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 up({prompt:e,goalTokenBudgetSource:r,promptRef:n,onOpenGoal:a,onPrepareGoalSubmit:s,onUpdateGoal:o,updateDraft:l,closeMenu:i,resetSlashPanel:d}){const[h,m]=c.useState(!1),[u,p]=c.useState(""),[f,g]=c.useState(!1),[x,j]=c.useState(null),b=c.useCallback(async()=>{const v=e.trim();if(!v)return j("Goal objective cannot be empty."),!1;const w=u.trim(),C=Ju(w);if(w.length>0&&(C===null||!Number.isInteger(C)||C<=0))return j("Token budget must be a positive number in thousands."),!1;if(!o)return j("/goal is unavailable in this view."),!1;g(!0),j(null);try{return s&&await s({objective:v,tokenBudget:C})===!1?!1:(await o({objective:v,status:"active",tokenBudget:C}),p(""),m(!1),l(()=>({prompt:"",attachments:[]})),!0)}catch(N){return j(N instanceof Error?N.message:"Unable to set goal."),!1}finally{g(!1)}},[u,s,o,e,l]),k=c.useCallback(()=>{i(),d(),m(!0),p(Qu(r==null?void 0:r.tokenBudget)),j(null),a==null||a(),requestAnimationFrame(()=>{var v;(v=n.current)==null||v.focus()})},[i,r==null?void 0:r.tokenBudget,a,n,d]),y=c.useCallback(()=>{m(!1),j(null)},[]);return{goalComposeMode:h,goalTokenBudget:u,goalBusy:f,goalLocalError:x,setGoalTokenBudget:p,submitGoal:b,enterGoalComposeMode:k,exitGoalComposeMode:y}}var zn=`node -e "process.stdin.resume(); process.stdin.on('end', () => console.error('hook ran'))"`;function mp(e){const r=new Map;for(const n of e??[])r.set(n.eventName,n.command);return r}function pp({slashPanelView:e,hookCommandTemplates:r,onCreateHook:n,onUpdateHook:a,onTrustHook:s,onUntrustHook:o}){const[l,i]=c.useState("list"),[d,h]=c.useState("project"),[m,u]=c.useState("preToolUse"),[p,f]=c.useState("Bash"),[g,x]=c.useState(zn),[j,b]=c.useState("30"),[k,y]=c.useState("Running hook"),[v,w]=c.useState(null),[C,N]=c.useState(!1),[E,R]=c.useState(null),[_,Y]=c.useState(null),W=c.useMemo(()=>mp(r),[r]),re=c.useCallback(G=>W.get(G)??W.get("preToolUse")??zn,[W]),F=c.useMemo(()=>new Set([zn,...W.values()]),[W]),A=c.useCallback(()=>{R(null),Y(null)},[]);c.useEffect(()=>{e!=="hooks"&&(i("list"),A())},[A,e]),c.useEffect(()=>{const G=rn.find(H=>H.value===m);f(H=>{const T=H.trim(),$=new Set(rn.map(D=>D.matcherHint).filter(Boolean));return T&&!$.has(T)?H:(G==null?void 0:G.matcherHint)??""}),x(H=>F.has(H.trim())?re(m):H)},[re,F,m]);const J=c.useCallback(()=>{w(null),h("project"),u("preToolUse"),f("Bash"),x(re("preToolUse")),b("30"),y("Running hook")},[re]),Z=c.useCallback(G=>{const H=jl(G);if(!H){R("Only command hooks in global or project hooks.json can be edited here.");return}w(H),h(H.scope),u(H.eventName),f(H.matcher??""),x(H.command),b(H.timeoutSec?String(H.timeoutSec):""),y(H.statusMessage??""),R(null),Y(null),i("edit")},[]),M=c.useCallback(async()=>{if(l==="edit"&&!a){R("Hook editing is unavailable in this view.");return}if(l!=="edit"&&!n){R("Hook editing is unavailable in this view.");return}if(l==="edit"&&!v){R("Select a hook to edit first.");return}const G=g.trim();if(!G){R("Hook command cannot be empty.");return}const H=j.trim(),T=H?Number(H):null;if(H&&(T===null||!Number.isInteger(T)||T<=0)){R("Timeout must be a positive number of seconds.");return}N(!0),R(null),Y(null);try{const $={scope:d,eventName:m,matcher:p.trim()||null,command:G,timeoutSec:T,statusMessage:k.trim()||null};l==="edit"?await(a==null?void 0:a({...$,target:v})):await(n==null?void 0:n($)),Y(`${d==="project"?"Project":"Global"} hook ${l==="edit"?"updated":"written"} in hooks.json and trusted.`),i("list"),w(null)}catch($){R($ instanceof Error?$.message:"Unable to write hooks.json.")}finally{N(!1)}},[v,g,m,p,d,k,j,l,n,a]),ie=c.useCallback(async G=>{if(!s||!G.currentHash){R("Hook trust is unavailable in this view.");return}N(!0),R(null),Y(null);try{await s({key:G.key,currentHash:G.currentHash}),Y("Hook trusted.")}catch(H){R(H instanceof Error?H.message:"Unable to trust hook.")}finally{N(!1)}},[s]),O=c.useCallback(async G=>{if(!o){R("Hook trust is unavailable in this view.");return}N(!0),R(null),Y(null);try{await o({key:G.key}),Y("Hook untrusted.")}catch(H){R(H instanceof Error?H.message:"Unable to untrust hook.")}finally{N(!1)}},[o]);return{hooksPanelMode:l,hookScope:d,hookEventName:m,hookMatcher:p,hookCommand:g,hookTimeoutSec:j,hookStatusMessage:k,editingHookTarget:v,hookConfigBusy:C,hookConfigError:E,hookConfigSuccess:_,setHooksPanelMode:i,setEditingHookTarget:w,setHookScope:h,setHookEventName:u,setHookMatcher:f,setHookCommand:x,setHookTimeoutSec:b,setHookStatusMessage:y,clearHookConfigStatus:A,resetHookForm:J,startEditingHook:Z,saveHook:M,trustHook:ie,untrustHook:O}}var fp=`[mcp_servers.example_stdio]
|
|
3948
|
+
${s}`:s}function Cl(e){return typeof e!="number"||Number.isNaN(e)?0:Math.max(0,Math.min(100,Math.round(e)))}function zn(e){const r=e/1e3;return Number.isInteger(r)?`${r}k`:`${Number(r.toFixed(1))}k`}function sm(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,`${zn(n)} used / ${zn(a)}`,`${zn(s)} left`,`${Cl(r.remainingPercent)}% context left`].join(" · ")}function om(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 lm(e){return e.replace(/[\r\n[\]]+/g," ").replace(/\s+/g," ").trim()||"attachment"}function ta(e){return e.type.startsWith("image/")?"photo":"file"}function ra(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 vs(e,r){return ra(e,r).length>0}function im(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function ks(e){const r=e.placeholder.match(/^\[(?:PHOTO|FILE)\s+(.+)\]$/);return r!=null&&r[1]?r[1]:im(e.originalName)}var nn=[{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 dm({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..."),m=e?r?"Setting...":"Set goal":!n&&a?"Connecting...":n&&a&&!s?"Sending...":"Send",u=n?e?"ui-action-info":"ui-action-primary":"ui-action-danger",p=l;return{promptPlaceholder:h,interruptLabel:s?"Send Ctrl-C":"Stop Current Turn",sendButtonLabel:m,sendButtonClassName:u,modelControlsDisabled:p,effortControlsDisabled:p||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 cm({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 hm(){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 um(){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 mm(){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 pm(){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 fm(){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 na(){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 gm(e){switch(e){case"bearerToken":return"Token";case"oAuth":return"OAuth";case"notLoggedIn":return"Login";case"unsupported":return"Public";default:return"Unknown"}}function xm(e){switch(e){case"repo":return"Repo";case"system":return"System";case"admin":return"Admin";case"user":default:return"User"}}function bm(e){var r;return((r=nn.find(n=>n.value===e))==null?void 0:r.label)??e}function vm(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 km(e){switch(e){case"managed":return"Managed";case"modified":return"Modified";case"trusted":return"Trusted";case"untrusted":return"Review"}}function wm(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 ym(e){return e.source==="user"?"global":e.source==="project"?"project":null}function Sl(e){const r=ym(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 jm(e){switch(e){case"active":return"Active";case"paused":return"Paused";case"budgetLimited":return"Budget";case"complete":return"Complete";default:return e}}function Nm({contextUsage:e}){const r=(e==null?void 0:e.availability)??"unavailable",n=Cl(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 Ht({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 Cm(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 Sm(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 Tm(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?jm(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 Em(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 Lm(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 Im(e){if(!e)return"";const r=document.createElement("div");return r.innerHTML=e,r.textContent??""}function zm(e){return!!e.querySelector("[style], font")}function Ut(e){return e instanceof HTMLElement&&e.dataset.segmentType==="attachment"&&e.dataset.placeholder?e.dataset.placeholder:e.textContent??""}function Tl(e){let r="";for(const n of Array.from(e.childNodes))r+=Ut(n);return r.replace(/\u00a0/g," ")}function ws(e,r,n){var i;let a=null,s=n;if(r===e){const d=Array.from(e.childNodes);let h=0;for(let m=0;m<Math.min(n,d.length);m+=1){const u=d[m];u&&(h+=Ut(u).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 Tl(e).length;if(a=d,d instanceof HTMLElement&&d.dataset.segmentType==="attachment"){const h=document.createRange();h.selectNodeContents(d);const m=Ut(d).length;try{h.setEnd(r,n);const u=h.toString().length,p=((i=d.textContent)==null?void 0:i.length)??0;p===0?s=m:s=Math.round(Math.min(1,u/p)*m)}catch{s=m}}else{const h=document.createRange();h.selectNodeContents(d);try{h.setEnd(r,n),s=h.toString().length}catch{s=Ut(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,Ut(d).length);l+=Ut(d).length}return l}function Pm(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:ws(e,n.startContainer,n.startOffset),end:ws(e,n.endContainer,n.endOffset)}}function ys(e,r){let n=Math.max(0,r);const a=Array.from(e.childNodes);for(const[s,o]of a.entries()){const i=Ut(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 Rm(e,r){const n=ys(e,r.start),a=ys(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 Am(e,r){if(r.length===0)return!1;const n=r.at(-1);if(!n)return!1;const a=Array.from(e.childNodes).find(i=>i instanceof HTMLElement&&i.dataset.segmentType==="attachment"&&i.dataset.clientId===n);if(!(a instanceof HTMLElement))return!1;const 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}hn();Mt();function _m({className:e,...r}){return t.jsx("div",{"data-slot":"input-group",role:"group",className:ot("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 Mm=Ir("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 $m({className:e,align:r="inline-start",...n}){return t.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":r,className:ot(Mm({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 Dm=Ir("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 St({className:e,type:r="button",variant:n="ghost",size:a="xs",...s}){return t.jsx(Er,{type:r,"data-size":a,variant:n,className:ot(Dm({size:a}),e),...s})}function Bm({className:e,...r}){return t.jsx("span",{className:ot("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 Fm(e){if(!e)return"reset time unavailable";const r=new Date(e);return Number.isNaN(r.getTime())?"reset time unavailable":`resets ${r.toLocaleString()}`}function Hm({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, ${Fm(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 Om({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(Hm,{usage:i})]})}function Wm({activeView:e,layerClassName:r,formClassName:n,shellClassName:a,inputGroupClassName:s,error:o,followTail:l,photoInputRef:i,fileInputRef:d,onAppendAttachments:h,onToggleFollow:m,canJumpToPreviousTurn:u,onJumpToPreviousTurn:p,canJumpToNextTurn:f,onJumpToNextTurn:g,subscriptionUsage:b,onSubmit:j,formRef:x,promptSlot:k,pendingQueueSlot:w,toolbarSlot:v,goalSlot:y,shellPromptSlot:N}){return t.jsxs("div",{className:r,children:[t.jsx(Gm,{photoInputRef:i,fileInputRef:d,onAppendAttachments:h}),t.jsx(Om,{activeView:e,followTail:l,onToggleFollow:m,canJumpToPreviousTurn:u,onJumpToPreviousTurn:p,canJumpToNextTurn:f,onJumpToNextTurn:g,subscriptionUsage:b}),w,t.jsxs("form",{ref:x,"data-testid":e==="chat"?"chat-composer":void 0,onSubmit:j,className:n,children:[t.jsxs("div",{className:`${a} flex w-full flex-col overflow-visible rounded-[16px] sm:rounded-[18px]`,children:[t.jsxs(_m,{className:s,children:[k,v]}),y,N]}),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 Um({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(R.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(R.Loader2,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":"true"}):t.jsx(R.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(R.X,{className:"h-4 w-4","aria-hidden":"true"})}):null]})]},l.id)})})]})}function Vm({open:e,iconButtonClassName:r,menuClassName:n,menuItemClassName:a,onToggle:s,onPickPhoto:o,onPickFile:l}){return t.jsxs("div",{className:"relative",children:[t.jsx(St,{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(um,{})}),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 El=[{mode:"read-only",label:"Read only"},{mode:"workspace-write",label:"Workspace write"},{mode:"danger-full-access",label:"Danger"}];function js(e){var r;return((r=El.find(n=>n.mode===e))==null?void 0:r.label)??"Default"}function Xm(e){switch(e){case"read-only":return"RO";case"workspace-write":return"WW";case"danger-full-access":return"Full";default:return"Sandbox"}}function qm({openMenu:e,model:r,agentLabel:n,modelOptions:a,modelContextTitle:s,contextUsage:o,reasoningEffort:l,supportedEfforts:i,displayedCollaborationMode:d,sandboxMode:h,planModeAvailable:m,sandboxModeAvailable:u,settingsBusy:p,goalComposeMode:f,goalBusy:g,activeView:b,disabled:j,fastMode:x,sendButtonLabel:k,sendButtonClassName:w,modelControlsDisabled:v,effortControlsDisabled:y,effortControlTitle:N,inlineToggleClassName:S,menuItemClassName:T,planToggleActiveClassName:M,sendButtonBaseClassName:A,onSetOpenMenu:J,onUpdateSettings:W}){var Y;const[re,O]=c.useState(null),P=(((Y=a.find(Z=>Z.model===r))==null?void 0:Y.displayName)||r||"Select model").replace(/\s+\([^)]+\)\s*$/,"");return t.jsxs(t.Fragment,{children:[n?t.jsx(St,{type:"button",variant:"ghost",size:"xs",disabled:!0,"aria-label":`Agent: ${n}`,title:`${n} is fixed for this thread`,className:`${S} max-w-[7.5rem] cursor-default rounded-full px-2.5 text-stone-500 disabled:opacity-100 sm:max-w-[9rem]`,children:t.jsx("span",{className:"block min-w-0 truncate whitespace-nowrap",children:n})}):null,t.jsxs("div",{className:"relative min-w-0",children:[t.jsx(St,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="model","aria-label":`Model and effort: ${P}, ${Fr(l)}`,disabled:v||a.length===0,onClick:()=>{O(null),J(Z=>Z==="model"?null:"model")},title:x?`Fast mode is on. Turn it off from the slash toolbox to edit model. ${s}`:s,className:`${S} relative min-w-0 max-w-[10rem] overflow-hidden rounded-full px-2.5 text-left text-stone-300 disabled:cursor-not-allowed disabled:text-stone-600 sm:max-w-[14rem]`,children:t.jsxs("span",{className:"relative z-[1] block min-w-0 truncate whitespace-nowrap",children:[P," · ",Fr(l)]})}),r?t.jsx(Nm,{contextUsage:o}):null,e==="model"&&t.jsxs("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full right-0 mb-2 w-[13.5rem] rounded-xl border border-stone-700 bg-stone-900 p-1.5 shadow-2xl shadow-stone-950/40",children:[t.jsxs("button",{type:"button",onClick:()=>O("model"),className:`${T} flex w-full items-center justify-between rounded-lg px-3 py-2 text-left text-stone-300`,children:[t.jsx("span",{children:"Model"}),t.jsxs("span",{className:"flex min-w-0 items-center gap-1 text-stone-500",children:[t.jsx("span",{className:"max-w-[7rem] truncate",children:P}),t.jsx(R.ChevronRight,{className:"h-3.5 w-3.5 shrink-0"})]})]}),t.jsxs("button",{type:"button",disabled:y,title:N,onClick:()=>O("effort"),className:`${T} flex w-full items-center justify-between rounded-lg px-3 py-2 text-left text-stone-300 disabled:cursor-not-allowed disabled:text-stone-600`,children:[t.jsx("span",{children:"Effort"}),t.jsxs("span",{className:"flex items-center gap-1 text-stone-500",children:[Fr(l),t.jsx(R.ChevronRight,{className:"h-3.5 w-3.5"})]})]}),re==="model"?t.jsxs("div",{className:"mt-1 w-full overflow-hidden border-t border-stone-700 bg-stone-900 p-1.5 sm:absolute sm:bottom-0 sm:left-[calc(100%+0.5rem)] sm:mt-0 sm:w-[13rem] sm:rounded-xl sm:border sm:shadow-2xl sm:shadow-stone-950/40",children:[t.jsx("p",{className:"px-3 py-1.5 text-xs text-stone-500",children:"Model"}),t.jsx("div",{className:"max-h-72 overflow-auto",children:a.map(Z=>{const _=Z.model===r;return t.jsxs("button",{type:"button",onClick:()=>{const ie=l&&Z.supportedReasoningEfforts.some(H=>H.reasoningEffort===l)?l:Z.defaultReasoningEffort;W({model:Z.model,reasoningEffort:ie}),J(()=>null)},className:`${T} flex w-full items-center justify-between rounded-lg px-3 py-2 text-left ${_?"ui-status-warning":"text-stone-300"}`,children:[t.jsx("span",{className:"truncate text-sm font-medium",children:Z.displayName||Z.model}),_?t.jsx(R.Check,{className:"h-3.5 w-3.5 shrink-0"}):null]},Z.id)})})]}):null,re==="effort"?t.jsxs("div",{className:"mt-1 w-full overflow-hidden border-t border-stone-700 bg-stone-900 p-1.5 sm:absolute sm:bottom-0 sm:left-[calc(100%+0.5rem)] sm:mt-0 sm:w-[11rem] sm:rounded-xl sm:border sm:shadow-2xl sm:shadow-stone-950/40",children:[t.jsx("p",{className:"px-3 py-1.5 text-xs text-stone-500",children:"Effort"}),i.map(Z=>{const _=Z.reasoningEffort===l;return t.jsxs("button",{type:"button",onClick:()=>{W({reasoningEffort:Z.reasoningEffort}),J(()=>null)},className:`${T} flex w-full items-center justify-between rounded-lg px-3 py-2 text-left ${_?"ui-status-warning":"text-stone-300"}`,children:[t.jsx("span",{className:"text-sm font-medium",children:Fr(Z.reasoningEffort)}),_?t.jsx(R.Check,{className:"h-3.5 w-3.5"}):null]},Z.reasoningEffort)}),i.some(Z=>Z.reasoningEffort==="ultra")?t.jsx("p",{className:"px-3 pb-1 pt-2 text-xs leading-4 text-stone-500",children:"Higher effort can consume usage limits faster."}):null]}):null]})]}),u&&t.jsxs("div",{className:"relative",children:[t.jsx(St,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="sandbox","aria-label":`Sandbox: ${js(h)}`,disabled:p,onClick:()=>J(Z=>Z==="sandbox"?null:"sandbox"),title:`Sandbox: ${js(h)}`,className:`${S} rounded-full px-2.5 text-stone-300 disabled:cursor-not-allowed disabled:text-stone-700`,children:Xm(h)}),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:El.map(Z=>t.jsx("button",{type:"button",onClick:()=>W({sandboxMode:Z.mode}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${Z.mode===h?"ui-status-warning":`${T} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:Z.label})},Z.mode))})})]}),m&&t.jsx(St,{type:"button",variant:"ghost",size:"xs","aria-pressed":d==="plan",disabled:p,onClick:()=>W({collaborationMode:d==="plan"?"default":"plan"}),className:`${S} rounded-full px-2.5 ${d==="plan"?`${M} 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(St,{type:"submit",variant:"default",size:"icon-xs","aria-label":f?"Set goal":"Send Prompt",title:k,disabled:g||(b==="chat"?j:!1),className:`${A} h-9 w-9 rounded-full text-sm font-medium disabled:cursor-not-allowed sm:h-8 sm:w-8 ${w}`,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 Km({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(na,{}),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(na,{}),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(Ht,{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(Ht,{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(Ht,{label:"CTRL-D"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("esc"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Ht,{label:"ESC"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("tab"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Ht,{label:"TAB"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("up"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Ht,{label:"UP"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("down"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Ht,{label:"DOWN"})})]})})}function Ym({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 Zm({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 Jm({hooksPanelMode:e,hooksState:r,hostConfigFilesAvailable:n,hookTrustAvailable:a,hookConfigBusy:s,hookConfigError:o,hookConfigSuccess:l,editingHookTarget:i,hookScope:d,hookEventName:h,hookMatcher:m,hookCommand:u,hookTimeoutSec:p,hookStatusMessage:f,composerChipButtonClassName:g,onResetHookForm:b,onSetHooksPanelMode:j,onClearHookConfigStatus:x,onSetEditingHookTarget:k,onSetHookScope:w,onSetHookEventName:v,onSetHookMatcher:y,onSetHookCommand:N,onSetHookTimeoutSec:S,onSetHookStatusMessage:T,onSaveHook:M,onStartEditingHook:A,onTrustHook:J,onUntrustHook:W}){var re,O,P,Y,Z;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:((re=r.data)==null?void 0:re.projectHooksPath)??"<workspace hooks config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:_=>{_.stopPropagation(),b(),j("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"," ",wm((i==null?void 0:i.eventName)??h)," ","in ",(i==null?void 0:i.scope)==="global"?"global":"project"," ","hooks.json"]}):null,t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("label",{className:"block text-xs text-stone-400",children:["Scope",t.jsxs("select",{"aria-label":"Hook scope",value:d,onChange:_=>w(_.target.value),disabled:e==="edit",className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-2.5 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50",children:[t.jsx("option",{value:"project",children:"Project"}),t.jsx("option",{value:"global",children:"Global"})]})]}),t.jsxs("label",{className:"block text-xs text-stone-400",children:["Event",t.jsx("select",{"aria-label":"Hook event",value:h,onChange:_=>v(_.target.value),className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-2.5 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50",children:nn.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:m,onChange:_=>y(_.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:u,onChange:_=>N(_.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:p,onChange:_=>S(_.target.value),inputMode:"numeric",className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50"})]}),t.jsxs("label",{className:"block text-xs text-stone-400",children:["Status message",t.jsx("input",{"aria-label":"Hook status message",value:f,onChange:_=>T(_.target.value),className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50"})]})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>{j("list"),k(null)},className:`${g} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void M(),disabled: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"&&((O=r.data)!=null&&O.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"&&((P=r.data)!=null&&P.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"&&((Y=r.data)!=null&&Y.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:[bm(_.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:[Sl(_)?t.jsx("button",{type:"button",onClick:ie=>{ie.stopPropagation(),A(_)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-sky-100 transition hover:border-sky-300/35 hover:bg-sky-300/10`,children:"Edit"}):null,a&&_.trustStatus==="trusted"&&!_.isManaged?t.jsx("button",{type:"button",disabled:s,onClick:ie=>{ie.stopPropagation(),W(_)},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(),J(_)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-emerald-100 transition hover:border-emerald-300/35 hover:bg-emerald-300/10 disabled:cursor-not-allowed disabled:opacity-50`,children:"Trust"}):null,t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-0.5 text-stone-300",children:km(_.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:vm(_.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&&(((Z=r.data)==null?void 0:Z.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 Jr(e){return e.localGoalId??`${e.createdAt}:${e.objective}`}function Qm(e,r){const n=e?[e,...r]:r,a=new Set;return n.filter(s=>{const o=Jr(s);return a.has(o)?!1:(a.add(o),!0)})}function ep(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 tp(e){switch(e){case"budgetLimited":return"Budget limited";case"complete":return"Complete";case"terminated":return"Terminated";case"paused":return"Paused";default:return"Active"}}function rp({goalState:e,goalHistory:r,busy:n,onBack:a,onUpdateGoal:s}){const o=Qm(e.data,r),l=e.data?Jr(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=Jr(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:tp(i.status)})]}),t.jsxs("p",{className:"mt-1.5 text-[11px] text-[var(--theme-fg-muted)]",children:[ep(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]},Jr(i))})})]})}function np({mcpPanelMode:e,mcpState:r,mcpConfigEditing:n,mcpConfigPath:a,mcpConfigError:s,mcpConfigSuccess:o,mcpConfigBusy:l,mcpHttpName:i,mcpHttpUrl:d,mcpRawBlock:h,composerPanelButtonClassName:m,composerChipButtonClassName:u,onSetMcpPanelMode:p,onClearMcpConfigStatus:f,onSetMcpHttpName:g,onSetMcpHttpUrl:b,onSetMcpRawBlock:j,onPrepareRawMcpBlock:x,onSaveHttpMcp:k,onSaveRawMcpBlock:w}){var v,y;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"MCP config source"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:a??"<provider config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),p("add"),f()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add MCP"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading MCP servers..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,s?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:s}):null,o?t.jsx("p",{className:"mb-2 rounded-xl border border-emerald-500/35 bg-emerald-500/10 px-3 py-3 text-sm text-emerald-100/90",children:o}):null,e==="add"?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:N=>{N.stopPropagation(),p("http"),f()},className:`${m} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"HTTP / Streamable HTTP"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"Form"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Add an MCP server with a name and URL, then write the matching block into provider config."})]}),t.jsxs("button",{type:"button",onClick:N=>{N.stopPropagation(),x()},className:`${m} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"stdio / raw block"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"TOML"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Write a single `[mcp_servers.name]` block, then save it back into provider config."})]})]}):null,e==="http"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"MCP name"}),t.jsx("input",{"aria-label":"MCP name",value:i,onChange:N=>g(N.target.value),placeholder:"openaiDeveloperDocs",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"URL"}),t.jsx("input",{"aria-label":"URL",value:d,onChange:N=>b(N.target.value),placeholder:"https://developers.openai.com/mcp",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>p("add"),className:`${u} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void k(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write HTTP MCP"})]})]}):null,e==="stdio"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsx("label",{className:"block text-xs text-stone-400",children:"MCP block for provider config"}),t.jsx("textarea",{"aria-label":"MCP block for provider config",value:h,onChange:N=>j(N.target.value),rows:8,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>p("add"),className:`${u} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void w(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write raw block"})]})]}):null,e==="list"&&((v=r.data)!=null&&v.servers.length)?t.jsx("div",{className:"space-y-2",children:r.data.servers.map(N=>t.jsxs("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:N.name}),t.jsxs("p",{className:"mt-0.5 text-xs text-stone-400",children:[N.tools.length," tools · ",N.resourceCount," ","resources · ",N.resourceTemplateCount," templates"]})]}),t.jsx("span",{className:"shrink-0 rounded-full border border-stone-700 px-2 py-1 text-[10px] uppercase tracking-[0.14em] text-stone-300",children:gm(N.authStatus)})]}),N.tools.length>0?t.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-stone-500",children:N.tools.slice(0,4).map(S=>S.title??S.name).join(" · ")}):null]},N.name))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((y=r.data)==null?void 0:y.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 ap({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,m;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:xm(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(na,{}),"$",d.name]})]}),t.jsx("p",{className:"text-xs leading-5 text-stone-400",children:((m=d.interface)==null?void 0:m.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 sp({open:e,slashPanelView:r,availableToolboxItems:n,busy:a,forkBusy:s,forkTurnOptionsState:o,skillsState:l,goalState:i,goalHistory:d,goalBusy:h,copiedSkillName:m,hooksPanelMode:u,hooksState:p,hostConfigFilesAvailable:f,hookTrustAvailable:g,hookConfigBusy:b,hookConfigError:j,hookConfigSuccess:x,editingHookTarget:k,hookScope:w,hookEventName:v,hookMatcher:y,hookCommand:N,hookTimeoutSec:S,hookStatusMessage:T,mcpPanelMode:M,mcpState:A,mcpConfigEditing:J,mcpConfigPath:W,mcpConfigError:re,mcpConfigSuccess:O,mcpConfigBusy:P,mcpHttpName:Y,mcpHttpUrl:Z,mcpRawBlock:_,iconButtonClassName:ie,menuClassName:H,menuItemClassName:B,panelButtonClassName:F,chipButtonClassName:E,onToggle:D,onToolboxItemClick:$,toolboxItemDisabled:L,toolboxItemClassName:C,toolboxItemStatus:U,onSetSlashPanelView:G,onViewGoals:le,onUpdateGoal:ee,onOpenForkTurns:ce,onForkLatest:q,onForkTurn:ve,onCopySkillInvokeName:ke,onResetHookForm:je,onSetHooksPanelMode:ye,onClearHookConfigStatus:fe,onSetEditingHookTarget:Te,onSetHookScope:oe,onSetHookEventName:Q,onSetHookMatcher:me,onSetHookCommand:we,onSetHookTimeoutSec:Ce,onSetHookStatusMessage:Me,onSaveHook:Be,onStartEditingHook:Ae,onTrustHook:He,onUntrustHook:X,onSetMcpPanelMode:he,onClearMcpConfigStatus:Se,onSetMcpHttpName:I,onSetMcpHttpUrl:V,onSetMcpRawBlock:se,onPrepareRawMcpBlock:ge,onSaveHttpMcp:Ne,onSaveRawMcpBlock:Le}){return t.jsxs("div",{className:"relative",children:[t.jsx(St,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Open slash toolbox",title:"Open slash toolbox",onClick:D,className:`${ie} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx(mm,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${H} 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:de=>{de.stopPropagation()},onMouseDown:de=>{de.stopPropagation()},onPointerDown:de=>{de.stopPropagation()},onTouchStart:de=>{de.stopPropagation()},children:r==="root"?t.jsxs("div",{className:"p-2",children:[n.map((de,Ge)=>de.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:de.description??de.label,children:[t.jsx("button",{type:"button",disabled:L(de),onClick:()=>{G("goals"),le==null||le()},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:de.command})}),t.jsx("button",{type:"button",disabled:L(de),onClick:qe=>$(de,qe),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"})]},`${de.action}:${de.command}`):t.jsx("button",{type:"button",disabled:L(de),onClick:qe=>$(de,qe),className:`${C(de)} ${Ge===0?"mt-0":""}`,title:de.description??de.label,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:de.command}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:U(de)})]})},`${de.action}:${de.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(rp,{goalState:i,goalHistory:d,busy:h,onBack:()=>G("root"),onUpdateGoal:ee}):r==="fork"?t.jsx(Ym,{busy:a,forkBusy:s,composerMenuItemClassName:B,onForkLatest:q,onSelectForkTurnPanel:()=>(G("forkTurns"),ce())}):r==="forkTurns"?t.jsx(Zm,{forkTurnOptionsState:o,forkBusy:s,composerPanelButtonClassName:F,onForkTurn:ve}):r==="skills"?t.jsx(ap,{skillsState:l,copiedSkillName:m,composerChipButtonClassName:E,onCopySkillInvokeName:ke}):r==="hooks"?t.jsx(Jm,{hooksPanelMode:u,hooksState:p,hostConfigFilesAvailable:f,hookTrustAvailable:g,hookConfigBusy:b,hookConfigError:j,hookConfigSuccess:x,editingHookTarget:k,hookScope:w,hookEventName:v,hookMatcher:y,hookCommand:N,hookTimeoutSec:S,hookStatusMessage:T,composerChipButtonClassName:E,onResetHookForm:je,onSetHooksPanelMode:ye,onClearHookConfigStatus:fe,onSetEditingHookTarget:Te,onSetHookScope:oe,onSetHookEventName:Q,onSetHookMatcher:me,onSetHookCommand:we,onSetHookTimeoutSec:Ce,onSetHookStatusMessage:Me,onSaveHook:Be,onStartEditingHook:Ae,onTrustHook:He,onUntrustHook:X}):t.jsx(np,{mcpPanelMode:M,mcpState:A,mcpConfigEditing:J,mcpConfigPath:W,mcpConfigError:re,mcpConfigSuccess:O,mcpConfigBusy:P,mcpHttpName:Y,mcpHttpUrl:Z,mcpRawBlock:_,composerPanelButtonClassName:F,composerChipButtonClassName:E,onSetMcpPanelMode:he,onClearMcpConfigStatus:Se,onSetMcpHttpName:I,onSetMcpHttpUrl:V,onSetMcpRawBlock:se,onPrepareRawMcpBlock:ge,onSaveHttpMcp:Ne,onSaveRawMcpBlock:Le})})})]})}function op({isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:s,toolbarClassName:o,iconButtonClassName:l,slashToolboxProps:i,attachmentMenuProps:d,settingsToolbarProps:h,shellToolsPanelProps:m,onToggleView:u,onDismissPromptFocus:p,onSetOpenMenu:f}){return t.jsxs($m,{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(sp,{...i}):null,!e&&d?t.jsx(Vm,{...d}):null,r&&t.jsx(St,{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:()=>u==null?void 0:u(),className:`${l} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:e?t.jsx(pm,{}):t.jsx(hm,{})})]}),t.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center justify-end gap-1.5",children:[!e&&h?t.jsx(qm,{...h}):null,e&&a?t.jsx(Bm,{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:()=>{p(),f(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(fm,{})}),s==="shellTools"&&m?t.jsx(Km,{...m}):null]})]})]})}function lp(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`attachment-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ip(e){return[...e.filter(r=>ta(r)==="photo"),...e.filter(r=>ta(r)==="file")]}function dp({prompt:e,attachments:r,updateDraft:n,getSelection:a,selectionSnapshotRef:s,pendingSelectionRef:o,pendingInsertedAttachmentIdsRef:l,onInserted:i,buildClientId:d=lp}){const h=c.useCallback((p,f)=>{if(p.length===0)return!1;const g=qu({prompt:e,attachments:r,files:p,selection:a()??s.current,kindForFile:f,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]),m=c.useCallback((p,f)=>!p||p.length===0?!1:h(Array.from(p),()=>f),[h]),u=c.useCallback(p=>h(ip(p),ta),[h]);return{appendAttachments:m,appendDroppedAttachments:u}}function Ns(e){for(const r of e.values())URL.revokeObjectURL(r);e.clear()}function cp({attachments:e,isShellView:r}){const n=c.useRef(new Map),[a,s]=c.useState({});return c.useEffect(()=>{const o=n.current;if(r){Ns(o),s({});return}const l={},i=new Set;for(const d of e){if(d.kind!=="photo")continue;i.add(d.clientId);let h=o.get(d.clientId);h||(h=URL.createObjectURL(d.file),o.set(d.clientId,h)),l[d.clientId]=h}for(const[d,h]of o.entries())i.has(d)||(URL.revokeObjectURL(h),o.delete(d));s(l)},[e,r]),c.useEffect(()=>{const o=n.current;return()=>{Ns(o)}},[]),a}var hp=180;function Pn(e,r){return{prompt:e??"",attachments:r??[]}}function up({isShellView:e,draftPrompt:r,draftAttachments:n,onDraftChange:a}){const[s,o]=c.useState({prompt:"",attachments:[]}),[l,i]=c.useState(()=>Pn(r,n)),d=c.useRef(null),h=c.useRef(l),m=c.useRef(Gr(l)),u=!e&&r!==void 0&&n!==void 0&&typeof a=="function",p=u?Gr(Pn(r,n)):"",f=c.useRef(p);c.useLayoutEffect(()=>{if(!u){f.current="";return}const w=Pn(r,n),v=Gr(w);v!==f.current&&(f.current=v,m.current=v,h.current=w,d.current!==null&&(window.clearTimeout(d.current),d.current=null),i(w))},[n,r,u]);const g=c.useCallback(w=>{if(!u||!a)return;const v=Gr(w);v!==m.current&&(m.current=v,a(()=>({prompt:w.prompt,attachments:w.attachments})))},[u,a]);c.useEffect(()=>()=>{g(h.current),d.current!==null&&window.clearTimeout(d.current)},[g]);const b=c.useCallback((w,v)=>{if(u){if(d.current!==null&&(window.clearTimeout(d.current),d.current=null),v==="immediate"){g(w);return}d.current=window.setTimeout(()=>{d.current=null,g(h.current)},hp)}},[u,g]),j=c.useCallback((w=h.current)=>{b(w,"immediate")},[b]),x=c.useCallback((w,v="immediate")=>{if(u){const y=w(h.current);h.current=y,i(y),b(y,v);return}o(y=>w(y))},[u,b]),k=u?l:s;return{prompt:k.prompt,attachments:k.attachments,isDraftControlled:u,updateDraft:x,flushControlledDraftToHost:j}}function mp({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 pp({prompt:e,goalTokenBudgetSource:r,promptRef:n,onOpenGoal:a,onPrepareGoalSubmit:s,onUpdateGoal:o,updateDraft:l,closeMenu:i,resetSlashPanel:d}){const[h,m]=c.useState(!1),[u,p]=c.useState(""),[f,g]=c.useState(!1),[b,j]=c.useState(null),x=c.useCallback(async()=>{const v=e.trim();if(!v)return j("Goal objective cannot be empty."),!1;const y=u.trim(),N=em(y);if(y.length>0&&(N===null||!Number.isInteger(N)||N<=0))return j("Token budget must be a positive number in thousands."),!1;if(!o)return j("/goal is unavailable in this view."),!1;g(!0),j(null);try{return s&&await s({objective:v,tokenBudget:N})===!1?!1:(await o({objective:v,status:"active",tokenBudget:N}),p(""),m(!1),l(()=>({prompt:"",attachments:[]})),!0)}catch(S){return j(S instanceof Error?S.message:"Unable to set goal."),!1}finally{g(!1)}},[u,s,o,e,l]),k=c.useCallback(()=>{i(),d(),m(!0),p(tm(r==null?void 0:r.tokenBudget)),j(null),a==null||a(),requestAnimationFrame(()=>{var v;(v=n.current)==null||v.focus()})},[i,r==null?void 0:r.tokenBudget,a,n,d]),w=c.useCallback(()=>{m(!1),j(null)},[]);return{goalComposeMode:h,goalTokenBudget:u,goalBusy:f,goalLocalError:b,setGoalTokenBudget:p,submitGoal:x,enterGoalComposeMode:k,exitGoalComposeMode:w}}var Rn=`node -e "process.stdin.resume(); process.stdin.on('end', () => console.error('hook ran'))"`;function fp(e){const r=new Map;for(const n of e??[])r.set(n.eventName,n.command);return r}function gp({slashPanelView:e,hookCommandTemplates:r,onCreateHook:n,onUpdateHook:a,onTrustHook:s,onUntrustHook:o}){const[l,i]=c.useState("list"),[d,h]=c.useState("project"),[m,u]=c.useState("preToolUse"),[p,f]=c.useState("Bash"),[g,b]=c.useState(Rn),[j,x]=c.useState("30"),[k,w]=c.useState("Running hook"),[v,y]=c.useState(null),[N,S]=c.useState(!1),[T,M]=c.useState(null),[A,J]=c.useState(null),W=c.useMemo(()=>fp(r),[r]),re=c.useCallback(B=>W.get(B)??W.get("preToolUse")??Rn,[W]),O=c.useMemo(()=>new Set([Rn,...W.values()]),[W]),P=c.useCallback(()=>{M(null),J(null)},[]);c.useEffect(()=>{e!=="hooks"&&(i("list"),P())},[P,e]),c.useEffect(()=>{const B=nn.find(F=>F.value===m);f(F=>{const E=F.trim(),D=new Set(nn.map($=>$.matcherHint).filter(Boolean));return E&&!D.has(E)?F:(B==null?void 0:B.matcherHint)??""}),b(F=>O.has(F.trim())?re(m):F)},[re,O,m]);const Y=c.useCallback(()=>{y(null),h("project"),u("preToolUse"),f("Bash"),b(re("preToolUse")),x("30"),w("Running hook")},[re]),Z=c.useCallback(B=>{const F=Sl(B);if(!F){M("Only command hooks in global or project hooks.json can be edited here.");return}y(F),h(F.scope),u(F.eventName),f(F.matcher??""),b(F.command),x(F.timeoutSec?String(F.timeoutSec):""),w(F.statusMessage??""),M(null),J(null),i("edit")},[]),_=c.useCallback(async()=>{if(l==="edit"&&!a){M("Hook editing is unavailable in this view.");return}if(l!=="edit"&&!n){M("Hook editing is unavailable in this view.");return}if(l==="edit"&&!v){M("Select a hook to edit first.");return}const B=g.trim();if(!B){M("Hook command cannot be empty.");return}const F=j.trim(),E=F?Number(F):null;if(F&&(E===null||!Number.isInteger(E)||E<=0)){M("Timeout must be a positive number of seconds.");return}S(!0),M(null),J(null);try{const D={scope:d,eventName:m,matcher:p.trim()||null,command:B,timeoutSec:E,statusMessage:k.trim()||null};l==="edit"?await(a==null?void 0:a({...D,target:v})):await(n==null?void 0:n(D)),J(`${d==="project"?"Project":"Global"} hook ${l==="edit"?"updated":"written"} in hooks.json and trusted.`),i("list"),y(null)}catch(D){M(D instanceof Error?D.message:"Unable to write hooks.json.")}finally{S(!1)}},[v,g,m,p,d,k,j,l,n,a]),ie=c.useCallback(async B=>{if(!s||!B.currentHash){M("Hook trust is unavailable in this view.");return}S(!0),M(null),J(null);try{await s({key:B.key,currentHash:B.currentHash}),J("Hook trusted.")}catch(F){M(F instanceof Error?F.message:"Unable to trust hook.")}finally{S(!1)}},[s]),H=c.useCallback(async B=>{if(!o){M("Hook trust is unavailable in this view.");return}S(!0),M(null),J(null);try{await o({key:B.key}),J("Hook untrusted.")}catch(F){M(F instanceof Error?F.message:"Unable to untrust hook.")}finally{S(!1)}},[o]);return{hooksPanelMode:l,hookScope:d,hookEventName:m,hookMatcher:p,hookCommand:g,hookTimeoutSec:j,hookStatusMessage:k,editingHookTarget:v,hookConfigBusy:N,hookConfigError:T,hookConfigSuccess:A,setHooksPanelMode:i,setEditingHookTarget:y,setHookScope:h,setHookEventName:u,setHookMatcher:f,setHookCommand:b,setHookTimeoutSec:x,setHookStatusMessage:w,clearHookConfigStatus:P,resetHookForm:Y,startEditingHook:Z,saveHook:_,trustHook:ie,untrustHook:H}}var xp=`[mcp_servers.example_stdio]
|
|
3949
3949
|
command = "npx"
|
|
3950
3950
|
args = ["-y", "your-mcp-server"]
|
|
3951
|
-
`,ys="MCP entry written to provider config. Restart the backend if it does not appear immediately.";function gp({hostConfigFilesAvailable:e,onReadProviderConfig:r,onWriteProviderConfig:n,setMcpPanelMode:a,onOpenMcp:s}){const[o,l]=c.useState(""),[i,d]=c.useState(""),[h,m]=c.useState(""),[u,p]=c.useState(null),[f,g]=c.useState(!1),[x,j]=c.useState(null),[b,k]=c.useState(null),y=c.useCallback(()=>{j(null),k(null)},[]),v=c.useCallback(async()=>{if(!e||!r)throw new Error("Provider config editing is unavailable for this thread.");const R=await r();return p(R.path),R},[e,r]),w=c.useCallback(async R=>{if(!e||!n)throw new Error("Provider config editing is unavailable for this thread.");const _=await n(R);return p(_.path),_},[e,n]),C=c.useCallback(async()=>{const R=em(o),_=i.trim();if(!R){j("MCP name must use only letters, numbers, underscore, or hyphen.");return}if(!/^https?:\/\//i.test(_)){j("HTTP MCP URL must start with http:// or https://");return}g(!0),j(null),k(null);try{const Y=await v(),W=fs(Y.content,R,rm(R,_));await w(W),k(ys),a("list"),l(""),d(""),s==null||s()}catch(Y){j(Y instanceof Error?Y.message:"Unable to update provider config.")}finally{g(!1)}},[v,o,i,s,a,w]),N=c.useCallback(async()=>{g(!0),j(null),k(null);try{await v(),m(R=>R||fp),a("stdio")}catch(R){j(R instanceof Error?R.message:"Unable to load provider config.")}finally{g(!1)}},[v,a]),E=c.useCallback(async()=>{const R=tm(h);if(!R){j("The raw MCP block must start with a header like [mcp_servers.name].");return}g(!0),j(null),k(null);try{const _=await v(),Y=fs(_.content,R,h);await w(Y),k(ys),a("list"),s==null||s()}catch(_){j(_ instanceof Error?_.message:"Unable to update provider config.")}finally{g(!1)}},[v,h,s,a,w]);return{mcpHttpName:o,mcpHttpUrl:i,mcpRawBlock:h,mcpConfigPath:u,mcpConfigBusy:f,mcpConfigError:x,mcpConfigSuccess:b,setMcpHttpName:l,setMcpHttpUrl:d,setMcpRawBlock:m,clearMcpConfigStatus:y,prepareRawMcpBlock:N,saveHttpMcp:C,saveRawMcpBlock:E}}function xp({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 m=window.setTimeout(()=>{d(u=>u===i?null:u)},1400);return()=>{window.clearTimeout(m)}},[i]),c.useEffect(()=>{function m(u){(typeof u.composedPath=="function"?u.composedPath():[]).some(g=>g instanceof HTMLElement&&(g.dataset.composerMenuSurface==="true"||g.dataset.composerMenuTrigger==="true"))||e&&r(null)}if(e)return window.addEventListener("pointerdown",m),()=>{window.removeEventListener("pointerdown",m)}},[e,r]);const h=c.useCallback(async m=>{try{await navigator.clipboard.writeText(`$${m}`),d(m)}catch{d(null)}},[]);return{copiedSkillName:i,copySkillInvokeName:h}}function bp(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=xs(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=xs(n),a.append(s,o),a}function vp(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(bp(a,r))}return n}function kp({promptRef:e,isShellView:r,prompt:n,promptSegments:a,attachmentPreviewUrls:s,previewSignature:o,editorSanitizeNonce:l,pendingSelectionRef:i,pendingInsertedAttachmentIdsRef:d,selectionSnapshotRef:h,renderedPreviewSignatureRef:m,renderedSanitizeNonceRef:u,serializeEditorPrompt:p,restoreSelection:f}){c.useLayoutEffect(()=>{const g=e.current;if(!g||r)return;const x=i.current,j=p()!==n||m.current!==o||u.current!==l;j&&(g.replaceChildren(vp(a,s)),m.current=o,u.current=l),x!==null?(g.focus(),Pm(g,d.current)||f(x),h.current=x):document.activeElement===g&&j&&f(h.current),i.current=null,d.current=[]},[s,l,r,o,n,e,a,d,i,m,u,f,h,p])}function wp({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 yp(){var r,n;return!!((n=(r=window.webkit)==null?void 0:r.messageHandlers)!=null&&n.remoteCodex)}function jp({promptRef:e,prompt:r,disabled:n,promptPlaceholder:a,canInterrupt:s,interruptLabel:o,composerPromptRegionClassName:l,graphChatInputClassName:i,onInterrupt:d,onInput:h,onPointerDown:m,onPaste:u,onKeyDown:p,onKeyUp:f,onMouseUp:g,onBlur:x,onDragEnter:j,onDragOver:b,onDragLeave:k,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:v=>{!n&&document.activeElement!==v.currentTarget&&yp()&&v.currentTarget.focus({preventScroll:!0}),m==null||m(v)},onInput:h,onPaste:u,onKeyDown:p,onKeyUp:f,onMouseUp:g,onBlur:x,onDragEnter:j,onDragOver:b,onDragLeave:k,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(St,{type:"button",variant:"ghost",size:"icon-xs","aria-label":o,title:o,onClick:v=>{v.preventDefault(),d==null||d()},className:"thread-graph-composer-stop-button ui-action-danger absolute right-2 top-2 z-30 h-8 w-8 rounded-full text-sm font-medium",children:t.jsx("span",{"aria-hidden":"true",className:"block h-2.5 w-2.5 rounded-[2px] bg-current"})}):null]})}function Np({prompt:e,promptPlaceholder:r,promptRegionClassName:n,promptInputClassName:a,interruptLabel:s,canInterrupt:o,sendButtonLabel:l,sendButtonClassName:i,sendDisabled:d,onPromptChange:h,onPromptKeyDown:m,onInterrupt:u}){return t.jsxs("div",{className:`${n} relative`,children:[t.jsx("textarea",{"aria-label":"Prompt",disabled:!1,value:e,onChange:p=>h(p.target.value),onKeyDown:m,rows:2,placeholder:r,className:`${a} resize-y pb-10`}),t.jsx("button",{type:"button","aria-label":s,title:s,onClick:()=>void(u==null?void 0:u()),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:p=>{p.preventDefault()},onPointerDown:p=>{p.preventDefault()},onTouchStart:p=>{p.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 Cp({isShellView:e,promptRef:r,prompt:n,disabled:a,promptPlaceholder:s,canInterrupt:o,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,promptInputClassName:h,goalComposeMode:m,goalTokenBudget:u,goalLocalError:p,goalBusy:f,busy:g,sendButtonLabel:x,sendButtonClassName:j,onInterrupt:b,onPromptInput:k,onPromptPaste:y,onPromptKeyDown:v,onPromptKeyUp:w,onPromptMouseUp:C,onPromptBlur:N,onPromptDragEnter:E,onPromptDragOver:R,onPromptDragLeave:_,onPromptDrop:Y,onGoalTokenBudgetChange:W,onCancelGoal:re,onShellPromptChange:F}){return{promptSlot:e?null:t.jsx(jp,{promptRef:r,prompt:n,disabled:a,promptPlaceholder:s,canInterrupt:o,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,onInterrupt:b,onInput:k,onPaste:y,onKeyDown:v,onKeyUp:w,onMouseUp:C,onBlur:N,onDragEnter:E,onDragOver:R,onDragLeave:_,onDrop:Y}),goalSlot:m&&!e?t.jsx(wp,{tokenBudget:u,error:p,onTokenBudgetChange:W,onCancel:re}):null,shellPromptSlot:e?t.jsx(Np,{prompt:n,promptPlaceholder:s,promptRegionClassName:i,promptInputClassName:h,interruptLabel:l,canInterrupt:o,sendButtonLabel:x,sendButtonClassName:j,sendDisabled:f||g,onPromptChange:F,onPromptKeyDown:v,onInterrupt:b}):null}}function Sp({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=Zu({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 Tp({isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:s,toolbarClassName:o,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:m,inlineToggleClassName:u,planToggleActiveClassName:p,sendButtonBaseClassName:f,slashPanelView:g,availableToolboxItems:x,busy:j,settingsBusy:b,compactBusy:k,forkBusy:y,fastMode:v,goalComposeMode:w,goalBusy:C,goalStatus:N,activeView:E,disabled:R,model:_,agentLabel:Y,modelOptions:W,modelContextTitle:re,contextUsage:F,reasoningEffort:A,supportedEfforts:J,displayedCollaborationMode:Z,sandboxMode:M,sendButtonLabel:ie,sendButtonClassName:O,modelControlsDisabled:G,effortControlsDisabled:H,effortControlTitle:T,forkTurnOptionsState:$,skillsState:D,goalState:L,goalHistory:S,copiedSkillName:U,hooksPanelMode:B,hooksState:le,hookConfigBusy:K,hookConfigError:de,hookConfigSuccess:ee,editingHookTarget:ve,hookScope:be,hookEventName:ye,hookMatcher:we,hookCommand:fe,hookTimeoutSec:Te,hookStatusMessage:oe,mcpPanelMode:Q,mcpState:me,mcpConfigPath:ke,mcpConfigError:Ne,mcpConfigSuccess:Ae,mcpConfigBusy:Ge,mcpHttpName:Me,mcpHttpUrl:Fe,mcpRawBlock:X,capabilities:he,shellControlState:Ce,onToggleView:I,onDismissPromptFocus:V,onSetOpenMenu:ae,onToolboxItemClick:ge,onSetSlashPanelView:je,onViewGoals:Ie,onUpdateGoal:ce,onOpenForkTurns:He,onForkLatest:qe,onForkTurn:We,onCopySkillInvokeName:Ye,onResetHookForm:ft,onSetHooksPanelMode:rt,onClearHookConfigStatus:ct,onSetEditingHookTarget:Ze,onSetHookScope:pt,onSetHookEventName:ot,onSetHookMatcher:z,onSetHookCommand:q,onSetHookTimeoutSec:xe,onSetHookStatusMessage:Ee,onSaveHook:$e,onStartEditingHook:Qe,onTrustHook:nt,onUntrustHook:Ve,onSetMcpPanelMode:De,onClearMcpConfigStatus:ht,onSetMcpHttpName:bt,onSetMcpHttpUrl:at,onSetMcpRawBlock:vt,onPrepareRawMcpBlock:lt,onSaveHttpMcp:Tt,onSaveRawMcpBlock:te,onPickPhoto:Re,onPickFile:se,onUpdateSettings:Se,onPasteShell:Xe,onCopyShell:Ue,onClearShell:it,onShellControl:Et}){const jt=e?null:{open:s==="slash",slashPanelView:g,availableToolboxItems:x,busy:j,forkBusy:y,forkTurnOptionsState:$,skillsState:D,goalState:L,goalHistory:S,goalBusy:C,copiedSkillName:U,hooksPanelMode:B,hooksState:le,hostConfigFilesAvailable:he.hostConfigFiles,hookTrustAvailable:he.hookTrust,hookConfigBusy:K,hookConfigError:de,hookConfigSuccess:ee,editingHookTarget:ve,hookScope:be,hookEventName:ye,hookMatcher:we,hookCommand:fe,hookTimeoutSec:Te,hookStatusMessage:oe,mcpPanelMode:Q,mcpState:me,mcpConfigEditing:he.mcpConfigEditing,mcpConfigPath:ke,mcpConfigError:Ne,mcpConfigSuccess:Ae,mcpConfigBusy:Ge,mcpHttpName:Me,mcpHttpUrl:Fe,mcpRawBlock:X,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:m,onToggle:()=>ae(ut=>ut==="slash"?null:"slash"),onToolboxItemClick:ge,toolboxItemDisabled:ut=>Sm(ut,{settingsBusy:b,compactBusy:k,busy:j,forkBusy:y}),toolboxItemClassName:ut=>Tm(ut,{fastMode:v,goalComposeMode:w,goalStatus:N,menuItemClassName:d}),toolboxItemStatus:ut=>Cm(ut,{fastMode:v,compactBusy:k,goalComposeMode:w,goalStatus:N,busy:j}),onSetSlashPanelView:je,onViewGoals:Ie,onUpdateGoal:ce,onOpenForkTurns:He,onForkLatest:qe,onForkTurn:We,onCopySkillInvokeName:Ye,onResetHookForm:ft,onSetHooksPanelMode:rt,onClearHookConfigStatus:ct,onSetEditingHookTarget:Ze,onSetHookScope:pt,onSetHookEventName:ot,onSetHookMatcher:z,onSetHookCommand:q,onSetHookTimeoutSec:xe,onSetHookStatusMessage:Ee,onSaveHook:$e,onStartEditingHook:Qe,onTrustHook:nt,onUntrustHook:Ve,onSetMcpPanelMode:De,onClearMcpConfigStatus:ht,onSetMcpHttpName:bt,onSetMcpHttpUrl:at,onSetMcpRawBlock:vt,onPrepareRawMcpBlock:lt,onSaveHttpMcp:Tt,onSaveRawMcpBlock:te},At=e?null:{open:s==="attachments",iconButtonClassName:l,menuClassName:i,menuItemClassName:d,onToggle:()=>ae(ut=>ut==="attachments"?null:"attachments"),onPickPhoto:Re,onPickFile:se},Zt=e?null:{openMenu:s,model:_,agentLabel:Y,modelOptions:W,modelContextTitle:re,contextUsage:F,reasoningEffort:A,supportedEfforts:J,displayedCollaborationMode:Z,sandboxMode:M,planModeAvailable:he.planMode,sandboxModeAvailable:he.sandboxMode,settingsBusy:b,goalComposeMode:w,goalBusy:C,activeView:E,disabled:R,fastMode:v,sendButtonLabel:ie,sendButtonClassName:O,modelControlsDisabled:G,effortControlsDisabled:H,effortControlTitle:T,inlineToggleClassName:u,menuItemClassName:d,planToggleActiveClassName:p,sendButtonBaseClassName:f,onSetOpenMenu:ae,onUpdateSettings:Se};return{isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:s,toolbarClassName:o,iconButtonClassName:l,slashToolboxProps:jt,attachmentMenuProps:At,settingsToolbarProps:Zt,shellToolsPanelProps:s==="shellTools"?{busy:j,shellControlState:Ce,onPaste:Xe,onCopy:Ue,onClear:it,onShellControl:Et}:null,shellControlState:Ce,onToggleView:I,onDismissPromptFocus:V,onSetOpenMenu:ae}}function ta({activeView:e,edgeToEdgeMobile:r=!1,busy:n=!1,settingsBusy:a=!1,compactBusy:s=!1,error:o,model:l=null,agentLabel:i=null,reasoningEffort:d=null,fastMode:h=!1,collaborationMode:m="default",sandboxMode:u=null,hideSandboxModeControl:p=!1,modelOptions:f=[],contextUsage:g=null,capabilities:x=null,toolboxItems:j=null,hookCommandTemplates:b=null,mcpConfigFormat:k="none",followTail:y=!1,threadConnected:v=!0,shellAvailable:w=!0,disabled:C=!1,disabledPlaceholder:N,shellControlState:E=null,draftPrompt:R,draftAttachments:_,onPickAttachment:Y,skillsState:W={status:"idle",data:null,error:null},mcpState:re={status:"idle",data:null,error:null},hooksState:F={status:"idle",data:null,error:null},goalState:A={status:"idle",data:null,error:null},goalHistory:J=[],forkTurnOptionsState:Z={status:"idle",data:null,error:null},onDraftChange:M,onSubmit:ie,onInterrupt:O,onCompact:G,onOpenSkills:H,onOpenMcp:T,onOpenHooks:$,onCreateHook:D,onUpdateHook:L,onTrustHook:S,onUntrustHook:U,onOpenGoal:B,onPrepareGoalSubmit:le,onUpdateGoal:K,onOpenForkTurns:de,onForkLatest:ee,onForkTurn:ve,onReadProviderConfig:be,onWriteProviderConfig:ye,onToggleFollow:we,canJumpToPreviousTurn:fe,onJumpToPreviousTurn:Te,canJumpToNextTurn:oe,onJumpToNextTurn:Q,subscriptionUsage:me,onUpdateSettings:ke,onToggleView:Ne,onShellCopy:Ae,onShellControl:Ge,canInterrupt:Me=!1,pendingPrompts:Fe=[],onSteerPendingPrompt:X,onCancelPendingPrompt:he}){var _a;const[Ce,I]=c.useState(null),[V,ae]=c.useState("root"),ge=c.useRef(!1),[je,Ie]=c.useState("list"),ce=c.useMemo(()=>({fast:(x==null?void 0:x.controls.performanceMode)??!1,compact:(x==null?void 0:x.turns.compact)??!1,goal:(x==null?void 0:x.controls.goals)??!1,fork:(x==null?void 0:x.branching.fork)??!1,skills:(x==null?void 0:x.management.skills)??!1,mcp:(x==null?void 0:x.management.mcpStatus)??!1,hooks:(x==null?void 0:x.management.hooks)??!1,hostConfigFiles:(x==null?void 0:x.management.hostConfigFiles)??!1,mcpConfigEditing:k==="codex-toml"&&!!(x!=null&&x.management.hostConfigFiles)&&!!be&&!!ye,hookTrust:(x==null?void 0:x.management.hookTrust)??!1,planMode:(x==null?void 0:x.controls.planMode)??!1,sandboxMode:(x==null?void 0:x.controls.sandboxMode)??!1}),[x,k,be,ye]),He=c.useMemo(()=>jm(j,ce),[ce,j]),qe=c.useRef(null),We=c.useRef(null),Ye=c.useRef(null),ft=c.useRef(null),rt=c.useRef(null),ct=c.useRef([]),Ze=c.useRef(null),pt=c.useRef(""),ot=c.useRef(0),z=e==="shell",q=w||z,xe=!!(z&&(E!=null&&E.isMobileShell)),Ee=(E==null?void 0:E.promptLabel)??null,[$e,Qe]=c.useState(!1),[nt,Ve]=c.useState(0),{prompt:De,attachments:ht,isDraftControlled:bt,updateDraft:at,flushControlledDraftToHost:vt}=cp({isShellView:z,draftPrompt:R,draftAttachments:_,onDraftChange:M}),lt=ip({attachments:ht,isShellView:z}),{displayedCollaborationMode:Tt,updateSettings:te}=Sp({collaborationMode:m,onUpdateSettings:ke,closeMenu:()=>I(null)}),{forkBusy:Re,forkLatest:se,forkTurn:Se}=hp({slashPanelView:V,onForkLatest:ee,onForkTurn:ve,closeMenu:()=>I(null)}),{hooksPanelMode:Xe,hookScope:Ue,hookEventName:it,hookMatcher:Et,hookCommand:jt,hookTimeoutSec:At,hookStatusMessage:Zt,editingHookTarget:pr,hookConfigBusy:ut,hookConfigError:gn,hookConfigSuccess:Zl,setHooksPanelMode:Jl,setEditingHookTarget:Ql,setHookScope:ei,setHookEventName:ti,setHookMatcher:ri,setHookCommand:ni,setHookTimeoutSec:ai,setHookStatusMessage:si,clearHookConfigStatus:Ca,resetHookForm:oi,startEditingHook:li,saveHook:ii,trustHook:di,untrustHook:ci}=pp({slashPanelView:V,hookCommandTemplates:b,onCreateHook:D,onUpdateHook:L,onTrustHook:S,onUntrustHook:U}),{goalComposeMode:fr,goalTokenBudget:hi,goalBusy:xn,goalLocalError:ui,setGoalTokenBudget:mi,submitGoal:pi,enterGoalComposeMode:fi,exitGoalComposeMode:Sa}=up({prompt:De,goalTokenBudgetSource:A.data,promptRef:We,onOpenGoal:B,onPrepareGoalSubmit:le,onUpdateGoal:K,updateDraft:at,closeMenu:()=>I(null),resetSlashPanel:()=>ae("root")}),{mcpHttpName:gi,mcpHttpUrl:xi,mcpRawBlock:bi,mcpConfigPath:vi,mcpConfigBusy:ki,mcpConfigError:wi,mcpConfigSuccess:yi,setMcpHttpName:ji,setMcpHttpUrl:Ni,setMcpRawBlock:Ci,clearMcpConfigStatus:Ta,prepareRawMcpBlock:Si,saveHttpMcp:Ti,saveRawMcpBlock:Ei}=gp({hostConfigFilesAvailable:ce.hostConfigFiles,onReadProviderConfig:be,onWriteProviderConfig:ye,setMcpPanelMode:Ie,onOpenMcp:T}),{copiedSkillName:Li,copySkillInvokeName:Ii}=xp({openMenu:Ce,setOpenMenu:I,slashPanelView:V,setSlashPanelView:ae,setMcpPanelMode:Ie,clearMcpConfigStatus:Ta,clearHookConfigStatus:Ca}),zi=c.useCallback(ne=>{at(Le=>{if(typeof ne=="function"){const _e=ne(Le.prompt,Le.attachments);return{prompt:_e.prompt,attachments:_e.attachments??Le.attachments}}return{prompt:ne,attachments:Le.attachments}})},[at]),bn=c.useMemo(()=>f.find(ne=>ne.model===l)??null,[l,f]),Pi=nm(l,g),Ea=(bn==null?void 0:bn.supportedReasoningEfforts)??[],Ri=c.useMemo(()=>Fu(De,ht),[ht,De]),_i=c.useMemo(()=>Object.entries(lt).sort(([ne],[Le])=>ne.localeCompare(Le)).map(([ne,Le])=>`${ne}:${Le}`).join("|"),[lt]);function Mi(ne,Le){Le.stopPropagation();const _e=Nm(ne,{fastMode:h,goalComposeMode:fr});switch(_e.type){case"toggleFast":te({fastMode:_e.fastMode});break;case"runCompact":I(null),G==null||G();break;case"enterGoalCompose":fi();break;case"exitGoalCompose":Sa(),I(null);break;case"openPanel":ae(_e.panel),_e.panel==="skills"?H==null||H():_e.panel==="mcp"?T==null||T():_e.panel==="hooks"&&($==null||$());break;case"insertPrompt":wn(_e.text),ae("root"),I(null);break}}function Jt(){const ne=We.current;return ne?Im(ne):null}const Ai=c.useCallback(ne=>{const Le=We.current;!Le||!ne||zm(Le,ne)},[]),vn=c.useCallback(()=>{const ne=We.current;return ne?Nl(ne):De},[De]),{appendAttachments:kn,appendDroppedAttachments:La}=lp({prompt:De,attachments:ht,updateDraft:at,getSelection:Jt,selectionSnapshotRef:Ze,pendingSelectionRef:rt,pendingInsertedAttachmentIdsRef:ct,onInserted:()=>I(null)}),Ia=c.useCallback((ne,Le)=>{var _e;if($t(),Y){Y({kind:ne,appendAttachments:(et,dt=ne)=>kn(et,dt),defaultPick:()=>{var et;return(et=Le.current)==null?void 0:et.click()}});return}(_e=Le.current)==null||_e.click()},[kn,$t,Y]);function wn(ne){if(!ne)return;const Le=Jt()??Ze.current,_e=(Le==null?void 0:Le.start)??De.length,et=(Le==null?void 0:Le.end)??_e,dt=Hu(ne),Qt=`${De.slice(0,_e)}${dt}${De.slice(et)}`;at(xd=>({prompt:Qt,attachments:xd.attachments}));const Dt=_e+dt.length;rt.current={start:Dt,end:Dt},Ze.current={start:Dt,end:Dt}}kp({promptRef:We,isShellView:z,prompt:De,promptSegments:Ri,attachmentPreviewUrls:lt,previewSignature:_i,editorSanitizeNonce:nt,pendingSelectionRef:rt,pendingInsertedAttachmentIdsRef:ct,selectionSnapshotRef:Ze,renderedPreviewSignatureRef:pt,renderedSanitizeNonceRef:ot,serializeEditorPrompt:vn,restoreSelection:Ai});function $t(){var ne;(ne=We.current)==null||ne.blur(),document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.blur()}async function $i(){var ne;if($t(),I(null),!!((ne=navigator.clipboard)!=null&&ne.readText))try{const Le=await navigator.clipboard.readText();wn(Le)}catch{return}}async function za(){if(!ge.current){ge.current=!0;try{if(bt&&vt(),fr&&!z){await pi();return}const ne=Xu({prompt:De,attachments:ht,isShellView:z});if(!ne||await ie(ne)===!1)return;at(()=>({prompt:"",attachments:[]}))}finally{ge.current=!1}}}async function Di(ne){ne.preventDefault(),await za()}function Bi(){const ne=vn(),Le=Jt();Ze.current=Le;const _e=We.current;(_e?Lm(_e):!1)&&(rt.current=Le,Ve(dt=>dt+1)),at(dt=>({prompt:ne,attachments:dt.attachments.filter(Qt=>ne.includes(Qt.placeholder))}),"deferred")}function Gi(ne){var et,dt,Qt,Dt;const Le=Qn((et=ne.clipboardData)==null?void 0:et.items,(dt=ne.clipboardData)==null?void 0:dt.files),_e=qu({files:Le,plainText:((Qt=ne.clipboardData)==null?void 0:Qt.getData("text/plain"))??"",htmlText:((Dt=ne.clipboardData)==null?void 0:Dt.getData("text/html"))??"",htmlToText:Em});_e.preventDefault&&ne.preventDefault(),_e.type==="insert-text"?wn(_e.text):_e.type==="append-files"&&La(_e.files)}function Hi(ne){var _e,et;const Le=ps(gs((_e=ne.dataTransfer)==null?void 0:_e.items,(et=ne.dataTransfer)==null?void 0:et.files));Le.preventDefault&&ne.preventDefault(),Le.activateDragTarget&&Qe(!0)}function Fi(ne){var _e,et;const Le=ps(gs((_e=ne.dataTransfer)==null?void 0:_e.items,(et=ne.dataTransfer)==null?void 0:et.files));Le.preventDefault&&ne.preventDefault(),Le.activateDragTarget&&ne.dataTransfer&&(ne.dataTransfer.dropEffect="copy"),Le.activateDragTarget&&Qe(!0)}function Oi(ne){ne.currentTarget.contains(ne.relatedTarget)||Qe(!1)}function Wi(ne){var et,dt;const Le=Qn((et=ne.dataTransfer)==null?void 0:et.items,(dt=ne.dataTransfer)==null?void 0:dt.files),_e=Ku(Le);_e.preventDefault&&ne.preventDefault(),_e.type==="accept-files"&&(Qe(!1),La(_e.files??[]))}function Ui(ne){if(ne.key==="Enter"&&ne.repeat){ne.preventDefault();return}if(e==="chat"&&ne.key==="/"&&!ne.metaKey&&!ne.ctrlKey&&!ne.altKey&&!n&&!C&&He.length>0&&vn().trim().length===0){ne.preventDefault(),ae("root"),I("slash");return}const Le=Yu({key:ne.key,metaKey:ne.metaKey,ctrlKey:ne.ctrlKey,busy:n,disabled:C});Le.preventDefault&&ne.preventDefault(),Le.submit&&za()}const{promptPlaceholder:Vi,interruptLabel:Xi,sendButtonLabel:Pa,sendButtonClassName:Ra,modelControlsDisabled:qi,effortControlsDisabled:Ki,effortControlTitle:Yi}=lm({goalComposeMode:fr,goalBusy:xn,threadConnected:v,busy:n,isShellView:z,disabledPlaceholder:N,settingsBusy:a,supportedEffortCount:Ea.length,fastMode:h}),{composerLayerClassName:Zi,formClassName:Ji,composerShellClassName:Qi,composerToolbarClassName:ed,composerIconButtonClassName:td,composerMenuClassName:rd,composerMenuItemClassName:nd,composerInlineToggleClassName:ad,composerPanelButtonClassName:sd,composerChipButtonClassName:od,composerPlanToggleActiveClassName:ld,composerSendButtonClassName:id,composerPromptRegionClassName:dd,promptInputClassName:cd,graphChatInputGroupClassName:hd,graphChatInputClassName:ud}=im({isShellView:z,edgeToEdgeMobile:r,isMobileShell:xe,openMenu:Ce!==null,isDragTargetActive:$e,busy:n}),md=Tp({isShellView:z,canToggleShellView:q,isMobileShell:xe,shellPromptLabel:Ee,openMenu:Ce,toolbarClassName:ed,iconButtonClassName:td,menuClassName:rd,menuItemClassName:nd,panelButtonClassName:sd,chipButtonClassName:od,inlineToggleClassName:ad,planToggleActiveClassName:ld,sendButtonBaseClassName:id,slashPanelView:V,availableToolboxItems:He,busy:n,settingsBusy:a,compactBusy:s,forkBusy:Re,fastMode:h,goalComposeMode:fr,goalBusy:xn,goalStatus:(_a=A.data)==null?void 0:_a.status,activeView:e,disabled:C,model:l,agentLabel:i,modelOptions:f,modelContextTitle:Pi,contextUsage:g,reasoningEffort:d,supportedEfforts:Ea,displayedCollaborationMode:Tt,sandboxMode:u,sendButtonLabel:Pa,sendButtonClassName:Ra,modelControlsDisabled:qi,effortControlsDisabled:Ki,effortControlTitle:Yi,forkTurnOptionsState:Z,skillsState:W,goalState:A,goalHistory:J,copiedSkillName:Li,hooksPanelMode:Xe,hooksState:F,hookConfigBusy:ut,hookConfigError:gn,hookConfigSuccess:Zl,editingHookTarget:pr,hookScope:Ue,hookEventName:it,hookMatcher:Et,hookCommand:jt,hookTimeoutSec:At,hookStatusMessage:Zt,mcpPanelMode:je,mcpState:re,mcpConfigPath:vi,mcpConfigError:wi,mcpConfigSuccess:yi,mcpConfigBusy:ki,mcpHttpName:gi,mcpHttpUrl:xi,mcpRawBlock:bi,capabilities:{hostConfigFiles:ce.hostConfigFiles,hookTrust:ce.hookTrust,mcpConfigEditing:ce.mcpConfigEditing,planMode:ce.planMode,sandboxMode:p?!1:ce.sandboxMode},shellControlState:E,onToggleView:Ne,onDismissPromptFocus:$t,onSetOpenMenu:I,onToolboxItemClick:Mi,onSetSlashPanelView:ae,onViewGoals:B,onUpdateGoal:K,onOpenForkTurns:()=>de==null?void 0:de(),onForkLatest:se,onForkTurn:Se,onCopySkillInvokeName:Ii,onResetHookForm:oi,onSetHooksPanelMode:Jl,onClearHookConfigStatus:Ca,onSetEditingHookTarget:Ql,onSetHookScope:ei,onSetHookEventName:ti,onSetHookMatcher:ri,onSetHookCommand:ni,onSetHookTimeoutSec:ai,onSetHookStatusMessage:si,onSaveHook:ii,onStartEditingHook:li,onTrustHook:di,onUntrustHook:ci,onSetMcpPanelMode:Ie,onClearMcpConfigStatus:Ta,onSetMcpHttpName:ji,onSetMcpHttpUrl:Ni,onSetMcpRawBlock:Ci,onPrepareRawMcpBlock:Si,onSaveHttpMcp:Ti,onSaveRawMcpBlock:Ei,onPickPhoto:()=>Ia("photo",Ye),onPickFile:()=>Ia("file",ft),onUpdateSettings:ne=>void te(ne),onPasteShell:()=>void $i(),onCopyShell:()=>{$t(),I(null),Ae==null||Ae()},onClearShell:()=>{$t(),I(null),ie({prompt:"clear"})},onShellControl:ne=>{$t(),I(null),Ge==null||Ge(ne)}}),{promptSlot:pd,goalSlot:fd,shellPromptSlot:gd}=Cp({isShellView:z,promptRef:We,prompt:De,disabled:C,promptPlaceholder:Vi,canInterrupt:Me,interruptLabel:Xi,composerPromptRegionClassName:dd,graphChatInputClassName:ud,promptInputClassName:cd,goalComposeMode:fr,goalTokenBudget:hi,goalLocalError:ui,goalBusy:xn,busy:n,sendButtonLabel:Pa,sendButtonClassName:Ra,onInterrupt:O,onPromptInput:Bi,onPromptPaste:Gi,onPromptKeyDown:Ui,onPromptKeyUp:()=>{Ze.current=Jt()},onPromptMouseUp:()=>{Ze.current=Jt()},onPromptBlur:()=>{Ze.current=Jt(),Qe(!1),bt&&vt()},onPromptDragEnter:Hi,onPromptDragOver:Fi,onPromptDragLeave:Oi,onPromptDrop:Wi,onGoalTokenBudgetChange:mi,onCancelGoal:Sa,onShellPromptChange:zi});return t.jsx(Fm,{activeView:e,layerClassName:Zi,formClassName:Ji,shellClassName:Qi,inputGroupClassName:hd,error:o,followTail:y,photoInputRef:Ye,fileInputRef:ft,onAppendAttachments:kn,onToggleFollow:we,canJumpToPreviousTurn:fe,onJumpToPreviousTurn:Te,canJumpToNextTurn:oe,onJumpToNextTurn:Q,subscriptionUsage:me,onSubmit:Di,formRef:qe,promptSlot:pd,pendingQueueSlot:!z&&Fe.length>0?t.jsx(Om,{prompts:Fe,onSteer:X,onCancel:he}):null,toolbarSlot:t.jsx(ap,{...md}),goalSlot:fd,shellPromptSlot:gd})}var Ep=c.createContext(null);function Sl(){return c.useContext(Ep)}function yt(e){return e?new Date(e).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"}):"Time unavailable"}function Xt(e){return e?new Date(e).toLocaleString():"Time unavailable"}function Lp(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 Ip(e){switch(e){case"idle":return"ui-status-neutral";case"running":return"ui-status-info";case"interrupted":return"ui-status-warning";case"failed":case"system_error":return"ui-status-danger";case"not_loaded":return"ui-status-neutral"}}function Tl(e){switch(e){case"sending":return"Sending";case"completed":return"Completed";case"interrupted":return"Interrupted";case"failed":return"Failed";case"inProgress":return"Running"}}function zp({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(m){m.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 Lr.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 Pp({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 Rp({children:e,roomsRailCollapsed:r,hideRoomsRail:n=!1}){return t.jsx("div",{className:`thread-shell-frame relative h-full min-h-0 ${n?"is-rail-hidden sm:grid-cols-[minmax(0,1fr)]":r?"is-rail-collapsed sm:grid-cols-[56px_minmax(0,1fr)]":"sm:grid-cols-[264px_minmax(0,1fr)]"}`,children:e})}function _p({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 Mp({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 Ap({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 $p({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 Dp({children:e}){return t.jsx("div",{className:"thread-split-region min-h-0 flex-1 overflow-hidden p-0 sm:p-2",children:e})}Wo();Mt();function js({...e}){return t.jsx(jd,{"data-slot":"dialog",...e})}function Ns({...e}){return t.jsx(Nd,{"data-slot":"dialog-trigger",...e})}function Bp({...e}){return t.jsx(Ld,{"data-slot":"dialog-portal",...e})}function Gp({className:e,...r}){return t.jsx(Id,{"data-slot":"dialog-overlay",className:st("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 Cs({children:e,className:r,showCloseButton:n=!0,...a}){return t.jsxs(Bp,{"data-slot":"dialog-portal",children:[t.jsx(Gp,{}),t.jsxs(Cd,{"data-slot":"dialog-content",className:st("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(Sd,{"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(P.XIcon,{}),t.jsx("span",{className:"sr-only",children:"Close"})]}):null]})]})}function Ss({className:e,...r}){return t.jsx("div",{"data-slot":"dialog-header",className:st("flex flex-col gap-2 text-center sm:text-left",e),...r})}function Ts({className:e,...r}){return t.jsx(Td,{"data-slot":"dialog-title",className:st("text-lg font-semibold leading-none",e),...r})}function Es({className:e,...r}){return t.jsx(Ed,{"data-slot":"dialog-description",className:st("text-sm text-muted-foreground",e),...r})}var Hp=[{value:"system",label:"Follow system",icon:P.Monitor},{value:"dark",label:"Dark",icon:P.Moon},{value:"light",label:"Light",icon:P.Sun}];function Fp({thread:e,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a={},onOpenThread:s,getThreadHref:o,renderThreadLink:l,onBeginRenameThread:i,onDeleteThread:d,showDeleteButton:h=!1,showSessionCopyButton:m=!1,collapsed:u=!1}){const[p,f]=c.useState("idle"),g=c.useRef(null),x=a[e.workspaceId],j=x&&!n?x:null,b=r===e.id;c.useEffect(()=>()=>{g.current!==null&&window.clearTimeout(g.current)},[]);async function k(){const N=e.providerSessionId;if(N)try{await navigator.clipboard.writeText(N),f("copied"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>f("idle"),1200)}catch{f("failed"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>f("idle"),1600)}}const y=()=>s(e.id),v=`thread-graph-room-card group flex w-full items-center gap-3 rounded-xl border text-left transition ${b?"is-active":""} ${u?"justify-center px-2 py-2":"px-3 py-2.5"}`,w=t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`thread-graph-room-card-icon flex h-8 w-8 shrink-0 items-center justify-center rounded-full ${b?"is-active":""}`,children:t.jsx(P.MessageSquare,{className:"h-4 w-4"})}),t.jsxs("div",{className:`min-w-0 flex-1 ${u?"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&&!u?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(P.Pencil,{className:"h-3 w-3"})}):null,m&&e.providerSessionId?t.jsx("button",{type:"button","aria-label":"Copy session ID",title:p==="copied"?"Copied":p==="failed"?"Copy failed":"Copy session ID",onClick:N=>{N.stopPropagation(),N.preventDefault(),k()},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:p==="copied"?t.jsx(P.Check,{className:"h-3.5 w-3.5"}):t.jsx(P.Copy,{className:"h-3.5 w-3.5"})}):null]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2",children:[j?t.jsx("p",{className:"thread-graph-room-card-meta min-w-0 flex-1 truncate text-[11px] text-[var(--theme-fg-muted)]",title:j,children:j}):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 ${Ip(e.status)}`,children:Lp(e.status)}),t.jsx("time",{className:"shrink-0 text-[11px] text-[var(--theme-fg-muted)]",dateTime:e.lastTurnStartedAt??e.updatedAt,children:yt(e.lastTurnStartedAt??e.updatedAt)})]})]}),h&&d&&!u?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(P.Trash2,{className:"h-3.5 w-3.5"})}):null]}),C=o==null?void 0:o(e.id);return l?t.jsx(t.Fragment,{children:l({thread:e,children:w,className:v,onClick:y})}):C?t.jsx("a",{href:C,onClick:N=>{N.preventDefault(),y()},title:u?e.title:void 0,className:v,children:w}):t.jsx("div",{role:"link",tabIndex:0,onClick:y,onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),y())},title:u?e.title:void 0,className:v,children:w})}function Op({threads:e,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a={},onOpenThread:s,getThreadHref:o,renderThreadLink:l,onBeginRenameThread:i,onDeleteThread:d,scrollable:h=!1,maxHeightClassName:m="max-h-full",showDeleteButton:u=!1,showSessionCopyButton:p=!1,collapsed:f=!1}){const g=h?`min-h-0 min-w-0 overflow-x-hidden overflow-y-auto overscroll-contain pr-1 ${m}`:"";return t.jsx("div",{className:g,children:t.jsx("div",{className:"min-w-0 space-y-1",children:e.map(x=>t.jsx(Fp,{thread:x,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a,onOpenThread:s,showDeleteButton:u,showSessionCopyButton:p,collapsed:f,...o?{getThreadHref:o}:{},...l?{renderThreadLink:l}:{},...i?{onBeginRenameThread:i}:{},...d?{onDeleteThread:d}:{}},x.id))})})}function Wp({threads:e,status:r,loading:n=!1,error:a,viewportConstrained:s=!1,layoutMode:o="responsive",effectiveTheme:l,themeMode:i,onThemeModeChange:d,showMobileNewThreadShortcut:h=!0,hideRoomsRail:m=!1,settingsDialogOpen:u,onSettingsDialogOpenChange:p,mobileHeaderAction:f,currentThreadId:g,currentThreadLabel:x=null,currentWorkspaceId:j=null,currentWorkspaceLabel:b=null,sessionLabel:k=null,usageLabel:y=null,threadActionsButton:v,topbarActions:w,metaContent:C,settingsContent:N,globalSettingsContent:E,workspaceLabels:R={},workspaceReturnHref:_,onWorkspaceReturn:Y,getThreadHref:W,onOpenThread:re,getNewThreadHref:F,newThreadHref:A,newThreadLabel:J="New Chat",onNewThread:Z,onNewThreadTitle:M,renderNewThreadDialogContent:ie,renderThreadLink:O,onCloseAppNavigation:G,onRenameThread:H,onDeleteThread:T,workspaceContent:$,workspaceTitle:D="Workspace",workspaceActions:L,workspaceRevealRequestKey:S,children:U}){const B=Sl(),le=typeof window<"u"?window.matchMedia("(max-width: 639px)").matches:o==="mobile",[K,de]=c.useState(()=>typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)").matches:!1),ee=i??(B==null?void 0:B.themeMode)??"system",ve=l??(B==null?void 0:B.effectiveTheme)??(ee==="system"?K?"dark":"light":ee),[be,ye]=c.useState(!1),[we,fe]=c.useState(!1),[Te,oe]=c.useState(!le),[Q,me]=c.useState(le),[ke,Ne]=c.useState("chat"),[Ae,Ge]=c.useState(null),[Me,Fe]=c.useState(""),[X,he]=c.useState(null),[Ce,I]=c.useState(!1),[V,ae]=c.useState(""),[ge,je]=c.useState(!1),[Ie,ce]=c.useState(!1),[He,qe]=c.useState("session");c.useEffect(()=>{S!==void 0&&(oe(!1),Ne("workspace"))},[S]),c.useEffect(()=>{if(typeof window>"u")return;const se=window.matchMedia("(max-width: 639px)"),Se=()=>{me(se.matches)};return Se(),se.addEventListener("change",Se),()=>{se.removeEventListener("change",Se)}},[]),c.useEffect(()=>{if(typeof window>"u")return;const se=window.matchMedia("(prefers-color-scheme: dark)"),Se=()=>{de(se.matches)};return Se(),se.addEventListener("change",Se),()=>{se.removeEventListener("change",Se)}},[]);const We=c.useMemo(()=>[...j?e.filter(Se=>Se.workspaceId===j):e].sort((Se,Xe)=>{if(Se.id===g)return-1;if(Xe.id===g)return 1;const Ue=Date.parse(Se.lastTurnStartedAt??Se.updatedAt);return Date.parse(Xe.lastTurnStartedAt??Xe.updatedAt)-Ue}),[g,j,e]),Ye=A??(F==null?void 0:F(j)),ft=b??j??"all",rt=k??x??g??"default_session",ct=y??(r!=null&&r.state?`runtime ${r.state}`:"waiting for agent usage"),Ze=d??(B==null?void 0:B.setThemeMode),pt=!!Ze,ot=()=>{ye(!1),G==null||G()};async function z(se){if(!H)return;const Se=Me.trim();if(Se){he(se);try{await H(se,Se),Ge(null),Fe("")}finally{he(null)}}}function q(se){Ge(se.id),Fe(se.title)}function xe(){Ge(null),Fe("")}function Ee(se){re==null||re(se),ot()}function $e(){I(!1),ae("")}function Qe(se){if(!Ye||!se.trim())return Ye;try{const Se=new URL(Ye,window.location.origin);return Se.searchParams.set("title",se.trim()),`${Se.pathname}${Se.search}${Se.hash}`}catch{const Se=Ye.includes("?")?"&":"?";return`${Ye}${Se}title=${encodeURIComponent(se.trim())}`}}async function nt(){const se=V.trim();je(!0);try{if(se&&M){await M(se),ae(""),I(!1),ot();return}if(Ye){window.location.assign(Qe(se)??Ye);return}await(Z==null?void 0:Z()),ae(""),I(!1),ot()}finally{je(!1)}}function Ve(se,Se=!1){const Xe=Se?t.jsxs(t.Fragment,{children:[t.jsx(P.Plus,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:J})]}):t.jsxs(t.Fragment,{children:[t.jsx(P.Plus,{className:"h-4 w-4"}),t.jsx("span",{children:J})]});return t.jsxs(js,{open:Ce,onOpenChange:Ue=>{ge||I(Ue)},children:[t.jsx(Ns,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":Se?J:void 0,title:J,className:se,children:Xe})}),t.jsx(Cs,{"data-testid":"create-thread-dialog","data-theme-effective":ve,"data-theme-mode":ee,className:"thread-graph-create-thread-dialog thread-graph-dialog max-h-[min(86vh,42rem)] overflow-hidden p-4 sm:max-w-[34rem]",children:ie?ie({close:$e,closeNavigation:ot,currentWorkspaceId:j}):t.jsxs(t.Fragment,{children:[t.jsxs(Ss,{children:[t.jsx(Ts,{children:"Create New Chat"}),t.jsx(Es,{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:V,onChange:Ue=>ae(Ue.target.value),onKeyDown:Ue=>{Ue.key==="Enter"&&(Ue.preventDefault(),nt())},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 nt(),disabled:ge,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:ge?"Creating...":"Create"})]})]})})]})}function De(){if(!N&&!C&&!E&&!pt)return null;const se=!!(N||C),Se=!!E,Xe=se&&Se,Ue=He==="global"&&Se||!se&&Se?"global":"session";return t.jsxs(js,{...u!==void 0?{open:u}:{},...p?{onOpenChange:p}:{},children:[t.jsx(Ns,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":"Open settings",title:"Settings",className:"thread-icon-button inline-flex h-10 w-10 items-center justify-center rounded-full sm:h-9 sm:w-9",children:t.jsx(P.Settings,{className:"h-4 w-4"})})}),t.jsxs(Cs,{"data-testid":"settings-dialog","data-theme-effective":ve,"data-theme-mode":ee,className:"thread-graph-settings-dialog thread-graph-dialog",children:[t.jsxs(Ss,{children:[t.jsx(Ts,{children:"Settings"}),t.jsx(Es,{children:"Manage this session and host-wide preferences."})]}),pt?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: ",ve]})]}),t.jsx("div",{className:"thread-graph-theme-mode-group grid grid-cols-3 gap-1 rounded-lg border p-1",role:"group","aria-label":"Theme mode",children:Hp.map(it=>{const Et=it.icon,jt=ee===it.value;return t.jsxs("button",{type:"button","data-testid":`theme-mode-${it.value}`,"aria-pressed":jt,disabled:!pt,onClick:()=>Ze==null?void 0:Ze(it.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 ${jt?"is-selected":""}`,children:[t.jsx(Et,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:"truncate",children:it.label})]},it.value)})})]})}):null,Xe?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":Ue==="session",onClick:()=>qe("session"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Ue==="session"?"is-active":""}`,children:"Session"}),t.jsx("button",{type:"button","aria-pressed":Ue==="global",onClick:()=>qe("global"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Ue==="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:Ue==="session"?t.jsxs("div",{className:"grid gap-4",children:[N?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:N}):null,C?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:C}):null,se?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:E})})]})]})}function ht(se=!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)] ${se?"justify-center":""}`,children:[t.jsx(P.Rows3,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:se?"sr-only":"",children:"Rooms"}),!se&&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&&We.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,We.length>0?t.jsx(Op,{threads:We,currentThreadId:g,currentWorkspaceId:j,workspaceLabels:R,onOpenThread:Ee,collapsed:se,...H?{onBeginRenameThread:q}:{},showDeleteButton:!!T,...W?{getThreadHref:W}:{},...O?{renderThreadLink:O}:{},...T?{onDeleteThread:T}:{}}):null]})]})})}function bt(){return $?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:()=>oe(!0),className:"thread-workspace-collapse-tab thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(P.ChevronsRight,{className:"h-4 w-4"})}),L?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:L})}):null,t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:$})]}):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:D}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:b??j??"Current context"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[L,t.jsx("button",{type:"button",onClick:()=>oe(!0),className:"thread-workspace-small-toggle thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(P.ChevronsRight,{className:"h-4 w-4"})})]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:$??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:b??j??"All threads"})]})]})})]})}const at=!!$,vt=o==="mobile"||o==="responsive"&&Q,lt=vt,Tt=lt&&!be,Re=!!(_||Y)?t.jsx("a",{href:_??"#",onClick:se=>{Y&&(se.preventDefault(),Y())},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(P.ArrowLeft,{className:"h-4 w-4"})}):null;return t.jsxs(t.Fragment,{children:[t.jsx(Pp,{effectiveTheme:ve,layoutMode:o,themeMode:ee,viewportConstrained:s,children:t.jsxs(Rp,{roomsRailCollapsed:we,hideRoomsRail:m,children:[m?null:t.jsx(_p,{open:be,onClose:()=>ye(!1)}),m?null:t.jsxs(Mp,{collapsed:we,mobileOpen:be,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 ${we?"sm:w-full sm:justify-center sm:px-2":""}`,children:t.jsxs("div",{className:`flex w-full items-center gap-3 ${we?"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:()=>fe(se=>!se),className:"thread-icon-button thread-desktop-only-flex h-9 w-9 shrink-0 items-center justify-center rounded-full",title:we?"Expand rooms":"Collapse rooms","aria-label":we?"Expand rooms":"Collapse rooms",children:we?t.jsx(P.PanelLeftOpen,{className:"h-4 w-4"}):t.jsx(P.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)] ${we?"thread-desktop-collapsed-hidden":""}`,children:(b??"R").charAt(0).toUpperCase()}),t.jsxs("div",{className:`min-w-0 ${we?"thread-desktop-collapsed-hidden":""}`,children:[t.jsx("p",{className:"truncate text-sm font-semibold text-[var(--theme-fg)]",children:b??"Remote Codex"}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:j??"Thread workspace"})]})]}),t.jsxs("div",{className:`flex shrink-0 items-center gap-1 ${we?"thread-desktop-collapsed-hidden":""}`,children:[De(),Re,t.jsx("button",{type:"button",onClick:()=>ye(!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(P.X,{className:"h-4 w-4"})})]})]})}),t.jsx("div",{className:`thread-graph-new-room-strip flex shrink-0 items-center border-b ${we?"h-12 w-full justify-center px-2 sm:h-12":"h-[68px] px-4"}`,children:Ve(`thread-graph-new-room-button inline-flex items-center justify-center rounded-xl font-medium transition ${we?"h-9 w-9 p-0":"h-11 w-full gap-2 px-3 text-sm sm:h-9"}`,we)}),t.jsx("div",{className:`flex min-h-0 flex-1 flex-col ${we?"w-full px-2 py-2":"px-3 py-3"}`,children:ht(we)})]}),t.jsxs(Ap,{children:[t.jsx($p,{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:[Tt&&!m?t.jsx("button",{type:"button",onClick:()=>ye(!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(P.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:x??"Shared Workspace",children:x??"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:()=>{ce(se=>!se)},"aria-expanded":Ie,"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:ft})]}),Ie?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 se;rt&&((se=navigator.clipboard)==null||se.writeText(rt))},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:rt})]}),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:ct})]})]}):null]})]})]}),t.jsxs("div",{className:"relative z-[1] inline-flex shrink-0 items-center gap-2",children:[v||w?t.jsxs("div",{className:"thread-graph-topbar-actions thread-desktop-only-inline-flex items-center rounded-lg border p-0.5 shadow-none",children:[v,w]}):null,lt&&v?t.jsx("div",{className:"thread-mobile-only-inline-flex",children:v}):null,lt&&at?t.jsx("button",{type:"button",onClick:()=>Ne(se=>se==="workspace"?"chat":"workspace"),"aria-label":ke==="workspace"?"Show chat":"Show workspace",title:ke==="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:ke==="workspace"?t.jsx(P.MessageSquare,{className:"h-4 w-4"}):t.jsx(P.Folder,{className:"h-4 w-4"})}):null,lt?f:null,lt&&h&&!m?Ve("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(Dp,{children:at&&!Te?vt?t.jsxs("div",{className:"thread-split-container thread-graph-shell-mobile-split h-full min-h-0 overflow-hidden",children:[t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${ke==="chat"?"block":"thread-mobile-chat-hidden"}`,children:U}),t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${ke==="workspace"?"block":"thread-mobile-workspace-hidden"}`,children:bt()})]}):t.jsxs(Fn,{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(lr,{defaultSize:47,minSize:30,maxSize:75,className:"thread-split-chat-pane min-w-0 overflow-hidden",children:U}),t.jsx(On,{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(lr,{defaultSize:53,minSize:30,maxSize:70,className:"thread-split-workspace-pane min-w-0 overflow-hidden",children:bt()})]}):t.jsxs("div",{className:"thread-split-container relative h-full min-h-0 overflow-hidden",children:[at&&Te?t.jsx("button",{type:"button",onClick:()=>oe(!1),className:"thread-workspace-expand-fab thread-desktop-only-inline-flex",title:"Expand workspace","aria-label":"Expand workspace",children:t.jsx(P.ChevronsLeft,{className:"h-4 w-4"})}):null,U]})})]})]})}),t.jsx(zp,{open:Ae!==null,title:"Rename Thread",label:"Thread Title",value:Me,busy:X!==null,onChange:Fe,onCancel:xe,onSubmit:()=>Ae?z(Ae):void 0})]})}function Up({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?Lr.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[90] flex items-center justify-center p-4 sm:p-6",children:[t.jsx("button",{type:"button","aria-label":"Close full text",onClick:a,className:"absolute inset-0 bg-stone-950/78 backdrop-blur-sm"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":r,className:"relative z-[1] flex max-h-[min(82vh,52rem)] w-full max-w-4xl flex-col overflow-hidden rounded-[1.8rem] border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-stone-800 px-4 py-3 sm:px-5",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:r}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:a,className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-stone-700 text-stone-300 transition hover:bg-stone-800",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-4 py-4 sm:px-5",children:t.jsx("pre",{className:"whitespace-pre-wrap break-words text-sm leading-6 text-stone-200",children:n})})]})]}),document.body):null}var Vp=[/^(?: {0,3})#{1,6}\s+\S/m,/^(?: {0,3})>{1,}\s*\S/m,/^(?: {0,3})(?:[-+*]|\d{1,9}[.)])\s+(?:\[[ xX]\]\s+)?\S/m,/^(?: {0,3})(?:```|~~~)/m,/^(?: {0,3})(?:[-*_]\s*){3,}$/m],Xp=/^(?:\|?[^|\n]+\|[^|\n]+(?:\|[^|\n]+)*\|?\s*\n\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$)/m,qp=/!?\[[^\]\n]+\]\([^)]+\)/,Kp=/`[^`\n]+`/,Yp=/(?:\*\*[^*\n]+\*\*|__[^_\n]+__)/,Zp=/(^|[^\w])(?:\*[^*\n]+\*|_[^_\n]+_)(?=[^\w]|$)/,Jp=/~~[^~\n]+~~/;function Qp(e){const r=e.trim();return r?Vp.some(n=>n.test(r))||Xp.test(r)?!0:/[`[\]*_~!]/.test(r)?qp.test(r)||Kp.test(r)||Yp.test(r)||Zp.test(r)||Jp.test(r):!1:!1}cn();function ra(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 va(e=[]){const r=ra(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 ka=c.createContext(va());function wa(){return c.useContext(ka)??va()}_r();function El(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ls(e){return El(e)?Object.entries(e):e==null||e===""?[]:[["value",e]]}function Ll(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 ef(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)}):Ll(r)}function Is({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(P.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"};case"failed":return{className:"is-failed",icon:t.jsx(P.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"};default:return{className:"is-pending",icon:t.jsx(P.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),label:"Running"}}},[n]),l=c.useMemo(()=>Ls(s),[s]),i=c.useMemo(()=>Ls(a),[a]),d=c.useMemo(()=>typeof s=="string"?s.length>0:El(s)?["stdout","stderr","result"].some(p=>{const f=s[p];return typeof f=="string"&&f.length>0}):!1,[s]),h=n==="pending"||d,[m,u]=c.useState(h?"item-1":void 0);return c.useEffect(()=>{h&&u("item-1")},[e,h]),t.jsx("div",{className:"thread-graph-tool-call my-2 w-full font-sans not-prose",children:t.jsx(zr,{type:"single",collapsible:!0,onValueChange:p=>u(p||void 0),className:"thread-graph-tool-accordion w-full overflow-hidden rounded-lg border",...m!==void 0?{value:m}:{},children:t.jsxs(Pr,{value:"item-1",className:"border-0",children:[t.jsx(hn,{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(P.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(Rr,{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(([p,f],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',p,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),Ll(f),g<i.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},p)):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(([p,f],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',p,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),ef(p,f),g<l.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},p)),"}"]})]}):null]})]})})})}Vo();function un(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function na(e){if(!e)return{};if(un(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 aa(){return{finalResult:null,stdout:"",stderr:""}}function tf(e){return typeof e=="string"?{result:e}:e}function Il(e){const r=un(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 zs(e){if(!e)return"pending";if(!un(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 rf(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 m=tf(d.result),u=r.get(h)??aa();return un(m)&&m.status==="stream"&&typeof m.chunk=="string"?m.stream==="stderr"?u.stderr+=m.chunk:u.stdout+=m.chunk:u.finalResult=m,r.set(h,u),""}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,m=d.tool;if(typeof m!="string")return l;const u=na(d.args);if(typeof h=="string"&&r.has(h)){const p=Il(r.get(h)??aa());return`\`\`\`tool-merged
|
|
3951
|
+
`,Cs="MCP entry written to provider config. Restart the backend if it does not appear immediately.";function bp({hostConfigFilesAvailable:e,onReadProviderConfig:r,onWriteProviderConfig:n,setMcpPanelMode:a,onOpenMcp:s}){const[o,l]=c.useState(""),[i,d]=c.useState(""),[h,m]=c.useState(""),[u,p]=c.useState(null),[f,g]=c.useState(!1),[b,j]=c.useState(null),[x,k]=c.useState(null),w=c.useCallback(()=>{j(null),k(null)},[]),v=c.useCallback(async()=>{if(!e||!r)throw new Error("Provider config editing is unavailable for this thread.");const M=await r();return p(M.path),M},[e,r]),y=c.useCallback(async M=>{if(!e||!n)throw new Error("Provider config editing is unavailable for this thread.");const A=await n(M);return p(A.path),A},[e,n]),N=c.useCallback(async()=>{const M=rm(o),A=i.trim();if(!M){j("MCP name must use only letters, numbers, underscore, or hyphen.");return}if(!/^https?:\/\//i.test(A)){j("HTTP MCP URL must start with http:// or https://");return}g(!0),j(null),k(null);try{const J=await v(),W=bs(J.content,M,am(M,A));await y(W),k(Cs),a("list"),l(""),d(""),s==null||s()}catch(J){j(J instanceof Error?J.message:"Unable to update provider config.")}finally{g(!1)}},[v,o,i,s,a,y]),S=c.useCallback(async()=>{g(!0),j(null),k(null);try{await v(),m(M=>M||xp),a("stdio")}catch(M){j(M instanceof Error?M.message:"Unable to load provider config.")}finally{g(!1)}},[v,a]),T=c.useCallback(async()=>{const M=nm(h);if(!M){j("The raw MCP block must start with a header like [mcp_servers.name].");return}g(!0),j(null),k(null);try{const A=await v(),J=bs(A.content,M,h);await y(J),k(Cs),a("list"),s==null||s()}catch(A){j(A instanceof Error?A.message:"Unable to update provider config.")}finally{g(!1)}},[v,h,s,a,y]);return{mcpHttpName:o,mcpHttpUrl:i,mcpRawBlock:h,mcpConfigPath:u,mcpConfigBusy:f,mcpConfigError:b,mcpConfigSuccess:x,setMcpHttpName:l,setMcpHttpUrl:d,setMcpRawBlock:m,clearMcpConfigStatus:w,prepareRawMcpBlock:S,saveHttpMcp:N,saveRawMcpBlock:T}}function vp({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 m=window.setTimeout(()=>{d(u=>u===i?null:u)},1400);return()=>{window.clearTimeout(m)}},[i]),c.useEffect(()=>{function m(u){(typeof u.composedPath=="function"?u.composedPath():[]).some(g=>g instanceof HTMLElement&&(g.dataset.composerMenuSurface==="true"||g.dataset.composerMenuTrigger==="true"))||e&&r(null)}if(e)return window.addEventListener("pointerdown",m),()=>{window.removeEventListener("pointerdown",m)}},[e,r]);const h=c.useCallback(async m=>{try{await navigator.clipboard.writeText(`$${m}`),d(m)}catch{d(null)}},[]);return{copiedSkillName:i,copySkillInvokeName:h}}function kp(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=ks(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=ks(n),a.append(s,o),a}function wp(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(kp(a,r))}return n}function yp({promptRef:e,isShellView:r,prompt:n,promptSegments:a,attachmentPreviewUrls:s,previewSignature:o,editorSanitizeNonce:l,pendingSelectionRef:i,pendingInsertedAttachmentIdsRef:d,selectionSnapshotRef:h,renderedPreviewSignatureRef:m,renderedSanitizeNonceRef:u,serializeEditorPrompt:p,restoreSelection:f}){c.useLayoutEffect(()=>{const g=e.current;if(!g||r)return;const b=i.current,j=p()!==n||m.current!==o||u.current!==l;j&&(g.replaceChildren(wp(a,s)),m.current=o,u.current=l),b!==null?(g.focus(),Am(g,d.current)||f(b),h.current=b):document.activeElement===g&&j&&f(h.current),i.current=null,d.current=[]},[s,l,r,o,n,e,a,d,i,m,u,f,h,p])}function jp({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 Cp({promptRef:e,prompt:r,disabled:n,promptPlaceholder:a,canInterrupt:s,interruptLabel:o,composerPromptRegionClassName:l,graphChatInputClassName:i,onInterrupt:d,onInput:h,onPointerDown:m,onPaste:u,onKeyDown:p,onKeyUp:f,onMouseUp:g,onBlur:b,onDragEnter:j,onDragOver:x,onDragLeave:k,onDrop:w}){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:v=>{!n&&document.activeElement!==v.currentTarget&&Np()&&v.currentTarget.focus({preventScroll:!0}),m==null||m(v)},onInput:h,onPaste:u,onKeyDown:p,onKeyUp:f,onMouseUp:g,onBlur:b,onDragEnter:j,onDragOver:x,onDragLeave:k,onDrop:w,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(St,{type:"button",variant:"ghost",size:"icon-xs","aria-label":o,title:o,onClick:v=>{v.preventDefault(),d==null||d()},className:"thread-graph-composer-stop-button ui-action-danger absolute right-2 top-2 z-30 h-8 w-8 rounded-full text-sm font-medium",children:t.jsx("span",{"aria-hidden":"true",className:"block h-2.5 w-2.5 rounded-[2px] bg-current"})}):null]})}function Sp({prompt:e,promptPlaceholder:r,promptRegionClassName:n,promptInputClassName:a,interruptLabel:s,canInterrupt:o,sendButtonLabel:l,sendButtonClassName:i,sendDisabled:d,onPromptChange:h,onPromptKeyDown:m,onInterrupt:u}){return t.jsxs("div",{className:`${n} relative`,children:[t.jsx("textarea",{"aria-label":"Prompt",disabled:!1,value:e,onChange:p=>h(p.target.value),onKeyDown:m,rows:2,placeholder:r,className:`${a} resize-y pb-10`}),t.jsx("button",{type:"button","aria-label":s,title:s,onClick:()=>void(u==null?void 0:u()),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:p=>{p.preventDefault()},onPointerDown:p=>{p.preventDefault()},onTouchStart:p=>{p.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:m,goalTokenBudget:u,goalLocalError:p,goalBusy:f,busy:g,sendButtonLabel:b,sendButtonClassName:j,onInterrupt:x,onPromptInput:k,onPromptPaste:w,onPromptKeyDown:v,onPromptKeyUp:y,onPromptMouseUp:N,onPromptBlur:S,onPromptDragEnter:T,onPromptDragOver:M,onPromptDragLeave:A,onPromptDrop:J,onGoalTokenBudgetChange:W,onCancelGoal:re,onShellPromptChange:O}){return{promptSlot:e?null:t.jsx(Cp,{promptRef:r,prompt:n,disabled:a,promptPlaceholder:s,canInterrupt:o,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,onInterrupt:x,onInput:k,onPaste:w,onKeyDown:v,onKeyUp:y,onMouseUp:N,onBlur:S,onDragEnter:T,onDragOver:M,onDragLeave:A,onDrop:J}),goalSlot:m&&!e?t.jsx(jp,{tokenBudget:u,error:p,onTokenBudgetChange:W,onCancel:re}):null,shellPromptSlot:e?t.jsx(Sp,{prompt:n,promptPlaceholder:s,promptRegionClassName:i,promptInputClassName:h,interruptLabel:l,canInterrupt:o,sendButtonLabel:b,sendButtonClassName:j,sendDisabled:f||g,onPromptChange:O,onPromptKeyDown:v,onInterrupt:x}):null}}function Ep({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=Qu({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 Lp({isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:s,toolbarClassName:o,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:m,inlineToggleClassName:u,planToggleActiveClassName:p,sendButtonBaseClassName:f,slashPanelView:g,availableToolboxItems:b,busy:j,settingsBusy:x,compactBusy:k,forkBusy:w,fastMode:v,goalComposeMode:y,goalBusy:N,goalStatus:S,activeView:T,disabled:M,model:A,agentLabel:J,modelOptions:W,modelContextTitle:re,contextUsage:O,reasoningEffort:P,supportedEfforts:Y,displayedCollaborationMode:Z,sandboxMode:_,sendButtonLabel:ie,sendButtonClassName:H,modelControlsDisabled:B,effortControlsDisabled:F,effortControlTitle:E,forkTurnOptionsState:D,skillsState:$,goalState:L,goalHistory:C,copiedSkillName:U,hooksPanelMode:G,hooksState:le,hookConfigBusy:ee,hookConfigError:ce,hookConfigSuccess:q,editingHookTarget:ve,hookScope:ke,hookEventName:je,hookMatcher:ye,hookCommand:fe,hookTimeoutSec:Te,hookStatusMessage:oe,mcpPanelMode:Q,mcpState:me,mcpConfigPath:we,mcpConfigError:Ce,mcpConfigSuccess:Me,mcpConfigBusy:Be,mcpHttpName:Ae,mcpHttpUrl:He,mcpRawBlock:X,capabilities:he,shellControlState:Se,onToggleView:I,onDismissPromptFocus:V,onSetOpenMenu:se,onToolboxItemClick:ge,onSetSlashPanelView:Ne,onViewGoals:Le,onUpdateGoal:de,onOpenForkTurns:Ge,onForkLatest:qe,onForkTurn:Ue,onCopySkillInvokeName:Ye,onResetHookForm:pt,onSetHooksPanelMode:rt,onClearHookConfigStatus:lt,onSetEditingHookTarget:Ze,onSetHookScope:mt,onSetHookEventName:it,onSetHookMatcher:z,onSetHookCommand:K,onSetHookTimeoutSec:be,onSetHookStatusMessage:Pe,onSaveHook:Oe,onStartEditingHook:Fe,onTrustHook:nt,onUntrustHook:Ve,onSetMcpPanelMode:$e,onClearMcpConfigStatus:at,onSetMcpHttpName:wt,onSetMcpHttpUrl:st,onSetMcpRawBlock:xt,onPrepareRawMcpBlock:dt,onSaveHttpMcp:Tt,onSaveRawMcpBlock:Et,onPickPhoto:te,onPickFile:ne,onUpdateSettings:xe,onPasteShell:Xe,onCopyShell:_e,onClearShell:tt,onShellControl:Lt}){const yt=e?null:{open:s==="slash",slashPanelView:g,availableToolboxItems:b,busy:j,forkBusy:w,forkTurnOptionsState:D,skillsState:$,goalState:L,goalHistory:C,goalBusy:N,copiedSkillName:U,hooksPanelMode:G,hooksState:le,hostConfigFilesAvailable:he.hostConfigFiles,hookTrustAvailable:he.hookTrust,hookConfigBusy:ee,hookConfigError:ce,hookConfigSuccess:q,editingHookTarget:ve,hookScope:ke,hookEventName:je,hookMatcher:ye,hookCommand:fe,hookTimeoutSec:Te,hookStatusMessage:oe,mcpPanelMode:Q,mcpState:me,mcpConfigEditing:he.mcpConfigEditing,mcpConfigPath:we,mcpConfigError:Ce,mcpConfigSuccess:Me,mcpConfigBusy:Be,mcpHttpName:Ae,mcpHttpUrl:He,mcpRawBlock:X,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:m,onToggle:()=>se(ht=>ht==="slash"?null:"slash"),onToolboxItemClick:ge,toolboxItemDisabled:ht=>Em(ht,{settingsBusy:x,compactBusy:k,busy:j,forkBusy:w}),toolboxItemClassName:ht=>Lm(ht,{fastMode:v,goalComposeMode:y,goalStatus:S,menuItemClassName:d}),toolboxItemStatus:ht=>Tm(ht,{fastMode:v,compactBusy:k,goalComposeMode:y,goalStatus:S,busy:j}),onSetSlashPanelView:Ne,onViewGoals:Le,onUpdateGoal:de,onOpenForkTurns:Ge,onForkLatest:qe,onForkTurn:Ue,onCopySkillInvokeName:Ye,onResetHookForm:pt,onSetHooksPanelMode:rt,onClearHookConfigStatus:lt,onSetEditingHookTarget:Ze,onSetHookScope:mt,onSetHookEventName:it,onSetHookMatcher:z,onSetHookCommand:K,onSetHookTimeoutSec:be,onSetHookStatusMessage:Pe,onSaveHook:Oe,onStartEditingHook:Fe,onTrustHook:nt,onUntrustHook:Ve,onSetMcpPanelMode:$e,onClearMcpConfigStatus:at,onSetMcpHttpName:wt,onSetMcpHttpUrl:st,onSetMcpRawBlock:xt,onPrepareRawMcpBlock:dt,onSaveHttpMcp:Tt,onSaveRawMcpBlock:Et},jt=e?null:{open:s==="attachments",iconButtonClassName:l,menuClassName:i,menuItemClassName:d,onToggle:()=>se(ht=>ht==="attachments"?null:"attachments"),onPickPhoto:te,onPickFile:ne},$t=e?null:{openMenu:s,model:A,agentLabel:J,modelOptions:W,modelContextTitle:re,contextUsage:O,reasoningEffort:P,supportedEfforts:Y,displayedCollaborationMode:Z,sandboxMode:_,planModeAvailable:he.planMode,sandboxModeAvailable:he.sandboxMode,settingsBusy:x,goalComposeMode:y,goalBusy:N,activeView:T,disabled:M,fastMode:v,sendButtonLabel:ie,sendButtonClassName:H,modelControlsDisabled:B,effortControlsDisabled:F,effortControlTitle:E,inlineToggleClassName:u,menuItemClassName:d,planToggleActiveClassName:p,sendButtonBaseClassName:f,onSetOpenMenu:se,onUpdateSettings:xe};return{isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:s,toolbarClassName:o,iconButtonClassName:l,slashToolboxProps:yt,attachmentMenuProps:jt,settingsToolbarProps:$t,shellToolsPanelProps:s==="shellTools"?{busy:j,shellControlState:Se,onPaste:Xe,onCopy:_e,onClear:tt,onShellControl:Lt}:null,shellControlState:Se,onToggleView:I,onDismissPromptFocus:V,onSetOpenMenu:se}}function aa({activeView:e,edgeToEdgeMobile:r=!1,busy:n=!1,settingsBusy:a=!1,compactBusy:s=!1,error:o,model:l=null,agentLabel:i=null,reasoningEffort:d=null,fastMode:h=!1,collaborationMode:m="default",sandboxMode:u=null,hideSandboxModeControl:p=!1,modelOptions:f=[],contextUsage:g=null,capabilities:b=null,toolboxItems:j=null,hookCommandTemplates:x=null,mcpConfigFormat:k="none",followTail:w=!1,threadConnected:v=!0,shellAvailable:y=!0,disabled:N=!1,disabledPlaceholder:S,shellControlState:T=null,draftPrompt:M,draftAttachments:A,onPickAttachment:J,skillsState:W={status:"idle",data:null,error:null},mcpState:re={status:"idle",data:null,error:null},hooksState:O={status:"idle",data:null,error:null},goalState:P={status:"idle",data:null,error:null},goalHistory:Y=[],forkTurnOptionsState:Z={status:"idle",data:null,error:null},onDraftChange:_,onSubmit:ie,onInterrupt:H,onCompact:B,onOpenSkills:F,onOpenMcp:E,onOpenHooks:D,onCreateHook:$,onUpdateHook:L,onTrustHook:C,onUntrustHook:U,onOpenGoal:G,onPrepareGoalSubmit:le,onUpdateGoal:ee,onOpenForkTurns:ce,onForkLatest:q,onForkTurn:ve,onReadProviderConfig:ke,onWriteProviderConfig:je,onToggleFollow:ye,canJumpToPreviousTurn:fe,onJumpToPreviousTurn:Te,canJumpToNextTurn:oe,onJumpToNextTurn:Q,subscriptionUsage:me,onUpdateSettings:we,onToggleView:Ce,onShellCopy:Me,onShellControl:Be,canInterrupt:Ae=!1,pendingPrompts:He=[],onSteerPendingPrompt:X,onCancelPendingPrompt:he}){var $a;const[Se,I]=c.useState(null),[V,se]=c.useState("root"),ge=c.useRef(!1),[Ne,Le]=c.useState("list"),de=c.useMemo(()=>({fast:(b==null?void 0:b.controls.performanceMode)??!1,compact:(b==null?void 0:b.turns.compact)??!1,goal:(b==null?void 0:b.controls.goals)??!1,fork:(b==null?void 0:b.branching.fork)??!1,skills:(b==null?void 0:b.management.skills)??!1,mcp:(b==null?void 0:b.management.mcpStatus)??!1,hooks:(b==null?void 0:b.management.hooks)??!1,hostConfigFiles:(b==null?void 0:b.management.hostConfigFiles)??!1,mcpConfigEditing:k==="codex-toml"&&!!(b!=null&&b.management.hostConfigFiles)&&!!ke&&!!je,hookTrust:(b==null?void 0:b.management.hookTrust)??!1,planMode:(b==null?void 0:b.controls.planMode)??!1,sandboxMode:(b==null?void 0:b.controls.sandboxMode)??!1}),[b,k,ke,je]),Ge=c.useMemo(()=>Cm(j,de),[de,j]),qe=c.useRef(null),Ue=c.useRef(null),Ye=c.useRef(null),pt=c.useRef(null),rt=c.useRef(null),lt=c.useRef([]),Ze=c.useRef(null),mt=c.useRef(""),it=c.useRef(0),z=e==="shell",K=y||z,be=!!(z&&(T!=null&&T.isMobileShell)),Pe=(T==null?void 0:T.promptLabel)??null,[Oe,Fe]=c.useState(!1),[nt,Ve]=c.useState(0),{prompt:$e,attachments:at,isDraftControlled:wt,updateDraft:st,flushControlledDraftToHost:xt}=up({isShellView:z,draftPrompt:M,draftAttachments:A,onDraftChange:_}),dt=cp({attachments:at,isShellView:z}),{displayedCollaborationMode:Tt,updateSettings:Et}=Ep({collaborationMode:m,onUpdateSettings:we,closeMenu:()=>I(null)}),{forkBusy:te,forkLatest:ne,forkTurn:xe}=mp({slashPanelView:V,onForkLatest:q,onForkTurn:ve,closeMenu:()=>I(null)}),{hooksPanelMode:Xe,hookScope:_e,hookEventName:tt,hookMatcher:Lt,hookCommand:yt,hookTimeoutSec:jt,hookStatusMessage:$t,editingHookTarget:Jt,hookConfigBusy:ht,hookConfigError:Mr,hookConfigSuccess:xn,setHooksPanelMode:bn,setEditingHookTarget:ti,setHookScope:ri,setHookEventName:ni,setHookMatcher:ai,setHookCommand:si,setHookTimeoutSec:oi,setHookStatusMessage:li,clearHookConfigStatus:Ea,resetHookForm:ii,startEditingHook:di,saveHook:ci,trustHook:hi,untrustHook:ui}=gp({slashPanelView:V,hookCommandTemplates:x,onCreateHook:$,onUpdateHook:L,onTrustHook:C,onUntrustHook:U}),{goalComposeMode:fr,goalTokenBudget:mi,goalBusy:vn,goalLocalError:pi,setGoalTokenBudget:fi,submitGoal:gi,enterGoalComposeMode:xi,exitGoalComposeMode:La}=pp({prompt:$e,goalTokenBudgetSource:P.data,promptRef:Ue,onOpenGoal:G,onPrepareGoalSubmit:le,onUpdateGoal:ee,updateDraft:st,closeMenu:()=>I(null),resetSlashPanel:()=>se("root")}),{mcpHttpName:bi,mcpHttpUrl:vi,mcpRawBlock:ki,mcpConfigPath:wi,mcpConfigBusy:yi,mcpConfigError:ji,mcpConfigSuccess:Ni,setMcpHttpName:Ci,setMcpHttpUrl:Si,setMcpRawBlock:Ti,clearMcpConfigStatus:Ia,prepareRawMcpBlock:Ei,saveHttpMcp:Li,saveRawMcpBlock:Ii}=bp({hostConfigFilesAvailable:de.hostConfigFiles,onReadProviderConfig:ke,onWriteProviderConfig:je,setMcpPanelMode:Le,onOpenMcp:E}),{copiedSkillName:zi,copySkillInvokeName:Pi}=vp({openMenu:Se,setOpenMenu:I,slashPanelView:V,setSlashPanelView:se,setMcpPanelMode:Le,clearMcpConfigStatus:Ia,clearHookConfigStatus:Ea}),Ri=c.useCallback(ae=>{st(Ee=>{if(typeof ae=="function"){const Re=ae(Ee.prompt,Ee.attachments);return{prompt:Re.prompt,attachments:Re.attachments??Ee.attachments}}return{prompt:ae,attachments:Ee.attachments}})},[st]),kn=c.useMemo(()=>f.find(ae=>ae.model===l)??null,[l,f]),Ai=sm(l,g),za=(kn==null?void 0:kn.supportedReasoningEfforts)??[],_i=c.useMemo(()=>Wu($e,at),[at,$e]),Mi=c.useMemo(()=>Object.entries(dt).sort(([ae],[Ee])=>ae.localeCompare(Ee)).map(([ae,Ee])=>`${ae}:${Ee}`).join("|"),[dt]);function $i(ae,Ee){Ee.stopPropagation();const Re=Sm(ae,{fastMode:h,goalComposeMode:fr});switch(Re.type){case"toggleFast":Et({fastMode:Re.fastMode});break;case"runCompact":I(null),B==null||B();break;case"enterGoalCompose":xi();break;case"exitGoalCompose":La(),I(null);break;case"openPanel":se(Re.panel),Re.panel==="skills"?F==null||F():Re.panel==="mcp"?E==null||E():Re.panel==="hooks"&&(D==null||D());break;case"insertPrompt":jn(Re.text),se("root"),I(null);break}}function Qt(){const ae=Ue.current;return ae?Pm(ae):null}const Di=c.useCallback(ae=>{const Ee=Ue.current;!Ee||!ae||Rm(Ee,ae)},[]),wn=c.useCallback(()=>{const ae=Ue.current;return ae?Tl(ae):$e},[$e]),{appendAttachments:yn,appendDroppedAttachments:Pa}=dp({prompt:$e,attachments:at,updateDraft:st,getSelection:Qt,selectionSnapshotRef:Ze,pendingSelectionRef:rt,pendingInsertedAttachmentIdsRef:lt,onInserted:()=>I(null)}),Ra=c.useCallback((ae,Ee)=>{var Re;if(Dt(),J){J({kind:ae,appendAttachments:(Qe,ct=ae)=>yn(Qe,ct),defaultPick:()=>{var Qe;return(Qe=Ee.current)==null?void 0:Qe.click()}});return}(Re=Ee.current)==null||Re.click()},[yn,Dt,J]);function jn(ae){if(!ae)return;const Ee=Qt()??Ze.current,Re=(Ee==null?void 0:Ee.start)??$e.length,Qe=(Ee==null?void 0:Ee.end)??Re,ct=Ou(ae),er=`${$e.slice(0,Re)}${ct}${$e.slice(Qe)}`;st(vd=>({prompt:er,attachments:vd.attachments}));const Bt=Re+ct.length;rt.current={start:Bt,end:Bt},Ze.current={start:Bt,end:Bt}}yp({promptRef:Ue,isShellView:z,prompt:$e,promptSegments:_i,attachmentPreviewUrls:dt,previewSignature:Mi,editorSanitizeNonce:nt,pendingSelectionRef:rt,pendingInsertedAttachmentIdsRef:lt,selectionSnapshotRef:Ze,renderedPreviewSignatureRef:mt,renderedSanitizeNonceRef:it,serializeEditorPrompt:wn,restoreSelection:Di});function Dt(){var ae;(ae=Ue.current)==null||ae.blur(),document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.blur()}async function Bi(){var ae;if(Dt(),I(null),!!((ae=navigator.clipboard)!=null&&ae.readText))try{const Ee=await navigator.clipboard.readText();jn(Ee)}catch{return}}async function Aa(){if(!ge.current){ge.current=!0;try{if(wt&&xt(),fr&&!z){await gi();return}const ae=Ku({prompt:$e,attachments:at,isShellView:z});if(!ae||await ie(ae)===!1)return;st(()=>({prompt:"",attachments:[]}))}finally{ge.current=!1}}}async function Gi(ae){ae.preventDefault(),await Aa()}function Fi(){const ae=wn(),Ee=Qt();Ze.current=Ee;const Re=Ue.current;(Re?zm(Re):!1)&&(rt.current=Ee,Ve(ct=>ct+1)),st(ct=>({prompt:ae,attachments:ct.attachments.filter(er=>ae.includes(er.placeholder))}),"deferred")}function Hi(ae){var Qe,ct,er,Bt;const Ee=ra((Qe=ae.clipboardData)==null?void 0:Qe.items,(ct=ae.clipboardData)==null?void 0:ct.files),Re=Yu({files:Ee,plainText:((er=ae.clipboardData)==null?void 0:er.getData("text/plain"))??"",htmlText:((Bt=ae.clipboardData)==null?void 0:Bt.getData("text/html"))??"",htmlToText:Im});Re.preventDefault&&ae.preventDefault(),Re.type==="insert-text"?jn(Re.text):Re.type==="append-files"&&Pa(Re.files)}function Oi(ae){var Re,Qe;const Ee=xs(vs((Re=ae.dataTransfer)==null?void 0:Re.items,(Qe=ae.dataTransfer)==null?void 0:Qe.files));Ee.preventDefault&&ae.preventDefault(),Ee.activateDragTarget&&Fe(!0)}function Wi(ae){var Re,Qe;const Ee=xs(vs((Re=ae.dataTransfer)==null?void 0:Re.items,(Qe=ae.dataTransfer)==null?void 0:Qe.files));Ee.preventDefault&&ae.preventDefault(),Ee.activateDragTarget&&ae.dataTransfer&&(ae.dataTransfer.dropEffect="copy"),Ee.activateDragTarget&&Fe(!0)}function Ui(ae){ae.currentTarget.contains(ae.relatedTarget)||Fe(!1)}function Vi(ae){var Qe,ct;const Ee=ra((Qe=ae.dataTransfer)==null?void 0:Qe.items,(ct=ae.dataTransfer)==null?void 0:ct.files),Re=Zu(Ee);Re.preventDefault&&ae.preventDefault(),Re.type==="accept-files"&&(Fe(!1),Pa(Re.files??[]))}function Xi(ae){if(ae.key==="Enter"&&ae.repeat){ae.preventDefault();return}if(e==="chat"&&ae.key==="/"&&!ae.metaKey&&!ae.ctrlKey&&!ae.altKey&&!n&&!N&&Ge.length>0&&wn().trim().length===0){ae.preventDefault(),se("root"),I("slash");return}const Ee=Ju({key:ae.key,metaKey:ae.metaKey,ctrlKey:ae.ctrlKey,busy:n,disabled:N});Ee.preventDefault&&ae.preventDefault(),Ee.submit&&Aa()}const{promptPlaceholder:qi,interruptLabel:Ki,sendButtonLabel:_a,sendButtonClassName:Ma,modelControlsDisabled:Yi,effortControlsDisabled:Zi,effortControlTitle:Ji}=dm({goalComposeMode:fr,goalBusy:vn,threadConnected:v,busy:n,isShellView:z,disabledPlaceholder:S,settingsBusy:a,supportedEffortCount:za.length,fastMode:h}),{composerLayerClassName:Qi,formClassName:ed,composerShellClassName:td,composerToolbarClassName:rd,composerIconButtonClassName:nd,composerMenuClassName:ad,composerMenuItemClassName:sd,composerInlineToggleClassName:od,composerPanelButtonClassName:ld,composerChipButtonClassName:id,composerPlanToggleActiveClassName:dd,composerSendButtonClassName:cd,composerPromptRegionClassName:hd,promptInputClassName:ud,graphChatInputGroupClassName:md,graphChatInputClassName:pd}=cm({isShellView:z,edgeToEdgeMobile:r,isMobileShell:be,openMenu:Se!==null,isDragTargetActive:Oe,busy:n}),fd=Lp({isShellView:z,canToggleShellView:K,isMobileShell:be,shellPromptLabel:Pe,openMenu:Se,toolbarClassName:rd,iconButtonClassName:nd,menuClassName:ad,menuItemClassName:sd,panelButtonClassName:ld,chipButtonClassName:id,inlineToggleClassName:od,planToggleActiveClassName:dd,sendButtonBaseClassName:cd,slashPanelView:V,availableToolboxItems:Ge,busy:n,settingsBusy:a,compactBusy:s,forkBusy:te,fastMode:h,goalComposeMode:fr,goalBusy:vn,goalStatus:($a=P.data)==null?void 0:$a.status,activeView:e,disabled:N,model:l,agentLabel:i,modelOptions:f,modelContextTitle:Ai,contextUsage:g,reasoningEffort:d,supportedEfforts:za,displayedCollaborationMode:Tt,sandboxMode:u,sendButtonLabel:_a,sendButtonClassName:Ma,modelControlsDisabled:Yi,effortControlsDisabled:Zi,effortControlTitle:Ji,forkTurnOptionsState:Z,skillsState:W,goalState:P,goalHistory:Y,copiedSkillName:zi,hooksPanelMode:Xe,hooksState:O,hookConfigBusy:ht,hookConfigError:Mr,hookConfigSuccess:xn,editingHookTarget:Jt,hookScope:_e,hookEventName:tt,hookMatcher:Lt,hookCommand:yt,hookTimeoutSec:jt,hookStatusMessage:$t,mcpPanelMode:Ne,mcpState:re,mcpConfigPath:wi,mcpConfigError:ji,mcpConfigSuccess:Ni,mcpConfigBusy:yi,mcpHttpName:bi,mcpHttpUrl:vi,mcpRawBlock:ki,capabilities:{hostConfigFiles:de.hostConfigFiles,hookTrust:de.hookTrust,mcpConfigEditing:de.mcpConfigEditing,planMode:de.planMode,sandboxMode:p?!1:de.sandboxMode},shellControlState:T,onToggleView:Ce,onDismissPromptFocus:Dt,onSetOpenMenu:I,onToolboxItemClick:$i,onSetSlashPanelView:se,onViewGoals:G,onUpdateGoal:ee,onOpenForkTurns:()=>ce==null?void 0:ce(),onForkLatest:ne,onForkTurn:xe,onCopySkillInvokeName:Pi,onResetHookForm:ii,onSetHooksPanelMode:bn,onClearHookConfigStatus:Ea,onSetEditingHookTarget:ti,onSetHookScope:ri,onSetHookEventName:ni,onSetHookMatcher:ai,onSetHookCommand:si,onSetHookTimeoutSec:oi,onSetHookStatusMessage:li,onSaveHook:ci,onStartEditingHook:di,onTrustHook:hi,onUntrustHook:ui,onSetMcpPanelMode:Le,onClearMcpConfigStatus:Ia,onSetMcpHttpName:Ci,onSetMcpHttpUrl:Si,onSetMcpRawBlock:Ti,onPrepareRawMcpBlock:Ei,onSaveHttpMcp:Li,onSaveRawMcpBlock:Ii,onPickPhoto:()=>Ra("photo",Ye),onPickFile:()=>Ra("file",pt),onUpdateSettings:ae=>void Et(ae),onPasteShell:()=>void Bi(),onCopyShell:()=>{Dt(),I(null),Me==null||Me()},onClearShell:()=>{Dt(),I(null),ie({prompt:"clear"})},onShellControl:ae=>{Dt(),I(null),Be==null||Be(ae)}}),{promptSlot:gd,goalSlot:xd,shellPromptSlot:bd}=Tp({isShellView:z,promptRef:Ue,prompt:$e,disabled:N,promptPlaceholder:qi,canInterrupt:Ae,interruptLabel:Ki,composerPromptRegionClassName:hd,graphChatInputClassName:pd,promptInputClassName:ud,goalComposeMode:fr,goalTokenBudget:mi,goalLocalError:pi,goalBusy:vn,busy:n,sendButtonLabel:_a,sendButtonClassName:Ma,onInterrupt:H,onPromptInput:Fi,onPromptPaste:Hi,onPromptKeyDown:Xi,onPromptKeyUp:()=>{Ze.current=Qt()},onPromptMouseUp:()=>{Ze.current=Qt()},onPromptBlur:()=>{Ze.current=Qt(),Fe(!1),wt&&xt()},onPromptDragEnter:Oi,onPromptDragOver:Wi,onPromptDragLeave:Ui,onPromptDrop:Vi,onGoalTokenBudgetChange:fi,onCancelGoal:La,onShellPromptChange:Ri});return t.jsx(Wm,{activeView:e,layerClassName:Qi,formClassName:ed,shellClassName:td,inputGroupClassName:md,error:o,followTail:w,photoInputRef:Ye,fileInputRef:pt,onAppendAttachments:yn,onToggleFollow:ye,canJumpToPreviousTurn:fe,onJumpToPreviousTurn:Te,canJumpToNextTurn:oe,onJumpToNextTurn:Q,subscriptionUsage:me,onSubmit:Gi,formRef:qe,promptSlot:gd,pendingQueueSlot:!z&&He.length>0?t.jsx(Um,{prompts:He,onSteer:X,onCancel:he}):null,toolbarSlot:t.jsx(op,{...fd}),goalSlot:xd,shellPromptSlot:bd})}var Ip=c.createContext(null);function Ll(){return c.useContext(Ip)}function kt(e){return e?new Date(e).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"}):"Time unavailable"}function qt(e){return e?new Date(e).toLocaleString():"Time unavailable"}function zp(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 Pp(e){switch(e){case"idle":return"ui-status-neutral";case"running":return"ui-status-info";case"interrupted":return"ui-status-warning";case"failed":case"system_error":return"ui-status-danger";case"not_loaded":return"ui-status-neutral"}}function Il(e){switch(e){case"sending":return"Sending";case"completed":return"Completed";case"interrupted":return"Interrupted";case"failed":return"Failed";case"inProgress":return"Running"}}function Rp({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(m){m.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 Lr.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 Ap({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 _p({children:e,roomsRailCollapsed:r,hideRoomsRail:n=!1}){return t.jsx("div",{className:`thread-shell-frame relative h-full min-h-0 ${n?"is-rail-hidden sm:grid-cols-[minmax(0,1fr)]":r?"is-rail-collapsed sm:grid-cols-[56px_minmax(0,1fr)]":"sm:grid-cols-[264px_minmax(0,1fr)]"}`,children:e})}function Mp({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 $p({children:e,collapsed:r,mobileOpen:n}){return t.jsx("aside",{className:`thread-graph-rooms-surface thread-rooms-rail fixed inset-y-0 left-0 z-50 flex min-h-0 min-w-0 w-[min(20rem,calc(100vw-2rem))] flex-col overflow-x-hidden border-r border-slate-200/80 bg-white shadow-[0_20px_50px_rgba(15,23,42,0.18)] transition-transform duration-200 ease-out sm:static sm:z-auto sm:w-auto sm:translate-x-0 sm:rounded-[12px] sm:border sm:shadow-[0_10px_30px_rgba(15,23,42,0.04)] ${n?"translate-x-0":"pointer-events-none -translate-x-full sm:pointer-events-auto"} ${r?"thread-ui-rail-collapsed sm:items-center":""}`,style:{paddingTop:"var(--android-safe-area-top, 0px)"},children:e})}function Dp({children:e}){return t.jsx("main",{className:"thread-shell-main h-full min-h-0 min-w-0 overflow-hidden",children:t.jsx("div",{className:"thread-main-panel thread-shell-card flex h-full min-h-0 flex-col overflow-hidden bg-white shadow-[0_10px_30px_rgba(15,23,42,0.04)] sm:rounded-[12px] sm:border sm:border-slate-200/80",children:e})})}function 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 Gp({children:e}){return t.jsx("div",{className:"thread-split-region min-h-0 flex-1 overflow-hidden p-0 sm:p-2",children:e})}Xo();Mt();function Ss({...e}){return t.jsx(Cd,{"data-slot":"dialog",...e})}function Ts({...e}){return t.jsx(Sd,{"data-slot":"dialog-trigger",...e})}function Fp({...e}){return t.jsx(zd,{"data-slot":"dialog-portal",...e})}function Hp({className:e,...r}){return t.jsx(Pd,{"data-slot":"dialog-overlay",className:ot("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 Es({children:e,className:r,showCloseButton:n=!0,...a}){return t.jsxs(Fp,{"data-slot":"dialog-portal",children:[t.jsx(Hp,{}),t.jsxs(Td,{"data-slot":"dialog-content",className:ot("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(Ed,{"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(R.XIcon,{}),t.jsx("span",{className:"sr-only",children:"Close"})]}):null]})]})}function Ls({className:e,...r}){return t.jsx("div",{"data-slot":"dialog-header",className:ot("flex flex-col gap-2 text-center sm:text-left",e),...r})}function Is({className:e,...r}){return t.jsx(Ld,{"data-slot":"dialog-title",className:ot("text-lg font-semibold leading-none",e),...r})}function zs({className:e,...r}){return t.jsx(Id,{"data-slot":"dialog-description",className:ot("text-sm text-muted-foreground",e),...r})}var Op=[{value:"system",label:"Follow system",icon:R.Monitor},{value:"dark",label:"Dark",icon:R.Moon},{value:"light",label:"Light",icon:R.Sun}];function Wp({thread:e,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a={},onOpenThread:s,getThreadHref:o,renderThreadLink:l,onBeginRenameThread:i,onDeleteThread:d,showDeleteButton:h=!1,showSessionCopyButton:m=!1,collapsed:u=!1}){const[p,f]=c.useState("idle"),g=c.useRef(null),b=a[e.workspaceId],j=b&&!n?b:null,x=r===e.id;c.useEffect(()=>()=>{g.current!==null&&window.clearTimeout(g.current)},[]);async function k(){const S=e.providerSessionId;if(S)try{await navigator.clipboard.writeText(S),f("copied"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>f("idle"),1200)}catch{f("failed"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>f("idle"),1600)}}const w=()=>s(e.id),v=`thread-graph-room-card group flex w-full items-center gap-3 rounded-xl border text-left transition ${x?"is-active":""} ${u?"justify-center px-2 py-2":"px-3 py-2.5"}`,y=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(R.MessageSquare,{className:"h-4 w-4"})}),t.jsxs("div",{className:`min-w-0 flex-1 ${u?"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&&!u?t.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),S.preventDefault(),i(e)},"aria-label":`Rename thread ${e.title}`,title:"Rename thread",className:"thread-card-quiet-button inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full transition",children:t.jsx(R.Pencil,{className:"h-3 w-3"})}):null,m&&e.providerSessionId?t.jsx("button",{type:"button","aria-label":"Copy session ID",title:p==="copied"?"Copied":p==="failed"?"Copy failed":"Copy session ID",onClick:S=>{S.stopPropagation(),S.preventDefault(),k()},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:p==="copied"?t.jsx(R.Check,{className:"h-3.5 w-3.5"}):t.jsx(R.Copy,{className:"h-3.5 w-3.5"})}):null]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2",children:[j?t.jsx("p",{className:"thread-graph-room-card-meta min-w-0 flex-1 truncate text-[11px] text-[var(--theme-fg-muted)]",title:j,children:j}):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 ${Pp(e.status)}`,children:zp(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&&!u?t.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),S.preventDefault(),d(e)},"aria-label":`Delete thread ${e.title}`,className:"thread-card-danger-button shrink-0 rounded-full p-1 transition",title:"Delete thread",children:t.jsx(R.Trash2,{className:"h-3.5 w-3.5"})}):null]}),N=o==null?void 0:o(e.id);return l?t.jsx(t.Fragment,{children:l({thread:e,children:y,className:v,onClick:w})}):N?t.jsx("a",{href:N,onClick:S=>{S.preventDefault(),w()},title:u?e.title:void 0,className:v,children:y}):t.jsx("div",{role:"link",tabIndex:0,onClick:w,onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),w())},title:u?e.title:void 0,className:v,children:y})}function Up({threads:e,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a={},onOpenThread:s,getThreadHref:o,renderThreadLink:l,onBeginRenameThread:i,onDeleteThread:d,scrollable:h=!1,maxHeightClassName:m="max-h-full",showDeleteButton:u=!1,showSessionCopyButton:p=!1,collapsed:f=!1}){const g=h?`min-h-0 min-w-0 overflow-x-hidden overflow-y-auto overscroll-contain pr-1 ${m}`:"";return t.jsx("div",{className:g,children:t.jsx("div",{className:"min-w-0 space-y-1",children:e.map(b=>t.jsx(Wp,{thread:b,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a,onOpenThread:s,showDeleteButton:u,showSessionCopyButton:p,collapsed:f,...o?{getThreadHref:o}:{},...l?{renderThreadLink:l}:{},...i?{onBeginRenameThread:i}:{},...d?{onDeleteThread:d}:{}},b.id))})})}function Vp({threads:e,status:r,loading:n=!1,error:a,viewportConstrained:s=!1,layoutMode:o="responsive",effectiveTheme:l,themeMode:i,onThemeModeChange:d,showMobileNewThreadShortcut:h=!0,hideRoomsRail:m=!1,settingsDialogOpen:u,onSettingsDialogOpenChange:p,mobileHeaderAction:f,currentThreadId:g,currentThreadLabel:b=null,currentWorkspaceId:j=null,currentWorkspaceLabel:x=null,sessionLabel:k=null,usageLabel:w=null,threadActionsButton:v,topbarActions:y,metaContent:N,settingsContent:S,globalSettingsContent:T,workspaceLabels:M={},workspaceReturnHref:A,onWorkspaceReturn:J,getThreadHref:W,onOpenThread:re,getNewThreadHref:O,newThreadHref:P,newThreadLabel:Y="New Chat",onNewThread:Z,onNewThreadTitle:_,renderNewThreadDialogContent:ie,renderThreadLink:H,onCloseAppNavigation:B,onRenameThread:F,onDeleteThread:E,workspaceContent:D,workspaceTitle:$="Workspace",workspaceActions:L,workspaceRevealRequestKey:C,children:U}){const G=Ll(),le=typeof window<"u"?window.matchMedia("(max-width: 639px)").matches:o==="mobile",[ee,ce]=c.useState(()=>typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)").matches:!1),q=i??(G==null?void 0:G.themeMode)??"system",ve=l??(G==null?void 0:G.effectiveTheme)??(q==="system"?ee?"dark":"light":q),[ke,je]=c.useState(!1),[ye,fe]=c.useState(!1),[Te,oe]=c.useState(!le),[Q,me]=c.useState(le),[we,Ce]=c.useState("chat"),[Me,Be]=c.useState(null),[Ae,He]=c.useState(""),[X,he]=c.useState(null),[Se,I]=c.useState(!1),[V,se]=c.useState(""),[ge,Ne]=c.useState(!1),[Le,de]=c.useState(!1),[Ge,qe]=c.useState("session");c.useEffect(()=>{C!==void 0&&(oe(!1),Ce("workspace"))},[C]),c.useEffect(()=>{if(typeof window>"u")return;const ne=window.matchMedia("(max-width: 639px)"),xe=()=>{me(ne.matches)};return xe(),ne.addEventListener("change",xe),()=>{ne.removeEventListener("change",xe)}},[]),c.useEffect(()=>{if(typeof window>"u")return;const ne=window.matchMedia("(prefers-color-scheme: dark)"),xe=()=>{ce(ne.matches)};return xe(),ne.addEventListener("change",xe),()=>{ne.removeEventListener("change",xe)}},[]);const Ue=c.useMemo(()=>[...j?e.filter(xe=>xe.workspaceId===j):e].sort((xe,Xe)=>{if(xe.id===g)return-1;if(Xe.id===g)return 1;const _e=Date.parse(xe.lastTurnStartedAt??xe.updatedAt);return Date.parse(Xe.lastTurnStartedAt??Xe.updatedAt)-_e}),[g,j,e]),Ye=P??(O==null?void 0:O(j)),pt=x??j??"all",rt=k??b??g??"default_session",lt=w??(r!=null&&r.state?`runtime ${r.state}`:"waiting for agent usage"),Ze=d??(G==null?void 0:G.setThemeMode),mt=!!Ze,it=()=>{je(!1),B==null||B()};async function z(ne){if(!F)return;const xe=Ae.trim();if(xe){he(ne);try{await F(ne,xe),Be(null),He("")}finally{he(null)}}}function K(ne){Be(ne.id),He(ne.title)}function be(){Be(null),He("")}function Pe(ne){re==null||re(ne),it()}function Oe(){I(!1),se("")}function Fe(ne){if(!Ye||!ne.trim())return Ye;try{const xe=new URL(Ye,window.location.origin);return xe.searchParams.set("title",ne.trim()),`${xe.pathname}${xe.search}${xe.hash}`}catch{const xe=Ye.includes("?")?"&":"?";return`${Ye}${xe}title=${encodeURIComponent(ne.trim())}`}}async function nt(){const ne=V.trim();Ne(!0);try{if(ne&&_){await _(ne),se(""),I(!1),it();return}if(Ye){window.location.assign(Fe(ne)??Ye);return}await(Z==null?void 0:Z()),se(""),I(!1),it()}finally{Ne(!1)}}function Ve(ne,xe=!1){const Xe=xe?t.jsxs(t.Fragment,{children:[t.jsx(R.Plus,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:Y})]}):t.jsxs(t.Fragment,{children:[t.jsx(R.Plus,{className:"h-4 w-4"}),t.jsx("span",{children:Y})]});return t.jsxs(Ss,{open:Se,onOpenChange:_e=>{ge||I(_e)},children:[t.jsx(Ts,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":xe?Y:void 0,title:Y,className:ne,children:Xe})}),t.jsx(Es,{"data-testid":"create-thread-dialog","data-theme-effective":ve,"data-theme-mode":q,className:"thread-graph-create-thread-dialog thread-graph-dialog max-h-[min(86vh,42rem)] overflow-hidden p-4 sm:max-w-[34rem]",children:ie?ie({close:Oe,closeNavigation:it,currentWorkspaceId:j}):t.jsxs(t.Fragment,{children:[t.jsxs(Ls,{children:[t.jsx(Is,{children:"Create New Chat"}),t.jsx(zs,{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:V,onChange:_e=>se(_e.target.value),onKeyDown:_e=>{_e.key==="Enter"&&(_e.preventDefault(),nt())},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 nt(),disabled:ge,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:ge?"Creating...":"Create"})]})]})})]})}function $e(){if(!S&&!N&&!T&&!mt)return null;const ne=!!(S||N),xe=!!T,Xe=ne&&xe,_e=Ge==="global"&&xe||!ne&&xe?"global":"session";return t.jsxs(Ss,{...u!==void 0?{open:u}:{},...p?{onOpenChange:p}:{},children:[t.jsx(Ts,{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(R.Settings,{className:"h-4 w-4"})})}),t.jsxs(Es,{"data-testid":"settings-dialog","data-theme-effective":ve,"data-theme-mode":q,className:"thread-graph-settings-dialog thread-graph-dialog",children:[t.jsxs(Ls,{children:[t.jsx(Is,{children:"Settings"}),t.jsx(zs,{children:"Manage this session and host-wide preferences."})]}),mt?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: ",ve]})]}),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:Op.map(tt=>{const Lt=tt.icon,yt=q===tt.value;return t.jsxs("button",{type:"button","data-testid":`theme-mode-${tt.value}`,"aria-pressed":yt,disabled:!mt,onClick:()=>Ze==null?void 0:Ze(tt.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(Lt,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:"truncate",children:tt.label})]},tt.value)})})]})}):null,Xe?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":_e==="session",onClick:()=>qe("session"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${_e==="session"?"is-active":""}`,children:"Session"}),t.jsx("button",{type:"button","aria-pressed":_e==="global",onClick:()=>qe("global"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${_e==="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:_e==="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,N?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:N}):null,ne?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:T})})]})]})}function at(ne=!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)] ${ne?"justify-center":""}`,children:[t.jsx(R.Rows3,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:ne?"sr-only":"",children:"Rooms"}),!ne&&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&&Ue.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,Ue.length>0?t.jsx(Up,{threads:Ue,currentThreadId:g,currentWorkspaceId:j,workspaceLabels:M,onOpenThread:Pe,collapsed:ne,...F?{onBeginRenameThread:K}:{},showDeleteButton:!!E,...W?{getThreadHref:W}:{},...H?{renderThreadLink:H}:{},...E?{onDeleteThread:E}:{}}):null]})]})})}function wt(){return D?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:()=>oe(!0),className:"thread-workspace-collapse-tab thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(R.ChevronsRight,{className:"h-4 w-4"})}),L?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:L})}):null,t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:D})]}):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:$}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:x??j??"Current context"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[L,t.jsx("button",{type:"button",onClick:()=>oe(!0),className:"thread-workspace-small-toggle thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(R.ChevronsRight,{className:"h-4 w-4"})})]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:D??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:x??j??"All threads"})]})]})})]})}const st=!!D,xt=o==="mobile"||o==="responsive"&&Q,dt=xt,Tt=dt&&!ke,te=!!(A||J)?t.jsx("a",{href:A??"#",onClick:ne=>{J&&(ne.preventDefault(),J())},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(R.ArrowLeft,{className:"h-4 w-4"})}):null;return t.jsxs(t.Fragment,{children:[t.jsx(Ap,{effectiveTheme:ve,layoutMode:o,themeMode:q,viewportConstrained:s,children:t.jsxs(_p,{roomsRailCollapsed:ye,hideRoomsRail:m,children:[m?null:t.jsx(Mp,{open:ke,onClose:()=>je(!1)}),m?null:t.jsxs($p,{collapsed:ye,mobileOpen:ke,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 ${ye?"sm:w-full sm:justify-center sm:px-2":""}`,children:t.jsxs("div",{className:`flex w-full items-center gap-3 ${ye?"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:()=>fe(ne=>!ne),className:"thread-icon-button thread-desktop-only-flex h-9 w-9 shrink-0 items-center justify-center rounded-full",title:ye?"Expand rooms":"Collapse rooms","aria-label":ye?"Expand rooms":"Collapse rooms",children:ye?t.jsx(R.PanelLeftOpen,{className:"h-4 w-4"}):t.jsx(R.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)] ${ye?"thread-desktop-collapsed-hidden":""}`,children:(x??"R").charAt(0).toUpperCase()}),t.jsxs("div",{className:`min-w-0 ${ye?"thread-desktop-collapsed-hidden":""}`,children:[t.jsx("p",{className:"truncate text-sm font-semibold text-[var(--theme-fg)]",children:x??"Remote Codex"}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:j??"Thread workspace"})]})]}),t.jsxs("div",{className:`flex shrink-0 items-center gap-1 ${ye?"thread-desktop-collapsed-hidden":""}`,children:[$e(),te,t.jsx("button",{type:"button",onClick:()=>je(!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(R.X,{className:"h-4 w-4"})})]})]})}),t.jsx("div",{className:`thread-graph-new-room-strip flex shrink-0 items-center border-b ${ye?"h-12 w-full justify-center px-2 sm:h-12":"h-[68px] px-4"}`,children:Ve(`thread-graph-new-room-button inline-flex items-center justify-center rounded-xl font-medium transition ${ye?"h-9 w-9 p-0":"h-11 w-full gap-2 px-3 text-sm sm:h-9"}`,ye)}),t.jsx("div",{className:`flex min-h-0 flex-1 flex-col ${ye?"w-full px-2 py-2":"px-3 py-3"}`,children:at(ye)})]}),t.jsxs(Dp,{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:[Tt&&!m?t.jsx("button",{type:"button",onClick:()=>je(!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(R.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:b??"Shared Workspace",children:b??"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:()=>{de(ne=>!ne)},"aria-expanded":Le,"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:pt})]}),Le?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 ne;rt&&((ne=navigator.clipboard)==null||ne.writeText(rt))},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:rt})]}),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:lt})]})]}):null]})]})]}),t.jsxs("div",{className:"relative z-[1] inline-flex shrink-0 items-center gap-2",children:[v||y?t.jsxs("div",{className:"thread-graph-topbar-actions thread-desktop-only-inline-flex items-center rounded-lg border p-0.5 shadow-none",children:[v,y]}):null,dt&&v?t.jsx("div",{className:"thread-mobile-only-inline-flex",children:v}):null,dt&&st?t.jsx("button",{type:"button",onClick:()=>Ce(ne=>ne==="workspace"?"chat":"workspace"),"aria-label":we==="workspace"?"Show chat":"Show workspace",title:we==="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:we==="workspace"?t.jsx(R.MessageSquare,{className:"h-4 w-4"}):t.jsx(R.Folder,{className:"h-4 w-4"})}):null,dt?f:null,dt&&h&&!m?Ve("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(Gp,{children:st&&!Te?xt?t.jsxs("div",{className:"thread-split-container thread-graph-shell-mobile-split h-full min-h-0 overflow-hidden",children:[t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${we==="chat"?"block":"thread-mobile-chat-hidden"}`,children:U}),t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${we==="workspace"?"block":"thread-mobile-workspace-hidden"}`,children:wt()})]}):t.jsxs(Un,{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(ir,{defaultSize:47,minSize:30,maxSize:75,className:"thread-split-chat-pane min-w-0 overflow-hidden",children:U}),t.jsx(Vn,{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(ir,{defaultSize:53,minSize:30,maxSize:70,className:"thread-split-workspace-pane min-w-0 overflow-hidden",children:wt()})]}):t.jsxs("div",{className:"thread-split-container relative h-full min-h-0 overflow-hidden",children:[st&&Te?t.jsx("button",{type:"button",onClick:()=>oe(!1),className:"thread-workspace-expand-fab thread-desktop-only-inline-flex",title:"Expand workspace","aria-label":"Expand workspace",children:t.jsx(R.ChevronsLeft,{className:"h-4 w-4"})}):null,U]})})]})]})}),t.jsx(Rp,{open:Me!==null,title:"Rename Thread",label:"Thread Title",value:Ae,busy:X!==null,onChange:He,onCancel:be,onSubmit:()=>Me?z(Me):void 0})]})}function Xp({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?Lr.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 qp=[/^(?: {0,3})#{1,6}\s+\S/m,/^(?: {0,3})>{1,}\s*\S/m,/^(?: {0,3})(?:[-+*]|\d{1,9}[.)])\s+(?:\[[ xX]\]\s+)?\S/m,/^(?: {0,3})(?:```|~~~)/m,/^(?: {0,3})(?:[-*_]\s*){3,}$/m],Kp=/^(?:\|?[^|\n]+\|[^|\n]+(?:\|[^|\n]+)*\|?\s*\n\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$)/m,Yp=/!?\[[^\]\n]+\]\([^)]+\)/,Zp=/`[^`\n]+`/,Jp=/(?:\*\*[^*\n]+\*\*|__[^_\n]+__)/,Qp=/(^|[^\w])(?:\*[^*\n]+\*|_[^_\n]+_)(?=[^\w]|$)/,ef=/~~[^~\n]+~~/;function tf(e){const r=e.trim();return r?qp.some(n=>n.test(r))||Kp.test(r)?!0:/[`[\]*_~!]/.test(r)?Yp.test(r)||Zp.test(r)||Jp.test(r)||Qp.test(r)||ef.test(r):!1:!1}hn();function sa(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 ya(e=[]){const r=sa(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 ja=c.createContext(ya());function Na(){return c.useContext(ja)??ya()}Ar();function zl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ps(e){return zl(e)?Object.entries(e):e==null||e===""?[]:[["value",e]]}function Pl(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 rf(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)}):Pl(r)}function Rs({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(R.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"};case"failed":return{className:"is-failed",icon:t.jsx(R.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"};default:return{className:"is-pending",icon:t.jsx(R.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),label:"Running"}}},[n]),l=c.useMemo(()=>Ps(s),[s]),i=c.useMemo(()=>Ps(a),[a]),d=c.useMemo(()=>typeof s=="string"?s.length>0:zl(s)?["stdout","stderr","result"].some(p=>{const f=s[p];return typeof f=="string"&&f.length>0}):!1,[s]),h=n==="pending"||d,[m,u]=c.useState(h?"item-1":void 0);return c.useEffect(()=>{h&&u("item-1")},[e,h]),t.jsx("div",{className:"thread-graph-tool-call my-2 w-full font-sans not-prose",children:t.jsx(zr,{type:"single",collapsible:!0,onValueChange:p=>u(p||void 0),className:"thread-graph-tool-accordion w-full overflow-hidden rounded-lg border",...m!==void 0?{value:m}:{},children:t.jsxs(Pr,{value:"item-1",className:"border-0",children:[t.jsx(un,{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(R.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(Rr,{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(([p,f],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',p,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),Pl(f),g<i.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},p)):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(([p,f],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',p,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),rf(p,f),g<l.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},p)),"}"]})]}):null]})]})})})}Ko();function mn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function oa(e){if(!e)return{};if(mn(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 la(){return{finalResult:null,stdout:"",stderr:""}}function nf(e){return typeof e=="string"?{result:e}:e}function Rl(e){const r=mn(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 As(e){if(!e)return"pending";if(!mn(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 af(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 m=nf(d.result),u=r.get(h)??la();return mn(m)&&m.status==="stream"&&typeof m.chunk=="string"?m.stream==="stderr"?u.stderr+=m.chunk:u.stdout+=m.chunk:u.finalResult=m,r.set(h,u),""}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,m=d.tool;if(typeof m!="string")return l;const u=oa(d.args);if(typeof h=="string"&&r.has(h)){const p=Rl(r.get(h)??la());return`\`\`\`tool-merged
|
|
3952
3952
|
${JSON.stringify({call:{tool:m,args:u,call_id:h},result:p},null,2)}
|
|
3953
|
-
\`\`\``}return l}catch{return l}}),resultMap:r}}var
|
|
3954
|
-
`)||
|
|
3953
|
+
\`\`\``}return l}catch{return l}}),resultMap:r}}var sf=["/api/","/assets/","/control-plane","/devices/","/relay/","/relay-account","/relay-admin","/relay-devices","/relay-portal","/threads","/workspaces"];function _s(e){return e.replace(/background-color:[^;"]+;?/g,"background-color: transparent;").replace(/background:[^;"]+;?/g,"background: transparent;")}function Ms(e){return Array.isArray(e)?e.map(r=>String(r)).join(""):String(e??"")}function of(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 lf(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("/")||sf.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 df({children:e,...r}){return cf(e)?t.jsx(t.Fragment,{children:e}):t.jsx("pre",{...r,children:e})}function cf(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 hf=c.memo(function({className:r="thread-graph-markdown",content:n,onOpenWorkspaceFile:a,resolveHref:s}){const o=c.useRef(null),l=Na(),[i,d]=c.useState(null),[h,m]=c.useState({}),[u,p]=c.useState(!1),{processedContent:f,resultMap:g}=c.useMemo(()=>af(n),[n]);c.useEffect(()=>{let x=!0;return qo().then(k=>{x&&d(k)}).catch(()=>{}),()=>{x=!1}},[]),c.useEffect(()=>{const x=o.current,k=x==null?void 0:x.closest(".thread-ui-shell"),w=()=>k?k.getAttribute("data-theme-effective")==="dark"||k.classList.contains("dark")||k.classList.contains("thread-ui-theme-dark"):document.documentElement.classList.contains("dark");if(p(w()),!k)return;const v=new MutationObserver(()=>p(w()));return v.observe(k,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>v.disconnect()},[]);async function b(x,k){try{await navigator.clipboard.writeText(k),m(w=>({...w,[x]:"copied"})),window.setTimeout(()=>{m(w=>{const v={...w};return delete v[x],v})},1200)}catch{m(w=>({...w,[x]:"failed"}))}}const j=({children:x,className:k,inline:w,node:v,...y})=>{var re;const N=/language-(\w+(?:-\w+)*)/.exec(k||""),S=N?N[1]??"":"",T=Ms(x).replace(/\n$/,""),{startLine:M,endLine:A}=of(v),J=w===!1||!!k||T.includes(`
|
|
3954
|
+
`)||M!==A;if(S==="tool-merged"){let O={call:{tool:"Unknown",args:{},call_id:void 0},result:null};try{O=JSON.parse(T)}catch{O={call:{tool:"Error",args:{raw:T}},result:{status:"failed"}}}const P=typeof O.call.tool=="string"?O.call.tool:"Unknown",Y=typeof O.call.call_id=="string"?O.call.call_id:void 0;return t.jsx(Rs,{callId:Y,toolName:P,status:As(O.result),parameters:oa(O.call.args),result:O.result})}if(S==="tool-call"){let O={tool:"Unknown",args:{},call_id:void 0};try{O=JSON.parse(T)}catch{O={tool:"Error",args:{raw:T}}}const P=typeof O.call_id=="string"?O.call_id:void 0,Y=P&&g.has(P)?Rl(g.get(P)??la()):void 0;return t.jsx(Rs,{callId:P,toolName:typeof O.tool=="string"?O.tool:"Unknown",status:Y?As(Y):"pending",parameters:oa(O.args),result:Y})}if(S==="tool-result")return null;if(["xyz","extxyz","cif","pdb"].includes(S)){const O=l.renderInlineCode({code:T,isIncomplete:!1,language:S});if(c.isValidElement(O))return O}if(J){const P=(((re=i==null?void 0:i.getLoadedLanguages)==null?void 0:re.call(i))??[]).includes(S)?S:"text",Y=u?"ayu-dark":"ayu-light",Z=`${S||"text"}:${T.length}:${T.slice(0,32)}`;let _="";if(i)try{_=_s(i.codeToHtml(T,{lang:P,theme:Y}))}catch{_=_s(i.codeToHtml(T,{lang:"text",theme:Y}))}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(Er,{type:"button",onClick:()=>void b(Z,T),variant:"ghost",size:"sm",className:"thread-graph-code-copy absolute right-2 top-2 z-10 rounded-md p-1.5",title:h[Z]==="copied"?"Copied":h[Z]==="failed"?"Copy failed":"Copy","aria-label":"Copy code",children:h[Z]==="copied"?t.jsx(R.Check,{className:"h-3.5 w-3.5"}):t.jsx(R.Copy,{className:"h-3.5 w-3.5"})}),_?t.jsx("div",{dangerouslySetInnerHTML:{__html:_}}):t.jsx("pre",{children:t.jsx("code",{className:"whitespace-pre",children:T})})]})}const W=Ms(x).replace(/`+/g,"");return t.jsx("code",{className:`thread-graph-inline-code rounded px-1 py-0.5 font-mono font-normal text-[0.9em] ${k||""}`,...y,children:W})};return t.jsx("div",{ref:o,className:`thread-graph-message-markdown ${r}`,children:t.jsx(so,{remarkPlugins:[oo,Qd],rehypePlugins:[Jd],components:{a({href:x,children:k,...w}){const v=lf(x);return v&&a?t.jsx("a",{...w,href:x,className:"thread-inline-link",onClick:y=>{y.preventDefault(),a(v)},children:k}):t.jsx("a",{...w,href:x&&((s==null?void 0:s(x))??x),className:"thread-inline-link",children:k})},code:j,pre:df},children:f})})}),$s=2400,uf=/\b(?:https?:\/\/|www\.)[^\s<>"'`]+/gi,mf=/[),.;:!?]+$/;function pf(e){return e.startsWith("www.")?`https://${e}`:e}function Ds(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function ff(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 cr({text:e}){var a;const r=[];let n=0;for(const s of e.matchAll(uf)){const o=s[0],l=s.index??0,i=((a=o.match(mf))==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:pf(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 Al=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,resolveHref:h}){const m=c.useRef(null),u=c.useRef(null),[p,f]=c.useState(!1),g=tf(r),b=!a&&r.length>$s,j=b&&!p?`${r.slice(0,$s).trimEnd()}
|
|
3955
3955
|
|
|
3956
|
-
...`:r,[
|
|
3956
|
+
...`:r,[x,k]=c.useState(a||typeof IntersectionObserver>"u"),w=c.useCallback(()=>{const v=n.current,y=m.current,N=(y==null?void 0:y.getBoundingClientRect().top)??null;i==null||i(),u.current=v&&N!==null?{root:v,top:N}:null,f(S=>!S)},[i,n]);return c.useLayoutEffect(()=>{const v=u.current,y=m.current;if(!v||!y)return;u.current=null;const N=()=>{const T=y.getBoundingClientRect().top;v.root.scrollTop+=T-v.top};N();const S=window.requestAnimationFrame(N);return()=>{window.cancelAnimationFrame(S)}},[p]),c.useEffect(()=>{if(a||typeof IntersectionObserver>"u"){k(!0);return}if(x||!m.current)return;const v=new IntersectionObserver(y=>{for(const N of y)if(N.isIntersecting){k(!0),v.disconnect();break}},{root:n.current,threshold:0});return v.observe(m.current),()=>{v.disconnect()}},[x,n,a]),t.jsxs("div",{ref:m,className:s,children:[x&&g?t.jsx(hf,{content:j,className:l,onOpenWorkspaceFile:d,resolveHref:h}):t.jsx("p",{className:o,children:t.jsx(cr,{text:j})}),b?t.jsx("button",{type:"button",onClick:w,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:p?"Show less":`Show more (${r.length.toLocaleString()} chars)`}):null]})}),gf=c.memo(function({text:r,scrollRootRef:n,streaming:a=!1,onBeforeResize:s,onOpenWorkspaceFile:o,resolveHref:l}){return t.jsx(Al,{text:r,scrollRootRef:n,streaming:a,containerClassName:"thread-graph-message-prose",...s?{onBeforeResize:s}:{},...o?{onOpenWorkspaceFile:o}:{},...l?{resolveHref:l}:{}})}),xf=c.memo(function({threadId:r,text:n,attachmentPreviewUrls:a,getImageAssetUrl:s}){const o=c.useMemo(()=>ff(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=Ds(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=Ds(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 bf(){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 Bs({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(R.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):a?t.jsx(R.XCircle,{className:"h-3.5 w-3.5"}):s?t.jsx(R.CheckCircle2,{className:"h-3.5 w-3.5"}):t.jsx(R.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(bf,{}):l}),t.jsx("span",{className:"thread-graph-status-label",children:e})]})}function vf({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(Bs,{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(Bs,{status:o}):null,h]}):null]})})}Ar();function kf(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function wf({tone:e="amber"}){const r=e==="sky"?"bg-sky-300/90":"bg-amber-200/90";return t.jsx("span",{className:"ml-1.5 inline-flex items-center gap-1","aria-hidden":"true",children:[0,1,2].map(n=>t.jsx("span",{className:`h-1.5 w-1.5 animate-pulse rounded-full ${r}`,style:{animationDelay:`${n*180}ms`}},n))})}var At=c.memo(function({threadId:r,item:n,scrollRootRef:a,streaming:s=!1,adapter:o,timeLabel:l,timeTitle:i,onBeforeMessageResize:d}){const[h,m]=c.useState("idle"),[u,p]=c.useState(!1),f=c.useRef(null),g=n.kind==="agentMessage"?n.reasoningItems??[]:[],b=g.map(S=>S.text.trim()).filter(Boolean).join(`
|
|
3957
3957
|
|
|
3958
|
-
`),j=n.kind==="userMessage"&&(n.status==="Steering"||n.status==="Accepted"||n.status==="Awaiting response");c.useEffect(()=>()=>{f.current!==null&&window.clearTimeout(f.current)},[]);async function b(){try{await navigator.clipboard.writeText(n.text),m("copied"),f.current!==null&&window.clearTimeout(f.current),f.current=window.setTimeout(()=>m("idle"),1200)}catch{m("failed"),f.current!==null&&window.clearTimeout(f.current),f.current=window.setTimeout(()=>m("idle"),1600)}}function k(){d==null||d(),p(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 b(),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(P.Check,{className:"h-3.5 w-3.5"}):t.jsx(P.Copy,{className:"h-3.5 w-3.5"})}):null,v=g.some(N=>bf(N.status)),w=n.kind==="agentMessage"&&x?t.jsxs("button",{type:"button","aria-label":u?"Hide chain of thought":"Show chain of thought","aria-expanded":u,title:u?"Hide CoT":"Show CoT",onClick:k,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 ${u?"is-open":""}`,children:[t.jsx(P.Brain,{className:`h-3.5 w-3.5 ${v?"animate-pulse":""}`}),t.jsx("span",{children:"CoT"}),v?t.jsx(vf,{tone:"sky"}):null]}):null,C=n.kind==="agentMessage"&&x?t.jsx("div",{className:"thread-graph-message-thinking mb-3",children:t.jsx(zr,{type:"single",collapsible:!0,value:u?"thoughts":"",className:"thread-graph-thinking-accordion w-full border-none",onValueChange:N=>p(!!N),children:t.jsx(Pr,{value:"thoughts",className:"border-b-0",children:t.jsx(Rr,{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(dr,{text:x})})})})})}):null;return t.jsx(xf,{kind:n.kind,status:j||n.kind==="agentMessage"?n.status:null,copyButton:y,metaControl:w,reasoning:C,timeLabel:l,timeTitle:i,children:n.kind==="agentMessage"?t.jsx(pf,{text:n.text,scrollRootRef:a,streaming:s,...d?{onBeforeResize:d}:{},...o!=null&&o.onOpenWorkspaceFile?{onOpenWorkspaceFile:o.onOpenWorkspaceFile}:{},...o!=null&&o.resolveHref?{resolveHref:o.resolveHref}:{}}):t.jsx(ff,{threadId:r,text:n.text,attachmentPreviewUrls:n.attachmentPreviewUrls,getImageAssetUrl:o==null?void 0:o.getImageAssetUrl})})});function kf(e){return!!(e&&typeof e.id=="string"&&typeof e.kind=="string")}function cr(e){return e.filter(kf)}function $s(e){return e.replace(/"/g,'"').replace(/'/g,"'").replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&")}function Pl(e){const r=e.trim().match(/^<hook_prompt(?:\s+hook_run_id="([^"]+)")?>([\s\S]*)<\/hook_prompt>$/);if(!r)return null;const n=r[1]?$s(r[1]):null,a=$s(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 wf(e){return e==="userMessage"||e==="agentMessage"}function yf(e){return e==="commandExecution"||e==="webSearch"||e==="fileRead"||e==="fileChange"||e==="image"||e==="contextCompaction"}function jf(e){return e==="agentMessage"||e==="reasoning"||e==="agentToolCall"||e==="skillToolCall"||e==="toolCall"||e==="plan"}function Nf(e,r){const n=cr(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&&yf(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=>jf(h.kind))?l:{...l,status:"Awaiting response"}:(o=!0,l))}function It(e){return typeof e.sequence=="number"&&Number.isFinite(e.sequence)}function Hr(e){return It(e)?e.sequence:Number.POSITIVE_INFINITY}function Ds(e){var m;const r=cr(e),n=[];let a=0;for(;a<r.length&&((m=r[a])==null?void 0:m.kind)==="userMessage"&&!It(r[a]);)n.push(r[a]),a+=1;const s=r.slice(a);if(!s.some(It))return r;const o=s.map(u=>Hr(u)).filter(Number.isFinite),l=o.length>0?Math.max(...o):0,i=[];let d=0;for(;d<s.length;){const u=s[d];if(It(u)){i.push({item:u,index:d,order:Hr(u)}),d+=1;continue}const p=d;for(;d<s.length&&!It(s[d]);)d+=1;const f=s.slice(p,d),g=[...s.slice(0,p)].reverse().find(It),x=s.slice(d).find(It),j=g?Hr(g):null,b=x?Hr(x):null;f.forEach((k,y)=>{let v;if(j===null&&b!==null)v=b-(f.length-y)/(f.length+1);else if(j!==null&&b!==null&&b>j){const w=b-j;v=j+(y+1)/(f.length+1)*w}else v=l+1+y/(f.length+1);i.push({item:k,index:p+y,order:v})})}const h=i.sort((u,p)=>{const f=u.order-p.order;return f===0?u.index-p.index:f}).map(u=>u.item);return[...n,...h]}function Cf(e,r){const n=cr(e),a=cr(r??[]);if(a.length===0)return Ds(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},m=d.detailText??i.detailText,u=d.previewText??i.previewText,p=d.status??i.status,f=d.sequence??i.sequence;return m!==void 0&&(h.detailText=m),u!==void 0&&(h.previewText=u),p!==void 0&&(h.status=p),f!==void 0&&(h.sequence=f),h}),l=[...s.values()];return l.length===0&&!o.some(It)||(o.push(...l),!o.some(i=>typeof i.sequence=="number"&&Number.isFinite(i.sequence)))?o:Ds(o)}function Sf(e,r){if(!e)return"";const n=cr(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 ya(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function jr(e){return e==="inProgress"||e==="sending"}function Tf(e){return zf(Ef(cr(e)))}function Ef(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 Bs(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 Lf(e){return(e==null?void 0:e.kind)==="item"&&e.item.kind==="agentMessage"&&e.item.text.trim().length>0&&!ya(e.item.status)}function If(e){return e.kind==="item"?1:e.kind==="agentActivityGroup"?e.itemCount:e.items.length}function zf(e){const r=[];let n=0;for(;n<e.length;){if(!Bs(e[n])){r.push(e[n]),n+=1;continue}const a=n;for(;n<e.length&&Bs(e[n]);)n+=1;const s=e.slice(a,n),o=s.reduce((l,i)=>l+If(i),0);if(s.length>1&&Lf(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 Rl(e,r){return[...e.map(n=>({id:n.id,startedAt:n.startedAt??""})),...r?[{id:r.id,startedAt:r.startedAt??""}]:[]]}function Nr(e,r,n){const a=e.get(r)??[];a.push(n),e.set(r,a)}function _l(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(f=>f.id)),o=new Map,l=new Map,i=[],d=[];for(const f of e)f.turnId&&s.has(f.turnId)?Nr(o,f.turnId,f):i.push(f);for(const f of r)f.turnId&&s.has(f.turnId)?Nr(l,f.turnId,f):d.push(f);const h=Rl(n,a),m=new Map,u=[],p=[...i.map(f=>({kind:"note",id:f.id,createdAt:f.createdAt??"",note:f})),...d.map(f=>({kind:"request",id:f.id,createdAt:f.createdAt,request:f}))].sort((f,g)=>f.createdAt.localeCompare(g.createdAt));for(const f of p){const g=_l(h,f.createdAt);if(!g){u.push(f);continue}Nr(m,g.id,f)}return{notesByTurnId:o,pendingRequestsByTurnId:l,beforeTurnId:m,trailing:u}}function Rf({activityNotes:e,visibleTurns:r,optimisticTurn:n}){const a=[...e].sort((u,p)=>u.createdAt.localeCompare(p.createdAt)),s=Rl(r,n),o=[],l=new Map,i=new Map,d=[],m=s.map(u=>u.startedAt).filter(u=>!!u).sort().at(-1)??null;for(const u of a){if(u.anchorTurnId==="__leading__"){o.push(u);continue}if(u.anchorTurnId){s.some(f=>f.id===u.anchorTurnId)?Nr(i,u.anchorTurnId,u):o.push(u);continue}const p=_l(s,u.createdAt);if(!p){!m||u.createdAt.localeCompare(m)<=0?o.push(u):d.push(u);continue}Nr(l,p.id,u)}return{leading:o,beforeTurnId:l,afterTurnId:i,trailing:d}}function Ml({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,m="__other__",u=e.kind==="planDecision"?"Plan":e.kind==="requestUserInput"?"Answer Required":e.title;function p(b){const k=/\s*\(recommended\)\s*$/i.test(b);return{rawLabel:b,displayLabel:b.replace(/\s*\(recommended\)\s*$/i,"").trim(),recommended:k}}function f(b){h&&(d(b),n==null||n(e.id,{answers:{[h.id]:{answers:[b]}}}))}function g(b){const k=a[b.id]??"";return Array.isArray(k)?k.map(y=>y===m?(o[b.id]??"").trim():y.trim()).filter(Boolean).join(", "):k===m?(o[b.id]??"").trim():k.trim()}function x(b){const k=a[b.id]??"";if(Array.isArray(k))return k.map(v=>v===m?(o[b.id]??"").trim():v.trim()).filter(Boolean);if(k===m){const v=(o[b.id]??"").trim();return v?[v]:[]}const y=k.trim();return y?[y]:[]}function j(b,k){s(y=>{const v=y[b],w=Array.isArray(v)?v:[],C=w.includes(k)?w.filter(N=>N!==k):[...w,k];return{...y,[b]:C}})}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:u}),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(b=>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:b.header}),t.jsx("p",{className:"timeline-primary-text mt-1 text-[13px] leading-5 sm:text-sm",children:b.question}),e.kind==="planDecision"&&b.options&&b.options.length>0?t.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:b.options.map((k,y)=>{const v=p(k.label),w=v.displayLabel.toLowerCase()==="implement";return t.jsxs("button",{type:"button",disabled:r,onClick:()=>f(k.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:k.description,children:[v.recommended?t.jsx("span",{"aria-hidden":"true",className:"absolute right-1.5 top-1 inline-flex h-3.5 w-3.5 items-center justify-center rounded-full bg-white/18 text-[10px] leading-none text-current",children:"✦"}):null,r&&i===k.label?w?"Starting...":"Saving...":v.displayLabel]},k.label)})}):b.options&&b.options.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[b.options.map(k=>{const y=p(k.label),v=a[b.id];return t.jsxs("button",{type:"button",disabled:r,onClick:()=>b.multiSelect?j(b.id,k.label):s(w=>({...w,[b.id]:k.label})),className:`relative rounded-2xl border px-3 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${(b.multiSelect?Array.isArray(v)&&v.includes(k.label):v===k.label)?"ui-status-warning":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:k.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]},k.label)}),b.isOther&&(()=>{const k=a[b.id];return t.jsx("button",{type:"button",disabled:r,onClick:()=>b.multiSelect?j(b.id,m):s(y=>({...y,[b.id]:m})),className:`rounded-2xl border px-3 py-1.5 text-[12px] leading-4 transition sm:text-[13px] ${(b.multiSelect?Array.isArray(k)&&k.includes(m):k===m)?"ui-status-info":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Not from above"})})()]}),b.isOther&&(()=>{const k=a[b.id];return(b.multiSelect?Array.isArray(k)&&k.includes(m):k===m)?t.jsx("input",{"aria-label":`${b.header} custom answer`,value:o[b.id]??"",onChange:v=>l(w=>({...w,[b.id]:v.target.value})),placeholder:"Enter a custom answer",className:"mt-3 w-full rounded-xl border border-stone-700 bg-stone-900 px-3 py-2 text-sm text-stone-100 outline-none transition focus:border-sky-300"}):null})()]}):t.jsx("input",{"aria-label":b.header,value:a[b.id]??"",onChange:k=>s(y=>({...y,[b.id]:k.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"})]},b.id))}),e.kind!=="planDecision"&&t.jsx("div",{className:"mt-3 flex justify-end",children:t.jsx("button",{type:"button",disabled:r||e.questions.some(b=>!g(b)),onClick:()=>void(n==null?void 0:n(e.id,{answers:Object.fromEntries(e.questions.map(b=>[b.id,{answers:x(b)}]))})),className:"ui-action-info rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:r?"Submitting...":"Submit"})})]})}function Al({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 $l({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:Xt(e.createdAt),className:"timeline-meta-text text-[10px]",children:yt(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 br({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($l,{note:a,onOpenThread:r,onOpenLinkedThread:n},a.id))})}function sa({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(Al,{note:a.note},a.id):t.jsx(Ml,{request:a.request,busy:r===a.request.id,onRespond:n},a.id))})}function _f({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(sa,{entries:s,respondingRequestId:n,onRespondToRequest:a})}function Mf({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($l,{note:o.note,onOpenThread:a,onOpenLinkedThread:s},o.id):o.kind==="note"?t.jsx(Al,{note:o.note},o.id):t.jsx(Ml,{request:o.request,busy:r===o.request.id,onRespond:n},o.id))})}function Af({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(m=>{const u=r[m.key]??!1,p=()=>n(m.key);return m.kind==="commandGroup"?a(m,u,p):m.kind==="fileChangeGroup"?s(m,u,p):m.kind==="searchGroup"?i(m,u,p):m.kind==="fileReadGroup"?o(m,u,p):m.kind==="toolCallGroup"||m.kind==="agentToolCallGroup"||m.kind==="skillToolCallGroup"?d(m,u,p):m.kind==="agentActivityGroup"?h(m,u,p):l(m)})})}function ur({children:e,className:r,count:n,countBadgeClassName:a,desktopIconClassName:s,expanded:o,expandedListClassName:l,icon:i,onToggleExpanded:d,runningIndicator:h,summary:m,timeMeta:u,toggleAriaLabel:p,trailingSummary:f}){return t.jsx("div",{className:`thread-graph-history-group ${r} relative min-w-0 w-full overflow-hidden rounded-[0.9rem] border px-3 py-2.5`,children:t.jsxs("div",{className:"flex items-start gap-2.5",children:[t.jsxs("div",{className:"thread-graph-history-group-icon mt-0.5 flex shrink-0 items-center",children:[t.jsxs("span",{className:`relative inline-flex h-8 w-8 items-center justify-center rounded-[0.9rem] border shadow-sm shadow-stone-950/20 ${s}`,children:[i,t.jsx("span",{className:`absolute -right-1 -top-1 inline-flex min-w-[1.1rem] items-center justify-center rounded-full border bg-stone-950/90 px-1 text-[9px] font-semibold leading-4 ${a}`,children:n})]}),h]}),t.jsxs("div",{className:"thread-graph-history-group-card min-w-0 flex-1 rounded-[0.85rem] border px-3 py-2",children:[t.jsxs("button",{type:"button","aria-expanded":o,"aria-label":p,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:m}),f||u?t.jsxs("div",{className:"inline-flex shrink-0 items-center gap-2",children:[f,u]}):null]}),o?t.jsx("div",{className:`thread-graph-history-group-list mt-3 space-y-2 border-t pt-3 ${l}`,children:e}):null]})]})})}_r();Mt();var $f=Ir("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 mn({asChild:e=!1,className:r,variant:n,...a}){const s=e?Qs:"span";return t.jsx(s,{"data-slot":"badge",className:st($f({variant:n,className:r})),...a})}function pn(e){if(!e)return!1;const r=e.trim().toLowerCase();return r==="running"||r==="in_progress"||r==="in progress"||r==="pending"}function Df(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.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 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.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 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.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 Hf(){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 Ff(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 Dl(e,r=42){const n=Ff(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 m=i.length-1;m>=0;m-=1){const u=i[m],p=h+u.length+(d.length>0?1:0);if(d.length>0&&p>r)break;d.unshift(u),h=p}if(d.length>0)return`.../${d.join("/")}${s}`}return`...${o.slice(-(r-s.length-3))}${s}`}function Of(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 nn({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,`
|
|
3958
|
+
`),j=n.kind==="userMessage"&&(n.status==="Steering"||n.status==="Accepted"||n.status==="Awaiting response");c.useEffect(()=>()=>{f.current!==null&&window.clearTimeout(f.current)},[]);async function x(){try{await navigator.clipboard.writeText(n.text),m("copied"),f.current!==null&&window.clearTimeout(f.current),f.current=window.setTimeout(()=>m("idle"),1200)}catch{m("failed"),f.current!==null&&window.clearTimeout(f.current),f.current=window.setTimeout(()=>m("idle"),1600)}}function k(){d==null||d(),p(S=>!S)}const w=n.kind==="agentMessage"?t.jsx("button",{type:"button","aria-label":"Copy agent reply",title:h==="copied"?"Copied":h==="failed"?"Copy failed":"Copy agent reply",onClick:()=>void x(),className:`thread-graph-message-copy inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border transition ${h==="copied"?"ui-status-info":h==="failed"?"ui-status-danger":""}`,children:h==="copied"?t.jsx(R.Check,{className:"h-3.5 w-3.5"}):t.jsx(R.Copy,{className:"h-3.5 w-3.5"})}):null,v=g.some(S=>kf(S.status)),y=n.kind==="agentMessage"&&b?t.jsxs("button",{type:"button","aria-label":u?"Hide chain of thought":"Show chain of thought","aria-expanded":u,title:u?"Hide CoT":"Show CoT",onClick:k,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 ${u?"is-open":""}`,children:[t.jsx(R.Brain,{className:`h-3.5 w-3.5 ${v?"animate-pulse":""}`}),t.jsx("span",{children:"CoT"}),v?t.jsx(wf,{tone:"sky"}):null]}):null,N=n.kind==="agentMessage"&&b?t.jsx("div",{className:"thread-graph-message-thinking mb-3",children:t.jsx(zr,{type:"single",collapsible:!0,value:u?"thoughts":"",className:"thread-graph-thinking-accordion w-full border-none",onValueChange:S=>p(!!S),children:t.jsx(Pr,{value:"thoughts",className:"border-b-0",children:t.jsx(Rr,{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(cr,{text:b})})})})})}):null;return t.jsx(vf,{kind:n.kind,status:j||n.kind==="agentMessage"?n.status:null,copyButton:w,metaControl:y,reasoning:N,timeLabel:l,timeTitle:i,children:n.kind==="agentMessage"?t.jsx(gf,{text:n.text,scrollRootRef:a,streaming:s,...d?{onBeforeResize:d}:{},...o!=null&&o.onOpenWorkspaceFile?{onOpenWorkspaceFile:o.onOpenWorkspaceFile}:{},...o!=null&&o.resolveHref?{resolveHref:o.resolveHref}:{}}):t.jsx(xf,{threadId:r,text:n.text,attachmentPreviewUrls:n.attachmentPreviewUrls,getImageAssetUrl:o==null?void 0:o.getImageAssetUrl})})});function yf(e){return!!(e&&typeof e.id=="string"&&typeof e.kind=="string")}function hr(e){return e.filter(yf)}function Gs(e){return e.replace(/"/g,'"').replace(/'/g,"'").replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&")}function _l(e){const r=e.trim().match(/^<hook_prompt(?:\s+hook_run_id="([^"]+)")?>([\s\S]*)<\/hook_prompt>$/);if(!r)return null;const n=r[1]?Gs(r[1]):null,a=Gs(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 jf(e){return e==="userMessage"||e==="agentMessage"}function Nf(e){return e==="commandExecution"||e==="webSearch"||e==="fileRead"||e==="fileChange"||e==="image"||e==="contextCompaction"}function Cf(e){return e==="agentMessage"||e==="reasoning"||e==="agentToolCall"||e==="skillToolCall"||e==="toolCall"||e==="plan"}function Sf(e,r){const n=hr(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=>Cf(h.kind))?l:{...l,status:"Awaiting response"}:(o=!0,l))}function zt(e){return typeof e.sequence=="number"&&Number.isFinite(e.sequence)}function Hr(e){return zt(e)?e.sequence:Number.POSITIVE_INFINITY}function Fs(e){var m;const r=hr(e),n=[];let a=0;for(;a<r.length&&((m=r[a])==null?void 0:m.kind)==="userMessage"&&!zt(r[a]);)n.push(r[a]),a+=1;const s=r.slice(a);if(!s.some(zt))return r;const o=s.map(u=>Hr(u)).filter(Number.isFinite),l=o.length>0?Math.max(...o):0,i=[];let d=0;for(;d<s.length;){const u=s[d];if(zt(u)){i.push({item:u,index:d,order:Hr(u)}),d+=1;continue}const p=d;for(;d<s.length&&!zt(s[d]);)d+=1;const f=s.slice(p,d),g=[...s.slice(0,p)].reverse().find(zt),b=s.slice(d).find(zt),j=g?Hr(g):null,x=b?Hr(b):null;f.forEach((k,w)=>{let v;if(j===null&&x!==null)v=x-(f.length-w)/(f.length+1);else if(j!==null&&x!==null&&x>j){const y=x-j;v=j+(w+1)/(f.length+1)*y}else v=l+1+w/(f.length+1);i.push({item:k,index:p+w,order:v})})}const h=i.sort((u,p)=>{const f=u.order-p.order;return f===0?u.index-p.index:f}).map(u=>u.item);return[...n,...h]}function Tf(e,r){const n=hr(e),a=hr(r??[]);if(a.length===0)return Fs(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},m=d.detailText??i.detailText,u=d.previewText??i.previewText,p=d.status??i.status,f=d.sequence??i.sequence;return m!==void 0&&(h.detailText=m),u!==void 0&&(h.previewText=u),p!==void 0&&(h.status=p),f!==void 0&&(h.sequence=f),h}),l=[...s.values()];return l.length===0&&!o.some(zt)||(o.push(...l),!o.some(i=>typeof i.sequence=="number"&&Number.isFinite(i.sequence)))?o:Fs(o)}function Ef(e,r){if(!e)return"";const n=hr(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 Ca(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function jr(e){return e==="inProgress"||e==="sending"}function Lf(e){return Rf(If(hr(e)))}function If(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 Hs(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 zf(e){return(e==null?void 0:e.kind)==="item"&&e.item.kind==="agentMessage"&&e.item.text.trim().length>0&&!Ca(e.item.status)}function Pf(e){return e.kind==="item"?1:e.kind==="agentActivityGroup"?e.itemCount:e.items.length}function Rf(e){const r=[];let n=0;for(;n<e.length;){if(!Hs(e[n])){r.push(e[n]),n+=1;continue}const a=n;for(;n<e.length&&Hs(e[n]);)n+=1;const s=e.slice(a,n),o=s.reduce((l,i)=>l+Pf(i),0);if(s.length>1&&zf(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 Ml(e,r){return[...e.map(n=>({id:n.id,startedAt:n.startedAt??""})),...r?[{id:r.id,startedAt:r.startedAt??""}]:[]]}function Nr(e,r,n){const a=e.get(r)??[];a.push(n),e.set(r,a)}function $l(e,r){return e.find(n=>r&&n.startedAt&&r.localeCompare(n.startedAt)<=0)}function Af({answeredRequestNotes:e,pendingRequests:r,visibleTurns:n,optimisticTurn:a}){const s=new Set(n.map(f=>f.id)),o=new Map,l=new Map,i=[],d=[];for(const f of e)f.turnId&&s.has(f.turnId)?Nr(o,f.turnId,f):i.push(f);for(const f of r)f.turnId&&s.has(f.turnId)?Nr(l,f.turnId,f):d.push(f);const h=Ml(n,a),m=new Map,u=[],p=[...i.map(f=>({kind:"note",id:f.id,createdAt:f.createdAt??"",note:f})),...d.map(f=>({kind:"request",id:f.id,createdAt:f.createdAt,request:f}))].sort((f,g)=>f.createdAt.localeCompare(g.createdAt));for(const f of p){const g=$l(h,f.createdAt);if(!g){u.push(f);continue}Nr(m,g.id,f)}return{notesByTurnId:o,pendingRequestsByTurnId:l,beforeTurnId:m,trailing:u}}function _f({activityNotes:e,visibleTurns:r,optimisticTurn:n}){const a=[...e].sort((u,p)=>u.createdAt.localeCompare(p.createdAt)),s=Ml(r,n),o=[],l=new Map,i=new Map,d=[],m=s.map(u=>u.startedAt).filter(u=>!!u).sort().at(-1)??null;for(const u of a){if(u.anchorTurnId==="__leading__"){o.push(u);continue}if(u.anchorTurnId){s.some(f=>f.id===u.anchorTurnId)?Nr(i,u.anchorTurnId,u):o.push(u);continue}const p=$l(s,u.createdAt);if(!p){!m||u.createdAt.localeCompare(m)<=0?o.push(u):d.push(u);continue}Nr(l,p.id,u)}return{leading:o,beforeTurnId:l,afterTurnId:i,trailing:d}}function Dl({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,m="__other__",u=e.kind==="planDecision"?"Plan":e.kind==="requestUserInput"?"Answer Required":e.title;function p(x){const k=/\s*\(recommended\)\s*$/i.test(x);return{rawLabel:x,displayLabel:x.replace(/\s*\(recommended\)\s*$/i,"").trim(),recommended:k}}function f(x){h&&(d(x),n==null||n(e.id,{answers:{[h.id]:{answers:[x]}}}))}function g(x){const k=a[x.id]??"";return Array.isArray(k)?k.map(w=>w===m?(o[x.id]??"").trim():w.trim()).filter(Boolean).join(", "):k===m?(o[x.id]??"").trim():k.trim()}function b(x){const k=a[x.id]??"";if(Array.isArray(k))return k.map(v=>v===m?(o[x.id]??"").trim():v.trim()).filter(Boolean);if(k===m){const v=(o[x.id]??"").trim();return v?[v]:[]}const w=k.trim();return w?[w]:[]}function j(x,k){s(w=>{const v=w[x],y=Array.isArray(v)?v:[],N=y.includes(k)?y.filter(S=>S!==k):[...y,k];return{...w,[x]:N}})}return t.jsxs("div",{className:"timeline-pending-card w-full rounded-[1rem] border px-3 py-3 sm:rounded-[1.2rem] sm:px-4",children:[t.jsx("div",{className:"flex items-center justify-between gap-3",children:t.jsxs("div",{children:[t.jsx("p",{className:"timeline-primary-text text-sm font-medium",children:u}),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((k,w)=>{const v=p(k.label),y=v.displayLabel.toLowerCase()==="implement";return t.jsxs("button",{type:"button",disabled:r,onClick:()=>f(k.label),className:`relative rounded-2xl border px-2.5 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${w===0?"ui-action-info":"border-stone-700 text-stone-200 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:k.description,children:[v.recommended?t.jsx("span",{"aria-hidden":"true",className:"absolute right-1.5 top-1 inline-flex h-3.5 w-3.5 items-center justify-center rounded-full bg-white/18 text-[10px] leading-none text-current",children:"✦"}):null,r&&i===k.label?y?"Starting...":"Saving...":v.displayLabel]},k.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(k=>{const w=p(k.label),v=a[x.id];return t.jsxs("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?j(x.id,k.label):s(y=>({...y,[x.id]:k.label})),className:`relative rounded-2xl border px-3 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${(x.multiSelect?Array.isArray(v)&&v.includes(k.label):v===k.label)?"ui-status-warning":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:k.description,children:[w.recommended?t.jsx("span",{"aria-hidden":"true",className:"absolute right-1.5 top-1 inline-flex h-3.5 w-3.5 items-center justify-center rounded-full bg-white/10 text-[10px] leading-none text-amber-100/90",children:"✦"}):null,w.displayLabel]},k.label)}),x.isOther&&(()=>{const k=a[x.id];return t.jsx("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?j(x.id,m):s(w=>({...w,[x.id]:m})),className:`rounded-2xl border px-3 py-1.5 text-[12px] leading-4 transition sm:text-[13px] ${(x.multiSelect?Array.isArray(k)&&k.includes(m):k===m)?"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 k=a[x.id];return(x.multiSelect?Array.isArray(k)&&k.includes(m):k===m)?t.jsx("input",{"aria-label":`${x.header} custom answer`,value:o[x.id]??"",onChange:v=>l(y=>({...y,[x.id]:v.target.value})),placeholder:"Enter a custom answer",className:"mt-3 w-full rounded-xl border border-stone-700 bg-stone-900 px-3 py-2 text-sm text-stone-100 outline-none transition focus:border-sky-300"}):null})()]}):t.jsx("input",{"aria-label":x.header,value:a[x.id]??"",onChange:k=>s(w=>({...w,[x.id]:k.target.value})),className:"mt-3 w-full rounded-xl border border-stone-700 bg-stone-900 px-3 py-2 text-sm text-stone-100 outline-none transition focus:border-amber-300"})]},x.id))}),e.kind!=="planDecision"&&t.jsx("div",{className:"mt-3 flex justify-end",children:t.jsx("button",{type:"button",disabled:r||e.questions.some(x=>!g(x)),onClick:()=>void(n==null?void 0:n(e.id,{answers:Object.fromEntries(e.questions.map(x=>[x.id,{answers:b(x)}]))})),className:"ui-action-info rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:r?"Submitting...":"Submit"})})]})}function Bl({note:e}){return t.jsxs("div",{className:"timeline-note-card w-full rounded-2xl border px-3 py-2.5",children:[t.jsx("p",{className:"timeline-meta-text text-[11px] uppercase tracking-[0.2em]",children:e.title}),t.jsx("div",{className:"mt-1 space-y-1",children:e.summaryLines.map((r,n)=>t.jsxs("p",{className:"timeline-primary-text text-[13px] leading-5",children:["You selected ",r]},`${e.id}-${n}`))})]})}function Gl({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:qt(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 br({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(Gl,{note:a,onOpenThread:r,onOpenLinkedThread:n},a.id))})}function ia({entries:e,respondingRequestId:r,onRespondToRequest:n}){return e.length===0?null:t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:e.map(a=>a.kind==="note"?t.jsx(Bl,{note:a.note},a.id):t.jsx(Dl,{request:a.request,busy:r===a.request.id,onRespond:n},a.id))})}function Mf({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(ia,{entries:s,respondingRequestId:n,onRespondToRequest:a})}function $f({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(Gl,{note:o.note,onOpenThread:a,onOpenLinkedThread:s},o.id):o.kind==="note"?t.jsx(Bl,{note:o.note},o.id):t.jsx(Dl,{request:o.request,busy:r===o.request.id,onRespond:n},o.id))})}function Df({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(m=>{const u=r[m.key]??!1,p=()=>n(m.key);return m.kind==="commandGroup"?a(m,u,p):m.kind==="fileChangeGroup"?s(m,u,p):m.kind==="searchGroup"?i(m,u,p):m.kind==="fileReadGroup"?o(m,u,p):m.kind==="toolCallGroup"||m.kind==="agentToolCallGroup"||m.kind==="skillToolCallGroup"?d(m,u,p):m.kind==="agentActivityGroup"?h(m,u,p):l(m)})})}function mr({children:e,className:r,count:n,countBadgeClassName:a,desktopIconClassName:s,expanded:o,expandedListClassName:l,icon:i,onToggleExpanded:d,runningIndicator:h,summary:m,timeMeta:u,toggleAriaLabel:p,trailingSummary:f}){return t.jsx("div",{className:`thread-graph-history-group ${r} relative min-w-0 w-full overflow-hidden rounded-[0.9rem] border px-3 py-2.5`,children:t.jsxs("div",{className:"flex items-start gap-2.5",children:[t.jsxs("div",{className:"thread-graph-history-group-icon mt-0.5 flex shrink-0 items-center",children:[t.jsxs("span",{className:`relative inline-flex h-8 w-8 items-center justify-center rounded-[0.9rem] border shadow-sm shadow-stone-950/20 ${s}`,children:[i,t.jsx("span",{className:`absolute -right-1 -top-1 inline-flex min-w-[1.1rem] items-center justify-center rounded-full border bg-stone-950/90 px-1 text-[9px] font-semibold leading-4 ${a}`,children:n})]}),h]}),t.jsxs("div",{className:"thread-graph-history-group-card min-w-0 flex-1 rounded-[0.85rem] border px-3 py-2",children:[t.jsxs("button",{type:"button","aria-expanded":o,"aria-label":p,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:m}),f||u?t.jsxs("div",{className:"inline-flex shrink-0 items-center gap-2",children:[f,u]}):null]}),o?t.jsx("div",{className:`thread-graph-history-group-list mt-3 space-y-2 border-t pt-3 ${l}`,children:e}):null]})]})})}Ar();Mt();var Bf=Ir("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 pn({asChild:e=!1,className:r,variant:n,...a}){const s=e?ro:"span";return t.jsx(s,{"data-slot":"badge",className:ot(Bf({variant:n,className:r})),...a})}function fn(e){if(!e)return!1;const r=e.trim().toLowerCase();return r==="running"||r==="in_progress"||r==="in progress"||r==="pending"}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.2 8h3.6"}),t.jsx("path",{d:"M6.2 10h1.7"})]})}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.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 Hf(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"2.75",y:"3",width:"8.5",height:"3",rx:"1.1"}),t.jsx("rect",{x:"4.25",y:"6.5",width:"8.5",height:"3",rx:"1.1"}),t.jsx("rect",{x:"5.75",y:"10",width:"7.5",height:"3",rx:"1.1"}),t.jsx("path",{d:"m6.25 4.5 1 1-1 1"}),t.jsx("path",{d:"M7.9 5.5h1.7"}),t.jsx("path",{d:"m7.75 8 1 1-1 1"}),t.jsx("path",{d:"M9.4 9h1.7"})]})}function Of(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"6",cy:"6",r:"2.3"}),t.jsx("path",{d:"m8 8 1.6 1.6"}),t.jsx("circle",{cx:"9.3",cy:"8.8",r:"2"}),t.jsx("path",{d:"m10.75 10.25 1.65 1.65"}),t.jsx("circle",{cx:"11.2",cy:"4.75",r:"1.8"}),t.jsx("path",{d:"m12.45 6 1.1 1.1"})]})}function Wf(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 Fl(e,r=42){const n=Wf(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 m=i.length-1;m>=0;m-=1){const u=i[m],p=h+u.length+(d.length>0?1:0);if(d.length>0&&p>r)break;d.unshift(u),h=p}if(d.length>0)return`.../${d.join("/")}${s}`}return`...${o.slice(-(r-s.length-3))}${s}`}function Uf(e){var a;const r=[];if(typeof e.changedFiles=="number"&&e.changedFiles>0&&r.push(`${e.changedFiles} ${e.changedFiles===1?"file":"files"}`),typeof e.addedLines=="number"&&e.addedLines>0&&r.push(`+${e.addedLines}`),typeof e.removedLines=="number"&&e.removedLines>0&&r.push(`-${e.removedLines}`),r.length>0)return r;const n=(a=e.previewText)==null?void 0:a.trim();return n?n.replace(/\bfiles changed\b/gi,"files").replace(/\bfile changed\b/gi,"file").split("·").map(s=>s.trim()).filter(Boolean):[]}function an({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 Vf(e){var n;const r=e.replace(/\r\n/g,`
|
|
3959
3959
|
`).split(`
|
|
3960
|
-
`);for(;r.length>1&&((n=r.at(-1))==null?void 0:n.trim())==="";)r.pop();return r}function xt(e){const r=Wf(e);return r.length===1?{firstLine:r[0]??"",showGap:!1,isTruncated:!1}:{firstLine:r[0]??"",showGap:!0,isTruncated:!0}}function Bl(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(P.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"}:r==="failed"||r==="failure"||r==="error"||r==="errored"?{className:"is-failed",icon:t.jsx(P.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"}:pn(e)?{className:"is-pending",icon:t.jsx(P.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 Uf(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 Vf(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 Yt({actions:e,children:r,className:n,headerMeta:a,icon:s,item:o,timeMeta:l,title:i,tone:d}){const h=Bl(o.status);return t.jsxs("div",{className:`thread-graph-event thread-graph-history-event ${Vf(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(mn,{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 mr({actionLabel:e="Open details",actionTitle:r,autoOpen:n=!1,className:a,details:s,icon:o,item:l,onOpen:i,preview:d,timeMeta:h,title:m,tone:u}){const p=Bl(l.status),[f,g]=c.useState(n?"item-1":void 0),x=c.useRef(n);return c.useLayoutEffect(()=>{n?g("item-1"):x.current&&g(void 0),x.current=n},[n,l.id]),t.jsx("div",{className:`thread-graph-event thread-graph-history-tool ${Uf(u)} ${a??""}`,children:t.jsx(zr,{type:"single",collapsible:!0,onValueChange:j=>{g(j||void 0)},className:"thread-graph-tool-accordion thread-graph-history-tool-accordion w-full overflow-hidden rounded-lg border",value:f??"",children:t.jsxs(Pr,{value:"item-1",className:"border-0",children:[t.jsxs(hn,{"aria-label":`${f==="item-1"?"Collapse":"Expand"} ${m} 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:m}),t.jsxs(mn,{variant:"outline",className:`thread-graph-tool-badge ${p.className} ml-1 sm:ml-2 rounded-full px-2 py-0.5 text-xs font-normal`,title:p.label,"aria-label":`Status: ${p.label}`,children:[p.icon,t.jsx("span",{className:"thread-graph-status-label",children:p.label})]})]}),h?t.jsx("span",{className:"thread-graph-history-tool-time shrink-0",children:h}):null]}),t.jsxs(Rr,{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(dr,{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(P.ExternalLink,{className:"h-3.5 w-3.5"}),r]})]})]})})})}var Xf=c.memo(function({item:r,scrollRootRef:n,onBeforeResize:a,timeMeta:s}){return t.jsx(Yt,{className:"thread-graph-event-plan",icon:t.jsx(P.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(zl,{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}:{}})})})}),qf=c.memo(function({item:r,timeMeta:n}){const a=pn(r.status)||r.text==="Compacting context",s=a?"Compacting context":"Context compacted",o=r.detailText&&r.detailText!==s?r.detailText:null;return t.jsxs(Yt,{className:"thread-graph-event-context",icon:t.jsx(P.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(nn,{tone:"emerald"}):null]}),o?t.jsx("p",{className:"thread-graph-history-event-secondary",title:o,children:o}):null]})}),Kf=c.memo(function({item:r,timeMeta:n}){return t.jsx(Yt,{className:"thread-graph-event-generic",icon:t.jsx(P.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(dr,{text:r.text})})})}),Yf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:s}){const o=xt(n.previewText??n.text);return t.jsx(mr,{actionLabel:"Open full command",actionTitle:"Command Output",autoOpen:r,className:"thread-graph-event-command",icon:t.jsx(P.Terminal,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Command Output"),preview:o,timeMeta:s,title:"command",tone:"command"})}),Zf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:s}){const o=xt(n.text);return t.jsx(mr,{actionLabel:"Open full tool call",actionTitle:"Tool Call Details",autoOpen:r,className:"thread-graph-event-tool",icon:t.jsx(P.Wrench,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Tool Call Details"),preview:o,timeMeta:s,title:"tool_call",tone:"tool"})}),Jf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:s}){const o=xt(n.text);return t.jsx(mr,{actionLabel:"Open agent details",actionTitle:"Agent Details",autoOpen:r,className:"thread-graph-event-agent-tool",icon:t.jsx(P.Bot,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Agent Details"),preview:o,timeMeta:s,title:"agent",tone:"agent"})}),Qf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:s}){const o=xt(n.text);return t.jsx(mr,{actionLabel:"Open skill details",actionTitle:"Skill Details",autoOpen:r,className:"thread-graph-event-skill-tool",icon:t.jsx(P.Sparkles,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Skill Details"),preview:o,timeMeta:s,title:"skill",tone:"skill"})}),eg=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=xt(o);return t.jsx(mr,{actionLabel:"Open full web search",actionTitle:"Web Search Details",autoOpen:r,className:"thread-graph-event-search",icon:t.jsx(P.Search,{className:"h-4 w-4"}),item:n,onOpen:()=>a("Web Search Details",l),preview:i,timeMeta:s,title:"web_search",tone:"search"})}),tg=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=xt(o);return t.jsx(mr,{actionLabel:"Open full file read",actionTitle:"File Read Details",autoOpen:r,className:"thread-graph-event-file-read",icon:t.jsx(P.FileText,{className:"h-4 w-4"}),item:n,onOpen:()=>a("File Read Details",l),preview:i,timeMeta:s,title:"file_read",tone:"fileRead"})}),rg=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(Yt,{className:"thread-graph-event-image",icon:t.jsx(P.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]})}),ng=c.memo(function({item:r,onOpen:n,timeMeta:a}){var u,p,f;const s=(u=r.previewText)!=null&&u.trim()&&r.text.trim()!==r.previewText.trim()?r.text.trim():null,o=((p=r.detailText)==null?void 0:p.trim())||null,l=Dl(s??((f=r.previewText)==null?void 0:f.trim())??r.text,48),i=Of(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))})]}),m=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(Yt,{className:"thread-graph-event-file-change",headerMeta:m,icon:t.jsx(P.FilePenLine,{className:"h-4 w-4"}),item:r,timeMeta:a,title:"file_change",tone:"fileChange"})}),ag=c.memo(function({item:r,onSelect:n,timeMeta:a}){const s=wa(),[o,l]=c.useState(!1),i=r.artifact,d=i?s.renderArtifact({artifact:i,expanded:o,onToggleExpanded:()=>l(h=>!h)}):null;return t.jsx(Yt,{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(P.PackageOpen,{className:"h-3.5 w-3.5"}),"Inspect"]}):null]}),className:"thread-graph-event-artifact",icon:t.jsx(P.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]})})}),sg=c.memo(function({item:r,timeMeta:n}){var h,m;const a=((h=r.hookOutputEntries)==null?void 0:h.map(u=>u.text.trim()).filter(Boolean).join(`
|
|
3961
|
-
`).trim())??"",s=r.hookEventLabel?`${r.hookEventLabel} hook`:r.text,o=((m=r.hookStatusMessage)==null?void 0:m.trim())||(r.previewText&&r.previewText!==r.hookStatusMessage?r.previewText.trim():"")||r.text.trim(),i=xt(a||(o&&o!==s?o:s)),d=!!(a&&i.showGap);return t.jsx(Yt,{className:"thread-graph-event-hook",icon:t.jsx(P.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(dr,{text:i.firstLine})]}):t.jsx(dr,{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]})})}),og=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s,timeMeta:o}){const l=r.filter(d=>pn(d.status)).length,i=r.length===1?"1 command":`${r.length} commands`;return t.jsx(ur,{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(Gf,{}),onToggleExpanded:a,runningIndicator:l>0?t.jsx(nn,{}):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(nn,{})}):null]}),timeMeta:o,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} command entries`,children:r.map((d,h)=>{const m=xt(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:m.firstLine}),m.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},d.id)})})}),lg=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s,timeMeta:o}){var m;const l=r.filter(u=>pn(u.status)).length,i=((m=r[0])==null?void 0:m.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(ur,{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(P.Bot,{className:"h-3.5 w-3.5"}):t.jsx(P.Wrench,{className:"h-3.5 w-3.5"}),onToggleExpanded:a,runningIndicator:l>0?t.jsx(nn,{}):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((u,p)=>{const f=xt(u.text);return t.jsx("button",{type:"button","aria-label":`Open ${d} ${p+1}`,onClick:()=>s(u,`${d} ${p+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:f.firstLine}),u.status?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-xs",children:u.status}):null]})},u.id)})})}),ig=c.memo(function({itemCount:r,expanded:n,onToggleExpanded:a,timeMeta:s,children:o}){const l=r===1?"1 operation":`${r} operations`;return t.jsx(ur,{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(P.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})}),dg=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(ur,{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(Hf,{}),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 p,f;const h=((p=i.previewText)==null?void 0:p.trim())||i.text||"Web search",m=xt(h),u=((f=i.detailText)==null?void 0:f.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}`,u),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"rounded-full border border-sky-300/18 bg-sky-300/[0.07] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-sky-100",children:["Search ",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:m.firstLine}),m.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},i.id)})})}),cg=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(ur,{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(Bf,{}),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 p,f;const h=((p=i.previewText)==null?void 0:p.trim())||i.text||"File read",m=xt(h),u=((f=i.detailText)==null?void 0:f.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}`,u),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"rounded-full border border-cyan-300/18 bg-cyan-300/[0.07] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-cyan-100",children:["Read ",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:m.firstLine}),m.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},i.id)})})}),hg=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s,timeMeta:o}){const l=r.reduce((m,u)=>m+(u.changedFiles??0),0),i=r.reduce((m,u)=>m+(u.addedLines??0),0),d=r.reduce((m,u)=>m+(u.removedLines??0),0),h=r.length===1?"1 file change":`${r.length} file changes`;return t.jsx(ur,{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(Df,{}),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((m,u)=>{var g,x,j,b;const p=((g=m.detailText)==null?void 0:g.trim())||((x=m.previewText)==null?void 0:x.trim())||m.text,f=(j=m.previewText)!=null&&j.trim()&&m.text.trim()!==m.previewText.trim()?m.text.trim():((b=m.previewText)==null?void 0:b.trim())||m.text;return t.jsx("button",{type:"button","aria-label":`Open grouped file change ${u+1}`,onClick:()=>s(`File Change ${u+1}`,p),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-detail-text min-w-0 flex-1 text-sm leading-6",title:f,children:Dl(f,34)}),t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[(m.addedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-add",children:["+",m.addedLines]}):null,(m.removedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-remove",children:["-",m.removedLines]}):null]})]})},m.id)})})});function ug(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 mg({status:e}){const r=ug(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(mn,{"aria-label":n,title:n.replace("Plan step status: ",""),className:a,children:r==="completed"?t.jsx(P.CheckCircle2,{className:"h-3.5 w-3.5"}):r==="in_progress"?t.jsx(P.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):r==="pending"?t.jsx(P.Clock3,{className:"h-3.5 w-3.5"}):r==="failed"?t.jsx(P.XCircle,{className:"h-3.5 w-3.5"}):t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.14em]",children:"?"})})}function pg({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(mn,{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(mg,{status:r.status})]},`${e.turnId}-${n}`))})]})}function fg({footer:e,history:r,liveHookPrompt:n,liveOutput:a,livePlan:s}){return t.jsxs(t.Fragment,{children:[r,s?t.jsx(pg,{livePlan:s}):null,n??a??null,e]})}function gg({absoluteIndex:e,body:r,collapsed:n,collapsedBody:a,error:s,footer:o,headerStatus:l,isActive:i=!1,refCallback:d,startedAt:h,timeLabel:m,timeTitle:u,tokenSummary:p}){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:u,className:"thread-graph-turn-time shrink-0 text-[10px] sm:text-[11px]",children:m}),l,s?t.jsx("p",{className:"hidden truncate text-[11px] text-rose-200 sm:block",children:s}):null]}),p]})}),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 xg(){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 bg(){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 Gs(){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 vg(){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 vr(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 Gl(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 sr(e){return!Number.isFinite(e)||e<=0?"$0.0000":`$${e.toFixed(4)}`}function Fr(e,r,n){const a=e??null;return!Number.isFinite(a??NaN)||a===null||r<=0||n<=0?null:a*n/r}function Hl(e){var d,h,m,u,p,f;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:vr(n),tokenRawValue:n,usdCompactValue:e.priceEstimate?sr(e.priceEstimate.inputUsd):"--",usdRawValue:((h=e.priceEstimate)==null?void 0:h.inputUsd)??null,className:"token-badge-in",icon:t.jsx(xg,{})}:null,a>0?{id:"cache",label:"Cached input",tokenCompactValue:vr(a),tokenRawValue:a,usdCompactValue:e.priceEstimate?sr(e.priceEstimate.cachedInputUsd):"--",usdRawValue:((m=e.priceEstimate)==null?void 0:m.cachedInputUsd)??null,className:"token-badge-cache",icon:t.jsx(Gs,{})}:null,s>0?{id:"cache-write",label:"Cache write",tokenCompactValue:vr(s),tokenRawValue:s,usdCompactValue:e.priceEstimate?sr(e.priceEstimate.cacheWriteInputUsd??0):"--",usdRawValue:((u=e.priceEstimate)==null?void 0:u.cacheWriteInputUsd)??null,className:"token-badge-cache",icon:t.jsx(Gs,{})}:null,l>0?{id:"out",label:"Output",tokenCompactValue:vr(l),tokenRawValue:l,usdCompactValue:e.priceEstimate?sr(Fr(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),l)??0):"--",usdRawValue:Fr((p=e.priceEstimate)==null?void 0:p.outputUsd,Math.max(r.outputTokens,0),l),className:"token-badge-out",icon:t.jsx(bg,{})}:null,o>0?{id:"reason",label:"Reasoning",tokenCompactValue:vr(o),tokenRawValue:o,usdCompactValue:e.priceEstimate?sr(Fr(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),o)??0):"--",usdRawValue:Fr((f=e.priceEstimate)==null?void 0:f.outputUsd,Math.max(r.outputTokens,0),o),className:"token-badge-reason",icon:t.jsx(vg,{})}:null].filter(g=>g!==null)}function kg(e){return Hl(e).map(r=>({id:r.id,label:r.tokenCompactValue,title:`${r.label}: ${r.tokenRawValue} tokens`,className:r.className,icon:r.icon}))}function Fl(e){return{label:e.priceEstimate?Gl(e.priceEstimate.totalUsd):"--",title:e.priceEstimate===null||e.priceEstimate===void 0?"Price estimate unavailable for this model.":`Estimated cost: ${sr(e.priceEstimate.totalUsd)}`,className:e.priceEstimate?"token-badge-total":"token-badge-empty"}}var Pn="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 wg({turn:e}){const r=Hl(e),n=Fl(e),[a,s]=c.useState(!1),[o,l]=c.useState(!1),[i,d]=c.useState(0),h=c.useRef(null),m=c.useRef(null),u=c.useRef(null);if(c.useLayoutEffect(()=>{if(!a||r.length===0){d(0);return}const f=()=>{const g=h.current,x=u.current;if(!g||!x)return;const j=g.getBoundingClientRect(),b=x.offsetWidth||x.getBoundingClientRect().width;if(b<=0)return;const k=window.innerWidth||document.documentElement.clientWidth,y=12,v=j.left+j.width/2-b/2,w=y,C=Math.max(w,k-y-b),N=Math.min(Math.max(v,w),C);d(Math.round(N-v))};return f(),window.addEventListener("resize",f),()=>{window.removeEventListener("resize",f)}},[r.length,a]),c.useEffect(()=>{if(!a&&!o)return;const f=g=>{g.target instanceof Node&&(h.current&&!h.current.contains(g.target)&&s(!1),m.current&&!m.current.contains(g.target)&&l(!1))};return document.addEventListener("pointerdown",f),()=>{document.removeEventListener("pointerdown",f)}},[o,a]),!n&&r.length===0)return null;const p=()=>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(f=>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:`${f.label}: ${f.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:f.icon}),t.jsx("span",{className:"thread-token-popover-strong font-medium",children:f.usdCompactValue})]}),t.jsx("span",{className:"thread-token-popover-text shrink-0 font-medium",children:f.tokenCompactValue})]},f.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:m,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:`${Pn} 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:p()}):null]}):null,r.map(f=>t.jsxs("span",{className:`${Pn} ${f.className}`,title:`${f.label}: ${f.usdCompactValue}, ${f.tokenRawValue} tokens`,children:[f.icon,t.jsx("span",{className:"thread-token-badge-value font-medium",children:f.tokenCompactValue})]},f.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(f=>!f),className:`${Pn} 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:u,className:"absolute left-1/2 top-full z-30 mt-1.5",style:{transform:`translateX(${i}px) translateX(-50%)`},children:p()}):null]})]})}function yg({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 Hs(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 jg(e){switch(e.kind){case"fileChange":case"webSearch":case"image":case"contextCompaction":return!0;case"commandExecution":case"toolCall":return!ya(e.status);default:return!1}}function Ng(e,r,n){if(!e||!jr(n))return e;const a=e.plan.findIndex(i=>Hs(i.status)==="in_progress");if(a<0)return e;const s=e.plan.findIndex((i,d)=>d>a&&Hs(i.status)==="pending");if(s<0||!r.some(i=>jg(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 Cg(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 Fs({status:e}){const r=Tl(e);return e==="completed"?t.jsx("span",{"aria-label":r,title:r,className:"timeline-status-icon timeline-status-icon-success inline-flex h-4 w-4 items-center justify-center",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m3.75 8.25 2.5 2.5 6-6"})})}):e==="failed"?t.jsx("span",{"aria-label":r,title:r,className:"timeline-status-icon timeline-status-icon-failed inline-flex h-4 w-4 items-center justify-center",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m5 5 6 6M11 5l-6 6"})})}):e==="interrupted"?t.jsx("span",{"aria-label":r,title:r,className:"timeline-status-icon timeline-status-icon-warning inline-flex h-4 w-4 items-center justify-center",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M6 4.5v7M10 4.5v7"})})}):t.jsx("span",{"aria-label":r,title:r,className:"inline-flex min-w-[1.25rem] items-center justify-center text-sky-200",children:t.jsx(yg,{tone:"emerald"})})}function Os({turn:e,variant:r="header"}){const n=Tl(e.status),a=Cg(e),s=kg(e),o=Fl(e),l=jr(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(Fs,{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:Xt(e.startedAt),className:"timeline-meta-text shrink-0 text-[11px]",children:yt(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(Fs,{status:e.status}),t.jsx("span",{className:"timeline-meta-text min-w-0 truncate",children:a})]})}function Sg(e,r){return e.createdAt??r}var ja=c.memo(function({threadId:r,item:n,scrollRootRef:a,onOpenExpandedText:s,onOpenCommandDetail:o,onOpenToolCallDetail:l,onOpenDeferredHistoryItemDetail:i,onSelectArtifact:d,onBeforeMessageResize:h,adapter:m,timeLabel:u,timeTitle:p,timeMeta:f,autoOpenToolDetails:g=!1}){var x,j,b;if(wf(n.kind))return t.jsx(Rt,{threadId:r,item:n,scrollRootRef:a,timeLabel:u,timeTitle:p,...h?{onBeforeMessageResize:h}:{},...m?{adapter:m}:{}});if(n.kind==="reasoning")return t.jsx(Rt,{item:{...n,kind:"agentMessage",status:n.status??null},scrollRootRef:a,timeLabel:u,timeTitle:p,...h?{onBeforeMessageResize:h}:{}});if(n.kind==="artifact")return t.jsx(ag,{item:n,timeMeta:f,...d?{onSelect:(k,y)=>d({item:k,artifact:y})}:{}});if(n.kind==="commandExecution")return t.jsx(Yf,{autoOpen:g,item:n,onOpen:o,timeMeta:f});if(n.kind==="toolCall")return t.jsx(Zf,{autoOpen:g,item:n,onOpen:l,timeMeta:f});if(n.kind==="agentToolCall")return t.jsx(Jf,{autoOpen:g,item:n,onOpen:l,timeMeta:f});if(n.kind==="skillToolCall")return t.jsx(Qf,{autoOpen:g,item:n,onOpen:l,timeMeta:f});if(n.kind==="webSearch"){const k=n,y=((x=k.detailText)==null?void 0:x.trim())||k.text||"Web search";return t.jsx(eg,{autoOpen:g,item:k,timeMeta:f,onOpen:()=>i(k,"Web Search Details",y,"Loading full web search details...","Unable to load full web search details.")})}if(n.kind==="fileRead"){const k=n,y=((j=k.detailText)==null?void 0:j.trim())||k.text||"File read";return t.jsx(tg,{autoOpen:g,item:k,timeMeta:f,onOpen:()=>i(k,"File Read Details",y,"Loading full file read details...","Unable to load full file read details.")})}if(n.kind==="image")return t.jsx(rg,{threadId:r,item:n,onOpen:s,getImageAssetUrl:m==null?void 0:m.getImageAssetUrl,timeMeta:f});if(n.kind==="plan")return t.jsx(Xf,{item:n,scrollRootRef:a,timeMeta:f,...h?{onBeforeResize:h}:{}});if(n.kind==="fileChange"){const k=n,y=((b=k.detailText)==null?void 0:b.trim())||k.text||"File change";return t.jsx(ng,{item:k,timeMeta:f,onOpen:()=>i(k,"File Change Details",y,"Loading full file change details...","Unable to load full file change details.")})}return n.kind==="contextCompaction"?t.jsx(qf,{item:n,timeMeta:f}):n.kind==="hook"?t.jsx(sg,{item:n,timeMeta:f}):t.jsx(Kf,{item:n,timeMeta:f})});function Ws(e){return e==="completed"||e==="failed"||e==="interrupted"}function Tg(e){const r=Date.parse(e.createdAt??"");return Number.isFinite(r)?r:null}function Eg(e){let r=null;for(const n of e){const a=Tg(n);a!==null&&(r=r===null?a:Math.max(r,a))}return r}function Lg(e,r){const n=Date.parse(e??""),a=Eg(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 Ig(e,r){const n=Date.parse(e??""),a=Date.parse(r??"");if(!Number.isFinite(n)||!Number.isFinite(a))return r?yt(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 Cr({absoluteLabel:e,className:r="",timestamp:n,turnStartedAt:a}){const[s,o]=c.useState(!1);if(!n)return null;const l=Xt(n),i=Ig(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(m=>!m)},onKeyDown:h=>{h.key!=="Enter"&&h.key!==" "||(h.preventDefault(),h.stopPropagation(),o(m=>!m))},children:t.jsx("time",{dateTime:n,children:d})})}function Ft(e){var r;return e.kind==="item"?e.item.createdAt??null:e.kind==="agentActivityGroup"?e.entries[0]?Ft(e.entries[0]):null:((r=e.items.find(n=>n.createdAt))==null?void 0:r.createdAt)??null}function zg(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 Rn=c.memo(function({threadId:r,adapter:n,turn:a,absoluteIndex:s,isCollapsed:o,livePlan:l,liveItems:i,liveOutput:d,forceActive:h=!1,onToggleCollapse:m,onOpenExpandedText:u,onOpenCommandDetail:p,onOpenToolCallDetail:f,onOpenDeferredHistoryItemDetail:g,onSelectArtifact:x,onBeforeMessageResize:j,scrollRootRef:b,articleRef:k,isLatestVisibleTurn:y=!1}){const v=!!l||!!d||!!(i&&i.length>0),w=h||jr(a.status)||v||y,C=w&&!jr(a.status)?{...a,status:"inProgress"}:a,N=c.useMemo(()=>Cf(a.items,i),[i,a.items]),E=c.useMemo(()=>Ng(l,N,a.status),[l,N,a.status]),R=c.useMemo(()=>Sf(d,N),[d,N]),_=c.useMemo(()=>Nf(N,w),[w,N]),Y=c.useMemo(()=>Tf(_),[_]),W=h||jr(a.status)||v,re=yt(a.startedAt),F=Xt(a.startedAt),A=c.useMemo(()=>Pl(R),[R]),[J,Z]=c.useState({}),M=c.useCallback(K=>{Z(de=>({...de,[K]:!de[K]}))},[]),ie=t.jsx(Ol,{entries:Y,expandedGroups:J,onToggleGroupedItem:M,threadId:r,scrollRootRef:b,onOpenExpandedText:u,onOpenCommandDetail:p,onOpenToolCallDetail:f,onOpenDeferredHistoryItemDetail:g,...j?{onBeforeMessageResize:j}:{},fallbackTimestamp:a.startedAt,fallbackTimeLabel:re,fallbackTimeTitle:F,turnStartedAt:a.startedAt,autoOpenLatestToolDetails:W,...x?{onSelectArtifact:x}:{},...n?{adapter:n}:{}}),O=A?t.jsx(ja,{threadId:r,item:A,scrollRootRef:b,onOpenExpandedText:u,onOpenCommandDetail:p,onOpenToolCallDetail:f,onOpenDeferredHistoryItemDetail:g,timeLabel:a.startedAt?t.jsx(Cr,{absoluteLabel:re,timestamp:a.startedAt,turnStartedAt:a.startedAt}):re,timeTitle:F,timeMeta:null,...x?{onSelectArtifact:x}:{},...n?{adapter:n}:{}}):null,G=!A&&R?t.jsx(Rt,{item:{id:"live-agent-message",kind:"agentMessage",text:R},scrollRootRef:b,timeLabel:a.startedAt?t.jsx(Cr,{absoluteLabel:re,timestamp:a.startedAt,turnStartedAt:a.startedAt}):re,timeTitle:F,streaming:!0,...j?{onBeforeMessageResize:j}:{}}):null,H=w?t.jsx(Os,{turn:C,variant:"footer"}):null,T=c.useMemo(()=>zg(Y),[Y]),$=c.useMemo(()=>Lg(a.startedAt,N),[N,a.startedAt]),D=T.hiddenEntries.length>0,L=o&&D,U=Ws(a.status)&&D&&!L?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:()=>m(a.id,!1),"aria-label":`${$}. Collapse turn ${s}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:$}),t.jsx(P.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,B=Ws(a.status)&&D?t.jsxs("div",{className:"thread-graph-turn-collapsed-summary space-y-2",children:[T.users.map(K=>t.jsx(Rt,{threadId:r,item:K,scrollRootRef:b,timeLabel:K.createdAt?yt(K.createdAt):re,timeTitle:K.createdAt?Xt(K.createdAt):F,...j?{onBeforeMessageResize:j}:{},...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:()=>m(a.id,!0),"aria-label":`${$}. Expand turn ${s}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:$}),t.jsx(P.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(Rt,{threadId:r,item:T.finalAgent,scrollRootRef:b,timeLabel:T.finalAgent.createdAt?t.jsx(Cr,{absoluteLabel:yt(T.finalAgent.createdAt),timestamp:T.finalAgent.createdAt,turnStartedAt:a.startedAt}):re,timeTitle:T.finalAgent.createdAt?Xt(T.finalAgent.createdAt):F,...j?{onBeforeMessageResize:j}:{},...n?{adapter:n}:{}}):null]}):null,le=t.jsx(fg,{footer:H,history:t.jsxs(t.Fragment,{children:[U,ie]}),liveHookPrompt:O,liveOutput:G,livePlan:E});return t.jsx(gg,{absoluteIndex:s,body:le,collapsed:L,collapsedBody:B,error:a.error,headerStatus:t.jsx(Os,{turn:a}),isActive:w,refCallback:k,startedAt:a.startedAt,timeLabel:re,timeTitle:F,tokenSummary:t.jsx(wg,{turn:a})})});function Ol({entries:e,expandedGroups:r,onToggleGroupedItem:n,threadId:a,scrollRootRef:s,onOpenExpandedText:o,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,onSelectArtifact:h,onBeforeMessageResize:m,adapter:u,fallbackTimestamp:p,fallbackTimeLabel:f,fallbackTimeTitle:g,turnStartedAt:x,autoOpenLatestToolDetails:j=!1}){var y;const b=((y=e.at(-1))==null?void 0:y.key)??null,k=c.useCallback(v=>v?t.jsx(Cr,{absoluteLabel:yt(v),timestamp:v,turnStartedAt:x??p}):null,[p,x]);return t.jsx(Af,{entries:e,expandedGroups:r,onToggleGroupedItem:n,renderCommandGroup:(v,w,C)=>t.jsx(og,{items:v.items,expanded:w,onToggleExpanded:C,onOpen:l,timeMeta:k(Ft(v))},v.key),renderFileChangeGroup:(v,w,C)=>t.jsx(hg,{items:v.items,expanded:w,onToggleExpanded:C,onOpen:o,timeMeta:k(Ft(v))},v.key),renderSearchGroup:(v,w,C)=>t.jsx(dg,{items:v.items,expanded:w,onToggleExpanded:C,onOpen:o,timeMeta:k(Ft(v))},v.key),renderFileReadGroup:(v,w,C)=>t.jsx(cg,{items:v.items,expanded:w,onToggleExpanded:C,onOpen:o,timeMeta:k(Ft(v))},v.key),renderToolCallGroup:(v,w,C)=>t.jsx(lg,{items:v.items,expanded:w,onToggleExpanded:C,onOpen:i,timeMeta:k(Ft(v))},v.key),renderAgentActivityGroup:(v,w,C)=>t.jsx(ig,{itemCount:v.itemCount,expanded:w,onToggleExpanded:C,timeMeta:k(Ft(v.entries[0])),children:t.jsx(Ol,{entries:v.entries,expandedGroups:r,onToggleGroupedItem:n,threadId:a,scrollRootRef:s,onOpenExpandedText:o,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,...m?{onBeforeMessageResize:m}:{},fallbackTimestamp:p,fallbackTimeLabel:f,fallbackTimeTitle:g,turnStartedAt:x,autoOpenLatestToolDetails:!1,...h?{onSelectArtifact:h}:{},...u?{adapter:u}:{}})},v.key),renderItem:v=>{const w=Sg(v.item,p??null),N=v.item.kind==="userMessage"?v.item.createdAt?yt(w):f:v.item.createdAt?t.jsx(Cr,{absoluteLabel:yt(w),timestamp:w,turnStartedAt:x??p}):f;return t.jsx(ja,{threadId:a,item:v.item,scrollRootRef:s,timeLabel:N,timeTitle:v.item.createdAt?Xt(w):g,timeMeta:k(w),autoOpenToolDetails:j&&v.key===b,onOpenExpandedText:o,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,...m?{onBeforeMessageResize:m}:{},...h?{onSelectArtifact:h}:{},...u?{adapter:u}:{}},v.key)}})}var Us=3,Pg=3,oa=80;function kr(e,r=oa){return e.scrollHeight-e.scrollTop-e.clientHeight<=r}function Rg(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 _g(e){return e.map(n=>{const a=n.createdAt;return typeof a=="string"&&a.trim()?a:null}).filter(n=>!!n).sort()[0]??null}function Mg(e,r){return{id:e,startedAt:_g(r),status:"inProgress",error:null,model:null,reasoningEffort:null,reasoningEffortAvailable:null,tokenUsage:null,priceEstimate:null,items:[]}}function Vs(e,r,n){return{id:e.id,kind:e.kind,title:r,text:n}}function Ag({loadHistoryItemDetail:e,onSelectHistoryItemDetail:r}){const n=c.useRef(0),a=c.useRef(new Map),[s,o]=c.useState(null),l=c.useCallback((f,g)=>{o({title:f,text:g})},[]),i=c.useCallback((f,g,x)=>{if(x&&r){r({item:f,detail:g});return}o({title:g.title,text:g.text})},[r]),d=c.useCallback(async({item:f,fallbackTitle:g,fallbackText:x,loadingText:j,errorText:b,useSelectionCallback:k})=>{if(!f.hasDeferredDetail||!e){i(f,Vs(f,g,x),k);return}const y=a.current.get(f.id);if(y){i(f,y,k);return}const v=n.current+1;n.current=v,k&&r||o({title:g,text:j});try{const w=await e(f.id);if(a.current.set(f.id,w),n.current!==v)return;i(f,w,k)}catch(w){if(n.current!==v)return;i(f,Vs(f,g,w instanceof Error?w.message:b),k)}},[e,r,i]),h=c.useCallback(async(f,g)=>{var x;await d({item:f,fallbackTitle:g,fallbackText:((x=f.detailText)==null?void 0:x.trim())||f.text||"Command output",loadingText:"Loading full command output...",errorText:"Unable to load full command output.",useSelectionCallback:!0})},[d]),m=c.useCallback(async(f,g)=>{var x;await d({item:f,fallbackTitle:g,fallbackText:((x=f.detailText)==null?void 0:x.trim())||f.text||"Tool call",loadingText:"Loading full tool call details...",errorText:"Unable to load full tool call details.",useSelectionCallback:!0})},[d]),u=c.useCallback(async(f,g,x,j,b)=>{await d({item:f,fallbackTitle:g,fallbackText:x,loadingText:j,errorText:b,useSelectionCallback:!1})},[d]),p=c.useCallback(()=>{n.current+=1,o(null)},[]);return{expandedText:s,openExpandedText:l,openCommandDetail:h,openToolCallDetail:m,openDeferredHistoryItemDetail:u,closeExpandedText:p}}function $g(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 Dg({threadId:e,turnsLength:r,totalTurnCount:n,loadingEarlier:a,onLoadEarlier:s,scrollRequestKey:o,bottomSpacer:l,onTailVisibilityChange:i,contentRevisionInputs:d}){const h=c.useRef(null),m=c.useRef(null),u=c.useRef(o),p=c.useRef(null),f=c.useRef(l),g=c.useRef(0),x=c.useRef(0),j=c.useRef(null),b=c.useRef(null),k=c.useRef(null),y=c.useRef(!0),v=c.useRef(!0),w=c.useRef(!1),C=c.useRef(!1),N=c.useRef(!1),E=c.useRef(!1),R=c.useRef(null),_=c.useRef(0),[Y,W]=c.useState(Us),[re,F]=c.useState(0),[A,J]=c.useState(!0),Z=$g(d),M=typeof s=="function"||n!==void 0,ie=n??r,O=M?0:Math.max(0,r-Y),H=(M?Math.max(0,ie-r):0)+O,T=M?r:r-O,$=M?0:r-T,D=M?Math.max(0,ie-r):0,L=M?D+$:$,S=!M&&L>0&&re>=2,U=M&&D>0&&$===0&&typeof s=="function",B=c.useCallback(()=>{const Q=h.current;if(!Q){j.current=null;return}j.current={scrollHeight:Q.scrollHeight,scrollTop:Q.scrollTop}},[]),le=c.useCallback(()=>!U||a||N.current?!1:(B(),N.current=!0,E.current=!1,_.current=0,s==null||s(),!0),[U,a,s,B]),K=c.useCallback(()=>{const Q=h.current,me=b.current;if(!Q)return;const ke=me?Rg(Q,me):kr(Q);y.current=ke,J(Ne=>Ne===ke?Ne:ke)},[]),de=c.useCallback(()=>{const Q=h.current;if(Q){C.current=!0;const me=Q.scrollTop,ke=x.current,Ne=me-ke;x.current=me,kr(Q,1)?(w.current=!1,v.current=!0):Ne<-1?(w.current=!0,v.current=!1):Ne>1&&(v.current=!w.current&&kr(Q,oa)),me<=0&&C.current?E.current=!0:me>0&&(E.current=!1,_.current=0)}K()},[K]),ee=c.useCallback(()=>{const Q=h.current;Q&&(Q.scrollTop=Q.scrollHeight,x.current=Q.scrollTop,g.current=Q.scrollHeight,y.current=!0,J(me=>me||!0),w.current=!1,v.current=!0)},[]),ve=c.useCallback(()=>{const Q=h.current;Q&&(x.current=Q.scrollTop,g.current=Q.scrollHeight,v.current=!1,w.current=!0)},[]),be=c.useCallback(()=>{if(M&&$===0){le();return}W(Q=>Math.min(r,Q+Pg)),F(Q=>Q+1)},[$,M,le,r]),ye=c.useCallback(Q=>{const me=h.current;if(!(!me||Q.deltaY>=-8||me.scrollTop>0||!U)){if(!E.current){E.current=!0;return}le()}},[U,le]),we=c.useCallback(Q=>{var me;R.current=((me=Q.touches.item(0))==null?void 0:me.clientY)??null,_.current=0},[]),fe=c.useCallback(Q=>{var Ge;const me=h.current,ke=((Ge=Q.touches.item(0))==null?void 0:Ge.clientY)??null,Ne=R.current;if(R.current=ke,!me||ke===null||Ne===null||me.scrollTop>0||!U){_.current=0;return}const Ae=ke-Ne;if(Ae<=0){_.current=0;return}if(!E.current){E.current=!0,_.current=0;return}_.current+=Ae,_.current>=28&&le()},[U,le]),Te=c.useCallback(()=>{R.current=null,_.current=0},[]),oe=c.useCallback(()=>{W(r)},[r]);return c.useLayoutEffect(()=>{const Q=window.requestAnimationFrame(()=>{ee()});return()=>{window.cancelAnimationFrame(Q)}},[e,ee]),c.useEffect(()=>{N.current=!1,C.current=!1,E.current=!1,j.current=null},[e]),c.useEffect(()=>{a||(N.current=!1)},[a,r]),c.useLayoutEffect(()=>{const Q=j.current,me=h.current;if(!Q||!me||a)return;j.current=null;const ke=me.scrollHeight-Q.scrollHeight;if(ke<=0){g.current=me.scrollHeight,x.current=me.scrollTop;return}const Ne=Q.scrollTop+ke;me.scrollTop=Ne,x.current=Ne,g.current=me.scrollHeight,w.current=!0,v.current=!1,E.current=!1},[a,r]),c.useEffect(()=>{W(Q=>Q>=r-1?r:Math.max(Q,Us))},[r]),c.useEffect(()=>{const Q=h.current;Q&&(g.current=Q.scrollHeight,x.current=Q.scrollTop,kr(Q,1)?(w.current=!1,v.current=!0):(w.current||!kr(Q,oa))&&(v.current=!1)),K()},[Z,K,Y]),c.useEffect(()=>{const Q=o!==u.current,me=p.current!==Z;if(p.current=Z,!(Q||me&&v.current&&!w.current))return;const Ne=window.requestAnimationFrame(()=>{ee()});return o!==u.current&&(u.current=o),()=>{window.cancelAnimationFrame(Ne)}},[Z,A,ee,o]),c.useEffect(()=>{const Q=h.current,me=m.current;if(!Q||!me||typeof ResizeObserver>"u")return;g.current=Q.scrollHeight;const ke=new ResizeObserver(()=>{const Ne=Q.scrollHeight,Ae=g.current;if(g.current=Ne,Ne<=Ae)return;const Ge=Ae>0&&Ae-Q.scrollTop-Q.clientHeight<=1;w.current||!(v.current||Ge||y.current)||window.requestAnimationFrame(()=>{ee()})});return ke.observe(me),()=>{ke.disconnect()}},[ee]),c.useEffect(()=>{if(!v.current||w.current){f.current=l;return}if(l===f.current)return;f.current=l;const Q=window.requestAnimationFrame(()=>{ee()});return()=>{window.cancelAnimationFrame(Q)}},[l,ee]),c.useEffect(()=>{i==null||i(A)},[A,i]),{scrollContainerRef:h,scrollContentRef:m,tailSentinelRef:b,topSentinelRef:k,isTailVisible:A,handleScroll:de,handleWheel:ye,handleTouchStart:we,handleTouchMove:fe,handleTouchEnd:Te,preserveScrollPositionForResize:ve,serverManagedHistory:M,effectiveTotalTurnCount:ie,startIndex:O,visibleTurnAbsoluteOffset:H,hiddenCount:L,loadedHiddenCount:$,unloadedHiddenCount:D,showLoadAll:S,handleLoadEarlierClick:be,handleLoadAllClick:oe}}function Bg(e){return e==="completed"||e==="failed"||e==="interrupted"}function Gg(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 Hg({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:m,liveOutput:u,scrollRequestKey:p=0,previousTurnScrollRequestKey:f=0,nextTurnScrollRequestKey:g=0,bottomSpacer:x=0,className:j="",onTailVisibilityChange:b,onPreviousTurnAvailabilityChange:k,onNextTurnAvailabilityChange:y,loadingEarlier:v=!1,onLoadEarlier:w,ephemeralUserNote:C=null,answeredRequestNotes:N=[],activityNotes:E=[],optimisticSteers:R=[],optimisticTurn:_=null,onLoadHistoryItemDetail:Y,onOpenThread:W,onSelectArtifact:re,onSelectHistoryItemDetail:F,adapter:A,autoCollapseCompletedTurns:J}){var bt,at,vt,lt,Tt;const Z=Sl(),M=J??(Z==null?void 0:Z.autoCollapseCompletedTurns)??!1,[ie,O]=c.useState({}),[G,H]=c.useState(()=>new Set),T=c.useRef(null),$=c.useRef(null),D=(A==null?void 0:A.onLoadHistoryItemDetail)??Y,L=A==null?void 0:A.onOpenLinkedThread,{expandedText:S,openExpandedText:U,openCommandDetail:B,openToolCallDetail:le,openDeferredHistoryItemDetail:K,closeExpandedText:de}=Ag({loadHistoryItemDetail:D,onSelectHistoryItemDetail:F}),{scrollContainerRef:ee,scrollContentRef:ve,tailSentinelRef:be,topSentinelRef:ye,handleScroll:we,handleWheel:fe,handleTouchStart:Te,handleTouchMove:oe,handleTouchEnd:Q,preserveScrollPositionForResize:me,serverManagedHistory:ke,effectiveTotalTurnCount:Ne,startIndex:Ae,visibleTurnAbsoluteOffset:Ge,hiddenCount:Me,loadedHiddenCount:Fe,unloadedHiddenCount:X,showLoadAll:he,handleLoadEarlierClick:Ce,handleLoadAllClick:I}=Dg({threadId:e,turnsLength:r.length,totalTurnCount:n,loadingEarlier:v,onLoadEarlier:w,scrollRequestKey:p,bottomSpacer:x,onTailVisibilityChange:b,contentRevisionInputs:[r,a,l,R,u,i,d,_,N,E,C,x]}),V=c.useCallback((te,Re)=>{O(se=>({...se,[te]:!Re}))},[]),ae=c.useCallback((te,Re)=>{const se=ie[te.id];return se!==void 0?se:!!(M&&Bg(te.status)&&!Re.forceActive&&!Re.hasLiveActivity)},[ie,M]),ge=ke?r:r.slice(Ae),je=Ne+1,Ie=o&&(!s||!ge.some(te=>te.id===s)&&(_==null?void 0:_.id)!==s),ce=(_==null?void 0:_.id)??((bt=ge.at(-1))==null?void 0:bt.id)??null,He=Ie&&ce!==null,qe=!!d&&(ge.some(te=>te.id===d.turnId)||(_==null?void 0:_.id)===d.turnId),We=d&&qe?d.turnId:d&&He?ce:null,Ye=_&&We===_.id?(d==null?void 0:d.items)??null:null,ft=((d==null?void 0:d.items.length)??0)>0,rt=d&&We===null?d.items:null,ct=c.useMemo(()=>d&&We===null&&d.items.length>0?Mg(d.turnId,d.items):null,[d,We]),Ze=Math.max(1,Ne+(_?1:0)),pt=!!u&&!!_&&_.status!=="failed"&&!Ye,ot=u&&ge.length>0?s&&ge.some(te=>te.id===s)?s:((at=ge.findLast(te=>ya(te.status)))==null?void 0:at.id)??(He?ce:null):null,z=!!ot,q=c.useMemo(()=>Pl(u),[u]),xe=[...l.map(te=>({id:te.id,prompt:te.prompt,status:"Accepted",createdAt:te.createdAt,canCancel:!0})),...R.map(te=>({id:te.id,prompt:te.prompt,status:te.status==="steering"?"Steering":null,createdAt:te.createdAt,canCancel:!1}))].sort((te,Re)=>te.createdAt.localeCompare(Re.createdAt)),Ee=c.useMemo(()=>Pf({answeredRequestNotes:N,pendingRequests:a,visibleTurns:ge,optimisticTurn:_}),[N,_,a,ge]),$e=c.useMemo(()=>Rf({activityNotes:E,visibleTurns:ge,optimisticTurn:_}),[E,_,ge]),Qe=c.useCallback(()=>{const te=ee.current;if(!te)return null;const Re=te.getBoundingClientRect().top;return Array.from(te.querySelectorAll("[data-timeline-turn]")).find(se=>se.getBoundingClientRect().top>Re+8)??null},[ee]),nt=c.useCallback(()=>{const te=ee.current;if(!te)return null;const Re=te.getBoundingClientRect().top;return Array.from(te.querySelectorAll("[data-timeline-turn]")).findLast(se=>se.getBoundingClientRect().top<Re-8)??null},[ee]),Ve=c.useCallback(()=>{k==null||k(!!nt())},[nt,k]),De=c.useCallback(()=>{y==null||y(!!Qe())},[Qe,y]),ht=c.useCallback(()=>{we(),Ve(),De()},[we,De,Ve]);return c.useEffect(()=>{Ve(),De()},[De,Ve,ge]),c.useEffect(()=>{if(f===0)return;const te=ee.current,Re=nt(),se=te?Array.from(te.querySelectorAll("[data-timeline-turn]")):[],Se=Re?se.indexOf(Re):-1,Xe=Re&&Re.dataset.turnId===T.current?se[Se-1]??null:Re;if(!te||!Xe)return;T.current=Xe.dataset.turnId??null;const Ue=Xe.getBoundingClientRect().top-te.getBoundingClientRect().top;te.scrollTo({top:te.scrollTop+Ue-8,behavior:"smooth"}),se.indexOf(Xe)===0&&(k==null||k(!1))},[nt,k,f,ee]),c.useEffect(()=>{if(g===0)return;const te=ee.current,Re=Qe(),se=te?Array.from(te.querySelectorAll("[data-timeline-turn]")):[],Se=Re?se.indexOf(Re):-1,Xe=Re&&Re.dataset.turnId===$.current?se[Se+1]??null:Re;if(!te||!Xe)return;$.current=Xe.dataset.turnId??null;const Ue=Xe.getBoundingClientRect().top-te.getBoundingClientRect().top;te.scrollTo({top:te.scrollTop+Ue-8,behavior:"smooth"}),se.indexOf(Xe)===se.length-1&&(y==null||y(!1))},[Qe,g,y,ee]),t.jsxs(t.Fragment,{children:[t.jsx("section",{className:`flex min-h-0 flex-1 flex-col ${j}`.trim(),children:t.jsx("div",{ref:ee,"data-testid":"thread-scroll-container",onScroll:ht,onWheel:fe,onTouchStart:Te,onTouchMove:oe,onTouchEnd:Q,onTouchCancel:Q,className:"thread-graph-scroll-container min-h-0 flex-1 overflow-y-auto overscroll-contain",style:x>0?{paddingBottom:x}:void 0,children:t.jsxs("div",{ref:ve,className:"thread-graph-scroll-content",children:[t.jsx("div",{ref:ye,"aria-hidden":"true",className:"h-px"}),r.length>0&&t.jsx("div",{className:"thread-graph-history-control px-3 pb-1 pt-2 sm:px-5 sm:pb-1.5 sm:pt-3",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 text-xs sm:text-sm",children:[Me>0&&t.jsx("button",{type:"button",onClick:Ce,disabled:v,className:"thread-graph-history-button rounded-full border px-2.5 py-1.5 transition",children:v?"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 ",Ne," turns",Me>0?` · ${Me} earlier hidden${Fe>0&&X>0?` (${Fe} loaded)`:""}`:""]})]})}),r.length===0&&!u&&!_&&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||_||$e.leading.length>0||$e.trailing.length>0)&&t.jsxs("div",{className:"thread-graph-message-list",children:[$e.leading.length>0?t.jsx(br,{notes:$e.leading,onOpenThread:W,onOpenLinkedThread:L}):null,ge.map((te,Re)=>{var se,Se,Xe,Ue,it;return t.jsxs("div",{"data-timeline-turn":!0,"data-turn-id":te.id,children:[(((se=$e.beforeTurnId.get(te.id))==null?void 0:se.length)??0)>0?t.jsx(br,{notes:$e.beforeTurnId.get(te.id)??[],onOpenThread:W,onOpenLinkedThread:L}):null,(((Se=Ee.beforeTurnId.get(te.id))==null?void 0:Se.length)??0)>0?t.jsx(sa,{entries:Ee.beforeTurnId.get(te.id)??[],respondingRequestId:h,onRespondToRequest:m??void 0}):null,(()=>{const Et=Gg(te,_),jt=(i==null?void 0:i.turnId)===te.id?i:null,At=We===te.id?(d==null?void 0:d.items)??null:null,Zt=ot===te.id?u:"",pr=s===te.id||He&&ce===te.id,ut=!!jt||!!Zt||!!(At&&At.length>0),gn=ae(Et,{forceActive:pr,hasLiveActivity:ut});return t.jsx(Rn,{threadId:e,...A?{adapter:A}:{},turn:Et,absoluteIndex:Ge+Re+1,isCollapsed:gn,livePlan:jt,liveItems:At,liveOutput:Zt,forceActive:pr,onToggleCollapse:V,onOpenExpandedText:U,onOpenCommandDetail:B,onOpenToolCallDetail:le,onOpenDeferredHistoryItemDetail:K,onBeforeMessageResize:me,...re?{onSelectArtifact:re}:{},scrollRootRef:ee,articleRef:void 0})})(),(((Xe=$e.afterTurnId.get(te.id))==null?void 0:Xe.length)??0)>0?t.jsx(br,{notes:$e.afterTurnId.get(te.id)??[],onOpenThread:W,onOpenLinkedThread:L}):null,(Ue=Ee.notesByTurnId.get(te.id))!=null&&Ue.length||(it=Ee.pendingRequestsByTurnId.get(te.id))!=null&&it.length?t.jsx(_f,{notes:Ee.notesByTurnId.get(te.id)??[],requests:Ee.pendingRequestsByTurnId.get(te.id)??[],respondingRequestId:h,onRespondToRequest:m??void 0}):null]},te.id)}),_&&ge.every(te=>te.id!==_.id)&&t.jsxs(t.Fragment,{children:[(((vt=$e.beforeTurnId.get(_.id))==null?void 0:vt.length)??0)>0?t.jsx(br,{notes:$e.beforeTurnId.get(_.id)??[],onOpenThread:W,onOpenLinkedThread:L}):null,(((lt=Ee.beforeTurnId.get(_.id))==null?void 0:lt.length)??0)>0?t.jsx(sa,{entries:Ee.beforeTurnId.get(_.id)??[],respondingRequestId:h,onRespondToRequest:m??void 0}):null,(()=>{const te=pt?u:"",Re=s===_.id||He&&ce===_.id,se=!!(Ye&&Ye.length>0)||!!te,Se=ae(_,{forceActive:Re,hasLiveActivity:se});return t.jsx(Rn,{threadId:e,...A?{adapter:A}:{},turn:_,absoluteIndex:je,isCollapsed:Se,livePlan:null,liveItems:Ye,liveOutput:te,forceActive:Re,onToggleCollapse:V,onOpenExpandedText:U,onOpenCommandDetail:B,onOpenToolCallDetail:le,onOpenDeferredHistoryItemDetail:K,onBeforeMessageResize:me,...re?{onSelectArtifact:re}:{},scrollRootRef:ee})})(),(((Tt=$e.afterTurnId.get(_.id))==null?void 0:Tt.length)??0)>0?t.jsx(br,{notes:$e.afterTurnId.get(_.id)??[],onOpenThread:W,onOpenLinkedThread:L}):null]})]}),xe.length>0&&t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:xe.map(te=>t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Rt,{threadId:e,item:{id:te.id,kind:"userMessage",text:te.prompt,status:te.status},scrollRootRef:ee,onBeforeMessageResize:me,...A?{adapter:A}:{}}),e&&te.canCancel&&(A!=null&&A.cancelPendingSteer)?t.jsx("div",{className:"flex justify-end px-1",children:t.jsx("button",{type:"button",className:"thread-graph-history-button rounded-full border px-2.5 py-1 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",disabled:G.has(te.id),onClick:()=>{var Re;H(se=>new Set(se).add(te.id)),Promise.resolve((Re=A.cancelPendingSteer)==null?void 0:Re.call(A,e,te.id)).catch(()=>{}).finally(()=>{H(se=>{const Se=new Set(se);return Se.delete(te.id),Se})})},children:G.has(te.id)?"Canceling...":"Cancel"})}):null]},te.id))}),(Ee.trailing.length>0||$e.trailing.length>0)&&t.jsx(Mf,{entries:[...$e.trailing.map(te=>({kind:"activity",id:te.id,createdAt:te.createdAt,note:te})),...Ee.trailing],respondingRequestId:h,onRespondToRequest:m??void 0,onOpenThread:W,onOpenLinkedThread:L}),C&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:t.jsx(Rt,{threadId:e,item:{id:"ephemeral-plan-decision-note",kind:"userMessage",text:C},scrollRootRef:ee,onBeforeMessageResize:me})}),ct&&rt&&rt.length>0&&t.jsx(Rn,{threadId:e,...A?{adapter:A}:{},turn:ct,absoluteIndex:Ze,isCollapsed:ie[ct.id]??!1,livePlan:(i==null?void 0:i.turnId)===ct.id?i:null,liveItems:rt,liveOutput:"",forceActive:!0,onToggleCollapse:V,onOpenExpandedText:U,onOpenCommandDetail:B,onOpenToolCallDetail:le,onOpenDeferredHistoryItemDetail:K,onBeforeMessageResize:me,...re?{onSelectArtifact:re}:{},scrollRootRef:ee}),u&&!z&&!pt&&!ft&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:q?t.jsx(ja,{threadId:e,item:q,scrollRootRef:ee,onOpenExpandedText:U,onOpenCommandDetail:B,onOpenToolCallDetail:le,onOpenDeferredHistoryItemDetail:K,onBeforeMessageResize:me,...re?{onSelectArtifact:re}:{},...A?{adapter:A}:{}}):t.jsx(Rt,{threadId:e,item:{id:"live-agent-message-fallback",kind:"agentMessage",text:u},scrollRootRef:ee,streaming:!0,onBeforeMessageResize:me,...A?{adapter:A}:{}})}),t.jsx("div",{ref:be,"aria-hidden":"true",className:"h-px w-full"})]})})}),t.jsx(Up,{open:S!==null,title:(S==null?void 0:S.title)??"Full text",text:(S==null?void 0:S.text)??"",onClose:de})]})}var Wl=c.memo(Hg);function Fg(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}function la(e){return e.replace(/\r\n/g,`
|
|
3962
|
-
`)}function
|
|
3960
|
+
`);for(;r.length>1&&((n=r.at(-1))==null?void 0:n.trim())==="";)r.pop();return r}function gt(e){const r=Vf(e);return r.length===1?{firstLine:r[0]??"",showGap:!1,isTruncated:!1}:{firstLine:r[0]??"",showGap:!0,isTruncated:!0}}function Hl(e){const r=(e==null?void 0:e.trim().toLowerCase())??"";return r==="completed"||r==="complete"||r==="success"||r==="succeeded"?{className:"is-completed",icon:t.jsx(R.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"}:r==="failed"||r==="failure"||r==="error"||r==="errored"?{className:"is-failed",icon:t.jsx(R.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"}:fn(e)?{className:"is-pending",icon:t.jsx(R.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 Xf(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 qf(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 Zt({actions:e,children:r,className:n,headerMeta:a,icon:s,item:o,timeMeta:l,title:i,tone:d}){const h=Hl(o.status);return t.jsxs("div",{className:`thread-graph-event thread-graph-history-event ${qf(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(pn,{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 pr({actionLabel:e="Open details",actionTitle:r,autoOpen:n=!1,className:a,details:s,icon:o,item:l,onOpen:i,preview:d,timeMeta:h,title:m,tone:u}){const p=Hl(l.status),[f,g]=c.useState(n?"item-1":void 0),b=c.useRef(n);return c.useLayoutEffect(()=>{n?g("item-1"):b.current&&g(void 0),b.current=n},[n,l.id]),t.jsx("div",{className:`thread-graph-event thread-graph-history-tool ${Xf(u)} ${a??""}`,children:t.jsx(zr,{type:"single",collapsible:!0,onValueChange:j=>{g(j||void 0)},className:"thread-graph-tool-accordion thread-graph-history-tool-accordion w-full overflow-hidden rounded-lg border",value:f??"",children:t.jsxs(Pr,{value:"item-1",className:"border-0",children:[t.jsxs(un,{"aria-label":`${f==="item-1"?"Collapse":"Expand"} ${m} 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:m}),t.jsxs(pn,{variant:"outline",className:`thread-graph-tool-badge ${p.className} ml-1 sm:ml-2 rounded-full px-2 py-0.5 text-xs font-normal`,title:p.label,"aria-label":`Status: ${p.label}`,children:[p.icon,t.jsx("span",{className:"thread-graph-status-label",children:p.label})]})]}),h?t.jsx("span",{className:"thread-graph-history-tool-time shrink-0",children:h}):null]}),t.jsxs(Rr,{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(cr,{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(R.ExternalLink,{className:"h-3.5 w-3.5"}),r]})]})]})})})}var Kf=c.memo(function({item:r,scrollRootRef:n,onBeforeResize:a,timeMeta:s}){return t.jsx(Zt,{className:"thread-graph-event-plan",icon:t.jsx(R.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(Al,{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}:{}})})})}),Yf=c.memo(function({item:r,timeMeta:n}){const a=fn(r.status)||r.text==="Compacting context",s=a?"Compacting context":"Context compacted",o=r.detailText&&r.detailText!==s?r.detailText:null;return t.jsxs(Zt,{className:"thread-graph-event-context",icon:t.jsx(R.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(an,{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(Zt,{className:"thread-graph-event-generic",icon:t.jsx(R.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(cr,{text:r.text})})})}),Jf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:s}){const o=gt(n.previewText??n.text);return t.jsx(pr,{actionLabel:"Open full command",actionTitle:"Command Output",autoOpen:r,className:"thread-graph-event-command",icon:t.jsx(R.Terminal,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Command Output"),preview:o,timeMeta:s,title:"command",tone:"command"})}),Qf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:s}){const o=gt(n.text);return t.jsx(pr,{actionLabel:"Open full tool call",actionTitle:"Tool Call Details",autoOpen:r,className:"thread-graph-event-tool",icon:t.jsx(R.Wrench,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Tool Call Details"),preview:o,timeMeta:s,title:"tool_call",tone:"tool"})}),eg=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:s}){const o=gt(n.text);return t.jsx(pr,{actionLabel:"Open agent details",actionTitle:"Agent Details",autoOpen:r,className:"thread-graph-event-agent-tool",icon:t.jsx(R.Bot,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Agent Details"),preview:o,timeMeta:s,title:"agent",tone:"agent"})}),tg=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:s}){const o=gt(n.text);return t.jsx(pr,{actionLabel:"Open skill details",actionTitle:"Skill Details",autoOpen:r,className:"thread-graph-event-skill-tool",icon:t.jsx(R.Sparkles,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Skill Details"),preview:o,timeMeta:s,title:"skill",tone:"skill"})}),rg=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=gt(o);return t.jsx(pr,{actionLabel:"Open full web search",actionTitle:"Web Search Details",autoOpen:r,className:"thread-graph-event-search",icon:t.jsx(R.Search,{className:"h-4 w-4"}),item:n,onOpen:()=>a("Web Search Details",l),preview:i,timeMeta:s,title:"web_search",tone:"search"})}),ng=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=gt(o);return t.jsx(pr,{actionLabel:"Open full file read",actionTitle:"File Read Details",autoOpen:r,className:"thread-graph-event-file-read",icon:t.jsx(R.FileText,{className:"h-4 w-4"}),item:n,onOpen:()=>a("File Read Details",l),preview:i,timeMeta:s,title:"file_read",tone:"fileRead"})}),ag=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(Zt,{className:"thread-graph-event-image",icon:t.jsx(R.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]})}),sg=c.memo(function({item:r,onOpen:n,timeMeta:a}){var u,p,f;const s=(u=r.previewText)!=null&&u.trim()&&r.text.trim()!==r.previewText.trim()?r.text.trim():null,o=((p=r.detailText)==null?void 0:p.trim())||null,l=Fl(s??((f=r.previewText)==null?void 0:f.trim())??r.text,48),i=Uf(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))})]}),m=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(Zt,{className:"thread-graph-event-file-change",headerMeta:m,icon:t.jsx(R.FilePenLine,{className:"h-4 w-4"}),item:r,timeMeta:a,title:"file_change",tone:"fileChange"})}),og=c.memo(function({item:r,onSelect:n,timeMeta:a}){const s=Na(),[o,l]=c.useState(!1),i=r.artifact,d=i?s.renderArtifact({artifact:i,expanded:o,onToggleExpanded:()=>l(h=>!h)}):null;return t.jsx(Zt,{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(R.PackageOpen,{className:"h-3.5 w-3.5"}),"Inspect"]}):null]}),className:"thread-graph-event-artifact",icon:t.jsx(R.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]})})}),lg=c.memo(function({item:r,timeMeta:n}){var h,m;const a=((h=r.hookOutputEntries)==null?void 0:h.map(u=>u.text.trim()).filter(Boolean).join(`
|
|
3961
|
+
`).trim())??"",s=r.hookEventLabel?`${r.hookEventLabel} hook`:r.text,o=((m=r.hookStatusMessage)==null?void 0:m.trim())||(r.previewText&&r.previewText!==r.hookStatusMessage?r.previewText.trim():"")||r.text.trim(),i=gt(a||(o&&o!==s?o:s)),d=!!(a&&i.showGap);return t.jsx(Zt,{className:"thread-graph-event-hook",icon:t.jsx(R.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(cr,{text:i.firstLine})]}):t.jsx(cr,{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]})})}),ig=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s,timeMeta:o}){const l=r.filter(d=>fn(d.status)).length,i=r.length===1?"1 command":`${r.length} commands`;return t.jsx(mr,{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(Hf,{}),onToggleExpanded:a,runningIndicator:l>0?t.jsx(an,{}):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(an,{})}):null]}),timeMeta:o,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} command entries`,children:r.map((d,h)=>{const m=gt(d.text);return t.jsxs("button",{type:"button","aria-label":`Open grouped command ${h+1}`,onClick:()=>s(d,`Command Output ${h+1}`),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"rounded-full border border-amber-300/18 bg-amber-300/[0.07] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-amber-100",children:["Step ",h+1]}),d.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:d.status})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2 text-sm leading-6",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:m.firstLine}),m.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},d.id)})})}),dg=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s,timeMeta:o}){var m;const l=r.filter(u=>fn(u.status)).length,i=((m=r[0])==null?void 0:m.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(mr,{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(R.Bot,{className:"h-3.5 w-3.5"}):t.jsx(R.Wrench,{className:"h-3.5 w-3.5"}),onToggleExpanded:a,runningIndicator:l>0?t.jsx(an,{}):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((u,p)=>{const f=gt(u.text);return t.jsx("button",{type:"button","aria-label":`Open ${d} ${p+1}`,onClick:()=>s(u,`${d} ${p+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:f.firstLine}),u.status?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-xs",children:u.status}):null]})},u.id)})})}),cg=c.memo(function({itemCount:r,expanded:n,onToggleExpanded:a,timeMeta:s,children:o}){const l=r===1?"1 operation":`${r} operations`;return t.jsx(mr,{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(R.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})}),hg=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(mr,{className:"thread-graph-history-group-search",count:r.length,countBadgeClassName:"border-sky-200/35 text-sky-100",desktopIconClassName:"border-sky-300/30 bg-sky-300/[0.14] text-sky-100",expanded:n,expandedListClassName:"border-sky-300/12",icon:t.jsx(Of,{}),onToggleExpanded:a,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-sky-300/28 bg-sky-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-sky-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:l})]}),timeMeta:o,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} web search entries`,children:r.map((i,d)=>{var p,f;const h=((p=i.previewText)==null?void 0:p.trim())||i.text||"Web search",m=gt(h),u=((f=i.detailText)==null?void 0:f.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}`,u),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"rounded-full border border-sky-300/18 bg-sky-300/[0.07] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-sky-100",children:["Search ",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:m.firstLine}),m.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},i.id)})})}),ug=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(mr,{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(Ff,{}),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 p,f;const h=((p=i.previewText)==null?void 0:p.trim())||i.text||"File read",m=gt(h),u=((f=i.detailText)==null?void 0:f.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}`,u),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"rounded-full border border-cyan-300/18 bg-cyan-300/[0.07] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-cyan-100",children:["Read ",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:m.firstLine}),m.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},i.id)})})}),mg=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:s,timeMeta:o}){const l=r.reduce((m,u)=>m+(u.changedFiles??0),0),i=r.reduce((m,u)=>m+(u.addedLines??0),0),d=r.reduce((m,u)=>m+(u.removedLines??0),0),h=r.length===1?"1 file change":`${r.length} file changes`;return t.jsx(mr,{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(Gf,{}),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((m,u)=>{var g,b,j,x;const p=((g=m.detailText)==null?void 0:g.trim())||((b=m.previewText)==null?void 0:b.trim())||m.text,f=(j=m.previewText)!=null&&j.trim()&&m.text.trim()!==m.previewText.trim()?m.text.trim():((x=m.previewText)==null?void 0:x.trim())||m.text;return t.jsx("button",{type:"button","aria-label":`Open grouped file change ${u+1}`,onClick:()=>s(`File Change ${u+1}`,p),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-detail-text min-w-0 flex-1 text-sm leading-6",title:f,children:Fl(f,34)}),t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[(m.addedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-add",children:["+",m.addedLines]}):null,(m.removedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-remove",children:["-",m.removedLines]}):null]})]})},m.id)})})});function pg(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 fg({status:e}){const r=pg(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(pn,{"aria-label":n,title:n.replace("Plan step status: ",""),className:a,children:r==="completed"?t.jsx(R.CheckCircle2,{className:"h-3.5 w-3.5"}):r==="in_progress"?t.jsx(R.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):r==="pending"?t.jsx(R.Clock3,{className:"h-3.5 w-3.5"}):r==="failed"?t.jsx(R.XCircle,{className:"h-3.5 w-3.5"}):t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.14em]",children:"?"})})}function gg({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(pn,{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(fg,{status:r.status})]},`${e.turnId}-${n}`))})]})}function xg({footer:e,history:r,liveHookPrompt:n,liveOutput:a,livePlan:s}){return t.jsxs(t.Fragment,{children:[r,s?t.jsx(gg,{livePlan:s}):null,n??a??null,e]})}function bg({absoluteIndex:e,body:r,collapsed:n,collapsedBody:a,error:s,footer:o,headerStatus:l,isActive:i=!1,refCallback:d,startedAt:h,timeLabel:m,timeTitle:u,tokenSummary:p}){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:u,className:"thread-graph-turn-time shrink-0 text-[10px] sm:text-[11px]",children:m}),l,s?t.jsx("p",{className:"hidden truncate text-[11px] text-rose-200 sm:block",children:s}):null]}),p]})}),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 vg(){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 kg(){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 Os(){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 wg(){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 vr(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 Ol(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 or(e){return!Number.isFinite(e)||e<=0?"$0.0000":`$${e.toFixed(4)}`}function Or(e,r,n){const a=e??null;return!Number.isFinite(a??NaN)||a===null||r<=0||n<=0?null:a*n/r}function Wl(e){var d,h,m,u,p,f;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:vr(n),tokenRawValue:n,usdCompactValue:e.priceEstimate?or(e.priceEstimate.inputUsd):"--",usdRawValue:((h=e.priceEstimate)==null?void 0:h.inputUsd)??null,className:"token-badge-in",icon:t.jsx(vg,{})}:null,a>0?{id:"cache",label:"Cached input",tokenCompactValue:vr(a),tokenRawValue:a,usdCompactValue:e.priceEstimate?or(e.priceEstimate.cachedInputUsd):"--",usdRawValue:((m=e.priceEstimate)==null?void 0:m.cachedInputUsd)??null,className:"token-badge-cache",icon:t.jsx(Os,{})}:null,s>0?{id:"cache-write",label:"Cache write",tokenCompactValue:vr(s),tokenRawValue:s,usdCompactValue:e.priceEstimate?or(e.priceEstimate.cacheWriteInputUsd??0):"--",usdRawValue:((u=e.priceEstimate)==null?void 0:u.cacheWriteInputUsd)??null,className:"token-badge-cache",icon:t.jsx(Os,{})}:null,l>0?{id:"out",label:"Output",tokenCompactValue:vr(l),tokenRawValue:l,usdCompactValue:e.priceEstimate?or(Or(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),l)??0):"--",usdRawValue:Or((p=e.priceEstimate)==null?void 0:p.outputUsd,Math.max(r.outputTokens,0),l),className:"token-badge-out",icon:t.jsx(kg,{})}:null,o>0?{id:"reason",label:"Reasoning",tokenCompactValue:vr(o),tokenRawValue:o,usdCompactValue:e.priceEstimate?or(Or(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),o)??0):"--",usdRawValue:Or((f=e.priceEstimate)==null?void 0:f.outputUsd,Math.max(r.outputTokens,0),o),className:"token-badge-reason",icon:t.jsx(wg,{})}:null].filter(g=>g!==null)}function yg(e){return Wl(e).map(r=>({id:r.id,label:r.tokenCompactValue,title:`${r.label}: ${r.tokenRawValue} tokens`,className:r.className,icon:r.icon}))}function Ul(e){return{label:e.priceEstimate?Ol(e.priceEstimate.totalUsd):"--",title:e.priceEstimate===null||e.priceEstimate===void 0?"Price estimate unavailable for this model.":`Estimated cost: ${or(e.priceEstimate.totalUsd)}`,className:e.priceEstimate?"token-badge-total":"token-badge-empty"}}var An="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 jg({turn:e}){const r=Wl(e),n=Ul(e),[a,s]=c.useState(!1),[o,l]=c.useState(!1),[i,d]=c.useState(0),h=c.useRef(null),m=c.useRef(null),u=c.useRef(null);if(c.useLayoutEffect(()=>{if(!a||r.length===0){d(0);return}const f=()=>{const g=h.current,b=u.current;if(!g||!b)return;const j=g.getBoundingClientRect(),x=b.offsetWidth||b.getBoundingClientRect().width;if(x<=0)return;const k=window.innerWidth||document.documentElement.clientWidth,w=12,v=j.left+j.width/2-x/2,y=w,N=Math.max(y,k-w-x),S=Math.min(Math.max(v,y),N);d(Math.round(S-v))};return f(),window.addEventListener("resize",f),()=>{window.removeEventListener("resize",f)}},[r.length,a]),c.useEffect(()=>{if(!a&&!o)return;const f=g=>{g.target instanceof Node&&(h.current&&!h.current.contains(g.target)&&s(!1),m.current&&!m.current.contains(g.target)&&l(!1))};return document.addEventListener("pointerdown",f),()=>{document.removeEventListener("pointerdown",f)}},[o,a]),!n&&r.length===0)return null;const p=()=>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(f=>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:`${f.label}: ${f.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:f.icon}),t.jsx("span",{className:"thread-token-popover-strong font-medium",children:f.usdCompactValue})]}),t.jsx("span",{className:"thread-token-popover-text shrink-0 font-medium",children:f.tokenCompactValue})]},f.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:m,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:`${An} 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:p()}):null]}):null,r.map(f=>t.jsxs("span",{className:`${An} ${f.className}`,title:`${f.label}: ${f.usdCompactValue}, ${f.tokenRawValue} tokens`,children:[f.icon,t.jsx("span",{className:"thread-token-badge-value font-medium",children:f.tokenCompactValue})]},f.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(f=>!f),className:`${An} 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:u,className:"absolute left-1/2 top-full z-30 mt-1.5",style:{transform:`translateX(${i}px) translateX(-50%)`},children:p()}):null]})]})}function Ng({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 Ws(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 Cg(e){switch(e.kind){case"fileChange":case"webSearch":case"image":case"contextCompaction":return!0;case"commandExecution":case"toolCall":return!Ca(e.status);default:return!1}}function Sg(e,r,n){if(!e||!jr(n))return e;const a=e.plan.findIndex(i=>Ws(i.status)==="in_progress");if(a<0)return e;const s=e.plan.findIndex((i,d)=>d>a&&Ws(i.status)==="pending");if(s<0||!r.some(i=>Cg(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 Tg(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 Eg(e){const[r,n]=c.useState(()=>Date.now());return c.useEffect(()=>{if(!e)return;n(Date.now());const a=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(a)},[e]),r}function Lg(e,r){const n=Date.parse(e??"");if(!Number.isFinite(n))return null;const a=Math.max(0,Math.floor((r-n)/1e3)),s=Math.floor(a/3600),o=Math.floor(a%3600/60),l=a%60;return s>0?`${s}h ${String(o).padStart(2,"0")}m ${String(l).padStart(2,"0")}s`:o>0?`${o}m ${String(l).padStart(2,"0")}s`:`${l}s`}function Us({status:e}){const r=Il(e);return e==="completed"?t.jsx("span",{"aria-label":r,title:r,className:"timeline-status-icon timeline-status-icon-success inline-flex h-4 w-4 items-center justify-center",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m3.75 8.25 2.5 2.5 6-6"})})}):e==="failed"?t.jsx("span",{"aria-label":r,title:r,className:"timeline-status-icon timeline-status-icon-failed inline-flex h-4 w-4 items-center justify-center",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m5 5 6 6M11 5l-6 6"})})}):e==="interrupted"?t.jsx("span",{"aria-label":r,title:r,className:"timeline-status-icon timeline-status-icon-warning inline-flex h-4 w-4 items-center justify-center",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M6 4.5v7M10 4.5v7"})})}):t.jsx("span",{"aria-label":r,title:r,className:"inline-flex min-w-[1.25rem] items-center justify-center text-sky-200",children:t.jsx(Ng,{tone:"emerald"})})}function Vs({turn:e,variant:r="header",lastActivityAt:n=null}){const a=Il(e.status),s=Tg(e),o=yg(e),l=Ul(e),i=jr(e.status),d=Eg(i&&r==="footer"),h=i?Lg(e.startedAt,d):null,m=n??e.startedAt,u=e.status==="failed"?"border-rose-300/20 bg-rose-300/[0.06] text-rose-100":i?"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 ${u}`,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(Us,{status:e.status}),t.jsx("span",{className:"timeline-soft-text min-w-0 truncate",children:s})]}),m&&t.jsxs("span",{className:"timeline-meta-text flex shrink-0 items-center gap-1 whitespace-nowrap text-[11px]",title:[`Last activity ${qt(m)}`,h?`Running for ${h}`:null].filter(Boolean).join(" · "),children:[t.jsx("time",{dateTime:m,children:kt(m)}),h?t.jsxs("span",{"aria-label":`Running for ${h}`,children:["· ",h]}):null]})]}),(l||o.length>0)&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 pl-6",children:[l?t.jsx("span",{className:`inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${l.className}`,title:l.title,children:l.label}):null,o.map(f=>t.jsxs("span",{className:`inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${f.className}`,title:f.title,children:[f.icon?t.jsx("span",{className:"mr-1",children:f.icon}):null,f.label]},f.id))]})]});const p=`${a} · ${s}`;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] ${u}`,title:p,children:[t.jsx(Us,{status:e.status}),t.jsx("span",{className:"timeline-meta-text min-w-0 truncate",children:s})]})}function Ig(e,r){return e.createdAt??r}var Sa=c.memo(function({threadId:r,item:n,scrollRootRef:a,onOpenExpandedText:s,onOpenCommandDetail:o,onOpenToolCallDetail:l,onOpenDeferredHistoryItemDetail:i,onSelectArtifact:d,onBeforeMessageResize:h,adapter:m,timeLabel:u,timeTitle:p,timeMeta:f,autoOpenToolDetails:g=!1}){var b,j,x;if(jf(n.kind))return t.jsx(At,{threadId:r,item:n,scrollRootRef:a,timeLabel:u,timeTitle:p,...h?{onBeforeMessageResize:h}:{},...m?{adapter:m}:{}});if(n.kind==="reasoning")return t.jsx(At,{item:{...n,kind:"agentMessage",status:n.status??null},scrollRootRef:a,timeLabel:u,timeTitle:p,...h?{onBeforeMessageResize:h}:{}});if(n.kind==="artifact")return t.jsx(og,{item:n,timeMeta:f,...d?{onSelect:(k,w)=>d({item:k,artifact:w})}:{}});if(n.kind==="commandExecution")return t.jsx(Jf,{autoOpen:g,item:n,onOpen:o,timeMeta:f});if(n.kind==="toolCall")return t.jsx(Qf,{autoOpen:g,item:n,onOpen:l,timeMeta:f});if(n.kind==="agentToolCall")return t.jsx(eg,{autoOpen:g,item:n,onOpen:l,timeMeta:f});if(n.kind==="skillToolCall")return t.jsx(tg,{autoOpen:g,item:n,onOpen:l,timeMeta:f});if(n.kind==="webSearch"){const k=n,w=((b=k.detailText)==null?void 0:b.trim())||k.text||"Web search";return t.jsx(rg,{autoOpen:g,item:k,timeMeta:f,onOpen:()=>i(k,"Web Search Details",w,"Loading full web search details...","Unable to load full web search details.")})}if(n.kind==="fileRead"){const k=n,w=((j=k.detailText)==null?void 0:j.trim())||k.text||"File read";return t.jsx(ng,{autoOpen:g,item:k,timeMeta:f,onOpen:()=>i(k,"File Read Details",w,"Loading full file read details...","Unable to load full file read details.")})}if(n.kind==="image")return t.jsx(ag,{threadId:r,item:n,onOpen:s,getImageAssetUrl:m==null?void 0:m.getImageAssetUrl,timeMeta:f});if(n.kind==="plan")return t.jsx(Kf,{item:n,scrollRootRef:a,timeMeta:f,...h?{onBeforeResize:h}:{}});if(n.kind==="fileChange"){const k=n,w=((x=k.detailText)==null?void 0:x.trim())||k.text||"File change";return t.jsx(sg,{item:k,timeMeta:f,onOpen:()=>i(k,"File Change Details",w,"Loading full file change details...","Unable to load full file change details.")})}return n.kind==="contextCompaction"?t.jsx(Yf,{item:n,timeMeta:f}):n.kind==="hook"?t.jsx(lg,{item:n,timeMeta:f}):t.jsx(Zf,{item:n,timeMeta:f})});function Xs(e){return e==="completed"||e==="failed"||e==="interrupted"}function zg(e){const r=Date.parse(e.createdAt??"");return Number.isFinite(r)?r:null}function Vl(e){let r=null;for(const n of e){const a=zg(n);a!==null&&(r=r===null?a:Math.max(r,a))}return r}function Pg(e,r,n){const a=[Date.parse(e??""),Vl(r)??Number.NaN,Date.parse(n??"")].filter(Number.isFinite);return a.length>0?new Date(Math.max(...a)).toISOString():null}function Rg(e,r){const n=Date.parse(e??""),a=Vl(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 Ag(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 Cr({absoluteLabel:e,className:r="",timestamp:n,turnStartedAt:a}){const[s,o]=c.useState(!1);if(!n)return null;const l=qt(n),i=Ag(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(m=>!m)},onKeyDown:h=>{h.key!=="Enter"&&h.key!==" "||(h.preventDefault(),h.stopPropagation(),o(m=>!m))},children:t.jsx("time",{dateTime:n,children:d})})}function Ot(e){var r;return e.kind==="item"?e.item.createdAt??null:e.kind==="agentActivityGroup"?e.entries[0]?Ot(e.entries[0]):null:((r=e.items.find(n=>n.createdAt))==null?void 0:r.createdAt)??null}function _g(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 _n=c.memo(function({threadId:r,adapter:n,turn:a,absoluteIndex:s,isCollapsed:o,livePlan:l,liveItems:i,liveActivityAt:d=null,liveOutput:h,forceActive:m=!1,onToggleCollapse:u,onOpenExpandedText:p,onOpenCommandDetail:f,onOpenToolCallDetail:g,onOpenDeferredHistoryItemDetail:b,onSelectArtifact:j,onBeforeMessageResize:x,scrollRootRef:k,articleRef:w,isLatestVisibleTurn:v=!1}){const y=!!l||!!h||!!(i&&i.length>0),N=m||jr(a.status)||y||v,S=N&&!jr(a.status)?{...a,status:"inProgress"}:a,T=c.useMemo(()=>Tf(a.items,i),[i,a.items]),M=c.useMemo(()=>Pg(a.startedAt,T,d),[d,T,a.startedAt]),A=c.useMemo(()=>Sg(l,T,a.status),[l,T,a.status]),J=c.useMemo(()=>Ef(h,T),[h,T]),W=c.useMemo(()=>Sf(T,N),[N,T]),re=c.useMemo(()=>Lf(W),[W]),O=m||jr(a.status)||y,P=kt(a.startedAt),Y=qt(a.startedAt),Z=c.useMemo(()=>_l(J),[J]),[_,ie]=c.useState({}),H=c.useCallback(q=>{ie(ve=>({...ve,[q]:!ve[q]}))},[]),B=t.jsx(Xl,{entries:re,expandedGroups:_,onToggleGroupedItem:H,threadId:r,scrollRootRef:k,onOpenExpandedText:p,onOpenCommandDetail:f,onOpenToolCallDetail:g,onOpenDeferredHistoryItemDetail:b,...x?{onBeforeMessageResize:x}:{},fallbackTimestamp:a.startedAt,fallbackTimeLabel:P,fallbackTimeTitle:Y,turnStartedAt:a.startedAt,autoOpenLatestToolDetails:O,...j?{onSelectArtifact:j}:{},...n?{adapter:n}:{}}),F=Z?t.jsx(Sa,{threadId:r,item:Z,scrollRootRef:k,onOpenExpandedText:p,onOpenCommandDetail:f,onOpenToolCallDetail:g,onOpenDeferredHistoryItemDetail:b,timeLabel:a.startedAt?t.jsx(Cr,{absoluteLabel:P,timestamp:a.startedAt,turnStartedAt:a.startedAt}):P,timeTitle:Y,timeMeta:null,...j?{onSelectArtifact:j}:{},...n?{adapter:n}:{}}):null,E=!Z&&J?t.jsx(At,{item:{id:"live-agent-message",kind:"agentMessage",text:J},scrollRootRef:k,timeLabel:a.startedAt?t.jsx(Cr,{absoluteLabel:P,timestamp:a.startedAt,turnStartedAt:a.startedAt}):P,timeTitle:Y,streaming:!0,...x?{onBeforeMessageResize:x}:{}}):null,D=N?t.jsx(Vs,{turn:S,variant:"footer",lastActivityAt:M}):null,$=c.useMemo(()=>_g(re),[re]),L=c.useMemo(()=>Rg(a.startedAt,T),[T,a.startedAt]),C=$.hiddenEntries.length>0,U=o&&C,le=Xs(a.status)&&C&&!U?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":`${L}. Collapse turn ${s}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:L}),t.jsx(R.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,ee=Xs(a.status)&&C?t.jsxs("div",{className:"thread-graph-turn-collapsed-summary space-y-2",children:[$.users.map(q=>t.jsx(At,{threadId:r,item:q,scrollRootRef:k,timeLabel:q.createdAt?kt(q.createdAt):P,timeTitle:q.createdAt?qt(q.createdAt):Y,...x?{onBeforeMessageResize:x}:{},...n?{adapter:n}:{}},q.id)),t.jsxs("button",{type:"button",className:"thread-graph-worked-summary group flex w-full items-center gap-2 py-2 text-left text-sm transition",onClick:()=>u(a.id,!0),"aria-label":`${L}. Expand turn ${s}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:L}),t.jsx(R.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"})]}),$.finalAgent?t.jsx(At,{threadId:r,item:$.finalAgent,scrollRootRef:k,timeLabel:$.finalAgent.createdAt?t.jsx(Cr,{absoluteLabel:kt($.finalAgent.createdAt),timestamp:$.finalAgent.createdAt,turnStartedAt:a.startedAt}):P,timeTitle:$.finalAgent.createdAt?qt($.finalAgent.createdAt):Y,...x?{onBeforeMessageResize:x}:{},...n?{adapter:n}:{}}):null]}):null,ce=t.jsx(xg,{footer:D,history:t.jsxs(t.Fragment,{children:[le,B]}),liveHookPrompt:F,liveOutput:E,livePlan:A});return t.jsx(bg,{absoluteIndex:s,body:ce,collapsed:U,collapsedBody:ee,error:a.error,headerStatus:t.jsx(Vs,{turn:a}),isActive:N,refCallback:w,startedAt:a.startedAt,timeLabel:P,timeTitle:Y,tokenSummary:t.jsx(jg,{turn:a})})});function Xl({entries:e,expandedGroups:r,onToggleGroupedItem:n,threadId:a,scrollRootRef:s,onOpenExpandedText:o,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,onSelectArtifact:h,onBeforeMessageResize:m,adapter:u,fallbackTimestamp:p,fallbackTimeLabel:f,fallbackTimeTitle:g,turnStartedAt:b,autoOpenLatestToolDetails:j=!1}){var w;const x=((w=e.at(-1))==null?void 0:w.key)??null,k=c.useCallback(v=>v?t.jsx(Cr,{absoluteLabel:kt(v),timestamp:v,turnStartedAt:b??p}):null,[p,b]);return t.jsx(Df,{entries:e,expandedGroups:r,onToggleGroupedItem:n,renderCommandGroup:(v,y,N)=>t.jsx(ig,{items:v.items,expanded:y,onToggleExpanded:N,onOpen:l,timeMeta:k(Ot(v))},v.key),renderFileChangeGroup:(v,y,N)=>t.jsx(mg,{items:v.items,expanded:y,onToggleExpanded:N,onOpen:o,timeMeta:k(Ot(v))},v.key),renderSearchGroup:(v,y,N)=>t.jsx(hg,{items:v.items,expanded:y,onToggleExpanded:N,onOpen:o,timeMeta:k(Ot(v))},v.key),renderFileReadGroup:(v,y,N)=>t.jsx(ug,{items:v.items,expanded:y,onToggleExpanded:N,onOpen:o,timeMeta:k(Ot(v))},v.key),renderToolCallGroup:(v,y,N)=>t.jsx(dg,{items:v.items,expanded:y,onToggleExpanded:N,onOpen:i,timeMeta:k(Ot(v))},v.key),renderAgentActivityGroup:(v,y,N)=>t.jsx(cg,{itemCount:v.itemCount,expanded:y,onToggleExpanded:N,timeMeta:k(Ot(v.entries[0])),children:t.jsx(Xl,{entries:v.entries,expandedGroups:r,onToggleGroupedItem:n,threadId:a,scrollRootRef:s,onOpenExpandedText:o,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,...m?{onBeforeMessageResize:m}:{},fallbackTimestamp:p,fallbackTimeLabel:f,fallbackTimeTitle:g,turnStartedAt:b,autoOpenLatestToolDetails:!1,...h?{onSelectArtifact:h}:{},...u?{adapter:u}:{}})},v.key),renderItem:v=>{const y=Ig(v.item,p??null),S=v.item.kind==="userMessage"?v.item.createdAt?kt(y):f:v.item.createdAt?t.jsx(Cr,{absoluteLabel:kt(y),timestamp:y,turnStartedAt:b??p}):f;return t.jsx(Sa,{threadId:a,item:v.item,scrollRootRef:s,timeLabel:S,timeTitle:v.item.createdAt?qt(y):g,timeMeta:k(y),autoOpenToolDetails:j&&v.key===x,onOpenExpandedText:o,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,...m?{onBeforeMessageResize:m}:{},...h?{onSelectArtifact:h}:{},...u?{adapter:u}:{}},v.key)}})}var qs=3,Mg=3,da=80;function kr(e,r=da){return e.scrollHeight-e.scrollTop-e.clientHeight<=r}function $g(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 Dg(e){return e.map(n=>{const a=n.createdAt;return typeof a=="string"&&a.trim()?a:null}).filter(n=>!!n).sort()[0]??null}function Bg(e,r){return{id:e,startedAt:Dg(r),status:"inProgress",error:null,model:null,reasoningEffort:null,reasoningEffortAvailable:null,tokenUsage:null,priceEstimate:null,items:[]}}function Ks(e,r,n){return{id:e.id,kind:e.kind,title:r,text:n}}function Gg({loadHistoryItemDetail:e,onSelectHistoryItemDetail:r}){const n=c.useRef(0),a=c.useRef(new Map),[s,o]=c.useState(null),l=c.useCallback((f,g)=>{o({title:f,text:g})},[]),i=c.useCallback((f,g,b)=>{if(b&&r){r({item:f,detail:g});return}o({title:g.title,text:g.text})},[r]),d=c.useCallback(async({item:f,fallbackTitle:g,fallbackText:b,loadingText:j,errorText:x,useSelectionCallback:k})=>{if(!f.hasDeferredDetail||!e){i(f,Ks(f,g,b),k);return}const w=a.current.get(f.id);if(w){i(f,w,k);return}const v=n.current+1;n.current=v,k&&r||o({title:g,text:j});try{const y=await e(f.id);if(a.current.set(f.id,y),n.current!==v)return;i(f,y,k)}catch(y){if(n.current!==v)return;i(f,Ks(f,g,y instanceof Error?y.message:x),k)}},[e,r,i]),h=c.useCallback(async(f,g)=>{var b;await d({item:f,fallbackTitle:g,fallbackText:((b=f.detailText)==null?void 0:b.trim())||f.text||"Command output",loadingText:"Loading full command output...",errorText:"Unable to load full command output.",useSelectionCallback:!0})},[d]),m=c.useCallback(async(f,g)=>{var b;await d({item:f,fallbackTitle:g,fallbackText:((b=f.detailText)==null?void 0:b.trim())||f.text||"Tool call",loadingText:"Loading full tool call details...",errorText:"Unable to load full tool call details.",useSelectionCallback:!0})},[d]),u=c.useCallback(async(f,g,b,j,x)=>{await d({item:f,fallbackTitle:g,fallbackText:b,loadingText:j,errorText:x,useSelectionCallback:!1})},[d]),p=c.useCallback(()=>{n.current+=1,o(null)},[]);return{expandedText:s,openExpandedText:l,openCommandDetail:h,openToolCallDetail:m,openDeferredHistoryItemDetail:u,closeExpandedText:p}}function Fg(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 Hg({threadId:e,turnsLength:r,totalTurnCount:n,loadingEarlier:a,onLoadEarlier:s,scrollRequestKey:o,bottomSpacer:l,onTailVisibilityChange:i,contentRevisionInputs:d}){const h=c.useRef(null),m=c.useRef(null),u=c.useRef(o),p=c.useRef(null),f=c.useRef(l),g=c.useRef(0),b=c.useRef(0),j=c.useRef(null),x=c.useRef(null),k=c.useRef(null),w=c.useRef(!0),v=c.useRef(!0),y=c.useRef(!1),N=c.useRef(!1),S=c.useRef(!1),T=c.useRef(!1),M=c.useRef(null),A=c.useRef(0),[J,W]=c.useState(qs),[re,O]=c.useState(0),[P,Y]=c.useState(!0),Z=Fg(d),_=typeof s=="function"||n!==void 0,ie=n??r,H=_?0:Math.max(0,r-J),F=(_?Math.max(0,ie-r):0)+H,E=_?r:r-H,D=_?0:r-E,$=_?Math.max(0,ie-r):0,L=_?$+D:D,C=!_&&L>0&&re>=2,U=_&&$>0&&D===0&&typeof s=="function",G=c.useCallback(()=>{const Q=h.current;if(!Q){j.current=null;return}j.current={scrollHeight:Q.scrollHeight,scrollTop:Q.scrollTop}},[]),le=c.useCallback(()=>!U||a||S.current?!1:(G(),S.current=!0,T.current=!1,A.current=0,s==null||s(),!0),[U,a,s,G]),ee=c.useCallback(()=>{const Q=h.current,me=x.current;if(!Q)return;const we=me?$g(Q,me):kr(Q);w.current=we,Y(Ce=>Ce===we?Ce:we)},[]),ce=c.useCallback(()=>{const Q=h.current;if(Q){N.current=!0;const me=Q.scrollTop,we=b.current,Ce=me-we;b.current=me,kr(Q,1)?(y.current=!1,v.current=!0):Ce<-1?(y.current=!0,v.current=!1):Ce>1&&(v.current=!y.current&&kr(Q,da)),me<=0&&N.current?T.current=!0:me>0&&(T.current=!1,A.current=0)}ee()},[ee]),q=c.useCallback(()=>{const Q=h.current;Q&&(Q.scrollTop=Q.scrollHeight,b.current=Q.scrollTop,g.current=Q.scrollHeight,w.current=!0,Y(me=>me||!0),y.current=!1,v.current=!0)},[]),ve=c.useCallback(()=>{const Q=h.current;Q&&(b.current=Q.scrollTop,g.current=Q.scrollHeight,v.current=!1,y.current=!0)},[]),ke=c.useCallback(()=>{if(_&&D===0){le();return}W(Q=>Math.min(r,Q+Mg)),O(Q=>Q+1)},[D,_,le,r]),je=c.useCallback(Q=>{const me=h.current;if(!(!me||Q.deltaY>=-8||me.scrollTop>0||!U)){if(!T.current){T.current=!0;return}le()}},[U,le]),ye=c.useCallback(Q=>{var me;M.current=((me=Q.touches.item(0))==null?void 0:me.clientY)??null,A.current=0},[]),fe=c.useCallback(Q=>{var Be;const me=h.current,we=((Be=Q.touches.item(0))==null?void 0:Be.clientY)??null,Ce=M.current;if(M.current=we,!me||we===null||Ce===null||me.scrollTop>0||!U){A.current=0;return}const Me=we-Ce;if(Me<=0){A.current=0;return}if(!T.current){T.current=!0,A.current=0;return}A.current+=Me,A.current>=28&&le()},[U,le]),Te=c.useCallback(()=>{M.current=null,A.current=0},[]),oe=c.useCallback(()=>{W(r)},[r]);return c.useLayoutEffect(()=>{const Q=window.requestAnimationFrame(()=>{q()});return()=>{window.cancelAnimationFrame(Q)}},[e,q]),c.useEffect(()=>{S.current=!1,N.current=!1,T.current=!1,j.current=null},[e]),c.useEffect(()=>{a||(S.current=!1)},[a,r]),c.useLayoutEffect(()=>{const Q=j.current,me=h.current;if(!Q||!me||a)return;j.current=null;const we=me.scrollHeight-Q.scrollHeight;if(we<=0){g.current=me.scrollHeight,b.current=me.scrollTop;return}const Ce=Q.scrollTop+we;me.scrollTop=Ce,b.current=Ce,g.current=me.scrollHeight,y.current=!0,v.current=!1,T.current=!1},[a,r]),c.useEffect(()=>{W(Q=>Q>=r-1?r:Math.max(Q,qs))},[r]),c.useEffect(()=>{const Q=h.current;Q&&(g.current=Q.scrollHeight,b.current=Q.scrollTop,kr(Q,1)?(y.current=!1,v.current=!0):(y.current||!kr(Q,da))&&(v.current=!1)),ee()},[Z,ee,J]),c.useEffect(()=>{const Q=o!==u.current,me=p.current!==Z;if(p.current=Z,!(Q||me&&v.current&&!y.current))return;const Ce=window.requestAnimationFrame(()=>{q()});return o!==u.current&&(u.current=o),()=>{window.cancelAnimationFrame(Ce)}},[Z,P,q,o]),c.useEffect(()=>{const Q=h.current,me=m.current;if(!Q||!me||typeof ResizeObserver>"u")return;g.current=Q.scrollHeight;const we=new ResizeObserver(()=>{const Ce=Q.scrollHeight,Me=g.current;if(g.current=Ce,Ce<=Me)return;const Be=Me>0&&Me-Q.scrollTop-Q.clientHeight<=1;y.current||!(v.current||Be||w.current)||window.requestAnimationFrame(()=>{q()})});return we.observe(me),()=>{we.disconnect()}},[q]),c.useEffect(()=>{if(!v.current||y.current){f.current=l;return}if(l===f.current)return;f.current=l;const Q=window.requestAnimationFrame(()=>{q()});return()=>{window.cancelAnimationFrame(Q)}},[l,q]),c.useEffect(()=>{i==null||i(P)},[P,i]),{scrollContainerRef:h,scrollContentRef:m,tailSentinelRef:x,topSentinelRef:k,isTailVisible:P,handleScroll:ce,handleWheel:je,handleTouchStart:ye,handleTouchMove:fe,handleTouchEnd:Te,preserveScrollPositionForResize:ve,serverManagedHistory:_,effectiveTotalTurnCount:ie,startIndex:H,visibleTurnAbsoluteOffset:F,hiddenCount:L,loadedHiddenCount:D,unloadedHiddenCount:$,showLoadAll:C,handleLoadEarlierClick:ke,handleLoadAllClick:oe}}function Og(e){return e==="completed"||e==="failed"||e==="interrupted"}function Mn(...e){let r=null;for(const n of e){if(!n)continue;const a=Date.parse(n);Number.isFinite(a)&&(!r||a>r.millis)&&(r={timestamp:n,millis:a})}return(r==null?void 0:r.timestamp)??null}function Wg(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 Ug({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:m,liveOutput:u,scrollRequestKey:p=0,previousTurnScrollRequestKey:f=0,nextTurnScrollRequestKey:g=0,bottomSpacer:b=0,className:j="",onTailVisibilityChange:x,onPreviousTurnAvailabilityChange:k,onNextTurnAvailabilityChange:w,loadingEarlier:v=!1,onLoadEarlier:y,ephemeralUserNote:N=null,answeredRequestNotes:S=[],activityNotes:T=[],optimisticSteers:M=[],optimisticTurn:A=null,onLoadHistoryItemDetail:J,onOpenThread:W,onSelectArtifact:re,onSelectHistoryItemDetail:O,adapter:P,autoCollapseCompletedTurns:Y}){var st,xt,dt,Tt,Et;const Z=Ll(),_=Y??(Z==null?void 0:Z.autoCollapseCompletedTurns)??!1,[ie,H]=c.useState({}),[B,F]=c.useState(()=>new Set),E=c.useRef(null),D=c.useRef(null),$=(P==null?void 0:P.onLoadHistoryItemDetail)??J,L=P==null?void 0:P.onOpenLinkedThread,{expandedText:C,openExpandedText:U,openCommandDetail:G,openToolCallDetail:le,openDeferredHistoryItemDetail:ee,closeExpandedText:ce}=Gg({loadHistoryItemDetail:$,onSelectHistoryItemDetail:O}),{scrollContainerRef:q,scrollContentRef:ve,tailSentinelRef:ke,topSentinelRef:je,handleScroll:ye,handleWheel:fe,handleTouchStart:Te,handleTouchMove:oe,handleTouchEnd:Q,preserveScrollPositionForResize:me,serverManagedHistory:we,effectiveTotalTurnCount:Ce,startIndex:Me,visibleTurnAbsoluteOffset:Be,hiddenCount:Ae,loadedHiddenCount:He,unloadedHiddenCount:X,showLoadAll:he,handleLoadEarlierClick:Se,handleLoadAllClick:I}=Hg({threadId:e,turnsLength:r.length,totalTurnCount:n,loadingEarlier:v,onLoadEarlier:y,scrollRequestKey:p,bottomSpacer:b,onTailVisibilityChange:x,contentRevisionInputs:[r,a,l,M,u,i,d,A,S,T,N,b]}),V=c.useCallback((te,ne)=>{H(xe=>({...xe,[te]:!ne}))},[]),se=c.useCallback((te,ne)=>{const xe=ie[te.id];return xe!==void 0?xe:!!(_&&Og(te.status)&&!ne.forceActive&&!ne.hasLiveActivity)},[ie,_]),ge=we?r:r.slice(Me),Ne=Ce+1,Le=o&&(!s||!ge.some(te=>te.id===s)&&(A==null?void 0:A.id)!==s),de=(A==null?void 0:A.id)??((st=ge.at(-1))==null?void 0:st.id)??null,Ge=Le&&de!==null,qe=!!d&&(ge.some(te=>te.id===d.turnId)||(A==null?void 0:A.id)===d.turnId),Ue=d&&qe?d.turnId:d&&Ge?de:null,Ye=A&&Ue===A.id?(d==null?void 0:d.items)??null:null,pt=((d==null?void 0:d.items.length)??0)>0,rt=d&&Ue===null?d.items:null,lt=c.useMemo(()=>d&&Ue===null&&d.items.length>0?Bg(d.turnId,d.items):null,[d,Ue]),Ze=Math.max(1,Ce+(A?1:0)),mt=!!u&&!!A&&A.status!=="failed"&&!Ye,it=u&&ge.length>0?s&&ge.some(te=>te.id===s)?s:((xt=ge.findLast(te=>Ca(te.status)))==null?void 0:xt.id)??(Ge?de:null):null,z=!!it,K=c.useMemo(()=>u?new Date().toISOString():null,[u]),be=c.useMemo(()=>_l(u),[u]),Pe=[...l.map(te=>({id:te.id,prompt:te.prompt,status:"Accepted",createdAt:te.createdAt,canCancel:!0})),...M.map(te=>({id:te.id,prompt:te.prompt,status:te.status==="steering"?"Steering":null,createdAt:te.createdAt,canCancel:!1}))].sort((te,ne)=>te.createdAt.localeCompare(ne.createdAt)),Oe=c.useMemo(()=>Af({answeredRequestNotes:S,pendingRequests:a,visibleTurns:ge,optimisticTurn:A}),[S,A,a,ge]),Fe=c.useMemo(()=>_f({activityNotes:T,visibleTurns:ge,optimisticTurn:A}),[T,A,ge]),nt=c.useCallback(()=>{const te=q.current;if(!te)return null;const ne=te.getBoundingClientRect().top;return Array.from(te.querySelectorAll("[data-timeline-turn]")).find(xe=>xe.getBoundingClientRect().top>ne+8)??null},[q]),Ve=c.useCallback(()=>{const te=q.current;if(!te)return null;const ne=te.getBoundingClientRect().top;return Array.from(te.querySelectorAll("[data-timeline-turn]")).findLast(xe=>xe.getBoundingClientRect().top<ne-8)??null},[q]),$e=c.useCallback(()=>{k==null||k(!!Ve())},[Ve,k]),at=c.useCallback(()=>{w==null||w(!!nt())},[nt,w]),wt=c.useCallback(()=>{ye(),$e(),at()},[ye,at,$e]);return c.useEffect(()=>{$e(),at()},[at,$e,ge]),c.useEffect(()=>{if(f===0)return;const te=q.current,ne=Ve(),xe=te?Array.from(te.querySelectorAll("[data-timeline-turn]")):[],Xe=ne?xe.indexOf(ne):-1,_e=ne&&ne.dataset.turnId===E.current?xe[Xe-1]??null:ne;if(!te||!_e)return;E.current=_e.dataset.turnId??null;const tt=_e.getBoundingClientRect().top-te.getBoundingClientRect().top;te.scrollTo({top:te.scrollTop+tt-8,behavior:"smooth"}),xe.indexOf(_e)===0&&(k==null||k(!1))},[Ve,k,f,q]),c.useEffect(()=>{if(g===0)return;const te=q.current,ne=nt(),xe=te?Array.from(te.querySelectorAll("[data-timeline-turn]")):[],Xe=ne?xe.indexOf(ne):-1,_e=ne&&ne.dataset.turnId===D.current?xe[Xe+1]??null:ne;if(!te||!_e)return;D.current=_e.dataset.turnId??null;const tt=_e.getBoundingClientRect().top-te.getBoundingClientRect().top;te.scrollTo({top:te.scrollTop+tt-8,behavior:"smooth"}),xe.indexOf(_e)===xe.length-1&&(w==null||w(!1))},[nt,g,w,q]),t.jsxs(t.Fragment,{children:[t.jsx("section",{className:`flex min-h-0 flex-1 flex-col ${j}`.trim(),children:t.jsx("div",{ref:q,"data-testid":"thread-scroll-container",onScroll:wt,onWheel:fe,onTouchStart:Te,onTouchMove:oe,onTouchEnd:Q,onTouchCancel:Q,className:"thread-graph-scroll-container min-h-0 flex-1 overflow-y-auto overscroll-contain",style:b>0?{paddingBottom:b}:void 0,children:t.jsxs("div",{ref:ve,className:"thread-graph-scroll-content",children:[t.jsx("div",{ref: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:[Ae>0&&t.jsx("button",{type:"button",onClick:Se,disabled:v,className:"thread-graph-history-button rounded-full border px-2.5 py-1.5 transition",children:v?"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 ",Ce," turns",Ae>0?` · ${Ae} earlier hidden${He>0&&X>0?` (${He} loaded)`:""}`:""]})]})}),r.length===0&&!u&&!A&&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||A||Fe.leading.length>0||Fe.trailing.length>0)&&t.jsxs("div",{className:"thread-graph-message-list",children:[Fe.leading.length>0?t.jsx(br,{notes:Fe.leading,onOpenThread:W,onOpenLinkedThread:L}):null,ge.map((te,ne)=>{var xe,Xe,_e,tt,Lt;return t.jsxs("div",{"data-timeline-turn":!0,"data-turn-id":te.id,children:[(((xe=Fe.beforeTurnId.get(te.id))==null?void 0:xe.length)??0)>0?t.jsx(br,{notes:Fe.beforeTurnId.get(te.id)??[],onOpenThread:W,onOpenLinkedThread:L}):null,(((Xe=Oe.beforeTurnId.get(te.id))==null?void 0:Xe.length)??0)>0?t.jsx(ia,{entries:Oe.beforeTurnId.get(te.id)??[],respondingRequestId:h,onRespondToRequest:m??void 0}):null,(()=>{const yt=Wg(te,A),jt=(i==null?void 0:i.turnId)===te.id?i:null,$t=Ue===te.id?(d==null?void 0:d.items)??null:null,Jt=it===te.id?u:"",ht=Mn(jt==null?void 0:jt.updatedAt,Ue===te.id?d==null?void 0:d.updatedAt:null,Jt?K:null),Mr=s===te.id||Ge&&de===te.id,xn=!!jt||!!Jt||!!($t&&$t.length>0),bn=se(yt,{forceActive:Mr,hasLiveActivity:xn});return t.jsx(_n,{threadId:e,...P?{adapter:P}:{},turn:yt,absoluteIndex:Be+ne+1,isCollapsed:bn,livePlan:jt,liveItems:$t,liveActivityAt:ht,liveOutput:Jt,forceActive:Mr,onToggleCollapse:V,onOpenExpandedText:U,onOpenCommandDetail:G,onOpenToolCallDetail:le,onOpenDeferredHistoryItemDetail:ee,onBeforeMessageResize:me,...re?{onSelectArtifact:re}:{},scrollRootRef:q,articleRef:void 0})})(),(((_e=Fe.afterTurnId.get(te.id))==null?void 0:_e.length)??0)>0?t.jsx(br,{notes:Fe.afterTurnId.get(te.id)??[],onOpenThread:W,onOpenLinkedThread:L}):null,(tt=Oe.notesByTurnId.get(te.id))!=null&&tt.length||(Lt=Oe.pendingRequestsByTurnId.get(te.id))!=null&&Lt.length?t.jsx(Mf,{notes:Oe.notesByTurnId.get(te.id)??[],requests:Oe.pendingRequestsByTurnId.get(te.id)??[],respondingRequestId:h,onRespondToRequest:m??void 0}):null]},te.id)}),A&&ge.every(te=>te.id!==A.id)&&t.jsxs(t.Fragment,{children:[(((dt=Fe.beforeTurnId.get(A.id))==null?void 0:dt.length)??0)>0?t.jsx(br,{notes:Fe.beforeTurnId.get(A.id)??[],onOpenThread:W,onOpenLinkedThread:L}):null,(((Tt=Oe.beforeTurnId.get(A.id))==null?void 0:Tt.length)??0)>0?t.jsx(ia,{entries:Oe.beforeTurnId.get(A.id)??[],respondingRequestId:h,onRespondToRequest:m??void 0}):null,(()=>{const te=mt?u:"",ne=Mn(Ue===A.id?d==null?void 0:d.updatedAt:null,te?K:null),xe=s===A.id||Ge&&de===A.id,Xe=!!(Ye&&Ye.length>0)||!!te,_e=se(A,{forceActive:xe,hasLiveActivity:Xe});return t.jsx(_n,{threadId:e,...P?{adapter:P}:{},turn:A,absoluteIndex:Ne,isCollapsed:_e,livePlan:null,liveItems:Ye,liveActivityAt:ne,liveOutput:te,forceActive:xe,onToggleCollapse:V,onOpenExpandedText:U,onOpenCommandDetail:G,onOpenToolCallDetail:le,onOpenDeferredHistoryItemDetail:ee,onBeforeMessageResize:me,...re?{onSelectArtifact:re}:{},scrollRootRef:q})})(),(((Et=Fe.afterTurnId.get(A.id))==null?void 0:Et.length)??0)>0?t.jsx(br,{notes:Fe.afterTurnId.get(A.id)??[],onOpenThread:W,onOpenLinkedThread:L}):null]})]}),Pe.length>0&&t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:Pe.map(te=>t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(At,{threadId:e,item:{id:te.id,kind:"userMessage",text:te.prompt,status:te.status},scrollRootRef:q,onBeforeMessageResize:me,...P?{adapter:P}:{}}),e&&te.canCancel&&(P!=null&&P.cancelPendingSteer)?t.jsx("div",{className:"flex justify-end px-1",children:t.jsx("button",{type:"button",className:"thread-graph-history-button rounded-full border px-2.5 py-1 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",disabled:B.has(te.id),onClick:()=>{var ne;F(xe=>new Set(xe).add(te.id)),Promise.resolve((ne=P.cancelPendingSteer)==null?void 0:ne.call(P,e,te.id)).catch(()=>{}).finally(()=>{F(xe=>{const Xe=new Set(xe);return Xe.delete(te.id),Xe})})},children:B.has(te.id)?"Canceling...":"Cancel"})}):null]},te.id))}),(Oe.trailing.length>0||Fe.trailing.length>0)&&t.jsx($f,{entries:[...Fe.trailing.map(te=>({kind:"activity",id:te.id,createdAt:te.createdAt,note:te})),...Oe.trailing],respondingRequestId:h,onRespondToRequest:m??void 0,onOpenThread:W,onOpenLinkedThread:L}),N&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:t.jsx(At,{threadId:e,item:{id:"ephemeral-plan-decision-note",kind:"userMessage",text:N},scrollRootRef:q,onBeforeMessageResize:me})}),lt&&rt&&rt.length>0&&t.jsx(_n,{threadId:e,...P?{adapter:P}:{},turn:lt,absoluteIndex:Ze,isCollapsed:ie[lt.id]??!1,livePlan:(i==null?void 0:i.turnId)===lt.id?i:null,liveItems:rt,liveActivityAt:Mn((i==null?void 0:i.turnId)===lt.id?i.updatedAt:null,(d==null?void 0:d.turnId)===lt.id?d.updatedAt:null),liveOutput:"",forceActive:!0,onToggleCollapse:V,onOpenExpandedText:U,onOpenCommandDetail:G,onOpenToolCallDetail:le,onOpenDeferredHistoryItemDetail:ee,onBeforeMessageResize:me,...re?{onSelectArtifact:re}:{},scrollRootRef:q}),u&&!z&&!mt&&!pt&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:be?t.jsx(Sa,{threadId:e,item:be,scrollRootRef:q,onOpenExpandedText:U,onOpenCommandDetail:G,onOpenToolCallDetail:le,onOpenDeferredHistoryItemDetail:ee,onBeforeMessageResize:me,...re?{onSelectArtifact:re}:{},...P?{adapter:P}:{}}):t.jsx(At,{threadId:e,item:{id:"live-agent-message-fallback",kind:"agentMessage",text:u},scrollRootRef:q,streaming:!0,onBeforeMessageResize:me,...P?{adapter:P}:{}})}),t.jsx("div",{ref:ke,"aria-hidden":"true",className:"h-px w-full"})]})})}),t.jsx(Xp,{open:C!==null,title:(C==null?void 0:C.title)??"Full text",text:(C==null?void 0:C.text)??"",onClose:ce})]})}var ql=c.memo(Ug);function Vg(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}function ca(e){return e.replace(/\r\n/g,`
|
|
3962
|
+
`)}function Ys(e){const r=ca(e),n=r.split(`
|
|
3963
3963
|
`);return r.endsWith(`
|
|
3964
|
-
`)&&n.at(-1)===""&&n.pop(),n}function
|
|
3965
|
-
`).trimEnd()}function Vg(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 qs(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 _n(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 fn(e){if(!e)return"";const r=e.replace(/[\\/]+$/,"");return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function Na(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 Mn(e){return Math.min(75,Math.max(25,e))}function Xg(){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 qg({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 Ks(){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 An({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 Kg=120,Yg=800,Zg=4e3,Jg=4500,Qg="Shell connection timed out. Reconnecting...";function ex({isCurrentSocket:e,viewerId:r}){return!e||r?null:{connectionError:Qg,isConnecting:!1,settleAttachPromise:!1,closeSocket:!0}}function tx({isCurrentSocket:e,shellId:r,attachSize:n}){return e?{message:{type:"shell.attach",shellId:r,cols:n.cols,rows:n.rows},shouldScheduleAttachTimeout:!0}:null}function rx({intentionalDisconnect:e,userDisconnectedShellId:r,shellId:n}){return!e&&r!==n}function nx({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:s}){return e?{shouldDetachShell:r,shouldScheduleReconnect:rx({intentionalDisconnect:n,userDisconnectedShellId:a,shellId:s})}:null}function ax({hasAttachSize:e,hasPendingRetry:r}){return!e&&!r}function Ul({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}:ax({hasAttachSize:!1,hasPendingRetry:i})?{type:"scheduleRetry"}:{type:"skip"}}function sx({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 ox({shellId:e,userDisconnectedShellId:r}){return{shouldClearUserDisconnectedShellId:!!e&&r===e,intentionalDisconnect:!1,connectionError:null,isConnecting:!0,shouldIncrementReconnectKey:!0}}function lx({hasShell:e}){return e?null:{viewerId:null,isConnecting:!1,settleAttachPromise:!1,connectionError:null,runtimePromptLabel:null,isCommandRunning:!1,shellSnapshot:"",lastCommandOutput:"",pendingCommand:null,shouldResetTerminal:!0}}function ix({hasReconnectTimer:e,hasAttachTimeout:r,hasAttachRetry:n}){return{shouldClearReconnectTimer:e,shouldClearAttachTimeout:r,shouldClearAttachRetry:n,settleAttachPromise:!1}}function Vl({shellId:e,viewerId:r}){return e&&r?{type:"shell.detach",shellId:e,viewerId:r}:null}function dx({shellId:e,viewerId:r,hasSocket:n}){return{userDisconnectedShellId:e,intentionalDisconnect:!0,detachMessage:Vl({shellId:e,viewerId:r}),shouldCloseSocket:n,shouldClearSocketRef:!0,shouldClearLastSentSize:!0,shouldDetachShell:!!e}}function cx({shellId:e,viewerId:r,socketReadyState:n,openReadyState:a,hasAttachRetryTimer:s,hasAttachTimeout:o,isCurrentSocket:l}){const i=Vl({shellId:e,viewerId:r});return{intentionalDisconnect:!0,shouldClearAttachRetry:s,detachMessage:i,shouldSendDetachMessage:!!(i&&n===a),shouldClearViewer:!0,isConnecting:!1,settleAttachPromise:l?!1:void 0,shouldClearAttachTimeout:o,shouldCloseSocket:!0,shouldClearSocketRef:l}}function hx({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 ux(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:Na(n??fn(r),a),isCommandRunning:e.isCommandRunning===!0}}function mx({currentSnapshot:e,data:r,replace:n,isCommandRunning:a,pendingCommand:s}){if(!r)return{nextSnapshot:e,nextPendingCommand:s,lastCommandOutput:null};const o=la(n?r:`${e}${r}`);return!n||a||!s?{nextSnapshot:o,nextPendingCommand:s,lastCommandOutput:null}:{nextSnapshot:o,nextPendingCommand:null,lastCommandOutput:Ug(s.beforeSnapshot,o,s.command)}}function px({event:e,currentViewerId:r}){if(e.type==="shell.output")return null;if(e.type==="shell.connected"){const a=String(e.payload.viewerId??"");return{viewerId:a||null,isConnecting:!1,settleAttachPromise:!!a,isCommandRunning:void 0,connectionError:void 0,intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:{status:"attached",attachedViewerId:a}}}if(e.type==="shell.error")return{viewerId:void 0,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:void 0,connectionError:String(e.payload.message??"Shell connection failed."),intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:e.payload.code==="viewer_conflict"?{status:"detached",attachedViewerId:null}:void 0};if(e.type==="shell.detached"){const a=String(e.payload.viewerId??"");if(!a||a!==r)return null;const s=String(e.payload.reason??"");return{viewerId:null,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:!1,connectionError:s==="replaced"?"This shell connection was taken over by another pane or device.":null,intentionalDisconnect:s==="replaced"?!0:void 0,closeSocket:!0,shellUpdate:{status:"detached",attachedViewerId:null}}}if(e.type==="shell.exited")return{viewerId:null,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:!1,connectionError:void 0,intentionalDisconnect:!0,closeSocket:!0,shellUpdate:{status:e.payload.state==="exited"?"exited":"not_found",attachedViewerId:null}};const n=e.payload.state;return{viewerId:n==="attached"?void 0:null,isConnecting:n==="attached"?void 0:!1,settleAttachPromise:n==="attached"?void 0:!1,isCommandRunning:n==="attached"?void 0:!1,connectionError:void 0,intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:{status:n,attachedViewerId:n==="attached"?void 0:null}}}function Xl(e,r,n,a,s){const o=r.replace(/\r\n/g,`
|
|
3964
|
+
`)&&n.at(-1)===""&&n.pop(),n}function Xg(e){const r=e.trim();return r?/(?:[$%#>])\s*$/.test(r):!1}function qg(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 Kg(e,r,n){var d,h;const a=Ys(e),s=Ys(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=qg(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())===""||Xg(i.at(-1)??""));)i.pop();return i.join(`
|
|
3965
|
+
`).trimEnd()}function Yg(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 Zs(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 $n(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 gn(e){if(!e)return"";const r=e.replace(/[\\/]+$/,"");return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function Ta(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 Dn(e){return Math.min(75,Math.max(25,e))}function Zg(){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 Jg({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 Js(){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 Bn({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 Qg=120,ex=800,tx=4e3,rx=4500,nx="Shell connection timed out. Reconnecting...";function ax({isCurrentSocket:e,viewerId:r}){return!e||r?null:{connectionError:nx,isConnecting:!1,settleAttachPromise:!1,closeSocket:!0}}function sx({isCurrentSocket:e,shellId:r,attachSize:n}){return e?{message:{type:"shell.attach",shellId:r,cols:n.cols,rows:n.rows},shouldScheduleAttachTimeout:!0}:null}function ox({intentionalDisconnect:e,userDisconnectedShellId:r,shellId:n}){return!e&&r!==n}function lx({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:s}){return e?{shouldDetachShell:r,shouldScheduleReconnect:ox({intentionalDisconnect:n,userDisconnectedShellId:a,shellId:s})}:null}function ix({hasAttachSize:e,hasPendingRetry:r}){return!e&&!r}function Kl({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}:ix({hasAttachSize:!1,hasPendingRetry:i})?{type:"scheduleRetry"}:{type:"skip"}}function dx({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 cx({shellId:e,userDisconnectedShellId:r}){return{shouldClearUserDisconnectedShellId:!!e&&r===e,intentionalDisconnect:!1,connectionError:null,isConnecting:!0,shouldIncrementReconnectKey:!0}}function hx({hasShell:e}){return e?null:{viewerId:null,isConnecting:!1,settleAttachPromise:!1,connectionError:null,runtimePromptLabel:null,isCommandRunning:!1,shellSnapshot:"",lastCommandOutput:"",pendingCommand:null,shouldResetTerminal:!0}}function ux({hasReconnectTimer:e,hasAttachTimeout:r,hasAttachRetry:n}){return{shouldClearReconnectTimer:e,shouldClearAttachTimeout:r,shouldClearAttachRetry:n,settleAttachPromise:!1}}function Yl({shellId:e,viewerId:r}){return e&&r?{type:"shell.detach",shellId:e,viewerId:r}:null}function mx({shellId:e,viewerId:r,hasSocket:n}){return{userDisconnectedShellId:e,intentionalDisconnect:!0,detachMessage:Yl({shellId:e,viewerId:r}),shouldCloseSocket:n,shouldClearSocketRef:!0,shouldClearLastSentSize:!0,shouldDetachShell:!!e}}function px({shellId:e,viewerId:r,socketReadyState:n,openReadyState:a,hasAttachRetryTimer:s,hasAttachTimeout:o,isCurrentSocket:l}){const i=Yl({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 fx({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 gx(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:Ta(n??gn(r),a),isCommandRunning:e.isCommandRunning===!0}}function xx({currentSnapshot:e,data:r,replace:n,isCommandRunning:a,pendingCommand:s}){if(!r)return{nextSnapshot:e,nextPendingCommand:s,lastCommandOutput:null};const o=ca(n?r:`${e}${r}`);return!n||a||!s?{nextSnapshot:o,nextPendingCommand:s,lastCommandOutput:null}:{nextSnapshot:o,nextPendingCommand:null,lastCommandOutput:Kg(s.beforeSnapshot,o,s.command)}}function bx({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,`
|
|
3966
3966
|
`),l=o.split(`
|
|
3967
3967
|
`);o.endsWith(`
|
|
3968
3968
|
`)&&l.at(-1)===""&&l.pop();let d=l.join(`\r
|
|
3969
|
-
`);if(n!==void 0&&a!==void 0){const m=(s!==void 0?Math.max(0,l.length-s):0)+a,u=Math.max(0,l.length-m-1);u>0&&(d+=`\x1B[${u}A`),d+=`\r\x1B[${n+1}G`}e.reset(),e.write(d,()=>{e.scrollToBottom()})}function
|
|
3970
|
-
`).trimEnd():""}function fx({clearTimeout:e}){let r=null;const n=s=>{(s==null?void 0:s.timer)!==null&&(s==null?void 0:s.timer)!==void 0&&e(s.timer)};return{hasPending:()=>!!r,joinPending:()=>new Promise(s=>{r==null||r.waiters.push(s)}),start:({timeoutMs:s,setTimeout:o,onTimeout:l})=>new Promise(i=>{const d=o(()=>{r=null,l(),i(!1)},s);r={waiters:[i],timer:d}}),settle:s=>{const o=r;if(o){r=null,n(o);for(const l of o.waiters)l(s)}},clear:()=>{const s=r;r=null,n(s)}}}var Zs={status:"not_created",shellInputEnabled:!1,isConnecting:!1,isCommandRunning:!1,promptLabel:null,error:null,hasShell:!1};function wt(e){return e.status!=="exited"&&e.status!=="not_found"}function gx({shell:e,workspacePathMissing:r}){return!!(e&&!r&&wt(e))}function xx(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 bx(e){return(e.activeShellId?e.shells.find(r=>r.id===e.activeShellId&&wt(r)):null)??(e.shell&&wt(e.shell)?e.shell:null)??e.shells.find(wt)??null}function vx({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&&!wt(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&&!wt(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 kx({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?Na(fn(r.cwd),null):null),isMobileShell:s,hasShell:!!r,busy:o,loading:l,error:e.error??i}}function Ut(e){return e.current===null?!1:(window.clearTimeout(e.current),e.current=null,!0)}function wx({attachRetryTimerRef:e,setReconnectKey:r,delayMs:n=Kg}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function yx({reconnectTimerRef:e,setReconnectKey:r,delayMs:n=Yg}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function jx({shellSocket:e,socketRef:r,viewerIdRef:n,attachTimeoutRef:a,setConnectionError:s,setIsConnecting:o,settleAttachPromise:l,delayMs:i=Zg}){a.current=window.setTimeout(()=>{var h,m,u;a.current=null;const d=ex({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&&((m=e.close)==null||m.call(e),(u=e.socket)==null||u.close()))},i)}function Nx(e){return{...e,status:e.status==="attached"?"detached":e.status,attachedViewerId:null}}function Cx({shellId:e,viewerId:r,shellSocket:n,attachRetryTimerRef:a,attachTimeoutRef:s,socketRef:o,openReadyState:l}){var i;return cx({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 Sx({closeApplication:e,shellId:r,attachTimeoutRef:n,socketRef:a,reconnectTimerRef:s,setViewerId:o,setIsConnecting:l,settleAttachPromise:i,onShellUpdate:d,setReconnectKey:h}){const m=e.closeAction;return m?(e.shouldClearAttachTimeout&&Ut(n),e.shouldClearSocketRef&&(a.current=null),o(e.viewerId),l(e.isConnecting),i(e.settleAttachPromise),m.shouldDetachShell&&d(r,Nx,"detached"),m.shouldScheduleReconnect&&yx({reconnectTimerRef:s,setReconnectKey:h}),!0):!1}function Tx({cleanupAction:e,shellSocket:r,attachRetryTimerRef:n,attachTimeoutRef:a,socketRef:s,intentionalDisconnectRef:o,setViewerId:l,setIsConnecting:i,settleAttachPromise:d}){o.current=e.intentionalDisconnect,e.shouldClearAttachRetry&&Ut(n),e.shouldSendDetachMessage&&e.detachMessage&&r.send(e.detachMessage),l(null),i(e.isConnecting),e.settleAttachPromise!==void 0&&d(e.settleAttachPromise),e.shouldClearAttachTimeout&&Ut(a),r.socket.close(),e.shouldClearSocketRef&&(s.current=null)}function Ex({eventShellId:e,shellId:r,socketExists:n,isCurrentSocket:a}){return n&&!a?!1:e===r}function Lx(e){return Ul({...e,attachSize:void 0})}function Ix({attachSize:e,...r}){return Ul({...r,attachSize:e})}function zx({isCurrentSocket:e,shellId:r,attachSize:n,hasAttachTimeout:a}){const s=tx({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 Rx({event:e,shellCwd:r,currentSnapshot:n,pendingCommand:a}){const s=ux(e.payload,r),o=s.data?mx({currentSnapshot:n,data:s.data,replace:s.replace,isCommandRunning:s.isCommandRunning,pendingCommand:a}):null;return{output:s,snapshotUpdate:o}}function _x({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:s,hasAttachTimeout:o}){const l=nx({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 Mx(e,r){return r.shellUpdate?{...e,status:r.shellUpdate.status==="attached"||r.shellUpdate.status==="detached"||r.shellUpdate.status==="exited"||r.shellUpdate.status==="not_found"?r.shellUpdate.status:e.status,attachedViewerId:r.shellUpdate.attachedViewerId===void 0?e.attachedViewerId:r.shellUpdate.attachedViewerId}:e}function Ax(e){return e.current}function $x({shell:e,shellAdapter:r,canAttachShell:n,terminalReady:a,reconnectKey:s,terminalRef:o,socketRef:l,viewerIdRef:i,shellIdRef:d,reconnectTimerRef:h,attachTimeoutRef:m,attachRetryTimerRef:u,isVisibleRef:p,intentionalDisconnectRef:f,userDisconnectedShellIdRef:g,shellSnapshotRef:x,pendingCommandRef:j,lastCommandOutputRef:b,snapshotCursorRef:k,syncTerminalSizeRef:y,setReconnectKey:v,setViewerId:w,setIsConnecting:C,setConnectionError:N,setRuntimePromptLabel:E,setIsCommandRunning:R,settleAttachPromise:_,onShellUpdate:Y}){const W=e==null?void 0:e.id,re=e==null?void 0:e.cwd;c.useEffect(()=>{const F=o.current,A={shellId:W??null,terminalReady:a,isVisible:p.current,canAttachShell:n,userDisconnectedShellId:g.current,hasTerminal:!!F,hasPendingAttachRetry:u.current!==null,hasCurrentSocketForShell:!!(l.current&&d.current===W),hasReconnectTimer:h.current!==null};if(Lx(A).type==="skip")return;const Z=y.current(),M=Ix({...A,attachSize:Z});if(M.type==="skip"||M.type==="measureSize")return;if(M.type==="scheduleRetry"){wx({attachRetryTimerRef:u,setReconnectKey:v});return}if(M.shouldClearAttachRetry&&Ut(u),M.type==="reuseSocket"||(M.shouldClearReconnectTimer&&Ut(h),!W||!F))return;const ie=M.attachSize;d.current=W,F.reset(),N(null),w(null),C(!0),f.current=!1;const O=r.connectSocket({onConnected:()=>{var $;const G=m.current,H=zx({isCurrentSocket:(($=l.current)==null?void 0:$.socket)===O.socket,shellId:W,attachSize:ie,hasAttachTimeout:G!==null}),T=H.openAction;T&&(O.send(T.message),H.shouldClearAttachTimeout&&G!==null&&Ut(m),T.shouldScheduleAttachTimeout&&jx({shellSocket:O,socketRef:l,viewerIdRef:i,attachTimeoutRef:m,setConnectionError:N,setIsConnecting:C,settleAttachPromise:_}))},onShellEvent:G=>{var $;if(!Ex({eventShellId:G.shellId,shellId:W,socketExists:!!O.socket,isCurrentSocket:(($=l.current)==null?void 0:$.socket)===O.socket}))return;if(G.type==="shell.connected"){Ut(m);const D=Px(G);w(D.viewerId),C(!1),_(D.settleAttachPromise),Y(W,D.nextShell,"attached");return}if(G.type==="shell.output"){const{output:D,snapshotUpdate:L}=Rx({event:G,shellCwd:re,currentSnapshot:x.current,pendingCommand:j.current});k.current={cursorX:D.cursorX,cursorY:D.cursorY,paneHeight:D.paneHeight},E(D.promptLabel),R(D.isCommandRunning),L&&(x.current=L.nextSnapshot,j.current=L.nextPendingCommand,L.lastCommandOutput!==null&&(b.current=L.lastCommandOutput),D.replace?Xl(F,D.data,D.cursorX,D.cursorY,D.paneHeight):F.write(D.data));return}const T=px({event:G,currentViewerId:i.current});T&&(T.viewerId!==void 0&&w(T.viewerId),T.isConnecting!==void 0&&C(T.isConnecting),T.settleAttachPromise!==void 0&&_(T.settleAttachPromise),T.isCommandRunning!==void 0&&R(T.isCommandRunning),T.connectionError!==void 0&&N(T.connectionError),T.intentionalDisconnect!==void 0&&(f.current=T.intentionalDisconnect),T.shellUpdate&&Y(W,D=>Mx(D,T),T.shellUpdate.status),T.closeSocket&&O.socket.close())}});return l.current=O,O.socket.addEventListener("close",()=>{var T;const G=m.current,H=_x({isCurrentSocket:((T=l.current)==null?void 0:T.socket)===O.socket,hadViewer:!!i.current,intentionalDisconnect:f.current,userDisconnectedShellId:g.current,shellId:W,hasAttachTimeout:G!==null});Sx({closeApplication:H,shellId:W,attachTimeoutRef:m,socketRef:l,reconnectTimerRef:h,setViewerId:w,setIsConnecting:C,settleAttachPromise:_,onShellUpdate:Y,setReconnectKey:v})}),()=>{const G=Ax(i),H=Cx({shellId:W,viewerId:G,shellSocket:O,attachRetryTimerRef:u,attachTimeoutRef:m,socketRef:l,openReadyState:WebSocket.OPEN});Tx({cleanupAction:H,shellSocket:O,attachRetryTimerRef:u,attachTimeoutRef:m,socketRef:l,intentionalDisconnectRef:f,setViewerId:w,setIsConnecting:C,settleAttachPromise:_})}},[u,m,n,f,p,b,Y,j,s,h,N,R,C,v,E,w,_,re,W,r,d,x,k,l,y,a,o,g,i])}function $n(e){return e.current}var Js=c.forwardRef(function({paneId:r,shell:n,isActive:a,isVisible:s,isMobileShell:o,effectiveTheme:l,workspacePathMissing:i,shellAdapter:d,onActivate:h,onShellUpdate:m,onRuntimeStateChange:u,onFeedback:p},f){const g=c.useRef(null),x=c.useRef(null),j=c.useRef(null),b=c.useRef(null),k=c.useRef(null),y=c.useRef(null),v=c.useRef(null),w=c.useRef(null),C=c.useRef(!1),N=c.useRef(null),E=c.useRef(""),R=c.useRef(null),_=c.useRef(""),Y=c.useRef(null),W=c.useRef(null),re=c.useRef({cursorX:void 0,cursorY:void 0,paneHeight:void 0}),F=c.useRef(!1),A=c.useRef(null),J=c.useRef(s),Z=c.useRef(o),M=c.useRef(()=>!1),ie=c.useRef(()=>null),O=c.useRef(()=>{}),G=c.useRef(fx({clearTimeout:window.clearTimeout})),[H,T]=c.useState(null),[$,D]=c.useState(!1),[L,S]=c.useState(null),[U,B]=c.useState(!1),[le,K]=c.useState(null),[de,ee]=c.useState(null),[ve,be]=c.useState(!1),[ye,we]=c.useState(0),fe=(n==null?void 0:n.status)??"not_created",Te=gx({shell:n,workspacePathMissing:i}),oe=c.useMemo(()=>Na(fn(n==null?void 0:n.cwd),null),[n==null?void 0:n.cwd]),Q=de??oe,me=c.useCallback(X=>{b.current=X,S(X)},[]),ke=c.useCallback(X=>{G.current.settle(X)},[]);c.useEffect(()=>{J.current=s},[s]),c.useEffect(()=>{Z.current=o},[o]),c.useEffect(()=>{k.current=(n==null?void 0:n.id)??null},[n==null?void 0:n.id]);const Ne=c.useCallback(X=>{const he=j.current,Ce=k.current,I=b.current;return!he||!Ce||!I?!1:(he.send({type:"shell.input",shellId:Ce,viewerId:I,data:X}),!0)},[]);c.useEffect(()=>{M.current=Ne},[Ne]);const Ae=c.useCallback(()=>{const X=j.current,he=k.current,Ce=b.current;return!X||!he||!Ce?!1:(X.send({type:"shell.clear",shellId:he,viewerId:Ce}),!0)},[]),Ge=c.useCallback(()=>{if(!s||!H)return!1;const X=H.getBoundingClientRect();return X.width>0&&X.height>0},[s,H]),Me=c.useCallback(X=>{const he=g.current,Ce=x.current;if(!he||!Ce||!Ge()||(Ce.fit(),he.cols<=0||he.rows<=0))return null;const I={cols:he.cols,rows:he.rows},V=hx({size:I,previousSize:W.current,shellId:k.current,viewerId:b.current,syncBackendSize:(X==null?void 0:X.syncBackendSize)!==!1});return(X==null?void 0:X.syncBackendSize)===!1||(W.current=V.nextLastSentSize,!V.message)||j.current&&j.current.send(V.message),I},[Ge]);c.useEffect(()=>{ie.current=Me},[Me]);const Fe=c.useCallback(X=>{const he=g.current;!he||!Ge()||(Me((X==null?void 0:X.syncBackendSize)===void 0?void 0:{syncBackendSize:X.syncBackendSize}),E.current&&!Ys(H)?Xl(he,E.current,re.current.cursorX,re.current.cursorY,re.current.paneHeight):he.scrollToBottom(),X!=null&&X.focus&&!o&&he.focus())},[o,Ge,Me,H]);return c.useEffect(()=>{O.current=()=>Fe()},[Fe]),c.useEffect(()=>{u({status:L?"attached":fe,shellInputEnabled:!!(L&&n),isConnecting:U,isCommandRunning:ve,promptLabel:Q,error:le,hasShell:!!n})},[le,U,ve,u,Q,n,fe,L]),c.useEffect(()=>{if(!H||g.current||F.current)return;let X=!1;return F.current=!0,(async()=>{const[{Terminal:he},{FitAddon:Ce}]=await Promise.all([Be(()=>import("./terminal-vendor-C5bTa-Ka.js").then(ae=>ae.x),__vite__mapDeps([17,2,18])),Be(()=>import("./terminal-vendor-C5bTa-Ka.js").then(ae=>ae.a),__vite__mapDeps([17,2,18]))]);if(X||!H){F.current=!1;return}const I=new he({cursorBlink:!0,disableStdin:Z.current,fontFamily:"IBM Plex Mono, SFMono-Regular, Menlo, monospace",fontSize:13,lineHeight:1.25,scrollback:3e3,theme:qs(l)}),V=new Ce;I.loadAddon(V),I.open(H),g.current=I,x.current=V,ie.current(),I.attachCustomKeyEventHandler(ae=>{if(Z.current||ae.type!=="keydown")return!0;if(ae.ctrlKey&&!ae.altKey&&!ae.metaKey&&!ae.shiftKey){const ge=Fg(ae.key);if(!ge)return!0;if(M.current(ge))return ae.preventDefault(),!1}return!0}),D(!0),F.current=!1,Y.current=new ResizeObserver(()=>{O.current()}),Y.current.observe(H),A.current=I.onData(ae=>{Z.current||M.current(ae)})})(),()=>{var he,Ce,I;X=!0,F.current=!1,(he=A.current)==null||he.dispose(),A.current=null,(Ce=Y.current)==null||Ce.disconnect(),Y.current=null,D(!1),(I=g.current)==null||I.dispose(),g.current=null,x.current=null,W.current=null}},[l,H]),c.useEffect(()=>{var he;const X=lx({hasShell:!!n});X&&(me(X.viewerId),B(X.isConnecting),ke(X.settleAttachPromise),K(X.connectionError),ee(X.runtimePromptLabel),be(X.isCommandRunning),E.current=X.shellSnapshot,_.current=X.lastCommandOutput,R.current=X.pendingCommand,X.shouldResetTerminal&&((he=g.current)==null||he.reset()))},[me,ke,n]),c.useEffect(()=>{const X=g.current;X&&(X.options.theme=qs(l))},[l]),c.useEffect(()=>{const X=g.current;X&&(X.options.disableStdin=o)},[o]),c.useEffect(()=>{if(!s||!$)return;const X=window.requestAnimationFrame(()=>{Fe({focus:a,syncBackendSize:!1}),!j.current&&(n!=null&&n.id)&&N.current!==n.id&&we(he=>he+1)});return()=>{window.cancelAnimationFrame(X)}},[a,s,Fe,n==null?void 0:n.id,$]),$x({shell:n,shellAdapter:d,canAttachShell:Te,terminalReady:$,reconnectKey:ye,terminalRef:g,socketRef:j,viewerIdRef:b,shellIdRef:k,reconnectTimerRef:y,attachTimeoutRef:v,attachRetryTimerRef:w,isVisibleRef:J,intentionalDisconnectRef:C,userDisconnectedShellIdRef:N,shellSnapshotRef:E,pendingCommandRef:R,lastCommandOutputRef:_,snapshotCursorRef:re,syncTerminalSizeRef:ie,setReconnectKey:we,setViewerId:me,setIsConnecting:B,setConnectionError:K,setRuntimePromptLabel:ee,setIsCommandRunning:be,settleAttachPromise:ke,onShellUpdate:m}),c.useEffect(()=>()=>{const X=$n(y),he=$n(v),Ce=$n(w),I=ix({hasReconnectTimer:X!==null,hasAttachTimeout:he!==null,hasAttachRetry:Ce!==null});I.shouldClearReconnectTimer&&X!==null&&window.clearTimeout(X),I.shouldClearAttachTimeout&&he!==null&&window.clearTimeout(he),I.shouldClearAttachRetry&&Ce!==null&&window.clearTimeout(Ce),ke(I.settleAttachPromise)},[ke]),c.useImperativeHandle(f,()=>({disconnect(){const X=j.current,he=k.current,Ce=b.current,I=dx({shellId:he,viewerId:Ce,hasSocket:!!X});N.current=I.userDisconnectedShellId,C.current=I.intentionalDisconnect,X&&I.detachMessage&&X.send(I.detachMessage),me(null),B(!1),ke(!1),I.shouldCloseSocket&&(X==null||X.socket.close()),j.current=null,W.current=null,I.shouldDetachShell&&he&&m(he,V=>({...V,status:"detached",attachedViewerId:null}),"detached")},reconnect(){const X=sx({hasShellId:!!k.current,terminalReady:$,workspacePathMissing:i,hasViewer:!!b.current,hasPendingAttach:G.current.hasPending()});if(X.type==="reject")return Promise.resolve(!1);if(X.type==="alreadyConnected")return Promise.resolve(!0);if(X.type==="joinPending")return G.current.joinPending();const he=G.current.start({timeoutMs:Jg,setTimeout:window.setTimeout,onTimeout:()=>{B(!1)}}),Ce=ox({shellId:k.current,userDisconnectedShellId:N.current});return Ce.shouldClearUserDisconnectedShellId&&(N.current=null),C.current=Ce.intentionalDisconnect,K(Ce.connectionError),B(Ce.isConnecting),we(I=>I+1),he},sendInput(X){return Ne(X)},sendCommand(X){const he={command:X,beforeSnapshot:E.current};if(R.current=he,X.trim()==="clear"){const V=Ae();return!V&&R.current===he&&(R.current=null),V}const Ce=X.endsWith(`
|
|
3969
|
+
`);if(n!==void 0&&a!==void 0){const m=(s!==void 0?Math.max(0,l.length-s):0)+a,u=Math.max(0,l.length-m-1);u>0&&(d+=`\x1B[${u}A`),d+=`\r\x1B[${n+1}G`}e.reset(),e.write(d,()=>{e.scrollToBottom()})}function Qs(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(`
|
|
3970
|
+
`).trimEnd():""}function vx({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 eo={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 kx({shell:e,workspacePathMissing:r}){return!!(e&&!r&&vt(e))}function wx(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 yx(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 jx({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 Nx({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?Ta(gn(r.cwd),null):null),isMobileShell:s,hasShell:!!r,busy:o,loading:l,error:e.error??i}}function Vt(e){return e.current===null?!1:(window.clearTimeout(e.current),e.current=null,!0)}function Cx({attachRetryTimerRef:e,setReconnectKey:r,delayMs:n=Qg}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function Sx({reconnectTimerRef:e,setReconnectKey:r,delayMs:n=ex}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function Tx({shellSocket:e,socketRef:r,viewerIdRef:n,attachTimeoutRef:a,setConnectionError:s,setIsConnecting:o,settleAttachPromise:l,delayMs:i=tx}){a.current=window.setTimeout(()=>{var h,m,u;a.current=null;const d=ax({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&&((m=e.close)==null||m.call(e),(u=e.socket)==null||u.close()))},i)}function Ex(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 px({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 m=e.closeAction;return m?(e.shouldClearAttachTimeout&&Vt(n),e.shouldClearSocketRef&&(a.current=null),o(e.viewerId),l(e.isConnecting),i(e.settleAttachPromise),m.shouldDetachShell&&d(r,Ex,"detached"),m.shouldScheduleReconnect&&Sx({reconnectTimerRef:s,setReconnectKey:h}),!0):!1}function zx({cleanupAction:e,shellSocket:r,attachRetryTimerRef:n,attachTimeoutRef:a,socketRef:s,intentionalDisconnectRef:o,setViewerId:l,setIsConnecting:i,settleAttachPromise:d}){o.current=e.intentionalDisconnect,e.shouldClearAttachRetry&&Vt(n),e.shouldSendDetachMessage&&e.detachMessage&&r.send(e.detachMessage),l(null),i(e.isConnecting),e.settleAttachPromise!==void 0&&d(e.settleAttachPromise),e.shouldClearAttachTimeout&&Vt(a),r.socket.close(),e.shouldClearSocketRef&&(s.current=null)}function Px({eventShellId:e,shellId:r,socketExists:n,isCurrentSocket:a}){return n&&!a?!1:e===r}function Rx(e){return Kl({...e,attachSize:void 0})}function Ax({attachSize:e,...r}){return Kl({...r,attachSize:e})}function _x({isCurrentSocket:e,shellId:r,attachSize:n,hasAttachTimeout:a}){const s=sx({isCurrentSocket:e,shellId:r,attachSize:n});return{openAction:s,shouldClearAttachTimeout:!!(s&&a)}}function Mx(e){const r=String(e.payload.viewerId??"");return{viewerId:r||null,settleAttachPromise:!!r,nextShell:n=>({...n,status:"attached",attachedViewerId:r})}}function $x({event:e,shellCwd:r,currentSnapshot:n,pendingCommand:a}){const s=gx(e.payload,r),o=s.data?xx({currentSnapshot:n,data:s.data,replace:s.replace,isCommandRunning:s.isCommandRunning,pendingCommand:a}):null;return{output:s,snapshotUpdate:o}}function Dx({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:s,hasAttachTimeout:o}){const l=lx({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 Bx(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 Gx(e){return e.current}function Fx({shell:e,shellAdapter:r,canAttachShell:n,terminalReady:a,reconnectKey:s,terminalRef:o,socketRef:l,viewerIdRef:i,shellIdRef:d,reconnectTimerRef:h,attachTimeoutRef:m,attachRetryTimerRef:u,isVisibleRef:p,intentionalDisconnectRef:f,userDisconnectedShellIdRef:g,shellSnapshotRef:b,pendingCommandRef:j,lastCommandOutputRef:x,snapshotCursorRef:k,syncTerminalSizeRef:w,setReconnectKey:v,setViewerId:y,setIsConnecting:N,setConnectionError:S,setRuntimePromptLabel:T,setIsCommandRunning:M,settleAttachPromise:A,onShellUpdate:J}){const W=e==null?void 0:e.id,re=e==null?void 0:e.cwd;c.useEffect(()=>{const O=o.current,P={shellId:W??null,terminalReady:a,isVisible:p.current,canAttachShell:n,userDisconnectedShellId:g.current,hasTerminal:!!O,hasPendingAttachRetry:u.current!==null,hasCurrentSocketForShell:!!(l.current&&d.current===W),hasReconnectTimer:h.current!==null};if(Rx(P).type==="skip")return;const Z=w.current(),_=Ax({...P,attachSize:Z});if(_.type==="skip"||_.type==="measureSize")return;if(_.type==="scheduleRetry"){Cx({attachRetryTimerRef:u,setReconnectKey:v});return}if(_.shouldClearAttachRetry&&Vt(u),_.type==="reuseSocket"||(_.shouldClearReconnectTimer&&Vt(h),!W||!O))return;const ie=_.attachSize;d.current=W,O.reset(),S(null),y(null),N(!0),f.current=!1;const H=r.connectSocket({onConnected:()=>{var D;const B=m.current,F=_x({isCurrentSocket:((D=l.current)==null?void 0:D.socket)===H.socket,shellId:W,attachSize:ie,hasAttachTimeout:B!==null}),E=F.openAction;E&&(H.send(E.message),F.shouldClearAttachTimeout&&B!==null&&Vt(m),E.shouldScheduleAttachTimeout&&Tx({shellSocket:H,socketRef:l,viewerIdRef:i,attachTimeoutRef:m,setConnectionError:S,setIsConnecting:N,settleAttachPromise:A}))},onShellEvent:B=>{var D;if(!Px({eventShellId:B.shellId,shellId:W,socketExists:!!H.socket,isCurrentSocket:((D=l.current)==null?void 0:D.socket)===H.socket}))return;if(B.type==="shell.connected"){Vt(m);const $=Mx(B);y($.viewerId),N(!1),A($.settleAttachPromise),J(W,$.nextShell,"attached");return}if(B.type==="shell.output"){const{output:$,snapshotUpdate:L}=$x({event:B,shellCwd:re,currentSnapshot:b.current,pendingCommand:j.current});k.current={cursorX:$.cursorX,cursorY:$.cursorY,paneHeight:$.paneHeight},T($.promptLabel),M($.isCommandRunning),L&&(b.current=L.nextSnapshot,j.current=L.nextPendingCommand,L.lastCommandOutput!==null&&(x.current=L.lastCommandOutput),$.replace?Zl(O,$.data,$.cursorX,$.cursorY,$.paneHeight):O.write($.data));return}const E=bx({event:B,currentViewerId:i.current});E&&(E.viewerId!==void 0&&y(E.viewerId),E.isConnecting!==void 0&&N(E.isConnecting),E.settleAttachPromise!==void 0&&A(E.settleAttachPromise),E.isCommandRunning!==void 0&&M(E.isCommandRunning),E.connectionError!==void 0&&S(E.connectionError),E.intentionalDisconnect!==void 0&&(f.current=E.intentionalDisconnect),E.shellUpdate&&J(W,$=>Bx($,E),E.shellUpdate.status),E.closeSocket&&H.socket.close())}});return l.current=H,H.socket.addEventListener("close",()=>{var E;const B=m.current,F=Dx({isCurrentSocket:((E=l.current)==null?void 0:E.socket)===H.socket,hadViewer:!!i.current,intentionalDisconnect:f.current,userDisconnectedShellId:g.current,shellId:W,hasAttachTimeout:B!==null});Ix({closeApplication:F,shellId:W,attachTimeoutRef:m,socketRef:l,reconnectTimerRef:h,setViewerId:y,setIsConnecting:N,settleAttachPromise:A,onShellUpdate:J,setReconnectKey:v})}),()=>{const B=Gx(i),F=Lx({shellId:W,viewerId:B,shellSocket:H,attachRetryTimerRef:u,attachTimeoutRef:m,socketRef:l,openReadyState:WebSocket.OPEN});zx({cleanupAction:F,shellSocket:H,attachRetryTimerRef:u,attachTimeoutRef:m,socketRef:l,intentionalDisconnectRef:f,setViewerId:y,setIsConnecting:N,settleAttachPromise:A})}},[u,m,n,f,p,x,J,j,s,h,S,M,N,v,T,y,A,re,W,r,d,b,k,l,w,a,o,g,i])}function Gn(e){return e.current}var to=c.forwardRef(function({paneId:r,shell:n,isActive:a,isVisible:s,isMobileShell:o,effectiveTheme:l,workspacePathMissing:i,shellAdapter:d,onActivate:h,onShellUpdate:m,onRuntimeStateChange:u,onFeedback:p},f){const g=c.useRef(null),b=c.useRef(null),j=c.useRef(null),x=c.useRef(null),k=c.useRef(null),w=c.useRef(null),v=c.useRef(null),y=c.useRef(null),N=c.useRef(!1),S=c.useRef(null),T=c.useRef(""),M=c.useRef(null),A=c.useRef(""),J=c.useRef(null),W=c.useRef(null),re=c.useRef({cursorX:void 0,cursorY:void 0,paneHeight:void 0}),O=c.useRef(!1),P=c.useRef(null),Y=c.useRef(s),Z=c.useRef(o),_=c.useRef(()=>!1),ie=c.useRef(()=>null),H=c.useRef(()=>{}),B=c.useRef(vx({clearTimeout:window.clearTimeout})),[F,E]=c.useState(null),[D,$]=c.useState(!1),[L,C]=c.useState(null),[U,G]=c.useState(!1),[le,ee]=c.useState(null),[ce,q]=c.useState(null),[ve,ke]=c.useState(!1),[je,ye]=c.useState(0),fe=(n==null?void 0:n.status)??"not_created",Te=kx({shell:n,workspacePathMissing:i}),oe=c.useMemo(()=>Ta(gn(n==null?void 0:n.cwd),null),[n==null?void 0:n.cwd]),Q=ce??oe,me=c.useCallback(X=>{x.current=X,C(X)},[]),we=c.useCallback(X=>{B.current.settle(X)},[]);c.useEffect(()=>{Y.current=s},[s]),c.useEffect(()=>{Z.current=o},[o]),c.useEffect(()=>{k.current=(n==null?void 0:n.id)??null},[n==null?void 0:n.id]);const Ce=c.useCallback(X=>{const he=j.current,Se=k.current,I=x.current;return!he||!Se||!I?!1:(he.send({type:"shell.input",shellId:Se,viewerId:I,data:X}),!0)},[]);c.useEffect(()=>{_.current=Ce},[Ce]);const Me=c.useCallback(()=>{const X=j.current,he=k.current,Se=x.current;return!X||!he||!Se?!1:(X.send({type:"shell.clear",shellId:he,viewerId:Se}),!0)},[]),Be=c.useCallback(()=>{if(!s||!F)return!1;const X=F.getBoundingClientRect();return X.width>0&&X.height>0},[s,F]),Ae=c.useCallback(X=>{const he=g.current,Se=b.current;if(!he||!Se||!Be()||(Se.fit(),he.cols<=0||he.rows<=0))return null;const I={cols:he.cols,rows:he.rows},V=fx({size:I,previousSize:W.current,shellId:k.current,viewerId:x.current,syncBackendSize:(X==null?void 0:X.syncBackendSize)!==!1});return(X==null?void 0:X.syncBackendSize)===!1||(W.current=V.nextLastSentSize,!V.message)||j.current&&j.current.send(V.message),I},[Be]);c.useEffect(()=>{ie.current=Ae},[Ae]);const He=c.useCallback(X=>{const he=g.current;!he||!Be()||(Ae((X==null?void 0:X.syncBackendSize)===void 0?void 0:{syncBackendSize:X.syncBackendSize}),T.current&&!Qs(F)?Zl(he,T.current,re.current.cursorX,re.current.cursorY,re.current.paneHeight):he.scrollToBottom(),X!=null&&X.focus&&!o&&he.focus())},[o,Be,Ae,F]);return c.useEffect(()=>{H.current=()=>He()},[He]),c.useEffect(()=>{u({status:L?"attached":fe,shellInputEnabled:!!(L&&n),isConnecting:U,isCommandRunning:ve,promptLabel:Q,error:le,hasShell:!!n})},[le,U,ve,u,Q,n,fe,L]),c.useEffect(()=>{if(!F||g.current||O.current)return;let X=!1;return O.current=!0,(async()=>{const[{Terminal:he},{FitAddon:Se}]=await Promise.all([De(()=>import("./terminal-vendor-C5bTa-Ka.js").then(se=>se.x),__vite__mapDeps([17,2,18])),De(()=>import("./terminal-vendor-C5bTa-Ka.js").then(se=>se.a),__vite__mapDeps([17,2,18]))]);if(X||!F){O.current=!1;return}const I=new he({cursorBlink:!0,disableStdin:Z.current,fontFamily:"IBM Plex Mono, SFMono-Regular, Menlo, monospace",fontSize:13,lineHeight:1.25,scrollback:3e3,theme:Zs(l)}),V=new Se;I.loadAddon(V),I.open(F),g.current=I,b.current=V,ie.current(),I.attachCustomKeyEventHandler(se=>{if(Z.current||se.type!=="keydown")return!0;if(se.ctrlKey&&!se.altKey&&!se.metaKey&&!se.shiftKey){const ge=Vg(se.key);if(!ge)return!0;if(_.current(ge))return se.preventDefault(),!1}return!0}),$(!0),O.current=!1,J.current=new ResizeObserver(()=>{H.current()}),J.current.observe(F),P.current=I.onData(se=>{Z.current||_.current(se)})})(),()=>{var he,Se,I;X=!0,O.current=!1,(he=P.current)==null||he.dispose(),P.current=null,(Se=J.current)==null||Se.disconnect(),J.current=null,$(!1),(I=g.current)==null||I.dispose(),g.current=null,b.current=null,W.current=null}},[l,F]),c.useEffect(()=>{var he;const X=hx({hasShell:!!n});X&&(me(X.viewerId),G(X.isConnecting),we(X.settleAttachPromise),ee(X.connectionError),q(X.runtimePromptLabel),ke(X.isCommandRunning),T.current=X.shellSnapshot,A.current=X.lastCommandOutput,M.current=X.pendingCommand,X.shouldResetTerminal&&((he=g.current)==null||he.reset()))},[me,we,n]),c.useEffect(()=>{const X=g.current;X&&(X.options.theme=Zs(l))},[l]),c.useEffect(()=>{const X=g.current;X&&(X.options.disableStdin=o)},[o]),c.useEffect(()=>{if(!s||!D)return;const X=window.requestAnimationFrame(()=>{He({focus:a,syncBackendSize:!1}),!j.current&&(n!=null&&n.id)&&S.current!==n.id&&ye(he=>he+1)});return()=>{window.cancelAnimationFrame(X)}},[a,s,He,n==null?void 0:n.id,D]),Fx({shell:n,shellAdapter:d,canAttachShell:Te,terminalReady:D,reconnectKey:je,terminalRef:g,socketRef:j,viewerIdRef:x,shellIdRef:k,reconnectTimerRef:w,attachTimeoutRef:v,attachRetryTimerRef:y,isVisibleRef:Y,intentionalDisconnectRef:N,userDisconnectedShellIdRef:S,shellSnapshotRef:T,pendingCommandRef:M,lastCommandOutputRef:A,snapshotCursorRef:re,syncTerminalSizeRef:ie,setReconnectKey:ye,setViewerId:me,setIsConnecting:G,setConnectionError:ee,setRuntimePromptLabel:q,setIsCommandRunning:ke,settleAttachPromise:we,onShellUpdate:m}),c.useEffect(()=>()=>{const X=Gn(w),he=Gn(v),Se=Gn(y),I=ux({hasReconnectTimer:X!==null,hasAttachTimeout:he!==null,hasAttachRetry:Se!==null});I.shouldClearReconnectTimer&&X!==null&&window.clearTimeout(X),I.shouldClearAttachTimeout&&he!==null&&window.clearTimeout(he),I.shouldClearAttachRetry&&Se!==null&&window.clearTimeout(Se),we(I.settleAttachPromise)},[we]),c.useImperativeHandle(f,()=>({disconnect(){const X=j.current,he=k.current,Se=x.current,I=mx({shellId:he,viewerId:Se,hasSocket:!!X});S.current=I.userDisconnectedShellId,N.current=I.intentionalDisconnect,X&&I.detachMessage&&X.send(I.detachMessage),me(null),G(!1),we(!1),I.shouldCloseSocket&&(X==null||X.socket.close()),j.current=null,W.current=null,I.shouldDetachShell&&he&&m(he,V=>({...V,status:"detached",attachedViewerId:null}),"detached")},reconnect(){const X=dx({hasShellId:!!k.current,terminalReady:D,workspacePathMissing:i,hasViewer:!!x.current,hasPendingAttach:B.current.hasPending()});if(X.type==="reject")return Promise.resolve(!1);if(X.type==="alreadyConnected")return Promise.resolve(!0);if(X.type==="joinPending")return B.current.joinPending();const he=B.current.start({timeoutMs:rx,setTimeout:window.setTimeout,onTimeout:()=>{G(!1)}}),Se=cx({shellId:k.current,userDisconnectedShellId:S.current});return Se.shouldClearUserDisconnectedShellId&&(S.current=null),N.current=Se.intentionalDisconnect,ee(Se.connectionError),G(Se.isConnecting),ye(I=>I+1),he},sendInput(X){return Ce(X)},sendCommand(X){const he={command:X,beforeSnapshot:T.current};if(M.current=he,X.trim()==="clear"){const V=Me();return!V&&M.current===he&&(M.current=null),V}const Se=X.endsWith(`
|
|
3971
3971
|
`)?X:`${X}
|
|
3972
|
-
`,I=Ne(Ce);return!I&&R.current===he&&(R.current=null),I},sendControl(X){return X==="clear"?Ae():Ne(Vg(X))},async copyLastCommandOutput(){const X=_.current.trim()||Ys(H);if(!X)return p==null||p("failed","Nothing to copy"),!1;try{return await navigator.clipboard.writeText(X),p==null||p("done","Copied"),!0}catch{return p==null||p("failed","Copy failed"),!1}},focus(){var X;(X=g.current)==null||X.focus()},refreshLayout(X){Fe(X)}}),[p,m,Fe,Ae,Ne,me,ke,H,$,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 X;h(),(X=g.current)==null||X.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"})]})}),Dx=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},m){const u=c.useRef(null),p=c.useRef(null),f=c.useRef(null),g=c.useRef(null),x=c.useRef(null),j=c.useRef(!1),[b,k]=c.useState(null),[y,v]=c.useState(!0),[w,C]=c.useState(!1),[N,E]=c.useState(null),[R,_]=c.useState("primary"),[Y,W]=c.useState(null),[re,F]=c.useState(null),[A,J]=c.useState("single"),[Z,M]=c.useState(50),[ie,O]=c.useState(null),[G,H]=c.useState(""),[T,$]=c.useState(!1),[D,L]=c.useState(!1),[S,U]=c.useState(!1),[B,le]=c.useState({primary:Zs,secondary:Zs}),[K,de]=c.useState(null),ee=(b==null?void 0:b.state)??"not_created",ve=c.useMemo(()=>(b==null?void 0:b.shells)??[],[b==null?void 0:b.shells]),be=c.useMemo(()=>ve.filter(wt),[ve]),ye=c.useMemo(()=>be.find(z=>z.id===Y)??null,[be,Y]),we=c.useMemo(()=>be.find(z=>z.id===re)??null,[be,re]),fe=R==="secondary"?we:ye,Te=B[R],oe=(b==null?void 0:b.workspacePathStatus)==="missing",Q=R==="secondary"?p:u,me=vx({activeRuntime:Te,activeShell:fe,busy:w,loading:y,status:ee,workspacePathMissing:oe}),ke=me.disabled,Ne=me.label,Ae=me.className,Ge=(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",Me=c.useCallback((z,q)=>{de({tone:z,text:q}),f.current!==null&&window.clearTimeout(f.current),f.current=window.setTimeout(()=>{de(null),f.current=null},1800)},[]),Fe=c.useCallback((z,q,xe)=>{k(Ee=>{var nt;if(!Ee)return Ee;const $e=Ee.shells.map(Ve=>Ve.id===z?q(Ve):Ve),Qe=((nt=Ee.shell)==null?void 0:nt.id)===z?q(Ee.shell):$e.find(Ve=>{var De;return Ve.id===((De=Ee.shell)==null?void 0:De.id)})??Ee.shell;return{...Ee,...xe?{state:xe}:{},shell:Qe,shells:$e}})},[]),X=c.useCallback(async()=>{v(!0);try{const z=await n.fetchState(r);k(z),E(null)}catch(z){E(z instanceof Error?z.message:"Unable to load shell state.")}finally{v(!1)}},[n,r]);c.useEffect(()=>{X()},[X]),c.useEffect(()=>{const z=i==null?void 0:i(r);if(z==null){M(50);return}const q=typeof z=="number"?z:Number.parseFloat(String(z));M(Number.isFinite(q)?Mn(q):50)},[i,r]),c.useEffect(()=>{if(!b){W(null),F(null);return}const z=bx(b);W(q=>q&&b.shells.some(xe=>xe.id===q&&wt(xe))?q:(z==null?void 0:z.id)??null),F(q=>{if(A!=="columns")return null;if(q&&b.shells.some(Ee=>Ee.id===q&&wt(Ee)))return q;const xe=b.shells.find(Ee=>wt(Ee)&&Ee.id!==(z==null?void 0:z.id));return(xe==null?void 0:xe.id)??null})},[b,A]),c.useEffect(()=>{A!=="columns"&&(_("primary"),F(null))},[A]),c.useEffect(()=>{if(A!=="columns"||re||be.length<2)return;const z=be.find(q=>q.id!==(ye==null?void 0:ye.id))??null;z&&F(z.id)},[be,ye==null?void 0:ye.id,re,A]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const z=window.matchMedia("(max-width: 767px), (hover: none) and (pointer: coarse)"),q=()=>{$(z.matches),z.matches||(U(!1),L(!1))};return q(),z.addEventListener("change",q),()=>{z.removeEventListener("change",q)}},[]),c.useEffect(()=>()=>{f.current!==null&&window.clearTimeout(f.current),x.current!==null&&window.cancelAnimationFrame(x.current)},[]);const he=c.useCallback((z,q)=>{le(xe=>{const Ee=xe[z];return xx(Ee,q)?xe:{...xe,[z]:q}})},[]),Ce=c.useCallback(z=>he("primary",z),[he]),I=c.useCallback(z=>he("secondary",z),[he]),V=c.useCallback(z=>{var xe;if((xe=z.label)!=null&&xe.trim())return z.label.trim();const q=ve.findIndex(Ee=>Ee.id===z.id);return`Shell ${q>=0?q+1:""}`.trim()},[ve]),ae=c.useCallback(z=>{var q;O(z.id),H(((q=z.label)==null?void 0:q.trim())||V(z))},[V]),ge=c.useCallback(()=>{O(null),H("")},[]),je=c.useCallback(async()=>{if(ie){C(!0);try{const z=G.trim(),q=await n.updateShell(ie,{label:z.length>0?z:null});k(xe=>{var Ee;return xe&&{...xe,state:xe.activeShellId===q.id?q.status:xe.state,shell:((Ee=xe.shell)==null?void 0:Ee.id)===q.id?q:xe.shell,shells:xe.shells.map($e=>$e.id===q.id?q:$e)}}),O(null),H(""),E(null)}catch(z){E(z instanceof Error?z.message:"Unable to rename shell.")}finally{C(!1)}}},[G,ie,n]),Ie=c.useCallback((z,q)=>{if(z==="primary"){W(q),F(xe=>xe===q?null:xe);return}F(q),W(xe=>xe===q?null:xe)},[]),ce=c.useCallback(z=>{var q,xe;if(z==="primary"){(q=u.current)==null||q.disconnect(),W(null),A==="columns"&&_("secondary");return}(xe=p.current)==null||xe.disconnect(),F(null),_("primary"),J("single")},[A]),He=c.useCallback((z,q=R)=>{const xe=A==="columns"?q:"primary";Ie(xe,z.id),A!=="columns"&&F(null),_(xe)},[R,Ie,A]),qe=c.useCallback(async(z=R)=>{var q;if(!j.current){j.current=!0,C(!0);try{const xe=await n.createShell(r);k(xe);const Ee=xe.activeShellId??((q=xe.shell)==null?void 0:q.id)??null;if(Ee){const $e=A==="columns"?z:"primary";Ie($e,Ee),A!=="columns"&&F(null),_($e)}E(null)}catch(xe){E(xe instanceof Error?xe.message:"Unable to create shell.")}finally{j.current=!1,C(!1)}}},[R,Ie,n,A,r]);c.useEffect(()=>{!a||!b||y||w||oe||ee==="creating"||be.length>0||qe("primary")},[w,qe,a,be.length,y,b,ee,oe]);const We=c.useCallback(async(z=(fe==null?void 0:fe.id)??"")=>{if(z){C(!0);try{await n.terminateShell(z),W(q=>q===z?null:q),F(q=>q===z?null:q),await X(),E(null)}catch(q){E(q instanceof Error?q.message:"Unable to terminate shell.")}finally{C(!1)}}},[fe==null?void 0:fe.id,X,n]),Ye=c.useCallback(async()=>{var z,q;if(!ke){if(Te.shellInputEnabled){(z=Q.current)==null||z.disconnect();return}if(!fe||fe.status==="exited"||fe.status==="not_found"){await qe(R);return}await((q=Q.current)==null?void 0:q.reconnect())}},[R,Q,Te.shellInputEnabled,fe,ke,qe]),ft=c.useCallback(z=>{typeof window>"u"||d==null||d(r,Mn(z))},[d,r]),rt=c.useCallback(()=>{var z,q;(z=u.current)==null||z.refreshLayout({syncBackendSize:!0}),(q=p.current)==null||q.refreshLayout({syncBackendSize:!0})},[]),ct=c.useCallback(z=>{var Qe,nt;if(A!=="columns")return;const q=g.current;if(!q)return;z.preventDefault(),(nt=(Qe=z.currentTarget).setPointerCapture)==null||nt.call(Qe,z.pointerId);const xe=Ve=>{const De=q.getBoundingClientRect();if(De.width<=0)return;const ht=Mn((Ve-De.left)/De.width*100);M(ht),x.current!==null&&window.cancelAnimationFrame(x.current),x.current=window.requestAnimationFrame(()=>{x.current=null,rt()})},Ee=Ve=>{xe(Ve.clientX)},$e=Ve=>{xe(Ve.clientX);const De=q.getBoundingClientRect();De.width>0&&ft((Ve.clientX-De.left)/De.width*100),window.removeEventListener("pointermove",Ee),window.removeEventListener("pointerup",$e)};window.addEventListener("pointermove",Ee),window.addEventListener("pointerup",$e,{once:!0})},[ft,rt,A]),Ze=c.useCallback((z,q)=>{Ie(q,z.id),_(q)},[Ie]),pt=c.useCallback(async()=>{var q;return await((q=Q.current)==null?void 0:q.copyLastCommandOutput())?!0:(Me("failed","Nothing to copy"),!1)},[Q,Me]);c.useEffect(()=>{h==null||h(kx({activeRuntime:Te,activeShell:fe,connectionButtonDisabled:ke,connectionButtonLabel:Ne,isMobileShell:T,busy:w,loading:y,error:N}))},[Te,fe,w,ke,Ne,N,T,y,h]),c.useImperativeHandle(m,()=>({async toggleConnection(){await Ye()},sendInput(z){var q;return((q=Q.current)==null?void 0:q.sendInput(z))??!1},sendCommand(z){var q;return((q=Q.current)==null?void 0:q.sendCommand(z))??!1},sendControl(z){var q;return((q=Q.current)==null?void 0:q.sendControl(z))??!1},async copyLastCommandOutput(){var z;return await((z=Q.current)==null?void 0:z.copyLastCommandOutput())??!1},async terminate(){await We()},focus(){var z;(z=Q.current)==null||z.focus()},refreshLayout(z){var q,xe;(q=u.current)==null||q.refreshLayout(z),A==="columns"&&((xe=p.current)==null||xe.refreshLayout(z))}}),[Q,Ye,We,A]);const ot=z=>t.jsx("div",{className:`rounded-md border px-2 py-1.5 text-xs ${z.id===(fe==null?void 0:fe.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===z.id?t.jsx("form",{className:"min-w-0 flex-1",onSubmit:q=>{q.preventDefault(),je()},children:t.jsx("input",{value:G,onChange:q=>H(q.currentTarget.value),onKeyDown:q=>{q.key==="Escape"&&(q.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:()=>He(z),onDoubleClick:()=>ae(z),className:"min-w-0 flex-1 text-left",title:z.tmuxSessionName,children:[t.jsx("span",{className:"block truncate",children:V(z)}),t.jsxs("span",{className:"block truncate text-[10px] text-[var(--theme-fg-muted)]",children:[_n(z.status)," · ",fn(z.cwd)||z.cwd]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[ie===z.id?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>void je(),className:"rounded border border-sky-300/35 bg-sky-300/12 px-1.5 py-1 text-[10px] text-sky-50",title:"Save shell name",children:"Save"}),t.jsx("button",{type:"button",onClick: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:()=>ae(z),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Rename shell",children:"Rename"}),A==="columns"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>Ze(z,"primary"),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Open in left pane",children:"L"}),t.jsx("button",{type:"button",onClick:()=>Ze(z,"secondary"),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Open in right pane",children:"R"})]}),t.jsx("button",{type:"button",disabled:w,onClick:()=>void We(z.id),className:"rounded border border-rose-300/35 bg-rose-300/12 px-1.5 py-1 text-[10px] text-rose-100 disabled:cursor-not-allowed disabled:opacity-50",title:"Kill shell process",children:"Kill"})]})]})},z.id);return t.jsxs("div",{className:"shell-panel flex min-h-0 flex-1 flex-col",children:[s&&t.jsxs("div",{className:"shell-header shrink-0 border-b px-3 py-3 sm:px-5",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs uppercase tracking-[0.24em] text-[var(--theme-fg-muted)]",children:"Shell"}),t.jsx("p",{className:"mt-1 truncate text-sm text-[var(--theme-fg-soft)]",children:Te.promptLabel??(fe==null?void 0:fe.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":Ne,title:`${Ne} (${_n(Te.status)})`,disabled:ke,onClick:()=>void Ye(),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 ${Ae}`,children:t.jsx(qg,{connected:Te.shellInputEnabled})}),fe&&t.jsx("button",{type:"button",disabled:w,onClick:()=>void We(fe.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||oe)&&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&&oe&&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:fe?V(fe):"No live shell process"}),fe&&t.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.12em] text-[var(--theme-fg-muted)]",children:_n(Te.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 ",be.length]}),t.jsx("button",{type:"button","aria-expanded":D,"aria-label":D?"Hide shell processes":"Show shell processes",onClick:()=>L(z=>!z),className:"rounded-md border border-stone-700/80 bg-stone-900/50 px-2.5 py-1.5 text-xs text-stone-200 sm:hidden",children:"Processes"})]})]}),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:[be.length," live"]})]}),t.jsxs("div",{className:"max-h-52 space-y-1 overflow-y-auto",children:[be.map(ot),be.length===0&&t.jsx("p",{className:"px-2 py-3 text-xs text-[var(--theme-fg-muted)]",children:"No live shell processes"})]}),t.jsx("div",{className:"mt-2 flex justify-end border-t border-stone-800/80 pt-2",children:t.jsx("button",{type:"button","aria-label":"New shell",title:"New shell",disabled:w||y||oe,onClick:()=>void qe(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"||oe?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."}),!oe&&t.jsx("button",{type:"button",disabled:w||y,onClick:()=>void qe("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||oe)&&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&&oe&&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 ${A==="columns"?"grid-cols-1 sm:grid-cols-[var(--shell-left)_0.35rem_var(--shell-right)]":"grid-cols-1"}`,style:A==="columns"?{"--shell-left":`${Z}fr`,"--shell-right":`${100-Z}fr`}:void 0,"data-shell-split-ratio":Z,children:[t.jsx(Js,{ref:u,paneId:"primary",shell:ye,isActive:R==="primary",isVisible:a,isMobileShell:T,effectiveTheme:l,workspacePathMissing:oe,shellAdapter:n,onActivate:()=>_("primary"),onShellUpdate:Fe,onRuntimeStateChange:Ce,onFeedback:Me}),A==="columns"&&t.jsx("button",{type:"button",onClick:()=>ce("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"}),A==="columns"&&t.jsx("button",{type:"button","aria-label":"Resize shell panes",title:"Resize shell panes",onPointerDown:ct,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"}),A==="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(Js,{ref:p,paneId:"secondary",shell:we,isActive:R==="secondary",isVisible:a,isMobileShell:T,effectiveTheme:l,workspacePathMissing:oe,shellAdapter:n,onActivate:()=>_("secondary"),onShellUpdate:Fe,onRuntimeStateChange:I,onFeedback:Me}),t.jsx("button",{type:"button",onClick:()=>ce("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 ${Ge}`,children:K.text}),S&&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:()=>{Me("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(Ks,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:()=>void pt(),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(Ks,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:!Te.shellInputEnabled,onClick:()=>{var z;(z=Q.current)!=null&&z.sendControl("clear")?Me("done","Cleared"):Me("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(An,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!Te.shellInputEnabled||!Te.isCommandRunning,onClick:()=>{var z;(z=Q.current)!=null&&z.sendInput("")?Me("done","Sent Ctrl-C"):Me("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(An,{label:"CTRL-C",tone:"rose"})}),["ctrl_d","esc","tab","up","down"].map(z=>t.jsx("button",{type:"button",disabled:!Te.shellInputEnabled,onClick:()=>{var q;(q=Q.current)!=null&&q.sendControl(z)?Me("done",`Sent ${z.toUpperCase().replace("_","-")}`):Me("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(An,{label:z.toUpperCase().replace("_","-"),tone:"stone"})},z))]})}),t.jsx("button",{type:"button","aria-expanded":S,"aria-label":S?"Close shell tools":"Open shell tools",onClick:()=>U(z=>!z),className:"shell-toolbox-trigger pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-2xl backdrop-blur transition",children:t.jsx(Xg,{})})]})]}),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:[be.length," live"]})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-1 overflow-y-auto",children:[be.map(ot),be.length===0&&t.jsx("p",{className:"px-2 py-3 text-xs text-[var(--theme-fg-muted)]",children:"No live shell processes"})]}),t.jsx("div",{className:"mt-2 flex justify-end border-t border-stone-800/80 pt-2",children:t.jsx("button",{type:"button","aria-label":"New shell",title:"New shell",disabled:w||y||oe,onClick:()=>void qe(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:"+"})})]})]})]})})]})}),Bx=c.lazy(async()=>({default:(await Promise.resolve().then(()=>(Gu(),wl))).ThreadGraphWorkspacePanel}));function Gx(){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 ql(e){return t.jsx(c.Suspense,{fallback:t.jsx(Gx,{}),children:t.jsx(Bx,{...e})})}c.memo(ql);function gb({open:e,title:r,description:n,confirmLabel:a="Delete",busyLabel:s="Deleting...",busy:o=!1,onCancel:l,onConfirm:i}){return c.useEffect(()=>{if(!e)return;function d(h){h.key==="Escape"&&!o&&l()}return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d)}},[o,l,e]),e?Lr.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:l,disabled:o,className:"absolute inset-0 bg-stone-950/78 backdrop-blur-sm disabled:cursor-not-allowed"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":r,className:"relative z-[1] w-full max-w-md rounded-[1.6rem] border border-stone-700 bg-stone-900 p-5 shadow-2xl shadow-stone-950/40 sm:p-6",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium text-stone-100",children:r}),t.jsx("p",{className:"mt-2 text-sm leading-6 text-stone-400",children:n})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:l,disabled:o,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-stone-700 text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsxs("div",{className:"mt-5 flex items-center justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:l,disabled:o,className:"rounded-full border border-stone-700 px-4 py-2 text-sm font-medium text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),t.jsx("button",{type:"button",onClick:()=>void i(),disabled:o,className:"ui-action-danger rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:o?s:a})]})]})]}),document.body):null}function Hx(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 Fx(e){switch(e){case"inProgress":return"running";case"completed":return"completed";case"interrupted":return"interrupted";case"failed":return"failed"}}function Ox(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 Ux(e){return e==="read"?"View only":"Collaborator"}function Vx(e){switch(e){case"write":return"Workspace write";case"read":return"Workspace read";case"none":default:return"No workspace"}}function xb({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:m,onRevokeShare:u,onOpenDeviceSharing:p}){var $,D,L;const f=c.useMemo(()=>{var S;return((S=n.data)==null?void 0:S.turns)??[]},[($=n.data)==null?void 0:$.turns]),[g,x]=c.useState(l),[j,b]=c.useState("latest-10"),[k,y]=c.useState(()=>new Set),[v,w]=c.useState(!0),[C,N]=c.useState(""),[E,R]=c.useState("read"),[_,Y]=c.useState("none"),[W,re]=c.useState(""),[F,A]=c.useState(()=>typeof document<"u"&&!document.documentElement.classList.contains("dark")?"light":"dark");if(c.useEffect(()=>{e&&(x(l),b("latest-10"),w(!0),N(""),R("read"),Y("none"),re(""),d())},[l,d,e]),c.useEffect(()=>{e&&f.length>0&&y(new Set(f.slice(0,10).map(S=>S.turnId)))},[e,f]),c.useEffect(()=>{if(!e)return;function S(U){U.key==="Escape"&&!r&&i()}return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[r,i,e]),c.useEffect(()=>{if(!e)return;const S=document.querySelector(".thread-ui-shell"),U=()=>S?S.getAttribute("data-theme-effective")==="dark"||S.classList.contains("dark")||S.classList.contains("thread-ui-theme-dark")?"dark":"light":document.documentElement.classList.contains("dark")?"dark":"light";if(A(U()),!S)return;const B=new MutationObserver(()=>A(U()));return B.observe(S,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>B.disconnect()},[e]),!e)return null;const J=Wx(j),Z=J!==null?Math.min(J,((D=n.data)==null?void 0:D.totalTurnCount)??J):j==="all-loaded"?f.length:k.size,M=!r&&g!=="share"&&(J!==null||j==="all-loaded"||k.size>0),ie=!r&&a&&!!m&&C.trim().length>0;function O(S){y(U=>{const B=new Set(U);return B.has(S)?B.delete(S):B.add(S),B})}function G(){if(g==="share")return;const S={format:g,...J!==null?{mode:"latest",limit:J}:j==="all-loaded"?{mode:"selected",turnIds:f.map(U=>U.turnId)}:{mode:"selected",turnIds:[...k]},profile:"review",options:{includeTokenAndPrice:v}};h(S)}function H(S){S.preventDefault(),ie&&(m==null||m({targetIdentifier:C.trim(),threadAccess:E,workspaceAccess:_,label:W.trim()||null}))}const T=[{mode:"pdf",label:"PDF"},{mode:"html",label:"HTML"},{mode:"share",label:"Share"}];return Lr.createPortal(t.jsxs("div",{className:`thread-export-dialog-root thread-ui-theme-${F} fixed inset-0 z-[96] flex items-end justify-center p-0 sm:items-center sm:p-6`,"data-theme-effective":F,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(S=>t.jsx("button",{type:"button",onClick:()=>x(S.mode),className:`rounded-full px-3 py-1.5 text-sm transition ${g===S.mode?"ui-status-warning":"thread-export-dialog-muted-action"}`,children:S.label},S.mode))}),g==="share"?t.jsxs("form",{id:"thread-actions-share-form",className:"mt-4 space-y-4",onSubmit:H,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&&p?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:p,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:S=>N(S.target.value),placeholder:"username or email",value: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:"Thread access"}),t.jsx("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[["read","View only"],["control","Collaborator"]].map(([S,U])=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex items-center gap-2 rounded-xl px-2.5 py-2 text-sm",children:[t.jsx("input",{type:"radio",checked:E===S,disabled:!a||r,onChange:()=>R(S)}),U]},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:"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(([S,U])=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex items-center gap-2 rounded-xl px-2.5 py-2 text-sm",children:[t.jsx("input",{type:"radio",checked:_===S,disabled:!a||r,onChange:()=>Y(S)}),U]},S))})]}),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:S=>re(S.target.value),placeholder:"optional",value:W})]}),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(S=>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:S.targetUsername}),t.jsxs("p",{className:"thread-export-dialog-subtitle mt-0.5 text-xs",children:[S.label?`${S.label} · `:"",Ux(S.threadAccess)," / ",Vx(S.workspaceAccess)]})]}),u?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 u(S.id),children:"Revoke"}):null]},S.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:j,onChange:S=>b(S.target.value),children:["latest-3","latest-10","latest-20","all-loaded","custom"].map(S=>t.jsx("option",{value:S,children:Ox(S)},S))})]}),j==="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 ",k.size," of ",((L=n.data)==null?void 0:L.totalTurnCount)??f.length]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>y(new Set(f.map(S=>S.turnId))),className:"thread-export-dialog-secondary-button rounded-full border px-2.5 py-1 text-xs transition",children:"Select all"}),t.jsx("button",{type:"button",onClick:()=>y(new Set),className:"thread-export-dialog-secondary-button rounded-full border px-2.5 py-1 text-xs transition",children:"Clear"})]})]}),n.status==="loading"?t.jsx("p",{className:"thread-export-dialog-subtitle px-3 py-6 text-sm",children:"Loading turns..."}):n.status==="failed"?t.jsx("p",{className:"px-3 py-6 text-sm text-rose-500 dark:text-rose-200",children:n.error}):t.jsx("div",{className:"max-h-80 overflow-auto p-2",children:f.map(S=>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:k.has(S.turnId),onChange:()=>O(S.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 ",S.turnNumber]}),t.jsx("span",{className:"thread-export-dialog-subtitle shrink-0 text-xs",children:Hx(S.startedAt)}),t.jsx("span",{className:"thread-export-dialog-body-text min-w-0 flex-1 truncate text-left",children:S.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:Fx(S.status)})]},S.turnId))})]}):null,t.jsxs("div",{className:"thread-export-dialog-body-text mt-4 grid gap-2 text-sm sm:grid-cols-2",children:[t.jsxs("label",{className:"thread-export-dialog-box flex items-center gap-2 rounded-xl border px-3 py-2",children:[t.jsx("input",{type:"checkbox",checked:v,onChange:S=>w(S.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.":`${Z} ${Z===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:G,disabled:!M,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 Xx({detail:e,adapter:r,timelineAdapter:n,TimelineComponent:a=Wl,liveOutput:s="",beforeTimelineContent:o,composerProps:l,timelineProps:i,transcriptItemCount:d,useFloatingMobileComposer:h=!1,floatingMobileComposerBottomOffset:m=0,composerHostRef:u}){const[p,f]=c.useState(!1),[g,x]=c.useState(0),[j,b]=c.useState(0),[k,y]=c.useState(0),[v,w]=c.useState(!1),C=c.useRef(null),N=i==null?void 0:i.onTailVisibilityChange,E=e.pendingRequests.length>0,R=c.useMemo(()=>{const G=e.pendingSteers??[],H=new Set(G.map(T=>T.clientRequestId).filter(T=>!!T));return[...G.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=>!H.has(T.clientRequestId)).map(T=>({id:T.id,prompt:T.prompt,optimistic:!0}))]},[e.pendingSteers,i==null?void 0:i.optimisticSteers]),_=c.useMemo(()=>(e.pendingSteers??[]).filter(G=>G.delivery==="steer"),[e.pendingSteers]),Y=c.useMemo(()=>{var G;return l?{...l,pendingPrompts:R,...r.steerPendingPrompt&&((G=l.capabilities)!=null&&G.turns.steer)?{onSteerPendingPrompt:H=>{var T;return(T=r.steerPendingPrompt)==null?void 0:T.call(r,e.thread.id,H)}}:{},...r.cancelPendingSteer?{onCancelPendingPrompt:H=>{var T;return(T=r.cancelPendingSteer)==null?void 0:T.call(r,e.thread.id,H)}}:{}}:null},[r.cancelPendingSteer,r.steerPendingPrompt,l,e.thread.id,R]),W=c.useCallback(G=>{N==null||N(G)},[N]);c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const G=window.matchMedia("(max-width: 639px)"),H=()=>f(G.matches);return H(),G.addEventListener("change",H),()=>{G.removeEventListener("change",H)}},[]),c.useEffect(()=>{var H,T;if(typeof window>"u")return;const G=()=>{const $=window.visualViewport,D=$?Math.max(0,Math.round(window.innerHeight-$.height-$.offsetTop)):0,L=$?Math.max(0,Math.round(window.innerHeight-$.height)):D,S=Math.min(D,L),U=Math.max(0,Math.round(window.innerHeight*.52));y(Math.min(S,U))};return G(),(H=window.visualViewport)==null||H.addEventListener("resize",G),(T=window.visualViewport)==null||T.addEventListener("scroll",G),window.addEventListener("resize",G),()=>{var $,D;($=window.visualViewport)==null||$.removeEventListener("resize",G),(D=window.visualViewport)==null||D.removeEventListener("scroll",G),window.removeEventListener("resize",G)}},[]),c.useLayoutEffect(()=>{const G=C.current;if(!G||!p){x(0);return}const H=()=>{x(Math.ceil(G.getBoundingClientRect().height))};if(H(),typeof ResizeObserver>"u")return;const T=new ResizeObserver(H);return T.observe(G),()=>{T.disconnect()}},[p,l,E]),c.useLayoutEffect(()=>{var $,D;const G=C.current;if(!G||!p){b(0);return}const H=()=>{const L=G.getBoundingClientRect();b(Math.max(0,Math.ceil(window.innerHeight-L.top)))};H(),window.addEventListener("resize",H),($=window.visualViewport)==null||$.addEventListener("resize",H),(D=window.visualViewport)==null||D.addEventListener("scroll",H);let T=null;return typeof ResizeObserver<"u"&&(T=new ResizeObserver(H),T.observe(G)),()=>{var L,S;window.removeEventListener("resize",H),(L=window.visualViewport)==null||L.removeEventListener("resize",H),(S=window.visualViewport)==null||S.removeEventListener("scroll",H),T==null||T.disconnect()}},[p,k,v,l,E]),c.useEffect(()=>{if(!p){w(!1);return}const G=T=>{var D;const $=T.target;$ instanceof HTMLElement&&((D=C.current)!=null&&D.contains($))&&w(!0)},H=T=>{var D;const $=T.relatedTarget;$ instanceof HTMLElement&&((D=C.current)!=null&&D.contains($))||w(!1)};return document.addEventListener("focusin",G),document.addEventListener("focusout",H),()=>{document.removeEventListener("focusin",G),document.removeEventListener("focusout",H)}},[p]);const re=c.useCallback(G=>{C.current=G,u&&(u.current=G)},[u]),F=p&&v?Math.max(0,k-m):0,A=Math.max(g,144),J=Math.max(j,A+F),Z=p?J+12:0,M=Z>0?{"--thread-graph-chat-scroll-bottom-spacer":`${Z}px`}:void 0,ie=h&&p?{bottom:`${m+F}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"}:void 0,O=c.useMemo(()=>{const G=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:G,liveOutput:s,className:"thread-timeline-surface min-h-0 flex-1",...i,pendingSteers:_,optimisticSteers:[],adapter:n,onOpenThread:(i==null?void 0:i.onOpenThread)??r.openThread,onTailVisibilityChange:W})},[a,r.openThread,e.pendingRequests,e.thread.activeTurnId,e.thread.id,e.thread.status,e.totalTurnCount,e.turns,W,s,n,i,_]);return t.jsxs("div",{"data-testid":"chat-panel",className:"thread-graph-chat-panel relative flex h-full min-h-0 flex-col",style:M,children:[o,O,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":""]})}),Y?h?t.jsx("div",{ref:re,className:"fixed inset-x-0 bottom-0 z-50 overflow-visible sm:hidden",style:ie??{bottom:`${m}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"},children:t.jsx(ta,{...Y,activeView:"chat",edgeToEdgeMobile:!0,onSubmit:r.sendPrompt})}):t.jsx("div",{ref:re,className:"thread-graph-composer-host shrink-0",children:t.jsx(ta,{...Y,activeView:"chat",onSubmit:r.sendPrompt})}):null]})}function qx(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 Or(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 Kx(e){if(!e||e.turns<=0)return"waiting for agent usage";const r=`in ${Or(e.input)} / out ${Or(e.output)} / cache read ${Or(e.cache)}`,n=e.cacheWrite>0?`${r} / cache write ${Or(e.cacheWrite)}`:r;return e.pricedTurns>0?`${n} / cost ${Gl(e.priceUsd)}`:n}function Yx(e){return!!(e&&typeof e=="object"&&typeof e.id=="string"&&typeof e.kind=="string")}function Zx(e){const r=n=>Array.isArray(n)?n.filter(Yx):[];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 bb({threads:e,detail:r,loading:n,error:a,status:s=null,plugins:o,adapter:l,metaContent:i,settingsContent:d,globalSettingsContent:h,settingsDialogOpen:m,onSettingsDialogOpenChange:u,mobileHeaderAction:p,appMenuButton:f,appNavigationMenu:g,workspaceReturnHref:x,onWorkspaceReturn:j,threadActionsButton:b,surfaceActions:k,floatingPanel:y,workspaceContent:v,workspaceTitle:w,workspaceActions:C,workspaceFeatures:N,workspaceFocusPathRequest:E=null,onNewThreadTitle:R,beforeTimelineContent:_,errorContent:Y,workspaceMissingContent:W,dialogs:re,currentThreadId:F,currentWorkspaceId:A,currentWorkspaceLabel:J,onCloseAppNavigation:Z,presentation:M="workspace",className:ie="thread-detail-surface relative flex h-full min-h-0 flex-1 flex-col overflow-hidden",activeView:O="chat",liveOutput:G="",timelineProps:H,composerProps:T,shellComposerProps:$,useFloatingMobileComposer:D=!1,floatingMobileComposerBottomOffset:L=0,composerHostRef:S,shellPanelRef:U,shellEffectiveTheme:B="dark",shellThemeMode:le=B,onShellThemeModeChange:K,onShellStateChange:de,shellUnavailableContent:ee,shellDisconnectedContent:ve,timelineComponent:be=Wl,shellPanelComponent:ye=Dx,shellContent:we,loadingContent:fe,emptyContent:Te}){const oe=c.useMemo(()=>r?Zx(r):null,[r]),Q=wa(),me=o??Q??va(),{getImageAssetUrl:ke,loadHistoryItemDetail:Ne,openWorkspaceFile:Ae,openThread:Ge,cancelPendingSteer:Me}=l,Fe=c.useMemo(()=>({...ke?{getImageAssetUrl:je=>ke(je.path)}:{},onOpenLinkedThread:Ge,...Ae?{onOpenWorkspaceFile:Ae}:{},...Ne?{onLoadHistoryItemDetail:Ne}:{},...Me?{cancelPendingSteer:Me}:{}}),[Me,ke,Ne,Ae,Ge]),X=me.getThreadPanels().some(je=>je.kind==="terminal"),he=c.useMemo(()=>oe?qx(oe):null,[oe]),Ce=c.useMemo(()=>Kx(he),[he]),I=c.useMemo(()=>{var je;return oe?oe.turns.reduce((Ie,ce)=>Ie+ce.items.length,((je=oe.liveItems)==null?void 0:je.items.length)??0):0},[oe]),V=v??(oe?t.jsx(ql,{detail:oe,status:s,plugins:me,workspaceAdapter:l.workspace??null,metaContent:i,settingsContent:d,activeView:O,features:N,focusPathRequest:E}):null),ae=n?fe??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..."}):oe?t.jsxs("div",{className:ie,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&&(Y??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})),oe.workspacePathStatus==="missing"&&(W??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:oe.workspace.absPath})]})),t.jsx("div",{className:O==="chat"?"flex min-h-0 flex-1 flex-col":"hidden",children:t.jsx(Xx,{detail:oe,adapter:l,timelineAdapter:Fe,TimelineComponent:be,liveOutput:G,transcriptItemCount:I,useFloatingMobileComposer:D,floatingMobileComposerBottomOffset:L,..._?{beforeTimelineContent:_}:{},...T?{composerProps:T}:{},...H?{timelineProps:H}:{},...S?{composerHostRef:S}:{}})}),t.jsxs("div",{className:O==="shell"?"flex min-h-0 flex-1 flex-col":"hidden",children:[we??(oe.thread.isLoaded&&X&&l.shell?t.jsx(ye,{ref:U,threadId:oe.thread.id,shellAdapter:l.shell,effectiveTheme:B,isVisible:O==="shell",showHeader:!1,showFloatingToolbox:!1,...de?{onStateChange:de}:{}}):oe.thread.isLoaded&&!X?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:"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."})]})}):ve??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."})]})})),O==="shell"&&$&&!we?t.jsx(ta,{...$,activeView:"shell",onSubmit:l.sendPrompt}):null]}),re]}):Te??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."}),ge=t.jsx(Wp,{threads:e,status:s,loading:n,error:n?null:a,viewportConstrained:!0,currentThreadId:F??(oe==null?void 0:oe.thread.id),currentThreadLabel:oe==null?void 0:oe.thread.title,currentWorkspaceId:A??(oe==null?void 0:oe.thread.workspaceId),currentWorkspaceLabel:J??(oe==null?void 0:oe.workspace.label),sessionLabel:(oe==null?void 0:oe.thread.providerSessionId)??(oe==null?void 0:oe.thread.id),usageLabel:Ce,threadActionsButton:b,topbarActions:k,metaContent:i,settingsContent:d,globalSettingsContent:h,...m!==void 0?{settingsDialogOpen:m}:{},...u?{onSettingsDialogOpenChange:u}:{},mobileHeaderAction:p,effectiveTheme:B,themeMode:le,appMenuButton:f,appNavigationMenu:g,workspaceReturnHref:x,...j?{onWorkspaceReturn:j}:{},showMobileAppMenu:!!f,showMobileThreadNavToggle:M!=="embedded-single-thread",showMobileNewThreadShortcut:!1,hideRoomsRail:M==="embedded-single-thread",onOpenThread:l.openThread,workspaceContent:V,workspaceTitle:w??"Workspace",workspaceActions:C,...E?{workspaceRevealRequestKey:E.requestId}:{},...R?{onNewThreadTitle:R}:{},...Z?{onCloseAppNavigation:Z}:{},...K?{onThemeModeChange:K}:{},...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:ae});return o?t.jsx(ka.Provider,{value:me,children:ge}):ge}var Jx={},Qx=[];function vb({adapter:e=Jx,builtinPlugins:r=Qx,children:n}){const[a,s]=c.useState(()=>ra(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(ra(r,y))}catch(y){d(y instanceof Error?y.message:"Unable to load plugins.")}finally{l(!1)}},[e,r]);c.useEffect(()=>{h()},[h]);const m=c.useCallback(async(y,v)=>{if(e.updatePlugin){const w=await e.updatePlugin(y,{enabled:v});s(C=>C.map(N=>N.id===w.id?w:N));return}s(w=>w.map(C=>C.id===y?{...C,enabled:v}:C))},[e]),u=c.useCallback(async y=>{if(!e.importPlugin)throw new Error("Plugin import is not available.");const v=await e.importPlugin(y);s(w=>[...w.filter(N=>N.id!==v.id),v])},[e]),p=c.useCallback(async y=>{if(!e.deletePlugin)throw new Error("Plugin uninstall is not available.");const v=await e.deletePlugin(y);s(w=>w.filter(C=>C.id!==v.id))},[e]),f=c.useMemo(()=>{const y=new Set(a.filter(v=>v.enabled).map(v=>v.id));return r.filter(v=>y.has(v.manifest.id))},[r,a]),g=c.useCallback(y=>{var w;const v=f.find(C=>C.renderArtifact&&C.manifest.capabilities.artifactTypes.some(N=>N.type===y.artifact.type));return((w=v==null?void 0:v.renderArtifact)==null?void 0:w.call(v,y))??null},[f]),x=c.useCallback(y=>{for(const v of f)for(const w of v.inlineCodeRenderers??[]){if(!w.languages.includes(y.language.trim().toLowerCase()))continue;const C=w.render(y);if(C)return C}return null},[f]),j=c.useCallback(y=>f.some(v=>!!v.renderArtifact&&v.manifest.capabilities.artifactTypes.some(w=>w.type===y.type)),[f]),b=c.useCallback(()=>f.flatMap(y=>y.threadPanels??[]),[f]),k=c.useMemo(()=>({plugins:a,loading:o,error:i,refresh:h,importPluginManifest:u,setPluginEnabled:m,uninstallPlugin:p,renderArtifact:g,renderInlineCode:x,hasRendererForArtifact:j,getThreadPanels:b}),[i,b,j,u,o,a,h,g,x,m,p]);return t.jsx(ka.Provider,{value:k,children:n})}const Dn="chemistry.molecule3d",eb={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:Dn,title:"3D Molecule",fileExtensions:["xyz","extxyz","cif","pdb"]}],timelineRenderers:[Dn],threadPanels:[{id:"xyz-viewer",label:"Molecules",artifactTypes:[Dn]}],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 tb="remote-codex.terminal",rb={id:tb,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 Bn(e){return typeof e=="string"&&e.trim()!==""&&Number.isFinite(Number(e))}function nb(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]??"")&&Bn(o[1])&&Bn(o[2])&&Bn(o[3])})}function ab(e){return e.split(/\r?\n/).some(r=>/^(ATOM|HETATM)\s+/i.test(r))}function sb(e){return/\bdata_[^\s]*/i.test(e)&&/_atom_site\./i.test(e)}function ob(e,r){switch(r){case"xyz":case"extxyz":return nb(e);case"pdb":return ab(e);case"cif":return sb(e);default:return!1}}var Kl=c.lazy(async()=>(await Be(()=>Promise.resolve({}),__vite__mapDeps([19])),{default:(await Be(()=>import("./frontend-DNAQzqc-.js"),__vite__mapDeps([20,2,21]))).XyzMoleculeViewer}));function Yl(){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 lb(e){return!e||typeof e!="object"?!1:Array.isArray(e.content)}function ib(e){return e.trim().toLowerCase()==="extxyz"?"xyz":e.trim().toLowerCase()}function db({artifact:e,expanded:r,onToggleExpanded:n}){const a=lb(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(Yl,{}),children:t.jsx(Kl,{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 cb({code:e,isIncomplete:r,language:n}){const[a,s]=c.useState(!0),[o,l]=c.useState(!1),i=ib(n),d=c.useMemo(()=>({content:[e.endsWith(`
|
|
3972
|
+
`,I=Ce(Se);return!I&&M.current===he&&(M.current=null),I},sendControl(X){return X==="clear"?Me():Ce(Yg(X))},async copyLastCommandOutput(){const X=A.current.trim()||Qs(F);if(!X)return p==null||p("failed","Nothing to copy"),!1;try{return await navigator.clipboard.writeText(X),p==null||p("done","Copied"),!0}catch{return p==null||p("failed","Copy failed"),!1}},focus(){var X;(X=g.current)==null||X.focus()},refreshLayout(X){He(X)}}),[p,m,He,Me,Ce,me,we,F,D,i]),t.jsxs("div",{className:`relative min-h-0 flex-1 overflow-hidden ${a?"shell-pane-active":""}`,onMouseDown:h,"data-pane-id":r,children:[t.jsx("div",{ref:E,className:`h-full w-full px-2 py-2 sm:px-3 sm:py-3 ${o?"mobile-shell-selectable":""}`,onMouseDown:()=>{var X;h(),(X=g.current)==null||X.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"})]})}),Hx=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},m){const u=c.useRef(null),p=c.useRef(null),f=c.useRef(null),g=c.useRef(null),b=c.useRef(null),j=c.useRef(!1),[x,k]=c.useState(null),[w,v]=c.useState(!0),[y,N]=c.useState(!1),[S,T]=c.useState(null),[M,A]=c.useState("primary"),[J,W]=c.useState(null),[re,O]=c.useState(null),[P,Y]=c.useState("single"),[Z,_]=c.useState(50),[ie,H]=c.useState(null),[B,F]=c.useState(""),[E,D]=c.useState(!1),[$,L]=c.useState(!1),[C,U]=c.useState(!1),[G,le]=c.useState({primary:eo,secondary:eo}),[ee,ce]=c.useState(null),q=(x==null?void 0:x.state)??"not_created",ve=c.useMemo(()=>(x==null?void 0:x.shells)??[],[x==null?void 0:x.shells]),ke=c.useMemo(()=>ve.filter(vt),[ve]),je=c.useMemo(()=>ke.find(z=>z.id===J)??null,[ke,J]),ye=c.useMemo(()=>ke.find(z=>z.id===re)??null,[ke,re]),fe=M==="secondary"?ye:je,Te=G[M],oe=(x==null?void 0:x.workspacePathStatus)==="missing",Q=M==="secondary"?p:u,me=jx({activeRuntime:Te,activeShell:fe,busy:y,loading:w,status:q,workspacePathMissing:oe}),we=me.disabled,Ce=me.label,Me=me.className,Be=(ee==null?void 0:ee.tone)==="done"?"shell-floating-feedback shell-floating-feedback-done":(ee==null?void 0:ee.tone)==="failed"?"shell-floating-feedback shell-floating-feedback-failed":"shell-floating-feedback",Ae=c.useCallback((z,K)=>{ce({tone:z,text:K}),f.current!==null&&window.clearTimeout(f.current),f.current=window.setTimeout(()=>{ce(null),f.current=null},1800)},[]),He=c.useCallback((z,K,be)=>{k(Pe=>{var nt;if(!Pe)return Pe;const Oe=Pe.shells.map(Ve=>Ve.id===z?K(Ve):Ve),Fe=((nt=Pe.shell)==null?void 0:nt.id)===z?K(Pe.shell):Oe.find(Ve=>{var $e;return Ve.id===(($e=Pe.shell)==null?void 0:$e.id)})??Pe.shell;return{...Pe,...be?{state:be}:{},shell:Fe,shells:Oe}})},[]),X=c.useCallback(async()=>{v(!0);try{const z=await n.fetchState(r);k(z),T(null)}catch(z){T(z instanceof Error?z.message:"Unable to load shell state.")}finally{v(!1)}},[n,r]);c.useEffect(()=>{X()},[X]),c.useEffect(()=>{const z=i==null?void 0:i(r);if(z==null){_(50);return}const K=typeof z=="number"?z:Number.parseFloat(String(z));_(Number.isFinite(K)?Dn(K):50)},[i,r]),c.useEffect(()=>{if(!x){W(null),O(null);return}const z=yx(x);W(K=>K&&x.shells.some(be=>be.id===K&&vt(be))?K:(z==null?void 0:z.id)??null),O(K=>{if(P!=="columns")return null;if(K&&x.shells.some(Pe=>Pe.id===K&&vt(Pe)))return K;const be=x.shells.find(Pe=>vt(Pe)&&Pe.id!==(z==null?void 0:z.id));return(be==null?void 0:be.id)??null})},[x,P]),c.useEffect(()=>{P!=="columns"&&(A("primary"),O(null))},[P]),c.useEffect(()=>{if(P!=="columns"||re||ke.length<2)return;const z=ke.find(K=>K.id!==(je==null?void 0:je.id))??null;z&&O(z.id)},[ke,je==null?void 0:je.id,re,P]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const z=window.matchMedia("(max-width: 767px), (hover: none) and (pointer: coarse)"),K=()=>{D(z.matches),z.matches||(U(!1),L(!1))};return K(),z.addEventListener("change",K),()=>{z.removeEventListener("change",K)}},[]),c.useEffect(()=>()=>{f.current!==null&&window.clearTimeout(f.current),b.current!==null&&window.cancelAnimationFrame(b.current)},[]);const he=c.useCallback((z,K)=>{le(be=>{const Pe=be[z];return wx(Pe,K)?be:{...be,[z]:K}})},[]),Se=c.useCallback(z=>he("primary",z),[he]),I=c.useCallback(z=>he("secondary",z),[he]),V=c.useCallback(z=>{var be;if((be=z.label)!=null&&be.trim())return z.label.trim();const K=ve.findIndex(Pe=>Pe.id===z.id);return`Shell ${K>=0?K+1:""}`.trim()},[ve]),se=c.useCallback(z=>{var K;H(z.id),F(((K=z.label)==null?void 0:K.trim())||V(z))},[V]),ge=c.useCallback(()=>{H(null),F("")},[]),Ne=c.useCallback(async()=>{if(ie){N(!0);try{const z=B.trim(),K=await n.updateShell(ie,{label:z.length>0?z:null});k(be=>{var Pe;return be&&{...be,state:be.activeShellId===K.id?K.status:be.state,shell:((Pe=be.shell)==null?void 0:Pe.id)===K.id?K:be.shell,shells:be.shells.map(Oe=>Oe.id===K.id?K:Oe)}}),H(null),F(""),T(null)}catch(z){T(z instanceof Error?z.message:"Unable to rename shell.")}finally{N(!1)}}},[B,ie,n]),Le=c.useCallback((z,K)=>{if(z==="primary"){W(K),O(be=>be===K?null:be);return}O(K),W(be=>be===K?null:be)},[]),de=c.useCallback(z=>{var K,be;if(z==="primary"){(K=u.current)==null||K.disconnect(),W(null),P==="columns"&&A("secondary");return}(be=p.current)==null||be.disconnect(),O(null),A("primary"),Y("single")},[P]),Ge=c.useCallback((z,K=M)=>{const be=P==="columns"?K:"primary";Le(be,z.id),P!=="columns"&&O(null),A(be)},[M,Le,P]),qe=c.useCallback(async(z=M)=>{var K;if(!j.current){j.current=!0,N(!0);try{const be=await n.createShell(r);k(be);const Pe=be.activeShellId??((K=be.shell)==null?void 0:K.id)??null;if(Pe){const Oe=P==="columns"?z:"primary";Le(Oe,Pe),P!=="columns"&&O(null),A(Oe)}T(null)}catch(be){T(be instanceof Error?be.message:"Unable to create shell.")}finally{j.current=!1,N(!1)}}},[M,Le,n,P,r]);c.useEffect(()=>{!a||!x||w||y||oe||q==="creating"||ke.length>0||qe("primary")},[y,qe,a,ke.length,w,x,q,oe]);const Ue=c.useCallback(async(z=(fe==null?void 0:fe.id)??"")=>{if(z){N(!0);try{await n.terminateShell(z),W(K=>K===z?null:K),O(K=>K===z?null:K),await X(),T(null)}catch(K){T(K instanceof Error?K.message:"Unable to terminate shell.")}finally{N(!1)}}},[fe==null?void 0:fe.id,X,n]),Ye=c.useCallback(async()=>{var z,K;if(!we){if(Te.shellInputEnabled){(z=Q.current)==null||z.disconnect();return}if(!fe||fe.status==="exited"||fe.status==="not_found"){await qe(M);return}await((K=Q.current)==null?void 0:K.reconnect())}},[M,Q,Te.shellInputEnabled,fe,we,qe]),pt=c.useCallback(z=>{typeof window>"u"||d==null||d(r,Dn(z))},[d,r]),rt=c.useCallback(()=>{var z,K;(z=u.current)==null||z.refreshLayout({syncBackendSize:!0}),(K=p.current)==null||K.refreshLayout({syncBackendSize:!0})},[]),lt=c.useCallback(z=>{var Fe,nt;if(P!=="columns")return;const K=g.current;if(!K)return;z.preventDefault(),(nt=(Fe=z.currentTarget).setPointerCapture)==null||nt.call(Fe,z.pointerId);const be=Ve=>{const $e=K.getBoundingClientRect();if($e.width<=0)return;const at=Dn((Ve-$e.left)/$e.width*100);_(at),b.current!==null&&window.cancelAnimationFrame(b.current),b.current=window.requestAnimationFrame(()=>{b.current=null,rt()})},Pe=Ve=>{be(Ve.clientX)},Oe=Ve=>{be(Ve.clientX);const $e=K.getBoundingClientRect();$e.width>0&&pt((Ve.clientX-$e.left)/$e.width*100),window.removeEventListener("pointermove",Pe),window.removeEventListener("pointerup",Oe)};window.addEventListener("pointermove",Pe),window.addEventListener("pointerup",Oe,{once:!0})},[pt,rt,P]),Ze=c.useCallback((z,K)=>{Le(K,z.id),A(K)},[Le]),mt=c.useCallback(async()=>{var K;return await((K=Q.current)==null?void 0:K.copyLastCommandOutput())?!0:(Ae("failed","Nothing to copy"),!1)},[Q,Ae]);c.useEffect(()=>{h==null||h(Nx({activeRuntime:Te,activeShell:fe,connectionButtonDisabled:we,connectionButtonLabel:Ce,isMobileShell:E,busy:y,loading:w,error:S}))},[Te,fe,y,we,Ce,S,E,w,h]),c.useImperativeHandle(m,()=>({async toggleConnection(){await Ye()},sendInput(z){var K;return((K=Q.current)==null?void 0:K.sendInput(z))??!1},sendCommand(z){var K;return((K=Q.current)==null?void 0:K.sendCommand(z))??!1},sendControl(z){var K;return((K=Q.current)==null?void 0:K.sendControl(z))??!1},async copyLastCommandOutput(){var z;return await((z=Q.current)==null?void 0:z.copyLastCommandOutput())??!1},async terminate(){await Ue()},focus(){var z;(z=Q.current)==null||z.focus()},refreshLayout(z){var K,be;(K=u.current)==null||K.refreshLayout(z),P==="columns"&&((be=p.current)==null||be.refreshLayout(z))}}),[Q,Ye,Ue,P]);const it=z=>t.jsx("div",{className:`rounded-md border px-2 py-1.5 text-xs ${z.id===(fe==null?void 0:fe.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===z.id?t.jsx("form",{className:"min-w-0 flex-1",onSubmit:K=>{K.preventDefault(),Ne()},children:t.jsx("input",{value:B,onChange:K=>F(K.currentTarget.value),onKeyDown:K=>{K.key==="Escape"&&(K.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(z),onDoubleClick:()=>se(z),className:"min-w-0 flex-1 text-left",title:z.tmuxSessionName,children:[t.jsx("span",{className:"block truncate",children:V(z)}),t.jsxs("span",{className:"block truncate text-[10px] text-[var(--theme-fg-muted)]",children:[$n(z.status)," · ",gn(z.cwd)||z.cwd]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[ie===z.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:()=>se(z),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Rename shell",children:"Rename"}),P==="columns"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>Ze(z,"primary"),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Open in left pane",children:"L"}),t.jsx("button",{type:"button",onClick:()=>Ze(z,"secondary"),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Open in right pane",children:"R"})]}),t.jsx("button",{type:"button",disabled:y,onClick:()=>void Ue(z.id),className:"rounded border border-rose-300/35 bg-rose-300/12 px-1.5 py-1 text-[10px] text-rose-100 disabled:cursor-not-allowed disabled:opacity-50",title:"Kill shell process",children:"Kill"})]})]})},z.id);return t.jsxs("div",{className:"shell-panel flex min-h-0 flex-1 flex-col",children:[s&&t.jsxs("div",{className:"shell-header shrink-0 border-b px-3 py-3 sm:px-5",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs uppercase tracking-[0.24em] text-[var(--theme-fg-muted)]",children:"Shell"}),t.jsx("p",{className:"mt-1 truncate text-sm text-[var(--theme-fg-soft)]",children:Te.promptLabel??(fe==null?void 0:fe.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":Ce,title:`${Ce} (${$n(Te.status)})`,disabled:we,onClick:()=>void Ye(),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 ${Me}`,children:t.jsx(Jg,{connected:Te.shellInputEnabled})}),fe&&t.jsx("button",{type:"button",disabled:y,onClick:()=>void Ue(fe.id),className:"rounded-full border border-rose-300/35 bg-rose-300/12 px-3 py-2 text-sm text-rose-600 transition hover:bg-rose-300/18 dark:text-rose-100 disabled:cursor-not-allowed disabled:opacity-60",children:"Terminate"})]})]}),(S||w||oe)&&t.jsxs("div",{className:"shell-banner mt-3 rounded-2xl border px-3 py-3 text-sm",children:[w&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!w&&oe&&t.jsx("p",{className:"text-rose-600 dark:text-rose-100",children:"Workspace path is missing on this machine. Restore the path before creating a shell."}),!w&&S&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:S})]})]}),t.jsx("div",{className:"min-h-0 flex-1",children:t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("div",{className:"shell-terminal-bar flex shrink-0 items-center gap-2 border-b px-2 py-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-1",children:[t.jsx("span",{className:"min-w-0 truncate text-xs text-[var(--theme-fg-soft)]",children:fe?V(fe):"No live shell process"}),fe&&t.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.12em] text-[var(--theme-fg-muted)]",children:$n(Te.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 ",ke.length]}),t.jsx("button",{type:"button","aria-expanded":$,"aria-label":$?"Hide shell processes":"Show shell processes",onClick:()=>L(z=>!z),className:"rounded-md border border-stone-700/80 bg-stone-900/50 px-2.5 py-1.5 text-xs text-stone-200 sm:hidden",children:"Processes"})]})]}),$&&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:[ke.length," live"]})]}),t.jsxs("div",{className:"max-h-52 space-y-1 overflow-y-auto",children:[ke.map(it),ke.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:y||w||oe,onClick:()=>void qe(M),className:"inline-flex h-8 w-8 items-center justify-center rounded-md border border-sky-300/35 bg-sky-300/12 text-base leading-none text-sky-50 disabled:cursor-not-allowed disabled:opacity-50",children:"+"})})]}),q==="not_created"||oe?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."}),!oe&&t.jsx("button",{type:"button",disabled:y||w,onClick:()=>void qe("primary"),className:"mt-5 rounded-md border border-sky-300/35 bg-sky-300/12 px-3 py-2 text-sm text-sky-50 disabled:cursor-not-allowed disabled:opacity-50",children:"New Shell"})]})}):t.jsxs("div",{className:"grid h-full min-h-0 grid-cols-1 gap-2 p-2 sm:grid-cols-[minmax(0,1fr)_16rem] sm:p-3",children:[t.jsxs("div",{className:"shell-terminal-frame relative min-h-0 overflow-hidden rounded-[1.4rem] border shadow-inner",children:[!s&&(S||w||oe)&&t.jsxs("div",{className:"shell-banner absolute left-2 right-2 top-2 z-10 rounded-2xl border px-3 py-3 text-sm backdrop-blur sm:left-3 sm:right-3 sm:top-3",children:[w&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!w&&oe&&t.jsx("p",{className:"text-rose-600 dark:text-rose-100",children:"Workspace path is missing on this machine. Restore the path before creating a shell."}),!w&&S&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:S})]}),t.jsxs("div",{ref:g,className:`relative grid h-full min-h-0 ${P==="columns"?"grid-cols-1 sm:grid-cols-[var(--shell-left)_0.35rem_var(--shell-right)]":"grid-cols-1"}`,style:P==="columns"?{"--shell-left":`${Z}fr`,"--shell-right":`${100-Z}fr`}:void 0,"data-shell-split-ratio":Z,children:[t.jsx(to,{ref:u,paneId:"primary",shell:je,isActive:M==="primary",isVisible:a,isMobileShell:E,effectiveTheme:l,workspacePathMissing:oe,shellAdapter:n,onActivate:()=>A("primary"),onShellUpdate:He,onRuntimeStateChange:Se,onFeedback:Ae}),P==="columns"&&t.jsx("button",{type:"button",onClick:()=>de("primary"),className:"absolute left-2 top-2 z-10 rounded-md border border-stone-700/80 bg-stone-950/70 px-2 py-1 text-[10px] text-stone-200 hover:border-rose-300/40",title:"Close left pane",children:"Close"}),P==="columns"&&t.jsx("button",{type:"button","aria-label":"Resize shell panes",title:"Resize shell panes",onPointerDown:lt,className:"hidden cursor-col-resize border-x border-stone-800/80 bg-stone-900/60 transition hover:border-sky-300/40 hover:bg-sky-300/10 sm:block"}),P==="columns"&&t.jsxs("div",{className:"relative min-h-0 border-t border-stone-800/80 sm:border-l sm:border-t-0",children:[t.jsx(to,{ref:p,paneId:"secondary",shell:ye,isActive:M==="secondary",isVisible:a,isMobileShell:E,effectiveTheme:l,workspacePathMissing:oe,shellAdapter:n,onActivate:()=>A("secondary"),onShellUpdate:He,onRuntimeStateChange:I,onFeedback:Ae}),t.jsx("button",{type:"button",onClick:()=>de("secondary"),className:"absolute left-2 top-2 z-10 rounded-md border border-stone-700/80 bg-stone-950/70 px-2 py-1 text-[10px] text-stone-200 hover:border-rose-300/40",title:"Close right pane",children:"Close"})]})]}),o&&E&&t.jsxs("div",{className:"pointer-events-none absolute bottom-3 right-3 z-20 flex flex-col items-end gap-2",children:[ee&&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:ee.text}),C&&t.jsx("div",{className:"shell-toolbox pointer-events-auto rounded-[1.2rem] border p-2 shadow-2xl backdrop-blur",children:t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx("button",{type:"button",onClick:()=>{Ae("idle","Use the prompt box tools to paste")},className:"inline-flex items-center justify-center rounded-full border border-sky-300/35 bg-sky-300/12 px-2.5 py-2 text-sky-600 dark:text-sky-50",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Js,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:()=>void mt(),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(Js,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:!Te.shellInputEnabled,onClick:()=>{var z;(z=Q.current)!=null&&z.sendControl("clear")?Ae("done","Cleared"):Ae("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(Bn,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!Te.shellInputEnabled||!Te.isCommandRunning,onClick:()=>{var z;(z=Q.current)!=null&&z.sendInput("")?Ae("done","Sent Ctrl-C"):Ae("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(Bn,{label:"CTRL-C",tone:"rose"})}),["ctrl_d","esc","tab","up","down"].map(z=>t.jsx("button",{type:"button",disabled:!Te.shellInputEnabled,onClick:()=>{var K;(K=Q.current)!=null&&K.sendControl(z)?Ae("done",`Sent ${z.toUpperCase().replace("_","-")}`):Ae("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(Bn,{label:z.toUpperCase().replace("_","-"),tone:"stone"})},z))]})}),t.jsx("button",{type:"button","aria-expanded":C,"aria-label":C?"Close shell tools":"Open shell tools",onClick:()=>U(z=>!z),className:"shell-toolbox-trigger pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-2xl backdrop-blur transition",children:t.jsx(Zg,{})})]})]}),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:[ke.length," live"]})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-1 overflow-y-auto",children:[ke.map(it),ke.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:y||w||oe,onClick:()=>void qe(M),className:"inline-flex h-8 w-8 items-center justify-center rounded-md border border-sky-300/35 bg-sky-300/12 text-base leading-none text-sky-50 disabled:cursor-not-allowed disabled:opacity-50",children:"+"})})]})]})]})})]})}),Ox=c.lazy(async()=>({default:(await Promise.resolve().then(()=>(Hu(),Nl))).ThreadGraphWorkspacePanel}));function Wx(){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 Jl(e){return t.jsx(c.Suspense,{fallback:t.jsx(Wx,{}),children:t.jsx(Ox,{...e})})}c.memo(Jl);function kb({open:e,title:r,description:n,confirmLabel:a="Delete",busyLabel:s="Deleting...",busy:o=!1,onCancel:l,onConfirm:i}){return c.useEffect(()=>{if(!e)return;function d(h){h.key==="Escape"&&!o&&l()}return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d)}},[o,l,e]),e?Lr.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:l,disabled:o,className:"absolute inset-0 bg-stone-950/78 backdrop-blur-sm disabled:cursor-not-allowed"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":r,className:"relative z-[1] w-full max-w-md rounded-[1.6rem] border border-stone-700 bg-stone-900 p-5 shadow-2xl shadow-stone-950/40 sm:p-6",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium text-stone-100",children:r}),t.jsx("p",{className:"mt-2 text-sm leading-6 text-stone-400",children:n})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:l,disabled:o,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-stone-700 text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsxs("div",{className:"mt-5 flex items-center justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:l,disabled:o,className:"rounded-full border border-stone-700 px-4 py-2 text-sm font-medium text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),t.jsx("button",{type:"button",onClick:()=>void i(),disabled:o,className:"ui-action-danger rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:o?s:a})]})]})]}),document.body):null}function Ux(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 Xx(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 qx(e){switch(e){case"latest-3":return 3;case"latest-10":return 10;case"latest-20":return 20;default:return null}}function Kx(e){return e==="read"?"View only":"Collaborator"}function Yx(e){switch(e){case"write":return"Workspace write";case"read":return"Workspace read";case"none":default:return"No workspace"}}function wb({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:m,onRevokeShare:u,onOpenDeviceSharing:p}){var D,$,L;const f=c.useMemo(()=>{var C;return((C=n.data)==null?void 0:C.turns)??[]},[(D=n.data)==null?void 0:D.turns]),[g,b]=c.useState(l),[j,x]=c.useState("latest-10"),[k,w]=c.useState(()=>new Set),[v,y]=c.useState(!0),[N,S]=c.useState(""),[T,M]=c.useState("read"),[A,J]=c.useState("none"),[W,re]=c.useState(""),[O,P]=c.useState(()=>typeof document<"u"&&!document.documentElement.classList.contains("dark")?"light":"dark");if(c.useEffect(()=>{e&&(b(l),x("latest-10"),y(!0),S(""),M("read"),J("none"),re(""),d())},[l,d,e]),c.useEffect(()=>{e&&f.length>0&&w(new Set(f.slice(0,10).map(C=>C.turnId)))},[e,f]),c.useEffect(()=>{if(!e)return;function C(U){U.key==="Escape"&&!r&&i()}return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[r,i,e]),c.useEffect(()=>{if(!e)return;const C=document.querySelector(".thread-ui-shell"),U=()=>C?C.getAttribute("data-theme-effective")==="dark"||C.classList.contains("dark")||C.classList.contains("thread-ui-theme-dark")?"dark":"light":document.documentElement.classList.contains("dark")?"dark":"light";if(P(U()),!C)return;const G=new MutationObserver(()=>P(U()));return G.observe(C,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>G.disconnect()},[e]),!e)return null;const Y=qx(j),Z=Y!==null?Math.min(Y,(($=n.data)==null?void 0:$.totalTurnCount)??Y):j==="all-loaded"?f.length:k.size,_=!r&&g!=="share"&&(Y!==null||j==="all-loaded"||k.size>0),ie=!r&&a&&!!m&&N.trim().length>0;function H(C){w(U=>{const G=new Set(U);return G.has(C)?G.delete(C):G.add(C),G})}function B(){if(g==="share")return;const C={format:g,...Y!==null?{mode:"latest",limit:Y}:j==="all-loaded"?{mode:"selected",turnIds:f.map(U=>U.turnId)}:{mode:"selected",turnIds:[...k]},profile:"review",options:{includeTokenAndPrice:v}};h(C)}function F(C){C.preventDefault(),ie&&(m==null||m({targetIdentifier:N.trim(),threadAccess:T,workspaceAccess:A,label:W.trim()||null}))}const E=[{mode:"pdf",label:"PDF"},{mode:"html",label:"HTML"},{mode:"share",label:"Share"}];return Lr.createPortal(t.jsxs("div",{className:`thread-export-dialog-root thread-ui-theme-${O} fixed inset-0 z-[96] flex items-end justify-center p-0 sm:items-center sm:p-6`,"data-theme-effective":O,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:E.map(C=>t.jsx("button",{type:"button",onClick:()=>b(C.mode),className:`rounded-full px-3 py-1.5 text-sm transition ${g===C.mode?"ui-status-warning":"thread-export-dialog-muted-action"}`,children:C.label},C.mode))}),g==="share"?t.jsxs("form",{id:"thread-actions-share-form",className:"mt-4 space-y-4",onSubmit:F,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&&p?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:p,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=>S(C.target.value),placeholder:"username or email",value:N})]}),t.jsxs("fieldset",{className:"thread-export-dialog-box rounded-2xl border p-3",children:[t.jsx("legend",{className:"thread-export-dialog-subtitle px-1 text-xs",children:"Thread access"}),t.jsx("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[["read","View only"],["control","Collaborator"]].map(([C,U])=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex items-center gap-2 rounded-xl px-2.5 py-2 text-sm",children:[t.jsx("input",{type:"radio",checked:T===C,disabled:!a||r,onChange:()=>M(C)}),U]},C))})]}),t.jsxs("fieldset",{className:"thread-export-dialog-box rounded-2xl border p-3",children:[t.jsx("legend",{className:"thread-export-dialog-subtitle px-1 text-xs",children:"Workspace"}),t.jsx("div",{className:"mt-2 grid gap-2 sm:grid-cols-3",children:[["none","No access"],["read","Read files"],["write","Read and edit"]].map(([C,U])=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex items-center gap-2 rounded-xl px-2.5 py-2 text-sm",children:[t.jsx("input",{type:"radio",checked:A===C,disabled:!a||r,onChange:()=>J(C)}),U]},C))})]}),t.jsxs("label",{className:"thread-export-dialog-body-text block text-sm",children:["Label",t.jsx("input",{className:"thread-export-dialog-box mt-2 w-full rounded-xl border bg-transparent px-3 py-2 outline-none",disabled:!a||r,onChange:C=>re(C.target.value),placeholder:"optional",value:W})]}),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} · `:"",Kx(C.threadAccess)," / ",Yx(C.workspaceAccess)]})]}),u?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 u(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:j,onChange:C=>x(C.target.value),children:["latest-3","latest-10","latest-20","all-loaded","custom"].map(C=>t.jsx("option",{value:C,children:Xx(C)},C))})]}),j==="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 ",k.size," of ",((L=n.data)==null?void 0:L.totalTurnCount)??f.length]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>w(new Set(f.map(C=>C.turnId))),className:"thread-export-dialog-secondary-button rounded-full border px-2.5 py-1 text-xs transition",children:"Select all"}),t.jsx("button",{type:"button",onClick:()=>w(new Set),className:"thread-export-dialog-secondary-button rounded-full border px-2.5 py-1 text-xs transition",children:"Clear"})]})]}),n.status==="loading"?t.jsx("p",{className:"thread-export-dialog-subtitle px-3 py-6 text-sm",children:"Loading turns..."}):n.status==="failed"?t.jsx("p",{className:"px-3 py-6 text-sm text-rose-500 dark:text-rose-200",children:n.error}):t.jsx("div",{className:"max-h-80 overflow-auto p-2",children:f.map(C=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex cursor-pointer items-center gap-3 rounded-xl px-2.5 py-2 text-sm transition",children:[t.jsx("input",{type:"checkbox",checked:k.has(C.turnId),onChange:()=>H(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:Ux(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:v,onChange:C=>y(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.":`${Z} ${Z===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:B,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 Zx({detail:e,adapter:r,timelineAdapter:n,TimelineComponent:a=ql,liveOutput:s="",beforeTimelineContent:o,composerProps:l,timelineProps:i,transcriptItemCount:d,useFloatingMobileComposer:h=!1,floatingMobileComposerBottomOffset:m=0,composerHostRef:u}){const[p,f]=c.useState(!1),[g,b]=c.useState(0),[j,x]=c.useState(0),[k,w]=c.useState(0),[v,y]=c.useState(!1),N=c.useRef(null),S=i==null?void 0:i.onTailVisibilityChange,T=e.pendingRequests.length>0,M=c.useMemo(()=>{const B=e.pendingSteers??[],F=new Set(B.map(E=>E.clientRequestId).filter(E=>!!E));return[...B.filter(E=>E.delivery==="continuation").map(E=>({id:E.id,prompt:E.prompt,...E.id.startsWith("optimistic-")?{optimistic:!0}:{}})),...((i==null?void 0:i.optimisticSteers)??[]).filter(E=>!F.has(E.clientRequestId)).map(E=>({id:E.id,prompt:E.prompt,optimistic:!0}))]},[e.pendingSteers,i==null?void 0:i.optimisticSteers]),A=c.useMemo(()=>(e.pendingSteers??[]).filter(B=>B.delivery==="steer"),[e.pendingSteers]),J=c.useMemo(()=>{var B;return l?{...l,pendingPrompts:M,...r.steerPendingPrompt&&((B=l.capabilities)!=null&&B.turns.steer)?{onSteerPendingPrompt:F=>{var E;return(E=r.steerPendingPrompt)==null?void 0:E.call(r,e.thread.id,F)}}:{},...r.cancelPendingSteer?{onCancelPendingPrompt:F=>{var E;return(E=r.cancelPendingSteer)==null?void 0:E.call(r,e.thread.id,F)}}:{}}:null},[r.cancelPendingSteer,r.steerPendingPrompt,l,e.thread.id,M]),W=c.useCallback(B=>{S==null||S(B)},[S]);c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const B=window.matchMedia("(max-width: 639px)"),F=()=>f(B.matches);return F(),B.addEventListener("change",F),()=>{B.removeEventListener("change",F)}},[]),c.useEffect(()=>{var F,E;if(typeof window>"u")return;const B=()=>{const D=window.visualViewport,$=D?Math.max(0,Math.round(window.innerHeight-D.height-D.offsetTop)):0,L=D?Math.max(0,Math.round(window.innerHeight-D.height)):$,C=Math.min($,L),U=Math.max(0,Math.round(window.innerHeight*.52));w(Math.min(C,U))};return B(),(F=window.visualViewport)==null||F.addEventListener("resize",B),(E=window.visualViewport)==null||E.addEventListener("scroll",B),window.addEventListener("resize",B),()=>{var D,$;(D=window.visualViewport)==null||D.removeEventListener("resize",B),($=window.visualViewport)==null||$.removeEventListener("scroll",B),window.removeEventListener("resize",B)}},[]),c.useLayoutEffect(()=>{const B=N.current;if(!B||!p){b(0);return}const F=()=>{b(Math.ceil(B.getBoundingClientRect().height))};if(F(),typeof ResizeObserver>"u")return;const E=new ResizeObserver(F);return E.observe(B),()=>{E.disconnect()}},[p,l,T]),c.useLayoutEffect(()=>{var D,$;const B=N.current;if(!B||!p){x(0);return}const F=()=>{const L=B.getBoundingClientRect();x(Math.max(0,Math.ceil(window.innerHeight-L.top)))};F(),window.addEventListener("resize",F),(D=window.visualViewport)==null||D.addEventListener("resize",F),($=window.visualViewport)==null||$.addEventListener("scroll",F);let E=null;return typeof ResizeObserver<"u"&&(E=new ResizeObserver(F),E.observe(B)),()=>{var L,C;window.removeEventListener("resize",F),(L=window.visualViewport)==null||L.removeEventListener("resize",F),(C=window.visualViewport)==null||C.removeEventListener("scroll",F),E==null||E.disconnect()}},[p,k,v,l,T]),c.useEffect(()=>{if(!p){y(!1);return}const B=E=>{var $;const D=E.target;D instanceof HTMLElement&&(($=N.current)!=null&&$.contains(D))&&y(!0)},F=E=>{var $;const D=E.relatedTarget;D instanceof HTMLElement&&(($=N.current)!=null&&$.contains(D))||y(!1)};return document.addEventListener("focusin",B),document.addEventListener("focusout",F),()=>{document.removeEventListener("focusin",B),document.removeEventListener("focusout",F)}},[p]);const re=c.useCallback(B=>{N.current=B,u&&(u.current=B)},[u]),O=p&&v?Math.max(0,k-m):0,P=Math.max(g,144),Y=Math.max(j,P+O),Z=p?Y+12:0,_=Z>0?{"--thread-graph-chat-scroll-bottom-spacer":`${Z}px`}:void 0,ie=h&&p?{bottom:`${m+O}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"}:void 0,H=c.useMemo(()=>{const B=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:B,liveOutput:s,className:"thread-timeline-surface min-h-0 flex-1",...i,pendingSteers:A,optimisticSteers:[],adapter:n,onOpenThread:(i==null?void 0:i.onOpenThread)??r.openThread,onTailVisibilityChange:W})},[a,r.openThread,e.pendingRequests,e.thread.activeTurnId,e.thread.id,e.thread.status,e.totalTurnCount,e.turns,W,s,n,i,A]);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,H,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":""]})}),J?h?t.jsx("div",{ref:re,className:"fixed inset-x-0 bottom-0 z-50 overflow-visible sm:hidden",style:ie??{bottom:`${m}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"},children:t.jsx(aa,{...J,activeView:"chat",edgeToEdgeMobile:!0,onSubmit:r.sendPrompt})}):t.jsx("div",{ref:re,className:"thread-graph-composer-host shrink-0",children:t.jsx(aa,{...J,activeView:"chat",onSubmit:r.sendPrompt})}):null]})}function Jx(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 Wr(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 Qx(e){if(!e||e.turns<=0)return"waiting for agent usage";const r=`in ${Wr(e.input)} / out ${Wr(e.output)} / cache read ${Wr(e.cache)}`,n=e.cacheWrite>0?`${r} / cache write ${Wr(e.cacheWrite)}`:r;return e.pricedTurns>0?`${n} / cost ${Ol(e.priceUsd)}`:n}function eb(e){return!!(e&&typeof e=="object"&&typeof e.id=="string"&&typeof e.kind=="string")}function tb(e){const r=n=>Array.isArray(n)?n.filter(eb):[];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 yb({threads:e,detail:r,loading:n,error:a,status:s=null,plugins:o,adapter:l,metaContent:i,settingsContent:d,globalSettingsContent:h,settingsDialogOpen:m,onSettingsDialogOpenChange:u,mobileHeaderAction:p,appMenuButton:f,appNavigationMenu:g,workspaceReturnHref:b,onWorkspaceReturn:j,threadActionsButton:x,surfaceActions:k,floatingPanel:w,workspaceContent:v,workspaceTitle:y,workspaceActions:N,workspaceFeatures:S,workspaceFocusPathRequest:T=null,onNewThreadTitle:M,beforeTimelineContent:A,errorContent:J,workspaceMissingContent:W,dialogs:re,currentThreadId:O,currentWorkspaceId:P,currentWorkspaceLabel:Y,onCloseAppNavigation:Z,presentation:_="workspace",className:ie="thread-detail-surface relative flex h-full min-h-0 flex-1 flex-col overflow-hidden",activeView:H="chat",liveOutput:B="",timelineProps:F,composerProps:E,shellComposerProps:D,useFloatingMobileComposer:$=!1,floatingMobileComposerBottomOffset:L=0,composerHostRef:C,shellPanelRef:U,shellEffectiveTheme:G="dark",shellThemeMode:le=G,onShellThemeModeChange:ee,onShellStateChange:ce,shellUnavailableContent:q,shellDisconnectedContent:ve,timelineComponent:ke=ql,shellPanelComponent:je=Hx,shellContent:ye,loadingContent:fe,emptyContent:Te}){const oe=c.useMemo(()=>r?tb(r):null,[r]),Q=Na(),me=o??Q??ya(),{getImageAssetUrl:we,loadHistoryItemDetail:Ce,openWorkspaceFile:Me,openThread:Be,cancelPendingSteer:Ae}=l,He=c.useMemo(()=>({...we?{getImageAssetUrl:Ne=>we(Ne.path)}:{},onOpenLinkedThread:Be,...Me?{onOpenWorkspaceFile:Me}:{},...Ce?{onLoadHistoryItemDetail:Ce}:{},...Ae?{cancelPendingSteer:Ae}:{}}),[Ae,we,Ce,Me,Be]),X=me.getThreadPanels().some(Ne=>Ne.kind==="terminal"),he=c.useMemo(()=>oe?Jx(oe):null,[oe]),Se=c.useMemo(()=>Qx(he),[he]),I=c.useMemo(()=>{var Ne;return oe?oe.turns.reduce((Le,de)=>Le+de.items.length,((Ne=oe.liveItems)==null?void 0:Ne.items.length)??0):0},[oe]),V=v??(oe?t.jsx(Jl,{detail:oe,status:s,plugins:me,workspaceAdapter:l.workspace??null,metaContent:i,settingsContent:d,activeView:H,features:S,focusPathRequest:T}):null),se=n?fe??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..."}):oe?t.jsxs("div",{className:ie,children:[w?t.jsx("div",{className:"fixed right-3 top-20 z-50 lg:absolute lg:right-4 lg:top-16",children:w}):null,a&&!n&&(J??t.jsx("div",{className:"shrink-0 border-b border-rose-500/20 bg-rose-500/10 px-5 py-4 text-sm text-rose-100 sm:px-6",children:a})),oe.workspacePathStatus==="missing"&&(W??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:oe.workspace.absPath})]})),t.jsx("div",{className:H==="chat"?"flex min-h-0 flex-1 flex-col":"hidden",children:t.jsx(Zx,{detail:oe,adapter:l,timelineAdapter:He,TimelineComponent:ke,liveOutput:B,transcriptItemCount:I,useFloatingMobileComposer:$,floatingMobileComposerBottomOffset:L,...A?{beforeTimelineContent:A}:{},...E?{composerProps:E}:{},...F?{timelineProps:F}:{},...C?{composerHostRef:C}:{}})}),t.jsxs("div",{className:H==="shell"?"flex min-h-0 flex-1 flex-col":"hidden",children:[ye??(oe.thread.isLoaded&&X&&l.shell?t.jsx(je,{ref:U,threadId:oe.thread.id,shellAdapter:l.shell,effectiveTheme:G,isVisible:H==="shell",showHeader:!1,showFloatingToolbox:!1,...ce?{onStateChange:ce}:{}}):oe.thread.isLoaded&&!X?q??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."})]})}):ve??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."})]})})),H==="shell"&&D&&!ye?t.jsx(aa,{...D,activeView:"shell",onSubmit:l.sendPrompt}):null]}),re]}):Te??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."}),ge=t.jsx(Vp,{threads:e,status:s,loading:n,error:n?null:a,viewportConstrained:!0,currentThreadId:O??(oe==null?void 0:oe.thread.id),currentThreadLabel:oe==null?void 0:oe.thread.title,currentWorkspaceId:P??(oe==null?void 0:oe.thread.workspaceId),currentWorkspaceLabel:Y??(oe==null?void 0:oe.workspace.label),sessionLabel:(oe==null?void 0:oe.thread.providerSessionId)??(oe==null?void 0:oe.thread.id),usageLabel:Se,threadActionsButton:x,topbarActions:k,metaContent:i,settingsContent:d,globalSettingsContent:h,...m!==void 0?{settingsDialogOpen:m}:{},...u?{onSettingsDialogOpenChange:u}:{},mobileHeaderAction:p,effectiveTheme:G,themeMode:le,appMenuButton:f,appNavigationMenu:g,workspaceReturnHref:b,...j?{onWorkspaceReturn:j}:{},showMobileAppMenu:!!f,showMobileThreadNavToggle:_!=="embedded-single-thread",showMobileNewThreadShortcut:!1,hideRoomsRail:_==="embedded-single-thread",onOpenThread:l.openThread,workspaceContent:V,workspaceTitle:y??"Workspace",workspaceActions:N,...T?{workspaceRevealRequestKey:T.requestId}:{},...M?{onNewThreadTitle:M}:{},...Z?{onCloseAppNavigation:Z}:{},...ee?{onThemeModeChange:ee}:{},...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:se});return o?t.jsx(ja.Provider,{value:me,children:ge}):ge}var rb={},nb=[];function jb({adapter:e=rb,builtinPlugins:r=nb,children:n}){const[a,s]=c.useState(()=>sa(r,[])),[o,l]=c.useState(!1),[i,d]=c.useState(null),h=c.useCallback(async()=>{l(!0),d(null);try{const w=e.fetchPlugins?await e.fetchPlugins():[];s(sa(r,w))}catch(w){d(w instanceof Error?w.message:"Unable to load plugins.")}finally{l(!1)}},[e,r]);c.useEffect(()=>{h()},[h]);const m=c.useCallback(async(w,v)=>{if(e.updatePlugin){const y=await e.updatePlugin(w,{enabled:v});s(N=>N.map(S=>S.id===y.id?y:S));return}s(y=>y.map(N=>N.id===w?{...N,enabled:v}:N))},[e]),u=c.useCallback(async w=>{if(!e.importPlugin)throw new Error("Plugin import is not available.");const v=await e.importPlugin(w);s(y=>[...y.filter(S=>S.id!==v.id),v])},[e]),p=c.useCallback(async w=>{if(!e.deletePlugin)throw new Error("Plugin uninstall is not available.");const v=await e.deletePlugin(w);s(y=>y.filter(N=>N.id!==v.id))},[e]),f=c.useMemo(()=>{const w=new Set(a.filter(v=>v.enabled).map(v=>v.id));return r.filter(v=>w.has(v.manifest.id))},[r,a]),g=c.useCallback(w=>{var y;const v=f.find(N=>N.renderArtifact&&N.manifest.capabilities.artifactTypes.some(S=>S.type===w.artifact.type));return((y=v==null?void 0:v.renderArtifact)==null?void 0:y.call(v,w))??null},[f]),b=c.useCallback(w=>{for(const v of f)for(const y of v.inlineCodeRenderers??[]){if(!y.languages.includes(w.language.trim().toLowerCase()))continue;const N=y.render(w);if(N)return N}return null},[f]),j=c.useCallback(w=>f.some(v=>!!v.renderArtifact&&v.manifest.capabilities.artifactTypes.some(y=>y.type===w.type)),[f]),x=c.useCallback(()=>f.flatMap(w=>w.threadPanels??[]),[f]),k=c.useMemo(()=>({plugins:a,loading:o,error:i,refresh:h,importPluginManifest:u,setPluginEnabled:m,uninstallPlugin:p,renderArtifact:g,renderInlineCode:b,hasRendererForArtifact:j,getThreadPanels:x}),[i,x,j,u,o,a,h,g,b,m,p]);return t.jsx(ja.Provider,{value:k,children:n})}const Fn="chemistry.molecule3d",ab={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:Fn,title:"3D Molecule",fileExtensions:["xyz","extxyz","cif","pdb"]}],timelineRenderers:[Fn],threadPanels:[{id:"xyz-viewer",label:"Molecules",artifactTypes:[Fn]}],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 sb="remote-codex.terminal",ob={id:sb,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 Hn(e){return typeof e=="string"&&e.trim()!==""&&Number.isFinite(Number(e))}function lb(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]??"")&&Hn(o[1])&&Hn(o[2])&&Hn(o[3])})}function ib(e){return e.split(/\r?\n/).some(r=>/^(ATOM|HETATM)\s+/i.test(r))}function db(e){return/\bdata_[^\s]*/i.test(e)&&/_atom_site\./i.test(e)}function cb(e,r){switch(r){case"xyz":case"extxyz":return lb(e);case"pdb":return ib(e);case"cif":return db(e);default:return!1}}var Ql=c.lazy(async()=>(await De(()=>Promise.resolve({}),__vite__mapDeps([19])),{default:(await De(()=>import("./frontend-DNAQzqc-.js"),__vite__mapDeps([20,2,21]))).XyzMoleculeViewer}));function ei(){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 hb(e){return!e||typeof e!="object"?!1:Array.isArray(e.content)}function ub(e){return e.trim().toLowerCase()==="extxyz"?"xyz":e.trim().toLowerCase()}function mb({artifact:e,expanded:r,onToggleExpanded:n}){const a=hb(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(ei,{}),children:t.jsx(Ql,{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 pb({code:e,isIncomplete:r,language:n}){const[a,s]=c.useState(!0),[o,l]=c.useState(!1),i=ub(n),d=c.useMemo(()=>({content:[e.endsWith(`
|
|
3973
3973
|
`)?e:`${e}
|
|
3974
|
-
`],format:i,name:`${i.toUpperCase()} structure`,uuid:`inline:${i}:${e.length}`}),[e,i]);return r||!
|
|
3974
|
+
`],format:i,name:`${i.toUpperCase()} structure`,uuid:`inline:${i}:${e.length}`}),[e,i]);return r||!cb(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(ei,{}),children:t.jsx(Ql,{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 Nb=[{manifest:ob,threadPanels:[{id:"terminal",kind:"terminal",label:"Terminal"}]},{manifest:ab,renderArtifact:e=>t.jsx(mb,{...e}),inlineCodeRenderers:[{languages:["xyz","extxyz","cif","pdb"],render:e=>t.jsx(pb,{...e})}]}];export{Ip as A,kb as C,Xp as L,jb as P,wb as T,Na as a,yb as b,Hx as c,ql as d,Vp as e,qt as f,Up as g,Nb as h,zp as t,Ll as u};
|