lattice-orchestrator 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lattice-server.d.ts.map +1 -1
- package/dist/lattice-server.js +3 -1
- package/dist/lattice-server.js.map +1 -1
- package/dist/middleware/error-handler.d.ts.map +1 -1
- package/dist/middleware/error-handler.js +2 -1
- package/dist/middleware/error-handler.js.map +1 -1
- package/dist/web/assets/{CodeHighlight-6q7RiMjH.js → CodeHighlight-AX8pcR0a.js} +1 -1
- package/dist/web/assets/{CodeHighlight-D8HpdVaw.js → CodeHighlight-BFCEx5SO.js} +1 -1
- package/dist/web/assets/{main-DJfx3Zb2.js → main-2MNgdbR4.js} +55 -55
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/angular-html-CU67Zn6k.js","assets/html-GMplVEZG.js","assets/javascript-wDzz0qaB.js","assets/css-DPfMkruS.js","assets/angular-ts-BwZT4LLn.js","assets/scss-OYdSNvt2.js","assets/apl-dKokRX4l.js","assets/xml-sdJ4AIDG.js","assets/java-CylS5w8V.js","assets/json-Cp-IABpG.js","assets/astro-CbQHKStN.js","assets/typescript-BPQ3VLAy.js","assets/postcss-CXtECtnM.js","assets/tsx-COt5Ahok.js","assets/blade-D4QpJJKB.js","assets/html-derivative-BFtXZ54Q.js","assets/sql-BLtJtn59.js","assets/bsl-BO_Y6i37.js","assets/sdbl-DVxCFoDh.js","assets/cairo-KRGpt6FW.js","assets/python-B6aJPvgy.js","assets/cobol-nwyudZeR.js","assets/coffee-Ch7k5sss.js","assets/cpp-CofmeUqb.js","assets/regexp-CDVJQ6XC.js","assets/glsl-DplSGwfg.js","assets/c-BIGW1oBm.js","assets/crystal-tKQVLTB8.js","assets/shellscript-Yzrsuije.js","assets/edge-BkV0erSs.js","assets/elixir-CDX3lj18.js","assets/elm-DbKCFpqz.js","assets/erb-B12qg9BL.js","assets/ruby-Dw2BHqvy.js","assets/haml-B8DHNrY2.js","assets/graphql-ChdNCCLP.js","assets/jsx-g9-lgVsj.js","assets/lua-BaeVxFsk.js","assets/yaml-Buea-lGh.js","assets/erlang-DsQrWhSR.js","assets/markdown-Cvjx9yec.js","assets/fortran-fixed-form-CkoXwp7k.js","assets/fortran-free-form-BxgE0vQu.js","assets/fsharp-CXgrBDvD.js","assets/gdresource-BOOCDP_w.js","assets/gdshader-DkwncUOv.js","assets/gdscript-C5YyOfLZ.js","assets/git-commit-F4YmCXRG.js","assets/diff-D97Zzqfu.js","assets/git-rebase-r7XF79zn.js","assets/glimmer-js-Rg0-pVw9.js","assets/glimmer-ts-U6CK756n.js","assets/hack-CaT9iCJl.js","assets/handlebars-BL8al0AC.js","assets/http-jrhK8wxY.js","assets/hurl-irOxFIW8.js","assets/csv-fuZLfV_i.js","assets/hxml-Bvhsp5Yf.js","assets/haxe-CzTSHFRz.js","assets/jinja-4LBKfQ-Z.js","assets/jison-wvAkD_A8.js","assets/julia-CxzCAyBv.js","assets/r-Dspwwk_N.js","assets/just-Cw27pwNe.js","assets/perl-C0TMdlhV.js","assets/latex-CWtU0Tv5.js","assets/tex-idrVyKtj.js","assets/liquid-DYVedYrR.js","assets/marko-CnJfTvn9.js","assets/less-B1dDrJ26.js","assets/mdc-BMNejdWA.js","assets/nextflow-Zz6hmt5N.js","assets/nextflow-groovy-BeH2EWoN.js","assets/nginx-BpAMiNFr.js","assets/nim-CVrawwO9.js","assets/php-Dhbhpdrm.js","assets/pug-CGlum2m_.js","assets/qml-3beO22l8.js","assets/razor-Uh8Bk_45.js","assets/csharp-COcwbKMJ.js","assets/rst-BrH8l1NY.js","assets/cmake-D1j8_8rp.js","assets/sas-cz2c8ADy.js","assets/shaderlab-Dg9Lc6iA.js","assets/hlsl-D3lLCCz7.js","assets/shellsession-BADoaaVG.js","assets/soy-Brmx7dQM.js","assets/sparql-rVzFXLq3.js","assets/turtle-BsS91CYL.js","assets/stata-BH5u7GGu.js","assets/surrealql-Bq5Q-fJD.js","assets/svelte-C_ipcX3V.js","assets/templ-P3uqSqPl.js","assets/go-CxLEBnE3.js","assets/ts-tags-zn1MmPIZ.js","assets/twig-DNn4PbVi.js","assets/vue-DN_0RTcg.js","assets/vue-html-AaS7Mt5G.js","assets/vue-vine-CQOfvN7w.js","assets/stylus-BEDo0Tqx.js","assets/xsl-CtQFsRM5.js","assets/CodeHighlight-
|
|
2
|
-
import{j as s,r as u,b as Te,c as Am,u as Rm,o as Pm,s as Mm,f as Lm,d as Om,e as Dm,h as $m,i as zm,l as Fm,k as mn,m as Nt,n as xa,p as St,q as $l,t as zl,L as hn,Q as Vm,v as Bm,w as Fl,x as xt,N as Um,B as Gm,y as Hm}from"./vendor-react-xyVz3hOa.js";import{S as qm,R as Wm,C as Km,a as Qm,u as dt,P as st,c as He,d as Ym,b as Wn,e as ls,f as pr,g as Vl,h as Jm,i as ba,j as Ys,k as Xm}from"./vendor-radix-BmcW-0BY.js";import{t as Zm,M as rs,r as Cs,a as Eo}from"./vendor-markdown-vZ7invOV.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const a of o)if(a.type==="childList")for(const i of a.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(o){const a={};return o.integrity&&(a.integrity=o.integrity),o.referrerPolicy&&(a.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?a.credentials="include":o.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(o){if(o.ep)return;o.ep=!0;const a=n(o);fetch(o.href,a)}})();function jn({children:t}){return s.jsx("div",{className:"flex flex-col w-full h-full overflow-hidden bg-background relative",children:s.jsx("main",{className:"flex-1 flex flex-col overflow-hidden h-full min-h-0",children:t})})}const eh=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),th=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),gi=t=>{const e=th(t);return e.charAt(0).toUpperCase()+e.slice(1)},Bl=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),sh=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var nh={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const rh=u.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:a,iconNode:i,...l},c)=>u.createElement("svg",{ref:c,...nh,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:Bl("lucide",o),...!a&&!sh(l)&&{"aria-hidden":"true"},...l},[...i.map(([d,p])=>u.createElement(d,p)),...Array.isArray(a)?a:[a]]));const Y=(t,e)=>{const n=u.forwardRef(({className:r,...o},a)=>u.createElement(rh,{ref:a,iconNode:e,className:Bl(`lucide-${eh(gi(t))}`,`lucide-${t}`,r),...o}));return n.displayName=gi(t),n};const oh=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],tn=Y("archive",oh);const ah=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],ih=Y("arrow-down",ah);const ch=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Ul=Y("arrow-left",ch);const lh=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],dh=Y("arrow-right",lh);const uh=[["path",{d:"M4.5 3h15",key:"c7n0jr"}],["path",{d:"M6 3v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V3",key:"m1uhx7"}],["path",{d:"M6 14h12",key:"4cwo0f"}]],To=Y("beaker",uh);const ph=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]],xi=Y("bell-off",ph);const mh=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],Gr=Y("bell",mh);const hh=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],fh=Y("bot",hh);const gh=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],xh=Y("box",gh);const bh=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],yh=Y("brain",bh);const vh=[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]],Gl=Y("bug",vh);const wh=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Oe=Y("check",wh);const _h=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Lt=Y("chevron-down",_h);const kh=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ut=Y("chevron-right",kh);const jh=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Nh=Y("chevron-up",jh);const Sh=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Es=Y("circle-alert",Sh);const Ch=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]],Eh=Y("circle-arrow-up",Ch);const Th=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Bn=Y("circle-check",Th);const Ih=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],bi=Y("circle-x",Ih);const Ah=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Hr=Y("circle",Ah);const Rh=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]],Ph=Y("clipboard-check",Rh);const Mh=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Lh=Y("clock",Mh);const Oh=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],Io=Y("code",Oh);const Dh=[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],$h=Y("compass",Dh);const zh=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Vt=Y("copy",zh);const Fh=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]],Vh=Y("crosshair",Fh);const Bh=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],Ao=Y("download",Bh);const Uh=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],os=Y("external-link",Uh);const Gh=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],yi=Y("eye-off",Gh);const Hh=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Ro=Y("eye",Hh);const qh=[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]],Wh=Y("file-code",qh);const Kh=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Po=Y("file-text",Kh);const Qh=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],Hl=Y("flask-conical",Qh);const Yh=[["rect",{width:"8",height:"5",x:"14",y:"17",rx:"1",key:"19aais"}],["path",{d:"M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2.5",key:"1w6v7t"}],["path",{d:"M20 17v-2a2 2 0 1 0-4 0v2",key:"pwaxnr"}]],Jh=Y("folder-lock",Yh);const Xh=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Zh=Y("gauge",Xh);const ef=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],ya=Y("git-branch",ef);const tf=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]],sf=Y("git-commit-horizontal",tf);const nf=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],rf=Y("globe",nf);const of=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],af=Y("image",of);const cf=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m8 11 4 4 4-4",key:"1dohi6"}],["path",{d:"M8 5H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-4",key:"1ywtjm"}]],Kn=Y("import",cf);const lf=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],df=Y("info",lf);const uf=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],pf=Y("key-round",uf);const mf=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],ql=Y("layers",mf);const hf=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],vi=Y("layout-dashboard",hf);const ff=[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]],gf=Y("list-checks",ff);const xf=[["rect",{x:"3",y:"5",width:"6",height:"6",rx:"1",key:"1defrl"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]],Js=Y("list-todo",xf);const bf=[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]],yf=Y("list",bf);const vf=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ae=Y("loader-circle",vf);const wf=[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],_f=Y("locate-fixed",wf);const kf=[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]],wi=Y("log-in",kf);const jf=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],_i=Y("log-out",jf);const Nf=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],Sf=Y("maximize-2",Nf);const Cf=[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]],Ef=Y("menu",Cf);const Tf=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],If=Y("message-circle",Tf);const Af=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],as=Y("message-square",Af);const Rf=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],Pf=Y("minimize-2",Rf);const Mf=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],Lf=Y("monitor",Mf);const Of=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],Df=Y("network",Of);const $f=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],zf=Y("panel-left-close",$f);const Ff=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],Wl=Y("panel-left",Ff);const Vf=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],qr=Y("panel-right-close",Vf);const Bf=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],Wr=Y("panel-right-open",Bf);const Uf=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],ki=Y("pause",Uf);const Gf=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],Hf=Y("pencil-line",Gf);const qf=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],va=Y("pencil",qf);const Wf=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],Gt=Y("play",Wf);const Kf=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Kl=Y("plus",Kf);const Qf=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],ds=Y("refresh-cw",Qf);const Yf=[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]],Jf=Y("rocket",Yf);const Xf=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],wa=Y("rotate-ccw",Xf);const Zf=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Ql=Y("search",Zf);const e0=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],ji=Y("send",e0);const t0=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Mo=Y("settings",t0);const s0=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],Yl=Y("shield-alert",s0);const n0=[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]],mr=Y("shield-off",n0);const r0=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Ms=Y("shield",r0);const o0=[["path",{d:"m12.5 17-.5-1-.5 1h1z",key:"3me087"}],["path",{d:"M15 22a1 1 0 0 0 1-1v-1a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20v1a1 1 0 0 0 1 1z",key:"1o5pge"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}]],a0=Y("skull",o0);const i0=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],_a=Y("sparkles",i0);const c0=[["path",{d:"M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8Z",key:"qazsjp"}],["path",{d:"M15 3v4a2 2 0 0 0 2 2h4",key:"40519r"}]],l0=Y("sticky-note",c0);const d0=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],u0=Y("terminal",d0);const p0=[["path",{d:"M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5c-1.4 0-2.5-1.1-2.5-2.5V2",key:"125lnx"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14.5 16h-5",key:"1ox875"}]],m0=Y("test-tube",p0);const h0=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Lo=Y("trash-2",h0);const f0=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],kt=Y("triangle-alert",f0);const g0=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Jl=Y("user",g0);const x0=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],b0=Y("users",x0);const y0=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],ka=Y("wrench",y0);const v0=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Be=Y("x",v0);const w0=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],ja=Y("zap",w0);function Xl(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var o=t.length;for(e=0;e<o;e++)t[e]&&(n=Xl(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function Na(){for(var t,e,n=0,r="",o=arguments.length;n<o;n++)(t=arguments[n])&&(e=Xl(t))&&(r&&(r+=" "),r+=e);return r}const Ni=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,Si=Na,_0=(t,e)=>n=>{var r;if(e?.variants==null)return Si(t,n?.class,n?.className);const{variants:o,defaultVariants:a}=e,i=Object.keys(o).map(d=>{const p=n?.[d],m=a?.[d];if(p===null)return null;const h=Ni(p)||Ni(m);return o[d][h]}),l=n&&Object.entries(n).reduce((d,p)=>{let[m,h]=p;return h===void 0||(d[m]=h),d},{}),c=e==null||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((d,p)=>{let{class:m,className:h,...g}=p;return Object.entries(g).every(f=>{let[x,b]=f;return Array.isArray(b)?b.includes({...a,...l}[x]):{...a,...l}[x]===b})?[...d,m,h]:d},[]);return Si(t,i,c,n?.class,n?.className)},k0=(t,e)=>{const n=new Array(t.length+e.length);for(let r=0;r<t.length;r++)n[r]=t[r];for(let r=0;r<e.length;r++)n[t.length+r]=e[r];return n},j0=(t,e)=>({classGroupId:t,validator:e}),Zl=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),Qn="-",Ci=[],N0="arbitrary..",S0=t=>{const e=E0(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return C0(i);const l=i.split(Qn),c=l[0]===""&&l.length>1?1:0;return ed(l,c,e)},getConflictingClassGroupIds:(i,l)=>{if(l){const c=r[i],d=n[i];return c?d?k0(d,c):c:d||Ci}return n[i]||Ci}}},ed=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const o=t[e],a=n.nextPart.get(o);if(a){const d=ed(t,e+1,a);if(d)return d}const i=n.validators;if(i===null)return;const l=e===0?t.join(Qn):t.slice(e).join(Qn),c=i.length;for(let d=0;d<c;d++){const p=i[d];if(p.validator(l))return p.classGroupId}},C0=t=>t.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),n=e.indexOf(":"),r=e.slice(0,n);return r?N0+r:void 0})(),E0=t=>{const{theme:e,classGroups:n}=t;return T0(n,e)},T0=(t,e)=>{const n=Zl();for(const r in t){const o=t[r];Sa(o,n,r,e)}return n},Sa=(t,e,n,r)=>{const o=t.length;for(let a=0;a<o;a++){const i=t[a];I0(i,e,n,r)}},I0=(t,e,n,r)=>{if(typeof t=="string"){A0(t,e,n);return}if(typeof t=="function"){R0(t,e,n,r);return}P0(t,e,n,r)},A0=(t,e,n)=>{const r=t===""?e:td(e,t);r.classGroupId=n},R0=(t,e,n,r)=>{if(M0(t)){Sa(t(r),e,n,r);return}e.validators===null&&(e.validators=[]),e.validators.push(j0(n,t))},P0=(t,e,n,r)=>{const o=Object.entries(t),a=o.length;for(let i=0;i<a;i++){const[l,c]=o[i];Sa(c,td(e,l),n,r)}},td=(t,e)=>{let n=t;const r=e.split(Qn),o=r.length;for(let a=0;a<o;a++){const i=r[a];let l=n.nextPart.get(i);l||(l=Zl(),n.nextPart.set(i,l)),n=l}return n},M0=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,L0=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=Object.create(null),r=Object.create(null);const o=(a,i)=>{n[a]=i,e++,e>t&&(e=0,r=n,n=Object.create(null))};return{get(a){let i=n[a];if(i!==void 0)return i;if((i=r[a])!==void 0)return o(a,i),i},set(a,i){a in n?n[a]=i:o(a,i)}}},Oo="!",Ei=":",O0=[],Ti=(t,e,n,r,o)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:r,isExternal:o}),D0=t=>{const{prefix:e,experimentalParseClassName:n}=t;let r=o=>{const a=[];let i=0,l=0,c=0,d;const p=o.length;for(let x=0;x<p;x++){const b=o[x];if(i===0&&l===0){if(b===Ei){a.push(o.slice(c,x)),c=x+1;continue}if(b==="/"){d=x;continue}}b==="["?i++:b==="]"?i--:b==="("?l++:b===")"&&l--}const m=a.length===0?o:o.slice(c);let h=m,g=!1;m.endsWith(Oo)?(h=m.slice(0,-1),g=!0):m.startsWith(Oo)&&(h=m.slice(1),g=!0);const f=d&&d>c?d-c:void 0;return Ti(a,g,h,f)};if(e){const o=e+Ei,a=r;r=i=>i.startsWith(o)?a(i.slice(o.length)):Ti(O0,!1,i,void 0,!0)}if(n){const o=r;r=a=>n({className:a,parseClassName:o})}return r},$0=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((n,r)=>{e.set(n,1e6+r)}),n=>{const r=[];let o=[];for(let a=0;a<n.length;a++){const i=n[a],l=i[0]==="[",c=e.has(i);l||c?(o.length>0&&(o.sort(),r.push(...o),o=[]),r.push(i)):o.push(i)}return o.length>0&&(o.sort(),r.push(...o)),r}},z0=t=>({cache:L0(t.cacheSize),parseClassName:D0(t),sortModifiers:$0(t),...S0(t)}),F0=/\s+/,V0=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:a}=e,i=[],l=t.trim().split(F0);let c="";for(let d=l.length-1;d>=0;d-=1){const p=l[d],{isExternal:m,modifiers:h,hasImportantModifier:g,baseClassName:f,maybePostfixModifierPosition:x}=n(p);if(m){c=p+(c.length>0?" "+c:c);continue}let b=!!x,y=r(b?f.substring(0,x):f);if(!y){if(!b){c=p+(c.length>0?" "+c:c);continue}if(y=r(f),!y){c=p+(c.length>0?" "+c:c);continue}b=!1}const v=h.length===0?"":h.length===1?h[0]:a(h).join(":"),w=g?v+Oo:v,N=w+y;if(i.indexOf(N)>-1)continue;i.push(N);const S=o(y,b);for(let T=0;T<S.length;++T){const C=S[T];i.push(w+C)}c=p+(c.length>0?" "+c:c)}return c},B0=(...t)=>{let e=0,n,r,o="";for(;e<t.length;)(n=t[e++])&&(r=sd(n))&&(o&&(o+=" "),o+=r);return o},sd=t=>{if(typeof t=="string")return t;let e,n="";for(let r=0;r<t.length;r++)t[r]&&(e=sd(t[r]))&&(n&&(n+=" "),n+=e);return n},U0=(t,...e)=>{let n,r,o,a;const i=c=>{const d=e.reduce((p,m)=>m(p),t());return n=z0(d),r=n.cache.get,o=n.cache.set,a=l,l(c)},l=c=>{const d=r(c);if(d)return d;const p=V0(c,n);return o(c,p),p};return a=i,(...c)=>a(B0(...c))},G0=[],Ue=t=>{const e=n=>n[t]||G0;return e.isThemeGetter=!0,e},nd=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,rd=/^\((?:(\w[\w-]*):)?(.+)\)$/i,H0=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,q0=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,W0=/\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$/,K0=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Q0=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Y0=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Dt=t=>H0.test(t),we=t=>!!t&&!Number.isNaN(Number(t)),$t=t=>!!t&&Number.isInteger(Number(t)),Kr=t=>t.endsWith("%")&&we(t.slice(0,-1)),It=t=>q0.test(t),od=()=>!0,J0=t=>W0.test(t)&&!K0.test(t),Ca=()=>!1,X0=t=>Q0.test(t),Z0=t=>Y0.test(t),eg=t=>!ce(t)&&!ue(t),tg=t=>Ht(t,cd,Ca),ce=t=>nd.test(t),Xt=t=>Ht(t,ld,J0),Ii=t=>Ht(t,lg,we),sg=t=>Ht(t,ud,od),ng=t=>Ht(t,dd,Ca),Ai=t=>Ht(t,ad,Ca),rg=t=>Ht(t,id,Z0),Nn=t=>Ht(t,pd,X0),ue=t=>rd.test(t),Us=t=>us(t,ld),og=t=>us(t,dd),Ri=t=>us(t,ad),ag=t=>us(t,cd),ig=t=>us(t,id),Sn=t=>us(t,pd,!0),cg=t=>us(t,ud,!0),Ht=(t,e,n)=>{const r=nd.exec(t);return r?r[1]?e(r[1]):n(r[2]):!1},us=(t,e,n=!1)=>{const r=rd.exec(t);return r?r[1]?e(r[1]):n:!1},ad=t=>t==="position"||t==="percentage",id=t=>t==="image"||t==="url",cd=t=>t==="length"||t==="size"||t==="bg-size",ld=t=>t==="length",lg=t=>t==="number",dd=t=>t==="family-name",ud=t=>t==="number"||t==="weight",pd=t=>t==="shadow",dg=()=>{const t=Ue("color"),e=Ue("font"),n=Ue("text"),r=Ue("font-weight"),o=Ue("tracking"),a=Ue("leading"),i=Ue("breakpoint"),l=Ue("container"),c=Ue("spacing"),d=Ue("radius"),p=Ue("shadow"),m=Ue("inset-shadow"),h=Ue("text-shadow"),g=Ue("drop-shadow"),f=Ue("blur"),x=Ue("perspective"),b=Ue("aspect"),y=Ue("ease"),v=Ue("animate"),w=()=>["auto","avoid","all","avoid-page","page","left","right","column"],N=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],S=()=>[...N(),ue,ce],T=()=>["auto","hidden","clip","visible","scroll"],C=()=>["auto","contain","none"],j=()=>[ue,ce,c],E=()=>[Dt,"full","auto",...j()],R=()=>[$t,"none","subgrid",ue,ce],O=()=>["auto",{span:["full",$t,ue,ce]},$t,ue,ce],$=()=>[$t,"auto",ue,ce],re=()=>["auto","min","max","fr",ue,ce],ne=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],V=()=>["start","end","center","stretch","center-safe","end-safe"],X=()=>["auto",...j()],q=()=>[Dt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...j()],K=()=>[Dt,"screen","full","dvw","lvw","svw","min","max","fit",...j()],ge=()=>[Dt,"screen","full","lh","dvh","lvh","svh","min","max","fit",...j()],D=()=>[t,ue,ce],W=()=>[...N(),Ri,Ai,{position:[ue,ce]}],Z=()=>["no-repeat",{repeat:["","x","y","space","round"]}],F=()=>["auto","cover","contain",ag,tg,{size:[ue,ce]}],se=()=>[Kr,Us,Xt],ee=()=>["","none","full",d,ue,ce],te=()=>["",we,Us,Xt],xe=()=>["solid","dashed","dotted","double"],_e=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],A=()=>[we,Kr,Ri,Ai],P=()=>["","none",f,ue,ce],le=()=>["none",we,ue,ce],J=()=>["none",we,ue,ce],H=()=>[we,ue,ce],ye=()=>[Dt,"full",...j()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[It],breakpoint:[It],color:[od],container:[It],"drop-shadow":[It],ease:["in","out","in-out"],font:[eg],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[It],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[It],shadow:[It],spacing:["px",we],text:[It],"text-shadow":[It],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Dt,ce,ue,b]}],container:["container"],columns:[{columns:[we,ce,ue,l]}],"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:S()}],overflow:[{overflow:T()}],"overflow-x":[{"overflow-x":T()}],"overflow-y":[{"overflow-y":T()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:E()}],"inset-x":[{"inset-x":E()}],"inset-y":[{"inset-y":E()}],start:[{"inset-s":E(),start:E()}],end:[{"inset-e":E(),end:E()}],"inset-bs":[{"inset-bs":E()}],"inset-be":[{"inset-be":E()}],top:[{top:E()}],right:[{right:E()}],bottom:[{bottom:E()}],left:[{left:E()}],visibility:["visible","invisible","collapse"],z:[{z:[$t,"auto",ue,ce]}],basis:[{basis:[Dt,"full","auto",l,...j()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[we,Dt,"auto","initial","none",ce]}],grow:[{grow:["",we,ue,ce]}],shrink:[{shrink:["",we,ue,ce]}],order:[{order:[$t,"first","last","none",ue,ce]}],"grid-cols":[{"grid-cols":R()}],"col-start-end":[{col:O()}],"col-start":[{"col-start":$()}],"col-end":[{"col-end":$()}],"grid-rows":[{"grid-rows":R()}],"row-start-end":[{row:O()}],"row-start":[{"row-start":$()}],"row-end":[{"row-end":$()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":re()}],"auto-rows":[{"auto-rows":re()}],gap:[{gap:j()}],"gap-x":[{"gap-x":j()}],"gap-y":[{"gap-y":j()}],"justify-content":[{justify:[...ne(),"normal"]}],"justify-items":[{"justify-items":[...V(),"normal"]}],"justify-self":[{"justify-self":["auto",...V()]}],"align-content":[{content:["normal",...ne()]}],"align-items":[{items:[...V(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...V(),{baseline:["","last"]}]}],"place-content":[{"place-content":ne()}],"place-items":[{"place-items":[...V(),"baseline"]}],"place-self":[{"place-self":["auto",...V()]}],p:[{p:j()}],px:[{px:j()}],py:[{py:j()}],ps:[{ps:j()}],pe:[{pe:j()}],pbs:[{pbs:j()}],pbe:[{pbe:j()}],pt:[{pt:j()}],pr:[{pr:j()}],pb:[{pb:j()}],pl:[{pl:j()}],m:[{m:X()}],mx:[{mx:X()}],my:[{my:X()}],ms:[{ms:X()}],me:[{me:X()}],mbs:[{mbs:X()}],mbe:[{mbe:X()}],mt:[{mt:X()}],mr:[{mr:X()}],mb:[{mb:X()}],ml:[{ml:X()}],"space-x":[{"space-x":j()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":j()}],"space-y-reverse":["space-y-reverse"],size:[{size:q()}],"inline-size":[{inline:["auto",...K()]}],"min-inline-size":[{"min-inline":["auto",...K()]}],"max-inline-size":[{"max-inline":["none",...K()]}],"block-size":[{block:["auto",...ge()]}],"min-block-size":[{"min-block":["auto",...ge()]}],"max-block-size":[{"max-block":["none",...ge()]}],w:[{w:[l,"screen",...q()]}],"min-w":[{"min-w":[l,"screen","none",...q()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[i]},...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,Us,Xt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,cg,sg]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Kr,ce]}],"font-family":[{font:[og,ng,e]}],"font-features":[{"font-features":[ce]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,ue,ce]}],"line-clamp":[{"line-clamp":[we,"none",ue,Ii]}],leading:[{leading:[a,...j()]}],"list-image":[{"list-image":["none",ue,ce]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ue,ce]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:D()}],"text-color":[{text:D()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...xe(),"wavy"]}],"text-decoration-thickness":[{decoration:[we,"from-font","auto",ue,Xt]}],"text-decoration-color":[{decoration:D()}],"underline-offset":[{"underline-offset":[we,"auto",ue,ce]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:j()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ue,ce]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ue,ce]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:W()}],"bg-repeat":[{bg:Z()}],"bg-size":[{bg:F()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},$t,ue,ce],radial:["",ue,ce],conic:[$t,ue,ce]},ig,rg]}],"bg-color":[{bg:D()}],"gradient-from-pos":[{from:se()}],"gradient-via-pos":[{via:se()}],"gradient-to-pos":[{to:se()}],"gradient-from":[{from:D()}],"gradient-via":[{via:D()}],"gradient-to":[{to:D()}],rounded:[{rounded:ee()}],"rounded-s":[{"rounded-s":ee()}],"rounded-e":[{"rounded-e":ee()}],"rounded-t":[{"rounded-t":ee()}],"rounded-r":[{"rounded-r":ee()}],"rounded-b":[{"rounded-b":ee()}],"rounded-l":[{"rounded-l":ee()}],"rounded-ss":[{"rounded-ss":ee()}],"rounded-se":[{"rounded-se":ee()}],"rounded-ee":[{"rounded-ee":ee()}],"rounded-es":[{"rounded-es":ee()}],"rounded-tl":[{"rounded-tl":ee()}],"rounded-tr":[{"rounded-tr":ee()}],"rounded-br":[{"rounded-br":ee()}],"rounded-bl":[{"rounded-bl":ee()}],"border-w":[{border:te()}],"border-w-x":[{"border-x":te()}],"border-w-y":[{"border-y":te()}],"border-w-s":[{"border-s":te()}],"border-w-e":[{"border-e":te()}],"border-w-bs":[{"border-bs":te()}],"border-w-be":[{"border-be":te()}],"border-w-t":[{"border-t":te()}],"border-w-r":[{"border-r":te()}],"border-w-b":[{"border-b":te()}],"border-w-l":[{"border-l":te()}],"divide-x":[{"divide-x":te()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":te()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...xe(),"hidden","none"]}],"divide-style":[{divide:[...xe(),"hidden","none"]}],"border-color":[{border:D()}],"border-color-x":[{"border-x":D()}],"border-color-y":[{"border-y":D()}],"border-color-s":[{"border-s":D()}],"border-color-e":[{"border-e":D()}],"border-color-bs":[{"border-bs":D()}],"border-color-be":[{"border-be":D()}],"border-color-t":[{"border-t":D()}],"border-color-r":[{"border-r":D()}],"border-color-b":[{"border-b":D()}],"border-color-l":[{"border-l":D()}],"divide-color":[{divide:D()}],"outline-style":[{outline:[...xe(),"none","hidden"]}],"outline-offset":[{"outline-offset":[we,ue,ce]}],"outline-w":[{outline:["",we,Us,Xt]}],"outline-color":[{outline:D()}],shadow:[{shadow:["","none",p,Sn,Nn]}],"shadow-color":[{shadow:D()}],"inset-shadow":[{"inset-shadow":["none",m,Sn,Nn]}],"inset-shadow-color":[{"inset-shadow":D()}],"ring-w":[{ring:te()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:D()}],"ring-offset-w":[{"ring-offset":[we,Xt]}],"ring-offset-color":[{"ring-offset":D()}],"inset-ring-w":[{"inset-ring":te()}],"inset-ring-color":[{"inset-ring":D()}],"text-shadow":[{"text-shadow":["none",h,Sn,Nn]}],"text-shadow-color":[{"text-shadow":D()}],opacity:[{opacity:[we,ue,ce]}],"mix-blend":[{"mix-blend":[..._e(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":_e()}],"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":[we]}],"mask-image-linear-from-pos":[{"mask-linear-from":A()}],"mask-image-linear-to-pos":[{"mask-linear-to":A()}],"mask-image-linear-from-color":[{"mask-linear-from":D()}],"mask-image-linear-to-color":[{"mask-linear-to":D()}],"mask-image-t-from-pos":[{"mask-t-from":A()}],"mask-image-t-to-pos":[{"mask-t-to":A()}],"mask-image-t-from-color":[{"mask-t-from":D()}],"mask-image-t-to-color":[{"mask-t-to":D()}],"mask-image-r-from-pos":[{"mask-r-from":A()}],"mask-image-r-to-pos":[{"mask-r-to":A()}],"mask-image-r-from-color":[{"mask-r-from":D()}],"mask-image-r-to-color":[{"mask-r-to":D()}],"mask-image-b-from-pos":[{"mask-b-from":A()}],"mask-image-b-to-pos":[{"mask-b-to":A()}],"mask-image-b-from-color":[{"mask-b-from":D()}],"mask-image-b-to-color":[{"mask-b-to":D()}],"mask-image-l-from-pos":[{"mask-l-from":A()}],"mask-image-l-to-pos":[{"mask-l-to":A()}],"mask-image-l-from-color":[{"mask-l-from":D()}],"mask-image-l-to-color":[{"mask-l-to":D()}],"mask-image-x-from-pos":[{"mask-x-from":A()}],"mask-image-x-to-pos":[{"mask-x-to":A()}],"mask-image-x-from-color":[{"mask-x-from":D()}],"mask-image-x-to-color":[{"mask-x-to":D()}],"mask-image-y-from-pos":[{"mask-y-from":A()}],"mask-image-y-to-pos":[{"mask-y-to":A()}],"mask-image-y-from-color":[{"mask-y-from":D()}],"mask-image-y-to-color":[{"mask-y-to":D()}],"mask-image-radial":[{"mask-radial":[ue,ce]}],"mask-image-radial-from-pos":[{"mask-radial-from":A()}],"mask-image-radial-to-pos":[{"mask-radial-to":A()}],"mask-image-radial-from-color":[{"mask-radial-from":D()}],"mask-image-radial-to-color":[{"mask-radial-to":D()}],"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":N()}],"mask-image-conic-pos":[{"mask-conic":[we]}],"mask-image-conic-from-pos":[{"mask-conic-from":A()}],"mask-image-conic-to-pos":[{"mask-conic-to":A()}],"mask-image-conic-from-color":[{"mask-conic-from":D()}],"mask-image-conic-to-color":[{"mask-conic-to":D()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:W()}],"mask-repeat":[{mask:Z()}],"mask-size":[{mask:F()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ue,ce]}],filter:[{filter:["","none",ue,ce]}],blur:[{blur:P()}],brightness:[{brightness:[we,ue,ce]}],contrast:[{contrast:[we,ue,ce]}],"drop-shadow":[{"drop-shadow":["","none",g,Sn,Nn]}],"drop-shadow-color":[{"drop-shadow":D()}],grayscale:[{grayscale:["",we,ue,ce]}],"hue-rotate":[{"hue-rotate":[we,ue,ce]}],invert:[{invert:["",we,ue,ce]}],saturate:[{saturate:[we,ue,ce]}],sepia:[{sepia:["",we,ue,ce]}],"backdrop-filter":[{"backdrop-filter":["","none",ue,ce]}],"backdrop-blur":[{"backdrop-blur":P()}],"backdrop-brightness":[{"backdrop-brightness":[we,ue,ce]}],"backdrop-contrast":[{"backdrop-contrast":[we,ue,ce]}],"backdrop-grayscale":[{"backdrop-grayscale":["",we,ue,ce]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[we,ue,ce]}],"backdrop-invert":[{"backdrop-invert":["",we,ue,ce]}],"backdrop-opacity":[{"backdrop-opacity":[we,ue,ce]}],"backdrop-saturate":[{"backdrop-saturate":[we,ue,ce]}],"backdrop-sepia":[{"backdrop-sepia":["",we,ue,ce]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":j()}],"border-spacing-x":[{"border-spacing-x":j()}],"border-spacing-y":[{"border-spacing-y":j()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ue,ce]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[we,"initial",ue,ce]}],ease:[{ease:["linear","initial",y,ue,ce]}],delay:[{delay:[we,ue,ce]}],animate:[{animate:["none",v,ue,ce]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[x,ue,ce]}],"perspective-origin":[{"perspective-origin":S()}],rotate:[{rotate:le()}],"rotate-x":[{"rotate-x":le()}],"rotate-y":[{"rotate-y":le()}],"rotate-z":[{"rotate-z":le()}],scale:[{scale:J()}],"scale-x":[{"scale-x":J()}],"scale-y":[{"scale-y":J()}],"scale-z":[{"scale-z":J()}],"scale-3d":["scale-3d"],skew:[{skew:H()}],"skew-x":[{"skew-x":H()}],"skew-y":[{"skew-y":H()}],transform:[{transform:[ue,ce,"","none","gpu","cpu"]}],"transform-origin":[{origin:S()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ye()}],"translate-x":[{"translate-x":ye()}],"translate-y":[{"translate-y":ye()}],"translate-z":[{"translate-z":ye()}],"translate-none":["translate-none"],accent:[{accent:D()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:D()}],"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",ue,ce]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":j()}],"scroll-mx":[{"scroll-mx":j()}],"scroll-my":[{"scroll-my":j()}],"scroll-ms":[{"scroll-ms":j()}],"scroll-me":[{"scroll-me":j()}],"scroll-mbs":[{"scroll-mbs":j()}],"scroll-mbe":[{"scroll-mbe":j()}],"scroll-mt":[{"scroll-mt":j()}],"scroll-mr":[{"scroll-mr":j()}],"scroll-mb":[{"scroll-mb":j()}],"scroll-ml":[{"scroll-ml":j()}],"scroll-p":[{"scroll-p":j()}],"scroll-px":[{"scroll-px":j()}],"scroll-py":[{"scroll-py":j()}],"scroll-ps":[{"scroll-ps":j()}],"scroll-pe":[{"scroll-pe":j()}],"scroll-pbs":[{"scroll-pbs":j()}],"scroll-pbe":[{"scroll-pbe":j()}],"scroll-pt":[{"scroll-pt":j()}],"scroll-pr":[{"scroll-pr":j()}],"scroll-pb":[{"scroll-pb":j()}],"scroll-pl":[{"scroll-pl":j()}],"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",ue,ce]}],fill:[{fill:["none",...D()]}],"stroke-w":[{stroke:[we,Us,Xt,Ii]}],stroke:[{stroke:["none",...D()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{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"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},md=U0(dg);function $e(...t){return md(Na(t))}const ug=_0("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 cursor-pointer",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),hd=u.forwardRef(({className:t,variant:e,size:n,asChild:r=!1,...o},a)=>{const i=r?qm:"button";return s.jsx(i,{className:$e(ug({variant:e,size:n,className:t})),ref:a,...o})});hd.displayName="Button";function Pi({data:t,collapsed:e=!1,depth:n=0}){const[r,o]=u.useState(!1),a=e||r,[i,l]=u.useState(!1),c=async()=>{try{await navigator.clipboard.writeText(JSON.stringify(t,null,2)),l(!0),setTimeout(()=>l(!1),2e3)}catch(p){console.error("Failed to copy:",p)}},d=(p,m)=>{if(p===null)return s.jsx("span",{className:"text-neutral-500 dark:text-neutral-400",children:"null"});if(p===void 0)return s.jsx("span",{className:"text-neutral-500 dark:text-neutral-400",children:"undefined"});if(typeof p=="boolean")return s.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:p.toString()});if(typeof p=="number")return s.jsx("span",{className:"text-green-600 dark:text-green-400",children:p});if(typeof p=="string")return s.jsxs("span",{className:"text-emerald-700 dark:text-orange-300",children:['"',p,'"']});if(Array.isArray(p))return p.length===0?s.jsx("span",{className:"text-foreground",children:"[]"}):s.jsxs("span",{className:"inline-block",children:[s.jsx("button",{className:"inline-flex items-center justify-center w-4 h-4 mr-0.5 text-neutral-500 hover:text-black dark:text-neutral-400 dark:hover:text-white transition-colors",onClick:()=>o(h=>!h),"aria-label":a?"Expand array":"Collapse array",children:a?s.jsx(Ut,{size:12}):s.jsx(Lt,{size:12})}),s.jsx("span",{className:"text-foreground",children:"["}),a?s.jsxs("span",{className:"text-neutral-500 dark:text-neutral-400 italic mx-1",children:["...",p.length," items"]}):s.jsx("div",{className:"ml-[18px]",children:Object.entries(p).map(([h,g])=>s.jsxs("div",{className:"my-0.5",children:[s.jsxs("span",{className:"text-muted-foreground mr-1",children:[h,":"]}),d(g),Number(h)<p.length-1&&s.jsx("span",{className:"text-foreground",children:","})]},`json-array-item-${h}`))}),s.jsx("span",{className:"text-foreground",children:"]"})]});if(typeof p=="object"){const h=Object.entries(p);return h.length===0?s.jsx("span",{className:"text-foreground",children:"{}"}):s.jsxs("span",{className:"inline-block",children:[s.jsx("button",{className:"inline-flex items-center justify-center w-4 h-4 mr-0.5 text-neutral-500 hover:text-black dark:text-neutral-400 dark:hover:text-white transition-colors",onClick:()=>o(g=>!g),"aria-label":a?"Expand object":"Collapse object",children:a?s.jsx(Ut,{size:12}):s.jsx(Lt,{size:12})}),s.jsx("span",{className:"text-foreground",children:"{"}),a?s.jsxs("span",{className:"text-neutral-500 dark:text-neutral-400 italic mx-1",children:["...",h.length," properties"]}):s.jsx("div",{className:"ml-[18px]",children:h.map(([g,f],x)=>s.jsxs("div",{className:"my-0.5",children:[s.jsxs("span",{className:"text-blue-700 dark:text-blue-300",children:['"',g,'"']}),s.jsx("span",{className:"text-foreground mx-1",children:":"}),d(f),x<h.length-1&&s.jsx("span",{className:"text-foreground",children:","})]},g))}),s.jsx("span",{className:"text-black dark:text-neutral-300",children:"}"})]})}return s.jsx("span",{className:"text-neutral-500 dark:text-neutral-400",children:String(p)})};return s.jsxs("div",{className:"relative font-mono text-xs leading-relaxed p-2 bg-neutral-50 dark:bg-neutral-900 rounded overflow-auto",children:[n===0&&s.jsx(hd,{variant:"ghost",size:"icon",className:"absolute top-1 right-1 h-6 w-6 bg-neutral-100 hover:bg-neutral-200 dark:bg-neutral-800 dark:hover:bg-neutral-700",onClick:c,"aria-label":"Copy JSON to clipboard",children:i?s.jsx(Oe,{size:14}):s.jsx(Vt,{size:14})}),d(t)]})}const Ea=u.createContext({theme:"dark"});function pg({children:t,...e}){return s.jsx(Ea.Provider,{value:e,children:t})}function hr(){return u.useContext(Ea).theme}function fd(t){const{resolveAgentColor:e}=u.useContext(Ea);if(!(!t||!e))return e(t)}const k={card:{bg:"bg-white dark:bg-zinc-900/30",border:"border-parchment-300 dark:border-zinc-800/40"},codeBg:"bg-parchment-100 dark:bg-zinc-950",codeBgSubtle:"bg-parchment-50 dark:bg-zinc-900/50",text:{primary:"text-parchment-800 dark:text-zinc-300",secondary:"text-parchment-600 dark:text-zinc-400",muted:"text-parchment-500 dark:text-zinc-500",faint:"text-parchment-400 dark:text-zinc-600"},separator:"border-parchment-200 dark:border-zinc-800/40",hover:"hover:bg-parchment-100 dark:hover:bg-zinc-800/40",scrollbar:"scrollbar-thin scrollbar-track-transparent scrollbar-thumb-parchment-300 dark:scrollbar-thumb-zinc-700"},ie={blue:{card:"border-blue-600/30 bg-blue-500/10 dark:border-blue-500/20 dark:bg-blue-500/5",icon:"text-blue-600 dark:text-blue-400/80"},emerald:{card:"border-emerald-600/30 bg-emerald-500/10 dark:border-emerald-500/20 dark:bg-emerald-500/5",icon:"text-emerald-600 dark:text-emerald-400/80"},violet:{card:"border-violet-600/30 bg-violet-500/10 dark:border-violet-500/20 dark:bg-violet-500/5",icon:"text-violet-600 dark:text-violet-400/80"},orange:{card:"border-orange-600/30 bg-orange-500/10 dark:border-orange-500/20 dark:bg-orange-500/5",icon:"text-orange-600 dark:text-orange-400/80"},amber:{card:"border-amber-600/30 bg-amber-500/10 dark:border-amber-500/20 dark:bg-amber-500/5",icon:"text-amber-600 dark:text-amber-400/80"},purple:{card:"border-purple-600/30 bg-purple-500/10 dark:border-purple-500/20 dark:bg-purple-500/5",icon:"text-purple-600 dark:text-purple-400/80"},cyan:{card:"border-cyan-600/30 bg-cyan-500/10 dark:border-cyan-500/20 dark:bg-cyan-500/5",icon:"text-cyan-600 dark:text-cyan-400/80"},indigo:{card:"border-indigo-600/30 bg-indigo-500/10 dark:border-indigo-500/20 dark:bg-indigo-500/5",icon:"text-indigo-600 dark:text-indigo-400/80"},rose:{card:"border-rose-600/30 bg-rose-500/10 dark:border-rose-500/20 dark:bg-rose-500/5",icon:"text-rose-600 dark:text-rose-400/80"},zinc:{card:"border-parchment-400/40 bg-parchment-500/8 dark:border-zinc-500/25 dark:bg-zinc-500/5",icon:"text-parchment-500 dark:text-zinc-400/80"}},_t={blue:{border:"border-blue-600/30 dark:border-blue-500/20",bg:"bg-blue-500/10 dark:bg-blue-500/5",icon:"text-blue-600 dark:text-blue-400/80"},green:{border:"border-green-600/30 dark:border-green-500/20",bg:"bg-green-500/10 dark:bg-green-500/5",icon:"text-green-600 dark:text-green-400/80"},yellow:{border:"border-amber-600/30 dark:border-amber-500/20",bg:"bg-amber-500/10 dark:bg-amber-500/5",icon:"text-amber-600 dark:text-amber-400/80"},purple:{border:"border-purple-600/30 dark:border-purple-500/20",bg:"bg-purple-500/10 dark:bg-purple-500/5",icon:"text-purple-600 dark:text-purple-400/80"},red:{border:"border-red-600/30 dark:border-red-500/20",bg:"bg-red-500/10 dark:bg-red-500/5",icon:"text-red-600 dark:text-red-400/80"},cyan:{border:"border-cyan-600/30 dark:border-cyan-500/20",bg:"bg-cyan-500/10 dark:bg-cyan-500/5",icon:"text-cyan-600 dark:text-cyan-400/80"}},mg={border:"border-parchment-400/40 dark:border-zinc-500/20",bg:"bg-parchment-500/8 dark:bg-zinc-500/5",icon:"text-parchment-500 dark:text-zinc-400/80"},Ls=`prose dark:prose-invert prose-sm max-w-none
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/angular-html-CU67Zn6k.js","assets/html-GMplVEZG.js","assets/javascript-wDzz0qaB.js","assets/css-DPfMkruS.js","assets/angular-ts-BwZT4LLn.js","assets/scss-OYdSNvt2.js","assets/apl-dKokRX4l.js","assets/xml-sdJ4AIDG.js","assets/java-CylS5w8V.js","assets/json-Cp-IABpG.js","assets/astro-CbQHKStN.js","assets/typescript-BPQ3VLAy.js","assets/postcss-CXtECtnM.js","assets/tsx-COt5Ahok.js","assets/blade-D4QpJJKB.js","assets/html-derivative-BFtXZ54Q.js","assets/sql-BLtJtn59.js","assets/bsl-BO_Y6i37.js","assets/sdbl-DVxCFoDh.js","assets/cairo-KRGpt6FW.js","assets/python-B6aJPvgy.js","assets/cobol-nwyudZeR.js","assets/coffee-Ch7k5sss.js","assets/cpp-CofmeUqb.js","assets/regexp-CDVJQ6XC.js","assets/glsl-DplSGwfg.js","assets/c-BIGW1oBm.js","assets/crystal-tKQVLTB8.js","assets/shellscript-Yzrsuije.js","assets/edge-BkV0erSs.js","assets/elixir-CDX3lj18.js","assets/elm-DbKCFpqz.js","assets/erb-B12qg9BL.js","assets/ruby-Dw2BHqvy.js","assets/haml-B8DHNrY2.js","assets/graphql-ChdNCCLP.js","assets/jsx-g9-lgVsj.js","assets/lua-BaeVxFsk.js","assets/yaml-Buea-lGh.js","assets/erlang-DsQrWhSR.js","assets/markdown-Cvjx9yec.js","assets/fortran-fixed-form-CkoXwp7k.js","assets/fortran-free-form-BxgE0vQu.js","assets/fsharp-CXgrBDvD.js","assets/gdresource-BOOCDP_w.js","assets/gdshader-DkwncUOv.js","assets/gdscript-C5YyOfLZ.js","assets/git-commit-F4YmCXRG.js","assets/diff-D97Zzqfu.js","assets/git-rebase-r7XF79zn.js","assets/glimmer-js-Rg0-pVw9.js","assets/glimmer-ts-U6CK756n.js","assets/hack-CaT9iCJl.js","assets/handlebars-BL8al0AC.js","assets/http-jrhK8wxY.js","assets/hurl-irOxFIW8.js","assets/csv-fuZLfV_i.js","assets/hxml-Bvhsp5Yf.js","assets/haxe-CzTSHFRz.js","assets/jinja-4LBKfQ-Z.js","assets/jison-wvAkD_A8.js","assets/julia-CxzCAyBv.js","assets/r-Dspwwk_N.js","assets/just-Cw27pwNe.js","assets/perl-C0TMdlhV.js","assets/latex-CWtU0Tv5.js","assets/tex-idrVyKtj.js","assets/liquid-DYVedYrR.js","assets/marko-CnJfTvn9.js","assets/less-B1dDrJ26.js","assets/mdc-BMNejdWA.js","assets/nextflow-Zz6hmt5N.js","assets/nextflow-groovy-BeH2EWoN.js","assets/nginx-BpAMiNFr.js","assets/nim-CVrawwO9.js","assets/php-Dhbhpdrm.js","assets/pug-CGlum2m_.js","assets/qml-3beO22l8.js","assets/razor-Uh8Bk_45.js","assets/csharp-COcwbKMJ.js","assets/rst-BrH8l1NY.js","assets/cmake-D1j8_8rp.js","assets/sas-cz2c8ADy.js","assets/shaderlab-Dg9Lc6iA.js","assets/hlsl-D3lLCCz7.js","assets/shellsession-BADoaaVG.js","assets/soy-Brmx7dQM.js","assets/sparql-rVzFXLq3.js","assets/turtle-BsS91CYL.js","assets/stata-BH5u7GGu.js","assets/surrealql-Bq5Q-fJD.js","assets/svelte-C_ipcX3V.js","assets/templ-P3uqSqPl.js","assets/go-CxLEBnE3.js","assets/ts-tags-zn1MmPIZ.js","assets/twig-DNn4PbVi.js","assets/vue-DN_0RTcg.js","assets/vue-html-AaS7Mt5G.js","assets/vue-vine-CQOfvN7w.js","assets/stylus-BEDo0Tqx.js","assets/xsl-CtQFsRM5.js","assets/CodeHighlight-AX8pcR0a.js","assets/vendor-react-xyVz3hOa.js","assets/vendor-radix-BmcW-0BY.js","assets/vendor-markdown-vZ7invOV.js","assets/CodeHighlight-BFCEx5SO.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{j as s,r as u,b as Ie,c as Am,u as Rm,o as Pm,s as Mm,f as Lm,d as Om,e as Dm,h as $m,i as zm,l as Fm,k as mn,m as Mt,n as xa,p as Nt,q as $l,t as zl,L as hn,Q as Vm,v as Bm,w as Fl,x as xt,N as Um,B as Gm,y as Hm}from"./vendor-react-xyVz3hOa.js";import{S as qm,R as Wm,C as Km,a as Qm,u as dt,P as st,c as He,d as Ym,b as Wn,e as ls,f as pr,g as Vl,h as Jm,i as ba,j as Ys,k as Xm}from"./vendor-radix-BmcW-0BY.js";import{t as Zm,M as rs,r as Cs,a as Eo}from"./vendor-markdown-vZ7invOV.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const a of o)if(a.type==="childList")for(const i of a.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(o){const a={};return o.integrity&&(a.integrity=o.integrity),o.referrerPolicy&&(a.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?a.credentials="include":o.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(o){if(o.ep)return;o.ep=!0;const a=n(o);fetch(o.href,a)}})();function jn({children:t}){return s.jsx("div",{className:"flex flex-col w-full h-full overflow-hidden bg-background relative",children:s.jsx("main",{className:"flex-1 flex flex-col overflow-hidden h-full min-h-0",children:t})})}const eh=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),th=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),gi=t=>{const e=th(t);return e.charAt(0).toUpperCase()+e.slice(1)},Bl=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),sh=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var nh={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const rh=u.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:a,iconNode:i,...l},c)=>u.createElement("svg",{ref:c,...nh,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:Bl("lucide",o),...!a&&!sh(l)&&{"aria-hidden":"true"},...l},[...i.map(([d,p])=>u.createElement(d,p)),...Array.isArray(a)?a:[a]]));const J=(t,e)=>{const n=u.forwardRef(({className:r,...o},a)=>u.createElement(rh,{ref:a,iconNode:e,className:Bl(`lucide-${eh(gi(t))}`,`lucide-${t}`,r),...o}));return n.displayName=gi(t),n};const oh=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],tn=J("archive",oh);const ah=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],ih=J("arrow-down",ah);const ch=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Ul=J("arrow-left",ch);const lh=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],dh=J("arrow-right",lh);const uh=[["path",{d:"M4.5 3h15",key:"c7n0jr"}],["path",{d:"M6 3v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V3",key:"m1uhx7"}],["path",{d:"M6 14h12",key:"4cwo0f"}]],To=J("beaker",uh);const ph=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]],xi=J("bell-off",ph);const mh=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],Gr=J("bell",mh);const hh=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],fh=J("bot",hh);const gh=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],xh=J("box",gh);const bh=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],yh=J("brain",bh);const vh=[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]],Gl=J("bug",vh);const wh=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Oe=J("check",wh);const _h=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Lt=J("chevron-down",_h);const kh=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ut=J("chevron-right",kh);const jh=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Nh=J("chevron-up",jh);const Sh=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Es=J("circle-alert",Sh);const Ch=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]],Eh=J("circle-arrow-up",Ch);const Th=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Bn=J("circle-check",Th);const Ih=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],bi=J("circle-x",Ih);const Ah=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Hr=J("circle",Ah);const Rh=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]],Ph=J("clipboard-check",Rh);const Mh=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Lh=J("clock",Mh);const Oh=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],Io=J("code",Oh);const Dh=[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],$h=J("compass",Dh);const zh=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Vt=J("copy",zh);const Fh=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]],Vh=J("crosshair",Fh);const Bh=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],Ao=J("download",Bh);const Uh=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],os=J("external-link",Uh);const Gh=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],yi=J("eye-off",Gh);const Hh=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Ro=J("eye",Hh);const qh=[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]],Wh=J("file-code",qh);const Kh=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Po=J("file-text",Kh);const Qh=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],Hl=J("flask-conical",Qh);const Yh=[["rect",{width:"8",height:"5",x:"14",y:"17",rx:"1",key:"19aais"}],["path",{d:"M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2.5",key:"1w6v7t"}],["path",{d:"M20 17v-2a2 2 0 1 0-4 0v2",key:"pwaxnr"}]],Jh=J("folder-lock",Yh);const Xh=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Zh=J("gauge",Xh);const ef=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],ya=J("git-branch",ef);const tf=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]],sf=J("git-commit-horizontal",tf);const nf=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],rf=J("globe",nf);const of=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],af=J("image",of);const cf=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m8 11 4 4 4-4",key:"1dohi6"}],["path",{d:"M8 5H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-4",key:"1ywtjm"}]],Kn=J("import",cf);const lf=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],df=J("info",lf);const uf=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],pf=J("key-round",uf);const mf=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],ql=J("layers",mf);const hf=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],vi=J("layout-dashboard",hf);const ff=[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]],gf=J("list-checks",ff);const xf=[["rect",{x:"3",y:"5",width:"6",height:"6",rx:"1",key:"1defrl"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]],Js=J("list-todo",xf);const bf=[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]],yf=J("list",bf);const vf=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Re=J("loader-circle",vf);const wf=[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],_f=J("locate-fixed",wf);const kf=[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]],wi=J("log-in",kf);const jf=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],_i=J("log-out",jf);const Nf=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],Sf=J("maximize-2",Nf);const Cf=[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]],Ef=J("menu",Cf);const Tf=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],If=J("message-circle",Tf);const Af=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],as=J("message-square",Af);const Rf=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],Pf=J("minimize-2",Rf);const Mf=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],Lf=J("monitor",Mf);const Of=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],Df=J("network",Of);const $f=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],zf=J("panel-left-close",$f);const Ff=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],Wl=J("panel-left",Ff);const Vf=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],qr=J("panel-right-close",Vf);const Bf=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],Wr=J("panel-right-open",Bf);const Uf=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],ki=J("pause",Uf);const Gf=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],Hf=J("pencil-line",Gf);const qf=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],va=J("pencil",qf);const Wf=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],Gt=J("play",Wf);const Kf=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Kl=J("plus",Kf);const Qf=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],ds=J("refresh-cw",Qf);const Yf=[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]],Jf=J("rocket",Yf);const Xf=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],wa=J("rotate-ccw",Xf);const Zf=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Ql=J("search",Zf);const e0=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],ji=J("send",e0);const t0=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Mo=J("settings",t0);const s0=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],Yl=J("shield-alert",s0);const n0=[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]],mr=J("shield-off",n0);const r0=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Ms=J("shield",r0);const o0=[["path",{d:"m12.5 17-.5-1-.5 1h1z",key:"3me087"}],["path",{d:"M15 22a1 1 0 0 0 1-1v-1a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20v1a1 1 0 0 0 1 1z",key:"1o5pge"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}]],a0=J("skull",o0);const i0=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],_a=J("sparkles",i0);const c0=[["path",{d:"M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8Z",key:"qazsjp"}],["path",{d:"M15 3v4a2 2 0 0 0 2 2h4",key:"40519r"}]],l0=J("sticky-note",c0);const d0=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],u0=J("terminal",d0);const p0=[["path",{d:"M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5c-1.4 0-2.5-1.1-2.5-2.5V2",key:"125lnx"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14.5 16h-5",key:"1ox875"}]],m0=J("test-tube",p0);const h0=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Lo=J("trash-2",h0);const f0=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],kt=J("triangle-alert",f0);const g0=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Jl=J("user",g0);const x0=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],b0=J("users",x0);const y0=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],ka=J("wrench",y0);const v0=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Be=J("x",v0);const w0=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],ja=J("zap",w0);function Xl(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var o=t.length;for(e=0;e<o;e++)t[e]&&(n=Xl(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function Na(){for(var t,e,n=0,r="",o=arguments.length;n<o;n++)(t=arguments[n])&&(e=Xl(t))&&(r&&(r+=" "),r+=e);return r}const Ni=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,Si=Na,_0=(t,e)=>n=>{var r;if(e?.variants==null)return Si(t,n?.class,n?.className);const{variants:o,defaultVariants:a}=e,i=Object.keys(o).map(d=>{const p=n?.[d],m=a?.[d];if(p===null)return null;const h=Ni(p)||Ni(m);return o[d][h]}),l=n&&Object.entries(n).reduce((d,p)=>{let[m,h]=p;return h===void 0||(d[m]=h),d},{}),c=e==null||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((d,p)=>{let{class:m,className:h,...g}=p;return Object.entries(g).every(f=>{let[x,b]=f;return Array.isArray(b)?b.includes({...a,...l}[x]):{...a,...l}[x]===b})?[...d,m,h]:d},[]);return Si(t,i,c,n?.class,n?.className)},k0=(t,e)=>{const n=new Array(t.length+e.length);for(let r=0;r<t.length;r++)n[r]=t[r];for(let r=0;r<e.length;r++)n[t.length+r]=e[r];return n},j0=(t,e)=>({classGroupId:t,validator:e}),Zl=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),Qn="-",Ci=[],N0="arbitrary..",S0=t=>{const e=E0(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return C0(i);const l=i.split(Qn),c=l[0]===""&&l.length>1?1:0;return ed(l,c,e)},getConflictingClassGroupIds:(i,l)=>{if(l){const c=r[i],d=n[i];return c?d?k0(d,c):c:d||Ci}return n[i]||Ci}}},ed=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const o=t[e],a=n.nextPart.get(o);if(a){const d=ed(t,e+1,a);if(d)return d}const i=n.validators;if(i===null)return;const l=e===0?t.join(Qn):t.slice(e).join(Qn),c=i.length;for(let d=0;d<c;d++){const p=i[d];if(p.validator(l))return p.classGroupId}},C0=t=>t.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),n=e.indexOf(":"),r=e.slice(0,n);return r?N0+r:void 0})(),E0=t=>{const{theme:e,classGroups:n}=t;return T0(n,e)},T0=(t,e)=>{const n=Zl();for(const r in t){const o=t[r];Sa(o,n,r,e)}return n},Sa=(t,e,n,r)=>{const o=t.length;for(let a=0;a<o;a++){const i=t[a];I0(i,e,n,r)}},I0=(t,e,n,r)=>{if(typeof t=="string"){A0(t,e,n);return}if(typeof t=="function"){R0(t,e,n,r);return}P0(t,e,n,r)},A0=(t,e,n)=>{const r=t===""?e:td(e,t);r.classGroupId=n},R0=(t,e,n,r)=>{if(M0(t)){Sa(t(r),e,n,r);return}e.validators===null&&(e.validators=[]),e.validators.push(j0(n,t))},P0=(t,e,n,r)=>{const o=Object.entries(t),a=o.length;for(let i=0;i<a;i++){const[l,c]=o[i];Sa(c,td(e,l),n,r)}},td=(t,e)=>{let n=t;const r=e.split(Qn),o=r.length;for(let a=0;a<o;a++){const i=r[a];let l=n.nextPart.get(i);l||(l=Zl(),n.nextPart.set(i,l)),n=l}return n},M0=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,L0=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=Object.create(null),r=Object.create(null);const o=(a,i)=>{n[a]=i,e++,e>t&&(e=0,r=n,n=Object.create(null))};return{get(a){let i=n[a];if(i!==void 0)return i;if((i=r[a])!==void 0)return o(a,i),i},set(a,i){a in n?n[a]=i:o(a,i)}}},Oo="!",Ei=":",O0=[],Ti=(t,e,n,r,o)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:r,isExternal:o}),D0=t=>{const{prefix:e,experimentalParseClassName:n}=t;let r=o=>{const a=[];let i=0,l=0,c=0,d;const p=o.length;for(let x=0;x<p;x++){const b=o[x];if(i===0&&l===0){if(b===Ei){a.push(o.slice(c,x)),c=x+1;continue}if(b==="/"){d=x;continue}}b==="["?i++:b==="]"?i--:b==="("?l++:b===")"&&l--}const m=a.length===0?o:o.slice(c);let h=m,g=!1;m.endsWith(Oo)?(h=m.slice(0,-1),g=!0):m.startsWith(Oo)&&(h=m.slice(1),g=!0);const f=d&&d>c?d-c:void 0;return Ti(a,g,h,f)};if(e){const o=e+Ei,a=r;r=i=>i.startsWith(o)?a(i.slice(o.length)):Ti(O0,!1,i,void 0,!0)}if(n){const o=r;r=a=>n({className:a,parseClassName:o})}return r},$0=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((n,r)=>{e.set(n,1e6+r)}),n=>{const r=[];let o=[];for(let a=0;a<n.length;a++){const i=n[a],l=i[0]==="[",c=e.has(i);l||c?(o.length>0&&(o.sort(),r.push(...o),o=[]),r.push(i)):o.push(i)}return o.length>0&&(o.sort(),r.push(...o)),r}},z0=t=>({cache:L0(t.cacheSize),parseClassName:D0(t),sortModifiers:$0(t),...S0(t)}),F0=/\s+/,V0=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:a}=e,i=[],l=t.trim().split(F0);let c="";for(let d=l.length-1;d>=0;d-=1){const p=l[d],{isExternal:m,modifiers:h,hasImportantModifier:g,baseClassName:f,maybePostfixModifierPosition:x}=n(p);if(m){c=p+(c.length>0?" "+c:c);continue}let b=!!x,y=r(b?f.substring(0,x):f);if(!y){if(!b){c=p+(c.length>0?" "+c:c);continue}if(y=r(f),!y){c=p+(c.length>0?" "+c:c);continue}b=!1}const v=h.length===0?"":h.length===1?h[0]:a(h).join(":"),w=g?v+Oo:v,N=w+y;if(i.indexOf(N)>-1)continue;i.push(N);const S=o(y,b);for(let T=0;T<S.length;++T){const C=S[T];i.push(w+C)}c=p+(c.length>0?" "+c:c)}return c},B0=(...t)=>{let e=0,n,r,o="";for(;e<t.length;)(n=t[e++])&&(r=sd(n))&&(o&&(o+=" "),o+=r);return o},sd=t=>{if(typeof t=="string")return t;let e,n="";for(let r=0;r<t.length;r++)t[r]&&(e=sd(t[r]))&&(n&&(n+=" "),n+=e);return n},U0=(t,...e)=>{let n,r,o,a;const i=c=>{const d=e.reduce((p,m)=>m(p),t());return n=z0(d),r=n.cache.get,o=n.cache.set,a=l,l(c)},l=c=>{const d=r(c);if(d)return d;const p=V0(c,n);return o(c,p),p};return a=i,(...c)=>a(B0(...c))},G0=[],Ue=t=>{const e=n=>n[t]||G0;return e.isThemeGetter=!0,e},nd=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,rd=/^\((?:(\w[\w-]*):)?(.+)\)$/i,H0=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,q0=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,W0=/\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$/,K0=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Q0=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Y0=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Dt=t=>H0.test(t),we=t=>!!t&&!Number.isNaN(Number(t)),$t=t=>!!t&&Number.isInteger(Number(t)),Kr=t=>t.endsWith("%")&&we(t.slice(0,-1)),Tt=t=>q0.test(t),od=()=>!0,J0=t=>W0.test(t)&&!K0.test(t),Ca=()=>!1,X0=t=>Q0.test(t),Z0=t=>Y0.test(t),eg=t=>!le(t)&&!pe(t),tg=t=>Ht(t,cd,Ca),le=t=>nd.test(t),Xt=t=>Ht(t,ld,J0),Ii=t=>Ht(t,lg,we),sg=t=>Ht(t,ud,od),ng=t=>Ht(t,dd,Ca),Ai=t=>Ht(t,ad,Ca),rg=t=>Ht(t,id,Z0),Nn=t=>Ht(t,pd,X0),pe=t=>rd.test(t),Us=t=>us(t,ld),og=t=>us(t,dd),Ri=t=>us(t,ad),ag=t=>us(t,cd),ig=t=>us(t,id),Sn=t=>us(t,pd,!0),cg=t=>us(t,ud,!0),Ht=(t,e,n)=>{const r=nd.exec(t);return r?r[1]?e(r[1]):n(r[2]):!1},us=(t,e,n=!1)=>{const r=rd.exec(t);return r?r[1]?e(r[1]):n:!1},ad=t=>t==="position"||t==="percentage",id=t=>t==="image"||t==="url",cd=t=>t==="length"||t==="size"||t==="bg-size",ld=t=>t==="length",lg=t=>t==="number",dd=t=>t==="family-name",ud=t=>t==="number"||t==="weight",pd=t=>t==="shadow",dg=()=>{const t=Ue("color"),e=Ue("font"),n=Ue("text"),r=Ue("font-weight"),o=Ue("tracking"),a=Ue("leading"),i=Ue("breakpoint"),l=Ue("container"),c=Ue("spacing"),d=Ue("radius"),p=Ue("shadow"),m=Ue("inset-shadow"),h=Ue("text-shadow"),g=Ue("drop-shadow"),f=Ue("blur"),x=Ue("perspective"),b=Ue("aspect"),y=Ue("ease"),v=Ue("animate"),w=()=>["auto","avoid","all","avoid-page","page","left","right","column"],N=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],S=()=>[...N(),pe,le],T=()=>["auto","hidden","clip","visible","scroll"],C=()=>["auto","contain","none"],j=()=>[pe,le,c],E=()=>[Dt,"full","auto",...j()],A=()=>[$t,"none","subgrid",pe,le],L=()=>["auto",{span:["full",$t,pe,le]},$t,pe,le],$=()=>[$t,"auto",pe,le],oe=()=>["auto","min","max","fr",pe,le],ne=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],B=()=>["start","end","center","stretch","center-safe","end-safe"],Q=()=>["auto",...j()],q=()=>[Dt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...j()],Z=()=>[Dt,"screen","full","dvw","lvw","svw","min","max","fit",...j()],me=()=>[Dt,"screen","full","lh","dvh","lvh","svh","min","max","fit",...j()],O=()=>[t,pe,le],W=()=>[...N(),Ri,Ai,{position:[pe,le]}],ee=()=>["no-repeat",{repeat:["","x","y","space","round"]}],z=()=>["auto","cover","contain",ag,tg,{size:[pe,le]}],re=()=>[Kr,Us,Xt],se=()=>["","none","full",d,pe,le],te=()=>["",we,Us,Xt],xe=()=>["solid","dashed","dotted","double"],_e=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],I=()=>[we,Kr,Ri,Ai],P=()=>["","none",f,pe,le],de=()=>["none",we,pe,le],X=()=>["none",we,pe,le],G=()=>[we,pe,le],V=()=>[Dt,"full",...j()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Tt],breakpoint:[Tt],color:[od],container:[Tt],"drop-shadow":[Tt],ease:["in","out","in-out"],font:[eg],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Tt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Tt],shadow:[Tt],spacing:["px",we],text:[Tt],"text-shadow":[Tt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Dt,le,pe,b]}],container:["container"],columns:[{columns:[we,le,pe,l]}],"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:S()}],overflow:[{overflow:T()}],"overflow-x":[{"overflow-x":T()}],"overflow-y":[{"overflow-y":T()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:E()}],"inset-x":[{"inset-x":E()}],"inset-y":[{"inset-y":E()}],start:[{"inset-s":E(),start:E()}],end:[{"inset-e":E(),end:E()}],"inset-bs":[{"inset-bs":E()}],"inset-be":[{"inset-be":E()}],top:[{top:E()}],right:[{right:E()}],bottom:[{bottom:E()}],left:[{left:E()}],visibility:["visible","invisible","collapse"],z:[{z:[$t,"auto",pe,le]}],basis:[{basis:[Dt,"full","auto",l,...j()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[we,Dt,"auto","initial","none",le]}],grow:[{grow:["",we,pe,le]}],shrink:[{shrink:["",we,pe,le]}],order:[{order:[$t,"first","last","none",pe,le]}],"grid-cols":[{"grid-cols":A()}],"col-start-end":[{col:L()}],"col-start":[{"col-start":$()}],"col-end":[{"col-end":$()}],"grid-rows":[{"grid-rows":A()}],"row-start-end":[{row:L()}],"row-start":[{"row-start":$()}],"row-end":[{"row-end":$()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":oe()}],"auto-rows":[{"auto-rows":oe()}],gap:[{gap:j()}],"gap-x":[{"gap-x":j()}],"gap-y":[{"gap-y":j()}],"justify-content":[{justify:[...ne(),"normal"]}],"justify-items":[{"justify-items":[...B(),"normal"]}],"justify-self":[{"justify-self":["auto",...B()]}],"align-content":[{content:["normal",...ne()]}],"align-items":[{items:[...B(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...B(),{baseline:["","last"]}]}],"place-content":[{"place-content":ne()}],"place-items":[{"place-items":[...B(),"baseline"]}],"place-self":[{"place-self":["auto",...B()]}],p:[{p:j()}],px:[{px:j()}],py:[{py:j()}],ps:[{ps:j()}],pe:[{pe:j()}],pbs:[{pbs:j()}],pbe:[{pbe:j()}],pt:[{pt:j()}],pr:[{pr:j()}],pb:[{pb:j()}],pl:[{pl:j()}],m:[{m:Q()}],mx:[{mx:Q()}],my:[{my:Q()}],ms:[{ms:Q()}],me:[{me:Q()}],mbs:[{mbs:Q()}],mbe:[{mbe:Q()}],mt:[{mt:Q()}],mr:[{mr:Q()}],mb:[{mb:Q()}],ml:[{ml:Q()}],"space-x":[{"space-x":j()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":j()}],"space-y-reverse":["space-y-reverse"],size:[{size:q()}],"inline-size":[{inline:["auto",...Z()]}],"min-inline-size":[{"min-inline":["auto",...Z()]}],"max-inline-size":[{"max-inline":["none",...Z()]}],"block-size":[{block:["auto",...me()]}],"min-block-size":[{"min-block":["auto",...me()]}],"max-block-size":[{"max-block":["none",...me()]}],w:[{w:[l,"screen",...q()]}],"min-w":[{"min-w":[l,"screen","none",...q()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[i]},...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,Us,Xt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,cg,sg]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Kr,le]}],"font-family":[{font:[og,ng,e]}],"font-features":[{"font-features":[le]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,pe,le]}],"line-clamp":[{"line-clamp":[we,"none",pe,Ii]}],leading:[{leading:[a,...j()]}],"list-image":[{"list-image":["none",pe,le]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",pe,le]}],"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:[...xe(),"wavy"]}],"text-decoration-thickness":[{decoration:[we,"from-font","auto",pe,Xt]}],"text-decoration-color":[{decoration:O()}],"underline-offset":[{"underline-offset":[we,"auto",pe,le]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:j()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",pe,le]}],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,le]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:W()}],"bg-repeat":[{bg:ee()}],"bg-size":[{bg:z()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},$t,pe,le],radial:["",pe,le],conic:[$t,pe,le]},ig,rg]}],"bg-color":[{bg:O()}],"gradient-from-pos":[{from:re()}],"gradient-via-pos":[{via:re()}],"gradient-to-pos":[{to:re()}],"gradient-from":[{from:O()}],"gradient-via":[{via:O()}],"gradient-to":[{to:O()}],rounded:[{rounded:se()}],"rounded-s":[{"rounded-s":se()}],"rounded-e":[{"rounded-e":se()}],"rounded-t":[{"rounded-t":se()}],"rounded-r":[{"rounded-r":se()}],"rounded-b":[{"rounded-b":se()}],"rounded-l":[{"rounded-l":se()}],"rounded-ss":[{"rounded-ss":se()}],"rounded-se":[{"rounded-se":se()}],"rounded-ee":[{"rounded-ee":se()}],"rounded-es":[{"rounded-es":se()}],"rounded-tl":[{"rounded-tl":se()}],"rounded-tr":[{"rounded-tr":se()}],"rounded-br":[{"rounded-br":se()}],"rounded-bl":[{"rounded-bl":se()}],"border-w":[{border:te()}],"border-w-x":[{"border-x":te()}],"border-w-y":[{"border-y":te()}],"border-w-s":[{"border-s":te()}],"border-w-e":[{"border-e":te()}],"border-w-bs":[{"border-bs":te()}],"border-w-be":[{"border-be":te()}],"border-w-t":[{"border-t":te()}],"border-w-r":[{"border-r":te()}],"border-w-b":[{"border-b":te()}],"border-w-l":[{"border-l":te()}],"divide-x":[{"divide-x":te()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":te()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...xe(),"hidden","none"]}],"divide-style":[{divide:[...xe(),"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:[...xe(),"none","hidden"]}],"outline-offset":[{"outline-offset":[we,pe,le]}],"outline-w":[{outline:["",we,Us,Xt]}],"outline-color":[{outline:O()}],shadow:[{shadow:["","none",p,Sn,Nn]}],"shadow-color":[{shadow:O()}],"inset-shadow":[{"inset-shadow":["none",m,Sn,Nn]}],"inset-shadow-color":[{"inset-shadow":O()}],"ring-w":[{ring:te()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:O()}],"ring-offset-w":[{"ring-offset":[we,Xt]}],"ring-offset-color":[{"ring-offset":O()}],"inset-ring-w":[{"inset-ring":te()}],"inset-ring-color":[{"inset-ring":O()}],"text-shadow":[{"text-shadow":["none",h,Sn,Nn]}],"text-shadow-color":[{"text-shadow":O()}],opacity:[{opacity:[we,pe,le]}],"mix-blend":[{"mix-blend":[..._e(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":_e()}],"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":[we]}],"mask-image-linear-from-pos":[{"mask-linear-from":I()}],"mask-image-linear-to-pos":[{"mask-linear-to":I()}],"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":I()}],"mask-image-t-to-pos":[{"mask-t-to":I()}],"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":I()}],"mask-image-r-to-pos":[{"mask-r-to":I()}],"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":I()}],"mask-image-b-to-pos":[{"mask-b-to":I()}],"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":I()}],"mask-image-l-to-pos":[{"mask-l-to":I()}],"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":I()}],"mask-image-x-to-pos":[{"mask-x-to":I()}],"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":I()}],"mask-image-y-to-pos":[{"mask-y-to":I()}],"mask-image-y-from-color":[{"mask-y-from":O()}],"mask-image-y-to-color":[{"mask-y-to":O()}],"mask-image-radial":[{"mask-radial":[pe,le]}],"mask-image-radial-from-pos":[{"mask-radial-from":I()}],"mask-image-radial-to-pos":[{"mask-radial-to":I()}],"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":N()}],"mask-image-conic-pos":[{"mask-conic":[we]}],"mask-image-conic-from-pos":[{"mask-conic-from":I()}],"mask-image-conic-to-pos":[{"mask-conic-to":I()}],"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:W()}],"mask-repeat":[{mask:ee()}],"mask-size":[{mask:z()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",pe,le]}],filter:[{filter:["","none",pe,le]}],blur:[{blur:P()}],brightness:[{brightness:[we,pe,le]}],contrast:[{contrast:[we,pe,le]}],"drop-shadow":[{"drop-shadow":["","none",g,Sn,Nn]}],"drop-shadow-color":[{"drop-shadow":O()}],grayscale:[{grayscale:["",we,pe,le]}],"hue-rotate":[{"hue-rotate":[we,pe,le]}],invert:[{invert:["",we,pe,le]}],saturate:[{saturate:[we,pe,le]}],sepia:[{sepia:["",we,pe,le]}],"backdrop-filter":[{"backdrop-filter":["","none",pe,le]}],"backdrop-blur":[{"backdrop-blur":P()}],"backdrop-brightness":[{"backdrop-brightness":[we,pe,le]}],"backdrop-contrast":[{"backdrop-contrast":[we,pe,le]}],"backdrop-grayscale":[{"backdrop-grayscale":["",we,pe,le]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[we,pe,le]}],"backdrop-invert":[{"backdrop-invert":["",we,pe,le]}],"backdrop-opacity":[{"backdrop-opacity":[we,pe,le]}],"backdrop-saturate":[{"backdrop-saturate":[we,pe,le]}],"backdrop-sepia":[{"backdrop-sepia":["",we,pe,le]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":j()}],"border-spacing-x":[{"border-spacing-x":j()}],"border-spacing-y":[{"border-spacing-y":j()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",pe,le]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[we,"initial",pe,le]}],ease:[{ease:["linear","initial",y,pe,le]}],delay:[{delay:[we,pe,le]}],animate:[{animate:["none",v,pe,le]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[x,pe,le]}],"perspective-origin":[{"perspective-origin":S()}],rotate:[{rotate:de()}],"rotate-x":[{"rotate-x":de()}],"rotate-y":[{"rotate-y":de()}],"rotate-z":[{"rotate-z":de()}],scale:[{scale:X()}],"scale-x":[{"scale-x":X()}],"scale-y":[{"scale-y":X()}],"scale-z":[{"scale-z":X()}],"scale-3d":["scale-3d"],skew:[{skew:G()}],"skew-x":[{"skew-x":G()}],"skew-y":[{"skew-y":G()}],transform:[{transform:[pe,le,"","none","gpu","cpu"]}],"transform-origin":[{origin:S()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:V()}],"translate-x":[{"translate-x":V()}],"translate-y":[{"translate-y":V()}],"translate-z":[{"translate-z":V()}],"translate-none":["translate-none"],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,le]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":j()}],"scroll-mx":[{"scroll-mx":j()}],"scroll-my":[{"scroll-my":j()}],"scroll-ms":[{"scroll-ms":j()}],"scroll-me":[{"scroll-me":j()}],"scroll-mbs":[{"scroll-mbs":j()}],"scroll-mbe":[{"scroll-mbe":j()}],"scroll-mt":[{"scroll-mt":j()}],"scroll-mr":[{"scroll-mr":j()}],"scroll-mb":[{"scroll-mb":j()}],"scroll-ml":[{"scroll-ml":j()}],"scroll-p":[{"scroll-p":j()}],"scroll-px":[{"scroll-px":j()}],"scroll-py":[{"scroll-py":j()}],"scroll-ps":[{"scroll-ps":j()}],"scroll-pe":[{"scroll-pe":j()}],"scroll-pbs":[{"scroll-pbs":j()}],"scroll-pbe":[{"scroll-pbe":j()}],"scroll-pt":[{"scroll-pt":j()}],"scroll-pr":[{"scroll-pr":j()}],"scroll-pb":[{"scroll-pb":j()}],"scroll-pl":[{"scroll-pl":j()}],"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,le]}],fill:[{fill:["none",...O()]}],"stroke-w":[{stroke:[we,Us,Xt,Ii]}],stroke:[{stroke:["none",...O()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{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"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},md=U0(dg);function $e(...t){return md(Na(t))}const ug=_0("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 cursor-pointer",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),hd=u.forwardRef(({className:t,variant:e,size:n,asChild:r=!1,...o},a)=>{const i=r?qm:"button";return s.jsx(i,{className:$e(ug({variant:e,size:n,className:t})),ref:a,...o})});hd.displayName="Button";function Pi({data:t,collapsed:e=!1,depth:n=0}){const[r,o]=u.useState(!1),a=e||r,[i,l]=u.useState(!1),c=async()=>{try{await navigator.clipboard.writeText(JSON.stringify(t,null,2)),l(!0),setTimeout(()=>l(!1),2e3)}catch(p){console.error("Failed to copy:",p)}},d=(p,m)=>{if(p===null)return s.jsx("span",{className:"text-neutral-500 dark:text-neutral-400",children:"null"});if(p===void 0)return s.jsx("span",{className:"text-neutral-500 dark:text-neutral-400",children:"undefined"});if(typeof p=="boolean")return s.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:p.toString()});if(typeof p=="number")return s.jsx("span",{className:"text-green-600 dark:text-green-400",children:p});if(typeof p=="string")return s.jsxs("span",{className:"text-emerald-700 dark:text-orange-300",children:['"',p,'"']});if(Array.isArray(p))return p.length===0?s.jsx("span",{className:"text-foreground",children:"[]"}):s.jsxs("span",{className:"inline-block",children:[s.jsx("button",{className:"inline-flex items-center justify-center w-4 h-4 mr-0.5 text-neutral-500 hover:text-black dark:text-neutral-400 dark:hover:text-white transition-colors",onClick:()=>o(h=>!h),"aria-label":a?"Expand array":"Collapse array",children:a?s.jsx(Ut,{size:12}):s.jsx(Lt,{size:12})}),s.jsx("span",{className:"text-foreground",children:"["}),a?s.jsxs("span",{className:"text-neutral-500 dark:text-neutral-400 italic mx-1",children:["...",p.length," items"]}):s.jsx("div",{className:"ml-[18px]",children:Object.entries(p).map(([h,g])=>s.jsxs("div",{className:"my-0.5",children:[s.jsxs("span",{className:"text-muted-foreground mr-1",children:[h,":"]}),d(g),Number(h)<p.length-1&&s.jsx("span",{className:"text-foreground",children:","})]},`json-array-item-${h}`))}),s.jsx("span",{className:"text-foreground",children:"]"})]});if(typeof p=="object"){const h=Object.entries(p);return h.length===0?s.jsx("span",{className:"text-foreground",children:"{}"}):s.jsxs("span",{className:"inline-block",children:[s.jsx("button",{className:"inline-flex items-center justify-center w-4 h-4 mr-0.5 text-neutral-500 hover:text-black dark:text-neutral-400 dark:hover:text-white transition-colors",onClick:()=>o(g=>!g),"aria-label":a?"Expand object":"Collapse object",children:a?s.jsx(Ut,{size:12}):s.jsx(Lt,{size:12})}),s.jsx("span",{className:"text-foreground",children:"{"}),a?s.jsxs("span",{className:"text-neutral-500 dark:text-neutral-400 italic mx-1",children:["...",h.length," properties"]}):s.jsx("div",{className:"ml-[18px]",children:h.map(([g,f],x)=>s.jsxs("div",{className:"my-0.5",children:[s.jsxs("span",{className:"text-blue-700 dark:text-blue-300",children:['"',g,'"']}),s.jsx("span",{className:"text-foreground mx-1",children:":"}),d(f),x<h.length-1&&s.jsx("span",{className:"text-foreground",children:","})]},g))}),s.jsx("span",{className:"text-black dark:text-neutral-300",children:"}"})]})}return s.jsx("span",{className:"text-neutral-500 dark:text-neutral-400",children:String(p)})};return s.jsxs("div",{className:"relative font-mono text-xs leading-relaxed p-2 bg-neutral-50 dark:bg-neutral-900 rounded overflow-auto",children:[n===0&&s.jsx(hd,{variant:"ghost",size:"icon",className:"absolute top-1 right-1 h-6 w-6 bg-neutral-100 hover:bg-neutral-200 dark:bg-neutral-800 dark:hover:bg-neutral-700",onClick:c,"aria-label":"Copy JSON to clipboard",children:i?s.jsx(Oe,{size:14}):s.jsx(Vt,{size:14})}),d(t)]})}const Ea=u.createContext({theme:"dark"});function pg({children:t,...e}){return s.jsx(Ea.Provider,{value:e,children:t})}function hr(){return u.useContext(Ea).theme}function fd(t){const{resolveAgentColor:e}=u.useContext(Ea);if(!(!t||!e))return e(t)}const k={card:{bg:"bg-white dark:bg-zinc-900/30",border:"border-parchment-300 dark:border-zinc-800/40"},codeBg:"bg-parchment-100 dark:bg-zinc-950",codeBgSubtle:"bg-parchment-50 dark:bg-zinc-900/50",text:{primary:"text-parchment-800 dark:text-zinc-300",secondary:"text-parchment-600 dark:text-zinc-400",muted:"text-parchment-500 dark:text-zinc-500",faint:"text-parchment-400 dark:text-zinc-600"},separator:"border-parchment-200 dark:border-zinc-800/40",hover:"hover:bg-parchment-100 dark:hover:bg-zinc-800/40",scrollbar:"scrollbar-thin scrollbar-track-transparent scrollbar-thumb-parchment-300 dark:scrollbar-thumb-zinc-700"},ce={blue:{card:"border-blue-600/30 bg-blue-500/10 dark:border-blue-500/20 dark:bg-blue-500/5",icon:"text-blue-600 dark:text-blue-400/80"},emerald:{card:"border-emerald-600/30 bg-emerald-500/10 dark:border-emerald-500/20 dark:bg-emerald-500/5",icon:"text-emerald-600 dark:text-emerald-400/80"},violet:{card:"border-violet-600/30 bg-violet-500/10 dark:border-violet-500/20 dark:bg-violet-500/5",icon:"text-violet-600 dark:text-violet-400/80"},orange:{card:"border-orange-600/30 bg-orange-500/10 dark:border-orange-500/20 dark:bg-orange-500/5",icon:"text-orange-600 dark:text-orange-400/80"},amber:{card:"border-amber-600/30 bg-amber-500/10 dark:border-amber-500/20 dark:bg-amber-500/5",icon:"text-amber-600 dark:text-amber-400/80"},purple:{card:"border-purple-600/30 bg-purple-500/10 dark:border-purple-500/20 dark:bg-purple-500/5",icon:"text-purple-600 dark:text-purple-400/80"},cyan:{card:"border-cyan-600/30 bg-cyan-500/10 dark:border-cyan-500/20 dark:bg-cyan-500/5",icon:"text-cyan-600 dark:text-cyan-400/80"},indigo:{card:"border-indigo-600/30 bg-indigo-500/10 dark:border-indigo-500/20 dark:bg-indigo-500/5",icon:"text-indigo-600 dark:text-indigo-400/80"},rose:{card:"border-rose-600/30 bg-rose-500/10 dark:border-rose-500/20 dark:bg-rose-500/5",icon:"text-rose-600 dark:text-rose-400/80"},zinc:{card:"border-parchment-400/40 bg-parchment-500/8 dark:border-zinc-500/25 dark:bg-zinc-500/5",icon:"text-parchment-500 dark:text-zinc-400/80"}},_t={blue:{border:"border-blue-600/30 dark:border-blue-500/20",bg:"bg-blue-500/10 dark:bg-blue-500/5",icon:"text-blue-600 dark:text-blue-400/80"},green:{border:"border-green-600/30 dark:border-green-500/20",bg:"bg-green-500/10 dark:bg-green-500/5",icon:"text-green-600 dark:text-green-400/80"},yellow:{border:"border-amber-600/30 dark:border-amber-500/20",bg:"bg-amber-500/10 dark:bg-amber-500/5",icon:"text-amber-600 dark:text-amber-400/80"},purple:{border:"border-purple-600/30 dark:border-purple-500/20",bg:"bg-purple-500/10 dark:bg-purple-500/5",icon:"text-purple-600 dark:text-purple-400/80"},red:{border:"border-red-600/30 dark:border-red-500/20",bg:"bg-red-500/10 dark:bg-red-500/5",icon:"text-red-600 dark:text-red-400/80"},cyan:{border:"border-cyan-600/30 dark:border-cyan-500/20",bg:"bg-cyan-500/10 dark:bg-cyan-500/5",icon:"text-cyan-600 dark:text-cyan-400/80"}},mg={border:"border-parchment-400/40 dark:border-zinc-500/20",bg:"bg-parchment-500/8 dark:bg-zinc-500/5",icon:"text-parchment-500 dark:text-zinc-400/80"},Ls=`prose dark:prose-invert prose-sm max-w-none
|
|
3
3
|
[&_h1]:text-[15px] [&_h1]:font-semibold [&_h1]:text-parchment-900 dark:[&_h1]:text-zinc-200 [&_h1]:mt-3 [&_h1]:mb-1
|
|
4
4
|
[&_h2]:text-[14px] [&_h2]:font-semibold [&_h2]:text-parchment-800 dark:[&_h2]:text-zinc-300 [&_h2]:mt-2.5 [&_h2]:mb-1
|
|
5
5
|
[&_h3]:text-[13px] [&_h3]:font-medium [&_h3]:text-parchment-600 dark:[&_h3]:text-zinc-400 [&_h3]:mt-2 [&_h3]:mb-0.5
|
|
@@ -18,67 +18,67 @@ import{j as s,r as u,b as Te,c as Am,u as Rm,o as Pm,s as Mm,f as Lm,d as Om,e a
|
|
|
18
18
|
[&_ul]:my-1 [&_ol]:my-1
|
|
19
19
|
[&_strong]:text-parchment-800 dark:[&_strong]:text-zinc-300 [&_strong]:font-medium
|
|
20
20
|
[&_a]:text-blue-600 dark:[&_a]:text-blue-400/80 [&_a]:no-underline
|
|
21
|
-
[&_code]:text-[12px] [&_code]:bg-parchment-200 dark:[&_code]:bg-zinc-800/50 [&_code]:px-1 [&_code]:rounded`;function M(...t){return md(Na(t))}const hg={".js":"javascript",".jsx":"jsx",".ts":"typescript",".tsx":"tsx",".mjs":"javascript",".cjs":"javascript",".py":"python",".pyw":"python",".pyi":"python",".html":"html",".htm":"html",".xml":"xml",".css":"css",".scss":"scss",".sass":"sass",".less":"less",".json":"json",".yaml":"yaml",".yml":"yaml",".toml":"toml",".ini":"ini",".sh":"bash",".bash":"bash",".zsh":"bash",".fish":"bash",".c":"c",".h":"c",".cpp":"cpp",".cc":"cpp",".cxx":"cpp",".hpp":"cpp",".hxx":"cpp",".java":"java",".kt":"kotlin",".kts":"kotlin",".go":"go",".rs":"rust",".rb":"ruby",".rake":"ruby",".php":"php",".phtml":"php",".swift":"swift",".mm":"objectivec",".cs":"csharp",".sql":"sql",".md":"markdown",".markdown":"markdown",".dockerfile":"dockerfile",".makefile":"makefile",".mk":"makefile",".vim":"vim",".vimrc":"vim",".lua":"lua",".r":"r",".R":"r",".scala":"scala",".sc":"scala",".clj":"clojure",".cljs":"clojure",".cljc":"clojure",".hs":"haskell",".lhs":"haskell",".ex":"elixir",".exs":"elixir",".erl":"erlang",".hrl":"erlang",".ml":"ocaml",".mli":"ocaml",".fs":"fsharp",".fsi":"fsharp",".fsx":"fsharp",".dart":"dart",".pl":"perl",".pm":"perl",".groovy":"groovy",".gradle":"groovy",".tex":"latex",".latex":"latex",".m":"matlab",".mat":"matlab",".ps1":"powershell",".psm1":"powershell",".psd1":"powershell",".asm":"asm",".s":"asm",".glsl":"glsl",".vert":"glsl",".frag":"glsl",".graphql":"graphql",".gql":"graphql",".prisma":"prisma",".sol":"solidity",".vue":"vue",".svelte":"svelte",".nix":"nix",".jl":"julia",".zig":"zig",".cr":"crystal",".nim":"nim",".nims":"nim",".d":"d",".di":"d",".pas":"pascal",".pp":"pascal",".inc":"pascal",".f":"fortran",".for":"fortran",".f90":"fortran",".f95":"fortran",".pro":"prolog",".P":"prolog",".scm":"scheme",".ss":"scheme",".rkt":"racket",".lisp":"lisp",".lsp":"lisp",".cl":"lisp",".tcl":"tcl",".awk":"awk",".vhd":"vhdl",".vhdl":"vhdl",".v":"verilog",".vh":"verilog",".sv":"verilog",".wat":"wasm",".wast":"wasm"},Mi={Dockerfile:"dockerfile",Makefile:"makefile",Rakefile:"ruby",Gemfile:"ruby",".gitignore":"gitignore",".gitattributes":"gitignore",".npmignore":"gitignore",".dockerignore":"gitignore",".env":"bash",".bashrc":"bash",".zshrc":"bash",".bash_profile":"bash",".profile":"bash","nginx.conf":"nginx","httpd.conf":"apache",".htaccess":"apache"};function fr(t){if(!t)return"text";const e=t.split("/"),n=e[e.length-1];if(Mi[n])return Mi[n];const r=n.lastIndexOf(".");if(r===-1||r===0)return"text";const o=n.slice(r).toLowerCase();return hg[o]||"text"}function Ia(t){return JSON.parse(t)}function Ns(t,e){if(!t)return t;if(e&&t.startsWith(e)){const r=t.slice(e.length),o=r.startsWith("/")?r.slice(1):r;return o?`./${o}`:"./"}const n=["/home/","/Users/"];for(const r of n)if(t.startsWith(r))return`~${t.slice(r.length-1)}`;return t}function Aa(t){if(!t)return 0;const e=(t.match(/\n/g)||[]).length;return t.length>0?e+1:0}function fg(t){try{const e=Ia(t);if(Array.isArray(e))return e.filter(n=>n!==null&&typeof n=="object"&&"content"in n&&"status"in n&&typeof n.content=="string"&&typeof n.status=="string")}catch{}return[]}function gd(t){return t.replace(/\n?\[rerun: b\d+\]\s*$/,"")}function sn(t){try{return new URL(t).hostname}catch{return t}}const gg=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),xd=(...t)=>t.filter((e,n,r)=>!!e&&r.indexOf(e)===n).join(" ");var xg={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const bg=u.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:a,iconNode:i,...l},c)=>u.createElement("svg",{ref:c,...xg,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:xd("lucide",o),...l},[...i.map(([d,p])=>u.createElement(d,p)),...Array.isArray(a)?a:[a]]));const fe=(t,e)=>{const n=u.forwardRef(({className:r,...o},a)=>u.createElement(bg,{ref:a,iconNode:e,className:xd(`lucide-${gg(t)}`,r),...o}));return n.displayName=`${t}`,n};const bd=fe("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const yg=fe("AlarmClock",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M12 9v4l2 2",key:"1c63tq"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}]]);const vg=fe("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);const Do=fe("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const nn=fe("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const yd=fe("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const wg=fe("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const _g=fe("Chrome",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["line",{x1:"21.17",x2:"12",y1:"8",y2:"8",key:"a0cw5f"}],["line",{x1:"3.95",x2:"8.54",y1:"6.06",y2:"14",key:"1kftof"}],["line",{x1:"10.88",x2:"15.46",y1:"21.94",y2:"14",key:"1ymyh8"}]]);const gr=fe("CircleCheckBig",[["path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14",key:"g774vq"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);const xr=fe("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const rn=fe("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const br=fe("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const kg=fe("ClipboardCheck",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]]);const vd=fe("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);const jg=fe("Compass",[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const Ng=fe("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);const Sg=fe("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);const Os=fe("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Cg=fe("Eye",[["path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z",key:"rwhkz3"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const Eg=fe("FilePen",[["path",{d:"M12.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v9.5",key:"1couwa"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]]);const Tg=fe("FilePlus",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]);const Ig=fe("FileSearch",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4.268 21a2 2 0 0 0 1.727 1H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"ms7g94"}],["path",{d:"m9 18-1.5-1.5",key:"1j6qii"}],["circle",{cx:"5",cy:"14",r:"3",key:"ufru5t"}]]);const jt=fe("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const Li=fe("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);const Ag=fe("FolderSearch",[["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.5-1.5",key:"3sg1j"}]]);const is=fe("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);const Rg=fe("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);const Ra=fe("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);const Pg=fe("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]]);const Mg=fe("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);const Lg=fe("ListTodo",[["rect",{x:"3",y:"5",width:"6",height:"6",rx:"1",key:"1defrl"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);const wd=fe("List",[["line",{x1:"8",x2:"21",y1:"6",y2:"6",key:"7ey8pc"}],["line",{x1:"8",x2:"21",y1:"12",y2:"12",key:"rjfblc"}],["line",{x1:"8",x2:"21",y1:"18",y2:"18",key:"c3b1m8"}],["line",{x1:"3",x2:"3.01",y1:"6",y2:"6",key:"1g7gq3"}],["line",{x1:"3",x2:"3.01",y1:"12",y2:"12",key:"1pjlvk"}],["line",{x1:"3",x2:"3.01",y1:"18",y2:"18",key:"28t2mc"}]]);const at=fe("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const Og=fe("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);const Dg=fe("MessageCircleQuestion",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const _d=fe("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);const $g=fe("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);const zg=fe("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);const Fg=fe("MousePointer",[["path",{d:"m3 3 7.07 16.97 2.51-7.39 7.39-2.51L3 3z",key:"y2ucgo"}],["path",{d:"m13 13 6 6",key:"1nhxnf"}]]);const Vg=fe("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);const Bg=fe("Paperclip",[["path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48",key:"1u3ebp"}]]);const Ug=fe("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);const kd=fe("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);const Gg=fe("Plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]);const Hg=fe("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const qg=fe("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);const ss=fe("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);const $o=fe("Send",[["path",{d:"m22 2-7 20-4-9-9-4Z",key:"1q3vgg"}],["path",{d:"M22 2 11 13",key:"nzbqef"}]]);const Wg=fe("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);const Kg=fe("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Oi=fe("Star",[["polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2",key:"8f66p6"}]]);const Yn=fe("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);const Qg=fe("TreePine",[["path",{d:"m17 14 3 3.3a1 1 0 0 1-.7 1.7H4.7a1 1 0 0 1-.7-1.7L7 14h-.3a1 1 0 0 1-.7-1.7L9 9h-.2A1 1 0 0 1 8 7.3L12 3l4 4.3a1 1 0 0 1-.8 1.7H15l3 3.3a1 1 0 0 1-.7 1.7H17Z",key:"cpyugq"}],["path",{d:"M12 22v-3",key:"kmzjlo"}]]);const zo=fe("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Yg=fe("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);const Jg=fe("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);const jd=fe("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);const yr=fe("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Xg="modulepreload",Zg=function(t){return"/"+t},Di={},_=function(e,n,r){let o=Promise.resolve();if(n&&n.length>0){let c=function(d){return Promise.all(d.map(p=>Promise.resolve(p).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),l=i?.nonce||i?.getAttribute("nonce");o=c(n.map(d=>{if(d=Zg(d),d in Di)return;Di[d]=!0;const p=d.endsWith(".css"),m=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${m}`))return;const h=document.createElement("link");if(h.rel=p?"stylesheet":Xg,p||(h.as="script"),h.crossOrigin="",h.href=d,l&&h.setAttribute("nonce",l),document.head.appendChild(h),p)return new Promise((g,f)=>{h.addEventListener("load",g),h.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${d}`)))})}))}function a(i){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=i,window.dispatchEvent(l),!l.defaultPrevented)throw i}return o.then(i=>{for(const l of i||[])l.status==="rejected"&&a(l.reason);return e().catch(a)})};let Ve=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function ex(t){return Pa(t)}function Pa(t){return Array.isArray(t)?tx(t):t instanceof RegExp?t:typeof t=="object"?sx(t):t}function tx(t){let e=[];for(let n=0,r=t.length;n<r;n++)e[n]=Pa(t[n]);return e}function sx(t){let e={};for(let n in t)e[n]=Pa(t[n]);return e}function Nd(t,...e){return e.forEach(n=>{for(let r in n)t[r]=n[r]}),t}function Sd(t){const e=~t.lastIndexOf("/")||~t.lastIndexOf("\\");return e===0?t:~e===t.length-1?Sd(t.substring(0,t.length-1)):t.substr(~e+1)}var Qr=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Cn=class{static hasCaptures(t){return t===null?!1:(Qr.lastIndex=0,Qr.test(t))}static replaceCaptures(t,e,n){return t.replace(Qr,(r,o,a,i)=>{let l=n[parseInt(o||a,10)];if(l){let c=e.substring(l.start,l.end);for(;c[0]===".";)c=c.substring(1);switch(i){case"downcase":return c.toLowerCase();case"upcase":return c.toUpperCase();default:return c}}else return r})}};function Cd(t,e){return t<e?-1:t>e?1:0}function Ed(t,e){if(t===null&&e===null)return 0;if(!t)return-1;if(!e)return 1;let n=t.length,r=e.length;if(n===r){for(let o=0;o<n;o++){let a=Cd(t[o],e[o]);if(a!==0)return a}return 0}return n-r}function $i(t){return!!(/^#[0-9a-f]{6}$/i.test(t)||/^#[0-9a-f]{8}$/i.test(t)||/^#[0-9a-f]{3}$/i.test(t)||/^#[0-9a-f]{4}$/i.test(t))}function Td(t){return t.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Id=class{constructor(t){this.fn=t}cache=new Map;get(t){if(this.cache.has(t))return this.cache.get(t);const e=this.fn(t);return this.cache.set(t,e),e}},Jn=class{constructor(t,e,n){this._colorMap=t,this._defaults=e,this._root=n}static createFromRawTheme(t,e){return this.createFromParsedTheme(ox(t),e)}static createFromParsedTheme(t,e){return ix(t,e)}_cachedMatchRoot=new Id(t=>this._root.match(t));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(t){if(t===null)return this._defaults;const e=t.scopeName,r=this._cachedMatchRoot.get(e).find(o=>nx(t.parent,o.parentScopes));return r?new Ad(r.fontStyle,r.foreground,r.background):null}},Yr=class Un{constructor(e,n){this.parent=e,this.scopeName=n}static push(e,n){for(const r of n)e=new Un(e,r);return e}static from(...e){let n=null;for(let r=0;r<e.length;r++)n=new Un(n,e[r]);return n}push(e){return new Un(this,e)}getSegments(){let e=this;const n=[];for(;e;)n.push(e.scopeName),e=e.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(e){return this===e?!0:this.parent===null?!1:this.parent.extends(e)}getExtensionIfDefined(e){const n=[];let r=this;for(;r&&r!==e;)n.push(r.scopeName),r=r.parent;return r===e?n.reverse():void 0}};function nx(t,e){if(e.length===0)return!0;for(let n=0;n<e.length;n++){let r=e[n],o=!1;if(r===">"){if(n===e.length-1)return!1;r=e[++n],o=!0}for(;t&&!rx(t.scopeName,r);){if(o)return!1;t=t.parent}if(!t)return!1;t=t.parent}return!0}function rx(t,e){return e===t||t.startsWith(e)&&t[e.length]==="."}var Ad=class{constructor(t,e,n){this.fontStyle=t,this.foregroundId=e,this.backgroundId=n}};function ox(t){if(!t)return[];if(!t.settings||!Array.isArray(t.settings))return[];let e=t.settings,n=[],r=0;for(let o=0,a=e.length;o<a;o++){let i=e[o];if(!i.settings)continue;let l;if(typeof i.scope=="string"){let m=i.scope;m=m.replace(/^[,]+/,""),m=m.replace(/[,]+$/,""),l=m.split(",")}else Array.isArray(i.scope)?l=i.scope:l=[""];let c=-1;if(typeof i.settings.fontStyle=="string"){c=0;let m=i.settings.fontStyle.split(" ");for(let h=0,g=m.length;h<g;h++)switch(m[h]){case"italic":c=c|1;break;case"bold":c=c|2;break;case"underline":c=c|4;break;case"strikethrough":c=c|8;break}}let d=null;typeof i.settings.foreground=="string"&&$i(i.settings.foreground)&&(d=i.settings.foreground);let p=null;typeof i.settings.background=="string"&&$i(i.settings.background)&&(p=i.settings.background);for(let m=0,h=l.length;m<h;m++){let f=l[m].trim().split(" "),x=f[f.length-1],b=null;f.length>1&&(b=f.slice(0,f.length-1),b.reverse()),n[r++]=new ax(x,b,o,c,d,p)}}return n}var ax=class{constructor(t,e,n,r,o,a){this.scope=t,this.parentScopes=e,this.index=n,this.fontStyle=r,this.foreground=o,this.background=a}},tt=(t=>(t[t.NotSet=-1]="NotSet",t[t.None=0]="None",t[t.Italic=1]="Italic",t[t.Bold=2]="Bold",t[t.Underline=4]="Underline",t[t.Strikethrough=8]="Strikethrough",t))(tt||{});function ix(t,e){t.sort((c,d)=>{let p=Cd(c.scope,d.scope);return p!==0||(p=Ed(c.parentScopes,d.parentScopes),p!==0)?p:c.index-d.index});let n=0,r="#000000",o="#ffffff";for(;t.length>=1&&t[0].scope==="";){let c=t.shift();c.fontStyle!==-1&&(n=c.fontStyle),c.foreground!==null&&(r=c.foreground),c.background!==null&&(o=c.background)}let a=new cx(e),i=new Ad(n,a.getId(r),a.getId(o)),l=new dx(new Fo(0,null,-1,0,0),[]);for(let c=0,d=t.length;c<d;c++){let p=t[c];l.insert(0,p.scope,p.parentScopes,p.fontStyle,a.getId(p.foreground),a.getId(p.background))}return new Jn(a,i,l)}var cx=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(t){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(t)){this._isFrozen=!0;for(let e=0,n=t.length;e<n;e++)this._color2id[t[e]]=e,this._id2color[e]=t[e]}else this._isFrozen=!1}getId(t){if(t===null)return 0;t=t.toUpperCase();let e=this._color2id[t];if(e)return e;if(this._isFrozen)throw new Error(`Missing color in color map - ${t}`);return e=++this._lastColorId,this._color2id[t]=e,this._id2color[e]=t,e}getColorMap(){return this._id2color.slice(0)}},lx=Object.freeze([]),Fo=class Rd{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,n,r,o,a){this.scopeDepth=e,this.parentScopes=n||lx,this.fontStyle=r,this.foreground=o,this.background=a}clone(){return new Rd(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let n=[];for(let r=0,o=e.length;r<o;r++)n[r]=e[r].clone();return n}acceptOverwrite(e,n,r,o){this.scopeDepth>e?console.log("how did this happen?"):this.scopeDepth=e,n!==-1&&(this.fontStyle=n),r!==0&&(this.foreground=r),o!==0&&(this.background=o)}},dx=class Vo{constructor(e,n=[],r={}){this._mainRule=e,this._children=r,this._rulesWithParentScopes=n}_rulesWithParentScopes;static _cmpBySpecificity(e,n){if(e.scopeDepth!==n.scopeDepth)return n.scopeDepth-e.scopeDepth;let r=0,o=0;for(;e.parentScopes[r]===">"&&r++,n.parentScopes[o]===">"&&o++,!(r>=e.parentScopes.length||o>=n.parentScopes.length);){const a=n.parentScopes[o].length-e.parentScopes[r].length;if(a!==0)return a;r++,o++}return n.parentScopes.length-e.parentScopes.length}match(e){if(e!==""){let r=e.indexOf("."),o,a;if(r===-1?(o=e,a=""):(o=e.substring(0,r),a=e.substring(r+1)),this._children.hasOwnProperty(o))return this._children[o].match(a)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(Vo._cmpBySpecificity),n}insert(e,n,r,o,a,i){if(n===""){this._doInsertHere(e,r,o,a,i);return}let l=n.indexOf("."),c,d;l===-1?(c=n,d=""):(c=n.substring(0,l),d=n.substring(l+1));let p;this._children.hasOwnProperty(c)?p=this._children[c]:(p=new Vo(this._mainRule.clone(),Fo.cloneArr(this._rulesWithParentScopes)),this._children[c]=p),p.insert(e+1,d,r,o,a,i)}_doInsertHere(e,n,r,o,a){if(n===null){this._mainRule.acceptOverwrite(e,r,o,a);return}for(let i=0,l=this._rulesWithParentScopes.length;i<l;i++){let c=this._rulesWithParentScopes[i];if(Ed(c.parentScopes,n)===0){c.acceptOverwrite(e,r,o,a);return}}r===-1&&(r=this._mainRule.fontStyle),o===0&&(o=this._mainRule.foreground),a===0&&(a=this._mainRule.background),this._rulesWithParentScopes.push(new Fo(e,n,r,o,a))}},Ts=class lt{static toBinaryStr(e){return e.toString(2).padStart(32,"0")}static print(e){const n=lt.getLanguageId(e),r=lt.getTokenType(e),o=lt.getFontStyle(e),a=lt.getForeground(e),i=lt.getBackground(e);console.log({languageId:n,tokenType:r,fontStyle:o,foreground:a,background:i})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!==0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(e,n,r,o,a,i,l){let c=lt.getLanguageId(e),d=lt.getTokenType(e),p=lt.containsBalancedBrackets(e)?1:0,m=lt.getFontStyle(e),h=lt.getForeground(e),g=lt.getBackground(e);return n!==0&&(c=n),r!==8&&(d=r),o!==null&&(p=o?1:0),a!==-1&&(m=a),i!==0&&(h=i),l!==0&&(g=l),(c<<0|d<<8|p<<10|m<<11|h<<15|g<<24)>>>0}};function Xn(t,e){const n=[],r=ux(t);let o=r.next();for(;o!==null;){let c=0;if(o.length===2&&o.charAt(1)===":"){switch(o.charAt(0)){case"R":c=1;break;case"L":c=-1;break;default:console.log(`Unknown priority ${o} in scope selector`)}o=r.next()}let d=i();if(n.push({matcher:d,priority:c}),o!==",")break;o=r.next()}return n;function a(){if(o==="-"){o=r.next();const c=a();return d=>!!c&&!c(d)}if(o==="("){o=r.next();const c=l();return o===")"&&(o=r.next()),c}if(zi(o)){const c=[];do c.push(o),o=r.next();while(zi(o));return d=>e(c,d)}return null}function i(){const c=[];let d=a();for(;d;)c.push(d),d=a();return p=>c.every(m=>m(p))}function l(){const c=[];let d=i();for(;d&&(c.push(d),o==="|"||o===",");){do o=r.next();while(o==="|"||o===",");d=i()}return p=>c.some(m=>m(p))}}function zi(t){return!!t&&!!t.match(/[\w\.:]+/)}function ux(t){let e=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=e.exec(t);return{next:()=>{if(!n)return null;const r=n[0];return n=e.exec(t),r}}}function Pd(t){typeof t.dispose=="function"&&t.dispose()}var on=class{constructor(t){this.scopeName=t}toKey(){return this.scopeName}},px=class{constructor(t,e){this.scopeName=t,this.ruleName=e}toKey(){return`${this.scopeName}#${this.ruleName}`}},mx=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(t){const e=t.toKey();this._seenReferenceKeys.has(e)||(this._seenReferenceKeys.add(e),this._references.push(t))}},hx=class{constructor(t,e){this.repo=t,this.initialScopeName=e,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new on(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){const t=this.Q;this.Q=[];const e=new mx;for(const n of t)fx(n,this.initialScopeName,this.repo,e);for(const n of e.references)if(n instanceof on){if(this.seenFullScopeRequests.has(n.scopeName))continue;this.seenFullScopeRequests.add(n.scopeName),this.Q.push(n)}else{if(this.seenFullScopeRequests.has(n.scopeName)||this.seenPartialScopeRequests.has(n.toKey()))continue;this.seenPartialScopeRequests.add(n.toKey()),this.Q.push(n)}}};function fx(t,e,n,r){const o=n.lookup(t.scopeName);if(!o){if(t.scopeName===e)throw new Error(`No grammar provided for <${e}>`);return}const a=n.lookup(e);t instanceof on?Gn({baseGrammar:a,selfGrammar:o},r):Bo(t.ruleName,{baseGrammar:a,selfGrammar:o,repository:o.repository},r);const i=n.injections(t.scopeName);if(i)for(const l of i)r.add(new on(l))}function Bo(t,e,n){if(e.repository&&e.repository[t]){const r=e.repository[t];Zn([r],e,n)}}function Gn(t,e){t.selfGrammar.patterns&&Array.isArray(t.selfGrammar.patterns)&&Zn(t.selfGrammar.patterns,{...t,repository:t.selfGrammar.repository},e),t.selfGrammar.injections&&Zn(Object.values(t.selfGrammar.injections),{...t,repository:t.selfGrammar.repository},e)}function Zn(t,e,n){for(const r of t){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const o=r.repository?Nd({},e.repository,r.repository):e.repository;Array.isArray(r.patterns)&&Zn(r.patterns,{...e,repository:o},n);const a=r.include;if(!a)continue;const i=Md(a);switch(i.kind){case 0:Gn({...e,selfGrammar:e.baseGrammar},n);break;case 1:Gn(e,n);break;case 2:Bo(i.ruleName,{...e,repository:o},n);break;case 3:case 4:const l=i.scopeName===e.selfGrammar.scopeName?e.selfGrammar:i.scopeName===e.baseGrammar.scopeName?e.baseGrammar:void 0;if(l){const c={baseGrammar:e.baseGrammar,selfGrammar:l,repository:o};i.kind===4?Bo(i.ruleName,c,n):Gn(c,n)}else i.kind===4?n.add(new px(i.scopeName,i.ruleName)):n.add(new on(i.scopeName));break}}}var gx=class{kind=0},xx=class{kind=1},bx=class{constructor(t){this.ruleName=t}kind=2},yx=class{constructor(t){this.scopeName=t}kind=3},vx=class{constructor(t,e){this.scopeName=t,this.ruleName=e}kind=4};function Md(t){if(t==="$base")return new gx;if(t==="$self")return new xx;const e=t.indexOf("#");if(e===-1)return new yx(t);if(e===0)return new bx(t.substring(1));{const n=t.substring(0,e),r=t.substring(e+1);return new vx(n,r)}}var wx=/\\(\d+)/,Fi=/\\(\d+)/g,_x=-1,Ld=-2;var fn=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(t,e,n,r){this.$location=t,this.id=e,this._name=n||null,this._nameIsCapturing=Cn.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=Cn.hasCaptures(this._contentName)}get debugName(){const t=this.$location?`${Sd(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${t}`}getName(t,e){return!this._nameIsCapturing||this._name===null||t===null||e===null?this._name:Cn.replaceCaptures(this._name,t,e)}getContentName(t,e){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Cn.replaceCaptures(this._contentName,t,e)}},kx=class extends fn{retokenizeCapturedWithRuleId;constructor(t,e,n,r,o){super(t,e,n,r),this.retokenizeCapturedWithRuleId=o}dispose(){}collectPatterns(t,e){throw new Error("Not supported!")}compile(t,e){throw new Error("Not supported!")}compileAG(t,e,n,r){throw new Error("Not supported!")}},jx=class extends fn{_match;captures;_cachedCompiledPatterns;constructor(t,e,n,r,o){super(t,e,n,null),this._match=new an(r,this.id),this.captures=o,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(t,e){e.push(this._match)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new cn,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Vi=class extends fn{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(t,e,n,r,o){super(t,e,n,r),this.patterns=o.patterns,this.hasMissingPatterns=o.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(t,e){for(const n of this.patterns)t.getRule(n).collectPatterns(t,e)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new cn,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Uo=class extends fn{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(t,e,n,r,o,a,i,l,c,d){super(t,e,n,r),this._begin=new an(o,this.id),this.beginCaptures=a,this._end=new an(i||"",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=l,this.applyEndPatternLast=c||!1,this.patterns=d.patterns,this.hasMissingPatterns=d.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(t,e){return this._end.resolveBackReferences(t,e)}collectPatterns(t,e){e.push(this._begin)}compile(t,e){return this._getCachedCompiledPatterns(t,e).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t,e).compileAG(t,n,r)}_getCachedCompiledPatterns(t,e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new cn;for(const n of this.patterns)t.getRule(n).collectPatterns(t,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,e):this._cachedCompiledPatterns.setSource(0,e)),this._cachedCompiledPatterns}},er=class extends fn{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(t,e,n,r,o,a,i,l,c){super(t,e,n,r),this._begin=new an(o,this.id),this.beginCaptures=a,this.whileCaptures=l,this._while=new an(i,Ld),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(t,e){return this._while.resolveBackReferences(t,e)}collectPatterns(t,e){e.push(this._begin)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new cn;for(const e of this.patterns)t.getRule(e).collectPatterns(t,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(t,e){return this._getCachedCompiledWhilePatterns(t,e).compile(t)}compileWhileAG(t,e,n,r){return this._getCachedCompiledWhilePatterns(t,e).compileAG(t,n,r)}_getCachedCompiledWhilePatterns(t,e){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new cn,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,e||""),this._cachedCompiledWhilePatterns}},Od=class Ze{static createCaptureRule(e,n,r,o,a){return e.registerRule(i=>new kx(n,i,r,o,a))}static getCompiledRuleId(e,n,r){return e.id||n.registerRule(o=>{if(e.id=o,e.match)return new jx(e.$vscodeTextmateLocation,e.id,e.name,e.match,Ze._compileCaptures(e.captures,n,r));if(typeof e.begin>"u"){e.repository&&(r=Nd({},r,e.repository));let a=e.patterns;return typeof a>"u"&&e.include&&(a=[{include:e.include}]),new Vi(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,Ze._compilePatterns(a,n,r))}return e.while?new er(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,Ze._compileCaptures(e.beginCaptures||e.captures,n,r),e.while,Ze._compileCaptures(e.whileCaptures||e.captures,n,r),Ze._compilePatterns(e.patterns,n,r)):new Uo(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,Ze._compileCaptures(e.beginCaptures||e.captures,n,r),e.end,Ze._compileCaptures(e.endCaptures||e.captures,n,r),e.applyEndPatternLast,Ze._compilePatterns(e.patterns,n,r))}),e.id}static _compileCaptures(e,n,r){let o=[];if(e){let a=0;for(const i in e){if(i==="$vscodeTextmateLocation")continue;const l=parseInt(i,10);l>a&&(a=l)}for(let i=0;i<=a;i++)o[i]=null;for(const i in e){if(i==="$vscodeTextmateLocation")continue;const l=parseInt(i,10);let c=0;e[i].patterns&&(c=Ze.getCompiledRuleId(e[i],n,r)),o[l]=Ze.createCaptureRule(n,e[i].$vscodeTextmateLocation,e[i].name,e[i].contentName,c)}}return o}static _compilePatterns(e,n,r){let o=[];if(e)for(let a=0,i=e.length;a<i;a++){const l=e[a];let c=-1;if(l.include){const d=Md(l.include);switch(d.kind){case 0:case 1:c=Ze.getCompiledRuleId(r[l.include],n,r);break;case 2:let p=r[d.ruleName];p&&(c=Ze.getCompiledRuleId(p,n,r));break;case 3:case 4:const m=d.scopeName,h=d.kind===4?d.ruleName:null,g=n.getExternalGrammar(m,r);if(g)if(h){let f=g.repository[h];f&&(c=Ze.getCompiledRuleId(f,n,g.repository))}else c=Ze.getCompiledRuleId(g.repository.$self,n,g.repository);break}}else c=Ze.getCompiledRuleId(l,n,r);if(c!==-1){const d=n.getRule(c);let p=!1;if((d instanceof Vi||d instanceof Uo||d instanceof er)&&d.hasMissingPatterns&&d.patterns.length===0&&(p=!0),p)continue;o.push(c)}}return{patterns:o,hasMissingPatterns:(e?e.length:0)!==o.length}}},an=class Dd{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,n){if(e&&typeof e=="string"){const r=e.length;let o=0,a=[],i=!1;for(let l=0;l<r;l++)if(e.charAt(l)==="\\"&&l+1<r){const d=e.charAt(l+1);d==="z"?(a.push(e.substring(o,l)),a.push("$(?!\\n)(?<!\\n)"),o=l+2):(d==="A"||d==="G")&&(i=!0),l++}this.hasAnchor=i,o===0?this.source=e:(a.push(e.substring(o,r)),this.source=a.join(""))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=wx.test(this.source):this.hasBackReferences=!1}clone(){return new Dd(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,n){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let r=n.map(o=>e.substring(o.start,o.end));return Fi.lastIndex=0,this.source.replace(Fi,(o,a)=>Td(r[parseInt(a,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let e=[],n=[],r=[],o=[],a,i,l,c;for(a=0,i=this.source.length;a<i;a++)l=this.source.charAt(a),e[a]=l,n[a]=l,r[a]=l,o[a]=l,l==="\\"&&a+1<i&&(c=this.source.charAt(a+1),c==="A"?(e[a+1]="",n[a+1]="",r[a+1]="A",o[a+1]="A"):c==="G"?(e[a+1]="",n[a+1]="G",r[a+1]="",o[a+1]="G"):(e[a+1]=c,n[a+1]=c,r[a+1]=c,o[a+1]=c),a++);return{A0_G0:e.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:o.join("")}}resolveAnchors(e,n){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:e?n?this._anchorCache.A1_G1:this._anchorCache.A1_G0:n?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},cn=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(t){this._items.push(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}unshift(t){this._items.unshift(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}length(){return this._items.length}setSource(t,e){this._items[t].source!==e&&(this._disposeCaches(),this._items[t].setSource(e))}compile(t){if(!this._cached){let e=this._items.map(n=>n.source);this._cached=new Bi(t,e,this._items.map(n=>n.ruleId))}return this._cached}compileAG(t,e,n){return this._hasAnchors?e?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(t,e,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(t,e,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(t,e,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(t,e,n)),this._anchorCache.A0_G0):this.compile(t)}_resolveAnchors(t,e,n){let r=this._items.map(o=>o.resolveAnchors(e,n));return new Bi(t,r,this._items.map(o=>o.ruleId))}},Bi=class{constructor(t,e,n){this.regExps=e,this.rules=n,this.scanner=t.createOnigScanner(e)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const t=[];for(let e=0,n=this.rules.length;e<n;e++)t.push(" - "+this.rules[e]+": "+this.regExps[e]);return t.join(`
|
|
21
|
+
[&_code]:text-[12px] [&_code]:bg-parchment-200 dark:[&_code]:bg-zinc-800/50 [&_code]:px-1 [&_code]:rounded`;function R(...t){return md(Na(t))}const hg={".js":"javascript",".jsx":"jsx",".ts":"typescript",".tsx":"tsx",".mjs":"javascript",".cjs":"javascript",".py":"python",".pyw":"python",".pyi":"python",".html":"html",".htm":"html",".xml":"xml",".css":"css",".scss":"scss",".sass":"sass",".less":"less",".json":"json",".yaml":"yaml",".yml":"yaml",".toml":"toml",".ini":"ini",".sh":"bash",".bash":"bash",".zsh":"bash",".fish":"bash",".c":"c",".h":"c",".cpp":"cpp",".cc":"cpp",".cxx":"cpp",".hpp":"cpp",".hxx":"cpp",".java":"java",".kt":"kotlin",".kts":"kotlin",".go":"go",".rs":"rust",".rb":"ruby",".rake":"ruby",".php":"php",".phtml":"php",".swift":"swift",".mm":"objectivec",".cs":"csharp",".sql":"sql",".md":"markdown",".markdown":"markdown",".dockerfile":"dockerfile",".makefile":"makefile",".mk":"makefile",".vim":"vim",".vimrc":"vim",".lua":"lua",".r":"r",".R":"r",".scala":"scala",".sc":"scala",".clj":"clojure",".cljs":"clojure",".cljc":"clojure",".hs":"haskell",".lhs":"haskell",".ex":"elixir",".exs":"elixir",".erl":"erlang",".hrl":"erlang",".ml":"ocaml",".mli":"ocaml",".fs":"fsharp",".fsi":"fsharp",".fsx":"fsharp",".dart":"dart",".pl":"perl",".pm":"perl",".groovy":"groovy",".gradle":"groovy",".tex":"latex",".latex":"latex",".m":"matlab",".mat":"matlab",".ps1":"powershell",".psm1":"powershell",".psd1":"powershell",".asm":"asm",".s":"asm",".glsl":"glsl",".vert":"glsl",".frag":"glsl",".graphql":"graphql",".gql":"graphql",".prisma":"prisma",".sol":"solidity",".vue":"vue",".svelte":"svelte",".nix":"nix",".jl":"julia",".zig":"zig",".cr":"crystal",".nim":"nim",".nims":"nim",".d":"d",".di":"d",".pas":"pascal",".pp":"pascal",".inc":"pascal",".f":"fortran",".for":"fortran",".f90":"fortran",".f95":"fortran",".pro":"prolog",".P":"prolog",".scm":"scheme",".ss":"scheme",".rkt":"racket",".lisp":"lisp",".lsp":"lisp",".cl":"lisp",".tcl":"tcl",".awk":"awk",".vhd":"vhdl",".vhdl":"vhdl",".v":"verilog",".vh":"verilog",".sv":"verilog",".wat":"wasm",".wast":"wasm"},Mi={Dockerfile:"dockerfile",Makefile:"makefile",Rakefile:"ruby",Gemfile:"ruby",".gitignore":"gitignore",".gitattributes":"gitignore",".npmignore":"gitignore",".dockerignore":"gitignore",".env":"bash",".bashrc":"bash",".zshrc":"bash",".bash_profile":"bash",".profile":"bash","nginx.conf":"nginx","httpd.conf":"apache",".htaccess":"apache"};function fr(t){if(!t)return"text";const e=t.split("/"),n=e[e.length-1];if(Mi[n])return Mi[n];const r=n.lastIndexOf(".");if(r===-1||r===0)return"text";const o=n.slice(r).toLowerCase();return hg[o]||"text"}function Ia(t){return JSON.parse(t)}function Ns(t,e){if(!t)return t;if(e&&t.startsWith(e)){const r=t.slice(e.length),o=r.startsWith("/")?r.slice(1):r;return o?`./${o}`:"./"}const n=["/home/","/Users/"];for(const r of n)if(t.startsWith(r))return`~${t.slice(r.length-1)}`;return t}function Aa(t){if(!t)return 0;const e=(t.match(/\n/g)||[]).length;return t.length>0?e+1:0}function fg(t){try{const e=Ia(t);if(Array.isArray(e))return e.filter(n=>n!==null&&typeof n=="object"&&"content"in n&&"status"in n&&typeof n.content=="string"&&typeof n.status=="string")}catch{}return[]}function gd(t){return t.replace(/\n?\[rerun: b\d+\]\s*$/,"")}function sn(t){try{return new URL(t).hostname}catch{return t}}const gg=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),xd=(...t)=>t.filter((e,n,r)=>!!e&&r.indexOf(e)===n).join(" ");var xg={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const bg=u.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:a,iconNode:i,...l},c)=>u.createElement("svg",{ref:c,...xg,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:xd("lucide",o),...l},[...i.map(([d,p])=>u.createElement(d,p)),...Array.isArray(a)?a:[a]]));const ge=(t,e)=>{const n=u.forwardRef(({className:r,...o},a)=>u.createElement(bg,{ref:a,iconNode:e,className:xd(`lucide-${gg(t)}`,r),...o}));return n.displayName=`${t}`,n};const bd=ge("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const yg=ge("AlarmClock",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M12 9v4l2 2",key:"1c63tq"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}]]);const vg=ge("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);const Do=ge("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const nn=ge("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const yd=ge("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const wg=ge("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const _g=ge("Chrome",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["line",{x1:"21.17",x2:"12",y1:"8",y2:"8",key:"a0cw5f"}],["line",{x1:"3.95",x2:"8.54",y1:"6.06",y2:"14",key:"1kftof"}],["line",{x1:"10.88",x2:"15.46",y1:"21.94",y2:"14",key:"1ymyh8"}]]);const gr=ge("CircleCheckBig",[["path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14",key:"g774vq"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);const xr=ge("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const rn=ge("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const br=ge("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const kg=ge("ClipboardCheck",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]]);const vd=ge("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);const jg=ge("Compass",[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const Ng=ge("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);const Sg=ge("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);const Os=ge("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Cg=ge("Eye",[["path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z",key:"rwhkz3"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const Eg=ge("FilePen",[["path",{d:"M12.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v9.5",key:"1couwa"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]]);const Tg=ge("FilePlus",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]);const Ig=ge("FileSearch",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4.268 21a2 2 0 0 0 1.727 1H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"ms7g94"}],["path",{d:"m9 18-1.5-1.5",key:"1j6qii"}],["circle",{cx:"5",cy:"14",r:"3",key:"ufru5t"}]]);const jt=ge("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const Li=ge("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);const Ag=ge("FolderSearch",[["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.5-1.5",key:"3sg1j"}]]);const is=ge("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);const Rg=ge("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);const Ra=ge("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);const Pg=ge("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]]);const Mg=ge("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);const Lg=ge("ListTodo",[["rect",{x:"3",y:"5",width:"6",height:"6",rx:"1",key:"1defrl"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);const wd=ge("List",[["line",{x1:"8",x2:"21",y1:"6",y2:"6",key:"7ey8pc"}],["line",{x1:"8",x2:"21",y1:"12",y2:"12",key:"rjfblc"}],["line",{x1:"8",x2:"21",y1:"18",y2:"18",key:"c3b1m8"}],["line",{x1:"3",x2:"3.01",y1:"6",y2:"6",key:"1g7gq3"}],["line",{x1:"3",x2:"3.01",y1:"12",y2:"12",key:"1pjlvk"}],["line",{x1:"3",x2:"3.01",y1:"18",y2:"18",key:"28t2mc"}]]);const at=ge("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const Og=ge("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);const Dg=ge("MessageCircleQuestion",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const _d=ge("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);const $g=ge("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);const zg=ge("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);const Fg=ge("MousePointer",[["path",{d:"m3 3 7.07 16.97 2.51-7.39 7.39-2.51L3 3z",key:"y2ucgo"}],["path",{d:"m13 13 6 6",key:"1nhxnf"}]]);const Vg=ge("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);const Bg=ge("Paperclip",[["path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48",key:"1u3ebp"}]]);const Ug=ge("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);const kd=ge("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);const Gg=ge("Plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]);const Hg=ge("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const qg=ge("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);const ss=ge("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);const $o=ge("Send",[["path",{d:"m22 2-7 20-4-9-9-4Z",key:"1q3vgg"}],["path",{d:"M22 2 11 13",key:"nzbqef"}]]);const Wg=ge("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);const Kg=ge("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Oi=ge("Star",[["polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2",key:"8f66p6"}]]);const Yn=ge("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);const Qg=ge("TreePine",[["path",{d:"m17 14 3 3.3a1 1 0 0 1-.7 1.7H4.7a1 1 0 0 1-.7-1.7L7 14h-.3a1 1 0 0 1-.7-1.7L9 9h-.2A1 1 0 0 1 8 7.3L12 3l4 4.3a1 1 0 0 1-.8 1.7H15l3 3.3a1 1 0 0 1-.7 1.7H17Z",key:"cpyugq"}],["path",{d:"M12 22v-3",key:"kmzjlo"}]]);const zo=ge("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Yg=ge("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);const Jg=ge("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);const jd=ge("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);const yr=ge("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Xg="modulepreload",Zg=function(t){return"/"+t},Di={},_=function(e,n,r){let o=Promise.resolve();if(n&&n.length>0){let c=function(d){return Promise.all(d.map(p=>Promise.resolve(p).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),l=i?.nonce||i?.getAttribute("nonce");o=c(n.map(d=>{if(d=Zg(d),d in Di)return;Di[d]=!0;const p=d.endsWith(".css"),m=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${m}`))return;const h=document.createElement("link");if(h.rel=p?"stylesheet":Xg,p||(h.as="script"),h.crossOrigin="",h.href=d,l&&h.setAttribute("nonce",l),document.head.appendChild(h),p)return new Promise((g,f)=>{h.addEventListener("load",g),h.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${d}`)))})}))}function a(i){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=i,window.dispatchEvent(l),!l.defaultPrevented)throw i}return o.then(i=>{for(const l of i||[])l.status==="rejected"&&a(l.reason);return e().catch(a)})};let Ve=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function ex(t){return Pa(t)}function Pa(t){return Array.isArray(t)?tx(t):t instanceof RegExp?t:typeof t=="object"?sx(t):t}function tx(t){let e=[];for(let n=0,r=t.length;n<r;n++)e[n]=Pa(t[n]);return e}function sx(t){let e={};for(let n in t)e[n]=Pa(t[n]);return e}function Nd(t,...e){return e.forEach(n=>{for(let r in n)t[r]=n[r]}),t}function Sd(t){const e=~t.lastIndexOf("/")||~t.lastIndexOf("\\");return e===0?t:~e===t.length-1?Sd(t.substring(0,t.length-1)):t.substr(~e+1)}var Qr=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Cn=class{static hasCaptures(t){return t===null?!1:(Qr.lastIndex=0,Qr.test(t))}static replaceCaptures(t,e,n){return t.replace(Qr,(r,o,a,i)=>{let l=n[parseInt(o||a,10)];if(l){let c=e.substring(l.start,l.end);for(;c[0]===".";)c=c.substring(1);switch(i){case"downcase":return c.toLowerCase();case"upcase":return c.toUpperCase();default:return c}}else return r})}};function Cd(t,e){return t<e?-1:t>e?1:0}function Ed(t,e){if(t===null&&e===null)return 0;if(!t)return-1;if(!e)return 1;let n=t.length,r=e.length;if(n===r){for(let o=0;o<n;o++){let a=Cd(t[o],e[o]);if(a!==0)return a}return 0}return n-r}function $i(t){return!!(/^#[0-9a-f]{6}$/i.test(t)||/^#[0-9a-f]{8}$/i.test(t)||/^#[0-9a-f]{3}$/i.test(t)||/^#[0-9a-f]{4}$/i.test(t))}function Td(t){return t.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Id=class{constructor(t){this.fn=t}cache=new Map;get(t){if(this.cache.has(t))return this.cache.get(t);const e=this.fn(t);return this.cache.set(t,e),e}},Jn=class{constructor(t,e,n){this._colorMap=t,this._defaults=e,this._root=n}static createFromRawTheme(t,e){return this.createFromParsedTheme(ox(t),e)}static createFromParsedTheme(t,e){return ix(t,e)}_cachedMatchRoot=new Id(t=>this._root.match(t));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(t){if(t===null)return this._defaults;const e=t.scopeName,r=this._cachedMatchRoot.get(e).find(o=>nx(t.parent,o.parentScopes));return r?new Ad(r.fontStyle,r.foreground,r.background):null}},Yr=class Un{constructor(e,n){this.parent=e,this.scopeName=n}static push(e,n){for(const r of n)e=new Un(e,r);return e}static from(...e){let n=null;for(let r=0;r<e.length;r++)n=new Un(n,e[r]);return n}push(e){return new Un(this,e)}getSegments(){let e=this;const n=[];for(;e;)n.push(e.scopeName),e=e.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(e){return this===e?!0:this.parent===null?!1:this.parent.extends(e)}getExtensionIfDefined(e){const n=[];let r=this;for(;r&&r!==e;)n.push(r.scopeName),r=r.parent;return r===e?n.reverse():void 0}};function nx(t,e){if(e.length===0)return!0;for(let n=0;n<e.length;n++){let r=e[n],o=!1;if(r===">"){if(n===e.length-1)return!1;r=e[++n],o=!0}for(;t&&!rx(t.scopeName,r);){if(o)return!1;t=t.parent}if(!t)return!1;t=t.parent}return!0}function rx(t,e){return e===t||t.startsWith(e)&&t[e.length]==="."}var Ad=class{constructor(t,e,n){this.fontStyle=t,this.foregroundId=e,this.backgroundId=n}};function ox(t){if(!t)return[];if(!t.settings||!Array.isArray(t.settings))return[];let e=t.settings,n=[],r=0;for(let o=0,a=e.length;o<a;o++){let i=e[o];if(!i.settings)continue;let l;if(typeof i.scope=="string"){let m=i.scope;m=m.replace(/^[,]+/,""),m=m.replace(/[,]+$/,""),l=m.split(",")}else Array.isArray(i.scope)?l=i.scope:l=[""];let c=-1;if(typeof i.settings.fontStyle=="string"){c=0;let m=i.settings.fontStyle.split(" ");for(let h=0,g=m.length;h<g;h++)switch(m[h]){case"italic":c=c|1;break;case"bold":c=c|2;break;case"underline":c=c|4;break;case"strikethrough":c=c|8;break}}let d=null;typeof i.settings.foreground=="string"&&$i(i.settings.foreground)&&(d=i.settings.foreground);let p=null;typeof i.settings.background=="string"&&$i(i.settings.background)&&(p=i.settings.background);for(let m=0,h=l.length;m<h;m++){let f=l[m].trim().split(" "),x=f[f.length-1],b=null;f.length>1&&(b=f.slice(0,f.length-1),b.reverse()),n[r++]=new ax(x,b,o,c,d,p)}}return n}var ax=class{constructor(t,e,n,r,o,a){this.scope=t,this.parentScopes=e,this.index=n,this.fontStyle=r,this.foreground=o,this.background=a}},tt=(t=>(t[t.NotSet=-1]="NotSet",t[t.None=0]="None",t[t.Italic=1]="Italic",t[t.Bold=2]="Bold",t[t.Underline=4]="Underline",t[t.Strikethrough=8]="Strikethrough",t))(tt||{});function ix(t,e){t.sort((c,d)=>{let p=Cd(c.scope,d.scope);return p!==0||(p=Ed(c.parentScopes,d.parentScopes),p!==0)?p:c.index-d.index});let n=0,r="#000000",o="#ffffff";for(;t.length>=1&&t[0].scope==="";){let c=t.shift();c.fontStyle!==-1&&(n=c.fontStyle),c.foreground!==null&&(r=c.foreground),c.background!==null&&(o=c.background)}let a=new cx(e),i=new Ad(n,a.getId(r),a.getId(o)),l=new dx(new Fo(0,null,-1,0,0),[]);for(let c=0,d=t.length;c<d;c++){let p=t[c];l.insert(0,p.scope,p.parentScopes,p.fontStyle,a.getId(p.foreground),a.getId(p.background))}return new Jn(a,i,l)}var cx=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(t){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(t)){this._isFrozen=!0;for(let e=0,n=t.length;e<n;e++)this._color2id[t[e]]=e,this._id2color[e]=t[e]}else this._isFrozen=!1}getId(t){if(t===null)return 0;t=t.toUpperCase();let e=this._color2id[t];if(e)return e;if(this._isFrozen)throw new Error(`Missing color in color map - ${t}`);return e=++this._lastColorId,this._color2id[t]=e,this._id2color[e]=t,e}getColorMap(){return this._id2color.slice(0)}},lx=Object.freeze([]),Fo=class Rd{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,n,r,o,a){this.scopeDepth=e,this.parentScopes=n||lx,this.fontStyle=r,this.foreground=o,this.background=a}clone(){return new Rd(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let n=[];for(let r=0,o=e.length;r<o;r++)n[r]=e[r].clone();return n}acceptOverwrite(e,n,r,o){this.scopeDepth>e?console.log("how did this happen?"):this.scopeDepth=e,n!==-1&&(this.fontStyle=n),r!==0&&(this.foreground=r),o!==0&&(this.background=o)}},dx=class Vo{constructor(e,n=[],r={}){this._mainRule=e,this._children=r,this._rulesWithParentScopes=n}_rulesWithParentScopes;static _cmpBySpecificity(e,n){if(e.scopeDepth!==n.scopeDepth)return n.scopeDepth-e.scopeDepth;let r=0,o=0;for(;e.parentScopes[r]===">"&&r++,n.parentScopes[o]===">"&&o++,!(r>=e.parentScopes.length||o>=n.parentScopes.length);){const a=n.parentScopes[o].length-e.parentScopes[r].length;if(a!==0)return a;r++,o++}return n.parentScopes.length-e.parentScopes.length}match(e){if(e!==""){let r=e.indexOf("."),o,a;if(r===-1?(o=e,a=""):(o=e.substring(0,r),a=e.substring(r+1)),this._children.hasOwnProperty(o))return this._children[o].match(a)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(Vo._cmpBySpecificity),n}insert(e,n,r,o,a,i){if(n===""){this._doInsertHere(e,r,o,a,i);return}let l=n.indexOf("."),c,d;l===-1?(c=n,d=""):(c=n.substring(0,l),d=n.substring(l+1));let p;this._children.hasOwnProperty(c)?p=this._children[c]:(p=new Vo(this._mainRule.clone(),Fo.cloneArr(this._rulesWithParentScopes)),this._children[c]=p),p.insert(e+1,d,r,o,a,i)}_doInsertHere(e,n,r,o,a){if(n===null){this._mainRule.acceptOverwrite(e,r,o,a);return}for(let i=0,l=this._rulesWithParentScopes.length;i<l;i++){let c=this._rulesWithParentScopes[i];if(Ed(c.parentScopes,n)===0){c.acceptOverwrite(e,r,o,a);return}}r===-1&&(r=this._mainRule.fontStyle),o===0&&(o=this._mainRule.foreground),a===0&&(a=this._mainRule.background),this._rulesWithParentScopes.push(new Fo(e,n,r,o,a))}},Ts=class lt{static toBinaryStr(e){return e.toString(2).padStart(32,"0")}static print(e){const n=lt.getLanguageId(e),r=lt.getTokenType(e),o=lt.getFontStyle(e),a=lt.getForeground(e),i=lt.getBackground(e);console.log({languageId:n,tokenType:r,fontStyle:o,foreground:a,background:i})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!==0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(e,n,r,o,a,i,l){let c=lt.getLanguageId(e),d=lt.getTokenType(e),p=lt.containsBalancedBrackets(e)?1:0,m=lt.getFontStyle(e),h=lt.getForeground(e),g=lt.getBackground(e);return n!==0&&(c=n),r!==8&&(d=r),o!==null&&(p=o?1:0),a!==-1&&(m=a),i!==0&&(h=i),l!==0&&(g=l),(c<<0|d<<8|p<<10|m<<11|h<<15|g<<24)>>>0}};function Xn(t,e){const n=[],r=ux(t);let o=r.next();for(;o!==null;){let c=0;if(o.length===2&&o.charAt(1)===":"){switch(o.charAt(0)){case"R":c=1;break;case"L":c=-1;break;default:console.log(`Unknown priority ${o} in scope selector`)}o=r.next()}let d=i();if(n.push({matcher:d,priority:c}),o!==",")break;o=r.next()}return n;function a(){if(o==="-"){o=r.next();const c=a();return d=>!!c&&!c(d)}if(o==="("){o=r.next();const c=l();return o===")"&&(o=r.next()),c}if(zi(o)){const c=[];do c.push(o),o=r.next();while(zi(o));return d=>e(c,d)}return null}function i(){const c=[];let d=a();for(;d;)c.push(d),d=a();return p=>c.every(m=>m(p))}function l(){const c=[];let d=i();for(;d&&(c.push(d),o==="|"||o===",");){do o=r.next();while(o==="|"||o===",");d=i()}return p=>c.some(m=>m(p))}}function zi(t){return!!t&&!!t.match(/[\w\.:]+/)}function ux(t){let e=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=e.exec(t);return{next:()=>{if(!n)return null;const r=n[0];return n=e.exec(t),r}}}function Pd(t){typeof t.dispose=="function"&&t.dispose()}var on=class{constructor(t){this.scopeName=t}toKey(){return this.scopeName}},px=class{constructor(t,e){this.scopeName=t,this.ruleName=e}toKey(){return`${this.scopeName}#${this.ruleName}`}},mx=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(t){const e=t.toKey();this._seenReferenceKeys.has(e)||(this._seenReferenceKeys.add(e),this._references.push(t))}},hx=class{constructor(t,e){this.repo=t,this.initialScopeName=e,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new on(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){const t=this.Q;this.Q=[];const e=new mx;for(const n of t)fx(n,this.initialScopeName,this.repo,e);for(const n of e.references)if(n instanceof on){if(this.seenFullScopeRequests.has(n.scopeName))continue;this.seenFullScopeRequests.add(n.scopeName),this.Q.push(n)}else{if(this.seenFullScopeRequests.has(n.scopeName)||this.seenPartialScopeRequests.has(n.toKey()))continue;this.seenPartialScopeRequests.add(n.toKey()),this.Q.push(n)}}};function fx(t,e,n,r){const o=n.lookup(t.scopeName);if(!o){if(t.scopeName===e)throw new Error(`No grammar provided for <${e}>`);return}const a=n.lookup(e);t instanceof on?Gn({baseGrammar:a,selfGrammar:o},r):Bo(t.ruleName,{baseGrammar:a,selfGrammar:o,repository:o.repository},r);const i=n.injections(t.scopeName);if(i)for(const l of i)r.add(new on(l))}function Bo(t,e,n){if(e.repository&&e.repository[t]){const r=e.repository[t];Zn([r],e,n)}}function Gn(t,e){t.selfGrammar.patterns&&Array.isArray(t.selfGrammar.patterns)&&Zn(t.selfGrammar.patterns,{...t,repository:t.selfGrammar.repository},e),t.selfGrammar.injections&&Zn(Object.values(t.selfGrammar.injections),{...t,repository:t.selfGrammar.repository},e)}function Zn(t,e,n){for(const r of t){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const o=r.repository?Nd({},e.repository,r.repository):e.repository;Array.isArray(r.patterns)&&Zn(r.patterns,{...e,repository:o},n);const a=r.include;if(!a)continue;const i=Md(a);switch(i.kind){case 0:Gn({...e,selfGrammar:e.baseGrammar},n);break;case 1:Gn(e,n);break;case 2:Bo(i.ruleName,{...e,repository:o},n);break;case 3:case 4:const l=i.scopeName===e.selfGrammar.scopeName?e.selfGrammar:i.scopeName===e.baseGrammar.scopeName?e.baseGrammar:void 0;if(l){const c={baseGrammar:e.baseGrammar,selfGrammar:l,repository:o};i.kind===4?Bo(i.ruleName,c,n):Gn(c,n)}else i.kind===4?n.add(new px(i.scopeName,i.ruleName)):n.add(new on(i.scopeName));break}}}var gx=class{kind=0},xx=class{kind=1},bx=class{constructor(t){this.ruleName=t}kind=2},yx=class{constructor(t){this.scopeName=t}kind=3},vx=class{constructor(t,e){this.scopeName=t,this.ruleName=e}kind=4};function Md(t){if(t==="$base")return new gx;if(t==="$self")return new xx;const e=t.indexOf("#");if(e===-1)return new yx(t);if(e===0)return new bx(t.substring(1));{const n=t.substring(0,e),r=t.substring(e+1);return new vx(n,r)}}var wx=/\\(\d+)/,Fi=/\\(\d+)/g,_x=-1,Ld=-2;var fn=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(t,e,n,r){this.$location=t,this.id=e,this._name=n||null,this._nameIsCapturing=Cn.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=Cn.hasCaptures(this._contentName)}get debugName(){const t=this.$location?`${Sd(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${t}`}getName(t,e){return!this._nameIsCapturing||this._name===null||t===null||e===null?this._name:Cn.replaceCaptures(this._name,t,e)}getContentName(t,e){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Cn.replaceCaptures(this._contentName,t,e)}},kx=class extends fn{retokenizeCapturedWithRuleId;constructor(t,e,n,r,o){super(t,e,n,r),this.retokenizeCapturedWithRuleId=o}dispose(){}collectPatterns(t,e){throw new Error("Not supported!")}compile(t,e){throw new Error("Not supported!")}compileAG(t,e,n,r){throw new Error("Not supported!")}},jx=class extends fn{_match;captures;_cachedCompiledPatterns;constructor(t,e,n,r,o){super(t,e,n,null),this._match=new an(r,this.id),this.captures=o,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(t,e){e.push(this._match)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new cn,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Vi=class extends fn{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(t,e,n,r,o){super(t,e,n,r),this.patterns=o.patterns,this.hasMissingPatterns=o.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(t,e){for(const n of this.patterns)t.getRule(n).collectPatterns(t,e)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new cn,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Uo=class extends fn{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(t,e,n,r,o,a,i,l,c,d){super(t,e,n,r),this._begin=new an(o,this.id),this.beginCaptures=a,this._end=new an(i||"",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=l,this.applyEndPatternLast=c||!1,this.patterns=d.patterns,this.hasMissingPatterns=d.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(t,e){return this._end.resolveBackReferences(t,e)}collectPatterns(t,e){e.push(this._begin)}compile(t,e){return this._getCachedCompiledPatterns(t,e).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t,e).compileAG(t,n,r)}_getCachedCompiledPatterns(t,e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new cn;for(const n of this.patterns)t.getRule(n).collectPatterns(t,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,e):this._cachedCompiledPatterns.setSource(0,e)),this._cachedCompiledPatterns}},er=class extends fn{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(t,e,n,r,o,a,i,l,c){super(t,e,n,r),this._begin=new an(o,this.id),this.beginCaptures=a,this.whileCaptures=l,this._while=new an(i,Ld),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(t,e){return this._while.resolveBackReferences(t,e)}collectPatterns(t,e){e.push(this._begin)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new cn;for(const e of this.patterns)t.getRule(e).collectPatterns(t,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(t,e){return this._getCachedCompiledWhilePatterns(t,e).compile(t)}compileWhileAG(t,e,n,r){return this._getCachedCompiledWhilePatterns(t,e).compileAG(t,n,r)}_getCachedCompiledWhilePatterns(t,e){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new cn,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,e||""),this._cachedCompiledWhilePatterns}},Od=class Ze{static createCaptureRule(e,n,r,o,a){return e.registerRule(i=>new kx(n,i,r,o,a))}static getCompiledRuleId(e,n,r){return e.id||n.registerRule(o=>{if(e.id=o,e.match)return new jx(e.$vscodeTextmateLocation,e.id,e.name,e.match,Ze._compileCaptures(e.captures,n,r));if(typeof e.begin>"u"){e.repository&&(r=Nd({},r,e.repository));let a=e.patterns;return typeof a>"u"&&e.include&&(a=[{include:e.include}]),new Vi(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,Ze._compilePatterns(a,n,r))}return e.while?new er(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,Ze._compileCaptures(e.beginCaptures||e.captures,n,r),e.while,Ze._compileCaptures(e.whileCaptures||e.captures,n,r),Ze._compilePatterns(e.patterns,n,r)):new Uo(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,Ze._compileCaptures(e.beginCaptures||e.captures,n,r),e.end,Ze._compileCaptures(e.endCaptures||e.captures,n,r),e.applyEndPatternLast,Ze._compilePatterns(e.patterns,n,r))}),e.id}static _compileCaptures(e,n,r){let o=[];if(e){let a=0;for(const i in e){if(i==="$vscodeTextmateLocation")continue;const l=parseInt(i,10);l>a&&(a=l)}for(let i=0;i<=a;i++)o[i]=null;for(const i in e){if(i==="$vscodeTextmateLocation")continue;const l=parseInt(i,10);let c=0;e[i].patterns&&(c=Ze.getCompiledRuleId(e[i],n,r)),o[l]=Ze.createCaptureRule(n,e[i].$vscodeTextmateLocation,e[i].name,e[i].contentName,c)}}return o}static _compilePatterns(e,n,r){let o=[];if(e)for(let a=0,i=e.length;a<i;a++){const l=e[a];let c=-1;if(l.include){const d=Md(l.include);switch(d.kind){case 0:case 1:c=Ze.getCompiledRuleId(r[l.include],n,r);break;case 2:let p=r[d.ruleName];p&&(c=Ze.getCompiledRuleId(p,n,r));break;case 3:case 4:const m=d.scopeName,h=d.kind===4?d.ruleName:null,g=n.getExternalGrammar(m,r);if(g)if(h){let f=g.repository[h];f&&(c=Ze.getCompiledRuleId(f,n,g.repository))}else c=Ze.getCompiledRuleId(g.repository.$self,n,g.repository);break}}else c=Ze.getCompiledRuleId(l,n,r);if(c!==-1){const d=n.getRule(c);let p=!1;if((d instanceof Vi||d instanceof Uo||d instanceof er)&&d.hasMissingPatterns&&d.patterns.length===0&&(p=!0),p)continue;o.push(c)}}return{patterns:o,hasMissingPatterns:(e?e.length:0)!==o.length}}},an=class Dd{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,n){if(e&&typeof e=="string"){const r=e.length;let o=0,a=[],i=!1;for(let l=0;l<r;l++)if(e.charAt(l)==="\\"&&l+1<r){const d=e.charAt(l+1);d==="z"?(a.push(e.substring(o,l)),a.push("$(?!\\n)(?<!\\n)"),o=l+2):(d==="A"||d==="G")&&(i=!0),l++}this.hasAnchor=i,o===0?this.source=e:(a.push(e.substring(o,r)),this.source=a.join(""))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=wx.test(this.source):this.hasBackReferences=!1}clone(){return new Dd(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,n){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let r=n.map(o=>e.substring(o.start,o.end));return Fi.lastIndex=0,this.source.replace(Fi,(o,a)=>Td(r[parseInt(a,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let e=[],n=[],r=[],o=[],a,i,l,c;for(a=0,i=this.source.length;a<i;a++)l=this.source.charAt(a),e[a]=l,n[a]=l,r[a]=l,o[a]=l,l==="\\"&&a+1<i&&(c=this.source.charAt(a+1),c==="A"?(e[a+1]="",n[a+1]="",r[a+1]="A",o[a+1]="A"):c==="G"?(e[a+1]="",n[a+1]="G",r[a+1]="",o[a+1]="G"):(e[a+1]=c,n[a+1]=c,r[a+1]=c,o[a+1]=c),a++);return{A0_G0:e.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:o.join("")}}resolveAnchors(e,n){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:e?n?this._anchorCache.A1_G1:this._anchorCache.A1_G0:n?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},cn=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(t){this._items.push(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}unshift(t){this._items.unshift(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}length(){return this._items.length}setSource(t,e){this._items[t].source!==e&&(this._disposeCaches(),this._items[t].setSource(e))}compile(t){if(!this._cached){let e=this._items.map(n=>n.source);this._cached=new Bi(t,e,this._items.map(n=>n.ruleId))}return this._cached}compileAG(t,e,n){return this._hasAnchors?e?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(t,e,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(t,e,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(t,e,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(t,e,n)),this._anchorCache.A0_G0):this.compile(t)}_resolveAnchors(t,e,n){let r=this._items.map(o=>o.resolveAnchors(e,n));return new Bi(t,r,this._items.map(o=>o.ruleId))}},Bi=class{constructor(t,e,n){this.regExps=e,this.rules=n,this.scanner=t.createOnigScanner(e)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const t=[];for(let e=0,n=this.rules.length;e<n;e++)t.push(" - "+this.rules[e]+": "+this.regExps[e]);return t.join(`
|
|
22
22
|
`)}findNextMatchSync(t,e,n){const r=this.scanner.findNextMatchSync(t,e,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},Jr=class{constructor(t,e){this.languageId=t,this.tokenType=e}},Nx=class Go{_defaultAttributes;_embeddedLanguagesMatcher;constructor(e,n){this._defaultAttributes=new Jr(e,8),this._embeddedLanguagesMatcher=new Sx(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(e){return e===null?Go._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(e)}static _NULL_SCOPE_METADATA=new Jr(0,0);_getBasicScopeAttributes=new Id(e=>{const n=this._scopeToLanguage(e),r=this._toStandardTokenType(e);return new Jr(n,r)});_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(e){const n=e.match(Go.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},Sx=class{values;scopesRegExp;constructor(t){if(t.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(t);const e=t.map(([n,r])=>Td(n));e.sort(),e.reverse(),this.scopesRegExp=new RegExp(`^((${e.join(")|(")}))($|\\.)`,"")}}match(t){if(!this.scopesRegExp)return;const e=t.match(this.scopesRegExp);if(e)return this.values.get(e[1])}},Ui=class{constructor(t,e){this.stack=t,this.stoppedEarly=e}};function $d(t,e,n,r,o,a,i,l){const c=e.content.length;let d=!1,p=-1;if(i){const g=Cx(t,e,n,r,o,a);o=g.stack,r=g.linePos,n=g.isFirstLine,p=g.anchorPosition}const m=Date.now();for(;!d;){if(l!==0&&Date.now()-m>l)return new Ui(o,!0);h()}return new Ui(o,!1);function h(){const g=Ex(t,e,n,r,o,p);if(!g){a.produce(o,c),d=!0;return}const f=g.captureIndices,x=g.matchedRuleId,b=f&&f.length>0?f[0].end>r:!1;if(x===_x){const y=o.getRule(t);a.produce(o,f[0].start),o=o.withContentNameScopesList(o.nameScopesList),Qs(t,e,n,o,a,y.endCaptures,f),a.produce(o,f[0].end);const v=o;if(o=o.parent,p=v.getAnchorPos(),!b&&v.getEnterPos()===r){o=v,a.produce(o,c),d=!0;return}}else{const y=t.getRule(x);a.produce(o,f[0].start);const v=o,w=y.getName(e.content,f),N=o.contentNameScopesList.pushAttributed(w,t);if(o=o.push(x,r,p,f[0].end===c,null,N,N),y instanceof Uo){const S=y;Qs(t,e,n,o,a,S.beginCaptures,f),a.produce(o,f[0].end),p=f[0].end;const T=S.getContentName(e.content,f),C=N.pushAttributed(T,t);if(o=o.withContentNameScopesList(C),S.endHasBackReferences&&(o=o.withEndRule(S.getEndWithResolvedBackReferences(e.content,f))),!b&&v.hasSameRuleAs(o)){o=o.pop(),a.produce(o,c),d=!0;return}}else if(y instanceof er){const S=y;Qs(t,e,n,o,a,S.beginCaptures,f),a.produce(o,f[0].end),p=f[0].end;const T=S.getContentName(e.content,f),C=N.pushAttributed(T,t);if(o=o.withContentNameScopesList(C),S.whileHasBackReferences&&(o=o.withEndRule(S.getWhileWithResolvedBackReferences(e.content,f))),!b&&v.hasSameRuleAs(o)){o=o.pop(),a.produce(o,c),d=!0;return}}else if(Qs(t,e,n,o,a,y.captures,f),a.produce(o,f[0].end),o=o.pop(),!b){o=o.safePop(),a.produce(o,c),d=!0;return}}f[0].end>r&&(r=f[0].end,n=!1)}}function Cx(t,e,n,r,o,a){let i=o.beginRuleCapturedEOL?0:-1;const l=[];for(let c=o;c;c=c.pop()){const d=c.getRule(t);d instanceof er&&l.push({rule:d,stack:c})}for(let c=l.pop();c;c=l.pop()){const{ruleScanner:d,findOptions:p}=Ax(c.rule,t,c.stack.endRule,n,r===i),m=d.findNextMatchSync(e,r,p);if(m){if(m.ruleId!==Ld){o=c.stack.pop();break}m.captureIndices&&m.captureIndices.length&&(a.produce(c.stack,m.captureIndices[0].start),Qs(t,e,n,c.stack,a,c.rule.whileCaptures,m.captureIndices),a.produce(c.stack,m.captureIndices[0].end),i=m.captureIndices[0].end,m.captureIndices[0].end>r&&(r=m.captureIndices[0].end,n=!1))}else{o=c.stack.pop();break}}return{stack:o,linePos:r,anchorPosition:i,isFirstLine:n}}function Ex(t,e,n,r,o,a){const i=Tx(t,e,n,r,o,a),l=t.getInjections();if(l.length===0)return i;const c=Ix(l,t,e,n,r,o,a);if(!c)return i;if(!i)return c;const d=i.captureIndices[0].start,p=c.captureIndices[0].start;return p<d||c.priorityMatch&&p===d?c:i}function Tx(t,e,n,r,o,a){const i=o.getRule(t),{ruleScanner:l,findOptions:c}=zd(i,t,o.endRule,n,r===a),d=l.findNextMatchSync(e,r,c);return d?{captureIndices:d.captureIndices,matchedRuleId:d.ruleId}:null}function Ix(t,e,n,r,o,a,i){let l=Number.MAX_VALUE,c=null,d,p=0;const m=a.contentNameScopesList.getScopeNames();for(let h=0,g=t.length;h<g;h++){const f=t[h];if(!f.matcher(m))continue;const x=e.getRule(f.ruleId),{ruleScanner:b,findOptions:y}=zd(x,e,null,r,o===i),v=b.findNextMatchSync(n,o,y);if(!v)continue;const w=v.captureIndices[0].start;if(!(w>=l)&&(l=w,c=v.captureIndices,d=v.ruleId,p=f.priority,l===o))break}return c?{priorityMatch:p===-1,captureIndices:c,matchedRuleId:d}:null}function zd(t,e,n,r,o){return{ruleScanner:t.compileAG(e,n,r,o),findOptions:0}}function Ax(t,e,n,r,o){return{ruleScanner:t.compileWhileAG(e,n,r,o),findOptions:0}}function Qs(t,e,n,r,o,a,i){if(a.length===0)return;const l=e.content,c=Math.min(a.length,i.length),d=[],p=i[0].end;for(let m=0;m<c;m++){const h=a[m];if(h===null)continue;const g=i[m];if(g.length===0)continue;if(g.start>p)break;for(;d.length>0&&d[d.length-1].endPos<=g.start;)o.produceFromScopes(d[d.length-1].scopes,d[d.length-1].endPos),d.pop();if(d.length>0?o.produceFromScopes(d[d.length-1].scopes,g.start):o.produce(r,g.start),h.retokenizeCapturedWithRuleId){const x=h.getName(l,i),b=r.contentNameScopesList.pushAttributed(x,t),y=h.getContentName(l,i),v=b.pushAttributed(y,t),w=r.push(h.retokenizeCapturedWithRuleId,g.start,-1,!1,null,b,v),N=t.createOnigString(l.substring(0,g.end));$d(t,N,n&&g.start===0,g.start,w,o,!1,0),Pd(N);continue}const f=h.getName(l,i);if(f!==null){const b=(d.length>0?d[d.length-1].scopes:r.contentNameScopesList).pushAttributed(f,t);d.push(new Rx(b,g.end))}}for(;d.length>0;)o.produceFromScopes(d[d.length-1].scopes,d[d.length-1].endPos),d.pop()}var Rx=class{scopes;endPos;constructor(t,e){this.scopes=t,this.endPos=e}};function Px(t,e,n,r,o,a,i,l){return new Lx(t,e,n,r,o,a,i,l)}function Gi(t,e,n,r,o){const a=Xn(e,tr),i=Od.getCompiledRuleId(n,r,o.repository);for(const l of a)t.push({debugSelector:e,matcher:l.matcher,ruleId:i,grammar:o,priority:l.priority})}function tr(t,e){if(e.length<t.length)return!1;let n=0;return t.every(r=>{for(let o=n;o<e.length;o++)if(Mx(e[o],r))return n=o+1,!0;return!1})}function Mx(t,e){if(!t)return!1;if(t===e)return!0;const n=e.length;return t.length>n&&t.substr(0,n)===e&&t[n]==="."}var Lx=class{constructor(t,e,n,r,o,a,i,l){if(this._rootScopeName=t,this.balancedBracketSelectors=a,this._onigLib=l,this._basicScopeAttributesProvider=new Nx(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=i,this._grammar=Hi(e,null),this._injections=null,this._tokenTypeMatchers=[],o)for(const c of Object.keys(o)){const d=Xn(c,tr);for(const p of d)this._tokenTypeMatchers.push({matcher:p.matcher,type:o[c]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(const t of this._ruleId2desc)t&&t.dispose()}createOnigScanner(t){return this._onigLib.createOnigScanner(t)}createOnigString(t){return this._onigLib.createOnigString(t)}getMetadataForScope(t){return this._basicScopeAttributesProvider.getBasicScopeAttributes(t)}_collectInjections(){const t={lookup:o=>o===this._rootScopeName?this._grammar:this.getExternalGrammar(o),injections:o=>this._grammarRepository.injections(o)},e=[],n=this._rootScopeName,r=t.lookup(n);if(r){const o=r.injections;if(o)for(let i in o)Gi(e,i,o[i],this,r);const a=this._grammarRepository.injections(n);a&&a.forEach(i=>{const l=this.getExternalGrammar(i);if(l){const c=l.injectionSelector;c&&Gi(e,c,l,this,l)}})}return e.sort((o,a)=>o.priority-a.priority),e}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(t){const e=++this._lastRuleId,n=t(e);return this._ruleId2desc[e]=n,n}getRule(t){return this._ruleId2desc[t]}getExternalGrammar(t,e){if(this._includedGrammars[t])return this._includedGrammars[t];if(this._grammarRepository){const n=this._grammarRepository.lookup(t);if(n)return this._includedGrammars[t]=Hi(n,e&&e.$base),this._includedGrammars[t]}}tokenizeLine(t,e,n=0){const r=this._tokenize(t,e,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(t,e,n=0){const r=this._tokenize(t,e,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(t,e,n,r){this._rootId===-1&&(this._rootId=Od.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let o;if(!e||e===Ho.NULL){o=!0;const d=this._basicScopeAttributesProvider.getDefaultAttributes(),p=this.themeProvider.getDefaults(),m=Ts.set(0,d.languageId,d.tokenType,null,p.fontStyle,p.foregroundId,p.backgroundId),h=this.getRule(this._rootId).getName(null,null);let g;h?g=Xs.createRootAndLookUpScopeName(h,m,this):g=Xs.createRoot("unknown",m),e=new Ho(null,this._rootId,-1,-1,!1,null,g,g)}else o=!1,e.reset();t=t+`
|
|
23
|
-
`;const a=this.createOnigString(t),i=a.content.length,l=new Dx(n,t,this._tokenTypeMatchers,this.balancedBracketSelectors),c=$d(this,a,o,0,e,l,!0,r);return Pd(a),{lineLength:i,lineTokens:l,ruleStack:c.stack,stoppedEarly:c.stoppedEarly}}};function Hi(t,e){return t=ex(t),t.repository=t.repository||{},t.repository.$self={$vscodeTextmateLocation:t.$vscodeTextmateLocation,patterns:t.patterns,name:t.scopeName},t.repository.$base=e||t.repository.$self,t}var Xs=class bt{constructor(e,n,r){this.parent=e,this.scopePath=n,this.tokenAttributes=r}static fromExtension(e,n){let r=e,o=e?.scopePath??null;for(const a of n)o=Yr.push(o,a.scopeNames),r=new bt(r,o,a.encodedTokenAttributes);return r}static createRoot(e,n){return new bt(null,new Yr(null,e),n)}static createRootAndLookUpScopeName(e,n,r){const o=r.getMetadataForScope(e),a=new Yr(null,e),i=r.themeProvider.themeMatch(a),l=bt.mergeAttributes(n,o,i);return new bt(null,a,l)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(e){return bt.equals(this,e)}static equals(e,n){do{if(e===n||!e&&!n)return!0;if(!e||!n||e.scopeName!==n.scopeName||e.tokenAttributes!==n.tokenAttributes)return!1;e=e.parent,n=n.parent}while(!0)}static mergeAttributes(e,n,r){let o=-1,a=0,i=0;return r!==null&&(o=r.fontStyle,a=r.foregroundId,i=r.backgroundId),Ts.set(e,n.languageId,n.tokenType,null,o,a,i)}pushAttributed(e,n){if(e===null)return this;if(e.indexOf(" ")===-1)return bt._pushAttributed(this,e,n);const r=e.split(/ /g);let o=this;for(const a of r)o=bt._pushAttributed(o,a,n);return o}static _pushAttributed(e,n,r){const o=r.getMetadataForScope(n),a=e.scopePath.push(n),i=r.themeProvider.themeMatch(a),l=bt.mergeAttributes(e.tokenAttributes,o,i);return new bt(e,a,l)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){const n=[];let r=this;for(;r&&r!==e;)n.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(r.parent?.scopePath??null)}),r=r.parent;return r===e?n.reverse():void 0}},Ho=class Zt{constructor(e,n,r,o,a,i,l,c){this.parent=e,this.ruleId=n,this.beginRuleCapturedEOL=a,this.endRule=i,this.nameScopesList=l,this.contentNameScopesList=c,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=o}_stackElementBrand=void 0;static NULL=new Zt(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(e){return e===null?!1:Zt._equals(this,e)}static _equals(e,n){return e===n?!0:this._structuralEquals(e,n)?Xs.equals(e.contentNameScopesList,n.contentNameScopesList):!1}static _structuralEquals(e,n){do{if(e===n||!e&&!n)return!0;if(!e||!n||e.depth!==n.depth||e.ruleId!==n.ruleId||e.endRule!==n.endRule)return!1;e=e.parent,n=n.parent}while(!0)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){Zt._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(e,n,r,o,a,i,l){return new Zt(this,e,n,r,o,a,i,l)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){const e=[];return this._writeString(e,0),"["+e.join(",")+"]"}_writeString(e,n){return this.parent&&(n=this.parent._writeString(e,n)),e[n++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,n}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(e){return this.endRule===e?this:new Zt(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,e,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let n=this;for(;n&&n._enterPos===e._enterPos;){if(n.ruleId===e.ruleId)return!0;n=n.parent}return!1}toStateStackFrame(){return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(e,n){const r=Xs.fromExtension(e?.nameScopesList??null,n.nameScopesList);return new Zt(e,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,Xs.fromExtension(r,n.contentNameScopesList))}},Ox=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(t,e){this.balancedBracketScopes=t.flatMap(n=>n==="*"?(this.allowAny=!0,[]):Xn(n,tr).map(r=>r.matcher)),this.unbalancedBracketScopes=e.flatMap(n=>Xn(n,tr).map(r=>r.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(t){for(const e of this.unbalancedBracketScopes)if(e(t))return!1;for(const e of this.balancedBracketScopes)if(e(t))return!0;return this.allowAny}},Dx=class{constructor(t,e,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=t,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(t,e){this.produceFromScopes(t.contentNameScopesList,e)}produceFromScopes(t,e){if(this._lastTokenEndIndex>=e)return;if(this._emitBinaryTokens){let r=t?.tokenAttributes??0,o=!1;if(this.balancedBracketSelectors?.matchesAlways&&(o=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const a=t?.getScopeNames()??[];for(const i of this._tokenTypeOverrides)i.matcher(a)&&(r=Ts.set(r,0,i.type,null,-1,0,0));this.balancedBracketSelectors&&(o=this.balancedBracketSelectors.match(a))}if(o&&(r=Ts.set(r,0,8,o,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===r){this._lastTokenEndIndex=e;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(r),this._lastTokenEndIndex=e;return}const n=t?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:e,scopes:n}),this._lastTokenEndIndex=e}getResult(t,e){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===e-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(t,e),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(t,e){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===e-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(t,e),this._binaryTokens[this._binaryTokens.length-2]=0);const n=new Uint32Array(this._binaryTokens.length);for(let r=0,o=this._binaryTokens.length;r<o;r++)n[r]=this._binaryTokens[r];return n}},$x=class{constructor(t,e){this._onigLib=e,this._theme=t}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(const t of this._grammars.values())t.dispose()}setTheme(t){this._theme=t}getColorMap(){return this._theme.getColorMap()}addGrammar(t,e){this._rawGrammars.set(t.scopeName,t),e&&this._injectionGrammars.set(t.scopeName,e)}lookup(t){return this._rawGrammars.get(t)}injections(t){return this._injectionGrammars.get(t)}getDefaults(){return this._theme.getDefaults()}themeMatch(t){return this._theme.match(t)}grammarForScopeName(t,e,n,r,o){if(!this._grammars.has(t)){let a=this._rawGrammars.get(t);if(!a)return null;this._grammars.set(t,Px(t,a,e,n,r,o,this,this._onigLib))}return this._grammars.get(t)}},zx=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new $x(Jn.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,n){this._syncRegistry.setTheme(Jn.createFromRawTheme(e,n))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,n,r){return this.loadGrammarWithConfiguration(e,n,{embeddedLanguages:r})}loadGrammarWithConfiguration(e,n,r){return this._loadGrammar(e,n,r.embeddedLanguages,r.tokenTypes,new Ox(r.balancedBracketSelectors||[],r.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,n,r,o,a){const i=new hx(this._syncRegistry,e);for(;i.Q.length>0;)i.Q.map(l=>this._loadSingleGrammar(l.scopeName)),i.processQueue();return this._grammarForScopeName(e,n,r,o,a)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){const n=this._options.loadGrammar(e);if(n){const r=typeof this._options.getInjections=="function"?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(n,r)}}addGrammar(e,n=[],r=0,o=null){return this._syncRegistry.addGrammar(e,n),this._grammarForScopeName(e.scopeName,r,o)}_grammarForScopeName(e,n=0,r=null,o=null,a=null){return this._syncRegistry.grammarForScopeName(e,n,r,o,a)}},qo=Ho.NULL;function sr(t,e){const n=typeof t=="string"?{}:{...t.colorReplacements},r=typeof t=="string"?t:t.name;for(const[o,a]of Object.entries(e?.colorReplacements||{}))typeof a=="string"?n[o]=a:o===r&&Object.assign(n,a);return n}function Bt(t,e){return t&&(e?.[t?.toLowerCase()]||t)}function Fx(t){return Array.isArray(t)?t:[t]}async function Fd(t){return Promise.resolve(typeof t=="function"?t():t).then(e=>e.default||e)}function Ma(t){return!t||["plaintext","txt","text","plain"].includes(t)}function Vd(t){return t==="ansi"||Ma(t)}function La(t){return t==="none"}function Bd(t){return La(t)}function Ud(t,e){if(!e)return t;t.properties||={},t.properties.class||=[],typeof t.properties.class=="string"&&(t.properties.class=t.properties.class.split(/\s+/g)),Array.isArray(t.properties.class)||(t.properties.class=[]);const n=Array.isArray(e)?e:e.split(/\s+/g);for(const r of n)r&&!t.properties.class.includes(r)&&t.properties.class.push(r);return t}function vr(t,e=!1){if(t.length===0)return[["",0]];const n=t.split(/(\r?\n)/g);let r=0;const o=[];for(let a=0;a<n.length;a+=2){const i=e?n[a]+(n[a+1]||""):n[a];o.push([i,r]),r+=n[a].length,r+=n[a+1]?.length||0}return o}function Vx(t){const e=vr(t,!0).map(([o])=>o);function n(o){if(o===t.length)return{line:e.length-1,character:e[e.length-1].length};let a=o,i=0;for(const l of e){if(a<l.length)break;a-=l.length,i++}return{line:i,character:a}}function r(o,a){let i=0;for(let l=0;l<o;l++)i+=e[l].length;return i+=a,i}return{lines:e,indexToPos:n,posToIndex:r}}function Bx(t,e,n){const r=new Set;for(const a of t.matchAll(/:?lang=["']([^"']+)["']/g)){const i=a[1].toLowerCase().trim();i&&r.add(i)}for(const a of t.matchAll(/(?:```|~~~)([\w-]+)/g)){const i=a[1].toLowerCase().trim();i&&r.add(i)}for(const a of t.matchAll(/\\begin\{([\w-]+)\}/g)){const i=a[1].toLowerCase().trim();i&&r.add(i)}for(const a of t.matchAll(/<script\s+(?:type|lang)=["']([^"']+)["']/gi)){const i=a[1].toLowerCase().trim(),l=i.includes("/")?i.split("/").pop():i;l&&r.add(l)}if(!n)return Array.from(r);const o=n.getBundledLanguages();return Array.from(r).filter(a=>a&&o[a])}const Oa="light-dark()",Ux=["color","background-color"];function Gx(t,e){let n=0;const r=[];for(const o of e)o>n&&r.push({...t,content:t.content.slice(n,o),offset:t.offset+n}),n=o;return n<t.content.length&&r.push({...t,content:t.content.slice(n),offset:t.offset+n}),r}function Hx(t,e){const n=Array.from(e instanceof Set?e:new Set(e)).sort((r,o)=>r-o);return n.length?t.map(r=>r.flatMap(o=>{const a=n.filter(i=>o.offset<i&&i<o.offset+o.content.length).map(i=>i-o.offset).sort((i,l)=>i-l);return a.length?Gx(o,a):o})):t}function qx(t,e,n,r,o="css-vars"){const a={content:t.content,explanation:t.explanation,offset:t.offset},i=e.map(p=>nr(t.variants[p])),l=new Set(i.flatMap(p=>Object.keys(p))),c={},d=(p,m)=>{const h=m==="color"?"":m==="background-color"?"-bg":`-${m}`;return n+e[p]+(m==="color"?"":h)};return i.forEach((p,m)=>{for(const h of l){const g=p[h]||"inherit";if(m===0&&r&&Ux.includes(h))if(r===Oa&&i.length>1){const f=e.findIndex(v=>v==="light"),x=e.findIndex(v=>v==="dark");if(f===-1||x===-1)throw new Ve('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');const b=i[f][h]||"inherit",y=i[x][h]||"inherit";c[h]=`light-dark(${b}, ${y})`,o==="css-vars"&&(c[d(m,h)]=g)}else c[h]=g;else o==="css-vars"&&(c[d(m,h)]=g)}}),a.htmlStyle=c,a}function nr(t){const e={};if(t.color&&(e.color=t.color),t.bgColor&&(e["background-color"]=t.bgColor),t.fontStyle){t.fontStyle&tt.Italic&&(e["font-style"]="italic"),t.fontStyle&tt.Bold&&(e["font-weight"]="bold");const n=[];t.fontStyle&tt.Underline&&n.push("underline"),t.fontStyle&tt.Strikethrough&&n.push("line-through"),n.length&&(e["text-decoration"]=n.join(" "))}return e}function Wo(t){return typeof t=="string"?t:Object.entries(t).map(([e,n])=>`${e}:${n}`).join(";")}const Gd=new WeakMap;function wr(t,e){Gd.set(t,e)}function ln(t){return Gd.get(t)}class Ds{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(e,n){return new Ds(Object.fromEntries(Fx(n).map(r=>[r,qo])),e)}constructor(...e){if(e.length===2){const[n,r]=e;this.lang=r,this._stacks=n}else{const[n,r,o]=e;this.lang=r,this._stacks={[o]:n}}}getInternalStack(e=this.theme){return this._stacks[e]}getScopes(e=this.theme){return Wx(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}}function Wx(t){const e=[],n=new Set;function r(o){if(n.has(o))return;n.add(o);const a=o?.nameScopesList?.scopeName;a&&e.push(a),o.parent&&r(o.parent)}return r(t),e}function Kx(t,e){if(!(t instanceof Ds))throw new Ve("Invalid grammar state");return t.getInternalStack(e)}function Qx(){const t=new WeakMap;function e(n){if(!t.has(n.meta)){let r=function(i){if(typeof i=="number"){if(i<0||i>n.source.length)throw new Ve(`Invalid decoration offset: ${i}. Code length: ${n.source.length}`);return{...o.indexToPos(i),offset:i}}else{const l=o.lines[i.line];if(l===void 0)throw new Ve(`Invalid decoration position ${JSON.stringify(i)}. Lines length: ${o.lines.length}`);let c=i.character;if(c<0&&(c=l.length+c),c<0||c>l.length)throw new Ve(`Invalid decoration position ${JSON.stringify(i)}. Line ${i.line} length: ${l.length}`);return{...i,character:c,offset:o.posToIndex(i.line,c)}}};const o=Vx(n.source),a=(n.options.decorations||[]).map(i=>({...i,start:r(i.start),end:r(i.end)}));Yx(a),t.set(n.meta,{decorations:a,converter:o,source:n.source})}return t.get(n.meta)}return{name:"shiki:decorations",tokens(n){if(!this.options.decorations?.length)return;const o=e(this).decorations.flatMap(i=>[i.start.offset,i.end.offset]);return Hx(n,o)},code(n){if(!this.options.decorations?.length)return;const r=e(this),o=Array.from(n.children).filter(p=>p.type==="element"&&p.tagName==="span");if(o.length!==r.converter.lines.length)throw new Ve(`Number of lines in code element (${o.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);function a(p,m,h,g){const f=o[p];let x="",b=-1,y=-1;if(m===0&&(b=0),h===0&&(y=0),h===Number.POSITIVE_INFINITY&&(y=f.children.length),b===-1||y===-1)for(let w=0;w<f.children.length;w++)x+=Hd(f.children[w]),b===-1&&x.length===m&&(b=w+1),y===-1&&x.length===h&&(y=w+1);if(b===-1)throw new Ve(`Failed to find start index for decoration ${JSON.stringify(g.start)}`);if(y===-1)throw new Ve(`Failed to find end index for decoration ${JSON.stringify(g.end)}`);const v=f.children.slice(b,y);if(!g.alwaysWrap&&v.length===f.children.length)l(f,g,"line");else if(!g.alwaysWrap&&v.length===1&&v[0].type==="element")l(v[0],g,"token");else{const w={type:"element",tagName:"span",properties:{},children:v};l(w,g,"wrapper"),f.children.splice(b,v.length,w)}}function i(p,m){o[p]=l(o[p],m,"line")}function l(p,m,h){const g=m.properties||{},f=m.transform||(x=>x);return p.tagName=m.tagName||"span",p.properties={...p.properties,...g,class:p.properties.class},m.properties?.class&&Ud(p,m.properties.class),p=f(p,h)||p,p}const c=[],d=r.decorations.sort((p,m)=>m.start.offset-p.start.offset||p.end.offset-m.end.offset);for(const p of d){const{start:m,end:h}=p;if(m.line===h.line)a(m.line,m.character,h.character,p);else if(m.line<h.line){a(m.line,m.character,Number.POSITIVE_INFINITY,p);for(let g=m.line+1;g<h.line;g++)c.unshift(()=>i(g,p));a(h.line,0,h.character,p)}}c.forEach(p=>p())}}}function Yx(t){for(let e=0;e<t.length;e++){const n=t[e];if(n.start.offset>n.end.offset)throw new Ve(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=e+1;r<t.length;r++){const o=t[r],a=n.start.offset<=o.start.offset&&o.start.offset<n.end.offset,i=n.start.offset<o.end.offset&&o.end.offset<=n.end.offset,l=o.start.offset<=n.start.offset&&n.start.offset<o.end.offset,c=o.start.offset<n.end.offset&&n.end.offset<=o.end.offset;if(a||i||l||c){if(a&&i||l&&c||l&&n.start.offset===n.end.offset||i&&o.start.offset===o.end.offset)continue;throw new Ve(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(o.start)} intersect.`)}}}}function Hd(t){return t.type==="text"?t.value:t.type==="element"?t.children.map(Hd).join(""):""}const Jx=[Qx()];function rr(t){const e=Xx(t.transformers||[]);return[...e.pre,...e.normal,...e.post,...Jx]}function Xx(t){const e=[],n=[],r=[];for(const o of t)switch(o.enforce){case"pre":e.push(o);break;case"post":n.push(o);break;default:r.push(o)}return{pre:e,post:n,normal:r}}var es=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],Xr={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function Zx(t,e){const n=t.indexOf("\x1B",e);if(n!==-1&&t[n+1]==="["){const r=t.indexOf("m",n);if(r!==-1)return{sequence:t.substring(n+2,r).split(";"),startPosition:n,position:r+1}}return{position:t.length}}function qi(t){const e=t.shift();if(e==="2"){const n=t.splice(0,3).map(r=>Number.parseInt(r));return n.length!==3||n.some(r=>Number.isNaN(r))?void 0:{type:"rgb",rgb:n}}else if(e==="5"){const n=t.shift();if(n)return{type:"table",index:Number(n)}}}function eb(t){const e=[];for(;t.length>0;){const n=t.shift();if(!n)continue;const r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)e.push({type:"resetAll"});else if(r<=9)Xr[r]&&e.push({type:"setDecoration",value:Xr[r]});else if(r<=29){const o=Xr[r-20];o&&(e.push({type:"resetDecoration",value:o}),o==="dim"&&e.push({type:"resetDecoration",value:"bold"}))}else if(r<=37)e.push({type:"setForegroundColor",value:{type:"named",name:es[r-30]}});else if(r===38){const o=qi(t);o&&e.push({type:"setForegroundColor",value:o})}else if(r===39)e.push({type:"resetForegroundColor"});else if(r<=47)e.push({type:"setBackgroundColor",value:{type:"named",name:es[r-40]}});else if(r===48){const o=qi(t);o&&e.push({type:"setBackgroundColor",value:o})}else r===49?e.push({type:"resetBackgroundColor"}):r===53?e.push({type:"setDecoration",value:"overline"}):r===55?e.push({type:"resetDecoration",value:"overline"}):r>=90&&r<=97?e.push({type:"setForegroundColor",value:{type:"named",name:es[r-90+8]}}):r>=100&&r<=107&&e.push({type:"setBackgroundColor",value:{type:"named",name:es[r-100+8]}})}return e}function tb(){let t=null,e=null,n=new Set;return{parse(r){const o=[];let a=0;do{const i=Zx(r,a),l=i.sequence?r.substring(a,i.startPosition):r.substring(a);if(l.length>0&&o.push({value:l,foreground:t,background:e,decorations:new Set(n)}),i.sequence){const c=eb(i.sequence);for(const d of c)d.type==="resetAll"?(t=null,e=null,n.clear()):d.type==="resetForegroundColor"?t=null:d.type==="resetBackgroundColor"?e=null:d.type==="resetDecoration"&&n.delete(d.value);for(const d of c)d.type==="setForegroundColor"?t=d.value:d.type==="setBackgroundColor"?e=d.value:d.type==="setDecoration"&&n.add(d.value)}a=i.position}while(a<r.length);return o}}}var sb={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function nb(t=sb){function e(l){return t[l]}function n(l){return`#${l.map(c=>Math.max(0,Math.min(c,255)).toString(16).padStart(2,"0")).join("")}`}let r;function o(){if(r)return r;r=[];for(let d=0;d<es.length;d++)r.push(e(es[d]));let l=[0,95,135,175,215,255];for(let d=0;d<6;d++)for(let p=0;p<6;p++)for(let m=0;m<6;m++)r.push(n([l[d],l[p],l[m]]));let c=8;for(let d=0;d<24;d++,c+=10)r.push(n([c,c,c]));return r}function a(l){return o()[l]}function i(l){switch(l.type){case"named":return e(l.name);case"rgb":return n(l.rgb);case"table":return a(l.index)}}return{value:i}}const rb={black:"#000000",red:"#cd3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#FFFFFF"};function ob(t,e,n){const r=sr(t,n),o=vr(e),a=Object.fromEntries(es.map(c=>{const d=`terminal.ansi${c[0].toUpperCase()}${c.substring(1)}`,p=t.colors?.[d];return[c,p||rb[c]]})),i=nb(a),l=tb();return o.map(c=>l.parse(c[0]).map(d=>{let p,m;d.decorations.has("reverse")?(p=d.background?i.value(d.background):t.bg,m=d.foreground?i.value(d.foreground):t.fg):(p=d.foreground?i.value(d.foreground):t.fg,m=d.background?i.value(d.background):void 0),p=Bt(p,r),m=Bt(m,r),d.decorations.has("dim")&&(p=ab(p));let h=tt.None;return d.decorations.has("bold")&&(h|=tt.Bold),d.decorations.has("italic")&&(h|=tt.Italic),d.decorations.has("underline")&&(h|=tt.Underline),d.decorations.has("strikethrough")&&(h|=tt.Strikethrough),{content:d.value,offset:c[1],color:p,bgColor:m,fontStyle:h}}))}function ab(t){const e=t.match(/#([0-9a-f]{3,8})/i);if(e){const r=e[1];if(r.length===8){const o=Math.round(Number.parseInt(r.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${r.slice(0,6)}${o}`}else{if(r.length===6)return`#${r}80`;if(r.length===4){const o=r[0],a=r[1],i=r[2],l=r[3],c=Math.round(Number.parseInt(`${l}${l}`,16)/2).toString(16).padStart(2,"0");return`#${o}${o}${a}${a}${i}${i}${c}`}else if(r.length===3){const o=r[0],a=r[1],i=r[2];return`#${o}${o}${a}${a}${i}${i}80`}}}const n=t.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return n?`var(${n[1]}-dim)`:t}function Da(t,e,n={}){const{theme:r=t.getLoadedThemes()[0]}=n,o=t.resolveLangAlias(n.lang||"text");if(Ma(o)||La(r))return vr(e).map(c=>[{content:c[0],offset:c[1]}]);const{theme:a,colorMap:i}=t.setTheme(r);if(o==="ansi")return ob(a,e,n);const l=t.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==l.name)throw new Ve(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${l.name}"`);if(!n.grammarState.themes.includes(a.name))throw new Ve(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${a.name}"`)}return cb(e,l,a,i,n)}function ib(...t){if(t.length===2)return ln(t[1]);const[e,n,r={}]=t,{lang:o="text",theme:a=e.getLoadedThemes()[0]}=r;if(Ma(o)||La(a))throw new Ve("Plain language does not have grammar state");if(o==="ansi")throw new Ve("ANSI language does not have grammar state");const{theme:i,colorMap:l}=e.setTheme(a),c=e.getLanguage(o);return new Ds($a(n,c,i,l,r).stateStack,c.name,i.name)}function cb(t,e,n,r,o){const a=$a(t,e,n,r,o),i=new Ds(a.stateStack,e.name,n.name);return wr(a.tokens,i),a.tokens}function $a(t,e,n,r,o){const a=sr(n,o),{tokenizeMaxLineLength:i=0,tokenizeTimeLimit:l=500}=o,c=vr(t);let d=o.grammarState?Kx(o.grammarState,n.name)??qo:o.grammarContextCode!=null?$a(o.grammarContextCode,e,n,r,{...o,grammarState:void 0,grammarContextCode:void 0}).stateStack:qo,p=[];const m=[];for(let h=0,g=c.length;h<g;h++){const[f,x]=c[h];if(f===""){p=[],m.push([]);continue}if(i>0&&f.length>=i){p=[],m.push([{content:f,offset:x,color:"",fontStyle:0}]);continue}let b,y,v;o.includeExplanation&&(b=e.tokenizeLine(f,d,l),y=b.tokens,v=0);const w=e.tokenizeLine2(f,d,l),N=w.tokens.length/2;for(let S=0;S<N;S++){const T=w.tokens[2*S],C=S+1<N?w.tokens[2*S+2]:f.length;if(T===C)continue;const j=w.tokens[2*S+1],E=Bt(r[Ts.getForeground(j)],a),R=Ts.getFontStyle(j),O={content:f.substring(T,C),offset:x+T,color:E,fontStyle:R};if(o.includeExplanation){const $=[];if(o.includeExplanation!=="scopeName")for(const ne of n.settings){let V;switch(typeof ne.scope){case"string":V=ne.scope.split(/,/).map(X=>X.trim());break;case"object":V=ne.scope;break;default:continue}$.push({settings:ne,selectors:V.map(X=>X.split(/ /))})}O.explanation=[];let re=0;for(;T+re<C;){const ne=y[v],V=f.substring(ne.startIndex,ne.endIndex);re+=V.length,O.explanation.push({content:V,scopes:o.includeExplanation==="scopeName"?lb(ne.scopes):db($,ne.scopes)}),v+=1}}p.push(O)}m.push(p),p=[],d=w.ruleStack}return{tokens:m,stateStack:d}}function lb(t){return t.map(e=>({scopeName:e}))}function db(t,e){const n=[];for(let r=0,o=e.length;r<o;r++){const a=e[r];n[r]={scopeName:a,themeMatches:pb(t,a,e.slice(0,r))}}return n}function Wi(t,e){return t===e||e.substring(0,t.length)===t&&e[t.length]==="."}function ub(t,e,n){if(!Wi(t[t.length-1],e))return!1;let r=t.length-2,o=n.length-1;for(;r>=0&&o>=0;)Wi(t[r],n[o])&&(r-=1),o-=1;return r===-1}function pb(t,e,n){const r=[];for(const{selectors:o,settings:a}of t)for(const i of o)if(ub(i,e,n)){r.push(a);break}return r}function qd(t,e,n){const r=Object.entries(n.themes).filter(c=>c[1]).map(c=>({color:c[0],theme:c[1]})),o=r.map(c=>{const d=Da(t,e,{...n,theme:c.theme}),p=ln(d),m=typeof c.theme=="string"?c.theme:c.theme.name;return{tokens:d,state:p,theme:m}}),a=mb(...o.map(c=>c.tokens)),i=a[0].map((c,d)=>c.map((p,m)=>{const h={content:p.content,variants:{},offset:p.offset};return"includeExplanation"in n&&n.includeExplanation&&(h.explanation=p.explanation),a.forEach((g,f)=>{const{content:x,explanation:b,offset:y,...v}=g[d][m];h.variants[r[f].color]=v}),h})),l=o[0].state?new Ds(Object.fromEntries(o.map(c=>[c.theme,c.state?.getInternalStack(c.theme)])),o[0].state.lang):void 0;return l&&wr(i,l),i}function mb(...t){const e=t.map(()=>[]),n=t.length;for(let r=0;r<t[0].length;r++){const o=t.map(c=>c[r]),a=e.map(()=>[]);e.forEach((c,d)=>c.push(a[d]));const i=o.map(()=>0),l=o.map(c=>c[0]);for(;l.every(c=>c);){const c=Math.min(...l.map(d=>d.content.length));for(let d=0;d<n;d++){const p=l[d];p.content.length===c?(a[d].push(p),i[d]+=1,l[d]=o[d][i[d]]):(a[d].push({...p,content:p.content.slice(0,c)}),l[d]={...p,content:p.content.slice(c),offset:p.offset+c})}}}return e}function or(t,e,n){let r,o,a,i,l,c;if("themes"in n){const{defaultColor:d="light",cssVariablePrefix:p="--shiki-",colorsRendering:m="css-vars"}=n,h=Object.entries(n.themes).filter(y=>y[1]).map(y=>({color:y[0],theme:y[1]})).sort((y,v)=>y.color===d?-1:v.color===d?1:0);if(h.length===0)throw new Ve("`themes` option must not be empty");const g=qd(t,e,n);if(c=ln(g),d&&Oa!==d&&!h.find(y=>y.color===d))throw new Ve(`\`themes\` option must contain the defaultColor key \`${d}\``);const f=h.map(y=>t.getTheme(y.theme)),x=h.map(y=>y.color);a=g.map(y=>y.map(v=>qx(v,x,p,d,m))),c&&wr(a,c);const b=h.map(y=>sr(y.theme,n));o=Ki(h,f,b,p,d,"fg",m),r=Ki(h,f,b,p,d,"bg",m),i=`shiki-themes ${f.map(y=>y.name).join(" ")}`,l=d?void 0:[o,r].join(";")}else if("theme"in n){const d=sr(n.theme,n);a=Da(t,e,n);const p=t.getTheme(n.theme);r=Bt(p.bg,d),o=Bt(p.fg,d),i=p.name,c=ln(a)}else throw new Ve("Invalid options, either `theme` or `themes` must be provided");return{tokens:a,fg:o,bg:r,themeName:i,rootStyle:l,grammarState:c}}function Ki(t,e,n,r,o,a,i){return t.map((l,c)=>{const d=Bt(e[c][a],n[c])||"inherit",p=`${r+l.color}${a==="bg"?"-bg":""}:${d}`;if(c===0&&o){if(o===Oa&&t.length>1){const m=t.findIndex(x=>x.color==="light"),h=t.findIndex(x=>x.color==="dark");if(m===-1||h===-1)throw new Ve('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');const g=Bt(e[m][a],n[m])||"inherit",f=Bt(e[h][a],n[h])||"inherit";return`light-dark(${g}, ${f});${p}`}return d}return i==="css-vars"?p:null}).filter(l=>!!l).join(";")}function ar(t,e,n,r={meta:{},options:n,codeToHast:(o,a)=>ar(t,o,a),codeToTokens:(o,a)=>or(t,o,a)}){let o=e;for(const f of rr(n))o=f.preprocess?.call(r,o,n)||o;let{tokens:a,fg:i,bg:l,themeName:c,rootStyle:d,grammarState:p}=or(t,o,n);const{mergeWhitespaces:m=!0,mergeSameStyleTokens:h=!1}=n;m===!0?a=fb(a):m==="never"&&(a=gb(a)),h&&(a=xb(a));const g={...r,get source(){return o}};for(const f of rr(n))a=f.tokens?.call(g,a)||a;return hb(a,{...n,fg:i,bg:l,themeName:c,rootStyle:n.rootStyle===!1?!1:n.rootStyle??d},g,p)}function hb(t,e,n,r=ln(t)){const o=rr(e),a=[],i={type:"root",children:[]},{structure:l="classic",tabindex:c="0"}=e,d={class:`shiki ${e.themeName||""}`};e.rootStyle!==!1&&(e.rootStyle!=null?d.style=e.rootStyle:d.style=`background-color:${e.bg};color:${e.fg}`),c!==!1&&c!=null&&(d.tabindex=c.toString());for(const[x,b]of Object.entries(e.meta||{}))x.startsWith("_")||(d[x]=b);let p={type:"element",tagName:"pre",properties:d,children:[],data:e.data},m={type:"element",tagName:"code",properties:{},children:a};const h=[],g={...n,structure:l,addClassToHast:Ud,get source(){return n.source},get tokens(){return t},get options(){return e},get root(){return i},get pre(){return p},get code(){return m},get lines(){return h}};if(t.forEach((x,b)=>{b&&(l==="inline"?i.children.push({type:"element",tagName:"br",properties:{},children:[]}):l==="classic"&&a.push({type:"text",value:`
|
|
23
|
+
`;const a=this.createOnigString(t),i=a.content.length,l=new Dx(n,t,this._tokenTypeMatchers,this.balancedBracketSelectors),c=$d(this,a,o,0,e,l,!0,r);return Pd(a),{lineLength:i,lineTokens:l,ruleStack:c.stack,stoppedEarly:c.stoppedEarly}}};function Hi(t,e){return t=ex(t),t.repository=t.repository||{},t.repository.$self={$vscodeTextmateLocation:t.$vscodeTextmateLocation,patterns:t.patterns,name:t.scopeName},t.repository.$base=e||t.repository.$self,t}var Xs=class bt{constructor(e,n,r){this.parent=e,this.scopePath=n,this.tokenAttributes=r}static fromExtension(e,n){let r=e,o=e?.scopePath??null;for(const a of n)o=Yr.push(o,a.scopeNames),r=new bt(r,o,a.encodedTokenAttributes);return r}static createRoot(e,n){return new bt(null,new Yr(null,e),n)}static createRootAndLookUpScopeName(e,n,r){const o=r.getMetadataForScope(e),a=new Yr(null,e),i=r.themeProvider.themeMatch(a),l=bt.mergeAttributes(n,o,i);return new bt(null,a,l)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(e){return bt.equals(this,e)}static equals(e,n){do{if(e===n||!e&&!n)return!0;if(!e||!n||e.scopeName!==n.scopeName||e.tokenAttributes!==n.tokenAttributes)return!1;e=e.parent,n=n.parent}while(!0)}static mergeAttributes(e,n,r){let o=-1,a=0,i=0;return r!==null&&(o=r.fontStyle,a=r.foregroundId,i=r.backgroundId),Ts.set(e,n.languageId,n.tokenType,null,o,a,i)}pushAttributed(e,n){if(e===null)return this;if(e.indexOf(" ")===-1)return bt._pushAttributed(this,e,n);const r=e.split(/ /g);let o=this;for(const a of r)o=bt._pushAttributed(o,a,n);return o}static _pushAttributed(e,n,r){const o=r.getMetadataForScope(n),a=e.scopePath.push(n),i=r.themeProvider.themeMatch(a),l=bt.mergeAttributes(e.tokenAttributes,o,i);return new bt(e,a,l)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){const n=[];let r=this;for(;r&&r!==e;)n.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(r.parent?.scopePath??null)}),r=r.parent;return r===e?n.reverse():void 0}},Ho=class Zt{constructor(e,n,r,o,a,i,l,c){this.parent=e,this.ruleId=n,this.beginRuleCapturedEOL=a,this.endRule=i,this.nameScopesList=l,this.contentNameScopesList=c,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=o}_stackElementBrand=void 0;static NULL=new Zt(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(e){return e===null?!1:Zt._equals(this,e)}static _equals(e,n){return e===n?!0:this._structuralEquals(e,n)?Xs.equals(e.contentNameScopesList,n.contentNameScopesList):!1}static _structuralEquals(e,n){do{if(e===n||!e&&!n)return!0;if(!e||!n||e.depth!==n.depth||e.ruleId!==n.ruleId||e.endRule!==n.endRule)return!1;e=e.parent,n=n.parent}while(!0)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){Zt._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(e,n,r,o,a,i,l){return new Zt(this,e,n,r,o,a,i,l)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){const e=[];return this._writeString(e,0),"["+e.join(",")+"]"}_writeString(e,n){return this.parent&&(n=this.parent._writeString(e,n)),e[n++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,n}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(e){return this.endRule===e?this:new Zt(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,e,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let n=this;for(;n&&n._enterPos===e._enterPos;){if(n.ruleId===e.ruleId)return!0;n=n.parent}return!1}toStateStackFrame(){return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(e,n){const r=Xs.fromExtension(e?.nameScopesList??null,n.nameScopesList);return new Zt(e,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,Xs.fromExtension(r,n.contentNameScopesList))}},Ox=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(t,e){this.balancedBracketScopes=t.flatMap(n=>n==="*"?(this.allowAny=!0,[]):Xn(n,tr).map(r=>r.matcher)),this.unbalancedBracketScopes=e.flatMap(n=>Xn(n,tr).map(r=>r.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(t){for(const e of this.unbalancedBracketScopes)if(e(t))return!1;for(const e of this.balancedBracketScopes)if(e(t))return!0;return this.allowAny}},Dx=class{constructor(t,e,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=t,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(t,e){this.produceFromScopes(t.contentNameScopesList,e)}produceFromScopes(t,e){if(this._lastTokenEndIndex>=e)return;if(this._emitBinaryTokens){let r=t?.tokenAttributes??0,o=!1;if(this.balancedBracketSelectors?.matchesAlways&&(o=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const a=t?.getScopeNames()??[];for(const i of this._tokenTypeOverrides)i.matcher(a)&&(r=Ts.set(r,0,i.type,null,-1,0,0));this.balancedBracketSelectors&&(o=this.balancedBracketSelectors.match(a))}if(o&&(r=Ts.set(r,0,8,o,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===r){this._lastTokenEndIndex=e;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(r),this._lastTokenEndIndex=e;return}const n=t?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:e,scopes:n}),this._lastTokenEndIndex=e}getResult(t,e){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===e-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(t,e),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(t,e){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===e-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(t,e),this._binaryTokens[this._binaryTokens.length-2]=0);const n=new Uint32Array(this._binaryTokens.length);for(let r=0,o=this._binaryTokens.length;r<o;r++)n[r]=this._binaryTokens[r];return n}},$x=class{constructor(t,e){this._onigLib=e,this._theme=t}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(const t of this._grammars.values())t.dispose()}setTheme(t){this._theme=t}getColorMap(){return this._theme.getColorMap()}addGrammar(t,e){this._rawGrammars.set(t.scopeName,t),e&&this._injectionGrammars.set(t.scopeName,e)}lookup(t){return this._rawGrammars.get(t)}injections(t){return this._injectionGrammars.get(t)}getDefaults(){return this._theme.getDefaults()}themeMatch(t){return this._theme.match(t)}grammarForScopeName(t,e,n,r,o){if(!this._grammars.has(t)){let a=this._rawGrammars.get(t);if(!a)return null;this._grammars.set(t,Px(t,a,e,n,r,o,this,this._onigLib))}return this._grammars.get(t)}},zx=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new $x(Jn.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,n){this._syncRegistry.setTheme(Jn.createFromRawTheme(e,n))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,n,r){return this.loadGrammarWithConfiguration(e,n,{embeddedLanguages:r})}loadGrammarWithConfiguration(e,n,r){return this._loadGrammar(e,n,r.embeddedLanguages,r.tokenTypes,new Ox(r.balancedBracketSelectors||[],r.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,n,r,o,a){const i=new hx(this._syncRegistry,e);for(;i.Q.length>0;)i.Q.map(l=>this._loadSingleGrammar(l.scopeName)),i.processQueue();return this._grammarForScopeName(e,n,r,o,a)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){const n=this._options.loadGrammar(e);if(n){const r=typeof this._options.getInjections=="function"?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(n,r)}}addGrammar(e,n=[],r=0,o=null){return this._syncRegistry.addGrammar(e,n),this._grammarForScopeName(e.scopeName,r,o)}_grammarForScopeName(e,n=0,r=null,o=null,a=null){return this._syncRegistry.grammarForScopeName(e,n,r,o,a)}},qo=Ho.NULL;function sr(t,e){const n=typeof t=="string"?{}:{...t.colorReplacements},r=typeof t=="string"?t:t.name;for(const[o,a]of Object.entries(e?.colorReplacements||{}))typeof a=="string"?n[o]=a:o===r&&Object.assign(n,a);return n}function Bt(t,e){return t&&(e?.[t?.toLowerCase()]||t)}function Fx(t){return Array.isArray(t)?t:[t]}async function Fd(t){return Promise.resolve(typeof t=="function"?t():t).then(e=>e.default||e)}function Ma(t){return!t||["plaintext","txt","text","plain"].includes(t)}function Vd(t){return t==="ansi"||Ma(t)}function La(t){return t==="none"}function Bd(t){return La(t)}function Ud(t,e){if(!e)return t;t.properties||={},t.properties.class||=[],typeof t.properties.class=="string"&&(t.properties.class=t.properties.class.split(/\s+/g)),Array.isArray(t.properties.class)||(t.properties.class=[]);const n=Array.isArray(e)?e:e.split(/\s+/g);for(const r of n)r&&!t.properties.class.includes(r)&&t.properties.class.push(r);return t}function vr(t,e=!1){if(t.length===0)return[["",0]];const n=t.split(/(\r?\n)/g);let r=0;const o=[];for(let a=0;a<n.length;a+=2){const i=e?n[a]+(n[a+1]||""):n[a];o.push([i,r]),r+=n[a].length,r+=n[a+1]?.length||0}return o}function Vx(t){const e=vr(t,!0).map(([o])=>o);function n(o){if(o===t.length)return{line:e.length-1,character:e[e.length-1].length};let a=o,i=0;for(const l of e){if(a<l.length)break;a-=l.length,i++}return{line:i,character:a}}function r(o,a){let i=0;for(let l=0;l<o;l++)i+=e[l].length;return i+=a,i}return{lines:e,indexToPos:n,posToIndex:r}}function Bx(t,e,n){const r=new Set;for(const a of t.matchAll(/:?lang=["']([^"']+)["']/g)){const i=a[1].toLowerCase().trim();i&&r.add(i)}for(const a of t.matchAll(/(?:```|~~~)([\w-]+)/g)){const i=a[1].toLowerCase().trim();i&&r.add(i)}for(const a of t.matchAll(/\\begin\{([\w-]+)\}/g)){const i=a[1].toLowerCase().trim();i&&r.add(i)}for(const a of t.matchAll(/<script\s+(?:type|lang)=["']([^"']+)["']/gi)){const i=a[1].toLowerCase().trim(),l=i.includes("/")?i.split("/").pop():i;l&&r.add(l)}if(!n)return Array.from(r);const o=n.getBundledLanguages();return Array.from(r).filter(a=>a&&o[a])}const Oa="light-dark()",Ux=["color","background-color"];function Gx(t,e){let n=0;const r=[];for(const o of e)o>n&&r.push({...t,content:t.content.slice(n,o),offset:t.offset+n}),n=o;return n<t.content.length&&r.push({...t,content:t.content.slice(n),offset:t.offset+n}),r}function Hx(t,e){const n=Array.from(e instanceof Set?e:new Set(e)).sort((r,o)=>r-o);return n.length?t.map(r=>r.flatMap(o=>{const a=n.filter(i=>o.offset<i&&i<o.offset+o.content.length).map(i=>i-o.offset).sort((i,l)=>i-l);return a.length?Gx(o,a):o})):t}function qx(t,e,n,r,o="css-vars"){const a={content:t.content,explanation:t.explanation,offset:t.offset},i=e.map(p=>nr(t.variants[p])),l=new Set(i.flatMap(p=>Object.keys(p))),c={},d=(p,m)=>{const h=m==="color"?"":m==="background-color"?"-bg":`-${m}`;return n+e[p]+(m==="color"?"":h)};return i.forEach((p,m)=>{for(const h of l){const g=p[h]||"inherit";if(m===0&&r&&Ux.includes(h))if(r===Oa&&i.length>1){const f=e.findIndex(v=>v==="light"),x=e.findIndex(v=>v==="dark");if(f===-1||x===-1)throw new Ve('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');const b=i[f][h]||"inherit",y=i[x][h]||"inherit";c[h]=`light-dark(${b}, ${y})`,o==="css-vars"&&(c[d(m,h)]=g)}else c[h]=g;else o==="css-vars"&&(c[d(m,h)]=g)}}),a.htmlStyle=c,a}function nr(t){const e={};if(t.color&&(e.color=t.color),t.bgColor&&(e["background-color"]=t.bgColor),t.fontStyle){t.fontStyle&tt.Italic&&(e["font-style"]="italic"),t.fontStyle&tt.Bold&&(e["font-weight"]="bold");const n=[];t.fontStyle&tt.Underline&&n.push("underline"),t.fontStyle&tt.Strikethrough&&n.push("line-through"),n.length&&(e["text-decoration"]=n.join(" "))}return e}function Wo(t){return typeof t=="string"?t:Object.entries(t).map(([e,n])=>`${e}:${n}`).join(";")}const Gd=new WeakMap;function wr(t,e){Gd.set(t,e)}function ln(t){return Gd.get(t)}class Ds{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(e,n){return new Ds(Object.fromEntries(Fx(n).map(r=>[r,qo])),e)}constructor(...e){if(e.length===2){const[n,r]=e;this.lang=r,this._stacks=n}else{const[n,r,o]=e;this.lang=r,this._stacks={[o]:n}}}getInternalStack(e=this.theme){return this._stacks[e]}getScopes(e=this.theme){return Wx(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}}function Wx(t){const e=[],n=new Set;function r(o){if(n.has(o))return;n.add(o);const a=o?.nameScopesList?.scopeName;a&&e.push(a),o.parent&&r(o.parent)}return r(t),e}function Kx(t,e){if(!(t instanceof Ds))throw new Ve("Invalid grammar state");return t.getInternalStack(e)}function Qx(){const t=new WeakMap;function e(n){if(!t.has(n.meta)){let r=function(i){if(typeof i=="number"){if(i<0||i>n.source.length)throw new Ve(`Invalid decoration offset: ${i}. Code length: ${n.source.length}`);return{...o.indexToPos(i),offset:i}}else{const l=o.lines[i.line];if(l===void 0)throw new Ve(`Invalid decoration position ${JSON.stringify(i)}. Lines length: ${o.lines.length}`);let c=i.character;if(c<0&&(c=l.length+c),c<0||c>l.length)throw new Ve(`Invalid decoration position ${JSON.stringify(i)}. Line ${i.line} length: ${l.length}`);return{...i,character:c,offset:o.posToIndex(i.line,c)}}};const o=Vx(n.source),a=(n.options.decorations||[]).map(i=>({...i,start:r(i.start),end:r(i.end)}));Yx(a),t.set(n.meta,{decorations:a,converter:o,source:n.source})}return t.get(n.meta)}return{name:"shiki:decorations",tokens(n){if(!this.options.decorations?.length)return;const o=e(this).decorations.flatMap(i=>[i.start.offset,i.end.offset]);return Hx(n,o)},code(n){if(!this.options.decorations?.length)return;const r=e(this),o=Array.from(n.children).filter(p=>p.type==="element"&&p.tagName==="span");if(o.length!==r.converter.lines.length)throw new Ve(`Number of lines in code element (${o.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);function a(p,m,h,g){const f=o[p];let x="",b=-1,y=-1;if(m===0&&(b=0),h===0&&(y=0),h===Number.POSITIVE_INFINITY&&(y=f.children.length),b===-1||y===-1)for(let w=0;w<f.children.length;w++)x+=Hd(f.children[w]),b===-1&&x.length===m&&(b=w+1),y===-1&&x.length===h&&(y=w+1);if(b===-1)throw new Ve(`Failed to find start index for decoration ${JSON.stringify(g.start)}`);if(y===-1)throw new Ve(`Failed to find end index for decoration ${JSON.stringify(g.end)}`);const v=f.children.slice(b,y);if(!g.alwaysWrap&&v.length===f.children.length)l(f,g,"line");else if(!g.alwaysWrap&&v.length===1&&v[0].type==="element")l(v[0],g,"token");else{const w={type:"element",tagName:"span",properties:{},children:v};l(w,g,"wrapper"),f.children.splice(b,v.length,w)}}function i(p,m){o[p]=l(o[p],m,"line")}function l(p,m,h){const g=m.properties||{},f=m.transform||(x=>x);return p.tagName=m.tagName||"span",p.properties={...p.properties,...g,class:p.properties.class},m.properties?.class&&Ud(p,m.properties.class),p=f(p,h)||p,p}const c=[],d=r.decorations.sort((p,m)=>m.start.offset-p.start.offset||p.end.offset-m.end.offset);for(const p of d){const{start:m,end:h}=p;if(m.line===h.line)a(m.line,m.character,h.character,p);else if(m.line<h.line){a(m.line,m.character,Number.POSITIVE_INFINITY,p);for(let g=m.line+1;g<h.line;g++)c.unshift(()=>i(g,p));a(h.line,0,h.character,p)}}c.forEach(p=>p())}}}function Yx(t){for(let e=0;e<t.length;e++){const n=t[e];if(n.start.offset>n.end.offset)throw new Ve(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=e+1;r<t.length;r++){const o=t[r],a=n.start.offset<=o.start.offset&&o.start.offset<n.end.offset,i=n.start.offset<o.end.offset&&o.end.offset<=n.end.offset,l=o.start.offset<=n.start.offset&&n.start.offset<o.end.offset,c=o.start.offset<n.end.offset&&n.end.offset<=o.end.offset;if(a||i||l||c){if(a&&i||l&&c||l&&n.start.offset===n.end.offset||i&&o.start.offset===o.end.offset)continue;throw new Ve(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(o.start)} intersect.`)}}}}function Hd(t){return t.type==="text"?t.value:t.type==="element"?t.children.map(Hd).join(""):""}const Jx=[Qx()];function rr(t){const e=Xx(t.transformers||[]);return[...e.pre,...e.normal,...e.post,...Jx]}function Xx(t){const e=[],n=[],r=[];for(const o of t)switch(o.enforce){case"pre":e.push(o);break;case"post":n.push(o);break;default:r.push(o)}return{pre:e,post:n,normal:r}}var es=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],Xr={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function Zx(t,e){const n=t.indexOf("\x1B",e);if(n!==-1&&t[n+1]==="["){const r=t.indexOf("m",n);if(r!==-1)return{sequence:t.substring(n+2,r).split(";"),startPosition:n,position:r+1}}return{position:t.length}}function qi(t){const e=t.shift();if(e==="2"){const n=t.splice(0,3).map(r=>Number.parseInt(r));return n.length!==3||n.some(r=>Number.isNaN(r))?void 0:{type:"rgb",rgb:n}}else if(e==="5"){const n=t.shift();if(n)return{type:"table",index:Number(n)}}}function eb(t){const e=[];for(;t.length>0;){const n=t.shift();if(!n)continue;const r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)e.push({type:"resetAll"});else if(r<=9)Xr[r]&&e.push({type:"setDecoration",value:Xr[r]});else if(r<=29){const o=Xr[r-20];o&&(e.push({type:"resetDecoration",value:o}),o==="dim"&&e.push({type:"resetDecoration",value:"bold"}))}else if(r<=37)e.push({type:"setForegroundColor",value:{type:"named",name:es[r-30]}});else if(r===38){const o=qi(t);o&&e.push({type:"setForegroundColor",value:o})}else if(r===39)e.push({type:"resetForegroundColor"});else if(r<=47)e.push({type:"setBackgroundColor",value:{type:"named",name:es[r-40]}});else if(r===48){const o=qi(t);o&&e.push({type:"setBackgroundColor",value:o})}else r===49?e.push({type:"resetBackgroundColor"}):r===53?e.push({type:"setDecoration",value:"overline"}):r===55?e.push({type:"resetDecoration",value:"overline"}):r>=90&&r<=97?e.push({type:"setForegroundColor",value:{type:"named",name:es[r-90+8]}}):r>=100&&r<=107&&e.push({type:"setBackgroundColor",value:{type:"named",name:es[r-100+8]}})}return e}function tb(){let t=null,e=null,n=new Set;return{parse(r){const o=[];let a=0;do{const i=Zx(r,a),l=i.sequence?r.substring(a,i.startPosition):r.substring(a);if(l.length>0&&o.push({value:l,foreground:t,background:e,decorations:new Set(n)}),i.sequence){const c=eb(i.sequence);for(const d of c)d.type==="resetAll"?(t=null,e=null,n.clear()):d.type==="resetForegroundColor"?t=null:d.type==="resetBackgroundColor"?e=null:d.type==="resetDecoration"&&n.delete(d.value);for(const d of c)d.type==="setForegroundColor"?t=d.value:d.type==="setBackgroundColor"?e=d.value:d.type==="setDecoration"&&n.add(d.value)}a=i.position}while(a<r.length);return o}}}var sb={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function nb(t=sb){function e(l){return t[l]}function n(l){return`#${l.map(c=>Math.max(0,Math.min(c,255)).toString(16).padStart(2,"0")).join("")}`}let r;function o(){if(r)return r;r=[];for(let d=0;d<es.length;d++)r.push(e(es[d]));let l=[0,95,135,175,215,255];for(let d=0;d<6;d++)for(let p=0;p<6;p++)for(let m=0;m<6;m++)r.push(n([l[d],l[p],l[m]]));let c=8;for(let d=0;d<24;d++,c+=10)r.push(n([c,c,c]));return r}function a(l){return o()[l]}function i(l){switch(l.type){case"named":return e(l.name);case"rgb":return n(l.rgb);case"table":return a(l.index)}}return{value:i}}const rb={black:"#000000",red:"#cd3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#FFFFFF"};function ob(t,e,n){const r=sr(t,n),o=vr(e),a=Object.fromEntries(es.map(c=>{const d=`terminal.ansi${c[0].toUpperCase()}${c.substring(1)}`,p=t.colors?.[d];return[c,p||rb[c]]})),i=nb(a),l=tb();return o.map(c=>l.parse(c[0]).map(d=>{let p,m;d.decorations.has("reverse")?(p=d.background?i.value(d.background):t.bg,m=d.foreground?i.value(d.foreground):t.fg):(p=d.foreground?i.value(d.foreground):t.fg,m=d.background?i.value(d.background):void 0),p=Bt(p,r),m=Bt(m,r),d.decorations.has("dim")&&(p=ab(p));let h=tt.None;return d.decorations.has("bold")&&(h|=tt.Bold),d.decorations.has("italic")&&(h|=tt.Italic),d.decorations.has("underline")&&(h|=tt.Underline),d.decorations.has("strikethrough")&&(h|=tt.Strikethrough),{content:d.value,offset:c[1],color:p,bgColor:m,fontStyle:h}}))}function ab(t){const e=t.match(/#([0-9a-f]{3,8})/i);if(e){const r=e[1];if(r.length===8){const o=Math.round(Number.parseInt(r.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${r.slice(0,6)}${o}`}else{if(r.length===6)return`#${r}80`;if(r.length===4){const o=r[0],a=r[1],i=r[2],l=r[3],c=Math.round(Number.parseInt(`${l}${l}`,16)/2).toString(16).padStart(2,"0");return`#${o}${o}${a}${a}${i}${i}${c}`}else if(r.length===3){const o=r[0],a=r[1],i=r[2];return`#${o}${o}${a}${a}${i}${i}80`}}}const n=t.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return n?`var(${n[1]}-dim)`:t}function Da(t,e,n={}){const{theme:r=t.getLoadedThemes()[0]}=n,o=t.resolveLangAlias(n.lang||"text");if(Ma(o)||La(r))return vr(e).map(c=>[{content:c[0],offset:c[1]}]);const{theme:a,colorMap:i}=t.setTheme(r);if(o==="ansi")return ob(a,e,n);const l=t.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==l.name)throw new Ve(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${l.name}"`);if(!n.grammarState.themes.includes(a.name))throw new Ve(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${a.name}"`)}return cb(e,l,a,i,n)}function ib(...t){if(t.length===2)return ln(t[1]);const[e,n,r={}]=t,{lang:o="text",theme:a=e.getLoadedThemes()[0]}=r;if(Ma(o)||La(a))throw new Ve("Plain language does not have grammar state");if(o==="ansi")throw new Ve("ANSI language does not have grammar state");const{theme:i,colorMap:l}=e.setTheme(a),c=e.getLanguage(o);return new Ds($a(n,c,i,l,r).stateStack,c.name,i.name)}function cb(t,e,n,r,o){const a=$a(t,e,n,r,o),i=new Ds(a.stateStack,e.name,n.name);return wr(a.tokens,i),a.tokens}function $a(t,e,n,r,o){const a=sr(n,o),{tokenizeMaxLineLength:i=0,tokenizeTimeLimit:l=500}=o,c=vr(t);let d=o.grammarState?Kx(o.grammarState,n.name)??qo:o.grammarContextCode!=null?$a(o.grammarContextCode,e,n,r,{...o,grammarState:void 0,grammarContextCode:void 0}).stateStack:qo,p=[];const m=[];for(let h=0,g=c.length;h<g;h++){const[f,x]=c[h];if(f===""){p=[],m.push([]);continue}if(i>0&&f.length>=i){p=[],m.push([{content:f,offset:x,color:"",fontStyle:0}]);continue}let b,y,v;o.includeExplanation&&(b=e.tokenizeLine(f,d,l),y=b.tokens,v=0);const w=e.tokenizeLine2(f,d,l),N=w.tokens.length/2;for(let S=0;S<N;S++){const T=w.tokens[2*S],C=S+1<N?w.tokens[2*S+2]:f.length;if(T===C)continue;const j=w.tokens[2*S+1],E=Bt(r[Ts.getForeground(j)],a),A=Ts.getFontStyle(j),L={content:f.substring(T,C),offset:x+T,color:E,fontStyle:A};if(o.includeExplanation){const $=[];if(o.includeExplanation!=="scopeName")for(const ne of n.settings){let B;switch(typeof ne.scope){case"string":B=ne.scope.split(/,/).map(Q=>Q.trim());break;case"object":B=ne.scope;break;default:continue}$.push({settings:ne,selectors:B.map(Q=>Q.split(/ /))})}L.explanation=[];let oe=0;for(;T+oe<C;){const ne=y[v],B=f.substring(ne.startIndex,ne.endIndex);oe+=B.length,L.explanation.push({content:B,scopes:o.includeExplanation==="scopeName"?lb(ne.scopes):db($,ne.scopes)}),v+=1}}p.push(L)}m.push(p),p=[],d=w.ruleStack}return{tokens:m,stateStack:d}}function lb(t){return t.map(e=>({scopeName:e}))}function db(t,e){const n=[];for(let r=0,o=e.length;r<o;r++){const a=e[r];n[r]={scopeName:a,themeMatches:pb(t,a,e.slice(0,r))}}return n}function Wi(t,e){return t===e||e.substring(0,t.length)===t&&e[t.length]==="."}function ub(t,e,n){if(!Wi(t[t.length-1],e))return!1;let r=t.length-2,o=n.length-1;for(;r>=0&&o>=0;)Wi(t[r],n[o])&&(r-=1),o-=1;return r===-1}function pb(t,e,n){const r=[];for(const{selectors:o,settings:a}of t)for(const i of o)if(ub(i,e,n)){r.push(a);break}return r}function qd(t,e,n){const r=Object.entries(n.themes).filter(c=>c[1]).map(c=>({color:c[0],theme:c[1]})),o=r.map(c=>{const d=Da(t,e,{...n,theme:c.theme}),p=ln(d),m=typeof c.theme=="string"?c.theme:c.theme.name;return{tokens:d,state:p,theme:m}}),a=mb(...o.map(c=>c.tokens)),i=a[0].map((c,d)=>c.map((p,m)=>{const h={content:p.content,variants:{},offset:p.offset};return"includeExplanation"in n&&n.includeExplanation&&(h.explanation=p.explanation),a.forEach((g,f)=>{const{content:x,explanation:b,offset:y,...v}=g[d][m];h.variants[r[f].color]=v}),h})),l=o[0].state?new Ds(Object.fromEntries(o.map(c=>[c.theme,c.state?.getInternalStack(c.theme)])),o[0].state.lang):void 0;return l&&wr(i,l),i}function mb(...t){const e=t.map(()=>[]),n=t.length;for(let r=0;r<t[0].length;r++){const o=t.map(c=>c[r]),a=e.map(()=>[]);e.forEach((c,d)=>c.push(a[d]));const i=o.map(()=>0),l=o.map(c=>c[0]);for(;l.every(c=>c);){const c=Math.min(...l.map(d=>d.content.length));for(let d=0;d<n;d++){const p=l[d];p.content.length===c?(a[d].push(p),i[d]+=1,l[d]=o[d][i[d]]):(a[d].push({...p,content:p.content.slice(0,c)}),l[d]={...p,content:p.content.slice(c),offset:p.offset+c})}}}return e}function or(t,e,n){let r,o,a,i,l,c;if("themes"in n){const{defaultColor:d="light",cssVariablePrefix:p="--shiki-",colorsRendering:m="css-vars"}=n,h=Object.entries(n.themes).filter(y=>y[1]).map(y=>({color:y[0],theme:y[1]})).sort((y,v)=>y.color===d?-1:v.color===d?1:0);if(h.length===0)throw new Ve("`themes` option must not be empty");const g=qd(t,e,n);if(c=ln(g),d&&Oa!==d&&!h.find(y=>y.color===d))throw new Ve(`\`themes\` option must contain the defaultColor key \`${d}\``);const f=h.map(y=>t.getTheme(y.theme)),x=h.map(y=>y.color);a=g.map(y=>y.map(v=>qx(v,x,p,d,m))),c&&wr(a,c);const b=h.map(y=>sr(y.theme,n));o=Ki(h,f,b,p,d,"fg",m),r=Ki(h,f,b,p,d,"bg",m),i=`shiki-themes ${f.map(y=>y.name).join(" ")}`,l=d?void 0:[o,r].join(";")}else if("theme"in n){const d=sr(n.theme,n);a=Da(t,e,n);const p=t.getTheme(n.theme);r=Bt(p.bg,d),o=Bt(p.fg,d),i=p.name,c=ln(a)}else throw new Ve("Invalid options, either `theme` or `themes` must be provided");return{tokens:a,fg:o,bg:r,themeName:i,rootStyle:l,grammarState:c}}function Ki(t,e,n,r,o,a,i){return t.map((l,c)=>{const d=Bt(e[c][a],n[c])||"inherit",p=`${r+l.color}${a==="bg"?"-bg":""}:${d}`;if(c===0&&o){if(o===Oa&&t.length>1){const m=t.findIndex(x=>x.color==="light"),h=t.findIndex(x=>x.color==="dark");if(m===-1||h===-1)throw new Ve('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');const g=Bt(e[m][a],n[m])||"inherit",f=Bt(e[h][a],n[h])||"inherit";return`light-dark(${g}, ${f});${p}`}return d}return i==="css-vars"?p:null}).filter(l=>!!l).join(";")}function ar(t,e,n,r={meta:{},options:n,codeToHast:(o,a)=>ar(t,o,a),codeToTokens:(o,a)=>or(t,o,a)}){let o=e;for(const f of rr(n))o=f.preprocess?.call(r,o,n)||o;let{tokens:a,fg:i,bg:l,themeName:c,rootStyle:d,grammarState:p}=or(t,o,n);const{mergeWhitespaces:m=!0,mergeSameStyleTokens:h=!1}=n;m===!0?a=fb(a):m==="never"&&(a=gb(a)),h&&(a=xb(a));const g={...r,get source(){return o}};for(const f of rr(n))a=f.tokens?.call(g,a)||a;return hb(a,{...n,fg:i,bg:l,themeName:c,rootStyle:n.rootStyle===!1?!1:n.rootStyle??d},g,p)}function hb(t,e,n,r=ln(t)){const o=rr(e),a=[],i={type:"root",children:[]},{structure:l="classic",tabindex:c="0"}=e,d={class:`shiki ${e.themeName||""}`};e.rootStyle!==!1&&(e.rootStyle!=null?d.style=e.rootStyle:d.style=`background-color:${e.bg};color:${e.fg}`),c!==!1&&c!=null&&(d.tabindex=c.toString());for(const[x,b]of Object.entries(e.meta||{}))x.startsWith("_")||(d[x]=b);let p={type:"element",tagName:"pre",properties:d,children:[],data:e.data},m={type:"element",tagName:"code",properties:{},children:a};const h=[],g={...n,structure:l,addClassToHast:Ud,get source(){return n.source},get tokens(){return t},get options(){return e},get root(){return i},get pre(){return p},get code(){return m},get lines(){return h}};if(t.forEach((x,b)=>{b&&(l==="inline"?i.children.push({type:"element",tagName:"br",properties:{},children:[]}):l==="classic"&&a.push({type:"text",value:`
|
|
24
24
|
`}));let y={type:"element",tagName:"span",properties:{class:"line"},children:[]},v=0;for(const w of x){let N={type:"element",tagName:"span",properties:{...w.htmlAttrs},children:[{type:"text",value:w.content}]};const S=Wo(w.htmlStyle||nr(w));S&&(N.properties.style=S);for(const T of o)N=T?.span?.call(g,N,b+1,v,y,w)||N;l==="inline"?i.children.push(N):l==="classic"&&y.children.push(N),v+=w.content.length}if(l==="classic"){for(const w of o)y=w?.line?.call(g,y,b+1)||y;h.push(y),a.push(y)}else l==="inline"&&h.push(y)}),l==="classic"){for(const x of o)m=x?.code?.call(g,m)||m;p.children.push(m);for(const x of o)p=x?.pre?.call(g,p)||p;i.children.push(p)}else if(l==="inline"){const x=[];let b={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(const w of i.children)w.type==="element"&&w.tagName==="br"?(x.push(b),b={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(w.type==="element"||w.type==="text")&&b.children.push(w);x.push(b);let v={type:"element",tagName:"code",properties:{},children:x};for(const w of o)v=w?.code?.call(g,v)||v;i.children=[];for(let w=0;w<v.children.length;w++){w>0&&i.children.push({type:"element",tagName:"br",properties:{},children:[]});const N=v.children[w];N.type==="element"&&i.children.push(...N.children)}}let f=i;for(const x of o)f=x?.root?.call(g,f)||f;return r&&wr(f,r),f}function fb(t){return t.map(e=>{const n=[];let r="",o;return e.forEach((a,i)=>{const c=!(a.fontStyle&&(a.fontStyle&tt.Underline||a.fontStyle&tt.Strikethrough));c&&a.content.match(/^\s+$/)&&e[i+1]?(o===void 0&&(o=a.offset),r+=a.content):r?(c?n.push({...a,offset:o,content:r+a.content}):n.push({content:r,offset:o},a),o=void 0,r=""):n.push(a)}),n})}function gb(t){return t.map(e=>e.flatMap(n=>{if(n.content.match(/^\s+$/))return n;const r=n.content.match(/^(\s*)(.*?)(\s*)$/);if(!r)return n;const[,o,a,i]=r;if(!o&&!i)return n;const l=[{...n,offset:n.offset+o.length,content:a}];return o&&l.unshift({content:o,offset:n.offset}),i&&l.push({content:i,offset:n.offset+o.length+a.length}),l}))}function xb(t){return t.map(e=>{const n=[];for(const r of e){if(n.length===0){n.push({...r});continue}const o=n[n.length-1],a=Wo(o.htmlStyle||nr(o)),i=Wo(r.htmlStyle||nr(r)),l=o.fontStyle&&(o.fontStyle&tt.Underline||o.fontStyle&tt.Strikethrough),c=r.fontStyle&&(r.fontStyle&tt.Underline||r.fontStyle&tt.Strikethrough);!l&&!c&&a===i?o.content+=r.content:n.push({...r})}return n})}const bb=Zm;function yb(t,e,n){const r={meta:{},options:n,codeToHast:(a,i)=>ar(t,a,i),codeToTokens:(a,i)=>or(t,a,i)};let o=bb(ar(t,e,n,r));for(const a of rr(n))o=a.postprocess?.call(r,o,n)||o;return o}const Qi={light:"#333333",dark:"#bbbbbb"},Yi={light:"#fffffe",dark:"#1e1e1e"},Ji="__shiki_resolved";function za(t){if(t?.[Ji])return t;const e={...t};e.tokenColors&&!e.settings&&(e.settings=e.tokenColors,delete e.tokenColors),e.type||="dark",e.colorReplacements={...e.colorReplacements},e.settings||=[];let{bg:n,fg:r}=e;if(!n||!r){const l=e.settings?e.settings.find(c=>!c.name&&!c.scope):void 0;l?.settings?.foreground&&(r=l.settings.foreground),l?.settings?.background&&(n=l.settings.background),!r&&e?.colors?.["editor.foreground"]&&(r=e.colors["editor.foreground"]),!n&&e?.colors?.["editor.background"]&&(n=e.colors["editor.background"]),r||(r=e.type==="light"?Qi.light:Qi.dark),n||(n=e.type==="light"?Yi.light:Yi.dark),e.fg=r,e.bg=n}e.settings[0]&&e.settings[0].settings&&!e.settings[0].scope||e.settings.unshift({settings:{foreground:e.fg,background:e.bg}});let o=0;const a=new Map;function i(l){if(a.has(l))return a.get(l);o+=1;const c=`#${o.toString(16).padStart(8,"0").toLowerCase()}`;return e.colorReplacements?.[`#${c}`]?i(l):(a.set(l,c),c)}e.settings=e.settings.map(l=>{const c=l.settings?.foreground&&!l.settings.foreground.startsWith("#"),d=l.settings?.background&&!l.settings.background.startsWith("#");if(!c&&!d)return l;const p={...l,settings:{...l.settings}};if(c){const m=i(l.settings.foreground);e.colorReplacements[m]=l.settings.foreground,p.settings.foreground=m}if(d){const m=i(l.settings.background);e.colorReplacements[m]=l.settings.background,p.settings.background=m}return p});for(const l of Object.keys(e.colors||{}))if((l==="editor.foreground"||l==="editor.background"||l.startsWith("terminal.ansi"))&&!e.colors[l]?.startsWith("#")){const c=i(e.colors[l]);e.colorReplacements[c]=e.colors[l],e.colors[l]=c}return Object.defineProperty(e,Ji,{enumerable:!1,writable:!1,value:!0}),e}async function Wd(t){return Array.from(new Set((await Promise.all(t.filter(e=>!Vd(e)).map(async e=>await Fd(e).then(n=>Array.isArray(n)?n:[n])))).flat()))}async function Kd(t){return(await Promise.all(t.map(async n=>Bd(n)?null:za(await Fd(n))))).filter(n=>!!n)}let vb=3;function wb(t,e=3){e>vb||console.trace(`[SHIKI DEPRECATE]: ${t}`)}let ks=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function Qd(t,e){if(!e)return t;if(e[t]){const n=new Set([t]);for(;e[t];){if(t=e[t],n.has(t))throw new ks(`Circular alias \`${Array.from(n).join(" -> ")} -> ${t}\``);n.add(t)}}return t}class _b extends zx{constructor(e,n,r,o={}){super(e),this._resolver=e,this._themes=n,this._langs=r,this._alias=o,this._themes.map(a=>this.loadTheme(a)),this.loadLanguages(this._langs)}_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;getTheme(e){return typeof e=="string"?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){const n=za(e);return n.name&&(this._resolvedThemes.set(n.name,n),this._loadedThemesCache=null),n}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(e){let n=this._textmateThemeCache.get(e);n||(n=Jn.createFromRawTheme(e),this._textmateThemeCache.set(e,n)),this._syncRegistry.setTheme(n)}getGrammar(e){return e=Qd(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;const n=new Set([...this._langMap.values()].filter(a=>a.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);const r={balancedBracketSelectors:e.balancedBracketSelectors||["*"],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);const o=this.loadGrammarWithConfiguration(e.scopeName,1,r);if(o.name=e.name,this._resolvedGrammars.set(e.name,o),e.aliases&&e.aliases.forEach(a=>{this._alias[a]=e.name}),this._loadedLanguagesCache=null,n.size)for(const a of n)this._resolvedGrammars.delete(a.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(a.scopeName),this._syncRegistry?._grammars?.delete(a.scopeName),this.loadLanguage(this._langMap.get(a.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(const o of e)this.resolveEmbeddedLanguages(o);const n=Array.from(this._langGraph.entries()),r=n.filter(([o,a])=>!a);if(r.length){const o=n.filter(([a,i])=>i?(i.embeddedLanguages||i.embeddedLangs)?.some(c=>r.map(([d])=>d).includes(c)):!1).filter(a=>!r.includes(a));throw new ks(`Missing languages ${r.map(([a])=>`\`${a}\``).join(", ")}, required by ${o.map(([a])=>`\`${a}\``).join(", ")}`)}for(const[o,a]of n)this._resolver.addLanguage(a);for(const[o,a]of n)this.loadLanguage(a)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);const n=e.embeddedLanguages??e.embeddedLangs;if(n)for(const r of n)this._langGraph.set(r,this._langMap.get(r))}}class kb{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,n){this._onigLib={createOnigScanner:r=>e.createScanner(r),createOnigString:r=>e.createString(r)},n.forEach(r=>this.addLanguage(r))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(n=>{this._langs.set(n,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(n=>{this._injections.get(n)||this._injections.set(n,[]),this._injections.get(n).push(e.scopeName)})}getInjections(e){const n=e.split(".");let r=[];for(let o=1;o<=n.length;o++){const a=n.slice(0,o).join(".");r=[...r,...this._injections.get(a)||[]]}return r}}let Gs=0;function jb(t){Gs+=1,t.warnings!==!1&&Gs>=10&&Gs%10===0&&console.warn(`[Shiki] ${Gs} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let e=!1;if(!t.engine)throw new ks("`engine` option is required for synchronous mode");const n=(t.langs||[]).flat(1),r=(t.themes||[]).flat(1).map(za),o=new kb(t.engine,n),a=new _b(o,r,n,t.langAlias);let i;function l(w){return Qd(w,t.langAlias)}function c(w){y();const N=a.getGrammar(typeof w=="string"?w:w.name);if(!N)throw new ks(`Language \`${w}\` not found, you may need to load it first`);return N}function d(w){if(w==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};y();const N=a.getTheme(w);if(!N)throw new ks(`Theme \`${w}\` not found, you may need to load it first`);return N}function p(w){y();const N=d(w);i!==w&&(a.setTheme(N),i=w);const S=a.getColorMap();return{theme:N,colorMap:S}}function m(){return y(),a.getLoadedThemes()}function h(){return y(),a.getLoadedLanguages()}function g(...w){y(),a.loadLanguages(w.flat(1))}async function f(...w){return g(await Wd(w))}function x(...w){y();for(const N of w.flat(1))a.loadTheme(N)}async function b(...w){return y(),x(await Kd(w))}function y(){if(e)throw new ks("Shiki instance has been disposed")}function v(){e||(e=!0,a.dispose(),Gs-=1)}return{setTheme:p,getTheme:d,getLanguage:c,getLoadedThemes:m,getLoadedLanguages:h,resolveLangAlias:l,loadLanguage:f,loadLanguageSync:g,loadTheme:b,loadThemeSync:x,dispose:v,[Symbol.dispose]:v}}async function Nb(t){t.engine||wb("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");const[e,n,r]=await Promise.all([Kd(t.themes||[]),Wd(t.langs||[]),t.engine]);return jb({...t,themes:e,langs:n,engine:r})}async function Sb(t){const e=await Nb(t);return{getLastGrammarState:(...n)=>ib(e,...n),codeToTokensBase:(n,r)=>Da(e,n,r),codeToTokensWithThemes:(n,r)=>qd(e,n,r),codeToTokens:(n,r)=>or(e,n,r),codeToHast:(n,r)=>ar(e,n,r),codeToHtml:(n,r)=>yb(e,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...e,getInternalContext:()=>e}}function Cb(t){const e=t.langs,n=t.themes,r=t.engine;async function o(a){function i(m){if(typeof m=="string"){if(m=a.langAlias?.[m]||m,Vd(m))return[];const h=e[m];if(!h)throw new Ve(`Language \`${m}\` is not included in this bundle. You may want to load it from external source.`);return h}return m}function l(m){if(Bd(m))return"none";if(typeof m=="string"){const h=n[m];if(!h)throw new Ve(`Theme \`${m}\` is not included in this bundle. You may want to load it from external source.`);return h}return m}const c=(a.themes??[]).map(m=>l(m)),d=(a.langs??[]).map(m=>i(m)),p=await Sb({engine:a.engine??r(),...a,themes:c,langs:d});return{...p,loadLanguage(...m){return p.loadLanguage(...m.map(i))},loadTheme(...m){return p.loadTheme(...m.map(l))},getBundledLanguages(){return e},getBundledThemes(){return n}}}return o}function Eb(t){let e;async function n(r={}){if(e){const o=await e;return await Promise.all([o.loadTheme(...r.themes||[]),o.loadLanguage(...r.langs||[])]),o}else{e=t({...r,themes:[],langs:[]});const o=await e;return await Promise.all([o.loadTheme(...r.themes||[]),o.loadLanguage(...r.langs||[])]),o}}return n}function Tb(t,e){const n=Eb(t);async function r(o,a){const i=await n({langs:[a.lang],themes:"theme"in a?[a.theme]:Object.values(a.themes)}),l=await e?.guessEmbeddedLanguages?.(o,a.lang,i);return l&&await i.loadLanguage(...l),i}return{getSingletonHighlighter(o){return n(o)},async codeToHtml(o,a){return(await r(o,a)).codeToHtml(o,a)},async codeToHast(o,a){return(await r(o,a)).codeToHast(o,a)},async codeToTokens(o,a){return(await r(o,a)).codeToTokens(o,a)},async codeToTokensBase(o,a){return(await r(o,a)).codeToTokensBase(o,a)},async codeToTokensWithThemes(o,a){return(await r(o,a)).codeToTokensWithThemes(o,a)},async getLastGrammarState(o,a){return(await n({langs:[a.lang],themes:[a.theme]})).getLastGrammarState(o,a)}}}const Yd=[{id:"abap",name:"ABAP",import:(()=>_(()=>import("./abap-BdImnpbu.js"),[]))},{id:"actionscript-3",name:"ActionScript",import:(()=>_(()=>import("./actionscript-3-CoDkCxhg.js"),[]))},{id:"ada",name:"Ada",import:(()=>_(()=>import("./ada-bCR0ucgS.js"),[]))},{id:"angular-html",name:"Angular HTML",import:(()=>_(()=>import("./angular-html-CU67Zn6k.js").then(t=>t.f),__vite__mapDeps([0,1,2,3])))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>_(()=>import("./angular-ts-BwZT4LLn.js"),__vite__mapDeps([4,0,1,2,3,5])))},{id:"apache",name:"Apache Conf",import:(()=>_(()=>import("./apache-Pmp26Uib.js"),[]))},{id:"apex",name:"Apex",import:(()=>_(()=>import("./apex-D8_7TLub.js"),[]))},{id:"apl",name:"APL",import:(()=>_(()=>import("./apl-dKokRX4l.js"),__vite__mapDeps([6,1,2,3,7,8,9])))},{id:"applescript",name:"AppleScript",import:(()=>_(()=>import("./applescript-Co6uUVPk.js"),[]))},{id:"ara",name:"Ara",import:(()=>_(()=>import("./ara-BRHolxvo.js"),[]))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>_(()=>import("./asciidoc-Ve4PFQV2.js"),[]))},{id:"asm",name:"Assembly",import:(()=>_(()=>import("./asm-D_Q5rh1f.js"),[]))},{id:"astro",name:"Astro",import:(()=>_(()=>import("./astro-CbQHKStN.js"),__vite__mapDeps([10,9,2,11,3,12,13])))},{id:"awk",name:"AWK",import:(()=>_(()=>import("./awk-DMzUqQB5.js"),[]))},{id:"ballerina",name:"Ballerina",import:(()=>_(()=>import("./ballerina-BFfxhgS-.js"),[]))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>_(()=>import("./bat-BkioyH1T.js"),[]))},{id:"beancount",name:"Beancount",import:(()=>_(()=>import("./beancount-k_qm7-4y.js"),[]))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>_(()=>import("./berry-uYugtg8r.js"),[]))},{id:"bibtex",name:"BibTeX",import:(()=>_(()=>import("./bibtex-CHM0blh-.js"),[]))},{id:"bicep",name:"Bicep",import:(()=>_(()=>import("./bicep-Bmn6On1c.js"),[]))},{id:"bird2",name:"BIRD2 Configuration",aliases:["bird"],import:(()=>_(()=>import("./bird2-DPOp833l.js"),[]))},{id:"blade",name:"Blade",import:(()=>_(()=>import("./blade-D4QpJJKB.js"),__vite__mapDeps([14,15,1,2,3,7,8,16,9])))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>_(()=>import("./bsl-BO_Y6i37.js"),__vite__mapDeps([17,18])))},{id:"c",name:"C",import:(()=>_(()=>import("./c-BIGW1oBm.js"),[]))},{id:"c3",name:"C3",import:(()=>_(()=>import("./c3-eo99z4R2.js"),[]))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>_(()=>import("./cadence-Bv_4Rxtq.js"),[]))},{id:"cairo",name:"Cairo",import:(()=>_(()=>import("./cairo-KRGpt6FW.js"),__vite__mapDeps([19,20])))},{id:"clarity",name:"Clarity",import:(()=>_(()=>import("./clarity-D53aC0YG.js"),[]))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>_(()=>import("./clojure-P80f7IUj.js"),[]))},{id:"cmake",name:"CMake",import:(()=>_(()=>import("./cmake-D1j8_8rp.js"),[]))},{id:"cobol",name:"COBOL",import:(()=>_(()=>import("./cobol-nwyudZeR.js"),__vite__mapDeps([21,1,2,3,8])))},{id:"codeowners",name:"CODEOWNERS",import:(()=>_(()=>import("./codeowners-Bp6g37R7.js"),[]))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>_(()=>import("./codeql-DsOJ9woJ.js"),[]))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>_(()=>import("./coffee-Ch7k5sss.js"),__vite__mapDeps([22,2])))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>_(()=>import("./common-lisp-Cg-RD9OK.js"),[]))},{id:"coq",name:"Coq",import:(()=>_(()=>import("./coq-DkFqJrB1.js"),[]))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>_(()=>import("./cpp-CofmeUqb.js"),__vite__mapDeps([23,24,25,26,16])))},{id:"crystal",name:"Crystal",import:(()=>_(()=>import("./crystal-tKQVLTB8.js"),__vite__mapDeps([27,1,2,3,16,26,28])))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>_(()=>import("./csharp-COcwbKMJ.js"),[]))},{id:"css",name:"CSS",import:(()=>_(()=>import("./css-DPfMkruS.js"),[]))},{id:"csv",name:"CSV",import:(()=>_(()=>import("./csv-fuZLfV_i.js"),[]))},{id:"cue",name:"CUE",import:(()=>_(()=>import("./cue-D82EKSYY.js"),[]))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>_(()=>import("./cypher-COkxafJQ.js"),[]))},{id:"d",name:"D",import:(()=>_(()=>import("./d-85-TOEBH.js"),[]))},{id:"dart",name:"Dart",import:(()=>_(()=>import("./dart-CF10PKvl.js"),[]))},{id:"dax",name:"DAX",import:(()=>_(()=>import("./dax-CEL-wOlO.js"),[]))},{id:"desktop",name:"Desktop",import:(()=>_(()=>import("./desktop-BmXAJ9_W.js"),[]))},{id:"diff",name:"Diff",import:(()=>_(()=>import("./diff-D97Zzqfu.js"),[]))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>_(()=>import("./docker-BcOcwvcX.js"),[]))},{id:"dotenv",name:"dotEnv",import:(()=>_(()=>import("./dotenv-Da5cRb03.js"),[]))},{id:"dream-maker",name:"Dream Maker",import:(()=>_(()=>import("./dream-maker-BtqSS_iP.js"),[]))},{id:"edge",name:"Edge",import:(()=>_(()=>import("./edge-BkV0erSs.js"),__vite__mapDeps([29,11,1,2,3,15])))},{id:"elixir",name:"Elixir",import:(()=>_(()=>import("./elixir-CDX3lj18.js"),__vite__mapDeps([30,1,2,3])))},{id:"elm",name:"Elm",import:(()=>_(()=>import("./elm-DbKCFpqz.js"),__vite__mapDeps([31,25,26])))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>_(()=>import("./emacs-lisp-C9XAeP06.js"),[]))},{id:"erb",name:"ERB",import:(()=>_(()=>import("./erb-B12qg9BL.js"),__vite__mapDeps([32,1,2,3,33,34,7,8,16,35,11,36,13,23,24,25,26,28,37,38])))},{id:"erlang",name:"Erlang",aliases:["erl"],import:(()=>_(()=>import("./erlang-DsQrWhSR.js"),__vite__mapDeps([39,40])))},{id:"fennel",name:"Fennel",import:(()=>_(()=>import("./fennel-BYunw83y.js"),[]))},{id:"fish",name:"Fish",import:(()=>_(()=>import("./fish-BvzEVeQv.js"),[]))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>_(()=>import("./fluent-C4IJs8-o.js"),[]))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>_(()=>import("./fortran-fixed-form-CkoXwp7k.js"),__vite__mapDeps([41,42])))},{id:"fortran-free-form",name:"Fortran (Free Form)",aliases:["f90","f95","f03","f08","f18"],import:(()=>_(()=>import("./fortran-free-form-BxgE0vQu.js"),[]))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>_(()=>import("./fsharp-CXgrBDvD.js"),__vite__mapDeps([43,40])))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>_(()=>import("./gdresource-BOOCDP_w.js"),__vite__mapDeps([44,45,46])))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>_(()=>import("./gdscript-C5YyOfLZ.js"),[]))},{id:"gdshader",name:"GDShader",import:(()=>_(()=>import("./gdshader-DkwncUOv.js"),[]))},{id:"genie",name:"Genie",import:(()=>_(()=>import("./genie-D0YGMca9.js"),[]))},{id:"gherkin",name:"Gherkin",import:(()=>_(()=>import("./gherkin-DyxjwDmM.js"),[]))},{id:"git-commit",name:"Git Commit Message",import:(()=>_(()=>import("./git-commit-F4YmCXRG.js"),__vite__mapDeps([47,48])))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>_(()=>import("./git-rebase-r7XF79zn.js"),__vite__mapDeps([49,28])))},{id:"gleam",name:"Gleam",import:(()=>_(()=>import("./gleam-BspZqrRM.js"),[]))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>_(()=>import("./glimmer-js-Rg0-pVw9.js"),__vite__mapDeps([50,2,11,3,1])))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>_(()=>import("./glimmer-ts-U6CK756n.js"),__vite__mapDeps([51,11,3,2,1])))},{id:"glsl",name:"GLSL",import:(()=>_(()=>import("./glsl-DplSGwfg.js"),__vite__mapDeps([25,26])))},{id:"gn",name:"GN",import:(()=>_(()=>import("./gn-n2N0HUVH.js"),[]))},{id:"gnuplot",name:"Gnuplot",import:(()=>_(()=>import("./gnuplot-DdkO51Og.js"),[]))},{id:"go",name:"Go",import:(()=>_(()=>import("./go-CxLEBnE3.js"),[]))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>_(()=>import("./graphql-ChdNCCLP.js"),__vite__mapDeps([35,2,11,36,13])))},{id:"groovy",name:"Groovy",import:(()=>_(()=>import("./groovy-gcz8RCvz.js"),[]))},{id:"hack",name:"Hack",import:(()=>_(()=>import("./hack-CaT9iCJl.js"),__vite__mapDeps([52,1,2,3,16])))},{id:"haml",name:"Ruby Haml",import:(()=>_(()=>import("./haml-B8DHNrY2.js"),__vite__mapDeps([34,2,3])))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>_(()=>import("./handlebars-BL8al0AC.js"),__vite__mapDeps([53,1,2,3,38])))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>_(()=>import("./haskell-Df6bDoY_.js"),[]))},{id:"haxe",name:"Haxe",import:(()=>_(()=>import("./haxe-CzTSHFRz.js"),[]))},{id:"hcl",name:"HashiCorp HCL",import:(()=>_(()=>import("./hcl-BWvSN4gD.js"),[]))},{id:"hjson",name:"Hjson",import:(()=>_(()=>import("./hjson-D5-asLiD.js"),[]))},{id:"hlsl",name:"HLSL",import:(()=>_(()=>import("./hlsl-D3lLCCz7.js"),[]))},{id:"html",name:"HTML",import:(()=>_(()=>import("./html-GMplVEZG.js"),__vite__mapDeps([1,2,3])))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>_(()=>import("./html-derivative-BFtXZ54Q.js"),__vite__mapDeps([15,1,2,3])))},{id:"http",name:"HTTP",import:(()=>_(()=>import("./http-jrhK8wxY.js"),__vite__mapDeps([54,28,9,7,8,35,2,11,36,13])))},{id:"hurl",name:"Hurl",import:(()=>_(()=>import("./hurl-irOxFIW8.js"),__vite__mapDeps([55,35,2,11,36,13,7,8,56])))},{id:"hxml",name:"HXML",import:(()=>_(()=>import("./hxml-Bvhsp5Yf.js"),__vite__mapDeps([57,58])))},{id:"hy",name:"Hy",import:(()=>_(()=>import("./hy-DFXneXwc.js"),[]))},{id:"imba",name:"Imba",import:(()=>_(()=>import("./imba-DGztddWO.js"),[]))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>_(()=>import("./ini-BEwlwnbL.js"),[]))},{id:"java",name:"Java",import:(()=>_(()=>import("./java-CylS5w8V.js"),[]))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>_(()=>import("./javascript-wDzz0qaB.js"),[]))},{id:"jinja",name:"Jinja",import:(()=>_(()=>import("./jinja-4LBKfQ-Z.js"),__vite__mapDeps([59,1,2,3])))},{id:"jison",name:"Jison",import:(()=>_(()=>import("./jison-wvAkD_A8.js"),__vite__mapDeps([60,2])))},{id:"json",name:"JSON",import:(()=>_(()=>import("./json-Cp-IABpG.js"),[]))},{id:"json5",name:"JSON5",import:(()=>_(()=>import("./json5-C9tS-k6U.js"),[]))},{id:"jsonc",name:"JSON with Comments",import:(()=>_(()=>import("./jsonc-Des-eS-w.js"),[]))},{id:"jsonl",name:"JSON Lines",import:(()=>_(()=>import("./jsonl-DcaNXYhu.js"),[]))},{id:"jsonnet",name:"Jsonnet",import:(()=>_(()=>import("./jsonnet-DFQXde-d.js"),[]))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>_(()=>import("./jssm-C2t-YnRu.js"),[]))},{id:"jsx",name:"JSX",import:(()=>_(()=>import("./jsx-g9-lgVsj.js"),[]))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>_(()=>import("./julia-CxzCAyBv.js"),__vite__mapDeps([61,23,24,25,26,16,20,2,62])))},{id:"just",name:"Just",import:(()=>_(()=>import("./just-Cw27pwNe.js"),__vite__mapDeps([63,28,2,11,64,1,3,7,8,16,20,33,34,35,36,13,23,24,25,26,37,38])))},{id:"kdl",name:"KDL",import:(()=>_(()=>import("./kdl-DV7GczEv.js"),[]))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>_(()=>import("./kotlin-BdnUsdx6.js"),[]))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>_(()=>import("./kusto-DZf3V79B.js"),[]))},{id:"latex",name:"LaTeX",import:(()=>_(()=>import("./latex-CWtU0Tv5.js"),__vite__mapDeps([65,66,62])))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>_(()=>import("./lean-BZvkOJ9d.js"),[]))},{id:"less",name:"Less",import:(()=>_(()=>import("./less-B1dDrJ26.js"),[]))},{id:"liquid",name:"Liquid",import:(()=>_(()=>import("./liquid-DYVedYrR.js"),__vite__mapDeps([67,1,2,3,9])))},{id:"llvm",name:"LLVM IR",import:(()=>_(()=>import("./llvm-DjAJT7YJ.js"),[]))},{id:"log",name:"Log file",import:(()=>_(()=>import("./log-2UxHyX5q.js"),[]))},{id:"logo",name:"Logo",import:(()=>_(()=>import("./logo-BtOb2qkB.js"),[]))},{id:"lua",name:"Lua",import:(()=>_(()=>import("./lua-BaeVxFsk.js"),__vite__mapDeps([37,26])))},{id:"luau",name:"Luau",import:(()=>_(()=>import("./luau-C-HG3fhB.js"),[]))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>_(()=>import("./make-CHLpvVh8.js"),[]))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>_(()=>import("./markdown-Cvjx9yec.js"),[]))},{id:"marko",name:"Marko",import:(()=>_(()=>import("./marko-CnJfTvn9.js"),__vite__mapDeps([68,3,69,5,11])))},{id:"matlab",name:"MATLAB",import:(()=>_(()=>import("./matlab-D7o27uSR.js"),[]))},{id:"mdc",name:"MDC",import:(()=>_(()=>import("./mdc-BMNejdWA.js"),__vite__mapDeps([70,40,38,15,1,2,3])))},{id:"mdx",name:"MDX",import:(()=>_(()=>import("./mdx-Cmh6b_Ma.js"),[]))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>_(()=>import("./mermaid-mWjccvbQ.js"),[]))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>_(()=>import("./mipsasm-CKIfxQSi.js"),[]))},{id:"mojo",name:"Mojo",import:(()=>_(()=>import("./mojo-rZm6bMo-.js"),[]))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>_(()=>import("./moonbit-_H4v1dQx.js"),[]))},{id:"move",name:"Move",import:(()=>_(()=>import("./move-IF9eRakj.js"),[]))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>_(()=>import("./narrat-DRg8JJMk.js"),[]))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>_(()=>import("./nextflow-Zz6hmt5N.js"),__vite__mapDeps([71,72])))},{id:"nextflow-groovy",name:"nextflow-groovy",import:(()=>_(()=>import("./nextflow-groovy-BeH2EWoN.js"),[]))},{id:"nginx",name:"Nginx",import:(()=>_(()=>import("./nginx-BpAMiNFr.js"),__vite__mapDeps([73,37,26])))},{id:"nim",name:"Nim",import:(()=>_(()=>import("./nim-CVrawwO9.js"),__vite__mapDeps([74,26,1,2,3,7,8,25,40])))},{id:"nix",name:"Nix",import:(()=>_(()=>import("./nix-CwoSXNpI.js"),[]))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>_(()=>import("./nushell-Cz2AlsmD.js"),[]))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>_(()=>import("./objective-c-DXmwc3jG.js"),[]))},{id:"objective-cpp",name:"Objective-C++",import:(()=>_(()=>import("./objective-cpp-CLxacb5B.js"),[]))},{id:"ocaml",name:"OCaml",import:(()=>_(()=>import("./ocaml-C0hk2d4L.js"),[]))},{id:"odin",name:"Odin",import:(()=>_(()=>import("./odin-BBf5iR-q.js"),[]))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>_(()=>import("./openscad-C4EeE6gA.js"),[]))},{id:"pascal",name:"Pascal",import:(()=>_(()=>import("./pascal-D93ZcfNL.js"),[]))},{id:"perl",name:"Perl",import:(()=>_(()=>import("./perl-C0TMdlhV.js"),__vite__mapDeps([64,1,2,3,7,8,16])))},{id:"php",name:"PHP",import:(()=>_(()=>import("./php-Dhbhpdrm.js"),__vite__mapDeps([75,1,2,3,7,8,16,9])))},{id:"pkl",name:"Pkl",import:(()=>_(()=>import("./pkl-u5AG7uiY.js"),[]))},{id:"plsql",name:"PL/SQL",import:(()=>_(()=>import("./plsql-ChMvpjG-.js"),[]))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>_(()=>import("./po-BTJTHyun.js"),[]))},{id:"polar",name:"Polar",import:(()=>_(()=>import("./polar-C0HS_06l.js"),[]))},{id:"postcss",name:"PostCSS",import:(()=>_(()=>import("./postcss-CXtECtnM.js"),[]))},{id:"powerquery",name:"PowerQuery",import:(()=>_(()=>import("./powerquery-CEu0bR-o.js"),[]))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>_(()=>import("./powershell-Dpen1YoG.js"),[]))},{id:"prisma",name:"Prisma",import:(()=>_(()=>import("./prisma-Dd19v3D-.js"),[]))},{id:"prolog",name:"Prolog",import:(()=>_(()=>import("./prolog-CbFg5uaA.js"),[]))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>_(()=>import("./proto-C7zT0LnQ.js"),[]))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>_(()=>import("./pug-CGlum2m_.js"),__vite__mapDeps([76,2,3,1])))},{id:"puppet",name:"Puppet",import:(()=>_(()=>import("./puppet-BMWR74SV.js"),[]))},{id:"purescript",name:"PureScript",import:(()=>_(()=>import("./purescript-CklMAg4u.js"),[]))},{id:"python",name:"Python",aliases:["py"],import:(()=>_(()=>import("./python-B6aJPvgy.js"),[]))},{id:"qml",name:"QML",import:(()=>_(()=>import("./qml-3beO22l8.js"),__vite__mapDeps([77,2])))},{id:"qmldir",name:"QML Directory",import:(()=>_(()=>import("./qmldir-C8lEn-DE.js"),[]))},{id:"qss",name:"Qt Style Sheets",import:(()=>_(()=>import("./qss-IeuSbFQv.js"),[]))},{id:"r",name:"R",import:(()=>_(()=>import("./r-Dspwwk_N.js"),[]))},{id:"racket",name:"Racket",import:(()=>_(()=>import("./racket-BqYA7rlc.js"),[]))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>_(()=>import("./raku-DXvB9xmW.js"),[]))},{id:"razor",name:"ASP.NET Razor",import:(()=>_(()=>import("./razor-Uh8Bk_45.js"),__vite__mapDeps([78,1,2,3,79])))},{id:"reg",name:"Windows Registry Script",import:(()=>_(()=>import("./reg-C-SQnVFl.js"),[]))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>_(()=>import("./regexp-CDVJQ6XC.js"),[]))},{id:"rel",name:"Rel",import:(()=>_(()=>import("./rel-C3B-1QV4.js"),[]))},{id:"riscv",name:"RISC-V",import:(()=>_(()=>import("./riscv-BM1_JUlF.js"),[]))},{id:"ron",name:"RON",import:(()=>_(()=>import("./ron-D8l8udqQ.js"),[]))},{id:"rosmsg",name:"ROS Interface",import:(()=>_(()=>import("./rosmsg-BJDFO7_C.js"),[]))},{id:"rst",name:"reStructuredText",import:(()=>_(()=>import("./rst-BrH8l1NY.js"),__vite__mapDeps([80,15,1,2,3,23,24,25,26,16,20,28,38,81,33,34,7,8,35,11,36,13,37])))},{id:"ruby",name:"Ruby",aliases:["rb"],import:(()=>_(()=>import("./ruby-Dw2BHqvy.js"),__vite__mapDeps([33,1,2,3,34,7,8,16,35,11,36,13,23,24,25,26,28,37,38])))},{id:"rust",name:"Rust",aliases:["rs"],import:(()=>_(()=>import("./rust-B1yitclQ.js"),[]))},{id:"sas",name:"SAS",import:(()=>_(()=>import("./sas-cz2c8ADy.js"),__vite__mapDeps([82,16])))},{id:"sass",name:"Sass",import:(()=>_(()=>import("./sass-Cj5Yp3dK.js"),[]))},{id:"scala",name:"Scala",import:(()=>_(()=>import("./scala-C151Ov-r.js"),[]))},{id:"scheme",name:"Scheme",import:(()=>_(()=>import("./scheme-C98Dy4si.js"),[]))},{id:"scss",name:"SCSS",import:(()=>_(()=>import("./scss-OYdSNvt2.js"),__vite__mapDeps([5,3])))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>_(()=>import("./sdbl-DVxCFoDh.js"),[]))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>_(()=>import("./shaderlab-Dg9Lc6iA.js"),__vite__mapDeps([83,84])))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>_(()=>import("./shellscript-Yzrsuije.js"),[]))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>_(()=>import("./shellsession-BADoaaVG.js"),__vite__mapDeps([85,28])))},{id:"smalltalk",name:"Smalltalk",import:(()=>_(()=>import("./smalltalk-BERRCDM3.js"),[]))},{id:"solidity",name:"Solidity",import:(()=>_(()=>import("./solidity-rGO070M0.js"),[]))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>_(()=>import("./soy-Brmx7dQM.js"),__vite__mapDeps([86,1,2,3])))},{id:"sparql",name:"SPARQL",import:(()=>_(()=>import("./sparql-rVzFXLq3.js"),__vite__mapDeps([87,88])))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>_(()=>import("./splunk-BtCnVYZw.js"),[]))},{id:"sql",name:"SQL",import:(()=>_(()=>import("./sql-BLtJtn59.js"),[]))},{id:"ssh-config",name:"SSH Config",import:(()=>_(()=>import("./ssh-config-_ykCGR6B.js"),[]))},{id:"stata",name:"Stata",import:(()=>_(()=>import("./stata-BH5u7GGu.js"),__vite__mapDeps([89,16])))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>_(()=>import("./stylus-BEDo0Tqx.js"),[]))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>_(()=>import("./surrealql-Bq5Q-fJD.js"),__vite__mapDeps([90,2])))},{id:"svelte",name:"Svelte",import:(()=>_(()=>import("./svelte-C_ipcX3V.js"),__vite__mapDeps([91,2,11,3,12])))},{id:"swift",name:"Swift",import:(()=>_(()=>import("./swift-D82vCrfD.js"),[]))},{id:"system-verilog",name:"SystemVerilog",import:(()=>_(()=>import("./system-verilog-CnnmHF94.js"),[]))},{id:"systemd",name:"Systemd Units",import:(()=>_(()=>import("./systemd-4A_iFExJ.js"),[]))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>_(()=>import("./talonscript-CkByrt1z.js"),[]))},{id:"tasl",name:"Tasl",import:(()=>_(()=>import("./tasl-QIJgUcNo.js"),[]))},{id:"tcl",name:"Tcl",import:(()=>_(()=>import("./tcl-dwOrl1Do.js"),[]))},{id:"templ",name:"Templ",import:(()=>_(()=>import("./templ-P3uqSqPl.js"),__vite__mapDeps([92,93,2,3])))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>_(()=>import("./terraform-BETggiCN.js"),[]))},{id:"tex",name:"TeX",import:(()=>_(()=>import("./tex-idrVyKtj.js"),__vite__mapDeps([66,62])))},{id:"toml",name:"TOML",import:(()=>_(()=>import("./toml-vGWfd6FD.js"),[]))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>_(()=>import("./ts-tags-zn1MmPIZ.js"),__vite__mapDeps([94,11,3,2,25,26,1,16,7,8])))},{id:"tsv",name:"TSV",import:(()=>_(()=>import("./tsv-B_m7g4N7.js"),[]))},{id:"tsx",name:"TSX",import:(()=>_(()=>import("./tsx-COt5Ahok.js"),[]))},{id:"turtle",name:"Turtle",import:(()=>_(()=>import("./turtle-BsS91CYL.js"),[]))},{id:"twig",name:"Twig",import:(()=>_(()=>import("./twig-DNn4PbVi.js"),__vite__mapDeps([95,3,2,5,75,1,7,8,16,9,20,33,34,35,11,36,13,23,24,25,26,28,37,38])))},{id:"typescript",name:"TypeScript",aliases:["ts","cts","mts"],import:(()=>_(()=>import("./typescript-BPQ3VLAy.js"),[]))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>_(()=>import("./typespec-BGHnOYBU.js"),[]))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>_(()=>import("./typst-DHCkPAjA.js"),[]))},{id:"v",name:"V",import:(()=>_(()=>import("./v-BcVCzyr7.js"),[]))},{id:"vala",name:"Vala",import:(()=>_(()=>import("./vala-CsfeWuGM.js"),[]))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>_(()=>import("./vb-D17OF-Vu.js"),[]))},{id:"verilog",name:"Verilog",import:(()=>_(()=>import("./verilog-BQ8w6xss.js"),[]))},{id:"vhdl",name:"VHDL",import:(()=>_(()=>import("./vhdl-CeAyd5Ju.js"),[]))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>_(()=>import("./viml-CJc9bBzg.js"),[]))},{id:"vue",name:"Vue",import:(()=>_(()=>import("./vue-DN_0RTcg.js"),__vite__mapDeps([96,3,2,11,9,1,15])))},{id:"vue-html",name:"Vue HTML",import:(()=>_(()=>import("./vue-html-AaS7Mt5G.js"),__vite__mapDeps([97,2])))},{id:"vue-vine",name:"Vue Vine",import:(()=>_(()=>import("./vue-vine-CQOfvN7w.js"),__vite__mapDeps([98,3,5,69,99,12,2])))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>_(()=>import("./vyper-CDx5xZoG.js"),[]))},{id:"wasm",name:"WebAssembly",import:(()=>_(()=>import("./wasm-MzD3tlZU.js"),[]))},{id:"wenyan",name:"Wenyan",aliases:["文言"],import:(()=>_(()=>import("./wenyan-BV7otONQ.js"),[]))},{id:"wgsl",name:"WGSL",import:(()=>_(()=>import("./wgsl-Dx-B1_4e.js"),[]))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>_(()=>import("./wikitext-BhOHFoWU.js"),[]))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>_(()=>import("./wit-5i3qLPDT.js"),[]))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>_(()=>import("./wolfram-lXgVvXCa.js"),[]))},{id:"xml",name:"XML",import:(()=>_(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([7,8])))},{id:"xsl",name:"XSL",import:(()=>_(()=>import("./xsl-CtQFsRM5.js"),__vite__mapDeps([100,7,8])))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>_(()=>import("./yaml-Buea-lGh.js"),[]))},{id:"zenscript",name:"ZenScript",import:(()=>_(()=>import("./zenscript-DVFEvuxE.js"),[]))},{id:"zig",name:"Zig",import:(()=>_(()=>import("./zig-VOosw3JB.js"),[]))}],Ib=Object.fromEntries(Yd.map(t=>[t.id,t.import])),Ab=Object.fromEntries(Yd.flatMap(t=>t.aliases?.map(e=>[e,t.import])||[])),Rb={...Ib,...Ab},Pb=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>_(()=>import("./andromeeda-C4gqWexZ.js"),[]))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>_(()=>import("./aurora-x-D-2ljcwZ.js"),[]))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>_(()=>import("./ayu-dark-DYE7WIF3.js"),[]))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>_(()=>import("./ayu-light-BA47KaF1.js"),[]))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>_(()=>import("./ayu-mirage-32ctXXKs.js"),[]))},{id:"catppuccin-frappe",displayName:"Catppuccin Frappé",type:"dark",import:(()=>_(()=>import("./catppuccin-frappe-DFWUc33u.js"),[]))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>_(()=>import("./catppuccin-latte-C9dUb6Cb.js"),[]))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>_(()=>import("./catppuccin-macchiato-DQyhUUbL.js"),[]))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>_(()=>import("./catppuccin-mocha-D87Tk5Gz.js"),[]))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>_(()=>import("./dark-plus-C3mMm8J8.js"),[]))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>_(()=>import("./dracula-BzJJZx-M.js"),[]))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>_(()=>import("./dracula-soft-BXkSAIEj.js"),[]))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>_(()=>import("./everforest-dark-BgDCqdQA.js"),[]))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>_(()=>import("./everforest-light-C8M2exoo.js"),[]))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>_(()=>import("./github-dark-DHJKELXO.js"),[]))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>_(()=>import("./github-dark-default-Cuk6v7N8.js"),[]))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>_(()=>import("./github-dark-dimmed-DH5Ifo-i.js"),[]))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>_(()=>import("./github-dark-high-contrast-E3gJ1_iC.js"),[]))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>_(()=>import("./github-light-DAi9KRSo.js"),[]))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>_(()=>import("./github-light-default-D7oLnXFd.js"),[]))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>_(()=>import("./github-light-high-contrast-BfjtVDDH.js"),[]))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>_(()=>import("./gruvbox-dark-hard-CFHQjOhq.js"),[]))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>_(()=>import("./gruvbox-dark-medium-GsRaNv29.js"),[]))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>_(()=>import("./gruvbox-dark-soft-CVdnzihN.js"),[]))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>_(()=>import("./gruvbox-light-hard-CH1njM8p.js"),[]))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>_(()=>import("./gruvbox-light-medium-DRw_LuNl.js"),[]))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>_(()=>import("./gruvbox-light-soft-hJgmCMqR.js"),[]))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>_(()=>import("./horizon-BUw7H-hv.js"),[]))},{id:"horizon-bright",displayName:"Horizon Bright",type:"dark",import:(()=>_(()=>import("./horizon-bright-Cn-bp-IR.js"),[]))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>_(()=>import("./houston-DnULxvSX.js"),[]))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>_(()=>import("./kanagawa-dragon-CkXjmgJE.js"),[]))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>_(()=>import("./kanagawa-lotus-CfQXZHmo.js"),[]))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>_(()=>import("./kanagawa-wave-DWedfzmr.js"),[]))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>_(()=>import("./laserwave-DUszq2jm.js"),[]))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>_(()=>import("./light-plus-B7mTdjB0.js"),[]))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>_(()=>import("./material-theme-D5KoaKCx.js"),[]))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>_(()=>import("./material-theme-darker-BfHTSMKl.js"),[]))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>_(()=>import("./material-theme-lighter-B0m2ddpp.js"),[]))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>_(()=>import("./material-theme-ocean-CyktbL80.js"),[]))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>_(()=>import("./material-theme-palenight-Csfq5Kiy.js"),[]))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>_(()=>import("./min-dark-CafNBF8u.js"),[]))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>_(()=>import("./min-light-CTRr51gU.js"),[]))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>_(()=>import("./monokai-D4h5O-jR.js"),[]))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>_(()=>import("./night-owl-C39BiMTA.js"),[]))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>_(()=>import("./night-owl-light-CMTm3GFP.js"),[]))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>_(()=>import("./nord-Ddv68eIx.js"),[]))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>_(()=>import("./one-dark-pro-DVMEJ2y_.js"),[]))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>_(()=>import("./one-light-C3Wv6jpd.js"),[]))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>_(()=>import("./plastic-3e1v2bzS.js"),[]))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>_(()=>import("./poimandres-CS3Unz2-.js"),[]))},{id:"red",displayName:"Red",type:"dark",import:(()=>_(()=>import("./red-bN70gL4F.js"),[]))},{id:"rose-pine",displayName:"Rosé Pine",type:"dark",import:(()=>_(()=>import("./rose-pine-qdsjHGoJ.js"),[]))},{id:"rose-pine-dawn",displayName:"Rosé Pine Dawn",type:"light",import:(()=>_(()=>import("./rose-pine-dawn-DHQR4-dF.js"),[]))},{id:"rose-pine-moon",displayName:"Rosé Pine Moon",type:"dark",import:(()=>_(()=>import("./rose-pine-moon-D4_iv3hh.js"),[]))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>_(()=>import("./slack-dark-BthQWCQV.js"),[]))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>_(()=>import("./slack-ochin-DqwNpetd.js"),[]))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>_(()=>import("./snazzy-light-Bw305WKR.js"),[]))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>_(()=>import("./solarized-dark-DXbdFlpD.js"),[]))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>_(()=>import("./solarized-light-L9t79GZl.js"),[]))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>_(()=>import("./synthwave-84-CbfX1IO0.js"),[]))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>_(()=>import("./tokyo-night-hegEt444.js"),[]))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>_(()=>import("./vesper-DU1UobuO.js"),[]))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>_(()=>import("./vitesse-black-Bkuqu6BP.js"),[]))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>_(()=>import("./vitesse-dark-D0r3Knsf.js"),[]))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>_(()=>import("./vitesse-light-CVO1_9PV.js"),[]))}],Mb=Object.fromEntries(Pb.map(t=>[t.id,t.import]));class Fa extends Error{constructor(e){super(e),this.name="ShikiError"}}function Lb(){return 2147483648}function Ob(){return typeof performance<"u"?performance.now():Date.now()}const Db=(t,e)=>t+(e-t%e)%e;async function $b(t){let e,n;const r={};function o(g){n=g,r.HEAPU8=new Uint8Array(g),r.HEAPU32=new Uint32Array(g)}function a(g,f,x){r.HEAPU8.copyWithin(g,f,f+x)}function i(g){try{return e.grow(g-n.byteLength+65535>>>16),o(e.buffer),1}catch{}}function l(g){const f=r.HEAPU8.length;g=g>>>0;const x=Lb();if(g>x)return!1;for(let b=1;b<=4;b*=2){let y=f*(1+.2/b);y=Math.min(y,g+100663296);const v=Math.min(x,Db(Math.max(g,y),65536));if(i(v))return!0}return!1}const c=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function d(g,f,x=1024){const b=f+x;let y=f;for(;g[y]&&!(y>=b);)++y;if(y-f>16&&g.buffer&&c)return c.decode(g.subarray(f,y));let v="";for(;f<y;){let w=g[f++];if(!(w&128)){v+=String.fromCharCode(w);continue}const N=g[f++]&63;if((w&224)===192){v+=String.fromCharCode((w&31)<<6|N);continue}const S=g[f++]&63;if((w&240)===224?w=(w&15)<<12|N<<6|S:w=(w&7)<<18|N<<12|S<<6|g[f++]&63,w<65536)v+=String.fromCharCode(w);else{const T=w-65536;v+=String.fromCharCode(55296|T>>10,56320|T&1023)}}return v}function p(g,f){return g?d(r.HEAPU8,g,f):""}const m={emscripten_get_now:Ob,emscripten_memcpy_big:a,emscripten_resize_heap:l,fd_write:()=>0};async function h(){const f=await t({env:m,wasi_snapshot_preview1:m});e=f.memory,o(e.buffer),Object.assign(r,f),r.UTF8ToString=p}return await h(),r}var zb=Object.defineProperty,Fb=(t,e,n)=>e in t?zb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Ge=(t,e,n)=>Fb(t,typeof e!="symbol"?e+"":e,n);let We=null;function Vb(t){throw new Fa(t.UTF8ToString(t.getLastOnigError()))}class _r{constructor(e){Ge(this,"utf16Length"),Ge(this,"utf8Length"),Ge(this,"utf16Value"),Ge(this,"utf8Value"),Ge(this,"utf16OffsetToUtf8"),Ge(this,"utf8OffsetToUtf16");const n=e.length,r=_r._utf8ByteLength(e),o=r!==n,a=o?new Uint32Array(n+1):null;o&&(a[n]=r);const i=o?new Uint32Array(r+1):null;o&&(i[r]=n);const l=new Uint8Array(r);let c=0;for(let d=0;d<n;d++){const p=e.charCodeAt(d);let m=p,h=!1;if(p>=55296&&p<=56319&&d+1<n){const g=e.charCodeAt(d+1);g>=56320&&g<=57343&&(m=(p-55296<<10)+65536|g-56320,h=!0)}o&&(a[d]=c,h&&(a[d+1]=c),m<=127?i[c+0]=d:m<=2047?(i[c+0]=d,i[c+1]=d):m<=65535?(i[c+0]=d,i[c+1]=d,i[c+2]=d):(i[c+0]=d,i[c+1]=d,i[c+2]=d,i[c+3]=d)),m<=127?l[c++]=m:m<=2047?(l[c++]=192|(m&1984)>>>6,l[c++]=128|(m&63)>>>0):m<=65535?(l[c++]=224|(m&61440)>>>12,l[c++]=128|(m&4032)>>>6,l[c++]=128|(m&63)>>>0):(l[c++]=240|(m&1835008)>>>18,l[c++]=128|(m&258048)>>>12,l[c++]=128|(m&4032)>>>6,l[c++]=128|(m&63)>>>0),h&&d++}this.utf16Length=n,this.utf8Length=r,this.utf16Value=e,this.utf8Value=l,this.utf16OffsetToUtf8=a,this.utf8OffsetToUtf16=i}static _utf8ByteLength(e){let n=0;for(let r=0,o=e.length;r<o;r++){const a=e.charCodeAt(r);let i=a,l=!1;if(a>=55296&&a<=56319&&r+1<o){const c=e.charCodeAt(r+1);c>=56320&&c<=57343&&(i=(a-55296<<10)+65536|c-56320,l=!0)}i<=127?n+=1:i<=2047?n+=2:i<=65535?n+=3:n+=4,l&&r++}return n}createString(e){const n=e.omalloc(this.utf8Length);return e.HEAPU8.set(this.utf8Value,n),n}}const kr=class yt{constructor(e){if(Ge(this,"id",++yt.LAST_ID),Ge(this,"_onigBinding"),Ge(this,"content"),Ge(this,"utf16Length"),Ge(this,"utf8Length"),Ge(this,"utf16OffsetToUtf8"),Ge(this,"utf8OffsetToUtf16"),Ge(this,"ptr"),!We)throw new Fa("Must invoke loadWasm first.");this._onigBinding=We,this.content=e;const n=new _r(e);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!yt._sharedPtrInUse?(yt._sharedPtr||(yt._sharedPtr=We.omalloc(1e4)),yt._sharedPtrInUse=!0,We.HEAPU8.set(n.utf8Value,yt._sharedPtr),this.ptr=yt._sharedPtr):this.ptr=n.createString(We)}convertUtf8OffsetToUtf16(e){return this.utf8OffsetToUtf16?e<0?0:e>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[e]:e}convertUtf16OffsetToUtf8(e){return this.utf16OffsetToUtf8?e<0?0:e>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[e]:e}dispose(){this.ptr===yt._sharedPtr?yt._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};Ge(kr,"LAST_ID",0);Ge(kr,"_sharedPtr",0);Ge(kr,"_sharedPtrInUse",!1);let Jd=kr;class Bb{constructor(e){if(Ge(this,"_onigBinding"),Ge(this,"_ptr"),!We)throw new Fa("Must invoke loadWasm first.");const n=[],r=[];for(let l=0,c=e.length;l<c;l++){const d=new _r(e[l]);n[l]=d.createString(We),r[l]=d.utf8Length}const o=We.omalloc(4*e.length);We.HEAPU32.set(n,o/4);const a=We.omalloc(4*e.length);We.HEAPU32.set(r,a/4);const i=We.createOnigScanner(o,a,e.length);for(let l=0,c=e.length;l<c;l++)We.ofree(n[l]);We.ofree(a),We.ofree(o),i===0&&Vb(We),this._onigBinding=We,this._ptr=i}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(e,n,r){let o=0;if(typeof r=="number"&&(o=r),typeof e=="string"){e=new Jd(e);const a=this._findNextMatchSync(e,n,!1,o);return e.dispose(),a}return this._findNextMatchSync(e,n,!1,o)}_findNextMatchSync(e,n,r,o){const a=this._onigBinding,i=a.findNextOnigScannerMatch(this._ptr,e.id,e.ptr,e.utf8Length,e.convertUtf16OffsetToUtf8(n),o);if(i===0)return null;const l=a.HEAPU32;let c=i/4;const d=l[c++],p=l[c++],m=[];for(let h=0;h<p;h++){const g=e.convertUtf8OffsetToUtf16(l[c++]),f=e.convertUtf8OffsetToUtf16(l[c++]);m[h]={start:g,end:f,length:f-g}}return{index:d,captureIndices:m}}}function Ub(t){return typeof t.instantiator=="function"}function Gb(t){return typeof t.default=="function"}function Hb(t){return typeof t.data<"u"}function qb(t){return typeof Response<"u"&&t instanceof Response}function Wb(t){return typeof ArrayBuffer<"u"&&(t instanceof ArrayBuffer||ArrayBuffer.isView(t))||typeof Buffer<"u"&&Buffer.isBuffer?.(t)||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer||typeof Uint32Array<"u"&&t instanceof Uint32Array}let En;function Kb(t){if(En)return En;async function e(){We=await $b(async n=>{let r=t;return r=await r,typeof r=="function"&&(r=await r(n)),typeof r=="function"&&(r=await r(n)),Ub(r)?r=await r.instantiator(n):Gb(r)?r=await r.default(n):(Hb(r)&&(r=r.data),qb(r)?typeof WebAssembly.instantiateStreaming=="function"?r=await Qb(r)(n):r=await Yb(r)(n):Wb(r)?r=await Zr(r)(n):r instanceof WebAssembly.Module?r=await Zr(r)(n):"default"in r&&r.default instanceof WebAssembly.Module&&(r=await Zr(r.default)(n))),"instance"in r&&(r=r.instance),"exports"in r&&(r=r.exports),r})}return En=e(),En}function Zr(t){return e=>WebAssembly.instantiate(t,e)}function Qb(t){return e=>WebAssembly.instantiateStreaming(t,e)}function Yb(t){return async e=>{const n=await t.arrayBuffer();return WebAssembly.instantiate(n,e)}}async function Jb(t){return t&&await Kb(t),{createScanner(e){return new Bb(e.map(n=>typeof n=="string"?n:n.source))},createString(e){return new Jd(e)}}}const Xb=Cb({langs:Rb,themes:Mb,engine:()=>Jb(_(()=>import("./wasm-CG6Dc4jp.js"),[]))}),{codeToHtml:Va,codeToTokens:Zb}=Tb(Xb,{guessEmbeddedLanguages:Bx});function Ba({...t}){return s.jsx(Wm,{"data-slot":"collapsible",...t})}function Ua({...t}){return s.jsx(Km,{"data-slot":"collapsible-trigger",...t})}function Ga({...t}){return s.jsx(Qm,{"data-slot":"collapsible-content",...t})}function Xd(t){let e;try{e=JSON.parse(t)}catch{return null}const n=[];if(Array.isArray(e))for(const o of e)o&&typeof o=="object"&&"type"in o&&n.push(o);else e&&typeof e=="object"&&"type"in e&&n.push(e);return n.length===0||!n.some(o=>o.type==="text"||o.type==="image")?null:{text:n.filter(o=>o.type==="text"&&o.text).map(o=>o.text).join(`
|
|
25
|
-
`),blocks:n}}function ey(t){return t.blocks.find(e=>e.type==="image"&&e.source?.data)}function Zd(t){return t.source?.data?`data:${t.source.media_type||"image/png"};base64,${t.source.data}`:null}let Ha=class extends u.Component{constructor(e){super(e),this.reset=()=>{this.setState({hasError:!1,error:null})},this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,n){console.error(`[ErrorBoundary${this.props.name?`:${this.props.name}`:""}]`,e,n.componentStack)}render(){return this.state.hasError&&this.state.error?typeof this.props.fallback=="function"?this.props.fallback(this.state.error,this.reset):this.props.fallback?this.props.fallback:this.props.inline?s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-red-400 text-sm",children:[s.jsx(zo,{size:14}),s.jsxs("span",{children:["Error",this.props.name?` in ${this.props.name}`:""]}),s.jsx("button",{onClick:this.reset,className:"text-red-300 hover:text-red-200 underline",children:"retry"})]}):s.jsxs("div",{className:"my-2 border border-red-500/30 rounded-lg overflow-hidden bg-red-500/5",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-red-500/20",children:[s.jsx(zo,{size:14,className:"text-red-400 flex-shrink-0"}),s.jsxs("span",{className:"text-xs font-semibold uppercase tracking-wider text-red-400",children:["Render Error",this.props.name?` — ${this.props.name}`:""]}),s.jsxs("button",{onClick:this.reset,className:"ml-auto flex items-center gap-1 px-2 py-1 text-xs text-red-300 hover:text-red-200 hover:bg-red-500/10 rounded transition-colors",children:[s.jsx(qg,{size:12})," Retry"]})]}),s.jsx("div",{className:"px-3 py-2 text-sm text-red-200 font-medium",children:this.state.error.message})]}):this.props.children}};const ty=
|
|
25
|
+
`),blocks:n}}function ey(t){return t.blocks.find(e=>e.type==="image"&&e.source?.data)}function Zd(t){return t.source?.data?`data:${t.source.media_type||"image/png"};base64,${t.source.data}`:null}let Ha=class extends u.Component{constructor(e){super(e),this.reset=()=>{this.setState({hasError:!1,error:null})},this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,n){console.error(`[ErrorBoundary${this.props.name?`:${this.props.name}`:""}]`,e,n.componentStack)}render(){return this.state.hasError&&this.state.error?typeof this.props.fallback=="function"?this.props.fallback(this.state.error,this.reset):this.props.fallback?this.props.fallback:this.props.inline?s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-red-400 text-sm",children:[s.jsx(zo,{size:14}),s.jsxs("span",{children:["Error",this.props.name?` in ${this.props.name}`:""]}),s.jsx("button",{onClick:this.reset,className:"text-red-300 hover:text-red-200 underline",children:"retry"})]}):s.jsxs("div",{className:"my-2 border border-red-500/30 rounded-lg overflow-hidden bg-red-500/5",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-red-500/20",children:[s.jsx(zo,{size:14,className:"text-red-400 flex-shrink-0"}),s.jsxs("span",{className:"text-xs font-semibold uppercase tracking-wider text-red-400",children:["Render Error",this.props.name?` — ${this.props.name}`:""]}),s.jsxs("button",{onClick:this.reset,className:"ml-auto flex items-center gap-1 px-2 py-1 text-xs text-red-300 hover:text-red-200 hover:bg-red-500/10 rounded transition-colors",children:[s.jsx(qg,{size:12})," Retry"]})]}),s.jsx("div",{className:"px-3 py-2 text-sm text-red-200 font-medium",children:this.state.error.message})]}):this.props.children}};const ty=Ie.lazy(async()=>({default:(await _(()=>import("./CodeHighlight-AX8pcR0a.js"),__vite__mapDeps([101,102,103,104]))).CodeHighlight}));function Xi({code:t,className:e=""}){return s.jsx("pre",{className:R("m-0 px-3 py-2.5 font-mono text-[13px] whitespace-pre-wrap break-words leading-relaxed",k.codeBg,k.text.secondary,e),children:s.jsx("code",{children:t.trimEnd()})})}function qa(t){return s.jsx(Ha,{inline:!0,name:"CodeHighlight",fallback:s.jsx(Xi,{code:t.code,className:t.className}),children:s.jsx(u.Suspense,{fallback:s.jsx(Xi,{code:t.code,className:t.className}),children:s.jsx(ty,{...t})})})}function De({isExpanded:t,onExpandedChange:e,headerContent:n,content:r,canExpand:o=!0,wrapperClassName:a,cardClassName:i,headerClassName:l}){return s.jsx("div",{className:R("w-fit max-w-full",a),children:s.jsx(Ba,{open:t,onOpenChange:e,children:s.jsxs("div",{className:R("border rounded-lg overflow-hidden",k.card.border,k.card.bg,i),children:[s.jsx(Ua,{className:"w-full text-left cursor-pointer select-none",disabled:!o,children:s.jsxs("div",{className:R("flex items-center gap-2 px-3 py-2 transition-colors",o&&k.hover,l),children:[n,o&&s.jsx(nn,{size:12,className:R("transition-transform duration-150 flex-shrink-0",k.text.faint,!t&&"-rotate-90")})]})}),o&&r&&s.jsx(Ga,{children:r})]})})})}function sy(t){let e=t.replace(/<system-reminder>[\s\S]*?<\/system-reminder>/g,"");return e=e.replace(/^\s*\d+→/gm,""),e.trimEnd()}const ny=5;function ry({input:t,result:e,workingDirectory:n}){const r=t?.file_path||"",o=Ns(r,n),a=u.useMemo(()=>{if(!e)return null;const m=Xd(e);if(!m)return null;const h=ey(m);return h?Zd(h):null},[e]),i=e?sy(e):"",l=Aa(i),[c,d]=u.useState(()=>l>0&&l<=ny),p=fr(r);return e?a?s.jsx(De,{isExpanded:!0,onExpandedChange:()=>{},cardClassName:ce.blue.card,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ra,{size:14,className:`${ce.blue.icon} flex-shrink-0`}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:"Read"})]}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:o})]}),content:s.jsx("div",{className:`border-t ${k.separator} px-3 py-2`,children:s.jsx("img",{src:a,alt:o,className:"rounded border border-stone-200 dark:border-zinc-800/40 max-w-full max-h-96 object-contain"})})}):s.jsx(De,{isExpanded:c,onExpandedChange:d,cardClassName:ce.blue.card,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(jt,{size:14,className:`${ce.blue.icon} flex-shrink-0`}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:"Read"})]}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:o})]}),content:i?s.jsx("div",{className:`border-t ${k.separator}`,children:p==="markdown"?s.jsx("div",{className:`px-3 py-2.5 max-h-96 overflow-y-auto ${k.scrollbar} ${Ls}`,children:s.jsx(rs,{remarkPlugins:[Cs],children:i})}):s.jsx(qa,{code:i,language:p,showLineNumbers:!0,className:"rounded-none"})}):void 0}):s.jsx("div",{})}const oy=Ie.lazy(async()=>({default:(await _(()=>Promise.resolve().then(()=>x1),void 0)).DiffViewer}));function Zi({oldValue:t,newValue:e}){return s.jsx("pre",{className:R("m-0 px-3 py-2.5 font-mono text-[13px] whitespace-pre-wrap break-words leading-relaxed",k.codeBg,k.text.primary),children:s.jsx("code",{children:e||t||"No changes"})})}function ec(t,e){return{added:Math.max(0,e.split(`
|
|
26
26
|
`).length-t.split(`
|
|
27
27
|
`).length),removed:Math.max(0,t.split(`
|
|
28
28
|
`).length-e.split(`
|
|
29
|
-
`).length)}}const ay=5;function iy({input:t,result:e,isMultiEdit:n=!1,workingDirectory:r}){const o=t?.file_path||"",a=Ns(o,r),i=fr(o);let l=0,c=0;if(n&&t.edits&&Array.isArray(t.edits))t.edits.forEach(f=>{const x=ec(f.old_string||"",f.new_string||"");l+=x.added,c+=x.removed});else if(t.old_string!==void 0&&t.new_string!==void 0){const f=ec(t.old_string,t.new_string);l=f.added,c=f.removed}const d=l+c,[p,m]=u.useState(()=>d>0&&d<=ay),h=l>0&&c>0?`+${l} -${c}`:l>0?`+${l}`:c>0?`-${c}`:"~",g=()=>{const f=(x,b)=>s.jsx(Ha,{inline:!0,name:"DiffViewer",fallback:s.jsx(Zi,{oldValue:x,newValue:b}),children:s.jsx(u.Suspense,{fallback:s.jsx(Zi,{oldValue:x,newValue:b}),children:s.jsx(oy,{oldValue:x,newValue:b,language:i})})});return n&&t.edits&&Array.isArray(t.edits)?s.jsx("div",{className:"flex flex-col",children:t.edits.map((x,b)=>s.jsxs("div",{children:[b>0&&s.jsx("div",{className:"border-t border-emerald-500/20"}),f(x.old_string||"",x.new_string||"")]},b))}):t.old_string!==void 0&&t.new_string!==void 0?f(t.old_string,t.new_string):e?s.jsx(qa,{code:e,language:i,className:"rounded-none"}):s.jsx("div",{className:`px-3 py-2 text-sm ${k.text.muted}`,children:"Edit completed successfully"})};return s.jsx(De,{isExpanded:p,onExpandedChange:m,cardClassName:
|
|
29
|
+
`).length)}}const ay=5;function iy({input:t,result:e,isMultiEdit:n=!1,workingDirectory:r}){const o=t?.file_path||"",a=Ns(o,r),i=fr(o);let l=0,c=0;if(n&&t.edits&&Array.isArray(t.edits))t.edits.forEach(f=>{const x=ec(f.old_string||"",f.new_string||"");l+=x.added,c+=x.removed});else if(t.old_string!==void 0&&t.new_string!==void 0){const f=ec(t.old_string,t.new_string);l=f.added,c=f.removed}const d=l+c,[p,m]=u.useState(()=>d>0&&d<=ay),h=l>0&&c>0?`+${l} -${c}`:l>0?`+${l}`:c>0?`-${c}`:"~",g=()=>{const f=(x,b)=>s.jsx(Ha,{inline:!0,name:"DiffViewer",fallback:s.jsx(Zi,{oldValue:x,newValue:b}),children:s.jsx(u.Suspense,{fallback:s.jsx(Zi,{oldValue:x,newValue:b}),children:s.jsx(oy,{oldValue:x,newValue:b,language:i})})});return n&&t.edits&&Array.isArray(t.edits)?s.jsx("div",{className:"flex flex-col",children:t.edits.map((x,b)=>s.jsxs("div",{children:[b>0&&s.jsx("div",{className:"border-t border-emerald-500/20"}),f(x.old_string||"",x.new_string||"")]},b))}):t.old_string!==void 0&&t.new_string!==void 0?f(t.old_string,t.new_string):e?s.jsx(qa,{code:e,language:i,className:"rounded-none"}):s.jsx("div",{className:`px-3 py-2 text-sm ${k.text.muted}`,children:"Edit completed successfully"})};return s.jsx(De,{isExpanded:p,onExpandedChange:m,cardClassName:ce.emerald.card,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(kd,{size:14,className:`${ce.emerald.icon} flex-shrink-0`}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:"Edit"})]}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:a}),s.jsx("span",{className:R("text-[11px] tabular-nums flex-shrink-0",k.text.faint),children:h})]}),content:s.jsx("div",{className:`border-t ${k.separator}`,children:g()})})}const cy=5;function ly({input:t,workingDirectory:e}){const n=t?.file_path||"",r=t?.content||"",o=Aa(r),[a,i]=u.useState(()=>o>0&&o<=cy),l=Ns(n,e),c=fr(n);return s.jsx(De,{isExpanded:a,onExpandedChange:i,cardClassName:ce.violet.card,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Tg,{size:14,className:`${ce.violet.icon} flex-shrink-0`}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:"Write"})]}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:l})]}),content:r?s.jsx("div",{className:`border-t ${k.separator}`,children:c==="markdown"?s.jsx("div",{className:`px-3 py-2.5 max-h-96 overflow-y-auto ${k.scrollbar} ${Ls}`,children:s.jsx(rs,{remarkPlugins:[Cs],children:r})}):s.jsx(qa,{code:r,language:c,showLineNumbers:!0,className:"rounded-none"})}):void 0})}const dy=80;function uy(t){const e=[];let n=!1,r=!1,o=!1,a=0,i=0;for(let l=0;l<t.length;l++){const c=t[l];if((l>0?t[l-1]:"")!=="\\"){if(c==="'"&&!r&&!o){n=!n;continue}if(c==='"'&&!n&&!o){r=!r;continue}if(c==="`"&&!n){o=!o;continue}if(!(n||r||o)){if(c==="("||c==="$"&&t[l+1]==="("){a++;continue}if(c===")"&&a>0){a--;continue}if(c==="{"){i++;continue}if(c==="}"&&i>0){i--;continue}a>0||i>0||(c==="|"&&t[l+1]!=="|"||c==="&"&&t[l+1]==="&"||c==="|"&&t[l+1]==="|"?e.push(l):c===";"&&e.push(l+1))}}}return e}function py(t){const e=t.trim();if(e.length<=dy||/<<[-']?\s*\w/.test(e))return e;const n=uy(e);if(n.length===0)return e;const r=[];let o=0;for(const i of n){const l=e.slice(o,i).trim();l&&r.push(l),o=i}const a=e.slice(o).trim();return a&&r.push(a),r.length<=1?e:r.map((i,l)=>l===0?i:` ${i}`).join(`
|
|
30
30
|
`)}function my(t){const e=t.trim();if((e.startsWith("{")||e.startsWith("["))&&e.length>2)try{const n=JSON.parse(e);return[JSON.stringify(n,null,2),"json"]}catch{}return[t,"shellscript"]}function eo({code:t,lang:e}){const r=hr()==="dark"?"github-dark-default":"github-light-default",[o,a]=u.useState(null),i=e||"shellscript";return u.useEffect(()=>{Va(t,{lang:i,theme:r}).then(a).catch(()=>a(null))},[t,i,r]),o?s.jsx("div",{className:"[&_pre]:!bg-transparent [&_pre]:m-0 [&_pre]:text-[13px] [&_pre]:leading-relaxed [&_pre]:whitespace-pre-wrap [&_pre]:break-all [&_code]:!bg-transparent",dangerouslySetInnerHTML:{__html:o}}):s.jsx("pre",{className:`m-0 font-mono text-[13px] whitespace-pre-wrap break-all leading-relaxed ${k.text.primary}`,children:t})}const hy=/Output is being written to:\s*(\S+)/,fy=2e3,Ko=1e5;function gy(t){const e=t.match(hy);return e?e[1]:null}function xy(t,e=80){let n=t.trim();const r=n.match(/^(?:bash|sh|zsh)\s+-c\s+['"](.+)['"]$/s);return r&&(n=r[1]),n.includes(`
|
|
31
31
|
`)&&(n=(n.split(`
|
|
32
32
|
`).find(a=>a.trim()&&!a.trim().startsWith("#"))||n.split(`
|
|
33
33
|
`)[0]).trim(),n.length<=e&&(n+=" …")),n.length>e?n.slice(0,e)+"…":n}function by(t,e,n){const[r,o]=u.useState({content:"",size:0,truncated:!1,done:!1}),a=u.useRef(0),i=u.useRef(0),l=u.useCallback(async()=>{if(!(!t||!n))try{const c=await n(t);if(!c)return;c.size===a.current&&c.size>0?i.current++:i.current=0,a.current=c.size;const d=i.current>=3;let p=c.content,m=c.truncated;p.length>Ko&&(p=p.slice(-Ko),m=!0),o({content:p,size:c.size,truncated:m,done:d})}catch{}},[t,n]);return u.useEffect(()=>{if(!t||!n||!e||r.done)return;l();const c=setInterval(()=>{l()},fy);return()=>clearInterval(c)},[t,n,e,r.done,l]),r}function yy(t){return t?t.split(`
|
|
34
|
-
`).filter(e=>e.trim()).length:0}const vy=5;function tc({input:t,result:e,isPending:n=!1,fetchBackgroundOutput:r}){const o=gd(e),a=yy(o),[i,l]=u.useState(()=>!n&&a>0&&a<=vy),c=t?.command||"",d=t?.description||"",p=u.useMemo(()=>gy(o),[o]),m=by(p,i,r);p&&m.content&&m.content;const h=u.useMemo(()=>xy(c),[c]),g=p&&!m.done,f=u.useRef(null);return u.useEffect(()=>{f.current&&i&&p&&(f.current.scrollTop=f.current.scrollHeight)},[m.content,i,p]),s.jsx(De,{isExpanded:i,onExpandedChange:l,cardClassName:
|
|
34
|
+
`).filter(e=>e.trim()).length:0}const vy=5;function tc({input:t,result:e,isPending:n=!1,fetchBackgroundOutput:r}){const o=gd(e),a=yy(o),[i,l]=u.useState(()=>!n&&a>0&&a<=vy),c=t?.command||"",d=t?.description||"",p=u.useMemo(()=>gy(o),[o]),m=by(p,i,r);p&&m.content&&m.content;const h=u.useMemo(()=>xy(c),[c]),g=p&&!m.done,f=u.useRef(null);return u.useEffect(()=>{f.current&&i&&p&&(f.current.scrollTop=f.current.scrollHeight)},[m.content,i,p]),s.jsx(De,{isExpanded:i,onExpandedChange:l,cardClassName:ce.orange.card,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[g&&s.jsx(at,{size:12,className:`${ce.orange.icon} animate-spin`}),s.jsx(Yn,{size:14,className:ce.orange.icon})]}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:d||h})]}),content:s.jsxs(s.Fragment,{children:[c&&s.jsx("div",{className:`border-t ${k.separator} ${k.codeBg} px-3 py-2.5`,children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-emerald-400/60 font-mono text-[13px] select-none shrink-0 leading-relaxed",children:"$"}),s.jsx(eo,{code:py(c)})]})}),p&&m.content&&s.jsxs("div",{className:`border-t ${k.separator} ${k.codeBg} px-3 py-2.5 max-h-96 overflow-auto`,ref:f,children:[m.truncated&&s.jsxs("div",{className:`text-[13px] ${k.text.faint} mb-1`,children:["… showing last ",(Ko/1e3).toFixed(0),"K chars"]}),s.jsx(eo,{code:m.content})]}),p&&!m.content&&s.jsxs("div",{className:`border-t ${k.separator} px-3 py-2 text-[13px] ${k.text.muted} ${k.codeBgSubtle} flex items-center gap-2`,children:[s.jsx(at,{size:12,className:"animate-spin"}),s.jsx("span",{children:"Waiting for output…"})]}),!p&&o&&(()=>{const[x,b]=my(o);return s.jsx("div",{className:`border-t ${k.separator} ${k.codeBg} px-3 py-2.5`,children:s.jsx(eo,{code:x,lang:b})})})(),!p&&!o&&n&&s.jsx("div",{className:`border-t ${k.separator} px-3 py-2 text-[13px] ${k.text.muted} ${k.codeBgSubtle}`,children:"Waiting for stdout..."})]})})}const wy=5;function _y(t){const e=t.split(`
|
|
35
35
|
`).filter(r=>r.trim());if(e.length===0)return!1;const n=e[0].startsWith("Found ")?e[1]:e[0];return n?/^.+?[:\-]\d+[:\-]/.test(n):!1}function ky(t,e){const n=t.split(`
|
|
36
36
|
`),r=new Map,o=[];for(const a of n){if(!a.trim()||a==="--"||a==="[Omitted long matching line]")continue;const i=a.match(/^(.+?):(\d+):(.*)$/);if(i){const[,p,m,h]=i;r.has(p)||(r.set(p,[]),o.push(p)),r.get(p).push({lineNum:m,content:h,isContext:!1});continue}const l=a.match(/^(.+?)-(\d+)-(.*)$/);if(l){const[,p,m,h]=l;r.has(p)||(r.set(p,[]),o.push(p)),r.get(p).push({lineNum:m,content:h,isContext:!0});continue}const c=a.match(/^(\d+):(.*)$/);if(c){const p="(result)";r.has(p)||(r.set(p,[]),o.push(p)),r.get(p).push({lineNum:c[1],content:c[2],isContext:!1});continue}const d=a.match(/^(\d+)-(.*)$/);if(d){const p="(result)";r.has(p)||(r.set(p,[]),o.push(p)),r.get(p).push({lineNum:d[1],content:d[2],isContext:!0});continue}}return o.map(a=>{let i=a;return e&&a.startsWith(e)&&(i=a.slice(e.length).replace(/^\//,"")),i=i.replace(/^\/Users\/[^/]+\//,"~/"),{file:a,shortFile:i,matches:r.get(a)}})}function jy(t,e){return t.split(`
|
|
37
|
-
`).filter(n=>n.trim()&&!n.startsWith("Found ")&&!n.startsWith("No ")).map(n=>{let r=n.trim();return e&&r.startsWith(e)&&(r=r.slice(e.length).replace(/^\//,"")),r=r.replace(/^\/Users\/[^/]+\//,"~/"),r})}function sc(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ny({text:t,pattern:e}){if(!e||!t)return s.jsx(s.Fragment,{children:t});try{const n=new RegExp(`(${e})`,"gi"),r=t.split(n);return r.length<=1?s.jsx(s.Fragment,{children:t}):s.jsx(s.Fragment,{children:r.map((o,a)=>n.test(o)?s.jsx("mark",{className:"bg-amber-400/30 dark:bg-amber-500/20 text-inherit rounded-sm px-0.5",children:o},a):s.jsx(
|
|
37
|
+
`).filter(n=>n.trim()&&!n.startsWith("Found ")&&!n.startsWith("No ")).map(n=>{let r=n.trim();return e&&r.startsWith(e)&&(r=r.slice(e.length).replace(/^\//,"")),r=r.replace(/^\/Users\/[^/]+\//,"~/"),r})}function sc(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ny({text:t,pattern:e}){if(!e||!t)return s.jsx(s.Fragment,{children:t});try{const n=new RegExp(`(${e})`,"gi"),r=t.split(n);return r.length<=1?s.jsx(s.Fragment,{children:t}):s.jsx(s.Fragment,{children:r.map((o,a)=>n.test(o)?s.jsx("mark",{className:"bg-amber-400/30 dark:bg-amber-500/20 text-inherit rounded-sm px-0.5",children:o},a):s.jsx(Ie.Fragment,{children:o},a))})}catch{return s.jsx(s.Fragment,{children:t})}}function Sy({groups:t,pattern:e}){const[n,r]=u.useState(new Set),o=i=>{r(l=>{const c=new Set(l);return c.has(i)?c.delete(i):c.add(i),c})},a=t.length===1&&t[0].file==="(result)";return s.jsx("div",{className:R("max-h-96 overflow-y-auto",k.scrollbar),children:t.map(i=>{const l=n.has(i.file);return s.jsxs("div",{children:[!a&&s.jsxs("button",{onClick:()=>o(i.file),className:R("w-full flex items-center gap-1.5 px-3 py-1.5 text-left cursor-pointer select-none border-t transition-colors",k.separator,k.hover),children:[s.jsx(yd,{size:10,className:R("flex-shrink-0 transition-transform duration-150",k.text.faint,!l&&"rotate-90")}),s.jsx(jt,{size:11,className:R("flex-shrink-0",ce.amber.icon)}),s.jsx("span",{className:R("text-[12px] font-mono truncate",k.text.secondary),children:i.shortFile}),s.jsx("span",{className:R("text-[11px] flex-shrink-0 ml-auto",k.text.faint),children:i.matches.filter(c=>!c.isContext).length})]}),!l&&s.jsx("div",{className:R("font-mono text-[13px] leading-relaxed",k.codeBg),children:i.matches.map((c,d)=>s.jsxs("div",{className:R("flex",c.isContext?"opacity-50":"",!c.isContext&&"bg-amber-500/5 dark:bg-amber-500/5"),children:[s.jsx("span",{className:R("select-none w-10 text-right pr-2 shrink-0 border-r",k.text.faint,c.isContext?k.separator:"border-amber-500/30"),children:c.lineNum}),s.jsx("span",{className:R("flex-1 pl-2 pr-3 whitespace-pre-wrap break-words",k.text.primary),children:c.isContext?c.content:s.jsx(Ny,{text:c.content,pattern:e})})]},`${c.lineNum}-${d}`))})]},i.file)})})}function Cy({files:t}){const e=new Map,n=[];for(const r of t){const o=r.lastIndexOf("/"),a=o>=0?r.slice(0,o):".",i=o>=0?r.slice(o+1):r;e.has(a)||(e.set(a,[]),n.push(a)),e.get(a).push(i)}return n.length===1?s.jsx("div",{className:R("max-h-64 overflow-y-auto",k.scrollbar),children:t.map((r,o)=>s.jsxs("div",{className:R("flex items-center gap-2 px-3 py-1 font-mono text-[13px]",k.text.primary),children:[s.jsx(jt,{size:11,className:k.text.faint}),s.jsx("span",{className:"truncate",children:r})]},o))}):s.jsx("div",{className:R("max-h-80 overflow-y-auto",k.scrollbar),children:n.map(r=>s.jsxs("div",{children:[s.jsxs("div",{className:R("px-3 py-1 font-mono text-[12px] border-t",k.text.faint,k.separator),children:[r,"/"]}),e.get(r).map((o,a)=>s.jsxs("div",{className:R("flex items-center gap-2 px-3 pl-6 py-0.5 font-mono text-[13px]",k.text.primary),children:[s.jsx(jt,{size:11,className:k.text.faint}),s.jsx("span",{className:"truncate",children:o})]},a))]},r))})}function Ey({input:t,result:e,toolType:n}){const r=Aa(e),[o,a]=u.useState(()=>r>0&&r<=wy),i=t?.pattern,l=t?.path;t?.output_mode;const c=u.useMemo(()=>n!=="Grep"||!e?null:_y(e)?{mode:"content",groups:ky(e,l)}:{mode:"files",files:jy(e,l)},[n,e,l]),p=(()=>{switch(n){case"Grep":{const g=l?String(l).split("/").pop():"",f=g?`${i||""} in ${g}`:i||"",x=c?.mode==="content"?c.groups.reduce((b,y)=>b+y.matches.filter(v=>!v.isContext).length,0):c?.mode==="files"?c.files.length:r;return{icon:ss,label:"Grep",color:ce.amber.icon,cardStyle:ce.amber.card,detail:f,count:x}}case"Glob":return{icon:Ag,label:"Glob",color:ce.violet.icon,cardStyle:ce.violet.card,detail:i||"",count:r};case"LS":return{icon:wd,label:"LS",color:ce.violet.icon,cardStyle:ce.violet.card,detail:t?.path||".",count:r}}})(),m=p.icon,h=u.useMemo(()=>{if(!i)return;if(!/[.*+?^${}()|[\]\\]/.test(i))return sc(i);try{return new RegExp(i),i}catch{return sc(i)}},[i]);return s.jsx("div",{className:"w-fit max-w-full",children:s.jsx(Ba,{open:o,onOpenChange:a,children:s.jsxs("div",{className:R("border rounded-lg overflow-hidden",p.cardStyle),children:[s.jsx(Ua,{className:"w-full text-left cursor-pointer select-none",children:s.jsxs("div",{className:R("flex items-center gap-2 px-3 py-2 transition-colors",k.hover),children:[s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(m,{size:14,className:p.color}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:p.label})]}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:p.detail}),p.count>0&&s.jsx("span",{className:R("text-[11px] flex-shrink-0",k.text.faint),children:p.count}),s.jsx(nn,{size:12,className:R("transition-transform duration-150 flex-shrink-0",k.text.faint,!o&&"-rotate-90")})]})}),s.jsx(Ga,{children:e&&s.jsx("div",{className:`border-t ${k.separator}`,children:c?.mode==="content"&&c.groups.length>0?s.jsx(Sy,{groups:c.groups,pattern:h}):c?.mode==="files"&&c.files.length>0?s.jsx(Cy,{files:c.files}):s.jsx("pre",{className:R("m-0 px-3 py-3 font-mono text-[13px] leading-relaxed whitespace-pre-wrap break-words",k.codeBg,k.text.primary),children:e})})})]})})})}function Ty(t){switch(t){case"completed":return s.jsx(gr,{size:14,className:"text-emerald-400/80 flex-shrink-0"});case"in_progress":return s.jsx(vd,{size:14,className:"text-cyan-400/80 flex-shrink-0"});default:return s.jsx(br,{size:14,className:`${k.text.muted} flex-shrink-0`})}}function Iy({input:t,result:e,isWrite:n}){let r=[];n&&t.todos&&Array.isArray(t.todos)?r=t.todos:!n&&e&&(r=fg(e));const o=r.filter(m=>m.status==="completed").length,a=r.filter(m=>m.status==="in_progress").length,i=r.filter(m=>m.status==="pending").length,l=[];o>0&&l.push(`${o} done`),a>0&&l.push(`${a} active`),i>0&&l.push(`${i} pending`);const c=l.length>0?l.join(", "):"No items",[d,p]=u.useState(()=>r.length>0&&r.length<=8);return s.jsx(De,{isExpanded:d,onExpandedChange:p,cardClassName:ce.indigo.card,canExpand:r.length>0,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Lg,{size:14,className:`${ce.indigo.icon} flex-shrink-0`}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:n?"Todos":"Todo List"})]}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:c}),r.length>0&&s.jsxs("span",{className:`text-[10px] ${k.text.faint}`,children:[r.length," items"]})]}),content:r.length>0?s.jsx("div",{className:`border-t ${k.separator} px-3 py-2.5 space-y-1.5`,children:r.map((m,h)=>s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("div",{className:"mt-0.5",children:Ty(m.status)}),s.jsx("span",{className:`text-[13px] leading-relaxed ${m.status==="completed"?`line-through ${k.text.faint}`:k.text.primary}`,children:m.content})]},m.id||`todo-${h}`))}):void 0})}function Ay(t){const e=t.match(/Links:\s*(\[[\s\S]*?\])/);if(!e)return[];try{const n=JSON.parse(e[1]);if(Array.isArray(n))return n.filter(r=>r.title&&r.url)}catch{}return[]}function Ry(t){const e=t.indexOf(`]
|
|
38
38
|
`);return e===-1?"":t.slice(e+2).trim()}function Py({links:t}){return s.jsx("div",{className:"px-3 py-2 space-y-1.5",children:t.map((e,n)=>s.jsxs("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-start gap-2 group",style:{textDecoration:"none"},children:[s.jsx("img",{src:`https://www.google.com/s2/favicons?domain=${sn(e.url)}&sz=32`,alt:"",width:12,height:12,className:"w-3 h-3 rounded-sm mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:`text-[13px] ${k.text.primary} group-hover:text-blue-400 dark:group-hover:text-blue-300 truncate`,children:e.title}),s.jsx("div",{className:`text-[13px] ${k.text.faint} truncate`,children:sn(e.url)})]})]},n))})}function eu({result:t,compact:e}){const n=Ay(t),r=Ry(t),o=e?Ta:Ls;return n.length===0?s.jsx("div",{className:`px-3 py-2.5 ${o}`,children:s.jsx(rs,{children:t})}):s.jsxs("div",{className:k.codeBg,children:[s.jsx(Py,{links:n}),r&&s.jsx("div",{className:`border-t ${k.separator} px-3 py-2.5 ${o}`,children:s.jsx(rs,{children:r})})]})}function My({result:t,url:e,compact:n}){const r=n?Ta:Ls;return s.jsxs("div",{className:k.codeBg,children:[e&&s.jsx("div",{className:`px-3 py-2 border-b ${k.separator}`,children:s.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[13px] transition-all
|
|
39
39
|
bg-stone-100 text-stone-500 hover:bg-stone-200 hover:text-stone-700
|
|
40
40
|
dark:bg-zinc-800/50 dark:text-zinc-400 dark:hover:bg-zinc-700/50 dark:hover:text-zinc-300`,style:{textDecoration:"none"},children:[s.jsx("img",{src:`https://www.google.com/s2/favicons?domain=${sn(e)}&sz=32`,alt:"",width:12,height:12,className:"w-3 h-3 rounded-sm"}),s.jsx("span",{children:sn(e)})]})}),s.jsx("div",{className:`px-3 py-2.5 ${r}`,children:s.jsx(rs,{children:t})})]})}function Ly({content:t,compact:e}){const n=e?Ta:Ls;return s.jsx("div",{className:`px-3 py-2.5 ${n}`,children:s.jsx(rs,{children:t})})}const Oy=5;function Dy({input:t,result:e,toolType:n}){const r=n==="WebSearch",o=e?e.split(`
|
|
41
|
-
`).filter(c=>c.trim()).length:0,[a,i]=u.useState(()=>o>0&&o<=Oy),l=()=>r?t?.query||"Web search":(t?.url?sn(t.url):"")||"Fetched URL";return s.jsx(De,{isExpanded:a,onExpandedChange:i,cardClassName:
|
|
42
|
-
`).filter(E=>E.trim()).length:0,[N,S]=u.useState(()=>l||w>0&&w<=5);u.useEffect(()=>{l&&!N&&S(!0)},[l]);const T=u.useRef(null),C=u.useRef(!1),j=u.useCallback(()=>{const E=T.current;E&&(C.current=E.scrollHeight-E.scrollTop-E.clientHeight>60)},[]);return u.useEffect(()=>{T.current&&c.length>0&&!C.current&&T.current.scrollTo({top:T.current.scrollHeight,behavior:"smooth"})},[c.length]),s.jsx(De,{isExpanded:N,onExpandedChange:S,wrapperClassName:"w-full",cardClassName:
|
|
41
|
+
`).filter(c=>c.trim()).length:0,[a,i]=u.useState(()=>o>0&&o<=Oy),l=()=>r?t?.query||"Web search":(t?.url?sn(t.url):"")||"Fetched URL";return s.jsx(De,{isExpanded:a,onExpandedChange:i,cardClassName:ce.emerald.card,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[r?s.jsx(is,{size:14,className:`${ce.emerald.icon} flex-shrink-0`}):s.jsx(Os,{size:14,className:`${ce.emerald.icon} flex-shrink-0`}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:r?"Search":"Fetch"})]}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:l()})]}),content:e?s.jsx("div",{className:`border-t ${k.separator} max-h-80 overflow-y-auto ${k.scrollbar}`,children:r?s.jsx(eu,{result:e}):s.jsx(My,{result:e,url:t?.url})}):void 0})}const $y={Explore:{icon:jg,tint:_t.blue,label:"Explorer"},Plan:{icon:Mg,tint:_t.yellow,label:"Architect"},"code-reviewer":{icon:Cg,tint:_t.purple,label:"Reviewer"},"statusline-setup":{icon:jd,tint:_t.green,label:"Config"}},zy={icon:Ng,tint:_t.purple,label:"Agent"},Fy={};function nc({input:t,result:e,toolUseId:n,childrenMessages:r=Fy,isPending:o=!1,isStreaming:a,renderChildMessage:i}){const l=n&&r[n]&&r[n].length>0,c=n?r[n]||[]:[],d=t?.description||"Subagent task",p=t?.subagent_type||"general",m=!!t?.team_name,h=t?.name,g=fd(t?.name),f=$y[p]||zy,x=g&&_t[g]||f.tint,b=m?vg:f.icon,y=m?h||"Agent":f.label,v=a!==!1&&(o||!e&&!l),w=e?e.split(`
|
|
42
|
+
`).filter(E=>E.trim()).length:0,[N,S]=u.useState(()=>l||w>0&&w<=5);u.useEffect(()=>{l&&!N&&S(!0)},[l]);const T=u.useRef(null),C=u.useRef(!1),j=u.useCallback(()=>{const E=T.current;E&&(C.current=E.scrollHeight-E.scrollTop-E.clientHeight>60)},[]);return u.useEffect(()=>{T.current&&c.length>0&&!C.current&&T.current.scrollTo({top:T.current.scrollHeight,behavior:"smooth"})},[c.length]),s.jsx(De,{isExpanded:N,onExpandedChange:S,wrapperClassName:"w-full",cardClassName:R(x.border,x.bg),headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[v?s.jsx(at,{size:14,className:R(x.icon,"animate-spin flex-shrink-0")}):s.jsx(b,{size:14,className:R(x.icon,"flex-shrink-0")}),s.jsx("span",{className:`text-xs font-medium ${k.text.muted}`,children:y}),m&&g&&s.jsx("span",{className:R("w-1.5 h-1.5 rounded-full flex-shrink-0",v?"animate-pulse":"",`bg-${g}-400`)})]}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:d}),p!=="general"&&p!=="general-purpose"&&s.jsx("span",{className:`text-[13px] ${k.text.faint}`,children:p})]}),content:s.jsx("div",{className:`border-t ${k.separator}`,children:l?s.jsx("div",{ref:T,onScroll:j,className:R("max-h-80 overflow-y-auto p-3 space-y-1",k.scrollbar,"bg-stone-50/50 dark:bg-zinc-950/50"),children:c.map(E=>s.jsx(Ie.Fragment,{children:i?i(E):null},E.messageId))}):e?s.jsx("pre",{className:R("m-0 px-3 py-3 font-mono text-[13px] leading-relaxed whitespace-pre-wrap break-words",k.codeBg,k.text.primary),children:e}):null})})}const Vy=5;function rc({input:t,result:e,isPending:n=!1}){const r=t?.task_id||"unknown",o=t?.block!==!1,a=e?e.split(`
|
|
43
43
|
`).filter(d=>d.trim()).length:0,[i,l]=u.useState(()=>a>0&&a<=Vy),c=()=>{if(n)return o?"Waiting for task...":"Checking status...";if(e){const d=e.split(`
|
|
44
44
|
`)[0].slice(0,60);return d.length<e.split(`
|
|
45
|
-
`)[0].length?d+"...":d}return"completed"};return s.jsx(De,{isExpanded:i,onExpandedChange:l,cardClassName:
|
|
45
|
+
`)[0].length?d+"...":d}return"completed"};return s.jsx(De,{isExpanded:i,onExpandedChange:l,cardClassName:ce.purple.card,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[n?s.jsx(at,{size:14,className:`${ce.purple.icon} animate-spin flex-shrink-0`}):s.jsx(Sg,{size:14,className:`${ce.purple.icon} flex-shrink-0`}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:"Output"})]}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:c()}),s.jsx("span",{className:`text-[13px] ${k.text.faint} font-mono`,children:r.slice(0,8)})]}),content:s.jsx("div",{className:`border-t ${k.separator}`,children:e?s.jsx("pre",{className:R("m-0 px-3 py-3 font-mono text-[13px] leading-relaxed whitespace-pre-wrap break-words max-h-96 overflow-auto",k.codeBg,k.text.primary),children:e}):n?null:s.jsx("div",{className:`px-3 py-3 text-xs ${k.text.muted}`,children:"No output received"})})})}function oc({input:t,result:e,isPendingApproval:n,priorOutcome:r=!1,onApprove:o,onReject:a}){const[i,l]=u.useState(!!n&&!r),[c,d]=u.useState(r||"pending"),p=t.plan||e||"No plan provided",m=u.useCallback(async()=>{d("approved"),await o?.()},[o]),h=u.useCallback(async()=>{d("rejected"),await a?.()},[a]),g=n&&c==="pending",f=c==="approved"?"Implementation plan":c==="rejected"?"Plan rejected":n?"Awaiting approval":"Implementation plan",x=`
|
|
46
46
|
[&_table]:w-full [&_table]:text-[13px]
|
|
47
47
|
[&_thead]:bg-stone-100 dark:[&_thead]:bg-zinc-800/20 [&_thead]:border-b ${k.separator}
|
|
48
48
|
[&_tbody]:divide-y [&_tbody]:divide-stone-200 dark:[&_tbody]:divide-zinc-800/40
|
|
49
49
|
[&_th]:px-3 [&_th]:py-1.5 [&_th]:text-left [&_th]:text-[13px] [&_th]:text-stone-400 dark:[&_th]:text-zinc-500
|
|
50
|
-
[&_td]:px-3 [&_td]:py-1.5 [&_td]:text-stone-500 dark:[&_td]:text-zinc-400`;return s.jsx(De,{isExpanded:i,onExpandedChange:l,wrapperClassName:"w-full",cardClassName:
|
|
50
|
+
[&_td]:px-3 [&_td]:py-1.5 [&_td]:text-stone-500 dark:[&_td]:text-zinc-400`;return s.jsx(De,{isExpanded:i,onExpandedChange:l,wrapperClassName:"w-full",cardClassName:ce.rose.card,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(kg,{size:14,className:`${ce.rose.icon} flex-shrink-0`}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:"Plan"})]}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:f})]}),content:s.jsxs(s.Fragment,{children:[s.jsx("div",{className:`border-t ${k.separator} px-3 py-2.5 max-h-96 overflow-y-auto ${k.scrollbar} ${Ls} ${x}`,children:s.jsx(rs,{remarkPlugins:[Cs],children:p})}),g&&s.jsxs("div",{className:"border-t border-rose-500/20 bg-rose-500/5 px-3 py-2.5 flex items-center gap-3",children:[s.jsx("span",{className:`text-[13px] ${k.text.secondary} flex-1`,children:"Ready to implement?"}),s.jsxs("button",{onClick:b=>{b.stopPropagation(),h()},className:`flex items-center gap-1.5 px-2.5 py-1 rounded text-[13px] border transition-colors
|
|
51
51
|
${k.text.secondary} border-stone-300 dark:border-zinc-700/50
|
|
52
52
|
hover:border-red-500/30 hover:text-red-400`,children:[s.jsx(yr,{size:11})," Reject"]}),s.jsxs("button",{onClick:b=>{b.stopPropagation(),m()},className:"flex items-center gap-1.5 px-2.5 py-1 rounded text-[13px] text-rose-400 border border-rose-500/30 hover:bg-rose-500/10 transition-colors",children:[s.jsx(Do,{size:11})," Approve"]})]})]})})}function ac(t){return/\(Recommended\)\s*$/i.test(t)}function By(t){return t.replace(/\s*\(Recommended\)\s*$/i,"")}function tu({input:t,result:e,questionId:n,onAnswer:r,onDismiss:o,isRecovered:a=!1}){const[i,l]=u.useState({}),[c,d]=u.useState({}),[p,m]=u.useState({}),[h,g]=u.useState(!1),f=t.questions||[];if(e)return s.jsx("div",{className:"w-fit max-w-full",children:s.jsx("div",{className:`border rounded-lg ${k.card.border} ${k.card.bg}`,children:s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[s.jsx(Do,{size:14,className:"text-emerald-400/80 flex-shrink-0"}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:"Question answered"})]})})});const x=(N,S,T)=>{S!=="__other__"&&m(C=>({...C,[N]:!1})),l(C=>{const j={...C};return j[N]||(j[N]=new Set),T?j[N].has(S)?j[N].delete(S):j[N].add(S):j[N]=new Set([S]),j})},b=N=>{m(S=>{const T={...S,[N]:!S[N]};return T[N]&&l(C=>({...C,[N]:new Set})),T})},y=async()=>{if(!n||!r)return;const N={};if(f.forEach((S,T)=>{if(p[T]&&c[T]?.trim())N[S.question]=`Other: ${c[T].trim()}`;else{const C=i[T];C&&C.size>0&&(N[S.question]=Array.from(C).join(", "))}}),Object.keys(N).length!==0){g(!0);try{await r(n,N)}catch(S){console.error("[AskUserQuestionTool] onAnswer failed:",S)}finally{g(!1)}}},v=f.every((N,S)=>i[S]&&i[S].size>0||p[S]&&c[S]?.trim()),w=f.some(N=>N.options.some(S=>ac(S.label)));return s.jsxs("div",{className:"w-full rounded-lg overflow-hidden border border-cyan-500/25 bg-cyan-500/5",children:[s.jsxs("div",{className:"px-3 py-2 border-b border-cyan-500/20 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Dg,{size:14,className:"text-cyan-400/80"}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:a?"Waiting for your answer":"Input required"})]}),o&&n&&s.jsx("button",{onClick:()=>o(n),className:`p-1 rounded ${k.text.faint} hover:${k.text.secondary} ${k.hover} transition-colors`,title:"Dismiss",children:s.jsx(yr,{size:12})})]}),s.jsxs("div",{className:"p-3 space-y-3",children:[a&&s.jsx("div",{className:"text-[13px] text-cyan-400/50",children:"Session paused. Answer to resume."}),f.length===0&&s.jsx("div",{className:"text-xs text-amber-400",children:"No questions received. Waiting for question data..."}),f.map((N,S)=>s.jsxs("div",{className:"space-y-2",children:[N.header&&s.jsx("span",{className:"text-[13px] text-cyan-400/40",children:N.header}),s.jsx("div",{className:`text-xs ${k.text.primary}`,children:N.question}),s.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[N.options.map((T,C)=>{const j=i[S]?.has(T.label)&&!p[S],E=ac(T.label);return s.jsxs("button",{onClick:()=>x(S,T.label,N.multiSelect||!1),disabled:h||!n,style:{touchAction:"manipulation"},className:`px-3 py-1.5 rounded border text-[13px] transition-colors select-none flex items-center gap-1.5 ${j?"border-cyan-400/50 bg-cyan-500/15 text-cyan-200":`border-stone-300 dark:border-zinc-700/40 bg-stone-50 dark:bg-zinc-900/50 ${k.text.secondary} hover:border-cyan-500/30 hover:${k.text.primary}`} ${h||!n?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:[N.multiSelect&&j&&s.jsx(Do,{size:10,className:"text-cyan-400"}),By(T.label),E&&s.jsx(Oi,{size:10,className:"text-cyan-400/60 fill-cyan-400/30"})]},C)}),s.jsxs("button",{onClick:()=>b(S),disabled:h||!n,style:{touchAction:"manipulation"},className:`px-3 py-1.5 rounded border border-dashed text-[13px] transition-colors select-none flex items-center gap-1.5 ${p[S]?"border-cyan-400/50 bg-cyan-500/10 text-cyan-300":`border-stone-300 dark:border-zinc-700/30 bg-stone-50 dark:bg-zinc-900/30 ${k.text.muted} hover:border-cyan-500/30`} ${h||!n?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:[s.jsx(kd,{size:10})," Other..."]})]}),p[S]&&s.jsx("textarea",{value:c[S]||"",onChange:T=>d(C=>({...C,[S]:T.target.value})),placeholder:"Type your response...",disabled:h,className:`w-full px-3 py-2 rounded border text-[13px] placeholder:${k.text.faint} focus:outline-none focus:border-cyan-500/40 resize-none transition-colors
|
|
53
53
|
border-stone-300 dark:border-zinc-700/40 bg-stone-50 dark:bg-zinc-900/50 ${k.text.primary}`,rows:2})]},S)),s.jsxs("div",{className:"flex items-center justify-between gap-3 pt-1",children:[w?s.jsxs("div",{className:`flex items-center gap-1.5 text-[13px] ${k.text.faint}`,children:[s.jsx(Oi,{size:10,className:"text-cyan-400/60 fill-cyan-400/30"})," ",s.jsx("span",{children:"Recommended"})]}):s.jsx("div",{}),s.jsx("button",{onClick:y,disabled:!v||h||!n,className:`flex items-center gap-1.5 px-3 py-1.5 rounded text-[13px] transition-colors ${v&&!h&&n?"border border-cyan-500/30 text-cyan-400 hover:bg-cyan-500/10 cursor-pointer":`border border-stone-300 dark:border-zinc-700/40 ${k.text.faint} cursor-not-allowed`}`,children:h?s.jsx("span",{children:a?"Resuming...":"Submitting..."}):s.jsxs(s.Fragment,{children:[s.jsx("span",{children:a?"Submit & Resume":"Submit"}),s.jsx(yd,{size:11})]})})]})]})]})}const Uy=5;function Gy({toolName:t,input:e,result:n}){const r=n?n.split(`
|
|
54
54
|
`).filter(c=>c.trim()).length:0,[o,a]=u.useState(()=>r>0&&r<=Uy),i=c=>{try{return JSON.stringify(Ia(c),null,2)}catch{return c}},l=()=>{if(n){const c=n.split(`
|
|
55
55
|
`)[0].slice(0,60);return c.length<n.split(`
|
|
56
|
-
`)[0].length?c+"...":c}return"completed"};return s.jsx(De,{isExpanded:o,onExpandedChange:a,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(jd,{size:14,className:`${k.text.muted} flex-shrink-0`}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:t})]}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:l()})]}),content:s.jsxs("div",{className:`border-t ${k.separator}`,children:[n&&s.jsx("pre",{className:
|
|
56
|
+
`)[0].length?c+"...":c}return"completed"};return s.jsx(De,{isExpanded:o,onExpandedChange:a,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(jd,{size:14,className:`${k.text.muted} flex-shrink-0`}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:t})]}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:l()})]}),content:s.jsxs("div",{className:`border-t ${k.separator}`,children:[n&&s.jsx("pre",{className:R("m-0 px-3 py-3 font-mono text-[13px] leading-relaxed whitespace-pre-wrap break-words",k.codeBg,k.text.primary),children:i(n)}),e&&s.jsxs("div",{className:R("border-t px-3 py-2.5 font-mono text-[13px] leading-relaxed",k.separator,k.codeBgSubtle),children:[s.jsx("span",{className:`uppercase text-[13px] tracking-wider ${k.text.faint}`,children:"Input"}),s.jsx("pre",{className:R("m-0 mt-1 whitespace-pre-wrap break-words",k.text.secondary),children:JSON.stringify(e,null,2)})]})]})})}function Hy(t){const e=t.match(/^mcp__([^_]+)__(.+)$/);return e?{server:e[1].replace(/_/g," "),tool:e[2].replace(/_/g," ")}:{server:"",tool:t}}const qy=["path","url","query","pattern","command","prompt","code","selector","text","expression","script","value","name"];function Wy(t){for(const e of qy){const n=t[e];if(typeof n=="string"&&n.length>0)return n.length>80?n.slice(0,77)+"…":n}for(const e of Object.values(t))if(typeof e=="string"&&e.length>0)return e.length>80?e.slice(0,77)+"…":e;return""}function Ky(t){try{const e=JSON.parse(t);return JSON.stringify(e,null,2)}catch{return t}}const Qy=5;function Yy({toolName:t,input:e,result:n}){const r=n?n.split(`
|
|
57
57
|
`).filter(d=>d.trim()).length:0,[o,a]=u.useState(()=>r>0&&r<=Qy),{server:i,tool:l}=Hy(t),c=Wy(e)||(n?n.split(`
|
|
58
|
-
`)[0].slice(0,80):"completed");return s.jsx(De,{isExpanded:o,onExpandedChange:a,cardClassName:
|
|
58
|
+
`)[0].slice(0,80):"completed");return s.jsx(De,{isExpanded:o,onExpandedChange:a,cardClassName:ce.purple.card,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(Gg,{size:14,className:`${ce.purple.icon} flex-shrink-0`}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:l}),i&&s.jsx("span",{className:`text-[13px] ${k.text.faint}`,children:i})]}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:c})]}),content:s.jsx("div",{className:`border-t ${k.separator}`,children:n&&s.jsx("pre",{className:R("m-0 px-3 py-3 font-mono text-[13px] leading-relaxed whitespace-pre-wrap break-words max-h-96 overflow-auto",k.codeBg,k.text.primary,k.scrollbar),children:Ky(n)})})})}function Jy(t){if(!t.includes("## Pages"))return null;const e=t.split(`
|
|
59
59
|
`),n=[];for(const r of e){const o=r.match(/^\s*(\d+):\s+(.+?)(\s+\[selected\])?\s*$/);o&&n.push({id:o[1],label:o[2],selected:!!o[3]})}return n.length>0?n:null}function Xy(t){if(!t.includes("## Console messages"))return null;const e=t.split(`
|
|
60
60
|
`),n=[];for(const r of e){const o=r.match(/^msgid=(\d+)\s+\[(\w+)]\s+(.+)$/);o&&n.push({id:o[1],level:o[2],text:o[3]})}return n.length>0?n:null}function Zy(t){if(!t.includes("## Network requests"))return null;const e=t.split(`
|
|
61
61
|
`),n=[];for(const r of e){const o=r.match(/^reqid=(\d+)\s+(\w+)\s+(\S+)\s+\[(\d+)]/);o&&n.push({id:o[1],method:o[2],url:o[3],status:o[4]})}return n.length>0?n:null}function ic(t){return t.match(/Showing \d+-\d+ of \d+.*$/m)?.[0]}function ev(t){const e=t.match(/^mcp__chrome[_-]devtools__(.+)$/);return e?e[1]:t}const tv=new Set(["click","fill","type_text","press_key","hover","drag","navigate_page","close_page","select_page","new_page","handle_dialog","upload_file","resize_page","emulate","fill_form"]);function sv(t,e){if(!e||!e.trim())return{kind:"confirmation",text:"Completed"};const n=Xd(e),r=n?n.text:e;if(t==="take_screenshot"&&n){const o=n.blocks.find(i=>i.type==="image"&&i.source?.data),a=o?Zd(o):null;if(a)return{kind:"image",dataUrl:a,text:r||void 0}}if(tv.has(t))return{kind:"confirmation",text:(r.split(`
|
|
62
62
|
`).find(a=>a.trim()&&!a.startsWith("##"))||r.split(`
|
|
63
|
-
`)[0]).trim()};if(t==="evaluate_script"){const o=r.match(/```(?:json)?\n?([\s\S]*?)\n?```/);if(o){const a=r.slice(0,r.indexOf("```")).trim()||null;let i=o[1];try{i=JSON.stringify(JSON.parse(i),null,2)}catch{}return{kind:"script",preamble:a,code:i}}return{kind:"script",preamble:null,code:r}}if(t==="list_pages"||r.includes("## Pages")){const o=Jy(r);if(o)return{kind:"pages",pages:o}}if(t==="list_console_messages"||r.includes("## Console messages")){const o=Xy(r);if(o)return{kind:"console",messages:o,header:ic(r)}}if(t==="list_network_requests"||r.includes("## Network requests")){const o=Zy(r);if(o)return{kind:"network",requests:o,header:ic(r)}}return t==="take_snapshot"||t==="wait_for"&&r.includes("## Latest page snapshot")?{kind:"snapshot",text:r}:t.includes("performance")||t==="lighthouse_audit"?{kind:"prose",text:r}:{kind:"raw",text:r}}function nv(t){return t==="take_screenshot"?Ra:t==="take_snapshot"?Qg:t.includes("page")||t.includes("navigate")?is:t.includes("click")||t.includes("fill")||t.includes("hover")||t.includes("drag")||t.includes("type")||t.includes("press")?Fg:t.includes("console")?Yn:t.includes("network")?Vg:t.includes("script")||t.includes("evaluate")?Yn:t.includes("performance")||t.includes("lighthouse")?bd:t.includes("emulate")||t.includes("resize")?zg:t.includes("wait")?Ig:_g}function rv(t,e){if(e.url&&typeof e.url=="string")try{return new URL(e.url).hostname+new URL(e.url).pathname.slice(0,40)}catch{return e.url.slice(0,60)}if(e.selector&&typeof e.selector=="string")return e.selector;if(e.text&&typeof e.text=="string")return e.text.slice(0,60);if(e.expression&&typeof e.expression=="string")return e.expression.slice(0,60);if(e.value&&typeof e.value=="string")return e.value.slice(0,60);if(e.uid&&typeof e.uid=="string")return`uid: ${e.uid}`;const n=e.function;if(typeof n=="string")return n.slice(0,60);for(const r of Object.values(e))if(typeof r=="string"&&r.length>0)return r.slice(0,60);return""}function ov({pages:t}){return s.jsx("div",{className:`divide-y ${k.separator} max-h-64 overflow-y-auto ${k.scrollbar}`,children:t.map(e=>s.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-2",children:[s.jsx(is,{size:10,className:e.selected?
|
|
63
|
+
`)[0]).trim()};if(t==="evaluate_script"){const o=r.match(/```(?:json)?\n?([\s\S]*?)\n?```/);if(o){const a=r.slice(0,r.indexOf("```")).trim()||null;let i=o[1];try{i=JSON.stringify(JSON.parse(i),null,2)}catch{}return{kind:"script",preamble:a,code:i}}return{kind:"script",preamble:null,code:r}}if(t==="list_pages"||r.includes("## Pages")){const o=Jy(r);if(o)return{kind:"pages",pages:o}}if(t==="list_console_messages"||r.includes("## Console messages")){const o=Xy(r);if(o)return{kind:"console",messages:o,header:ic(r)}}if(t==="list_network_requests"||r.includes("## Network requests")){const o=Zy(r);if(o)return{kind:"network",requests:o,header:ic(r)}}return t==="take_snapshot"||t==="wait_for"&&r.includes("## Latest page snapshot")?{kind:"snapshot",text:r}:t.includes("performance")||t==="lighthouse_audit"?{kind:"prose",text:r}:{kind:"raw",text:r}}function nv(t){return t==="take_screenshot"?Ra:t==="take_snapshot"?Qg:t.includes("page")||t.includes("navigate")?is:t.includes("click")||t.includes("fill")||t.includes("hover")||t.includes("drag")||t.includes("type")||t.includes("press")?Fg:t.includes("console")?Yn:t.includes("network")?Vg:t.includes("script")||t.includes("evaluate")?Yn:t.includes("performance")||t.includes("lighthouse")?bd:t.includes("emulate")||t.includes("resize")?zg:t.includes("wait")?Ig:_g}function rv(t,e){if(e.url&&typeof e.url=="string")try{return new URL(e.url).hostname+new URL(e.url).pathname.slice(0,40)}catch{return e.url.slice(0,60)}if(e.selector&&typeof e.selector=="string")return e.selector;if(e.text&&typeof e.text=="string")return e.text.slice(0,60);if(e.expression&&typeof e.expression=="string")return e.expression.slice(0,60);if(e.value&&typeof e.value=="string")return e.value.slice(0,60);if(e.uid&&typeof e.uid=="string")return`uid: ${e.uid}`;const n=e.function;if(typeof n=="string")return n.slice(0,60);for(const r of Object.values(e))if(typeof r=="string"&&r.length>0)return r.slice(0,60);return""}function ov({pages:t}){return s.jsx("div",{className:`divide-y ${k.separator} max-h-64 overflow-y-auto ${k.scrollbar}`,children:t.map(e=>s.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-2",children:[s.jsx(is,{size:10,className:e.selected?ce.cyan.icon:k.text.faint}),s.jsx("span",{className:R("text-[13px] font-mono flex-shrink-0",k.text.faint),children:e.id}),s.jsx("span",{className:R("text-[13px] truncate flex-1 min-w-0",k.text.primary),children:e.label}),e.selected&&s.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded bg-cyan-500/15 dark:bg-cyan-500/10 text-cyan-700 dark:text-cyan-400/80 flex-shrink-0",children:"selected"})]},e.id))})}const av={error:"bg-red-500/15 dark:bg-red-500/10 text-red-700 dark:text-red-400/80",warn:"bg-amber-500/15 dark:bg-amber-500/10 text-amber-700 dark:text-amber-400/80",warning:"bg-amber-500/15 dark:bg-amber-500/10 text-amber-700 dark:text-amber-400/80",issue:"bg-amber-500/15 dark:bg-amber-500/10 text-amber-700 dark:text-amber-400/80",info:"bg-blue-500/12 dark:bg-blue-500/8 text-blue-700 dark:text-blue-400/80",debug:"bg-parchment-200/60 dark:bg-zinc-800/50 text-parchment-500 dark:text-zinc-500"},iv="bg-parchment-200/40 dark:bg-zinc-800/30 text-parchment-600 dark:text-zinc-400";function cv({messages:t,header:e}){return s.jsxs("div",{className:"max-h-72 overflow-y-auto",children:[e&&s.jsx("div",{className:R("px-3 py-1 text-[13px]",k.text.faint),children:e}),s.jsx("div",{className:`divide-y ${k.separator}`,children:t.map(n=>s.jsxs("div",{className:"px-3 py-1.5 flex gap-2 items-start",children:[s.jsx("span",{className:R("text-[9px] px-1 py-0.5 rounded flex-shrink-0 font-mono",av[n.level]||iv),children:n.level}),s.jsx("span",{className:R("text-[13px] leading-relaxed font-mono break-all flex-1 min-w-0",k.text.primary),children:n.text})]},n.id))})]})}const lv={GET:"text-emerald-700 dark:text-emerald-400/80",POST:"text-blue-700 dark:text-blue-400/80",PUT:"text-amber-700 dark:text-amber-400/80",PATCH:"text-amber-700 dark:text-amber-400/80",DELETE:"text-red-700 dark:text-red-400/80"};function dv(t){const e=parseInt(t,10);return e>=200&&e<300?"text-emerald-700 dark:text-emerald-400/80":e>=300&&e<400?"text-blue-700 dark:text-blue-400/80":e>=400&&e<500?"text-amber-700 dark:text-amber-400/80":e>=500?"text-red-700 dark:text-red-400/80":k.text.muted}function uv(t){try{const e=new URL(t),n=e.pathname+e.search;return n.length>60?n.slice(0,57)+"...":n}catch{return t.length>60?t.slice(0,57)+"...":t}}function pv({requests:t,header:e}){return s.jsxs("div",{className:"max-h-72 overflow-y-auto",children:[e&&s.jsx("div",{className:R("px-3 py-1 text-[13px]",k.text.faint),children:e}),s.jsx("div",{className:`divide-y ${k.separator}`,children:t.map(n=>s.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-2",children:[s.jsx("span",{className:R("text-[13px] font-mono font-medium w-8 flex-shrink-0",lv[n.method]||k.text.muted),children:n.method}),s.jsx("span",{className:R("text-[13px] font-mono w-7 flex-shrink-0 text-right",dv(n.status)),children:n.status}),s.jsx("span",{className:R("text-[13px] font-mono truncate flex-1 min-w-0",k.text.primary),children:uv(n.url)})]},n.id))})]})}function mv({text:t}){return s.jsxs("div",{className:"px-3 py-2 flex items-start gap-2",children:[s.jsx(xr,{size:12,className:"text-emerald-600 dark:text-emerald-400/80 flex-shrink-0 mt-0.5"}),s.jsx("span",{className:R("text-[13px] leading-relaxed whitespace-pre-wrap",k.text.secondary),children:t})]})}function hv({preamble:t,code:e}){return s.jsxs("div",{children:[t&&s.jsx("div",{className:R("px-3 pt-2 pb-1 text-[13px]",k.text.secondary),children:t}),s.jsx("pre",{className:R("m-0 px-3 py-2.5 font-mono text-[13px] leading-relaxed whitespace-pre-wrap break-words max-h-64 overflow-auto",k.codeBg,k.text.primary,k.scrollbar),children:e})]})}function fv({dataUrl:t,text:e}){return s.jsxs("div",{className:"px-3 py-2",children:[e&&s.jsx("span",{className:R("text-[13px] block mb-2",k.text.secondary),children:e}),s.jsx("img",{src:t,alt:"Screenshot",className:"rounded border border-parchment-200 dark:border-zinc-800/40 max-w-full max-h-80 object-contain"})]})}function gv({text:t}){const e=t.split(`
|
|
64
64
|
`),n=e.findIndex(l=>l.trim().startsWith("uid=")),r=n>0?e.slice(0,n).filter(l=>l.trim()).join(`
|
|
65
65
|
`):null,o=n>=0?e.slice(n):e,a=o.length>40,i=o.slice(0,40).join(`
|
|
66
|
-
`);return s.jsxs("div",{children:[r&&s.jsx("div",{className:
|
|
67
|
-
`);return s.jsx(De,{isExpanded:i,onExpandedChange:l,canExpand:!h,cardClassName:
|
|
68
|
-
`&&!r?(o.push(n),n="",o.length>1&&e.push([...o]),o.length=0):n+=i}return o.push(n),o.length>1&&e.push(o),e}function jv(t){try{const e=new Date(t);return e.toLocaleDateString("en-US",{month:"short",day:"numeric"})+" "+e.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"})}catch{return t}}function Nv(t){const e=t.match(/^mcp__slack__(.+)$/);return e?e[1].replace(/_/g," "):"Slack"}function Sv(t,e){const n=t.match(/^mcp__slack__(.+)$/)?.[1]||"";if(n==="conversations_history"){const r=e.channel_id||"";return r.startsWith("#")||r.startsWith("@")?r:`#${r}`}if(n==="conversations_search_messages")return e.search_query||e.filter_in_channel||"messages";if(n==="users_search")return e.query||"";for(const r of Object.values(e))if(typeof r=="string"&&r.length>0)return r.length>60?r.slice(0,57)+"...":r;return""}function Cv({toolName:t,input:e,result:n}){const r=u.useMemo(()=>_v(n),[n]),[o,a]=u.useState(()=>r.length>0&&r.length<=5),i=Nv(t),l=Sv(t,e),c=r.length>0;return s.jsx(De,{isExpanded:o,onExpandedChange:a,cardClassName:ie.indigo.card,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(_d,{size:14,className:`${ie.indigo.icon} flex-shrink-0`}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:i})]}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:l}),c&&s.jsxs("span",{className:`text-[13px] ${k.text.faint} flex-shrink-0`,children:[r.length," message",r.length!==1?"s":""]})]}),content:s.jsx("div",{className:`border-t ${k.separator}`,children:c?s.jsx("div",{className:`divide-y ${k.separator} max-h-80 overflow-y-auto ${k.scrollbar}`,children:r.map((d,p)=>s.jsxs("div",{className:"px-3 py-2 flex gap-2.5",children:[s.jsx("div",{className:"flex-shrink-0 pt-0.5",children:s.jsx("div",{className:M("w-5 h-5 rounded flex items-center justify-center","bg-indigo-500/10 dark:bg-indigo-500/10"),children:s.jsx(Yg,{size:10,className:ie.indigo.icon})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-baseline gap-2",children:[s.jsx("span",{className:M("text-[13px] font-medium",k.text.primary),children:d.realName||d.userName}),d.channel&&s.jsxs("span",{className:M("text-[13px] flex items-center gap-0.5",k.text.faint),children:[s.jsx(Rg,{size:8}),d.channel.replace(/^#/,"")]}),s.jsx("span",{className:M("text-[13px] ml-auto flex-shrink-0",k.text.faint),children:jv(d.time)})]}),s.jsx("p",{className:M("text-[13px] leading-relaxed mt-0.5 whitespace-pre-wrap break-words",k.text.secondary),children:d.text})]})]},p))}):s.jsx("pre",{className:M("m-0 px-3 py-3 font-mono text-[13px] leading-relaxed whitespace-pre-wrap break-words",k.codeBg,k.text.primary),children:n})})})}function Ev(t){try{const e=JSON.parse(t);return e.results&&Array.isArray(e.results)?e:null}catch{return null}}function Tv(t){try{return new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return t}}function Iv(t){const e=t.match(/^mcp__(?:claude_ai_)?[Nn]otion__(.+)$/);return e?e[1].replace(/^notion-/,"").replace(/[-_]/g," "):"Notion"}function Av(t,e){const n=e.query;if(n)return n.length>60?n.slice(0,57)+"...":n;const r=e.id;if(r)return r;for(const o of Object.values(e))if(typeof o=="string"&&o.length>0)return o.length>60?o.slice(0,57)+"...":o;return""}function Rv({toolName:t,input:e,result:n}){const r=u.useMemo(()=>Ev(n),[n]),[o,a]=u.useState(()=>r!==null&&r.results.length>0&&r.results.length<=5),i=Iv(t),l=Av(t,e),c=r!==null&&r.results.length>0;return s.jsx(De,{isExpanded:o,onExpandedChange:a,cardClassName:ie.zinc.card,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(jt,{size:14,className:`${ie.zinc.icon} flex-shrink-0`}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:i})]}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:l}),c&&s.jsxs("span",{className:`text-[13px] ${k.text.faint} flex-shrink-0`,children:[r.results.length," result",r.results.length!==1?"s":""]})]}),content:s.jsx("div",{className:`border-t ${k.separator}`,children:c?s.jsx("div",{className:`divide-y ${k.separator} max-h-80 overflow-y-auto ${k.scrollbar}`,children:r.results.map(d=>s.jsx("div",{className:"px-3 py-2",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:M("text-[13px] font-medium",k.text.primary),children:d.title||"Untitled"}),d.type&&d.type!=="page"&&s.jsx("span",{className:M("text-[9px] px-1 py-0.5 rounded","bg-stone-200/60 dark:bg-zinc-800/50",k.text.faint),children:d.type})]}),d.highlight&&s.jsx("p",{className:M("text-[13px] leading-relaxed mt-0.5",k.text.secondary),children:d.highlight}),d.timestamp&&s.jsx("span",{className:M("text-[9px] mt-0.5 block",k.text.faint),children:Tv(d.timestamp)})]}),d.url&&s.jsx(Os,{size:10,className:M("flex-shrink-0 mt-1",k.text.faint)})]})},d.id))}):s.jsx("pre",{className:M("m-0 px-3 py-3 font-mono text-[13px] leading-relaxed whitespace-pre-wrap break-words",k.codeBg,k.text.primary),children:n})})})}function Pv(t){let e;try{const d=JSON.parse(t);if(Array.isArray(d)){const p=d.find(m=>m.type==="text"&&m.text);if(p?.text)e=JSON.parse(p.text);else return null}else e=d}catch{return null}const n=e.issues;if(n?.nodes&&Array.isArray(n.nodes))return{kind:"issues",issues:n.nodes};const r=e.issueCreate;if(r)return{kind:"mutation",success:!!r.success,issue:r.issue};const o=e.issueUpdate;if(o)return{kind:"mutation",success:!!o.success,issue:o.issue};const a=e.issueDelete;if(a)return{kind:"mutation",success:!!a.success};const i=e.issue;if(i?.identifier)return{kind:"issues",issues:[i]};const l=e.projects;if(l?.nodes&&Array.isArray(l.nodes))return{kind:"projects",projects:l.nodes};const c=e.project;return c?.name?{kind:"project",project:c}:null}function Mv(t){const e=t.match(/^mcp__(?:claude_ai_)?[Ll]inear__(.+)$/);return e?e[1].replace(/_/g," "):t}function Lv(t){const e=["query","title","identifiers","id","issueId"];for(const n of e){const r=t[n];if(typeof r=="string"&&r.length>0)return r.length>80?r.slice(0,77)+"…":r;if(Array.isArray(r))return r.join(", ").slice(0,80)}return""}const Ov={completed:xr,canceled:rn},Dv={completed:"text-emerald-600 dark:text-emerald-400/80",canceled:"text-zinc-400 dark:text-zinc-500",started:"text-amber-600 dark:text-amber-400/80",unstarted:"text-stone-400 dark:text-zinc-500",triage:"text-orange-500 dark:text-orange-400/80",backlog:"text-stone-400 dark:text-zinc-600"};function $v({issue:t}){const e=t.state?.type||"unstarted",n=Ov[e]||br,r=Dv[e]||k.text.faint;return s.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-2 min-w-0",children:[s.jsx(n,{size:12,className:M("flex-shrink-0",r)}),s.jsx("span",{className:M("text-[13px] font-mono flex-shrink-0",k.text.faint),children:t.identifier}),s.jsx("span",{className:M("text-[13px] truncate flex-1 min-w-0",k.text.primary),children:t.title}),t.assignee&&s.jsx("span",{className:M("text-[11px] flex-shrink-0",k.text.faint),children:t.assignee.name}),t.labels?.nodes&&t.labels.nodes.length>0&&s.jsx("div",{className:"flex gap-1 flex-shrink-0",children:t.labels.nodes.slice(0,2).map(o=>s.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded",style:o.color?{backgroundColor:`${o.color}20`,color:o.color}:void 0,children:o.name},o.name))}),t.url&&s.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:M("flex-shrink-0",k.text.faint,"hover:text-indigo-500"),children:s.jsx(Os,{size:10})})]})}function zv({success:t,issue:e}){return s.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",children:[t?s.jsx(xr,{size:12,className:"text-emerald-600 dark:text-emerald-400/80 flex-shrink-0"}):s.jsx(rn,{size:12,className:"text-red-600 dark:text-red-400/80 flex-shrink-0"}),e?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:M("text-[13px] font-mono",k.text.faint),children:e.identifier}),s.jsx("span",{className:M("text-[13px] truncate flex-1",k.text.primary),children:e.title}),e.url&&s.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:M("flex-shrink-0",k.text.faint,"hover:text-indigo-500"),children:s.jsx(Os,{size:10})})]}):s.jsx("span",{className:M("text-[13px]",k.text.secondary),children:t?"Success":"Failed"})]})}function dc({project:t}){return s.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-2 min-w-0",children:[s.jsx(br,{size:10,className:M("flex-shrink-0",k.text.faint)}),s.jsx("span",{className:M("text-[13px] truncate flex-1 min-w-0",k.text.primary),children:t.name}),t.state&&s.jsx("span",{className:M("text-[9px] px-1 py-0.5 rounded","bg-stone-200/60 dark:bg-zinc-800/50",k.text.faint),children:t.state}),t.url&&s.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:M("flex-shrink-0",k.text.faint,"hover:text-indigo-500"),children:s.jsx(Os,{size:10})})]})}function uc({size:t=14,className:e}){return s.jsxs("svg",{width:t,height:t,viewBox:"0 0 100 100",fill:"currentColor",className:e,children:[s.jsx("path",{d:"M1.22541 61.5228c-.97401-1.6679-.9621-3.7358.02515-5.393L42.2113 1.7038c1.0762-1.81266 3.3714-2.41393 5.1357-1.34447 1.7643 1.06946 2.3512 3.34827 1.2749 5.16094L7.66132 59.946c-.98736 1.6629-3.29117 2.2133-4.96353 1.2006-.59502-.3603-1.06135-.8799-1.37738-1.4706-.0527-.0985-.10188-.1997-.1474-.3034-.0159-.0363-.03138-.0728-.04644-.1096Z"}),s.jsx("path",{d:"M12.1816 77.934c-.7543-1.2904-.5323-2.9344.5671-3.9832l45.1186-43.0733c1.1466-1.0946 2.9483-1.0419 4.0275.1176 1.0793 1.1596 1.028 2.9791-.1186 4.0738L16.6576 78.1423c-1.1466 1.0946-2.9483 1.0419-4.0276-.1176-.1622-.1741-.2995-.3651-.4109-.5672-.0171-.031-.0337-.0623-.0497-.0939Z"}),s.jsx("path",{d:"M22.9861 85.7189c-.5308-.9079-.2765-2.0785.576-2.6838l38.3729-27.2402c.8897-.6314 2.1128-.4117 2.734.491.6213.9028.4032 2.1398-.4866 2.7712L25.8095 86.2973c-.89.6314-2.1129.4117-2.734-.491-.0358-.052-.069-.1057-.0994-.161Z"}),s.jsx("path",{d:"M32.4431 90.7801c-.3628-.6207-.0959-1.409.5883-1.7282l30.3399-14.1616c.7125-.3327 1.561-.0273 1.8977.6831.3367.7104.0327 1.5613-.6798 1.894l-30.34 14.1616c-.7124.3326-1.5609.0273-1.8976-.6831-.0326-.0687-.0599-.1396-.0818-.2132-.0057-.019-.011-.0381-.0158-.0574Z"}),s.jsx("path",{d:"M42.0827 93.402c-.1652-.5006.0993-1.0424.5898-1.2147l23.4313-8.2326c.5116-.1797 1.0727.0908 1.2547.6039.182.513-.0892 1.0756-.6009 1.2553L43.326 93.9874c-.5117.1797-1.0727-.0908-1.2548-.6039-.0029-.0041-.0032-.0081-.0046-.0122l.0161.0307Z"})]})}function Fv({toolName:t,input:e,result:n}){const r=Mv(t),o=u.useMemo(()=>Pv(n),[n]),a=Lv(e),i=o?.kind==="issues"?o.issues.length:o?.kind==="projects"?o.projects.length:0,[l,c]=u.useState(()=>o?o.kind==="mutation"||i>0&&i<=10:!1);if(!o){let d=n;try{d=JSON.stringify(JSON.parse(n),null,2)}catch{}return s.jsx(De,{isExpanded:l,onExpandedChange:c,cardClassName:ie.indigo.card,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(uc,{size:14,className:ie.indigo.icon}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:r})]}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:a})]}),content:s.jsx("div",{className:`border-t ${k.separator}`,children:s.jsx("pre",{className:M("m-0 px-3 py-3 font-mono text-[13px] leading-relaxed whitespace-pre-wrap break-words max-h-96 overflow-auto",k.codeBg,k.text.primary,k.scrollbar),children:d})})})}return s.jsx(De,{isExpanded:l,onExpandedChange:c,cardClassName:ie.indigo.card,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(uc,{size:14,className:ie.indigo.icon}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:r})]}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:a}),i>0&&s.jsx("span",{className:`text-[13px] ${k.text.faint} flex-shrink-0`,children:i})]}),content:s.jsxs("div",{className:`border-t ${k.separator}`,children:[o.kind==="issues"&&s.jsx("div",{className:`divide-y ${k.separator} max-h-80 overflow-y-auto ${k.scrollbar}`,children:o.issues.map((d,p)=>s.jsx($v,{issue:d},d.identifier||p))}),o.kind==="mutation"&&s.jsx(zv,{success:o.success,issue:o.issue}),o.kind==="projects"&&s.jsx("div",{className:`divide-y ${k.separator} max-h-80 overflow-y-auto ${k.scrollbar}`,children:o.projects.map((d,p)=>s.jsx(dc,{project:d},d.name||p))}),o.kind==="project"&&s.jsx(dc,{project:o.project})]})})}function Vv(t){switch(t){case"completed":case"done":return s.jsx(gr,{size:14,className:"text-emerald-400/80 flex-shrink-0"});case"in_progress":case"current":return s.jsx(vd,{size:14,className:"text-cyan-400/80 flex-shrink-0"});case"paused":return s.jsx(Ug,{size:14,className:"text-amber-400/80 flex-shrink-0"});case"abandoned":return s.jsx(rn,{size:14,className:`${k.text.muted} flex-shrink-0`});default:return s.jsx(br,{size:14,className:"text-zinc-400/80 dark:text-zinc-400/80 flex-shrink-0"})}}function Bv(t){const e="text-[13px] px-1.5 py-0.5 rounded";switch(t){case"completed":case"done":return s.jsx("span",{className:`${e} bg-emerald-500/15 text-emerald-400/80`,children:"done"});case"in_progress":case"current":return s.jsx("span",{className:`${e} bg-cyan-500/15 text-cyan-400/80`,children:"active"});case"paused":return s.jsx("span",{className:`${e} bg-amber-500/15 text-amber-400/80`,children:"paused"});case"abandoned":return s.jsx("span",{className:`${e} bg-zinc-500/15 ${k.text.muted}`,children:"abandoned"});default:return null}}function Uv({input:t,result:e,isUpdate:n}){const r=t.subject||t.activeForm||"",o=t.taskId||t.id||"",a=t.status,i=t.description,l=t.blockedBy&&t.blockedBy.length>0||t.addBlockedBy&&t.addBlockedBy.length>0;let c="";n?c=o?`#${o}${a?` → ${a}`:""}`:"Update task":(c=r?.slice(0,60)||"Create task",r&&r.length>60&&(c+="..."));const d=i||l||e&&e.trim(),[p,m]=u.useState(!1);return s.jsx(De,{isExpanded:p,onExpandedChange:m,cardClassName:ie.cyan.card,canExpand:!!d,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[Vv(a),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:n?"Update":"Task"})]}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:c}),a&&Bv(a)]}),content:d?s.jsxs("div",{className:`border-t ${k.separator} px-3 py-3 space-y-2`,children:[!n&&r&&r.length>60&&s.jsx("div",{className:`text-xs ${k.text.primary}`,children:r}),i&&s.jsx("div",{className:`text-xs ${k.text.secondary}`,children:i}),l&&s.jsxs("div",{className:`text-[13px] ${k.text.muted}`,children:[s.jsx("span",{className:"text-cyan-400/80",children:"Blocked by:"})," ",(t.blockedBy||t.addBlockedBy||[]).join(", ")]}),e&&e.trim()&&s.jsx("pre",{className:M("m-0 font-mono text-[13px] leading-relaxed whitespace-pre-wrap break-words rounded p-2",k.codeBg,k.text.primary),children:e})]}):void 0})}function Gv(t){try{const e=JSON.parse(t);if(Array.isArray(e))return e.filter(n=>n.tool_name).map(n=>{const r=n.tool_name,o=r.match(/^mcp__([^_]+(?:_[^_]+)*)__(.+)$/);return o?{raw:r,server:o[1].replace(/_/g," "),label:o[2].replace(/_/g," ")}:{raw:r,label:r}})}catch{}return[]}function Hv({input:t,result:e}){const n=t?.query||"",r=Gv(e),o=r.length>0,[a,i]=u.useState(()=>o);return s.jsx(De,{isExpanded:a,onExpandedChange:i,cardClassName:ie.violet.card,canExpand:o,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ss,{size:14,className:`${ie.violet.icon} flex-shrink-0`}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:"Tools"})]}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:n}),o&&s.jsxs("span",{className:`text-[13px] ${k.text.faint}`,children:[r.length," found"]})]}),content:o?s.jsx("div",{className:`border-t ${k.separator} px-3 py-2 flex flex-wrap gap-1.5`,children:r.map(l=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded bg-violet-500/10 text-[13px]",children:[l.server&&s.jsxs("span",{className:"text-violet-400/50",children:[l.server,":"]}),s.jsx("span",{className:"text-violet-300/80",children:l.label})]},l.raw))}):void 0})}const qv={blue:"bg-blue-400",green:"bg-green-400",yellow:"bg-amber-400",purple:"bg-purple-400",red:"bg-red-400",cyan:"bg-cyan-400"};function Wv({input:t,result:e,isPending:n,isStreaming:r}){const o=t?.team_name||"unnamed",a=t?.description||"",i=r!==!1&&(n||!e),[l,c]=u.useState(!1);let d=[];if(e)try{const p=Ia(e);p.members&&(d=p.members)}catch{}return s.jsx(De,{isExpanded:l,onExpandedChange:c,cardClassName:ie.amber.card,canExpand:d.length>0,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[i?s.jsx(at,{size:14,className:`${ie.amber.icon} animate-spin flex-shrink-0`}):s.jsx(Jg,{size:14,className:`${ie.amber.icon} flex-shrink-0`}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:i?"Creating team":"Team"})]}),s.jsxs("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:[o,a?` — ${a}`:""]})]}),content:d.length>0?s.jsx("div",{className:`border-t ${k.separator} px-3 py-2 flex flex-wrap gap-1.5`,children:d.map(p=>s.jsxs("span",{className:M("inline-flex items-center gap-1.5 text-[13px] px-2 py-0.5 rounded","bg-stone-100 dark:bg-zinc-800/50"),children:[s.jsx("span",{className:M("w-1.5 h-1.5 rounded-full",qv[p.color||""]||"bg-zinc-500")}),s.jsx("span",{className:k.text.primary,children:p.name}),p.agentType&&p.agentType!=="general-purpose"&&s.jsx("span",{className:k.text.faint,children:p.agentType})]},p.name))}):void 0})}function Kv({input:t,result:e,isPending:n,isStreaming:r}){const o=t?.type||"message",a=t?.recipient||"unknown",i=t?.summary||"",l=t?.content||"",c=r!==!1&&(n||!e),d=fd(a),p=d&&_t[d]||mg;let m,h,g=p;switch(o){case"shutdown_request":m=s.jsx(rn,{size:14,className:"text-red-400/80 flex-shrink-0"}),h="Shutdown request",g=_t.red;break;case"shutdown_response":m=t?.approve?s.jsx(gr,{size:14,className:"text-green-400/80 flex-shrink-0"}):s.jsx(rn,{size:14,className:"text-red-400/80 flex-shrink-0"}),h=t?.approve?"Shutdown approved":"Shutdown rejected",g=t?.approve?_t.green:_t.red;break;case"broadcast":m=s.jsx($o,{size:14,className:M(p.icon,"flex-shrink-0")}),h="Broadcast";break;default:m=c?s.jsx(at,{size:14,className:M(p.icon,"animate-spin flex-shrink-0")}):s.jsx(_d,{size:14,className:M(p.icon,"flex-shrink-0")}),h=c?"Sending":"Message"}const f=l?l.split(`
|
|
69
|
-
`).filter(y=>y.trim()).length:0,[x,b]=u.useState(()=>f>0&&f<=5);return s.jsx(De,{isExpanded:x,onExpandedChange:b,cardClassName:
|
|
66
|
+
`);return s.jsxs("div",{children:[r&&s.jsx("div",{className:R("px-3 pt-2 pb-1 text-[13px]",k.text.secondary),children:r}),s.jsx("pre",{className:R("m-0 px-3 py-2.5 font-mono text-[13px] leading-relaxed whitespace-pre-wrap break-words max-h-72 overflow-auto",k.codeBg,k.text.primary,k.scrollbar),children:i}),a&&s.jsxs("div",{className:R("px-3 py-1 text-[13px] text-center",k.text.faint),children:[o.length-40," more lines..."]})]})}function xv({text:t}){return s.jsx("pre",{className:R("m-0 px-3 py-2.5 font-mono text-[13px] leading-relaxed whitespace-pre-wrap break-words max-h-72 overflow-auto",k.codeBg,k.text.primary,k.scrollbar),children:t})}function bv({text:t}){let e=t;try{e=JSON.stringify(JSON.parse(t),null,2)}catch{}return s.jsx("pre",{className:R("m-0 px-3 py-2.5 font-mono text-[13px] leading-relaxed whitespace-pre-wrap break-words max-h-64 overflow-auto",k.codeBg,k.text.primary,k.scrollbar),children:e})}function yv({toolName:t,input:e,result:n}){const r=ev(t),o=u.useMemo(()=>sv(r,n),[r,n]),a=o.kind==="pages"?o.pages.length:o.kind==="console"?o.messages.length:o.kind==="network"?o.requests.length:0,[i,l]=u.useState(()=>o.kind==="confirmation"||o.kind==="image"||o.kind==="script"||a>0&&a<=8),c=nv(r),d=rv(r,e),p=r.replace(/_/g," "),m=a>0?`${a}`:void 0,h=o.kind==="confirmation"&&!o.text.includes(`
|
|
67
|
+
`);return s.jsx(De,{isExpanded:i,onExpandedChange:l,canExpand:!h,cardClassName:ce.cyan.card,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(c,{size:14,className:`${ce.cyan.icon} flex-shrink-0`}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:p})]}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:d}),m&&s.jsx("span",{className:`text-[13px] ${k.text.faint} flex-shrink-0`,children:m}),h&&s.jsx(xr,{size:12,className:"text-emerald-600 dark:text-emerald-400/80 flex-shrink-0"})]}),content:s.jsxs("div",{className:`border-t ${k.separator}`,children:[o.kind==="confirmation"&&s.jsx(mv,{text:o.text}),o.kind==="script"&&s.jsx(hv,{preamble:o.preamble,code:o.code}),o.kind==="image"&&s.jsx(fv,{dataUrl:o.dataUrl,text:o.text}),o.kind==="pages"&&s.jsx(ov,{pages:o.pages}),o.kind==="console"&&s.jsx(cv,{messages:o.messages,header:o.header}),o.kind==="network"&&s.jsx(pv,{requests:o.requests,header:o.header}),o.kind==="snapshot"&&s.jsx(gv,{text:o.text}),o.kind==="prose"&&s.jsx(xv,{text:o.text}),o.kind==="raw"&&s.jsx(bv,{text:o.text})]})})}function cc({input:t,result:e,isPending:n=!1}){const[r,o]=u.useState(!1),a=t?.description||"background monitor",i=t?.command||"",l=e.match(/\(task\s+(\w+)/),c=l?l[1]:void 0,d=c?`${a} · ${c}`:a;return s.jsx(De,{isExpanded:r,onExpandedChange:o,cardClassName:ce.cyan.card,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(bd,{size:14,className:`${ce.cyan.icon} flex-shrink-0`}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:"Monitor"})]}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:d})]}),content:s.jsxs(s.Fragment,{children:[i&&s.jsx("div",{className:R("border-t px-3 py-2.5",k.separator,k.codeBg),children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-cyan-400/60 font-mono text-[13px] select-none shrink-0 leading-relaxed",children:"$"}),s.jsx("pre",{className:R("m-0 font-mono text-[13px] whitespace-pre-wrap break-all leading-relaxed",k.text.primary),children:i})]})}),e&&!n&&s.jsx("div",{className:R("border-t px-3 py-2 text-[13px]",k.separator,k.codeBgSubtle,k.text.secondary),children:e.split(".")[0]})]})})}function vv(t){if(!Number.isFinite(t)||t<=0)return"";if(t<60)return`${Math.round(t)}s`;const e=Math.floor(t/60),n=Math.round(t%60);if(t<3600)return n?`${e}m ${n}s`:`${e}m`;const r=Math.floor(t/3600),o=Math.round(t%3600/60);return o?`${r}h ${o}m`:`${r}h`}function wv(t){const e=t.match(/\b(\d{1,2}:\d{2}(?::\d{2})?)\b/);return e?e[1]:null}function lc({input:t,result:e,isPending:n=!1}){const[r,o]=u.useState(!1),a=t?.delaySeconds??0,i=(t?.reason??"").trim(),l=(t?.prompt??"").trim(),c=wv(e),d=vv(a),p=[];c&&d?p.push(`${c} (in ${d})`):c?p.push(c):d&&p.push(`in ${d}`),i&&p.push(i);const m=p.join(" — ");return s.jsx(De,{isExpanded:r,onExpandedChange:o,cardClassName:ce.amber.card,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(yg,{size:14,className:`${ce.amber.icon} flex-shrink-0`}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:"Wakeup"})]}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:n?"scheduling…":m||"scheduled"})]}),content:s.jsxs(s.Fragment,{children:[(i||d||c)&&s.jsxs("div",{className:R("border-t px-3 py-2 text-[13px] flex flex-col gap-0.5",k.separator,k.codeBgSubtle),children:[c&&s.jsxs("div",{className:k.text.secondary,children:[s.jsx("span",{className:`mr-2 ${k.text.muted}`,children:"Fires at"}),s.jsx("span",{className:k.text.primary,children:c}),d&&s.jsxs("span",{className:`ml-1 ${k.text.muted}`,children:["(in ",d,")"]})]}),!c&&d&&s.jsxs("div",{className:k.text.secondary,children:[s.jsx("span",{className:`mr-2 ${k.text.muted}`,children:"Delay"}),s.jsx("span",{className:k.text.primary,children:d})]}),i&&s.jsxs("div",{className:k.text.secondary,children:[s.jsx("span",{className:`mr-2 ${k.text.muted}`,children:"Reason"}),s.jsx("span",{className:k.text.primary,children:i})]})]}),l&&s.jsxs("div",{className:R("border-t px-3 py-2.5",k.separator,k.codeBg),children:[s.jsx("div",{className:`uppercase text-[11px] tracking-wider mb-1 ${k.text.faint}`,children:"Prompt"}),s.jsx("pre",{className:R("m-0 font-mono text-[13px] whitespace-pre-wrap break-words leading-relaxed",k.text.primary),children:l})]})]})})}function _v(t){const e=kv(t.trim());if(e.length<2)return[];const n=e[0],r=a=>n.indexOf(a),o=[];for(let a=1;a<e.length;a++){const i=e[a];i.length<4||o.push({userName:i[r("UserName")]||i[r("userName")]||"",realName:i[r("RealName")]||i[r("realName")]||"",channel:i[r("Channel")]||i[r("channel")]||"",text:i[r("Text")]||i[r("text")]||"",time:i[r("Time")]||i[r("time")]||"",threadTs:i[r("ThreadTs")]||i[r("threadTs")]||void 0})}return o}function kv(t){const e=[];let n="",r=!1;const o=[];for(let a=0;a<t.length;a++){const i=t[a];i==='"'?r&&t[a+1]==='"'?(n+='"',a++):r=!r:i===","&&!r?(o.push(n),n=""):i===`
|
|
68
|
+
`&&!r?(o.push(n),n="",o.length>1&&e.push([...o]),o.length=0):n+=i}return o.push(n),o.length>1&&e.push(o),e}function jv(t){try{const e=new Date(t);return e.toLocaleDateString("en-US",{month:"short",day:"numeric"})+" "+e.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"})}catch{return t}}function Nv(t){const e=t.match(/^mcp__slack__(.+)$/);return e?e[1].replace(/_/g," "):"Slack"}function Sv(t,e){const n=t.match(/^mcp__slack__(.+)$/)?.[1]||"";if(n==="conversations_history"){const r=e.channel_id||"";return r.startsWith("#")||r.startsWith("@")?r:`#${r}`}if(n==="conversations_search_messages")return e.search_query||e.filter_in_channel||"messages";if(n==="users_search")return e.query||"";for(const r of Object.values(e))if(typeof r=="string"&&r.length>0)return r.length>60?r.slice(0,57)+"...":r;return""}function Cv({toolName:t,input:e,result:n}){const r=u.useMemo(()=>_v(n),[n]),[o,a]=u.useState(()=>r.length>0&&r.length<=5),i=Nv(t),l=Sv(t,e),c=r.length>0;return s.jsx(De,{isExpanded:o,onExpandedChange:a,cardClassName:ce.indigo.card,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(_d,{size:14,className:`${ce.indigo.icon} flex-shrink-0`}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:i})]}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:l}),c&&s.jsxs("span",{className:`text-[13px] ${k.text.faint} flex-shrink-0`,children:[r.length," message",r.length!==1?"s":""]})]}),content:s.jsx("div",{className:`border-t ${k.separator}`,children:c?s.jsx("div",{className:`divide-y ${k.separator} max-h-80 overflow-y-auto ${k.scrollbar}`,children:r.map((d,p)=>s.jsxs("div",{className:"px-3 py-2 flex gap-2.5",children:[s.jsx("div",{className:"flex-shrink-0 pt-0.5",children:s.jsx("div",{className:R("w-5 h-5 rounded flex items-center justify-center","bg-indigo-500/10 dark:bg-indigo-500/10"),children:s.jsx(Yg,{size:10,className:ce.indigo.icon})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-baseline gap-2",children:[s.jsx("span",{className:R("text-[13px] font-medium",k.text.primary),children:d.realName||d.userName}),d.channel&&s.jsxs("span",{className:R("text-[13px] flex items-center gap-0.5",k.text.faint),children:[s.jsx(Rg,{size:8}),d.channel.replace(/^#/,"")]}),s.jsx("span",{className:R("text-[13px] ml-auto flex-shrink-0",k.text.faint),children:jv(d.time)})]}),s.jsx("p",{className:R("text-[13px] leading-relaxed mt-0.5 whitespace-pre-wrap break-words",k.text.secondary),children:d.text})]})]},p))}):s.jsx("pre",{className:R("m-0 px-3 py-3 font-mono text-[13px] leading-relaxed whitespace-pre-wrap break-words",k.codeBg,k.text.primary),children:n})})})}function Ev(t){try{const e=JSON.parse(t);return e.results&&Array.isArray(e.results)?e:null}catch{return null}}function Tv(t){try{return new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return t}}function Iv(t){const e=t.match(/^mcp__(?:claude_ai_)?[Nn]otion__(.+)$/);return e?e[1].replace(/^notion-/,"").replace(/[-_]/g," "):"Notion"}function Av(t,e){const n=e.query;if(n)return n.length>60?n.slice(0,57)+"...":n;const r=e.id;if(r)return r;for(const o of Object.values(e))if(typeof o=="string"&&o.length>0)return o.length>60?o.slice(0,57)+"...":o;return""}function Rv({toolName:t,input:e,result:n}){const r=u.useMemo(()=>Ev(n),[n]),[o,a]=u.useState(()=>r!==null&&r.results.length>0&&r.results.length<=5),i=Iv(t),l=Av(t,e),c=r!==null&&r.results.length>0;return s.jsx(De,{isExpanded:o,onExpandedChange:a,cardClassName:ce.zinc.card,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(jt,{size:14,className:`${ce.zinc.icon} flex-shrink-0`}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:i})]}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:l}),c&&s.jsxs("span",{className:`text-[13px] ${k.text.faint} flex-shrink-0`,children:[r.results.length," result",r.results.length!==1?"s":""]})]}),content:s.jsx("div",{className:`border-t ${k.separator}`,children:c?s.jsx("div",{className:`divide-y ${k.separator} max-h-80 overflow-y-auto ${k.scrollbar}`,children:r.results.map(d=>s.jsx("div",{className:"px-3 py-2",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:R("text-[13px] font-medium",k.text.primary),children:d.title||"Untitled"}),d.type&&d.type!=="page"&&s.jsx("span",{className:R("text-[9px] px-1 py-0.5 rounded","bg-stone-200/60 dark:bg-zinc-800/50",k.text.faint),children:d.type})]}),d.highlight&&s.jsx("p",{className:R("text-[13px] leading-relaxed mt-0.5",k.text.secondary),children:d.highlight}),d.timestamp&&s.jsx("span",{className:R("text-[9px] mt-0.5 block",k.text.faint),children:Tv(d.timestamp)})]}),d.url&&s.jsx(Os,{size:10,className:R("flex-shrink-0 mt-1",k.text.faint)})]})},d.id))}):s.jsx("pre",{className:R("m-0 px-3 py-3 font-mono text-[13px] leading-relaxed whitespace-pre-wrap break-words",k.codeBg,k.text.primary),children:n})})})}function Pv(t){let e;try{const d=JSON.parse(t);if(Array.isArray(d)){const p=d.find(m=>m.type==="text"&&m.text);if(p?.text)e=JSON.parse(p.text);else return null}else e=d}catch{return null}const n=e.issues;if(n?.nodes&&Array.isArray(n.nodes))return{kind:"issues",issues:n.nodes};const r=e.issueCreate;if(r)return{kind:"mutation",success:!!r.success,issue:r.issue};const o=e.issueUpdate;if(o)return{kind:"mutation",success:!!o.success,issue:o.issue};const a=e.issueDelete;if(a)return{kind:"mutation",success:!!a.success};const i=e.issue;if(i?.identifier)return{kind:"issues",issues:[i]};const l=e.projects;if(l?.nodes&&Array.isArray(l.nodes))return{kind:"projects",projects:l.nodes};const c=e.project;return c?.name?{kind:"project",project:c}:null}function Mv(t){const e=t.match(/^mcp__(?:claude_ai_)?[Ll]inear__(.+)$/);return e?e[1].replace(/_/g," "):t}function Lv(t){const e=["query","title","identifiers","id","issueId"];for(const n of e){const r=t[n];if(typeof r=="string"&&r.length>0)return r.length>80?r.slice(0,77)+"…":r;if(Array.isArray(r))return r.join(", ").slice(0,80)}return""}const Ov={completed:xr,canceled:rn},Dv={completed:"text-emerald-600 dark:text-emerald-400/80",canceled:"text-zinc-400 dark:text-zinc-500",started:"text-amber-600 dark:text-amber-400/80",unstarted:"text-stone-400 dark:text-zinc-500",triage:"text-orange-500 dark:text-orange-400/80",backlog:"text-stone-400 dark:text-zinc-600"};function $v({issue:t}){const e=t.state?.type||"unstarted",n=Ov[e]||br,r=Dv[e]||k.text.faint;return s.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-2 min-w-0",children:[s.jsx(n,{size:12,className:R("flex-shrink-0",r)}),s.jsx("span",{className:R("text-[13px] font-mono flex-shrink-0",k.text.faint),children:t.identifier}),s.jsx("span",{className:R("text-[13px] truncate flex-1 min-w-0",k.text.primary),children:t.title}),t.assignee&&s.jsx("span",{className:R("text-[11px] flex-shrink-0",k.text.faint),children:t.assignee.name}),t.labels?.nodes&&t.labels.nodes.length>0&&s.jsx("div",{className:"flex gap-1 flex-shrink-0",children:t.labels.nodes.slice(0,2).map(o=>s.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded",style:o.color?{backgroundColor:`${o.color}20`,color:o.color}:void 0,children:o.name},o.name))}),t.url&&s.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:R("flex-shrink-0",k.text.faint,"hover:text-indigo-500"),children:s.jsx(Os,{size:10})})]})}function zv({success:t,issue:e}){return s.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",children:[t?s.jsx(xr,{size:12,className:"text-emerald-600 dark:text-emerald-400/80 flex-shrink-0"}):s.jsx(rn,{size:12,className:"text-red-600 dark:text-red-400/80 flex-shrink-0"}),e?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:R("text-[13px] font-mono",k.text.faint),children:e.identifier}),s.jsx("span",{className:R("text-[13px] truncate flex-1",k.text.primary),children:e.title}),e.url&&s.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:R("flex-shrink-0",k.text.faint,"hover:text-indigo-500"),children:s.jsx(Os,{size:10})})]}):s.jsx("span",{className:R("text-[13px]",k.text.secondary),children:t?"Success":"Failed"})]})}function dc({project:t}){return s.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-2 min-w-0",children:[s.jsx(br,{size:10,className:R("flex-shrink-0",k.text.faint)}),s.jsx("span",{className:R("text-[13px] truncate flex-1 min-w-0",k.text.primary),children:t.name}),t.state&&s.jsx("span",{className:R("text-[9px] px-1 py-0.5 rounded","bg-stone-200/60 dark:bg-zinc-800/50",k.text.faint),children:t.state}),t.url&&s.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:R("flex-shrink-0",k.text.faint,"hover:text-indigo-500"),children:s.jsx(Os,{size:10})})]})}function uc({size:t=14,className:e}){return s.jsxs("svg",{width:t,height:t,viewBox:"0 0 100 100",fill:"currentColor",className:e,children:[s.jsx("path",{d:"M1.22541 61.5228c-.97401-1.6679-.9621-3.7358.02515-5.393L42.2113 1.7038c1.0762-1.81266 3.3714-2.41393 5.1357-1.34447 1.7643 1.06946 2.3512 3.34827 1.2749 5.16094L7.66132 59.946c-.98736 1.6629-3.29117 2.2133-4.96353 1.2006-.59502-.3603-1.06135-.8799-1.37738-1.4706-.0527-.0985-.10188-.1997-.1474-.3034-.0159-.0363-.03138-.0728-.04644-.1096Z"}),s.jsx("path",{d:"M12.1816 77.934c-.7543-1.2904-.5323-2.9344.5671-3.9832l45.1186-43.0733c1.1466-1.0946 2.9483-1.0419 4.0275.1176 1.0793 1.1596 1.028 2.9791-.1186 4.0738L16.6576 78.1423c-1.1466 1.0946-2.9483 1.0419-4.0276-.1176-.1622-.1741-.2995-.3651-.4109-.5672-.0171-.031-.0337-.0623-.0497-.0939Z"}),s.jsx("path",{d:"M22.9861 85.7189c-.5308-.9079-.2765-2.0785.576-2.6838l38.3729-27.2402c.8897-.6314 2.1128-.4117 2.734.491.6213.9028.4032 2.1398-.4866 2.7712L25.8095 86.2973c-.89.6314-2.1129.4117-2.734-.491-.0358-.052-.069-.1057-.0994-.161Z"}),s.jsx("path",{d:"M32.4431 90.7801c-.3628-.6207-.0959-1.409.5883-1.7282l30.3399-14.1616c.7125-.3327 1.561-.0273 1.8977.6831.3367.7104.0327 1.5613-.6798 1.894l-30.34 14.1616c-.7124.3326-1.5609.0273-1.8976-.6831-.0326-.0687-.0599-.1396-.0818-.2132-.0057-.019-.011-.0381-.0158-.0574Z"}),s.jsx("path",{d:"M42.0827 93.402c-.1652-.5006.0993-1.0424.5898-1.2147l23.4313-8.2326c.5116-.1797 1.0727.0908 1.2547.6039.182.513-.0892 1.0756-.6009 1.2553L43.326 93.9874c-.5117.1797-1.0727-.0908-1.2548-.6039-.0029-.0041-.0032-.0081-.0046-.0122l.0161.0307Z"})]})}function Fv({toolName:t,input:e,result:n}){const r=Mv(t),o=u.useMemo(()=>Pv(n),[n]),a=Lv(e),i=o?.kind==="issues"?o.issues.length:o?.kind==="projects"?o.projects.length:0,[l,c]=u.useState(()=>o?o.kind==="mutation"||i>0&&i<=10:!1);if(!o){let d=n;try{d=JSON.stringify(JSON.parse(n),null,2)}catch{}return s.jsx(De,{isExpanded:l,onExpandedChange:c,cardClassName:ce.indigo.card,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(uc,{size:14,className:ce.indigo.icon}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:r})]}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:a})]}),content:s.jsx("div",{className:`border-t ${k.separator}`,children:s.jsx("pre",{className:R("m-0 px-3 py-3 font-mono text-[13px] leading-relaxed whitespace-pre-wrap break-words max-h-96 overflow-auto",k.codeBg,k.text.primary,k.scrollbar),children:d})})})}return s.jsx(De,{isExpanded:l,onExpandedChange:c,cardClassName:ce.indigo.card,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(uc,{size:14,className:ce.indigo.icon}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:r})]}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:a}),i>0&&s.jsx("span",{className:`text-[13px] ${k.text.faint} flex-shrink-0`,children:i})]}),content:s.jsxs("div",{className:`border-t ${k.separator}`,children:[o.kind==="issues"&&s.jsx("div",{className:`divide-y ${k.separator} max-h-80 overflow-y-auto ${k.scrollbar}`,children:o.issues.map((d,p)=>s.jsx($v,{issue:d},d.identifier||p))}),o.kind==="mutation"&&s.jsx(zv,{success:o.success,issue:o.issue}),o.kind==="projects"&&s.jsx("div",{className:`divide-y ${k.separator} max-h-80 overflow-y-auto ${k.scrollbar}`,children:o.projects.map((d,p)=>s.jsx(dc,{project:d},d.name||p))}),o.kind==="project"&&s.jsx(dc,{project:o.project})]})})}function Vv(t){switch(t){case"completed":case"done":return s.jsx(gr,{size:14,className:"text-emerald-400/80 flex-shrink-0"});case"in_progress":case"current":return s.jsx(vd,{size:14,className:"text-cyan-400/80 flex-shrink-0"});case"paused":return s.jsx(Ug,{size:14,className:"text-amber-400/80 flex-shrink-0"});case"abandoned":return s.jsx(rn,{size:14,className:`${k.text.muted} flex-shrink-0`});default:return s.jsx(br,{size:14,className:"text-zinc-400/80 dark:text-zinc-400/80 flex-shrink-0"})}}function Bv(t){const e="text-[13px] px-1.5 py-0.5 rounded";switch(t){case"completed":case"done":return s.jsx("span",{className:`${e} bg-emerald-500/15 text-emerald-400/80`,children:"done"});case"in_progress":case"current":return s.jsx("span",{className:`${e} bg-cyan-500/15 text-cyan-400/80`,children:"active"});case"paused":return s.jsx("span",{className:`${e} bg-amber-500/15 text-amber-400/80`,children:"paused"});case"abandoned":return s.jsx("span",{className:`${e} bg-zinc-500/15 ${k.text.muted}`,children:"abandoned"});default:return null}}function Uv({input:t,result:e,isUpdate:n}){const r=t.subject||t.activeForm||"",o=t.taskId||t.id||"",a=t.status,i=t.description,l=t.blockedBy&&t.blockedBy.length>0||t.addBlockedBy&&t.addBlockedBy.length>0;let c="";n?c=o?`#${o}${a?` → ${a}`:""}`:"Update task":(c=r?.slice(0,60)||"Create task",r&&r.length>60&&(c+="..."));const d=i||l||e&&e.trim(),[p,m]=u.useState(!1);return s.jsx(De,{isExpanded:p,onExpandedChange:m,cardClassName:ce.cyan.card,canExpand:!!d,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[Vv(a),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:n?"Update":"Task"})]}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:c}),a&&Bv(a)]}),content:d?s.jsxs("div",{className:`border-t ${k.separator} px-3 py-3 space-y-2`,children:[!n&&r&&r.length>60&&s.jsx("div",{className:`text-xs ${k.text.primary}`,children:r}),i&&s.jsx("div",{className:`text-xs ${k.text.secondary}`,children:i}),l&&s.jsxs("div",{className:`text-[13px] ${k.text.muted}`,children:[s.jsx("span",{className:"text-cyan-400/80",children:"Blocked by:"})," ",(t.blockedBy||t.addBlockedBy||[]).join(", ")]}),e&&e.trim()&&s.jsx("pre",{className:R("m-0 font-mono text-[13px] leading-relaxed whitespace-pre-wrap break-words rounded p-2",k.codeBg,k.text.primary),children:e})]}):void 0})}function Gv(t){try{const e=JSON.parse(t);if(Array.isArray(e))return e.filter(n=>n.tool_name).map(n=>{const r=n.tool_name,o=r.match(/^mcp__([^_]+(?:_[^_]+)*)__(.+)$/);return o?{raw:r,server:o[1].replace(/_/g," "),label:o[2].replace(/_/g," ")}:{raw:r,label:r}})}catch{}return[]}function Hv({input:t,result:e}){const n=t?.query||"",r=Gv(e),o=r.length>0,[a,i]=u.useState(()=>o);return s.jsx(De,{isExpanded:a,onExpandedChange:i,cardClassName:ce.violet.card,canExpand:o,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ss,{size:14,className:`${ce.violet.icon} flex-shrink-0`}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:"Tools"})]}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:n}),o&&s.jsxs("span",{className:`text-[13px] ${k.text.faint}`,children:[r.length," found"]})]}),content:o?s.jsx("div",{className:`border-t ${k.separator} px-3 py-2 flex flex-wrap gap-1.5`,children:r.map(l=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded bg-violet-500/10 text-[13px]",children:[l.server&&s.jsxs("span",{className:"text-violet-400/50",children:[l.server,":"]}),s.jsx("span",{className:"text-violet-300/80",children:l.label})]},l.raw))}):void 0})}const qv={blue:"bg-blue-400",green:"bg-green-400",yellow:"bg-amber-400",purple:"bg-purple-400",red:"bg-red-400",cyan:"bg-cyan-400"};function Wv({input:t,result:e,isPending:n,isStreaming:r}){const o=t?.team_name||"unnamed",a=t?.description||"",i=r!==!1&&(n||!e),[l,c]=u.useState(!1);let d=[];if(e)try{const p=Ia(e);p.members&&(d=p.members)}catch{}return s.jsx(De,{isExpanded:l,onExpandedChange:c,cardClassName:ce.amber.card,canExpand:d.length>0,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[i?s.jsx(at,{size:14,className:`${ce.amber.icon} animate-spin flex-shrink-0`}):s.jsx(Jg,{size:14,className:`${ce.amber.icon} flex-shrink-0`}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:i?"Creating team":"Team"})]}),s.jsxs("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:[o,a?` — ${a}`:""]})]}),content:d.length>0?s.jsx("div",{className:`border-t ${k.separator} px-3 py-2 flex flex-wrap gap-1.5`,children:d.map(p=>s.jsxs("span",{className:R("inline-flex items-center gap-1.5 text-[13px] px-2 py-0.5 rounded","bg-stone-100 dark:bg-zinc-800/50"),children:[s.jsx("span",{className:R("w-1.5 h-1.5 rounded-full",qv[p.color||""]||"bg-zinc-500")}),s.jsx("span",{className:k.text.primary,children:p.name}),p.agentType&&p.agentType!=="general-purpose"&&s.jsx("span",{className:k.text.faint,children:p.agentType})]},p.name))}):void 0})}function Kv({input:t,result:e,isPending:n,isStreaming:r}){const o=t?.type||"message",a=t?.recipient||"unknown",i=t?.summary||"",l=t?.content||"",c=r!==!1&&(n||!e),d=fd(a),p=d&&_t[d]||mg;let m,h,g=p;switch(o){case"shutdown_request":m=s.jsx(rn,{size:14,className:"text-red-400/80 flex-shrink-0"}),h="Shutdown request",g=_t.red;break;case"shutdown_response":m=t?.approve?s.jsx(gr,{size:14,className:"text-green-400/80 flex-shrink-0"}):s.jsx(rn,{size:14,className:"text-red-400/80 flex-shrink-0"}),h=t?.approve?"Shutdown approved":"Shutdown rejected",g=t?.approve?_t.green:_t.red;break;case"broadcast":m=s.jsx($o,{size:14,className:R(p.icon,"flex-shrink-0")}),h="Broadcast";break;default:m=c?s.jsx(at,{size:14,className:R(p.icon,"animate-spin flex-shrink-0")}):s.jsx(_d,{size:14,className:R(p.icon,"flex-shrink-0")}),h=c?"Sending":"Message"}const f=l?l.split(`
|
|
69
|
+
`).filter(y=>y.trim()).length:0,[x,b]=u.useState(()=>f>0&&f<=5);return s.jsx(De,{isExpanded:x,onExpandedChange:b,cardClassName:R(g.border,g.bg),canExpand:!!l,headerContent:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[m,s.jsx("span",{className:`text-xs ${k.text.muted}`,children:h})]}),s.jsxs("span",{className:`text-xs ${k.text.secondary}`,children:["→ ",a]}),i&&s.jsx("span",{className:`text-xs ${k.text.muted} truncate flex-1`,children:i})]}),content:l?s.jsx("div",{className:`border-t ${k.separator}`,children:s.jsx("pre",{className:R("m-0 px-3 py-2.5 font-mono text-[13px] leading-relaxed whitespace-pre-wrap break-words",k.codeBg,k.text.primary),children:l.length>500?l.slice(0,500)+"...":l})}):void 0})}function Qv({result:t,isPending:e,isStreaming:n}){const r=n!==!1&&(e||!t);return s.jsx(De,{isExpanded:!1,onExpandedChange:()=>{},cardClassName:ce.zinc.card,canExpand:!1,headerContent:s.jsxs("div",{className:"flex items-center gap-2",children:[r?s.jsx(at,{size:14,className:"text-zinc-400/80 animate-spin flex-shrink-0"}):s.jsx(gr,{size:14,className:"text-zinc-400/80 flex-shrink-0"}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:r?"Disbanding team":"Team disbanded"})]})})}function Yv({code:t}){const n=hr()==="dark"?"github-dark-default":"github-light-default",[r,o]=u.useState(null);return u.useEffect(()=>{Va(t,{lang:"shellscript",theme:n}).then(o).catch(()=>o(null))},[t,n]),r?s.jsx("div",{className:"[&_pre]:!bg-transparent [&_pre]:px-3 [&_pre]:py-2.5 [&_pre]:m-0 [&_pre]:text-[13px] [&_pre]:leading-relaxed [&_pre]:whitespace-pre-wrap [&_pre]:break-words [&_code]:!bg-transparent",dangerouslySetInnerHTML:{__html:r}}):s.jsx("pre",{className:R("m-0 px-3 py-2.5 font-mono text-[13px] whitespace-pre-wrap break-words leading-relaxed",k.text.primary),children:t})}function Jv(t,e,n){switch(t){case"Bash":return typeof e.command=="string"?e.command.slice(0,60):void 0;case"WebFetch":return typeof e.url=="string"?e.url:void 0;case"WebSearch":return typeof e.query=="string"?e.query:void 0;case"Read":case"Edit":case"Write":case"MultiEdit":{const r=typeof e.file_path=="string"?e.file_path:"";return n&&r.startsWith(n)?r.slice(n.length+1):r||void 0}default:return}}function Xv({message:t,toolName:e,context:n,isExpanded:r,onExpandedChange:o}){const a=t.split(`
|
|
70
70
|
`)[0],i=t.includes(`
|
|
71
|
-
`)&&t.trim()!==a.trim(),l=a.slice(0,80)+(a.length>80?"...":""),c=s.jsxs(s.Fragment,{children:[s.jsx(zo,{size:14,className:"text-red-700 dark:text-red-400/80 flex-shrink-0"}),n&&s.jsx("span",{className:"text-xs text-red-800/70 dark:text-red-300/60 truncate flex-shrink min-w-0",children:n}),n&&s.jsx("span",{className:"text-xs text-red-800/40 dark:text-red-400/40",children:"|"}),s.jsx("span",{className:"text-xs text-red-800/80 dark:text-red-300/70 truncate flex-1",children:l})]});return i?s.jsx("div",{className:"w-fit max-w-full",children:s.jsx(Ba,{open:r,onOpenChange:o,children:s.jsxs("div",{className:"border border-red-600/30 rounded-lg overflow-hidden bg-red-500/15 dark:bg-red-500/5",children:[s.jsx(Ua,{className:"w-full text-left cursor-pointer select-none",children:s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 hover:bg-red-500/20 dark:hover:bg-red-500/10 transition-colors",children:[c,s.jsx(nn,{size:12,className:`text-red-700/60 dark:text-red-400/60 transition-transform duration-150 flex-shrink-0 ${r?"":"-rotate-90"}`})]})}),s.jsx(Ga,{children:s.jsx("div",{className:
|
|
72
|
-
`):"":"",N=n?.is_error===!0,S=(!n||n.status==="pending")&&d!==!1;if(m?.[t]){const T=m[t]({toolName:t,input:e,result:w,isError:N,isPending:S,toolUseId:o,workingDirectory:r,isStreaming:d});if(T!==void 0)return T}if(S){if(t==="Task"||t==="Agent")return s.jsx(nc,{input:e,result:w,toolUseId:o,childrenMessages:a,toolResults:i,isPending:!0,isStreaming:d,renderChildMessage:p});if(t==="TaskOutput")return s.jsx(rc,{input:e,result:w,isPending:!0});if(t==="AskUserQuestion"&&!l)return null;if(t==="Bash")return s.jsx(tc,{input:e,result:w,workingDirectory:r,isPending:!0,fetchBackgroundOutput:x});if(t==="Monitor")return s.jsx(cc,{input:e,result:w,isPending:!0});if(t==="ScheduleWakeup")return s.jsx(lc,{input:e,result:w,isPending:!0});const C=(()=>{switch(t){case"Read":return{icon:jt,label:"Reading",detail:Ns(String(e?.file_path??""),r),iconClass:ie.blue.icon};case"Edit":case"MultiEdit":return{icon:Wg,label:"Editing",detail:Ns(String(e?.file_path??""),r),iconClass:ie.emerald.icon};case"Write":return{icon:Eg,label:"Writing",detail:Ns(String(e?.file_path??""),r),iconClass:ie.violet.icon};case"Bash":return{icon:Yn,label:"Running",detail:typeof e?.command=="string"?e.command.slice(0,60):"",iconClass:ie.orange.icon};case"Grep":return{icon:ss,label:"Searching",detail:String(e?.pattern??""),iconClass:ie.amber.icon};case"Glob":return{icon:ss,label:"Finding",detail:String(e?.pattern??""),iconClass:ie.violet.icon};case"LS":return{icon:wd,label:"Listing",detail:String(e?.path??"."),iconClass:ie.violet.icon};case"ToolSearch":return{icon:ss,label:"Loading tools",detail:String(e?.query??""),iconClass:ie.violet.icon};case"WebSearch":return{icon:is,label:"Searching",detail:String(e?.query??""),iconClass:ie.emerald.icon};case"WebFetch":return{icon:Os,label:"Fetching",detail:e?.url?(()=>{try{return new URL(e.url).hostname}catch{return""}})():"",iconClass:ie.emerald.icon};default:{if(t.startsWith("mcp__")){const E=t.match(/^mcp__[^_]+__(.+)$/),R=E?E[1].replace(/_/g," "):t,O=t.includes("chrome_devtools__")||t.includes("chrome-devtools__"),$=e?.selector||e?.url||e?.uid||e?.text||e?.path||e?.query||e?.pattern||"";return{icon:O?is:jt,label:R,detail:$,iconClass:O?ie.cyan.icon:ie.purple.icon}}return{icon:jt,label:t,detail:"",iconClass:k.text.muted}}}})(),j=C.icon;return s.jsx("div",{className:"w-fit max-w-full",children:s.jsx("div",{className:M("border rounded-lg overflow-hidden",k.card.border,k.card.bg),children:s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[s.jsx(at,{size:12,className:`${k.text.muted} flex-shrink-0 animate-spin`}),s.jsx(j,{size:14,className:`${C.iconClass} flex-shrink-0`}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:C.label}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:C.detail})]})})})}if(N&&(t==="AskUserQuestion"||t==="EnterPlanMode"||w?.toLowerCase().includes("answer questions?")))return null;if(N&&(t==="ExitPlanMode"||t==="exit_plan_mode"||w?.toLowerCase().includes("exit plan mode")))return s.jsx(oc,{input:e,result:w,isPendingApproval:!0,priorOutcome:o&&f?.[o]||!1,onApprove:h,onReject:g});if(N)return s.jsx(Xv,{message:w||"Tool execution failed",toolName:t,context:Jv(t,e,r),isExpanded:b,onExpandedChange:y});switch(t){case"Read":return s.jsx(ry,{input:e,result:w,workingDirectory:r});case"Edit":case"MultiEdit":return s.jsx(iy,{input:e,result:w,isMultiEdit:t==="MultiEdit",workingDirectory:r});case"Write":return s.jsx(ly,{input:e,result:w,workingDirectory:r});case"Bash":return s.jsx(tc,{input:e,result:w,fetchBackgroundOutput:x});case"Monitor":return s.jsx(cc,{input:e,result:w});case"ScheduleWakeup":return s.jsx(lc,{input:e,result:w});case"Grep":case"Glob":case"LS":return s.jsx(Ey,{input:e,result:w,toolType:t});case"TodoRead":case"TodoWrite":return s.jsx(Iy,{input:e,result:w,isWrite:t==="TodoWrite"});case"WebSearch":case"WebFetch":return s.jsx(Dy,{input:e,result:w,toolType:t});case"ToolSearch":return s.jsx(Hv,{input:e,result:w});case"Task":case"Agent":return s.jsx(nc,{input:e,result:w,toolUseId:o,childrenMessages:a,toolResults:i,isStreaming:d,renderChildMessage:p});case"TaskOutput":return s.jsx(rc,{input:e,result:w});case"TaskCreate":case"TaskUpdate":return s.jsx(Uv,{input:e,result:w,isUpdate:t==="TaskUpdate"});case"EnterPlanMode":return null;case"exit_plan_mode":case"ExitPlanMode":return s.jsx(oc,{input:e,result:w,onApprove:h,onReject:g});case"AskUserQuestion":return s.jsx(tu,{input:e,result:w,questionId:l,onAnswer:c,isPending:S});case"TeamCreate":return s.jsx(Wv,{input:e,result:w,isPending:S,isStreaming:d});case"SendMessage":return s.jsx(Kv,{input:e,result:w,isPending:S,isStreaming:d});case"TeamDelete":return s.jsx(Qv,{result:w,isPending:S,isStreaming:d});default:return t.startsWith("mcp__")?t.includes("slack__")?s.jsx(Cv,{toolName:t,input:e,result:w}):t.includes("otion__")||t.includes("notion__")?s.jsx(Rv,{toolName:t,input:e,result:w}):t.includes("chrome_devtools__")||t.includes("chrome-devtools__")?s.jsx(yv,{toolName:t,input:e,result:w}):t.includes("linear__")?s.jsx(Fv,{toolName:t,input:e,result:w}):s.jsx(Yy,{toolName:t,input:e,result:w}):s.jsx(Gy,{toolName:t,input:e,result:w})}}const e1={},t1={};function s1({toolUse:t,toolResult:e,toolResults:n=e1,workingDirectory:r,childrenMessages:o=t1,questionId:a,onAnswerQuestion:i,isStreaming:l,renderChildMessage:c,customRenderers:d,onPlanApprove:p,onPlanReject:m,planOutcomes:h,fetchBackgroundOutput:g}){return t.name==="ToolSearch"&&typeof t.input.query=="string"&&t.input.query.startsWith("select:")?null:s.jsx(Ha,{name:`Tool:${t.name}`,children:s.jsx("div",{"data-testid":`tool-${t.name}`,children:s.jsx(Zv,{toolName:t.name,toolInput:t.input,toolResult:e,workingDirectory:r,toolUseId:t.id,childrenMessages:o,toolResults:n,questionId:a,onAnswerQuestion:i,isStreaming:l,renderChildMessage:c,customRenderers:d,onPlanApprove:p,onPlanReject:m,planOutcomes:h,fetchBackgroundOutput:g})})})}const pc={read:{icon:jt,label:"Read",color:"text-blue-400/80"},grep:{icon:ss,label:"Grep",color:"text-amber-400/80"},glob:{icon:Li,label:"Glob",color:"text-violet-400/80"},ls:{icon:Li,label:"LS",color:"text-violet-400/80"},"web-search":{icon:is,label:"Search",color:"text-emerald-400/80"},"web-fetch":{icon:is,label:"Fetch",color:"text-emerald-400/80"},"tool-search":{icon:ss,label:"Tools",color:"text-emerald-400/80"}};function n1(t){return t.replace(/^\d+\t/gm,"")}function r1({code:t,language:e}){const r=hr()==="dark"?"github-dark-default":"github-light-default",[o,a]=u.useState(null);return u.useEffect(()=>{Va(t,{lang:e,theme:r}).then(a).catch(()=>a(null))},[t,e,r]),o?s.jsx("div",{className:"[&_pre]:!bg-transparent [&_pre]:px-3 [&_pre]:py-2.5 [&_pre]:text-[13px] [&_pre]:leading-relaxed [&_pre]:whitespace-pre-wrap [&_pre]:break-words [&_code]:!bg-transparent",dangerouslySetInnerHTML:{__html:o}}):s.jsx("pre",{className:M("px-3 py-2.5 text-[13px] whitespace-pre-wrap break-words leading-relaxed",k.text.secondary),children:t})}function o1({hint:t}){const[e,n]=u.useState(t),[r,o]=u.useState(!1);return u.useEffect(()=>{if(t!==e){o(!0);const a=setTimeout(()=>{n(t),o(!1)},150);return()=>clearTimeout(a)}},[t,e]),s.jsx("span",{className:M("inline-flex items-center overflow-hidden h-4 ml-2 pl-2 border-l","border-stone-200 dark:border-zinc-700/50"),children:s.jsx("span",{className:"relative overflow-hidden h-4 inline-flex items-center",children:s.jsx("span",{className:M("text-[11px] transition-all duration-150 ease-out",k.text.faint,r?"-translate-y-full opacity-0":"translate-y-0 opacity-100"),children:e})})})}function Qo({group:t,temporalState:e}){const[n,r]=u.useState(!1),[o,a]=u.useState(new Set),i=l=>{a(c=>{const d=new Set(c);return d.has(l)?d.delete(l):d.add(l),d})};return s.jsxs("div",{className:M("w-fit max-w-full rounded-lg border transition-all duration-200","border-stone-300/40 bg-stone-500/5 dark:border-zinc-500/25 dark:bg-zinc-500/5"),children:[s.jsxs("button",{onClick:()=>r(!n),className:"w-full flex items-center gap-2 px-3 py-2 text-left cursor-pointer group",children:[s.jsx("div",{className:"flex-shrink-0",children:e==="active"?s.jsx(at,{className:M("w-3.5 h-3.5 animate-spin",k.text.secondary)}):s.jsx(Pg,{className:M("w-3.5 h-3.5",k.text.secondary)})}),s.jsxs("span",{className:M("flex-1 min-w-0 text-xs truncate",k.text.secondary),children:[t.summary,e==="active"&&t.latestHint&&s.jsx(o1,{hint:t.latestHint})]}),s.jsx(nn,{className:M("w-3 h-3 transition-all duration-200 flex-shrink-0",k.text.muted,`group-hover:${k.text.secondary}`,n&&"rotate-180")})]}),n&&s.jsx("div",{className:"px-3 pb-3",children:s.jsx("div",{className:M("border-t pt-2 space-y-1",k.separator),children:t.toolCalls.map((l,c)=>{const d=pc[l.tool]??pc.read,p=d.icon,m=o.has(c),h=l.resultContent?gd(l.resultContent):l.resultContent,g=h&&l.status==="success",f=l.tool==="read"&&fr(l.filePath??l.input)||"text";return s.jsxs("div",{children:[s.jsxs("button",{onClick:x=>{x.stopPropagation(),g&&i(c)},className:M("w-full flex items-center gap-2 px-2 py-1.5 rounded text-left transition-colors",g&&`cursor-pointer ${k.hover}`,!g&&"cursor-default"),children:[s.jsx(p,{className:M("w-3.5 h-3.5 flex-shrink-0",d.color)}),s.jsx("span",{className:M("flex-1 text-xs truncate",k.text.secondary),children:l.input}),g&&s.jsx(nn,{className:M("w-3 h-3 transition-transform duration-150 flex-shrink-0",k.text.faint,m&&"rotate-180")}),l.status==="pending"&&s.jsx(at,{className:M("w-3 h-3 animate-spin flex-shrink-0",k.text.faint)})]}),m&&g&&s.jsx("div",{className:"mt-1.5 mb-2",children:s.jsxs("div",{className:M("relative rounded-md border overflow-hidden max-h-60 overflow-y-auto",k.codeBg,"border-stone-200 dark:border-zinc-800/60",k.scrollbar),children:[s.jsx("div",{className:"absolute inset-y-0 left-0 w-0.5 bg-gradient-to-b from-stone-300 via-stone-400 to-stone-300 dark:from-zinc-700 dark:via-zinc-600 dark:to-zinc-700"}),l.tool==="read"?s.jsx(r1,{code:n1(h),language:f}):l.tool==="web-search"?s.jsx(eu,{result:h,compact:!0}):s.jsx(Ly,{content:h,compact:!0})]})})]},c)})})})]})}function Ct(){}Ct.prototype={diff:function(e,n){var r,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=o.callback;typeof o=="function"&&(a=o,o={});var i=this;function l(N){return N=i.postProcess(N,o),a?(setTimeout(function(){a(N)},0),!0):N}e=this.castInput(e,o),n=this.castInput(n,o),e=this.removeEmpty(this.tokenize(e,o)),n=this.removeEmpty(this.tokenize(n,o));var c=n.length,d=e.length,p=1,m=c+d;o.maxEditLength!=null&&(m=Math.min(m,o.maxEditLength));var h=(r=o.timeout)!==null&&r!==void 0?r:1/0,g=Date.now()+h,f=[{oldPos:-1,lastComponent:void 0}],x=this.extractCommon(f[0],n,e,0,o);if(f[0].oldPos+1>=d&&x+1>=c)return l(mc(i,f[0].lastComponent,n,e,i.useLongestToken));var b=-1/0,y=1/0;function v(){for(var N=Math.max(b,-p);N<=Math.min(y,p);N+=2){var S=void 0,T=f[N-1],C=f[N+1];T&&(f[N-1]=void 0);var j=!1;if(C){var E=C.oldPos-N;j=C&&0<=E&&E<c}var R=T&&T.oldPos+1<d;if(!j&&!R){f[N]=void 0;continue}if(!R||j&&T.oldPos<C.oldPos?S=i.addToPath(C,!0,!1,0,o):S=i.addToPath(T,!1,!0,1,o),x=i.extractCommon(S,n,e,N,o),S.oldPos+1>=d&&x+1>=c)return l(mc(i,S.lastComponent,n,e,i.useLongestToken));f[N]=S,S.oldPos+1>=d&&(y=Math.min(y,N-1)),x+1>=c&&(b=Math.max(b,N+1))}p++}if(a)(function N(){setTimeout(function(){if(p>m||Date.now()>g)return a();v()||N()},0)})();else for(;p<=m&&Date.now()<=g;){var w=v();if(w)return w}},addToPath:function(e,n,r,o,a){var i=e.lastComponent;return i&&!a.oneChangePerToken&&i.added===n&&i.removed===r?{oldPos:e.oldPos+o,lastComponent:{count:i.count+1,added:n,removed:r,previousComponent:i.previousComponent}}:{oldPos:e.oldPos+o,lastComponent:{count:1,added:n,removed:r,previousComponent:i}}},extractCommon:function(e,n,r,o,a){for(var i=n.length,l=r.length,c=e.oldPos,d=c-o,p=0;d+1<i&&c+1<l&&this.equals(r[c+1],n[d+1],a);)d++,c++,p++,a.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return p&&!a.oneChangePerToken&&(e.lastComponent={count:p,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=c,d},equals:function(e,n,r){return r.comparator?r.comparator(e,n):e===n||r.ignoreCase&&e.toLowerCase()===n.toLowerCase()},removeEmpty:function(e){for(var n=[],r=0;r<e.length;r++)e[r]&&n.push(e[r]);return n},castInput:function(e){return e},tokenize:function(e){return Array.from(e)},join:function(e){return e.join("")},postProcess:function(e){return e}};function mc(t,e,n,r,o){for(var a=[],i;e;)a.push(e),i=e.previousComponent,delete e.previousComponent,e=i;a.reverse();for(var l=0,c=a.length,d=0,p=0;l<c;l++){var m=a[l];if(m.removed)m.value=t.join(r.slice(p,p+m.count)),p+=m.count;else{if(!m.added&&o){var h=n.slice(d,d+m.count);h=h.map(function(g,f){var x=r[p+f];return x.length>g.length?x:g}),m.value=t.join(h)}else m.value=t.join(n.slice(d,d+m.count));d+=m.count,m.added||(p+=m.count)}}return a}function hc(t,e){var n;for(n=0;n<t.length&&n<e.length;n++)if(t[n]!=e[n])return t.slice(0,n);return t.slice(0,n)}function fc(t,e){var n;if(!t||!e||t[t.length-1]!=e[e.length-1])return"";for(n=0;n<t.length&&n<e.length;n++)if(t[t.length-(n+1)]!=e[e.length-(n+1)])return t.slice(-n);return t.slice(-n)}function Yo(t,e,n){if(t.slice(0,e.length)!=e)throw Error("string ".concat(JSON.stringify(t)," doesn't start with prefix ").concat(JSON.stringify(e),"; this is a bug"));return n+t.slice(e.length)}function Jo(t,e,n){if(!e)return t+n;if(t.slice(-e.length)!=e)throw Error("string ".concat(JSON.stringify(t)," doesn't end with suffix ").concat(JSON.stringify(e),"; this is a bug"));return t.slice(0,-e.length)+n}function Hs(t,e){return Yo(t,e,"")}function Tn(t,e){return Jo(t,e,"")}function gc(t,e){return e.slice(0,a1(t,e))}function a1(t,e){var n=0;t.length>e.length&&(n=t.length-e.length);var r=e.length;t.length<e.length&&(r=t.length);var o=Array(r),a=0;o[0]=0;for(var i=1;i<r;i++){for(e[i]==e[a]?o[i]=o[a]:o[i]=a;a>0&&e[i]!=e[a];)a=o[a];e[i]==e[a]&&a++}a=0;for(var l=n;l<t.length;l++){for(;a>0&&t[l]!=e[a];)a=o[a];t[l]==e[a]&&a++}return a}var ir="a-zA-Z0-9_\\u{C0}-\\u{FF}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}",i1=new RegExp("[".concat(ir,"]+|\\s+|[^").concat(ir,"]"),"ug"),gn=new Ct;gn.equals=function(t,e,n){return n.ignoreCase&&(t=t.toLowerCase(),e=e.toLowerCase()),t.trim()===e.trim()};gn.tokenize=function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n;if(e.intlSegmenter){if(e.intlSegmenter.resolvedOptions().granularity!="word")throw new Error('The segmenter passed must have a granularity of "word"');n=Array.from(e.intlSegmenter.segment(t),function(a){return a.segment})}else n=t.match(i1)||[];var r=[],o=null;return n.forEach(function(a){/\s/.test(a)?o==null?r.push(a):r.push(r.pop()+a):/\s/.test(o)?r[r.length-1]==o?r.push(r.pop()+a):r.push(o+a):r.push(a),o=a}),r};gn.join=function(t){return t.map(function(e,n){return n==0?e:e.replace(/^\s+/,"")}).join("")};gn.postProcess=function(t,e){if(!t||e.oneChangePerToken)return t;var n=null,r=null,o=null;return t.forEach(function(a){a.added?r=a:a.removed?o=a:((r||o)&&xc(n,o,r,a),n=a,r=null,o=null)}),(r||o)&&xc(n,o,r,null),t};function c1(t,e,n){return gn.diff(t,e,n)}function xc(t,e,n,r){if(e&&n){var o=e.value.match(/^\s*/)[0],a=e.value.match(/\s*$/)[0],i=n.value.match(/^\s*/)[0],l=n.value.match(/\s*$/)[0];if(t){var c=hc(o,i);t.value=Jo(t.value,i,c),e.value=Hs(e.value,c),n.value=Hs(n.value,c)}if(r){var d=fc(a,l);r.value=Yo(r.value,l,d),e.value=Tn(e.value,d),n.value=Tn(n.value,d)}}else if(n)t&&(n.value=n.value.replace(/^\s*/,"")),r&&(r.value=r.value.replace(/^\s*/,""));else if(t&&r){var p=r.value.match(/^\s*/)[0],m=e.value.match(/^\s*/)[0],h=e.value.match(/\s*$/)[0],g=hc(p,m);e.value=Hs(e.value,g);var f=fc(Hs(p,g),h);e.value=Tn(e.value,f),r.value=Yo(r.value,p,f),t.value=Jo(t.value,p,p.slice(0,p.length-f.length))}else if(r){var x=r.value.match(/^\s*/)[0],b=e.value.match(/\s*$/)[0],y=gc(b,x);e.value=Tn(e.value,y)}else if(t){var v=t.value.match(/\s*$/)[0],w=e.value.match(/^\s*/)[0],N=gc(v,w);e.value=Hs(e.value,N)}}var l1=new Ct;l1.tokenize=function(t){var e=new RegExp("(\\r?\\n)|[".concat(ir,"]+|[^\\S\\n\\r]+|[^").concat(ir,"]"),"ug");return t.match(e)||[]};var jr=new Ct;jr.tokenize=function(t,e){e.stripTrailingCr&&(t=t.replace(/\r\n/g,`
|
|
71
|
+
`)&&t.trim()!==a.trim(),l=a.slice(0,80)+(a.length>80?"...":""),c=s.jsxs(s.Fragment,{children:[s.jsx(zo,{size:14,className:"text-red-700 dark:text-red-400/80 flex-shrink-0"}),n&&s.jsx("span",{className:"text-xs text-red-800/70 dark:text-red-300/60 truncate flex-shrink min-w-0",children:n}),n&&s.jsx("span",{className:"text-xs text-red-800/40 dark:text-red-400/40",children:"|"}),s.jsx("span",{className:"text-xs text-red-800/80 dark:text-red-300/70 truncate flex-1",children:l})]});return i?s.jsx("div",{className:"w-fit max-w-full",children:s.jsx(Ba,{open:r,onOpenChange:o,children:s.jsxs("div",{className:"border border-red-600/30 rounded-lg overflow-hidden bg-red-500/15 dark:bg-red-500/5",children:[s.jsx(Ua,{className:"w-full text-left cursor-pointer select-none",children:s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 hover:bg-red-500/20 dark:hover:bg-red-500/10 transition-colors",children:[c,s.jsx(nn,{size:12,className:`text-red-700/60 dark:text-red-400/60 transition-transform duration-150 flex-shrink-0 ${r?"":"-rotate-90"}`})]})}),s.jsx(Ga,{children:s.jsx("div",{className:R("border-t border-red-500/20",k.codeBg),children:s.jsx(Yv,{code:t})})})]})})}):s.jsx("div",{className:"w-fit max-w-full",children:s.jsx("div",{className:"border border-red-600/30 rounded-lg overflow-hidden bg-red-500/15 dark:bg-red-500/5",children:s.jsx("div",{className:"flex items-center gap-2 px-3 py-2",children:c})})})}function Zv({toolName:t,toolInput:e,toolResult:n,workingDirectory:r,toolUseId:o,childrenMessages:a,toolResults:i,questionId:l,onAnswerQuestion:c,isStreaming:d,renderChildMessage:p,customRenderers:m,onPlanApprove:h,onPlanReject:g,planOutcomes:f,fetchBackgroundOutput:x}){const[b,y]=u.useState(!1),w=n?.result?typeof n.result=="string"?n.result:Array.isArray(n.result)?n.result.filter(T=>T.type==="text").map(T=>T.text||"").join(`
|
|
72
|
+
`):"":"",N=n?.is_error===!0,S=(!n||n.status==="pending")&&d!==!1;if(m?.[t]){const T=m[t]({toolName:t,input:e,result:w,isError:N,isPending:S,toolUseId:o,workingDirectory:r,isStreaming:d});if(T!==void 0)return T}if(S){if(t==="Task"||t==="Agent")return s.jsx(nc,{input:e,result:w,toolUseId:o,childrenMessages:a,toolResults:i,isPending:!0,isStreaming:d,renderChildMessage:p});if(t==="TaskOutput")return s.jsx(rc,{input:e,result:w,isPending:!0});if(t==="AskUserQuestion"&&!l)return null;if(t==="Bash")return s.jsx(tc,{input:e,result:w,workingDirectory:r,isPending:!0,fetchBackgroundOutput:x});if(t==="Monitor")return s.jsx(cc,{input:e,result:w,isPending:!0});if(t==="ScheduleWakeup")return s.jsx(lc,{input:e,result:w,isPending:!0});const C=(()=>{switch(t){case"Read":return{icon:jt,label:"Reading",detail:Ns(String(e?.file_path??""),r),iconClass:ce.blue.icon};case"Edit":case"MultiEdit":return{icon:Wg,label:"Editing",detail:Ns(String(e?.file_path??""),r),iconClass:ce.emerald.icon};case"Write":return{icon:Eg,label:"Writing",detail:Ns(String(e?.file_path??""),r),iconClass:ce.violet.icon};case"Bash":return{icon:Yn,label:"Running",detail:typeof e?.command=="string"?e.command.slice(0,60):"",iconClass:ce.orange.icon};case"Grep":return{icon:ss,label:"Searching",detail:String(e?.pattern??""),iconClass:ce.amber.icon};case"Glob":return{icon:ss,label:"Finding",detail:String(e?.pattern??""),iconClass:ce.violet.icon};case"LS":return{icon:wd,label:"Listing",detail:String(e?.path??"."),iconClass:ce.violet.icon};case"ToolSearch":return{icon:ss,label:"Loading tools",detail:String(e?.query??""),iconClass:ce.violet.icon};case"WebSearch":return{icon:is,label:"Searching",detail:String(e?.query??""),iconClass:ce.emerald.icon};case"WebFetch":return{icon:Os,label:"Fetching",detail:e?.url?(()=>{try{return new URL(e.url).hostname}catch{return""}})():"",iconClass:ce.emerald.icon};default:{if(t.startsWith("mcp__")){const E=t.match(/^mcp__[^_]+__(.+)$/),A=E?E[1].replace(/_/g," "):t,L=t.includes("chrome_devtools__")||t.includes("chrome-devtools__"),$=e?.selector||e?.url||e?.uid||e?.text||e?.path||e?.query||e?.pattern||"";return{icon:L?is:jt,label:A,detail:$,iconClass:L?ce.cyan.icon:ce.purple.icon}}return{icon:jt,label:t,detail:"",iconClass:k.text.muted}}}})(),j=C.icon;return s.jsx("div",{className:"w-fit max-w-full",children:s.jsx("div",{className:R("border rounded-lg overflow-hidden",k.card.border,k.card.bg),children:s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[s.jsx(at,{size:12,className:`${k.text.muted} flex-shrink-0 animate-spin`}),s.jsx(j,{size:14,className:`${C.iconClass} flex-shrink-0`}),s.jsx("span",{className:`text-xs ${k.text.muted}`,children:C.label}),s.jsx("span",{className:`text-xs ${k.text.secondary} truncate flex-1`,children:C.detail})]})})})}if(N&&(t==="AskUserQuestion"||t==="EnterPlanMode"||w?.toLowerCase().includes("answer questions?")))return null;if(N&&(t==="ExitPlanMode"||t==="exit_plan_mode"||w?.toLowerCase().includes("exit plan mode")))return s.jsx(oc,{input:e,result:w,isPendingApproval:!0,priorOutcome:o&&f?.[o]||!1,onApprove:h,onReject:g});if(N)return s.jsx(Xv,{message:w||"Tool execution failed",toolName:t,context:Jv(t,e,r),isExpanded:b,onExpandedChange:y});switch(t){case"Read":return s.jsx(ry,{input:e,result:w,workingDirectory:r});case"Edit":case"MultiEdit":return s.jsx(iy,{input:e,result:w,isMultiEdit:t==="MultiEdit",workingDirectory:r});case"Write":return s.jsx(ly,{input:e,result:w,workingDirectory:r});case"Bash":return s.jsx(tc,{input:e,result:w,fetchBackgroundOutput:x});case"Monitor":return s.jsx(cc,{input:e,result:w});case"ScheduleWakeup":return s.jsx(lc,{input:e,result:w});case"Grep":case"Glob":case"LS":return s.jsx(Ey,{input:e,result:w,toolType:t});case"TodoRead":case"TodoWrite":return s.jsx(Iy,{input:e,result:w,isWrite:t==="TodoWrite"});case"WebSearch":case"WebFetch":return s.jsx(Dy,{input:e,result:w,toolType:t});case"ToolSearch":return s.jsx(Hv,{input:e,result:w});case"Task":case"Agent":return s.jsx(nc,{input:e,result:w,toolUseId:o,childrenMessages:a,toolResults:i,isStreaming:d,renderChildMessage:p});case"TaskOutput":return s.jsx(rc,{input:e,result:w});case"TaskCreate":case"TaskUpdate":return s.jsx(Uv,{input:e,result:w,isUpdate:t==="TaskUpdate"});case"EnterPlanMode":return null;case"exit_plan_mode":case"ExitPlanMode":return s.jsx(oc,{input:e,result:w,onApprove:h,onReject:g});case"AskUserQuestion":return s.jsx(tu,{input:e,result:w,questionId:l,onAnswer:c,isPending:S});case"TeamCreate":return s.jsx(Wv,{input:e,result:w,isPending:S,isStreaming:d});case"SendMessage":return s.jsx(Kv,{input:e,result:w,isPending:S,isStreaming:d});case"TeamDelete":return s.jsx(Qv,{result:w,isPending:S,isStreaming:d});default:return t.startsWith("mcp__")?t.includes("slack__")?s.jsx(Cv,{toolName:t,input:e,result:w}):t.includes("otion__")||t.includes("notion__")?s.jsx(Rv,{toolName:t,input:e,result:w}):t.includes("chrome_devtools__")||t.includes("chrome-devtools__")?s.jsx(yv,{toolName:t,input:e,result:w}):t.includes("linear__")?s.jsx(Fv,{toolName:t,input:e,result:w}):s.jsx(Yy,{toolName:t,input:e,result:w}):s.jsx(Gy,{toolName:t,input:e,result:w})}}const e1={},t1={};function s1({toolUse:t,toolResult:e,toolResults:n=e1,workingDirectory:r,childrenMessages:o=t1,questionId:a,onAnswerQuestion:i,isStreaming:l,renderChildMessage:c,customRenderers:d,onPlanApprove:p,onPlanReject:m,planOutcomes:h,fetchBackgroundOutput:g}){return t.name==="ToolSearch"&&typeof t.input.query=="string"&&t.input.query.startsWith("select:")?null:s.jsx(Ha,{name:`Tool:${t.name}`,children:s.jsx("div",{"data-testid":`tool-${t.name}`,children:s.jsx(Zv,{toolName:t.name,toolInput:t.input,toolResult:e,workingDirectory:r,toolUseId:t.id,childrenMessages:o,toolResults:n,questionId:a,onAnswerQuestion:i,isStreaming:l,renderChildMessage:c,customRenderers:d,onPlanApprove:p,onPlanReject:m,planOutcomes:h,fetchBackgroundOutput:g})})})}const pc={read:{icon:jt,label:"Read",color:"text-blue-400/80"},grep:{icon:ss,label:"Grep",color:"text-amber-400/80"},glob:{icon:Li,label:"Glob",color:"text-violet-400/80"},ls:{icon:Li,label:"LS",color:"text-violet-400/80"},"web-search":{icon:is,label:"Search",color:"text-emerald-400/80"},"web-fetch":{icon:is,label:"Fetch",color:"text-emerald-400/80"},"tool-search":{icon:ss,label:"Tools",color:"text-emerald-400/80"}};function n1(t){return t.replace(/^\d+\t/gm,"")}function r1({code:t,language:e}){const r=hr()==="dark"?"github-dark-default":"github-light-default",[o,a]=u.useState(null);return u.useEffect(()=>{Va(t,{lang:e,theme:r}).then(a).catch(()=>a(null))},[t,e,r]),o?s.jsx("div",{className:"[&_pre]:!bg-transparent [&_pre]:px-3 [&_pre]:py-2.5 [&_pre]:text-[13px] [&_pre]:leading-relaxed [&_pre]:whitespace-pre-wrap [&_pre]:break-words [&_code]:!bg-transparent",dangerouslySetInnerHTML:{__html:o}}):s.jsx("pre",{className:R("px-3 py-2.5 text-[13px] whitespace-pre-wrap break-words leading-relaxed",k.text.secondary),children:t})}function o1({hint:t}){const[e,n]=u.useState(t),[r,o]=u.useState(!1);return u.useEffect(()=>{if(t!==e){o(!0);const a=setTimeout(()=>{n(t),o(!1)},150);return()=>clearTimeout(a)}},[t,e]),s.jsx("span",{className:R("inline-flex items-center overflow-hidden h-4 ml-2 pl-2 border-l","border-stone-200 dark:border-zinc-700/50"),children:s.jsx("span",{className:"relative overflow-hidden h-4 inline-flex items-center",children:s.jsx("span",{className:R("text-[11px] transition-all duration-150 ease-out",k.text.faint,r?"-translate-y-full opacity-0":"translate-y-0 opacity-100"),children:e})})})}function Qo({group:t,temporalState:e}){const[n,r]=u.useState(!1),[o,a]=u.useState(new Set),i=l=>{a(c=>{const d=new Set(c);return d.has(l)?d.delete(l):d.add(l),d})};return s.jsxs("div",{className:R("w-fit max-w-full rounded-lg border transition-all duration-200","border-stone-300/40 bg-stone-500/5 dark:border-zinc-500/25 dark:bg-zinc-500/5"),children:[s.jsxs("button",{onClick:()=>r(!n),className:"w-full flex items-center gap-2 px-3 py-2 text-left cursor-pointer group",children:[s.jsx("div",{className:"flex-shrink-0",children:e==="active"?s.jsx(at,{className:R("w-3.5 h-3.5 animate-spin",k.text.secondary)}):s.jsx(Pg,{className:R("w-3.5 h-3.5",k.text.secondary)})}),s.jsxs("span",{className:R("flex-1 min-w-0 text-xs truncate",k.text.secondary),children:[t.summary,e==="active"&&t.latestHint&&s.jsx(o1,{hint:t.latestHint})]}),s.jsx(nn,{className:R("w-3 h-3 transition-all duration-200 flex-shrink-0",k.text.muted,`group-hover:${k.text.secondary}`,n&&"rotate-180")})]}),n&&s.jsx("div",{className:"px-3 pb-3",children:s.jsx("div",{className:R("border-t pt-2 space-y-1",k.separator),children:t.toolCalls.map((l,c)=>{const d=pc[l.tool]??pc.read,p=d.icon,m=o.has(c),h=l.resultContent?gd(l.resultContent):l.resultContent,g=h&&l.status==="success",f=l.tool==="read"&&fr(l.filePath??l.input)||"text";return s.jsxs("div",{children:[s.jsxs("button",{onClick:x=>{x.stopPropagation(),g&&i(c)},className:R("w-full flex items-center gap-2 px-2 py-1.5 rounded text-left transition-colors",g&&`cursor-pointer ${k.hover}`,!g&&"cursor-default"),children:[s.jsx(p,{className:R("w-3.5 h-3.5 flex-shrink-0",d.color)}),s.jsx("span",{className:R("flex-1 text-xs truncate",k.text.secondary),children:l.input}),g&&s.jsx(nn,{className:R("w-3 h-3 transition-transform duration-150 flex-shrink-0",k.text.faint,m&&"rotate-180")}),l.status==="pending"&&s.jsx(at,{className:R("w-3 h-3 animate-spin flex-shrink-0",k.text.faint)})]}),m&&g&&s.jsx("div",{className:"mt-1.5 mb-2",children:s.jsxs("div",{className:R("relative rounded-md border overflow-hidden max-h-60 overflow-y-auto",k.codeBg,"border-stone-200 dark:border-zinc-800/60",k.scrollbar),children:[s.jsx("div",{className:"absolute inset-y-0 left-0 w-0.5 bg-gradient-to-b from-stone-300 via-stone-400 to-stone-300 dark:from-zinc-700 dark:via-zinc-600 dark:to-zinc-700"}),l.tool==="read"?s.jsx(r1,{code:n1(h),language:f}):l.tool==="web-search"?s.jsx(eu,{result:h,compact:!0}):s.jsx(Ly,{content:h,compact:!0})]})})]},c)})})})]})}function St(){}St.prototype={diff:function(e,n){var r,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=o.callback;typeof o=="function"&&(a=o,o={});var i=this;function l(N){return N=i.postProcess(N,o),a?(setTimeout(function(){a(N)},0),!0):N}e=this.castInput(e,o),n=this.castInput(n,o),e=this.removeEmpty(this.tokenize(e,o)),n=this.removeEmpty(this.tokenize(n,o));var c=n.length,d=e.length,p=1,m=c+d;o.maxEditLength!=null&&(m=Math.min(m,o.maxEditLength));var h=(r=o.timeout)!==null&&r!==void 0?r:1/0,g=Date.now()+h,f=[{oldPos:-1,lastComponent:void 0}],x=this.extractCommon(f[0],n,e,0,o);if(f[0].oldPos+1>=d&&x+1>=c)return l(mc(i,f[0].lastComponent,n,e,i.useLongestToken));var b=-1/0,y=1/0;function v(){for(var N=Math.max(b,-p);N<=Math.min(y,p);N+=2){var S=void 0,T=f[N-1],C=f[N+1];T&&(f[N-1]=void 0);var j=!1;if(C){var E=C.oldPos-N;j=C&&0<=E&&E<c}var A=T&&T.oldPos+1<d;if(!j&&!A){f[N]=void 0;continue}if(!A||j&&T.oldPos<C.oldPos?S=i.addToPath(C,!0,!1,0,o):S=i.addToPath(T,!1,!0,1,o),x=i.extractCommon(S,n,e,N,o),S.oldPos+1>=d&&x+1>=c)return l(mc(i,S.lastComponent,n,e,i.useLongestToken));f[N]=S,S.oldPos+1>=d&&(y=Math.min(y,N-1)),x+1>=c&&(b=Math.max(b,N+1))}p++}if(a)(function N(){setTimeout(function(){if(p>m||Date.now()>g)return a();v()||N()},0)})();else for(;p<=m&&Date.now()<=g;){var w=v();if(w)return w}},addToPath:function(e,n,r,o,a){var i=e.lastComponent;return i&&!a.oneChangePerToken&&i.added===n&&i.removed===r?{oldPos:e.oldPos+o,lastComponent:{count:i.count+1,added:n,removed:r,previousComponent:i.previousComponent}}:{oldPos:e.oldPos+o,lastComponent:{count:1,added:n,removed:r,previousComponent:i}}},extractCommon:function(e,n,r,o,a){for(var i=n.length,l=r.length,c=e.oldPos,d=c-o,p=0;d+1<i&&c+1<l&&this.equals(r[c+1],n[d+1],a);)d++,c++,p++,a.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return p&&!a.oneChangePerToken&&(e.lastComponent={count:p,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=c,d},equals:function(e,n,r){return r.comparator?r.comparator(e,n):e===n||r.ignoreCase&&e.toLowerCase()===n.toLowerCase()},removeEmpty:function(e){for(var n=[],r=0;r<e.length;r++)e[r]&&n.push(e[r]);return n},castInput:function(e){return e},tokenize:function(e){return Array.from(e)},join:function(e){return e.join("")},postProcess:function(e){return e}};function mc(t,e,n,r,o){for(var a=[],i;e;)a.push(e),i=e.previousComponent,delete e.previousComponent,e=i;a.reverse();for(var l=0,c=a.length,d=0,p=0;l<c;l++){var m=a[l];if(m.removed)m.value=t.join(r.slice(p,p+m.count)),p+=m.count;else{if(!m.added&&o){var h=n.slice(d,d+m.count);h=h.map(function(g,f){var x=r[p+f];return x.length>g.length?x:g}),m.value=t.join(h)}else m.value=t.join(n.slice(d,d+m.count));d+=m.count,m.added||(p+=m.count)}}return a}function hc(t,e){var n;for(n=0;n<t.length&&n<e.length;n++)if(t[n]!=e[n])return t.slice(0,n);return t.slice(0,n)}function fc(t,e){var n;if(!t||!e||t[t.length-1]!=e[e.length-1])return"";for(n=0;n<t.length&&n<e.length;n++)if(t[t.length-(n+1)]!=e[e.length-(n+1)])return t.slice(-n);return t.slice(-n)}function Yo(t,e,n){if(t.slice(0,e.length)!=e)throw Error("string ".concat(JSON.stringify(t)," doesn't start with prefix ").concat(JSON.stringify(e),"; this is a bug"));return n+t.slice(e.length)}function Jo(t,e,n){if(!e)return t+n;if(t.slice(-e.length)!=e)throw Error("string ".concat(JSON.stringify(t)," doesn't end with suffix ").concat(JSON.stringify(e),"; this is a bug"));return t.slice(0,-e.length)+n}function Hs(t,e){return Yo(t,e,"")}function Tn(t,e){return Jo(t,e,"")}function gc(t,e){return e.slice(0,a1(t,e))}function a1(t,e){var n=0;t.length>e.length&&(n=t.length-e.length);var r=e.length;t.length<e.length&&(r=t.length);var o=Array(r),a=0;o[0]=0;for(var i=1;i<r;i++){for(e[i]==e[a]?o[i]=o[a]:o[i]=a;a>0&&e[i]!=e[a];)a=o[a];e[i]==e[a]&&a++}a=0;for(var l=n;l<t.length;l++){for(;a>0&&t[l]!=e[a];)a=o[a];t[l]==e[a]&&a++}return a}var ir="a-zA-Z0-9_\\u{C0}-\\u{FF}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}",i1=new RegExp("[".concat(ir,"]+|\\s+|[^").concat(ir,"]"),"ug"),gn=new St;gn.equals=function(t,e,n){return n.ignoreCase&&(t=t.toLowerCase(),e=e.toLowerCase()),t.trim()===e.trim()};gn.tokenize=function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n;if(e.intlSegmenter){if(e.intlSegmenter.resolvedOptions().granularity!="word")throw new Error('The segmenter passed must have a granularity of "word"');n=Array.from(e.intlSegmenter.segment(t),function(a){return a.segment})}else n=t.match(i1)||[];var r=[],o=null;return n.forEach(function(a){/\s/.test(a)?o==null?r.push(a):r.push(r.pop()+a):/\s/.test(o)?r[r.length-1]==o?r.push(r.pop()+a):r.push(o+a):r.push(a),o=a}),r};gn.join=function(t){return t.map(function(e,n){return n==0?e:e.replace(/^\s+/,"")}).join("")};gn.postProcess=function(t,e){if(!t||e.oneChangePerToken)return t;var n=null,r=null,o=null;return t.forEach(function(a){a.added?r=a:a.removed?o=a:((r||o)&&xc(n,o,r,a),n=a,r=null,o=null)}),(r||o)&&xc(n,o,r,null),t};function c1(t,e,n){return gn.diff(t,e,n)}function xc(t,e,n,r){if(e&&n){var o=e.value.match(/^\s*/)[0],a=e.value.match(/\s*$/)[0],i=n.value.match(/^\s*/)[0],l=n.value.match(/\s*$/)[0];if(t){var c=hc(o,i);t.value=Jo(t.value,i,c),e.value=Hs(e.value,c),n.value=Hs(n.value,c)}if(r){var d=fc(a,l);r.value=Yo(r.value,l,d),e.value=Tn(e.value,d),n.value=Tn(n.value,d)}}else if(n)t&&(n.value=n.value.replace(/^\s*/,"")),r&&(r.value=r.value.replace(/^\s*/,""));else if(t&&r){var p=r.value.match(/^\s*/)[0],m=e.value.match(/^\s*/)[0],h=e.value.match(/\s*$/)[0],g=hc(p,m);e.value=Hs(e.value,g);var f=fc(Hs(p,g),h);e.value=Tn(e.value,f),r.value=Yo(r.value,p,f),t.value=Jo(t.value,p,p.slice(0,p.length-f.length))}else if(r){var x=r.value.match(/^\s*/)[0],b=e.value.match(/\s*$/)[0],y=gc(b,x);e.value=Tn(e.value,y)}else if(t){var v=t.value.match(/\s*$/)[0],w=e.value.match(/^\s*/)[0],N=gc(v,w);e.value=Hs(e.value,N)}}var l1=new St;l1.tokenize=function(t){var e=new RegExp("(\\r?\\n)|[".concat(ir,"]+|[^\\S\\n\\r]+|[^").concat(ir,"]"),"ug");return t.match(e)||[]};var jr=new St;jr.tokenize=function(t,e){e.stripTrailingCr&&(t=t.replace(/\r\n/g,`
|
|
73
73
|
`));var n=[],r=t.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(var o=0;o<r.length;o++){var a=r[o];o%2&&!e.newlineIsToken?n[n.length-1]+=a:n.push(a)}return n};jr.equals=function(t,e,n){return n.ignoreWhitespace?((!n.newlineIsToken||!t.includes(`
|
|
74
74
|
`))&&(t=t.trim()),(!n.newlineIsToken||!e.includes(`
|
|
75
75
|
`))&&(e=e.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(t.endsWith(`
|
|
76
76
|
`)&&(t=t.slice(0,-1)),e.endsWith(`
|
|
77
|
-
`)&&(e=e.slice(0,-1))),
|
|
77
|
+
`)&&(e=e.slice(0,-1))),St.prototype.equals.call(this,t,e,n)};function d1(t,e,n){return jr.diff(t,e,n)}var u1=new St;u1.tokenize=function(t){return t.split(/(\S.+?[.!?])(?=\s+|$)/)};var p1=new St;p1.tokenize=function(t){return t.split(/([{}:;,]|\s+)/)};function Xo(t){"@babel/helpers - typeof";return Xo=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Xo(t)}var dn=new St;dn.useLongestToken=!0;dn.tokenize=jr.tokenize;dn.castInput=function(t,e){var n=e.undefinedReplacement,r=e.stringifyReplacer,o=r===void 0?function(a,i){return typeof i>"u"?n:i}:r;return typeof t=="string"?t:JSON.stringify(Zo(t,null,null,o),o," ")};dn.equals=function(t,e,n){return St.prototype.equals.call(dn,t.replace(/,([\r\n])/g,"$1"),e.replace(/,([\r\n])/g,"$1"),n)};function Zo(t,e,n,r,o){e=e||[],n=n||[],r&&(t=r(o,t));var a;for(a=0;a<e.length;a+=1)if(e[a]===t)return n[a];var i;if(Object.prototype.toString.call(t)==="[object Array]"){for(e.push(t),i=new Array(t.length),n.push(i),a=0;a<t.length;a+=1)i[a]=Zo(t[a],e,n,r,o);return e.pop(),n.pop(),i}if(t&&t.toJSON&&(t=t.toJSON()),Xo(t)==="object"&&t!==null){e.push(t),i={},n.push(i);var l=[],c;for(c in t)Object.prototype.hasOwnProperty.call(t,c)&&l.push(c);for(l.sort(),a=0;a<l.length;a+=1)c=l[a],i[c]=Zo(t[c],e,n,r,c);e.pop(),n.pop()}else i=t;return i}var ea=new St;ea.tokenize=function(t){return t.slice()};ea.join=ea.removeEmpty=function(t){return t};function m1(t,e){const n=t.split(`
|
|
78
78
|
`),r=e.split(`
|
|
79
79
|
`),o=n.map(l=>[{text:l,type:"removed"}]),a=r.map(l=>[{text:l,type:"added"}]),i=Math.min(n.length,r.length);for(let l=0;l<i;l++){const c=c1(n[l],r[l]),d=[],p=[];for(const m of c)m.added?p.push({text:m.value,type:"added"}):m.removed?d.push({text:m.value,type:"removed"}):(d.push({text:m.value,type:"unchanged"}),p.push({text:m.value,type:"unchanged"}));o[l]=d,a[l]=p}return{oldSegments:o,newSegments:a}}function h1(t,e){const n=d1(t,e),r=[];let o=0,a=1,i=1;const l=n.map(c=>({type:c.added?"added":c.removed?"removed":"unchanged",value:c.value}));for(let c=0;c<l.length;c++){const d=l[c],p=d.value.split(`
|
|
80
80
|
`);if(p[p.length-1]===""&&p.pop(),d.type==="unchanged")for(const m of p)r.push({id:`d-${o++}`,type:"unchanged",content:m,oldLineNum:a++,newLineNum:i++});else if(d.type==="removed"){const m=l[c+1];if(m?.type==="added"){const{oldSegments:h,newSegments:g}=m1(d.value.replace(/\n$/,""),m.value.replace(/\n$/,""));for(let x=0;x<h.length;x++)r.push({id:`d-${o++}`,type:"removed",content:p[x]||"",segments:h[x],oldLineNum:a++});const f=m.value.split(`
|
|
81
|
-
`);f[f.length-1]===""&&f.pop();for(let x=0;x<f.length;x++)r.push({id:`d-${o++}`,type:"added",content:f[x],segments:g[x],newLineNum:i++});c++}else for(const h of p)r.push({id:`d-${o++}`,type:"removed",content:h,oldLineNum:a++})}else for(const m of p)r.push({id:`d-${o++}`,type:"added",content:m,newLineNum:i++})}return r}function bc(t,e,n){const[r,o]=u.useState(null);return u.useEffect(()=>{if(!t||e==="text"){o(null);return}Zb(t,{lang:e,theme:n}).then(a=>o(a.tokens)).catch(()=>o(null))},[t,e,n]),r}function f1({tokens:t}){return t.length?s.jsx(s.Fragment,{children:t.map((e,n)=>s.jsx("span",{style:{color:e.color},children:e.content},n))}):s.jsx(s.Fragment,{children:" "})}function g1({segments:t}){return s.jsx(s.Fragment,{children:t.map((e,n)=>{if(e.type==="unchanged")return s.jsx("span",{children:e.text},n);const r=e.type==="added"?"bg-emerald-500/25 dark:bg-emerald-400/20 rounded-sm":"bg-red-500/25 dark:bg-red-400/20 rounded-sm";return s.jsx("span",{className:r,children:e.text},n)})})}const to=12;function su({oldValue:t,newValue:e,language:n="text"}){const[r,o]=u.useState(!1),a=t??"",i=e??"",c=hr()==="dark"?"github-dark-default":"github-light-default",d=u.useMemo(()=>h1(a,i),[a,i]),p=bc(a,n,c),m=bc(i,n,c),h=u.useMemo(()=>{if(!p)return null;const v=new Map;return p.forEach((w,N)=>v.set(N+1,w)),v},[p]),g=u.useMemo(()=>{if(!m)return null;const v=new Map;return m.forEach((w,N)=>v.set(N+1,w)),v},[m]),f=d.length,x=f>to,b=r?d:d.slice(0,to),y=f-to;return a===i?s.jsx("div",{className:M("p-3 font-mono text-[13px]",k.text.muted,k.codeBg),children:"No changes"}):s.jsxs("div",{className:M("relative overflow-hidden",k.codeBg),children:[x&&s.jsx("button",{onClick:()=>o(!r),className:M("absolute top-2 right-2 h-6 w-6 p-0 z-10 flex items-center justify-center rounded transition-colors cursor-pointer","text-stone-400 hover:text-stone-600 bg-stone-100/80","dark:text-zinc-600 dark:hover:text-zinc-400 dark:bg-zinc-900/80"),"aria-label":r?"Show fewer lines":"Show all lines",children:r?s.jsx($g,{size:12}):s.jsx(Og,{size:12})}),s.jsx("div",{className:"font-mono text-[13px] leading-relaxed",children:b.map(v=>{const w=v.type==="added"?"bg-emerald-500/8 dark:bg-emerald-500/8":v.type==="removed"?"bg-red-500/8 dark:bg-red-500/8":"",N=v.type==="added"?"text-emerald-600 dark:text-emerald-400/70":v.type==="removed"?"text-red-600 dark:text-red-400/70":k.text.faint,S=v.type==="added"?"+":v.type==="removed"?"-":" ",T=v.type==="unchanged"?"opacity-50":"";return s.jsxs("div",{className:M("flex",w),children:[s.jsx("span",{className:M("select-none w-8 text-right pr-1 shrink-0 text-[11px] tabular-nums",k.text.faint),children:v.oldLineNum??""}),s.jsx("span",{className:M("select-none w-8 text-right pr-1 shrink-0 text-[11px] tabular-nums",k.text.faint),children:v.newLineNum??""}),s.jsx("span",{className:M("select-none w-5 text-center shrink-0 border-r",N,v.type==="unchanged"?k.separator:v.type==="added"?"border-emerald-500/20":"border-red-500/20"),children:S}),s.jsx("span",{className:M("flex-1 whitespace-pre-wrap break-words pl-2 pr-3",k.text.primary,T),children:v.segments?s.jsx(g1,{segments:v.segments}):(()=>{const C=v.type==="removed"?h:v.type==="added"?g:h||g,j=v.type==="removed"?v.oldLineNum:v.type==="added"?v.newLineNum:v.oldLineNum||v.newLineNum,E=j&&C?.get(j);return E?s.jsx(f1,{tokens:E}):s.jsx(s.Fragment,{children:v.content||" "})})()})]},v.id)})}),!r&&x&&s.jsxs("div",{className:M("text-center text-xs py-2 border-t border-emerald-500/20",k.text.muted,"bg-stone-50/50 dark:bg-zinc-950/50"),children:["+",y," more lines"]})]})}const x1=Object.freeze(Object.defineProperty({__proto__:null,DiffViewer:su},Symbol.toStringTag,{value:"Module"}));function Is(t){const e=u.useRef(t);return u.useEffect(()=>{e.current=t}),u.useMemo(()=>(...n)=>e.current?.(...n),[])}function b1(t,e=globalThis?.document){const n=Is(t);u.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}var y1="DismissableLayer",ta="dismissableLayer.update",v1="dismissableLayer.pointerDownOutside",w1="dismissableLayer.focusOutside",yc,nu=u.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Nr=u.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:i,onDismiss:l,...c}=t,d=u.useContext(nu),[p,m]=u.useState(null),h=p?.ownerDocument??globalThis?.document,[,g]=u.useState({}),f=dt(e,C=>m(C)),x=Array.from(d.layers),[b]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),y=x.indexOf(b),v=p?x.indexOf(p):-1,w=d.layersWithOutsidePointerEventsDisabled.size>0,N=v>=y,S=j1(C=>{const j=C.target,E=[...d.branches].some(R=>R.contains(j));!N||E||(o?.(C),i?.(C),C.defaultPrevented||l?.())},h),T=N1(C=>{const j=C.target;[...d.branches].some(R=>R.contains(j))||(a?.(C),i?.(C),C.defaultPrevented||l?.())},h);return b1(C=>{v===d.layers.size-1&&(r?.(C),!C.defaultPrevented&&l&&(C.preventDefault(),l()))},h),u.useEffect(()=>{if(p)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(yc=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(p)),d.layers.add(p),vc(),()=>{n&&d.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=yc)}},[p,h,n,d]),u.useEffect(()=>()=>{p&&(d.layers.delete(p),d.layersWithOutsidePointerEventsDisabled.delete(p),vc())},[p,d]),u.useEffect(()=>{const C=()=>g({});return document.addEventListener(ta,C),()=>document.removeEventListener(ta,C)},[]),s.jsx(st.div,{...c,ref:f,style:{pointerEvents:w?N?"auto":"none":void 0,...t.style},onFocusCapture:He(t.onFocusCapture,T.onFocusCapture),onBlurCapture:He(t.onBlurCapture,T.onBlurCapture),onPointerDownCapture:He(t.onPointerDownCapture,S.onPointerDownCapture)})});Nr.displayName=y1;var _1="DismissableLayerBranch",k1=u.forwardRef((t,e)=>{const n=u.useContext(nu),r=u.useRef(null),o=dt(e,r);return u.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),s.jsx(st.div,{...t,ref:o})});k1.displayName=_1;function j1(t,e=globalThis?.document){const n=Is(t),r=u.useRef(!1),o=u.useRef(()=>{});return u.useEffect(()=>{const a=l=>{if(l.target&&!r.current){let c=function(){ru(v1,n,d,{discrete:!0})};const d={originalEvent:l};l.pointerType==="touch"?(e.removeEventListener("click",o.current),o.current=c,e.addEventListener("click",o.current,{once:!0})):c()}else e.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{e.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),e.removeEventListener("pointerdown",a),e.removeEventListener("click",o.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function N1(t,e=globalThis?.document){const n=Is(t),r=u.useRef(!1);return u.useEffect(()=>{const o=a=>{a.target&&!r.current&&ru(w1,n,{originalEvent:a},{discrete:!1})};return e.addEventListener("focusin",o),()=>e.removeEventListener("focusin",o)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function vc(){const t=new CustomEvent(ta);document.dispatchEvent(t)}function ru(t,e,n,{discrete:r}){const o=n.originalEvent.target,a=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&o.addEventListener(t,e,{once:!0}),r?Ym(o,a):o.dispatchEvent(a)}var so="focusScope.autoFocusOnMount",no="focusScope.autoFocusOnUnmount",wc={bubbles:!1,cancelable:!0},S1="FocusScope",Wa=u.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...i}=t,[l,c]=u.useState(null),d=Is(o),p=Is(a),m=u.useRef(null),h=dt(e,x=>c(x)),g=u.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;u.useEffect(()=>{if(r){let x=function(w){if(g.paused||!l)return;const N=w.target;l.contains(N)?m.current=N:Ft(m.current,{select:!0})},b=function(w){if(g.paused||!l)return;const N=w.relatedTarget;N!==null&&(l.contains(N)||Ft(m.current,{select:!0}))},y=function(w){if(document.activeElement===document.body)for(const S of w)S.removedNodes.length>0&&Ft(l)};document.addEventListener("focusin",x),document.addEventListener("focusout",b);const v=new MutationObserver(y);return l&&v.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",b),v.disconnect()}}},[r,l,g.paused]),u.useEffect(()=>{if(l){kc.add(g);const x=document.activeElement;if(!l.contains(x)){const y=new CustomEvent(so,wc);l.addEventListener(so,d),l.dispatchEvent(y),y.defaultPrevented||(C1(R1(ou(l)),{select:!0}),document.activeElement===x&&Ft(l))}return()=>{l.removeEventListener(so,d),setTimeout(()=>{const y=new CustomEvent(no,wc);l.addEventListener(no,p),l.dispatchEvent(y),y.defaultPrevented||Ft(x??document.body,{select:!0}),l.removeEventListener(no,p),kc.remove(g)},0)}}},[l,d,p,g]);const f=u.useCallback(x=>{if(!n&&!r||g.paused)return;const b=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,y=document.activeElement;if(b&&y){const v=x.currentTarget,[w,N]=E1(v);w&&N?!x.shiftKey&&y===N?(x.preventDefault(),n&&Ft(w,{select:!0})):x.shiftKey&&y===w&&(x.preventDefault(),n&&Ft(N,{select:!0})):y===v&&x.preventDefault()}},[n,r,g.paused]);return s.jsx(st.div,{tabIndex:-1,...i,ref:h,onKeyDown:f})});Wa.displayName=S1;function C1(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(Ft(r,{select:e}),document.activeElement!==n)return}function E1(t){const e=ou(t),n=_c(e,t),r=_c(e.reverse(),t);return[n,r]}function ou(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function _c(t,e){for(const n of t)if(!T1(n,{upTo:e}))return n}function T1(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function I1(t){return t instanceof HTMLInputElement&&"select"in t}function Ft(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&I1(t)&&e&&t.select()}}var kc=A1();function A1(){let t=[];return{add(e){const n=t[0];e!==n&&n?.pause(),t=jc(t,e),t.unshift(e)},remove(e){t=jc(t,e),t[0]?.resume()}}}function jc(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function R1(t){return t.filter(e=>e.tagName!=="A")}var P1="Portal",Sr=u.forwardRef((t,e)=>{const{container:n,...r}=t,[o,a]=u.useState(!1);Wn(()=>a(!0),[]);const i=n||o&&globalThis?.document?.body;return i?Am.createPortal(s.jsx(st.div,{...r,ref:e}),i):null});Sr.displayName=P1;var ro=0;function au(){u.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??Nc()),document.body.insertAdjacentElement("beforeend",t[1]??Nc()),ro++,()=>{ro===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),ro--}},[])}function Nc(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var wt=function(){return wt=Object.assign||function(e){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},wt.apply(this,arguments)};function iu(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]]);return n}function M1(t,e,n){if(n||arguments.length===2)for(var r=0,o=e.length,a;r<o;r++)(a||!(r in e))&&(a||(a=Array.prototype.slice.call(e,0,r)),a[r]=e[r]);return t.concat(a||Array.prototype.slice.call(e))}var Hn="right-scroll-bar-position",qn="width-before-scroll-bar",L1="with-scroll-bars-hidden",O1="--removed-body-scroll-bar-size";function oo(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function D1(t,e){var n=u.useState(function(){return{value:t,callback:e,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=e,n.facade}var $1=typeof window<"u"?u.useLayoutEffect:u.useEffect,Sc=new WeakMap;function z1(t,e){var n=D1(null,function(r){return t.forEach(function(o){return oo(o,r)})});return $1(function(){var r=Sc.get(n);if(r){var o=new Set(r),a=new Set(t),i=n.current;o.forEach(function(l){a.has(l)||oo(l,null)}),a.forEach(function(l){o.has(l)||oo(l,i)})}Sc.set(n,t)},[t]),n}function F1(t){return t}function V1(t,e){e===void 0&&(e=F1);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:t},useMedium:function(a){var i=e(a,r);return n.push(i),function(){n=n.filter(function(l){return l!==i})}},assignSyncMedium:function(a){for(r=!0;n.length;){var i=n;n=[],i.forEach(a)}n={push:function(l){return a(l)},filter:function(){return n}}},assignMedium:function(a){r=!0;var i=[];if(n.length){var l=n;n=[],l.forEach(a),i=n}var c=function(){var p=i;i=[],p.forEach(a)},d=function(){return Promise.resolve().then(c)};d(),n={push:function(p){i.push(p),d()},filter:function(p){return i=i.filter(p),n}}}};return o}function B1(t){t===void 0&&(t={});var e=V1(null);return e.options=wt({async:!0,ssr:!1},t),e}var cu=function(t){var e=t.sideCar,n=iu(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=e.read();if(!r)throw new Error("Sidecar medium not found");return u.createElement(r,wt({},n))};cu.isSideCarExport=!0;function U1(t,e){return t.useMedium(e),cu}var lu=B1(),ao=function(){},Cr=u.forwardRef(function(t,e){var n=u.useRef(null),r=u.useState({onScrollCapture:ao,onWheelCapture:ao,onTouchMoveCapture:ao}),o=r[0],a=r[1],i=t.forwardProps,l=t.children,c=t.className,d=t.removeScrollBar,p=t.enabled,m=t.shards,h=t.sideCar,g=t.noRelative,f=t.noIsolation,x=t.inert,b=t.allowPinchZoom,y=t.as,v=y===void 0?"div":y,w=t.gapMode,N=iu(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=h,T=z1([n,e]),C=wt(wt({},N),o);return u.createElement(u.Fragment,null,p&&u.createElement(S,{sideCar:lu,removeScrollBar:d,shards:m,noRelative:g,noIsolation:f,inert:x,setCallbacks:a,allowPinchZoom:!!b,lockRef:n,gapMode:w}),i?u.cloneElement(u.Children.only(l),wt(wt({},C),{ref:T})):u.createElement(v,wt({},C,{className:c,ref:T}),l))});Cr.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Cr.classNames={fullWidth:qn,zeroRight:Hn};var G1=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function H1(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=G1();return e&&t.setAttribute("nonce",e),t}function q1(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function W1(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var K1=function(){var t=0,e=null;return{add:function(n){t==0&&(e=H1())&&(q1(e,n),W1(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},Q1=function(){var t=K1();return function(e,n){u.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},du=function(){var t=Q1(),e=function(n){var r=n.styles,o=n.dynamic;return t(r,o),null};return e},Y1={left:0,top:0,right:0,gap:0},io=function(t){return parseInt(t||"",10)||0},J1=function(t){var e=window.getComputedStyle(document.body),n=e[t==="padding"?"paddingLeft":"marginLeft"],r=e[t==="padding"?"paddingTop":"marginTop"],o=e[t==="padding"?"paddingRight":"marginRight"];return[io(n),io(r),io(o)]},X1=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return Y1;var e=J1(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-n+e[2]-e[0])}},Z1=du(),Ss="data-scroll-locked",ew=function(t,e,n,r){var o=t.left,a=t.top,i=t.right,l=t.gap;return n===void 0&&(n="margin"),`
|
|
81
|
+
`);f[f.length-1]===""&&f.pop();for(let x=0;x<f.length;x++)r.push({id:`d-${o++}`,type:"added",content:f[x],segments:g[x],newLineNum:i++});c++}else for(const h of p)r.push({id:`d-${o++}`,type:"removed",content:h,oldLineNum:a++})}else for(const m of p)r.push({id:`d-${o++}`,type:"added",content:m,newLineNum:i++})}return r}function bc(t,e,n){const[r,o]=u.useState(null);return u.useEffect(()=>{if(!t||e==="text"){o(null);return}Zb(t,{lang:e,theme:n}).then(a=>o(a.tokens)).catch(()=>o(null))},[t,e,n]),r}function f1({tokens:t}){return t.length?s.jsx(s.Fragment,{children:t.map((e,n)=>s.jsx("span",{style:{color:e.color},children:e.content},n))}):s.jsx(s.Fragment,{children:" "})}function g1({segments:t}){return s.jsx(s.Fragment,{children:t.map((e,n)=>{if(e.type==="unchanged")return s.jsx("span",{children:e.text},n);const r=e.type==="added"?"bg-emerald-500/25 dark:bg-emerald-400/20 rounded-sm":"bg-red-500/25 dark:bg-red-400/20 rounded-sm";return s.jsx("span",{className:r,children:e.text},n)})})}const to=12;function su({oldValue:t,newValue:e,language:n="text"}){const[r,o]=u.useState(!1),a=t??"",i=e??"",c=hr()==="dark"?"github-dark-default":"github-light-default",d=u.useMemo(()=>h1(a,i),[a,i]),p=bc(a,n,c),m=bc(i,n,c),h=u.useMemo(()=>{if(!p)return null;const v=new Map;return p.forEach((w,N)=>v.set(N+1,w)),v},[p]),g=u.useMemo(()=>{if(!m)return null;const v=new Map;return m.forEach((w,N)=>v.set(N+1,w)),v},[m]),f=d.length,x=f>to,b=r?d:d.slice(0,to),y=f-to;return a===i?s.jsx("div",{className:R("p-3 font-mono text-[13px]",k.text.muted,k.codeBg),children:"No changes"}):s.jsxs("div",{className:R("relative overflow-hidden",k.codeBg),children:[x&&s.jsx("button",{onClick:()=>o(!r),className:R("absolute top-2 right-2 h-6 w-6 p-0 z-10 flex items-center justify-center rounded transition-colors cursor-pointer","text-stone-400 hover:text-stone-600 bg-stone-100/80","dark:text-zinc-600 dark:hover:text-zinc-400 dark:bg-zinc-900/80"),"aria-label":r?"Show fewer lines":"Show all lines",children:r?s.jsx($g,{size:12}):s.jsx(Og,{size:12})}),s.jsx("div",{className:"font-mono text-[13px] leading-relaxed",children:b.map(v=>{const w=v.type==="added"?"bg-emerald-500/8 dark:bg-emerald-500/8":v.type==="removed"?"bg-red-500/8 dark:bg-red-500/8":"",N=v.type==="added"?"text-emerald-600 dark:text-emerald-400/70":v.type==="removed"?"text-red-600 dark:text-red-400/70":k.text.faint,S=v.type==="added"?"+":v.type==="removed"?"-":" ",T=v.type==="unchanged"?"opacity-50":"";return s.jsxs("div",{className:R("flex",w),children:[s.jsx("span",{className:R("select-none w-8 text-right pr-1 shrink-0 text-[11px] tabular-nums",k.text.faint),children:v.oldLineNum??""}),s.jsx("span",{className:R("select-none w-8 text-right pr-1 shrink-0 text-[11px] tabular-nums",k.text.faint),children:v.newLineNum??""}),s.jsx("span",{className:R("select-none w-5 text-center shrink-0 border-r",N,v.type==="unchanged"?k.separator:v.type==="added"?"border-emerald-500/20":"border-red-500/20"),children:S}),s.jsx("span",{className:R("flex-1 whitespace-pre-wrap break-words pl-2 pr-3",k.text.primary,T),children:v.segments?s.jsx(g1,{segments:v.segments}):(()=>{const C=v.type==="removed"?h:v.type==="added"?g:h||g,j=v.type==="removed"?v.oldLineNum:v.type==="added"?v.newLineNum:v.oldLineNum||v.newLineNum,E=j&&C?.get(j);return E?s.jsx(f1,{tokens:E}):s.jsx(s.Fragment,{children:v.content||" "})})()})]},v.id)})}),!r&&x&&s.jsxs("div",{className:R("text-center text-xs py-2 border-t border-emerald-500/20",k.text.muted,"bg-stone-50/50 dark:bg-zinc-950/50"),children:["+",y," more lines"]})]})}const x1=Object.freeze(Object.defineProperty({__proto__:null,DiffViewer:su},Symbol.toStringTag,{value:"Module"}));function Is(t){const e=u.useRef(t);return u.useEffect(()=>{e.current=t}),u.useMemo(()=>(...n)=>e.current?.(...n),[])}function b1(t,e=globalThis?.document){const n=Is(t);u.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}var y1="DismissableLayer",ta="dismissableLayer.update",v1="dismissableLayer.pointerDownOutside",w1="dismissableLayer.focusOutside",yc,nu=u.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Nr=u.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:i,onDismiss:l,...c}=t,d=u.useContext(nu),[p,m]=u.useState(null),h=p?.ownerDocument??globalThis?.document,[,g]=u.useState({}),f=dt(e,C=>m(C)),x=Array.from(d.layers),[b]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),y=x.indexOf(b),v=p?x.indexOf(p):-1,w=d.layersWithOutsidePointerEventsDisabled.size>0,N=v>=y,S=j1(C=>{const j=C.target,E=[...d.branches].some(A=>A.contains(j));!N||E||(o?.(C),i?.(C),C.defaultPrevented||l?.())},h),T=N1(C=>{const j=C.target;[...d.branches].some(A=>A.contains(j))||(a?.(C),i?.(C),C.defaultPrevented||l?.())},h);return b1(C=>{v===d.layers.size-1&&(r?.(C),!C.defaultPrevented&&l&&(C.preventDefault(),l()))},h),u.useEffect(()=>{if(p)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(yc=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(p)),d.layers.add(p),vc(),()=>{n&&d.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=yc)}},[p,h,n,d]),u.useEffect(()=>()=>{p&&(d.layers.delete(p),d.layersWithOutsidePointerEventsDisabled.delete(p),vc())},[p,d]),u.useEffect(()=>{const C=()=>g({});return document.addEventListener(ta,C),()=>document.removeEventListener(ta,C)},[]),s.jsx(st.div,{...c,ref:f,style:{pointerEvents:w?N?"auto":"none":void 0,...t.style},onFocusCapture:He(t.onFocusCapture,T.onFocusCapture),onBlurCapture:He(t.onBlurCapture,T.onBlurCapture),onPointerDownCapture:He(t.onPointerDownCapture,S.onPointerDownCapture)})});Nr.displayName=y1;var _1="DismissableLayerBranch",k1=u.forwardRef((t,e)=>{const n=u.useContext(nu),r=u.useRef(null),o=dt(e,r);return u.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),s.jsx(st.div,{...t,ref:o})});k1.displayName=_1;function j1(t,e=globalThis?.document){const n=Is(t),r=u.useRef(!1),o=u.useRef(()=>{});return u.useEffect(()=>{const a=l=>{if(l.target&&!r.current){let c=function(){ru(v1,n,d,{discrete:!0})};const d={originalEvent:l};l.pointerType==="touch"?(e.removeEventListener("click",o.current),o.current=c,e.addEventListener("click",o.current,{once:!0})):c()}else e.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{e.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),e.removeEventListener("pointerdown",a),e.removeEventListener("click",o.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function N1(t,e=globalThis?.document){const n=Is(t),r=u.useRef(!1);return u.useEffect(()=>{const o=a=>{a.target&&!r.current&&ru(w1,n,{originalEvent:a},{discrete:!1})};return e.addEventListener("focusin",o),()=>e.removeEventListener("focusin",o)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function vc(){const t=new CustomEvent(ta);document.dispatchEvent(t)}function ru(t,e,n,{discrete:r}){const o=n.originalEvent.target,a=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&o.addEventListener(t,e,{once:!0}),r?Ym(o,a):o.dispatchEvent(a)}var so="focusScope.autoFocusOnMount",no="focusScope.autoFocusOnUnmount",wc={bubbles:!1,cancelable:!0},S1="FocusScope",Wa=u.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...i}=t,[l,c]=u.useState(null),d=Is(o),p=Is(a),m=u.useRef(null),h=dt(e,x=>c(x)),g=u.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;u.useEffect(()=>{if(r){let x=function(w){if(g.paused||!l)return;const N=w.target;l.contains(N)?m.current=N:Ft(m.current,{select:!0})},b=function(w){if(g.paused||!l)return;const N=w.relatedTarget;N!==null&&(l.contains(N)||Ft(m.current,{select:!0}))},y=function(w){if(document.activeElement===document.body)for(const S of w)S.removedNodes.length>0&&Ft(l)};document.addEventListener("focusin",x),document.addEventListener("focusout",b);const v=new MutationObserver(y);return l&&v.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",b),v.disconnect()}}},[r,l,g.paused]),u.useEffect(()=>{if(l){kc.add(g);const x=document.activeElement;if(!l.contains(x)){const y=new CustomEvent(so,wc);l.addEventListener(so,d),l.dispatchEvent(y),y.defaultPrevented||(C1(R1(ou(l)),{select:!0}),document.activeElement===x&&Ft(l))}return()=>{l.removeEventListener(so,d),setTimeout(()=>{const y=new CustomEvent(no,wc);l.addEventListener(no,p),l.dispatchEvent(y),y.defaultPrevented||Ft(x??document.body,{select:!0}),l.removeEventListener(no,p),kc.remove(g)},0)}}},[l,d,p,g]);const f=u.useCallback(x=>{if(!n&&!r||g.paused)return;const b=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,y=document.activeElement;if(b&&y){const v=x.currentTarget,[w,N]=E1(v);w&&N?!x.shiftKey&&y===N?(x.preventDefault(),n&&Ft(w,{select:!0})):x.shiftKey&&y===w&&(x.preventDefault(),n&&Ft(N,{select:!0})):y===v&&x.preventDefault()}},[n,r,g.paused]);return s.jsx(st.div,{tabIndex:-1,...i,ref:h,onKeyDown:f})});Wa.displayName=S1;function C1(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(Ft(r,{select:e}),document.activeElement!==n)return}function E1(t){const e=ou(t),n=_c(e,t),r=_c(e.reverse(),t);return[n,r]}function ou(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function _c(t,e){for(const n of t)if(!T1(n,{upTo:e}))return n}function T1(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function I1(t){return t instanceof HTMLInputElement&&"select"in t}function Ft(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&I1(t)&&e&&t.select()}}var kc=A1();function A1(){let t=[];return{add(e){const n=t[0];e!==n&&n?.pause(),t=jc(t,e),t.unshift(e)},remove(e){t=jc(t,e),t[0]?.resume()}}}function jc(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function R1(t){return t.filter(e=>e.tagName!=="A")}var P1="Portal",Sr=u.forwardRef((t,e)=>{const{container:n,...r}=t,[o,a]=u.useState(!1);Wn(()=>a(!0),[]);const i=n||o&&globalThis?.document?.body;return i?Am.createPortal(s.jsx(st.div,{...r,ref:e}),i):null});Sr.displayName=P1;var ro=0;function au(){u.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??Nc()),document.body.insertAdjacentElement("beforeend",t[1]??Nc()),ro++,()=>{ro===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),ro--}},[])}function Nc(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var wt=function(){return wt=Object.assign||function(e){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},wt.apply(this,arguments)};function iu(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]]);return n}function M1(t,e,n){if(n||arguments.length===2)for(var r=0,o=e.length,a;r<o;r++)(a||!(r in e))&&(a||(a=Array.prototype.slice.call(e,0,r)),a[r]=e[r]);return t.concat(a||Array.prototype.slice.call(e))}var Hn="right-scroll-bar-position",qn="width-before-scroll-bar",L1="with-scroll-bars-hidden",O1="--removed-body-scroll-bar-size";function oo(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function D1(t,e){var n=u.useState(function(){return{value:t,callback:e,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=e,n.facade}var $1=typeof window<"u"?u.useLayoutEffect:u.useEffect,Sc=new WeakMap;function z1(t,e){var n=D1(null,function(r){return t.forEach(function(o){return oo(o,r)})});return $1(function(){var r=Sc.get(n);if(r){var o=new Set(r),a=new Set(t),i=n.current;o.forEach(function(l){a.has(l)||oo(l,null)}),a.forEach(function(l){o.has(l)||oo(l,i)})}Sc.set(n,t)},[t]),n}function F1(t){return t}function V1(t,e){e===void 0&&(e=F1);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:t},useMedium:function(a){var i=e(a,r);return n.push(i),function(){n=n.filter(function(l){return l!==i})}},assignSyncMedium:function(a){for(r=!0;n.length;){var i=n;n=[],i.forEach(a)}n={push:function(l){return a(l)},filter:function(){return n}}},assignMedium:function(a){r=!0;var i=[];if(n.length){var l=n;n=[],l.forEach(a),i=n}var c=function(){var p=i;i=[],p.forEach(a)},d=function(){return Promise.resolve().then(c)};d(),n={push:function(p){i.push(p),d()},filter:function(p){return i=i.filter(p),n}}}};return o}function B1(t){t===void 0&&(t={});var e=V1(null);return e.options=wt({async:!0,ssr:!1},t),e}var cu=function(t){var e=t.sideCar,n=iu(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=e.read();if(!r)throw new Error("Sidecar medium not found");return u.createElement(r,wt({},n))};cu.isSideCarExport=!0;function U1(t,e){return t.useMedium(e),cu}var lu=B1(),ao=function(){},Cr=u.forwardRef(function(t,e){var n=u.useRef(null),r=u.useState({onScrollCapture:ao,onWheelCapture:ao,onTouchMoveCapture:ao}),o=r[0],a=r[1],i=t.forwardProps,l=t.children,c=t.className,d=t.removeScrollBar,p=t.enabled,m=t.shards,h=t.sideCar,g=t.noRelative,f=t.noIsolation,x=t.inert,b=t.allowPinchZoom,y=t.as,v=y===void 0?"div":y,w=t.gapMode,N=iu(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=h,T=z1([n,e]),C=wt(wt({},N),o);return u.createElement(u.Fragment,null,p&&u.createElement(S,{sideCar:lu,removeScrollBar:d,shards:m,noRelative:g,noIsolation:f,inert:x,setCallbacks:a,allowPinchZoom:!!b,lockRef:n,gapMode:w}),i?u.cloneElement(u.Children.only(l),wt(wt({},C),{ref:T})):u.createElement(v,wt({},C,{className:c,ref:T}),l))});Cr.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Cr.classNames={fullWidth:qn,zeroRight:Hn};var G1=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function H1(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=G1();return e&&t.setAttribute("nonce",e),t}function q1(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function W1(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var K1=function(){var t=0,e=null;return{add:function(n){t==0&&(e=H1())&&(q1(e,n),W1(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},Q1=function(){var t=K1();return function(e,n){u.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},du=function(){var t=Q1(),e=function(n){var r=n.styles,o=n.dynamic;return t(r,o),null};return e},Y1={left:0,top:0,right:0,gap:0},io=function(t){return parseInt(t||"",10)||0},J1=function(t){var e=window.getComputedStyle(document.body),n=e[t==="padding"?"paddingLeft":"marginLeft"],r=e[t==="padding"?"paddingTop":"marginTop"],o=e[t==="padding"?"paddingRight":"marginRight"];return[io(n),io(r),io(o)]},X1=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return Y1;var e=J1(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-n+e[2]-e[0])}},Z1=du(),Ss="data-scroll-locked",ew=function(t,e,n,r){var o=t.left,a=t.top,i=t.right,l=t.gap;return n===void 0&&(n="margin"),`
|
|
82
82
|
.`.concat(L1,` {
|
|
83
83
|
overflow: hidden `).concat(r,`;
|
|
84
84
|
padding-right: `).concat(l,"px ").concat(r,`;
|
|
@@ -118,21 +118,21 @@ import{j as s,r as u,b as Te,c as Am,u as Rm,o as Pm,s as Mm,f as Lm,d as Om,e a
|
|
|
118
118
|
`)},Cc=function(){var t=parseInt(document.body.getAttribute(Ss)||"0",10);return isFinite(t)?t:0},tw=function(){u.useEffect(function(){return document.body.setAttribute(Ss,(Cc()+1).toString()),function(){var t=Cc()-1;t<=0?document.body.removeAttribute(Ss):document.body.setAttribute(Ss,t.toString())}},[])},sw=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,o=r===void 0?"margin":r;tw();var a=u.useMemo(function(){return X1(o)},[o]);return u.createElement(Z1,{styles:ew(a,!e,o,n?"":"!important")})},sa=!1;if(typeof window<"u")try{var In=Object.defineProperty({},"passive",{get:function(){return sa=!0,!0}});window.addEventListener("test",In,In),window.removeEventListener("test",In,In)}catch{sa=!1}var xs=sa?{passive:!1}:!1,nw=function(t){return t.tagName==="TEXTAREA"},uu=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!nw(t)&&n[e]==="visible")},rw=function(t){return uu(t,"overflowY")},ow=function(t){return uu(t,"overflowX")},Ec=function(t,e){var n=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=pu(t,r);if(o){var a=mu(t,r),i=a[1],l=a[2];if(i>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},aw=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},iw=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},pu=function(t,e){return t==="v"?rw(e):ow(e)},mu=function(t,e){return t==="v"?aw(e):iw(e)},cw=function(t,e){return t==="h"&&e==="rtl"?-1:1},lw=function(t,e,n,r,o){var a=cw(t,window.getComputedStyle(e).direction),i=a*r,l=n.target,c=e.contains(l),d=!1,p=i>0,m=0,h=0;do{if(!l)break;var g=mu(t,l),f=g[0],x=g[1],b=g[2],y=x-b-a*f;(f||y)&&pu(t,l)&&(m+=y,h+=f);var v=l.parentNode;l=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!c&&l!==document.body||c&&(e.contains(l)||e===l));return(p&&Math.abs(m)<1||!p&&Math.abs(h)<1)&&(d=!0),d},An=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},Tc=function(t){return[t.deltaX,t.deltaY]},Ic=function(t){return t&&"current"in t?t.current:t},dw=function(t,e){return t[0]===e[0]&&t[1]===e[1]},uw=function(t){return`
|
|
119
119
|
.block-interactivity-`.concat(t,` {pointer-events: none;}
|
|
120
120
|
.allow-interactivity-`).concat(t,` {pointer-events: all;}
|
|
121
|
-
`)},pw=0,bs=[];function mw(t){var e=u.useRef([]),n=u.useRef([0,0]),r=u.useRef(),o=u.useState(pw++)[0],a=u.useState(du)[0],i=u.useRef(t);u.useEffect(function(){i.current=t},[t]),u.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(o));var x=M1([t.lockRef.current],(t.shards||[]).map(Ic),!0).filter(Boolean);return x.forEach(function(b){return b.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),x.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(o))})}}},[t.inert,t.lockRef.current,t.shards]);var l=u.useCallback(function(x,b){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!i.current.allowPinchZoom;var y=An(x),v=n.current,w="deltaX"in x?x.deltaX:v[0]-y[0],N="deltaY"in x?x.deltaY:v[1]-y[1],S,T=x.target,C=Math.abs(w)>Math.abs(N)?"h":"v";if("touches"in x&&C==="h"&&T.type==="range")return!1;var j=window.getSelection(),E=j&&j.anchorNode,
|
|
121
|
+
`)},pw=0,bs=[];function mw(t){var e=u.useRef([]),n=u.useRef([0,0]),r=u.useRef(),o=u.useState(pw++)[0],a=u.useState(du)[0],i=u.useRef(t);u.useEffect(function(){i.current=t},[t]),u.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(o));var x=M1([t.lockRef.current],(t.shards||[]).map(Ic),!0).filter(Boolean);return x.forEach(function(b){return b.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),x.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(o))})}}},[t.inert,t.lockRef.current,t.shards]);var l=u.useCallback(function(x,b){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!i.current.allowPinchZoom;var y=An(x),v=n.current,w="deltaX"in x?x.deltaX:v[0]-y[0],N="deltaY"in x?x.deltaY:v[1]-y[1],S,T=x.target,C=Math.abs(w)>Math.abs(N)?"h":"v";if("touches"in x&&C==="h"&&T.type==="range")return!1;var j=window.getSelection(),E=j&&j.anchorNode,A=E?E===T||E.contains(T):!1;if(A)return!1;var L=Ec(C,T);if(!L)return!0;if(L?S=C:(S=C==="v"?"h":"v",L=Ec(C,T)),!L)return!1;if(!r.current&&"changedTouches"in x&&(w||N)&&(r.current=S),!S)return!0;var $=r.current||S;return lw($,b,x,$==="h"?w:N)},[]),c=u.useCallback(function(x){var b=x;if(!(!bs.length||bs[bs.length-1]!==a)){var y="deltaY"in b?Tc(b):An(b),v=e.current.filter(function(S){return S.name===b.type&&(S.target===b.target||b.target===S.shadowParent)&&dw(S.delta,y)})[0];if(v&&v.should){b.cancelable&&b.preventDefault();return}if(!v){var w=(i.current.shards||[]).map(Ic).filter(Boolean).filter(function(S){return S.contains(b.target)}),N=w.length>0?l(b,w[0]):!i.current.noIsolation;N&&b.cancelable&&b.preventDefault()}}},[]),d=u.useCallback(function(x,b,y,v){var w={name:x,delta:b,target:y,should:v,shadowParent:hw(y)};e.current.push(w),setTimeout(function(){e.current=e.current.filter(function(N){return N!==w})},1)},[]),p=u.useCallback(function(x){n.current=An(x),r.current=void 0},[]),m=u.useCallback(function(x){d(x.type,Tc(x),x.target,l(x,t.lockRef.current))},[]),h=u.useCallback(function(x){d(x.type,An(x),x.target,l(x,t.lockRef.current))},[]);u.useEffect(function(){return bs.push(a),t.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:h}),document.addEventListener("wheel",c,xs),document.addEventListener("touchmove",c,xs),document.addEventListener("touchstart",p,xs),function(){bs=bs.filter(function(x){return x!==a}),document.removeEventListener("wheel",c,xs),document.removeEventListener("touchmove",c,xs),document.removeEventListener("touchstart",p,xs)}},[]);var g=t.removeScrollBar,f=t.inert;return u.createElement(u.Fragment,null,f?u.createElement(a,{styles:uw(o)}):null,g?u.createElement(sw,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function hw(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const fw=U1(lu,mw);var Ka=u.forwardRef(function(t,e){return u.createElement(Cr,wt({},t,{ref:e,sideCar:fw}))});Ka.classNames=Cr.classNames;var gw=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},ys=new WeakMap,Rn=new WeakMap,Pn={},co=0,hu=function(t){return t&&(t.host||hu(t.parentNode))},xw=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=hu(n);return r&&t.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},bw=function(t,e,n,r){var o=xw(e,Array.isArray(t)?t:[t]);Pn[n]||(Pn[n]=new WeakMap);var a=Pn[n],i=[],l=new Set,c=new Set(o),d=function(m){!m||l.has(m)||(l.add(m),d(m.parentNode))};o.forEach(d);var p=function(m){!m||c.has(m)||Array.prototype.forEach.call(m.children,function(h){if(l.has(h))p(h);else try{var g=h.getAttribute(r),f=g!==null&&g!=="false",x=(ys.get(h)||0)+1,b=(a.get(h)||0)+1;ys.set(h,x),a.set(h,b),i.push(h),x===1&&f&&Rn.set(h,!0),b===1&&h.setAttribute(n,"true"),f||h.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",h,y)}})};return p(e),l.clear(),co++,function(){i.forEach(function(m){var h=ys.get(m)-1,g=a.get(m)-1;ys.set(m,h),a.set(m,g),h||(Rn.has(m)||m.removeAttribute(r),Rn.delete(m)),g||m.removeAttribute(n)}),co--,co||(ys=new WeakMap,ys=new WeakMap,Rn=new WeakMap,Pn={})}},fu=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),o=gw(t);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),bw(r,o,n,"aria-hidden")):function(){return null}},Er="Dialog",[gu]=pr(Er),[yw,ft]=gu(Er),xu=t=>{const{__scopeDialog:e,children:n,open:r,defaultOpen:o,onOpenChange:a,modal:i=!0}=t,l=u.useRef(null),c=u.useRef(null),[d,p]=ba({prop:r,defaultProp:o??!1,onChange:a,caller:Er});return s.jsx(yw,{scope:e,triggerRef:l,contentRef:c,contentId:Ys(),titleId:Ys(),descriptionId:Ys(),open:d,onOpenChange:p,onOpenToggle:u.useCallback(()=>p(m=>!m),[p]),modal:i,children:n})};xu.displayName=Er;var bu="DialogTrigger",vw=u.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,o=ft(bu,n),a=dt(e,o.triggerRef);return s.jsx(st.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Ja(o.open),...r,ref:a,onClick:He(t.onClick,o.onOpenToggle)})});vw.displayName=bu;var Qa="DialogPortal",[ww,yu]=gu(Qa,{forceMount:void 0}),vu=t=>{const{__scopeDialog:e,forceMount:n,children:r,container:o}=t,a=ft(Qa,e);return s.jsx(ww,{scope:e,forceMount:n,children:u.Children.map(r,i=>s.jsx(ls,{present:n||a.open,children:s.jsx(Sr,{asChild:!0,container:o,children:i})}))})};vu.displayName=Qa;var cr="DialogOverlay",wu=u.forwardRef((t,e)=>{const n=yu(cr,t.__scopeDialog),{forceMount:r=n.forceMount,...o}=t,a=ft(cr,t.__scopeDialog);return a.modal?s.jsx(ls,{present:r||a.open,children:s.jsx(kw,{...o,ref:e})}):null});wu.displayName=cr;var _w=Vl("DialogOverlay.RemoveScroll"),kw=u.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,o=ft(cr,n);return s.jsx(Ka,{as:_w,allowPinchZoom:!0,shards:[o.contentRef],children:s.jsx(st.div,{"data-state":Ja(o.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),cs="DialogContent",_u=u.forwardRef((t,e)=>{const n=yu(cs,t.__scopeDialog),{forceMount:r=n.forceMount,...o}=t,a=ft(cs,t.__scopeDialog);return s.jsx(ls,{present:r||a.open,children:a.modal?s.jsx(jw,{...o,ref:e}):s.jsx(Nw,{...o,ref:e})})});_u.displayName=cs;var jw=u.forwardRef((t,e)=>{const n=ft(cs,t.__scopeDialog),r=u.useRef(null),o=dt(e,n.contentRef,r);return u.useEffect(()=>{const a=r.current;if(a)return fu(a)},[]),s.jsx(ku,{...t,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:He(t.onCloseAutoFocus,a=>{a.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:He(t.onPointerDownOutside,a=>{const i=a.detail.originalEvent,l=i.button===0&&i.ctrlKey===!0;(i.button===2||l)&&a.preventDefault()}),onFocusOutside:He(t.onFocusOutside,a=>a.preventDefault())})}),Nw=u.forwardRef((t,e)=>{const n=ft(cs,t.__scopeDialog),r=u.useRef(!1),o=u.useRef(!1);return s.jsx(ku,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{t.onCloseAutoFocus?.(a),a.defaultPrevented||(r.current||n.triggerRef.current?.focus(),a.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:a=>{t.onInteractOutside?.(a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=a.target;n.triggerRef.current?.contains(i)&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),ku=u.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,...i}=t,l=ft(cs,n),c=u.useRef(null),d=dt(e,c);return au(),s.jsxs(s.Fragment,{children:[s.jsx(Wa,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:s.jsx(Nr,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":Ja(l.open),...i,ref:d,onDismiss:()=>l.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(Sw,{titleId:l.titleId}),s.jsx(Ew,{contentRef:c,descriptionId:l.descriptionId})]})]})}),Ya="DialogTitle",ju=u.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,o=ft(Ya,n);return s.jsx(st.h2,{id:o.titleId,...r,ref:e})});ju.displayName=Ya;var Nu="DialogDescription",Su=u.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,o=ft(Nu,n);return s.jsx(st.p,{id:o.descriptionId,...r,ref:e})});Su.displayName=Nu;var Cu="DialogClose",Eu=u.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,o=ft(Cu,n);return s.jsx(st.button,{type:"button",...r,ref:e,onClick:He(t.onClick,()=>o.onOpenChange(!1))})});Eu.displayName=Cu;function Ja(t){return t?"open":"closed"}var Tu="DialogTitleWarning",[nC,Iu]=Jm(Tu,{contentName:cs,titleName:Ya,docsSlug:"dialog"}),Sw=({titleId:t})=>{const e=Iu(Tu),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
|
|
122
122
|
|
|
123
123
|
If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
124
124
|
|
|
125
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return u.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},Cw="DialogDescriptionWarning",Ew=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Iu(Cw).contentName}}.`;return u.useEffect(()=>{const o=t.current?.getAttribute("aria-describedby");e&&o&&(document.getElementById(e)||console.warn(r))},[r,t,e]),null},Tw=xu,Iw=vu,Au=wu,Ru=_u,Aw=ju,Rw=Su,Pw=Eu;const Mw=Tw,Lw=Iw,Pu=u.forwardRef(({className:t,...e},n)=>s.jsx(Au,{ref:n,className:M("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e}));Pu.displayName=Au.displayName;const Mu=u.forwardRef(({className:t,children:e,...n},r)=>s.jsxs(Lw,{children:[s.jsx(Pu,{}),s.jsxs(Ru,{ref:r,className:M("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 rounded-lg border p-6 shadow-lg duration-200","bg-composer-surface border-composer-border","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]",t),...n,children:[e,s.jsxs(Pw,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-composer-surface transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-composer-active focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-composer-active/10 data-[state=open]:text-composer-text-secondary",children:[s.jsx(yr,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Mu.displayName=Ru.displayName;function Ow({className:t,...e}){return s.jsx("div",{className:M("flex flex-col space-y-1.5 text-center sm:text-left",t),...e})}function Dw({className:t,ref:e,...n}){return s.jsx(Aw,{ref:e,className:M("text-lg font-semibold leading-none tracking-tight text-composer-text",t),...n})}function $w({className:t,ref:e,...n}){return s.jsx(Rw,{ref:e,className:M("text-sm text-composer-text-secondary",t),...n})}var zw="Arrow",Lu=u.forwardRef((t,e)=>{const{children:n,width:r=10,height:o=5,...a}=t;return s.jsx(st.svg,{...a,ref:e,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:s.jsx("polygon",{points:"0,0 30,0 15,10"})})});Lu.displayName=zw;var Fw=Lu;function Vw(t){const[e,n]=u.useState(void 0);return Wn(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const a=o[0];let i,l;if("borderBoxSize"in a){const c=a.borderBoxSize,d=Array.isArray(c)?c[0]:c;i=d.inlineSize,l=d.blockSize}else i=t.offsetWidth,l=t.offsetHeight;n({width:i,height:l})});return r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),e}var Xa="Popper",[Ou,Tr]=pr(Xa),[Bw,Du]=Ou(Xa),$u=t=>{const{__scopePopper:e,children:n}=t,[r,o]=u.useState(null);return s.jsx(Bw,{scope:e,anchor:r,onAnchorChange:o,children:n})};$u.displayName=Xa;var zu="PopperAnchor",Fu=u.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...o}=t,a=Du(zu,n),i=u.useRef(null),l=dt(e,i),c=u.useRef(null);return u.useEffect(()=>{const d=c.current;c.current=r?.current||i.current,d!==c.current&&a.onAnchorChange(c.current)}),r?null:s.jsx(st.div,{...o,ref:l})});Fu.displayName=zu;var Za="PopperContent",[Uw,Gw]=Ou(Za),Vu=u.forwardRef((t,e)=>{const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:a="center",alignOffset:i=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:p=0,sticky:m="partial",hideWhenDetached:h=!1,updatePositionStrategy:g="optimized",onPlaced:f,...x}=t,b=Du(Za,n),[y,v]=u.useState(null),w=dt(e,xe=>v(xe)),[N,S]=u.useState(null),T=Vw(N),C=T?.width??0,j=T?.height??0,E=r+(a!=="center"?"-"+a:""),R=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},O=Array.isArray(d)?d:[d],$=O.length>0,re={padding:R,boundary:O.filter(qw),altBoundary:$},{refs:ne,floatingStyles:V,placement:X,isPositioned:q,middlewareData:K}=Rm({strategy:"fixed",placement:E,whileElementsMounted:(...xe)=>zm(...xe,{animationFrame:g==="always"}),elements:{reference:b.anchor},middleware:[Pm({mainAxis:o+j,alignmentAxis:i}),c&&Mm({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?Fm():void 0,...re}),c&&Lm({...re}),Om({...re,apply:({elements:xe,rects:_e,availableWidth:A,availableHeight:P})=>{const{width:le,height:J}=_e.reference,H=xe.floating.style;H.setProperty("--radix-popper-available-width",`${A}px`),H.setProperty("--radix-popper-available-height",`${P}px`),H.setProperty("--radix-popper-anchor-width",`${le}px`),H.setProperty("--radix-popper-anchor-height",`${J}px`)}}),N&&Dm({element:N,padding:l}),Ww({arrowWidth:C,arrowHeight:j}),h&&$m({strategy:"referenceHidden",...re})]}),[ge,D]=Gu(X),W=Is(f);Wn(()=>{q&&W?.()},[q,W]);const Z=K.arrow?.x,F=K.arrow?.y,se=K.arrow?.centerOffset!==0,[ee,te]=u.useState();return Wn(()=>{y&&te(window.getComputedStyle(y).zIndex)},[y]),s.jsx("div",{ref:ne.setFloating,"data-radix-popper-content-wrapper":"",style:{...V,transform:q?V.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ee,"--radix-popper-transform-origin":[K.transformOrigin?.x,K.transformOrigin?.y].join(" "),...K.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:s.jsx(Uw,{scope:n,placedSide:ge,onArrowChange:S,arrowX:Z,arrowY:F,shouldHideArrow:se,children:s.jsx(st.div,{"data-side":ge,"data-align":D,...x,ref:w,style:{...x.style,animation:q?void 0:"none"}})})})});Vu.displayName=Za;var Bu="PopperArrow",Hw={top:"bottom",right:"left",bottom:"top",left:"right"},Uu=u.forwardRef(function(e,n){const{__scopePopper:r,...o}=e,a=Gw(Bu,r),i=Hw[a.placedSide];return s.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:s.jsx(Fw,{...o,ref:n,style:{...o.style,display:"block"}})})});Uu.displayName=Bu;function qw(t){return t!==null}var Ww=t=>({name:"transformOrigin",options:t,fn(e){const{placement:n,rects:r,middlewareData:o}=e,i=o.arrow?.centerOffset!==0,l=i?0:t.arrowWidth,c=i?0:t.arrowHeight,[d,p]=Gu(n),m={start:"0%",center:"50%",end:"100%"}[p],h=(o.arrow?.x??0)+l/2,g=(o.arrow?.y??0)+c/2;let f="",x="";return d==="bottom"?(f=i?m:`${h}px`,x=`${-c}px`):d==="top"?(f=i?m:`${h}px`,x=`${r.floating.height+c}px`):d==="right"?(f=`${-c}px`,x=i?m:`${g}px`):d==="left"&&(f=`${r.floating.width+c}px`,x=i?m:`${g}px`),{data:{x:f,y:x}}}});function Gu(t){const[e,n="center"]=t.split("-");return[e,n]}var Hu=$u,ei=Fu,qu=Vu,Wu=Uu,Kw=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Qw="VisuallyHidden",Ku=u.forwardRef((t,e)=>s.jsx(st.span,{...t,ref:e,style:{...Kw,...t.style}}));Ku.displayName=Qw;var Yw=Ku,[Ir]=pr("Tooltip",[Tr]),Ar=Tr(),Qu="TooltipProvider",Jw=700,na="tooltip.open",[Xw,ti]=Ir(Qu),Yu=t=>{const{__scopeTooltip:e,delayDuration:n=Jw,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:a}=t,i=u.useRef(!0),l=u.useRef(!1),c=u.useRef(0);return u.useEffect(()=>{const d=c.current;return()=>window.clearTimeout(d)},[]),s.jsx(Xw,{scope:e,isOpenDelayedRef:i,delayDuration:n,onOpen:u.useCallback(()=>{window.clearTimeout(c.current),i.current=!1},[]),onClose:u.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:u.useCallback(d=>{l.current=d},[]),disableHoverableContent:o,children:a})};Yu.displayName=Qu;var un="Tooltip",[Zw,xn]=Ir(un),Ju=t=>{const{__scopeTooltip:e,children:n,open:r,defaultOpen:o,onOpenChange:a,disableHoverableContent:i,delayDuration:l}=t,c=ti(un,t.__scopeTooltip),d=Ar(e),[p,m]=u.useState(null),h=Ys(),g=u.useRef(0),f=i??c.disableHoverableContent,x=l??c.delayDuration,b=u.useRef(!1),[y,v]=ba({prop:r,defaultProp:o??!1,onChange:C=>{C?(c.onOpen(),document.dispatchEvent(new CustomEvent(na))):c.onClose(),a?.(C)},caller:un}),w=u.useMemo(()=>y?b.current?"delayed-open":"instant-open":"closed",[y]),N=u.useCallback(()=>{window.clearTimeout(g.current),g.current=0,b.current=!1,v(!0)},[v]),S=u.useCallback(()=>{window.clearTimeout(g.current),g.current=0,v(!1)},[v]),T=u.useCallback(()=>{window.clearTimeout(g.current),g.current=window.setTimeout(()=>{b.current=!0,v(!0),g.current=0},x)},[x,v]);return u.useEffect(()=>()=>{g.current&&(window.clearTimeout(g.current),g.current=0)},[]),s.jsx(Hu,{...d,children:s.jsx(Zw,{scope:e,contentId:h,open:y,stateAttribute:w,trigger:p,onTriggerChange:m,onTriggerEnter:u.useCallback(()=>{c.isOpenDelayedRef.current?T():N()},[c.isOpenDelayedRef,T,N]),onTriggerLeave:u.useCallback(()=>{f?S():(window.clearTimeout(g.current),g.current=0)},[S,f]),onOpen:N,onClose:S,disableHoverableContent:f,children:n})})};Ju.displayName=un;var ra="TooltipTrigger",Xu=u.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,o=xn(ra,n),a=ti(ra,n),i=Ar(n),l=u.useRef(null),c=dt(e,l,o.onTriggerChange),d=u.useRef(!1),p=u.useRef(!1),m=u.useCallback(()=>d.current=!1,[]);return u.useEffect(()=>()=>document.removeEventListener("pointerup",m),[m]),s.jsx(ei,{asChild:!0,...i,children:s.jsx(st.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:c,onPointerMove:He(t.onPointerMove,h=>{h.pointerType!=="touch"&&!p.current&&!a.isPointerInTransitRef.current&&(o.onTriggerEnter(),p.current=!0)}),onPointerLeave:He(t.onPointerLeave,()=>{o.onTriggerLeave(),p.current=!1}),onPointerDown:He(t.onPointerDown,()=>{o.open&&o.onClose(),d.current=!0,document.addEventListener("pointerup",m,{once:!0})}),onFocus:He(t.onFocus,()=>{d.current||o.onOpen()}),onBlur:He(t.onBlur,o.onClose),onClick:He(t.onClick,o.onClose)})})});Xu.displayName=ra;var si="TooltipPortal",[e_,t_]=Ir(si,{forceMount:void 0}),Zu=t=>{const{__scopeTooltip:e,forceMount:n,children:r,container:o}=t,a=xn(si,e);return s.jsx(e_,{scope:e,forceMount:n,children:s.jsx(ls,{present:n||a.open,children:s.jsx(Sr,{asChild:!0,container:o,children:r})})})};Zu.displayName=si;var As="TooltipContent",ep=u.forwardRef((t,e)=>{const n=t_(As,t.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...a}=t,i=xn(As,t.__scopeTooltip);return s.jsx(ls,{present:r||i.open,children:i.disableHoverableContent?s.jsx(tp,{side:o,...a,ref:e}):s.jsx(s_,{side:o,...a,ref:e})})}),s_=u.forwardRef((t,e)=>{const n=xn(As,t.__scopeTooltip),r=ti(As,t.__scopeTooltip),o=u.useRef(null),a=dt(e,o),[i,l]=u.useState(null),{trigger:c,onClose:d}=n,p=o.current,{onPointerInTransitChange:m}=r,h=u.useCallback(()=>{l(null),m(!1)},[m]),g=u.useCallback((f,x)=>{const b=f.currentTarget,y={x:f.clientX,y:f.clientY},v=i_(y,b.getBoundingClientRect()),w=c_(y,v),N=l_(x.getBoundingClientRect()),S=u_([...w,...N]);l(S),m(!0)},[m]);return u.useEffect(()=>()=>h(),[h]),u.useEffect(()=>{if(c&&p){const f=b=>g(b,p),x=b=>g(b,c);return c.addEventListener("pointerleave",f),p.addEventListener("pointerleave",x),()=>{c.removeEventListener("pointerleave",f),p.removeEventListener("pointerleave",x)}}},[c,p,g,h]),u.useEffect(()=>{if(i){const f=x=>{const b=x.target,y={x:x.clientX,y:x.clientY},v=c?.contains(b)||p?.contains(b),w=!d_(y,i);v?h():w&&(h(),d())};return document.addEventListener("pointermove",f),()=>document.removeEventListener("pointermove",f)}},[c,p,i,d,h]),s.jsx(tp,{...t,ref:a})}),[n_,r_]=Ir(un,{isInside:!1}),o_=Xm("TooltipContent"),tp=u.forwardRef((t,e)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:a,onPointerDownOutside:i,...l}=t,c=xn(As,n),d=Ar(n),{onClose:p}=c;return u.useEffect(()=>(document.addEventListener(na,p),()=>document.removeEventListener(na,p)),[p]),u.useEffect(()=>{if(c.trigger){const m=h=>{h.target?.contains(c.trigger)&&p()};return window.addEventListener("scroll",m,{capture:!0}),()=>window.removeEventListener("scroll",m,{capture:!0})}},[c.trigger,p]),s.jsx(Nr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:m=>m.preventDefault(),onDismiss:p,children:s.jsxs(qu,{"data-state":c.stateAttribute,...d,...l,ref:e,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[s.jsx(o_,{children:r}),s.jsx(n_,{scope:n,isInside:!0,children:s.jsx(Yw,{id:c.contentId,role:"tooltip",children:o||r})})]})})});ep.displayName=As;var sp="TooltipArrow",a_=u.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,o=Ar(n);return r_(sp,n).isInside?null:s.jsx(Wu,{...o,...r,ref:e})});a_.displayName=sp;function i_(t,e){const n=Math.abs(e.top-t.y),r=Math.abs(e.bottom-t.y),o=Math.abs(e.right-t.x),a=Math.abs(e.left-t.x);switch(Math.min(n,r,o,a)){case a:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function c_(t,e,n=5){const r=[];switch(e){case"top":r.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":r.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":r.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":r.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return r}function l_(t){const{top:e,right:n,bottom:r,left:o}=t;return[{x:o,y:e},{x:n,y:e},{x:n,y:r},{x:o,y:r}]}function d_(t,e){const{x:n,y:r}=t;let o=!1;for(let a=0,i=e.length-1;a<e.length;i=a++){const l=e[a],c=e[i],d=l.x,p=l.y,m=c.x,h=c.y;p>r!=h>r&&n<(m-d)*(r-p)/(h-p)+d&&(o=!o)}return o}function u_(t){const e=t.slice();return e.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),p_(e)}function p_(t){if(t.length<=1)return t.slice();const e=[];for(let r=0;r<t.length;r++){const o=t[r];for(;e.length>=2;){const a=e[e.length-1],i=e[e.length-2];if((a.x-i.x)*(o.y-i.y)>=(a.y-i.y)*(o.x-i.x))e.pop();else break}e.push(o)}e.pop();const n=[];for(let r=t.length-1;r>=0;r--){const o=t[r];for(;n.length>=2;){const a=n[n.length-1],i=n[n.length-2];if((a.x-i.x)*(o.y-i.y)>=(a.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}return n.pop(),e.length===1&&n.length===1&&e[0].x===n[0].x&&e[0].y===n[0].y?e:e.concat(n)}var np=Yu,rp=Ju,op=Xu,ap=Zu,Rr=ep;const m_=np,h_=rp,f_=op,ip=u.forwardRef(({className:t,sideOffset:e=4,...n},r)=>s.jsx(ap,{children:s.jsx(Rr,{ref:r,sideOffset:e,className:M("z-50 overflow-hidden rounded-md px-3 py-1.5 text-xs shadow-md","bg-composer-surface-elevated text-composer-text border border-composer-border","animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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",t),...n})}));ip.displayName=Rr.displayName;const oa={get(t,e){try{const n=localStorage.getItem(t);return n?JSON.parse(n):e}catch{return e}},set(t,e){try{localStorage.setItem(t,JSON.stringify(e))}catch{}},remove(t){try{localStorage.removeItem(t)}catch{}}};function g_(t,e){const[n,r]=u.useState(()=>oa.get(t,e)),o=u.useCallback(a=>{r(i=>{const l=a instanceof Function?a(i):a;return oa.set(t,l),l})},[t]);return u.useEffect(()=>{const a=i=>{if(i.key===t&&i.newValue)try{r(JSON.parse(i.newValue))}catch{}};return window.addEventListener("storage",a),()=>window.removeEventListener("storage",a)},[t]),[n,o]}const x_=["image/jpeg","image/png","image/gif","image/webp"],b_=["application/pdf"],y_=["text/plain","text/markdown","text/csv","text/html","text/css","text/javascript","application/json","application/xml","text/xml","application/x-yaml","text/yaml"],v_=5*1024*1024,Ac=20;function w_(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function __(t){return x_.includes(t)?"image":b_.includes(t)?"document":y_.includes(t)?"text":null}function k_(t){return new Promise((e,n)=>{const r=new FileReader;r.onload=()=>{const a=r.result.split(",")[1];e(a)},r.onerror=()=>n(new Error("Failed to read file")),r.readAsDataURL(t)})}function j_(t){return new Promise((e,n)=>{const r=new FileReader;r.onload=()=>e(r.result),r.onerror=()=>n(new Error("Failed to read file")),r.readAsText(t)})}function N_(){const[t,e]=u.useState([]),[n,r]=u.useState(null),o=u.useCallback(c=>{const d=Array.from(c);if(r(null),t.length+d.length>Ac){r(`Maximum ${Ac} attachments allowed`);return}const p=[],m=[];for(const h of d){const g=__(h.type);if(!g){m.push(`${h.name}: Unsupported file type (${h.type||"unknown"})`);continue}if(h.size>v_){const f=(h.size/1048576).toFixed(1);m.push(`${h.name}: File too large (${f}MB, max 5MB)`);continue}p.push({id:w_(),file:h,name:h.name,type:g,mimeType:h.type,base64:null,textContent:null,status:"pending",size:h.size})}if(m.length>0&&r(m.join("; ")),p.length!==0){e(h=>[...h,...p]);for(const h of p)e(f=>f.map(x=>x.id===h.id?{...x,status:"processing"}:x)),(h.type==="text"?j_(h.file).then(f=>({textContent:f,base64:null})):k_(h.file).then(f=>({base64:f,textContent:null}))).then(({base64:f,textContent:x})=>{e(b=>b.map(y=>y.id===h.id?{...y,base64:f,textContent:x,status:"ready"}:y))}).catch(f=>{const x=f instanceof Error?f.message:"Upload failed";e(b=>b.map(y=>y.id===h.id?{...y,status:"error",error:x}:y))})}},[t.length]),a=u.useCallback(c=>{e(d=>d.filter(p=>p.id!==c)),r(null)},[]),i=u.useCallback(()=>{e([]),r(null)},[]),l=u.useCallback(()=>t.filter(c=>c.status==="ready"&&(c.base64||c.textContent)).map(c=>({type:c.type,mimeType:c.mimeType,base64:c.base64??void 0,textContent:c.textContent??void 0,fileName:c.name})),[t]);return{attachments:t,addFiles:o,removeAttachment:a,clearAll:i,getContentBlocks:l,isProcessing:t.some(c=>c.status==="pending"||c.status==="processing"),hasAttachments:t.length>0,totalSize:t.reduce((c,d)=>c+d.size,0),error:n}}function S_({suggestions:t,onSelect:e,onClose:n,isOpen:r,focusedIndex:o,type:a,onFocusReturn:i}){const l=u.useRef(null);return u.useEffect(()=>{if(!r||o<0||!l.current)return;l.current.querySelectorAll("[data-autocomplete-item]")[o]?.scrollIntoView({block:"nearest"})},[o,r]),u.useEffect(()=>{if(!r)return;const c=d=>{l.current&&!l.current.contains(d.target)&&(n(),i?.())};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[r,n,i]),!r||t.length===0?null:s.jsx("div",{ref:l,className:"absolute bottom-full left-0 right-0 z-50 mb-1 max-h-[240px] overflow-y-auto rounded-md border bg-composer-surface border-composer-border shadow-md",children:t.map((c,d)=>{const p=a==="command",m=c.name,h=p?c.description:void 0;return s.jsxs("button",{"data-autocomplete-item":!0,type:"button",className:M("flex w-full flex-col items-start gap-0.5 px-3 py-1.5 text-left text-sm transition-colors",d===o?"bg-composer-active/10 text-composer-text":"text-composer-text-secondary hover:bg-composer-active/5"),onMouseDown:g=>{g.preventDefault(),e(m)},children:[s.jsx("span",{children:m}),h&&s.jsx("span",{className:"text-xs text-composer-text-faint",children:h})]},m)})})}const C_=t=>t?`composer-draft-${t}`:"composer-draft-home";function E_(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${Math.round(t/1e3)}K`:`${t}`}const T_="image/jpeg,image/png,image/gif,image/webp,application/pdf,text/plain,text/markdown,text/csv,text/html,text/css,text/javascript,application/json,application/xml,text/xml,.json,.md,.txt,.csv,.html,.css,.js,.ts,.yaml,.yml",I_=u.forwardRef(function(e,n){const r=e.core?.onSubmit??(()=>{}),o=e.core?.value,a=e.core?.onChange,i=e.core?.placeholder??"Type a message...",l=e.core?.disabled??!1,c=e.core?.sessionId,d=e.features?.enableAttachments??!0,p=e.features?.enableFileAutocomplete??!1,m=e.features?.showStatusBar??!0,h=e.features?.showMenu??!1,g=e.workingDirectory??"",f=e.permissionConfig?.onStop,x=e.permissionConfig?.onInterrupt,b=e.runtimeConfig?.isSessionActive??!1,y=e.runtimeConfig?.isSessionConnected??b,v=e.runtimeConfig?.isStopRequested??!1,w=e.runtimeConfig?.isInitializing??!1,N=e.runtimeConfig?.hasBackgroundTasks??!1,S=e.runtimeConfig?.scheduledWakeup??null,T=e.runtimeConfig?.sessionStartTime,C=e.runtimeConfig?.fileSystemEntries??[],j=e.runtimeConfig?.onFetchFileSystem,E=e.runtimeConfig?.availableCommands??[],R=e.runtimeConfig?.onFetchCommands,O=e.runtimeConfig?.queuedMessages??[],$=e.runtimeConfig?.sessionUsage??null,[re,ne]=u.useState(null);u.useEffect(()=>{if(!S){ne(null);return}const z=()=>{const Ie=S.expectedAt-Date.now();if(Ie<=0){ne("now");return}const Ee=Math.ceil(Ie/1e3),Se=Math.floor(Ee/60),Xe=Ee%60;ne(Se>0?`${Se}m ${Xe}s`:`${Ee}s`)};z();const de=setInterval(z,1e3);return()=>clearInterval(de)},[S]);const V=w?"Starting":v?"Stopping":b?"Working":S&&y?"Scheduled wakeup":N&&y?"Waiting for background task":y?"Ready":"Off",X=u.useRef(V);u.useEffect(()=>{const z=X.current;X.current=V,z!==V&&z==="Ready"&&V==="Starting"&&console.error(`[Composer] ILLEGAL STATUS TRANSITION: ${z} → ${V}. Ready means the process is alive, Starting means starting a new one.
|
|
126
|
-
isSessionActive=${b}, isSessionConnected=${y}, isInitializing=${w}, isStopRequested=${v}`)},[
|
|
127
|
-
`)?null:{triggerIndex:
|
|
128
|
-
`)&&!Se.endsWith(" "))return null;const Xe=
|
|
129
|
-
`)?null:{triggerIndex:Ee,query:Xe,type:"command"}},Dr=z=>{if(!pe)return[];if(!z)return pe.slice(0,50);const de=z.toLowerCase();return pe.filter(Ie=>Ie.name.toLowerCase().includes(de)).slice(0,50)},wn=z=>{if(!Ce)return[];if(!z)return Ce.slice(0,50);const de=z.toLowerCase();return Ce.filter(Ie=>Ie.name.toLowerCase().includes(de)).slice(0,50)},Tt=()=>{Re({isActive:!1,triggerIndex:-1,query:"",suggestions:[],focusedIndex:-1,type:"file"})},Bs=z=>{if(!B.current)return;const de=B.current.selectionStart;if(ke.type==="command"){const Ie=P.substring(0,ke.triggerIndex)+z+" "+P.substring(de);le(Ie),Tt(),setTimeout(()=>{if(B.current){const Ee=ke.triggerIndex+z.length+1;B.current.setSelectionRange(Ee,Ee),B.current.focus(),Wt()}},0)}else{const Ie=P.substring(0,ke.triggerIndex+1)+z+" "+P.substring(de);le(Ie),Tt(),setTimeout(()=>{if(B.current){const Ee=ke.triggerIndex+1+z.length+1;B.current.setSelectionRange(Ee,Ee),B.current.focus(),Wt()}},0)}},$r=z=>{const de=z.target.value;le(de),Wt();const Ie=z.target.selectionStart,Ee=Or(de,Ie);if(Ee&&R){Ce.length===0&&Vs();const Se=wn(Ee.query);Re(Xe=>({isActive:!0,triggerIndex:Ee.triggerIndex,query:Ee.query,suggestions:Se,type:Ee.type,focusedIndex:Xe.focusedIndex>=0&&Xe.focusedIndex<Se.length?Xe.focusedIndex:-1}));return}if(p){const Se=Lr(de,Ie);if(Se){pe.length===0&&ms();const Xe=Dr(Se.query);Re(it=>({isActive:!0,triggerIndex:Se.triggerIndex,query:Se.query,suggestions:Xe,type:Se.type,focusedIndex:it.focusedIndex>=0&&it.focusedIndex<Xe.length?it.focusedIndex:-1}));return}}Tt()},Je=()=>{const z=P.trim();if(!z&&!F||Z)return;const de=F?W():void 0,Ie=`${ee}-backup`;try{localStorage.setItem(Ie,P)}catch{}r(z,{workingDirectory:g||void 0,attachments:de}),le(""),oa.set(ee,""),D(),Tt()},rt=z=>{if(ke.isActive)switch(z.key){case"ArrowDown":z.preventDefault(),ke.suggestions.length>0&&Re(de=>({...de,focusedIndex:de.focusedIndex<0?0:(de.focusedIndex+1)%de.suggestions.length}));break;case"ArrowUp":z.preventDefault(),ke.suggestions.length>0&&Re(de=>({...de,focusedIndex:de.focusedIndex<0||de.focusedIndex===0?de.suggestions.length-1:de.focusedIndex-1}));break;case"Enter":case"Tab":if(!z.metaKey&&!z.ctrlKey&&(z.preventDefault(),ke.suggestions.length>0)){const de=ke.focusedIndex>=0?ke.focusedIndex:0,Ie=ke.suggestions[de],Ee=(ke.type==="command",Ie.name);Bs(Ee)}break;case" ":Tt();break;case"Escape":z.preventDefault(),Tt(),setTimeout(()=>B.current?.focus(),0);break}else if(z.key==="Enter"){if(z.shiftKey)return;z.preventDefault(),Je()}else z.key==="c"&&z.ctrlKey&&(b||y)&&(z.preventDefault(),x?.())},Wt=()=>{const z=B.current;if(z){z.style.height="auto";const de=Math.floor(window.innerHeight*.8);z.style.height=`${Math.min(z.scrollHeight,de)}px`}};u.useEffect(()=>Wt(),[P]),u.useEffect(()=>{const z=()=>Wt();return window.addEventListener("resize",z),()=>window.removeEventListener("resize",z)},[]);const _n=z=>{if(!d)return;const de=Array.from(z.clipboardData.files);de.length>0&&(z.preventDefault(),K(de))},kn=z=>{d&&(z.preventDefault(),z.stopPropagation(),ze(!0))},Kt=z=>{d&&(z.preventDefault(),z.stopPropagation(),z.currentTarget.contains(z.relatedTarget)||ze(!1))},hs=z=>{if(!d)return;z.preventDefault(),z.stopPropagation(),ze(!1);const de=Array.from(z.dataTransfer.files);de.length>0&&K(de)},fs=z=>{z.target.files&&z.target.files.length>0&&(K(z.target.files),z.target.value="")},ot=w||v?{border:"border-composer-caution dark:border-composer-caution/60",bg:"bg-composer-caution/30 dark:bg-composer-caution/10",borderInner:"border-composer-caution/60 dark:border-composer-caution/25",text:"text-composer-caution",textDim:"text-composer-caution dark:text-composer-caution/70"}:b?{border:"border-composer-active dark:border-composer-active/60",bg:"bg-composer-active/30 dark:bg-composer-active/10",borderInner:"border-composer-active/60 dark:border-composer-active/25",text:"text-composer-active",textDim:"text-composer-active dark:text-composer-active/70"}:S&&y?{border:"border-violet-400 dark:border-violet-400/60",bg:"bg-violet-400/30 dark:bg-violet-400/10",borderInner:"border-violet-400/60 dark:border-violet-400/25",text:"text-violet-500 dark:text-violet-300",textDim:"text-violet-500/70 dark:text-violet-300/70"}:y?{border:"border-composer-ready dark:border-composer-ready/40",bg:"bg-composer-ready/25 dark:bg-composer-ready/5",borderInner:"border-composer-ready/50 dark:border-composer-ready/15",text:"text-composer-ready",textDim:"text-composer-ready dark:text-composer-ready/60"}:{border:"border-composer-border",bg:"bg-composer-muted/15 dark:bg-composer-muted/5",borderInner:"border-composer-border/50",text:"text-composer-muted",textDim:"text-composer-muted/70 dark:text-composer-muted/40"};return s.jsx(m_,{children:s.jsxs("div",{ref:he,className:M("w-full relative",e.className),children:[d&&s.jsx("input",{ref:L,type:"file",multiple:!0,accept:T_,className:"hidden",onChange:fs}),s.jsxs("div",{"data-composer-status":w?"starting":v?"stopping":b?"active":y?"ready":"off",className:M("relative rounded-md overflow-hidden border bg-composer-surface/85 backdrop-blur-sm transition-all duration-200",m?ot.border:"border-composer-border/70"),children:[m&&s.jsxs("div",{className:M("relative flex min-h-[36px] sm:min-h-[44px] items-center justify-between gap-1.5 sm:gap-2 px-2 sm:px-3 py-1 sm:py-1.5 border-b",ot.bg,ot.borderInner),children:[s.jsx("div",{className:"flex items-center gap-1.5 sm:gap-2 shrink-0",children:w?s.jsxs(s.Fragment,{children:[s.jsx(at,{size:12,className:M("animate-spin",ot.text)}),s.jsx("span",{className:M("text-[8px] sm:text-[10px] font-semibold uppercase tracking-wider",ot.text),children:"Starting"})]}):v?s.jsxs(s.Fragment,{children:[s.jsx(at,{size:12,className:M("animate-spin",ot.text)}),s.jsx("span",{className:M("text-[8px] sm:text-[10px] font-semibold uppercase tracking-wider",ot.text),children:"Stopping"})]}):b?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"relative flex h-2 w-2",children:[s.jsx("span",{className:M("animate-ping absolute inline-flex h-full w-full rounded-full opacity-75","bg-composer-active")}),s.jsx("span",{className:M("relative inline-flex rounded-full h-2 w-2","bg-composer-active")})]}),s.jsx("span",{className:M("text-[8px] sm:text-[10px] font-semibold uppercase tracking-wider",ot.text),children:"Working"}),Et&&s.jsx("span",{className:M("text-[8px] sm:text-[10px] font-mono tabular-nums",ot.textDim),children:nt})]}):S&&y?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"relative flex h-2 w-2",children:[s.jsx("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-violet-400 dark:bg-violet-400 opacity-50"}),s.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-violet-400/70 dark:bg-violet-400/70"})]}),s.jsx("span",{className:"text-[8px] sm:text-[10px] font-semibold uppercase tracking-wider text-violet-500/70 dark:text-violet-300/70",children:"Sleeping"}),re&&s.jsx("span",{className:"text-[8px] sm:text-[10px] font-mono tabular-nums text-violet-500/50 dark:text-violet-300/50",children:re})]}):N&&y?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"relative flex h-2 w-2",children:[s.jsx("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-composer-caution opacity-50"}),s.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-composer-caution/70"})]}),s.jsx("span",{className:"text-[8px] sm:text-[10px] font-semibold uppercase tracking-wider text-composer-caution/70",children:"Waiting for background task"})]}):y?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"relative flex h-2 w-2",children:s.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-composer-ready dark:bg-composer-ready/50"})}),s.jsx("span",{className:"text-[8px] sm:text-[10px] font-semibold uppercase tracking-wider text-composer-ready dark:text-composer-ready/60",children:"Ready"})]}):s.jsx("span",{className:"text-[8px] sm:text-[10px] font-semibold uppercase tracking-wider text-composer-text-faint",children:"Idle"})}),s.jsxs("div",{className:"flex items-center gap-1 sm:gap-2 min-w-0 shrink",children:[$&&(()=>{const z=$.contextTokens??$.inputTokens+$.cacheCreationInputTokens+$.cacheReadInputTokens,de=z>=5e5?"text-red-500 dark:text-red-400":z>=2e5?"text-amber-500 dark:text-amber-400":b?"text-composer-active":y?"text-composer-ready":"text-composer-muted";return s.jsx("div",{className:"flex items-center rounded-sm border border-composer-border/50 bg-composer-surface-elevated/50 p-0.5","data-testid":"token-usage",children:s.jsxs("span",{className:M("px-1.5 sm:px-3 py-0.5 sm:py-1 text-[8px] sm:text-[10px] font-semibold uppercase tracking-wider whitespace-nowrap",de),"data-tokens":z,children:[E_(z)," tokens"]})})})(),O.length>0&&s.jsxs(h_,{children:[s.jsx(f_,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:()=>Me(!0),className:"px-1.5 sm:px-2 py-0.5 sm:py-1 rounded-sm border border-composer-caution/35 bg-composer-caution/10 text-composer-caution text-[8px] sm:text-[10px] font-semibold uppercase tracking-wider hover:border-composer-caution/60 hover:bg-composer-caution/20 transition-colors cursor-pointer whitespace-nowrap",children:["Queue ",O.length]})}),s.jsx(ip,{side:"top",children:s.jsx("p",{children:"Per-session message queue. These auto-send in order when the current run finishes."})})]})]})]}),s.jsxs("div",{className:M("flex flex-col items-center justify-center w-full bg-transparent cursor-text relative",me&&"ring-2 ring-composer-active/50 ring-inset bg-composer-active/5"),onDragOver:kn,onDragLeave:Kt,onDrop:hs,children:[me&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-composer-active/10 z-10 pointer-events-none",children:s.jsxs("div",{className:"flex items-center gap-2 text-composer-active font-medium",children:[s.jsx(Bg,{size:20}),s.jsx("span",{children:"Drop files to attach"})]})}),F&&s.jsxs("div",{className:"flex gap-2 px-3 py-2 w-full border-b border-composer-border/50 overflow-x-auto",children:[q.map(z=>s.jsxs("div",{className:"relative group flex-shrink-0 flex items-center gap-1.5 px-2 py-1 rounded bg-composer-surface-elevated/50 border border-composer-border/50",children:[z.type==="image"?s.jsx(Ra,{size:14,className:"text-composer-active"}):s.jsx(jt,{size:14,className:"text-composer-caution"}),s.jsx("span",{className:"text-xs text-composer-text-secondary max-w-[100px] truncate",children:z.name}),z.status==="processing"&&s.jsx(at,{size:12,className:"animate-spin text-composer-text-secondary"}),z.status==="error"&&s.jsx("span",{className:"text-composer-danger text-xs",children:"!"}),s.jsx("button",{type:"button",onClick:()=>ge(z.id),className:"ml-1 p-0.5 rounded hover:bg-composer-danger/20 text-composer-text-secondary hover:text-composer-danger transition-colors",children:s.jsx(yr,{size:12})})]},z.id)),se&&s.jsx("span",{className:"text-xs text-composer-danger self-center",children:se})]}),s.jsxs("div",{className:"relative flex w-full min-h-[44px] items-center",children:[s.jsx("div",{className:"relative flex flex-1 min-h-[44px] items-center",children:s.jsx("textarea",{ref:B,"data-testid":"composer-input",className:"max-h-[80vh] w-full border-none bg-transparent text-composer-text leading-relaxed resize-none outline-none overflow-y-auto min-h-[40px] py-2 pl-12 pr-28 text-sm tracking-[0.01em] placeholder:text-composer-text-faint",placeholder:i,value:P,onChange:$r,onKeyDown:rt,onPaste:_n,rows:1,disabled:l})}),d&&s.jsx("div",{className:"absolute flex items-center justify-center left-1.5 bottom-1.5",children:s.jsx("button",{type:"button",onClick:()=>L.current?.click(),disabled:l,"aria-label":"Add attachment",className:"flex h-8 w-8 items-center justify-center rounded-sm border border-composer-active dark:border-composer-active/30 text-composer-active transition-all duration-100 hover:border-composer-active hover:bg-composer-active/20 dark:hover:bg-composer-active/5 disabled:opacity-45 disabled:cursor-not-allowed",children:s.jsx(Hg,{size:14})})}),s.jsx("div",{className:"absolute flex items-center justify-center gap-2 right-1.5 bottom-1.5",children:b||y?s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("button",{type:"button","data-testid":"send-button",className:M("h-8 w-8 flex items-center justify-center rounded-sm border transition-all duration-100",P.trim()||F?"border-composer-active dark:border-composer-active/40 text-composer-active hover:border-composer-active hover:bg-composer-active/20 dark:hover:bg-composer-active/10":"border-composer-border text-composer-text-faint cursor-not-allowed"),disabled:!P.trim()&&!F||l||Z,onClick:Je,"aria-label":"Send message",children:s.jsx($o,{size:14})}),(b||v)&&s.jsxs("button",{type:"button",className:M("relative h-8 flex items-center justify-center gap-1 rounded-sm border text-[10px] font-semibold uppercase tracking-wider transition-all duration-100",v?"px-2":"w-8",v?"border-composer-caution/50 text-composer-caution bg-composer-caution/10":"border-composer-danger/30 text-composer-danger hover:border-composer-danger hover:bg-composer-danger/5"),onClick:()=>f?.(),"data-testid":"stop-button","aria-label":v?"Stop requested":"Stop session",children:[v?s.jsx(at,{size:14,className:"animate-spin"}):s.jsx(Kg,{size:14}),v&&s.jsx("span",{className:"hidden sm:inline",children:"Stopping"})]})]}):s.jsxs("div",{className:"flex items-center gap-2",children:[h&&s.jsx("button",{type:"button",onClick:()=>be(!ae),title:"Menu",className:M("flex items-center justify-center px-2 h-8 rounded-sm border transition-all duration-100 cursor-pointer",ae?"bg-composer-surface-elevated border-composer-border text-composer-text-secondary":"border-composer-border text-composer-text-faint hover:border-composer-text-faint hover:text-composer-text-secondary hover:bg-composer-surface-elevated/50"),children:s.jsx(wg,{size:14})}),s.jsx("button",{type:"button","data-testid":"send-button",disabled:!P.trim()&&!F||l||Z,onClick:Je,className:M("flex items-center justify-center h-8 w-8 rounded-sm border transition-all duration-100 cursor-pointer",!P.trim()&&!F||l||Z?"border-composer-border text-composer-text-faint cursor-not-allowed":"border-composer-active dark:border-composer-active/50 text-composer-active hover:border-composer-active hover:bg-composer-active/20 dark:hover:bg-composer-active/10"),children:s.jsx($o,{size:14})})]})})]}),s.jsx(Mw,{open:Ne,onOpenChange:Me,children:s.jsxs(Mu,{className:"max-w-lg",children:[s.jsxs(Ow,{children:[s.jsxs(Dw,{className:"text-sm font-semibold uppercase tracking-wider text-composer-caution",children:["Queued Messages (",O.length,")"]}),s.jsx($w,{className:"text-xs text-composer-text-secondary",children:"Per-session queue. These auto-send in order when the current run finishes."})]}),s.jsx("div",{className:"max-h-[55vh] overflow-y-auto space-y-2 pr-1",children:O.map(z=>s.jsxs("div",{className:"border border-composer-border/50 rounded-sm px-2.5 py-2 bg-composer-surface/80",children:[s.jsx("p",{className:"text-xs text-composer-text whitespace-pre-wrap break-words",children:z.content}),s.jsx("p",{className:"text-[10px] text-composer-text-faint mt-1 font-mono",children:z.status==="dispatching"?"sending...":`queued ${new Date(z.timestamp).toLocaleTimeString()}`})]},z.id))})]})})]})]}),h&&ae&&e.renderMenu?.({onClose:()=>be(!1)}),(p||R)&&s.jsx(S_,{suggestions:ke.suggestions,onSelect:Bs,onClose:Tt,isOpen:ke.isActive&&ke.suggestions.length>0,focusedIndex:ke.focusedIndex,type:ke.type,onFocusReturn:()=>B.current?.focus()})]})})});class Zs extends u.Component{constructor(e){super(e),this.state={hasError:!1,error:null,showStack:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,n){console.error(`[ErrorBoundary${this.props.name?`:${this.props.name}`:""}] Caught error:`,e,`
|
|
130
|
-
Component stack:`,n.componentStack),this.props.onError?.(e,n)}reset=()=>{this.setState({hasError:!1,error:null,showStack:!1})};toggleStack=()=>{this.setState(e=>({showStack:!e.showStack}))};render(){return this.state.hasError&&this.state.error?typeof this.props.fallback=="function"?this.props.fallback(this.state.error,this.reset):this.props.fallback?this.props.fallback:this.props.inline?s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-red-400 text-sm",children:[s.jsx(kt,{size:14}),s.jsxs("span",{children:["Error",this.props.name?` in ${this.props.name}`:""]}),s.jsx("button",{onClick:this.reset,className:"text-red-300 hover:text-red-200 underline",children:"retry"})]}):s.jsxs("div",{className:"my-2 border border-red-500/30 rounded-lg overflow-hidden bg-red-500/5",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-red-500/20",children:[s.jsx(kt,{size:14,className:"text-red-400 flex-shrink-0"}),s.jsxs("span",{className:"text-xs font-semibold uppercase tracking-wider text-red-400",children:["Render Error",this.props.name?` - ${this.props.name}`:""]}),s.jsxs("button",{onClick:this.reset,className:"ml-auto flex items-center gap-1 px-2 py-1 text-xs text-red-300 hover:text-red-200 hover:bg-red-500/10 rounded transition-colors",children:[s.jsx(ds,{size:12}),"Retry"]})]}),s.jsxs("div",{className:"px-3 py-2",children:[s.jsx("p",{className:"text-sm text-red-200 font-medium",children:this.state.error.message}),this.state.error.stack&&s.jsxs("div",{className:"mt-2",children:[s.jsxs("button",{onClick:this.toggleStack,className:"flex items-center gap-1 text-xs text-red-400/70 hover:text-red-400 transition-colors",children:[this.state.showStack?s.jsx(Nh,{size:12}):s.jsx(Lt,{size:12}),this.state.showStack?"Hide":"Show"," stack trace"]}),this.state.showStack&&s.jsx("pre",{className:"mt-2 text-xs text-red-300/60 font-mono whitespace-pre-wrap overflow-x-auto max-h-48 overflow-y-auto",children:this.state.error.stack})]})]})]}):this.props.children}}function A_({error:t,reset:e}){return s.jsx("div",{className:"min-h-dvh bg-background flex items-center justify-center p-4",children:s.jsx("div",{className:"max-w-md w-full",children:s.jsxs("div",{className:"border border-red-500/30 rounded-lg overflow-hidden bg-red-500/5",children:[s.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-red-500/20",children:[s.jsx(kt,{size:18,className:"text-red-400"}),s.jsx("span",{className:"text-sm font-semibold text-red-400",children:"Application Error"})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:"Something went wrong while rendering the application."}),s.jsx("p",{className:"text-sm text-red-200 font-mono bg-red-500/10 px-3 py-2 rounded",children:t.message}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{onClick:e,className:"flex items-center gap-2 px-4 py-2 bg-red-500/20 hover:bg-red-500/30 text-red-200 rounded transition-colors",children:[s.jsx(ds,{size:14}),"Try Again"]}),s.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 text-muted-foreground hover:text-foreground transition-colors",children:"Reload Page"})]})]})]})})})}const R_=Te.lazy(async()=>({default:(await _(()=>import("./CodeHighlight-D8HpdVaw.js"),__vite__mapDeps([105,102,104,103]))).CodeHighlight}));function Rc({code:t,className:e=""}){return s.jsx("pre",{className:$e("m-0 overflow-x-auto bg-zinc-950 px-3 py-2.5 font-mono text-[10px] leading-relaxed text-zinc-400",e),children:s.jsx("code",{children:t.trimEnd()})})}function P_(t){return s.jsx(Zs,{inline:!0,name:"CodeHighlight",fallback:s.jsx(Rc,{code:t.code,className:t.className}),children:s.jsx(u.Suspense,{fallback:s.jsx(Rc,{code:t.code,className:t.className}),children:s.jsx(R_,{...t})})})}const M_={},L_={};function Pc({src:t,alt:e="Attached",className:n="max-w-[200px] max-h-[200px] rounded border border-zinc-600 object-contain"}){const[r,o]=u.useState(!0),[a,i]=u.useState(!1),l=u.useCallback(()=>o(!1),[]),c=u.useCallback(()=>{o(!1),i(!0)},[]);return a?s.jsx("div",{className:`${n} flex items-center justify-center bg-zinc-800/50`,children:s.jsx("span",{className:"text-xs text-zinc-500",children:"Failed to load"})}):s.jsxs("div",{className:"relative inline-block",children:[r&&s.jsx("div",{className:`${n} flex items-center justify-center bg-zinc-800/50 absolute inset-0`,children:s.jsx(Ae,{size:20,className:"animate-spin text-cyan-400"})}),s.jsx("img",{src:t,alt:e,className:`${n} ${r?"invisible":"visible"}`,onLoad:l,onError:c})]})}function O_(t){return t.replace(/<!--\s*NEXT_STEPS\s*\n[\s\S]*?-->/g,"").trim()}function D_(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function $_(t,e){if(typeof t=="string"){const r=t.trim();if(r.length>0&&r.toLowerCase()!=="unknown")return r}const n=[e.tool_name,e.toolName,e.recipient_name,e.recipientName];for(const r of n)if(typeof r=="string"){const o=r.trim();if(o.length>0&&o.toLowerCase()!=="unknown")return o}return"Tool"}function z_(t){const e=[],n=/`?★\s*Insight\s*─+`?\s*([\s\S]*?)\s*`?─{5,}`?/g;let r=0,o;for(;(o=n.exec(t))!==null;){if(o.index>r){const a=t.slice(r,o.index).trim();a&&e.push({type:"text",content:a})}e.push({type:"insight",content:o[1].trim()}),r=o.index+o[0].length}if(r<t.length){const a=t.slice(r).trim();a&&e.push({type:"text",content:a})}return e.length===0&&e.push({type:"text",content:t}),e}function F_(t){return t.replace(/^(\d+)\./gm,"$1\\.")}function Mc({text:t,markdownComponents:e}){const n=z_(t),[r,o]=u.useState(!1),a=l=>{l.stopPropagation();const c=document.createElement("textarea");c.value=t,c.style.position="fixed",c.style.left="-9999px",c.style.top="-9999px",document.body.appendChild(c),c.focus(),c.select();try{document.execCommand("copy"),o(!0),setTimeout(()=>o(!1),2e3)}catch(d){console.error("Failed to copy:",d)}document.body.removeChild(c)},i=s.jsxs("div",{className:"border border-blue-500/15 rounded-lg overflow-hidden bg-blue-500/5 w-fit max-w-full",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-blue-500/10",children:[s.jsx(as,{size:12,className:"text-blue-400/80 flex-shrink-0"}),s.jsx("span",{className:"text-[11px] text-zinc-400 font-medium",children:"Agent"}),s.jsx("div",{className:"flex-1"}),s.jsx("button",{type:"button",onClick:a,onPointerDown:l=>l.stopPropagation(),className:"p-1 rounded hover:bg-zinc-800/40 text-zinc-600 hover:text-zinc-400 opacity-100 sm:opacity-0 sm:group-hover/response:opacity-100 transition-opacity touch-manipulation",title:r?"Copied!":"Copy response",children:r?s.jsx(Oe,{size:12,className:"text-green-500"}):s.jsx(Vt,{size:12})})]}),s.jsx("div",{className:"px-3 py-2 prose max-w-none text-[13px] leading-relaxed dark:prose-invert",children:n.map((l,c)=>l.type==="insight"?s.jsx("div",{className:"my-3 not-prose",children:s.jsxs("div",{className:"border border-zinc-800/40 rounded-lg overflow-hidden bg-zinc-900/30",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-zinc-800/40",children:[s.jsx(_a,{size:12,className:"text-yellow-400/80 flex-shrink-0"}),s.jsx("span",{className:"text-[10px] text-zinc-400 font-medium",children:"Insight"})]}),s.jsx("div",{className:"px-3 py-2 prose max-w-none text-[13px] leading-relaxed dark:prose-invert",children:s.jsx(Eo,{remarkPlugins:[Cs],components:e,children:l.content})})]})},c):s.jsx(Eo,{remarkPlugins:[Cs],components:e,children:F_(l.content)},c))})]});return s.jsx("div",{className:"group/response relative",children:i})}const V_=[{pattern:/^\/prototype\/(.+)$/,getInfo:t=>({label:t[1].replace(/-/g," ").replace(/\b\w/g,e=>e.toUpperCase()),icon:Hl})},{pattern:/^\/c\/([a-f0-9-]+)$/,getInfo:t=>({label:`Session ${t[1].slice(0,8)}`,icon:If})},{pattern:/^\/dev$/,getInfo:()=>({label:"Dev Hub",icon:ka})},{pattern:/^\/session\/([a-f0-9-]+)\/review$/,getInfo:t=>({label:`Analysis ${t[1].slice(0,8)}`,icon:vi})},{pattern:/^\/analysis\/cross-session$/,getInfo:()=>({label:"Cross-session analysis",icon:vi})}];function Lc(t){if(!t)return null;let e;if(t.startsWith("/"))e=t;else try{const n=new URL(t),r=n.hostname;if(!(r==="localhost"||r==="127.0.0.1"||/^\d+\.\d+\.\d+\.\d+$/.test(r)))return null;e=n.pathname}catch{return null}for(const{pattern:n,getInfo:r}of V_){const o=e.match(n);if(o)return{path:e,...r(o)}}return null}function Oc({route:t}){return s.jsxs("a",{href:t.path,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 not-prose px-3 py-1 my-0.5 rounded-sm border border-cyan-500/40 bg-cyan-500/20 hover:bg-cyan-500/30 active:bg-cyan-500/35 transition-all duration-100 no-underline select-none align-middle cursor-pointer",style:{touchAction:"manipulation"},children:[s.jsx(t.icon,{size:11,className:"text-cyan-300 flex-shrink-0"}),s.jsx("span",{className:"text-[10px] font-display font-bold uppercase tracking-wider text-cyan-300 truncate max-w-[200px]",children:t.label}),s.jsx(os,{size:9,className:"text-cyan-300/40 flex-shrink-0"})]})}const lo={a({href:t,children:e}){const n=Lc(t);if(n)return s.jsx(Oc,{route:n});const r=t?.startsWith("/");return s.jsx("a",{href:t,target:r?void 0:"_blank",rel:r?void 0:"noopener noreferrer",className:"text-cyan-400 hover:text-cyan-300 underline underline-offset-2",children:e})},table({children:t}){return s.jsx("div",{className:"my-3 not-prose",children:s.jsx("div",{className:"border border-zinc-800/40 rounded-lg overflow-hidden bg-zinc-900/30",children:s.jsx("div",{className:"overflow-x-auto",children:s.jsx("table",{className:"w-full text-sm",children:t})})})})},thead({children:t}){return s.jsx("thead",{className:"bg-zinc-800/20 border-b border-zinc-800/40",children:t})},tbody({children:t}){return s.jsx("tbody",{className:"divide-y divide-zinc-800/40",children:t})},tr({children:t}){return s.jsx("tr",{className:"hover:bg-zinc-800/20 transition-colors",children:t})},th({children:t}){return s.jsx("th",{className:"px-3 py-2 text-left text-xs font-semibold uppercase tracking-wider text-zinc-400",children:t})},td({children:t}){return s.jsx("td",{className:"px-3 py-2 text-foreground",children:t})},code({node:t,inline:e,className:n,children:r,...o}){const a=/language-(\w+)/.exec(n||""),i=a?a[1]:"text";if(!e&&a)return s.jsx(P_,{code:String(r).replace(/\n$/,""),language:i,className:"rounded-md overflow-hidden max-w-full box-border"});const l=String(r).trim();if(/^https?:\/\//.test(l)){const c=Lc(l);if(c)return s.jsx(Oc,{route:c})}return s.jsx("code",{className:n,...o,children:r})}};function cp({message:t,toolResults:e=M_,childrenMessages:n=L_,expandedTasks:r=new Set,onToggleTaskExpanded:o,isFirstInGroup:a=!0,isLastInGroup:i=!0,isStreaming:l=!1,currentQuestionRequest:c,onAnswerQuestion:d,onPlanApprove:p,onPlanReject:m,planOutcomes:h}){const g=u.useRef(l),[f,x]=u.useState(new Set),[b,y]=u.useState(!1);if(u.useMemo(()=>{if(!Array.isArray(t.content))return{};const v={};return t.content.forEach(w=>{if(w&&typeof w=="object"&&w.type==="tool_result"){const N=w.tool_use_id;if(N){const S=w.content,T=(Array.isArray(S),S);v[N]={status:"completed",result:typeof T=="string"||Array.isArray(T)?T:void 0,is_error:w.is_error}}}}),v},[t.content]),t.type==="user"){let v=typeof t.content=="string"?t.content:Array.isArray(t.content)?t.content.filter(R=>R.type==="text").map(R=>R.text||"").join(`
|
|
131
|
-
`):"";v=v.trim();const w=Array.isArray(t.content)?t.content.filter(
|
|
125
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return u.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},Cw="DialogDescriptionWarning",Ew=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Iu(Cw).contentName}}.`;return u.useEffect(()=>{const o=t.current?.getAttribute("aria-describedby");e&&o&&(document.getElementById(e)||console.warn(r))},[r,t,e]),null},Tw=xu,Iw=vu,Au=wu,Ru=_u,Aw=ju,Rw=Su,Pw=Eu;const Mw=Tw,Lw=Iw,Pu=u.forwardRef(({className:t,...e},n)=>s.jsx(Au,{ref:n,className:R("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e}));Pu.displayName=Au.displayName;const Mu=u.forwardRef(({className:t,children:e,...n},r)=>s.jsxs(Lw,{children:[s.jsx(Pu,{}),s.jsxs(Ru,{ref:r,className:R("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 rounded-lg border p-6 shadow-lg duration-200","bg-composer-surface border-composer-border","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]",t),...n,children:[e,s.jsxs(Pw,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-composer-surface transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-composer-active focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-composer-active/10 data-[state=open]:text-composer-text-secondary",children:[s.jsx(yr,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Mu.displayName=Ru.displayName;function Ow({className:t,...e}){return s.jsx("div",{className:R("flex flex-col space-y-1.5 text-center sm:text-left",t),...e})}function Dw({className:t,ref:e,...n}){return s.jsx(Aw,{ref:e,className:R("text-lg font-semibold leading-none tracking-tight text-composer-text",t),...n})}function $w({className:t,ref:e,...n}){return s.jsx(Rw,{ref:e,className:R("text-sm text-composer-text-secondary",t),...n})}var zw="Arrow",Lu=u.forwardRef((t,e)=>{const{children:n,width:r=10,height:o=5,...a}=t;return s.jsx(st.svg,{...a,ref:e,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:s.jsx("polygon",{points:"0,0 30,0 15,10"})})});Lu.displayName=zw;var Fw=Lu;function Vw(t){const[e,n]=u.useState(void 0);return Wn(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const a=o[0];let i,l;if("borderBoxSize"in a){const c=a.borderBoxSize,d=Array.isArray(c)?c[0]:c;i=d.inlineSize,l=d.blockSize}else i=t.offsetWidth,l=t.offsetHeight;n({width:i,height:l})});return r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),e}var Xa="Popper",[Ou,Tr]=pr(Xa),[Bw,Du]=Ou(Xa),$u=t=>{const{__scopePopper:e,children:n}=t,[r,o]=u.useState(null);return s.jsx(Bw,{scope:e,anchor:r,onAnchorChange:o,children:n})};$u.displayName=Xa;var zu="PopperAnchor",Fu=u.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...o}=t,a=Du(zu,n),i=u.useRef(null),l=dt(e,i),c=u.useRef(null);return u.useEffect(()=>{const d=c.current;c.current=r?.current||i.current,d!==c.current&&a.onAnchorChange(c.current)}),r?null:s.jsx(st.div,{...o,ref:l})});Fu.displayName=zu;var Za="PopperContent",[Uw,Gw]=Ou(Za),Vu=u.forwardRef((t,e)=>{const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:a="center",alignOffset:i=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:p=0,sticky:m="partial",hideWhenDetached:h=!1,updatePositionStrategy:g="optimized",onPlaced:f,...x}=t,b=Du(Za,n),[y,v]=u.useState(null),w=dt(e,xe=>v(xe)),[N,S]=u.useState(null),T=Vw(N),C=T?.width??0,j=T?.height??0,E=r+(a!=="center"?"-"+a:""),A=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},L=Array.isArray(d)?d:[d],$=L.length>0,oe={padding:A,boundary:L.filter(qw),altBoundary:$},{refs:ne,floatingStyles:B,placement:Q,isPositioned:q,middlewareData:Z}=Rm({strategy:"fixed",placement:E,whileElementsMounted:(...xe)=>zm(...xe,{animationFrame:g==="always"}),elements:{reference:b.anchor},middleware:[Pm({mainAxis:o+j,alignmentAxis:i}),c&&Mm({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?Fm():void 0,...oe}),c&&Lm({...oe}),Om({...oe,apply:({elements:xe,rects:_e,availableWidth:I,availableHeight:P})=>{const{width:de,height:X}=_e.reference,G=xe.floating.style;G.setProperty("--radix-popper-available-width",`${I}px`),G.setProperty("--radix-popper-available-height",`${P}px`),G.setProperty("--radix-popper-anchor-width",`${de}px`),G.setProperty("--radix-popper-anchor-height",`${X}px`)}}),N&&Dm({element:N,padding:l}),Ww({arrowWidth:C,arrowHeight:j}),h&&$m({strategy:"referenceHidden",...oe})]}),[me,O]=Gu(Q),W=Is(f);Wn(()=>{q&&W?.()},[q,W]);const ee=Z.arrow?.x,z=Z.arrow?.y,re=Z.arrow?.centerOffset!==0,[se,te]=u.useState();return Wn(()=>{y&&te(window.getComputedStyle(y).zIndex)},[y]),s.jsx("div",{ref:ne.setFloating,"data-radix-popper-content-wrapper":"",style:{...B,transform:q?B.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:se,"--radix-popper-transform-origin":[Z.transformOrigin?.x,Z.transformOrigin?.y].join(" "),...Z.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:s.jsx(Uw,{scope:n,placedSide:me,onArrowChange:S,arrowX:ee,arrowY:z,shouldHideArrow:re,children:s.jsx(st.div,{"data-side":me,"data-align":O,...x,ref:w,style:{...x.style,animation:q?void 0:"none"}})})})});Vu.displayName=Za;var Bu="PopperArrow",Hw={top:"bottom",right:"left",bottom:"top",left:"right"},Uu=u.forwardRef(function(e,n){const{__scopePopper:r,...o}=e,a=Gw(Bu,r),i=Hw[a.placedSide];return s.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:s.jsx(Fw,{...o,ref:n,style:{...o.style,display:"block"}})})});Uu.displayName=Bu;function qw(t){return t!==null}var Ww=t=>({name:"transformOrigin",options:t,fn(e){const{placement:n,rects:r,middlewareData:o}=e,i=o.arrow?.centerOffset!==0,l=i?0:t.arrowWidth,c=i?0:t.arrowHeight,[d,p]=Gu(n),m={start:"0%",center:"50%",end:"100%"}[p],h=(o.arrow?.x??0)+l/2,g=(o.arrow?.y??0)+c/2;let f="",x="";return d==="bottom"?(f=i?m:`${h}px`,x=`${-c}px`):d==="top"?(f=i?m:`${h}px`,x=`${r.floating.height+c}px`):d==="right"?(f=`${-c}px`,x=i?m:`${g}px`):d==="left"&&(f=`${r.floating.width+c}px`,x=i?m:`${g}px`),{data:{x:f,y:x}}}});function Gu(t){const[e,n="center"]=t.split("-");return[e,n]}var Hu=$u,ei=Fu,qu=Vu,Wu=Uu,Kw=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Qw="VisuallyHidden",Ku=u.forwardRef((t,e)=>s.jsx(st.span,{...t,ref:e,style:{...Kw,...t.style}}));Ku.displayName=Qw;var Yw=Ku,[Ir]=pr("Tooltip",[Tr]),Ar=Tr(),Qu="TooltipProvider",Jw=700,na="tooltip.open",[Xw,ti]=Ir(Qu),Yu=t=>{const{__scopeTooltip:e,delayDuration:n=Jw,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:a}=t,i=u.useRef(!0),l=u.useRef(!1),c=u.useRef(0);return u.useEffect(()=>{const d=c.current;return()=>window.clearTimeout(d)},[]),s.jsx(Xw,{scope:e,isOpenDelayedRef:i,delayDuration:n,onOpen:u.useCallback(()=>{window.clearTimeout(c.current),i.current=!1},[]),onClose:u.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:u.useCallback(d=>{l.current=d},[]),disableHoverableContent:o,children:a})};Yu.displayName=Qu;var un="Tooltip",[Zw,xn]=Ir(un),Ju=t=>{const{__scopeTooltip:e,children:n,open:r,defaultOpen:o,onOpenChange:a,disableHoverableContent:i,delayDuration:l}=t,c=ti(un,t.__scopeTooltip),d=Ar(e),[p,m]=u.useState(null),h=Ys(),g=u.useRef(0),f=i??c.disableHoverableContent,x=l??c.delayDuration,b=u.useRef(!1),[y,v]=ba({prop:r,defaultProp:o??!1,onChange:C=>{C?(c.onOpen(),document.dispatchEvent(new CustomEvent(na))):c.onClose(),a?.(C)},caller:un}),w=u.useMemo(()=>y?b.current?"delayed-open":"instant-open":"closed",[y]),N=u.useCallback(()=>{window.clearTimeout(g.current),g.current=0,b.current=!1,v(!0)},[v]),S=u.useCallback(()=>{window.clearTimeout(g.current),g.current=0,v(!1)},[v]),T=u.useCallback(()=>{window.clearTimeout(g.current),g.current=window.setTimeout(()=>{b.current=!0,v(!0),g.current=0},x)},[x,v]);return u.useEffect(()=>()=>{g.current&&(window.clearTimeout(g.current),g.current=0)},[]),s.jsx(Hu,{...d,children:s.jsx(Zw,{scope:e,contentId:h,open:y,stateAttribute:w,trigger:p,onTriggerChange:m,onTriggerEnter:u.useCallback(()=>{c.isOpenDelayedRef.current?T():N()},[c.isOpenDelayedRef,T,N]),onTriggerLeave:u.useCallback(()=>{f?S():(window.clearTimeout(g.current),g.current=0)},[S,f]),onOpen:N,onClose:S,disableHoverableContent:f,children:n})})};Ju.displayName=un;var ra="TooltipTrigger",Xu=u.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,o=xn(ra,n),a=ti(ra,n),i=Ar(n),l=u.useRef(null),c=dt(e,l,o.onTriggerChange),d=u.useRef(!1),p=u.useRef(!1),m=u.useCallback(()=>d.current=!1,[]);return u.useEffect(()=>()=>document.removeEventListener("pointerup",m),[m]),s.jsx(ei,{asChild:!0,...i,children:s.jsx(st.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:c,onPointerMove:He(t.onPointerMove,h=>{h.pointerType!=="touch"&&!p.current&&!a.isPointerInTransitRef.current&&(o.onTriggerEnter(),p.current=!0)}),onPointerLeave:He(t.onPointerLeave,()=>{o.onTriggerLeave(),p.current=!1}),onPointerDown:He(t.onPointerDown,()=>{o.open&&o.onClose(),d.current=!0,document.addEventListener("pointerup",m,{once:!0})}),onFocus:He(t.onFocus,()=>{d.current||o.onOpen()}),onBlur:He(t.onBlur,o.onClose),onClick:He(t.onClick,o.onClose)})})});Xu.displayName=ra;var si="TooltipPortal",[e_,t_]=Ir(si,{forceMount:void 0}),Zu=t=>{const{__scopeTooltip:e,forceMount:n,children:r,container:o}=t,a=xn(si,e);return s.jsx(e_,{scope:e,forceMount:n,children:s.jsx(ls,{present:n||a.open,children:s.jsx(Sr,{asChild:!0,container:o,children:r})})})};Zu.displayName=si;var As="TooltipContent",ep=u.forwardRef((t,e)=>{const n=t_(As,t.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...a}=t,i=xn(As,t.__scopeTooltip);return s.jsx(ls,{present:r||i.open,children:i.disableHoverableContent?s.jsx(tp,{side:o,...a,ref:e}):s.jsx(s_,{side:o,...a,ref:e})})}),s_=u.forwardRef((t,e)=>{const n=xn(As,t.__scopeTooltip),r=ti(As,t.__scopeTooltip),o=u.useRef(null),a=dt(e,o),[i,l]=u.useState(null),{trigger:c,onClose:d}=n,p=o.current,{onPointerInTransitChange:m}=r,h=u.useCallback(()=>{l(null),m(!1)},[m]),g=u.useCallback((f,x)=>{const b=f.currentTarget,y={x:f.clientX,y:f.clientY},v=i_(y,b.getBoundingClientRect()),w=c_(y,v),N=l_(x.getBoundingClientRect()),S=u_([...w,...N]);l(S),m(!0)},[m]);return u.useEffect(()=>()=>h(),[h]),u.useEffect(()=>{if(c&&p){const f=b=>g(b,p),x=b=>g(b,c);return c.addEventListener("pointerleave",f),p.addEventListener("pointerleave",x),()=>{c.removeEventListener("pointerleave",f),p.removeEventListener("pointerleave",x)}}},[c,p,g,h]),u.useEffect(()=>{if(i){const f=x=>{const b=x.target,y={x:x.clientX,y:x.clientY},v=c?.contains(b)||p?.contains(b),w=!d_(y,i);v?h():w&&(h(),d())};return document.addEventListener("pointermove",f),()=>document.removeEventListener("pointermove",f)}},[c,p,i,d,h]),s.jsx(tp,{...t,ref:a})}),[n_,r_]=Ir(un,{isInside:!1}),o_=Xm("TooltipContent"),tp=u.forwardRef((t,e)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:a,onPointerDownOutside:i,...l}=t,c=xn(As,n),d=Ar(n),{onClose:p}=c;return u.useEffect(()=>(document.addEventListener(na,p),()=>document.removeEventListener(na,p)),[p]),u.useEffect(()=>{if(c.trigger){const m=h=>{h.target?.contains(c.trigger)&&p()};return window.addEventListener("scroll",m,{capture:!0}),()=>window.removeEventListener("scroll",m,{capture:!0})}},[c.trigger,p]),s.jsx(Nr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:m=>m.preventDefault(),onDismiss:p,children:s.jsxs(qu,{"data-state":c.stateAttribute,...d,...l,ref:e,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[s.jsx(o_,{children:r}),s.jsx(n_,{scope:n,isInside:!0,children:s.jsx(Yw,{id:c.contentId,role:"tooltip",children:o||r})})]})})});ep.displayName=As;var sp="TooltipArrow",a_=u.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,o=Ar(n);return r_(sp,n).isInside?null:s.jsx(Wu,{...o,...r,ref:e})});a_.displayName=sp;function i_(t,e){const n=Math.abs(e.top-t.y),r=Math.abs(e.bottom-t.y),o=Math.abs(e.right-t.x),a=Math.abs(e.left-t.x);switch(Math.min(n,r,o,a)){case a:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function c_(t,e,n=5){const r=[];switch(e){case"top":r.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":r.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":r.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":r.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return r}function l_(t){const{top:e,right:n,bottom:r,left:o}=t;return[{x:o,y:e},{x:n,y:e},{x:n,y:r},{x:o,y:r}]}function d_(t,e){const{x:n,y:r}=t;let o=!1;for(let a=0,i=e.length-1;a<e.length;i=a++){const l=e[a],c=e[i],d=l.x,p=l.y,m=c.x,h=c.y;p>r!=h>r&&n<(m-d)*(r-p)/(h-p)+d&&(o=!o)}return o}function u_(t){const e=t.slice();return e.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),p_(e)}function p_(t){if(t.length<=1)return t.slice();const e=[];for(let r=0;r<t.length;r++){const o=t[r];for(;e.length>=2;){const a=e[e.length-1],i=e[e.length-2];if((a.x-i.x)*(o.y-i.y)>=(a.y-i.y)*(o.x-i.x))e.pop();else break}e.push(o)}e.pop();const n=[];for(let r=t.length-1;r>=0;r--){const o=t[r];for(;n.length>=2;){const a=n[n.length-1],i=n[n.length-2];if((a.x-i.x)*(o.y-i.y)>=(a.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}return n.pop(),e.length===1&&n.length===1&&e[0].x===n[0].x&&e[0].y===n[0].y?e:e.concat(n)}var np=Yu,rp=Ju,op=Xu,ap=Zu,Rr=ep;const m_=np,h_=rp,f_=op,ip=u.forwardRef(({className:t,sideOffset:e=4,...n},r)=>s.jsx(ap,{children:s.jsx(Rr,{ref:r,sideOffset:e,className:R("z-50 overflow-hidden rounded-md px-3 py-1.5 text-xs shadow-md","bg-composer-surface-elevated text-composer-text border border-composer-border","animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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",t),...n})}));ip.displayName=Rr.displayName;const oa={get(t,e){try{const n=localStorage.getItem(t);return n?JSON.parse(n):e}catch{return e}},set(t,e){try{localStorage.setItem(t,JSON.stringify(e))}catch{}},remove(t){try{localStorage.removeItem(t)}catch{}}};function g_(t,e){const[n,r]=u.useState(()=>oa.get(t,e)),o=u.useCallback(a=>{r(i=>{const l=a instanceof Function?a(i):a;return oa.set(t,l),l})},[t]);return u.useEffect(()=>{const a=i=>{if(i.key===t&&i.newValue)try{r(JSON.parse(i.newValue))}catch{}};return window.addEventListener("storage",a),()=>window.removeEventListener("storage",a)},[t]),[n,o]}const x_=["image/jpeg","image/png","image/gif","image/webp"],b_=["application/pdf"],y_=["text/plain","text/markdown","text/csv","text/html","text/css","text/javascript","application/json","application/xml","text/xml","application/x-yaml","text/yaml"],v_=5*1024*1024,Ac=20;function w_(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function __(t){return x_.includes(t)?"image":b_.includes(t)?"document":y_.includes(t)?"text":null}function k_(t){return new Promise((e,n)=>{const r=new FileReader;r.onload=()=>{const a=r.result.split(",")[1];e(a)},r.onerror=()=>n(new Error("Failed to read file")),r.readAsDataURL(t)})}function j_(t){return new Promise((e,n)=>{const r=new FileReader;r.onload=()=>e(r.result),r.onerror=()=>n(new Error("Failed to read file")),r.readAsText(t)})}function N_(){const[t,e]=u.useState([]),[n,r]=u.useState(null),o=u.useCallback(c=>{const d=Array.from(c);if(r(null),t.length+d.length>Ac){r(`Maximum ${Ac} attachments allowed`);return}const p=[],m=[];for(const h of d){const g=__(h.type);if(!g){m.push(`${h.name}: Unsupported file type (${h.type||"unknown"})`);continue}if(h.size>v_){const f=(h.size/1048576).toFixed(1);m.push(`${h.name}: File too large (${f}MB, max 5MB)`);continue}p.push({id:w_(),file:h,name:h.name,type:g,mimeType:h.type,base64:null,textContent:null,status:"pending",size:h.size})}if(m.length>0&&r(m.join("; ")),p.length!==0){e(h=>[...h,...p]);for(const h of p)e(f=>f.map(x=>x.id===h.id?{...x,status:"processing"}:x)),(h.type==="text"?j_(h.file).then(f=>({textContent:f,base64:null})):k_(h.file).then(f=>({base64:f,textContent:null}))).then(({base64:f,textContent:x})=>{e(b=>b.map(y=>y.id===h.id?{...y,base64:f,textContent:x,status:"ready"}:y))}).catch(f=>{const x=f instanceof Error?f.message:"Upload failed";e(b=>b.map(y=>y.id===h.id?{...y,status:"error",error:x}:y))})}},[t.length]),a=u.useCallback(c=>{e(d=>d.filter(p=>p.id!==c)),r(null)},[]),i=u.useCallback(()=>{e([]),r(null)},[]),l=u.useCallback(()=>t.filter(c=>c.status==="ready"&&(c.base64||c.textContent)).map(c=>({type:c.type,mimeType:c.mimeType,base64:c.base64??void 0,textContent:c.textContent??void 0,fileName:c.name})),[t]);return{attachments:t,addFiles:o,removeAttachment:a,clearAll:i,getContentBlocks:l,isProcessing:t.some(c=>c.status==="pending"||c.status==="processing"),hasAttachments:t.length>0,totalSize:t.reduce((c,d)=>c+d.size,0),error:n}}function S_({suggestions:t,onSelect:e,onClose:n,isOpen:r,focusedIndex:o,type:a,onFocusReturn:i}){const l=u.useRef(null);return u.useEffect(()=>{if(!r||o<0||!l.current)return;l.current.querySelectorAll("[data-autocomplete-item]")[o]?.scrollIntoView({block:"nearest"})},[o,r]),u.useEffect(()=>{if(!r)return;const c=d=>{l.current&&!l.current.contains(d.target)&&(n(),i?.())};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[r,n,i]),!r||t.length===0?null:s.jsx("div",{ref:l,className:"absolute bottom-full left-0 right-0 z-50 mb-1 max-h-[240px] overflow-y-auto rounded-md border bg-composer-surface border-composer-border shadow-md",children:t.map((c,d)=>{const p=a==="command",m=c.name,h=p?c.description:void 0;return s.jsxs("button",{"data-autocomplete-item":!0,type:"button",className:R("flex w-full flex-col items-start gap-0.5 px-3 py-1.5 text-left text-sm transition-colors",d===o?"bg-composer-active/10 text-composer-text":"text-composer-text-secondary hover:bg-composer-active/5"),onMouseDown:g=>{g.preventDefault(),e(m)},children:[s.jsx("span",{children:m}),h&&s.jsx("span",{className:"text-xs text-composer-text-faint",children:h})]},m)})})}const C_=t=>t?`composer-draft-${t}`:"composer-draft-home";function E_(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${Math.round(t/1e3)}K`:`${t}`}const T_="image/jpeg,image/png,image/gif,image/webp,application/pdf,text/plain,text/markdown,text/csv,text/html,text/css,text/javascript,application/json,application/xml,text/xml,.json,.md,.txt,.csv,.html,.css,.js,.ts,.yaml,.yml",I_=u.forwardRef(function(e,n){const r=e.core?.onSubmit??(()=>{}),o=e.core?.value,a=e.core?.onChange,i=e.core?.placeholder??"Type a message...",l=e.core?.disabled??!1,c=e.core?.sessionId,d=e.features?.enableAttachments??!0,p=e.features?.enableFileAutocomplete??!1,m=e.features?.showStatusBar??!0,h=e.features?.showMenu??!1,g=e.workingDirectory??"",f=e.permissionConfig?.onStop,x=e.permissionConfig?.onInterrupt,b=e.runtimeConfig?.isSessionActive??!1,y=e.runtimeConfig?.isSessionConnected??b,v=e.runtimeConfig?.isStopRequested??!1,w=e.runtimeConfig?.isInitializing??!1,N=e.runtimeConfig?.hasBackgroundTasks??!1,S=e.runtimeConfig?.scheduledWakeup??null,T=e.runtimeConfig?.sessionStartTime,C=e.runtimeConfig?.fileSystemEntries??[],j=e.runtimeConfig?.onFetchFileSystem,E=e.runtimeConfig?.availableCommands??[],A=e.runtimeConfig?.onFetchCommands,L=e.runtimeConfig?.queuedMessages??[],$=e.runtimeConfig?.sessionUsage??null,[oe,ne]=u.useState(null);u.useEffect(()=>{if(!S){ne(null);return}const F=()=>{const Ae=S.expectedAt-Date.now();if(Ae<=0){ne("now");return}const Te=Math.ceil(Ae/1e3),Se=Math.floor(Te/60),Xe=Te%60;ne(Se>0?`${Se}m ${Xe}s`:`${Te}s`)};F();const ue=setInterval(F,1e3);return()=>clearInterval(ue)},[S]);const B=w?"Starting":v?"Stopping":b?"Working":S&&y?"Scheduled wakeup":N&&y?"Waiting for background task":y?"Ready":"Off",Q=u.useRef(B);u.useEffect(()=>{const F=Q.current;Q.current=B,F!==B&&F==="Ready"&&B==="Starting"&&console.error(`[Composer] ILLEGAL STATUS TRANSITION: ${F} → ${B}. Ready means the process is alive, Starting means starting a new one.
|
|
126
|
+
isSessionActive=${b}, isSessionConnected=${y}, isInitializing=${w}, isStopRequested=${v}`)},[B,b,y,w,v]);const{attachments:q,addFiles:Z,removeAttachment:me,clearAll:O,getContentBlocks:W,isProcessing:ee,hasAttachments:z,error:re}=N_(),se=C_(c),[te,xe]=g_(se,""),[_e,I]=u.useState(te),P=o!==void 0?o:_e,de=F=>{o===void 0&&I(F),a?.(F)};u.useEffect(()=>{o===void 0&&xe(_e)},[_e,xe,o]),u.useEffect(()=>{o===void 0&&I(te)},[se]);const[X,G]=u.useState([]),[V,D]=u.useState([]),be=X.length>0?X:C,Ce=V.length>0?V:E,[je,Ee]=u.useState({isActive:!1,triggerIndex:-1,query:"",suggestions:[],focusedIndex:-1,type:"file"}),K=u.useRef(null),fe=u.useRef(null),M=u.useRef(null),Y=u.useRef(null),U=u.useRef(null),[ie,ye]=u.useState(!1),[he,ze]=u.useState(!1),[Ne,Me]=u.useState(!1),[nt,Ye]=u.useState("0:00"),[Ct,ps]=u.useState(!1);u.useEffect(()=>{G([]),D([]),Y.current=null,U.current=null},[g]);const vn=b||y;u.useEffect(()=>{if(!vn){Ye("0:00"),ps(!1);return}if(!T){ps(!1);return}ps(!0);const F=()=>{const Ae=Math.floor((Date.now()-T)/1e3),Te=Math.floor(Ae/60),Se=Ae%60;Ye(`${Te}:${Se.toString().padStart(2,"0")}`)};F();const ue=setInterval(F,1e3);return()=>clearInterval(ue)},[vn,T]),u.useImperativeHandle(n,()=>({focusInput:()=>K.current?.focus()}));const ms=u.useCallback(async()=>{if(!p||!j)return[];if(!g||g==="Select directory")return[];if(Y.current)return Y.current;const F=j(g).then(ue=>(G(ue),ue)).catch(ue=>(console.error("Failed to fetch file system entries:",ue),[])).finally(()=>{Y.current=null});return Y.current=F,F},[p,j,g]),Vs=u.useCallback(async()=>{if(!A)return[];if(U.current)return U.current;const F=A(g!=="Select directory"?g:void 0).then(ue=>(D(ue),ue)).catch(ue=>(console.error("Failed to fetch commands:",ue),[])).finally(()=>{U.current=null});return U.current=F,F},[A,g]);u.useEffect(()=>{if(!p||!j)return;const F=K.current;if(F){const ue=()=>{ms()};return F.addEventListener("focus",ue),()=>F.removeEventListener("focus",ue)}},[p,j,ms]),u.useEffect(()=>{if(!A)return;const F=K.current;if(F){const ue=()=>{Vs()};return F.addEventListener("focus",ue),()=>F.removeEventListener("focus",ue)}},[A,Vs]);const Lr=(F,ue)=>{const Ae=F.substring(0,ue),Te=Ae.lastIndexOf("@");if(Te===-1)return null;const Se=Ae.substring(Te+1);return Se.includes(" ")||Se.includes(`
|
|
127
|
+
`)?null:{triggerIndex:Te,query:Se,type:"file"}},Or=(F,ue)=>{const Ae=F.substring(0,ue),Te=Ae.lastIndexOf("/");if(Te===-1)return null;const Se=Ae.substring(0,Te);if(Se.trim()!==""&&!Se.endsWith(`
|
|
128
|
+
`)&&!Se.endsWith(" "))return null;const Xe=Ae.substring(Te+1);return Xe.includes(" ")||Xe.includes(`
|
|
129
|
+
`)?null:{triggerIndex:Te,query:Xe,type:"command"}},Dr=F=>{if(!be)return[];if(!F)return be.slice(0,50);const ue=F.toLowerCase();return be.filter(Ae=>Ae.name.toLowerCase().includes(ue)).slice(0,50)},wn=F=>{if(!Ce)return[];if(!F)return Ce.slice(0,50);const ue=F.toLowerCase();return Ce.filter(Ae=>Ae.name.toLowerCase().includes(ue)).slice(0,50)},Et=()=>{Ee({isActive:!1,triggerIndex:-1,query:"",suggestions:[],focusedIndex:-1,type:"file"})},Bs=F=>{if(!K.current)return;const ue=K.current.selectionStart;if(je.type==="command"){const Ae=P.substring(0,je.triggerIndex)+F+" "+P.substring(ue);de(Ae),Et(),setTimeout(()=>{if(K.current){const Te=je.triggerIndex+F.length+1;K.current.setSelectionRange(Te,Te),K.current.focus(),Wt()}},0)}else{const Ae=P.substring(0,je.triggerIndex+1)+F+" "+P.substring(ue);de(Ae),Et(),setTimeout(()=>{if(K.current){const Te=je.triggerIndex+1+F.length+1;K.current.setSelectionRange(Te,Te),K.current.focus(),Wt()}},0)}},$r=F=>{const ue=F.target.value;de(ue),Wt();const Ae=F.target.selectionStart,Te=Or(ue,Ae);if(Te&&A){Ce.length===0&&Vs();const Se=wn(Te.query);Ee(Xe=>({isActive:!0,triggerIndex:Te.triggerIndex,query:Te.query,suggestions:Se,type:Te.type,focusedIndex:Xe.focusedIndex>=0&&Xe.focusedIndex<Se.length?Xe.focusedIndex:-1}));return}if(p){const Se=Lr(ue,Ae);if(Se){be.length===0&&ms();const Xe=Dr(Se.query);Ee(it=>({isActive:!0,triggerIndex:Se.triggerIndex,query:Se.query,suggestions:Xe,type:Se.type,focusedIndex:it.focusedIndex>=0&&it.focusedIndex<Xe.length?it.focusedIndex:-1}));return}}Et()},Je=()=>{const F=P.trim();if(!F&&!z||ee)return;const ue=z?W():void 0,Ae=`${se}-backup`;try{localStorage.setItem(Ae,P)}catch{}r(F,{workingDirectory:g||void 0,attachments:ue}),de(""),oa.set(se,""),O(),Et()},rt=F=>{if(je.isActive)switch(F.key){case"ArrowDown":F.preventDefault(),je.suggestions.length>0&&Ee(ue=>({...ue,focusedIndex:ue.focusedIndex<0?0:(ue.focusedIndex+1)%ue.suggestions.length}));break;case"ArrowUp":F.preventDefault(),je.suggestions.length>0&&Ee(ue=>({...ue,focusedIndex:ue.focusedIndex<0||ue.focusedIndex===0?ue.suggestions.length-1:ue.focusedIndex-1}));break;case"Enter":case"Tab":if(!F.metaKey&&!F.ctrlKey&&(F.preventDefault(),je.suggestions.length>0)){const ue=je.focusedIndex>=0?je.focusedIndex:0,Ae=je.suggestions[ue],Te=(je.type==="command",Ae.name);Bs(Te)}break;case" ":Et();break;case"Escape":F.preventDefault(),Et(),setTimeout(()=>K.current?.focus(),0);break}else if(F.key==="Enter"){if(F.shiftKey)return;F.preventDefault(),Je()}else F.key==="c"&&F.ctrlKey&&(b||y)&&(F.preventDefault(),x?.())},Wt=()=>{const F=K.current;if(F){F.style.height="auto";const ue=Math.floor(window.innerHeight*.8);F.style.height=`${Math.min(F.scrollHeight,ue)}px`}};u.useEffect(()=>Wt(),[P]),u.useEffect(()=>{const F=()=>Wt();return window.addEventListener("resize",F),()=>window.removeEventListener("resize",F)},[]);const _n=F=>{if(!d)return;const ue=Array.from(F.clipboardData.files);ue.length>0&&(F.preventDefault(),Z(ue))},kn=F=>{d&&(F.preventDefault(),F.stopPropagation(),ze(!0))},Kt=F=>{d&&(F.preventDefault(),F.stopPropagation(),F.currentTarget.contains(F.relatedTarget)||ze(!1))},hs=F=>{if(!d)return;F.preventDefault(),F.stopPropagation(),ze(!1);const ue=Array.from(F.dataTransfer.files);ue.length>0&&Z(ue)},fs=F=>{F.target.files&&F.target.files.length>0&&(Z(F.target.files),F.target.value="")},ot=w||v?{border:"border-composer-caution dark:border-composer-caution/60",bg:"bg-composer-caution/30 dark:bg-composer-caution/10",borderInner:"border-composer-caution/60 dark:border-composer-caution/25",text:"text-composer-caution",textDim:"text-composer-caution dark:text-composer-caution/70"}:b?{border:"border-composer-active dark:border-composer-active/60",bg:"bg-composer-active/30 dark:bg-composer-active/10",borderInner:"border-composer-active/60 dark:border-composer-active/25",text:"text-composer-active",textDim:"text-composer-active dark:text-composer-active/70"}:S&&y?{border:"border-violet-400 dark:border-violet-400/60",bg:"bg-violet-400/30 dark:bg-violet-400/10",borderInner:"border-violet-400/60 dark:border-violet-400/25",text:"text-violet-500 dark:text-violet-300",textDim:"text-violet-500/70 dark:text-violet-300/70"}:y?{border:"border-composer-ready dark:border-composer-ready/40",bg:"bg-composer-ready/25 dark:bg-composer-ready/5",borderInner:"border-composer-ready/50 dark:border-composer-ready/15",text:"text-composer-ready",textDim:"text-composer-ready dark:text-composer-ready/60"}:{border:"border-composer-border",bg:"bg-composer-muted/15 dark:bg-composer-muted/5",borderInner:"border-composer-border/50",text:"text-composer-muted",textDim:"text-composer-muted/70 dark:text-composer-muted/40"};return s.jsx(m_,{children:s.jsxs("div",{ref:fe,className:R("w-full relative",e.className),children:[d&&s.jsx("input",{ref:M,type:"file",multiple:!0,accept:T_,className:"hidden",onChange:fs}),s.jsxs("div",{"data-composer-status":w?"starting":v?"stopping":b?"active":y?"ready":"off",className:R("relative rounded-md overflow-hidden border bg-composer-surface/85 backdrop-blur-sm transition-all duration-200",m?ot.border:"border-composer-border/70"),children:[m&&s.jsxs("div",{className:R("relative flex min-h-[36px] sm:min-h-[44px] items-center justify-between gap-1.5 sm:gap-2 px-2 sm:px-3 py-1 sm:py-1.5 border-b",ot.bg,ot.borderInner),children:[s.jsx("div",{className:"flex items-center gap-1.5 sm:gap-2 shrink-0",children:w?s.jsxs(s.Fragment,{children:[s.jsx(at,{size:12,className:R("animate-spin",ot.text)}),s.jsx("span",{className:R("text-[8px] sm:text-[10px] font-semibold uppercase tracking-wider",ot.text),children:"Starting"})]}):v?s.jsxs(s.Fragment,{children:[s.jsx(at,{size:12,className:R("animate-spin",ot.text)}),s.jsx("span",{className:R("text-[8px] sm:text-[10px] font-semibold uppercase tracking-wider",ot.text),children:"Stopping"})]}):b?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"relative flex h-2 w-2",children:[s.jsx("span",{className:R("animate-ping absolute inline-flex h-full w-full rounded-full opacity-75","bg-composer-active")}),s.jsx("span",{className:R("relative inline-flex rounded-full h-2 w-2","bg-composer-active")})]}),s.jsx("span",{className:R("text-[8px] sm:text-[10px] font-semibold uppercase tracking-wider",ot.text),children:"Working"}),Ct&&s.jsx("span",{className:R("text-[8px] sm:text-[10px] font-mono tabular-nums",ot.textDim),children:nt})]}):S&&y?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"relative flex h-2 w-2",children:[s.jsx("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-violet-400 dark:bg-violet-400 opacity-50"}),s.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-violet-400/70 dark:bg-violet-400/70"})]}),s.jsx("span",{className:"text-[8px] sm:text-[10px] font-semibold uppercase tracking-wider text-violet-500/70 dark:text-violet-300/70",children:"Sleeping"}),oe&&s.jsx("span",{className:"text-[8px] sm:text-[10px] font-mono tabular-nums text-violet-500/50 dark:text-violet-300/50",children:oe})]}):N&&y?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"relative flex h-2 w-2",children:[s.jsx("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-composer-caution opacity-50"}),s.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-composer-caution/70"})]}),s.jsx("span",{className:"text-[8px] sm:text-[10px] font-semibold uppercase tracking-wider text-composer-caution/70",children:"Waiting for background task"})]}):y?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"relative flex h-2 w-2",children:s.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-composer-ready dark:bg-composer-ready/50"})}),s.jsx("span",{className:"text-[8px] sm:text-[10px] font-semibold uppercase tracking-wider text-composer-ready dark:text-composer-ready/60",children:"Ready"})]}):s.jsx("span",{className:"text-[8px] sm:text-[10px] font-semibold uppercase tracking-wider text-composer-text-faint",children:"Idle"})}),s.jsxs("div",{className:"flex items-center gap-1 sm:gap-2 min-w-0 shrink",children:[$&&(()=>{const F=$.contextTokens??$.inputTokens+$.cacheCreationInputTokens+$.cacheReadInputTokens,ue=F>=5e5?"text-red-500 dark:text-red-400":F>=2e5?"text-amber-500 dark:text-amber-400":b?"text-composer-active":y?"text-composer-ready":"text-composer-muted";return s.jsx("div",{className:"flex items-center rounded-sm border border-composer-border/50 bg-composer-surface-elevated/50 p-0.5","data-testid":"token-usage",children:s.jsxs("span",{className:R("px-1.5 sm:px-3 py-0.5 sm:py-1 text-[8px] sm:text-[10px] font-semibold uppercase tracking-wider whitespace-nowrap",ue),"data-tokens":F,children:[E_(F)," tokens"]})})})(),L.length>0&&s.jsxs(h_,{children:[s.jsx(f_,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:()=>Me(!0),className:"px-1.5 sm:px-2 py-0.5 sm:py-1 rounded-sm border border-composer-caution/35 bg-composer-caution/10 text-composer-caution text-[8px] sm:text-[10px] font-semibold uppercase tracking-wider hover:border-composer-caution/60 hover:bg-composer-caution/20 transition-colors cursor-pointer whitespace-nowrap",children:["Queue ",L.length]})}),s.jsx(ip,{side:"top",children:s.jsx("p",{children:"Per-session message queue. These auto-send in order when the current run finishes."})})]})]})]}),s.jsxs("div",{className:R("flex flex-col items-center justify-center w-full bg-transparent cursor-text relative",he&&"ring-2 ring-composer-active/50 ring-inset bg-composer-active/5"),onDragOver:kn,onDragLeave:Kt,onDrop:hs,children:[he&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-composer-active/10 z-10 pointer-events-none",children:s.jsxs("div",{className:"flex items-center gap-2 text-composer-active font-medium",children:[s.jsx(Bg,{size:20}),s.jsx("span",{children:"Drop files to attach"})]})}),z&&s.jsxs("div",{className:"flex gap-2 px-3 py-2 w-full border-b border-composer-border/50 overflow-x-auto",children:[q.map(F=>s.jsxs("div",{className:"relative group flex-shrink-0 flex items-center gap-1.5 px-2 py-1 rounded bg-composer-surface-elevated/50 border border-composer-border/50",children:[F.type==="image"?s.jsx(Ra,{size:14,className:"text-composer-active"}):s.jsx(jt,{size:14,className:"text-composer-caution"}),s.jsx("span",{className:"text-xs text-composer-text-secondary max-w-[100px] truncate",children:F.name}),F.status==="processing"&&s.jsx(at,{size:12,className:"animate-spin text-composer-text-secondary"}),F.status==="error"&&s.jsx("span",{className:"text-composer-danger text-xs",children:"!"}),s.jsx("button",{type:"button",onClick:()=>me(F.id),className:"ml-1 p-0.5 rounded hover:bg-composer-danger/20 text-composer-text-secondary hover:text-composer-danger transition-colors",children:s.jsx(yr,{size:12})})]},F.id)),re&&s.jsx("span",{className:"text-xs text-composer-danger self-center",children:re})]}),s.jsxs("div",{className:"relative flex w-full min-h-[44px] items-center",children:[s.jsx("div",{className:"relative flex flex-1 min-h-[44px] items-center",children:s.jsx("textarea",{ref:K,"data-testid":"composer-input",className:"max-h-[80vh] w-full border-none bg-transparent text-composer-text leading-relaxed resize-none outline-none overflow-y-auto min-h-[40px] py-2 pl-12 pr-28 text-sm tracking-[0.01em] placeholder:text-composer-text-faint",placeholder:i,value:P,onChange:$r,onKeyDown:rt,onPaste:_n,rows:1,disabled:l})}),d&&s.jsx("div",{className:"absolute flex items-center justify-center left-1.5 bottom-1.5",children:s.jsx("button",{type:"button",onClick:()=>M.current?.click(),disabled:l,"aria-label":"Add attachment",className:"flex h-8 w-8 items-center justify-center rounded-sm border border-composer-active dark:border-composer-active/30 text-composer-active transition-all duration-100 hover:border-composer-active hover:bg-composer-active/20 dark:hover:bg-composer-active/5 disabled:opacity-45 disabled:cursor-not-allowed",children:s.jsx(Hg,{size:14})})}),s.jsx("div",{className:"absolute flex items-center justify-center gap-2 right-1.5 bottom-1.5",children:b||y?s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("button",{type:"button","data-testid":"send-button",className:R("h-8 w-8 flex items-center justify-center rounded-sm border transition-all duration-100",P.trim()||z?"border-composer-active dark:border-composer-active/40 text-composer-active hover:border-composer-active hover:bg-composer-active/20 dark:hover:bg-composer-active/10":"border-composer-border text-composer-text-faint cursor-not-allowed"),disabled:!P.trim()&&!z||l||ee,onClick:Je,"aria-label":"Send message",children:s.jsx($o,{size:14})}),(b||v)&&s.jsxs("button",{type:"button",className:R("relative h-8 flex items-center justify-center gap-1 rounded-sm border text-[10px] font-semibold uppercase tracking-wider transition-all duration-100",v?"px-2":"w-8",v?"border-composer-caution/50 text-composer-caution bg-composer-caution/10":"border-composer-danger/30 text-composer-danger hover:border-composer-danger hover:bg-composer-danger/5"),onClick:()=>f?.(),"data-testid":"stop-button","aria-label":v?"Stop requested":"Stop session",children:[v?s.jsx(at,{size:14,className:"animate-spin"}):s.jsx(Kg,{size:14}),v&&s.jsx("span",{className:"hidden sm:inline",children:"Stopping"})]})]}):s.jsxs("div",{className:"flex items-center gap-2",children:[h&&s.jsx("button",{type:"button",onClick:()=>ye(!ie),title:"Menu",className:R("flex items-center justify-center px-2 h-8 rounded-sm border transition-all duration-100 cursor-pointer",ie?"bg-composer-surface-elevated border-composer-border text-composer-text-secondary":"border-composer-border text-composer-text-faint hover:border-composer-text-faint hover:text-composer-text-secondary hover:bg-composer-surface-elevated/50"),children:s.jsx(wg,{size:14})}),s.jsx("button",{type:"button","data-testid":"send-button",disabled:!P.trim()&&!z||l||ee,onClick:Je,className:R("flex items-center justify-center h-8 w-8 rounded-sm border transition-all duration-100 cursor-pointer",!P.trim()&&!z||l||ee?"border-composer-border text-composer-text-faint cursor-not-allowed":"border-composer-active dark:border-composer-active/50 text-composer-active hover:border-composer-active hover:bg-composer-active/20 dark:hover:bg-composer-active/10"),children:s.jsx($o,{size:14})})]})})]}),s.jsx(Mw,{open:Ne,onOpenChange:Me,children:s.jsxs(Mu,{className:"max-w-lg",children:[s.jsxs(Ow,{children:[s.jsxs(Dw,{className:"text-sm font-semibold uppercase tracking-wider text-composer-caution",children:["Queued Messages (",L.length,")"]}),s.jsx($w,{className:"text-xs text-composer-text-secondary",children:"Per-session queue. These auto-send in order when the current run finishes."})]}),s.jsx("div",{className:"max-h-[55vh] overflow-y-auto space-y-2 pr-1",children:L.map(F=>s.jsxs("div",{className:"border border-composer-border/50 rounded-sm px-2.5 py-2 bg-composer-surface/80",children:[s.jsx("p",{className:"text-xs text-composer-text whitespace-pre-wrap break-words",children:F.content}),s.jsx("p",{className:"text-[10px] text-composer-text-faint mt-1 font-mono",children:F.status==="dispatching"?"sending...":`queued ${new Date(F.timestamp).toLocaleTimeString()}`})]},F.id))})]})})]})]}),h&&ie&&e.renderMenu?.({onClose:()=>ye(!1)}),(p||A)&&s.jsx(S_,{suggestions:je.suggestions,onSelect:Bs,onClose:Et,isOpen:je.isActive&&je.suggestions.length>0,focusedIndex:je.focusedIndex,type:je.type,onFocusReturn:()=>K.current?.focus()})]})})});class Zs extends u.Component{constructor(e){super(e),this.state={hasError:!1,error:null,showStack:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,n){console.error(`[ErrorBoundary${this.props.name?`:${this.props.name}`:""}] Caught error:`,e,`
|
|
130
|
+
Component stack:`,n.componentStack),this.props.onError?.(e,n)}reset=()=>{this.setState({hasError:!1,error:null,showStack:!1})};toggleStack=()=>{this.setState(e=>({showStack:!e.showStack}))};render(){return this.state.hasError&&this.state.error?typeof this.props.fallback=="function"?this.props.fallback(this.state.error,this.reset):this.props.fallback?this.props.fallback:this.props.inline?s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-red-400 text-sm",children:[s.jsx(kt,{size:14}),s.jsxs("span",{children:["Error",this.props.name?` in ${this.props.name}`:""]}),s.jsx("button",{onClick:this.reset,className:"text-red-300 hover:text-red-200 underline",children:"retry"})]}):s.jsxs("div",{className:"my-2 border border-red-500/30 rounded-lg overflow-hidden bg-red-500/5",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-red-500/20",children:[s.jsx(kt,{size:14,className:"text-red-400 flex-shrink-0"}),s.jsxs("span",{className:"text-xs font-semibold uppercase tracking-wider text-red-400",children:["Render Error",this.props.name?` - ${this.props.name}`:""]}),s.jsxs("button",{onClick:this.reset,className:"ml-auto flex items-center gap-1 px-2 py-1 text-xs text-red-300 hover:text-red-200 hover:bg-red-500/10 rounded transition-colors",children:[s.jsx(ds,{size:12}),"Retry"]})]}),s.jsxs("div",{className:"px-3 py-2",children:[s.jsx("p",{className:"text-sm text-red-200 font-medium",children:this.state.error.message}),this.state.error.stack&&s.jsxs("div",{className:"mt-2",children:[s.jsxs("button",{onClick:this.toggleStack,className:"flex items-center gap-1 text-xs text-red-400/70 hover:text-red-400 transition-colors",children:[this.state.showStack?s.jsx(Nh,{size:12}):s.jsx(Lt,{size:12}),this.state.showStack?"Hide":"Show"," stack trace"]}),this.state.showStack&&s.jsx("pre",{className:"mt-2 text-xs text-red-300/60 font-mono whitespace-pre-wrap overflow-x-auto max-h-48 overflow-y-auto",children:this.state.error.stack})]})]})]}):this.props.children}}function A_({error:t,reset:e}){return s.jsx("div",{className:"min-h-dvh bg-background flex items-center justify-center p-4",children:s.jsx("div",{className:"max-w-md w-full",children:s.jsxs("div",{className:"border border-red-500/30 rounded-lg overflow-hidden bg-red-500/5",children:[s.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-red-500/20",children:[s.jsx(kt,{size:18,className:"text-red-400"}),s.jsx("span",{className:"text-sm font-semibold text-red-400",children:"Application Error"})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:"Something went wrong while rendering the application."}),s.jsx("p",{className:"text-sm text-red-200 font-mono bg-red-500/10 px-3 py-2 rounded",children:t.message}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{onClick:e,className:"flex items-center gap-2 px-4 py-2 bg-red-500/20 hover:bg-red-500/30 text-red-200 rounded transition-colors",children:[s.jsx(ds,{size:14}),"Try Again"]}),s.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 text-muted-foreground hover:text-foreground transition-colors",children:"Reload Page"})]})]})]})})})}const R_=Ie.lazy(async()=>({default:(await _(()=>import("./CodeHighlight-BFCEx5SO.js"),__vite__mapDeps([105,102,104,103]))).CodeHighlight}));function Rc({code:t,className:e=""}){return s.jsx("pre",{className:$e("m-0 overflow-x-auto bg-zinc-950 px-3 py-2.5 font-mono text-[10px] leading-relaxed text-zinc-400",e),children:s.jsx("code",{children:t.trimEnd()})})}function P_(t){return s.jsx(Zs,{inline:!0,name:"CodeHighlight",fallback:s.jsx(Rc,{code:t.code,className:t.className}),children:s.jsx(u.Suspense,{fallback:s.jsx(Rc,{code:t.code,className:t.className}),children:s.jsx(R_,{...t})})})}const M_={},L_={};function Pc({src:t,alt:e="Attached",className:n="max-w-[200px] max-h-[200px] rounded border border-zinc-600 object-contain"}){const[r,o]=u.useState(!0),[a,i]=u.useState(!1),l=u.useCallback(()=>o(!1),[]),c=u.useCallback(()=>{o(!1),i(!0)},[]);return a?s.jsx("div",{className:`${n} flex items-center justify-center bg-zinc-800/50`,children:s.jsx("span",{className:"text-xs text-zinc-500",children:"Failed to load"})}):s.jsxs("div",{className:"relative inline-block",children:[r&&s.jsx("div",{className:`${n} flex items-center justify-center bg-zinc-800/50 absolute inset-0`,children:s.jsx(Re,{size:20,className:"animate-spin text-cyan-400"})}),s.jsx("img",{src:t,alt:e,className:`${n} ${r?"invisible":"visible"}`,onLoad:l,onError:c})]})}function O_(t){return t.replace(/<!--\s*NEXT_STEPS\s*\n[\s\S]*?-->/g,"").trim()}function D_(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function $_(t,e){if(typeof t=="string"){const r=t.trim();if(r.length>0&&r.toLowerCase()!=="unknown")return r}const n=[e.tool_name,e.toolName,e.recipient_name,e.recipientName];for(const r of n)if(typeof r=="string"){const o=r.trim();if(o.length>0&&o.toLowerCase()!=="unknown")return o}return"Tool"}function z_(t){const e=[],n=/`?★\s*Insight\s*─+`?\s*([\s\S]*?)\s*`?─{5,}`?/g;let r=0,o;for(;(o=n.exec(t))!==null;){if(o.index>r){const a=t.slice(r,o.index).trim();a&&e.push({type:"text",content:a})}e.push({type:"insight",content:o[1].trim()}),r=o.index+o[0].length}if(r<t.length){const a=t.slice(r).trim();a&&e.push({type:"text",content:a})}return e.length===0&&e.push({type:"text",content:t}),e}function F_(t){return t.replace(/^(\d+)\./gm,"$1\\.")}function Mc({text:t,markdownComponents:e}){const n=z_(t),[r,o]=u.useState(!1),a=l=>{l.stopPropagation();const c=document.createElement("textarea");c.value=t,c.style.position="fixed",c.style.left="-9999px",c.style.top="-9999px",document.body.appendChild(c),c.focus(),c.select();try{document.execCommand("copy"),o(!0),setTimeout(()=>o(!1),2e3)}catch(d){console.error("Failed to copy:",d)}document.body.removeChild(c)},i=s.jsxs("div",{className:"border border-blue-500/15 rounded-lg overflow-hidden bg-blue-500/5 w-fit max-w-full",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-blue-500/10",children:[s.jsx(as,{size:12,className:"text-blue-400/80 flex-shrink-0"}),s.jsx("span",{className:"text-[11px] text-zinc-400 font-medium",children:"Agent"}),s.jsx("div",{className:"flex-1"}),s.jsx("button",{type:"button",onClick:a,onPointerDown:l=>l.stopPropagation(),className:"p-1 rounded hover:bg-zinc-800/40 text-zinc-600 hover:text-zinc-400 opacity-100 sm:opacity-0 sm:group-hover/response:opacity-100 transition-opacity touch-manipulation",title:r?"Copied!":"Copy response",children:r?s.jsx(Oe,{size:12,className:"text-green-500"}):s.jsx(Vt,{size:12})})]}),s.jsx("div",{className:"px-3 py-2 prose max-w-none text-[13px] leading-relaxed dark:prose-invert",children:n.map((l,c)=>l.type==="insight"?s.jsx("div",{className:"my-3 not-prose",children:s.jsxs("div",{className:"border border-zinc-800/40 rounded-lg overflow-hidden bg-zinc-900/30",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-zinc-800/40",children:[s.jsx(_a,{size:12,className:"text-yellow-400/80 flex-shrink-0"}),s.jsx("span",{className:"text-[10px] text-zinc-400 font-medium",children:"Insight"})]}),s.jsx("div",{className:"px-3 py-2 prose max-w-none text-[13px] leading-relaxed dark:prose-invert",children:s.jsx(Eo,{remarkPlugins:[Cs],components:e,children:l.content})})]})},c):s.jsx(Eo,{remarkPlugins:[Cs],components:e,children:F_(l.content)},c))})]});return s.jsx("div",{className:"group/response relative",children:i})}const V_=[{pattern:/^\/prototype\/(.+)$/,getInfo:t=>({label:t[1].replace(/-/g," ").replace(/\b\w/g,e=>e.toUpperCase()),icon:Hl})},{pattern:/^\/c\/([a-f0-9-]+)$/,getInfo:t=>({label:`Session ${t[1].slice(0,8)}`,icon:If})},{pattern:/^\/dev$/,getInfo:()=>({label:"Dev Hub",icon:ka})},{pattern:/^\/session\/([a-f0-9-]+)\/review$/,getInfo:t=>({label:`Analysis ${t[1].slice(0,8)}`,icon:vi})},{pattern:/^\/analysis\/cross-session$/,getInfo:()=>({label:"Cross-session analysis",icon:vi})}];function Lc(t){if(!t)return null;let e;if(t.startsWith("/"))e=t;else try{const n=new URL(t),r=n.hostname;if(!(r==="localhost"||r==="127.0.0.1"||/^\d+\.\d+\.\d+\.\d+$/.test(r)))return null;e=n.pathname}catch{return null}for(const{pattern:n,getInfo:r}of V_){const o=e.match(n);if(o)return{path:e,...r(o)}}return null}function Oc({route:t}){return s.jsxs("a",{href:t.path,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 not-prose px-3 py-1 my-0.5 rounded-sm border border-cyan-500/40 bg-cyan-500/20 hover:bg-cyan-500/30 active:bg-cyan-500/35 transition-all duration-100 no-underline select-none align-middle cursor-pointer",style:{touchAction:"manipulation"},children:[s.jsx(t.icon,{size:11,className:"text-cyan-300 flex-shrink-0"}),s.jsx("span",{className:"text-[10px] font-display font-bold uppercase tracking-wider text-cyan-300 truncate max-w-[200px]",children:t.label}),s.jsx(os,{size:9,className:"text-cyan-300/40 flex-shrink-0"})]})}const lo={a({href:t,children:e}){const n=Lc(t);if(n)return s.jsx(Oc,{route:n});const r=t?.startsWith("/");return s.jsx("a",{href:t,target:r?void 0:"_blank",rel:r?void 0:"noopener noreferrer",className:"text-cyan-400 hover:text-cyan-300 underline underline-offset-2",children:e})},table({children:t}){return s.jsx("div",{className:"my-3 not-prose",children:s.jsx("div",{className:"border border-zinc-800/40 rounded-lg overflow-hidden bg-zinc-900/30",children:s.jsx("div",{className:"overflow-x-auto",children:s.jsx("table",{className:"w-full text-sm",children:t})})})})},thead({children:t}){return s.jsx("thead",{className:"bg-zinc-800/20 border-b border-zinc-800/40",children:t})},tbody({children:t}){return s.jsx("tbody",{className:"divide-y divide-zinc-800/40",children:t})},tr({children:t}){return s.jsx("tr",{className:"hover:bg-zinc-800/20 transition-colors",children:t})},th({children:t}){return s.jsx("th",{className:"px-3 py-2 text-left text-xs font-semibold uppercase tracking-wider text-zinc-400",children:t})},td({children:t}){return s.jsx("td",{className:"px-3 py-2 text-foreground",children:t})},code({node:t,inline:e,className:n,children:r,...o}){const a=/language-(\w+)/.exec(n||""),i=a?a[1]:"text";if(!e&&a)return s.jsx(P_,{code:String(r).replace(/\n$/,""),language:i,className:"rounded-md overflow-hidden max-w-full box-border"});const l=String(r).trim();if(/^https?:\/\//.test(l)){const c=Lc(l);if(c)return s.jsx(Oc,{route:c})}return s.jsx("code",{className:n,...o,children:r})}};function cp({message:t,toolResults:e=M_,childrenMessages:n=L_,expandedTasks:r=new Set,onToggleTaskExpanded:o,isFirstInGroup:a=!0,isLastInGroup:i=!0,isStreaming:l=!1,currentQuestionRequest:c,onAnswerQuestion:d,onPlanApprove:p,onPlanReject:m,planOutcomes:h}){const g=u.useRef(l),[f,x]=u.useState(new Set),[b,y]=u.useState(!1);if(u.useMemo(()=>{if(!Array.isArray(t.content))return{};const v={};return t.content.forEach(w=>{if(w&&typeof w=="object"&&w.type==="tool_result"){const N=w.tool_use_id;if(N){const S=w.content,T=(Array.isArray(S),S);v[N]={status:"completed",result:typeof T=="string"||Array.isArray(T)?T:void 0,is_error:w.is_error}}}}),v},[t.content]),t.type==="user"){let v=typeof t.content=="string"?t.content:Array.isArray(t.content)?t.content.filter(A=>A.type==="text").map(A=>A.text||"").join(`
|
|
131
|
+
`):"";v=v.trim();const w=Array.isArray(t.content)?t.content.filter(A=>A.type==="image"||A.type==="document"):[];if(!v&&w.length===0)return null;const N=v.split(`
|
|
132
132
|
`),S=N.length>8,T=b?N:N.slice(0,8),C=N.length-8,j=T.join(`
|
|
133
|
-
`),E=s.jsxs("div",{className:"group/user relative border border-cyan-500/15 rounded-lg overflow-hidden bg-cyan-500/5 w-full",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-cyan-500/10",children:[s.jsx(Jl,{size:12,className:"text-cyan-400/80 flex-shrink-0"}),s.jsx("span",{className:"text-[11px] text-zinc-400 font-medium",children:"User"}),s.jsx("div",{className:"flex-1"}),S&&s.jsx("button",{onClick:()=>y(!b),className:"w-5 h-5 border-none bg-transparent text-zinc-500 cursor-pointer flex items-center justify-center p-0 hover:text-zinc-300","aria-label":b?"Show fewer lines":"Show all lines",children:b?s.jsx(Pf,{size:14}):s.jsx(Sf,{size:14})})]}),s.jsxs("div",{className:"px-3 py-2 text-[13px] leading-relaxed text-foreground",children:[w.length>0&&s.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:w.map((
|
|
134
|
-
`,"... +",C," lines"]})]})]})]});return s.jsx("div",{className:"flex justify-end w-full my-1","data-testid":"user-message",children:s.jsx("div",{className:"max-w-[80%] min-w-[100px]",children:E})})}if(t.type==="assistant"){const v=e||{},w=()=>{if(typeof t.content=="string")return s.jsx("div",{children:s.jsx(Mc,{text:t.content,markdownComponents:lo})});if(Array.isArray(t.content)){const N=t.content,S=[],T=new Map,C=j=>{if(j.type==="tool_use"&&typeof j.id=="string"&&j.id.length>0)return`${t.messageId}-tool_use-${j.id}`;if(j.type==="tool_result"&&typeof j.tool_use_id=="string"&&j.tool_use_id.length>0)return`${t.messageId}-tool_result-${j.tool_use_id}`;const E=T.get(j.type)??0;return T.set(j.type,E+1),`${t.messageId}-${j.type}-${E}`};return N.forEach(j=>{const E=C(j);if(j.type!=="tool_result"){if(j.type==="text"){const R=O_(typeof j.text=="string"?j.text:"");if(!R)return;S.push(s.jsx("div",{children:s.jsx(Mc,{text:R,markdownComponents:lo})},E));return}if(j.type==="thinking"){S.push(s.jsx("div",{className:"max-w-lg","data-testid":"thinking-block",children:s.jsxs("div",{className:"border border-amber-500/20 rounded-lg overflow-hidden bg-amber-500/5",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-amber-500/10",children:[s.jsx(yh,{size:12,className:"text-amber-400/80 flex-shrink-0"}),s.jsx("span",{className:"text-[11px] text-zinc-400 font-medium",children:"Thinking"})]}),s.jsx("div",{className:"px-3 py-2 prose max-w-none text-[13px] leading-relaxed text-muted-foreground dark:prose-invert",children:s.jsx(Eo,{remarkPlugins:[Cs],components:lo,children:typeof j.thinking=="string"?j.thinking:""})})]})},E));return}if(j.type==="tool_use"){const R=typeof j.id=="string"?j.id:"";if(!R)return;const O=D_(j.input)?j.input:{},$=$_(j.name,O),re=v[R];if(re?.is_error){const V=typeof re.result=="string"?re.result:"";if($==="AskUserQuestion"||V.toLowerCase().includes("answer questions?"))return}const ne=c?.toolUseId===R?c?.id:void 0;S.push(s.jsx("div",{className:"w-full",children:s.jsx(s1,{toolUse:{type:"tool_use",id:R,name:$,input:O},toolResult:re,toolResults:v,workingDirectory:t.workingDirectory,childrenMessages:n,questionId:ne,onAnswerQuestion:d,isStreaming:l,onPlanApprove:p,onPlanReject:m,planOutcomes:h,renderChildMessage:V=>s.jsx(cp,{message:V,toolResults:v,childrenMessages:n,isStreaming:l},V.messageId)})},E));return}if(j.type==="image"){const R=j.source,O=R.type==="base64"?`data:${R.media_type};base64,${R.data}`:R.url;S.push(s.jsx("div",{children:s.jsxs("div",{className:"inline-block border border-zinc-800/40 rounded-lg overflow-hidden bg-zinc-900/30",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-zinc-800/40",children:[s.jsx(af,{size:12,className:"text-zinc-600"}),s.jsx("span",{className:"text-[11px] text-zinc-600",children:"Image"})]}),s.jsx("div",{className:"p-2",children:s.jsx(Pc,{src:O,alt:"Attached image",className:"max-w-md max-h-96 rounded object-contain"})})]})},E))}if(j.type==="document"){S.push(s.jsx("div",{children:s.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg border border-zinc-800/40 bg-zinc-900/30",children:[s.jsx(Po,{size:14,className:"text-zinc-500"}),s.jsx("span",{className:"text-xs text-zinc-400",children:"PDF Document"})]})},E));return}S.push(s.jsx("div",{children:s.jsxs("div",{className:"border border-zinc-800/40 rounded-lg overflow-hidden bg-zinc-900/30",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-zinc-800/40",children:[s.jsx(Io,{size:14,className:"text-zinc-400 flex-shrink-0"}),s.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-400",children:"Data"})]}),s.jsx("div",{className:"px-3 py-2 text-[13px] leading-relaxed text-foreground",children:s.jsx(Pi,{data:j})})]})},E))}}),S}return s.jsx("div",{children:s.jsxs("div",{className:"border border-zinc-800/40 rounded-lg overflow-hidden bg-zinc-900/30",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-zinc-800/40",children:[s.jsx(Io,{size:14,className:"text-zinc-400 flex-shrink-0"}),s.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-400",children:"Data"})]}),s.jsx("div",{className:"px-3 py-2 text-[13px] leading-relaxed text-foreground",children:s.jsx(Pi,{data:t.content})})]})})};return s.jsx("div",{className:`relative w-full flex flex-col gap-1.5${g.current?" streaming-message":""}`,"data-testid":"assistant-message",children:w()})}return t.type==="error"?s.jsx("div",{children:s.jsxs("div",{className:"border border-red-500/30 rounded-lg overflow-hidden bg-red-500/5",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-red-500/10",children:[s.jsx(kt,{size:14,className:"text-red-400/80 flex-shrink-0"}),s.jsx("span",{className:"text-[11px] text-red-300/80 font-medium",children:"Error"})]}),s.jsx("div",{className:"px-3 py-2.5 text-[13px] text-red-200 font-mono whitespace-pre-wrap",children:String(t.content)})]})}):null}function Dc({isVisible:t,startTime:e}){const n=u.useRef(null),r=u.useRef([]),o=u.useRef([]),a=u.useRef(0),i=u.useRef(null),l=u.useRef(t),c=u.useRef(0),d=u.useRef(0);return u.useEffect(()=>{l.current=t},[t]),u.useEffect(()=>{if(t&&!a.current){const p=i.current;p&&(a.current=requestAnimationFrame(p))}},[t]),u.useEffect(()=>{const p=n.current;if(!p)return;const m=p.getContext("2d");if(!m)return;const h=80,g=32,f=Math.min(window.devicePixelRatio||1,2);p.width=Math.floor(h*f),p.height=Math.floor(g*f),m.setTransform(f,0,0,f,0,0);const x=16;r.current=[];for(let v=0;v<x;v++)r.current.push({x:8+Math.random()*(h-16),y:6+Math.random()*(g-12),vx:(Math.random()-.5)*.3,vy:(Math.random()-.5)*.3,radius:1.2+Math.random()*.8,pulsePhase:Math.random()*Math.PI*2,connections:[],activity:Math.random(),isFiring:!1,fireTimer:Math.random()*60});r.current.forEach((v,w)=>{const N=r.current.map((S,T)=>({index:T,distance:Math.hypot(v.x-S.x,v.y-S.y)})).filter(({index:S})=>S!==w).sort((S,T)=>S.distance-T.distance).slice(0,2).map(({index:S})=>S);v.connections=N});const b=(v,w,N)=>{const S=Math.random()*Math.PI*2,T=.3+Math.random()*.8;o.current.push({x:v,y:w,vx:Math.cos(S)*T,vy:Math.sin(S)*T,life:1,maxLife:12+Math.random()*10,hue:N})},y=()=>{const v=l.current;c.current+=((v?1:0)-c.current)*.06;const w=c.current;d.current+=.02;const N=d.current;if(m.clearRect(0,0,h,g),w<.01){a.current=0;return}const S=r.current,T=o.current;S.forEach(C=>{C.x+=C.vx,C.y+=C.vy,(C.x<=6||C.x>=h-6)&&(C.vx*=-1),(C.y<=4||C.y>=g-4)&&(C.vy*=-1),C.x=Math.min(h-6,Math.max(6,C.x)),C.y=Math.min(g-4,Math.max(4,C.y)),C.activity=.4+.6*Math.sin(N*3+C.pulsePhase),C.fireTimer-=1,v&&C.fireTimer<=0?(C.isFiring=!0,C.fireTimer=35+Math.random()*50,b(C.x,C.y,180+Math.random()*30)):(C.fireTimer<=0&&(C.fireTimer=35+Math.random()*50),C.isFiring=!1)});for(let C=T.length-1;C>=0;C--){const j=T[C];if(j.x+=j.vx,j.y+=j.vy,j.life-=1/j.maxLife,j.life<=0){T.splice(C,1);continue}const E=j.life*.5*w;m.fillStyle=`hsla(${j.hue}, 100%, 70%, ${E})`,m.beginPath(),m.arc(j.x,j.y,.8+j.life*.5,0,Math.PI*2),m.fill()}m.lineWidth=.5,S.forEach(C=>{C.connections.forEach(j=>{const E=S[j],R=C.isFiring||E.isFiring;if(R)m.strokeStyle=`rgba(0, 255, 255, ${(.35+Math.random()*.15)*w})`,m.lineWidth=1;else{const O=(C.activity+E.activity)/2;m.strokeStyle=`rgba(0, 200, 255, ${(.08+O*.12)*w})`,m.lineWidth=.4}if(m.beginPath(),m.moveTo(C.x,C.y),R){const O=(C.x+E.x)/2+(Math.random()-.5)*2,$=(C.y+E.y)/2+(Math.random()-.5)*2;m.quadraticCurveTo(O,$,E.x,E.y)}else m.lineTo(E.x,E.y);m.stroke()})}),S.forEach(C=>{const j=C.activity*.6+.3,E=C.isFiring,R=E?5:3,O=m.createRadialGradient(C.x,C.y,0,C.x,C.y,R);E?(O.addColorStop(0,`rgba(0, 255, 255, ${.6*w})`),O.addColorStop(.4,`rgba(0, 200, 255, ${.25*w})`),O.addColorStop(1,"rgba(0, 150, 255, 0)")):(O.addColorStop(0,`rgba(0, 200, 255, ${(.1+j*.15)*w})`),O.addColorStop(1,"rgba(0, 150, 255, 0)")),m.fillStyle=O,m.beginPath(),m.arc(C.x,C.y,R,0,Math.PI*2),m.fill();const $=(E?.85:.4+j*.25)*w;m.fillStyle=`rgba(${E?"150, 255, 255":"100, 220, 255"}, ${$})`,m.beginPath(),m.arc(C.x,C.y,E?C.radius*1.3:C.radius,0,Math.PI*2),m.fill()}),a.current=requestAnimationFrame(y)};return i.current=y,a.current=requestAnimationFrame(y),()=>{i.current=null,a.current&&(cancelAnimationFrame(a.current),a.current=0)}},[]),s.jsx("div",{className:`flex items-center gap-2 transition-opacity duration-300 ${t?"opacity-100":"opacity-0 pointer-events-none"}`,"aria-hidden":"true",children:s.jsx("canvas",{ref:n,className:"w-[80px] h-[32px]",style:{imageRendering:"auto"}})})}function B_({trigger:t}){const e=t==="manual";return s.jsx("div",{className:"flex items-center justify-center gap-3 my-4 px-4",children:s.jsxs("span",{className:"text-[10px] font-display font-bold uppercase tracking-wider text-amber-300/50",children:["Context Compacted",e?" · Manual":""]})})}const $c=96,lp=50,lr=50;function U_(t){const{sessionId:e,messages:n}=t,r=u.useRef(e),o=u.useRef(new Set),a=u.useRef(0),[i,l]=u.useState(!1),[c,d]=u.useState(new Map);return u.useEffect(()=>{e!==r.current&&(r.current=e,l(!1),o.current=new Set,a.current=0,d(new Map))},[e]),u.useEffect(()=>{n.length>0&&!i&&requestAnimationFrame(()=>{l(!0)})},[n.length,i]),u.useEffect(()=>{const p=new Set(n.map(x=>x.messageId||x.id).filter(Boolean)),m=new Map;let h=0;n.forEach(x=>{const b=x.messageId||x.id;b&&!o.current.has(b)&&m.set(b,h++)});const g=a.current;if(a.current=p.size,p.forEach(x=>o.current.add(x)),m.size===0||p.size<=g)return;d(m);const f=setTimeout(()=>{d(new Map)},300);return()=>clearTimeout(f)},[n]),{hasShownContent:i,newMessageIds:c}}function G_(t){const{sessionId:e,messages:n,isStreaming:r,scrollContainerRef:o}=t,[a,i]=u.useState(!1),[l,c]=u.useState(0),d=u.useRef(e),p=u.useRef(n.length),m=u.useRef(n[0]?.messageId),h=u.useRef(!1),g=u.useRef(!0),f=u.useRef(null),x=u.useRef(!1);u.useEffect(()=>{e!==d.current&&(d.current=e,g.current=!0,h.current=!1,x.current=!1,i(!1),c(0),requestAnimationFrame(()=>{o.current?.scrollTo({top:0,behavior:"auto"})}))},[e,o]),u.useEffect(()=>{if(r){const y=o.current;y&&Math.abs(y.scrollTop)<=$c&&(x.current=!1)}},[r,o]),u.useEffect(()=>{const y=o.current;if(!y)return;const v=()=>{const N=Math.abs(y.scrollTop)<=$c;g.current=N,N?(x.current=!1,i(!1),c(0)):(x.current=!0,r&&i(!0)),h.current=!0,f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{h.current=!1},150)};return y.addEventListener("scroll",v,{passive:!0}),()=>{y.removeEventListener("scroll",v),f.current&&clearTimeout(f.current)}},[r,o]),u.useEffect(()=>{const y=p.current,v=n.length>y,w=n.length-y,N=n[0]?.messageId,S=N!==m.current;if(p.current=n.length,m.current=N,!(!v||S)){if(r&&g.current&&!x.current){o.current?.scrollTo({top:0,behavior:"smooth"}),i(!1);return}(!g.current||x.current)&&(c(T=>T+w),i(!0))}},[n,r,o]),u.useEffect(()=>{!r&&g.current&&i(!1)},[r]);const b=u.useCallback(()=>{g.current=!0,h.current=!1,x.current=!1,i(!1),c(0),o.current?.scrollTo({top:0,behavior:"smooth"})},[o]);return{showJumpToLatest:a,unseenCount:l,handleJumpToLatest:b}}function dp(t){if(!Array.isArray(t.content))return 1;const e=t.content.filter(n=>n.type!=="tool_result");return Math.max(1,e.length)}function H_(t,e){let n=0;for(let r=0;r<t.length;r++)if(n+=dp(t[r].message),n>e&&r>0)return r;return t.length}function q_(t){const{sessionId:e,reversedItems:n,hasMore:r,isLoadingMore:o,onLoadMore:a,topSentinelRef:i,scrollContainerRef:l,initialBudget:c=lp,budgetStep:d=lr}=t,[p,m]=u.useState(c);u.useEffect(()=>{m(c)},[e,c]);const h=u.useMemo(()=>H_(n,p),[n,p]),g=u.useMemo(()=>n.slice(0,h),[n,h]),f=u.useMemo(()=>Math.max(0,n.length-h),[n.length,h]),x=r||f>0;return u.useEffect(()=>{if(!i.current||o||!x)return;const b=h<n.length,y=new IntersectionObserver(v=>{if(v[0].isIntersecting){if(b){m(w=>w+d);return}a?.()}},{root:l.current,rootMargin:"200px 0px 0px 0px",threshold:0});return y.observe(i.current),()=>y.disconnect()},[d,h,n.length,x,o,a,l,i]),{blockBudget:p,setBlockBudget:m,visibleCount:h,visibleReversedItems:g,truncatedOlderCount:f,hasInternalMore:x}}function W_(t){const{jumpToMessageId:e,reversedItems:n,visibleCount:r,setBlockBudget:o,scrollContainerRef:a,onJumpHandled:i,blockBudgetStep:l=lr}=t;u.useEffect(()=>{if(!e)return;const c=n.findIndex(p=>(p.message.messageId||p.message.id)===e);if(c<0)return;if(c>=r){let p=0;for(let m=0;m<=c;m+=1)p+=dp(n[m].message);o(p+l);return}const d=requestAnimationFrame(()=>{const p=a.current;if(!p)return;const m=e.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),h=p.querySelector(`[data-message-id="${m}"]`);if(!h)return;const g=p.getBoundingClientRect(),f=h.getBoundingClientRect(),x=f.top+f.height/2,b=g.top+g.height/2,y=x-b;p.scrollTo({top:p.scrollTop+y,behavior:"smooth"}),h.classList.add("jump-highlight"),setTimeout(()=>h.classList.remove("jump-highlight"),2e3),i?.()});return()=>cancelAnimationFrame(d)},[e,n,r,o,a,i,l])}const zc="/api/system/telemetry/client",K_=6e4,Q_=8,Y_=6e4,J_=new Map;function up(t,e,n,r=Q_,o=Y_){const a=t.get(e);return!a||n-a.windowStartMs>=o?(t.set(e,{windowStartMs:n,count:1}),!0):a.count>=r?!1:(a.count+=1,!0)}function mt(t){if(typeof window>"u")return;const e=t.component.trim(),n=t.event.trim(),r=t.severity||"info";if(!e||!n)return;const o=Date.now(),a=`${e}:${n}:${r}`;if(!up(J_,a,o))return;const i=JSON.stringify({component:e,event:n,severity:r,traceId:t.traceId,details:{...t.details||{},clientTimestamp:new Date(o).toISOString()}});try{if(typeof navigator<"u"&&typeof navigator.sendBeacon=="function"&&typeof Blob<"u"&&i.length<=K_&&navigator.sendBeacon(zc,new Blob([i],{type:"application/json"})))return}catch{}fetch(zc,{method:"POST",headers:{"Content-Type":"application/json"},body:i,keepalive:!0}).catch(()=>{})}const X_=1e4;function aa(t){const e=t.match(/^h-(\d+)$/);if(e)return{kind:"seq",value:Number(e[1])};const n=t.match(/^group-(\d+)$/);return n?{kind:"timestamp",value:Number(n[1])}:null}function Z_(t){let e=-1/0,n="";for(let r=0;r<t.length;r++){const o=aa(t[r]);if(o){if(o.value<e)return{index:r,prevId:n,prevKey:e,currId:t[r],currKey:o.value};e=o.value,n=t[r]}}return null}function ek({conversationId:t,expectedOrder:e,containerRef:n,isStreaming:r,actionTrace:o}){const a=u.useRef(null);u.useEffect(()=>{if(!t||e.length<2||!n.current)return;const i=n.current.querySelectorAll("[data-message-id]");if(i.length<2)return;const l=[];for(let j=i.length-1;j>=0;j--){const E=i[j].getAttribute("data-message-id");E&&l.push(E)}const c=new Set(l),d=e.filter(j=>c.has(j));if(d.length<2||d.length!==l.length)return;let p=-1;for(let j=0;j<d.length;j++)if(d[j]!==l[j]){p=j;break}if(p===-1)return;const m=Date.now(),h=a.current;if(h&&h.sessionId===t&&m-h.ts<X_)return;a.current={sessionId:t,ts:m};const g=Z_(d),f=g?"data_ordering_bug":"rendering_glitch",x=Math.max(0,p-2),b=Math.min(d.length,p+5),y=d.slice(x,b),v=l.slice(x,b),w=y.map(j=>{const E=aa(j);return E?`${E.kind}=${E.value}`:j}),N=v.map(j=>{const E=aa(j);return E?`${E.kind}=${E.value}`:j}),S=o?.slice(-30),T={conversationId:t,rootCause:f,divergenceIndex:p,expectedWindow:y,expectedKeys:w,domWindow:v,domKeys:N,totalExpected:d.length,totalDom:l.length,isStreaming:!!r,dataViolation:g??void 0,actionTrace:S};mt({component:"RenderOrderDetector",event:"dom-order-mismatch",severity:f==="data_ordering_bug"?"error":"warn",details:T}),console.warn(`[RenderOrderDetector] ${f==="data_ordering_bug"?"🔴 DATA ORDERING BUG — events array has wrong seq order":"⚠️ Rendering glitch — data is correct but DOM order diverges"}`,T)})}const tk={},sk={};function nk(t){return t.type==="system"&&t.systemSubtype==="compact_boundary"}const rk=({sessionId:t,messages:e,renderItems:n,toolResults:r=tk,childrenMessages:o=sk,expandedTasks:a=new Set,onToggleTaskExpanded:i,isLoading:l,isStreaming:c,streamingProvider:d,currentQuestionRequest:p,onAnswerQuestion:m,pendingQuestion:h,onAnswerPendingQuestion:g,onDismissPendingQuestion:f,hasMore:x=!1,isLoadingMore:b=!1,onLoadMore:y,branchLineage:v,onNavigateToSession:w,sessionStartTime:N,isSwitchingProvider:S=!1,switchingToProvider:T,jumpToMessageId:C=null,onJumpHandled:j,inlinePermissionPrompt:E,onPlanApprove:R,onPlanReject:O,planOutcomes:$={},actionTrace:re})=>{const ne=u.useRef(null),V=u.useRef(null),{hasShownContent:X,newMessageIds:q}=U_({sessionId:t,messages:e}),K=e,ge=v?.branchPointMessageId??null,D=u.useMemo(()=>{const J=[];return K.forEach(H=>{const ye=J[J.length-1];ye&&ye.type===H.type?ye.messages.push(H):J.push({type:H.type,messages:[H],groupIndex:J.length})}),J},[K]),W=u.useMemo(()=>{if(n&&n.length>0){const ye=[];let I=0;for(const pe of n)if(pe.kind==="message")ye.push({kind:"message",message:pe.message,groupIndex:I++,groupType:pe.message.type,isFirstInGroup:!0,isLastInGroup:!0});else{const Ce={id:pe.group.id,messageId:pe.group.id,type:"assistant",content:pe.group.summary,timestamp:pe.group.timestamp,provider:"claude"};ye.push({kind:"group",renderItem:pe,message:Ce,groupIndex:I++,groupType:"assistant",isFirstInGroup:!0,isLastInGroup:!0})}return ye}const J=[];let H;return D.forEach((ye,I)=>{ye.messages.forEach((pe,Ce)=>{const ke=Ce===ye.messages.length-1,Re=pe.provider==="claude"?pe.provider:void 0;let B;if(pe.type==="assistant"){const he=Re||H;he&&H&&he!==H&&(B={from:H,to:he}),he&&(H=he)}J.push({kind:"message",message:pe,groupIndex:I,groupType:ye.type,isFirstInGroup:Ce===0,isLastInGroup:ke,providerSwitch:B})})}),J},[n,D]),Z=u.useMemo(()=>[...W].reverse(),[W]),F=u.useMemo(()=>W.map(J=>J.message.messageId||J.message.id),[W]);ek({conversationId:t??null,expectedOrder:F,containerRef:ne,isStreaming:c,actionTrace:re});const{showJumpToLatest:se,unseenCount:ee,handleJumpToLatest:te}=G_({sessionId:t,messages:e,isStreaming:c,scrollContainerRef:ne}),{visibleCount:xe,visibleReversedItems:_e,hasInternalMore:A,setBlockBudget:P}=q_({sessionId:t,reversedItems:Z,hasMore:x,isLoadingMore:b,onLoadMore:y,topSentinelRef:V,scrollContainerRef:ne,initialBudget:lp,budgetStep:lr});W_({jumpToMessageId:C,reversedItems:Z,visibleCount:xe,setBlockBudget:P,scrollContainerRef:ne,onJumpHandled:j,blockBudgetStep:lr}),u.useMemo(()=>K.some(J=>J.type==="assistant"&&Array.isArray(J.content)?J.content.some(H=>{if(H.type==="tool_use"&&H.id){const ye=r[H.id];return!ye||ye.status==="pending"}return!1}):!1),[K,r]);const le=u.useCallback(J=>{const H=J.message.messageId||J.message.id,ye=H;if(J.kind==="group")return s.jsx("div",{className:"w-full flex justify-center","data-message-id":ye,children:s.jsx("div",{className:"w-full max-w-5xl px-4 py-1",children:s.jsx(Zs,{name:"CollapsedGroup",children:s.jsx(Qo,{group:J.renderItem.group,temporalState:J.renderItem.temporalState})})})},ye);const I=ge!==null&&ge===H,pe=q.get(ye),Ce=pe!==void 0,ke=J.groupType==="assistant",Re=Ce&&!ke,B=nk(J.message),he=c&&ke;return s.jsx("div",{className:`w-full flex justify-center ${Re?"animate-message-in":""}`,style:Re&&pe!==void 0&&pe>0?{animationDelay:`${pe*120}ms`}:void 0,"data-message-id":ye,children:s.jsxs("div",{className:"w-full max-w-5xl px-4 py-1",children:[B?s.jsx(B_,{trigger:J.message.compactMetadata?.trigger,preTokens:J.message.compactMetadata?.preTokens}):s.jsx(Zs,{name:"Message",children:s.jsx(cp,{message:J.message,toolResults:r,childrenMessages:o,expandedTasks:a,onToggleTaskExpanded:i,isFirstInGroup:J.isFirstInGroup,isLastInGroup:J.isLastInGroup,isStreaming:he,currentQuestionRequest:p,onAnswerQuestion:m,onPlanApprove:R,onPlanReject:O,planOutcomes:$})}),I&&v&&w&&s.jsxs("div",{"data-testid":"branch-point-indicator","data-branch-turn":v.atTurn,className:"flex items-center gap-2 mt-3 mb-1 py-2 text-sm text-muted-foreground/60 border-t border-b border-cyan-400/20",children:[s.jsx(ya,{size:14,className:"text-cyan-400/60"}),s.jsxs("span",{children:["Branched from"," ",s.jsx("button",{onClick:()=>w(v.parentSessionId),className:"text-cyan-400/80 hover:text-cyan-400 hover:underline cursor-pointer",children:"parent session"})," ","at turn ",v.atTurn]})]})]})},ye)},[r,o,a,i,c,p,m,ge,v,w,q,R,O,$]);return K.length===0&&!l?s.jsxs("div",{className:"flex-1 flex flex-col justify-end relative bg-background scrollbar-auto-hide overflow-hidden",children:[s.jsx("div",{className:"relative z-10 w-full flex justify-center p-8",children:s.jsxs("div",{className:"w-full max-w-5xl px-4",children:[!c&&!E&&s.jsx("div",{className:"text-center text-muted-foreground animate-message-in",children:s.jsx("p",{children:"No messages yet. Start by typing a message below."})}),E&&s.jsx("div",{className:"py-1",children:E})]})}),c&&s.jsx("div",{className:"w-full flex justify-center py-2",children:s.jsx(Dc,{isVisible:!0,startTime:N})})]}):s.jsxs("div",{className:`flex-1 min-h-0 relative bg-background transition-opacity duration-300 ease-out ${X?"opacity-100":"opacity-0"}`,children:[s.jsxs("div",{ref:ne,"data-testid":"message-list",className:"h-full min-h-0 relative overflow-y-auto overflow-x-hidden bg-background flex flex-col-reverse scrollbar-auto-hide",style:{overflowAnchor:"none"},children:[S&&s.jsx("div",{className:"w-full flex justify-center py-3",children:s.jsx("div",{className:"flex items-center gap-2 text-[10px] font-display font-bold uppercase tracking-wider text-stone-400 animate-pulse",children:s.jsx("span",{children:"Switching to Claude..."})})}),!l&&D.length>0&&s.jsx("div",{className:"w-full grid transition-all duration-300 ease-out",style:{gridTemplateRows:c?"1fr":"0fr"},children:s.jsx("div",{className:"overflow-hidden flex justify-center",children:s.jsx("div",{className:c?"py-2":"py-0",children:s.jsx(Dc,{isVisible:!!c,startTime:N})})})}),!c&&h&&g&&s.jsx("div",{className:"w-full flex justify-center relative z-10",children:s.jsx("div",{className:"w-full max-w-5xl px-4 py-1",children:s.jsx(Zs,{name:"PendingQuestion",children:s.jsx(tu,{input:{questions:h.questions},result:"",questionId:h.id,onAnswer:g,onDismiss:f,isRecovered:!0})})})}),E&&s.jsx("div",{className:"w-full flex justify-center relative z-10",children:s.jsx("div",{className:"w-full max-w-5xl px-4 py-1",children:E})}),_e.map(J=>le(J)),l&&K.length===0&&s.jsx("div",{className:"flex items-center justify-center p-8 relative z-10",children:s.jsxs("div",{className:"flex gap-1",children:[s.jsx("span",{className:"w-1 h-1 bg-blue-500 rounded-full animate-bounce [animation-delay:-0.32s]"}),s.jsx("span",{className:"w-1 h-1 bg-blue-500 rounded-full animate-bounce [animation-delay:-0.16s]"}),s.jsx("span",{className:"w-1 h-1 bg-blue-500 rounded-full animate-bounce"})]})}),b&&s.jsx("div",{className:"flex items-center justify-center p-4 relative z-10",children:s.jsxs("div",{className:"flex gap-1",children:[s.jsx("span",{className:"w-1 h-1 bg-muted-foreground rounded-full animate-bounce [animation-delay:-0.32s]"}),s.jsx("span",{className:"w-1 h-1 bg-muted-foreground rounded-full animate-bounce [animation-delay:-0.16s]"}),s.jsx("span",{className:"w-1 h-1 bg-muted-foreground rounded-full animate-bounce"})]})}),A&&!b&&s.jsx("div",{ref:V,className:"h-1 w-full shrink-0"})]}),se&&s.jsx("div",{className:"pointer-events-none absolute bottom-4 left-0 right-0 z-20 flex justify-center",children:s.jsx("div",{className:"w-full max-w-5xl px-4 flex justify-end pointer-events-none",children:s.jsxs("button",{"data-testid":"jump-to-latest",onClick:te,className:"pointer-events-auto flex items-center gap-1.5 px-3 py-1.5 rounded-sm border border-cyan-500/30 bg-background/90 backdrop-blur-sm text-cyan-300 text-xs font-display font-bold uppercase tracking-wider hover:border-cyan-400 hover:bg-cyan-500/10 transition-colors cursor-pointer shadow-lg shadow-black/20",children:[s.jsx(ih,{size:12}),"Latest",ee>0&&s.jsx("span",{className:"ml-0.5 min-w-[18px] h-[18px] flex items-center justify-center rounded-full bg-cyan-500/20 text-cyan-300 text-[10px] font-bold tabular-nums px-1",children:ee>99?"99+":ee})]})})})]})},Mn=[{id:"skills",label:"Skills",icon:ja,color:"purple"},{id:"mode",label:"Mode",icon:Ms,color:"cyan"},{id:"mcp",label:"MCP",icon:Df,color:"emerald"}],ok=[],uo=[{value:"default",label:"ASK",description:"",icon:Ms,activeClassName:"bg-cyan-500/10",iconClassName:"text-cyan-400",textClassName:"text-cyan-400"},{value:"acceptEdits",label:"AUTO",description:"Allow workspace writes and safe commands. Prompt for actions outside the sandbox.",icon:Zh,activeClassName:"bg-emerald-500/10",iconClassName:"text-emerald-400",textClassName:"text-emerald-400"},{value:"bypassPermissions",label:"TRUST",description:"Skip all permission prompts. Runs freely with no restrictions.",icon:mr,activeClassName:"bg-amber-500/10",iconClassName:"text-amber-400",textClassName:"text-amber-400"}],ak={mapper:{icon:$h,color:"purple"},locator:{icon:Vh,color:"blue"},adversarial:{icon:a0,color:"rose"},note:{icon:l0,color:"amber"},look:{icon:Ro,color:"emerald"},debuglog:{icon:Gl,color:"orange"},rightpanel:{icon:Lf,color:"cyan"},amppanel:{icon:as,color:"violet"}},Fc={purple:{text:"text-purple-400",icon:"text-purple-400"},blue:{text:"text-blue-400",icon:"text-blue-400"},rose:{text:"text-rose-400",icon:"text-rose-400"},amber:{text:"text-amber-400",icon:"text-amber-400"},emerald:{text:"text-emerald-400",icon:"text-emerald-400"},orange:{text:"text-orange-400",icon:"text-orange-400"},cyan:{text:"text-cyan-400",icon:"text-cyan-400"},violet:{text:"text-violet-400",icon:"text-violet-400"}},ik={icon:ja,color:"purple"};function Vc(t){const e=t.replace(/^\//,"").toLowerCase();return ak[e]||ik}function ck({isOpen:t,onClose:e,onSelectSkill:n,skills:r,mcpServers:o=ok,permissionMode:a,onPermissionModeChange:i,provider:l="claude"}){const[c,d]=u.useState("skills"),[p,m]=u.useState(null),[h,g]=u.useState(""),[f,x]=u.useState(0),[b,y]=u.useState(0),[v,w]=u.useState("categories"),N=u.useRef(null),S=u.useRef(null);u.useEffect(()=>{t||(d("skills"),m(null),g(""),x(0),y(0),w("categories"))},[t]),u.useEffect(()=>{p&&S.current&&S.current.focus()},[p]);const T=u.useCallback(()=>{p&&(n(p.name,h||void 0),e())},[p,h,n,e]);u.useEffect(()=>{if(!t)return;const j=E=>{if(p&&document.activeElement===S.current){E.key==="Escape"?(m(null),g(""),E.preventDefault()):E.key==="Enter"&&(T(),E.preventDefault());return}const R=c==="skills"?r.length:c==="mcp"?o.length:uo.length;switch(E.key){case"Escape":e(),E.preventDefault();break;case"ArrowDown":v==="categories"?x(O=>Math.min(O+1,Mn.length-1)):y(O=>Math.min(O+1,R-1)),E.preventDefault();break;case"ArrowUp":v==="categories"?x(O=>Math.max(O-1,0)):y(O=>Math.max(O-1,0)),E.preventDefault();break;case"ArrowLeft":v==="items"&&w("categories"),E.preventDefault();break;case"ArrowRight":v==="categories"&&(d(Mn[f].id),w("items"),y(0)),E.preventDefault();break;case"Enter":if(v==="categories")d(Mn[f].id),w("items"),y(0);else if(c==="skills"&&r[b])m(r[b]);else if(c==="mode"){const O=uo[b]?.value??"default";i(O),e()}E.preventDefault();break}};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[t,c,p,f,b,v,r,o.length,e,i,T]);const C=j=>j.replace(/^\//,"");return t?s.jsxs("div",{ref:N,className:"absolute bottom-full mb-2 right-0 max-w-[400px] w-full bg-background/95 backdrop-blur-md border border-border/50 rounded-lg shadow-xl overflow-hidden animate-in fade-in slide-in-from-bottom-2 duration-150 z-50",children:[p?(()=>{const j=Vc(p.name),E=Fc[j.color],R=j.icon;return s.jsxs("div",{className:"p-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsxs("div",{className:$e("flex items-center gap-2 px-2 py-1 rounded-sm",`bg-${j.color}-500/10 border border-${j.color}-500/30`),children:[s.jsx(R,{size:14,className:E.icon}),s.jsx("span",{className:$e("font-display text-xs font-bold uppercase tracking-wider",E.text),children:C(p.name)})]}),p.description&&s.jsx("span",{className:"text-xs text-muted-foreground",children:p.description})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{ref:S,type:"text",value:h,onChange:O=>g(O.target.value),onKeyDown:O=>{O.key==="Enter"?(T(),O.preventDefault()):O.key==="Escape"&&(m(null),g(""),O.preventDefault())},placeholder:p.argumentHint||"Optional arguments...",className:$e("flex-1 px-3 py-2 bg-background/50 border border-border/50 rounded-sm text-sm text-foreground placeholder:text-muted-foreground/40 focus:outline-none",`focus:border-${j.color}-500/50`)}),s.jsx("button",{onClick:T,className:$e("flex items-center gap-2 px-3 py-1.5 rounded-sm bg-background/80 backdrop-blur-sm border text-xs font-display font-bold uppercase tracking-wider transition-all duration-100 cursor-pointer",`border-${j.color}-500/30 ${E.text}`,`hover:border-${j.color}-400 hover:bg-${j.color}-500/5`),children:"Launch"})]}),s.jsxs("div",{className:"mt-3 text-[10px] text-muted-foreground/50 font-mono",children:[s.jsx("kbd",{className:"px-1 py-0.5 rounded bg-muted/30 text-muted-foreground/70",children:"Enter"})," launch",s.jsx("span",{className:"mx-2",children:"·"}),s.jsx("kbd",{className:"px-1 py-0.5 rounded bg-muted/30 text-muted-foreground/70",children:"Esc"})," back"]})]})})():s.jsxs("div",{className:"flex",children:[s.jsx("div",{className:"w-10 border-r border-border/30 py-2 flex flex-col items-center gap-1",children:Mn.map((j,E)=>{const R=j.icon,O=c===j.id,$=v==="categories"&&f===E,re={purple:"text-purple-400 bg-purple-500/10",cyan:"text-cyan-400 bg-cyan-500/10",emerald:"text-emerald-400 bg-emerald-500/10"};return s.jsx("button",{onClick:()=>{d(j.id),w("items"),y(0)},className:$e("p-1.5 rounded transition-all cursor-pointer",O||$?re[j.color]:"text-muted-foreground hover:text-foreground hover:bg-muted/30"),title:j.label,children:s.jsx(R,{size:14})},j.id)})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[c==="skills"&&s.jsx("div",{className:"py-1 max-h-72 overflow-y-auto",children:r.length===0?s.jsx("div",{className:"py-8 text-center text-muted-foreground/50 text-xs font-display uppercase tracking-wider",children:"No skills available"}):r.map((j,E)=>{const R=v==="items"&&b===E,O=Vc(j.name),$=Fc[O.color],re=O.icon;return s.jsxs("button",{onClick:()=>m(j),className:$e("w-full text-left px-3 py-2.5 transition-all cursor-pointer flex items-start gap-3",R?"bg-muted/30":"hover:bg-muted/30"),children:[s.jsx(re,{size:16,className:$e($.icon,"mt-0.5 shrink-0")}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:$e("text-sm font-medium",$.text),children:C(j.name)}),j.description&&s.jsx("div",{className:"text-[11px] text-muted-foreground/50 leading-relaxed mt-0.5",children:j.description})]})]},j.name)})}),c==="mode"&&s.jsx("div",{className:"p-2 space-y-1.5",children:uo.map((j,E)=>{const R=j.icon,O=a===j.value,$=v==="items"&&b===E,re=j.value==="default"?"Prompt before every tool use.":j.description;return s.jsxs("button",{onClick:()=>{i(j.value),e()},className:$e("w-full text-left px-3 py-2.5 rounded-sm transition-all cursor-pointer flex items-start gap-3",O||$?j.activeClassName:"hover:bg-muted/30"),children:[s.jsx(R,{size:16,className:$e(j.iconClassName,"mt-0.5 shrink-0")}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:$e("text-sm font-medium",j.textClassName),children:j.label}),O&&s.jsx(Oe,{size:12,className:j.iconClassName})]}),s.jsx("div",{className:"text-[11px] text-muted-foreground/50 leading-relaxed mt-0.5",children:re})]})]},j.value)})}),c==="mcp"&&s.jsx("div",{className:"p-2 space-y-1",children:o.length===0?s.jsx("div",{className:"py-8 text-center text-muted-foreground/50 text-xs font-display uppercase tracking-wider",children:"No MCP servers connected"}):o.map((j,E)=>{const R=v==="items"&&b===E,O=j.status==="connected",$=j.status==="configured",re=O?"bg-emerald-400":$?"bg-stone-500":"bg-amber-400",ne=O?"text-emerald-400/70":$?"text-stone-500/70":"text-amber-400/70";return s.jsxs("div",{className:$e("px-3 py-2.5 rounded-sm flex items-center gap-3",R?"bg-muted/30":""),children:[s.jsx("div",{className:$e("w-2 h-2 rounded-full shrink-0",re)}),s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx("span",{className:"text-sm font-medium text-foreground",children:j.name})}),s.jsx("span",{className:$e("text-[10px] font-display uppercase tracking-wider",ne),children:j.status})]},j.name)})})]})]}),!p&&s.jsxs("div",{className:"px-3 py-2 border-t border-border/30 text-[10px] text-muted-foreground/50 font-mono flex gap-4",children:[s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1 py-0.5 rounded bg-muted/30 text-muted-foreground/70",children:"↑↓"})," navigate"]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1 py-0.5 rounded bg-muted/30 text-muted-foreground/70",children:"←→"})," switch"]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1 py-0.5 rounded bg-muted/30 text-muted-foreground/70",children:"Enter"})," select"]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1 py-0.5 rounded bg-muted/30 text-muted-foreground/70",children:"Esc"})," close"]})]})]}):null}function lk(t){return t.type==="image"?{type:"image",source:{type:"base64",media_type:t.mimeType,data:t.base64}}:t.type==="text"?{type:"text",text:`[File: ${t.fileName}]
|
|
135
|
-
${t.textContent}`}:{type:"document",source:{type:"base64",media_type:"application/pdf",data:t.base64}}}const pp=u.forwardRef(function(e,n){const{core:r,features:o,skills:a=[],mcpServers:i=[],...l}=e,[c,d]=u.useState("default"),[p,m]=u.useState(void 0),h=
|
|
133
|
+
`),E=s.jsxs("div",{className:"group/user relative border border-cyan-500/15 rounded-lg overflow-hidden bg-cyan-500/5 w-full",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-cyan-500/10",children:[s.jsx(Jl,{size:12,className:"text-cyan-400/80 flex-shrink-0"}),s.jsx("span",{className:"text-[11px] text-zinc-400 font-medium",children:"User"}),s.jsx("div",{className:"flex-1"}),S&&s.jsx("button",{onClick:()=>y(!b),className:"w-5 h-5 border-none bg-transparent text-zinc-500 cursor-pointer flex items-center justify-center p-0 hover:text-zinc-300","aria-label":b?"Show fewer lines":"Show all lines",children:b?s.jsx(Pf,{size:14}):s.jsx(Sf,{size:14})})]}),s.jsxs("div",{className:"px-3 py-2 text-[13px] leading-relaxed text-foreground",children:[w.length>0&&s.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:w.map((A,L)=>{if(A.type==="image"&&A.source){const $=A.source.type==="base64"?`data:${A.source.media_type};base64,${A.source.data}`:A.source.url;return s.jsx(Pc,{src:$,alt:"Attached",className:"max-w-[200px] max-h-[200px] rounded border border-zinc-600 object-contain"},`img-${L}`)}return A.type==="document"?s.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded bg-amber-500/10 border border-amber-500/20",children:[s.jsx(Po,{size:14,className:"text-amber-400"}),s.jsx("span",{className:"text-xs text-amber-300",children:"PDF"})]},`doc-${L}`):null})}),s.jsxs("div",{className:"whitespace-pre-wrap break-words",children:[j,!b&&S&&s.jsxs("span",{className:"text-muted-foreground italic",children:[`
|
|
134
|
+
`,"... +",C," lines"]})]})]})]});return s.jsx("div",{className:"flex justify-end w-full my-1","data-testid":"user-message",children:s.jsx("div",{className:"max-w-[80%] min-w-[100px]",children:E})})}if(t.type==="assistant"){const v=e||{},w=()=>{if(typeof t.content=="string")return s.jsx("div",{children:s.jsx(Mc,{text:t.content,markdownComponents:lo})});if(Array.isArray(t.content)){const N=t.content,S=[],T=new Map,C=j=>{if(j.type==="tool_use"&&typeof j.id=="string"&&j.id.length>0)return`${t.messageId}-tool_use-${j.id}`;if(j.type==="tool_result"&&typeof j.tool_use_id=="string"&&j.tool_use_id.length>0)return`${t.messageId}-tool_result-${j.tool_use_id}`;const E=T.get(j.type)??0;return T.set(j.type,E+1),`${t.messageId}-${j.type}-${E}`};return N.forEach(j=>{const E=C(j);if(j.type!=="tool_result"){if(j.type==="text"){const A=O_(typeof j.text=="string"?j.text:"");if(!A)return;S.push(s.jsx("div",{children:s.jsx(Mc,{text:A,markdownComponents:lo})},E));return}if(j.type==="thinking"){S.push(s.jsx("div",{className:"max-w-lg","data-testid":"thinking-block",children:s.jsxs("div",{className:"border border-amber-500/20 rounded-lg overflow-hidden bg-amber-500/5",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-amber-500/10",children:[s.jsx(yh,{size:12,className:"text-amber-400/80 flex-shrink-0"}),s.jsx("span",{className:"text-[11px] text-zinc-400 font-medium",children:"Thinking"})]}),s.jsx("div",{className:"px-3 py-2 prose max-w-none text-[13px] leading-relaxed text-muted-foreground dark:prose-invert",children:s.jsx(Eo,{remarkPlugins:[Cs],components:lo,children:typeof j.thinking=="string"?j.thinking:""})})]})},E));return}if(j.type==="tool_use"){const A=typeof j.id=="string"?j.id:"";if(!A)return;const L=D_(j.input)?j.input:{},$=$_(j.name,L),oe=v[A];if(oe?.is_error){const B=typeof oe.result=="string"?oe.result:"";if($==="AskUserQuestion"||B.toLowerCase().includes("answer questions?"))return}const ne=c?.toolUseId===A?c?.id:void 0;S.push(s.jsx("div",{className:"w-full",children:s.jsx(s1,{toolUse:{type:"tool_use",id:A,name:$,input:L},toolResult:oe,toolResults:v,workingDirectory:t.workingDirectory,childrenMessages:n,questionId:ne,onAnswerQuestion:d,isStreaming:l,onPlanApprove:p,onPlanReject:m,planOutcomes:h,renderChildMessage:B=>s.jsx(cp,{message:B,toolResults:v,childrenMessages:n,isStreaming:l},B.messageId)})},E));return}if(j.type==="image"){const A=j.source,L=A.type==="base64"?`data:${A.media_type};base64,${A.data}`:A.url;S.push(s.jsx("div",{children:s.jsxs("div",{className:"inline-block border border-zinc-800/40 rounded-lg overflow-hidden bg-zinc-900/30",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-zinc-800/40",children:[s.jsx(af,{size:12,className:"text-zinc-600"}),s.jsx("span",{className:"text-[11px] text-zinc-600",children:"Image"})]}),s.jsx("div",{className:"p-2",children:s.jsx(Pc,{src:L,alt:"Attached image",className:"max-w-md max-h-96 rounded object-contain"})})]})},E))}if(j.type==="document"){S.push(s.jsx("div",{children:s.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg border border-zinc-800/40 bg-zinc-900/30",children:[s.jsx(Po,{size:14,className:"text-zinc-500"}),s.jsx("span",{className:"text-xs text-zinc-400",children:"PDF Document"})]})},E));return}S.push(s.jsx("div",{children:s.jsxs("div",{className:"border border-zinc-800/40 rounded-lg overflow-hidden bg-zinc-900/30",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-zinc-800/40",children:[s.jsx(Io,{size:14,className:"text-zinc-400 flex-shrink-0"}),s.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-400",children:"Data"})]}),s.jsx("div",{className:"px-3 py-2 text-[13px] leading-relaxed text-foreground",children:s.jsx(Pi,{data:j})})]})},E))}}),S}return s.jsx("div",{children:s.jsxs("div",{className:"border border-zinc-800/40 rounded-lg overflow-hidden bg-zinc-900/30",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-zinc-800/40",children:[s.jsx(Io,{size:14,className:"text-zinc-400 flex-shrink-0"}),s.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-400",children:"Data"})]}),s.jsx("div",{className:"px-3 py-2 text-[13px] leading-relaxed text-foreground",children:s.jsx(Pi,{data:t.content})})]})})};return s.jsx("div",{className:`relative w-full flex flex-col gap-1.5${g.current?" streaming-message":""}`,"data-testid":"assistant-message",children:w()})}return t.type==="error"?s.jsx("div",{children:s.jsxs("div",{className:"border border-red-500/30 rounded-lg overflow-hidden bg-red-500/5",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-red-500/10",children:[s.jsx(kt,{size:14,className:"text-red-400/80 flex-shrink-0"}),s.jsx("span",{className:"text-[11px] text-red-300/80 font-medium",children:"Error"})]}),s.jsx("div",{className:"px-3 py-2.5 text-[13px] text-red-200 font-mono whitespace-pre-wrap",children:String(t.content)})]})}):null}function Dc({isVisible:t,startTime:e}){const n=u.useRef(null),r=u.useRef([]),o=u.useRef([]),a=u.useRef(0),i=u.useRef(null),l=u.useRef(t),c=u.useRef(0),d=u.useRef(0);return u.useEffect(()=>{l.current=t},[t]),u.useEffect(()=>{if(t&&!a.current){const p=i.current;p&&(a.current=requestAnimationFrame(p))}},[t]),u.useEffect(()=>{const p=n.current;if(!p)return;const m=p.getContext("2d");if(!m)return;const h=80,g=32,f=Math.min(window.devicePixelRatio||1,2);p.width=Math.floor(h*f),p.height=Math.floor(g*f),m.setTransform(f,0,0,f,0,0);const x=16;r.current=[];for(let v=0;v<x;v++)r.current.push({x:8+Math.random()*(h-16),y:6+Math.random()*(g-12),vx:(Math.random()-.5)*.3,vy:(Math.random()-.5)*.3,radius:1.2+Math.random()*.8,pulsePhase:Math.random()*Math.PI*2,connections:[],activity:Math.random(),isFiring:!1,fireTimer:Math.random()*60});r.current.forEach((v,w)=>{const N=r.current.map((S,T)=>({index:T,distance:Math.hypot(v.x-S.x,v.y-S.y)})).filter(({index:S})=>S!==w).sort((S,T)=>S.distance-T.distance).slice(0,2).map(({index:S})=>S);v.connections=N});const b=(v,w,N)=>{const S=Math.random()*Math.PI*2,T=.3+Math.random()*.8;o.current.push({x:v,y:w,vx:Math.cos(S)*T,vy:Math.sin(S)*T,life:1,maxLife:12+Math.random()*10,hue:N})},y=()=>{const v=l.current;c.current+=((v?1:0)-c.current)*.06;const w=c.current;d.current+=.02;const N=d.current;if(m.clearRect(0,0,h,g),w<.01){a.current=0;return}const S=r.current,T=o.current;S.forEach(C=>{C.x+=C.vx,C.y+=C.vy,(C.x<=6||C.x>=h-6)&&(C.vx*=-1),(C.y<=4||C.y>=g-4)&&(C.vy*=-1),C.x=Math.min(h-6,Math.max(6,C.x)),C.y=Math.min(g-4,Math.max(4,C.y)),C.activity=.4+.6*Math.sin(N*3+C.pulsePhase),C.fireTimer-=1,v&&C.fireTimer<=0?(C.isFiring=!0,C.fireTimer=35+Math.random()*50,b(C.x,C.y,180+Math.random()*30)):(C.fireTimer<=0&&(C.fireTimer=35+Math.random()*50),C.isFiring=!1)});for(let C=T.length-1;C>=0;C--){const j=T[C];if(j.x+=j.vx,j.y+=j.vy,j.life-=1/j.maxLife,j.life<=0){T.splice(C,1);continue}const E=j.life*.5*w;m.fillStyle=`hsla(${j.hue}, 100%, 70%, ${E})`,m.beginPath(),m.arc(j.x,j.y,.8+j.life*.5,0,Math.PI*2),m.fill()}m.lineWidth=.5,S.forEach(C=>{C.connections.forEach(j=>{const E=S[j],A=C.isFiring||E.isFiring;if(A)m.strokeStyle=`rgba(0, 255, 255, ${(.35+Math.random()*.15)*w})`,m.lineWidth=1;else{const L=(C.activity+E.activity)/2;m.strokeStyle=`rgba(0, 200, 255, ${(.08+L*.12)*w})`,m.lineWidth=.4}if(m.beginPath(),m.moveTo(C.x,C.y),A){const L=(C.x+E.x)/2+(Math.random()-.5)*2,$=(C.y+E.y)/2+(Math.random()-.5)*2;m.quadraticCurveTo(L,$,E.x,E.y)}else m.lineTo(E.x,E.y);m.stroke()})}),S.forEach(C=>{const j=C.activity*.6+.3,E=C.isFiring,A=E?5:3,L=m.createRadialGradient(C.x,C.y,0,C.x,C.y,A);E?(L.addColorStop(0,`rgba(0, 255, 255, ${.6*w})`),L.addColorStop(.4,`rgba(0, 200, 255, ${.25*w})`),L.addColorStop(1,"rgba(0, 150, 255, 0)")):(L.addColorStop(0,`rgba(0, 200, 255, ${(.1+j*.15)*w})`),L.addColorStop(1,"rgba(0, 150, 255, 0)")),m.fillStyle=L,m.beginPath(),m.arc(C.x,C.y,A,0,Math.PI*2),m.fill();const $=(E?.85:.4+j*.25)*w;m.fillStyle=`rgba(${E?"150, 255, 255":"100, 220, 255"}, ${$})`,m.beginPath(),m.arc(C.x,C.y,E?C.radius*1.3:C.radius,0,Math.PI*2),m.fill()}),a.current=requestAnimationFrame(y)};return i.current=y,a.current=requestAnimationFrame(y),()=>{i.current=null,a.current&&(cancelAnimationFrame(a.current),a.current=0)}},[]),s.jsx("div",{className:`flex items-center gap-2 transition-opacity duration-300 ${t?"opacity-100":"opacity-0 pointer-events-none"}`,"aria-hidden":"true",children:s.jsx("canvas",{ref:n,className:"w-[80px] h-[32px]",style:{imageRendering:"auto"}})})}function B_({trigger:t}){const e=t==="manual";return s.jsx("div",{className:"flex items-center justify-center gap-3 my-4 px-4",children:s.jsxs("span",{className:"text-[10px] font-display font-bold uppercase tracking-wider text-amber-300/50",children:["Context Compacted",e?" · Manual":""]})})}const $c=96,lp=50,lr=50;function U_(t){const{sessionId:e,messages:n}=t,r=u.useRef(e),o=u.useRef(new Set),a=u.useRef(0),[i,l]=u.useState(!1),[c,d]=u.useState(new Map);return u.useEffect(()=>{e!==r.current&&(r.current=e,l(!1),o.current=new Set,a.current=0,d(new Map))},[e]),u.useEffect(()=>{n.length>0&&!i&&requestAnimationFrame(()=>{l(!0)})},[n.length,i]),u.useEffect(()=>{const p=new Set(n.map(x=>x.messageId||x.id).filter(Boolean)),m=new Map;let h=0;n.forEach(x=>{const b=x.messageId||x.id;b&&!o.current.has(b)&&m.set(b,h++)});const g=a.current;if(a.current=p.size,p.forEach(x=>o.current.add(x)),m.size===0||p.size<=g)return;d(m);const f=setTimeout(()=>{d(new Map)},300);return()=>clearTimeout(f)},[n]),{hasShownContent:i,newMessageIds:c}}function G_(t){const{sessionId:e,messages:n,isStreaming:r,scrollContainerRef:o}=t,[a,i]=u.useState(!1),[l,c]=u.useState(0),d=u.useRef(e),p=u.useRef(n.length),m=u.useRef(n[0]?.messageId),h=u.useRef(!1),g=u.useRef(!0),f=u.useRef(null),x=u.useRef(!1);u.useEffect(()=>{e!==d.current&&(d.current=e,g.current=!0,h.current=!1,x.current=!1,i(!1),c(0),requestAnimationFrame(()=>{o.current?.scrollTo({top:0,behavior:"auto"})}))},[e,o]),u.useEffect(()=>{if(r){const y=o.current;y&&Math.abs(y.scrollTop)<=$c&&(x.current=!1)}},[r,o]),u.useEffect(()=>{const y=o.current;if(!y)return;const v=()=>{const N=Math.abs(y.scrollTop)<=$c;g.current=N,N?(x.current=!1,i(!1),c(0)):(x.current=!0,r&&i(!0)),h.current=!0,f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{h.current=!1},150)};return y.addEventListener("scroll",v,{passive:!0}),()=>{y.removeEventListener("scroll",v),f.current&&clearTimeout(f.current)}},[r,o]),u.useEffect(()=>{const y=p.current,v=n.length>y,w=n.length-y,N=n[0]?.messageId,S=N!==m.current;if(p.current=n.length,m.current=N,!(!v||S)){if(r&&g.current&&!x.current){o.current?.scrollTo({top:0,behavior:"smooth"}),i(!1);return}(!g.current||x.current)&&(c(T=>T+w),i(!0))}},[n,r,o]),u.useEffect(()=>{!r&&g.current&&i(!1)},[r]);const b=u.useCallback(()=>{g.current=!0,h.current=!1,x.current=!1,i(!1),c(0),o.current?.scrollTo({top:0,behavior:"smooth"})},[o]);return{showJumpToLatest:a,unseenCount:l,handleJumpToLatest:b}}function dp(t){if(!Array.isArray(t.content))return 1;const e=t.content.filter(n=>n.type!=="tool_result");return Math.max(1,e.length)}function H_(t,e){let n=0;for(let r=0;r<t.length;r++)if(n+=dp(t[r].message),n>e&&r>0)return r;return t.length}function q_(t){const{sessionId:e,reversedItems:n,hasMore:r,isLoadingMore:o,onLoadMore:a,topSentinelRef:i,scrollContainerRef:l,initialBudget:c=lp,budgetStep:d=lr}=t,[p,m]=u.useState(c);u.useEffect(()=>{m(c)},[e,c]);const h=u.useMemo(()=>H_(n,p),[n,p]),g=u.useMemo(()=>n.slice(0,h),[n,h]),f=u.useMemo(()=>Math.max(0,n.length-h),[n.length,h]),x=r||f>0;return u.useEffect(()=>{if(!i.current||o||!x)return;const b=h<n.length,y=new IntersectionObserver(v=>{if(v[0].isIntersecting){if(b){m(w=>w+d);return}a?.()}},{root:l.current,rootMargin:"200px 0px 0px 0px",threshold:0});return y.observe(i.current),()=>y.disconnect()},[d,h,n.length,x,o,a,l,i]),{blockBudget:p,setBlockBudget:m,visibleCount:h,visibleReversedItems:g,truncatedOlderCount:f,hasInternalMore:x}}function W_(t){const{jumpToMessageId:e,reversedItems:n,visibleCount:r,setBlockBudget:o,scrollContainerRef:a,onJumpHandled:i,blockBudgetStep:l=lr}=t;u.useEffect(()=>{if(!e)return;const c=n.findIndex(p=>(p.message.messageId||p.message.id)===e);if(c<0)return;if(c>=r){let p=0;for(let m=0;m<=c;m+=1)p+=dp(n[m].message);o(p+l);return}const d=requestAnimationFrame(()=>{const p=a.current;if(!p)return;const m=e.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),h=p.querySelector(`[data-message-id="${m}"]`);if(!h)return;const g=p.getBoundingClientRect(),f=h.getBoundingClientRect(),x=f.top+f.height/2,b=g.top+g.height/2,y=x-b;p.scrollTo({top:p.scrollTop+y,behavior:"smooth"}),h.classList.add("jump-highlight"),setTimeout(()=>h.classList.remove("jump-highlight"),2e3),i?.()});return()=>cancelAnimationFrame(d)},[e,n,r,o,a,i,l])}const zc="/api/system/telemetry/client",K_=6e4,Q_=8,Y_=6e4,J_=new Map;function up(t,e,n,r=Q_,o=Y_){const a=t.get(e);return!a||n-a.windowStartMs>=o?(t.set(e,{windowStartMs:n,count:1}),!0):a.count>=r?!1:(a.count+=1,!0)}function mt(t){if(typeof window>"u")return;const e=t.component.trim(),n=t.event.trim(),r=t.severity||"info";if(!e||!n)return;const o=Date.now(),a=`${e}:${n}:${r}`;if(!up(J_,a,o))return;const i=JSON.stringify({component:e,event:n,severity:r,traceId:t.traceId,details:{...t.details||{},clientTimestamp:new Date(o).toISOString()}});try{if(typeof navigator<"u"&&typeof navigator.sendBeacon=="function"&&typeof Blob<"u"&&i.length<=K_&&navigator.sendBeacon(zc,new Blob([i],{type:"application/json"})))return}catch{}fetch(zc,{method:"POST",headers:{"Content-Type":"application/json"},body:i,keepalive:!0}).catch(()=>{})}const X_=1e4;function aa(t){const e=t.match(/^h-(\d+)$/);if(e)return{kind:"seq",value:Number(e[1])};const n=t.match(/^group-(\d+)$/);return n?{kind:"timestamp",value:Number(n[1])}:null}function Z_(t){let e=-1/0,n="";for(let r=0;r<t.length;r++){const o=aa(t[r]);if(o){if(o.value<e)return{index:r,prevId:n,prevKey:e,currId:t[r],currKey:o.value};e=o.value,n=t[r]}}return null}function ek({conversationId:t,expectedOrder:e,containerRef:n,isStreaming:r,actionTrace:o}){const a=u.useRef(null);u.useEffect(()=>{if(!t||e.length<2||!n.current)return;const i=n.current.querySelectorAll("[data-message-id]");if(i.length<2)return;const l=[];for(let j=i.length-1;j>=0;j--){const E=i[j].getAttribute("data-message-id");E&&l.push(E)}const c=new Set(l),d=e.filter(j=>c.has(j));if(d.length<2||d.length!==l.length)return;let p=-1;for(let j=0;j<d.length;j++)if(d[j]!==l[j]){p=j;break}if(p===-1)return;const m=Date.now(),h=a.current;if(h&&h.sessionId===t&&m-h.ts<X_)return;a.current={sessionId:t,ts:m};const g=Z_(d),f=g?"data_ordering_bug":"rendering_glitch",x=Math.max(0,p-2),b=Math.min(d.length,p+5),y=d.slice(x,b),v=l.slice(x,b),w=y.map(j=>{const E=aa(j);return E?`${E.kind}=${E.value}`:j}),N=v.map(j=>{const E=aa(j);return E?`${E.kind}=${E.value}`:j}),S=o?.slice(-30),T={conversationId:t,rootCause:f,divergenceIndex:p,expectedWindow:y,expectedKeys:w,domWindow:v,domKeys:N,totalExpected:d.length,totalDom:l.length,isStreaming:!!r,dataViolation:g??void 0,actionTrace:S};mt({component:"RenderOrderDetector",event:"dom-order-mismatch",severity:f==="data_ordering_bug"?"error":"warn",details:T}),console.warn(`[RenderOrderDetector] ${f==="data_ordering_bug"?"🔴 DATA ORDERING BUG — events array has wrong seq order":"⚠️ Rendering glitch — data is correct but DOM order diverges"}`,T)})}const tk={},sk={};function nk(t){return t.type==="system"&&t.systemSubtype==="compact_boundary"}const rk=({sessionId:t,messages:e,renderItems:n,toolResults:r=tk,childrenMessages:o=sk,expandedTasks:a=new Set,onToggleTaskExpanded:i,isLoading:l,isStreaming:c,streamingProvider:d,currentQuestionRequest:p,onAnswerQuestion:m,pendingQuestion:h,onAnswerPendingQuestion:g,onDismissPendingQuestion:f,hasMore:x=!1,isLoadingMore:b=!1,onLoadMore:y,branchLineage:v,onNavigateToSession:w,sessionStartTime:N,isSwitchingProvider:S=!1,switchingToProvider:T,jumpToMessageId:C=null,onJumpHandled:j,inlinePermissionPrompt:E,onPlanApprove:A,onPlanReject:L,planOutcomes:$={},actionTrace:oe})=>{const ne=u.useRef(null),B=u.useRef(null),{hasShownContent:Q,newMessageIds:q}=U_({sessionId:t,messages:e}),Z=e,me=v?.branchPointMessageId??null,O=u.useMemo(()=>{const X=[];return Z.forEach(G=>{const V=X[X.length-1];V&&V.type===G.type?V.messages.push(G):X.push({type:G.type,messages:[G],groupIndex:X.length})}),X},[Z]),W=u.useMemo(()=>{if(n&&n.length>0){const V=[];let D=0;for(const be of n)if(be.kind==="message")V.push({kind:"message",message:be.message,groupIndex:D++,groupType:be.message.type,isFirstInGroup:!0,isLastInGroup:!0});else{const Ce={id:be.group.id,messageId:be.group.id,type:"assistant",content:be.group.summary,timestamp:be.group.timestamp,provider:"claude"};V.push({kind:"group",renderItem:be,message:Ce,groupIndex:D++,groupType:"assistant",isFirstInGroup:!0,isLastInGroup:!0})}return V}const X=[];let G;return O.forEach((V,D)=>{V.messages.forEach((be,Ce)=>{const je=Ce===V.messages.length-1,Ee=be.provider==="claude"?be.provider:void 0;let K;if(be.type==="assistant"){const fe=Ee||G;fe&&G&&fe!==G&&(K={from:G,to:fe}),fe&&(G=fe)}X.push({kind:"message",message:be,groupIndex:D,groupType:V.type,isFirstInGroup:Ce===0,isLastInGroup:je,providerSwitch:K})})}),X},[n,O]),ee=u.useMemo(()=>[...W].reverse(),[W]),z=u.useMemo(()=>W.map(X=>X.message.messageId||X.message.id),[W]);ek({conversationId:t??null,expectedOrder:z,containerRef:ne,isStreaming:c,actionTrace:oe});const{showJumpToLatest:re,unseenCount:se,handleJumpToLatest:te}=G_({sessionId:t,messages:e,isStreaming:c,scrollContainerRef:ne}),{visibleCount:xe,visibleReversedItems:_e,hasInternalMore:I,setBlockBudget:P}=q_({sessionId:t,reversedItems:ee,hasMore:x,isLoadingMore:b,onLoadMore:y,topSentinelRef:B,scrollContainerRef:ne,initialBudget:lp,budgetStep:lr});W_({jumpToMessageId:C,reversedItems:ee,visibleCount:xe,setBlockBudget:P,scrollContainerRef:ne,onJumpHandled:j,blockBudgetStep:lr}),u.useMemo(()=>Z.some(X=>X.type==="assistant"&&Array.isArray(X.content)?X.content.some(G=>{if(G.type==="tool_use"&&G.id){const V=r[G.id];return!V||V.status==="pending"}return!1}):!1),[Z,r]);const de=u.useCallback(X=>{const G=X.message.messageId||X.message.id,V=G;if(X.kind==="group")return s.jsx("div",{className:"w-full flex justify-center","data-message-id":V,children:s.jsx("div",{className:"w-full max-w-5xl px-4 py-1",children:s.jsx(Zs,{name:"CollapsedGroup",children:s.jsx(Qo,{group:X.renderItem.group,temporalState:X.renderItem.temporalState})})})},V);const D=me!==null&&me===G,be=q.get(V),Ce=be!==void 0,je=X.groupType==="assistant",Ee=Ce&&!je,K=nk(X.message),fe=c&&je;return s.jsx("div",{className:`w-full flex justify-center ${Ee?"animate-message-in":""}`,style:Ee&&be!==void 0&&be>0?{animationDelay:`${be*120}ms`}:void 0,"data-message-id":V,children:s.jsxs("div",{className:"w-full max-w-5xl px-4 py-1",children:[K?s.jsx(B_,{trigger:X.message.compactMetadata?.trigger,preTokens:X.message.compactMetadata?.preTokens}):s.jsx(Zs,{name:"Message",children:s.jsx(cp,{message:X.message,toolResults:r,childrenMessages:o,expandedTasks:a,onToggleTaskExpanded:i,isFirstInGroup:X.isFirstInGroup,isLastInGroup:X.isLastInGroup,isStreaming:fe,currentQuestionRequest:p,onAnswerQuestion:m,onPlanApprove:A,onPlanReject:L,planOutcomes:$})}),D&&v&&w&&s.jsxs("div",{"data-testid":"branch-point-indicator","data-branch-turn":v.atTurn,className:"flex items-center gap-2 mt-3 mb-1 py-2 text-sm text-muted-foreground/60 border-t border-b border-cyan-400/20",children:[s.jsx(ya,{size:14,className:"text-cyan-400/60"}),s.jsxs("span",{children:["Branched from"," ",s.jsx("button",{onClick:()=>w(v.parentSessionId),className:"text-cyan-400/80 hover:text-cyan-400 hover:underline cursor-pointer",children:"parent session"})," ","at turn ",v.atTurn]})]})]})},V)},[r,o,a,i,c,p,m,me,v,w,q,A,L,$]);return Z.length===0&&!l?s.jsxs("div",{className:"flex-1 flex flex-col justify-end relative bg-background scrollbar-auto-hide overflow-hidden",children:[s.jsx("div",{className:"relative z-10 w-full flex justify-center p-8",children:s.jsxs("div",{className:"w-full max-w-5xl px-4",children:[!c&&!E&&s.jsx("div",{className:"text-center text-muted-foreground animate-message-in",children:s.jsx("p",{children:"No messages yet. Start by typing a message below."})}),E&&s.jsx("div",{className:"py-1",children:E})]})}),c&&s.jsx("div",{className:"w-full flex justify-center py-2",children:s.jsx(Dc,{isVisible:!0,startTime:N})})]}):s.jsxs("div",{className:`flex-1 min-h-0 relative bg-background transition-opacity duration-300 ease-out ${Q?"opacity-100":"opacity-0"}`,children:[s.jsxs("div",{ref:ne,"data-testid":"message-list",className:"h-full min-h-0 relative overflow-y-auto overflow-x-hidden bg-background flex flex-col-reverse scrollbar-auto-hide",style:{overflowAnchor:"none"},children:[S&&s.jsx("div",{className:"w-full flex justify-center py-3",children:s.jsx("div",{className:"flex items-center gap-2 text-[10px] font-display font-bold uppercase tracking-wider text-stone-400 animate-pulse",children:s.jsx("span",{children:"Switching to Claude..."})})}),!l&&O.length>0&&s.jsx("div",{className:"w-full grid transition-all duration-300 ease-out",style:{gridTemplateRows:c?"1fr":"0fr"},children:s.jsx("div",{className:"overflow-hidden flex justify-center",children:s.jsx("div",{className:c?"py-2":"py-0",children:s.jsx(Dc,{isVisible:!!c,startTime:N})})})}),!c&&h&&g&&s.jsx("div",{className:"w-full flex justify-center relative z-10",children:s.jsx("div",{className:"w-full max-w-5xl px-4 py-1",children:s.jsx(Zs,{name:"PendingQuestion",children:s.jsx(tu,{input:{questions:h.questions},result:"",questionId:h.id,onAnswer:g,onDismiss:f,isRecovered:!0})})})}),E&&s.jsx("div",{className:"w-full flex justify-center relative z-10",children:s.jsx("div",{className:"w-full max-w-5xl px-4 py-1",children:E})}),_e.map(X=>de(X)),l&&Z.length===0&&s.jsx("div",{className:"flex items-center justify-center p-8 relative z-10",children:s.jsxs("div",{className:"flex gap-1",children:[s.jsx("span",{className:"w-1 h-1 bg-blue-500 rounded-full animate-bounce [animation-delay:-0.32s]"}),s.jsx("span",{className:"w-1 h-1 bg-blue-500 rounded-full animate-bounce [animation-delay:-0.16s]"}),s.jsx("span",{className:"w-1 h-1 bg-blue-500 rounded-full animate-bounce"})]})}),b&&s.jsx("div",{className:"flex items-center justify-center p-4 relative z-10",children:s.jsxs("div",{className:"flex gap-1",children:[s.jsx("span",{className:"w-1 h-1 bg-muted-foreground rounded-full animate-bounce [animation-delay:-0.32s]"}),s.jsx("span",{className:"w-1 h-1 bg-muted-foreground rounded-full animate-bounce [animation-delay:-0.16s]"}),s.jsx("span",{className:"w-1 h-1 bg-muted-foreground rounded-full animate-bounce"})]})}),I&&!b&&s.jsx("div",{ref:B,className:"h-1 w-full shrink-0"})]}),re&&s.jsx("div",{className:"pointer-events-none absolute bottom-4 left-0 right-0 z-20 flex justify-center",children:s.jsx("div",{className:"w-full max-w-5xl px-4 flex justify-end pointer-events-none",children:s.jsxs("button",{"data-testid":"jump-to-latest",onClick:te,className:"pointer-events-auto flex items-center gap-1.5 px-3 py-1.5 rounded-sm border border-cyan-500/30 bg-background/90 backdrop-blur-sm text-cyan-300 text-xs font-display font-bold uppercase tracking-wider hover:border-cyan-400 hover:bg-cyan-500/10 transition-colors cursor-pointer shadow-lg shadow-black/20",children:[s.jsx(ih,{size:12}),"Latest",se>0&&s.jsx("span",{className:"ml-0.5 min-w-[18px] h-[18px] flex items-center justify-center rounded-full bg-cyan-500/20 text-cyan-300 text-[10px] font-bold tabular-nums px-1",children:se>99?"99+":se})]})})})]})},Mn=[{id:"skills",label:"Skills",icon:ja,color:"purple"},{id:"mode",label:"Mode",icon:Ms,color:"cyan"},{id:"mcp",label:"MCP",icon:Df,color:"emerald"}],ok=[],uo=[{value:"default",label:"ASK",description:"",icon:Ms,activeClassName:"bg-cyan-500/10",iconClassName:"text-cyan-400",textClassName:"text-cyan-400"},{value:"acceptEdits",label:"AUTO",description:"Allow workspace writes and safe commands. Prompt for actions outside the sandbox.",icon:Zh,activeClassName:"bg-emerald-500/10",iconClassName:"text-emerald-400",textClassName:"text-emerald-400"},{value:"bypassPermissions",label:"TRUST",description:"Skip all permission prompts. Runs freely with no restrictions.",icon:mr,activeClassName:"bg-amber-500/10",iconClassName:"text-amber-400",textClassName:"text-amber-400"}],ak={mapper:{icon:$h,color:"purple"},locator:{icon:Vh,color:"blue"},adversarial:{icon:a0,color:"rose"},note:{icon:l0,color:"amber"},look:{icon:Ro,color:"emerald"},debuglog:{icon:Gl,color:"orange"},rightpanel:{icon:Lf,color:"cyan"},amppanel:{icon:as,color:"violet"}},Fc={purple:{text:"text-purple-400",icon:"text-purple-400"},blue:{text:"text-blue-400",icon:"text-blue-400"},rose:{text:"text-rose-400",icon:"text-rose-400"},amber:{text:"text-amber-400",icon:"text-amber-400"},emerald:{text:"text-emerald-400",icon:"text-emerald-400"},orange:{text:"text-orange-400",icon:"text-orange-400"},cyan:{text:"text-cyan-400",icon:"text-cyan-400"},violet:{text:"text-violet-400",icon:"text-violet-400"}},ik={icon:ja,color:"purple"};function Vc(t){const e=t.replace(/^\//,"").toLowerCase();return ak[e]||ik}function ck({isOpen:t,onClose:e,onSelectSkill:n,skills:r,mcpServers:o=ok,permissionMode:a,onPermissionModeChange:i,provider:l="claude"}){const[c,d]=u.useState("skills"),[p,m]=u.useState(null),[h,g]=u.useState(""),[f,x]=u.useState(0),[b,y]=u.useState(0),[v,w]=u.useState("categories"),N=u.useRef(null),S=u.useRef(null);u.useEffect(()=>{t||(d("skills"),m(null),g(""),x(0),y(0),w("categories"))},[t]),u.useEffect(()=>{p&&S.current&&S.current.focus()},[p]);const T=u.useCallback(()=>{p&&(n(p.name,h||void 0),e())},[p,h,n,e]);u.useEffect(()=>{if(!t)return;const j=E=>{if(p&&document.activeElement===S.current){E.key==="Escape"?(m(null),g(""),E.preventDefault()):E.key==="Enter"&&(T(),E.preventDefault());return}const A=c==="skills"?r.length:c==="mcp"?o.length:uo.length;switch(E.key){case"Escape":e(),E.preventDefault();break;case"ArrowDown":v==="categories"?x(L=>Math.min(L+1,Mn.length-1)):y(L=>Math.min(L+1,A-1)),E.preventDefault();break;case"ArrowUp":v==="categories"?x(L=>Math.max(L-1,0)):y(L=>Math.max(L-1,0)),E.preventDefault();break;case"ArrowLeft":v==="items"&&w("categories"),E.preventDefault();break;case"ArrowRight":v==="categories"&&(d(Mn[f].id),w("items"),y(0)),E.preventDefault();break;case"Enter":if(v==="categories")d(Mn[f].id),w("items"),y(0);else if(c==="skills"&&r[b])m(r[b]);else if(c==="mode"){const L=uo[b]?.value??"default";i(L),e()}E.preventDefault();break}};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[t,c,p,f,b,v,r,o.length,e,i,T]);const C=j=>j.replace(/^\//,"");return t?s.jsxs("div",{ref:N,className:"absolute bottom-full mb-2 right-0 max-w-[400px] w-full bg-background/95 backdrop-blur-md border border-border/50 rounded-lg shadow-xl overflow-hidden animate-in fade-in slide-in-from-bottom-2 duration-150 z-50",children:[p?(()=>{const j=Vc(p.name),E=Fc[j.color],A=j.icon;return s.jsxs("div",{className:"p-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsxs("div",{className:$e("flex items-center gap-2 px-2 py-1 rounded-sm",`bg-${j.color}-500/10 border border-${j.color}-500/30`),children:[s.jsx(A,{size:14,className:E.icon}),s.jsx("span",{className:$e("font-display text-xs font-bold uppercase tracking-wider",E.text),children:C(p.name)})]}),p.description&&s.jsx("span",{className:"text-xs text-muted-foreground",children:p.description})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{ref:S,type:"text",value:h,onChange:L=>g(L.target.value),onKeyDown:L=>{L.key==="Enter"?(T(),L.preventDefault()):L.key==="Escape"&&(m(null),g(""),L.preventDefault())},placeholder:p.argumentHint||"Optional arguments...",className:$e("flex-1 px-3 py-2 bg-background/50 border border-border/50 rounded-sm text-sm text-foreground placeholder:text-muted-foreground/40 focus:outline-none",`focus:border-${j.color}-500/50`)}),s.jsx("button",{onClick:T,className:$e("flex items-center gap-2 px-3 py-1.5 rounded-sm bg-background/80 backdrop-blur-sm border text-xs font-display font-bold uppercase tracking-wider transition-all duration-100 cursor-pointer",`border-${j.color}-500/30 ${E.text}`,`hover:border-${j.color}-400 hover:bg-${j.color}-500/5`),children:"Launch"})]}),s.jsxs("div",{className:"mt-3 text-[10px] text-muted-foreground/50 font-mono",children:[s.jsx("kbd",{className:"px-1 py-0.5 rounded bg-muted/30 text-muted-foreground/70",children:"Enter"})," launch",s.jsx("span",{className:"mx-2",children:"·"}),s.jsx("kbd",{className:"px-1 py-0.5 rounded bg-muted/30 text-muted-foreground/70",children:"Esc"})," back"]})]})})():s.jsxs("div",{className:"flex",children:[s.jsx("div",{className:"w-10 border-r border-border/30 py-2 flex flex-col items-center gap-1",children:Mn.map((j,E)=>{const A=j.icon,L=c===j.id,$=v==="categories"&&f===E,oe={purple:"text-purple-400 bg-purple-500/10",cyan:"text-cyan-400 bg-cyan-500/10",emerald:"text-emerald-400 bg-emerald-500/10"};return s.jsx("button",{onClick:()=>{d(j.id),w("items"),y(0)},className:$e("p-1.5 rounded transition-all cursor-pointer",L||$?oe[j.color]:"text-muted-foreground hover:text-foreground hover:bg-muted/30"),title:j.label,children:s.jsx(A,{size:14})},j.id)})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[c==="skills"&&s.jsx("div",{className:"py-1 max-h-72 overflow-y-auto",children:r.length===0?s.jsx("div",{className:"py-8 text-center text-muted-foreground/50 text-xs font-display uppercase tracking-wider",children:"No skills available"}):r.map((j,E)=>{const A=v==="items"&&b===E,L=Vc(j.name),$=Fc[L.color],oe=L.icon;return s.jsxs("button",{onClick:()=>m(j),className:$e("w-full text-left px-3 py-2.5 transition-all cursor-pointer flex items-start gap-3",A?"bg-muted/30":"hover:bg-muted/30"),children:[s.jsx(oe,{size:16,className:$e($.icon,"mt-0.5 shrink-0")}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:$e("text-sm font-medium",$.text),children:C(j.name)}),j.description&&s.jsx("div",{className:"text-[11px] text-muted-foreground/50 leading-relaxed mt-0.5",children:j.description})]})]},j.name)})}),c==="mode"&&s.jsx("div",{className:"p-2 space-y-1.5",children:uo.map((j,E)=>{const A=j.icon,L=a===j.value,$=v==="items"&&b===E,oe=j.value==="default"?"Prompt before every tool use.":j.description;return s.jsxs("button",{onClick:()=>{i(j.value),e()},className:$e("w-full text-left px-3 py-2.5 rounded-sm transition-all cursor-pointer flex items-start gap-3",L||$?j.activeClassName:"hover:bg-muted/30"),children:[s.jsx(A,{size:16,className:$e(j.iconClassName,"mt-0.5 shrink-0")}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:$e("text-sm font-medium",j.textClassName),children:j.label}),L&&s.jsx(Oe,{size:12,className:j.iconClassName})]}),s.jsx("div",{className:"text-[11px] text-muted-foreground/50 leading-relaxed mt-0.5",children:oe})]})]},j.value)})}),c==="mcp"&&s.jsx("div",{className:"p-2 space-y-1",children:o.length===0?s.jsx("div",{className:"py-8 text-center text-muted-foreground/50 text-xs font-display uppercase tracking-wider",children:"No MCP servers connected"}):o.map((j,E)=>{const A=v==="items"&&b===E,L=j.status==="connected",$=j.status==="configured",oe=L?"bg-emerald-400":$?"bg-stone-500":"bg-amber-400",ne=L?"text-emerald-400/70":$?"text-stone-500/70":"text-amber-400/70";return s.jsxs("div",{className:$e("px-3 py-2.5 rounded-sm flex items-center gap-3",A?"bg-muted/30":""),children:[s.jsx("div",{className:$e("w-2 h-2 rounded-full shrink-0",oe)}),s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx("span",{className:"text-sm font-medium text-foreground",children:j.name})}),s.jsx("span",{className:$e("text-[10px] font-display uppercase tracking-wider",ne),children:j.status})]},j.name)})})]})]}),!p&&s.jsxs("div",{className:"px-3 py-2 border-t border-border/30 text-[10px] text-muted-foreground/50 font-mono flex gap-4",children:[s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1 py-0.5 rounded bg-muted/30 text-muted-foreground/70",children:"↑↓"})," navigate"]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1 py-0.5 rounded bg-muted/30 text-muted-foreground/70",children:"←→"})," switch"]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1 py-0.5 rounded bg-muted/30 text-muted-foreground/70",children:"Enter"})," select"]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1 py-0.5 rounded bg-muted/30 text-muted-foreground/70",children:"Esc"})," close"]})]})]}):null}function lk(t){return t.type==="image"?{type:"image",source:{type:"base64",media_type:t.mimeType,data:t.base64}}:t.type==="text"?{type:"text",text:`[File: ${t.fileName}]
|
|
135
|
+
${t.textContent}`}:{type:"document",source:{type:"base64",media_type:"application/pdf",data:t.base64}}}const pp=u.forwardRef(function(e,n){const{core:r,features:o,skills:a=[],mcpServers:i=[],...l}=e,[c,d]=u.useState("default"),[p,m]=u.useState(void 0),h=Ie.useRef(null);Ie.useImperativeHandle(n,()=>({focusInput:()=>h.current?.focusInput()}));const g=r?.onSubmit,f=u.useCallback((b,y)=>{const v=y?.attachments?.map(lk);return g?.(b,y?.workingDirectory,void 0,c==="default"?void 0:c,v)},[g,c]),x=o?.showSmartMenu??!1;return s.jsx("div",{className:"lattice-composer",children:s.jsx(I_,{ref:h,core:r?{...r,onSubmit:f,value:p,onChange:b=>{m(void 0),r.onChange?.(b)}}:void 0,features:{...o,showMenu:x},renderMenu:x?({onClose:b})=>s.jsx(ck,{isOpen:!0,onClose:b,onSelectSkill:(y,v)=>{const w=v?`${y} ${v}`:y;m(w),b(),setTimeout(()=>h.current?.focusInput(),0)},skills:a,mcpServers:i,permissionMode:c,onPermissionModeChange:d,provider:"claude"}):void 0,...l})})}),Ot=np,Ke=rp,Qe=op,qe=u.forwardRef(({className:t,sideOffset:e=8,label:n="Info",icon:r,children:o,...a},i)=>s.jsx(ap,{children:s.jsxs(Rr,{ref:i,sideOffset:e,className:$e("z-50 max-w-[360px] overflow-hidden rounded-lg border border-zinc-500/20 bg-zinc-500/5 backdrop-blur-md","animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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",t),...a,children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-zinc-500/10",children:[s.jsx("span",{className:"text-zinc-400 shrink-0",children:r??s.jsx(df,{size:14})}),s.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-400",children:n})]}),s.jsx("div",{className:"px-3 py-2 text-[11px] font-mono text-foreground/90 leading-relaxed whitespace-pre-wrap",children:o})]})}));qe.displayName=Rr.displayName;const dk={ArrowRight:dh,FileCode:Wh,FlaskConical:Hl,GitBranch:ya,GitCommit:sf,ListChecks:gf,Play:Gt,RefreshCw:ds,Rocket:Jf,Search:Ql,Sparkles:_a,TestTube:m0,Wrench:ka};function uk(t){if(!t)return null;const e=t.replace(/Icon$/,"");return dk[e]??null}const Bc=Ie.forwardRef(function({onTap:e,className:n,children:r,onClick:o,...a},i){const l=u.useRef(!1),c=u.useCallback(p=>{p.preventDefault(),l.current=!0,e(),setTimeout(()=>{l.current=!1},300)},[e]),d=u.useCallback(p=>{l.current||(e(),o?.(p))},[e,o]);return s.jsx("button",{ref:i,...a,onClick:d,onTouchEnd:c,className:n,style:{touchAction:"manipulation",WebkitTapHighlightColor:"transparent"},children:r})});function Uc({content:t,children:e}){return s.jsxs(Ke,{delayDuration:300,children:[s.jsx(Qe,{asChild:!0,children:e}),s.jsx(qe,{side:"top",sideOffset:8,label:"Prompt",children:t})]})}function pk({steps:t,onSelect:e,onDismiss:n}){return t.length===0?s.jsx(s.Fragment,{}):s.jsx(Ot,{children:s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"text-[10px] font-mono text-muted-foreground/50 uppercase tracking-wider",children:"Next"}),t.map(r=>{const o=uk(r.icon),a=r.description||r.prompt;return s.jsx(Uc,{content:a,children:s.jsxs(Bc,{onTap:()=>e(r.prompt),className:`flex items-center gap-2 px-3 py-2.5 min-h-[44px] rounded-sm
|
|
136
136
|
bg-background/80 backdrop-blur-sm
|
|
137
137
|
border border-sky-500/30
|
|
138
138
|
text-sky-400 text-[11px] font-display font-bold uppercase tracking-wider
|
|
@@ -146,8 +146,8 @@ ${t.textContent}`}:{type:"document",source:{type:"base64",media_type:"applicatio
|
|
|
146
146
|
text-zinc-500 text-[10px]
|
|
147
147
|
hover:border-zinc-600 hover:text-zinc-400
|
|
148
148
|
active:bg-zinc-700/20
|
|
149
|
-
transition-all duration-100 cursor-pointer select-none`,children:s.jsx(Be,{size:14})})})]})})}const mp=Math.PI/6,mk=Math.cos(mp),hk=Math.sin(mp);function fk(t,e,n,r=20,o=50,a=50){const i=(t-n)*mk*r+o,l=(t+n)*hk*r-e*r+a;return{x:i,y:l}}const po={cyan:{base:"#22d3ee",glow:"rgba(34,211,238,"},amber:{base:"#fbbf24",glow:"rgba(251,191,36,"},purple:{base:"#a855f7",glow:"rgba(168,85,247,"},emerald:{base:"#34d399",glow:"rgba(52,211,153,"},rose:{base:"#fb7185",glow:"rgba(251,113,133,"}};function hp({size:t=100,colorScheme:e="gradient",interactive:n=!0,className:r}){const[o,a]=u.useState({x:50,y:50}),{nodes:i,edges:l}=u.useMemo(()=>{const f=[],x=[];for(let b=0;b<3;b++)for(let y=0;y<3;y++)for(let v=0;v<3;v++){const w=`${b}-${y}-${v}`,N=fk(b-1,y-1,v-1,15,50,50);let S="cyan";if(e==="gradient")y===2?S="cyan":y===1?S="purple":S="amber";else if(e==="rainbow"){const T=["cyan","amber","purple","emerald","rose"];S=T[(b+y+v)%T.length]}f.push({id:w,x:b,y,z:v,iso:N,color:S})}for(const b of f){const{x:y,y:v,z:w}=b;y<2&&x.push({from:b.id,to:`${y+1}-${v}-${w}`}),v<2&&x.push({from:b.id,to:`${y}-${v+1}-${w}`}),w<2&&x.push({from:b.id,to:`${y}-${v}-${w+1}`})}return{nodes:f,edges:x}},[e]),c=u.useCallback(f=>{if(!n)return;const x=f.currentTarget.getBoundingClientRect();a({x:(f.clientX-x.left)/x.width*100,y:(f.clientY-x.top)/x.height*100})},[n]),d=u.useCallback(()=>{n&&a({x:50,y:50})},[n]),p=u.useCallback(f=>{if(!n)return .2;const x=o.x-f.iso.x,b=o.y-f.iso.y,y=Math.sqrt(x*x+b*b);return Math.max(.15,.7*(1-y/45))},[o,n]),m=u.useCallback((f,x)=>{if(!n)return .15;const b=(f.iso.x+x.iso.x)/2,y=(f.iso.y+x.iso.y)/2,v=o.x-b,w=o.y-y,N=Math.sqrt(v*v+w*w);return Math.max(.1,.6*(1-N/50))},[o,n]),h=u.useMemo(()=>[...i].sort((f,x)=>f.x+f.z-(x.x+x.z)),[i]),g=u.useMemo(()=>{const f=new Map;for(const x of i)f.set(x.id,x);return f},[i]);return s.jsxs("svg",{width:t,height:t,viewBox:"0 0 100 100",onMouseMove:c,onMouseLeave:d,className:r,children:[s.jsx("defs",{children:Object.entries(po).map(([f,x])=>s.jsxs("filter",{id:`glow-${f}`,x:"-100%",y:"-100%",width:"300%",height:"300%",children:[s.jsx("feGaussianBlur",{stdDeviation:"2",result:"blur"}),s.jsx("feFlood",{floodColor:x.base,result:"color"}),s.jsx("feComposite",{in:"color",in2:"blur",operator:"in",result:"glow"}),s.jsxs("feMerge",{children:[s.jsx("feMergeNode",{in:"glow"}),s.jsx("feMergeNode",{in:"glow"}),s.jsx("feMergeNode",{in:"SourceGraphic"})]})]},f))}),l.map((f,x)=>{const b=g.get(f.from),y=g.get(f.to),v=m(b,y),w=po[b.color];return s.jsx("line",{x1:b.iso.x,y1:b.iso.y,x2:y.iso.x,y2:y.iso.y,stroke:w.base,strokeWidth:1.5,opacity:v,style:{transition:n?"opacity 0.15s ease-out":void 0}},x)}),h.map(f=>{const x=p(f),b=po[f.color],y=3+x*2;return s.jsxs("g",{children:[x>.35&&s.jsx("circle",{cx:f.iso.x,cy:f.iso.y,r:y+x*4,fill:`${b.glow}${x*.2})`,style:{transition:n?"all 0.15s ease-out":void 0}}),s.jsx("circle",{cx:f.iso.x,cy:f.iso.y,r:y,fill:b.base,opacity:.2+x*.6,filter:x>.5?`url(#glow-${f.color})`:void 0,style:{transition:n?"all 0.15s ease-out":void 0}})]},f.id)})]})}const ia=3e4;function gk(){let t=sessionStorage.getItem("connectionDebugTraceId");return t||(t=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,sessionStorage.setItem("connectionDebugTraceId",t)),t}let Pr=!1,ns=null;function xk(){return Pr}function bk(){return ns}function Rt(t,e,n){if(!Pr)return;const r=ns?`[${ns.slice(0,8)}]`:"";console.log(`%c[ConnDebug]%c ${r} %c${t}%c:${e}`,"background: #4a5568; color: white; padding: 1px 4px; border-radius: 2px;","color: #718096;","color: #48bb78; font-weight: bold;","color: #9ae6b4;",n||""),fetch("/api/system/debug/connection/log",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({component:t,event:e,details:n,traceId:ns})}).catch(()=>{})}async function yk(){Pr=!0,ns=gk();try{await fetch("/api/system/debug/connection/enable",{method:"POST"}),console.log("%c[ConnDebug] Enabled%c - trace ID: %c"+ns,"background: #48bb78; color: white; padding: 2px 6px; border-radius: 3px;","color: #9ae6b4;","color: #48bb78; font-weight: bold;"),console.log("%c[ConnDebug]%c Backend logs: ~/.lattice/logs/connection-debug.log","background: #4a5568; color: white; padding: 1px 4px; border-radius: 2px;","color: #a0aec0;")}catch(t){console.error("[ConnDebug] Failed to enable backend logging:",t)}Rt("Debug","enabled",{url:window.location.href,userAgent:navigator.userAgent,timestamp:new Date().toISOString()})}async function vk(){Rt("Debug","disabled"),Pr=!1,ns=null;try{await fetch("/api/system/debug/connection/disable",{method:"POST"}),console.log("%c[ConnDebug] Disabled","background: #718096; color: white; padding: 2px 6px; border-radius: 3px;")}catch(t){console.error("[ConnDebug] Failed to disable backend logging:",t)}}async function wk(t=200){try{return(await(await fetch(`/api/system/debug/connection/logs?limit=${t}`)).json()).logs}catch(e){return console.error("[ConnDebug] Failed to fetch logs:",e),[]}}async function _k(){try{await fetch("/api/system/debug/connection/logs",{method:"DELETE"})}catch(t){console.error("[ConnDebug] Failed to clear logs:",t)}}async function kk(){const t=await wk();console.log("%c[ConnDebug] Recent Logs ("+t.length+")","background: #4a5568; color: white; padding: 4px 8px; border-radius: 3px; font-size: 14px;"),t.forEach(e=>{const n=e,r=n.source==="frontend"?"#48bb78":"#4299e1";console.log(`%c${n.source}%c ${n.timestamp.slice(11,23)} %c${n.component}%c:${n.event}`,`background: ${r}; color: white; padding: 1px 4px; border-radius: 2px;`,"color: #718096;","color: #ed8936;","color: #fbd38d;",n.details||"")})}typeof window<"u"&&(window.__enableConnectionDebug=yk,window.__disableConnectionDebug=vk,window.__viewConnectionLogs=kk,window.__clearConnectionLogs=_k,window.__connectionDebug={log:Rt,isEnabled:xk,getTraceId:bk});function ca(t,e,n){jk({conversationId:t,milestone:e,clientTimestamp:Date.now(),fields:n})}function jk(t){try{fetch("/api/timeline/milestone",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),keepalive:!0}).catch(()=>{})}catch{}}const Gc="/api/logs/incidents",fp=6e4,Nk=4,Sk=6e4,Ck=new Map;let Hc=!1,Mt={};function Ek(t){Mt={...t}}function Tk(){Mt={}}function la(){return typeof window>"u"?"":`${window.location.pathname}${window.location.search}`}function Ik(t,e){return up(Ck,t,e,Nk,Sk)}function Rs(t){if(typeof window>"u")return;const e=Date.now(),n=`${t.type}:${t.severity}:${t.route||la()}:${t.message||""}`;if(!Ik(n,e))return;const r=JSON.stringify({incidents:[{conversationId:t.conversationId??Mt.conversationId,sessionId:t.sessionId??Mt.sessionId,streamingId:t.streamingId??Mt.streamingId,...t,route:t.route||la()}]});try{if(typeof navigator<"u"&&typeof navigator.sendBeacon=="function"&&typeof Blob<"u"&&r.length<=fp&&navigator.sendBeacon(Gc,new Blob([r],{type:"application/json"})))return}catch{}fetch(Gc,{method:"POST",headers:{"Content-Type":"application/json"},body:r,keepalive:!0}).catch(()=>{})}const qc="/api/logs/console",Ak=2e3,Rk=50;let en=[];function da(){if(en.length===0)return;const t=en;en=[];const e=JSON.stringify({entries:t});try{if(typeof navigator<"u"&&typeof navigator.sendBeacon=="function"&&typeof Blob<"u"&&e.length<=fp&&navigator.sendBeacon(qc,new Blob([e],{type:"application/json"})))return}catch{}fetch(qc,{method:"POST",headers:{"Content-Type":"application/json"},body:e,keepalive:!0}).catch(()=>{})}function Wc(t,e){const n=e.map(r=>typeof r=="string"?r:r instanceof Error?r.message:JSON.stringify(r)).join(" ").slice(0,500);en.push({level:t,message:n,timestamp:new Date().toISOString(),route:la(),conversationId:Mt.conversationId,sessionId:Mt.sessionId}),en.length>=Rk&&da()}let Kc=!1;function Pk(){if(Kc||typeof window>"u")return;Kc=!0;const t=console.warn.bind(console),e=console.error.bind(console);console.warn=(...n)=>{t(...n),Wc("warn",n)},console.error=(...n)=>{e(...n),Wc("error",n)},setInterval(da,Ak),window.addEventListener("beforeunload",da)}function Mk(){Hc||typeof window>"u"||(Hc=!0,window.addEventListener("error",t=>{Rs({type:"window-error",severity:"error",message:t.message||"Unhandled window error",...Mt,details:{filename:t.filename||null,lineno:t.lineno||null,colno:t.colno||null}})}),window.addEventListener("unhandledrejection",t=>{const e=t.reason instanceof Error?t.reason.message:String(t.reason??"Unhandled promise rejection");Rs({type:"unhandled-rejection",severity:"error",message:e,...Mt})}))}const Lk="lattice:suspected-tab-network-stall",Qc=2e4,Ok=6e4,Dk=12,$k=12;class zk{pendingRequests=new Map;recentOutcomes=[];streams=new Map;lastStallIncidentAtMs=0;requestCounter=0;beginApiRequest(e){const n=`req-${Date.now().toString(36)}-${this.requestCounter++}`;return this.pendingRequests.set(n,{id:n,method:e.method,path:e.path,timeoutMs:e.timeoutMs,startedAtMs:Date.now()}),n}finishApiRequest(e,n){this.pendingRequests.delete(e),this.pushOutcome({at:new Date().toISOString(),status:n.status,method:n.method,path:n.path,durationMs:n.durationMs,timeoutMs:n.timeoutMs,error:n.error}),(n.status==="timeout"||n.status==="failed")&&this.maybeReportSuspectedStall({source:"api",reason:n.status==="timeout"?"request-timeout":"request-failed",method:n.method,path:n.path,status:n.status})}noteStreamConnecting(e){this.upsertStream(e,{status:"connecting"})}noteStreamOpen(e){this.upsertStream(e,{status:"open",connectedAtMs:Date.now(),lastError:void 0})}noteStreamActivity(e){const n=this.streams.get(e);n&&(n.lastEventAtMs=Date.now(),n.status!=="open"&&(n.status="open",n.lastStateAtMs=n.lastEventAtMs))}noteStreamError(e,n){this.upsertStream(e,{status:"error",lastError:n}),this.maybeReportSuspectedStall({source:"stream",reason:"stream-error",streamKind:e.kind,streamKey:e.key})}noteStreamClosed(e,n){this.upsertStream(e,{status:"closed",lastError:n})}upsertStream(e,n){const r=Date.now(),o=this.streams.get(e.key),a={key:e.key,kind:e.kind,sessionId:e.sessionId,streamingId:e.streamingId,status:n.status??o?.status??"closed",lastStateAtMs:r,connectedAtMs:n.connectedAtMs??o?.connectedAtMs,lastEventAtMs:n.lastEventAtMs??o?.lastEventAtMs,lastError:n.lastError??o?.lastError};this.streams.set(e.key,a),this.pruneStreams()}pushOutcome(e){const n=Date.now()-Qc;this.recentOutcomes.push(e),this.recentOutcomes=this.recentOutcomes.filter(r=>Date.parse(r.at)>=n).slice(-40)}pruneStreams(){const e=Date.now()-18e5;for(const[n,r]of this.streams.entries())r.status==="closed"&&r.lastStateAtMs<e&&this.streams.delete(n)}maybeReportSuspectedStall(e){if(typeof window>"u")return;const n=Date.now();if(n-this.lastStallIncidentAtMs<Ok)return;const r=this.recentOutcomes.filter(h=>n-Date.parse(h.at)<=Qc),o=r.filter(h=>h.status==="timeout"||h.status==="failed"),a=new Set(o.map(h=>`${h.method} ${h.path}`)),i=o.filter(h=>h.status==="timeout").length,l=Array.from(this.pendingRequests.values()),c=l.reduce((h,g)=>{const f=n-g.startedAtMs;return f>h?f:h},0);if(!(i>=2&&a.size>=2||o.length>=4&&a.size>=3||l.length>=6&&c>=1e4&&o.length>=2))return;this.lastStallIncidentAtMs=n;const p=Array.from(this.streams.values()).sort((h,g)=>g.lastStateAtMs-h.lastStateAtMs).slice(0,$k).map(h=>({key:h.key,kind:h.kind,sessionId:h.sessionId,streamingId:h.streamingId,status:h.status,connectedAgeMs:h.connectedAtMs?n-h.connectedAtMs:null,lastEventAgeMs:h.lastEventAtMs?n-h.lastEventAtMs:null,lastStateAgeMs:n-h.lastStateAtMs,lastError:h.lastError})),m=l.sort((h,g)=>h.startedAtMs-g.startedAtMs).slice(0,Dk).map(h=>({method:h.method,path:h.path,ageMs:n-h.startedAtMs,timeoutMs:h.timeoutMs}));Rs({type:"suspected-tab-network-stall",severity:"error",message:"Burst of client request failures suggests browser-tab transport stall",details:{trigger:e,visibilityState:document.visibilityState,online:typeof navigator<"u"?navigator.onLine:void 0,pendingRequestCount:l.length,oldestPendingRequestAgeMs:c||0,pendingRequests:m,recentApiOutcomes:r.slice(-12),streamHealth:p}}),window.dispatchEvent(new CustomEvent(Lk,{detail:{trigger:e,pendingRequestCount:l.length,oldestPendingRequestAgeMs:c||0,recentApiOutcomes:r.slice(-12),streamHealth:p}}))}}let mo=null;function Fk(){return mo||(mo=new zk),mo}const Yc=6e4,Jc=2e3,Vk="Request timeout after ",ho=25;function Bk(t){const[e]=t.split("?");return e.replace(/\/conv-[A-Za-z0-9_-]+/g,"/conv-:id").replace(/\/codex-[A-Za-z0-9_-]+/g,"/codex-:id").replace(/\/[0-9a-f]{8}-[0-9a-f-]{27,}/gi,"/:uuid")}function Uk(){return`nav-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`}function Gk(t){return t instanceof Error&&t.message.startsWith(Vk)}class Hk extends Error{status;code;details;constructor(e,n,r,o){super(e),this.name="ApiRequestError",this.status=n,this.code=r,this.details=o}}function qk(t){return t===void 0||t>ho?ho:null}class Wk{baseUrl="";canonicalConversationIdCache=new Map;canonicalConversationIdInFlight=new Map;cachedGetResponses=new Map;cachedGetInFlight=new Map;cachedGetGeneration=new Map;assertUnifiedConversationId(e){if(!e.startsWith("conv-"))throw new Error(`Expected unified conversation ID (conv-*), got "${e}"`)}async resolveCanonicalConversationId(e){if(e.startsWith("conv-"))return e;const n=this.canonicalConversationIdCache.get(e);if(n)return n;const r=this.canonicalConversationIdInFlight.get(e);if(r)return r;const o=this.resolveUnifiedConversationId(e).then(a=>(this.canonicalConversationIdCache.set(e,a.conversationId),a.conversationId)).finally(()=>{this.canonicalConversationIdInFlight.delete(e)});return this.canonicalConversationIdInFlight.set(e,o),o}shouldEnableKeepalive(e){if(!e.keepalive)return!1;const n=e.body;return n?typeof n=="string"?n.length<=Yc:n instanceof URLSearchParams?n.toString().length<=Yc:!1:!0}async apiCall(e,n){const r=`${this.baseUrl}${e}`,o=n?.timeout??ia,a=(n?.method||"GET").toUpperCase(),i=Bk(e),l=performance.now(),c=Fk(),d=c.beginApiRequest({method:a,path:i,timeoutMs:o}),p=new Headers(n?.headers);p.set("Content-Type","application/json");const m=new AbortController,h=setTimeout(()=>m.abort(),o);try{const g={...n||{}};delete g.timeout;const f=this.shouldEnableKeepalive(g),x=await fetch(r,{...g,headers:p,signal:m.signal,keepalive:f});clearTimeout(h);const b=await x.json();if(!x.ok){const v=b,w=v.error||`HTTP ${x.status}`,N=Math.round(performance.now()-l);throw c.finishApiRequest(d,{status:"http_error",method:a,path:i,timeoutMs:o,durationMs:N,error:w}),mt({component:"ApiService",event:"api-request-error",severity:"warn",details:{method:a,path:i,status:x.status,timeoutMs:o,durationMs:N,message:w}}),new Hk(w,x.status,v.code,v)}const y=Math.round(performance.now()-l);return c.finishApiRequest(d,{status:y>=Jc?"slow":"success",method:a,path:i,timeoutMs:o,durationMs:y}),y>=Jc&&mt({component:"ApiService",event:"api-request-slow",severity:"warn",details:{method:a,path:i,durationMs:y,timeoutMs:o}}),b}catch(g){if(clearTimeout(h),g instanceof Error&&g.name==="AbortError"){const x=new Error(`Request timeout after ${o}ms: ${e}`),b=Math.round(performance.now()-l);throw c.finishApiRequest(d,{status:"timeout",method:a,path:i,timeoutMs:o,durationMs:b,error:x.message}),mt({component:"ApiService",event:"api-request-timeout",severity:"error",details:{method:a,path:i,timeoutMs:o,durationMs:b}}),Rs({type:"api-request-timeout",severity:"error",message:x.message,details:{method:a,path:i,timeoutMs:o,durationMs:b}}),x}const f=Math.round(performance.now()-l);throw c.finishApiRequest(d,{status:"failed",method:a,path:i,timeoutMs:o,durationMs:f,error:g instanceof Error?g.message:String(g)}),mt({component:"ApiService",event:"api-request-failed",severity:"error",details:{method:a,path:i,timeoutMs:o,durationMs:f,error:g instanceof Error?g.message:String(g)}}),Rs({type:"api-request-failed",severity:"warn",message:g instanceof Error?g.message:String(g),details:{method:a,path:i,timeoutMs:o,durationMs:f}}),g}}async fetchDirect(e,n){return fetch(e,n)}async cachedGet(e,n,r){const o=Date.now(),a=this.cachedGetResponses.get(e);if(a&&a.expiresAt>o)return a.value;const i=this.cachedGetInFlight.get(e);if(i)return i;const l=this.cachedGetGeneration.get(e)??0,c=r().then(d=>((this.cachedGetGeneration.get(e)??0)===l&&this.cachedGetResponses.set(e,{value:d,expiresAt:Date.now()+n}),d)).finally(()=>{this.cachedGetInFlight.delete(e)});return this.cachedGetInFlight.set(e,c),c}invalidateCachedGet(e){for(const n of this.cachedGetResponses.keys())n.startsWith(e)&&(this.cachedGetResponses.delete(n),this.cachedGetGeneration.set(n,(this.cachedGetGeneration.get(n)??0)+1));for(const n of this.cachedGetInFlight.keys())n.startsWith(e)&&(this.cachedGetInFlight.delete(n),this.cachedGetGeneration.set(n,(this.cachedGetGeneration.get(n)??0)+1))}async resolveUnifiedConversationId(e){return this.apiCall(`/api/conv/resolve/${encodeURIComponent(e)}`)}}const Kk="conversation:session-status:",Qk=750;class Yk extends Wk{async getConversationDetails(e,n){this.assertUnifiedConversationId(e);const r="/api/conv",o=n?.traceId||Uk(),a=performance.now(),i=e.slice(0,8),l=async c=>{const d=new URLSearchParams,p=c??n?.limit;p&&d.set("limit",String(p)),n?.before&&d.set("before",n.before);const m=d.toString(),h=`${r}/${e}${m?`?${m}`:""}`;return this.apiCall(h,{headers:{"X-Trace-Id":o},timeout:n?.timeout})};try{const c=await l(),d=Math.round(performance.now()-a);return d>1e3&&mt({component:"ApiService",event:"conversation-details-slow",severity:"warn",traceId:o,details:{sessionId:i,providerRoute:e.startsWith("conv-")?"unified":"legacy",durationMs:d,timeoutMs:n?.timeout??ia,messageCount:c.messages?.length??0,limit:n?.limit??null,beforeProvided:!!n?.before}}),c}catch(c){const d=Math.round(performance.now()-a),p=Gk(c)?qk(n?.limit):null;if(!p)throw c;mt({component:"ApiService",event:"conversation-details-fallback-start",severity:"warn",traceId:o,details:{sessionId:i,originalLimit:n?.limit??null,fallbackLimit:p,beforeProvided:!!n?.before,timeoutMs:n?.timeout??ia,initialDurationMs:d}});const m=performance.now();try{const h=await l(p),g=Math.round(performance.now()-m);return mt({component:"ApiService",event:"conversation-details-fallback-success",severity:"warn",traceId:o,details:{sessionId:i,fallbackLimit:p,fallbackDurationMs:g,messageCount:h.messages?.length??0,hasMore:h.hasMore??null,oldestMessageId:h.oldestMessageId??null}}),h}catch(h){throw mt({component:"ApiService",event:"conversation-details-fallback-failed",severity:"error",traceId:o,details:{sessionId:i,fallbackLimit:p,error:h instanceof Error?h.message:String(h)}}),h}}}async getConversationStatus(e){this.assertUnifiedConversationId(e);const r=(await this.getSessionsStatus([e])).sessions[e]??{status:"completed",provider:null,streamingId:null,startedAt:null};return{sessionId:e,status:r.status,provider:r.provider,streamingId:r.streamingId,startedAt:r.startedAt}}async getSessionsStatus(e){const r=[...(e??[]).map(i=>i.trim()).filter(i=>i.length>0)].sort(),o=r.length>0?`?ids=${encodeURIComponent(r.join(","))}`:"",a=`${Kk}${r.join(",")}`;return this.cachedGet(a,Qk,()=>this.apiCall(`/api/sessions/status${o}`))}async createConversation(e){const n=performance.now();Rt("ApiService","create-conversation-request",{provider:e.provider,permissionMode:e.permissionMode??null});const r=await this.apiCall("/api/conv/create",{method:"POST",body:JSON.stringify(e),keepalive:!0,timeout:65e3});return Rt("ApiService","create-conversation-response",{conversationId:r.conversationId.slice(0,12),streamingId:r.streamingId.slice(0,8),durationMs:Math.round(performance.now()-n),permissionMode:r.permissionMode??e.permissionMode??null}),ca(r.conversationId,"client.create_response_received",{durationMs:Math.round(performance.now()-n)}),r}async resumeConversation(e,n){const r=performance.now();Rt("ApiService","resume-conversation-request",{conversationId:e.slice(0,12),permissionMode:n.permissionMode??null});const o=await this.apiCall(`/api/conv/${e}/resume`,{method:"POST",body:JSON.stringify(n),keepalive:!0,timeout:65e3});return Rt("ApiService","resume-conversation-response",{conversationId:o.conversationId.slice(0,12),streamingId:o.streamingId.slice(0,8),durationMs:Math.round(performance.now()-r)}),ca(o.conversationId,"client.resume_response_received",{durationMs:Math.round(performance.now()-r)}),o}async getUnifiedConversation(e){return this.apiCall(`/api/conv/${e}`)}async listUnifiedConversations(e){const n=new URLSearchParams;e?.includeIdentityImage!==void 0&&n.set("includeIdentityImage",String(e.includeIdentityImage)),e?.archived!==void 0&&n.set("archived",String(e.archived)),typeof e?.limit=="number"&&Number.isFinite(e.limit)&&e.limit>0&&n.set("limit",String(Math.floor(e.limit))),typeof e?.cursor=="string"&&e.cursor.trim().length>0&&n.set("cursor",e.cursor);const r=n.toString();return this.apiCall(r?`/api/conv?${r}`:"/api/conv")}async getUnifiedConversationIdentityImage(e){return this.apiCall(`/api/conv/${e}/identity-image`)}async unifiedStopConversation(e,n){return this.assertUnifiedConversationId(e),this.apiCall(`/api/conv/${e}/stop`,{method:"POST",body:n?.inFlightMessage?JSON.stringify({inFlightMessage:n.inFlightMessage}):void 0})}async unifiedInterruptConversation(e){return this.assertUnifiedConversationId(e),this.apiCall(`/api/conv/${e}/interrupt`,{method:"POST"})}async unifiedForceKillConversation(e){return this.assertUnifiedConversationId(e),this.apiCall(`/api/conv/${e}/force-kill`,{method:"POST"})}async unifiedInjectMessage(e,n,r){return this.assertUnifiedConversationId(e),this.apiCall(`/api/conv/${e}/inject`,{method:"POST",body:JSON.stringify({message:n,...r&&r.length>0?{initialContent:r}:{}})})}async unifiedUpdateConversation(e,n){return this.assertUnifiedConversationId(e),this.apiCall(`/api/conv/${e}/update`,{method:"PUT",body:JSON.stringify(n)})}async unifiedBranchConversation(e,n,r){return this.assertUnifiedConversationId(e),this.apiCall(`/api/conv/${e}/branch`,{method:"POST",body:JSON.stringify({afterTurn:n,timestamp:r})})}async unifiedGetInsights(e,n=!0){return this.assertUnifiedConversationId(e),this.apiCall(`/api/conv/${e}/insights?quick=${n}`)}async unifiedRefreshInsights(e){return this.assertUnifiedConversationId(e),this.apiCall(`/api/conv/${e}/insights/refresh`,{method:"POST"})}async unifiedGetQueue(e){return this.assertUnifiedConversationId(e),this.apiCall(`/api/conv/${e}/queue`)}async unifiedEnqueueMessage(e,n){return this.assertUnifiedConversationId(e),this.apiCall(`/api/conv/${e}/queue`,{method:"POST",body:JSON.stringify(n)})}async unifiedDeleteQueuedMessage(e,n){return this.assertUnifiedConversationId(e),this.apiCall(`/api/conv/${e}/queue/${n}`,{method:"DELETE"})}async unifiedClearQueue(e){return this.assertUnifiedConversationId(e),this.apiCall(`/api/conv/${e}/queue/clear`,{method:"POST"})}async unifiedArchiveAll(){return this.apiCall("/api/conv/archive-all",{method:"POST"})}async unifiedActivityCheck(e,n,r){return this.apiCall("/api/conv/activity-check",{method:"POST",body:JSON.stringify({sessionIds:e,knownMtimes:n,previouslyActiveSessionIds:r})})}async getConversationIdentityImage(e){const n=await this.resolveCanonicalConversationId(e);return this.getUnifiedConversationIdentityImage(n)}async getLastContextTransfer(e,n){return this.apiCall(`/api/context-transfers/${e}/last?toProvider=${n}`)}}class Jk extends Yk{async getWorkingDirectories(){return this.apiCall("/api/working-directories")}async getPermissions(e){const n=new URLSearchParams;return e?.streamingId&&n.append("streamingId",e.streamingId),e?.sessionId&&n.append("sessionId",e.sessionId),e?.status&&n.append("status",e.status),this.apiCall(`/api/permissions?${n}`)}async sendPermissionDecision(e,n){return this.apiCall(`/api/permissions/${e}/decision`,{method:"POST",body:JSON.stringify(n)})}async addToAllowlist(e,n,r){const o=e==="session"?{pattern:n,streamingId:r}:{pattern:n};return this.apiCall(`/api/permissions/allowlist/${e}`,{method:"POST",body:JSON.stringify(o)})}async getSuggestedPatterns(e,n){return this.apiCall("/api/permissions/suggest-patterns",{method:"POST",body:JSON.stringify({toolName:e,toolInput:n})})}}class Xk extends Jk{async listTeams(){return this.apiCall("/api/teams")}async getTeamInfo(e){return this.apiCall(`/api/teams/${encodeURIComponent(e)}`)}async getTeamInboxes(e){return this.apiCall(`/api/teams/${encodeURIComponent(e)}/inboxes`)}}const Zk=15e3,e2="config:commands:",t2=1e4,s2="config:directory-list:",n2=6e4,r2="config:web-push-status";class o2 extends Xk{async listDirectory(e){const n=new URLSearchParams;n.append("path",e.path),e.recursive!==void 0&&n.append("recursive",e.recursive.toString()),e.respectGitignore!==void 0&&n.append("respectGitignore",e.respectGitignore.toString());const r=n.toString(),o=`${s2}${r}`;return this.cachedGet(o,t2,()=>this.apiCall(`/api/filesystem/list?${r}`))}async getCommands(e){const n=new URLSearchParams;e&&n.append("workingDirectory",e);const r=n.toString(),o=`${e2}${e||""}`;return this.cachedGet(o,Zk,()=>this.apiCall(`/api/system/commands?${r}`))}async getSystemStatus(){return this.apiCall("/api/system/status")}async checkVersion(){return this.apiCall("/api/system/version-check")}async getLoadedPlugins(){return this.apiCall("/api/plugins")}async getRecentLogs(e){const n=new URLSearchParams;return e!==void 0&&n.append("limit",e.toString()),this.apiCall(`/api/logs/recent?${n}`)}getLogStreamUrl(){return"/api/logs/stream"}async readFile(e){const n=new URLSearchParams;return n.append("path",e),this.apiCall(`/api/filesystem/read?${n}`)}async transcribeAudio(e,n){return this.apiCall("/api/gemini/transcribe",{method:"POST",body:JSON.stringify({audio:e,mimeType:n})})}async getGeminiHealth(){return this.apiCall("/api/gemini/health")}async checkAnthropicCredits(){return this.apiCall("/api/system/check-credits",{method:"POST"})}async getConfig(){return this.apiCall("/api/config")}async updateConfig(e){return this.apiCall("/api/config",{method:"PUT",body:JSON.stringify(e)})}async getLicenseStatus(){return this.apiCall("/api/license/status")}async revalidateLicense(){return this.apiCall("/api/license/revalidate",{method:"POST"})}async getWebPushStatus(){return this.cachedGet(r2,n2,()=>this.apiCall("/api/notifications/status"))}async registerWebPush(e){return this.apiCall("/api/notifications/register",{method:"POST",body:JSON.stringify(e)})}async unregisterWebPush(e){return this.apiCall("/api/notifications/unregister",{method:"POST",body:JSON.stringify({endpoint:e})})}async sendTestNotification(){return this.apiCall("/api/notifications/test",{method:"POST",body:JSON.stringify({})})}exportLogs(e=10){window.open(`/api/logs/export?minutes=${e}`,"_blank")}}const qs="session:dev-notes",Ln="session:pending-recommendations",a2="session:turns:",vs="session:cross-session-status",ws="session:cross-session-latest",Xc=15e3,i2=1e4;class c2 extends o2{async regenerateMission(e){const n=await this.unifiedRefreshInsights(e);return{success:n.success,sessionId:n.conversationId,mission:n.mission}}async getSessionTurns(e){return this.cachedGet(`${a2}${e}`,i2,()=>this.apiCall(`/api/insights/${e}/turns`))}async getTurnAnchorMessageId(e,n){return this.apiCall(`/api/insights/${e}/turns/${n}/message-id`)}async analyzeSessionForReview(e,n=!1){const r=n?"?force=true":"";return this.apiCall(`/api/insights/${e}/review${r}`,{method:"POST",timeout:12e4})}async acceptRecommendation(e){const n=await this.apiCall("/api/insights/recommendations/accept",{method:"POST",body:JSON.stringify(e)});return this.invalidateCachedGet(Ln),n}async dismissRecommendation(e){const n=await this.apiCall(`/api/insights/recommendations/${e}/dismiss`,{method:"POST"});return this.invalidateCachedGet(Ln),n}async completeRecommendation(e){const n=await this.apiCall(`/api/insights/recommendations/${e}/complete`,{method:"POST"});return this.invalidateCachedGet(Ln),n}async getPendingRecommendations(){return this.cachedGet(Ln,Xc,()=>this.apiCall("/api/insights/recommendations/pending"))}async getCrossSessionStatus(){return this.cachedGet(vs,1e4,()=>this.apiCall("/api/insights/cross-session/status"))}async getLatestCrossSessionSynthesis(){return this.cachedGet(ws,1e4,()=>this.apiCall("/api/insights/cross-session/latest"))}async runCrossSessionAnalysis(){const e=await this.apiCall("/api/insights/cross-session/run",{method:"POST",timeout:12e4});return this.invalidateCachedGet(vs),this.invalidateCachedGet(ws),e}async runCrossSessionDeepScan(){const e=await this.apiCall("/api/insights/cross-session/deep-scan",{method:"POST",timeout:12e4});return this.invalidateCachedGet(vs),this.invalidateCachedGet(ws),e}async applyCrossSessionProposal(e){const n=await this.apiCall(`/api/insights/cross-session/${e.synthesisId}/proposals/${e.proposalId}/apply`,{method:"POST",body:JSON.stringify({proposedText:e.proposedText,currentText:e.currentText,anchorHeading:e.anchorHeading,operation:e.operation,sourceSynthesisId:e.sourceSynthesisId})});return this.invalidateCachedGet(vs),this.invalidateCachedGet(ws),n}async dismissCrossSessionProposal(e){const n=await this.apiCall(`/api/insights/cross-session/${e.synthesisId}/proposals/${e.proposalId}/dismiss`,{method:"POST",body:JSON.stringify({sourceSynthesisId:e.sourceSynthesisId})});return this.invalidateCachedGet(vs),this.invalidateCachedGet(ws),n}async archiveCrossSessionProposals(e){const n=await this.apiCall(`/api/insights/cross-session/${e.synthesisId}/proposals/archive`,{method:"POST",body:JSON.stringify({proposalIds:e.proposalIds,sourceSynthesisIds:e.sourceSynthesisIds})});return this.invalidateCachedGet(vs),this.invalidateCachedGet(ws),n}async getDevNotes(){return this.cachedGet(qs,Xc,()=>this.apiCall("/api/notes"))}async createDevNote(e){const n=await this.apiCall("/api/notes",{method:"POST",body:JSON.stringify(e)});return this.invalidateCachedGet(qs),n}async updateDevNote(e,n){const r=await this.apiCall(`/api/notes/${e}`,{method:"PATCH",body:JSON.stringify(n)});return this.invalidateCachedGet(qs),r}async updateDevNoteStatus(e,n){return this.updateDevNote(e,{status:n})}async deleteDevNote(e){const n=await this.apiCall(`/api/notes/${e}`,{method:"DELETE"});return this.invalidateCachedGet(qs),n}async markDevNotesAsDone(e){const n=await this.apiCall("/api/notes/batch-done",{method:"POST",body:JSON.stringify({noteIds:e})});return this.invalidateCachedGet(qs),n}async getPendingQuestions(e){const n=new URLSearchParams;e&&n.append("sessionId",e);const r=n.toString();return this.apiCall(`/api/pending-questions${r?`?${r}`:""}`)}async getPendingQuestion(e){return this.apiCall(`/api/pending-questions/${e}`)}async answerPendingQuestion(e,n){return this.apiCall(`/api/pending-questions/${e}/answer`,{method:"POST",body:JSON.stringify({answers:n})})}async expirePendingQuestion(e){return this.apiCall(`/api/pending-questions/${e}/expire`,{method:"POST"})}async getSessionDiagnostic(e){return this.apiCall(`/api/debug/sessions/${e}/diagnostic`)}async getSessionEvents(e,n){const r=new URLSearchParams;n?.traceId&&r.append("traceId",n.traceId),n?.limit&&r.append("limit",n.limit.toString()),n?.since&&r.append("since",n.since),n?.types&&r.append("types",n.types.join(","));const o=r.toString();return this.apiCall(`/api/debug/sessions/${e}/events${o?`?${o}`:""}`)}async getSessionAuditTrail(e,n){const r=new URLSearchParams;n?.limit&&r.append("limit",n.limit.toString()),n?.eventTypes&&r.append("eventTypes",n.eventTypes.join(",")),n?.triggers&&r.append("triggers",n.triggers.join(",")),n?.since&&r.append("since",n.since);const o=r.toString();return this.apiCall(`/api/debug/sessions/${e}/audit-trail${o?`?${o}`:""}`)}async getSessionCosts(e){return this.apiCall(`/api/debug/sessions/${e}/costs`)}async getActiveSessionsOverview(){return this.apiCall("/api/debug/active-sessions")}async exportSession(e){const n=await this.fetchDirect(`/api/sessions/export/${e}`);if(!n.ok){const d=await n.json().catch(()=>({error:"Export failed"})),p=d&&typeof d=="object"&&"error"in d&&typeof d.error=="string"?d.error:"Export failed";throw new Error(p)}const r=await n.blob(),i=n.headers.get("Content-Disposition")?.match(/filename="(.+?)"/)?.[1]||`session-${e}.lattice.json`,l=URL.createObjectURL(r),c=document.createElement("a");c.href=l,c.download=i,document.body.appendChild(c),c.click(),document.body.removeChild(c),URL.revokeObjectURL(l)}async importSession(e){return this.apiCall("/api/sessions/import",{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json"}})}}class l2 extends c2{}const G=new l2;var Mr="Popover",[gp]=pr(Mr,[Tr]),bn=Tr(),[d2,qt]=gp(Mr),xp=t=>{const{__scopePopover:e,children:n,open:r,defaultOpen:o,onOpenChange:a,modal:i=!1}=t,l=bn(e),c=u.useRef(null),[d,p]=u.useState(!1),[m,h]=ba({prop:r,defaultProp:o??!1,onChange:a,caller:Mr});return s.jsx(Hu,{...l,children:s.jsx(d2,{scope:e,contentId:Ys(),triggerRef:c,open:m,onOpenChange:h,onOpenToggle:u.useCallback(()=>h(g=>!g),[h]),hasCustomAnchor:d,onCustomAnchorAdd:u.useCallback(()=>p(!0),[]),onCustomAnchorRemove:u.useCallback(()=>p(!1),[]),modal:i,children:n})})};xp.displayName=Mr;var bp="PopoverAnchor",u2=u.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,o=qt(bp,n),a=bn(n),{onCustomAnchorAdd:i,onCustomAnchorRemove:l}=o;return u.useEffect(()=>(i(),()=>l()),[i,l]),s.jsx(ei,{...a,...r,ref:e})});u2.displayName=bp;var yp="PopoverTrigger",vp=u.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,o=qt(yp,n),a=bn(n),i=dt(e,o.triggerRef),l=s.jsx(st.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Np(o.open),...r,ref:i,onClick:He(t.onClick,o.onOpenToggle)});return o.hasCustomAnchor?l:s.jsx(ei,{asChild:!0,...a,children:l})});vp.displayName=yp;var ni="PopoverPortal",[p2,m2]=gp(ni,{forceMount:void 0}),wp=t=>{const{__scopePopover:e,forceMount:n,children:r,container:o}=t,a=qt(ni,e);return s.jsx(p2,{scope:e,forceMount:n,children:s.jsx(ls,{present:n||a.open,children:s.jsx(Sr,{asChild:!0,container:o,children:r})})})};wp.displayName=ni;var Ps="PopoverContent",_p=u.forwardRef((t,e)=>{const n=m2(Ps,t.__scopePopover),{forceMount:r=n.forceMount,...o}=t,a=qt(Ps,t.__scopePopover);return s.jsx(ls,{present:r||a.open,children:a.modal?s.jsx(f2,{...o,ref:e}):s.jsx(g2,{...o,ref:e})})});_p.displayName=Ps;var h2=Vl("PopoverContent.RemoveScroll"),f2=u.forwardRef((t,e)=>{const n=qt(Ps,t.__scopePopover),r=u.useRef(null),o=dt(e,r),a=u.useRef(!1);return u.useEffect(()=>{const i=r.current;if(i)return fu(i)},[]),s.jsx(Ka,{as:h2,allowPinchZoom:!0,children:s.jsx(kp,{...t,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:He(t.onCloseAutoFocus,i=>{i.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:He(t.onPointerDownOutside,i=>{const l=i.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;a.current=d},{checkForDefaultPrevented:!1}),onFocusOutside:He(t.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),g2=u.forwardRef((t,e)=>{const n=qt(Ps,t.__scopePopover),r=u.useRef(!1),o=u.useRef(!1);return s.jsx(kp,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{t.onCloseAutoFocus?.(a),a.defaultPrevented||(r.current||n.triggerRef.current?.focus(),a.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:a=>{t.onInteractOutside?.(a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=a.target;n.triggerRef.current?.contains(i)&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),kp=u.forwardRef((t,e)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,disableOutsidePointerEvents:i,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onInteractOutside:p,...m}=t,h=qt(Ps,n),g=bn(n);return au(),s.jsx(Wa,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:s.jsx(Nr,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:p,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onDismiss:()=>h.onOpenChange(!1),children:s.jsx(qu,{"data-state":Np(h.open),role:"dialog",id:h.contentId,...g,...m,ref:e,style:{...m.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),jp="PopoverClose",x2=u.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,o=qt(jp,n);return s.jsx(st.button,{type:"button",...r,ref:e,onClick:He(t.onClick,()=>o.onOpenChange(!1))})});x2.displayName=jp;var b2="PopoverArrow",y2=u.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,o=bn(n);return s.jsx(Wu,{...o,...r,ref:e})});y2.displayName=b2;function Np(t){return t?"open":"closed"}var v2=xp,w2=vp,_2=wp,Sp=_p;function Zc({...t}){return s.jsx(v2,{"data-slot":"popover",...t})}function el({...t}){return s.jsx(w2,{"data-slot":"popover-trigger",...t})}const ua=u.forwardRef(({className:t,align:e="center",sideOffset:n=4,...r},o)=>s.jsx(_2,{children:s.jsx(Sp,{ref:o,"data-slot":"popover-content",align:e,sideOffset:n,className:$e("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]: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 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),...r})}));ua.displayName=Sp.displayName;const Cp=u.createContext(void 0),k2={status:"disconnected",error:null,reconnectAttempt:0,lastConnectedAt:null,lastDisconnectedAt:null};function j2({children:t}){const e=u.useRef(new Map),n=u.useRef(!0);u.useEffect(()=>(n.current=!0,()=>{n.current=!1}),[]);const r=u.useCallback((i,l)=>{const c=i.type==="session"?`session:${i.sessionId}`:"activity";return e.current.has(c)||e.current.set(c,new Set),e.current.get(c).add(l),()=>{const d=e.current.get(c);d&&(d.delete(l),d.size===0&&e.current.delete(c))}},[]),o=u.useCallback(()=>{},[]),a=u.useMemo(()=>({connectionState:k2,subscribe:r,reconnect:o,isConnected:!1,isReconnecting:!1,errorMessage:null}),[r,o]);return s.jsx(Cp.Provider,{value:a,children:t})}function ri(){const t=u.useContext(Cp);if(t===void 0)throw new Error("useActivityStream must be used within an ActivityStreamProvider");return t}function Pt(t,e){const{subscribe:n}=ri(),r=u.useRef(e);u.useEffect(()=>{r.current=e},[e]),u.useEffect(()=>t?n(t,a=>{r.current(a)}):void 0,[t,n])}const fo={status:"completed",provider:null,streamingId:null,startedAt:null,runVersion:null,segmentId:null,providerSessionId:null,transitionReason:null},vt={all:["session-status"],one:t=>["session-status",t]};function N2(t){const e=mn(),{connectionState:n}=ri(),r=u.useRef(n.status),o=(t||"").trim(),a=o.startsWith("conv-"),i=Nt({queryKey:vt.one(o),queryFn:async()=>{if(!a)return fo;const p=(await G.getSessionsStatus([o])).sessions[o]??fo;return console.debug(`[status:query] ${o.slice(0,12)} fetched=${p.status} sid=${p.streamingId?.slice(0,8)??"-"}`),p},enabled:a,refetchInterval:a?5e3:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0,staleTime:5e3});Pt({type:"activity"},d=>{if(!a)return;const p=d;p.sessionId===o&&(p.type==="session-started"||p.type==="session-ended"||p.type==="session-idle"||p.type==="current-work")&&e.invalidateQueries({queryKey:vt.one(o)})}),u.useEffect(()=>{if(!a)return;const d=r.current,p=n.status;r.current=p,p==="connected"&&d&&d!=="connected"&&(console.debug(`[DETAIL-TRACE] status-reconnect invalidating session-status for ${o?.slice(0,12)} (${d}→${p})`),e.invalidateQueries({queryKey:vt.one(o)}))},[n.status,a,o,e]);const l=d=>{a&&e.setQueryData(vt.one(o),{status:"ongoing",provider:d?.provider??"claude",streamingId:d?.streamingId??null,startedAt:new Date().toISOString(),runVersion:null,segmentId:null,providerSessionId:null,transitionReason:null})},c=()=>{if(!a)return;const d=e.getQueryData(vt.one(o));e.setQueryData(vt.one(o),{...fo,lastTurnUsage:d?.lastTurnUsage})};return{status:i.data?.status??"completed",provider:i.data?.provider??null,streamingId:i.data?.streamingId??null,startedAt:i.data?.startedAt??null,runVersion:i.data?.runVersion??null,segmentId:i.data?.segmentId??null,providerSessionId:i.data?.providerSessionId??null,transitionReason:i.data?.transitionReason??null,lastTurnUsage:i.data?.lastTurnUsage??null,isOngoing:i.data?.status==="ongoing",isIdle:i.data?.status==="idle",isCompleted:i.data?.status!=="ongoing"&&i.data?.status!=="idle",isFetching:i.isFetching,isLoading:i.isLoading,dataUpdatedAt:i.dataUpdatedAt,setOptimisticOngoing:l,setOptimisticCompleted:c}}const Ep=u.createContext(void 0),ht={all:["conversations"],list:(t,e)=>[...ht.all,"list",t,e],details:t=>[...ht.all,"details",t]};function On(t){return t[0]===ht.all[0]&&t[1]==="list"}const S2=3e4,C2=30*1e3,E2=3,T2=12,tl=6e4,sl=50;function I2(t,e){const n=e.now??Date.now(),r=e.limit??T2,o=[];for(const a of t){const{conversationId:i,identityImage:l}=a;if(!(l||!i.startsWith("conv-")||e.inFlight.has(i)||(e.retryAfterBySessionId.get(i)||0)>n)&&(o.push(i),o.length>=r))break}return o}function A2(t,e,n){let r=!1;const o=t.map(a=>a.conversationId!==e||a.identityImage?a:(r=!0,{...a,identityImage:n}));return r?o:t}function Tp(t,e){if(e.size===0)return t;let n=!1;const r=t.map(o=>{if(o.identityImage)return o;const a=e.get(o.conversationId);return a?(n=!0,{...o,identityImage:a}):o});return n?r:t}function R2(t){const{existing:e,incoming:n,pinnedOnly:r=!1,identityImageBySessionId:o=new Map}=t,a=r?n.filter(c=>c.pinned):n;if(a.length===0&&o.size===0)return e;const i=new Map(e.map(c=>[c.conversationId,c]));for(const c of a)i.set(c.conversationId,c);const l=Array.from(i.values());return l.sort((c,d)=>new Date(d.updatedAt).getTime()-new Date(c.updatedAt).getTime()),Tp(l,o)}function P2({children:t}){const e=mn(),n="main",[r,o]=u.useState({archived:!1}),[a,i]=u.useState(!1),l=Te.useRef(Date.now()),[c,d]=u.useState({}),[p,m]=u.useState({}),h=u.useRef(!1),g=u.useRef(!1),[f,x]=u.useState(new Set),[b,y]=u.useState(new Map),[v,w]=u.useState(new Map),[N,S]=u.useState(new Set),T=u.useRef(new Map),C=u.useRef(new Set),j=u.useRef(new Map),E=u.useCallback((L,Q)=>{L.startsWith("conv-")&&m(U=>{if(U[L]?.status==="ongoing")return U;const ae=U[L];return{...U,[L]:{status:"ongoing",provider:Q??ae?.provider??null,streamingId:ae?.streamingId??null,startedAt:new Date().toISOString(),runVersion:ae?.runVersion??null,segmentId:ae?.segmentId??null,providerSessionId:ae?.providerSessionId??null,transitionReason:ae?.transitionReason??null}}})},[]),{connectionState:R}=ri(),O=u.useRef(R.status),$=u.useCallback(()=>{e.invalidateQueries({predicate:L=>On(L.queryKey)})},[e]),re=u.useCallback(async()=>{await e.refetchQueries({predicate:L=>On(L.queryKey)})},[e]);u.useEffect(()=>{const L=O.current,Q=R.status;O.current=Q,Q==="connected"&&L&&L!=="connected"&&(Rt("ConversationsContext","reconnect-refetch",{prevStatus:L}),$())},[R.status,$]);const ne=u.useRef({lists:!1,sessionIds:new Set}),V=u.useRef(null),X=u.useCallback(L=>{const{sessionId:Q,lists:U}=L||{};Q&&ne.current.sessionIds.add(Q),U&&(ne.current.lists=!0),V.current&&clearTimeout(V.current),V.current=setTimeout(()=>{const{lists:ae,sessionIds:be}=ne.current;ae&&$(),be.forEach(me=>{e.invalidateQueries({queryKey:["insights",me]})}),ne.current={lists:!1,sessionIds:new Set},V.current=null},500)},[e,$]),q=u.useRef({}),K=u.useRef(()=>{}),ge=u.useCallback(L=>{const Q=L;switch(Q.type){case"session-started":{const{sessionId:U,streamingId:ae}=Q;if(!U||!U.startsWith("conv-"))break;console.debug(`[status:sse] session-started ${U.slice(0,12)} sid=${ae?.slice(0,8)??"-"}`),K.current(),$();break}case"session-idle":{const{sessionId:U}=Q;if(!U||!U.startsWith("conv-"))break;console.debug(`[status:sse] session-idle ${U.slice(0,12)}`),K.current(),$();break}case"insights-status":{const U=Q.timestamps||{};let ae=!1;for(const[be,me]of Object.entries(U)){const ze=q.current[be];ze&&me>ze&&(ae=!0)}q.current=U,ae&&$();break}case"active-sessions":{console.debug("[status:sse] active-sessions received, triggering refetch"),K.current();break}case"activity":{const{sessionId:U,recentActions:ae}=Q;U&&ae&&Array.isArray(ae)&&d(be=>{if(ae.length>0)return{...be,[U]:ae};{const me={...be};return delete me[U],me}});break}case"insights":{const{sessionId:U,conversationId:ae,identityImage:be}=Q;if(!U&&!ae)break;const me=new Set;if(U&&me.add(U),ae&&me.add(ae),me.size===0)break;x(Ne=>{const Me=new Set(Ne);let nt=!1;return me.forEach(Ye=>{Me.delete(Ye)&&(nt=!0)}),nt?Me:Ne});const ze=new Date().toISOString();me.forEach(Ne=>{q.current[Ne]=ze}),me.forEach(Ne=>{e.setQueryData(["insights",Ne],Me=>Me&&{...Me,patchedAt:ze})}),be&&(me.forEach(Ne=>{T.current.set(Ne,be)}),e.setQueriesData({predicate:Ne=>On(Ne.queryKey)},Ne=>Ne?.conversations?{...Ne,conversations:Ne.conversations.map(Me=>me.has(Me.conversationId)?{...Me,identityImage:be}:Me)}:Ne)),me.forEach(Ne=>{X({sessionId:Ne})}),X({lists:!0});break}case"session-ended":{const{sessionId:U,streamingId:ae}=Q;if(!U||!U.startsWith("conv-"))break;console.debug(`[status:sse] session-ended ${U.slice(0,12)} sid=${ae?.slice(0,8)??"-"}`),Rt("ConversationsContext","session-ended-received",{sessionId:U.slice(0,8),streamingId:ae?.slice(0,8)}),x(be=>{const me=new Set(be);return me.add(U),setTimeout(()=>{x(ze=>{if(!ze.has(U))return ze;const Ne=new Set(ze);return Ne.delete(U),Ne})},15e3),me}),S(be=>{const me=new Set(be);return me.add(U),me}),setTimeout(()=>{S(be=>{if(!be.has(U))return be;const me=new Set(be);return me.delete(U),me})},1e4),d(be=>{const me={...be};return delete me[U],me}),K.current(),$();break}case"current-work":{const{sessionId:U}=Q;if(!U||!U.startsWith("conv-"))break;K.current(),$();break}case"current-work-clear":{$();break}case"turn-captured":{$();break}}},[e,X,$]);Pt({type:"activity"},ge),u.useEffect(()=>()=>{V.current&&clearTimeout(V.current)},[]);const D=void 0,W=Te.useMemo(()=>ht.list(n,r),[n,r]),{data:Z,isLoading:F,error:se}=Nt({queryKey:W,queryFn:async()=>{const L=await G.listUnifiedConversations({includeIdentityImage:!1,archived:r.archived,limit:sl}),Q=L.conversations.filter(ae=>!(r.pinned===!0&&!ae.pinned));return Q.sort((ae,be)=>new Date(be.updatedAt).getTime()-new Date(ae.updatedAt).getTime()),{conversations:Tp(Q,T.current),hasMore:!!L.hasMore,nextCursor:L.nextCursor??null,total:L.total}},placeholderData:L=>L}),ee=Te.useMemo(()=>Z?.conversations??[],[Z?.conversations]),te=Z?.hasMore??!1,xe=Te.useMemo(()=>{const L=new Set(ee.map(ae=>ae.conversationId)),Q=Array.from(b.values()).filter(ae=>!L.has(ae.conversationId));return[...Array.from(v.values()),...Q,...ee]},[ee,b,v]),_e=Te.useMemo(()=>xe.map(L=>L.conversationId).filter(L=>L.startsWith("conv-")).sort(),[xe]),A=u.useCallback(async()=>{if(h.current){g.current=!0;return}h.current=!0;try{const L=await G.getSessionsStatus(_e.length>0?_e:void 0);m(L.sessions);for(const[Q,U]of Object.entries(L.sessions))e.setQueryData(vt.one(Q),U)}catch{}h.current=!1,g.current&&(g.current=!1,A())},[_e,e]),P=u.useCallback(()=>{A()},[A]);K.current=P,u.useEffect(()=>{let L=null;const Q=()=>{L||(A(),L=setInterval(()=>{A()},5e3))},U=()=>{L&&(clearInterval(L),L=null)},ae=()=>{document.hidden?U():Q()};return document.hidden||Q(),document.addEventListener("visibilitychange",ae),()=>{U(),document.removeEventListener("visibilitychange",ae)}},[A]);const le=u.useMemo(()=>{const L=new Set;for(const[Q,U]of Object.entries(p))U.status==="ongoing"&&L.add(Q);return L},[p]),J=p;u.useEffect(()=>{const L=I2(xe,{inFlight:C.current,retryAfterBySessionId:j.current});if(L.length===0)return;const Q=[...L],U=Math.min(E2,Q.length);let ae=!1;const be=async()=>{for(;!ae&&Q.length>0;){const me=Q.shift();if(!me)return;C.current.add(me);try{const Ne=(await G.getUnifiedConversationIdentityImage(me)).identityImage;if(!Ne){j.current.set(me,Date.now()+tl);continue}T.current.set(me,Ne),j.current.delete(me),e.setQueriesData({predicate:Me=>On(Me.queryKey)},Me=>{const nt=Me;if(!nt?.conversations)return Me;const Ye=A2(nt.conversations,me,Ne);return Ye===nt.conversations?Me:{...nt,conversations:Ye}})}catch{j.current.set(me,Date.now()+tl)}finally{C.current.delete(me)}}};return Promise.all(Array.from({length:U},()=>be())),()=>{ae=!0}},[xe,e]),u.useEffect(()=>{if(b.size===0)return;const L=new Set(ee.map(U=>U.conversationId)),Q=Array.from(b.keys()).filter(U=>L.has(U));Q.length>0&&y(U=>{const ae=new Map(U);return Q.forEach(be=>ae.delete(be)),ae})},[ee,b]);const H=Te.useMemo(()=>xe.map(L=>{const Q=J[L.conversationId];if(!Q)return L;const U=Q.status==="ongoing"?{streamingId:Q.streamingId||L.streamingId||void 0,currentStatus:"Claude Active",connectionState:"connected"}:void 0;return{...L,status:Q.status,latestProvider:Q.provider||L.latestProvider,streamingId:Q.streamingId??L.streamingId??null,liveStatus:U}}),[xe,J]),ye=Te.useMemo(()=>{const L={};return H.forEach(Q=>{const U=Q.workingDirectory;if(U){const ae=U.split("/"),be=ae[ae.length-1]??U,me=L[U];(!me||new Date(Q.updatedAt)>new Date(me.lastDate))&&(L[U]={lastDate:Q.updatedAt,shortname:be})}}),L},[H,D]),I=u.useRef(new Set);u.useEffect(()=>{const Q=Array.from(le).filter(U=>!I.current.has(U));Q.length!==0&&Q.forEach(U=>{I.current.add(U),e.prefetchQuery({queryKey:ht.details(U),queryFn:()=>G.getConversationDetails(U,{limit:50,timeout:1e4}),staleTime:3e4})})},[le,e]),u.useEffect(()=>{const L={},Q={};let U=[];const ae=async()=>{if(document.visibilityState!=="visible")return;const ze=xe.map(Ne=>Ne.conversationId);if(ze.length!==0)try{const{mtimes:Ne,insightMtimes:Me}=await G.unifiedActivityCheck(ze,L,U);let nt=!1;for(const[Ye,Et]of Object.entries(Ne))L[Ye]!==void 0&&L[Ye]!==Et&&(nt=!0),L[Ye]=Et;if(Me)for(const[Ye,Et]of Object.entries(Me))Q[Ye]!==void 0&&Q[Ye]!==Et&&(nt=!0),Q[Ye]=Et;nt&&$()}catch{}},be=setInterval(()=>{ae()},S2),me=()=>{document.visibilityState==="visible"?Date.now()-l.current>C2&&$():l.current=Date.now()};return document.addEventListener("visibilitychange",me),()=>{clearInterval(be),document.removeEventListener("visibilitychange",me)}},[xe,$]);const pe=u.useCallback(async L=>{if(!a&&!(!Z?.hasMore||!Z.nextCursor)){i(!0);try{const Q=await G.listUnifiedConversations({includeIdentityImage:!1,archived:r.archived,limit:sl,cursor:Z.nextCursor});e.setQueryData(W,U=>{const ae=U?.conversations??[];return{conversations:R2({existing:ae,incoming:Q.conversations,pinnedOnly:r.pinned===!0,identityImageBySessionId:T.current}),hasMore:!!Q.hasMore,nextCursor:Q.nextCursor??null,total:Q.total}})}finally{i(!1)}}},[r.archived,r.pinned,W,a,e,Z?.hasMore,Z?.nextCursor]),Ce=u.useCallback(()=>H.length===0?null:[...H].sort((Q,U)=>new Date(U.updatedAt).getTime()-new Date(Q.updatedAt).getTime())[0]?.workingDirectory||null,[H]),ke=u.useCallback(async()=>{await re()},[re]),Re=u.useCallback(L=>{const Q=new Date().toISOString(),U={conversationId:L.conversationId,streamingId:L.streamingId,workingDirectory:L.workingDirectory,workspace:L.workspace,latestProvider:L.provider||"claude",providersUsed:[L.provider||"claude"],activeProvider:L.provider||"claude",segmentCount:1,customName:"",pinned:!1,archived:!1,pausedReason:null,importedAt:null,permissionMode:L.permissionMode,identityImage:null,initialPrompt:L.initialPrompt,createdAt:Q,updatedAt:Q,status:"ongoing",liveStatus:{streamingId:L.streamingId,currentStatus:"Thinking",connectionState:"connected"}};y(be=>{const me=new Map(be);return me.set(L.conversationId,U),me});const ae={status:"ongoing",provider:L.provider||"claude",streamingId:L.streamingId,startedAt:new Date().toISOString(),runVersion:null,segmentId:null,providerSessionId:null,transitionReason:null};m(be=>({...be,[L.conversationId]:ae})),e.setQueryData(vt.one(L.conversationId),{status:"ongoing",provider:L.provider||"claude",streamingId:L.streamingId,startedAt:Q,runVersion:null,segmentId:null,providerSessionId:null,transitionReason:null})},[e]),B=u.useCallback(L=>{const Q=new Date().toISOString(),U={conversationId:L.tempId,streamingId:null,workingDirectory:L.workingDirectory,workspace:L.workspace,latestProvider:L.provider,providersUsed:[L.provider],activeProvider:L.provider,segmentCount:0,customName:"",pinned:!1,archived:!1,pausedReason:null,importedAt:null,permissionMode:L.permissionMode,identityImage:null,initialPrompt:L.initialPrompt,createdAt:Q,updatedAt:Q,status:"pending",liveStatus:{streamingId:void 0,currentStatus:"Launching",connectionState:"connecting"}};w(ae=>{const be=new Map(ae);return be.set(L.tempId,U),be})},[]),he=u.useCallback(L=>{w(Q=>{const U=new Map(Q);return U.delete(L),U})},[]);return s.jsx(Ep.Provider,{value:{conversations:H,loading:F,loadingMore:a,hasMore:te,error:se?"Failed to load conversations":null,recentDirectories:ye,activeFilters:r,setActiveFilters:o,loadMoreConversations:pe,getMostRecentWorkingDirectory:Ce,invalidateConversations:ke,addOptimisticSession:Re,addPendingLaunch:B,removePendingLaunch:he,recentActions:c,pendingInsightsUpdates:f,setSessionOptimisticOngoing:E,recentlyCompletedSessions:N},children:t})}function $s(){const t=u.useContext(Ep);if(t===void 0)throw new Error("useConversations must be used within a ConversationsProvider");return t}const Ip=u.createContext(void 0),M2={mode:"dark",colorScheme:"dark",toggle:()=>{}};function L2({children:t}){const[e,n]=u.useState(null),[r,o]=u.useState(null),[a,i]=u.useState(!1),[l,c]=u.useState(!0),[d,p]=u.useState(null);u.useEffect(()=>{(async()=>{try{c(!0);const f=await G.getConfig();n(f.interface??null),o(f.server??null),i(f.interface?.devMode===!0)}catch(f){p(f instanceof Error?f:new Error("Failed to load preferences"))}finally{c(!1)}})()},[]);const m=u.useCallback(async g=>{try{const f=await G.updateConfig({interface:g});n(f.interface??null)}catch(f){throw p(f instanceof Error?f:new Error("Failed to update preferences")),f}},[]),h=u.useCallback(g=>{o(g)},[]);return s.jsx(Ip.Provider,{value:{preferences:e,serverConfig:r,theme:M2,updatePreferences:m,setServerConfig:h,isLoading:l,error:d,devMode:a},children:t})}function zs(){const t=u.useContext(Ip);if(!t)throw new Error("usePreferencesContext must be used within a PreferencesProvider");return t}const Ap=u.createContext({isPro:!1,isLoading:!0,devOverride:null});function O2({children:t}){const[e]=xa(),n=e.get("tier"),{data:r,isLoading:o}=Nt({queryKey:["licenseStatus"],queryFn:()=>G.getLicenseStatus(),staleTime:6e4,refetchOnWindowFocus:!1,retry:!1,enabled:n===null}),a=u.useMemo(()=>n==="free"?{isPro:!1,isLoading:!1,devOverride:"free"}:n==="pro"?{isPro:!0,isLoading:!1,devOverride:"pro"}:{isPro:r?.isPro??!1,isLoading:o,devOverride:null},[n,r?.isPro,o]);return s.jsx(Ap.Provider,{value:a,children:t})}function yn(){return u.useContext(Ap)}function D2(t){const e="=".repeat((4-t.length%4)%4),n=(t+e).replace(/-/g,"+").replace(/_/g,"/"),r=window.atob(n),o=new Uint8Array(r.length);for(let a=0;a<r.length;++a)o[a]=r.charCodeAt(a);return o}function $2(){const t=navigator.userAgent||"";return/iPad|iPhone|iPod/i.test(t)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1}function z2(){const t=typeof window.matchMedia=="function"&&window.matchMedia("(display-mode: standalone)").matches,e=!!navigator.standalone;return t||e}function F2(){const[t,e]=u.useState({supported:!1,permission:"unsupported",subscribed:!1,loading:!0,publicKey:null,supportIssues:[]}),n=u.useCallback(async()=>{const i=[],l="serviceWorker"in navigator,c="PushManager"in window,d="Notification"in window,p=window.isSecureContext,m=$2(),h=z2();if(p||i.push("insecure-context"),m&&!h&&i.push("ios-home-screen-required"),(!l||!c||!d)&&i.push("missing-browser-apis"),!(i.length===0)){e({supported:!1,permission:"unsupported",subscribed:!1,loading:!1,publicKey:null,supportIssues:i});return}try{const f=await G.getWebPushStatus(),b=await(await navigator.serviceWorker.ready).pushManager.getSubscription();e({supported:!0,permission:Notification.permission,subscribed:!!b,loading:!1,publicKey:f.publicKey||null,supportIssues:[]})}catch{e(f=>({...f,supported:!0,loading:!1,supportIssues:[]}))}},[]);u.useEffect(()=>{n()},[n]);const r=u.useCallback(async()=>{if(!t.supported||!t.publicKey)return!1;e(i=>({...i,loading:!0}));try{const i=await Notification.requestPermission();if(i!=="granted")return e(d=>({...d,permission:i,loading:!1})),!1;const c=await(await navigator.serviceWorker.ready).pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:D2(t.publicKey)});return await G.registerWebPush(c),e(d=>({...d,permission:"granted",subscribed:!0,loading:!1})),!0}catch(i){return console.error("Push subscription failed:",i),e(l=>({...l,loading:!1})),!1}},[t.supported,t.publicKey]),o=u.useCallback(async()=>{e(i=>({...i,loading:!0}));try{const l=await(await navigator.serviceWorker.ready).pushManager.getSubscription();return l&&(await G.unregisterWebPush(l.endpoint),await l.unsubscribe()),e(c=>({...c,subscribed:!1,loading:!1})),!0}catch(i){return console.error("Push unsubscribe failed:",i),e(l=>({...l,loading:!1})),!1}},[]),a=u.useCallback(async()=>{try{return await G.sendTestNotification()}catch(i){return console.error("Test notification failed:",i),null}},[]);return{...t,subscribe:r,unsubscribe:o,sendTest:a,refresh:n}}function Fs(t){return JSON.parse(t)}function Rp(t){try{return Fs(t)}catch{return null}}async function zt(t,e){const n=new Headers(e?.headers);n.has("Content-Type")||n.set("Content-Type","application/json");const r=await fetch(t,{...e,headers:n}),o=await r.text(),a=o?Rp(o):null;if(!r.ok){const i=a&&typeof a=="object"&&a!==null&&"error"in a&&typeof a.error=="string"?a.error:`HTTP ${r.status}`;throw new Error(i)}return a}function V2(t){return t.replace(/\x1B\[[0-9;]*[A-Za-z]/g,"")}function B2(t,e){return t.length<=e?t:t.slice(t.length-e)}function U2(t){const e=t.match(/https?:\/\/\S+/);return e?e[0]:null}function G2(t){const e=t.match(/\b[A-Z0-9]{4}-[A-Z0-9]{5}\b/);return e?e[0]:null}function H2(){const[t,e]=u.useState(null),[n,r]=u.useState(null),[o,a]=u.useState(null),[i,l]=u.useState(null),[c,d]=u.useState(null),[p,m]=u.useState(""),[h,g]=u.useState(!1),[f,x]=u.useState(!1),[b,y]=u.useState(null),[v,w]=u.useState(""),[N,S]=u.useState(!1),T=u.useRef(null),C=u.useCallback(async()=>{a(null);try{const[W,Z]=await Promise.all([zt("/api/provider-auth/claude/status"),zt("/api/provider-auth/codex/status")]);e(W),r(Z)}catch(W){a(W instanceof Error?W.message:"Failed to load auth status")}},[]);u.useEffect(()=>(C(),()=>{T.current?.close()}),[C]);const j=u.useMemo(()=>!t||!t.available||!t.status||typeof t.status!="object"?!1:t.status.loggedIn===!0,[t]),E=u.useMemo(()=>{if(!t||!t.available||!t.status||typeof t.status!="object")return null;const W=t.status;return typeof W.authMethod=="string"?W.authMethod:null},[t]),R=u.useMemo(()=>U2(v),[v]),O=u.useMemo(()=>G2(v),[v]),$=u.useCallback(W=>{const Z=new EventSource(`/api/provider-auth/stream/${encodeURIComponent(W)}`);T.current?.close(),T.current=Z,y(W),S(!0),a(null),Z.onmessage=F=>{const se=typeof F.data=="string"?F.data:String(F.data??""),ee=Rp(se);if(!ee||typeof ee!="object"||!("type"in ee))return;const te=ee;te.type==="log"&&w(xe=>B2(xe+V2(te.text),3e4)),te.type==="exit"&&(S(!1),Z.close(),C())},Z.onerror=()=>{S(!1),a("Auth stream disconnected"),Z.close()}},[C]),re=u.useCallback(async()=>{a(null),x(!1),m("");try{const W=await zt("/api/provider-auth/claude/login",{method:"POST",body:JSON.stringify({})});l(W.sessionId),d(W.authorizeUrl)}catch(W){a(W instanceof Error?W.message:"Failed to start Claude login")}},[]),ne=u.useCallback(async()=>{if(!(!i||!p.trim())){g(!0),a(null);try{await zt("/api/provider-auth/claude/exchange",{method:"POST",body:JSON.stringify({sessionId:i,code:p.trim()})}),x(!0),l(null),d(null),m(""),C()}catch(W){a(W instanceof Error?W.message:"Failed to exchange code")}finally{g(!1)}}},[i,p,C]),V=u.useCallback(()=>{l(null),d(null),m(""),x(!1)},[]),X=u.useCallback(async()=>{w("");const W=await zt("/api/provider-auth/codex/login",{method:"POST",body:JSON.stringify({})});$(W.sessionId)},[$]),q=u.useCallback(async W=>{if(W)try{await zt("/api/provider-auth/cancel/"+encodeURIComponent(W),{method:"POST",body:JSON.stringify({})})}catch{}},[]),K=u.useCallback(async()=>{a(null);try{await zt("/api/provider-auth/claude/logout",{method:"POST",body:JSON.stringify({})}),C()}catch(W){a(W instanceof Error?W.message:"Failed to logout")}},[C]),ge=u.useCallback(async()=>{a(null);try{await zt("/api/provider-auth/codex/logout",{method:"POST",body:JSON.stringify({})}),C()}catch(W){a(W instanceof Error?W.message:"Failed to logout")}},[C]),D=!!c;return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] text-muted-foreground font-display uppercase tracking-widest mb-2",children:"[PROVIDER_AUTH]"}),s.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:"These logins happen inside this workspace. Use this when you want to run Claude Code / Codex with your own plan, without API billing."})]}),s.jsxs("div",{className:"border border-border/50 rounded-sm p-3 bg-background/30 space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-xs font-display font-bold uppercase tracking-wider text-cyan-400",children:"CLAUDE"}),s.jsxs("p",{className:"text-[11px] font-mono text-muted-foreground",children:[t?.available===!1&&`Unavailable: ${t.error}`,t?.available===!0&&(j?`Logged in (${E||"unknown"})`:"Not logged in"),!t&&"Checking status..."]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[j?s.jsxs("button",{onClick:()=>{K()},disabled:D,className:"flex items-center gap-2 px-3 py-2 rounded-sm bg-background border border-border/50 text-muted-foreground text-xs font-display uppercase tracking-wider hover:text-foreground hover:border-cyan-500/30 transition-all cursor-pointer disabled:opacity-50",children:[s.jsx(_i,{size:14}),s.jsx("span",{children:"Logout"})]}):s.jsxs("button",{onClick:()=>{re()},disabled:D,className:"flex items-center gap-2 px-3 py-2 rounded-sm bg-background border border-cyan-500/30 text-cyan-400 text-xs font-display font-bold uppercase tracking-wider hover:border-cyan-400 hover:bg-cyan-500/5 hover:shadow-[1px_1px_0_rgba(0,255,255,0.4)] hover:translate-x-[-0.5px] hover:translate-y-[-0.5px] transition-all cursor-pointer disabled:opacity-50",children:[h?s.jsx(Ae,{size:14,className:"animate-spin"}):s.jsx(wi,{size:14}),s.jsx("span",{children:D?"Connecting...":"Connect"})]}),D&&s.jsxs("button",{onClick:V,className:"flex items-center gap-2 px-3 py-2 rounded-sm bg-background border border-red-500/30 text-red-400 text-xs font-display uppercase tracking-wider hover:border-red-400 hover:bg-red-500/5 transition-all cursor-pointer",children:[s.jsx(bi,{size:14}),s.jsx("span",{children:"Cancel"})]})]})]}),f&&s.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-mono text-emerald-400",children:[s.jsx(Bn,{size:14}),s.jsx("span",{children:"Login successful! Credentials saved."})]}),c&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-[11px] font-mono text-muted-foreground",children:"1. Click the link below to authorize Claude Code:"}),s.jsxs("a",{href:c,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-2 text-[11px] font-mono text-cyan-400 hover:underline",children:[s.jsx(os,{size:12}),s.jsx("span",{children:"Open sign-in link"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-[11px] font-mono text-muted-foreground",children:"2. After authorizing, paste the code shown on the callback page:"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"text",value:p,onChange:W=>m(W.target.value),onKeyDown:W=>{W.key==="Enter"&&ne()},placeholder:"Paste authorization code here",disabled:h,className:"flex-1 text-[11px] font-mono bg-background border border-border/50 rounded-sm px-3 py-2 text-foreground placeholder:text-muted-foreground/50 focus:outline-none focus:border-cyan-500/50 disabled:opacity-50"}),s.jsx("button",{onClick:()=>{ne()},disabled:!p.trim()||h,className:"px-3 py-2 rounded-sm bg-cyan-500/10 border border-cyan-500/30 text-cyan-400 text-[11px] font-display uppercase tracking-wider hover:border-cyan-400 hover:bg-cyan-500/20 transition-all cursor-pointer disabled:opacity-50",children:h?s.jsx(Ae,{size:14,className:"animate-spin"}):"Submit"})]})]})]})]}),s.jsxs("div",{className:"border border-border/50 rounded-sm p-3 bg-background/30 space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-xs font-display font-bold uppercase tracking-wider text-amber-400",children:"CODEX"}),s.jsxs("p",{className:"text-[11px] font-mono text-muted-foreground",children:[n?.available===!1&&`Unavailable: ${n.error}`,n?.available===!0&&(n.authenticated?"Logged in":"Not logged in"),!n&&"Checking status..."]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[n?.available===!0&&n.authenticated?s.jsxs("button",{onClick:()=>{ge()},disabled:N,className:"flex items-center gap-2 px-3 py-2 rounded-sm bg-background border border-border/50 text-muted-foreground text-xs font-display uppercase tracking-wider hover:text-foreground hover:border-amber-500/30 transition-all cursor-pointer disabled:opacity-50",children:[s.jsx(_i,{size:14}),s.jsx("span",{children:"Logout"})]}):s.jsxs("button",{onClick:()=>{X()},disabled:N,className:"flex items-center gap-2 px-3 py-2 rounded-sm bg-background border border-amber-500/30 text-amber-400 text-xs font-display font-bold uppercase tracking-wider hover:border-amber-400 hover:bg-amber-500/5 hover:shadow-[1px_1px_0_rgba(251,191,36,0.35)] hover:translate-x-[-0.5px] hover:translate-y-[-0.5px] transition-all cursor-pointer disabled:opacity-50",children:[N?s.jsx(Ae,{size:14,className:"animate-spin"}):s.jsx(wi,{size:14}),s.jsx("span",{children:N?"Connecting...":"Connect"})]}),N&&s.jsxs("button",{onClick:()=>{q(b)},className:"flex items-center gap-2 px-3 py-2 rounded-sm bg-background border border-red-500/30 text-red-400 text-xs font-display uppercase tracking-wider hover:border-red-400 hover:bg-red-500/5 transition-all cursor-pointer",children:[s.jsx(bi,{size:14}),s.jsx("span",{children:"Cancel"})]})]})]}),(N||v)&&s.jsxs("div",{className:"space-y-2",children:[(R||O)&&s.jsxs("div",{className:"text-[11px] font-mono text-muted-foreground space-y-1",children:[R&&s.jsxs("a",{href:R,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-2 text-amber-400 hover:underline",children:[s.jsx(os,{size:12}),s.jsx("span",{children:"Open device auth"})]}),O&&s.jsxs("p",{children:["Code: ",s.jsx("span",{className:"text-amber-300",children:O})]})]}),s.jsx("pre",{className:"text-[11px] font-mono whitespace-pre-wrap break-words bg-background border border-border/50 rounded-sm p-3 max-h-48 overflow-auto",children:v||"..."})]})]}),o&&s.jsxs("p",{className:"text-xs font-mono text-red-400",children:["[ERROR] ",o]})]})}const q2=["claude-opus-4-7","claude-opus-4-6","claude-sonnet-4-5-20250929","claude-haiku-4-5-20251001"];function W2({isOpen:t,onClose:e}){const{serverConfig:n,setServerConfig:r}=zs(),[o,a]=u.useState(""),[i,l]=u.useState(""),[c,d]=u.useState(""),[p,m]=u.useState("claude"),[h,g]=u.useState("claude-opus-4-7"),[f,x]=u.useState(!1),[b,y]=u.useState(!1),[v,w]=u.useState(!1),[N,S]=u.useState(!1),[T,C]=u.useState(null),[j,E]=u.useState("credentials"),[R,O]=u.useState(null),[$,re]=u.useState(null),[ne,V]=u.useState(!1),[X,q]=u.useState(""),[K,ge]=u.useState(null),[D,W]=u.useState(!1),Z=F2(),F=typeof window<"u"?window.location.origin:"",se=F.includes("localhost")||F.includes("127.0.0.1"),ee=n?.port||3001,te=`http://localhost:${ee}`,xe=n?.tailscaleIp,_e=xe?`http://${xe}:${ee}`:null,A=H=>{navigator.clipboard.writeText(H),O(H),setTimeout(()=>O(null),2e3)},P=u.useMemo(()=>{const H=c.split(`
|
|
150
|
-
`).length,
|
|
149
|
+
transition-all duration-100 cursor-pointer select-none`,children:s.jsx(Be,{size:14})})})]})})}const mp=Math.PI/6,mk=Math.cos(mp),hk=Math.sin(mp);function fk(t,e,n,r=20,o=50,a=50){const i=(t-n)*mk*r+o,l=(t+n)*hk*r-e*r+a;return{x:i,y:l}}const po={cyan:{base:"#22d3ee",glow:"rgba(34,211,238,"},amber:{base:"#fbbf24",glow:"rgba(251,191,36,"},purple:{base:"#a855f7",glow:"rgba(168,85,247,"},emerald:{base:"#34d399",glow:"rgba(52,211,153,"},rose:{base:"#fb7185",glow:"rgba(251,113,133,"}};function hp({size:t=100,colorScheme:e="gradient",interactive:n=!0,className:r}){const[o,a]=u.useState({x:50,y:50}),{nodes:i,edges:l}=u.useMemo(()=>{const f=[],x=[];for(let b=0;b<3;b++)for(let y=0;y<3;y++)for(let v=0;v<3;v++){const w=`${b}-${y}-${v}`,N=fk(b-1,y-1,v-1,15,50,50);let S="cyan";if(e==="gradient")y===2?S="cyan":y===1?S="purple":S="amber";else if(e==="rainbow"){const T=["cyan","amber","purple","emerald","rose"];S=T[(b+y+v)%T.length]}f.push({id:w,x:b,y,z:v,iso:N,color:S})}for(const b of f){const{x:y,y:v,z:w}=b;y<2&&x.push({from:b.id,to:`${y+1}-${v}-${w}`}),v<2&&x.push({from:b.id,to:`${y}-${v+1}-${w}`}),w<2&&x.push({from:b.id,to:`${y}-${v}-${w+1}`})}return{nodes:f,edges:x}},[e]),c=u.useCallback(f=>{if(!n)return;const x=f.currentTarget.getBoundingClientRect();a({x:(f.clientX-x.left)/x.width*100,y:(f.clientY-x.top)/x.height*100})},[n]),d=u.useCallback(()=>{n&&a({x:50,y:50})},[n]),p=u.useCallback(f=>{if(!n)return .2;const x=o.x-f.iso.x,b=o.y-f.iso.y,y=Math.sqrt(x*x+b*b);return Math.max(.15,.7*(1-y/45))},[o,n]),m=u.useCallback((f,x)=>{if(!n)return .15;const b=(f.iso.x+x.iso.x)/2,y=(f.iso.y+x.iso.y)/2,v=o.x-b,w=o.y-y,N=Math.sqrt(v*v+w*w);return Math.max(.1,.6*(1-N/50))},[o,n]),h=u.useMemo(()=>[...i].sort((f,x)=>f.x+f.z-(x.x+x.z)),[i]),g=u.useMemo(()=>{const f=new Map;for(const x of i)f.set(x.id,x);return f},[i]);return s.jsxs("svg",{width:t,height:t,viewBox:"0 0 100 100",onMouseMove:c,onMouseLeave:d,className:r,children:[s.jsx("defs",{children:Object.entries(po).map(([f,x])=>s.jsxs("filter",{id:`glow-${f}`,x:"-100%",y:"-100%",width:"300%",height:"300%",children:[s.jsx("feGaussianBlur",{stdDeviation:"2",result:"blur"}),s.jsx("feFlood",{floodColor:x.base,result:"color"}),s.jsx("feComposite",{in:"color",in2:"blur",operator:"in",result:"glow"}),s.jsxs("feMerge",{children:[s.jsx("feMergeNode",{in:"glow"}),s.jsx("feMergeNode",{in:"glow"}),s.jsx("feMergeNode",{in:"SourceGraphic"})]})]},f))}),l.map((f,x)=>{const b=g.get(f.from),y=g.get(f.to),v=m(b,y),w=po[b.color];return s.jsx("line",{x1:b.iso.x,y1:b.iso.y,x2:y.iso.x,y2:y.iso.y,stroke:w.base,strokeWidth:1.5,opacity:v,style:{transition:n?"opacity 0.15s ease-out":void 0}},x)}),h.map(f=>{const x=p(f),b=po[f.color],y=3+x*2;return s.jsxs("g",{children:[x>.35&&s.jsx("circle",{cx:f.iso.x,cy:f.iso.y,r:y+x*4,fill:`${b.glow}${x*.2})`,style:{transition:n?"all 0.15s ease-out":void 0}}),s.jsx("circle",{cx:f.iso.x,cy:f.iso.y,r:y,fill:b.base,opacity:.2+x*.6,filter:x>.5?`url(#glow-${f.color})`:void 0,style:{transition:n?"all 0.15s ease-out":void 0}})]},f.id)})]})}const ia=3e4;function gk(){let t=sessionStorage.getItem("connectionDebugTraceId");return t||(t=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,sessionStorage.setItem("connectionDebugTraceId",t)),t}let Pr=!1,ns=null;function xk(){return Pr}function bk(){return ns}function At(t,e,n){if(!Pr)return;const r=ns?`[${ns.slice(0,8)}]`:"";console.log(`%c[ConnDebug]%c ${r} %c${t}%c:${e}`,"background: #4a5568; color: white; padding: 1px 4px; border-radius: 2px;","color: #718096;","color: #48bb78; font-weight: bold;","color: #9ae6b4;",n||""),fetch("/api/system/debug/connection/log",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({component:t,event:e,details:n,traceId:ns})}).catch(()=>{})}async function yk(){Pr=!0,ns=gk();try{await fetch("/api/system/debug/connection/enable",{method:"POST"}),console.log("%c[ConnDebug] Enabled%c - trace ID: %c"+ns,"background: #48bb78; color: white; padding: 2px 6px; border-radius: 3px;","color: #9ae6b4;","color: #48bb78; font-weight: bold;"),console.log("%c[ConnDebug]%c Backend logs: ~/.lattice/logs/connection-debug.log","background: #4a5568; color: white; padding: 1px 4px; border-radius: 2px;","color: #a0aec0;")}catch(t){console.error("[ConnDebug] Failed to enable backend logging:",t)}At("Debug","enabled",{url:window.location.href,userAgent:navigator.userAgent,timestamp:new Date().toISOString()})}async function vk(){At("Debug","disabled"),Pr=!1,ns=null;try{await fetch("/api/system/debug/connection/disable",{method:"POST"}),console.log("%c[ConnDebug] Disabled","background: #718096; color: white; padding: 2px 6px; border-radius: 3px;")}catch(t){console.error("[ConnDebug] Failed to disable backend logging:",t)}}async function wk(t=200){try{return(await(await fetch(`/api/system/debug/connection/logs?limit=${t}`)).json()).logs}catch(e){return console.error("[ConnDebug] Failed to fetch logs:",e),[]}}async function _k(){try{await fetch("/api/system/debug/connection/logs",{method:"DELETE"})}catch(t){console.error("[ConnDebug] Failed to clear logs:",t)}}async function kk(){const t=await wk();console.log("%c[ConnDebug] Recent Logs ("+t.length+")","background: #4a5568; color: white; padding: 4px 8px; border-radius: 3px; font-size: 14px;"),t.forEach(e=>{const n=e,r=n.source==="frontend"?"#48bb78":"#4299e1";console.log(`%c${n.source}%c ${n.timestamp.slice(11,23)} %c${n.component}%c:${n.event}`,`background: ${r}; color: white; padding: 1px 4px; border-radius: 2px;`,"color: #718096;","color: #ed8936;","color: #fbd38d;",n.details||"")})}typeof window<"u"&&(window.__enableConnectionDebug=yk,window.__disableConnectionDebug=vk,window.__viewConnectionLogs=kk,window.__clearConnectionLogs=_k,window.__connectionDebug={log:At,isEnabled:xk,getTraceId:bk});function ca(t,e,n){jk({conversationId:t,milestone:e,clientTimestamp:Date.now(),fields:n})}function jk(t){try{fetch("/api/timeline/milestone",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),keepalive:!0}).catch(()=>{})}catch{}}const Gc="/api/logs/incidents",fp=6e4,Nk=4,Sk=6e4,Ck=new Map;let Hc=!1,Pt={};function Ek(t){Pt={...t}}function Tk(){Pt={}}function la(){return typeof window>"u"?"":`${window.location.pathname}${window.location.search}`}function Ik(t,e){return up(Ck,t,e,Nk,Sk)}function Rs(t){if(typeof window>"u")return;const e=Date.now(),n=`${t.type}:${t.severity}:${t.route||la()}:${t.message||""}`;if(!Ik(n,e))return;const r=JSON.stringify({incidents:[{conversationId:t.conversationId??Pt.conversationId,sessionId:t.sessionId??Pt.sessionId,streamingId:t.streamingId??Pt.streamingId,...t,route:t.route||la()}]});try{if(typeof navigator<"u"&&typeof navigator.sendBeacon=="function"&&typeof Blob<"u"&&r.length<=fp&&navigator.sendBeacon(Gc,new Blob([r],{type:"application/json"})))return}catch{}fetch(Gc,{method:"POST",headers:{"Content-Type":"application/json"},body:r,keepalive:!0}).catch(()=>{})}const qc="/api/logs/console",Ak=2e3,Rk=50;let en=[];function da(){if(en.length===0)return;const t=en;en=[];const e=JSON.stringify({entries:t});try{if(typeof navigator<"u"&&typeof navigator.sendBeacon=="function"&&typeof Blob<"u"&&e.length<=fp&&navigator.sendBeacon(qc,new Blob([e],{type:"application/json"})))return}catch{}fetch(qc,{method:"POST",headers:{"Content-Type":"application/json"},body:e,keepalive:!0}).catch(()=>{})}function Wc(t,e){const n=e.map(r=>typeof r=="string"?r:r instanceof Error?r.message:JSON.stringify(r)).join(" ").slice(0,500);en.push({level:t,message:n,timestamp:new Date().toISOString(),route:la(),conversationId:Pt.conversationId,sessionId:Pt.sessionId}),en.length>=Rk&&da()}let Kc=!1;function Pk(){if(Kc||typeof window>"u")return;Kc=!0;const t=console.warn.bind(console),e=console.error.bind(console);console.warn=(...n)=>{t(...n),Wc("warn",n)},console.error=(...n)=>{e(...n),Wc("error",n)},setInterval(da,Ak),window.addEventListener("beforeunload",da)}function Mk(){Hc||typeof window>"u"||(Hc=!0,window.addEventListener("error",t=>{Rs({type:"window-error",severity:"error",message:t.message||"Unhandled window error",...Pt,details:{filename:t.filename||null,lineno:t.lineno||null,colno:t.colno||null}})}),window.addEventListener("unhandledrejection",t=>{const e=t.reason instanceof Error?t.reason.message:String(t.reason??"Unhandled promise rejection");Rs({type:"unhandled-rejection",severity:"error",message:e,...Pt})}))}const Lk="lattice:suspected-tab-network-stall",Qc=2e4,Ok=6e4,Dk=12,$k=12;class zk{pendingRequests=new Map;recentOutcomes=[];streams=new Map;lastStallIncidentAtMs=0;requestCounter=0;beginApiRequest(e){const n=`req-${Date.now().toString(36)}-${this.requestCounter++}`;return this.pendingRequests.set(n,{id:n,method:e.method,path:e.path,timeoutMs:e.timeoutMs,startedAtMs:Date.now()}),n}finishApiRequest(e,n){this.pendingRequests.delete(e),this.pushOutcome({at:new Date().toISOString(),status:n.status,method:n.method,path:n.path,durationMs:n.durationMs,timeoutMs:n.timeoutMs,error:n.error}),(n.status==="timeout"||n.status==="failed")&&this.maybeReportSuspectedStall({source:"api",reason:n.status==="timeout"?"request-timeout":"request-failed",method:n.method,path:n.path,status:n.status})}noteStreamConnecting(e){this.upsertStream(e,{status:"connecting"})}noteStreamOpen(e){this.upsertStream(e,{status:"open",connectedAtMs:Date.now(),lastError:void 0})}noteStreamActivity(e){const n=this.streams.get(e);n&&(n.lastEventAtMs=Date.now(),n.status!=="open"&&(n.status="open",n.lastStateAtMs=n.lastEventAtMs))}noteStreamError(e,n){this.upsertStream(e,{status:"error",lastError:n}),this.maybeReportSuspectedStall({source:"stream",reason:"stream-error",streamKind:e.kind,streamKey:e.key})}noteStreamClosed(e,n){this.upsertStream(e,{status:"closed",lastError:n})}upsertStream(e,n){const r=Date.now(),o=this.streams.get(e.key),a={key:e.key,kind:e.kind,sessionId:e.sessionId,streamingId:e.streamingId,status:n.status??o?.status??"closed",lastStateAtMs:r,connectedAtMs:n.connectedAtMs??o?.connectedAtMs,lastEventAtMs:n.lastEventAtMs??o?.lastEventAtMs,lastError:n.lastError??o?.lastError};this.streams.set(e.key,a),this.pruneStreams()}pushOutcome(e){const n=Date.now()-Qc;this.recentOutcomes.push(e),this.recentOutcomes=this.recentOutcomes.filter(r=>Date.parse(r.at)>=n).slice(-40)}pruneStreams(){const e=Date.now()-18e5;for(const[n,r]of this.streams.entries())r.status==="closed"&&r.lastStateAtMs<e&&this.streams.delete(n)}maybeReportSuspectedStall(e){if(typeof window>"u")return;const n=Date.now();if(n-this.lastStallIncidentAtMs<Ok)return;const r=this.recentOutcomes.filter(h=>n-Date.parse(h.at)<=Qc),o=r.filter(h=>h.status==="timeout"||h.status==="failed"),a=new Set(o.map(h=>`${h.method} ${h.path}`)),i=o.filter(h=>h.status==="timeout").length,l=Array.from(this.pendingRequests.values()),c=l.reduce((h,g)=>{const f=n-g.startedAtMs;return f>h?f:h},0);if(!(i>=2&&a.size>=2||o.length>=4&&a.size>=3||l.length>=6&&c>=1e4&&o.length>=2))return;this.lastStallIncidentAtMs=n;const p=Array.from(this.streams.values()).sort((h,g)=>g.lastStateAtMs-h.lastStateAtMs).slice(0,$k).map(h=>({key:h.key,kind:h.kind,sessionId:h.sessionId,streamingId:h.streamingId,status:h.status,connectedAgeMs:h.connectedAtMs?n-h.connectedAtMs:null,lastEventAgeMs:h.lastEventAtMs?n-h.lastEventAtMs:null,lastStateAgeMs:n-h.lastStateAtMs,lastError:h.lastError})),m=l.sort((h,g)=>h.startedAtMs-g.startedAtMs).slice(0,Dk).map(h=>({method:h.method,path:h.path,ageMs:n-h.startedAtMs,timeoutMs:h.timeoutMs}));Rs({type:"suspected-tab-network-stall",severity:"error",message:"Burst of client request failures suggests browser-tab transport stall",details:{trigger:e,visibilityState:document.visibilityState,online:typeof navigator<"u"?navigator.onLine:void 0,pendingRequestCount:l.length,oldestPendingRequestAgeMs:c||0,pendingRequests:m,recentApiOutcomes:r.slice(-12),streamHealth:p}}),window.dispatchEvent(new CustomEvent(Lk,{detail:{trigger:e,pendingRequestCount:l.length,oldestPendingRequestAgeMs:c||0,recentApiOutcomes:r.slice(-12),streamHealth:p}}))}}let mo=null;function Fk(){return mo||(mo=new zk),mo}const Yc=6e4,Jc=2e3,Vk="Request timeout after ",ho=25;function Bk(t){const[e]=t.split("?");return e.replace(/\/conv-[A-Za-z0-9_-]+/g,"/conv-:id").replace(/\/codex-[A-Za-z0-9_-]+/g,"/codex-:id").replace(/\/[0-9a-f]{8}-[0-9a-f-]{27,}/gi,"/:uuid")}function Uk(){return`nav-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`}function Gk(t){return t instanceof Error&&t.message.startsWith(Vk)}class Hk extends Error{status;code;details;constructor(e,n,r,o){super(e),this.name="ApiRequestError",this.status=n,this.code=r,this.details=o}}function qk(t){return t===void 0||t>ho?ho:null}class Wk{baseUrl="";canonicalConversationIdCache=new Map;canonicalConversationIdInFlight=new Map;cachedGetResponses=new Map;cachedGetInFlight=new Map;cachedGetGeneration=new Map;assertUnifiedConversationId(e){if(!e.startsWith("conv-"))throw new Error(`Expected unified conversation ID (conv-*), got "${e}"`)}async resolveCanonicalConversationId(e){if(e.startsWith("conv-"))return e;const n=this.canonicalConversationIdCache.get(e);if(n)return n;const r=this.canonicalConversationIdInFlight.get(e);if(r)return r;const o=this.resolveUnifiedConversationId(e).then(a=>(this.canonicalConversationIdCache.set(e,a.conversationId),a.conversationId)).finally(()=>{this.canonicalConversationIdInFlight.delete(e)});return this.canonicalConversationIdInFlight.set(e,o),o}shouldEnableKeepalive(e){if(!e.keepalive)return!1;const n=e.body;return n?typeof n=="string"?n.length<=Yc:n instanceof URLSearchParams?n.toString().length<=Yc:!1:!0}async apiCall(e,n){const r=`${this.baseUrl}${e}`,o=n?.timeout??ia,a=(n?.method||"GET").toUpperCase(),i=Bk(e),l=performance.now(),c=Fk(),d=c.beginApiRequest({method:a,path:i,timeoutMs:o}),p=new Headers(n?.headers);p.set("Content-Type","application/json");const m=new AbortController,h=setTimeout(()=>m.abort(),o);try{const g={...n||{}};delete g.timeout;const f=this.shouldEnableKeepalive(g),x=await fetch(r,{...g,headers:p,signal:m.signal,keepalive:f});clearTimeout(h);const b=await x.json();if(!x.ok){const v=b,w=v.error||`HTTP ${x.status}`,N=Math.round(performance.now()-l);throw c.finishApiRequest(d,{status:"http_error",method:a,path:i,timeoutMs:o,durationMs:N,error:w}),mt({component:"ApiService",event:"api-request-error",severity:"warn",details:{method:a,path:i,status:x.status,timeoutMs:o,durationMs:N,message:w}}),new Hk(w,x.status,v.code,v)}const y=Math.round(performance.now()-l);return c.finishApiRequest(d,{status:y>=Jc?"slow":"success",method:a,path:i,timeoutMs:o,durationMs:y}),y>=Jc&&mt({component:"ApiService",event:"api-request-slow",severity:"warn",details:{method:a,path:i,durationMs:y,timeoutMs:o}}),b}catch(g){if(clearTimeout(h),g instanceof Error&&g.name==="AbortError"){const x=new Error(`Request timeout after ${o}ms: ${e}`),b=Math.round(performance.now()-l);throw c.finishApiRequest(d,{status:"timeout",method:a,path:i,timeoutMs:o,durationMs:b,error:x.message}),mt({component:"ApiService",event:"api-request-timeout",severity:"error",details:{method:a,path:i,timeoutMs:o,durationMs:b}}),Rs({type:"api-request-timeout",severity:"error",message:x.message,details:{method:a,path:i,timeoutMs:o,durationMs:b}}),x}const f=Math.round(performance.now()-l);throw c.finishApiRequest(d,{status:"failed",method:a,path:i,timeoutMs:o,durationMs:f,error:g instanceof Error?g.message:String(g)}),mt({component:"ApiService",event:"api-request-failed",severity:"error",details:{method:a,path:i,timeoutMs:o,durationMs:f,error:g instanceof Error?g.message:String(g)}}),Rs({type:"api-request-failed",severity:"warn",message:g instanceof Error?g.message:String(g),details:{method:a,path:i,timeoutMs:o,durationMs:f}}),g}}async fetchDirect(e,n){return fetch(e,n)}async cachedGet(e,n,r){const o=Date.now(),a=this.cachedGetResponses.get(e);if(a&&a.expiresAt>o)return a.value;const i=this.cachedGetInFlight.get(e);if(i)return i;const l=this.cachedGetGeneration.get(e)??0,c=r().then(d=>((this.cachedGetGeneration.get(e)??0)===l&&this.cachedGetResponses.set(e,{value:d,expiresAt:Date.now()+n}),d)).finally(()=>{this.cachedGetInFlight.delete(e)});return this.cachedGetInFlight.set(e,c),c}invalidateCachedGet(e){for(const n of this.cachedGetResponses.keys())n.startsWith(e)&&(this.cachedGetResponses.delete(n),this.cachedGetGeneration.set(n,(this.cachedGetGeneration.get(n)??0)+1));for(const n of this.cachedGetInFlight.keys())n.startsWith(e)&&(this.cachedGetInFlight.delete(n),this.cachedGetGeneration.set(n,(this.cachedGetGeneration.get(n)??0)+1))}async resolveUnifiedConversationId(e){return this.apiCall(`/api/conv/resolve/${encodeURIComponent(e)}`)}}const Kk="conversation:session-status:",Qk=750;class Yk extends Wk{async getConversationDetails(e,n){this.assertUnifiedConversationId(e);const r="/api/conv",o=n?.traceId||Uk(),a=performance.now(),i=e.slice(0,8),l=async c=>{const d=new URLSearchParams,p=c??n?.limit;p&&d.set("limit",String(p)),n?.before&&d.set("before",n.before);const m=d.toString(),h=`${r}/${e}${m?`?${m}`:""}`;return this.apiCall(h,{headers:{"X-Trace-Id":o},timeout:n?.timeout})};try{const c=await l(),d=Math.round(performance.now()-a);return d>1e3&&mt({component:"ApiService",event:"conversation-details-slow",severity:"warn",traceId:o,details:{sessionId:i,providerRoute:e.startsWith("conv-")?"unified":"legacy",durationMs:d,timeoutMs:n?.timeout??ia,messageCount:c.messages?.length??0,limit:n?.limit??null,beforeProvided:!!n?.before}}),c}catch(c){const d=Math.round(performance.now()-a),p=Gk(c)?qk(n?.limit):null;if(!p)throw c;mt({component:"ApiService",event:"conversation-details-fallback-start",severity:"warn",traceId:o,details:{sessionId:i,originalLimit:n?.limit??null,fallbackLimit:p,beforeProvided:!!n?.before,timeoutMs:n?.timeout??ia,initialDurationMs:d}});const m=performance.now();try{const h=await l(p),g=Math.round(performance.now()-m);return mt({component:"ApiService",event:"conversation-details-fallback-success",severity:"warn",traceId:o,details:{sessionId:i,fallbackLimit:p,fallbackDurationMs:g,messageCount:h.messages?.length??0,hasMore:h.hasMore??null,oldestMessageId:h.oldestMessageId??null}}),h}catch(h){throw mt({component:"ApiService",event:"conversation-details-fallback-failed",severity:"error",traceId:o,details:{sessionId:i,fallbackLimit:p,error:h instanceof Error?h.message:String(h)}}),h}}}async getConversationStatus(e){this.assertUnifiedConversationId(e);const r=(await this.getSessionsStatus([e])).sessions[e]??{status:"completed",provider:null,streamingId:null,startedAt:null};return{sessionId:e,status:r.status,provider:r.provider,streamingId:r.streamingId,startedAt:r.startedAt}}async getSessionsStatus(e){const r=[...(e??[]).map(i=>i.trim()).filter(i=>i.length>0)].sort(),o=r.length>0?`?ids=${encodeURIComponent(r.join(","))}`:"",a=`${Kk}${r.join(",")}`;return this.cachedGet(a,Qk,()=>this.apiCall(`/api/sessions/status${o}`))}async createConversation(e){const n=performance.now();At("ApiService","create-conversation-request",{provider:e.provider,permissionMode:e.permissionMode??null});const r=await this.apiCall("/api/conv/create",{method:"POST",body:JSON.stringify(e),keepalive:!0,timeout:65e3});return At("ApiService","create-conversation-response",{conversationId:r.conversationId.slice(0,12),streamingId:r.streamingId.slice(0,8),durationMs:Math.round(performance.now()-n),permissionMode:r.permissionMode??e.permissionMode??null}),ca(r.conversationId,"client.create_response_received",{durationMs:Math.round(performance.now()-n)}),r}async resumeConversation(e,n){const r=performance.now();At("ApiService","resume-conversation-request",{conversationId:e.slice(0,12),permissionMode:n.permissionMode??null});const o=await this.apiCall(`/api/conv/${e}/resume`,{method:"POST",body:JSON.stringify(n),keepalive:!0,timeout:65e3});return At("ApiService","resume-conversation-response",{conversationId:o.conversationId.slice(0,12),streamingId:o.streamingId.slice(0,8),durationMs:Math.round(performance.now()-r)}),ca(o.conversationId,"client.resume_response_received",{durationMs:Math.round(performance.now()-r)}),o}async getUnifiedConversation(e){return this.apiCall(`/api/conv/${e}`)}async listUnifiedConversations(e){const n=new URLSearchParams;e?.includeIdentityImage!==void 0&&n.set("includeIdentityImage",String(e.includeIdentityImage)),e?.archived!==void 0&&n.set("archived",String(e.archived)),typeof e?.limit=="number"&&Number.isFinite(e.limit)&&e.limit>0&&n.set("limit",String(Math.floor(e.limit))),typeof e?.cursor=="string"&&e.cursor.trim().length>0&&n.set("cursor",e.cursor);const r=n.toString();return this.apiCall(r?`/api/conv?${r}`:"/api/conv")}async getUnifiedConversationIdentityImage(e){return this.apiCall(`/api/conv/${e}/identity-image`)}async unifiedStopConversation(e,n){return this.assertUnifiedConversationId(e),this.apiCall(`/api/conv/${e}/stop`,{method:"POST",body:n?.inFlightMessage?JSON.stringify({inFlightMessage:n.inFlightMessage}):void 0})}async unifiedInterruptConversation(e){return this.assertUnifiedConversationId(e),this.apiCall(`/api/conv/${e}/interrupt`,{method:"POST"})}async unifiedForceKillConversation(e){return this.assertUnifiedConversationId(e),this.apiCall(`/api/conv/${e}/force-kill`,{method:"POST"})}async unifiedInjectMessage(e,n,r){return this.assertUnifiedConversationId(e),this.apiCall(`/api/conv/${e}/inject`,{method:"POST",body:JSON.stringify({message:n,...r&&r.length>0?{initialContent:r}:{}})})}async unifiedUpdateConversation(e,n){return this.assertUnifiedConversationId(e),this.apiCall(`/api/conv/${e}/update`,{method:"PUT",body:JSON.stringify(n)})}async unifiedBranchConversation(e,n,r){return this.assertUnifiedConversationId(e),this.apiCall(`/api/conv/${e}/branch`,{method:"POST",body:JSON.stringify({afterTurn:n,timestamp:r})})}async unifiedGetInsights(e,n=!0){return this.assertUnifiedConversationId(e),this.apiCall(`/api/conv/${e}/insights?quick=${n}`)}async unifiedRefreshInsights(e){return this.assertUnifiedConversationId(e),this.apiCall(`/api/conv/${e}/insights/refresh`,{method:"POST"})}async unifiedGetQueue(e){return this.assertUnifiedConversationId(e),this.apiCall(`/api/conv/${e}/queue`)}async unifiedEnqueueMessage(e,n){return this.assertUnifiedConversationId(e),this.apiCall(`/api/conv/${e}/queue`,{method:"POST",body:JSON.stringify(n)})}async unifiedDeleteQueuedMessage(e,n){return this.assertUnifiedConversationId(e),this.apiCall(`/api/conv/${e}/queue/${n}`,{method:"DELETE"})}async unifiedClearQueue(e){return this.assertUnifiedConversationId(e),this.apiCall(`/api/conv/${e}/queue/clear`,{method:"POST"})}async unifiedArchiveAll(){return this.apiCall("/api/conv/archive-all",{method:"POST"})}async unifiedActivityCheck(e,n,r){return this.apiCall("/api/conv/activity-check",{method:"POST",body:JSON.stringify({sessionIds:e,knownMtimes:n,previouslyActiveSessionIds:r})})}async getConversationIdentityImage(e){const n=await this.resolveCanonicalConversationId(e);return this.getUnifiedConversationIdentityImage(n)}async getLastContextTransfer(e,n){return this.apiCall(`/api/context-transfers/${e}/last?toProvider=${n}`)}}class Jk extends Yk{async getWorkingDirectories(){return this.apiCall("/api/working-directories")}async getPermissions(e){const n=new URLSearchParams;return e?.streamingId&&n.append("streamingId",e.streamingId),e?.sessionId&&n.append("sessionId",e.sessionId),e?.status&&n.append("status",e.status),this.apiCall(`/api/permissions?${n}`)}async sendPermissionDecision(e,n){return this.apiCall(`/api/permissions/${e}/decision`,{method:"POST",body:JSON.stringify(n)})}async addToAllowlist(e,n,r){const o=e==="session"?{pattern:n,streamingId:r}:{pattern:n};return this.apiCall(`/api/permissions/allowlist/${e}`,{method:"POST",body:JSON.stringify(o)})}async getSuggestedPatterns(e,n){return this.apiCall("/api/permissions/suggest-patterns",{method:"POST",body:JSON.stringify({toolName:e,toolInput:n})})}}class Xk extends Jk{async listTeams(){return this.apiCall("/api/teams")}async getTeamInfo(e){return this.apiCall(`/api/teams/${encodeURIComponent(e)}`)}async getTeamInboxes(e){return this.apiCall(`/api/teams/${encodeURIComponent(e)}/inboxes`)}}const Zk=15e3,e2="config:commands:",t2=1e4,s2="config:directory-list:",n2=6e4,r2="config:web-push-status";class o2 extends Xk{async listDirectory(e){const n=new URLSearchParams;n.append("path",e.path),e.recursive!==void 0&&n.append("recursive",e.recursive.toString()),e.respectGitignore!==void 0&&n.append("respectGitignore",e.respectGitignore.toString());const r=n.toString(),o=`${s2}${r}`;return this.cachedGet(o,t2,()=>this.apiCall(`/api/filesystem/list?${r}`))}async getCommands(e){const n=new URLSearchParams;e&&n.append("workingDirectory",e);const r=n.toString(),o=`${e2}${e||""}`;return this.cachedGet(o,Zk,()=>this.apiCall(`/api/system/commands?${r}`))}async getSystemStatus(){return this.apiCall("/api/system/status")}async checkVersion(){return this.apiCall("/api/system/version-check")}async getLoadedPlugins(){return this.apiCall("/api/plugins")}async getRecentLogs(e){const n=new URLSearchParams;return e!==void 0&&n.append("limit",e.toString()),this.apiCall(`/api/logs/recent?${n}`)}getLogStreamUrl(){return"/api/logs/stream"}async readFile(e){const n=new URLSearchParams;return n.append("path",e),this.apiCall(`/api/filesystem/read?${n}`)}async transcribeAudio(e,n){return this.apiCall("/api/gemini/transcribe",{method:"POST",body:JSON.stringify({audio:e,mimeType:n})})}async getGeminiHealth(){return this.apiCall("/api/gemini/health")}async checkAnthropicCredits(){return this.apiCall("/api/system/check-credits",{method:"POST"})}async getConfig(){return this.apiCall("/api/config")}async updateConfig(e){return this.apiCall("/api/config",{method:"PUT",body:JSON.stringify(e)})}async getLicenseStatus(){return this.apiCall("/api/license/status")}async revalidateLicense(){return this.apiCall("/api/license/revalidate",{method:"POST"})}async getWebPushStatus(){return this.cachedGet(r2,n2,()=>this.apiCall("/api/notifications/status"))}async registerWebPush(e){return this.apiCall("/api/notifications/register",{method:"POST",body:JSON.stringify(e)})}async unregisterWebPush(e){return this.apiCall("/api/notifications/unregister",{method:"POST",body:JSON.stringify({endpoint:e})})}async sendTestNotification(){return this.apiCall("/api/notifications/test",{method:"POST",body:JSON.stringify({})})}exportLogs(e=10){window.open(`/api/logs/export?minutes=${e}`,"_blank")}}const qs="session:dev-notes",Ln="session:pending-recommendations",a2="session:turns:",vs="session:cross-session-status",ws="session:cross-session-latest",Xc=15e3,i2=1e4;class c2 extends o2{async regenerateMission(e){const n=await this.unifiedRefreshInsights(e);return{success:n.success,sessionId:n.conversationId,mission:n.mission}}async getSessionTurns(e){return this.cachedGet(`${a2}${e}`,i2,()=>this.apiCall(`/api/insights/${e}/turns`))}async getTurnAnchorMessageId(e,n){return this.apiCall(`/api/insights/${e}/turns/${n}/message-id`)}async analyzeSessionForReview(e,n=!1){const r=n?"?force=true":"";return this.apiCall(`/api/insights/${e}/review${r}`,{method:"POST",timeout:12e4})}async acceptRecommendation(e){const n=await this.apiCall("/api/insights/recommendations/accept",{method:"POST",body:JSON.stringify(e)});return this.invalidateCachedGet(Ln),n}async dismissRecommendation(e){const n=await this.apiCall(`/api/insights/recommendations/${e}/dismiss`,{method:"POST"});return this.invalidateCachedGet(Ln),n}async completeRecommendation(e){const n=await this.apiCall(`/api/insights/recommendations/${e}/complete`,{method:"POST"});return this.invalidateCachedGet(Ln),n}async getPendingRecommendations(){return this.cachedGet(Ln,Xc,()=>this.apiCall("/api/insights/recommendations/pending"))}async getCrossSessionStatus(){return this.cachedGet(vs,1e4,()=>this.apiCall("/api/insights/cross-session/status"))}async getLatestCrossSessionSynthesis(){return this.cachedGet(ws,1e4,()=>this.apiCall("/api/insights/cross-session/latest"))}async runCrossSessionAnalysis(){const e=await this.apiCall("/api/insights/cross-session/run",{method:"POST",timeout:12e4});return this.invalidateCachedGet(vs),this.invalidateCachedGet(ws),e}async runCrossSessionDeepScan(){const e=await this.apiCall("/api/insights/cross-session/deep-scan",{method:"POST",timeout:12e4});return this.invalidateCachedGet(vs),this.invalidateCachedGet(ws),e}async applyCrossSessionProposal(e){const n=await this.apiCall(`/api/insights/cross-session/${e.synthesisId}/proposals/${e.proposalId}/apply`,{method:"POST",body:JSON.stringify({proposedText:e.proposedText,currentText:e.currentText,anchorHeading:e.anchorHeading,operation:e.operation,sourceSynthesisId:e.sourceSynthesisId})});return this.invalidateCachedGet(vs),this.invalidateCachedGet(ws),n}async dismissCrossSessionProposal(e){const n=await this.apiCall(`/api/insights/cross-session/${e.synthesisId}/proposals/${e.proposalId}/dismiss`,{method:"POST",body:JSON.stringify({sourceSynthesisId:e.sourceSynthesisId})});return this.invalidateCachedGet(vs),this.invalidateCachedGet(ws),n}async archiveCrossSessionProposals(e){const n=await this.apiCall(`/api/insights/cross-session/${e.synthesisId}/proposals/archive`,{method:"POST",body:JSON.stringify({proposalIds:e.proposalIds,sourceSynthesisIds:e.sourceSynthesisIds})});return this.invalidateCachedGet(vs),this.invalidateCachedGet(ws),n}async getDevNotes(){return this.cachedGet(qs,Xc,()=>this.apiCall("/api/notes"))}async createDevNote(e){const n=await this.apiCall("/api/notes",{method:"POST",body:JSON.stringify(e)});return this.invalidateCachedGet(qs),n}async updateDevNote(e,n){const r=await this.apiCall(`/api/notes/${e}`,{method:"PATCH",body:JSON.stringify(n)});return this.invalidateCachedGet(qs),r}async updateDevNoteStatus(e,n){return this.updateDevNote(e,{status:n})}async deleteDevNote(e){const n=await this.apiCall(`/api/notes/${e}`,{method:"DELETE"});return this.invalidateCachedGet(qs),n}async markDevNotesAsDone(e){const n=await this.apiCall("/api/notes/batch-done",{method:"POST",body:JSON.stringify({noteIds:e})});return this.invalidateCachedGet(qs),n}async getPendingQuestions(e){const n=new URLSearchParams;e&&n.append("sessionId",e);const r=n.toString();return this.apiCall(`/api/pending-questions${r?`?${r}`:""}`)}async getPendingQuestion(e){return this.apiCall(`/api/pending-questions/${e}`)}async answerPendingQuestion(e,n){return this.apiCall(`/api/pending-questions/${e}/answer`,{method:"POST",body:JSON.stringify({answers:n})})}async expirePendingQuestion(e){return this.apiCall(`/api/pending-questions/${e}/expire`,{method:"POST"})}async getSessionDiagnostic(e){return this.apiCall(`/api/debug/sessions/${e}/diagnostic`)}async getSessionEvents(e,n){const r=new URLSearchParams;n?.traceId&&r.append("traceId",n.traceId),n?.limit&&r.append("limit",n.limit.toString()),n?.since&&r.append("since",n.since),n?.types&&r.append("types",n.types.join(","));const o=r.toString();return this.apiCall(`/api/debug/sessions/${e}/events${o?`?${o}`:""}`)}async getSessionAuditTrail(e,n){const r=new URLSearchParams;n?.limit&&r.append("limit",n.limit.toString()),n?.eventTypes&&r.append("eventTypes",n.eventTypes.join(",")),n?.triggers&&r.append("triggers",n.triggers.join(",")),n?.since&&r.append("since",n.since);const o=r.toString();return this.apiCall(`/api/debug/sessions/${e}/audit-trail${o?`?${o}`:""}`)}async getSessionCosts(e){return this.apiCall(`/api/debug/sessions/${e}/costs`)}async getActiveSessionsOverview(){return this.apiCall("/api/debug/active-sessions")}async exportSession(e){const n=await this.fetchDirect(`/api/sessions/export/${e}`);if(!n.ok){const d=await n.json().catch(()=>({error:"Export failed"})),p=d&&typeof d=="object"&&"error"in d&&typeof d.error=="string"?d.error:"Export failed";throw new Error(p)}const r=await n.blob(),i=n.headers.get("Content-Disposition")?.match(/filename="(.+?)"/)?.[1]||`session-${e}.lattice.json`,l=URL.createObjectURL(r),c=document.createElement("a");c.href=l,c.download=i,document.body.appendChild(c),c.click(),document.body.removeChild(c),URL.revokeObjectURL(l)}async importSession(e){return this.apiCall("/api/sessions/import",{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json"}})}}class l2 extends c2{}const H=new l2;var Mr="Popover",[gp]=pr(Mr,[Tr]),bn=Tr(),[d2,qt]=gp(Mr),xp=t=>{const{__scopePopover:e,children:n,open:r,defaultOpen:o,onOpenChange:a,modal:i=!1}=t,l=bn(e),c=u.useRef(null),[d,p]=u.useState(!1),[m,h]=ba({prop:r,defaultProp:o??!1,onChange:a,caller:Mr});return s.jsx(Hu,{...l,children:s.jsx(d2,{scope:e,contentId:Ys(),triggerRef:c,open:m,onOpenChange:h,onOpenToggle:u.useCallback(()=>h(g=>!g),[h]),hasCustomAnchor:d,onCustomAnchorAdd:u.useCallback(()=>p(!0),[]),onCustomAnchorRemove:u.useCallback(()=>p(!1),[]),modal:i,children:n})})};xp.displayName=Mr;var bp="PopoverAnchor",u2=u.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,o=qt(bp,n),a=bn(n),{onCustomAnchorAdd:i,onCustomAnchorRemove:l}=o;return u.useEffect(()=>(i(),()=>l()),[i,l]),s.jsx(ei,{...a,...r,ref:e})});u2.displayName=bp;var yp="PopoverTrigger",vp=u.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,o=qt(yp,n),a=bn(n),i=dt(e,o.triggerRef),l=s.jsx(st.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Np(o.open),...r,ref:i,onClick:He(t.onClick,o.onOpenToggle)});return o.hasCustomAnchor?l:s.jsx(ei,{asChild:!0,...a,children:l})});vp.displayName=yp;var ni="PopoverPortal",[p2,m2]=gp(ni,{forceMount:void 0}),wp=t=>{const{__scopePopover:e,forceMount:n,children:r,container:o}=t,a=qt(ni,e);return s.jsx(p2,{scope:e,forceMount:n,children:s.jsx(ls,{present:n||a.open,children:s.jsx(Sr,{asChild:!0,container:o,children:r})})})};wp.displayName=ni;var Ps="PopoverContent",_p=u.forwardRef((t,e)=>{const n=m2(Ps,t.__scopePopover),{forceMount:r=n.forceMount,...o}=t,a=qt(Ps,t.__scopePopover);return s.jsx(ls,{present:r||a.open,children:a.modal?s.jsx(f2,{...o,ref:e}):s.jsx(g2,{...o,ref:e})})});_p.displayName=Ps;var h2=Vl("PopoverContent.RemoveScroll"),f2=u.forwardRef((t,e)=>{const n=qt(Ps,t.__scopePopover),r=u.useRef(null),o=dt(e,r),a=u.useRef(!1);return u.useEffect(()=>{const i=r.current;if(i)return fu(i)},[]),s.jsx(Ka,{as:h2,allowPinchZoom:!0,children:s.jsx(kp,{...t,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:He(t.onCloseAutoFocus,i=>{i.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:He(t.onPointerDownOutside,i=>{const l=i.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;a.current=d},{checkForDefaultPrevented:!1}),onFocusOutside:He(t.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),g2=u.forwardRef((t,e)=>{const n=qt(Ps,t.__scopePopover),r=u.useRef(!1),o=u.useRef(!1);return s.jsx(kp,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{t.onCloseAutoFocus?.(a),a.defaultPrevented||(r.current||n.triggerRef.current?.focus(),a.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:a=>{t.onInteractOutside?.(a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=a.target;n.triggerRef.current?.contains(i)&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),kp=u.forwardRef((t,e)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,disableOutsidePointerEvents:i,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onInteractOutside:p,...m}=t,h=qt(Ps,n),g=bn(n);return au(),s.jsx(Wa,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:s.jsx(Nr,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:p,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onDismiss:()=>h.onOpenChange(!1),children:s.jsx(qu,{"data-state":Np(h.open),role:"dialog",id:h.contentId,...g,...m,ref:e,style:{...m.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),jp="PopoverClose",x2=u.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,o=qt(jp,n);return s.jsx(st.button,{type:"button",...r,ref:e,onClick:He(t.onClick,()=>o.onOpenChange(!1))})});x2.displayName=jp;var b2="PopoverArrow",y2=u.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,o=bn(n);return s.jsx(Wu,{...o,...r,ref:e})});y2.displayName=b2;function Np(t){return t?"open":"closed"}var v2=xp,w2=vp,_2=wp,Sp=_p;function Zc({...t}){return s.jsx(v2,{"data-slot":"popover",...t})}function el({...t}){return s.jsx(w2,{"data-slot":"popover-trigger",...t})}const ua=u.forwardRef(({className:t,align:e="center",sideOffset:n=4,...r},o)=>s.jsx(_2,{children:s.jsx(Sp,{ref:o,"data-slot":"popover-content",align:e,sideOffset:n,className:$e("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]: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 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),...r})}));ua.displayName=Sp.displayName;const Cp=u.createContext(void 0),k2={status:"disconnected",error:null,reconnectAttempt:0,lastConnectedAt:null,lastDisconnectedAt:null};function j2({children:t}){const e=u.useRef(new Map),n=u.useRef(!0);u.useEffect(()=>(n.current=!0,()=>{n.current=!1}),[]);const r=u.useCallback((i,l)=>{const c=i.type==="session"?`session:${i.sessionId}`:"activity";return e.current.has(c)||e.current.set(c,new Set),e.current.get(c).add(l),()=>{const d=e.current.get(c);d&&(d.delete(l),d.size===0&&e.current.delete(c))}},[]),o=u.useCallback(()=>{},[]),a=u.useMemo(()=>({connectionState:k2,subscribe:r,reconnect:o,isConnected:!1,isReconnecting:!1,errorMessage:null}),[r,o]);return s.jsx(Cp.Provider,{value:a,children:t})}function ri(){const t=u.useContext(Cp);if(t===void 0)throw new Error("useActivityStream must be used within an ActivityStreamProvider");return t}function Rt(t,e){const{subscribe:n}=ri(),r=u.useRef(e);u.useEffect(()=>{r.current=e},[e]),u.useEffect(()=>t?n(t,a=>{r.current(a)}):void 0,[t,n])}const fo={status:"completed",provider:null,streamingId:null,startedAt:null,runVersion:null,segmentId:null,providerSessionId:null,transitionReason:null},vt={all:["session-status"],one:t=>["session-status",t]};function N2(t){const e=mn(),{connectionState:n}=ri(),r=u.useRef(n.status),o=(t||"").trim(),a=o.startsWith("conv-"),i=Mt({queryKey:vt.one(o),queryFn:async()=>{if(!a)return fo;const p=(await H.getSessionsStatus([o])).sessions[o]??fo;return console.debug(`[status:query] ${o.slice(0,12)} fetched=${p.status} sid=${p.streamingId?.slice(0,8)??"-"}`),p},enabled:a,refetchInterval:a?5e3:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0,staleTime:5e3});Rt({type:"activity"},d=>{if(!a)return;const p=d;p.sessionId===o&&(p.type==="session-started"||p.type==="session-ended"||p.type==="session-idle"||p.type==="current-work")&&e.invalidateQueries({queryKey:vt.one(o)})}),u.useEffect(()=>{if(!a)return;const d=r.current,p=n.status;r.current=p,p==="connected"&&d&&d!=="connected"&&(console.debug(`[DETAIL-TRACE] status-reconnect invalidating session-status for ${o?.slice(0,12)} (${d}→${p})`),e.invalidateQueries({queryKey:vt.one(o)}))},[n.status,a,o,e]);const l=d=>{a&&e.setQueryData(vt.one(o),{status:"ongoing",provider:d?.provider??"claude",streamingId:d?.streamingId??null,startedAt:new Date().toISOString(),runVersion:null,segmentId:null,providerSessionId:null,transitionReason:null})},c=()=>{if(!a)return;const d=e.getQueryData(vt.one(o));e.setQueryData(vt.one(o),{...fo,lastTurnUsage:d?.lastTurnUsage})};return{status:i.data?.status??"completed",provider:i.data?.provider??null,streamingId:i.data?.streamingId??null,startedAt:i.data?.startedAt??null,runVersion:i.data?.runVersion??null,segmentId:i.data?.segmentId??null,providerSessionId:i.data?.providerSessionId??null,transitionReason:i.data?.transitionReason??null,lastTurnUsage:i.data?.lastTurnUsage??null,isOngoing:i.data?.status==="ongoing",isIdle:i.data?.status==="idle",isCompleted:i.data?.status!=="ongoing"&&i.data?.status!=="idle",isFetching:i.isFetching,isLoading:i.isLoading,dataUpdatedAt:i.dataUpdatedAt,setOptimisticOngoing:l,setOptimisticCompleted:c}}const Ep=u.createContext(void 0),ht={all:["conversations"],list:(t,e)=>[...ht.all,"list",t,e],details:t=>[...ht.all,"details",t]};function On(t){return t[0]===ht.all[0]&&t[1]==="list"}const S2=3e4,C2=30*1e3,E2=3,T2=12,tl=6e4,sl=50;function I2(t,e){const n=e.now??Date.now(),r=e.limit??T2,o=[];for(const a of t){const{conversationId:i,identityImage:l}=a;if(!(l||!i.startsWith("conv-")||e.inFlight.has(i)||(e.retryAfterBySessionId.get(i)||0)>n)&&(o.push(i),o.length>=r))break}return o}function A2(t,e,n){let r=!1;const o=t.map(a=>a.conversationId!==e||a.identityImage?a:(r=!0,{...a,identityImage:n}));return r?o:t}function Tp(t,e){if(e.size===0)return t;let n=!1;const r=t.map(o=>{if(o.identityImage)return o;const a=e.get(o.conversationId);return a?(n=!0,{...o,identityImage:a}):o});return n?r:t}function R2(t){const{existing:e,incoming:n,pinnedOnly:r=!1,identityImageBySessionId:o=new Map}=t,a=r?n.filter(c=>c.pinned):n;if(a.length===0&&o.size===0)return e;const i=new Map(e.map(c=>[c.conversationId,c]));for(const c of a)i.set(c.conversationId,c);const l=Array.from(i.values());return l.sort((c,d)=>new Date(d.updatedAt).getTime()-new Date(c.updatedAt).getTime()),Tp(l,o)}function P2({children:t}){const e=mn(),n="main",[r,o]=u.useState({archived:!1}),[a,i]=u.useState(!1),l=Ie.useRef(Date.now()),[c,d]=u.useState({}),[p,m]=u.useState({}),h=u.useRef(!1),g=u.useRef(!1),[f,x]=u.useState(new Set),[b,y]=u.useState(new Map),[v,w]=u.useState(new Map),[N,S]=u.useState(new Set),T=u.useRef(new Map),C=u.useRef(new Set),j=u.useRef(new Map),E=u.useCallback((M,Y)=>{M.startsWith("conv-")&&m(U=>{if(U[M]?.status==="ongoing")return U;const ie=U[M];return{...U,[M]:{status:"ongoing",provider:Y??ie?.provider??null,streamingId:ie?.streamingId??null,startedAt:new Date().toISOString(),runVersion:ie?.runVersion??null,segmentId:ie?.segmentId??null,providerSessionId:ie?.providerSessionId??null,transitionReason:ie?.transitionReason??null}}})},[]),{connectionState:A}=ri(),L=u.useRef(A.status),$=u.useCallback(()=>{e.invalidateQueries({predicate:M=>On(M.queryKey)})},[e]),oe=u.useCallback(async()=>{await e.refetchQueries({predicate:M=>On(M.queryKey)})},[e]);u.useEffect(()=>{const M=L.current,Y=A.status;L.current=Y,Y==="connected"&&M&&M!=="connected"&&(At("ConversationsContext","reconnect-refetch",{prevStatus:M}),$())},[A.status,$]);const ne=u.useRef({lists:!1,sessionIds:new Set}),B=u.useRef(null),Q=u.useCallback(M=>{const{sessionId:Y,lists:U}=M||{};Y&&ne.current.sessionIds.add(Y),U&&(ne.current.lists=!0),B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{const{lists:ie,sessionIds:ye}=ne.current;ie&&$(),ye.forEach(he=>{e.invalidateQueries({queryKey:["insights",he]})}),ne.current={lists:!1,sessionIds:new Set},B.current=null},500)},[e,$]),q=u.useRef({}),Z=u.useRef(()=>{}),me=u.useCallback(M=>{const Y=M;switch(Y.type){case"session-started":{const{sessionId:U,streamingId:ie}=Y;if(!U||!U.startsWith("conv-"))break;console.debug(`[status:sse] session-started ${U.slice(0,12)} sid=${ie?.slice(0,8)??"-"}`),Z.current(),$();break}case"session-idle":{const{sessionId:U}=Y;if(!U||!U.startsWith("conv-"))break;console.debug(`[status:sse] session-idle ${U.slice(0,12)}`),Z.current(),$();break}case"insights-status":{const U=Y.timestamps||{};let ie=!1;for(const[ye,he]of Object.entries(U)){const ze=q.current[ye];ze&&he>ze&&(ie=!0)}q.current=U,ie&&$();break}case"active-sessions":{console.debug("[status:sse] active-sessions received, triggering refetch"),Z.current();break}case"activity":{const{sessionId:U,recentActions:ie}=Y;U&&ie&&Array.isArray(ie)&&d(ye=>{if(ie.length>0)return{...ye,[U]:ie};{const he={...ye};return delete he[U],he}});break}case"insights":{const{sessionId:U,conversationId:ie,identityImage:ye}=Y;if(!U&&!ie)break;const he=new Set;if(U&&he.add(U),ie&&he.add(ie),he.size===0)break;x(Ne=>{const Me=new Set(Ne);let nt=!1;return he.forEach(Ye=>{Me.delete(Ye)&&(nt=!0)}),nt?Me:Ne});const ze=new Date().toISOString();he.forEach(Ne=>{q.current[Ne]=ze}),he.forEach(Ne=>{e.setQueryData(["insights",Ne],Me=>Me&&{...Me,patchedAt:ze})}),ye&&(he.forEach(Ne=>{T.current.set(Ne,ye)}),e.setQueriesData({predicate:Ne=>On(Ne.queryKey)},Ne=>Ne?.conversations?{...Ne,conversations:Ne.conversations.map(Me=>he.has(Me.conversationId)?{...Me,identityImage:ye}:Me)}:Ne)),he.forEach(Ne=>{Q({sessionId:Ne})}),Q({lists:!0});break}case"session-ended":{const{sessionId:U,streamingId:ie}=Y;if(!U||!U.startsWith("conv-"))break;console.debug(`[status:sse] session-ended ${U.slice(0,12)} sid=${ie?.slice(0,8)??"-"}`),At("ConversationsContext","session-ended-received",{sessionId:U.slice(0,8),streamingId:ie?.slice(0,8)}),x(ye=>{const he=new Set(ye);return he.add(U),setTimeout(()=>{x(ze=>{if(!ze.has(U))return ze;const Ne=new Set(ze);return Ne.delete(U),Ne})},15e3),he}),S(ye=>{const he=new Set(ye);return he.add(U),he}),setTimeout(()=>{S(ye=>{if(!ye.has(U))return ye;const he=new Set(ye);return he.delete(U),he})},1e4),d(ye=>{const he={...ye};return delete he[U],he}),Z.current(),$();break}case"current-work":{const{sessionId:U}=Y;if(!U||!U.startsWith("conv-"))break;Z.current(),$();break}case"current-work-clear":{$();break}case"turn-captured":{$();break}}},[e,Q,$]);Rt({type:"activity"},me),u.useEffect(()=>()=>{B.current&&clearTimeout(B.current)},[]);const O=void 0,W=Ie.useMemo(()=>ht.list(n,r),[n,r]),{data:ee,isLoading:z,error:re}=Mt({queryKey:W,queryFn:async()=>{const M=await H.listUnifiedConversations({includeIdentityImage:!1,archived:r.archived,limit:sl}),Y=M.conversations.filter(ie=>!(r.pinned===!0&&!ie.pinned));return Y.sort((ie,ye)=>new Date(ye.updatedAt).getTime()-new Date(ie.updatedAt).getTime()),{conversations:Tp(Y,T.current),hasMore:!!M.hasMore,nextCursor:M.nextCursor??null,total:M.total}},placeholderData:M=>M}),se=Ie.useMemo(()=>ee?.conversations??[],[ee?.conversations]),te=ee?.hasMore??!1,xe=Ie.useMemo(()=>{const M=new Set(se.map(ie=>ie.conversationId)),Y=Array.from(b.values()).filter(ie=>!M.has(ie.conversationId));return[...Array.from(v.values()),...Y,...se]},[se,b,v]),_e=Ie.useMemo(()=>xe.map(M=>M.conversationId).filter(M=>M.startsWith("conv-")).sort(),[xe]),I=u.useCallback(async()=>{if(h.current){g.current=!0;return}h.current=!0;try{const M=await H.getSessionsStatus(_e.length>0?_e:void 0);m(M.sessions);for(const[Y,U]of Object.entries(M.sessions))e.setQueryData(vt.one(Y),U)}catch{}h.current=!1,g.current&&(g.current=!1,I())},[_e,e]),P=u.useCallback(()=>{I()},[I]);Z.current=P,u.useEffect(()=>{let M=null;const Y=()=>{M||(I(),M=setInterval(()=>{I()},5e3))},U=()=>{M&&(clearInterval(M),M=null)},ie=()=>{document.hidden?U():Y()};return document.hidden||Y(),document.addEventListener("visibilitychange",ie),()=>{U(),document.removeEventListener("visibilitychange",ie)}},[I]);const de=u.useMemo(()=>{const M=new Set;for(const[Y,U]of Object.entries(p))U.status==="ongoing"&&M.add(Y);return M},[p]),X=p;u.useEffect(()=>{const M=I2(xe,{inFlight:C.current,retryAfterBySessionId:j.current});if(M.length===0)return;const Y=[...M],U=Math.min(E2,Y.length);let ie=!1;const ye=async()=>{for(;!ie&&Y.length>0;){const he=Y.shift();if(!he)return;C.current.add(he);try{const Ne=(await H.getUnifiedConversationIdentityImage(he)).identityImage;if(!Ne){j.current.set(he,Date.now()+tl);continue}T.current.set(he,Ne),j.current.delete(he),e.setQueriesData({predicate:Me=>On(Me.queryKey)},Me=>{const nt=Me;if(!nt?.conversations)return Me;const Ye=A2(nt.conversations,he,Ne);return Ye===nt.conversations?Me:{...nt,conversations:Ye}})}catch{j.current.set(he,Date.now()+tl)}finally{C.current.delete(he)}}};return Promise.all(Array.from({length:U},()=>ye())),()=>{ie=!0}},[xe,e]),u.useEffect(()=>{if(b.size===0)return;const M=new Set(se.map(U=>U.conversationId)),Y=Array.from(b.keys()).filter(U=>M.has(U));Y.length>0&&y(U=>{const ie=new Map(U);return Y.forEach(ye=>ie.delete(ye)),ie})},[se,b]);const G=Ie.useMemo(()=>xe.map(M=>{const Y=X[M.conversationId];if(!Y)return M;const U=Y.status==="ongoing"?{streamingId:Y.streamingId||M.streamingId||void 0,currentStatus:"Claude Active",connectionState:"connected"}:void 0;return{...M,status:Y.status,latestProvider:Y.provider||M.latestProvider,streamingId:Y.streamingId??M.streamingId??null,liveStatus:U}}),[xe,X]),V=Ie.useMemo(()=>{const M={};return G.forEach(Y=>{const U=Y.workingDirectory;if(U){const ie=U.split("/"),ye=ie[ie.length-1]??U,he=M[U];(!he||new Date(Y.updatedAt)>new Date(he.lastDate))&&(M[U]={lastDate:Y.updatedAt,shortname:ye})}}),M},[G,O]),D=u.useRef(new Set);u.useEffect(()=>{const Y=Array.from(de).filter(U=>!D.current.has(U));Y.length!==0&&Y.forEach(U=>{D.current.add(U),e.prefetchQuery({queryKey:ht.details(U),queryFn:()=>H.getConversationDetails(U,{limit:50,timeout:1e4}),staleTime:3e4})})},[de,e]),u.useEffect(()=>{const M={},Y={};let U=[];const ie=async()=>{if(document.visibilityState!=="visible")return;const ze=xe.map(Ne=>Ne.conversationId);if(ze.length!==0)try{const{mtimes:Ne,insightMtimes:Me}=await H.unifiedActivityCheck(ze,M,U);let nt=!1;for(const[Ye,Ct]of Object.entries(Ne))M[Ye]!==void 0&&M[Ye]!==Ct&&(nt=!0),M[Ye]=Ct;if(Me)for(const[Ye,Ct]of Object.entries(Me))Y[Ye]!==void 0&&Y[Ye]!==Ct&&(nt=!0),Y[Ye]=Ct;nt&&$()}catch{}},ye=setInterval(()=>{ie()},S2),he=()=>{document.visibilityState==="visible"?Date.now()-l.current>C2&&$():l.current=Date.now()};return document.addEventListener("visibilitychange",he),()=>{clearInterval(ye),document.removeEventListener("visibilitychange",he)}},[xe,$]);const be=u.useCallback(async M=>{if(!a&&!(!ee?.hasMore||!ee.nextCursor)){i(!0);try{const Y=await H.listUnifiedConversations({includeIdentityImage:!1,archived:r.archived,limit:sl,cursor:ee.nextCursor});e.setQueryData(W,U=>{const ie=U?.conversations??[];return{conversations:R2({existing:ie,incoming:Y.conversations,pinnedOnly:r.pinned===!0,identityImageBySessionId:T.current}),hasMore:!!Y.hasMore,nextCursor:Y.nextCursor??null,total:Y.total}})}finally{i(!1)}}},[r.archived,r.pinned,W,a,e,ee?.hasMore,ee?.nextCursor]),Ce=u.useCallback(()=>G.length===0?null:[...G].sort((Y,U)=>new Date(U.updatedAt).getTime()-new Date(Y.updatedAt).getTime())[0]?.workingDirectory||null,[G]),je=u.useCallback(async()=>{await oe()},[oe]),Ee=u.useCallback(M=>{const Y=new Date().toISOString(),U={conversationId:M.conversationId,streamingId:M.streamingId,workingDirectory:M.workingDirectory,workspace:M.workspace,latestProvider:M.provider||"claude",providersUsed:[M.provider||"claude"],activeProvider:M.provider||"claude",segmentCount:1,customName:"",pinned:!1,archived:!1,pausedReason:null,importedAt:null,permissionMode:M.permissionMode,identityImage:null,initialPrompt:M.initialPrompt,createdAt:Y,updatedAt:Y,status:"ongoing",liveStatus:{streamingId:M.streamingId,currentStatus:"Thinking",connectionState:"connected"}};y(ye=>{const he=new Map(ye);return he.set(M.conversationId,U),he});const ie={status:"ongoing",provider:M.provider||"claude",streamingId:M.streamingId,startedAt:new Date().toISOString(),runVersion:null,segmentId:null,providerSessionId:null,transitionReason:null};m(ye=>({...ye,[M.conversationId]:ie})),e.setQueryData(vt.one(M.conversationId),{status:"ongoing",provider:M.provider||"claude",streamingId:M.streamingId,startedAt:Y,runVersion:null,segmentId:null,providerSessionId:null,transitionReason:null})},[e]),K=u.useCallback(M=>{const Y=new Date().toISOString(),U={conversationId:M.tempId,streamingId:null,workingDirectory:M.workingDirectory,workspace:M.workspace,latestProvider:M.provider,providersUsed:[M.provider],activeProvider:M.provider,segmentCount:0,customName:"",pinned:!1,archived:!1,pausedReason:null,importedAt:null,permissionMode:M.permissionMode,identityImage:null,initialPrompt:M.initialPrompt,createdAt:Y,updatedAt:Y,status:"pending",liveStatus:{streamingId:void 0,currentStatus:"Launching",connectionState:"connecting"}};w(ie=>{const ye=new Map(ie);return ye.set(M.tempId,U),ye})},[]),fe=u.useCallback(M=>{w(Y=>{const U=new Map(Y);return U.delete(M),U})},[]);return s.jsx(Ep.Provider,{value:{conversations:G,loading:z,loadingMore:a,hasMore:te,error:re?"Failed to load conversations":null,recentDirectories:V,activeFilters:r,setActiveFilters:o,loadMoreConversations:be,getMostRecentWorkingDirectory:Ce,invalidateConversations:je,addOptimisticSession:Ee,addPendingLaunch:K,removePendingLaunch:fe,recentActions:c,pendingInsightsUpdates:f,setSessionOptimisticOngoing:E,recentlyCompletedSessions:N},children:t})}function $s(){const t=u.useContext(Ep);if(t===void 0)throw new Error("useConversations must be used within a ConversationsProvider");return t}const Ip=u.createContext(void 0),M2={mode:"dark",colorScheme:"dark",toggle:()=>{}};function L2({children:t}){const[e,n]=u.useState(null),[r,o]=u.useState(null),[a,i]=u.useState(!1),[l,c]=u.useState(!0),[d,p]=u.useState(null);u.useEffect(()=>{(async()=>{try{c(!0);const f=await H.getConfig();n(f.interface??null),o(f.server??null),i(f.interface?.devMode===!0)}catch(f){p(f instanceof Error?f:new Error("Failed to load preferences"))}finally{c(!1)}})()},[]);const m=u.useCallback(async g=>{try{const f=await H.updateConfig({interface:g});n(f.interface??null)}catch(f){throw p(f instanceof Error?f:new Error("Failed to update preferences")),f}},[]),h=u.useCallback(g=>{o(g)},[]);return s.jsx(Ip.Provider,{value:{preferences:e,serverConfig:r,theme:M2,updatePreferences:m,setServerConfig:h,isLoading:l,error:d,devMode:a},children:t})}function zs(){const t=u.useContext(Ip);if(!t)throw new Error("usePreferencesContext must be used within a PreferencesProvider");return t}const Ap=u.createContext({isPro:!1,isLoading:!0,devOverride:null});function O2({children:t}){const[e]=xa(),n=e.get("tier"),{data:r,isLoading:o}=Mt({queryKey:["licenseStatus"],queryFn:()=>H.getLicenseStatus(),staleTime:6e4,refetchOnWindowFocus:!1,retry:!1,enabled:n===null}),a=u.useMemo(()=>n==="free"?{isPro:!1,isLoading:!1,devOverride:"free"}:n==="pro"?{isPro:!0,isLoading:!1,devOverride:"pro"}:{isPro:r?.isPro??!1,isLoading:o,devOverride:null},[n,r?.isPro,o]);return s.jsx(Ap.Provider,{value:a,children:t})}function yn(){return u.useContext(Ap)}function D2(t){const e="=".repeat((4-t.length%4)%4),n=(t+e).replace(/-/g,"+").replace(/_/g,"/"),r=window.atob(n),o=new Uint8Array(r.length);for(let a=0;a<r.length;++a)o[a]=r.charCodeAt(a);return o}function $2(){const t=navigator.userAgent||"";return/iPad|iPhone|iPod/i.test(t)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1}function z2(){const t=typeof window.matchMedia=="function"&&window.matchMedia("(display-mode: standalone)").matches,e=!!navigator.standalone;return t||e}function F2(){const[t,e]=u.useState({supported:!1,permission:"unsupported",subscribed:!1,loading:!0,publicKey:null,supportIssues:[]}),n=u.useCallback(async()=>{const i=[],l="serviceWorker"in navigator,c="PushManager"in window,d="Notification"in window,p=window.isSecureContext,m=$2(),h=z2();if(p||i.push("insecure-context"),m&&!h&&i.push("ios-home-screen-required"),(!l||!c||!d)&&i.push("missing-browser-apis"),!(i.length===0)){e({supported:!1,permission:"unsupported",subscribed:!1,loading:!1,publicKey:null,supportIssues:i});return}try{const f=await H.getWebPushStatus(),b=await(await navigator.serviceWorker.ready).pushManager.getSubscription();e({supported:!0,permission:Notification.permission,subscribed:!!b,loading:!1,publicKey:f.publicKey||null,supportIssues:[]})}catch{e(f=>({...f,supported:!0,loading:!1,supportIssues:[]}))}},[]);u.useEffect(()=>{n()},[n]);const r=u.useCallback(async()=>{if(!t.supported||!t.publicKey)return!1;e(i=>({...i,loading:!0}));try{const i=await Notification.requestPermission();if(i!=="granted")return e(d=>({...d,permission:i,loading:!1})),!1;const c=await(await navigator.serviceWorker.ready).pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:D2(t.publicKey)});return await H.registerWebPush(c),e(d=>({...d,permission:"granted",subscribed:!0,loading:!1})),!0}catch(i){return console.error("Push subscription failed:",i),e(l=>({...l,loading:!1})),!1}},[t.supported,t.publicKey]),o=u.useCallback(async()=>{e(i=>({...i,loading:!0}));try{const l=await(await navigator.serviceWorker.ready).pushManager.getSubscription();return l&&(await H.unregisterWebPush(l.endpoint),await l.unsubscribe()),e(c=>({...c,subscribed:!1,loading:!1})),!0}catch(i){return console.error("Push unsubscribe failed:",i),e(l=>({...l,loading:!1})),!1}},[]),a=u.useCallback(async()=>{try{return await H.sendTestNotification()}catch(i){return console.error("Test notification failed:",i),null}},[]);return{...t,subscribe:r,unsubscribe:o,sendTest:a,refresh:n}}function Fs(t){return JSON.parse(t)}function Rp(t){try{return Fs(t)}catch{return null}}async function zt(t,e){const n=new Headers(e?.headers);n.has("Content-Type")||n.set("Content-Type","application/json");const r=await fetch(t,{...e,headers:n}),o=await r.text(),a=o?Rp(o):null;if(!r.ok){const i=a&&typeof a=="object"&&a!==null&&"error"in a&&typeof a.error=="string"?a.error:`HTTP ${r.status}`;throw new Error(i)}return a}function V2(t){return t.replace(/\x1B\[[0-9;]*[A-Za-z]/g,"")}function B2(t,e){return t.length<=e?t:t.slice(t.length-e)}function U2(t){const e=t.match(/https?:\/\/\S+/);return e?e[0]:null}function G2(t){const e=t.match(/\b[A-Z0-9]{4}-[A-Z0-9]{5}\b/);return e?e[0]:null}function H2(){const[t,e]=u.useState(null),[n,r]=u.useState(null),[o,a]=u.useState(null),[i,l]=u.useState(null),[c,d]=u.useState(null),[p,m]=u.useState(""),[h,g]=u.useState(!1),[f,x]=u.useState(!1),[b,y]=u.useState(null),[v,w]=u.useState(""),[N,S]=u.useState(!1),T=u.useRef(null),C=u.useCallback(async()=>{a(null);try{const[W,ee]=await Promise.all([zt("/api/provider-auth/claude/status"),zt("/api/provider-auth/codex/status")]);e(W),r(ee)}catch(W){a(W instanceof Error?W.message:"Failed to load auth status")}},[]);u.useEffect(()=>(C(),()=>{T.current?.close()}),[C]);const j=u.useMemo(()=>!t||!t.available||!t.status||typeof t.status!="object"?!1:t.status.loggedIn===!0,[t]),E=u.useMemo(()=>{if(!t||!t.available||!t.status||typeof t.status!="object")return null;const W=t.status;return typeof W.authMethod=="string"?W.authMethod:null},[t]),A=u.useMemo(()=>U2(v),[v]),L=u.useMemo(()=>G2(v),[v]),$=u.useCallback(W=>{const ee=new EventSource(`/api/provider-auth/stream/${encodeURIComponent(W)}`);T.current?.close(),T.current=ee,y(W),S(!0),a(null),ee.onmessage=z=>{const re=typeof z.data=="string"?z.data:String(z.data??""),se=Rp(re);if(!se||typeof se!="object"||!("type"in se))return;const te=se;te.type==="log"&&w(xe=>B2(xe+V2(te.text),3e4)),te.type==="exit"&&(S(!1),ee.close(),C())},ee.onerror=()=>{S(!1),a("Auth stream disconnected"),ee.close()}},[C]),oe=u.useCallback(async()=>{a(null),x(!1),m("");try{const W=await zt("/api/provider-auth/claude/login",{method:"POST",body:JSON.stringify({})});l(W.sessionId),d(W.authorizeUrl)}catch(W){a(W instanceof Error?W.message:"Failed to start Claude login")}},[]),ne=u.useCallback(async()=>{if(!(!i||!p.trim())){g(!0),a(null);try{await zt("/api/provider-auth/claude/exchange",{method:"POST",body:JSON.stringify({sessionId:i,code:p.trim()})}),x(!0),l(null),d(null),m(""),C()}catch(W){a(W instanceof Error?W.message:"Failed to exchange code")}finally{g(!1)}}},[i,p,C]),B=u.useCallback(()=>{l(null),d(null),m(""),x(!1)},[]),Q=u.useCallback(async()=>{w("");const W=await zt("/api/provider-auth/codex/login",{method:"POST",body:JSON.stringify({})});$(W.sessionId)},[$]),q=u.useCallback(async W=>{if(W)try{await zt("/api/provider-auth/cancel/"+encodeURIComponent(W),{method:"POST",body:JSON.stringify({})})}catch{}},[]),Z=u.useCallback(async()=>{a(null);try{await zt("/api/provider-auth/claude/logout",{method:"POST",body:JSON.stringify({})}),C()}catch(W){a(W instanceof Error?W.message:"Failed to logout")}},[C]),me=u.useCallback(async()=>{a(null);try{await zt("/api/provider-auth/codex/logout",{method:"POST",body:JSON.stringify({})}),C()}catch(W){a(W instanceof Error?W.message:"Failed to logout")}},[C]),O=!!c;return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] text-muted-foreground font-display uppercase tracking-widest mb-2",children:"[PROVIDER_AUTH]"}),s.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:"These logins happen inside this workspace. Use this when you want to run Claude Code / Codex with your own plan, without API billing."})]}),s.jsxs("div",{className:"border border-border/50 rounded-sm p-3 bg-background/30 space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-xs font-display font-bold uppercase tracking-wider text-cyan-400",children:"CLAUDE"}),s.jsxs("p",{className:"text-[11px] font-mono text-muted-foreground",children:[t?.available===!1&&`Unavailable: ${t.error}`,t?.available===!0&&(j?`Logged in (${E||"unknown"})`:"Not logged in"),!t&&"Checking status..."]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[j?s.jsxs("button",{onClick:()=>{Z()},disabled:O,className:"flex items-center gap-2 px-3 py-2 rounded-sm bg-background border border-border/50 text-muted-foreground text-xs font-display uppercase tracking-wider hover:text-foreground hover:border-cyan-500/30 transition-all cursor-pointer disabled:opacity-50",children:[s.jsx(_i,{size:14}),s.jsx("span",{children:"Logout"})]}):s.jsxs("button",{onClick:()=>{oe()},disabled:O,className:"flex items-center gap-2 px-3 py-2 rounded-sm bg-background border border-cyan-500/30 text-cyan-400 text-xs font-display font-bold uppercase tracking-wider hover:border-cyan-400 hover:bg-cyan-500/5 hover:shadow-[1px_1px_0_rgba(0,255,255,0.4)] hover:translate-x-[-0.5px] hover:translate-y-[-0.5px] transition-all cursor-pointer disabled:opacity-50",children:[h?s.jsx(Re,{size:14,className:"animate-spin"}):s.jsx(wi,{size:14}),s.jsx("span",{children:O?"Connecting...":"Connect"})]}),O&&s.jsxs("button",{onClick:B,className:"flex items-center gap-2 px-3 py-2 rounded-sm bg-background border border-red-500/30 text-red-400 text-xs font-display uppercase tracking-wider hover:border-red-400 hover:bg-red-500/5 transition-all cursor-pointer",children:[s.jsx(bi,{size:14}),s.jsx("span",{children:"Cancel"})]})]})]}),f&&s.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-mono text-emerald-400",children:[s.jsx(Bn,{size:14}),s.jsx("span",{children:"Login successful! Credentials saved."})]}),c&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-[11px] font-mono text-muted-foreground",children:"1. Click the link below to authorize Claude Code:"}),s.jsxs("a",{href:c,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-2 text-[11px] font-mono text-cyan-400 hover:underline",children:[s.jsx(os,{size:12}),s.jsx("span",{children:"Open sign-in link"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-[11px] font-mono text-muted-foreground",children:"2. After authorizing, paste the code shown on the callback page:"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"text",value:p,onChange:W=>m(W.target.value),onKeyDown:W=>{W.key==="Enter"&&ne()},placeholder:"Paste authorization code here",disabled:h,className:"flex-1 text-[11px] font-mono bg-background border border-border/50 rounded-sm px-3 py-2 text-foreground placeholder:text-muted-foreground/50 focus:outline-none focus:border-cyan-500/50 disabled:opacity-50"}),s.jsx("button",{onClick:()=>{ne()},disabled:!p.trim()||h,className:"px-3 py-2 rounded-sm bg-cyan-500/10 border border-cyan-500/30 text-cyan-400 text-[11px] font-display uppercase tracking-wider hover:border-cyan-400 hover:bg-cyan-500/20 transition-all cursor-pointer disabled:opacity-50",children:h?s.jsx(Re,{size:14,className:"animate-spin"}):"Submit"})]})]})]})]}),s.jsxs("div",{className:"border border-border/50 rounded-sm p-3 bg-background/30 space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-xs font-display font-bold uppercase tracking-wider text-amber-400",children:"CODEX"}),s.jsxs("p",{className:"text-[11px] font-mono text-muted-foreground",children:[n?.available===!1&&`Unavailable: ${n.error}`,n?.available===!0&&(n.authenticated?"Logged in":"Not logged in"),!n&&"Checking status..."]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[n?.available===!0&&n.authenticated?s.jsxs("button",{onClick:()=>{me()},disabled:N,className:"flex items-center gap-2 px-3 py-2 rounded-sm bg-background border border-border/50 text-muted-foreground text-xs font-display uppercase tracking-wider hover:text-foreground hover:border-amber-500/30 transition-all cursor-pointer disabled:opacity-50",children:[s.jsx(_i,{size:14}),s.jsx("span",{children:"Logout"})]}):s.jsxs("button",{onClick:()=>{Q()},disabled:N,className:"flex items-center gap-2 px-3 py-2 rounded-sm bg-background border border-amber-500/30 text-amber-400 text-xs font-display font-bold uppercase tracking-wider hover:border-amber-400 hover:bg-amber-500/5 hover:shadow-[1px_1px_0_rgba(251,191,36,0.35)] hover:translate-x-[-0.5px] hover:translate-y-[-0.5px] transition-all cursor-pointer disabled:opacity-50",children:[N?s.jsx(Re,{size:14,className:"animate-spin"}):s.jsx(wi,{size:14}),s.jsx("span",{children:N?"Connecting...":"Connect"})]}),N&&s.jsxs("button",{onClick:()=>{q(b)},className:"flex items-center gap-2 px-3 py-2 rounded-sm bg-background border border-red-500/30 text-red-400 text-xs font-display uppercase tracking-wider hover:border-red-400 hover:bg-red-500/5 transition-all cursor-pointer",children:[s.jsx(bi,{size:14}),s.jsx("span",{children:"Cancel"})]})]})]}),(N||v)&&s.jsxs("div",{className:"space-y-2",children:[(A||L)&&s.jsxs("div",{className:"text-[11px] font-mono text-muted-foreground space-y-1",children:[A&&s.jsxs("a",{href:A,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-2 text-amber-400 hover:underline",children:[s.jsx(os,{size:12}),s.jsx("span",{children:"Open device auth"})]}),L&&s.jsxs("p",{children:["Code: ",s.jsx("span",{className:"text-amber-300",children:L})]})]}),s.jsx("pre",{className:"text-[11px] font-mono whitespace-pre-wrap break-words bg-background border border-border/50 rounded-sm p-3 max-h-48 overflow-auto",children:v||"..."})]})]}),o&&s.jsxs("p",{className:"text-xs font-mono text-red-400",children:["[ERROR] ",o]})]})}const q2=["claude-opus-4-7","claude-opus-4-6","claude-sonnet-4-5-20250929","claude-haiku-4-5-20251001"];function W2({isOpen:t,onClose:e}){const{serverConfig:n,setServerConfig:r}=zs(),[o,a]=u.useState(""),[i,l]=u.useState(""),[c,d]=u.useState(""),[p,m]=u.useState("claude"),[h,g]=u.useState("claude-opus-4-7"),[f,x]=u.useState(!1),[b,y]=u.useState(!1),[v,w]=u.useState(!1),[N,S]=u.useState(!1),[T,C]=u.useState(null),[j,E]=u.useState("credentials"),[A,L]=u.useState(null),[$,oe]=u.useState(null),[ne,B]=u.useState(!1),[Q,q]=u.useState(""),[Z,me]=u.useState(null),[O,W]=u.useState(!1),ee=F2(),z=typeof window<"u"?window.location.origin:"",re=z.includes("localhost")||z.includes("127.0.0.1"),se=n?.port||3001,te=`http://localhost:${se}`,xe=n?.tailscaleIp,_e=xe?`http://${xe}:${se}`:null,I=G=>{navigator.clipboard.writeText(G),L(G),setTimeout(()=>L(null),2e3)},P=u.useMemo(()=>{const G=c.split(`
|
|
150
|
+
`).length,V=c.length;return{lines:G,chars:V}},[c]);u.useEffect(()=>{t&&(H.getConfig().then(G=>{a(G.anthropic?.apiKey||""),l(G.gemini?.apiKey||""),d(G.server?.systemPrompt||""),m(G.server?.defaultProvider||"claude"),g(G.server?.defaultModel||"claude-opus-4-7"),q(G.license?.key||"")}).catch(G=>{console.error("Failed to load config:",G)}),H.getLicenseStatus().then(me).catch(()=>{me(null)}))},[t]);const de=async()=>{w(!0),C(null),S(!1);try{const G=await H.updateConfig({...Z?.plan==="partner"?{anthropic:{apiKey:o||void 0}}:{},gemini:{apiKey:i||void 0},server:{systemPrompt:c||void 0,defaultProvider:p,defaultModel:h||void 0},license:{key:Q||void 0}});r(G.server||null),S(!0),setTimeout(()=>{S(!1),e()},1500)}catch(G){C("Failed to save settings"),console.error("Failed to save config:",G)}finally{w(!1)}},X=u.useCallback(async()=>{W(!0),C(null);try{await H.updateConfig({license:{key:Q||void 0}});const G=await H.revalidateLicense();me(G)}catch{C("Failed to save license key")}finally{W(!1)}},[Q]);return t?s.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center sm:items-center",style:{paddingTop:"calc(env(safe-area-inset-top, 0px) + 1rem)",paddingRight:"calc(env(safe-area-inset-right, 0px) + 1rem)",paddingBottom:"calc(env(safe-area-inset-bottom, 0px) + 1rem)",paddingLeft:"calc(env(safe-area-inset-left, 0px) + 1rem)"},children:[s.jsx("button",{type:"button",className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:e,"aria-label":"Close settings dialog"}),s.jsxs("div",{className:"relative z-10 w-full max-w-2xl bg-card border border-border rounded-sm shadow-xl overflow-hidden max-h-[calc(100dvh-2rem)] sm:max-h-[90vh] flex flex-col",children:[s.jsx("div",{className:"absolute inset-0 bg-[linear-gradient(rgba(0,255,255,0.02)_1px,transparent_1px),linear-gradient(90deg,rgba(0,255,255,0.02)_1px,transparent_1px)] bg-[size:16px_16px] pointer-events-none"}),s.jsxs("div",{className:"relative px-4 py-3 border-b border-border/50 space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(Mo,{size:16,className:"text-cyan-400"}),s.jsx("span",{className:"font-mono text-sm font-bold text-cyan-400 tracking-wider",children:"CONFIG"})]}),s.jsx("button",{onClick:e,className:"shrink-0 p-1 rounded-sm text-muted-foreground hover:text-cyan-400 hover:bg-cyan-500/5 hover:shadow-[2px_2px_0_rgba(0,255,255,0.5),-2px_-2px_0_rgba(168,85,247,0.3)] hover:translate-x-[-1px] hover:translate-y-[-1px] transition-all duration-100 cursor-pointer",children:s.jsx(Be,{size:16})})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[s.jsx("button",{onClick:()=>E("credentials"),className:`px-3 py-1 text-xs font-display uppercase tracking-wider whitespace-nowrap rounded-sm transition-all cursor-pointer ${j==="credentials"?"bg-cyan-500/10 text-cyan-400 border border-cyan-500/30":"text-muted-foreground hover:text-foreground"}`,children:"API Keys"}),s.jsx("button",{onClick:()=>E("auth"),className:`px-3 py-1 text-xs font-display uppercase tracking-wider whitespace-nowrap rounded-sm transition-all cursor-pointer ${j==="auth"?"bg-cyan-500/10 text-cyan-400 border border-cyan-500/30":"text-muted-foreground hover:text-foreground"}`,children:"Auth"}),s.jsx("button",{onClick:()=>E("persona"),className:`px-3 py-1 text-xs font-display uppercase tracking-wider whitespace-nowrap rounded-sm transition-all cursor-pointer ${j==="persona"?"bg-purple-500/10 text-purple-400 border border-purple-500/30":"text-muted-foreground hover:text-foreground"}`,children:"Persona"}),s.jsx("button",{onClick:()=>E("connection"),className:`px-3 py-1 text-xs font-display uppercase tracking-wider whitespace-nowrap rounded-sm transition-all cursor-pointer ${j==="connection"?"bg-emerald-500/10 text-emerald-400 border border-emerald-500/30":"text-muted-foreground hover:text-foreground"}`,children:"Access"}),s.jsx("button",{onClick:()=>E("runtime"),className:`px-3 py-1 text-xs font-display uppercase tracking-wider whitespace-nowrap rounded-sm transition-all cursor-pointer ${j==="runtime"?"bg-blue-500/10 text-blue-400 border border-blue-500/30":"text-muted-foreground hover:text-foreground"}`,children:"Runtime"}),s.jsx("button",{onClick:()=>E("notifications"),className:`px-3 py-1 text-xs font-display uppercase tracking-wider whitespace-nowrap rounded-sm transition-all cursor-pointer ${j==="notifications"?"bg-amber-500/10 text-amber-400 border border-amber-500/30":"text-muted-foreground hover:text-foreground"}`,children:"Notify"}),s.jsx("button",{onClick:()=>E("license"),className:`px-3 py-1 text-xs font-display uppercase tracking-wider whitespace-nowrap rounded-sm transition-all cursor-pointer ${j==="license"?"bg-emerald-500/10 text-emerald-400 border border-emerald-500/30":"text-muted-foreground hover:text-foreground"}`,children:"License"})]})]}),s.jsxs("div",{className:"relative p-4 space-y-5 overflow-y-auto flex-1",children:[j==="credentials"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] text-muted-foreground font-display uppercase tracking-widest mb-2",children:"[API_CREDENTIALS]"}),s.jsxs("p",{className:"text-xs text-muted-foreground font-mono",children:["Local storage: ",s.jsx("code",{className:"px-1.5 py-0.5 bg-background rounded-sm text-cyan-400 border border-border/50",children:"local config file"})]})]}),Z?.plan==="partner"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{htmlFor:"settings-anthropic-key",className:"text-xs font-display font-bold text-foreground uppercase tracking-wider flex items-center gap-2",children:[s.jsx("span",{className:"text-cyan-400",children:"▸"})," ANTHROPIC_KEY",s.jsx("span",{className:"text-[10px] text-muted-foreground font-normal",children:"[REQUIRED FOR PARTNER]"})]}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{id:"settings-anthropic-key",type:f?"text":"password",value:o,onChange:G=>a(G.target.value),placeholder:"sk-ant-...",className:"w-full px-3 py-2 pr-10 bg-background border border-border rounded-sm text-sm font-mono text-foreground placeholder:text-muted-foreground focus:outline-none focus:border-cyan-500/50 focus:shadow-[0_0_10px_rgba(0,255,255,0.1)]"}),s.jsx("button",{type:"button",onClick:()=>x(!f),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 text-muted-foreground hover:text-cyan-400 transition-colors cursor-pointer",children:f?s.jsx(yi,{size:14}):s.jsx(Ro,{size:14})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{htmlFor:"settings-gemini-key",className:"text-xs font-display font-bold text-foreground uppercase tracking-wider flex items-center gap-2",children:[s.jsx("span",{className:"text-amber-400",children:"▸"})," GOOGLE_KEY",s.jsx("span",{className:"text-[10px] text-muted-foreground font-normal",children:"[OPTIONAL]"})]}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{id:"settings-gemini-key",type:b?"text":"password",value:i,onChange:G=>l(G.target.value),placeholder:"AIza...",className:"w-full px-3 py-2 pr-10 bg-background border border-border rounded-sm text-sm font-mono text-foreground placeholder:text-muted-foreground focus:outline-none focus:border-amber-500/50 focus:shadow-[0_0_10px_rgba(245,158,11,0.1)]"}),s.jsx("button",{type:"button",onClick:()=>y(!b),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 text-muted-foreground hover:text-amber-400 transition-colors cursor-pointer",children:b?s.jsx(yi,{size:14}):s.jsx(Ro,{size:14})})]})]}),s.jsxs("div",{className:"border-t border-border/30 pt-4",children:[s.jsx("p",{className:"text-[10px] text-muted-foreground font-display uppercase tracking-widest mb-3",children:"[DIAGNOSTICS]"}),s.jsxs("button",{onClick:()=>H.exportLogs(10),className:"flex items-center gap-2 px-3 py-2 rounded-sm bg-background border border-border/50 text-sm font-mono text-muted-foreground hover:text-foreground hover:border-cyan-500/30 transition-colors cursor-pointer",children:[s.jsx(Ao,{size:14}),s.jsx("span",{children:"Export diagnostics (last 10 min)"})]}),s.jsx("p",{className:"text-[10px] text-muted-foreground/60 font-mono mt-1.5",children:"Downloads structured server, daemon, events, permissions, and browser incidents"})]})]}),j==="persona"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] text-muted-foreground font-display uppercase tracking-widest mb-2",children:"[CLAUDE_PERSONA]"}),s.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:"Define how Claude should behave across all sessions. This becomes the system prompt."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("label",{htmlFor:"settings-persona",className:"text-xs font-display font-bold text-foreground uppercase tracking-wider flex items-center gap-2",children:[s.jsx(Jl,{size:12,className:"text-purple-400"}),s.jsx("span",{className:"text-purple-400",children:"▸"})," PERSONA"]}),s.jsxs("span",{className:"text-[10px] text-muted-foreground font-mono",children:[P.lines," lines · ",P.chars," chars"]})]}),s.jsx("textarea",{id:"settings-persona",value:c,onChange:G=>d(G.target.value),placeholder:`## Collaboration Model
|
|
151
151
|
|
|
152
152
|
You are a peer collaborator, not an assistant...
|
|
153
153
|
|
|
@@ -155,7 +155,7 @@ You are a peer collaborator, not an assistant...
|
|
|
155
155
|
- Verify before claiming...
|
|
156
156
|
|
|
157
157
|
**Communication:**
|
|
158
|
-
- Be direct and information-dense...`,rows:16,className:"w-full px-3 py-2 bg-background border border-border rounded-sm text-sm font-mono text-foreground placeholder:text-muted-foreground/40 focus:outline-none focus:border-purple-500/50 focus:shadow-[0_0_10px_rgba(168,85,247,0.1)] resize-y min-h-[300px]"}),s.jsx("div",{className:"flex items-start justify-between gap-4",children:s.jsxs("p",{className:"text-[10px] text-muted-foreground/60 font-mono flex-1",children:["Supports markdown. Defines personality, communication style, epistemic standards, and working preferences. Applied to all new sessions via ",s.jsx("code",{className:"text-purple-400",children:"--system-prompt"}),"."]})})]}),s.jsxs("div",{className:"border border-purple-500/20 rounded-sm p-3 bg-purple-500/5",children:[s.jsx("p",{className:"text-[10px] text-purple-400 font-display uppercase tracking-widest mb-2",children:"Tips"}),s.jsxs("ul",{className:"text-xs text-muted-foreground font-mono space-y-1",children:[s.jsxs("li",{children:["• Use ",s.jsx("code",{className:"text-purple-400",children:"##"})," headers to organize sections"]}),s.jsx("li",{children:"• Be explicit - Claude 4.x follows instructions literally"}),s.jsx("li",{children:"• Include both what TO do and HOW to do it"}),s.jsx("li",{children:"• Changes apply to new sessions only"})]})]})]}),j==="connection"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] text-muted-foreground font-display uppercase tracking-widest mb-2",children:"[ACCESS_URLS]"}),s.jsxs("p",{className:"text-xs text-muted-foreground font-mono",children:["Access Lattice from different networks. Currently accessing via: ",s.jsx("code",{className:"px-1.5 py-0.5 bg-background rounded-sm text-emerald-400 border border-border/50",children:se?"localhost":"remote"})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(rf,{size:14,className:"text-emerald-400"}),s.jsx("span",{className:"text-xs font-display font-bold text-foreground uppercase tracking-wider",children:"Current URL"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"flex-1 px-3 py-2 bg-background border border-emerald-500/30 rounded-sm text-sm font-mono text-emerald-400",children:F}),s.jsx("button",{onClick:()=>A(F),className:"p-2 rounded-sm text-muted-foreground hover:text-emerald-400 hover:bg-emerald-500/10 transition-colors cursor-pointer",children:R===F?s.jsx(Bn,{size:16,className:"text-emerald-400"}):s.jsx(Vt,{size:16})})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-xs font-display font-bold text-foreground uppercase tracking-wider",children:[s.jsx("span",{className:"text-cyan-400",children:"▸"})," Local Access"]}),se&&s.jsx("span",{className:"text-[10px] text-emerald-400 font-mono",children:"(current)"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"flex-1 px-3 py-2 bg-background border border-border/50 rounded-sm text-sm font-mono text-foreground",children:te}),s.jsx("button",{onClick:()=>A(te),className:"p-2 rounded-sm text-muted-foreground hover:text-cyan-400 hover:bg-cyan-500/10 transition-colors cursor-pointer",children:R===te?s.jsx(Bn,{size:16,className:"text-emerald-400"}):s.jsx(Vt,{size:16})})]}),s.jsx("p",{className:"text-[10px] text-muted-foreground/60 font-mono",children:"Use when on the same machine as the Lattice server"})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-xs font-display font-bold text-foreground uppercase tracking-wider",children:[s.jsx("span",{className:"text-amber-400",children:"▸"})," Remote Access (Tailscale)"]}),!se&&s.jsx("span",{className:"text-[10px] text-emerald-400 font-mono",children:"(current)"})]}),_e?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"flex-1 px-3 py-2 bg-background border border-border/50 rounded-sm text-sm font-mono text-foreground",children:_e}),s.jsx("button",{onClick:()=>A(_e),className:"p-2 rounded-sm text-muted-foreground hover:text-amber-400 hover:bg-amber-500/10 transition-colors cursor-pointer",children:R===_e?s.jsx(Bn,{size:16,className:"text-emerald-400"}):s.jsx(Vt,{size:16})})]}),s.jsx("p",{className:"text-[10px] text-muted-foreground/60 font-mono",children:"Use when accessing from another device on your Tailscale network"})]}):s.jsx("p",{className:"text-[10px] text-muted-foreground/60 font-mono",children:"Tailscale not detected. Install Tailscale or check that the daemon is running."})]}),s.jsxs("div",{className:"border border-emerald-500/20 rounded-sm p-3 bg-emerald-500/5",children:[s.jsx("p",{className:"text-[10px] text-emerald-400 font-display uppercase tracking-widest mb-2",children:"Quick Tips"}),s.jsxs("ul",{className:"text-xs text-muted-foreground font-mono space-y-1",children:[s.jsxs("li",{children:["• ",s.jsx("code",{className:"text-emerald-400",children:"localhost"})," only works on the server machine"]}),s.jsx("li",{children:"• Session links use relative paths - just swap the hostname"}),s.jsxs("li",{children:["• Prototypes: append ",s.jsx("code",{className:"text-emerald-400",children:"/prototype/[name]"})," to any base URL"]})]})]})]}),j==="auth"&&s.jsx(H2,{}),j==="runtime"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] text-muted-foreground font-display uppercase tracking-widest mb-2",children:"[RUNTIME_DEFAULTS]"}),s.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:"Global defaults applied when a model is not explicitly selected in the composer."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{htmlFor:"settings-default-provider",className:"text-xs font-display font-bold text-foreground uppercase tracking-wider flex items-center gap-2",children:[s.jsx("span",{className:"text-emerald-400",children:"▸"})," DEFAULT_PROVIDER"]}),s.jsx("select",{id:"settings-default-provider",value:p,onChange:()=>m("claude"),className:"w-full px-3 py-2 bg-background border border-border rounded-sm text-sm font-mono text-foreground focus:outline-none focus:border-emerald-500/50 focus:shadow-[0_0_10px_rgba(16,185,129,0.1)]",children:s.jsx("option",{value:"claude",children:"claude"})}),s.jsx("p",{className:"text-[10px] text-muted-foreground/60 font-mono",children:"Used as the initial provider in unified conversations when no session-specific provider has been chosen yet."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{htmlFor:"settings-default-claude-model",className:"text-xs font-display font-bold text-foreground uppercase tracking-wider flex items-center gap-2",children:[s.jsx("span",{className:"text-blue-400",children:"▸"})," CLAUDE_DEFAULT_MODEL"]}),s.jsx("select",{id:"settings-default-claude-model",value:h,onChange:H=>g(H.target.value),className:"w-full px-3 py-2 bg-background border border-border rounded-sm text-sm font-mono text-foreground focus:outline-none focus:border-blue-500/50 focus:shadow-[0_0_10px_rgba(59,130,246,0.1)]",children:q2.map(H=>s.jsx("option",{value:H,children:H},H))}),s.jsx("p",{className:"text-[10px] text-muted-foreground/60 font-mono",children:"Used for new sessions and resumed Claude turns when no model is specified."})]})]}),j==="notifications"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] text-muted-foreground font-display uppercase tracking-widest mb-2",children:"[PUSH_NOTIFICATIONS]"}),s.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:"Get notified when sessions complete or need attention. Works on mobile and desktop."})]}),Z.supported?Z.publicKey?s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[Z.subscribed?s.jsx(Gr,{size:16,className:"text-amber-400"}):s.jsx(xi,{size:16,className:"text-muted-foreground/50"}),s.jsx("span",{className:"text-sm font-mono text-foreground",children:Z.subscribed?"Notifications enabled":"Notifications disabled"}),Z.permission==="denied"&&s.jsx("span",{className:"text-[10px] text-red-400 font-mono",children:"(blocked by browser — check site permissions)"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[Z.subscribed?s.jsxs("button",{onClick:()=>{Z.unsubscribe()},disabled:Z.loading,className:"flex items-center gap-2 px-4 py-2 rounded-sm bg-background border border-red-500/30 text-red-400 text-xs font-display font-bold uppercase tracking-wider hover:border-red-400 hover:bg-red-500/5 transition-all cursor-pointer disabled:opacity-50",children:[Z.loading?s.jsx(Ae,{size:14,className:"animate-spin"}):s.jsx(xi,{size:14}),s.jsx("span",{children:"Disable"})]}):s.jsxs("button",{onClick:()=>{Z.subscribe()},disabled:Z.loading||Z.permission==="denied",className:"flex items-center gap-2 px-4 py-2 rounded-sm bg-background border border-amber-500/30 text-amber-400 text-xs font-display font-bold uppercase tracking-wider hover:border-amber-400 hover:bg-amber-500/5 hover:shadow-[1px_1px_0_rgba(251,191,36,0.4)] hover:translate-x-[-0.5px] hover:translate-y-[-0.5px] transition-all cursor-pointer disabled:opacity-50",children:[Z.loading?s.jsx(Ae,{size:14,className:"animate-spin"}):s.jsx(Gr,{size:14}),s.jsx("span",{children:"Enable Notifications"})]}),Z.subscribed&&s.jsx("button",{onClick:async()=>{re(null);const H=await Z.sendTest();re(H?`Sent: ${H.sent}, Failed: ${H.failed}`:"Test failed"),setTimeout(()=>re(null),3e3)},className:"flex items-center gap-2 px-3 py-2 rounded-sm bg-background border border-border/50 text-muted-foreground text-xs font-display uppercase tracking-wider hover:text-foreground hover:border-amber-500/30 transition-all cursor-pointer",children:s.jsx("span",{children:"Test"})})]}),$&&s.jsx("p",{className:"text-xs font-mono text-amber-400",children:$}),s.jsxs("div",{className:"border border-amber-500/20 rounded-sm p-3 bg-amber-500/5",children:[s.jsx("p",{className:"text-[10px] text-amber-400 font-display uppercase tracking-widest mb-2",children:"What you'll get notified about"}),s.jsxs("ul",{className:"text-xs text-muted-foreground font-mono space-y-1",children:[s.jsx("li",{children:"• Session completes (task finished)"}),s.jsx("li",{children:"• Permission requests (Claude needs approval)"}),s.jsx("li",{children:"• Works on mobile PWA and desktop browsers"})]})]})]}):s.jsxs("div",{className:"border border-amber-500/20 rounded-sm p-3 bg-amber-500/5 space-y-3",children:[s.jsx("p",{className:"text-xs text-amber-400 font-mono",children:"Push notifications are not configured on the server yet."}),s.jsxs("button",{onClick:async()=>{V(!0),C(null);try{await G.updateConfig({interface:{notifications:{enabled:!0}}}),await Z.refresh()}catch(H){C("Failed to enable notifications"),console.error("Failed to enable notifications:",H)}finally{V(!1)}},disabled:ne,className:"flex items-center gap-2 px-4 py-2 rounded-sm bg-background border border-amber-500/30 text-amber-400 text-xs font-display font-bold uppercase tracking-wider hover:border-amber-400 hover:bg-amber-500/5 transition-all cursor-pointer disabled:opacity-50",children:[ne?s.jsx(Ae,{size:14,className:"animate-spin"}):s.jsx(Gr,{size:14}),s.jsx("span",{children:ne?"Enabling...":"Enable On Server"})]}),s.jsx("p",{className:"text-[10px] text-muted-foreground font-mono",children:"This creates VAPID keys automatically and unlocks browser subscription."})]}):s.jsxs("div",{className:"border border-amber-500/20 rounded-sm p-3 bg-amber-500/5",children:[s.jsx("p",{className:"text-xs text-amber-400 font-mono mb-2",children:"Push notifications are unavailable in this browsing context."}),s.jsxs("ul",{className:"text-[11px] text-amber-300/90 font-mono space-y-1",children:[Z.supportIssues.includes("ios-home-screen-required")&&s.jsx("li",{children:"• iOS requirement: open Lattice as an installed Home Screen app (`Share` → `Add to Home Screen`) and enable notifications from that app."}),Z.supportIssues.includes("insecure-context")&&s.jsxs("li",{children:["• Secure context required: notifications need HTTPS (or localhost). Current origin: ",s.jsx("span",{className:"text-amber-200",children:F})]}),Z.supportIssues.includes("missing-browser-apis")&&s.jsx("li",{children:"• This browser/runtime does not expose all required push APIs (`ServiceWorker`, `PushManager`, `Notification`)."}),Z.supportIssues.length===0&&s.jsx("li",{children:"• Browser push APIs are unavailable right now."})]})]})]}),j==="license"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] text-muted-foreground font-display uppercase tracking-widest mb-2",children:"[LICENSE]"}),s.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:"Enter your Pro license key to unlock insights, reviews, turn capture, and thread tagging."})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`w-2 h-2 rounded-full ${K?.isPro?"bg-emerald-400 shadow-[0_0_8px_rgba(52,211,153,0.5)]":"bg-stone-600"}`}),s.jsx("span",{className:"text-sm font-mono text-foreground",children:K?.isPro?`Pro — ${K.plan}`:K?.error?`Invalid — ${K.error}`:"No license"}),K?.lastValidatedAt&&s.jsxs("span",{className:"text-[10px] text-muted-foreground/60 font-mono",children:["checked ",new Date(K.lastValidatedAt).toLocaleDateString()]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{htmlFor:"settings-license-key",className:"text-xs font-display font-bold text-foreground uppercase tracking-wider flex items-center gap-2",children:[s.jsx(pf,{size:12,className:"text-emerald-400"}),s.jsx("span",{className:"text-emerald-400",children:"▸"})," LICENSE_KEY"]}),s.jsx("input",{id:"settings-license-key",type:"text",value:X,onChange:H=>q(H.target.value),placeholder:"LATTICE-PRO-...",className:"w-full px-3 py-2 bg-background border border-border rounded-sm text-sm font-mono text-foreground placeholder:text-muted-foreground focus:outline-none focus:border-emerald-500/50 focus:shadow-[0_0_10px_rgba(52,211,153,0.1)]"})]}),s.jsx("div",{className:"flex items-center gap-3",children:s.jsxs("button",{onClick:J,disabled:D,className:"flex items-center gap-2 px-4 py-2 rounded-sm bg-background border border-emerald-500/30 text-emerald-400 text-xs font-display font-bold uppercase tracking-wider hover:border-emerald-400 hover:bg-emerald-500/5 transition-all cursor-pointer disabled:opacity-50",children:[D?s.jsx(Ae,{size:14,className:"animate-spin"}):s.jsx(ds,{size:14}),s.jsx("span",{children:D?"Validating...":"Save & Validate"})]})}),s.jsxs("div",{className:"border border-emerald-500/20 rounded-sm p-3 bg-emerald-500/5",children:[s.jsx("p",{className:"text-[10px] text-emerald-400 font-display uppercase tracking-widest mb-2",children:"Get a License"}),s.jsx("p",{className:"text-xs text-muted-foreground font-mono mb-2",children:"Subscribe at lattice.cc to get your license key. Copy it from the dashboard and paste it above."}),s.jsxs("a",{href:"https://lattice.cc/dashboard/license",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-xs font-mono text-emerald-400 hover:text-emerald-300 transition-colors",children:[s.jsx(os,{size:12}),"lattice.cc/dashboard/license"]})]})]}),T&&s.jsxs("p",{className:"text-xs font-mono text-red-400",children:["[ERROR] ",T]})]}),s.jsxs("div",{className:"relative px-4 py-3 border-t border-border/50 flex items-center justify-end gap-3",children:[s.jsx("button",{onClick:e,className:"px-3 py-1.5 text-xs font-display text-muted-foreground hover:text-foreground transition-colors cursor-pointer uppercase tracking-wider",children:"CANCEL"}),s.jsx("button",{onClick:le,disabled:v,className:"flex items-center gap-2 px-4 py-1.5 rounded-sm bg-background/80 backdrop-blur-sm border border-cyan-500/30 text-cyan-400 text-xs font-display font-bold uppercase tracking-wider hover:border-cyan-400 hover:bg-cyan-500/5 hover:shadow-[2px_2px_0_rgba(0,255,255,0.5),-2px_-2px_0_rgba(168,85,247,0.3)] hover:translate-x-[-1px] hover:translate-y-[-1px] transition-all duration-100 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:shadow-none disabled:hover:translate-x-0 disabled:hover:translate-y-0",children:v?s.jsx(Ae,{size:14,className:"animate-spin"}):N?s.jsxs(s.Fragment,{children:[s.jsx(Oe,{size:14}),s.jsx("span",{children:"SAVED"})]}):s.jsxs(s.Fragment,{children:[s.jsx(Oe,{size:14}),s.jsx("span",{children:"SAVE"})]})})]})]})]}):null}function K2(t){let e=t.split(`
|
|
158
|
+
- Be direct and information-dense...`,rows:16,className:"w-full px-3 py-2 bg-background border border-border rounded-sm text-sm font-mono text-foreground placeholder:text-muted-foreground/40 focus:outline-none focus:border-purple-500/50 focus:shadow-[0_0_10px_rgba(168,85,247,0.1)] resize-y min-h-[300px]"}),s.jsx("div",{className:"flex items-start justify-between gap-4",children:s.jsxs("p",{className:"text-[10px] text-muted-foreground/60 font-mono flex-1",children:["Supports markdown. Defines personality, communication style, epistemic standards, and working preferences. Applied to all new sessions via ",s.jsx("code",{className:"text-purple-400",children:"--system-prompt"}),"."]})})]}),s.jsxs("div",{className:"border border-purple-500/20 rounded-sm p-3 bg-purple-500/5",children:[s.jsx("p",{className:"text-[10px] text-purple-400 font-display uppercase tracking-widest mb-2",children:"Tips"}),s.jsxs("ul",{className:"text-xs text-muted-foreground font-mono space-y-1",children:[s.jsxs("li",{children:["• Use ",s.jsx("code",{className:"text-purple-400",children:"##"})," headers to organize sections"]}),s.jsx("li",{children:"• Be explicit - Claude 4.x follows instructions literally"}),s.jsx("li",{children:"• Include both what TO do and HOW to do it"}),s.jsx("li",{children:"• Changes apply to new sessions only"})]})]})]}),j==="connection"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] text-muted-foreground font-display uppercase tracking-widest mb-2",children:"[ACCESS_URLS]"}),s.jsxs("p",{className:"text-xs text-muted-foreground font-mono",children:["Access Lattice from different networks. Currently accessing via: ",s.jsx("code",{className:"px-1.5 py-0.5 bg-background rounded-sm text-emerald-400 border border-border/50",children:re?"localhost":"remote"})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(rf,{size:14,className:"text-emerald-400"}),s.jsx("span",{className:"text-xs font-display font-bold text-foreground uppercase tracking-wider",children:"Current URL"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"flex-1 px-3 py-2 bg-background border border-emerald-500/30 rounded-sm text-sm font-mono text-emerald-400",children:z}),s.jsx("button",{onClick:()=>I(z),className:"p-2 rounded-sm text-muted-foreground hover:text-emerald-400 hover:bg-emerald-500/10 transition-colors cursor-pointer",children:A===z?s.jsx(Bn,{size:16,className:"text-emerald-400"}):s.jsx(Vt,{size:16})})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-xs font-display font-bold text-foreground uppercase tracking-wider",children:[s.jsx("span",{className:"text-cyan-400",children:"▸"})," Local Access"]}),re&&s.jsx("span",{className:"text-[10px] text-emerald-400 font-mono",children:"(current)"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"flex-1 px-3 py-2 bg-background border border-border/50 rounded-sm text-sm font-mono text-foreground",children:te}),s.jsx("button",{onClick:()=>I(te),className:"p-2 rounded-sm text-muted-foreground hover:text-cyan-400 hover:bg-cyan-500/10 transition-colors cursor-pointer",children:A===te?s.jsx(Bn,{size:16,className:"text-emerald-400"}):s.jsx(Vt,{size:16})})]}),s.jsx("p",{className:"text-[10px] text-muted-foreground/60 font-mono",children:"Use when on the same machine as the Lattice server"})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-xs font-display font-bold text-foreground uppercase tracking-wider",children:[s.jsx("span",{className:"text-amber-400",children:"▸"})," Remote Access (Tailscale)"]}),!re&&s.jsx("span",{className:"text-[10px] text-emerald-400 font-mono",children:"(current)"})]}),_e?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"flex-1 px-3 py-2 bg-background border border-border/50 rounded-sm text-sm font-mono text-foreground",children:_e}),s.jsx("button",{onClick:()=>I(_e),className:"p-2 rounded-sm text-muted-foreground hover:text-amber-400 hover:bg-amber-500/10 transition-colors cursor-pointer",children:A===_e?s.jsx(Bn,{size:16,className:"text-emerald-400"}):s.jsx(Vt,{size:16})})]}),s.jsx("p",{className:"text-[10px] text-muted-foreground/60 font-mono",children:"Use when accessing from another device on your Tailscale network"})]}):s.jsx("p",{className:"text-[10px] text-muted-foreground/60 font-mono",children:"Tailscale not detected. Install Tailscale or check that the daemon is running."})]}),s.jsxs("div",{className:"border border-emerald-500/20 rounded-sm p-3 bg-emerald-500/5",children:[s.jsx("p",{className:"text-[10px] text-emerald-400 font-display uppercase tracking-widest mb-2",children:"Quick Tips"}),s.jsxs("ul",{className:"text-xs text-muted-foreground font-mono space-y-1",children:[s.jsxs("li",{children:["• ",s.jsx("code",{className:"text-emerald-400",children:"localhost"})," only works on the server machine"]}),s.jsx("li",{children:"• Session links use relative paths - just swap the hostname"}),s.jsxs("li",{children:["• Prototypes: append ",s.jsx("code",{className:"text-emerald-400",children:"/prototype/[name]"})," to any base URL"]})]})]})]}),j==="auth"&&s.jsx(H2,{}),j==="runtime"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] text-muted-foreground font-display uppercase tracking-widest mb-2",children:"[RUNTIME_DEFAULTS]"}),s.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:"Global defaults applied when a model is not explicitly selected in the composer."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{htmlFor:"settings-default-provider",className:"text-xs font-display font-bold text-foreground uppercase tracking-wider flex items-center gap-2",children:[s.jsx("span",{className:"text-emerald-400",children:"▸"})," DEFAULT_PROVIDER"]}),s.jsx("select",{id:"settings-default-provider",value:p,onChange:()=>m("claude"),className:"w-full px-3 py-2 bg-background border border-border rounded-sm text-sm font-mono text-foreground focus:outline-none focus:border-emerald-500/50 focus:shadow-[0_0_10px_rgba(16,185,129,0.1)]",children:s.jsx("option",{value:"claude",children:"claude"})}),s.jsx("p",{className:"text-[10px] text-muted-foreground/60 font-mono",children:"Used as the initial provider in unified conversations when no session-specific provider has been chosen yet."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{htmlFor:"settings-default-claude-model",className:"text-xs font-display font-bold text-foreground uppercase tracking-wider flex items-center gap-2",children:[s.jsx("span",{className:"text-blue-400",children:"▸"})," CLAUDE_DEFAULT_MODEL"]}),s.jsx("select",{id:"settings-default-claude-model",value:h,onChange:G=>g(G.target.value),className:"w-full px-3 py-2 bg-background border border-border rounded-sm text-sm font-mono text-foreground focus:outline-none focus:border-blue-500/50 focus:shadow-[0_0_10px_rgba(59,130,246,0.1)]",children:q2.map(G=>s.jsx("option",{value:G,children:G},G))}),s.jsx("p",{className:"text-[10px] text-muted-foreground/60 font-mono",children:"Used for new sessions and resumed Claude turns when no model is specified."})]})]}),j==="notifications"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] text-muted-foreground font-display uppercase tracking-widest mb-2",children:"[PUSH_NOTIFICATIONS]"}),s.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:"Get notified when sessions complete or need attention. Works on mobile and desktop."})]}),ee.supported?ee.publicKey?s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[ee.subscribed?s.jsx(Gr,{size:16,className:"text-amber-400"}):s.jsx(xi,{size:16,className:"text-muted-foreground/50"}),s.jsx("span",{className:"text-sm font-mono text-foreground",children:ee.subscribed?"Notifications enabled":"Notifications disabled"}),ee.permission==="denied"&&s.jsx("span",{className:"text-[10px] text-red-400 font-mono",children:"(blocked by browser — check site permissions)"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[ee.subscribed?s.jsxs("button",{onClick:()=>{ee.unsubscribe()},disabled:ee.loading,className:"flex items-center gap-2 px-4 py-2 rounded-sm bg-background border border-red-500/30 text-red-400 text-xs font-display font-bold uppercase tracking-wider hover:border-red-400 hover:bg-red-500/5 transition-all cursor-pointer disabled:opacity-50",children:[ee.loading?s.jsx(Re,{size:14,className:"animate-spin"}):s.jsx(xi,{size:14}),s.jsx("span",{children:"Disable"})]}):s.jsxs("button",{onClick:()=>{ee.subscribe()},disabled:ee.loading||ee.permission==="denied",className:"flex items-center gap-2 px-4 py-2 rounded-sm bg-background border border-amber-500/30 text-amber-400 text-xs font-display font-bold uppercase tracking-wider hover:border-amber-400 hover:bg-amber-500/5 hover:shadow-[1px_1px_0_rgba(251,191,36,0.4)] hover:translate-x-[-0.5px] hover:translate-y-[-0.5px] transition-all cursor-pointer disabled:opacity-50",children:[ee.loading?s.jsx(Re,{size:14,className:"animate-spin"}):s.jsx(Gr,{size:14}),s.jsx("span",{children:"Enable Notifications"})]}),ee.subscribed&&s.jsx("button",{onClick:async()=>{oe(null);const G=await ee.sendTest();oe(G?`Sent: ${G.sent}, Failed: ${G.failed}`:"Test failed"),setTimeout(()=>oe(null),3e3)},className:"flex items-center gap-2 px-3 py-2 rounded-sm bg-background border border-border/50 text-muted-foreground text-xs font-display uppercase tracking-wider hover:text-foreground hover:border-amber-500/30 transition-all cursor-pointer",children:s.jsx("span",{children:"Test"})})]}),$&&s.jsx("p",{className:"text-xs font-mono text-amber-400",children:$}),s.jsxs("div",{className:"border border-amber-500/20 rounded-sm p-3 bg-amber-500/5",children:[s.jsx("p",{className:"text-[10px] text-amber-400 font-display uppercase tracking-widest mb-2",children:"What you'll get notified about"}),s.jsxs("ul",{className:"text-xs text-muted-foreground font-mono space-y-1",children:[s.jsx("li",{children:"• Session completes (task finished)"}),s.jsx("li",{children:"• Permission requests (Claude needs approval)"}),s.jsx("li",{children:"• Works on mobile PWA and desktop browsers"})]})]})]}):s.jsxs("div",{className:"border border-amber-500/20 rounded-sm p-3 bg-amber-500/5 space-y-3",children:[s.jsx("p",{className:"text-xs text-amber-400 font-mono",children:"Push notifications are not configured on the server yet."}),s.jsxs("button",{onClick:async()=>{B(!0),C(null);try{await H.updateConfig({interface:{notifications:{enabled:!0}}}),await ee.refresh()}catch(G){C("Failed to enable notifications"),console.error("Failed to enable notifications:",G)}finally{B(!1)}},disabled:ne,className:"flex items-center gap-2 px-4 py-2 rounded-sm bg-background border border-amber-500/30 text-amber-400 text-xs font-display font-bold uppercase tracking-wider hover:border-amber-400 hover:bg-amber-500/5 transition-all cursor-pointer disabled:opacity-50",children:[ne?s.jsx(Re,{size:14,className:"animate-spin"}):s.jsx(Gr,{size:14}),s.jsx("span",{children:ne?"Enabling...":"Enable On Server"})]}),s.jsx("p",{className:"text-[10px] text-muted-foreground font-mono",children:"This creates VAPID keys automatically and unlocks browser subscription."})]}):s.jsxs("div",{className:"border border-amber-500/20 rounded-sm p-3 bg-amber-500/5",children:[s.jsx("p",{className:"text-xs text-amber-400 font-mono mb-2",children:"Push notifications are unavailable in this browsing context."}),s.jsxs("ul",{className:"text-[11px] text-amber-300/90 font-mono space-y-1",children:[ee.supportIssues.includes("ios-home-screen-required")&&s.jsx("li",{children:"• iOS requirement: open Lattice as an installed Home Screen app (`Share` → `Add to Home Screen`) and enable notifications from that app."}),ee.supportIssues.includes("insecure-context")&&s.jsxs("li",{children:["• Secure context required: notifications need HTTPS (or localhost). Current origin: ",s.jsx("span",{className:"text-amber-200",children:z})]}),ee.supportIssues.includes("missing-browser-apis")&&s.jsx("li",{children:"• This browser/runtime does not expose all required push APIs (`ServiceWorker`, `PushManager`, `Notification`)."}),ee.supportIssues.length===0&&s.jsx("li",{children:"• Browser push APIs are unavailable right now."})]})]})]}),j==="license"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] text-muted-foreground font-display uppercase tracking-widest mb-2",children:"[LICENSE]"}),s.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:"Enter your Pro license key to unlock insights, reviews, turn capture, and thread tagging."})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`w-2 h-2 rounded-full ${Z?.isPro?"bg-emerald-400 shadow-[0_0_8px_rgba(52,211,153,0.5)]":"bg-stone-600"}`}),s.jsx("span",{className:"text-sm font-mono text-foreground",children:Z?.isPro?`Pro — ${Z.plan}`:Z?.error?`Invalid — ${Z.error}`:"No license"}),Z?.lastValidatedAt&&s.jsxs("span",{className:"text-[10px] text-muted-foreground/60 font-mono",children:["checked ",new Date(Z.lastValidatedAt).toLocaleDateString()]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{htmlFor:"settings-license-key",className:"text-xs font-display font-bold text-foreground uppercase tracking-wider flex items-center gap-2",children:[s.jsx(pf,{size:12,className:"text-emerald-400"}),s.jsx("span",{className:"text-emerald-400",children:"▸"})," LICENSE_KEY"]}),s.jsx("input",{id:"settings-license-key",type:"text",value:Q,onChange:G=>q(G.target.value),placeholder:"LATTICE-PRO-...",className:"w-full px-3 py-2 bg-background border border-border rounded-sm text-sm font-mono text-foreground placeholder:text-muted-foreground focus:outline-none focus:border-emerald-500/50 focus:shadow-[0_0_10px_rgba(52,211,153,0.1)]"})]}),s.jsx("div",{className:"flex items-center gap-3",children:s.jsxs("button",{onClick:X,disabled:O,className:"flex items-center gap-2 px-4 py-2 rounded-sm bg-background border border-emerald-500/30 text-emerald-400 text-xs font-display font-bold uppercase tracking-wider hover:border-emerald-400 hover:bg-emerald-500/5 transition-all cursor-pointer disabled:opacity-50",children:[O?s.jsx(Re,{size:14,className:"animate-spin"}):s.jsx(ds,{size:14}),s.jsx("span",{children:O?"Validating...":"Save & Validate"})]})}),s.jsxs("div",{className:"border border-emerald-500/20 rounded-sm p-3 bg-emerald-500/5",children:[s.jsx("p",{className:"text-[10px] text-emerald-400 font-display uppercase tracking-widest mb-2",children:"Get a License"}),s.jsx("p",{className:"text-xs text-muted-foreground font-mono mb-2",children:"Subscribe at lattice.cc to get your license key. Copy it from the dashboard and paste it above."}),s.jsxs("a",{href:"https://lattice.cc/dashboard/license",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-xs font-mono text-emerald-400 hover:text-emerald-300 transition-colors",children:[s.jsx(os,{size:12}),"lattice.cc/dashboard/license"]})]})]}),T&&s.jsxs("p",{className:"text-xs font-mono text-red-400",children:["[ERROR] ",T]})]}),s.jsxs("div",{className:"relative px-4 py-3 border-t border-border/50 flex items-center justify-end gap-3",children:[s.jsx("button",{onClick:e,className:"px-3 py-1.5 text-xs font-display text-muted-foreground hover:text-foreground transition-colors cursor-pointer uppercase tracking-wider",children:"CANCEL"}),s.jsx("button",{onClick:de,disabled:v,className:"flex items-center gap-2 px-4 py-1.5 rounded-sm bg-background/80 backdrop-blur-sm border border-cyan-500/30 text-cyan-400 text-xs font-display font-bold uppercase tracking-wider hover:border-cyan-400 hover:bg-cyan-500/5 hover:shadow-[2px_2px_0_rgba(0,255,255,0.5),-2px_-2px_0_rgba(168,85,247,0.3)] hover:translate-x-[-1px] hover:translate-y-[-1px] transition-all duration-100 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:shadow-none disabled:hover:translate-x-0 disabled:hover:translate-y-0",children:v?s.jsx(Re,{size:14,className:"animate-spin"}):N?s.jsxs(s.Fragment,{children:[s.jsx(Oe,{size:14}),s.jsx("span",{children:"SAVED"})]}):s.jsxs(s.Fragment,{children:[s.jsx(Oe,{size:14}),s.jsx("span",{children:"SAVE"})]})})]})]})]}):null}function K2(t){let e=t.split(`
|
|
159
159
|
---
|
|
160
160
|
`);return e.length<2&&(e=t.split(" --- ")),{friction:e[0]?.trim()||"",action:e[1]?.trim()||"",rationale:e[2]?.trim()||""}}const Pp="lattice-queued-session-last-prompt";function Mp(){return typeof window>"u"||typeof window.localStorage>"u"?null:window.localStorage}function Q2(t){const e=Mp();if(e)try{e.setItem(Pp,JSON.stringify(t))}catch{}}function go(){const t=Mp();if(!t)return null;try{const e=t.getItem(Pp);if(!e)return null;const n=Fs(e);return!n||typeof n.prompt!="string"||typeof n.provider!="string"?null:{prompt:n.prompt,provider:"claude",model:typeof n.model=="string"?n.model:void 0,workspace:typeof n.workspace=="string"?n.workspace:void 0,workingDirectory:typeof n.workingDirectory=="string"?n.workingDirectory:"~",permissionMode:typeof n.permissionMode=="string"?n.permissionMode:void 0,createdAt:typeof n.createdAt=="string"?n.createdAt:new Date().toISOString()}}catch{return null}}function Y2(t,e){const n=[...t].sort((o,a)=>new Date(a.createdAt).getTime()-new Date(o.createdAt).getTime());let r="";if(n.length>0){r+=`You have ${t.length} dev note${t.length!==1?"s":""} to work through.
|
|
161
161
|
|
|
@@ -187,7 +187,7 @@ Please work through these notes systematically. For each one, either:
|
|
|
187
187
|
2. Investigate and propose a solution if complex
|
|
188
188
|
3. Ask clarifying questions if the note is ambiguous
|
|
189
189
|
|
|
190
|
-
Mark each note as addressed as you complete it.`,r}async function Lp(t,e,n,r,o={}){if(e.length===0&&n.length===0)return null;const a=Y2(e,n),i=o.provider||"claude",l=o.model;return Q2({prompt:a,provider:i,model:l,workspace:o.workspace,workingDirectory:r,permissionMode:o.permissionMode,createdAt:new Date().toISOString()}),t.createConversation({provider:i,message:a,workingDirectory:r,model:l,permissionMode:o.permissionMode,workspace:o.workspace})}const Op="claudia-last-permission-mode";function pa(t,e){const n=t==="acceptEdits"?"acceptEdits":t==="bypassPermissions"?"bypassPermissions":"default";return e==="claude"&&n==="acceptEdits"?"default":n}function J2(t,e){try{const n=localStorage.getItem(Op);if(n==="default"||n==="acceptEdits"||n==="bypassPermissions")return pa(n,e)}catch{}return pa(t,e)}function pn(t){const{explicit:e,fallback:n,provider:r}=t;return typeof e=="string"&&e.length>0?pa(e,r):J2(n,r)}function ma(t){try{localStorage.setItem(Op,t)}catch{}}const nl={codebase:{icon:ka,text:"text-emerald-400",bg:"bg-emerald-500/10"},project_instructions:{icon:Io,text:"text-sky-400",bg:"bg-sky-500/10"},global_instructions:{icon:ja,text:"text-purple-400",bg:"bg-purple-500/10"}};function rl(t){const e=new Date(t),r=new Date().getTime()-e.getTime(),o=Math.floor(r/6e4),a=Math.floor(r/36e5),i=Math.floor(r/864e5);return o<1?"just now":o<60?`${o}m`:a<24?`${a}h`:i<7?`${i}d`:e.toLocaleDateString()}function ol(t){return[...t].sort((e,n)=>new Date(n.createdAt).getTime()-new Date(e.createdAt).getTime())}function Dp({isOpen:t,onClose:e,onLaunchSession:n,defaultProvider:r="claude",defaultPermissionMode:o,initialProvider:a,initialPermissionMode:i}){const l=St(),[c,d]=u.useState([]),[p,m]=u.useState([]),[h,g]=u.useState(()=>{try{return localStorage.getItem("lattice-dev-note-draft")||""}catch{return""}}),f=B=>{g(B);try{B?localStorage.setItem("lattice-dev-note-draft",B):localStorage.removeItem("lattice-dev-note-draft")}catch{}},[x,b]=u.useState(!1),[y,v]=u.useState(!1),[w,N]=u.useState(!1),[S,T]=u.useState(null),[C,j]=u.useState(a||r),[E,R]=u.useState(()=>pn({explicit:i,fallback:o,provider:a||r})),[O,$]=u.useState(null),[re,ne]=u.useState(""),[V,X]=u.useState(!1),[q,K]=u.useState(null),[ge,D]=u.useState(null),W=u.useRef(null),Z=ol(c),F=c.length+p.length,se=u.useMemo(()=>{const B=new Map;for(const he of p){const L=he.sourceProject||"General";B.has(L)||B.set(L,[]),B.get(L).push(he)}return[...B.entries()]},[p]);u.useEffect(()=>{t&&(N(!1),T(null),$(null),ne(""),a&&j(a),i&&R(pn({explicit:i,fallback:o,provider:a||r})),D(go()?.prompt||null),te(),setTimeout(()=>W.current?.focus(),100))},[t,a,i,o,r]),u.useEffect(()=>{C==="claude"&&E==="acceptEdits"&&(R("default"),ma("default"))},[C,E]);const ee=u.useCallback(async()=>{const B=ge||go()?.prompt;if(!B)return;try{if(navigator?.clipboard?.writeText){await navigator.clipboard.writeText(B);return}}catch{}const he=document.createElement("textarea");he.value=B,he.style.position="fixed",he.style.left="-9999px",he.style.top="-9999px",document.body.appendChild(he),he.focus(),he.select(),document.execCommand("copy"),document.body.removeChild(he)},[ge]),te=async()=>{b(!0),K(null);try{const[B,he]=await Promise.all([G.getDevNotes(),G.getPendingRecommendations()]);d(ol(B.notes)),m(he.recommendations)}catch(B){K("Failed to load queue"),console.error("Failed to fetch action queue:",B)}finally{b(!1)}},xe=u.useCallback(async()=>{if(!(!h.trim()||y)){v(!0),K(null);try{await G.createDevNote({content:h.trim()}),f(""),await te()}catch(B){K("Failed to create note"),console.error("Failed to create dev note:",B)}finally{v(!1)}}},[h,y]),_e=B=>{B.key==="Enter"&&!B.shiftKey&&(B.preventDefault(),xe())},A=async B=>{try{await G.updateDevNoteStatus(B,"done"),O===B&&($(null),ne("")),d(he=>he.filter(L=>L.id!==B))}catch(he){console.error("Failed to mark note as done:",he)}},P=async B=>{try{await G.deleteDevNote(B),O===B&&($(null),ne("")),d(he=>he.filter(L=>L.id!==B))}catch(he){console.error("Failed to delete note:",he)}},le=u.useCallback(B=>{$(B.id),ne(B.content)},[]),J=u.useCallback(()=>{$(null),ne("")},[]),H=u.useCallback(async()=>{if(!O||V)return;const B=re.trim();if(!B){K("Note content cannot be empty");return}X(!0),K(null);try{await G.updateDevNote(O,{content:B}),d(he=>he.map(L=>L.id===O?{...L,content:B}:L)),J()}catch(he){K("Failed to update note"),console.error("Failed to update dev note:",he)}finally{X(!1)}},[O,re,V,J]),ye=async B=>{try{await G.completeRecommendation(B),m(he=>he.filter(L=>L.id!==B))}catch(he){console.error("Failed to complete recommendation:",he)}},I=async B=>{try{await G.dismissRecommendation(B),m(he=>he.filter(L=>L.id!==B))}catch(he){console.error("Failed to dismiss recommendation:",he)}},pe=u.useCallback(async()=>{if(S){e(),l(`/c/${S}`);return}if(!(F===0||!n||w)){N(!0),K(null);try{const B=await n(c,p,C,E);B?.sessionId?T(B.sessionId):K("Session started but no session ID was returned")}catch(B){K("Failed to start session"),D(go()?.prompt||null),console.error("Failed to launch queue session:",B)}finally{N(!1)}}},[S,F,n,w,c,p,e,l,C,E]),Ce=u.useCallback(B=>{R(B),ma(B)},[]),ke=[{mode:"default",label:"Ask",icon:Ms,activeClasses:"bg-cyan-500/20 text-cyan-300 border border-cyan-500/40",description:"Prompt before every tool use."},{mode:"bypassPermissions",label:"Trust",icon:mr,activeClasses:"bg-amber-500/20 text-amber-300 border border-amber-500/40",description:"Skip all permission prompts. Runs freely with no restrictions."}],Re=()=>Z.length===0?null:s.jsxs("div",{className:"mb-1",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1",children:[s.jsx(Js,{size:10,className:"text-amber-400"}),s.jsx("span",{className:"text-[10px] font-display font-bold uppercase tracking-wider text-amber-400",children:"Notes"})]}),s.jsx("div",{className:"space-y-0.5",children:Z.map(B=>s.jsxs("div",{className:"group px-3 py-1.5 hover:bg-muted/20 transition-colors",children:[O===B.id?s.jsxs("div",{className:"space-y-2",children:[s.jsx("input",{value:re,onChange:he=>ne(he.target.value),className:"w-full px-2 py-1.5 text-sm font-mono bg-background/60 border border-cyan-500/30 rounded-sm text-foreground focus:outline-none focus:border-cyan-400/60",onKeyDown:he=>{he.key==="Enter"&&!he.shiftKey&&(he.preventDefault(),H())}}),s.jsx("div",{className:"flex items-center justify-end gap-1",children:s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>{H()},disabled:V||!re.trim(),className:"p-1 text-muted-foreground/50 hover:text-emerald-400 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",title:"Save note",children:V?s.jsx(Ae,{size:12,className:"animate-spin"}):s.jsx(Oe,{size:12})}),s.jsx("button",{onClick:J,disabled:V,className:"p-1 text-muted-foreground/50 hover:text-rose-400 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",title:"Cancel edit",children:s.jsx(Be,{size:12})})]})})]}):s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("p",{className:"flex-1 min-w-0 text-sm font-mono text-foreground/80 leading-snug break-words",children:B.content}),s.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0 pt-0.5",children:[s.jsx("span",{className:"hidden sm:inline text-[10px] font-mono text-muted-foreground/30 opacity-0 group-hover:opacity-100 transition-opacity",children:rl(B.createdAt)}),s.jsxs("div",{className:"flex gap-1 opacity-100 sm:opacity-0 sm:group-hover:opacity-100 transition-opacity",children:[s.jsx("button",{onClick:()=>le(B),className:"p-1 text-muted-foreground/50 hover:text-cyan-400 cursor-pointer",title:"Edit note",children:s.jsx(va,{size:12})}),s.jsx("button",{onClick:()=>{A(B.id)},className:"p-1 text-muted-foreground/50 hover:text-emerald-400 cursor-pointer",title:"Mark done",children:s.jsx(Oe,{size:12})}),s.jsx("button",{onClick:()=>{P(B.id)},className:"p-1 text-muted-foreground/50 hover:text-rose-400 cursor-pointer",title:"Delete note",children:s.jsx(Lo,{size:12})})]})]})]}),s.jsx("div",{className:"h-0.5"})]},B.id))})]});return t?s.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center",style:{paddingTop:"calc(env(safe-area-inset-top, 0px) + 10vh)",paddingRight:"calc(env(safe-area-inset-right, 0px) + 1rem)",paddingBottom:"calc(env(safe-area-inset-bottom, 0px) + 1rem)",paddingLeft:"calc(env(safe-area-inset-left, 0px) + 1rem)"},children:[s.jsx("button",{type:"button",className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:e,"aria-label":"Close queue dialog"}),s.jsxs("div",{className:"relative z-10 w-full max-w-md mx-4 bg-background border border-border rounded-sm shadow-xl overflow-hidden max-h-[80vh] flex flex-col",children:[s.jsx("div",{className:"absolute inset-0 bg-[linear-gradient(rgba(0,255,255,0.02)_1px,transparent_1px),linear-gradient(90deg,rgba(0,255,255,0.02)_1px,transparent_1px)] bg-[size:16px_16px] pointer-events-none"}),s.jsxs("div",{className:"relative border-b border-border/50",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Js,{size:14,className:"text-cyan-400"}),s.jsx("span",{className:"text-[10px] font-display font-bold text-cyan-400 uppercase tracking-wider",children:"Action Queue"})]}),F>0&&s.jsx("div",{className:"flex items-center gap-1",children:p.length>0&&s.jsx("span",{className:"min-w-[18px] h-[18px] flex items-center justify-center text-[9px] font-bold bg-purple-500/20 text-purple-400 border border-purple-500/30 rounded-sm",children:p.length})})]}),s.jsx("button",{onClick:e,className:"p-1 text-muted-foreground hover:text-cyan-400 transition-colors cursor-pointer",children:s.jsx(Be,{size:14})})]}),s.jsx("p",{className:"px-4 pb-2 text-[11px] leading-relaxed text-muted-foreground/70",children:"Backlog for future sessions. Items stay here until you start a dedicated session. This is separate from the per-session message queue in the composer."})]}),s.jsx("div",{className:"relative px-4 py-3 border-b border-border/30",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{ref:W,value:h,onChange:B=>f(B.target.value),onKeyDown:_e,placeholder:"Add a note...",className:"flex-1 px-3 py-1.5 bg-background/50 border border-border/50 rounded-sm text-sm font-mono placeholder:text-muted-foreground/40 focus:outline-none focus:border-cyan-500/50"}),s.jsx("button",{onClick:()=>{xe()},disabled:!h.trim()||y,className:"px-2.5 py-1.5 rounded-sm border border-cyan-500/30 text-cyan-400 hover:bg-cyan-500/10 hover:border-cyan-400 transition-all cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",children:y?s.jsx(Ae,{size:14,className:"animate-spin"}):s.jsx(Kl,{size:14})})]})}),s.jsx("div",{className:"relative flex-1 overflow-y-auto p-2 min-h-[150px] max-h-96 flex flex-col",children:x?s.jsx("div",{className:"flex flex-1 items-center justify-center py-8",children:s.jsx(Ae,{size:20,className:"animate-spin text-muted-foreground"})}):q?s.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 py-8 text-rose-400",children:[s.jsxs("div",{className:"flex items-center justify-center gap-2",children:[s.jsx(Es,{size:16}),s.jsx("span",{className:"text-sm font-mono",children:q})]}),ge&&s.jsx("button",{onClick:()=>{ee()},className:"px-2 py-1 rounded-sm border border-rose-500/30 text-[10px] font-mono font-bold uppercase tracking-wider hover:bg-rose-500/10 hover:border-rose-400 cursor-pointer",children:"Copy Last Prompt"})]}):F===0?s.jsxs("div",{className:"flex flex-1 min-h-[220px] flex-col items-center justify-center py-8 text-center text-muted-foreground/50",children:[s.jsx(Js,{size:24,className:"mb-2 opacity-50"}),s.jsx("span",{className:"text-sm font-mono",children:"Action queue empty"}),s.jsx("span",{className:"text-xs font-mono mt-1",children:"Add a note above, or review a session to generate recommendations"})]}):s.jsxs(s.Fragment,{children:[Re(),p.length>0&&s.jsxs(s.Fragment,{children:[c.length>0&&s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 mt-2",children:[s.jsx("div",{className:"flex-1 border-t border-purple-500/20"}),s.jsx("span",{className:"text-[9px] font-mono font-bold text-purple-400/60 uppercase tracking-wider",children:"ai"}),s.jsx("div",{className:"flex-1 border-t border-purple-500/20"})]}),s.jsxs("div",{className:"mb-1",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1",children:[s.jsx(fh,{size:10,className:"text-purple-400"}),s.jsx("span",{className:"text-[10px] font-mono font-bold uppercase tracking-wider text-purple-400",children:"Recommendations"}),s.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground/30",children:["(",p.length,")"]})]}),se.map(([B,he])=>s.jsxs("div",{className:"mb-2",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5",children:[s.jsx("span",{className:"text-[10px] font-display font-bold uppercase tracking-wider text-cyan-400/70",children:B}),s.jsx("span",{className:"text-[10px] font-mono text-muted-foreground/20",children:he.length})]}),s.jsx("div",{className:"space-y-0.5",children:he.map(L=>{const Q=nl[L.target]||nl.codebase,U=Q.icon,ae=L.friction?(()=>{const be=K2(L.friction).friction,me=be.match(/^[^.!?]+[.!?]/)?.[0]||be;return me.length>140?me.slice(0,140)+"...":me})():"";return s.jsxs("div",{className:"group px-3 py-2 hover:bg-muted/20 transition-colors",children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("div",{className:`p-1 rounded ${Q.bg} flex-shrink-0 mt-0.5`,children:s.jsx(U,{size:10,className:Q.text})}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("p",{className:"text-sm font-mono text-foreground/80 leading-snug",children:L.action})})]}),ae&&s.jsx("p",{className:"text-[11px] font-mono text-muted-foreground/40 mt-1 pl-7 leading-snug line-clamp-2",children:ae}),s.jsxs("div",{className:"flex items-center gap-2 mt-1.5 pl-7",children:[s.jsx("span",{className:"text-[10px] font-mono text-muted-foreground/30",children:rl(L.createdAt)}),L.sessionId&&s.jsxs("button",{onClick:()=>{e(),l(`/c/${L.sessionId}`)},className:"flex items-center gap-1 text-[10px] font-mono text-muted-foreground/30 hover:text-cyan-400/70 transition-colors cursor-pointer",title:L.sourceMission||"View source session",children:[s.jsx(os,{size:9}),s.jsx("span",{className:"truncate max-w-[160px]",children:L.sourceMission||"session"})]}),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[s.jsx("button",{onClick:()=>{ye(L.id)},className:"p-1 text-muted-foreground/50 hover:text-emerald-400 cursor-pointer",title:"Mark complete",children:s.jsx(Oe,{size:12})}),s.jsx("button",{onClick:()=>{I(L.id)},className:"p-1 text-muted-foreground/50 hover:text-rose-400 cursor-pointer",title:"Dismiss",children:s.jsx(Lo,{size:12})})]})]})]},L.id)})})]},B))]})]})]})}),F>0&&n&&s.jsxs("div",{className:"relative px-4 py-2.5 border-t border-border/30 space-y-2",children:[!S&&s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:s.jsx("div",{className:"flex items-center rounded-sm border border-zinc-700/50 bg-zinc-900/50 p-0.5",children:ke.map(({mode:B,label:he,icon:L,activeClasses:Q,description:U})=>{const ae=E===B;return s.jsxs("button",{onClick:()=>Ce(B),disabled:w,title:U,className:`flex items-center gap-1 px-2 py-1 rounded-sm text-[10px] font-display font-bold uppercase tracking-wider transition-all duration-100 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed ${ae?Q:"text-zinc-500 hover:text-zinc-400 border border-transparent"}`,children:[s.jsx(L,{size:10}),he]},B)})})}),s.jsx("button",{onClick:()=>{pe()},disabled:w,className:"w-full flex items-center justify-center gap-2 py-1.5 rounded-sm ui-action-btn ui-action-btn--cool text-[10px] font-display font-bold uppercase tracking-wider bg-background/80 backdrop-blur-sm disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:shadow-none disabled:hover:translate-x-0 disabled:hover:translate-y-0",children:w?s.jsxs(s.Fragment,{children:[s.jsx(Ae,{size:12,className:"animate-spin"}),"Starting Session..."]}):S?s.jsxs(s.Fragment,{children:[s.jsx(Gt,{size:12}),"Go to Session"]}):s.jsxs(s.Fragment,{children:[s.jsx(Gt,{size:12}),"Start Session"]})})]})]})]}):null}const X2=200,oi=["conversations","archived-sidebar"];function Z2(t){const{enabled:e}=t,{data:n,isLoading:r}=Nt({queryKey:oi,queryFn:async()=>((await G.listUnifiedConversations({archived:!0,includeIdentityImage:!1,limit:X2})).conversations||[]).filter(a=>a.archived).sort((a,i)=>new Date(i.updatedAt).getTime()-new Date(a.updatedAt).getTime()),enabled:e,staleTime:6e4,refetchOnWindowFocus:!1});return{archivedSessions:n||[],isLoading:r}}function ej(t,e){if(!t)return t;const n=t.conversations.filter(r=>r.conversationId!==e);return n.length===t.conversations.length?t:{...t,conversations:n,total:Math.max(0,t.total-1)}}function Dn(t,e,n){return t+(e-t)*n}function Ws(t,e,n){return[Dn(t[0],e[0],n),Dn(t[1],e[1],n),Dn(t[2],e[2],n),Dn(t[3],e[3],n)]}function ct(t){return`rgba(${Math.round(t[0])},${Math.round(t[1])},${Math.round(t[2])},${t[3].toFixed(3)})`}const xo=[120,120,130,.2],et=[251,191,36,.8],Ks=[52,211,153,1];function tj(t){if(t>=2)return{strokeColor:ct(Ks),fillColor:ct(Ks),fillOpacity:.6,borderColor:ct(Ks),textColor:ct(Ks),bgColor:"rgba(16,185,129,0.08)",scanning:!1,glowOpacity:.04};if(t>=1){const l=t-1,c=Ws(et,Ks,l*.3);return{strokeColor:ct(c),fillColor:ct(c),fillOpacity:.6,borderColor:ct([c[0],c[1],c[2],.4]),textColor:ct([c[0],c[1],c[2],.8]),bgColor:"transparent",scanning:!0,glowOpacity:0}}const e=Math.max(0,Math.min(t,.99)),n=Ws(xo,[et[0],et[1],et[2],.45],e),r=Ws(xo,[et[0],et[1],et[2],.55],e),o=e*e*.55,a=Math.max(0,(e-.5)*2),i=Ws([120,120,130,0],[et[0],et[1],et[2],a*.2],a);return{strokeColor:ct(n),fillColor:ct(r),fillOpacity:o,borderColor:ct(i),textColor:ct(Ws(xo,[et[0],et[1],et[2],.5],e*.6)),bgColor:"transparent",scanning:!1,glowOpacity:0}}function ha({status:t,isLoading:e=!1,disabled:n=!1,onClick:r}){const o=!!t?.synthesisInProgress,a=t?.pendingProposals??0,i=t?.threshold?Math.min((t.pendingExtractions??0)/t.threshold,1):0,l=a>0?2:o?1:i,c=tj(l),d=e?"Checking status...":o?"Reviewing recent sessions for patterns worth acting on":a>0?`${a} proposed change${a===1?"":"s"} based on patterns across recent sessions`:i>0?`${t?.pendingExtractions}/${t?.threshold} sessions toward next analysis`:"Lattice watches how you work across sessions and proposes changes when it spots patterns";return s.jsxs(Ke,{children:[s.jsx(Qe,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:r,disabled:n,"aria-label":"Cross-session insights",className:`group relative flex items-center gap-2 px-3 py-1.5 max-sm:h-10 rounded-sm text-[10px] font-display font-bold uppercase tracking-wider transition-all duration-300 overflow-hidden ${a>0?"hover:shadow-[2px_2px_0_rgba(16,185,129,0.5),-2px_-2px_0_rgba(34,211,238,0.25)] hover:translate-x-[-1px] hover:translate-y-[-1px]":""} disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:shadow-none disabled:hover:translate-x-0 disabled:hover:translate-y-0`,style:{borderWidth:1,borderStyle:"solid",borderColor:c.borderColor,color:c.textColor,backgroundColor:c.bgColor},children:[c.scanning&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"absolute top-0 left-0 h-[1px] w-full animate-[insight-scan_1.5s_linear_infinite]",style:{background:`linear-gradient(to right, transparent, ${c.strokeColor}, transparent)`}}),s.jsx("span",{className:"absolute bottom-0 right-0 h-[1px] w-full animate-[insight-scan_1.5s_linear_infinite_0.75s]",style:{background:`linear-gradient(to right, transparent, ${ct([et[0],et[1],et[2],.4])}, transparent)`}})]}),s.jsxs("svg",{viewBox:"0 0 12 12",className:"w-3 h-3 transition-all duration-500","aria-hidden":"true",children:[s.jsx("path",{d:"M6 1 L11 6 L6 11 L1 6 Z",fill:"none",stroke:c.strokeColor,strokeWidth:"1.2"}),c.fillOpacity>.01&&s.jsx("path",{d:"M6 3.5 L8.5 6 L6 8.5 L3.5 6 Z",fill:c.fillColor,opacity:c.fillOpacity})]}),a>0&&s.jsx("span",{className:"relative",children:a}),c.glowOpacity>0&&s.jsx("span",{className:"absolute inset-0 rounded-sm",style:{backgroundColor:`rgba(52,211,153,${c.glowOpacity})`}})]})}),s.jsx(qe,{children:s.jsx("p",{children:d})})]})}function $p({count:t,onClick:e}){return s.jsxs(Ke,{children:[s.jsx(Qe,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:e,"aria-label":"Notes",className:"relative flex items-center gap-2 p-1.5 min-[1440px]:px-3 min-[1440px]:py-1.5 bg-background/80 backdrop-blur-sm ui-action-btn ui-action-btn--cool text-[10px] font-display font-bold uppercase tracking-wider",children:[s.jsx(Js,{size:14}),s.jsx("span",{className:"hidden min-[1440px]:inline",children:"NOTES"}),t>0&&s.jsx("span",{className:"min-w-[16px] h-[16px] px-1 flex items-center justify-center rounded-full bg-cyan-400/15 border border-cyan-400/30 text-[9px] leading-none text-cyan-300 pb-px pl-0.5",children:t>99?"99+":t})]})}),s.jsx(qe,{side:"bottom",align:"end",className:"max-w-[300px]",children:"Action queue for future work: notes and review recommendations stay here until you launch a separate session. This is different from the composer message queue."})]})}function sj({sessionId:t,isArchived:e=!1,insightsPanelOpen:n,onToggleInsightsPanel:r,crossSessionSidebarOpen:o,onToggleCrossSessionSidebar:a,onOpenCrossSessionAnalysis:i,onOpenFeedbackPanel:l}){const c=St(),d=mn(),p=$l(),{isPro:m}=yn(),{conversations:h,invalidateConversations:g}=$s(),{serverConfig:f}=zs(),[x,b]=u.useState(!1),[y,v]=u.useState(!1),[w,N]=u.useState(!1),[S,T]=u.useState(0),{data:C,isLoading:j}=Nt({queryKey:["cross-session-status"],queryFn:()=>G.getCrossSessionStatus(),staleTime:1e4,refetchInterval:I=>I.state.data?.synthesisInProgress?3e3:15e3});u.useEffect(()=>{const I=async()=>{try{const[Ce,ke]=await Promise.all([G.getDevNotes(),G.getPendingRecommendations()]);T(Ce.notes.length+ke.recommendations.length)}catch{}};I();const pe=setInterval(()=>{I()},3e4);return()=>clearInterval(pe)},[]);const E=u.useCallback(()=>{N(!1),Promise.all([G.getDevNotes(),G.getPendingRecommendations()]).then(([I,pe])=>T(I.notes.length+pe.recommendations.length))},[]),R=u.useCallback(async(I,pe,Ce,ke)=>{if(I.length===0&&pe.length===0)return;const Re=Ce||"claude";try{const B=await Lp(G,I,pe,f?.defaultWorkingDirectory||f?.cwd||"~",{workspace:"main",provider:Re,model:f?.defaultModel,permissionMode:ke||f?.defaultPermissionMode});return B?(await g(),{sessionId:B.conversationId}):null}catch(B){throw console.error("Failed to launch queue session:",B),B}},[g,f?.defaultWorkingDirectory,f?.cwd,f?.defaultModel,f?.defaultPermissionMode]),O=async()=>{if(t)try{await G.unifiedUpdateConversation(t,{archived:!e}),e||d.setQueriesData({predicate:I=>I.queryKey[0]==="conversations"&&I.queryKey[1]==="list"},I=>ej(I,t)),await Promise.all([g(),d.invalidateQueries({queryKey:oi})]),c("/",{replace:!0})}catch(I){console.error(`[Archive] Failed to ${e?"unarchive":"archive"} session:`,I)}},[$,re]=u.useState(!1),ne=async()=>{if(t){re(!0);try{await G.exportSession(t)}catch(I){console.error("Failed to export session:",I),alert(`Export failed: ${I instanceof Error?I.message:"Unknown error"}`)}finally{re(!1)}}},V=h.find(I=>I.conversationId===t),X=!!V?.importedAt,[q,K]=u.useState(""),[ge,D]=u.useState(!1),[W,Z]=u.useState(!1),[F,se]=u.useState(!1),ee=Te.useRef(null),te=Te.useRef(null),xe=V?.pausedReason;u.useEffect(()=>{if(t){if(xe&&xe.trim().length>0){D(!0),K(xe);return}if(h.some(I=>I.conversationId===t)){D(!1);return}G.getConversationDetails(t,{limit:1}).then(I=>{const pe=I?.sessionInfo?.paused_reason;D(!!pe),pe&&K(pe)}).catch(()=>{})}},[t,xe,h]),u.useEffect(()=>{W&&requestAnimationFrame(()=>ee.current?.focus())},[W]),u.useEffect(()=>{F&&requestAnimationFrame(()=>te.current?.focus())},[F]);const _e=async()=>{if(!t||!q.trim())return!1;try{return await G.unifiedUpdateConversation(t,{pausedReason:q.trim()}),D(!0),Z(!1),await g(),!0}catch(I){return console.error("Failed to pause session:",I),!1}},A=async()=>{if(!t)return!1;try{return await G.unifiedUpdateConversation(t,{pausedReason:null}),D(!1),K(""),await g(),!0}catch(I){return console.error("Failed to resume session:",I),!1}},[P,le]=u.useState(!1),J=async()=>{if(t)try{if(navigator.clipboard?.writeText)await navigator.clipboard.writeText(t);else{const I=document.createElement("textarea");I.value=t,I.style.position="fixed",I.style.left="-9999px",I.style.top="-9999px",document.body.appendChild(I),I.focus(),I.select(),document.execCommand("copy"),document.body.removeChild(I)}le(!0),setTimeout(()=>le(!1),2e3)}catch(I){console.error("Failed to copy session ID:",I)}},H=p.pathname==="/analysis/cross-session",ye=()=>{if(H)c(-1);else if(i)i();else{const I=!!C?.readyToAnalyze;c(I?"/analysis/cross-session?run=1":"/analysis/cross-session")}};return s.jsxs(Ot,{children:[s.jsxs("div",{className:"flex justify-between items-center gap-3 px-4 py-3 border-b border-border/50 bg-background transition-colors relative overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 ui-grid-overlay pointer-events-none"}),s.jsxs("div",{className:"relative flex items-center gap-3",children:[a&&!o&&s.jsx("button",{onClick:a,"aria-label":"Open sessions sidebar",className:"p-1.5 ui-icon-btn ui-icon-btn--cool",children:s.jsx(Wl,{size:18})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(hp,{size:28,interactive:!0,colorScheme:"gradient"}),s.jsx("span",{className:"text-base font-display font-medium lowercase tracking-widest text-white",children:"lattice"}),s.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/30 select-none",children:"18351bca"})]})]}),s.jsxs("div",{className:"relative hidden sm:flex items-center gap-1 md:gap-2 min-[1440px]:gap-2 flex-shrink-0",children:[X&&s.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-sm border border-cyan-500/30 bg-cyan-500/10",children:[s.jsx(Kn,{size:12,className:"text-cyan-400"}),s.jsx("span",{className:"text-[10px] font-display font-bold uppercase tracking-wider text-cyan-400",children:"Imported · Read-only"})]}),!e&&s.jsxs(s.Fragment,{children:[s.jsx(ha,{status:C??null,isLoading:j,disabled:!C&&!j,onClick:ye}),l&&s.jsxs(Ke,{children:[s.jsx(Qe,{asChild:!0,children:s.jsxs("button",{onClick:l,"aria-label":"Send feedback",className:"flex items-center gap-2 px-3 py-1.5 rounded-sm border border-transparent text-muted-foreground/50 hover:text-muted-foreground/70 hover:border-border/20 text-[10px] font-display font-bold uppercase tracking-wider transition-all duration-100",children:[s.jsx(as,{size:12}),s.jsx("span",{className:"hidden min-[1440px]:inline",children:"FEEDBACK"})]})}),s.jsx(qe,{children:s.jsx("p",{children:"Report a bug or send a comment"})})]}),s.jsx("span",{className:"h-4 w-px bg-border/20 mx-2"})]}),ge?s.jsxs("button",{onClick:()=>{A()},disabled:!t,"aria-label":"Resume session",className:"flex items-center gap-2 p-1.5 min-[1440px]:px-3 min-[1440px]:py-1.5 bg-background/80 backdrop-blur-sm ui-action-btn ui-action-btn--violet text-[10px] font-display font-bold uppercase tracking-wider disabled:opacity-50 disabled:cursor-not-allowed",children:[s.jsx(Gt,{size:14}),s.jsx("span",{className:"hidden min-[1440px]:inline",children:"RESUME"})]}):s.jsxs(Zc,{open:W,onOpenChange:Z,children:[s.jsx(el,{asChild:!0,children:s.jsxs("button",{disabled:!t,"aria-label":"Pause session",className:"flex items-center gap-2 p-1.5 min-[1440px]:px-3 min-[1440px]:py-1.5 bg-background/80 backdrop-blur-sm ui-action-btn ui-action-btn--violet text-[10px] font-display font-bold uppercase tracking-wider disabled:opacity-50 disabled:cursor-not-allowed",children:[s.jsx(ki,{size:14}),s.jsx("span",{className:"hidden min-[1440px]:inline",children:"PAUSE"})]})}),s.jsx(ua,{side:"bottom",align:"end",className:"w-72 p-3 bg-zinc-900/95 backdrop-blur-sm border border-violet-500/20 shadow-[0_0_12px_rgba(139,92,246,0.15)]",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:"pause-reason-desktop",className:"text-[10px] font-mono text-violet-400/60 uppercase tracking-wider",children:"Pause reason"}),s.jsx("textarea",{id:"pause-reason-desktop",ref:ee,value:q,onChange:I=>K(I.target.value),onKeyDown:I=>{I.key==="Enter"&&!I.shiftKey&&(I.preventDefault(),_e())},placeholder:"Why are you pausing? (waiting for deploy, review, etc.)",className:"w-full px-2 py-2 text-[11px] leading-relaxed bg-zinc-800/50 border border-violet-500/20 rounded-sm text-zinc-200 placeholder:text-zinc-500 focus:outline-none focus:border-violet-400/40 resize-none",rows:3}),s.jsx("button",{onClick:()=>{_e()},disabled:!q.trim(),className:"w-full px-3 py-1.5 text-[10px] font-display font-bold uppercase tracking-wider bg-violet-500/10 border border-violet-500/30 text-violet-400 rounded-sm hover:bg-violet-500/20 hover:border-violet-400 transition-all disabled:opacity-40 disabled:cursor-not-allowed",children:"Pause Session"})]})})]}),s.jsxs(Ke,{children:[s.jsx(Qe,{asChild:!0,children:s.jsxs("button",{onClick:()=>{ne()},disabled:!t||$,"aria-label":"Export session",className:"flex items-center gap-2 p-1.5 min-[1440px]:px-3 min-[1440px]:py-1.5 rounded-sm bg-background/80 backdrop-blur-sm border border-cyan-500/30 text-cyan-400 text-[10px] font-display font-bold uppercase tracking-wider hover:border-cyan-400 hover:bg-cyan-500/5 hover:shadow-[2px_2px_0_rgba(0,255,255,0.5),-2px_-2px_0_rgba(168,85,247,0.3)] hover:translate-x-[-1px] hover:translate-y-[-1px] transition-all duration-100 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:shadow-none disabled:hover:translate-x-0 disabled:hover:translate-y-0",children:[$?s.jsx(Ae,{size:14,className:"animate-spin"}):s.jsx(Ao,{size:14}),s.jsx("span",{className:"hidden min-[1440px]:inline",children:"EXPORT"})]})}),s.jsx(qe,{children:s.jsx("p",{children:"Save a portable snapshot of this session — messages, tool calls, and metadata"})})]}),s.jsxs("button",{onClick:O,disabled:!t,"aria-label":e?"Unarchive Task":"Archive Task",className:"flex items-center gap-2 p-1.5 min-[1440px]:px-3 min-[1440px]:py-1.5 bg-background/80 backdrop-blur-sm ui-action-btn ui-action-btn--rose text-[10px] font-display font-bold uppercase tracking-wider disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:shadow-none disabled:hover:translate-x-0 disabled:hover:translate-y-0",children:[s.jsx(tn,{size:14}),s.jsx("span",{className:"hidden min-[1440px]:inline",children:e?"RESTORE":"ARCHIVE"})]}),s.jsx($p,{count:S,onClick:()=>N(!0)}),t&&s.jsxs(Ke,{children:[s.jsx(Qe,{asChild:!0,children:s.jsx("button",{onClick:J,"aria-label":"Copy session ID",className:`p-1.5 ui-icon-btn ${P?"border-green-400/50 text-green-300 bg-green-500/10":"ui-icon-btn--cool"}`,children:P?s.jsx(Oe,{size:16}):s.jsx(Vt,{size:16})})}),s.jsx(qe,{children:s.jsx("p",{children:P?"Copied!":"For linking to this session in notes, bugs, or conversations"})})]}),s.jsx("button",{onClick:()=>v(!0),"aria-label":"Settings",className:"p-1.5 ui-icon-btn ui-icon-btn--cool",children:s.jsx(Mo,{size:16})}),r&&(()=>{const I=m?n?null:"Turn-by-turn timeline of this session's progress":"Unlock turn-by-turn session timeline, milestones, and progress tracking",pe=s.jsxs("button",{onClick:m?r:void 0,disabled:!m,"aria-label":n?"Hide history panel":"Show history panel",className:"flex items-center gap-2 p-1.5 min-[1440px]:px-3 min-[1440px]:py-1.5 bg-background/80 backdrop-blur-sm ui-action-btn ui-action-btn--amber text-[10px] font-display font-bold uppercase tracking-wider disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:shadow-none disabled:hover:translate-x-0 disabled:hover:translate-y-0",children:[n?s.jsx(qr,{size:14}):s.jsx(Wr,{size:14}),s.jsx("span",{className:"hidden min-[1440px]:inline",children:n?"HIDE":"HISTORY"})]});return I?s.jsxs(Ke,{children:[s.jsx(Qe,{asChild:!0,children:pe}),s.jsx(qe,{children:s.jsx("p",{children:I})})]}):pe})()]}),s.jsxs("div",{className:"relative flex items-center gap-3 sm:hidden",children:[e?null:s.jsx("div",{className:"mr-3",children:s.jsx(ha,{status:C??null,isLoading:j,disabled:!C&&!j,onClick:ye})}),s.jsxs(Zc,{open:x,onOpenChange:I=>{b(I),I||se(!1)},children:[s.jsx(el,{asChild:!0,children:s.jsx("button",{type:"button",className:"relative flex items-center justify-center w-10 h-10 bg-background/80 backdrop-blur-sm ui-action-btn ui-action-btn--cool active:bg-cyan-500/10 touch-manipulation","aria-label":"Menu",children:x?s.jsx(Be,{size:20}):s.jsx(Ef,{size:20})})}),s.jsx(ua,{align:"end",sideOffset:8,onOpenAutoFocus:I=>I.preventDefault(),onCloseAutoFocus:I=>I.preventDefault(),className:`p-2 bg-background/95 backdrop-blur-md border border-cyan-500/30 rounded-sm z-[100] ${F?"w-64":"w-52"}`,children:s.jsx("div",{className:"flex flex-col gap-1",children:F?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"px-3 py-2 space-y-2",children:[s.jsx("div",{className:"text-[10px] font-mono text-violet-400/70 uppercase tracking-wider",children:"Pause reason"}),s.jsx("textarea",{id:"pause-reason-mobile",ref:te,value:q,onChange:I=>K(I.target.value),onKeyDown:I=>{I.key==="Enter"&&!I.shiftKey&&(I.preventDefault(),(async()=>await _e()&&(se(!1),b(!1)))())},placeholder:"Why are you pausing?",rows:4,className:"w-full px-2 py-2 text-sm font-mono leading-relaxed bg-background/60 border border-violet-500/30 rounded-sm text-foreground placeholder:text-muted-foreground/50 focus:outline-none focus:border-violet-400/60 resize-none"})]}),s.jsxs("div",{className:"flex items-center gap-2 px-3 pb-1",children:[s.jsx("button",{onClick:()=>se(!1),className:"flex-1 px-3 py-2 rounded-sm text-xs font-display font-bold uppercase tracking-wider text-muted-foreground hover:text-foreground hover:bg-muted/20 transition-colors cursor-pointer",children:"Back"}),s.jsx("button",{onClick:()=>{(async()=>await _e()&&(se(!1),b(!1)))()},disabled:!q.trim(),className:"flex-1 px-3 py-2 rounded-sm text-xs font-display font-bold uppercase tracking-wider text-violet-400 border border-violet-500/30 hover:bg-violet-500/10 hover:border-violet-400 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",children:"Pause"})]})]}):s.jsxs(s.Fragment,{children:[X&&s.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 mx-1 mb-1 rounded-sm border border-cyan-500/30 bg-cyan-500/10",children:[s.jsx(Kn,{size:14,className:"text-cyan-400"}),s.jsx("span",{className:"text-xs font-display font-bold uppercase tracking-wider text-cyan-400",children:"Imported · Read-only"})]}),r&&(m?s.jsxs("button",{onClick:()=>{r(),b(!1)},className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-sm text-amber-400 text-sm font-display font-bold uppercase tracking-wider hover:bg-amber-500/10 transition-colors cursor-pointer",children:[n?s.jsx(qr,{size:16}):s.jsx(Wr,{size:16}),s.jsx("span",{children:n?"Hide History":"History"})]}):s.jsx(Ot,{children:s.jsxs(Ke,{children:[s.jsx(Qe,{asChild:!0,children:s.jsxs("button",{disabled:!0,className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-sm text-amber-400 text-sm font-display font-bold uppercase tracking-wider disabled:opacity-50 disabled:cursor-not-allowed",children:[n?s.jsx(qr,{size:16}):s.jsx(Wr,{size:16}),s.jsx("span",{children:n?"Hide History":"History"})]})}),s.jsx(qe,{children:s.jsx("p",{children:"Unlock turn-by-turn session timeline, milestones, and progress tracking"})})]})})),t&&s.jsxs("button",{onClick:()=>{J(),setTimeout(()=>b(!1),500)},className:`flex items-center gap-3 w-full px-3 py-2.5 rounded-sm text-sm font-display font-bold uppercase tracking-wider transition-colors cursor-pointer ${P?"text-green-400 bg-green-500/10":"text-blue-400 hover:bg-blue-500/10"}`,children:[P?s.jsx(Oe,{size:16}):s.jsx(Vt,{size:16}),s.jsx("span",{children:P?"Copied!":"Copy ID"})]}),ge?s.jsxs("button",{onClick:()=>{(async()=>await A()&&b(!1))()},disabled:!t,className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-sm text-violet-400 text-sm font-display font-bold uppercase tracking-wider hover:bg-violet-500/10 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",children:[s.jsx(Gt,{size:16}),s.jsx("span",{children:"Resume"})]}):s.jsxs("button",{onClick:()=>se(!0),disabled:!t,className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-sm text-violet-400 text-sm font-display font-bold uppercase tracking-wider hover:bg-violet-500/10 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",children:[s.jsx(ki,{size:16}),s.jsx("span",{children:"Pause"})]}),s.jsxs("button",{onClick:()=>{ne(),b(!1)},disabled:!t||$,className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-sm text-cyan-400 text-sm font-display font-bold uppercase tracking-wider hover:bg-cyan-500/10 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",children:[$?s.jsx(Ae,{size:16,className:"animate-spin"}):s.jsx(Ao,{size:16}),s.jsx("span",{children:"Export"})]}),s.jsxs("button",{onClick:()=>{O(),b(!1)},disabled:!t,className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-sm text-rose-400 text-sm font-display font-bold uppercase tracking-wider hover:bg-rose-500/10 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",children:[s.jsx(tn,{size:16}),s.jsx("span",{children:e?"Restore":"Archive"})]}),s.jsx("div",{className:"border-t border-border/30 my-1"}),l&&s.jsxs("button",{onClick:()=>{l(),b(!1)},className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-sm text-muted-foreground text-sm font-display font-bold uppercase tracking-wider hover:bg-cyan-500/10 hover:text-cyan-400 transition-colors cursor-pointer",children:[s.jsx(as,{size:16}),s.jsx("span",{children:"Feedback"})]}),s.jsxs("button",{onClick:()=>{N(!0),b(!1)},className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-sm text-cyan-400 text-sm font-display font-bold uppercase tracking-wider hover:bg-cyan-500/10 transition-colors cursor-pointer",children:[s.jsx(Js,{size:16}),s.jsxs("span",{children:["Notes",S>0?` (${S})`:""]})]}),s.jsxs("button",{onClick:()=>{v(!0),b(!1)},className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-sm text-muted-foreground text-sm font-display font-bold uppercase tracking-wider hover:bg-cyan-500/10 hover:text-cyan-400 transition-colors cursor-pointer",children:[s.jsx(Mo,{size:16}),s.jsx("span",{children:"Settings"})]})]})})})]})]})]}),s.jsx(W2,{isOpen:y,onClose:()=>v(!1)}),s.jsx(Dp,{isOpen:w,onClose:E,onLaunchSession:R,defaultProvider:"claude",defaultPermissionMode:f?.defaultPermissionMode,initialProvider:V?.activeProvider||V?.latestProvider||void 0,initialPermissionMode:V?.permissionMode||void 0})]})}const zp=u.createContext(null);function Fp(){const t=u.useContext(zp);if(!t)throw new Error("useToast must be used within ToastProvider");return t}function nj({toast:t,onDismiss:e}){const[n,r]=u.useState(!1);u.useEffect(()=>{if(t.duration!==0){const c=setTimeout(e,t.duration||5e3);return()=>clearTimeout(c)}},[t.duration,e]);const o=async c=>{if(c.stopPropagation(),t.copyUrl){const d=window.location.origin+t.copyUrl;await navigator.clipboard.writeText(d),r(!0),setTimeout(()=>r(!1),2e3)}},a={success:"border-emerald-500/50",error:"border-red-500/50",info:"border-cyan-500/50"}[t.type],i={success:"text-emerald-400",error:"text-red-400",info:"text-cyan-400"}[t.type],l={success:Oe,error:Es,info:Es}[t.type];return s.jsxs("div",{className:`
|
|
190
|
+
Mark each note as addressed as you complete it.`,r}async function Lp(t,e,n,r,o={}){if(e.length===0&&n.length===0)return null;const a=Y2(e,n),i=o.provider||"claude",l=o.model;return Q2({prompt:a,provider:i,model:l,workspace:o.workspace,workingDirectory:r,permissionMode:o.permissionMode,createdAt:new Date().toISOString()}),t.createConversation({provider:i,message:a,workingDirectory:r,model:l,permissionMode:o.permissionMode,workspace:o.workspace})}const Op="claudia-last-permission-mode";function pa(t,e){const n=t==="acceptEdits"?"acceptEdits":t==="bypassPermissions"?"bypassPermissions":"default";return e==="claude"&&n==="acceptEdits"?"default":n}function J2(t,e){try{const n=localStorage.getItem(Op);if(n==="default"||n==="acceptEdits"||n==="bypassPermissions")return pa(n,e)}catch{}return pa(t,e)}function pn(t){const{explicit:e,fallback:n,provider:r}=t;return typeof e=="string"&&e.length>0?pa(e,r):J2(n,r)}function ma(t){try{localStorage.setItem(Op,t)}catch{}}const nl={codebase:{icon:ka,text:"text-emerald-400",bg:"bg-emerald-500/10"},project_instructions:{icon:Io,text:"text-sky-400",bg:"bg-sky-500/10"},global_instructions:{icon:ja,text:"text-purple-400",bg:"bg-purple-500/10"}};function rl(t){const e=new Date(t),r=new Date().getTime()-e.getTime(),o=Math.floor(r/6e4),a=Math.floor(r/36e5),i=Math.floor(r/864e5);return o<1?"just now":o<60?`${o}m`:a<24?`${a}h`:i<7?`${i}d`:e.toLocaleDateString()}function ol(t){return[...t].sort((e,n)=>new Date(n.createdAt).getTime()-new Date(e.createdAt).getTime())}function Dp({isOpen:t,onClose:e,onLaunchSession:n,defaultProvider:r="claude",defaultPermissionMode:o,initialProvider:a,initialPermissionMode:i}){const l=Nt(),[c,d]=u.useState([]),[p,m]=u.useState([]),[h,g]=u.useState(()=>{try{return localStorage.getItem("lattice-dev-note-draft")||""}catch{return""}}),f=K=>{g(K);try{K?localStorage.setItem("lattice-dev-note-draft",K):localStorage.removeItem("lattice-dev-note-draft")}catch{}},[x,b]=u.useState(!1),[y,v]=u.useState(!1),[w,N]=u.useState(!1),[S,T]=u.useState(null),[C,j]=u.useState(a||r),[E,A]=u.useState(()=>pn({explicit:i,fallback:o,provider:a||r})),[L,$]=u.useState(null),[oe,ne]=u.useState(""),[B,Q]=u.useState(!1),[q,Z]=u.useState(null),[me,O]=u.useState(null),W=u.useRef(null),ee=ol(c),z=c.length+p.length,re=u.useMemo(()=>{const K=new Map;for(const fe of p){const M=fe.sourceProject||"General";K.has(M)||K.set(M,[]),K.get(M).push(fe)}return[...K.entries()]},[p]);u.useEffect(()=>{t&&(N(!1),T(null),$(null),ne(""),a&&j(a),i&&A(pn({explicit:i,fallback:o,provider:a||r})),O(go()?.prompt||null),te(),setTimeout(()=>W.current?.focus(),100))},[t,a,i,o,r]),u.useEffect(()=>{C==="claude"&&E==="acceptEdits"&&(A("default"),ma("default"))},[C,E]);const se=u.useCallback(async()=>{const K=me||go()?.prompt;if(!K)return;try{if(navigator?.clipboard?.writeText){await navigator.clipboard.writeText(K);return}}catch{}const fe=document.createElement("textarea");fe.value=K,fe.style.position="fixed",fe.style.left="-9999px",fe.style.top="-9999px",document.body.appendChild(fe),fe.focus(),fe.select(),document.execCommand("copy"),document.body.removeChild(fe)},[me]),te=async()=>{b(!0),Z(null);try{const[K,fe]=await Promise.all([H.getDevNotes(),H.getPendingRecommendations()]);d(ol(K.notes)),m(fe.recommendations)}catch(K){Z("Failed to load queue"),console.error("Failed to fetch action queue:",K)}finally{b(!1)}},xe=u.useCallback(async()=>{if(!(!h.trim()||y)){v(!0),Z(null);try{await H.createDevNote({content:h.trim()}),f(""),await te()}catch(K){Z("Failed to create note"),console.error("Failed to create dev note:",K)}finally{v(!1)}}},[h,y]),_e=K=>{K.key==="Enter"&&!K.shiftKey&&(K.preventDefault(),xe())},I=async K=>{try{await H.updateDevNoteStatus(K,"done"),L===K&&($(null),ne("")),d(fe=>fe.filter(M=>M.id!==K))}catch(fe){console.error("Failed to mark note as done:",fe)}},P=async K=>{try{await H.deleteDevNote(K),L===K&&($(null),ne("")),d(fe=>fe.filter(M=>M.id!==K))}catch(fe){console.error("Failed to delete note:",fe)}},de=u.useCallback(K=>{$(K.id),ne(K.content)},[]),X=u.useCallback(()=>{$(null),ne("")},[]),G=u.useCallback(async()=>{if(!L||B)return;const K=oe.trim();if(!K){Z("Note content cannot be empty");return}Q(!0),Z(null);try{await H.updateDevNote(L,{content:K}),d(fe=>fe.map(M=>M.id===L?{...M,content:K}:M)),X()}catch(fe){Z("Failed to update note"),console.error("Failed to update dev note:",fe)}finally{Q(!1)}},[L,oe,B,X]),V=async K=>{try{await H.completeRecommendation(K),m(fe=>fe.filter(M=>M.id!==K))}catch(fe){console.error("Failed to complete recommendation:",fe)}},D=async K=>{try{await H.dismissRecommendation(K),m(fe=>fe.filter(M=>M.id!==K))}catch(fe){console.error("Failed to dismiss recommendation:",fe)}},be=u.useCallback(async()=>{if(S){e(),l(`/c/${S}`);return}if(!(z===0||!n||w)){N(!0),Z(null);try{const K=await n(c,p,C,E);K?.sessionId?T(K.sessionId):Z("Session started but no session ID was returned")}catch(K){Z("Failed to start session"),O(go()?.prompt||null),console.error("Failed to launch queue session:",K)}finally{N(!1)}}},[S,z,n,w,c,p,e,l,C,E]),Ce=u.useCallback(K=>{A(K),ma(K)},[]),je=[{mode:"default",label:"Ask",icon:Ms,activeClasses:"bg-cyan-500/20 text-cyan-300 border border-cyan-500/40",description:"Prompt before every tool use."},{mode:"bypassPermissions",label:"Trust",icon:mr,activeClasses:"bg-amber-500/20 text-amber-300 border border-amber-500/40",description:"Skip all permission prompts. Runs freely with no restrictions."}],Ee=()=>ee.length===0?null:s.jsxs("div",{className:"mb-1",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1",children:[s.jsx(Js,{size:10,className:"text-amber-400"}),s.jsx("span",{className:"text-[10px] font-display font-bold uppercase tracking-wider text-amber-400",children:"Notes"})]}),s.jsx("div",{className:"space-y-0.5",children:ee.map(K=>s.jsxs("div",{className:"group px-3 py-1.5 hover:bg-muted/20 transition-colors",children:[L===K.id?s.jsxs("div",{className:"space-y-2",children:[s.jsx("input",{value:oe,onChange:fe=>ne(fe.target.value),className:"w-full px-2 py-1.5 text-sm font-mono bg-background/60 border border-cyan-500/30 rounded-sm text-foreground focus:outline-none focus:border-cyan-400/60",onKeyDown:fe=>{fe.key==="Enter"&&!fe.shiftKey&&(fe.preventDefault(),G())}}),s.jsx("div",{className:"flex items-center justify-end gap-1",children:s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>{G()},disabled:B||!oe.trim(),className:"p-1 text-muted-foreground/50 hover:text-emerald-400 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",title:"Save note",children:B?s.jsx(Re,{size:12,className:"animate-spin"}):s.jsx(Oe,{size:12})}),s.jsx("button",{onClick:X,disabled:B,className:"p-1 text-muted-foreground/50 hover:text-rose-400 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",title:"Cancel edit",children:s.jsx(Be,{size:12})})]})})]}):s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("p",{className:"flex-1 min-w-0 text-sm font-mono text-foreground/80 leading-snug break-words",children:K.content}),s.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0 pt-0.5",children:[s.jsx("span",{className:"hidden sm:inline text-[10px] font-mono text-muted-foreground/30 opacity-0 group-hover:opacity-100 transition-opacity",children:rl(K.createdAt)}),s.jsxs("div",{className:"flex gap-1 opacity-100 sm:opacity-0 sm:group-hover:opacity-100 transition-opacity",children:[s.jsx("button",{onClick:()=>de(K),className:"p-1 text-muted-foreground/50 hover:text-cyan-400 cursor-pointer",title:"Edit note",children:s.jsx(va,{size:12})}),s.jsx("button",{onClick:()=>{I(K.id)},className:"p-1 text-muted-foreground/50 hover:text-emerald-400 cursor-pointer",title:"Mark done",children:s.jsx(Oe,{size:12})}),s.jsx("button",{onClick:()=>{P(K.id)},className:"p-1 text-muted-foreground/50 hover:text-rose-400 cursor-pointer",title:"Delete note",children:s.jsx(Lo,{size:12})})]})]})]}),s.jsx("div",{className:"h-0.5"})]},K.id))})]});return t?s.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center",style:{paddingTop:"calc(env(safe-area-inset-top, 0px) + 10vh)",paddingRight:"calc(env(safe-area-inset-right, 0px) + 1rem)",paddingBottom:"calc(env(safe-area-inset-bottom, 0px) + 1rem)",paddingLeft:"calc(env(safe-area-inset-left, 0px) + 1rem)"},children:[s.jsx("button",{type:"button",className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:e,"aria-label":"Close queue dialog"}),s.jsxs("div",{className:"relative z-10 w-full max-w-md mx-4 bg-background border border-border rounded-sm shadow-xl overflow-hidden max-h-[80vh] flex flex-col",children:[s.jsx("div",{className:"absolute inset-0 bg-[linear-gradient(rgba(0,255,255,0.02)_1px,transparent_1px),linear-gradient(90deg,rgba(0,255,255,0.02)_1px,transparent_1px)] bg-[size:16px_16px] pointer-events-none"}),s.jsxs("div",{className:"relative border-b border-border/50",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Js,{size:14,className:"text-cyan-400"}),s.jsx("span",{className:"text-[10px] font-display font-bold text-cyan-400 uppercase tracking-wider",children:"Action Queue"})]}),z>0&&s.jsx("div",{className:"flex items-center gap-1",children:p.length>0&&s.jsx("span",{className:"min-w-[18px] h-[18px] flex items-center justify-center text-[9px] font-bold bg-purple-500/20 text-purple-400 border border-purple-500/30 rounded-sm",children:p.length})})]}),s.jsx("button",{onClick:e,className:"p-1 text-muted-foreground hover:text-cyan-400 transition-colors cursor-pointer",children:s.jsx(Be,{size:14})})]}),s.jsx("p",{className:"px-4 pb-2 text-[11px] leading-relaxed text-muted-foreground/70",children:"Backlog for future sessions. Items stay here until you start a dedicated session. This is separate from the per-session message queue in the composer."})]}),s.jsx("div",{className:"relative px-4 py-3 border-b border-border/30",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{ref:W,value:h,onChange:K=>f(K.target.value),onKeyDown:_e,placeholder:"Add a note...",className:"flex-1 px-3 py-1.5 bg-background/50 border border-border/50 rounded-sm text-sm font-mono placeholder:text-muted-foreground/40 focus:outline-none focus:border-cyan-500/50"}),s.jsx("button",{onClick:()=>{xe()},disabled:!h.trim()||y,className:"px-2.5 py-1.5 rounded-sm border border-cyan-500/30 text-cyan-400 hover:bg-cyan-500/10 hover:border-cyan-400 transition-all cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",children:y?s.jsx(Re,{size:14,className:"animate-spin"}):s.jsx(Kl,{size:14})})]})}),s.jsx("div",{className:"relative flex-1 overflow-y-auto p-2 min-h-[150px] max-h-96 flex flex-col",children:x?s.jsx("div",{className:"flex flex-1 items-center justify-center py-8",children:s.jsx(Re,{size:20,className:"animate-spin text-muted-foreground"})}):q?s.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 py-8 text-rose-400",children:[s.jsxs("div",{className:"flex items-center justify-center gap-2",children:[s.jsx(Es,{size:16}),s.jsx("span",{className:"text-sm font-mono",children:q})]}),me&&s.jsx("button",{onClick:()=>{se()},className:"px-2 py-1 rounded-sm border border-rose-500/30 text-[10px] font-mono font-bold uppercase tracking-wider hover:bg-rose-500/10 hover:border-rose-400 cursor-pointer",children:"Copy Last Prompt"})]}):z===0?s.jsxs("div",{className:"flex flex-1 min-h-[220px] flex-col items-center justify-center py-8 text-center text-muted-foreground/50",children:[s.jsx(Js,{size:24,className:"mb-2 opacity-50"}),s.jsx("span",{className:"text-sm font-mono",children:"Action queue empty"}),s.jsx("span",{className:"text-xs font-mono mt-1",children:"Add a note above, or review a session to generate recommendations"})]}):s.jsxs(s.Fragment,{children:[Ee(),p.length>0&&s.jsxs(s.Fragment,{children:[c.length>0&&s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 mt-2",children:[s.jsx("div",{className:"flex-1 border-t border-purple-500/20"}),s.jsx("span",{className:"text-[9px] font-mono font-bold text-purple-400/60 uppercase tracking-wider",children:"ai"}),s.jsx("div",{className:"flex-1 border-t border-purple-500/20"})]}),s.jsxs("div",{className:"mb-1",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1",children:[s.jsx(fh,{size:10,className:"text-purple-400"}),s.jsx("span",{className:"text-[10px] font-mono font-bold uppercase tracking-wider text-purple-400",children:"Recommendations"}),s.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground/30",children:["(",p.length,")"]})]}),re.map(([K,fe])=>s.jsxs("div",{className:"mb-2",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5",children:[s.jsx("span",{className:"text-[10px] font-display font-bold uppercase tracking-wider text-cyan-400/70",children:K}),s.jsx("span",{className:"text-[10px] font-mono text-muted-foreground/20",children:fe.length})]}),s.jsx("div",{className:"space-y-0.5",children:fe.map(M=>{const Y=nl[M.target]||nl.codebase,U=Y.icon,ie=M.friction?(()=>{const ye=K2(M.friction).friction,he=ye.match(/^[^.!?]+[.!?]/)?.[0]||ye;return he.length>140?he.slice(0,140)+"...":he})():"";return s.jsxs("div",{className:"group px-3 py-2 hover:bg-muted/20 transition-colors",children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("div",{className:`p-1 rounded ${Y.bg} flex-shrink-0 mt-0.5`,children:s.jsx(U,{size:10,className:Y.text})}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("p",{className:"text-sm font-mono text-foreground/80 leading-snug",children:M.action})})]}),ie&&s.jsx("p",{className:"text-[11px] font-mono text-muted-foreground/40 mt-1 pl-7 leading-snug line-clamp-2",children:ie}),s.jsxs("div",{className:"flex items-center gap-2 mt-1.5 pl-7",children:[s.jsx("span",{className:"text-[10px] font-mono text-muted-foreground/30",children:rl(M.createdAt)}),M.sessionId&&s.jsxs("button",{onClick:()=>{e(),l(`/c/${M.sessionId}`)},className:"flex items-center gap-1 text-[10px] font-mono text-muted-foreground/30 hover:text-cyan-400/70 transition-colors cursor-pointer",title:M.sourceMission||"View source session",children:[s.jsx(os,{size:9}),s.jsx("span",{className:"truncate max-w-[160px]",children:M.sourceMission||"session"})]}),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[s.jsx("button",{onClick:()=>{V(M.id)},className:"p-1 text-muted-foreground/50 hover:text-emerald-400 cursor-pointer",title:"Mark complete",children:s.jsx(Oe,{size:12})}),s.jsx("button",{onClick:()=>{D(M.id)},className:"p-1 text-muted-foreground/50 hover:text-rose-400 cursor-pointer",title:"Dismiss",children:s.jsx(Lo,{size:12})})]})]})]},M.id)})})]},K))]})]})]})}),z>0&&n&&s.jsxs("div",{className:"relative px-4 py-2.5 border-t border-border/30 space-y-2",children:[!S&&s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:s.jsx("div",{className:"flex items-center rounded-sm border border-zinc-700/50 bg-zinc-900/50 p-0.5",children:je.map(({mode:K,label:fe,icon:M,activeClasses:Y,description:U})=>{const ie=E===K;return s.jsxs("button",{onClick:()=>Ce(K),disabled:w,title:U,className:`flex items-center gap-1 px-2 py-1 rounded-sm text-[10px] font-display font-bold uppercase tracking-wider transition-all duration-100 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed ${ie?Y:"text-zinc-500 hover:text-zinc-400 border border-transparent"}`,children:[s.jsx(M,{size:10}),fe]},K)})})}),s.jsx("button",{onClick:()=>{be()},disabled:w,className:"w-full flex items-center justify-center gap-2 py-1.5 rounded-sm ui-action-btn ui-action-btn--cool text-[10px] font-display font-bold uppercase tracking-wider bg-background/80 backdrop-blur-sm disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:shadow-none disabled:hover:translate-x-0 disabled:hover:translate-y-0",children:w?s.jsxs(s.Fragment,{children:[s.jsx(Re,{size:12,className:"animate-spin"}),"Starting Session..."]}):S?s.jsxs(s.Fragment,{children:[s.jsx(Gt,{size:12}),"Go to Session"]}):s.jsxs(s.Fragment,{children:[s.jsx(Gt,{size:12}),"Start Session"]})})]})]})]}):null}const X2=200,oi=["conversations","archived-sidebar"];function Z2(t){const{enabled:e}=t,{data:n,isLoading:r}=Mt({queryKey:oi,queryFn:async()=>((await H.listUnifiedConversations({archived:!0,includeIdentityImage:!1,limit:X2})).conversations||[]).filter(a=>a.archived).sort((a,i)=>new Date(i.updatedAt).getTime()-new Date(a.updatedAt).getTime()),enabled:e,staleTime:6e4,refetchOnWindowFocus:!1});return{archivedSessions:n||[],isLoading:r}}function ej(t,e){if(!t)return t;const n=t.conversations.filter(r=>r.conversationId!==e);return n.length===t.conversations.length?t:{...t,conversations:n,total:Math.max(0,t.total-1)}}function Dn(t,e,n){return t+(e-t)*n}function Ws(t,e,n){return[Dn(t[0],e[0],n),Dn(t[1],e[1],n),Dn(t[2],e[2],n),Dn(t[3],e[3],n)]}function ct(t){return`rgba(${Math.round(t[0])},${Math.round(t[1])},${Math.round(t[2])},${t[3].toFixed(3)})`}const xo=[120,120,130,.2],et=[251,191,36,.8],Ks=[52,211,153,1];function tj(t){if(t>=2)return{strokeColor:ct(Ks),fillColor:ct(Ks),fillOpacity:.6,borderColor:ct(Ks),textColor:ct(Ks),bgColor:"rgba(16,185,129,0.08)",scanning:!1,glowOpacity:.04};if(t>=1){const l=t-1,c=Ws(et,Ks,l*.3);return{strokeColor:ct(c),fillColor:ct(c),fillOpacity:.6,borderColor:ct([c[0],c[1],c[2],.4]),textColor:ct([c[0],c[1],c[2],.8]),bgColor:"transparent",scanning:!0,glowOpacity:0}}const e=Math.max(0,Math.min(t,.99)),n=Ws(xo,[et[0],et[1],et[2],.45],e),r=Ws(xo,[et[0],et[1],et[2],.55],e),o=e*e*.55,a=Math.max(0,(e-.5)*2),i=Ws([120,120,130,0],[et[0],et[1],et[2],a*.2],a);return{strokeColor:ct(n),fillColor:ct(r),fillOpacity:o,borderColor:ct(i),textColor:ct(Ws(xo,[et[0],et[1],et[2],.5],e*.6)),bgColor:"transparent",scanning:!1,glowOpacity:0}}function ha({status:t,isLoading:e=!1,disabled:n=!1,onClick:r}){const o=!!t?.synthesisInProgress,a=t?.pendingProposals??0,i=t?.threshold?Math.min((t.pendingExtractions??0)/t.threshold,1):0,l=a>0?2:o?1:i,c=tj(l),d=e?"Checking status...":o?"Reviewing recent sessions for patterns worth acting on":a>0?`${a} proposed change${a===1?"":"s"} based on patterns across recent sessions`:i>0?`${t?.pendingExtractions}/${t?.threshold} sessions toward next analysis`:"Lattice watches how you work across sessions and proposes changes when it spots patterns";return s.jsxs(Ke,{children:[s.jsx(Qe,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:r,disabled:n,"aria-label":"Cross-session insights",className:`group relative flex items-center gap-2 px-3 py-1.5 max-sm:h-10 rounded-sm text-[10px] font-display font-bold uppercase tracking-wider transition-all duration-300 overflow-hidden ${a>0?"hover:shadow-[2px_2px_0_rgba(16,185,129,0.5),-2px_-2px_0_rgba(34,211,238,0.25)] hover:translate-x-[-1px] hover:translate-y-[-1px]":""} disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:shadow-none disabled:hover:translate-x-0 disabled:hover:translate-y-0`,style:{borderWidth:1,borderStyle:"solid",borderColor:c.borderColor,color:c.textColor,backgroundColor:c.bgColor},children:[c.scanning&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"absolute top-0 left-0 h-[1px] w-full animate-[insight-scan_1.5s_linear_infinite]",style:{background:`linear-gradient(to right, transparent, ${c.strokeColor}, transparent)`}}),s.jsx("span",{className:"absolute bottom-0 right-0 h-[1px] w-full animate-[insight-scan_1.5s_linear_infinite_0.75s]",style:{background:`linear-gradient(to right, transparent, ${ct([et[0],et[1],et[2],.4])}, transparent)`}})]}),s.jsxs("svg",{viewBox:"0 0 12 12",className:"w-3 h-3 transition-all duration-500","aria-hidden":"true",children:[s.jsx("path",{d:"M6 1 L11 6 L6 11 L1 6 Z",fill:"none",stroke:c.strokeColor,strokeWidth:"1.2"}),c.fillOpacity>.01&&s.jsx("path",{d:"M6 3.5 L8.5 6 L6 8.5 L3.5 6 Z",fill:c.fillColor,opacity:c.fillOpacity})]}),a>0&&s.jsx("span",{className:"relative",children:a}),c.glowOpacity>0&&s.jsx("span",{className:"absolute inset-0 rounded-sm",style:{backgroundColor:`rgba(52,211,153,${c.glowOpacity})`}})]})}),s.jsx(qe,{children:s.jsx("p",{children:d})})]})}function $p({count:t,onClick:e}){return s.jsxs(Ke,{children:[s.jsx(Qe,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:e,"aria-label":"Notes",className:"relative flex items-center gap-2 p-1.5 min-[1440px]:px-3 min-[1440px]:py-1.5 bg-background/80 backdrop-blur-sm ui-action-btn ui-action-btn--cool text-[10px] font-display font-bold uppercase tracking-wider",children:[s.jsx(Js,{size:14}),s.jsx("span",{className:"hidden min-[1440px]:inline",children:"NOTES"}),t>0&&s.jsx("span",{className:"min-w-[16px] h-[16px] px-1 flex items-center justify-center rounded-full bg-cyan-400/15 border border-cyan-400/30 text-[9px] leading-none text-cyan-300 pb-px pl-0.5",children:t>99?"99+":t})]})}),s.jsx(qe,{side:"bottom",align:"end",className:"max-w-[300px]",children:"Action queue for future work: notes and review recommendations stay here until you launch a separate session. This is different from the composer message queue."})]})}function sj({sessionId:t,isArchived:e=!1,insightsPanelOpen:n,onToggleInsightsPanel:r,crossSessionSidebarOpen:o,onToggleCrossSessionSidebar:a,onOpenCrossSessionAnalysis:i,onOpenFeedbackPanel:l}){const c=Nt(),d=mn(),p=$l(),{isPro:m}=yn(),{conversations:h,invalidateConversations:g}=$s(),{serverConfig:f}=zs(),[x,b]=u.useState(!1),[y,v]=u.useState(!1),[w,N]=u.useState(!1),[S,T]=u.useState(0),C=!1;u.useEffect(()=>{const V=async()=>{try{const[be,Ce]=await Promise.all([H.getDevNotes(),H.getPendingRecommendations()]);T(be.notes.length+Ce.recommendations.length)}catch{}};V();const D=setInterval(()=>{V()},3e4);return()=>clearInterval(D)},[]);const j=u.useCallback(()=>{N(!1),Promise.all([H.getDevNotes(),H.getPendingRecommendations()]).then(([V,D])=>T(V.notes.length+D.recommendations.length))},[]),E=u.useCallback(async(V,D,be,Ce)=>{if(V.length===0&&D.length===0)return;const je=be||"claude";try{const Ee=await Lp(H,V,D,f?.defaultWorkingDirectory||f?.cwd||"~",{workspace:"main",provider:je,model:f?.defaultModel,permissionMode:Ce||f?.defaultPermissionMode});return Ee?(await g(),{sessionId:Ee.conversationId}):null}catch(Ee){throw console.error("Failed to launch queue session:",Ee),Ee}},[g,f?.defaultWorkingDirectory,f?.cwd,f?.defaultModel,f?.defaultPermissionMode]),A=async()=>{if(t)try{await H.unifiedUpdateConversation(t,{archived:!e}),e||d.setQueriesData({predicate:V=>V.queryKey[0]==="conversations"&&V.queryKey[1]==="list"},V=>ej(V,t)),await Promise.all([g(),d.invalidateQueries({queryKey:oi})]),c("/",{replace:!0})}catch(V){console.error(`[Archive] Failed to ${e?"unarchive":"archive"} session:`,V)}},[L,$]=u.useState(!1),oe=async()=>{if(t){$(!0);try{await H.exportSession(t)}catch(V){console.error("Failed to export session:",V),alert(`Export failed: ${V instanceof Error?V.message:"Unknown error"}`)}finally{$(!1)}}},ne=h.find(V=>V.conversationId===t),B=!!ne?.importedAt,[Q,q]=u.useState(""),[Z,me]=u.useState(!1),[O,W]=u.useState(!1),[ee,z]=u.useState(!1),re=Ie.useRef(null),se=Ie.useRef(null),te=ne?.pausedReason;u.useEffect(()=>{if(t){if(te&&te.trim().length>0){me(!0),q(te);return}if(h.some(V=>V.conversationId===t)){me(!1);return}H.getConversationDetails(t,{limit:1}).then(V=>{const D=V?.sessionInfo?.paused_reason;me(!!D),D&&q(D)}).catch(()=>{})}},[t,te,h]),u.useEffect(()=>{O&&requestAnimationFrame(()=>re.current?.focus())},[O]),u.useEffect(()=>{ee&&requestAnimationFrame(()=>se.current?.focus())},[ee]);const xe=async()=>{if(!t||!Q.trim())return!1;try{return await H.unifiedUpdateConversation(t,{pausedReason:Q.trim()}),me(!0),W(!1),await g(),!0}catch(V){return console.error("Failed to pause session:",V),!1}},_e=async()=>{if(!t)return!1;try{return await H.unifiedUpdateConversation(t,{pausedReason:null}),me(!1),q(""),await g(),!0}catch(V){return console.error("Failed to resume session:",V),!1}},[I,P]=u.useState(!1),de=async()=>{if(t)try{if(navigator.clipboard?.writeText)await navigator.clipboard.writeText(t);else{const V=document.createElement("textarea");V.value=t,V.style.position="fixed",V.style.left="-9999px",V.style.top="-9999px",document.body.appendChild(V),V.focus(),V.select(),document.execCommand("copy"),document.body.removeChild(V)}P(!0),setTimeout(()=>P(!1),2e3)}catch(V){console.error("Failed to copy session ID:",V)}},X=p.pathname==="/analysis/cross-session",G=()=>{X?c(-1):i?i():c("/analysis/cross-session")};return s.jsxs(Ot,{children:[s.jsxs("div",{className:"flex justify-between items-center gap-3 px-4 py-3 border-b border-border/50 bg-background transition-colors relative overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 ui-grid-overlay pointer-events-none"}),s.jsxs("div",{className:"relative flex items-center gap-3",children:[a&&!o&&s.jsx("button",{onClick:a,"aria-label":"Open sessions sidebar",className:"p-1.5 ui-icon-btn ui-icon-btn--cool",children:s.jsx(Wl,{size:18})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(hp,{size:28,interactive:!0,colorScheme:"gradient"}),s.jsx("span",{className:"text-base font-display font-medium lowercase tracking-widest text-white",children:"lattice"}),s.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/30 select-none",children:"bfe47eb5"})]})]}),s.jsxs("div",{className:"relative hidden sm:flex items-center gap-1 md:gap-2 min-[1440px]:gap-2 flex-shrink-0",children:[B&&s.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-sm border border-cyan-500/30 bg-cyan-500/10",children:[s.jsx(Kn,{size:12,className:"text-cyan-400"}),s.jsx("span",{className:"text-[10px] font-display font-bold uppercase tracking-wider text-cyan-400",children:"Imported · Read-only"})]}),!e&&s.jsxs(s.Fragment,{children:[s.jsx(ha,{status:null,isLoading:C,disabled:!C,onClick:G}),l&&s.jsxs(Ke,{children:[s.jsx(Qe,{asChild:!0,children:s.jsxs("button",{onClick:l,"aria-label":"Send feedback",className:"flex items-center gap-2 px-3 py-1.5 rounded-sm border border-transparent text-muted-foreground/50 hover:text-muted-foreground/70 hover:border-border/20 text-[10px] font-display font-bold uppercase tracking-wider transition-all duration-100",children:[s.jsx(as,{size:12}),s.jsx("span",{className:"hidden min-[1440px]:inline",children:"FEEDBACK"})]})}),s.jsx(qe,{children:s.jsx("p",{children:"Report a bug or send a comment"})})]}),s.jsx("span",{className:"h-4 w-px bg-border/20 mx-2"})]}),Z?s.jsxs("button",{onClick:()=>{_e()},disabled:!t,"aria-label":"Resume session",className:"flex items-center gap-2 p-1.5 min-[1440px]:px-3 min-[1440px]:py-1.5 bg-background/80 backdrop-blur-sm ui-action-btn ui-action-btn--violet text-[10px] font-display font-bold uppercase tracking-wider disabled:opacity-50 disabled:cursor-not-allowed",children:[s.jsx(Gt,{size:14}),s.jsx("span",{className:"hidden min-[1440px]:inline",children:"RESUME"})]}):s.jsxs(Zc,{open:O,onOpenChange:W,children:[s.jsx(el,{asChild:!0,children:s.jsxs("button",{disabled:!t,"aria-label":"Pause session",className:"flex items-center gap-2 p-1.5 min-[1440px]:px-3 min-[1440px]:py-1.5 bg-background/80 backdrop-blur-sm ui-action-btn ui-action-btn--violet text-[10px] font-display font-bold uppercase tracking-wider disabled:opacity-50 disabled:cursor-not-allowed",children:[s.jsx(ki,{size:14}),s.jsx("span",{className:"hidden min-[1440px]:inline",children:"PAUSE"})]})}),s.jsx(ua,{side:"bottom",align:"end",className:"w-72 p-3 bg-zinc-900/95 backdrop-blur-sm border border-violet-500/20 shadow-[0_0_12px_rgba(139,92,246,0.15)]",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:"pause-reason-desktop",className:"text-[10px] font-mono text-violet-400/60 uppercase tracking-wider",children:"Pause reason"}),s.jsx("textarea",{id:"pause-reason-desktop",ref:re,value:Q,onChange:V=>q(V.target.value),onKeyDown:V=>{V.key==="Enter"&&!V.shiftKey&&(V.preventDefault(),xe())},placeholder:"Why are you pausing? (waiting for deploy, review, etc.)",className:"w-full px-2 py-2 text-[11px] leading-relaxed bg-zinc-800/50 border border-violet-500/20 rounded-sm text-zinc-200 placeholder:text-zinc-500 focus:outline-none focus:border-violet-400/40 resize-none",rows:3}),s.jsx("button",{onClick:()=>{xe()},disabled:!Q.trim(),className:"w-full px-3 py-1.5 text-[10px] font-display font-bold uppercase tracking-wider bg-violet-500/10 border border-violet-500/30 text-violet-400 rounded-sm hover:bg-violet-500/20 hover:border-violet-400 transition-all disabled:opacity-40 disabled:cursor-not-allowed",children:"Pause Session"})]})})]}),s.jsxs(Ke,{children:[s.jsx(Qe,{asChild:!0,children:s.jsxs("button",{onClick:()=>{oe()},disabled:!t||L,"aria-label":"Export session",className:"flex items-center gap-2 p-1.5 min-[1440px]:px-3 min-[1440px]:py-1.5 rounded-sm bg-background/80 backdrop-blur-sm border border-cyan-500/30 text-cyan-400 text-[10px] font-display font-bold uppercase tracking-wider hover:border-cyan-400 hover:bg-cyan-500/5 hover:shadow-[2px_2px_0_rgba(0,255,255,0.5),-2px_-2px_0_rgba(168,85,247,0.3)] hover:translate-x-[-1px] hover:translate-y-[-1px] transition-all duration-100 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:shadow-none disabled:hover:translate-x-0 disabled:hover:translate-y-0",children:[L?s.jsx(Re,{size:14,className:"animate-spin"}):s.jsx(Ao,{size:14}),s.jsx("span",{className:"hidden min-[1440px]:inline",children:"EXPORT"})]})}),s.jsx(qe,{children:s.jsx("p",{children:"Save a portable snapshot of this session — messages, tool calls, and metadata"})})]}),s.jsxs("button",{onClick:A,disabled:!t,"aria-label":e?"Unarchive Task":"Archive Task",className:"flex items-center gap-2 p-1.5 min-[1440px]:px-3 min-[1440px]:py-1.5 bg-background/80 backdrop-blur-sm ui-action-btn ui-action-btn--rose text-[10px] font-display font-bold uppercase tracking-wider disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:shadow-none disabled:hover:translate-x-0 disabled:hover:translate-y-0",children:[s.jsx(tn,{size:14}),s.jsx("span",{className:"hidden min-[1440px]:inline",children:e?"RESTORE":"ARCHIVE"})]}),s.jsx($p,{count:S,onClick:()=>N(!0)}),t&&s.jsxs(Ke,{children:[s.jsx(Qe,{asChild:!0,children:s.jsx("button",{onClick:de,"aria-label":"Copy session ID",className:`p-1.5 ui-icon-btn ${I?"border-green-400/50 text-green-300 bg-green-500/10":"ui-icon-btn--cool"}`,children:I?s.jsx(Oe,{size:16}):s.jsx(Vt,{size:16})})}),s.jsx(qe,{children:s.jsx("p",{children:I?"Copied!":"For linking to this session in notes, bugs, or conversations"})})]}),s.jsx("button",{onClick:()=>v(!0),"aria-label":"Settings",className:"p-1.5 ui-icon-btn ui-icon-btn--cool",children:s.jsx(Mo,{size:16})}),r&&(()=>{const V=m?n?null:"Turn-by-turn timeline of this session's progress":"Unlock turn-by-turn session timeline, milestones, and progress tracking",D=s.jsxs("button",{onClick:m?r:void 0,disabled:!m,"aria-label":n?"Hide history panel":"Show history panel",className:"flex items-center gap-2 p-1.5 min-[1440px]:px-3 min-[1440px]:py-1.5 bg-background/80 backdrop-blur-sm ui-action-btn ui-action-btn--amber text-[10px] font-display font-bold uppercase tracking-wider disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:shadow-none disabled:hover:translate-x-0 disabled:hover:translate-y-0",children:[n?s.jsx(qr,{size:14}):s.jsx(Wr,{size:14}),s.jsx("span",{className:"hidden min-[1440px]:inline",children:n?"HIDE":"HISTORY"})]});return V?s.jsxs(Ke,{children:[s.jsx(Qe,{asChild:!0,children:D}),s.jsx(qe,{children:s.jsx("p",{children:V})})]}):D})()]}),s.jsxs("div",{className:"relative flex items-center gap-3 sm:hidden",children:[e?null:s.jsx("div",{className:"mr-3",children:s.jsx(ha,{status:null,isLoading:C,disabled:!C,onClick:G})}),s.jsxs(Zc,{open:x,onOpenChange:V=>{b(V),V||z(!1)},children:[s.jsx(el,{asChild:!0,children:s.jsx("button",{type:"button",className:"relative flex items-center justify-center w-10 h-10 bg-background/80 backdrop-blur-sm ui-action-btn ui-action-btn--cool active:bg-cyan-500/10 touch-manipulation","aria-label":"Menu",children:x?s.jsx(Be,{size:20}):s.jsx(Ef,{size:20})})}),s.jsx(ua,{align:"end",sideOffset:8,onOpenAutoFocus:V=>V.preventDefault(),onCloseAutoFocus:V=>V.preventDefault(),className:`p-2 bg-background/95 backdrop-blur-md border border-cyan-500/30 rounded-sm z-[100] ${ee?"w-64":"w-52"}`,children:s.jsx("div",{className:"flex flex-col gap-1",children:ee?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"px-3 py-2 space-y-2",children:[s.jsx("div",{className:"text-[10px] font-mono text-violet-400/70 uppercase tracking-wider",children:"Pause reason"}),s.jsx("textarea",{id:"pause-reason-mobile",ref:se,value:Q,onChange:V=>q(V.target.value),onKeyDown:V=>{V.key==="Enter"&&!V.shiftKey&&(V.preventDefault(),(async()=>await xe()&&(z(!1),b(!1)))())},placeholder:"Why are you pausing?",rows:4,className:"w-full px-2 py-2 text-sm font-mono leading-relaxed bg-background/60 border border-violet-500/30 rounded-sm text-foreground placeholder:text-muted-foreground/50 focus:outline-none focus:border-violet-400/60 resize-none"})]}),s.jsxs("div",{className:"flex items-center gap-2 px-3 pb-1",children:[s.jsx("button",{onClick:()=>z(!1),className:"flex-1 px-3 py-2 rounded-sm text-xs font-display font-bold uppercase tracking-wider text-muted-foreground hover:text-foreground hover:bg-muted/20 transition-colors cursor-pointer",children:"Back"}),s.jsx("button",{onClick:()=>{(async()=>await xe()&&(z(!1),b(!1)))()},disabled:!Q.trim(),className:"flex-1 px-3 py-2 rounded-sm text-xs font-display font-bold uppercase tracking-wider text-violet-400 border border-violet-500/30 hover:bg-violet-500/10 hover:border-violet-400 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",children:"Pause"})]})]}):s.jsxs(s.Fragment,{children:[B&&s.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 mx-1 mb-1 rounded-sm border border-cyan-500/30 bg-cyan-500/10",children:[s.jsx(Kn,{size:14,className:"text-cyan-400"}),s.jsx("span",{className:"text-xs font-display font-bold uppercase tracking-wider text-cyan-400",children:"Imported · Read-only"})]}),r&&(m?s.jsxs("button",{onClick:()=>{r(),b(!1)},className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-sm text-amber-400 text-sm font-display font-bold uppercase tracking-wider hover:bg-amber-500/10 transition-colors cursor-pointer",children:[n?s.jsx(qr,{size:16}):s.jsx(Wr,{size:16}),s.jsx("span",{children:n?"Hide History":"History"})]}):s.jsx(Ot,{children:s.jsxs(Ke,{children:[s.jsx(Qe,{asChild:!0,children:s.jsxs("button",{disabled:!0,className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-sm text-amber-400 text-sm font-display font-bold uppercase tracking-wider disabled:opacity-50 disabled:cursor-not-allowed",children:[n?s.jsx(qr,{size:16}):s.jsx(Wr,{size:16}),s.jsx("span",{children:n?"Hide History":"History"})]})}),s.jsx(qe,{children:s.jsx("p",{children:"Unlock turn-by-turn session timeline, milestones, and progress tracking"})})]})})),t&&s.jsxs("button",{onClick:()=>{de(),setTimeout(()=>b(!1),500)},className:`flex items-center gap-3 w-full px-3 py-2.5 rounded-sm text-sm font-display font-bold uppercase tracking-wider transition-colors cursor-pointer ${I?"text-green-400 bg-green-500/10":"text-blue-400 hover:bg-blue-500/10"}`,children:[I?s.jsx(Oe,{size:16}):s.jsx(Vt,{size:16}),s.jsx("span",{children:I?"Copied!":"Copy ID"})]}),Z?s.jsxs("button",{onClick:()=>{(async()=>await _e()&&b(!1))()},disabled:!t,className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-sm text-violet-400 text-sm font-display font-bold uppercase tracking-wider hover:bg-violet-500/10 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",children:[s.jsx(Gt,{size:16}),s.jsx("span",{children:"Resume"})]}):s.jsxs("button",{onClick:()=>z(!0),disabled:!t,className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-sm text-violet-400 text-sm font-display font-bold uppercase tracking-wider hover:bg-violet-500/10 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",children:[s.jsx(ki,{size:16}),s.jsx("span",{children:"Pause"})]}),s.jsxs("button",{onClick:()=>{oe(),b(!1)},disabled:!t||L,className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-sm text-cyan-400 text-sm font-display font-bold uppercase tracking-wider hover:bg-cyan-500/10 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",children:[L?s.jsx(Re,{size:16,className:"animate-spin"}):s.jsx(Ao,{size:16}),s.jsx("span",{children:"Export"})]}),s.jsxs("button",{onClick:()=>{A(),b(!1)},disabled:!t,className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-sm text-rose-400 text-sm font-display font-bold uppercase tracking-wider hover:bg-rose-500/10 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",children:[s.jsx(tn,{size:16}),s.jsx("span",{children:e?"Restore":"Archive"})]}),s.jsx("div",{className:"border-t border-border/30 my-1"}),l&&s.jsxs("button",{onClick:()=>{l(),b(!1)},className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-sm text-muted-foreground text-sm font-display font-bold uppercase tracking-wider hover:bg-cyan-500/10 hover:text-cyan-400 transition-colors cursor-pointer",children:[s.jsx(as,{size:16}),s.jsx("span",{children:"Feedback"})]}),s.jsxs("button",{onClick:()=>{N(!0),b(!1)},className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-sm text-cyan-400 text-sm font-display font-bold uppercase tracking-wider hover:bg-cyan-500/10 transition-colors cursor-pointer",children:[s.jsx(Js,{size:16}),s.jsxs("span",{children:["Notes",S>0?` (${S})`:""]})]}),s.jsxs("button",{onClick:()=>{v(!0),b(!1)},className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-sm text-muted-foreground text-sm font-display font-bold uppercase tracking-wider hover:bg-cyan-500/10 hover:text-cyan-400 transition-colors cursor-pointer",children:[s.jsx(Mo,{size:16}),s.jsx("span",{children:"Settings"})]})]})})})]})]})]}),s.jsx(W2,{isOpen:y,onClose:()=>v(!1)}),s.jsx(Dp,{isOpen:w,onClose:j,onLaunchSession:E,defaultProvider:"claude",defaultPermissionMode:f?.defaultPermissionMode,initialProvider:ne?.activeProvider||ne?.latestProvider||void 0,initialPermissionMode:ne?.permissionMode||void 0})]})}const zp=u.createContext(null);function Fp(){const t=u.useContext(zp);if(!t)throw new Error("useToast must be used within ToastProvider");return t}function nj({toast:t,onDismiss:e}){const[n,r]=u.useState(!1);u.useEffect(()=>{if(t.duration!==0){const c=setTimeout(e,t.duration||5e3);return()=>clearTimeout(c)}},[t.duration,e]);const o=async c=>{if(c.stopPropagation(),t.copyUrl){const d=window.location.origin+t.copyUrl;await navigator.clipboard.writeText(d),r(!0),setTimeout(()=>r(!1),2e3)}},a={success:"border-emerald-500/50",error:"border-red-500/50",info:"border-cyan-500/50"}[t.type],i={success:"text-emerald-400",error:"text-red-400",info:"text-cyan-400"}[t.type],l={success:Oe,error:Es,info:Es}[t.type];return s.jsxs("div",{className:`
|
|
191
191
|
flex items-start gap-3 p-3 rounded-lg
|
|
192
192
|
bg-card/95 backdrop-blur-sm border ${a}
|
|
193
193
|
shadow-lg animate-in slide-in-from-right-5 fade-in duration-200
|
|
@@ -207,11 +207,11 @@ Mark each note as addressed as you complete it.`,r}async function Lp(t,e,n,r,o={
|
|
|
207
207
|
text-xs font-display uppercase tracking-wider
|
|
208
208
|
text-muted-foreground hover:text-foreground
|
|
209
209
|
border border-border/30 hover:border-border/50 transition-colors
|
|
210
|
-
`,title:"Copy URL",children:[n?s.jsx(Oe,{size:10,className:"text-green-400"}):s.jsx(Vt,{size:10}),n?"Copied":"Copy URL"]})]})]}),s.jsx("button",{onClick:e,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0",children:s.jsx(Be,{size:14})})]})}function rj({children:t}){const[e,n]=u.useState([]),r=u.useCallback(a=>{const i=`toast-${Date.now()}-${Math.random().toString(36).slice(2)}`;return n(l=>[...l,{...a,id:i}]),i},[]),o=u.useCallback(a=>{n(i=>i.filter(l=>l.id!==a))},[]);return s.jsxs(zp.Provider,{value:{showToast:r,dismissToast:o},children:[t,e.length>0&&s.jsx("div",{className:"fixed top-4 right-4 z-50 flex flex-col gap-2",children:e.map(a=>s.jsx(nj,{toast:a,onDismiss:()=>o(a.id)},a.id))})]})}function Vp(t){return t?Math.floor((Date.now()-new Date(t).getTime())/1e3):0}function al(t){if(!t)return null;const e=Vp(t);if(e<5)return"just now";if(e<60)return`${e}s ago`;const n=Math.floor(e/60);if(n<60)return`${n}m ago`;const r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function oj(t){const e=t.filter(n=>typeof n=="string").map(n=>n.trim()).filter(n=>n.length>0&&n!=="Details unavailable"&&n!=="Outcome unavailable");return e.length===0?null:e[e.length-1]}const $n={paddingTop:"env(safe-area-inset-top, 0px)",paddingRight:"env(safe-area-inset-right, 0px)",paddingBottom:"env(safe-area-inset-bottom, 0px)",paddingLeft:"env(safe-area-inset-left, 0px)"};function aj({insights:t,isLoading:e,isOpen:n,onClose:r,syncState:o,isPendingInsightsUpdate:a=!1,sessionId:i,onBranch:l,onJumpToTurn:c}){const{showToast:d}=Fp(),[,p]=u.useState(0),[m,h]=u.useState([]),[g,f]=u.useState(!1),[x,b]=u.useState(new Set),[y,v]=u.useState(null),[w,N]=u.useState(null),[S,T]=u.useState(null),[C,j]=u.useState(!1),[E,R]=u.useState(!1),O=u.useCallback(async()=>{R(!0);try{(await G.checkAnthropicCredits()).creditsExhausted?d({title:"Still Exhausted",message:"Credits are still insufficient.",type:"error",duration:3e3}):(j(!1),d({title:"Credits Restored",message:"Insights will resume.",type:"success",duration:5e3}))}catch{}finally{R(!1)}},[d]);u.useEffect(()=>{if(!i){h([]);return}f(!0),G.getSessionTurns(i).then(F=>h(F.turns||[])).catch(()=>h([])).finally(()=>f(!1))},[i]);const $=u.useCallback(F=>{const se=F;se.type==="turn-captured"&&se.sessionId===i&&se.turn&&(h(ee=>ee.some(te=>te.id===se.turn.id)?ee:[...ee,se.turn]),v(null))},[i]);Pt({type:"activity"},$);const re=u.useCallback(F=>{const se=F;se.type==="current-work"&&se.sessionId===i&&v({summary:se.summary,userMessage:se.userMessage,startedAt:se.startedAt})},[i]);Pt({type:"activity"},re);const ne=u.useCallback(F=>{const se=F;se.type==="current-work-clear"&&se.sessionId===i&&v(null)},[i]);Pt({type:"activity"},ne);const V=u.useCallback(F=>{const se=F;se.type==="api-health"&&typeof se.creditsExhausted=="boolean"&&(j(se.creditsExhausted),se.creditsExhausted&&d({title:"Anthropic API Credits Exhausted",message:"Insights and analysis are paused until credits are added.",type:"error",duration:0}))},[d]);Pt({type:"activity"},V),u.useEffect(()=>{v(null)},[i]);const X=F=>{b(se=>{const ee=new Set(se);return ee.has(F)?ee.delete(F):ee.add(F),ee})},q=u.useCallback(async(F,se,ee)=>{if(ee.stopPropagation(),!(!i||w!==null||S!==null)){N(F);try{const te=await G.unifiedBranchConversation(i,F,se);te.success&&l&&(N(null),T(F),setTimeout(()=>{l(te.conversationId??te.newSessionId)},500))}catch(te){console.error("Failed to branch session:",te),N(null)}}},[i,w,S,l]);u.useEffect(()=>{if(!o?.lastUpdateTime)return;let F;const se=()=>{const te=Vp(o.lastUpdateTime)<60?1e3:1e4;F=setTimeout(()=>{p(xe=>xe+1),se()},te)};return se(),()=>clearTimeout(F)},[o?.lastUpdateTime]);const K=F=>{switch(F){case"decision":return{bg:"bg-purple-500/10",text:"text-purple-400",border:"border-purple-500/20"};case"fix":return{bg:"bg-green-500/10",text:"text-green-400",border:"border-green-500/20"};case"debug":return{bg:"bg-amber-500/10",text:"text-amber-400",border:"border-amber-500/20"};case"discovery":return{bg:"bg-cyan-500/10",text:"text-cyan-400",border:"border-cyan-500/20"};case"pivot":return{bg:"bg-orange-500/10",text:"text-orange-400",border:"border-orange-500/20"};case"friction":return{bg:"bg-red-500/10",text:"text-red-400",border:"border-red-500/20"};case"build":return{bg:"bg-blue-500/10",text:"text-blue-400",border:"border-blue-500/20"};default:return{bg:"bg-muted/30",text:"text-muted-foreground",border:"border-border/30"}}};if(n===!1)return null;if(e&&!t)return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"md:hidden fixed inset-0 z-50 bg-background/95 backdrop-blur-sm overflow-y-auto",style:$n,children:s.jsx("div",{className:"p-5",children:s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground/50",children:[s.jsx(Ae,{size:14,className:"animate-spin"}),s.jsx("span",{children:"Loading history..."})]})})}),s.jsx("aside",{className:"hidden md:block w-[480px] border-l border-border/50 bg-card/30 flex-shrink-0 overflow-y-auto",children:s.jsx("div",{className:"p-5",children:s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground/50",children:[s.jsx(Ae,{size:14,className:"animate-spin"}),s.jsx("span",{children:"Loading history..."})]})})})]});if(!t)return C?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"md:hidden fixed inset-0 z-50 bg-background/95 backdrop-blur-sm overflow-y-auto",style:$n,children:s.jsxs("div",{className:"p-5",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("span",{className:"text-xs uppercase tracking-wider text-muted-foreground/50",children:"Insights"}),s.jsx("button",{onClick:r,className:"p-1 rounded hover:bg-muted/50 transition-colors",children:s.jsx(Be,{size:16,className:"text-muted-foreground"})})]}),s.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg border border-amber-500/30 bg-amber-500/5",children:[s.jsx(kt,{size:16,className:"text-amber-500 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"text-[13px]",children:[s.jsx("div",{className:"font-medium text-amber-400",children:"Anthropic API Credits Exhausted"}),s.jsx("div",{className:"text-muted-foreground mt-1",children:"Insights and analysis are paused."}),s.jsx("a",{href:"https://console.anthropic.com/settings/billing",target:"_blank",rel:"noopener noreferrer",className:"text-cyan-400 hover:text-cyan-300 mt-2 inline-block text-xs",children:"Add Credits →"})]})]})]})}),s.jsx("aside",{className:"hidden md:block w-[480px] border-l border-border bg-background/50 backdrop-blur-sm overflow-y-auto",children:s.jsxs("div",{className:"p-5",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("span",{className:"text-xs uppercase tracking-wider text-muted-foreground/50",children:"Insights"}),s.jsx("button",{onClick:r,className:"p-1 rounded hover:bg-muted/50 transition-colors",children:s.jsx(Be,{size:16,className:"text-muted-foreground"})})]}),s.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg border border-amber-500/30 bg-amber-500/5",children:[s.jsx(kt,{size:16,className:"text-amber-500 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"text-[13px]",children:[s.jsx("div",{className:"font-medium text-amber-400",children:"Anthropic API Credits Exhausted"}),s.jsx("div",{className:"text-muted-foreground mt-1",children:"Insights and analysis are paused."}),s.jsx("a",{href:"https://console.anthropic.com/settings/billing",target:"_blank",rel:"noopener noreferrer",className:"text-cyan-400 hover:text-cyan-300 mt-2 inline-block text-xs",children:"Add Credits →"})]})]})]})})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"md:hidden fixed inset-0 z-50 bg-background/95 backdrop-blur-sm overflow-y-auto",style:$n,children:s.jsxs("div",{className:"p-5",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("span",{className:"text-xs uppercase tracking-wider text-muted-foreground/50",children:"History"}),s.jsx("button",{onClick:r,className:"p-1 rounded hover:bg-muted/50 transition-colors",children:s.jsx(Be,{size:16,className:"text-muted-foreground"})})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground/40 mt-8",children:[s.jsx(Hr,{size:6,className:"text-muted-foreground/30 animate-pulse"}),s.jsx("span",{children:"History will appear as the session progresses."})]})]})}),s.jsx("aside",{className:"hidden md:block w-[480px] border-l border-border/50 bg-card/30 flex-shrink-0 overflow-y-auto",children:s.jsx("div",{className:"p-5",children:s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground/40 mt-8",children:[s.jsx(Hr,{size:6,className:"text-muted-foreground/30 animate-pulse"}),s.jsx("span",{children:"History will appear as the session progresses."})]})})})]});const ge=m.length>0,D=!!y,W=!!t?.context?.mission,Z=s.jsxs("div",{className:"p-5 space-y-6",children:[y&&s.jsxs("div",{className:"flex flex-col",children:[s.jsx("div",{className:"text-xs uppercase tracking-wider text-muted-foreground/50 mb-3",children:"CURRENTLY"}),s.jsx("div",{className:"space-y-0",children:s.jsx("div",{className:"py-2",children:s.jsxs("div",{className:"flex items-start gap-2 px-2 -mx-2 py-1.5 -my-1.5",children:[s.jsxs("div",{className:"flex flex-col items-center w-12 flex-shrink-0",children:[s.jsx("span",{className:"text-sm",children:"⚡"}),s.jsx("span",{className:"text-[9px] text-amber-400 uppercase tracking-wide mt-0.5",children:"working"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-[13px] text-foreground/80 leading-snug",children:y.summary}),s.jsx("div",{className:"text-[10px] text-muted-foreground/40 mt-1.5",children:al(y.startedAt)})]})]})})})]}),C&&s.jsxs("div",{className:"flex items-start gap-2 p-2.5 rounded border border-amber-500/20 bg-amber-500/5 mb-3",children:[s.jsx(kt,{size:14,className:"text-amber-500 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"text-[12px] flex-1",children:[s.jsx("span",{className:"text-amber-400",children:"API credits exhausted"}),s.jsx("span",{className:"text-muted-foreground",children:" — updates paused. "}),s.jsx("a",{href:"https://console.anthropic.com/settings/billing",target:"_blank",rel:"noopener noreferrer",className:"text-cyan-400 hover:text-cyan-300",children:"Add credits →"})]}),s.jsxs("button",{onClick:O,disabled:E,className:"flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] text-muted-foreground hover:text-amber-400 border border-muted-foreground/20 hover:border-amber-500/30 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed flex-shrink-0",title:"Check if credits have been restored",children:[E?s.jsx(Ae,{size:10,className:"animate-spin"}):s.jsx(ds,{size:10}),s.jsx("span",{children:"Retry"})]})]}),m.length>0&&s.jsxs("div",{className:"flex flex-col min-h-0 flex-1",children:[s.jsxs("div",{className:"text-xs uppercase tracking-wider text-muted-foreground/50 mb-3",children:["History",g&&s.jsx(Ae,{size:10,className:"inline ml-2 animate-spin"})]}),s.jsx("div",{className:"space-y-0 overflow-y-auto flex-1 min-h-0",children:[...m].reverse().map((F,se,ee)=>{const xe=F.tag.replace(/[\p{Extended_Pictographic}\p{Variation_Selector}\s]+/gu,"").trim()||"action",_e=K(xe),A=x.has(F.id),P=oj(F.actions),le=!!P;return s.jsxs("div",{"data-testid":`turn-${F.turnNumber}`,children:[s.jsxs("div",{className:"py-2",children:[s.jsxs("div",{className:"group relative",children:[s.jsxs("button",{onClick:()=>X(F.id),className:"w-full text-left flex items-start gap-2 cursor-pointer rounded-md px-2 -mx-2 py-1.5 -my-1.5 hover:bg-muted/20 transition-colors",children:[s.jsxs("div",{className:"flex flex-col items-center w-14 flex-shrink-0 overflow-visible",children:[s.jsx("span",{className:"text-sm",children:F.icon}),s.jsx("span",{className:`text-[9px] ${_e.text} uppercase tracking-wide mt-0.5`,children:xe})]}),s.jsxs("div",{className:"flex-1 min-w-0 pr-16",children:[s.jsx("div",{className:`text-[13px] text-foreground/80 leading-snug ${A?"":"line-clamp-2"}`,children:F.headline}),s.jsxs("div",{className:"text-[10px] text-muted-foreground/40 mt-1",children:[al(F.timestamp),F.toolCount>0&&` · ${F.toolCount} tools`,le&&!A&&" · outcome"]})]})]}),(c||l)&&s.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1",children:[c&&s.jsx(Ot,{children:s.jsxs(Ke,{children:[s.jsx(Qe,{asChild:!0,children:s.jsx("button",{onClick:J=>{J.stopPropagation(),c(F)},className:`p-1.5 rounded-md opacity-0 group-hover:opacity-100
|
|
210
|
+
`,title:"Copy URL",children:[n?s.jsx(Oe,{size:10,className:"text-green-400"}):s.jsx(Vt,{size:10}),n?"Copied":"Copy URL"]})]})]}),s.jsx("button",{onClick:e,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0",children:s.jsx(Be,{size:14})})]})}function rj({children:t}){const[e,n]=u.useState([]),r=u.useCallback(a=>{const i=`toast-${Date.now()}-${Math.random().toString(36).slice(2)}`;return n(l=>[...l,{...a,id:i}]),i},[]),o=u.useCallback(a=>{n(i=>i.filter(l=>l.id!==a))},[]);return s.jsxs(zp.Provider,{value:{showToast:r,dismissToast:o},children:[t,e.length>0&&s.jsx("div",{className:"fixed top-4 right-4 z-50 flex flex-col gap-2",children:e.map(a=>s.jsx(nj,{toast:a,onDismiss:()=>o(a.id)},a.id))})]})}function Vp(t){return t?Math.floor((Date.now()-new Date(t).getTime())/1e3):0}function al(t){if(!t)return null;const e=Vp(t);if(e<5)return"just now";if(e<60)return`${e}s ago`;const n=Math.floor(e/60);if(n<60)return`${n}m ago`;const r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function oj(t){const e=t.filter(n=>typeof n=="string").map(n=>n.trim()).filter(n=>n.length>0&&n!=="Details unavailable"&&n!=="Outcome unavailable");return e.length===0?null:e[e.length-1]}const $n={paddingTop:"env(safe-area-inset-top, 0px)",paddingRight:"env(safe-area-inset-right, 0px)",paddingBottom:"env(safe-area-inset-bottom, 0px)",paddingLeft:"env(safe-area-inset-left, 0px)"};function aj({insights:t,isLoading:e,isOpen:n,onClose:r,syncState:o,isPendingInsightsUpdate:a=!1,sessionId:i,onBranch:l,onJumpToTurn:c}){const{showToast:d}=Fp(),[,p]=u.useState(0),[m,h]=u.useState([]),[g,f]=u.useState(!1),[x,b]=u.useState(new Set),[y,v]=u.useState(null),[w,N]=u.useState(null),[S,T]=u.useState(null),[C,j]=u.useState(!1),[E,A]=u.useState(!1),L=u.useCallback(async()=>{A(!0);try{(await H.checkAnthropicCredits()).creditsExhausted?d({title:"Still Exhausted",message:"Credits are still insufficient.",type:"error",duration:3e3}):(j(!1),d({title:"Credits Restored",message:"Insights will resume.",type:"success",duration:5e3}))}catch{}finally{A(!1)}},[d]);u.useEffect(()=>{if(!i){h([]);return}f(!0),H.getSessionTurns(i).then(z=>h(z.turns||[])).catch(()=>h([])).finally(()=>f(!1))},[i]);const $=u.useCallback(z=>{const re=z;re.type==="turn-captured"&&re.sessionId===i&&re.turn&&(h(se=>se.some(te=>te.id===re.turn.id)?se:[...se,re.turn]),v(null))},[i]);Rt({type:"activity"},$);const oe=u.useCallback(z=>{const re=z;re.type==="current-work"&&re.sessionId===i&&v({summary:re.summary,userMessage:re.userMessage,startedAt:re.startedAt})},[i]);Rt({type:"activity"},oe);const ne=u.useCallback(z=>{const re=z;re.type==="current-work-clear"&&re.sessionId===i&&v(null)},[i]);Rt({type:"activity"},ne);const B=u.useCallback(z=>{const re=z;re.type==="api-health"&&typeof re.creditsExhausted=="boolean"&&(j(re.creditsExhausted),re.creditsExhausted&&d({title:"Anthropic API Credits Exhausted",message:"Insights and analysis are paused until credits are added.",type:"error",duration:0}))},[d]);Rt({type:"activity"},B),u.useEffect(()=>{v(null)},[i]);const Q=z=>{b(re=>{const se=new Set(re);return se.has(z)?se.delete(z):se.add(z),se})},q=u.useCallback(async(z,re,se)=>{if(se.stopPropagation(),!(!i||w!==null||S!==null)){N(z);try{const te=await H.unifiedBranchConversation(i,z,re);te.success&&l&&(N(null),T(z),setTimeout(()=>{l(te.conversationId??te.newSessionId)},500))}catch(te){console.error("Failed to branch session:",te),N(null)}}},[i,w,S,l]);u.useEffect(()=>{if(!o?.lastUpdateTime)return;let z;const re=()=>{const te=Vp(o.lastUpdateTime)<60?1e3:1e4;z=setTimeout(()=>{p(xe=>xe+1),re()},te)};return re(),()=>clearTimeout(z)},[o?.lastUpdateTime]);const Z=z=>{switch(z){case"decision":return{bg:"bg-purple-500/10",text:"text-purple-400",border:"border-purple-500/20"};case"fix":return{bg:"bg-green-500/10",text:"text-green-400",border:"border-green-500/20"};case"debug":return{bg:"bg-amber-500/10",text:"text-amber-400",border:"border-amber-500/20"};case"discovery":return{bg:"bg-cyan-500/10",text:"text-cyan-400",border:"border-cyan-500/20"};case"pivot":return{bg:"bg-orange-500/10",text:"text-orange-400",border:"border-orange-500/20"};case"friction":return{bg:"bg-red-500/10",text:"text-red-400",border:"border-red-500/20"};case"build":return{bg:"bg-blue-500/10",text:"text-blue-400",border:"border-blue-500/20"};default:return{bg:"bg-muted/30",text:"text-muted-foreground",border:"border-border/30"}}};if(n===!1)return null;if(e&&!t)return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"md:hidden fixed inset-0 z-50 bg-background/95 backdrop-blur-sm overflow-y-auto",style:$n,children:s.jsx("div",{className:"p-5",children:s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground/50",children:[s.jsx(Re,{size:14,className:"animate-spin"}),s.jsx("span",{children:"Loading history..."})]})})}),s.jsx("aside",{className:"hidden md:block w-[480px] border-l border-border/50 bg-card/30 flex-shrink-0 overflow-y-auto",children:s.jsx("div",{className:"p-5",children:s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground/50",children:[s.jsx(Re,{size:14,className:"animate-spin"}),s.jsx("span",{children:"Loading history..."})]})})})]});if(!t)return C?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"md:hidden fixed inset-0 z-50 bg-background/95 backdrop-blur-sm overflow-y-auto",style:$n,children:s.jsxs("div",{className:"p-5",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("span",{className:"text-xs uppercase tracking-wider text-muted-foreground/50",children:"Insights"}),s.jsx("button",{onClick:r,className:"p-1 rounded hover:bg-muted/50 transition-colors",children:s.jsx(Be,{size:16,className:"text-muted-foreground"})})]}),s.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg border border-amber-500/30 bg-amber-500/5",children:[s.jsx(kt,{size:16,className:"text-amber-500 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"text-[13px]",children:[s.jsx("div",{className:"font-medium text-amber-400",children:"Anthropic API Credits Exhausted"}),s.jsx("div",{className:"text-muted-foreground mt-1",children:"Insights and analysis are paused."}),s.jsx("a",{href:"https://console.anthropic.com/settings/billing",target:"_blank",rel:"noopener noreferrer",className:"text-cyan-400 hover:text-cyan-300 mt-2 inline-block text-xs",children:"Add Credits →"})]})]})]})}),s.jsx("aside",{className:"hidden md:block w-[480px] border-l border-border bg-background/50 backdrop-blur-sm overflow-y-auto",children:s.jsxs("div",{className:"p-5",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("span",{className:"text-xs uppercase tracking-wider text-muted-foreground/50",children:"Insights"}),s.jsx("button",{onClick:r,className:"p-1 rounded hover:bg-muted/50 transition-colors",children:s.jsx(Be,{size:16,className:"text-muted-foreground"})})]}),s.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg border border-amber-500/30 bg-amber-500/5",children:[s.jsx(kt,{size:16,className:"text-amber-500 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"text-[13px]",children:[s.jsx("div",{className:"font-medium text-amber-400",children:"Anthropic API Credits Exhausted"}),s.jsx("div",{className:"text-muted-foreground mt-1",children:"Insights and analysis are paused."}),s.jsx("a",{href:"https://console.anthropic.com/settings/billing",target:"_blank",rel:"noopener noreferrer",className:"text-cyan-400 hover:text-cyan-300 mt-2 inline-block text-xs",children:"Add Credits →"})]})]})]})})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"md:hidden fixed inset-0 z-50 bg-background/95 backdrop-blur-sm overflow-y-auto",style:$n,children:s.jsxs("div",{className:"p-5",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("span",{className:"text-xs uppercase tracking-wider text-muted-foreground/50",children:"History"}),s.jsx("button",{onClick:r,className:"p-1 rounded hover:bg-muted/50 transition-colors",children:s.jsx(Be,{size:16,className:"text-muted-foreground"})})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground/40 mt-8",children:[s.jsx(Hr,{size:6,className:"text-muted-foreground/30 animate-pulse"}),s.jsx("span",{children:"History will appear as the session progresses."})]})]})}),s.jsx("aside",{className:"hidden md:block w-[480px] border-l border-border/50 bg-card/30 flex-shrink-0 overflow-y-auto",children:s.jsx("div",{className:"p-5",children:s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground/40 mt-8",children:[s.jsx(Hr,{size:6,className:"text-muted-foreground/30 animate-pulse"}),s.jsx("span",{children:"History will appear as the session progresses."})]})})})]});const me=m.length>0,O=!!y,W=!!t?.context?.mission,ee=s.jsxs("div",{className:"p-5 space-y-6",children:[y&&s.jsxs("div",{className:"flex flex-col",children:[s.jsx("div",{className:"text-xs uppercase tracking-wider text-muted-foreground/50 mb-3",children:"CURRENTLY"}),s.jsx("div",{className:"space-y-0",children:s.jsx("div",{className:"py-2",children:s.jsxs("div",{className:"flex items-start gap-2 px-2 -mx-2 py-1.5 -my-1.5",children:[s.jsxs("div",{className:"flex flex-col items-center w-12 flex-shrink-0",children:[s.jsx("span",{className:"text-sm",children:"⚡"}),s.jsx("span",{className:"text-[9px] text-amber-400 uppercase tracking-wide mt-0.5",children:"working"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-[13px] text-foreground/80 leading-snug",children:y.summary}),s.jsx("div",{className:"text-[10px] text-muted-foreground/40 mt-1.5",children:al(y.startedAt)})]})]})})})]}),C&&s.jsxs("div",{className:"flex items-start gap-2 p-2.5 rounded border border-amber-500/20 bg-amber-500/5 mb-3",children:[s.jsx(kt,{size:14,className:"text-amber-500 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"text-[12px] flex-1",children:[s.jsx("span",{className:"text-amber-400",children:"API credits exhausted"}),s.jsx("span",{className:"text-muted-foreground",children:" — updates paused. "}),s.jsx("a",{href:"https://console.anthropic.com/settings/billing",target:"_blank",rel:"noopener noreferrer",className:"text-cyan-400 hover:text-cyan-300",children:"Add credits →"})]}),s.jsxs("button",{onClick:L,disabled:E,className:"flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] text-muted-foreground hover:text-amber-400 border border-muted-foreground/20 hover:border-amber-500/30 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed flex-shrink-0",title:"Check if credits have been restored",children:[E?s.jsx(Re,{size:10,className:"animate-spin"}):s.jsx(ds,{size:10}),s.jsx("span",{children:"Retry"})]})]}),m.length>0&&s.jsxs("div",{className:"flex flex-col min-h-0 flex-1",children:[s.jsxs("div",{className:"text-xs uppercase tracking-wider text-muted-foreground/50 mb-3",children:["History",g&&s.jsx(Re,{size:10,className:"inline ml-2 animate-spin"})]}),s.jsx("div",{className:"space-y-0 overflow-y-auto flex-1 min-h-0",children:[...m].reverse().map((z,re,se)=>{const xe=z.tag.replace(/[\p{Extended_Pictographic}\p{Variation_Selector}\s]+/gu,"").trim()||"action",_e=Z(xe),I=x.has(z.id),P=oj(z.actions),de=!!P;return s.jsxs("div",{"data-testid":`turn-${z.turnNumber}`,children:[s.jsxs("div",{className:"py-2",children:[s.jsxs("div",{className:"group relative",children:[s.jsxs("button",{onClick:()=>Q(z.id),className:"w-full text-left flex items-start gap-2 cursor-pointer rounded-md px-2 -mx-2 py-1.5 -my-1.5 hover:bg-muted/20 transition-colors",children:[s.jsxs("div",{className:"flex flex-col items-center w-14 flex-shrink-0 overflow-visible",children:[s.jsx("span",{className:"text-sm",children:z.icon}),s.jsx("span",{className:`text-[9px] ${_e.text} uppercase tracking-wide mt-0.5`,children:xe})]}),s.jsxs("div",{className:"flex-1 min-w-0 pr-16",children:[s.jsx("div",{className:`text-[13px] text-foreground/80 leading-snug ${I?"":"line-clamp-2"}`,children:z.headline}),s.jsxs("div",{className:"text-[10px] text-muted-foreground/40 mt-1",children:[al(z.timestamp),z.toolCount>0&&` · ${z.toolCount} tools`,de&&!I&&" · outcome"]})]})]}),(c||l)&&s.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1",children:[c&&s.jsx(Ot,{children:s.jsxs(Ke,{children:[s.jsx(Qe,{asChild:!0,children:s.jsx("button",{onClick:X=>{X.stopPropagation(),c(z)},className:`p-1.5 rounded-md opacity-0 group-hover:opacity-100
|
|
211
211
|
transition-all duration-200 cursor-pointer text-muted-foreground/50
|
|
212
|
-
hover:text-cyan-400 hover:bg-cyan-500/10`,"aria-label":`Go to turn ${
|
|
213
|
-
${S===
|
|
214
|
-
disabled:cursor-not-allowed`,"aria-label":`Branch from turn ${F.turnNumber}`,children:w===F.turnNumber?s.jsx(Ae,{size:14,className:"animate-spin"}):S===F.turnNumber?s.jsx(Oe,{size:14}):s.jsx(ya,{size:14})})}),s.jsx(qe,{side:"left",children:s.jsx("p",{children:S===F.turnNumber?"Branched!":"Start a new direction from this point — original history is preserved"})})]})})]})]}),A&&s.jsxs("div",{className:"mt-3 space-y-1.5",children:[s.jsx("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/50 px-1",children:"Outcome"}),s.jsx("div",{className:"w-full bg-muted/30 rounded-md px-3 py-2.5 text-[13px] text-foreground/80 leading-relaxed",children:P??"Outcome unavailable"})]})]}),se<ee.length-1&&s.jsx("div",{className:"border-t border-border/20"})]},F.id)})})]}),!ge&&!D&&W&&s.jsxs("div",{className:"flex flex-col gap-4",children:[s.jsx("div",{className:"text-xs uppercase tracking-wider text-muted-foreground/50",children:"Mission"}),s.jsx("div",{className:"text-[13px] text-foreground/70 leading-relaxed",children:t.context?.mission}),s.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-muted-foreground/40 mt-2",children:[s.jsx(Hr,{size:6,className:"text-muted-foreground/30 animate-pulse"}),s.jsx("span",{children:"History will appear as the session progresses"})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"md:hidden fixed inset-0 z-50 bg-background flex flex-col",style:$n,children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border/50 flex-shrink-0",children:[s.jsx("span",{className:"text-xs uppercase tracking-wider text-muted-foreground/50 font-display",children:"Session History"}),r&&s.jsx("button",{onClick:r,className:"p-2 -m-2 text-muted-foreground hover:text-foreground transition-colors","aria-label":"Close history",children:s.jsx(Be,{size:20})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto",children:Z})]}),s.jsx("aside",{"data-testid":"insights-panel",className:"hidden md:flex md:flex-col w-[480px] border-l border-border/50 bg-card/30 flex-shrink-0 overflow-hidden",children:s.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-auto-hide",children:Z})})]})}const js={operational_playbook:{label:"Playbook",color:"text-cyan-400"},repository_convention:{label:"Convention",color:"text-purple-400"},context_heuristic:{label:"Context",color:"text-emerald-400"},guardrail:{label:"Guardrail",color:"text-orange-400"},architecture_invariant:{label:"Architecture",color:"text-amber-400"},toolchain:{label:"Toolchain",color:"text-blue-400"},collaboration:{label:"Collaboration",color:"text-sky-400"}},il={high:{label:"High confidence",icon:_a,color:"text-emerald-400",pillBg:"bg-emerald-500/10 border-emerald-500/20"},medium:{label:"Medium confidence",icon:Yl,color:"text-amber-400",pillBg:"bg-amber-500/10 border-amber-500/20"},low:{label:"Low confidence",icon:Es,color:"text-muted-foreground/60",pillBg:"bg-muted/20 border-border/30"}},fa={claude_md:{label:"CLAUDE.md",color:"text-cyan-400"},skill:{label:"Skill",color:"text-violet-400"},hook:{label:"Hook",color:"text-amber-400"},human_followup:{label:"Discussion",color:"text-rose-400"},ci_check:{label:"CI Check",color:"text-blue-400"},adr_doc:{label:"ADR",color:"text-teal-400"}},ij={pending:{border:"border-border/25",bg:"bg-background/20",hover:"hover:border-cyan-500/35 hover:bg-background/35 hover:shadow-[2px_2px_0_rgba(0,255,255,0.2)]",badgeColor:"",badgeLabel:"",badgeIcon:Oe},accepted:{border:"border-emerald-500/50",bg:"bg-emerald-500/10",hover:"",badgeColor:"text-emerald-400",badgeLabel:"Accepted",badgeIcon:Oe},archived:{border:"border-purple-500/40",bg:"bg-purple-500/[0.07]",hover:"",badgeColor:"text-purple-400",badgeLabel:"Archived",badgeIcon:tn},rejected:{border:"border-rose-500/30",bg:"bg-rose-500/[0.05]",hover:"",badgeColor:"text-rose-400/70",badgeLabel:"Rejected",badgeIcon:Be}};function _s({proposal:t,synthesisId:e,cardState:n="pending",onAccepted:r,onUnaccept:o,onDismissed:a,onReload:i}){const[l,c]=u.useState(!1),[d,p]=u.useState(!1),[m,h]=u.useState(null),g=t.delivery==="skill"?"skillContent":t.delivery==="hook"?"scriptContent":"proposedText",f=t[g]||"",[x,b]=u.useState(f);u.useEffect(()=>{b(f)},[f]);const y=t.delivery==="claude_md"||t.delivery==="skill"||t.delivery==="hook",v=t.delivery==="human_followup",w=u.useCallback(()=>{const $=l?{...t,[g]:x}:t;r?.($),c(!1)},[x,g,r,t,l]),N=u.useCallback(async()=>{p(!0),h(null);try{const $=await G.dismissCrossSessionProposal({synthesisId:e,proposalId:t.id,sourceSynthesisId:t.sourceSynthesisId});if(!$.success){h($.error||"Failed to dismiss proposal.");return}a?.(t),await i?.()}catch($){h($ instanceof Error?$.message:"Failed to dismiss proposal.")}finally{p(!1)}},[a,i,t,e]),S=js[t.category]||js.repository_convention,T=il[t.confidence]||il.medium,C=T.icon,j=t.rationale.split(/\n/).map($=>$.replace(/^[-•*]\s*/,"").trim()).filter(Boolean),E=ij[n],R=n==="pending",O=E.badgeIcon;return s.jsxs("article",{className:`relative rounded-sm border ${E.border} ${E.bg} overflow-hidden transition-all ${E.hover}`,children:[s.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[linear-gradient(rgba(0,255,255,0.02)_1px,transparent_1px),linear-gradient(90deg,rgba(0,255,255,0.02)_1px,transparent_1px)] bg-[size:18px_18px]"}),s.jsxs("div",{className:"relative p-2.5 space-y-2 font-display",children:[s.jsxs("div",{className:"rounded-sm border border-border/25 bg-background/35 px-2.5 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`text-[9px] uppercase tracking-widest ${S.color}`,children:S.label}),t.delivery!=="claude_md"&&s.jsx("span",{className:`text-[9px] uppercase tracking-widest ${fa[t.delivery]?.color||"text-muted-foreground"}`,children:fa[t.delivery]?.label||t.delivery})]}),s.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-sm border text-[9px] uppercase tracking-widest ${T.color} ${T.pillBg}`,children:[s.jsx(C,{size:9}),T.label]})]}),s.jsx("div",{className:"mt-1 text-sm text-foreground/90 font-semibold leading-relaxed",children:t.title})]}),(R||n==="accepted")&&j.length>0&&s.jsxs("div",{className:"rounded-sm border border-border/20 bg-muted/10 px-2.5 py-2",children:[s.jsx("span",{className:"text-[9px] uppercase tracking-widest text-muted-foreground/60",children:"Why"}),s.jsx("div",{className:"mt-1.5 space-y-1.5",children:j.map(($,re)=>s.jsxs("div",{className:"flex items-start gap-2 text-xs text-foreground/80 font-sans leading-relaxed",children:[s.jsx(Ut,{size:10,className:"mt-0.5 flex-shrink-0 text-cyan-400/50"}),s.jsx("span",{children:$})]},`${re}-${$.slice(0,24)}`))})]}),!R&&s.jsxs("div",{className:"flex items-center justify-between pt-0.5",children:[s.jsxs("div",{className:`flex items-center gap-1.5 ${E.badgeColor} text-[10px] font-display font-bold uppercase tracking-wider`,children:[s.jsx(O,{size:12}),E.badgeLabel]}),n==="accepted"&&o&&s.jsx("button",{onClick:()=>o(t.id),className:"p-0.5 text-muted-foreground/30 hover:text-foreground transition-colors",children:s.jsx(Be,{size:10})})]}),R&&l&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"rounded-sm border border-border/25 bg-background/35 p-2.5",children:[s.jsx("div",{className:"mb-1.5 text-[9px] uppercase tracking-widest text-muted-foreground/60",children:t.delivery==="skill"?"Edit skill content":t.delivery==="hook"?"Edit hook script":"Edit proposed text"}),s.jsx("textarea",{value:x,onChange:$=>b($.target.value),rows:8,className:"w-full rounded-sm border border-border/30 bg-background px-3 py-2 font-mono text-xs leading-relaxed text-foreground focus:border-cyan-500/50 focus:outline-none resize-none"})]}),t.delivery==="claude_md"&&s.jsx("div",{className:"rounded-sm border border-border/25 overflow-hidden",children:s.jsx(su,{oldValue:t.currentText||"",newValue:x,language:"markdown"})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:w,className:"flex items-center gap-1.5 px-2.5 py-1 ui-action-btn ui-action-btn--emerald text-[10px] font-display font-bold uppercase tracking-wider bg-background/80 backdrop-blur-sm",children:[s.jsx(Oe,{size:10}),"Accept with edit"]}),s.jsx("button",{onClick:()=>{c(!1),b(f)},className:"flex items-center gap-1.5 px-2.5 py-1 ui-action-btn ui-action-btn--cool text-[10px] font-display font-bold uppercase tracking-wider bg-background/80 backdrop-blur-sm",children:"Cancel"})]})]}),(R||n==="accepted")&&!l&&t.delivery!=="claude_md"&&s.jsxs("div",{className:"rounded-sm border border-border/20 bg-muted/10 px-2.5 py-2",children:[t.delivery==="skill"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[s.jsx("span",{className:"text-[9px] uppercase tracking-widest text-muted-foreground/60",children:"Skill"}),s.jsx("code",{className:"text-[10px] text-violet-400 bg-violet-500/10 px-1.5 py-0.5 rounded-sm",children:t.skillName}),s.jsx("span",{className:"text-[9px] text-muted-foreground/40",children:t.skillScope||"global"})]}),t.skillContent&&s.jsx("pre",{className:"text-xs text-foreground/70 font-mono leading-relaxed whitespace-pre-wrap max-h-32 overflow-y-auto",children:t.skillContent})]}),t.delivery==="hook"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[s.jsx("span",{className:"text-[9px] uppercase tracking-widest text-muted-foreground/60",children:"Hook"}),s.jsx("code",{className:"text-[10px] text-amber-400 bg-amber-500/10 px-1.5 py-0.5 rounded-sm",children:t.hookEvent}),t.hookMatcher&&t.hookMatcher!==".*"&&s.jsx("code",{className:"text-[10px] text-muted-foreground/60 bg-muted/20 px-1.5 py-0.5 rounded-sm",children:t.hookMatcher})]}),t.scriptContent&&s.jsx("pre",{className:"text-xs text-foreground/70 font-mono leading-relaxed whitespace-pre-wrap max-h-32 overflow-y-auto",children:t.scriptContent})]}),t.delivery==="human_followup"&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-[9px] uppercase tracking-widest text-muted-foreground/60",children:"Discussion topic"}),s.jsx("div",{className:"mt-1.5 text-xs text-foreground/80 font-sans leading-relaxed",children:t.followupContext}),t.suggestedAction&&s.jsx("div",{className:"mt-1.5 text-xs text-muted-foreground/60 font-sans italic",children:t.suggestedAction})]}),(t.delivery==="ci_check"||t.delivery==="adr_doc")&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-[9px] uppercase tracking-widest text-muted-foreground/60",children:t.delivery==="ci_check"?"CI Check":"ADR"}),s.jsx("div",{className:"mt-1.5 text-xs text-foreground/70 font-sans leading-relaxed",children:t.delivery==="adr_doc"?t.adrContent:t.implementationPrompt})]})]}),R&&!l&&s.jsxs("div",{className:"flex items-center gap-2 pt-0.5",children:[s.jsxs("button",{onClick:w,className:"flex items-center gap-1.5 px-2.5 py-1 ui-action-btn ui-action-btn--emerald text-[10px] font-display font-bold uppercase tracking-wider bg-background/80 backdrop-blur-sm",children:[s.jsx(Oe,{size:10}),v?"Acknowledge":"Accept"]}),y&&s.jsxs("button",{onClick:()=>c(!0),className:"flex items-center gap-1.5 px-2.5 py-1 ui-action-btn ui-action-btn--cool text-[10px] font-display font-bold uppercase tracking-wider bg-background/80 backdrop-blur-sm",children:[s.jsx(va,{size:10}),"Edit"]}),s.jsx("button",{onClick:()=>{N()},disabled:d,className:"flex items-center gap-1.5 px-2.5 py-1 ui-action-btn ui-action-btn--rose text-[10px] font-display font-bold uppercase tracking-wider bg-background/80 backdrop-blur-sm disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:shadow-none disabled:hover:translate-x-0 disabled:hover:translate-y-0",children:s.jsx(Be,{size:10})})]}),m&&s.jsx("div",{className:"rounded-sm border border-red-500/20 bg-red-500/5 px-2.5 py-2 text-xs text-red-400 font-sans",children:m})]})]})}function bo({label:t,count:e,color:n,children:r,defaultOpen:o=!1}){const[a,i]=u.useState(o);return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("button",{onClick:()=>i(!a),className:"flex items-center gap-1.5 group cursor-pointer",children:[a?s.jsx(Lt,{size:10,className:`${n} transition-transform`}):s.jsx(Ut,{size:10,className:`${n} transition-transform`}),s.jsxs("span",{className:`text-[9px] font-display uppercase tracking-widest ${n}`,children:[t," (",e,")"]})]}),a&&s.jsx("div",{className:"space-y-3",children:r})]})}function cj(t){const e=t.filter(o=>o.delivery!=="human_followup"),n=t.filter(o=>o.delivery==="human_followup");let r="";if(n.length>0){r+=`## Discussion topics
|
|
212
|
+
hover:text-cyan-400 hover:bg-cyan-500/10`,"aria-label":`Go to turn ${z.turnNumber}`,children:s.jsx(_f,{size:14})})}),s.jsx(qe,{side:"left",children:s.jsx("p",{children:"Jump to this point in the conversation"})})]})}),l&&s.jsx(Ot,{children:s.jsxs(Ke,{children:[s.jsx(Qe,{asChild:!0,children:s.jsx("button",{onClick:X=>q(z.turnNumber,z.timestamp,X),disabled:w!==null||S!==null,className:`p-1.5 rounded-md transition-all duration-200 cursor-pointer
|
|
213
|
+
${S===z.turnNumber?"opacity-100 text-green-400 bg-green-500/20":"opacity-0 group-hover:opacity-100 text-muted-foreground/50 hover:text-cyan-400 hover:bg-cyan-500/10"}
|
|
214
|
+
disabled:cursor-not-allowed`,"aria-label":`Branch from turn ${z.turnNumber}`,children:w===z.turnNumber?s.jsx(Re,{size:14,className:"animate-spin"}):S===z.turnNumber?s.jsx(Oe,{size:14}):s.jsx(ya,{size:14})})}),s.jsx(qe,{side:"left",children:s.jsx("p",{children:S===z.turnNumber?"Branched!":"Start a new direction from this point — original history is preserved"})})]})})]})]}),I&&s.jsxs("div",{className:"mt-3 space-y-1.5",children:[s.jsx("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/50 px-1",children:"Outcome"}),s.jsx("div",{className:"w-full bg-muted/30 rounded-md px-3 py-2.5 text-[13px] text-foreground/80 leading-relaxed",children:P??"Outcome unavailable"})]})]}),re<se.length-1&&s.jsx("div",{className:"border-t border-border/20"})]},z.id)})})]}),!me&&!O&&W&&s.jsxs("div",{className:"flex flex-col gap-4",children:[s.jsx("div",{className:"text-xs uppercase tracking-wider text-muted-foreground/50",children:"Mission"}),s.jsx("div",{className:"text-[13px] text-foreground/70 leading-relaxed",children:t.context?.mission}),s.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-muted-foreground/40 mt-2",children:[s.jsx(Hr,{size:6,className:"text-muted-foreground/30 animate-pulse"}),s.jsx("span",{children:"History will appear as the session progresses"})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"md:hidden fixed inset-0 z-50 bg-background flex flex-col",style:$n,children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border/50 flex-shrink-0",children:[s.jsx("span",{className:"text-xs uppercase tracking-wider text-muted-foreground/50 font-display",children:"Session History"}),r&&s.jsx("button",{onClick:r,className:"p-2 -m-2 text-muted-foreground hover:text-foreground transition-colors","aria-label":"Close history",children:s.jsx(Be,{size:20})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto",children:ee})]}),s.jsx("aside",{"data-testid":"insights-panel",className:"hidden md:flex md:flex-col w-[480px] border-l border-border/50 bg-card/30 flex-shrink-0 overflow-hidden",children:s.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-auto-hide",children:ee})})]})}const js={operational_playbook:{label:"Playbook",color:"text-cyan-400"},repository_convention:{label:"Convention",color:"text-purple-400"},context_heuristic:{label:"Context",color:"text-emerald-400"},guardrail:{label:"Guardrail",color:"text-orange-400"},architecture_invariant:{label:"Architecture",color:"text-amber-400"},toolchain:{label:"Toolchain",color:"text-blue-400"},collaboration:{label:"Collaboration",color:"text-sky-400"}},il={high:{label:"High confidence",icon:_a,color:"text-emerald-400",pillBg:"bg-emerald-500/10 border-emerald-500/20"},medium:{label:"Medium confidence",icon:Yl,color:"text-amber-400",pillBg:"bg-amber-500/10 border-amber-500/20"},low:{label:"Low confidence",icon:Es,color:"text-muted-foreground/60",pillBg:"bg-muted/20 border-border/30"}},fa={claude_md:{label:"CLAUDE.md",color:"text-cyan-400"},skill:{label:"Skill",color:"text-violet-400"},hook:{label:"Hook",color:"text-amber-400"},human_followup:{label:"Discussion",color:"text-rose-400"},ci_check:{label:"CI Check",color:"text-blue-400"},adr_doc:{label:"ADR",color:"text-teal-400"}},ij={pending:{border:"border-border/25",bg:"bg-background/20",hover:"hover:border-cyan-500/35 hover:bg-background/35 hover:shadow-[2px_2px_0_rgba(0,255,255,0.2)]",badgeColor:"",badgeLabel:"",badgeIcon:Oe},accepted:{border:"border-emerald-500/50",bg:"bg-emerald-500/10",hover:"",badgeColor:"text-emerald-400",badgeLabel:"Accepted",badgeIcon:Oe},archived:{border:"border-purple-500/40",bg:"bg-purple-500/[0.07]",hover:"",badgeColor:"text-purple-400",badgeLabel:"Archived",badgeIcon:tn},rejected:{border:"border-rose-500/30",bg:"bg-rose-500/[0.05]",hover:"",badgeColor:"text-rose-400/70",badgeLabel:"Rejected",badgeIcon:Be}};function _s({proposal:t,synthesisId:e,cardState:n="pending",onAccepted:r,onUnaccept:o,onDismissed:a,onReload:i}){const[l,c]=u.useState(!1),[d,p]=u.useState(!1),[m,h]=u.useState(null),g=t.delivery==="skill"?"skillContent":t.delivery==="hook"?"scriptContent":"proposedText",f=t[g]||"",[x,b]=u.useState(f);u.useEffect(()=>{b(f)},[f]);const y=t.delivery==="claude_md"||t.delivery==="skill"||t.delivery==="hook",v=t.delivery==="human_followup",w=u.useCallback(()=>{const $=l?{...t,[g]:x}:t;r?.($),c(!1)},[x,g,r,t,l]),N=u.useCallback(async()=>{p(!0),h(null);try{const $=await H.dismissCrossSessionProposal({synthesisId:e,proposalId:t.id,sourceSynthesisId:t.sourceSynthesisId});if(!$.success){h($.error||"Failed to dismiss proposal.");return}a?.(t),await i?.()}catch($){h($ instanceof Error?$.message:"Failed to dismiss proposal.")}finally{p(!1)}},[a,i,t,e]),S=js[t.category]||js.repository_convention,T=il[t.confidence]||il.medium,C=T.icon,j=t.rationale.split(/\n/).map($=>$.replace(/^[-•*]\s*/,"").trim()).filter(Boolean),E=ij[n],A=n==="pending",L=E.badgeIcon;return s.jsxs("article",{className:`relative rounded-sm border ${E.border} ${E.bg} overflow-hidden transition-all ${E.hover}`,children:[s.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[linear-gradient(rgba(0,255,255,0.02)_1px,transparent_1px),linear-gradient(90deg,rgba(0,255,255,0.02)_1px,transparent_1px)] bg-[size:18px_18px]"}),s.jsxs("div",{className:"relative p-2.5 space-y-2 font-display",children:[s.jsxs("div",{className:"rounded-sm border border-border/25 bg-background/35 px-2.5 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`text-[9px] uppercase tracking-widest ${S.color}`,children:S.label}),t.delivery!=="claude_md"&&s.jsx("span",{className:`text-[9px] uppercase tracking-widest ${fa[t.delivery]?.color||"text-muted-foreground"}`,children:fa[t.delivery]?.label||t.delivery})]}),s.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-sm border text-[9px] uppercase tracking-widest ${T.color} ${T.pillBg}`,children:[s.jsx(C,{size:9}),T.label]})]}),s.jsx("div",{className:"mt-1 text-sm text-foreground/90 font-semibold leading-relaxed",children:t.title})]}),(A||n==="accepted")&&j.length>0&&s.jsxs("div",{className:"rounded-sm border border-border/20 bg-muted/10 px-2.5 py-2",children:[s.jsx("span",{className:"text-[9px] uppercase tracking-widest text-muted-foreground/60",children:"Why"}),s.jsx("div",{className:"mt-1.5 space-y-1.5",children:j.map(($,oe)=>s.jsxs("div",{className:"flex items-start gap-2 text-xs text-foreground/80 font-sans leading-relaxed",children:[s.jsx(Ut,{size:10,className:"mt-0.5 flex-shrink-0 text-cyan-400/50"}),s.jsx("span",{children:$})]},`${oe}-${$.slice(0,24)}`))})]}),!A&&s.jsxs("div",{className:"flex items-center justify-between pt-0.5",children:[s.jsxs("div",{className:`flex items-center gap-1.5 ${E.badgeColor} text-[10px] font-display font-bold uppercase tracking-wider`,children:[s.jsx(L,{size:12}),E.badgeLabel]}),n==="accepted"&&o&&s.jsx("button",{onClick:()=>o(t.id),className:"p-0.5 text-muted-foreground/30 hover:text-foreground transition-colors",children:s.jsx(Be,{size:10})})]}),A&&l&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"rounded-sm border border-border/25 bg-background/35 p-2.5",children:[s.jsx("div",{className:"mb-1.5 text-[9px] uppercase tracking-widest text-muted-foreground/60",children:t.delivery==="skill"?"Edit skill content":t.delivery==="hook"?"Edit hook script":"Edit proposed text"}),s.jsx("textarea",{value:x,onChange:$=>b($.target.value),rows:8,className:"w-full rounded-sm border border-border/30 bg-background px-3 py-2 font-mono text-xs leading-relaxed text-foreground focus:border-cyan-500/50 focus:outline-none resize-none"})]}),t.delivery==="claude_md"&&s.jsx("div",{className:"rounded-sm border border-border/25 overflow-hidden",children:s.jsx(su,{oldValue:t.currentText||"",newValue:x,language:"markdown"})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:w,className:"flex items-center gap-1.5 px-2.5 py-1 ui-action-btn ui-action-btn--emerald text-[10px] font-display font-bold uppercase tracking-wider bg-background/80 backdrop-blur-sm",children:[s.jsx(Oe,{size:10}),"Accept with edit"]}),s.jsx("button",{onClick:()=>{c(!1),b(f)},className:"flex items-center gap-1.5 px-2.5 py-1 ui-action-btn ui-action-btn--cool text-[10px] font-display font-bold uppercase tracking-wider bg-background/80 backdrop-blur-sm",children:"Cancel"})]})]}),(A||n==="accepted")&&!l&&t.delivery!=="claude_md"&&s.jsxs("div",{className:"rounded-sm border border-border/20 bg-muted/10 px-2.5 py-2",children:[t.delivery==="skill"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[s.jsx("span",{className:"text-[9px] uppercase tracking-widest text-muted-foreground/60",children:"Skill"}),s.jsx("code",{className:"text-[10px] text-violet-400 bg-violet-500/10 px-1.5 py-0.5 rounded-sm",children:t.skillName}),s.jsx("span",{className:"text-[9px] text-muted-foreground/40",children:t.skillScope||"global"})]}),t.skillContent&&s.jsx("pre",{className:"text-xs text-foreground/70 font-mono leading-relaxed whitespace-pre-wrap max-h-32 overflow-y-auto",children:t.skillContent})]}),t.delivery==="hook"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[s.jsx("span",{className:"text-[9px] uppercase tracking-widest text-muted-foreground/60",children:"Hook"}),s.jsx("code",{className:"text-[10px] text-amber-400 bg-amber-500/10 px-1.5 py-0.5 rounded-sm",children:t.hookEvent}),t.hookMatcher&&t.hookMatcher!==".*"&&s.jsx("code",{className:"text-[10px] text-muted-foreground/60 bg-muted/20 px-1.5 py-0.5 rounded-sm",children:t.hookMatcher})]}),t.scriptContent&&s.jsx("pre",{className:"text-xs text-foreground/70 font-mono leading-relaxed whitespace-pre-wrap max-h-32 overflow-y-auto",children:t.scriptContent})]}),t.delivery==="human_followup"&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-[9px] uppercase tracking-widest text-muted-foreground/60",children:"Discussion topic"}),s.jsx("div",{className:"mt-1.5 text-xs text-foreground/80 font-sans leading-relaxed",children:t.followupContext}),t.suggestedAction&&s.jsx("div",{className:"mt-1.5 text-xs text-muted-foreground/60 font-sans italic",children:t.suggestedAction})]}),(t.delivery==="ci_check"||t.delivery==="adr_doc")&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-[9px] uppercase tracking-widest text-muted-foreground/60",children:t.delivery==="ci_check"?"CI Check":"ADR"}),s.jsx("div",{className:"mt-1.5 text-xs text-foreground/70 font-sans leading-relaxed",children:t.delivery==="adr_doc"?t.adrContent:t.implementationPrompt})]})]}),A&&!l&&s.jsxs("div",{className:"flex items-center gap-2 pt-0.5",children:[s.jsxs("button",{onClick:w,className:"flex items-center gap-1.5 px-2.5 py-1 ui-action-btn ui-action-btn--emerald text-[10px] font-display font-bold uppercase tracking-wider bg-background/80 backdrop-blur-sm",children:[s.jsx(Oe,{size:10}),v?"Acknowledge":"Accept"]}),y&&s.jsxs("button",{onClick:()=>c(!0),className:"flex items-center gap-1.5 px-2.5 py-1 ui-action-btn ui-action-btn--cool text-[10px] font-display font-bold uppercase tracking-wider bg-background/80 backdrop-blur-sm",children:[s.jsx(va,{size:10}),"Edit"]}),s.jsx("button",{onClick:()=>{N()},disabled:d,className:"flex items-center gap-1.5 px-2.5 py-1 ui-action-btn ui-action-btn--rose text-[10px] font-display font-bold uppercase tracking-wider bg-background/80 backdrop-blur-sm disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:shadow-none disabled:hover:translate-x-0 disabled:hover:translate-y-0",children:s.jsx(Be,{size:10})})]}),m&&s.jsx("div",{className:"rounded-sm border border-red-500/20 bg-red-500/5 px-2.5 py-2 text-xs text-red-400 font-sans",children:m})]})]})}function bo({label:t,count:e,color:n,children:r,defaultOpen:o=!1}){const[a,i]=u.useState(o);return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("button",{onClick:()=>i(!a),className:"flex items-center gap-1.5 group cursor-pointer",children:[a?s.jsx(Lt,{size:10,className:`${n} transition-transform`}):s.jsx(Ut,{size:10,className:`${n} transition-transform`}),s.jsxs("span",{className:`text-[9px] font-display uppercase tracking-widest ${n}`,children:[t," (",e,")"]})]}),a&&s.jsx("div",{className:"space-y-3",children:r})]})}function cj(t){const e=t.filter(o=>o.delivery!=="human_followup"),n=t.filter(o=>o.delivery==="human_followup");let r="";if(n.length>0){r+=`## Discussion topics
|
|
215
215
|
|
|
216
216
|
`,r+=`The following ${n.length} topic${n.length!==1?"s":""} surfaced from cross-session analysis and need${n.length===1?"s":""} your input before they can be acted on. Think through each one with the user — don't just implement something, help them decide.
|
|
217
217
|
|
|
@@ -267,7 +267,7 @@ ${a.proposedText}
|
|
|
267
267
|
|
|
268
268
|
Work through each recommendation systematically. After completing each one, briefly confirm what you did.
|
|
269
269
|
`}return r||`No recommendations to implement or discuss.
|
|
270
|
-
`}function Bp({onClose:t,autoRun:e=!1}){const n=
|
|
270
|
+
`}function Bp({onClose:t,autoRun:e=!1}){const n=Nt(),{serverConfig:r}=zs(),[o,a]=u.useState(null),[i,l]=u.useState(null),[c,d]=u.useState(!0),[p,m]=u.useState(null),[h,g]=u.useState(null),f=u.useRef(null),x=u.useRef(!1),[b,y]=u.useState(!1),[v,w]=u.useState([]),[N,S]=u.useState([]),[T,C]=u.useState([]),[j,E]=u.useState("claude"),[A,L]=u.useState(()=>pn({fallback:void 0,provider:"claude"})==="bypassPermissions"?"bypassPermissions":"default"),[$,oe]=u.useState(!1),[ne,B]=u.useState(null),Q=u.useRef(!1),q=u.useCallback(async()=>{const[D,be]=await Promise.all([H.getCrossSessionStatus(),H.getLatestCrossSessionSynthesis()]);a(D),l(be.synthesis??null),D.synthesisInProgress||D.latestStatus==="running"||y(!1)},[]);u.useEffect(()=>{let D=!1;return(async()=>{d(!0),m(null);try{await q()}catch(be){if(D)return;m(be instanceof Error?be.message:"Failed to load cross-session analysis")}finally{D||d(!1)}})(),()=>{D=!0}},[q]),u.useEffect(()=>{if(!(!e||!o||x.current)){if(!o.readyToAnalyze){g(`Need ${o.threshold} extracted sessions before analysis can run.`),x.current=!0;return}x.current=!0,g(null),y(!0),H.runCrossSessionAnalysis().then(D=>{if(!D.started){g(D.reason||"Cross-session analysis did not start."),y(!1);return}return f.current=D.startedAt||new Date().toISOString(),q()}).catch(D=>{g(D instanceof Error?D.message:"Failed to start cross-session analysis"),y(!1)})}},[e,q,o]),u.useEffect(()=>{if(!b&&!o?.synthesisInProgress&&o?.latestStatus!=="running")return;const D=window.setInterval(()=>{q().catch(()=>{})},2500);return()=>window.clearInterval(D)},[q,b,o?.latestStatus,o?.synthesisInProgress]),Rt({type:"activity"},u.useCallback(D=>{D&&typeof D=="object"&&"type"in D&&D.type==="cross-session-update"&&q().catch(()=>{})},[q])),u.useEffect(()=>{Q.current||r&&(L(pn({fallback:r.defaultPermissionMode,provider:"claude"})==="bypassPermissions"?"bypassPermissions":"default"),Q.current=!0)},[r]);const Z=u.useMemo(()=>!i?.synthesis||typeof i.synthesis!="object"?null:i.synthesis,[i]),me=Z?.investigation??null,O=!!(b||o?.synthesisInProgress||o?.latestStatus==="running"),W=Z?.meta.stage==="failed"||o?.latestStatus==="failed",ee=!!(i&&Z&&Z.meta.stage==="ready"&&!O&&!W),z=u.useMemo(()=>new Set(v.map(D=>D.id)),[v]),re=u.useMemo(()=>new Set(N.map(D=>D.id)),[N]),se=u.useMemo(()=>new Set(T.map(D=>D.id)),[T]),te=u.useMemo(()=>(me?.proposals??[]).filter(D=>D.status==="pending"&&!z.has(D.id)&&!re.has(D.id)&&!se.has(D.id)),[me,z,re,se]),xe=u.useMemo(()=>(me?.proposals??[]).filter(D=>D.status==="applied"),[me]),_e=u.useMemo(()=>(me?.proposals??[]).filter(D=>D.status==="dismissed"),[me]),I=Z?.meta.stage==="investigating"?"Investigating patterns...":O?"Analyzing recent sessions...":"",P=u.useCallback(D=>{w(be=>[...be,D])},[]),de=u.useCallback(D=>{w(be=>be.filter(Ce=>Ce.id!==D))},[]),X=u.useCallback(D=>{C(be=>[...be,D])},[]),G=u.useCallback(D=>{L(D),ma(D)},[]),V=u.useCallback(async()=>{if(v.length!==0){oe(!0);try{const D=i?.id||"",be={};for(const Ee of v)Ee.sourceSynthesisId&&Ee.sourceSynthesisId!==D&&(be[Ee.id]=Ee.sourceSynthesisId);await H.archiveCrossSessionProposals({synthesisId:D,proposalIds:v.map(Ee=>Ee.id),sourceSynthesisIds:Object.keys(be).length>0?be:void 0}),S(Ee=>[...Ee,...v]),w([]);const Ce=cj(v),je=await H.createConversation({provider:j,message:Ce,workingDirectory:"~",permissionMode:A});B(je.conversationId)}catch(D){g(D instanceof Error?D.message:"Failed to launch session")}finally{oe(!1)}}},[v,j,A,i?.id]);return s.jsxs("div",{className:"flex flex-col h-full bg-background text-foreground relative",children:[s.jsx("div",{className:"absolute inset-0 bg-[linear-gradient(rgba(0,255,255,0.015)_1px,transparent_1px),linear-gradient(90deg,rgba(0,255,255,0.015)_1px,transparent_1px)] bg-[size:20px_20px] pointer-events-none"}),s.jsxs("div",{className:"relative flex items-center justify-between px-5 py-3 border-b border-border/30 flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-[10px] font-display font-bold uppercase tracking-wider text-muted-foreground/40",children:"Cross-session analysis"}),ee&&!O&&s.jsx("button",{onClick:()=>{y(!0),H.runCrossSessionDeepScan().then(D=>{if(!D.started){g(D.reason||"Deep scan did not start."),y(!1);return}return f.current=D.startedAt||new Date().toISOString(),q()}).catch(D=>{g(D instanceof Error?D.message:"Failed to start deep scan"),y(!1)})},className:"px-2 py-0.5 text-[9px] font-display font-bold uppercase tracking-wider text-teal-400/60 border border-teal-500/20 rounded-sm hover:text-teal-300 hover:border-teal-500/40 hover:bg-teal-500/10 transition-all",children:"Deep scan"})]}),t&&s.jsx("button",{onClick:t,className:"p-1.5 text-muted-foreground/30 hover:text-foreground transition-colors","aria-label":"Close",children:s.jsx(Be,{size:14})})]}),s.jsx("div",{className:"relative flex-1 overflow-y-auto",children:s.jsx("div",{className:"max-w-2xl mx-auto px-6 py-10 space-y-6",children:c?s.jsx("div",{className:"flex min-h-[200px] items-center justify-center",children:s.jsx(Re,{size:18,className:"animate-spin text-cyan-400/40"})}):p?s.jsx("div",{className:"flex min-h-[200px] items-center justify-center",children:s.jsxs("div",{className:"text-center space-y-2",children:[s.jsx(Es,{size:16,className:"mx-auto text-red-400"}),s.jsx("div",{className:"text-sm text-foreground/80",children:"Failed to load"}),s.jsx("div",{className:"text-xs text-muted-foreground/50",children:p})]})}):ee?s.jsxs(s.Fragment,{children:[(te.length>0||v.length>0)&&s.jsxs("div",{className:"space-y-3",children:[v.map(D=>s.jsx(_s,{proposal:D,synthesisId:i?.id||"",cardState:"accepted",onUnaccept:de},D.id)),te.map(D=>s.jsx(_s,{proposal:D,synthesisId:i?.id||"",cardState:"pending",onAccepted:P,onDismissed:X,onReload:q},D.id))]}),te.length===0&&v.length===0&&N.length===0&&T.length===0&&xe.length===0&&_e.length===0&&s.jsx("div",{className:"text-sm text-muted-foreground/50",children:"Nothing to propose — your setup matches how you actually work."}),xe.length>0&&s.jsx(bo,{label:"Accepted",count:xe.length,color:"text-emerald-400/60",children:xe.map(D=>s.jsx(_s,{proposal:D,synthesisId:i?.id||"",cardState:"accepted"},D.id))}),N.length>0&&s.jsx(bo,{label:"Archived",count:N.length,color:"text-purple-400/60",children:N.map(D=>s.jsx(_s,{proposal:D,synthesisId:i?.id||"",cardState:"archived"},D.id))}),(T.length>0||_e.length>0)&&s.jsxs(bo,{label:"Rejected",count:T.length+_e.length,color:"text-rose-400/50",children:[T.map(D=>s.jsx(_s,{proposal:D,synthesisId:i?.id||"",cardState:"rejected"},D.id)),_e.map(D=>s.jsx(_s,{proposal:D,synthesisId:i?.id||"",cardState:"rejected"},D.id))]}),v.length>0&&s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"flex items-center rounded-sm border border-zinc-700/50 bg-zinc-900/50 p-0.5",children:s.jsx("div",{className:"px-3 py-1 rounded-sm text-[10px] font-display font-bold uppercase tracking-wider bg-cyan-500/20 text-cyan-300 border border-cyan-500/40",children:"claude"})}),s.jsx("div",{className:"flex items-center rounded-sm border border-zinc-700/50 bg-zinc-900/50 p-0.5",children:[{value:"default",label:"Ask",icon:Ms,activeColor:"bg-cyan-500/20 text-cyan-300 border border-cyan-500/40"},{value:"bypassPermissions",label:"Trust",icon:mr,activeColor:"bg-amber-500/20 text-amber-300 border border-amber-500/40"}].map(D=>{const be=D.icon;return s.jsxs("button",{onClick:()=>G(D.value),disabled:$,className:`flex items-center gap-1 px-3 py-1 rounded-sm text-[10px] font-display font-bold uppercase tracking-wider transition-all duration-100 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed ${A===D.value?D.activeColor:"text-zinc-500 hover:text-zinc-400 border border-transparent"}`,children:[s.jsx(be,{size:10}),D.label]},D.value)})}),s.jsx("button",{onClick:ne?()=>n(`/c/${ne}`):()=>{V()},disabled:$,className:"flex-1 flex items-center justify-center gap-2 py-1.5 rounded-sm ui-action-btn ui-action-btn--cool text-[10px] font-display font-bold uppercase tracking-wider bg-background/80 backdrop-blur-sm disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:shadow-none disabled:hover:translate-x-0 disabled:hover:translate-y-0",children:$?s.jsxs(s.Fragment,{children:[s.jsx(Re,{size:12,className:"animate-spin"}),"Starting..."]}):ne?s.jsxs(s.Fragment,{children:[s.jsx(Gt,{size:12}),"Go to Session"]}):s.jsxs(s.Fragment,{children:[s.jsx(Gt,{size:12}),"Start Session"]})})]})]}):s.jsx("div",{className:"flex flex-col items-center justify-center min-h-[200px] text-center space-y-3",children:O?s.jsxs(s.Fragment,{children:[s.jsx(Re,{size:18,className:"animate-spin text-cyan-400/40"}),s.jsx("div",{className:"text-sm text-muted-foreground/60",children:I})]}):W?s.jsxs(s.Fragment,{children:[s.jsx(Es,{size:16,className:"text-red-400"}),s.jsx("div",{className:"text-sm text-foreground/80",children:"Analysis failed"}),s.jsx("div",{className:"text-xs text-muted-foreground/50 max-w-sm",children:Z?.meta.error||me?.error||"Something went wrong."})]}):h?s.jsx("div",{className:"text-sm text-muted-foreground/60",children:h}):s.jsx("div",{className:"text-sm text-muted-foreground/50",children:"No analysis available yet."})})})})]})}function lj(){const t=Nt(),[e]=xa(),n=e.get("run")==="1";return s.jsx("div",{className:"h-dvh bg-background text-foreground flex flex-col overflow-hidden",children:s.jsx(Bp,{onClose:()=>t(-1),autoRun:n})})}const dj=2e3,cl=12e4,yo=[{value:"bug",label:"Bug",icon:Gl,color:"text-rose-400",bg:"bg-rose-500/10 border-rose-500/30"},{value:"comment",label:"Comment",icon:as,color:"text-sky-400",bg:"bg-sky-500/10 border-sky-500/30"}];function uj(t,e){return`You are a diagnostic agent investigating a user-reported bug in Lattice. Your job is to gather relevant context from logs and session state that would help the developer diagnose this issue.
|
|
271
271
|
|
|
272
272
|
## User's bug report
|
|
273
273
|
${t}
|
|
@@ -332,9 +332,9 @@ Split your findings into two groups:
|
|
|
332
332
|
Only include sections where you found relevant information — don't include empty sections.
|
|
333
333
|
If you find nothing relevant, say so in the summary and return empty arrays.
|
|
334
334
|
Be concise. The developer will read this alongside the user's bug report.`}function vo(t){return Array.isArray(t)?t.filter(e=>typeof e=="object"&&e!==null&&typeof e.label=="string"&&typeof e.text=="string"):[]}function pj(t){for(let e=t.length-1;e>=0;e--){const n=t[e];if(n.type!=="assistant")continue;const r=mj(n.message);if(!r)continue;const o=r.match(/```json\s*\n?([\s\S]*?)\n?\s*```/);if(o)try{const a=Fs(o[1]);if(typeof a.summary=="string"){const i=vo(a.related),l=vo(a.also_found);return i.length===0&&l.length===0&&Array.isArray(a.details)?{summary:String(a.summary),related:vo(a.details),alsoFound:[]}:{summary:String(a.summary),related:i,alsoFound:l}}}catch{}}return{summary:"",related:[],alsoFound:[]}}function mj(t){if(!t||typeof t!="object")return"";const e=t;return Array.isArray(e.content)?e.content.filter(n=>typeof n=="object"&&n!==null&&n.type==="text"&&typeof n.text=="string").map(n=>n.text).join(`
|
|
335
|
-
`):typeof e.content=="string"?e.content:""}function ll({finding:t,onRemove:e}){return s.jsxs("div",{className:"rounded-sm border border-border/15 bg-background/20 overflow-hidden group",children:[s.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[s.jsx("span",{className:"text-[9px] font-display uppercase tracking-widest text-muted-foreground/40",children:t.label}),s.jsx("button",{onClick:e,className:"p-0.5 text-muted-foreground/20 hover:text-rose-400/60 transition-colors cursor-pointer opacity-0 group-hover:opacity-100",title:"Remove from report",children:s.jsx(Lo,{size:10})})]}),s.jsx("div",{className:"px-2.5 pb-2",children:s.jsx("pre",{className:"text-[10px] font-mono text-foreground/60 leading-relaxed whitespace-pre-wrap",children:t.text})})]})}function hj({onClose:t,conversationId:e}){const[n,r]=u.useState("bug"),[o,a]=u.useState(""),[i,l]=u.useState(!1),[c,d]=u.useState(null),[p,m]=u.useState({summary:"",related:[],alsoFound:[]}),[h,g]=u.useState(null),f=u.useRef(null),x=u.useRef(null),b=u.useRef(!1),[y,v]=u.useState(!1),[w,N]=u.useState("compose");u.useEffect(()=>()=>{f.current&&clearInterval(f.current),x.current&&clearTimeout(x.current)},[]);const S=u.useCallback(()=>{f.current&&(clearInterval(f.current),f.current=null),x.current&&(clearTimeout(x.current),x.current=null)},[]),T=u.useCallback(async()=>{N("investigating"),g(null),b.current=!1;try{const V=uj(o,e),X=await G.createConversation({provider:"claude",message:V,workingDirectory:"/Users/jasonliggi/src/lattice-orchestrator",permissionMode:"bypassPermissions"});if(b.current)return;const q=X.conversationId;d(q);const K=Date.now(),ge=async()=>{if(b.current){S();return}if(Date.now()-K>cl){S(),g("Investigation timed out. You can still send the feedback without debug context.");return}try{if((await G.getSessionsStatus([q])).sessions[q]?.status==="completed"){if(S(),b.current)return;try{const Z=await G.getConversationDetails(q,{limit:50}),F=pj(Z.messages);m(F),!F.summary&&F.related.length===0&&F.alsoFound.length===0&&g("Investigation completed but found no relevant diagnostics.")}catch(Z){console.error("[FeedbackPanel] Failed to fetch investigation results:",Z),g("Investigation completed but failed to retrieve results.")}N("review")}}catch(D){console.warn("[FeedbackPanel] Poll error:",D)}};f.current=setInterval(()=>{ge()},dj),x.current=setTimeout(()=>{!b.current&&f.current&&(S(),g("Investigation timed out after 2 minutes."),N("review"))},cl)}catch(V){console.error("[FeedbackPanel] Failed to launch investigation:",V),g("Failed to launch investigation session. You can still send feedback without debug context."),N("review")}},[o,e,S]),C=u.useCallback(async V=>{v(!0);try{const X={category:n,message:o,findings:V,conversationId:e||null,investigationConversationId:c,timestamp:new Date().toISOString(),userAgent:navigator.userAgent};await fetch("/api/feedback/submit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(X)}),N("sent")}catch(X){console.error("[FeedbackPanel] Failed to submit feedback:",X),N("sent")}finally{v(!1)}},[n,o,e,c]),j=u.useCallback(()=>{i&&n==="bug"&&w==="compose"?T():w==="compose"&&C(null)},[i,n,w,T,C]),E=p.summary||p.related.length>0||p.alsoFound.length>0,R=u.useCallback(()=>{C(E?p:null)},[E,p,C]),O=u.useCallback(()=>{b.current=!0,S(),N("compose"),d(null),g(null)},[S]),$=u.useCallback(()=>{N("compose"),a(""),l(!1),d(null),m({summary:"",related:[],alsoFound:[]}),g(null),r("bug")},[]),re=yo.find(V=>V.value===n)||yo[0],ne=re.icon;return s.jsxs("div",{className:"h-full flex flex-col bg-background relative overflow-hidden",children:[s.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[linear-gradient(rgba(0,255,255,0.015)_1px,transparent_1px),linear-gradient(90deg,rgba(0,255,255,0.015)_1px,transparent_1px)] bg-[size:20px_20px]"}),s.jsxs("div",{className:"relative border-b border-border/30 px-6 py-3 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(as,{size:12,className:"text-muted-foreground/40"}),s.jsx("span",{className:"text-[10px] font-display font-bold uppercase tracking-wider text-muted-foreground/60",children:"Feedback"})]}),s.jsx("button",{onClick:t,className:"p-1 text-muted-foreground/40 hover:text-muted-foreground transition-colors cursor-pointer",children:s.jsx(Be,{size:14})})]}),s.jsx("div",{className:"relative flex-1 overflow-y-auto",children:s.jsxs("div",{className:"max-w-xl mx-auto px-6 py-10 space-y-6",children:[w==="compose"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("span",{className:"text-[9px] font-display uppercase tracking-widest text-muted-foreground/50",children:"What kind of feedback?"}),s.jsx("div",{className:"grid grid-cols-2 gap-2",children:yo.map(V=>{const X=V.icon,q=n===V.value;return s.jsxs("button",{onClick:()=>r(V.value),className:`relative flex items-center gap-2.5 px-3 py-2.5 rounded-sm border transition-all cursor-pointer overflow-hidden ${q?`${V.bg} ${V.color}`:"border-border/20 text-muted-foreground/40 hover:border-border/40 hover:text-muted-foreground/60"}`,children:[q&&s.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[linear-gradient(rgba(0,255,255,0.02)_1px,transparent_1px),linear-gradient(90deg,rgba(0,255,255,0.02)_1px,transparent_1px)] bg-[size:18px_18px]"}),s.jsx(X,{size:14,className:"relative"}),s.jsx("span",{className:"relative text-[11px] font-display font-bold uppercase tracking-wider",children:V.label})]},V.value)})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("span",{className:"text-[9px] font-display uppercase tracking-widest text-muted-foreground/50",children:"Details"}),s.jsx("textarea",{value:o,onChange:V=>a(V.target.value),placeholder:"Describe what happened, what you expected, or what you'd like to see...",rows:5,className:"w-full bg-background/50 border border-border/30 rounded-sm px-3 py-2.5 text-sm font-mono placeholder:text-muted-foreground/30 focus:outline-none focus:border-cyan-500/40 resize-none leading-relaxed"})]}),n==="bug"&&s.jsx("div",{className:"rounded-sm border border-border/20 bg-muted/5 p-3",children:s.jsxs("button",{type:"button",onClick:()=>l(V=>!V),className:"flex items-start gap-2.5 cursor-pointer w-full text-left",children:[s.jsx("div",{className:`mt-0.5 w-4 h-4 rounded-sm border flex items-center justify-center transition-all flex-shrink-0 ${i?"border-cyan-500/50 bg-cyan-500/15":"border-border/40"}`,children:i&&s.jsx(Oe,{size:10,className:"text-cyan-400"})}),s.jsx("span",{className:"text-sm font-mono text-muted-foreground/50 leading-relaxed",children:"Launch an agent to investigate recent logs and session state. You'll review everything before it sends."})]})}),s.jsx("button",{onClick:j,disabled:!o.trim(),className:"w-full flex items-center justify-center gap-2 py-2 rounded-sm ui-action-btn ui-action-btn--cool text-[10px] font-display font-bold uppercase tracking-wider bg-background/80 backdrop-blur-sm disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:shadow-none disabled:hover:translate-x-0 disabled:hover:translate-y-0",children:i&&n==="bug"?s.jsxs(s.Fragment,{children:[s.jsx(Gt,{size:12}),"Launch Investigation"]}):s.jsxs(s.Fragment,{children:[s.jsx(ji,{size:12}),"Send Feedback"]})})]}),w==="investigating"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rounded-sm border border-border/20 bg-background/30 px-3 py-2 flex items-center gap-2",children:[s.jsx(ne,{size:10,className:re.color}),s.jsx("span",{className:"text-xs font-mono text-foreground/60 truncate flex-1",children:o}),s.jsx("span",{className:`text-[9px] font-display uppercase tracking-widest ${re.color}`,children:re.label})]}),s.jsx("div",{className:"rounded-sm border border-cyan-500/15 bg-cyan-500/[0.03] p-6",children:s.jsxs("div",{className:"flex flex-col items-center text-center space-y-3",children:[s.jsx(Ae,{size:20,className:"animate-spin text-cyan-400/60"}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("span",{className:"text-[10px] font-display font-bold uppercase tracking-wider text-cyan-400/70 block",children:"Investigation running"}),s.jsx("span",{className:"text-[10px] font-mono text-muted-foreground/40 block",children:"A session is analyzing logs and session state. This usually takes 15–30 seconds."})]}),c&&s.jsxs("a",{href:`/c/${c}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-[10px] font-mono text-muted-foreground/30 hover:text-muted-foreground/50 transition-colors",children:[s.jsx(os,{size:10}),"View session"]})]})}),s.jsx("button",{onClick:O,className:"w-full flex items-center justify-center gap-2 py-1.5 rounded-sm border border-border/30 text-[10px] font-display font-bold uppercase tracking-wider text-muted-foreground/50 hover:text-muted-foreground hover:border-border/50 transition-all cursor-pointer",children:"Cancel"})]}),w==="review"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("span",{className:"text-[9px] font-display uppercase tracking-widest text-muted-foreground/50",children:"Review before sending"}),s.jsx("p",{className:"text-[10px] font-mono text-muted-foreground/40 leading-relaxed",children:"This is exactly what will be submitted. Remove any sections you don't want included."})]}),h&&s.jsxs("div",{className:"rounded-sm border border-amber-500/20 bg-amber-500/5 px-3 py-2 flex items-start gap-2",children:[s.jsx(kt,{size:12,className:"text-amber-400/60 mt-0.5 flex-shrink-0"}),s.jsx("span",{className:"text-[10px] font-mono text-amber-400/70 leading-relaxed",children:h})]}),s.jsxs("div",{className:"rounded-sm border border-border/25 bg-background/35 overflow-hidden",children:[s.jsxs("div",{className:"px-3 py-1.5 border-b border-border/15 flex items-center gap-2",children:[s.jsx(ne,{size:10,className:re.color}),s.jsx("span",{className:"text-[9px] font-display uppercase tracking-widest text-muted-foreground/50",children:"Your feedback"})]}),s.jsx("div",{className:"px-3 py-2.5",children:s.jsx("p",{className:"text-sm font-mono text-foreground/80 leading-relaxed",children:o})})]}),(p.summary||p.related.length>0)&&s.jsxs("div",{className:"rounded-sm border border-cyan-500/20 bg-cyan-500/[0.03] overflow-hidden",children:[s.jsxs("div",{className:"px-3 py-1.5 border-b border-cyan-500/10 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ms,{size:10,className:"text-cyan-400/60"}),s.jsx("span",{className:"text-[9px] font-display uppercase tracking-widest text-cyan-400/60",children:"Related to your bug"})]}),s.jsx("button",{onClick:()=>m(V=>({...V,summary:"",related:[]})),className:"text-[9px] font-mono text-rose-400/50 hover:text-rose-400 transition-colors cursor-pointer",children:"Remove all"})]}),s.jsxs("div",{className:"px-3 py-3 space-y-3",children:[p.summary&&s.jsxs("div",{children:[s.jsx("span",{className:"text-[9px] font-display uppercase tracking-widest text-muted-foreground/40",children:"Summary"}),s.jsx("p",{className:"mt-1 text-xs font-mono text-foreground/70 leading-relaxed",children:p.summary})]}),p.related.length>0&&s.jsx("div",{className:"space-y-2 pt-1",children:p.related.map((V,X)=>s.jsx(ll,{finding:V,onRemove:()=>{m(q=>({...q,related:q.related.filter((K,ge)=>ge!==X)}))}},`related-${V.label}-${X}`))})]})]}),p.alsoFound.length>0&&s.jsxs("div",{className:"rounded-sm border border-border/20 bg-muted/[0.03] overflow-hidden",children:[s.jsxs("div",{className:"px-3 py-1.5 border-b border-border/10 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(kt,{size:10,className:"text-amber-400/50"}),s.jsx("span",{className:"text-[9px] font-display uppercase tracking-widest text-muted-foreground/40",children:"Also found"})]}),s.jsx("button",{onClick:()=>m(V=>({...V,alsoFound:[]})),className:"text-[9px] font-mono text-rose-400/50 hover:text-rose-400 transition-colors cursor-pointer",children:"Remove all"})]}),s.jsx("div",{className:"px-3 py-3 space-y-2",children:p.alsoFound.map((V,X)=>s.jsx(ll,{finding:V,onRemove:()=>{m(q=>({...q,alsoFound:q.alsoFound.filter((K,ge)=>ge!==X)}))}},`also-${V.label}-${X}`))})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{onClick:()=>N("compose"),className:"flex-1 flex items-center justify-center gap-2 py-2 rounded-sm border border-border/30 text-[10px] font-display font-bold uppercase tracking-wider text-muted-foreground/60 hover:text-muted-foreground hover:border-border/50 transition-all cursor-pointer",children:"Back"}),s.jsxs("button",{onClick:R,disabled:y,className:"flex-[2] flex items-center justify-center gap-2 py-2 rounded-sm ui-action-btn ui-action-btn--cool text-[10px] font-display font-bold uppercase tracking-wider bg-background/80 backdrop-blur-sm disabled:opacity-50",children:[y?s.jsx(Ae,{size:12,className:"animate-spin"}):s.jsx(ji,{size:12}),E?"Send with Context":"Send Feedback"]})]})]}),w==="sent"&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[s.jsx("div",{className:"w-10 h-10 rounded-full border border-emerald-500/40 bg-emerald-500/10 flex items-center justify-center mb-4",children:s.jsx(Oe,{size:20,className:"text-emerald-400"})}),s.jsx("span",{className:"text-sm font-display font-semibold text-foreground/90",children:"Feedback sent"}),s.jsx("span",{className:"text-xs text-muted-foreground/50 mt-1.5 font-mono max-w-xs",children:"Thanks. This goes directly to the developer."}),s.jsx("button",{onClick:$,className:"mt-8 px-4 py-1.5 rounded-sm border border-border/30 text-[10px] font-display font-bold uppercase tracking-wider text-muted-foreground/50 hover:text-muted-foreground hover:border-border/50 transition-all cursor-pointer",children:"Send another"})]})]})})]})}function Up(t){if(!t)return null;const e=t.trim();return!e||e==="~"?null:e.replace(/\/+$/,"")||null}function fj(t){const e=Up(t);if(!e)return[];const n=`${e}/**`;return[`Read(${n})`,`Write(${n})`,`Edit(${n})`]}function gj({toolName:t,toolInput:e}){switch(t){case"Bash":return s.jsxs("div",{className:"space-y-2",children:[!!e.description&&s.jsx("div",{className:"text-xs text-muted-foreground",children:e.description}),s.jsx("pre",{className:"font-mono text-sm text-foreground whitespace-pre-wrap break-all bg-neutral-950 rounded p-3",children:e.command})]});case"Read":case"Write":return s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"font-mono text-sm text-foreground",children:e.file_path}),!!e.content&&s.jsxs("pre",{className:"font-mono text-xs text-foreground/80 whitespace-pre-wrap break-all bg-neutral-950 rounded p-3 max-h-64 overflow-auto",children:[e.content.slice(0,2e3),e.content.length>2e3&&"..."]})]});case"Edit":return s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"font-mono text-sm text-foreground",children:e.file_path}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-red-400 mb-1",children:"Old:"}),s.jsx("pre",{className:"font-mono text-xs text-foreground/80 whitespace-pre-wrap break-all bg-red-950/30 rounded p-2 max-h-32 overflow-auto",children:e.old_string})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-emerald-400 mb-1",children:"New:"}),s.jsx("pre",{className:"font-mono text-xs text-foreground/80 whitespace-pre-wrap break-all bg-emerald-950/30 rounded p-2 max-h-32 overflow-auto",children:e.new_string})]})]})]});default:return s.jsx("pre",{className:"font-mono text-xs text-foreground/80 whitespace-pre-wrap break-all bg-neutral-950 rounded p-3 max-h-64 overflow-auto",children:JSON.stringify(e,null,2)})}}function xj(t,e){switch(t){case"Bash":return e.command||"";case"Read":case"Write":case"Edit":return e.file_path||"";case"Grep":return`"${String(e.pattern??"")}" in ${String(e.path??"")}`;case"Glob":return e.pattern||"";case"WebFetch":return e.url||"";case"Task":return e.description||e.prompt?.slice(0,50)||"";default:return JSON.stringify(e).slice(0,60)}}function bj(t,e,n){if(n===0)return"Only this exact operation";if(n===e-1){const i=t.match(/^([A-Za-z]+)$/);if(i)return`All ${i[1].toLowerCase()} operations`}const r=t.match(/^([A-Za-z]+)\((.+)\)$/);if(!r)return t;const[,o,a]=r;if(o==="Bash")return a.endsWith(" *")?`Any "${a.slice(0,-2)}" command`:`Commands matching "${a}"`;if(["Write","Read","Edit"].includes(o)){if(a.startsWith("*."))return`Any ${a.slice(1)} file`;if(a.includes("**")){const i=a.split("**");return i[0]&&i[1]?`Any ${i[1].replace(/^\/?\*?/,"")} file under ${i[0].replace(/\/$/,"")}`:`Any file under ${a.replace("/**","")}`}if(a.includes("*")){const i=a.substring(0,a.lastIndexOf("/")),l=a.includes(".")?a.split(".").pop():null;return l?`Any .${l} file in ${i||"this directory"}`:`Any file in ${i||"this directory"}`}return`File: ${a}`}return t}function yj({onApprove:t,onDeny:e,isLoading:n}){return s.jsx("div",{"data-testid":"plan-approval-banner",className:"border border-rose-500/30 rounded-lg overflow-hidden bg-rose-500/5",children:s.jsxs("div",{className:"bg-rose-500/10 px-4 py-3 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[s.jsx(Ph,{size:16,className:"text-rose-400 shrink-0"}),s.jsx("div",{className:"min-w-0",children:s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"font-display text-xs font-bold text-rose-400 uppercase tracking-wider",children:"Implement Plan"}),s.jsx("span",{className:"text-muted-foreground/40 shrink-0",children:"·"}),s.jsx("span",{className:"text-sm text-foreground/70",children:"Claude is ready to implement the plan above"})]})})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2 shrink-0 sm:justify-end",children:[s.jsxs("button",{onClick:r=>{r.stopPropagation(),e("Plan rejected — please revise or take a different approach.")},disabled:n,className:"group flex min-h-9 items-center gap-1.5 px-3 py-1.5 rounded-sm bg-background/80 border border-border/30 text-muted-foreground text-xs font-display uppercase tracking-wider hover:border-red-500/30 hover:text-red-400 transition-colors disabled:opacity-50",children:[s.jsx(Be,{size:12}),"Reject"]}),s.jsxs("button",{"data-testid":"plan-approve-button",onClick:r=>{r.stopPropagation(),t()},disabled:n,className:"group flex min-h-9 items-center gap-1.5 px-3 py-1.5 rounded-sm bg-background/80 border border-rose-500/30 text-rose-400 text-xs font-display uppercase tracking-wider hover:border-rose-400 hover:bg-rose-500/5 transition-colors disabled:opacity-50",children:[s.jsx(Oe,{size:12}),"Approve"]})]})]})})}function vj({permission:t,streamingId:e,workingDirectory:n,onApprove:r,onApprovePattern:o,onApprovePatterns:a,onDeny:i,isLoading:l}){const c=t.toolName==="ExitPlanMode"||t.toolName==="exit_plan_mode",[d,p]=u.useState(!1),[m,h]=u.useState(!1),[g,f]=u.useState([]),[x,b]=u.useState(!1),y=xj(t.toolName,t.toolInput),v=u.useMemo(()=>Up(n),[n]),w=u.useMemo(()=>fj(n),[n]),N=v?.split("/").filter(Boolean).pop()||"project";u.useEffect(()=>{c||g.length>0||x||(b(!0),G.getSuggestedPatterns(t.toolName,t.toolInput).then(({patterns:C})=>f(C)).catch(C=>{console.error("Failed to fetch suggested patterns:",C),f([t.toolName])}).finally(()=>b(!1)))},[t.id]);const S=C=>{h(!1),o(C,"global")},T=C=>{w.length!==0&&(h(!1),a(w,C))};return c?s.jsx(yj,{onApprove:r,onDeny:i,isLoading:l}):s.jsxs("div",{"data-testid":"permission-banner",className:"border border-amber-500/30 rounded-lg overflow-hidden bg-amber-500/5",children:[s.jsxs("div",{className:"bg-amber-500/10 px-4 py-3 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("button",{onClick:()=>p(!d),className:"flex items-start gap-3 flex-1 min-w-0 text-left",disabled:l,children:[d?s.jsx(Lt,{size:14,className:"text-amber-400 shrink-0 mt-0.5"}):s.jsx(Ut,{size:14,className:"text-amber-400 shrink-0 mt-0.5"}),s.jsx(Yl,{size:16,className:"text-amber-400 shrink-0 mt-0.5"}),s.jsx("div",{className:"min-w-0 flex-1",children:s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-wrap",children:[s.jsx("span",{className:"font-display text-xs font-bold text-amber-400 uppercase tracking-wider shrink-0",children:t.toolName}),s.jsx("span",{className:"text-muted-foreground/40 shrink-0",children:"·"}),s.jsx("span",{className:`text-sm text-foreground/70 font-mono ${d?"break-all":"line-clamp-2 break-all sm:line-clamp-1"}`,children:y})]})})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2 shrink-0 sm:justify-end",children:[s.jsxs("button",{onClick:C=>{C.stopPropagation(),i()},disabled:l,className:"group flex min-h-9 items-center gap-1.5 px-3 py-1.5 rounded-sm bg-background/80 border border-border/30 text-muted-foreground text-xs font-display uppercase tracking-wider hover:border-red-500/30 hover:text-red-400 transition-colors disabled:opacity-50",children:[s.jsx(Be,{size:12}),"Deny"]}),s.jsxs("button",{"data-testid":"permission-allow-button",onClick:C=>{C.stopPropagation(),r()},disabled:l,className:"group flex min-h-9 items-center gap-1.5 px-3 py-1.5 rounded-sm bg-background/80 border border-emerald-500/30 text-emerald-400 text-xs font-display uppercase tracking-wider hover:border-emerald-400 hover:bg-emerald-500/5 transition-colors disabled:opacity-50",children:[s.jsx(Oe,{size:12}),"Allow"]}),s.jsxs("button",{onClick:C=>{C.stopPropagation(),h(!m)},disabled:l,className:`group flex min-h-9 items-center gap-1.5 px-3 py-1.5 rounded-sm bg-background/80 border text-xs font-display uppercase tracking-wider transition-colors disabled:opacity-50 ${m?"border-sky-400 text-sky-400 bg-sky-500/5":"border-sky-500/30 text-sky-400 hover:border-sky-400 hover:bg-sky-500/5"}`,children:[m?s.jsx(Lt,{size:12}):s.jsx(Ut,{size:12}),"Allow Always"]})]})]}),d&&!m&&s.jsx("div",{className:"border-t border-amber-500/20 px-4 py-3 bg-background/50",children:s.jsx(gj,{toolName:t.toolName,toolInput:t.toolInput})}),m&&s.jsxs("div",{className:"border-t border-amber-500/20 bg-background/30",children:[w.length>0&&v&&s.jsx("div",{className:"px-3 pt-3",children:s.jsxs("div",{className:"rounded-md border border-sky-500/20 bg-sky-500/5 overflow-hidden",children:[s.jsxs("div",{className:"px-4 py-3 border-b border-sky-500/20 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Jh,{size:14,className:"text-sky-400 shrink-0"}),s.jsx("span",{className:"text-[11px] font-display font-bold uppercase tracking-wider text-sky-300",children:"Trust Project Files"})]}),s.jsxs("p",{className:"mt-1 text-xs text-foreground/75",children:["Allow Claude to read and edit files anywhere under ",s.jsx("span",{className:"font-medium text-foreground",children:N}),"."]}),s.jsxs("p",{className:"mt-1 font-mono text-[11px] text-sky-200/80 break-all",children:[v,"/**"]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2 shrink-0 sm:justify-end",children:[s.jsx("button",{onClick:()=>T("session"),className:"min-h-8 px-2.5 py-1.5 rounded-sm border border-sky-500/30 text-sky-300 text-[10px] font-display uppercase tracking-wider hover:border-sky-400 hover:bg-sky-500/10 transition-colors",children:"This Session"}),s.jsx("button",{onClick:()=>T("global"),className:"min-h-8 px-2.5 py-1.5 rounded-sm border border-sky-400/40 text-sky-200 text-[10px] font-display uppercase tracking-wider hover:border-sky-300 hover:bg-sky-500/10 transition-colors",children:"Always"})]})]}),s.jsxs("div",{className:"px-4 py-2 text-[10px] text-muted-foreground border-t border-border/20",children:["Adds ",s.jsx("span",{className:"font-mono text-foreground/80",children:"Read"}),", ",s.jsx("span",{className:"font-mono text-foreground/80",children:"Write"}),", and ",s.jsx("span",{className:"font-mono text-foreground/80",children:"Edit"})," allowlist rules for this working directory."]})]})}),w.length>0&&s.jsx("div",{className:"px-4 pt-3 text-[10px] font-display uppercase tracking-wider text-muted-foreground/70",children:"More Specific Patterns"}),s.jsx("div",{className:"py-2",children:x?s.jsx("div",{className:"px-4 py-4 text-center text-xs text-muted-foreground",children:"Loading patterns..."}):g.map((C,j)=>{const E=bj(C,g.length,j),R=j===0,O=j===g.length-1&&g.length>1;return s.jsxs("button",{onClick:()=>S(C),className:"w-full text-left px-4 py-2.5 hover:bg-accent/30 transition-colors flex items-center gap-3 group",children:[s.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${R?"bg-emerald-400":O?"bg-amber-400":"bg-muted-foreground/30"}`}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("span",{className:"font-mono text-xs text-foreground/80",children:C}),s.jsx("span",{className:"text-[11px] text-muted-foreground block mt-0.5",children:E})]}),R&&s.jsx("span",{className:"text-[9px] uppercase tracking-wider text-emerald-400/70 bg-emerald-500/10 px-1.5 py-0.5 rounded shrink-0",children:"safest"}),O&&s.jsx("span",{className:"text-[9px] uppercase tracking-wider text-amber-400/70 bg-amber-500/10 px-1.5 py-0.5 rounded shrink-0",children:"broad"}),s.jsx(Oe,{size:14,className:"shrink-0 opacity-0 group-hover:opacity-100 transition-opacity text-violet-400"})]},C)})}),s.jsx("div",{className:"px-4 py-2 border-t border-border/20 text-[10px] text-muted-foreground",children:s.jsx("span",{children:'Patterns added here are saved globally. Use "This Session" above for repo trust without persisting it.'})})]})]})}function Gp(t){for(let e=t.length-1;e>=0;e--)switch(t[e].type){case"run:end":case"run:error":case"turn:end":return"idle";case"stop:requested":return"stopping";case"content":case"result":return"streaming";case"input:sent":for(let n=e-1;n>=0;n--){if(t[n].type==="run:ready")return"streaming";if(t[n].type==="run:start")return"starting"}return"streaming";case"run:ready":for(let n=e-1;n>=0;n--){if(t[n].type==="input:sent")return"streaming";if(t[n].type==="turn:end"||t[n].type==="run:end"||t[n].type==="run:start")return"idle"}return"idle";case"run:start":return"starting"}return"idle"}function wj(t){for(let e=t.length-1;e>=0;e--)switch(t[e].type){case"run:end":case"run:error":return!1;case"run:start":case"run:ready":case"content":case"result":case"input:sent":case"turn:end":case"stop:requested":case"task:started":case"task:updated":case"task:notification":case"task:output":return!0}return!1}function _j(t){let e=null,n;for(let r=t.length-1;r>=0;r--){const o=t[r];if(!e&&o.type==="turn:end"){const a=o.data;a.usage&&(e={inputTokens:a.usage.input_tokens??0,outputTokens:a.usage.output_tokens??0,cacheCreationInputTokens:a.usage.cache_creation_input_tokens??0,cacheReadInputTokens:a.usage.cache_read_input_tokens??0,costUsd:a.costUsd})}if(n===void 0&&o.type==="content"){const a=o.data;a.apiUsage&&(n=(a.apiUsage.input_tokens??0)+(a.apiUsage.cache_creation_input_tokens??0)+(a.apiUsage.cache_read_input_tokens??0))}if(e&&n!==void 0)break}return e?(e.contextTokens=n,e):n!==void 0?{inputTokens:0,outputTokens:0,cacheCreationInputTokens:0,cacheReadInputTokens:0,contextTokens:n}:null}function kj(t){const e=new Map;for(const n of t){if(n.type==="run:end"||n.type==="run:error"){e.clear();continue}if(n.type==="task:started"){const r=n.data;if(r.taskType!=="local_bash")continue;e.set(r.taskId,{taskId:r.taskId,toolUseId:r.toolUseId,description:r.description,taskType:r.taskType,status:"running"})}else if(n.type==="task:updated"){const r=n.data,o=e.get(r.taskId);if(!o)continue;r.patch.status!=="running"&&(o.status="completed")}else if(n.type==="task:notification"){const r=n.data,o=e.get(r.taskId);o&&(o.status="completed")}}return e}function jj(t){const e=kj(t);for(const n of e.values())if(n.status==="running")return!0;return!1}function Nj(t){if(Gp(t)!=="streaming")return null;for(let n=t.length-1;n>=0;n--){const r=t[n];if(r.type==="content"){const o=r.data.blocks;if(!o||o.length===0)continue;const a=o[o.length-1];if(a.type==="thinking")return{type:"thinking"};if(a.type==="tool_use")return{type:"tool",name:a.name,input:a.input}}if(r.type==="turn:end")return null}return null}async function Sj(t,e){const n=t.getReader();for(;;){const r=await n.read();if(r.done)break;e(r.value)}}var ts;(function(t){t[t.NewLine=10]="NewLine",t[t.CarriageReturn=13]="CarriageReturn",t[t.Space=32]="Space",t[t.Colon=58]="Colon"})(ts||(ts={}));function Cj(t){let e,n,r,o=!1;return function(i){e===void 0?(e=i,n=0,r=-1):e=Tj(e,i);const l=e.length;let c=0;for(;n<l;){o&&(e[n]===ts.NewLine&&(c=++n),o=!1);let d=-1;for(;n<l&&d===-1;++n)switch(e[n]){case ts.Colon:r===-1&&(r=n-c);break;case ts.CarriageReturn:o=!0;case ts.NewLine:d=n;break}if(d===-1)break;t(e.subarray(c,d),r),c=n,r=-1}c===l?e=void 0:c!==0&&(e=e.subarray(c),n-=c)}}function Ej(t,e,n){let r=dl();const o=new TextDecoder;return function(i,l){if(i.length===0)n?.(r),r=dl();else if(l>0){const c=o.decode(i.subarray(0,l)),d=l+(i[l+1]===ts.Space?2:1),p=o.decode(i.subarray(d));switch(c){case"data":r.data=r.data?r.data+`
|
|
336
|
-
`+p:p;break;case"event":r.event=p;break;case"id":t(r.id=p);break;case"retry":{const m=parseInt(p,10);isNaN(m)||e(r.retry=m);break}}}}}function Tj(t,e){const n=new Uint8Array(t.length+e.length);return n.set(t),n.set(e,t.length),n}function dl(){return{data:"",event:"",id:"",retry:void 0}}const ul=1e3,pl=3e4,wo=10,Ij=25e3;class Aj{controller=null;options;running=!1;looping=!1;visibilityHandler=null;connectionEstablished=!1;constructor(e){this.options=e}start(){this.running||(this.running=!0,this.connectLoop(),this.setupVisibilityHandler())}stop(){this.running=!1,this.looping=!1,this.controller?.abort(),this.controller=null,this.teardownVisibilityHandler()}async connectLoop(){if(!this.looping){this.looping=!0;try{let e=0;for(;this.running;){this.connectionEstablished=!1,this.controller=new AbortController;try{if(await this.connect(this.controller.signal)==="no_session"){if(e++,e>=wo){this.running=!1;return}const r=Math.min(ul*2**e,pl);await ml(r);continue}e=0}catch{if(!this.running||typeof document<"u"&&document.hidden)return;if(this.connectionEstablished?e=0:e++,e>=wo){this.options.onError(`Connection failed after ${wo} retries`),this.running=!1;return}const r=Math.min(ul*2**e,pl);await ml(r)}this.running&&this.options.onDisconnected()}}finally{this.looping=!1}}}async connect(e){const n=this.options.getLastSeq(),r=`${this.options.url}?after=${n}`,o=await fetch(r,{headers:{Accept:"text/event-stream"},signal:e});if(!o.ok)throw new Error(`SSE connect failed: ${o.status}`);if(!o.body)throw new Error("SSE response has no body");let a=!1,i=!1,l=null;const c=()=>{l&&clearTimeout(l),l=setTimeout(()=>{this.controller?.abort()},Ij)},d=()=>{l&&(clearTimeout(l),l=null)};try{await Sj(o.body,Cj(Ej(()=>{},()=>{},p=>{if(c(),p.event==="reset"){try{(p.data?JSON.parse(p.data):{}).reason==="no_session"&&(i=!0)}catch{}this.options.onReset();return}if(a||(a=!0,this.connectionEstablished=!0,this.options.onConnected()),p.event==="replay_meta"){if(p.data&&this.options.onReplayMeta)try{this.options.onReplayMeta(JSON.parse(p.data))}catch{}return}if(p.data)try{const m=JSON.parse(p.data);this.options.onEvent(m)}catch{}})))}finally{d()}return i?"no_session":"ok"}setupVisibilityHandler(){typeof document>"u"||(this.visibilityHandler=()=>{document.hidden?this.controller?.abort():this.running&&!this.looping&&this.connectLoop()},document.addEventListener("visibilitychange",this.visibilityHandler))}teardownVisibilityHandler(){this.visibilityHandler&&typeof document<"u"&&(document.removeEventListener("visibilitychange",this.visibilityHandler),this.visibilityHandler=null)}}function ml(t){return new Promise(e=>setTimeout(e,t))}const hl=2e3,fl=50;class Rj{entries=[];record(e){let n;switch(e.type){case"EVENT":n=`seq=${e.event.seq} type=${e.event.type}`;break;case"RESET":n=`count=${e.events.length} seqRange=${e.events[0]?.seq??"-"}..${e.events.at(-1)?.seq??"-"}`;break;case"PREPEND_HISTORY":n=`count=${e.events.length} seqRange=${e.events[0]?.seq??"-"}..${e.events.at(-1)?.seq??"-"}`;break;case"ERROR":n=e.message;break}this.entries.push({action:e.type,ts:Date.now(),detail:n}),this.entries.length>fl&&this.entries.splice(0,this.entries.length-fl)}snapshot(){return[...this.entries]}}function Pj(t,e){switch(e.type){case"EVENT":{if(t.lastSeq>0&&e.event.seq<=t.lastSeq)return t;const n=[...t.events,e.event],r=n.length>hl?n.slice(n.length-hl):n;return{...t,events:r,lastSeq:e.event.seq}}case"CONNECTED":return{...t,connected:!0,error:null};case"DISCONNECTED":return{...t,connected:!1};case"ERROR":return{...t,error:e.message};case"RESET":return{...t,events:e.events,lastSeq:e.events.at(-1)?.seq??0};case"PREPEND_HISTORY":if(e.events.length===0)return t;{const n=new Set(t.events.map(a=>a.seq)),r=e.events.filter(a=>!n.has(a.seq));if(r.length===0)return t;const o=[...r,...t.events];return o.sort((a,i)=>a.seq-i.seq),{...t,events:o}}}}const Mj={events:[],lastSeq:0,connected:!1,error:null};function Lj(t,e){const[n,r]=u.useReducer(Pj,Mj),o=u.useRef(null),a=u.useRef("idle"),i=u.useRef(0),l=u.useRef(e);l.current=e;const c=u.useRef(new Rj),d=u.useCallback(C=>{c.current.record(C),r(C)},[]),[p,m]=u.useState(0),h=u.useRef(null);u.useEffect(()=>{if(!t){d({type:"RESET",events:[]}),i.current=0,h.current=null;return}const C=t!==h.current;h.current=t,C&&(d({type:"RESET",events:[]}),i.current=0);const j=new Aj({url:`${e.baseUrl}/${t}/events`,onEvent:E=>{i.current=E.seq,d({type:"EVENT",event:E}),l.current.onEvent?.(E)},onConnected:()=>{d({type:"CONNECTED"}),i.current===0&&(async()=>{if(await new Promise(E=>setTimeout(E,50)),!(i.current>0))try{const E=await fetch(`${l.current.baseUrl}/${t}/history?before=${Number.MAX_SAFE_INTEGER}&limit=200`);if(E.ok){const R=await E.json();R.events.length>0&&(i.current===0?(i.current=R.events.at(-1)?.seq??0,d({type:"RESET",events:R.events})):d({type:"PREPEND_HISTORY",events:R.events}))}}catch{}})()},onDisconnected:()=>{d({type:"DISCONNECTED"})},onReset:async()=>{const E=await l.current.onReset?.()??[];if(E.length>0){i.current=E.at(-1)?.seq??0,d({type:"RESET",events:E});return}try{const R=await fetch(`${l.current.baseUrl}/${t}/history?before=${Number.MAX_SAFE_INTEGER}&limit=200`);if(R.ok){const O=await R.json();if(O.events.length>0){i.current=O.events.at(-1)?.seq??0,d({type:"RESET",events:O.events});return}}}catch{}i.current=0,d({type:"RESET",events:[]})},onReplayMeta:E=>{E.scoped&&(async()=>{try{const R=await fetch(`${l.current.baseUrl}/${t}/history?before=${Number.MAX_SAFE_INTEGER}&limit=200`);if(R.ok){const O=await R.json();O.events.length>0&&d({type:"PREPEND_HISTORY",events:O.events})}}catch{}})()},onError:E=>{d({type:"ERROR",message:E})},getLastSeq:()=>i.current});return o.current=j,j.start(),()=>{j.stop(),o.current=null}},[t,e.baseUrl,p]);const g=u.useMemo(()=>Gp(n.events),[n.events]),f=u.useMemo(()=>Nj(n.events),[n.events]),x=u.useMemo(()=>wj(n.events),[n.events]),b=u.useMemo(()=>_j(n.events),[n.events]);u.useEffect(()=>{a.current!==g&&(l.current.onStatusChange?.(a.current,g),a.current=g)},[g]);const y=u.useCallback(async(C,j)=>{if(!t)return;const E=await fetch(`${l.current.baseUrl}/${t}/send`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:C,...j})});if(!E.ok){const R=await E.json().catch(()=>({error:"Send failed"}));throw new Error(R.error||`Send failed (${E.status})`)}},[t]),v=u.useCallback(async()=>{t&&await fetch(`${l.current.baseUrl}/${t}/stop`,{method:"POST"})},[t]),w=u.useCallback(()=>{m(C=>C+1)},[]),N=u.useCallback(C=>{i.current=C.seq,d({type:"EVENT",event:C})},[d]),S=u.useCallback(async C=>{if(!t)return{hasMore:!1};const j=n.events[0]?.seq??0;if(j<=1)return{hasMore:!1};const E=C?.limit??50,R=`${l.current.baseUrl}/${t}/history?before=${j}&limit=${E}`,O=await fetch(R);if(!O.ok)return{hasMore:!1};const $=await O.json();return $.events.length>0&&d({type:"PREPEND_HISTORY",events:$.events}),{hasMore:$.hasMore}},[t,n.events,d]),T=u.useMemo(()=>c.current.snapshot(),[n.events,n.connected]);return{status:g,activity:f,error:n.error,events:n.events,connected:n.connected,processAlive:x,usage:b,actionTrace:T,send:y,stop:v,reconnect:w,injectEvent:N,fetchHistory:S}}function gl(t,e=80){return t.length<=e?t:t.slice(0,e-1)+"…"}function Pe(t,e){const n=t[e];return typeof n=="string"?n:void 0}const Oj={Read:{category:"read",summary:{present:"Reading file",past:"Read file"},extractDetail:t=>Pe(t,"file_path"),isCollapsible:!0,isStructural:!1},Glob:{category:"read",summary:{present:"Searching files",past:"Searched files"},extractDetail:t=>Pe(t,"pattern"),isCollapsible:!0,isStructural:!1},LS:{category:"read",summary:{present:"Listing directory",past:"Listed directory"},extractDetail:t=>Pe(t,"path"),isCollapsible:!0,isStructural:!1},ListMcpResourcesTool:{category:"read",summary:{present:"Listing resources",past:"Listed resources"},isCollapsible:!0,isStructural:!1},ReadMcpResourceTool:{category:"read",summary:{present:"Reading resource",past:"Read resource"},extractDetail:t=>Pe(t,"uri"),isCollapsible:!0,isStructural:!1},Grep:{category:"search",summary:{present:"Searching code",past:"Searched code"},extractDetail:t=>Pe(t,"pattern"),isCollapsible:!0,isStructural:!1},WebSearch:{category:"search",summary:{present:"Searching web",past:"Searched web"},extractDetail:t=>Pe(t,"query"),isCollapsible:!0,isStructural:!1},WebFetch:{category:"search",summary:{present:"Fetching page",past:"Fetched page"},extractDetail:t=>Pe(t,"url"),isCollapsible:!0,isStructural:!1},ToolSearch:{category:"search",summary:{present:"Searching tools",past:"Searched tools"},extractDetail:t=>Pe(t,"query"),isCollapsible:!0,isStructural:!1},Write:{category:"write",summary:{present:"Writing file",past:"Wrote file"},extractDetail:t=>Pe(t,"file_path"),isCollapsible:!1,isStructural:!1},Edit:{category:"write",summary:{present:"Editing file",past:"Edited file"},extractDetail:t=>Pe(t,"file_path"),isCollapsible:!1,isStructural:!1},MultiEdit:{category:"write",summary:{present:"Editing file",past:"Edited file"},extractDetail:t=>Pe(t,"file_path"),isCollapsible:!1,isStructural:!1},NotebookEdit:{category:"write",summary:{present:"Editing notebook",past:"Edited notebook"},extractDetail:t=>Pe(t,"notebook_path"),isCollapsible:!1,isStructural:!1},Bash:{category:"execute",summary:{present:"Running command",past:"Ran command"},extractDetail:t=>{const e=Pe(t,"command");return e?gl(e,60):void 0},isCollapsible:!1,isStructural:!1},Monitor:{category:"execute",summary:{present:"Monitoring",past:"Monitored"},extractDetail:t=>Pe(t,"description"),isCollapsible:!0,isStructural:!1},ScheduleWakeup:{category:"meta",summary:{present:"Scheduling wakeup",past:"Scheduled wakeup"},extractDetail:t=>Pe(t,"reason"),isCollapsible:!0,isStructural:!1},Agent:{category:"agent",summary:{present:"Spawning agent",past:"Spawned agent"},extractDetail:t=>Pe(t,"description")??Pe(t,"subagent_type"),isCollapsible:!1,isStructural:!0},SendMessage:{category:"agent",summary:{present:"Sending message",past:"Sent message"},extractDetail:t=>Pe(t,"to"),isCollapsible:!1,isStructural:!0},EnterWorktree:{category:"agent",summary:{present:"Entering worktree",past:"Entered worktree"},isCollapsible:!1,isStructural:!0},ExitWorktree:{category:"agent",summary:{present:"Exiting worktree",past:"Exited worktree"},isCollapsible:!1,isStructural:!0},AskUserQuestion:{category:"meta",summary:{present:"Asking user",past:"Asked user"},extractDetail:t=>{const e=Pe(t,"question");return e?gl(e,60):void 0},isCollapsible:!1,isStructural:!1},EnterPlanMode:{category:"meta",summary:{present:"Entering plan mode",past:"Entered plan mode"},isCollapsible:!1,isStructural:!1},ExitPlanMode:{category:"meta",summary:{present:"Exiting plan mode",past:"Exited plan mode"},isCollapsible:!1,isStructural:!1},TaskCreate:{category:"meta",summary:{present:"Creating task",past:"Created task"},extractDetail:t=>Pe(t,"subject")??Pe(t,"description"),isCollapsible:!1,isStructural:!1},TaskUpdate:{category:"meta",summary:{present:"Updating task",past:"Updated task"},extractDetail:t=>Pe(t,"id"),isCollapsible:!1,isStructural:!1},TaskGet:{category:"meta",summary:{present:"Checking task",past:"Checked task"},extractDetail:t=>Pe(t,"id"),isCollapsible:!1,isStructural:!1},TaskList:{category:"meta",summary:{present:"Listing tasks",past:"Listed tasks"},isCollapsible:!1,isStructural:!1},TaskOutput:{category:"meta",summary:{present:"Reading task output",past:"Read task output"},extractDetail:t=>Pe(t,"id"),isCollapsible:!1,isStructural:!1},TaskStop:{category:"meta",summary:{present:"Stopping task",past:"Stopped task"},extractDetail:t=>Pe(t,"id"),isCollapsible:!1,isStructural:!1}};function dr(t,e){if(t.startsWith("mcp__"))return Dj(t);const n=Oj[t];if(!n)return{name:t,category:"meta",summary:{present:`Using ${t}`,past:`Used ${t}`},isCollapsible:!1,isStructural:!1};const r=e&&typeof e=="object"&&!Array.isArray(e)?e:{};return{name:t,category:n.category,summary:n.summary,detail:n.extractDetail?.(r),isCollapsible:n.isCollapsible,isStructural:n.isStructural}}function Dj(t){const e=t.split("__"),n=e[1]??"unknown",r=e.slice(2).join("__")||t;return{name:t,category:"integration",summary:{present:`${n}: ${r}`,past:`${n}: ${r}`},isCollapsible:!1,isStructural:!1,mcpServer:n}}function $j(t){return t.type==="collapsed"}function Hp(t){if(t.type!=="content")return[];const e=t.data;return e.blocks?e.blocks.filter(n=>n.type==="tool_use"):[]}function zj(t){const e=Hp(t);return e.length===0?!1:e.every(n=>dr(n.name,n.input).isCollapsible)}function Fj(t){const e=[];return t.read>0&&e.push(`Read ${t.read} file${t.read!==1?"s":""}`),t.search>0&&e.push(`searched ${t.search} pattern${t.search!==1?"s":""}`),t.list>0&&e.push(`listed ${t.list} director${t.list!==1?"ies":"y"}`),e.length>0&&(e[0]=e[0].charAt(0).toUpperCase()+e[0].slice(1)),e.join(", ")||"Explored codebase"}function xl(t,e,n){if(e.length<2){n.push(...t);return}const r={read:0,search:0,list:0},o=new Set;for(const a of e){switch(a.category){case"read":a.name==="LS"||a.name==="ListMcpResourcesTool"?r.list++:r.read++;break;case"search":r.search++;break}a.detail&&o.add(a.detail)}n.push({type:"collapsed",events:[...t],summary:Fj(r),counts:r,paths:[...o]})}function Vj(t){const e=[];let n=[],r=[];for(const o of t)if(o.type==="content"&&zj(o)){n.push(o);for(const a of Hp(o))r.push(dr(a.name,a.input))}else o.type==="result"&&n.length>0?n.push(o):(n.length>0&&(xl(n,r,e),n=[],r=[]),e.push(o));return n.length>0&&xl(n,r,e),e}const ur=new Set(["Agent","Task"]);function Bj(t){return t.some(n=>n.data?.parentToolUseId!=null)?Uj(t):Gj(t)}function Uj(t){const e=[],n={},r=new Set,o=new Set;for(const a of t){if(a.type!=="content")continue;const i=a.data;for(const l of i.blocks??[])l.type==="tool_use"&&ur.has(l.name??"")&&l.id&&r.add(l.id)}for(const a of r)n[a]=[];for(const a of t){const i=a.data,l=i?.parentToolUseId;if(a.type==="content"){let c=!1;for(const d of i?.blocks??[])if(d.type==="tool_use"&&ur.has(d.name??"")&&d.id){o.has(d.id)?c=!0:o.add(d.id);break}if(c)continue}l&&n[l]?n[l].push(a):e.push(a)}return{topLevel:e,childrenByToolUseId:n}}function Gj(t){const e=Hj(t),n=[],r={},o=[],a=new Set;for(const i of t){if(i.type==="result"&&o.length>0){const d=i.data,p=o[o.length-1];if((d.blocks??[]).some(h=>h.type==="tool_result"&&h.tool_use_id===p)){o.pop(),o.length>0?r[o[o.length-1]].push(i):n.push(i);continue}}let l=!1,c;if(i.type==="content"){const d=i.data;for(const p of d.blocks??[])if(p.type==="tool_use"&&ur.has(p.name??"")&&p.id){a.has(p.id)?l=!0:c=p.id;break}}l||(o.length>0?r[o[o.length-1]].push(i):n.push(i),c&&(a.add(c),e.has(c)||(o.push(c),r[c]=[])))}return{topLevel:n,childrenByToolUseId:r}}function Hj(t){const e=new Set,n=new Map;for(const r of t)if(r.type==="content"){const o=r.data,a=o.messageId;if(!a)continue;for(const i of o.blocks??[])if(i.type==="tool_use"&&ur.has(i.name??"")&&i.id){const l=n.get(a);l?l.push(i.id):n.set(a,[i.id])}}for(const[,r]of n)if(r.length>1)for(const o of r)e.add(o);return e}const qj=new Set(["content","result"]),Wj=new Set(["turn:end","run:end","run:ready","run:start","stop:requested"]);function Kj(t){const e=[],n=[];let r=!1,o=[];for(const a of t){if(o.length>0){let i=!1;if(a.type==="content"){const l=a.data,c=(l.blocks??[]).some(p=>p.type==="thinking"),d=(l.blocks??[]).some(p=>p.type==="text");(c||d)&&(i=!0)}if(a.type==="turn:end"&&(i=!0),i){for(const l of o)n.push({inputEvent:l.inputEvent,consumedByEvent:a});o=[]}}if(a.type==="input:sent"){if(r){const i=a.data;i.text&&o.push({inputEvent:a,text:i.text})}continue}Wj.has(a.type)?r=!1:qj.has(a.type)&&(r=!0)}return e.push(...o),{pending:e,consumed:n}}function Qj(t,e){const n="/api/harness",{status:r,activity:o,events:a,connected:i,processAlive:l,usage:c,error:d,send:p,stop:m,reconnect:h,injectEvent:g,fetchHistory:f,actionTrace:x}=Lj(t,{baseUrl:n,onEvent:j=>{}}),{pending:b,consumed:y}=u.useMemo(()=>Kj(a),[a]),v=u.useMemo(()=>Zj(a),[a]),w=r==="streaming",{renderItems:N,childrenMessages:S}=u.useMemo(()=>Jj(a,w,b,y),[a,w,b,y]),T=Yj(r),C=u.useMemo(()=>jj(a),[a]);return{status:T,activity:o,connected:i,processAlive:l,error:d,messages:v,renderItems:N,childrenMessages:S,usage:c,hasBackgroundTasks:C,pendingMessages:b,actionTrace:x,send:p,stop:m,reconnect:h,injectEvent:g,fetchHistory:f}}function Yj(t){switch(t){case"idle":return"idle";case"starting":return"initializing";case"streaming":return"streaming";case"stopping":return"stopping"}}function Jj(t,e,n=[],r=[]){const o=new Set;for(const m of n)o.add(m.inputEvent.seq);for(const m of r)o.add(m.inputEvent.seq);const a=new Map;for(const m of r){const h=m.consumedByEvent.seq,g=a.get(h);g?g.push(m):a.set(h,[m])}const{topLevel:i,childrenByToolUseId:l}=Bj(t),c=Vj(i),d=[];for(let m=0;m<c.length;m++){const h=c[m];if($j(h)){const f=m===c.length-1&&e;for(const x of h.events){const b=a.get(x.seq);if(b)for(const y of b){const v=y.inputEvent.data;v.text&&d.push({kind:"message",message:{id:`h-${y.inputEvent.seq}`,messageId:`h-${y.inputEvent.seq}`,type:"user",content:v.text,timestamp:new Date(y.inputEvent.timestamp).toISOString(),provider:"claude"}})}}d.push({kind:"group",group:Xj(h,f),temporalState:f?"active":"historical"})}else{if(h.type==="input:sent"&&o.has(h.seq)||h.type==="result")continue;const g=a.get(h.seq);if(g)for(const x of g){const b=x.inputEvent.data;b.text&&d.push({kind:"message",message:{id:`h-${x.inputEvent.seq}`,messageId:`h-${x.inputEvent.seq}`,type:"user",content:b.text,timestamp:new Date(x.inputEvent.timestamp).toISOString(),provider:"claude"}})}const f=ga(h);f&&d.push({kind:"message",message:f})}}const p={};for(const[m,h]of Object.entries(l)){const g=[];for(const f of h){const x=ga(f);x&&g.push(x)}g.length>0&&(p[m]=g)}return{renderItems:d,childrenMessages:p}}function Xj(t,e){const n=[];let r;const o=[];for(const i of t.events)if(i.type==="content"){const l=i.data;for(const c of l.blocks??[])c.type==="tool_use"&&o.push({name:c.name,input:c.input,id:c.id})}else if(i.type==="result"){const l=i.data;for(const c of l.blocks??[])if(c.type==="tool_result"){const d=c.tool_use_id,p=o.findIndex(h=>h.id===d),m=p>=0?o.splice(p,1)[0]:null;if(m){if(m.name==="ToolSearch"&&typeof m.input.query=="string"&&m.input.query.startsWith("select:"))continue;const h=dr(m.name,m.input);n.push({tool:bl(m.name),input:h.detail??m.name,filePath:m.input.file_path??void 0,resultContent:typeof c.content=="string"?c.content:void 0,status:c.is_error?"error":"success"})}}}for(const i of o){if(i.name==="ToolSearch"&&typeof i.input.query=="string"&&i.input.query.startsWith("select:"))continue;const l=dr(i.name,i.input);n.push({tool:bl(i.name),input:l.detail??i.name,filePath:i.input.file_path??void 0,status:"pending"}),r=l.summary.present+(l.detail?` ${l.detail}`:"")}!r&&n.length>0&&(r=n[n.length-1].input);const a=t.events[0]?.timestamp??Date.now();return{id:`group-${a}`,summary:t.summary,toolCalls:n,isActive:e||void 0,latestHint:e?r:void 0,timestamp:new Date(a).toISOString()}}function bl(t){switch(t){case"Read":return"read";case"Grep":return"grep";case"Glob":return"glob";case"LS":return"ls";case"WebSearch":return"web-search";case"WebFetch":return"web-fetch";case"ToolSearch":return"tool-search";default:return"read"}}function ga(t){switch(t.type){case"content":{const e=t.data;if(!e.blocks||e.blocks.length===0)return null;const n=e.blocks.map(eN).filter(Boolean);return n.length===0?null:{id:`h-${t.seq}`,messageId:`h-${t.seq}`,type:"assistant",content:n,timestamp:new Date(t.timestamp).toISOString(),provider:"claude"}}case"result":{const e=t.data;if(!e.blocks||e.blocks.length===0)return null;const n=[];for(const r of e.blocks)r.type==="tool_result"&&n.push({type:"tool_result",tool_use_id:r.tool_use_id,content:typeof r.content=="string"?r.content:JSON.stringify(r.content),is_error:r.is_error??!1});return n.length===0?null:{id:`h-${t.seq}`,messageId:`h-${t.seq}`,type:"user",content:n,timestamp:new Date(t.timestamp).toISOString(),provider:"claude"}}case"input:sent":{const e=t.data;return e.text?{id:`h-${t.seq}`,messageId:`h-${t.seq}`,type:"user",content:e.text,timestamp:new Date(t.timestamp).toISOString(),provider:"claude"}:null}case"run:error":{const e=t.data;return{id:`h-${t.seq}`,messageId:`h-${t.seq}`,type:"error",content:e.message??"Unknown error",timestamp:new Date(t.timestamp).toISOString(),provider:"claude"}}default:return null}}function Zj(t){const e=[];for(const n of t){const r=ga(n);r&&e.push(r)}return e}function eN(t){switch(t.type){case"text":return{type:"text",text:t.text};case"thinking":return{type:"thinking",thinking:t.thinking};case"tool_use":return{type:"tool_use",id:t.id,name:t.name,input:t.input};default:return null}}const tN=3e4;function yl(t){if(typeof t.content=="string")return t.content.slice(0,120);if(Array.isArray(t.content))for(const e of t.content){const n=e;if(n.type==="text"&&typeof n.text=="string")return n.text.slice(0,120)}return"[non-text]"}function vl(t){if(typeof t.content=="string")return t.content;if(Array.isArray(t.content)){const e=[];for(const n of t.content){const r=n;r.type==="text"&&typeof r.text=="string"&&e.push(r.text)}return e.length>0?e.join(`
|
|
337
|
-
`):null}return null}function sN({conversationId:t,messages:e,actionTrace:n,connected:r,status:o}){const a=u.useRef(null);u.useEffect(()=>{if(!t||e.length<2)return;const i=new Map,l=[];for(const x of e){const b=x.messageId||x.id,y=i.get(b)??0;if(i.set(b,y+1),y+1===2)l.push({id:b,count:2,preview:yl(x)});else if(y+1>2){const v=l.find(w=>w.id===b);v&&(v.count=y+1)}}const c=[];for(let x=1;x<e.length;x++){const b=e[x-1],y=e[x];if(b.type==="assistant"&&y.type==="assistant"){const v=vl(b),w=vl(y);v&&w&&v===w&&v.length>20&&c.push({index:x,id:y.messageId||y.id,preview:w.slice(0,120)})}}const d=[];for(let x=1;x<e.length;x++){const b=e[x-1],y=e[x];if(b.type==="assistant"&&y.type==="user"){const v=b.timestamp?new Date(b.timestamp).getTime():0,w=y.timestamp?new Date(y.timestamp).getTime():0;w>0&&v>0&&w<v&&d.push({index:x,userId:y.messageId||y.id,assistantId:b.messageId||b.id,userTs:y.timestamp||"",assistantTs:b.timestamp||"",userPreview:yl(y)})}}if(l.length===0&&c.length===0&&d.length===0)return;const p=Date.now(),m=a.current;if(m&&m.sessionId===t&&p-m.ts<tN)return;a.current={sessionId:t,ts:p};const h={conversationId:t,duplicateIds:l,consecutiveDupes:c,orderingAnomalies:d,messageCount:e.length,connected:r,status:o,actionTrace:n.slice(-30).map(x=>({action:x.action,ts:new Date(x.ts).toISOString(),detail:x.detail}))},g=d.length>0&&l.length===0&&c.length===0?"ordering-anomaly":d.length>0?"duplicate-and-ordering-anomaly":"duplicate-detected";mt({component:"DuplicateMessageDetector",event:g,severity:"warn",details:h});const f=d.length>0?"Message ordering anomaly":"Duplicate messages";console.warn(`[DuplicateMessageDetector] ${f} detected`,h)},[t,e,n,r,o])}const nN=2500,wl=1e4;function rN(t){const[e,n]=u.useState(null),r=u.useRef(!1),o=u.useRef(!1);u.useEffect(()=>{if(!t)return;let c=null;const d=async()=>{if(!r.current){r.current=!0;try{const{permissions:p}=await
|
|
335
|
+
`):typeof e.content=="string"?e.content:""}function ll({finding:t,onRemove:e}){return s.jsxs("div",{className:"rounded-sm border border-border/15 bg-background/20 overflow-hidden group",children:[s.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[s.jsx("span",{className:"text-[9px] font-display uppercase tracking-widest text-muted-foreground/40",children:t.label}),s.jsx("button",{onClick:e,className:"p-0.5 text-muted-foreground/20 hover:text-rose-400/60 transition-colors cursor-pointer opacity-0 group-hover:opacity-100",title:"Remove from report",children:s.jsx(Lo,{size:10})})]}),s.jsx("div",{className:"px-2.5 pb-2",children:s.jsx("pre",{className:"text-[10px] font-mono text-foreground/60 leading-relaxed whitespace-pre-wrap",children:t.text})})]})}function hj({onClose:t,conversationId:e}){const[n,r]=u.useState("bug"),[o,a]=u.useState(""),[i,l]=u.useState(!1),[c,d]=u.useState(null),[p,m]=u.useState({summary:"",related:[],alsoFound:[]}),[h,g]=u.useState(null),f=u.useRef(null),x=u.useRef(null),b=u.useRef(!1),[y,v]=u.useState(!1),[w,N]=u.useState("compose");u.useEffect(()=>()=>{f.current&&clearInterval(f.current),x.current&&clearTimeout(x.current)},[]);const S=u.useCallback(()=>{f.current&&(clearInterval(f.current),f.current=null),x.current&&(clearTimeout(x.current),x.current=null)},[]),T=u.useCallback(async()=>{N("investigating"),g(null),b.current=!1;try{const B=uj(o,e),Q=await H.createConversation({provider:"claude",message:B,workingDirectory:"/Users/jasonliggi/src/lattice-orchestrator",permissionMode:"bypassPermissions"});if(b.current)return;const q=Q.conversationId;d(q);const Z=Date.now(),me=async()=>{if(b.current){S();return}if(Date.now()-Z>cl){S(),g("Investigation timed out. You can still send the feedback without debug context.");return}try{if((await H.getSessionsStatus([q])).sessions[q]?.status==="completed"){if(S(),b.current)return;try{const ee=await H.getConversationDetails(q,{limit:50}),z=pj(ee.messages);m(z),!z.summary&&z.related.length===0&&z.alsoFound.length===0&&g("Investigation completed but found no relevant diagnostics.")}catch(ee){console.error("[FeedbackPanel] Failed to fetch investigation results:",ee),g("Investigation completed but failed to retrieve results.")}N("review")}}catch(O){console.warn("[FeedbackPanel] Poll error:",O)}};f.current=setInterval(()=>{me()},dj),x.current=setTimeout(()=>{!b.current&&f.current&&(S(),g("Investigation timed out after 2 minutes."),N("review"))},cl)}catch(B){console.error("[FeedbackPanel] Failed to launch investigation:",B),g("Failed to launch investigation session. You can still send feedback without debug context."),N("review")}},[o,e,S]),C=u.useCallback(async B=>{v(!0);try{const Q={category:n,message:o,findings:B,conversationId:e||null,investigationConversationId:c,timestamp:new Date().toISOString(),userAgent:navigator.userAgent};await fetch("/api/feedback/submit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Q)}),N("sent")}catch(Q){console.error("[FeedbackPanel] Failed to submit feedback:",Q),N("sent")}finally{v(!1)}},[n,o,e,c]),j=u.useCallback(()=>{i&&n==="bug"&&w==="compose"?T():w==="compose"&&C(null)},[i,n,w,T,C]),E=p.summary||p.related.length>0||p.alsoFound.length>0,A=u.useCallback(()=>{C(E?p:null)},[E,p,C]),L=u.useCallback(()=>{b.current=!0,S(),N("compose"),d(null),g(null)},[S]),$=u.useCallback(()=>{N("compose"),a(""),l(!1),d(null),m({summary:"",related:[],alsoFound:[]}),g(null),r("bug")},[]),oe=yo.find(B=>B.value===n)||yo[0],ne=oe.icon;return s.jsxs("div",{className:"h-full flex flex-col bg-background relative overflow-hidden",children:[s.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[linear-gradient(rgba(0,255,255,0.015)_1px,transparent_1px),linear-gradient(90deg,rgba(0,255,255,0.015)_1px,transparent_1px)] bg-[size:20px_20px]"}),s.jsxs("div",{className:"relative border-b border-border/30 px-6 py-3 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(as,{size:12,className:"text-muted-foreground/40"}),s.jsx("span",{className:"text-[10px] font-display font-bold uppercase tracking-wider text-muted-foreground/60",children:"Feedback"})]}),s.jsx("button",{onClick:t,className:"p-1 text-muted-foreground/40 hover:text-muted-foreground transition-colors cursor-pointer",children:s.jsx(Be,{size:14})})]}),s.jsx("div",{className:"relative flex-1 overflow-y-auto",children:s.jsxs("div",{className:"max-w-xl mx-auto px-6 py-10 space-y-6",children:[w==="compose"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("span",{className:"text-[9px] font-display uppercase tracking-widest text-muted-foreground/50",children:"What kind of feedback?"}),s.jsx("div",{className:"grid grid-cols-2 gap-2",children:yo.map(B=>{const Q=B.icon,q=n===B.value;return s.jsxs("button",{onClick:()=>r(B.value),className:`relative flex items-center gap-2.5 px-3 py-2.5 rounded-sm border transition-all cursor-pointer overflow-hidden ${q?`${B.bg} ${B.color}`:"border-border/20 text-muted-foreground/40 hover:border-border/40 hover:text-muted-foreground/60"}`,children:[q&&s.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[linear-gradient(rgba(0,255,255,0.02)_1px,transparent_1px),linear-gradient(90deg,rgba(0,255,255,0.02)_1px,transparent_1px)] bg-[size:18px_18px]"}),s.jsx(Q,{size:14,className:"relative"}),s.jsx("span",{className:"relative text-[11px] font-display font-bold uppercase tracking-wider",children:B.label})]},B.value)})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("span",{className:"text-[9px] font-display uppercase tracking-widest text-muted-foreground/50",children:"Details"}),s.jsx("textarea",{value:o,onChange:B=>a(B.target.value),placeholder:"Describe what happened, what you expected, or what you'd like to see...",rows:5,className:"w-full bg-background/50 border border-border/30 rounded-sm px-3 py-2.5 text-sm font-mono placeholder:text-muted-foreground/30 focus:outline-none focus:border-cyan-500/40 resize-none leading-relaxed"})]}),n==="bug"&&s.jsx("div",{className:"rounded-sm border border-border/20 bg-muted/5 p-3",children:s.jsxs("button",{type:"button",onClick:()=>l(B=>!B),className:"flex items-start gap-2.5 cursor-pointer w-full text-left",children:[s.jsx("div",{className:`mt-0.5 w-4 h-4 rounded-sm border flex items-center justify-center transition-all flex-shrink-0 ${i?"border-cyan-500/50 bg-cyan-500/15":"border-border/40"}`,children:i&&s.jsx(Oe,{size:10,className:"text-cyan-400"})}),s.jsx("span",{className:"text-sm font-mono text-muted-foreground/50 leading-relaxed",children:"Launch an agent to investigate recent logs and session state. You'll review everything before it sends."})]})}),s.jsx("button",{onClick:j,disabled:!o.trim(),className:"w-full flex items-center justify-center gap-2 py-2 rounded-sm ui-action-btn ui-action-btn--cool text-[10px] font-display font-bold uppercase tracking-wider bg-background/80 backdrop-blur-sm disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:shadow-none disabled:hover:translate-x-0 disabled:hover:translate-y-0",children:i&&n==="bug"?s.jsxs(s.Fragment,{children:[s.jsx(Gt,{size:12}),"Launch Investigation"]}):s.jsxs(s.Fragment,{children:[s.jsx(ji,{size:12}),"Send Feedback"]})})]}),w==="investigating"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rounded-sm border border-border/20 bg-background/30 px-3 py-2 flex items-center gap-2",children:[s.jsx(ne,{size:10,className:oe.color}),s.jsx("span",{className:"text-xs font-mono text-foreground/60 truncate flex-1",children:o}),s.jsx("span",{className:`text-[9px] font-display uppercase tracking-widest ${oe.color}`,children:oe.label})]}),s.jsx("div",{className:"rounded-sm border border-cyan-500/15 bg-cyan-500/[0.03] p-6",children:s.jsxs("div",{className:"flex flex-col items-center text-center space-y-3",children:[s.jsx(Re,{size:20,className:"animate-spin text-cyan-400/60"}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("span",{className:"text-[10px] font-display font-bold uppercase tracking-wider text-cyan-400/70 block",children:"Investigation running"}),s.jsx("span",{className:"text-[10px] font-mono text-muted-foreground/40 block",children:"A session is analyzing logs and session state. This usually takes 15–30 seconds."})]}),c&&s.jsxs("a",{href:`/c/${c}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-[10px] font-mono text-muted-foreground/30 hover:text-muted-foreground/50 transition-colors",children:[s.jsx(os,{size:10}),"View session"]})]})}),s.jsx("button",{onClick:L,className:"w-full flex items-center justify-center gap-2 py-1.5 rounded-sm border border-border/30 text-[10px] font-display font-bold uppercase tracking-wider text-muted-foreground/50 hover:text-muted-foreground hover:border-border/50 transition-all cursor-pointer",children:"Cancel"})]}),w==="review"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("span",{className:"text-[9px] font-display uppercase tracking-widest text-muted-foreground/50",children:"Review before sending"}),s.jsx("p",{className:"text-[10px] font-mono text-muted-foreground/40 leading-relaxed",children:"This is exactly what will be submitted. Remove any sections you don't want included."})]}),h&&s.jsxs("div",{className:"rounded-sm border border-amber-500/20 bg-amber-500/5 px-3 py-2 flex items-start gap-2",children:[s.jsx(kt,{size:12,className:"text-amber-400/60 mt-0.5 flex-shrink-0"}),s.jsx("span",{className:"text-[10px] font-mono text-amber-400/70 leading-relaxed",children:h})]}),s.jsxs("div",{className:"rounded-sm border border-border/25 bg-background/35 overflow-hidden",children:[s.jsxs("div",{className:"px-3 py-1.5 border-b border-border/15 flex items-center gap-2",children:[s.jsx(ne,{size:10,className:oe.color}),s.jsx("span",{className:"text-[9px] font-display uppercase tracking-widest text-muted-foreground/50",children:"Your feedback"})]}),s.jsx("div",{className:"px-3 py-2.5",children:s.jsx("p",{className:"text-sm font-mono text-foreground/80 leading-relaxed",children:o})})]}),(p.summary||p.related.length>0)&&s.jsxs("div",{className:"rounded-sm border border-cyan-500/20 bg-cyan-500/[0.03] overflow-hidden",children:[s.jsxs("div",{className:"px-3 py-1.5 border-b border-cyan-500/10 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ms,{size:10,className:"text-cyan-400/60"}),s.jsx("span",{className:"text-[9px] font-display uppercase tracking-widest text-cyan-400/60",children:"Related to your bug"})]}),s.jsx("button",{onClick:()=>m(B=>({...B,summary:"",related:[]})),className:"text-[9px] font-mono text-rose-400/50 hover:text-rose-400 transition-colors cursor-pointer",children:"Remove all"})]}),s.jsxs("div",{className:"px-3 py-3 space-y-3",children:[p.summary&&s.jsxs("div",{children:[s.jsx("span",{className:"text-[9px] font-display uppercase tracking-widest text-muted-foreground/40",children:"Summary"}),s.jsx("p",{className:"mt-1 text-xs font-mono text-foreground/70 leading-relaxed",children:p.summary})]}),p.related.length>0&&s.jsx("div",{className:"space-y-2 pt-1",children:p.related.map((B,Q)=>s.jsx(ll,{finding:B,onRemove:()=>{m(q=>({...q,related:q.related.filter((Z,me)=>me!==Q)}))}},`related-${B.label}-${Q}`))})]})]}),p.alsoFound.length>0&&s.jsxs("div",{className:"rounded-sm border border-border/20 bg-muted/[0.03] overflow-hidden",children:[s.jsxs("div",{className:"px-3 py-1.5 border-b border-border/10 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(kt,{size:10,className:"text-amber-400/50"}),s.jsx("span",{className:"text-[9px] font-display uppercase tracking-widest text-muted-foreground/40",children:"Also found"})]}),s.jsx("button",{onClick:()=>m(B=>({...B,alsoFound:[]})),className:"text-[9px] font-mono text-rose-400/50 hover:text-rose-400 transition-colors cursor-pointer",children:"Remove all"})]}),s.jsx("div",{className:"px-3 py-3 space-y-2",children:p.alsoFound.map((B,Q)=>s.jsx(ll,{finding:B,onRemove:()=>{m(q=>({...q,alsoFound:q.alsoFound.filter((Z,me)=>me!==Q)}))}},`also-${B.label}-${Q}`))})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{onClick:()=>N("compose"),className:"flex-1 flex items-center justify-center gap-2 py-2 rounded-sm border border-border/30 text-[10px] font-display font-bold uppercase tracking-wider text-muted-foreground/60 hover:text-muted-foreground hover:border-border/50 transition-all cursor-pointer",children:"Back"}),s.jsxs("button",{onClick:A,disabled:y,className:"flex-[2] flex items-center justify-center gap-2 py-2 rounded-sm ui-action-btn ui-action-btn--cool text-[10px] font-display font-bold uppercase tracking-wider bg-background/80 backdrop-blur-sm disabled:opacity-50",children:[y?s.jsx(Re,{size:12,className:"animate-spin"}):s.jsx(ji,{size:12}),E?"Send with Context":"Send Feedback"]})]})]}),w==="sent"&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[s.jsx("div",{className:"w-10 h-10 rounded-full border border-emerald-500/40 bg-emerald-500/10 flex items-center justify-center mb-4",children:s.jsx(Oe,{size:20,className:"text-emerald-400"})}),s.jsx("span",{className:"text-sm font-display font-semibold text-foreground/90",children:"Feedback sent"}),s.jsx("span",{className:"text-xs text-muted-foreground/50 mt-1.5 font-mono max-w-xs",children:"Thanks. This goes directly to the developer."}),s.jsx("button",{onClick:$,className:"mt-8 px-4 py-1.5 rounded-sm border border-border/30 text-[10px] font-display font-bold uppercase tracking-wider text-muted-foreground/50 hover:text-muted-foreground hover:border-border/50 transition-all cursor-pointer",children:"Send another"})]})]})})]})}function Up(t){if(!t)return null;const e=t.trim();return!e||e==="~"?null:e.replace(/\/+$/,"")||null}function fj(t){const e=Up(t);if(!e)return[];const n=`${e}/**`;return[`Read(${n})`,`Write(${n})`,`Edit(${n})`]}function gj({toolName:t,toolInput:e}){switch(t){case"Bash":return s.jsxs("div",{className:"space-y-2",children:[!!e.description&&s.jsx("div",{className:"text-xs text-muted-foreground",children:e.description}),s.jsx("pre",{className:"font-mono text-sm text-foreground whitespace-pre-wrap break-all bg-neutral-950 rounded p-3",children:e.command})]});case"Read":case"Write":return s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"font-mono text-sm text-foreground",children:e.file_path}),!!e.content&&s.jsxs("pre",{className:"font-mono text-xs text-foreground/80 whitespace-pre-wrap break-all bg-neutral-950 rounded p-3 max-h-64 overflow-auto",children:[e.content.slice(0,2e3),e.content.length>2e3&&"..."]})]});case"Edit":return s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"font-mono text-sm text-foreground",children:e.file_path}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-red-400 mb-1",children:"Old:"}),s.jsx("pre",{className:"font-mono text-xs text-foreground/80 whitespace-pre-wrap break-all bg-red-950/30 rounded p-2 max-h-32 overflow-auto",children:e.old_string})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-emerald-400 mb-1",children:"New:"}),s.jsx("pre",{className:"font-mono text-xs text-foreground/80 whitespace-pre-wrap break-all bg-emerald-950/30 rounded p-2 max-h-32 overflow-auto",children:e.new_string})]})]})]});default:return s.jsx("pre",{className:"font-mono text-xs text-foreground/80 whitespace-pre-wrap break-all bg-neutral-950 rounded p-3 max-h-64 overflow-auto",children:JSON.stringify(e,null,2)})}}function xj(t,e){switch(t){case"Bash":return e.command||"";case"Read":case"Write":case"Edit":return e.file_path||"";case"Grep":return`"${String(e.pattern??"")}" in ${String(e.path??"")}`;case"Glob":return e.pattern||"";case"WebFetch":return e.url||"";case"Task":return e.description||e.prompt?.slice(0,50)||"";default:return JSON.stringify(e).slice(0,60)}}function bj(t,e,n){if(n===0)return"Only this exact operation";if(n===e-1){const i=t.match(/^([A-Za-z]+)$/);if(i)return`All ${i[1].toLowerCase()} operations`}const r=t.match(/^([A-Za-z]+)\((.+)\)$/);if(!r)return t;const[,o,a]=r;if(o==="Bash")return a.endsWith(" *")?`Any "${a.slice(0,-2)}" command`:`Commands matching "${a}"`;if(["Write","Read","Edit"].includes(o)){if(a.startsWith("*."))return`Any ${a.slice(1)} file`;if(a.includes("**")){const i=a.split("**");return i[0]&&i[1]?`Any ${i[1].replace(/^\/?\*?/,"")} file under ${i[0].replace(/\/$/,"")}`:`Any file under ${a.replace("/**","")}`}if(a.includes("*")){const i=a.substring(0,a.lastIndexOf("/")),l=a.includes(".")?a.split(".").pop():null;return l?`Any .${l} file in ${i||"this directory"}`:`Any file in ${i||"this directory"}`}return`File: ${a}`}return t}function yj({onApprove:t,onDeny:e,isLoading:n}){return s.jsx("div",{"data-testid":"plan-approval-banner",className:"border border-rose-500/30 rounded-lg overflow-hidden bg-rose-500/5",children:s.jsxs("div",{className:"bg-rose-500/10 px-4 py-3 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[s.jsx(Ph,{size:16,className:"text-rose-400 shrink-0"}),s.jsx("div",{className:"min-w-0",children:s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"font-display text-xs font-bold text-rose-400 uppercase tracking-wider",children:"Implement Plan"}),s.jsx("span",{className:"text-muted-foreground/40 shrink-0",children:"·"}),s.jsx("span",{className:"text-sm text-foreground/70",children:"Claude is ready to implement the plan above"})]})})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2 shrink-0 sm:justify-end",children:[s.jsxs("button",{onClick:r=>{r.stopPropagation(),e("Plan rejected — please revise or take a different approach.")},disabled:n,className:"group flex min-h-9 items-center gap-1.5 px-3 py-1.5 rounded-sm bg-background/80 border border-border/30 text-muted-foreground text-xs font-display uppercase tracking-wider hover:border-red-500/30 hover:text-red-400 transition-colors disabled:opacity-50",children:[s.jsx(Be,{size:12}),"Reject"]}),s.jsxs("button",{"data-testid":"plan-approve-button",onClick:r=>{r.stopPropagation(),t()},disabled:n,className:"group flex min-h-9 items-center gap-1.5 px-3 py-1.5 rounded-sm bg-background/80 border border-rose-500/30 text-rose-400 text-xs font-display uppercase tracking-wider hover:border-rose-400 hover:bg-rose-500/5 transition-colors disabled:opacity-50",children:[s.jsx(Oe,{size:12}),"Approve"]})]})]})})}function vj({permission:t,streamingId:e,workingDirectory:n,onApprove:r,onApprovePattern:o,onApprovePatterns:a,onDeny:i,isLoading:l}){const c=t.toolName==="ExitPlanMode"||t.toolName==="exit_plan_mode",[d,p]=u.useState(!1),[m,h]=u.useState(!1),[g,f]=u.useState([]),[x,b]=u.useState(!1),y=xj(t.toolName,t.toolInput),v=u.useMemo(()=>Up(n),[n]),w=u.useMemo(()=>fj(n),[n]),N=v?.split("/").filter(Boolean).pop()||"project";u.useEffect(()=>{c||g.length>0||x||(b(!0),H.getSuggestedPatterns(t.toolName,t.toolInput).then(({patterns:C})=>f(C)).catch(C=>{console.error("Failed to fetch suggested patterns:",C),f([t.toolName])}).finally(()=>b(!1)))},[t.id]);const S=C=>{h(!1),o(C,"global")},T=C=>{w.length!==0&&(h(!1),a(w,C))};return c?s.jsx(yj,{onApprove:r,onDeny:i,isLoading:l}):s.jsxs("div",{"data-testid":"permission-banner",className:"border border-amber-500/30 rounded-lg overflow-hidden bg-amber-500/5",children:[s.jsxs("div",{className:"bg-amber-500/10 px-4 py-3 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("button",{onClick:()=>p(!d),className:"flex items-start gap-3 flex-1 min-w-0 text-left",disabled:l,children:[d?s.jsx(Lt,{size:14,className:"text-amber-400 shrink-0 mt-0.5"}):s.jsx(Ut,{size:14,className:"text-amber-400 shrink-0 mt-0.5"}),s.jsx(Yl,{size:16,className:"text-amber-400 shrink-0 mt-0.5"}),s.jsx("div",{className:"min-w-0 flex-1",children:s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-wrap",children:[s.jsx("span",{className:"font-display text-xs font-bold text-amber-400 uppercase tracking-wider shrink-0",children:t.toolName}),s.jsx("span",{className:"text-muted-foreground/40 shrink-0",children:"·"}),s.jsx("span",{className:`text-sm text-foreground/70 font-mono ${d?"break-all":"line-clamp-2 break-all sm:line-clamp-1"}`,children:y})]})})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2 shrink-0 sm:justify-end",children:[s.jsxs("button",{onClick:C=>{C.stopPropagation(),i()},disabled:l,className:"group flex min-h-9 items-center gap-1.5 px-3 py-1.5 rounded-sm bg-background/80 border border-border/30 text-muted-foreground text-xs font-display uppercase tracking-wider hover:border-red-500/30 hover:text-red-400 transition-colors disabled:opacity-50",children:[s.jsx(Be,{size:12}),"Deny"]}),s.jsxs("button",{"data-testid":"permission-allow-button",onClick:C=>{C.stopPropagation(),r()},disabled:l,className:"group flex min-h-9 items-center gap-1.5 px-3 py-1.5 rounded-sm bg-background/80 border border-emerald-500/30 text-emerald-400 text-xs font-display uppercase tracking-wider hover:border-emerald-400 hover:bg-emerald-500/5 transition-colors disabled:opacity-50",children:[s.jsx(Oe,{size:12}),"Allow"]}),s.jsxs("button",{onClick:C=>{C.stopPropagation(),h(!m)},disabled:l,className:`group flex min-h-9 items-center gap-1.5 px-3 py-1.5 rounded-sm bg-background/80 border text-xs font-display uppercase tracking-wider transition-colors disabled:opacity-50 ${m?"border-sky-400 text-sky-400 bg-sky-500/5":"border-sky-500/30 text-sky-400 hover:border-sky-400 hover:bg-sky-500/5"}`,children:[m?s.jsx(Lt,{size:12}):s.jsx(Ut,{size:12}),"Allow Always"]})]})]}),d&&!m&&s.jsx("div",{className:"border-t border-amber-500/20 px-4 py-3 bg-background/50",children:s.jsx(gj,{toolName:t.toolName,toolInput:t.toolInput})}),m&&s.jsxs("div",{className:"border-t border-amber-500/20 bg-background/30",children:[w.length>0&&v&&s.jsx("div",{className:"px-3 pt-3",children:s.jsxs("div",{className:"rounded-md border border-sky-500/20 bg-sky-500/5 overflow-hidden",children:[s.jsxs("div",{className:"px-4 py-3 border-b border-sky-500/20 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Jh,{size:14,className:"text-sky-400 shrink-0"}),s.jsx("span",{className:"text-[11px] font-display font-bold uppercase tracking-wider text-sky-300",children:"Trust Project Files"})]}),s.jsxs("p",{className:"mt-1 text-xs text-foreground/75",children:["Allow Claude to read and edit files anywhere under ",s.jsx("span",{className:"font-medium text-foreground",children:N}),"."]}),s.jsxs("p",{className:"mt-1 font-mono text-[11px] text-sky-200/80 break-all",children:[v,"/**"]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2 shrink-0 sm:justify-end",children:[s.jsx("button",{onClick:()=>T("session"),className:"min-h-8 px-2.5 py-1.5 rounded-sm border border-sky-500/30 text-sky-300 text-[10px] font-display uppercase tracking-wider hover:border-sky-400 hover:bg-sky-500/10 transition-colors",children:"This Session"}),s.jsx("button",{onClick:()=>T("global"),className:"min-h-8 px-2.5 py-1.5 rounded-sm border border-sky-400/40 text-sky-200 text-[10px] font-display uppercase tracking-wider hover:border-sky-300 hover:bg-sky-500/10 transition-colors",children:"Always"})]})]}),s.jsxs("div",{className:"px-4 py-2 text-[10px] text-muted-foreground border-t border-border/20",children:["Adds ",s.jsx("span",{className:"font-mono text-foreground/80",children:"Read"}),", ",s.jsx("span",{className:"font-mono text-foreground/80",children:"Write"}),", and ",s.jsx("span",{className:"font-mono text-foreground/80",children:"Edit"})," allowlist rules for this working directory."]})]})}),w.length>0&&s.jsx("div",{className:"px-4 pt-3 text-[10px] font-display uppercase tracking-wider text-muted-foreground/70",children:"More Specific Patterns"}),s.jsx("div",{className:"py-2",children:x?s.jsx("div",{className:"px-4 py-4 text-center text-xs text-muted-foreground",children:"Loading patterns..."}):g.map((C,j)=>{const E=bj(C,g.length,j),A=j===0,L=j===g.length-1&&g.length>1;return s.jsxs("button",{onClick:()=>S(C),className:"w-full text-left px-4 py-2.5 hover:bg-accent/30 transition-colors flex items-center gap-3 group",children:[s.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${A?"bg-emerald-400":L?"bg-amber-400":"bg-muted-foreground/30"}`}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("span",{className:"font-mono text-xs text-foreground/80",children:C}),s.jsx("span",{className:"text-[11px] text-muted-foreground block mt-0.5",children:E})]}),A&&s.jsx("span",{className:"text-[9px] uppercase tracking-wider text-emerald-400/70 bg-emerald-500/10 px-1.5 py-0.5 rounded shrink-0",children:"safest"}),L&&s.jsx("span",{className:"text-[9px] uppercase tracking-wider text-amber-400/70 bg-amber-500/10 px-1.5 py-0.5 rounded shrink-0",children:"broad"}),s.jsx(Oe,{size:14,className:"shrink-0 opacity-0 group-hover:opacity-100 transition-opacity text-violet-400"})]},C)})}),s.jsx("div",{className:"px-4 py-2 border-t border-border/20 text-[10px] text-muted-foreground",children:s.jsx("span",{children:'Patterns added here are saved globally. Use "This Session" above for repo trust without persisting it.'})})]})]})}function Gp(t){for(let e=t.length-1;e>=0;e--)switch(t[e].type){case"run:end":case"run:error":case"turn:end":return"idle";case"stop:requested":return"stopping";case"content":case"result":return"streaming";case"input:sent":for(let n=e-1;n>=0;n--){if(t[n].type==="run:ready")return"streaming";if(t[n].type==="run:start")return"starting"}return"streaming";case"run:ready":for(let n=e-1;n>=0;n--){if(t[n].type==="input:sent")return"streaming";if(t[n].type==="turn:end"||t[n].type==="run:end"||t[n].type==="run:start")return"idle"}return"idle";case"run:start":return"starting"}return"idle"}function wj(t){for(let e=t.length-1;e>=0;e--)switch(t[e].type){case"run:end":case"run:error":return!1;case"run:start":case"run:ready":case"content":case"result":case"input:sent":case"turn:end":case"stop:requested":case"task:started":case"task:updated":case"task:notification":case"task:output":return!0}return!1}function _j(t){let e=null,n;for(let r=t.length-1;r>=0;r--){const o=t[r];if(!e&&o.type==="turn:end"){const a=o.data;a.usage&&(e={inputTokens:a.usage.input_tokens??0,outputTokens:a.usage.output_tokens??0,cacheCreationInputTokens:a.usage.cache_creation_input_tokens??0,cacheReadInputTokens:a.usage.cache_read_input_tokens??0,costUsd:a.costUsd})}if(n===void 0&&o.type==="content"){const a=o.data;a.apiUsage&&(n=(a.apiUsage.input_tokens??0)+(a.apiUsage.cache_creation_input_tokens??0)+(a.apiUsage.cache_read_input_tokens??0))}if(e&&n!==void 0)break}return e?(e.contextTokens=n,e):n!==void 0?{inputTokens:0,outputTokens:0,cacheCreationInputTokens:0,cacheReadInputTokens:0,contextTokens:n}:null}function kj(t){const e=new Map;for(const n of t){if(n.type==="run:end"||n.type==="run:error"){e.clear();continue}if(n.type==="task:started"){const r=n.data;if(r.taskType!=="local_bash")continue;e.set(r.taskId,{taskId:r.taskId,toolUseId:r.toolUseId,description:r.description,taskType:r.taskType,status:"running"})}else if(n.type==="task:updated"){const r=n.data,o=e.get(r.taskId);if(!o)continue;r.patch.status!=="running"&&(o.status="completed")}else if(n.type==="task:notification"){const r=n.data,o=e.get(r.taskId);o&&(o.status="completed")}}return e}function jj(t){const e=kj(t);for(const n of e.values())if(n.status==="running")return!0;return!1}function Nj(t){if(Gp(t)!=="streaming")return null;for(let n=t.length-1;n>=0;n--){const r=t[n];if(r.type==="content"){const o=r.data.blocks;if(!o||o.length===0)continue;const a=o[o.length-1];if(a.type==="thinking")return{type:"thinking"};if(a.type==="tool_use")return{type:"tool",name:a.name,input:a.input}}if(r.type==="turn:end")return null}return null}async function Sj(t,e){const n=t.getReader();for(;;){const r=await n.read();if(r.done)break;e(r.value)}}var ts;(function(t){t[t.NewLine=10]="NewLine",t[t.CarriageReturn=13]="CarriageReturn",t[t.Space=32]="Space",t[t.Colon=58]="Colon"})(ts||(ts={}));function Cj(t){let e,n,r,o=!1;return function(i){e===void 0?(e=i,n=0,r=-1):e=Tj(e,i);const l=e.length;let c=0;for(;n<l;){o&&(e[n]===ts.NewLine&&(c=++n),o=!1);let d=-1;for(;n<l&&d===-1;++n)switch(e[n]){case ts.Colon:r===-1&&(r=n-c);break;case ts.CarriageReturn:o=!0;case ts.NewLine:d=n;break}if(d===-1)break;t(e.subarray(c,d),r),c=n,r=-1}c===l?e=void 0:c!==0&&(e=e.subarray(c),n-=c)}}function Ej(t,e,n){let r=dl();const o=new TextDecoder;return function(i,l){if(i.length===0)n?.(r),r=dl();else if(l>0){const c=o.decode(i.subarray(0,l)),d=l+(i[l+1]===ts.Space?2:1),p=o.decode(i.subarray(d));switch(c){case"data":r.data=r.data?r.data+`
|
|
336
|
+
`+p:p;break;case"event":r.event=p;break;case"id":t(r.id=p);break;case"retry":{const m=parseInt(p,10);isNaN(m)||e(r.retry=m);break}}}}}function Tj(t,e){const n=new Uint8Array(t.length+e.length);return n.set(t),n.set(e,t.length),n}function dl(){return{data:"",event:"",id:"",retry:void 0}}const ul=1e3,pl=3e4,wo=10,Ij=25e3;class Aj{controller=null;options;running=!1;looping=!1;visibilityHandler=null;connectionEstablished=!1;constructor(e){this.options=e}start(){this.running||(this.running=!0,this.connectLoop(),this.setupVisibilityHandler())}stop(){this.running=!1,this.looping=!1,this.controller?.abort(),this.controller=null,this.teardownVisibilityHandler()}async connectLoop(){if(!this.looping){this.looping=!0;try{let e=0;for(;this.running;){this.connectionEstablished=!1,this.controller=new AbortController;try{if(await this.connect(this.controller.signal)==="no_session"){if(e++,e>=wo){this.running=!1;return}const r=Math.min(ul*2**e,pl);await ml(r);continue}e=0}catch{if(!this.running||typeof document<"u"&&document.hidden)return;if(this.connectionEstablished?e=0:e++,e>=wo){this.options.onError(`Connection failed after ${wo} retries`),this.running=!1;return}const r=Math.min(ul*2**e,pl);await ml(r)}this.running&&this.options.onDisconnected()}}finally{this.looping=!1}}}async connect(e){const n=this.options.getLastSeq(),r=`${this.options.url}?after=${n}`,o=await fetch(r,{headers:{Accept:"text/event-stream"},signal:e});if(!o.ok)throw new Error(`SSE connect failed: ${o.status}`);if(!o.body)throw new Error("SSE response has no body");let a=!1,i=!1,l=null;const c=()=>{l&&clearTimeout(l),l=setTimeout(()=>{this.controller?.abort()},Ij)},d=()=>{l&&(clearTimeout(l),l=null)};try{await Sj(o.body,Cj(Ej(()=>{},()=>{},p=>{if(c(),p.event==="reset"){try{(p.data?JSON.parse(p.data):{}).reason==="no_session"&&(i=!0)}catch{}this.options.onReset();return}if(a||(a=!0,this.connectionEstablished=!0,this.options.onConnected()),p.event==="replay_meta"){if(p.data&&this.options.onReplayMeta)try{this.options.onReplayMeta(JSON.parse(p.data))}catch{}return}if(p.data)try{const m=JSON.parse(p.data);this.options.onEvent(m)}catch{}})))}finally{d()}return i?"no_session":"ok"}setupVisibilityHandler(){typeof document>"u"||(this.visibilityHandler=()=>{document.hidden?this.controller?.abort():this.running&&!this.looping&&this.connectLoop()},document.addEventListener("visibilitychange",this.visibilityHandler))}teardownVisibilityHandler(){this.visibilityHandler&&typeof document<"u"&&(document.removeEventListener("visibilitychange",this.visibilityHandler),this.visibilityHandler=null)}}function ml(t){return new Promise(e=>setTimeout(e,t))}const hl=2e3,fl=50;class Rj{entries=[];record(e){let n;switch(e.type){case"EVENT":n=`seq=${e.event.seq} type=${e.event.type}`;break;case"RESET":n=`count=${e.events.length} seqRange=${e.events[0]?.seq??"-"}..${e.events.at(-1)?.seq??"-"}`;break;case"PREPEND_HISTORY":n=`count=${e.events.length} seqRange=${e.events[0]?.seq??"-"}..${e.events.at(-1)?.seq??"-"}`;break;case"ERROR":n=e.message;break}this.entries.push({action:e.type,ts:Date.now(),detail:n}),this.entries.length>fl&&this.entries.splice(0,this.entries.length-fl)}snapshot(){return[...this.entries]}}function Pj(t,e){switch(e.type){case"EVENT":{if(t.lastSeq>0&&e.event.seq<=t.lastSeq)return t;const n=[...t.events,e.event],r=n.length>hl?n.slice(n.length-hl):n;return{...t,events:r,lastSeq:e.event.seq}}case"CONNECTED":return{...t,connected:!0,error:null};case"DISCONNECTED":return{...t,connected:!1};case"ERROR":return{...t,error:e.message};case"RESET":return{...t,events:e.events,lastSeq:e.events.at(-1)?.seq??0};case"PREPEND_HISTORY":if(e.events.length===0)return t;{const n=new Set(t.events.map(a=>a.seq)),r=e.events.filter(a=>!n.has(a.seq));if(r.length===0)return t;const o=[...r,...t.events];return o.sort((a,i)=>a.seq-i.seq),{...t,events:o}}}}const Mj={events:[],lastSeq:0,connected:!1,error:null};function Lj(t,e){const[n,r]=u.useReducer(Pj,Mj),o=u.useRef(null),a=u.useRef("idle"),i=u.useRef(0),l=u.useRef(e);l.current=e;const c=u.useRef(new Rj),d=u.useCallback(C=>{c.current.record(C),r(C)},[]),[p,m]=u.useState(0),h=u.useRef(null);u.useEffect(()=>{if(!t){d({type:"RESET",events:[]}),i.current=0,h.current=null;return}const C=t!==h.current;h.current=t,C&&(d({type:"RESET",events:[]}),i.current=0);const j=new Aj({url:`${e.baseUrl}/${t}/events`,onEvent:E=>{i.current=E.seq,d({type:"EVENT",event:E}),l.current.onEvent?.(E)},onConnected:()=>{d({type:"CONNECTED"}),i.current===0&&(async()=>{if(await new Promise(E=>setTimeout(E,50)),!(i.current>0))try{const E=await fetch(`${l.current.baseUrl}/${t}/history?before=${Number.MAX_SAFE_INTEGER}&limit=200`);if(E.ok){const A=await E.json();A.events.length>0&&(i.current===0?(i.current=A.events.at(-1)?.seq??0,d({type:"RESET",events:A.events})):d({type:"PREPEND_HISTORY",events:A.events}))}}catch{}})()},onDisconnected:()=>{d({type:"DISCONNECTED"})},onReset:async()=>{const E=await l.current.onReset?.()??[];if(E.length>0){i.current=E.at(-1)?.seq??0,d({type:"RESET",events:E});return}try{const A=await fetch(`${l.current.baseUrl}/${t}/history?before=${Number.MAX_SAFE_INTEGER}&limit=200`);if(A.ok){const L=await A.json();if(L.events.length>0){i.current=L.events.at(-1)?.seq??0,d({type:"RESET",events:L.events});return}}}catch{}i.current=0,d({type:"RESET",events:[]})},onReplayMeta:E=>{E.scoped&&(async()=>{try{const A=await fetch(`${l.current.baseUrl}/${t}/history?before=${Number.MAX_SAFE_INTEGER}&limit=200`);if(A.ok){const L=await A.json();L.events.length>0&&d({type:"PREPEND_HISTORY",events:L.events})}}catch{}})()},onError:E=>{d({type:"ERROR",message:E})},getLastSeq:()=>i.current});return o.current=j,j.start(),()=>{j.stop(),o.current=null}},[t,e.baseUrl,p]);const g=u.useMemo(()=>Gp(n.events),[n.events]),f=u.useMemo(()=>Nj(n.events),[n.events]),x=u.useMemo(()=>wj(n.events),[n.events]),b=u.useMemo(()=>_j(n.events),[n.events]);u.useEffect(()=>{a.current!==g&&(l.current.onStatusChange?.(a.current,g),a.current=g)},[g]);const y=u.useCallback(async(C,j)=>{if(!t)return;const E=await fetch(`${l.current.baseUrl}/${t}/send`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:C,...j})});if(!E.ok){const A=await E.json().catch(()=>({error:"Send failed"}));throw new Error(A.error||`Send failed (${E.status})`)}},[t]),v=u.useCallback(async()=>{t&&await fetch(`${l.current.baseUrl}/${t}/stop`,{method:"POST"})},[t]),w=u.useCallback(()=>{m(C=>C+1)},[]),N=u.useCallback(C=>{i.current=C.seq,d({type:"EVENT",event:C})},[d]),S=u.useCallback(async C=>{if(!t)return{hasMore:!1};const j=n.events[0]?.seq??0;if(j<=1)return{hasMore:!1};const E=C?.limit??50,A=`${l.current.baseUrl}/${t}/history?before=${j}&limit=${E}`,L=await fetch(A);if(!L.ok)return{hasMore:!1};const $=await L.json();return $.events.length>0&&d({type:"PREPEND_HISTORY",events:$.events}),{hasMore:$.hasMore}},[t,n.events,d]),T=u.useMemo(()=>c.current.snapshot(),[n.events,n.connected]);return{status:g,activity:f,error:n.error,events:n.events,connected:n.connected,processAlive:x,usage:b,actionTrace:T,send:y,stop:v,reconnect:w,injectEvent:N,fetchHistory:S}}function gl(t,e=80){return t.length<=e?t:t.slice(0,e-1)+"…"}function Pe(t,e){const n=t[e];return typeof n=="string"?n:void 0}const Oj={Read:{category:"read",summary:{present:"Reading file",past:"Read file"},extractDetail:t=>Pe(t,"file_path"),isCollapsible:!0,isStructural:!1},Glob:{category:"read",summary:{present:"Searching files",past:"Searched files"},extractDetail:t=>Pe(t,"pattern"),isCollapsible:!0,isStructural:!1},LS:{category:"read",summary:{present:"Listing directory",past:"Listed directory"},extractDetail:t=>Pe(t,"path"),isCollapsible:!0,isStructural:!1},ListMcpResourcesTool:{category:"read",summary:{present:"Listing resources",past:"Listed resources"},isCollapsible:!0,isStructural:!1},ReadMcpResourceTool:{category:"read",summary:{present:"Reading resource",past:"Read resource"},extractDetail:t=>Pe(t,"uri"),isCollapsible:!0,isStructural:!1},Grep:{category:"search",summary:{present:"Searching code",past:"Searched code"},extractDetail:t=>Pe(t,"pattern"),isCollapsible:!0,isStructural:!1},WebSearch:{category:"search",summary:{present:"Searching web",past:"Searched web"},extractDetail:t=>Pe(t,"query"),isCollapsible:!0,isStructural:!1},WebFetch:{category:"search",summary:{present:"Fetching page",past:"Fetched page"},extractDetail:t=>Pe(t,"url"),isCollapsible:!0,isStructural:!1},ToolSearch:{category:"search",summary:{present:"Searching tools",past:"Searched tools"},extractDetail:t=>Pe(t,"query"),isCollapsible:!0,isStructural:!1},Write:{category:"write",summary:{present:"Writing file",past:"Wrote file"},extractDetail:t=>Pe(t,"file_path"),isCollapsible:!1,isStructural:!1},Edit:{category:"write",summary:{present:"Editing file",past:"Edited file"},extractDetail:t=>Pe(t,"file_path"),isCollapsible:!1,isStructural:!1},MultiEdit:{category:"write",summary:{present:"Editing file",past:"Edited file"},extractDetail:t=>Pe(t,"file_path"),isCollapsible:!1,isStructural:!1},NotebookEdit:{category:"write",summary:{present:"Editing notebook",past:"Edited notebook"},extractDetail:t=>Pe(t,"notebook_path"),isCollapsible:!1,isStructural:!1},Bash:{category:"execute",summary:{present:"Running command",past:"Ran command"},extractDetail:t=>{const e=Pe(t,"command");return e?gl(e,60):void 0},isCollapsible:!1,isStructural:!1},Monitor:{category:"execute",summary:{present:"Monitoring",past:"Monitored"},extractDetail:t=>Pe(t,"description"),isCollapsible:!0,isStructural:!1},ScheduleWakeup:{category:"meta",summary:{present:"Scheduling wakeup",past:"Scheduled wakeup"},extractDetail:t=>Pe(t,"reason"),isCollapsible:!0,isStructural:!1},Agent:{category:"agent",summary:{present:"Spawning agent",past:"Spawned agent"},extractDetail:t=>Pe(t,"description")??Pe(t,"subagent_type"),isCollapsible:!1,isStructural:!0},SendMessage:{category:"agent",summary:{present:"Sending message",past:"Sent message"},extractDetail:t=>Pe(t,"to"),isCollapsible:!1,isStructural:!0},EnterWorktree:{category:"agent",summary:{present:"Entering worktree",past:"Entered worktree"},isCollapsible:!1,isStructural:!0},ExitWorktree:{category:"agent",summary:{present:"Exiting worktree",past:"Exited worktree"},isCollapsible:!1,isStructural:!0},AskUserQuestion:{category:"meta",summary:{present:"Asking user",past:"Asked user"},extractDetail:t=>{const e=Pe(t,"question");return e?gl(e,60):void 0},isCollapsible:!1,isStructural:!1},EnterPlanMode:{category:"meta",summary:{present:"Entering plan mode",past:"Entered plan mode"},isCollapsible:!1,isStructural:!1},ExitPlanMode:{category:"meta",summary:{present:"Exiting plan mode",past:"Exited plan mode"},isCollapsible:!1,isStructural:!1},TaskCreate:{category:"meta",summary:{present:"Creating task",past:"Created task"},extractDetail:t=>Pe(t,"subject")??Pe(t,"description"),isCollapsible:!1,isStructural:!1},TaskUpdate:{category:"meta",summary:{present:"Updating task",past:"Updated task"},extractDetail:t=>Pe(t,"id"),isCollapsible:!1,isStructural:!1},TaskGet:{category:"meta",summary:{present:"Checking task",past:"Checked task"},extractDetail:t=>Pe(t,"id"),isCollapsible:!1,isStructural:!1},TaskList:{category:"meta",summary:{present:"Listing tasks",past:"Listed tasks"},isCollapsible:!1,isStructural:!1},TaskOutput:{category:"meta",summary:{present:"Reading task output",past:"Read task output"},extractDetail:t=>Pe(t,"id"),isCollapsible:!1,isStructural:!1},TaskStop:{category:"meta",summary:{present:"Stopping task",past:"Stopped task"},extractDetail:t=>Pe(t,"id"),isCollapsible:!1,isStructural:!1}};function dr(t,e){if(t.startsWith("mcp__"))return Dj(t);const n=Oj[t];if(!n)return{name:t,category:"meta",summary:{present:`Using ${t}`,past:`Used ${t}`},isCollapsible:!1,isStructural:!1};const r=e&&typeof e=="object"&&!Array.isArray(e)?e:{};return{name:t,category:n.category,summary:n.summary,detail:n.extractDetail?.(r),isCollapsible:n.isCollapsible,isStructural:n.isStructural}}function Dj(t){const e=t.split("__"),n=e[1]??"unknown",r=e.slice(2).join("__")||t;return{name:t,category:"integration",summary:{present:`${n}: ${r}`,past:`${n}: ${r}`},isCollapsible:!1,isStructural:!1,mcpServer:n}}function $j(t){return t.type==="collapsed"}function Hp(t){if(t.type!=="content")return[];const e=t.data;return e.blocks?e.blocks.filter(n=>n.type==="tool_use"):[]}function zj(t){const e=Hp(t);return e.length===0?!1:e.every(n=>dr(n.name,n.input).isCollapsible)}function Fj(t){const e=[];return t.read>0&&e.push(`Read ${t.read} file${t.read!==1?"s":""}`),t.search>0&&e.push(`searched ${t.search} pattern${t.search!==1?"s":""}`),t.list>0&&e.push(`listed ${t.list} director${t.list!==1?"ies":"y"}`),e.length>0&&(e[0]=e[0].charAt(0).toUpperCase()+e[0].slice(1)),e.join(", ")||"Explored codebase"}function xl(t,e,n){if(e.length<2){n.push(...t);return}const r={read:0,search:0,list:0},o=new Set;for(const a of e){switch(a.category){case"read":a.name==="LS"||a.name==="ListMcpResourcesTool"?r.list++:r.read++;break;case"search":r.search++;break}a.detail&&o.add(a.detail)}n.push({type:"collapsed",events:[...t],summary:Fj(r),counts:r,paths:[...o]})}function Vj(t){const e=[];let n=[],r=[];for(const o of t)if(o.type==="content"&&zj(o)){n.push(o);for(const a of Hp(o))r.push(dr(a.name,a.input))}else o.type==="result"&&n.length>0?n.push(o):(n.length>0&&(xl(n,r,e),n=[],r=[]),e.push(o));return n.length>0&&xl(n,r,e),e}const ur=new Set(["Agent","Task"]);function Bj(t){return t.some(n=>n.data?.parentToolUseId!=null)?Uj(t):Gj(t)}function Uj(t){const e=[],n={},r=new Set,o=new Set;for(const a of t){if(a.type!=="content")continue;const i=a.data;for(const l of i.blocks??[])l.type==="tool_use"&&ur.has(l.name??"")&&l.id&&r.add(l.id)}for(const a of r)n[a]=[];for(const a of t){const i=a.data,l=i?.parentToolUseId;if(a.type==="content"){let c=!1;for(const d of i?.blocks??[])if(d.type==="tool_use"&&ur.has(d.name??"")&&d.id){o.has(d.id)?c=!0:o.add(d.id);break}if(c)continue}l&&n[l]?n[l].push(a):e.push(a)}return{topLevel:e,childrenByToolUseId:n}}function Gj(t){const e=Hj(t),n=[],r={},o=[],a=new Set;for(const i of t){if(i.type==="result"&&o.length>0){const d=i.data,p=o[o.length-1];if((d.blocks??[]).some(h=>h.type==="tool_result"&&h.tool_use_id===p)){o.pop(),o.length>0?r[o[o.length-1]].push(i):n.push(i);continue}}let l=!1,c;if(i.type==="content"){const d=i.data;for(const p of d.blocks??[])if(p.type==="tool_use"&&ur.has(p.name??"")&&p.id){a.has(p.id)?l=!0:c=p.id;break}}l||(o.length>0?r[o[o.length-1]].push(i):n.push(i),c&&(a.add(c),e.has(c)||(o.push(c),r[c]=[])))}return{topLevel:n,childrenByToolUseId:r}}function Hj(t){const e=new Set,n=new Map;for(const r of t)if(r.type==="content"){const o=r.data,a=o.messageId;if(!a)continue;for(const i of o.blocks??[])if(i.type==="tool_use"&&ur.has(i.name??"")&&i.id){const l=n.get(a);l?l.push(i.id):n.set(a,[i.id])}}for(const[,r]of n)if(r.length>1)for(const o of r)e.add(o);return e}const qj=new Set(["content","result"]),Wj=new Set(["turn:end","run:end","run:ready","run:start","stop:requested"]);function Kj(t){const e=[],n=[];let r=!1,o=[];for(const a of t){if(o.length>0){let i=!1;if(a.type==="content"){const l=a.data,c=(l.blocks??[]).some(p=>p.type==="thinking"),d=(l.blocks??[]).some(p=>p.type==="text");(c||d)&&(i=!0)}if(a.type==="turn:end"&&(i=!0),i){for(const l of o)n.push({inputEvent:l.inputEvent,consumedByEvent:a});o=[]}}if(a.type==="input:sent"){if(r){const i=a.data;i.text&&o.push({inputEvent:a,text:i.text})}continue}Wj.has(a.type)?r=!1:qj.has(a.type)&&(r=!0)}return e.push(...o),{pending:e,consumed:n}}function Qj(t,e){const n="/api/harness",{status:r,activity:o,events:a,connected:i,processAlive:l,usage:c,error:d,send:p,stop:m,reconnect:h,injectEvent:g,fetchHistory:f,actionTrace:x}=Lj(t,{baseUrl:n,onEvent:j=>{}}),{pending:b,consumed:y}=u.useMemo(()=>Kj(a),[a]),v=u.useMemo(()=>Zj(a),[a]),w=r==="streaming",{renderItems:N,childrenMessages:S}=u.useMemo(()=>Jj(a,w,b,y),[a,w,b,y]),T=Yj(r),C=u.useMemo(()=>jj(a),[a]);return{status:T,activity:o,connected:i,processAlive:l,error:d,messages:v,renderItems:N,childrenMessages:S,usage:c,hasBackgroundTasks:C,pendingMessages:b,actionTrace:x,send:p,stop:m,reconnect:h,injectEvent:g,fetchHistory:f}}function Yj(t){switch(t){case"idle":return"idle";case"starting":return"initializing";case"streaming":return"streaming";case"stopping":return"stopping"}}function Jj(t,e,n=[],r=[]){const o=new Set;for(const m of n)o.add(m.inputEvent.seq);for(const m of r)o.add(m.inputEvent.seq);const a=new Map;for(const m of r){const h=m.consumedByEvent.seq,g=a.get(h);g?g.push(m):a.set(h,[m])}const{topLevel:i,childrenByToolUseId:l}=Bj(t),c=Vj(i),d=[];for(let m=0;m<c.length;m++){const h=c[m];if($j(h)){const f=m===c.length-1&&e;for(const x of h.events){const b=a.get(x.seq);if(b)for(const y of b){const v=y.inputEvent.data;v.text&&d.push({kind:"message",message:{id:`h-${y.inputEvent.seq}`,messageId:`h-${y.inputEvent.seq}`,type:"user",content:v.text,timestamp:new Date(y.inputEvent.timestamp).toISOString(),provider:"claude"}})}}d.push({kind:"group",group:Xj(h,f),temporalState:f?"active":"historical"})}else{if(h.type==="input:sent"&&o.has(h.seq)||h.type==="result")continue;const g=a.get(h.seq);if(g)for(const x of g){const b=x.inputEvent.data;b.text&&d.push({kind:"message",message:{id:`h-${x.inputEvent.seq}`,messageId:`h-${x.inputEvent.seq}`,type:"user",content:b.text,timestamp:new Date(x.inputEvent.timestamp).toISOString(),provider:"claude"}})}const f=ga(h);f&&d.push({kind:"message",message:f})}}const p={};for(const[m,h]of Object.entries(l)){const g=[];for(const f of h){const x=ga(f);x&&g.push(x)}g.length>0&&(p[m]=g)}return{renderItems:d,childrenMessages:p}}function Xj(t,e){const n=[];let r;const o=[];for(const i of t.events)if(i.type==="content"){const l=i.data;for(const c of l.blocks??[])c.type==="tool_use"&&o.push({name:c.name,input:c.input,id:c.id})}else if(i.type==="result"){const l=i.data;for(const c of l.blocks??[])if(c.type==="tool_result"){const d=c.tool_use_id,p=o.findIndex(h=>h.id===d),m=p>=0?o.splice(p,1)[0]:null;if(m){if(m.name==="ToolSearch"&&typeof m.input.query=="string"&&m.input.query.startsWith("select:"))continue;const h=dr(m.name,m.input);n.push({tool:bl(m.name),input:h.detail??m.name,filePath:m.input.file_path??void 0,resultContent:typeof c.content=="string"?c.content:void 0,status:c.is_error?"error":"success"})}}}for(const i of o){if(i.name==="ToolSearch"&&typeof i.input.query=="string"&&i.input.query.startsWith("select:"))continue;const l=dr(i.name,i.input);n.push({tool:bl(i.name),input:l.detail??i.name,filePath:i.input.file_path??void 0,status:"pending"}),r=l.summary.present+(l.detail?` ${l.detail}`:"")}!r&&n.length>0&&(r=n[n.length-1].input);const a=t.events[0]?.timestamp??Date.now();return{id:`group-${a}`,summary:t.summary,toolCalls:n,isActive:e||void 0,latestHint:e?r:void 0,timestamp:new Date(a).toISOString()}}function bl(t){switch(t){case"Read":return"read";case"Grep":return"grep";case"Glob":return"glob";case"LS":return"ls";case"WebSearch":return"web-search";case"WebFetch":return"web-fetch";case"ToolSearch":return"tool-search";default:return"read"}}function ga(t){switch(t.type){case"content":{const e=t.data;if(!e.blocks||e.blocks.length===0)return null;const n=e.blocks.map(eN).filter(Boolean);return n.length===0?null:{id:`h-${t.seq}`,messageId:`h-${t.seq}`,type:"assistant",content:n,timestamp:new Date(t.timestamp).toISOString(),provider:"claude"}}case"result":{const e=t.data;if(!e.blocks||e.blocks.length===0)return null;const n=[];for(const r of e.blocks)r.type==="tool_result"&&n.push({type:"tool_result",tool_use_id:r.tool_use_id,content:typeof r.content=="string"?r.content:JSON.stringify(r.content),is_error:r.is_error??!1});return n.length===0?null:{id:`h-${t.seq}`,messageId:`h-${t.seq}`,type:"user",content:n,timestamp:new Date(t.timestamp).toISOString(),provider:"claude"}}case"input:sent":{const e=t.data;return e.text?{id:`h-${t.seq}`,messageId:`h-${t.seq}`,type:"user",content:e.text,timestamp:new Date(t.timestamp).toISOString(),provider:"claude"}:null}case"run:error":{const e=t.data;return{id:`h-${t.seq}`,messageId:`h-${t.seq}`,type:"error",content:e.message??"Unknown error",timestamp:new Date(t.timestamp).toISOString(),provider:"claude"}}default:return null}}function Zj(t){const e=[];for(const n of t){const r=ga(n);r&&e.push(r)}return e}function eN(t){switch(t.type){case"text":return{type:"text",text:t.text};case"thinking":return{type:"thinking",thinking:t.thinking};case"tool_use":return{type:"tool_use",id:t.id,name:t.name,input:t.input};default:return null}}const tN=3e4;function yl(t){if(typeof t.content=="string")return t.content.slice(0,120);if(Array.isArray(t.content))for(const e of t.content){const n=e;if(n.type==="text"&&typeof n.text=="string")return n.text.slice(0,120)}return"[non-text]"}function vl(t){if(typeof t.content=="string")return t.content;if(Array.isArray(t.content)){const e=[];for(const n of t.content){const r=n;r.type==="text"&&typeof r.text=="string"&&e.push(r.text)}return e.length>0?e.join(`
|
|
337
|
+
`):null}return null}function sN({conversationId:t,messages:e,actionTrace:n,connected:r,status:o}){const a=u.useRef(null);u.useEffect(()=>{if(!t||e.length<2)return;const i=new Map,l=[];for(const x of e){const b=x.messageId||x.id,y=i.get(b)??0;if(i.set(b,y+1),y+1===2)l.push({id:b,count:2,preview:yl(x)});else if(y+1>2){const v=l.find(w=>w.id===b);v&&(v.count=y+1)}}const c=[];for(let x=1;x<e.length;x++){const b=e[x-1],y=e[x];if(b.type==="assistant"&&y.type==="assistant"){const v=vl(b),w=vl(y);v&&w&&v===w&&v.length>20&&c.push({index:x,id:y.messageId||y.id,preview:w.slice(0,120)})}}const d=[];for(let x=1;x<e.length;x++){const b=e[x-1],y=e[x];if(b.type==="assistant"&&y.type==="user"){const v=b.timestamp?new Date(b.timestamp).getTime():0,w=y.timestamp?new Date(y.timestamp).getTime():0;w>0&&v>0&&w<v&&d.push({index:x,userId:y.messageId||y.id,assistantId:b.messageId||b.id,userTs:y.timestamp||"",assistantTs:b.timestamp||"",userPreview:yl(y)})}}if(l.length===0&&c.length===0&&d.length===0)return;const p=Date.now(),m=a.current;if(m&&m.sessionId===t&&p-m.ts<tN)return;a.current={sessionId:t,ts:p};const h={conversationId:t,duplicateIds:l,consecutiveDupes:c,orderingAnomalies:d,messageCount:e.length,connected:r,status:o,actionTrace:n.slice(-30).map(x=>({action:x.action,ts:new Date(x.ts).toISOString(),detail:x.detail}))},g=d.length>0&&l.length===0&&c.length===0?"ordering-anomaly":d.length>0?"duplicate-and-ordering-anomaly":"duplicate-detected";mt({component:"DuplicateMessageDetector",event:g,severity:"warn",details:h});const f=d.length>0?"Message ordering anomaly":"Duplicate messages";console.warn(`[DuplicateMessageDetector] ${f} detected`,h)},[t,e,n,r,o])}const nN=2500,wl=1e4;function rN(t){const[e,n]=u.useState(null),r=u.useRef(!1),o=u.useRef(!1);u.useEffect(()=>{if(!t)return;let c=null;const d=async()=>{if(!r.current){r.current=!0;try{const{permissions:p}=await H.getPermissions({sessionId:t,status:"pending"}),m=p.length>0?p[p.length-1]:null;n(m);const h=o.current;if(o.current=m!==null,h!==o.current){c!==null&&clearInterval(c);const g=o.current?nN:wl;c=setInterval(()=>{d()},g)}}catch{}finally{r.current=!1}}};return d(),c=setInterval(()=>{d()},wl),()=>{c!==null&&clearInterval(c)}},[t]);const a=u.useCallback(async(c,d,p)=>{await H.sendPermissionDecision(c,{action:d,denyReason:p}),n(null)},[]),i=u.useCallback(async(c,d,p)=>{await H.addToAllowlist(p,d,e?.streamingId),await H.sendPermissionDecision(c,{action:"approve"}),n(null)},[e?.streamingId]),l=u.useCallback(async(c,d,p)=>{for(const m of d)await H.addToAllowlist(p,m,e?.streamingId);await H.sendPermissionDecision(c,{action:"approve"}),n(null)},[e?.streamingId]);return{permissionRequest:e,setPermissionRequest:n,answerPermission:a,answerPermissionWithPattern:i,answerPermissionWithPatterns:l}}const qp=u.createContext({agentColors:{},teamName:null});function oN(){return u.useContext(qp)}function aN({teamName:t,children:e}){const[n,r]=u.useState({}),o=u.useRef(t);o.current=t;const a=u.useCallback(async()=>{if(!o.current){r({});return}try{const l=await H.getTeamInfo(o.current);if(!l?.config?.members)return;const c={};for(const d of l.config.members)d.color&&(c[d.name]=d.color);r(c)}catch{}},[]);u.useEffect(()=>{t?a():r({})},[t,a]),Rt(u.useMemo(()=>({type:"activity"}),[]),u.useCallback(l=>{if(!t||typeof l!="object"||l===null||!("type"in l))return;const c=l.type;(c==="team-updated"||c==="team-inbox-update")&&a()},[t,a]));const i=u.useMemo(()=>({agentColors:n,teamName:t}),[n,t]);return s.jsx(qp.Provider,{value:i,children:e})}const Fe={tooltips:!1,focus:!1,sse:!1,insights:!1,composer:!1,walkthrough:!1,scroll:!1,navigation:!1,messages:!1};class iN{buffer=[];flushTimer=null;FLUSH_INTERVAL=1e3;MAX_BUFFER_SIZE=50;enabled=!0;constructor(){this.interceptConsole(),typeof window<"u"&&window.addEventListener("beforeunload",()=>{this.flush()})}interceptConsole(){if(typeof window>"u")return;const e=console.warn.bind(console);console.warn=(...n)=>{e(...n),this.enabled&&typeof n[0]=="string"&&n[0].startsWith("[")&&this.capture("warn",n)}}capture(e,n){const r=n.map(o=>typeof o=="string"?o:JSON.stringify(o)).join(" ");this.buffer.push({level:e,message:r,timestamp:new Date().toISOString()}),this.buffer.length>=this.MAX_BUFFER_SIZE?this.flush():this.scheduleFlush()}scheduleFlush(){this.flushTimer||(this.flushTimer=setTimeout(()=>{this.flushTimer=null,this.flush()},this.FLUSH_INTERVAL))}async flush(){if(this.buffer.length===0)return;const e=[...this.buffer];this.buffer=[];try{await fetch("/api/logs/debug",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({logs:e,source:"browser"})})}catch{}}log(e,n){console.warn(e,n??"")}setEnabled(e){this.enabled=e}async clear(){try{await fetch("/api/logs/debug",{method:"DELETE"})}catch{}}}new iN;if(typeof window<"u"){window.__latticeExportLogs=(e=10)=>{window.open(`/api/logs/export?minutes=${e}`,"_blank")};const t=console.log.bind(console);window.__latticeDebug={enable(e){e==="all"?(Object.keys(Fe).forEach(n=>{Fe[n]=!0}),t("[Debug] All flags enabled:",Object.keys(Fe).join(", "))):e in Fe?(Fe[e]=!0,t(`[Debug] Enabled: ${e}`)):t(`[Debug] Unknown flag: ${e}. Available: ${Object.keys(Fe).join(", ")}`)},disable(e){e==="all"?(Object.keys(Fe).forEach(n=>{Fe[n]=!1}),t("[Debug] All flags disabled")):e in Fe?(Fe[e]=!1,t(`[Debug] Disabled: ${e}`)):t(`[Debug] Unknown flag: ${e}. Available: ${Object.keys(Fe).join(", ")}`)},toggle(e){e in Fe?(Fe[e]=!Fe[e],t(`[Debug] ${e}: ${Fe[e]?"enabled":"disabled"}`)):t(`[Debug] Unknown flag: ${e}. Available: ${Object.keys(Fe).join(", ")}`)},list(){t("[Debug] Flags:",{...Fe}),t('Usage: __latticeDebug.enable("tooltips") or __latticeDebug.enable("all")')},flags:Fe}}function cN(t,e){const n=[],{displayMessages:r,toolResults:o}=t;for(const c of r)if(c.type==="user"&&Array.isArray(c.content)){const d=c.content;d.length>0&&d.every(m=>m.type==="tool_result")&&n.push({rule:"no-standalone-tool-results",message:`User message ${c.id} contains only tool_result blocks but is in displayMessages`,severity:"error",context:{messageId:c.id,blockCount:d.length}})}const a=new Map;for(let c=0;c<r.length;c++){const d=r[c].id;d&&a.has(d)?n.push({rule:"no-duplicate-uuids",message:`Duplicate message ID "${d}" at indices ${a.get(d)} and ${c}`,severity:"error",context:{id:d,firstIndex:a.get(d),secondIndex:c}}):d&&a.set(d,c)}for(const c of r)if(c.type==="assistant"&&Array.isArray(c.content))for(const d of c.content){const p=d;if(p.type==="tool_use"&&p.id){const m=p.id,h=typeof p.name=="string"?p.name:"unknown";o[m]||n.push({rule:"tool-use-has-result",message:`tool_use "${m}" (${h}) has no entry in toolResults`,severity:"warning",context:{toolUseId:m,toolName:h,messageId:c.id}})}}const i=r.reduce((c,d)=>d.type==="assistant"&&Array.isArray(d.content)?c+d.content.filter(p=>p.type==="tool_use").length:c,0),l=Object.values(o).filter(c=>c.status==="completed").length;i>0&&l===0&&n.push({rule:"tool-results-populated",message:`${i} tool_use blocks found but 0 completed tool results — results may not have been extracted from history`,severity:"error",context:{toolUseCount:i,completedCount:l,pendingCount:Object.keys(o).length}});for(let c=1;c<r.length;c++){const d=new Date(r[c-1].timestamp).getTime(),p=new Date(r[c].timestamp).getTime();p<d&&!isNaN(d)&&!isNaN(p)&&n.push({rule:"chronological-order",message:`Message at index ${c} (${r[c].id}) is before message at index ${c-1} (${r[c-1].id})`,severity:"warning",context:{prevId:r[c-1].id,prevTimestamp:r[c-1].timestamp,currId:r[c].id,currTimestamp:r[c].timestamp}})}for(const c of r)(c.content===null||c.content===void 0||c.content===""||Array.isArray(c.content)&&c.content.length===0)&&n.push({rule:"no-empty-content",message:`Message ${c.id} (${c.type}) has empty content`,severity:"warning",context:{messageId:c.id,type:c.type}});return n}const lN=({messages:t,toolResults:e,childrenMessages:n,sessionId:r})=>{const[o,a]=u.useState(!1),[i,l]=u.useState(!1),c=u.useMemo(()=>{const g=t.filter(S=>S.type==="user"),f=t.filter(S=>S.type==="assistant"),x=t.filter(S=>S.type!=="user"&&S.type!=="assistant"),b=t.reduce((S,T)=>T.type==="assistant"&&Array.isArray(T.content)?S+T.content.filter(C=>C.type==="tool_use").length:S,0),y=Object.values(e).filter(S=>S.status==="completed").length,v=Object.values(e).filter(S=>S.status==="pending").length,w=Object.keys(n).length,N=Object.values(n).reduce((S,T)=>S+T.length,0);return{total:t.length,user:g.length,assistant:f.length,system:x.length,toolUseCount:b,completedToolResults:y,pendingToolResults:v,totalToolResults:Object.keys(e).length,childGroupCount:w,totalChildMessages:N}},[t,e,n]),d=u.useMemo(()=>cN({displayMessages:t,toolResults:e}),[t,e,n]),p=d.filter(g=>g.severity==="error"),m=d.filter(g=>g.severity==="warning"),h=u.useCallback(()=>{const g={sessionId:r,stats:c,violations:d,messages:t.map(f=>({id:f.id,messageId:f.messageId,type:f.type,contentType:typeof f.content=="string"?"string":"blocks",blockTypes:Array.isArray(f.content)?f.content.map(x=>x.type):[],parentToolUseId:f.parentToolUseId})),toolResults:Object.entries(e).map(([f,x])=>({id:f,status:x.status,hasResult:!!x.result,isError:x.is_error})),childrenMessages:Object.entries(n).map(([f,x])=>({parentId:f,count:x.length}))};navigator.clipboard.writeText(JSON.stringify(g,null,2))},[r,c,d,t,e,n]);return o?s.jsxs("button",{onClick:()=>a(!1),className:`fixed bottom-4 right-4 z-50 px-3 py-1.5 text-xs font-mono
|
|
338
338
|
bg-stone-900/95 border border-amber-500/40 text-amber-400
|
|
339
339
|
rounded shadow-lg hover:border-amber-500/70 transition-colors`,title:"Show message debug overlay",children:["MSG ",p.length>0?`!! ${p.length}`:`${c.total}`]}):s.jsxs("div",{className:`fixed bottom-4 right-4 z-50 w-80 font-mono text-xs
|
|
340
340
|
bg-stone-900/95 border border-stone-700 rounded-lg shadow-xl
|
|
@@ -344,16 +344,16 @@ Be concise. The developer will read this alongside the user's bug report.`}funct
|
|
|
344
344
|
transition-colors`,title:"Copy state to clipboard",children:"COPY"}),s.jsx("button",{onClick:()=>a(!0),className:`px-1.5 py-0.5 text-stone-400 hover:text-stone-200
|
|
345
345
|
border border-stone-600 rounded hover:border-stone-500
|
|
346
346
|
transition-colors`,children:"—"})]})]}),r&&s.jsxs("div",{className:"px-3 py-1.5 border-b border-stone-800 text-stone-500",children:[r.slice(0,20),r.length>20?"…":""]}),s.jsxs("div",{className:"px-3 py-2 space-y-1",children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-stone-400",children:"Display msgs:"}),s.jsx("span",{className:"text-stone-200",children:c.total})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-stone-400",children:"User / Asst:"}),s.jsxs("span",{className:"text-stone-200",children:[c.user," / ",c.assistant,c.system>0&&s.jsxs("span",{className:"text-stone-500",children:[" + ",c.system," other"]})]})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-stone-400",children:"Tool results:"}),s.jsxs("span",{className:c.pendingToolResults>0?"text-amber-400":"text-stone-200",children:[c.completedToolResults,"/",c.totalToolResults,c.pendingToolResults>0&&` (${c.pendingToolResults} pending)`]})]}),c.childGroupCount>0&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-stone-400",children:"Children:"}),s.jsxs("span",{className:"text-stone-200",children:[c.totalChildMessages," in ",c.childGroupCount," groups"]})]})]}),s.jsx("div",{className:"px-3 py-2 border-t border-stone-800",children:p.length===0&&m.length===0?s.jsx("div",{className:"text-green-400",children:"✓ No violations"}):s.jsxs("div",{className:"space-y-1",children:[p.length>0&&s.jsxs("div",{className:"text-red-400",children:["✗ ",p.length," error",p.length!==1?"s":""]}),m.length>0&&s.jsxs("div",{className:"text-amber-400",children:["⚠ ",m.length," warning",m.length!==1?"s":""]})]})}),d.length>0&&s.jsxs("div",{className:"border-t border-stone-800",children:[s.jsxs("button",{onClick:()=>l(!i),className:`w-full px-3 py-1.5 text-left text-stone-400
|
|
347
|
-
hover:text-stone-200 hover:bg-stone-800/50 transition-colors`,children:[i?"▼":"▶"," Details"]}),i&&s.jsx("div",{className:"px-3 pb-2 space-y-1.5 max-h-40 overflow-y-auto",children:d.map((g,f)=>s.jsxs("div",{className:`text-[10px] leading-tight ${g.severity==="error"?"text-red-300":"text-amber-300/80"}`,children:[s.jsxs("span",{className:"font-bold",children:["[",g.rule,"]"]})," ",g.message]},f))})]})]})},dN=3e3;function _l(t){if(typeof t.content=="string")return t.content;if(Array.isArray(t.content)){const e=[];for(const n of t.content)typeof n=="object"&&n!==null&&"type"in n&&n.type==="text"&&"text"in n&&typeof n.text=="string"&&e.push(n.text);return e.join("")}return""}function kl(t){return t.replace(/\s+/g," ").trim()}function jl(t){const e=Date.parse(t);return Number.isFinite(e)?e:null}function Nl(t){return!t||t.startsWith("user-prompt-")?!1:t.startsWith("user-")||t.startsWith("optimistic-")||t.startsWith("queued-local-")||t.startsWith("h-")}function uN(t,e){return!t.provider||!e.provider?!0:t.provider===e.provider}function pN(t){const e=[];for(const n of t){if(n.type!=="user"){e.push(n);continue}const r=kl(_l(n));if(!r){e.push(n);continue}const o=n.id||n.messageId,a=jl(n.timestamp);let i=!1;for(let l=e.length-1;l>=0;l--){const c=e[l];if(c.type!=="user"||!uN(c,n)||kl(_l(c))!==r)continue;const p=jl(c.timestamp);if(a!==null&&p!==null&&Math.abs(a-p)>dN)continue;const m=c.id||c.messageId,h=Nl(o),g=Nl(m);if(h!==g){g&&!h&&(e[l]=n),i=!0;break}}i||e.push(n)}return e}const mN=7e3,hN=15e3;async function fN(t){try{const e=await
|
|
348
|
-
`)}function Cl(t){return t.replace(/[“”]/g,'"').replace(/^\s*[-*]\s+/,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^["'`]+/,"").replace(/["'`]+$/,"").replace(/\*\*/g,"").replace(/\s+/g," ").trim().toLowerCase()}function NN(t){const e=t.trim();if(e.length<2)return e;const n=e[0],r=e[e.length-1],o=[['"','"'],["“","”"],["'","'"],["`","`"]];for(const[a,i]of o)if(n===a&&r===i)return e.slice(1,-1).trim();return e}function SN(t){if(!t)return[];const e=[];for(const n of t.split(/\r?\n/)){const r=n.trim();if(!r)continue;const o=r.toUpperCase().indexOf(Sl);if(o===-1)continue;const a=NN(r.slice(o+Sl.length));a&&e.push(a)}return e}function CN(t){const{conversationId:e,combinedMessages:n,showToast:r}=t,o=u.useRef(new Set);u.useEffect(()=>{o.current.clear()},[e]),u.useEffect(()=>{if(!e||n.length===0)return;const a=new Map;for(const i of n){if(i.type!=="assistant")continue;const l=jN(i);if(!l)continue;const c=SN(l);for(const d of c){const p=Cl(d);if(!p)continue;const m=`${e}:${p}`;o.current.has(m)||a.set(m,{normalized:p})}}a.size!==0&&(async()=>{try{const{notes:i}=await G.getDevNotes();if(!Array.isArray(i)||i.length===0)return;const l=new Map;for(const h of i){const g=Cl(h.content);if(!g||h.status!=="pending")continue;const f=l.get(g);f?f.push(h):l.set(g,[h])}const c=[],d=new Set,p=new Set;for(const[h,g]of a.entries()){let x=l.get(g.normalized)?.find(b=>!p.has(b.id));if(!x){const y=Array.from(l.entries()).find(([v])=>v.includes(g.normalized)||g.normalized.includes(v));y&&(x=y[1].find(v=>!p.has(v.id)))}x&&(d.add(h),p.add(x.id),c.push(x))}if(c.length===0)return;await Promise.all(c.map(h=>G.updateDevNoteStatus(h.id,"done"))),d.forEach(h=>o.current.add(h));const m=c.length;r({title:`Marked ${m} dev note${m===1?"":"s"} done`,message:m===1?c[0].content:void 0,type:"success",duration:3500})}catch(i){console.error("Failed to auto-complete dev notes from CHECK OFF markers:",i)}})()},[n,e,r])}const EN=300;function TN(t){const{conversationId:e,queryClient:n}=t;u.useEffect(()=>{let r=null;const o=()=>{document.visibilityState==="visible"&&e&&(r=setTimeout(()=>{console.debug(`[DETAIL-TRACE] visibility-refresh invalidating details for ${e?.slice(0,12)}`),n.invalidateQueries({queryKey:ht.details(e)}),n.invalidateQueries({queryKey:vt.one(e)})},EN))};return document.addEventListener("visibilitychange",o),()=>{document.removeEventListener("visibilitychange",o),r&&clearTimeout(r)}},[e,n])}function IN(t){return!!t&&t.startsWith("conv-")}function AN(t){const{conversationId:e,conversationDetails:n,insights:r,navStartRef:o,navigationDebugEnabled:a}=t,i=u.useRef(null),l=u.useRef(null),c=u.useRef(new Map),d=typeof window<"u"&&window.localStorage.getItem("perf-debug")==="1",p=u.useCallback((m,h,g,f)=>{d&&g<32},[d]);return u.useEffect(()=>{if(!e)return;const m=`nav-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`;o.current={conversationId:e,time:performance.now(),traceId:m},i.current=null,l.current=null},[e,a,o]),u.useEffect(()=>{if(!e||!IN(e))return;let m=!1;const h=setTimeout(()=>{(async()=>{try{const g=await G.getConversationStatus(e);if(m||g.status!=="ongoing")return;const f=await G.getUnifiedConversation(e);if(m)return;const x=f.segments.slice().sort((w,N)=>w.sequenceNumber-N.sequenceNumber).at(-1);if(x?.status==="active")return;const b=Date.now(),y="session-switch-segment-status-mismatch",v=c.current.get(y);(v===void 0||b-v>=1e4)&&(c.current.set(y,b),mt({component:"ConversationView",event:y,severity:"warn",details:{conversationId:e.slice(0,8),conversationStatus:g.status,activeStreamingId:g.streamingId||null,latestSegmentId:x?.segmentId||null,latestSegmentProvider:x?.provider||null,latestSegmentStatus:x?.status||"missing"}}))}catch{if(m)return}})()},500);return()=>{m=!0,clearTimeout(h)}},[e]),u.useEffect(()=>{if(!e||!n||i.current===e)return;i.current=e;const m=o.current,h=m.conversationId===e?m.time:void 0;h&&Math.round(performance.now()-h),m.conversationId===e&&m.traceId},[n,e,o]),u.useEffect(()=>{if(!e||!r||l.current===e)return;l.current=e;const m=o.current.conversationId===e?o.current.time:void 0;m&&Math.round(performance.now()-m)},[e,r,o]),{onPerfRender:p}}function RN(t){return t instanceof Error?t.message:typeof t=="string"?t:"Unknown error"}function PN(t,e){const n=RN(e).trim()||"Unknown error";return/permission request timeout/i.test(n)||/did not respond/i.test(n)?"Claude session paused after a permission request timed out. Retry with TRUST/accept-edits mode, or respond to permissions sooner.":`Claude session failed: ${n}`}function MN(t){const{conversationId:e,conversationPausedReason:n,session:r,setSessionOptimisticOngoing:o,invalidateConversations:a,restoreDraftFromBackup:i,setSessionFailureError:l,nextStepsDismissedRef:c}=t;return{handleSendMessage:u.useCallback(async(p,m,h,g,f)=>{l(null),r.proposedNextSteps&&r.proposedNextSteps.length>0&&(c.current=!0,r.clearNextSteps()),e&&n&&G.unifiedUpdateConversation(e,{pausedReason:null});try{r.addOptimisticUserMessage(p),e&&o(e,"claude"),await r.sendMessage(p,h,g,f),a()}catch(x){console.error("[ConversationView] Send failed:",x),l(PN("claude",x)),i()}},[e,n,r,o,a,i,l,c])}}const El=1500,LN=3500;function _o(t){return new Promise(e=>setTimeout(e,t))}function ON(t){const{session:e,conversationId:n,setStopRequested:r}=t;return{handleStop:u.useCallback(async()=>{if(r(!0),!n){try{await e.stop()||(console.warn("[stop] Graceful stop failed, escalating to force-kill"),await e.forceKill())}catch(l){console.error("[stop] Stop/force-kill threw:",l)}r(!1);return}const a=async()=>{try{return(await G.getConversationStatus(n)).status}catch{return null}},i=l=>l===null||l==="completed"||l==="idle";try{await e.stop(),await _o(El);let l=await a();if(i(l)||(await _o(LN),l=await a()),!i(l)){console.warn("[stop] Server-side escalation timed out, sending force-kill",{conversationId:n,status:l});try{await G.unifiedForceKillConversation(n)}catch{}await _o(El),l=await a(),i(l)||console.error("[stop] Force-kill did not terminate session",{conversationId:n,status:l})}}catch(l){console.error("[stop] Unexpected error during stop sequence:",l)}r(!1)},[e,n,r])}}const DN=5e3,$N=["Load failed","Failed to fetch","NetworkError","network error","Connection lost"];function Tl(t){return t?$N.some(e=>t.includes(e)):!1}function zN(t){const{sessionError:e,sessionFailureError:n,clearSessionError:r,clearSessionFailureError:o}=t,a=u.useRef(null);u.useEffect(()=>{a.current&&(clearTimeout(a.current),a.current=null);const i=Tl(e),l=Tl(n);if(!(!i&&!l))return a.current=setTimeout(()=>{i&&r(),l&&o(),a.current=null},DN),()=>{a.current&&(clearTimeout(a.current),a.current=null)}},[e,n,r,o])}function FN(t,e){return t&&!e}const Il=2;function VN(t){return t.includes("Failed to fetch")||t.includes("Load failed")||t.includes("NetworkError")?"Connection lost — retrying…":t.includes("timeout")?"Session load timed out — retrying…":t}function BN({children:t}){const{agentColors:e}=oN(),n=u.useCallback(r=>e[r],[e]);return s.jsx(pg,{theme:"dark",resolveAgentColor:n,children:t})}function UN({sidebarOpen:t,onToggleSidebar:e}={}){const{conversationId:n}=zl(),r=n,o=$l(),a=St(),i=mn(),{isPro:l}=yn(),{showToast:c}=Fp();u.useEffect(()=>(r&&Ek({conversationId:r,sessionId:r}),()=>Tk()),[r]);const d=u.useMemo(()=>new URLSearchParams(o.search).get("debug")==="messages"||Fe.messages===!0,[o.search]),{status:p,connected:m,processAlive:h,error:g,messages:f,renderItems:x,childrenMessages:b,usage:y,hasBackgroundTasks:v,pendingMessages:w,actionTrace:N,send:S,stop:T,reconnect:C,fetchHistory:j}=Qj(r??null),{permissionRequest:E,answerPermission:R,answerPermissionWithPattern:O,answerPermissionWithPatterns:$}=rN(r),[re,ne]=u.useState(new Set),[V,X]=u.useState([]),[q,K]=u.useState(null),[ge,D]=u.useState([]),[W,Z]=u.useState(null),[F,se]=u.useState(null),ee=p!=="idle",te=p==="idle",xe=p==="initializing",_e=p==="streaming",A=g??F,P=u.useCallback(()=>se(null),[]);u.useEffect(()=>{(p==="initializing"||p==="streaming")&&W===null&&Z(Date.now()),p==="idle"&&Z(null)},[p,W]);const le=f,J=u.useMemo(()=>{const oe={};for(const ve of le)if(Array.isArray(ve.content))for(const je of ve.content){const Le=je;Le.type==="tool_result"&&typeof Le.tool_use_id=="string"&&(oe[Le.tool_use_id]={status:"completed",result:typeof Le.content=="string"?Le.content:void 0,is_error:typeof Le.is_error=="boolean"?Le.is_error:void 0})}return oe},[le]),H=u.useCallback(async(oe,ve,je,Le,Ur,gs)=>{try{if(m)await S(oe);else{const Jt=await fetch(`/api/harness/${r}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:oe,model:ve,permissionMode:je})});if(!Jt.ok){const Im=await Jt.json().catch(()=>({error:"Start failed"}));throw new Error(Im.error||"Start failed")}C()}}catch(Jt){se(Jt instanceof Error?Jt.message:"Send failed")}},[r,m,S,C]),ye=u.useCallback(async()=>{try{return await T(),!0}catch{return!1}},[T]),I=u.useCallback(async()=>{await T()},[T]),pe=u.useCallback(oe=>{ne(ve=>{const je=new Set(ve);return je.has(oe)?je.delete(oe):je.add(oe),je})},[]),Ce=u.useCallback(()=>K(null),[]),ke=u.useCallback(async oe=>{await H(oe)},[H]);u.useEffect(()=>{if(te&&ge.length>0){const[oe,...ve]=ge;D(ve),H(oe.sendContent)}},[te,ge,H]);const Re=u.useMemo(()=>({messages:le,isActive:ee,isConnected:m,proposedNextSteps:q,clearNextSteps:Ce,addOptimisticUserMessage:oe=>{},sendMessage:H,enqueueMessage:ke}),[le,ee,m,q,Ce,H,ke]),B=u.useMemo(()=>({stop:ye,forceKill:I}),[ye,I]),[he]=u.useState("Conversation"),[L,Q]=u.useState(!1),[U,ae]=u.useState(null),[be,me]=u.useState(!1),ze=u.useCallback(()=>ae(null),[]);zN({sessionError:A,sessionFailureError:U,clearSessionError:P,clearSessionFailureError:ze});const{insightsPanelOpen:Ne,setInsightsPanelOpen:Me,toggleInsightsPanel:nt}=wN(),Ye=t??!1,[Et,ps]=u.useState(!1),[vn,ms]=u.useState(!1),[Vs,Lr]=u.useState([]),Or=u.useCallback(async oe=>{try{return(await G.listDirectory({path:oe||"",recursive:!1,respectGitignore:!0})).entries}catch(ve){return console.error("Failed to fetch file system entries:",ve),[]}},[]),Dr=u.useCallback(async oe=>{try{const ve=await G.getCommands(oe||""),je=ve.commands.filter(Le=>Le.type==="custom").map(Le=>({name:Le.name,description:Le.description||"",argumentHint:Le.argumentHint}));return Lr(je),ve.commands}catch(ve){return console.error("Failed to fetch commands:",ve),[]}},[]),{conversations:wn,pendingInsightsUpdates:Tt,invalidateConversations:Bs,setSessionOptimisticOngoing:$r}=$s(),Je=u.useMemo(()=>r&&wn.find(oe=>oe.conversationId===r)||null,[wn,r]),rt=N2(r),Wt=u.useCallback(()=>{const oe=r?`claudia-draft-${r}`:"claudia-draft-home",ve=`${oe}-backup`;try{const je=localStorage.getItem(ve);je&&(localStorage.setItem(oe,je),localStorage.removeItem(ve))}catch{}},[r]),_n=u.useRef(null),kn=u.useRef(!1),Kt=u.useRef(!1),hs=u.useRef({}),fs=u.useRef({}),ot=u.useRef(!1);u.useEffect(()=>{if(o.state)try{window.history.replaceState({},document.title)}catch{}},[o]),u.useEffect(()=>{kn.current=!1,Kt.current=!1},[r]);const z=u.useRef(rt.isOngoing);u.useEffect(()=>{const oe=z.current;z.current=rt.isOngoing,FN(oe,rt.isOngoing)&&r&&(console.debug(`[DETAIL-TRACE] completion-edge invalidating details for ${r?.slice(0,12)}`),i.invalidateQueries({queryKey:ht.details(r)}))},[rt.isOngoing,r,i]);const de=u.useRef(r);u.useEffect(()=>{de.current!==r&&(de.current=r,me(!1),r&&(console.debug(`[DETAIL-TRACE] session-switch invalidating details for ${r?.slice(0,12)}`),i.invalidateQueries({queryKey:ht.details(r)}),i.invalidateQueries({queryKey:vt.one(r)})))},[r,i]);const Ie=50,Ee=10,{data:Se,isLoading:Xe,error:it,isFetching:zr}=Nt({queryKey:ht.details(r||""),queryFn:()=>{const oe=hs.current.conversationId===r?hs.current.traceId:void 0;return console.debug(`[DETAIL-TRACE] queryFn executing for ${r?.slice(0,12)} limit=${Ee} traceId=${oe?.slice(0,16)}`),G.getConversationDetails(r,{limit:Ee,traceId:oe,timeout:2e4})},enabled:!!r,staleTime:3e4,refetchOnMount:!0,refetchOnWindowFocus:!1,retry:(oe,ve)=>{if(oe>=3||!(ve instanceof Error))return!1;const je=ve.message,Le=je.includes("not found"),Ur=je.includes("Failed to fetch")||je.includes("NetworkError")||je.includes("Load failed"),gs=je.includes("timeout");return Le||Ur||gs},retryDelay:oe=>Math.min(500*2**oe,3e3)});TN({conversationId:r,queryClient:i});const{data:Qt,isLoading:am}=Nt({queryKey:["insights",r],queryFn:()=>G.unifiedGetInsights(r,!0),enabled:!!r,staleTime:3e4,refetchOnMount:!0,refetchOnWindowFocus:!1}),{onPerfRender:Fr}=AN({conversationId:r,conversationDetails:Se,insights:Qt,navStartRef:hs,navigationDebugEnabled:Fe.navigation}),{pendingQuestions:ci,handleAnswerPendingQuestion:im,handleDismissPendingQuestion:cm}=kN({conversationId:r,isSessionIdle:te,reconnectToStream:C}),lm=u.useMemo(()=>Qt?{lastUpdateTime:Qt.patchedAt||Qt.computedAt||null}:void 0,[Qt]);u.useEffect(()=>{Se&&Se.sessionId===r&&(bN({conversationDetails:Se,currentProposedNextSteps:q,isSessionIdle:te,isDismissedThisSession:Kt.current,setProposedNextSteps:K}),Se.mcpServers&&Se.mcpServers.length>0&&X(Se.mcpServers),yN({hasInitiallyFocusedRef:kn,composerRef:_n}))},[Se,q]),_N({conversationSummary:Je,insights:Qt,conversationTitle:he});const dm=u.useCallback(()=>{e?.()},[e]),{handleSendMessage:Vr}=MN({conversationId:r,conversationPausedReason:Je?.pausedReason,session:Re,setSessionOptimisticOngoing:$r,invalidateConversations:Bs,restoreDraftFromBackup:Wt,setSessionFailureError:ae,nextStepsDismissedRef:Kt}),um=u.useCallback(oe=>{Kt.current=!0,Ce();const ve=Je?.permissionMode;Vr(oe,void 0,void 0,ve||void 0)},[Vr,Je?.permissionMode,Ce]),pm=u.useCallback(()=>{Kt.current=!0,Ce()},[Ce]),li=u.useCallback(async(oe,ve,je)=>{if(!L){Q(!0);try{await R(oe,ve,je)}catch(Le){console.error("Failed to send permission decision:",Le)}finally{Q(!1)}}},[L,R]),mm=u.useCallback(async(oe,ve,je)=>{if(!L){Q(!0);try{await O(oe,ve,je)}catch(Le){console.error(`Failed to add pattern to ${je} allowlist:`,Le)}finally{Q(!1)}}},[L,O]),hm=u.useCallback(async(oe,ve,je)=>{if(!L){Q(!0);try{await $(oe,ve,je)}catch(Le){console.error(`Failed to add patterns to ${je} allowlist:`,Le)}finally{Q(!1)}}},[L,$]),{handleStop:fm}=ON({session:B,conversationId:r,setStopRequested:me});u.useEffect(()=>{ae(null)},[r]);const di=u.useCallback(async oe=>{if(!r||ot.current)return;const ve=(fs.current[r]||0)+1;if(ve>Il)return;fs.current[r]=ve,ot.current=!0;const je=hs.current;je.conversationId===r&&je.time&&Math.round(performance.now()-je.time);try{await fN({sessionId:r,reconnectToStream:C}),await gN({queryClient:i,sessionId:r})}finally{ot.current=!1}},[r,m,C,i]),ui=!it&&Xe,gm=ui,Yt=u.useMemo(()=>pN(le),[le]);sN({conversationId:r??null,messages:Yt,actionTrace:N,connected:m,status:p});const{hasMoreMessages:xm,isLoadingMore:bm,jumpToMessageId:ym,setJumpToMessageId:vm,loadMoreMessages:wm,handleJumpToTurn:_m}=vN({conversationId:r,fetchHistory:j,initialMessageLimit:Ie});CN({conversationId:r,combinedMessages:Yt,showToast:c});const ut=ee,pi=u.useRef(te);u.useEffect(()=>{const oe=pi.current;if(pi.current=te,!r&&be){me(!1);return}!ut&&te&&!oe&&be&&me(!1)},[r,ut,te,be]);const Br=u.useRef(!1);u.useEffect(()=>{Br.current=!1},[r]),u.useEffect(()=>{Br.current||(Br.current=!0,console.debug(`[status:mount] ${r?.slice(0,12)}`,`alive=${h} busy=${ut}`,{"authoritative.status":rt.status,"authoritative.streamingId":rt.streamingId?.slice(0,8)??"-","authoritative.isFetching":rt.isFetching,"authoritative.isLoading":rt.isLoading,"authoritative.dataUpdatedAt":rt.dataUpdatedAt,harnessStatus:p,isActive:ee,harnessConnected:m,"session.streamingId":"-"}))});const mi=u.useRef({isProviderBusy:ut,processAlive:h});u.useEffect(()=>{const oe=mi.current;(oe.isProviderBusy!==ut||oe.processAlive!==h)&&(console.debug(`[status:view] ${r?.slice(0,12)}`,`busy=${ut} (was ${oe.isProviderBusy})`,`alive=${h} (was ${oe.processAlive})`,{isActive:ee,harnessConnected:m,harnessStatus:p,"authoritative.isOngoing":rt.isOngoing,"authoritative.isFetching":rt.isFetching}),mi.current={isProviderBusy:ut,processAlive:h})});const km=[...ge];u.useEffect(()=>{r&&(fs.current[r]=0,ot.current=!1)},[r]),u.useEffect(()=>{if(!r)return;const oe=it instanceof Error&&it.message.includes("not found");if(it&&!(oe&&h)||(fs.current[r]||0)>=Il)return;const je=ut,Le=Yt.length===0,gs=xN({hasActiveSignal:je,noVisibleContent:Le,slowHydration:Xe||zr});if(!gs.shouldRecover)return;const Jt=setTimeout(()=>{di(gs.reason)},gs.delayMs);return()=>clearTimeout(Jt)},[r,it,Xe,zr,ut,h,Yt.length,di]);const jm=ut||h,Nm=it instanceof Error&&it.message.includes("not found"),Sm=it&&!(Nm&&jm)?VN(it.message):null,hi=A==="session_limit"||A==="init_timeout"||zr?null:U||A||Sm,Cm=E?s.jsx(vj,{permission:E,streamingId:void 0,workingDirectory:Je?.workingDirectory,onApprove:()=>li(E.id,"approve"),onApprovePattern:(oe,ve)=>mm(E.id,oe,ve),onApprovePatterns:(oe,ve)=>hm(E.id,oe,ve),onDeny:oe=>li(E.id,"deny",oe),isLoading:L}):null,fi=u.useRef(null);u.useEffect(()=>{if(A&&A!==fi.current){const oe=r?`claudia-draft-${r}-backup`:"claudia-draft-home-backup",ve=localStorage.getItem(oe);if(ve){const je=r?`claudia-draft-${r}`:"claudia-draft-home";localStorage.setItem(je,ve),localStorage.removeItem(oe)}}fi.current=A},[A,r]);const Em=u.useCallback(async()=>{r&&await G.resumeConversation(r,{message:"Approved. Proceed with the plan.",permissionMode:"bypassPermissions"})},[r]),Tm=u.useCallback(async()=>{r&&await G.resumeConversation(r,{message:"Plan rejected — please revise or take a different approach.",permissionMode:"plan"})},[r]);return s.jsx(u.Profiler,{id:"ConversationView",onRender:Fr,children:s.jsx(aN,{teamName:Je?.teamName??null,children:s.jsx(BN,{children:s.jsxs("div",{className:"h-full w-full flex flex-col bg-background relative overflow-hidden",role:"main","aria-label":"Conversation view",children:[s.jsx(sj,{sessionId:r,isArchived:Je?.archived||!1,isPinned:Je?.pinned||!1,subtitle:Je?{date:new Date(Je.createdAt).toLocaleDateString("en-US",{month:"short",day:"numeric"}),repo:Je.workingDirectory.split("/").pop()||"project"}:void 0,insightsPanelOpen:Ne,onToggleInsightsPanel:nt,crossSessionSidebarOpen:Ye,onToggleCrossSessionSidebar:dm,onOpenCrossSessionAnalysis:()=>ps(!0),onOpenFeedbackPanel:()=>ms(!0)}),hi&&s.jsx("div",{className:"bg-red-500/10 border-b border-red-500 text-red-600 dark:text-red-400 px-4 py-2 text-sm text-center animate-in slide-in-from-top duration-300",role:"alert",children:hi}),A==="init_timeout"&&s.jsx("div",{className:"bg-amber-500/10 border-b border-amber-500 text-amber-700 dark:text-amber-400 px-4 py-2 text-sm text-center animate-in slide-in-from-top duration-300",role:"alert",children:"Session initialization timed out — the conversation may be too large. Consider starting a fresh session."}),s.jsxs("div",{className:"flex-1 flex overflow-hidden relative",children:[Et&&s.jsx("div",{className:"absolute inset-0 z-30 bg-background",children:s.jsx(Bp,{onClose:()=>ps(!1)})}),vn&&s.jsx("div",{className:"absolute inset-0 z-30 bg-background",children:s.jsx(hj,{onClose:()=>ms(!1),conversationId:r})}),s.jsxs("div",{className:"flex-1 flex flex-col min-w-0 relative",children:[s.jsxs(s.Fragment,{children:[s.jsx(u.Profiler,{id:"MessageList",onRender:Fr,children:s.jsx(rk,{sessionId:r,messages:ui&&Yt.length===0?[]:Yt,renderItems:x,toolResults:J,childrenMessages:b,expandedTasks:re,onToggleTaskExpanded:pe,isLoading:gm,isStreaming:_e,streamingProvider:"claude",pendingQuestion:ci.length>0?ci[0]:null,onAnswerPendingQuestion:im,onDismissPendingQuestion:cm,hasMore:xm,isLoadingMore:bm,onLoadMore:wm,branchLineage:Se?.sessionInfo?.branched_from_session_id?{parentSessionId:Se.sessionInfo.branched_from_session_id,atTurn:Se.sessionInfo.branched_at_turn||0,branchPointMessageId:Se.branchPointMessageId}:void 0,onNavigateToSession:oe=>a(`/c/${oe}`),sessionStartTime:W,isSwitchingProvider:!1,switchingToProvider:"claude",jumpToMessageId:ym,onJumpHandled:()=>vm(null),inlinePermissionPrompt:Cm,onPlanApprove:Em,onPlanReject:Tm,actionTrace:N})}),d&&s.jsx(lN,{messages:Yt,toolResults:J,childrenMessages:b,sessionId:r})]}),Je?.importedAt?s.jsx("div",{className:"flex-shrink-0 z-10 w-full flex justify-center py-3",style:{paddingBottom:"calc(var(--lattice-composer-dock-bottom-gap) + var(--lattice-safe-area-bottom))"},children:s.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 bg-cyan-500/10 border border-cyan-500/30 rounded-sm",children:[s.jsx(Kn,{size:14,className:"text-cyan-400"}),s.jsx("span",{className:"text-cyan-400 font-display text-xs uppercase tracking-wider",children:"Imported session — read-only"})]})}):s.jsxs("div",{className:"flex-shrink-0 bg-white/80 dark:bg-zinc-900/80 backdrop-blur-sm z-10 w-full flex flex-col items-center pt-4",style:{paddingBottom:"calc(var(--app-composer-dock-bottom-gap) + var(--app-safe-area-bottom))"},children:[q&&q.length>0&&te&&s.jsx("div",{className:"w-full max-w-5xl px-4 mb-2",children:s.jsx(pk,{steps:q,onSelect:um,onDismiss:pm})}),w.length>0&&s.jsx("div",{className:"w-full max-w-5xl px-4 mb-2 flex flex-col gap-1.5",children:w.map(oe=>s.jsx("div",{"data-testid":"pending-message",className:"flex justify-end",children:s.jsx("div",{className:"max-w-[80%] min-w-[100px]",children:s.jsxs("div",{className:"border border-cyan-500/15 rounded-lg overflow-hidden bg-cyan-500/3 w-full opacity-60",children:[s.jsx("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-cyan-500/8",children:s.jsx("span",{className:"text-[11px] text-zinc-500 font-medium",children:"User"})}),s.jsx("div",{className:"px-3 py-2 text-[13px] leading-relaxed text-foreground/40 whitespace-pre-wrap break-words",children:oe.text})]})})},`pending-${oe.inputEvent.seq}`))}),s.jsx("div",{className:"w-full max-w-5xl px-4",children:s.jsx(pp,{ref:_n,core:{sessionId:r,onSubmit:Vr,isLoading:m||L,placeholder:""},features:{enableFileAutocomplete:!0,showSmartMenu:!0},workingDirectory:Je?.workingDirectory,permissionConfig:{onStop:fm,onInterrupt:I},skills:Vs,mcpServers:V,runtimeConfig:{isSessionActive:ut,isSessionConnected:h||rt.isIdle,isStopRequested:be,isInitializing:xe,hasBackgroundTasks:v,sessionStartTime:W??void 0,onFetchFileSystem:Or,onFetchCommands:Dr,queuedMessages:km,sessionUsage:y}})})]})]}),s.jsx(u.Profiler,{id:"InsightsPanel",onRender:Fr,children:s.jsx(aj,{insights:Qt??null,isLoading:am,isOpen:l&&Ne,onClose:()=>{Me(!1),localStorage.setItem("insightsPanelOpen","false")},syncState:lm,isPendingInsightsUpdate:r?Tt.has(r):!1,sessionId:r,onJumpToTurn:_m,onBranch:async oe=>{await Bs(),a(`/c/${oe}`)}})})]})]})})})})}function GN(){return`pending-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function Wp({sidebarOpen:t,onToggleSidebar:e}){const[n,r]=xa(),o=St(),{serverConfig:a}=zs(),{addOptimisticSession:i,addPendingLaunch:l,removePendingLaunch:c,invalidateConversations:d}=$s(),p="main",[m,h]=u.useState(!1),[g,f]=u.useState(!1),[x,b]=u.useState(0),[y,v]=u.useState(null),[w,N]=u.useState(!0);n.get("provider");const S=n.get("mode"),T="claude",[C,j]=u.useState(T);u.useEffect(()=>{j(T)},[T]);const E=pn({explicit:S??void 0,fallback:a?.defaultPermissionMode,provider:T}),R=a?.defaultWorkingDirectory||a?.cwd||"~",O=u.useCallback(async()=>{try{const[X,q,K]=await Promise.all([G.getDevNotes(),G.getPendingRecommendations(),G.getCrossSessionStatus()]);b(X.notes.length+q.recommendations.length),v({pendingExtractions:K.pendingExtractions,threshold:K.threshold,pendingProposals:K.pendingProposals,readyToAnalyze:K.readyToAnalyze,synthesisInProgress:K.synthesisInProgress})}catch(X){console.error("Failed to refresh new-session header state:",X)}finally{N(!1)}},[]);u.useEffect(()=>{O();const X=window.setInterval(()=>{O()},15e3);return()=>window.clearInterval(X)},[O]),u.useCallback(X=>{j(X);const q=new URLSearchParams(n);q.set("provider",X),r(q,{replace:!0})},[n,r]);const $=u.useCallback(()=>{f(!1),O()},[O]),re=u.useCallback(async(X,q,K,ge)=>{if(X.length===0&&q.length===0)return;const W=await Lp(G,X,q,R,{workspace:p,provider:K||"claude",model:a?.defaultModel,permissionMode:ge||E});return W?(await d(),{sessionId:W.conversationId}):null},[d,E,a?.defaultModel,R]),ne=u.useCallback(()=>{const X=!!y?.readyToAnalyze;o(X?"/analysis/cross-session?run=1":"/analysis/cross-session")},[y?.readyToAnalyze,o]),V=u.useCallback(async(X,q,K,ge,D,W)=>{if(!X.trim()||m)return;h(!0);const Z=W||C,F=a?.defaultModel||"claude-opus-4-7",se=E,ee=GN();l({tempId:ee,workingDirectory:q||R,initialPrompt:X,model:F,permissionMode:se,workspace:p,provider:Z});try{const te=await G.createConversation({provider:Z,message:X,workingDirectory:q||R,model:F,permissionMode:se,workspace:p});try{localStorage.setItem(`lattice:last-provider:${te.conversationId}`,te.provider)}catch{}i({conversationId:te.conversationId,streamingId:te.streamingId,workingDirectory:te.cwd,model:te.model,permissionMode:te.permissionMode||se,initialPrompt:X,workspace:p,provider:te.provider}),ca(te.conversationId,"client.navigate_to_conversation"),o(`/c/${te.conversationId}`),d()}catch(te){console.error("Failed to create session:",te),alert(`Failed to create session: ${te instanceof Error?te.message:"Unknown error"}`)}finally{c(ee),h(!1)}},[m,C,E,R,p,a,i,l,c,d,o]);return s.jsx(Ot,{children:s.jsxs("div",{className:`flex-1 min-w-0 flex flex-col h-full relative overflow-hidden ${t?"hidden md:flex":""}`,children:[s.jsxs("div",{className:"flex justify-between items-center gap-3 px-4 py-3 border-b border-border/50 bg-background transition-colors relative overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 ui-grid-overlay pointer-events-none"}),s.jsxs("div",{className:"relative flex items-center gap-2 sm:gap-3 min-w-0",children:[!t&&s.jsx("button",{onClick:e,"aria-label":"Open sessions sidebar",className:"p-1.5 ui-icon-btn ui-icon-btn--cool",children:s.jsx(Wl,{size:18})}),s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(hp,{size:28,interactive:!0,colorScheme:"gradient"}),s.jsx("span",{className:"text-base font-display font-medium lowercase tracking-widest text-white",children:"lattice"}),s.jsx("span",{className:"hidden lg:inline font-mono text-[10px] text-muted-foreground/30 select-none",children:"18351bca"})]}),s.jsx("span",{className:"hidden md:block h-4 w-px bg-border/20 shrink-0"}),s.jsx("span",{className:"hidden sm:inline text-[10px] font-display font-bold uppercase tracking-wider text-muted-foreground/60",children:"New Session"})]}),s.jsxs("div",{className:"relative flex items-center gap-2 flex-shrink-0",children:[s.jsx(ha,{status:y,isLoading:w,onClick:ne}),s.jsx($p,{count:x,onClick:()=>f(!0)})]})]}),s.jsxs("div",{className:"flex-1 flex flex-col justify-end",children:[s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsxs("div",{className:"flex flex-col items-center gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(as,{size:14,className:"text-cyan-400/40"}),s.jsx("span",{className:"text-sm font-display font-bold uppercase tracking-wider text-muted-foreground/35",children:"Claude"})]}),s.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground/20",children:[s.jsx("span",{className:"text-[10px] font-mono",children:"Type a message to start"}),s.jsx("span",{className:"text-[9px] font-mono px-1 py-0.5 border border-border/30 rounded-sm bg-background/40",children:"⏎"})]})]})}),s.jsx("div",{className:"flex-shrink-0 bg-white/80 dark:bg-zinc-900/80 backdrop-blur-sm z-10 w-full flex flex-col items-center pt-4",style:{paddingBottom:"calc(var(--app-composer-dock-bottom-gap) + var(--app-safe-area-bottom))"},children:s.jsx("div",{className:"w-full max-w-5xl px-4",children:s.jsx(pp,{core:{onSubmit:V,isLoading:m,disabled:m,placeholder:""},features:{enableFileAutocomplete:!0,showSmartMenu:!0},workingDirectory:R,runtimeConfig:{isInitializing:m}})})})]}),s.jsx(Dp,{isOpen:g,onClose:$,onLaunchSession:re,defaultProvider:"claude",defaultPermissionMode:E,initialProvider:C,initialPermissionMode:E})]})})}const Al="app-favicon",Kp="/favicon.png",HN="/favicon-attention.svg",Qp=5e3;function Yp(t){return t.endsWith(".png")?"image/png":"image/svg+xml"}const Jp=["attention-favicon"];function qN(){const t=document.getElementById(Al);if(t instanceof HTMLLinkElement)return t;const e=document.createElement("link");return e.id=Al,e.rel="icon",e.type=Yp(Kp),document.head.appendChild(e),e}function Rl(t){if(typeof document>"u")return;const e=qN(),n=t?HN:Kp;e.rel="icon",e.type=Yp(n),e.href=n}async function Xp(){const[t,e]=await Promise.all([G.getPermissions({status:"pending"}),G.getPendingQuestions()]),n={};for(const r of t.permissions){const o=r.conversationId||r.sessionId;o&&(n[o]=(n[o]||0)+1)}for(const r of e.questions){const o=r.conversationId||r.sessionId;o&&(n[o]=(n[o]||0)+1)}return{permissionCount:t.permissions.length,questionCount:e.questions.length,sessionAttention:n}}function WN(){const{data:t}=Nt({queryKey:Jp,queryFn:Xp,staleTime:2e3,refetchInterval:Qp,refetchIntervalInBackground:!1}),e=(t?.permissionCount||0)>0||(t?.questionCount||0)>0;return u.useEffect(()=>(Rl(e),()=>{Rl(!1)}),[e]),null}function KN(t){const{data:e}=Nt({queryKey:Jp,queryFn:Xp,staleTime:2e3,refetchInterval:Qp,refetchIntervalInBackground:!1});return!e||!t?!1:(e.sessionAttention[t]||0)>0}function zn({children:t,className:e=""}){return s.jsx("span",{className:`text-[7px] px-1 py-0.5 rounded-sm border font-bold uppercase tracking-wider backdrop-blur-sm ${e}`,children:t})}function QN(t){const e=Date.now()-new Date(t).getTime(),n=Math.floor(e/1e3),r=Math.floor(n/60),o=Math.floor(r/60);return n<10?"now":n<60?`${n}s`:r<60?`${r}m`:o<24?`${o}h`:`${Math.floor(o/24)}d`}const YN=["claude"];function JN(t){const e=new Set(t.providersUsed??[]);return e.add(t.latestProvider),YN.filter(n=>e.has(n))}function XN(t){return t.activeProvider??t.latestProvider}const ZN=encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 80 80" fill="none">
|
|
347
|
+
hover:text-stone-200 hover:bg-stone-800/50 transition-colors`,children:[i?"▼":"▶"," Details"]}),i&&s.jsx("div",{className:"px-3 pb-2 space-y-1.5 max-h-40 overflow-y-auto",children:d.map((g,f)=>s.jsxs("div",{className:`text-[10px] leading-tight ${g.severity==="error"?"text-red-300":"text-amber-300/80"}`,children:[s.jsxs("span",{className:"font-bold",children:["[",g.rule,"]"]})," ",g.message]},f))})]})]})},dN=3e3;function _l(t){if(typeof t.content=="string")return t.content;if(Array.isArray(t.content)){const e=[];for(const n of t.content)typeof n=="object"&&n!==null&&"type"in n&&n.type==="text"&&"text"in n&&typeof n.text=="string"&&e.push(n.text);return e.join("")}return""}function kl(t){return t.replace(/\s+/g," ").trim()}function jl(t){const e=Date.parse(t);return Number.isFinite(e)?e:null}function Nl(t){return!t||t.startsWith("user-prompt-")?!1:t.startsWith("user-")||t.startsWith("optimistic-")||t.startsWith("queued-local-")||t.startsWith("h-")}function uN(t,e){return!t.provider||!e.provider?!0:t.provider===e.provider}function pN(t){const e=[];for(const n of t){if(n.type!=="user"){e.push(n);continue}const r=kl(_l(n));if(!r){e.push(n);continue}const o=n.id||n.messageId,a=jl(n.timestamp);let i=!1;for(let l=e.length-1;l>=0;l--){const c=e[l];if(c.type!=="user"||!uN(c,n)||kl(_l(c))!==r)continue;const p=jl(c.timestamp);if(a!==null&&p!==null&&Math.abs(a-p)>dN)continue;const m=c.id||c.messageId,h=Nl(o),g=Nl(m);if(h!==g){g&&!h&&(e[l]=n),i=!0;break}}i||e.push(n)}return e}const mN=7e3,hN=15e3;async function fN(t){try{const e=await H.getConversationStatus(t.sessionId);e.status==="ongoing"&&e.streamingId&&t.reconnectToStream(e.streamingId)}catch{}}async function gN(t){console.debug(`[DETAIL-TRACE] watchdog-recovery refetching details for ${t.sessionId?.slice(0,12)}`),await t.queryClient.cancelQueries({queryKey:ht.details(t.sessionId),exact:!0}),await Promise.all([t.queryClient.refetchQueries({queryKey:ht.details(t.sessionId),exact:!0}),t.queryClient.refetchQueries({queryKey:["insights",t.sessionId],exact:!0})])}function xN(t){if(!(t.hasActiveSignal&&t.noVisibleContent||t.slowHydration))return{shouldRecover:!1};const n=t.hasActiveSignal&&t.noVisibleContent?"empty-active":"slow-hydration";return{shouldRecover:!0,reason:n,delayMs:n==="empty-active"?mN:hN}}function bN(t){const e=t.conversationDetails.proposedNextSteps;!e||e.length===0||t.currentProposedNextSteps||!t.isSessionIdle||t.isDismissedThisSession||t.setProposedNextSteps(e)}function yN(t){t.hasInitiallyFocusedRef.current||(t.hasInitiallyFocusedRef.current=!0,setTimeout(()=>t.composerRef.current?.focusInput(),100))}function vN(t){const{conversationId:e,fetchHistory:n,initialMessageLimit:r}=t,[o,a]=u.useState(!0),[i,l]=u.useState(!1),[c,d]=u.useState(null),p=u.useCallback(async()=>{if(!(!e||!o||i)){l(!0);try{const h=await n({limit:r});a(h.hasMore)}catch(h){console.error("Failed to load more messages:",h)}finally{l(!1)}}},[e,o,i,n,r]),m=u.useCallback(async h=>{if(e){l(!0);try{let g=!0,f=0;const x=40;for(;g&&f<x;)g=(await n({limit:r})).hasMore,f++;a(g)}catch(g){console.error("Failed to load history for jump-to-turn:",g)}finally{l(!1)}}},[e,n,r]);return{hasMoreMessages:o,setHasMoreMessages:a,isLoadingMore:i,jumpToMessageId:c,setJumpToMessageId:d,loadMoreMessages:p,handleJumpToTurn:m}}function wN(){const[t,e]=u.useState(()=>{try{const r=localStorage.getItem("insightsPanelOpen");if(r!==null)return r==="true"}catch{}return typeof window<"u"&&window.innerWidth>=768}),n=u.useCallback(()=>{e(r=>{const o=!r;try{localStorage.setItem("insightsPanelOpen",String(o))}catch{}return o})},[]);return{insightsPanelOpen:t,setInsightsPanelOpen:e,toggleInsightsPanel:n}}function _N(t){const{conversationSummary:e,insights:n,conversationTitle:r}=t;u.useEffect(()=>{const o=e?.customName||n?.context?.mission||n?.purpose||(r!=="Conversation"?r:null);if(o){const a=o.length>50?`${o.slice(0,47)}...`:o;document.title=`Lattice · ${a}`}else document.title="Lattice";return()=>{document.title="Lattice"}},[r,e,n])}function kN(t){const{conversationId:e,isSessionIdle:n,reconnectToStream:r}=t,{data:o,refetch:a}=Mt({queryKey:["pendingQuestions",e],queryFn:()=>H.getPendingQuestions(e),enabled:!!e&&n,staleTime:1e4}),i=o?.questions||[],l=u.useRef(n);u.useEffect(()=>{n&&!l.current&&a(),l.current=n},[n,a]);const c=u.useCallback(async(p,m)=>{const h=await H.answerPendingQuestion(p,m);return a(),h.streamingId&&r(h.streamingId),h},[r,a]),d=u.useCallback(async p=>{try{await H.expirePendingQuestion(p),a()}catch(m){console.error("Failed to dismiss pending question:",m)}},[a]);return{pendingQuestions:i,handleAnswerPendingQuestion:c,handleDismissPendingQuestion:d,refetchPendingQuestions:a}}const Sl="CHECK OFF DEV NOTE:";function jN(t){if(typeof t.content=="string")return t.content;if(!Array.isArray(t.content))return"";const e=[];for(const n of t.content)n&&typeof n=="object"&&"type"in n&&n.type==="text"&&"text"in n&&typeof n.text=="string"&&e.push(n.text);return e.join(`
|
|
348
|
+
`)}function Cl(t){return t.replace(/[“”]/g,'"').replace(/^\s*[-*]\s+/,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^["'`]+/,"").replace(/["'`]+$/,"").replace(/\*\*/g,"").replace(/\s+/g," ").trim().toLowerCase()}function NN(t){const e=t.trim();if(e.length<2)return e;const n=e[0],r=e[e.length-1],o=[['"','"'],["“","”"],["'","'"],["`","`"]];for(const[a,i]of o)if(n===a&&r===i)return e.slice(1,-1).trim();return e}function SN(t){if(!t)return[];const e=[];for(const n of t.split(/\r?\n/)){const r=n.trim();if(!r)continue;const o=r.toUpperCase().indexOf(Sl);if(o===-1)continue;const a=NN(r.slice(o+Sl.length));a&&e.push(a)}return e}function CN(t){const{conversationId:e,combinedMessages:n,showToast:r}=t,o=u.useRef(new Set);u.useEffect(()=>{o.current.clear()},[e]),u.useEffect(()=>{if(!e||n.length===0)return;const a=new Map;for(const i of n){if(i.type!=="assistant")continue;const l=jN(i);if(!l)continue;const c=SN(l);for(const d of c){const p=Cl(d);if(!p)continue;const m=`${e}:${p}`;o.current.has(m)||a.set(m,{normalized:p})}}a.size!==0&&(async()=>{try{const{notes:i}=await H.getDevNotes();if(!Array.isArray(i)||i.length===0)return;const l=new Map;for(const h of i){const g=Cl(h.content);if(!g||h.status!=="pending")continue;const f=l.get(g);f?f.push(h):l.set(g,[h])}const c=[],d=new Set,p=new Set;for(const[h,g]of a.entries()){let x=l.get(g.normalized)?.find(b=>!p.has(b.id));if(!x){const y=Array.from(l.entries()).find(([v])=>v.includes(g.normalized)||g.normalized.includes(v));y&&(x=y[1].find(v=>!p.has(v.id)))}x&&(d.add(h),p.add(x.id),c.push(x))}if(c.length===0)return;await Promise.all(c.map(h=>H.updateDevNoteStatus(h.id,"done"))),d.forEach(h=>o.current.add(h));const m=c.length;r({title:`Marked ${m} dev note${m===1?"":"s"} done`,message:m===1?c[0].content:void 0,type:"success",duration:3500})}catch(i){console.error("Failed to auto-complete dev notes from CHECK OFF markers:",i)}})()},[n,e,r])}const EN=300;function TN(t){const{conversationId:e,queryClient:n}=t;u.useEffect(()=>{let r=null;const o=()=>{document.visibilityState==="visible"&&e&&(r=setTimeout(()=>{console.debug(`[DETAIL-TRACE] visibility-refresh invalidating details for ${e?.slice(0,12)}`),n.invalidateQueries({queryKey:ht.details(e)}),n.invalidateQueries({queryKey:vt.one(e)})},EN))};return document.addEventListener("visibilitychange",o),()=>{document.removeEventListener("visibilitychange",o),r&&clearTimeout(r)}},[e,n])}function IN(t){return!!t&&t.startsWith("conv-")}function AN(t){const{conversationId:e,conversationDetails:n,insights:r,navStartRef:o,navigationDebugEnabled:a}=t,i=u.useRef(null),l=u.useRef(null),c=u.useRef(new Map),d=typeof window<"u"&&window.localStorage.getItem("perf-debug")==="1",p=u.useCallback((m,h,g,f)=>{d&&g<32},[d]);return u.useEffect(()=>{if(!e)return;const m=`nav-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`;o.current={conversationId:e,time:performance.now(),traceId:m},i.current=null,l.current=null},[e,a,o]),u.useEffect(()=>{if(!e||!IN(e))return;let m=!1;const h=setTimeout(()=>{(async()=>{try{const g=await H.getConversationStatus(e);if(m||g.status!=="ongoing")return;const f=await H.getUnifiedConversation(e);if(m)return;const x=f.segments.slice().sort((w,N)=>w.sequenceNumber-N.sequenceNumber).at(-1);if(x?.status==="active")return;const b=Date.now(),y="session-switch-segment-status-mismatch",v=c.current.get(y);(v===void 0||b-v>=1e4)&&(c.current.set(y,b),mt({component:"ConversationView",event:y,severity:"warn",details:{conversationId:e.slice(0,8),conversationStatus:g.status,activeStreamingId:g.streamingId||null,latestSegmentId:x?.segmentId||null,latestSegmentProvider:x?.provider||null,latestSegmentStatus:x?.status||"missing"}}))}catch{if(m)return}})()},500);return()=>{m=!0,clearTimeout(h)}},[e]),u.useEffect(()=>{if(!e||!n||i.current===e)return;i.current=e;const m=o.current,h=m.conversationId===e?m.time:void 0;h&&Math.round(performance.now()-h),m.conversationId===e&&m.traceId},[n,e,o]),u.useEffect(()=>{if(!e||!r||l.current===e)return;l.current=e;const m=o.current.conversationId===e?o.current.time:void 0;m&&Math.round(performance.now()-m)},[e,r,o]),{onPerfRender:p}}function RN(t){return t instanceof Error?t.message:typeof t=="string"?t:"Unknown error"}function PN(t,e){const n=RN(e).trim()||"Unknown error";return/permission request timeout/i.test(n)||/did not respond/i.test(n)?"Claude session paused after a permission request timed out. Retry with TRUST/accept-edits mode, or respond to permissions sooner.":`Claude session failed: ${n}`}function MN(t){const{conversationId:e,conversationPausedReason:n,session:r,setSessionOptimisticOngoing:o,invalidateConversations:a,restoreDraftFromBackup:i,setSessionFailureError:l,nextStepsDismissedRef:c}=t;return{handleSendMessage:u.useCallback(async(p,m,h,g,f)=>{l(null),r.proposedNextSteps&&r.proposedNextSteps.length>0&&(c.current=!0,r.clearNextSteps()),e&&n&&H.unifiedUpdateConversation(e,{pausedReason:null});try{r.addOptimisticUserMessage(p),e&&o(e,"claude"),await r.sendMessage(p,h,g,f),a()}catch(x){console.error("[ConversationView] Send failed:",x),l(PN("claude",x)),i()}},[e,n,r,o,a,i,l,c])}}const El=1500,LN=3500;function _o(t){return new Promise(e=>setTimeout(e,t))}function ON(t){const{session:e,conversationId:n,setStopRequested:r}=t;return{handleStop:u.useCallback(async()=>{if(r(!0),!n){try{await e.stop()||(console.warn("[stop] Graceful stop failed, escalating to force-kill"),await e.forceKill())}catch(l){console.error("[stop] Stop/force-kill threw:",l)}r(!1);return}const a=async()=>{try{return(await H.getConversationStatus(n)).status}catch{return null}},i=l=>l===null||l==="completed"||l==="idle";try{await e.stop(),await _o(El);let l=await a();if(i(l)||(await _o(LN),l=await a()),!i(l)){console.warn("[stop] Server-side escalation timed out, sending force-kill",{conversationId:n,status:l});try{await H.unifiedForceKillConversation(n)}catch{}await _o(El),l=await a(),i(l)||console.error("[stop] Force-kill did not terminate session",{conversationId:n,status:l})}}catch(l){console.error("[stop] Unexpected error during stop sequence:",l)}r(!1)},[e,n,r])}}const DN=5e3,$N=["Load failed","Failed to fetch","NetworkError","network error","Connection lost"];function Tl(t){return t?$N.some(e=>t.includes(e)):!1}function zN(t){const{sessionError:e,sessionFailureError:n,clearSessionError:r,clearSessionFailureError:o}=t,a=u.useRef(null);u.useEffect(()=>{a.current&&(clearTimeout(a.current),a.current=null);const i=Tl(e),l=Tl(n);if(!(!i&&!l))return a.current=setTimeout(()=>{i&&r(),l&&o(),a.current=null},DN),()=>{a.current&&(clearTimeout(a.current),a.current=null)}},[e,n,r,o])}function FN(t,e){return t&&!e}const Il=2;function VN(t){return t.includes("Failed to fetch")||t.includes("Load failed")||t.includes("NetworkError")?"Connection lost — retrying…":t.includes("timeout")?"Session load timed out — retrying…":t}function BN({children:t}){const{agentColors:e}=oN(),n=u.useCallback(r=>e[r],[e]);return s.jsx(pg,{theme:"dark",resolveAgentColor:n,children:t})}function UN({sidebarOpen:t,onToggleSidebar:e}={}){const{conversationId:n}=zl(),r=n,o=$l(),a=Nt(),i=mn(),{isPro:l}=yn(),{showToast:c}=Fp();u.useEffect(()=>(r&&Ek({conversationId:r,sessionId:r}),()=>Tk()),[r]);const d=u.useMemo(()=>new URLSearchParams(o.search).get("debug")==="messages"||Fe.messages===!0,[o.search]),{status:p,connected:m,processAlive:h,error:g,messages:f,renderItems:x,childrenMessages:b,usage:y,hasBackgroundTasks:v,pendingMessages:w,actionTrace:N,send:S,stop:T,reconnect:C,fetchHistory:j}=Qj(r??null),{permissionRequest:E,answerPermission:A,answerPermissionWithPattern:L,answerPermissionWithPatterns:$}=rN(r),[oe,ne]=u.useState(new Set),[B,Q]=u.useState([]),[q,Z]=u.useState(null),[me,O]=u.useState([]),[W,ee]=u.useState(null),[z,re]=u.useState(null),se=p!=="idle",te=p==="idle",xe=p==="initializing",_e=p==="streaming",I=g??z,P=u.useCallback(()=>re(null),[]);u.useEffect(()=>{(p==="initializing"||p==="streaming")&&W===null&&ee(Date.now()),p==="idle"&&ee(null)},[p,W]);const de=f,X=u.useMemo(()=>{const ae={};for(const ve of de)if(Array.isArray(ve.content))for(const ke of ve.content){const Le=ke;Le.type==="tool_result"&&typeof Le.tool_use_id=="string"&&(ae[Le.tool_use_id]={status:"completed",result:typeof Le.content=="string"?Le.content:void 0,is_error:typeof Le.is_error=="boolean"?Le.is_error:void 0})}return ae},[de]),G=u.useCallback(async(ae,ve,ke,Le,Ur,gs)=>{try{if(m)await S(ae);else{const Jt=await fetch(`/api/harness/${r}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:ae,model:ve,permissionMode:ke})});if(!Jt.ok){const Im=await Jt.json().catch(()=>({error:"Start failed"}));throw new Error(Im.error||"Start failed")}C()}}catch(Jt){re(Jt instanceof Error?Jt.message:"Send failed")}},[r,m,S,C]),V=u.useCallback(async()=>{try{return await T(),!0}catch{return!1}},[T]),D=u.useCallback(async()=>{await T()},[T]),be=u.useCallback(ae=>{ne(ve=>{const ke=new Set(ve);return ke.has(ae)?ke.delete(ae):ke.add(ae),ke})},[]),Ce=u.useCallback(()=>Z(null),[]),je=u.useCallback(async ae=>{await G(ae)},[G]);u.useEffect(()=>{if(te&&me.length>0){const[ae,...ve]=me;O(ve),G(ae.sendContent)}},[te,me,G]);const Ee=u.useMemo(()=>({messages:de,isActive:se,isConnected:m,proposedNextSteps:q,clearNextSteps:Ce,addOptimisticUserMessage:ae=>{},sendMessage:G,enqueueMessage:je}),[de,se,m,q,Ce,G,je]),K=u.useMemo(()=>({stop:V,forceKill:D}),[V,D]),[fe]=u.useState("Conversation"),[M,Y]=u.useState(!1),[U,ie]=u.useState(null),[ye,he]=u.useState(!1),ze=u.useCallback(()=>ie(null),[]);zN({sessionError:I,sessionFailureError:U,clearSessionError:P,clearSessionFailureError:ze});const{insightsPanelOpen:Ne,setInsightsPanelOpen:Me,toggleInsightsPanel:nt}=wN(),Ye=t??!1,[Ct,ps]=u.useState(!1),[vn,ms]=u.useState(!1),[Vs,Lr]=u.useState([]),Or=u.useCallback(async ae=>{try{return(await H.listDirectory({path:ae||"",recursive:!1,respectGitignore:!0})).entries}catch(ve){return console.error("Failed to fetch file system entries:",ve),[]}},[]),Dr=u.useCallback(async ae=>{try{const ve=await H.getCommands(ae||""),ke=ve.commands.filter(Le=>Le.type==="custom").map(Le=>({name:Le.name,description:Le.description||"",argumentHint:Le.argumentHint}));return Lr(ke),ve.commands}catch(ve){return console.error("Failed to fetch commands:",ve),[]}},[]),{conversations:wn,pendingInsightsUpdates:Et,invalidateConversations:Bs,setSessionOptimisticOngoing:$r}=$s(),Je=u.useMemo(()=>r&&wn.find(ae=>ae.conversationId===r)||null,[wn,r]),rt=N2(r),Wt=u.useCallback(()=>{const ae=r?`claudia-draft-${r}`:"claudia-draft-home",ve=`${ae}-backup`;try{const ke=localStorage.getItem(ve);ke&&(localStorage.setItem(ae,ke),localStorage.removeItem(ve))}catch{}},[r]),_n=u.useRef(null),kn=u.useRef(!1),Kt=u.useRef(!1),hs=u.useRef({}),fs=u.useRef({}),ot=u.useRef(!1);u.useEffect(()=>{if(o.state)try{window.history.replaceState({},document.title)}catch{}},[o]),u.useEffect(()=>{kn.current=!1,Kt.current=!1},[r]);const F=u.useRef(rt.isOngoing);u.useEffect(()=>{const ae=F.current;F.current=rt.isOngoing,FN(ae,rt.isOngoing)&&r&&(console.debug(`[DETAIL-TRACE] completion-edge invalidating details for ${r?.slice(0,12)}`),i.invalidateQueries({queryKey:ht.details(r)}))},[rt.isOngoing,r,i]);const ue=u.useRef(r);u.useEffect(()=>{ue.current!==r&&(ue.current=r,he(!1),r&&(console.debug(`[DETAIL-TRACE] session-switch invalidating details for ${r?.slice(0,12)}`),i.invalidateQueries({queryKey:ht.details(r)}),i.invalidateQueries({queryKey:vt.one(r)})))},[r,i]);const Ae=50,Te=10,{data:Se,isLoading:Xe,error:it,isFetching:zr}=Mt({queryKey:ht.details(r||""),queryFn:()=>{const ae=hs.current.conversationId===r?hs.current.traceId:void 0;return console.debug(`[DETAIL-TRACE] queryFn executing for ${r?.slice(0,12)} limit=${Te} traceId=${ae?.slice(0,16)}`),H.getConversationDetails(r,{limit:Te,traceId:ae,timeout:2e4})},enabled:!!r,staleTime:3e4,refetchOnMount:!0,refetchOnWindowFocus:!1,retry:(ae,ve)=>{if(ae>=3||!(ve instanceof Error))return!1;const ke=ve.message,Le=ke.includes("not found"),Ur=ke.includes("Failed to fetch")||ke.includes("NetworkError")||ke.includes("Load failed"),gs=ke.includes("timeout");return Le||Ur||gs},retryDelay:ae=>Math.min(500*2**ae,3e3)});TN({conversationId:r,queryClient:i});const{data:Qt,isLoading:am}=Mt({queryKey:["insights",r],queryFn:()=>H.unifiedGetInsights(r,!0),enabled:!!r,staleTime:3e4,refetchOnMount:!0,refetchOnWindowFocus:!1}),{onPerfRender:Fr}=AN({conversationId:r,conversationDetails:Se,insights:Qt,navStartRef:hs,navigationDebugEnabled:Fe.navigation}),{pendingQuestions:ci,handleAnswerPendingQuestion:im,handleDismissPendingQuestion:cm}=kN({conversationId:r,isSessionIdle:te,reconnectToStream:C}),lm=u.useMemo(()=>Qt?{lastUpdateTime:Qt.patchedAt||Qt.computedAt||null}:void 0,[Qt]);u.useEffect(()=>{Se&&Se.sessionId===r&&(bN({conversationDetails:Se,currentProposedNextSteps:q,isSessionIdle:te,isDismissedThisSession:Kt.current,setProposedNextSteps:Z}),Se.mcpServers&&Se.mcpServers.length>0&&Q(Se.mcpServers),yN({hasInitiallyFocusedRef:kn,composerRef:_n}))},[Se,q]),_N({conversationSummary:Je,insights:Qt,conversationTitle:fe});const dm=u.useCallback(()=>{e?.()},[e]),{handleSendMessage:Vr}=MN({conversationId:r,conversationPausedReason:Je?.pausedReason,session:Ee,setSessionOptimisticOngoing:$r,invalidateConversations:Bs,restoreDraftFromBackup:Wt,setSessionFailureError:ie,nextStepsDismissedRef:Kt}),um=u.useCallback(ae=>{Kt.current=!0,Ce();const ve=Je?.permissionMode;Vr(ae,void 0,void 0,ve||void 0)},[Vr,Je?.permissionMode,Ce]),pm=u.useCallback(()=>{Kt.current=!0,Ce()},[Ce]),li=u.useCallback(async(ae,ve,ke)=>{if(!M){Y(!0);try{await A(ae,ve,ke)}catch(Le){console.error("Failed to send permission decision:",Le)}finally{Y(!1)}}},[M,A]),mm=u.useCallback(async(ae,ve,ke)=>{if(!M){Y(!0);try{await L(ae,ve,ke)}catch(Le){console.error(`Failed to add pattern to ${ke} allowlist:`,Le)}finally{Y(!1)}}},[M,L]),hm=u.useCallback(async(ae,ve,ke)=>{if(!M){Y(!0);try{await $(ae,ve,ke)}catch(Le){console.error(`Failed to add patterns to ${ke} allowlist:`,Le)}finally{Y(!1)}}},[M,$]),{handleStop:fm}=ON({session:K,conversationId:r,setStopRequested:he});u.useEffect(()=>{ie(null)},[r]);const di=u.useCallback(async ae=>{if(!r||ot.current)return;const ve=(fs.current[r]||0)+1;if(ve>Il)return;fs.current[r]=ve,ot.current=!0;const ke=hs.current;ke.conversationId===r&&ke.time&&Math.round(performance.now()-ke.time);try{await fN({sessionId:r,reconnectToStream:C}),await gN({queryClient:i,sessionId:r})}finally{ot.current=!1}},[r,m,C,i]),ui=!it&&Xe,gm=ui,Yt=u.useMemo(()=>pN(de),[de]);sN({conversationId:r??null,messages:Yt,actionTrace:N,connected:m,status:p});const{hasMoreMessages:xm,isLoadingMore:bm,jumpToMessageId:ym,setJumpToMessageId:vm,loadMoreMessages:wm,handleJumpToTurn:_m}=vN({conversationId:r,fetchHistory:j,initialMessageLimit:Ae});CN({conversationId:r,combinedMessages:Yt,showToast:c});const ut=se,pi=u.useRef(te);u.useEffect(()=>{const ae=pi.current;if(pi.current=te,!r&&ye){he(!1);return}!ut&&te&&!ae&&ye&&he(!1)},[r,ut,te,ye]);const Br=u.useRef(!1);u.useEffect(()=>{Br.current=!1},[r]),u.useEffect(()=>{Br.current||(Br.current=!0,console.debug(`[status:mount] ${r?.slice(0,12)}`,`alive=${h} busy=${ut}`,{"authoritative.status":rt.status,"authoritative.streamingId":rt.streamingId?.slice(0,8)??"-","authoritative.isFetching":rt.isFetching,"authoritative.isLoading":rt.isLoading,"authoritative.dataUpdatedAt":rt.dataUpdatedAt,harnessStatus:p,isActive:se,harnessConnected:m,"session.streamingId":"-"}))});const mi=u.useRef({isProviderBusy:ut,processAlive:h});u.useEffect(()=>{const ae=mi.current;(ae.isProviderBusy!==ut||ae.processAlive!==h)&&(console.debug(`[status:view] ${r?.slice(0,12)}`,`busy=${ut} (was ${ae.isProviderBusy})`,`alive=${h} (was ${ae.processAlive})`,{isActive:se,harnessConnected:m,harnessStatus:p,"authoritative.isOngoing":rt.isOngoing,"authoritative.isFetching":rt.isFetching}),mi.current={isProviderBusy:ut,processAlive:h})});const km=[...me];u.useEffect(()=>{r&&(fs.current[r]=0,ot.current=!1)},[r]),u.useEffect(()=>{if(!r)return;const ae=it instanceof Error&&it.message.includes("not found");if(it&&!(ae&&h)||(fs.current[r]||0)>=Il)return;const ke=ut,Le=Yt.length===0,gs=xN({hasActiveSignal:ke,noVisibleContent:Le,slowHydration:Xe||zr});if(!gs.shouldRecover)return;const Jt=setTimeout(()=>{di(gs.reason)},gs.delayMs);return()=>clearTimeout(Jt)},[r,it,Xe,zr,ut,h,Yt.length,di]);const jm=ut||h,Nm=it instanceof Error&&it.message.includes("not found"),Sm=it&&!(Nm&&jm)?VN(it.message):null,hi=I==="session_limit"||I==="init_timeout"||zr?null:U||I||Sm,Cm=E?s.jsx(vj,{permission:E,streamingId:void 0,workingDirectory:Je?.workingDirectory,onApprove:()=>li(E.id,"approve"),onApprovePattern:(ae,ve)=>mm(E.id,ae,ve),onApprovePatterns:(ae,ve)=>hm(E.id,ae,ve),onDeny:ae=>li(E.id,"deny",ae),isLoading:M}):null,fi=u.useRef(null);u.useEffect(()=>{if(I&&I!==fi.current){const ae=r?`claudia-draft-${r}-backup`:"claudia-draft-home-backup",ve=localStorage.getItem(ae);if(ve){const ke=r?`claudia-draft-${r}`:"claudia-draft-home";localStorage.setItem(ke,ve),localStorage.removeItem(ae)}}fi.current=I},[I,r]);const Em=u.useCallback(async()=>{r&&await H.resumeConversation(r,{message:"Approved. Proceed with the plan.",permissionMode:"bypassPermissions"})},[r]),Tm=u.useCallback(async()=>{r&&await H.resumeConversation(r,{message:"Plan rejected — please revise or take a different approach.",permissionMode:"plan"})},[r]);return s.jsx(u.Profiler,{id:"ConversationView",onRender:Fr,children:s.jsx(aN,{teamName:Je?.teamName??null,children:s.jsx(BN,{children:s.jsxs("div",{className:"h-full w-full flex flex-col bg-background relative overflow-hidden",role:"main","aria-label":"Conversation view",children:[s.jsx(sj,{sessionId:r,isArchived:Je?.archived||!1,isPinned:Je?.pinned||!1,subtitle:Je?{date:new Date(Je.createdAt).toLocaleDateString("en-US",{month:"short",day:"numeric"}),repo:Je.workingDirectory.split("/").pop()||"project"}:void 0,insightsPanelOpen:Ne,onToggleInsightsPanel:nt,crossSessionSidebarOpen:Ye,onToggleCrossSessionSidebar:dm,onOpenCrossSessionAnalysis:()=>ps(!0),onOpenFeedbackPanel:()=>ms(!0)}),hi&&s.jsx("div",{className:"bg-red-500/10 border-b border-red-500 text-red-600 dark:text-red-400 px-4 py-2 text-sm text-center animate-in slide-in-from-top duration-300",role:"alert",children:hi}),I==="init_timeout"&&s.jsx("div",{className:"bg-amber-500/10 border-b border-amber-500 text-amber-700 dark:text-amber-400 px-4 py-2 text-sm text-center animate-in slide-in-from-top duration-300",role:"alert",children:"Session initialization timed out — the conversation may be too large. Consider starting a fresh session."}),s.jsxs("div",{className:"flex-1 flex overflow-hidden relative",children:[Ct&&s.jsx("div",{className:"absolute inset-0 z-30 bg-background",children:s.jsx(Bp,{onClose:()=>ps(!1)})}),vn&&s.jsx("div",{className:"absolute inset-0 z-30 bg-background",children:s.jsx(hj,{onClose:()=>ms(!1),conversationId:r})}),s.jsxs("div",{className:"flex-1 flex flex-col min-w-0 relative",children:[s.jsxs(s.Fragment,{children:[s.jsx(u.Profiler,{id:"MessageList",onRender:Fr,children:s.jsx(rk,{sessionId:r,messages:ui&&Yt.length===0?[]:Yt,renderItems:x,toolResults:X,childrenMessages:b,expandedTasks:oe,onToggleTaskExpanded:be,isLoading:gm,isStreaming:_e,streamingProvider:"claude",pendingQuestion:ci.length>0?ci[0]:null,onAnswerPendingQuestion:im,onDismissPendingQuestion:cm,hasMore:xm,isLoadingMore:bm,onLoadMore:wm,branchLineage:Se?.sessionInfo?.branched_from_session_id?{parentSessionId:Se.sessionInfo.branched_from_session_id,atTurn:Se.sessionInfo.branched_at_turn||0,branchPointMessageId:Se.branchPointMessageId}:void 0,onNavigateToSession:ae=>a(`/c/${ae}`),sessionStartTime:W,isSwitchingProvider:!1,switchingToProvider:"claude",jumpToMessageId:ym,onJumpHandled:()=>vm(null),inlinePermissionPrompt:Cm,onPlanApprove:Em,onPlanReject:Tm,actionTrace:N})}),d&&s.jsx(lN,{messages:Yt,toolResults:X,childrenMessages:b,sessionId:r})]}),Je?.importedAt?s.jsx("div",{className:"flex-shrink-0 z-10 w-full flex justify-center py-3",style:{paddingBottom:"calc(var(--lattice-composer-dock-bottom-gap) + var(--lattice-safe-area-bottom))"},children:s.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 bg-cyan-500/10 border border-cyan-500/30 rounded-sm",children:[s.jsx(Kn,{size:14,className:"text-cyan-400"}),s.jsx("span",{className:"text-cyan-400 font-display text-xs uppercase tracking-wider",children:"Imported session — read-only"})]})}):s.jsxs("div",{className:"flex-shrink-0 bg-white/80 dark:bg-zinc-900/80 backdrop-blur-sm z-10 w-full flex flex-col items-center pt-4",style:{paddingBottom:"calc(var(--app-composer-dock-bottom-gap) + var(--app-safe-area-bottom))"},children:[q&&q.length>0&&te&&s.jsx("div",{className:"w-full max-w-5xl px-4 mb-2",children:s.jsx(pk,{steps:q,onSelect:um,onDismiss:pm})}),w.length>0&&s.jsx("div",{className:"w-full max-w-5xl px-4 mb-2 flex flex-col gap-1.5",children:w.map(ae=>s.jsx("div",{"data-testid":"pending-message",className:"flex justify-end",children:s.jsx("div",{className:"max-w-[80%] min-w-[100px]",children:s.jsxs("div",{className:"border border-cyan-500/15 rounded-lg overflow-hidden bg-cyan-500/3 w-full opacity-60",children:[s.jsx("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-cyan-500/8",children:s.jsx("span",{className:"text-[11px] text-zinc-500 font-medium",children:"User"})}),s.jsx("div",{className:"px-3 py-2 text-[13px] leading-relaxed text-foreground/40 whitespace-pre-wrap break-words",children:ae.text})]})})},`pending-${ae.inputEvent.seq}`))}),s.jsx("div",{className:"w-full max-w-5xl px-4",children:s.jsx(pp,{ref:_n,core:{sessionId:r,onSubmit:Vr,isLoading:m||M,placeholder:""},features:{enableFileAutocomplete:!0,showSmartMenu:!0},workingDirectory:Je?.workingDirectory,permissionConfig:{onStop:fm,onInterrupt:D},skills:Vs,mcpServers:B,runtimeConfig:{isSessionActive:ut,isSessionConnected:h||rt.isIdle,isStopRequested:ye,isInitializing:xe,hasBackgroundTasks:v,sessionStartTime:W??void 0,onFetchFileSystem:Or,onFetchCommands:Dr,queuedMessages:km,sessionUsage:y}})})]})]}),s.jsx(u.Profiler,{id:"InsightsPanel",onRender:Fr,children:s.jsx(aj,{insights:Qt??null,isLoading:am,isOpen:l&&Ne,onClose:()=>{Me(!1),localStorage.setItem("insightsPanelOpen","false")},syncState:lm,isPendingInsightsUpdate:r?Et.has(r):!1,sessionId:r,onJumpToTurn:_m,onBranch:async ae=>{await Bs(),a(`/c/${ae}`)}})})]})]})})})})}function GN(){return`pending-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function Wp({sidebarOpen:t,onToggleSidebar:e}){const[n,r]=xa(),o=Nt(),{serverConfig:a}=zs(),{addOptimisticSession:i,addPendingLaunch:l,removePendingLaunch:c,invalidateConversations:d}=$s(),p="main",[m,h]=u.useState(!1),[g,f]=u.useState(!1),[x,b]=u.useState(0),[y,v]=u.useState(null),[w,N]=u.useState(!0);n.get("provider");const S=n.get("mode"),T="claude",[C,j]=u.useState(T);u.useEffect(()=>{j(T)},[T]);const E=pn({explicit:S??void 0,fallback:a?.defaultPermissionMode,provider:T}),A=a?.defaultWorkingDirectory||a?.cwd||"~",L=u.useCallback(async()=>{try{const[Q,q]=await Promise.all([H.getDevNotes(),H.getPendingRecommendations()]);b(Q.notes.length+q.recommendations.length),v(null)}catch(Q){console.error("Failed to refresh new-session header state:",Q)}finally{N(!1)}},[]);u.useEffect(()=>{L();const Q=window.setInterval(()=>{L()},15e3);return()=>window.clearInterval(Q)},[L]),u.useCallback(Q=>{j(Q);const q=new URLSearchParams(n);q.set("provider",Q),r(q,{replace:!0})},[n,r]);const $=u.useCallback(()=>{f(!1),L()},[L]),oe=u.useCallback(async(Q,q,Z,me)=>{if(Q.length===0&&q.length===0)return;const W=await Lp(H,Q,q,A,{workspace:p,provider:Z||"claude",model:a?.defaultModel,permissionMode:me||E});return W?(await d(),{sessionId:W.conversationId}):null},[d,E,a?.defaultModel,A]),ne=u.useCallback(()=>{const Q=!!y?.readyToAnalyze;o(Q?"/analysis/cross-session?run=1":"/analysis/cross-session")},[y?.readyToAnalyze,o]),B=u.useCallback(async(Q,q,Z,me,O,W)=>{if(!Q.trim()||m)return;h(!0);const ee=W||C,z=a?.defaultModel||"claude-opus-4-7",re=E,se=GN();l({tempId:se,workingDirectory:q||A,initialPrompt:Q,model:z,permissionMode:re,workspace:p,provider:ee});try{const te=await H.createConversation({provider:ee,message:Q,workingDirectory:q||A,model:z,permissionMode:re,workspace:p});try{localStorage.setItem(`lattice:last-provider:${te.conversationId}`,te.provider)}catch{}i({conversationId:te.conversationId,streamingId:te.streamingId,workingDirectory:te.cwd,model:te.model,permissionMode:te.permissionMode||re,initialPrompt:Q,workspace:p,provider:te.provider}),ca(te.conversationId,"client.navigate_to_conversation"),o(`/c/${te.conversationId}`),d()}catch(te){console.error("Failed to create session:",te),alert(`Failed to create session: ${te instanceof Error?te.message:"Unknown error"}`)}finally{c(se),h(!1)}},[m,C,E,A,p,a,i,l,c,d,o]);return s.jsx(Ot,{children:s.jsxs("div",{className:`flex-1 min-w-0 flex flex-col h-full relative overflow-hidden ${t?"hidden md:flex":""}`,children:[s.jsxs("div",{className:"flex justify-between items-center gap-3 px-4 py-3 border-b border-border/50 bg-background transition-colors relative overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 ui-grid-overlay pointer-events-none"}),s.jsxs("div",{className:"relative flex items-center gap-2 sm:gap-3 min-w-0",children:[!t&&s.jsx("button",{onClick:e,"aria-label":"Open sessions sidebar",className:"p-1.5 ui-icon-btn ui-icon-btn--cool",children:s.jsx(Wl,{size:18})}),s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(hp,{size:28,interactive:!0,colorScheme:"gradient"}),s.jsx("span",{className:"text-base font-display font-medium lowercase tracking-widest text-white",children:"lattice"}),s.jsx("span",{className:"hidden lg:inline font-mono text-[10px] text-muted-foreground/30 select-none",children:"bfe47eb5"})]}),s.jsx("span",{className:"hidden md:block h-4 w-px bg-border/20 shrink-0"}),s.jsx("span",{className:"hidden sm:inline text-[10px] font-display font-bold uppercase tracking-wider text-muted-foreground/60",children:"New Session"})]}),s.jsxs("div",{className:"relative flex items-center gap-2 flex-shrink-0",children:[s.jsx(ha,{status:y,isLoading:w,onClick:ne}),s.jsx($p,{count:x,onClick:()=>f(!0)})]})]}),s.jsxs("div",{className:"flex-1 flex flex-col justify-end",children:[s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsxs("div",{className:"flex flex-col items-center gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(as,{size:14,className:"text-cyan-400/40"}),s.jsx("span",{className:"text-sm font-display font-bold uppercase tracking-wider text-muted-foreground/35",children:"Claude"})]}),s.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground/20",children:[s.jsx("span",{className:"text-[10px] font-mono",children:"Type a message to start"}),s.jsx("span",{className:"text-[9px] font-mono px-1 py-0.5 border border-border/30 rounded-sm bg-background/40",children:"⏎"})]})]})}),s.jsx("div",{className:"flex-shrink-0 bg-white/80 dark:bg-zinc-900/80 backdrop-blur-sm z-10 w-full flex flex-col items-center pt-4",style:{paddingBottom:"calc(var(--app-composer-dock-bottom-gap) + var(--app-safe-area-bottom))"},children:s.jsx("div",{className:"w-full max-w-5xl px-4",children:s.jsx(pp,{core:{onSubmit:B,isLoading:m,disabled:m,placeholder:""},features:{enableFileAutocomplete:!0,showSmartMenu:!0},workingDirectory:A,runtimeConfig:{isInitializing:m}})})})]}),s.jsx(Dp,{isOpen:g,onClose:$,onLaunchSession:oe,defaultProvider:"claude",defaultPermissionMode:E,initialProvider:C,initialPermissionMode:E})]})})}const Al="app-favicon",Kp="/favicon.png",HN="/favicon-attention.svg",Qp=5e3;function Yp(t){return t.endsWith(".png")?"image/png":"image/svg+xml"}const Jp=["attention-favicon"];function qN(){const t=document.getElementById(Al);if(t instanceof HTMLLinkElement)return t;const e=document.createElement("link");return e.id=Al,e.rel="icon",e.type=Yp(Kp),document.head.appendChild(e),e}function Rl(t){if(typeof document>"u")return;const e=qN(),n=t?HN:Kp;e.rel="icon",e.type=Yp(n),e.href=n}async function Xp(){const[t,e]=await Promise.all([H.getPermissions({status:"pending"}),H.getPendingQuestions()]),n={};for(const r of t.permissions){const o=r.conversationId||r.sessionId;o&&(n[o]=(n[o]||0)+1)}for(const r of e.questions){const o=r.conversationId||r.sessionId;o&&(n[o]=(n[o]||0)+1)}return{permissionCount:t.permissions.length,questionCount:e.questions.length,sessionAttention:n}}function WN(){const{data:t}=Mt({queryKey:Jp,queryFn:Xp,staleTime:2e3,refetchInterval:Qp,refetchIntervalInBackground:!1}),e=(t?.permissionCount||0)>0||(t?.questionCount||0)>0;return u.useEffect(()=>(Rl(e),()=>{Rl(!1)}),[e]),null}function KN(t){const{data:e}=Mt({queryKey:Jp,queryFn:Xp,staleTime:2e3,refetchInterval:Qp,refetchIntervalInBackground:!1});return!e||!t?!1:(e.sessionAttention[t]||0)>0}function zn({children:t,className:e=""}){return s.jsx("span",{className:`text-[7px] px-1 py-0.5 rounded-sm border font-bold uppercase tracking-wider backdrop-blur-sm ${e}`,children:t})}function QN(t){const e=Date.now()-new Date(t).getTime(),n=Math.floor(e/1e3),r=Math.floor(n/60),o=Math.floor(r/60);return n<10?"now":n<60?`${n}s`:r<60?`${r}m`:o<24?`${o}h`:`${Math.floor(o/24)}d`}const YN=["claude"];function JN(t){const e=new Set(t.providersUsed??[]);return e.add(t.latestProvider),YN.filter(n=>e.has(n))}function XN(t){return t.activeProvider??t.latestProvider}const ZN=encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 80 80" fill="none">
|
|
349
349
|
<path d="M0 20h80M0 40h80M0 60h80M20 0v80M40 0v80M60 0v80" stroke="rgba(255,255,255,0.18)" stroke-width="1"/>
|
|
350
|
-
</svg>`);function eS({identityImage:t,isCurrent:e,isPending:n}){const r=!!t,o=r?`url(data:image/jpeg;base64,${t})`:"linear-gradient(135deg, rgba(56,189,248,0.25), rgba(59,130,246,0.05))",a=r?"":`, url("data:image/svg+xml,${ZN}")`;return s.jsxs("div",{className:`relative h-11 w-full rounded-sm border border-border/20 overflow-hidden${n&&!r?" animate-pulse":""}`,style:{boxShadow:e?"0 0 10px rgba(34,211,238,0.12)":"0 0 6px rgba(148,163,184,0.08)"},children:[s.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[linear-gradient(rgba(0,255,255,0.04)_1px,transparent_1px),linear-gradient(90deg,rgba(0,255,255,0.04)_1px,transparent_1px)] bg-[size:14px_14px] z-[1]"}),s.jsx("div",{className:"h-full w-full",style:{backgroundImage:`${o}${a}`,backgroundSize:r?"cover":"cover, 80px 80px",backgroundPosition:"center"}})]})}function gt({conversation:t,teamStatus:e,isCurrent:n,onClick:r,compact:o=!1,onRestore:a,recentlyCompleted:i=!1,onRenameSessionName:l,isRenamingSessionName:c=!1,onRegenerateSessionName:d,isRegeneratingSessionName:p=!1,onPin:m}){const{isPro:h}=yn(),g=KN(t.conversationId),f=h?t.insights:void 0,x=f?.context?.mission||f?.purpose||t.initialPrompt||"New session",b=t.customName?.trim()||"",y=b||x,v=!b&&!f?.context?.mission&&!f?.purpose&&!!t.initialPrompt,w=f?.purpose,[N,S]=
|
|
350
|
+
</svg>`);function eS({identityImage:t,isCurrent:e,isPending:n}){const r=!!t,o=r?`url(data:image/jpeg;base64,${t})`:"linear-gradient(135deg, rgba(56,189,248,0.25), rgba(59,130,246,0.05))",a=r?"":`, url("data:image/svg+xml,${ZN}")`;return s.jsxs("div",{className:`relative h-11 w-full rounded-sm border border-border/20 overflow-hidden${n&&!r?" animate-pulse":""}`,style:{boxShadow:e?"0 0 10px rgba(34,211,238,0.12)":"0 0 6px rgba(148,163,184,0.08)"},children:[s.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[linear-gradient(rgba(0,255,255,0.04)_1px,transparent_1px),linear-gradient(90deg,rgba(0,255,255,0.04)_1px,transparent_1px)] bg-[size:14px_14px] z-[1]"}),s.jsx("div",{className:"h-full w-full",style:{backgroundImage:`${o}${a}`,backgroundSize:r?"cover":"cover, 80px 80px",backgroundPosition:"center"}})]})}function gt({conversation:t,teamStatus:e,isCurrent:n,onClick:r,compact:o=!1,onRestore:a,recentlyCompleted:i=!1,onRenameSessionName:l,isRenamingSessionName:c=!1,onRegenerateSessionName:d,isRegeneratingSessionName:p=!1,onPin:m}){const{isPro:h}=yn(),g=KN(t.conversationId),f=h?t.insights:void 0,x=f?.context?.mission||f?.purpose||t.initialPrompt||"New session",b=t.customName?.trim()||"",y=b||x,v=!b&&!f?.context?.mission&&!f?.purpose&&!!t.initialPrompt,w=f?.purpose,[N,S]=Ie.useState(!1),[T,C]=Ie.useState(y),j=Ie.useRef(T);j.current=T;const E=Ie.useRef(null),A=Ie.useRef(c),L=Ie.useRef(!1),$=Ie.useCallback(()=>{const O=E.current;if(!O)return;O.style.height="0px";const z=Math.min(Math.max(O.scrollHeight,42),128);O.style.height=`${z}px`},[]);Ie.useEffect(()=>{N||C(y)},[N,y]),Ie.useEffect(()=>{!N||!E.current||(E.current.focus(),E.current.select(),$())},[$,N]),Ie.useEffect(()=>{N&&$()},[$,N,T]),Ie.useEffect(()=>{A.current&&!c&&N&&S(!1),A.current=c},[N,c]);const oe=Ie.useCallback(async()=>{if(!l||c||L.current)return;const O=j.current.trim();if(!O){C(y),S(!1);return}if(O===y){S(!1);return}L.current=!0,S(!1);try{await l(t,O)}catch{}finally{L.current=!1}},[t,l,y,c]),ne=h&&t.identityImage||void 0,B=JN(t),Q=XN(t),q=!!(!t.importedAt&&(f?.context?.scope||f?.theme||f?.tags?.complexity&&f.tags.complexity!=="routine")),Z=!!(!N&&r),me=Ie.useCallback(O=>{!Z||!r||(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),r())},[Z,r]);return o?s.jsxs("div",{className:`
|
|
351
351
|
flex items-center gap-4 p-4 rounded-sm
|
|
352
352
|
bg-card/30 backdrop-blur-sm
|
|
353
353
|
border border-rose-500/20
|
|
354
354
|
hover:border-rose-500/40
|
|
355
355
|
transition-all duration-100
|
|
356
|
-
`,children:[h&&(ne?s.jsx("div",{className:"w-16 h-12 rounded-sm flex-shrink-0",style:{backgroundImage:`url(data:image/jpeg;base64,${ne})`,backgroundSize:"cover",backgroundPosition:"center"}}):s.jsx("div",{className:"w-16 h-12 rounded-sm flex-shrink-0 bg-gradient-to-r from-muted/10 via-muted/20 to-muted/10"})),s.jsxs("div",{className:"flex-1 min-w-0 font-display",children:[s.jsx(hn,{to:`/c/${t.conversationId}`,className:"block group",children:s.jsx("h3",{className:"text-sm font-bold text-foreground/90 group-hover:text-rose-400 truncate transition-colors",children:b||f?.purpose||t.conversationId.slice(0,8)})}),s.jsxs("div",{className:"flex items-center gap-3 mt-2 text-[10px] text-muted-foreground/40",children:[s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Lh,{size:10}),QN(t.updatedAt||t.createdAt)]}),t.workingDirectory&&s.jsxs(Ke,{children:[s.jsx(Qe,{asChild:!0,children:s.jsx("span",{className:"truncate max-w-[200px]",children:t.workingDirectory.split("/").slice(-2).join("/")})}),s.jsx(qe,{side:"top",sideOffset:6,children:t.workingDirectory})]})]})]}),a&&s.jsxs("button",{onClick:
|
|
356
|
+
`,children:[h&&(ne?s.jsx("div",{className:"w-16 h-12 rounded-sm flex-shrink-0",style:{backgroundImage:`url(data:image/jpeg;base64,${ne})`,backgroundSize:"cover",backgroundPosition:"center"}}):s.jsx("div",{className:"w-16 h-12 rounded-sm flex-shrink-0 bg-gradient-to-r from-muted/10 via-muted/20 to-muted/10"})),s.jsxs("div",{className:"flex-1 min-w-0 font-display",children:[s.jsx(hn,{to:`/c/${t.conversationId}`,className:"block group",children:s.jsx("h3",{className:"text-sm font-bold text-foreground/90 group-hover:text-rose-400 truncate transition-colors",children:b||f?.purpose||t.conversationId.slice(0,8)})}),s.jsxs("div",{className:"flex items-center gap-3 mt-2 text-[10px] text-muted-foreground/40",children:[s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Lh,{size:10}),QN(t.updatedAt||t.createdAt)]}),t.workingDirectory&&s.jsxs(Ke,{children:[s.jsx(Qe,{asChild:!0,children:s.jsx("span",{className:"truncate max-w-[200px]",children:t.workingDirectory.split("/").slice(-2).join("/")})}),s.jsx(qe,{side:"top",sideOffset:6,children:t.workingDirectory})]})]})]}),a&&s.jsxs("button",{onClick:O=>{O.stopPropagation(),a()},className:`
|
|
357
357
|
flex items-center gap-1.5 px-3 py-1.5 rounded-sm
|
|
358
358
|
text-[10px] font-display font-bold uppercase tracking-wider
|
|
359
359
|
text-muted-foreground hover:text-emerald-400
|
|
@@ -361,8 +361,8 @@ Be concise. The developer will read this alongside the user's bug report.`}funct
|
|
|
361
361
|
hover:bg-emerald-500/5
|
|
362
362
|
hover:shadow-[1px_1px_0_rgba(16,185,129,0.3)]
|
|
363
363
|
transition-all duration-100
|
|
364
|
-
`,children:[s.jsx(wa,{size:10}),"Restore"]})]}):s.jsxs("div",{"data-testid":`session-${t.conversationId}`,className:`relative group transition-all cursor-pointer rounded-sm border overflow-hidden ${n?"border-cyan-500/50 bg-cyan-500/[0.03] shadow-[0_0_15px_rgba(34,211,238,0.15)]":"border-border/25 bg-background/20 hover:border-cyan-500/35 hover:bg-background/35 hover:shadow-[2px_2px_0_rgba(0,255,255,0.2)]"}`,onClick:
|
|
365
|
-
`);v=S.pop()||"";for(const T of S)if(T.startsWith("data: "))try{const C=Fs(T.slice(6));if(l(C.message),C.error){a("error");return}if(C.stage==="restarting"){a("restarting"),setTimeout(m,3e3);return}}catch{}}}catch{a("error"),l("Connection lost during upgrade")}})()},[m]);if(!t||n)return null;const g=o!=="idle"&&o!=="error",f=o==="done";return s.jsx("div",{className:"relative border-b border-emerald-500/15 bg-gradient-to-r from-emerald-500/[0.04] via-transparent to-emerald-500/[0.02] px-3 py-2 animate-ui-in",children:s.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o==="error"?s.jsx(kt,{size:13,className:"text-amber-400/70 shrink-0"}):f?s.jsx(Oe,{size:13,className:"text-emerald-400/70 shrink-0"}):g?s.jsx(Ae,{size:13,className:"text-emerald-400/70 shrink-0 animate-spin"}):s.jsx(Eh,{size:13,className:"text-emerald-400/70 shrink-0"}),g||f||o==="error"?s.jsx("span",{className:"text-[10px] text-muted-foreground/60 truncate",children:i}):s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"text-[10px] font-display font-bold text-emerald-400/70 uppercase tracking-wider shrink-0",children:["v",t.latest]}),s.jsx("span",{className:"text-[10px] text-muted-foreground/50 truncate",children:"available"})]})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[o==="idle"&&s.jsxs(s.Fragment,{children:[s.jsxs(Ke,{children:[s.jsx(Qe,{asChild:!0,children:s.jsx("button",{onClick:h,className:"text-[9px] font-display font-bold uppercase tracking-wider px-2 py-0.5 rounded-sm border border-emerald-500/20 bg-emerald-500/5 text-emerald-400/60 hover:text-emerald-300 hover:border-emerald-500/30 hover:bg-emerald-500/10 hover:shadow-[1px_1px_0_rgba(52,211,153,0.2)] hover:translate-x-[-0.5px] hover:translate-y-[-0.5px] transition-all duration-100 cursor-pointer",children:"Upgrade"})}),s.jsx(qe,{children:s.jsx("span",{className:"font-mono text-[10px]",children:"npm update -g lattice-orchestrator"})})]}),s.jsx("button",{onClick:p,className:"p-0.5 rounded-sm text-muted-foreground/30 hover:text-muted-foreground/60 transition-colors duration-100 cursor-pointer","aria-label":"Dismiss update notice",children:s.jsx(Be,{size:11})})]}),o==="error"&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>{a("idle"),l("")},className:"text-[9px] font-display font-bold uppercase tracking-wider px-2 py-0.5 rounded-sm border border-amber-500/20 bg-amber-500/5 text-amber-400/60 hover:text-amber-300 hover:border-amber-500/30 transition-all duration-100 cursor-pointer",children:"Retry"}),s.jsx("button",{onClick:p,className:"p-0.5 rounded-sm text-muted-foreground/30 hover:text-muted-foreground/60 transition-colors duration-100 cursor-pointer","aria-label":"Dismiss",children:s.jsx(Be,{size:11})})]})]})]})})}function sS(t){const e=Date.now()-new Date(t).getTime(),n=Math.floor(e/1e3),r=Math.floor(n/60),o=Math.floor(r/60);return n<10?"now":n<60?`${n}s`:r<60?`${r}m`:o<24?`${o}h`:`${Math.floor(o/24)}d`}function nS(t,e){const n=e?t.insights:void 0,r=t.customName?.trim(),o=t.initialPrompt?.trim();return r||n?.context?.mission||n?.purpose||o||t.conversationId.slice(0,8)}function Ml({archivedSessions:t,currentSessionId:e,isLoading:n,onSelectSession:r,onRestoreSession:o}){const{isPro:a}=yn(),[i,l]=u.useState(null),c=u.useCallback(async p=>{if(!i){l(p);try{await o(p)}catch(m){console.error("Failed to restore archived session:",m)}finally{l(null)}}},[o,i]),d=u.useMemo(()=>t.map(p=>{const m=nS(p,a),h=p.conversationId===e,g=i===p.conversationId;return s.jsxs("div",{className:`group relative rounded-sm border transition-all duration-100 ${h?"border-stone-400/35 bg-stone-500/[0.08]":"border-border/20 bg-background/20 hover:border-stone-400/30 hover:bg-stone-500/[0.04]"}`,children:[s.jsx("button",{onClick:()=>r(p.conversationId),className:"w-full px-2.5 py-2 text-left cursor-pointer",type:"button",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Oe,{size:11,className:"mt-0.5 shrink-0 text-emerald-400/70"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"line-clamp-2 text-[11px] leading-snug text-foreground/70",children:m}),s.jsx("p",{className:"mt-1 text-[9px] uppercase tracking-wider text-muted-foreground/45",children:sS(p.updatedAt)})]})]})}),s.jsxs("button",{type:"button",onClick:f=>{f.stopPropagation(),c(p.conversationId)},disabled:!!i,className:`absolute right-1.5 top-1.5 flex items-center gap-1 rounded-sm border px-1.5 py-1 text-[9px] font-display font-bold uppercase tracking-wider transition-all duration-100 ${g?"border-emerald-400/40 bg-emerald-500/10 text-emerald-300 opacity-100":"border-border/20 bg-background/70 text-muted-foreground/70 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 hover:border-emerald-400/35 hover:bg-emerald-500/10 hover:text-emerald-300"} ${g?"pointer-events-auto":"pointer-events-none group-hover:pointer-events-auto group-focus-within:pointer-events-auto"}`,"aria-label":`Restore ${m}`,children:[g?s.jsx(Ae,{size:10,className:"animate-spin"}):s.jsx(wa,{size:10}),s.jsx("span",{children:"Restore"})]})]},p.conversationId)}),[t,e,c,a,i,r]);return n?s.jsx("div",{className:"space-y-1.5 py-1",children:["archived-skeleton-1","archived-skeleton-2","archived-skeleton-3"].map(p=>s.jsx("div",{className:"h-12 animate-pulse rounded-sm border border-border/20 bg-background/20"},p))}):t.length===0?s.jsx("div",{className:"rounded-sm border border-dashed border-border/25 bg-background/15 px-2.5 py-2 text-[10px] uppercase tracking-wider text-muted-foreground/45",children:"No archived sessions"}):s.jsx("div",{className:"space-y-1.5",children:d})}const Ll=["blue","green","yellow","purple"];function rS(t){if(!t||typeof t!="object")return!1;const e=t;return typeof e.type!="string"||typeof e.teamName!="string"?!1:e.type==="team-updated"||e.type==="team-removed"||e.type==="team-inbox-update"}function oS(t,e){if(e.agentCompletions?.find(o=>o.agentName===t)?.deliveredToLead)return"completed";const r=e.tasks.pending+e.tasks.in_progress+e.tasks.completed;return r>0&&e.tasks.completed>=r?"completed":e.tasks.in_progress>0||r>0&&e.tasks.pending>0?"running":"idle"}function aS(t){const e=new Map;for(const d of t.inboxSummaries||[])e.set(d.agentName,{messageCount:d.messageCount,unreadCount:d.unreadCount,latestTimestamp:d.latestTimestamp});const n=t.config.members.filter(d=>d.agentType!=="team-lead").map((d,p)=>{const m=e.get(d.name),h=oS(d.name,t);return{agentName:d.name,color:d.color||Ll[p%Ll.length],status:h,messageCount:m?.messageCount??0,unreadCount:m?.unreadCount??0,latestTimestamp:m?.latestTimestamp??null}}),r=n.reduce((d,p)=>(d[p.status]+=1,d),{idle:0,running:0,completed:0}),o=t.agentCompletions?.filter(d=>d.deliveredToLead).length??0,a=n.length,i=t.tasks.pending+t.tasks.in_progress+t.tasks.completed,l=t.tasks.completed;let c;return o>0&&a>0?c=Math.min(100,Math.round(o/a*100)):i>0?c=Math.min(100,Math.round(l/i*100)):c=0,{teamName:t.teamName,leadSessionId:t.leadSessionId,memberCount:t.memberCount,tasks:t.tasks,progressPct:c,agents:n,counts:r,updatedAt:t.timestamp}}function iS(t){const[e,n]=u.useState({}),r=u.useRef(!0),o=u.useRef(new Map),a=u.useMemo(()=>{const l=new Set;for(const c of t){const d=c.teamName?.trim();d&&l.add(d)}return Array.from(l)},[t]),i=u.useCallback(async l=>{const c=o.current.get(l)||{inFlight:!1,pending:!1};if(c.inFlight){c.pending=!0,o.current.set(l,c);return}c.inFlight=!0,c.pending=!1,o.current.set(l,c);try{const d=await G.getTeamInfo(l);if(!r.current)return;const p=aS(d);n(m=>({...m,[l]:p}))}catch{if(!r.current)return}finally{const d=o.current.get(l);d&&(d.pending?(d.pending=!1,d.inFlight=!1,o.current.set(l,d),i(l)):(d.inFlight=!1,o.current.set(l,d)))}},[]);return u.useEffect(()=>(r.current=!0,()=>{r.current=!1}),[]),u.useEffect(()=>{const l=new Set(a);n(c=>{const d={};for(const[p,m]of Object.entries(c))l.has(p)&&(d[p]=m);return d});for(const c of a)i(c)},[a,i]),Pt({type:"activity"},l=>{if(rS(l)){if(l.type==="team-removed"){n(c=>{if(!(l.teamName in c))return c;const d={...c};return delete d[l.teamName],d});return}i(l.teamName)}}),{teamStatuses:e}}const cS=1440*60*1e3;function Zp(t){const e=Date.now(),n=[],r=[],o=[],a=[],i=[],l=[];for(const c of t)c.status==="pending"?n.push(c):c.importedAt?a.push(c):c.pausedReason?o.push(c):c.status==="ongoing"?r.push(c):e-new Date(c.updatedAt).getTime()<cS?i.push(c):l.push(c);return{starting:n,active:r,paused:o,imported:a,recent:i,older:l}}function em(t){const e=new Map,n=r=>{const o=r.insights?.context?.project?.trim(),a=r.insights?.context?.area?.trim(),i=o||"",l=a||"",c=new Set(["claudia","lattice","lattice orchestrator"]);return i&&l?c.has(i.toLowerCase())?l:i.toLowerCase()!==l.toLowerCase()?`${i} / ${l}`:i:i||l||r.workingDirectory?.split("/").filter(Boolean).pop()||"Ungrouped"};for(const r of t){const o=n(r);e.has(o)||e.set(o,[]),e.get(o).push(r)}return Array.from(e.entries()).sort((r,o)=>{if(r[0]==="Ungrouped")return 1;if(o[0]==="Ungrouped")return-1;const a=Math.max(...r[1].map(l=>new Date(l.updatedAt).getTime()));return Math.max(...o[1].map(l=>new Date(l.updatedAt).getTime()))-a})}function tm(t){const e=new Map;for(const n of t){const r=n.teamName?.trim()||"No Team";e.has(r)||e.set(r,[]),e.get(r).push(n)}return Array.from(e.entries()).sort((n,r)=>{if(n[0]==="No Team")return 1;if(r[0]==="No Team")return-1;const o=Math.max(...n[1].map(i=>new Date(i.updatedAt).getTime()));return Math.max(...r[1].map(i=>new Date(i.updatedAt).getTime()))-o})}function lS(t,e){const n=t.filter(a=>a.pinned),r=t.filter(a=>!a.pinned),o=[];for(const a of n)o.push(a.conversationId);if(e==="flat")for(const a of r)o.push(a.conversationId);else if(e==="relevance"){const a=Zp(r);for(const i of[a.starting,a.active,a.recent,a.paused,a.imported,a.older])for(const l of i)o.push(l.conversationId)}else if(e==="project"){const a=em(r);for(const[,i]of a)for(const l of i)o.push(l.conversationId)}else if(e==="team"){const a=tm(r);for(const[,i]of a)for(const l of i)o.push(l.conversationId)}return o}const ko="claudia-last-permission-mode",dS="claudia-last-new-session-provider";function uS({onNew:t,isLoading:e,defaultPermissionMode:n}){const r=n==="acceptEdits"?"acceptEdits":n==="bypassPermissions"?"bypassPermissions":"default",o=()=>{const m=localStorage.getItem(ko);return m==="bypassPermissions"?"bypassPermissions":m==="acceptEdits"?"acceptEdits":m==="default"?"default":r},a="claude",[i,l]=u.useState(o),c=m=>{l(m),localStorage.setItem(ko,m)},d=()=>{e||(localStorage.setItem(ko,i),localStorage.setItem(dS,a),t(a,i))},p=[{mode:"default",label:"Ask",icon:s.jsx(Ms,{size:12}),tone:"cyan",activeClasses:"border-cyan-500/50 bg-cyan-500/10 text-cyan-400",description:"Prompt before every tool use."},{mode:"bypassPermissions",label:"Trust",icon:s.jsx(mr,{size:12}),tone:"amber",activeClasses:"border-amber-500/50 bg-amber-500/10 text-amber-400",description:"Skip all permission prompts. Runs freely with no restrictions."}];return s.jsxs("div",{className:"relative flex flex-col gap-2",children:[s.jsxs("button",{onClick:d,disabled:e,className:"flex items-center justify-center gap-1.5 w-full py-1.5 rounded-sm border border-cyan-500/30 bg-background/60 text-cyan-400 cursor-pointer hover:border-cyan-400 hover:bg-cyan-500/5 hover:shadow-[2px_2px_0_rgba(0,255,255,0.45),-2px_-2px_0_rgba(168,85,247,0.25)] hover:translate-x-[-1px] hover:translate-y-[-1px] transition-all duration-100 disabled:opacity-40 disabled:pointer-events-none disabled:hover:shadow-none disabled:hover:translate-x-0 disabled:hover:translate-y-0",children:[s.jsx(Kl,{size:12}),s.jsx("span",{className:"text-[10px] font-display font-bold uppercase tracking-wider",children:"New Session"})]}),s.jsx("div",{className:"flex items-center justify-between",children:s.jsx(Ot,{delayDuration:0,skipDelayDuration:0,children:s.jsx("div",{className:"flex gap-1",children:p.map(({mode:m,label:h,icon:g,activeClasses:f,description:x})=>{const b=i===m;return s.jsxs(Ke,{disableHoverableContent:!0,children:[s.jsx(Qe,{asChild:!0,children:s.jsxs("button",{onClick:()=>c(m),disabled:e,className:`flex items-center gap-1 px-1.5 py-1 rounded-sm border cursor-pointer transition-all duration-100 disabled:opacity-40 disabled:pointer-events-none ${b?f:"border-border/25 bg-background/40 text-muted-foreground/50 hover:text-muted-foreground/80 hover:border-border/40"}`,children:[g,s.jsx("span",{className:"text-[10px] font-display font-bold uppercase tracking-wider",children:h})]})}),s.jsx(qe,{children:x})]},m)})})})})]})}const sm="lattice-sidebar-org-mode",nm="lattice-sidebar-collapsed";function pS(){const t=localStorage.getItem(sm);return t==="flat"||t==="relevance"||t==="project"||t==="team"?t:"relevance"}function mS(){try{const t=localStorage.getItem(nm);if(!t)return{};const e=Fs(t);if(!e||typeof e!="object")return{};const n={};for(const[r,o]of Object.entries(e))typeof o=="boolean"&&(n[r]=o);return n}catch{return{}}}function hS(t,e){const n=e.toLowerCase();return[t.customName,t.initialPrompt,t.insights?.context?.mission,t.insights?.purpose].some(o=>o&&o.toLowerCase().includes(n))}const jo={flat:{icon:s.jsx(yf,{size:14}),label:"Recency",description:"Single list by recent activity"},relevance:{icon:s.jsx(ql,{size:14}),label:"Relevance",description:"Grouped by active/idle context"},project:{icon:s.jsx(xh,{size:14}),label:"Project",description:"Grouped by project and area"},team:{icon:s.jsx(b0,{size:14}),label:"Team",description:"Grouped by team and agent progress"}},fS=["flat","relevance","project","team"];function pt({title:t,count:e,isCollapsed:n,onToggle:r,accentColor:o="text-muted-foreground/60",headerRight:a,tone:i="default",children:l}){const c=i==="muted";return s.jsxs("div",{children:[s.jsxs("button",{onClick:r,className:`w-full flex items-center gap-2 px-2.5 py-2 rounded-sm border transition-all duration-100 min-h-[40px] cursor-pointer ${c?"border-border/20 bg-background/20 hover:border-stone-400/25 hover:bg-stone-500/[0.04] active:bg-stone-500/[0.08]":"border-border/20 bg-background/25 hover:border-cyan-500/30 hover:bg-cyan-500/5 active:bg-cyan-500/10"}`,children:[s.jsx("span",{className:"text-muted-foreground/50",children:n?s.jsx(Ut,{size:14}):s.jsx(Lt,{size:14})}),s.jsx("span",{className:`${c?"text-[9px]":"text-[10px]"} font-display font-bold uppercase tracking-wider ${o}`,children:t}),s.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[a,s.jsx("span",{className:`px-1.5 py-0.5 rounded-sm border ${c?"text-[9px] border-border/20 text-muted-foreground/45":"text-[10px] border-border/25 text-muted-foreground/50"}`,children:e})]})]}),!n&&s.jsx("div",{className:`mt-1.5 space-y-2 pl-2 border-l ${c?"border-border/15":"border-border/20"}`,children:l})]})}function Ol(t){const e=t.trim().toLowerCase();return e==="blue"?"bg-sky-400":e==="green"?"bg-emerald-400":e==="yellow"?"bg-amber-400":e==="purple"?"bg-violet-400":"bg-cyan-400"}function gS({teamName:t,teamStatus:e}){const n=e?.progressPct??0,r=e?.agents??[],o=e?.counts.completed??0,a=e?.counts.running??0,i=r.length,l=i>0&&o>=i,c=i>0?`${o}/${i}`:"0/0";return s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"flex items-center gap-1",children:r.slice(0,6).map(d=>s.jsxs("span",{className:"relative inline-flex h-2 w-2",children:[d.status==="running"&&s.jsx("span",{className:`absolute inline-flex h-full w-full rounded-full animate-ping opacity-75 ${Ol(d.color)}`}),s.jsx("span",{className:`relative inline-flex h-2 w-2 rounded-full ${Ol(d.color)} ${d.status==="idle"?"opacity-35":""}`,title:`${d.agentName} (${d.status})`})]},`${t}:${d.agentName}`))}),s.jsx("div",{className:"h-1 w-14 overflow-hidden rounded-sm border border-border/30 bg-background/60",children:s.jsx("div",{className:`h-full transition-[width] duration-200 ${l?"bg-emerald-400/80":"bg-cyan-400/80"}`,style:{width:`${n}%`}})}),s.jsx("span",{className:`text-[9px] font-display font-bold tracking-wider ${l?"text-emerald-300/80":a>0?"text-cyan-300/80":"text-muted-foreground/60"}`,children:l?"✓ done":c})]})}function ai({currentSessionId:t,isOpen:e,onClose:n,onOpen:r}){const o=St(),a=mn(),{isPro:i}=yn(),{conversations:l,loading:c,recentActions:d,invalidateConversations:p,recentlyCompletedSessions:m}=$s(),{serverConfig:h}=zs(),[g,f]=u.useState(pS),[x,b]=u.useState(!1),[y,v]=u.useState(mS),[w,N]=u.useState({}),[S,T]=u.useState(""),C=u.useRef(null),j=u.useRef(null),E=u.useCallback(A=>{f(A),localStorage.setItem(sm,A),b(!1)},[]);u.useEffect(()=>{const A=P=>{j.current&&!j.current.contains(P.target)&&b(!1)};if(x)return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[x]);const R=u.useCallback((A,P=!1)=>{v(le=>{const J=le[A]??P,H={...le,[A]:!J};return localStorage.setItem(nm,JSON.stringify(H)),H})},[]),O=l.filter(A=>!A.archived).sort((A,P)=>new Date(P.updatedAt).getTime()-new Date(A.updatedAt).getTime()),$=y.archived??!0,{archivedSessions:re,isLoading:ne}=Z2({enabled:e&&!$}),V=u.useMemo(()=>re,[re]),{teamStatuses:X}=iS(O),q=u.useCallback(A=>{const P=A?.trim();if(P)return X[P]},[X]),K=S?O.filter(A=>hS(A,S)):O,ge=K.filter(A=>A.pinned),D=K.filter(A=>!A.pinned),W=u.useCallback(A=>{A.startsWith("pending-")||A!==t&&(o(`/c/${A}`),window.innerWidth<768&&n())},[t,o,n]),Z=u.useCallback((A,P)=>{N(le=>({...le,[A]:P}))},[]),F=u.useCallback(async A=>{const{conversationId:P}=A;if(!(!P||P.startsWith("pending-"))&&!w[P]){Z(P,"regenerate");try{await Promise.all([G.regenerateMission(P),G.unifiedUpdateConversation(P,{customName:""})]),await p()}catch(le){console.error("Failed to regenerate session name:",le)}finally{Z(P,void 0)}}},[p,Z,w]),se=u.useCallback(async(A,P)=>{const{conversationId:le}=A;if(!le||le.startsWith("pending-")||w[le])return;const J=P.trim();if(J){Z(le,"rename");try{await G.unifiedUpdateConversation(le,{customName:J}),await p()}catch(H){console.error("Failed to rename session:",H)}finally{Z(le,void 0)}}},[p,Z,w]),ee=u.useCallback(async A=>{const{conversationId:P}=A;if(!(!P||P.startsWith("pending-")))try{await G.unifiedUpdateConversation(P,{pinned:!A.pinned}),await p()}catch(le){console.error("Failed to toggle pin:",le)}},[p]),te=u.useCallback(async A=>{if(!(!A||A.startsWith("pending-")))try{await G.unifiedUpdateConversation(A,{archived:!1}),await Promise.all([p(),a.invalidateQueries({queryKey:oi})])}catch(P){throw console.error("Failed to restore archived session:",P),P}},[p,a]),xe=u.useRef(null),_e=u.useCallback(async A=>{try{const P=await A.text(),le=Fs(P),J=await G.importSession(le);await p(),o(`/c/${J.conversationId}`)}catch(P){console.error("Failed to import session:",P),alert(`Import failed: ${P instanceof Error?P.message:"Unknown error"}`)}},[p,o]);return e?s.jsx(Ot,{children:s.jsxs("aside",{className:"relative w-full max-w-[420px] md:w-[420px] border-r border-cyan-500/20 bg-[radial-gradient(ellipse_at_top_left,rgba(6,182,212,0.08),transparent_45%),radial-gradient(ellipse_at_bottom_right,rgba(245,158,11,0.08),transparent_40%),rgba(41,37,36,0.9)] flex-shrink-0 flex flex-col h-full font-display backdrop-blur-sm",children:[s.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[linear-gradient(rgba(0,255,255,0.02)_1px,transparent_1px),linear-gradient(90deg,rgba(0,255,255,0.02)_1px,transparent_1px)] bg-[size:22px_22px]"}),s.jsxs("div",{className:"relative p-3 border-b border-border/30 flex items-center justify-between bg-background/30",children:[s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("span",{className:"text-xs font-display font-bold text-cyan-400/80 uppercase tracking-wider select-none",children:"Sessions"})}),s.jsx("div",{className:"flex items-center gap-1",children:s.jsxs(Ke,{children:[s.jsx(Qe,{asChild:!0,children:s.jsx("button",{onClick:n,className:"p-1.5 rounded-sm border border-border/30 bg-background/70 text-muted-foreground hover:text-cyan-400 hover:border-cyan-500/30 hover:bg-cyan-500/5 hover:shadow-[2px_2px_0_rgba(0,255,255,0.35),-2px_-2px_0_rgba(168,85,247,0.2)] hover:translate-x-[-1px] hover:translate-y-[-1px] transition-all duration-100 cursor-pointer","aria-label":"Close sidebar",children:s.jsx(zf,{size:14})})}),s.jsx(qe,{children:"Close sidebar"})]})})]}),s.jsx(tS,{}),s.jsx("div",{className:"relative p-2.5 border-b border-border/30 bg-zinc-800/40",children:s.jsx(uS,{onNew:(A,P)=>{o(`/new?provider=${A}&mode=${P}`),window.innerWidth<768&&n()},isLoading:!1,defaultPermissionMode:h?.defaultPermissionMode,defaultProvider:"claude"})}),s.jsx("div",{className:"relative px-2.5 pt-2 pb-1",children:s.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-sm border border-border/30 bg-background/30",children:[s.jsx(Ql,{size:12,className:"text-muted-foreground/40 flex-shrink-0"}),s.jsx("input",{ref:C,type:"text",value:S,onChange:A=>T(A.target.value),placeholder:"Search sessions...",className:"flex-1 bg-transparent text-[11px] font-mono text-foreground/90 placeholder:text-muted-foreground/30 outline-none"}),S&&s.jsx("button",{onClick:()=>{T(""),C.current?.focus()},className:"text-muted-foreground/40 hover:text-muted-foreground/70 transition-colors cursor-pointer",children:s.jsx(Be,{size:12})})]})}),s.jsxs("div",{className:"relative flex-1 overflow-y-auto p-2 space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between pb-1",children:[s.jsxs(Ke,{children:[s.jsx(Qe,{asChild:!0,children:s.jsxs("button",{onClick:()=>xe.current?.click(),className:"flex items-center gap-1 px-2 py-1 rounded-sm border border-border/25 bg-background/60 text-muted-foreground hover:text-cyan-300 hover:border-cyan-500/30 hover:bg-cyan-500/5 hover:shadow-[2px_2px_0_rgba(0,255,255,0.3)] hover:translate-x-[-1px] hover:translate-y-[-1px] transition-all duration-100 cursor-pointer","aria-label":"Import session",children:[s.jsx(Kn,{size:12}),s.jsx("span",{className:"text-[10px] font-display font-bold uppercase tracking-wider",children:"Import"})]})}),s.jsx(qe,{children:"Import a .lattice session file"})]}),s.jsx("input",{ref:xe,type:"file",accept:".lattice.json,.json",className:"hidden",onChange:A=>{const P=A.target.files?.[0];P&&(_e(P),A.target.value="")}}),s.jsxs("div",{ref:j,className:"relative",children:[s.jsxs(Ke,{children:[s.jsx(Qe,{asChild:!0,children:s.jsxs("button",{onClick:()=>b(A=>!A),className:"flex items-center gap-1.5 px-2.5 py-1 rounded-sm border border-border/25 bg-background/60 text-muted-foreground hover:text-cyan-300 hover:border-cyan-500/30 hover:bg-cyan-500/5 hover:shadow-[2px_2px_0_rgba(0,255,255,0.3)] hover:translate-x-[-1px] hover:translate-y-[-1px] transition-all duration-100 cursor-pointer","aria-label":"Select organization mode","aria-expanded":x,children:[jo[g].icon,s.jsx("span",{className:"text-[10px] font-display font-bold uppercase tracking-wider",children:jo[g].label}),s.jsx(Lt,{size:12,className:`transition-transform ${x?"rotate-180":""}`})]})}),s.jsx(qe,{children:"Choose organization mode"})]}),x&&s.jsx("div",{className:"absolute right-0 top-full mt-1 z-30 min-w-[220px] rounded-sm border border-border/40 bg-card/95 backdrop-blur-sm shadow-lg p-1",children:fS.map(A=>{const P=jo[A],le=A===g;return s.jsxs("button",{onClick:()=>E(A),className:`w-full text-left rounded-sm px-2 py-1.5 transition-colors cursor-pointer ${le?"bg-cyan-500/10 border border-cyan-500/30":"border border-transparent hover:bg-cyan-500/5 hover:border-cyan-500/20"}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:le?"text-cyan-300":"text-muted-foreground",children:P.icon}),s.jsx("span",{className:`text-[10px] font-display font-bold uppercase tracking-wider ${le?"text-cyan-300":"text-foreground/85"}`,children:P.label})]}),s.jsx("div",{className:`mt-0.5 text-[10px] ${le?"text-cyan-300/75":"text-muted-foreground/70"}`,children:P.description})]},A)})})]})]}),c?s.jsx("div",{className:"space-y-2",children:["session-skeleton-1","session-skeleton-2","session-skeleton-3"].map(A=>s.jsxs("div",{className:"rounded-sm border border-border/20 bg-background/30 overflow-hidden animate-pulse",children:[s.jsx("div",{className:"w-full h-12 bg-gradient-to-r from-muted/10 via-muted/20 to-muted/10"}),s.jsxs("div",{className:"p-2.5 space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-muted/30"}),s.jsx("div",{className:"w-6 h-2 rounded bg-muted/20"})]}),s.jsxs("div",{className:"border border-border/20 rounded-sm p-2 bg-muted/5",children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[s.jsx("div",{className:"w-3 h-3 rounded bg-muted/20"}),s.jsx("div",{className:"w-12 h-2 rounded bg-muted/20"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"h-2.5 w-full rounded bg-muted/15"}),s.jsx("div",{className:"h-2.5 w-4/5 rounded bg-muted/15"})]})]})]})]},A))}):S&&K.length===0?s.jsxs("div",{className:"text-center text-muted-foreground/40 text-xs font-mono py-8 border border-dashed border-border/30 rounded-sm bg-background/20",children:["No sessions match “",S,"”"]}):O.length===0?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"text-center text-muted-foreground/50 text-sm py-8 border border-dashed border-border/30 rounded-sm bg-background/20",children:"No active sessions"}),s.jsx(pt,{title:"Archived",count:V.length,isCollapsed:$,onToggle:()=>R("archived",!0),accentColor:"text-stone-300/70",tone:"muted",children:s.jsx(Ml,{archivedSessions:V,currentSessionId:t,isLoading:ne,onSelectSession:W,onRestoreSession:te})})]}):s.jsxs(s.Fragment,{children:[ge.length>0&&s.jsx(pt,{title:"Pinned",count:ge.length,isCollapsed:y.pinned,onToggle:()=>R("pinned"),accentColor:"text-amber-400",children:ge.map(A=>s.jsx(gt,{conversation:A,teamStatus:q(A.teamName),isCurrent:A.conversationId===t,onClick:()=>W(A.conversationId),recentActions:d[A.conversationId],recentlyCompleted:m.has(A.conversationId),onRenameSessionName:se,onRegenerateSessionName:i?F:void 0,isRenamingSessionName:w[A.conversationId]==="rename",isRegeneratingSessionName:w[A.conversationId]==="regenerate",onPin:ee},A.conversationId))}),g==="flat"&&D.map(A=>s.jsx(gt,{conversation:A,teamStatus:q(A.teamName),isCurrent:A.conversationId===t,onClick:()=>W(A.conversationId),recentActions:d[A.conversationId],recentlyCompleted:m.has(A.conversationId),onRenameSessionName:se,onRegenerateSessionName:i?F:void 0,isRenamingSessionName:w[A.conversationId]==="rename",isRegeneratingSessionName:w[A.conversationId]==="regenerate",onPin:ee},A.conversationId)),g==="relevance"&&(()=>{const A=Zp(D);return s.jsxs("div",{className:"space-y-3",children:[A.starting.length>0&&s.jsx(pt,{title:"Starting",count:A.starting.length,isCollapsed:y.starting,onToggle:()=>R("starting"),accentColor:"text-sky-400",children:A.starting.map(P=>s.jsx(gt,{conversation:P,isCurrent:P.conversationId===t,onClick:()=>W(P.conversationId),recentActions:d[P.conversationId]},P.conversationId))}),A.active.length>0&&s.jsx(pt,{title:"Active",count:A.active.length,isCollapsed:y.active,onToggle:()=>R("active"),accentColor:"text-green-400",children:A.active.map(P=>s.jsx(gt,{conversation:P,teamStatus:q(P.teamName),isCurrent:P.conversationId===t,onClick:()=>W(P.conversationId),recentActions:d[P.conversationId],onRenameSessionName:se,onRegenerateSessionName:i?F:void 0,isRenamingSessionName:w[P.conversationId]==="rename",isRegeneratingSessionName:w[P.conversationId]==="regenerate",onPin:ee},P.conversationId))}),A.recent.length>0&&s.jsx(pt,{title:"Idle",count:A.recent.length,isCollapsed:y.recent,onToggle:()=>R("recent"),accentColor:"text-amber-400",children:A.recent.map(P=>s.jsx(gt,{conversation:P,teamStatus:q(P.teamName),isCurrent:P.conversationId===t,onClick:()=>W(P.conversationId),recentActions:d[P.conversationId],onRenameSessionName:se,onRegenerateSessionName:i?F:void 0,isRenamingSessionName:w[P.conversationId]==="rename",isRegeneratingSessionName:w[P.conversationId]==="regenerate",onPin:ee},P.conversationId))}),A.paused.length>0&&s.jsx(pt,{title:"Paused",count:A.paused.length,isCollapsed:y.paused,onToggle:()=>R("paused"),accentColor:"text-violet-400",children:A.paused.map(P=>s.jsx(gt,{conversation:P,teamStatus:q(P.teamName),isCurrent:P.conversationId===t,onClick:()=>W(P.conversationId),recentActions:d[P.conversationId],recentlyCompleted:m.has(P.conversationId),onRenameSessionName:se,onRegenerateSessionName:i?F:void 0,isRenamingSessionName:w[P.conversationId]==="rename",isRegeneratingSessionName:w[P.conversationId]==="regenerate",onPin:ee},P.conversationId))}),A.imported.length>0&&s.jsx(pt,{title:"Imported",count:A.imported.length,isCollapsed:y.imported,onToggle:()=>R("imported"),accentColor:"text-cyan-400",children:A.imported.map(P=>s.jsx(gt,{conversation:P,teamStatus:q(P.teamName),isCurrent:P.conversationId===t,onClick:()=>W(P.conversationId),recentActions:d[P.conversationId],onRenameSessionName:se,onRegenerateSessionName:i?F:void 0,isRenamingSessionName:w[P.conversationId]==="rename",isRegeneratingSessionName:w[P.conversationId]==="regenerate",onPin:ee},P.conversationId))}),A.older.length>0&&s.jsx(pt,{title:"Older",count:A.older.length,isCollapsed:y.older??!0,onToggle:()=>R("older",!0),accentColor:"text-muted-foreground/50",children:A.older.map(P=>s.jsx(gt,{conversation:P,teamStatus:q(P.teamName),isCurrent:P.conversationId===t,onClick:()=>W(P.conversationId),recentActions:d[P.conversationId],onRenameSessionName:se,onRegenerateSessionName:i?F:void 0,isRenamingSessionName:w[P.conversationId]==="rename",isRegeneratingSessionName:w[P.conversationId]==="regenerate",onPin:ee},P.conversationId))})]})})(),g==="project"&&(()=>{const A=em(D);return s.jsx("div",{className:"space-y-3",children:A.map(([P,le])=>s.jsx(pt,{title:P,count:le.length,isCollapsed:y[P],onToggle:()=>R(P),accentColor:P==="Ungrouped"?"text-muted-foreground/50":"text-cyan-400",children:le.map(J=>s.jsx(gt,{conversation:J,teamStatus:q(J.teamName),isCurrent:J.conversationId===t,onClick:()=>W(J.conversationId),recentActions:d[J.conversationId],onRenameSessionName:se,onRegenerateSessionName:i?F:void 0,isRenamingSessionName:w[J.conversationId]==="rename",isRegeneratingSessionName:w[J.conversationId]==="regenerate",onPin:ee},J.conversationId))},P))})})(),g==="team"&&(()=>{const A=tm(D);return s.jsx("div",{className:"space-y-3",children:A.map(([P,le])=>s.jsx(pt,{title:P,count:le.length,isCollapsed:y[`team:${P}`],onToggle:()=>R(`team:${P}`),accentColor:P==="No Team"?"text-muted-foreground/50":"text-blue-300",headerRight:P==="No Team"?void 0:s.jsx(gS,{teamName:P,teamStatus:X[P]}),children:le.map(J=>s.jsx(gt,{conversation:J,teamStatus:q(J.teamName),isCurrent:J.conversationId===t,onClick:()=>W(J.conversationId),recentActions:d[J.conversationId],onRenameSessionName:se,onRegenerateSessionName:i?F:void 0,isRenamingSessionName:w[J.conversationId]==="rename",isRegeneratingSessionName:w[J.conversationId]==="regenerate",onPin:ee},J.conversationId))},P))})})(),s.jsx(pt,{title:"Archived",count:V.length,isCollapsed:$,onToggle:()=>R("archived",!0),accentColor:"text-stone-300/70",tone:"muted",children:s.jsx(Ml,{archivedSessions:V,currentSessionId:t,isLoading:ne,onSelectSession:W,onRestoreSession:te})})]})]})]})}):null}const No=[{path:"/prototype/new-session-empty-state",name:"New Session Empty State",category:"ui",created:"2026-03-07"},{path:"/prototype/new-session-controls",name:"New Session Controls",category:"ui",created:"2026-03-07"},{path:"/prototype/session-card-density",name:"Session Card Density",category:"ui",created:"2026-03-07"},{path:"/prototype/composer-status-input",name:"Composer Status + Input",category:"ui",created:"2026-02-11"},{path:"/prototype/new-session-variants",name:"New Session Variants",category:"ui",created:"2026-02-10"},{path:"/prototype/action-queue",name:"Action Queue",category:"ui",created:"2026-02-09"},{path:"/prototype/codex-activity-indicator",name:"Codex Activity Indicator",category:"ui",created:"2026-02-07"},{path:"/prototype/ask-question-variants",name:"Ask Question Variants",category:"ui",created:"2026-02-07"},{path:"/prototype/session-card-title",name:"Session Card Title",category:"ui",created:"2026-02-07"},{path:"/prototype/recommendation-cards",name:"Recommendation Cards",category:"ui",created:"2026-02-07"},{path:"/prototype/geist-pixel",name:"Geist Pixel",category:"ui",created:"2026-02-07"},{path:"/prototype/session-skeleton-variants",name:"Session Skeleton Variants",category:"ui",created:"2026-02-06"},{path:"/prototype/codex-thinking",name:"Codex Thinking",category:"ui",created:"2026-02-06"},{path:"/prototype/codex-thinking-pill",name:"Codex Thinking Pill",category:"ui",created:"2026-02-06"},{path:"/prototype/codex-thinking-active-variants",name:"Codex Thinking Active Variants",category:"ui",created:"2026-02-06"},{path:"/prototype/font-showcase",name:"Font Gallery",category:"banner",created:"2026-01-27"},{path:"/prototype/session-sidebar",name:"Session Sidebar Variations",category:"ui",created:"2026-01-27"},{path:"/prototype/timeline-card",name:"Timeline Cards",category:"ui",created:"2026-01-25"},{path:"/prototype/archived-card",name:"Archived Cards",category:"ui",created:"2026-01-25"},{path:"/prototype/toolbar",name:"Toolbar",category:"ui",created:"2026-01-24"},{path:"/prototype/menu-styles",name:"Menu Styles",category:"ui",created:"2026-01-24"},{path:"/prototype/smart-menu",name:"Smart Menu",category:"ui",created:"2026-01-24"},{path:"/prototype/mark-button",name:"Mark Button",category:"ui",created:"2026-01-21"},{path:"/prototype/session-start",name:"Session Start",category:"ui",created:"2026-01-18"},{path:"/prototype/permissions",name:"Permissions",category:"ui",created:"2026-01-18"},{path:"/prototype/styles",name:"Style Gallery",category:"banner",created:"2026-01-18"},{path:"/prototype/session-cards",name:"Session Cards",category:"banner",created:"2026-01-18"},{path:"/prototype/semantic",name:"Semantic Gallery",category:"banner",created:"2026-01-18"},{path:"/prototype/pipeline",name:"Pipeline Gallery",category:"banner",created:"2026-01-18"},{path:"/prototype/geometric",name:"Geometric Gallery",category:"banner",created:"2026-01-18"},{path:"/prototype/banners",name:"Banners",category:"banner",created:"2026-01-18"},{path:"/prototype/gallery",name:"Banner Gallery",category:"banner",created:"2026-01-18"},{path:"/prototype/permission-patterns",name:"Permission Patterns",category:"ui",created:"2026-01-18"}],xS={banner:{label:"BANNER / IDENTITY",icon:s.jsx(ql,{size:14}),textColor:"text-purple-400",borderColor:"border-purple-500/30",shadowColor:"rgba(168,85,247,0.5)"},ui:{label:"UI COMPONENTS",icon:s.jsx(To,{size:14}),textColor:"text-amber-400",borderColor:"border-amber-500/30",shadowColor:"rgba(251,191,36,0.5)"}};function bS(t){const e=new Date(t),r=Date.now()-e.getTime(),o=Math.floor(r/6e4),a=Math.floor(o/60),i=Math.floor(a/24);return o<1?"just now":o<60?`${o}m ago`:a<24?`${a}h ago`:i<7?`${i}d ago`:e.toLocaleDateString()}function yS({session:t,onRestore:e}){const{insights:n,updatedAt:r,conversationId:o,customName:a,identityImage:i}=t,l=a||n?.context?.mission||n?.purpose||o.slice(0,8);return s.jsxs("div",{className:"flex gap-3 group",children:[s.jsxs("div",{className:"flex flex-col items-center flex-shrink-0 pt-2",children:[s.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-rose-500/30 border-2 border-rose-500/50 group-hover:bg-rose-400 group-hover:border-rose-400 transition-colors"}),s.jsx("div",{className:"w-px flex-1 bg-border/30 mt-1"})]}),s.jsx("div",{className:"flex-1 pb-4 min-w-0",children:s.jsxs("div",{className:"rounded-lg border border-border/20 overflow-hidden hover:border-emerald-500/30 transition-all",children:[i?s.jsx("div",{className:"w-full h-16",style:{backgroundImage:`url(data:image/png;base64,${i})`,backgroundSize:"cover",backgroundPosition:"center"}}):s.jsx("div",{className:"w-full h-16 bg-gradient-to-r from-muted/10 via-muted/20 to-muted/10"}),s.jsxs("div",{className:"p-2.5 space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[10px] text-muted-foreground/40",children:bS(r)}),s.jsxs("div",{className:"flex flex-wrap gap-1 ml-auto",children:[n?.context?.scope&&s.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded uppercase tracking-wide font-medium ${n.context.scope==="major"?"bg-purple-500/10 text-purple-400":n.context.scope==="feature"?"bg-blue-500/10 text-blue-400":"bg-muted/30 text-muted-foreground/70"}`,children:n.context.scope}),n?.theme&&s.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded uppercase tracking-wide font-medium ${n.theme==="debugging"?"bg-orange-500/10 text-orange-400":n.theme==="firefighting"?"bg-red-500/10 text-red-400":n.theme==="building"?"bg-emerald-500/10 text-emerald-400":n.theme==="designing"?"bg-violet-500/10 text-violet-400":n.theme==="refactoring"?"bg-cyan-500/10 text-cyan-400":n.theme==="investigating"?"bg-sky-500/10 text-sky-400":n.theme==="polishing"?"bg-teal-500/10 text-teal-400":"bg-muted/30 text-muted-foreground/70"}`,children:n.theme}),n?.tags?.complexity&&n.tags.complexity!=="routine"&&s.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded uppercase tracking-wide font-medium ${n.tags.complexity==="gnarly"?"bg-red-500/10 text-red-400":"bg-amber-500/10 text-amber-400"}`,children:n.tags.complexity})]})]}),s.jsxs("div",{className:"border border-border/20 rounded-lg p-3 bg-muted/5",children:[s.jsxs("div",{className:"text-[11px] uppercase tracking-wider text-muted-foreground/50 mb-2 flex items-center gap-1.5",children:[s.jsx("span",{className:"text-xs leading-none",children:"🎯"}),"Mission"]}),s.jsx("div",{className:"text-xs leading-relaxed text-muted-foreground/70 line-clamp-2",children:l})]}),s.jsx("div",{className:"flex justify-end",children:s.jsxs("button",{onClick:e,className:`
|
|
364
|
+
`,children:[s.jsx(wa,{size:10}),"Restore"]})]}):s.jsxs("div",{"data-testid":`session-${t.conversationId}`,className:`relative group transition-all cursor-pointer rounded-sm border overflow-hidden ${n?"border-cyan-500/50 bg-cyan-500/[0.03] shadow-[0_0_15px_rgba(34,211,238,0.15)]":"border-border/25 bg-background/20 hover:border-cyan-500/35 hover:bg-background/35 hover:shadow-[2px_2px_0_rgba(0,255,255,0.2)]"}`,onClick:Z?r:void 0,onKeyDown:Z?me:void 0,role:"button",tabIndex:Z?0:-1,children:[s.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[linear-gradient(rgba(0,255,255,0.02)_1px,transparent_1px),linear-gradient(90deg,rgba(0,255,255,0.02)_1px,transparent_1px)] bg-[size:18px_18px]"}),s.jsxs("div",{className:"relative p-2.5 space-y-2 font-display caret-transparent",children:[h&&s.jsxs("div",{"data-testid":`session-image-${t.conversationId}`,className:"relative",children:[s.jsx(eS,{identityImage:ne,isCurrent:n,isPending:t.status==="pending"}),B.length>0&&s.jsx("div",{className:"absolute bottom-1 left-1 flex items-center gap-1 z-[2] rounded-sm bg-black/55 backdrop-blur-sm px-1 py-0.5",children:B.map(O=>{const W=B.length>1&&O!==Q;return s.jsx(zn,{className:`border-cyan-500/40 bg-cyan-500/20 text-cyan-200 ${W?"opacity-60":""}`,children:O},O)})}),q&&s.jsxs("div",{className:"absolute bottom-1 right-1 flex items-center gap-1 z-[2] rounded-sm bg-black/60 backdrop-blur-sm px-1 py-0.5",children:[f?.context?.scope&&s.jsx(zn,{className:f.context.scope==="major"?"border-purple-500/40 bg-purple-500/20 text-purple-200":f.context.scope==="feature"?"border-blue-500/40 bg-blue-500/20 text-blue-200":"border-border/30 bg-muted/40 text-muted-foreground/80",children:f.context.scope}),f?.theme&&s.jsx(zn,{className:f.theme==="debugging"?"border-orange-500/40 bg-orange-500/20 text-orange-200":f.theme==="firefighting"?"border-red-500/40 bg-red-500/20 text-red-200":f.theme==="building"?"border-emerald-500/40 bg-emerald-500/20 text-emerald-200":f.theme==="designing"?"border-violet-500/40 bg-violet-500/20 text-violet-200":f.theme==="refactoring"?"border-cyan-500/40 bg-cyan-500/20 text-cyan-200":f.theme==="investigating"?"border-sky-500/40 bg-sky-500/20 text-sky-200":f.theme==="polishing"?"border-teal-500/40 bg-teal-500/20 text-teal-200":"border-border/30 bg-muted/40 text-muted-foreground/80",children:f.theme}),f?.tags?.complexity&&f.tags.complexity!=="routine"&&s.jsx(zn,{className:f.tags.complexity==="gnarly"?"border-red-500/40 bg-red-500/20 text-red-200":"border-amber-500/40 bg-amber-500/20 text-amber-200",children:f.tags.complexity})]})]}),s.jsxs("div",{className:"rounded-sm border border-border/25 bg-background/35 px-2.5 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"text-[9px] uppercase tracking-widest text-cyan-400/70",children:"Mission"}),(l||d)&&s.jsxs("div",{className:"flex items-center gap-1 opacity-45 group-hover:opacity-100 transition-opacity",children:[d&&s.jsxs(Ke,{children:[s.jsx(Qe,{asChild:!0,children:s.jsx("button",{onClick:O=>{O.stopPropagation(),d(t)},disabled:p,className:"p-1 rounded-sm text-muted-foreground/70 hover:text-cyan-300 hover:bg-cyan-500/10 transition-colors cursor-pointer","aria-label":"Regenerate mission",children:p?s.jsx(Re,{size:10,className:"animate-spin"}):s.jsx(ds,{size:10})})}),s.jsx(qe,{side:"top",sideOffset:6,children:p?"Regenerating...":"Re-derive mission from recent context"})]}),l&&s.jsxs(Ke,{children:[s.jsx(Qe,{asChild:!0,children:s.jsx("button",{onClick:O=>{if(O.stopPropagation(),N){oe();return}C(y),S(!0)},disabled:c,className:"p-1 rounded-sm text-muted-foreground/70 hover:text-sky-300 hover:bg-sky-500/10 transition-colors cursor-pointer","aria-label":"Rename session",children:c?s.jsx(Re,{size:10,className:"animate-spin"}):s.jsx(Hf,{size:10})})}),s.jsx(qe,{side:"top",sideOffset:6,children:c?"Saving name...":N?"Save name":"Manually set the session name"})]})]})]}),N?s.jsx("textarea",{ref:E,value:T,onChange:O=>C(O.target.value),onClick:O=>O.stopPropagation(),onMouseDown:O=>O.stopPropagation(),onKeyDown:O=>{O.stopPropagation(),O.key==="Enter"&&(O.metaKey||O.ctrlKey)&&(O.preventDefault(),oe()),O.key==="Escape"&&(O.preventDefault(),C(y),S(!1))},onBlur:()=>{oe()},disabled:c,rows:2,className:"mt-1 w-full rounded-sm border border-sky-500/35 bg-background/80 px-2 py-1 text-sm font-semibold leading-snug text-foreground/95 focus:outline-none focus:border-sky-400/60 focus:ring-1 focus:ring-sky-400/35 resize-none overflow-y-auto",placeholder:"Session name","aria-label":"Session name"}):s.jsx("div",{"data-testid":`session-mission-${t.conversationId}`,className:`mt-1 text-sm text-foreground/90 font-semibold leading-relaxed ${v?"line-clamp-1":""}`,children:y})]}),t.importedAt?s.jsxs("div",{className:"rounded-sm border border-cyan-500/25 bg-cyan-500/10 px-3 py-2 text-xs",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-widest text-cyan-400/60",children:"Read-only"}),s.jsx("div",{className:"mt-1 text-cyan-300/80 font-sans",children:"Imported session — view history only"})]}):t.pausedReason?s.jsxs("div",{className:"rounded-sm border border-violet-500/25 bg-violet-500/10 px-3 py-2 text-xs",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-widest text-violet-400/60",children:"Paused"}),s.jsx("div",{className:"mt-1 text-violet-300/90 font-sans",children:t.pausedReason})]}):g?s.jsxs("div",{className:"rounded-sm border border-orange-500/25 bg-orange-500/10 px-3 py-2 text-xs",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-widest text-orange-400/60",children:"Awaiting Input"}),s.jsx("div",{className:"mt-1 text-orange-300/80 font-sans",children:"Permission or question pending"})]}):s.jsx(s.Fragment,{children:w&&w!==x&&s.jsxs("div",{className:"rounded-sm border border-border/20 bg-muted/10 px-3 py-2 text-xs text-muted-foreground/80",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-widest text-muted-foreground/60",children:"Current Aim"}),s.jsx("div",{className:"mt-1 text-foreground/90 font-sans",children:w})]})})]})]})}const Pl="lattice-version-dismissed";function tS(){const[t,e]=u.useState(null),[n,r]=u.useState(!1),[o,a]=u.useState("idle"),[i,l]=u.useState(""),c=u.useRef(),d=u.useCallback(async()=>{try{const x=await H.checkVersion();x.updateAvailable&&(localStorage.getItem(Pl)===x.latest&&r(!0),e({current:x.current,latest:x.latest}))}catch{}},[]);u.useEffect(()=>{const x=setTimeout(()=>{d()},3e3);return()=>clearTimeout(x)},[d]),u.useEffect(()=>()=>{c.current&&clearInterval(c.current)},[]);const p=u.useCallback(()=>{t&&localStorage.setItem(Pl,t.latest),r(!0)},[t]),m=u.useCallback(()=>{a("polling"),l("Waiting for server...");let x=0;const b=30;c.current=setInterval(()=>{x++,fetch("/api/system/health").then(y=>{y.ok&&(c.current&&clearInterval(c.current),a("done"),l("Updated! Reloading..."),setTimeout(()=>window.location.reload(),1e3))}).catch(()=>{}),x>=b&&(c.current&&clearInterval(c.current),a("error"),l("Server didn’t come back. Check logs."))},1e3)},[]),h=u.useCallback(()=>{a("installing"),l("Updating package..."),(async()=>{try{const x=await fetch("/api/system/upgrade",{method:"POST"});if(!x.ok||!x.body){a("error"),l(`Server returned ${x.status}`);return}const b=x.body.getReader(),y=new TextDecoder;let v="";for(;;){const{done:w,value:N}=await b.read();if(w)break;v+=y.decode(N,{stream:!0});const S=v.split(`
|
|
365
|
+
`);v=S.pop()||"";for(const T of S)if(T.startsWith("data: "))try{const C=Fs(T.slice(6));if(l(C.message),C.error){a("error");return}if(C.stage==="restarting"){a("restarting"),setTimeout(m,3e3);return}}catch{}}}catch{a("error"),l("Connection lost during upgrade")}})()},[m]);if(!t||n)return null;const g=o!=="idle"&&o!=="error",f=o==="done";return s.jsx("div",{className:"relative border-b border-emerald-500/15 bg-gradient-to-r from-emerald-500/[0.04] via-transparent to-emerald-500/[0.02] px-3 py-2 animate-ui-in",children:s.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o==="error"?s.jsx(kt,{size:13,className:"text-amber-400/70 shrink-0"}):f?s.jsx(Oe,{size:13,className:"text-emerald-400/70 shrink-0"}):g?s.jsx(Re,{size:13,className:"text-emerald-400/70 shrink-0 animate-spin"}):s.jsx(Eh,{size:13,className:"text-emerald-400/70 shrink-0"}),g||f||o==="error"?s.jsx("span",{className:"text-[10px] text-muted-foreground/60 truncate",children:i}):s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"text-[10px] font-display font-bold text-emerald-400/70 uppercase tracking-wider shrink-0",children:["v",t.latest]}),s.jsx("span",{className:"text-[10px] text-muted-foreground/50 truncate",children:"available"})]})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[o==="idle"&&s.jsxs(s.Fragment,{children:[s.jsxs(Ke,{children:[s.jsx(Qe,{asChild:!0,children:s.jsx("button",{onClick:h,className:"text-[9px] font-display font-bold uppercase tracking-wider px-2 py-0.5 rounded-sm border border-emerald-500/20 bg-emerald-500/5 text-emerald-400/60 hover:text-emerald-300 hover:border-emerald-500/30 hover:bg-emerald-500/10 hover:shadow-[1px_1px_0_rgba(52,211,153,0.2)] hover:translate-x-[-0.5px] hover:translate-y-[-0.5px] transition-all duration-100 cursor-pointer",children:"Upgrade"})}),s.jsx(qe,{children:s.jsx("span",{className:"font-mono text-[10px]",children:"npm update -g lattice-orchestrator"})})]}),s.jsx("button",{onClick:p,className:"p-0.5 rounded-sm text-muted-foreground/30 hover:text-muted-foreground/60 transition-colors duration-100 cursor-pointer","aria-label":"Dismiss update notice",children:s.jsx(Be,{size:11})})]}),o==="error"&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>{a("idle"),l("")},className:"text-[9px] font-display font-bold uppercase tracking-wider px-2 py-0.5 rounded-sm border border-amber-500/20 bg-amber-500/5 text-amber-400/60 hover:text-amber-300 hover:border-amber-500/30 transition-all duration-100 cursor-pointer",children:"Retry"}),s.jsx("button",{onClick:p,className:"p-0.5 rounded-sm text-muted-foreground/30 hover:text-muted-foreground/60 transition-colors duration-100 cursor-pointer","aria-label":"Dismiss",children:s.jsx(Be,{size:11})})]})]})]})})}function sS(t){const e=Date.now()-new Date(t).getTime(),n=Math.floor(e/1e3),r=Math.floor(n/60),o=Math.floor(r/60);return n<10?"now":n<60?`${n}s`:r<60?`${r}m`:o<24?`${o}h`:`${Math.floor(o/24)}d`}function nS(t,e){const n=e?t.insights:void 0,r=t.customName?.trim(),o=t.initialPrompt?.trim();return r||n?.context?.mission||n?.purpose||o||t.conversationId.slice(0,8)}function Ml({archivedSessions:t,currentSessionId:e,isLoading:n,onSelectSession:r,onRestoreSession:o}){const{isPro:a}=yn(),[i,l]=u.useState(null),c=u.useCallback(async p=>{if(!i){l(p);try{await o(p)}catch(m){console.error("Failed to restore archived session:",m)}finally{l(null)}}},[o,i]),d=u.useMemo(()=>t.map(p=>{const m=nS(p,a),h=p.conversationId===e,g=i===p.conversationId;return s.jsxs("div",{className:`group relative rounded-sm border transition-all duration-100 ${h?"border-stone-400/35 bg-stone-500/[0.08]":"border-border/20 bg-background/20 hover:border-stone-400/30 hover:bg-stone-500/[0.04]"}`,children:[s.jsx("button",{onClick:()=>r(p.conversationId),className:"w-full px-2.5 py-2 text-left cursor-pointer",type:"button",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Oe,{size:11,className:"mt-0.5 shrink-0 text-emerald-400/70"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"line-clamp-2 text-[11px] leading-snug text-foreground/70",children:m}),s.jsx("p",{className:"mt-1 text-[9px] uppercase tracking-wider text-muted-foreground/45",children:sS(p.updatedAt)})]})]})}),s.jsxs("button",{type:"button",onClick:f=>{f.stopPropagation(),c(p.conversationId)},disabled:!!i,className:`absolute right-1.5 top-1.5 flex items-center gap-1 rounded-sm border px-1.5 py-1 text-[9px] font-display font-bold uppercase tracking-wider transition-all duration-100 ${g?"border-emerald-400/40 bg-emerald-500/10 text-emerald-300 opacity-100":"border-border/20 bg-background/70 text-muted-foreground/70 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 hover:border-emerald-400/35 hover:bg-emerald-500/10 hover:text-emerald-300"} ${g?"pointer-events-auto":"pointer-events-none group-hover:pointer-events-auto group-focus-within:pointer-events-auto"}`,"aria-label":`Restore ${m}`,children:[g?s.jsx(Re,{size:10,className:"animate-spin"}):s.jsx(wa,{size:10}),s.jsx("span",{children:"Restore"})]})]},p.conversationId)}),[t,e,c,a,i,r]);return n?s.jsx("div",{className:"space-y-1.5 py-1",children:["archived-skeleton-1","archived-skeleton-2","archived-skeleton-3"].map(p=>s.jsx("div",{className:"h-12 animate-pulse rounded-sm border border-border/20 bg-background/20"},p))}):t.length===0?s.jsx("div",{className:"rounded-sm border border-dashed border-border/25 bg-background/15 px-2.5 py-2 text-[10px] uppercase tracking-wider text-muted-foreground/45",children:"No archived sessions"}):s.jsx("div",{className:"space-y-1.5",children:d})}const Ll=["blue","green","yellow","purple"];function rS(t){if(!t||typeof t!="object")return!1;const e=t;return typeof e.type!="string"||typeof e.teamName!="string"?!1:e.type==="team-updated"||e.type==="team-removed"||e.type==="team-inbox-update"}function oS(t,e){if(e.agentCompletions?.find(o=>o.agentName===t)?.deliveredToLead)return"completed";const r=e.tasks.pending+e.tasks.in_progress+e.tasks.completed;return r>0&&e.tasks.completed>=r?"completed":e.tasks.in_progress>0||r>0&&e.tasks.pending>0?"running":"idle"}function aS(t){const e=new Map;for(const d of t.inboxSummaries||[])e.set(d.agentName,{messageCount:d.messageCount,unreadCount:d.unreadCount,latestTimestamp:d.latestTimestamp});const n=t.config.members.filter(d=>d.agentType!=="team-lead").map((d,p)=>{const m=e.get(d.name),h=oS(d.name,t);return{agentName:d.name,color:d.color||Ll[p%Ll.length],status:h,messageCount:m?.messageCount??0,unreadCount:m?.unreadCount??0,latestTimestamp:m?.latestTimestamp??null}}),r=n.reduce((d,p)=>(d[p.status]+=1,d),{idle:0,running:0,completed:0}),o=t.agentCompletions?.filter(d=>d.deliveredToLead).length??0,a=n.length,i=t.tasks.pending+t.tasks.in_progress+t.tasks.completed,l=t.tasks.completed;let c;return o>0&&a>0?c=Math.min(100,Math.round(o/a*100)):i>0?c=Math.min(100,Math.round(l/i*100)):c=0,{teamName:t.teamName,leadSessionId:t.leadSessionId,memberCount:t.memberCount,tasks:t.tasks,progressPct:c,agents:n,counts:r,updatedAt:t.timestamp}}function iS(t){const[e,n]=u.useState({}),r=u.useRef(!0),o=u.useRef(new Map),a=u.useMemo(()=>{const l=new Set;for(const c of t){const d=c.teamName?.trim();d&&l.add(d)}return Array.from(l)},[t]),i=u.useCallback(async l=>{const c=o.current.get(l)||{inFlight:!1,pending:!1};if(c.inFlight){c.pending=!0,o.current.set(l,c);return}c.inFlight=!0,c.pending=!1,o.current.set(l,c);try{const d=await H.getTeamInfo(l);if(!r.current)return;const p=aS(d);n(m=>({...m,[l]:p}))}catch{if(!r.current)return}finally{const d=o.current.get(l);d&&(d.pending?(d.pending=!1,d.inFlight=!1,o.current.set(l,d),i(l)):(d.inFlight=!1,o.current.set(l,d)))}},[]);return u.useEffect(()=>(r.current=!0,()=>{r.current=!1}),[]),u.useEffect(()=>{const l=new Set(a);n(c=>{const d={};for(const[p,m]of Object.entries(c))l.has(p)&&(d[p]=m);return d});for(const c of a)i(c)},[a,i]),Rt({type:"activity"},l=>{if(rS(l)){if(l.type==="team-removed"){n(c=>{if(!(l.teamName in c))return c;const d={...c};return delete d[l.teamName],d});return}i(l.teamName)}}),{teamStatuses:e}}const cS=1440*60*1e3;function Zp(t){const e=Date.now(),n=[],r=[],o=[],a=[],i=[],l=[];for(const c of t)c.status==="pending"?n.push(c):c.importedAt?a.push(c):c.pausedReason?o.push(c):c.status==="ongoing"?r.push(c):e-new Date(c.updatedAt).getTime()<cS?i.push(c):l.push(c);return{starting:n,active:r,paused:o,imported:a,recent:i,older:l}}function em(t){const e=new Map,n=r=>{const o=r.insights?.context?.project?.trim(),a=r.insights?.context?.area?.trim(),i=o||"",l=a||"",c=new Set(["claudia","lattice","lattice orchestrator"]);return i&&l?c.has(i.toLowerCase())?l:i.toLowerCase()!==l.toLowerCase()?`${i} / ${l}`:i:i||l||r.workingDirectory?.split("/").filter(Boolean).pop()||"Ungrouped"};for(const r of t){const o=n(r);e.has(o)||e.set(o,[]),e.get(o).push(r)}return Array.from(e.entries()).sort((r,o)=>{if(r[0]==="Ungrouped")return 1;if(o[0]==="Ungrouped")return-1;const a=Math.max(...r[1].map(l=>new Date(l.updatedAt).getTime()));return Math.max(...o[1].map(l=>new Date(l.updatedAt).getTime()))-a})}function tm(t){const e=new Map;for(const n of t){const r=n.teamName?.trim()||"No Team";e.has(r)||e.set(r,[]),e.get(r).push(n)}return Array.from(e.entries()).sort((n,r)=>{if(n[0]==="No Team")return 1;if(r[0]==="No Team")return-1;const o=Math.max(...n[1].map(i=>new Date(i.updatedAt).getTime()));return Math.max(...r[1].map(i=>new Date(i.updatedAt).getTime()))-o})}function lS(t,e){const n=t.filter(a=>a.pinned),r=t.filter(a=>!a.pinned),o=[];for(const a of n)o.push(a.conversationId);if(e==="flat")for(const a of r)o.push(a.conversationId);else if(e==="relevance"){const a=Zp(r);for(const i of[a.starting,a.active,a.recent,a.paused,a.imported,a.older])for(const l of i)o.push(l.conversationId)}else if(e==="project"){const a=em(r);for(const[,i]of a)for(const l of i)o.push(l.conversationId)}else if(e==="team"){const a=tm(r);for(const[,i]of a)for(const l of i)o.push(l.conversationId)}return o}const ko="claudia-last-permission-mode",dS="claudia-last-new-session-provider";function uS({onNew:t,isLoading:e,defaultPermissionMode:n}){const r=n==="acceptEdits"?"acceptEdits":n==="bypassPermissions"?"bypassPermissions":"default",o=()=>{const m=localStorage.getItem(ko);return m==="bypassPermissions"?"bypassPermissions":m==="acceptEdits"?"acceptEdits":m==="default"?"default":r},a="claude",[i,l]=u.useState(o),c=m=>{l(m),localStorage.setItem(ko,m)},d=()=>{e||(localStorage.setItem(ko,i),localStorage.setItem(dS,a),t(a,i))},p=[{mode:"default",label:"Ask",icon:s.jsx(Ms,{size:12}),tone:"cyan",activeClasses:"border-cyan-500/50 bg-cyan-500/10 text-cyan-400",description:"Prompt before every tool use."},{mode:"bypassPermissions",label:"Trust",icon:s.jsx(mr,{size:12}),tone:"amber",activeClasses:"border-amber-500/50 bg-amber-500/10 text-amber-400",description:"Skip all permission prompts. Runs freely with no restrictions."}];return s.jsxs("div",{className:"relative flex flex-col gap-2",children:[s.jsxs("button",{onClick:d,disabled:e,className:"flex items-center justify-center gap-1.5 w-full py-1.5 rounded-sm border border-cyan-500/30 bg-background/60 text-cyan-400 cursor-pointer hover:border-cyan-400 hover:bg-cyan-500/5 hover:shadow-[2px_2px_0_rgba(0,255,255,0.45),-2px_-2px_0_rgba(168,85,247,0.25)] hover:translate-x-[-1px] hover:translate-y-[-1px] transition-all duration-100 disabled:opacity-40 disabled:pointer-events-none disabled:hover:shadow-none disabled:hover:translate-x-0 disabled:hover:translate-y-0",children:[s.jsx(Kl,{size:12}),s.jsx("span",{className:"text-[10px] font-display font-bold uppercase tracking-wider",children:"New Session"})]}),s.jsx("div",{className:"flex items-center justify-between",children:s.jsx(Ot,{delayDuration:0,skipDelayDuration:0,children:s.jsx("div",{className:"flex gap-1",children:p.map(({mode:m,label:h,icon:g,activeClasses:f,description:x})=>{const b=i===m;return s.jsxs(Ke,{disableHoverableContent:!0,children:[s.jsx(Qe,{asChild:!0,children:s.jsxs("button",{onClick:()=>c(m),disabled:e,className:`flex items-center gap-1 px-1.5 py-1 rounded-sm border cursor-pointer transition-all duration-100 disabled:opacity-40 disabled:pointer-events-none ${b?f:"border-border/25 bg-background/40 text-muted-foreground/50 hover:text-muted-foreground/80 hover:border-border/40"}`,children:[g,s.jsx("span",{className:"text-[10px] font-display font-bold uppercase tracking-wider",children:h})]})}),s.jsx(qe,{children:x})]},m)})})})})]})}const sm="lattice-sidebar-org-mode",nm="lattice-sidebar-collapsed";function pS(){const t=localStorage.getItem(sm);return t==="flat"||t==="relevance"||t==="project"||t==="team"?t:"relevance"}function mS(){try{const t=localStorage.getItem(nm);if(!t)return{};const e=Fs(t);if(!e||typeof e!="object")return{};const n={};for(const[r,o]of Object.entries(e))typeof o=="boolean"&&(n[r]=o);return n}catch{return{}}}function hS(t,e){const n=e.toLowerCase();return[t.customName,t.initialPrompt,t.insights?.context?.mission,t.insights?.purpose].some(o=>o&&o.toLowerCase().includes(n))}const jo={flat:{icon:s.jsx(yf,{size:14}),label:"Recency",description:"Single list by recent activity"},relevance:{icon:s.jsx(ql,{size:14}),label:"Relevance",description:"Grouped by active/idle context"},project:{icon:s.jsx(xh,{size:14}),label:"Project",description:"Grouped by project and area"},team:{icon:s.jsx(b0,{size:14}),label:"Team",description:"Grouped by team and agent progress"}},fS=["flat","relevance","project","team"];function pt({title:t,count:e,isCollapsed:n,onToggle:r,accentColor:o="text-muted-foreground/60",headerRight:a,tone:i="default",children:l}){const c=i==="muted";return s.jsxs("div",{children:[s.jsxs("button",{onClick:r,className:`w-full flex items-center gap-2 px-2.5 py-2 rounded-sm border transition-all duration-100 min-h-[40px] cursor-pointer ${c?"border-border/20 bg-background/20 hover:border-stone-400/25 hover:bg-stone-500/[0.04] active:bg-stone-500/[0.08]":"border-border/20 bg-background/25 hover:border-cyan-500/30 hover:bg-cyan-500/5 active:bg-cyan-500/10"}`,children:[s.jsx("span",{className:"text-muted-foreground/50",children:n?s.jsx(Ut,{size:14}):s.jsx(Lt,{size:14})}),s.jsx("span",{className:`${c?"text-[9px]":"text-[10px]"} font-display font-bold uppercase tracking-wider ${o}`,children:t}),s.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[a,s.jsx("span",{className:`px-1.5 py-0.5 rounded-sm border ${c?"text-[9px] border-border/20 text-muted-foreground/45":"text-[10px] border-border/25 text-muted-foreground/50"}`,children:e})]})]}),!n&&s.jsx("div",{className:`mt-1.5 space-y-2 pl-2 border-l ${c?"border-border/15":"border-border/20"}`,children:l})]})}function Ol(t){const e=t.trim().toLowerCase();return e==="blue"?"bg-sky-400":e==="green"?"bg-emerald-400":e==="yellow"?"bg-amber-400":e==="purple"?"bg-violet-400":"bg-cyan-400"}function gS({teamName:t,teamStatus:e}){const n=e?.progressPct??0,r=e?.agents??[],o=e?.counts.completed??0,a=e?.counts.running??0,i=r.length,l=i>0&&o>=i,c=i>0?`${o}/${i}`:"0/0";return s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"flex items-center gap-1",children:r.slice(0,6).map(d=>s.jsxs("span",{className:"relative inline-flex h-2 w-2",children:[d.status==="running"&&s.jsx("span",{className:`absolute inline-flex h-full w-full rounded-full animate-ping opacity-75 ${Ol(d.color)}`}),s.jsx("span",{className:`relative inline-flex h-2 w-2 rounded-full ${Ol(d.color)} ${d.status==="idle"?"opacity-35":""}`,title:`${d.agentName} (${d.status})`})]},`${t}:${d.agentName}`))}),s.jsx("div",{className:"h-1 w-14 overflow-hidden rounded-sm border border-border/30 bg-background/60",children:s.jsx("div",{className:`h-full transition-[width] duration-200 ${l?"bg-emerald-400/80":"bg-cyan-400/80"}`,style:{width:`${n}%`}})}),s.jsx("span",{className:`text-[9px] font-display font-bold tracking-wider ${l?"text-emerald-300/80":a>0?"text-cyan-300/80":"text-muted-foreground/60"}`,children:l?"✓ done":c})]})}function ai({currentSessionId:t,isOpen:e,onClose:n,onOpen:r}){const o=Nt(),a=mn(),{isPro:i}=yn(),{conversations:l,loading:c,recentActions:d,invalidateConversations:p,recentlyCompletedSessions:m}=$s(),{serverConfig:h}=zs(),[g,f]=u.useState(pS),[x,b]=u.useState(!1),[y,v]=u.useState(mS),[w,N]=u.useState({}),[S,T]=u.useState(""),C=u.useRef(null),j=u.useRef(null),E=u.useCallback(I=>{f(I),localStorage.setItem(sm,I),b(!1)},[]);u.useEffect(()=>{const I=P=>{j.current&&!j.current.contains(P.target)&&b(!1)};if(x)return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[x]);const A=u.useCallback((I,P=!1)=>{v(de=>{const X=de[I]??P,G={...de,[I]:!X};return localStorage.setItem(nm,JSON.stringify(G)),G})},[]),L=l.filter(I=>!I.archived).sort((I,P)=>new Date(P.updatedAt).getTime()-new Date(I.updatedAt).getTime()),$=y.archived??!0,{archivedSessions:oe,isLoading:ne}=Z2({enabled:e&&!$}),B=u.useMemo(()=>oe,[oe]),{teamStatuses:Q}=iS(L),q=u.useCallback(I=>{const P=I?.trim();if(P)return Q[P]},[Q]),Z=S?L.filter(I=>hS(I,S)):L,me=Z.filter(I=>I.pinned),O=Z.filter(I=>!I.pinned),W=u.useCallback(I=>{I.startsWith("pending-")||I!==t&&(o(`/c/${I}`),window.innerWidth<768&&n())},[t,o,n]),ee=u.useCallback((I,P)=>{N(de=>({...de,[I]:P}))},[]),z=u.useCallback(async I=>{const{conversationId:P}=I;if(!(!P||P.startsWith("pending-"))&&!w[P]){ee(P,"regenerate");try{await Promise.all([H.regenerateMission(P),H.unifiedUpdateConversation(P,{customName:""})]),await p()}catch(de){console.error("Failed to regenerate session name:",de)}finally{ee(P,void 0)}}},[p,ee,w]),re=u.useCallback(async(I,P)=>{const{conversationId:de}=I;if(!de||de.startsWith("pending-")||w[de])return;const X=P.trim();if(X){ee(de,"rename");try{await H.unifiedUpdateConversation(de,{customName:X}),await p()}catch(G){console.error("Failed to rename session:",G)}finally{ee(de,void 0)}}},[p,ee,w]),se=u.useCallback(async I=>{const{conversationId:P}=I;if(!(!P||P.startsWith("pending-")))try{await H.unifiedUpdateConversation(P,{pinned:!I.pinned}),await p()}catch(de){console.error("Failed to toggle pin:",de)}},[p]),te=u.useCallback(async I=>{if(!(!I||I.startsWith("pending-")))try{await H.unifiedUpdateConversation(I,{archived:!1}),await Promise.all([p(),a.invalidateQueries({queryKey:oi})])}catch(P){throw console.error("Failed to restore archived session:",P),P}},[p,a]),xe=u.useRef(null),_e=u.useCallback(async I=>{try{const P=await I.text(),de=Fs(P),X=await H.importSession(de);await p(),o(`/c/${X.conversationId}`)}catch(P){console.error("Failed to import session:",P),alert(`Import failed: ${P instanceof Error?P.message:"Unknown error"}`)}},[p,o]);return e?s.jsx(Ot,{children:s.jsxs("aside",{className:"relative w-full max-w-[420px] md:w-[420px] border-r border-cyan-500/20 bg-[radial-gradient(ellipse_at_top_left,rgba(6,182,212,0.08),transparent_45%),radial-gradient(ellipse_at_bottom_right,rgba(245,158,11,0.08),transparent_40%),rgba(41,37,36,0.9)] flex-shrink-0 flex flex-col h-full font-display backdrop-blur-sm",children:[s.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[linear-gradient(rgba(0,255,255,0.02)_1px,transparent_1px),linear-gradient(90deg,rgba(0,255,255,0.02)_1px,transparent_1px)] bg-[size:22px_22px]"}),s.jsxs("div",{className:"relative p-3 border-b border-border/30 flex items-center justify-between bg-background/30",children:[s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("span",{className:"text-xs font-display font-bold text-cyan-400/80 uppercase tracking-wider select-none",children:"Sessions"})}),s.jsx("div",{className:"flex items-center gap-1",children:s.jsxs(Ke,{children:[s.jsx(Qe,{asChild:!0,children:s.jsx("button",{onClick:n,className:"p-1.5 rounded-sm border border-border/30 bg-background/70 text-muted-foreground hover:text-cyan-400 hover:border-cyan-500/30 hover:bg-cyan-500/5 hover:shadow-[2px_2px_0_rgba(0,255,255,0.35),-2px_-2px_0_rgba(168,85,247,0.2)] hover:translate-x-[-1px] hover:translate-y-[-1px] transition-all duration-100 cursor-pointer","aria-label":"Close sidebar",children:s.jsx(zf,{size:14})})}),s.jsx(qe,{children:"Close sidebar"})]})})]}),s.jsx(tS,{}),s.jsx("div",{className:"relative p-2.5 border-b border-border/30 bg-zinc-800/40",children:s.jsx(uS,{onNew:(I,P)=>{o(`/new?provider=${I}&mode=${P}`),window.innerWidth<768&&n()},isLoading:!1,defaultPermissionMode:h?.defaultPermissionMode,defaultProvider:"claude"})}),s.jsx("div",{className:"relative px-2.5 pt-2 pb-1",children:s.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-sm border border-border/30 bg-background/30",children:[s.jsx(Ql,{size:12,className:"text-muted-foreground/40 flex-shrink-0"}),s.jsx("input",{ref:C,type:"text",value:S,onChange:I=>T(I.target.value),placeholder:"Search sessions...",className:"flex-1 bg-transparent text-[11px] font-mono text-foreground/90 placeholder:text-muted-foreground/30 outline-none"}),S&&s.jsx("button",{onClick:()=>{T(""),C.current?.focus()},className:"text-muted-foreground/40 hover:text-muted-foreground/70 transition-colors cursor-pointer",children:s.jsx(Be,{size:12})})]})}),s.jsxs("div",{className:"relative flex-1 overflow-y-auto p-2 space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between pb-1",children:[s.jsxs(Ke,{children:[s.jsx(Qe,{asChild:!0,children:s.jsxs("button",{onClick:()=>xe.current?.click(),className:"flex items-center gap-1 px-2 py-1 rounded-sm border border-border/25 bg-background/60 text-muted-foreground hover:text-cyan-300 hover:border-cyan-500/30 hover:bg-cyan-500/5 hover:shadow-[2px_2px_0_rgba(0,255,255,0.3)] hover:translate-x-[-1px] hover:translate-y-[-1px] transition-all duration-100 cursor-pointer","aria-label":"Import session",children:[s.jsx(Kn,{size:12}),s.jsx("span",{className:"text-[10px] font-display font-bold uppercase tracking-wider",children:"Import"})]})}),s.jsx(qe,{children:"Import a .lattice session file"})]}),s.jsx("input",{ref:xe,type:"file",accept:".lattice.json,.json",className:"hidden",onChange:I=>{const P=I.target.files?.[0];P&&(_e(P),I.target.value="")}}),s.jsxs("div",{ref:j,className:"relative",children:[s.jsxs(Ke,{children:[s.jsx(Qe,{asChild:!0,children:s.jsxs("button",{onClick:()=>b(I=>!I),className:"flex items-center gap-1.5 px-2.5 py-1 rounded-sm border border-border/25 bg-background/60 text-muted-foreground hover:text-cyan-300 hover:border-cyan-500/30 hover:bg-cyan-500/5 hover:shadow-[2px_2px_0_rgba(0,255,255,0.3)] hover:translate-x-[-1px] hover:translate-y-[-1px] transition-all duration-100 cursor-pointer","aria-label":"Select organization mode","aria-expanded":x,children:[jo[g].icon,s.jsx("span",{className:"text-[10px] font-display font-bold uppercase tracking-wider",children:jo[g].label}),s.jsx(Lt,{size:12,className:`transition-transform ${x?"rotate-180":""}`})]})}),s.jsx(qe,{children:"Choose organization mode"})]}),x&&s.jsx("div",{className:"absolute right-0 top-full mt-1 z-30 min-w-[220px] rounded-sm border border-border/40 bg-card/95 backdrop-blur-sm shadow-lg p-1",children:fS.map(I=>{const P=jo[I],de=I===g;return s.jsxs("button",{onClick:()=>E(I),className:`w-full text-left rounded-sm px-2 py-1.5 transition-colors cursor-pointer ${de?"bg-cyan-500/10 border border-cyan-500/30":"border border-transparent hover:bg-cyan-500/5 hover:border-cyan-500/20"}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:de?"text-cyan-300":"text-muted-foreground",children:P.icon}),s.jsx("span",{className:`text-[10px] font-display font-bold uppercase tracking-wider ${de?"text-cyan-300":"text-foreground/85"}`,children:P.label})]}),s.jsx("div",{className:`mt-0.5 text-[10px] ${de?"text-cyan-300/75":"text-muted-foreground/70"}`,children:P.description})]},I)})})]})]}),c?s.jsx("div",{className:"space-y-2",children:["session-skeleton-1","session-skeleton-2","session-skeleton-3"].map(I=>s.jsxs("div",{className:"rounded-sm border border-border/20 bg-background/30 overflow-hidden animate-pulse",children:[s.jsx("div",{className:"w-full h-12 bg-gradient-to-r from-muted/10 via-muted/20 to-muted/10"}),s.jsxs("div",{className:"p-2.5 space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-muted/30"}),s.jsx("div",{className:"w-6 h-2 rounded bg-muted/20"})]}),s.jsxs("div",{className:"border border-border/20 rounded-sm p-2 bg-muted/5",children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[s.jsx("div",{className:"w-3 h-3 rounded bg-muted/20"}),s.jsx("div",{className:"w-12 h-2 rounded bg-muted/20"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"h-2.5 w-full rounded bg-muted/15"}),s.jsx("div",{className:"h-2.5 w-4/5 rounded bg-muted/15"})]})]})]})]},I))}):S&&Z.length===0?s.jsxs("div",{className:"text-center text-muted-foreground/40 text-xs font-mono py-8 border border-dashed border-border/30 rounded-sm bg-background/20",children:["No sessions match “",S,"”"]}):L.length===0?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"text-center text-muted-foreground/50 text-sm py-8 border border-dashed border-border/30 rounded-sm bg-background/20",children:"No active sessions"}),s.jsx(pt,{title:"Archived",count:B.length,isCollapsed:$,onToggle:()=>A("archived",!0),accentColor:"text-stone-300/70",tone:"muted",children:s.jsx(Ml,{archivedSessions:B,currentSessionId:t,isLoading:ne,onSelectSession:W,onRestoreSession:te})})]}):s.jsxs(s.Fragment,{children:[me.length>0&&s.jsx(pt,{title:"Pinned",count:me.length,isCollapsed:y.pinned,onToggle:()=>A("pinned"),accentColor:"text-amber-400",children:me.map(I=>s.jsx(gt,{conversation:I,teamStatus:q(I.teamName),isCurrent:I.conversationId===t,onClick:()=>W(I.conversationId),recentActions:d[I.conversationId],recentlyCompleted:m.has(I.conversationId),onRenameSessionName:re,onRegenerateSessionName:i?z:void 0,isRenamingSessionName:w[I.conversationId]==="rename",isRegeneratingSessionName:w[I.conversationId]==="regenerate",onPin:se},I.conversationId))}),g==="flat"&&O.map(I=>s.jsx(gt,{conversation:I,teamStatus:q(I.teamName),isCurrent:I.conversationId===t,onClick:()=>W(I.conversationId),recentActions:d[I.conversationId],recentlyCompleted:m.has(I.conversationId),onRenameSessionName:re,onRegenerateSessionName:i?z:void 0,isRenamingSessionName:w[I.conversationId]==="rename",isRegeneratingSessionName:w[I.conversationId]==="regenerate",onPin:se},I.conversationId)),g==="relevance"&&(()=>{const I=Zp(O);return s.jsxs("div",{className:"space-y-3",children:[I.starting.length>0&&s.jsx(pt,{title:"Starting",count:I.starting.length,isCollapsed:y.starting,onToggle:()=>A("starting"),accentColor:"text-sky-400",children:I.starting.map(P=>s.jsx(gt,{conversation:P,isCurrent:P.conversationId===t,onClick:()=>W(P.conversationId),recentActions:d[P.conversationId]},P.conversationId))}),I.active.length>0&&s.jsx(pt,{title:"Active",count:I.active.length,isCollapsed:y.active,onToggle:()=>A("active"),accentColor:"text-green-400",children:I.active.map(P=>s.jsx(gt,{conversation:P,teamStatus:q(P.teamName),isCurrent:P.conversationId===t,onClick:()=>W(P.conversationId),recentActions:d[P.conversationId],onRenameSessionName:re,onRegenerateSessionName:i?z:void 0,isRenamingSessionName:w[P.conversationId]==="rename",isRegeneratingSessionName:w[P.conversationId]==="regenerate",onPin:se},P.conversationId))}),I.recent.length>0&&s.jsx(pt,{title:"Idle",count:I.recent.length,isCollapsed:y.recent,onToggle:()=>A("recent"),accentColor:"text-amber-400",children:I.recent.map(P=>s.jsx(gt,{conversation:P,teamStatus:q(P.teamName),isCurrent:P.conversationId===t,onClick:()=>W(P.conversationId),recentActions:d[P.conversationId],onRenameSessionName:re,onRegenerateSessionName:i?z:void 0,isRenamingSessionName:w[P.conversationId]==="rename",isRegeneratingSessionName:w[P.conversationId]==="regenerate",onPin:se},P.conversationId))}),I.paused.length>0&&s.jsx(pt,{title:"Paused",count:I.paused.length,isCollapsed:y.paused,onToggle:()=>A("paused"),accentColor:"text-violet-400",children:I.paused.map(P=>s.jsx(gt,{conversation:P,teamStatus:q(P.teamName),isCurrent:P.conversationId===t,onClick:()=>W(P.conversationId),recentActions:d[P.conversationId],recentlyCompleted:m.has(P.conversationId),onRenameSessionName:re,onRegenerateSessionName:i?z:void 0,isRenamingSessionName:w[P.conversationId]==="rename",isRegeneratingSessionName:w[P.conversationId]==="regenerate",onPin:se},P.conversationId))}),I.imported.length>0&&s.jsx(pt,{title:"Imported",count:I.imported.length,isCollapsed:y.imported,onToggle:()=>A("imported"),accentColor:"text-cyan-400",children:I.imported.map(P=>s.jsx(gt,{conversation:P,teamStatus:q(P.teamName),isCurrent:P.conversationId===t,onClick:()=>W(P.conversationId),recentActions:d[P.conversationId],onRenameSessionName:re,onRegenerateSessionName:i?z:void 0,isRenamingSessionName:w[P.conversationId]==="rename",isRegeneratingSessionName:w[P.conversationId]==="regenerate",onPin:se},P.conversationId))}),I.older.length>0&&s.jsx(pt,{title:"Older",count:I.older.length,isCollapsed:y.older??!0,onToggle:()=>A("older",!0),accentColor:"text-muted-foreground/50",children:I.older.map(P=>s.jsx(gt,{conversation:P,teamStatus:q(P.teamName),isCurrent:P.conversationId===t,onClick:()=>W(P.conversationId),recentActions:d[P.conversationId],onRenameSessionName:re,onRegenerateSessionName:i?z:void 0,isRenamingSessionName:w[P.conversationId]==="rename",isRegeneratingSessionName:w[P.conversationId]==="regenerate",onPin:se},P.conversationId))})]})})(),g==="project"&&(()=>{const I=em(O);return s.jsx("div",{className:"space-y-3",children:I.map(([P,de])=>s.jsx(pt,{title:P,count:de.length,isCollapsed:y[P],onToggle:()=>A(P),accentColor:P==="Ungrouped"?"text-muted-foreground/50":"text-cyan-400",children:de.map(X=>s.jsx(gt,{conversation:X,teamStatus:q(X.teamName),isCurrent:X.conversationId===t,onClick:()=>W(X.conversationId),recentActions:d[X.conversationId],onRenameSessionName:re,onRegenerateSessionName:i?z:void 0,isRenamingSessionName:w[X.conversationId]==="rename",isRegeneratingSessionName:w[X.conversationId]==="regenerate",onPin:se},X.conversationId))},P))})})(),g==="team"&&(()=>{const I=tm(O);return s.jsx("div",{className:"space-y-3",children:I.map(([P,de])=>s.jsx(pt,{title:P,count:de.length,isCollapsed:y[`team:${P}`],onToggle:()=>A(`team:${P}`),accentColor:P==="No Team"?"text-muted-foreground/50":"text-blue-300",headerRight:P==="No Team"?void 0:s.jsx(gS,{teamName:P,teamStatus:Q[P]}),children:de.map(X=>s.jsx(gt,{conversation:X,teamStatus:q(X.teamName),isCurrent:X.conversationId===t,onClick:()=>W(X.conversationId),recentActions:d[X.conversationId],onRenameSessionName:re,onRegenerateSessionName:i?z:void 0,isRenamingSessionName:w[X.conversationId]==="rename",isRegeneratingSessionName:w[X.conversationId]==="regenerate",onPin:se},X.conversationId))},P))})})(),s.jsx(pt,{title:"Archived",count:B.length,isCollapsed:$,onToggle:()=>A("archived",!0),accentColor:"text-stone-300/70",tone:"muted",children:s.jsx(Ml,{archivedSessions:B,currentSessionId:t,isLoading:ne,onSelectSession:W,onRestoreSession:te})})]})]})]})}):null}const No=[{path:"/prototype/new-session-empty-state",name:"New Session Empty State",category:"ui",created:"2026-03-07"},{path:"/prototype/new-session-controls",name:"New Session Controls",category:"ui",created:"2026-03-07"},{path:"/prototype/session-card-density",name:"Session Card Density",category:"ui",created:"2026-03-07"},{path:"/prototype/composer-status-input",name:"Composer Status + Input",category:"ui",created:"2026-02-11"},{path:"/prototype/new-session-variants",name:"New Session Variants",category:"ui",created:"2026-02-10"},{path:"/prototype/action-queue",name:"Action Queue",category:"ui",created:"2026-02-09"},{path:"/prototype/codex-activity-indicator",name:"Codex Activity Indicator",category:"ui",created:"2026-02-07"},{path:"/prototype/ask-question-variants",name:"Ask Question Variants",category:"ui",created:"2026-02-07"},{path:"/prototype/session-card-title",name:"Session Card Title",category:"ui",created:"2026-02-07"},{path:"/prototype/recommendation-cards",name:"Recommendation Cards",category:"ui",created:"2026-02-07"},{path:"/prototype/geist-pixel",name:"Geist Pixel",category:"ui",created:"2026-02-07"},{path:"/prototype/session-skeleton-variants",name:"Session Skeleton Variants",category:"ui",created:"2026-02-06"},{path:"/prototype/codex-thinking",name:"Codex Thinking",category:"ui",created:"2026-02-06"},{path:"/prototype/codex-thinking-pill",name:"Codex Thinking Pill",category:"ui",created:"2026-02-06"},{path:"/prototype/codex-thinking-active-variants",name:"Codex Thinking Active Variants",category:"ui",created:"2026-02-06"},{path:"/prototype/font-showcase",name:"Font Gallery",category:"banner",created:"2026-01-27"},{path:"/prototype/session-sidebar",name:"Session Sidebar Variations",category:"ui",created:"2026-01-27"},{path:"/prototype/timeline-card",name:"Timeline Cards",category:"ui",created:"2026-01-25"},{path:"/prototype/archived-card",name:"Archived Cards",category:"ui",created:"2026-01-25"},{path:"/prototype/toolbar",name:"Toolbar",category:"ui",created:"2026-01-24"},{path:"/prototype/menu-styles",name:"Menu Styles",category:"ui",created:"2026-01-24"},{path:"/prototype/smart-menu",name:"Smart Menu",category:"ui",created:"2026-01-24"},{path:"/prototype/mark-button",name:"Mark Button",category:"ui",created:"2026-01-21"},{path:"/prototype/session-start",name:"Session Start",category:"ui",created:"2026-01-18"},{path:"/prototype/permissions",name:"Permissions",category:"ui",created:"2026-01-18"},{path:"/prototype/styles",name:"Style Gallery",category:"banner",created:"2026-01-18"},{path:"/prototype/session-cards",name:"Session Cards",category:"banner",created:"2026-01-18"},{path:"/prototype/semantic",name:"Semantic Gallery",category:"banner",created:"2026-01-18"},{path:"/prototype/pipeline",name:"Pipeline Gallery",category:"banner",created:"2026-01-18"},{path:"/prototype/geometric",name:"Geometric Gallery",category:"banner",created:"2026-01-18"},{path:"/prototype/banners",name:"Banners",category:"banner",created:"2026-01-18"},{path:"/prototype/gallery",name:"Banner Gallery",category:"banner",created:"2026-01-18"},{path:"/prototype/permission-patterns",name:"Permission Patterns",category:"ui",created:"2026-01-18"}],xS={banner:{label:"BANNER / IDENTITY",icon:s.jsx(ql,{size:14}),textColor:"text-purple-400",borderColor:"border-purple-500/30",shadowColor:"rgba(168,85,247,0.5)"},ui:{label:"UI COMPONENTS",icon:s.jsx(To,{size:14}),textColor:"text-amber-400",borderColor:"border-amber-500/30",shadowColor:"rgba(251,191,36,0.5)"}};function bS(t){const e=new Date(t),r=Date.now()-e.getTime(),o=Math.floor(r/6e4),a=Math.floor(o/60),i=Math.floor(a/24);return o<1?"just now":o<60?`${o}m ago`:a<24?`${a}h ago`:i<7?`${i}d ago`:e.toLocaleDateString()}function yS({session:t,onRestore:e}){const{insights:n,updatedAt:r,conversationId:o,customName:a,identityImage:i}=t,l=a||n?.context?.mission||n?.purpose||o.slice(0,8);return s.jsxs("div",{className:"flex gap-3 group",children:[s.jsxs("div",{className:"flex flex-col items-center flex-shrink-0 pt-2",children:[s.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-rose-500/30 border-2 border-rose-500/50 group-hover:bg-rose-400 group-hover:border-rose-400 transition-colors"}),s.jsx("div",{className:"w-px flex-1 bg-border/30 mt-1"})]}),s.jsx("div",{className:"flex-1 pb-4 min-w-0",children:s.jsxs("div",{className:"rounded-lg border border-border/20 overflow-hidden hover:border-emerald-500/30 transition-all",children:[i?s.jsx("div",{className:"w-full h-16",style:{backgroundImage:`url(data:image/png;base64,${i})`,backgroundSize:"cover",backgroundPosition:"center"}}):s.jsx("div",{className:"w-full h-16 bg-gradient-to-r from-muted/10 via-muted/20 to-muted/10"}),s.jsxs("div",{className:"p-2.5 space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[10px] text-muted-foreground/40",children:bS(r)}),s.jsxs("div",{className:"flex flex-wrap gap-1 ml-auto",children:[n?.context?.scope&&s.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded uppercase tracking-wide font-medium ${n.context.scope==="major"?"bg-purple-500/10 text-purple-400":n.context.scope==="feature"?"bg-blue-500/10 text-blue-400":"bg-muted/30 text-muted-foreground/70"}`,children:n.context.scope}),n?.theme&&s.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded uppercase tracking-wide font-medium ${n.theme==="debugging"?"bg-orange-500/10 text-orange-400":n.theme==="firefighting"?"bg-red-500/10 text-red-400":n.theme==="building"?"bg-emerald-500/10 text-emerald-400":n.theme==="designing"?"bg-violet-500/10 text-violet-400":n.theme==="refactoring"?"bg-cyan-500/10 text-cyan-400":n.theme==="investigating"?"bg-sky-500/10 text-sky-400":n.theme==="polishing"?"bg-teal-500/10 text-teal-400":"bg-muted/30 text-muted-foreground/70"}`,children:n.theme}),n?.tags?.complexity&&n.tags.complexity!=="routine"&&s.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded uppercase tracking-wide font-medium ${n.tags.complexity==="gnarly"?"bg-red-500/10 text-red-400":"bg-amber-500/10 text-amber-400"}`,children:n.tags.complexity})]})]}),s.jsxs("div",{className:"border border-border/20 rounded-lg p-3 bg-muted/5",children:[s.jsxs("div",{className:"text-[11px] uppercase tracking-wider text-muted-foreground/50 mb-2 flex items-center gap-1.5",children:[s.jsx("span",{className:"text-xs leading-none",children:"🎯"}),"Mission"]}),s.jsx("div",{className:"text-xs leading-relaxed text-muted-foreground/70 line-clamp-2",children:l})]}),s.jsx("div",{className:"flex justify-end",children:s.jsxs("button",{onClick:e,className:`
|
|
366
366
|
flex items-center gap-1.5 px-3 py-1.5 rounded-lg cursor-pointer
|
|
367
367
|
bg-emerald-500/10 border border-emerald-500/30
|
|
368
368
|
text-[10px] font-display font-bold uppercase tracking-wider text-emerald-400
|
|
@@ -380,7 +380,7 @@ Be concise. The developer will read this alongside the user's bug report.`}funct
|
|
|
380
380
|
transition-all duration-100 group
|
|
381
381
|
no-underline hover:no-underline
|
|
382
382
|
${e.textColor}
|
|
383
|
-
`,style:{"--shadow-color":e.shadowColor},children:[s.jsx("div",{className:`p-1.5 rounded-sm border ${e.borderColor} opacity-60 group-hover:opacity-100 transition-opacity`,children:e.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("span",{className:"text-xs font-display font-bold uppercase tracking-wider text-foreground/70 group-hover:text-current transition-colors block truncate",children:t.name}),s.jsx("span",{className:"text-[9px] font-mono text-muted-foreground/40",children:vS(t.created)})]}),s.jsx(Ut,{size:12,className:"text-muted-foreground/20 group-hover:text-current transition-colors"})]})}const jS=10,NS=25;function SS(){const{devMode:t}=zs(),[e,n]=u.useState([]),[r,o]=u.useState(0),[a,i]=u.useState(0),[l,c]=u.useState(!1),[d,p]=u.useState(!1),[m,h]=u.useState("archived"),g=u.useRef(null),f=u.useCallback(async(b=!1)=>{b||e.length===0?c(!0):p(!0);try{const v=b?0:a,N=[...(await
|
|
383
|
+
`,style:{"--shadow-color":e.shadowColor},children:[s.jsx("div",{className:`p-1.5 rounded-sm border ${e.borderColor} opacity-60 group-hover:opacity-100 transition-opacity`,children:e.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("span",{className:"text-xs font-display font-bold uppercase tracking-wider text-foreground/70 group-hover:text-current transition-colors block truncate",children:t.name}),s.jsx("span",{className:"text-[9px] font-mono text-muted-foreground/40",children:vS(t.created)})]}),s.jsx(Ut,{size:12,className:"text-muted-foreground/20 group-hover:text-current transition-colors"})]})}const jS=10,NS=25;function SS(){const{devMode:t}=zs(),[e,n]=u.useState([]),[r,o]=u.useState(0),[a,i]=u.useState(0),[l,c]=u.useState(!1),[d,p]=u.useState(!1),[m,h]=u.useState("archived"),g=u.useRef(null),f=u.useCallback(async(b=!1)=>{b||e.length===0?c(!0):p(!0);try{const v=b?0:a,N=[...(await H.listUnifiedConversations({archived:!0,includeIdentityImage:!0})).conversations||[]].filter(T=>T.archived).sort((T,C)=>new Date(C.updatedAt).getTime()-new Date(T.updatedAt).getTime()),S=Math.min(N.length,b?jS:v+NS);n(N.slice(0,S)),i(S),o(N.length)}catch(v){console.error("Failed to fetch archived sessions:",v)}finally{c(!1),p(!1)}},[a,e.length]),x=async b=>{try{await H.unifiedUpdateConversation(b,{archived:!1}),n(y=>y.filter(v=>v.conversationId!==b)),o(y=>y-1)}catch(y){console.error("Failed to restore session:",y)}};return u.useEffect(()=>{if(m!=="archived")return;const b=new IntersectionObserver(v=>{const[w]=v;w.isIntersecting&&!l&&!d&&e.length<r&&f(!1)},{threshold:.1}),y=g.current;return y&&b.observe(y),()=>{y&&b.unobserve(y)}},[m,l,d,e.length,r,f]),u.useEffect(()=>{m==="archived"&&e.length===0&&!l&&f(!0)},[m]),s.jsxs("div",{className:"min-h-dvh bg-background text-foreground relative",children:[s.jsx("div",{className:"fixed inset-0 bg-[linear-gradient(rgba(0,255,255,0.02)_1px,transparent_1px),linear-gradient(90deg,rgba(0,255,255,0.02)_1px,transparent_1px)] bg-[size:24px_24px] pointer-events-none"}),s.jsx("header",{className:"relative border-b border-border/30 bg-card/80 backdrop-blur-md sticky top-0 z-10",children:s.jsxs("div",{className:"max-w-5xl mx-auto px-4 sm:px-6 py-3 sm:py-4 flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 min-w-0",children:[s.jsx(hn,{to:"/",className:`
|
|
384
384
|
p-2 -ml-2 rounded-sm flex-shrink-0
|
|
385
385
|
text-muted-foreground hover:text-cyan-400
|
|
386
386
|
hover:bg-cyan-500/10
|
|
@@ -405,7 +405,7 @@ Be concise. The developer will read this alongside the user's bug report.`}funct
|
|
|
405
405
|
hover:bg-rose-500/5
|
|
406
406
|
transition-all duration-100
|
|
407
407
|
disabled:opacity-50
|
|
408
|
-
`,children:[s.jsx(ds,{size:10,className:l?"animate-spin":""}),"Refresh"]})]}),l&&e.length===0?s.jsx("div",{className:"text-center py-16 text-muted-foreground/40 font-mono text-sm",children:"Loading archived sessions..."}):e.length===0?s.jsxs("div",{className:"text-center py-16",children:[s.jsx("p",{className:"text-muted-foreground/50 font-mono text-sm mb-2",children:"No archived sessions."}),s.jsx("p",{className:"text-muted-foreground/30 text-xs",children:"Archive sessions from the header to move them here."})]}):s.jsxs("div",{className:"max-w-xl ml-4",children:[e.map(b=>s.jsx(yS,{session:b,onRestore:()=>x(b.conversationId)},b.conversationId)),s.jsxs("div",{ref:g,className:"py-4 ml-5",children:[d&&s.jsxs("div",{className:"flex items-center justify-center gap-2 text-muted-foreground/40 text-sm",children:[s.jsx(Ae,{size:14,className:"animate-spin"}),s.jsx("span",{children:"Loading more..."})]}),!d&&e.length>=r&&e.length>0&&s.jsx("div",{className:"text-center text-muted-foreground/30 text-xs font-mono",children:"End of archived sessions"})]})]})]}):t?s.jsxs("div",{children:[s.jsx("div",{className:"flex items-center justify-between mb-6",children:s.jsxs("h2",{className:"flex items-center gap-2 text-sm font-display font-bold uppercase tracking-wider text-purple-400",children:[s.jsx(To,{size:14}),"Prototypes",s.jsxs("span",{className:"text-muted-foreground/30 text-[10px]",children:["(",No.length,")"]})]})}),s.jsx("div",{className:"space-y-6",children:_S(No).map(b=>s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[s.jsx("h3",{className:"text-[11px] font-mono font-semibold uppercase tracking-wider text-muted-foreground/60 whitespace-nowrap",children:b.label}),s.jsx("div",{className:"flex-1 h-px bg-muted-foreground/10"}),s.jsx("span",{className:"text-[9px] font-mono text-muted-foreground/30",children:b.prototypes.length})]}),s.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:b.prototypes.map(y=>{const v=xS[y.category];return s.jsx(kS,{prototype:y,categoryConfig:v},y.path)})})]},b.weekStart.toISOString()))})]}):null})]})}const So={date:"2026-01-02",title:"Initial Lattice Orchestrator Baseline",summary:"History starts from the initial baseline commit and tracks all Lattice Orchestrator versions from there forward."},CS=[{version:"v1.0.0",date:"2026-02-22",title:"1.0 Launch Hardening",summary:"Stability and platform-control release that finalized proxy-first AI routing and tightened unified session reliability.",highlights:["Centralized Anthropic routing with proxy/BYOK fallback selection.","Fixed pending-session redirect loops and stale-active reconciliation edges.","Added provider-switch divider guards and launch-mode settings controls."]},{version:"v0.13.0",date:"2026-02-21",title:"Codex Next Steps + Branch Reliability",summary:"Expanded Codex parity and branch correctness while adding stronger release validation coverage.",highlights:["Added NEXT_STEPS proposal flow support for Codex sessions.","Fixed branch history carryover and branch-lineage persistence regressions.","Introduced Playwright preflight E2E infrastructure for regression gates."]},{version:"v0.12.1",date:"2026-02-19",title:"Unified Sidebar + Branching Fixes",summary:"Focused bugfix release for conversation visibility and branch context consistency.",highlights:["Fixed unified-created sessions not appearing in the sidebar.","Resolved branching context loss and shared-message resolution edge cases.","Removed walkthrough UI runtime path and deprecated the backend surface."]},{version:"v0.11.23",date:"2026-02-16",title:"Queue Session + Mobile Controls",summary:"Large integration pass across queueing, mobile controls, and provider-auth workflows.",highlights:["Unified queue-session launches under the createConversation API path.","Added mobile pause/resume controls and header state polish.","Added Codex integration scaffolding and in-workspace provider auth updates."]},{version:"v0.11.0",date:"2026-02-12",title:"Unified Conversation Foundation",summary:"Major architecture cutover from legacy session routes to unified conversation flows.",highlights:["Added unified conversation backend routes and session controls.","Wired unified conversation flows through the chat interface.","Improved mixed-provider attribution and expanded regression test coverage."]},{version:"v0.10.0",date:"2026-02-07",title:"Next Steps + Codex Daemon Mode",summary:"Feature release centered on guided follow-up flows and Codex runtime support.",highlights:["Added Next Steps proposal generation and UI rendering.","Added daemon-mode support for Codex process execution.","Improved test isolation and singleton hygiene safeguards."]},{version:"v0.8.10",date:"2026-02-05",title:"Review UX Stabilization",summary:"Reliability pass for review surfaces, sidebar behavior, and interaction polish.",highlights:["Added missing ReviewContext provider and stabilized review rendering paths.","Improved sidebar behavior for hidden/retry edge cases.","Cleaned dead tests and resolved failing test paths."]},{version:"v0.7.0",date:"2026-01-28",title:"Lattice Orchestrator Identity Baseline",summary:"Identity and UX baseline that established the modern Lattice direction.",highlights:["Set Lattice Orchestrator naming and visual baseline.","Added migration and onboarding support for existing environments.","Laid groundwork for recommendation and plugin-era improvements."]},{version:"v0.1.1",date:"2026-01-09",title:"First Versioned Lattice Release",summary:"Initial versioned release cycle focused on packaging, runtime detection, and session stability.",highlights:["Added daemon/direct mode auto-detection for fresh installs.","Improved packaging/install behavior for CLI usage.","Stabilized early SSE and insights update behavior."]}],ES=[{version:"v1.0.0",date:"2026-02-22",summary:"Partner plan, proxy-first routing, settings lockdown; Add @types/semver"},{version:"v0.13.0",date:"2026-02-21",summary:"Fix archived filter bypass from queryParser boolean coercion; Recommendation batch: CLAUDE.md guardrails and regression tests"},{version:"v0.12.1",date:"2026-02-19",summary:"Remove walkthrough UI, mark backend deprecated; Fix branching context loss and shared message resolution"},{version:"v0.12.0",date:"2026-02-19",summary:"Include API endpoints in queue session prompt so agents can check off notes and recommendations; Align queue-session test with updated dev-note prompt format"},{version:"v0.11.23",date:"2026-02-16",summary:"Add Codex integration scaffolding and credential injection; Add deploy, release, and diagnostic skill definitions"},{version:"v0.11.22",date:"2026-02-15",summary:"Guard against empty hydration wipes; Add Claude OAuth PKCE login flow"},{version:"v0.11.16",date:"2026-02-15",summary:"Remove Codex credential export from setup transfer"},{version:"v0.11.15",date:"2026-02-15",summary:"Add in-workspace provider auth for Claude and Codex"},{version:"v0.11.13",date:"2026-02-14",summary:"Refine tooltips and permission labels; Update hygiene and archived defaults"},{version:"v0.11.12",date:"2026-02-14",summary:"Version bump and maintenance updates"},{version:"v0.11.11",date:"2026-02-14",summary:"Version bump and maintenance updates"},{version:"v0.11.10",date:"2026-02-14",summary:"Version bump and maintenance updates"},{version:"v0.11.8",date:"2026-02-14",summary:"Version bump and maintenance updates"},{version:"v0.11.7",date:"2026-02-14",summary:"Rollover codex thread after context-window exhaustion; Finalize cloud setup export and session stability fixes"},{version:"v0.11.6",date:"2026-02-13",summary:"Make default model configurable"},{version:"v0.11.5",date:"2026-02-13",summary:"Preserve sidebar active state during codex status lag; Add codex sidebar active-state regression coverage"},{version:"v0.11.4",date:"2026-02-13",summary:"Default new sessions to unarchived"},{version:"v0.11.3",date:"2026-02-13",summary:"Remove legacy empty sections + fix unified conv insights lookup; Resolve conv-* IDs at data access layer for insights lookups"},{version:"v0.11.2",date:"2026-02-12",summary:"AskUserQuestion UI: resolve conv-* IDs for pending questions + preserve is_error"},{version:"v0.11.1",date:"2026-02-12",summary:"Split conversation details hydration helpers; Fix spam: single owner + suppress when user is watching"},{version:"v0.11.0",date:"2026-02-12",summary:"Expand unified conversation coverage and tooling; Fix singleton mock timing and stale test assertions"},{version:"v0.10.1",date:"2026-02-08",summary:"Add artifacts explorer, design system, and session org modes prototypes; Add message extraction block composition and spawn tools response tests"},{version:"v0.10.0",date:"2026-02-07",summary:"Improve test isolation and add hygiene checks; Expand singleton hygiene check coverage"},{version:"v0.8.8",date:"2026-02-02",summary:"Improve debugging for permission hangs and log export; Dynamic plugin loading from config"},{version:"v0.8.10",date:"2026-02-05",summary:"Fix all test failures and remove dead tests; Remove duplicate sidebar toggle button"},{version:"v0.8.6",date:"2026-01-29",summary:"Version bump and maintenance updates"},{version:"v0.8.5",date:"2026-01-29",summary:"Fix MCP server name mismatch in runtime configuration"},{version:"v0.8.4",date:"2026-01-29",summary:"Fix RecommendationsCard to match prototype exactly; Capture projectPath when accepting recommendations"},{version:"v0.8.1",date:"2026-01-29",summary:"Version bump and maintenance updates"},{version:"v0.8.0",date:"2026-01-29",summary:"Migrate to target-based schema; Update UI to minimal card style"},{version:"v0.7.2",date:"2026-01-28",summary:"Improve tab title to show session mission/purpose"},{version:"v0.7.1",date:"2026-01-28",summary:"Version bump and maintenance updates"},{version:"v0.7.0",date:"2026-01-28",summary:"Apply font-display across UI components; Establish Lattice Orchestrator project naming baseline"},{version:"v0.5.0",date:"2026-01-25",summary:"Fix integration tests and add stdin timing test; Add DB fast path for archived sessions + responsive header buttons"},{version:"v0.2.10",date:"2026-01-22",summary:"Add copy button and show actions on mobile without hover; Preserve messageIds when replacing optimistic messages"},{version:"v0.2.9",date:"2026-01-21",summary:"Add prototype scaffolding script"},{version:"v0.2.8",date:"2026-01-21",summary:"Add typed session marks with turn context capture"},{version:"v0.2.7",date:"2026-01-21",summary:"Simplify banner generation with randomized style seeds; Add banner generation gallery endpoint for style testing"},{version:"v0.2.6",date:"2026-01-21",summary:"Type-ahead message queue with optimistic display; Enable send button during active sessions"},{version:"v0.2.5",date:"2026-01-18",summary:"Fix ASK mode being converted to YOLO in frontend"},{version:"v0.2.4",date:"2026-01-18",summary:"Enable ASK mode permission prompts on resume operations"},{version:"v0.2.3",date:"2026-01-18",summary:"Fix working directory resolution for paths containing hyphens"},{version:"v0.2.2",date:"2026-01-18",summary:"Fix resume crash when ASK mode used without MCP config"},{version:"v0.2.1",date:"2026-01-18",summary:"Always use CLI invocation directory as default working directory"},{version:"v0.2.0",date:"2026-01-18",summary:"Version bump and maintenance updates"},{version:"v0.1.15",date:"2026-01-18",summary:"Add MCP permission prompt tool for 'default' permission mode"},{version:"v0.1.14",date:"2026-01-18",summary:"Use CLI invocation directory as default working directory"},{version:"v0.1.13",date:"2026-01-18",summary:"Fix permission mode handling and turn capture JSON parsing"},{version:"v0.1.12",date:"2026-01-18",summary:"Fix loading skeleton to match current SessionCard banner layout; Improve session review with git-aware recommendations"},{version:"v0.1.11",date:"2026-01-12",summary:"Retry identity image generation on patch if mission now exists; Fix sessions briefly appearing active before moving to archive"},{version:"v0.1.10",date:"2026-01-12",summary:"Fix spawn-helper permissions for npx installs on macOS"},{version:"v0.1.9",date:"2026-01-12",summary:"Fix stale insights and improve active session detection; Fix repeated input focus, add limitations to README"},{version:"v0.1.8",date:"2026-01-11",summary:"Add feedback widget, update banner, and UI prototypes"},{version:"v0.1.7",date:"2026-01-11",summary:"Add V9 accumulative fields to database layer; Add heartbeat timeout to detect stale connections"},{version:"v0.1.6",date:"2026-01-09",summary:"Handle both npm and pnpm paths for spawn-helper chmod"},{version:"v0.1.5",date:"2026-01-09",summary:"Default new sessions to archived, unarchive when started from Lattice"},{version:"v0.1.4",date:"2026-01-09",summary:"Make dist/server.js executable in postinstall"},{version:"v0.1.3",date:"2026-01-09",summary:"Misc UI polish and fixes; Rebrand to Lattice + misc polish"},{version:"v0.1.2",date:"2026-01-09",summary:"Improve error message when Claude CLI is not installed"},{version:"v0.1.1",date:"2026-01-09",summary:"Add bundle analysis files to gitignore; Auto-detect daemon vs direct mode for fresh installs"}];function Co(t){return new Date(`${t}T00:00:00.000Z`).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"})}function TS(){return s.jsx("div",{className:"h-full overflow-y-auto bg-background",children:s.jsxs("div",{className:"mx-auto w-full max-w-5xl px-3 pb-8 pt-4 sm:px-6 sm:pb-12 sm:pt-6",children:[s.jsxs("header",{className:"sticky top-0 z-10 mb-5 flex flex-wrap items-center justify-between gap-3 border border-border/50 bg-background/95 px-3 py-3 backdrop-blur sm:mb-8 sm:px-4",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] font-display font-bold uppercase tracking-[0.16em] text-cyan-400",children:"Lattice Orchestrator"}),s.jsx("h1",{className:"mt-1 text-lg font-display font-bold text-foreground sm:text-2xl",children:"Changelog"})]}),s.jsx(hn,{to:"/",className:"inline-flex items-center rounded-sm border border-cyan-500/50 bg-cyan-500/10 px-3 py-2 text-[10px] font-display font-bold uppercase tracking-[0.14em] text-cyan-300 transition-colors hover:bg-cyan-500/20 sm:text-xs",children:"Open App"})]}),s.jsxs("section",{className:"rounded-sm border border-border/50 bg-card/70 p-4 sm:p-5",children:[s.jsx("p",{className:"text-[10px] font-display font-bold uppercase tracking-[0.14em] text-muted-foreground",children:"Timeline Start"}),s.jsx("p",{className:"mt-2 text-base font-display font-bold text-foreground sm:text-lg",children:So.title}),s.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:So.summary}),s.jsxs("p",{className:"mt-3 text-xs uppercase tracking-[0.12em] text-muted-foreground",children:[Co(So.date)," baseline"]})]}),s.jsxs("section",{className:"mt-6 sm:mt-8",children:[s.jsx("p",{className:"mb-3 text-[10px] font-display font-bold uppercase tracking-[0.16em] text-amber-400",children:"Release Milestones"}),s.jsx("ol",{className:"space-y-3 sm:space-y-4",children:CS.map(t=>s.jsxs("li",{className:"rounded-sm border border-border/50 bg-card/70 p-4 sm:p-5",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsx("p",{className:"text-xs font-display font-bold uppercase tracking-[0.14em] text-cyan-300",children:t.version}),s.jsx("p",{className:"text-[11px] uppercase tracking-[0.12em] text-muted-foreground",children:Co(t.date)})]}),s.jsx("h2",{className:"mt-2 text-base font-display font-bold text-foreground sm:text-lg",children:t.title}),s.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:t.summary}),s.jsx("ul",{className:"mt-3 space-y-2",children:t.highlights.map(e=>s.jsxs("li",{className:"flex items-start gap-2 text-sm text-foreground",children:[s.jsx("span",{className:"mt-1.5 h-1.5 w-1.5 rounded-full bg-amber-400"}),s.jsx("span",{className:"break-words",children:e})]},e))})]},t.version))})]}),s.jsxs("section",{className:"mt-6 sm:mt-8",children:[s.jsx("p",{className:"mb-3 text-[10px] font-display font-bold uppercase tracking-[0.16em] text-purple-300",children:"Version Ledger"}),s.jsxs("div",{className:"overflow-hidden rounded-sm border border-border/50 bg-card/70",children:[s.jsx("div",{className:"border-b border-border/40 px-3 py-2 text-[10px] uppercase tracking-[0.13em] text-muted-foreground sm:px-4",children:"Version-by-version history from baseline to current release."}),s.jsx("ul",{className:"max-h-[56vh] divide-y divide-border/40 overflow-y-auto sm:max-h-[62vh]",children:ES.map(t=>s.jsxs("li",{className:"px-3 py-3 sm:px-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsx("p",{className:"text-xs font-display font-bold uppercase tracking-[0.13em] text-cyan-300",children:t.version}),s.jsx("p",{className:"text-[11px] uppercase tracking-[0.12em] text-muted-foreground",children:Co(t.date)})]}),s.jsx("p",{className:"mt-1 break-words text-sm text-foreground/90",children:t.summary})]},t.version))})]})]})]})})}class IS{diff(e,n,r={}){let o;typeof r=="function"?(o=r,r={}):"callback"in r&&(o=r.callback);const a=this.castInput(e,r),i=this.castInput(n,r),l=this.removeEmpty(this.tokenize(a,r)),c=this.removeEmpty(this.tokenize(i,r));return this.diffWithOptionsObj(l,c,r,o)}diffWithOptionsObj(e,n,r,o){var a;const i=v=>{if(v=this.postProcess(v,r),o){setTimeout(function(){o(v)},0);return}else return v},l=n.length,c=e.length;let d=1,p=l+c;r.maxEditLength!=null&&(p=Math.min(p,r.maxEditLength));const m=(a=r.timeout)!==null&&a!==void 0?a:1/0,h=Date.now()+m,g=[{oldPos:-1,lastComponent:void 0}];let f=this.extractCommon(g[0],n,e,0,r);if(g[0].oldPos+1>=c&&f+1>=l)return i(this.buildValues(g[0].lastComponent,n,e));let x=-1/0,b=1/0;const y=()=>{for(let v=Math.max(x,-d);v<=Math.min(b,d);v+=2){let w;const N=g[v-1],S=g[v+1];N&&(g[v-1]=void 0);let T=!1;if(S){const j=S.oldPos-v;T=S&&0<=j&&j<l}const C=N&&N.oldPos+1<c;if(!T&&!C){g[v]=void 0;continue}if(!C||T&&N.oldPos<S.oldPos?w=this.addToPath(S,!0,!1,0,r):w=this.addToPath(N,!1,!0,1,r),f=this.extractCommon(w,n,e,v,r),w.oldPos+1>=c&&f+1>=l)return i(this.buildValues(w.lastComponent,n,e))||!0;g[v]=w,w.oldPos+1>=c&&(b=Math.min(b,v-1)),f+1>=l&&(x=Math.max(x,v+1))}d++};if(o)(function v(){setTimeout(function(){if(d>p||Date.now()>h)return o(void 0);y()||v()},0)})();else for(;d<=p&&Date.now()<=h;){const v=y();if(v)return v}}addToPath(e,n,r,o,a){const i=e.lastComponent;return i&&!a.oneChangePerToken&&i.added===n&&i.removed===r?{oldPos:e.oldPos+o,lastComponent:{count:i.count+1,added:n,removed:r,previousComponent:i.previousComponent}}:{oldPos:e.oldPos+o,lastComponent:{count:1,added:n,removed:r,previousComponent:i}}}extractCommon(e,n,r,o,a){const i=n.length,l=r.length;let c=e.oldPos,d=c-o,p=0;for(;d+1<i&&c+1<l&&this.equals(r[c+1],n[d+1],a);)d++,c++,p++,a.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return p&&!a.oneChangePerToken&&(e.lastComponent={count:p,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=c,d}equals(e,n,r){return r.comparator?r.comparator(e,n):e===n||!!r.ignoreCase&&e.toLowerCase()===n.toLowerCase()}removeEmpty(e){const n=[];for(let r=0;r<e.length;r++)e[r]&&n.push(e[r]);return n}castInput(e,n){return e}tokenize(e,n){return Array.from(e)}join(e){return e.join("")}postProcess(e,n){return e}get useLongestToken(){return!1}buildValues(e,n,r){const o=[];let a;for(;e;)o.push(e),a=e.previousComponent,delete e.previousComponent,e=a;o.reverse();const i=o.length;let l=0,c=0,d=0;for(;l<i;l++){const p=o[l];if(p.removed)p.value=this.join(r.slice(d,d+p.count)),d+=p.count;else{if(!p.added&&this.useLongestToken){let m=n.slice(c,c+p.count);m=m.map(function(h,g){const f=r[d+g];return f.length>h.length?f:h}),p.value=this.join(m)}else p.value=this.join(n.slice(c,c+p.count));c+=p.count,p.added||(d+=p.count)}}return o}}class AS extends IS{constructor(){super(...arguments),this.tokenize=MS}equals(e,n,r){return r.ignoreWhitespace?((!r.newlineIsToken||!e.includes(`
|
|
408
|
+
`,children:[s.jsx(ds,{size:10,className:l?"animate-spin":""}),"Refresh"]})]}),l&&e.length===0?s.jsx("div",{className:"text-center py-16 text-muted-foreground/40 font-mono text-sm",children:"Loading archived sessions..."}):e.length===0?s.jsxs("div",{className:"text-center py-16",children:[s.jsx("p",{className:"text-muted-foreground/50 font-mono text-sm mb-2",children:"No archived sessions."}),s.jsx("p",{className:"text-muted-foreground/30 text-xs",children:"Archive sessions from the header to move them here."})]}):s.jsxs("div",{className:"max-w-xl ml-4",children:[e.map(b=>s.jsx(yS,{session:b,onRestore:()=>x(b.conversationId)},b.conversationId)),s.jsxs("div",{ref:g,className:"py-4 ml-5",children:[d&&s.jsxs("div",{className:"flex items-center justify-center gap-2 text-muted-foreground/40 text-sm",children:[s.jsx(Re,{size:14,className:"animate-spin"}),s.jsx("span",{children:"Loading more..."})]}),!d&&e.length>=r&&e.length>0&&s.jsx("div",{className:"text-center text-muted-foreground/30 text-xs font-mono",children:"End of archived sessions"})]})]})]}):t?s.jsxs("div",{children:[s.jsx("div",{className:"flex items-center justify-between mb-6",children:s.jsxs("h2",{className:"flex items-center gap-2 text-sm font-display font-bold uppercase tracking-wider text-purple-400",children:[s.jsx(To,{size:14}),"Prototypes",s.jsxs("span",{className:"text-muted-foreground/30 text-[10px]",children:["(",No.length,")"]})]})}),s.jsx("div",{className:"space-y-6",children:_S(No).map(b=>s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[s.jsx("h3",{className:"text-[11px] font-mono font-semibold uppercase tracking-wider text-muted-foreground/60 whitespace-nowrap",children:b.label}),s.jsx("div",{className:"flex-1 h-px bg-muted-foreground/10"}),s.jsx("span",{className:"text-[9px] font-mono text-muted-foreground/30",children:b.prototypes.length})]}),s.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:b.prototypes.map(y=>{const v=xS[y.category];return s.jsx(kS,{prototype:y,categoryConfig:v},y.path)})})]},b.weekStart.toISOString()))})]}):null})]})}const So={date:"2026-01-02",title:"Initial Lattice Orchestrator Baseline",summary:"History starts from the initial baseline commit and tracks all Lattice Orchestrator versions from there forward."},CS=[{version:"v1.0.0",date:"2026-02-22",title:"1.0 Launch Hardening",summary:"Stability and platform-control release that finalized proxy-first AI routing and tightened unified session reliability.",highlights:["Centralized Anthropic routing with proxy/BYOK fallback selection.","Fixed pending-session redirect loops and stale-active reconciliation edges.","Added provider-switch divider guards and launch-mode settings controls."]},{version:"v0.13.0",date:"2026-02-21",title:"Codex Next Steps + Branch Reliability",summary:"Expanded Codex parity and branch correctness while adding stronger release validation coverage.",highlights:["Added NEXT_STEPS proposal flow support for Codex sessions.","Fixed branch history carryover and branch-lineage persistence regressions.","Introduced Playwright preflight E2E infrastructure for regression gates."]},{version:"v0.12.1",date:"2026-02-19",title:"Unified Sidebar + Branching Fixes",summary:"Focused bugfix release for conversation visibility and branch context consistency.",highlights:["Fixed unified-created sessions not appearing in the sidebar.","Resolved branching context loss and shared-message resolution edge cases.","Removed walkthrough UI runtime path and deprecated the backend surface."]},{version:"v0.11.23",date:"2026-02-16",title:"Queue Session + Mobile Controls",summary:"Large integration pass across queueing, mobile controls, and provider-auth workflows.",highlights:["Unified queue-session launches under the createConversation API path.","Added mobile pause/resume controls and header state polish.","Added Codex integration scaffolding and in-workspace provider auth updates."]},{version:"v0.11.0",date:"2026-02-12",title:"Unified Conversation Foundation",summary:"Major architecture cutover from legacy session routes to unified conversation flows.",highlights:["Added unified conversation backend routes and session controls.","Wired unified conversation flows through the chat interface.","Improved mixed-provider attribution and expanded regression test coverage."]},{version:"v0.10.0",date:"2026-02-07",title:"Next Steps + Codex Daemon Mode",summary:"Feature release centered on guided follow-up flows and Codex runtime support.",highlights:["Added Next Steps proposal generation and UI rendering.","Added daemon-mode support for Codex process execution.","Improved test isolation and singleton hygiene safeguards."]},{version:"v0.8.10",date:"2026-02-05",title:"Review UX Stabilization",summary:"Reliability pass for review surfaces, sidebar behavior, and interaction polish.",highlights:["Added missing ReviewContext provider and stabilized review rendering paths.","Improved sidebar behavior for hidden/retry edge cases.","Cleaned dead tests and resolved failing test paths."]},{version:"v0.7.0",date:"2026-01-28",title:"Lattice Orchestrator Identity Baseline",summary:"Identity and UX baseline that established the modern Lattice direction.",highlights:["Set Lattice Orchestrator naming and visual baseline.","Added migration and onboarding support for existing environments.","Laid groundwork for recommendation and plugin-era improvements."]},{version:"v0.1.1",date:"2026-01-09",title:"First Versioned Lattice Release",summary:"Initial versioned release cycle focused on packaging, runtime detection, and session stability.",highlights:["Added daemon/direct mode auto-detection for fresh installs.","Improved packaging/install behavior for CLI usage.","Stabilized early SSE and insights update behavior."]}],ES=[{version:"v1.0.0",date:"2026-02-22",summary:"Partner plan, proxy-first routing, settings lockdown; Add @types/semver"},{version:"v0.13.0",date:"2026-02-21",summary:"Fix archived filter bypass from queryParser boolean coercion; Recommendation batch: CLAUDE.md guardrails and regression tests"},{version:"v0.12.1",date:"2026-02-19",summary:"Remove walkthrough UI, mark backend deprecated; Fix branching context loss and shared message resolution"},{version:"v0.12.0",date:"2026-02-19",summary:"Include API endpoints in queue session prompt so agents can check off notes and recommendations; Align queue-session test with updated dev-note prompt format"},{version:"v0.11.23",date:"2026-02-16",summary:"Add Codex integration scaffolding and credential injection; Add deploy, release, and diagnostic skill definitions"},{version:"v0.11.22",date:"2026-02-15",summary:"Guard against empty hydration wipes; Add Claude OAuth PKCE login flow"},{version:"v0.11.16",date:"2026-02-15",summary:"Remove Codex credential export from setup transfer"},{version:"v0.11.15",date:"2026-02-15",summary:"Add in-workspace provider auth for Claude and Codex"},{version:"v0.11.13",date:"2026-02-14",summary:"Refine tooltips and permission labels; Update hygiene and archived defaults"},{version:"v0.11.12",date:"2026-02-14",summary:"Version bump and maintenance updates"},{version:"v0.11.11",date:"2026-02-14",summary:"Version bump and maintenance updates"},{version:"v0.11.10",date:"2026-02-14",summary:"Version bump and maintenance updates"},{version:"v0.11.8",date:"2026-02-14",summary:"Version bump and maintenance updates"},{version:"v0.11.7",date:"2026-02-14",summary:"Rollover codex thread after context-window exhaustion; Finalize cloud setup export and session stability fixes"},{version:"v0.11.6",date:"2026-02-13",summary:"Make default model configurable"},{version:"v0.11.5",date:"2026-02-13",summary:"Preserve sidebar active state during codex status lag; Add codex sidebar active-state regression coverage"},{version:"v0.11.4",date:"2026-02-13",summary:"Default new sessions to unarchived"},{version:"v0.11.3",date:"2026-02-13",summary:"Remove legacy empty sections + fix unified conv insights lookup; Resolve conv-* IDs at data access layer for insights lookups"},{version:"v0.11.2",date:"2026-02-12",summary:"AskUserQuestion UI: resolve conv-* IDs for pending questions + preserve is_error"},{version:"v0.11.1",date:"2026-02-12",summary:"Split conversation details hydration helpers; Fix spam: single owner + suppress when user is watching"},{version:"v0.11.0",date:"2026-02-12",summary:"Expand unified conversation coverage and tooling; Fix singleton mock timing and stale test assertions"},{version:"v0.10.1",date:"2026-02-08",summary:"Add artifacts explorer, design system, and session org modes prototypes; Add message extraction block composition and spawn tools response tests"},{version:"v0.10.0",date:"2026-02-07",summary:"Improve test isolation and add hygiene checks; Expand singleton hygiene check coverage"},{version:"v0.8.8",date:"2026-02-02",summary:"Improve debugging for permission hangs and log export; Dynamic plugin loading from config"},{version:"v0.8.10",date:"2026-02-05",summary:"Fix all test failures and remove dead tests; Remove duplicate sidebar toggle button"},{version:"v0.8.6",date:"2026-01-29",summary:"Version bump and maintenance updates"},{version:"v0.8.5",date:"2026-01-29",summary:"Fix MCP server name mismatch in runtime configuration"},{version:"v0.8.4",date:"2026-01-29",summary:"Fix RecommendationsCard to match prototype exactly; Capture projectPath when accepting recommendations"},{version:"v0.8.1",date:"2026-01-29",summary:"Version bump and maintenance updates"},{version:"v0.8.0",date:"2026-01-29",summary:"Migrate to target-based schema; Update UI to minimal card style"},{version:"v0.7.2",date:"2026-01-28",summary:"Improve tab title to show session mission/purpose"},{version:"v0.7.1",date:"2026-01-28",summary:"Version bump and maintenance updates"},{version:"v0.7.0",date:"2026-01-28",summary:"Apply font-display across UI components; Establish Lattice Orchestrator project naming baseline"},{version:"v0.5.0",date:"2026-01-25",summary:"Fix integration tests and add stdin timing test; Add DB fast path for archived sessions + responsive header buttons"},{version:"v0.2.10",date:"2026-01-22",summary:"Add copy button and show actions on mobile without hover; Preserve messageIds when replacing optimistic messages"},{version:"v0.2.9",date:"2026-01-21",summary:"Add prototype scaffolding script"},{version:"v0.2.8",date:"2026-01-21",summary:"Add typed session marks with turn context capture"},{version:"v0.2.7",date:"2026-01-21",summary:"Simplify banner generation with randomized style seeds; Add banner generation gallery endpoint for style testing"},{version:"v0.2.6",date:"2026-01-21",summary:"Type-ahead message queue with optimistic display; Enable send button during active sessions"},{version:"v0.2.5",date:"2026-01-18",summary:"Fix ASK mode being converted to YOLO in frontend"},{version:"v0.2.4",date:"2026-01-18",summary:"Enable ASK mode permission prompts on resume operations"},{version:"v0.2.3",date:"2026-01-18",summary:"Fix working directory resolution for paths containing hyphens"},{version:"v0.2.2",date:"2026-01-18",summary:"Fix resume crash when ASK mode used without MCP config"},{version:"v0.2.1",date:"2026-01-18",summary:"Always use CLI invocation directory as default working directory"},{version:"v0.2.0",date:"2026-01-18",summary:"Version bump and maintenance updates"},{version:"v0.1.15",date:"2026-01-18",summary:"Add MCP permission prompt tool for 'default' permission mode"},{version:"v0.1.14",date:"2026-01-18",summary:"Use CLI invocation directory as default working directory"},{version:"v0.1.13",date:"2026-01-18",summary:"Fix permission mode handling and turn capture JSON parsing"},{version:"v0.1.12",date:"2026-01-18",summary:"Fix loading skeleton to match current SessionCard banner layout; Improve session review with git-aware recommendations"},{version:"v0.1.11",date:"2026-01-12",summary:"Retry identity image generation on patch if mission now exists; Fix sessions briefly appearing active before moving to archive"},{version:"v0.1.10",date:"2026-01-12",summary:"Fix spawn-helper permissions for npx installs on macOS"},{version:"v0.1.9",date:"2026-01-12",summary:"Fix stale insights and improve active session detection; Fix repeated input focus, add limitations to README"},{version:"v0.1.8",date:"2026-01-11",summary:"Add feedback widget, update banner, and UI prototypes"},{version:"v0.1.7",date:"2026-01-11",summary:"Add V9 accumulative fields to database layer; Add heartbeat timeout to detect stale connections"},{version:"v0.1.6",date:"2026-01-09",summary:"Handle both npm and pnpm paths for spawn-helper chmod"},{version:"v0.1.5",date:"2026-01-09",summary:"Default new sessions to archived, unarchive when started from Lattice"},{version:"v0.1.4",date:"2026-01-09",summary:"Make dist/server.js executable in postinstall"},{version:"v0.1.3",date:"2026-01-09",summary:"Misc UI polish and fixes; Rebrand to Lattice + misc polish"},{version:"v0.1.2",date:"2026-01-09",summary:"Improve error message when Claude CLI is not installed"},{version:"v0.1.1",date:"2026-01-09",summary:"Add bundle analysis files to gitignore; Auto-detect daemon vs direct mode for fresh installs"}];function Co(t){return new Date(`${t}T00:00:00.000Z`).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"})}function TS(){return s.jsx("div",{className:"h-full overflow-y-auto bg-background",children:s.jsxs("div",{className:"mx-auto w-full max-w-5xl px-3 pb-8 pt-4 sm:px-6 sm:pb-12 sm:pt-6",children:[s.jsxs("header",{className:"sticky top-0 z-10 mb-5 flex flex-wrap items-center justify-between gap-3 border border-border/50 bg-background/95 px-3 py-3 backdrop-blur sm:mb-8 sm:px-4",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] font-display font-bold uppercase tracking-[0.16em] text-cyan-400",children:"Lattice Orchestrator"}),s.jsx("h1",{className:"mt-1 text-lg font-display font-bold text-foreground sm:text-2xl",children:"Changelog"})]}),s.jsx(hn,{to:"/",className:"inline-flex items-center rounded-sm border border-cyan-500/50 bg-cyan-500/10 px-3 py-2 text-[10px] font-display font-bold uppercase tracking-[0.14em] text-cyan-300 transition-colors hover:bg-cyan-500/20 sm:text-xs",children:"Open App"})]}),s.jsxs("section",{className:"rounded-sm border border-border/50 bg-card/70 p-4 sm:p-5",children:[s.jsx("p",{className:"text-[10px] font-display font-bold uppercase tracking-[0.14em] text-muted-foreground",children:"Timeline Start"}),s.jsx("p",{className:"mt-2 text-base font-display font-bold text-foreground sm:text-lg",children:So.title}),s.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:So.summary}),s.jsxs("p",{className:"mt-3 text-xs uppercase tracking-[0.12em] text-muted-foreground",children:[Co(So.date)," baseline"]})]}),s.jsxs("section",{className:"mt-6 sm:mt-8",children:[s.jsx("p",{className:"mb-3 text-[10px] font-display font-bold uppercase tracking-[0.16em] text-amber-400",children:"Release Milestones"}),s.jsx("ol",{className:"space-y-3 sm:space-y-4",children:CS.map(t=>s.jsxs("li",{className:"rounded-sm border border-border/50 bg-card/70 p-4 sm:p-5",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsx("p",{className:"text-xs font-display font-bold uppercase tracking-[0.14em] text-cyan-300",children:t.version}),s.jsx("p",{className:"text-[11px] uppercase tracking-[0.12em] text-muted-foreground",children:Co(t.date)})]}),s.jsx("h2",{className:"mt-2 text-base font-display font-bold text-foreground sm:text-lg",children:t.title}),s.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:t.summary}),s.jsx("ul",{className:"mt-3 space-y-2",children:t.highlights.map(e=>s.jsxs("li",{className:"flex items-start gap-2 text-sm text-foreground",children:[s.jsx("span",{className:"mt-1.5 h-1.5 w-1.5 rounded-full bg-amber-400"}),s.jsx("span",{className:"break-words",children:e})]},e))})]},t.version))})]}),s.jsxs("section",{className:"mt-6 sm:mt-8",children:[s.jsx("p",{className:"mb-3 text-[10px] font-display font-bold uppercase tracking-[0.16em] text-purple-300",children:"Version Ledger"}),s.jsxs("div",{className:"overflow-hidden rounded-sm border border-border/50 bg-card/70",children:[s.jsx("div",{className:"border-b border-border/40 px-3 py-2 text-[10px] uppercase tracking-[0.13em] text-muted-foreground sm:px-4",children:"Version-by-version history from baseline to current release."}),s.jsx("ul",{className:"max-h-[56vh] divide-y divide-border/40 overflow-y-auto sm:max-h-[62vh]",children:ES.map(t=>s.jsxs("li",{className:"px-3 py-3 sm:px-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsx("p",{className:"text-xs font-display font-bold uppercase tracking-[0.13em] text-cyan-300",children:t.version}),s.jsx("p",{className:"text-[11px] uppercase tracking-[0.12em] text-muted-foreground",children:Co(t.date)})]}),s.jsx("p",{className:"mt-1 break-words text-sm text-foreground/90",children:t.summary})]},t.version))})]})]})]})})}class IS{diff(e,n,r={}){let o;typeof r=="function"?(o=r,r={}):"callback"in r&&(o=r.callback);const a=this.castInput(e,r),i=this.castInput(n,r),l=this.removeEmpty(this.tokenize(a,r)),c=this.removeEmpty(this.tokenize(i,r));return this.diffWithOptionsObj(l,c,r,o)}diffWithOptionsObj(e,n,r,o){var a;const i=v=>{if(v=this.postProcess(v,r),o){setTimeout(function(){o(v)},0);return}else return v},l=n.length,c=e.length;let d=1,p=l+c;r.maxEditLength!=null&&(p=Math.min(p,r.maxEditLength));const m=(a=r.timeout)!==null&&a!==void 0?a:1/0,h=Date.now()+m,g=[{oldPos:-1,lastComponent:void 0}];let f=this.extractCommon(g[0],n,e,0,r);if(g[0].oldPos+1>=c&&f+1>=l)return i(this.buildValues(g[0].lastComponent,n,e));let x=-1/0,b=1/0;const y=()=>{for(let v=Math.max(x,-d);v<=Math.min(b,d);v+=2){let w;const N=g[v-1],S=g[v+1];N&&(g[v-1]=void 0);let T=!1;if(S){const j=S.oldPos-v;T=S&&0<=j&&j<l}const C=N&&N.oldPos+1<c;if(!T&&!C){g[v]=void 0;continue}if(!C||T&&N.oldPos<S.oldPos?w=this.addToPath(S,!0,!1,0,r):w=this.addToPath(N,!1,!0,1,r),f=this.extractCommon(w,n,e,v,r),w.oldPos+1>=c&&f+1>=l)return i(this.buildValues(w.lastComponent,n,e))||!0;g[v]=w,w.oldPos+1>=c&&(b=Math.min(b,v-1)),f+1>=l&&(x=Math.max(x,v+1))}d++};if(o)(function v(){setTimeout(function(){if(d>p||Date.now()>h)return o(void 0);y()||v()},0)})();else for(;d<=p&&Date.now()<=h;){const v=y();if(v)return v}}addToPath(e,n,r,o,a){const i=e.lastComponent;return i&&!a.oneChangePerToken&&i.added===n&&i.removed===r?{oldPos:e.oldPos+o,lastComponent:{count:i.count+1,added:n,removed:r,previousComponent:i.previousComponent}}:{oldPos:e.oldPos+o,lastComponent:{count:1,added:n,removed:r,previousComponent:i}}}extractCommon(e,n,r,o,a){const i=n.length,l=r.length;let c=e.oldPos,d=c-o,p=0;for(;d+1<i&&c+1<l&&this.equals(r[c+1],n[d+1],a);)d++,c++,p++,a.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return p&&!a.oneChangePerToken&&(e.lastComponent={count:p,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=c,d}equals(e,n,r){return r.comparator?r.comparator(e,n):e===n||!!r.ignoreCase&&e.toLowerCase()===n.toLowerCase()}removeEmpty(e){const n=[];for(let r=0;r<e.length;r++)e[r]&&n.push(e[r]);return n}castInput(e,n){return e}tokenize(e,n){return Array.from(e)}join(e){return e.join("")}postProcess(e,n){return e}get useLongestToken(){return!1}buildValues(e,n,r){const o=[];let a;for(;e;)o.push(e),a=e.previousComponent,delete e.previousComponent,e=a;o.reverse();const i=o.length;let l=0,c=0,d=0;for(;l<i;l++){const p=o[l];if(p.removed)p.value=this.join(r.slice(d,d+p.count)),d+=p.count;else{if(!p.added&&this.useLongestToken){let m=n.slice(c,c+p.count);m=m.map(function(h,g){const f=r[d+g];return f.length>h.length?f:h}),p.value=this.join(m)}else p.value=this.join(n.slice(c,c+p.count));c+=p.count,p.added||(d+=p.count)}}return o}}class AS extends IS{constructor(){super(...arguments),this.tokenize=MS}equals(e,n,r){return r.ignoreWhitespace?((!r.newlineIsToken||!e.includes(`
|
|
409
409
|
`))&&(e=e.trim()),(!r.newlineIsToken||!n.includes(`
|
|
410
410
|
`))&&(n=n.trim())):r.ignoreNewlineAtEof&&!r.newlineIsToken&&(e.endsWith(`
|
|
411
411
|
`)&&(e=e.slice(0,-1)),n.endsWith(`
|
|
@@ -485,4 +485,4 @@ Be concise. The developer will read this alongside the user's bug report.`}funct
|
|
|
485
485
|
const mergedMessages = harnessMessages;`}},DS=["Reading normalize-claude.ts","Reading api/chat.ts","Searching for CollapsedGroup"];function $S({oldValue:t,newValue:e}){const n=u.useMemo(()=>{const r=PS(t,e),o=[];for(const a of r){const i=a.value.split(`
|
|
486
486
|
`);i[i.length-1]===""&&i.pop();for(const l of i)o.push({type:a.added?"added":a.removed?"removed":"unchanged",content:l})}return o},[t,e]);return s.jsx("div",{className:"font-mono text-[10px] leading-relaxed overflow-x-auto",children:n.map((r,o)=>s.jsxs("div",{className:$e("flex",r.type==="added"&&"bg-emerald-500/10",r.type==="removed"&&"bg-red-500/10"),children:[s.jsx("span",{className:$e("select-none w-4 text-center shrink-0",r.type==="added"?"text-emerald-400/70":r.type==="removed"?"text-red-400/70":"text-zinc-700"),children:r.type==="added"?"+":r.type==="removed"?"-":" "}),s.jsx("span",{className:"flex-1 whitespace-pre-wrap break-all px-2 text-zinc-300",children:r.content||" "})]},o))})}function Vn({path:t,old:e,new:n}){const[r,o]=u.useState(!1),a=e.split(`
|
|
487
487
|
`).length,l=n.split(`
|
|
488
|
-
`).length-a,c=l>0?`+${l}`:l<0?`${l}`:"~";return s.jsxs("div",{className:"rounded-lg border border-zinc-800/40 bg-zinc-900/30",children:[s.jsxs("button",{onClick:()=>o(!r),className:"w-full flex items-center gap-2 px-3 py-2 text-left cursor-pointer hover:bg-zinc-800/40 transition-colors",children:[s.jsx(va,{className:"w-3.5 h-3.5 text-emerald-400/80 flex-shrink-0"}),s.jsx("span",{className:"text-xs text-zinc-500",children:"Edit"}),s.jsx("span",{className:"text-xs text-zinc-400 truncate flex-1",children:t}),s.jsx("span",{className:$e("text-[10px] tabular-nums flex-shrink-0",l>0?"text-emerald-400/60":l<0?"text-red-400/60":"text-zinc-600"),children:c}),s.jsx(Lt,{className:$e("w-3 h-3 text-zinc-600 transition-transform duration-150 flex-shrink-0",r&&"rotate-180")})]}),r&&s.jsx("div",{className:"border-t border-zinc-800/40 bg-zinc-950 rounded-b-lg overflow-hidden",children:s.jsx($S,{oldValue:e,newValue:n})})]})}function Dl({label:t,detail:e,icon:n,iconColor:r}){return s.jsx("div",{className:"rounded-lg border border-zinc-800/40 bg-zinc-900/30",children:s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[s.jsx(n,{className:$e("w-3.5 h-3.5 flex-shrink-0",r)}),s.jsx("span",{className:"text-xs text-zinc-500",children:t}),s.jsx("span",{className:"text-xs text-zinc-400 truncate flex-1",children:e})]})})}function zS(){const[t,e]=u.useState(0);return u.useEffect(()=>{const n=setInterval(()=>e(r=>(r+1)%DS.length),2e3);return()=>clearInterval(n)},[]),s.jsxs("div",{className:"min-h-dvh bg-zinc-950",children:[s.jsx("header",{className:"border-b border-zinc-800/40 bg-zinc-900/50 sticky top-0 z-10",children:s.jsxs("div",{className:"max-w-2xl mx-auto px-6 py-3 flex items-center gap-4",children:[s.jsx(hn,{to:"/",className:"p-2 -ml-2 rounded text-zinc-500 hover:text-zinc-300 transition-colors",children:s.jsx(Ul,{size:18})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-sm font-semibold text-zinc-100",children:"Collapsed Tool Group"}),s.jsx("p",{className:"text-[10px] text-zinc-600",children:"Real conversation from conv-LusReARKu6S4"})]})]})}),s.jsx("main",{className:"max-w-2xl mx-auto px-6 py-8",children:s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(At,{children:"First, let me understand the full rendering chain from useHarnessSession down to the renderer, so I know what needs to change."}),s.jsx(Dl,{label:"Read",detail:"src/web/chat/hooks/useHarnessSession.ts",icon:Po,iconColor:"text-blue-400/80"}),s.jsx(At,{children:"Now I need to understand how ConversationView uses `harnessMessages` and what needs to change. Let me trace the critical path."}),s.jsx(Qo,{temporalState:"historical",group:LS}),s.jsx(At,{children:"Now let me see the conversation detail loading / hydration section — this is the historical pipeline I need to replace:"}),s.jsx(Qo,{temporalState:"historical",group:OS}),s.jsx(At,{children:"OK. I can see the full picture now. Here's what needs to happen:\n\n1. `useHarnessSession` needs to expose `fetchHistory`\n2. ConversationView replaces the whole merge pipeline\n3. Remove `historicalMessages`, `optimisticUserMessage` state"}),s.jsx(Vn,{...Fn.addFetchToDestructure}),s.jsx(At,{children:"Now the big change — ConversationView. I need to expose `fetchHistory` from the harness hook, replace the entire merge pipeline with just `harnessMessages`, and remove the dead state."}),s.jsx(Vn,{...Fn.removeDeadState}),s.jsx(At,{children:"Remove the optimistic message clearing effect:"}),s.jsx(Vn,{...Fn.removeOptimisticEffect}),s.jsx(At,{children:"Now replace the entire merge pipeline with just `harnessMessages`:"}),s.jsx(Vn,{...Fn.replaceMergePipeline}),s.jsx(At,{children:"Let me typecheck to make sure everything compiles."}),s.jsx(Dl,{label:"Bash",detail:"pnpm typecheck 2>&1",icon:u0,iconColor:"text-orange-400/80"}),s.jsx(At,{children:"Clean — no type errors. The entire historical message merge pipeline is gone. Messages now come from a single source: the harness event stream."})]})})]})}function At({children:t}){return s.jsx("div",{className:"py-2",children:s.jsx("p",{className:"text-[13px] text-zinc-300 leading-relaxed whitespace-pre-wrap",children:t})})}const FS="lattice-sidebar-org-mode";function VS(){const t=localStorage.getItem(FS);return t==="flat"||t==="relevance"||t==="project"||t==="team"?t:"relevance"}function ii(t){const e=St(),{conversations:n}=$s(),r=u.useMemo(()=>{const o=n.filter(a=>!a.archived).sort((a,i)=>new Date(i.updatedAt).getTime()-new Date(a.updatedAt).getTime());return lS(o,VS())},[n]);u.useEffect(()=>{const o=a=>{if(!a.ctrlKey||a.key!=="Tab"||r.length===0)return;a.preventDefault();const i=t?r.indexOf(t):-1;let l;a.shiftKey?l=i<=0?r.length-1:i-1:l=i>=r.length-1?0:i+1;const c=r[l];c&&c!==t&&e(`/c/${c}`)};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[r,t,e])}const BS=new Vm({defaultOptions:{queries:{staleTime:3e4,gcTime:300*1e3,refetchOnWindowFocus:!0,retry:1}}});function US(){const{conversationId:t}=zl(),e=St();ii(t);const[n,r]=u.useState(()=>{const l=localStorage.getItem("crossSessionSidebarOpen");return l!==null?l==="true":typeof window<"u"&&window.innerWidth>=1024}),o=u.useCallback(()=>{r(!1),localStorage.setItem("crossSessionSidebarOpen","false")},[]),a=u.useCallback(()=>{r(!0),localStorage.setItem("crossSessionSidebarOpen","true")},[]);u.useEffect(()=>{if(!t||t.startsWith("conv-"))return;if(t.startsWith("pending-")){e("/",{replace:!0});return}let l=!1;return(async()=>{try{const c=await G.resolveUnifiedConversationId(t);if(l)return;if(c.conversationId&&c.conversationId.startsWith("conv-")){e(`/c/${c.conversationId}`,{replace:!0});return}e("/",{replace:!0})}catch{if(l)return;e("/",{replace:!0})}})(),()=>{l=!0}},[t,e]);const i=!!t&&!t.startsWith("conv-");return s.jsxs("div",{className:"h-full flex overflow-hidden",children:[s.jsx(ai,{currentSessionId:t,isOpen:n,onClose:o,onOpen:a}),i?s.jsx("main",{className:"flex-1 min-w-0 flex items-center justify-center text-white/70","aria-label":"Conversation view",children:s.jsx("div",{className:"text-sm tracking-wide",children:"Resolving legacy session..."})}):s.jsx(UN,{sidebarOpen:n,onToggleSidebar:()=>n?o():a()},t)]})}function GS(){const t=St(),{conversations:e,loading:n}=$s();ii(void 0);const[r,o]=u.useState(()=>{const l=localStorage.getItem("crossSessionSidebarOpen");return l!==null?l==="true":typeof window<"u"&&window.innerWidth>=1024}),a=u.useCallback(()=>{o(!1),localStorage.setItem("crossSessionSidebarOpen","false")},[]),i=u.useCallback(()=>{o(!0),localStorage.setItem("crossSessionSidebarOpen","true")},[]);return u.useEffect(()=>{if(n)return;const l=e.filter(c=>!c.archived&&c.status!=="pending"&&c.conversationId.startsWith("conv-")).sort((c,d)=>new Date(d.createdAt).getTime()-new Date(c.createdAt).getTime());l.length>0&&t(`/c/${l[0].conversationId}`,{replace:!0})},[e,n,t]),n?s.jsx("div",{className:"h-full flex items-center justify-center",children:s.jsx("div",{className:"text-muted-foreground text-sm",children:"Loading sessions..."})}):s.jsxs("div",{className:"h-full flex overflow-hidden",children:[s.jsx(ai,{currentSessionId:void 0,isOpen:r,onClose:a,onOpen:i}),s.jsx(Wp,{sidebarOpen:r,onToggleSidebar:()=>r?a():i()})]})}function HS(){ii(void 0);const[t,e]=u.useState(()=>{const o=localStorage.getItem("crossSessionSidebarOpen");return o!==null?o==="true":typeof window<"u"&&window.innerWidth>=1024}),n=u.useCallback(()=>{e(!1),localStorage.setItem("crossSessionSidebarOpen","false")},[]),r=u.useCallback(()=>{e(!0),localStorage.setItem("crossSessionSidebarOpen","true")},[]);return s.jsxs("div",{className:"h-full flex overflow-hidden",children:[s.jsx(ai,{currentSessionId:void 0,isOpen:t,onClose:n,onOpen:r}),s.jsx(Wp,{sidebarOpen:t,onToggleSidebar:()=>t?n():r()})]})}function qS(){return s.jsx(Bm,{client:BS,children:s.jsx(O2,{children:s.jsx(j2,{children:s.jsx(L2,{children:s.jsx(P2,{children:s.jsx(Ot,{children:s.jsxs(rj,{children:[s.jsx(WN,{}),s.jsxs(Fl,{children:[s.jsx(xt,{path:"/",element:s.jsx(jn,{children:s.jsx(GS,{})})}),s.jsx(xt,{path:"/new",element:s.jsx(jn,{children:s.jsx(HS,{})})}),s.jsx(xt,{path:"/c/:conversationId",element:s.jsx(jn,{children:s.jsx(US,{})})}),s.jsx(xt,{path:"/session/:sessionId/review",element:s.jsx(Um,{to:"/analysis/cross-session",replace:!0})}),s.jsx(xt,{path:"/analysis/cross-session",element:s.jsx(lj,{})}),s.jsx(xt,{path:"/lab/collapsed-group",element:s.jsx(zS,{})}),s.jsx(xt,{path:"/dev",element:s.jsx(SS,{})}),s.jsx(xt,{path:"/changelog",element:s.jsx(jn,{children:s.jsx(TS,{})})}),s.jsx(xt,{path:"*",element:s.jsxs("div",{className:"p-8 text-white",children:[s.jsx("h1",{children:"404 - Route not found"}),s.jsxs("p",{children:["Path: ",window.location.pathname]})]})})]})]})})})})})})})}function WS(){return s.jsx(Zs,{name:"App",fallback:(t,e)=>s.jsx(A_,{error:t,reset:e}),children:s.jsx(Gm,{future:{v7_startTransition:!1,v7_relativeSplatPath:!0},children:s.jsx(Fl,{children:s.jsx(xt,{path:"/*",element:s.jsx(qS,{})})})})})}function om(t){if(!t.includes("dynamically imported module")&&!t.includes("Failed to fetch dynamically imported module")&&!t.includes("Loading chunk"))return;const e="lattice:chunk-reload",n=sessionStorage.getItem(e);(!n||Date.now()-Number(n)>3e4)&&(sessionStorage.setItem(e,String(Date.now())),window.location.reload())}window.addEventListener("error",t=>om(t.message??""));window.addEventListener("unhandledrejection",t=>{const e=t.reason instanceof Error?t.reason.message:String(t.reason??"");om(e)});Mk();Pk();document.documentElement.setAttribute("data-theme","dark");document.documentElement.classList.add("dark");const KS=typeof window.matchMedia=="function"&&window.matchMedia("(display-mode: standalone)").matches,QS=!!navigator.standalone;document.documentElement.setAttribute("data-display-mode",KS||QS?"standalone":"browser");Hm.createRoot(document.getElementById("root")).render(s.jsx(Te.StrictMode,{children:s.jsx(WS,{})}));"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").catch(t=>{console.warn("Service worker registration failed:",t),Rs({type:"service-worker-registration-failed",severity:"warn",message:t instanceof Error?t.message:String(t)})});export{Ts as E,tt as F,qo as I,$g as M,zx as R,Jn as T,_,Og as a,M as b,Va as c,Pf as d,Sf as e,$e as f,k as t,hr as u};
|
|
488
|
+
`).length-a,c=l>0?`+${l}`:l<0?`${l}`:"~";return s.jsxs("div",{className:"rounded-lg border border-zinc-800/40 bg-zinc-900/30",children:[s.jsxs("button",{onClick:()=>o(!r),className:"w-full flex items-center gap-2 px-3 py-2 text-left cursor-pointer hover:bg-zinc-800/40 transition-colors",children:[s.jsx(va,{className:"w-3.5 h-3.5 text-emerald-400/80 flex-shrink-0"}),s.jsx("span",{className:"text-xs text-zinc-500",children:"Edit"}),s.jsx("span",{className:"text-xs text-zinc-400 truncate flex-1",children:t}),s.jsx("span",{className:$e("text-[10px] tabular-nums flex-shrink-0",l>0?"text-emerald-400/60":l<0?"text-red-400/60":"text-zinc-600"),children:c}),s.jsx(Lt,{className:$e("w-3 h-3 text-zinc-600 transition-transform duration-150 flex-shrink-0",r&&"rotate-180")})]}),r&&s.jsx("div",{className:"border-t border-zinc-800/40 bg-zinc-950 rounded-b-lg overflow-hidden",children:s.jsx($S,{oldValue:e,newValue:n})})]})}function Dl({label:t,detail:e,icon:n,iconColor:r}){return s.jsx("div",{className:"rounded-lg border border-zinc-800/40 bg-zinc-900/30",children:s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[s.jsx(n,{className:$e("w-3.5 h-3.5 flex-shrink-0",r)}),s.jsx("span",{className:"text-xs text-zinc-500",children:t}),s.jsx("span",{className:"text-xs text-zinc-400 truncate flex-1",children:e})]})})}function zS(){const[t,e]=u.useState(0);return u.useEffect(()=>{const n=setInterval(()=>e(r=>(r+1)%DS.length),2e3);return()=>clearInterval(n)},[]),s.jsxs("div",{className:"min-h-dvh bg-zinc-950",children:[s.jsx("header",{className:"border-b border-zinc-800/40 bg-zinc-900/50 sticky top-0 z-10",children:s.jsxs("div",{className:"max-w-2xl mx-auto px-6 py-3 flex items-center gap-4",children:[s.jsx(hn,{to:"/",className:"p-2 -ml-2 rounded text-zinc-500 hover:text-zinc-300 transition-colors",children:s.jsx(Ul,{size:18})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-sm font-semibold text-zinc-100",children:"Collapsed Tool Group"}),s.jsx("p",{className:"text-[10px] text-zinc-600",children:"Real conversation from conv-LusReARKu6S4"})]})]})}),s.jsx("main",{className:"max-w-2xl mx-auto px-6 py-8",children:s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(It,{children:"First, let me understand the full rendering chain from useHarnessSession down to the renderer, so I know what needs to change."}),s.jsx(Dl,{label:"Read",detail:"src/web/chat/hooks/useHarnessSession.ts",icon:Po,iconColor:"text-blue-400/80"}),s.jsx(It,{children:"Now I need to understand how ConversationView uses `harnessMessages` and what needs to change. Let me trace the critical path."}),s.jsx(Qo,{temporalState:"historical",group:LS}),s.jsx(It,{children:"Now let me see the conversation detail loading / hydration section — this is the historical pipeline I need to replace:"}),s.jsx(Qo,{temporalState:"historical",group:OS}),s.jsx(It,{children:"OK. I can see the full picture now. Here's what needs to happen:\n\n1. `useHarnessSession` needs to expose `fetchHistory`\n2. ConversationView replaces the whole merge pipeline\n3. Remove `historicalMessages`, `optimisticUserMessage` state"}),s.jsx(Vn,{...Fn.addFetchToDestructure}),s.jsx(It,{children:"Now the big change — ConversationView. I need to expose `fetchHistory` from the harness hook, replace the entire merge pipeline with just `harnessMessages`, and remove the dead state."}),s.jsx(Vn,{...Fn.removeDeadState}),s.jsx(It,{children:"Remove the optimistic message clearing effect:"}),s.jsx(Vn,{...Fn.removeOptimisticEffect}),s.jsx(It,{children:"Now replace the entire merge pipeline with just `harnessMessages`:"}),s.jsx(Vn,{...Fn.replaceMergePipeline}),s.jsx(It,{children:"Let me typecheck to make sure everything compiles."}),s.jsx(Dl,{label:"Bash",detail:"pnpm typecheck 2>&1",icon:u0,iconColor:"text-orange-400/80"}),s.jsx(It,{children:"Clean — no type errors. The entire historical message merge pipeline is gone. Messages now come from a single source: the harness event stream."})]})})]})}function It({children:t}){return s.jsx("div",{className:"py-2",children:s.jsx("p",{className:"text-[13px] text-zinc-300 leading-relaxed whitespace-pre-wrap",children:t})})}const FS="lattice-sidebar-org-mode";function VS(){const t=localStorage.getItem(FS);return t==="flat"||t==="relevance"||t==="project"||t==="team"?t:"relevance"}function ii(t){const e=Nt(),{conversations:n}=$s(),r=u.useMemo(()=>{const o=n.filter(a=>!a.archived).sort((a,i)=>new Date(i.updatedAt).getTime()-new Date(a.updatedAt).getTime());return lS(o,VS())},[n]);u.useEffect(()=>{const o=a=>{if(!a.ctrlKey||a.key!=="Tab"||r.length===0)return;a.preventDefault();const i=t?r.indexOf(t):-1;let l;a.shiftKey?l=i<=0?r.length-1:i-1:l=i>=r.length-1?0:i+1;const c=r[l];c&&c!==t&&e(`/c/${c}`)};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[r,t,e])}const BS=new Vm({defaultOptions:{queries:{staleTime:3e4,gcTime:300*1e3,refetchOnWindowFocus:!0,retry:1}}});function US(){const{conversationId:t}=zl(),e=Nt();ii(t);const[n,r]=u.useState(()=>{const l=localStorage.getItem("crossSessionSidebarOpen");return l!==null?l==="true":typeof window<"u"&&window.innerWidth>=1024}),o=u.useCallback(()=>{r(!1),localStorage.setItem("crossSessionSidebarOpen","false")},[]),a=u.useCallback(()=>{r(!0),localStorage.setItem("crossSessionSidebarOpen","true")},[]);u.useEffect(()=>{if(!t||t.startsWith("conv-"))return;if(t.startsWith("pending-")){e("/",{replace:!0});return}let l=!1;return(async()=>{try{const c=await H.resolveUnifiedConversationId(t);if(l)return;if(c.conversationId&&c.conversationId.startsWith("conv-")){e(`/c/${c.conversationId}`,{replace:!0});return}e("/",{replace:!0})}catch{if(l)return;e("/",{replace:!0})}})(),()=>{l=!0}},[t,e]);const i=!!t&&!t.startsWith("conv-");return s.jsxs("div",{className:"h-full flex overflow-hidden",children:[s.jsx(ai,{currentSessionId:t,isOpen:n,onClose:o,onOpen:a}),i?s.jsx("main",{className:"flex-1 min-w-0 flex items-center justify-center text-white/70","aria-label":"Conversation view",children:s.jsx("div",{className:"text-sm tracking-wide",children:"Resolving legacy session..."})}):s.jsx(UN,{sidebarOpen:n,onToggleSidebar:()=>n?o():a()},t)]})}function GS(){const t=Nt(),{conversations:e,loading:n}=$s();ii(void 0);const[r,o]=u.useState(()=>{const l=localStorage.getItem("crossSessionSidebarOpen");return l!==null?l==="true":typeof window<"u"&&window.innerWidth>=1024}),a=u.useCallback(()=>{o(!1),localStorage.setItem("crossSessionSidebarOpen","false")},[]),i=u.useCallback(()=>{o(!0),localStorage.setItem("crossSessionSidebarOpen","true")},[]);return u.useEffect(()=>{if(n)return;const l=e.filter(c=>!c.archived&&c.status!=="pending"&&c.conversationId.startsWith("conv-")).sort((c,d)=>new Date(d.createdAt).getTime()-new Date(c.createdAt).getTime());l.length>0&&t(`/c/${l[0].conversationId}`,{replace:!0})},[e,n,t]),n?s.jsx("div",{className:"h-full flex items-center justify-center",children:s.jsx("div",{className:"text-muted-foreground text-sm",children:"Loading sessions..."})}):s.jsxs("div",{className:"h-full flex overflow-hidden",children:[s.jsx(ai,{currentSessionId:void 0,isOpen:r,onClose:a,onOpen:i}),s.jsx(Wp,{sidebarOpen:r,onToggleSidebar:()=>r?a():i()})]})}function HS(){ii(void 0);const[t,e]=u.useState(()=>{const o=localStorage.getItem("crossSessionSidebarOpen");return o!==null?o==="true":typeof window<"u"&&window.innerWidth>=1024}),n=u.useCallback(()=>{e(!1),localStorage.setItem("crossSessionSidebarOpen","false")},[]),r=u.useCallback(()=>{e(!0),localStorage.setItem("crossSessionSidebarOpen","true")},[]);return s.jsxs("div",{className:"h-full flex overflow-hidden",children:[s.jsx(ai,{currentSessionId:void 0,isOpen:t,onClose:n,onOpen:r}),s.jsx(Wp,{sidebarOpen:t,onToggleSidebar:()=>t?n():r()})]})}function qS(){return s.jsx(Bm,{client:BS,children:s.jsx(O2,{children:s.jsx(j2,{children:s.jsx(L2,{children:s.jsx(P2,{children:s.jsx(Ot,{children:s.jsxs(rj,{children:[s.jsx(WN,{}),s.jsxs(Fl,{children:[s.jsx(xt,{path:"/",element:s.jsx(jn,{children:s.jsx(GS,{})})}),s.jsx(xt,{path:"/new",element:s.jsx(jn,{children:s.jsx(HS,{})})}),s.jsx(xt,{path:"/c/:conversationId",element:s.jsx(jn,{children:s.jsx(US,{})})}),s.jsx(xt,{path:"/session/:sessionId/review",element:s.jsx(Um,{to:"/analysis/cross-session",replace:!0})}),s.jsx(xt,{path:"/analysis/cross-session",element:s.jsx(lj,{})}),s.jsx(xt,{path:"/lab/collapsed-group",element:s.jsx(zS,{})}),s.jsx(xt,{path:"/dev",element:s.jsx(SS,{})}),s.jsx(xt,{path:"/changelog",element:s.jsx(jn,{children:s.jsx(TS,{})})}),s.jsx(xt,{path:"*",element:s.jsxs("div",{className:"p-8 text-white",children:[s.jsx("h1",{children:"404 - Route not found"}),s.jsxs("p",{children:["Path: ",window.location.pathname]})]})})]})]})})})})})})})}function WS(){return s.jsx(Zs,{name:"App",fallback:(t,e)=>s.jsx(A_,{error:t,reset:e}),children:s.jsx(Gm,{future:{v7_startTransition:!1,v7_relativeSplatPath:!0},children:s.jsx(Fl,{children:s.jsx(xt,{path:"/*",element:s.jsx(qS,{})})})})})}function om(t){if(!t.includes("dynamically imported module")&&!t.includes("Failed to fetch dynamically imported module")&&!t.includes("Loading chunk"))return;const e="lattice:chunk-reload",n=sessionStorage.getItem(e);(!n||Date.now()-Number(n)>3e4)&&(sessionStorage.setItem(e,String(Date.now())),window.location.reload())}window.addEventListener("error",t=>om(t.message??""));window.addEventListener("unhandledrejection",t=>{const e=t.reason instanceof Error?t.reason.message:String(t.reason??"");om(e)});Mk();Pk();document.documentElement.setAttribute("data-theme","dark");document.documentElement.classList.add("dark");const KS=typeof window.matchMedia=="function"&&window.matchMedia("(display-mode: standalone)").matches,QS=!!navigator.standalone;document.documentElement.setAttribute("data-display-mode",KS||QS?"standalone":"browser");Hm.createRoot(document.getElementById("root")).render(s.jsx(Ie.StrictMode,{children:s.jsx(WS,{})}));"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").catch(t=>{console.warn("Service worker registration failed:",t),Rs({type:"service-worker-registration-failed",severity:"warn",message:t instanceof Error?t.message:String(t)})});export{Ts as E,tt as F,qo as I,$g as M,zx as R,Jn as T,_,Og as a,R as b,Va as c,Pf as d,Sf as e,$e as f,k as t,hr as u};
|