remote-codex 0.11.49 → 0.11.51

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.
Files changed (38) hide show
  1. package/README.md +38 -5
  2. package/apps/supervisor-api/dist/index.js +2137 -422
  3. package/apps/supervisor-web/dist/assets/index-7LiZQ3aJ.js +22 -0
  4. package/apps/supervisor-web/dist/assets/{index-Dy8PgXgw.css → index-Bg8FdhS1.css} +1 -1
  5. package/apps/supervisor-web/dist/assets/{thread-ui-gcslNXur.js → thread-ui-BbtcUwps.js} +25 -19
  6. package/apps/supervisor-web/dist/index.html +3 -3
  7. package/bin/remote-codex.mjs +4 -2
  8. package/package.json +7 -1
  9. package/packages/acp/src/agent-catalog.test.ts +25 -0
  10. package/packages/acp/src/agent-catalog.ts +3 -1
  11. package/packages/acp/src/capabilities.ts +139 -0
  12. package/packages/acp/src/capability-parity.test.ts +99 -0
  13. package/packages/acp/src/catalog-runtime.test.ts +200 -6
  14. package/packages/acp/src/catalog-runtime.ts +239 -31
  15. package/packages/acp/src/extension-registry.test.ts +198 -0
  16. package/packages/acp/src/extension-registry.ts +285 -0
  17. package/packages/acp/src/extensions.test.ts +45 -0
  18. package/packages/acp/src/extensions.ts +103 -0
  19. package/packages/acp/src/harness-contract.test.ts +81 -0
  20. package/packages/acp/src/harness-contract.ts +62 -0
  21. package/packages/acp/src/index.ts +7 -0
  22. package/packages/acp/src/item-mapper.ts +28 -2
  23. package/packages/acp/src/prompt-content.test.ts +90 -0
  24. package/packages/acp/src/prompt-content.ts +99 -0
  25. package/packages/acp/src/runtimeAdapter.test.ts +458 -5
  26. package/packages/acp/src/runtimeAdapter.ts +791 -60
  27. package/packages/acp/src/session-hydrator.test.ts +135 -0
  28. package/packages/acp/src/session-hydrator.ts +147 -0
  29. package/packages/acp/src/terminal-service.test.ts +21 -2
  30. package/packages/acp/src/terminal-service.ts +23 -3
  31. package/packages/acp/src/test/fixtures/fake-acp-agent.mjs +514 -0
  32. package/packages/acp/src/workspace-boundary.test.ts +32 -0
  33. package/packages/acp/src/workspace-boundary.ts +47 -0
  34. package/packages/agent-runtime/src/types.ts +61 -1
  35. package/packages/db/src/repositories.ts +3 -2
  36. package/packages/shared/src/index.ts +32 -1
  37. package/scripts/service-manager.mjs +13 -0
  38. package/apps/supervisor-web/dist/assets/index-DZI1aSXo.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 Ft,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 w=f.length===0?"":f.length===1?f[0]:o(f).join(":"),v=g?w+Gn:w,y=v+k;if(i.indexOf(y)>-1)continue;i.push(y);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=[],Qe=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)\(.+\)$/,Tt=e=>jc.test(e),ze=e=>!!e&&!Number.isNaN(Number(e)),vt=e=>!!e&&Number.isInteger(Number(e)),yn=e=>e.endsWith("%")&&ze(e.slice(0,-1)),jt=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=>Pt(e,go,da),ue=e=>ho.test(e),Dt=e=>Pt(e,xo,Lc),Ha=e=>Pt(e,Fc,ze),Mc=e=>Pt(e,vo,mo),Ac=e=>Pt(e,bo,da),Fa=e=>Pt(e,po,da),$c=e=>Pt(e,fo,zc),Ar=e=>Pt(e,ko,Ic),pe=e=>uo.test(e),gr=e=>qt(e,xo),Dc=e=>qt(e,bo),Oa=e=>qt(e,po),Bc=e=>qt(e,go),Gc=e=>qt(e,fo),$r=e=>qt(e,ko,!0),Hc=e=>qt(e,vo,!0),Pt=(e,r,n)=>{const a=ho.exec(e);return a?a[1]?r(a[1]):n(a[2]):!1},qt=(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=Qe("color"),r=Qe("font"),n=Qe("text"),a=Qe("font-weight"),s=Qe("tracking"),o=Qe("leading"),l=Qe("breakpoint"),i=Qe("container"),d=Qe("spacing"),h=Qe("radius"),m=Qe("shadow"),u=Qe("inset-shadow"),p=Qe("text-shadow"),f=Qe("drop-shadow"),g=Qe("blur"),x=Qe("perspective"),j=Qe("aspect"),b=Qe("ease"),k=Qe("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],C=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto","contain","none"],E=()=>[pe,ue,d],_=()=>[Tt,"full","auto",...E()],M=()=>[vt,"none","subgrid",pe,ue],J=()=>["auto",{span:["full",vt,pe,ue]},vt,pe,ue],O=()=>[vt,"auto",pe,ue],X=()=>["auto","min","max","fr",pe,ue],K=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],R=()=>["start","end","center","stretch","center-safe","end-safe"],ee=()=>["auto",...E()],Q=()=>[Tt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...E()],A=()=>[Tt,"screen","full","dvw","lvw","svw","min","max","fit",...E()],ie=()=>[Tt,"screen","full","lh","dvh","lvh","svh","min","max","fit",...E()],U=()=>[e,pe,ue],D=()=>[...v(),Oa,Fa,{position:[pe,ue]}],G=()=>["no-repeat",{repeat:["","x","y","space","round"]}],T=()=>["auto","cover","contain",Bc,_c,{size:[pe,ue]}],B=()=>[yn,gr,Dt],$=()=>["","none","full",h,pe,ue],L=()=>["",ze,gr,Dt],S=()=>["solid","dashed","dotted","double"],H=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],F=()=>[ze,yn,Oa,Fa],le=()=>["","none",g,pe,ue],Y=()=>["none",ze,pe,ue],de=()=>["none",ze,pe,ue],te=()=>[ze,pe,ue],we=()=>[Tt,"full",...E()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[jt],breakpoint:[jt],color:[mo],container:[jt],"drop-shadow":[jt],ease:["in","out","in-out"],font:[Pc],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[jt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[jt],shadow:[jt],spacing:["px",ze],text:[jt],"text-shadow":[jt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Tt,ue,pe,j]}],container:["container"],"container-type":[{"@container":["","normal","size",pe,ue]}],"container-named":[Rc],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: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:_()}],"inset-x":[{"inset-x":_()}],"inset-y":[{"inset-y":_()}],start:[{"inset-s":_(),start:_()}],end:[{"inset-e":_(),end:_()}],"inset-bs":[{"inset-bs":_()}],"inset-be":[{"inset-be":_()}],top:[{top:_()}],right:[{right:_()}],bottom:[{bottom:_()}],left:[{left:_()}],visibility:["visible","invisible","collapse"],z:[{z:[vt,"auto",pe,ue]}],basis:[{basis:[Tt,"full","auto",i,...E()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[ze,Tt,"auto","initial","none",ue]}],grow:[{grow:["",ze,pe,ue]}],shrink:[{shrink:["",ze,pe,ue]}],order:[{order:[vt,"first","last","none",pe,ue]}],"grid-cols":[{"grid-cols":M()}],"col-start-end":[{col:J()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":M()}],"row-start-end":[{row:J()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":X()}],"auto-rows":[{"auto-rows":X()}],gap:[{gap:E()}],"gap-x":[{"gap-x":E()}],"gap-y":[{"gap-y":E()}],"justify-content":[{justify:[...K(),"normal"]}],"justify-items":[{"justify-items":[...R(),"normal"]}],"justify-self":[{"justify-self":["auto",...R()]}],"align-content":[{content:["normal",...K()]}],"align-items":[{items:[...R(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...R(),{baseline:["","last"]}]}],"place-content":[{"place-content":K()}],"place-items":[{"place-items":[...R(),"baseline"]}],"place-self":[{"place-self":["auto",...R()]}],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:ee()}],mx:[{mx:ee()}],my:[{my:ee()}],ms:[{ms:ee()}],me:[{me:ee()}],mbs:[{mbs:ee()}],mbe:[{mbe:ee()}],mt:[{mt:ee()}],mr:[{mr:ee()}],mb:[{mb:ee()}],ml:[{ml:ee()}],"space-x":[{"space-x":E()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":E()}],"space-y-reverse":["space-y-reverse"],size:[{size:Q()}],"inline-size":[{inline:["auto",...A()]}],"min-inline-size":[{"min-inline":["auto",...A()]}],"max-inline-size":[{"max-inline":["none",...A()]}],"block-size":[{block:["auto",...ie()]}],"min-block-size":[{"min-block":["auto",...ie()]}],"max-block-size":[{"max-block":["none",...ie()]}],w:[{w:[i,"screen",...Q()]}],"min-w":[{"min-w":[i,"screen","none",...Q()]}],"max-w":[{"max-w":[i,"screen","none","prose",{screen:[l]},...Q()]}],h:[{h:["screen","lh",...Q()]}],"min-h":[{"min-h":["screen","lh","none",...Q()]}],"max-h":[{"max-h":["screen","lh",...Q()]}],"font-size":[{text:["base",n,gr,Dt]}],"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":[ze,"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:U()}],"text-color":[{text:U()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...S(),"wavy"]}],"text-decoration-thickness":[{decoration:[ze,"from-font","auto",pe,Dt]}],"text-decoration-color":[{decoration:U()}],"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:E()}],"tab-size":[{tab:[vt,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:D()}],"bg-repeat":[{bg:G()}],"bg-size":[{bg:T()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},vt,pe,ue],radial:["",pe,ue],conic:[vt,pe,ue]},Gc,$c]}],"bg-color":[{bg:U()}],"gradient-from-pos":[{from:B()}],"gradient-via-pos":[{via:B()}],"gradient-to-pos":[{to:B()}],"gradient-from":[{from:U()}],"gradient-via":[{via:U()}],"gradient-to":[{to:U()}],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:[...S(),"hidden","none"]}],"divide-style":[{divide:[...S(),"hidden","none"]}],"border-color":[{border:U()}],"border-color-x":[{"border-x":U()}],"border-color-y":[{"border-y":U()}],"border-color-s":[{"border-s":U()}],"border-color-e":[{"border-e":U()}],"border-color-bs":[{"border-bs":U()}],"border-color-be":[{"border-be":U()}],"border-color-t":[{"border-t":U()}],"border-color-r":[{"border-r":U()}],"border-color-b":[{"border-b":U()}],"border-color-l":[{"border-l":U()}],"divide-color":[{divide:U()}],"outline-style":[{outline:[...S(),"none","hidden"]}],"outline-offset":[{"outline-offset":[ze,pe,ue]}],"outline-w":[{outline:["",ze,gr,Dt]}],"outline-color":[{outline:U()}],shadow:[{shadow:["","none",m,$r,Ar]}],"shadow-color":[{shadow:U()}],"inset-shadow":[{"inset-shadow":["none",u,$r,Ar]}],"inset-shadow-color":[{"inset-shadow":U()}],"ring-w":[{ring:L()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:U()}],"ring-offset-w":[{"ring-offset":[ze,Dt]}],"ring-offset-color":[{"ring-offset":U()}],"inset-ring-w":[{"inset-ring":L()}],"inset-ring-color":[{"inset-ring":U()}],"text-shadow":[{"text-shadow":["none",p,$r,Ar]}],"text-shadow-color":[{"text-shadow":U()}],opacity:[{opacity:[ze,pe,ue]}],"mix-blend":[{"mix-blend":[...H(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":H()}],"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":F()}],"mask-image-linear-to-pos":[{"mask-linear-to":F()}],"mask-image-linear-from-color":[{"mask-linear-from":U()}],"mask-image-linear-to-color":[{"mask-linear-to":U()}],"mask-image-t-from-pos":[{"mask-t-from":F()}],"mask-image-t-to-pos":[{"mask-t-to":F()}],"mask-image-t-from-color":[{"mask-t-from":U()}],"mask-image-t-to-color":[{"mask-t-to":U()}],"mask-image-r-from-pos":[{"mask-r-from":F()}],"mask-image-r-to-pos":[{"mask-r-to":F()}],"mask-image-r-from-color":[{"mask-r-from":U()}],"mask-image-r-to-color":[{"mask-r-to":U()}],"mask-image-b-from-pos":[{"mask-b-from":F()}],"mask-image-b-to-pos":[{"mask-b-to":F()}],"mask-image-b-from-color":[{"mask-b-from":U()}],"mask-image-b-to-color":[{"mask-b-to":U()}],"mask-image-l-from-pos":[{"mask-l-from":F()}],"mask-image-l-to-pos":[{"mask-l-to":F()}],"mask-image-l-from-color":[{"mask-l-from":U()}],"mask-image-l-to-color":[{"mask-l-to":U()}],"mask-image-x-from-pos":[{"mask-x-from":F()}],"mask-image-x-to-pos":[{"mask-x-to":F()}],"mask-image-x-from-color":[{"mask-x-from":U()}],"mask-image-x-to-color":[{"mask-x-to":U()}],"mask-image-y-from-pos":[{"mask-y-from":F()}],"mask-image-y-to-pos":[{"mask-y-to":F()}],"mask-image-y-from-color":[{"mask-y-from":U()}],"mask-image-y-to-color":[{"mask-y-to":U()}],"mask-image-radial":[{"mask-radial":[pe,ue]}],"mask-image-radial-from-pos":[{"mask-radial-from":F()}],"mask-image-radial-to-pos":[{"mask-radial-to":F()}],"mask-image-radial-from-color":[{"mask-radial-from":U()}],"mask-image-radial-to-color":[{"mask-radial-to":U()}],"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":F()}],"mask-image-conic-to-pos":[{"mask-conic-to":F()}],"mask-image-conic-from-color":[{"mask-conic-from":U()}],"mask-image-conic-to-color":[{"mask-conic-to":U()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:D()}],"mask-repeat":[{mask:G()}],"mask-size":[{mask:T()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",pe,ue]}],filter:[{filter:["","none",pe,ue]}],blur:[{blur:le()}],brightness:[{brightness:[ze,pe,ue]}],contrast:[{contrast:[ze,pe,ue]}],"drop-shadow":[{"drop-shadow":["","none",f,$r,Ar]}],"drop-shadow-color":[{"drop-shadow":U()}],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":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:[ze,"initial",pe,ue]}],ease:[{ease:["linear","initial",b,pe,ue]}],delay:[{delay:[ze,pe,ue]}],animate:[{animate:["none",k,pe,ue]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[x,pe,ue]}],"perspective-origin":[{"perspective-origin":y()}],rotate:[{rotate:Y()}],"rotate-x":[{"rotate-x":Y()}],"rotate-y":[{"rotate-y":Y()}],"rotate-z":[{"rotate-z":Y()}],scale:[{scale:de()}],"scale-x":[{"scale-x":de()}],"scale-y":[{"scale-y":de()}],"scale-z":[{"scale-z":de()}],"scale-3d":["scale-3d"],skew:[{skew:te()}],"skew-x":[{"skew-x":te()}],"skew-y":[{"skew-y":te()}],transform:[{transform:[pe,ue,"","none","gpu","cpu"]}],"transform-origin":[{origin:y()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:we()}],"translate-x":[{"translate-x":we()}],"translate-y":[{"translate-y":we()}],"translate-z":[{"translate-z":we()}],"translate-none":["translate-none"],zoom:[{zoom:[vt,pe,ue]}],accent:[{accent:U()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:U()}],"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":U()}],"scrollbar-track-color":[{"scrollbar-track":U()}],"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",...U()]}],"stroke-w":[{stroke:[ze,gr,Dt,Ha]}],stroke:[{stroke:["none",...U()]}],"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 qe={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},ca=10,Ut=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:w,getPanelStyle:v,groupId:y,isPanelCollapsed:C,reevaluatePanelConstraints:N,registerPanel:E,resizePanel:_,unregisterPanel:M}=j,J=ha(l),O=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}),Ut(()=>{const{callbacks:K,constraints:R}=O.current,ee={...R};O.current.id=J,O.current.idIsFromProps=l!==void 0,O.current.order=p,K.onCollapse=h,K.onExpand=m,K.onResize=u,R.collapsedSize=n,R.collapsible=a,R.defaultSize=s,R.maxSize=i,R.minSize=d,(ee.collapsedSize!==R.collapsedSize||ee.collapsible!==R.collapsible||ee.maxSize!==R.maxSize||ee.minSize!==R.minSize)&&N(O.current,ee)}),Ut(()=>{const K=O.current;return E(K),()=>{M(K)}},[p,J,E,M]),c.useImperativeHandle(o,()=>({collapse:()=>{b(O.current)},expand:K=>{k(O.current,K)},getId(){return J},getSize(){return w(O.current)},isCollapsed(){return C(O.current)},isExpanded(){return!C(O.current)},resize:K=>{_(O.current,K)}}),[b,k,w,C,J,_]);const X=v(O.current,s);return c.createElement(g,{...x,children:e,className:r,id:J,style:{...X,...f},[qe.groupId]:y,[qe.panel]:"",[qe.panelCollapsible]:a||void 0,[qe.panelId]:J,[qe.panelSize]:parseFloat(""+X.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,Lt=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(){Lt!==null&&(document.head.removeChild(Lt),Hn=null,Lt=null,Wr=-1)}function jn(e,r,n){var a,s;const o=Xc(e,r);if(Hn!==o){if(Hn=o,Lt===null&&(Lt=document.createElement("style"),document.head.appendChild(Lt)),Wr>=0){var l;(l=Lt.sheet)===null||l===void 0||l.removeRule(Wr)}Wr=(a=(s=Lt.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;Ee(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(Ee(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,It=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=It.get(l))!==null&&o!==void 0?o:0;return It.set(l,d+1),Sr.add(i),Qr(),function(){var m;on.delete(e),Sr.delete(i);const u=(m=It.get(l))!==null&&m!==void 0?m:1;if(It.set(l,u-1),Qr(),u===1&&It.delete(l),gt.includes(i)){const p=gt.indexOf(i);p>=0&&gt.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(qe.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&&It.forEach((n,a)=>{const{body:s}=a;n>0&&(s.addEventListener("contextmenu",Cn,r),s.addEventListener("pointerleave",Nn,r),s.addEventListener("pointermove",Nn,r))}),It.forEach((n,a)=>{const{body:s}=a;s.addEventListener("pointerup",Cn,r),s.addEventListener("pointercancel",Cn,r)})):It.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 Ee(e,r){if(!e)throw console.error(r),Error(r)}function Xt(e,r,n=ca){return e.toFixed(n)===r.toFixed(n)?0:e>r?1:-1}function Nt(e,r,n=ca){return Xt(e,r,n)===0}function mt(e,r,n){return Xt(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];Ee(a!=null,`Panel constraints not found for index ${r}`);let{collapsedSize:s=0,collapsible:o,maxSize:l=100,minSize:i=0}=a;if(Xt(n,i)<0)if(o){const d=(s+i)/2;Xt(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;Ee(i!=null,"Invalid first pivot index"),Ee(d!=null,"Invalid second pivot index");let h=0;if(o==="keyboard"){{const u=e<0?d:i,p=n[u];Ee(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(Ee(j!=null,`Previous layout not found for panel index ${u}`),mt(j,f)){const b=x-j;Xt(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}{const u=e<0?i:d,p=n[u];Ee(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(Ee(j!=null,`Previous layout not found for panel index ${u}`),mt(j,x)){const b=j-f;Xt(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];Ee(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];Ee(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];Ee(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];Ee(k!=null,`Previous layout not found for panel index ${b}`);const w=k+x,v=or({panelConstraints:n,panelIndex:b,size:w});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];Ee(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(`[${qe.resizeHandleId}][data-panel-group-id="${e}"]`))}function Po(e,r,n=document){const s=Tr(e,n).findIndex(o=>o.getAttribute(qe.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(`[${qe.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}),Ut(()=>{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];Ee(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;Ee(i,"Eager values not found");const{panelDataArray:d}=i,h=_o(n,o);Ee(h!=null,`No group found for id "${n}"`);const m=Tr(n,o);Ee(m,`No resize handles found for group id "${n}"`);const u=m.map(p=>{const f=p.getAttribute(qe.resizeHandleId);Ee(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(w=>w.id===g);if(k>=0){const w=d[k];Ee(w,`No panel data found for index ${k}`);const v=a[k],{collapsedSize:y=0,collapsible:C,minSize:N=0}=w.constraints;if(v!=null&&C){const E=wr({delta:mt(v,y)?N-y:y-v,initialLayout:a,panelConstraints:d.map(_=>_.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);Ee(l,`No resize handle element found for id "${r}"`);const i=l.getAttribute(qe.groupId);Ee(i,"Resize handle element has no group id attribute");let{initialCursorPosition:d}=a;const h=Mo(n,e),m=_o(i,s);Ee(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];Ee(l,`Panel constraints not found for index ${o}`);const{defaultSize:i}=l;i!=null&&(a++,r[o]=i,s-=i)}for(let o=0;o<e.length;o++){const l=n[o];Ee(l,`Panel constraints not found for index ${o}`);const{defaultSize:i}=l;if(i!=null)continue;const d=e.length-a,h=s/d;a++,r[o]=h,s-=h}return r}function er(e,r,n){r.forEach((a,s)=>{const o=e[s];Ee(o,`Panel data not found for index ${s}`);const{callbacks:l,constraints:i,id:d}=o,{collapsedSize:h=0,collapsible: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||Nt(u,h))&&!Nt(a,h)&&f(),p&&(u==null||!Nt(u,h))&&Nt(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];Ee(l!=null,`No layout data found for index ${o}`);const i=100/a*l;n[o]=i}let s=0;for(let o=0;o<r.length;o++){const l=n[o];Ee(l!=null,`No layout data found for index ${o}`);const i=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];Ee(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(),w=c.useRef({}),v=c.useRef(new Map),y=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:B}=C.current,{layout:$,panelDataArray:L}=N.current,S=Ja({layout:T,panelConstraints:L.map(H=>H.constraints)});Ya($,S)||(b(S),N.current.layout=S,B&&B(S),er(L,S,w.current))}}),[]),Ut(()=>{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 B=Qa[e];B==null&&(B=ph(gh,xh),Qa[e]=B);const $=[...T],L=new Map(v.current);B(e,$,L,j,d)}},[e,j,d]),c.useEffect(()=>{});const E=c.useCallback(T=>{const{onLayout:B}=C.current,{layout:$,panelDataArray:L}=N.current;if(T.constraints.collapsible){const S=L.map(Y=>Y.constraints),{collapsedSize:H=0,panelSize:F,pivotIndices:le}=Bt(L,T,$);if(Ee(F!=null,`Panel size not found for panel "${T.id}"`),!Nt(F,H)){v.current.set(T.id,F);const de=rr(L,T)===L.length-1?F-H:H-F,te=wr({delta:de,initialLayout:$,panelConstraints:S,pivotIndices:le,prevLayout:$,trigger:"imperative-api"});Dr($,te)||(b(te),N.current.layout=te,B&&B(te),er(L,te,w.current))}}},[]),_=c.useCallback((T,B)=>{const{onLayout:$}=C.current,{layout:L,panelDataArray:S}=N.current;if(T.constraints.collapsible){const H=S.map(we=>we.constraints),{collapsedSize:F=0,panelSize:le=0,minSize:Y=0,pivotIndices:de}=Bt(S,T,L),te=B??Y;if(Nt(le,F)){const we=v.current.get(T.id),ke=we!=null&&we>=te?we:te,Re=rr(S,T)===S.length-1?le-ke:ke-le,me=wr({delta:Re,initialLayout:L,panelConstraints:H,pivotIndices:de,prevLayout:L,trigger:"imperative-api"});Dr(L,me)||(b(me),N.current.layout=me,$&&$(me),er(S,me,w.current))}}},[]),M=c.useCallback(T=>{const{layout:B,panelDataArray:$}=N.current,{panelSize:L}=Bt($,T,B);return Ee(L!=null,`Panel size not found for panel "${T.id}"`),L},[]),J=c.useCallback((T,B)=>{const{panelDataArray:$}=N.current,L=rr($,T);return mh({defaultSize:B,dragState:g,layout:j,panelData:$,panelIndex:L})},[g,j]),O=c.useCallback(T=>{const{layout:B,panelDataArray:$}=N.current,{collapsedSize:L=0,collapsible:S,panelSize:H}=Bt($,T,B);return Ee(H!=null,`Panel size not found for panel "${T.id}"`),S===!0&&Nt(H,L)},[]),X=c.useCallback(T=>{const{layout:B,panelDataArray:$}=N.current,{collapsedSize:L=0,collapsible:S,panelSize:H}=Bt($,T,B);return Ee(H!=null,`Panel size not found for panel "${T.id}"`),!S||Xt(H,L)>0},[]),K=c.useCallback(T=>{const{panelDataArray:B}=N.current;B.push(T),B.sort(($,L)=>{const S=$.order,H=L.order;return S==null&&H==null?0:S==null?-1:H==null?1:S-H}),N.current.panelDataArrayChanged=!0,k()},[k]);Ut(()=>{if(N.current.panelDataArrayChanged){N.current.panelDataArrayChanged=!1;const{autoSaveId:T,onLayout:B,storage:$}=C.current,{layout:L,panelDataArray:S}=N.current;let H=null;if(T){const le=fh(T,S,$);le&&(v.current=new Map(Object.entries(le.expandToSizes)),H=le.layout)}H==null&&(H=uh({panelDataArray:S}));const F=Ja({layout:H,panelConstraints:S.map(le=>le.constraints)});Ya(L,F)||(b(F),N.current.layout=F,B&&B(F),er(S,F,w.current))}}),Ut(()=>{const T=N.current;return()=>{T.layout=[]}},[]);const R=c.useCallback(T=>{let B=!1;const $=f.current;return $&&window.getComputedStyle($,null).getPropertyValue("direction")==="rtl"&&(B=!0),function(S){S.preventDefault();const H=f.current;if(!H)return()=>null;const{direction:F,dragState:le,id:Y,keyboardResizeBy:de,onLayout:te}=C.current,{layout:we,panelDataArray:ke}=N.current,{initialLayout:xe}=le??{},Re=Ro(Y,T,H);let me=hh(S,T,F,le,de,H);const se=F==="horizontal";se&&B&&(me=-me);const Le=ke.map(je=>je.constraints),Z=wr({delta:me,initialLayout:xe??we,panelConstraints:Le,pivotIndices:Re,prevLayout:we,trigger:jo(S)?"keyboard":"mouse-or-touch"}),ce=!Dr(we,Z);(No(S)||Co(S))&&y.current!=me&&(y.current=me,!ce&&me!==0?se?Sn(T,me<0?To:Eo):Sn(T,me<0?Lo:Io):Sn(T,0)),ce&&(b(Z),N.current.layout=Z,te&&te(Z),er(ke,Z,w.current))}},[]),ee=c.useCallback((T,B)=>{const{onLayout:$}=C.current,{layout:L,panelDataArray:S}=N.current,H=S.map(we=>we.constraints),{panelSize:F,pivotIndices:le}=Bt(S,T,L);Ee(F!=null,`Panel size not found for panel "${T.id}"`);const de=rr(S,T)===S.length-1?F-B:B-F,te=wr({delta:de,initialLayout:L,panelConstraints:H,pivotIndices:le,prevLayout:L,trigger:"imperative-api"});Dr(L,te)||(b(te),N.current.layout=te,$&&$(te),er(S,te,w.current))},[]),Q=c.useCallback((T,B)=>{const{layout:$,panelDataArray:L}=N.current,{collapsedSize:S=0,collapsible:H}=B,{collapsedSize:F=0,collapsible:le,maxSize:Y=100,minSize:de=0}=T.constraints,{panelSize:te}=Bt(L,T,$);te!=null&&(H&&le&&Nt(te,S)?Nt(S,F)||ee(T,F):te<de?ee(T,de):te>Y&&ee(T,Y))},[ee]),A=c.useCallback((T,B)=>{const{direction:$}=C.current,{layout:L}=N.current;if(!f.current)return;const S=dn(T,f.current);Ee(S,`Drag handle element not found for id "${T}"`);const H=Mo($,B);x({dragHandleId:T,dragHandleRect:S.getBoundingClientRect(),initialCursorPosition:H,initialLayout:L})},[]),ie=c.useCallback(()=>{x(null)},[]),U=c.useCallback(T=>{const{panelDataArray:B}=N.current,$=rr(B,T);$>=0&&(B.splice($,1),delete w.current[T.id],N.current.panelDataArrayChanged=!0,k())},[k]),D=c.useMemo(()=>({collapsePanel:E,direction:a,dragState:g,expandPanel:_,getPanelSize:M,getPanelStyle:J,groupId:p,isPanelCollapsed:O,isPanelExpanded:X,reevaluatePanelConstraints:Q,registerPanel:K,registerResizeHandle:R,resizePanel:ee,startDragging:A,stopDragging:ie,unregisterPanel:U,panelGroupElement:f.current}),[E,g,a,_,M,J,p,O,X,Q,K,R,ee,A,ie,U]),G={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return c.createElement(an.Provider,{value:D},c.createElement(m,{...u,children:r,className:n,id:o,ref:f,style:{...G,...h},[qe.group]:"",[qe.groupDirection]:a,[qe.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 Bt(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(qe.groupId);Ee(i,`No group element found for id "${i}"`);const d=Tr(i,a),h=Po(i,r,a);Ee(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 w=c.useContext(an);if(w===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:v,groupId:y,registerResizeHandle:C,startDragging:N,stopDragging:E,panelGroupElement:_}=w,M=ha(s),[J,O]=c.useState("inactive"),[X,K]=c.useState(!1),[R,ee]=c.useState(null),Q=c.useRef({state:J});Ut(()=>{Q.current.state=J}),c.useEffect(()=>{if(n)ee(null);else{const D=C(M);ee(()=>D)}},[n,M,C]);const A=(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||R==null)return;const D=b.current;Ee(D,"Element ref not attached");let G=!1;return rh(M,D,v,{coarse:A,fine:ie},(B,$,L)=>{if(!$){O("inactive");return}switch(B){case"down":{O("drag"),G=!1,Ee(L,'Expected event to be defined for "down" action'),N(M,L);const{onDragging:S,onPointerDown:H}=k.current;S==null||S(!0),H==null||H();break}case"move":{const{state:S}=Q.current;G=!0,S!=="drag"&&O("hover"),Ee(L,'Expected event to be defined for "move" action'),R(L);break}case"up":{O("hover"),E();const{onClick:S,onDragging:H,onPointerUp:F}=k.current;H==null||H(!1),F==null||F(),G||S==null||S();break}}})},[A,v,n,ie,C,M,R,N,E]),bh({disabled:n,handleId:M,resizeHandler:R,panelGroupElement:_});const U={touchAction:"none",userSelect:"none"};return c.createElement(f,{...g,children:e,className:r,id:s,onBlur:()=>{K(!1),o==null||o()},onFocus:()=>{K(!0),d==null||d()},ref:b,role:"separator",style:{...U,...u},tabIndex:p,[qe.groupDirection]:v,[qe.groupId]:y,[qe.resizeHandle]:"",[qe.resizeHandleActive]:J==="drag"?"pointer":X?"keyboard":void 0,[qe.resizeHandleEnabled]:!n,[qe.resizeHandleId]:M,[qe.resizeHandleState]:J})}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 nt(...e){return Wc(so(e))}var Rt=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:nt(Fo({variant:a,size:n,className:r})),...s})}var Fo,cn=Oe({"src/components/graph-ui/Button.tsx"(){Rt(),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,w,v,y,C,N,E,_,M])=>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,w.default,v.default,y.default,C.default,N.default,E.default,_.default,M.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 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&&gt.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(`
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:nt("shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",e),...a})}var _h=Oe({"src/components/graph-ui/Separator.tsx"(){Rt()}});function Mh({className:e,orientation:r,...n}){return t.jsx("div",{role:"group","data-slot":"button-group","data-orientation":r,className:nt(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:nt("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(),Rt(),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:nt("z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md bg-foreground px-3 py-1.5 text-balance text-xs text-background animate-in fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",r),...a,children:[e,t.jsx(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"(){Rt()}});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 Ye({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(Ye,{label:"Distance",children:t.jsx(P.AlignVerticalDistributeCenter,{className:"size-4"})}),t.jsx(Ye,{label:"Connectivity",children:t.jsx(P.Share2,{className:"size-4"})}),t.jsx(Ye,{label:"Angle",children:t.jsx(P.Waypoints,{className:"size-4"})}),t.jsx(Ye,{label:"Dihedral",children:t.jsx(P.Spline,{className:"size-4"})}),t.jsx(Ye,{label:"Add dummy atoms",children:t.jsx(P.Bubbles,{className:"size-4"})}),t.jsx(Ye,{label:"Delete atoms",children:t.jsx(P.CircleX,{className:"size-4"})}),t.jsx(Ye,{label:"Rotate",children:t.jsx(P.Rotate3d,{className:"size-4"})})]}),t.jsxs(Kn,{children:[t.jsx(Ye,{label:p?"Hide unit cell":"Show unit cell",disabled:!u,onClick:l,children:t.jsx(P.Boxes,{className:"size-4"})}),t.jsx(Ye,{label:"Clear selection",disabled:!f,onClick:r,children:t.jsx(P.Trash2,{className:"size-4"})}),t.jsx(Ye,{label:"Send selection",disabled:!f,onClick:a,children:t.jsx(P.Send,{className:"size-4"})}),t.jsx(Ye,{label:"Stage current selection",disabled:!f,onClick:o,children:t.jsx(P.Box,{className:"size-4"})}),t.jsx(Ye,{label:"Clear staged selections",disabled:!g,onClick:n,children:t.jsx(P.Eraser,{className:"size-4"})}),t.jsx(Ye,{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(Ye,{label:"Copy current structure",onClick:()=>void d(),disabled:!o,children:t.jsx(P.Copy,{className:"size-3.5"})}),t.jsx(Ye,{label:"Download current structure",onClick:h,disabled:!o,children:t.jsx(P.Download,{className:"size-3.5"})}),t.jsx(Ye,{label:"Download full trajectory",onClick:m,disabled:!r,children:t.jsx(P.Box,{className:"size-3.5"})}),t.jsx(Ye,{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(Ye,{label:"Zoom in",onClick:u,disabled:!s.current||!o,children:t.jsx(P.ZoomIn,{className:"size-3.5"})}),t.jsx(Ye,{label:"Zoom out",onClick:p,disabled:!s.current||!o,children:t.jsx(P.ZoomOut,{className:"size-3.5"})}),t.jsx(Ye,{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:nt("relative flex w-full touch-none select-none items-center data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",e),...o,children:[t.jsx(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"(){Rt()}});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 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,`
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
9
  `),a+=i}return n.length>0?n:[e]}function ns(e,r){return r!=="xyz"?e:e.flatMap(n=>Jh(n))}function as(e){return e.map(r=>`${r.replace(/\s+$/g,"")}
10
- `).join("")}function Qh(e){if(!e)return{format:"xyz",frames:[],exportContent:""};if(typeof e=="string"){const s=ns([e],"xyz");return{frames:s,format:"xyz",exportContent:as(s)}}const r=Zh(e.format),n=e.content.filter(s=>s.trim().length>0);return{frames:ns(n,r),format:r,exportContent:as(n)}}var eu=Oe({"src/components/graph-workspace/GraphMoleculeViewerData.ts"(){}});function tu({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),[x,j]=c.useState(null),[b,k]=c.useState(!1),[w,v]=c.useState({}),[y,C]=c.useState([]),[N,E]=c.useState({}),[_,M]=c.useState(!1),[J,O]=c.useState(!1),[X,K]=c.useState(null),R=c.useMemo(()=>Qh(s),[s]),ee=R.frames,Q=R.format,A=ee[f]??null,ie=ee.length>0&&f===ee.length-1,U=r??"current",D=Object.values(N).reduce((L,S)=>L+S.length,0),G=Object.keys(N).length;c.useEffect(()=>{if(ee.length===0){g(0);return}g(ee.length-1)},[ee.length]),c.useEffect(()=>{if(!b||ee.length<=1)return;const L=window.setInterval(()=>{g(S=>S>=ee.length-1?(window.clearInterval(L),k(!1),S):S+1)},200);return()=>window.clearInterval(L)},[b,ee.length]),c.useEffect(()=>{const L=l.current;if(!L||i.current)return;let S=!1;try{const F=document.createElement("canvas");if(!(F.getContext("webgl2")||F.getContext("webgl")||F.getContext("experimental-webgl"))){K("WebGL is unavailable in this browser environment. Unable to render 3D viewer.");return}}catch{K("WebGL is unavailable in this browser environment. Unable to render 3D viewer.");return}const H=()=>{var F,le;(F=i.current)==null||F.resize(),(le=i.current)==null||le.render()};return Xh().then(F=>{if(!(S||i.current))try{const le=F.createViewer(L,{});i.current=le,le.setBackgroundColor("#f8fafc",.8),window.addEventListener("resize",H),window.setTimeout(H,100)}catch(le){console.error("Failed to initialize 3Dmol viewer:",le),K("Failed to initialize 3D viewer. Please refresh or try another browser.")}}).catch(F=>{console.error("Failed to load 3Dmol viewer runtime:",F),K("Failed to load 3D viewer runtime. Please refresh or try another browser.")}),()=>{S=!0,window.removeEventListener("resize",H),i.current=null,d.current=null}},[]),c.useEffect(()=>{const L=i.current;if(!(!L||!A))try{L.removeAllModels(),L.removeAllShapes(),L.removeAllLabels();const S=L.addModel(A,Q||"xyz");d.current=S,S.setStyle({},{stick:{radius:.2},sphere:{scale:.3}});const H=S.getCrystData(),F=!!(H&&typeof H=="object"&&Object.keys(H).length);M(F),O(F?m.current:!1),C([]),v({});const le=A.split(`
11
- `).slice(2).map(Y=>Y.trim()).filter(Boolean).map(Y=>Y.split(/\s+/)[0]??"Atom");h.current||(L.zoomTo(),h.current=!0),S.setClickable({},!0,(Y,de,te)=>{const we=Y.serial??Y.index;if(we===void 0)return;const ke=Y.atom||Y.elem||le[we]||"Atom";C(xe=>{const me=!!(te!=null&&te.shiftKey||te!=null&&te.metaKey||te!=null&&te.ctrlKey)?xe.includes(we)?xe.filter(se=>se!==we):[...xe,we]:xe.length===1&&xe[0]===we?[]:[we];return v(se=>{if(me.length===0)return{};const Le={};return me.forEach(Z=>{Le[Z]=se[Z]||le[Z]||ke}),Le}),me})}),S.setHoverable({},!0,(Y,de,te)=>{!te||!Y||j({x:te.clientX,y:te.clientY,label:`${Y.atom||Y.elem||"Atom"} (${Y.serial??Y.index??"?"})`,coords:{x:Y.x.toFixed(2),y:Y.y.toFixed(2),z:Y.z.toFixed(2)}})},()=>j(null)),L.render()}catch(S){console.error("Failed to render molecule:",S),K("Unable to render this molecular structure.")}},[A,Q]),c.useEffect(()=>{const L=i.current,S=d.current;if(!(!L||!S)){try{L.removeUnitCell(S)}catch{}if(J&&_)try{L.addUnitCell(S,{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{M(!1),O(!1)}L.render()}},[_,J,A,Q]),c.useEffect(()=>{const L=i.current,S=d.current;!L||!S||!A||(S.setStyle({},{stick:{radius:.2},sphere:{scale:.3}}),y.length>0&&S.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,A]),c.useEffect(()=>{if(!A)return;let L=0;const S=()=>{var F,le;const H=(le=(F=i.current)==null?void 0:F.getView)==null?void 0:le.call(F);if(Array.isArray(H)&&H.length>=8){const[Y,de,te,we,ke,xe,Re,me]=H;if(typeof Y=="number"&&typeof de=="number"&&typeof te=="number"&&typeof we=="number"&&typeof ke=="number"&&typeof xe=="number"&&typeof Re=="number"&&typeof me=="number"){const se=Math.sqrt(ke*ke+xe*xe+Re*Re),Le=se>0?{x:ke/se,y:xe/se,z:Re/se}:{x:0,y:0,z:0};p({position:{x:Y,y:de,z:te,qx:ke,qy:xe,qz:Re,qw:me},lookAt:Le,zoom:we})}}L=window.requestAnimationFrame(S)};return L=window.requestAnimationFrame(S),()=>window.cancelAnimationFrame(L)},[A]);const T=c.useCallback(async()=>{const L=i.current;if(!(L!=null&&L.pngURI))return;L.render();const S=L.pngURI();if(S){try{const F=await(await fetch(S)).blob(),le=new ClipboardItem({[F.type||"image/png"]:F});await navigator.clipboard.write([le])}catch{}n==null||n({moleculeId:r,image:S})}},[r,n]);function B(){_&&O(L=>{const S=!L;return m.current=S,S})}function $(){y.length!==0&&E(L=>{const S=L[U]??[];return{...L,[U]:Array.from(new Set([...S,...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:[X?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:X}):null,!X&&!A?t.jsx("div",{className:"thread-graph-molecule-empty absolute inset-0 flex items-center justify-center p-4 text-sm text-slate-400",children:"No molecule data available."}):null,x?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:x.x-20,top:x.y-50},children:[t.jsx("div",{className:"mb-0.5 font-semibold text-gray-900",children:x.label}),t.jsxs("div",{className:"space-x-2 text-gray-600",children:[t.jsxs("span",{children:["x: ",x.coords.x]}),t.jsxs("span",{children:["y: ",x.coords.y]}),t.jsxs("span",{children:["z: ",x.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(Uh,{currentIndex:f,exportContent:R.exportContent,moleculeId:r,onScreenshot:()=>void T(),viewerRef:i,xyzContent:A,xyzFormat:Q})]}),ee.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," / ",ee.length,t.jsx(Er,{type:"button",variant:"ghost",size:"icon",className:"thread-graph-molecule-button h-5 w-5",onClick:()=>{k(L=>{const S=!L;return S&&f===ee.length-1&&g(0),S})},"aria-label":b?"Pause trajectory":"Play trajectory",title:b?"Pause trajectory":"Play trajectory",children:b&&f!==ee.length-1?t.jsx(P.Pause,{className:"h-3 w-3"}):t.jsx(P.Play,{className:"h-3 w-3"})})]}),t.jsxs(Er,{type:"button",variant:"ghost",onClick:()=>g(ee.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(Kh,{value:[f],max:ee.length-1,step:1,onValueChange:L=>g(L[0]??0),"aria-label":"Trajectory frame"})]}):null,t.jsx(Oh,{cameraInfo:u,onClearSelection:()=>C([]),onClearStaged:()=>E({}),onSendSelection:()=>a==null?void 0:a({moleculeId:r,atoms:y}),onSendStaged:()=>{Object.entries(N).forEach(([L,S])=>{a==null||a({moleculeId:L==="current"?r:L,atoms:S})})},onStageSelection:$,onToggleUnitCell:B,selectedAtomLabels:w,selectedSerials:y,stagedAtoms:D,stagedMolecules:G,unitCellAvailable:_,unitCellVisible:J})]})]})]})}var ru=Oe({"src/components/graph-workspace/GraphMoleculeViewer.tsx"(){Wh(),Vh(),qh(),cn(),Yh(),eu()}});function ss(e){return e.replace(/background-color:[^;"]+;?/g,"background-color: transparent;").replace(/background:[^;"]+;?/g,"background: transparent;")}function nu(e){try{return decodeURIComponent(e)}catch{return e}}function os(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 au({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=nu(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 x=l&&(i===l||i.startsWith(`${l}/`))?i.slice(l.length):i;return os(x)}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 os(f?`${f}/${o}`:o)}function su(e){return!e.truncated&&e.size<=al&&e.content.split(`
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 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=lu(k);if(y!==l){if(typeof w=="number"&&typeof v=="number"&&a.current){const C=a.current.getBoundingClientRect(),N=w-(C.left+C.width/2),E=v-(C.top+C.height/2),_=y/l;h(M=>({x:N-(N-M.x)*_,y:E-(E-M.y)*_}))}i(y)}}function g(k){k.preventDefault();const w=k.deltaY<0?1:-1;f(l+w*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 w=o.current;!w||w.pointerId!==k.pointerId||h({x:w.startOffsetX+k.clientX-w.startClientX,y:w.startOffsetY+k.clientY-w.startClientY})}function b(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-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,w]=c.useState(null),[v,y]=c.useState(!1),[C,N]=c.useState("preview"),E=(p==null?void 0:p.node)??null,_=E!=null&&E.artifact?m.renderArtifact({artifact:E.artifact,expanded:!0,onToggleExpanded:()=>{}}):null,M=Th(d??null),J=(d==null?void 0:d.language)||Eh((d==null?void 0:d.path)??""),O=d?Mr(d.path):"",X=ol.has(O),K=ou(p),R=d!==null&&pa.has(O),ee=!!(d&&a)&&!R&&su(d),Q=(p==null?void 0:p.kind)==="live-molecule",A=!!(E!=null&&E.artifact&&_),ie=!!M||A;c.useEffect(()=>{x(!1),b((d==null?void 0:d.content)??""),w(null),N("preview")},[d==null?void 0:d.path,d==null?void 0:d.content]);async function U(){if(!(!d||!a)){y(!0),w(null);try{await a({path:d.path,content:j}),x(!1)}catch(D){w(D instanceof Error?D.message:"Failed to save file.")}finally{y(!1)}}}return t.jsxs("section",{className:"thread-graph-viewer flex h-full min-h-0 flex-col overflow-hidden rounded-[12px]","data-preview-target-kind":(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"}),K?t.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-slate-500 dark:text-slate-400",children:K}):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"&&M?t.jsx("div",{className:"thread-graph-molecule-preview min-h-0 flex-1 overflow-hidden",children:t.jsx(tu,{source:M,moleculeId:M.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:[R?"molecule":J||O||"text"," ","| ",d.size.toLocaleString()," bytes",d.truncated?t.jsxs("span",{className:"ml-2 text-amber-500",children:["showing ",d.nextOffset.toLocaleString()," bytes"]}):null]}),X||ee?t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[X&&!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,ee?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),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(P.X,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:()=>void U(),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),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(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:D=>b(D.currentTarget.value),spellCheck:!1,"aria-label":"Workspace file editor",className:"thread-graph-file-editor min-h-0 flex-1 resize-none border-0 bg-transparent p-4 font-mono text-[12px] leading-5 text-slate-900 outline-none dark:text-slate-100"}):X&&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: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||Q?"min-h-0 flex-1 overflow-hidden":"min-h-0 flex-1 overflow-auto p-3",children:_}):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 w=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:w,...i?{onCopyPath:i}:{},...l?{onDownload:l}:{},...h?{onPreview:h}:{},onSelect:u,onToggle:p,selectedNodeId:j}),w.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(W=>W.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,w]=c.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 639px)").matches?"viewer":null),[v,y]=c.useState(null),[C,N]=c.useState(!1),[E,_]=c.useState(()=>new Set),[M,J]=c.useState(!1),[O,X]=c.useState(!1),[K,R]=c.useState(!1),[ee,Q]=c.useState([]),[A,ie]=c.useState(null),[U,D]=c.useState(null),[G,T]=c.useState(null),[B,$]=c.useState(!1),L=c.useRef(null),S=c.useRef(null),H=c.useRef(0),F=c.useRef(null),le=!!l,Y=(g?u.get(g):null)??f??null,de={threadId:r.thread.id,workspaceId:r.workspace.id??r.thread.workspaceId??null};c.useEffect(()=>{H.current=0,F.current=null,b(new Set(["","artifacts","thread-events","live",...pu(de),...ts((f==null?void 0:f.path)??"")]))},[de.threadId,de.workspaceId]);function te(){var W;const I=((W=S.current)==null?void 0:W.scrollTop)??H.current;H.current=I,F.current=I}function we(){const I=F.current??H.current;if(!S.current)return;let oe=0;const ge=()=>{const Se=S.current;Se&&(Se.scrollTop=Math.min(I,Math.max(0,Se.scrollHeight-Se.clientHeight)),H.current=Se.scrollTop,oe+=1,oe<8?window.requestAnimationFrame(ge):F.current=null)};window.requestAnimationFrame(ge)}c.useLayoutEffect(()=>{k!=="explorer"&&we()},[k,m]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const I=window.matchMedia("(max-width: 639px)"),W=()=>$(I.matches);return W(),typeof I.addEventListener=="function"?(I.addEventListener("change",W),()=>I.removeEventListener("change",W)):(I.addListener(W),()=>I.removeListener(W))},[]);async function ke(I){if(!l)return;const W=I??(Y==null?void 0:Y.path)??null;N(!0),y(null);try{const oe=nr(await l.listTree({...de,path:""}));let ge=i?Yn(oe,i):oe;if(i){const Ie=[...j].filter(he=>he).sort((he,He)=>he.split("/").length-He.split("/").length);for(const he of Ie){const He=Un(i,he);if((He==null?void 0:He.kind)!=="directory"||!He.childrenLoaded)continue;const Ue=nr(await l.listTree({...de,path:he}));ge=Xn(ge,he,Yn(Ue,He))}}d(ge);const Se=qo(ge);x(Ie=>{var He;const he=W??(Ie?(He=u.get(Ie))==null?void 0:He.path:null);return he&&qn(ge,he)?`workspace:${he}`:(Se==null?void 0:Se.id)??Ie})}catch(oe){y(oe instanceof Error?oe.message:"Failed to load workspace"),d(null)}finally{N(!1)}}async function xe(I){if(!(!l||!i)){_(W=>{if(W.has(I))return W;const oe=new Set(W);return oe.add(I),oe}),y(null);try{const W=nr(await l.listTree({...de,path:I}));d(oe=>oe&&Xo(oe,I,W.children,{truncated:W.truncated}))}catch(W){y(W instanceof Error?W.message:"Failed to load directory")}finally{_(W=>{if(!W.has(I))return W;const oe=new Set(W);return oe.delete(I),oe})}}}async function Re(I){const W=Ch(I,r.workspace.absPath);if(!W)return;const oe=Sh(W);if(w(null),b(ge=>{const Se=new Set(ge);Se.add("");for(const Ie of oe)Se.add(Ie);return is(de,Se),Se}),!l){qn(m,W)&&x(`workspace:${W}`);return}N(!0),y(null);try{let ge=i??nr(await l.listTree({...de,path:""}));for(const Se of oe){const Ie=Un(ge,Se);if((Ie==null?void 0:Ie.kind)==="directory"&&Ie.childrenLoaded)continue;const he=nr(await l.listTree({...de,path:Se}));ge=Xn(ge,Se,he)}d(ge),x(`workspace:${W}`)}catch(ge){y(ge instanceof Error?ge.message:`Failed to open ${W}`)}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)&&xe(I.path)},[i,j,u,l]),c.useEffect(()=>{d(null),_(new Set),ie(null),D(null),T(null),y(null),ke()},[le,r.thread.id,r.workspace.id,r.thread.workspaceId]),c.useEffect(()=>{o&&Re(o.path)},[o==null?void 0:o.requestId]),c.useEffect(()=>{l!=null&&l.subscribeWorkspaceChanged},[l,de.threadId,de.workspaceId]),c.useEffect(()=>{const I=l&&(Y==null?void 0:Y.kind)==="file"?Y.path:null;if(!I){ie(null),D(null),T(null);return}const W=I;let oe=!1;async function ge(){var Se;if(l){J(!0),y(null),ie(null),D(null),T(null);try{const Ie=Mr(W),he=(Se=l.getRawFileUrl)==null?void 0:Se.call(l,{...de,path:W});if(he&&Zo.has(Ie)){oe||D(he);return}if(he&&Jo.has(Ie)){oe||T(he);return}const He=await l.readFile({...de,path:W,limit:qr});oe||ie(He)}catch(Ie){oe||y(Ie instanceof Error?Ie.message:"Failed to read file")}finally{oe||J(!1)}}}return ge(),()=>{oe=!0}},[l,Y==null?void 0:Y.id]);async function me(){if(!(!l||!(A!=null&&A.truncated))){X(!0);try{const I=await l.readFile({...de,path:A.path,offset:A.nextOffset,limit:qr});ie(W=>W&&{...W,content:W.content+I.content,truncated:I.truncated,nextOffset:I.nextOffset,size:I.size})}finally{X(!1)}}}async function se(I){if(!(l!=null&&l.writeFile))return;y(null),await l.writeFile({...de,path:I.path,content:I.content}),await ke(I.path);const W=await l.readFile({...de,path:I.path,limit:qr});ie(W)}async function Le(I){if(!(!(l!=null&&l.uploadFile)||!I)){N(!0),y(null);try{const W=await l.uploadFile({...de,path:I.name,file:I}),oe=W.kind==="archive"?W.paths[0]??null:W.file.path;await ke(oe)}catch(W){y(W instanceof Error?W.message:"Failed to upload file")}finally{N(!1)}}}async function Z(I){var oe;const W=(oe=I.target.files)==null?void 0:oe[0];I.target.value="",W&&await Le(W)}function ce(){if(!(l!=null&&l.uploadFile))return;const I=()=>{var W;return(W=L.current)==null?void 0:W.click()};if(l.pickUploadFile){l.pickUploadFile({...de,defaultPick:I,upload:Le});return}I()}function je(I){var W;(W=l==null?void 0:l.downloadNode)==null||W.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 W=r.workspace.absPath.replace(/\/+$/,""),oe=I.path.startsWith("/")?I.path:W?`${W}/${I.path.replace(/^\/+/,"")}`:I.path;navigator.clipboard.writeText(oe).catch(ge=>{y(ge instanceof Error?ge.message:"Failed to copy file path")})}function $e(I){I.kind==="file"&&(te(),x(I.id),w("explorer"))}async function Ge(){if(l!=null&&l.emptyGarbage){if(y(null),!l.listGarbage){Q([]),R(!0);return}try{const I=await l.listGarbage(de);Q(I.map(W=>`garbage/${W}`))}catch(I){Q([]),y(I instanceof Error?I.message:"Failed to list garbage files")}finally{R(!0)}}}async function _e(){if(l!=null&&l.emptyGarbage){R(!1),y(null);try{await l.emptyGarbage(de),await ke((Y==null?void 0:Y.path)??null)}catch(I){y(I instanceof Error?I.message:"Failed to empty garbage")}}}const We={onCopyPath:Ne,...l!=null&&l.downloadNode?{onDownload:je}:{},...l!=null&&l.emptyGarbage?{onEmptyGarbage:Ge}:{},...l?{onRefresh:()=>void ke((Y==null?void 0:Y.path)??null)}:{},...l!=null&&l.uploadFile?{onUpload:ce}:{}};function V(I){if(!I)return;const W=u.get(`workspace:${I}`),oe=(W==null?void 0:W.kind)==="directory"&&W.hasChildren&&!W.childrenLoaded&&!E.has(I);b(ge=>{const Se=new Set(ge);return Se.has(I)?Se.delete(I):Se.add(I),is(de,Se),Se}),!j.has(I)&&oe&&xe(I)}const fe=t.jsx(gu,{canEmptyGarbage:!!(l!=null&&l.emptyGarbage),canUpload:!!(l!=null&&l.uploadFile),onCollapse:()=>{te(),w("explorer")},expandedPaths:j,loadingPaths:E,loading:C,explorerScrollTopRef:H,explorerScrollerRef:S,...We,onPreview:$e,onSelect:I=>{x(I)},onToggle:V,selectedNodeId:(Y==null?void 0:Y.id)??null,tree:m,liveNodes:p}),ye=t.jsx(cu,{error:v,imageUrl:U,loadingMore:O,onOpenWorkspaceFile:I=>{Re(I)},onLoadMore:me,...l!=null&&l.writeFile?{onSaveFile:se}:{},onCollapse:()=>{te(),w("viewer")},pdfUrl:G,previewFile:A,previewLoading:M,plugins:a,...l!=null&&l.getRawFileUrl?{resolveWorkspaceFileUrl:I=>{var W;return((W=l.getRawFileUrl)==null?void 0:W.call(l,{...de,path:I}))??null}}:{},selectedTarget:du(Y),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:ye}):k==="viewer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:fe}):t.jsxs("div",{"data-testid":"workspace-panel",className:"flex h-full min-h-0 w-full overflow-hidden bg-transparent p-2",children:[K?t.jsx(uu,{files:ee,onCancel:()=>R(!1),onConfirm:()=>void _e()}):null,B?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:fe})}),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:ye})})]}):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:fe})}),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:ye})})]}),t.jsx("input",{ref:L,type:"file","aria-label":"Workspace upload file input","data-testid":"workspace-upload-file-input",className:"hidden",onChange:I=>void Z(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,w=d*(b+k)+m,v=h*(-b+k)+u;return{x:w,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?Ft.Left:o>=a+(e.measured.width??1)-1?Ft.Right:l<=s+1?Ft.Top:l>=n.y+(e.measured.height??1)-1?Ft.Bottom:Ft.Top}function 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 w=(b<<5)-b+k.charCodeAt(0);return w&w},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 w=p.get(b.id),v=p.get(k.id);if(!w||!v)continue;const y=w.x-v.x,C=w.y-v.y,N=Math.sqrt(y*y+C*C)||1,_=(200-N)*.5,M=y/N*_,J=C/N*_;w.vx+=M,w.vy+=J,v.vx-=M,v.vy-=J}h.forEach(x=>{const j=p.get(x.source),b=p.get(x.target);if(!j||!b)return;const k=b.x-j.x,w=b.y-j.y,v=Math.sqrt(k*k+w*w)||1,C=(v-120)*.3,N=k/v*C,E=w/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:Ft.Top,isConnectable:p,style:{opacity:0,pointerEvents:"none"}}),t.jsx(Ma,{type:"source",position:Ft.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 y=new Map;for(const C of g)y.set(C.kind,(y.get(C.kind)??0)+1);return[...y.entries()].sort((C,N)=>N[1]-C[1])},[g]),j=n.getThreadPanels(),b=Math.max(...x.map(([,y])=>y),1),k=c.useMemo(()=>Du(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:P.BarChart2}),h.guide&&y.push({id:"guide",label:"Guide",icon:P.BookOpen}),y},[h.guide,h.toolUsage,h.workspace]),v=c.useMemo(()=>{const y=[];return h.threadGraph&&y.push({id:"graph",label:"Thread graph",icon:P.GitBranch}),h.extensions&&y.push({id:"extensions",label:"Remote Codex extensions",icon:P.Wrench}),y},[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:[w.map(y=>{const C=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:[C?t.jsx(C,{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 C=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(C,{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(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(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(ar,{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(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,
10
+ `).join("")}function Qh(e){if(!e)return{format:"xyz",frames:[],exportContent:""};if(typeof e=="string"){const s=ns([e],"xyz");return{frames:s,format:"xyz",exportContent:as(s)}}const r=Zh(e.format),n=e.content.filter(s=>s.trim().length>0);return{frames:ns(n,r),format:r,exportContent:as(n)}}var eu=Oe({"src/components/graph-workspace/GraphMoleculeViewerData.ts"(){}});function tu({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),[x,j]=c.useState(null),[b,k]=c.useState(!1),[y,v]=c.useState({}),[w,C]=c.useState([]),[N,E]=c.useState({}),[R,_]=c.useState(!1),[Y,W]=c.useState(!1),[re,F]=c.useState(null),A=c.useMemo(()=>Qh(s),[s]),J=A.frames,Z=A.format,M=J[f]??null,ie=J.length>0&&f===J.length-1,O=r??"current",G=Object.values(N).reduce((L,S)=>L+S.length,0),H=Object.keys(N).length;c.useEffect(()=>{if(J.length===0){g(0);return}g(J.length-1)},[J.length]),c.useEffect(()=>{if(!b||J.length<=1)return;const L=window.setInterval(()=>{g(S=>S>=J.length-1?(window.clearInterval(L),k(!1),S):S+1)},200);return()=>window.clearInterval(L)},[b,J.length]),c.useEffect(()=>{const L=l.current;if(!L||i.current)return;let S=!1;try{const B=document.createElement("canvas");if(!(B.getContext("webgl2")||B.getContext("webgl")||B.getContext("experimental-webgl"))){F("WebGL is unavailable in this browser environment. Unable to render 3D viewer.");return}}catch{F("WebGL is unavailable in this browser environment. Unable to render 3D viewer.");return}const U=()=>{var B,le;(B=i.current)==null||B.resize(),(le=i.current)==null||le.render()};return Xh().then(B=>{if(!(S||i.current))try{const le=B.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),F("Failed to initialize 3D viewer. Please refresh or try another browser.")}}).catch(B=>{console.error("Failed to load 3Dmol viewer runtime:",B),F("Failed to load 3D viewer runtime. Please refresh or try another browser.")}),()=>{S=!0,window.removeEventListener("resize",U),i.current=null,d.current=null}},[]),c.useEffect(()=>{const L=i.current;if(!(!L||!M))try{L.removeAllModels(),L.removeAllShapes(),L.removeAllLabels();const S=L.addModel(M,Z||"xyz");d.current=S,S.setStyle({},{stick:{radius:.2},sphere:{scale:.3}});const U=S.getCrystData(),B=!!(U&&typeof U=="object"&&Object.keys(U).length);_(B),W(B?m.current:!1),C([]),v({});const le=M.split(`
11
+ `).slice(2).map(K=>K.trim()).filter(Boolean).map(K=>K.split(/\s+/)[0]??"Atom");h.current||(L.zoomTo(),h.current=!0),S.setClickable({},!0,(K,de,ee)=>{const ve=K.serial??K.index;if(ve===void 0)return;const be=K.atom||K.elem||le[ve]||"Atom";C(ye=>{const fe=!!(ee!=null&&ee.shiftKey||ee!=null&&ee.metaKey||ee!=null&&ee.ctrlKey)?ye.includes(ve)?ye.filter(Te=>Te!==ve):[...ye,ve]:ye.length===1&&ye[0]===ve?[]:[ve];return v(Te=>{if(fe.length===0)return{};const oe={};return fe.forEach(Q=>{oe[Q]=Te[Q]||le[Q]||be}),oe}),fe})}),S.setHoverable({},!0,(K,de,ee)=>{!ee||!K||j({x:ee.clientX,y:ee.clientY,label:`${K.atom||K.elem||"Atom"} (${K.serial??K.index??"?"})`,coords:{x:K.x.toFixed(2),y:K.y.toFixed(2),z:K.z.toFixed(2)}})},()=>j(null)),L.render()}catch(S){console.error("Failed to render molecule:",S),F("Unable to render this molecular structure.")}},[M,Z]),c.useEffect(()=>{const L=i.current,S=d.current;if(!(!L||!S)){try{L.removeUnitCell(S)}catch{}if(Y&&R)try{L.addUnitCell(S,{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{_(!1),W(!1)}L.render()}},[R,Y,M,Z]),c.useEffect(()=>{const L=i.current,S=d.current;!L||!S||!M||(S.setStyle({},{stick:{radius:.2},sphere:{scale:.3}}),w.length>0&&S.setStyle({serial:w},{stick:{radius:.3,color:"yellow"},sphere:{scale:.4,color:"yellow"}}),L.render(),a==null||a({moleculeId:r,atoms:w}))},[r,a,w,M]),c.useEffect(()=>{if(!M)return;let L=0;const S=()=>{var B,le;const U=(le=(B=i.current)==null?void 0:B.getView)==null?void 0:le.call(B);if(Array.isArray(U)&&U.length>=8){const[K,de,ee,ve,be,ye,we,fe]=U;if(typeof K=="number"&&typeof de=="number"&&typeof ee=="number"&&typeof ve=="number"&&typeof be=="number"&&typeof ye=="number"&&typeof we=="number"&&typeof fe=="number"){const Te=Math.sqrt(be*be+ye*ye+we*we),oe=Te>0?{x:be/Te,y:ye/Te,z:we/Te}:{x:0,y:0,z:0};p({position:{x:K,y:de,z:ee,qx:be,qy:ye,qz:we,qw:fe},lookAt:oe,zoom:ve})}}L=window.requestAnimationFrame(S)};return L=window.requestAnimationFrame(S),()=>window.cancelAnimationFrame(L)},[M]);const T=c.useCallback(async()=>{const L=i.current;if(!(L!=null&&L.pngURI))return;L.render();const S=L.pngURI();if(S){try{const B=await(await fetch(S)).blob(),le=new ClipboardItem({[B.type||"image/png"]:B});await navigator.clipboard.write([le])}catch{}n==null||n({moleculeId:r,image:S})}},[r,n]);function $(){R&&W(L=>{const S=!L;return m.current=S,S})}function D(){w.length!==0&&E(L=>{const S=L[O]??[];return{...L,[O]:Array.from(new Set([...S,...w]))}})}return t.jsxs("div",{className:`thread-graph-molecule-viewer flex h-full min-h-0 flex-col bg-white ${e}`,children:[t.jsxs("div",{className:"thread-graph-molecule-header flex shrink-0 items-center justify-between gap-3 border-b border-slate-200 px-3 py-2 sm:px-4 sm:py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"truncate text-sm font-semibold text-slate-900",children:o}),t.jsx("p",{className:"mt-1 hidden text-[11px] text-slate-400 sm:block",children:"cartoon + surface"})]}),t.jsx("span",{className:"shrink-0 text-[11px] text-slate-400",children:"workspace preview"})]}),t.jsxs("div",{className:"thread-graph-molecule-body min-h-0 flex-1",children:[t.jsxs("div",{ref:l,"data-testid":"molecule-viewer",className:"thread-graph-molecule-stage relative min-h-0 flex-1 overflow-hidden",children:[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&&!M?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,x?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:x.x-20,top:x.y-50},children:[t.jsx("div",{className:"mb-0.5 font-semibold text-gray-900",children:x.label}),t.jsxs("div",{className:"space-x-2 text-gray-600",children:[t.jsxs("span",{children:["x: ",x.coords.x]}),t.jsxs("span",{children:["y: ",x.coords.y]}),t.jsxs("span",{children:["z: ",x.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(Uh,{currentIndex:f,exportContent:A.exportContent,moleculeId:r,onScreenshot:()=>void T(),viewerRef:i,xyzContent:M,xyzFormat:Z})]}),J.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," / ",J.length,t.jsx(Er,{type:"button",variant:"ghost",size:"icon",className:"thread-graph-molecule-button h-5 w-5",onClick:()=>{k(L=>{const S=!L;return S&&f===J.length-1&&g(0),S})},"aria-label":b?"Pause trajectory":"Play trajectory",title:b?"Pause trajectory":"Play trajectory",children:b&&f!==J.length-1?t.jsx(P.Pause,{className:"h-3 w-3"}):t.jsx(P.Play,{className:"h-3 w-3"})})]}),t.jsxs(Er,{type:"button",variant:"ghost",onClick:()=>g(J.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(Kh,{value:[f],max:J.length-1,step:1,onValueChange:L=>g(L[0]??0),"aria-label":"Trajectory frame"})]}):null,t.jsx(Oh,{cameraInfo:u,onClearSelection:()=>C([]),onClearStaged:()=>E({}),onSendSelection:()=>a==null?void 0:a({moleculeId:r,atoms:w}),onSendStaged:()=>{Object.entries(N).forEach(([L,S])=>{a==null||a({moleculeId:L==="current"?r:L,atoms:S})})},onStageSelection:D,onToggleUnitCell:$,selectedAtomLabels:y,selectedSerials:w,stagedAtoms:G,stagedMolecules:H,unitCellAvailable:R,unitCellVisible:Y})]})]})]})}var ru=Oe({"src/components/graph-workspace/GraphMoleculeViewer.tsx"(){Wh(),Vh(),qh(),cn(),Yh(),eu()}});function ss(e){return e.replace(/background-color:[^;"]+;?/g,"background-color: transparent;").replace(/background:[^;"]+;?/g,"background: transparent;")}function nu(e){try{return decodeURIComponent(e)}catch{return e}}function os(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 au({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=nu(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 x=l&&(i===l||i.startsWith(`${l}/`))?i.slice(l.length):i;return os(x)}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 os(f?`${f}/${o}`:o)}function su(e){return!e.truncated&&e.size<=al&&e.content.split(`
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,
15
15
  .thread-graph-dialog {
16
16
  color-scheme: light;
17
17
  --radius: 0.625rem;
@@ -1074,6 +1074,9 @@ 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
1074
1074
  .thread-ui-shell[data-thread-layout=desktop] .thread-shell-frame.is-rail-collapsed {
1075
1075
  grid-template-columns: 56px minmax(0, 1fr);
1076
1076
  }
1077
+ .thread-ui-shell[data-thread-layout=desktop] .thread-shell-frame.is-rail-hidden {
1078
+ grid-template-columns: minmax(0, 1fr);
1079
+ }
1077
1080
  .thread-ui-shell[data-thread-layout=desktop] .thread-rooms-rail {
1078
1081
  position: static;
1079
1082
  z-index: auto;
@@ -1166,6 +1169,9 @@ 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
1166
1169
  .thread-ui-shell:not([data-thread-layout=mobile]) .thread-shell-frame.is-rail-collapsed {
1167
1170
  grid-template-columns: 56px minmax(0, 1fr);
1168
1171
  }
1172
+ .thread-ui-shell:not([data-thread-layout=mobile]) .thread-shell-frame.is-rail-hidden {
1173
+ grid-template-columns: minmax(0, 1fr);
1174
+ }
1169
1175
  .thread-ui-shell:not([data-thread-layout=mobile]) .thread-rooms-rail {
1170
1176
  position: static;
1171
1177
  z-index: auto;
@@ -3939,20 +3945,20 @@ url = ${JSON.stringify(r.trim())}
3939
3945
  `).concat(`
3940
3946
  `)}const m=a.trimEnd();return m?`${m}
3941
3947
 
3942
- ${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 Gt({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 Ot(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+=Ot(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+=Ot(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=Ot(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=Ot(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,Ot(d).length);l+=Ot(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=Ot(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();Rt();function Rm({className:e,...r}){return t.jsx("div",{"data-slot":"input-group",role:"group",className:nt("group/input-group relative flex w-full min-w-0 items-center rounded-md border shadow-xs outline-none transition-[color,box-shadow]","h-9 has-[>textarea]:h-auto","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col",e),...r})}var _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:nt(_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 Ct({className:e,type:r="button",variant:n="ghost",size:a="xs",...s}){return t.jsx(Er,{type:r,"data-size":a,variant:n,className:nt(Am({size:a}),e),...s})}function $m({className:e,...r}){return t.jsx("span",{className:nt("flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*=size-])]:size-4",e),...r})}function 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:w,toolbarSlot:v,goalSlot:y,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}),w,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]}),y,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(Ct,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Add attachment",title:"Add attachment",onClick:s,className:`${r} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx(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:w,modelControlsDisabled:v,effortControlsDisabled:y,effortControlTitle:C,inlineToggleClassName:N,menuItemClassName:E,planToggleActiveClassName:_,sendButtonBaseClassName:M,onSetOpenMenu:J,onUpdateSettings:O}){var ee;const[X,K]=c.useState(null),R=(((ee=a.find(Q=>Q.model===r))==null?void 0:ee.displayName)||r||"Select model").replace(/\s+\([^)]+\)\s*$/,"");return t.jsxs(t.Fragment,{children:[n?t.jsx(Ct,{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(Ct,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="model","aria-label":`Model and effort: ${R}, ${Gr(l)}`,disabled:v||a.length===0,onClick:()=>{K(null),J(Q=>Q==="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:[R," · ",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:()=>K("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:R}),t.jsx(P.ChevronRight,{className:"h-3.5 w-3.5 shrink-0"})]})]}),t.jsxs("button",{type:"button",disabled:y,title:C,onClick:()=>K("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"})]})]}),X==="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(Q=>{const A=Q.model===r;return t.jsxs("button",{type:"button",onClick:()=>{const ie=l&&Q.supportedReasoningEfforts.some(U=>U.reasoningEffort===l)?l:Q.defaultReasoningEffort;O({model:Q.model,reasoningEffort:ie}),J(()=>null)},className:`${E} flex w-full items-center justify-between rounded-lg px-3 py-2 text-left ${A?"ui-status-warning":"text-stone-300"}`,children:[t.jsx("span",{className:"truncate text-sm font-medium",children:Q.displayName||Q.model}),A?t.jsx(P.Check,{className:"h-3.5 w-3.5 shrink-0"}):null]},Q.id)})})]}):null,X==="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(Q=>{const A=Q.reasoningEffort===l;return t.jsxs("button",{type:"button",onClick:()=>{O({reasoningEffort:Q.reasoningEffort}),J(()=>null)},className:`${E} flex w-full items-center justify-between rounded-lg px-3 py-2 text-left ${A?"ui-status-warning":"text-stone-300"}`,children:[t.jsx("span",{className:"text-sm font-medium",children:Gr(Q.reasoningEffort)}),A?t.jsx(P.Check,{className:"h-3.5 w-3.5"}):null]},Q.reasoningEffort)}),i.some(Q=>Q.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(Ct,{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:()=>J(Q=>Q==="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(Q=>t.jsx("button",{type:"button",onClick:()=>O({sandboxMode:Q.mode}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${Q.mode===h?"ui-status-warning":`${E} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:Q.label})},Q.mode))})})]}),m&&t.jsx(Ct,{type:"button",variant:"ghost",size:"xs","aria-pressed":d==="plan",disabled:p,onClick:()=>O({collaborationMode:d==="plan"?"default":"plan"}),className:`${N} rounded-full px-2.5 ${d==="plan"?`${_} border !border-[oklch(0.78_0.16_86_/_0.76)] !bg-[oklch(0.44_0.095_82_/_0.72)] !text-[oklch(0.96_0.055_92)] shadow-[0_0_0_1px_oklch(0.78_0.16_86_/_0.24),0_0_18px_oklch(0.78_0.16_86_/_0.42),inset_0_0_0_1px_oklch(0.98_0.04_96_/_0.18)]`:"text-stone-500"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Plan"}),t.jsx(Ct,{type:"submit",variant:"default",size:"icon-xs","aria-label":f?"Set goal":"Send Prompt",title:k,disabled:g||(x==="chat"?j:!1),className:`${M} 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 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(Gt,{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(Gt,{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(Gt,{label:"CTRL-D"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("esc"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Gt,{label:"ESC"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("tab"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Gt,{label:"TAB"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("up"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Gt,{label:"UP"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>o("down"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Gt,{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:w,onSetHookEventName:v,onSetHookMatcher:y,onSetHookCommand:C,onSetHookTimeoutSec:N,onSetHookStatusMessage:E,onSaveHook:_,onStartEditingHook:M,onTrustHook:J,onUntrustHook:O}){var X,K,R,ee,Q;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:((X=r.data)==null?void 0:X.projectHooksPath)??"<workspace hooks config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:A=>{A.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:A=>w(A.target.value),disabled:e==="edit",className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-2.5 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50",children:[t.jsx("option",{value:"project",children:"Project"}),t.jsx("option",{value:"global",children:"Global"})]})]}),t.jsxs("label",{className:"block text-xs text-stone-400",children:["Event",t.jsx("select",{"aria-label":"Hook event",value:h,onChange:A=>v(A.target.value),className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-2.5 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50",children:rn.map(A=>t.jsx("option",{value:A.value,children:A.label},A.value))})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"Matcher"}),t.jsx("input",{"aria-label":"Hook matcher",value:m,onChange:A=>y(A.target.value),placeholder:"Bash",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"Command"}),t.jsx("textarea",{"aria-label":"Hook command",value:u,onChange:A=>C(A.target.value),rows:3,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 font-mono text-xs text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("label",{className:"block text-xs text-stone-400",children:["Timeout",t.jsx("input",{"aria-label":"Hook timeout seconds",value:p,onChange:A=>N(A.target.value),inputMode:"numeric",className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50"})]}),t.jsxs("label",{className:"block text-xs text-stone-400",children:["Status message",t.jsx("input",{"aria-label":"Hook status message",value:f,onChange:A=>E(A.target.value),className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50"})]})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>{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 _(),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"&&((K=r.data)!=null&&K.warnings.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.warnings.map(A=>t.jsx("p",{className:"rounded-xl border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-100/85",children:A},A))}):null,e==="list"&&((R=r.data)!=null&&R.errors.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.errors.map(A=>t.jsxs("div",{className:"rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-2 text-xs text-rose-100/90",children:[t.jsx("p",{className:"font-medium",children:A.message}),t.jsx("p",{className:"mt-1 break-all text-rose-100/60",children:A.path})]},`${A.path}:${A.message}`))}):null,e==="list"&&((ee=r.data)!=null&&ee.hooks.length)?t.jsx("div",{className:"space-y-2",children:r.data.hooks.map(A=>t.jsxs("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("p",{className:"truncate text-sm font-medium text-stone-100",children:[gm(A.eventName),A.matcher?` · ${A.matcher}`:""]}),t.jsx("p",{className:"mt-0.5 truncate font-mono text-[11px] text-stone-400",children:A.command??A.handlerType}),A.statusMessage?t.jsx("p",{className:"mt-1 truncate text-[11px] text-stone-500",children:A.statusMessage}):null]}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.08em] text-stone-500",children:[jl(A)?t.jsx("button",{type:"button",onClick:ie=>{ie.stopPropagation(),M(A)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-sky-100 transition hover:border-sky-300/35 hover:bg-sky-300/10`,children:"Edit"}):null,a&&A.trustStatus==="trusted"&&!A.isManaged?t.jsx("button",{type:"button",disabled:s,onClick:ie=>{ie.stopPropagation(),O(A)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-amber-100 transition hover:border-amber-300/35 hover:bg-amber-300/10 disabled:cursor-not-allowed disabled:opacity-50`,children:"Untrust"}):null,(A.trustStatus==="untrusted"||A.trustStatus==="modified")&&!A.isManaged&&a?t.jsx("button",{type:"button",disabled:s||!A.currentHash,onClick:ie=>{ie.stopPropagation(),J(A)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-emerald-100 transition hover:border-emerald-300/35 hover:bg-emerald-300/10 disabled:cursor-not-allowed disabled:opacity-50`,children:"Trust"}):null,t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-0.5 text-stone-300",children:bm(A.trustStatus)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.14em] text-stone-500",children:[t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:xm(A.source)}),t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:A.enabled?"Enabled":"Disabled"}),t.jsxs("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:[A.timeoutSec,"s"]})]})]},A.key))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((Q=r.data)==null?void 0:Q.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: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: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 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(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&&(((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 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:w,hookEventName:v,hookMatcher:y,hookCommand:C,hookTimeoutSec:N,hookStatusMessage:E,mcpPanelMode:_,mcpState:M,mcpConfigEditing:J,mcpConfigPath:O,mcpConfigError:X,mcpConfigSuccess:K,mcpConfigBusy:R,mcpHttpName:ee,mcpHttpUrl:Q,mcpRawBlock:A,iconButtonClassName:ie,menuClassName:U,menuItemClassName:D,panelButtonClassName:G,chipButtonClassName:T,onToggle:B,onToolboxItemClick:$,toolboxItemDisabled:L,toolboxItemClassName:S,toolboxItemStatus:H,onSetSlashPanelView:F,onViewGoals:le,onUpdateGoal:Y,onOpenForkTurns:de,onForkLatest:te,onForkTurn:we,onCopySkillInvokeName:ke,onResetHookForm:xe,onSetHooksPanelMode:Re,onClearHookConfigStatus:me,onSetEditingHookTarget:se,onSetHookScope:Le,onSetHookEventName:Z,onSetHookMatcher:ce,onSetHookCommand:je,onSetHookTimeoutSec:Ne,onSetHookStatusMessage:$e,onSaveHook:Ge,onStartEditingHook:_e,onTrustHook:We,onUntrustHook:V,onSetMcpPanelMode:fe,onClearMcpConfigStatus:ye,onSetMcpHttpName:I,onSetMcpHttpUrl:W,onSetMcpRawBlock:oe,onPrepareRawMcpBlock:ge,onSaveHttpMcp:Se,onSaveRawMcpBlock:Ie}){return t.jsxs("div",{className:"relative",children:[t.jsx(Ct,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Open slash toolbox",title:"Open slash toolbox",onClick:B,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:`${U} 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:he=>{he.stopPropagation()},onMouseDown:he=>{he.stopPropagation()},onPointerDown:he=>{he.stopPropagation()},onTouchStart:he=>{he.stopPropagation()},children:r==="root"?t.jsxs("div",{className:"p-2",children:[n.map((he,He)=>he.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:he.description??he.label,children:[t.jsx("button",{type:"button",disabled:L(he),onClick:()=>{F("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:he.command})}),t.jsx("button",{type:"button",disabled:L(he),onClick:Ue=>$(he,Ue),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"})]},`${he.action}:${he.command}`):t.jsx("button",{type:"button",disabled:L(he),onClick:Ue=>$(he,Ue),className:`${S(he)} ${He===0?"mt-0":""}`,title:he.description??he.label,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:he.command}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:H(he)})]})},`${he.action}:${he.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:()=>F("root"),onUpdateGoal:Y}):r==="fork"?t.jsx(qm,{busy:a,forkBusy:s,composerMenuItemClassName:D,onForkLatest:te,onSelectForkTurnPanel:()=>(F("forkTurns"),de())}):r==="forkTurns"?t.jsx(Km,{forkTurnOptionsState:o,forkBusy:s,composerPanelButtonClassName:G,onForkTurn:we}):r==="skills"?t.jsx(rp,{skillsState:l,copiedSkillName:m,composerChipButtonClassName:T,onCopySkillInvokeName:ke}):r==="hooks"?t.jsx(Ym,{hooksPanelMode:u,hooksState:p,hostConfigFilesAvailable:f,hookTrustAvailable:g,hookConfigBusy:x,hookConfigError:j,hookConfigSuccess:b,editingHookTarget:k,hookScope:w,hookEventName:v,hookMatcher:y,hookCommand:C,hookTimeoutSec:N,hookStatusMessage:E,composerChipButtonClassName:T,onResetHookForm:xe,onSetHooksPanelMode:Re,onClearHookConfigStatus:me,onSetEditingHookTarget:se,onSetHookScope:Le,onSetHookEventName:Z,onSetHookMatcher:ce,onSetHookCommand:je,onSetHookTimeoutSec:Ne,onSetHookStatusMessage:$e,onSaveHook:Ge,onStartEditingHook:_e,onTrustHook:We,onUntrustHook:V}):t.jsx(tp,{mcpPanelMode:_,mcpState:M,mcpConfigEditing:J,mcpConfigPath:O,mcpConfigError:X,mcpConfigSuccess:K,mcpConfigBusy:R,mcpHttpName:ee,mcpHttpUrl:Q,mcpRawBlock:A,composerPanelButtonClassName:G,composerChipButtonClassName:T,onSetMcpPanelMode:fe,onClearMcpConfigStatus:ye,onSetMcpHttpName:I,onSetMcpHttpUrl:W,onSetMcpRawBlock:oe,onPrepareRawMcpBlock:ge,onSaveHttpMcp:Se,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(Ct,{type:"button",variant:"ghost",size:"icon-xs","aria-label":e?"Switch to chat":"Switch to shell",title:e?"Switch to chat":"Switch to shell",onClick:()=>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 w=In(r,n),v=Br(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=Br(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 x=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)},dp)}},[u,g]),j=c.useCallback((w=h.current)=>{x(w,"immediate")},[x]),b=c.useCallback((w,v="immediate")=>{if(u){const y=w(h.current);h.current=y,i(y),x(y,v);return}o(y=>w(y))},[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 y=u.trim(),C=Ju(y);if(y.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]),w=c.useCallback(()=>{m(!1),j(null)},[]);return{goalComposeMode:h,goalTokenBudget:u,goalBusy:f,goalLocalError:x,setGoalTokenBudget:p,submitGoal:b,enterGoalComposeMode:k,exitGoalComposeMode:w}}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,w]=c.useState("Running hook"),[v,y]=c.useState(null),[C,N]=c.useState(!1),[E,_]=c.useState(null),[M,J]=c.useState(null),O=c.useMemo(()=>mp(r),[r]),X=c.useCallback(D=>O.get(D)??O.get("preToolUse")??zn,[O]),K=c.useMemo(()=>new Set([zn,...O.values()]),[O]),R=c.useCallback(()=>{_(null),J(null)},[]);c.useEffect(()=>{e!=="hooks"&&(i("list"),R())},[R,e]),c.useEffect(()=>{const D=rn.find(G=>G.value===m);f(G=>{const T=G.trim(),B=new Set(rn.map($=>$.matcherHint).filter(Boolean));return T&&!B.has(T)?G:(D==null?void 0:D.matcherHint)??""}),x(G=>K.has(G.trim())?X(m):G)},[X,K,m]);const ee=c.useCallback(()=>{y(null),h("project"),u("preToolUse"),f("Bash"),x(X("preToolUse")),b("30"),w("Running hook")},[X]),Q=c.useCallback(D=>{const G=jl(D);if(!G){_("Only command hooks in global or project hooks.json can be edited here.");return}y(G),h(G.scope),u(G.eventName),f(G.matcher??""),x(G.command),b(G.timeoutSec?String(G.timeoutSec):""),w(G.statusMessage??""),_(null),J(null),i("edit")},[]),A=c.useCallback(async()=>{if(l==="edit"&&!a){_("Hook editing is unavailable in this view.");return}if(l!=="edit"&&!n){_("Hook editing is unavailable in this view.");return}if(l==="edit"&&!v){_("Select a hook to edit first.");return}const D=g.trim();if(!D){_("Hook command cannot be empty.");return}const G=j.trim(),T=G?Number(G):null;if(G&&(T===null||!Number.isInteger(T)||T<=0)){_("Timeout must be a positive number of seconds.");return}N(!0),_(null),J(null);try{const B={scope:d,eventName:m,matcher:p.trim()||null,command:D,timeoutSec:T,statusMessage:k.trim()||null};l==="edit"?await(a==null?void 0:a({...B,target:v})):await(n==null?void 0:n(B)),J(`${d==="project"?"Project":"Global"} hook ${l==="edit"?"updated":"written"} in hooks.json and trusted.`),i("list"),y(null)}catch(B){_(B instanceof Error?B.message:"Unable to write hooks.json.")}finally{N(!1)}},[v,g,m,p,d,k,j,l,n,a]),ie=c.useCallback(async D=>{if(!s||!D.currentHash){_("Hook trust is unavailable in this view.");return}N(!0),_(null),J(null);try{await s({key:D.key,currentHash:D.currentHash}),J("Hook trusted.")}catch(G){_(G instanceof Error?G.message:"Unable to trust hook.")}finally{N(!1)}},[s]),U=c.useCallback(async D=>{if(!o){_("Hook trust is unavailable in this view.");return}N(!0),_(null),J(null);try{await o({key:D.key}),J("Hook untrusted.")}catch(G){_(G instanceof Error?G.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:M,setHooksPanelMode:i,setEditingHookTarget:y,setHookScope:h,setHookEventName:u,setHookMatcher:f,setHookCommand:x,setHookTimeoutSec:b,setHookStatusMessage:w,clearHookConfigStatus:R,resetHookForm:ee,startEditingHook:Q,saveHook:A,trustHook:ie,untrustHook:U}}var fp=`[mcp_servers.example_stdio]
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]
3943
3949
  command = "npx"
3944
3950
  args = ["-y", "your-mcp-server"]
3945
- `,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),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 _=await r();return p(_.path),_},[e,r]),y=c.useCallback(async _=>{if(!e||!n)throw new Error("Provider config editing is unavailable for this thread.");const M=await n(_);return p(M.path),M},[e,n]),C=c.useCallback(async()=>{const _=em(o),M=i.trim();if(!_){j("MCP name must use only letters, numbers, underscore, or hyphen.");return}if(!/^https?:\/\//i.test(M)){j("HTTP MCP URL must start with http:// or https://");return}g(!0),j(null),k(null);try{const J=await v(),O=fs(J.content,_,rm(_,M));await y(O),k(ys),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]),N=c.useCallback(async()=>{g(!0),j(null),k(null);try{await v(),m(_=>_||fp),a("stdio")}catch(_){j(_ instanceof Error?_.message:"Unable to load provider config.")}finally{g(!1)}},[v,a]),E=c.useCallback(async()=>{const _=tm(h);if(!_){j("The raw MCP block must start with a header like [mcp_servers.name].");return}g(!0),j(null),k(null);try{const M=await v(),J=fs(M.content,_,h);await y(J),k(ys),a("list"),s==null||s()}catch(M){j(M instanceof Error?M.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:x,mcpConfigSuccess:b,setMcpHttpName:l,setMcpHttpUrl:d,setMcpRawBlock:m,clearMcpConfigStatus:w,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: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&&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: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(Ct,{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:w,onPromptKeyDown:v,onPromptKeyUp:y,onPromptMouseUp:C,onPromptBlur:N,onPromptDragEnter:E,onPromptDragOver:_,onPromptDragLeave:M,onPromptDrop:J,onGoalTokenBudgetChange:O,onCancelGoal:X,onShellPromptChange:K}){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:w,onKeyDown:v,onKeyUp:y,onMouseUp:C,onBlur:N,onDragEnter:E,onDragOver:_,onDragLeave:M,onDrop:J}),goalSlot:m&&!e?t.jsx(wp,{tokenBudget:u,error:p,onTokenBudgetChange:O,onCancel:X}):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:K,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:w,fastMode:v,goalComposeMode:y,goalBusy:C,goalStatus:N,activeView:E,disabled:_,model:M,agentLabel:J,modelOptions:O,modelContextTitle:X,contextUsage:K,reasoningEffort:R,supportedEfforts:ee,displayedCollaborationMode:Q,sandboxMode:A,sendButtonLabel:ie,sendButtonClassName:U,modelControlsDisabled:D,effortControlsDisabled:G,effortControlTitle:T,forkTurnOptionsState:B,skillsState:$,goalState:L,goalHistory:S,copiedSkillName:H,hooksPanelMode:F,hooksState:le,hookConfigBusy:Y,hookConfigError:de,hookConfigSuccess:te,editingHookTarget:we,hookScope:ke,hookEventName:xe,hookMatcher:Re,hookCommand:me,hookTimeoutSec:se,hookStatusMessage:Le,mcpPanelMode:Z,mcpState:ce,mcpConfigPath:je,mcpConfigError:Ne,mcpConfigSuccess:$e,mcpConfigBusy:Ge,mcpHttpName:_e,mcpHttpUrl:We,mcpRawBlock:V,capabilities:fe,shellControlState:ye,onToggleView:I,onDismissPromptFocus:W,onSetOpenMenu:oe,onToolboxItemClick:ge,onSetSlashPanelView:Se,onViewGoals:Ie,onUpdateGoal:he,onOpenForkTurns:He,onForkLatest:Ue,onForkTurn:Fe,onCopySkillInvokeName:at,onResetHookForm:dt,onSetHooksPanelMode:st,onClearHookConfigStatus:rt,onSetEditingHookTarget:Ze,onSetHookScope:ct,onSetHookEventName:pt,onSetHookMatcher:z,onSetHookCommand:q,onSetHookTimeoutSec:ve,onSetHookStatusMessage:Ce,onSaveHook:Me,onStartEditingHook:Ke,onTrustHook:tt,onUntrustHook:Ve,onSetMcpPanelMode:Ae,onClearMcpConfigStatus:lt,onSetMcpHttpName:ft,onSetMcpHttpUrl:ot,onSetMcpRawBlock:ht,onPrepareRawMcpBlock:bt,onSaveHttpMcp:_t,onSaveRawMcpBlock:re,onPickPhoto:ne,onPickFile:be,onUpdateSettings:Xe,onPasteShell:De,onCopyShell:et,onClearShell:St,onShellControl:yt}){const Yt=e?null:{open:s==="slash",slashPanelView:g,availableToolboxItems:x,busy:j,forkBusy:w,forkTurnOptionsState:B,skillsState:$,goalState:L,goalHistory:S,goalBusy:C,copiedSkillName:H,hooksPanelMode:F,hooksState:le,hostConfigFilesAvailable:fe.hostConfigFiles,hookTrustAvailable:fe.hookTrust,hookConfigBusy:Y,hookConfigError:de,hookConfigSuccess:te,editingHookTarget:we,hookScope:ke,hookEventName:xe,hookMatcher:Re,hookCommand:me,hookTimeoutSec:se,hookStatusMessage:Le,mcpPanelMode:Z,mcpState:ce,mcpConfigEditing:fe.mcpConfigEditing,mcpConfigPath:je,mcpConfigError:Ne,mcpConfigSuccess:$e,mcpConfigBusy:Ge,mcpHttpName:_e,mcpHttpUrl:We,mcpRawBlock:V,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:m,onToggle:()=>oe(ut=>ut==="slash"?null:"slash"),onToolboxItemClick:ge,toolboxItemDisabled:ut=>Sm(ut,{settingsBusy:b,compactBusy:k,busy:j,forkBusy:w}),toolboxItemClassName:ut=>Tm(ut,{fastMode:v,goalComposeMode:y,goalStatus:N,menuItemClassName:d}),toolboxItemStatus:ut=>Cm(ut,{fastMode:v,compactBusy:k,goalComposeMode:y,goalStatus:N,busy:j}),onSetSlashPanelView:Se,onViewGoals:Ie,onUpdateGoal:he,onOpenForkTurns:He,onForkLatest:Ue,onForkTurn:Fe,onCopySkillInvokeName:at,onResetHookForm:dt,onSetHooksPanelMode:st,onClearHookConfigStatus:rt,onSetEditingHookTarget:Ze,onSetHookScope:ct,onSetHookEventName:pt,onSetHookMatcher:z,onSetHookCommand:q,onSetHookTimeoutSec:ve,onSetHookStatusMessage:Ce,onSaveHook:Me,onStartEditingHook:Ke,onTrustHook:tt,onUntrustHook:Ve,onSetMcpPanelMode:Ae,onClearMcpConfigStatus:lt,onSetMcpHttpName:ft,onSetMcpHttpUrl:ot,onSetMcpRawBlock:ht,onPrepareRawMcpBlock:bt,onSaveHttpMcp:_t,onSaveRawMcpBlock:re},Mt=e?null:{open:s==="attachments",iconButtonClassName:l,menuClassName:i,menuItemClassName:d,onToggle:()=>oe(ut=>ut==="attachments"?null:"attachments"),onPickPhoto:ne,onPickFile:be},Zt=e?null:{openMenu:s,model:M,agentLabel:J,modelOptions:O,modelContextTitle:X,contextUsage:K,reasoningEffort:R,supportedEfforts:ee,displayedCollaborationMode:Q,sandboxMode:A,planModeAvailable:fe.planMode,sandboxModeAvailable:fe.sandboxMode,settingsBusy:b,goalComposeMode:y,goalBusy:C,activeView:E,disabled:_,fastMode:v,sendButtonLabel:ie,sendButtonClassName:U,modelControlsDisabled:D,effortControlsDisabled:G,effortControlTitle:T,inlineToggleClassName:u,menuItemClassName:d,planToggleActiveClassName:p,sendButtonBaseClassName:f,onSetOpenMenu:oe,onUpdateSettings:Xe};return{isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:s,toolbarClassName:o,iconButtonClassName:l,slashToolboxProps:Yt,attachmentMenuProps:Mt,settingsToolbarProps:Zt,shellToolsPanelProps:s==="shellTools"?{busy:j,shellControlState:ye,onPaste:De,onCopy:et,onClear:St,onShellControl:yt}:null,shellControlState:ye,onToggleView:I,onDismissPromptFocus:W,onSetOpenMenu:oe}}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:w=!1,threadConnected:v=!0,shellAvailable:y=!0,disabled:C=!1,disabledPlaceholder:N,shellControlState:E=null,draftPrompt:_,draftAttachments:M,onPickAttachment:J,skillsState:O={status:"idle",data:null,error:null},mcpState:X={status:"idle",data:null,error:null},hooksState:K={status:"idle",data:null,error:null},goalState:R={status:"idle",data:null,error:null},goalHistory:ee=[],forkTurnOptionsState:Q={status:"idle",data:null,error:null},onDraftChange:A,onSubmit:ie,onInterrupt:U,onCompact:D,onOpenSkills:G,onOpenMcp:T,onOpenHooks:B,onCreateHook:$,onUpdateHook:L,onTrustHook:S,onUntrustHook:H,onOpenGoal:F,onPrepareGoalSubmit:le,onUpdateGoal:Y,onOpenForkTurns:de,onForkLatest:te,onForkTurn:we,onReadProviderConfig:ke,onWriteProviderConfig:xe,onToggleFollow:Re,canJumpToPreviousTurn:me,onJumpToPreviousTurn:se,canJumpToNextTurn:Le,onJumpToNextTurn:Z,subscriptionUsage:ce,onUpdateSettings:je,onToggleView:Ne,onShellCopy:$e,onShellControl:Ge,canInterrupt:_e=!1,pendingPrompts:We=[],onSteerPendingPrompt:V,onCancelPendingPrompt:fe}){var _a;const[ye,I]=c.useState(null),[W,oe]=c.useState("root"),ge=c.useRef(!1),[Se,Ie]=c.useState("list"),he=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)&&!!ke&&!!xe,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,ke,xe]),He=c.useMemo(()=>jm(j,he),[he,j]),Ue=c.useRef(null),Fe=c.useRef(null),at=c.useRef(null),dt=c.useRef(null),st=c.useRef(null),rt=c.useRef([]),Ze=c.useRef(null),ct=c.useRef(""),pt=c.useRef(0),z=e==="shell",q=y||z,ve=!!(z&&(E!=null&&E.isMobileShell)),Ce=(E==null?void 0:E.promptLabel)??null,[Me,Ke]=c.useState(!1),[tt,Ve]=c.useState(0),{prompt:Ae,attachments:lt,isDraftControlled:ft,updateDraft:ot,flushControlledDraftToHost:ht}=cp({isShellView:z,draftPrompt:_,draftAttachments:M,onDraftChange:A}),bt=ip({attachments:lt,isShellView:z}),{displayedCollaborationMode:_t,updateSettings:re}=Sp({collaborationMode:m,onUpdateSettings:je,closeMenu:()=>I(null)}),{forkBusy:ne,forkLatest:be,forkTurn:Xe}=hp({slashPanelView:W,onForkLatest:te,onForkTurn:we,closeMenu:()=>I(null)}),{hooksPanelMode:De,hookScope:et,hookEventName:St,hookMatcher:yt,hookCommand:Yt,hookTimeoutSec:Mt,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:W,hookCommandTemplates:b,onCreateHook:$,onUpdateHook:L,onTrustHook:S,onUntrustHook:H}),{goalComposeMode:fr,goalTokenBudget:hi,goalBusy:xn,goalLocalError:ui,setGoalTokenBudget:mi,submitGoal:pi,enterGoalComposeMode:fi,exitGoalComposeMode:Sa}=up({prompt:Ae,goalTokenBudgetSource:R.data,promptRef:Fe,onOpenGoal:F,onPrepareGoalSubmit:le,onUpdateGoal:Y,updateDraft:ot,closeMenu:()=>I(null),resetSlashPanel:()=>oe("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:he.hostConfigFiles,onReadProviderConfig:ke,onWriteProviderConfig:xe,setMcpPanelMode:Ie,onOpenMcp:T}),{copiedSkillName:Li,copySkillInvokeName:Ii}=xp({openMenu:ye,setOpenMenu:I,slashPanelView:W,setSlashPanelView:oe,setMcpPanelMode:Ie,clearMcpConfigStatus:Ta,clearHookConfigStatus:Ca}),zi=c.useCallback(ae=>{ot(Te=>{if(typeof ae=="function"){const Pe=ae(Te.prompt,Te.attachments);return{prompt:Pe.prompt,attachments:Pe.attachments??Te.attachments}}return{prompt:ae,attachments:Te.attachments}})},[ot]),bn=c.useMemo(()=>f.find(ae=>ae.model===l)??null,[l,f]),Pi=nm(l,g),Ea=(bn==null?void 0:bn.supportedReasoningEfforts)??[],Ri=c.useMemo(()=>Fu(Ae,lt),[lt,Ae]),_i=c.useMemo(()=>Object.entries(bt).sort(([ae],[Te])=>ae.localeCompare(Te)).map(([ae,Te])=>`${ae}:${Te}`).join("|"),[bt]);function Mi(ae,Te){Te.stopPropagation();const Pe=Nm(ae,{fastMode:h,goalComposeMode:fr});switch(Pe.type){case"toggleFast":re({fastMode:Pe.fastMode});break;case"runCompact":I(null),D==null||D();break;case"enterGoalCompose":fi();break;case"exitGoalCompose":Sa(),I(null);break;case"openPanel":oe(Pe.panel),Pe.panel==="skills"?G==null||G():Pe.panel==="mcp"?T==null||T():Pe.panel==="hooks"&&(B==null||B());break;case"insertPrompt":wn(Pe.text),oe("root"),I(null);break}}function Jt(){const ae=Fe.current;return ae?Im(ae):null}const Ai=c.useCallback(ae=>{const Te=Fe.current;!Te||!ae||zm(Te,ae)},[]),vn=c.useCallback(()=>{const ae=Fe.current;return ae?Nl(ae):Ae},[Ae]),{appendAttachments:kn,appendDroppedAttachments:La}=lp({prompt:Ae,attachments:lt,updateDraft:ot,getSelection:Jt,selectionSnapshotRef:Ze,pendingSelectionRef:st,pendingInsertedAttachmentIdsRef:rt,onInserted:()=>I(null)}),Ia=c.useCallback((ae,Te)=>{var Pe;if(At(),J){J({kind:ae,appendAttachments:(Je,it=ae)=>kn(Je,it),defaultPick:()=>{var Je;return(Je=Te.current)==null?void 0:Je.click()}});return}(Pe=Te.current)==null||Pe.click()},[kn,At,J]);function wn(ae){if(!ae)return;const Te=Jt()??Ze.current,Pe=(Te==null?void 0:Te.start)??Ae.length,Je=(Te==null?void 0:Te.end)??Pe,it=Hu(ae),Qt=`${Ae.slice(0,Pe)}${it}${Ae.slice(Je)}`;ot(xd=>({prompt:Qt,attachments:xd.attachments}));const $t=Pe+it.length;st.current={start:$t,end:$t},Ze.current={start:$t,end:$t}}kp({promptRef:Fe,isShellView:z,prompt:Ae,promptSegments:Ri,attachmentPreviewUrls:bt,previewSignature:_i,editorSanitizeNonce:tt,pendingSelectionRef:st,pendingInsertedAttachmentIdsRef:rt,selectionSnapshotRef:Ze,renderedPreviewSignatureRef:ct,renderedSanitizeNonceRef:pt,serializeEditorPrompt:vn,restoreSelection:Ai});function At(){var ae;(ae=Fe.current)==null||ae.blur(),document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.blur()}async function $i(){var ae;if(At(),I(null),!!((ae=navigator.clipboard)!=null&&ae.readText))try{const Te=await navigator.clipboard.readText();wn(Te)}catch{return}}async function za(){if(!ge.current){ge.current=!0;try{if(ft&&ht(),fr&&!z){await pi();return}const ae=Xu({prompt:Ae,attachments:lt,isShellView:z});if(!ae||await ie(ae)===!1)return;ot(()=>({prompt:"",attachments:[]}))}finally{ge.current=!1}}}async function Di(ae){ae.preventDefault(),await za()}function Bi(){const ae=vn(),Te=Jt();Ze.current=Te;const Pe=Fe.current;(Pe?Lm(Pe):!1)&&(st.current=Te,Ve(it=>it+1)),ot(it=>({prompt:ae,attachments:it.attachments.filter(Qt=>ae.includes(Qt.placeholder))}),"deferred")}function Gi(ae){var Je,it,Qt,$t;const Te=Qn((Je=ae.clipboardData)==null?void 0:Je.items,(it=ae.clipboardData)==null?void 0:it.files),Pe=qu({files:Te,plainText:((Qt=ae.clipboardData)==null?void 0:Qt.getData("text/plain"))??"",htmlText:(($t=ae.clipboardData)==null?void 0:$t.getData("text/html"))??"",htmlToText:Em});Pe.preventDefault&&ae.preventDefault(),Pe.type==="insert-text"?wn(Pe.text):Pe.type==="append-files"&&La(Pe.files)}function Hi(ae){var Pe,Je;const Te=ps(gs((Pe=ae.dataTransfer)==null?void 0:Pe.items,(Je=ae.dataTransfer)==null?void 0:Je.files));Te.preventDefault&&ae.preventDefault(),Te.activateDragTarget&&Ke(!0)}function Fi(ae){var Pe,Je;const Te=ps(gs((Pe=ae.dataTransfer)==null?void 0:Pe.items,(Je=ae.dataTransfer)==null?void 0:Je.files));Te.preventDefault&&ae.preventDefault(),Te.activateDragTarget&&ae.dataTransfer&&(ae.dataTransfer.dropEffect="copy"),Te.activateDragTarget&&Ke(!0)}function Oi(ae){ae.currentTarget.contains(ae.relatedTarget)||Ke(!1)}function Wi(ae){var Je,it;const Te=Qn((Je=ae.dataTransfer)==null?void 0:Je.items,(it=ae.dataTransfer)==null?void 0:it.files),Pe=Ku(Te);Pe.preventDefault&&ae.preventDefault(),Pe.type==="accept-files"&&(Ke(!1),La(Pe.files??[]))}function Ui(ae){if(ae.key==="Enter"&&ae.repeat){ae.preventDefault();return}if(e==="chat"&&ae.key==="/"&&!ae.metaKey&&!ae.ctrlKey&&!ae.altKey&&!n&&!C&&He.length>0&&vn().trim().length===0){ae.preventDefault(),oe("root"),I("slash");return}const Te=Yu({key:ae.key,metaKey:ae.metaKey,ctrlKey:ae.ctrlKey,busy:n,disabled:C});Te.preventDefault&&ae.preventDefault(),Te.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:ve,openMenu:ye!==null,isDragTargetActive:Me,busy:n}),md=Tp({isShellView:z,canToggleShellView:q,isMobileShell:ve,shellPromptLabel:Ce,openMenu:ye,toolbarClassName:ed,iconButtonClassName:td,menuClassName:rd,menuItemClassName:nd,panelButtonClassName:sd,chipButtonClassName:od,inlineToggleClassName:ad,planToggleActiveClassName:ld,sendButtonBaseClassName:id,slashPanelView:W,availableToolboxItems:He,busy:n,settingsBusy:a,compactBusy:s,forkBusy:ne,fastMode:h,goalComposeMode:fr,goalBusy:xn,goalStatus:(_a=R.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:_t,sandboxMode:u,sendButtonLabel:Pa,sendButtonClassName:Ra,modelControlsDisabled:qi,effortControlsDisabled:Ki,effortControlTitle:Yi,forkTurnOptionsState:Q,skillsState:O,goalState:R,goalHistory:ee,copiedSkillName:Li,hooksPanelMode:De,hooksState:K,hookConfigBusy:ut,hookConfigError:gn,hookConfigSuccess:Zl,editingHookTarget:pr,hookScope:et,hookEventName:St,hookMatcher:yt,hookCommand:Yt,hookTimeoutSec:Mt,hookStatusMessage:Zt,mcpPanelMode:Se,mcpState:X,mcpConfigPath:vi,mcpConfigError:wi,mcpConfigSuccess:yi,mcpConfigBusy:ki,mcpHttpName:gi,mcpHttpUrl:xi,mcpRawBlock:bi,capabilities:{hostConfigFiles:he.hostConfigFiles,hookTrust:he.hookTrust,mcpConfigEditing:he.mcpConfigEditing,planMode:he.planMode,sandboxMode:p?!1:he.sandboxMode},shellControlState:E,onToggleView:Ne,onDismissPromptFocus:At,onSetOpenMenu:I,onToolboxItemClick:Mi,onSetSlashPanelView:oe,onViewGoals:F,onUpdateGoal:Y,onOpenForkTurns:()=>de==null?void 0:de(),onForkLatest:be,onForkTurn:Xe,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",at),onPickFile:()=>Ia("file",dt),onUpdateSettings:ae=>void re(ae),onPasteShell:()=>void $i(),onCopyShell:()=>{At(),I(null),$e==null||$e()},onClearShell:()=>{At(),I(null),ie({prompt:"clear"})},onShellControl:ae=>{At(),I(null),Ge==null||Ge(ae)}}),{promptSlot:pd,goalSlot:fd,shellPromptSlot:gd}=Cp({isShellView:z,promptRef:Fe,prompt:Ae,disabled:C,promptPlaceholder:Vi,canInterrupt:_e,interruptLabel:Xi,composerPromptRegionClassName:dd,graphChatInputClassName:ud,promptInputClassName:cd,goalComposeMode:fr,goalTokenBudget:hi,goalLocalError:ui,goalBusy:xn,busy:n,sendButtonLabel:Pa,sendButtonClassName:Ra,onInterrupt:U,onPromptInput:Bi,onPromptPaste:Gi,onPromptKeyDown:Ui,onPromptKeyUp:()=>{Ze.current=Jt()},onPromptMouseUp:()=>{Ze.current=Jt()},onPromptBlur:()=>{Ze.current=Jt(),Ke(!1),ft&&ht()},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:w,photoInputRef:at,fileInputRef:dt,onAppendAttachments:kn,onToggleFollow:Re,canJumpToPreviousTurn:me,onJumpToPreviousTurn:se,canJumpToNextTurn:Le,onJumpToNextTurn:Z,subscriptionUsage:ce,onSubmit:Di,formRef:Ue,promptSlot:pd,pendingQueueSlot:!z&&We.length>0?t.jsx(Om,{prompts:We,onSteer:V,onCancel:fe}):null,toolbarSlot:t.jsx(ap,{...md}),goalSlot:fd,shellPromptSlot:gd})}var Ep=c.createContext(null);function Sl(){return c.useContext(Ep)}function wt(e){return e?new Date(e).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"}):"Time unavailable"}function Vt(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}){return t.jsx("div",{className:`thread-shell-frame relative h-full min-h-0 ${r?"is-rail-collapsed sm:grid-cols-[56px_minmax(0,1fr)]":"sm:grid-cols-[264px_minmax(0,1fr)]"}`,children:e})}function _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();Rt();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:nt("fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",e),...r})}function 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:nt("fixed left-[50%] top-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg",r),...a,children:[e,n?t.jsxs(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:nt("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:nt("text-lg font-semibold leading-none",e),...r})}function Es({className:e,...r}){return t.jsx(Ed,{"data-slot":"dialog-description",className:nt("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 w=()=>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"}`,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 ${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:wt(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:y,className:v,onClick:w})}):C?t.jsx("a",{href:C,onClick:N=>{N.preventDefault(),w()},title:u?e.title:void 0,className:v,children:y}):t.jsx("div",{role:"link",tabIndex:0,onClick:w,onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),w())},title:u?e.title:void 0,className:v,children:y})}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,settingsDialogOpen:m,onSettingsDialogOpenChange:u,mobileHeaderAction:p,currentThreadId:f,currentThreadLabel:g=null,currentWorkspaceId:x=null,currentWorkspaceLabel:j=null,sessionLabel:b=null,usageLabel:k=null,threadActionsButton:w,topbarActions:v,metaContent:y,settingsContent:C,globalSettingsContent:N,workspaceLabels:E={},workspaceReturnHref:_,onWorkspaceReturn:M,getThreadHref:J,onOpenThread:O,getNewThreadHref:X,newThreadHref:K,newThreadLabel:R="New Chat",onNewThread:ee,onNewThreadTitle:Q,renderNewThreadDialogContent:A,renderThreadLink:ie,onCloseAppNavigation:U,onRenameThread:D,onDeleteThread:G,workspaceContent:T,workspaceTitle:B="Workspace",workspaceActions:$,workspaceRevealRequestKey:L,children:S}){const H=Sl(),F=typeof window<"u"?window.matchMedia("(max-width: 639px)").matches:o==="mobile",[le,Y]=c.useState(()=>typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)").matches:!1),de=i??(H==null?void 0:H.themeMode)??"system",te=l??(H==null?void 0:H.effectiveTheme)??(de==="system"?le?"dark":"light":de),[we,ke]=c.useState(!1),[xe,Re]=c.useState(!1),[me,se]=c.useState(!F),[Le,Z]=c.useState(F),[ce,je]=c.useState("chat"),[Ne,$e]=c.useState(null),[Ge,_e]=c.useState(""),[We,V]=c.useState(null),[fe,ye]=c.useState(!1),[I,W]=c.useState(""),[oe,ge]=c.useState(!1),[Se,Ie]=c.useState(!1),[he,He]=c.useState("session");c.useEffect(()=>{L!==void 0&&(se(!1),je("workspace"))},[L]),c.useEffect(()=>{if(typeof window>"u")return;const ne=window.matchMedia("(max-width: 639px)"),be=()=>{Z(ne.matches)};return be(),ne.addEventListener("change",be),()=>{ne.removeEventListener("change",be)}},[]),c.useEffect(()=>{if(typeof window>"u")return;const ne=window.matchMedia("(prefers-color-scheme: dark)"),be=()=>{Y(ne.matches)};return be(),ne.addEventListener("change",be),()=>{ne.removeEventListener("change",be)}},[]);const Ue=c.useMemo(()=>[...x?e.filter(be=>be.workspaceId===x):e].sort((be,Xe)=>{if(be.id===f)return-1;if(Xe.id===f)return 1;const De=Date.parse(be.lastTurnStartedAt??be.updatedAt);return Date.parse(Xe.lastTurnStartedAt??Xe.updatedAt)-De}),[f,x,e]),Fe=K??(X==null?void 0:X(x)),at=j??x??"all",dt=b??g??f??"default_session",st=k??(r!=null&&r.state?`runtime ${r.state}`:"waiting for agent usage"),rt=d??(H==null?void 0:H.setThemeMode),Ze=!!rt,ct=()=>{ke(!1),U==null||U()};async function pt(ne){if(!D)return;const be=Ge.trim();if(be){V(ne);try{await D(ne,be),$e(null),_e("")}finally{V(null)}}}function z(ne){$e(ne.id),_e(ne.title)}function q(){$e(null),_e("")}function ve(ne){O==null||O(ne),ct()}function Ce(){ye(!1),W("")}function Me(ne){if(!Fe||!ne.trim())return Fe;try{const be=new URL(Fe,window.location.origin);return be.searchParams.set("title",ne.trim()),`${be.pathname}${be.search}${be.hash}`}catch{const be=Fe.includes("?")?"&":"?";return`${Fe}${be}title=${encodeURIComponent(ne.trim())}`}}async function Ke(){const ne=I.trim();ge(!0);try{if(ne&&Q){await Q(ne),W(""),ye(!1),ct();return}if(Fe){window.location.assign(Me(ne)??Fe);return}await(ee==null?void 0:ee()),W(""),ye(!1),ct()}finally{ge(!1)}}function tt(ne,be=!1){const Xe=be?t.jsxs(t.Fragment,{children:[t.jsx(P.Plus,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:R})]}):t.jsxs(t.Fragment,{children:[t.jsx(P.Plus,{className:"h-4 w-4"}),t.jsx("span",{children:R})]});return t.jsxs(js,{open:fe,onOpenChange:De=>{oe||ye(De)},children:[t.jsx(Ns,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":be?R:void 0,title:R,className:ne,children:Xe})}),t.jsx(Cs,{"data-testid":"create-thread-dialog","data-theme-effective":te,"data-theme-mode":de,className:"thread-graph-create-thread-dialog thread-graph-dialog max-h-[min(86vh,42rem)] overflow-hidden p-4 sm:max-w-[34rem]",children:A?A({close:Ce,closeNavigation:ct,currentWorkspaceId:x}):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:I,onChange:De=>W(De.target.value),onKeyDown:De=>{De.key==="Enter"&&(De.preventDefault(),Ke())},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 Ke(),disabled:oe,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:oe?"Creating...":"Create"})]})]})})]})}function Ve(){if(!C&&!y&&!N&&!Ze)return null;const ne=!!(C||y),be=!!N,Xe=ne&&be,De=he==="global"&&be||!ne&&be?"global":"session";return t.jsxs(js,{...m!==void 0?{open:m}:{},...u?{onOpenChange:u}:{},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":te,"data-theme-mode":de,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."})]}),Ze?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: ",te]})]}),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(et=>{const St=et.icon,yt=de===et.value;return t.jsxs("button",{type:"button","data-testid":`theme-mode-${et.value}`,"aria-pressed":yt,disabled:!Ze,onClick:()=>rt==null?void 0:rt(et.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(St,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:"truncate",children:et.label})]},et.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":De==="session",onClick:()=>He("session"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${De==="session"?"is-active":""}`,children:"Session"}),t.jsx("button",{type:"button","aria-pressed":De==="global",onClick:()=>He("global"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${De==="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:De==="session"?t.jsxs("div",{className:"grid gap-4",children:[C?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:C}):null,y?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:y}):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:N})})]})]})}function Ae(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(P.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(Op,{threads:Ue,currentThreadId:f,currentWorkspaceId:x,workspaceLabels:E,onOpenThread:ve,collapsed:ne,...D?{onBeginRenameThread:z}:{},showDeleteButton:!!G,...J?{getThreadHref:J}:{},...ie?{renderThreadLink:ie}:{},...G?{onDeleteThread:G}:{}}):null]})]})})}function lt(){return T?t.jsxs("div",{className:"thread-workspace-panel relative flex h-full min-h-0 flex-col overflow-hidden rounded-[12px] border",children:[t.jsx("button",{type:"button",onClick:()=>se(!0),className:"thread-workspace-collapse-tab thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(P.ChevronsRight,{className:"h-4 w-4"})}),$?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:$})}):null,t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:T})]}):t.jsxs("div",{className:"thread-workspace-panel flex h-full min-h-0 flex-col overflow-hidden rounded-[12px] border",children:[t.jsxs("div",{className:"thread-workspace-panel-header flex h-12 shrink-0 items-center justify-between gap-3 border-b border-[var(--theme-border)] px-3 sm:h-[60px] sm:px-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-base font-semibold text-[var(--theme-fg)] sm:text-[18px]",children:B}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:j??x??"Current context"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[$,t.jsx("button",{type:"button",onClick:()=>se(!0),className:"thread-workspace-small-toggle thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(P.ChevronsRight,{className:"h-4 w-4"})})]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:T??t.jsxs("div",{className:"grid h-full min-h-0 gap-3 overflow-y-auto p-3 text-sm text-[var(--theme-fg-soft)]",children:[t.jsxs("div",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:"Runtime"}),t.jsx("p",{className:"mt-2 text-[var(--theme-fg)]",children:(r==null?void 0:r.state)??"unknown"})]}),t.jsxs("div",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:"Workspace"}),t.jsx("p",{className:"mt-2 break-words text-[var(--theme-fg)]",children:j??x??"All threads"})]})]})})]})}const ft=!!T,ot=o==="mobile"||o==="responsive"&&Le,ht=ot,bt=ht&&!we,re=!!(_||M)?t.jsx("a",{href:_??"#",onClick:ne=>{M&&(ne.preventDefault(),M())},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:te,layoutMode:o,themeMode:de,viewportConstrained:s,children:t.jsxs(Rp,{roomsRailCollapsed:xe,children:[t.jsx(_p,{open:we,onClose:()=>ke(!1)}),t.jsxs(Mp,{collapsed:xe,mobileOpen:we,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 ${xe?"sm:w-full sm:justify-center sm:px-2":""}`,children:t.jsxs("div",{className:`flex w-full items-center gap-3 ${xe?"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:()=>Re(ne=>!ne),className:"thread-icon-button thread-desktop-only-flex h-9 w-9 shrink-0 items-center justify-center rounded-full",title:xe?"Expand rooms":"Collapse rooms","aria-label":xe?"Expand rooms":"Collapse rooms",children:xe?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)] ${xe?"thread-desktop-collapsed-hidden":""}`,children:(j??"R").charAt(0).toUpperCase()}),t.jsxs("div",{className:`min-w-0 ${xe?"thread-desktop-collapsed-hidden":""}`,children:[t.jsx("p",{className:"truncate text-sm font-semibold text-[var(--theme-fg)]",children:j??"Remote Codex"}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:x??"Thread workspace"})]})]}),t.jsxs("div",{className:`flex shrink-0 items-center gap-1 ${xe?"thread-desktop-collapsed-hidden":""}`,children:[Ve(),re,t.jsx("button",{type:"button",onClick:()=>ke(!1),"aria-label":"Close rooms",title:"Close rooms",className:"thread-icon-button thread-mobile-only-inline-flex h-10 w-10 items-center justify-center rounded-full",children:t.jsx(P.X,{className:"h-4 w-4"})})]})]})}),t.jsx("div",{className:`thread-graph-new-room-strip flex shrink-0 items-center border-b ${xe?"h-12 w-full justify-center px-2 sm:h-12":"h-[68px] px-4"}`,children:tt(`thread-graph-new-room-button inline-flex items-center justify-center rounded-xl font-medium transition ${xe?"h-9 w-9 p-0":"h-11 w-full gap-2 px-3 text-sm sm:h-9"}`,xe)}),t.jsx("div",{className:`flex min-h-0 flex-1 flex-col ${xe?"w-full px-2 py-2":"px-3 py-3"}`,children:Ae(xe)})]}),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:[bt?t.jsx("button",{type:"button",onClick:()=>ke(!0),"aria-label":"Open rooms",title:"Open rooms",className:"thread-icon-button thread-mobile-only-inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-full",children:t.jsx(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:g??"Shared Workspace",children:g??"Shared Workspace"}),t.jsxs("div",{className:"relative mt-0.5 flex min-w-0 items-center gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{Ie(ne=>!ne)},"aria-expanded":Se,"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:at})]}),Se?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;dt&&((ne=navigator.clipboard)==null||ne.writeText(dt))},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:dt})]}),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:st})]})]}):null]})]})]}),t.jsxs("div",{className:"relative z-[1] inline-flex shrink-0 items-center gap-2",children:[w||v?t.jsxs("div",{className:"thread-graph-topbar-actions thread-desktop-only-inline-flex items-center rounded-lg border p-0.5 shadow-none",children:[w,v]}):null,ht&&w?t.jsx("div",{className:"thread-mobile-only-inline-flex",children:w}):null,ht&&ft?t.jsx("button",{type:"button",onClick:()=>je(ne=>ne==="workspace"?"chat":"workspace"),"aria-label":ce==="workspace"?"Show chat":"Show workspace",title:ce==="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:ce==="workspace"?t.jsx(P.MessageSquare,{className:"h-4 w-4"}):t.jsx(P.Folder,{className:"h-4 w-4"})}):null,ht?p:null,ht&&h?tt("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:ft&&!me?ot?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 ${ce==="chat"?"block":"thread-mobile-chat-hidden"}`,children:S}),t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${ce==="workspace"?"block":"thread-mobile-workspace-hidden"}`,children:lt()})]}):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:S}),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:lt()})]}):t.jsxs("div",{className:"thread-split-container relative h-full min-h-0 overflow-hidden",children:[ft&&me?t.jsx("button",{type:"button",onClick:()=>se(!1),className:"thread-workspace-expand-fab thread-desktop-only-inline-flex",title:"Expand workspace","aria-label":"Expand workspace",children:t.jsx(P.ChevronsLeft,{className:"h-4 w-4"})}):null,S]})})]})]})}),t.jsx(zp,{open:Ne!==null,title:"Rename Thread",label:"Thread Title",value:Ge,busy:We!==null,onChange:_e,onCancel:q,onSubmit:()=>Ne?pt(Ne):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
+ `,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
3946
3952
  ${JSON.stringify({call:{tool:m,args:u,call_id:h},result:p},null,2)}
3947
- \`\`\``}return l}catch{return l}}),resultMap:r}}var nf=["/api/","/assets/","/control-plane","/devices/","/relay/","/relay-account","/relay-admin","/relay-devices","/relay-portal","/threads","/workspaces"];function Ps(e){return e.replace(/background-color:[^;"]+;?/g,"background-color: transparent;").replace(/background:[^;"]+;?/g,"background: transparent;")}function Rs(e){return Array.isArray(e)?e.map(r=>String(r)).join(""):String(e??"")}function af(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 sf(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("/")||nf.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 of({children:e,...r}){return lf(e)?t.jsx(t.Fragment,{children:e}):t.jsx("pre",{...r,children:e})}function lf(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 df=c.memo(function({className:r="thread-graph-markdown",content:n,onOpenWorkspaceFile:a}){const s=c.useRef(null),o=wa(),[l,i]=c.useState(null),[d,h]=c.useState({}),[m,u]=c.useState(!1),{processedContent:p,resultMap:f}=c.useMemo(()=>rf(n),[n]);c.useEffect(()=>{let j=!0;return Uo().then(b=>{j&&i(b)}).catch(()=>{}),()=>{j=!1}},[]),c.useEffect(()=>{const j=s.current,b=j==null?void 0:j.closest(".thread-ui-shell"),k=()=>b?b.getAttribute("data-theme-effective")==="dark"||b.classList.contains("dark")||b.classList.contains("thread-ui-theme-dark"):document.documentElement.classList.contains("dark");if(u(k()),!b)return;const w=new MutationObserver(()=>u(k()));return w.observe(b,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>w.disconnect()},[]);async function g(j,b){try{await navigator.clipboard.writeText(b),h(k=>({...k,[j]:"copied"})),window.setTimeout(()=>{h(k=>{const w={...k};return delete w[j],w})},1200)}catch{h(k=>({...k,[j]:"failed"}))}}const x=({children:j,className:b,inline:k,node:w,...v})=>{var O;const y=/language-(\w+(?:-\w+)*)/.exec(b||""),C=y?y[1]??"":"",N=Rs(j).replace(/\n$/,""),{startLine:E,endLine:_}=af(w),M=k===!1||!!b||N.includes(`
3948
- `)||E!==_;if(C==="tool-merged"){let X={call:{tool:"Unknown",args:{},call_id:void 0},result:null};try{X=JSON.parse(N)}catch{X={call:{tool:"Error",args:{raw:N}},result:{status:"failed"}}}const K=typeof X.call.tool=="string"?X.call.tool:"Unknown",R=typeof X.call.call_id=="string"?X.call.call_id:void 0;return t.jsx(Is,{callId:R,toolName:K,status:zs(X.result),parameters:na(X.call.args),result:X.result})}if(C==="tool-call"){let X={tool:"Unknown",args:{},call_id:void 0};try{X=JSON.parse(N)}catch{X={tool:"Error",args:{raw:N}}}const K=typeof X.call_id=="string"?X.call_id:void 0,R=K&&f.has(K)?Il(f.get(K)??aa()):void 0;return t.jsx(Is,{callId:K,toolName:typeof X.tool=="string"?X.tool:"Unknown",status:R?zs(R):"pending",parameters:na(X.args),result:R})}if(C==="tool-result")return null;if(["xyz","extxyz","cif","pdb"].includes(C)){const X=o.renderInlineCode({code:N,isIncomplete:!1,language:C});if(c.isValidElement(X))return X}if(M){const K=(((O=l==null?void 0:l.getLoadedLanguages)==null?void 0:O.call(l))??[]).includes(C)?C:"text",R=m?"ayu-dark":"ayu-light",ee=`${C||"text"}:${N.length}:${N.slice(0,32)}`;let Q="";if(l)try{Q=Ps(l.codeToHtml(N,{lang:K,theme:R}))}catch{Q=Ps(l.codeToHtml(N,{lang:"text",theme:R}))}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 g(ee,N),variant:"ghost",size:"sm",className:"thread-graph-code-copy absolute right-2 top-2 z-10 rounded-md p-1.5",title:d[ee]==="copied"?"Copied":d[ee]==="failed"?"Copy failed":"Copy","aria-label":"Copy code",children:d[ee]==="copied"?t.jsx(P.Check,{className:"h-3.5 w-3.5"}):t.jsx(P.Copy,{className:"h-3.5 w-3.5"})}),Q?t.jsx("div",{dangerouslySetInnerHTML:{__html:Q}}):t.jsx("pre",{children:t.jsx("code",{className:"whitespace-pre",children:N})})]})}const J=Rs(j).replace(/`+/g,"");return t.jsx("code",{className:`thread-graph-inline-code rounded px-1 py-0.5 font-mono font-normal text-[0.9em] ${b||""}`,...v,children:J})};return t.jsx("div",{ref:s,className:`thread-graph-message-markdown ${r}`,children:t.jsx(ro,{remarkPlugins:[no,Zd],rehypePlugins:[Yd],components:{a({href:j,children:b,...k}){const w=sf(j);return w&&a?t.jsx("a",{...k,href:j,className:"thread-inline-link",onClick:v=>{v.preventDefault(),a(w)},children:b}):t.jsx("a",{...k,href:j,className:"thread-inline-link",children:b})},code:x,pre:of},children:p})})}),_s=2400,cf=/\b(?:https?:\/\/|www\.)[^\s<>"'`]+/gi,hf=/[),.;:!?]+$/;function uf(e){return e.startsWith("www.")?`https://${e}`:e}function Ms(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function mf(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 dr({text:e}){var a;const r=[];let n=0;for(const s of e.matchAll(cf)){const o=s[0],l=s.index??0,i=((a=o.match(hf))==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:uf(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 zl=c.memo(function({text:r,scrollRootRef:n,streaming:a=!1,containerClassName:s="",plainTextClassName:o="thread-graph-plain-text whitespace-pre-wrap break-words text-[15px] leading-6",markdownClassName:l="thread-graph-markdown",onBeforeResize:i,onOpenWorkspaceFile:d}){const h=c.useRef(null),m=c.useRef(null),[u,p]=c.useState(!1),f=Qp(r),g=!a&&r.length>_s,x=g&&!u?`${r.slice(0,_s).trimEnd()}
3953
+ \`\`\``}return l}catch{return l}}),resultMap:r}}var nf=["/api/","/assets/","/control-plane","/devices/","/relay/","/relay-account","/relay-admin","/relay-devices","/relay-portal","/threads","/workspaces"];function Ps(e){return e.replace(/background-color:[^;"]+;?/g,"background-color: transparent;").replace(/background:[^;"]+;?/g,"background: transparent;")}function Rs(e){return Array.isArray(e)?e.map(r=>String(r)).join(""):String(e??"")}function af(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 sf(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("/")||nf.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 of({children:e,...r}){return lf(e)?t.jsx(t.Fragment,{children:e}):t.jsx("pre",{...r,children:e})}function lf(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 df=c.memo(function({className:r="thread-graph-markdown",content:n,onOpenWorkspaceFile:a,resolveHref:s}){const o=c.useRef(null),l=wa(),[i,d]=c.useState(null),[h,m]=c.useState({}),[u,p]=c.useState(!1),{processedContent:f,resultMap:g}=c.useMemo(()=>rf(n),[n]);c.useEffect(()=>{let b=!0;return Uo().then(k=>{b&&d(k)}).catch(()=>{}),()=>{b=!1}},[]),c.useEffect(()=>{const b=o.current,k=b==null?void 0:b.closest(".thread-ui-shell"),y=()=>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(y()),!k)return;const v=new MutationObserver(()=>p(y()));return v.observe(k,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>v.disconnect()},[]);async function x(b,k){try{await navigator.clipboard.writeText(k),m(y=>({...y,[b]:"copied"})),window.setTimeout(()=>{m(y=>{const v={...y};return delete v[b],v})},1200)}catch{m(y=>({...y,[b]:"failed"}))}}const j=({children:b,className:k,inline:y,node:v,...w})=>{var re;const C=/language-(\w+(?:-\w+)*)/.exec(k||""),N=C?C[1]??"":"",E=Rs(b).replace(/\n$/,""),{startLine:R,endLine:_}=af(v),Y=y===!1||!!k||E.includes(`
3954
+ `)||R!==_;if(N==="tool-merged"){let F={call:{tool:"Unknown",args:{},call_id:void 0},result:null};try{F=JSON.parse(E)}catch{F={call:{tool:"Error",args:{raw:E}},result:{status:"failed"}}}const A=typeof F.call.tool=="string"?F.call.tool:"Unknown",J=typeof F.call.call_id=="string"?F.call.call_id:void 0;return t.jsx(Is,{callId:J,toolName:A,status:zs(F.result),parameters:na(F.call.args),result:F.result})}if(N==="tool-call"){let F={tool:"Unknown",args:{},call_id:void 0};try{F=JSON.parse(E)}catch{F={tool:"Error",args:{raw:E}}}const A=typeof F.call_id=="string"?F.call_id:void 0,J=A&&g.has(A)?Il(g.get(A)??aa()):void 0;return t.jsx(Is,{callId:A,toolName:typeof F.tool=="string"?F.tool:"Unknown",status:J?zs(J):"pending",parameters:na(F.args),result:J})}if(N==="tool-result")return null;if(["xyz","extxyz","cif","pdb"].includes(N)){const F=l.renderInlineCode({code:E,isIncomplete:!1,language:N});if(c.isValidElement(F))return F}if(Y){const A=(((re=i==null?void 0:i.getLoadedLanguages)==null?void 0:re.call(i))??[]).includes(N)?N:"text",J=u?"ayu-dark":"ayu-light",Z=`${N||"text"}:${E.length}:${E.slice(0,32)}`;let M="";if(i)try{M=Ps(i.codeToHtml(E,{lang:A,theme:J}))}catch{M=Ps(i.codeToHtml(E,{lang:"text",theme:J}))}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 x(Z,E),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(P.Check,{className:"h-3.5 w-3.5"}):t.jsx(P.Copy,{className:"h-3.5 w-3.5"})}),M?t.jsx("div",{dangerouslySetInnerHTML:{__html:M}}):t.jsx("pre",{children:t.jsx("code",{className:"whitespace-pre",children:E})})]})}const W=Rs(b).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||""}`,...w,children:W})};return t.jsx("div",{ref:o,className:`thread-graph-message-markdown ${r}`,children:t.jsx(ro,{remarkPlugins:[no,Zd],rehypePlugins:[Yd],components:{a({href:b,children:k,...y}){const v=sf(b);return v&&a?t.jsx("a",{...y,href:b,className:"thread-inline-link",onClick:w=>{w.preventDefault(),a(v)},children:k}):t.jsx("a",{...y,href:b&&((s==null?void 0:s(b))??b),className:"thread-inline-link",children:k})},code:j,pre:of},children:f})})}),_s=2400,cf=/\b(?:https?:\/\/|www\.)[^\s<>"'`]+/gi,hf=/[),.;:!?]+$/;function uf(e){return e.startsWith("www.")?`https://${e}`:e}function Ms(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function mf(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 dr({text:e}){var a;const r=[];let n=0;for(const s of e.matchAll(cf)){const o=s[0],l=s.index??0,i=((a=o.match(hf))==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:uf(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 zl=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=Qp(r),x=!a&&r.length>_s,j=x&&!p?`${r.slice(0,_s).trimEnd()}
3949
3955
 
3950
- ...`:r,[j,b]=c.useState(a||typeof IntersectionObserver>"u"),k=c.useCallback(()=>{const w=n.current,v=h.current,y=(v==null?void 0:v.getBoundingClientRect().top)??null;i==null||i(),m.current=w&&y!==null?{root:w,top:y}:null,p(C=>!C)},[i,n]);return c.useLayoutEffect(()=>{const w=m.current,v=h.current;if(!w||!v)return;m.current=null;const y=()=>{const N=v.getBoundingClientRect().top;w.root.scrollTop+=N-w.top};y();const C=window.requestAnimationFrame(y);return()=>{window.cancelAnimationFrame(C)}},[u]),c.useEffect(()=>{if(a||typeof IntersectionObserver>"u"){b(!0);return}if(j||!h.current)return;const w=new IntersectionObserver(v=>{for(const y of v)if(y.isIntersecting){b(!0),w.disconnect();break}},{root:n.current,threshold:0});return w.observe(h.current),()=>{w.disconnect()}},[j,n,a]),t.jsxs("div",{ref:h,className:s,children:[j&&f?t.jsx(df,{content:x,className:l,onOpenWorkspaceFile:d}):t.jsx("p",{className:o,children:t.jsx(dr,{text:x})}),g?t.jsx("button",{type:"button",onClick:k,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:u?"Show less":`Show more (${r.length.toLocaleString()} chars)`}):null]})}),pf=c.memo(function({text:r,scrollRootRef:n,streaming:a=!1,onBeforeResize:s,onOpenWorkspaceFile:o}){return t.jsx(zl,{text:r,scrollRootRef:n,streaming:a,containerClassName:"thread-graph-message-prose",...s?{onBeforeResize:s}:{},...o?{onOpenWorkspaceFile:o}:{}})}),ff=c.memo(function({threadId:r,text:n,attachmentPreviewUrls:a,getImageAssetUrl:s}){const o=c.useMemo(()=>mf(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=Ms(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=Ms(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 gf(){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 As({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(P.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):a?t.jsx(P.XCircle,{className:"h-3.5 w-3.5"}):s?t.jsx(P.CheckCircle2,{className:"h-3.5 w-3.5"}):t.jsx(P.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(gf,{}):l}),t.jsx("span",{className:"thread-graph-status-label",children:e})]})}function xf({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(As,{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(As,{status:o}):null,h]}):null]})})}_r();function bf(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function vf({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 zt=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??[]:[],x=g.map(N=>N.text.trim()).filter(Boolean).join(`
3956
+ ...`:r,[b,k]=c.useState(a||typeof IntersectionObserver>"u"),y=c.useCallback(()=>{const v=n.current,w=m.current,C=(w==null?void 0:w.getBoundingClientRect().top)??null;i==null||i(),u.current=v&&C!==null?{root:v,top:C}:null,f(N=>!N)},[i,n]);return c.useLayoutEffect(()=>{const v=u.current,w=m.current;if(!v||!w)return;u.current=null;const C=()=>{const E=w.getBoundingClientRect().top;v.root.scrollTop+=E-v.top};C();const N=window.requestAnimationFrame(C);return()=>{window.cancelAnimationFrame(N)}},[p]),c.useEffect(()=>{if(a||typeof IntersectionObserver>"u"){k(!0);return}if(b||!m.current)return;const v=new IntersectionObserver(w=>{for(const C of w)if(C.isIntersecting){k(!0),v.disconnect();break}},{root:n.current,threshold:0});return v.observe(m.current),()=>{v.disconnect()}},[b,n,a]),t.jsxs("div",{ref:m,className:s,children:[b&&g?t.jsx(df,{content:j,className:l,onOpenWorkspaceFile:d,resolveHref:h}):t.jsx("p",{className:o,children:t.jsx(dr,{text:j})}),x?t.jsx("button",{type:"button",onClick:y,className:"thread-graph-show-more timeline-meta-text mt-1.5 flex w-full items-center justify-center rounded-md border border-[var(--theme-border)] px-2 py-0.5 text-[10px] leading-4 transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)]",children:p?"Show less":`Show more (${r.length.toLocaleString()} chars)`}):null]})}),pf=c.memo(function({text:r,scrollRootRef:n,streaming:a=!1,onBeforeResize:s,onOpenWorkspaceFile:o,resolveHref:l}){return t.jsx(zl,{text:r,scrollRootRef:n,streaming:a,containerClassName:"thread-graph-message-prose",...s?{onBeforeResize:s}:{},...o?{onOpenWorkspaceFile:o}:{},...l?{resolveHref:l}:{}})}),ff=c.memo(function({threadId:r,text:n,attachmentPreviewUrls:a,getImageAssetUrl:s}){const o=c.useMemo(()=>mf(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=Ms(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=Ms(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 gf(){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 As({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(P.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):a?t.jsx(P.XCircle,{className:"h-3.5 w-3.5"}):s?t.jsx(P.CheckCircle2,{className:"h-3.5 w-3.5"}):t.jsx(P.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(gf,{}):l}),t.jsx("span",{className:"thread-graph-status-label",children:e})]})}function xf({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(As,{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(As,{status:o}):null,h]}):null]})})}_r();function bf(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function vf({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 Rt=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??[]:[],x=g.map(N=>N.text.trim()).filter(Boolean).join(`
3951
3957
 
3952
- `),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 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 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)),y=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:w,metaControl:y,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}:{}}):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(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/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 Et(e){return typeof e.sequence=="number"&&Number.isFinite(e.sequence)}function Hr(e){return Et(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"&&!Et(r[a]);)n.push(r[a]),a+=1;const s=r.slice(a);if(!s.some(Et))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(Et(u)){i.push({item:u,index:d,order:Hr(u)}),d+=1;continue}const p=d;for(;d<s.length&&!Et(s[d]);)d+=1;const f=s.slice(p,d),g=[...s.slice(0,p)].reverse().find(Et),x=s.slice(d).find(Et),j=g?Hr(g):null,b=x?Hr(x):null;f.forEach((k,w)=>{let v;if(j===null&&b!==null)v=b-(f.length-w)/(f.length+1);else if(j!==null&&b!==null&&b>j){const y=b-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 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(Et)||(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(w=>w===m?(o[b.id]??"").trim():w.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 w=k.trim();return w?[w]:[]}function j(b,k){s(w=>{const v=w[b],y=Array.isArray(v)?v:[],C=y.includes(k)?y.filter(N=>N!==k):[...y,k];return{...w,[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,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)})}):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 w=p(k.label),v=a[b.id];return t.jsxs("button",{type:"button",disabled:r,onClick:()=>b.multiSelect?j(b.id,k.label):s(y=>({...y,[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:[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)}),b.isOther&&(()=>{const k=a[b.id];return t.jsx("button",{type:"button",disabled:r,onClick:()=>b.multiSelect?j(b.id,m):s(w=>({...w,[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(y=>({...y,[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(w=>({...w,[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:Vt(e.createdAt),className:"timeline-meta-text text-[10px]",children:wt(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();Rt();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:nt($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 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(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/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,`
3953
3959
  `).split(`
3954
- `);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 Kt({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(Kt,{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(Kt,{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(Kt,{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(Kt,{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(Kt,{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(Kt,{actions:t.jsxs("span",{className:"inline-flex items-center gap-2",children:[i&&!s.hasRendererForArtifact(i)?t.jsx("span",{className:"thread-graph-history-event-secondary",children:"No renderer"}):null,i&&n?t.jsxs("button",{type:"button","aria-label":`Open artifact inspector for ${i.title}`,onClick:()=>n(r,i),className:"thread-graph-history-event-action",children:[t.jsx(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(`
3955
- `).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(Kt,{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,w=12,v=j.left+j.width/2-b/2,y=w,C=Math.max(y,k-w-b),N=Math.min(Math.max(v,y),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:Vt(e.startedAt),className:"timeline-meta-text shrink-0 text-[11px]",children:wt(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(zt,{threadId:r,item:n,scrollRootRef:a,timeLabel:u,timeTitle:p,...h?{onBeforeMessageResize:h}:{},...m?{adapter:m}:{}});if(n.kind==="reasoning")return t.jsx(zt,{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,w)=>d({item:k,artifact:w})}:{}});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,w=((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",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(tg,{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(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,w=((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",w,"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?wt(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=Vt(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 Ht(e){var r;return e.kind==="item"?e.item.createdAt??null:e.kind==="agentActivityGroup"?e.entries[0]?Ht(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:w=!1}){const v=!!l||!!d||!!(i&&i.length>0),y=h||jr(a.status)||v||w,C=y&&!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]),_=c.useMemo(()=>Sf(d,N),[d,N]),M=c.useMemo(()=>Nf(N,y),[y,N]),J=c.useMemo(()=>Tf(M),[M]),O=h||jr(a.status)||v,X=wt(a.startedAt),K=Vt(a.startedAt),R=c.useMemo(()=>Pl(_),[_]),[ee,Q]=c.useState({}),A=c.useCallback(Y=>{Q(de=>({...de,[Y]:!de[Y]}))},[]),ie=t.jsx(Ol,{entries:J,expandedGroups:ee,onToggleGroupedItem:A,threadId:r,scrollRootRef:b,onOpenExpandedText:u,onOpenCommandDetail:p,onOpenToolCallDetail:f,onOpenDeferredHistoryItemDetail:g,...j?{onBeforeMessageResize:j}:{},fallbackTimestamp:a.startedAt,fallbackTimeLabel:X,fallbackTimeTitle:K,turnStartedAt:a.startedAt,autoOpenLatestToolDetails:O,...x?{onSelectArtifact:x}:{},...n?{adapter:n}:{}}),U=R?t.jsx(ja,{threadId:r,item:R,scrollRootRef:b,onOpenExpandedText:u,onOpenCommandDetail:p,onOpenToolCallDetail:f,onOpenDeferredHistoryItemDetail:g,timeLabel:a.startedAt?t.jsx(Cr,{absoluteLabel:X,timestamp:a.startedAt,turnStartedAt:a.startedAt}):X,timeTitle:K,timeMeta:null,...x?{onSelectArtifact:x}:{},...n?{adapter:n}:{}}):null,D=!R&&_?t.jsx(zt,{item:{id:"live-agent-message",kind:"agentMessage",text:_},scrollRootRef:b,timeLabel:a.startedAt?t.jsx(Cr,{absoluteLabel:X,timestamp:a.startedAt,turnStartedAt:a.startedAt}):X,timeTitle:K,streaming:!0,...j?{onBeforeMessageResize:j}:{}}):null,G=y?t.jsx(Os,{turn:C,variant:"footer"}):null,T=c.useMemo(()=>zg(J),[J]),B=c.useMemo(()=>Lg(a.startedAt,N),[N,a.startedAt]),$=T.hiddenEntries.length>0,L=o&&$,H=Ws(a.status)&&$&&!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":`${B}. Collapse turn ${s}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:B}),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,F=Ws(a.status)&&$?t.jsxs("div",{className:"thread-graph-turn-collapsed-summary space-y-2",children:[T.users.map(Y=>t.jsx(zt,{threadId:r,item:Y,scrollRootRef:b,timeLabel:Y.createdAt?wt(Y.createdAt):X,timeTitle:Y.createdAt?Vt(Y.createdAt):K,...j?{onBeforeMessageResize:j}:{},...n?{adapter:n}:{}},Y.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":`${B}. Expand turn ${s}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:B}),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(zt,{threadId:r,item:T.finalAgent,scrollRootRef:b,timeLabel:T.finalAgent.createdAt?t.jsx(Cr,{absoluteLabel:wt(T.finalAgent.createdAt),timestamp:T.finalAgent.createdAt,turnStartedAt:a.startedAt}):X,timeTitle:T.finalAgent.createdAt?Vt(T.finalAgent.createdAt):K,...j?{onBeforeMessageResize:j}:{},...n?{adapter:n}:{}}):null]}):null,le=t.jsx(fg,{footer:G,history:t.jsxs(t.Fragment,{children:[H,ie]}),liveHookPrompt:U,liveOutput:D,livePlan:E});return t.jsx(gg,{absoluteIndex:s,body:le,collapsed:L,collapsedBody:F,error:a.error,headerStatus:t.jsx(Os,{turn:a}),isActive:y,refCallback:k,startedAt:a.startedAt,timeLabel:X,timeTitle:K,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 w;const b=((w=e.at(-1))==null?void 0:w.key)??null,k=c.useCallback(v=>v?t.jsx(Cr,{absoluteLabel:wt(v),timestamp:v,turnStartedAt:x??p}):null,[p,x]);return t.jsx(Af,{entries:e,expandedGroups:r,onToggleGroupedItem:n,renderCommandGroup:(v,y,C)=>t.jsx(og,{items:v.items,expanded:y,onToggleExpanded:C,onOpen:l,timeMeta:k(Ht(v))},v.key),renderFileChangeGroup:(v,y,C)=>t.jsx(hg,{items:v.items,expanded:y,onToggleExpanded:C,onOpen:o,timeMeta:k(Ht(v))},v.key),renderSearchGroup:(v,y,C)=>t.jsx(dg,{items:v.items,expanded:y,onToggleExpanded:C,onOpen:o,timeMeta:k(Ht(v))},v.key),renderFileReadGroup:(v,y,C)=>t.jsx(cg,{items:v.items,expanded:y,onToggleExpanded:C,onOpen:o,timeMeta:k(Ht(v))},v.key),renderToolCallGroup:(v,y,C)=>t.jsx(lg,{items:v.items,expanded:y,onToggleExpanded:C,onOpen:i,timeMeta:k(Ht(v))},v.key),renderAgentActivityGroup:(v,y,C)=>t.jsx(ig,{itemCount:v.itemCount,expanded:y,onToggleExpanded:C,timeMeta:k(Ht(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 y=Sg(v.item,p??null),N=v.item.kind==="userMessage"?v.item.createdAt?wt(y):f:v.item.createdAt?t.jsx(Cr,{absoluteLabel:wt(y),timestamp:y,turnStartedAt:x??p}):f;return t.jsx(ja,{threadId:a,item:v.item,scrollRootRef:s,timeLabel:N,timeTitle:v.item.createdAt?Vt(y):g,timeMeta:k(y),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 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,Vs(f,g,y instanceof Error?y.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),w=c.useRef(!0),v=c.useRef(!0),y=c.useRef(!1),C=c.useRef(!1),N=c.useRef(!1),E=c.useRef(!1),_=c.useRef(null),M=c.useRef(0),[J,O]=c.useState(Us),[X,K]=c.useState(0),[R,ee]=c.useState(!0),Q=$g(d),A=typeof s=="function"||n!==void 0,ie=n??r,U=A?0:Math.max(0,r-J),G=(A?Math.max(0,ie-r):0)+U,T=A?r:r-U,B=A?0:r-T,$=A?Math.max(0,ie-r):0,L=A?$+B:B,S=!A&&L>0&&X>=2,H=A&&$>0&&B===0&&typeof s=="function",F=c.useCallback(()=>{const Z=h.current;if(!Z){j.current=null;return}j.current={scrollHeight:Z.scrollHeight,scrollTop:Z.scrollTop}},[]),le=c.useCallback(()=>!H||a||N.current?!1:(F(),N.current=!0,E.current=!1,M.current=0,s==null||s(),!0),[H,a,s,F]),Y=c.useCallback(()=>{const Z=h.current,ce=b.current;if(!Z)return;const je=ce?Rg(Z,ce):kr(Z);w.current=je,ee(Ne=>Ne===je?Ne:je)},[]),de=c.useCallback(()=>{const Z=h.current;if(Z){C.current=!0;const ce=Z.scrollTop,je=x.current,Ne=ce-je;x.current=ce,kr(Z,1)?(y.current=!1,v.current=!0):Ne<-1?(y.current=!0,v.current=!1):Ne>1&&(v.current=!y.current&&kr(Z,oa)),ce<=0&&C.current?E.current=!0:ce>0&&(E.current=!1,M.current=0)}Y()},[Y]),te=c.useCallback(()=>{const Z=h.current;Z&&(Z.scrollTop=Z.scrollHeight,x.current=Z.scrollTop,g.current=Z.scrollHeight,w.current=!0,ee(ce=>ce||!0),y.current=!1,v.current=!0)},[]),we=c.useCallback(()=>{const Z=h.current;Z&&(x.current=Z.scrollTop,g.current=Z.scrollHeight,v.current=!1,y.current=!0)},[]),ke=c.useCallback(()=>{if(A&&B===0){le();return}O(Z=>Math.min(r,Z+Pg)),K(Z=>Z+1)},[B,A,le,r]),xe=c.useCallback(Z=>{const ce=h.current;if(!(!ce||Z.deltaY>=-8||ce.scrollTop>0||!H)){if(!E.current){E.current=!0;return}le()}},[H,le]),Re=c.useCallback(Z=>{var ce;_.current=((ce=Z.touches.item(0))==null?void 0:ce.clientY)??null,M.current=0},[]),me=c.useCallback(Z=>{var Ge;const ce=h.current,je=((Ge=Z.touches.item(0))==null?void 0:Ge.clientY)??null,Ne=_.current;if(_.current=je,!ce||je===null||Ne===null||ce.scrollTop>0||!H){M.current=0;return}const $e=je-Ne;if($e<=0){M.current=0;return}if(!E.current){E.current=!0,M.current=0;return}M.current+=$e,M.current>=28&&le()},[H,le]),se=c.useCallback(()=>{_.current=null,M.current=0},[]),Le=c.useCallback(()=>{O(r)},[r]);return c.useLayoutEffect(()=>{const Z=window.requestAnimationFrame(()=>{te()});return()=>{window.cancelAnimationFrame(Z)}},[e,te]),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 Z=j.current,ce=h.current;if(!Z||!ce||a)return;j.current=null;const je=ce.scrollHeight-Z.scrollHeight;if(je<=0){g.current=ce.scrollHeight,x.current=ce.scrollTop;return}const Ne=Z.scrollTop+je;ce.scrollTop=Ne,x.current=Ne,g.current=ce.scrollHeight,y.current=!0,v.current=!1,E.current=!1},[a,r]),c.useEffect(()=>{O(Z=>Z>=r-1?r:Math.max(Z,Us))},[r]),c.useEffect(()=>{const Z=h.current;Z&&(g.current=Z.scrollHeight,x.current=Z.scrollTop,kr(Z,1)?(y.current=!1,v.current=!0):(y.current||!kr(Z,oa))&&(v.current=!1)),Y()},[Q,Y,J]),c.useEffect(()=>{const Z=o!==u.current,ce=p.current!==Q;if(p.current=Q,!(Z||ce&&v.current&&!y.current))return;const Ne=window.requestAnimationFrame(()=>{te()});return o!==u.current&&(u.current=o),()=>{window.cancelAnimationFrame(Ne)}},[Q,R,te,o]),c.useEffect(()=>{const Z=h.current,ce=m.current;if(!Z||!ce||typeof ResizeObserver>"u")return;g.current=Z.scrollHeight;const je=new ResizeObserver(()=>{const Ne=Z.scrollHeight,$e=g.current;if(g.current=Ne,Ne<=$e)return;const Ge=$e>0&&$e-Z.scrollTop-Z.clientHeight<=1;y.current||!(v.current||Ge||w.current)||window.requestAnimationFrame(()=>{te()})});return je.observe(ce),()=>{je.disconnect()}},[te]),c.useEffect(()=>{if(!v.current||y.current){f.current=l;return}if(l===f.current)return;f.current=l;const Z=window.requestAnimationFrame(()=>{te()});return()=>{window.cancelAnimationFrame(Z)}},[l,te]),c.useEffect(()=>{i==null||i(R)},[R,i]),{scrollContainerRef:h,scrollContentRef:m,tailSentinelRef:b,topSentinelRef:k,isTailVisible:R,handleScroll:de,handleWheel:xe,handleTouchStart:Re,handleTouchMove:me,handleTouchEnd:se,preserveScrollPositionForResize:we,serverManagedHistory:A,effectiveTotalTurnCount:ie,startIndex:U,visibleTurnAbsoluteOffset:G,hiddenCount:L,loadedHiddenCount:B,unloadedHiddenCount:$,showLoadAll:S,handleLoadEarlierClick:ke,handleLoadAllClick:Le}}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:w,loadingEarlier:v=!1,onLoadEarlier:y,ephemeralUserNote:C=null,answeredRequestNotes:N=[],activityNotes:E=[],optimisticSteers:_=[],optimisticTurn:M=null,onLoadHistoryItemDetail:J,onOpenThread:O,onSelectArtifact:X,onSelectHistoryItemDetail:K,adapter:R,autoCollapseCompletedTurns:ee}){var ft,ot,ht,bt,_t;const Q=Sl(),A=ee??(Q==null?void 0:Q.autoCollapseCompletedTurns)??!1,[ie,U]=c.useState({}),[D,G]=c.useState(()=>new Set),T=c.useRef(null),B=c.useRef(null),$=(R==null?void 0:R.onLoadHistoryItemDetail)??J,L=R==null?void 0:R.onOpenLinkedThread,{expandedText:S,openExpandedText:H,openCommandDetail:F,openToolCallDetail:le,openDeferredHistoryItemDetail:Y,closeExpandedText:de}=Ag({loadHistoryItemDetail:$,onSelectHistoryItemDetail:K}),{scrollContainerRef:te,scrollContentRef:we,tailSentinelRef:ke,topSentinelRef:xe,handleScroll:Re,handleWheel:me,handleTouchStart:se,handleTouchMove:Le,handleTouchEnd:Z,preserveScrollPositionForResize:ce,serverManagedHistory:je,effectiveTotalTurnCount:Ne,startIndex:$e,visibleTurnAbsoluteOffset:Ge,hiddenCount:_e,loadedHiddenCount:We,unloadedHiddenCount:V,showLoadAll:fe,handleLoadEarlierClick:ye,handleLoadAllClick:I}=Dg({threadId:e,turnsLength:r.length,totalTurnCount:n,loadingEarlier:v,onLoadEarlier:y,scrollRequestKey:p,bottomSpacer:x,onTailVisibilityChange:b,contentRevisionInputs:[r,a,l,_,u,i,d,M,N,E,C,x]}),W=c.useCallback((re,ne)=>{U(be=>({...be,[re]:!ne}))},[]),oe=c.useCallback((re,ne)=>{const be=ie[re.id];return be!==void 0?be:!!(A&&Bg(re.status)&&!ne.forceActive&&!ne.hasLiveActivity)},[ie,A]),ge=je?r:r.slice($e),Se=Ne+1,Ie=o&&(!s||!ge.some(re=>re.id===s)&&(M==null?void 0:M.id)!==s),he=(M==null?void 0:M.id)??((ft=ge.at(-1))==null?void 0:ft.id)??null,He=Ie&&he!==null,Ue=!!d&&(ge.some(re=>re.id===d.turnId)||(M==null?void 0:M.id)===d.turnId),Fe=d&&Ue?d.turnId:d&&He?he:null,at=M&&Fe===M.id?(d==null?void 0:d.items)??null:null,dt=((d==null?void 0:d.items.length)??0)>0,st=d&&Fe===null?d.items:null,rt=c.useMemo(()=>d&&Fe===null&&d.items.length>0?Mg(d.turnId,d.items):null,[d,Fe]),Ze=Math.max(1,Ne+(M?1:0)),ct=!!u&&!!M&&M.status!=="failed"&&!at,pt=u&&ge.length>0?s&&ge.some(re=>re.id===s)?s:((ot=ge.findLast(re=>ya(re.status)))==null?void 0:ot.id)??(He?he:null):null,z=!!pt,q=c.useMemo(()=>Pl(u),[u]),ve=[...l.map(re=>({id:re.id,prompt:re.prompt,status:"Accepted",createdAt:re.createdAt,canCancel:!0})),..._.map(re=>({id:re.id,prompt:re.prompt,status:re.status==="steering"?"Steering":null,createdAt:re.createdAt,canCancel:!1}))].sort((re,ne)=>re.createdAt.localeCompare(ne.createdAt)),Ce=c.useMemo(()=>Pf({answeredRequestNotes:N,pendingRequests:a,visibleTurns:ge,optimisticTurn:M}),[N,M,a,ge]),Me=c.useMemo(()=>Rf({activityNotes:E,visibleTurns:ge,optimisticTurn:M}),[E,M,ge]),Ke=c.useCallback(()=>{const re=te.current;if(!re)return null;const ne=re.getBoundingClientRect().top;return Array.from(re.querySelectorAll("[data-timeline-turn]")).find(be=>be.getBoundingClientRect().top>ne+8)??null},[te]),tt=c.useCallback(()=>{const re=te.current;if(!re)return null;const ne=re.getBoundingClientRect().top;return Array.from(re.querySelectorAll("[data-timeline-turn]")).findLast(be=>be.getBoundingClientRect().top<ne-8)??null},[te]),Ve=c.useCallback(()=>{k==null||k(!!tt())},[tt,k]),Ae=c.useCallback(()=>{w==null||w(!!Ke())},[Ke,w]),lt=c.useCallback(()=>{Re(),Ve(),Ae()},[Re,Ae,Ve]);return c.useEffect(()=>{Ve(),Ae()},[Ae,Ve,ge]),c.useEffect(()=>{if(f===0)return;const re=te.current,ne=tt(),be=re?Array.from(re.querySelectorAll("[data-timeline-turn]")):[],Xe=ne?be.indexOf(ne):-1,De=ne&&ne.dataset.turnId===T.current?be[Xe-1]??null:ne;if(!re||!De)return;T.current=De.dataset.turnId??null;const et=De.getBoundingClientRect().top-re.getBoundingClientRect().top;re.scrollTo({top:re.scrollTop+et-8,behavior:"smooth"}),be.indexOf(De)===0&&(k==null||k(!1))},[tt,k,f,te]),c.useEffect(()=>{if(g===0)return;const re=te.current,ne=Ke(),be=re?Array.from(re.querySelectorAll("[data-timeline-turn]")):[],Xe=ne?be.indexOf(ne):-1,De=ne&&ne.dataset.turnId===B.current?be[Xe+1]??null:ne;if(!re||!De)return;B.current=De.dataset.turnId??null;const et=De.getBoundingClientRect().top-re.getBoundingClientRect().top;re.scrollTo({top:re.scrollTop+et-8,behavior:"smooth"}),be.indexOf(De)===be.length-1&&(w==null||w(!1))},[Ke,g,w,te]),t.jsxs(t.Fragment,{children:[t.jsx("section",{className:`flex min-h-0 flex-1 flex-col ${j}`.trim(),children:t.jsx("div",{ref:te,"data-testid":"thread-scroll-container",onScroll:lt,onWheel:me,onTouchStart:se,onTouchMove:Le,onTouchEnd:Z,onTouchCancel:Z,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:we,className:"thread-graph-scroll-content",children:[t.jsx("div",{ref:xe,"aria-hidden":"true",className:"h-px"}),r.length>0&&t.jsx("div",{className:"thread-graph-history-control px-3 pb-1 pt-2 sm:px-5 sm:pb-1.5 sm:pt-3",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 text-xs sm:text-sm",children:[_e>0&&t.jsx("button",{type:"button",onClick:ye,disabled:v,className:"thread-graph-history-button rounded-full border px-2.5 py-1.5 transition",children:v?"Loading earlier...":"Load 3 earlier"}),fe&&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",_e>0?` · ${_e} earlier hidden${We>0&&V>0?` (${We} loaded)`:""}`:""]})]})}),r.length===0&&!u&&!M&&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||M||Me.leading.length>0||Me.trailing.length>0)&&t.jsxs("div",{className:"thread-graph-message-list",children:[Me.leading.length>0?t.jsx(br,{notes:Me.leading,onOpenThread:O,onOpenLinkedThread:L}):null,ge.map((re,ne)=>{var be,Xe,De,et,St;return t.jsxs("div",{"data-timeline-turn":!0,"data-turn-id":re.id,children:[(((be=Me.beforeTurnId.get(re.id))==null?void 0:be.length)??0)>0?t.jsx(br,{notes:Me.beforeTurnId.get(re.id)??[],onOpenThread:O,onOpenLinkedThread:L}):null,(((Xe=Ce.beforeTurnId.get(re.id))==null?void 0:Xe.length)??0)>0?t.jsx(sa,{entries:Ce.beforeTurnId.get(re.id)??[],respondingRequestId:h,onRespondToRequest:m??void 0}):null,(()=>{const yt=Gg(re,M),Yt=(i==null?void 0:i.turnId)===re.id?i:null,Mt=Fe===re.id?(d==null?void 0:d.items)??null:null,Zt=pt===re.id?u:"",pr=s===re.id||He&&he===re.id,ut=!!Yt||!!Zt||!!(Mt&&Mt.length>0),gn=oe(yt,{forceActive:pr,hasLiveActivity:ut});return t.jsx(Rn,{threadId:e,...R?{adapter:R}:{},turn:yt,absoluteIndex:Ge+ne+1,isCollapsed:gn,livePlan:Yt,liveItems:Mt,liveOutput:Zt,forceActive:pr,onToggleCollapse:W,onOpenExpandedText:H,onOpenCommandDetail:F,onOpenToolCallDetail:le,onOpenDeferredHistoryItemDetail:Y,onBeforeMessageResize:ce,...X?{onSelectArtifact:X}:{},scrollRootRef:te,articleRef:void 0})})(),(((De=Me.afterTurnId.get(re.id))==null?void 0:De.length)??0)>0?t.jsx(br,{notes:Me.afterTurnId.get(re.id)??[],onOpenThread:O,onOpenLinkedThread:L}):null,(et=Ce.notesByTurnId.get(re.id))!=null&&et.length||(St=Ce.pendingRequestsByTurnId.get(re.id))!=null&&St.length?t.jsx(_f,{notes:Ce.notesByTurnId.get(re.id)??[],requests:Ce.pendingRequestsByTurnId.get(re.id)??[],respondingRequestId:h,onRespondToRequest:m??void 0}):null]},re.id)}),M&&ge.every(re=>re.id!==M.id)&&t.jsxs(t.Fragment,{children:[(((ht=Me.beforeTurnId.get(M.id))==null?void 0:ht.length)??0)>0?t.jsx(br,{notes:Me.beforeTurnId.get(M.id)??[],onOpenThread:O,onOpenLinkedThread:L}):null,(((bt=Ce.beforeTurnId.get(M.id))==null?void 0:bt.length)??0)>0?t.jsx(sa,{entries:Ce.beforeTurnId.get(M.id)??[],respondingRequestId:h,onRespondToRequest:m??void 0}):null,(()=>{const re=ct?u:"",ne=s===M.id||He&&he===M.id,be=!!(at&&at.length>0)||!!re,Xe=oe(M,{forceActive:ne,hasLiveActivity:be});return t.jsx(Rn,{threadId:e,...R?{adapter:R}:{},turn:M,absoluteIndex:Se,isCollapsed:Xe,livePlan:null,liveItems:at,liveOutput:re,forceActive:ne,onToggleCollapse:W,onOpenExpandedText:H,onOpenCommandDetail:F,onOpenToolCallDetail:le,onOpenDeferredHistoryItemDetail:Y,onBeforeMessageResize:ce,...X?{onSelectArtifact:X}:{},scrollRootRef:te})})(),(((_t=Me.afterTurnId.get(M.id))==null?void 0:_t.length)??0)>0?t.jsx(br,{notes:Me.afterTurnId.get(M.id)??[],onOpenThread:O,onOpenLinkedThread:L}):null]})]}),ve.length>0&&t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:ve.map(re=>t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(zt,{threadId:e,item:{id:re.id,kind:"userMessage",text:re.prompt,status:re.status},scrollRootRef:te,onBeforeMessageResize:ce,...R?{adapter:R}:{}}),e&&re.canCancel&&(R!=null&&R.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:D.has(re.id),onClick:()=>{var ne;G(be=>new Set(be).add(re.id)),Promise.resolve((ne=R.cancelPendingSteer)==null?void 0:ne.call(R,e,re.id)).catch(()=>{}).finally(()=>{G(be=>{const Xe=new Set(be);return Xe.delete(re.id),Xe})})},children:D.has(re.id)?"Canceling...":"Cancel"})}):null]},re.id))}),(Ce.trailing.length>0||Me.trailing.length>0)&&t.jsx(Mf,{entries:[...Me.trailing.map(re=>({kind:"activity",id:re.id,createdAt:re.createdAt,note:re})),...Ce.trailing],respondingRequestId:h,onRespondToRequest:m??void 0,onOpenThread:O,onOpenLinkedThread:L}),C&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:t.jsx(zt,{threadId:e,item:{id:"ephemeral-plan-decision-note",kind:"userMessage",text:C},scrollRootRef:te,onBeforeMessageResize:ce})}),rt&&st&&st.length>0&&t.jsx(Rn,{threadId:e,...R?{adapter:R}:{},turn:rt,absoluteIndex:Ze,isCollapsed:ie[rt.id]??!1,livePlan:(i==null?void 0:i.turnId)===rt.id?i:null,liveItems:st,liveOutput:"",forceActive:!0,onToggleCollapse:W,onOpenExpandedText:H,onOpenCommandDetail:F,onOpenToolCallDetail:le,onOpenDeferredHistoryItemDetail:Y,onBeforeMessageResize:ce,...X?{onSelectArtifact:X}:{},scrollRootRef:te}),u&&!z&&!ct&&!dt&&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:te,onOpenExpandedText:H,onOpenCommandDetail:F,onOpenToolCallDetail:le,onOpenDeferredHistoryItemDetail:Y,onBeforeMessageResize:ce,...X?{onSelectArtifact:X}:{},...R?{adapter:R}:{}}):t.jsx(zt,{threadId:e,item:{id:"live-agent-message-fallback",kind:"agentMessage",text:u},scrollRootRef:te,streaming:!0,onBeforeMessageResize:ce,...R?{adapter:R}:{}})}),t.jsx("div",{ref:ke,"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,`
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,`
3956
3962
  `)}function Xs(e){const r=la(e),n=r.split(`
3957
3963
  `);return r.endsWith(`
3958
3964
  `)&&n.at(-1)===""&&n.pop(),n}function Og(e){const r=e.trim();return r?/(?:[$%#>])\s*$/.test(r):!1}function Wg(e,r){const n=r.trim();if(!n||e.length===0)return e;const[a,...s]=e;if(a===void 0)return e;const o=a.trim();return o===n||o.endsWith(` ${n}`)||o.endsWith(`$ ${n}`)||o.endsWith(`% ${n}`)||o.endsWith(`# ${n}`)||o.endsWith(`> ${n}`)?s:e}function Ug(e,r,n){var d,h;const a=Xs(e),s=Xs(r);let o=0;for(;o<a.length&&o<s.length&&a[o]===s[o];)o+=1;let l=0;for(;l<a.length-o&&l<s.length-o&&a[a.length-1-l]===s[s.length-1-l];)l+=1;let i=s.slice(o,s.length-l);for(i=Wg(i,n);i.length>0&&((d=i[0])==null?void 0:d.trim())==="";)i.shift();for(;i.length>0&&(((h=i.at(-1))==null?void 0:h.trim())===""||Og(i.at(-1)??""));)i.pop();return i.join(`
@@ -3961,8 +3967,8 @@ ${JSON.stringify({call:{tool:m,args:u,call_id:h},result:p},null,2)}
3961
3967
  `);o.endsWith(`
3962
3968
  `)&&l.at(-1)===""&&l.pop();let d=l.join(`\r
3963
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 Ys(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(`
3964
- `).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 kt(e){return e.status!=="exited"&&e.status!=="not_found"}function gx({shell:e,workspacePathMissing:r}){return!!(e&&!r&&kt(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&&kt(r)):null)??(e.shell&&kt(e.shell)?e.shell:null)??e.shells.find(kt)??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&&!kt(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&&!kt(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 Wt(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&&Wt(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&&Wt(n),e.shouldSendDetachMessage&&e.detachMessage&&r.send(e.detachMessage),l(null),i(e.isConnecting),e.settleAttachPromise!==void 0&&d(e.settleAttachPromise),e.shouldClearAttachTimeout&&Wt(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:w,setReconnectKey:v,setViewerId:y,setIsConnecting:C,setConnectionError:N,setRuntimePromptLabel:E,setIsCommandRunning:_,settleAttachPromise:M,onShellUpdate:J}){const O=e==null?void 0:e.id,X=e==null?void 0:e.cwd;c.useEffect(()=>{const K=o.current,R={shellId:O??null,terminalReady:a,isVisible:p.current,canAttachShell:n,userDisconnectedShellId:g.current,hasTerminal:!!K,hasPendingAttachRetry:u.current!==null,hasCurrentSocketForShell:!!(l.current&&d.current===O),hasReconnectTimer:h.current!==null};if(Lx(R).type==="skip")return;const Q=w.current(),A=Ix({...R,attachSize:Q});if(A.type==="skip"||A.type==="measureSize")return;if(A.type==="scheduleRetry"){wx({attachRetryTimerRef:u,setReconnectKey:v});return}if(A.shouldClearAttachRetry&&Wt(u),A.type==="reuseSocket"||(A.shouldClearReconnectTimer&&Wt(h),!O||!K))return;const ie=A.attachSize;d.current=O,K.reset(),N(null),y(null),C(!0),f.current=!1;const U=r.connectSocket({onConnected:()=>{var B;const D=m.current,G=zx({isCurrentSocket:((B=l.current)==null?void 0:B.socket)===U.socket,shellId:O,attachSize:ie,hasAttachTimeout:D!==null}),T=G.openAction;T&&(U.send(T.message),G.shouldClearAttachTimeout&&D!==null&&Wt(m),T.shouldScheduleAttachTimeout&&jx({shellSocket:U,socketRef:l,viewerIdRef:i,attachTimeoutRef:m,setConnectionError:N,setIsConnecting:C,settleAttachPromise:M}))},onShellEvent:D=>{var B;if(!Ex({eventShellId:D.shellId,shellId:O,socketExists:!!U.socket,isCurrentSocket:((B=l.current)==null?void 0:B.socket)===U.socket}))return;if(D.type==="shell.connected"){Wt(m);const $=Px(D);y($.viewerId),C(!1),M($.settleAttachPromise),J(O,$.nextShell,"attached");return}if(D.type==="shell.output"){const{output:$,snapshotUpdate:L}=Rx({event:D,shellCwd:X,currentSnapshot:x.current,pendingCommand:j.current});k.current={cursorX:$.cursorX,cursorY:$.cursorY,paneHeight:$.paneHeight},E($.promptLabel),_($.isCommandRunning),L&&(x.current=L.nextSnapshot,j.current=L.nextPendingCommand,L.lastCommandOutput!==null&&(b.current=L.lastCommandOutput),$.replace?Xl(K,$.data,$.cursorX,$.cursorY,$.paneHeight):K.write($.data));return}const T=px({event:D,currentViewerId:i.current});T&&(T.viewerId!==void 0&&y(T.viewerId),T.isConnecting!==void 0&&C(T.isConnecting),T.settleAttachPromise!==void 0&&M(T.settleAttachPromise),T.isCommandRunning!==void 0&&_(T.isCommandRunning),T.connectionError!==void 0&&N(T.connectionError),T.intentionalDisconnect!==void 0&&(f.current=T.intentionalDisconnect),T.shellUpdate&&J(O,$=>Mx($,T),T.shellUpdate.status),T.closeSocket&&U.socket.close())}});return l.current=U,U.socket.addEventListener("close",()=>{var T;const D=m.current,G=_x({isCurrentSocket:((T=l.current)==null?void 0:T.socket)===U.socket,hadViewer:!!i.current,intentionalDisconnect:f.current,userDisconnectedShellId:g.current,shellId:O,hasAttachTimeout:D!==null});Sx({closeApplication:G,shellId:O,attachTimeoutRef:m,socketRef:l,reconnectTimerRef:h,setViewerId:y,setIsConnecting:C,settleAttachPromise:M,onShellUpdate:J,setReconnectKey:v})}),()=>{const D=Ax(i),G=Cx({shellId:O,viewerId:D,shellSocket:U,attachRetryTimerRef:u,attachTimeoutRef:m,socketRef:l,openReadyState:WebSocket.OPEN});Tx({cleanupAction:G,shellSocket:U,attachRetryTimerRef:u,attachTimeoutRef:m,socketRef:l,intentionalDisconnectRef:f,setViewerId:y,setIsConnecting:C,settleAttachPromise:M})}},[u,m,n,f,p,b,J,j,s,h,N,_,C,v,E,y,M,X,O,r,d,x,k,l,w,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),w=c.useRef(null),v=c.useRef(null),y=c.useRef(null),C=c.useRef(!1),N=c.useRef(null),E=c.useRef(""),_=c.useRef(null),M=c.useRef(""),J=c.useRef(null),O=c.useRef(null),X=c.useRef({cursorX:void 0,cursorY:void 0,paneHeight:void 0}),K=c.useRef(!1),R=c.useRef(null),ee=c.useRef(s),Q=c.useRef(o),A=c.useRef(()=>!1),ie=c.useRef(()=>null),U=c.useRef(()=>{}),D=c.useRef(fx({clearTimeout:window.clearTimeout})),[G,T]=c.useState(null),[B,$]=c.useState(!1),[L,S]=c.useState(null),[H,F]=c.useState(!1),[le,Y]=c.useState(null),[de,te]=c.useState(null),[we,ke]=c.useState(!1),[xe,Re]=c.useState(0),me=(n==null?void 0:n.status)??"not_created",se=gx({shell:n,workspacePathMissing:i}),Le=c.useMemo(()=>Na(fn(n==null?void 0:n.cwd),null),[n==null?void 0:n.cwd]),Z=de??Le,ce=c.useCallback(V=>{b.current=V,S(V)},[]),je=c.useCallback(V=>{D.current.settle(V)},[]);c.useEffect(()=>{ee.current=s},[s]),c.useEffect(()=>{Q.current=o},[o]),c.useEffect(()=>{k.current=(n==null?void 0:n.id)??null},[n==null?void 0:n.id]);const Ne=c.useCallback(V=>{const fe=j.current,ye=k.current,I=b.current;return!fe||!ye||!I?!1:(fe.send({type:"shell.input",shellId:ye,viewerId:I,data:V}),!0)},[]);c.useEffect(()=>{A.current=Ne},[Ne]);const $e=c.useCallback(()=>{const V=j.current,fe=k.current,ye=b.current;return!V||!fe||!ye?!1:(V.send({type:"shell.clear",shellId:fe,viewerId:ye}),!0)},[]),Ge=c.useCallback(()=>{if(!s||!G)return!1;const V=G.getBoundingClientRect();return V.width>0&&V.height>0},[s,G]),_e=c.useCallback(V=>{const fe=g.current,ye=x.current;if(!fe||!ye||!Ge()||(ye.fit(),fe.cols<=0||fe.rows<=0))return null;const I={cols:fe.cols,rows:fe.rows},W=hx({size:I,previousSize:O.current,shellId:k.current,viewerId:b.current,syncBackendSize:(V==null?void 0:V.syncBackendSize)!==!1});return(V==null?void 0:V.syncBackendSize)===!1||(O.current=W.nextLastSentSize,!W.message)||j.current&&j.current.send(W.message),I},[Ge]);c.useEffect(()=>{ie.current=_e},[_e]);const We=c.useCallback(V=>{const fe=g.current;!fe||!Ge()||(_e((V==null?void 0:V.syncBackendSize)===void 0?void 0:{syncBackendSize:V.syncBackendSize}),E.current&&!Ys(G)?Xl(fe,E.current,X.current.cursorX,X.current.cursorY,X.current.paneHeight):fe.scrollToBottom(),V!=null&&V.focus&&!o&&fe.focus())},[o,Ge,_e,G]);return c.useEffect(()=>{U.current=()=>We()},[We]),c.useEffect(()=>{u({status:L?"attached":me,shellInputEnabled:!!(L&&n),isConnecting:H,isCommandRunning:we,promptLabel:Z,error:le,hasShell:!!n})},[le,H,we,u,Z,n,me,L]),c.useEffect(()=>{if(!G||g.current||K.current)return;let V=!1;return K.current=!0,(async()=>{const[{Terminal:fe},{FitAddon:ye}]=await Promise.all([Be(()=>import("./terminal-vendor-C5bTa-Ka.js").then(oe=>oe.x),__vite__mapDeps([17,2,18])),Be(()=>import("./terminal-vendor-C5bTa-Ka.js").then(oe=>oe.a),__vite__mapDeps([17,2,18]))]);if(V||!G){K.current=!1;return}const I=new fe({cursorBlink:!0,disableStdin:Q.current,fontFamily:"IBM Plex Mono, SFMono-Regular, Menlo, monospace",fontSize:13,lineHeight:1.25,scrollback:3e3,theme:qs(l)}),W=new ye;I.loadAddon(W),I.open(G),g.current=I,x.current=W,ie.current(),I.attachCustomKeyEventHandler(oe=>{if(Q.current||oe.type!=="keydown")return!0;if(oe.ctrlKey&&!oe.altKey&&!oe.metaKey&&!oe.shiftKey){const ge=Fg(oe.key);if(!ge)return!0;if(A.current(ge))return oe.preventDefault(),!1}return!0}),$(!0),K.current=!1,J.current=new ResizeObserver(()=>{U.current()}),J.current.observe(G),R.current=I.onData(oe=>{Q.current||A.current(oe)})})(),()=>{var fe,ye,I;V=!0,K.current=!1,(fe=R.current)==null||fe.dispose(),R.current=null,(ye=J.current)==null||ye.disconnect(),J.current=null,$(!1),(I=g.current)==null||I.dispose(),g.current=null,x.current=null,O.current=null}},[l,G]),c.useEffect(()=>{var fe;const V=lx({hasShell:!!n});V&&(ce(V.viewerId),F(V.isConnecting),je(V.settleAttachPromise),Y(V.connectionError),te(V.runtimePromptLabel),ke(V.isCommandRunning),E.current=V.shellSnapshot,M.current=V.lastCommandOutput,_.current=V.pendingCommand,V.shouldResetTerminal&&((fe=g.current)==null||fe.reset()))},[ce,je,n]),c.useEffect(()=>{const V=g.current;V&&(V.options.theme=qs(l))},[l]),c.useEffect(()=>{const V=g.current;V&&(V.options.disableStdin=o)},[o]),c.useEffect(()=>{if(!s||!B)return;const V=window.requestAnimationFrame(()=>{We({focus:a,syncBackendSize:!1}),!j.current&&(n!=null&&n.id)&&N.current!==n.id&&Re(fe=>fe+1)});return()=>{window.cancelAnimationFrame(V)}},[a,s,We,n==null?void 0:n.id,B]),$x({shell:n,shellAdapter:d,canAttachShell:se,terminalReady:B,reconnectKey:xe,terminalRef:g,socketRef:j,viewerIdRef:b,shellIdRef:k,reconnectTimerRef:w,attachTimeoutRef:v,attachRetryTimerRef:y,isVisibleRef:ee,intentionalDisconnectRef:C,userDisconnectedShellIdRef:N,shellSnapshotRef:E,pendingCommandRef:_,lastCommandOutputRef:M,snapshotCursorRef:X,syncTerminalSizeRef:ie,setReconnectKey:Re,setViewerId:ce,setIsConnecting:F,setConnectionError:Y,setRuntimePromptLabel:te,setIsCommandRunning:ke,settleAttachPromise:je,onShellUpdate:m}),c.useEffect(()=>()=>{const V=$n(w),fe=$n(v),ye=$n(y),I=ix({hasReconnectTimer:V!==null,hasAttachTimeout:fe!==null,hasAttachRetry:ye!==null});I.shouldClearReconnectTimer&&V!==null&&window.clearTimeout(V),I.shouldClearAttachTimeout&&fe!==null&&window.clearTimeout(fe),I.shouldClearAttachRetry&&ye!==null&&window.clearTimeout(ye),je(I.settleAttachPromise)},[je]),c.useImperativeHandle(f,()=>({disconnect(){const V=j.current,fe=k.current,ye=b.current,I=dx({shellId:fe,viewerId:ye,hasSocket:!!V});N.current=I.userDisconnectedShellId,C.current=I.intentionalDisconnect,V&&I.detachMessage&&V.send(I.detachMessage),ce(null),F(!1),je(!1),I.shouldCloseSocket&&(V==null||V.socket.close()),j.current=null,O.current=null,I.shouldDetachShell&&fe&&m(fe,W=>({...W,status:"detached",attachedViewerId:null}),"detached")},reconnect(){const V=sx({hasShellId:!!k.current,terminalReady:B,workspacePathMissing:i,hasViewer:!!b.current,hasPendingAttach:D.current.hasPending()});if(V.type==="reject")return Promise.resolve(!1);if(V.type==="alreadyConnected")return Promise.resolve(!0);if(V.type==="joinPending")return D.current.joinPending();const fe=D.current.start({timeoutMs:Jg,setTimeout:window.setTimeout,onTimeout:()=>{F(!1)}}),ye=ox({shellId:k.current,userDisconnectedShellId:N.current});return ye.shouldClearUserDisconnectedShellId&&(N.current=null),C.current=ye.intentionalDisconnect,Y(ye.connectionError),F(ye.isConnecting),Re(I=>I+1),fe},sendInput(V){return Ne(V)},sendCommand(V){const fe={command:V,beforeSnapshot:E.current};if(_.current=fe,V.trim()==="clear"){const W=$e();return!W&&_.current===fe&&(_.current=null),W}const ye=V.endsWith(`
3965
- `)?V:`${V}
3966
- `,I=Ne(ye);return!I&&_.current===fe&&(_.current=null),I},sendControl(V){return V==="clear"?$e():Ne(Vg(V))},async copyLastCommandOutput(){const V=M.current.trim()||Ys(G);if(!V)return p==null||p("failed","Nothing to copy"),!1;try{return await navigator.clipboard.writeText(V),p==null||p("done","Copied"),!0}catch{return p==null||p("failed","Copy failed"),!1}},focus(){var V;(V=g.current)==null||V.focus()},refreshLayout(V){We(V)}}),[p,m,We,$e,Ne,ce,je,G,B,i]),t.jsxs("div",{className:`relative min-h-0 flex-1 overflow-hidden ${a?"shell-pane-active":""}`,onMouseDown:h,"data-pane-id":r,children:[t.jsx("div",{ref:T,className:`h-full w-full px-2 py-2 sm:px-3 sm:py-3 ${o?"mobile-shell-selectable":""}`,onMouseDown:()=>{var V;h(),(V=g.current)==null||V.focus()}}),a&&t.jsx("div",{className:"pointer-events-none absolute right-2 top-2 rounded-md border border-sky-300/30 bg-sky-300/10 px-2 py-1 text-[10px] uppercase tracking-[0.12em] text-sky-100",children:"Active"})]})}),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),[w,v]=c.useState(!0),[y,C]=c.useState(!1),[N,E]=c.useState(null),[_,M]=c.useState("primary"),[J,O]=c.useState(null),[X,K]=c.useState(null),[R,ee]=c.useState("single"),[Q,A]=c.useState(50),[ie,U]=c.useState(null),[D,G]=c.useState(""),[T,B]=c.useState(!1),[$,L]=c.useState(!1),[S,H]=c.useState(!1),[F,le]=c.useState({primary:Zs,secondary:Zs}),[Y,de]=c.useState(null),te=(b==null?void 0:b.state)??"not_created",we=c.useMemo(()=>(b==null?void 0:b.shells)??[],[b==null?void 0:b.shells]),ke=c.useMemo(()=>we.filter(kt),[we]),xe=c.useMemo(()=>ke.find(z=>z.id===J)??null,[ke,J]),Re=c.useMemo(()=>ke.find(z=>z.id===X)??null,[ke,X]),me=_==="secondary"?Re:xe,se=F[_],Le=(b==null?void 0:b.workspacePathStatus)==="missing",Z=_==="secondary"?p:u,ce=vx({activeRuntime:se,activeShell:me,busy:y,loading:w,status:te,workspacePathMissing:Le}),je=ce.disabled,Ne=ce.label,$e=ce.className,Ge=(Y==null?void 0:Y.tone)==="done"?"shell-floating-feedback shell-floating-feedback-done":(Y==null?void 0:Y.tone)==="failed"?"shell-floating-feedback shell-floating-feedback-failed":"shell-floating-feedback",_e=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)},[]),We=c.useCallback((z,q,ve)=>{k(Ce=>{var tt;if(!Ce)return Ce;const Me=Ce.shells.map(Ve=>Ve.id===z?q(Ve):Ve),Ke=((tt=Ce.shell)==null?void 0:tt.id)===z?q(Ce.shell):Me.find(Ve=>{var Ae;return Ve.id===((Ae=Ce.shell)==null?void 0:Ae.id)})??Ce.shell;return{...Ce,...ve?{state:ve}:{},shell:Ke,shells:Me}})},[]),V=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(()=>{V()},[V]),c.useEffect(()=>{const z=i==null?void 0:i(r);if(z==null){A(50);return}const q=typeof z=="number"?z:Number.parseFloat(String(z));A(Number.isFinite(q)?Mn(q):50)},[i,r]),c.useEffect(()=>{if(!b){O(null),K(null);return}const z=bx(b);O(q=>q&&b.shells.some(ve=>ve.id===q&&kt(ve))?q:(z==null?void 0:z.id)??null),K(q=>{if(R!=="columns")return null;if(q&&b.shells.some(Ce=>Ce.id===q&&kt(Ce)))return q;const ve=b.shells.find(Ce=>kt(Ce)&&Ce.id!==(z==null?void 0:z.id));return(ve==null?void 0:ve.id)??null})},[b,R]),c.useEffect(()=>{R!=="columns"&&(M("primary"),K(null))},[R]),c.useEffect(()=>{if(R!=="columns"||X||ke.length<2)return;const z=ke.find(q=>q.id!==(xe==null?void 0:xe.id))??null;z&&K(z.id)},[ke,xe==null?void 0:xe.id,X,R]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const z=window.matchMedia("(max-width: 767px), (hover: none) and (pointer: coarse)"),q=()=>{B(z.matches),z.matches||(H(!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 fe=c.useCallback((z,q)=>{le(ve=>{const Ce=ve[z];return xx(Ce,q)?ve:{...ve,[z]:q}})},[]),ye=c.useCallback(z=>fe("primary",z),[fe]),I=c.useCallback(z=>fe("secondary",z),[fe]),W=c.useCallback(z=>{var ve;if((ve=z.label)!=null&&ve.trim())return z.label.trim();const q=we.findIndex(Ce=>Ce.id===z.id);return`Shell ${q>=0?q+1:""}`.trim()},[we]),oe=c.useCallback(z=>{var q;U(z.id),G(((q=z.label)==null?void 0:q.trim())||W(z))},[W]),ge=c.useCallback(()=>{U(null),G("")},[]),Se=c.useCallback(async()=>{if(ie){C(!0);try{const z=D.trim(),q=await n.updateShell(ie,{label:z.length>0?z:null});k(ve=>{var Ce;return ve&&{...ve,state:ve.activeShellId===q.id?q.status:ve.state,shell:((Ce=ve.shell)==null?void 0:Ce.id)===q.id?q:ve.shell,shells:ve.shells.map(Me=>Me.id===q.id?q:Me)}}),U(null),G(""),E(null)}catch(z){E(z instanceof Error?z.message:"Unable to rename shell.")}finally{C(!1)}}},[D,ie,n]),Ie=c.useCallback((z,q)=>{if(z==="primary"){O(q),K(ve=>ve===q?null:ve);return}K(q),O(ve=>ve===q?null:ve)},[]),he=c.useCallback(z=>{var q,ve;if(z==="primary"){(q=u.current)==null||q.disconnect(),O(null),R==="columns"&&M("secondary");return}(ve=p.current)==null||ve.disconnect(),K(null),M("primary"),ee("single")},[R]),He=c.useCallback((z,q=_)=>{const ve=R==="columns"?q:"primary";Ie(ve,z.id),R!=="columns"&&K(null),M(ve)},[_,Ie,R]),Ue=c.useCallback(async(z=_)=>{var q;if(!j.current){j.current=!0,C(!0);try{const ve=await n.createShell(r);k(ve);const Ce=ve.activeShellId??((q=ve.shell)==null?void 0:q.id)??null;if(Ce){const Me=R==="columns"?z:"primary";Ie(Me,Ce),R!=="columns"&&K(null),M(Me)}E(null)}catch(ve){E(ve instanceof Error?ve.message:"Unable to create shell.")}finally{j.current=!1,C(!1)}}},[_,Ie,n,R,r]);c.useEffect(()=>{!a||!b||w||y||Le||te==="creating"||ke.length>0||Ue("primary")},[y,Ue,a,ke.length,w,b,te,Le]);const Fe=c.useCallback(async(z=(me==null?void 0:me.id)??"")=>{if(z){C(!0);try{await n.terminateShell(z),O(q=>q===z?null:q),K(q=>q===z?null:q),await V(),E(null)}catch(q){E(q instanceof Error?q.message:"Unable to terminate shell.")}finally{C(!1)}}},[me==null?void 0:me.id,V,n]),at=c.useCallback(async()=>{var z,q;if(!je){if(se.shellInputEnabled){(z=Z.current)==null||z.disconnect();return}if(!me||me.status==="exited"||me.status==="not_found"){await Ue(_);return}await((q=Z.current)==null?void 0:q.reconnect())}},[_,Z,se.shellInputEnabled,me,je,Ue]),dt=c.useCallback(z=>{typeof window>"u"||d==null||d(r,Mn(z))},[d,r]),st=c.useCallback(()=>{var z,q;(z=u.current)==null||z.refreshLayout({syncBackendSize:!0}),(q=p.current)==null||q.refreshLayout({syncBackendSize:!0})},[]),rt=c.useCallback(z=>{var Ke,tt;if(R!=="columns")return;const q=g.current;if(!q)return;z.preventDefault(),(tt=(Ke=z.currentTarget).setPointerCapture)==null||tt.call(Ke,z.pointerId);const ve=Ve=>{const Ae=q.getBoundingClientRect();if(Ae.width<=0)return;const lt=Mn((Ve-Ae.left)/Ae.width*100);A(lt),x.current!==null&&window.cancelAnimationFrame(x.current),x.current=window.requestAnimationFrame(()=>{x.current=null,st()})},Ce=Ve=>{ve(Ve.clientX)},Me=Ve=>{ve(Ve.clientX);const Ae=q.getBoundingClientRect();Ae.width>0&&dt((Ve.clientX-Ae.left)/Ae.width*100),window.removeEventListener("pointermove",Ce),window.removeEventListener("pointerup",Me)};window.addEventListener("pointermove",Ce),window.addEventListener("pointerup",Me,{once:!0})},[dt,st,R]),Ze=c.useCallback((z,q)=>{Ie(q,z.id),M(q)},[Ie]),ct=c.useCallback(async()=>{var q;return await((q=Z.current)==null?void 0:q.copyLastCommandOutput())?!0:(_e("failed","Nothing to copy"),!1)},[Z,_e]);c.useEffect(()=>{h==null||h(kx({activeRuntime:se,activeShell:me,connectionButtonDisabled:je,connectionButtonLabel:Ne,isMobileShell:T,busy:y,loading:w,error:N}))},[se,me,y,je,Ne,N,T,w,h]),c.useImperativeHandle(m,()=>({async toggleConnection(){await at()},sendInput(z){var q;return((q=Z.current)==null?void 0:q.sendInput(z))??!1},sendCommand(z){var q;return((q=Z.current)==null?void 0:q.sendCommand(z))??!1},sendControl(z){var q;return((q=Z.current)==null?void 0:q.sendControl(z))??!1},async copyLastCommandOutput(){var z;return await((z=Z.current)==null?void 0:z.copyLastCommandOutput())??!1},async terminate(){await Fe()},focus(){var z;(z=Z.current)==null||z.focus()},refreshLayout(z){var q,ve;(q=u.current)==null||q.refreshLayout(z),R==="columns"&&((ve=p.current)==null||ve.refreshLayout(z))}}),[Z,at,Fe,R]);const pt=z=>t.jsx("div",{className:`rounded-md border px-2 py-1.5 text-xs ${z.id===(me==null?void 0:me.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(),Se()},children:t.jsx("input",{value:D,onChange:q=>G(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:()=>oe(z),className:"min-w-0 flex-1 text-left",title:z.tmuxSessionName,children:[t.jsx("span",{className:"block truncate",children:W(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 Se(),className:"rounded border border-sky-300/35 bg-sky-300/12 px-1.5 py-1 text-[10px] text-sky-50",title:"Save shell name",children:"Save"}),t.jsx("button",{type:"button",onClick:ge,className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200",title:"Cancel rename",children:"Cancel"})]}):t.jsx("button",{type:"button",onClick:()=>oe(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"}),R==="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 Fe(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:se.promptLabel??(me==null?void 0:me.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(se.status)})`,disabled:je,onClick:()=>void at(),className:`inline-flex h-10 w-10 items-center justify-center rounded-full border shadow-lg shadow-stone-950/25 transition disabled:cursor-not-allowed disabled:opacity-60 ${$e}`,children:t.jsx(qg,{connected:se.shellInputEnabled})}),me&&t.jsx("button",{type:"button",disabled:y,onClick:()=>void Fe(me.id),className:"rounded-full border border-rose-300/35 bg-rose-300/12 px-3 py-2 text-sm text-rose-600 transition hover:bg-rose-300/18 dark:text-rose-100 disabled:cursor-not-allowed disabled:opacity-60",children:"Terminate"})]})]}),(N||w||Le)&&t.jsxs("div",{className:"shell-banner mt-3 rounded-2xl border px-3 py-3 text-sm",children:[w&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!w&&Le&&t.jsx("p",{className:"text-rose-600 dark:text-rose-100",children:"Workspace path is missing on this machine. Restore the path before creating a shell."}),!w&&N&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:N})]})]}),t.jsx("div",{className:"min-h-0 flex-1",children:t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("div",{className:"shell-terminal-bar flex shrink-0 items-center gap-2 border-b px-2 py-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-1",children:[t.jsx("span",{className:"min-w-0 truncate text-xs text-[var(--theme-fg-soft)]",children:me?W(me):"No live shell process"}),me&&t.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.12em] text-[var(--theme-fg-muted)]",children:_n(se.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(pt),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||Le,onClick:()=>void Ue(_),className:"inline-flex h-8 w-8 items-center justify-center rounded-md border border-sky-300/35 bg-sky-300/12 text-base leading-none text-sky-50 disabled:cursor-not-allowed disabled:opacity-50",children:"+"})})]}),te==="not_created"||Le?t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"shell-empty-state max-w-md rounded-[1.6rem] border px-6 py-8",children:[t.jsx("p",{className:"text-base font-medium text-[var(--theme-fg)]",children:"Durable thread shell"}),t.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--theme-fg-muted)]",children:"The shell runs under a supervisor-managed PTY and reconnects after browser disconnects. Create it explicitly when you want to inspect or take over the workspace."}),!Le&&t.jsx("button",{type:"button",disabled:y||w,onClick:()=>void Ue("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||w||Le)&&t.jsxs("div",{className:"shell-banner absolute left-2 right-2 top-2 z-10 rounded-2xl border px-3 py-3 text-sm backdrop-blur sm:left-3 sm:right-3 sm:top-3",children:[w&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!w&&Le&&t.jsx("p",{className:"text-rose-600 dark:text-rose-100",children:"Workspace path is missing on this machine. Restore the path before creating a shell."}),!w&&N&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:N})]}),t.jsxs("div",{ref:g,className:`relative grid h-full min-h-0 ${R==="columns"?"grid-cols-1 sm:grid-cols-[var(--shell-left)_0.35rem_var(--shell-right)]":"grid-cols-1"}`,style:R==="columns"?{"--shell-left":`${Q}fr`,"--shell-right":`${100-Q}fr`}:void 0,"data-shell-split-ratio":Q,children:[t.jsx(Js,{ref:u,paneId:"primary",shell:xe,isActive:_==="primary",isVisible:a,isMobileShell:T,effectiveTheme:l,workspacePathMissing:Le,shellAdapter:n,onActivate:()=>M("primary"),onShellUpdate:We,onRuntimeStateChange:ye,onFeedback:_e}),R==="columns"&&t.jsx("button",{type:"button",onClick:()=>he("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"}),R==="columns"&&t.jsx("button",{type:"button","aria-label":"Resize shell panes",title:"Resize shell panes",onPointerDown:rt,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"}),R==="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:Re,isActive:_==="secondary",isVisible:a,isMobileShell:T,effectiveTheme:l,workspacePathMissing:Le,shellAdapter:n,onActivate:()=>M("secondary"),onShellUpdate:We,onRuntimeStateChange:I,onFeedback:_e}),t.jsx("button",{type:"button",onClick:()=>he("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:[Y&&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:Y.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:()=>{_e("idle","Use the prompt box tools to paste")},className:"inline-flex items-center justify-center rounded-full border border-sky-300/35 bg-sky-300/12 px-2.5 py-2 text-sky-600 dark:text-sky-50",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Ks,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:()=>void ct(),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:!se.shellInputEnabled,onClick:()=>{var z;(z=Z.current)!=null&&z.sendControl("clear")?_e("done","Cleared"):_e("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(An,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!se.shellInputEnabled||!se.isCommandRunning,onClick:()=>{var z;(z=Z.current)!=null&&z.sendInput("")?_e("done","Sent Ctrl-C"):_e("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:!se.shellInputEnabled,onClick:()=>{var q;(q=Z.current)!=null&&q.sendControl(z)?_e("done",`Sent ${z.toUpperCase().replace("_","-")}`):_e("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:()=>H(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:[ke.length," live"]})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-1 overflow-y-auto",children:[ke.map(pt),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||Le,onClick:()=>void Ue(_),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",busy:s=!1,onCancel:o,onConfirm:l}){return c.useEffect(()=>{if(!e)return;function i(d){d.key==="Escape"&&!s&&o()}return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[s,o,e]),e?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:o,disabled:s,className:"absolute inset-0 bg-stone-950/78 backdrop-blur-sm disabled:cursor-not-allowed"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":r,className:"relative z-[1] w-full max-w-md rounded-[1.6rem] border border-stone-700 bg-stone-900 p-5 shadow-2xl shadow-stone-950/40 sm:p-6",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium text-stone-100",children:r}),t.jsx("p",{className:"mt-2 text-sm leading-6 text-stone-400",children:n})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:o,disabled:s,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-stone-700 text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsxs("div",{className:"mt-5 flex items-center justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:o,disabled:s,className:"rounded-full border border-stone-700 px-4 py-2 text-sm font-medium text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),t.jsx("button",{type:"button",onClick:()=>void l(),disabled:s,className:"ui-action-danger rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:s?"Deleting...":a})]})]})]}),document.body):null}function 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 B,$,L;const f=c.useMemo(()=>{var S;return((S=n.data)==null?void 0:S.turns)??[]},[(B=n.data)==null?void 0:B.turns]),[g,x]=c.useState(l),[j,b]=c.useState("latest-10"),[k,w]=c.useState(()=>new Set),[v,y]=c.useState(!0),[C,N]=c.useState(""),[E,_]=c.useState("read"),[M,J]=c.useState("none"),[O,X]=c.useState(""),[K,R]=c.useState(()=>typeof document<"u"&&!document.documentElement.classList.contains("dark")?"light":"dark");if(c.useEffect(()=>{e&&(x(l),b("latest-10"),y(!0),N(""),_("read"),J("none"),X(""),d())},[l,d,e]),c.useEffect(()=>{e&&f.length>0&&w(new Set(f.slice(0,10).map(S=>S.turnId)))},[e,f]),c.useEffect(()=>{if(!e)return;function S(H){H.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"),H=()=>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(R(H()),!S)return;const F=new MutationObserver(()=>R(H()));return F.observe(S,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>F.disconnect()},[e]),!e)return null;const ee=Wx(j),Q=ee!==null?Math.min(ee,(($=n.data)==null?void 0:$.totalTurnCount)??ee):j==="all-loaded"?f.length:k.size,A=!r&&g!=="share"&&(ee!==null||j==="all-loaded"||k.size>0),ie=!r&&a&&!!m&&C.trim().length>0;function U(S){w(H=>{const F=new Set(H);return F.has(S)?F.delete(S):F.add(S),F})}function D(){if(g==="share")return;const S={format:g,...ee!==null?{mode:"latest",limit:ee}:j==="all-loaded"?{mode:"selected",turnIds:f.map(H=>H.turnId)}:{mode:"selected",turnIds:[...k]},profile:"review",options:{includeTokenAndPrice:v}};h(S)}function G(S){S.preventDefault(),ie&&(m==null||m({targetIdentifier:C.trim(),threadAccess:E,workspaceAccess:M,label:O.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-${K} fixed inset-0 z-[96] flex items-end justify-center p-0 sm:items-center sm:p-6`,"data-theme-effective":K,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:G,children:[a?null:t.jsx("p",{className:"thread-export-dialog-box thread-export-dialog-subtitle rounded-2xl border px-3 py-3 text-sm",children:s}),a&&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,H])=>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:()=>_(S)}),H]},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,H])=>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:M===S,disabled:!a||r,onChange:()=>J(S)}),H]},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=>X(S.target.value),placeholder:"optional",value:O})]}),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:()=>w(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:()=>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(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:()=>U(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=>y(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.":`${Q} ${Q===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:D,disabled:!A,className:"ui-status-warning rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:r?"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,w]=c.useState(0),[v,y]=c.useState(!1),C=c.useRef(null),N=i==null?void 0:i.onTailVisibilityChange,E=e.pendingRequests.length>0,_=c.useMemo(()=>{const D=e.pendingSteers??[],G=new Set(D.map(T=>T.clientRequestId).filter(T=>!!T));return[...D.filter(T=>T.delivery==="continuation").map(T=>({id:T.id,prompt:T.prompt,...T.id.startsWith("optimistic-")?{optimistic:!0}:{}})),...((i==null?void 0:i.optimisticSteers)??[]).filter(T=>!G.has(T.clientRequestId)).map(T=>({id:T.id,prompt:T.prompt,optimistic:!0}))]},[e.pendingSteers,i==null?void 0:i.optimisticSteers]),M=c.useMemo(()=>(e.pendingSteers??[]).filter(D=>D.delivery==="steer"),[e.pendingSteers]),J=c.useMemo(()=>{var D;return l?{...l,pendingPrompts:_,...r.steerPendingPrompt&&((D=l.capabilities)!=null&&D.turns.steer)?{onSteerPendingPrompt:G=>{var T;return(T=r.steerPendingPrompt)==null?void 0:T.call(r,e.thread.id,G)}}:{},...r.cancelPendingSteer?{onCancelPendingPrompt:G=>{var T;return(T=r.cancelPendingSteer)==null?void 0:T.call(r,e.thread.id,G)}}:{}}:null},[r.cancelPendingSteer,r.steerPendingPrompt,l,e.thread.id,_]),O=c.useCallback(D=>{N==null||N(D)},[N]);c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const D=window.matchMedia("(max-width: 639px)"),G=()=>f(D.matches);return G(),D.addEventListener("change",G),()=>{D.removeEventListener("change",G)}},[]),c.useEffect(()=>{var G,T;if(typeof window>"u")return;const D=()=>{const B=window.visualViewport,$=B?Math.max(0,Math.round(window.innerHeight-B.height-B.offsetTop)):0,L=B?Math.max(0,Math.round(window.innerHeight-B.height)):$,S=Math.min($,L),H=Math.max(0,Math.round(window.innerHeight*.52));w(Math.min(S,H))};return D(),(G=window.visualViewport)==null||G.addEventListener("resize",D),(T=window.visualViewport)==null||T.addEventListener("scroll",D),window.addEventListener("resize",D),()=>{var B,$;(B=window.visualViewport)==null||B.removeEventListener("resize",D),($=window.visualViewport)==null||$.removeEventListener("scroll",D),window.removeEventListener("resize",D)}},[]),c.useLayoutEffect(()=>{const D=C.current;if(!D||!p){x(0);return}const G=()=>{x(Math.ceil(D.getBoundingClientRect().height))};if(G(),typeof ResizeObserver>"u")return;const T=new ResizeObserver(G);return T.observe(D),()=>{T.disconnect()}},[p,l,E]),c.useLayoutEffect(()=>{var B,$;const D=C.current;if(!D||!p){b(0);return}const G=()=>{const L=D.getBoundingClientRect();b(Math.max(0,Math.ceil(window.innerHeight-L.top)))};G(),window.addEventListener("resize",G),(B=window.visualViewport)==null||B.addEventListener("resize",G),($=window.visualViewport)==null||$.addEventListener("scroll",G);let T=null;return typeof ResizeObserver<"u"&&(T=new ResizeObserver(G),T.observe(D)),()=>{var L,S;window.removeEventListener("resize",G),(L=window.visualViewport)==null||L.removeEventListener("resize",G),(S=window.visualViewport)==null||S.removeEventListener("scroll",G),T==null||T.disconnect()}},[p,k,v,l,E]),c.useEffect(()=>{if(!p){y(!1);return}const D=T=>{var $;const B=T.target;B instanceof HTMLElement&&(($=C.current)!=null&&$.contains(B))&&y(!0)},G=T=>{var $;const B=T.relatedTarget;B instanceof HTMLElement&&(($=C.current)!=null&&$.contains(B))||y(!1)};return document.addEventListener("focusin",D),document.addEventListener("focusout",G),()=>{document.removeEventListener("focusin",D),document.removeEventListener("focusout",G)}},[p]);const X=c.useCallback(D=>{C.current=D,u&&(u.current=D)},[u]),K=p&&v?Math.max(0,k-m):0,R=Math.max(g,144),ee=Math.max(j,R+K),Q=p?ee+12:0,A=Q>0?{"--thread-graph-chat-scroll-bottom-spacer":`${Q}px`}:void 0,ie=h&&p?{bottom:`${m+K}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"}:void 0,U=c.useMemo(()=>{const D=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:D,liveOutput:s,className:"thread-timeline-surface min-h-0 flex-1",...i,pendingSteers:M,optimisticSteers:[],adapter:n,onOpenThread:(i==null?void 0:i.onOpenThread)??r.openThread,onTailVisibilityChange:O})},[a,r.openThread,e.pendingRequests,e.thread.activeTurnId,e.thread.id,e.thread.status,e.totalTurnCount,e.turns,O,s,n,i,M]);return t.jsxs("div",{"data-testid":"chat-panel",className:"thread-graph-chat-panel relative flex h-full min-h-0 flex-col",style:A,children:[o,U,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:X,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,{...J,activeView:"chat",edgeToEdgeMobile:!0,onSubmit:r.sendPrompt})}):t.jsx("div",{ref:X,className:"thread-graph-composer-host shrink-0",children:t.jsx(ta,{...J,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:w,workspaceContent:v,workspaceTitle:y,workspaceActions:C,workspaceFeatures:N,workspaceFocusPathRequest:E=null,onNewThreadTitle:_,beforeTimelineContent:M,errorContent:J,workspaceMissingContent:O,dialogs:X,currentThreadId:K,currentWorkspaceId:R,currentWorkspaceLabel:ee,onCloseAppNavigation:Q,className:A="thread-detail-surface relative flex h-full min-h-0 flex-1 flex-col overflow-hidden",activeView:ie="chat",liveOutput:U="",timelineProps:D,composerProps:G,shellComposerProps:T,useFloatingMobileComposer:B=!1,floatingMobileComposerBottomOffset:$=0,composerHostRef:L,shellPanelRef:S,shellEffectiveTheme:H="dark",shellThemeMode:F=H,onShellThemeModeChange:le,onShellStateChange:Y,shellUnavailableContent:de,shellDisconnectedContent:te,timelineComponent:we=Wl,shellPanelComponent:ke=Dx,shellContent:xe,loadingContent:Re,emptyContent:me}){const se=c.useMemo(()=>r?Zx(r):null,[r]),Le=wa(),Z=o??Le??va(),{getImageAssetUrl:ce,loadHistoryItemDetail:je,openWorkspaceFile:Ne,openThread:$e,cancelPendingSteer:Ge}=l,_e=c.useMemo(()=>({...ce?{getImageAssetUrl:ge=>ce(ge.path)}:{},onOpenLinkedThread:$e,...Ne?{onOpenWorkspaceFile:Ne}:{},...je?{onLoadHistoryItemDetail:je}:{},...Ge?{cancelPendingSteer:Ge}:{}}),[Ge,ce,je,Ne,$e]),We=Z.getThreadPanels().some(ge=>ge.kind==="terminal"),V=c.useMemo(()=>se?qx(se):null,[se]),fe=c.useMemo(()=>Kx(V),[V]),ye=c.useMemo(()=>{var ge;return se?se.turns.reduce((Se,Ie)=>Se+Ie.items.length,((ge=se.liveItems)==null?void 0:ge.items.length)??0):0},[se]),I=v??(se?t.jsx(ql,{detail:se,status:s,plugins:Z,workspaceAdapter:l.workspace??null,metaContent:i,settingsContent:d,activeView:ie,features:N,focusPathRequest:E}):null),W=n?Re??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..."}):se?t.jsxs("div",{className:A,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})),se.workspacePathStatus==="missing"&&(O??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:se.workspace.absPath})]})),t.jsx("div",{className:ie==="chat"?"flex min-h-0 flex-1 flex-col":"hidden",children:t.jsx(Xx,{detail:se,adapter:l,timelineAdapter:_e,TimelineComponent:we,liveOutput:U,transcriptItemCount:ye,useFloatingMobileComposer:B,floatingMobileComposerBottomOffset:$,...M?{beforeTimelineContent:M}:{},...G?{composerProps:G}:{},...D?{timelineProps:D}:{},...L?{composerHostRef:L}:{}})}),t.jsxs("div",{className:ie==="shell"?"flex min-h-0 flex-1 flex-col":"hidden",children:[xe??(se.thread.isLoaded&&We&&l.shell?t.jsx(ke,{ref:S,threadId:se.thread.id,shellAdapter:l.shell,effectiveTheme:H,isVisible:ie==="shell",showHeader:!1,showFloatingToolbox:!1,...Y?{onStateChange:Y}:{}}):se.thread.isLoaded&&!We?de??t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center p-4 sm:p-6",children:t.jsxs("div",{className:"thread-empty-surface max-w-md rounded-[1.6rem] border px-6 py-8 text-center",children:[t.jsx("p",{className:"text-base font-medium text-[var(--theme-fg)]",children:"Terminal plugin disabled"}),t.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--theme-fg-muted)]",children:"Enable the Terminal plugin in Settings to use the shell panel."})]})}):te??t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center p-4 sm:p-6",children:t.jsxs("div",{className:"thread-empty-surface max-w-md rounded-[1.6rem] border px-6 py-8 text-center",children:[t.jsx("p",{className:"text-base font-medium text-[var(--theme-fg)]",children:"Thread disconnected"}),t.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--theme-fg-soft)]",children:"Reconnect this thread before creating or attaching a shell."})]})})),ie==="shell"&&T&&!xe?t.jsx(ta,{...T,activeView:"shell",onSubmit:l.sendPrompt}):null]}),X]}):me??t.jsx("div",{className:"flex flex-1 items-center justify-center px-6 py-12 text-center text-[var(--theme-fg-muted)]",children:"Select a thread to inspect."}),oe=t.jsx(Wp,{threads:e,status:s,loading:n,error:n?null:a,viewportConstrained:!0,currentThreadId:K??(se==null?void 0:se.thread.id),currentThreadLabel:se==null?void 0:se.thread.title,currentWorkspaceId:R??(se==null?void 0:se.thread.workspaceId),currentWorkspaceLabel:ee??(se==null?void 0:se.workspace.label),sessionLabel:(se==null?void 0:se.thread.providerSessionId)??(se==null?void 0:se.thread.id),usageLabel:fe,threadActionsButton:b,topbarActions:k,metaContent:i,settingsContent:d,globalSettingsContent:h,...m!==void 0?{settingsDialogOpen:m}:{},...u?{onSettingsDialogOpenChange:u}:{},mobileHeaderAction:p,effectiveTheme:H,themeMode:F,appMenuButton:f,appNavigationMenu:g,workspaceReturnHref:x,...j?{onWorkspaceReturn:j}:{},showMobileAppMenu:!!f,showMobileThreadNavToggle:!0,showMobileNewThreadShortcut:!1,onOpenThread:l.openThread,workspaceContent:I,workspaceTitle:y??"Workspace",workspaceActions:C,...E?{workspaceRevealRequestKey:E.requestId}:{},..._?{onNewThreadTitle:_}:{},...Q?{onCloseAppNavigation:Q}:{},...le?{onThemeModeChange:le}:{},...l.getThreadHref?{getThreadHref:l.getThreadHref}:{},...l.getNewThreadHref?{getNewThreadHref:l.getNewThreadHref}:{},...l.renderNewThreadDialogContent?{renderNewThreadDialogContent:l.renderNewThreadDialogContent}:{},...l.renameThread?{onRenameThread:l.renameThread}:{},...l.deleteThread?{onDeleteThread:l.deleteThread}:{},children:W});return o?t.jsx(ka.Provider,{value:Z,children:oe}):oe}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 w=e.fetchPlugins?await e.fetchPlugins():[];s(ra(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(C=>C.map(N=>N.id===y.id?y:N));return}s(y=>y.map(C=>C.id===w?{...C,enabled:v}:C))},[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(N=>N.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(C=>C.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(C=>C.renderArtifact&&C.manifest.capabilities.artifactTypes.some(N=>N.type===w.artifact.type));return((y=v==null?void 0:v.renderArtifact)==null?void 0:y.call(v,w))??null},[f]),x=c.useCallback(w=>{for(const v of f)for(const y of v.inlineCodeRenderers??[]){if(!y.languages.includes(w.language.trim().toLowerCase()))continue;const C=y.render(w);if(C)return C}return null},[f]),j=c.useCallback(w=>f.some(v=>!!v.renderArtifact&&v.manifest.capabilities.artifactTypes.some(y=>y.type===w.type)),[f]),b=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: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(`
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(`
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(`
3967
3973
  `)?e:`${e}
3968
- `],format:i,name:`${i.toUpperCase()} structure`,uuid:`inline:${i}:${e.length}`}),[e,i]);return r||!ob(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(Yl,{}),children:t.jsx(Kl,{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 kb=[{manifest:rb,threadPanels:[{id:"terminal",kind:"terminal",label:"Terminal"}]},{manifest:eb,renderArtifact:e=>t.jsx(db,{...e}),inlineCodeRenderers:[{languages:["xyz","extxyz","cif","pdb"],render:e=>t.jsx(cb,{...e})}]}];export{Ep as A,gb as C,Up as L,vb as P,xb as T,wa as a,bb as b,Dx as c,Wl as d,Wp as e,Vt as f,Op as g,kb as h,Lp as t,Sl as u};
3974
+ `],format:i,name:`${i.toUpperCase()} structure`,uuid:`inline:${i}:${e.length}`}),[e,i]);return r||!ob(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(Yl,{}),children:t.jsx(Kl,{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 kb=[{manifest:rb,threadPanels:[{id:"terminal",kind:"terminal",label:"Terminal"}]},{manifest:eb,renderArtifact:e=>t.jsx(db,{...e}),inlineCodeRenderers:[{languages:["xyz","extxyz","cif","pdb"],render:e=>t.jsx(cb,{...e})}]}];export{Ep as A,gb as C,Up as L,vb as P,xb as T,wa as a,bb as b,Dx as c,Wl as d,Wp as e,Xt as f,Op as g,kb as h,Lp as t,Sl as u};