@grackle-ai/web 0.83.2 → 0.84.0
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/KnowledgePage-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/KnowledgePage-vV_eStmC.js","assets/markdown-gcy1Jmzi.js","assets/dagview-BA5TtMAQ.js","assets/grpc-DU5jMhZD.js","assets/KnowledgePage-DMqJ4jlP.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{r as JS,a as y,j as l,v as WS,b as XS,t as Jl,i as QS,f as eT,M as up,c as dp}from"./markdown-gcy1Jmzi.js";import{r as tT,d as Qv,H as e0,P as t0,i as nT,B as sT,a as aT,C as iT,M as oT}from"./dagview-BA5TtMAQ.js";import{c as rT,a as lT,G as cT,C as Ec,b as uT,e as ob,w as dT,t as fT,p as Wl,d as pT,f as mT,M as hT,R as nr,A as rb,D as lb,W as gT,O as vT,g as yT,S as n0}from"./grpc-DU5jMhZD.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))o(c);new MutationObserver(c=>{for(const u of c)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&o(d)}).observe(document,{childList:!0,subtree:!0});function i(c){const u={};return c.integrity&&(u.integrity=c.integrity),c.referrerPolicy&&(u.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?u.credentials="include":c.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function o(c){if(c.ep)return;c.ep=!0;const u=i(c);fetch(c.href,u)}})();var Xd={exports:{}},sr={},Qd={exports:{}},ef={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* scheduler.production.js
|
|
@@ -34,7 +34,7 @@ Error generating stack: `+r.message+`
|
|
|
34
34
|
* @license MIT
|
|
35
35
|
*/var l0="popstate";function c0(n){return typeof n=="object"&&n!=null&&"pathname"in n&&"search"in n&&"hash"in n&&"state"in n&&"key"in n}function ET(n={}){function s(o,c){var g;let u=(g=c.state)==null?void 0:g.masked,{pathname:d,search:m,hash:h}=u||o.location;return Lf("",{pathname:d,search:m,hash:h},c.state&&c.state.usr||null,c.state&&c.state.key||"default",u?{pathname:o.location.pathname,search:o.location.search,hash:o.location.hash}:void 0)}function i(o,c){return typeof c=="string"?c:_r(c)}return DT(s,i,null,n)}function dt(n,s){if(n===!1||n===null||typeof n>"u")throw new Error(s)}function Ln(n,s){if(!n){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function AT(){return Math.random().toString(36).substring(2,10)}function u0(n,s){return{usr:n.state,key:n.key,idx:s,masked:n.unstable_mask?{pathname:n.pathname,search:n.search,hash:n.hash}:void 0}}function Lf(n,s,i=null,o,c){return{pathname:typeof n=="string"?n:n.pathname,search:"",hash:"",...typeof s=="string"?ao(s):s,state:i,key:s&&s.key||o||AT(),unstable_mask:c}}function _r({pathname:n="/",search:s="",hash:i=""}){return s&&s!=="?"&&(n+=s.charAt(0)==="?"?s:"?"+s),i&&i!=="#"&&(n+=i.charAt(0)==="#"?i:"#"+i),n}function ao(n){let s={};if(n){let i=n.indexOf("#");i>=0&&(s.hash=n.substring(i),n=n.substring(0,i));let o=n.indexOf("?");o>=0&&(s.search=n.substring(o),n=n.substring(0,o)),n&&(s.pathname=n)}return s}function DT(n,s,i,o={}){let{window:c=document.defaultView,v5Compat:u=!1}=o,d=c.history,m="POP",h=null,g=v();g==null&&(g=0,d.replaceState({...d.state,idx:g},""));function v(){return(d.state||{idx:null}).idx}function b(){m="POP";let j=v(),w=j==null?null:j-g;g=j,h&&h({action:m,location:N.location,delta:w})}function _(j,w){m="PUSH";let E=c0(j)?j:Lf(N.location,j,w);g=v()+1;let A=u0(E,g),O=N.createHref(E.unstable_mask||E);try{d.pushState(A,"",O)}catch(C){if(C instanceof DOMException&&C.name==="DataCloneError")throw C;c.location.assign(O)}u&&h&&h({action:m,location:N.location,delta:1})}function S(j,w){m="REPLACE";let E=c0(j)?j:Lf(N.location,j,w);g=v();let A=u0(E,g),O=N.createHref(E.unstable_mask||E);d.replaceState(A,"",O),u&&h&&h({action:m,location:N.location,delta:0})}function T(j){return RT(j)}let N={get action(){return m},get location(){return n(c,d)},listen(j){if(h)throw new Error("A history only accepts one active listener");return c.addEventListener(l0,b),h=j,()=>{c.removeEventListener(l0,b),h=null}},createHref(j){return s(c,j)},createURL:T,encodeLocation(j){let w=T(j);return{pathname:w.pathname,search:w.search,hash:w.hash}},push:_,replace:S,go(j){return d.go(j)}};return N}function RT(n,s=!1){let i="http://localhost";typeof window<"u"&&(i=window.location.origin!=="null"?window.location.origin:window.location.href),dt(i,"No window.location.(origin|href) available to create URL");let o=typeof n=="string"?n:_r(n);return o=o.replace(/ $/,"%20"),!s&&o.startsWith("//")&&(o=i+o),new URL(o,i)}function cb(n,s,i="/"){return MT(n,s,i,!1)}function MT(n,s,i,o){let c=typeof s=="string"?ao(s):s,u=Os(c.pathname||"/",i);if(u==null)return null;let d=ub(n);OT(d);let m=null;for(let h=0;m==null&&h<d.length;++h){let g=fb(u);m=HT(d[h],g,o)}return m}function ub(n,s=[],i=[],o="",c=!1){let u=(d,m,h=c,g)=>{let v={relativePath:g===void 0?d.path||"":g,caseSensitive:d.caseSensitive===!0,childrenIndex:m,route:d};if(v.relativePath.startsWith("/")){if(!v.relativePath.startsWith(o)&&h)return;dt(v.relativePath.startsWith(o),`Absolute route path "${v.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),v.relativePath=v.relativePath.slice(o.length)}let b=ss([o,v.relativePath]),_=i.concat(v);d.children&&d.children.length>0&&(dt(d.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${b}".`),ub(d.children,s,_,b,h)),!(d.path==null&&!d.index)&&s.push({path:b,score:VT(b,d.index),routesMeta:_})};return n.forEach((d,m)=>{var h;if(d.path===""||!((h=d.path)!=null&&h.includes("?")))u(d,m);else for(let g of db(d.path))u(d,m,!0,g)}),s}function db(n){let s=n.split("/");if(s.length===0)return[];let[i,...o]=s,c=i.endsWith("?"),u=i.replace(/\?$/,"");if(o.length===0)return c?[u,""]:[u];let d=db(o.join("/")),m=[];return m.push(...d.map(h=>h===""?u:[u,h].join("/"))),c&&m.push(...d),m.map(h=>n.startsWith("/")&&h===""?"/":h)}function OT(n){n.sort((s,i)=>s.score!==i.score?i.score-s.score:qT(s.routesMeta.map(o=>o.childrenIndex),i.routesMeta.map(o=>o.childrenIndex)))}var IT=/^:[\w-]+$/,BT=3,LT=2,UT=1,zT=10,PT=-2,d0=n=>n==="*";function VT(n,s){let i=n.split("/"),o=i.length;return i.some(d0)&&(o+=PT),s&&(o+=LT),i.filter(c=>!d0(c)).reduce((c,u)=>c+(IT.test(u)?BT:u===""?UT:zT),o)}function qT(n,s){return n.length===s.length&&n.slice(0,-1).every((o,c)=>o===s[c])?n[n.length-1]-s[s.length-1]:0}function HT(n,s,i=!1){let{routesMeta:o}=n,c={},u="/",d=[];for(let m=0;m<o.length;++m){let h=o[m],g=m===o.length-1,v=u==="/"?s:s.slice(u.length)||"/",b=xr({path:h.relativePath,caseSensitive:h.caseSensitive,end:g},v),_=h.route;if(!b&&g&&i&&!o[o.length-1].route.index&&(b=xr({path:h.relativePath,caseSensitive:h.caseSensitive,end:!1},v)),!b)return null;Object.assign(c,b.params),d.push({params:c,pathname:ss([u,b.pathname]),pathnameBase:KT(ss([u,b.pathnameBase])),route:_}),b.pathnameBase!=="/"&&(u=ss([u,b.pathnameBase]))}return d}function xr(n,s){typeof n=="string"&&(n={path:n,caseSensitive:!1,end:!0});let[i,o]=GT(n.path,n.caseSensitive,n.end),c=s.match(i);if(!c)return null;let u=c[0],d=u.replace(/(.)\/+$/,"$1"),m=c.slice(1);return{params:o.reduce((g,{paramName:v,isOptional:b},_)=>{if(v==="*"){let T=m[_]||"";d=u.slice(0,u.length-T.length).replace(/(.)\/+$/,"$1")}const S=m[_];return b&&!S?g[v]=void 0:g[v]=(S||"").replace(/%2F/g,"/"),g},{}),pathname:u,pathnameBase:d,pattern:n}}function GT(n,s=!1,i=!0){Ln(n==="*"||!n.endsWith("*")||n.endsWith("/*"),`Route path "${n}" will be treated as if it were "${n.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${n.replace(/\*$/,"/*")}".`);let o=[],c="^"+n.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(d,m,h,g,v)=>{if(o.push({paramName:m,isOptional:h!=null}),h){let b=v.charAt(g+d.length);return b&&b!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return n.endsWith("*")?(o.push({paramName:"*"}),c+=n==="*"||n==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):i?c+="\\/*$":n!==""&&n!=="/"&&(c+="(?:(?=\\/|$))"),[new RegExp(c,s?void 0:"i"),o]}function fb(n){try{return n.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return Ln(!1,`The URL path "${n}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${s}).`),n}}function Os(n,s){if(s==="/")return n;if(!n.toLowerCase().startsWith(s.toLowerCase()))return null;let i=s.endsWith("/")?s.length-1:s.length,o=n.charAt(i);return o&&o!=="/"?null:n.slice(i)||"/"}var $T=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function FT(n,s="/"){let{pathname:i,search:o="",hash:c=""}=typeof n=="string"?ao(n):n,u;return i?(i=i.replace(/\/\/+/g,"/"),i.startsWith("/")?u=f0(i.substring(1),"/"):u=f0(i,s)):u=s,{pathname:u,search:YT(o),hash:JT(c)}}function f0(n,s){let i=s.replace(/\/+$/,"").split("/");return n.split("/").forEach(c=>{c===".."?i.length>1&&i.pop():c!=="."&&i.push(c)}),i.length>1?i.join("/"):"/"}function tf(n,s,i,o){return`Cannot include a '${n}' character in a manually specified \`to.${s}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${i}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function ZT(n){return n.filter((s,i)=>i===0||s.route.path&&s.route.path.length>0)}function fp(n){let s=ZT(n);return s.map((i,o)=>o===s.length-1?i.pathname:i.pathnameBase)}function Ac(n,s,i,o=!1){let c;typeof n=="string"?c=ao(n):(c={...n},dt(!c.pathname||!c.pathname.includes("?"),tf("?","pathname","search",c)),dt(!c.pathname||!c.pathname.includes("#"),tf("#","pathname","hash",c)),dt(!c.search||!c.search.includes("#"),tf("#","search","hash",c)));let u=n===""||c.pathname==="",d=u?"/":c.pathname,m;if(d==null)m=i;else{let b=s.length-1;if(!o&&d.startsWith("..")){let _=d.split("/");for(;_[0]==="..";)_.shift(),b-=1;c.pathname=_.join("/")}m=b>=0?s[b]:"/"}let h=FT(c,m),g=d&&d!=="/"&&d.endsWith("/"),v=(u||d===".")&&i.endsWith("/");return!h.pathname.endsWith("/")&&(g||v)&&(h.pathname+="/"),h}var ss=n=>n.join("/").replace(/\/\/+/g,"/"),KT=n=>n.replace(/\/+$/,"").replace(/^\/*/,"/"),YT=n=>!n||n==="?"?"":n.startsWith("?")?n:"?"+n,JT=n=>!n||n==="#"?"":n.startsWith("#")?n:"#"+n,WT=class{constructor(n,s,i,o=!1){this.status=n,this.statusText=s||"",this.internal=o,i instanceof Error?(this.data=i.toString(),this.error=i):this.data=i}};function XT(n){return n!=null&&typeof n.status=="number"&&typeof n.statusText=="string"&&typeof n.internal=="boolean"&&"data"in n}function QT(n){return n.map(s=>s.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var pb=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function mb(n,s){let i=n;if(typeof i!="string"||!$T.test(i))return{absoluteURL:void 0,isExternal:!1,to:i};let o=i,c=!1;if(pb)try{let u=new URL(window.location.href),d=i.startsWith("//")?new URL(u.protocol+i):new URL(i),m=Os(d.pathname,s);d.origin===u.origin&&m!=null?i=m+d.search+d.hash:c=!0}catch{Ln(!1,`<Link to="${i}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:c,to:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var hb=["POST","PUT","PATCH","DELETE"];new Set(hb);var ek=["GET",...hb];new Set(ek);var io=y.createContext(null);io.displayName="DataRouter";var Dc=y.createContext(null);Dc.displayName="DataRouterState";var tk=y.createContext(!1),gb=y.createContext({isTransitioning:!1});gb.displayName="ViewTransition";var nk=y.createContext(new Map);nk.displayName="Fetchers";var sk=y.createContext(null);sk.displayName="Await";var Sn=y.createContext(null);Sn.displayName="Navigation";var Cr=y.createContext(null);Cr.displayName="Location";var Un=y.createContext({outlet:null,matches:[],isDataRoute:!1});Un.displayName="Route";var pp=y.createContext(null);pp.displayName="RouteError";var vb="REACT_ROUTER_ERROR",ak="REDIRECT",ik="ROUTE_ERROR_RESPONSE";function ok(n){if(n.startsWith(`${vb}:${ak}:{`))try{let s=JSON.parse(n.slice(28));if(typeof s=="object"&&s&&typeof s.status=="number"&&typeof s.statusText=="string"&&typeof s.location=="string"&&typeof s.reloadDocument=="boolean"&&typeof s.replace=="boolean")return s}catch{}}function rk(n){if(n.startsWith(`${vb}:${ik}:{`))try{let s=JSON.parse(n.slice(40));if(typeof s=="object"&&s&&typeof s.status=="number"&&typeof s.statusText=="string")return new WT(s.status,s.statusText,s.data)}catch{}}function lk(n,{relative:s}={}){dt(Xa(),"useHref() may be used only in the context of a <Router> component.");let{basename:i,navigator:o}=y.useContext(Sn),{hash:c,pathname:u,search:d}=Er(n,{relative:s}),m=u;return i!=="/"&&(m=u==="/"?i:ss([i,u])),o.createHref({pathname:m,search:d,hash:c})}function Xa(){return y.useContext(Cr)!=null}function It(){return dt(Xa(),"useLocation() may be used only in the context of a <Router> component."),y.useContext(Cr).location}function Dt(n){dt(Xa(),"useMatch() may be used only in the context of a <Router> component.");let{pathname:s}=It();return y.useMemo(()=>xr(n,fb(s)),[s,n])}var yb="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function bb(n){y.useContext(Sn).static||y.useLayoutEffect(n)}function Rc(){let{isDataRoute:n}=y.useContext(Un);return n?Tk():ck()}function ck(){dt(Xa(),"useNavigate() may be used only in the context of a <Router> component.");let n=y.useContext(io),{basename:s,navigator:i}=y.useContext(Sn),{matches:o}=y.useContext(Un),{pathname:c}=It(),u=JSON.stringify(fp(o)),d=y.useRef(!1);return bb(()=>{d.current=!0}),y.useCallback((h,g={})=>{if(Ln(d.current,yb),!d.current)return;if(typeof h=="number"){i.go(h);return}let v=Ac(h,JSON.parse(u),c,g.relative==="path");n==null&&s!=="/"&&(v.pathname=v.pathname==="/"?s:ss([s,v.pathname])),(g.replace?i.replace:i.push)(v,g.state,g)},[s,i,u,c,n])}var uk=y.createContext(null);function dk(n){let s=y.useContext(Un).outlet;return y.useMemo(()=>s&&y.createElement(uk.Provider,{value:n},s),[s,n])}function va(){let{matches:n}=y.useContext(Un),s=n[n.length-1];return s?s.params:{}}function Er(n,{relative:s}={}){let{matches:i}=y.useContext(Un),{pathname:o}=It(),c=JSON.stringify(fp(i));return y.useMemo(()=>Ac(n,JSON.parse(c),o,s==="path"),[n,c,o,s])}function fk(n,s){return _b(n,s)}function _b(n,s,i){var j;dt(Xa(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=y.useContext(Sn),{matches:c}=y.useContext(Un),u=c[c.length-1],d=u?u.params:{},m=u?u.pathname:"/",h=u?u.pathnameBase:"/",g=u&&u.route;{let w=g&&g.path||"";Sb(m,!g||w.endsWith("*")||w.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${m}" (under <Route path="${w}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
36
36
|
|
|
37
|
-
Please change the parent <Route path="${w}"> to <Route path="${w==="/"?"*":`${w}/*`}">.`)}let v=It(),b;if(s){let w=typeof s=="string"?ao(s):s;dt(h==="/"||((j=w.pathname)==null?void 0:j.startsWith(h)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${h}" but pathname "${w.pathname}" was given in the \`location\` prop.`),b=w}else b=v;let _=b.pathname||"/",S=_;if(h!=="/"){let w=h.replace(/^\//,"").split("/");S="/"+_.replace(/^\//,"").split("/").slice(w.length).join("/")}let T=cb(n,{pathname:S});Ln(g||T!=null,`No routes matched location "${b.pathname}${b.search}${b.hash}" `),Ln(T==null||T[T.length-1].route.element!==void 0||T[T.length-1].route.Component!==void 0||T[T.length-1].route.lazy!==void 0,`Matched leaf route at location "${b.pathname}${b.search}${b.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let N=vk(T&&T.map(w=>Object.assign({},w,{params:Object.assign({},d,w.params),pathname:ss([h,o.encodeLocation?o.encodeLocation(w.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:w.pathname]),pathnameBase:w.pathnameBase==="/"?h:ss([h,o.encodeLocation?o.encodeLocation(w.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:w.pathnameBase])})),c,i);return s&&N?y.createElement(Cr.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",unstable_mask:void 0,...b},navigationType:"POP"}},N):N}function pk(){let n=Sk(),s=XT(n)?`${n.status} ${n.statusText}`:n instanceof Error?n.message:JSON.stringify(n),i=n instanceof Error?n.stack:null,o="rgba(200,200,200, 0.5)",c={padding:"0.5rem",backgroundColor:o},u={padding:"2px 4px",backgroundColor:o},d=null;return console.error("Error handled by React Router default ErrorBoundary:",n),d=y.createElement(y.Fragment,null,y.createElement("p",null,"💿 Hey developer 👋"),y.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",y.createElement("code",{style:u},"ErrorBoundary")," or"," ",y.createElement("code",{style:u},"errorElement")," prop on your route.")),y.createElement(y.Fragment,null,y.createElement("h2",null,"Unexpected Application Error!"),y.createElement("h3",{style:{fontStyle:"italic"}},s),i?y.createElement("pre",{style:c},i):null,d)}var mk=y.createElement(pk,null),xb=class extends y.Component{constructor(n){super(n),this.state={location:n.location,revalidation:n.revalidation,error:n.error}}static getDerivedStateFromError(n){return{error:n}}static getDerivedStateFromProps(n,s){return s.location!==n.location||s.revalidation!=="idle"&&n.revalidation==="idle"?{error:n.error,location:n.location,revalidation:n.revalidation}:{error:n.error!==void 0?n.error:s.error,location:s.location,revalidation:n.revalidation||s.revalidation}}componentDidCatch(n,s){this.props.onError?this.props.onError(n,s):console.error("React Router caught the following error during render",n)}render(){let n=this.state.error;if(this.context&&typeof n=="object"&&n&&"digest"in n&&typeof n.digest=="string"){const i=rk(n.digest);i&&(n=i)}let s=n!==void 0?y.createElement(Un.Provider,{value:this.props.routeContext},y.createElement(pp.Provider,{value:n,children:this.props.component})):this.props.children;return this.context?y.createElement(hk,{error:n},s):s}};xb.contextType=tk;var nf=new WeakMap;function hk({children:n,error:s}){let{basename:i}=y.useContext(Sn);if(typeof s=="object"&&s&&"digest"in s&&typeof s.digest=="string"){let o=ok(s.digest);if(o){let c=nf.get(s);if(c)throw c;let u=mb(o.location,i);if(pb&&!nf.get(s))if(u.isExternal||o.reloadDocument)window.location.href=u.absoluteURL||u.to;else{const d=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(u.to,{replace:o.replace}));throw nf.set(s,d),d}return y.createElement("meta",{httpEquiv:"refresh",content:`0;url=${u.absoluteURL||u.to}`})}}return n}function gk({routeContext:n,match:s,children:i}){let o=y.useContext(io);return o&&o.static&&o.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=s.route.id),y.createElement(Un.Provider,{value:n},i)}function vk(n,s=[],i){let o=i==null?void 0:i.state;if(n==null){if(!o)return null;if(o.errors)n=o.matches;else if(s.length===0&&!o.initialized&&o.matches.length>0)n=o.matches;else return null}let c=n,u=o==null?void 0:o.errors;if(u!=null){let v=c.findIndex(b=>b.route.id&&(u==null?void 0:u[b.route.id])!==void 0);dt(v>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(u).join(",")}`),c=c.slice(0,Math.min(c.length,v+1))}let d=!1,m=-1;if(i&&o){d=o.renderFallback;for(let v=0;v<c.length;v++){let b=c[v];if((b.route.HydrateFallback||b.route.hydrateFallbackElement)&&(m=v),b.route.id){let{loaderData:_,errors:S}=o,T=b.route.loader&&!_.hasOwnProperty(b.route.id)&&(!S||S[b.route.id]===void 0);if(b.route.lazy||T){i.isStatic&&(d=!0),m>=0?c=c.slice(0,m+1):c=[c[0]];break}}}}let h=i==null?void 0:i.onError,g=o&&h?(v,b)=>{var _,S;h(v,{location:o.location,params:((S=(_=o.matches)==null?void 0:_[0])==null?void 0:S.params)??{},unstable_pattern:QT(o.matches),errorInfo:b})}:void 0;return c.reduceRight((v,b,_)=>{let S,T=!1,N=null,j=null;o&&(S=u&&b.route.id?u[b.route.id]:void 0,N=b.route.errorElement||mk,d&&(m<0&&_===0?(Sb("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),T=!0,j=null):m===_&&(T=!0,j=b.route.hydrateFallbackElement||null)));let w=s.concat(c.slice(0,_+1)),E=()=>{let A;return S?A=N:T?A=j:b.route.Component?A=y.createElement(b.route.Component,null):b.route.element?A=b.route.element:A=v,y.createElement(gk,{match:b,routeContext:{outlet:v,matches:w,isDataRoute:o!=null},children:A})};return o&&(b.route.ErrorBoundary||b.route.errorElement||_===0)?y.createElement(xb,{location:o.location,revalidation:o.revalidation,component:N,error:S,children:E(),routeContext:{outlet:null,matches:w,isDataRoute:!0},onError:g}):E()},null)}function mp(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function yk(n){let s=y.useContext(io);return dt(s,mp(n)),s}function bk(n){let s=y.useContext(Dc);return dt(s,mp(n)),s}function _k(n){let s=y.useContext(Un);return dt(s,mp(n)),s}function hp(n){let s=_k(n),i=s.matches[s.matches.length-1];return dt(i.route.id,`${n} can only be used on routes that contain a unique "id"`),i.route.id}function xk(){return hp("useRouteId")}function Sk(){var o;let n=y.useContext(pp),s=bk("useRouteError"),i=hp("useRouteError");return n!==void 0?n:(o=s.errors)==null?void 0:o[i]}function Tk(){let{router:n}=yk("useNavigate"),s=hp("useNavigate"),i=y.useRef(!1);return bb(()=>{i.current=!0}),y.useCallback(async(c,u={})=>{Ln(i.current,yb),i.current&&(typeof c=="number"?await n.navigate(c):await n.navigate(c,{fromRouteId:s,...u}))},[n,s])}var p0={};function Sb(n,s,i){!s&&!p0[n]&&(p0[n]=!0,Ln(!1,i))}y.memo(kk);function kk({routes:n,future:s,state:i,isStatic:o,onError:c}){return _b(n,void 0,{state:i,isStatic:o,onError:c})}function Zn({to:n,replace:s,state:i,relative:o}){dt(Xa(),"<Navigate> may be used only in the context of a <Router> component.");let{static:c}=y.useContext(Sn);Ln(!c,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:u}=y.useContext(Un),{pathname:d}=It(),m=Rc(),h=Ac(n,fp(u),d,o==="path"),g=JSON.stringify(h);return y.useEffect(()=>{m(JSON.parse(g),{replace:s,state:i,relative:o})},[m,g,o,s,i]),null}function Qa(n){return dk(n.context)}function Ce(n){dt(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function wk({basename:n="/",children:s=null,location:i,navigationType:o="POP",navigator:c,static:u=!1,unstable_useTransitions:d}){dt(!Xa(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let m=n.replace(/^\/*/,"/"),h=y.useMemo(()=>({basename:m,navigator:c,static:u,unstable_useTransitions:d,future:{}}),[m,c,u,d]);typeof i=="string"&&(i=ao(i));let{pathname:g="/",search:v="",hash:b="",state:_=null,key:S="default",unstable_mask:T}=i,N=y.useMemo(()=>{let j=Os(g,m);return j==null?null:{location:{pathname:j,search:v,hash:b,state:_,key:S,unstable_mask:T},navigationType:o}},[m,g,v,b,_,S,o,T]);return Ln(N!=null,`<Router basename="${m}"> is not able to match the URL "${g}${v}${b}" because it does not start with the basename, so the <Router> won't render anything.`),N==null?null:y.createElement(Sn.Provider,{value:h},y.createElement(Cr.Provider,{children:s,value:N}))}function Nk({children:n,location:s}){return fk(Uf(n),s)}function Uf(n,s=[]){let i=[];return y.Children.forEach(n,(o,c)=>{if(!y.isValidElement(o))return;let u=[...s,c];if(o.type===y.Fragment){i.push.apply(i,Uf(o.props.children,u));return}dt(o.type===Ce,`[${typeof o.type=="string"?o.type:o.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),dt(!o.props.index||!o.props.children,"An index route cannot have child routes.");let d={id:o.props.id||u.join("-"),caseSensitive:o.props.caseSensitive,element:o.props.element,Component:o.props.Component,index:o.props.index,path:o.props.path,middleware:o.props.middleware,loader:o.props.loader,action:o.props.action,hydrateFallbackElement:o.props.hydrateFallbackElement,HydrateFallback:o.props.HydrateFallback,errorElement:o.props.errorElement,ErrorBoundary:o.props.ErrorBoundary,hasErrorBoundary:o.props.hasErrorBoundary===!0||o.props.ErrorBoundary!=null||o.props.errorElement!=null,shouldRevalidate:o.props.shouldRevalidate,handle:o.props.handle,lazy:o.props.lazy};o.props.children&&(d.children=Uf(o.props.children,u)),i.push(d)}),i}var uc="get",dc="application/x-www-form-urlencoded";function Mc(n){return typeof HTMLElement<"u"&&n instanceof HTMLElement}function jk(n){return Mc(n)&&n.tagName.toLowerCase()==="button"}function Ck(n){return Mc(n)&&n.tagName.toLowerCase()==="form"}function Ek(n){return Mc(n)&&n.tagName.toLowerCase()==="input"}function Ak(n){return!!(n.metaKey||n.altKey||n.ctrlKey||n.shiftKey)}function Dk(n,s){return n.button===0&&(!s||s==="_self")&&!Ak(n)}function zf(n=""){return new URLSearchParams(typeof n=="string"||Array.isArray(n)||n instanceof URLSearchParams?n:Object.keys(n).reduce((s,i)=>{let o=n[i];return s.concat(Array.isArray(o)?o.map(c=>[i,c]):[[i,o]])},[]))}function Rk(n,s){let i=zf(n);return s&&s.forEach((o,c)=>{i.has(c)||s.getAll(c).forEach(u=>{i.append(c,u)})}),i}var Xl=null;function Mk(){if(Xl===null)try{new FormData(document.createElement("form"),0),Xl=!1}catch{Xl=!0}return Xl}var Ok=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function sf(n){return n!=null&&!Ok.has(n)?(Ln(!1,`"${n}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${dc}"`),null):n}function Ik(n,s){let i,o,c,u,d;if(Ck(n)){let m=n.getAttribute("action");o=m?Os(m,s):null,i=n.getAttribute("method")||uc,c=sf(n.getAttribute("enctype"))||dc,u=new FormData(n)}else if(jk(n)||Ek(n)&&(n.type==="submit"||n.type==="image")){let m=n.form;if(m==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let h=n.getAttribute("formaction")||m.getAttribute("action");if(o=h?Os(h,s):null,i=n.getAttribute("formmethod")||m.getAttribute("method")||uc,c=sf(n.getAttribute("formenctype"))||sf(m.getAttribute("enctype"))||dc,u=new FormData(m,n),!Mk()){let{name:g,type:v,value:b}=n;if(v==="image"){let _=g?`${g}.`:"";u.append(`${_}x`,"0"),u.append(`${_}y`,"0")}else g&&u.append(g,b)}}else{if(Mc(n))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');i=uc,o=null,c=dc,d=n}return u&&c==="text/plain"&&(d=u,u=void 0),{action:o,method:i.toLowerCase(),encType:c,formData:u,body:d}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function gp(n,s){if(n===!1||n===null||typeof n>"u")throw new Error(s)}function Bk(n,s,i,o){let c=typeof n=="string"?new URL(n,typeof window>"u"?"server://singlefetch/":window.location.origin):n;return i?c.pathname.endsWith("/")?c.pathname=`${c.pathname}_.${o}`:c.pathname=`${c.pathname}.${o}`:c.pathname==="/"?c.pathname=`_root.${o}`:s&&Os(c.pathname,s)==="/"?c.pathname=`${s.replace(/\/$/,"")}/_root.${o}`:c.pathname=`${c.pathname.replace(/\/$/,"")}.${o}`,c}async function Lk(n,s){if(n.id in s)return s[n.id];try{let i=await import(n.module);return s[n.id]=i,i}catch(i){return console.error(`Error loading route module \`${n.module}\`, reloading page...`),console.error(i),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Uk(n){return n==null?!1:n.href==null?n.rel==="preload"&&typeof n.imageSrcSet=="string"&&typeof n.imageSizes=="string":typeof n.rel=="string"&&typeof n.href=="string"}async function zk(n,s,i){let o=await Promise.all(n.map(async c=>{let u=s.routes[c.route.id];if(u){let d=await Lk(u,i);return d.links?d.links():[]}return[]}));return Hk(o.flat(1).filter(Uk).filter(c=>c.rel==="stylesheet"||c.rel==="preload").map(c=>c.rel==="stylesheet"?{...c,rel:"prefetch",as:"style"}:{...c,rel:"prefetch"}))}function m0(n,s,i,o,c,u){let d=(h,g)=>i[g]?h.route.id!==i[g].route.id:!0,m=(h,g)=>{var v;return i[g].pathname!==h.pathname||((v=i[g].route.path)==null?void 0:v.endsWith("*"))&&i[g].params["*"]!==h.params["*"]};return u==="assets"?s.filter((h,g)=>d(h,g)||m(h,g)):u==="data"?s.filter((h,g)=>{var b;let v=o.routes[h.route.id];if(!v||!v.hasLoader)return!1;if(d(h,g)||m(h,g))return!0;if(h.route.shouldRevalidate){let _=h.route.shouldRevalidate({currentUrl:new URL(c.pathname+c.search+c.hash,window.origin),currentParams:((b=i[0])==null?void 0:b.params)||{},nextUrl:new URL(n,window.origin),nextParams:h.params,defaultShouldRevalidate:!0});if(typeof _=="boolean")return _}return!0}):[]}function Pk(n,s,{includeHydrateFallback:i}={}){return Vk(n.map(o=>{let c=s.routes[o.route.id];if(!c)return[];let u=[c.module];return c.clientActionModule&&(u=u.concat(c.clientActionModule)),c.clientLoaderModule&&(u=u.concat(c.clientLoaderModule)),i&&c.hydrateFallbackModule&&(u=u.concat(c.hydrateFallbackModule)),c.imports&&(u=u.concat(c.imports)),u}).flat(1))}function Vk(n){return[...new Set(n)]}function qk(n){let s={},i=Object.keys(n).sort();for(let o of i)s[o]=n[o];return s}function Hk(n,s){let i=new Set;return new Set(s),n.reduce((o,c)=>{let u=JSON.stringify(qk(c));return i.has(u)||(i.add(u),o.push({key:u,link:c})),o},[])}function Tb(){let n=y.useContext(io);return gp(n,"You must render this element inside a <DataRouterContext.Provider> element"),n}function Gk(){let n=y.useContext(Dc);return gp(n,"You must render this element inside a <DataRouterStateContext.Provider> element"),n}var vp=y.createContext(void 0);vp.displayName="FrameworkContext";function kb(){let n=y.useContext(vp);return gp(n,"You must render this element inside a <HydratedRouter> element"),n}function $k(n,s){let i=y.useContext(vp),[o,c]=y.useState(!1),[u,d]=y.useState(!1),{onFocus:m,onBlur:h,onMouseEnter:g,onMouseLeave:v,onTouchStart:b}=s,_=y.useRef(null);y.useEffect(()=>{if(n==="render"&&d(!0),n==="viewport"){let N=w=>{w.forEach(E=>{d(E.isIntersecting)})},j=new IntersectionObserver(N,{threshold:.5});return _.current&&j.observe(_.current),()=>{j.disconnect()}}},[n]),y.useEffect(()=>{if(o){let N=setTimeout(()=>{d(!0)},100);return()=>{clearTimeout(N)}}},[o]);let S=()=>{c(!0)},T=()=>{c(!1),d(!1)};return i?n!=="intent"?[u,_,{}]:[u,_,{onFocus:ar(m,S),onBlur:ar(h,T),onMouseEnter:ar(g,S),onMouseLeave:ar(v,T),onTouchStart:ar(b,S)}]:[!1,_,{}]}function ar(n,s){return i=>{n&&n(i),i.defaultPrevented||s(i)}}function Fk({page:n,...s}){let{router:i}=Tb(),o=y.useMemo(()=>cb(i.routes,n,i.basename),[i.routes,n,i.basename]);return o?y.createElement(Kk,{page:n,matches:o,...s}):null}function Zk(n){let{manifest:s,routeModules:i}=kb(),[o,c]=y.useState([]);return y.useEffect(()=>{let u=!1;return zk(n,s,i).then(d=>{u||c(d)}),()=>{u=!0}},[n,s,i]),o}function Kk({page:n,matches:s,...i}){let o=It(),{future:c,manifest:u,routeModules:d}=kb(),{basename:m}=Tb(),{loaderData:h,matches:g}=Gk(),v=y.useMemo(()=>m0(n,s,g,u,o,"data"),[n,s,g,u,o]),b=y.useMemo(()=>m0(n,s,g,u,o,"assets"),[n,s,g,u,o]),_=y.useMemo(()=>{if(n===o.pathname+o.search+o.hash)return[];let N=new Set,j=!1;if(s.forEach(E=>{var O;let A=u.routes[E.route.id];!A||!A.hasLoader||(!v.some(C=>C.route.id===E.route.id)&&E.route.id in h&&((O=d[E.route.id])!=null&&O.shouldRevalidate)||A.hasClientLoader?j=!0:N.add(E.route.id))}),N.size===0)return[];let w=Bk(n,m,c.unstable_trailingSlashAwareDataRequests,"data");return j&&N.size>0&&w.searchParams.set("_routes",s.filter(E=>N.has(E.route.id)).map(E=>E.route.id).join(",")),[w.pathname+w.search]},[m,c.unstable_trailingSlashAwareDataRequests,h,o,u,v,s,n,d]),S=y.useMemo(()=>Pk(b,u),[b,u]),T=Zk(b);return y.createElement(y.Fragment,null,_.map(N=>y.createElement("link",{key:N,rel:"prefetch",as:"fetch",href:N,...i})),S.map(N=>y.createElement("link",{key:N,rel:"modulepreload",href:N,...i})),T.map(({key:N,link:j})=>y.createElement("link",{key:N,nonce:i.nonce,...j,crossOrigin:j.crossOrigin??i.crossOrigin})))}function Yk(...n){return s=>{n.forEach(i=>{typeof i=="function"?i(s):i!=null&&(i.current=s)})}}var Jk=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Jk&&(window.__reactRouterVersion="7.13.2")}catch{}function Wk({basename:n,children:s,unstable_useTransitions:i,window:o}){let c=y.useRef();c.current==null&&(c.current=ET({window:o,v5Compat:!0}));let u=c.current,[d,m]=y.useState({action:u.action,location:u.location}),h=y.useCallback(g=>{i===!1?m(g):y.startTransition(()=>m(g))},[i]);return y.useLayoutEffect(()=>u.listen(h),[u,h]),y.createElement(wk,{basename:n,children:s,location:d.location,navigationType:d.action,navigator:u,unstable_useTransitions:i})}var wb=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,yp=y.forwardRef(function({onClick:s,discover:i="render",prefetch:o="none",relative:c,reloadDocument:u,replace:d,unstable_mask:m,state:h,target:g,to:v,preventScrollReset:b,viewTransition:_,unstable_defaultShouldRevalidate:S,...T},N){let{basename:j,navigator:w,unstable_useTransitions:E}=y.useContext(Sn),A=typeof v=="string"&&wb.test(v),O=mb(v,j);v=O.to;let C=lk(v,{relative:c}),M=It(),G=null;if(m){let re=Ac(m,[],M.unstable_mask?M.unstable_mask.pathname:"/",!0);j!=="/"&&(re.pathname=re.pathname==="/"?j:ss([j,re.pathname])),G=w.createHref(re)}let[U,V,Z]=$k(o,T),ee=t2(v,{replace:d,unstable_mask:m,state:h,target:g,preventScrollReset:b,relative:c,viewTransition:_,unstable_defaultShouldRevalidate:S,unstable_useTransitions:E});function ie(re){s&&s(re),re.defaultPrevented||ee(re)}let be=!(O.isExternal||u),K=y.createElement("a",{...T,...Z,href:(be?G:void 0)||O.absoluteURL||C,onClick:be?ie:s,ref:Yk(N,V),target:g,"data-discover":!A&&i==="render"?"true":void 0});return U&&!A?y.createElement(y.Fragment,null,K,y.createElement(Fk,{page:C})):K});yp.displayName="Link";var Xk=y.forwardRef(function({"aria-current":s="page",caseSensitive:i=!1,className:o="",end:c=!1,style:u,to:d,viewTransition:m,children:h,...g},v){let b=Er(d,{relative:g.relative}),_=It(),S=y.useContext(Dc),{navigator:T,basename:N}=y.useContext(Sn),j=S!=null&&o2(b)&&m===!0,w=T.encodeLocation?T.encodeLocation(b).pathname:b.pathname,E=_.pathname,A=S&&S.navigation&&S.navigation.location?S.navigation.location.pathname:null;i||(E=E.toLowerCase(),A=A?A.toLowerCase():null,w=w.toLowerCase()),A&&N&&(A=Os(A,N)||A);const O=w!=="/"&&w.endsWith("/")?w.length-1:w.length;let C=E===w||!c&&E.startsWith(w)&&E.charAt(O)==="/",M=A!=null&&(A===w||!c&&A.startsWith(w)&&A.charAt(w.length)==="/"),G={isActive:C,isPending:M,isTransitioning:j},U=C?s:void 0,V;typeof o=="function"?V=o(G):V=[o,C?"active":null,M?"pending":null,j?"transitioning":null].filter(Boolean).join(" ");let Z=typeof u=="function"?u(G):u;return y.createElement(yp,{...g,"aria-current":U,className:V,ref:v,style:Z,to:d,viewTransition:m},typeof h=="function"?h(G):h)});Xk.displayName="NavLink";var Qk=y.forwardRef(({discover:n="render",fetcherKey:s,navigate:i,reloadDocument:o,replace:c,state:u,method:d=uc,action:m,onSubmit:h,relative:g,preventScrollReset:v,viewTransition:b,unstable_defaultShouldRevalidate:_,...S},T)=>{let{unstable_useTransitions:N}=y.useContext(Sn),j=a2(),w=i2(m,{relative:g}),E=d.toLowerCase()==="get"?"get":"post",A=typeof m=="string"&&wb.test(m),O=C=>{if(h&&h(C),C.defaultPrevented)return;C.preventDefault();let M=C.nativeEvent.submitter,G=(M==null?void 0:M.getAttribute("formmethod"))||d,U=()=>j(M||C.currentTarget,{fetcherKey:s,method:G,navigate:i,replace:c,state:u,relative:g,preventScrollReset:v,viewTransition:b,unstable_defaultShouldRevalidate:_});N&&i!==!1?y.startTransition(()=>U()):U()};return y.createElement("form",{ref:T,method:E,action:w,onSubmit:o?h:O,...S,"data-discover":!A&&n==="render"?"true":void 0})});Qk.displayName="Form";function e2(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Nb(n){let s=y.useContext(io);return dt(s,e2(n)),s}function t2(n,{target:s,replace:i,unstable_mask:o,state:c,preventScrollReset:u,relative:d,viewTransition:m,unstable_defaultShouldRevalidate:h,unstable_useTransitions:g}={}){let v=Rc(),b=It(),_=Er(n,{relative:d});return y.useCallback(S=>{if(Dk(S,s)){S.preventDefault();let T=i!==void 0?i:_r(b)===_r(_),N=()=>v(n,{replace:T,unstable_mask:o,state:c,preventScrollReset:u,relative:d,viewTransition:m,unstable_defaultShouldRevalidate:h});g?y.startTransition(()=>N()):N()}},[b,v,_,i,o,c,s,n,u,d,m,h,g])}function bp(n){Ln(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let s=y.useRef(zf(n)),i=y.useRef(!1),o=It(),c=y.useMemo(()=>Rk(o.search,i.current?null:s.current),[o.search]),u=Rc(),d=y.useCallback((m,h)=>{const g=zf(typeof m=="function"?m(new URLSearchParams(c)):m);i.current=!0,u("?"+g,h)},[u,c]);return[c,d]}var n2=0,s2=()=>`__${String(++n2)}__`;function a2(){let{router:n}=Nb("useSubmit"),{basename:s}=y.useContext(Sn),i=xk(),o=n.fetch,c=n.navigate;return y.useCallback(async(u,d={})=>{let{action:m,method:h,encType:g,formData:v,body:b}=Ik(u,s);if(d.navigate===!1){let _=d.fetcherKey||s2();await o(_,i,d.action||m,{unstable_defaultShouldRevalidate:d.unstable_defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:v,body:b,formMethod:d.method||h,formEncType:d.encType||g,flushSync:d.flushSync})}else await c(d.action||m,{unstable_defaultShouldRevalidate:d.unstable_defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:v,body:b,formMethod:d.method||h,formEncType:d.encType||g,replace:d.replace,state:d.state,fromRouteId:i,flushSync:d.flushSync,viewTransition:d.viewTransition})},[o,c,s,i])}function i2(n,{relative:s}={}){let{basename:i}=y.useContext(Sn),o=y.useContext(Un);dt(o,"useFormAction must be used inside a RouteContext");let[c]=o.matches.slice(-1),u={...Er(n||".",{relative:s})},d=It();if(n==null){u.search=d.search;let m=new URLSearchParams(u.search),h=m.getAll("index");if(h.some(v=>v==="")){m.delete("index"),h.filter(b=>b).forEach(b=>m.append("index",b));let v=m.toString();u.search=v?`?${v}`:""}}return(!n||n===".")&&c.route.index&&(u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index"),i!=="/"&&(u.pathname=u.pathname==="/"?i:ss([i,u.pathname])),_r(u)}function o2(n,{relative:s}={}){let i=y.useContext(gb);dt(i!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Nb("useViewTransitionState"),c=Er(n,{relative:s});if(!i.isTransitioning)return!1;let u=Os(i.currentLocation.pathname,o)||i.currentLocation.pathname,d=Os(i.nextLocation.pathname,o)||i.nextLocation.pathname;return xr(c.pathname,d)!=null||xr(c.pathname,u)!=null}function St(){const n=Rc();return y.useCallback((s,i)=>{typeof s=="number"?n(s):n(s,i)},[n])}function jb(n){return`/sessions/${encodeURIComponent(n)}`}function Wi(n,s){return s?`/environments/${encodeURIComponent(s)}/workspaces/${encodeURIComponent(n)}`:`/workspaces/${encodeURIComponent(n)}`}function os(n,s,i,o){const c=encodeURIComponent(n);let u;return i&&o?u=`/environments/${encodeURIComponent(o)}/workspaces/${encodeURIComponent(i)}/tasks/${c}`:i?u=`/workspaces/${encodeURIComponent(i)}/tasks/${c}`:u=`/tasks/${c}`,s?`${u}/${s}`:u}function ei(n,s,i){const o=new URLSearchParams;n&&o.set("workspace",n),s&&o.set("parent",s);const c=o.toString();if(n&&i){const u=`/environments/${encodeURIComponent(i)}/workspaces/${encodeURIComponent(n)}/tasks/new`;return s?`${u}?parent=${encodeURIComponent(s)}`:u}return c?`/tasks/new?${c}`:"/tasks/new"}function Cb(n){return`/sessions/new?${new URLSearchParams({env:n}).toString()}`}const Xi="/environments",r2="/environments/new";function Qi(n){return`/environments/${encodeURIComponent(n)}`}function l2(n){return`/environments/${encodeURIComponent(n)}/edit`}const Ji="/settings",c2="/settings/credentials",af="/settings/personas",u2="/settings/personas/new";function Eb(n){return`/settings/personas/${encodeURIComponent(n)}`}const d2="/settings/shortcuts",f2="/pair",p2="/chat",Ya="/",m2="/tasks",Ab="/workspaces/new",Db="/knowledge",h2=3e3;function g2(n){const[s,i]=y.useState(!1),o=y.useRef(n.onSessionEvent);o.current=n.onSessionEvent;const c=y.useRef(n.onDomainEvent);c.current=n.onDomainEvent;const u=y.useRef(n.onConnect);u.current=n.onConnect;const d=y.useRef(n.onDisconnect);return d.current=n.onDisconnect,y.useEffect(()=>{let m=!1,h;async function g(){var v,b;if(!m){try{const _=we.streamEvents({});i(!0),(v=u.current)==null||v.call(u);for await(const S of _){if(m)break;const T=S.event;if(T.case==="sessionEvent"){const N=T.value;o.current({sessionId:N.sessionId,type:N.type,timestamp:N.timestamp,content:N.content,raw:N.raw})}else if(T.case==="domainEvent"){const N=T.value;c.current({id:N.id,type:N.type,timestamp:N.timestamp,payloadJson:N.payloadJson})}}}catch(_){if(_ instanceof Ec&&_.code===uT.Unauthenticated){window.location.href=f2;return}}m||(i(!1),(b=d.current)==null||b.call(d),h=setTimeout(()=>{g().catch(()=>{})},h2))}}return g().catch(()=>{}),()=>{m=!0,clearTimeout(h),i(!1)}},[]),{connected:s}}function Rb(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Mb(n,s){return console.warn(`[ws] Malformed "${n}" message: ${s}`),!1}function v2(n){return Rb(n)&&typeof n.sessionId=="string"&&typeof n.eventType=="string"&&typeof n.timestamp=="string"&&typeof n.content=="string"&&(n.raw===void 0||typeof n.raw=="string")}const y2=new Set(["off","subscription","api_key"]),Ql=new Set(["off","on"]);function b2(n){return Rb(n)&&y2.has(n.claude)&&Ql.has(n.github)&&Ql.has(n.copilot)&&Ql.has(n.codex)&&Ql.has(n.goose)}function Ob(n){switch(n){case"waiting_input":return"idle";case"completed":return"stopped";case"killed":return"stopped";case"failed":return"stopped";case"interrupted":return"stopped";case"terminated":return"stopped";default:return n}}function Ib(n){switch(n){case"completed":return"completed";case"killed":return"killed";case"failed":return"interrupted";case"interrupted":return"interrupted";case"terminated":return"terminated";default:return}}const Vi=5e3;function _2(n){return{id:n.id,displayName:n.displayName,adapterType:n.adapterType,adapterConfig:n.adapterConfig||"{}",status:n.status,bootstrapped:n.bootstrapped}}function h0(n){return{id:n.id,environmentId:n.environmentId,runtime:n.runtime,status:n.status,prompt:n.prompt,startedAt:n.startedAt,endedAt:n.endedAt||void 0,error:n.error||void 0,endReason:n.endReason||void 0,personaId:n.personaId||void 0,inputTokens:n.inputTokens,outputTokens:n.outputTokens,costUsd:n.costUsd}}function x2(n){return{sessionId:n.sessionId,eventType:ob(n.type),timestamp:n.timestamp,content:n.content,raw:n.raw||void 0}}function S2(n){return{id:n.id,name:n.name,description:n.description,repoUrl:n.repoUrl,environmentId:n.environmentId,status:dT(n.status),workingDirectory:n.workingDirectory,useWorktrees:n.useWorktrees,defaultPersonaId:n.defaultPersonaId,createdAt:n.createdAt,updatedAt:n.updatedAt}}function g0(n){return{id:n.id,workspaceId:n.workspaceId??void 0,title:n.title,description:n.description,status:fT(n.status),branch:n.branch,latestSessionId:n.latestSessionId,dependsOn:[...n.dependsOn],sortOrder:n.sortOrder,createdAt:n.createdAt,startedAt:n.startedAt||void 0,completedAt:n.completedAt||void 0,parentTaskId:n.parentTaskId,depth:n.depth,childTaskIds:[...n.childTaskIds],canDecompose:n.canDecompose,defaultPersonaId:n.defaultPersonaId,workpad:n.workpad}}function T2(n){return{id:n.id,workspaceId:n.workspaceId,taskId:n.taskId,sessionId:n.sessionId,category:n.category,title:n.title,content:n.content,tags:[...n.tags],createdAt:n.createdAt}}function k2(n){return{name:n.name,tokenType:n.type,envVar:n.envVar,filePath:n.filePath,expiresAt:n.expiresAt}}function w2(n){return{claude:pT(n.claude),github:Wl(n.github),copilot:Wl(n.copilot),codex:Wl(n.codex),goose:Wl(n.goose)}}function N2(n){return{name:n.name,repository:n.repository,state:n.state,gitStatus:n.gitStatus}}function of(n){return{id:n.id,name:n.name,description:n.description,systemPrompt:n.systemPrompt,toolConfig:n.toolConfig?JSON.stringify({allowedTools:[...n.toolConfig.allowedTools],disallowedTools:[...n.toolConfig.disallowedTools]}):"{}",runtime:n.runtime,model:n.model,maxTurns:n.maxTurns,mcpServers:JSON.stringify(n.mcpServers.map(s=>({name:s.name,command:s.command,args:[...s.args],tools:[...s.tools]}))),createdAt:n.createdAt,updatedAt:n.updatedAt,type:n.type||"agent",script:n.script,allowedMcpTools:[...n.allowedMcpTools]}}function j2(n){return{inputTokens:n.inputTokens,outputTokens:n.outputTokens,costUsd:n.costUsd,sessionCount:n.sessionCount}}function ec(n,s=0){return{id:n.id,label:n.title||n.label||n.id,kind:n.kind,category:n.category||void 0,sourceType:n.sourceType||void 0,sourceId:n.sourceId||void 0,content:n.content||void 0,tags:n.tags.length>0?[...n.tags]:void 0,workspaceId:n.workspaceId||void 0,createdAt:n.createdAt||void 0,updatedAt:n.updatedAt||void 0,val:s}}function rf(n){return{source:n.fromId,target:n.toId,type:n.type}}const v0=5e3;function C2(){const[n,s]=y.useState([]),[i,o]=y.useState({}),c=y.useCallback(()=>{we.listEnvironments({}).then(_=>{s(_.environments.map(_2))},()=>{})},[]),u=y.useCallback(_=>{switch(_.type){case"environment.added":return!0;case"environment.removed":{const S=_.payload.environmentId;return S&&(s(T=>T.filter(N=>N.id!==S)),o(T=>{const N={...T};return delete N[S],N})),!0}case"environment.changed":return c(),!0;case"environment.provision_progress":{const S=_.payload;if(typeof S.environmentId!="string"||typeof S.stage!="string"||typeof S.message!="string"||typeof S.progress!="number")return Mb("environment.provision_progress","invalid payload"),!0;if(o(T=>({...T,[S.environmentId]:{stage:S.stage,message:S.message,progress:S.progress}})),S.stage==="ready"){const T=S.environmentId;setTimeout(()=>{o(N=>{const j={...N};return delete j[T],j})},v0)}return!0}default:return!1}},[c]),d=y.useCallback(_=>{var S;if(_.type==="environments"){const T=Array.isArray((S=_.payload)==null?void 0:S.environments)?_.payload.environments:[];return s(T),!0}return!1},[]),m=y.useCallback((_,S,T)=>{we.addEnvironment({displayName:_,adapterType:S,adapterConfig:JSON.stringify(T??{})}).catch(()=>{})},[]),h=y.useCallback((_,S)=>{we.updateEnvironment({id:_,displayName:S.displayName,adapterConfig:S.adapterConfig?JSON.stringify(S.adapterConfig):void 0}).catch(()=>{})},[]),g=y.useCallback((_,S)=>{(async()=>{try{const N=we.provisionEnvironment({id:_,force:S??!1});for await(const j of N)o(w=>({...w,[_]:{stage:j.stage,message:j.message,progress:j.progress}})),j.stage==="ready"&&setTimeout(()=>{o(w=>{const E={...w};return delete E[_],E})},v0)}catch{o(N=>{const j={...N};return delete j[_],j})}})().catch(()=>{})},[]),v=y.useCallback(_=>{we.stopEnvironment({id:_}).catch(()=>{})},[]),b=y.useCallback(_=>{we.removeEnvironment({id:_}).catch(()=>{})},[]);return{environments:n,provisionStatus:i,loadEnvironments:c,addEnvironment:m,updateEnvironment:h,provisionEnvironment:g,stopEnvironment:v,removeEnvironment:b,handleEvent:u,handleLegacyMessage:d}}const lf=new Set(["pending","running","idle"]),E2=new Set(["completed","failed","interrupted","hibernating","suspended"]),y0=["pending","running","idle"];function A2(){const[n,s]=y.useState([]),[i,o]=y.useState([]),[c,u]=y.useState(0),[d,m]=y.useState(void 0),[h,g]=y.useState({}),v=y.useCallback(()=>{we.listSessions({}).then(C=>{const M=C.sessions.map(h0);s(G=>{const U=new Map(G.map(V=>[V.id,V]));return M.map(V=>{const Z=U.get(V.id),ee=Z==null?void 0:Z.status;return!ee||ee===V.status?V:E2.has(ee)&&lf.has(V.status)?{...V,status:ee,...Z.endReason!==void 0?{endReason:Z.endReason}:{}}:lf.has(ee)&&lf.has(V.status)&&y0.indexOf(ee)>y0.indexOf(V.status)?{...V,status:ee}:V})})},()=>{})},[]),b=y.useCallback(C=>{if(C.type!=="session_event")return!1;if(!v2(C.payload))return Mb("session_event","payload is not a valid SessionEvent"),!0;const M=C.payload;let G=0;if(o(U=>{const V=[...U,M];return V.length>Vi?(G=V.length-Vi,V.slice(-Vi)):V}),G>0&&u(U=>U+G),M.eventType==="usage")try{const U=JSON.parse(M.content),V=Number(U.input_tokens)||0,Z=Number(U.output_tokens)||0,ee=Number(U.cost_usd)||0;(V>0||Z>0||ee>0)&&s(ie=>ie.map(be=>be.id===M.sessionId?{...be,inputTokens:(be.inputTokens??0)+V,outputTokens:(be.outputTokens??0)+Z,costUsd:(be.costUsd??0)+ee}:be))}catch{}if(M.eventType==="status"){const U=Ob(M.content),V=Ib(M.content);s(Z=>Z.some(ie=>ie.id===M.sessionId)?Z.map(ie=>ie.id===M.sessionId?{...ie,status:U,...V!==void 0?{endReason:V}:{}}:ie):[...Z,{id:M.sessionId,environmentId:"",runtime:"",status:U,prompt:"",startedAt:M.timestamp,...V!==void 0?{endReason:V}:{}}])}return!0},[]),_=y.useCallback(C=>{b({type:"session_event",payload:C})},[b]),S=y.useCallback(C=>{var M,G,U,V,Z;switch(C.type){case"sessions":{const ee=Array.isArray((M=C.payload)==null?void 0:M.sessions)?C.payload.sessions:[];return s(ee),!0}case"spawned":{const ee=(G=C.payload)==null?void 0:G.sessionId;return typeof ee=="string"&&ee&&m(ee),v(),!0}case"session_events":{const ee=Array.isArray((U=C.payload)==null?void 0:U.events)?C.payload.events:[];return ee.length>0&&o(ee),!0}case"task_sessions":{const ee=(V=C.payload)==null?void 0:V.taskId;if(typeof ee=="string"&&ee){const ie=Array.isArray((Z=C.payload)==null?void 0:Z.sessions)?C.payload.sessions:[];g(be=>({...be,[ee]:ie}))}return!0}default:return!1}},[v]),T=y.useCallback((C,M,G,U)=>{we.spawnAgent({environmentId:C,prompt:M,personaId:G||"",workingDirectory:U||""}).then(V=>{m(V.id),v()},()=>{})},[v]),N=y.useCallback((C,M)=>{we.sendInput({sessionId:C,text:M}).catch(()=>{})},[]),j=y.useCallback(C=>{we.killAgent({id:C,graceful:!1}).catch(()=>{})},[]),w=y.useCallback(C=>{we.killAgent({id:C,graceful:!0}).catch(()=>{})},[]),E=y.useCallback(C=>{we.getSessionEvents({id:C}).then(M=>{const G=M.events.map(x2);if(G.length>0){let U=0;o(V=>{const Z=new Set;for(const be of V)be.sessionId===C&&Z.add(`${be.timestamp}|${be.eventType}`);const ee=G.filter(be=>!Z.has(`${be.timestamp}|${be.eventType}`)),ie=[...V,...ee].sort((be,K)=>be.sessionId!==K.sessionId?0:be.timestamp.localeCompare(K.timestamp));return ie.length>Vi?(U=ie.length-Vi,ie.slice(-Vi)):ie}),U>0&&u(V=>V+U)}},()=>{})},[]),A=y.useCallback(()=>{o([]),u(0)},[]),O=y.useCallback(C=>{we.getTaskSessions({id:C}).then(M=>{const G=M.sessions.map(h0);g(U=>({...U,[C]:G}))},()=>{})},[]);return{sessions:n,events:i,eventsDropped:c,lastSpawnedId:d,taskSessions:h,loadSessions:v,spawn:T,sendInput:N,kill:j,stopGraceful:w,loadSessionEvents:E,clearEvents:A,loadTaskSessions:O,handleMessage:b,handleSessionEvent:_,handleLegacyMessage:S}}function D2(){const[n,s]=y.useState([]),[i,o]=y.useState(!1),c=y.useCallback(()=>{we.listWorkspaces({}).then(v=>{s(v.workspaces.map(S2))},()=>{})},[]),u=y.useCallback(v=>{switch(v.type){case"workspace.created":return o(!1),c(),!0;case"workspace.archived":case"workspace.updated":return c(),!0;default:return!1}},[c]),d=y.useCallback(()=>{o(!1)},[]),m=y.useCallback((v,b,_,S,T,N,j,w,E)=>{o(!0),we.createWorkspace({name:v,description:b||"",repoUrl:_||"",environmentId:S||"",defaultPersonaId:T||void 0,useWorktrees:N??!0,workingDirectory:j||void 0}).then(()=>{o(!1),w==null||w()},A=>{o(!1);const O=A instanceof Ec?A.message:"Failed to create workspace";E==null||E(O)})},[]),h=y.useCallback(v=>{we.archiveWorkspace({id:v}).catch(()=>{})},[]),g=y.useCallback((v,b)=>{we.updateWorkspace({id:v,...b}).catch(()=>{})},[]);return{workspaces:n,workspaceCreating:i,loadWorkspaces:c,createWorkspace:m,archiveWorkspace:h,updateWorkspace:g,handleEvent:u,onDisconnect:d}}function R2(){const[n,s]=y.useState([]),[i,o]=y.useState(void 0),c=y.useRef({}),u=y.useCallback(E=>{we.listTasks({workspaceId:E}).then(A=>{const O=A.tasks.map(g0);s(C=>[...C.filter(M=>M.workspaceId!==E),...O])},()=>{})},[]),d=y.useCallback(()=>{we.listTasks({}).then(E=>{const A=E.tasks.map(g0);s(O=>{const C=new Set(A.map(M=>M.id));return[...O.filter(M=>!C.has(M.id)),...A]})},()=>{})},[]),m=y.useCallback((E,A)=>{const O=C=>{clearTimeout(c.current[C]),c.current[C]=setTimeout(()=>{delete c.current[C],u(C)},200)};E?O(E):A&&s(C=>{const M=C.find(G=>G.id===A);return M!=null&&M.workspaceId?O(M.workspaceId):d(),C})},[u,d]),h=y.useCallback(E=>{const A=E.payload;switch(E.type){case"task.created":{const O=typeof A.workspaceId=="string"?A.workspaceId:"";return O&&u(O),!0}case"task.started":{const O=typeof A.taskId=="string"?A.taskId:"",C=typeof A.sessionId=="string"?A.sessionId:"",M=typeof A.workspaceId=="string"?A.workspaceId:"";return o(G=>O&&G===O?void 0:G),C&&O&&s(G=>G.map(U=>U.id===O?{...U,latestSessionId:C}:U)),m(M,O),!0}case"task.completed":case"task.deleted":case"task.reparented":case"task.updated":{const O=typeof A.workspaceId=="string"?A.workspaceId:"",C=typeof A.taskId=="string"?A.taskId:"";return m(O,C),!0}default:return!1}},[u,m]),g=y.useCallback(()=>{o(void 0)},[]),v=y.useCallback(E=>{var A,O;if(E.type==="tasks"){const C=Array.isArray((A=E.payload)==null?void 0:A.tasks)?E.payload.tasks:[],M=typeof((O=E.payload)==null?void 0:O.workspaceId)=="string"&&E.payload.workspaceId?E.payload.workspaceId:"";return s(M?G=>[...G.filter(U=>U.workspaceId!==M),...C]:G=>{const U=new Set(C.map(V=>V.id));return[...G.filter(V=>!U.has(V.id)),...C]}),!0}return!1},[]),b=y.useCallback((E,A,O,C,M,G,U,V,Z)=>{we.createTask({workspaceId:E,title:A,description:O||"",dependsOn:C||[],parentTaskId:M||"",defaultPersonaId:G||void 0,canDecompose:U??void 0}).then(()=>{V==null||V()},ee=>{const ie=ee instanceof Ec?ee.message:"Failed to create task";Z==null||Z(ie)})},[]),_=y.useCallback((E,A,O,C)=>{o(E),we.startTask({taskId:E,personaId:A||"",environmentId:O||"",notes:C||""}).catch(()=>{o(void 0)})},[]),S=y.useCallback(E=>{we.stopTask({id:E}).catch(()=>{})},[]),T=y.useCallback(E=>{we.completeTask({id:E}).catch(()=>{})},[]),N=y.useCallback(E=>{we.resumeTask({id:E}).catch(()=>{})},[]),j=y.useCallback((E,A,O,C,M)=>{we.updateTask({id:E,title:A,description:O,dependsOn:C,...M!==void 0?{defaultPersonaId:M}:{}}).catch(()=>{})},[]),w=y.useCallback(E=>{we.deleteTask({id:E}).catch(()=>{})},[]);return{tasks:n,taskStartingId:i,loadTasks:u,loadAllTasks:d,createTask:b,startTask:_,stopTask:S,completeTask:T,resumeTask:N,updateTask:j,deleteTask:w,handleEvent:h,onDisconnect:g,handleLegacyMessage:v}}function M2(){const[n,s]=y.useState([]),i=y.useCallback(u=>{we.queryFindings({workspaceId:u}).then(d=>{s(d.findings.map(T2))},()=>{})},[]),o=y.useCallback(u=>{if(u.type==="finding.posted"){const d=typeof u.payload.workspaceId=="string"?u.payload.workspaceId:"";return d&&i(d),!0}return!1},[i]),c=y.useCallback((u,d,m,h,g)=>{we.postFinding({workspaceId:u,title:d,content:m,category:h??"general",tags:g??[]}).catch(()=>{})},[]);return{findings:n,loadFindings:i,postFinding:c,handleEvent:o}}function O2(){const[n,s]=y.useState([]),i=y.useCallback(()=>{we.listTokens({}).then(d=>{s(d.tokens.map(k2))},()=>{})},[]),o=y.useCallback(d=>d.type==="token.changed"?(i(),!0):!1,[i]),c=y.useCallback((d,m,h,g,v)=>{we.setToken({name:d,value:m,type:h,envVar:g,filePath:v}).catch(()=>{})},[]),u=y.useCallback(d=>{we.deleteToken({name:d}).catch(()=>{})},[]);return{tokens:n,loadTokens:i,setToken:c,deleteToken:u,handleEvent:o}}function I2(){const[n,s]=y.useState({claude:"off",github:"off",copilot:"off",codex:"off",goose:"off"}),i=y.useCallback(()=>{we.getCredentialProviders({}).then(u=>{s(w2(u))},()=>{})},[]),o=y.useCallback(u=>u.type==="credential.providers_changed"?(b2(u.payload)&&s(u.payload),!0):!1,[]),c=y.useCallback(u=>{const d=[{provider:"claude",value:u.claude},{provider:"github",value:u.github},{provider:"copilot",value:u.copilot},{provider:"codex",value:u.codex},{provider:"goose",value:u.goose}];for(const{provider:m,value:h}of d)we.setCredentialProvider({provider:m,value:h}).catch(()=>{})},[]);return{credentialProviders:n,loadCredentials:i,updateCredentialProviders:c,handleEvent:o}}function B2(){const[n,s]=y.useState([]),[i,o]=y.useState(""),[c,u]=y.useState(""),[d,m]=y.useState(!1),h=y.useCallback(()=>{we.listCodespaces({}).then(v=>{s(v.codespaces.map(N2)),u(v.error)},()=>{})},[]),g=y.useCallback((v,b)=>{m(!0),o(""),we.createCodespace({repo:v,machine:b??""}).then(()=>{m(!1),h()},_=>{m(!1);const S=_ instanceof Ec?_.message:"Failed to create codespace";o(S)})},[h]);return{codespaces:n,codespaceError:i,codespaceListError:c,codespaceCreating:d,listCodespaces:h,createCodespace:g}}function L2(){const[n,s]=y.useState([]),i=y.useCallback(()=>{we.listPersonas({}).then(m=>{s(m.personas.map(of))},()=>{})},[]),o=y.useCallback(m=>{switch(m.type){case"persona.created":case"persona.updated":case"persona.deleted":return i(),!0;default:return!1}},[i]),c=y.useCallback((m,h,g,v,b,_,S,T,N)=>we.createPersona({name:m,description:h,systemPrompt:g,runtime:v||"",model:b||"",maxTurns:_||0,type:S||"agent",script:T||"",allowedMcpTools:N||[]}).then(j=>{const w=of(j);return s(E=>[...E.filter(A=>A.id!==w.id),w]),w}),[]),u=y.useCallback((m,h,g,v,b,_,S,T,N,j)=>{const w={id:m};return h!==void 0&&(w.name=h),g!==void 0&&(w.description=g),v!==void 0&&(w.systemPrompt=v),b!==void 0&&(w.runtime=b),_!==void 0&&(w.model=_),S!==void 0&&(w.maxTurns=S),T!==void 0&&(w.type=T),N!==void 0&&(w.script=N),j!==void 0&&(w.allowedMcpTools=j),we.updatePersona(w).then(E=>{const A=of(E);return s(O=>O.map(C=>C.id===A.id?A:C)),A})},[]),d=y.useCallback(async m=>{await we.deletePersona({id:m}),s(h=>h.filter(g=>g.id!==m))},[]);return{personas:n,loadPersonas:i,createPersona:c,updatePersona:u,deletePersona:d,handleEvent:o}}function U2(n){if(n)try{return JSON.parse(n)}catch{return}}function z2(){const[n,s]=y.useState(new Map),[i,o]=y.useState([]),[c,u]=y.useState(void 0),[d,m]=y.useState(void 0),[h,g]=y.useState(!1),[v,b]=y.useState(""),_=y.useRef(""),S=y.useCallback(O=>{const C=O??"";_.current=C,b(""),g(!0),we.listRecentKnowledgeNodes({limit:30,workspaceId:C}).then(M=>{const G=new Map,U=[];for(const V of M.nodes)G.set(V.id,ec(V));for(const V of M.edges)U.push(rf(V));for(const V of U){const Z=G.get(V.source);Z&&(Z.val+=1);const ee=G.get(V.target);ee&&(ee.val+=1)}s(G),o(U),g(!1)},()=>{g(!1)})},[]),T=y.useCallback(O=>{O.trim()&&(b(O),m(void 0),u(void 0),g(!0),we.searchKnowledge({query:O,limit:20,workspaceId:_.current}).then(C=>{const M=new Map,G=[];for(const U of C.results){U.node&&M.set(U.node.id,ec(U.node,U.edges.length));for(const V of U.edges)G.push(rf(V))}s(M),o(G),g(!1)},()=>{g(!1)}))},[]),N=y.useCallback(()=>{S(_.current)},[S]),j=y.useCallback(O=>{m(O),we.getKnowledgeNode({id:O}).then(C=>{if(!C.node){u(void 0);return}u({node:ec(C.node,C.edges.length),edges:C.edges.map(M=>({fromId:M.fromId,toId:M.toId,type:M.type,metadata:U2(M.metadataJson)}))})},()=>{u(void 0)})},[]),w=y.useCallback(()=>{m(void 0),u(void 0)},[]),E=y.useCallback(O=>{we.expandKnowledgeNode({id:O,depth:1}).then(C=>{s(M=>{const G=new Map(M);for(const U of C.nodes)G.has(U.id)||G.set(U.id,ec(U));return G}),o(M=>{const G=new Set(M.map(V=>`${V.source}:${V.target}:${V.type}`)),U=[];for(const V of C.edges){const Z=rf(V),ee=`${Z.source}:${Z.target}:${Z.type}`;G.has(ee)||U.push(Z)}return[...M,...U]})},()=>{})},[]),A=y.useCallback(O=>!1,[]);return{graphData:{nodes:[...n.values()],links:i},selectedNode:c,selectedId:d,loading:h,searchQuery:v,search:T,clearSearch:N,selectNode:j,clearSelection:w,expandNode:E,loadRecent:S,handleEvent:A}}function P2(){const[n,s]=y.useState(""),[i,o]=y.useState(void 0),[c,u]=y.useState({}),d=C2(),m=A2(),h=D2(),g=R2(),v=M2(),b=O2(),_=I2(),S=B2(),T=L2(),N=z2(),{connected:j}=g2({onSessionEvent:Z=>{m.handleSessionEvent({sessionId:Z.sessionId,eventType:ob(Z.type),timestamp:Z.timestamp,content:Z.content,raw:Z.raw||void 0})},onDomainEvent:Z=>{try{const ee=JSON.parse(Z.payloadJson);M({id:Z.id,type:Z.type,timestamp:Z.timestamp,payload:ee})}catch{console.warn("[grackle] Failed to parse domain event payloadJson:",Z.payloadJson)}},onConnect:G,onDisconnect:U}),w="default_persona_id",E="onboarding_completed",A=y.useCallback(async Z=>{const ee=await we.setSetting({key:w,value:Z});s(ee.value)},[]),O=y.useCallback(()=>{o(!0),we.setSetting({key:E,value:"true"}).catch(()=>{})},[]),C=y.useCallback((Z,ee)=>{we.getUsage({scope:Z,id:ee}).then(ie=>{const be=`${Z}:${ee}`;u(K=>({...K,[be]:j2(ie)}))},()=>{})},[]);function M(Z){const ee=Z.payload.key,ie=Z.payload.value;if(Z.type==="setting.changed"){ee===w&&s(ie??""),ee===E&&o(ie==="true");return}if(d.handleEvent(Z)){(Z.type==="environment.removed"||Z.type==="environment.changed")&&m.loadSessions();return}if(!h.handleEvent(Z)){if(g.handleEvent(Z)){Z.type==="task.started"&&m.loadSessions();return}v.handleEvent(Z)||b.handleEvent(Z)||_.handleEvent(Z)||T.handleEvent(Z)||N.handleEvent(Z)}}function G(){d.loadEnvironments(),m.loadSessions(),h.loadWorkspaces(),b.loadTokens(),_.loadCredentials(),T.loadPersonas(),we.getSetting({key:w}).then(Z=>{s(Z.value)},()=>{}),we.getSetting({key:E}).then(Z=>{o(Z.value==="true")},()=>{}),g.loadAllTasks()}function U(){h.onDisconnect(),g.onDisconnect()}const V=y.useCallback(()=>{d.loadEnvironments(),m.loadSessions(),h.loadWorkspaces(),b.loadTokens()},[d.loadEnvironments,m.loadSessions,h.loadWorkspaces,b.loadTokens]);return{connected:j,environments:d.environments,sessions:m.sessions,events:m.events,eventsDropped:m.eventsDropped,lastSpawnedId:m.lastSpawnedId,workspaces:h.workspaces,tasks:g.tasks,findings:v.findings,tokens:b.tokens,spawn:m.spawn,sendInput:m.sendInput,kill:m.kill,stopGraceful:m.stopGraceful,refresh:V,loadSessionEvents:m.loadSessionEvents,clearEvents:m.clearEvents,loadWorkspaces:h.loadWorkspaces,createWorkspace:h.createWorkspace,archiveWorkspace:h.archiveWorkspace,updateWorkspace:h.updateWorkspace,loadTasks:g.loadTasks,loadAllTasks:g.loadAllTasks,createTask:g.createTask,startTask:g.startTask,stopTask:g.stopTask,completeTask:g.completeTask,resumeTask:g.resumeTask,updateTask:g.updateTask,deleteTask:g.deleteTask,loadFindings:v.loadFindings,postFinding:v.postFinding,loadEnvironments:d.loadEnvironments,addEnvironment:d.addEnvironment,updateEnvironment:d.updateEnvironment,loadTokens:b.loadTokens,setToken:b.setToken,deleteToken:b.deleteToken,credentialProviders:_.credentialProviders,updateCredentialProviders:_.updateCredentialProviders,provisionStatus:d.provisionStatus,provisionEnvironment:d.provisionEnvironment,stopEnvironment:d.stopEnvironment,removeEnvironment:d.removeEnvironment,codespaces:S.codespaces,codespaceError:S.codespaceError,codespaceListError:S.codespaceListError,codespaceCreating:S.codespaceCreating,listCodespaces:S.listCodespaces,createCodespace:S.createCodespace,workspaceCreating:h.workspaceCreating,taskStartingId:g.taskStartingId,personas:T.personas,createPersona:T.createPersona,updatePersona:T.updatePersona,deletePersona:T.deletePersona,taskSessions:m.taskSessions,loadTaskSessions:m.loadTaskSessions,appDefaultPersonaId:n,setAppDefaultPersonaId:A,onboardingCompleted:i,completeOnboarding:O,usageCache:c,loadUsage:C,knowledge:N}}const _p=y.createContext(void 0);function V2({children:n}){const s=P2();return l.jsx(_p.Provider,{value:s,children:n})}function pt(){const n=y.useContext(_p);if(!n)throw new Error("useGrackle must be used within GrackleProvider");return n}const ns=[{id:"kn-auth-flow",label:"Authentication Flow",kind:"knowledge",category:"concept",content:"The application uses JWT Bearer tokens for stateless authentication. Access tokens expire after 24h. Refresh tokens are stored in the database and rotated on use. The auth middleware verifies tokens and attaches the decoded payload to req.user.",tags:["auth","jwt","security"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:30:00Z",updatedAt:"2026-02-27T08:15:00Z",val:5},{id:"kn-db-schema",label:"Database Schema",kind:"knowledge",category:"concept",content:"PostgreSQL database with tables: users, sessions, refresh_tokens, audit_log. Uses UUID primary keys, TIMESTAMPTZ for all timestamps, and JSONB for flexible metadata columns. Connection pooling via pg-pool with per-tenant isolation.",tags:["database","postgres","schema"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:00:00Z",updatedAt:"2026-02-26T22:45:00Z",val:4},{id:"kn-error-handling",label:"Error Response Pattern",kind:"knowledge",category:"concept",content:"All API errors follow the shape { error: string, code: string, details?: unknown }. HTTP status codes map to: 400 (validation), 401 (unauthenticated), 403 (forbidden), 404 (not found), 409 (conflict), 429 (rate limited), 500 (internal).",tags:["api","errors","patterns"],workspaceId:"proj-alpha",createdAt:"2026-02-27T08:17:00Z",updatedAt:"2026-02-27T08:17:00Z",val:3},{id:"kn-rate-limiting",label:"Rate Limiting Strategy",kind:"knowledge",category:"concept",content:"Token-bucket algorithm with in-memory state per client IP. Default rate: 100 requests/minute, burst: 20. Returns 429 with Retry-After header. Redis adapter available for multi-instance deployments.",tags:["api","rate-limiting","infrastructure"],workspaceId:"proj-alpha",createdAt:"2026-02-27T09:00:00Z",updatedAt:"2026-02-27T09:00:00Z",val:2},{id:"kn-etl-pipeline",label:"ETL Pipeline Architecture",kind:"knowledge",category:"concept",content:"Data pipelines follow an Extract-Transform-Load pattern with pluggable stages. Each stage reads from a source (Postgres, S3, API), transforms via configurable mappers, and loads into a target (Parquet, BigQuery, S3). Incremental loads use high-watermark tracking.",tags:["etl","pipeline","architecture"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:00:00Z",updatedAt:"2026-02-27T09:05:00Z",val:4},{id:"kn-parquet-format",label:"Parquet Output Format",kind:"knowledge",category:"concept",content:"Parquet files are written with row-group buffering (configurable batch size, default 10000 rows). Supports Snappy, ZSTD, and GZIP compression. Schema is derived from the internal column type system using Arrow type mapping.",tags:["parquet","data-format","compression"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:05:00Z",updatedAt:"2026-02-26T08:15:00Z",val:3},{id:"kn-jwt-over-session",label:"JWT over Session Auth",kind:"knowledge",category:"decision",content:"Chose JWT tokens over server-side sessions for stateless auth. Rationale: (1) no session store needed, (2) works across microservices without shared state, (3) supports mobile clients natively. Trade-off: tokens can't be revoked instantly (mitigated by short expiry + refresh rotation).",tags:["auth","decision","jwt"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:00:00Z",updatedAt:"2026-02-25T10:00:00Z",val:3},{id:"kn-pg-pool-decision",label:"pg-pool over Knex",kind:"knowledge",category:"decision",content:"Chose pg-pool over Knex for connection pooling. pg-pool gives direct control over idle timeout, max connections, and health check queries. Knex wraps pg-pool and adds query-building overhead we don't need since we write raw SQL with parameterized queries.",tags:["database","decision","postgres"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:30:00Z",updatedAt:"2026-02-23T11:30:00Z",val:2},{id:"kn-watermark-decision",label:"Local Watermark Storage",kind:"knowledge",category:"decision",content:"Currently using local SQLite for watermark storage. This works for single-worker pipelines but needs to move to a shared store (Redis or Postgres) for production multi-worker scenarios. Tracked as a follow-up task.",tags:["pipeline","decision","watermarks"],workspaceId:"proj-beta",createdAt:"2026-02-27T09:05:00Z",updatedAt:"2026-02-27T09:05:00Z",val:2},{id:"kn-jwt-middleware",label:"JWT Verify Middleware",kind:"knowledge",category:"snippet",content:`\`\`\`typescript
|
|
37
|
+
Please change the parent <Route path="${w}"> to <Route path="${w==="/"?"*":`${w}/*`}">.`)}let v=It(),b;if(s){let w=typeof s=="string"?ao(s):s;dt(h==="/"||((j=w.pathname)==null?void 0:j.startsWith(h)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${h}" but pathname "${w.pathname}" was given in the \`location\` prop.`),b=w}else b=v;let _=b.pathname||"/",S=_;if(h!=="/"){let w=h.replace(/^\//,"").split("/");S="/"+_.replace(/^\//,"").split("/").slice(w.length).join("/")}let T=cb(n,{pathname:S});Ln(g||T!=null,`No routes matched location "${b.pathname}${b.search}${b.hash}" `),Ln(T==null||T[T.length-1].route.element!==void 0||T[T.length-1].route.Component!==void 0||T[T.length-1].route.lazy!==void 0,`Matched leaf route at location "${b.pathname}${b.search}${b.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let N=vk(T&&T.map(w=>Object.assign({},w,{params:Object.assign({},d,w.params),pathname:ss([h,o.encodeLocation?o.encodeLocation(w.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:w.pathname]),pathnameBase:w.pathnameBase==="/"?h:ss([h,o.encodeLocation?o.encodeLocation(w.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:w.pathnameBase])})),c,i);return s&&N?y.createElement(Cr.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",unstable_mask:void 0,...b},navigationType:"POP"}},N):N}function pk(){let n=Sk(),s=XT(n)?`${n.status} ${n.statusText}`:n instanceof Error?n.message:JSON.stringify(n),i=n instanceof Error?n.stack:null,o="rgba(200,200,200, 0.5)",c={padding:"0.5rem",backgroundColor:o},u={padding:"2px 4px",backgroundColor:o},d=null;return console.error("Error handled by React Router default ErrorBoundary:",n),d=y.createElement(y.Fragment,null,y.createElement("p",null,"💿 Hey developer 👋"),y.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",y.createElement("code",{style:u},"ErrorBoundary")," or"," ",y.createElement("code",{style:u},"errorElement")," prop on your route.")),y.createElement(y.Fragment,null,y.createElement("h2",null,"Unexpected Application Error!"),y.createElement("h3",{style:{fontStyle:"italic"}},s),i?y.createElement("pre",{style:c},i):null,d)}var mk=y.createElement(pk,null),xb=class extends y.Component{constructor(n){super(n),this.state={location:n.location,revalidation:n.revalidation,error:n.error}}static getDerivedStateFromError(n){return{error:n}}static getDerivedStateFromProps(n,s){return s.location!==n.location||s.revalidation!=="idle"&&n.revalidation==="idle"?{error:n.error,location:n.location,revalidation:n.revalidation}:{error:n.error!==void 0?n.error:s.error,location:s.location,revalidation:n.revalidation||s.revalidation}}componentDidCatch(n,s){this.props.onError?this.props.onError(n,s):console.error("React Router caught the following error during render",n)}render(){let n=this.state.error;if(this.context&&typeof n=="object"&&n&&"digest"in n&&typeof n.digest=="string"){const i=rk(n.digest);i&&(n=i)}let s=n!==void 0?y.createElement(Un.Provider,{value:this.props.routeContext},y.createElement(pp.Provider,{value:n,children:this.props.component})):this.props.children;return this.context?y.createElement(hk,{error:n},s):s}};xb.contextType=tk;var nf=new WeakMap;function hk({children:n,error:s}){let{basename:i}=y.useContext(Sn);if(typeof s=="object"&&s&&"digest"in s&&typeof s.digest=="string"){let o=ok(s.digest);if(o){let c=nf.get(s);if(c)throw c;let u=mb(o.location,i);if(pb&&!nf.get(s))if(u.isExternal||o.reloadDocument)window.location.href=u.absoluteURL||u.to;else{const d=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(u.to,{replace:o.replace}));throw nf.set(s,d),d}return y.createElement("meta",{httpEquiv:"refresh",content:`0;url=${u.absoluteURL||u.to}`})}}return n}function gk({routeContext:n,match:s,children:i}){let o=y.useContext(io);return o&&o.static&&o.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=s.route.id),y.createElement(Un.Provider,{value:n},i)}function vk(n,s=[],i){let o=i==null?void 0:i.state;if(n==null){if(!o)return null;if(o.errors)n=o.matches;else if(s.length===0&&!o.initialized&&o.matches.length>0)n=o.matches;else return null}let c=n,u=o==null?void 0:o.errors;if(u!=null){let v=c.findIndex(b=>b.route.id&&(u==null?void 0:u[b.route.id])!==void 0);dt(v>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(u).join(",")}`),c=c.slice(0,Math.min(c.length,v+1))}let d=!1,m=-1;if(i&&o){d=o.renderFallback;for(let v=0;v<c.length;v++){let b=c[v];if((b.route.HydrateFallback||b.route.hydrateFallbackElement)&&(m=v),b.route.id){let{loaderData:_,errors:S}=o,T=b.route.loader&&!_.hasOwnProperty(b.route.id)&&(!S||S[b.route.id]===void 0);if(b.route.lazy||T){i.isStatic&&(d=!0),m>=0?c=c.slice(0,m+1):c=[c[0]];break}}}}let h=i==null?void 0:i.onError,g=o&&h?(v,b)=>{var _,S;h(v,{location:o.location,params:((S=(_=o.matches)==null?void 0:_[0])==null?void 0:S.params)??{},unstable_pattern:QT(o.matches),errorInfo:b})}:void 0;return c.reduceRight((v,b,_)=>{let S,T=!1,N=null,j=null;o&&(S=u&&b.route.id?u[b.route.id]:void 0,N=b.route.errorElement||mk,d&&(m<0&&_===0?(Sb("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),T=!0,j=null):m===_&&(T=!0,j=b.route.hydrateFallbackElement||null)));let w=s.concat(c.slice(0,_+1)),E=()=>{let A;return S?A=N:T?A=j:b.route.Component?A=y.createElement(b.route.Component,null):b.route.element?A=b.route.element:A=v,y.createElement(gk,{match:b,routeContext:{outlet:v,matches:w,isDataRoute:o!=null},children:A})};return o&&(b.route.ErrorBoundary||b.route.errorElement||_===0)?y.createElement(xb,{location:o.location,revalidation:o.revalidation,component:N,error:S,children:E(),routeContext:{outlet:null,matches:w,isDataRoute:!0},onError:g}):E()},null)}function mp(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function yk(n){let s=y.useContext(io);return dt(s,mp(n)),s}function bk(n){let s=y.useContext(Dc);return dt(s,mp(n)),s}function _k(n){let s=y.useContext(Un);return dt(s,mp(n)),s}function hp(n){let s=_k(n),i=s.matches[s.matches.length-1];return dt(i.route.id,`${n} can only be used on routes that contain a unique "id"`),i.route.id}function xk(){return hp("useRouteId")}function Sk(){var o;let n=y.useContext(pp),s=bk("useRouteError"),i=hp("useRouteError");return n!==void 0?n:(o=s.errors)==null?void 0:o[i]}function Tk(){let{router:n}=yk("useNavigate"),s=hp("useNavigate"),i=y.useRef(!1);return bb(()=>{i.current=!0}),y.useCallback(async(c,u={})=>{Ln(i.current,yb),i.current&&(typeof c=="number"?await n.navigate(c):await n.navigate(c,{fromRouteId:s,...u}))},[n,s])}var p0={};function Sb(n,s,i){!s&&!p0[n]&&(p0[n]=!0,Ln(!1,i))}y.memo(kk);function kk({routes:n,future:s,state:i,isStatic:o,onError:c}){return _b(n,void 0,{state:i,isStatic:o,onError:c})}function Zn({to:n,replace:s,state:i,relative:o}){dt(Xa(),"<Navigate> may be used only in the context of a <Router> component.");let{static:c}=y.useContext(Sn);Ln(!c,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:u}=y.useContext(Un),{pathname:d}=It(),m=Rc(),h=Ac(n,fp(u),d,o==="path"),g=JSON.stringify(h);return y.useEffect(()=>{m(JSON.parse(g),{replace:s,state:i,relative:o})},[m,g,o,s,i]),null}function Qa(n){return dk(n.context)}function Ce(n){dt(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function wk({basename:n="/",children:s=null,location:i,navigationType:o="POP",navigator:c,static:u=!1,unstable_useTransitions:d}){dt(!Xa(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let m=n.replace(/^\/*/,"/"),h=y.useMemo(()=>({basename:m,navigator:c,static:u,unstable_useTransitions:d,future:{}}),[m,c,u,d]);typeof i=="string"&&(i=ao(i));let{pathname:g="/",search:v="",hash:b="",state:_=null,key:S="default",unstable_mask:T}=i,N=y.useMemo(()=>{let j=Os(g,m);return j==null?null:{location:{pathname:j,search:v,hash:b,state:_,key:S,unstable_mask:T},navigationType:o}},[m,g,v,b,_,S,o,T]);return Ln(N!=null,`<Router basename="${m}"> is not able to match the URL "${g}${v}${b}" because it does not start with the basename, so the <Router> won't render anything.`),N==null?null:y.createElement(Sn.Provider,{value:h},y.createElement(Cr.Provider,{children:s,value:N}))}function Nk({children:n,location:s}){return fk(Uf(n),s)}function Uf(n,s=[]){let i=[];return y.Children.forEach(n,(o,c)=>{if(!y.isValidElement(o))return;let u=[...s,c];if(o.type===y.Fragment){i.push.apply(i,Uf(o.props.children,u));return}dt(o.type===Ce,`[${typeof o.type=="string"?o.type:o.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),dt(!o.props.index||!o.props.children,"An index route cannot have child routes.");let d={id:o.props.id||u.join("-"),caseSensitive:o.props.caseSensitive,element:o.props.element,Component:o.props.Component,index:o.props.index,path:o.props.path,middleware:o.props.middleware,loader:o.props.loader,action:o.props.action,hydrateFallbackElement:o.props.hydrateFallbackElement,HydrateFallback:o.props.HydrateFallback,errorElement:o.props.errorElement,ErrorBoundary:o.props.ErrorBoundary,hasErrorBoundary:o.props.hasErrorBoundary===!0||o.props.ErrorBoundary!=null||o.props.errorElement!=null,shouldRevalidate:o.props.shouldRevalidate,handle:o.props.handle,lazy:o.props.lazy};o.props.children&&(d.children=Uf(o.props.children,u)),i.push(d)}),i}var uc="get",dc="application/x-www-form-urlencoded";function Mc(n){return typeof HTMLElement<"u"&&n instanceof HTMLElement}function jk(n){return Mc(n)&&n.tagName.toLowerCase()==="button"}function Ck(n){return Mc(n)&&n.tagName.toLowerCase()==="form"}function Ek(n){return Mc(n)&&n.tagName.toLowerCase()==="input"}function Ak(n){return!!(n.metaKey||n.altKey||n.ctrlKey||n.shiftKey)}function Dk(n,s){return n.button===0&&(!s||s==="_self")&&!Ak(n)}function zf(n=""){return new URLSearchParams(typeof n=="string"||Array.isArray(n)||n instanceof URLSearchParams?n:Object.keys(n).reduce((s,i)=>{let o=n[i];return s.concat(Array.isArray(o)?o.map(c=>[i,c]):[[i,o]])},[]))}function Rk(n,s){let i=zf(n);return s&&s.forEach((o,c)=>{i.has(c)||s.getAll(c).forEach(u=>{i.append(c,u)})}),i}var Xl=null;function Mk(){if(Xl===null)try{new FormData(document.createElement("form"),0),Xl=!1}catch{Xl=!0}return Xl}var Ok=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function sf(n){return n!=null&&!Ok.has(n)?(Ln(!1,`"${n}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${dc}"`),null):n}function Ik(n,s){let i,o,c,u,d;if(Ck(n)){let m=n.getAttribute("action");o=m?Os(m,s):null,i=n.getAttribute("method")||uc,c=sf(n.getAttribute("enctype"))||dc,u=new FormData(n)}else if(jk(n)||Ek(n)&&(n.type==="submit"||n.type==="image")){let m=n.form;if(m==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let h=n.getAttribute("formaction")||m.getAttribute("action");if(o=h?Os(h,s):null,i=n.getAttribute("formmethod")||m.getAttribute("method")||uc,c=sf(n.getAttribute("formenctype"))||sf(m.getAttribute("enctype"))||dc,u=new FormData(m,n),!Mk()){let{name:g,type:v,value:b}=n;if(v==="image"){let _=g?`${g}.`:"";u.append(`${_}x`,"0"),u.append(`${_}y`,"0")}else g&&u.append(g,b)}}else{if(Mc(n))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');i=uc,o=null,c=dc,d=n}return u&&c==="text/plain"&&(d=u,u=void 0),{action:o,method:i.toLowerCase(),encType:c,formData:u,body:d}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function gp(n,s){if(n===!1||n===null||typeof n>"u")throw new Error(s)}function Bk(n,s,i,o){let c=typeof n=="string"?new URL(n,typeof window>"u"?"server://singlefetch/":window.location.origin):n;return i?c.pathname.endsWith("/")?c.pathname=`${c.pathname}_.${o}`:c.pathname=`${c.pathname}.${o}`:c.pathname==="/"?c.pathname=`_root.${o}`:s&&Os(c.pathname,s)==="/"?c.pathname=`${s.replace(/\/$/,"")}/_root.${o}`:c.pathname=`${c.pathname.replace(/\/$/,"")}.${o}`,c}async function Lk(n,s){if(n.id in s)return s[n.id];try{let i=await import(n.module);return s[n.id]=i,i}catch(i){return console.error(`Error loading route module \`${n.module}\`, reloading page...`),console.error(i),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Uk(n){return n==null?!1:n.href==null?n.rel==="preload"&&typeof n.imageSrcSet=="string"&&typeof n.imageSizes=="string":typeof n.rel=="string"&&typeof n.href=="string"}async function zk(n,s,i){let o=await Promise.all(n.map(async c=>{let u=s.routes[c.route.id];if(u){let d=await Lk(u,i);return d.links?d.links():[]}return[]}));return Hk(o.flat(1).filter(Uk).filter(c=>c.rel==="stylesheet"||c.rel==="preload").map(c=>c.rel==="stylesheet"?{...c,rel:"prefetch",as:"style"}:{...c,rel:"prefetch"}))}function m0(n,s,i,o,c,u){let d=(h,g)=>i[g]?h.route.id!==i[g].route.id:!0,m=(h,g)=>{var v;return i[g].pathname!==h.pathname||((v=i[g].route.path)==null?void 0:v.endsWith("*"))&&i[g].params["*"]!==h.params["*"]};return u==="assets"?s.filter((h,g)=>d(h,g)||m(h,g)):u==="data"?s.filter((h,g)=>{var b;let v=o.routes[h.route.id];if(!v||!v.hasLoader)return!1;if(d(h,g)||m(h,g))return!0;if(h.route.shouldRevalidate){let _=h.route.shouldRevalidate({currentUrl:new URL(c.pathname+c.search+c.hash,window.origin),currentParams:((b=i[0])==null?void 0:b.params)||{},nextUrl:new URL(n,window.origin),nextParams:h.params,defaultShouldRevalidate:!0});if(typeof _=="boolean")return _}return!0}):[]}function Pk(n,s,{includeHydrateFallback:i}={}){return Vk(n.map(o=>{let c=s.routes[o.route.id];if(!c)return[];let u=[c.module];return c.clientActionModule&&(u=u.concat(c.clientActionModule)),c.clientLoaderModule&&(u=u.concat(c.clientLoaderModule)),i&&c.hydrateFallbackModule&&(u=u.concat(c.hydrateFallbackModule)),c.imports&&(u=u.concat(c.imports)),u}).flat(1))}function Vk(n){return[...new Set(n)]}function qk(n){let s={},i=Object.keys(n).sort();for(let o of i)s[o]=n[o];return s}function Hk(n,s){let i=new Set;return new Set(s),n.reduce((o,c)=>{let u=JSON.stringify(qk(c));return i.has(u)||(i.add(u),o.push({key:u,link:c})),o},[])}function Tb(){let n=y.useContext(io);return gp(n,"You must render this element inside a <DataRouterContext.Provider> element"),n}function Gk(){let n=y.useContext(Dc);return gp(n,"You must render this element inside a <DataRouterStateContext.Provider> element"),n}var vp=y.createContext(void 0);vp.displayName="FrameworkContext";function kb(){let n=y.useContext(vp);return gp(n,"You must render this element inside a <HydratedRouter> element"),n}function $k(n,s){let i=y.useContext(vp),[o,c]=y.useState(!1),[u,d]=y.useState(!1),{onFocus:m,onBlur:h,onMouseEnter:g,onMouseLeave:v,onTouchStart:b}=s,_=y.useRef(null);y.useEffect(()=>{if(n==="render"&&d(!0),n==="viewport"){let N=w=>{w.forEach(E=>{d(E.isIntersecting)})},j=new IntersectionObserver(N,{threshold:.5});return _.current&&j.observe(_.current),()=>{j.disconnect()}}},[n]),y.useEffect(()=>{if(o){let N=setTimeout(()=>{d(!0)},100);return()=>{clearTimeout(N)}}},[o]);let S=()=>{c(!0)},T=()=>{c(!1),d(!1)};return i?n!=="intent"?[u,_,{}]:[u,_,{onFocus:ar(m,S),onBlur:ar(h,T),onMouseEnter:ar(g,S),onMouseLeave:ar(v,T),onTouchStart:ar(b,S)}]:[!1,_,{}]}function ar(n,s){return i=>{n&&n(i),i.defaultPrevented||s(i)}}function Fk({page:n,...s}){let{router:i}=Tb(),o=y.useMemo(()=>cb(i.routes,n,i.basename),[i.routes,n,i.basename]);return o?y.createElement(Kk,{page:n,matches:o,...s}):null}function Zk(n){let{manifest:s,routeModules:i}=kb(),[o,c]=y.useState([]);return y.useEffect(()=>{let u=!1;return zk(n,s,i).then(d=>{u||c(d)}),()=>{u=!0}},[n,s,i]),o}function Kk({page:n,matches:s,...i}){let o=It(),{future:c,manifest:u,routeModules:d}=kb(),{basename:m}=Tb(),{loaderData:h,matches:g}=Gk(),v=y.useMemo(()=>m0(n,s,g,u,o,"data"),[n,s,g,u,o]),b=y.useMemo(()=>m0(n,s,g,u,o,"assets"),[n,s,g,u,o]),_=y.useMemo(()=>{if(n===o.pathname+o.search+o.hash)return[];let N=new Set,j=!1;if(s.forEach(E=>{var O;let A=u.routes[E.route.id];!A||!A.hasLoader||(!v.some(C=>C.route.id===E.route.id)&&E.route.id in h&&((O=d[E.route.id])!=null&&O.shouldRevalidate)||A.hasClientLoader?j=!0:N.add(E.route.id))}),N.size===0)return[];let w=Bk(n,m,c.unstable_trailingSlashAwareDataRequests,"data");return j&&N.size>0&&w.searchParams.set("_routes",s.filter(E=>N.has(E.route.id)).map(E=>E.route.id).join(",")),[w.pathname+w.search]},[m,c.unstable_trailingSlashAwareDataRequests,h,o,u,v,s,n,d]),S=y.useMemo(()=>Pk(b,u),[b,u]),T=Zk(b);return y.createElement(y.Fragment,null,_.map(N=>y.createElement("link",{key:N,rel:"prefetch",as:"fetch",href:N,...i})),S.map(N=>y.createElement("link",{key:N,rel:"modulepreload",href:N,...i})),T.map(({key:N,link:j})=>y.createElement("link",{key:N,nonce:i.nonce,...j,crossOrigin:j.crossOrigin??i.crossOrigin})))}function Yk(...n){return s=>{n.forEach(i=>{typeof i=="function"?i(s):i!=null&&(i.current=s)})}}var Jk=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Jk&&(window.__reactRouterVersion="7.13.2")}catch{}function Wk({basename:n,children:s,unstable_useTransitions:i,window:o}){let c=y.useRef();c.current==null&&(c.current=ET({window:o,v5Compat:!0}));let u=c.current,[d,m]=y.useState({action:u.action,location:u.location}),h=y.useCallback(g=>{i===!1?m(g):y.startTransition(()=>m(g))},[i]);return y.useLayoutEffect(()=>u.listen(h),[u,h]),y.createElement(wk,{basename:n,children:s,location:d.location,navigationType:d.action,navigator:u,unstable_useTransitions:i})}var wb=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,yp=y.forwardRef(function({onClick:s,discover:i="render",prefetch:o="none",relative:c,reloadDocument:u,replace:d,unstable_mask:m,state:h,target:g,to:v,preventScrollReset:b,viewTransition:_,unstable_defaultShouldRevalidate:S,...T},N){let{basename:j,navigator:w,unstable_useTransitions:E}=y.useContext(Sn),A=typeof v=="string"&&wb.test(v),O=mb(v,j);v=O.to;let C=lk(v,{relative:c}),M=It(),G=null;if(m){let re=Ac(m,[],M.unstable_mask?M.unstable_mask.pathname:"/",!0);j!=="/"&&(re.pathname=re.pathname==="/"?j:ss([j,re.pathname])),G=w.createHref(re)}let[U,V,Z]=$k(o,T),ee=tw(v,{replace:d,unstable_mask:m,state:h,target:g,preventScrollReset:b,relative:c,viewTransition:_,unstable_defaultShouldRevalidate:S,unstable_useTransitions:E});function ie(re){s&&s(re),re.defaultPrevented||ee(re)}let be=!(O.isExternal||u),K=y.createElement("a",{...T,...Z,href:(be?G:void 0)||O.absoluteURL||C,onClick:be?ie:s,ref:Yk(N,V),target:g,"data-discover":!A&&i==="render"?"true":void 0});return U&&!A?y.createElement(y.Fragment,null,K,y.createElement(Fk,{page:C})):K});yp.displayName="Link";var Xk=y.forwardRef(function({"aria-current":s="page",caseSensitive:i=!1,className:o="",end:c=!1,style:u,to:d,viewTransition:m,children:h,...g},v){let b=Er(d,{relative:g.relative}),_=It(),S=y.useContext(Dc),{navigator:T,basename:N}=y.useContext(Sn),j=S!=null&&ow(b)&&m===!0,w=T.encodeLocation?T.encodeLocation(b).pathname:b.pathname,E=_.pathname,A=S&&S.navigation&&S.navigation.location?S.navigation.location.pathname:null;i||(E=E.toLowerCase(),A=A?A.toLowerCase():null,w=w.toLowerCase()),A&&N&&(A=Os(A,N)||A);const O=w!=="/"&&w.endsWith("/")?w.length-1:w.length;let C=E===w||!c&&E.startsWith(w)&&E.charAt(O)==="/",M=A!=null&&(A===w||!c&&A.startsWith(w)&&A.charAt(w.length)==="/"),G={isActive:C,isPending:M,isTransitioning:j},U=C?s:void 0,V;typeof o=="function"?V=o(G):V=[o,C?"active":null,M?"pending":null,j?"transitioning":null].filter(Boolean).join(" ");let Z=typeof u=="function"?u(G):u;return y.createElement(yp,{...g,"aria-current":U,className:V,ref:v,style:Z,to:d,viewTransition:m},typeof h=="function"?h(G):h)});Xk.displayName="NavLink";var Qk=y.forwardRef(({discover:n="render",fetcherKey:s,navigate:i,reloadDocument:o,replace:c,state:u,method:d=uc,action:m,onSubmit:h,relative:g,preventScrollReset:v,viewTransition:b,unstable_defaultShouldRevalidate:_,...S},T)=>{let{unstable_useTransitions:N}=y.useContext(Sn),j=aw(),w=iw(m,{relative:g}),E=d.toLowerCase()==="get"?"get":"post",A=typeof m=="string"&&wb.test(m),O=C=>{if(h&&h(C),C.defaultPrevented)return;C.preventDefault();let M=C.nativeEvent.submitter,G=(M==null?void 0:M.getAttribute("formmethod"))||d,U=()=>j(M||C.currentTarget,{fetcherKey:s,method:G,navigate:i,replace:c,state:u,relative:g,preventScrollReset:v,viewTransition:b,unstable_defaultShouldRevalidate:_});N&&i!==!1?y.startTransition(()=>U()):U()};return y.createElement("form",{ref:T,method:E,action:w,onSubmit:o?h:O,...S,"data-discover":!A&&n==="render"?"true":void 0})});Qk.displayName="Form";function ew(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Nb(n){let s=y.useContext(io);return dt(s,ew(n)),s}function tw(n,{target:s,replace:i,unstable_mask:o,state:c,preventScrollReset:u,relative:d,viewTransition:m,unstable_defaultShouldRevalidate:h,unstable_useTransitions:g}={}){let v=Rc(),b=It(),_=Er(n,{relative:d});return y.useCallback(S=>{if(Dk(S,s)){S.preventDefault();let T=i!==void 0?i:_r(b)===_r(_),N=()=>v(n,{replace:T,unstable_mask:o,state:c,preventScrollReset:u,relative:d,viewTransition:m,unstable_defaultShouldRevalidate:h});g?y.startTransition(()=>N()):N()}},[b,v,_,i,o,c,s,n,u,d,m,h,g])}function bp(n){Ln(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let s=y.useRef(zf(n)),i=y.useRef(!1),o=It(),c=y.useMemo(()=>Rk(o.search,i.current?null:s.current),[o.search]),u=Rc(),d=y.useCallback((m,h)=>{const g=zf(typeof m=="function"?m(new URLSearchParams(c)):m);i.current=!0,u("?"+g,h)},[u,c]);return[c,d]}var nw=0,sw=()=>`__${String(++nw)}__`;function aw(){let{router:n}=Nb("useSubmit"),{basename:s}=y.useContext(Sn),i=xk(),o=n.fetch,c=n.navigate;return y.useCallback(async(u,d={})=>{let{action:m,method:h,encType:g,formData:v,body:b}=Ik(u,s);if(d.navigate===!1){let _=d.fetcherKey||sw();await o(_,i,d.action||m,{unstable_defaultShouldRevalidate:d.unstable_defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:v,body:b,formMethod:d.method||h,formEncType:d.encType||g,flushSync:d.flushSync})}else await c(d.action||m,{unstable_defaultShouldRevalidate:d.unstable_defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:v,body:b,formMethod:d.method||h,formEncType:d.encType||g,replace:d.replace,state:d.state,fromRouteId:i,flushSync:d.flushSync,viewTransition:d.viewTransition})},[o,c,s,i])}function iw(n,{relative:s}={}){let{basename:i}=y.useContext(Sn),o=y.useContext(Un);dt(o,"useFormAction must be used inside a RouteContext");let[c]=o.matches.slice(-1),u={...Er(n||".",{relative:s})},d=It();if(n==null){u.search=d.search;let m=new URLSearchParams(u.search),h=m.getAll("index");if(h.some(v=>v==="")){m.delete("index"),h.filter(b=>b).forEach(b=>m.append("index",b));let v=m.toString();u.search=v?`?${v}`:""}}return(!n||n===".")&&c.route.index&&(u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index"),i!=="/"&&(u.pathname=u.pathname==="/"?i:ss([i,u.pathname])),_r(u)}function ow(n,{relative:s}={}){let i=y.useContext(gb);dt(i!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Nb("useViewTransitionState"),c=Er(n,{relative:s});if(!i.isTransitioning)return!1;let u=Os(i.currentLocation.pathname,o)||i.currentLocation.pathname,d=Os(i.nextLocation.pathname,o)||i.nextLocation.pathname;return xr(c.pathname,d)!=null||xr(c.pathname,u)!=null}function St(){const n=Rc();return y.useCallback((s,i)=>{typeof s=="number"?n(s):n(s,i)},[n])}function jb(n){return`/sessions/${encodeURIComponent(n)}`}function Wi(n,s){return s?`/environments/${encodeURIComponent(s)}/workspaces/${encodeURIComponent(n)}`:`/workspaces/${encodeURIComponent(n)}`}function os(n,s,i,o){const c=encodeURIComponent(n);let u;return i&&o?u=`/environments/${encodeURIComponent(o)}/workspaces/${encodeURIComponent(i)}/tasks/${c}`:i?u=`/workspaces/${encodeURIComponent(i)}/tasks/${c}`:u=`/tasks/${c}`,s?`${u}/${s}`:u}function ei(n,s,i){const o=new URLSearchParams;n&&o.set("workspace",n),s&&o.set("parent",s);const c=o.toString();if(n&&i){const u=`/environments/${encodeURIComponent(i)}/workspaces/${encodeURIComponent(n)}/tasks/new`;return s?`${u}?parent=${encodeURIComponent(s)}`:u}return c?`/tasks/new?${c}`:"/tasks/new"}function Cb(n){return`/sessions/new?${new URLSearchParams({env:n}).toString()}`}const Xi="/environments",rw="/environments/new";function Qi(n){return`/environments/${encodeURIComponent(n)}`}function lw(n){return`/environments/${encodeURIComponent(n)}/edit`}const Ji="/settings",cw="/settings/credentials",af="/settings/personas",uw="/settings/personas/new";function Eb(n){return`/settings/personas/${encodeURIComponent(n)}`}const dw="/settings/shortcuts",fw="/pair",pw="/chat",Ya="/",mw="/tasks",Ab="/workspaces/new",Db="/knowledge",hw=3e3;function gw(n){const[s,i]=y.useState(!1),o=y.useRef(n.onSessionEvent);o.current=n.onSessionEvent;const c=y.useRef(n.onDomainEvent);c.current=n.onDomainEvent;const u=y.useRef(n.onConnect);u.current=n.onConnect;const d=y.useRef(n.onDisconnect);return d.current=n.onDisconnect,y.useEffect(()=>{let m=!1,h;async function g(){var v,b;if(!m){try{const _=we.streamEvents({});i(!0),(v=u.current)==null||v.call(u);for await(const S of _){if(m)break;const T=S.event;if(T.case==="sessionEvent"){const N=T.value;o.current({sessionId:N.sessionId,type:N.type,timestamp:N.timestamp,content:N.content,raw:N.raw})}else if(T.case==="domainEvent"){const N=T.value;c.current({id:N.id,type:N.type,timestamp:N.timestamp,payloadJson:N.payloadJson})}}}catch(_){if(_ instanceof Ec&&_.code===uT.Unauthenticated){window.location.href=fw;return}}m||(i(!1),(b=d.current)==null||b.call(d),h=setTimeout(()=>{g().catch(()=>{})},hw))}}return g().catch(()=>{}),()=>{m=!0,clearTimeout(h),i(!1)}},[]),{connected:s}}function Rb(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Mb(n,s){return console.warn(`[ws] Malformed "${n}" message: ${s}`),!1}function vw(n){return Rb(n)&&typeof n.sessionId=="string"&&typeof n.eventType=="string"&&typeof n.timestamp=="string"&&typeof n.content=="string"&&(n.raw===void 0||typeof n.raw=="string")}const yw=new Set(["off","subscription","api_key"]),Ql=new Set(["off","on"]);function bw(n){return Rb(n)&&yw.has(n.claude)&&Ql.has(n.github)&&Ql.has(n.copilot)&&Ql.has(n.codex)&&Ql.has(n.goose)}function Ob(n){switch(n){case"waiting_input":return"idle";case"completed":return"stopped";case"killed":return"stopped";case"failed":return"stopped";case"interrupted":return"stopped";case"terminated":return"stopped";default:return n}}function Ib(n){switch(n){case"completed":return"completed";case"killed":return"killed";case"failed":return"interrupted";case"interrupted":return"interrupted";case"terminated":return"terminated";default:return}}const Vi=5e3;function _w(n){return{id:n.id,displayName:n.displayName,adapterType:n.adapterType,adapterConfig:n.adapterConfig||"{}",status:n.status,bootstrapped:n.bootstrapped}}function h0(n){return{id:n.id,environmentId:n.environmentId,runtime:n.runtime,status:n.status,prompt:n.prompt,startedAt:n.startedAt,endedAt:n.endedAt||void 0,error:n.error||void 0,endReason:n.endReason||void 0,personaId:n.personaId||void 0,inputTokens:n.inputTokens,outputTokens:n.outputTokens,costUsd:n.costUsd}}function xw(n){return{sessionId:n.sessionId,eventType:ob(n.type),timestamp:n.timestamp,content:n.content,raw:n.raw||void 0}}function Sw(n){return{id:n.id,name:n.name,description:n.description,repoUrl:n.repoUrl,environmentId:n.environmentId,status:dT(n.status),workingDirectory:n.workingDirectory,useWorktrees:n.useWorktrees,defaultPersonaId:n.defaultPersonaId,createdAt:n.createdAt,updatedAt:n.updatedAt}}function g0(n){return{id:n.id,workspaceId:n.workspaceId??void 0,title:n.title,description:n.description,status:fT(n.status),branch:n.branch,latestSessionId:n.latestSessionId,dependsOn:[...n.dependsOn],sortOrder:n.sortOrder,createdAt:n.createdAt,startedAt:n.startedAt||void 0,completedAt:n.completedAt||void 0,parentTaskId:n.parentTaskId,depth:n.depth,childTaskIds:[...n.childTaskIds],canDecompose:n.canDecompose,defaultPersonaId:n.defaultPersonaId,workpad:n.workpad}}function Tw(n){return{id:n.id,workspaceId:n.workspaceId,taskId:n.taskId,sessionId:n.sessionId,category:n.category,title:n.title,content:n.content,tags:[...n.tags],createdAt:n.createdAt}}function kw(n){return{name:n.name,tokenType:n.type,envVar:n.envVar,filePath:n.filePath,expiresAt:n.expiresAt}}function ww(n){return{claude:pT(n.claude),github:Wl(n.github),copilot:Wl(n.copilot),codex:Wl(n.codex),goose:Wl(n.goose)}}function Nw(n){return{name:n.name,repository:n.repository,state:n.state,gitStatus:n.gitStatus}}function of(n){return{id:n.id,name:n.name,description:n.description,systemPrompt:n.systemPrompt,toolConfig:n.toolConfig?JSON.stringify({allowedTools:[...n.toolConfig.allowedTools],disallowedTools:[...n.toolConfig.disallowedTools]}):"{}",runtime:n.runtime,model:n.model,maxTurns:n.maxTurns,mcpServers:JSON.stringify(n.mcpServers.map(s=>({name:s.name,command:s.command,args:[...s.args],tools:[...s.tools]}))),createdAt:n.createdAt,updatedAt:n.updatedAt,type:n.type||"agent",script:n.script,allowedMcpTools:[...n.allowedMcpTools]}}function jw(n){return{inputTokens:n.inputTokens,outputTokens:n.outputTokens,costUsd:n.costUsd,sessionCount:n.sessionCount}}function ec(n,s=0){return{id:n.id,label:n.title||n.label||n.id,kind:n.kind,category:n.category||void 0,sourceType:n.sourceType||void 0,sourceId:n.sourceId||void 0,content:n.content||void 0,tags:n.tags.length>0?[...n.tags]:void 0,workspaceId:n.workspaceId||void 0,createdAt:n.createdAt||void 0,updatedAt:n.updatedAt||void 0,val:s}}function rf(n){return{source:n.fromId,target:n.toId,type:n.type}}const v0=5e3;function Cw(){const[n,s]=y.useState([]),[i,o]=y.useState({}),c=y.useCallback(()=>{we.listEnvironments({}).then(_=>{s(_.environments.map(_w))},()=>{})},[]),u=y.useCallback(_=>{switch(_.type){case"environment.added":return!0;case"environment.removed":{const S=_.payload.environmentId;return S&&(s(T=>T.filter(N=>N.id!==S)),o(T=>{const N={...T};return delete N[S],N})),!0}case"environment.changed":return c(),!0;case"environment.provision_progress":{const S=_.payload;if(typeof S.environmentId!="string"||typeof S.stage!="string"||typeof S.message!="string"||typeof S.progress!="number")return Mb("environment.provision_progress","invalid payload"),!0;if(o(T=>({...T,[S.environmentId]:{stage:S.stage,message:S.message,progress:S.progress}})),S.stage==="ready"){const T=S.environmentId;setTimeout(()=>{o(N=>{const j={...N};return delete j[T],j})},v0)}return!0}default:return!1}},[c]),d=y.useCallback(_=>{var S;if(_.type==="environments"){const T=Array.isArray((S=_.payload)==null?void 0:S.environments)?_.payload.environments:[];return s(T),!0}return!1},[]),m=y.useCallback((_,S,T)=>{we.addEnvironment({displayName:_,adapterType:S,adapterConfig:JSON.stringify(T??{})}).catch(()=>{})},[]),h=y.useCallback((_,S)=>{we.updateEnvironment({id:_,displayName:S.displayName,adapterConfig:S.adapterConfig?JSON.stringify(S.adapterConfig):void 0}).catch(()=>{})},[]),g=y.useCallback((_,S)=>{(async()=>{try{const N=we.provisionEnvironment({id:_,force:S??!1});for await(const j of N)o(w=>({...w,[_]:{stage:j.stage,message:j.message,progress:j.progress}})),j.stage==="ready"&&setTimeout(()=>{o(w=>{const E={...w};return delete E[_],E})},v0)}catch{o(N=>{const j={...N};return delete j[_],j})}})().catch(()=>{})},[]),v=y.useCallback(_=>{we.stopEnvironment({id:_}).catch(()=>{})},[]),b=y.useCallback(_=>{we.removeEnvironment({id:_}).catch(()=>{})},[]);return{environments:n,provisionStatus:i,loadEnvironments:c,addEnvironment:m,updateEnvironment:h,provisionEnvironment:g,stopEnvironment:v,removeEnvironment:b,handleEvent:u,handleLegacyMessage:d}}const lf=new Set(["pending","running","idle"]),Ew=new Set(["completed","failed","interrupted","hibernating","suspended"]),y0=["pending","running","idle"];function Aw(){const[n,s]=y.useState([]),[i,o]=y.useState([]),[c,u]=y.useState(0),[d,m]=y.useState(void 0),[h,g]=y.useState({}),v=y.useCallback(()=>{we.listSessions({}).then(C=>{const M=C.sessions.map(h0);s(G=>{const U=new Map(G.map(V=>[V.id,V]));return M.map(V=>{const Z=U.get(V.id),ee=Z==null?void 0:Z.status;return!ee||ee===V.status?V:Ew.has(ee)&&lf.has(V.status)?{...V,status:ee,...Z.endReason!==void 0?{endReason:Z.endReason}:{}}:lf.has(ee)&&lf.has(V.status)&&y0.indexOf(ee)>y0.indexOf(V.status)?{...V,status:ee}:V})})},()=>{})},[]),b=y.useCallback(C=>{if(C.type!=="session_event")return!1;if(!vw(C.payload))return Mb("session_event","payload is not a valid SessionEvent"),!0;const M=C.payload;let G=0;if(o(U=>{const V=[...U,M];return V.length>Vi?(G=V.length-Vi,V.slice(-Vi)):V}),G>0&&u(U=>U+G),M.eventType==="usage")try{const U=JSON.parse(M.content),V=Number(U.input_tokens)||0,Z=Number(U.output_tokens)||0,ee=Number(U.cost_usd)||0;(V>0||Z>0||ee>0)&&s(ie=>ie.map(be=>be.id===M.sessionId?{...be,inputTokens:(be.inputTokens??0)+V,outputTokens:(be.outputTokens??0)+Z,costUsd:(be.costUsd??0)+ee}:be))}catch{}if(M.eventType==="status"){const U=Ob(M.content),V=Ib(M.content);s(Z=>Z.some(ie=>ie.id===M.sessionId)?Z.map(ie=>ie.id===M.sessionId?{...ie,status:U,...V!==void 0?{endReason:V}:{}}:ie):[...Z,{id:M.sessionId,environmentId:"",runtime:"",status:U,prompt:"",startedAt:M.timestamp,...V!==void 0?{endReason:V}:{}}])}return!0},[]),_=y.useCallback(C=>{b({type:"session_event",payload:C})},[b]),S=y.useCallback(C=>{var M,G,U,V,Z;switch(C.type){case"sessions":{const ee=Array.isArray((M=C.payload)==null?void 0:M.sessions)?C.payload.sessions:[];return s(ee),!0}case"spawned":{const ee=(G=C.payload)==null?void 0:G.sessionId;return typeof ee=="string"&&ee&&m(ee),v(),!0}case"session_events":{const ee=Array.isArray((U=C.payload)==null?void 0:U.events)?C.payload.events:[];return ee.length>0&&o(ee),!0}case"task_sessions":{const ee=(V=C.payload)==null?void 0:V.taskId;if(typeof ee=="string"&&ee){const ie=Array.isArray((Z=C.payload)==null?void 0:Z.sessions)?C.payload.sessions:[];g(be=>({...be,[ee]:ie}))}return!0}default:return!1}},[v]),T=y.useCallback((C,M,G,U)=>{we.spawnAgent({environmentId:C,prompt:M,personaId:G||"",workingDirectory:U||""}).then(V=>{m(V.id),v()},()=>{})},[v]),N=y.useCallback((C,M)=>{we.sendInput({sessionId:C,text:M}).catch(()=>{})},[]),j=y.useCallback(C=>{we.killAgent({id:C,graceful:!1}).catch(()=>{})},[]),w=y.useCallback(C=>{we.killAgent({id:C,graceful:!0}).catch(()=>{})},[]),E=y.useCallback(C=>{we.getSessionEvents({id:C}).then(M=>{const G=M.events.map(xw);if(G.length>0){let U=0;o(V=>{const Z=new Set;for(const be of V)be.sessionId===C&&Z.add(`${be.timestamp}|${be.eventType}`);const ee=G.filter(be=>!Z.has(`${be.timestamp}|${be.eventType}`)),ie=[...V,...ee].sort((be,K)=>be.sessionId!==K.sessionId?0:be.timestamp.localeCompare(K.timestamp));return ie.length>Vi?(U=ie.length-Vi,ie.slice(-Vi)):ie}),U>0&&u(V=>V+U)}},()=>{})},[]),A=y.useCallback(()=>{o([]),u(0)},[]),O=y.useCallback(C=>{we.getTaskSessions({id:C}).then(M=>{const G=M.sessions.map(h0);g(U=>({...U,[C]:G}))},()=>{})},[]);return{sessions:n,events:i,eventsDropped:c,lastSpawnedId:d,taskSessions:h,loadSessions:v,spawn:T,sendInput:N,kill:j,stopGraceful:w,loadSessionEvents:E,clearEvents:A,loadTaskSessions:O,handleMessage:b,handleSessionEvent:_,handleLegacyMessage:S}}function Dw(){const[n,s]=y.useState([]),[i,o]=y.useState(!1),c=y.useCallback(()=>{we.listWorkspaces({}).then(v=>{s(v.workspaces.map(Sw))},()=>{})},[]),u=y.useCallback(v=>{switch(v.type){case"workspace.created":return o(!1),c(),!0;case"workspace.archived":case"workspace.updated":return c(),!0;default:return!1}},[c]),d=y.useCallback(()=>{o(!1)},[]),m=y.useCallback((v,b,_,S,T,N,j,w,E)=>{o(!0),we.createWorkspace({name:v,description:b||"",repoUrl:_||"",environmentId:S||"",defaultPersonaId:T||void 0,useWorktrees:N??!0,workingDirectory:j||void 0}).then(()=>{o(!1),w==null||w()},A=>{o(!1);const O=A instanceof Ec?A.message:"Failed to create workspace";E==null||E(O)})},[]),h=y.useCallback(v=>{we.archiveWorkspace({id:v}).catch(()=>{})},[]),g=y.useCallback((v,b)=>{we.updateWorkspace({id:v,...b}).catch(()=>{})},[]);return{workspaces:n,workspaceCreating:i,loadWorkspaces:c,createWorkspace:m,archiveWorkspace:h,updateWorkspace:g,handleEvent:u,onDisconnect:d}}function Rw(){const[n,s]=y.useState([]),[i,o]=y.useState(void 0),c=y.useRef({}),u=y.useCallback(E=>{we.listTasks({workspaceId:E}).then(A=>{const O=A.tasks.map(g0);s(C=>[...C.filter(M=>M.workspaceId!==E),...O])},()=>{})},[]),d=y.useCallback(()=>{we.listTasks({}).then(E=>{const A=E.tasks.map(g0);s(O=>{const C=new Set(A.map(M=>M.id));return[...O.filter(M=>!C.has(M.id)),...A]})},()=>{})},[]),m=y.useCallback((E,A)=>{const O=C=>{clearTimeout(c.current[C]),c.current[C]=setTimeout(()=>{delete c.current[C],u(C)},200)};E?O(E):A&&s(C=>{const M=C.find(G=>G.id===A);return M!=null&&M.workspaceId?O(M.workspaceId):d(),C})},[u,d]),h=y.useCallback(E=>{const A=E.payload;switch(E.type){case"task.created":{const O=typeof A.workspaceId=="string"?A.workspaceId:"";return O&&u(O),!0}case"task.started":{const O=typeof A.taskId=="string"?A.taskId:"",C=typeof A.sessionId=="string"?A.sessionId:"",M=typeof A.workspaceId=="string"?A.workspaceId:"";return o(G=>O&&G===O?void 0:G),C&&O&&s(G=>G.map(U=>U.id===O?{...U,latestSessionId:C}:U)),m(M,O),!0}case"task.completed":case"task.deleted":case"task.reparented":case"task.updated":{const O=typeof A.workspaceId=="string"?A.workspaceId:"",C=typeof A.taskId=="string"?A.taskId:"";return m(O,C),!0}default:return!1}},[u,m]),g=y.useCallback(()=>{o(void 0)},[]),v=y.useCallback(E=>{var A,O;if(E.type==="tasks"){const C=Array.isArray((A=E.payload)==null?void 0:A.tasks)?E.payload.tasks:[],M=typeof((O=E.payload)==null?void 0:O.workspaceId)=="string"&&E.payload.workspaceId?E.payload.workspaceId:"";return s(M?G=>[...G.filter(U=>U.workspaceId!==M),...C]:G=>{const U=new Set(C.map(V=>V.id));return[...G.filter(V=>!U.has(V.id)),...C]}),!0}return!1},[]),b=y.useCallback((E,A,O,C,M,G,U,V,Z)=>{we.createTask({workspaceId:E,title:A,description:O||"",dependsOn:C||[],parentTaskId:M||"",defaultPersonaId:G||void 0,canDecompose:U??void 0}).then(()=>{V==null||V()},ee=>{const ie=ee instanceof Ec?ee.message:"Failed to create task";Z==null||Z(ie)})},[]),_=y.useCallback((E,A,O,C)=>{o(E),we.startTask({taskId:E,personaId:A||"",environmentId:O||"",notes:C||""}).catch(()=>{o(void 0)})},[]),S=y.useCallback(E=>{we.stopTask({id:E}).catch(()=>{})},[]),T=y.useCallback(E=>{we.completeTask({id:E}).catch(()=>{})},[]),N=y.useCallback(E=>{we.resumeTask({id:E}).catch(()=>{})},[]),j=y.useCallback((E,A,O,C,M)=>{we.updateTask({id:E,title:A,description:O,dependsOn:C,...M!==void 0?{defaultPersonaId:M}:{}}).catch(()=>{})},[]),w=y.useCallback(E=>{we.deleteTask({id:E}).catch(()=>{})},[]);return{tasks:n,taskStartingId:i,loadTasks:u,loadAllTasks:d,createTask:b,startTask:_,stopTask:S,completeTask:T,resumeTask:N,updateTask:j,deleteTask:w,handleEvent:h,onDisconnect:g,handleLegacyMessage:v}}function Mw(){const[n,s]=y.useState([]),i=y.useCallback(u=>{we.queryFindings({workspaceId:u}).then(d=>{s(d.findings.map(Tw))},()=>{})},[]),o=y.useCallback(u=>{if(u.type==="finding.posted"){const d=typeof u.payload.workspaceId=="string"?u.payload.workspaceId:"";return d&&i(d),!0}return!1},[i]),c=y.useCallback((u,d,m,h,g)=>{we.postFinding({workspaceId:u,title:d,content:m,category:h??"general",tags:g??[]}).catch(()=>{})},[]);return{findings:n,loadFindings:i,postFinding:c,handleEvent:o}}function Ow(){const[n,s]=y.useState([]),i=y.useCallback(()=>{we.listTokens({}).then(d=>{s(d.tokens.map(kw))},()=>{})},[]),o=y.useCallback(d=>d.type==="token.changed"?(i(),!0):!1,[i]),c=y.useCallback((d,m,h,g,v)=>{we.setToken({name:d,value:m,type:h,envVar:g,filePath:v}).catch(()=>{})},[]),u=y.useCallback(d=>{we.deleteToken({name:d}).catch(()=>{})},[]);return{tokens:n,loadTokens:i,setToken:c,deleteToken:u,handleEvent:o}}function Iw(){const[n,s]=y.useState({claude:"off",github:"off",copilot:"off",codex:"off",goose:"off"}),i=y.useCallback(()=>{we.getCredentialProviders({}).then(u=>{s(ww(u))},()=>{})},[]),o=y.useCallback(u=>u.type==="credential.providers_changed"?(bw(u.payload)&&s(u.payload),!0):!1,[]),c=y.useCallback(u=>{const d=[{provider:"claude",value:u.claude},{provider:"github",value:u.github},{provider:"copilot",value:u.copilot},{provider:"codex",value:u.codex},{provider:"goose",value:u.goose}];for(const{provider:m,value:h}of d)we.setCredentialProvider({provider:m,value:h}).catch(()=>{})},[]);return{credentialProviders:n,loadCredentials:i,updateCredentialProviders:c,handleEvent:o}}function Bw(){const[n,s]=y.useState([]),[i,o]=y.useState(""),[c,u]=y.useState(""),[d,m]=y.useState(!1),h=y.useCallback(()=>{we.listCodespaces({}).then(v=>{s(v.codespaces.map(Nw)),u(v.error)},()=>{})},[]),g=y.useCallback((v,b)=>{m(!0),o(""),we.createCodespace({repo:v,machine:b??""}).then(()=>{m(!1),h()},_=>{m(!1);const S=_ instanceof Ec?_.message:"Failed to create codespace";o(S)})},[h]);return{codespaces:n,codespaceError:i,codespaceListError:c,codespaceCreating:d,listCodespaces:h,createCodespace:g}}function Lw(){const[n,s]=y.useState([]),i=y.useCallback(()=>{we.listPersonas({}).then(m=>{s(m.personas.map(of))},()=>{})},[]),o=y.useCallback(m=>{switch(m.type){case"persona.created":case"persona.updated":case"persona.deleted":return i(),!0;default:return!1}},[i]),c=y.useCallback((m,h,g,v,b,_,S,T,N)=>we.createPersona({name:m,description:h,systemPrompt:g,runtime:v||"",model:b||"",maxTurns:_||0,type:S||"agent",script:T||"",allowedMcpTools:N||[]}).then(j=>{const w=of(j);return s(E=>[...E.filter(A=>A.id!==w.id),w]),w}),[]),u=y.useCallback((m,h,g,v,b,_,S,T,N,j)=>{const w={id:m};return h!==void 0&&(w.name=h),g!==void 0&&(w.description=g),v!==void 0&&(w.systemPrompt=v),b!==void 0&&(w.runtime=b),_!==void 0&&(w.model=_),S!==void 0&&(w.maxTurns=S),T!==void 0&&(w.type=T),N!==void 0&&(w.script=N),j!==void 0&&(w.allowedMcpTools=j),we.updatePersona(w).then(E=>{const A=of(E);return s(O=>O.map(C=>C.id===A.id?A:C)),A})},[]),d=y.useCallback(async m=>{await we.deletePersona({id:m}),s(h=>h.filter(g=>g.id!==m))},[]);return{personas:n,loadPersonas:i,createPersona:c,updatePersona:u,deletePersona:d,handleEvent:o}}function Uw(n){if(n)try{return JSON.parse(n)}catch{return}}function zw(){const[n,s]=y.useState(new Map),[i,o]=y.useState([]),[c,u]=y.useState(void 0),[d,m]=y.useState(void 0),[h,g]=y.useState(!1),[v,b]=y.useState(""),_=y.useRef(""),S=y.useCallback(O=>{const C=O??"";_.current=C,b(""),g(!0),we.listRecentKnowledgeNodes({limit:30,workspaceId:C}).then(M=>{const G=new Map,U=[];for(const V of M.nodes)G.set(V.id,ec(V));for(const V of M.edges)U.push(rf(V));for(const V of U){const Z=G.get(V.source);Z&&(Z.val+=1);const ee=G.get(V.target);ee&&(ee.val+=1)}s(G),o(U),g(!1)},()=>{g(!1)})},[]),T=y.useCallback(O=>{O.trim()&&(b(O),m(void 0),u(void 0),g(!0),we.searchKnowledge({query:O,limit:20,workspaceId:_.current}).then(C=>{const M=new Map,G=[];for(const U of C.results){U.node&&M.set(U.node.id,ec(U.node,U.edges.length));for(const V of U.edges)G.push(rf(V))}s(M),o(G),g(!1)},()=>{g(!1)}))},[]),N=y.useCallback(()=>{S(_.current)},[S]),j=y.useCallback(O=>{m(O),we.getKnowledgeNode({id:O}).then(C=>{if(!C.node){u(void 0);return}u({node:ec(C.node,C.edges.length),edges:C.edges.map(M=>({fromId:M.fromId,toId:M.toId,type:M.type,metadata:Uw(M.metadataJson)}))})},()=>{u(void 0)})},[]),w=y.useCallback(()=>{m(void 0),u(void 0)},[]),E=y.useCallback(O=>{we.expandKnowledgeNode({id:O,depth:1}).then(C=>{s(M=>{const G=new Map(M);for(const U of C.nodes)G.has(U.id)||G.set(U.id,ec(U));return G}),o(M=>{const G=new Set(M.map(V=>`${V.source}:${V.target}:${V.type}`)),U=[];for(const V of C.edges){const Z=rf(V),ee=`${Z.source}:${Z.target}:${Z.type}`;G.has(ee)||U.push(Z)}return[...M,...U]})},()=>{})},[]),A=y.useCallback(O=>!1,[]);return{graphData:{nodes:[...n.values()],links:i},selectedNode:c,selectedId:d,loading:h,searchQuery:v,search:T,clearSearch:N,selectNode:j,clearSelection:w,expandNode:E,loadRecent:S,handleEvent:A}}function Pw(){const[n,s]=y.useState(""),[i,o]=y.useState(void 0),[c,u]=y.useState({}),d=Cw(),m=Aw(),h=Dw(),g=Rw(),v=Mw(),b=Ow(),_=Iw(),S=Bw(),T=Lw(),N=zw(),{connected:j}=gw({onSessionEvent:Z=>{m.handleSessionEvent({sessionId:Z.sessionId,eventType:ob(Z.type),timestamp:Z.timestamp,content:Z.content,raw:Z.raw||void 0})},onDomainEvent:Z=>{try{const ee=JSON.parse(Z.payloadJson);M({id:Z.id,type:Z.type,timestamp:Z.timestamp,payload:ee})}catch{console.warn("[grackle] Failed to parse domain event payloadJson:",Z.payloadJson)}},onConnect:G,onDisconnect:U}),w="default_persona_id",E="onboarding_completed",A=y.useCallback(async Z=>{const ee=await we.setSetting({key:w,value:Z});s(ee.value)},[]),O=y.useCallback(()=>{o(!0),we.setSetting({key:E,value:"true"}).catch(()=>{})},[]),C=y.useCallback((Z,ee)=>{we.getUsage({scope:Z,id:ee}).then(ie=>{const be=`${Z}:${ee}`;u(K=>({...K,[be]:jw(ie)}))},()=>{})},[]);function M(Z){const ee=Z.payload.key,ie=Z.payload.value;if(Z.type==="setting.changed"){ee===w&&s(ie??""),ee===E&&o(ie==="true");return}if(d.handleEvent(Z)){(Z.type==="environment.removed"||Z.type==="environment.changed")&&m.loadSessions();return}if(!h.handleEvent(Z)){if(g.handleEvent(Z)){Z.type==="task.started"&&m.loadSessions();return}v.handleEvent(Z)||b.handleEvent(Z)||_.handleEvent(Z)||T.handleEvent(Z)||N.handleEvent(Z)}}function G(){d.loadEnvironments(),m.loadSessions(),h.loadWorkspaces(),b.loadTokens(),_.loadCredentials(),T.loadPersonas(),we.getSetting({key:w}).then(Z=>{s(Z.value)},()=>{}),we.getSetting({key:E}).then(Z=>{o(Z.value==="true")},()=>{}),g.loadAllTasks()}function U(){h.onDisconnect(),g.onDisconnect()}const V=y.useCallback(()=>{d.loadEnvironments(),m.loadSessions(),h.loadWorkspaces(),b.loadTokens()},[d.loadEnvironments,m.loadSessions,h.loadWorkspaces,b.loadTokens]);return{connected:j,environments:d.environments,sessions:m.sessions,events:m.events,eventsDropped:m.eventsDropped,lastSpawnedId:m.lastSpawnedId,workspaces:h.workspaces,tasks:g.tasks,findings:v.findings,tokens:b.tokens,spawn:m.spawn,sendInput:m.sendInput,kill:m.kill,stopGraceful:m.stopGraceful,refresh:V,loadSessionEvents:m.loadSessionEvents,clearEvents:m.clearEvents,loadWorkspaces:h.loadWorkspaces,createWorkspace:h.createWorkspace,archiveWorkspace:h.archiveWorkspace,updateWorkspace:h.updateWorkspace,loadTasks:g.loadTasks,loadAllTasks:g.loadAllTasks,createTask:g.createTask,startTask:g.startTask,stopTask:g.stopTask,completeTask:g.completeTask,resumeTask:g.resumeTask,updateTask:g.updateTask,deleteTask:g.deleteTask,loadFindings:v.loadFindings,postFinding:v.postFinding,loadEnvironments:d.loadEnvironments,addEnvironment:d.addEnvironment,updateEnvironment:d.updateEnvironment,loadTokens:b.loadTokens,setToken:b.setToken,deleteToken:b.deleteToken,credentialProviders:_.credentialProviders,updateCredentialProviders:_.updateCredentialProviders,provisionStatus:d.provisionStatus,provisionEnvironment:d.provisionEnvironment,stopEnvironment:d.stopEnvironment,removeEnvironment:d.removeEnvironment,codespaces:S.codespaces,codespaceError:S.codespaceError,codespaceListError:S.codespaceListError,codespaceCreating:S.codespaceCreating,listCodespaces:S.listCodespaces,createCodespace:S.createCodespace,workspaceCreating:h.workspaceCreating,taskStartingId:g.taskStartingId,personas:T.personas,createPersona:T.createPersona,updatePersona:T.updatePersona,deletePersona:T.deletePersona,taskSessions:m.taskSessions,loadTaskSessions:m.loadTaskSessions,appDefaultPersonaId:n,setAppDefaultPersonaId:A,onboardingCompleted:i,completeOnboarding:O,usageCache:c,loadUsage:C,knowledge:N}}const _p=y.createContext(void 0);function Vw({children:n}){const s=Pw();return l.jsx(_p.Provider,{value:s,children:n})}function pt(){const n=y.useContext(_p);if(!n)throw new Error("useGrackle must be used within GrackleProvider");return n}const ns=[{id:"kn-auth-flow",label:"Authentication Flow",kind:"knowledge",category:"concept",content:"The application uses JWT Bearer tokens for stateless authentication. Access tokens expire after 24h. Refresh tokens are stored in the database and rotated on use. The auth middleware verifies tokens and attaches the decoded payload to req.user.",tags:["auth","jwt","security"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:30:00Z",updatedAt:"2026-02-27T08:15:00Z",val:5},{id:"kn-db-schema",label:"Database Schema",kind:"knowledge",category:"concept",content:"PostgreSQL database with tables: users, sessions, refresh_tokens, audit_log. Uses UUID primary keys, TIMESTAMPTZ for all timestamps, and JSONB for flexible metadata columns. Connection pooling via pg-pool with per-tenant isolation.",tags:["database","postgres","schema"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:00:00Z",updatedAt:"2026-02-26T22:45:00Z",val:4},{id:"kn-error-handling",label:"Error Response Pattern",kind:"knowledge",category:"concept",content:"All API errors follow the shape { error: string, code: string, details?: unknown }. HTTP status codes map to: 400 (validation), 401 (unauthenticated), 403 (forbidden), 404 (not found), 409 (conflict), 429 (rate limited), 500 (internal).",tags:["api","errors","patterns"],workspaceId:"proj-alpha",createdAt:"2026-02-27T08:17:00Z",updatedAt:"2026-02-27T08:17:00Z",val:3},{id:"kn-rate-limiting",label:"Rate Limiting Strategy",kind:"knowledge",category:"concept",content:"Token-bucket algorithm with in-memory state per client IP. Default rate: 100 requests/minute, burst: 20. Returns 429 with Retry-After header. Redis adapter available for multi-instance deployments.",tags:["api","rate-limiting","infrastructure"],workspaceId:"proj-alpha",createdAt:"2026-02-27T09:00:00Z",updatedAt:"2026-02-27T09:00:00Z",val:2},{id:"kn-etl-pipeline",label:"ETL Pipeline Architecture",kind:"knowledge",category:"concept",content:"Data pipelines follow an Extract-Transform-Load pattern with pluggable stages. Each stage reads from a source (Postgres, S3, API), transforms via configurable mappers, and loads into a target (Parquet, BigQuery, S3). Incremental loads use high-watermark tracking.",tags:["etl","pipeline","architecture"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:00:00Z",updatedAt:"2026-02-27T09:05:00Z",val:4},{id:"kn-parquet-format",label:"Parquet Output Format",kind:"knowledge",category:"concept",content:"Parquet files are written with row-group buffering (configurable batch size, default 10000 rows). Supports Snappy, ZSTD, and GZIP compression. Schema is derived from the internal column type system using Arrow type mapping.",tags:["parquet","data-format","compression"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:05:00Z",updatedAt:"2026-02-26T08:15:00Z",val:3},{id:"kn-jwt-over-session",label:"JWT over Session Auth",kind:"knowledge",category:"decision",content:"Chose JWT tokens over server-side sessions for stateless auth. Rationale: (1) no session store needed, (2) works across microservices without shared state, (3) supports mobile clients natively. Trade-off: tokens can't be revoked instantly (mitigated by short expiry + refresh rotation).",tags:["auth","decision","jwt"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:00:00Z",updatedAt:"2026-02-25T10:00:00Z",val:3},{id:"kn-pg-pool-decision",label:"pg-pool over Knex",kind:"knowledge",category:"decision",content:"Chose pg-pool over Knex for connection pooling. pg-pool gives direct control over idle timeout, max connections, and health check queries. Knex wraps pg-pool and adds query-building overhead we don't need since we write raw SQL with parameterized queries.",tags:["database","decision","postgres"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:30:00Z",updatedAt:"2026-02-23T11:30:00Z",val:2},{id:"kn-watermark-decision",label:"Local Watermark Storage",kind:"knowledge",category:"decision",content:"Currently using local SQLite for watermark storage. This works for single-worker pipelines but needs to move to a shared store (Redis or Postgres) for production multi-worker scenarios. Tracked as a follow-up task.",tags:["pipeline","decision","watermarks"],workspaceId:"proj-beta",createdAt:"2026-02-27T09:05:00Z",updatedAt:"2026-02-27T09:05:00Z",val:2},{id:"kn-jwt-middleware",label:"JWT Verify Middleware",kind:"knowledge",category:"snippet",content:`\`\`\`typescript
|
|
38
38
|
export function verifyToken(req: Request, res: Response, next: NextFunction): void {
|
|
39
39
|
const header = req.headers.authorization;
|
|
40
40
|
if (!header?.startsWith("Bearer ")) {
|
|
@@ -57,7 +57,7 @@ CREATE TABLE audit_log (
|
|
|
57
57
|
ip_address INET,
|
|
58
58
|
created_at TIMESTAMPTZ DEFAULT now()
|
|
59
59
|
);
|
|
60
|
-
\`\`\``,tags:["database","audit","schema","sql"],workspaceId:"proj-alpha",createdAt:"2026-02-26T22:45:15Z",updatedAt:"2026-02-26T22:45:15Z",val:2},{id:"kn-n1-query",label:"N+1 Query in User List",kind:"knowledge",category:"insight",content:"GET /api/users performs a separate query for each user's role metadata, resulting in N+1 queries. For 500 users this adds ~2 seconds of latency. Solution: use a JOIN or batch lookup to fetch all role data in a single query.",tags:["performance","database","n+1"],workspaceId:"proj-alpha",createdAt:"2026-02-22T09:30:00Z",updatedAt:"2026-02-22T09:30:00Z",val:2},{id:"kn-session-race",label:"Session Cleanup Race Condition",kind:"knowledge",category:"insight",content:"When two concurrent requests hit /api/logout, the second call throws a 500 because the session row has already been deleted. Fix: use DELETE ... RETURNING or add IF EXISTS guard to make the operation idempotent.",tags:["bug","concurrency","sessions"],workspaceId:"proj-alpha",createdAt:"2026-02-26T22:50:00Z",updatedAt:"2026-02-26T22:50:00Z",val:2},{id:"kn-ref-task-001",label:"JWT Auth Task",kind:"reference",sourceType:"task",sourceId:"task-001",content:"Implement JWT authentication across all protected routes, replacing session-based auth.",workspaceId:"proj-alpha",createdAt:"2026-02-25T10:00:00Z",updatedAt:"2026-02-27T08:15:00Z",val:3},{id:"kn-ref-task-006",label:"Parquet Export Task",kind:"reference",sourceType:"task",sourceId:"task-006",content:"Add Parquet export support for pipeline outputs, enabling downstream Spark consumption.",workspaceId:"proj-beta",createdAt:"2026-02-26T08:00:00Z",updatedAt:"2026-02-27T09:00:00Z",val:3},{id:"kn-ref-sess-001",label:"Auth Middleware Session",kind:"reference",sourceType:"session",sourceId:"sess-001",content:"Active session implementing JWT auth middleware, rewrote auth.ts, login.ts, and test suite.",workspaceId:"proj-alpha",createdAt:"2026-02-27T08:15:00Z",updatedAt:"2026-02-27T08:15:42Z",val:2}],ca=[{source:"kn-auth-flow",target:"kn-jwt-over-session",type:"decided_by"},{source:"kn-auth-flow",target:"kn-jwt-middleware",type:"implemented_by"},{source:"kn-auth-flow",target:"kn-ref-task-001",type:"tracked_in"},{source:"kn-auth-flow",target:"kn-error-handling",type:"relates_to"},{source:"kn-jwt-over-session",target:"kn-ref-task-001",type:"motivated_by"},{source:"kn-db-schema",target:"kn-pg-pool-decision",type:"decided_by"},{source:"kn-db-schema",target:"kn-audit-schema",type:"contains"},{source:"kn-db-schema",target:"kn-n1-query",type:"affected_by"},{source:"kn-db-schema",target:"kn-session-race",type:"affected_by"},{source:"kn-rate-limiting",target:"kn-error-handling",type:"relates_to"},{source:"kn-rate-limiting",target:"kn-auth-flow",type:"depends_on"},{source:"kn-etl-pipeline",target:"kn-parquet-format",type:"outputs_to"},{source:"kn-etl-pipeline",target:"kn-watermark-decision",type:"decided_by"},{source:"kn-etl-pipeline",target:"kn-ref-task-006",type:"tracked_in"},{source:"kn-parquet-format",target:"kn-ref-task-006",type:"tracked_in"},{source:"kn-watermark-decision",target:"kn-etl-pipeline",type:"relates_to"},{source:"kn-ref-task-001",target:"kn-ref-sess-001",type:"has_session"},{source:"kn-jwt-middleware",target:"kn-ref-sess-001",type:"created_in"},{source:"kn-audit-schema",target:"kn-db-schema",type:"part_of"}],
|
|
60
|
+
\`\`\``,tags:["database","audit","schema","sql"],workspaceId:"proj-alpha",createdAt:"2026-02-26T22:45:15Z",updatedAt:"2026-02-26T22:45:15Z",val:2},{id:"kn-n1-query",label:"N+1 Query in User List",kind:"knowledge",category:"insight",content:"GET /api/users performs a separate query for each user's role metadata, resulting in N+1 queries. For 500 users this adds ~2 seconds of latency. Solution: use a JOIN or batch lookup to fetch all role data in a single query.",tags:["performance","database","n+1"],workspaceId:"proj-alpha",createdAt:"2026-02-22T09:30:00Z",updatedAt:"2026-02-22T09:30:00Z",val:2},{id:"kn-session-race",label:"Session Cleanup Race Condition",kind:"knowledge",category:"insight",content:"When two concurrent requests hit /api/logout, the second call throws a 500 because the session row has already been deleted. Fix: use DELETE ... RETURNING or add IF EXISTS guard to make the operation idempotent.",tags:["bug","concurrency","sessions"],workspaceId:"proj-alpha",createdAt:"2026-02-26T22:50:00Z",updatedAt:"2026-02-26T22:50:00Z",val:2},{id:"kn-ref-task-001",label:"JWT Auth Task",kind:"reference",sourceType:"task",sourceId:"task-001",content:"Implement JWT authentication across all protected routes, replacing session-based auth.",workspaceId:"proj-alpha",createdAt:"2026-02-25T10:00:00Z",updatedAt:"2026-02-27T08:15:00Z",val:3},{id:"kn-ref-task-006",label:"Parquet Export Task",kind:"reference",sourceType:"task",sourceId:"task-006",content:"Add Parquet export support for pipeline outputs, enabling downstream Spark consumption.",workspaceId:"proj-beta",createdAt:"2026-02-26T08:00:00Z",updatedAt:"2026-02-27T09:00:00Z",val:3},{id:"kn-ref-sess-001",label:"Auth Middleware Session",kind:"reference",sourceType:"session",sourceId:"sess-001",content:"Active session implementing JWT auth middleware, rewrote auth.ts, login.ts, and test suite.",workspaceId:"proj-alpha",createdAt:"2026-02-27T08:15:00Z",updatedAt:"2026-02-27T08:15:42Z",val:2}],ca=[{source:"kn-auth-flow",target:"kn-jwt-over-session",type:"decided_by"},{source:"kn-auth-flow",target:"kn-jwt-middleware",type:"implemented_by"},{source:"kn-auth-flow",target:"kn-ref-task-001",type:"tracked_in"},{source:"kn-auth-flow",target:"kn-error-handling",type:"relates_to"},{source:"kn-jwt-over-session",target:"kn-ref-task-001",type:"motivated_by"},{source:"kn-db-schema",target:"kn-pg-pool-decision",type:"decided_by"},{source:"kn-db-schema",target:"kn-audit-schema",type:"contains"},{source:"kn-db-schema",target:"kn-n1-query",type:"affected_by"},{source:"kn-db-schema",target:"kn-session-race",type:"affected_by"},{source:"kn-rate-limiting",target:"kn-error-handling",type:"relates_to"},{source:"kn-rate-limiting",target:"kn-auth-flow",type:"depends_on"},{source:"kn-etl-pipeline",target:"kn-parquet-format",type:"outputs_to"},{source:"kn-etl-pipeline",target:"kn-watermark-decision",type:"decided_by"},{source:"kn-etl-pipeline",target:"kn-ref-task-006",type:"tracked_in"},{source:"kn-parquet-format",target:"kn-ref-task-006",type:"tracked_in"},{source:"kn-watermark-decision",target:"kn-etl-pipeline",type:"relates_to"},{source:"kn-ref-task-001",target:"kn-ref-sess-001",type:"has_session"},{source:"kn-jwt-middleware",target:"kn-ref-sess-001",type:"created_in"},{source:"kn-audit-schema",target:"kn-db-schema",type:"part_of"}],qw=new Map(ns.map(n=>[n.id,n]));function cf(n){const s=qw.get(n);if(!s)throw new Error(`MOCK_KNOWLEDGE_NODES is missing node "${n}"`);return s}const b0={"kn-auth-flow":{node:cf("kn-auth-flow"),edges:[{fromId:"kn-auth-flow",toId:"kn-jwt-over-session",type:"decided_by"},{fromId:"kn-auth-flow",toId:"kn-jwt-middleware",type:"implemented_by"},{fromId:"kn-auth-flow",toId:"kn-ref-task-001",type:"tracked_in"},{fromId:"kn-auth-flow",toId:"kn-error-handling",type:"relates_to"},{fromId:"kn-rate-limiting",toId:"kn-auth-flow",type:"depends_on"}]},"kn-db-schema":{node:cf("kn-db-schema"),edges:[{fromId:"kn-db-schema",toId:"kn-pg-pool-decision",type:"decided_by"},{fromId:"kn-db-schema",toId:"kn-audit-schema",type:"contains"},{fromId:"kn-db-schema",toId:"kn-n1-query",type:"affected_by"},{fromId:"kn-db-schema",toId:"kn-session-race",type:"affected_by"},{fromId:"kn-audit-schema",toId:"kn-db-schema",type:"part_of"}]},"kn-etl-pipeline":{node:cf("kn-etl-pipeline"),edges:[{fromId:"kn-etl-pipeline",toId:"kn-parquet-format",type:"outputs_to"},{fromId:"kn-etl-pipeline",toId:"kn-watermark-decision",type:"decided_by"},{fromId:"kn-etl-pipeline",toId:"kn-ref-task-006",type:"tracked_in"},{fromId:"kn-watermark-decision",toId:"kn-etl-pipeline",type:"relates_to"}]}},Hw=[{id:"env-local-01",displayName:"Local Dev",adapterType:"local",adapterConfig:"{}",status:"connected",bootstrapped:!0},{id:"env-docker-01",displayName:"Docker Sandbox",adapterType:"docker",adapterConfig:'{"image":"node:20"}',status:"connected",bootstrapped:!0},{id:"env-cs-01",displayName:"GitHub Codespace",adapterType:"codespace",adapterConfig:'{"codespaceName":"my-codespace"}',status:"connected",bootstrapped:!0},{id:"env-remote-01",displayName:"Staging (SSH)",adapterType:"ssh",adapterConfig:'{"host":"192.168.1.10","user":"deploy","sshPort":22}',status:"disconnected",bootstrapped:!1}],Gw=[{id:"sess-001-prev",environmentId:"env-local-01",runtime:"claude-code",status:"stopped",endReason:"interrupted",prompt:"Implement auth middleware",startedAt:"2026-02-26T14:00:00Z",endedAt:"2026-02-26T15:12:00Z",error:"Context window exceeded before completing implementation",inputTokens:84200,outputTokens:12750,costUsd:.41},{id:"sess-001",environmentId:"env-local-01",runtime:"claude-code",status:"running",prompt:"Refactor the authentication middleware to use JWT tokens",startedAt:"2026-02-27T08:15:00Z",inputTokens:42600,outputTokens:8100,costUsd:.22},{id:"sess-002",environmentId:"env-docker-01",runtime:"copilot",status:"stopped",endReason:"completed",prompt:"Write unit tests for the user registration endpoint",startedAt:"2026-02-27T07:30:00Z",endedAt:"2026-02-27T07:33:00Z",inputTokens:31400,outputTokens:9800,costUsd:.18},{id:"sess-003",environmentId:"env-local-01",runtime:"claude-code",status:"stopped",endReason:"interrupted",prompt:"Migrate database schema to add audit_log table",startedAt:"2026-02-26T22:45:00Z",endedAt:"2026-02-26T23:10:00Z",inputTokens:56300,outputTokens:14200,costUsd:.31},{id:"sess-004",environmentId:"env-docker-01",runtime:"codex",status:"running",prompt:"Implement rate limiting for the public API",startedAt:"2026-02-27T09:00:00Z",inputTokens:18900,outputTokens:4500,costUsd:.1},{id:"sess-005",environmentId:"env-cs-01",runtime:"claude-code",status:"suspended",prompt:"Refactor database connection pooling for multi-tenant isolation",startedAt:"2026-02-27T06:00:00Z",inputTokens:67800,outputTokens:19300,costUsd:.38}],$w=[{sessionId:"sess-001-prev",eventType:"status",timestamp:"2026-02-26T14:00:01Z",content:"running"},{sessionId:"sess-001-prev",eventType:"system",timestamp:"2026-02-26T14:00:02Z",content:`You are a senior backend engineer. Focus on security best practices and thorough testing.
|
|
61
61
|
Project: acme/alpha — Node.js + Express REST API
|
|
62
62
|
Task: Implement auth middleware using JWT tokens`,raw:JSON.stringify({systemContext:!0})},{sessionId:"sess-001-prev",eventType:"text",timestamp:"2026-02-26T14:00:05Z",content:"I'll start by reading the current authentication middleware to understand what needs to change."},{sessionId:"sess-001-prev",eventType:"tool_use",timestamp:"2026-02-26T14:00:06Z",content:JSON.stringify({tool:"Read",args:{file_path:"src/middleware/auth.ts"}}),raw:JSON.stringify({id:"tu-prev-001",type:"tool_use"})},{sessionId:"sess-001-prev",eventType:"tool_result",timestamp:"2026-02-26T14:00:07Z",content:`import session from "express-session";
|
|
63
63
|
import type { Request, Response, NextFunction } from "express";
|
|
@@ -366,7 +366,7 @@ src/services/analytics.ts:1:import { pool } from "../db/pool.js";`,raw:JSON.stri
|
|
|
366
366
|
2. Update all consumers to use \`getPool(tenantId)\` instead of the global pool
|
|
367
367
|
3. Add middleware to extract tenant ID from the request
|
|
368
368
|
|
|
369
|
-
This is a significant refactor. Let me start with the PoolManager class.`},{sessionId:"sess-005",eventType:"usage",timestamp:"2026-02-27T06:30:00Z",content:JSON.stringify({input_tokens:67800,output_tokens:19300,cost_usd:.38})},{sessionId:"sess-005",eventType:"status",timestamp:"2026-02-27T06:30:01Z",content:"suspended"}],F2=[{id:"proj-alpha",name:"Workspace Alpha",description:"Core platform API and authentication services",repoUrl:"https://github.com/acme/alpha",environmentId:"env-local-01",status:"active",workingDirectory:"",useWorktrees:!0,defaultPersonaId:"",createdAt:"2026-01-15T10:00:00Z",updatedAt:"2026-01-15T10:00:00Z"},{id:"proj-beta",name:"Data Pipeline",description:"ETL pipelines for analytics and reporting",repoUrl:"https://github.com/acme/data-pipeline",environmentId:"env-docker-01",status:"active",workingDirectory:"",useWorktrees:!0,defaultPersonaId:"",createdAt:"2026-02-01T14:30:00Z",updatedAt:"2026-02-01T14:30:00Z"},{id:"proj-gamma",name:"Mobile App",description:"React Native cross-platform mobile application",repoUrl:"",environmentId:"env-local-01",status:"archived",workingDirectory:"",useWorktrees:!0,defaultPersonaId:"",createdAt:"2025-11-20T09:00:00Z",updatedAt:"2025-11-20T09:00:00Z"}],Z2=[{id:"task-001",workspaceId:"proj-alpha",title:"Implement JWT authentication",description:"Replace session-based auth with JWT tokens across all protected routes",status:"working",branch:"feat/jwt-auth",latestSessionId:"sess-001",dependsOn:[],reviewNotes:void 0,sortOrder:1,createdAt:"2026-02-25T10:00:00Z",parentTaskId:"",depth:0,childTaskIds:["task-001a","task-001b","task-001c"],canDecompose:!0,defaultPersonaId:"",workpad:""},{id:"task-001a",workspaceId:"proj-alpha",title:"Design token schema",description:"Define JWT payload structure, expiry, and refresh token strategy",status:"complete",branch:"feat/jwt-auth/design-token-schema",latestSessionId:"",dependsOn:[],reviewNotes:void 0,sortOrder:1,createdAt:"2026-02-25T10:10:00Z",parentTaskId:"task-001",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:""},{id:"task-001b",workspaceId:"proj-alpha",title:"Implement auth middleware",description:"Build Express middleware that verifies JWT Bearer tokens",status:"working",branch:"feat/jwt-auth/implement-auth-middleware",latestSessionId:"sess-001",dependsOn:[],reviewNotes:void 0,sortOrder:2,createdAt:"2026-02-25T10:15:00Z",parentTaskId:"task-001",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:""},{id:"task-001c",workspaceId:"proj-alpha",title:"Write auth integration tests",description:"End-to-end tests for login flow, token refresh, and protected route access",status:"not_started",branch:"",latestSessionId:"",dependsOn:["task-001b"],reviewNotes:void 0,sortOrder:3,createdAt:"2026-02-25T10:20:00Z",parentTaskId:"task-001",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:""},{id:"task-002",workspaceId:"proj-alpha",title:"Add rate limiting",description:"Implement token-bucket rate limiting for public API endpoints",status:"not_started",branch:"",latestSessionId:"",dependsOn:["task-001"],reviewNotes:void 0,sortOrder:2,createdAt:"2026-02-25T10:05:00Z",parentTaskId:"",depth:0,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:""},{id:"task-003",workspaceId:"proj-alpha",title:"Set up OpenAPI documentation",description:"Generate Swagger docs from route decorators and serve at /api/docs",status:"paused",branch:"feat/openapi-docs",latestSessionId:"sess-002",dependsOn:[],reviewNotes:void 0,sortOrder:3,createdAt:"2026-02-24T16:00:00Z",parentTaskId:"",depth:0,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:""},{id:"task-004",workspaceId:"proj-alpha",title:"Database connection pooling",description:"Switch from single connection to a connection pool with health checks",status:"complete",branch:"feat/db-pool",latestSessionId:"",dependsOn:[],reviewNotes:void 0,sortOrder:4,createdAt:"2026-02-23T11:00:00Z",parentTaskId:"",depth:0,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:""},{id:"task-005",workspaceId:"proj-alpha",title:"Fix N+1 query in user list",description:"Use a JOIN instead of per-row lookups in GET /api/users",status:"not_started",branch:"fix/user-list-n1",latestSessionId:"",dependsOn:[],reviewNotes:void 0,sortOrder:5,createdAt:"2026-02-22T09:30:00Z",parentTaskId:"",depth:0,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:""},{id:"task-006",workspaceId:"proj-beta",title:"Add Parquet export support",description:"Allow pipeline outputs to be written as Parquet files for Spark consumption",status:"working",branch:"feat/parquet-export",latestSessionId:"",dependsOn:[],reviewNotes:void 0,sortOrder:1,createdAt:"2026-02-26T08:00:00Z",parentTaskId:"",depth:0,childTaskIds:["task-006a","task-006b","task-006c","task-006d"],canDecompose:!0,defaultPersonaId:"",workpad:""},{id:"task-006a",workspaceId:"proj-beta",title:"Define Parquet schema mapping",description:"Map internal column types to Arrow/Parquet type system",status:"complete",branch:"feat/parquet-export/define-parquet-schema-mapping",latestSessionId:"",dependsOn:[],reviewNotes:void 0,sortOrder:1,createdAt:"2026-02-26T08:05:00Z",parentTaskId:"task-006",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:""},{id:"task-006b",workspaceId:"proj-beta",title:"Implement row-group writer",description:"Write buffered row groups with configurable batch size",status:"complete",branch:"feat/parquet-export/implement-row-group-writer",latestSessionId:"",dependsOn:["task-006a"],reviewNotes:void 0,sortOrder:2,createdAt:"2026-02-26T08:10:00Z",parentTaskId:"task-006",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:""},{id:"task-006c",workspaceId:"proj-beta",title:"Add compression options",description:"Support Snappy, ZSTD, and GZIP compression for Parquet output",status:"working",branch:"feat/parquet-export/add-compression-options",latestSessionId:"sess-004",dependsOn:["task-006b"],reviewNotes:void 0,sortOrder:3,createdAt:"2026-02-26T08:15:00Z",parentTaskId:"task-006",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:""},{id:"task-006d",workspaceId:"proj-beta",title:"Write Parquet integration tests",description:"Round-trip tests: write Parquet, read back with pyarrow, verify data integrity",status:"not_started",branch:"",latestSessionId:"",dependsOn:["task-006c"],reviewNotes:void 0,sortOrder:4,createdAt:"2026-02-26T08:20:00Z",parentTaskId:"task-006",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:""},{id:"task-007",workspaceId:"proj-beta",title:"Implement incremental loads",description:"Track watermarks so pipelines only process new/changed rows",status:"working",branch:"feat/incremental",latestSessionId:"sess-004",dependsOn:[],reviewNotes:void 0,sortOrder:2,createdAt:"2026-02-26T08:30:00Z",parentTaskId:"",depth:0,childTaskIds:["task-007a","task-007b"],canDecompose:!0,defaultPersonaId:"",workpad:""},{id:"task-007a",workspaceId:"proj-beta",title:"Design watermark storage",description:"Define schema for per-pipeline high-watermark tracking",status:"complete",branch:"feat/incremental/design-watermark-storage",latestSessionId:"",dependsOn:[],reviewNotes:void 0,sortOrder:1,createdAt:"2026-02-26T08:35:00Z",parentTaskId:"task-007",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:""},{id:"task-007b",workspaceId:"proj-beta",title:"Implement change detection query",description:"Generate WHERE clauses from watermarks to fetch only changed rows",status:"failed",branch:"feat/incremental/implement-change-detection-query",latestSessionId:"",dependsOn:["task-007a"],reviewNotes:void 0,sortOrder:2,createdAt:"2026-02-26T08:40:00Z",parentTaskId:"task-007",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:""},{id:"task-008",workspaceId:"proj-beta",title:"Add pipeline monitoring dashboard",description:"Real-time metrics for pipeline throughput, latency, and error rates",status:"paused",branch:"feat/monitoring",latestSessionId:"",dependsOn:[],reviewNotes:void 0,sortOrder:3,createdAt:"2026-02-26T09:00:00Z",parentTaskId:"",depth:0,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:""}],_0=[{id:"find-001",workspaceId:"proj-alpha",taskId:"task-001",sessionId:"sess-001",category:"architecture",title:"Auth middleware is tightly coupled to Express",content:"The current auth middleware directly references Express Request/Response types. Consider extracting a framework-agnostic token verification layer so we can reuse it in the WebSocket auth path.",tags:["auth","decoupling","middleware"],createdAt:"2026-02-27T08:16:00Z"},{id:"find-002",workspaceId:"proj-alpha",taskId:"task-003",sessionId:"sess-002",category:"api",title:"Missing pagination on GET /api/users",content:"The users endpoint returns all rows without limit/offset. For datasets over 10k rows this will cause timeouts. Recommend cursor-based pagination with a default page size of 50.",tags:["api","pagination","performance"],createdAt:"2026-02-27T07:31:00Z"},{id:"find-003",workspaceId:"proj-alpha",taskId:"task-005",sessionId:"sess-003",category:"bug",title:"Race condition in session cleanup",content:"When two requests hit /api/logout concurrently, the second call throws a 500 because the session row has already been deleted. Needs an idempotent DELETE or a conditional check.",tags:["bug","concurrency","sessions"],createdAt:"2026-02-26T22:50:00Z"},{id:"find-004",workspaceId:"proj-alpha",taskId:"task-004",sessionId:"",category:"decision",title:"Chose pg-pool over knex connection pool",content:"pg-pool gives us direct control over idle timeout, max connections, and health check queries. Knex wraps pg-pool anyway and adds overhead we don't need since we write raw SQL.",tags:["database","decision","postgres"],createdAt:"2026-02-23T11:30:00Z"},{id:"find-005",workspaceId:"proj-alpha",taskId:"",sessionId:"",category:"dependency",title:"jsonwebtoken has 3 high-severity CVEs",content:"The jsonwebtoken package (v8.x) has known vulnerabilities. Consider migrating to jose which is maintained, supports ESM, and covers the same JWS/JWE surface area with zero dependencies.",tags:["security","dependency","jwt"],createdAt:"2026-02-27T08:20:00Z"},{id:"find-006",workspaceId:"proj-alpha",taskId:"task-001",sessionId:"sess-001",category:"pattern",title:"Consistent error response shape",content:"All error responses should follow the shape `{ error: string, code: string, details?: unknown }`. Currently some routes return `{ message: string }` and others return `{ error: string }`.",tags:["api","consistency","error-handling"],createdAt:"2026-02-27T08:17:00Z"},{id:"find-007",workspaceId:"proj-beta",taskId:"task-007",sessionId:"sess-004",category:"architecture",title:"Watermark storage should be pluggable",content:"The incremental load watermarks are currently stored in a local SQLite file. For production multi-worker scenarios, this needs to be backed by a shared store (Redis or Postgres).",tags:["architecture","pipeline","scalability"],createdAt:"2026-02-27T09:05:00Z"}],K2=[{name:"anthropic",tokenType:"env_var",envVar:"ANTHROPIC_API_KEY",filePath:"",expiresAt:""},{name:"github",tokenType:"env_var",envVar:"GITHUB_TOKEN",filePath:"",expiresAt:"2026-12-31T23:59:59Z"},{name:"gcp-service-account",tokenType:"file",envVar:"",filePath:"/home/user/.config/gcloud/credentials.json",expiresAt:""}],Y2=[{id:"persona-arch",name:"Software Architect",description:"Designs system architecture, defines interfaces, and decomposes large features into implementable tasks.",systemPrompt:"You are a senior software architect. Focus on clean interfaces, separation of concerns, and scalable patterns. When decomposing work, create concrete subtasks with clear acceptance criteria.",toolConfig:JSON.stringify({allowedTools:["Read","Grep","Glob","Write","Edit"]}),runtime:"claude-code",model:"claude-sonnet-4-5-20250929",maxTurns:50,mcpServers:"[]",createdAt:"2026-02-20T10:00:00Z",updatedAt:"2026-02-20T10:00:00Z",type:"agent",script:"",allowedMcpTools:[]},{id:"persona-fe",name:"Frontend Engineer",description:"React specialist — builds UI components, writes CSS, implements routing, and creates Playwright tests.",systemPrompt:"You are a frontend engineer specializing in React, TypeScript, and modern CSS. Follow component composition patterns, use semantic HTML, and write accessible markup.",toolConfig:JSON.stringify({allowedTools:["Read","Grep","Glob","Write","Edit","Bash"]}),runtime:"claude-code",model:"claude-sonnet-4-5-20250929",maxTurns:100,mcpServers:"[]",createdAt:"2026-02-20T10:05:00Z",updatedAt:"2026-02-20T10:05:00Z",type:"agent",script:"",allowedMcpTools:[]},{id:"persona-reviewer",name:"Code Reviewer",description:"Reviews diffs for correctness, security, and style. Posts findings for issues discovered.",systemPrompt:"You are a meticulous code reviewer. Check for security vulnerabilities, performance issues, and style consistency. Post findings for anything noteworthy.",toolConfig:JSON.stringify({allowedTools:["Read","Grep","Glob"]}),runtime:"claude-code",model:"claude-sonnet-4-5-20250929",maxTurns:30,mcpServers:"[]",createdAt:"2026-02-20T10:10:00Z",updatedAt:"2026-02-20T10:10:00Z",type:"agent",script:"",allowedMcpTools:[]},{id:"persona-tester",name:"QA Engineer",description:"Writes comprehensive test suites — unit tests, integration tests, and E2E Playwright specs.",systemPrompt:"You are a QA engineer focused on test coverage. Write tests that cover happy paths, edge cases, error scenarios, and accessibility. Use Playwright for E2E tests.",toolConfig:JSON.stringify({allowedTools:["Read","Grep","Glob","Write","Edit","Bash"]}),runtime:"claude-code",model:"claude-sonnet-4-5-20250929",maxTurns:80,mcpServers:"[]",createdAt:"2026-02-20T10:15:00Z",updatedAt:"2026-02-20T10:15:00Z",type:"agent",script:"",allowedMcpTools:[]},{id:"persona-lint",name:"Lint & Format",description:"Scripted persona — runs ESLint and Prettier on changed files, auto-fixes violations, and posts a findings summary.",systemPrompt:"",toolConfig:"{}",runtime:"genaiscript",model:"",maxTurns:1,mcpServers:"[]",createdAt:"2026-02-21T09:00:00Z",updatedAt:"2026-02-21T09:00:00Z",type:"script",script:`const files = env.files.filter(f => /\\.(ts|tsx|js)$/.test(f.filename));
|
|
369
|
+
This is a significant refactor. Let me start with the PoolManager class.`},{sessionId:"sess-005",eventType:"usage",timestamp:"2026-02-27T06:30:00Z",content:JSON.stringify({input_tokens:67800,output_tokens:19300,cost_usd:.38})},{sessionId:"sess-005",eventType:"status",timestamp:"2026-02-27T06:30:01Z",content:"suspended"}],Fw=[{id:"proj-alpha",name:"Workspace Alpha",description:"Core platform API and authentication services",repoUrl:"https://github.com/acme/alpha",environmentId:"env-local-01",status:"active",workingDirectory:"",useWorktrees:!0,defaultPersonaId:"",createdAt:"2026-01-15T10:00:00Z",updatedAt:"2026-01-15T10:00:00Z"},{id:"proj-beta",name:"Data Pipeline",description:"ETL pipelines for analytics and reporting",repoUrl:"https://github.com/acme/data-pipeline",environmentId:"env-docker-01",status:"active",workingDirectory:"",useWorktrees:!0,defaultPersonaId:"",createdAt:"2026-02-01T14:30:00Z",updatedAt:"2026-02-01T14:30:00Z"},{id:"proj-gamma",name:"Mobile App",description:"React Native cross-platform mobile application",repoUrl:"",environmentId:"env-local-01",status:"archived",workingDirectory:"",useWorktrees:!0,defaultPersonaId:"",createdAt:"2025-11-20T09:00:00Z",updatedAt:"2025-11-20T09:00:00Z"}],Zw=[{id:"task-001",workspaceId:"proj-alpha",title:"Implement JWT authentication",description:"Replace session-based auth with JWT tokens across all protected routes",status:"working",branch:"feat/jwt-auth",latestSessionId:"sess-001",dependsOn:[],reviewNotes:void 0,sortOrder:1,createdAt:"2026-02-25T10:00:00Z",parentTaskId:"",depth:0,childTaskIds:["task-001a","task-001b","task-001c"],canDecompose:!0,defaultPersonaId:"",workpad:JSON.stringify({status:"in_progress",summary:"Design and implement JWT-based authentication with access/refresh tokens, replacing session-based auth.",extra:{approach:"Replace express-session with JWT Bearer tokens. Access tokens expire in 24h, refresh tokens stored in DB.",files_changed:["src/middleware/auth.ts","src/routes/login.ts","src/routes/protected.ts"],decisions:["Chose jsonwebtoken over jose for consistency with existing codebase","24h access token expiry — long enough for dev sessions, short enough for security","Refresh tokens are 48-byte random hex stored in DB with user association"],blockers:"Need to verify token rotation strategy with security team before merging"}})},{id:"task-001a",workspaceId:"proj-alpha",title:"Design token schema",description:"Define JWT payload structure, expiry, and refresh token strategy",status:"complete",branch:"feat/jwt-auth/design-token-schema",latestSessionId:"",dependsOn:[],reviewNotes:void 0,sortOrder:1,createdAt:"2026-02-25T10:10:00Z",parentTaskId:"task-001",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:""},{id:"task-001b",workspaceId:"proj-alpha",title:"Implement auth middleware",description:"Build Express middleware that verifies JWT Bearer tokens",status:"working",branch:"feat/jwt-auth/implement-auth-middleware",latestSessionId:"sess-001",dependsOn:[],reviewNotes:void 0,sortOrder:2,createdAt:"2026-02-25T10:15:00Z",parentTaskId:"task-001",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:""},{id:"task-001c",workspaceId:"proj-alpha",title:"Write auth integration tests",description:"End-to-end tests for login flow, token refresh, and protected route access",status:"not_started",branch:"",latestSessionId:"",dependsOn:["task-001b"],reviewNotes:void 0,sortOrder:3,createdAt:"2026-02-25T10:20:00Z",parentTaskId:"task-001",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:""},{id:"task-002",workspaceId:"proj-alpha",title:"Add rate limiting",description:"Implement token-bucket rate limiting for public API endpoints",status:"not_started",branch:"",latestSessionId:"",dependsOn:["task-001"],reviewNotes:void 0,sortOrder:2,createdAt:"2026-02-25T10:05:00Z",parentTaskId:"",depth:0,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:""},{id:"task-003",workspaceId:"proj-alpha",title:"Set up OpenAPI documentation",description:"Generate Swagger docs from route decorators and serve at /api/docs",status:"paused",branch:"feat/openapi-docs",latestSessionId:"sess-002",dependsOn:[],reviewNotes:void 0,sortOrder:3,createdAt:"2026-02-24T16:00:00Z",parentTaskId:"",depth:0,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:""},{id:"task-004",workspaceId:"proj-alpha",title:"Database connection pooling",description:"Switch from single connection to a connection pool with health checks",status:"complete",branch:"feat/db-pool",latestSessionId:"",dependsOn:[],reviewNotes:void 0,sortOrder:4,createdAt:"2026-02-23T11:00:00Z",parentTaskId:"",depth:0,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:""},{id:"task-005",workspaceId:"proj-alpha",title:"Fix N+1 query in user list",description:"Use a JOIN instead of per-row lookups in GET /api/users",status:"not_started",branch:"fix/user-list-n1",latestSessionId:"",dependsOn:[],reviewNotes:void 0,sortOrder:5,createdAt:"2026-02-22T09:30:00Z",parentTaskId:"",depth:0,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:""},{id:"task-006",workspaceId:"proj-beta",title:"Add Parquet export support",description:"Allow pipeline outputs to be written as Parquet files for Spark consumption",status:"working",branch:"feat/parquet-export",latestSessionId:"",dependsOn:[],reviewNotes:void 0,sortOrder:1,createdAt:"2026-02-26T08:00:00Z",parentTaskId:"",depth:0,childTaskIds:["task-006a","task-006b","task-006c","task-006d"],canDecompose:!0,defaultPersonaId:"",workpad:JSON.stringify({status:"in_progress",summary:"Plan for adding Parquet export support, including compression options and performance benchmarks.",extra:{approach:"Use apache-arrow npm package for Parquet write support. Map internal column types to Arrow type system.",compression:{supported:["snappy","zstd","gzip"],default:"snappy"},benchmarks:{"1M rows snappy":"2.3s","1M rows zstd":"3.1s","1M rows gzip":"4.8s"}}})},{id:"task-006a",workspaceId:"proj-beta",title:"Define Parquet schema mapping",description:"Map internal column types to Arrow/Parquet type system",status:"complete",branch:"feat/parquet-export/define-parquet-schema-mapping",latestSessionId:"",dependsOn:[],reviewNotes:void 0,sortOrder:1,createdAt:"2026-02-26T08:05:00Z",parentTaskId:"task-006",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:""},{id:"task-006b",workspaceId:"proj-beta",title:"Implement row-group writer",description:"Write buffered row groups with configurable batch size",status:"complete",branch:"feat/parquet-export/implement-row-group-writer",latestSessionId:"",dependsOn:["task-006a"],reviewNotes:void 0,sortOrder:2,createdAt:"2026-02-26T08:10:00Z",parentTaskId:"task-006",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:""},{id:"task-006c",workspaceId:"proj-beta",title:"Add compression options",description:"Support Snappy, ZSTD, and GZIP compression for Parquet output",status:"working",branch:"feat/parquet-export/add-compression-options",latestSessionId:"sess-004",dependsOn:["task-006b"],reviewNotes:void 0,sortOrder:3,createdAt:"2026-02-26T08:15:00Z",parentTaskId:"task-006",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:""},{id:"task-006d",workspaceId:"proj-beta",title:"Write Parquet integration tests",description:"Round-trip tests: write Parquet, read back with pyarrow, verify data integrity",status:"not_started",branch:"",latestSessionId:"",dependsOn:["task-006c"],reviewNotes:void 0,sortOrder:4,createdAt:"2026-02-26T08:20:00Z",parentTaskId:"task-006",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:""},{id:"task-007",workspaceId:"proj-beta",title:"Implement incremental loads",description:"Track watermarks so pipelines only process new/changed rows",status:"working",branch:"feat/incremental",latestSessionId:"sess-004",dependsOn:[],reviewNotes:void 0,sortOrder:2,createdAt:"2026-02-26T08:30:00Z",parentTaskId:"",depth:0,childTaskIds:["task-007a","task-007b"],canDecompose:!0,defaultPersonaId:"",workpad:""},{id:"task-007a",workspaceId:"proj-beta",title:"Design watermark storage",description:"Define schema for per-pipeline high-watermark tracking",status:"complete",branch:"feat/incremental/design-watermark-storage",latestSessionId:"",dependsOn:[],reviewNotes:void 0,sortOrder:1,createdAt:"2026-02-26T08:35:00Z",parentTaskId:"task-007",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:""},{id:"task-007b",workspaceId:"proj-beta",title:"Implement change detection query",description:"Generate WHERE clauses from watermarks to fetch only changed rows",status:"failed",branch:"feat/incremental/implement-change-detection-query",latestSessionId:"",dependsOn:["task-007a"],reviewNotes:void 0,sortOrder:2,createdAt:"2026-02-26T08:40:00Z",parentTaskId:"task-007",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:""},{id:"task-008",workspaceId:"proj-beta",title:"Add pipeline monitoring dashboard",description:"Real-time metrics for pipeline throughput, latency, and error rates",status:"paused",branch:"feat/monitoring",latestSessionId:"",dependsOn:[],reviewNotes:void 0,sortOrder:3,createdAt:"2026-02-26T09:00:00Z",parentTaskId:"",depth:0,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:""}],_0=[{id:"find-001",workspaceId:"proj-alpha",taskId:"task-001",sessionId:"sess-001",category:"architecture",title:"Auth middleware is tightly coupled to Express",content:"The current auth middleware directly references Express Request/Response types. Consider extracting a framework-agnostic token verification layer so we can reuse it in the WebSocket auth path.",tags:["auth","decoupling","middleware"],createdAt:"2026-02-27T08:16:00Z"},{id:"find-002",workspaceId:"proj-alpha",taskId:"task-003",sessionId:"sess-002",category:"api",title:"Missing pagination on GET /api/users",content:"The users endpoint returns all rows without limit/offset. For datasets over 10k rows this will cause timeouts. Recommend cursor-based pagination with a default page size of 50.",tags:["api","pagination","performance"],createdAt:"2026-02-27T07:31:00Z"},{id:"find-003",workspaceId:"proj-alpha",taskId:"task-005",sessionId:"sess-003",category:"bug",title:"Race condition in session cleanup",content:"When two requests hit /api/logout concurrently, the second call throws a 500 because the session row has already been deleted. Needs an idempotent DELETE or a conditional check.",tags:["bug","concurrency","sessions"],createdAt:"2026-02-26T22:50:00Z"},{id:"find-004",workspaceId:"proj-alpha",taskId:"task-004",sessionId:"",category:"decision",title:"Chose pg-pool over knex connection pool",content:"pg-pool gives us direct control over idle timeout, max connections, and health check queries. Knex wraps pg-pool anyway and adds overhead we don't need since we write raw SQL.",tags:["database","decision","postgres"],createdAt:"2026-02-23T11:30:00Z"},{id:"find-005",workspaceId:"proj-alpha",taskId:"",sessionId:"",category:"dependency",title:"jsonwebtoken has 3 high-severity CVEs",content:"The jsonwebtoken package (v8.x) has known vulnerabilities. Consider migrating to jose which is maintained, supports ESM, and covers the same JWS/JWE surface area with zero dependencies.",tags:["security","dependency","jwt"],createdAt:"2026-02-27T08:20:00Z"},{id:"find-006",workspaceId:"proj-alpha",taskId:"task-001",sessionId:"sess-001",category:"pattern",title:"Consistent error response shape",content:"All error responses should follow the shape `{ error: string, code: string, details?: unknown }`. Currently some routes return `{ message: string }` and others return `{ error: string }`.",tags:["api","consistency","error-handling"],createdAt:"2026-02-27T08:17:00Z"},{id:"find-007",workspaceId:"proj-beta",taskId:"task-007",sessionId:"sess-004",category:"architecture",title:"Watermark storage should be pluggable",content:"The incremental load watermarks are currently stored in a local SQLite file. For production multi-worker scenarios, this needs to be backed by a shared store (Redis or Postgres).",tags:["architecture","pipeline","scalability"],createdAt:"2026-02-27T09:05:00Z"}],Kw=[{name:"anthropic",tokenType:"env_var",envVar:"ANTHROPIC_API_KEY",filePath:"",expiresAt:""},{name:"github",tokenType:"env_var",envVar:"GITHUB_TOKEN",filePath:"",expiresAt:"2026-12-31T23:59:59Z"},{name:"gcp-service-account",tokenType:"file",envVar:"",filePath:"/home/user/.config/gcloud/credentials.json",expiresAt:""}],Yw=[{id:"persona-arch",name:"Software Architect",description:"Designs system architecture, defines interfaces, and decomposes large features into implementable tasks.",systemPrompt:"You are a senior software architect. Focus on clean interfaces, separation of concerns, and scalable patterns. When decomposing work, create concrete subtasks with clear acceptance criteria.",toolConfig:JSON.stringify({allowedTools:["Read","Grep","Glob","Write","Edit"]}),runtime:"claude-code",model:"claude-sonnet-4-6",maxTurns:50,mcpServers:"[]",createdAt:"2026-02-20T10:00:00Z",updatedAt:"2026-02-20T10:00:00Z",type:"agent",script:"",allowedMcpTools:["task_create","task_update","task_list","finding_post","finding_list","knowledge_search","knowledge_create_node","session_spawn"]},{id:"persona-fe",name:"Frontend Engineer",description:"React specialist — builds UI components, writes CSS, implements routing, and creates Playwright tests.",systemPrompt:"You are a frontend engineer specializing in React, TypeScript, and modern CSS. Follow component composition patterns, use semantic HTML, and write accessible markup.",toolConfig:JSON.stringify({allowedTools:["Read","Grep","Glob","Write","Edit","Bash"]}),runtime:"claude-code",model:"claude-sonnet-4-6",maxTurns:100,mcpServers:"[]",createdAt:"2026-02-20T10:05:00Z",updatedAt:"2026-02-20T10:05:00Z",type:"agent",script:"",allowedMcpTools:[]},{id:"persona-reviewer",name:"Code Reviewer",description:"Reviews diffs for correctness, security, and style. Posts findings for issues discovered.",systemPrompt:"You are a meticulous code reviewer. Check for security vulnerabilities, performance issues, and style consistency. Post findings for anything noteworthy.",toolConfig:JSON.stringify({allowedTools:["Read","Grep","Glob"]}),runtime:"claude-code",model:"claude-sonnet-4-6",maxTurns:30,mcpServers:"[]",createdAt:"2026-02-20T10:10:00Z",updatedAt:"2026-02-20T10:10:00Z",type:"agent",script:"",allowedMcpTools:["finding_post","finding_list","knowledge_search"]},{id:"persona-tester",name:"QA Engineer",description:"Writes comprehensive test suites — unit tests, integration tests, and E2E Playwright specs.",systemPrompt:"You are a QA engineer focused on test coverage. Write tests that cover happy paths, edge cases, error scenarios, and accessibility. Use Playwright for E2E tests.",toolConfig:JSON.stringify({allowedTools:["Read","Grep","Glob","Write","Edit","Bash"]}),runtime:"claude-code",model:"claude-sonnet-4-6",maxTurns:80,mcpServers:"[]",createdAt:"2026-02-20T10:15:00Z",updatedAt:"2026-02-20T10:15:00Z",type:"agent",script:"",allowedMcpTools:[]},{id:"persona-lint",name:"Lint & Format",description:"Scripted persona — runs ESLint and Prettier on changed files, auto-fixes violations, and posts a findings summary.",systemPrompt:"",toolConfig:"{}",runtime:"genaiscript",model:"",maxTurns:1,mcpServers:"[]",createdAt:"2026-02-21T09:00:00Z",updatedAt:"2026-02-21T09:00:00Z",type:"script",script:`const files = env.files.filter(f => /\\.(ts|tsx|js)$/.test(f.filename));
|
|
370
370
|
for (const f of files) {
|
|
371
371
|
const eslintResult = await host.exec("npx", ["eslint", "--fix", f.filename]);
|
|
372
372
|
if (eslintResult.exitCode !== 0) {
|
|
@@ -377,7 +377,7 @@ for (const f of files) {
|
|
|
377
377
|
env.findings.push({ category: "format", title: \`Prettier issues in \${f.filename}\`, content: prettierResult.stderr });
|
|
378
378
|
}
|
|
379
379
|
}
|
|
380
|
-
env.findings.push({ category: "summary", title: "Lint & format pass complete", content: \`Ran ESLint and Prettier on \${files.length} files\` });`,allowedMcpTools:[]}],
|
|
380
|
+
env.findings.push({ category: "summary", title: "Lint & format pass complete", content: \`Ran ESLint and Prettier on \${files.length} files\` });`,allowedMcpTools:[]}],Jw={"task-001b":[{id:"sess-001-prev",environmentId:"env-local-01",runtime:"claude-code",status:"stopped",endReason:"interrupted",prompt:"Implement auth middleware",startedAt:"2026-02-26T14:00:00Z"},{id:"sess-001",environmentId:"env-local-01",runtime:"claude-code",status:"running",prompt:"Implement auth middleware",startedAt:"2026-02-27T08:15:00Z"}],"task-006c":[{id:"sess-004",environmentId:"env-docker-01",runtime:"claude-code",status:"running",prompt:"Add compression options",startedAt:"2026-02-27T09:00:00Z"}]};function Ee(n){return new Date(Date.now()+n).toISOString()}const x0=[{label:"API Refactor",pauseForInput:!1,steps:[{delayMs:0,event:{eventType:"status",timestamp:Ee(0),content:"running"}},{delayMs:600,event:{eventType:"text",timestamp:Ee(600),content:"I'll start by finding all API route files that need refactoring."}},{delayMs:1200,event:{eventType:"tool_use",timestamp:Ee(1200),content:JSON.stringify({tool:"Glob",args:{pattern:"src/routes/**/*.ts"}}),raw:JSON.stringify({id:"stream-a-01",type:"tool_use"})}},{delayMs:1600,event:{eventType:"tool_result",timestamp:Ee(1600),content:`src/routes/users.ts
|
|
381
381
|
src/routes/auth.ts
|
|
382
382
|
src/routes/billing.ts
|
|
383
383
|
src/routes/admin.ts
|
|
@@ -461,7 +461,7 @@ export function verifyToken(req: Request, res: Response, next: NextFunction): vo
|
|
|
461
461
|
|
|
462
462
|
Tests: 3 passed, 3 total
|
|
463
463
|
Time: 1.234s`,raw:JSON.stringify({tool_use_id:"tool-mock-003",is_error:!1})}},{delayMs:6400,event:{eventType:"tool_use",timestamp:Ee(6400),content:JSON.stringify({tool:"Grep",args:{pattern:"decoded\\.exp",path:"src/"}}),raw:JSON.stringify({id:"tool-mock-004"})}},{delayMs:7e3,event:{eventType:"tool_result",timestamp:Ee(7e3),content:`src/middleware/auth.ts:14: if (decoded.exp < Date.now() / 1000) {
|
|
464
|
-
src/utils/token-refresh.ts:28: const remaining = decoded.exp - Date.now() / 1000;`,raw:JSON.stringify({tool_use_id:"tool-mock-004",is_error:!1})}},{delayMs:7800,event:{eventType:"text",timestamp:Ee(7800),content:"Fixed. The token expiry comparison was inverted — `decoded.exp > Date.now()` should have been `<` (a token is expired when its `exp` is in the past). The other occurrence in `token-refresh.ts` uses subtraction (not comparison), so it was already correct. All 3 auth tests pass."}},{delayMs:8400,event:{eventType:"usage",timestamp:Ee(8400),content:JSON.stringify({input_tokens:42600,output_tokens:1850,cost_usd:.12})}},{delayMs:8800,event:{eventType:"status",timestamp:Ee(8800),content:"completed"}}]}],S0=400;function W2({children:n}){const[s,i]=y.useState(H2),[o,c]=y.useState(G2),[u,d]=y.useState($2),[m,h]=y.useState(void 0),[g,v]=y.useState(F2),[b,_]=y.useState(Z2),[S,T]=y.useState(_0),[N,j]=y.useState(K2),[w,E]=y.useState({claude:"off",github:"off",copilot:"off",codex:"off",goose:"off"}),[A,O]=y.useState(Y2),[C]=y.useState(J2),[M,G]=y.useState(""),[U,V]=y.useState(ns),[Z,ee]=y.useState(ca),[ie,be]=y.useState(void 0),[K,re]=y.useState(void 0),[I,$]=y.useState(""),Q=y.useRef(void 0),de=y.useRef(0),me=y.useRef(0),ze=y.useRef(new Set),je=y.useRef(new Map),Ne=y.useRef(b);Ne.current=b;const Ae=y.useRef(new Map),ce=y.useRef(new Map),fe=y.useCallback(q=>(de.current+=1,`mock-${q}-${String(de.current).padStart(3,"0")}`),[]),pe=y.useCallback(()=>{const q=x0[me.current%x0.length];return me.current+=1,q},[]),Re=y.useCallback((q,ne,oe)=>{const le=setTimeout(()=>{var ue;ze.current.delete(le),oe&&((ue=je.current.get(oe))==null||ue.delete(le)),q()},ne);ze.current.add(le),oe&&(je.current.has(oe)||je.current.set(oe,new Set),je.current.get(oe).add(le))},[]),Bt=y.useCallback(q=>{const ne=je.current.get(q);ne&&(ne.forEach(oe=>{clearTimeout(oe),ze.current.delete(oe)}),je.current.delete(q))},[]),te=y.useCallback((q,ne,oe)=>{c(le=>le.map(ue=>ue.id===q?{...ue,status:ne,...oe!==void 0?{endReason:oe}:{}}:ue))},[]),X=y.useCallback(q=>{d(ne=>[...ne,q])},[]),Te=y.useCallback((q,ne,oe)=>{ne.forEach((le,ue)=>{Re(()=>{const qe={sessionId:q,...le.event,timestamp:new Date().toISOString()};if(X(qe),le.event.eventType==="status"){const ye=Ob(le.event.content),Oe=Ib(le.event.content);te(q,ye,Oe)}ue===ne.length-1&&oe&&oe()},le.delayMs,q)})},[Re,X,te]),un=y.useCallback((q,ne,oe,le)=>{console.log("[MockGrackle] spawn",{environmentId:q,prompt:ne,runtime:le});const ue=fe("sess"),qe={id:ue,environmentId:q,runtime:le||"claude-code",status:"running",prompt:ne,startedAt:new Date().toISOString()};c(Oe=>[...Oe,qe]),h(ue);const ye=pe();if(console.log(`[MockGrackle] Playing scenario: ${ye.label}`),ye.pauseForInput){const Oe=ye.pauseAfterStep??ye.steps.length-1,Ke=ye.steps.slice(0,Oe+1),nt=Ke.length>0?Ke[Ke.length-1].delayMs:0;Te(ue,Ke),Re(()=>{te(ue,"idle"),X({sessionId:ue,eventType:"status",timestamp:new Date().toISOString(),content:"idle"})},nt+S0,ue),ye.resumeSteps&&Ae.current.set(ue,ye.resumeSteps)}else Te(ue,ye.steps)},[fe,pe,Te,Re,te,X]),Ze=y.useCallback(q=>{console.log("[MockGrackle] kill",q),Bt(q),Ae.current.delete(q),te(q,"stopped","killed"),X({sessionId:q,eventType:"status",timestamp:new Date().toISOString(),content:"killed"}),_(ne=>ne.map(oe=>oe.latestSessionId===q&&oe.status==="working"?{...oe,status:"not_started"}:oe))},[Bt,te,X]),Kn=y.useCallback(q=>{console.log("[MockGrackle] stopGraceful",q),Bt(q),Ae.current.delete(q),te(q,"stopped","terminated"),X({sessionId:q,eventType:"status",timestamp:new Date().toISOString(),content:"terminated"}),_(ne=>ne.map(oe=>oe.latestSessionId===q&&oe.status==="working"?{...oe,status:"not_started"}:oe))},[Bt,te,X]),Yn=y.useCallback(()=>{console.log("[MockGrackle] refresh")},[]),zn=y.useCallback(q=>{console.log("[MockGrackle] loadSessionEvents",q)},[]),Jn=y.useCallback(()=>{console.log("[MockGrackle] clearEvents"),d([])},[]),Tn=y.useCallback((q,ne,oe,le,ue,qe,ye,Oe,Ke)=>{console.log("[MockGrackle] createWorkspace",{name:q,description:ne});const nt={id:fe("proj"),name:q,description:ne||"",repoUrl:oe||"",environmentId:le||"",status:"active",workingDirectory:ye||"",useWorktrees:qe??!0,defaultPersonaId:ue||"",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};v(He=>[...He,nt]),Oe&&Oe()},[fe]),Ls=y.useCallback(q=>{console.log("[MockGrackle] archiveWorkspace",q),v(ne=>ne.map(oe=>oe.id===q?{...oe,status:"archived"}:oe))},[]),dn=y.useCallback(q=>{console.log("[MockGrackle] loadTasks",q)},[]),Me=y.useCallback((q,ne,oe,le,ue,qe,ye,Oe,Ke)=>{console.log("[MockGrackle] createTask",{workspaceId:q,title:ne,parentTaskId:ue}),_(nt=>{const zt=nt.filter(Vn=>Vn.workspaceId===q).reduce((Vn,xa)=>Math.max(Vn,xa.sortOrder),0),Pt=ue?nt.find(Vn=>Vn.id===ue):void 0;if(ue&&!Pt)return console.warn("[MockGrackle] Parent task not found:",ue),nt;if(Pt&&!Pt.canDecompose)return console.warn("[MockGrackle] Parent task does not have decomposition rights:",ue),nt;const Tt=Pt?Pt.depth+1:0,ls={id:fe("task"),workspaceId:q,title:ne,description:oe||"",status:"not_started",branch:"",latestSessionId:"",dependsOn:le||[],reviewNotes:void 0,sortOrder:zt+1,createdAt:new Date().toISOString(),parentTaskId:ue||"",depth:Tt,childTaskIds:[],canDecompose:ye??!ue,defaultPersonaId:qe||"",workpad:""};return[...nt,ls]}),Oe&&Oe()},[fe]),Mt=y.useCallback((q,ne,oe,le)=>{var nt;console.log("[MockGrackle] startTask",{taskId:q});const ue=Ne.current.find(He=>He.id===q),qe=(ue==null?void 0:ue.title)??"",ye=fe("sess"),Oe={id:ye,environmentId:"env-local-01",runtime:"claude-code",status:"running",prompt:qe||q,startedAt:new Date().toISOString()};c(He=>[...He,Oe]),_(He=>He.map(zt=>zt.id===q?{...zt,status:"working",latestSessionId:ye,branch:`mock/${q.slice(0,8)}`}:zt));const Ke=pe();if(console.log(`[MockGrackle] Playing task scenario: ${Ke.label}`),Ke.pauseForInput){const He=Ke.pauseAfterStep??Ke.steps.length-1,zt=Ke.steps.slice(0,He+1),Pt=zt.length>0?zt[zt.length-1].delayMs:0;if(Te(ye,zt),Re(()=>{te(ye,"idle"),X({sessionId:ye,eventType:"status",timestamp:new Date().toISOString(),content:"idle"})},Pt+S0,ye),Ke.resumeSteps){const Tt=[...Ke.resumeSteps];Ae.current.set(ye,Tt);const ls=Tt.reduce((Vn,xa)=>Math.max(Vn,xa.delayMs),0);ce.current.set(ye,{taskId:q,delayAfterResume:ls+200})}}else{const He=Ke.steps.length>0?Ke.steps[Ke.steps.length-1].delayMs:0;Te(ye,Ke.steps);const zt=(nt=Ke.steps[Ke.steps.length-1])==null?void 0:nt.event.content;Re(()=>{zt==="completed"?_(Pt=>Pt.map(Tt=>Tt.id===q&&Tt.status==="working"?{...Tt,status:"paused"}:Tt)):zt==="failed"&&_(Pt=>Pt.map(Tt=>Tt.id===q&&Tt.status==="working"?{...Tt,status:"failed"}:Tt))},He+100,ye)}},[fe,pe,Te,Re,te,X]),Kt=y.useCallback((q,ne)=>{console.log("[MockGrackle] sendInput",{sessionId:q,text:ne}),X({sessionId:q,eventType:"output",timestamp:new Date().toISOString(),content:`User input: ${ne}`}),te(q,"running"),X({sessionId:q,eventType:"status",timestamp:new Date().toISOString(),content:"running"});const oe=Ae.current.get(q);if(oe)Ae.current.delete(q),Te(q,oe);else{const ue=[{delayMs:500,event:{eventType:"output",timestamp:new Date().toISOString(),content:"I received your input, continuing..."}},{delayMs:1500,event:{eventType:"status",timestamp:new Date().toISOString(),content:"completed"}}];Te(q,ue)}const le=ce.current.get(q);le&&(ce.current.delete(q),Re(()=>{_(ue=>ue.map(qe=>qe.id===le.taskId&&qe.status==="working"?{...qe,status:"paused"}:qe))},le.delayAfterResume,q))},[X,te,Te,Re]),lo=y.useCallback(q=>{console.log("[MockGrackle] completeTask",q),_(ne=>ne.map(oe=>oe.id===q?{...oe,status:"complete"}:oe))},[]),co=y.useCallback(q=>{console.log("[MockGrackle] resumeTask",q)},[]),uo=y.useCallback((q,ne,oe,le,ue)=>{console.log("[MockGrackle] updateTask",{taskId:q,title:ne}),_(qe=>qe.map(ye=>ye.id===q?{...ye,title:ne.trim()||ye.title,description:oe,dependsOn:le,...ue!==void 0?{defaultPersonaId:ue}:{}}:ye))},[]),_a=y.useCallback(q=>{console.log("[MockGrackle] deleteTask",q),_(ne=>ne.filter(oe=>oe.id!==q))},[]),Or=y.useCallback(q=>{console.log("[MockGrackle] loadFindings",q),T(_0.filter(ne=>ne.workspaceId===q))},[]),fo=y.useCallback((q,ne,oe,le,ue)=>{console.log("[MockGrackle] postFinding",{workspaceId:q,title:ne});const qe={id:fe("find"),workspaceId:q,taskId:"",sessionId:"",category:le||"general",title:ne,content:oe,tags:ue||[],createdAt:new Date().toISOString()};T(ye=>[...ye,qe])},[fe]),Ir=y.useCallback(()=>{console.log("[MockGrackle] loadEnvironments")},[]),Br=y.useCallback((q,ne,oe)=>{console.log("[MockGrackle] addEnvironment",{displayName:q,adapterType:ne,adapterConfig:oe})},[]),Us=y.useCallback((q,ne)=>{console.log("[MockGrackle] updateEnvironment",{environmentId:q,...ne}),i(oe=>oe.map(le=>le.id!==q?le:{...le,...ne.displayName!==void 0?{displayName:ne.displayName}:{},...ne.adapterConfig!==void 0?{adapterConfig:JSON.stringify(ne.adapterConfig)}:{}}))},[]),Yt=y.useCallback(()=>{console.log("[MockGrackle] loadTokens")},[]),Pn=y.useCallback((q,ne,oe,le,ue)=>{console.log("[MockGrackle] setToken",{name:q,tokenType:oe}),j(qe=>[...qe.filter(Oe=>Oe.name!==q),{name:q,tokenType:oe,envVar:le,filePath:ue,expiresAt:""}])},[]),Jt=y.useCallback(q=>{console.log("[MockGrackle] deleteToken",q),j(ne=>ne.filter(oe=>oe.name!==q))},[]),Lr=y.useCallback(q=>{console.log("[MockGrackle] updateCredentialProviders",q),E(q)},[]);y.useEffect(()=>()=>{ze.current.forEach(clearTimeout),ze.current.clear()},[]);const qc=y.useMemo(()=>({connected:!0,send:()=>{},environments:s,sessions:o,events:u,eventsDropped:0,lastSpawnedId:m,workspaces:g,tasks:b,findings:S,tokens:N,credentialProviders:w,spawn:un,sendInput:Kt,kill:Ze,stopGraceful:Kn,refresh:Yn,loadSessionEvents:zn,clearEvents:Jn,loadWorkspaces:()=>{console.log("[MockGrackle] loadWorkspaces")},createWorkspace:Tn,archiveWorkspace:Ls,updateWorkspace:(q,ne)=>{console.log("[MockGrackle] updateWorkspace",{workspaceId:q,...ne}),v(oe=>oe.map(le=>le.id!==q?le:{...le,...ne.name!==void 0?{name:ne.name}:{},...ne.description!==void 0?{description:ne.description}:{},...ne.repoUrl!==void 0?{repoUrl:ne.repoUrl}:{},...ne.environmentId!==void 0?{environmentId:ne.environmentId}:{},...ne.workingDirectory!==void 0?{workingDirectory:ne.workingDirectory}:{},...ne.useWorktrees!==void 0?{useWorktrees:ne.useWorktrees}:{},...ne.defaultPersonaId!==void 0?{defaultPersonaId:ne.defaultPersonaId}:{},updatedAt:new Date().toISOString()}))},loadTasks:dn,loadAllTasks:()=>{console.log("[MockGrackle] loadAllTasks")},createTask:Me,startTask:Mt,stopTask:q=>{console.log("[MockGrackle] stopTask",{taskId:q}),lo(q)},completeTask:lo,resumeTask:co,updateTask:uo,deleteTask:_a,loadFindings:Or,postFinding:fo,loadEnvironments:Ir,addEnvironment:Br,updateEnvironment:Us,loadTokens:Yt,setToken:Pn,deleteToken:Jt,updateCredentialProviders:Lr,provisionStatus:{},provisionEnvironment:(q,ne)=>{},stopEnvironment:()=>{},removeEnvironment:()=>{},codespaces:[],codespaceError:"",codespaceListError:"",codespaceCreating:!1,listCodespaces:()=>{},createCodespace:()=>{},workspaceCreating:!1,taskStartingId:void 0,personas:A,createPersona:async(q,ne,oe,le,ue,qe,ye,Oe,Ke)=>{console.log("[MockGrackle] createPersona",{name:q});const nt={id:`mock-persona-${Date.now()}`,name:q,description:ne,systemPrompt:oe,toolConfig:"{}",runtime:le??"claude-code",model:ue||"",maxTurns:qe||0,mcpServers:"[]",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),type:ye||"agent",script:Oe||"",allowedMcpTools:Ke||[]};return O(He=>[...He,nt]),nt},updatePersona:async(q,ne,oe,le,ue,qe,ye,Oe,Ke,nt)=>{console.log("[MockGrackle] updatePersona",{personaId:q,name:ne});const He=A.find(Tt=>Tt.id===q);if(!He)throw new Error(`Persona not found: ${q}`);const zt=new Date().toISOString(),Pt={...He,...ne!==void 0?{name:ne}:{},...oe!==void 0?{description:oe}:{},...le!==void 0?{systemPrompt:le}:{},...ue!==void 0?{runtime:ue}:{},...qe!==void 0?{model:qe}:{},...ye!==void 0?{maxTurns:ye}:{},...Oe!==void 0?{type:Oe}:{},...Ke!==void 0?{script:Ke}:{},...nt!==void 0?{allowedMcpTools:nt}:{},updatedAt:zt};return O(Tt=>Tt.map(ls=>ls.id===q?Pt:ls)),Pt},deletePersona:async q=>{console.log("[MockGrackle] deletePersona",q),O(ne=>ne.filter(oe=>oe.id!==q))},taskSessions:C,loadTaskSessions:q=>{console.log("[MockGrackle] loadTaskSessions",q)},appDefaultPersonaId:M,setAppDefaultPersonaId:async q=>{console.log("[MockGrackle] setAppDefaultPersonaId",q),G(q)},onboardingCompleted:!0,completeOnboarding:()=>{console.log("[MockGrackle] completeOnboarding")},usageCache:{"workspace:proj-alpha":{inputTokens:214500,outputTokens:44850,costUsd:1.12,sessionCount:4},"workspace:proj-beta":{inputTokens:86700,outputTokens:23800,costUsd:.48,sessionCount:3},"task:task-001":{inputTokens:126800,outputTokens:20850,costUsd:.63,sessionCount:2},"task:task-006":{inputTokens:18900,outputTokens:4500,costUsd:.1,sessionCount:1},"task_tree:task-001":{inputTokens:126800,outputTokens:20850,costUsd:.63,sessionCount:2},"task_tree:task-006":{inputTokens:18900,outputTokens:4500,costUsd:.1,sessionCount:1}},loadUsage:(q,ne)=>{console.log(`[MockGrackle] loadUsage(${q}, ${ne})`)},knowledge:{graphData:{nodes:U,links:Z},selectedNode:ie,loading:!1,selectedId:K,searchQuery:I,search:q=>{if(console.log("[MockGrackle] knowledge.search",q),!q.trim()){$(q);return}$(q);const ne=Q.current,oe=ne?ns.filter(ye=>!ye.workspaceId||ye.workspaceId===ne):ns,le=q.toLowerCase(),ue=oe.filter(ye=>{var Oe,Ke,nt;return ye.label.toLowerCase().includes(le)||((Oe=ye.content)==null?void 0:Oe.toLowerCase().includes(le))||((Ke=ye.tags)==null?void 0:Ke.some(He=>He.toLowerCase().includes(le)))||((nt=ye.category)==null?void 0:nt.toLowerCase().includes(le))});V(ue);const qe=new Set(ue.map(ye=>ye.id));ee(ca.filter(ye=>qe.has(ye.source)&&qe.has(ye.target))),re(void 0),be(void 0)},clearSearch:()=>{console.log("[MockGrackle] knowledge.clearSearch"),$("");const q=Q.current,ne=q?ns.filter(le=>!le.workspaceId||le.workspaceId===q):ns;V(ne);const oe=new Set(ne.map(le=>le.id));ee(ca.filter(le=>oe.has(le.source)&&oe.has(le.target)))},selectNode:q=>{console.log("[MockGrackle] knowledge.selectNode",q),re(q);const ne=q in b0?b0[q]:void 0;if(ne)be(ne);else{const oe=ns.find(le=>le.id===q);if(oe){const le=ca.filter(ue=>ue.source===q||ue.target===q).map(ue=>({fromId:ue.source,toId:ue.target,type:ue.type}));be({node:oe,edges:le})}}},clearSelection:()=>{console.log("[MockGrackle] knowledge.clearSelection"),re(void 0),be(void 0)},expandNode:q=>{console.log("[MockGrackle] knowledge.expandNode",q),V(ne=>{const oe=new Set(ne.map(Oe=>Oe.id)),le=ca.filter(Oe=>Oe.source===q||Oe.target===q),ue=new Set;for(const Oe of le)oe.has(Oe.source)||ue.add(Oe.source),oe.has(Oe.target)||ue.add(Oe.target);if(ue.size===0)return ne;const qe=ns.filter(Oe=>ue.has(Oe.id)),ye=new Set([...oe,...ue]);return ee(Oe=>{const Ke=new Set(Oe.map(He=>`${He.source}|${He.target}|${He.type}`)),nt=ca.filter(He=>ye.has(He.source)&&ye.has(He.target)&&!Ke.has(`${He.source}|${He.target}|${He.type}`));return nt.length>0?[...Oe,...nt]:Oe}),[...ne,...qe]})},loadRecent:q=>{if(console.log("[MockGrackle] knowledge.loadRecent",q),Q.current=q,q){const ne=ns.filter(le=>!le.workspaceId||le.workspaceId===q);V(ne);const oe=new Set(ne.map(le=>le.id));ee(ca.filter(le=>oe.has(le.source)&&oe.has(le.target)))}else V(ns),ee(ca);$("")},handleEvent:()=>!1}}),[s,o,u,m,g,b,S,N,w,A,C,M,U,Z,ie,K,I,un,Kt,Ze,Kn,Yn,zn,Jn,Tn,Ls,dn,Me,Mt,lo,co,uo,_a,Or,fo,Ir,Br,Us,Yt,Pn,Jt,Lr]);return l.jsx(_p.Provider,{value:qc,children:n})}const Bb=y.createContext(void 0),X2=4e3;function Q2({children:n}){const[s,i]=y.useState([]),o=y.useRef(0),c=y.useCallback(d=>{i(m=>m.filter(h=>h.id!==d))},[]),u=y.useCallback((d,m="info",h=X2)=>{const g=`toast-${++o.current}`;i(v=>[...v,{id:g,message:d,variant:m,duration:h}])},[]);return l.jsx(Bb.Provider,{value:{toasts:s,showToast:u,dismissToast:c},children:n})}function Bs(){const n=y.useContext(Bb);if(!n)throw new Error("useToast must be used within ToastProvider");return n}const Oc=[{id:"grackle",label:"Grackle",description:"The default Grackle theme — iridescent purple on clean dark.",swatches:["#0e1218","#8b5cf6","#60a5fa","#e5e7eb","#34d399"],variantLightId:"grackle-light",variantDarkId:"grackle-dark"},{id:"grackle-light",label:"Grackle Light",description:"Light Grackle variant.",hidden:!0},{id:"grackle-dark",label:"Grackle Dark",description:"Dark Grackle variant.",hidden:!0},{id:"glass",label:"Glassmorphism",description:"Dark frosted-glass aesthetic with backdrop blur effects.",swatches:["#0a0c14","#4ecca3","#70a1ff","#e2e8f0","#a855f7"]},{id:"matrix",label:"Matrix",description:"Phosphor-green CRT terminal with scanlines and glow.",swatches:["#050505","#00ff41","#00bfff","#33ff77","#ffb000"]},{id:"brutalist",label:"Neubrutalism",description:"Thick borders, raw colors, bold type — ugly on purpose.",swatches:["#f5f0e8","#ff5757","#5ce1e6","#1a1a1a","#ffde59"],variantLightId:"brutalist-light",variantDarkId:"brutalist-dark"},{id:"brutalist-light",label:"Neubrutalism Light",description:"Light neubrutalism variant.",hidden:!0},{id:"brutalist-dark",label:"Neubrutalism Dark",description:"Dark neubrutalism variant.",hidden:!0},{id:"monokai",label:"Monokai",description:"Classic warm editor palette — pink, green, and purple.",swatches:["#272822","#f92672","#a6e22e","#f8f8f2","#ae81ff"],variantLightId:"monokai-light",variantDarkId:"monokai-dark"},{id:"monokai-dark",label:"Monokai Dark",description:"Dark Monokai variant.",hidden:!0},{id:"monokai-light",label:"Monokai Light",description:"Light Monokai variant.",hidden:!0},{id:"ubuntu",label:"Ubuntu",description:"Aubergine terminal with the GNOME Tango palette.",swatches:["#300a24","#8ae234","#ef2929","#eeeeec","#fce94f"]},{id:"sandstone",label:"Sandstone",description:"Warm terracotta accent on dark brown, in the style of Claude Code.",swatches:["#1a1815","#C15F3C","#6b8afd","#e8e6e3","#a78bfa"]},{id:"verdigris",label:"Verdigris",description:"Teal accent on charcoal, in the style of ChatGPT.",swatches:["#141414","#00a67e","#3b82f6","#ececec","#ab68ff"]},{id:"primer",label:"Primer",description:"Blue accent on ink-dark grey, in the style of GitHub.",swatches:["#0d1117","#58a6ff","#3fb950","#c9d1d9","#bc8cff"]}],Lb=new Set(Oc.map(n=>n.id)),T0="grackle";function Pf(n){return Oc.find(s=>s.id===n)}const Vf="grackle-theme",Ub="grackle-prefer-system",zb="(prefers-color-scheme: dark)";let cr=[],fc;function uf(){fc=void 0;for(const n of cr)n()}function qf(){return typeof window>"u"?!1:window.matchMedia(zb).matches}function mr(){if(typeof localStorage>"u")return T0;try{const n=localStorage.getItem(Vf);if(n!==null&&Lb.has(n))return n}catch{}return T0}function yc(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(Ub)==="true"}catch{return!1}}function Hf(n){return Oc.find(s=>s.variantLightId===n||s.variantDarkId===n)}function Pb(n,s){const i=Pf(n);if(i!=null&&i.variantDarkId)return s&&i.variantLightId?qf()?i.variantDarkId:i.variantLightId:i.variantDarkId;if(i!=null&&i.hidden&&s){const o=Hf(n);if(o!=null&&o.variantLightId&&o.variantDarkId)return qf()?o.variantDarkId:o.variantLightId}return n}function Hi(n,s,i=!1){i&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=Pb(n,s),i&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&Hi(mr(),yc());function ew(){return fc===void 0&&(fc={themeId:mr(),systemDark:qf(),preferSystem:yc()}),fc}function tw(n){return cr=[...cr,n],()=>{cr=cr.filter(s=>s!==n)}}function nw(){const n=y.useSyncExternalStore(tw,ew),{themeId:s,preferSystem:i}=n,o=Pb(s,i),c=y.useCallback(d=>{if(Lb.has(d)){try{localStorage.setItem(Vf,d)}catch{}Hi(d,yc(),!0),uf()}},[]),u=y.useCallback(d=>{try{localStorage.setItem(Ub,d?"true":"false")}catch{}if(d){const m=mr(),h=Pf(m);if(h!=null&&h.hidden){const g=Hf(m);if(g)try{localStorage.setItem(Vf,g.id)}catch{}}}Hi(mr(),d,!0),uf()},[]);return y.useEffect(()=>{Hi(s,i)},[s,i]),y.useEffect(()=>{if(typeof window>"u")return;const d=window.matchMedia(zb),m=()=>{const h=mr(),g=yc();if(g){const v=Pf(h);if(v!=null&&v.variantDarkId&&v.variantLightId&&Hi(h,g),v!=null&&v.hidden){const b=Hf(h);b!=null&&b.variantDarkId&&b.variantLightId&&Hi(h,g)}}uf()};return d.addEventListener("change",m),()=>{d.removeEventListener("change",m)}},[]),{themeId:s,setTheme:c,resolvedThemeId:o,preferSystem:i,setPreferSystem:u}}const Vb=y.createContext(void 0);function sw({children:n}){const s=nw();return l.jsx(Vb.Provider,{value:s,children:n})}function qb(){const n=y.useContext(Vb);if(!n)throw new Error("useThemeContext must be used within ThemeProvider");return n}const aw="_container_1mq5u_1",iw="_hamburger_1mq5u_33",ow="_brand_1mq5u_49",rw="_brandLogo_1mq5u_68",lw="_info_1mq5u_75",cw="_connectionLabel_1mq5u_90",uw="_connectionDot_1mq5u_103",dw="_connected_1mq5u_106",fw="_disconnected_1mq5u_110",js={container:aw,hamburger:iw,brand:ow,brandLogo:rw,info:lw,connectionLabel:cw,connectionDot:uw,connected:dw,disconnected:fw};function pw({connected:n,environments:s,sessions:i,onToggleSidebar:o,sidebarOpen:c}){const u=St(),d=s.length,m=s.filter(g=>g.status==="connected").length,h=i.filter(g=>["running","idle"].includes(g.status)).length;return l.jsxs("div",{className:js.container,children:[o&&l.jsx("button",{type:"button",className:js.hamburger,onClick:o,"aria-label":"Toggle sidebar","aria-expanded":c,children:"☰"}),l.jsxs("button",{type:"button",className:js.brand,onClick:()=>u(Ya),title:"Home",children:[l.jsx("img",{src:"/icon-192x192.png",alt:"",className:js.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]}),l.jsxs("div",{className:js.info,children:[l.jsxs("span",{"aria-label":n?"Connected":"Disconnected",children:[l.jsx("span",{className:`${js.connectionDot} ${n?js.connected:js.disconnected}`,"aria-hidden":"true",children:"●"})," ",l.jsx("span",{className:js.connectionLabel,"aria-hidden":"true",children:n?"Connected":"Disconnected"})]}),l.jsxs("span",{children:[m,"/",d," env",d!==1?"s":""]}),l.jsxs("span",{children:[h," active"]})]})]})}const mw="_nav_13gkc_1",hw="_tab_13gkc_35",gw="_tabIcon_13gkc_68",vw="_tabLabel_13gkc_79",yw="_tabActive_13gkc_84",ir={nav:mw,tab:hw,tabIcon:gw,tabLabel:vw,tabActive:yw},za=[{view:"dashboard",label:"Dashboard",icon:"🏠",route:Ya,testId:"sidebar-tab-dashboard"},{view:"chat",label:"Chat",icon:"💬",route:p2,testId:"sidebar-tab-chat"},{view:"tasks",label:"Tasks",icon:"📋",route:m2,testId:"sidebar-tab-tasks"},{view:"environments",label:"Environments",icon:"🖥️",route:Xi,testId:"sidebar-tab-environments"},{view:"knowledge",label:"Knowledge",icon:"🧠",route:Db,testId:"sidebar-tab-knowledge"},{view:"settings",label:"Settings",icon:"⚙️",route:c2,testId:"sidebar-tab-settings"}];function bw(n){return n===Ya||n==="/"?"dashboard":n.startsWith("/chat")||n.startsWith("/sessions")?"chat":n.startsWith("/workspaces")||n.startsWith("/environments")?"environments":n.startsWith(Db)?"knowledge":n.startsWith(Ji)?"settings":"tasks"}function _w(){const n=It(),s=St(),i=y.useRef(null),o=bw(n.pathname),c=y.useCallback(d=>{s(d.route)},[s]),u=y.useCallback(d=>{var b,_;const m=(b=i.current)==null?void 0:b.querySelectorAll('[role="tab"]');if(!m)return;const h=Array.from(m).findIndex(S=>S===document.activeElement),g=h>=0?h:za.findIndex(S=>S.view===o);let v=g;if(d.key==="ArrowRight"||d.key==="j"||d.key==="J")d.preventDefault(),v=(g+1)%za.length;else if(d.key==="ArrowLeft"||d.key==="k"||d.key==="K")d.preventDefault(),v=(g-1+za.length)%za.length;else if(d.key==="Home")d.preventDefault(),v=0;else if(d.key==="End")d.preventDefault(),v=za.length-1;else return;s(za[v].route),(_=m[v])==null||_.focus()},[o,s]);return l.jsx("nav",{className:ir.nav,ref:i,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:u,"data-testid":"sidebar-nav",children:za.map(d=>{const m=d.view===o;return l.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${ir.tab} ${m?ir.tabActive:""}`,onClick:()=>c(d),"data-testid":d.testId,title:d.label,"aria-label":d.label,children:[l.jsx("span",{className:ir.tabIcon,"aria-hidden":"true",children:d.icon}),l.jsx("span",{className:ir.tabLabel,children:d.label})]},d.view)})})}const Hb=y.createContext(void 0),Gb=y.createContext(void 0);function xw({children:n}){const[s,i]=y.useState(void 0),o=y.useCallback(c=>{i(c)},[]);return l.jsx(Gb.Provider,{value:o,children:l.jsx(Hb.Provider,{value:s,children:n})})}function $b(){return y.useContext(Hb)}function Sw(){const n=y.useContext(Gb);if(n===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return n}const Tw="_container_pi6ii_1",kw="_content_pi6ii_66",k0={container:Tw,content:kw},ww=320,Fb=220,Zb=600,Kb="grackle-sidebar-width";function Nw(){try{const n=localStorage.getItem(Kb);if(n!==null){const s=Number(n);if(Number.isFinite(s)&&s>=Fb&&s<=Zb)return s}}catch{}return ww}function jw(n){try{localStorage.setItem(Kb,String(n))}catch{}}function Cw(){const[n]=y.useState(Nw),s=y.useRef(null),i=$b();if(y.useEffect(()=>{const o=s.current;if(!o)return;const c=new ResizeObserver(u=>{for(const d of u){const m=d.borderBoxSize[0];if(m){const h=Math.round(m.inlineSize);h>=Fb&&h<=Zb&&jw(h)}}});return c.observe(o),()=>{c.disconnect()}},[]),i!==void 0)return l.jsx("div",{className:k0.container,ref:s,"data-testid":"sidebar",style:{width:n},children:l.jsx("div",{className:k0.content,children:i})})}function Ic(n){const s=Sw();y.useLayoutEffect(()=>(s(n),()=>{s(void 0)}),[n,s])}const xp=y.createContext({});function Sp(n){const s=y.useRef(null);return s.current===null&&(s.current=n()),s.current}const Bc=y.createContext(null),Tp=y.createContext({transformPagePoint:n=>n,isStatic:!1,reducedMotion:"never"});class Ew extends y.Component{getSnapshotBeforeUpdate(s){const i=this.props.childRef.current;if(i&&s.isPresent&&!this.props.isPresent){const o=this.props.sizeRef.current;o.height=i.offsetHeight||0,o.width=i.offsetWidth||0,o.top=i.offsetTop,o.left=i.offsetLeft}return null}componentDidUpdate(){}render(){return this.props.children}}function Aw({children:n,isPresent:s}){const i=y.useId(),o=y.useRef(null),c=y.useRef({width:0,height:0,top:0,left:0}),{nonce:u}=y.useContext(Tp);return y.useInsertionEffect(()=>{const{width:d,height:m,top:h,left:g}=c.current;if(s||!o.current||!d||!m)return;o.current.dataset.motionPopId=i;const v=document.createElement("style");return u&&(v.nonce=u),document.head.appendChild(v),v.sheet&&v.sheet.insertRule(`
|
|
464
|
+
src/utils/token-refresh.ts:28: const remaining = decoded.exp - Date.now() / 1000;`,raw:JSON.stringify({tool_use_id:"tool-mock-004",is_error:!1})}},{delayMs:7800,event:{eventType:"text",timestamp:Ee(7800),content:"Fixed. The token expiry comparison was inverted — `decoded.exp > Date.now()` should have been `<` (a token is expired when its `exp` is in the past). The other occurrence in `token-refresh.ts` uses subtraction (not comparison), so it was already correct. All 3 auth tests pass."}},{delayMs:8400,event:{eventType:"usage",timestamp:Ee(8400),content:JSON.stringify({input_tokens:42600,output_tokens:1850,cost_usd:.12})}},{delayMs:8800,event:{eventType:"status",timestamp:Ee(8800),content:"completed"}}]}],S0=400;function Ww({children:n}){const[s,i]=y.useState(Hw),[o,c]=y.useState(Gw),[u,d]=y.useState($w),[m,h]=y.useState(void 0),[g,v]=y.useState(Fw),[b,_]=y.useState(Zw),[S,T]=y.useState(_0),[N,j]=y.useState(Kw),[w,E]=y.useState({claude:"off",github:"off",copilot:"off",codex:"off",goose:"off"}),[A,O]=y.useState(Yw),[C]=y.useState(Jw),[M,G]=y.useState(""),[U,V]=y.useState(ns),[Z,ee]=y.useState(ca),[ie,be]=y.useState(void 0),[K,re]=y.useState(void 0),[I,$]=y.useState(""),Q=y.useRef(void 0),de=y.useRef(0),me=y.useRef(0),ze=y.useRef(new Set),je=y.useRef(new Map),Ne=y.useRef(b);Ne.current=b;const Ae=y.useRef(new Map),ce=y.useRef(new Map),fe=y.useCallback(q=>(de.current+=1,`mock-${q}-${String(de.current).padStart(3,"0")}`),[]),pe=y.useCallback(()=>{const q=x0[me.current%x0.length];return me.current+=1,q},[]),Re=y.useCallback((q,ne,oe)=>{const le=setTimeout(()=>{var ue;ze.current.delete(le),oe&&((ue=je.current.get(oe))==null||ue.delete(le)),q()},ne);ze.current.add(le),oe&&(je.current.has(oe)||je.current.set(oe,new Set),je.current.get(oe).add(le))},[]),Bt=y.useCallback(q=>{const ne=je.current.get(q);ne&&(ne.forEach(oe=>{clearTimeout(oe),ze.current.delete(oe)}),je.current.delete(q))},[]),te=y.useCallback((q,ne,oe)=>{c(le=>le.map(ue=>ue.id===q?{...ue,status:ne,...oe!==void 0?{endReason:oe}:{}}:ue))},[]),X=y.useCallback(q=>{d(ne=>[...ne,q])},[]),Te=y.useCallback((q,ne,oe)=>{ne.forEach((le,ue)=>{Re(()=>{const qe={sessionId:q,...le.event,timestamp:new Date().toISOString()};if(X(qe),le.event.eventType==="status"){const ye=Ob(le.event.content),Oe=Ib(le.event.content);te(q,ye,Oe)}ue===ne.length-1&&oe&&oe()},le.delayMs,q)})},[Re,X,te]),un=y.useCallback((q,ne,oe,le)=>{console.log("[MockGrackle] spawn",{environmentId:q,prompt:ne,runtime:le});const ue=fe("sess"),qe={id:ue,environmentId:q,runtime:le||"claude-code",status:"running",prompt:ne,startedAt:new Date().toISOString()};c(Oe=>[...Oe,qe]),h(ue);const ye=pe();if(console.log(`[MockGrackle] Playing scenario: ${ye.label}`),ye.pauseForInput){const Oe=ye.pauseAfterStep??ye.steps.length-1,Ke=ye.steps.slice(0,Oe+1),nt=Ke.length>0?Ke[Ke.length-1].delayMs:0;Te(ue,Ke),Re(()=>{te(ue,"idle"),X({sessionId:ue,eventType:"status",timestamp:new Date().toISOString(),content:"idle"})},nt+S0,ue),ye.resumeSteps&&Ae.current.set(ue,ye.resumeSteps)}else Te(ue,ye.steps)},[fe,pe,Te,Re,te,X]),Ze=y.useCallback(q=>{console.log("[MockGrackle] kill",q),Bt(q),Ae.current.delete(q),te(q,"stopped","killed"),X({sessionId:q,eventType:"status",timestamp:new Date().toISOString(),content:"killed"}),_(ne=>ne.map(oe=>oe.latestSessionId===q&&oe.status==="working"?{...oe,status:"not_started"}:oe))},[Bt,te,X]),Kn=y.useCallback(q=>{console.log("[MockGrackle] stopGraceful",q),Bt(q),Ae.current.delete(q),te(q,"stopped","terminated"),X({sessionId:q,eventType:"status",timestamp:new Date().toISOString(),content:"terminated"}),_(ne=>ne.map(oe=>oe.latestSessionId===q&&oe.status==="working"?{...oe,status:"not_started"}:oe))},[Bt,te,X]),Yn=y.useCallback(()=>{console.log("[MockGrackle] refresh")},[]),zn=y.useCallback(q=>{console.log("[MockGrackle] loadSessionEvents",q)},[]),Jn=y.useCallback(()=>{console.log("[MockGrackle] clearEvents"),d([])},[]),Tn=y.useCallback((q,ne,oe,le,ue,qe,ye,Oe,Ke)=>{console.log("[MockGrackle] createWorkspace",{name:q,description:ne});const nt={id:fe("proj"),name:q,description:ne||"",repoUrl:oe||"",environmentId:le||"",status:"active",workingDirectory:ye||"",useWorktrees:qe??!0,defaultPersonaId:ue||"",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};v(He=>[...He,nt]),Oe&&Oe()},[fe]),Ls=y.useCallback(q=>{console.log("[MockGrackle] archiveWorkspace",q),v(ne=>ne.map(oe=>oe.id===q?{...oe,status:"archived"}:oe))},[]),dn=y.useCallback(q=>{console.log("[MockGrackle] loadTasks",q)},[]),Me=y.useCallback((q,ne,oe,le,ue,qe,ye,Oe,Ke)=>{console.log("[MockGrackle] createTask",{workspaceId:q,title:ne,parentTaskId:ue}),_(nt=>{const zt=nt.filter(Vn=>Vn.workspaceId===q).reduce((Vn,xa)=>Math.max(Vn,xa.sortOrder),0),Pt=ue?nt.find(Vn=>Vn.id===ue):void 0;if(ue&&!Pt)return console.warn("[MockGrackle] Parent task not found:",ue),nt;if(Pt&&!Pt.canDecompose)return console.warn("[MockGrackle] Parent task does not have decomposition rights:",ue),nt;const Tt=Pt?Pt.depth+1:0,ls={id:fe("task"),workspaceId:q,title:ne,description:oe||"",status:"not_started",branch:"",latestSessionId:"",dependsOn:le||[],reviewNotes:void 0,sortOrder:zt+1,createdAt:new Date().toISOString(),parentTaskId:ue||"",depth:Tt,childTaskIds:[],canDecompose:ye??!ue,defaultPersonaId:qe||"",workpad:""};return[...nt,ls]}),Oe&&Oe()},[fe]),Mt=y.useCallback((q,ne,oe,le)=>{var nt;console.log("[MockGrackle] startTask",{taskId:q});const ue=Ne.current.find(He=>He.id===q),qe=(ue==null?void 0:ue.title)??"",ye=fe("sess"),Oe={id:ye,environmentId:"env-local-01",runtime:"claude-code",status:"running",prompt:qe||q,startedAt:new Date().toISOString()};c(He=>[...He,Oe]),_(He=>He.map(zt=>zt.id===q?{...zt,status:"working",latestSessionId:ye,branch:`mock/${q.slice(0,8)}`}:zt));const Ke=pe();if(console.log(`[MockGrackle] Playing task scenario: ${Ke.label}`),Ke.pauseForInput){const He=Ke.pauseAfterStep??Ke.steps.length-1,zt=Ke.steps.slice(0,He+1),Pt=zt.length>0?zt[zt.length-1].delayMs:0;if(Te(ye,zt),Re(()=>{te(ye,"idle"),X({sessionId:ye,eventType:"status",timestamp:new Date().toISOString(),content:"idle"})},Pt+S0,ye),Ke.resumeSteps){const Tt=[...Ke.resumeSteps];Ae.current.set(ye,Tt);const ls=Tt.reduce((Vn,xa)=>Math.max(Vn,xa.delayMs),0);ce.current.set(ye,{taskId:q,delayAfterResume:ls+200})}}else{const He=Ke.steps.length>0?Ke.steps[Ke.steps.length-1].delayMs:0;Te(ye,Ke.steps);const zt=(nt=Ke.steps[Ke.steps.length-1])==null?void 0:nt.event.content;Re(()=>{zt==="completed"?_(Pt=>Pt.map(Tt=>Tt.id===q&&Tt.status==="working"?{...Tt,status:"paused"}:Tt)):zt==="failed"&&_(Pt=>Pt.map(Tt=>Tt.id===q&&Tt.status==="working"?{...Tt,status:"failed"}:Tt))},He+100,ye)}},[fe,pe,Te,Re,te,X]),Kt=y.useCallback((q,ne)=>{console.log("[MockGrackle] sendInput",{sessionId:q,text:ne}),X({sessionId:q,eventType:"output",timestamp:new Date().toISOString(),content:`User input: ${ne}`}),te(q,"running"),X({sessionId:q,eventType:"status",timestamp:new Date().toISOString(),content:"running"});const oe=Ae.current.get(q);if(oe)Ae.current.delete(q),Te(q,oe);else{const ue=[{delayMs:500,event:{eventType:"output",timestamp:new Date().toISOString(),content:"I received your input, continuing..."}},{delayMs:1500,event:{eventType:"status",timestamp:new Date().toISOString(),content:"completed"}}];Te(q,ue)}const le=ce.current.get(q);le&&(ce.current.delete(q),Re(()=>{_(ue=>ue.map(qe=>qe.id===le.taskId&&qe.status==="working"?{...qe,status:"paused"}:qe))},le.delayAfterResume,q))},[X,te,Te,Re]),lo=y.useCallback(q=>{console.log("[MockGrackle] completeTask",q),_(ne=>ne.map(oe=>oe.id===q?{...oe,status:"complete"}:oe))},[]),co=y.useCallback(q=>{console.log("[MockGrackle] resumeTask",q)},[]),uo=y.useCallback((q,ne,oe,le,ue)=>{console.log("[MockGrackle] updateTask",{taskId:q,title:ne}),_(qe=>qe.map(ye=>ye.id===q?{...ye,title:ne.trim()||ye.title,description:oe,dependsOn:le,...ue!==void 0?{defaultPersonaId:ue}:{}}:ye))},[]),_a=y.useCallback(q=>{console.log("[MockGrackle] deleteTask",q),_(ne=>ne.filter(oe=>oe.id!==q))},[]),Or=y.useCallback(q=>{console.log("[MockGrackle] loadFindings",q),T(_0.filter(ne=>ne.workspaceId===q))},[]),fo=y.useCallback((q,ne,oe,le,ue)=>{console.log("[MockGrackle] postFinding",{workspaceId:q,title:ne});const qe={id:fe("find"),workspaceId:q,taskId:"",sessionId:"",category:le||"general",title:ne,content:oe,tags:ue||[],createdAt:new Date().toISOString()};T(ye=>[...ye,qe])},[fe]),Ir=y.useCallback(()=>{console.log("[MockGrackle] loadEnvironments")},[]),Br=y.useCallback((q,ne,oe)=>{console.log("[MockGrackle] addEnvironment",{displayName:q,adapterType:ne,adapterConfig:oe})},[]),Us=y.useCallback((q,ne)=>{console.log("[MockGrackle] updateEnvironment",{environmentId:q,...ne}),i(oe=>oe.map(le=>le.id!==q?le:{...le,...ne.displayName!==void 0?{displayName:ne.displayName}:{},...ne.adapterConfig!==void 0?{adapterConfig:JSON.stringify(ne.adapterConfig)}:{}}))},[]),Yt=y.useCallback(()=>{console.log("[MockGrackle] loadTokens")},[]),Pn=y.useCallback((q,ne,oe,le,ue)=>{console.log("[MockGrackle] setToken",{name:q,tokenType:oe}),j(qe=>[...qe.filter(Oe=>Oe.name!==q),{name:q,tokenType:oe,envVar:le,filePath:ue,expiresAt:""}])},[]),Jt=y.useCallback(q=>{console.log("[MockGrackle] deleteToken",q),j(ne=>ne.filter(oe=>oe.name!==q))},[]),Lr=y.useCallback(q=>{console.log("[MockGrackle] updateCredentialProviders",q),E(q)},[]);y.useEffect(()=>()=>{ze.current.forEach(clearTimeout),ze.current.clear()},[]);const qc=y.useMemo(()=>({connected:!0,send:()=>{},environments:s,sessions:o,events:u,eventsDropped:0,lastSpawnedId:m,workspaces:g,tasks:b,findings:S,tokens:N,credentialProviders:w,spawn:un,sendInput:Kt,kill:Ze,stopGraceful:Kn,refresh:Yn,loadSessionEvents:zn,clearEvents:Jn,loadWorkspaces:()=>{console.log("[MockGrackle] loadWorkspaces")},createWorkspace:Tn,archiveWorkspace:Ls,updateWorkspace:(q,ne)=>{console.log("[MockGrackle] updateWorkspace",{workspaceId:q,...ne}),v(oe=>oe.map(le=>le.id!==q?le:{...le,...ne.name!==void 0?{name:ne.name}:{},...ne.description!==void 0?{description:ne.description}:{},...ne.repoUrl!==void 0?{repoUrl:ne.repoUrl}:{},...ne.environmentId!==void 0?{environmentId:ne.environmentId}:{},...ne.workingDirectory!==void 0?{workingDirectory:ne.workingDirectory}:{},...ne.useWorktrees!==void 0?{useWorktrees:ne.useWorktrees}:{},...ne.defaultPersonaId!==void 0?{defaultPersonaId:ne.defaultPersonaId}:{},updatedAt:new Date().toISOString()}))},loadTasks:dn,loadAllTasks:()=>{console.log("[MockGrackle] loadAllTasks")},createTask:Me,startTask:Mt,stopTask:q=>{console.log("[MockGrackle] stopTask",{taskId:q}),lo(q)},completeTask:lo,resumeTask:co,updateTask:uo,deleteTask:_a,loadFindings:Or,postFinding:fo,loadEnvironments:Ir,addEnvironment:Br,updateEnvironment:Us,loadTokens:Yt,setToken:Pn,deleteToken:Jt,updateCredentialProviders:Lr,provisionStatus:{},provisionEnvironment:(q,ne)=>{},stopEnvironment:()=>{},removeEnvironment:()=>{},codespaces:[],codespaceError:"",codespaceListError:"",codespaceCreating:!1,listCodespaces:()=>{},createCodespace:()=>{},workspaceCreating:!1,taskStartingId:void 0,personas:A,createPersona:async(q,ne,oe,le,ue,qe,ye,Oe,Ke)=>{console.log("[MockGrackle] createPersona",{name:q});const nt={id:`mock-persona-${Date.now()}`,name:q,description:ne,systemPrompt:oe,toolConfig:"{}",runtime:le??"claude-code",model:ue||"",maxTurns:qe||0,mcpServers:"[]",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),type:ye||"agent",script:Oe||"",allowedMcpTools:Ke||[]};return O(He=>[...He,nt]),nt},updatePersona:async(q,ne,oe,le,ue,qe,ye,Oe,Ke,nt)=>{console.log("[MockGrackle] updatePersona",{personaId:q,name:ne});const He=A.find(Tt=>Tt.id===q);if(!He)throw new Error(`Persona not found: ${q}`);const zt=new Date().toISOString(),Pt={...He,...ne!==void 0?{name:ne}:{},...oe!==void 0?{description:oe}:{},...le!==void 0?{systemPrompt:le}:{},...ue!==void 0?{runtime:ue}:{},...qe!==void 0?{model:qe}:{},...ye!==void 0?{maxTurns:ye}:{},...Oe!==void 0?{type:Oe}:{},...Ke!==void 0?{script:Ke}:{},...nt!==void 0?{allowedMcpTools:nt}:{},updatedAt:zt};return O(Tt=>Tt.map(ls=>ls.id===q?Pt:ls)),Pt},deletePersona:async q=>{console.log("[MockGrackle] deletePersona",q),O(ne=>ne.filter(oe=>oe.id!==q))},taskSessions:C,loadTaskSessions:q=>{console.log("[MockGrackle] loadTaskSessions",q)},appDefaultPersonaId:M,setAppDefaultPersonaId:async q=>{console.log("[MockGrackle] setAppDefaultPersonaId",q),G(q)},onboardingCompleted:!0,completeOnboarding:()=>{console.log("[MockGrackle] completeOnboarding")},usageCache:{"workspace:proj-alpha":{inputTokens:214500,outputTokens:44850,costUsd:1.12,sessionCount:4},"workspace:proj-beta":{inputTokens:86700,outputTokens:23800,costUsd:.48,sessionCount:3},"task:task-001":{inputTokens:126800,outputTokens:20850,costUsd:.63,sessionCount:2},"task:task-006":{inputTokens:18900,outputTokens:4500,costUsd:.1,sessionCount:1},"task_tree:task-001":{inputTokens:126800,outputTokens:20850,costUsd:.63,sessionCount:2},"task_tree:task-006":{inputTokens:18900,outputTokens:4500,costUsd:.1,sessionCount:1}},loadUsage:(q,ne)=>{console.log(`[MockGrackle] loadUsage(${q}, ${ne})`)},knowledge:{graphData:{nodes:U,links:Z},selectedNode:ie,loading:!1,selectedId:K,searchQuery:I,search:q=>{if(console.log("[MockGrackle] knowledge.search",q),!q.trim()){$(q);return}$(q);const ne=Q.current,oe=ne?ns.filter(ye=>!ye.workspaceId||ye.workspaceId===ne):ns,le=q.toLowerCase(),ue=oe.filter(ye=>{var Oe,Ke,nt;return ye.label.toLowerCase().includes(le)||((Oe=ye.content)==null?void 0:Oe.toLowerCase().includes(le))||((Ke=ye.tags)==null?void 0:Ke.some(He=>He.toLowerCase().includes(le)))||((nt=ye.category)==null?void 0:nt.toLowerCase().includes(le))});V(ue);const qe=new Set(ue.map(ye=>ye.id));ee(ca.filter(ye=>qe.has(ye.source)&&qe.has(ye.target))),re(void 0),be(void 0)},clearSearch:()=>{console.log("[MockGrackle] knowledge.clearSearch"),$("");const q=Q.current,ne=q?ns.filter(le=>!le.workspaceId||le.workspaceId===q):ns;V(ne);const oe=new Set(ne.map(le=>le.id));ee(ca.filter(le=>oe.has(le.source)&&oe.has(le.target)))},selectNode:q=>{console.log("[MockGrackle] knowledge.selectNode",q),re(q);const ne=q in b0?b0[q]:void 0;if(ne)be(ne);else{const oe=ns.find(le=>le.id===q);if(oe){const le=ca.filter(ue=>ue.source===q||ue.target===q).map(ue=>({fromId:ue.source,toId:ue.target,type:ue.type}));be({node:oe,edges:le})}}},clearSelection:()=>{console.log("[MockGrackle] knowledge.clearSelection"),re(void 0),be(void 0)},expandNode:q=>{console.log("[MockGrackle] knowledge.expandNode",q),V(ne=>{const oe=new Set(ne.map(Oe=>Oe.id)),le=ca.filter(Oe=>Oe.source===q||Oe.target===q),ue=new Set;for(const Oe of le)oe.has(Oe.source)||ue.add(Oe.source),oe.has(Oe.target)||ue.add(Oe.target);if(ue.size===0)return ne;const qe=ns.filter(Oe=>ue.has(Oe.id)),ye=new Set([...oe,...ue]);return ee(Oe=>{const Ke=new Set(Oe.map(He=>`${He.source}|${He.target}|${He.type}`)),nt=ca.filter(He=>ye.has(He.source)&&ye.has(He.target)&&!Ke.has(`${He.source}|${He.target}|${He.type}`));return nt.length>0?[...Oe,...nt]:Oe}),[...ne,...qe]})},loadRecent:q=>{if(console.log("[MockGrackle] knowledge.loadRecent",q),Q.current=q,q){const ne=ns.filter(le=>!le.workspaceId||le.workspaceId===q);V(ne);const oe=new Set(ne.map(le=>le.id));ee(ca.filter(le=>oe.has(le.source)&&oe.has(le.target)))}else V(ns),ee(ca);$("")},handleEvent:()=>!1}}),[s,o,u,m,g,b,S,N,w,A,C,M,U,Z,ie,K,I,un,Kt,Ze,Kn,Yn,zn,Jn,Tn,Ls,dn,Me,Mt,lo,co,uo,_a,Or,fo,Ir,Br,Us,Yt,Pn,Jt,Lr]);return l.jsx(_p.Provider,{value:qc,children:n})}const Bb=y.createContext(void 0),Xw=4e3;function Qw({children:n}){const[s,i]=y.useState([]),o=y.useRef(0),c=y.useCallback(d=>{i(m=>m.filter(h=>h.id!==d))},[]),u=y.useCallback((d,m="info",h=Xw)=>{const g=`toast-${++o.current}`;i(v=>[...v,{id:g,message:d,variant:m,duration:h}])},[]);return l.jsx(Bb.Provider,{value:{toasts:s,showToast:u,dismissToast:c},children:n})}function Bs(){const n=y.useContext(Bb);if(!n)throw new Error("useToast must be used within ToastProvider");return n}const Oc=[{id:"grackle",label:"Grackle",description:"The default Grackle theme — iridescent purple on clean dark.",swatches:["#0e1218","#8b5cf6","#60a5fa","#e5e7eb","#34d399"],variantLightId:"grackle-light",variantDarkId:"grackle-dark"},{id:"grackle-light",label:"Grackle Light",description:"Light Grackle variant.",hidden:!0},{id:"grackle-dark",label:"Grackle Dark",description:"Dark Grackle variant.",hidden:!0},{id:"glass",label:"Glassmorphism",description:"Dark frosted-glass aesthetic with backdrop blur effects.",swatches:["#0a0c14","#4ecca3","#70a1ff","#e2e8f0","#a855f7"]},{id:"matrix",label:"Matrix",description:"Phosphor-green CRT terminal with scanlines and glow.",swatches:["#050505","#00ff41","#00bfff","#33ff77","#ffb000"]},{id:"brutalist",label:"Neubrutalism",description:"Thick borders, raw colors, bold type — ugly on purpose.",swatches:["#f5f0e8","#ff5757","#5ce1e6","#1a1a1a","#ffde59"],variantLightId:"brutalist-light",variantDarkId:"brutalist-dark"},{id:"brutalist-light",label:"Neubrutalism Light",description:"Light neubrutalism variant.",hidden:!0},{id:"brutalist-dark",label:"Neubrutalism Dark",description:"Dark neubrutalism variant.",hidden:!0},{id:"monokai",label:"Monokai",description:"Classic warm editor palette — pink, green, and purple.",swatches:["#272822","#f92672","#a6e22e","#f8f8f2","#ae81ff"],variantLightId:"monokai-light",variantDarkId:"monokai-dark"},{id:"monokai-dark",label:"Monokai Dark",description:"Dark Monokai variant.",hidden:!0},{id:"monokai-light",label:"Monokai Light",description:"Light Monokai variant.",hidden:!0},{id:"ubuntu",label:"Ubuntu",description:"Aubergine terminal with the GNOME Tango palette.",swatches:["#300a24","#8ae234","#ef2929","#eeeeec","#fce94f"]},{id:"sandstone",label:"Sandstone",description:"Warm terracotta accent on dark brown, in the style of Claude Code.",swatches:["#1a1815","#C15F3C","#6b8afd","#e8e6e3","#a78bfa"]},{id:"verdigris",label:"Verdigris",description:"Teal accent on charcoal, in the style of ChatGPT.",swatches:["#141414","#00a67e","#3b82f6","#ececec","#ab68ff"]},{id:"primer",label:"Primer",description:"Blue accent on ink-dark grey, in the style of GitHub.",swatches:["#0d1117","#58a6ff","#3fb950","#c9d1d9","#bc8cff"]}],Lb=new Set(Oc.map(n=>n.id)),T0="grackle";function Pf(n){return Oc.find(s=>s.id===n)}const Vf="grackle-theme",Ub="grackle-prefer-system",zb="(prefers-color-scheme: dark)";let cr=[],fc;function uf(){fc=void 0;for(const n of cr)n()}function qf(){return typeof window>"u"?!1:window.matchMedia(zb).matches}function mr(){if(typeof localStorage>"u")return T0;try{const n=localStorage.getItem(Vf);if(n!==null&&Lb.has(n))return n}catch{}return T0}function yc(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(Ub)==="true"}catch{return!1}}function Hf(n){return Oc.find(s=>s.variantLightId===n||s.variantDarkId===n)}function Pb(n,s){const i=Pf(n);if(i!=null&&i.variantDarkId)return s&&i.variantLightId?qf()?i.variantDarkId:i.variantLightId:i.variantDarkId;if(i!=null&&i.hidden&&s){const o=Hf(n);if(o!=null&&o.variantLightId&&o.variantDarkId)return qf()?o.variantDarkId:o.variantLightId}return n}function Hi(n,s,i=!1){i&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=Pb(n,s),i&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&Hi(mr(),yc());function e2(){return fc===void 0&&(fc={themeId:mr(),systemDark:qf(),preferSystem:yc()}),fc}function t2(n){return cr=[...cr,n],()=>{cr=cr.filter(s=>s!==n)}}function n2(){const n=y.useSyncExternalStore(t2,e2),{themeId:s,preferSystem:i}=n,o=Pb(s,i),c=y.useCallback(d=>{if(Lb.has(d)){try{localStorage.setItem(Vf,d)}catch{}Hi(d,yc(),!0),uf()}},[]),u=y.useCallback(d=>{try{localStorage.setItem(Ub,d?"true":"false")}catch{}if(d){const m=mr(),h=Pf(m);if(h!=null&&h.hidden){const g=Hf(m);if(g)try{localStorage.setItem(Vf,g.id)}catch{}}}Hi(mr(),d,!0),uf()},[]);return y.useEffect(()=>{Hi(s,i)},[s,i]),y.useEffect(()=>{if(typeof window>"u")return;const d=window.matchMedia(zb),m=()=>{const h=mr(),g=yc();if(g){const v=Pf(h);if(v!=null&&v.variantDarkId&&v.variantLightId&&Hi(h,g),v!=null&&v.hidden){const b=Hf(h);b!=null&&b.variantDarkId&&b.variantLightId&&Hi(h,g)}}uf()};return d.addEventListener("change",m),()=>{d.removeEventListener("change",m)}},[]),{themeId:s,setTheme:c,resolvedThemeId:o,preferSystem:i,setPreferSystem:u}}const Vb=y.createContext(void 0);function s2({children:n}){const s=n2();return l.jsx(Vb.Provider,{value:s,children:n})}function qb(){const n=y.useContext(Vb);if(!n)throw new Error("useThemeContext must be used within ThemeProvider");return n}const a2="_container_1mq5u_1",i2="_hamburger_1mq5u_33",o2="_brand_1mq5u_49",r2="_brandLogo_1mq5u_68",l2="_info_1mq5u_75",c2="_connectionLabel_1mq5u_90",u2="_connectionDot_1mq5u_103",d2="_connected_1mq5u_106",f2="_disconnected_1mq5u_110",js={container:a2,hamburger:i2,brand:o2,brandLogo:r2,info:l2,connectionLabel:c2,connectionDot:u2,connected:d2,disconnected:f2};function p2({connected:n,environments:s,sessions:i,onToggleSidebar:o,sidebarOpen:c}){const u=St(),d=s.length,m=s.filter(g=>g.status==="connected").length,h=i.filter(g=>["running","idle"].includes(g.status)).length;return l.jsxs("div",{className:js.container,children:[o&&l.jsx("button",{type:"button",className:js.hamburger,onClick:o,"aria-label":"Toggle sidebar","aria-expanded":c,children:"☰"}),l.jsxs("button",{type:"button",className:js.brand,onClick:()=>u(Ya),title:"Home",children:[l.jsx("img",{src:"/icon-192x192.png",alt:"",className:js.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]}),l.jsxs("div",{className:js.info,children:[l.jsxs("span",{"aria-label":n?"Connected":"Disconnected",children:[l.jsx("span",{className:`${js.connectionDot} ${n?js.connected:js.disconnected}`,"aria-hidden":"true",children:"●"})," ",l.jsx("span",{className:js.connectionLabel,"aria-hidden":"true",children:n?"Connected":"Disconnected"})]}),l.jsxs("span",{children:[m,"/",d," env",d!==1?"s":""]}),l.jsxs("span",{children:[h," active"]})]})]})}const m2="_nav_13gkc_1",h2="_tab_13gkc_35",g2="_tabIcon_13gkc_68",v2="_tabLabel_13gkc_79",y2="_tabActive_13gkc_84",ir={nav:m2,tab:h2,tabIcon:g2,tabLabel:v2,tabActive:y2},za=[{view:"dashboard",label:"Dashboard",icon:"🏠",route:Ya,testId:"sidebar-tab-dashboard"},{view:"chat",label:"Chat",icon:"💬",route:pw,testId:"sidebar-tab-chat"},{view:"tasks",label:"Tasks",icon:"📋",route:mw,testId:"sidebar-tab-tasks"},{view:"environments",label:"Environments",icon:"🖥️",route:Xi,testId:"sidebar-tab-environments"},{view:"knowledge",label:"Knowledge",icon:"🧠",route:Db,testId:"sidebar-tab-knowledge"},{view:"settings",label:"Settings",icon:"⚙️",route:cw,testId:"sidebar-tab-settings"}];function b2(n){return n===Ya||n==="/"?"dashboard":n.startsWith("/chat")||n.startsWith("/sessions")?"chat":n.startsWith("/workspaces")||n.startsWith("/environments")?"environments":n.startsWith(Db)?"knowledge":n.startsWith(Ji)?"settings":"tasks"}function _2(){const n=It(),s=St(),i=y.useRef(null),o=b2(n.pathname),c=y.useCallback(d=>{s(d.route)},[s]),u=y.useCallback(d=>{var b,_;const m=(b=i.current)==null?void 0:b.querySelectorAll('[role="tab"]');if(!m)return;const h=Array.from(m).findIndex(S=>S===document.activeElement),g=h>=0?h:za.findIndex(S=>S.view===o);let v=g;if(d.key==="ArrowRight"||d.key==="j"||d.key==="J")d.preventDefault(),v=(g+1)%za.length;else if(d.key==="ArrowLeft"||d.key==="k"||d.key==="K")d.preventDefault(),v=(g-1+za.length)%za.length;else if(d.key==="Home")d.preventDefault(),v=0;else if(d.key==="End")d.preventDefault(),v=za.length-1;else return;s(za[v].route),(_=m[v])==null||_.focus()},[o,s]);return l.jsx("nav",{className:ir.nav,ref:i,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:u,"data-testid":"sidebar-nav",children:za.map(d=>{const m=d.view===o;return l.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${ir.tab} ${m?ir.tabActive:""}`,onClick:()=>c(d),"data-testid":d.testId,title:d.label,"aria-label":d.label,children:[l.jsx("span",{className:ir.tabIcon,"aria-hidden":"true",children:d.icon}),l.jsx("span",{className:ir.tabLabel,children:d.label})]},d.view)})})}const Hb=y.createContext(void 0),Gb=y.createContext(void 0);function x2({children:n}){const[s,i]=y.useState(void 0),o=y.useCallback(c=>{i(c)},[]);return l.jsx(Gb.Provider,{value:o,children:l.jsx(Hb.Provider,{value:s,children:n})})}function $b(){return y.useContext(Hb)}function S2(){const n=y.useContext(Gb);if(n===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return n}const T2="_container_pi6ii_1",k2="_content_pi6ii_66",k0={container:T2,content:k2},w2=320,Fb=220,Zb=600,Kb="grackle-sidebar-width";function N2(){try{const n=localStorage.getItem(Kb);if(n!==null){const s=Number(n);if(Number.isFinite(s)&&s>=Fb&&s<=Zb)return s}}catch{}return w2}function j2(n){try{localStorage.setItem(Kb,String(n))}catch{}}function C2(){const[n]=y.useState(N2),s=y.useRef(null),i=$b();if(y.useEffect(()=>{const o=s.current;if(!o)return;const c=new ResizeObserver(u=>{for(const d of u){const m=d.borderBoxSize[0];if(m){const h=Math.round(m.inlineSize);h>=Fb&&h<=Zb&&j2(h)}}});return c.observe(o),()=>{c.disconnect()}},[]),i!==void 0)return l.jsx("div",{className:k0.container,ref:s,"data-testid":"sidebar",style:{width:n},children:l.jsx("div",{className:k0.content,children:i})})}function Ic(n){const s=S2();y.useLayoutEffect(()=>(s(n),()=>{s(void 0)}),[n,s])}const xp=y.createContext({});function Sp(n){const s=y.useRef(null);return s.current===null&&(s.current=n()),s.current}const Bc=y.createContext(null),Tp=y.createContext({transformPagePoint:n=>n,isStatic:!1,reducedMotion:"never"});class E2 extends y.Component{getSnapshotBeforeUpdate(s){const i=this.props.childRef.current;if(i&&s.isPresent&&!this.props.isPresent){const o=this.props.sizeRef.current;o.height=i.offsetHeight||0,o.width=i.offsetWidth||0,o.top=i.offsetTop,o.left=i.offsetLeft}return null}componentDidUpdate(){}render(){return this.props.children}}function A2({children:n,isPresent:s}){const i=y.useId(),o=y.useRef(null),c=y.useRef({width:0,height:0,top:0,left:0}),{nonce:u}=y.useContext(Tp);return y.useInsertionEffect(()=>{const{width:d,height:m,top:h,left:g}=c.current;if(s||!o.current||!d||!m)return;o.current.dataset.motionPopId=i;const v=document.createElement("style");return u&&(v.nonce=u),document.head.appendChild(v),v.sheet&&v.sheet.insertRule(`
|
|
465
465
|
[data-motion-pop-id="${i}"] {
|
|
466
466
|
position: absolute !important;
|
|
467
467
|
width: ${d}px !important;
|
|
@@ -469,7 +469,7 @@ src/utils/token-refresh.ts:28: const remaining = decoded.exp - Date.now() / 1
|
|
|
469
469
|
top: ${h}px !important;
|
|
470
470
|
left: ${g}px !important;
|
|
471
471
|
}
|
|
472
|
-
`),()=>{document.head.removeChild(v)}},[s]),l.jsx(Ew,{isPresent:s,childRef:o,sizeRef:c,children:y.cloneElement(n,{ref:o})})}const Dw=({children:n,initial:s,isPresent:i,onExitComplete:o,custom:c,presenceAffectsLayout:u,mode:d})=>{const m=Sp(Rw),h=y.useId(),g=y.useCallback(b=>{m.set(b,!0);for(const _ of m.values())if(!_)return;o&&o()},[m,o]),v=y.useMemo(()=>({id:h,initial:s,isPresent:i,custom:c,onExitComplete:g,register:b=>(m.set(b,!1),()=>m.delete(b))}),u?[Math.random(),g]:[i,g]);return y.useMemo(()=>{m.forEach((b,_)=>m.set(_,!1))},[i]),y.useEffect(()=>{!i&&!m.size&&o&&o()},[i]),d==="popLayout"&&(n=l.jsx(Aw,{isPresent:i,children:n})),l.jsx(Bc.Provider,{value:v,children:n})};function Rw(){return new Map}function Yb(n=!0){const s=y.useContext(Bc);if(s===null)return[!0,null];const{isPresent:i,onExitComplete:o,register:c}=s,u=y.useId();y.useEffect(()=>{n&&c(u)},[n]);const d=y.useCallback(()=>n&&o&&o(u),[u,o,n]);return!i&&o?[!1,d]:[!0]}const tc=n=>n.key||"";function w0(n){const s=[];return y.Children.forEach(n,i=>{y.isValidElement(i)&&s.push(i)}),s}const kp=typeof window<"u",Jb=kp?y.useLayoutEffect:y.useEffect,rs=({children:n,custom:s,initial:i=!0,onExitComplete:o,presenceAffectsLayout:c=!0,mode:u="sync",propagate:d=!1})=>{const[m,h]=Yb(d),g=y.useMemo(()=>w0(n),[n]),v=d&&!m?[]:g.map(tc),b=y.useRef(!0),_=y.useRef(g),S=Sp(()=>new Map),[T,N]=y.useState(g),[j,w]=y.useState(g);Jb(()=>{b.current=!1,_.current=g;for(let O=0;O<j.length;O++){const C=tc(j[O]);v.includes(C)?S.delete(C):S.get(C)!==!0&&S.set(C,!1)}},[j,v.length,v.join("-")]);const E=[];if(g!==T){let O=[...g];for(let C=0;C<j.length;C++){const M=j[C],G=tc(M);v.includes(G)||(O.splice(C,0,M),E.push(M))}u==="wait"&&E.length&&(O=E),w(w0(O)),N(g);return}const{forceRender:A}=y.useContext(xp);return l.jsx(l.Fragment,{children:j.map(O=>{const C=tc(O),M=d&&!m?!1:g===j||v.includes(C),G=()=>{if(S.has(C))S.set(C,!0);else return;let U=!0;S.forEach(V=>{V||(U=!1)}),U&&(A==null||A(),w(_.current),d&&(h==null||h()),o&&o())};return l.jsx(Dw,{isPresent:M,initial:!b.current||i?void 0:!1,custom:M?void 0:s,presenceAffectsLayout:c,mode:u,onExitComplete:M?void 0:G,children:O},C)})})},_n=n=>n;let Wb=_n;const Mw={useManualTiming:!1};function Ow(n){let s=new Set,i=new Set,o=!1,c=!1;const u=new WeakSet;let d={delta:0,timestamp:0,isProcessing:!1};function m(g){u.has(g)&&(h.schedule(g),n()),g(d)}const h={schedule:(g,v=!1,b=!1)=>{const S=b&&o?s:i;return v&&u.add(g),S.has(g)||S.add(g),g},cancel:g=>{i.delete(g),u.delete(g)},process:g=>{if(d=g,o){c=!0;return}o=!0,[s,i]=[i,s],s.forEach(m),s.clear(),o=!1,c&&(c=!1,h.process(g))}};return h}const nc=["read","resolveKeyframes","update","preRender","render","postRender"],Iw=40;function Xb(n,s){let i=!1,o=!0;const c={delta:0,timestamp:0,isProcessing:!1},u=()=>i=!0,d=nc.reduce((w,E)=>(w[E]=Ow(u),w),{}),{read:m,resolveKeyframes:h,update:g,preRender:v,render:b,postRender:_}=d,S=()=>{const w=performance.now();i=!1,c.delta=o?1e3/60:Math.max(Math.min(w-c.timestamp,Iw),1),c.timestamp=w,c.isProcessing=!0,m.process(c),h.process(c),g.process(c),v.process(c),b.process(c),_.process(c),c.isProcessing=!1,i&&s&&(o=!1,n(S))},T=()=>{i=!0,o=!0,c.isProcessing||n(S)};return{schedule:nc.reduce((w,E)=>{const A=d[E];return w[E]=(O,C=!1,M=!1)=>(i||T(),A.schedule(O,C,M)),w},{}),cancel:w=>{for(let E=0;E<nc.length;E++)d[nc[E]].cancel(w)},state:c,steps:d}}const{schedule:ft,cancel:ma,state:Ft,steps:df}=Xb(typeof requestAnimationFrame<"u"?requestAnimationFrame:_n,!0),Qb=y.createContext({strict:!1}),N0={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},eo={};for(const n in N0)eo[n]={isEnabled:s=>N0[n].some(i=>!!s[i])};function Bw(n){for(const s in n)eo[s]={...eo[s],...n[s]}}const Lw=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function bc(n){return n.startsWith("while")||n.startsWith("drag")&&n!=="draggable"||n.startsWith("layout")||n.startsWith("onTap")||n.startsWith("onPan")||n.startsWith("onLayout")||Lw.has(n)}let e_=n=>!bc(n);function Uw(n){n&&(e_=s=>s.startsWith("on")?!bc(s):n(s))}try{Uw(require("@emotion/is-prop-valid").default)}catch{}function zw(n,s,i){const o={};for(const c in n)c==="values"&&typeof n.values=="object"||(e_(c)||i===!0&&bc(c)||!s&&!bc(c)||n.draggable&&c.startsWith("onDrag"))&&(o[c]=n[c]);return o}function Pw(n){if(typeof Proxy>"u")return n;const s=new Map,i=(...o)=>n(...o);return new Proxy(i,{get:(o,c)=>c==="create"?n:(s.has(c)||s.set(c,n(c)),s.get(c))})}const Lc=y.createContext({});function Sr(n){return typeof n=="string"||Array.isArray(n)}function Uc(n){return n!==null&&typeof n=="object"&&typeof n.start=="function"}const wp=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Np=["initial",...wp];function zc(n){return Uc(n.animate)||Np.some(s=>Sr(n[s]))}function t_(n){return!!(zc(n)||n.variants)}function Vw(n,s){if(zc(n)){const{initial:i,animate:o}=n;return{initial:i===!1||Sr(i)?i:void 0,animate:Sr(o)?o:void 0}}return n.inherit!==!1?s:{}}function qw(n){const{initial:s,animate:i}=Vw(n,y.useContext(Lc));return y.useMemo(()=>({initial:s,animate:i}),[j0(s),j0(i)])}function j0(n){return Array.isArray(n)?n.join(" "):n}const Hw=Symbol.for("motionComponentSymbol");function Gi(n){return n&&typeof n=="object"&&Object.prototype.hasOwnProperty.call(n,"current")}function Gw(n,s,i){return y.useCallback(o=>{o&&n.onMount&&n.onMount(o),s&&(o?s.mount(o):s.unmount()),i&&(typeof i=="function"?i(o):Gi(i)&&(i.current=o))},[s])}const jp=n=>n.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),$w="framerAppearId",n_="data-"+jp($w),{schedule:Cp}=Xb(queueMicrotask,!1),s_=y.createContext({});function Fw(n,s,i,o,c){var u,d;const{visualElement:m}=y.useContext(Lc),h=y.useContext(Qb),g=y.useContext(Bc),v=y.useContext(Tp).reducedMotion,b=y.useRef(null);o=o||h.renderer,!b.current&&o&&(b.current=o(n,{visualState:s,parent:m,props:i,presenceContext:g,blockInitialAnimation:g?g.initial===!1:!1,reducedMotionConfig:v}));const _=b.current,S=y.useContext(s_);_&&!_.projection&&c&&(_.type==="html"||_.type==="svg")&&Zw(b.current,i,c,S);const T=y.useRef(!1);y.useInsertionEffect(()=>{_&&T.current&&_.update(i,g)});const N=i[n_],j=y.useRef(!!N&&!(!((u=window.MotionHandoffIsComplete)===null||u===void 0)&&u.call(window,N))&&((d=window.MotionHasOptimisedAnimation)===null||d===void 0?void 0:d.call(window,N)));return Jb(()=>{_&&(T.current=!0,window.MotionIsMounted=!0,_.updateFeatures(),Cp.render(_.render),j.current&&_.animationState&&_.animationState.animateChanges())}),y.useEffect(()=>{_&&(!j.current&&_.animationState&&_.animationState.animateChanges(),j.current&&(queueMicrotask(()=>{var w;(w=window.MotionHandoffMarkAsComplete)===null||w===void 0||w.call(window,N)}),j.current=!1))}),_}function Zw(n,s,i,o){const{layoutId:c,layout:u,drag:d,dragConstraints:m,layoutScroll:h,layoutRoot:g}=s;n.projection=new i(n.latestValues,s["data-framer-portal-id"]?void 0:a_(n.parent)),n.projection.setOptions({layoutId:c,layout:u,alwaysMeasureLayout:!!d||m&&Gi(m),visualElement:n,animationType:typeof u=="string"?u:"both",initialPromotionConfig:o,layoutScroll:h,layoutRoot:g})}function a_(n){if(n)return n.options.allowProjection!==!1?n.projection:a_(n.parent)}function Kw({preloadedFeatures:n,createVisualElement:s,useRender:i,useVisualState:o,Component:c}){var u,d;n&&Bw(n);function m(g,v){let b;const _={...y.useContext(Tp),...g,layoutId:Yw(g)},{isStatic:S}=_,T=qw(g),N=o(g,S);if(!S&&kp){Jw();const j=Ww(_);b=j.MeasureLayout,T.visualElement=Fw(c,N,_,s,j.ProjectionNode)}return l.jsxs(Lc.Provider,{value:T,children:[b&&T.visualElement?l.jsx(b,{visualElement:T.visualElement,..._}):null,i(c,g,Gw(N,T.visualElement,v),N,S,T.visualElement)]})}m.displayName=`motion.${typeof c=="string"?c:`create(${(d=(u=c.displayName)!==null&&u!==void 0?u:c.name)!==null&&d!==void 0?d:""})`}`;const h=y.forwardRef(m);return h[Hw]=c,h}function Yw({layoutId:n}){const s=y.useContext(xp).id;return s&&n!==void 0?s+"-"+n:n}function Jw(n,s){y.useContext(Qb).strict}function Ww(n){const{drag:s,layout:i}=eo;if(!s&&!i)return{};const o={...s,...i};return{MeasureLayout:s!=null&&s.isEnabled(n)||i!=null&&i.isEnabled(n)?o.MeasureLayout:void 0,ProjectionNode:o.ProjectionNode}}const Xw=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function Ep(n){return typeof n!="string"||n.includes("-")?!1:!!(Xw.indexOf(n)>-1||/[A-Z]/u.test(n))}function C0(n){const s=[{},{}];return n==null||n.values.forEach((i,o)=>{s[0][o]=i.get(),s[1][o]=i.getVelocity()}),s}function Ap(n,s,i,o){if(typeof s=="function"){const[c,u]=C0(o);s=s(i!==void 0?i:n.custom,c,u)}if(typeof s=="string"&&(s=n.variants&&n.variants[s]),typeof s=="function"){const[c,u]=C0(o);s=s(i!==void 0?i:n.custom,c,u)}return s}const Gf=n=>Array.isArray(n),Qw=n=>!!(n&&typeof n=="object"&&n.mix&&n.toValue),eN=n=>Gf(n)?n[n.length-1]||0:n,Xt=n=>!!(n&&n.getVelocity);function pc(n){const s=Xt(n)?n.get():n;return Qw(s)?s.toValue():s}function tN({scrapeMotionValuesFromProps:n,createRenderState:s,onUpdate:i},o,c,u){const d={latestValues:nN(o,c,u,n),renderState:s()};return i&&(d.onMount=m=>i({props:o,current:m,...d}),d.onUpdate=m=>i(m)),d}const i_=n=>(s,i)=>{const o=y.useContext(Lc),c=y.useContext(Bc),u=()=>tN(n,s,o,c);return i?u():Sp(u)};function nN(n,s,i,o){const c={},u=o(n,{});for(const _ in u)c[_]=pc(u[_]);let{initial:d,animate:m}=n;const h=zc(n),g=t_(n);s&&g&&!h&&n.inherit!==!1&&(d===void 0&&(d=s.initial),m===void 0&&(m=s.animate));let v=i?i.initial===!1:!1;v=v||d===!1;const b=v?m:d;if(b&&typeof b!="boolean"&&!Uc(b)){const _=Array.isArray(b)?b:[b];for(let S=0;S<_.length;S++){const T=Ap(n,_[S]);if(T){const{transitionEnd:N,transition:j,...w}=T;for(const E in w){let A=w[E];if(Array.isArray(A)){const O=v?A.length-1:0;A=A[O]}A!==null&&(c[E]=A)}for(const E in N)c[E]=N[E]}}}return c}const oo=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],ti=new Set(oo),o_=n=>s=>typeof s=="string"&&s.startsWith(n),r_=o_("--"),sN=o_("var(--"),Dp=n=>sN(n)?aN.test(n.split("/*")[0].trim()):!1,aN=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,l_=(n,s)=>s&&typeof n=="number"?s.transform(n):n,Is=(n,s,i)=>i>s?s:i<n?n:i,ro={test:n=>typeof n=="number",parse:parseFloat,transform:n=>n},Tr={...ro,transform:n=>Is(0,1,n)},sc={...ro,default:1},Ar=n=>({test:s=>typeof s=="string"&&s.endsWith(n)&&s.split(" ").length===1,parse:parseFloat,transform:s=>`${s}${n}`}),pa=Ar("deg"),as=Ar("%"),ke=Ar("px"),iN=Ar("vh"),oN=Ar("vw"),E0={...as,parse:n=>as.parse(n)/100,transform:n=>as.transform(n*100)},rN={borderWidth:ke,borderTopWidth:ke,borderRightWidth:ke,borderBottomWidth:ke,borderLeftWidth:ke,borderRadius:ke,radius:ke,borderTopLeftRadius:ke,borderTopRightRadius:ke,borderBottomRightRadius:ke,borderBottomLeftRadius:ke,width:ke,maxWidth:ke,height:ke,maxHeight:ke,top:ke,right:ke,bottom:ke,left:ke,padding:ke,paddingTop:ke,paddingRight:ke,paddingBottom:ke,paddingLeft:ke,margin:ke,marginTop:ke,marginRight:ke,marginBottom:ke,marginLeft:ke,backgroundPositionX:ke,backgroundPositionY:ke},lN={rotate:pa,rotateX:pa,rotateY:pa,rotateZ:pa,scale:sc,scaleX:sc,scaleY:sc,scaleZ:sc,skew:pa,skewX:pa,skewY:pa,distance:ke,translateX:ke,translateY:ke,translateZ:ke,x:ke,y:ke,z:ke,perspective:ke,transformPerspective:ke,opacity:Tr,originX:E0,originY:E0,originZ:ke},A0={...ro,transform:Math.round},Rp={...rN,...lN,zIndex:A0,size:ke,fillOpacity:Tr,strokeOpacity:Tr,numOctaves:A0},cN={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},uN=oo.length;function dN(n,s,i){let o="",c=!0;for(let u=0;u<uN;u++){const d=oo[u],m=n[d];if(m===void 0)continue;let h=!0;if(typeof m=="number"?h=m===(d.startsWith("scale")?1:0):h=parseFloat(m)===0,!h||i){const g=l_(m,Rp[d]);if(!h){c=!1;const v=cN[d]||d;o+=`${v}(${g}) `}i&&(s[d]=g)}}return o=o.trim(),i?o=i(s,c?"":o):c&&(o="none"),o}function Mp(n,s,i){const{style:o,vars:c,transformOrigin:u}=n;let d=!1,m=!1;for(const h in s){const g=s[h];if(ti.has(h)){d=!0;continue}else if(r_(h)){c[h]=g;continue}else{const v=l_(g,Rp[h]);h.startsWith("origin")?(m=!0,u[h]=v):o[h]=v}}if(s.transform||(d||i?o.transform=dN(s,n.transform,i):o.transform&&(o.transform="none")),m){const{originX:h="50%",originY:g="50%",originZ:v=0}=u;o.transformOrigin=`${h} ${g} ${v}`}}const fN={offset:"stroke-dashoffset",array:"stroke-dasharray"},pN={offset:"strokeDashoffset",array:"strokeDasharray"};function mN(n,s,i=1,o=0,c=!0){n.pathLength=1;const u=c?fN:pN;n[u.offset]=ke.transform(-o);const d=ke.transform(s),m=ke.transform(i);n[u.array]=`${d} ${m}`}function D0(n,s,i){return typeof n=="string"?n:ke.transform(s+i*n)}function hN(n,s,i){const o=D0(s,n.x,n.width),c=D0(i,n.y,n.height);return`${o} ${c}`}function Op(n,{attrX:s,attrY:i,attrScale:o,originX:c,originY:u,pathLength:d,pathSpacing:m=1,pathOffset:h=0,...g},v,b){if(Mp(n,g,b),v){n.style.viewBox&&(n.attrs.viewBox=n.style.viewBox);return}n.attrs=n.style,n.style={};const{attrs:_,style:S,dimensions:T}=n;_.transform&&(T&&(S.transform=_.transform),delete _.transform),T&&(c!==void 0||u!==void 0||S.transform)&&(S.transformOrigin=hN(T,c!==void 0?c:.5,u!==void 0?u:.5)),s!==void 0&&(_.x=s),i!==void 0&&(_.y=i),o!==void 0&&(_.scale=o),d!==void 0&&mN(_,d,m,h,!1)}const Ip=()=>({style:{},transform:{},transformOrigin:{},vars:{}}),c_=()=>({...Ip(),attrs:{}}),Bp=n=>typeof n=="string"&&n.toLowerCase()==="svg";function u_(n,{style:s,vars:i},o,c){Object.assign(n.style,s,c&&c.getProjectionStyles(o));for(const u in i)n.style.setProperty(u,i[u])}const d_=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function f_(n,s,i,o){u_(n,s,void 0,o);for(const c in s.attrs)n.setAttribute(d_.has(c)?c:jp(c),s.attrs[c])}const _c={};function gN(n){Object.assign(_c,n)}function p_(n,{layout:s,layoutId:i}){return ti.has(n)||n.startsWith("origin")||(s||i!==void 0)&&(!!_c[n]||n==="opacity")}function Lp(n,s,i){var o;const{style:c}=n,u={};for(const d in c)(Xt(c[d])||s.style&&Xt(s.style[d])||p_(d,n)||((o=i==null?void 0:i.getValue(d))===null||o===void 0?void 0:o.liveStyle)!==void 0)&&(u[d]=c[d]);return u}function m_(n,s,i){const o=Lp(n,s,i);for(const c in n)if(Xt(n[c])||Xt(s[c])){const u=oo.indexOf(c)!==-1?"attr"+c.charAt(0).toUpperCase()+c.substring(1):c;o[u]=n[c]}return o}function vN(n,s){try{s.dimensions=typeof n.getBBox=="function"?n.getBBox():n.getBoundingClientRect()}catch{s.dimensions={x:0,y:0,width:0,height:0}}}const R0=["x","y","width","height","cx","cy","r"],yN={useVisualState:i_({scrapeMotionValuesFromProps:m_,createRenderState:c_,onUpdate:({props:n,prevProps:s,current:i,renderState:o,latestValues:c})=>{if(!i)return;let u=!!n.drag;if(!u){for(const m in c)if(ti.has(m)){u=!0;break}}if(!u)return;let d=!s;if(s)for(let m=0;m<R0.length;m++){const h=R0[m];n[h]!==s[h]&&(d=!0)}d&&ft.read(()=>{vN(i,o),ft.render(()=>{Op(o,c,Bp(i.tagName),n.transformTemplate),f_(i,o)})})}})},bN={useVisualState:i_({scrapeMotionValuesFromProps:Lp,createRenderState:Ip})};function h_(n,s,i){for(const o in s)!Xt(s[o])&&!p_(o,i)&&(n[o]=s[o])}function _N({transformTemplate:n},s){return y.useMemo(()=>{const i=Ip();return Mp(i,s,n),Object.assign({},i.vars,i.style)},[s])}function xN(n,s){const i=n.style||{},o={};return h_(o,i,n),Object.assign(o,_N(n,s)),o}function SN(n,s){const i={},o=xN(n,s);return n.drag&&n.dragListener!==!1&&(i.draggable=!1,o.userSelect=o.WebkitUserSelect=o.WebkitTouchCallout="none",o.touchAction=n.drag===!0?"none":`pan-${n.drag==="x"?"y":"x"}`),n.tabIndex===void 0&&(n.onTap||n.onTapStart||n.whileTap)&&(i.tabIndex=0),i.style=o,i}function TN(n,s,i,o){const c=y.useMemo(()=>{const u=c_();return Op(u,s,Bp(o),n.transformTemplate),{...u.attrs,style:{...u.style}}},[s]);if(n.style){const u={};h_(u,n.style,n),c.style={...u,...c.style}}return c}function kN(n=!1){return(i,o,c,{latestValues:u},d)=>{const h=(Ep(i)?TN:SN)(o,u,d,i),g=zw(o,typeof i=="string",n),v=i!==y.Fragment?{...g,...h,ref:c}:{},{children:b}=o,_=y.useMemo(()=>Xt(b)?b.get():b,[b]);return y.createElement(i,{...v,children:_})}}function wN(n,s){return function(o,{forwardMotionProps:c}={forwardMotionProps:!1}){const d={...Ep(o)?yN:bN,preloadedFeatures:n,useRender:kN(c),createVisualElement:s,Component:o};return Kw(d)}}function g_(n,s){if(!Array.isArray(s))return!1;const i=s.length;if(i!==n.length)return!1;for(let o=0;o<i;o++)if(s[o]!==n[o])return!1;return!0}function Pc(n,s,i){const o=n.getProps();return Ap(o,s,i!==void 0?i:o.custom,n)}function Up(n,s){return n?n[s]||n.default||n:void 0}const v_=new Set(["width","height","top","left","right","bottom",...oo]);let mc;function NN(){mc=void 0}const is={now:()=>(mc===void 0&&is.set(Ft.isProcessing||Mw.useManualTiming?Ft.timestamp:performance.now()),mc),set:n=>{mc=n,queueMicrotask(NN)}};function zp(n,s){n.indexOf(s)===-1&&n.push(s)}function Pp(n,s){const i=n.indexOf(s);i>-1&&n.splice(i,1)}class Vp{constructor(){this.subscriptions=[]}add(s){return zp(this.subscriptions,s),()=>Pp(this.subscriptions,s)}notify(s,i,o){const c=this.subscriptions.length;if(c)if(c===1)this.subscriptions[0](s,i,o);else for(let u=0;u<c;u++){const d=this.subscriptions[u];d&&d(s,i,o)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}function y_(n,s){return s?n*(1e3/s):0}const M0=30,jN=n=>!isNaN(parseFloat(n));class CN{constructor(s,i={}){this.version="11.18.2",this.canTrackVelocity=null,this.events={},this.updateAndNotify=(o,c=!0)=>{const u=is.now();this.updatedAt!==u&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(o),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),c&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(s),this.owner=i.owner}setCurrent(s){this.current=s,this.updatedAt=is.now(),this.canTrackVelocity===null&&s!==void 0&&(this.canTrackVelocity=jN(this.current))}setPrevFrameValue(s=this.current){this.prevFrameValue=s,this.prevUpdatedAt=this.updatedAt}onChange(s){return this.on("change",s)}on(s,i){this.events[s]||(this.events[s]=new Vp);const o=this.events[s].add(i);return s==="change"?()=>{o(),ft.read(()=>{this.events.change.getSize()||this.stop()})}:o}clearListeners(){for(const s in this.events)this.events[s].clear()}attach(s,i){this.passiveEffect=s,this.stopPassiveEffect=i}set(s,i=!0){!i||!this.passiveEffect?this.updateAndNotify(s,i):this.passiveEffect(s,this.updateAndNotify)}setWithVelocity(s,i,o){this.set(i),this.prev=void 0,this.prevFrameValue=s,this.prevUpdatedAt=this.updatedAt-o}jump(s,i=!0){this.updateAndNotify(s),this.prev=s,this.prevUpdatedAt=this.prevFrameValue=void 0,i&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const s=is.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||s-this.updatedAt>M0)return 0;const i=Math.min(this.updatedAt-this.prevUpdatedAt,M0);return y_(parseFloat(this.current)-parseFloat(this.prevFrameValue),i)}start(s){return this.stop(),new Promise(i=>{this.hasAnimated=!0,this.animation=s(i),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function kr(n,s){return new CN(n,s)}function EN(n,s,i){n.hasValue(s)?n.getValue(s).set(i):n.addValue(s,kr(i))}function AN(n,s){const i=Pc(n,s);let{transitionEnd:o={},transition:c={},...u}=i||{};u={...u,...o};for(const d in u){const m=eN(u[d]);EN(n,d,m)}}function DN(n){return!!(Xt(n)&&n.add)}function $f(n,s){const i=n.getValue("willChange");if(DN(i))return i.add(s)}function b_(n){return n.props[n_]}function qp(n){let s;return()=>(s===void 0&&(s=n()),s)}const RN=qp(()=>window.ScrollTimeline!==void 0);class MN{constructor(s){this.stop=()=>this.runAll("stop"),this.animations=s.filter(Boolean)}get finished(){return Promise.all(this.animations.map(s=>"finished"in s?s.finished:s))}getAll(s){return this.animations[0][s]}setAll(s,i){for(let o=0;o<this.animations.length;o++)this.animations[o][s]=i}attachTimeline(s,i){const o=this.animations.map(c=>{if(RN()&&c.attachTimeline)return c.attachTimeline(s);if(typeof i=="function")return i(c)});return()=>{o.forEach((c,u)=>{c&&c(),this.animations[u].stop()})}}get time(){return this.getAll("time")}set time(s){this.setAll("time",s)}get speed(){return this.getAll("speed")}set speed(s){this.setAll("speed",s)}get startTime(){return this.getAll("startTime")}get duration(){let s=0;for(let i=0;i<this.animations.length;i++)s=Math.max(s,this.animations[i].duration);return s}runAll(s){this.animations.forEach(i=>i[s]())}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}class ON extends MN{then(s,i){return Promise.all(this.animations).then(s).catch(i)}}const Ds=n=>n*1e3,Rs=n=>n/1e3;function Hp(n){return typeof n=="function"}function O0(n,s){n.timeline=s,n.onfinish=null}const Gp=n=>Array.isArray(n)&&typeof n[0]=="number",IN={linearEasing:void 0};function BN(n,s){const i=qp(n);return()=>{var o;return(o=IN[s])!==null&&o!==void 0?o:i()}}const xc=BN(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),to=(n,s,i)=>{const o=s-n;return o===0?1:(i-n)/o},__=(n,s,i=10)=>{let o="";const c=Math.max(Math.round(s/i),2);for(let u=0;u<c;u++)o+=n(to(0,c-1,u))+", ";return`linear(${o.substring(0,o.length-2)})`};function x_(n){return!!(typeof n=="function"&&xc()||!n||typeof n=="string"&&(n in Ff||xc())||Gp(n)||Array.isArray(n)&&n.every(x_))}const ur=([n,s,i,o])=>`cubic-bezier(${n}, ${s}, ${i}, ${o})`,Ff={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:ur([0,.65,.55,1]),circOut:ur([.55,0,1,.45]),backIn:ur([.31,.01,.66,-.59]),backOut:ur([.33,1.53,.69,.99])};function S_(n,s){if(n)return typeof n=="function"&&xc()?__(n,s):Gp(n)?ur(n):Array.isArray(n)?n.map(i=>S_(i,s)||Ff.easeOut):Ff[n]}const T_=(n,s,i)=>(((1-3*i+3*s)*n+(3*i-6*s))*n+3*s)*n,LN=1e-7,UN=12;function zN(n,s,i,o,c){let u,d,m=0;do d=s+(i-s)/2,u=T_(d,o,c)-n,u>0?i=d:s=d;while(Math.abs(u)>LN&&++m<UN);return d}function Dr(n,s,i,o){if(n===s&&i===o)return _n;const c=u=>zN(u,0,1,n,i);return u=>u===0||u===1?u:T_(c(u),s,o)}const k_=n=>s=>s<=.5?n(2*s)/2:(2-n(2*(1-s)))/2,w_=n=>s=>1-n(1-s),N_=Dr(.33,1.53,.69,.99),$p=w_(N_),j_=k_($p),C_=n=>(n*=2)<1?.5*$p(n):.5*(2-Math.pow(2,-10*(n-1))),Fp=n=>1-Math.sin(Math.acos(n)),E_=w_(Fp),A_=k_(Fp),D_=n=>/^0[^.\s]+$/u.test(n);function PN(n){return typeof n=="number"?n===0:n!==null?n==="none"||n==="0"||D_(n):!0}const hr=n=>Math.round(n*1e5)/1e5,Zp=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function VN(n){return n==null}const qN=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Kp=(n,s)=>i=>!!(typeof i=="string"&&qN.test(i)&&i.startsWith(n)||s&&!VN(i)&&Object.prototype.hasOwnProperty.call(i,s)),R_=(n,s,i)=>o=>{if(typeof o!="string")return o;const[c,u,d,m]=o.match(Zp);return{[n]:parseFloat(c),[s]:parseFloat(u),[i]:parseFloat(d),alpha:m!==void 0?parseFloat(m):1}},HN=n=>Is(0,255,n),ff={...ro,transform:n=>Math.round(HN(n))},Fa={test:Kp("rgb","red"),parse:R_("red","green","blue"),transform:({red:n,green:s,blue:i,alpha:o=1})=>"rgba("+ff.transform(n)+", "+ff.transform(s)+", "+ff.transform(i)+", "+hr(Tr.transform(o))+")"};function GN(n){let s="",i="",o="",c="";return n.length>5?(s=n.substring(1,3),i=n.substring(3,5),o=n.substring(5,7),c=n.substring(7,9)):(s=n.substring(1,2),i=n.substring(2,3),o=n.substring(3,4),c=n.substring(4,5),s+=s,i+=i,o+=o,c+=c),{red:parseInt(s,16),green:parseInt(i,16),blue:parseInt(o,16),alpha:c?parseInt(c,16)/255:1}}const Zf={test:Kp("#"),parse:GN,transform:Fa.transform},$i={test:Kp("hsl","hue"),parse:R_("hue","saturation","lightness"),transform:({hue:n,saturation:s,lightness:i,alpha:o=1})=>"hsla("+Math.round(n)+", "+as.transform(hr(s))+", "+as.transform(hr(i))+", "+hr(Tr.transform(o))+")"},Wt={test:n=>Fa.test(n)||Zf.test(n)||$i.test(n),parse:n=>Fa.test(n)?Fa.parse(n):$i.test(n)?$i.parse(n):Zf.parse(n),transform:n=>typeof n=="string"?n:n.hasOwnProperty("red")?Fa.transform(n):$i.transform(n)},$N=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function FN(n){var s,i;return isNaN(n)&&typeof n=="string"&&(((s=n.match(Zp))===null||s===void 0?void 0:s.length)||0)+(((i=n.match($N))===null||i===void 0?void 0:i.length)||0)>0}const M_="number",O_="color",ZN="var",KN="var(",I0="${}",YN=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function wr(n){const s=n.toString(),i=[],o={color:[],number:[],var:[]},c=[];let u=0;const m=s.replace(YN,h=>(Wt.test(h)?(o.color.push(u),c.push(O_),i.push(Wt.parse(h))):h.startsWith(KN)?(o.var.push(u),c.push(ZN),i.push(h)):(o.number.push(u),c.push(M_),i.push(parseFloat(h))),++u,I0)).split(I0);return{values:i,split:m,indexes:o,types:c}}function I_(n){return wr(n).values}function B_(n){const{split:s,types:i}=wr(n),o=s.length;return c=>{let u="";for(let d=0;d<o;d++)if(u+=s[d],c[d]!==void 0){const m=i[d];m===M_?u+=hr(c[d]):m===O_?u+=Wt.transform(c[d]):u+=c[d]}return u}}const JN=n=>typeof n=="number"?0:n;function WN(n){const s=I_(n);return B_(n)(s.map(JN))}const ha={test:FN,parse:I_,createTransformer:B_,getAnimatableNone:WN},XN=new Set(["brightness","contrast","saturate","opacity"]);function QN(n){const[s,i]=n.slice(0,-1).split("(");if(s==="drop-shadow")return n;const[o]=i.match(Zp)||[];if(!o)return n;const c=i.replace(o,"");let u=XN.has(s)?1:0;return o!==i&&(u*=100),s+"("+u+c+")"}const ej=/\b([a-z-]*)\(.*?\)/gu,Kf={...ha,getAnimatableNone:n=>{const s=n.match(ej);return s?s.map(QN).join(" "):n}},tj={...Rp,color:Wt,backgroundColor:Wt,outlineColor:Wt,fill:Wt,stroke:Wt,borderColor:Wt,borderTopColor:Wt,borderRightColor:Wt,borderBottomColor:Wt,borderLeftColor:Wt,filter:Kf,WebkitFilter:Kf},Yp=n=>tj[n];function L_(n,s){let i=Yp(n);return i!==Kf&&(i=ha),i.getAnimatableNone?i.getAnimatableNone(s):void 0}const nj=new Set(["auto","none","0"]);function sj(n,s,i){let o=0,c;for(;o<n.length&&!c;){const u=n[o];typeof u=="string"&&!nj.has(u)&&wr(u).values.length&&(c=n[o]),o++}if(c&&i)for(const u of s)n[u]=L_(i,c)}const B0=n=>n===ro||n===ke,L0=(n,s)=>parseFloat(n.split(", ")[s]),U0=(n,s)=>(i,{transform:o})=>{if(o==="none"||!o)return 0;const c=o.match(/^matrix3d\((.+)\)$/u);if(c)return L0(c[1],s);{const u=o.match(/^matrix\((.+)\)$/u);return u?L0(u[1],n):0}},aj=new Set(["x","y","z"]),ij=oo.filter(n=>!aj.has(n));function oj(n){const s=[];return ij.forEach(i=>{const o=n.getValue(i);o!==void 0&&(s.push([i,o.get()]),o.set(i.startsWith("scale")?1:0))}),s}const no={width:({x:n},{paddingLeft:s="0",paddingRight:i="0"})=>n.max-n.min-parseFloat(s)-parseFloat(i),height:({y:n},{paddingTop:s="0",paddingBottom:i="0"})=>n.max-n.min-parseFloat(s)-parseFloat(i),top:(n,{top:s})=>parseFloat(s),left:(n,{left:s})=>parseFloat(s),bottom:({y:n},{top:s})=>parseFloat(s)+(n.max-n.min),right:({x:n},{left:s})=>parseFloat(s)+(n.max-n.min),x:U0(4,13),y:U0(5,14)};no.translateX=no.x;no.translateY=no.y;const Ka=new Set;let Yf=!1,Jf=!1;function U_(){if(Jf){const n=Array.from(Ka).filter(o=>o.needsMeasurement),s=new Set(n.map(o=>o.element)),i=new Map;s.forEach(o=>{const c=oj(o);c.length&&(i.set(o,c),o.render())}),n.forEach(o=>o.measureInitialState()),s.forEach(o=>{o.render();const c=i.get(o);c&&c.forEach(([u,d])=>{var m;(m=o.getValue(u))===null||m===void 0||m.set(d)})}),n.forEach(o=>o.measureEndState()),n.forEach(o=>{o.suspendedScrollY!==void 0&&window.scrollTo(0,o.suspendedScrollY)})}Jf=!1,Yf=!1,Ka.forEach(n=>n.complete()),Ka.clear()}function z_(){Ka.forEach(n=>{n.readKeyframes(),n.needsMeasurement&&(Jf=!0)})}function rj(){z_(),U_()}class Jp{constructor(s,i,o,c,u,d=!1){this.isComplete=!1,this.isAsync=!1,this.needsMeasurement=!1,this.isScheduled=!1,this.unresolvedKeyframes=[...s],this.onComplete=i,this.name=o,this.motionValue=c,this.element=u,this.isAsync=d}scheduleResolve(){this.isScheduled=!0,this.isAsync?(Ka.add(this),Yf||(Yf=!0,ft.read(z_),ft.resolveKeyframes(U_))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:s,name:i,element:o,motionValue:c}=this;for(let u=0;u<s.length;u++)if(s[u]===null)if(u===0){const d=c==null?void 0:c.get(),m=s[s.length-1];if(d!==void 0)s[0]=d;else if(o&&i){const h=o.readValue(i,m);h!=null&&(s[0]=h)}s[0]===void 0&&(s[0]=m),c&&d===void 0&&c.set(s[0])}else s[u]=s[u-1]}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(){this.isComplete=!0,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe),Ka.delete(this)}cancel(){this.isComplete||(this.isScheduled=!1,Ka.delete(this))}resume(){this.isComplete||this.scheduleResolve()}}const P_=n=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(n),lj=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function cj(n){const s=lj.exec(n);if(!s)return[,];const[,i,o,c]=s;return[`--${i??o}`,c]}function V_(n,s,i=1){const[o,c]=cj(n);if(!o)return;const u=window.getComputedStyle(s).getPropertyValue(o);if(u){const d=u.trim();return P_(d)?parseFloat(d):d}return Dp(c)?V_(c,s,i+1):c}const q_=n=>s=>s.test(n),uj={test:n=>n==="auto",parse:n=>n},H_=[ro,ke,as,pa,oN,iN,uj],z0=n=>H_.find(q_(n));class G_ extends Jp{constructor(s,i,o,c,u){super(s,i,o,c,u,!0)}readKeyframes(){const{unresolvedKeyframes:s,element:i,name:o}=this;if(!i||!i.current)return;super.readKeyframes();for(let h=0;h<s.length;h++){let g=s[h];if(typeof g=="string"&&(g=g.trim(),Dp(g))){const v=V_(g,i.current);v!==void 0&&(s[h]=v),h===s.length-1&&(this.finalKeyframe=g)}}if(this.resolveNoneKeyframes(),!v_.has(o)||s.length!==2)return;const[c,u]=s,d=z0(c),m=z0(u);if(d!==m)if(B0(d)&&B0(m))for(let h=0;h<s.length;h++){const g=s[h];typeof g=="string"&&(s[h]=parseFloat(g))}else this.needsMeasurement=!0}resolveNoneKeyframes(){const{unresolvedKeyframes:s,name:i}=this,o=[];for(let c=0;c<s.length;c++)PN(s[c])&&o.push(c);o.length&&sj(s,o,i)}measureInitialState(){const{element:s,unresolvedKeyframes:i,name:o}=this;if(!s||!s.current)return;o==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=no[o](s.measureViewportBox(),window.getComputedStyle(s.current)),i[0]=this.measuredOrigin;const c=i[i.length-1];c!==void 0&&s.getValue(o,c).jump(c,!1)}measureEndState(){var s;const{element:i,name:o,unresolvedKeyframes:c}=this;if(!i||!i.current)return;const u=i.getValue(o);u&&u.jump(this.measuredOrigin,!1);const d=c.length-1,m=c[d];c[d]=no[o](i.measureViewportBox(),window.getComputedStyle(i.current)),m!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=m),!((s=this.removedTransforms)===null||s===void 0)&&s.length&&this.removedTransforms.forEach(([h,g])=>{i.getValue(h).set(g)}),this.resolveNoneKeyframes()}}const P0=(n,s)=>s==="zIndex"?!1:!!(typeof n=="number"||Array.isArray(n)||typeof n=="string"&&(ha.test(n)||n==="0")&&!n.startsWith("url("));function dj(n){const s=n[0];if(n.length===1)return!0;for(let i=0;i<n.length;i++)if(n[i]!==s)return!0}function fj(n,s,i,o){const c=n[0];if(c===null)return!1;if(s==="display"||s==="visibility")return!0;const u=n[n.length-1],d=P0(c,s),m=P0(u,s);return!d||!m?!1:dj(n)||(i==="spring"||Hp(i))&&o}const pj=n=>n!==null;function Vc(n,{repeat:s,repeatType:i="loop"},o){const c=n.filter(pj),u=s&&i!=="loop"&&s%2===1?0:c.length-1;return!u||o===void 0?c[u]:o}const mj=40;class $_{constructor({autoplay:s=!0,delay:i=0,type:o="keyframes",repeat:c=0,repeatDelay:u=0,repeatType:d="loop",...m}){this.isStopped=!1,this.hasAttemptedResolve=!1,this.createdAt=is.now(),this.options={autoplay:s,delay:i,type:o,repeat:c,repeatDelay:u,repeatType:d,...m},this.updateFinishedPromise()}calcStartTime(){return this.resolvedAt?this.resolvedAt-this.createdAt>mj?this.resolvedAt:this.createdAt:this.createdAt}get resolved(){return!this._resolved&&!this.hasAttemptedResolve&&rj(),this._resolved}onKeyframesResolved(s,i){this.resolvedAt=is.now(),this.hasAttemptedResolve=!0;const{name:o,type:c,velocity:u,delay:d,onComplete:m,onUpdate:h,isGenerator:g}=this.options;if(!g&&!fj(s,o,c,u))if(d)this.options.duration=0;else{h&&h(Vc(s,this.options,i)),m&&m(),this.resolveFinishedPromise();return}const v=this.initPlayback(s,i);v!==!1&&(this._resolved={keyframes:s,finalKeyframe:i,...v},this.onPostResolved())}onPostResolved(){}then(s,i){return this.currentFinishedPromise.then(s,i)}flatten(){this.options.type="keyframes",this.options.ease="linear"}updateFinishedPromise(){this.currentFinishedPromise=new Promise(s=>{this.resolveFinishedPromise=s})}}const Wf=2e4;function F_(n){let s=0;const i=50;let o=n.next(s);for(;!o.done&&s<Wf;)s+=i,o=n.next(s);return s>=Wf?1/0:s}const vt=(n,s,i)=>n+(s-n)*i;function pf(n,s,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?n+(s-n)*6*i:i<1/2?s:i<2/3?n+(s-n)*(2/3-i)*6:n}function hj({hue:n,saturation:s,lightness:i,alpha:o}){n/=360,s/=100,i/=100;let c=0,u=0,d=0;if(!s)c=u=d=i;else{const m=i<.5?i*(1+s):i+s-i*s,h=2*i-m;c=pf(h,m,n+1/3),u=pf(h,m,n),d=pf(h,m,n-1/3)}return{red:Math.round(c*255),green:Math.round(u*255),blue:Math.round(d*255),alpha:o}}function Sc(n,s){return i=>i>0?s:n}const mf=(n,s,i)=>{const o=n*n,c=i*(s*s-o)+o;return c<0?0:Math.sqrt(c)},gj=[Zf,Fa,$i],vj=n=>gj.find(s=>s.test(n));function V0(n){const s=vj(n);if(!s)return!1;let i=s.parse(n);return s===$i&&(i=hj(i)),i}const q0=(n,s)=>{const i=V0(n),o=V0(s);if(!i||!o)return Sc(n,s);const c={...i};return u=>(c.red=mf(i.red,o.red,u),c.green=mf(i.green,o.green,u),c.blue=mf(i.blue,o.blue,u),c.alpha=vt(i.alpha,o.alpha,u),Fa.transform(c))},yj=(n,s)=>i=>s(n(i)),Rr=(...n)=>n.reduce(yj),Xf=new Set(["none","hidden"]);function bj(n,s){return Xf.has(n)?i=>i<=0?n:s:i=>i>=1?s:n}function _j(n,s){return i=>vt(n,s,i)}function Wp(n){return typeof n=="number"?_j:typeof n=="string"?Dp(n)?Sc:Wt.test(n)?q0:Tj:Array.isArray(n)?Z_:typeof n=="object"?Wt.test(n)?q0:xj:Sc}function Z_(n,s){const i=[...n],o=i.length,c=n.map((u,d)=>Wp(u)(u,s[d]));return u=>{for(let d=0;d<o;d++)i[d]=c[d](u);return i}}function xj(n,s){const i={...n,...s},o={};for(const c in i)n[c]!==void 0&&s[c]!==void 0&&(o[c]=Wp(n[c])(n[c],s[c]));return c=>{for(const u in o)i[u]=o[u](c);return i}}function Sj(n,s){var i;const o=[],c={color:0,var:0,number:0};for(let u=0;u<s.values.length;u++){const d=s.types[u],m=n.indexes[d][c[d]],h=(i=n.values[m])!==null&&i!==void 0?i:0;o[u]=h,c[d]++}return o}const Tj=(n,s)=>{const i=ha.createTransformer(s),o=wr(n),c=wr(s);return o.indexes.var.length===c.indexes.var.length&&o.indexes.color.length===c.indexes.color.length&&o.indexes.number.length>=c.indexes.number.length?Xf.has(n)&&!c.values.length||Xf.has(s)&&!o.values.length?bj(n,s):Rr(Z_(Sj(o,c),c.values),i):Sc(n,s)};function K_(n,s,i){return typeof n=="number"&&typeof s=="number"&&typeof i=="number"?vt(n,s,i):Wp(n)(n,s)}const kj=5;function Y_(n,s,i){const o=Math.max(s-kj,0);return y_(i-n(o),s-o)}const _t={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},hf=.001;function wj({duration:n=_t.duration,bounce:s=_t.bounce,velocity:i=_t.velocity,mass:o=_t.mass}){let c,u,d=1-s;d=Is(_t.minDamping,_t.maxDamping,d),n=Is(_t.minDuration,_t.maxDuration,Rs(n)),d<1?(c=g=>{const v=g*d,b=v*n,_=v-i,S=Qf(g,d),T=Math.exp(-b);return hf-_/S*T},u=g=>{const b=g*d*n,_=b*i+i,S=Math.pow(d,2)*Math.pow(g,2)*n,T=Math.exp(-b),N=Qf(Math.pow(g,2),d);return(-c(g)+hf>0?-1:1)*((_-S)*T)/N}):(c=g=>{const v=Math.exp(-g*n),b=(g-i)*n+1;return-hf+v*b},u=g=>{const v=Math.exp(-g*n),b=(i-g)*(n*n);return v*b});const m=5/n,h=jj(c,u,m);if(n=Ds(n),isNaN(h))return{stiffness:_t.stiffness,damping:_t.damping,duration:n};{const g=Math.pow(h,2)*o;return{stiffness:g,damping:d*2*Math.sqrt(o*g),duration:n}}}const Nj=12;function jj(n,s,i){let o=i;for(let c=1;c<Nj;c++)o=o-n(o)/s(o);return o}function Qf(n,s){return n*Math.sqrt(1-s*s)}const Cj=["duration","bounce"],Ej=["stiffness","damping","mass"];function H0(n,s){return s.some(i=>n[i]!==void 0)}function Aj(n){let s={velocity:_t.velocity,stiffness:_t.stiffness,damping:_t.damping,mass:_t.mass,isResolvedFromDuration:!1,...n};if(!H0(n,Ej)&&H0(n,Cj))if(n.visualDuration){const i=n.visualDuration,o=2*Math.PI/(i*1.2),c=o*o,u=2*Is(.05,1,1-(n.bounce||0))*Math.sqrt(c);s={...s,mass:_t.mass,stiffness:c,damping:u}}else{const i=wj(n);s={...s,...i,mass:_t.mass},s.isResolvedFromDuration=!0}return s}function J_(n=_t.visualDuration,s=_t.bounce){const i=typeof n!="object"?{visualDuration:n,keyframes:[0,1],bounce:s}:n;let{restSpeed:o,restDelta:c}=i;const u=i.keyframes[0],d=i.keyframes[i.keyframes.length-1],m={done:!1,value:u},{stiffness:h,damping:g,mass:v,duration:b,velocity:_,isResolvedFromDuration:S}=Aj({...i,velocity:-Rs(i.velocity||0)}),T=_||0,N=g/(2*Math.sqrt(h*v)),j=d-u,w=Rs(Math.sqrt(h/v)),E=Math.abs(j)<5;o||(o=E?_t.restSpeed.granular:_t.restSpeed.default),c||(c=E?_t.restDelta.granular:_t.restDelta.default);let A;if(N<1){const C=Qf(w,N);A=M=>{const G=Math.exp(-N*w*M);return d-G*((T+N*w*j)/C*Math.sin(C*M)+j*Math.cos(C*M))}}else if(N===1)A=C=>d-Math.exp(-w*C)*(j+(T+w*j)*C);else{const C=w*Math.sqrt(N*N-1);A=M=>{const G=Math.exp(-N*w*M),U=Math.min(C*M,300);return d-G*((T+N*w*j)*Math.sinh(U)+C*j*Math.cosh(U))/C}}const O={calculatedDuration:S&&b||null,next:C=>{const M=A(C);if(S)m.done=C>=b;else{let G=0;N<1&&(G=C===0?Ds(T):Y_(A,C,M));const U=Math.abs(G)<=o,V=Math.abs(d-M)<=c;m.done=U&&V}return m.value=m.done?d:M,m},toString:()=>{const C=Math.min(F_(O),Wf),M=__(G=>O.next(C*G).value,C,30);return C+"ms "+M}};return O}function G0({keyframes:n,velocity:s=0,power:i=.8,timeConstant:o=325,bounceDamping:c=10,bounceStiffness:u=500,modifyTarget:d,min:m,max:h,restDelta:g=.5,restSpeed:v}){const b=n[0],_={done:!1,value:b},S=U=>m!==void 0&&U<m||h!==void 0&&U>h,T=U=>m===void 0?h:h===void 0||Math.abs(m-U)<Math.abs(h-U)?m:h;let N=i*s;const j=b+N,w=d===void 0?j:d(j);w!==j&&(N=w-b);const E=U=>-N*Math.exp(-U/o),A=U=>w+E(U),O=U=>{const V=E(U),Z=A(U);_.done=Math.abs(V)<=g,_.value=_.done?w:Z};let C,M;const G=U=>{S(_.value)&&(C=U,M=J_({keyframes:[_.value,T(_.value)],velocity:Y_(A,U,_.value),damping:c,stiffness:u,restDelta:g,restSpeed:v}))};return G(0),{calculatedDuration:null,next:U=>{let V=!1;return!M&&C===void 0&&(V=!0,O(U),G(U)),C!==void 0&&U>=C?M.next(U-C):(!V&&O(U),_)}}}const Dj=Dr(.42,0,1,1),Rj=Dr(0,0,.58,1),W_=Dr(.42,0,.58,1),Mj=n=>Array.isArray(n)&&typeof n[0]!="number",Oj={linear:_n,easeIn:Dj,easeInOut:W_,easeOut:Rj,circIn:Fp,circInOut:A_,circOut:E_,backIn:$p,backInOut:j_,backOut:N_,anticipate:C_},$0=n=>{if(Gp(n)){Wb(n.length===4);const[s,i,o,c]=n;return Dr(s,i,o,c)}else if(typeof n=="string")return Oj[n];return n};function Ij(n,s,i){const o=[],c=i||K_,u=n.length-1;for(let d=0;d<u;d++){let m=c(n[d],n[d+1]);if(s){const h=Array.isArray(s)?s[d]||_n:s;m=Rr(h,m)}o.push(m)}return o}function Bj(n,s,{clamp:i=!0,ease:o,mixer:c}={}){const u=n.length;if(Wb(u===s.length),u===1)return()=>s[0];if(u===2&&s[0]===s[1])return()=>s[1];const d=n[0]===n[1];n[0]>n[u-1]&&(n=[...n].reverse(),s=[...s].reverse());const m=Ij(s,o,c),h=m.length,g=v=>{if(d&&v<n[0])return s[0];let b=0;if(h>1)for(;b<n.length-2&&!(v<n[b+1]);b++);const _=to(n[b],n[b+1],v);return m[b](_)};return i?v=>g(Is(n[0],n[u-1],v)):g}function Lj(n,s){const i=n[n.length-1];for(let o=1;o<=s;o++){const c=to(0,s,o);n.push(vt(i,1,c))}}function Uj(n){const s=[0];return Lj(s,n.length-1),s}function zj(n,s){return n.map(i=>i*s)}function Pj(n,s){return n.map(()=>s||W_).splice(0,n.length-1)}function Tc({duration:n=300,keyframes:s,times:i,ease:o="easeInOut"}){const c=Mj(o)?o.map($0):$0(o),u={done:!1,value:s[0]},d=zj(i&&i.length===s.length?i:Uj(s),n),m=Bj(d,s,{ease:Array.isArray(c)?c:Pj(s,c)});return{calculatedDuration:n,next:h=>(u.value=m(h),u.done=h>=n,u)}}const Vj=n=>{const s=({timestamp:i})=>n(i);return{start:()=>ft.update(s,!0),stop:()=>ma(s),now:()=>Ft.isProcessing?Ft.timestamp:is.now()}},qj={decay:G0,inertia:G0,tween:Tc,keyframes:Tc,spring:J_},Hj=n=>n/100;class Xp extends $_{constructor(s){super(s),this.holdTime=null,this.cancelTime=null,this.currentTime=0,this.playbackSpeed=1,this.pendingPlayState="running",this.startTime=null,this.state="idle",this.stop=()=>{if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.teardown();const{onStop:h}=this.options;h&&h()};const{name:i,motionValue:o,element:c,keyframes:u}=this.options,d=(c==null?void 0:c.KeyframeResolver)||Jp,m=(h,g)=>this.onKeyframesResolved(h,g);this.resolver=new d(u,m,i,o,c),this.resolver.scheduleResolve()}flatten(){super.flatten(),this._resolved&&Object.assign(this._resolved,this.initPlayback(this._resolved.keyframes))}initPlayback(s){const{type:i="keyframes",repeat:o=0,repeatDelay:c=0,repeatType:u,velocity:d=0}=this.options,m=Hp(i)?i:qj[i]||Tc;let h,g;m!==Tc&&typeof s[0]!="number"&&(h=Rr(Hj,K_(s[0],s[1])),s=[0,100]);const v=m({...this.options,keyframes:s});u==="mirror"&&(g=m({...this.options,keyframes:[...s].reverse(),velocity:-d})),v.calculatedDuration===null&&(v.calculatedDuration=F_(v));const{calculatedDuration:b}=v,_=b+c,S=_*(o+1)-c;return{generator:v,mirroredGenerator:g,mapPercentToKeyframes:h,calculatedDuration:b,resolvedDuration:_,totalDuration:S}}onPostResolved(){const{autoplay:s=!0}=this.options;this.play(),this.pendingPlayState==="paused"||!s?this.pause():this.state=this.pendingPlayState}tick(s,i=!1){const{resolved:o}=this;if(!o){const{keyframes:U}=this.options;return{done:!0,value:U[U.length-1]}}const{finalKeyframe:c,generator:u,mirroredGenerator:d,mapPercentToKeyframes:m,keyframes:h,calculatedDuration:g,totalDuration:v,resolvedDuration:b}=o;if(this.startTime===null)return u.next(0);const{delay:_,repeat:S,repeatType:T,repeatDelay:N,onUpdate:j}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,s):this.speed<0&&(this.startTime=Math.min(s-v/this.speed,this.startTime)),i?this.currentTime=s:this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=Math.round(s-this.startTime)*this.speed;const w=this.currentTime-_*(this.speed>=0?1:-1),E=this.speed>=0?w<0:w>v;this.currentTime=Math.max(w,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=v);let A=this.currentTime,O=u;if(S){const U=Math.min(this.currentTime,v)/b;let V=Math.floor(U),Z=U%1;!Z&&U>=1&&(Z=1),Z===1&&V--,V=Math.min(V,S+1),!!(V%2)&&(T==="reverse"?(Z=1-Z,N&&(Z-=N/b)):T==="mirror"&&(O=d)),A=Is(0,1,Z)*b}const C=E?{done:!1,value:h[0]}:O.next(A);m&&(C.value=m(C.value));let{done:M}=C;!E&&g!==null&&(M=this.speed>=0?this.currentTime>=v:this.currentTime<=0);const G=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&M);return G&&c!==void 0&&(C.value=Vc(h,this.options,c)),j&&j(C.value),G&&this.finish(),C}get duration(){const{resolved:s}=this;return s?Rs(s.calculatedDuration):0}get time(){return Rs(this.currentTime)}set time(s){s=Ds(s),this.currentTime=s,this.holdTime!==null||this.speed===0?this.holdTime=s:this.driver&&(this.startTime=this.driver.now()-s/this.speed)}get speed(){return this.playbackSpeed}set speed(s){const i=this.playbackSpeed!==s;this.playbackSpeed=s,i&&(this.time=Rs(this.currentTime))}play(){if(this.resolver.isScheduled||this.resolver.resume(),!this._resolved){this.pendingPlayState="running";return}if(this.isStopped)return;const{driver:s=Vj,onPlay:i,startTime:o}=this.options;this.driver||(this.driver=s(u=>this.tick(u))),i&&i();const c=this.driver.now();this.holdTime!==null?this.startTime=c-this.holdTime:this.startTime?this.state==="finished"&&(this.startTime=c):this.startTime=o??this.calcStartTime(),this.state==="finished"&&this.updateFinishedPromise(),this.cancelTime=this.startTime,this.holdTime=null,this.state="running",this.driver.start()}pause(){var s;if(!this._resolved){this.pendingPlayState="paused";return}this.state="paused",this.holdTime=(s=this.currentTime)!==null&&s!==void 0?s:0}complete(){this.state!=="running"&&this.play(),this.pendingPlayState=this.state="finished",this.holdTime=null}finish(){this.teardown(),this.state="finished";const{onComplete:s}=this.options;s&&s()}cancel(){this.cancelTime!==null&&this.tick(this.cancelTime),this.teardown(),this.updateFinishedPromise()}teardown(){this.state="idle",this.stopDriver(),this.resolveFinishedPromise(),this.updateFinishedPromise(),this.startTime=this.cancelTime=null,this.resolver.cancel()}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(s){return this.startTime=0,this.tick(s,!0)}}const Gj=new Set(["opacity","clipPath","filter","transform"]);function $j(n,s,i,{delay:o=0,duration:c=300,repeat:u=0,repeatType:d="loop",ease:m="easeInOut",times:h}={}){const g={[s]:i};h&&(g.offset=h);const v=S_(m,c);return Array.isArray(v)&&(g.easing=v),n.animate(g,{delay:o,duration:c,easing:Array.isArray(v)?"linear":v,fill:"both",iterations:u+1,direction:d==="reverse"?"alternate":"normal"})}const Fj=qp(()=>Object.hasOwnProperty.call(Element.prototype,"animate")),kc=10,Zj=2e4;function Kj(n){return Hp(n.type)||n.type==="spring"||!x_(n.ease)}function Yj(n,s){const i=new Xp({...s,keyframes:n,repeat:0,delay:0,isGenerator:!0});let o={done:!1,value:n[0]};const c=[];let u=0;for(;!o.done&&u<Zj;)o=i.sample(u),c.push(o.value),u+=kc;return{times:void 0,keyframes:c,duration:u-kc,ease:"linear"}}const X_={anticipate:C_,backInOut:j_,circInOut:A_};function Jj(n){return n in X_}class F0 extends $_{constructor(s){super(s);const{name:i,motionValue:o,element:c,keyframes:u}=this.options;this.resolver=new G_(u,(d,m)=>this.onKeyframesResolved(d,m),i,o,c),this.resolver.scheduleResolve()}initPlayback(s,i){let{duration:o=300,times:c,ease:u,type:d,motionValue:m,name:h,startTime:g}=this.options;if(!m.owner||!m.owner.current)return!1;if(typeof u=="string"&&xc()&&Jj(u)&&(u=X_[u]),Kj(this.options)){const{onComplete:b,onUpdate:_,motionValue:S,element:T,...N}=this.options,j=Yj(s,N);s=j.keyframes,s.length===1&&(s[1]=s[0]),o=j.duration,c=j.times,u=j.ease,d="keyframes"}const v=$j(m.owner.current,h,s,{...this.options,duration:o,times:c,ease:u});return v.startTime=g??this.calcStartTime(),this.pendingTimeline?(O0(v,this.pendingTimeline),this.pendingTimeline=void 0):v.onfinish=()=>{const{onComplete:b}=this.options;m.set(Vc(s,this.options,i)),b&&b(),this.cancel(),this.resolveFinishedPromise()},{animation:v,duration:o,times:c,type:d,ease:u,keyframes:s}}get duration(){const{resolved:s}=this;if(!s)return 0;const{duration:i}=s;return Rs(i)}get time(){const{resolved:s}=this;if(!s)return 0;const{animation:i}=s;return Rs(i.currentTime||0)}set time(s){const{resolved:i}=this;if(!i)return;const{animation:o}=i;o.currentTime=Ds(s)}get speed(){const{resolved:s}=this;if(!s)return 1;const{animation:i}=s;return i.playbackRate}set speed(s){const{resolved:i}=this;if(!i)return;const{animation:o}=i;o.playbackRate=s}get state(){const{resolved:s}=this;if(!s)return"idle";const{animation:i}=s;return i.playState}get startTime(){const{resolved:s}=this;if(!s)return null;const{animation:i}=s;return i.startTime}attachTimeline(s){if(!this._resolved)this.pendingTimeline=s;else{const{resolved:i}=this;if(!i)return _n;const{animation:o}=i;O0(o,s)}return _n}play(){if(this.isStopped)return;const{resolved:s}=this;if(!s)return;const{animation:i}=s;i.playState==="finished"&&this.updateFinishedPromise(),i.play()}pause(){const{resolved:s}=this;if(!s)return;const{animation:i}=s;i.pause()}stop(){if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.resolveFinishedPromise(),this.updateFinishedPromise();const{resolved:s}=this;if(!s)return;const{animation:i,keyframes:o,duration:c,type:u,ease:d,times:m}=s;if(i.playState==="idle"||i.playState==="finished")return;if(this.time){const{motionValue:g,onUpdate:v,onComplete:b,element:_,...S}=this.options,T=new Xp({...S,keyframes:o,duration:c,type:u,ease:d,times:m,isGenerator:!0}),N=Ds(this.time);g.setWithVelocity(T.sample(N-kc).value,T.sample(N).value,kc)}const{onStop:h}=this.options;h&&h(),this.cancel()}complete(){const{resolved:s}=this;s&&s.animation.finish()}cancel(){const{resolved:s}=this;s&&s.animation.cancel()}static supports(s){const{motionValue:i,name:o,repeatDelay:c,repeatType:u,damping:d,type:m}=s;if(!i||!i.owner||!(i.owner.current instanceof HTMLElement))return!1;const{onUpdate:h,transformTemplate:g}=i.owner.getProps();return Fj()&&o&&Gj.has(o)&&!h&&!g&&!c&&u!=="mirror"&&d!==0&&m!=="inertia"}}const Wj={type:"spring",stiffness:500,damping:25,restSpeed:10},Xj=n=>({type:"spring",stiffness:550,damping:n===0?2*Math.sqrt(550):30,restSpeed:10}),Qj={type:"keyframes",duration:.8},eC={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},tC=(n,{keyframes:s})=>s.length>2?Qj:ti.has(n)?n.startsWith("scale")?Xj(s[1]):Wj:eC;function nC({when:n,delay:s,delayChildren:i,staggerChildren:o,staggerDirection:c,repeat:u,repeatType:d,repeatDelay:m,from:h,elapsed:g,...v}){return!!Object.keys(v).length}const Qp=(n,s,i,o={},c,u)=>d=>{const m=Up(o,n)||{},h=m.delay||o.delay||0;let{elapsed:g=0}=o;g=g-Ds(h);let v={keyframes:Array.isArray(i)?i:[null,i],ease:"easeOut",velocity:s.getVelocity(),...m,delay:-g,onUpdate:_=>{s.set(_),m.onUpdate&&m.onUpdate(_)},onComplete:()=>{d(),m.onComplete&&m.onComplete()},name:n,motionValue:s,element:u?void 0:c};nC(m)||(v={...v,...tC(n,v)}),v.duration&&(v.duration=Ds(v.duration)),v.repeatDelay&&(v.repeatDelay=Ds(v.repeatDelay)),v.from!==void 0&&(v.keyframes[0]=v.from);let b=!1;if((v.type===!1||v.duration===0&&!v.repeatDelay)&&(v.duration=0,v.delay===0&&(b=!0)),b&&!u&&s.get()!==void 0){const _=Vc(v.keyframes,m);if(_!==void 0)return ft.update(()=>{v.onUpdate(_),v.onComplete()}),new ON([])}return!u&&F0.supports(v)?new F0(v):new Xp(v)};function sC({protectedKeys:n,needsAnimating:s},i){const o=n.hasOwnProperty(i)&&s[i]!==!0;return s[i]=!1,o}function Q_(n,s,{delay:i=0,transitionOverride:o,type:c}={}){var u;let{transition:d=n.getDefaultTransition(),transitionEnd:m,...h}=s;o&&(d=o);const g=[],v=c&&n.animationState&&n.animationState.getState()[c];for(const b in h){const _=n.getValue(b,(u=n.latestValues[b])!==null&&u!==void 0?u:null),S=h[b];if(S===void 0||v&&sC(v,b))continue;const T={delay:i,...Up(d||{},b)};let N=!1;if(window.MotionHandoffAnimation){const w=b_(n);if(w){const E=window.MotionHandoffAnimation(w,b,ft);E!==null&&(T.startTime=E,N=!0)}}$f(n,b),_.start(Qp(b,_,S,n.shouldReduceMotion&&v_.has(b)?{type:!1}:T,n,N));const j=_.animation;j&&g.push(j)}return m&&Promise.all(g).then(()=>{ft.update(()=>{m&&AN(n,m)})}),g}function ep(n,s,i={}){var o;const c=Pc(n,s,i.type==="exit"?(o=n.presenceContext)===null||o===void 0?void 0:o.custom:void 0);let{transition:u=n.getDefaultTransition()||{}}=c||{};i.transitionOverride&&(u=i.transitionOverride);const d=c?()=>Promise.all(Q_(n,c,i)):()=>Promise.resolve(),m=n.variantChildren&&n.variantChildren.size?(g=0)=>{const{delayChildren:v=0,staggerChildren:b,staggerDirection:_}=u;return aC(n,s,v+g,b,_,i)}:()=>Promise.resolve(),{when:h}=u;if(h){const[g,v]=h==="beforeChildren"?[d,m]:[m,d];return g().then(()=>v())}else return Promise.all([d(),m(i.delay)])}function aC(n,s,i=0,o=0,c=1,u){const d=[],m=(n.variantChildren.size-1)*o,h=c===1?(g=0)=>g*o:(g=0)=>m-g*o;return Array.from(n.variantChildren).sort(iC).forEach((g,v)=>{g.notify("AnimationStart",s),d.push(ep(g,s,{...u,delay:i+h(v)}).then(()=>g.notify("AnimationComplete",s)))}),Promise.all(d)}function iC(n,s){return n.sortNodePosition(s)}function oC(n,s,i={}){n.notify("AnimationStart",s);let o;if(Array.isArray(s)){const c=s.map(u=>ep(n,u,i));o=Promise.all(c)}else if(typeof s=="string")o=ep(n,s,i);else{const c=typeof s=="function"?Pc(n,s,i.custom):s;o=Promise.all(Q_(n,c,i))}return o.then(()=>{n.notify("AnimationComplete",s)})}const rC=Np.length;function ex(n){if(!n)return;if(!n.isControllingVariants){const i=n.parent?ex(n.parent)||{}:{};return n.props.initial!==void 0&&(i.initial=n.props.initial),i}const s={};for(let i=0;i<rC;i++){const o=Np[i],c=n.props[o];(Sr(c)||c===!1)&&(s[o]=c)}return s}const lC=[...wp].reverse(),cC=wp.length;function uC(n){return s=>Promise.all(s.map(({animation:i,options:o})=>oC(n,i,o)))}function dC(n){let s=uC(n),i=Z0(),o=!0;const c=h=>(g,v)=>{var b;const _=Pc(n,v,h==="exit"?(b=n.presenceContext)===null||b===void 0?void 0:b.custom:void 0);if(_){const{transition:S,transitionEnd:T,...N}=_;g={...g,...N,...T}}return g};function u(h){s=h(n)}function d(h){const{props:g}=n,v=ex(n.parent)||{},b=[],_=new Set;let S={},T=1/0;for(let j=0;j<cC;j++){const w=lC[j],E=i[w],A=g[w]!==void 0?g[w]:v[w],O=Sr(A),C=w===h?E.isActive:null;C===!1&&(T=j);let M=A===v[w]&&A!==g[w]&&O;if(M&&o&&n.manuallyAnimateOnMount&&(M=!1),E.protectedKeys={...S},!E.isActive&&C===null||!A&&!E.prevProp||Uc(A)||typeof A=="boolean")continue;const G=fC(E.prevProp,A);let U=G||w===h&&E.isActive&&!M&&O||j>T&&O,V=!1;const Z=Array.isArray(A)?A:[A];let ee=Z.reduce(c(w),{});C===!1&&(ee={});const{prevResolvedValues:ie={}}=E,be={...ie,...ee},K=$=>{U=!0,_.has($)&&(V=!0,_.delete($)),E.needsAnimating[$]=!0;const Q=n.getValue($);Q&&(Q.liveStyle=!1)};for(const $ in be){const Q=ee[$],de=ie[$];if(S.hasOwnProperty($))continue;let me=!1;Gf(Q)&&Gf(de)?me=!g_(Q,de):me=Q!==de,me?Q!=null?K($):_.add($):Q!==void 0&&_.has($)?K($):E.protectedKeys[$]=!0}E.prevProp=A,E.prevResolvedValues=ee,E.isActive&&(S={...S,...ee}),o&&n.blockInitialAnimation&&(U=!1),U&&(!(M&&G)||V)&&b.push(...Z.map($=>({animation:$,options:{type:w}})))}if(_.size){const j={};_.forEach(w=>{const E=n.getBaseTarget(w),A=n.getValue(w);A&&(A.liveStyle=!0),j[w]=E??null}),b.push({animation:j})}let N=!!b.length;return o&&(g.initial===!1||g.initial===g.animate)&&!n.manuallyAnimateOnMount&&(N=!1),o=!1,N?s(b):Promise.resolve()}function m(h,g){var v;if(i[h].isActive===g)return Promise.resolve();(v=n.variantChildren)===null||v===void 0||v.forEach(_=>{var S;return(S=_.animationState)===null||S===void 0?void 0:S.setActive(h,g)}),i[h].isActive=g;const b=d(h);for(const _ in i)i[_].protectedKeys={};return b}return{animateChanges:d,setActive:m,setAnimateFunction:u,getState:()=>i,reset:()=>{i=Z0(),o=!0}}}function fC(n,s){return typeof s=="string"?s!==n:Array.isArray(s)?!g_(s,n):!1}function Pa(n=!1){return{isActive:n,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Z0(){return{animate:Pa(!0),whileInView:Pa(),whileHover:Pa(),whileTap:Pa(),whileDrag:Pa(),whileFocus:Pa(),exit:Pa()}}class ya{constructor(s){this.isMounted=!1,this.node=s}update(){}}class pC extends ya{constructor(s){super(s),s.animationState||(s.animationState=dC(s))}updateAnimationControlsSubscription(){const{animate:s}=this.node.getProps();Uc(s)&&(this.unmountControls=s.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:s}=this.node.getProps(),{animate:i}=this.node.prevProps||{};s!==i&&this.updateAnimationControlsSubscription()}unmount(){var s;this.node.animationState.reset(),(s=this.unmountControls)===null||s===void 0||s.call(this)}}let mC=0;class hC extends ya{constructor(){super(...arguments),this.id=mC++}update(){if(!this.node.presenceContext)return;const{isPresent:s,onExitComplete:i}=this.node.presenceContext,{isPresent:o}=this.node.prevPresenceContext||{};if(!this.node.animationState||s===o)return;const c=this.node.animationState.setActive("exit",!s);i&&!s&&c.then(()=>i(this.id))}mount(){const{register:s}=this.node.presenceContext||{};s&&(this.unmount=s(this.id))}unmount(){}}const gC={animation:{Feature:pC},exit:{Feature:hC}},Fn={x:!1,y:!1};function tx(){return Fn.x||Fn.y}function vC(n){return n==="x"||n==="y"?Fn[n]?null:(Fn[n]=!0,()=>{Fn[n]=!1}):Fn.x||Fn.y?null:(Fn.x=Fn.y=!0,()=>{Fn.x=Fn.y=!1})}const em=n=>n.pointerType==="mouse"?typeof n.button!="number"||n.button<=0:n.isPrimary!==!1;function Nr(n,s,i,o={passive:!0}){return n.addEventListener(s,i,o),()=>n.removeEventListener(s,i)}function Mr(n){return{point:{x:n.pageX,y:n.pageY}}}const yC=n=>s=>em(s)&&n(s,Mr(s));function gr(n,s,i,o){return Nr(n,s,yC(i),o)}const K0=(n,s)=>Math.abs(n-s);function bC(n,s){const i=K0(n.x,s.x),o=K0(n.y,s.y);return Math.sqrt(i**2+o**2)}class nx{constructor(s,i,{transformPagePoint:o,contextWindow:c,dragSnapToOrigin:u=!1}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const b=vf(this.lastMoveEventInfo,this.history),_=this.startEvent!==null,S=bC(b.offset,{x:0,y:0})>=3;if(!_&&!S)return;const{point:T}=b,{timestamp:N}=Ft;this.history.push({...T,timestamp:N});const{onStart:j,onMove:w}=this.handlers;_||(j&&j(this.lastMoveEvent,b),this.startEvent=this.lastMoveEvent),w&&w(this.lastMoveEvent,b)},this.handlePointerMove=(b,_)=>{this.lastMoveEvent=b,this.lastMoveEventInfo=gf(_,this.transformPagePoint),ft.update(this.updatePoint,!0)},this.handlePointerUp=(b,_)=>{this.end();const{onEnd:S,onSessionEnd:T,resumeAnimation:N}=this.handlers;if(this.dragSnapToOrigin&&N&&N(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const j=vf(b.type==="pointercancel"?this.lastMoveEventInfo:gf(_,this.transformPagePoint),this.history);this.startEvent&&S&&S(b,j),T&&T(b,j)},!em(s))return;this.dragSnapToOrigin=u,this.handlers=i,this.transformPagePoint=o,this.contextWindow=c||window;const d=Mr(s),m=gf(d,this.transformPagePoint),{point:h}=m,{timestamp:g}=Ft;this.history=[{...h,timestamp:g}];const{onSessionStart:v}=i;v&&v(s,vf(m,this.history)),this.removeListeners=Rr(gr(this.contextWindow,"pointermove",this.handlePointerMove),gr(this.contextWindow,"pointerup",this.handlePointerUp),gr(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(s){this.handlers=s}end(){this.removeListeners&&this.removeListeners(),ma(this.updatePoint)}}function gf(n,s){return s?{point:s(n.point)}:n}function Y0(n,s){return{x:n.x-s.x,y:n.y-s.y}}function vf({point:n},s){return{point:n,delta:Y0(n,sx(s)),offset:Y0(n,_C(s)),velocity:xC(s,.1)}}function _C(n){return n[0]}function sx(n){return n[n.length-1]}function xC(n,s){if(n.length<2)return{x:0,y:0};let i=n.length-1,o=null;const c=sx(n);for(;i>=0&&(o=n[i],!(c.timestamp-o.timestamp>Ds(s)));)i--;if(!o)return{x:0,y:0};const u=Rs(c.timestamp-o.timestamp);if(u===0)return{x:0,y:0};const d={x:(c.x-o.x)/u,y:(c.y-o.y)/u};return d.x===1/0&&(d.x=0),d.y===1/0&&(d.y=0),d}const ax=1e-4,SC=1-ax,TC=1+ax,ix=.01,kC=0-ix,wC=0+ix;function xn(n){return n.max-n.min}function NC(n,s,i){return Math.abs(n-s)<=i}function J0(n,s,i,o=.5){n.origin=o,n.originPoint=vt(s.min,s.max,n.origin),n.scale=xn(i)/xn(s),n.translate=vt(i.min,i.max,n.origin)-n.originPoint,(n.scale>=SC&&n.scale<=TC||isNaN(n.scale))&&(n.scale=1),(n.translate>=kC&&n.translate<=wC||isNaN(n.translate))&&(n.translate=0)}function vr(n,s,i,o){J0(n.x,s.x,i.x,o?o.originX:void 0),J0(n.y,s.y,i.y,o?o.originY:void 0)}function W0(n,s,i){n.min=i.min+s.min,n.max=n.min+xn(s)}function jC(n,s,i){W0(n.x,s.x,i.x),W0(n.y,s.y,i.y)}function X0(n,s,i){n.min=s.min-i.min,n.max=n.min+xn(s)}function yr(n,s,i){X0(n.x,s.x,i.x),X0(n.y,s.y,i.y)}function CC(n,{min:s,max:i},o){return s!==void 0&&n<s?n=o?vt(s,n,o.min):Math.max(n,s):i!==void 0&&n>i&&(n=o?vt(i,n,o.max):Math.min(n,i)),n}function Q0(n,s,i){return{min:s!==void 0?n.min+s:void 0,max:i!==void 0?n.max+i-(n.max-n.min):void 0}}function EC(n,{top:s,left:i,bottom:o,right:c}){return{x:Q0(n.x,i,c),y:Q0(n.y,s,o)}}function ey(n,s){let i=s.min-n.min,o=s.max-n.max;return s.max-s.min<n.max-n.min&&([i,o]=[o,i]),{min:i,max:o}}function AC(n,s){return{x:ey(n.x,s.x),y:ey(n.y,s.y)}}function DC(n,s){let i=.5;const o=xn(n),c=xn(s);return c>o?i=to(s.min,s.max-o,n.min):o>c&&(i=to(n.min,n.max-c,s.min)),Is(0,1,i)}function RC(n,s){const i={};return s.min!==void 0&&(i.min=s.min-n.min),s.max!==void 0&&(i.max=s.max-n.min),i}const tp=.35;function MC(n=tp){return n===!1?n=0:n===!0&&(n=tp),{x:ty(n,"left","right"),y:ty(n,"top","bottom")}}function ty(n,s,i){return{min:ny(n,s),max:ny(n,i)}}function ny(n,s){return typeof n=="number"?n:n[s]||0}const sy=()=>({translate:0,scale:1,origin:0,originPoint:0}),Fi=()=>({x:sy(),y:sy()}),ay=()=>({min:0,max:0}),Nt=()=>({x:ay(),y:ay()});function Bn(n){return[n("x"),n("y")]}function ox({top:n,left:s,right:i,bottom:o}){return{x:{min:s,max:i},y:{min:n,max:o}}}function OC({x:n,y:s}){return{top:s.min,right:n.max,bottom:s.max,left:n.min}}function IC(n,s){if(!s)return n;const i=s({x:n.left,y:n.top}),o=s({x:n.right,y:n.bottom});return{top:i.y,left:i.x,bottom:o.y,right:o.x}}function yf(n){return n===void 0||n===1}function np({scale:n,scaleX:s,scaleY:i}){return!yf(n)||!yf(s)||!yf(i)}function Ga(n){return np(n)||rx(n)||n.z||n.rotate||n.rotateX||n.rotateY||n.skewX||n.skewY}function rx(n){return iy(n.x)||iy(n.y)}function iy(n){return n&&n!=="0%"}function wc(n,s,i){const o=n-i,c=s*o;return i+c}function oy(n,s,i,o,c){return c!==void 0&&(n=wc(n,c,o)),wc(n,i,o)+s}function sp(n,s=0,i=1,o,c){n.min=oy(n.min,s,i,o,c),n.max=oy(n.max,s,i,o,c)}function lx(n,{x:s,y:i}){sp(n.x,s.translate,s.scale,s.originPoint),sp(n.y,i.translate,i.scale,i.originPoint)}const ry=.999999999999,ly=1.0000000000001;function BC(n,s,i,o=!1){const c=i.length;if(!c)return;s.x=s.y=1;let u,d;for(let m=0;m<c;m++){u=i[m],d=u.projectionDelta;const{visualElement:h}=u.options;h&&h.props.style&&h.props.style.display==="contents"||(o&&u.options.layoutScroll&&u.scroll&&u!==u.root&&Ki(n,{x:-u.scroll.offset.x,y:-u.scroll.offset.y}),d&&(s.x*=d.x.scale,s.y*=d.y.scale,lx(n,d)),o&&Ga(u.latestValues)&&Ki(n,u.latestValues))}s.x<ly&&s.x>ry&&(s.x=1),s.y<ly&&s.y>ry&&(s.y=1)}function Zi(n,s){n.min=n.min+s,n.max=n.max+s}function cy(n,s,i,o,c=.5){const u=vt(n.min,n.max,c);sp(n,s,i,u,o)}function Ki(n,s){cy(n.x,s.x,s.scaleX,s.scale,s.originX),cy(n.y,s.y,s.scaleY,s.scale,s.originY)}function cx(n,s){return ox(IC(n.getBoundingClientRect(),s))}function LC(n,s,i){const o=cx(n,i),{scroll:c}=s;return c&&(Zi(o.x,c.offset.x),Zi(o.y,c.offset.y)),o}const ux=({current:n})=>n?n.ownerDocument.defaultView:null,UC=new WeakMap;class zC{constructor(s){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Nt(),this.visualElement=s}start(s,{snapToCursor:i=!1}={}){const{presenceContext:o}=this.visualElement;if(o&&o.isPresent===!1)return;const c=v=>{const{dragSnapToOrigin:b}=this.getProps();b?this.pauseAnimation():this.stopAnimation(),i&&this.snapToCursor(Mr(v).point)},u=(v,b)=>{const{drag:_,dragPropagation:S,onDragStart:T}=this.getProps();if(_&&!S&&(this.openDragLock&&this.openDragLock(),this.openDragLock=vC(_),!this.openDragLock))return;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Bn(j=>{let w=this.getAxisMotionValue(j).get()||0;if(as.test(w)){const{projection:E}=this.visualElement;if(E&&E.layout){const A=E.layout.layoutBox[j];A&&(w=xn(A)*(parseFloat(w)/100))}}this.originPoint[j]=w}),T&&ft.postRender(()=>T(v,b)),$f(this.visualElement,"transform");const{animationState:N}=this.visualElement;N&&N.setActive("whileDrag",!0)},d=(v,b)=>{const{dragPropagation:_,dragDirectionLock:S,onDirectionLock:T,onDrag:N}=this.getProps();if(!_&&!this.openDragLock)return;const{offset:j}=b;if(S&&this.currentDirection===null){this.currentDirection=PC(j),this.currentDirection!==null&&T&&T(this.currentDirection);return}this.updateAxis("x",b.point,j),this.updateAxis("y",b.point,j),this.visualElement.render(),N&&N(v,b)},m=(v,b)=>this.stop(v,b),h=()=>Bn(v=>{var b;return this.getAnimationState(v)==="paused"&&((b=this.getAxisMotionValue(v).animation)===null||b===void 0?void 0:b.play())}),{dragSnapToOrigin:g}=this.getProps();this.panSession=new nx(s,{onSessionStart:c,onStart:u,onMove:d,onSessionEnd:m,resumeAnimation:h},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:g,contextWindow:ux(this.visualElement)})}stop(s,i){const o=this.isDragging;if(this.cancel(),!o)return;const{velocity:c}=i;this.startAnimation(c);const{onDragEnd:u}=this.getProps();u&&ft.postRender(()=>u(s,i))}cancel(){this.isDragging=!1;const{projection:s,animationState:i}=this.visualElement;s&&(s.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:o}=this.getProps();!o&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),i&&i.setActive("whileDrag",!1)}updateAxis(s,i,o){const{drag:c}=this.getProps();if(!o||!ac(s,c,this.currentDirection))return;const u=this.getAxisMotionValue(s);let d=this.originPoint[s]+o[s];this.constraints&&this.constraints[s]&&(d=CC(d,this.constraints[s],this.elastic[s])),u.set(d)}resolveConstraints(){var s;const{dragConstraints:i,dragElastic:o}=this.getProps(),c=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(s=this.visualElement.projection)===null||s===void 0?void 0:s.layout,u=this.constraints;i&&Gi(i)?this.constraints||(this.constraints=this.resolveRefConstraints()):i&&c?this.constraints=EC(c.layoutBox,i):this.constraints=!1,this.elastic=MC(o),u!==this.constraints&&c&&this.constraints&&!this.hasMutatedConstraints&&Bn(d=>{this.constraints!==!1&&this.getAxisMotionValue(d)&&(this.constraints[d]=RC(c.layoutBox[d],this.constraints[d]))})}resolveRefConstraints(){const{dragConstraints:s,onMeasureDragConstraints:i}=this.getProps();if(!s||!Gi(s))return!1;const o=s.current,{projection:c}=this.visualElement;if(!c||!c.layout)return!1;const u=LC(o,c.root,this.visualElement.getTransformPagePoint());let d=AC(c.layout.layoutBox,u);if(i){const m=i(OC(d));this.hasMutatedConstraints=!!m,m&&(d=ox(m))}return d}startAnimation(s){const{drag:i,dragMomentum:o,dragElastic:c,dragTransition:u,dragSnapToOrigin:d,onDragTransitionEnd:m}=this.getProps(),h=this.constraints||{},g=Bn(v=>{if(!ac(v,i,this.currentDirection))return;let b=h&&h[v]||{};d&&(b={min:0,max:0});const _=c?200:1e6,S=c?40:1e7,T={type:"inertia",velocity:o?s[v]:0,bounceStiffness:_,bounceDamping:S,timeConstant:750,restDelta:1,restSpeed:10,...u,...b};return this.startAxisValueAnimation(v,T)});return Promise.all(g).then(m)}startAxisValueAnimation(s,i){const o=this.getAxisMotionValue(s);return $f(this.visualElement,s),o.start(Qp(s,o,0,i,this.visualElement,!1))}stopAnimation(){Bn(s=>this.getAxisMotionValue(s).stop())}pauseAnimation(){Bn(s=>{var i;return(i=this.getAxisMotionValue(s).animation)===null||i===void 0?void 0:i.pause()})}getAnimationState(s){var i;return(i=this.getAxisMotionValue(s).animation)===null||i===void 0?void 0:i.state}getAxisMotionValue(s){const i=`_drag${s.toUpperCase()}`,o=this.visualElement.getProps(),c=o[i];return c||this.visualElement.getValue(s,(o.initial?o.initial[s]:void 0)||0)}snapToCursor(s){Bn(i=>{const{drag:o}=this.getProps();if(!ac(i,o,this.currentDirection))return;const{projection:c}=this.visualElement,u=this.getAxisMotionValue(i);if(c&&c.layout){const{min:d,max:m}=c.layout.layoutBox[i];u.set(s[i]-vt(d,m,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:s,dragConstraints:i}=this.getProps(),{projection:o}=this.visualElement;if(!Gi(i)||!o||!this.constraints)return;this.stopAnimation();const c={x:0,y:0};Bn(d=>{const m=this.getAxisMotionValue(d);if(m&&this.constraints!==!1){const h=m.get();c[d]=DC({min:h,max:h},this.constraints[d])}});const{transformTemplate:u}=this.visualElement.getProps();this.visualElement.current.style.transform=u?u({},""):"none",o.root&&o.root.updateScroll(),o.updateLayout(),this.resolveConstraints(),Bn(d=>{if(!ac(d,s,null))return;const m=this.getAxisMotionValue(d),{min:h,max:g}=this.constraints[d];m.set(vt(h,g,c[d]))})}addListeners(){if(!this.visualElement.current)return;UC.set(this.visualElement,this);const s=this.visualElement.current,i=gr(s,"pointerdown",h=>{const{drag:g,dragListener:v=!0}=this.getProps();g&&v&&this.start(h)}),o=()=>{const{dragConstraints:h}=this.getProps();Gi(h)&&h.current&&(this.constraints=this.resolveRefConstraints())},{projection:c}=this.visualElement,u=c.addEventListener("measure",o);c&&!c.layout&&(c.root&&c.root.updateScroll(),c.updateLayout()),ft.read(o);const d=Nr(window,"resize",()=>this.scalePositionWithinConstraints()),m=c.addEventListener("didUpdate",(({delta:h,hasLayoutChanged:g})=>{this.isDragging&&g&&(Bn(v=>{const b=this.getAxisMotionValue(v);b&&(this.originPoint[v]+=h[v].translate,b.set(b.get()+h[v].translate))}),this.visualElement.render())}));return()=>{d(),i(),u(),m&&m()}}getProps(){const s=this.visualElement.getProps(),{drag:i=!1,dragDirectionLock:o=!1,dragPropagation:c=!1,dragConstraints:u=!1,dragElastic:d=tp,dragMomentum:m=!0}=s;return{...s,drag:i,dragDirectionLock:o,dragPropagation:c,dragConstraints:u,dragElastic:d,dragMomentum:m}}}function ac(n,s,i){return(s===!0||s===n)&&(i===null||i===n)}function PC(n,s=10){let i=null;return Math.abs(n.y)>s?i="y":Math.abs(n.x)>s&&(i="x"),i}class VC extends ya{constructor(s){super(s),this.removeGroupControls=_n,this.removeListeners=_n,this.controls=new zC(s)}mount(){const{dragControls:s}=this.node.getProps();s&&(this.removeGroupControls=s.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||_n}unmount(){this.removeGroupControls(),this.removeListeners()}}const uy=n=>(s,i)=>{n&&ft.postRender(()=>n(s,i))};class qC extends ya{constructor(){super(...arguments),this.removePointerDownListener=_n}onPointerDown(s){this.session=new nx(s,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:ux(this.node)})}createPanHandlers(){const{onPanSessionStart:s,onPanStart:i,onPan:o,onPanEnd:c}=this.node.getProps();return{onSessionStart:uy(s),onStart:uy(i),onMove:o,onEnd:(u,d)=>{delete this.session,c&&ft.postRender(()=>c(u,d))}}}mount(){this.removePointerDownListener=gr(this.node.current,"pointerdown",s=>this.onPointerDown(s))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const hc={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function dy(n,s){return s.max===s.min?0:n/(s.max-s.min)*100}const or={correct:(n,s)=>{if(!s.target)return n;if(typeof n=="string")if(ke.test(n))n=parseFloat(n);else return n;const i=dy(n,s.target.x),o=dy(n,s.target.y);return`${i}% ${o}%`}},HC={correct:(n,{treeScale:s,projectionDelta:i})=>{const o=n,c=ha.parse(n);if(c.length>5)return o;const u=ha.createTransformer(n),d=typeof c[0]!="number"?1:0,m=i.x.scale*s.x,h=i.y.scale*s.y;c[0+d]/=m,c[1+d]/=h;const g=vt(m,h,.5);return typeof c[2+d]=="number"&&(c[2+d]/=g),typeof c[3+d]=="number"&&(c[3+d]/=g),u(c)}};class GC extends y.Component{componentDidMount(){const{visualElement:s,layoutGroup:i,switchLayoutGroup:o,layoutId:c}=this.props,{projection:u}=s;gN($C),u&&(i.group&&i.group.add(u),o&&o.register&&c&&o.register(u),u.root.didUpdate(),u.addEventListener("animationComplete",()=>{this.safeToRemove()}),u.setOptions({...u.options,onExitComplete:()=>this.safeToRemove()})),hc.hasEverUpdated=!0}getSnapshotBeforeUpdate(s){const{layoutDependency:i,visualElement:o,drag:c,isPresent:u}=this.props,d=o.projection;return d&&(d.isPresent=u,c||s.layoutDependency!==i||i===void 0?d.willUpdate():this.safeToRemove(),s.isPresent!==u&&(u?d.promote():d.relegate()||ft.postRender(()=>{const m=d.getStack();(!m||!m.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:s}=this.props.visualElement;s&&(s.root.didUpdate(),Cp.postRender(()=>{!s.currentAnimation&&s.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:s,layoutGroup:i,switchLayoutGroup:o}=this.props,{projection:c}=s;c&&(c.scheduleCheckAfterUnmount(),i&&i.group&&i.group.remove(c),o&&o.deregister&&o.deregister(c))}safeToRemove(){const{safeToRemove:s}=this.props;s&&s()}render(){return null}}function dx(n){const[s,i]=Yb(),o=y.useContext(xp);return l.jsx(GC,{...n,layoutGroup:o,switchLayoutGroup:y.useContext(s_),isPresent:s,safeToRemove:i})}const $C={borderRadius:{...or,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:or,borderTopRightRadius:or,borderBottomLeftRadius:or,borderBottomRightRadius:or,boxShadow:HC};function FC(n,s,i){const o=Xt(n)?n:kr(n);return o.start(Qp("",o,s,i)),o.animation}function ZC(n){return n instanceof SVGElement&&n.tagName!=="svg"}const KC=(n,s)=>n.depth-s.depth;class YC{constructor(){this.children=[],this.isDirty=!1}add(s){zp(this.children,s),this.isDirty=!0}remove(s){Pp(this.children,s),this.isDirty=!0}forEach(s){this.isDirty&&this.children.sort(KC),this.isDirty=!1,this.children.forEach(s)}}function JC(n,s){const i=is.now(),o=({timestamp:c})=>{const u=c-i;u>=s&&(ma(o),n(u-s))};return ft.read(o,!0),()=>ma(o)}const fx=["TopLeft","TopRight","BottomLeft","BottomRight"],WC=fx.length,fy=n=>typeof n=="string"?parseFloat(n):n,py=n=>typeof n=="number"||ke.test(n);function XC(n,s,i,o,c,u){c?(n.opacity=vt(0,i.opacity!==void 0?i.opacity:1,QC(o)),n.opacityExit=vt(s.opacity!==void 0?s.opacity:1,0,eE(o))):u&&(n.opacity=vt(s.opacity!==void 0?s.opacity:1,i.opacity!==void 0?i.opacity:1,o));for(let d=0;d<WC;d++){const m=`border${fx[d]}Radius`;let h=my(s,m),g=my(i,m);if(h===void 0&&g===void 0)continue;h||(h=0),g||(g=0),h===0||g===0||py(h)===py(g)?(n[m]=Math.max(vt(fy(h),fy(g),o),0),(as.test(g)||as.test(h))&&(n[m]+="%")):n[m]=g}(s.rotate||i.rotate)&&(n.rotate=vt(s.rotate||0,i.rotate||0,o))}function my(n,s){return n[s]!==void 0?n[s]:n.borderRadius}const QC=px(0,.5,E_),eE=px(.5,.95,_n);function px(n,s,i){return o=>o<n?0:o>s?1:i(to(n,s,o))}function hy(n,s){n.min=s.min,n.max=s.max}function On(n,s){hy(n.x,s.x),hy(n.y,s.y)}function gy(n,s){n.translate=s.translate,n.scale=s.scale,n.originPoint=s.originPoint,n.origin=s.origin}function vy(n,s,i,o,c){return n-=s,n=wc(n,1/i,o),c!==void 0&&(n=wc(n,1/c,o)),n}function tE(n,s=0,i=1,o=.5,c,u=n,d=n){if(as.test(s)&&(s=parseFloat(s),s=vt(d.min,d.max,s/100)-d.min),typeof s!="number")return;let m=vt(u.min,u.max,o);n===u&&(m-=s),n.min=vy(n.min,s,i,m,c),n.max=vy(n.max,s,i,m,c)}function yy(n,s,[i,o,c],u,d){tE(n,s[i],s[o],s[c],s.scale,u,d)}const nE=["x","scaleX","originX"],sE=["y","scaleY","originY"];function by(n,s,i,o){yy(n.x,s,nE,i?i.x:void 0,o?o.x:void 0),yy(n.y,s,sE,i?i.y:void 0,o?o.y:void 0)}function _y(n){return n.translate===0&&n.scale===1}function mx(n){return _y(n.x)&&_y(n.y)}function xy(n,s){return n.min===s.min&&n.max===s.max}function aE(n,s){return xy(n.x,s.x)&&xy(n.y,s.y)}function Sy(n,s){return Math.round(n.min)===Math.round(s.min)&&Math.round(n.max)===Math.round(s.max)}function hx(n,s){return Sy(n.x,s.x)&&Sy(n.y,s.y)}function Ty(n){return xn(n.x)/xn(n.y)}function ky(n,s){return n.translate===s.translate&&n.scale===s.scale&&n.originPoint===s.originPoint}class iE{constructor(){this.members=[]}add(s){zp(this.members,s),s.scheduleRender()}remove(s){if(Pp(this.members,s),s===this.prevLead&&(this.prevLead=void 0),s===this.lead){const i=this.members[this.members.length-1];i&&this.promote(i)}}relegate(s){const i=this.members.findIndex(c=>s===c);if(i===0)return!1;let o;for(let c=i;c>=0;c--){const u=this.members[c];if(u.isPresent!==!1){o=u;break}}return o?(this.promote(o),!0):!1}promote(s,i){const o=this.lead;if(s!==o&&(this.prevLead=o,this.lead=s,s.show(),o)){o.instance&&o.scheduleRender(),s.scheduleRender(),s.resumeFrom=o,i&&(s.resumeFrom.preserveOpacity=!0),o.snapshot&&(s.snapshot=o.snapshot,s.snapshot.latestValues=o.animationValues||o.latestValues),s.root&&s.root.isUpdating&&(s.isLayoutDirty=!0);const{crossfade:c}=s.options;c===!1&&o.hide()}}exitAnimationComplete(){this.members.forEach(s=>{const{options:i,resumingFrom:o}=s;i.onExitComplete&&i.onExitComplete(),o&&o.options.onExitComplete&&o.options.onExitComplete()})}scheduleRender(){this.members.forEach(s=>{s.instance&&s.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function oE(n,s,i){let o="";const c=n.x.translate/s.x,u=n.y.translate/s.y,d=(i==null?void 0:i.z)||0;if((c||u||d)&&(o=`translate3d(${c}px, ${u}px, ${d}px) `),(s.x!==1||s.y!==1)&&(o+=`scale(${1/s.x}, ${1/s.y}) `),i){const{transformPerspective:g,rotate:v,rotateX:b,rotateY:_,skewX:S,skewY:T}=i;g&&(o=`perspective(${g}px) ${o}`),v&&(o+=`rotate(${v}deg) `),b&&(o+=`rotateX(${b}deg) `),_&&(o+=`rotateY(${_}deg) `),S&&(o+=`skewX(${S}deg) `),T&&(o+=`skewY(${T}deg) `)}const m=n.x.scale*s.x,h=n.y.scale*s.y;return(m!==1||h!==1)&&(o+=`scale(${m}, ${h})`),o||"none"}const $a={type:"projectionFrame",totalNodes:0,resolvedTargetDeltas:0,recalculatedProjection:0},dr=typeof window<"u"&&window.MotionDebug!==void 0,bf=["","X","Y","Z"],rE={visibility:"hidden"},wy=1e3;let lE=0;function _f(n,s,i,o){const{latestValues:c}=s;c[n]&&(i[n]=c[n],s.setStaticValue(n,0),o&&(o[n]=0))}function gx(n){if(n.hasCheckedOptimisedAppear=!0,n.root===n)return;const{visualElement:s}=n.options;if(!s)return;const i=b_(s);if(window.MotionHasOptimisedAnimation(i,"transform")){const{layout:c,layoutId:u}=n.options;window.MotionCancelOptimisedAnimation(i,"transform",ft,!(c||u))}const{parent:o}=n;o&&!o.hasCheckedOptimisedAppear&&gx(o)}function vx({attachResizeListener:n,defaultParent:s,measureScroll:i,checkIsScrollRoot:o,resetTransform:c}){return class{constructor(d={},m=s==null?void 0:s()){this.id=lE++,this.animationId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,dr&&($a.totalNodes=$a.resolvedTargetDeltas=$a.recalculatedProjection=0),this.nodes.forEach(dE),this.nodes.forEach(gE),this.nodes.forEach(vE),this.nodes.forEach(fE),dr&&window.MotionDebug.record($a)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=d,this.root=m?m.root||m:this,this.path=m?[...m.path,m]:[],this.parent=m,this.depth=m?m.depth+1:0;for(let h=0;h<this.path.length;h++)this.path[h].shouldResetTransform=!0;this.root===this&&(this.nodes=new YC)}addEventListener(d,m){return this.eventHandlers.has(d)||this.eventHandlers.set(d,new Vp),this.eventHandlers.get(d).add(m)}notifyListeners(d,...m){const h=this.eventHandlers.get(d);h&&h.notify(...m)}hasListeners(d){return this.eventHandlers.has(d)}mount(d,m=this.root.hasTreeAnimated){if(this.instance)return;this.isSVG=ZC(d),this.instance=d;const{layoutId:h,layout:g,visualElement:v}=this.options;if(v&&!v.current&&v.mount(d),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),m&&(g||h)&&(this.isLayoutDirty=!0),n){let b;const _=()=>this.root.updateBlockedByResize=!1;n(d,()=>{this.root.updateBlockedByResize=!0,b&&b(),b=JC(_,250),hc.hasAnimatedSinceResize&&(hc.hasAnimatedSinceResize=!1,this.nodes.forEach(jy))})}h&&this.root.registerSharedNode(h,this),this.options.animate!==!1&&v&&(h||g)&&this.addEventListener("didUpdate",({delta:b,hasLayoutChanged:_,hasRelativeTargetChanged:S,layout:T})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const N=this.options.transition||v.getDefaultTransition()||SE,{onLayoutAnimationStart:j,onLayoutAnimationComplete:w}=v.getProps(),E=!this.targetLayout||!hx(this.targetLayout,T)||S,A=!_&&S;if(this.options.layoutRoot||this.resumeFrom&&this.resumeFrom.instance||A||_&&(E||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0),this.setAnimationOrigin(b,A);const O={...Up(N,"layout"),onPlay:j,onComplete:w};(v.shouldReduceMotion||this.options.layoutRoot)&&(O.delay=0,O.type=!1),this.startAnimation(O)}else _||jy(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=T})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const d=this.getStack();d&&d.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,ma(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(yE),this.animationId++)}getTransformTemplate(){const{visualElement:d}=this.options;return d&&d.getProps().transformTemplate}willUpdate(d=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&gx(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let v=0;v<this.path.length;v++){const b=this.path[v];b.shouldResetTransform=!0,b.updateScroll("snapshot"),b.options.layoutRoot&&b.willUpdate(!1)}const{layoutId:m,layout:h}=this.options;if(m===void 0&&!h)return;const g=this.getTransformTemplate();this.prevTransformTemplateValue=g?g(this.latestValues,""):void 0,this.updateSnapshot(),d&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Ny);return}this.isUpdating||this.nodes.forEach(mE),this.isUpdating=!1,this.nodes.forEach(hE),this.nodes.forEach(cE),this.nodes.forEach(uE),this.clearAllSnapshots();const m=is.now();Ft.delta=Is(0,1e3/60,m-Ft.timestamp),Ft.timestamp=m,Ft.isProcessing=!0,df.update.process(Ft),df.preRender.process(Ft),df.render.process(Ft),Ft.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Cp.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(pE),this.sharedNodes.forEach(bE)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,ft.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){ft.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure())}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let h=0;h<this.path.length;h++)this.path[h].updateScroll();const d=this.layout;this.layout=this.measure(!1),this.layoutCorrected=Nt(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:m}=this.options;m&&m.notify("LayoutMeasure",this.layout.layoutBox,d?d.layoutBox:void 0)}updateScroll(d="measure"){let m=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===d&&(m=!1),m){const h=o(this.instance);this.scroll={animationId:this.root.animationId,phase:d,isRoot:h,offset:i(this.instance),wasRoot:this.scroll?this.scroll.isRoot:h}}}resetTransform(){if(!c)return;const d=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,m=this.projectionDelta&&!mx(this.projectionDelta),h=this.getTransformTemplate(),g=h?h(this.latestValues,""):void 0,v=g!==this.prevTransformTemplateValue;d&&(m||Ga(this.latestValues)||v)&&(c(this.instance,g),this.shouldResetTransform=!1,this.scheduleRender())}measure(d=!0){const m=this.measurePageBox();let h=this.removeElementScroll(m);return d&&(h=this.removeTransform(h)),TE(h),{animationId:this.root.animationId,measuredBox:m,layoutBox:h,latestValues:{},source:this.id}}measurePageBox(){var d;const{visualElement:m}=this.options;if(!m)return Nt();const h=m.measureViewportBox();if(!(((d=this.scroll)===null||d===void 0?void 0:d.wasRoot)||this.path.some(kE))){const{scroll:v}=this.root;v&&(Zi(h.x,v.offset.x),Zi(h.y,v.offset.y))}return h}removeElementScroll(d){var m;const h=Nt();if(On(h,d),!((m=this.scroll)===null||m===void 0)&&m.wasRoot)return h;for(let g=0;g<this.path.length;g++){const v=this.path[g],{scroll:b,options:_}=v;v!==this.root&&b&&_.layoutScroll&&(b.wasRoot&&On(h,d),Zi(h.x,b.offset.x),Zi(h.y,b.offset.y))}return h}applyTransform(d,m=!1){const h=Nt();On(h,d);for(let g=0;g<this.path.length;g++){const v=this.path[g];!m&&v.options.layoutScroll&&v.scroll&&v!==v.root&&Ki(h,{x:-v.scroll.offset.x,y:-v.scroll.offset.y}),Ga(v.latestValues)&&Ki(h,v.latestValues)}return Ga(this.latestValues)&&Ki(h,this.latestValues),h}removeTransform(d){const m=Nt();On(m,d);for(let h=0;h<this.path.length;h++){const g=this.path[h];if(!g.instance||!Ga(g.latestValues))continue;np(g.latestValues)&&g.updateSnapshot();const v=Nt(),b=g.measurePageBox();On(v,b),by(m,g.latestValues,g.snapshot?g.snapshot.layoutBox:void 0,v)}return Ga(this.latestValues)&&by(m,this.latestValues),m}setTargetDelta(d){this.targetDelta=d,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(d){this.options={...this.options,...d,crossfade:d.crossfade!==void 0?d.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Ft.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(d=!1){var m;const h=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=h.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=h.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=h.isSharedProjectionDirty);const g=!!this.resumingFrom||this!==h;if(!(d||g&&this.isSharedProjectionDirty||this.isProjectionDirty||!((m=this.parent)===null||m===void 0)&&m.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:b,layoutId:_}=this.options;if(!(!this.layout||!(b||_))){if(this.resolvedRelativeTargetAt=Ft.timestamp,!this.targetDelta&&!this.relativeTarget){const S=this.getClosestProjectingParent();S&&S.layout&&this.animationProgress!==1?(this.relativeParent=S,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Nt(),this.relativeTargetOrigin=Nt(),yr(this.relativeTargetOrigin,this.layout.layoutBox,S.layout.layoutBox),On(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)){if(this.target||(this.target=Nt(),this.targetWithTransforms=Nt()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),jC(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):On(this.target,this.layout.layoutBox),lx(this.target,this.targetDelta)):On(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget){this.attemptToResolveRelativeTarget=!1;const S=this.getClosestProjectingParent();S&&!!S.resumingFrom==!!this.resumingFrom&&!S.options.layoutScroll&&S.target&&this.animationProgress!==1?(this.relativeParent=S,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Nt(),this.relativeTargetOrigin=Nt(),yr(this.relativeTargetOrigin,this.target,S.target),On(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}dr&&$a.resolvedTargetDeltas++}}}getClosestProjectingParent(){if(!(!this.parent||np(this.parent.latestValues)||rx(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){var d;const m=this.getLead(),h=!!this.resumingFrom||this!==m;let g=!0;if((this.isProjectionDirty||!((d=this.parent)===null||d===void 0)&&d.isProjectionDirty)&&(g=!1),h&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(g=!1),this.resolvedRelativeTargetAt===Ft.timestamp&&(g=!1),g)return;const{layout:v,layoutId:b}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(v||b))return;On(this.layoutCorrected,this.layout.layoutBox);const _=this.treeScale.x,S=this.treeScale.y;BC(this.layoutCorrected,this.treeScale,this.path,h),m.layout&&!m.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(m.target=m.layout.layoutBox,m.targetWithTransforms=Nt());const{target:T}=m;if(!T){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(gy(this.prevProjectionDelta.x,this.projectionDelta.x),gy(this.prevProjectionDelta.y,this.projectionDelta.y)),vr(this.projectionDelta,this.layoutCorrected,T,this.latestValues),(this.treeScale.x!==_||this.treeScale.y!==S||!ky(this.projectionDelta.x,this.prevProjectionDelta.x)||!ky(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",T)),dr&&$a.recalculatedProjection++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(d=!0){var m;if((m=this.options.visualElement)===null||m===void 0||m.scheduleRender(),d){const h=this.getStack();h&&h.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Fi(),this.projectionDelta=Fi(),this.projectionDeltaWithTransform=Fi()}setAnimationOrigin(d,m=!1){const h=this.snapshot,g=h?h.latestValues:{},v={...this.latestValues},b=Fi();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!m;const _=Nt(),S=h?h.source:void 0,T=this.layout?this.layout.source:void 0,N=S!==T,j=this.getStack(),w=!j||j.members.length<=1,E=!!(N&&!w&&this.options.crossfade===!0&&!this.path.some(xE));this.animationProgress=0;let A;this.mixTargetDelta=O=>{const C=O/1e3;Cy(b.x,d.x,C),Cy(b.y,d.y,C),this.setTargetDelta(b),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(yr(_,this.layout.layoutBox,this.relativeParent.layout.layoutBox),_E(this.relativeTarget,this.relativeTargetOrigin,_,C),A&&aE(this.relativeTarget,A)&&(this.isProjectionDirty=!1),A||(A=Nt()),On(A,this.relativeTarget)),N&&(this.animationValues=v,XC(v,g,this.latestValues,C,E,w)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=C},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(d){this.notifyListeners("animationStart"),this.currentAnimation&&this.currentAnimation.stop(),this.resumingFrom&&this.resumingFrom.currentAnimation&&this.resumingFrom.currentAnimation.stop(),this.pendingAnimation&&(ma(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=ft.update(()=>{hc.hasAnimatedSinceResize=!0,this.currentAnimation=FC(0,wy,{...d,onUpdate:m=>{this.mixTargetDelta(m),d.onUpdate&&d.onUpdate(m)},onComplete:()=>{d.onComplete&&d.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const d=this.getStack();d&&d.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(wy),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const d=this.getLead();let{targetWithTransforms:m,target:h,layout:g,latestValues:v}=d;if(!(!m||!h||!g)){if(this!==d&&this.layout&&g&&yx(this.options.animationType,this.layout.layoutBox,g.layoutBox)){h=this.target||Nt();const b=xn(this.layout.layoutBox.x);h.x.min=d.target.x.min,h.x.max=h.x.min+b;const _=xn(this.layout.layoutBox.y);h.y.min=d.target.y.min,h.y.max=h.y.min+_}On(m,h),Ki(m,v),vr(this.projectionDeltaWithTransform,this.layoutCorrected,m,v)}}registerSharedNode(d,m){this.sharedNodes.has(d)||this.sharedNodes.set(d,new iE),this.sharedNodes.get(d).add(m);const g=m.options.initialPromotionConfig;m.promote({transition:g?g.transition:void 0,preserveFollowOpacity:g&&g.shouldPreserveFollowOpacity?g.shouldPreserveFollowOpacity(m):void 0})}isLead(){const d=this.getStack();return d?d.lead===this:!0}getLead(){var d;const{layoutId:m}=this.options;return m?((d=this.getStack())===null||d===void 0?void 0:d.lead)||this:this}getPrevLead(){var d;const{layoutId:m}=this.options;return m?(d=this.getStack())===null||d===void 0?void 0:d.prevLead:void 0}getStack(){const{layoutId:d}=this.options;if(d)return this.root.sharedNodes.get(d)}promote({needsReset:d,transition:m,preserveFollowOpacity:h}={}){const g=this.getStack();g&&g.promote(this,h),d&&(this.projectionDelta=void 0,this.needsReset=!0),m&&this.setOptions({transition:m})}relegate(){const d=this.getStack();return d?d.relegate(this):!1}resetSkewAndRotation(){const{visualElement:d}=this.options;if(!d)return;let m=!1;const{latestValues:h}=d;if((h.z||h.rotate||h.rotateX||h.rotateY||h.rotateZ||h.skewX||h.skewY)&&(m=!0),!m)return;const g={};h.z&&_f("z",d,g,this.animationValues);for(let v=0;v<bf.length;v++)_f(`rotate${bf[v]}`,d,g,this.animationValues),_f(`skew${bf[v]}`,d,g,this.animationValues);d.render();for(const v in g)d.setStaticValue(v,g[v]),this.animationValues&&(this.animationValues[v]=g[v]);d.scheduleRender()}getProjectionStyles(d){var m,h;if(!this.instance||this.isSVG)return;if(!this.isVisible)return rE;const g={visibility:""},v=this.getTransformTemplate();if(this.needsReset)return this.needsReset=!1,g.opacity="",g.pointerEvents=pc(d==null?void 0:d.pointerEvents)||"",g.transform=v?v(this.latestValues,""):"none",g;const b=this.getLead();if(!this.projectionDelta||!this.layout||!b.target){const N={};return this.options.layoutId&&(N.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,N.pointerEvents=pc(d==null?void 0:d.pointerEvents)||""),this.hasProjected&&!Ga(this.latestValues)&&(N.transform=v?v({},""):"none",this.hasProjected=!1),N}const _=b.animationValues||b.latestValues;this.applyTransformsToTarget(),g.transform=oE(this.projectionDeltaWithTransform,this.treeScale,_),v&&(g.transform=v(_,g.transform));const{x:S,y:T}=this.projectionDelta;g.transformOrigin=`${S.origin*100}% ${T.origin*100}% 0`,b.animationValues?g.opacity=b===this?(h=(m=_.opacity)!==null&&m!==void 0?m:this.latestValues.opacity)!==null&&h!==void 0?h:1:this.preserveOpacity?this.latestValues.opacity:_.opacityExit:g.opacity=b===this?_.opacity!==void 0?_.opacity:"":_.opacityExit!==void 0?_.opacityExit:0;for(const N in _c){if(_[N]===void 0)continue;const{correct:j,applyTo:w}=_c[N],E=g.transform==="none"?_[N]:j(_[N],b);if(w){const A=w.length;for(let O=0;O<A;O++)g[w[O]]=E}else g[N]=E}return this.options.layoutId&&(g.pointerEvents=b===this?pc(d==null?void 0:d.pointerEvents)||"":"none"),g}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(d=>{var m;return(m=d.currentAnimation)===null||m===void 0?void 0:m.stop()}),this.root.nodes.forEach(Ny),this.root.sharedNodes.clear()}}}function cE(n){n.updateLayout()}function uE(n){var s;const i=((s=n.resumeFrom)===null||s===void 0?void 0:s.snapshot)||n.snapshot;if(n.isLead()&&n.layout&&i&&n.hasListeners("didUpdate")){const{layoutBox:o,measuredBox:c}=n.layout,{animationType:u}=n.options,d=i.source!==n.layout.source;u==="size"?Bn(b=>{const _=d?i.measuredBox[b]:i.layoutBox[b],S=xn(_);_.min=o[b].min,_.max=_.min+S}):yx(u,i.layoutBox,o)&&Bn(b=>{const _=d?i.measuredBox[b]:i.layoutBox[b],S=xn(o[b]);_.max=_.min+S,n.relativeTarget&&!n.currentAnimation&&(n.isProjectionDirty=!0,n.relativeTarget[b].max=n.relativeTarget[b].min+S)});const m=Fi();vr(m,o,i.layoutBox);const h=Fi();d?vr(h,n.applyTransform(c,!0),i.measuredBox):vr(h,o,i.layoutBox);const g=!mx(m);let v=!1;if(!n.resumeFrom){const b=n.getClosestProjectingParent();if(b&&!b.resumeFrom){const{snapshot:_,layout:S}=b;if(_&&S){const T=Nt();yr(T,i.layoutBox,_.layoutBox);const N=Nt();yr(N,o,S.layoutBox),hx(T,N)||(v=!0),b.options.layoutRoot&&(n.relativeTarget=N,n.relativeTargetOrigin=T,n.relativeParent=b)}}}n.notifyListeners("didUpdate",{layout:o,snapshot:i,delta:h,layoutDelta:m,hasLayoutChanged:g,hasRelativeTargetChanged:v})}else if(n.isLead()){const{onExitComplete:o}=n.options;o&&o()}n.options.transition=void 0}function dE(n){dr&&$a.totalNodes++,n.parent&&(n.isProjecting()||(n.isProjectionDirty=n.parent.isProjectionDirty),n.isSharedProjectionDirty||(n.isSharedProjectionDirty=!!(n.isProjectionDirty||n.parent.isProjectionDirty||n.parent.isSharedProjectionDirty)),n.isTransformDirty||(n.isTransformDirty=n.parent.isTransformDirty))}function fE(n){n.isProjectionDirty=n.isSharedProjectionDirty=n.isTransformDirty=!1}function pE(n){n.clearSnapshot()}function Ny(n){n.clearMeasurements()}function mE(n){n.isLayoutDirty=!1}function hE(n){const{visualElement:s}=n.options;s&&s.getProps().onBeforeLayoutMeasure&&s.notify("BeforeLayoutMeasure"),n.resetTransform()}function jy(n){n.finishAnimation(),n.targetDelta=n.relativeTarget=n.target=void 0,n.isProjectionDirty=!0}function gE(n){n.resolveTargetDelta()}function vE(n){n.calcProjection()}function yE(n){n.resetSkewAndRotation()}function bE(n){n.removeLeadSnapshot()}function Cy(n,s,i){n.translate=vt(s.translate,0,i),n.scale=vt(s.scale,1,i),n.origin=s.origin,n.originPoint=s.originPoint}function Ey(n,s,i,o){n.min=vt(s.min,i.min,o),n.max=vt(s.max,i.max,o)}function _E(n,s,i,o){Ey(n.x,s.x,i.x,o),Ey(n.y,s.y,i.y,o)}function xE(n){return n.animationValues&&n.animationValues.opacityExit!==void 0}const SE={duration:.45,ease:[.4,0,.1,1]},Ay=n=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(n),Dy=Ay("applewebkit/")&&!Ay("chrome/")?Math.round:_n;function Ry(n){n.min=Dy(n.min),n.max=Dy(n.max)}function TE(n){Ry(n.x),Ry(n.y)}function yx(n,s,i){return n==="position"||n==="preserve-aspect"&&!NC(Ty(s),Ty(i),.2)}function kE(n){var s;return n!==n.root&&((s=n.scroll)===null||s===void 0?void 0:s.wasRoot)}const wE=vx({attachResizeListener:(n,s)=>Nr(n,"resize",s),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),xf={current:void 0},bx=vx({measureScroll:n=>({x:n.scrollLeft,y:n.scrollTop}),defaultParent:()=>{if(!xf.current){const n=new wE({});n.mount(window),n.setOptions({layoutScroll:!0}),xf.current=n}return xf.current},resetTransform:(n,s)=>{n.style.transform=s!==void 0?s:"none"},checkIsScrollRoot:n=>window.getComputedStyle(n).position==="fixed"}),NE={pan:{Feature:qC},drag:{Feature:VC,ProjectionNode:bx,MeasureLayout:dx}};function jE(n,s,i){var o;if(n instanceof Element)return[n];if(typeof n=="string"){let c=document;const u=(o=void 0)!==null&&o!==void 0?o:c.querySelectorAll(n);return u?Array.from(u):[]}return Array.from(n)}function _x(n,s){const i=jE(n),o=new AbortController,c={passive:!0,...s,signal:o.signal};return[i,c,()=>o.abort()]}function My(n){return s=>{s.pointerType==="touch"||tx()||n(s)}}function CE(n,s,i={}){const[o,c,u]=_x(n,i),d=My(m=>{const{target:h}=m,g=s(m);if(typeof g!="function"||!h)return;const v=My(b=>{g(b),h.removeEventListener("pointerleave",v)});h.addEventListener("pointerleave",v,c)});return o.forEach(m=>{m.addEventListener("pointerenter",d,c)}),u}function Oy(n,s,i){const{props:o}=n;n.animationState&&o.whileHover&&n.animationState.setActive("whileHover",i==="Start");const c="onHover"+i,u=o[c];u&&ft.postRender(()=>u(s,Mr(s)))}class EE extends ya{mount(){const{current:s}=this.node;s&&(this.unmount=CE(s,i=>(Oy(this.node,i,"Start"),o=>Oy(this.node,o,"End"))))}unmount(){}}class AE extends ya{constructor(){super(...arguments),this.isActive=!1}onFocus(){let s=!1;try{s=this.node.current.matches(":focus-visible")}catch{s=!0}!s||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Rr(Nr(this.node.current,"focus",()=>this.onFocus()),Nr(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}const xx=(n,s)=>s?n===s?!0:xx(n,s.parentElement):!1,DE=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function RE(n){return DE.has(n.tagName)||n.tabIndex!==-1}const fr=new WeakSet;function Iy(n){return s=>{s.key==="Enter"&&n(s)}}function Sf(n,s){n.dispatchEvent(new PointerEvent("pointer"+s,{isPrimary:!0,bubbles:!0}))}const ME=(n,s)=>{const i=n.currentTarget;if(!i)return;const o=Iy(()=>{if(fr.has(i))return;Sf(i,"down");const c=Iy(()=>{Sf(i,"up")}),u=()=>Sf(i,"cancel");i.addEventListener("keyup",c,s),i.addEventListener("blur",u,s)});i.addEventListener("keydown",o,s),i.addEventListener("blur",()=>i.removeEventListener("keydown",o),s)};function By(n){return em(n)&&!tx()}function OE(n,s,i={}){const[o,c,u]=_x(n,i),d=m=>{const h=m.currentTarget;if(!By(m)||fr.has(h))return;fr.add(h);const g=s(m),v=(S,T)=>{window.removeEventListener("pointerup",b),window.removeEventListener("pointercancel",_),!(!By(S)||!fr.has(h))&&(fr.delete(h),typeof g=="function"&&g(S,{success:T}))},b=S=>{v(S,i.useGlobalTarget||xx(h,S.target))},_=S=>{v(S,!1)};window.addEventListener("pointerup",b,c),window.addEventListener("pointercancel",_,c)};return o.forEach(m=>{!RE(m)&&m.getAttribute("tabindex")===null&&(m.tabIndex=0),(i.useGlobalTarget?window:m).addEventListener("pointerdown",d,c),m.addEventListener("focus",g=>ME(g,c),c)}),u}function Ly(n,s,i){const{props:o}=n;n.animationState&&o.whileTap&&n.animationState.setActive("whileTap",i==="Start");const c="onTap"+(i==="End"?"":i),u=o[c];u&&ft.postRender(()=>u(s,Mr(s)))}class IE extends ya{mount(){const{current:s}=this.node;s&&(this.unmount=OE(s,i=>(Ly(this.node,i,"Start"),(o,{success:c})=>Ly(this.node,o,c?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const ap=new WeakMap,Tf=new WeakMap,BE=n=>{const s=ap.get(n.target);s&&s(n)},LE=n=>{n.forEach(BE)};function UE({root:n,...s}){const i=n||document;Tf.has(i)||Tf.set(i,{});const o=Tf.get(i),c=JSON.stringify(s);return o[c]||(o[c]=new IntersectionObserver(LE,{root:n,...s})),o[c]}function zE(n,s,i){const o=UE(s);return ap.set(n,i),o.observe(n),()=>{ap.delete(n),o.unobserve(n)}}const PE={some:0,all:1};class VE extends ya{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:s={}}=this.node.getProps(),{root:i,margin:o,amount:c="some",once:u}=s,d={root:i?i.current:void 0,rootMargin:o,threshold:typeof c=="number"?c:PE[c]},m=h=>{const{isIntersecting:g}=h;if(this.isInView===g||(this.isInView=g,u&&!g&&this.hasEnteredView))return;g&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",g);const{onViewportEnter:v,onViewportLeave:b}=this.node.getProps(),_=g?v:b;_&&_(h)};return zE(this.node.current,d,m)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:s,prevProps:i}=this.node;["amount","margin","root"].some(qE(s,i))&&this.startObserver()}unmount(){}}function qE({viewport:n={}},{viewport:s={}}={}){return i=>n[i]!==s[i]}const HE={inView:{Feature:VE},tap:{Feature:IE},focus:{Feature:AE},hover:{Feature:EE}},GE={layout:{ProjectionNode:bx,MeasureLayout:dx}},Nc={current:null},tm={current:!1};function Sx(){if(tm.current=!0,!!kp)if(window.matchMedia){const n=window.matchMedia("(prefers-reduced-motion)"),s=()=>Nc.current=n.matches;n.addListener(s),s()}else Nc.current=!1}const $E=[...H_,Wt,ha],FE=n=>$E.find(q_(n)),Uy=new WeakMap;function ZE(n,s,i){for(const o in s){const c=s[o],u=i[o];if(Xt(c))n.addValue(o,c);else if(Xt(u))n.addValue(o,kr(c,{owner:n}));else if(u!==c)if(n.hasValue(o)){const d=n.getValue(o);d.liveStyle===!0?d.jump(c):d.hasAnimated||d.set(c)}else{const d=n.getStaticValue(o);n.addValue(o,kr(d!==void 0?d:c,{owner:n}))}}for(const o in i)s[o]===void 0&&n.removeValue(o);return s}const zy=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class KE{scrapeMotionValuesFromProps(s,i,o){return{}}constructor({parent:s,props:i,presenceContext:o,reducedMotionConfig:c,blockInitialAnimation:u,visualState:d},m={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=Jp,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const S=is.now();this.renderScheduledAt<S&&(this.renderScheduledAt=S,ft.render(this.render,!1,!0))};const{latestValues:h,renderState:g,onUpdate:v}=d;this.onUpdate=v,this.latestValues=h,this.baseTarget={...h},this.initialValues=i.initial?{...h}:{},this.renderState=g,this.parent=s,this.props=i,this.presenceContext=o,this.depth=s?s.depth+1:0,this.reducedMotionConfig=c,this.options=m,this.blockInitialAnimation=!!u,this.isControllingVariants=zc(i),this.isVariantNode=t_(i),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(s&&s.current);const{willChange:b,..._}=this.scrapeMotionValuesFromProps(i,{},this);for(const S in _){const T=_[S];h[S]!==void 0&&Xt(T)&&T.set(h[S],!1)}}mount(s){this.current=s,Uy.set(s,this),this.projection&&!this.projection.instance&&this.projection.mount(s),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((i,o)=>this.bindToMotionValue(o,i)),tm.current||Sx(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:Nc.current,this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){Uy.delete(this.current),this.projection&&this.projection.unmount(),ma(this.notifyUpdate),ma(this.render),this.valueSubscriptions.forEach(s=>s()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(const s in this.events)this.events[s].clear();for(const s in this.features){const i=this.features[s];i&&(i.unmount(),i.isMounted=!1)}this.current=null}bindToMotionValue(s,i){this.valueSubscriptions.has(s)&&this.valueSubscriptions.get(s)();const o=ti.has(s),c=i.on("change",m=>{this.latestValues[s]=m,this.props.onUpdate&&ft.preRender(this.notifyUpdate),o&&this.projection&&(this.projection.isTransformDirty=!0)}),u=i.on("renderRequest",this.scheduleRender);let d;window.MotionCheckAppearSync&&(d=window.MotionCheckAppearSync(this,s,i)),this.valueSubscriptions.set(s,()=>{c(),u(),d&&d(),i.owner&&i.stop()})}sortNodePosition(s){return!this.current||!this.sortInstanceNodePosition||this.type!==s.type?0:this.sortInstanceNodePosition(this.current,s.current)}updateFeatures(){let s="animation";for(s in eo){const i=eo[s];if(!i)continue;const{isEnabled:o,Feature:c}=i;if(!this.features[s]&&c&&o(this.props)&&(this.features[s]=new c(this)),this.features[s]){const u=this.features[s];u.isMounted?u.update():(u.mount(),u.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Nt()}getStaticValue(s){return this.latestValues[s]}setStaticValue(s,i){this.latestValues[s]=i}update(s,i){(s.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=s,this.prevPresenceContext=this.presenceContext,this.presenceContext=i;for(let o=0;o<zy.length;o++){const c=zy[o];this.propEventSubscriptions[c]&&(this.propEventSubscriptions[c](),delete this.propEventSubscriptions[c]);const u="on"+c,d=s[u];d&&(this.propEventSubscriptions[c]=this.on(c,d))}this.prevMotionValues=ZE(this,this.scrapeMotionValuesFromProps(s,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue(),this.onUpdate&&this.onUpdate(this)}getProps(){return this.props}getVariant(s){return this.props.variants?this.props.variants[s]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(s){const i=this.getClosestVariantNode();if(i)return i.variantChildren&&i.variantChildren.add(s),()=>i.variantChildren.delete(s)}addValue(s,i){const o=this.values.get(s);i!==o&&(o&&this.removeValue(s),this.bindToMotionValue(s,i),this.values.set(s,i),this.latestValues[s]=i.get())}removeValue(s){this.values.delete(s);const i=this.valueSubscriptions.get(s);i&&(i(),this.valueSubscriptions.delete(s)),delete this.latestValues[s],this.removeValueFromRenderState(s,this.renderState)}hasValue(s){return this.values.has(s)}getValue(s,i){if(this.props.values&&this.props.values[s])return this.props.values[s];let o=this.values.get(s);return o===void 0&&i!==void 0&&(o=kr(i===null?void 0:i,{owner:this}),this.addValue(s,o)),o}readValue(s,i){var o;let c=this.latestValues[s]!==void 0||!this.current?this.latestValues[s]:(o=this.getBaseTargetFromProps(this.props,s))!==null&&o!==void 0?o:this.readValueFromInstance(this.current,s,this.options);return c!=null&&(typeof c=="string"&&(P_(c)||D_(c))?c=parseFloat(c):!FE(c)&&ha.test(i)&&(c=L_(s,i)),this.setBaseTarget(s,Xt(c)?c.get():c)),Xt(c)?c.get():c}setBaseTarget(s,i){this.baseTarget[s]=i}getBaseTarget(s){var i;const{initial:o}=this.props;let c;if(typeof o=="string"||typeof o=="object"){const d=Ap(this.props,o,(i=this.presenceContext)===null||i===void 0?void 0:i.custom);d&&(c=d[s])}if(o&&c!==void 0)return c;const u=this.getBaseTargetFromProps(this.props,s);return u!==void 0&&!Xt(u)?u:this.initialValues[s]!==void 0&&c===void 0?void 0:this.baseTarget[s]}on(s,i){return this.events[s]||(this.events[s]=new Vp),this.events[s].add(i)}notify(s,...i){this.events[s]&&this.events[s].notify(...i)}}class Tx extends KE{constructor(){super(...arguments),this.KeyframeResolver=G_}sortInstanceNodePosition(s,i){return s.compareDocumentPosition(i)&2?1:-1}getBaseTargetFromProps(s,i){return s.style?s.style[i]:void 0}removeValueFromRenderState(s,{vars:i,style:o}){delete i[s],delete o[s]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:s}=this.props;Xt(s)&&(this.childSubscription=s.on("change",i=>{this.current&&(this.current.textContent=`${i}`)}))}}function YE(n){return window.getComputedStyle(n)}class JE extends Tx{constructor(){super(...arguments),this.type="html",this.renderInstance=u_}readValueFromInstance(s,i){if(ti.has(i)){const o=Yp(i);return o&&o.default||0}else{const o=YE(s),c=(r_(i)?o.getPropertyValue(i):o[i])||0;return typeof c=="string"?c.trim():c}}measureInstanceViewportBox(s,{transformPagePoint:i}){return cx(s,i)}build(s,i,o){Mp(s,i,o.transformTemplate)}scrapeMotionValuesFromProps(s,i,o){return Lp(s,i,o)}}class WE extends Tx{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Nt}getBaseTargetFromProps(s,i){return s[i]}readValueFromInstance(s,i){if(ti.has(i)){const o=Yp(i);return o&&o.default||0}return i=d_.has(i)?i:jp(i),s.getAttribute(i)}scrapeMotionValuesFromProps(s,i,o){return m_(s,i,o)}build(s,i,o){Op(s,i,this.isSVGTag,o.transformTemplate)}renderInstance(s,i,o,c){f_(s,i,o,c)}mount(s){this.isSVGTag=Bp(s.tagName),super.mount(s)}}const XE=(n,s)=>Ep(n)?new WE(s):new JE(s,{allowProjection:n!==y.Fragment}),QE=wN({...gC,...HE,...NE,...GE},XE),Rt=Pw(QE);function eA(){!tm.current&&Sx();const[n]=y.useState(Nc.current);return n}const ip={not_started:{color:"var(--text-tertiary)",icon:"○",label:"Not Started"},working:{color:"var(--accent-green)",icon:"●",label:"Working"},paused:{color:"var(--accent-yellow)",icon:"◉",label:"Paused"},complete:{color:"var(--accent-green)",icon:"✓",label:"Complete"},failed:{color:"var(--accent-red)",icon:"✗",label:"Failed"},blocked:{color:"var(--accent-yellow)",icon:"⦸",label:"Blocked"}};function ga(n){return n==="blocked"?ip.blocked:ip[nm(n)]}const tA={not_started:"statusPending",working:"statusInProgress",paused:"statusWaitingInput",complete:"statusDone",failed:"statusFailed"};function nA(n){return tA[nm(n)]??"statusPending"}const sA=["working","paused","failed","not_started","blocked","complete"],Py=["not_started","working","paused","complete","failed"],aA={pending:"not_started",assigned:"not_started",in_progress:"working",waiting_input:"paused",review:"paused",done:"complete"};function nm(n){return n in ip&&n!=="blocked"?n:aA[n]??"not_started"}const iA={not_started:"--text-tertiary",working:"--accent-green",paused:"--accent-yellow",complete:"--accent-green",failed:"--accent-red",pending:"--text-tertiary",assigned:"--text-tertiary",in_progress:"--accent-green",review:"--accent-yellow",done:"--accent-green",waiting_input:"--accent-yellow"};function oA(n){if(n.length===0)return[];const s=[...n].sort((o,c)=>o[0]-c[0]),i=[[s[0][0],s[0][1]]];for(let o=1;o<s.length;o++){const c=i[i.length-1],[u,d]=s[o];u<=c[1]+1?c[1]=Math.max(c[1],d):i.push([u,d])}return i}function kx({text:n,indices:s,highlightClass:i}){if(!s||s.length===0)return l.jsx(l.Fragment,{children:n});const o=oA(s),c=[];let u=0;for(const[d,m]of o)d>u&&c.push(l.jsx("span",{children:n.slice(u,d)},`p${u}`)),c.push(l.jsx("mark",{className:i,children:n.slice(d,m+1)},`m${d}`)),u=m+1;return u<n.length&&c.push(l.jsx("span",{children:n.slice(u)},`p${u}`)),l.jsx(l.Fragment,{children:c})}function rA(n){const s=new Map(n.map(o=>[o.id,{...o,children:[]}])),i=[];for(const o of s.values())o.parentTaskId&&s.has(o.parentTaskId)?s.get(o.parentTaskId).children.push(o):i.push(o);for(const o of s.values())o.children.sort((c,u)=>c.sortOrder-u.sortOrder);return i.sort((o,c)=>o.sortOrder-c.sortOrder)}function lA(n,s){const i=new Map;for(const u of n){const m=u.dependsOn.length>0&&u.dependsOn.some(g=>s.get(g)!=="complete")?"blocked":u.status,h=i.get(m);h?h.push(u):i.set(m,[u])}const o=[],c=new Set;for(const u of sA){c.add(u);const d=i.get(u);if(d&&d.length>0){d.sort((h,g)=>h.sortOrder-g.sortOrder);const m=ga(u);o.push({status:u,label:m.label,style:m,tasks:d})}}for(const[u,d]of i)if(!c.has(u)&&d.length>0){d.sort((h,g)=>h.sortOrder-g.sortOrder);const m=ga(u);o.push({status:u,label:m.label,style:m,tasks:d})}return o}const cA="_container_z4i38_1",uA="_header_z4i38_5",dA="_headerActions_z4i38_17",fA="_searchInput_z4i38_23",pA="_searchHighlight_z4i38_56",mA="_groupToggle_z4i38_62",hA="_groupToggleActive_z4i38_89",gA="_addButton_z4i38_93",vA="_taskRow_z4i38_120",yA="_selected_z4i38_140",bA="_expandArrow_z4i38_150",_A="_expanded_z4i38_157",xA="_leafSpacer_z4i38_161",SA="_taskStatusIcon_z4i38_166",TA="_taskTitle_z4i38_170",kA="_workspaceBadge_z4i38_177",wA="_childCountBadge_z4i38_195",NA="_dependencyBadge_z4i38_208",jA="_blockedBadge_z4i38_220",CA="_addChildButton_z4i38_225",EA="_emptyState_z4i38_268",AA="_statusGroupHeader_z4i38_275",DA="_statusGroupIcon_z4i38_294",RA="_statusGroupLabel_z4i38_298",MA="_statusGroupCount_z4i38_303",Fe={container:cA,header:uA,headerActions:dA,searchInput:fA,searchHighlight:pA,groupToggle:mA,groupToggleActive:hA,addButton:gA,taskRow:vA,selected:yA,expandArrow:bA,expanded:_A,leafSpacer:xA,taskStatusIcon:SA,taskTitle:TA,workspaceBadge:kA,childCountBadge:wA,dependencyBadge:NA,blockedBadge:jA,addChildButton:CA,emptyState:EA,statusGroupHeader:AA,statusGroupIcon:DA,statusGroupLabel:RA,statusGroupCount:MA},OA=[{name:"title",weight:2},{name:"description",weight:1}],wx=16,IA=16,Nx="grackle-task-group-by-status";function Vy(){try{return localStorage.getItem(Nx)==="true"}catch{return!1}}function BA(n){try{localStorage.setItem(Nx,String(n))}catch{}}function LA({group:n,isExpanded:s,onToggle:i,selectedTaskId:o,navigate:c,titleHighlights:u,workspaceNames:d}){return l.jsxs("div",{"data-testid":`status-group-${n.status}`,children:[l.jsxs("div",{className:Fe.statusGroupHeader,role:"button",tabIndex:0,"aria-expanded":s,onClick:i,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),i())},children:[l.jsx("span",{className:`${Fe.expandArrow} ${s?Fe.expanded:""}`,children:"▸"}),l.jsx("span",{className:Fe.statusGroupIcon,style:{color:n.style.color},children:n.style.icon}),l.jsx("span",{className:Fe.statusGroupLabel,children:n.label}),l.jsx("span",{className:Fe.statusGroupCount,children:n.tasks.length})]}),l.jsx(rs,{children:s&&l.jsx(Rt.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},style:{overflow:"hidden"},children:n.tasks.map(m=>{const h=ga(m.status),g=o===m.id,v=m.parentTaskId||!m.workspaceId?void 0:d.get(m.workspaceId);return l.jsxs("div",{onClick:()=>c(os(m.id)),className:`${Fe.taskRow} ${g?Fe.selected:""}`,style:{"--task-indent":`${wx}px`},"data-task-id":m.id,children:[l.jsx("span",{className:Fe.leafSpacer}),l.jsx("span",{className:Fe.taskStatusIcon,style:{color:h.color},children:h.icon}),l.jsx("span",{className:Fe.taskTitle,title:m.title,children:l.jsx(kx,{text:m.title,indices:u.get(m.id),highlightClass:Fe.searchHighlight})}),v&&l.jsx("span",{className:Fe.workspaceBadge,title:v,children:v})]},m.id)})})})]})}function jx({node:n,depth:s,expandedTasks:i,toggleTask:o,selectedTaskId:c,navigate:u,taskStatusById:d,titleHighlights:m,workspaceNames:h}){const g=ga(n.status),v=n.dependsOn.length>0&&n.dependsOn.some(w=>d.get(w)!=="complete"),b=i.has(n.id),_=n.children.length>0,S=c===n.id,T=wx+s*IA,j=s===0&&!n.parentTaskId&&n.workspaceId?h.get(n.workspaceId):void 0;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{onClick:()=>u(os(n.id)),className:`${Fe.taskRow} ${S?Fe.selected:""}`,style:{"--task-indent":`${T}px`},"data-task-id":n.id,children:[_&&l.jsx("span",{className:`${Fe.expandArrow} ${b?Fe.expanded:""}`,role:"button",tabIndex:0,"aria-label":b?"Collapse task":"Expand task",onClick:w=>{w.stopPropagation(),o(n.id)},onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),w.stopPropagation(),o(n.id))},children:"▸"}),!_&&l.jsx("span",{className:Fe.leafSpacer}),l.jsx("span",{className:Fe.taskStatusIcon,style:{color:g.color},children:g.icon}),l.jsx("span",{className:Fe.taskTitle,title:n.title,children:l.jsx(kx,{text:n.title,indices:m.get(n.id),highlightClass:Fe.searchHighlight})}),j&&l.jsx("span",{className:Fe.workspaceBadge,title:j,children:j}),_&&l.jsxs("span",{className:Fe.childCountBadge,children:[n.children.filter(w=>w.status==="complete").length,"/",n.children.length]}),n.dependsOn.length>0&&l.jsx("span",{className:`${Fe.dependencyBadge} ${v?Fe.blockedBadge:""}`,title:`Depends on: ${n.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<hT&&l.jsx("button",{onClick:w=>{w.stopPropagation(),u(ei(n.workspaceId,n.id))},title:"Add child task","aria-label":"Add child task",className:Fe.addChildButton,children:"+"})]}),l.jsx(rs,{children:_&&b&&l.jsx(Rt.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},style:{overflow:"hidden"},children:n.children.map(w=>l.jsx(jx,{node:w,depth:s+1,expandedTasks:i,toggleTask:o,selectedTaskId:c,navigate:u,taskStatusById:d,titleHighlights:m,workspaceNames:h},w.id))})})]})}function UA({workspaces:n,tasks:s}){const i=St(),[o,c]=y.useState(new Set),[u,d]=y.useState(new Set),[m,h]=y.useState(Vy),[g,v]=y.useState(Vy),[b,_]=y.useState(new Map),S=Dt("/tasks/:taskId/*"),T=(S==null?void 0:S.params.taskId)!=="new"?S==null?void 0:S.params.taskId:void 0,N=y.useMemo(()=>new Map(s.map(K=>[K.id,K.status])),[s]),j=y.useMemo(()=>new Map(n.map(K=>[K.id,K.name])),[n]),w=()=>{const K=!m;BA(K),h(K),K&&(v(!0),_(new Map))},E=K=>{_(re=>{const I=new Map(re),$=I.has(K)?I.get(K):g;return I.set(K,!$),I})},A=K=>b.has(K)?b.get(K):g,O=K=>{c(re=>{const I=new Set(re);return I.has(K)?(I.delete(K),d($=>new Set($).add(K))):(I.add(K),d($=>{const Q=new Set($);return Q.delete(K),Q})),I})};y.useEffect(()=>{const K=new Set(s.filter(re=>re.parentTaskId).map(re=>re.parentTaskId));K.size>0&&c(re=>{const I=new Set(re);for(const $ of K)u.has($)||I.add($);return I})},[s,u]);const[C,M]=y.useState(""),{directMatchTaskIds:G,treeMatchTaskIds:U,titleHighlights:V}=y.useMemo(()=>{if(!C.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const K=mT(s,C,OA),re=new Set(K.map(de=>de.item.id)),I=new Map;for(const de of K){const me=de.matches.find(ze=>ze.key==="title");me&&I.set(de.item.id,me.indices)}const $=new Set(re),Q=new Map(s.map(de=>[de.id,de]));for(const de of[...re]){let me=Q.get(de);for(;me!=null&&me.parentTaskId;)$.add(me.parentTaskId),me=Q.get(me.parentTaskId)}return{directMatchTaskIds:re,treeMatchTaskIds:$,titleHighlights:I}},[C,s]),Z=G!==null,ee=Z?m?G:U:null,ie=ee?s.filter(K=>ee.has(K.id)):s,be=m?[]:rA(ie);return l.jsxs("div",{className:Fe.container,children:[l.jsxs("div",{className:Fe.header,children:[l.jsx("span",{children:"Tasks"}),l.jsxs("div",{className:Fe.headerActions,children:[l.jsx("button",{className:`${Fe.groupToggle} ${m?Fe.groupToggleActive:""}`,onClick:w,"aria-label":m?"Switch to tree view":"Group tasks by status","aria-pressed":m,title:m?"Switch to tree view":"Group tasks by status","data-testid":"task-group-by-status-toggle",children:"≡"}),l.jsx("button",{className:Fe.addButton,onClick:()=>i(ei()),"aria-label":"New task",title:"New task","data-testid":"new-task-button",children:"+"})]})]}),s.length>0&&l.jsx("input",{type:"text",value:C,onChange:K=>M(K.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:Fe.searchInput,"data-testid":"sidebar-search"}),m?lA(ie,N).map(K=>l.jsx(LA,{group:K,isExpanded:A(K.status),onToggle:()=>E(K.status),selectedTaskId:T,navigate:i,titleHighlights:V,workspaceNames:j},K.status)):be.map(K=>l.jsx(jx,{node:K,depth:0,expandedTasks:o,toggleTask:O,selectedTaskId:T,navigate:i,taskStatusById:N,titleHighlights:V,workspaceNames:j},K.id)),ie.length===0&&!Z&&l.jsx("div",{className:Fe.emptyState,children:"No tasks yet. Click + to create one."}),ie.length===0&&Z&&l.jsx("div",{className:Fe.emptyState,children:"No matching tasks"})]})}const zA="_nav_14i94_1",PA="_tab_14i94_24",VA="_tabActive_14i94_62",qA="_tabLabel_14i94_75",HA="_statusDot_14i94_81",GA="_pulse_14i94_87",$A="_addButton_14i94_99",FA="_empty_14i94_132",ua={nav:zA,tab:PA,tabActive:VA,tabLabel:qA,statusDot:HA,pulse:GA,addButton:$A,empty:FA},ZA={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function KA({environments:n}){const s=St(),i=y.useRef(null),o=Dt("/environments/:environmentId"),c=Dt("/environments/:environmentId/edit"),u=Dt("/environments/:environmentId/workspaces/:workspaceId"),d=Dt("/environments/:environmentId/workspaces/:workspaceId/*"),m=(o==null?void 0:o.params.environmentId)??(c==null?void 0:c.params.environmentId)??(u==null?void 0:u.params.environmentId)??(d==null?void 0:d.params.environmentId),h=m==="new"?void 0:m,g=y.useCallback(_=>{s(Qi(_))},[s]),v=y.useCallback(_=>{var w;const S=(w=i.current)==null?void 0:w.querySelectorAll('[role="tab"]');if(!S||S.length===0)return;const T=Array.from(S).findIndex(E=>E===document.activeElement),N=T>=0?T:n.findIndex(E=>E.id===h);let j=N;if(_.key==="ArrowDown"||_.key==="j"||_.key==="J")_.preventDefault(),j=(N+1)%S.length;else if(_.key==="ArrowUp"||_.key==="k"||_.key==="K")_.preventDefault(),j=(N-1+S.length)%S.length;else if(_.key==="Home")_.preventDefault(),j=0;else if(_.key==="End")_.preventDefault(),j=S.length-1;else return;j<n.length&&s(Qi(n[j].id)),S[j].focus()},[h,n,s]),b=h??(n.length>0?n[0].id:void 0);return l.jsxs("div",{className:ua.nav,"data-testid":"environment-nav",children:[l.jsx("nav",{ref:i,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:n.map(_=>{const S=_.id===h,T=_.id===b,N=ZA[_.status]||"var(--text-tertiary)",j=_.status==="connected";return l.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:T?0:-1,className:`${ua.tab} ${S?ua.tabActive:""}`,onClick:()=>g(_.id),"data-testid":"env-nav-item",children:[l.jsx("span",{className:`${ua.statusDot} ${j?ua.pulse:""}`,style:{color:N},children:"●"}),l.jsx("span",{className:ua.tabLabel,title:_.displayName||_.id,children:_.displayName||_.id})]},_.id)})}),l.jsx("button",{type:"button",className:ua.addButton,onClick:()=>s(r2),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),n.length===0&&l.jsx("div",{className:ua.empty,children:"No environments yet."})]})}const YA="_nav_1bhou_1",JA="_tab_1bhou_24",WA="_tabIcon_1bhou_62",XA="_tabActive_1bhou_68",ic={nav:YA,tab:JA,tabIcon:WA,tabActive:XA},Cs=[{path:"credentials",label:"Credentials",icon:"🔑"},{path:"personas",label:"Personas",icon:"👤"},{path:"appearance",label:"Appearance",icon:"🎨"},{path:"shortcuts",label:"Shortcuts",icon:"⌨️"},{path:"about",label:"About",icon:"ℹ️"}];function QA(){var d;const n=It(),s=St(),i=y.useRef(null),o=((d=Cs.find(m=>{const h=`${Ji}/${m.path}`;return n.pathname===h||n.pathname.startsWith(`${h}/`)}))==null?void 0:d.path)??Cs[0].path,c=y.useCallback(m=>{s(`${Ji}/${m}`)},[s]),u=y.useCallback(m=>{var S,T;const h=(S=i.current)==null?void 0:S.querySelectorAll('[role="tab"]');if(!h)return;const g=Array.from(h).findIndex(N=>N===document.activeElement),v=g>=0?g:Cs.findIndex(N=>N.path===o);let b=v;if(m.key==="ArrowDown"||m.key==="j"||m.key==="J")m.preventDefault(),b=(v+1)%Cs.length;else if(m.key==="ArrowUp"||m.key==="k"||m.key==="K")m.preventDefault(),b=(v-1+Cs.length)%Cs.length;else if(m.key==="Home")m.preventDefault(),b=0;else if(m.key==="End")m.preventDefault(),b=Cs.length-1;else return;const _=Cs[b].path;s(`${Ji}/${_}`),(T=h[b])==null||T.focus()},[o,s]);return l.jsx("nav",{className:ic.nav,ref:i,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:u,children:Cs.map(m=>{const h=m.path===o;return l.jsxs("button",{role:"tab",type:"button","aria-selected":h,tabIndex:h?0:-1,className:`${ic.tab} ${h?ic.tabActive:""}`,onClick:()=>c(m.path),children:[l.jsx("span",{className:ic.tabIcon,"aria-hidden":"true",children:m.icon}),m.label]},m.path)})})}const eD="_nav_1snmp_1",tD="_searchForm_1snmp_8",nD="_searchInput_1snmp_15",sD="_searchButton_1snmp_33",aD="_clearButton_1snmp_68",iD="_workspaceSelect_1snmp_85",oD="_listHeader_1snmp_99",rD="_nodeList_1snmp_108",lD="_nodeItem_1snmp_116",cD="_indicator_1snmp_129",uD="_label_1snmp_136",dD="_badge_1snmp_145",In={nav:eD,searchForm:tD,searchInput:nD,searchButton:sD,clearButton:aD,workspaceSelect:iD,listHeader:oD,nodeList:rD,nodeItem:lD,indicator:cD,label:uD,badge:dD};function fD({nodes:n,workspaces:s,loading:i,searchQuery:o,onSearch:c,onClearSearch:u,onSelectNode:d,onWorkspaceChange:m}){const[h,g]=y.useState(""),v=y.useCallback(T=>{T.preventDefault(),h.trim()&&c(h.trim())},[h,c]),b=y.useCallback(()=>{g(""),u()},[u]),_=y.useCallback(T=>{d(T)},[d]),S=y.useCallback(T=>{g(""),m(T)},[m]);return l.jsxs("div",{className:In.nav,"data-testid":"knowledge-nav",children:[l.jsxs("form",{className:In.searchForm,onSubmit:v,children:[l.jsx("input",{className:In.searchInput,type:"text",placeholder:"Search...",value:h,onChange:T=>{g(T.target.value)},"data-testid":"knowledge-search-input"}),l.jsx("button",{type:"submit",className:In.searchButton,disabled:i,children:"Go"})]}),o&&l.jsx("button",{type:"button",className:In.clearButton,onClick:b,children:"Clear search"}),l.jsxs("select",{className:In.workspaceSelect,onChange:T=>{S(T.target.value)},"data-testid":"knowledge-workspace-filter",children:[l.jsx("option",{value:"",children:"All workspaces"}),s.map(T=>l.jsx("option",{value:T.id,children:T.name},T.id))]}),l.jsxs("div",{className:In.listHeader,children:["Nodes (",n.length,")"]}),l.jsx("ul",{className:In.nodeList,children:n.map(T=>l.jsxs("li",{className:In.nodeItem,onClick:()=>{_(T.id)},onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),_(T.id))},role:"button",tabIndex:0,children:[l.jsx("span",{className:In.indicator,style:{backgroundColor:T.kind==="reference"?"#4A9EFF":T.category==="decision"?"#22C55E":T.category==="concept"?"#A855F7":T.category==="snippet"?"#6B7280":"#EAB308"}}),l.jsx("span",{className:In.label,children:T.label}),l.jsx("span",{className:In.badge,children:T.kind==="reference"?T.sourceType:T.category})]},T.id))})]})}function pD(){const{workspaces:n,tasks:s}=pt(),i=y.useMemo(()=>l.jsx(UA,{workspaces:n,tasks:s}),[n,s]);return Ic(i),l.jsx(Qa,{})}function mD(){const{environments:n}=pt(),s=y.useMemo(()=>l.jsx(KA,{environments:n}),[n]);return Ic(s),l.jsx(Qa,{})}function hD(){const n=y.useMemo(()=>l.jsx(QA,{}),[]);return Ic(n),l.jsx(Qa,{})}function gD(){const{knowledge:n,workspaces:s}=pt(),i=y.useCallback(m=>{n.search(m)},[n]),o=y.useCallback(()=>{n.clearSearch()},[n]),c=y.useCallback(m=>{n.selectNode(m)},[n]),u=y.useCallback(m=>{n.loadRecent(m||void 0)},[n]),d=y.useMemo(()=>l.jsx(fD,{nodes:n.graphData.nodes,workspaces:s,loading:n.loading,searchQuery:n.searchQuery,onSearch:i,onClearSearch:o,onSelectNode:c,onWorkspaceChange:u}),[n,s,i,o,c,u]);return Ic(d),l.jsx(Qa,{})}const vD="_bar_tnfsh_1",yD="_btnPrimary_tnfsh_32",bD="_statusText_tnfsh_85",_D="_statusCompleted_tnfsh_90",xD="_statusFailed_tnfsh_94",SD="_statusBlocked_tnfsh_98",TD="_hintText_tnfsh_103",ht={bar:vD,btnPrimary:yD,statusText:bD,statusCompleted:_D,statusFailed:xD,statusBlocked:SD,hintText:TD};function kD({sessions:n,tasks:s,environments:i}){const o=St(),c=It(),u=Dt("/sessions/:sessionId"),d=Dt("/tasks/:taskId"),m=Dt("/tasks/:taskId/stream"),h=Dt("/tasks/:taskId/findings"),g=Dt("/tasks/:taskId/edit"),v=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),b=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),_=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings"),S=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),T=Dt("/sessions/new"),N=Dt("/environments/:environmentId/workspaces/:workspaceId"),j=Dt("/tasks/new"),w=Dt("/chat"),E=Dt("/"),A=Dt("/settings/*"),O=u==null?void 0:u.params.sessionId,C=(d==null?void 0:d.params.taskId)??(m==null?void 0:m.params.taskId)??(h==null?void 0:h.params.taskId)??(v==null?void 0:v.params.taskId)??(b==null?void 0:b.params.taskId)??(_==null?void 0:_.params.taskId)??(S==null?void 0:S.params.taskId),M=v??b??_??S,G=(M==null?void 0:M.params.environmentId)??(N==null?void 0:N.params.environmentId),U=c.pathname.startsWith("/environments")&&!N&&!M,V=!!w,Z=!!T,ee=!!N&&!v&&!b&&!_&&!S,ie=!!j;if(!!E&&!Z&&!ee&&!ie||!!A||(!!g||!!S)||ie||U||Z)return l.jsx(l.Fragment,{});if(V)return i.find($=>$.adapterType==="local"&&$.status==="connected")?l.jsx(l.Fragment,{}):l.jsx("div",{className:ht.bar,children:l.jsx("span",{className:ht.hintText,children:"Add a local environment to start chatting"})});if(ee)return l.jsx("div",{className:ht.bar,children:l.jsx("span",{className:ht.hintText,children:"Select a task or click + to create one"})});if(C){const I=s.find(de=>de.id===C);if(!I)return l.jsx("div",{className:ht.bar,children:l.jsx("span",{className:ht.hintText,children:"Loading..."})});const $=new Map(s.map(de=>[de.id,de])),Q=I.dependsOn.some(de=>{const me=$.get(de);return me!==void 0&&me.status!=="complete"});if(I.status==="not_started"){const de=Q?I.dependsOn.map(me=>$.get(me)).filter(me=>me&&me.status!=="complete").map(me=>me.title):[];return l.jsx("div",{className:ht.bar,children:Q?l.jsxs("span",{className:ht.statusBlocked,children:["Blocked by: ",de.join(", ")]}):l.jsx("span",{className:ht.hintText,children:"Use the buttons above to start or manage this task"})})}if(I.status==="working"||I.status==="paused"){const de=I.latestSessionId||void 0,me=de?n.find(je=>je.id===de):void 0;return me&&me.status!=="stopped"?l.jsx(l.Fragment,{}):l.jsx("div",{className:ht.bar,children:l.jsx("span",{className:ht.hintText,children:"Waiting for agent..."})})}if(I.status==="complete")return l.jsxs("div",{className:ht.bar,children:[l.jsx("span",{className:`${ht.statusText} ${ht.statusCompleted}`,children:"Task completed"}),l.jsx("button",{onClick:()=>o(ei(I.workspaceId,void 0,G)),className:ht.btnPrimary,children:"+ New Task"})]});if(I.status==="failed")return l.jsx("div",{className:ht.bar,children:l.jsx("span",{className:`${ht.statusText} ${ht.statusFailed}`,children:"Task failed"})})}if(O){const I=n.find(de=>de.id===O),$=(I==null?void 0:I.status)==="stopped";if(I!==void 0&&!$)return l.jsx(l.Fragment,{});if($)return l.jsxs("div",{className:ht.bar,children:[l.jsxs("span",{className:`${ht.statusText} ${ht.hintText}`,children:["Session ",I.endReason||I.status]}),l.jsx("button",{onClick:()=>o(Cb(I.environmentId)),className:ht.btnPrimary,children:"+ New Chat"})]})}return l.jsx("div",{className:ht.bar,children:l.jsx("span",{className:ht.hintText,children:"Loading..."})})}const wD="_toast_da8ll_1",ND="_success_da8ll_18",jD="_icon_da8ll_22",CD="_error_da8ll_25",ED="_warning_da8ll_32",AD="_info_da8ll_38",DD="_message_da8ll_53",RD="_close_da8ll_60",rr={toast:wD,success:ND,icon:jD,error:CD,warning:ED,info:AD,message:DD,close:RD},MD={success:"✓",error:"✕",warning:"⚠",info:"ℹ"};function OD({toast:n,onDismiss:s}){return y.useEffect(()=>{const i=setTimeout(()=>s(n.id),n.duration);return()=>clearTimeout(i)},[n.id,n.duration,s]),l.jsxs(Rt.div,{className:`${rr.toast} ${rr[n.variant]}`,role:"status",initial:{opacity:0,y:-16,scale:.94},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.94},transition:{duration:.2,ease:"easeOut"},layout:!0,children:[l.jsx("span",{className:rr.icon,"aria-hidden":"true",children:MD[n.variant]}),l.jsx("span",{className:rr.message,children:n.message}),l.jsx("button",{type:"button",className:rr.close,onClick:()=>s(n.id),"aria-label":"Dismiss notification",children:"×"})]})}const ID="_container_qqse2_1",BD={container:ID};function LD(){const{toasts:n,dismissToast:s}=Bs();return l.jsx("div",{className:BD.container,"data-testid":"toast-container",children:l.jsx(rs,{children:n.map(i=>l.jsx(OD,{toast:i,onDismiss:s},i.id))})})}const UD="_callout_1jaue_1",zD="_success_1jaue_11",PD="_icon_1jaue_15",VD="_error_1jaue_18",qD="_warning_1jaue_25",HD="_info_1jaue_32",GD="_content_1jaue_48",$D="_close_1jaue_53",lr={callout:UD,success:zD,icon:PD,error:VD,warning:qD,info:HD,content:GD,close:$D},FD={success:"✓",error:"✕",warning:"⚠",info:"ℹ"};function ZD({variant:n="info",children:s,dismissible:i=!1,className:o}){const[c,u]=y.useState(!1);return l.jsx(l.Fragment,{children:!c&&l.jsxs("div",{className:[lr.callout,lr[n],o].filter(Boolean).join(" "),role:n==="error"||n==="warning"?"alert":"status",children:[l.jsx("span",{className:lr.icon,"aria-hidden":"true",children:FD[n]}),l.jsx("span",{className:lr.content,children:s}),i&&l.jsx("button",{type:"button",className:lr.close,onClick:()=>u(!0),"aria-label":"Dismiss",children:"×"})]})})}const KD="_breadcrumbs_17or2_1",YD="_list_17or2_11",JD="_item_17or2_21",WD="_separator_17or2_28",XD="_link_17or2_34",QD="_current_17or2_57",qi={breadcrumbs:KD,list:YD,item:JD,separator:WD,link:XD,current:QD},eR="›";function ba({segments:n}){return l.jsx("nav",{className:qi.breadcrumbs,"aria-label":"Breadcrumb","data-testid":"breadcrumbs",children:l.jsx("ol",{className:qi.list,children:n.map((s,i)=>{const o=i===n.length-1;return l.jsxs("li",{className:qi.item,children:[i>0&&l.jsx("span",{className:qi.separator,"aria-hidden":"true",children:eR}),s.url&&!o?l.jsx(yp,{className:qi.link,to:s.url,title:s.label,children:s.label}):l.jsx("span",{className:qi.current,"aria-current":"page",title:s.label,children:s.label})]},i)})})})}const tR="_btn_dwk2o_1",nR="_sm_dwk2o_22",sR="_md_dwk2o_28",aR="_lg_dwk2o_34",iR="_primary_dwk2o_40",oR="_danger_dwk2o_55",rR="_outline_dwk2o_70",lR="_ghost_dwk2o_80",kf={btn:tR,sm:nR,md:sR,lg:aR,primary:iR,danger:oR,outline:rR,ghost:lR},As=y.forwardRef(function({variant:s="primary",size:i="md",className:o,children:c,...u},d){const m=[kf.btn,kf[s],kf[i],o].filter(Boolean).join(" ");return l.jsx("button",{ref:d,className:m,...u,children:c})}),cR="_copyButton_1bqk0_1",uR={copyButton:cR},dR=2e3;async function fR(n,s){const i=new ClipboardItem({"text/html":new Blob([s],{type:"text/html"}),"text/plain":new Blob([n],{type:"text/plain"})});await navigator.clipboard.write([i])}function ni({text:n,getHtml:s,className:i,"data-testid":o}){const[c,u]=y.useState(!1),d=y.useRef(void 0);y.useEffect(()=>()=>{d.current!==void 0&&clearTimeout(d.current)},[]);const m=y.useCallback(async()=>{try{const h=s==null?void 0:s();if(h)try{await fR(n,h)}catch{await navigator.clipboard.writeText(n)}else await navigator.clipboard.writeText(n);u(!0),d.current!==void 0&&clearTimeout(d.current),d.current=setTimeout(()=>{u(!1),d.current=void 0},dR)}catch{}},[n,s]);return l.jsx("button",{type:"button",className:`${uR.copyButton} ${i??""}`,onClick:()=>{m().catch(()=>{})},"aria-label":c?"Copied":"Copy to clipboard","data-testid":o??"copy-button",children:c?"✓":"📋"})}const pR="_banner_bxqlh_1",mR="_label_bxqlh_15",hR="_text_bxqlh_25",gR="_link_bxqlh_29",oc={banner:pR,label:mR,text:hR,link:gR};function vR(){return l.jsxs("div",{className:oc.banner,"data-testid":"demo-banner",children:[l.jsx("span",{className:oc.label,children:"DEMO"}),l.jsxs("span",{className:oc.text,children:["This is an interactive demo with mock data."," ",l.jsx("a",{href:"https://github.com/nick-pape/grackle",target:"_blank",rel:"noopener noreferrer",className:oc.link,children:"Install Grackle"})," ","to use it for real."]})]})}const yR="_container_og0yp_1",bR="_chevronButton_og0yp_6",_R="_mainButton_og0yp_6",xR="_sm_og0yp_34",SR="_md_og0yp_34",TR="_lg_og0yp_34",kR="_primary_og0yp_57",wR="_danger_og0yp_70",NR="_outline_og0yp_83",jR="_ghost_og0yp_92",CR="_dropdown_og0yp_100",ER="_option_og0yp_113",AR="_optionLabel_og0yp_130",DR="_optionDesc_og0yp_135",Es={container:yR,chevronButton:bR,mainButton:_R,sm:xR,md:SR,lg:TR,primary:kR,danger:wR,outline:NR,ghost:jR,dropdown:CR,option:ER,optionLabel:AR,optionDesc:DR};function Cx({label:n,onClick:s,options:i,variant:o="primary",size:c="md","data-testid":u}){const[d,m]=y.useState(!1),h=y.useRef(null);y.useEffect(()=>{if(!d)return;function _(S){h.current&&S.target instanceof Node&&!h.current.contains(S.target)&&m(!1)}return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[d]),y.useEffect(()=>{if(!d)return;function _(S){S.key==="Escape"&&m(!1)}return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[d]);const g=Es[o]||"",v=Es[c]||"",b=()=>{d&&m(!1),s()};return l.jsxs("div",{ref:h,className:Es.container,"data-testid":u,children:[l.jsx("button",{type:"button",className:`${Es.mainButton} ${g} ${v}`,onClick:b,"data-testid":u?`${u}-main`:void 0,children:n}),l.jsx("button",{type:"button",className:`${Es.chevronButton} ${g} ${v}`,onClick:()=>m(_=>!_),"aria-label":`More options for ${n}`,"aria-haspopup":"menu","aria-expanded":d,"data-testid":u?`${u}-chevron`:void 0,children:"▾"}),d&&l.jsx("div",{className:Es.dropdown,"data-testid":u?`${u}-menu`:void 0,children:i.map((_,S)=>l.jsxs("button",{type:"button",className:Es.option,onClick:()=>{_.onClick(),m(!1)},children:[l.jsx("span",{className:Es.optionLabel,children:_.label}),_.description&&l.jsx("span",{className:Es.optionDesc,children:_.description})]},S))})]})}function op(){op=function(c,u){return new i(c,void 0,u)};var n=RegExp.prototype,s=new WeakMap;function i(c,u,d){var m=new RegExp(c,u);return s.set(m,d||s.get(c)),jc(m,i.prototype)}function o(c,u){var d=s.get(u);return Object.keys(d).reduce(function(m,h){var g=d[h];if(typeof g=="number")m[h]=c[g];else{for(var v=0;c[g[v]]===void 0&&v+1<g.length;)v++;m[h]=c[g[v]]}return m},Object.create(null))}return(function(c,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(u&&u.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),Object.defineProperty(c,"prototype",{writable:!1}),u&&jc(c,u)})(i,RegExp),i.prototype.exec=function(c){var u=n.exec.call(this,c);if(u){u.groups=o(u,this);var d=u.indices;d&&(d.groups=o(d,this))}return u},i.prototype[Symbol.replace]=function(c,u){if(typeof u=="string"){var d=s.get(this);return n[Symbol.replace].call(this,c,u.replace(/\$<([^>]+)>/g,function(h,g){var v=d[g];return"$"+(Array.isArray(v)?v.join("$"):v)}))}if(typeof u=="function"){var m=this;return n[Symbol.replace].call(this,c,function(){var h=arguments;return typeof h[h.length-1]!="object"&&(h=[].slice.call(h)).push(o(h,m)),u.apply(this,h)})}return n[Symbol.replace].call(this,c,u)},op.apply(this,arguments)}function jc(n,s){return jc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,o){return i.__proto__=o,i},jc(n,s)}function qy(n,s){(s==null||s>n.length)&&(s=n.length);for(var i=0,o=new Array(s);i<s;i++)o[i]=n[i];return o}function wf(n,s){var i=typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(i)return(i=i.call(n)).next.bind(i);if(Array.isArray(n)||(i=(function(c,u){if(c){if(typeof c=="string")return qy(c,u);var d=Object.prototype.toString.call(c).slice(8,-1);return d==="Object"&&c.constructor&&(d=c.constructor.name),d==="Map"||d==="Set"?Array.from(c):d==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(d)?qy(c,u):void 0}})(n))||s){i&&(n=i);var o=0;return function(){return o>=n.length?{done:!0}:{done:!1,value:n[o++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
472
|
+
`),()=>{document.head.removeChild(v)}},[s]),l.jsx(E2,{isPresent:s,childRef:o,sizeRef:c,children:y.cloneElement(n,{ref:o})})}const D2=({children:n,initial:s,isPresent:i,onExitComplete:o,custom:c,presenceAffectsLayout:u,mode:d})=>{const m=Sp(R2),h=y.useId(),g=y.useCallback(b=>{m.set(b,!0);for(const _ of m.values())if(!_)return;o&&o()},[m,o]),v=y.useMemo(()=>({id:h,initial:s,isPresent:i,custom:c,onExitComplete:g,register:b=>(m.set(b,!1),()=>m.delete(b))}),u?[Math.random(),g]:[i,g]);return y.useMemo(()=>{m.forEach((b,_)=>m.set(_,!1))},[i]),y.useEffect(()=>{!i&&!m.size&&o&&o()},[i]),d==="popLayout"&&(n=l.jsx(A2,{isPresent:i,children:n})),l.jsx(Bc.Provider,{value:v,children:n})};function R2(){return new Map}function Yb(n=!0){const s=y.useContext(Bc);if(s===null)return[!0,null];const{isPresent:i,onExitComplete:o,register:c}=s,u=y.useId();y.useEffect(()=>{n&&c(u)},[n]);const d=y.useCallback(()=>n&&o&&o(u),[u,o,n]);return!i&&o?[!1,d]:[!0]}const tc=n=>n.key||"";function w0(n){const s=[];return y.Children.forEach(n,i=>{y.isValidElement(i)&&s.push(i)}),s}const kp=typeof window<"u",Jb=kp?y.useLayoutEffect:y.useEffect,rs=({children:n,custom:s,initial:i=!0,onExitComplete:o,presenceAffectsLayout:c=!0,mode:u="sync",propagate:d=!1})=>{const[m,h]=Yb(d),g=y.useMemo(()=>w0(n),[n]),v=d&&!m?[]:g.map(tc),b=y.useRef(!0),_=y.useRef(g),S=Sp(()=>new Map),[T,N]=y.useState(g),[j,w]=y.useState(g);Jb(()=>{b.current=!1,_.current=g;for(let O=0;O<j.length;O++){const C=tc(j[O]);v.includes(C)?S.delete(C):S.get(C)!==!0&&S.set(C,!1)}},[j,v.length,v.join("-")]);const E=[];if(g!==T){let O=[...g];for(let C=0;C<j.length;C++){const M=j[C],G=tc(M);v.includes(G)||(O.splice(C,0,M),E.push(M))}u==="wait"&&E.length&&(O=E),w(w0(O)),N(g);return}const{forceRender:A}=y.useContext(xp);return l.jsx(l.Fragment,{children:j.map(O=>{const C=tc(O),M=d&&!m?!1:g===j||v.includes(C),G=()=>{if(S.has(C))S.set(C,!0);else return;let U=!0;S.forEach(V=>{V||(U=!1)}),U&&(A==null||A(),w(_.current),d&&(h==null||h()),o&&o())};return l.jsx(D2,{isPresent:M,initial:!b.current||i?void 0:!1,custom:M?void 0:s,presenceAffectsLayout:c,mode:u,onExitComplete:M?void 0:G,children:O},C)})})},_n=n=>n;let Wb=_n;const M2={useManualTiming:!1};function O2(n){let s=new Set,i=new Set,o=!1,c=!1;const u=new WeakSet;let d={delta:0,timestamp:0,isProcessing:!1};function m(g){u.has(g)&&(h.schedule(g),n()),g(d)}const h={schedule:(g,v=!1,b=!1)=>{const S=b&&o?s:i;return v&&u.add(g),S.has(g)||S.add(g),g},cancel:g=>{i.delete(g),u.delete(g)},process:g=>{if(d=g,o){c=!0;return}o=!0,[s,i]=[i,s],s.forEach(m),s.clear(),o=!1,c&&(c=!1,h.process(g))}};return h}const nc=["read","resolveKeyframes","update","preRender","render","postRender"],I2=40;function Xb(n,s){let i=!1,o=!0;const c={delta:0,timestamp:0,isProcessing:!1},u=()=>i=!0,d=nc.reduce((w,E)=>(w[E]=O2(u),w),{}),{read:m,resolveKeyframes:h,update:g,preRender:v,render:b,postRender:_}=d,S=()=>{const w=performance.now();i=!1,c.delta=o?1e3/60:Math.max(Math.min(w-c.timestamp,I2),1),c.timestamp=w,c.isProcessing=!0,m.process(c),h.process(c),g.process(c),v.process(c),b.process(c),_.process(c),c.isProcessing=!1,i&&s&&(o=!1,n(S))},T=()=>{i=!0,o=!0,c.isProcessing||n(S)};return{schedule:nc.reduce((w,E)=>{const A=d[E];return w[E]=(O,C=!1,M=!1)=>(i||T(),A.schedule(O,C,M)),w},{}),cancel:w=>{for(let E=0;E<nc.length;E++)d[nc[E]].cancel(w)},state:c,steps:d}}const{schedule:ft,cancel:ma,state:Ft,steps:df}=Xb(typeof requestAnimationFrame<"u"?requestAnimationFrame:_n,!0),Qb=y.createContext({strict:!1}),N0={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},eo={};for(const n in N0)eo[n]={isEnabled:s=>N0[n].some(i=>!!s[i])};function B2(n){for(const s in n)eo[s]={...eo[s],...n[s]}}const L2=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function bc(n){return n.startsWith("while")||n.startsWith("drag")&&n!=="draggable"||n.startsWith("layout")||n.startsWith("onTap")||n.startsWith("onPan")||n.startsWith("onLayout")||L2.has(n)}let e_=n=>!bc(n);function U2(n){n&&(e_=s=>s.startsWith("on")?!bc(s):n(s))}try{U2(require("@emotion/is-prop-valid").default)}catch{}function z2(n,s,i){const o={};for(const c in n)c==="values"&&typeof n.values=="object"||(e_(c)||i===!0&&bc(c)||!s&&!bc(c)||n.draggable&&c.startsWith("onDrag"))&&(o[c]=n[c]);return o}function P2(n){if(typeof Proxy>"u")return n;const s=new Map,i=(...o)=>n(...o);return new Proxy(i,{get:(o,c)=>c==="create"?n:(s.has(c)||s.set(c,n(c)),s.get(c))})}const Lc=y.createContext({});function Sr(n){return typeof n=="string"||Array.isArray(n)}function Uc(n){return n!==null&&typeof n=="object"&&typeof n.start=="function"}const wp=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Np=["initial",...wp];function zc(n){return Uc(n.animate)||Np.some(s=>Sr(n[s]))}function t_(n){return!!(zc(n)||n.variants)}function V2(n,s){if(zc(n)){const{initial:i,animate:o}=n;return{initial:i===!1||Sr(i)?i:void 0,animate:Sr(o)?o:void 0}}return n.inherit!==!1?s:{}}function q2(n){const{initial:s,animate:i}=V2(n,y.useContext(Lc));return y.useMemo(()=>({initial:s,animate:i}),[j0(s),j0(i)])}function j0(n){return Array.isArray(n)?n.join(" "):n}const H2=Symbol.for("motionComponentSymbol");function Gi(n){return n&&typeof n=="object"&&Object.prototype.hasOwnProperty.call(n,"current")}function G2(n,s,i){return y.useCallback(o=>{o&&n.onMount&&n.onMount(o),s&&(o?s.mount(o):s.unmount()),i&&(typeof i=="function"?i(o):Gi(i)&&(i.current=o))},[s])}const jp=n=>n.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),$2="framerAppearId",n_="data-"+jp($2),{schedule:Cp}=Xb(queueMicrotask,!1),s_=y.createContext({});function F2(n,s,i,o,c){var u,d;const{visualElement:m}=y.useContext(Lc),h=y.useContext(Qb),g=y.useContext(Bc),v=y.useContext(Tp).reducedMotion,b=y.useRef(null);o=o||h.renderer,!b.current&&o&&(b.current=o(n,{visualState:s,parent:m,props:i,presenceContext:g,blockInitialAnimation:g?g.initial===!1:!1,reducedMotionConfig:v}));const _=b.current,S=y.useContext(s_);_&&!_.projection&&c&&(_.type==="html"||_.type==="svg")&&Z2(b.current,i,c,S);const T=y.useRef(!1);y.useInsertionEffect(()=>{_&&T.current&&_.update(i,g)});const N=i[n_],j=y.useRef(!!N&&!(!((u=window.MotionHandoffIsComplete)===null||u===void 0)&&u.call(window,N))&&((d=window.MotionHasOptimisedAnimation)===null||d===void 0?void 0:d.call(window,N)));return Jb(()=>{_&&(T.current=!0,window.MotionIsMounted=!0,_.updateFeatures(),Cp.render(_.render),j.current&&_.animationState&&_.animationState.animateChanges())}),y.useEffect(()=>{_&&(!j.current&&_.animationState&&_.animationState.animateChanges(),j.current&&(queueMicrotask(()=>{var w;(w=window.MotionHandoffMarkAsComplete)===null||w===void 0||w.call(window,N)}),j.current=!1))}),_}function Z2(n,s,i,o){const{layoutId:c,layout:u,drag:d,dragConstraints:m,layoutScroll:h,layoutRoot:g}=s;n.projection=new i(n.latestValues,s["data-framer-portal-id"]?void 0:a_(n.parent)),n.projection.setOptions({layoutId:c,layout:u,alwaysMeasureLayout:!!d||m&&Gi(m),visualElement:n,animationType:typeof u=="string"?u:"both",initialPromotionConfig:o,layoutScroll:h,layoutRoot:g})}function a_(n){if(n)return n.options.allowProjection!==!1?n.projection:a_(n.parent)}function K2({preloadedFeatures:n,createVisualElement:s,useRender:i,useVisualState:o,Component:c}){var u,d;n&&B2(n);function m(g,v){let b;const _={...y.useContext(Tp),...g,layoutId:Y2(g)},{isStatic:S}=_,T=q2(g),N=o(g,S);if(!S&&kp){J2();const j=W2(_);b=j.MeasureLayout,T.visualElement=F2(c,N,_,s,j.ProjectionNode)}return l.jsxs(Lc.Provider,{value:T,children:[b&&T.visualElement?l.jsx(b,{visualElement:T.visualElement,..._}):null,i(c,g,G2(N,T.visualElement,v),N,S,T.visualElement)]})}m.displayName=`motion.${typeof c=="string"?c:`create(${(d=(u=c.displayName)!==null&&u!==void 0?u:c.name)!==null&&d!==void 0?d:""})`}`;const h=y.forwardRef(m);return h[H2]=c,h}function Y2({layoutId:n}){const s=y.useContext(xp).id;return s&&n!==void 0?s+"-"+n:n}function J2(n,s){y.useContext(Qb).strict}function W2(n){const{drag:s,layout:i}=eo;if(!s&&!i)return{};const o={...s,...i};return{MeasureLayout:s!=null&&s.isEnabled(n)||i!=null&&i.isEnabled(n)?o.MeasureLayout:void 0,ProjectionNode:o.ProjectionNode}}const X2=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function Ep(n){return typeof n!="string"||n.includes("-")?!1:!!(X2.indexOf(n)>-1||/[A-Z]/u.test(n))}function C0(n){const s=[{},{}];return n==null||n.values.forEach((i,o)=>{s[0][o]=i.get(),s[1][o]=i.getVelocity()}),s}function Ap(n,s,i,o){if(typeof s=="function"){const[c,u]=C0(o);s=s(i!==void 0?i:n.custom,c,u)}if(typeof s=="string"&&(s=n.variants&&n.variants[s]),typeof s=="function"){const[c,u]=C0(o);s=s(i!==void 0?i:n.custom,c,u)}return s}const Gf=n=>Array.isArray(n),Q2=n=>!!(n&&typeof n=="object"&&n.mix&&n.toValue),eN=n=>Gf(n)?n[n.length-1]||0:n,Xt=n=>!!(n&&n.getVelocity);function pc(n){const s=Xt(n)?n.get():n;return Q2(s)?s.toValue():s}function tN({scrapeMotionValuesFromProps:n,createRenderState:s,onUpdate:i},o,c,u){const d={latestValues:nN(o,c,u,n),renderState:s()};return i&&(d.onMount=m=>i({props:o,current:m,...d}),d.onUpdate=m=>i(m)),d}const i_=n=>(s,i)=>{const o=y.useContext(Lc),c=y.useContext(Bc),u=()=>tN(n,s,o,c);return i?u():Sp(u)};function nN(n,s,i,o){const c={},u=o(n,{});for(const _ in u)c[_]=pc(u[_]);let{initial:d,animate:m}=n;const h=zc(n),g=t_(n);s&&g&&!h&&n.inherit!==!1&&(d===void 0&&(d=s.initial),m===void 0&&(m=s.animate));let v=i?i.initial===!1:!1;v=v||d===!1;const b=v?m:d;if(b&&typeof b!="boolean"&&!Uc(b)){const _=Array.isArray(b)?b:[b];for(let S=0;S<_.length;S++){const T=Ap(n,_[S]);if(T){const{transitionEnd:N,transition:j,...w}=T;for(const E in w){let A=w[E];if(Array.isArray(A)){const O=v?A.length-1:0;A=A[O]}A!==null&&(c[E]=A)}for(const E in N)c[E]=N[E]}}}return c}const oo=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],ti=new Set(oo),o_=n=>s=>typeof s=="string"&&s.startsWith(n),r_=o_("--"),sN=o_("var(--"),Dp=n=>sN(n)?aN.test(n.split("/*")[0].trim()):!1,aN=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,l_=(n,s)=>s&&typeof n=="number"?s.transform(n):n,Is=(n,s,i)=>i>s?s:i<n?n:i,ro={test:n=>typeof n=="number",parse:parseFloat,transform:n=>n},Tr={...ro,transform:n=>Is(0,1,n)},sc={...ro,default:1},Ar=n=>({test:s=>typeof s=="string"&&s.endsWith(n)&&s.split(" ").length===1,parse:parseFloat,transform:s=>`${s}${n}`}),pa=Ar("deg"),as=Ar("%"),ke=Ar("px"),iN=Ar("vh"),oN=Ar("vw"),E0={...as,parse:n=>as.parse(n)/100,transform:n=>as.transform(n*100)},rN={borderWidth:ke,borderTopWidth:ke,borderRightWidth:ke,borderBottomWidth:ke,borderLeftWidth:ke,borderRadius:ke,radius:ke,borderTopLeftRadius:ke,borderTopRightRadius:ke,borderBottomRightRadius:ke,borderBottomLeftRadius:ke,width:ke,maxWidth:ke,height:ke,maxHeight:ke,top:ke,right:ke,bottom:ke,left:ke,padding:ke,paddingTop:ke,paddingRight:ke,paddingBottom:ke,paddingLeft:ke,margin:ke,marginTop:ke,marginRight:ke,marginBottom:ke,marginLeft:ke,backgroundPositionX:ke,backgroundPositionY:ke},lN={rotate:pa,rotateX:pa,rotateY:pa,rotateZ:pa,scale:sc,scaleX:sc,scaleY:sc,scaleZ:sc,skew:pa,skewX:pa,skewY:pa,distance:ke,translateX:ke,translateY:ke,translateZ:ke,x:ke,y:ke,z:ke,perspective:ke,transformPerspective:ke,opacity:Tr,originX:E0,originY:E0,originZ:ke},A0={...ro,transform:Math.round},Rp={...rN,...lN,zIndex:A0,size:ke,fillOpacity:Tr,strokeOpacity:Tr,numOctaves:A0},cN={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},uN=oo.length;function dN(n,s,i){let o="",c=!0;for(let u=0;u<uN;u++){const d=oo[u],m=n[d];if(m===void 0)continue;let h=!0;if(typeof m=="number"?h=m===(d.startsWith("scale")?1:0):h=parseFloat(m)===0,!h||i){const g=l_(m,Rp[d]);if(!h){c=!1;const v=cN[d]||d;o+=`${v}(${g}) `}i&&(s[d]=g)}}return o=o.trim(),i?o=i(s,c?"":o):c&&(o="none"),o}function Mp(n,s,i){const{style:o,vars:c,transformOrigin:u}=n;let d=!1,m=!1;for(const h in s){const g=s[h];if(ti.has(h)){d=!0;continue}else if(r_(h)){c[h]=g;continue}else{const v=l_(g,Rp[h]);h.startsWith("origin")?(m=!0,u[h]=v):o[h]=v}}if(s.transform||(d||i?o.transform=dN(s,n.transform,i):o.transform&&(o.transform="none")),m){const{originX:h="50%",originY:g="50%",originZ:v=0}=u;o.transformOrigin=`${h} ${g} ${v}`}}const fN={offset:"stroke-dashoffset",array:"stroke-dasharray"},pN={offset:"strokeDashoffset",array:"strokeDasharray"};function mN(n,s,i=1,o=0,c=!0){n.pathLength=1;const u=c?fN:pN;n[u.offset]=ke.transform(-o);const d=ke.transform(s),m=ke.transform(i);n[u.array]=`${d} ${m}`}function D0(n,s,i){return typeof n=="string"?n:ke.transform(s+i*n)}function hN(n,s,i){const o=D0(s,n.x,n.width),c=D0(i,n.y,n.height);return`${o} ${c}`}function Op(n,{attrX:s,attrY:i,attrScale:o,originX:c,originY:u,pathLength:d,pathSpacing:m=1,pathOffset:h=0,...g},v,b){if(Mp(n,g,b),v){n.style.viewBox&&(n.attrs.viewBox=n.style.viewBox);return}n.attrs=n.style,n.style={};const{attrs:_,style:S,dimensions:T}=n;_.transform&&(T&&(S.transform=_.transform),delete _.transform),T&&(c!==void 0||u!==void 0||S.transform)&&(S.transformOrigin=hN(T,c!==void 0?c:.5,u!==void 0?u:.5)),s!==void 0&&(_.x=s),i!==void 0&&(_.y=i),o!==void 0&&(_.scale=o),d!==void 0&&mN(_,d,m,h,!1)}const Ip=()=>({style:{},transform:{},transformOrigin:{},vars:{}}),c_=()=>({...Ip(),attrs:{}}),Bp=n=>typeof n=="string"&&n.toLowerCase()==="svg";function u_(n,{style:s,vars:i},o,c){Object.assign(n.style,s,c&&c.getProjectionStyles(o));for(const u in i)n.style.setProperty(u,i[u])}const d_=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function f_(n,s,i,o){u_(n,s,void 0,o);for(const c in s.attrs)n.setAttribute(d_.has(c)?c:jp(c),s.attrs[c])}const _c={};function gN(n){Object.assign(_c,n)}function p_(n,{layout:s,layoutId:i}){return ti.has(n)||n.startsWith("origin")||(s||i!==void 0)&&(!!_c[n]||n==="opacity")}function Lp(n,s,i){var o;const{style:c}=n,u={};for(const d in c)(Xt(c[d])||s.style&&Xt(s.style[d])||p_(d,n)||((o=i==null?void 0:i.getValue(d))===null||o===void 0?void 0:o.liveStyle)!==void 0)&&(u[d]=c[d]);return u}function m_(n,s,i){const o=Lp(n,s,i);for(const c in n)if(Xt(n[c])||Xt(s[c])){const u=oo.indexOf(c)!==-1?"attr"+c.charAt(0).toUpperCase()+c.substring(1):c;o[u]=n[c]}return o}function vN(n,s){try{s.dimensions=typeof n.getBBox=="function"?n.getBBox():n.getBoundingClientRect()}catch{s.dimensions={x:0,y:0,width:0,height:0}}}const R0=["x","y","width","height","cx","cy","r"],yN={useVisualState:i_({scrapeMotionValuesFromProps:m_,createRenderState:c_,onUpdate:({props:n,prevProps:s,current:i,renderState:o,latestValues:c})=>{if(!i)return;let u=!!n.drag;if(!u){for(const m in c)if(ti.has(m)){u=!0;break}}if(!u)return;let d=!s;if(s)for(let m=0;m<R0.length;m++){const h=R0[m];n[h]!==s[h]&&(d=!0)}d&&ft.read(()=>{vN(i,o),ft.render(()=>{Op(o,c,Bp(i.tagName),n.transformTemplate),f_(i,o)})})}})},bN={useVisualState:i_({scrapeMotionValuesFromProps:Lp,createRenderState:Ip})};function h_(n,s,i){for(const o in s)!Xt(s[o])&&!p_(o,i)&&(n[o]=s[o])}function _N({transformTemplate:n},s){return y.useMemo(()=>{const i=Ip();return Mp(i,s,n),Object.assign({},i.vars,i.style)},[s])}function xN(n,s){const i=n.style||{},o={};return h_(o,i,n),Object.assign(o,_N(n,s)),o}function SN(n,s){const i={},o=xN(n,s);return n.drag&&n.dragListener!==!1&&(i.draggable=!1,o.userSelect=o.WebkitUserSelect=o.WebkitTouchCallout="none",o.touchAction=n.drag===!0?"none":`pan-${n.drag==="x"?"y":"x"}`),n.tabIndex===void 0&&(n.onTap||n.onTapStart||n.whileTap)&&(i.tabIndex=0),i.style=o,i}function TN(n,s,i,o){const c=y.useMemo(()=>{const u=c_();return Op(u,s,Bp(o),n.transformTemplate),{...u.attrs,style:{...u.style}}},[s]);if(n.style){const u={};h_(u,n.style,n),c.style={...u,...c.style}}return c}function kN(n=!1){return(i,o,c,{latestValues:u},d)=>{const h=(Ep(i)?TN:SN)(o,u,d,i),g=z2(o,typeof i=="string",n),v=i!==y.Fragment?{...g,...h,ref:c}:{},{children:b}=o,_=y.useMemo(()=>Xt(b)?b.get():b,[b]);return y.createElement(i,{...v,children:_})}}function wN(n,s){return function(o,{forwardMotionProps:c}={forwardMotionProps:!1}){const d={...Ep(o)?yN:bN,preloadedFeatures:n,useRender:kN(c),createVisualElement:s,Component:o};return K2(d)}}function g_(n,s){if(!Array.isArray(s))return!1;const i=s.length;if(i!==n.length)return!1;for(let o=0;o<i;o++)if(s[o]!==n[o])return!1;return!0}function Pc(n,s,i){const o=n.getProps();return Ap(o,s,i!==void 0?i:o.custom,n)}function Up(n,s){return n?n[s]||n.default||n:void 0}const v_=new Set(["width","height","top","left","right","bottom",...oo]);let mc;function NN(){mc=void 0}const is={now:()=>(mc===void 0&&is.set(Ft.isProcessing||M2.useManualTiming?Ft.timestamp:performance.now()),mc),set:n=>{mc=n,queueMicrotask(NN)}};function zp(n,s){n.indexOf(s)===-1&&n.push(s)}function Pp(n,s){const i=n.indexOf(s);i>-1&&n.splice(i,1)}class Vp{constructor(){this.subscriptions=[]}add(s){return zp(this.subscriptions,s),()=>Pp(this.subscriptions,s)}notify(s,i,o){const c=this.subscriptions.length;if(c)if(c===1)this.subscriptions[0](s,i,o);else for(let u=0;u<c;u++){const d=this.subscriptions[u];d&&d(s,i,o)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}function y_(n,s){return s?n*(1e3/s):0}const M0=30,jN=n=>!isNaN(parseFloat(n));class CN{constructor(s,i={}){this.version="11.18.2",this.canTrackVelocity=null,this.events={},this.updateAndNotify=(o,c=!0)=>{const u=is.now();this.updatedAt!==u&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(o),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),c&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(s),this.owner=i.owner}setCurrent(s){this.current=s,this.updatedAt=is.now(),this.canTrackVelocity===null&&s!==void 0&&(this.canTrackVelocity=jN(this.current))}setPrevFrameValue(s=this.current){this.prevFrameValue=s,this.prevUpdatedAt=this.updatedAt}onChange(s){return this.on("change",s)}on(s,i){this.events[s]||(this.events[s]=new Vp);const o=this.events[s].add(i);return s==="change"?()=>{o(),ft.read(()=>{this.events.change.getSize()||this.stop()})}:o}clearListeners(){for(const s in this.events)this.events[s].clear()}attach(s,i){this.passiveEffect=s,this.stopPassiveEffect=i}set(s,i=!0){!i||!this.passiveEffect?this.updateAndNotify(s,i):this.passiveEffect(s,this.updateAndNotify)}setWithVelocity(s,i,o){this.set(i),this.prev=void 0,this.prevFrameValue=s,this.prevUpdatedAt=this.updatedAt-o}jump(s,i=!0){this.updateAndNotify(s),this.prev=s,this.prevUpdatedAt=this.prevFrameValue=void 0,i&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const s=is.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||s-this.updatedAt>M0)return 0;const i=Math.min(this.updatedAt-this.prevUpdatedAt,M0);return y_(parseFloat(this.current)-parseFloat(this.prevFrameValue),i)}start(s){return this.stop(),new Promise(i=>{this.hasAnimated=!0,this.animation=s(i),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function kr(n,s){return new CN(n,s)}function EN(n,s,i){n.hasValue(s)?n.getValue(s).set(i):n.addValue(s,kr(i))}function AN(n,s){const i=Pc(n,s);let{transitionEnd:o={},transition:c={},...u}=i||{};u={...u,...o};for(const d in u){const m=eN(u[d]);EN(n,d,m)}}function DN(n){return!!(Xt(n)&&n.add)}function $f(n,s){const i=n.getValue("willChange");if(DN(i))return i.add(s)}function b_(n){return n.props[n_]}function qp(n){let s;return()=>(s===void 0&&(s=n()),s)}const RN=qp(()=>window.ScrollTimeline!==void 0);class MN{constructor(s){this.stop=()=>this.runAll("stop"),this.animations=s.filter(Boolean)}get finished(){return Promise.all(this.animations.map(s=>"finished"in s?s.finished:s))}getAll(s){return this.animations[0][s]}setAll(s,i){for(let o=0;o<this.animations.length;o++)this.animations[o][s]=i}attachTimeline(s,i){const o=this.animations.map(c=>{if(RN()&&c.attachTimeline)return c.attachTimeline(s);if(typeof i=="function")return i(c)});return()=>{o.forEach((c,u)=>{c&&c(),this.animations[u].stop()})}}get time(){return this.getAll("time")}set time(s){this.setAll("time",s)}get speed(){return this.getAll("speed")}set speed(s){this.setAll("speed",s)}get startTime(){return this.getAll("startTime")}get duration(){let s=0;for(let i=0;i<this.animations.length;i++)s=Math.max(s,this.animations[i].duration);return s}runAll(s){this.animations.forEach(i=>i[s]())}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}class ON extends MN{then(s,i){return Promise.all(this.animations).then(s).catch(i)}}const Ds=n=>n*1e3,Rs=n=>n/1e3;function Hp(n){return typeof n=="function"}function O0(n,s){n.timeline=s,n.onfinish=null}const Gp=n=>Array.isArray(n)&&typeof n[0]=="number",IN={linearEasing:void 0};function BN(n,s){const i=qp(n);return()=>{var o;return(o=IN[s])!==null&&o!==void 0?o:i()}}const xc=BN(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),to=(n,s,i)=>{const o=s-n;return o===0?1:(i-n)/o},__=(n,s,i=10)=>{let o="";const c=Math.max(Math.round(s/i),2);for(let u=0;u<c;u++)o+=n(to(0,c-1,u))+", ";return`linear(${o.substring(0,o.length-2)})`};function x_(n){return!!(typeof n=="function"&&xc()||!n||typeof n=="string"&&(n in Ff||xc())||Gp(n)||Array.isArray(n)&&n.every(x_))}const ur=([n,s,i,o])=>`cubic-bezier(${n}, ${s}, ${i}, ${o})`,Ff={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:ur([0,.65,.55,1]),circOut:ur([.55,0,1,.45]),backIn:ur([.31,.01,.66,-.59]),backOut:ur([.33,1.53,.69,.99])};function S_(n,s){if(n)return typeof n=="function"&&xc()?__(n,s):Gp(n)?ur(n):Array.isArray(n)?n.map(i=>S_(i,s)||Ff.easeOut):Ff[n]}const T_=(n,s,i)=>(((1-3*i+3*s)*n+(3*i-6*s))*n+3*s)*n,LN=1e-7,UN=12;function zN(n,s,i,o,c){let u,d,m=0;do d=s+(i-s)/2,u=T_(d,o,c)-n,u>0?i=d:s=d;while(Math.abs(u)>LN&&++m<UN);return d}function Dr(n,s,i,o){if(n===s&&i===o)return _n;const c=u=>zN(u,0,1,n,i);return u=>u===0||u===1?u:T_(c(u),s,o)}const k_=n=>s=>s<=.5?n(2*s)/2:(2-n(2*(1-s)))/2,w_=n=>s=>1-n(1-s),N_=Dr(.33,1.53,.69,.99),$p=w_(N_),j_=k_($p),C_=n=>(n*=2)<1?.5*$p(n):.5*(2-Math.pow(2,-10*(n-1))),Fp=n=>1-Math.sin(Math.acos(n)),E_=w_(Fp),A_=k_(Fp),D_=n=>/^0[^.\s]+$/u.test(n);function PN(n){return typeof n=="number"?n===0:n!==null?n==="none"||n==="0"||D_(n):!0}const hr=n=>Math.round(n*1e5)/1e5,Zp=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function VN(n){return n==null}const qN=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Kp=(n,s)=>i=>!!(typeof i=="string"&&qN.test(i)&&i.startsWith(n)||s&&!VN(i)&&Object.prototype.hasOwnProperty.call(i,s)),R_=(n,s,i)=>o=>{if(typeof o!="string")return o;const[c,u,d,m]=o.match(Zp);return{[n]:parseFloat(c),[s]:parseFloat(u),[i]:parseFloat(d),alpha:m!==void 0?parseFloat(m):1}},HN=n=>Is(0,255,n),ff={...ro,transform:n=>Math.round(HN(n))},Fa={test:Kp("rgb","red"),parse:R_("red","green","blue"),transform:({red:n,green:s,blue:i,alpha:o=1})=>"rgba("+ff.transform(n)+", "+ff.transform(s)+", "+ff.transform(i)+", "+hr(Tr.transform(o))+")"};function GN(n){let s="",i="",o="",c="";return n.length>5?(s=n.substring(1,3),i=n.substring(3,5),o=n.substring(5,7),c=n.substring(7,9)):(s=n.substring(1,2),i=n.substring(2,3),o=n.substring(3,4),c=n.substring(4,5),s+=s,i+=i,o+=o,c+=c),{red:parseInt(s,16),green:parseInt(i,16),blue:parseInt(o,16),alpha:c?parseInt(c,16)/255:1}}const Zf={test:Kp("#"),parse:GN,transform:Fa.transform},$i={test:Kp("hsl","hue"),parse:R_("hue","saturation","lightness"),transform:({hue:n,saturation:s,lightness:i,alpha:o=1})=>"hsla("+Math.round(n)+", "+as.transform(hr(s))+", "+as.transform(hr(i))+", "+hr(Tr.transform(o))+")"},Wt={test:n=>Fa.test(n)||Zf.test(n)||$i.test(n),parse:n=>Fa.test(n)?Fa.parse(n):$i.test(n)?$i.parse(n):Zf.parse(n),transform:n=>typeof n=="string"?n:n.hasOwnProperty("red")?Fa.transform(n):$i.transform(n)},$N=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function FN(n){var s,i;return isNaN(n)&&typeof n=="string"&&(((s=n.match(Zp))===null||s===void 0?void 0:s.length)||0)+(((i=n.match($N))===null||i===void 0?void 0:i.length)||0)>0}const M_="number",O_="color",ZN="var",KN="var(",I0="${}",YN=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function wr(n){const s=n.toString(),i=[],o={color:[],number:[],var:[]},c=[];let u=0;const m=s.replace(YN,h=>(Wt.test(h)?(o.color.push(u),c.push(O_),i.push(Wt.parse(h))):h.startsWith(KN)?(o.var.push(u),c.push(ZN),i.push(h)):(o.number.push(u),c.push(M_),i.push(parseFloat(h))),++u,I0)).split(I0);return{values:i,split:m,indexes:o,types:c}}function I_(n){return wr(n).values}function B_(n){const{split:s,types:i}=wr(n),o=s.length;return c=>{let u="";for(let d=0;d<o;d++)if(u+=s[d],c[d]!==void 0){const m=i[d];m===M_?u+=hr(c[d]):m===O_?u+=Wt.transform(c[d]):u+=c[d]}return u}}const JN=n=>typeof n=="number"?0:n;function WN(n){const s=I_(n);return B_(n)(s.map(JN))}const ha={test:FN,parse:I_,createTransformer:B_,getAnimatableNone:WN},XN=new Set(["brightness","contrast","saturate","opacity"]);function QN(n){const[s,i]=n.slice(0,-1).split("(");if(s==="drop-shadow")return n;const[o]=i.match(Zp)||[];if(!o)return n;const c=i.replace(o,"");let u=XN.has(s)?1:0;return o!==i&&(u*=100),s+"("+u+c+")"}const ej=/\b([a-z-]*)\(.*?\)/gu,Kf={...ha,getAnimatableNone:n=>{const s=n.match(ej);return s?s.map(QN).join(" "):n}},tj={...Rp,color:Wt,backgroundColor:Wt,outlineColor:Wt,fill:Wt,stroke:Wt,borderColor:Wt,borderTopColor:Wt,borderRightColor:Wt,borderBottomColor:Wt,borderLeftColor:Wt,filter:Kf,WebkitFilter:Kf},Yp=n=>tj[n];function L_(n,s){let i=Yp(n);return i!==Kf&&(i=ha),i.getAnimatableNone?i.getAnimatableNone(s):void 0}const nj=new Set(["auto","none","0"]);function sj(n,s,i){let o=0,c;for(;o<n.length&&!c;){const u=n[o];typeof u=="string"&&!nj.has(u)&&wr(u).values.length&&(c=n[o]),o++}if(c&&i)for(const u of s)n[u]=L_(i,c)}const B0=n=>n===ro||n===ke,L0=(n,s)=>parseFloat(n.split(", ")[s]),U0=(n,s)=>(i,{transform:o})=>{if(o==="none"||!o)return 0;const c=o.match(/^matrix3d\((.+)\)$/u);if(c)return L0(c[1],s);{const u=o.match(/^matrix\((.+)\)$/u);return u?L0(u[1],n):0}},aj=new Set(["x","y","z"]),ij=oo.filter(n=>!aj.has(n));function oj(n){const s=[];return ij.forEach(i=>{const o=n.getValue(i);o!==void 0&&(s.push([i,o.get()]),o.set(i.startsWith("scale")?1:0))}),s}const no={width:({x:n},{paddingLeft:s="0",paddingRight:i="0"})=>n.max-n.min-parseFloat(s)-parseFloat(i),height:({y:n},{paddingTop:s="0",paddingBottom:i="0"})=>n.max-n.min-parseFloat(s)-parseFloat(i),top:(n,{top:s})=>parseFloat(s),left:(n,{left:s})=>parseFloat(s),bottom:({y:n},{top:s})=>parseFloat(s)+(n.max-n.min),right:({x:n},{left:s})=>parseFloat(s)+(n.max-n.min),x:U0(4,13),y:U0(5,14)};no.translateX=no.x;no.translateY=no.y;const Ka=new Set;let Yf=!1,Jf=!1;function U_(){if(Jf){const n=Array.from(Ka).filter(o=>o.needsMeasurement),s=new Set(n.map(o=>o.element)),i=new Map;s.forEach(o=>{const c=oj(o);c.length&&(i.set(o,c),o.render())}),n.forEach(o=>o.measureInitialState()),s.forEach(o=>{o.render();const c=i.get(o);c&&c.forEach(([u,d])=>{var m;(m=o.getValue(u))===null||m===void 0||m.set(d)})}),n.forEach(o=>o.measureEndState()),n.forEach(o=>{o.suspendedScrollY!==void 0&&window.scrollTo(0,o.suspendedScrollY)})}Jf=!1,Yf=!1,Ka.forEach(n=>n.complete()),Ka.clear()}function z_(){Ka.forEach(n=>{n.readKeyframes(),n.needsMeasurement&&(Jf=!0)})}function rj(){z_(),U_()}class Jp{constructor(s,i,o,c,u,d=!1){this.isComplete=!1,this.isAsync=!1,this.needsMeasurement=!1,this.isScheduled=!1,this.unresolvedKeyframes=[...s],this.onComplete=i,this.name=o,this.motionValue=c,this.element=u,this.isAsync=d}scheduleResolve(){this.isScheduled=!0,this.isAsync?(Ka.add(this),Yf||(Yf=!0,ft.read(z_),ft.resolveKeyframes(U_))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:s,name:i,element:o,motionValue:c}=this;for(let u=0;u<s.length;u++)if(s[u]===null)if(u===0){const d=c==null?void 0:c.get(),m=s[s.length-1];if(d!==void 0)s[0]=d;else if(o&&i){const h=o.readValue(i,m);h!=null&&(s[0]=h)}s[0]===void 0&&(s[0]=m),c&&d===void 0&&c.set(s[0])}else s[u]=s[u-1]}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(){this.isComplete=!0,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe),Ka.delete(this)}cancel(){this.isComplete||(this.isScheduled=!1,Ka.delete(this))}resume(){this.isComplete||this.scheduleResolve()}}const P_=n=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(n),lj=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function cj(n){const s=lj.exec(n);if(!s)return[,];const[,i,o,c]=s;return[`--${i??o}`,c]}function V_(n,s,i=1){const[o,c]=cj(n);if(!o)return;const u=window.getComputedStyle(s).getPropertyValue(o);if(u){const d=u.trim();return P_(d)?parseFloat(d):d}return Dp(c)?V_(c,s,i+1):c}const q_=n=>s=>s.test(n),uj={test:n=>n==="auto",parse:n=>n},H_=[ro,ke,as,pa,oN,iN,uj],z0=n=>H_.find(q_(n));class G_ extends Jp{constructor(s,i,o,c,u){super(s,i,o,c,u,!0)}readKeyframes(){const{unresolvedKeyframes:s,element:i,name:o}=this;if(!i||!i.current)return;super.readKeyframes();for(let h=0;h<s.length;h++){let g=s[h];if(typeof g=="string"&&(g=g.trim(),Dp(g))){const v=V_(g,i.current);v!==void 0&&(s[h]=v),h===s.length-1&&(this.finalKeyframe=g)}}if(this.resolveNoneKeyframes(),!v_.has(o)||s.length!==2)return;const[c,u]=s,d=z0(c),m=z0(u);if(d!==m)if(B0(d)&&B0(m))for(let h=0;h<s.length;h++){const g=s[h];typeof g=="string"&&(s[h]=parseFloat(g))}else this.needsMeasurement=!0}resolveNoneKeyframes(){const{unresolvedKeyframes:s,name:i}=this,o=[];for(let c=0;c<s.length;c++)PN(s[c])&&o.push(c);o.length&&sj(s,o,i)}measureInitialState(){const{element:s,unresolvedKeyframes:i,name:o}=this;if(!s||!s.current)return;o==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=no[o](s.measureViewportBox(),window.getComputedStyle(s.current)),i[0]=this.measuredOrigin;const c=i[i.length-1];c!==void 0&&s.getValue(o,c).jump(c,!1)}measureEndState(){var s;const{element:i,name:o,unresolvedKeyframes:c}=this;if(!i||!i.current)return;const u=i.getValue(o);u&&u.jump(this.measuredOrigin,!1);const d=c.length-1,m=c[d];c[d]=no[o](i.measureViewportBox(),window.getComputedStyle(i.current)),m!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=m),!((s=this.removedTransforms)===null||s===void 0)&&s.length&&this.removedTransforms.forEach(([h,g])=>{i.getValue(h).set(g)}),this.resolveNoneKeyframes()}}const P0=(n,s)=>s==="zIndex"?!1:!!(typeof n=="number"||Array.isArray(n)||typeof n=="string"&&(ha.test(n)||n==="0")&&!n.startsWith("url("));function dj(n){const s=n[0];if(n.length===1)return!0;for(let i=0;i<n.length;i++)if(n[i]!==s)return!0}function fj(n,s,i,o){const c=n[0];if(c===null)return!1;if(s==="display"||s==="visibility")return!0;const u=n[n.length-1],d=P0(c,s),m=P0(u,s);return!d||!m?!1:dj(n)||(i==="spring"||Hp(i))&&o}const pj=n=>n!==null;function Vc(n,{repeat:s,repeatType:i="loop"},o){const c=n.filter(pj),u=s&&i!=="loop"&&s%2===1?0:c.length-1;return!u||o===void 0?c[u]:o}const mj=40;class $_{constructor({autoplay:s=!0,delay:i=0,type:o="keyframes",repeat:c=0,repeatDelay:u=0,repeatType:d="loop",...m}){this.isStopped=!1,this.hasAttemptedResolve=!1,this.createdAt=is.now(),this.options={autoplay:s,delay:i,type:o,repeat:c,repeatDelay:u,repeatType:d,...m},this.updateFinishedPromise()}calcStartTime(){return this.resolvedAt?this.resolvedAt-this.createdAt>mj?this.resolvedAt:this.createdAt:this.createdAt}get resolved(){return!this._resolved&&!this.hasAttemptedResolve&&rj(),this._resolved}onKeyframesResolved(s,i){this.resolvedAt=is.now(),this.hasAttemptedResolve=!0;const{name:o,type:c,velocity:u,delay:d,onComplete:m,onUpdate:h,isGenerator:g}=this.options;if(!g&&!fj(s,o,c,u))if(d)this.options.duration=0;else{h&&h(Vc(s,this.options,i)),m&&m(),this.resolveFinishedPromise();return}const v=this.initPlayback(s,i);v!==!1&&(this._resolved={keyframes:s,finalKeyframe:i,...v},this.onPostResolved())}onPostResolved(){}then(s,i){return this.currentFinishedPromise.then(s,i)}flatten(){this.options.type="keyframes",this.options.ease="linear"}updateFinishedPromise(){this.currentFinishedPromise=new Promise(s=>{this.resolveFinishedPromise=s})}}const Wf=2e4;function F_(n){let s=0;const i=50;let o=n.next(s);for(;!o.done&&s<Wf;)s+=i,o=n.next(s);return s>=Wf?1/0:s}const vt=(n,s,i)=>n+(s-n)*i;function pf(n,s,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?n+(s-n)*6*i:i<1/2?s:i<2/3?n+(s-n)*(2/3-i)*6:n}function hj({hue:n,saturation:s,lightness:i,alpha:o}){n/=360,s/=100,i/=100;let c=0,u=0,d=0;if(!s)c=u=d=i;else{const m=i<.5?i*(1+s):i+s-i*s,h=2*i-m;c=pf(h,m,n+1/3),u=pf(h,m,n),d=pf(h,m,n-1/3)}return{red:Math.round(c*255),green:Math.round(u*255),blue:Math.round(d*255),alpha:o}}function Sc(n,s){return i=>i>0?s:n}const mf=(n,s,i)=>{const o=n*n,c=i*(s*s-o)+o;return c<0?0:Math.sqrt(c)},gj=[Zf,Fa,$i],vj=n=>gj.find(s=>s.test(n));function V0(n){const s=vj(n);if(!s)return!1;let i=s.parse(n);return s===$i&&(i=hj(i)),i}const q0=(n,s)=>{const i=V0(n),o=V0(s);if(!i||!o)return Sc(n,s);const c={...i};return u=>(c.red=mf(i.red,o.red,u),c.green=mf(i.green,o.green,u),c.blue=mf(i.blue,o.blue,u),c.alpha=vt(i.alpha,o.alpha,u),Fa.transform(c))},yj=(n,s)=>i=>s(n(i)),Rr=(...n)=>n.reduce(yj),Xf=new Set(["none","hidden"]);function bj(n,s){return Xf.has(n)?i=>i<=0?n:s:i=>i>=1?s:n}function _j(n,s){return i=>vt(n,s,i)}function Wp(n){return typeof n=="number"?_j:typeof n=="string"?Dp(n)?Sc:Wt.test(n)?q0:Tj:Array.isArray(n)?Z_:typeof n=="object"?Wt.test(n)?q0:xj:Sc}function Z_(n,s){const i=[...n],o=i.length,c=n.map((u,d)=>Wp(u)(u,s[d]));return u=>{for(let d=0;d<o;d++)i[d]=c[d](u);return i}}function xj(n,s){const i={...n,...s},o={};for(const c in i)n[c]!==void 0&&s[c]!==void 0&&(o[c]=Wp(n[c])(n[c],s[c]));return c=>{for(const u in o)i[u]=o[u](c);return i}}function Sj(n,s){var i;const o=[],c={color:0,var:0,number:0};for(let u=0;u<s.values.length;u++){const d=s.types[u],m=n.indexes[d][c[d]],h=(i=n.values[m])!==null&&i!==void 0?i:0;o[u]=h,c[d]++}return o}const Tj=(n,s)=>{const i=ha.createTransformer(s),o=wr(n),c=wr(s);return o.indexes.var.length===c.indexes.var.length&&o.indexes.color.length===c.indexes.color.length&&o.indexes.number.length>=c.indexes.number.length?Xf.has(n)&&!c.values.length||Xf.has(s)&&!o.values.length?bj(n,s):Rr(Z_(Sj(o,c),c.values),i):Sc(n,s)};function K_(n,s,i){return typeof n=="number"&&typeof s=="number"&&typeof i=="number"?vt(n,s,i):Wp(n)(n,s)}const kj=5;function Y_(n,s,i){const o=Math.max(s-kj,0);return y_(i-n(o),s-o)}const _t={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},hf=.001;function wj({duration:n=_t.duration,bounce:s=_t.bounce,velocity:i=_t.velocity,mass:o=_t.mass}){let c,u,d=1-s;d=Is(_t.minDamping,_t.maxDamping,d),n=Is(_t.minDuration,_t.maxDuration,Rs(n)),d<1?(c=g=>{const v=g*d,b=v*n,_=v-i,S=Qf(g,d),T=Math.exp(-b);return hf-_/S*T},u=g=>{const b=g*d*n,_=b*i+i,S=Math.pow(d,2)*Math.pow(g,2)*n,T=Math.exp(-b),N=Qf(Math.pow(g,2),d);return(-c(g)+hf>0?-1:1)*((_-S)*T)/N}):(c=g=>{const v=Math.exp(-g*n),b=(g-i)*n+1;return-hf+v*b},u=g=>{const v=Math.exp(-g*n),b=(i-g)*(n*n);return v*b});const m=5/n,h=jj(c,u,m);if(n=Ds(n),isNaN(h))return{stiffness:_t.stiffness,damping:_t.damping,duration:n};{const g=Math.pow(h,2)*o;return{stiffness:g,damping:d*2*Math.sqrt(o*g),duration:n}}}const Nj=12;function jj(n,s,i){let o=i;for(let c=1;c<Nj;c++)o=o-n(o)/s(o);return o}function Qf(n,s){return n*Math.sqrt(1-s*s)}const Cj=["duration","bounce"],Ej=["stiffness","damping","mass"];function H0(n,s){return s.some(i=>n[i]!==void 0)}function Aj(n){let s={velocity:_t.velocity,stiffness:_t.stiffness,damping:_t.damping,mass:_t.mass,isResolvedFromDuration:!1,...n};if(!H0(n,Ej)&&H0(n,Cj))if(n.visualDuration){const i=n.visualDuration,o=2*Math.PI/(i*1.2),c=o*o,u=2*Is(.05,1,1-(n.bounce||0))*Math.sqrt(c);s={...s,mass:_t.mass,stiffness:c,damping:u}}else{const i=wj(n);s={...s,...i,mass:_t.mass},s.isResolvedFromDuration=!0}return s}function J_(n=_t.visualDuration,s=_t.bounce){const i=typeof n!="object"?{visualDuration:n,keyframes:[0,1],bounce:s}:n;let{restSpeed:o,restDelta:c}=i;const u=i.keyframes[0],d=i.keyframes[i.keyframes.length-1],m={done:!1,value:u},{stiffness:h,damping:g,mass:v,duration:b,velocity:_,isResolvedFromDuration:S}=Aj({...i,velocity:-Rs(i.velocity||0)}),T=_||0,N=g/(2*Math.sqrt(h*v)),j=d-u,w=Rs(Math.sqrt(h/v)),E=Math.abs(j)<5;o||(o=E?_t.restSpeed.granular:_t.restSpeed.default),c||(c=E?_t.restDelta.granular:_t.restDelta.default);let A;if(N<1){const C=Qf(w,N);A=M=>{const G=Math.exp(-N*w*M);return d-G*((T+N*w*j)/C*Math.sin(C*M)+j*Math.cos(C*M))}}else if(N===1)A=C=>d-Math.exp(-w*C)*(j+(T+w*j)*C);else{const C=w*Math.sqrt(N*N-1);A=M=>{const G=Math.exp(-N*w*M),U=Math.min(C*M,300);return d-G*((T+N*w*j)*Math.sinh(U)+C*j*Math.cosh(U))/C}}const O={calculatedDuration:S&&b||null,next:C=>{const M=A(C);if(S)m.done=C>=b;else{let G=0;N<1&&(G=C===0?Ds(T):Y_(A,C,M));const U=Math.abs(G)<=o,V=Math.abs(d-M)<=c;m.done=U&&V}return m.value=m.done?d:M,m},toString:()=>{const C=Math.min(F_(O),Wf),M=__(G=>O.next(C*G).value,C,30);return C+"ms "+M}};return O}function G0({keyframes:n,velocity:s=0,power:i=.8,timeConstant:o=325,bounceDamping:c=10,bounceStiffness:u=500,modifyTarget:d,min:m,max:h,restDelta:g=.5,restSpeed:v}){const b=n[0],_={done:!1,value:b},S=U=>m!==void 0&&U<m||h!==void 0&&U>h,T=U=>m===void 0?h:h===void 0||Math.abs(m-U)<Math.abs(h-U)?m:h;let N=i*s;const j=b+N,w=d===void 0?j:d(j);w!==j&&(N=w-b);const E=U=>-N*Math.exp(-U/o),A=U=>w+E(U),O=U=>{const V=E(U),Z=A(U);_.done=Math.abs(V)<=g,_.value=_.done?w:Z};let C,M;const G=U=>{S(_.value)&&(C=U,M=J_({keyframes:[_.value,T(_.value)],velocity:Y_(A,U,_.value),damping:c,stiffness:u,restDelta:g,restSpeed:v}))};return G(0),{calculatedDuration:null,next:U=>{let V=!1;return!M&&C===void 0&&(V=!0,O(U),G(U)),C!==void 0&&U>=C?M.next(U-C):(!V&&O(U),_)}}}const Dj=Dr(.42,0,1,1),Rj=Dr(0,0,.58,1),W_=Dr(.42,0,.58,1),Mj=n=>Array.isArray(n)&&typeof n[0]!="number",Oj={linear:_n,easeIn:Dj,easeInOut:W_,easeOut:Rj,circIn:Fp,circInOut:A_,circOut:E_,backIn:$p,backInOut:j_,backOut:N_,anticipate:C_},$0=n=>{if(Gp(n)){Wb(n.length===4);const[s,i,o,c]=n;return Dr(s,i,o,c)}else if(typeof n=="string")return Oj[n];return n};function Ij(n,s,i){const o=[],c=i||K_,u=n.length-1;for(let d=0;d<u;d++){let m=c(n[d],n[d+1]);if(s){const h=Array.isArray(s)?s[d]||_n:s;m=Rr(h,m)}o.push(m)}return o}function Bj(n,s,{clamp:i=!0,ease:o,mixer:c}={}){const u=n.length;if(Wb(u===s.length),u===1)return()=>s[0];if(u===2&&s[0]===s[1])return()=>s[1];const d=n[0]===n[1];n[0]>n[u-1]&&(n=[...n].reverse(),s=[...s].reverse());const m=Ij(s,o,c),h=m.length,g=v=>{if(d&&v<n[0])return s[0];let b=0;if(h>1)for(;b<n.length-2&&!(v<n[b+1]);b++);const _=to(n[b],n[b+1],v);return m[b](_)};return i?v=>g(Is(n[0],n[u-1],v)):g}function Lj(n,s){const i=n[n.length-1];for(let o=1;o<=s;o++){const c=to(0,s,o);n.push(vt(i,1,c))}}function Uj(n){const s=[0];return Lj(s,n.length-1),s}function zj(n,s){return n.map(i=>i*s)}function Pj(n,s){return n.map(()=>s||W_).splice(0,n.length-1)}function Tc({duration:n=300,keyframes:s,times:i,ease:o="easeInOut"}){const c=Mj(o)?o.map($0):$0(o),u={done:!1,value:s[0]},d=zj(i&&i.length===s.length?i:Uj(s),n),m=Bj(d,s,{ease:Array.isArray(c)?c:Pj(s,c)});return{calculatedDuration:n,next:h=>(u.value=m(h),u.done=h>=n,u)}}const Vj=n=>{const s=({timestamp:i})=>n(i);return{start:()=>ft.update(s,!0),stop:()=>ma(s),now:()=>Ft.isProcessing?Ft.timestamp:is.now()}},qj={decay:G0,inertia:G0,tween:Tc,keyframes:Tc,spring:J_},Hj=n=>n/100;class Xp extends $_{constructor(s){super(s),this.holdTime=null,this.cancelTime=null,this.currentTime=0,this.playbackSpeed=1,this.pendingPlayState="running",this.startTime=null,this.state="idle",this.stop=()=>{if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.teardown();const{onStop:h}=this.options;h&&h()};const{name:i,motionValue:o,element:c,keyframes:u}=this.options,d=(c==null?void 0:c.KeyframeResolver)||Jp,m=(h,g)=>this.onKeyframesResolved(h,g);this.resolver=new d(u,m,i,o,c),this.resolver.scheduleResolve()}flatten(){super.flatten(),this._resolved&&Object.assign(this._resolved,this.initPlayback(this._resolved.keyframes))}initPlayback(s){const{type:i="keyframes",repeat:o=0,repeatDelay:c=0,repeatType:u,velocity:d=0}=this.options,m=Hp(i)?i:qj[i]||Tc;let h,g;m!==Tc&&typeof s[0]!="number"&&(h=Rr(Hj,K_(s[0],s[1])),s=[0,100]);const v=m({...this.options,keyframes:s});u==="mirror"&&(g=m({...this.options,keyframes:[...s].reverse(),velocity:-d})),v.calculatedDuration===null&&(v.calculatedDuration=F_(v));const{calculatedDuration:b}=v,_=b+c,S=_*(o+1)-c;return{generator:v,mirroredGenerator:g,mapPercentToKeyframes:h,calculatedDuration:b,resolvedDuration:_,totalDuration:S}}onPostResolved(){const{autoplay:s=!0}=this.options;this.play(),this.pendingPlayState==="paused"||!s?this.pause():this.state=this.pendingPlayState}tick(s,i=!1){const{resolved:o}=this;if(!o){const{keyframes:U}=this.options;return{done:!0,value:U[U.length-1]}}const{finalKeyframe:c,generator:u,mirroredGenerator:d,mapPercentToKeyframes:m,keyframes:h,calculatedDuration:g,totalDuration:v,resolvedDuration:b}=o;if(this.startTime===null)return u.next(0);const{delay:_,repeat:S,repeatType:T,repeatDelay:N,onUpdate:j}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,s):this.speed<0&&(this.startTime=Math.min(s-v/this.speed,this.startTime)),i?this.currentTime=s:this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=Math.round(s-this.startTime)*this.speed;const w=this.currentTime-_*(this.speed>=0?1:-1),E=this.speed>=0?w<0:w>v;this.currentTime=Math.max(w,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=v);let A=this.currentTime,O=u;if(S){const U=Math.min(this.currentTime,v)/b;let V=Math.floor(U),Z=U%1;!Z&&U>=1&&(Z=1),Z===1&&V--,V=Math.min(V,S+1),!!(V%2)&&(T==="reverse"?(Z=1-Z,N&&(Z-=N/b)):T==="mirror"&&(O=d)),A=Is(0,1,Z)*b}const C=E?{done:!1,value:h[0]}:O.next(A);m&&(C.value=m(C.value));let{done:M}=C;!E&&g!==null&&(M=this.speed>=0?this.currentTime>=v:this.currentTime<=0);const G=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&M);return G&&c!==void 0&&(C.value=Vc(h,this.options,c)),j&&j(C.value),G&&this.finish(),C}get duration(){const{resolved:s}=this;return s?Rs(s.calculatedDuration):0}get time(){return Rs(this.currentTime)}set time(s){s=Ds(s),this.currentTime=s,this.holdTime!==null||this.speed===0?this.holdTime=s:this.driver&&(this.startTime=this.driver.now()-s/this.speed)}get speed(){return this.playbackSpeed}set speed(s){const i=this.playbackSpeed!==s;this.playbackSpeed=s,i&&(this.time=Rs(this.currentTime))}play(){if(this.resolver.isScheduled||this.resolver.resume(),!this._resolved){this.pendingPlayState="running";return}if(this.isStopped)return;const{driver:s=Vj,onPlay:i,startTime:o}=this.options;this.driver||(this.driver=s(u=>this.tick(u))),i&&i();const c=this.driver.now();this.holdTime!==null?this.startTime=c-this.holdTime:this.startTime?this.state==="finished"&&(this.startTime=c):this.startTime=o??this.calcStartTime(),this.state==="finished"&&this.updateFinishedPromise(),this.cancelTime=this.startTime,this.holdTime=null,this.state="running",this.driver.start()}pause(){var s;if(!this._resolved){this.pendingPlayState="paused";return}this.state="paused",this.holdTime=(s=this.currentTime)!==null&&s!==void 0?s:0}complete(){this.state!=="running"&&this.play(),this.pendingPlayState=this.state="finished",this.holdTime=null}finish(){this.teardown(),this.state="finished";const{onComplete:s}=this.options;s&&s()}cancel(){this.cancelTime!==null&&this.tick(this.cancelTime),this.teardown(),this.updateFinishedPromise()}teardown(){this.state="idle",this.stopDriver(),this.resolveFinishedPromise(),this.updateFinishedPromise(),this.startTime=this.cancelTime=null,this.resolver.cancel()}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(s){return this.startTime=0,this.tick(s,!0)}}const Gj=new Set(["opacity","clipPath","filter","transform"]);function $j(n,s,i,{delay:o=0,duration:c=300,repeat:u=0,repeatType:d="loop",ease:m="easeInOut",times:h}={}){const g={[s]:i};h&&(g.offset=h);const v=S_(m,c);return Array.isArray(v)&&(g.easing=v),n.animate(g,{delay:o,duration:c,easing:Array.isArray(v)?"linear":v,fill:"both",iterations:u+1,direction:d==="reverse"?"alternate":"normal"})}const Fj=qp(()=>Object.hasOwnProperty.call(Element.prototype,"animate")),kc=10,Zj=2e4;function Kj(n){return Hp(n.type)||n.type==="spring"||!x_(n.ease)}function Yj(n,s){const i=new Xp({...s,keyframes:n,repeat:0,delay:0,isGenerator:!0});let o={done:!1,value:n[0]};const c=[];let u=0;for(;!o.done&&u<Zj;)o=i.sample(u),c.push(o.value),u+=kc;return{times:void 0,keyframes:c,duration:u-kc,ease:"linear"}}const X_={anticipate:C_,backInOut:j_,circInOut:A_};function Jj(n){return n in X_}class F0 extends $_{constructor(s){super(s);const{name:i,motionValue:o,element:c,keyframes:u}=this.options;this.resolver=new G_(u,(d,m)=>this.onKeyframesResolved(d,m),i,o,c),this.resolver.scheduleResolve()}initPlayback(s,i){let{duration:o=300,times:c,ease:u,type:d,motionValue:m,name:h,startTime:g}=this.options;if(!m.owner||!m.owner.current)return!1;if(typeof u=="string"&&xc()&&Jj(u)&&(u=X_[u]),Kj(this.options)){const{onComplete:b,onUpdate:_,motionValue:S,element:T,...N}=this.options,j=Yj(s,N);s=j.keyframes,s.length===1&&(s[1]=s[0]),o=j.duration,c=j.times,u=j.ease,d="keyframes"}const v=$j(m.owner.current,h,s,{...this.options,duration:o,times:c,ease:u});return v.startTime=g??this.calcStartTime(),this.pendingTimeline?(O0(v,this.pendingTimeline),this.pendingTimeline=void 0):v.onfinish=()=>{const{onComplete:b}=this.options;m.set(Vc(s,this.options,i)),b&&b(),this.cancel(),this.resolveFinishedPromise()},{animation:v,duration:o,times:c,type:d,ease:u,keyframes:s}}get duration(){const{resolved:s}=this;if(!s)return 0;const{duration:i}=s;return Rs(i)}get time(){const{resolved:s}=this;if(!s)return 0;const{animation:i}=s;return Rs(i.currentTime||0)}set time(s){const{resolved:i}=this;if(!i)return;const{animation:o}=i;o.currentTime=Ds(s)}get speed(){const{resolved:s}=this;if(!s)return 1;const{animation:i}=s;return i.playbackRate}set speed(s){const{resolved:i}=this;if(!i)return;const{animation:o}=i;o.playbackRate=s}get state(){const{resolved:s}=this;if(!s)return"idle";const{animation:i}=s;return i.playState}get startTime(){const{resolved:s}=this;if(!s)return null;const{animation:i}=s;return i.startTime}attachTimeline(s){if(!this._resolved)this.pendingTimeline=s;else{const{resolved:i}=this;if(!i)return _n;const{animation:o}=i;O0(o,s)}return _n}play(){if(this.isStopped)return;const{resolved:s}=this;if(!s)return;const{animation:i}=s;i.playState==="finished"&&this.updateFinishedPromise(),i.play()}pause(){const{resolved:s}=this;if(!s)return;const{animation:i}=s;i.pause()}stop(){if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.resolveFinishedPromise(),this.updateFinishedPromise();const{resolved:s}=this;if(!s)return;const{animation:i,keyframes:o,duration:c,type:u,ease:d,times:m}=s;if(i.playState==="idle"||i.playState==="finished")return;if(this.time){const{motionValue:g,onUpdate:v,onComplete:b,element:_,...S}=this.options,T=new Xp({...S,keyframes:o,duration:c,type:u,ease:d,times:m,isGenerator:!0}),N=Ds(this.time);g.setWithVelocity(T.sample(N-kc).value,T.sample(N).value,kc)}const{onStop:h}=this.options;h&&h(),this.cancel()}complete(){const{resolved:s}=this;s&&s.animation.finish()}cancel(){const{resolved:s}=this;s&&s.animation.cancel()}static supports(s){const{motionValue:i,name:o,repeatDelay:c,repeatType:u,damping:d,type:m}=s;if(!i||!i.owner||!(i.owner.current instanceof HTMLElement))return!1;const{onUpdate:h,transformTemplate:g}=i.owner.getProps();return Fj()&&o&&Gj.has(o)&&!h&&!g&&!c&&u!=="mirror"&&d!==0&&m!=="inertia"}}const Wj={type:"spring",stiffness:500,damping:25,restSpeed:10},Xj=n=>({type:"spring",stiffness:550,damping:n===0?2*Math.sqrt(550):30,restSpeed:10}),Qj={type:"keyframes",duration:.8},eC={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},tC=(n,{keyframes:s})=>s.length>2?Qj:ti.has(n)?n.startsWith("scale")?Xj(s[1]):Wj:eC;function nC({when:n,delay:s,delayChildren:i,staggerChildren:o,staggerDirection:c,repeat:u,repeatType:d,repeatDelay:m,from:h,elapsed:g,...v}){return!!Object.keys(v).length}const Qp=(n,s,i,o={},c,u)=>d=>{const m=Up(o,n)||{},h=m.delay||o.delay||0;let{elapsed:g=0}=o;g=g-Ds(h);let v={keyframes:Array.isArray(i)?i:[null,i],ease:"easeOut",velocity:s.getVelocity(),...m,delay:-g,onUpdate:_=>{s.set(_),m.onUpdate&&m.onUpdate(_)},onComplete:()=>{d(),m.onComplete&&m.onComplete()},name:n,motionValue:s,element:u?void 0:c};nC(m)||(v={...v,...tC(n,v)}),v.duration&&(v.duration=Ds(v.duration)),v.repeatDelay&&(v.repeatDelay=Ds(v.repeatDelay)),v.from!==void 0&&(v.keyframes[0]=v.from);let b=!1;if((v.type===!1||v.duration===0&&!v.repeatDelay)&&(v.duration=0,v.delay===0&&(b=!0)),b&&!u&&s.get()!==void 0){const _=Vc(v.keyframes,m);if(_!==void 0)return ft.update(()=>{v.onUpdate(_),v.onComplete()}),new ON([])}return!u&&F0.supports(v)?new F0(v):new Xp(v)};function sC({protectedKeys:n,needsAnimating:s},i){const o=n.hasOwnProperty(i)&&s[i]!==!0;return s[i]=!1,o}function Q_(n,s,{delay:i=0,transitionOverride:o,type:c}={}){var u;let{transition:d=n.getDefaultTransition(),transitionEnd:m,...h}=s;o&&(d=o);const g=[],v=c&&n.animationState&&n.animationState.getState()[c];for(const b in h){const _=n.getValue(b,(u=n.latestValues[b])!==null&&u!==void 0?u:null),S=h[b];if(S===void 0||v&&sC(v,b))continue;const T={delay:i,...Up(d||{},b)};let N=!1;if(window.MotionHandoffAnimation){const w=b_(n);if(w){const E=window.MotionHandoffAnimation(w,b,ft);E!==null&&(T.startTime=E,N=!0)}}$f(n,b),_.start(Qp(b,_,S,n.shouldReduceMotion&&v_.has(b)?{type:!1}:T,n,N));const j=_.animation;j&&g.push(j)}return m&&Promise.all(g).then(()=>{ft.update(()=>{m&&AN(n,m)})}),g}function ep(n,s,i={}){var o;const c=Pc(n,s,i.type==="exit"?(o=n.presenceContext)===null||o===void 0?void 0:o.custom:void 0);let{transition:u=n.getDefaultTransition()||{}}=c||{};i.transitionOverride&&(u=i.transitionOverride);const d=c?()=>Promise.all(Q_(n,c,i)):()=>Promise.resolve(),m=n.variantChildren&&n.variantChildren.size?(g=0)=>{const{delayChildren:v=0,staggerChildren:b,staggerDirection:_}=u;return aC(n,s,v+g,b,_,i)}:()=>Promise.resolve(),{when:h}=u;if(h){const[g,v]=h==="beforeChildren"?[d,m]:[m,d];return g().then(()=>v())}else return Promise.all([d(),m(i.delay)])}function aC(n,s,i=0,o=0,c=1,u){const d=[],m=(n.variantChildren.size-1)*o,h=c===1?(g=0)=>g*o:(g=0)=>m-g*o;return Array.from(n.variantChildren).sort(iC).forEach((g,v)=>{g.notify("AnimationStart",s),d.push(ep(g,s,{...u,delay:i+h(v)}).then(()=>g.notify("AnimationComplete",s)))}),Promise.all(d)}function iC(n,s){return n.sortNodePosition(s)}function oC(n,s,i={}){n.notify("AnimationStart",s);let o;if(Array.isArray(s)){const c=s.map(u=>ep(n,u,i));o=Promise.all(c)}else if(typeof s=="string")o=ep(n,s,i);else{const c=typeof s=="function"?Pc(n,s,i.custom):s;o=Promise.all(Q_(n,c,i))}return o.then(()=>{n.notify("AnimationComplete",s)})}const rC=Np.length;function ex(n){if(!n)return;if(!n.isControllingVariants){const i=n.parent?ex(n.parent)||{}:{};return n.props.initial!==void 0&&(i.initial=n.props.initial),i}const s={};for(let i=0;i<rC;i++){const o=Np[i],c=n.props[o];(Sr(c)||c===!1)&&(s[o]=c)}return s}const lC=[...wp].reverse(),cC=wp.length;function uC(n){return s=>Promise.all(s.map(({animation:i,options:o})=>oC(n,i,o)))}function dC(n){let s=uC(n),i=Z0(),o=!0;const c=h=>(g,v)=>{var b;const _=Pc(n,v,h==="exit"?(b=n.presenceContext)===null||b===void 0?void 0:b.custom:void 0);if(_){const{transition:S,transitionEnd:T,...N}=_;g={...g,...N,...T}}return g};function u(h){s=h(n)}function d(h){const{props:g}=n,v=ex(n.parent)||{},b=[],_=new Set;let S={},T=1/0;for(let j=0;j<cC;j++){const w=lC[j],E=i[w],A=g[w]!==void 0?g[w]:v[w],O=Sr(A),C=w===h?E.isActive:null;C===!1&&(T=j);let M=A===v[w]&&A!==g[w]&&O;if(M&&o&&n.manuallyAnimateOnMount&&(M=!1),E.protectedKeys={...S},!E.isActive&&C===null||!A&&!E.prevProp||Uc(A)||typeof A=="boolean")continue;const G=fC(E.prevProp,A);let U=G||w===h&&E.isActive&&!M&&O||j>T&&O,V=!1;const Z=Array.isArray(A)?A:[A];let ee=Z.reduce(c(w),{});C===!1&&(ee={});const{prevResolvedValues:ie={}}=E,be={...ie,...ee},K=$=>{U=!0,_.has($)&&(V=!0,_.delete($)),E.needsAnimating[$]=!0;const Q=n.getValue($);Q&&(Q.liveStyle=!1)};for(const $ in be){const Q=ee[$],de=ie[$];if(S.hasOwnProperty($))continue;let me=!1;Gf(Q)&&Gf(de)?me=!g_(Q,de):me=Q!==de,me?Q!=null?K($):_.add($):Q!==void 0&&_.has($)?K($):E.protectedKeys[$]=!0}E.prevProp=A,E.prevResolvedValues=ee,E.isActive&&(S={...S,...ee}),o&&n.blockInitialAnimation&&(U=!1),U&&(!(M&&G)||V)&&b.push(...Z.map($=>({animation:$,options:{type:w}})))}if(_.size){const j={};_.forEach(w=>{const E=n.getBaseTarget(w),A=n.getValue(w);A&&(A.liveStyle=!0),j[w]=E??null}),b.push({animation:j})}let N=!!b.length;return o&&(g.initial===!1||g.initial===g.animate)&&!n.manuallyAnimateOnMount&&(N=!1),o=!1,N?s(b):Promise.resolve()}function m(h,g){var v;if(i[h].isActive===g)return Promise.resolve();(v=n.variantChildren)===null||v===void 0||v.forEach(_=>{var S;return(S=_.animationState)===null||S===void 0?void 0:S.setActive(h,g)}),i[h].isActive=g;const b=d(h);for(const _ in i)i[_].protectedKeys={};return b}return{animateChanges:d,setActive:m,setAnimateFunction:u,getState:()=>i,reset:()=>{i=Z0(),o=!0}}}function fC(n,s){return typeof s=="string"?s!==n:Array.isArray(s)?!g_(s,n):!1}function Pa(n=!1){return{isActive:n,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Z0(){return{animate:Pa(!0),whileInView:Pa(),whileHover:Pa(),whileTap:Pa(),whileDrag:Pa(),whileFocus:Pa(),exit:Pa()}}class ya{constructor(s){this.isMounted=!1,this.node=s}update(){}}class pC extends ya{constructor(s){super(s),s.animationState||(s.animationState=dC(s))}updateAnimationControlsSubscription(){const{animate:s}=this.node.getProps();Uc(s)&&(this.unmountControls=s.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:s}=this.node.getProps(),{animate:i}=this.node.prevProps||{};s!==i&&this.updateAnimationControlsSubscription()}unmount(){var s;this.node.animationState.reset(),(s=this.unmountControls)===null||s===void 0||s.call(this)}}let mC=0;class hC extends ya{constructor(){super(...arguments),this.id=mC++}update(){if(!this.node.presenceContext)return;const{isPresent:s,onExitComplete:i}=this.node.presenceContext,{isPresent:o}=this.node.prevPresenceContext||{};if(!this.node.animationState||s===o)return;const c=this.node.animationState.setActive("exit",!s);i&&!s&&c.then(()=>i(this.id))}mount(){const{register:s}=this.node.presenceContext||{};s&&(this.unmount=s(this.id))}unmount(){}}const gC={animation:{Feature:pC},exit:{Feature:hC}},Fn={x:!1,y:!1};function tx(){return Fn.x||Fn.y}function vC(n){return n==="x"||n==="y"?Fn[n]?null:(Fn[n]=!0,()=>{Fn[n]=!1}):Fn.x||Fn.y?null:(Fn.x=Fn.y=!0,()=>{Fn.x=Fn.y=!1})}const em=n=>n.pointerType==="mouse"?typeof n.button!="number"||n.button<=0:n.isPrimary!==!1;function Nr(n,s,i,o={passive:!0}){return n.addEventListener(s,i,o),()=>n.removeEventListener(s,i)}function Mr(n){return{point:{x:n.pageX,y:n.pageY}}}const yC=n=>s=>em(s)&&n(s,Mr(s));function gr(n,s,i,o){return Nr(n,s,yC(i),o)}const K0=(n,s)=>Math.abs(n-s);function bC(n,s){const i=K0(n.x,s.x),o=K0(n.y,s.y);return Math.sqrt(i**2+o**2)}class nx{constructor(s,i,{transformPagePoint:o,contextWindow:c,dragSnapToOrigin:u=!1}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const b=vf(this.lastMoveEventInfo,this.history),_=this.startEvent!==null,S=bC(b.offset,{x:0,y:0})>=3;if(!_&&!S)return;const{point:T}=b,{timestamp:N}=Ft;this.history.push({...T,timestamp:N});const{onStart:j,onMove:w}=this.handlers;_||(j&&j(this.lastMoveEvent,b),this.startEvent=this.lastMoveEvent),w&&w(this.lastMoveEvent,b)},this.handlePointerMove=(b,_)=>{this.lastMoveEvent=b,this.lastMoveEventInfo=gf(_,this.transformPagePoint),ft.update(this.updatePoint,!0)},this.handlePointerUp=(b,_)=>{this.end();const{onEnd:S,onSessionEnd:T,resumeAnimation:N}=this.handlers;if(this.dragSnapToOrigin&&N&&N(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const j=vf(b.type==="pointercancel"?this.lastMoveEventInfo:gf(_,this.transformPagePoint),this.history);this.startEvent&&S&&S(b,j),T&&T(b,j)},!em(s))return;this.dragSnapToOrigin=u,this.handlers=i,this.transformPagePoint=o,this.contextWindow=c||window;const d=Mr(s),m=gf(d,this.transformPagePoint),{point:h}=m,{timestamp:g}=Ft;this.history=[{...h,timestamp:g}];const{onSessionStart:v}=i;v&&v(s,vf(m,this.history)),this.removeListeners=Rr(gr(this.contextWindow,"pointermove",this.handlePointerMove),gr(this.contextWindow,"pointerup",this.handlePointerUp),gr(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(s){this.handlers=s}end(){this.removeListeners&&this.removeListeners(),ma(this.updatePoint)}}function gf(n,s){return s?{point:s(n.point)}:n}function Y0(n,s){return{x:n.x-s.x,y:n.y-s.y}}function vf({point:n},s){return{point:n,delta:Y0(n,sx(s)),offset:Y0(n,_C(s)),velocity:xC(s,.1)}}function _C(n){return n[0]}function sx(n){return n[n.length-1]}function xC(n,s){if(n.length<2)return{x:0,y:0};let i=n.length-1,o=null;const c=sx(n);for(;i>=0&&(o=n[i],!(c.timestamp-o.timestamp>Ds(s)));)i--;if(!o)return{x:0,y:0};const u=Rs(c.timestamp-o.timestamp);if(u===0)return{x:0,y:0};const d={x:(c.x-o.x)/u,y:(c.y-o.y)/u};return d.x===1/0&&(d.x=0),d.y===1/0&&(d.y=0),d}const ax=1e-4,SC=1-ax,TC=1+ax,ix=.01,kC=0-ix,wC=0+ix;function xn(n){return n.max-n.min}function NC(n,s,i){return Math.abs(n-s)<=i}function J0(n,s,i,o=.5){n.origin=o,n.originPoint=vt(s.min,s.max,n.origin),n.scale=xn(i)/xn(s),n.translate=vt(i.min,i.max,n.origin)-n.originPoint,(n.scale>=SC&&n.scale<=TC||isNaN(n.scale))&&(n.scale=1),(n.translate>=kC&&n.translate<=wC||isNaN(n.translate))&&(n.translate=0)}function vr(n,s,i,o){J0(n.x,s.x,i.x,o?o.originX:void 0),J0(n.y,s.y,i.y,o?o.originY:void 0)}function W0(n,s,i){n.min=i.min+s.min,n.max=n.min+xn(s)}function jC(n,s,i){W0(n.x,s.x,i.x),W0(n.y,s.y,i.y)}function X0(n,s,i){n.min=s.min-i.min,n.max=n.min+xn(s)}function yr(n,s,i){X0(n.x,s.x,i.x),X0(n.y,s.y,i.y)}function CC(n,{min:s,max:i},o){return s!==void 0&&n<s?n=o?vt(s,n,o.min):Math.max(n,s):i!==void 0&&n>i&&(n=o?vt(i,n,o.max):Math.min(n,i)),n}function Q0(n,s,i){return{min:s!==void 0?n.min+s:void 0,max:i!==void 0?n.max+i-(n.max-n.min):void 0}}function EC(n,{top:s,left:i,bottom:o,right:c}){return{x:Q0(n.x,i,c),y:Q0(n.y,s,o)}}function ey(n,s){let i=s.min-n.min,o=s.max-n.max;return s.max-s.min<n.max-n.min&&([i,o]=[o,i]),{min:i,max:o}}function AC(n,s){return{x:ey(n.x,s.x),y:ey(n.y,s.y)}}function DC(n,s){let i=.5;const o=xn(n),c=xn(s);return c>o?i=to(s.min,s.max-o,n.min):o>c&&(i=to(n.min,n.max-c,s.min)),Is(0,1,i)}function RC(n,s){const i={};return s.min!==void 0&&(i.min=s.min-n.min),s.max!==void 0&&(i.max=s.max-n.min),i}const tp=.35;function MC(n=tp){return n===!1?n=0:n===!0&&(n=tp),{x:ty(n,"left","right"),y:ty(n,"top","bottom")}}function ty(n,s,i){return{min:ny(n,s),max:ny(n,i)}}function ny(n,s){return typeof n=="number"?n:n[s]||0}const sy=()=>({translate:0,scale:1,origin:0,originPoint:0}),Fi=()=>({x:sy(),y:sy()}),ay=()=>({min:0,max:0}),Nt=()=>({x:ay(),y:ay()});function Bn(n){return[n("x"),n("y")]}function ox({top:n,left:s,right:i,bottom:o}){return{x:{min:s,max:i},y:{min:n,max:o}}}function OC({x:n,y:s}){return{top:s.min,right:n.max,bottom:s.max,left:n.min}}function IC(n,s){if(!s)return n;const i=s({x:n.left,y:n.top}),o=s({x:n.right,y:n.bottom});return{top:i.y,left:i.x,bottom:o.y,right:o.x}}function yf(n){return n===void 0||n===1}function np({scale:n,scaleX:s,scaleY:i}){return!yf(n)||!yf(s)||!yf(i)}function Ga(n){return np(n)||rx(n)||n.z||n.rotate||n.rotateX||n.rotateY||n.skewX||n.skewY}function rx(n){return iy(n.x)||iy(n.y)}function iy(n){return n&&n!=="0%"}function wc(n,s,i){const o=n-i,c=s*o;return i+c}function oy(n,s,i,o,c){return c!==void 0&&(n=wc(n,c,o)),wc(n,i,o)+s}function sp(n,s=0,i=1,o,c){n.min=oy(n.min,s,i,o,c),n.max=oy(n.max,s,i,o,c)}function lx(n,{x:s,y:i}){sp(n.x,s.translate,s.scale,s.originPoint),sp(n.y,i.translate,i.scale,i.originPoint)}const ry=.999999999999,ly=1.0000000000001;function BC(n,s,i,o=!1){const c=i.length;if(!c)return;s.x=s.y=1;let u,d;for(let m=0;m<c;m++){u=i[m],d=u.projectionDelta;const{visualElement:h}=u.options;h&&h.props.style&&h.props.style.display==="contents"||(o&&u.options.layoutScroll&&u.scroll&&u!==u.root&&Ki(n,{x:-u.scroll.offset.x,y:-u.scroll.offset.y}),d&&(s.x*=d.x.scale,s.y*=d.y.scale,lx(n,d)),o&&Ga(u.latestValues)&&Ki(n,u.latestValues))}s.x<ly&&s.x>ry&&(s.x=1),s.y<ly&&s.y>ry&&(s.y=1)}function Zi(n,s){n.min=n.min+s,n.max=n.max+s}function cy(n,s,i,o,c=.5){const u=vt(n.min,n.max,c);sp(n,s,i,u,o)}function Ki(n,s){cy(n.x,s.x,s.scaleX,s.scale,s.originX),cy(n.y,s.y,s.scaleY,s.scale,s.originY)}function cx(n,s){return ox(IC(n.getBoundingClientRect(),s))}function LC(n,s,i){const o=cx(n,i),{scroll:c}=s;return c&&(Zi(o.x,c.offset.x),Zi(o.y,c.offset.y)),o}const ux=({current:n})=>n?n.ownerDocument.defaultView:null,UC=new WeakMap;class zC{constructor(s){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Nt(),this.visualElement=s}start(s,{snapToCursor:i=!1}={}){const{presenceContext:o}=this.visualElement;if(o&&o.isPresent===!1)return;const c=v=>{const{dragSnapToOrigin:b}=this.getProps();b?this.pauseAnimation():this.stopAnimation(),i&&this.snapToCursor(Mr(v).point)},u=(v,b)=>{const{drag:_,dragPropagation:S,onDragStart:T}=this.getProps();if(_&&!S&&(this.openDragLock&&this.openDragLock(),this.openDragLock=vC(_),!this.openDragLock))return;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Bn(j=>{let w=this.getAxisMotionValue(j).get()||0;if(as.test(w)){const{projection:E}=this.visualElement;if(E&&E.layout){const A=E.layout.layoutBox[j];A&&(w=xn(A)*(parseFloat(w)/100))}}this.originPoint[j]=w}),T&&ft.postRender(()=>T(v,b)),$f(this.visualElement,"transform");const{animationState:N}=this.visualElement;N&&N.setActive("whileDrag",!0)},d=(v,b)=>{const{dragPropagation:_,dragDirectionLock:S,onDirectionLock:T,onDrag:N}=this.getProps();if(!_&&!this.openDragLock)return;const{offset:j}=b;if(S&&this.currentDirection===null){this.currentDirection=PC(j),this.currentDirection!==null&&T&&T(this.currentDirection);return}this.updateAxis("x",b.point,j),this.updateAxis("y",b.point,j),this.visualElement.render(),N&&N(v,b)},m=(v,b)=>this.stop(v,b),h=()=>Bn(v=>{var b;return this.getAnimationState(v)==="paused"&&((b=this.getAxisMotionValue(v).animation)===null||b===void 0?void 0:b.play())}),{dragSnapToOrigin:g}=this.getProps();this.panSession=new nx(s,{onSessionStart:c,onStart:u,onMove:d,onSessionEnd:m,resumeAnimation:h},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:g,contextWindow:ux(this.visualElement)})}stop(s,i){const o=this.isDragging;if(this.cancel(),!o)return;const{velocity:c}=i;this.startAnimation(c);const{onDragEnd:u}=this.getProps();u&&ft.postRender(()=>u(s,i))}cancel(){this.isDragging=!1;const{projection:s,animationState:i}=this.visualElement;s&&(s.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:o}=this.getProps();!o&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),i&&i.setActive("whileDrag",!1)}updateAxis(s,i,o){const{drag:c}=this.getProps();if(!o||!ac(s,c,this.currentDirection))return;const u=this.getAxisMotionValue(s);let d=this.originPoint[s]+o[s];this.constraints&&this.constraints[s]&&(d=CC(d,this.constraints[s],this.elastic[s])),u.set(d)}resolveConstraints(){var s;const{dragConstraints:i,dragElastic:o}=this.getProps(),c=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(s=this.visualElement.projection)===null||s===void 0?void 0:s.layout,u=this.constraints;i&&Gi(i)?this.constraints||(this.constraints=this.resolveRefConstraints()):i&&c?this.constraints=EC(c.layoutBox,i):this.constraints=!1,this.elastic=MC(o),u!==this.constraints&&c&&this.constraints&&!this.hasMutatedConstraints&&Bn(d=>{this.constraints!==!1&&this.getAxisMotionValue(d)&&(this.constraints[d]=RC(c.layoutBox[d],this.constraints[d]))})}resolveRefConstraints(){const{dragConstraints:s,onMeasureDragConstraints:i}=this.getProps();if(!s||!Gi(s))return!1;const o=s.current,{projection:c}=this.visualElement;if(!c||!c.layout)return!1;const u=LC(o,c.root,this.visualElement.getTransformPagePoint());let d=AC(c.layout.layoutBox,u);if(i){const m=i(OC(d));this.hasMutatedConstraints=!!m,m&&(d=ox(m))}return d}startAnimation(s){const{drag:i,dragMomentum:o,dragElastic:c,dragTransition:u,dragSnapToOrigin:d,onDragTransitionEnd:m}=this.getProps(),h=this.constraints||{},g=Bn(v=>{if(!ac(v,i,this.currentDirection))return;let b=h&&h[v]||{};d&&(b={min:0,max:0});const _=c?200:1e6,S=c?40:1e7,T={type:"inertia",velocity:o?s[v]:0,bounceStiffness:_,bounceDamping:S,timeConstant:750,restDelta:1,restSpeed:10,...u,...b};return this.startAxisValueAnimation(v,T)});return Promise.all(g).then(m)}startAxisValueAnimation(s,i){const o=this.getAxisMotionValue(s);return $f(this.visualElement,s),o.start(Qp(s,o,0,i,this.visualElement,!1))}stopAnimation(){Bn(s=>this.getAxisMotionValue(s).stop())}pauseAnimation(){Bn(s=>{var i;return(i=this.getAxisMotionValue(s).animation)===null||i===void 0?void 0:i.pause()})}getAnimationState(s){var i;return(i=this.getAxisMotionValue(s).animation)===null||i===void 0?void 0:i.state}getAxisMotionValue(s){const i=`_drag${s.toUpperCase()}`,o=this.visualElement.getProps(),c=o[i];return c||this.visualElement.getValue(s,(o.initial?o.initial[s]:void 0)||0)}snapToCursor(s){Bn(i=>{const{drag:o}=this.getProps();if(!ac(i,o,this.currentDirection))return;const{projection:c}=this.visualElement,u=this.getAxisMotionValue(i);if(c&&c.layout){const{min:d,max:m}=c.layout.layoutBox[i];u.set(s[i]-vt(d,m,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:s,dragConstraints:i}=this.getProps(),{projection:o}=this.visualElement;if(!Gi(i)||!o||!this.constraints)return;this.stopAnimation();const c={x:0,y:0};Bn(d=>{const m=this.getAxisMotionValue(d);if(m&&this.constraints!==!1){const h=m.get();c[d]=DC({min:h,max:h},this.constraints[d])}});const{transformTemplate:u}=this.visualElement.getProps();this.visualElement.current.style.transform=u?u({},""):"none",o.root&&o.root.updateScroll(),o.updateLayout(),this.resolveConstraints(),Bn(d=>{if(!ac(d,s,null))return;const m=this.getAxisMotionValue(d),{min:h,max:g}=this.constraints[d];m.set(vt(h,g,c[d]))})}addListeners(){if(!this.visualElement.current)return;UC.set(this.visualElement,this);const s=this.visualElement.current,i=gr(s,"pointerdown",h=>{const{drag:g,dragListener:v=!0}=this.getProps();g&&v&&this.start(h)}),o=()=>{const{dragConstraints:h}=this.getProps();Gi(h)&&h.current&&(this.constraints=this.resolveRefConstraints())},{projection:c}=this.visualElement,u=c.addEventListener("measure",o);c&&!c.layout&&(c.root&&c.root.updateScroll(),c.updateLayout()),ft.read(o);const d=Nr(window,"resize",()=>this.scalePositionWithinConstraints()),m=c.addEventListener("didUpdate",(({delta:h,hasLayoutChanged:g})=>{this.isDragging&&g&&(Bn(v=>{const b=this.getAxisMotionValue(v);b&&(this.originPoint[v]+=h[v].translate,b.set(b.get()+h[v].translate))}),this.visualElement.render())}));return()=>{d(),i(),u(),m&&m()}}getProps(){const s=this.visualElement.getProps(),{drag:i=!1,dragDirectionLock:o=!1,dragPropagation:c=!1,dragConstraints:u=!1,dragElastic:d=tp,dragMomentum:m=!0}=s;return{...s,drag:i,dragDirectionLock:o,dragPropagation:c,dragConstraints:u,dragElastic:d,dragMomentum:m}}}function ac(n,s,i){return(s===!0||s===n)&&(i===null||i===n)}function PC(n,s=10){let i=null;return Math.abs(n.y)>s?i="y":Math.abs(n.x)>s&&(i="x"),i}class VC extends ya{constructor(s){super(s),this.removeGroupControls=_n,this.removeListeners=_n,this.controls=new zC(s)}mount(){const{dragControls:s}=this.node.getProps();s&&(this.removeGroupControls=s.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||_n}unmount(){this.removeGroupControls(),this.removeListeners()}}const uy=n=>(s,i)=>{n&&ft.postRender(()=>n(s,i))};class qC extends ya{constructor(){super(...arguments),this.removePointerDownListener=_n}onPointerDown(s){this.session=new nx(s,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:ux(this.node)})}createPanHandlers(){const{onPanSessionStart:s,onPanStart:i,onPan:o,onPanEnd:c}=this.node.getProps();return{onSessionStart:uy(s),onStart:uy(i),onMove:o,onEnd:(u,d)=>{delete this.session,c&&ft.postRender(()=>c(u,d))}}}mount(){this.removePointerDownListener=gr(this.node.current,"pointerdown",s=>this.onPointerDown(s))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const hc={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function dy(n,s){return s.max===s.min?0:n/(s.max-s.min)*100}const or={correct:(n,s)=>{if(!s.target)return n;if(typeof n=="string")if(ke.test(n))n=parseFloat(n);else return n;const i=dy(n,s.target.x),o=dy(n,s.target.y);return`${i}% ${o}%`}},HC={correct:(n,{treeScale:s,projectionDelta:i})=>{const o=n,c=ha.parse(n);if(c.length>5)return o;const u=ha.createTransformer(n),d=typeof c[0]!="number"?1:0,m=i.x.scale*s.x,h=i.y.scale*s.y;c[0+d]/=m,c[1+d]/=h;const g=vt(m,h,.5);return typeof c[2+d]=="number"&&(c[2+d]/=g),typeof c[3+d]=="number"&&(c[3+d]/=g),u(c)}};class GC extends y.Component{componentDidMount(){const{visualElement:s,layoutGroup:i,switchLayoutGroup:o,layoutId:c}=this.props,{projection:u}=s;gN($C),u&&(i.group&&i.group.add(u),o&&o.register&&c&&o.register(u),u.root.didUpdate(),u.addEventListener("animationComplete",()=>{this.safeToRemove()}),u.setOptions({...u.options,onExitComplete:()=>this.safeToRemove()})),hc.hasEverUpdated=!0}getSnapshotBeforeUpdate(s){const{layoutDependency:i,visualElement:o,drag:c,isPresent:u}=this.props,d=o.projection;return d&&(d.isPresent=u,c||s.layoutDependency!==i||i===void 0?d.willUpdate():this.safeToRemove(),s.isPresent!==u&&(u?d.promote():d.relegate()||ft.postRender(()=>{const m=d.getStack();(!m||!m.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:s}=this.props.visualElement;s&&(s.root.didUpdate(),Cp.postRender(()=>{!s.currentAnimation&&s.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:s,layoutGroup:i,switchLayoutGroup:o}=this.props,{projection:c}=s;c&&(c.scheduleCheckAfterUnmount(),i&&i.group&&i.group.remove(c),o&&o.deregister&&o.deregister(c))}safeToRemove(){const{safeToRemove:s}=this.props;s&&s()}render(){return null}}function dx(n){const[s,i]=Yb(),o=y.useContext(xp);return l.jsx(GC,{...n,layoutGroup:o,switchLayoutGroup:y.useContext(s_),isPresent:s,safeToRemove:i})}const $C={borderRadius:{...or,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:or,borderTopRightRadius:or,borderBottomLeftRadius:or,borderBottomRightRadius:or,boxShadow:HC};function FC(n,s,i){const o=Xt(n)?n:kr(n);return o.start(Qp("",o,s,i)),o.animation}function ZC(n){return n instanceof SVGElement&&n.tagName!=="svg"}const KC=(n,s)=>n.depth-s.depth;class YC{constructor(){this.children=[],this.isDirty=!1}add(s){zp(this.children,s),this.isDirty=!0}remove(s){Pp(this.children,s),this.isDirty=!0}forEach(s){this.isDirty&&this.children.sort(KC),this.isDirty=!1,this.children.forEach(s)}}function JC(n,s){const i=is.now(),o=({timestamp:c})=>{const u=c-i;u>=s&&(ma(o),n(u-s))};return ft.read(o,!0),()=>ma(o)}const fx=["TopLeft","TopRight","BottomLeft","BottomRight"],WC=fx.length,fy=n=>typeof n=="string"?parseFloat(n):n,py=n=>typeof n=="number"||ke.test(n);function XC(n,s,i,o,c,u){c?(n.opacity=vt(0,i.opacity!==void 0?i.opacity:1,QC(o)),n.opacityExit=vt(s.opacity!==void 0?s.opacity:1,0,eE(o))):u&&(n.opacity=vt(s.opacity!==void 0?s.opacity:1,i.opacity!==void 0?i.opacity:1,o));for(let d=0;d<WC;d++){const m=`border${fx[d]}Radius`;let h=my(s,m),g=my(i,m);if(h===void 0&&g===void 0)continue;h||(h=0),g||(g=0),h===0||g===0||py(h)===py(g)?(n[m]=Math.max(vt(fy(h),fy(g),o),0),(as.test(g)||as.test(h))&&(n[m]+="%")):n[m]=g}(s.rotate||i.rotate)&&(n.rotate=vt(s.rotate||0,i.rotate||0,o))}function my(n,s){return n[s]!==void 0?n[s]:n.borderRadius}const QC=px(0,.5,E_),eE=px(.5,.95,_n);function px(n,s,i){return o=>o<n?0:o>s?1:i(to(n,s,o))}function hy(n,s){n.min=s.min,n.max=s.max}function On(n,s){hy(n.x,s.x),hy(n.y,s.y)}function gy(n,s){n.translate=s.translate,n.scale=s.scale,n.originPoint=s.originPoint,n.origin=s.origin}function vy(n,s,i,o,c){return n-=s,n=wc(n,1/i,o),c!==void 0&&(n=wc(n,1/c,o)),n}function tE(n,s=0,i=1,o=.5,c,u=n,d=n){if(as.test(s)&&(s=parseFloat(s),s=vt(d.min,d.max,s/100)-d.min),typeof s!="number")return;let m=vt(u.min,u.max,o);n===u&&(m-=s),n.min=vy(n.min,s,i,m,c),n.max=vy(n.max,s,i,m,c)}function yy(n,s,[i,o,c],u,d){tE(n,s[i],s[o],s[c],s.scale,u,d)}const nE=["x","scaleX","originX"],sE=["y","scaleY","originY"];function by(n,s,i,o){yy(n.x,s,nE,i?i.x:void 0,o?o.x:void 0),yy(n.y,s,sE,i?i.y:void 0,o?o.y:void 0)}function _y(n){return n.translate===0&&n.scale===1}function mx(n){return _y(n.x)&&_y(n.y)}function xy(n,s){return n.min===s.min&&n.max===s.max}function aE(n,s){return xy(n.x,s.x)&&xy(n.y,s.y)}function Sy(n,s){return Math.round(n.min)===Math.round(s.min)&&Math.round(n.max)===Math.round(s.max)}function hx(n,s){return Sy(n.x,s.x)&&Sy(n.y,s.y)}function Ty(n){return xn(n.x)/xn(n.y)}function ky(n,s){return n.translate===s.translate&&n.scale===s.scale&&n.originPoint===s.originPoint}class iE{constructor(){this.members=[]}add(s){zp(this.members,s),s.scheduleRender()}remove(s){if(Pp(this.members,s),s===this.prevLead&&(this.prevLead=void 0),s===this.lead){const i=this.members[this.members.length-1];i&&this.promote(i)}}relegate(s){const i=this.members.findIndex(c=>s===c);if(i===0)return!1;let o;for(let c=i;c>=0;c--){const u=this.members[c];if(u.isPresent!==!1){o=u;break}}return o?(this.promote(o),!0):!1}promote(s,i){const o=this.lead;if(s!==o&&(this.prevLead=o,this.lead=s,s.show(),o)){o.instance&&o.scheduleRender(),s.scheduleRender(),s.resumeFrom=o,i&&(s.resumeFrom.preserveOpacity=!0),o.snapshot&&(s.snapshot=o.snapshot,s.snapshot.latestValues=o.animationValues||o.latestValues),s.root&&s.root.isUpdating&&(s.isLayoutDirty=!0);const{crossfade:c}=s.options;c===!1&&o.hide()}}exitAnimationComplete(){this.members.forEach(s=>{const{options:i,resumingFrom:o}=s;i.onExitComplete&&i.onExitComplete(),o&&o.options.onExitComplete&&o.options.onExitComplete()})}scheduleRender(){this.members.forEach(s=>{s.instance&&s.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function oE(n,s,i){let o="";const c=n.x.translate/s.x,u=n.y.translate/s.y,d=(i==null?void 0:i.z)||0;if((c||u||d)&&(o=`translate3d(${c}px, ${u}px, ${d}px) `),(s.x!==1||s.y!==1)&&(o+=`scale(${1/s.x}, ${1/s.y}) `),i){const{transformPerspective:g,rotate:v,rotateX:b,rotateY:_,skewX:S,skewY:T}=i;g&&(o=`perspective(${g}px) ${o}`),v&&(o+=`rotate(${v}deg) `),b&&(o+=`rotateX(${b}deg) `),_&&(o+=`rotateY(${_}deg) `),S&&(o+=`skewX(${S}deg) `),T&&(o+=`skewY(${T}deg) `)}const m=n.x.scale*s.x,h=n.y.scale*s.y;return(m!==1||h!==1)&&(o+=`scale(${m}, ${h})`),o||"none"}const $a={type:"projectionFrame",totalNodes:0,resolvedTargetDeltas:0,recalculatedProjection:0},dr=typeof window<"u"&&window.MotionDebug!==void 0,bf=["","X","Y","Z"],rE={visibility:"hidden"},wy=1e3;let lE=0;function _f(n,s,i,o){const{latestValues:c}=s;c[n]&&(i[n]=c[n],s.setStaticValue(n,0),o&&(o[n]=0))}function gx(n){if(n.hasCheckedOptimisedAppear=!0,n.root===n)return;const{visualElement:s}=n.options;if(!s)return;const i=b_(s);if(window.MotionHasOptimisedAnimation(i,"transform")){const{layout:c,layoutId:u}=n.options;window.MotionCancelOptimisedAnimation(i,"transform",ft,!(c||u))}const{parent:o}=n;o&&!o.hasCheckedOptimisedAppear&&gx(o)}function vx({attachResizeListener:n,defaultParent:s,measureScroll:i,checkIsScrollRoot:o,resetTransform:c}){return class{constructor(d={},m=s==null?void 0:s()){this.id=lE++,this.animationId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,dr&&($a.totalNodes=$a.resolvedTargetDeltas=$a.recalculatedProjection=0),this.nodes.forEach(dE),this.nodes.forEach(gE),this.nodes.forEach(vE),this.nodes.forEach(fE),dr&&window.MotionDebug.record($a)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=d,this.root=m?m.root||m:this,this.path=m?[...m.path,m]:[],this.parent=m,this.depth=m?m.depth+1:0;for(let h=0;h<this.path.length;h++)this.path[h].shouldResetTransform=!0;this.root===this&&(this.nodes=new YC)}addEventListener(d,m){return this.eventHandlers.has(d)||this.eventHandlers.set(d,new Vp),this.eventHandlers.get(d).add(m)}notifyListeners(d,...m){const h=this.eventHandlers.get(d);h&&h.notify(...m)}hasListeners(d){return this.eventHandlers.has(d)}mount(d,m=this.root.hasTreeAnimated){if(this.instance)return;this.isSVG=ZC(d),this.instance=d;const{layoutId:h,layout:g,visualElement:v}=this.options;if(v&&!v.current&&v.mount(d),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),m&&(g||h)&&(this.isLayoutDirty=!0),n){let b;const _=()=>this.root.updateBlockedByResize=!1;n(d,()=>{this.root.updateBlockedByResize=!0,b&&b(),b=JC(_,250),hc.hasAnimatedSinceResize&&(hc.hasAnimatedSinceResize=!1,this.nodes.forEach(jy))})}h&&this.root.registerSharedNode(h,this),this.options.animate!==!1&&v&&(h||g)&&this.addEventListener("didUpdate",({delta:b,hasLayoutChanged:_,hasRelativeTargetChanged:S,layout:T})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const N=this.options.transition||v.getDefaultTransition()||SE,{onLayoutAnimationStart:j,onLayoutAnimationComplete:w}=v.getProps(),E=!this.targetLayout||!hx(this.targetLayout,T)||S,A=!_&&S;if(this.options.layoutRoot||this.resumeFrom&&this.resumeFrom.instance||A||_&&(E||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0),this.setAnimationOrigin(b,A);const O={...Up(N,"layout"),onPlay:j,onComplete:w};(v.shouldReduceMotion||this.options.layoutRoot)&&(O.delay=0,O.type=!1),this.startAnimation(O)}else _||jy(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=T})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const d=this.getStack();d&&d.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,ma(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(yE),this.animationId++)}getTransformTemplate(){const{visualElement:d}=this.options;return d&&d.getProps().transformTemplate}willUpdate(d=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&gx(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let v=0;v<this.path.length;v++){const b=this.path[v];b.shouldResetTransform=!0,b.updateScroll("snapshot"),b.options.layoutRoot&&b.willUpdate(!1)}const{layoutId:m,layout:h}=this.options;if(m===void 0&&!h)return;const g=this.getTransformTemplate();this.prevTransformTemplateValue=g?g(this.latestValues,""):void 0,this.updateSnapshot(),d&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Ny);return}this.isUpdating||this.nodes.forEach(mE),this.isUpdating=!1,this.nodes.forEach(hE),this.nodes.forEach(cE),this.nodes.forEach(uE),this.clearAllSnapshots();const m=is.now();Ft.delta=Is(0,1e3/60,m-Ft.timestamp),Ft.timestamp=m,Ft.isProcessing=!0,df.update.process(Ft),df.preRender.process(Ft),df.render.process(Ft),Ft.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Cp.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(pE),this.sharedNodes.forEach(bE)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,ft.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){ft.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure())}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let h=0;h<this.path.length;h++)this.path[h].updateScroll();const d=this.layout;this.layout=this.measure(!1),this.layoutCorrected=Nt(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:m}=this.options;m&&m.notify("LayoutMeasure",this.layout.layoutBox,d?d.layoutBox:void 0)}updateScroll(d="measure"){let m=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===d&&(m=!1),m){const h=o(this.instance);this.scroll={animationId:this.root.animationId,phase:d,isRoot:h,offset:i(this.instance),wasRoot:this.scroll?this.scroll.isRoot:h}}}resetTransform(){if(!c)return;const d=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,m=this.projectionDelta&&!mx(this.projectionDelta),h=this.getTransformTemplate(),g=h?h(this.latestValues,""):void 0,v=g!==this.prevTransformTemplateValue;d&&(m||Ga(this.latestValues)||v)&&(c(this.instance,g),this.shouldResetTransform=!1,this.scheduleRender())}measure(d=!0){const m=this.measurePageBox();let h=this.removeElementScroll(m);return d&&(h=this.removeTransform(h)),TE(h),{animationId:this.root.animationId,measuredBox:m,layoutBox:h,latestValues:{},source:this.id}}measurePageBox(){var d;const{visualElement:m}=this.options;if(!m)return Nt();const h=m.measureViewportBox();if(!(((d=this.scroll)===null||d===void 0?void 0:d.wasRoot)||this.path.some(kE))){const{scroll:v}=this.root;v&&(Zi(h.x,v.offset.x),Zi(h.y,v.offset.y))}return h}removeElementScroll(d){var m;const h=Nt();if(On(h,d),!((m=this.scroll)===null||m===void 0)&&m.wasRoot)return h;for(let g=0;g<this.path.length;g++){const v=this.path[g],{scroll:b,options:_}=v;v!==this.root&&b&&_.layoutScroll&&(b.wasRoot&&On(h,d),Zi(h.x,b.offset.x),Zi(h.y,b.offset.y))}return h}applyTransform(d,m=!1){const h=Nt();On(h,d);for(let g=0;g<this.path.length;g++){const v=this.path[g];!m&&v.options.layoutScroll&&v.scroll&&v!==v.root&&Ki(h,{x:-v.scroll.offset.x,y:-v.scroll.offset.y}),Ga(v.latestValues)&&Ki(h,v.latestValues)}return Ga(this.latestValues)&&Ki(h,this.latestValues),h}removeTransform(d){const m=Nt();On(m,d);for(let h=0;h<this.path.length;h++){const g=this.path[h];if(!g.instance||!Ga(g.latestValues))continue;np(g.latestValues)&&g.updateSnapshot();const v=Nt(),b=g.measurePageBox();On(v,b),by(m,g.latestValues,g.snapshot?g.snapshot.layoutBox:void 0,v)}return Ga(this.latestValues)&&by(m,this.latestValues),m}setTargetDelta(d){this.targetDelta=d,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(d){this.options={...this.options,...d,crossfade:d.crossfade!==void 0?d.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Ft.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(d=!1){var m;const h=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=h.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=h.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=h.isSharedProjectionDirty);const g=!!this.resumingFrom||this!==h;if(!(d||g&&this.isSharedProjectionDirty||this.isProjectionDirty||!((m=this.parent)===null||m===void 0)&&m.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:b,layoutId:_}=this.options;if(!(!this.layout||!(b||_))){if(this.resolvedRelativeTargetAt=Ft.timestamp,!this.targetDelta&&!this.relativeTarget){const S=this.getClosestProjectingParent();S&&S.layout&&this.animationProgress!==1?(this.relativeParent=S,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Nt(),this.relativeTargetOrigin=Nt(),yr(this.relativeTargetOrigin,this.layout.layoutBox,S.layout.layoutBox),On(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)){if(this.target||(this.target=Nt(),this.targetWithTransforms=Nt()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),jC(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):On(this.target,this.layout.layoutBox),lx(this.target,this.targetDelta)):On(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget){this.attemptToResolveRelativeTarget=!1;const S=this.getClosestProjectingParent();S&&!!S.resumingFrom==!!this.resumingFrom&&!S.options.layoutScroll&&S.target&&this.animationProgress!==1?(this.relativeParent=S,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Nt(),this.relativeTargetOrigin=Nt(),yr(this.relativeTargetOrigin,this.target,S.target),On(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}dr&&$a.resolvedTargetDeltas++}}}getClosestProjectingParent(){if(!(!this.parent||np(this.parent.latestValues)||rx(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){var d;const m=this.getLead(),h=!!this.resumingFrom||this!==m;let g=!0;if((this.isProjectionDirty||!((d=this.parent)===null||d===void 0)&&d.isProjectionDirty)&&(g=!1),h&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(g=!1),this.resolvedRelativeTargetAt===Ft.timestamp&&(g=!1),g)return;const{layout:v,layoutId:b}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(v||b))return;On(this.layoutCorrected,this.layout.layoutBox);const _=this.treeScale.x,S=this.treeScale.y;BC(this.layoutCorrected,this.treeScale,this.path,h),m.layout&&!m.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(m.target=m.layout.layoutBox,m.targetWithTransforms=Nt());const{target:T}=m;if(!T){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(gy(this.prevProjectionDelta.x,this.projectionDelta.x),gy(this.prevProjectionDelta.y,this.projectionDelta.y)),vr(this.projectionDelta,this.layoutCorrected,T,this.latestValues),(this.treeScale.x!==_||this.treeScale.y!==S||!ky(this.projectionDelta.x,this.prevProjectionDelta.x)||!ky(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",T)),dr&&$a.recalculatedProjection++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(d=!0){var m;if((m=this.options.visualElement)===null||m===void 0||m.scheduleRender(),d){const h=this.getStack();h&&h.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Fi(),this.projectionDelta=Fi(),this.projectionDeltaWithTransform=Fi()}setAnimationOrigin(d,m=!1){const h=this.snapshot,g=h?h.latestValues:{},v={...this.latestValues},b=Fi();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!m;const _=Nt(),S=h?h.source:void 0,T=this.layout?this.layout.source:void 0,N=S!==T,j=this.getStack(),w=!j||j.members.length<=1,E=!!(N&&!w&&this.options.crossfade===!0&&!this.path.some(xE));this.animationProgress=0;let A;this.mixTargetDelta=O=>{const C=O/1e3;Cy(b.x,d.x,C),Cy(b.y,d.y,C),this.setTargetDelta(b),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(yr(_,this.layout.layoutBox,this.relativeParent.layout.layoutBox),_E(this.relativeTarget,this.relativeTargetOrigin,_,C),A&&aE(this.relativeTarget,A)&&(this.isProjectionDirty=!1),A||(A=Nt()),On(A,this.relativeTarget)),N&&(this.animationValues=v,XC(v,g,this.latestValues,C,E,w)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=C},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(d){this.notifyListeners("animationStart"),this.currentAnimation&&this.currentAnimation.stop(),this.resumingFrom&&this.resumingFrom.currentAnimation&&this.resumingFrom.currentAnimation.stop(),this.pendingAnimation&&(ma(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=ft.update(()=>{hc.hasAnimatedSinceResize=!0,this.currentAnimation=FC(0,wy,{...d,onUpdate:m=>{this.mixTargetDelta(m),d.onUpdate&&d.onUpdate(m)},onComplete:()=>{d.onComplete&&d.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const d=this.getStack();d&&d.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(wy),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const d=this.getLead();let{targetWithTransforms:m,target:h,layout:g,latestValues:v}=d;if(!(!m||!h||!g)){if(this!==d&&this.layout&&g&&yx(this.options.animationType,this.layout.layoutBox,g.layoutBox)){h=this.target||Nt();const b=xn(this.layout.layoutBox.x);h.x.min=d.target.x.min,h.x.max=h.x.min+b;const _=xn(this.layout.layoutBox.y);h.y.min=d.target.y.min,h.y.max=h.y.min+_}On(m,h),Ki(m,v),vr(this.projectionDeltaWithTransform,this.layoutCorrected,m,v)}}registerSharedNode(d,m){this.sharedNodes.has(d)||this.sharedNodes.set(d,new iE),this.sharedNodes.get(d).add(m);const g=m.options.initialPromotionConfig;m.promote({transition:g?g.transition:void 0,preserveFollowOpacity:g&&g.shouldPreserveFollowOpacity?g.shouldPreserveFollowOpacity(m):void 0})}isLead(){const d=this.getStack();return d?d.lead===this:!0}getLead(){var d;const{layoutId:m}=this.options;return m?((d=this.getStack())===null||d===void 0?void 0:d.lead)||this:this}getPrevLead(){var d;const{layoutId:m}=this.options;return m?(d=this.getStack())===null||d===void 0?void 0:d.prevLead:void 0}getStack(){const{layoutId:d}=this.options;if(d)return this.root.sharedNodes.get(d)}promote({needsReset:d,transition:m,preserveFollowOpacity:h}={}){const g=this.getStack();g&&g.promote(this,h),d&&(this.projectionDelta=void 0,this.needsReset=!0),m&&this.setOptions({transition:m})}relegate(){const d=this.getStack();return d?d.relegate(this):!1}resetSkewAndRotation(){const{visualElement:d}=this.options;if(!d)return;let m=!1;const{latestValues:h}=d;if((h.z||h.rotate||h.rotateX||h.rotateY||h.rotateZ||h.skewX||h.skewY)&&(m=!0),!m)return;const g={};h.z&&_f("z",d,g,this.animationValues);for(let v=0;v<bf.length;v++)_f(`rotate${bf[v]}`,d,g,this.animationValues),_f(`skew${bf[v]}`,d,g,this.animationValues);d.render();for(const v in g)d.setStaticValue(v,g[v]),this.animationValues&&(this.animationValues[v]=g[v]);d.scheduleRender()}getProjectionStyles(d){var m,h;if(!this.instance||this.isSVG)return;if(!this.isVisible)return rE;const g={visibility:""},v=this.getTransformTemplate();if(this.needsReset)return this.needsReset=!1,g.opacity="",g.pointerEvents=pc(d==null?void 0:d.pointerEvents)||"",g.transform=v?v(this.latestValues,""):"none",g;const b=this.getLead();if(!this.projectionDelta||!this.layout||!b.target){const N={};return this.options.layoutId&&(N.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,N.pointerEvents=pc(d==null?void 0:d.pointerEvents)||""),this.hasProjected&&!Ga(this.latestValues)&&(N.transform=v?v({},""):"none",this.hasProjected=!1),N}const _=b.animationValues||b.latestValues;this.applyTransformsToTarget(),g.transform=oE(this.projectionDeltaWithTransform,this.treeScale,_),v&&(g.transform=v(_,g.transform));const{x:S,y:T}=this.projectionDelta;g.transformOrigin=`${S.origin*100}% ${T.origin*100}% 0`,b.animationValues?g.opacity=b===this?(h=(m=_.opacity)!==null&&m!==void 0?m:this.latestValues.opacity)!==null&&h!==void 0?h:1:this.preserveOpacity?this.latestValues.opacity:_.opacityExit:g.opacity=b===this?_.opacity!==void 0?_.opacity:"":_.opacityExit!==void 0?_.opacityExit:0;for(const N in _c){if(_[N]===void 0)continue;const{correct:j,applyTo:w}=_c[N],E=g.transform==="none"?_[N]:j(_[N],b);if(w){const A=w.length;for(let O=0;O<A;O++)g[w[O]]=E}else g[N]=E}return this.options.layoutId&&(g.pointerEvents=b===this?pc(d==null?void 0:d.pointerEvents)||"":"none"),g}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(d=>{var m;return(m=d.currentAnimation)===null||m===void 0?void 0:m.stop()}),this.root.nodes.forEach(Ny),this.root.sharedNodes.clear()}}}function cE(n){n.updateLayout()}function uE(n){var s;const i=((s=n.resumeFrom)===null||s===void 0?void 0:s.snapshot)||n.snapshot;if(n.isLead()&&n.layout&&i&&n.hasListeners("didUpdate")){const{layoutBox:o,measuredBox:c}=n.layout,{animationType:u}=n.options,d=i.source!==n.layout.source;u==="size"?Bn(b=>{const _=d?i.measuredBox[b]:i.layoutBox[b],S=xn(_);_.min=o[b].min,_.max=_.min+S}):yx(u,i.layoutBox,o)&&Bn(b=>{const _=d?i.measuredBox[b]:i.layoutBox[b],S=xn(o[b]);_.max=_.min+S,n.relativeTarget&&!n.currentAnimation&&(n.isProjectionDirty=!0,n.relativeTarget[b].max=n.relativeTarget[b].min+S)});const m=Fi();vr(m,o,i.layoutBox);const h=Fi();d?vr(h,n.applyTransform(c,!0),i.measuredBox):vr(h,o,i.layoutBox);const g=!mx(m);let v=!1;if(!n.resumeFrom){const b=n.getClosestProjectingParent();if(b&&!b.resumeFrom){const{snapshot:_,layout:S}=b;if(_&&S){const T=Nt();yr(T,i.layoutBox,_.layoutBox);const N=Nt();yr(N,o,S.layoutBox),hx(T,N)||(v=!0),b.options.layoutRoot&&(n.relativeTarget=N,n.relativeTargetOrigin=T,n.relativeParent=b)}}}n.notifyListeners("didUpdate",{layout:o,snapshot:i,delta:h,layoutDelta:m,hasLayoutChanged:g,hasRelativeTargetChanged:v})}else if(n.isLead()){const{onExitComplete:o}=n.options;o&&o()}n.options.transition=void 0}function dE(n){dr&&$a.totalNodes++,n.parent&&(n.isProjecting()||(n.isProjectionDirty=n.parent.isProjectionDirty),n.isSharedProjectionDirty||(n.isSharedProjectionDirty=!!(n.isProjectionDirty||n.parent.isProjectionDirty||n.parent.isSharedProjectionDirty)),n.isTransformDirty||(n.isTransformDirty=n.parent.isTransformDirty))}function fE(n){n.isProjectionDirty=n.isSharedProjectionDirty=n.isTransformDirty=!1}function pE(n){n.clearSnapshot()}function Ny(n){n.clearMeasurements()}function mE(n){n.isLayoutDirty=!1}function hE(n){const{visualElement:s}=n.options;s&&s.getProps().onBeforeLayoutMeasure&&s.notify("BeforeLayoutMeasure"),n.resetTransform()}function jy(n){n.finishAnimation(),n.targetDelta=n.relativeTarget=n.target=void 0,n.isProjectionDirty=!0}function gE(n){n.resolveTargetDelta()}function vE(n){n.calcProjection()}function yE(n){n.resetSkewAndRotation()}function bE(n){n.removeLeadSnapshot()}function Cy(n,s,i){n.translate=vt(s.translate,0,i),n.scale=vt(s.scale,1,i),n.origin=s.origin,n.originPoint=s.originPoint}function Ey(n,s,i,o){n.min=vt(s.min,i.min,o),n.max=vt(s.max,i.max,o)}function _E(n,s,i,o){Ey(n.x,s.x,i.x,o),Ey(n.y,s.y,i.y,o)}function xE(n){return n.animationValues&&n.animationValues.opacityExit!==void 0}const SE={duration:.45,ease:[.4,0,.1,1]},Ay=n=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(n),Dy=Ay("applewebkit/")&&!Ay("chrome/")?Math.round:_n;function Ry(n){n.min=Dy(n.min),n.max=Dy(n.max)}function TE(n){Ry(n.x),Ry(n.y)}function yx(n,s,i){return n==="position"||n==="preserve-aspect"&&!NC(Ty(s),Ty(i),.2)}function kE(n){var s;return n!==n.root&&((s=n.scroll)===null||s===void 0?void 0:s.wasRoot)}const wE=vx({attachResizeListener:(n,s)=>Nr(n,"resize",s),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),xf={current:void 0},bx=vx({measureScroll:n=>({x:n.scrollLeft,y:n.scrollTop}),defaultParent:()=>{if(!xf.current){const n=new wE({});n.mount(window),n.setOptions({layoutScroll:!0}),xf.current=n}return xf.current},resetTransform:(n,s)=>{n.style.transform=s!==void 0?s:"none"},checkIsScrollRoot:n=>window.getComputedStyle(n).position==="fixed"}),NE={pan:{Feature:qC},drag:{Feature:VC,ProjectionNode:bx,MeasureLayout:dx}};function jE(n,s,i){var o;if(n instanceof Element)return[n];if(typeof n=="string"){let c=document;const u=(o=void 0)!==null&&o!==void 0?o:c.querySelectorAll(n);return u?Array.from(u):[]}return Array.from(n)}function _x(n,s){const i=jE(n),o=new AbortController,c={passive:!0,...s,signal:o.signal};return[i,c,()=>o.abort()]}function My(n){return s=>{s.pointerType==="touch"||tx()||n(s)}}function CE(n,s,i={}){const[o,c,u]=_x(n,i),d=My(m=>{const{target:h}=m,g=s(m);if(typeof g!="function"||!h)return;const v=My(b=>{g(b),h.removeEventListener("pointerleave",v)});h.addEventListener("pointerleave",v,c)});return o.forEach(m=>{m.addEventListener("pointerenter",d,c)}),u}function Oy(n,s,i){const{props:o}=n;n.animationState&&o.whileHover&&n.animationState.setActive("whileHover",i==="Start");const c="onHover"+i,u=o[c];u&&ft.postRender(()=>u(s,Mr(s)))}class EE extends ya{mount(){const{current:s}=this.node;s&&(this.unmount=CE(s,i=>(Oy(this.node,i,"Start"),o=>Oy(this.node,o,"End"))))}unmount(){}}class AE extends ya{constructor(){super(...arguments),this.isActive=!1}onFocus(){let s=!1;try{s=this.node.current.matches(":focus-visible")}catch{s=!0}!s||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Rr(Nr(this.node.current,"focus",()=>this.onFocus()),Nr(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}const xx=(n,s)=>s?n===s?!0:xx(n,s.parentElement):!1,DE=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function RE(n){return DE.has(n.tagName)||n.tabIndex!==-1}const fr=new WeakSet;function Iy(n){return s=>{s.key==="Enter"&&n(s)}}function Sf(n,s){n.dispatchEvent(new PointerEvent("pointer"+s,{isPrimary:!0,bubbles:!0}))}const ME=(n,s)=>{const i=n.currentTarget;if(!i)return;const o=Iy(()=>{if(fr.has(i))return;Sf(i,"down");const c=Iy(()=>{Sf(i,"up")}),u=()=>Sf(i,"cancel");i.addEventListener("keyup",c,s),i.addEventListener("blur",u,s)});i.addEventListener("keydown",o,s),i.addEventListener("blur",()=>i.removeEventListener("keydown",o),s)};function By(n){return em(n)&&!tx()}function OE(n,s,i={}){const[o,c,u]=_x(n,i),d=m=>{const h=m.currentTarget;if(!By(m)||fr.has(h))return;fr.add(h);const g=s(m),v=(S,T)=>{window.removeEventListener("pointerup",b),window.removeEventListener("pointercancel",_),!(!By(S)||!fr.has(h))&&(fr.delete(h),typeof g=="function"&&g(S,{success:T}))},b=S=>{v(S,i.useGlobalTarget||xx(h,S.target))},_=S=>{v(S,!1)};window.addEventListener("pointerup",b,c),window.addEventListener("pointercancel",_,c)};return o.forEach(m=>{!RE(m)&&m.getAttribute("tabindex")===null&&(m.tabIndex=0),(i.useGlobalTarget?window:m).addEventListener("pointerdown",d,c),m.addEventListener("focus",g=>ME(g,c),c)}),u}function Ly(n,s,i){const{props:o}=n;n.animationState&&o.whileTap&&n.animationState.setActive("whileTap",i==="Start");const c="onTap"+(i==="End"?"":i),u=o[c];u&&ft.postRender(()=>u(s,Mr(s)))}class IE extends ya{mount(){const{current:s}=this.node;s&&(this.unmount=OE(s,i=>(Ly(this.node,i,"Start"),(o,{success:c})=>Ly(this.node,o,c?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const ap=new WeakMap,Tf=new WeakMap,BE=n=>{const s=ap.get(n.target);s&&s(n)},LE=n=>{n.forEach(BE)};function UE({root:n,...s}){const i=n||document;Tf.has(i)||Tf.set(i,{});const o=Tf.get(i),c=JSON.stringify(s);return o[c]||(o[c]=new IntersectionObserver(LE,{root:n,...s})),o[c]}function zE(n,s,i){const o=UE(s);return ap.set(n,i),o.observe(n),()=>{ap.delete(n),o.unobserve(n)}}const PE={some:0,all:1};class VE extends ya{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:s={}}=this.node.getProps(),{root:i,margin:o,amount:c="some",once:u}=s,d={root:i?i.current:void 0,rootMargin:o,threshold:typeof c=="number"?c:PE[c]},m=h=>{const{isIntersecting:g}=h;if(this.isInView===g||(this.isInView=g,u&&!g&&this.hasEnteredView))return;g&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",g);const{onViewportEnter:v,onViewportLeave:b}=this.node.getProps(),_=g?v:b;_&&_(h)};return zE(this.node.current,d,m)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:s,prevProps:i}=this.node;["amount","margin","root"].some(qE(s,i))&&this.startObserver()}unmount(){}}function qE({viewport:n={}},{viewport:s={}}={}){return i=>n[i]!==s[i]}const HE={inView:{Feature:VE},tap:{Feature:IE},focus:{Feature:AE},hover:{Feature:EE}},GE={layout:{ProjectionNode:bx,MeasureLayout:dx}},Nc={current:null},tm={current:!1};function Sx(){if(tm.current=!0,!!kp)if(window.matchMedia){const n=window.matchMedia("(prefers-reduced-motion)"),s=()=>Nc.current=n.matches;n.addListener(s),s()}else Nc.current=!1}const $E=[...H_,Wt,ha],FE=n=>$E.find(q_(n)),Uy=new WeakMap;function ZE(n,s,i){for(const o in s){const c=s[o],u=i[o];if(Xt(c))n.addValue(o,c);else if(Xt(u))n.addValue(o,kr(c,{owner:n}));else if(u!==c)if(n.hasValue(o)){const d=n.getValue(o);d.liveStyle===!0?d.jump(c):d.hasAnimated||d.set(c)}else{const d=n.getStaticValue(o);n.addValue(o,kr(d!==void 0?d:c,{owner:n}))}}for(const o in i)s[o]===void 0&&n.removeValue(o);return s}const zy=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class KE{scrapeMotionValuesFromProps(s,i,o){return{}}constructor({parent:s,props:i,presenceContext:o,reducedMotionConfig:c,blockInitialAnimation:u,visualState:d},m={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=Jp,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const S=is.now();this.renderScheduledAt<S&&(this.renderScheduledAt=S,ft.render(this.render,!1,!0))};const{latestValues:h,renderState:g,onUpdate:v}=d;this.onUpdate=v,this.latestValues=h,this.baseTarget={...h},this.initialValues=i.initial?{...h}:{},this.renderState=g,this.parent=s,this.props=i,this.presenceContext=o,this.depth=s?s.depth+1:0,this.reducedMotionConfig=c,this.options=m,this.blockInitialAnimation=!!u,this.isControllingVariants=zc(i),this.isVariantNode=t_(i),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(s&&s.current);const{willChange:b,..._}=this.scrapeMotionValuesFromProps(i,{},this);for(const S in _){const T=_[S];h[S]!==void 0&&Xt(T)&&T.set(h[S],!1)}}mount(s){this.current=s,Uy.set(s,this),this.projection&&!this.projection.instance&&this.projection.mount(s),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((i,o)=>this.bindToMotionValue(o,i)),tm.current||Sx(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:Nc.current,this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){Uy.delete(this.current),this.projection&&this.projection.unmount(),ma(this.notifyUpdate),ma(this.render),this.valueSubscriptions.forEach(s=>s()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(const s in this.events)this.events[s].clear();for(const s in this.features){const i=this.features[s];i&&(i.unmount(),i.isMounted=!1)}this.current=null}bindToMotionValue(s,i){this.valueSubscriptions.has(s)&&this.valueSubscriptions.get(s)();const o=ti.has(s),c=i.on("change",m=>{this.latestValues[s]=m,this.props.onUpdate&&ft.preRender(this.notifyUpdate),o&&this.projection&&(this.projection.isTransformDirty=!0)}),u=i.on("renderRequest",this.scheduleRender);let d;window.MotionCheckAppearSync&&(d=window.MotionCheckAppearSync(this,s,i)),this.valueSubscriptions.set(s,()=>{c(),u(),d&&d(),i.owner&&i.stop()})}sortNodePosition(s){return!this.current||!this.sortInstanceNodePosition||this.type!==s.type?0:this.sortInstanceNodePosition(this.current,s.current)}updateFeatures(){let s="animation";for(s in eo){const i=eo[s];if(!i)continue;const{isEnabled:o,Feature:c}=i;if(!this.features[s]&&c&&o(this.props)&&(this.features[s]=new c(this)),this.features[s]){const u=this.features[s];u.isMounted?u.update():(u.mount(),u.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Nt()}getStaticValue(s){return this.latestValues[s]}setStaticValue(s,i){this.latestValues[s]=i}update(s,i){(s.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=s,this.prevPresenceContext=this.presenceContext,this.presenceContext=i;for(let o=0;o<zy.length;o++){const c=zy[o];this.propEventSubscriptions[c]&&(this.propEventSubscriptions[c](),delete this.propEventSubscriptions[c]);const u="on"+c,d=s[u];d&&(this.propEventSubscriptions[c]=this.on(c,d))}this.prevMotionValues=ZE(this,this.scrapeMotionValuesFromProps(s,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue(),this.onUpdate&&this.onUpdate(this)}getProps(){return this.props}getVariant(s){return this.props.variants?this.props.variants[s]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(s){const i=this.getClosestVariantNode();if(i)return i.variantChildren&&i.variantChildren.add(s),()=>i.variantChildren.delete(s)}addValue(s,i){const o=this.values.get(s);i!==o&&(o&&this.removeValue(s),this.bindToMotionValue(s,i),this.values.set(s,i),this.latestValues[s]=i.get())}removeValue(s){this.values.delete(s);const i=this.valueSubscriptions.get(s);i&&(i(),this.valueSubscriptions.delete(s)),delete this.latestValues[s],this.removeValueFromRenderState(s,this.renderState)}hasValue(s){return this.values.has(s)}getValue(s,i){if(this.props.values&&this.props.values[s])return this.props.values[s];let o=this.values.get(s);return o===void 0&&i!==void 0&&(o=kr(i===null?void 0:i,{owner:this}),this.addValue(s,o)),o}readValue(s,i){var o;let c=this.latestValues[s]!==void 0||!this.current?this.latestValues[s]:(o=this.getBaseTargetFromProps(this.props,s))!==null&&o!==void 0?o:this.readValueFromInstance(this.current,s,this.options);return c!=null&&(typeof c=="string"&&(P_(c)||D_(c))?c=parseFloat(c):!FE(c)&&ha.test(i)&&(c=L_(s,i)),this.setBaseTarget(s,Xt(c)?c.get():c)),Xt(c)?c.get():c}setBaseTarget(s,i){this.baseTarget[s]=i}getBaseTarget(s){var i;const{initial:o}=this.props;let c;if(typeof o=="string"||typeof o=="object"){const d=Ap(this.props,o,(i=this.presenceContext)===null||i===void 0?void 0:i.custom);d&&(c=d[s])}if(o&&c!==void 0)return c;const u=this.getBaseTargetFromProps(this.props,s);return u!==void 0&&!Xt(u)?u:this.initialValues[s]!==void 0&&c===void 0?void 0:this.baseTarget[s]}on(s,i){return this.events[s]||(this.events[s]=new Vp),this.events[s].add(i)}notify(s,...i){this.events[s]&&this.events[s].notify(...i)}}class Tx extends KE{constructor(){super(...arguments),this.KeyframeResolver=G_}sortInstanceNodePosition(s,i){return s.compareDocumentPosition(i)&2?1:-1}getBaseTargetFromProps(s,i){return s.style?s.style[i]:void 0}removeValueFromRenderState(s,{vars:i,style:o}){delete i[s],delete o[s]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:s}=this.props;Xt(s)&&(this.childSubscription=s.on("change",i=>{this.current&&(this.current.textContent=`${i}`)}))}}function YE(n){return window.getComputedStyle(n)}class JE extends Tx{constructor(){super(...arguments),this.type="html",this.renderInstance=u_}readValueFromInstance(s,i){if(ti.has(i)){const o=Yp(i);return o&&o.default||0}else{const o=YE(s),c=(r_(i)?o.getPropertyValue(i):o[i])||0;return typeof c=="string"?c.trim():c}}measureInstanceViewportBox(s,{transformPagePoint:i}){return cx(s,i)}build(s,i,o){Mp(s,i,o.transformTemplate)}scrapeMotionValuesFromProps(s,i,o){return Lp(s,i,o)}}class WE extends Tx{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Nt}getBaseTargetFromProps(s,i){return s[i]}readValueFromInstance(s,i){if(ti.has(i)){const o=Yp(i);return o&&o.default||0}return i=d_.has(i)?i:jp(i),s.getAttribute(i)}scrapeMotionValuesFromProps(s,i,o){return m_(s,i,o)}build(s,i,o){Op(s,i,this.isSVGTag,o.transformTemplate)}renderInstance(s,i,o,c){f_(s,i,o,c)}mount(s){this.isSVGTag=Bp(s.tagName),super.mount(s)}}const XE=(n,s)=>Ep(n)?new WE(s):new JE(s,{allowProjection:n!==y.Fragment}),QE=wN({...gC,...HE,...NE,...GE},XE),Rt=P2(QE);function eA(){!tm.current&&Sx();const[n]=y.useState(Nc.current);return n}const ip={not_started:{color:"var(--text-tertiary)",icon:"○",label:"Not Started"},working:{color:"var(--accent-green)",icon:"●",label:"Working"},paused:{color:"var(--accent-yellow)",icon:"◉",label:"Paused"},complete:{color:"var(--accent-green)",icon:"✓",label:"Complete"},failed:{color:"var(--accent-red)",icon:"✗",label:"Failed"},blocked:{color:"var(--accent-yellow)",icon:"⦸",label:"Blocked"}};function ga(n){return n==="blocked"?ip.blocked:ip[nm(n)]}const tA={not_started:"statusPending",working:"statusInProgress",paused:"statusWaitingInput",complete:"statusDone",failed:"statusFailed"};function nA(n){return tA[nm(n)]??"statusPending"}const sA=["working","paused","failed","not_started","blocked","complete"],Py=["not_started","working","paused","complete","failed"],aA={pending:"not_started",assigned:"not_started",in_progress:"working",waiting_input:"paused",review:"paused",done:"complete"};function nm(n){return n in ip&&n!=="blocked"?n:aA[n]??"not_started"}const iA={not_started:"--text-tertiary",working:"--accent-green",paused:"--accent-yellow",complete:"--accent-green",failed:"--accent-red",pending:"--text-tertiary",assigned:"--text-tertiary",in_progress:"--accent-green",review:"--accent-yellow",done:"--accent-green",waiting_input:"--accent-yellow"};function oA(n){if(n.length===0)return[];const s=[...n].sort((o,c)=>o[0]-c[0]),i=[[s[0][0],s[0][1]]];for(let o=1;o<s.length;o++){const c=i[i.length-1],[u,d]=s[o];u<=c[1]+1?c[1]=Math.max(c[1],d):i.push([u,d])}return i}function kx({text:n,indices:s,highlightClass:i}){if(!s||s.length===0)return l.jsx(l.Fragment,{children:n});const o=oA(s),c=[];let u=0;for(const[d,m]of o)d>u&&c.push(l.jsx("span",{children:n.slice(u,d)},`p${u}`)),c.push(l.jsx("mark",{className:i,children:n.slice(d,m+1)},`m${d}`)),u=m+1;return u<n.length&&c.push(l.jsx("span",{children:n.slice(u)},`p${u}`)),l.jsx(l.Fragment,{children:c})}function rA(n){const s=new Map(n.map(o=>[o.id,{...o,children:[]}])),i=[];for(const o of s.values())o.parentTaskId&&s.has(o.parentTaskId)?s.get(o.parentTaskId).children.push(o):i.push(o);for(const o of s.values())o.children.sort((c,u)=>c.sortOrder-u.sortOrder);return i.sort((o,c)=>o.sortOrder-c.sortOrder)}function lA(n,s){const i=new Map;for(const u of n){const m=u.dependsOn.length>0&&u.dependsOn.some(g=>s.get(g)!=="complete")?"blocked":u.status,h=i.get(m);h?h.push(u):i.set(m,[u])}const o=[],c=new Set;for(const u of sA){c.add(u);const d=i.get(u);if(d&&d.length>0){d.sort((h,g)=>h.sortOrder-g.sortOrder);const m=ga(u);o.push({status:u,label:m.label,style:m,tasks:d})}}for(const[u,d]of i)if(!c.has(u)&&d.length>0){d.sort((h,g)=>h.sortOrder-g.sortOrder);const m=ga(u);o.push({status:u,label:m.label,style:m,tasks:d})}return o}const cA="_container_z4i38_1",uA="_header_z4i38_5",dA="_headerActions_z4i38_17",fA="_searchInput_z4i38_23",pA="_searchHighlight_z4i38_56",mA="_groupToggle_z4i38_62",hA="_groupToggleActive_z4i38_89",gA="_addButton_z4i38_93",vA="_taskRow_z4i38_120",yA="_selected_z4i38_140",bA="_expandArrow_z4i38_150",_A="_expanded_z4i38_157",xA="_leafSpacer_z4i38_161",SA="_taskStatusIcon_z4i38_166",TA="_taskTitle_z4i38_170",kA="_workspaceBadge_z4i38_177",wA="_childCountBadge_z4i38_195",NA="_dependencyBadge_z4i38_208",jA="_blockedBadge_z4i38_220",CA="_addChildButton_z4i38_225",EA="_emptyState_z4i38_268",AA="_statusGroupHeader_z4i38_275",DA="_statusGroupIcon_z4i38_294",RA="_statusGroupLabel_z4i38_298",MA="_statusGroupCount_z4i38_303",Fe={container:cA,header:uA,headerActions:dA,searchInput:fA,searchHighlight:pA,groupToggle:mA,groupToggleActive:hA,addButton:gA,taskRow:vA,selected:yA,expandArrow:bA,expanded:_A,leafSpacer:xA,taskStatusIcon:SA,taskTitle:TA,workspaceBadge:kA,childCountBadge:wA,dependencyBadge:NA,blockedBadge:jA,addChildButton:CA,emptyState:EA,statusGroupHeader:AA,statusGroupIcon:DA,statusGroupLabel:RA,statusGroupCount:MA},OA=[{name:"title",weight:2},{name:"description",weight:1}],wx=16,IA=16,Nx="grackle-task-group-by-status";function Vy(){try{return localStorage.getItem(Nx)==="true"}catch{return!1}}function BA(n){try{localStorage.setItem(Nx,String(n))}catch{}}function LA({group:n,isExpanded:s,onToggle:i,selectedTaskId:o,navigate:c,titleHighlights:u,workspaceNames:d}){return l.jsxs("div",{"data-testid":`status-group-${n.status}`,children:[l.jsxs("div",{className:Fe.statusGroupHeader,role:"button",tabIndex:0,"aria-expanded":s,onClick:i,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),i())},children:[l.jsx("span",{className:`${Fe.expandArrow} ${s?Fe.expanded:""}`,children:"▸"}),l.jsx("span",{className:Fe.statusGroupIcon,style:{color:n.style.color},children:n.style.icon}),l.jsx("span",{className:Fe.statusGroupLabel,children:n.label}),l.jsx("span",{className:Fe.statusGroupCount,children:n.tasks.length})]}),l.jsx(rs,{children:s&&l.jsx(Rt.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},style:{overflow:"hidden"},children:n.tasks.map(m=>{const h=ga(m.status),g=o===m.id,v=m.parentTaskId||!m.workspaceId?void 0:d.get(m.workspaceId);return l.jsxs("div",{onClick:()=>c(os(m.id)),className:`${Fe.taskRow} ${g?Fe.selected:""}`,style:{"--task-indent":`${wx}px`},"data-task-id":m.id,children:[l.jsx("span",{className:Fe.leafSpacer}),l.jsx("span",{className:Fe.taskStatusIcon,style:{color:h.color},children:h.icon}),l.jsx("span",{className:Fe.taskTitle,title:m.title,children:l.jsx(kx,{text:m.title,indices:u.get(m.id),highlightClass:Fe.searchHighlight})}),v&&l.jsx("span",{className:Fe.workspaceBadge,title:v,children:v})]},m.id)})})})]})}function jx({node:n,depth:s,expandedTasks:i,toggleTask:o,selectedTaskId:c,navigate:u,taskStatusById:d,titleHighlights:m,workspaceNames:h}){const g=ga(n.status),v=n.dependsOn.length>0&&n.dependsOn.some(w=>d.get(w)!=="complete"),b=i.has(n.id),_=n.children.length>0,S=c===n.id,T=wx+s*IA,j=s===0&&!n.parentTaskId&&n.workspaceId?h.get(n.workspaceId):void 0;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{onClick:()=>u(os(n.id)),className:`${Fe.taskRow} ${S?Fe.selected:""}`,style:{"--task-indent":`${T}px`},"data-task-id":n.id,children:[_&&l.jsx("span",{className:`${Fe.expandArrow} ${b?Fe.expanded:""}`,role:"button",tabIndex:0,"aria-label":b?"Collapse task":"Expand task",onClick:w=>{w.stopPropagation(),o(n.id)},onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),w.stopPropagation(),o(n.id))},children:"▸"}),!_&&l.jsx("span",{className:Fe.leafSpacer}),l.jsx("span",{className:Fe.taskStatusIcon,style:{color:g.color},children:g.icon}),l.jsx("span",{className:Fe.taskTitle,title:n.title,children:l.jsx(kx,{text:n.title,indices:m.get(n.id),highlightClass:Fe.searchHighlight})}),j&&l.jsx("span",{className:Fe.workspaceBadge,title:j,children:j}),_&&l.jsxs("span",{className:Fe.childCountBadge,children:[n.children.filter(w=>w.status==="complete").length,"/",n.children.length]}),n.dependsOn.length>0&&l.jsx("span",{className:`${Fe.dependencyBadge} ${v?Fe.blockedBadge:""}`,title:`Depends on: ${n.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<hT&&l.jsx("button",{onClick:w=>{w.stopPropagation(),u(ei(n.workspaceId,n.id))},title:"Add child task","aria-label":"Add child task",className:Fe.addChildButton,children:"+"})]}),l.jsx(rs,{children:_&&b&&l.jsx(Rt.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},style:{overflow:"hidden"},children:n.children.map(w=>l.jsx(jx,{node:w,depth:s+1,expandedTasks:i,toggleTask:o,selectedTaskId:c,navigate:u,taskStatusById:d,titleHighlights:m,workspaceNames:h},w.id))})})]})}function UA({workspaces:n,tasks:s}){const i=St(),[o,c]=y.useState(new Set),[u,d]=y.useState(new Set),[m,h]=y.useState(Vy),[g,v]=y.useState(Vy),[b,_]=y.useState(new Map),S=Dt("/tasks/:taskId/*"),T=(S==null?void 0:S.params.taskId)!=="new"?S==null?void 0:S.params.taskId:void 0,N=y.useMemo(()=>new Map(s.map(K=>[K.id,K.status])),[s]),j=y.useMemo(()=>new Map(n.map(K=>[K.id,K.name])),[n]),w=()=>{const K=!m;BA(K),h(K),K&&(v(!0),_(new Map))},E=K=>{_(re=>{const I=new Map(re),$=I.has(K)?I.get(K):g;return I.set(K,!$),I})},A=K=>b.has(K)?b.get(K):g,O=K=>{c(re=>{const I=new Set(re);return I.has(K)?(I.delete(K),d($=>new Set($).add(K))):(I.add(K),d($=>{const Q=new Set($);return Q.delete(K),Q})),I})};y.useEffect(()=>{const K=new Set(s.filter(re=>re.parentTaskId).map(re=>re.parentTaskId));K.size>0&&c(re=>{const I=new Set(re);for(const $ of K)u.has($)||I.add($);return I})},[s,u]);const[C,M]=y.useState(""),{directMatchTaskIds:G,treeMatchTaskIds:U,titleHighlights:V}=y.useMemo(()=>{if(!C.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const K=mT(s,C,OA),re=new Set(K.map(de=>de.item.id)),I=new Map;for(const de of K){const me=de.matches.find(ze=>ze.key==="title");me&&I.set(de.item.id,me.indices)}const $=new Set(re),Q=new Map(s.map(de=>[de.id,de]));for(const de of[...re]){let me=Q.get(de);for(;me!=null&&me.parentTaskId;)$.add(me.parentTaskId),me=Q.get(me.parentTaskId)}return{directMatchTaskIds:re,treeMatchTaskIds:$,titleHighlights:I}},[C,s]),Z=G!==null,ee=Z?m?G:U:null,ie=ee?s.filter(K=>ee.has(K.id)):s,be=m?[]:rA(ie);return l.jsxs("div",{className:Fe.container,children:[l.jsxs("div",{className:Fe.header,children:[l.jsx("span",{children:"Tasks"}),l.jsxs("div",{className:Fe.headerActions,children:[l.jsx("button",{className:`${Fe.groupToggle} ${m?Fe.groupToggleActive:""}`,onClick:w,"aria-label":m?"Switch to tree view":"Group tasks by status","aria-pressed":m,title:m?"Switch to tree view":"Group tasks by status","data-testid":"task-group-by-status-toggle",children:"≡"}),l.jsx("button",{className:Fe.addButton,onClick:()=>i(ei()),"aria-label":"New task",title:"New task","data-testid":"new-task-button",children:"+"})]})]}),s.length>0&&l.jsx("input",{type:"text",value:C,onChange:K=>M(K.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:Fe.searchInput,"data-testid":"sidebar-search"}),m?lA(ie,N).map(K=>l.jsx(LA,{group:K,isExpanded:A(K.status),onToggle:()=>E(K.status),selectedTaskId:T,navigate:i,titleHighlights:V,workspaceNames:j},K.status)):be.map(K=>l.jsx(jx,{node:K,depth:0,expandedTasks:o,toggleTask:O,selectedTaskId:T,navigate:i,taskStatusById:N,titleHighlights:V,workspaceNames:j},K.id)),ie.length===0&&!Z&&l.jsx("div",{className:Fe.emptyState,children:"No tasks yet. Click + to create one."}),ie.length===0&&Z&&l.jsx("div",{className:Fe.emptyState,children:"No matching tasks"})]})}const zA="_nav_14i94_1",PA="_tab_14i94_24",VA="_tabActive_14i94_62",qA="_tabLabel_14i94_75",HA="_statusDot_14i94_81",GA="_pulse_14i94_87",$A="_addButton_14i94_99",FA="_empty_14i94_132",ua={nav:zA,tab:PA,tabActive:VA,tabLabel:qA,statusDot:HA,pulse:GA,addButton:$A,empty:FA},ZA={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function KA({environments:n}){const s=St(),i=y.useRef(null),o=Dt("/environments/:environmentId"),c=Dt("/environments/:environmentId/edit"),u=Dt("/environments/:environmentId/workspaces/:workspaceId"),d=Dt("/environments/:environmentId/workspaces/:workspaceId/*"),m=(o==null?void 0:o.params.environmentId)??(c==null?void 0:c.params.environmentId)??(u==null?void 0:u.params.environmentId)??(d==null?void 0:d.params.environmentId),h=m==="new"?void 0:m,g=y.useCallback(_=>{s(Qi(_))},[s]),v=y.useCallback(_=>{var w;const S=(w=i.current)==null?void 0:w.querySelectorAll('[role="tab"]');if(!S||S.length===0)return;const T=Array.from(S).findIndex(E=>E===document.activeElement),N=T>=0?T:n.findIndex(E=>E.id===h);let j=N;if(_.key==="ArrowDown"||_.key==="j"||_.key==="J")_.preventDefault(),j=(N+1)%S.length;else if(_.key==="ArrowUp"||_.key==="k"||_.key==="K")_.preventDefault(),j=(N-1+S.length)%S.length;else if(_.key==="Home")_.preventDefault(),j=0;else if(_.key==="End")_.preventDefault(),j=S.length-1;else return;j<n.length&&s(Qi(n[j].id)),S[j].focus()},[h,n,s]),b=h??(n.length>0?n[0].id:void 0);return l.jsxs("div",{className:ua.nav,"data-testid":"environment-nav",children:[l.jsx("nav",{ref:i,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:n.map(_=>{const S=_.id===h,T=_.id===b,N=ZA[_.status]||"var(--text-tertiary)",j=_.status==="connected";return l.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:T?0:-1,className:`${ua.tab} ${S?ua.tabActive:""}`,onClick:()=>g(_.id),"data-testid":"env-nav-item",children:[l.jsx("span",{className:`${ua.statusDot} ${j?ua.pulse:""}`,style:{color:N},children:"●"}),l.jsx("span",{className:ua.tabLabel,title:_.displayName||_.id,children:_.displayName||_.id})]},_.id)})}),l.jsx("button",{type:"button",className:ua.addButton,onClick:()=>s(rw),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),n.length===0&&l.jsx("div",{className:ua.empty,children:"No environments yet."})]})}const YA="_nav_1bhou_1",JA="_tab_1bhou_24",WA="_tabIcon_1bhou_62",XA="_tabActive_1bhou_68",ic={nav:YA,tab:JA,tabIcon:WA,tabActive:XA},Cs=[{path:"credentials",label:"Credentials",icon:"🔑"},{path:"personas",label:"Personas",icon:"👤"},{path:"appearance",label:"Appearance",icon:"🎨"},{path:"shortcuts",label:"Shortcuts",icon:"⌨️"},{path:"about",label:"About",icon:"ℹ️"}];function QA(){var d;const n=It(),s=St(),i=y.useRef(null),o=((d=Cs.find(m=>{const h=`${Ji}/${m.path}`;return n.pathname===h||n.pathname.startsWith(`${h}/`)}))==null?void 0:d.path)??Cs[0].path,c=y.useCallback(m=>{s(`${Ji}/${m}`)},[s]),u=y.useCallback(m=>{var S,T;const h=(S=i.current)==null?void 0:S.querySelectorAll('[role="tab"]');if(!h)return;const g=Array.from(h).findIndex(N=>N===document.activeElement),v=g>=0?g:Cs.findIndex(N=>N.path===o);let b=v;if(m.key==="ArrowDown"||m.key==="j"||m.key==="J")m.preventDefault(),b=(v+1)%Cs.length;else if(m.key==="ArrowUp"||m.key==="k"||m.key==="K")m.preventDefault(),b=(v-1+Cs.length)%Cs.length;else if(m.key==="Home")m.preventDefault(),b=0;else if(m.key==="End")m.preventDefault(),b=Cs.length-1;else return;const _=Cs[b].path;s(`${Ji}/${_}`),(T=h[b])==null||T.focus()},[o,s]);return l.jsx("nav",{className:ic.nav,ref:i,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:u,children:Cs.map(m=>{const h=m.path===o;return l.jsxs("button",{role:"tab",type:"button","aria-selected":h,tabIndex:h?0:-1,className:`${ic.tab} ${h?ic.tabActive:""}`,onClick:()=>c(m.path),children:[l.jsx("span",{className:ic.tabIcon,"aria-hidden":"true",children:m.icon}),m.label]},m.path)})})}const eD="_nav_1snmp_1",tD="_searchForm_1snmp_8",nD="_searchInput_1snmp_15",sD="_searchButton_1snmp_33",aD="_clearButton_1snmp_68",iD="_workspaceSelect_1snmp_85",oD="_listHeader_1snmp_99",rD="_nodeList_1snmp_108",lD="_nodeItem_1snmp_116",cD="_indicator_1snmp_129",uD="_label_1snmp_136",dD="_badge_1snmp_145",In={nav:eD,searchForm:tD,searchInput:nD,searchButton:sD,clearButton:aD,workspaceSelect:iD,listHeader:oD,nodeList:rD,nodeItem:lD,indicator:cD,label:uD,badge:dD};function fD({nodes:n,workspaces:s,loading:i,searchQuery:o,onSearch:c,onClearSearch:u,onSelectNode:d,onWorkspaceChange:m}){const[h,g]=y.useState(""),v=y.useCallback(T=>{T.preventDefault(),h.trim()&&c(h.trim())},[h,c]),b=y.useCallback(()=>{g(""),u()},[u]),_=y.useCallback(T=>{d(T)},[d]),S=y.useCallback(T=>{g(""),m(T)},[m]);return l.jsxs("div",{className:In.nav,"data-testid":"knowledge-nav",children:[l.jsxs("form",{className:In.searchForm,onSubmit:v,children:[l.jsx("input",{className:In.searchInput,type:"text",placeholder:"Search...",value:h,onChange:T=>{g(T.target.value)},"data-testid":"knowledge-search-input"}),l.jsx("button",{type:"submit",className:In.searchButton,disabled:i,children:"Go"})]}),o&&l.jsx("button",{type:"button",className:In.clearButton,onClick:b,children:"Clear search"}),l.jsxs("select",{className:In.workspaceSelect,onChange:T=>{S(T.target.value)},"data-testid":"knowledge-workspace-filter",children:[l.jsx("option",{value:"",children:"All workspaces"}),s.map(T=>l.jsx("option",{value:T.id,children:T.name},T.id))]}),l.jsxs("div",{className:In.listHeader,children:["Nodes (",n.length,")"]}),l.jsx("ul",{className:In.nodeList,children:n.map(T=>l.jsxs("li",{className:In.nodeItem,onClick:()=>{_(T.id)},onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),_(T.id))},role:"button",tabIndex:0,children:[l.jsx("span",{className:In.indicator,style:{backgroundColor:T.kind==="reference"?"#4A9EFF":T.category==="decision"?"#22C55E":T.category==="concept"?"#A855F7":T.category==="snippet"?"#6B7280":"#EAB308"}}),l.jsx("span",{className:In.label,children:T.label}),l.jsx("span",{className:In.badge,children:T.kind==="reference"?T.sourceType:T.category})]},T.id))})]})}function pD(){const{workspaces:n,tasks:s}=pt(),i=y.useMemo(()=>l.jsx(UA,{workspaces:n,tasks:s}),[n,s]);return Ic(i),l.jsx(Qa,{})}function mD(){const{environments:n}=pt(),s=y.useMemo(()=>l.jsx(KA,{environments:n}),[n]);return Ic(s),l.jsx(Qa,{})}function hD(){const n=y.useMemo(()=>l.jsx(QA,{}),[]);return Ic(n),l.jsx(Qa,{})}function gD(){const{knowledge:n,workspaces:s}=pt(),i=y.useCallback(m=>{n.search(m)},[n]),o=y.useCallback(()=>{n.clearSearch()},[n]),c=y.useCallback(m=>{n.selectNode(m)},[n]),u=y.useCallback(m=>{n.loadRecent(m||void 0)},[n]),d=y.useMemo(()=>l.jsx(fD,{nodes:n.graphData.nodes,workspaces:s,loading:n.loading,searchQuery:n.searchQuery,onSearch:i,onClearSearch:o,onSelectNode:c,onWorkspaceChange:u}),[n,s,i,o,c,u]);return Ic(d),l.jsx(Qa,{})}const vD="_bar_tnfsh_1",yD="_btnPrimary_tnfsh_32",bD="_statusText_tnfsh_85",_D="_statusCompleted_tnfsh_90",xD="_statusFailed_tnfsh_94",SD="_statusBlocked_tnfsh_98",TD="_hintText_tnfsh_103",ht={bar:vD,btnPrimary:yD,statusText:bD,statusCompleted:_D,statusFailed:xD,statusBlocked:SD,hintText:TD};function kD({sessions:n,tasks:s,environments:i}){const o=St(),c=It(),u=Dt("/sessions/:sessionId"),d=Dt("/tasks/:taskId"),m=Dt("/tasks/:taskId/stream"),h=Dt("/tasks/:taskId/findings"),g=Dt("/tasks/:taskId/edit"),v=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),b=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),_=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings"),S=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),T=Dt("/sessions/new"),N=Dt("/environments/:environmentId/workspaces/:workspaceId"),j=Dt("/tasks/new"),w=Dt("/chat"),E=Dt("/"),A=Dt("/settings/*"),O=u==null?void 0:u.params.sessionId,C=(d==null?void 0:d.params.taskId)??(m==null?void 0:m.params.taskId)??(h==null?void 0:h.params.taskId)??(v==null?void 0:v.params.taskId)??(b==null?void 0:b.params.taskId)??(_==null?void 0:_.params.taskId)??(S==null?void 0:S.params.taskId),M=v??b??_??S,G=(M==null?void 0:M.params.environmentId)??(N==null?void 0:N.params.environmentId),U=c.pathname.startsWith("/environments")&&!N&&!M,V=!!w,Z=!!T,ee=!!N&&!v&&!b&&!_&&!S,ie=!!j;if(!!E&&!Z&&!ee&&!ie||!!A||(!!g||!!S)||ie||U||Z)return l.jsx(l.Fragment,{});if(V)return i.find($=>$.adapterType==="local"&&$.status==="connected")?l.jsx(l.Fragment,{}):l.jsx("div",{className:ht.bar,children:l.jsx("span",{className:ht.hintText,children:"Add a local environment to start chatting"})});if(ee)return l.jsx("div",{className:ht.bar,children:l.jsx("span",{className:ht.hintText,children:"Select a task or click + to create one"})});if(C){const I=s.find(de=>de.id===C);if(!I)return l.jsx("div",{className:ht.bar,children:l.jsx("span",{className:ht.hintText,children:"Loading..."})});const $=new Map(s.map(de=>[de.id,de])),Q=I.dependsOn.some(de=>{const me=$.get(de);return me!==void 0&&me.status!=="complete"});if(I.status==="not_started"){const de=Q?I.dependsOn.map(me=>$.get(me)).filter(me=>me&&me.status!=="complete").map(me=>me.title):[];return l.jsx("div",{className:ht.bar,children:Q?l.jsxs("span",{className:ht.statusBlocked,children:["Blocked by: ",de.join(", ")]}):l.jsx("span",{className:ht.hintText,children:"Use the buttons above to start or manage this task"})})}if(I.status==="working"||I.status==="paused"){const de=I.latestSessionId||void 0,me=de?n.find(je=>je.id===de):void 0;return me&&me.status!=="stopped"?l.jsx(l.Fragment,{}):l.jsx("div",{className:ht.bar,children:l.jsx("span",{className:ht.hintText,children:"Waiting for agent..."})})}if(I.status==="complete")return l.jsxs("div",{className:ht.bar,children:[l.jsx("span",{className:`${ht.statusText} ${ht.statusCompleted}`,children:"Task completed"}),l.jsx("button",{onClick:()=>o(ei(I.workspaceId,void 0,G)),className:ht.btnPrimary,children:"+ New Task"})]});if(I.status==="failed")return l.jsx("div",{className:ht.bar,children:l.jsx("span",{className:`${ht.statusText} ${ht.statusFailed}`,children:"Task failed"})})}if(O){const I=n.find(de=>de.id===O),$=(I==null?void 0:I.status)==="stopped";if(I!==void 0&&!$)return l.jsx(l.Fragment,{});if($)return l.jsxs("div",{className:ht.bar,children:[l.jsxs("span",{className:`${ht.statusText} ${ht.hintText}`,children:["Session ",I.endReason||I.status]}),l.jsx("button",{onClick:()=>o(Cb(I.environmentId)),className:ht.btnPrimary,children:"+ New Chat"})]})}return l.jsx("div",{className:ht.bar,children:l.jsx("span",{className:ht.hintText,children:"Loading..."})})}const wD="_toast_da8ll_1",ND="_success_da8ll_18",jD="_icon_da8ll_22",CD="_error_da8ll_25",ED="_warning_da8ll_32",AD="_info_da8ll_38",DD="_message_da8ll_53",RD="_close_da8ll_60",rr={toast:wD,success:ND,icon:jD,error:CD,warning:ED,info:AD,message:DD,close:RD},MD={success:"✓",error:"✕",warning:"⚠",info:"ℹ"};function OD({toast:n,onDismiss:s}){return y.useEffect(()=>{const i=setTimeout(()=>s(n.id),n.duration);return()=>clearTimeout(i)},[n.id,n.duration,s]),l.jsxs(Rt.div,{className:`${rr.toast} ${rr[n.variant]}`,role:"status",initial:{opacity:0,y:-16,scale:.94},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.94},transition:{duration:.2,ease:"easeOut"},layout:!0,children:[l.jsx("span",{className:rr.icon,"aria-hidden":"true",children:MD[n.variant]}),l.jsx("span",{className:rr.message,children:n.message}),l.jsx("button",{type:"button",className:rr.close,onClick:()=>s(n.id),"aria-label":"Dismiss notification",children:"×"})]})}const ID="_container_qqse2_1",BD={container:ID};function LD(){const{toasts:n,dismissToast:s}=Bs();return l.jsx("div",{className:BD.container,"data-testid":"toast-container",children:l.jsx(rs,{children:n.map(i=>l.jsx(OD,{toast:i,onDismiss:s},i.id))})})}const UD="_callout_1jaue_1",zD="_success_1jaue_11",PD="_icon_1jaue_15",VD="_error_1jaue_18",qD="_warning_1jaue_25",HD="_info_1jaue_32",GD="_content_1jaue_48",$D="_close_1jaue_53",lr={callout:UD,success:zD,icon:PD,error:VD,warning:qD,info:HD,content:GD,close:$D},FD={success:"✓",error:"✕",warning:"⚠",info:"ℹ"};function ZD({variant:n="info",children:s,dismissible:i=!1,className:o}){const[c,u]=y.useState(!1);return l.jsx(l.Fragment,{children:!c&&l.jsxs("div",{className:[lr.callout,lr[n],o].filter(Boolean).join(" "),role:n==="error"||n==="warning"?"alert":"status",children:[l.jsx("span",{className:lr.icon,"aria-hidden":"true",children:FD[n]}),l.jsx("span",{className:lr.content,children:s}),i&&l.jsx("button",{type:"button",className:lr.close,onClick:()=>u(!0),"aria-label":"Dismiss",children:"×"})]})})}const KD="_breadcrumbs_17or2_1",YD="_list_17or2_11",JD="_item_17or2_21",WD="_separator_17or2_28",XD="_link_17or2_34",QD="_current_17or2_57",qi={breadcrumbs:KD,list:YD,item:JD,separator:WD,link:XD,current:QD},eR="›";function ba({segments:n}){return l.jsx("nav",{className:qi.breadcrumbs,"aria-label":"Breadcrumb","data-testid":"breadcrumbs",children:l.jsx("ol",{className:qi.list,children:n.map((s,i)=>{const o=i===n.length-1;return l.jsxs("li",{className:qi.item,children:[i>0&&l.jsx("span",{className:qi.separator,"aria-hidden":"true",children:eR}),s.url&&!o?l.jsx(yp,{className:qi.link,to:s.url,title:s.label,children:s.label}):l.jsx("span",{className:qi.current,"aria-current":"page",title:s.label,children:s.label})]},i)})})})}const tR="_btn_dwk2o_1",nR="_sm_dwk2o_22",sR="_md_dwk2o_28",aR="_lg_dwk2o_34",iR="_primary_dwk2o_40",oR="_danger_dwk2o_55",rR="_outline_dwk2o_70",lR="_ghost_dwk2o_80",kf={btn:tR,sm:nR,md:sR,lg:aR,primary:iR,danger:oR,outline:rR,ghost:lR},As=y.forwardRef(function({variant:s="primary",size:i="md",className:o,children:c,...u},d){const m=[kf.btn,kf[s],kf[i],o].filter(Boolean).join(" ");return l.jsx("button",{ref:d,className:m,...u,children:c})}),cR="_copyButton_1bqk0_1",uR={copyButton:cR},dR=2e3;async function fR(n,s){const i=new ClipboardItem({"text/html":new Blob([s],{type:"text/html"}),"text/plain":new Blob([n],{type:"text/plain"})});await navigator.clipboard.write([i])}function ni({text:n,getHtml:s,className:i,"data-testid":o}){const[c,u]=y.useState(!1),d=y.useRef(void 0);y.useEffect(()=>()=>{d.current!==void 0&&clearTimeout(d.current)},[]);const m=y.useCallback(async()=>{try{const h=s==null?void 0:s();if(h)try{await fR(n,h)}catch{await navigator.clipboard.writeText(n)}else await navigator.clipboard.writeText(n);u(!0),d.current!==void 0&&clearTimeout(d.current),d.current=setTimeout(()=>{u(!1),d.current=void 0},dR)}catch{}},[n,s]);return l.jsx("button",{type:"button",className:`${uR.copyButton} ${i??""}`,onClick:()=>{m().catch(()=>{})},"aria-label":c?"Copied":"Copy to clipboard","data-testid":o??"copy-button",children:c?"✓":"📋"})}const pR="_banner_bxqlh_1",mR="_label_bxqlh_15",hR="_text_bxqlh_25",gR="_link_bxqlh_29",oc={banner:pR,label:mR,text:hR,link:gR};function vR(){return l.jsxs("div",{className:oc.banner,"data-testid":"demo-banner",children:[l.jsx("span",{className:oc.label,children:"DEMO"}),l.jsxs("span",{className:oc.text,children:["This is an interactive demo with mock data."," ",l.jsx("a",{href:"https://github.com/nick-pape/grackle",target:"_blank",rel:"noopener noreferrer",className:oc.link,children:"Install Grackle"})," ","to use it for real."]})]})}const yR="_container_og0yp_1",bR="_chevronButton_og0yp_6",_R="_mainButton_og0yp_6",xR="_sm_og0yp_34",SR="_md_og0yp_34",TR="_lg_og0yp_34",kR="_primary_og0yp_57",wR="_danger_og0yp_70",NR="_outline_og0yp_83",jR="_ghost_og0yp_92",CR="_dropdown_og0yp_100",ER="_option_og0yp_113",AR="_optionLabel_og0yp_130",DR="_optionDesc_og0yp_135",Es={container:yR,chevronButton:bR,mainButton:_R,sm:xR,md:SR,lg:TR,primary:kR,danger:wR,outline:NR,ghost:jR,dropdown:CR,option:ER,optionLabel:AR,optionDesc:DR};function Cx({label:n,onClick:s,options:i,variant:o="primary",size:c="md","data-testid":u}){const[d,m]=y.useState(!1),h=y.useRef(null);y.useEffect(()=>{if(!d)return;function _(S){h.current&&S.target instanceof Node&&!h.current.contains(S.target)&&m(!1)}return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[d]),y.useEffect(()=>{if(!d)return;function _(S){S.key==="Escape"&&m(!1)}return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[d]);const g=Es[o]||"",v=Es[c]||"",b=()=>{d&&m(!1),s()};return l.jsxs("div",{ref:h,className:Es.container,"data-testid":u,children:[l.jsx("button",{type:"button",className:`${Es.mainButton} ${g} ${v}`,onClick:b,"data-testid":u?`${u}-main`:void 0,children:n}),l.jsx("button",{type:"button",className:`${Es.chevronButton} ${g} ${v}`,onClick:()=>m(_=>!_),"aria-label":`More options for ${n}`,"aria-haspopup":"menu","aria-expanded":d,"data-testid":u?`${u}-chevron`:void 0,children:"▾"}),d&&l.jsx("div",{className:Es.dropdown,"data-testid":u?`${u}-menu`:void 0,children:i.map((_,S)=>l.jsxs("button",{type:"button",className:Es.option,onClick:()=>{_.onClick(),m(!1)},children:[l.jsx("span",{className:Es.optionLabel,children:_.label}),_.description&&l.jsx("span",{className:Es.optionDesc,children:_.description})]},S))})]})}function op(){op=function(c,u){return new i(c,void 0,u)};var n=RegExp.prototype,s=new WeakMap;function i(c,u,d){var m=new RegExp(c,u);return s.set(m,d||s.get(c)),jc(m,i.prototype)}function o(c,u){var d=s.get(u);return Object.keys(d).reduce(function(m,h){var g=d[h];if(typeof g=="number")m[h]=c[g];else{for(var v=0;c[g[v]]===void 0&&v+1<g.length;)v++;m[h]=c[g[v]]}return m},Object.create(null))}return(function(c,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(u&&u.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),Object.defineProperty(c,"prototype",{writable:!1}),u&&jc(c,u)})(i,RegExp),i.prototype.exec=function(c){var u=n.exec.call(this,c);if(u){u.groups=o(u,this);var d=u.indices;d&&(d.groups=o(d,this))}return u},i.prototype[Symbol.replace]=function(c,u){if(typeof u=="string"){var d=s.get(this);return n[Symbol.replace].call(this,c,u.replace(/\$<([^>]+)>/g,function(h,g){var v=d[g];return"$"+(Array.isArray(v)?v.join("$"):v)}))}if(typeof u=="function"){var m=this;return n[Symbol.replace].call(this,c,function(){var h=arguments;return typeof h[h.length-1]!="object"&&(h=[].slice.call(h)).push(o(h,m)),u.apply(this,h)})}return n[Symbol.replace].call(this,c,u)},op.apply(this,arguments)}function jc(n,s){return jc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,o){return i.__proto__=o,i},jc(n,s)}function qy(n,s){(s==null||s>n.length)&&(s=n.length);for(var i=0,o=new Array(s);i<s;i++)o[i]=n[i];return o}function wf(n,s){var i=typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(i)return(i=i.call(n)).next.bind(i);if(Array.isArray(n)||(i=(function(c,u){if(c){if(typeof c=="string")return qy(c,u);var d=Object.prototype.toString.call(c).slice(8,-1);return d==="Object"&&c.constructor&&(d=c.constructor.name),d==="Map"||d==="Set"?Array.from(c):d==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(d)?qy(c,u):void 0}})(n))||s){i&&(n=i);var o=0;return function(){return o>=n.length?{done:!0}:{done:!1,value:n[o++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
473
473
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var RR=(function(n){return function(s){return s===void 0&&(s={}),(function(o,c){if(c&&!o.registered(c))throw new Error('The default language "'+c+'" is not registered with refractor.')})(n,s.defaultLanguage),function(o){WS(o,"element",i)};function i(o,c,u){var d,m;if(u&&u.tagName==="pre"&&o.tagName==="code"){var h=(o==null||(d=o.data)==null?void 0:d.meta)||(o==null||(m=o.properties)==null?void 0:m.metastring)||"";o.properties.className?typeof o.properties.className=="boolean"?o.properties.className=[]:Array.isArray(o.properties.className)||(o.properties.className=[o.properties.className]):o.properties.className=[];var g,v,b=(function(C){for(var M,G=wf(C.properties.className);!(M=G()).done;){var U=M.value;if(U.slice(0,9)==="language-")return U.slice(9).toLowerCase()}return null})(o);if(!b&&s.defaultLanguage&&o.properties.className.push("language-"+(b=s.defaultLanguage)),o.properties.className.push("code-highlight"),b)try{var _,S;S=(_=b)!=null&&_.includes("diff-")?b.split("-")[1]:b,g=n.highlight(Jl(o),S),u.properties.className=(u.properties.className||[]).concat("language-"+S)}catch(C){if(!s.ignoreMissing||!/Unknown language/.test(C.message))throw C;g=o}else g=o;g.children=(v=1,function C(M){return M.reduce(function(G,U){if(U.type==="text"){var V=U.value,Z=(V.match(/\n/g)||"").length;if(Z===0)U.position={start:{line:v,column:1},end:{line:v,column:1}},G.push(U);else for(var ee,ie=V.split(`
|
|
474
474
|
`),be=wf(ie.entries());!(ee=be()).done;){var K=ee.value,re=K[0],I=K[1];G.push({type:"text",value:re===ie.length-1?I:I+`
|
|
475
475
|
`,position:{start:{line:v+re,column:1},end:{line:v+re,column:1}}})}return v+=Z,G}if(Object.prototype.hasOwnProperty.call(U,"children")){var $=v;return U.children=C(U.children),G.push(U),U.position={start:{line:$,column:1},end:{line:v,column:1}},G}return G.push(U),G},[])})(g.children),g.position=g.children.length>0?{start:{line:g.children[0].position.start.line,column:0},end:{line:g.children[g.children.length-1].position.end.line,column:0}}:{start:{line:0,column:0},end:{line:0,column:0}};for(var T,N=(function(C){var M=/{([\d,-]+)}/,G=C.split(",").map(function(Z){return Z.trim()}).join();if(M.test(G)){var U=M.exec(G)[1],V=QS(U);return function(Z){return V.includes(Z+1)}}return function(){return!1}})(h),j=(function(C){var M=op(/showLineNumbers=(\d+)/i,{lines:1});if(M.test(C)){var G=M.exec(C);return Number(G.groups.lines)}return 1})(h),w=(function(C){for(var M=new Array(C),G=0;G<C;G++)M[G]={type:"element",tagName:"span",properties:{className:[]},children:[]};return M})(g.position.end.line),E=["showlinenumbers=false",'showlinenumbers="false"',"showlinenumbers={false}"],A=function(){var C,M,G=T.value,U=G[0],V=G[1];V.properties.className=["code-line"];var Z=eT(g,function(ee){return ee.position.start.line<=U+1&&ee.position.end.line>=U+1});V.children=Z.children,(h.toLowerCase().includes("showLineNumbers".toLowerCase())||s.showLineNumbers===!0||typeof s.showLineNumbers=="object"&&s.showLineNumbers.includes(b))&&!E.some(function(ee){return h.toLowerCase().includes(ee)})&&(V.properties.line=[(U+j).toString()],V.properties.className.push("line-number")),N(U)&&V.properties.className.push("highlight-line"),(b==="diff"||(C=b)!=null&&C.includes("diff-"))&&Jl(V).substring(0,1)==="-"?V.properties.className.push("deleted"):(b==="diff"||(M=b)!=null&&M.includes("diff-"))&&Jl(V).substring(0,1)==="+"&&V.properties.className.push("inserted")},O=wf(w.entries());!(T=O()).done;)A();w.length>0&&Jl(w[w.length-1]).trim()===""&&w.pop(),o.children=w}}}})(XS);function Ex(n){if(n>=1e6)return`${(n/1e6).toFixed(1)}M`;if(n>=1e3){const s=Number((n/1e3).toFixed(1));return s>=1e3?`${(n/1e6).toFixed(1)}M`:`${s.toFixed(1)}k`}return String(n)}function so(n){return n===0?"-":n<.01?`$${n.toFixed(4)}`:`$${n.toFixed(2)}`}const MR={read:"file-read",view:"file-read",edit:"file-edit",file_change:"file-edit",write:"file-write",bash:"shell",command_execution:"shell",grep:"search",glob:"search",todowrite:"todo",update_plan:"todo",todo_write:"todo",report_intent:"metadata"};function OR(n){return MR[n.toLowerCase()]??"generic"}const IR="_card_17a7m_2",BR="_cardBlue_17a7m_20",LR="_cardOrange_17a7m_24",UR="_cardGreen_17a7m_28",zR="_cardPurple_17a7m_32",PR="_cardNeutral_17a7m_36",VR="_cardRed_17a7m_40",qR="_header_17a7m_44",HR="_icon_17a7m_51",GR="_toolName_17a7m_58",$R="_fileName_17a7m_65",FR="_badge_17a7m_74",ZR="_spacer_17a7m_81",KR="_bodyToggle_17a7m_85",YR="_chevron_17a7m_103",JR="_chevronExpanded_17a7m_108",WR="_pre_17a7m_112",XR="_diffAdd_17a7m_136",QR="_diffRemove_17a7m_148",eM="_diffContext_17a7m_160",tM="_diffHeader_17a7m_169",nM="_diffLine_17a7m_175",sM="_exitOk_17a7m_181",aM="_exitError_17a7m_187",iM="_exitPending_17a7m_193",oM="_copyButtonInline_17a7m_207",rM="_inProgress_17a7m_221",lM="_metadata_17a7m_225",cM="_metadataPrefix_17a7m_232",ae={card:IR,cardBlue:BR,cardOrange:LR,cardGreen:UR,cardPurple:zR,cardNeutral:PR,cardRed:VR,header:qR,icon:HR,toolName:GR,fileName:$R,badge:FR,spacer:ZR,bodyToggle:KR,chevron:YR,chevronExpanded:JR,pre:WR,diffAdd:XR,diffRemove:QR,diffContext:eM,diffHeader:tM,diffLine:nM,exitOk:sM,exitError:aM,exitPending:iM,copyButtonInline:oM,inProgress:rM,metadata:lM,metadataPrefix:cM};function uM(n){if(n==null||typeof n!="object")return"";const s=n;return typeof s.file_path=="string"?s.file_path:typeof s.path=="string"?s.path:""}function dM(n){const s=n.split(/[/\\]/);return s[s.length-1]||n}const Nf=5;function Hy({tool:n,args:s,result:i,isError:o,writeVariant:c}){const[u,d]=y.useState(!1),m=uM(s),h=dM(m),g=i===void 0,v=o?ae.cardRed:c?ae.cardGreen:ae.cardBlue,b=c?"var(--accent-green)":"var(--accent-blue)",_=c?"📝":"📄",S=c?"tool-card-file-write":"tool-card-file-read",T=(i==null?void 0:i.split(`
|
|
@@ -486,7 +486,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
486
486
|
`))??[],v=g.length>Af,b=c?i:g.slice(0,Af).join(`
|
|
487
487
|
`);let _="";if(s!=null)try{_=JSON.stringify(s,null,2)}catch{_=String(s)}return l.jsxs("div",{className:`${ae.card} ${o?ae.cardRed:ae.cardBlue} ${h?ae.inProgress:""}`,"data-testid":"tool-card-generic",children:[l.jsxs("div",{className:ae.header,children:[l.jsx("span",{className:ae.icon,children:"⚙"}),l.jsx("span",{className:ae.toolName,style:{color:"var(--accent-blue)"},children:d}),m&&l.jsx("span",{className:ae.fileName,children:m}),!h&&!o&&i&&l.jsx(ni,{text:i,"data-testid":"tool-card-copy",className:ae.copyButtonInline})]}),h&&_&&l.jsx("pre",{className:ae.pre,"data-testid":"tool-card-args",children:_}),o&&i&&l.jsx("pre",{className:ae.pre,"data-testid":"tool-card-error",children:i}),!o&&!h&&i&&l.jsxs(l.Fragment,{children:[l.jsx("pre",{className:ae.pre,"data-testid":"tool-card-result",children:b}),v&&l.jsxs("button",{type:"button",className:ae.bodyToggle,onClick:()=>{u(S=>!S)},"aria-expanded":c,"data-testid":"tool-card-toggle",children:[l.jsx("span",{className:`${ae.chevron} ${c?ae.chevronExpanded:""}`,children:"▸"}),c?"collapse":`${g.length-Af} more lines`]})]})]})}function Df(n){switch(OR(n.tool)){case"file-read":return l.jsx(Hy,{...n});case"file-edit":return l.jsx(bM,{...n});case"file-write":return l.jsx(Hy,{...n,writeVariant:!0});case"shell":return l.jsx(kM,{...n});case"search":return l.jsx(NM,{...n});case"todo":return l.jsx($M,{...n});case"metadata":return l.jsx(ZM,{...n});default:return l.jsx(JM,{...n})}}const WM="_systemContextEvent_8n7q0_1",XM="_systemContextHeader_8n7q0_7",QM="_systemContextBadge_8n7q0_28",e3="_systemContextToggle_8n7q0_37",t3="_systemContextPre_8n7q0_43",n3="_systemContextEllipsis_8n7q0_54",s3="_systemEvent_8n7q0_58",a3="_systemTimestamp_8n7q0_65",i3="_textEvent_8n7q0_69",o3="_messageCopyButton_8n7q0_75",r3="_codeBlockWrapper_8n7q0_159",l3="_codeBlockCopyButton_8n7q0_162",c3="_errorEvent_8n7q0_166",u3="_statusEvent_8n7q0_174",d3="_userInputEvent_8n7q0_183",f3="_userInputContent_8n7q0_189",p3="_signalEvent_8n7q0_206",m3="_signalBadge_8n7q0_217",h3="_signalContent_8n7q0_226",g3="_usageEvent_8n7q0_231",v3="_usageBadge_8n7q0_238",y3="_defaultEvent_8n7q0_247",xt={systemContextEvent:WM,systemContextHeader:XM,systemContextBadge:QM,systemContextToggle:e3,systemContextPre:t3,systemContextEllipsis:n3,systemEvent:s3,systemTimestamp:a3,textEvent:i3,messageCopyButton:o3,codeBlockWrapper:r3,codeBlockCopyButton:l3,errorEvent:c3,statusEvent:u3,userInputEvent:d3,userInputContent:f3,signalEvent:p3,signalBadge:m3,signalContent:h3,usageEvent:g3,usageBadge:v3,defaultEvent:y3},$y=3;function b3({content:n}){const[s,i]=y.useState(!1),o=n.split(`
|
|
488
488
|
`),c=o.length>$y,u=s?n:o.slice(0,$y).join(`
|
|
489
|
-
`);return l.jsxs("div",{className:xt.systemContextEvent,"data-testid":"system-context-event",children:[l.jsxs("button",{type:"button",className:xt.systemContextHeader,onClick:()=>{i(d=>!d)},"aria-expanded":s,children:[l.jsx("span",{className:xt.systemContextBadge,children:"SYSTEM PROMPT"}),c&&l.jsx("span",{className:xt.systemContextToggle,"aria-hidden":"true",children:s?"▾":"▸"})]}),l.jsxs("pre",{className:xt.systemContextPre,children:[u,!s&&c&&l.jsx("span",{className:xt.systemContextEllipsis,children:"…"})]})]})}function _3({time:n,content:s}){return l.jsxs("div",{className:xt.systemEvent,children:[l.jsxs("span",{className:xt.systemTimestamp,children:["[",n,"]"]})," ",s]})}function rp(n){return typeof n=="string"?n:typeof n=="number"?String(n):Array.isArray(n)?n.map(rp).join(""):n!=null&&typeof n=="object"&&"props"in n?rp(n.props.children):""}function x3({children:n,node:s,...i}){const o=rp(n);return l.jsxs("div",{className:xt.codeBlockWrapper,children:[l.jsx("pre",{...i,children:n}),l.jsx(ni,{text:o,"data-testid":"copy-code-block",className:xt.codeBlockCopyButton})]})}const S3={pre:x3};function T3({content:n}){const s=y.useRef(null),i=y.useCallback(()=>{if(!s.current)return;const o=s.current.cloneNode(!0);for(const c of o.querySelectorAll("[data-testid='copy-code-block']"))c.remove();return o.innerHTML},[]);return l.jsxs("div",{className:xt.textEvent,children:[l.jsx(ni,{text:n,getHtml:i,"data-testid":"copy-message",className:xt.messageCopyButton}),l.jsx("div",{ref:s,children:l.jsx(up,{remarkPlugins:[dp],rehypePlugins:[RR],components:S3,children:n})})]})}function k3({content:n}){return l.jsxs("div",{className:xt.errorEvent,children:["Error: ",n]})}function w3({content:n}){return l.jsxs("div",{className:xt.statusEvent,children:["--- ",n," ---"]})}function N3({content:n}){return l.jsx("div",{className:xt.userInputEvent,children:l.jsx("span",{className:xt.userInputContent,children:n})})}function j3({content:n}){return l.jsxs("div",{className:xt.signalEvent,"data-testid":"signal-event",children:[l.jsx("span",{className:xt.signalBadge,children:"SIGNAL"}),l.jsx("span",{className:xt.signalContent,children:n})]})}function C3({content:n}){let s=n;try{const i=JSON.parse(n),o=Number(i.input_tokens)||0,c=Number(i.output_tokens)||0,u=Ex(o+c),d=so(Number(i.cost_usd)||0);s=`${u} tokens · ${d}`}catch{}return l.jsx("div",{className:xt.usageEvent,"data-testid":"usage-event",children:l.jsx("span",{className:xt.usageBadge,children:s})})}function E3({content:n}){return l.jsx("div",{className:xt.defaultEvent,children:n})}function A3({event:n,toolUseCtx:s}){const i=new Date(n.timestamp).toLocaleTimeString();switch(n.eventType){case"system":{if(n.raw)try{if(JSON.parse(n.raw).systemContext===!0)return l.jsx(b3,{content:n.content})}catch{}return l.jsx(_3,{time:i,content:n.content})}case"text":case"output":return l.jsx(T3,{content:n.content});case"tool_use":{let o="",c={};try{const u=JSON.parse(n.content);o=u.tool||"",c=u.args}catch{}return l.jsx(Df,{tool:o,args:c})}case"tool_result":{let o=!1;if(n.raw)try{o=JSON.parse(n.raw).is_error===!0}catch{}let c=n.content;if(n.content.trimStart().startsWith("{"))try{const u=JSON.parse(n.content);typeof u.content=="string"&&(c=u.content)}catch{}return s?l.jsx(Df,{tool:s.tool,args:s.args,result:c,isError:o,detailedResult:s.detailedResult}):l.jsx(Df,{tool:"Tool output",args:void 0,result:c,isError:o})}case"error":return l.jsx(k3,{content:n.content});case"status":return l.jsx(w3,{content:n.content});case"user_input":return l.jsx(N3,{content:n.content});case"signal":return l.jsx(j3,{content:n.content});case"usage":return l.jsx(C3,{content:n.content});default:return l.jsx(E3,{content:n.content})}}const D3="_overlay_cmicx_1",R3="_dialog_cmicx_11",M3="_title_cmicx_30",O3="_description_cmicx_38",I3="_actions_cmicx_45",B3="_cancelButton_cmicx_52",L3="_confirmButton_cmicx_79",Va={overlay:D3,dialog:R3,title:M3,description:O3,actions:I3,cancelButton:B3,confirmButton:L3};function Ja({isOpen:n,title:s,description:i,confirmLabel:o="Delete",onConfirm:c,onCancel:u}){const d=y.useId(),m=y.useId();return l.jsx(rs,{children:n&&l.jsx(Rt.div,{className:Va.overlay,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},onClick:u,onKeyDown:h=>{h.key==="Escape"&&u()},role:"dialog","aria-modal":"true","aria-labelledby":d,"aria-describedby":i?m:void 0,children:l.jsxs(Rt.div,{className:Va.dialog,initial:{opacity:0,scale:.93,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.93,y:-10},transition:{duration:.15,ease:[.16,1,.3,1]},onClick:h=>h.stopPropagation(),children:[l.jsx("h3",{id:d,className:Va.title,children:s}),i&&l.jsx("p",{id:m,className:Va.description,children:i}),l.jsxs("div",{className:Va.actions,children:[l.jsx("button",{type:"button",className:Va.cancelButton,onClick:u,autoFocus:!0,children:"Cancel"}),l.jsx("button",{type:"button",className:Va.confirmButton,onClick:c,children:o})]})]})})})}const U3="_spinner_1uyt1_1",z3="_spin_1uyt1_1",P3="_sm_1uyt1_14",V3="_md_1uyt1_20",q3="_lg_1uyt1_26",H3="_xl_1uyt1_32",Fy={spinner:U3,spin:z3,sm:P3,md:V3,lg:q3,xl:H3};function Ax({size:n="md",className:s,label:i="Loading",liveRegion:o=!1}){return l.jsx("span",{className:`${Fy.spinner} ${Fy[n]} ${s??""}`,role:o?"status":void 0,"aria-label":i,"aria-hidden":o?void 0:!0})}const G3="_splash_1bn1g_1",$3="_logo_1bn1g_11",Zy={splash:G3,logo:$3};function Dx(){return l.jsxs("div",{className:Zy.splash,"data-testid":"splash-screen",children:[l.jsx("img",{src:"/grackle-logo.png",alt:"Grackle",className:Zy.logo}),l.jsx(Ax,{size:"xl",label:"Loading Grackle",liveRegion:!0})]})}function F3(n,s){const i=y.useRef(null);y.useEffect(()=>{const o=i.current;if(i.current=n,o===null)return;const c=new Map;for(const d of o)c.set(d.id,d);const u=new Set;for(const d of n){u.add(d.id);const m=c.get(d.id);if(m&&m.status!==d.status&&d.status!=="sleeping"){if(d.status==="connecting"){s("Provisioning environment…","info");continue}d.status==="connected"?s("Environment connected","success"):d.status==="error"?s("Environment provision failed","error"):d.status==="disconnected"&&(m.status==="connected"?s("Environment disconnected","warning"):s("Environment stopped","info"))}}for(const d of o)u.has(d.id)||s("Environment removed","info")},[n,s])}const Z3={working:{message:"Task is now running",variant:"info"},paused:{message:"Task paused",variant:"warning"},complete:{message:"Task complete",variant:"success"},failed:{message:"Task failed to complete",variant:"error"}};function K3(n){return Z3[n]}function Y3(n,s){if(n===void 0)return[];const i=[],o=new Map;for(const u of n)o.set(u.id,u);const c=new Set;for(const u of s){c.add(u.id);const d=o.get(u.id);if(!d||d.status===u.status)continue;const m=K3(u.status);m&&i.push(m)}for(const u of n)c.has(u.id)||i.push({message:"Task deleted",variant:"info"});return i}function J3(n,s){const i=y.useRef(void 0);y.useEffect(()=>{const o=i.current;i.current=n;const c=Y3(o,n);for(const u of c)s(u.message,u.variant)},[n,s])}function W3(n,s,i){const o=n.filter(h=>h.status==="running"||h.status==="idle"||h.status==="waiting").length,c=Rx(s),u=s.filter(h=>lp(h,c)).length,d=s.filter(h=>h.status==="paused"||h.status==="failed"||lp(h,c)).length,m=i.filter(h=>h.status==="disconnected"||h.status==="error").length;return{activeSessions:o,blockedTasks:u,attentionTasks:d,unhealthyEnvironments:m}}function Rx(n){const s=new Map;for(const i of n)s.set(i.id,i.status);return s}function lp(n,s){return n.dependsOn.some(i=>s.get(i)!=="complete")}function X3(n,s){var d;const i=new Map;for(const m of s)i.set(m.id,m);const o=Rx(n),c=[];for(const m of n){const h=m.workspaceId?((d=i.get(m.workspaceId))==null?void 0:d.name)??"Unknown":"Unknown";m.status==="failed"?c.push({task:m,reason:"failed",workspaceName:h}):lp(m,o)?c.push({task:m,reason:"blocked",workspaceName:h}):m.status==="paused"&&c.push({task:m,reason:"paused",workspaceName:h})}const u={failed:0,blocked:1,paused:2};return c.sort((m,h)=>(u[m.reason]??3)-(u[h.reason]??3)),c}function Q3(n,s){const i=new Map;for(const o of s)i.set(o.id,o);return n.filter(o=>o.status==="running"||o.status==="idle"||o.status==="waiting").map(o=>{var c;return{session:o,environmentName:((c=i.get(o.environmentId))==null?void 0:c.displayName)??"Unknown"}})}function e6(n,s,i){const o=new Map;for(const c of s){if(!c.workspaceId)continue;let u=o.get(c.workspaceId);u||(u={totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0},o.set(c.workspaceId,u)),u.totalTasks+=1,c.status==="complete"?u.completedTasks+=1:c.status==="working"?u.workingTasks+=1:c.status==="failed"&&(u.failedTasks+=1)}return n.map(c=>{const u=o.get(c.id)??{totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0};return{workspace:c,totalTasks:u.totalTasks,completedTasks:u.completedTasks,workingTasks:u.workingTasks,failedTasks:u.failedTasks}})}const t6="_dashboard_16pzm_1",n6="_kpiStrip_16pzm_11",s6="_kpiCard_16pzm_23",a6="_kpiValue_16pzm_68",i6="_kpiLabel_16pzm_76",o6="_bodyGrid_16pzm_84",r6="_section_16pzm_96",l6="_sectionHeader_16pzm_109",c6="_sectionIcon_16pzm_118",u6="_sectionTitle_16pzm_123",d6="_sectionCount_16pzm_131",f6="_sectionBody_16pzm_138",p6="_emptyHint_16pzm_143",m6="_sessionRow_16pzm_150",h6="_sessionPrompt_16pzm_177",g6="_sessionEnv_16pzm_186",v6="_sessionRuntime_16pzm_192",y6="_sessionStatus_16pzm_198",b6="_statusDot_16pzm_207",_6="_attentionRow_16pzm_233",x6="_attentionTitle_16pzm_259",S6="_attentionMeta_16pzm_267",T6="_reasonBadge_16pzm_274",k6="_bottomGrid_16pzm_301",w6="_envRow_16pzm_312",N6="_envName_16pzm_323",j6="_envStatusBadge_16pzm_333",C6="_workspaceRow_16pzm_369",E6="_workspaceTop_16pzm_395",A6="_workspaceName_16pzm_401",D6="_workspaceCounts_16pzm_407",R6="_progressBar_16pzm_415",M6="_progressFill_16pzm_422",xe={dashboard:t6,kpiStrip:n6,kpiCard:s6,kpiValue:a6,kpiLabel:i6,bodyGrid:o6,section:r6,sectionHeader:l6,sectionIcon:c6,sectionTitle:u6,sectionCount:d6,sectionBody:f6,emptyHint:p6,sessionRow:m6,sessionPrompt:h6,sessionEnv:g6,sessionRuntime:v6,sessionStatus:y6,statusDot:b6,attentionRow:_6,attentionTitle:x6,attentionMeta:S6,reasonBadge:T6,bottomGrid:k6,envRow:w6,envName:N6,envStatusBadge:j6,workspaceRow:C6,workspaceTop:E6,workspaceName:A6,workspaceCounts:D6,progressBar:R6,progressFill:M6},O6={hidden:{opacity:0,y:12},visible:n=>({opacity:1,y:0,transition:{delay:n*.06,duration:.3,ease:"easeOut"}})},rc={hidden:{opacity:0,y:16},visible:n=>({opacity:1,y:0,transition:{delay:.15+n*.08,duration:.35,ease:"easeOut"}})};function I6(n,s,i,o){const c=[`${n} of ${s} tasks completed`];return i>0&&c.push(`${i} in progress`),o>0&&c.push(`${o} failed`),c.join(", ")}function lc({value:n,label:s,accent:i,index:o,testId:c}){return l.jsxs(Rt.div,{className:xe.kpiCard,"data-accent":i,"data-testid":c,variants:O6,initial:"hidden",animate:"visible",custom:o,children:[l.jsx("span",{className:xe.kpiValue,children:n}),l.jsx("span",{className:xe.kpiLabel,children:s})]})}function B6(){const{workspaces:n,tasks:s,sessions:i,environments:o,loadTasks:c}=pt(),u=St(),d=y.useRef(new Set);y.useEffect(()=>{for(const b of n)d.current.has(b.id)||(d.current.add(b.id),c(b.id))},[n,c]);const m=y.useMemo(()=>W3(i,s,o),[i,s,o]),h=y.useMemo(()=>Q3(i,o),[i,o]),g=y.useMemo(()=>X3(s,n),[s,n]),v=y.useMemo(()=>e6(n,s),[n,s,o]);return l.jsxs("div",{className:xe.dashboard,"data-testid":"dashboard",children:[l.jsxs("div",{className:xe.kpiStrip,"data-testid":"dashboard-kpi-strip",children:[l.jsx(lc,{value:m.activeSessions,label:"Active Sessions",accent:"green",index:0,testId:"kpi-active-sessions"}),l.jsx(lc,{value:m.blockedTasks,label:"Blocked Tasks",accent:"yellow",index:1,testId:"kpi-blocked-tasks"}),l.jsx(lc,{value:m.attentionTasks,label:"Needs Attention",accent:"red",index:2,testId:"kpi-attention-tasks"}),l.jsx(lc,{value:m.unhealthyEnvironments,label:"Unhealthy Envs",accent:"blue",index:3,testId:"kpi-unhealthy-envs"})]}),l.jsxs("div",{className:xe.bodyGrid,children:[l.jsxs(Rt.div,{className:xe.section,variants:rc,initial:"hidden",animate:"visible",custom:0,"data-testid":"dashboard-active-sessions",children:[l.jsxs("div",{className:xe.sectionHeader,children:[l.jsx("span",{className:xe.sectionIcon,"aria-hidden":"true",children:"●"}),l.jsx("span",{className:xe.sectionTitle,children:"Active Sessions"}),l.jsx("span",{className:xe.sectionCount,children:h.length})]}),l.jsx("div",{className:xe.sectionBody,children:h.length===0?l.jsx("div",{className:xe.emptyHint,children:"No active sessions"}):h.map(({session:b,environmentName:_})=>l.jsxs("button",{type:"button",className:xe.sessionRow,onClick:()=>u(jb(b.id)),"data-testid":"session-row",children:[l.jsx("span",{className:xe.sessionPrompt,title:b.prompt,children:b.prompt||"—"}),l.jsx("span",{className:xe.sessionEnv,children:_}),l.jsx("span",{className:xe.sessionRuntime,children:b.runtime}),l.jsxs("span",{className:xe.sessionStatus,children:[l.jsx("span",{className:xe.statusDot,"data-status":b.status}),b.status]})]},b.id))})]}),l.jsxs(Rt.div,{className:xe.section,variants:rc,initial:"hidden",animate:"visible",custom:1,"data-testid":"dashboard-needs-attention",children:[l.jsxs("div",{className:xe.sectionHeader,children:[l.jsx("span",{className:xe.sectionIcon,"aria-hidden":"true",children:"⚑"}),l.jsx("span",{className:xe.sectionTitle,children:"Needs Attention"}),l.jsx("span",{className:xe.sectionCount,children:g.length})]}),l.jsx("div",{className:xe.sectionBody,children:g.length===0?l.jsx("div",{className:xe.emptyHint,children:"All clear"}):g.map(({task:b,reason:_,workspaceName:S})=>l.jsxs("button",{type:"button",className:xe.attentionRow,onClick:()=>u(os(b.id)),"data-testid":"attention-row",children:[l.jsxs("div",{className:xe.attentionTitle,children:[l.jsx("span",{className:xe.reasonBadge,"data-reason":_,children:_}),b.title]}),l.jsx("div",{className:xe.attentionMeta,children:l.jsx("span",{children:S})})]},b.id))})]})]}),l.jsxs("div",{className:xe.bottomGrid,children:[l.jsxs(Rt.div,{className:xe.section,variants:rc,initial:"hidden",animate:"visible",custom:2,"data-testid":"dashboard-env-health",children:[l.jsxs("div",{className:xe.sectionHeader,children:[l.jsx("span",{className:xe.sectionIcon,"aria-hidden":"true",children:"◈"}),l.jsx("span",{className:xe.sectionTitle,children:"Environment Health"}),l.jsx("span",{className:xe.sectionCount,children:o.length})]}),l.jsx("div",{className:xe.sectionBody,children:o.length===0?l.jsx("div",{className:xe.emptyHint,children:"No environments configured"}):o.map(b=>l.jsxs("div",{className:xe.envRow,"data-testid":"dashboard-env-row",children:[l.jsx("span",{className:xe.envName,children:b.displayName}),l.jsx("span",{className:xe.envStatusBadge,"data-status":b.status,children:b.status})]},b.id))})]}),l.jsxs(Rt.div,{className:xe.section,variants:rc,initial:"hidden",animate:"visible",custom:3,"data-testid":"dashboard-workspace-snapshot",children:[l.jsxs("div",{className:xe.sectionHeader,children:[l.jsx("span",{className:xe.sectionIcon,"aria-hidden":"true",children:"▦"}),l.jsx("span",{className:xe.sectionTitle,children:"Workspaces"}),l.jsx("span",{className:xe.sectionCount,children:n.length})]}),l.jsx("div",{className:xe.sectionBody,children:v.length===0?l.jsx("div",{className:xe.emptyHint,children:"No workspaces yet"}):v.map(({workspace:b,totalTasks:_,completedTasks:S,workingTasks:T,failedTasks:N})=>{const j=_>0?Math.round(S/_*100):0;return l.jsxs("button",{type:"button",className:xe.workspaceRow,onClick:()=>u(Wi(b.id,b.environmentId)),"data-testid":"workspace-row",children:[l.jsxs("div",{className:xe.workspaceTop,children:[l.jsx("span",{className:xe.workspaceName,children:b.name}),l.jsxs("span",{className:xe.workspaceCounts,"aria-label":I6(S,_,T,N),children:[S,"/",_,T>0&&l.jsxs("span",{style:{color:"var(--accent-green)"},"aria-hidden":"true",children:["▸",T]}),N>0&&l.jsxs("span",{style:{color:"var(--accent-red)"},"aria-hidden":"true",children:["✗",N]})]})]}),_>0&&l.jsx("div",{className:xe.progressBar,children:l.jsx("div",{className:xe.progressFill,style:{width:`${j}%`}})})]},b.id)})})]})]})]})}const L6="_panelContainer_1h5qd_1",U6="_emptyState_1h5qd_8",z6="_fadeIn_1h5qd_1",P6="_workspaceSummary_1h5qd_17",V6="_workspaceSummaryTitle_1h5qd_28",q6="_workspaceSummarySubtitle_1h5qd_32",H6="_header_1h5qd_36",G6="_headerInfo_1h5qd_71",$6="_killButton_1h5qd_77",F6="_headerTitle_1h5qd_106",Z6="_headerActions_1h5qd_121",K6="_taskStatusBadge_1h5qd_128",Y6="_taskBranch_1h5qd_137",J6="_taskBlockedBadge_1h5qd_143",W6="_btnPrimary_1h5qd_151",X6="_btnDanger_1h5qd_182",Q6="_btnGhost_1h5qd_221",eO="_rejectInput_1h5qd_247",tO="_tabBar_1h5qd_277",nO="_tab_1h5qd_277",sO="_active_1h5qd_303",aO="_eventScroll_1h5qd_308",iO="_tabContent_1h5qd_314",oO="_noContext_1h5qd_319",rO="_overviewContent_1h5qd_325",lO="_overviewDashboard_1h5qd_334",cO="_overviewHero_1h5qd_340",uO="_statusBadge_1h5qd_347",dO="_statusPending_1h5qd_359",fO="_statusAssigned_1h5qd_364",pO="_statusInProgress_1h5qd_369",mO="_statusReview_1h5qd_374",hO="_statusDone_1h5qd_379",gO="_statusFailed_1h5qd_384",vO="_statusWaitingInput_1h5qd_389",yO="_overviewBranchPill_1h5qd_394",bO="_branchLink_1h5qd_409",_O="_overviewSection_1h5qd_420",xO="_overviewLabel_1h5qd_426",SO="_overviewValue_1h5qd_433",TO="_overviewMuted_1h5qd_438",kO="_overviewMarkdown_1h5qd_444",wO="_envRow_1h5qd_513",NO="_envDot_1h5qd_519",jO="_envDotGreen_1h5qd_526",CO="_envDotYellow_1h5qd_530",EO="_envDotRed_1h5qd_534",AO="_envDotGray_1h5qd_538",DO="_depList_1h5qd_542",RO="_depItem_1h5qd_548",MO="_depBlocked_1h5qd_555",OO="_depDone_1h5qd_559",IO="_timeline_1h5qd_563",BO="_timelineRow_1h5qd_569",LO="_timelineKey_1h5qd_576",UO="_timelineValue_1h5qd_582",zO="_timelineDelta_1h5qd_586",PO="_reviewNotes_1h5qd_597",VO="_overviewDescription_1h5qd_608",qO="_waitingMessage_1h5qd_614",HO="_errorMessage_1h5qd_618",GO="_eventOverflowWarning_1h5qd_622",$O="_attemptSelector_1h5qd_636",FO="_attemptLabel_1h5qd_652",ZO="_attemptButton_1h5qd_656",KO="_attemptActive_1h5qd_673",YO="_attemptStatus_1h5qd_679",JO="_emptyCta_1h5qd_685",WO="_ctaTitle_1h5qd_697",XO="_ctaDescription_1h5qd_703",QO="_ctaButton_1h5qd_710",eI="_ctaCreateForm_1h5qd_745",tI="_ctaCreateInput_1h5qd_751",nI="_ctaCreateOk_1h5qd_782",sI="_ctaLink_1h5qd_817",aI="_workspaceHeader_1h5qd_831",iI="_workspaceName_1h5qd_856",oI="_workspaceMeta_1h5qd_869",rI="_metaRow_1h5qd_877",lI="_metaLabel_1h5qd_890",cI="_metaValue_1h5qd_905",uI="_archiveButton_1h5qd_915",dI="_repoLink_1h5qd_945",fI="_metaToggle_1h5qd_955",pI="_metaToggleArrow_1h5qd_976",mI="_metaToggleArrowOpen_1h5qd_981",hI="_progressBarContainer_1h5qd_985",gI="_progressBar_1h5qd_985",vI="_progressFill_1h5qd_1001",yI="_progressLabel_1h5qd_1008",bI="_metaTimestamps_1h5qd_1015",_I="_metaTimestamp_1h5qd_1015",L={panelContainer:L6,emptyState:U6,fadeIn:z6,workspaceSummary:P6,workspaceSummaryTitle:V6,workspaceSummarySubtitle:q6,header:H6,headerInfo:G6,killButton:$6,headerTitle:F6,headerActions:Z6,taskStatusBadge:K6,taskBranch:Y6,taskBlockedBadge:J6,btnPrimary:W6,btnDanger:X6,btnGhost:Q6,rejectInput:eO,tabBar:tO,tab:nO,active:sO,eventScroll:aO,tabContent:iO,noContext:oO,overviewContent:rO,overviewDashboard:lO,overviewHero:cO,statusBadge:uO,statusPending:dO,statusAssigned:fO,statusInProgress:pO,statusReview:mO,statusDone:hO,statusFailed:gO,statusWaitingInput:vO,overviewBranchPill:yO,branchLink:bO,overviewSection:_O,overviewLabel:xO,overviewValue:SO,overviewMuted:TO,overviewMarkdown:kO,envRow:wO,envDot:NO,envDotGreen:jO,envDotYellow:CO,envDotRed:EO,envDotGray:AO,depList:DO,depItem:RO,depBlocked:MO,depDone:OO,timeline:IO,timelineRow:BO,timelineKey:LO,timelineValue:UO,timelineDelta:zO,reviewNotes:PO,overviewDescription:VO,waitingMessage:qO,errorMessage:HO,eventOverflowWarning:GO,attemptSelector:$O,attemptLabel:FO,attemptButton:ZO,attemptActive:KO,attemptStatus:YO,emptyCta:JO,ctaTitle:WO,ctaDescription:XO,ctaButton:QO,ctaCreateForm:eI,ctaCreateInput:tI,ctaCreateOk:nI,ctaLink:sI,workspaceHeader:aI,workspaceName:iI,workspaceMeta:oI,metaRow:rI,metaLabel:lI,metaValue:cI,archiveButton:uI,repoLink:dI,metaToggle:fI,metaToggleArrow:pI,metaToggleArrowOpen:mI,progressBarContainer:hI,progressBar:gI,progressFill:vI,progressLabel:yI,metaTimestamps:bI,metaTimestamp:_I};function xI(){return l.jsx("div",{className:L.emptyState,children:"Select a task or click + to create one"})}function SI(){return l.jsx("div",{className:L.emptyState,children:"Select an environment to manage its workspaces, or add a new one."})}function TI(){const{workspaces:n,environments:s}=pt(),i=St(),o=s.length>0;return n.length>0?l.jsx(B6,{}):l.jsxs("div",{className:L.emptyCta,"data-testid":"welcome-cta",children:[l.jsx("div",{className:L.ctaTitle,children:"Welcome to Grackle"}),l.jsx("div",{className:L.ctaDescription,children:"Organize your work into workspaces and let agents tackle the tasks."}),l.jsx("button",{className:L.ctaButton,onClick:()=>i(Ab),disabled:!o,"data-testid":"welcome-create-button",children:"Create Your First Workspace"}),!o&&l.jsx("div",{className:L.ctaDescription,children:"Add an environment first before creating a workspace."})]})}const Mx=50;function kI(n,s,i,o,c=Mx){return o?n<c:s-n-i<c}function wI(n,s){const i=s-n;return i>0?i:0}function NI({scrollRef:n,contentLength:s,isReversed:i}){const[o,c]=y.useState(!0),u=y.useRef(0),d=y.useRef(!1),m=y.useRef(0);y.useEffect(()=>{const g=n.current;if(!g)return;let v=!0;const b=()=>{m.current||(m.current=requestAnimationFrame(()=>{m.current=0;const _=kI(g.scrollTop,g.scrollHeight,g.clientHeight,i,Mx);_!==v&&(v=_,c(_))}))};return g.addEventListener("scroll",b,{passive:!0}),()=>{g.removeEventListener("scroll",b),m.current&&(cancelAnimationFrame(m.current),m.current=0)}},[n,i]),y.useLayoutEffect(()=>{const g=n.current;!g||d.current||(d.current=!0,i?g.scrollTop=0:g.scrollTop=g.scrollHeight,c(!0))},[n,i]),y.useLayoutEffect(()=>{const g=n.current;if(g){if(i&&!o){const v=wI(u.current,g.scrollHeight);v>0&&(g.scrollTop+=v)}o&&(i?g.scrollTo({top:0,behavior:"smooth"}):g.scrollTo({top:g.scrollHeight,behavior:"smooth"})),u.current=g.scrollHeight}},[s,o,i,n]);const h=y.useCallback(()=>{const g=n.current;if(!g)return;const v=i?0:g.scrollHeight;g.scrollTo({top:v,behavior:"smooth"}),c(!0)},[n,i]);return{isAtAnchor:o,scrollToAnchor:h}}const jI="_wrapper_p24zt_1",CI="_scrollContainer_p24zt_9",EI="_toolbar_p24zt_15",AI="_directionToggle_p24zt_22",DI="_scrollToAnchor_p24zt_60",RI="_scrollToAnchorBottom_p24zt_84",MI="_scrollToAnchorTop_p24zt_88",qa={wrapper:jI,scrollContainer:CI,toolbar:EI,directionToggle:AI,scrollToAnchor:DI,scrollToAnchorBottom:RI,scrollToAnchorTop:MI},Ox="grackle-stream-direction";function OI(){try{return localStorage.getItem(Ox)==="reversed"}catch{return!1}}function II({eventsDropped:n}){return n<=0?l.jsx(l.Fragment,{}):l.jsxs("div",{className:L.eventOverflowWarning,role:"alert",children:["⚠"," ",n.toLocaleString()," older event",n===1?"":"s"," were dropped — only the most recent 5,000 are shown. Full history is available in the session log."]})}function sm({events:n,eventsDropped:s,emptyState:i}){const o=y.useRef(null),[c,u]=y.useState(OI),d=eA(),m=y.useMemo(()=>c?[...n].reverse():n,[n,c]),{isAtAnchor:h,scrollToAnchor:g}=NI({scrollRef:o,contentLength:n.length,isReversed:c}),v=()=>{const S=!c;u(S);try{localStorage.setItem(Ox,S?"reversed":"default")}catch{}},b=d?0:.2,_=c?-8:8;return l.jsxs("div",{className:qa.wrapper,children:[l.jsx("div",{className:qa.toolbar,children:l.jsx("button",{className:qa.directionToggle,onClick:v,title:c?"Showing newest first":"Showing oldest first","aria-label":c?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:c?"↓":"↑"})}),l.jsxs("div",{ref:o,className:qa.scrollContainer,"data-testid":"event-stream-scroll",children:[n.length===0&&i,l.jsx(II,{eventsDropped:s}),l.jsx(rs,{initial:!1,children:m.map((S,T)=>{const N=c?n.length-1-T:T;return l.jsx(Rt.div,{initial:{opacity:0,y:_},animate:{opacity:1,y:0},transition:{duration:b,ease:"easeOut"},children:l.jsx(A3,{event:S,toolUseCtx:S.toolUseCtx})},`${S.sessionId}-${S.timestamp}-${N}`)})})]}),l.jsx(rs,{children:!h&&l.jsxs(Rt.button,{className:`${qa.scrollToAnchor} ${c?qa.scrollToAnchorTop:qa.scrollToAnchorBottom}`,onClick:g,initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.15},"aria-label":"Scroll to latest","data-testid":"scroll-to-anchor",children:[c?"↑":"↓"," New events"]})})]})}const BI="_bar_1xhb4_1",LI="_input_1xhb4_32",UI="_select_1xhb4_67",zI="_btnPrimary_1xhb4_103",PI="_btnGhost_1xhb4_173",VI="_badge_1xhb4_195",qI="_disconnectHint_1xhb4_205",bn={bar:BI,input:LI,select:UI,btnPrimary:zI,btnGhost:PI,badge:VI,disconnectHint:qI};function HI(n,s){if(!n)return!1;const i=s.find(o=>o.id===n);return i!==void 0&&(i.status==="disconnected"||i.status==="error")}function GI({environmentId:n,onReconnect:s}){return l.jsxs(l.Fragment,{children:[l.jsx("span",{className:bn.disconnectHint,"data-testid":"env-disconnect-hint",children:"Environment unavailable"}),l.jsx("button",{type:"button",onClick:()=>s(n),className:bn.btnGhost,"data-testid":"reconnect-btn",title:"Reconnect the environment to resume messaging",children:"Reconnect"})]})}function jr({mode:n,sessionId:s,environmentId:i,taskId:o,showPersonaSelect:c,personas:u,environments:d,onSendInput:m,onSpawn:h,onStartTask:g,onProvisionEnvironment:v}){const{showToast:b}=Bs(),[_,S]=y.useState(""),[T,N]=y.useState(""),j=HI(i,d),w=E=>{if(E.preventDefault(),!!_.trim())if(n==="send"){if(!s||j)return;m(s,_),S("")}else if(n==="spawn"){if(!i)return;h(i,_,T),b("Session started","success"),S(""),N("")}else{if(!o)return;g(o,void 0,i,_),S("")}};return n==="spawn"?l.jsxs("form",{onSubmit:w,className:bn.bar,children:[l.jsx("span",{className:bn.badge,children:"new chat"}),l.jsx("input",{type:"text",value:_,onChange:E=>S(E.target.value),placeholder:"Enter prompt...",autoFocus:!0,className:bn.input}),c&&l.jsxs("select",{value:T,onChange:E=>N(E.target.value),className:bn.select,children:[l.jsx("option",{value:"",children:"(Default)"}),u.map(E=>l.jsx("option",{value:E.id,children:E.name},E.id))]}),l.jsx("button",{type:"submit",disabled:!_.trim()||!i,className:bn.btnPrimary,children:"Go"})]}):n==="start"?l.jsxs("form",{onSubmit:w,className:bn.bar,children:[l.jsx("input",{type:"text",value:_,onChange:E=>S(E.target.value),placeholder:"Type a message...",autoFocus:!0,className:bn.input}),l.jsx("button",{type:"submit",disabled:!_.trim(),className:bn.btnPrimary,children:"Send"})]}):l.jsxs("form",{onSubmit:w,className:bn.bar,children:[j&&i&&l.jsx(GI,{environmentId:i,onReconnect:v}),l.jsx("input",{type:"text",value:_,onChange:E=>S(E.target.value),placeholder:"Type a message...",autoFocus:!j,disabled:j,className:bn.input}),l.jsx("span",{title:j?"Environment is unavailable — reconnect first":void 0,children:l.jsx("button",{type:"submit",disabled:!_.trim()||j,className:bn.btnPrimary,children:"Send"})})]})}function am(n){const s=[];for(const i of n){const o=s[s.length-1];i.eventType==="text"&&(o==null?void 0:o.eventType)==="text"?s[s.length-1]={...o,content:o.content+i.content}:s.push(i)}return s}function im(n){const s=new Map;for(const u of n)if(u.raw)try{s.set(u,JSON.parse(u.raw))}catch{}const i=new Map;for(const u of n){if(u.eventType!=="tool_use")continue;const d=s.get(u);if(!(!d||typeof d.id!="string"))try{const m=JSON.parse(u.content);i.set(d.id,{tool:m.tool,args:m.args})}catch{}}const o=new Set;return n.map(u=>{if(u.eventType!=="tool_result")return u;const d=s.get(u);if(!d||typeof d.tool_use_id!="string")return u;const m=i.get(d.tool_use_id);if(!m)return u;o.add(d.tool_use_id);let h;const g=u.content.trim();if(g.startsWith("{"))try{const v=JSON.parse(g);typeof v.detailedContent=="string"&&(h=v.detailedContent)}catch{}return{...u,toolUseCtx:{...m,detailedResult:h}}}).filter(u=>{if(u.eventType!=="tool_use")return!0;const d=s.get(u);return d&&typeof d.id=="string"?!o.has(d.id):!0})}const $I="_panelContainer_19poq_1",FI="_chatHeader_19poq_8",ZI="_chatHeaderInfo_19poq_37",KI="_emptyState_19poq_43",YI="_emptyTitle_19poq_55",JI="_emptyDescription_19poq_61",WI="_emptyHint_19poq_67",Za={panelContainer:$I,chatHeader:FI,chatHeaderInfo:ZI,emptyState:KI,emptyTitle:YI,emptyDescription:JI,emptyHint:WI};function XI({hasLocalEnvironment:n}){return l.jsxs("div",{className:Za.emptyState,"data-testid":"chat-empty-state",children:[l.jsx("div",{className:Za.emptyTitle,children:"Welcome to Grackle"}),l.jsx("div",{className:Za.emptyDescription,children:n?"Type a message below to start chatting with the System agent. It can help you plan work, create tasks, and coordinate agents.":"Add a local environment in Settings to start chatting."}),!n&&l.jsx("div",{className:Za.emptyHint,children:"Go to Settings → Environments to add one."})]})}function QI(){const{tasks:n,sessions:s,events:i,eventsDropped:o,environments:c,loadTaskSessions:u,loadSessionEvents:d,kill:m,stopGraceful:h,taskSessions:g,sendInput:v,spawn:b,startTask:_,personas:S,provisionEnvironment:T}=pt(),N=y.useRef(void 0),[j,w]=y.useState(),E=n.find(V=>V.id===nr),A=E!=null&&E.latestSessionId?s.find(V=>V.id===E.latestSessionId)??(g[nr]??[]).find(V=>V.id===E.latestSessionId):void 0;y.useEffect(()=>{u(nr)},[u]),y.useEffect(()=>{E!=null&&E.latestSessionId&&u(nr)},[E==null?void 0:E.latestSessionId,u]),y.useEffect(()=>{A&&A.id!==N.current&&(N.current=A.id,d(A.id))},[A==null?void 0:A.id,d]);const O=y.useMemo(()=>{if(!A)return[];const V=i.filter(Z=>Z.sessionId===A.id);return im(am(V))},[i,A==null?void 0:A.id]),C=c.find(V=>V.adapterType==="local"&&V.status==="connected"),M=A!==void 0&&A.status!=="stopped"&&A.status!=="suspended",G=(A==null?void 0:A.status)==="idle";y.useEffect(()=>{j&&A&&G&&(v(A.id,j),w(void 0))},[j,G,A==null?void 0:A.id,v]);const U=y.useCallback((V,Z,ee,ie)=>{ie&&w(ie),_(V,Z,ee)},[_]);return l.jsxs("div",{className:Za.panelContainer,"data-testid":"chat-page",children:[M&&l.jsxs("div",{className:Za.chatHeader,children:[l.jsxs("span",{className:Za.chatHeaderInfo,children:["Session: ",A.id.slice(0,8)," | ",A.runtime," | ",A.status]}),l.jsx(Cx,{label:"Stop",onClick:()=>h(A.id),variant:"danger",size:"sm","data-testid":"stop-split-button",options:[{label:"Stop",description:"Graceful shutdown",onClick:()=>h(A.id)},{label:"Kill",description:"Force kill",onClick:()=>m(A.id)}]})]}),l.jsx(sm,{events:O,eventsDropped:o,emptyState:l.jsx(XI,{hasLocalEnvironment:!!C})}),C&&M&&l.jsx(jr,{mode:"send",sessionId:A.id,environmentId:A.environmentId,personas:S,environments:c,onSendInput:v,onSpawn:b,onStartTask:_,onProvisionEnvironment:T}),C&&!M&&l.jsx(jr,{mode:"start",taskId:nr,environmentId:C.id,personas:S,environments:c,onSendInput:v,onSpawn:b,onStartTask:U,onProvisionEnvironment:T})]})}function e5(n,s){const i=[];let o=n;const c=new Set;for(;o&&s.has(o)&&!c.has(o);){c.add(o);const u=s.get(o);i.unshift(u),o=u.parentTaskId||void 0}return i}const Wa={label:"Home",url:Ya};function t5(n){return n?[Wa,{label:"Settings",url:Ji},{label:n,url:void 0}]:[Wa,{label:"Settings",url:void 0}]}const Ix={label:"Environments",url:Xi};function n5(){return[Wa,{label:"Environments",url:void 0}]}function s5(){return[Wa,{label:"New Chat",url:void 0}]}function a5(n){return[Wa,{label:`Session ${n.slice(0,8)}`,url:void 0}]}function i5(n,s,i,o){const c=i.find(d=>d.id===n),u=o.find(d=>d.id===s);return[Wa,Ix,{label:(u==null?void 0:u.displayName)??"Environment",url:Qi(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function o5(n,s,i,o,c){const u=e5(n,c),d=c.get(n),m=d==null?void 0:d.workspaceId,h=m?i.find(S=>S.id===m):void 0,g=s??(h==null?void 0:h.environmentId),v=g?o.find(S=>S.id===g):void 0,b=[Wa];v&&g&&(b.push(Ix),b.push({label:v.displayName,url:Qi(g)})),h&&g&&b.push({label:h.name,url:Wi(h.id,g)});for(let S=0;S<u.length-1;S++)b.push({label:u[S].title,url:os(u[S].id,void 0,m,g)});const _=u[u.length-1];return b.push({label:(_==null?void 0:_.title)??n,url:void 0}),b}function r5(){const n=s5(),[s]=bp(),i=s.get("env")??"",{sendInput:o,spawn:c,startTask:u,personas:d,environments:m,provisionEnvironment:h}=pt();return l.jsxs("div",{className:L.panelContainer,children:[l.jsx(ba,{segments:n}),l.jsx("div",{className:L.emptyState,children:"Enter a prompt below to start a new session"}),l.jsx(jr,{mode:"spawn",environmentId:i,showPersonaSelect:!0,personas:d,environments:m,onSendInput:o,onSpawn:c,onStartTask:u,onProvisionEnvironment:h})]})}function l5({sessionId:n,session:s,isActive:i,onStop:o,onKill:c}){return l.jsxs("div",{className:L.header,children:[l.jsxs("span",{children:["Session: ",n.slice(0,8),s&&` | ${s.runtime} | ${s.endReason||s.status}`,s!=null&&s.inputTokens||s!=null&&s.outputTokens||s!=null&&s.costUsd?` | ${Ex((s.inputTokens??0)+(s.outputTokens??0))} tokens · ${so(s.costUsd??0)}`:""]}),l.jsxs("span",{className:L.headerInfo,children:[s&&l.jsx("span",{children:s.prompt.length>60?s.prompt.slice(0,60)+"...":s.prompt}),i&&l.jsx(Cx,{label:"Stop",onClick:o,variant:"danger",size:"sm","data-testid":"stop-split-button",options:[{label:"Stop",description:"Graceful shutdown",onClick:o},{label:"Kill",description:"Force kill",onClick:c}]})]})]})}function c5({session:n}){const s=n&&(n.status==="stopped"||n.status==="suspended"),i=s?`Session ${n.endReason||n.status} with no events recorded.`:"Waiting for events...";return l.jsx("div",{className:s?L.errorMessage:L.waitingMessage,children:i})}function u5(){const{sessionId:n}=va(),{events:s,eventsDropped:i,sessions:o,kill:c,stopGraceful:u,loadSessionEvents:d,sendInput:m,spawn:h,startTask:g,personas:v,environments:b,provisionEnvironment:_}=pt(),S=y.useRef(void 0),T=a5(n),N=o.find(E=>E.id===n)??void 0,j=y.useMemo(()=>{const E=n?s.filter(A=>A.sessionId===n):[];return im(am(E))},[s,n]);if(y.useEffect(()=>{n&&n!==S.current&&(S.current=n,d(n))},[n,d]),!n)return l.jsx("div",{className:L.emptyState,children:"No session selected"});const w=(N==null?void 0:N.status)==="running"||(N==null?void 0:N.status)==="idle";return l.jsxs("div",{className:L.panelContainer,children:[l.jsx(ba,{segments:T}),l.jsx(l5,{sessionId:n,session:N,isActive:w,onStop:()=>u(n),onKill:()=>c(n)}),l.jsx(sm,{events:j,eventsDropped:i,emptyState:l.jsx(c5,{session:N})}),w&&l.jsx(jr,{mode:"send",sessionId:n,environmentId:N.environmentId,personas:v,environments:b,onSendInput:m,onSpawn:h,onStartTask:g,onProvisionEnvironment:_})]})}function d5(n){if(!n)return!1;const s=n.tagName;return!!(s==="INPUT"||s==="TEXTAREA"||s==="SELECT"||n.isContentEditable)}function Ms(n,s){const i=y.useRef(s);i.current=s;const{key:o,ctrl:c=!1,shift:u=!1,suppressInInputs:d=!0,enabled:m=!0}=n;y.useEffect(()=>{if(!m)return;const h=g=>{if(d&&d5(document.activeElement??void 0))return;const v=g.ctrlKey||g.metaKey;c===v&&(u&&!g.shiftKey||g.key===o&&i.current())};return document.addEventListener("keydown",h),()=>{document.removeEventListener("keydown",h)}},[o,c,u,d,m])}const Ky=220,Yy=70,f5=40,p5=60,m5="hierarchy",h5="dependency";function g5(n){return y.useMemo(()=>{if(n.length===0)return{nodes:[],edges:[]};const s=new Qv.graphlib.Graph({multigraph:!0});s.setDefaultEdgeLabel(()=>({})),s.setGraph({rankdir:"TB",nodesep:f5,ranksep:p5});const i=new Map(n.map(d=>[d.id,d])),o=new Map;for(const d of n)if(d.parentTaskId&&i.has(d.parentTaskId)){const m=o.get(d.parentTaskId)||[];m.push(d),o.set(d.parentTaskId,m)}for(const d of n)s.setNode(d.id,{width:Ky,height:Yy});const c=[];for(const d of n){if(d.parentTaskId&&i.has(d.parentTaskId)){const m=`hierarchy-${d.parentTaskId}-${d.id}`;s.setEdge(d.parentTaskId,d.id,{},m),c.push({id:m,source:d.parentTaskId,target:d.id,type:"smoothstep",data:{edgeType:m5},style:{stroke:"var(--accent-green)",strokeWidth:2},animated:!1})}for(const m of d.dependsOn)if(i.has(m)){const h=`dependency-${m}-${d.id}`;s.setEdge(m,d.id,{},h),c.push({id:h,source:m,target:d.id,type:"smoothstep",data:{edgeType:h5},style:{stroke:"var(--text-tertiary)",strokeWidth:1.5,strokeDasharray:"6 3"},animated:!1})}}return Qv.layout(s),{nodes:n.map(d=>{const m=s.node(d.id),h=o.get(d.id)||[];return{id:d.id,type:"task",position:{x:m.x-Ky/2,y:m.y-Yy/2},data:{task:d,childCount:h.length,doneChildCount:h.filter(g=>g.status==="complete").length,hasDependencies:d.dependsOn.length>0}}}),edges:c}},[n])}const v5="_dagContainer_js4w6_1",y5="_taskNode_js4w6_26",b5="_taskNodeBorder_js4w6_54",_5="_taskNodeContent_js4w6_60",x5="_taskNodeHeader_js4w6_70",S5="_taskNodeIcon_js4w6_77",T5="_taskNodeTitle_js4w6_82",k5="_taskNodeBadges_js4w6_90",w5="_childBadge_js4w6_95",N5="_depBadge_js4w6_107",j5="_handle_js4w6_119",C5="_emptyCta_js4w6_126",E5="_ctaDescription_js4w6_137",A5="_ctaButton_js4w6_144",tn={dagContainer:v5,taskNode:y5,taskNodeBorder:b5,taskNodeContent:_5,taskNodeHeader:x5,taskNodeIcon:S5,taskNodeTitle:T5,taskNodeBadges:k5,childBadge:w5,depBadge:N5,handle:j5,emptyCta:C5,ctaDescription:E5,ctaButton:A5};function D5({data:n}){const{task:s,childCount:i,doneChildCount:o,hasDependencies:c}=n,u=ga(s.status);return l.jsxs("div",{className:tn.taskNode,"data-task-id":s.id,"data-task-title":s.title,children:[l.jsx(e0,{type:"target",position:t0.Top,className:tn.handle}),l.jsx("div",{className:tn.taskNodeBorder,style:{backgroundColor:u.color}}),l.jsxs("div",{className:tn.taskNodeContent,children:[l.jsxs("div",{className:tn.taskNodeHeader,children:[l.jsx("span",{className:tn.taskNodeIcon,style:{color:u.color},children:u.icon}),l.jsx("span",{className:tn.taskNodeTitle,children:s.title})]}),l.jsxs("div",{className:tn.taskNodeBadges,children:[i>0&&l.jsxs("span",{className:tn.childBadge,children:[o,"/",i]}),c&&l.jsx("span",{className:tn.depBadge,children:"dep"})]})]}),l.jsx(e0,{type:"source",position:t0.Bottom,className:tn.handle})]})}const R5=iA,M5={task:D5};function O5({workspaceId:n,environmentId:s,tasks:i}){const o=St(),{resolvedThemeId:c}=qb(),u=y.useMemo(()=>i.filter(b=>b.workspaceId===n),[i,n]),{nodes:d,edges:m}=g5(u),h=y.useMemo(()=>{const b=getComputedStyle(document.documentElement),_={};for(const[S,T]of Object.entries(R5))_[S]=b.getPropertyValue(T).trim()||"#6b7a8d";return _},[c]),g=y.useCallback((b,_)=>{o(os(_.id,void 0,n,s))},[o,n,s]),v=y.useCallback(b=>{const _=b.data;return h[_.task.status]||h.pending},[h]);return u.length===0?l.jsxs("div",{className:tn.emptyCta,children:[l.jsx("button",{className:tn.ctaButton,onClick:()=>o(ei(n,void 0,s)),children:"Create Task"}),l.jsx("div",{className:tn.ctaDescription,children:"Create tasks to see the dependency graph"})]}):l.jsx("div",{className:tn.dagContainer,children:l.jsxs(nT,{nodes:d,edges:m,nodeTypes:M5,onNodeClick:g,fitView:!0,fitViewOptions:{padding:.2},minZoom:.3,maxZoom:2,children:[l.jsx(sT,{variant:aT.Dots,gap:24,size:1,color:"var(--text-disabled)"}),l.jsx(iT,{showInteractive:!1}),l.jsx(oT,{nodeColor:v,maskColor:"var(--bg-overlay)",style:{background:"var(--bg-inset)"}})]})})}function I5({tasks:n,taskStatusById:s,sessionStatusByTaskId:i}){const o=new Map;for(const u of n)if(u.parentTaskId){const d=o.get(u.parentTaskId);d?d.push(u):o.set(u.parentTaskId,[u])}const c=new Map(Py.map(u=>[u,[]]));for(const u of n){const d=nm(u.status),m=u.dependsOn.length>0&&u.dependsOn.some(T=>s.get(T)!=="complete"),h=o.get(u.id)??[],g=h.length,v=h.filter(T=>T.status==="complete").length;let b;if(d==="paused"&&i){const T=i.get(u.id);T==="idle"?b="Needs input":T==="completed"&&(b="Ready to complete")}const _={task:u,isBlocked:m,childCount:g,doneChildCount:v,pausedSubBadge:b},S=c.get(d);S?S.push(_):c.get("not_started").push(_)}for(const u of c.values())u.sort((d,m)=>d.task.sortOrder-m.task.sortOrder);return Py.map(u=>{const d=ga(u);return{status:u,label:d.label,style:d,tasks:c.get(u)??[]}})}const B5="_boardContainer_1c4y1_1",L5="_column_1c4y1_17",U5="_columnHeader_1c4y1_34",z5="_columnIcon_1c4y1_47",P5="_columnLabel_1c4y1_52",V5="_columnCount_1c4y1_57",q5="_cardList_1c4y1_67",H5="_emptyPlaceholder_1c4y1_76",G5="_card_1c4y1_67",$5="_cardHeader_1c4y1_107",F5="_cardStatusIcon_1c4y1_113",Z5="_cardTitle_1c4y1_119",K5="_cardBadges_1c4y1_127",Y5="_badge_1c4y1_134",J5="_blockedBadge_1c4y1_146",W5="_childBadge_1c4y1_151",X5="_depBadge_1c4y1_155",Q5="_parentBadge_1c4y1_159",e4="_pausedSubBadge_1c4y1_166",t4="_personaBadge_1c4y1_170",n4="_envBadge_1c4y1_174",s4="_emptyCta_1c4y1_178",a4="_ctaButton_1c4y1_188",i4="_ctaDescription_1c4y1_204",Qe={boardContainer:B5,column:L5,columnHeader:U5,columnIcon:z5,columnLabel:P5,columnCount:V5,cardList:q5,emptyPlaceholder:H5,card:G5,cardHeader:$5,cardStatusIcon:F5,cardTitle:Z5,cardBadges:K5,badge:Y5,blockedBadge:J5,childBadge:W5,depBadge:X5,parentBadge:Q5,pausedSubBadge:e4,personaBadge:t4,envBadge:n4,emptyCta:s4,ctaButton:a4,ctaDescription:i4};function o4({workspaceId:n,environmentId:s,tasks:i,sessions:o,personas:c,environments:u}){const d=St(),m=y.useMemo(()=>i.filter(_=>_.workspaceId===n),[i,n]),h=y.useMemo(()=>new Map(i.map(_=>[_.id,_.status])),[i]),g=y.useMemo(()=>new Map(m.map(_=>[_.id,_])),[m]),v=y.useMemo(()=>{const _=new Map(o.map(E=>[E.id,E])),S=new Map(c.map(E=>[E.id,E])),T=new Map(u.map(E=>[E.id,E])),N=new Map,j=new Map,w=new Map;for(const E of m)if(E.latestSessionId){const A=_.get(E.latestSessionId);if(A){if(N.set(E.id,A.endReason||A.status),A.personaId){const O=S.get(A.personaId);O&&j.set(E.id,O.name)}if(A.environmentId){const O=T.get(A.environmentId);O&&w.set(E.id,O.displayName)}}}return{sessionStatusByTaskId:N,personaNameByTaskId:j,environmentNameByTaskId:w}},[m,o,c,u]),b=y.useMemo(()=>I5({tasks:m,taskStatusById:h,sessionStatusByTaskId:v.sessionStatusByTaskId}),[m,h,v]);return m.length===0?l.jsxs("div",{className:Qe.emptyCta,"data-testid":"board-empty-cta",children:[l.jsx("button",{className:Qe.ctaButton,onClick:()=>d(ei(n,void 0,s)),children:"Create Task"}),l.jsx("div",{className:Qe.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):l.jsx("div",{className:Qe.boardContainer,"data-testid":"board-container",children:b.map(_=>l.jsxs("section",{className:Qe.column,"data-testid":`board-column-${_.status}`,"aria-label":`${_.label}, ${_.tasks.length} ${_.tasks.length===1?"task":"tasks"}`,children:[l.jsxs("div",{className:Qe.columnHeader,children:[l.jsx("span",{className:Qe.columnIcon,style:{color:_.style.color},children:_.style.icon}),l.jsx("span",{className:Qe.columnLabel,children:_.label}),l.jsx("span",{className:Qe.columnCount,"data-testid":`board-count-${_.status}`,children:_.tasks.length})]}),l.jsx("div",{className:Qe.cardList,children:_.tasks.length===0?l.jsx("div",{className:Qe.emptyPlaceholder,children:"No tasks"}):l.jsx(rs,{mode:"popLayout",children:_.tasks.map(S=>l.jsx(Rt.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:l.jsx(r4,{boardTask:S,tasksById:g,personaName:v.personaNameByTaskId.get(S.task.id),envName:v.environmentNameByTaskId.get(S.task.id),onClick:()=>d(os(S.task.id,void 0,n,s))})},S.task.id))})})]},_.status))})}function r4({boardTask:n,tasksById:s,personaName:i,envName:o,onClick:c}){const{task:u,isBlocked:d,childCount:m,doneChildCount:h,pausedSubBadge:g}=n,v=ga(u.status),b=u.parentTaskId?s.get(u.parentTaskId):void 0;return l.jsxs("div",{className:Qe.card,tabIndex:0,role:"button","data-testid":`board-card-${u.id}`,onClick:c,onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),c())},children:[l.jsxs("div",{className:Qe.cardHeader,children:[l.jsx("span",{className:Qe.cardStatusIcon,style:{color:v.color},children:v.icon}),l.jsx("span",{className:Qe.cardTitle,children:u.title})]}),l.jsxs("div",{className:Qe.cardBadges,children:[b&&l.jsx("span",{className:`${Qe.badge} ${Qe.parentBadge}`,title:b.title,children:b.title}),m>0&&l.jsxs("span",{className:`${Qe.badge} ${Qe.childBadge}`,children:[h,"/",m]}),d&&l.jsx("span",{className:`${Qe.badge} ${Qe.blockedBadge}`,children:"blocked"}),u.dependsOn.length>0&&!d&&l.jsx("span",{className:`${Qe.badge} ${Qe.depBadge}`,children:"dep"}),g&&l.jsx("span",{className:`${Qe.badge} ${Qe.pausedSubBadge}`,children:g}),i&&l.jsx("span",{className:`${Qe.badge} ${Qe.personaBadge}`,children:i}),o&&l.jsx("span",{className:`${Qe.badge} ${Qe.envBadge}`,children:o})]})]})}function om(n){const{value:s,onSave:i,validate:o,fieldId:c,activeFieldId:u,onActivate:d,enterToSave:m=!0,trimOnSave:h=!0}=n,[g,v]=y.useState(""),[b,_]=y.useState(""),S=y.useRef(!1),T=u===c,N=y.useCallback(G=>{v(G),_("")},[]),j=y.useCallback(()=>{_("")},[]),w=y.useCallback(()=>{S.current=!1,d==null||d(null),v(""),_("")},[d]),E=y.useCallback(()=>{const G=h?g.trim():g;if(o){const V=o(g);if(V){_(V);return}}const U=h?s.trim():s;if(G===U){w();return}i(G),w()},[g,s,h,o,i,w]),A=y.useCallback(()=>{S.current=!0,d==null||d(c),v(s),_("")},[c,s,d]),O=y.useCallback(G=>{if(S.current){S.current=!1;return}G.relatedTarget instanceof HTMLElement&&G.relatedTarget.dataset.editAction===c||E()},[c,E]),C=y.useCallback(G=>{G.key==="Escape"?w():G.key==="Enter"&&m&&E()},[w,m,E]),M=(()=>{if(!T)return!1;const G=h?s.trim():s;return(h?g.trim():g)!==G})();return y.useEffect(()=>{!T&&(g!==""||b!=="")&&(v(""),_(""))},[T,g,b]),{isEditing:T,draft:g,error:b,isDirty:M,startEdit:A,cancelEdit:w,save:E,setDraft:N,clearError:j,handleBlur:O,handleKeyDown:C,ignoreInitialBlurRef:S}}const l4="_editFieldWrapper_yuzty_1",c4="_editInput_yuzty_10",u4="_editTextarea_yuzty_42",d4="_editSelect_yuzty_78",f4="_editError_yuzty_111",p4="_editInputInvalid_yuzty_118",m4="_editHint_yuzty_123",h4="_unsavedDot_yuzty_132",g4="_metaValueClickable_yuzty_140",v4="_editButton_yuzty_159",y4="_metaPlaceholder_yuzty_175",b4="_worktreeToggle_yuzty_180",We={editFieldWrapper:l4,editInput:c4,editTextarea:u4,editSelect:d4,editError:f4,editInputInvalid:p4,editHint:m4,unsavedDot:h4,metaValueClickable:g4,editButton:v4,metaPlaceholder:y4,worktreeToggle:b4};function Zt(n){const{value:s,onSave:i,validate:o,mode:c="edit",fieldId:u="text",activeFieldId:d,onActivate:m,onChange:h,renderDisplay:g,placeholder:v,maxLength:b,ariaLabel:_,"data-testid":S}=n,T=y.useRef(null),N=om({value:s,onSave:i,validate:o,fieldId:u,activeFieldId:d,onActivate:m,enterToSave:!0,trimOnSave:!0});if(y.useEffect(()=>{if(N.isEditing){const w=window.setTimeout(()=>{var E;(E=T.current)==null||E.focus()},0);return()=>window.clearTimeout(w)}},[N.isEditing]),c==="create"){const w=A=>{h==null||h(A.target.value)},E=o==null?void 0:o(s);return l.jsxs("div",{className:We.editFieldWrapper,children:[l.jsx("input",{className:`${We.editInput} ${E?We.editInputInvalid:""}`,value:s,onChange:w,maxLength:b,placeholder:v,"aria-label":_,"data-testid":S?`${S}-input`:void 0}),E&&l.jsx("span",{className:We.editError,"data-testid":"edit-error",children:E})]})}if(N.isEditing)return l.jsxs("div",{className:We.editFieldWrapper,children:[l.jsx("input",{ref:T,className:`${We.editInput} ${N.error?We.editInputInvalid:""}`,value:N.draft,onChange:w=>N.setDraft(w.target.value),onBlur:N.handleBlur,onKeyDown:N.handleKeyDown,maxLength:b,placeholder:v,"aria-label":_,"data-testid":S?`${S}-input`:void 0}),N.isDirty&&l.jsx("span",{className:We.unsavedDot,title:"Unsaved changes"}),N.error&&l.jsx("span",{className:We.editError,"data-testid":"edit-error",children:N.error}),l.jsx("span",{className:We.editHint,children:"Enter to save · Esc to cancel"})]});const j=g==null?void 0:g(s);return l.jsxs("span",{role:"button",tabIndex:0,className:We.metaValueClickable,onClick:()=>N.startEdit(),onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),N.startEdit())},title:"Click to edit","aria-label":_,"data-testid":S?`${S}-button`:void 0,children:[j!==void 0?j:s?l.jsx("span",{children:s}):l.jsx("span",{className:We.metaPlaceholder,children:v||"None"}),l.jsx("span",{className:We.editButton,"aria-hidden":"true",children:"✏️"})]})}function cp(n){const{value:s,onSave:i,validate:o,mode:c="edit",fieldId:u="textarea",activeFieldId:d,onActivate:m,onChange:h,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":_}=n,S=y.useRef(null),T=om({value:s,onSave:i,validate:o,fieldId:u,activeFieldId:d,onActivate:m,enterToSave:!1,trimOnSave:!1});if(y.useEffect(()=>{if(T.isEditing){const j=window.setTimeout(()=>{var w;(w=S.current)==null||w.focus()},0);return()=>window.clearTimeout(j)}},[T.isEditing]),c==="create"){const j=E=>{h==null||h(E.target.value)},w=o==null?void 0:o(s);return l.jsxs("div",{className:We.editFieldWrapper,children:[l.jsx("textarea",{className:`${We.editTextarea} ${w?We.editInputInvalid:""}`,value:s,onChange:j,placeholder:v,"aria-label":b,"data-testid":_?`${_}-input`:void 0}),w&&l.jsx("span",{className:We.editError,"data-testid":"edit-error",children:w})]})}if(T.isEditing)return l.jsxs("div",{className:We.editFieldWrapper,children:[l.jsx("textarea",{ref:S,className:`${We.editTextarea} ${T.error?We.editInputInvalid:""}`,value:T.draft,onChange:j=>T.setDraft(j.target.value),onBlur:T.handleBlur,onKeyDown:T.handleKeyDown,title:b,"aria-label":b,"data-testid":_?`${_}-input`:void 0}),T.isDirty&&l.jsx("span",{className:We.unsavedDot,title:"Unsaved changes"}),T.error&&l.jsx("span",{className:We.editError,"data-testid":"edit-error",children:T.error}),l.jsx("span",{className:We.editHint,children:"Tab to save · Esc to cancel"})]});const N=g==null?void 0:g(s);return l.jsxs("span",{role:"button",tabIndex:0,className:We.metaValueClickable,onClick:()=>T.startEdit(),onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),T.startEdit())},title:"Click to edit","aria-label":b,"data-testid":_?`${_}-button`:void 0,children:[N!==void 0?N:s?l.jsx("span",{children:s}):l.jsx("span",{className:We.metaPlaceholder,children:v||"None"}),l.jsx("span",{className:We.editButton,"aria-hidden":"true",children:"✏️"})]})}function Cc(n){var A;const{value:s,onSave:i,mode:o="edit",options:c,fieldId:u="select",activeFieldId:d,onActivate:m,onChange:h,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":_}=n,S=y.useRef(null),T=om({value:s,onSave:i,fieldId:u,activeFieldId:d,onActivate:m,enterToSave:!1,trimOnSave:!1});y.useEffect(()=>{if(T.isEditing){const O=window.setTimeout(()=>{var C;(C=S.current)==null||C.focus()},0);return()=>window.clearTimeout(O)}},[T.isEditing]);const N=y.useCallback(O=>{const C=O.target.value;T.ignoreInitialBlurRef.current=!1,C!==s&&i(C),T.cancelEdit()},[s,i,T]),j=y.useCallback(O=>{if(T.ignoreInitialBlurRef.current){T.ignoreInitialBlurRef.current=!1;return}O.relatedTarget instanceof HTMLElement&&O.relatedTarget.dataset.editAction===u||T.cancelEdit()},[u,T]);if(o==="create")return l.jsx("select",{className:We.editSelect,value:s,onChange:O=>h==null?void 0:h(O.target.value),"aria-label":b,"data-testid":_?`${_}-select`:void 0,children:c.map(O=>l.jsx("option",{value:O.value,children:O.label},O.value))});if(T.isEditing)return l.jsx("select",{ref:S,className:We.editSelect,value:T.draft,onChange:N,onBlur:j,title:b,"aria-label":b,"data-testid":_?`${_}-select`:void 0,children:c.map(O=>l.jsx("option",{value:O.value,children:O.label},O.value))});const w=g==null?void 0:g(s),E=(A=c.find(O=>O.value===s))==null?void 0:A.label;return l.jsxs("button",{type:"button",className:We.metaValueClickable,onClick:()=>T.startEdit(),title:"Click to change","aria-label":b,"data-testid":_?`${_}-button`:void 0,children:[w!==void 0?w:E?l.jsx("span",{children:E}):l.jsx("span",{className:We.metaPlaceholder,children:v||"None"}),l.jsx("span",{className:We.editButton,"aria-hidden":"true",children:"✏️"})]})}function _4(n){const{checked:s,onChange:i,label:o,ariaLabel:c,"data-testid":u}=n;return l.jsxs("label",{className:We.worktreeToggle,"data-testid":u,children:[l.jsx("input",{type:"checkbox",checked:s,onChange:d=>i(d.target.checked),"aria-label":c}),l.jsx("span",{children:o})]})}const x4="_envRow_1e1r5_1",S4="_envDot_1e1r5_7",T4="_envDotGreen_1e1r5_14",k4="_envDotYellow_1e1r5_18",w4="_envDotRed_1e1r5_22",N4="_envDotGray_1e1r5_26",Yi={envRow:x4,envDot:S4,envDotGreen:T4,envDotYellow:k4,envDotRed:w4,envDotGray:N4};function j4(n){const s=n.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?Yi.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?Yi.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?Yi.envDotRed:Yi.envDotGray}function C4(n){const{value:s,onSave:i,environments:o,allowNone:c=!1,fieldId:u="environment",activeFieldId:d,onActivate:m,placeholder:h="No environment",ariaLabel:g="Environment","data-testid":v}=n,b=o.find(T=>T.id===s),_=[...c?[{value:"",label:"None"}]:[],...o.map(T=>({value:T.id,label:T.displayName}))],S=()=>{if(b)return l.jsxs("span",{className:Yi.envRow,children:[l.jsx("span",{className:`${Yi.envDot} ${j4(b.status)}`}),b.displayName]})};return l.jsx(Cc,{value:s,onSave:i,options:_,fieldId:u,activeFieldId:d,onActivate:m,renderDisplay:S,placeholder:h,ariaLabel:g,"data-testid":v})}function Jy(n){if(!n)return"";const s=new Date(n);if(isNaN(s.getTime()))return"";const o=Date.now()-s.getTime();if(o<0)return"just now";const c=Math.floor(o/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;const u=Math.floor(c/60);if(u<24)return`${u}h ago`;const d=Math.floor(u/24);return d<30?`${d}d ago`:s.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}const Rf=100;function E4(n){try{const s=new URL(n);return s.protocol!=="http:"&&s.protocol!=="https:"?void 0:s.toString()}catch{return}}function A4(){const{workspaceId:n,environmentId:s}=va(),i=St(),{tasks:o,environments:c,workspaces:u,personas:d,sessions:m,archiveWorkspace:h,updateWorkspace:g,usageCache:v,loadUsage:b}=pt(),[_,S]=y.useState("tasks"),[T,N]=y.useState(!1),[j,w]=y.useState(null),[E,A]=y.useState(!1),O=y.useRef(void 0),C=u.find(K=>K.id===n),M=s??(C==null?void 0:C.environmentId)??"",G=i5(n,M,u,c);Ms({key:"1"},()=>S("graph")),Ms({key:"2"},()=>S("board")),Ms({key:"3"},()=>S("tasks")),y.useEffect(()=>{const K=O.current;O.current=n,!(K===void 0||K===n)&&j!==null&&w(null)},[n,j]);const U=m.reduce((K,re)=>K+(re.costUsd??0),0);y.useEffect(()=>{n&&b("workspace",n)},[n,b,U]);const V=n?v[`workspace:${n}`]:void 0,Z=o.filter(K=>K.workspaceId===n),ee=Z.filter(K=>K.status==="complete").length,ie=Z.length,be=ie>0?Math.round(ee/ie*100):0;return l.jsxs("div",{className:L.panelContainer,children:[l.jsx(ba,{segments:G}),l.jsxs("div",{className:L.workspaceHeader,children:[l.jsx("span",{className:L.workspaceName,"data-testid":"workspace-name",children:l.jsx(Zt,{value:(C==null?void 0:C.name)||"",onSave:K=>{C&&g(C.id,{name:K})},validate:K=>{const re=K.trim();if(!re)return"Name is required";if(re.length>Rf)return`Max ${Rf} characters`},maxLength:Rf,fieldId:"name",activeFieldId:j,onActivate:w,ariaLabel:"Workspace name",renderDisplay:K=>K||n||void 0,"data-testid":"edit-name"})}),l.jsx("button",{className:L.archiveButton,onClick:()=>N(!0),title:"Archive workspace","data-testid":"archive-workspace-button",children:"Archive"})]}),l.jsxs("button",{className:L.metaToggle,onClick:()=>A(!E),"aria-expanded":!E,"aria-controls":"workspace-meta-panel","data-testid":"meta-toggle",children:[l.jsx("span",{className:`${L.metaToggleArrow} ${E?"":L.metaToggleArrowOpen}`,children:"▶"}),"Details"]}),!E&&l.jsxs("div",{className:L.workspaceMeta,"data-testid":"workspace-meta",id:"workspace-meta-panel",children:[l.jsxs("div",{className:L.metaRow,children:[l.jsx("span",{className:L.metaLabel,children:"Description"}),l.jsx("div",{className:L.metaValue,children:l.jsx(cp,{value:(C==null?void 0:C.description)||"",onSave:K=>{C&&g(C.id,{description:K})},fieldId:"description",activeFieldId:j,onActivate:w,renderDisplay:K=>K?l.jsx("span",{className:L.overviewMarkdown,children:l.jsx(up,{remarkPlugins:[dp],children:K})}):void 0,placeholder:"No description",ariaLabel:"Workspace description","data-testid":"edit-description"})})]}),l.jsxs("div",{className:L.metaRow,children:[l.jsx("span",{className:L.metaLabel,children:"Repository"}),l.jsx("div",{className:L.metaValue,children:l.jsx(Zt,{value:(C==null?void 0:C.repoUrl)||"",onSave:K=>{C&&g(C.id,{repoUrl:K})},validate:K=>{const re=K.trim();if(re&&!/^https?:\/\/.+/.test(re))return"Must be a valid http(s) URL"},fieldId:"repoUrl",activeFieldId:j,onActivate:w,renderDisplay:K=>{const re=E4(K);return re?l.jsx("a",{className:L.repoLink,href:re,target:"_blank",rel:"noopener noreferrer",onClick:I=>I.stopPropagation(),children:K}):K?l.jsx("span",{children:K}):void 0},placeholder:"No repository",ariaLabel:"Workspace repository URL","data-testid":"edit-repo"})})]}),l.jsxs("div",{className:L.metaRow,children:[l.jsx("span",{className:L.metaLabel,children:"Environment"}),l.jsx("div",{className:L.metaValue,children:l.jsx(C4,{value:(C==null?void 0:C.environmentId)||"",onSave:K=>{C&&K&&g(C.id,{environmentId:K})},environments:c,fieldId:"environmentId",activeFieldId:j,onActivate:w,placeholder:"Select environment",ariaLabel:"Workspace environment","data-testid":"edit-env"})})]}),l.jsxs("div",{className:L.metaRow,children:[l.jsx("span",{className:L.metaLabel,children:"Persona"}),l.jsx("div",{className:L.metaValue,children:l.jsx(Cc,{value:(C==null?void 0:C.defaultPersonaId)||"",onSave:K=>{C&&g(C.id,{defaultPersonaId:K})},options:[{value:"",label:"(Inherit)"},...d.map(K=>({value:K.id,label:K.name}))],fieldId:"defaultPersonaId",activeFieldId:j,onActivate:w,renderDisplay:K=>{const re=d.find(I=>I.id===K);if(re)return l.jsx("span",{children:re.name})},placeholder:(C==null?void 0:C.defaultPersonaId)||"(Inherit)",ariaLabel:"Workspace default persona","data-testid":"edit-persona"})})]}),l.jsxs("div",{className:L.metaRow,children:[l.jsx("span",{className:L.metaLabel,children:"Worktrees"}),l.jsx("div",{className:L.metaValue,children:l.jsx(_4,{checked:(C==null?void 0:C.useWorktrees)??!0,onChange:K=>{C&&g(C.id,{useWorktrees:K})},label:"Enable worktree isolation","data-testid":"worktree-toggle"})})]}),l.jsxs("div",{className:L.metaRow,children:[l.jsx("span",{className:L.metaLabel,children:"Working Dir"}),l.jsx("div",{className:L.metaValue,children:l.jsx(Zt,{value:(C==null?void 0:C.workingDirectory)||"",onSave:K=>{C&&g(C.id,{workingDirectory:K})},fieldId:"workingDirectory",activeFieldId:j,onActivate:w,placeholder:"Default (server default)",ariaLabel:"Working directory","data-testid":"edit-working-directory"})})]}),C&&l.jsxs("div",{className:L.metaTimestamps,children:[l.jsxs("span",{className:L.metaTimestamp,children:["Created ",Jy(C.createdAt)]}),C.updatedAt&&C.updatedAt!==C.createdAt&&l.jsxs("span",{className:L.metaTimestamp,children:["· Updated ",Jy(C.updatedAt)]})]})]}),ie>0&&l.jsxs("div",{className:L.progressBarContainer,"data-testid":"progress-bar",children:[l.jsx("div",{className:L.progressBar,children:l.jsx("div",{className:L.progressFill,style:{width:`${be}%`}})}),l.jsxs("span",{className:L.progressLabel,children:[ee,"/",ie]})]}),V&&V.costUsd>0&&l.jsx("div",{className:L.progressBarContainer,children:l.jsxs("span",{className:L.progressLabel,children:["Usage: ",so(V.costUsd)," (",V.sessionCount," session",V.sessionCount!==1?"s":"",")"]})}),l.jsxs("div",{className:L.tabBar,role:"tablist","aria-label":"Workspace view",children:[l.jsx("button",{role:"tab","aria-selected":_==="graph",className:`${L.tab} ${_==="graph"?L.active:""}`,onClick:()=>S("graph"),children:"Graph"}),l.jsx("button",{role:"tab","aria-selected":_==="board",className:`${L.tab} ${_==="board"?L.active:""}`,onClick:()=>S("board"),"data-testid":"board-tab",children:"Board"}),l.jsx("button",{role:"tab","aria-selected":_==="tasks",className:`${L.tab} ${_==="tasks"?L.active:""}`,onClick:()=>S("tasks"),children:"Tasks"})]}),_==="tasks"&&ie>0&&l.jsxs("div",{className:L.workspaceSummary,children:[l.jsx("span",{className:L.workspaceSummaryTitle,children:`${ee}/${ie} tasks complete`}),l.jsx("span",{className:L.workspaceSummarySubtitle,children:"Select a task or click + to create one"})]}),_==="tasks"&&ie===0&&l.jsxs("div",{className:L.emptyCta,children:[l.jsx("button",{className:L.ctaButton,onClick:()=>i(ei(n,void 0,M)),children:"Create Task"}),l.jsx("div",{className:L.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}),_==="board"&&l.jsx(o4,{workspaceId:n,environmentId:M,tasks:o,sessions:m,personas:d,environments:c}),_==="graph"&&l.jsx(O5,{workspaceId:n,environmentId:M,tasks:o}),l.jsx(Ja,{isOpen:T,title:"Archive Workspace?",description:"This will hide the workspace from the sidebar. Tasks will not be deleted.",confirmLabel:"Archive",onConfirm:()=>{C&&(h(C.id),i("/",{replace:!0})),N(!1)},onCancel:()=>N(!1)})]})}const D4="_formContent_ymnez_1",R4="_section_ymnez_13",M4="_label_ymnez_19",O4="_titleInput_ymnez_26",I4="_descriptionTextarea_ymnez_58",B4="_selectField_ymnez_94",L4="_checkboxRow_ymnez_128",U4="_checkboxLabel_ymnez_141",z4="_fieldError_ymnez_146",ut={formContent:D4,section:R4,label:M4,titleInput:O4,descriptionTextarea:I4,selectField:B4,checkboxRow:L4,checkboxLabel:U4,fieldError:z4};function P4(n,s){return{name:(n==null?void 0:n.name)??"",description:(n==null?void 0:n.description)??"",repoUrl:(n==null?void 0:n.repoUrl)??"",environmentId:(n==null?void 0:n.environmentId)??s??"",defaultPersonaId:(n==null?void 0:n.defaultPersonaId)??"",useWorktrees:(n==null?void 0:n.useWorktrees)??!0,workingDirectory:(n==null?void 0:n.workingDirectory)??""}}const V4=100;function q4({values:n,onChange:s,environments:i,personas:o,errors:c,disabled:u,autoFocusName:d}){const m=(h,g)=>{s({...n,[h]:g})};return l.jsxs("div",{className:ut.formContent,children:[l.jsxs("div",{className:ut.section,children:[l.jsx("label",{className:ut.label,htmlFor:"ws-name",children:"Name"}),l.jsx("input",{id:"ws-name",className:ut.titleInput,type:"text",value:n.name,onChange:h=>m("name",h.target.value),placeholder:"Workspace name",maxLength:V4,autoFocus:d,disabled:u,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&l.jsx("span",{className:ut.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),l.jsxs("div",{className:ut.section,children:[l.jsx("label",{className:ut.label,htmlFor:"ws-description",children:"Description"}),l.jsx("textarea",{id:"ws-description",className:ut.descriptionTextarea,value:n.description,onChange:h=>m("description",h.target.value),placeholder:"Optional description (Markdown supported)",disabled:u,"data-testid":"workspace-form-description"})]}),l.jsxs("div",{className:ut.section,children:[l.jsx("label",{className:ut.label,htmlFor:"ws-repo",children:"Repository URL"}),l.jsx("input",{id:"ws-repo",className:ut.titleInput,type:"text",value:n.repoUrl,onChange:h=>m("repoUrl",h.target.value),placeholder:"https://github.com/org/repo",disabled:u,"data-testid":"workspace-form-repo"}),(c==null?void 0:c.repoUrl)&&l.jsx("span",{className:ut.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),l.jsxs("div",{className:ut.section,children:[l.jsx("label",{className:ut.label,htmlFor:"ws-environment",children:"Environment"}),l.jsxs("select",{id:"ws-environment",className:ut.selectField,value:n.environmentId,onChange:h=>m("environmentId",h.target.value),disabled:u,"data-testid":"workspace-form-environment",children:[l.jsx("option",{value:"",children:"Select environment…"}),i.map(h=>l.jsx("option",{value:h.id,children:h.displayName||h.id},h.id))]}),(c==null?void 0:c.environmentId)&&l.jsx("span",{className:ut.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),l.jsxs("div",{className:ut.section,children:[l.jsx("label",{className:ut.label,htmlFor:"ws-persona",children:"Default Persona"}),l.jsxs("select",{id:"ws-persona",className:ut.selectField,value:n.defaultPersonaId,onChange:h=>m("defaultPersonaId",h.target.value),disabled:u,"data-testid":"workspace-form-persona",children:[l.jsx("option",{value:"",children:"(Inherit)"}),o.map(h=>l.jsx("option",{value:h.id,children:h.name},h.id))]})]}),l.jsx("div",{className:ut.section,children:l.jsxs("label",{className:ut.checkboxRow,children:[l.jsx("input",{type:"checkbox",checked:n.useWorktrees,onChange:h=>m("useWorktrees",h.target.checked),disabled:u,"data-testid":"workspace-form-worktrees"}),l.jsx("span",{className:ut.checkboxLabel,children:"Enable worktree isolation"})]})}),l.jsxs("div",{className:ut.section,children:[l.jsx("label",{className:ut.label,htmlFor:"ws-workdir",children:"Working Directory"}),l.jsx("input",{id:"ws-workdir",className:ut.titleInput,type:"text",value:n.workingDirectory,onChange:h=>m("workingDirectory",h.target.value),placeholder:"Default (server default)",disabled:u,"data-testid":"workspace-form-workdir"})]})]})}const H4="_container_cddyd_1",G4="_header_cddyd_8",$4="_headerTitle_cddyd_35",F4="_badge_cddyd_44",Z4="_headerActions_cddyd_54",K4="_body_cddyd_61",Y4="_formContent_cddyd_73",J4="_section_cddyd_85",W4="_label_cddyd_91",X4="_titleInput_cddyd_98",Q4="_descriptionTextarea_cddyd_131",eB="_parentContext_cddyd_167",tB="_parentLabel_cddyd_175",nB="_parentName_cddyd_182",sB="_personaSelect_cddyd_186",aB="_depList_cddyd_220",iB="_depItem_cddyd_226",oB="_depItemSelected_cddyd_248",rB="_noDeps_cddyd_252",lB="_btnPrimary_cddyd_258",cB="_btnGhost_cddyd_289",Be={container:H4,header:G4,headerTitle:$4,badge:F4,headerActions:Z4,body:K4,formContent:Y4,section:J4,label:W4,titleInput:X4,descriptionTextarea:Q4,parentContext:eB,parentLabel:tB,parentName:nB,personaSelect:sB,depList:aB,depItem:iB,depItemSelected:oB,noDeps:rB,btnPrimary:lB,btnGhost:cB};function uB(n){const s={};return n.name.trim()||(s.name="Name is required"),n.repoUrl.trim()&&!/^https?:\/\/.+/i.test(n.repoUrl.trim())&&(s.repoUrl="Must be a valid http(s) URL"),n.environmentId||(s.environmentId="Environment is required"),Object.keys(s).length>0?s:void 0}const dB=[{label:"Home",url:Ya},{label:"New Workspace",url:void 0}];function fB(){const[n]=bp(),s=n.get("environment")??void 0,{environments:i,personas:o,createWorkspace:c,workspaceCreating:u}=pt(),{showToast:d}=Bs(),m=St(),[h,g]=y.useState(()=>{var j;return P4(void 0,s||((j=i[0])==null?void 0:j.id))}),[v,b]=y.useState(),[_,S]=y.useState();y.useEffect(()=>{s||h.environmentId||i.length===0||g(j=>{var w;return j.environmentId?j:{...j,environmentId:((w=i[0])==null?void 0:w.id)??""}})},[i,s,h.environmentId]);const T=()=>{const j=uB(h);if(j){b(j),S(void 0);return}b(void 0),S(void 0),c(h.name.trim(),h.description,h.repoUrl.trim(),h.environmentId,h.defaultPersonaId,h.useWorktrees,h.workingDirectory,()=>{d("Workspace created","success"),m(Ya,{replace:!0})},w=>{S(w)})},N=()=>{m(s?Qi(s):Ya,{replace:!0})};return l.jsxs("div",{className:Be.container,children:[l.jsxs("div",{className:Be.header,children:[l.jsx("div",{className:Be.headerTitle,children:l.jsx(ba,{segments:dB})}),l.jsxs("div",{className:Be.headerActions,children:[l.jsx("button",{className:Be.btnGhost,onClick:N,disabled:u,"data-testid":"workspace-create-cancel",children:"Cancel"}),l.jsx("button",{className:Be.btnPrimary,onClick:T,disabled:u||!h.name.trim()||!h.environmentId,"data-testid":"workspace-create-save",children:u?l.jsx(Ax,{size:"sm",label:"Creating"}):"Create Workspace"})]})]}),l.jsxs("div",{className:Be.body,children:[l.jsx(q4,{values:h,onChange:j=>{g(j),b(void 0),S(void 0)},environments:i,personas:o,errors:v,disabled:u,autoFocusName:!0}),_&&l.jsx("div",{className:Be.error,"data-testid":"workspace-create-submit-error",children:_})]})]})}function Bx({mode:n,taskId:s,workspaceId:i,parentTaskId:o,environmentId:c,tasks:u,workspaces:d,personas:m,onCreateTask:h,onUpdateTask:g,onEditDone:v}){const{showToast:b}=Bs(),_=St(),S=n==="edit",T=S&&s?u.find(pe=>pe.id===s):void 0,N=S?(T==null?void 0:T.workspaceId)??"":i??"",[j,w]=y.useState(N),E=N||j,A=d.find(pe=>pe.id===E),O=c??(A==null?void 0:A.environmentId),C=!S&&!i,M=S?(T==null?void 0:T.parentTaskId)??"":o??"",G=M?u.find(pe=>pe.id===M):void 0,[U,V]=y.useState((T==null?void 0:T.title)??""),[Z,ee]=y.useState((T==null?void 0:T.description)??""),[ie,be]=y.useState((T==null?void 0:T.dependsOn)??[]),[K,re]=y.useState((T==null?void 0:T.defaultPersonaId)??""),[I,$]=y.useState((T==null?void 0:T.canDecompose)??!1),[Q,de]=y.useState(!1),me=y.useRef(!1);y.useEffect(()=>{S&&T&&!me.current&&(me.current=!0,V(T.title),ee(T.description),be(T.dependsOn),re(T.defaultPersonaId),$(T.canDecompose))},[S,T]);const ze=u.filter(pe=>pe.workspaceId===E&&(!S||pe.id!==s)&&pe.id!==M),je=U.trim().length>0&&(!S||T!==void 0)&&E.length>0,Ne=pe=>{be(Re=>Re.includes(pe)?Re.filter(Bt=>Bt!==pe):[...Re,pe])},Ae=()=>{!je||Q||S&&T===void 0||(S&&s?(g(s,U.trim(),Z,ie,K),b("Task updated","success"),v?v():_(os(s,void 0,E,O),{replace:!0})):(de(!0),h(E,U.trim(),Z,ie.length>0?ie:void 0,M||void 0,K,I,()=>{b("Task created","success"),_(i?Wi(i,O):"/tasks",{replace:!0})},pe=>{b(pe,"error"),de(!1)})))},ce=()=>{if(v){v();return}_(S&&s?os(s,void 0,E,O):i?Wi(i,O):"/tasks")},fe=S?"edit task":M?"child task":"new task";return l.jsxs("div",{className:Be.container,children:[l.jsxs("div",{className:Be.header,children:[l.jsxs("div",{className:Be.headerTitle,children:[l.jsx("span",{className:Be.badge,children:fe}),G&&l.jsxs("span",{className:Be.parentContext,children:[l.jsx("span",{className:Be.parentLabel,children:"Child of"}),l.jsx("span",{className:Be.parentName,children:G.title})]})]}),l.jsxs("div",{className:Be.headerActions,children:[l.jsx("button",{onClick:Ae,disabled:!je||Q,className:Be.btnPrimary,"data-testid":"task-edit-save",children:Q?"Creating…":S?"Save Changes":"Create"}),l.jsx("button",{onClick:ce,className:Be.btnGhost,children:"Cancel"})]})]}),l.jsx("div",{className:Be.body,children:l.jsxs("div",{className:Be.formContent,children:[C&&l.jsxs("div",{className:Be.section,children:[l.jsx("label",{className:Be.label,htmlFor:"task-edit-workspace",children:"Workspace"}),l.jsxs("select",{id:"task-edit-workspace",value:j,onChange:pe=>w(pe.target.value),className:Be.personaSelect,"data-testid":"task-edit-workspace",children:[l.jsx("option",{value:"",children:"Select a workspace..."}),d.map(pe=>l.jsx("option",{value:pe.id,children:pe.name},pe.id))]})]}),l.jsxs("div",{className:Be.section,children:[l.jsx("label",{className:Be.label,htmlFor:"task-edit-title",children:"Title"}),l.jsx("input",{id:"task-edit-title",type:"text",value:U,onChange:pe=>V(pe.target.value),placeholder:"Task title...",autoFocus:!0,className:Be.titleInput,"data-testid":"task-edit-title",onKeyDown:pe=>{pe.key==="Enter"&&je&&Ae()}})]}),l.jsxs("div",{className:Be.section,children:[l.jsx("label",{className:Be.label,htmlFor:"task-edit-description",children:"Description"}),l.jsx("textarea",{id:"task-edit-description",value:Z,onChange:pe=>ee(pe.target.value),placeholder:"Describe the task... (markdown supported)",className:Be.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),l.jsxs("div",{className:Be.section,children:[l.jsx("label",{className:Be.label,htmlFor:"task-edit-persona",children:"Default Persona"}),l.jsxs("select",{id:"task-edit-persona",value:K,onChange:pe=>re(pe.target.value),className:Be.personaSelect,"data-testid":"task-edit-persona",children:[l.jsx("option",{value:"",children:"(Inherit)"}),m.map(pe=>l.jsx("option",{value:pe.id,children:pe.name},pe.id))]})]}),!S&&l.jsx("div",{className:Be.section,children:l.jsxs("label",{className:Be.depItem,"data-testid":"task-edit-can-decompose",children:[l.jsx("input",{type:"checkbox",checked:I,onChange:pe=>$(pe.target.checked)}),"Can spawn subtasks"]})}),l.jsxs("div",{className:Be.section,children:[l.jsx("div",{className:Be.label,children:"Dependencies"}),ze.length===0?l.jsx("div",{className:Be.noDeps,children:"No other tasks in this workspace"}):l.jsx("div",{className:Be.depList,children:ze.map(pe=>{const Re=ie.includes(pe.id);return l.jsxs("label",{className:`${Be.depItem} ${Re?Be.depItemSelected:""}`,"data-testid":`dep-option-${pe.id}`,children:[l.jsx("input",{type:"checkbox",checked:Re,onChange:()=>Ne(pe.id)}),pe.title,l.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",pe.status,")"]})]},pe.id)})})]})]})})]})}function Wy(){const{workspaceId:n,environmentId:s}=va(),[i]=bp(),o=n??i.get("workspace")??"",c=i.get("parent")??void 0,{tasks:u,workspaces:d,personas:m,createTask:h,updateTask:g}=pt();return l.jsx(Bx,{mode:"new",workspaceId:o,parentTaskId:c,environmentId:s,tasks:u,workspaces:d,personas:m,onCreateTask:h,onUpdateTask:g})}const pB="_container_1pqxm_1",mB="_emptyState_1pqxm_8",hB="_card_1pqxm_14",gB="_cardHeader_1pqxm_34",vB="_categoryBadge_1pqxm_46",yB="_findingTitle_1pqxm_54",bB="_findingDate_1pqxm_60",_B="_findingContent_1pqxm_72",xB="_tags_1pqxm_78",SB="_tag_1pqxm_78",ts={container:pB,emptyState:mB,card:hB,cardHeader:gB,categoryBadge:vB,findingTitle:yB,findingDate:bB,findingContent:_B,tags:xB,tag:SB};function TB(n){const s=new Date(n),i=new Date,o=i.getTime()-s.getTime(),c=Math.floor(o/1e3),u=Math.floor(c/60),d=Math.floor(u/60),m=Math.floor(d/24);if(c<60)return"just now";if(u<60)return`${u}m ago`;if(d<24)return`${d}h ago`;if(m===1)return"yesterday";if(m<7)return`${m} days ago`;const h=s.getFullYear()===i.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return h?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}const Xy={architecture:{text:"var(--accent-blue)",bg:"var(--accent-blue-dim)"},api:{text:"var(--accent-green)",bg:"var(--accent-green-dim)"},bug:{text:"var(--accent-red)",bg:"var(--accent-red-dim)"},decision:{text:"var(--accent-yellow)",bg:"var(--accent-yellow-dim)"},dependency:{text:"var(--accent-purple)",bg:"var(--accent-purple-dim)"},pattern:{text:"var(--accent-cyan)",bg:"var(--accent-cyan-dim)"},general:{text:"var(--text-secondary)",bg:"var(--bg-elevated)"}};function kB({findings:n}){return n.length===0?l.jsx("div",{className:ts.emptyState,children:"No findings yet. Agents will post discoveries here."}):l.jsx("div",{className:ts.container,children:n.map((s,i)=>{const o=Xy[s.category]||Xy.general;return l.jsxs(Rt.div,{className:ts.card,initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:i*.05,duration:.2},children:[l.jsxs("div",{className:ts.cardHeader,children:[l.jsx("span",{className:ts.categoryBadge,style:{background:o.bg,color:o.text},children:s.category}),l.jsx("span",{className:ts.findingTitle,children:s.title}),l.jsx("span",{className:ts.findingDate,title:s.createdAt,children:TB(s.createdAt)})]}),l.jsx("div",{className:ts.findingContent,children:s.content.length>300?s.content.slice(0,300)+"...":s.content}),s.tags.length>0&&l.jsx("div",{className:ts.tags,children:s.tags.map(c=>l.jsx("span",{className:ts.tag,style:{color:o.text,textShadow:`0 0 8px ${o.text}`},children:c},c))})]},s.id)})})}const wB="_workpadSection_y8nj9_1",NB="_workpadLabel_y8nj9_9",jB="_workpadStatus_y8nj9_17",CB="_workpadSummary_y8nj9_23",EB="_workpadExtra_y8nj9_29",da={workpadSection:wB,workpadLabel:NB,workpadStatus:jB,workpadSummary:CB,workpadExtra:EB};function AB({workpad:n}){if(!n)return;let s;try{const i=JSON.parse(n);if(i==null||typeof i!="object"||Array.isArray(i))return;s=i}catch{return l.jsxs("div",{className:da.workpadSection,"data-testid":"workpad-panel",children:[l.jsx("div",{className:da.workpadLabel,children:"Workpad"}),l.jsx("div",{className:da.workpadExtra,children:n})]})}if(!(!s.status&&!s.summary&&!s.extra))return l.jsxs("div",{className:da.workpadSection,"data-testid":"workpad-panel",children:[l.jsx("div",{className:da.workpadLabel,children:"Workpad"}),s.status&&l.jsx("div",{className:da.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&l.jsx("div",{className:da.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&l.jsx("div",{className:da.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}function cc(n){if(!n)return"—";const s=new Date(n);return isNaN(s.getTime())?"—":s.toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function Mf(n,s){if(!n||!s)return;const i=new Date(s).getTime()-new Date(n).getTime();if(isNaN(i)||i<0)return;const o=Math.floor(i/6e4),c=Math.floor(i%6e4/1e3);if(o===0)return`${c}s`;const u=Math.floor(o/60),d=o%60;return u===0?`${o}m ${c}s`:`${u}h ${d}m`}function Qy(n){const s=n.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?L.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?L.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?L.envDotRed:L.envDotGray}function DB({status:n}){const s=ga(n),i=nA(n);return l.jsx("span",{className:`${L.statusBadge} ${L[i]??L.statusPending}`,children:s.label})}function RB({task:n,tasksById:s,environments:i,workspaces:o,taskSessions:c,selectedEnvId:u}){const{loadUsage:d,usageCache:m}=pt(),h=c.reduce((A,O)=>A+(O.costUsd??0),0);y.useEffect(()=>{d("task",n.id),n.childTaskIds.length>0&&d("task_tree",n.id)},[n.id,n.childTaskIds.length,d,h]);const g=`task:${n.id}`,v=g in m?m[g]:void 0,b=`task_tree:${n.id}`,_=n.childTaskIds.length>0&&b in m?m[b]:void 0,S=c.length>0?c[c.length-1]:void 0,T=(S==null?void 0:S.environmentId)??"",N=T?i.find(A=>A.id===T):void 0,j=o.find(A=>A.id===n.workspaceId),w=i.find(A=>A.id===u),E=n.branch&&(j!=null&&j.repoUrl)?`${j.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(n.branch)}`:void 0;return l.jsxs("div",{className:L.overviewDashboard,children:[l.jsxs("div",{className:L.overviewHero,children:[l.jsx(DB,{status:n.status}),n.branch&&l.jsx("span",{className:L.overviewBranchPill,children:E?l.jsxs("a",{href:E,target:"_blank",rel:"noreferrer noopener",className:L.branchLink,children:["🔗"," ",n.branch]}):l.jsxs("span",{children:["🔗"," ",n.branch]})})]}),typeof n.description=="string"&&n.description&&l.jsxs("div",{className:L.overviewSection,children:[l.jsx("div",{className:L.overviewLabel,children:"Description"}),l.jsx("div",{className:L.overviewMarkdown,children:l.jsx(up,{remarkPlugins:[dp],children:n.description})})]}),n.workpad&&l.jsx(AB,{workpad:n.workpad}),l.jsxs("div",{className:L.overviewSection,children:[l.jsx("div",{className:L.overviewLabel,children:"Environment"}),T&&N?l.jsxs("div",{className:L.envRow,"data-testid":"task-overview-environment",children:[l.jsx("span",{className:`${L.envDot} ${Qy(N.status)}`,title:N.status,"aria-label":`Status: ${N.status}`,role:"img"}),l.jsx("span",{className:L.overviewValue,children:N.displayName})]}):w?l.jsxs("div",{className:L.envRow,"data-testid":"task-overview-environment",children:[l.jsx("span",{className:`${L.envDot} ${Qy(w.status)}`,title:w.status,"aria-label":`Status: ${w.status}`,role:"img"}),l.jsx("span",{className:L.overviewValue,children:w.displayName}),l.jsx("span",{className:L.overviewMuted,children:"(workspace default)"})]}):l.jsx("div",{className:L.overviewMuted,children:"Set in workspace settings"})]}),l.jsxs("div",{className:L.overviewSection,"data-testid":"task-overview-dependencies",children:[l.jsx("div",{className:L.overviewLabel,children:"Dependencies"}),n.dependsOn.length===0?l.jsx("div",{className:L.overviewMuted,children:"None"}):l.jsx("div",{className:L.depList,children:n.dependsOn.map(A=>{const O=s.get(A),C=(O==null?void 0:O.status)==="complete";return l.jsxs("div",{className:`${L.depItem} ${C?L.depDone:L.depBlocked}`,children:[l.jsx("span",{children:C?"✓":"○"}),l.jsx("span",{children:(O==null?void 0:O.title)??A})]},A)})})]}),l.jsxs("div",{className:L.overviewSection,children:[l.jsx("div",{className:L.overviewLabel,children:"Timeline"}),l.jsxs("div",{className:L.timeline,children:[n.createdAt&&l.jsxs("div",{className:L.timelineRow,children:[l.jsx("span",{className:L.timelineKey,children:"Created"}),l.jsx("span",{className:L.timelineValue,children:cc(n.createdAt)})]}),n.assignedAt&&(()=>{const A=Mf(n.createdAt,n.assignedAt);return l.jsxs("div",{className:L.timelineRow,children:[l.jsx("span",{className:L.timelineKey,children:"Assigned"}),l.jsx("span",{className:L.timelineValue,children:cc(n.assignedAt)}),A!==void 0&&l.jsx("span",{className:L.timelineDelta,children:A})]})})(),n.startedAt&&(()=>{const A=Mf(n.assignedAt??n.createdAt,n.startedAt);return l.jsxs("div",{className:L.timelineRow,children:[l.jsx("span",{className:L.timelineKey,children:"Started"}),l.jsx("span",{className:L.timelineValue,children:cc(n.startedAt)}),A!==void 0&&l.jsx("span",{className:L.timelineDelta,children:A})]})})(),n.completedAt&&(()=>{const A=Mf(n.startedAt,n.completedAt);return l.jsxs("div",{className:L.timelineRow,children:[l.jsx("span",{className:L.timelineKey,children:"Completed"}),l.jsx("span",{className:L.timelineValue,children:cc(n.completedAt)}),A!==void 0&&l.jsx("span",{className:L.timelineDelta,children:A})]})})(),!n.createdAt&&!n.assignedAt&&!n.startedAt&&!n.completedAt&&l.jsx("div",{className:L.overviewMuted,children:"No timing data"})]})]}),v&&v.costUsd>0&&l.jsxs("div",{className:L.overviewSection,children:[l.jsx("div",{className:L.overviewLabel,children:"Usage"}),l.jsxs("div",{className:L.timeline,children:[l.jsxs("div",{className:L.timelineRow,children:[l.jsx("span",{className:L.timelineKey,children:"Cost"}),l.jsx("span",{className:L.timelineValue,children:so(v.costUsd)}),l.jsxs("span",{className:L.timelineDelta,children:[v.sessionCount," session",v.sessionCount!==1?"s":""]})]}),_&&_.costUsd>v.costUsd&&l.jsxs("div",{className:L.timelineRow,children:[l.jsx("span",{className:L.timelineKey,children:"Total (incl. subtasks)"}),l.jsx("span",{className:L.timelineValue,children:so(_.costUsd)}),l.jsxs("span",{className:L.timelineDelta,children:[_.sessionCount," session",_.sessionCount!==1?"s":""]})]})]})]}),n.reviewNotes&&l.jsxs("div",{className:L.overviewSection,children:[l.jsx("div",{className:L.overviewLabel,children:"Review Notes"}),l.jsx("div",{className:L.reviewNotes,children:n.reviewNotes})]})]})}function MB({task:n,sessionId:s,isBlocked:i,onStart:o,onResume:c,onStop:u,onPause:d,onDelete:m,onEdit:h}){if(n.status==="not_started")return i?l.jsxs("div",{className:L.headerActions,children:[l.jsx("button",{onClick:h,className:L.btnGhost,children:"Edit"}),l.jsx("button",{onClick:m,className:L.btnDanger,children:"Delete"})]}):l.jsxs("div",{className:L.headerActions,children:[l.jsx("button",{"data-testid":"task-header-start",onClick:o,className:L.btnPrimary,children:"Start"}),l.jsx("button",{onClick:h,className:L.btnGhost,children:"Edit"}),l.jsx("button",{onClick:m,className:L.btnDanger,children:"Delete"})]});if(n.status==="working")return l.jsxs("div",{className:L.headerActions,children:[l.jsx("button",{onClick:u,className:L.btnDanger,children:"Stop"}),l.jsx("button",{onClick:d,disabled:!s,className:L.btnGhost,children:"Pause"})]});if(n.status==="paused")return l.jsxs("div",{className:L.headerActions,children:[l.jsx("button",{onClick:u,className:L.btnPrimary,children:"Stop"}),l.jsx("button",{onClick:c,className:L.btnGhost,children:"Resume"}),l.jsx("button",{onClick:m,className:L.btnDanger,children:"Delete"})]});if(n.status==="complete")return l.jsx("div",{className:L.headerActions,children:l.jsx("button",{onClick:m,className:L.btnDanger,children:"Delete"})});if(n.status==="failed")return l.jsxs("div",{className:L.headerActions,children:[l.jsx("button",{onClick:o,className:L.btnPrimary,children:"Retry"}),l.jsx("button",{onClick:m,className:L.btnDanger,children:"Delete"})]})}function OB({taskSessions:n,selectedSessionId:s,onSelect:i}){if(!(n.length<2))return l.jsxs("div",{className:L.attemptSelector,"data-testid":"attempt-selector",children:[l.jsx("span",{className:L.attemptLabel,children:"Attempts:"}),n.map((o,c)=>{const u=o.id===s,d=o.status==="stopped"&&o.endReason==="completed"?"✓":o.status==="stopped"?"✗":o.status==="running"||o.status==="idle"?"●":"";return l.jsxs("button",{className:`${L.attemptButton} ${u?L.attemptActive:""}`,onClick:()=>i(o.id),title:`Attempt #${c+1} — ${o.status}`,"aria-label":`Attempt #${c+1}, ${o.status}`,"aria-pressed":u,"data-testid":`attempt-${c+1}`,children:["#",c+1,d&&l.jsx("span",{className:L.attemptStatus,children:d})]},o.id)})]})}function fa(){const{taskId:n,workspaceId:s,environmentId:i}=va(),o=It(),c=St(),{events:u,eventsDropped:d,tasks:m,sessions:h,environments:g,findings:v,loadSessionEvents:b,loadFindings:_,kill:S,startTask:T,stopTask:N,resumeTask:j,deleteTask:w,createTask:E,updateTask:A,workspaces:O,taskSessions:C,loadTaskSessions:M,sendInput:G,spawn:U,personas:V,provisionEnvironment:Z}=pt(),ee=y.useRef(void 0),ie=y.useRef(void 0),be=y.useRef(void 0),K=y.useRef(void 0),re=y.useRef(void 0),I=o.pathname.endsWith("/stream")?"stream":o.pathname.endsWith("/findings")?"findings":"overview",$=o.pathname.endsWith("/edit"),[Q,de]=y.useState(I),[me,ze]=y.useState(!1),[je,Ne]=y.useState(void 0),[Ae,ce]=y.useState(""),[fe,pe]=y.useState($),Re=y.useRef(I),Bt=y.useRef($),te=m.find(Me=>Me.id===n),X=(te==null?void 0:te.workspaceId)||void 0,Te=O.find(Me=>Me.id===X);y.useEffect(()=>{I!==Re.current&&(Re.current=I,I!==Q&&de(I))},[I,Q]),y.useEffect(()=>{$!==Bt.current&&(Bt.current=$,$!==fe&&pe($))},[$,fe]),y.useEffect(()=>{if(Ae===""){if(Te!=null&&Te.environmentId)ce(Te.environmentId);else if(g.length>0){const Me=g.find(Mt=>Mt.status==="connected");ce((Me==null?void 0:Me.id)??g[0].id)}}},[Ae,Te==null?void 0:Te.environmentId,g]);const un=te?C[te.id]??[]:[];let Ze;je&&un.some(Me=>Me.id===je)?Ze=je:Ze=(te==null?void 0:te.latestSessionId)||void 0;const Kn=()=>{ze(!0)},Yn=()=>{if(!te)return;w(te.id),ze(!1);const Me=i??(Te==null?void 0:Te.environmentId);c(te.workspaceId&&Me?Wi(te.workspaceId,Me):"/",{replace:!0})};y.useEffect(()=>{(te==null?void 0:te.id)!==ie.current&&(ie.current=te==null?void 0:te.id,Ne(void 0),ce(""),pe($))},[te==null?void 0:te.id,$]),y.useEffect(()=>{if(!(te!=null&&te.id))return;const Me=te.id!==K.current,Mt=te.latestSessionId!==re.current;(Me||Mt)&&(K.current=te.id,re.current=te.latestSessionId,M(te.id))},[te==null?void 0:te.id,te==null?void 0:te.latestSessionId,M]),y.useEffect(()=>{if((te==null?void 0:te.status)!==be.current){const Me=be.current===void 0;be.current=te==null?void 0:te.status;const Mt=(te==null?void 0:te.status)==="not_started"?"overview":(te==null?void 0:te.status)==="working"||(te==null?void 0:te.status)==="paused"?"stream":(te==null?void 0:te.status)==="complete"?"findings":void 0;Mt&&Mt!==Q&&!(Me&&I!=="overview")&&de(Mt)}},[te==null?void 0:te.status,Q,I]);const zn=y.useMemo(()=>new Map(m.map(Me=>[Me.id,Me])),[m]),Jn=y.useMemo(()=>{const Me=Ze?u.filter(Mt=>Mt.sessionId===Ze):[];return im(am(Me))},[u,Ze]),Tn=te?te.dependsOn.some(Me=>{const Mt=zn.get(Me);return Mt!==void 0&&Mt.status!=="complete"}):!1,Ls=y.useMemo(()=>o5(n,i,O,g,zn),[n,i,O,g,zn]);y.useEffect(()=>{Ze&&Ze!==ee.current&&(ee.current=Ze,b(Ze))},[Ze,b]),y.useEffect(()=>{Q==="findings"&&X&&_(X)},[Q,X,_]);const dn=Me=>{de(Me),c(os(n,Me==="overview"?void 0:Me,s,i))};return Ms({key:"1"},()=>dn("overview")),Ms({key:"2"},()=>dn("stream")),Ms({key:"3"},()=>dn("findings")),l.jsxs("div",{className:L.panelContainer,children:[l.jsx(ba,{segments:Ls}),l.jsxs("div",{className:L.header,children:[l.jsxs("span",{className:L.headerTitle,children:[l.jsx("span",{"data-testid":"task-title",children:(te==null?void 0:te.title)||n}),te&&l.jsx("span",{className:L.taskStatusBadge,"data-testid":"task-status",children:te.status}),(te==null?void 0:te.branch)&&l.jsx("span",{className:L.taskBranch,children:te.branch}),Tn&&l.jsx("span",{className:L.taskBlockedBadge,children:"blocked"})]}),te&&l.jsx(MB,{task:te,sessionId:Ze,isBlocked:Tn,onStart:()=>T(te.id,void 0,Ae),onResume:()=>j(te.id),onStop:()=>N(te.id),onPause:()=>Ze&&S(Ze),onDelete:Kn,onEdit:()=>pe(!0)})]}),l.jsxs("div",{className:L.tabBar,role:"tablist","aria-label":"Task view",children:[l.jsx("button",{role:"tab","aria-selected":Q==="overview",className:`${L.tab} ${Q==="overview"?L.active:""}`,onClick:()=>dn("overview"),children:"Overview"}),l.jsx("button",{role:"tab","aria-selected":Q==="stream",className:`${L.tab} ${Q==="stream"?L.active:""}`,onClick:()=>dn("stream"),children:"Stream"}),l.jsx("button",{role:"tab","aria-selected":Q==="findings",className:`${L.tab} ${Q==="findings"?L.active:""}`,onClick:()=>dn("findings"),children:"Findings"})]}),l.jsxs(rs,{mode:"wait",children:[Q==="overview"&&l.jsx(Rt.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},className:L.overviewContent,"data-testid":"task-overview",children:fe&&te?l.jsx(Bx,{mode:"edit",taskId:te.id,workspaceId:X,environmentId:i,tasks:m,workspaces:O,personas:V,onCreateTask:E,onUpdateTask:A,onEditDone:()=>{$?c(os(te.id,void 0,s,i),{replace:!0}):pe(!1)}}):te?l.jsx(RB,{task:te,tasksById:zn,environments:g,workspaces:O,taskSessions:un,selectedEnvId:Ae}):l.jsx("div",{className:L.waitingMessage,children:"No additional details"})},"overview"),Q==="stream"&&l.jsxs(Rt.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},style:{display:"flex",flexDirection:"column",flex:1,overflow:"hidden"},children:[l.jsx(OB,{taskSessions:un,selectedSessionId:Ze,onSelect:Me=>Ne(Me)}),l.jsx(sm,{events:Jn,eventsDropped:d,emptyState:!Ze&&te?Tn?l.jsx("div",{className:L.emptyCta,"data-testid":"stream-blocked-message",children:l.jsx("div",{className:L.ctaDescription,children:"This task is blocked by incomplete dependencies"})}):l.jsxs("div",{className:L.emptyCta,children:[l.jsx("button",{"data-testid":"stream-start-cta",className:L.ctaButton,onClick:()=>T(te.id,void 0,Ae),children:"Start Task"}),l.jsx("div",{className:L.ctaDescription,children:"Click to begin agent execution"})]}):Ze&&Jn.length===0?l.jsx("div",{className:L.waitingMessage,children:"Waiting for events..."}):void 0})]},"stream"),Q==="findings"&&l.jsx(Rt.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},className:L.tabContent,children:X?l.jsx(kB,{findings:v.filter(Me=>Me.workspaceId===X)}):l.jsx("div",{className:L.noContext,children:"Navigate to a task within a workspace to view findings"})},"findings")]}),(()=>{if(!te||te.status!=="working"&&te.status!=="paused")return;const Me=Ze?h.find(Mt=>Mt.id===Ze):void 0;if(!(!Me||Me.status==="stopped"))return l.jsx(jr,{mode:"send",sessionId:Me.id,environmentId:Me.environmentId,personas:V,environments:g,onSendInput:G,onSpawn:U,onStartTask:T,onProvisionEnvironment:Z})})(),te&&l.jsx(Ja,{isOpen:me,title:"Delete Task?",description:`"${te.title}" will be permanently removed.`,onConfirm:Yn,onCancel:()=>ze(!1)})]})}const IB="_container_legrg_1",BB="_header_legrg_8",LB="_headerTitle_legrg_35",UB="_badge_legrg_44",zB="_headerActions_legrg_54",PB="_body_legrg_61",VB="_formContent_legrg_73",qB="_section_legrg_85",HB="_label_legrg_91",GB="_nameInput_legrg_98",$B="_fieldInput_legrg_131",FB="_adapterSelect_legrg_164",ZB="_readOnlyValue_legrg_198",KB="_codespaceSection_legrg_204",YB="_codespaceActions_legrg_210",JB="_creatingHint_legrg_216",WB="_errorHint_legrg_222",XB="_btnPrimary_legrg_235",QB="_btnGhost_legrg_266",se={container:IB,header:BB,headerTitle:LB,badge:UB,headerActions:zB,body:PB,formContent:VB,section:qB,label:HB,nameInput:GB,fieldInput:$B,adapterSelect:FB,readOnlyValue:ZB,codespaceSection:KB,codespaceActions:YB,creatingHint:JB,errorHint:WB,btnPrimary:XB,btnGhost:QB},gc=1,vc=65535;function Of(n){if(!n.trim())return!0;const s=Number(n);return Number.isInteger(s)&&s>=gc&&s<=vc}function If(n){try{const s=JSON.parse(n);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function eL({codespaceName:n,onCodespaceNameChange:s,envName:i,onEnvNameChange:o,codespaces:c,codespaceError:u,codespaceListError:d,codespaceCreating:m,onCreateCodespace:h}){const[g,v]=y.useState("pick"),[b,_]=y.useState(""),[S,T]=y.useState("");return g==="create"?l.jsxs("div",{className:se.codespaceSection,children:[l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,children:"Repository"}),l.jsx("input",{type:"text",value:b,onChange:N=>_(N.target.value),placeholder:"owner/repo",className:se.fieldInput,"data-testid":"env-codespace-repo"})]}),l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,children:"Machine Type"}),l.jsx("input",{type:"text",value:S,onChange:N=>T(N.target.value),placeholder:"Machine type (optional)...",className:se.fieldInput,"data-testid":"env-codespace-machine"})]}),l.jsxs("div",{className:se.codespaceActions,children:[l.jsx("button",{onClick:()=>{b.trim()&&(h(b.trim(),S.trim()||void 0),v("pick"),_(""),T(""))},disabled:!b.trim(),className:se.btnPrimary,children:"Create"}),l.jsx("button",{onClick:()=>{v("pick"),_(""),T("")},className:se.btnGhost,children:"Cancel"})]})]}):l.jsx("div",{className:se.codespaceSection,children:l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,children:"Codespace"}),!d&&l.jsxs("select",{value:n,onChange:N=>{N.target.value==="__create__"?(v("create"),s("")):(s(N.target.value),N.target.value&&!i.trim()&&o(N.target.value))},disabled:m,className:se.adapterSelect,"data-testid":"env-codespace-select",children:[l.jsx("option",{value:"",children:"Select a codespace..."}),c.map(N=>l.jsxs("option",{value:N.name,children:[N.name," (",N.repository,") — ",N.state]},N.name)),l.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),m&&l.jsx("span",{className:se.creatingHint,children:"Creating codespace..."}),d&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:se.errorHint,children:d}),l.jsx("input",{type:"text",value:n,onChange:N=>s(N.target.value),placeholder:"Or enter codespace name manually...",className:se.fieldInput,"data-testid":"env-codespace-manual"})]}),u&&!d&&l.jsx("span",{className:se.errorHint,children:u})]})})}function Lx({mode:n,environmentId:s,environments:i,onAddEnvironment:o,onUpdateEnvironment:c,onListCodespaces:u,codespaces:d,codespaceError:m,codespaceListError:h,codespaceCreating:g,onCreateCodespace:v}){const{showToast:b}=Bs(),_=St(),S=n==="edit",T=S&&s?i.find(ce=>ce.id===s):void 0,[N,j]=y.useState(""),[w,E]=y.useState("local"),[A,O]=y.useState(""),[C,M]=y.useState(""),[G,U]=y.useState(""),[V,Z]=y.useState(""),[ee,ie]=y.useState(""),[be,K]=y.useState(""),[re,I]=y.useState(""),[$,Q]=y.useState(null),de=y.useCallback(()=>{const ce={};if(w==="local"){if(A.trim()&&(ce.host=A.trim()),C.trim()){const fe=Number(C);Number.isInteger(fe)&&(ce.port=fe)}}else if(w==="ssh"){if(ce.host=A.trim(),G.trim()&&(ce.user=G.trim()),C.trim()){const fe=Number(C);Number.isInteger(fe)&&(ce.sshPort=fe)}V.trim()&&(ce.identityFile=V.trim())}else w==="docker"?(ee.trim()&&(ce.image=ee.trim()),be.trim()&&(ce.repo=be.trim())):w==="codespace"&&(ce.codespaceName=re.trim());return ce},[w,A,C,G,V,ee,be,re]),me=()=>!(!N.trim()||w==="ssh"&&!A.trim()||w==="codespace"&&!re.trim()||(w==="local"||w==="ssh")&&!Of(C)),ze=()=>{me()&&(o(N.trim(),w,de()),b("Environment added successfully","success"),_(Xi,{replace:!0}))},je=()=>{_(s?Qi(s):Xi)},Ne=y.useCallback((ce,fe)=>{if(!T||!s)return;const pe=If(T.adapterConfig),Re=fe.trim();Re?pe[ce]=Re:delete pe[ce],c(s,{adapterConfig:pe})},[T,s,c]),Ae=y.useCallback((ce,fe)=>{if(!T||!s)return;const pe=If(T.adapterConfig);if(fe.trim()){const Re=Number(fe);Number.isInteger(Re)&&Re>=gc&&Re<=vc&&(pe[ce]=Re)}else delete pe[ce];c(s,{adapterConfig:pe})},[T,s,c]);if(S){if(!T)return l.jsxs("div",{className:se.container,children:[l.jsxs("div",{className:se.header,children:[l.jsx("div",{className:se.headerTitle,children:l.jsx("span",{className:se.badge,children:"edit environment"})}),l.jsx("div",{className:se.headerActions,children:l.jsx("button",{onClick:je,className:se.btnGhost,children:"Back"})})]}),l.jsx("div",{className:se.body,children:l.jsx("div",{className:se.formContent,children:l.jsx("span",{className:se.readOnlyValue,children:"Environment not found"})})})]});const ce=If(T.adapterConfig);return l.jsxs("div",{className:se.container,"data-testid":"env-edit-panel",children:[l.jsxs("div",{className:se.header,children:[l.jsx("div",{className:se.headerTitle,children:l.jsx("span",{className:se.badge,children:"edit environment"})}),l.jsx("div",{className:se.headerActions,children:l.jsx("button",{onClick:je,className:se.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),l.jsx("div",{className:se.body,children:l.jsxs("div",{className:se.formContent,children:[l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,children:"Name"}),l.jsx(Zt,{value:T.displayName,onSave:fe=>{s&&c(s,{displayName:fe})},validate:fe=>fe.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:$,onActivate:Q,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,children:"Adapter Type"}),l.jsx("span",{className:se.readOnlyValue,"data-testid":"env-edit-adapter-type",children:T.adapterType})]}),T.adapterType==="local"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,children:"Host"}),l.jsx(Zt,{value:String(ce.host??""),onSave:fe=>Ne("host",fe),mode:"edit",fieldId:"host",activeFieldId:$,onActivate:Q,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,children:"Port"}),l.jsx(Zt,{value:String(ce.port??""),onSave:fe=>Ae("port",fe),validate:fe=>Of(fe)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:$,onActivate:Q,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),T.adapterType==="ssh"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,children:"Host"}),l.jsx(Zt,{value:String(ce.host??""),onSave:fe=>Ne("host",fe),validate:fe=>fe.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:$,onActivate:Q,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,children:"User"}),l.jsx(Zt,{value:String(ce.user??""),onSave:fe=>Ne("user",fe),mode:"edit",fieldId:"user",activeFieldId:$,onActivate:Q,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,children:"SSH Port"}),l.jsx(Zt,{value:String(ce.sshPort??""),onSave:fe=>Ae("sshPort",fe),validate:fe=>Of(fe)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:$,onActivate:Q,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,children:"Identity File"}),l.jsx(Zt,{value:String(ce.identityFile??""),onSave:fe=>Ne("identityFile",fe),mode:"edit",fieldId:"identityFile",activeFieldId:$,onActivate:Q,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),T.adapterType==="docker"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,children:"Image"}),l.jsx(Zt,{value:String(ce.image??""),onSave:fe=>Ne("image",fe),mode:"edit",fieldId:"image",activeFieldId:$,onActivate:Q,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,children:"Repo"}),l.jsx(Zt,{value:String(ce.repo??""),onSave:fe=>Ne("repo",fe),mode:"edit",fieldId:"repo",activeFieldId:$,onActivate:Q,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),T.adapterType==="codespace"&&l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,children:"Codespace Name"}),l.jsx(Zt,{value:String(ce.codespaceName??""),onSave:fe=>Ne("codespaceName",fe),validate:fe=>fe.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:$,onActivate:Q,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return l.jsxs("div",{className:se.container,"data-testid":"env-create-panel",children:[l.jsxs("div",{className:se.header,children:[l.jsx("div",{className:se.headerTitle,children:l.jsx("span",{className:se.badge,children:"new environment"})}),l.jsxs("div",{className:se.headerActions,children:[l.jsx("button",{onClick:ze,disabled:!me(),className:se.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),l.jsx("button",{onClick:je,className:se.btnGhost,children:"Cancel"})]})]}),l.jsx("div",{className:se.body,children:l.jsxs("div",{className:se.formContent,children:[l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,htmlFor:"env-create-name",children:"Name"}),l.jsx("input",{id:"env-create-name",type:"text",value:N,onChange:ce=>j(ce.target.value),placeholder:"Environment name...",autoFocus:!0,className:se.nameInput,"data-testid":"env-create-name",onKeyDown:ce=>{ce.key==="Enter"&&me()&&ze()}})]}),l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),l.jsxs("select",{id:"env-create-adapter",value:w,onChange:ce=>{E(ce.target.value),ce.target.value==="codespace"&&u()},className:se.adapterSelect,"data-testid":"env-create-adapter",children:[l.jsx("option",{value:"local",children:"local"}),l.jsx("option",{value:"ssh",children:"ssh"}),l.jsx("option",{value:"docker",children:"docker"}),l.jsx("option",{value:"codespace",children:"codespace"})]})]}),w==="local"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,htmlFor:"env-create-host",children:"Host"}),l.jsx("input",{id:"env-create-host",type:"text",value:A,onChange:ce=>O(ce.target.value),placeholder:"Host (optional)...",className:se.fieldInput,"data-testid":"env-create-host"})]}),l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,htmlFor:"env-create-port",children:"Port"}),l.jsx("input",{id:"env-create-port",type:"number",min:gc,max:vc,value:C,onChange:ce=>M(ce.target.value),placeholder:"Port (optional)...",className:se.fieldInput,"data-testid":"env-create-port"})]})]}),w==="ssh"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,htmlFor:"env-create-host",children:"Host"}),l.jsx("input",{id:"env-create-host",type:"text",value:A,onChange:ce=>O(ce.target.value),placeholder:"Host (required)...",className:se.fieldInput,"data-testid":"env-create-host"})]}),l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,htmlFor:"env-create-user",children:"User"}),l.jsx("input",{id:"env-create-user",type:"text",value:G,onChange:ce=>U(ce.target.value),placeholder:"User (optional)...",className:se.fieldInput,"data-testid":"env-create-user"})]}),l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,htmlFor:"env-create-port",children:"SSH Port"}),l.jsx("input",{id:"env-create-port",type:"number",min:gc,max:vc,value:C,onChange:ce=>M(ce.target.value),placeholder:"SSH port (optional)...",className:se.fieldInput,"data-testid":"env-create-port"})]}),l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,htmlFor:"env-create-identity",children:"Identity File"}),l.jsx("input",{id:"env-create-identity",type:"text",value:V,onChange:ce=>Z(ce.target.value),placeholder:"Identity file (optional)...",className:se.fieldInput,"data-testid":"env-create-identity"})]})]}),w==="docker"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,htmlFor:"env-create-image",children:"Image"}),l.jsx("input",{id:"env-create-image",type:"text",value:ee,onChange:ce=>ie(ce.target.value),placeholder:"Image (optional)...",className:se.fieldInput,"data-testid":"env-create-image"})]}),l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,htmlFor:"env-create-repo",children:"Repo"}),l.jsx("input",{id:"env-create-repo",type:"text",value:be,onChange:ce=>K(ce.target.value),placeholder:"Repo (optional)...",className:se.fieldInput,"data-testid":"env-create-repo"})]})]}),w==="codespace"&&l.jsx(eL,{codespaceName:re,onCodespaceNameChange:I,envName:N,onEnvNameChange:j,codespaces:d,codespaceError:m,codespaceListError:h,codespaceCreating:g,onCreateCodespace:v})]})})]})}function tL(){const{environments:n,addEnvironment:s,updateEnvironment:i,listCodespaces:o,codespaces:c,codespaceError:u,codespaceListError:d,codespaceCreating:m,createCodespace:h}=pt();return l.jsx(Lx,{mode:"new",environments:n,onAddEnvironment:s,onUpdateEnvironment:i,onListCodespaces:o,codespaces:c,codespaceError:u,codespaceListError:d,codespaceCreating:m,onCreateCodespace:h})}function nL(){const{environmentId:n}=va(),{environments:s,addEnvironment:i,updateEnvironment:o,listCodespaces:c,codespaces:u,codespaceError:d,codespaceListError:m,codespaceCreating:h,createCodespace:g}=pt();return l.jsx(Lx,{mode:"edit",environmentId:n,environments:s,onAddEnvironment:i,onUpdateEnvironment:o,onListCodespaces:c,codespaces:u,codespaceError:d,codespaceListError:m,codespaceCreating:h,onCreateCodespace:g})}const sL="_layout_11u79_1",aL="_content_11u79_8",iL="_tabPanel_11u79_14",br={layout:sL,content:aL,tabPanel:iL};function oL(){const n=n5();return l.jsxs("div",{className:br.layout,children:[l.jsx(ba,{segments:n}),l.jsx("div",{className:br.content,children:l.jsx(Qa,{})})]})}const rL="_container_13sb6_1",lL="_envHeader_13sb6_6",cL="_envTitleRow_13sb6_10",uL="_statusDot_13sb6_16",dL="_envName_13sb6_21",fL="_statusBadge_13sb6_27",pL="_envMeta_13sb6_33",mL="_metaTag_13sb6_39",hL="_actions_13sb6_51",gL="_provisionMessage_13sb6_59",vL="_errorMessage_13sb6_64",yL="_section_13sb6_69",bL="_sectionHeader_13sb6_73",_L="_cardList_13sb6_121",xL="_card_13sb6_121",SL="_cardHeader_13sb6_138",TL="_cardName_13sb6_144",kL="_cardActions_13sb6_149",wL="_cardDescription_13sb6_154",NL="_cardMeta_13sb6_160",jL="_repoLink_13sb6_166",CL="_empty_13sb6_174",EL="_btnPrimary_13sb6_180",AL="_btnOutline_13sb6_214",DL="_btnSmall_13sb6_241",RL="_btnDanger_13sb6_267",$e={container:rL,envHeader:lL,envTitleRow:cL,statusDot:uL,envName:dL,statusBadge:fL,envMeta:pL,metaTag:mL,actions:hL,provisionMessage:gL,errorMessage:vL,section:yL,sectionHeader:bL,cardList:_L,card:xL,cardHeader:SL,cardName:TL,cardActions:kL,cardDescription:wL,cardMeta:NL,repoLink:jL,empty:CL,btnPrimary:EL,btnOutline:AL,btnSmall:DL,btnDanger:RL},ML={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function OL(){const{environmentId:n}=va(),s=St(),{environments:i,workspaces:o,sessions:c,provisionStatus:u,provisionEnvironment:d,stopEnvironment:m,removeEnvironment:h,archiveWorkspace:g}=pt(),[v,b]=y.useState(!1),[_,S]=y.useState(!1),[T,N]=y.useState(void 0),j=i.find(ie=>ie.id===n);if(!n||!j)return l.jsx(Zn,{to:Xi,replace:!0});const w=o.filter(ie=>ie.environmentId===j.id),E=c.filter(ie=>ie.environmentId===j.id),A=E.reduce((ie,be)=>ie+(be.costUsd??0),0),O=ML[j.status]||"var(--text-tertiary)",C=j.status==="connected",M=j.status==="connecting",G=j.status==="disconnected"||j.status==="error",U=j.id in u?u[j.id]:void 0,V=()=>{h(j.id),b(!1),s(Xi,{replace:!0})},Z=()=>{S(!1),d(j.id,!0)},ee=ie=>{g(ie),N(void 0)};return l.jsxs("div",{className:$e.container,children:[l.jsx(Ja,{isOpen:v,title:"Delete Environment?",description:`"${j.displayName||j.id}" will be permanently removed along with all its data.`,onConfirm:V,onCancel:()=>b(!1)}),l.jsx(Ja,{isOpen:_,title:"Reprovision Environment?",description:"This will kill any active session and force a fresh provision cycle. The environment will be temporarily disconnected.",confirmLabel:"Reprovision",onConfirm:Z,onCancel:()=>S(!1)}),l.jsxs("div",{className:$e.envHeader,children:[l.jsxs("div",{className:$e.envTitleRow,children:[l.jsx("span",{className:$e.statusDot,style:{color:O},children:"●"}),l.jsx("h2",{className:$e.envName,children:j.displayName||j.id}),l.jsx("span",{className:$e.statusBadge,style:{color:O},children:j.status})]}),l.jsxs("div",{className:$e.envMeta,children:[l.jsxs("span",{className:$e.metaTag,children:["Adapter: ",j.adapterType]}),E.length>0&&l.jsxs("span",{className:$e.metaTag,children:[E.length," session",E.length!==1?"s":""]}),A>0&&l.jsxs("span",{className:$e.metaTag,children:["Cost: ",so(A)]})]})]}),l.jsxs("div",{className:$e.actions,children:[C&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:$e.btnPrimary,onClick:()=>s(Cb(j.id)),children:"New Chat"}),l.jsx("button",{className:$e.btnOutline,onClick:()=>m(j.id),children:"Stop"}),l.jsx("button",{className:$e.btnOutline,onClick:()=>S(!0),disabled:U!==void 0,"data-testid":"env-reprovision-btn",children:"Reprovision"})]}),G&&l.jsx("button",{className:$e.btnPrimary,onClick:()=>d(j.id),children:j.status==="error"?"Retry":"Connect"}),M&&U!==void 0&&l.jsx("span",{className:$e.provisionMessage,children:U.message}),j.status==="error"&&(U==null?void 0:U.stage)==="error"&&l.jsx("span",{className:$e.errorMessage,children:U.message}),l.jsx("button",{className:$e.btnOutline,onClick:()=>s(l2(j.id)),"data-testid":"env-edit-btn",children:"Edit Config"}),l.jsx("button",{className:$e.btnDanger,onClick:()=>b(!0),children:"Delete"})]}),l.jsxs("div",{className:$e.section,children:[l.jsxs("div",{className:$e.sectionHeader,children:[l.jsx("h3",{children:"Workspaces"}),l.jsx("button",{className:$e.btnPrimary,onClick:()=>s(`${Ab}?environment=${encodeURIComponent(j.id)}`),"data-testid":"workspace-create-button",children:"+ New Workspace"})]}),w.length===0&&l.jsx("p",{className:$e.empty,children:"No workspaces yet. Create one to get started."}),l.jsx("div",{className:$e.cardList,children:w.map(ie=>l.jsx(IL,{workspace:ie,confirmArchiveId:T,onOpen:()=>s(Wi(ie.id,j.id)),onArchive:()=>N(ie.id),onConfirmArchive:()=>ee(ie.id),onCancelArchive:()=>N(void 0)},ie.id))})]})]})}function IL({workspace:n,confirmArchiveId:s,onOpen:i,onArchive:o,onConfirmArchive:c,onCancelArchive:u}){const d=s===n.id,m=n.repoUrl&&/^https?:\/\//.test(n.repoUrl);return l.jsxs("div",{className:$e.card,"data-testid":"workspace-card",children:[l.jsxs("div",{className:$e.cardHeader,children:[l.jsx("strong",{className:$e.cardName,children:n.name}),l.jsxs("div",{className:$e.cardActions,children:[l.jsx("button",{className:$e.btnSmall,onClick:i,children:"Open"}),d?l.jsxs(l.Fragment,{children:[l.jsx("button",{className:$e.btnDanger,onClick:c,children:"Confirm"}),l.jsx("button",{className:$e.btnSmall,onClick:u,children:"Cancel"})]}):l.jsx("button",{className:$e.btnSmall,onClick:o,children:"Archive"})]})]}),n.description&&l.jsx("p",{className:$e.cardDescription,children:n.description}),n.repoUrl&&l.jsx("div",{className:$e.cardMeta,children:m?l.jsx("a",{href:n.repoUrl,target:"_blank",rel:"noopener noreferrer",className:$e.repoLink,children:n.repoUrl}):l.jsx("span",{children:n.repoUrl})})]})}const BL={credentials:"Credentials",personas:"Personas",appearance:"Appearance",about:"About",shortcuts:"Shortcuts"};function LL(){const s=It().pathname.replace(/^\/settings\/?/,"").split("/")[0],i=BL[s],o=t5(i);return l.jsxs("div",{className:br.layout,children:[l.jsx(ba,{segments:o}),l.jsx("div",{className:br.content,children:l.jsx("div",{className:br.tabPanel,children:l.jsx(Qa,{})},s)})]})}const UL="_section_1ingb_14",zL="_sectionTitle_1ingb_26",PL="_sectionDescription_1ingb_35",VL="_tokenList_1ingb_48",qL="_tokenRow_1ingb_55",HL="_tokenBadge_1ingb_68",GL="_tokenName_1ingb_83",$L="_tokenTarget_1ingb_90",FL="_deleteButton_1ingb_99",ZL="_addForm_1ingb_113",KL="_formRow_1ingb_119",YL="_input_1ingb_125",JL="_select_1ingb_155",WL="_addButton_1ingb_187",XL="_emptyStateInfo_1ingb_221",QL="_themeOptions_1ingb_229",e8="_themeOption_1ingb_229",t8="_themeOptionSelected_1ingb_254",n8="_themeOptionHeader_1ingb_259",s8="_themeOptionLabel_1ingb_266",a8="_themeOptionDesc_1ingb_273",i8="_variantToggle_1ingb_279",o8="_variantButton_1ingb_286",r8="_variantActive_1ingb_305",l8="_themeSwatches_1ingb_311",c8="_themeSwatch_1ingb_311",u8="_systemToggle_1ingb_325",d8="_systemToggleHint_1ingb_341",f8="_themeActive_1ingb_348",p8="_aboutGrid_1ingb_354",m8="_aboutItem_1ingb_360",h8="_aboutLabel_1ingb_373",g8="_aboutValue_1ingb_379",v8="_aboutDot_1ingb_387",y8="_aboutDotConnected_1ingb_394",b8="_aboutDotDisconnected_1ingb_398",he={section:UL,sectionTitle:zL,sectionDescription:PL,tokenList:VL,tokenRow:qL,tokenBadge:HL,tokenName:GL,tokenTarget:$L,deleteButton:FL,addForm:ZL,formRow:KL,input:YL,select:JL,addButton:WL,emptyStateInfo:XL,themeOptions:QL,themeOption:e8,themeOptionSelected:t8,themeOptionHeader:n8,themeOptionLabel:s8,themeOptionDesc:a8,variantToggle:i8,variantButton:o8,variantActive:r8,themeSwatches:l8,themeSwatch:c8,systemToggle:u8,systemToggleHint:d8,themeActive:f8,aboutGrid:p8,aboutItem:m8,aboutLabel:h8,aboutValue:g8,aboutDot:v8,aboutDotConnected:y8,aboutDotDisconnected:b8},_8=[{key:"claude",label:"Claude",description:"Forward Claude credentials for AI agent access.",options:[{value:"off",label:"Off"},{value:"subscription",label:"Subscription"},{value:"api_key",label:"API Key"}]},{key:"github",label:"GitHub",description:"Forward GITHUB_TOKEN and GH_TOKEN for git operations.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"copilot",label:"Copilot",description:"Forward Copilot tokens (COPILOT_GITHUB_TOKEN, CLI config).",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"codex",label:"Codex",description:"Forward OPENAI_API_KEY for Codex/OpenAI access.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"goose",label:"Goose",description:"Forward Goose config and API keys for Goose agent access.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]}];function x8({credentialProviders:n,onUpdateCredentialProviders:s}){const i=(o,c)=>{const u={...n};o==="claude"?u.claude=c:u[o]=c,s(u)};return l.jsxs("section",{className:he.section,children:[l.jsx("h3",{className:he.sectionTitle,children:"Credential Providers"}),l.jsx("p",{className:he.sectionDescription,children:"Enable providers to automatically forward credentials to environments at task start. Credentials are read fresh from the host each time."}),l.jsx("div",{className:he.tokenList,children:_8.map(o=>l.jsxs("div",{className:he.tokenRow,children:[l.jsx("span",{className:he.tokenName,children:o.label}),l.jsx("span",{className:he.tokenTarget,children:o.description}),l.jsx("select",{className:he.select,value:n[o.key],onChange:c=>i(o.key,c.target.value),children:o.options.map(c=>l.jsx("option",{value:c.value,children:c.label},c.value))})]},o.key))})]})}const S8=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function T8({tokens:n,onSetToken:s,onDeleteToken:i}){const{showToast:o}=Bs(),[c,u]=y.useState(""),[d,m]=y.useState(""),[h,g]=y.useState("env_var"),[v,b]=y.useState(""),[_,S]=y.useState(null),T=w=>{if(w.preventDefault(),!c||!d)return;const E=h==="env_var"?v||c.toUpperCase()+"_TOKEN":"";s(c,d,h,E,h==="file"?v:""),o("Token saved successfully","success"),u(""),m(""),b("")},N=w=>{S(w)},j=()=>{_&&(i(_),o("Token deleted","info")),S(null)};return l.jsxs(l.Fragment,{children:[l.jsx(Ja,{isOpen:_!==null,title:"Delete Token?",description:_?`"${_}" will be permanently removed.`:void 0,onConfirm:j,onCancel:()=>S(null)}),l.jsxs("section",{className:he.section,children:[l.jsx("h3",{className:he.sectionTitle,children:"Tokens"}),l.jsx("p",{className:he.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),n.length===0?l.jsx("div",{className:he.emptyStateInfo,children:"Add your first API token to enable service integrations."}):l.jsx("div",{className:he.tokenList,children:n.map(w=>l.jsxs("div",{className:he.tokenRow,children:[l.jsx("span",{className:he.tokenBadge,children:w.tokenType}),l.jsx("span",{className:he.tokenName,children:w.name}),l.jsx("span",{className:he.tokenTarget,children:w.tokenType==="env_var"?w.envVar:w.filePath}),l.jsx("button",{className:he.deleteButton,onClick:()=>N(w.name),title:`Delete ${w.name}`,children:"×"})]},w.name))}),l.jsxs("form",{className:he.addForm,onSubmit:T,children:[l.jsxs("div",{className:he.formRow,children:[l.jsx("input",{className:he.input,type:"text",placeholder:"Token name",value:c,onChange:w=>u(w.target.value)}),l.jsx("input",{className:he.input,type:"password",placeholder:"Value",value:d,onChange:w=>m(w.target.value)})]}),l.jsxs("div",{className:he.formRow,children:[l.jsx("select",{className:he.select,value:h,onChange:w=>g(w.target.value),children:S8.map(w=>l.jsx("option",{value:w.value,children:w.label},w.value))}),l.jsx("input",{className:he.input,type:"text",placeholder:h==="env_var"?"Env var name (e.g. API_TOKEN)":"File path (e.g. /home/user/.token)",value:v,onChange:w=>b(w.target.value)}),l.jsx("button",{className:he.addButton,type:"submit",children:"Add Token"})]})]})]})]})}function k8(){const{tokens:n,setToken:s,deleteToken:i,credentialProviders:o,updateCredentialProviders:c}=pt();return l.jsxs(l.Fragment,{children:[l.jsx(x8,{credentialProviders:o,onUpdateCredentialProviders:c}),l.jsx(T8,{tokens:n,onSetToken:s,onDeleteToken:i})]})}const w8="_container_10efq_1",N8="_header_10efq_7",j8="_form_10efq_19",C8="_formActions_10efq_87",E8="_editableSection_10efq_94",A8="_list_10efq_105",D8="_card_10efq_111",R8="_cardHeader_10efq_125",M8="_cardTitle_10efq_135",O8="_defaultBadge_10efq_141",I8="_cardActions_10efq_155",B8="_description_10efq_160",L8="_meta_10efq_166",U8="_empty_10efq_212",z8="_typeToggle_10efq_348",P8="_typeBadge_10efq_362",V8="_scriptEditor_10efq_376",q8="_optional_10efq_383",gt={container:w8,header:N8,form:j8,formActions:C8,editableSection:E8,list:A8,card:D8,cardHeader:R8,cardTitle:M8,defaultBadge:O8,cardActions:I8,description:B8,meta:L8,empty:U8,typeToggle:z8,typeBadge:P8,scriptEditor:V8,optional:q8};function H8({personas:n,appDefaultPersonaId:s,onDeletePersona:i,onSetAppDefaultPersonaId:o,onNavigateToNew:c,onNavigateToPersona:u}){const[d,m]=y.useState(null),h=d?n.find(v=>v.id===d):void 0,g=async v=>{await i(v),m(null)};return l.jsxs("div",{className:gt.container,children:[l.jsxs("div",{className:gt.header,children:[l.jsx("h2",{children:"Personas"}),l.jsx(As,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),n.length===0?l.jsx("p",{className:gt.empty,children:"No personas yet. Create one to get started."}):l.jsx("div",{className:gt.list,children:n.map(v=>{const b=s===v.id,_=v.type==="script";return l.jsxs("div",{className:gt.card,"data-testid":`persona-card-${v.id}`,onClick:()=>u(v.id),role:"button",tabIndex:0,onKeyDown:S=>{S.currentTarget===S.target&&(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),u(v.id))},children:[l.jsxs("div",{className:gt.cardHeader,children:[l.jsxs("span",{className:gt.cardTitle,children:[l.jsx("strong",{children:v.name}),l.jsx("span",{className:gt.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:_?"Script":"Agent"}),b&&l.jsx("span",{className:gt.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),l.jsxs("div",{className:gt.cardActions,onClick:S=>S.stopPropagation(),children:[!b&&l.jsx(As,{variant:"ghost",size:"sm",onClick:()=>{o(v.id).catch(()=>{})},"data-testid":`persona-set-default-${v.id}`,title:"Set as app default persona",children:"Set Default"}),l.jsx(As,{variant:"ghost",size:"sm",onClick:()=>u(v.id),children:"Edit"}),l.jsx(As,{variant:"ghost",size:"sm",onClick:()=>m(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&l.jsx("p",{className:gt.description,children:v.description}),l.jsxs("div",{className:gt.meta,children:[v.runtime&&l.jsxs("span",{children:["Runtime: ",v.runtime]}),v.model&&l.jsxs("span",{children:["Model: ",v.model]}),v.maxTurns>0&&l.jsxs("span",{children:["Max turns: ",v.maxTurns]})]})]},v.id)})}),l.jsx(Ja,{isOpen:d!==null,title:"Delete Persona?",description:`"${(h==null?void 0:h.name)??""}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:()=>{d&&g(d).catch(()=>{})},onCancel:()=>m(null)})]})}function G8(){const{personas:n,deletePersona:s,appDefaultPersonaId:i,setAppDefaultPersonaId:o}=pt(),{showToast:c}=Bs(),u=St();return l.jsx(H8,{personas:n,appDefaultPersonaId:i,onDeletePersona:async d=>{try{await s(d)}catch(m){throw console.error("Failed to delete persona",{personaId:d,error:m}),c("Failed to delete persona","error"),m}},onSetAppDefaultPersonaId:async d=>{try{await o(d)}catch(m){console.error("Failed to set app default persona ID",{personaId:d,error:m}),c("Failed to set app default persona","error")}},onNavigateToNew:()=>u(u2),onNavigateToPersona:d=>u(Eb(d))})}const $8="_container_uy08i_1",F8="_header_uy08i_7",Z8="_count_uy08i_13",K8="_presets_uy08i_18",Y8="_presetButton_uy08i_24",J8="_filterInput_uy08i_41",W8="_groups_uy08i_53",X8="_group_uy08i_53",Q8="_groupHeader_uy08i_68",eU="_groupName_uy08i_77",tU="_groupCount_uy08i_81",nU="_toolList_uy08i_87",sU="_toolItem_uy08i_95",aU="_toolName_uy08i_103",en={container:$8,header:F8,count:Z8,presets:K8,presetButton:Y8,filterInput:J8,groups:W8,group:X8,groupHeader:Q8,groupName:eU,groupCount:tU,toolList:nU,toolItem:sU,toolName:aU},iU=(()=>{const n=new Map;for(const s of rb){const i=s==="get_version_status"?"version":s.split("_")[0];n.has(i)||n.set(i,[]),n.get(i).push(s)}return[...n.entries()].sort(([s],[i])=>s.localeCompare(i)).map(([s,i])=>({group:s,tools:i.sort()}))})(),oU=[{name:"default",label:"Default",tools:lb},{name:"worker",label:"Worker",tools:gT},{name:"orchestrator",label:"Orchestrator",tools:vT},{name:"admin",label:"Admin",tools:yT}];function eb({selectedTools:n,onChange:s,disabled:i}){const[o,c]=y.useState(""),u=y.useMemo(()=>new Set(n),[n]),d=y.useCallback(v=>{if(i)return;const b=new Set(u);b.has(v)?b.delete(v):b.add(v),s([...b].sort())},[u,s,i]),m=y.useCallback((v,b)=>{if(i)return;const _=new Set(u);for(const S of v)b?_.delete(S):_.add(S);s([..._].sort())},[u,s,i]),h=y.useCallback(v=>{i||s([...v].sort())},[s,i]),g=o.toLowerCase();return l.jsxs("div",{className:en.container,"data-testid":"mcp-tool-selector",children:[l.jsx("div",{className:en.header,children:l.jsx("span",{className:en.count,children:n.length===0?`Using default (${lb.length} tools)`:`${n.length} of ${rb.size} tools selected`})}),l.jsxs("div",{className:en.presets,"data-testid":"mcp-tool-presets",children:[oU.map(v=>l.jsx("button",{type:"button",className:en.presetButton,disabled:i,onClick:()=>h(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),l.jsx("button",{type:"button",className:en.presetButton,disabled:i,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),l.jsx("input",{type:"text",className:en.filterInput,placeholder:"Filter tools...",value:o,onChange:v=>c(v.target.value),disabled:i,"data-testid":"mcp-tool-filter"}),l.jsx("div",{className:en.groups,children:iU.map(({group:v,tools:b})=>{const _=g?b.filter(T=>T.toLowerCase().includes(g)):b;if(_.length===0)return null;const S=_.every(T=>u.has(T));return l.jsxs("div",{className:en.group,"data-testid":`tool-group-${v}`,children:[l.jsxs("label",{className:en.groupHeader,children:[l.jsx("input",{type:"checkbox",checked:S,onChange:()=>m(_,S),disabled:i,"data-testid":`group-toggle-${v}`}),l.jsx("span",{className:en.groupName,children:v}),l.jsxs("span",{className:en.groupCount,children:["(",_.filter(T=>u.has(T)).length,"/",_.length,")"]})]}),l.jsx("div",{className:en.toolList,children:_.map(T=>l.jsxs("label",{className:en.toolItem,children:[l.jsx("input",{type:"checkbox",checked:u.has(T),onChange:()=>d(T),disabled:i,"data-testid":`tool-${T}`}),l.jsx("span",{className:en.toolName,children:T})]},T))})]},v)})})]})}const tb=[{value:"claude-code",label:"claude-code"},{value:"codex",label:"codex"},{value:"copilot",label:"copilot"},{value:"goose",label:"goose"},{value:"stub",label:"stub"},{value:"claude-code-acp",label:"claude-code-acp (experimental)"},{value:"codex-acp",label:"codex-acp (experimental)"},{value:"copilot-acp",label:"copilot-acp (experimental)"}],nb=[{value:"genaiscript",label:"genaiscript"}],rU="0";function sb(){const{personaId:n}=va(),s=St(),{showToast:i}=Bs(),{personas:o,createPersona:c,updatePersona:u,deletePersona:d,appDefaultPersonaId:m,setAppDefaultPersonaId:h}=pt(),g=n===void 0,v=g?void 0:o.find(_=>_.id===n);if(!g&&o.length>0&&!v)return l.jsx(Zn,{to:af,replace:!0});const b=[{label:"Settings",url:Ji},{label:"Personas",url:af},{label:g?"New Persona":(v==null?void 0:v.name)??"Persona",url:void 0}];return l.jsxs("div",{className:gt.container,children:[l.jsx(ba,{segments:b}),l.jsx(lU,{existing:v,isNew:g,appDefaultPersonaId:m,onCreatePersona:c,onUpdatePersona:u,onDeletePersona:d,onSetAppDefaultPersonaId:h,onDone:()=>{s(af)},showToast:i})]})}function lU({existing:n,isNew:s,appDefaultPersonaId:i,onCreatePersona:o,onUpdatePersona:c,onDeletePersona:u,onSetAppDefaultPersonaId:d,onDone:m,showToast:h}){const g=St(),[v,b]=y.useState((n==null?void 0:n.name)??""),[_,S]=y.useState((n==null?void 0:n.description)??""),[T,N]=y.useState((n==null?void 0:n.systemPrompt)??""),[j,w]=y.useState((n==null?void 0:n.runtime)??"claude-code"),[E,A]=y.useState((n==null?void 0:n.model)??"sonnet"),[O,C]=y.useState((n==null?void 0:n.maxTurns)??0),[M,G]=y.useState((n==null?void 0:n.type)==="script"?"script":"agent"),[U,V]=y.useState((n==null?void 0:n.script)??""),[Z,ee]=y.useState((n==null?void 0:n.allowedMcpTools)??[]),[ie,be]=y.useState(!1),[K,re]=y.useState(null),[I,$]=y.useState(!!s);y.useEffect(()=>{if(!s&&n&&!I){$(!0),b(n.name),S(n.description),N(n.systemPrompt);const X=n.type==="script"?"script":"agent";w(X==="script"?n.runtime||"genaiscript":n.runtime),A(n.model),C(n.maxTurns),G(X),V(n.script||""),ee(n.allowedMcpTools)}},[s,n,I]);const Q=X=>{G(X),X==="script"?w("genaiscript"):j==="genaiscript"&&w("claude-code")},de=!s&&n===void 0,me=v.trim().length>0&&!de&&T.trim().length>0&&(M==="script"?U.trim().length>0:!!j&&!!E),ze=s&&me,je=!s&&i===(n==null?void 0:n.id),Ne=!s&&n&&!je&&M==="agent"&&!!j&&!!E,Ae=(X,Te)=>{if(!X.trim())return`${Te} is required`},ce=X=>{if(X.preventDefault(),!(de||!me)){if(n){c(n.id,v,_,T,j,E,O,M,U).then(()=>{h("Persona updated","success"),m()},()=>{h("Failed to save persona","error")});return}o(v,_,T,j,E,O,M,U,Z).then(Te=>{h("Persona created","success"),g(Eb(Te.id),{replace:!0})},()=>{h("Failed to save persona","error")})}},fe=()=>{n&&u(n.id).then(()=>{h("Persona deleted","success"),m()},()=>{h("Failed to delete persona","error")})},pe=async(X,Te,un,Ze)=>X().then(()=>{Te(),h(un,"success")},()=>{h(Ze,"error")}),Re=(X,Te)=>{if(!n)return;const un=X==="type"?String(Te):M,Ze=X==="runtime"?String(Te):X==="type"?String(Te)==="script"?"genaiscript":j==="genaiscript"?"claude-code":j:j,Kn=X==="model"?String(Te):E,Yn=X==="maxTurns"?Number(Te):O,zn=X==="systemPrompt"?String(Te):T,Jn=X==="script"?String(Te):U;pe(()=>c(n.id,X==="name"?String(Te):v,X==="description"?String(Te):_,zn,Ze,Kn,Yn,un,Jn),()=>{if(X==="type"){const Tn=String(Te)==="script"?"script":"agent";G(Tn),w(Ze)}X==="runtime"&&w(String(Te)),X==="name"&&b(String(Te)),X==="description"&&S(String(Te)),X==="systemPrompt"&&N(String(Te)),X==="model"&&A(String(Te)),X==="maxTurns"&&C(Number(Te)),X==="script"&&V(String(Te))},"Persona updated","Failed to update persona").catch(()=>{})},Bt=X=>{ce(X)},te=()=>{n&&d(n.id).then(()=>{h("Set as app default","success")},()=>{h("Failed to set app default","error")})};return l.jsxs(l.Fragment,{children:[de?l.jsxs("div",{className:gt.form,children:[l.jsx("h3",{children:"Edit Persona"}),l.jsx("p",{children:"Loading persona..."})]}):s?l.jsxs("form",{onSubmit:Bt,className:gt.form,children:[l.jsx("h3",{children:"Create Persona"}),l.jsxs("div",{className:gt.typeToggle,"data-testid":"persona-type-toggle",children:[l.jsxs("label",{children:[l.jsx("input",{type:"radio",name:"personaType",value:"agent",checked:M==="agent",onChange:()=>Q("agent")}),"Agent"]}),l.jsxs("label",{children:[l.jsx("input",{type:"radio",name:"personaType",value:"script",checked:M==="script",onChange:()=>Q("script")}),"Script"]})]}),l.jsxs("label",{children:["Name",l.jsx("input",{type:"text",value:v,onChange:X=>b(X.target.value),placeholder:M==="script"?"e.g. Nightly Report":"e.g. Frontend Engineer",required:!0,"data-testid":"persona-detail-name"})]}),l.jsxs("label",{children:["Description",l.jsx("input",{type:"text",value:_,onChange:X=>S(X.target.value),placeholder:"Brief description...","data-testid":"persona-detail-description"})]}),l.jsxs("label",{children:["Runtime",l.jsx("select",{value:j,onChange:X=>w(X.target.value),"data-testid":"persona-runtime-select",children:(M==="script"?nb:tb).map(X=>l.jsx("option",{value:X.value,children:X.label},X.value))})]}),M==="agent"&&l.jsxs(l.Fragment,{children:[l.jsxs("label",{children:["Model",l.jsx("input",{type:"text",value:E,onChange:X=>A(X.target.value),placeholder:"e.g. sonnet","data-testid":"persona-detail-model"})]}),l.jsxs("label",{children:["Max Turns",l.jsx("input",{type:"number",value:O,onChange:X=>C(parseInt(X.target.value,10)||0),min:0,"data-testid":"persona-detail-max-turns"})]}),l.jsxs("label",{children:["System Prompt",l.jsx("textarea",{value:T,onChange:X=>N(X.target.value),placeholder:"You are a senior frontend engineer...",rows:10,required:!0,"data-testid":"persona-detail-prompt"})]})]}),M==="script"&&l.jsxs(l.Fragment,{children:[l.jsxs("label",{children:["Model ",l.jsx("span",{className:gt.optional,children:"(optional)"}),l.jsx("input",{type:"text",value:E,onChange:X=>A(X.target.value),placeholder:"e.g. sonnet (leave empty for script-only)","data-testid":"persona-detail-model"})]}),l.jsxs("label",{children:["System Prompt",l.jsx("textarea",{value:T,onChange:X=>N(X.target.value),placeholder:"Context for the script...",rows:4,required:!0,"data-testid":"persona-detail-prompt"})]}),l.jsxs("label",{children:["Script",l.jsx("textarea",{value:U,onChange:X=>V(X.target.value),placeholder:`script({ model: "openai:gpt-4o" });
|
|
489
|
+
`);return l.jsxs("div",{className:xt.systemContextEvent,"data-testid":"system-context-event",children:[l.jsxs("button",{type:"button",className:xt.systemContextHeader,onClick:()=>{i(d=>!d)},"aria-expanded":s,children:[l.jsx("span",{className:xt.systemContextBadge,children:"SYSTEM PROMPT"}),c&&l.jsx("span",{className:xt.systemContextToggle,"aria-hidden":"true",children:s?"▾":"▸"})]}),l.jsxs("pre",{className:xt.systemContextPre,children:[u,!s&&c&&l.jsx("span",{className:xt.systemContextEllipsis,children:"…"})]})]})}function _3({time:n,content:s}){return l.jsxs("div",{className:xt.systemEvent,children:[l.jsxs("span",{className:xt.systemTimestamp,children:["[",n,"]"]})," ",s]})}function rp(n){return typeof n=="string"?n:typeof n=="number"?String(n):Array.isArray(n)?n.map(rp).join(""):n!=null&&typeof n=="object"&&"props"in n?rp(n.props.children):""}function x3({children:n,node:s,...i}){const o=rp(n);return l.jsxs("div",{className:xt.codeBlockWrapper,children:[l.jsx("pre",{...i,children:n}),l.jsx(ni,{text:o,"data-testid":"copy-code-block",className:xt.codeBlockCopyButton})]})}const S3={pre:x3};function T3({content:n}){const s=y.useRef(null),i=y.useCallback(()=>{if(!s.current)return;const o=s.current.cloneNode(!0);for(const c of o.querySelectorAll("[data-testid='copy-code-block']"))c.remove();return o.innerHTML},[]);return l.jsxs("div",{className:xt.textEvent,children:[l.jsx(ni,{text:n,getHtml:i,"data-testid":"copy-message",className:xt.messageCopyButton}),l.jsx("div",{ref:s,children:l.jsx(up,{remarkPlugins:[dp],rehypePlugins:[RR],components:S3,children:n})})]})}function k3({content:n}){return l.jsxs("div",{className:xt.errorEvent,children:["Error: ",n]})}function w3({content:n}){return l.jsxs("div",{className:xt.statusEvent,children:["--- ",n," ---"]})}function N3({content:n}){return l.jsx("div",{className:xt.userInputEvent,children:l.jsx("span",{className:xt.userInputContent,children:n})})}function j3({content:n}){return l.jsxs("div",{className:xt.signalEvent,"data-testid":"signal-event",children:[l.jsx("span",{className:xt.signalBadge,children:"SIGNAL"}),l.jsx("span",{className:xt.signalContent,children:n})]})}function C3({content:n}){let s=n;try{const i=JSON.parse(n),o=Number(i.input_tokens)||0,c=Number(i.output_tokens)||0,u=Ex(o+c),d=so(Number(i.cost_usd)||0);s=`${u} tokens · ${d}`}catch{}return l.jsx("div",{className:xt.usageEvent,"data-testid":"usage-event",children:l.jsx("span",{className:xt.usageBadge,children:s})})}function E3({content:n}){return l.jsx("div",{className:xt.defaultEvent,children:n})}function A3({event:n,toolUseCtx:s}){const i=new Date(n.timestamp).toLocaleTimeString();switch(n.eventType){case"system":{if(n.raw)try{if(JSON.parse(n.raw).systemContext===!0)return l.jsx(b3,{content:n.content})}catch{}return l.jsx(_3,{time:i,content:n.content})}case"text":case"output":return l.jsx(T3,{content:n.content});case"tool_use":{let o="",c={};try{const u=JSON.parse(n.content);o=u.tool||"",c=u.args}catch{}return l.jsx(Df,{tool:o,args:c})}case"tool_result":{let o=!1;if(n.raw)try{o=JSON.parse(n.raw).is_error===!0}catch{}let c=n.content;if(n.content.trimStart().startsWith("{"))try{const u=JSON.parse(n.content);typeof u.content=="string"&&(c=u.content)}catch{}return s?l.jsx(Df,{tool:s.tool,args:s.args,result:c,isError:o,detailedResult:s.detailedResult}):l.jsx(Df,{tool:"Tool output",args:void 0,result:c,isError:o})}case"error":return l.jsx(k3,{content:n.content});case"status":return l.jsx(w3,{content:n.content});case"user_input":return l.jsx(N3,{content:n.content});case"signal":return l.jsx(j3,{content:n.content});case"usage":return l.jsx(C3,{content:n.content});default:return l.jsx(E3,{content:n.content})}}const D3="_overlay_cmicx_1",R3="_dialog_cmicx_11",M3="_title_cmicx_30",O3="_description_cmicx_38",I3="_actions_cmicx_45",B3="_cancelButton_cmicx_52",L3="_confirmButton_cmicx_79",Va={overlay:D3,dialog:R3,title:M3,description:O3,actions:I3,cancelButton:B3,confirmButton:L3};function Ja({isOpen:n,title:s,description:i,confirmLabel:o="Delete",onConfirm:c,onCancel:u}){const d=y.useId(),m=y.useId();return l.jsx(rs,{children:n&&l.jsx(Rt.div,{className:Va.overlay,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},onClick:u,onKeyDown:h=>{h.key==="Escape"&&u()},role:"dialog","aria-modal":"true","aria-labelledby":d,"aria-describedby":i?m:void 0,children:l.jsxs(Rt.div,{className:Va.dialog,initial:{opacity:0,scale:.93,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.93,y:-10},transition:{duration:.15,ease:[.16,1,.3,1]},onClick:h=>h.stopPropagation(),children:[l.jsx("h3",{id:d,className:Va.title,children:s}),i&&l.jsx("p",{id:m,className:Va.description,children:i}),l.jsxs("div",{className:Va.actions,children:[l.jsx("button",{type:"button",className:Va.cancelButton,onClick:u,autoFocus:!0,children:"Cancel"}),l.jsx("button",{type:"button",className:Va.confirmButton,onClick:c,children:o})]})]})})})}const U3="_spinner_1uyt1_1",z3="_spin_1uyt1_1",P3="_sm_1uyt1_14",V3="_md_1uyt1_20",q3="_lg_1uyt1_26",H3="_xl_1uyt1_32",Fy={spinner:U3,spin:z3,sm:P3,md:V3,lg:q3,xl:H3};function Ax({size:n="md",className:s,label:i="Loading",liveRegion:o=!1}){return l.jsx("span",{className:`${Fy.spinner} ${Fy[n]} ${s??""}`,role:o?"status":void 0,"aria-label":i,"aria-hidden":o?void 0:!0})}const G3="_splash_1bn1g_1",$3="_logo_1bn1g_11",Zy={splash:G3,logo:$3};function Dx(){return l.jsxs("div",{className:Zy.splash,"data-testid":"splash-screen",children:[l.jsx("img",{src:"/grackle-logo.png",alt:"Grackle",className:Zy.logo}),l.jsx(Ax,{size:"xl",label:"Loading Grackle",liveRegion:!0})]})}function F3(n,s){const i=y.useRef(null);y.useEffect(()=>{const o=i.current;if(i.current=n,o===null)return;const c=new Map;for(const d of o)c.set(d.id,d);const u=new Set;for(const d of n){u.add(d.id);const m=c.get(d.id);if(m&&m.status!==d.status&&d.status!=="sleeping"){if(d.status==="connecting"){s("Provisioning environment…","info");continue}d.status==="connected"?s("Environment connected","success"):d.status==="error"?s("Environment provision failed","error"):d.status==="disconnected"&&(m.status==="connected"?s("Environment disconnected","warning"):s("Environment stopped","info"))}}for(const d of o)u.has(d.id)||s("Environment removed","info")},[n,s])}const Z3={working:{message:"Task is now running",variant:"info"},paused:{message:"Task paused",variant:"warning"},complete:{message:"Task complete",variant:"success"},failed:{message:"Task failed to complete",variant:"error"}};function K3(n){return Z3[n]}function Y3(n,s){if(n===void 0)return[];const i=[],o=new Map;for(const u of n)o.set(u.id,u);const c=new Set;for(const u of s){c.add(u.id);const d=o.get(u.id);if(!d||d.status===u.status)continue;const m=K3(u.status);m&&i.push(m)}for(const u of n)c.has(u.id)||i.push({message:"Task deleted",variant:"info"});return i}function J3(n,s){const i=y.useRef(void 0);y.useEffect(()=>{const o=i.current;i.current=n;const c=Y3(o,n);for(const u of c)s(u.message,u.variant)},[n,s])}function W3(n,s,i){const o=n.filter(h=>h.status==="running"||h.status==="idle"||h.status==="waiting").length,c=Rx(s),u=s.filter(h=>lp(h,c)).length,d=s.filter(h=>h.status==="paused"||h.status==="failed"||lp(h,c)).length,m=i.filter(h=>h.status==="disconnected"||h.status==="error").length;return{activeSessions:o,blockedTasks:u,attentionTasks:d,unhealthyEnvironments:m}}function Rx(n){const s=new Map;for(const i of n)s.set(i.id,i.status);return s}function lp(n,s){return n.dependsOn.some(i=>s.get(i)!=="complete")}function X3(n,s){var d;const i=new Map;for(const m of s)i.set(m.id,m);const o=Rx(n),c=[];for(const m of n){const h=m.workspaceId?((d=i.get(m.workspaceId))==null?void 0:d.name)??"Unknown":"Unknown";m.status==="failed"?c.push({task:m,reason:"failed",workspaceName:h}):lp(m,o)?c.push({task:m,reason:"blocked",workspaceName:h}):m.status==="paused"&&c.push({task:m,reason:"paused",workspaceName:h})}const u={failed:0,blocked:1,paused:2};return c.sort((m,h)=>(u[m.reason]??3)-(u[h.reason]??3)),c}function Q3(n,s){const i=new Map;for(const o of s)i.set(o.id,o);return n.filter(o=>o.status==="running"||o.status==="idle"||o.status==="waiting").map(o=>{var c;return{session:o,environmentName:((c=i.get(o.environmentId))==null?void 0:c.displayName)??"Unknown"}})}function e6(n,s,i){const o=new Map;for(const c of s){if(!c.workspaceId)continue;let u=o.get(c.workspaceId);u||(u={totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0},o.set(c.workspaceId,u)),u.totalTasks+=1,c.status==="complete"?u.completedTasks+=1:c.status==="working"?u.workingTasks+=1:c.status==="failed"&&(u.failedTasks+=1)}return n.map(c=>{const u=o.get(c.id)??{totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0};return{workspace:c,totalTasks:u.totalTasks,completedTasks:u.completedTasks,workingTasks:u.workingTasks,failedTasks:u.failedTasks}})}const t6="_dashboard_16pzm_1",n6="_kpiStrip_16pzm_11",s6="_kpiCard_16pzm_23",a6="_kpiValue_16pzm_68",i6="_kpiLabel_16pzm_76",o6="_bodyGrid_16pzm_84",r6="_section_16pzm_96",l6="_sectionHeader_16pzm_109",c6="_sectionIcon_16pzm_118",u6="_sectionTitle_16pzm_123",d6="_sectionCount_16pzm_131",f6="_sectionBody_16pzm_138",p6="_emptyHint_16pzm_143",m6="_sessionRow_16pzm_150",h6="_sessionPrompt_16pzm_177",g6="_sessionEnv_16pzm_186",v6="_sessionRuntime_16pzm_192",y6="_sessionStatus_16pzm_198",b6="_statusDot_16pzm_207",_6="_attentionRow_16pzm_233",x6="_attentionTitle_16pzm_259",S6="_attentionMeta_16pzm_267",T6="_reasonBadge_16pzm_274",k6="_bottomGrid_16pzm_301",w6="_envRow_16pzm_312",N6="_envName_16pzm_323",j6="_envStatusBadge_16pzm_333",C6="_workspaceRow_16pzm_369",E6="_workspaceTop_16pzm_395",A6="_workspaceName_16pzm_401",D6="_workspaceCounts_16pzm_407",R6="_progressBar_16pzm_415",M6="_progressFill_16pzm_422",xe={dashboard:t6,kpiStrip:n6,kpiCard:s6,kpiValue:a6,kpiLabel:i6,bodyGrid:o6,section:r6,sectionHeader:l6,sectionIcon:c6,sectionTitle:u6,sectionCount:d6,sectionBody:f6,emptyHint:p6,sessionRow:m6,sessionPrompt:h6,sessionEnv:g6,sessionRuntime:v6,sessionStatus:y6,statusDot:b6,attentionRow:_6,attentionTitle:x6,attentionMeta:S6,reasonBadge:T6,bottomGrid:k6,envRow:w6,envName:N6,envStatusBadge:j6,workspaceRow:C6,workspaceTop:E6,workspaceName:A6,workspaceCounts:D6,progressBar:R6,progressFill:M6},O6={hidden:{opacity:0,y:12},visible:n=>({opacity:1,y:0,transition:{delay:n*.06,duration:.3,ease:"easeOut"}})},rc={hidden:{opacity:0,y:16},visible:n=>({opacity:1,y:0,transition:{delay:.15+n*.08,duration:.35,ease:"easeOut"}})};function I6(n,s,i,o){const c=[`${n} of ${s} tasks completed`];return i>0&&c.push(`${i} in progress`),o>0&&c.push(`${o} failed`),c.join(", ")}function lc({value:n,label:s,accent:i,index:o,testId:c}){return l.jsxs(Rt.div,{className:xe.kpiCard,"data-accent":i,"data-testid":c,variants:O6,initial:"hidden",animate:"visible",custom:o,children:[l.jsx("span",{className:xe.kpiValue,children:n}),l.jsx("span",{className:xe.kpiLabel,children:s})]})}function B6(){const{workspaces:n,tasks:s,sessions:i,environments:o,loadTasks:c}=pt(),u=St(),d=y.useRef(new Set);y.useEffect(()=>{for(const b of n)d.current.has(b.id)||(d.current.add(b.id),c(b.id))},[n,c]);const m=y.useMemo(()=>W3(i,s,o),[i,s,o]),h=y.useMemo(()=>Q3(i,o),[i,o]),g=y.useMemo(()=>X3(s,n),[s,n]),v=y.useMemo(()=>e6(n,s),[n,s,o]);return l.jsxs("div",{className:xe.dashboard,"data-testid":"dashboard",children:[l.jsxs("div",{className:xe.kpiStrip,"data-testid":"dashboard-kpi-strip",children:[l.jsx(lc,{value:m.activeSessions,label:"Active Sessions",accent:"green",index:0,testId:"kpi-active-sessions"}),l.jsx(lc,{value:m.blockedTasks,label:"Blocked Tasks",accent:"yellow",index:1,testId:"kpi-blocked-tasks"}),l.jsx(lc,{value:m.attentionTasks,label:"Needs Attention",accent:"red",index:2,testId:"kpi-attention-tasks"}),l.jsx(lc,{value:m.unhealthyEnvironments,label:"Unhealthy Envs",accent:"blue",index:3,testId:"kpi-unhealthy-envs"})]}),l.jsxs("div",{className:xe.bodyGrid,children:[l.jsxs(Rt.div,{className:xe.section,variants:rc,initial:"hidden",animate:"visible",custom:0,"data-testid":"dashboard-active-sessions",children:[l.jsxs("div",{className:xe.sectionHeader,children:[l.jsx("span",{className:xe.sectionIcon,"aria-hidden":"true",children:"●"}),l.jsx("span",{className:xe.sectionTitle,children:"Active Sessions"}),l.jsx("span",{className:xe.sectionCount,children:h.length})]}),l.jsx("div",{className:xe.sectionBody,children:h.length===0?l.jsx("div",{className:xe.emptyHint,children:"No active sessions"}):h.map(({session:b,environmentName:_})=>l.jsxs("button",{type:"button",className:xe.sessionRow,onClick:()=>u(jb(b.id)),"data-testid":"session-row",children:[l.jsx("span",{className:xe.sessionPrompt,title:b.prompt,children:b.prompt||"—"}),l.jsx("span",{className:xe.sessionEnv,children:_}),l.jsx("span",{className:xe.sessionRuntime,children:b.runtime}),l.jsxs("span",{className:xe.sessionStatus,children:[l.jsx("span",{className:xe.statusDot,"data-status":b.status}),b.status]})]},b.id))})]}),l.jsxs(Rt.div,{className:xe.section,variants:rc,initial:"hidden",animate:"visible",custom:1,"data-testid":"dashboard-needs-attention",children:[l.jsxs("div",{className:xe.sectionHeader,children:[l.jsx("span",{className:xe.sectionIcon,"aria-hidden":"true",children:"⚑"}),l.jsx("span",{className:xe.sectionTitle,children:"Needs Attention"}),l.jsx("span",{className:xe.sectionCount,children:g.length})]}),l.jsx("div",{className:xe.sectionBody,children:g.length===0?l.jsx("div",{className:xe.emptyHint,children:"All clear"}):g.map(({task:b,reason:_,workspaceName:S})=>l.jsxs("button",{type:"button",className:xe.attentionRow,onClick:()=>u(os(b.id)),"data-testid":"attention-row",children:[l.jsxs("div",{className:xe.attentionTitle,children:[l.jsx("span",{className:xe.reasonBadge,"data-reason":_,children:_}),b.title]}),l.jsx("div",{className:xe.attentionMeta,children:l.jsx("span",{children:S})})]},b.id))})]})]}),l.jsxs("div",{className:xe.bottomGrid,children:[l.jsxs(Rt.div,{className:xe.section,variants:rc,initial:"hidden",animate:"visible",custom:2,"data-testid":"dashboard-env-health",children:[l.jsxs("div",{className:xe.sectionHeader,children:[l.jsx("span",{className:xe.sectionIcon,"aria-hidden":"true",children:"◈"}),l.jsx("span",{className:xe.sectionTitle,children:"Environment Health"}),l.jsx("span",{className:xe.sectionCount,children:o.length})]}),l.jsx("div",{className:xe.sectionBody,children:o.length===0?l.jsx("div",{className:xe.emptyHint,children:"No environments configured"}):o.map(b=>l.jsxs("div",{className:xe.envRow,"data-testid":"dashboard-env-row",children:[l.jsx("span",{className:xe.envName,children:b.displayName}),l.jsx("span",{className:xe.envStatusBadge,"data-status":b.status,children:b.status})]},b.id))})]}),l.jsxs(Rt.div,{className:xe.section,variants:rc,initial:"hidden",animate:"visible",custom:3,"data-testid":"dashboard-workspace-snapshot",children:[l.jsxs("div",{className:xe.sectionHeader,children:[l.jsx("span",{className:xe.sectionIcon,"aria-hidden":"true",children:"▦"}),l.jsx("span",{className:xe.sectionTitle,children:"Workspaces"}),l.jsx("span",{className:xe.sectionCount,children:n.length})]}),l.jsx("div",{className:xe.sectionBody,children:v.length===0?l.jsx("div",{className:xe.emptyHint,children:"No workspaces yet"}):v.map(({workspace:b,totalTasks:_,completedTasks:S,workingTasks:T,failedTasks:N})=>{const j=_>0?Math.round(S/_*100):0;return l.jsxs("button",{type:"button",className:xe.workspaceRow,onClick:()=>u(Wi(b.id,b.environmentId)),"data-testid":"workspace-row",children:[l.jsxs("div",{className:xe.workspaceTop,children:[l.jsx("span",{className:xe.workspaceName,children:b.name}),l.jsxs("span",{className:xe.workspaceCounts,"aria-label":I6(S,_,T,N),children:[S,"/",_,T>0&&l.jsxs("span",{style:{color:"var(--accent-green)"},"aria-hidden":"true",children:["▸",T]}),N>0&&l.jsxs("span",{style:{color:"var(--accent-red)"},"aria-hidden":"true",children:["✗",N]})]})]}),_>0&&l.jsx("div",{className:xe.progressBar,children:l.jsx("div",{className:xe.progressFill,style:{width:`${j}%`}})})]},b.id)})})]})]})]})}const L6="_panelContainer_1h5qd_1",U6="_emptyState_1h5qd_8",z6="_fadeIn_1h5qd_1",P6="_workspaceSummary_1h5qd_17",V6="_workspaceSummaryTitle_1h5qd_28",q6="_workspaceSummarySubtitle_1h5qd_32",H6="_header_1h5qd_36",G6="_headerInfo_1h5qd_71",$6="_killButton_1h5qd_77",F6="_headerTitle_1h5qd_106",Z6="_headerActions_1h5qd_121",K6="_taskStatusBadge_1h5qd_128",Y6="_taskBranch_1h5qd_137",J6="_taskBlockedBadge_1h5qd_143",W6="_btnPrimary_1h5qd_151",X6="_btnDanger_1h5qd_182",Q6="_btnGhost_1h5qd_221",eO="_rejectInput_1h5qd_247",tO="_tabBar_1h5qd_277",nO="_tab_1h5qd_277",sO="_active_1h5qd_303",aO="_eventScroll_1h5qd_308",iO="_tabContent_1h5qd_314",oO="_noContext_1h5qd_319",rO="_overviewContent_1h5qd_325",lO="_overviewDashboard_1h5qd_334",cO="_overviewHero_1h5qd_340",uO="_statusBadge_1h5qd_347",dO="_statusPending_1h5qd_359",fO="_statusAssigned_1h5qd_364",pO="_statusInProgress_1h5qd_369",mO="_statusReview_1h5qd_374",hO="_statusDone_1h5qd_379",gO="_statusFailed_1h5qd_384",vO="_statusWaitingInput_1h5qd_389",yO="_overviewBranchPill_1h5qd_394",bO="_branchLink_1h5qd_409",_O="_overviewSection_1h5qd_420",xO="_overviewLabel_1h5qd_426",SO="_overviewValue_1h5qd_433",TO="_overviewMuted_1h5qd_438",kO="_overviewMarkdown_1h5qd_444",wO="_envRow_1h5qd_513",NO="_envDot_1h5qd_519",jO="_envDotGreen_1h5qd_526",CO="_envDotYellow_1h5qd_530",EO="_envDotRed_1h5qd_534",AO="_envDotGray_1h5qd_538",DO="_depList_1h5qd_542",RO="_depItem_1h5qd_548",MO="_depBlocked_1h5qd_555",OO="_depDone_1h5qd_559",IO="_timeline_1h5qd_563",BO="_timelineRow_1h5qd_569",LO="_timelineKey_1h5qd_576",UO="_timelineValue_1h5qd_582",zO="_timelineDelta_1h5qd_586",PO="_reviewNotes_1h5qd_597",VO="_overviewDescription_1h5qd_608",qO="_waitingMessage_1h5qd_614",HO="_errorMessage_1h5qd_618",GO="_eventOverflowWarning_1h5qd_622",$O="_attemptSelector_1h5qd_636",FO="_attemptLabel_1h5qd_652",ZO="_attemptButton_1h5qd_656",KO="_attemptActive_1h5qd_673",YO="_attemptStatus_1h5qd_679",JO="_emptyCta_1h5qd_685",WO="_ctaTitle_1h5qd_697",XO="_ctaDescription_1h5qd_703",QO="_ctaButton_1h5qd_710",eI="_ctaCreateForm_1h5qd_745",tI="_ctaCreateInput_1h5qd_751",nI="_ctaCreateOk_1h5qd_782",sI="_ctaLink_1h5qd_817",aI="_workspaceHeader_1h5qd_831",iI="_workspaceName_1h5qd_856",oI="_workspaceMeta_1h5qd_869",rI="_metaRow_1h5qd_877",lI="_metaLabel_1h5qd_890",cI="_metaValue_1h5qd_905",uI="_archiveButton_1h5qd_915",dI="_repoLink_1h5qd_945",fI="_metaToggle_1h5qd_955",pI="_metaToggleArrow_1h5qd_976",mI="_metaToggleArrowOpen_1h5qd_981",hI="_progressBarContainer_1h5qd_985",gI="_progressBar_1h5qd_985",vI="_progressFill_1h5qd_1001",yI="_progressLabel_1h5qd_1008",bI="_metaTimestamps_1h5qd_1015",_I="_metaTimestamp_1h5qd_1015",L={panelContainer:L6,emptyState:U6,fadeIn:z6,workspaceSummary:P6,workspaceSummaryTitle:V6,workspaceSummarySubtitle:q6,header:H6,headerInfo:G6,killButton:$6,headerTitle:F6,headerActions:Z6,taskStatusBadge:K6,taskBranch:Y6,taskBlockedBadge:J6,btnPrimary:W6,btnDanger:X6,btnGhost:Q6,rejectInput:eO,tabBar:tO,tab:nO,active:sO,eventScroll:aO,tabContent:iO,noContext:oO,overviewContent:rO,overviewDashboard:lO,overviewHero:cO,statusBadge:uO,statusPending:dO,statusAssigned:fO,statusInProgress:pO,statusReview:mO,statusDone:hO,statusFailed:gO,statusWaitingInput:vO,overviewBranchPill:yO,branchLink:bO,overviewSection:_O,overviewLabel:xO,overviewValue:SO,overviewMuted:TO,overviewMarkdown:kO,envRow:wO,envDot:NO,envDotGreen:jO,envDotYellow:CO,envDotRed:EO,envDotGray:AO,depList:DO,depItem:RO,depBlocked:MO,depDone:OO,timeline:IO,timelineRow:BO,timelineKey:LO,timelineValue:UO,timelineDelta:zO,reviewNotes:PO,overviewDescription:VO,waitingMessage:qO,errorMessage:HO,eventOverflowWarning:GO,attemptSelector:$O,attemptLabel:FO,attemptButton:ZO,attemptActive:KO,attemptStatus:YO,emptyCta:JO,ctaTitle:WO,ctaDescription:XO,ctaButton:QO,ctaCreateForm:eI,ctaCreateInput:tI,ctaCreateOk:nI,ctaLink:sI,workspaceHeader:aI,workspaceName:iI,workspaceMeta:oI,metaRow:rI,metaLabel:lI,metaValue:cI,archiveButton:uI,repoLink:dI,metaToggle:fI,metaToggleArrow:pI,metaToggleArrowOpen:mI,progressBarContainer:hI,progressBar:gI,progressFill:vI,progressLabel:yI,metaTimestamps:bI,metaTimestamp:_I};function xI(){return l.jsx("div",{className:L.emptyState,children:"Select a task or click + to create one"})}function SI(){return l.jsx("div",{className:L.emptyState,children:"Select an environment to manage its workspaces, or add a new one."})}function TI(){const{workspaces:n,environments:s}=pt(),i=St(),o=s.length>0;return n.length>0?l.jsx(B6,{}):l.jsxs("div",{className:L.emptyCta,"data-testid":"welcome-cta",children:[l.jsx("div",{className:L.ctaTitle,children:"Welcome to Grackle"}),l.jsx("div",{className:L.ctaDescription,children:"Organize your work into workspaces and let agents tackle the tasks."}),l.jsx("button",{className:L.ctaButton,onClick:()=>i(Ab),disabled:!o,"data-testid":"welcome-create-button",children:"Create Your First Workspace"}),!o&&l.jsx("div",{className:L.ctaDescription,children:"Add an environment first before creating a workspace."})]})}const Mx=50;function kI(n,s,i,o,c=Mx){return o?n<c:s-n-i<c}function wI(n,s){const i=s-n;return i>0?i:0}function NI({scrollRef:n,contentLength:s,isReversed:i}){const[o,c]=y.useState(!0),u=y.useRef(0),d=y.useRef(!1),m=y.useRef(0);y.useEffect(()=>{const g=n.current;if(!g)return;let v=!0;const b=()=>{m.current||(m.current=requestAnimationFrame(()=>{m.current=0;const _=kI(g.scrollTop,g.scrollHeight,g.clientHeight,i,Mx);_!==v&&(v=_,c(_))}))};return g.addEventListener("scroll",b,{passive:!0}),()=>{g.removeEventListener("scroll",b),m.current&&(cancelAnimationFrame(m.current),m.current=0)}},[n,i]),y.useLayoutEffect(()=>{const g=n.current;!g||d.current||(d.current=!0,i?g.scrollTop=0:g.scrollTop=g.scrollHeight,c(!0))},[n,i]),y.useLayoutEffect(()=>{const g=n.current;if(g){if(i&&!o){const v=wI(u.current,g.scrollHeight);v>0&&(g.scrollTop+=v)}o&&(i?g.scrollTo({top:0,behavior:"smooth"}):g.scrollTo({top:g.scrollHeight,behavior:"smooth"})),u.current=g.scrollHeight}},[s,o,i,n]);const h=y.useCallback(()=>{const g=n.current;if(!g)return;const v=i?0:g.scrollHeight;g.scrollTo({top:v,behavior:"smooth"}),c(!0)},[n,i]);return{isAtAnchor:o,scrollToAnchor:h}}const jI="_wrapper_p24zt_1",CI="_scrollContainer_p24zt_9",EI="_toolbar_p24zt_15",AI="_directionToggle_p24zt_22",DI="_scrollToAnchor_p24zt_60",RI="_scrollToAnchorBottom_p24zt_84",MI="_scrollToAnchorTop_p24zt_88",qa={wrapper:jI,scrollContainer:CI,toolbar:EI,directionToggle:AI,scrollToAnchor:DI,scrollToAnchorBottom:RI,scrollToAnchorTop:MI},Ox="grackle-stream-direction";function OI(){try{return localStorage.getItem(Ox)==="reversed"}catch{return!1}}function II({eventsDropped:n}){return n<=0?l.jsx(l.Fragment,{}):l.jsxs("div",{className:L.eventOverflowWarning,role:"alert",children:["⚠"," ",n.toLocaleString()," older event",n===1?"":"s"," were dropped — only the most recent 5,000 are shown. Full history is available in the session log."]})}function sm({events:n,eventsDropped:s,emptyState:i}){const o=y.useRef(null),[c,u]=y.useState(OI),d=eA(),m=y.useMemo(()=>c?[...n].reverse():n,[n,c]),{isAtAnchor:h,scrollToAnchor:g}=NI({scrollRef:o,contentLength:n.length,isReversed:c}),v=()=>{const S=!c;u(S);try{localStorage.setItem(Ox,S?"reversed":"default")}catch{}},b=d?0:.2,_=c?-8:8;return l.jsxs("div",{className:qa.wrapper,children:[l.jsx("div",{className:qa.toolbar,children:l.jsx("button",{className:qa.directionToggle,onClick:v,title:c?"Showing newest first":"Showing oldest first","aria-label":c?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:c?"↓":"↑"})}),l.jsxs("div",{ref:o,className:qa.scrollContainer,"data-testid":"event-stream-scroll",children:[n.length===0&&i,l.jsx(II,{eventsDropped:s}),l.jsx(rs,{initial:!1,children:m.map((S,T)=>{const N=c?n.length-1-T:T;return l.jsx(Rt.div,{initial:{opacity:0,y:_},animate:{opacity:1,y:0},transition:{duration:b,ease:"easeOut"},children:l.jsx(A3,{event:S,toolUseCtx:S.toolUseCtx})},`${S.sessionId}-${S.timestamp}-${N}`)})})]}),l.jsx(rs,{children:!h&&l.jsxs(Rt.button,{className:`${qa.scrollToAnchor} ${c?qa.scrollToAnchorTop:qa.scrollToAnchorBottom}`,onClick:g,initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.15},"aria-label":"Scroll to latest","data-testid":"scroll-to-anchor",children:[c?"↑":"↓"," New events"]})})]})}const BI="_bar_1xhb4_1",LI="_input_1xhb4_32",UI="_select_1xhb4_67",zI="_btnPrimary_1xhb4_103",PI="_btnGhost_1xhb4_173",VI="_badge_1xhb4_195",qI="_disconnectHint_1xhb4_205",bn={bar:BI,input:LI,select:UI,btnPrimary:zI,btnGhost:PI,badge:VI,disconnectHint:qI};function HI(n,s){if(!n)return!1;const i=s.find(o=>o.id===n);return i!==void 0&&(i.status==="disconnected"||i.status==="error")}function GI({environmentId:n,onReconnect:s}){return l.jsxs(l.Fragment,{children:[l.jsx("span",{className:bn.disconnectHint,"data-testid":"env-disconnect-hint",children:"Environment unavailable"}),l.jsx("button",{type:"button",onClick:()=>s(n),className:bn.btnGhost,"data-testid":"reconnect-btn",title:"Reconnect the environment to resume messaging",children:"Reconnect"})]})}function jr({mode:n,sessionId:s,environmentId:i,taskId:o,showPersonaSelect:c,personas:u,environments:d,onSendInput:m,onSpawn:h,onStartTask:g,onProvisionEnvironment:v}){const{showToast:b}=Bs(),[_,S]=y.useState(""),[T,N]=y.useState(""),j=HI(i,d),w=E=>{if(E.preventDefault(),!!_.trim())if(n==="send"){if(!s||j)return;m(s,_),S("")}else if(n==="spawn"){if(!i)return;h(i,_,T),b("Session started","success"),S(""),N("")}else{if(!o)return;g(o,void 0,i,_),S("")}};return n==="spawn"?l.jsxs("form",{onSubmit:w,className:bn.bar,children:[l.jsx("span",{className:bn.badge,children:"new chat"}),l.jsx("input",{type:"text",value:_,onChange:E=>S(E.target.value),placeholder:"Enter prompt...",autoFocus:!0,className:bn.input}),c&&l.jsxs("select",{value:T,onChange:E=>N(E.target.value),className:bn.select,children:[l.jsx("option",{value:"",children:"(Default)"}),u.map(E=>l.jsx("option",{value:E.id,children:E.name},E.id))]}),l.jsx("button",{type:"submit",disabled:!_.trim()||!i,className:bn.btnPrimary,children:"Go"})]}):n==="start"?l.jsxs("form",{onSubmit:w,className:bn.bar,children:[l.jsx("input",{type:"text",value:_,onChange:E=>S(E.target.value),placeholder:"Type a message...",autoFocus:!0,className:bn.input}),l.jsx("button",{type:"submit",disabled:!_.trim(),className:bn.btnPrimary,children:"Send"})]}):l.jsxs("form",{onSubmit:w,className:bn.bar,children:[j&&i&&l.jsx(GI,{environmentId:i,onReconnect:v}),l.jsx("input",{type:"text",value:_,onChange:E=>S(E.target.value),placeholder:"Type a message...",autoFocus:!j,disabled:j,className:bn.input}),l.jsx("span",{title:j?"Environment is unavailable — reconnect first":void 0,children:l.jsx("button",{type:"submit",disabled:!_.trim()||j,className:bn.btnPrimary,children:"Send"})})]})}function am(n){const s=[];for(const i of n){const o=s[s.length-1];i.eventType==="text"&&(o==null?void 0:o.eventType)==="text"?s[s.length-1]={...o,content:o.content+i.content}:s.push(i)}return s}function im(n){const s=new Map;for(const u of n)if(u.raw)try{s.set(u,JSON.parse(u.raw))}catch{}const i=new Map;for(const u of n){if(u.eventType!=="tool_use")continue;const d=s.get(u);if(!(!d||typeof d.id!="string"))try{const m=JSON.parse(u.content);i.set(d.id,{tool:m.tool,args:m.args})}catch{}}const o=new Set;return n.map(u=>{if(u.eventType!=="tool_result")return u;const d=s.get(u);if(!d||typeof d.tool_use_id!="string")return u;const m=i.get(d.tool_use_id);if(!m)return u;o.add(d.tool_use_id);let h;const g=u.content.trim();if(g.startsWith("{"))try{const v=JSON.parse(g);typeof v.detailedContent=="string"&&(h=v.detailedContent)}catch{}return{...u,toolUseCtx:{...m,detailedResult:h}}}).filter(u=>{if(u.eventType!=="tool_use")return!0;const d=s.get(u);return d&&typeof d.id=="string"?!o.has(d.id):!0})}const $I="_panelContainer_19poq_1",FI="_chatHeader_19poq_8",ZI="_chatHeaderInfo_19poq_37",KI="_emptyState_19poq_43",YI="_emptyTitle_19poq_55",JI="_emptyDescription_19poq_61",WI="_emptyHint_19poq_67",Za={panelContainer:$I,chatHeader:FI,chatHeaderInfo:ZI,emptyState:KI,emptyTitle:YI,emptyDescription:JI,emptyHint:WI};function XI({hasLocalEnvironment:n}){return l.jsxs("div",{className:Za.emptyState,"data-testid":"chat-empty-state",children:[l.jsx("div",{className:Za.emptyTitle,children:"Welcome to Grackle"}),l.jsx("div",{className:Za.emptyDescription,children:n?"Type a message below to start chatting with the System agent. It can help you plan work, create tasks, and coordinate agents.":"Add a local environment in Settings to start chatting."}),!n&&l.jsx("div",{className:Za.emptyHint,children:"Go to Settings → Environments to add one."})]})}function QI(){const{tasks:n,sessions:s,events:i,eventsDropped:o,environments:c,loadTaskSessions:u,loadSessionEvents:d,kill:m,stopGraceful:h,taskSessions:g,sendInput:v,spawn:b,startTask:_,personas:S,provisionEnvironment:T}=pt(),N=y.useRef(void 0),[j,w]=y.useState(),E=n.find(V=>V.id===nr),A=E!=null&&E.latestSessionId?s.find(V=>V.id===E.latestSessionId)??(g[nr]??[]).find(V=>V.id===E.latestSessionId):void 0;y.useEffect(()=>{u(nr)},[u]),y.useEffect(()=>{E!=null&&E.latestSessionId&&u(nr)},[E==null?void 0:E.latestSessionId,u]),y.useEffect(()=>{A&&A.id!==N.current&&(N.current=A.id,d(A.id))},[A==null?void 0:A.id,d]);const O=y.useMemo(()=>{if(!A)return[];const V=i.filter(Z=>Z.sessionId===A.id);return im(am(V))},[i,A==null?void 0:A.id]),C=c.find(V=>V.adapterType==="local"&&V.status==="connected"),M=A!==void 0&&A.status!=="stopped"&&A.status!=="suspended",G=(A==null?void 0:A.status)==="idle";y.useEffect(()=>{j&&A&&G&&(v(A.id,j),w(void 0))},[j,G,A==null?void 0:A.id,v]);const U=y.useCallback((V,Z,ee,ie)=>{ie&&w(ie),_(V,Z,ee)},[_]);return l.jsxs("div",{className:Za.panelContainer,"data-testid":"chat-page",children:[M&&l.jsxs("div",{className:Za.chatHeader,children:[l.jsxs("span",{className:Za.chatHeaderInfo,children:["Session: ",A.id.slice(0,8)," | ",A.runtime," | ",A.status]}),l.jsx(Cx,{label:"Stop",onClick:()=>h(A.id),variant:"danger",size:"sm","data-testid":"stop-split-button",options:[{label:"Stop",description:"Graceful shutdown",onClick:()=>h(A.id)},{label:"Kill",description:"Force kill",onClick:()=>m(A.id)}]})]}),l.jsx(sm,{events:O,eventsDropped:o,emptyState:l.jsx(XI,{hasLocalEnvironment:!!C})}),C&&M&&l.jsx(jr,{mode:"send",sessionId:A.id,environmentId:A.environmentId,personas:S,environments:c,onSendInput:v,onSpawn:b,onStartTask:_,onProvisionEnvironment:T}),C&&!M&&l.jsx(jr,{mode:"start",taskId:nr,environmentId:C.id,personas:S,environments:c,onSendInput:v,onSpawn:b,onStartTask:U,onProvisionEnvironment:T})]})}function e5(n,s){const i=[];let o=n;const c=new Set;for(;o&&s.has(o)&&!c.has(o);){c.add(o);const u=s.get(o);i.unshift(u),o=u.parentTaskId||void 0}return i}const Wa={label:"Home",url:Ya};function t5(n){return n?[Wa,{label:"Settings",url:Ji},{label:n,url:void 0}]:[Wa,{label:"Settings",url:void 0}]}const Ix={label:"Environments",url:Xi};function n5(){return[Wa,{label:"Environments",url:void 0}]}function s5(){return[Wa,{label:"New Chat",url:void 0}]}function a5(n){return[Wa,{label:`Session ${n.slice(0,8)}`,url:void 0}]}function i5(n,s,i,o){const c=i.find(d=>d.id===n),u=o.find(d=>d.id===s);return[Wa,Ix,{label:(u==null?void 0:u.displayName)??"Environment",url:Qi(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function o5(n,s,i,o,c){const u=e5(n,c),d=c.get(n),m=d==null?void 0:d.workspaceId,h=m?i.find(S=>S.id===m):void 0,g=s??(h==null?void 0:h.environmentId),v=g?o.find(S=>S.id===g):void 0,b=[Wa];v&&g&&(b.push(Ix),b.push({label:v.displayName,url:Qi(g)})),h&&g&&b.push({label:h.name,url:Wi(h.id,g)});for(let S=0;S<u.length-1;S++)b.push({label:u[S].title,url:os(u[S].id,void 0,m,g)});const _=u[u.length-1];return b.push({label:(_==null?void 0:_.title)??n,url:void 0}),b}function r5(){const n=s5(),[s]=bp(),i=s.get("env")??"",{sendInput:o,spawn:c,startTask:u,personas:d,environments:m,provisionEnvironment:h}=pt();return l.jsxs("div",{className:L.panelContainer,children:[l.jsx(ba,{segments:n}),l.jsx("div",{className:L.emptyState,children:"Enter a prompt below to start a new session"}),l.jsx(jr,{mode:"spawn",environmentId:i,showPersonaSelect:!0,personas:d,environments:m,onSendInput:o,onSpawn:c,onStartTask:u,onProvisionEnvironment:h})]})}function l5({sessionId:n,session:s,isActive:i,onStop:o,onKill:c}){return l.jsxs("div",{className:L.header,children:[l.jsxs("span",{children:["Session: ",n.slice(0,8),s&&` | ${s.runtime} | ${s.endReason||s.status}`,s!=null&&s.inputTokens||s!=null&&s.outputTokens||s!=null&&s.costUsd?` | ${Ex((s.inputTokens??0)+(s.outputTokens??0))} tokens · ${so(s.costUsd??0)}`:""]}),l.jsxs("span",{className:L.headerInfo,children:[s&&l.jsx("span",{children:s.prompt.length>60?s.prompt.slice(0,60)+"...":s.prompt}),i&&l.jsx(Cx,{label:"Stop",onClick:o,variant:"danger",size:"sm","data-testid":"stop-split-button",options:[{label:"Stop",description:"Graceful shutdown",onClick:o},{label:"Kill",description:"Force kill",onClick:c}]})]})]})}function c5({session:n}){const s=n&&(n.status==="stopped"||n.status==="suspended"),i=s?`Session ${n.endReason||n.status} with no events recorded.`:"Waiting for events...";return l.jsx("div",{className:s?L.errorMessage:L.waitingMessage,children:i})}function u5(){const{sessionId:n}=va(),{events:s,eventsDropped:i,sessions:o,kill:c,stopGraceful:u,loadSessionEvents:d,sendInput:m,spawn:h,startTask:g,personas:v,environments:b,provisionEnvironment:_}=pt(),S=y.useRef(void 0),T=a5(n),N=o.find(E=>E.id===n)??void 0,j=y.useMemo(()=>{const E=n?s.filter(A=>A.sessionId===n):[];return im(am(E))},[s,n]);if(y.useEffect(()=>{n&&n!==S.current&&(S.current=n,d(n))},[n,d]),!n)return l.jsx("div",{className:L.emptyState,children:"No session selected"});const w=(N==null?void 0:N.status)==="running"||(N==null?void 0:N.status)==="idle";return l.jsxs("div",{className:L.panelContainer,children:[l.jsx(ba,{segments:T}),l.jsx(l5,{sessionId:n,session:N,isActive:w,onStop:()=>u(n),onKill:()=>c(n)}),l.jsx(sm,{events:j,eventsDropped:i,emptyState:l.jsx(c5,{session:N})}),w&&l.jsx(jr,{mode:"send",sessionId:n,environmentId:N.environmentId,personas:v,environments:b,onSendInput:m,onSpawn:h,onStartTask:g,onProvisionEnvironment:_})]})}function d5(n){if(!n)return!1;const s=n.tagName;return!!(s==="INPUT"||s==="TEXTAREA"||s==="SELECT"||n.isContentEditable)}function Ms(n,s){const i=y.useRef(s);i.current=s;const{key:o,ctrl:c=!1,shift:u=!1,suppressInInputs:d=!0,enabled:m=!0}=n;y.useEffect(()=>{if(!m)return;const h=g=>{if(d&&d5(document.activeElement??void 0))return;const v=g.ctrlKey||g.metaKey;c===v&&(u&&!g.shiftKey||g.key===o&&i.current())};return document.addEventListener("keydown",h),()=>{document.removeEventListener("keydown",h)}},[o,c,u,d,m])}const Ky=220,Yy=70,f5=40,p5=60,m5="hierarchy",h5="dependency";function g5(n){return y.useMemo(()=>{if(n.length===0)return{nodes:[],edges:[]};const s=new Qv.graphlib.Graph({multigraph:!0});s.setDefaultEdgeLabel(()=>({})),s.setGraph({rankdir:"TB",nodesep:f5,ranksep:p5});const i=new Map(n.map(d=>[d.id,d])),o=new Map;for(const d of n)if(d.parentTaskId&&i.has(d.parentTaskId)){const m=o.get(d.parentTaskId)||[];m.push(d),o.set(d.parentTaskId,m)}for(const d of n)s.setNode(d.id,{width:Ky,height:Yy});const c=[];for(const d of n){if(d.parentTaskId&&i.has(d.parentTaskId)){const m=`hierarchy-${d.parentTaskId}-${d.id}`;s.setEdge(d.parentTaskId,d.id,{},m),c.push({id:m,source:d.parentTaskId,target:d.id,type:"smoothstep",data:{edgeType:m5},style:{stroke:"var(--accent-green)",strokeWidth:2},animated:!1})}for(const m of d.dependsOn)if(i.has(m)){const h=`dependency-${m}-${d.id}`;s.setEdge(m,d.id,{},h),c.push({id:h,source:m,target:d.id,type:"smoothstep",data:{edgeType:h5},style:{stroke:"var(--text-tertiary)",strokeWidth:1.5,strokeDasharray:"6 3"},animated:!1})}}return Qv.layout(s),{nodes:n.map(d=>{const m=s.node(d.id),h=o.get(d.id)||[];return{id:d.id,type:"task",position:{x:m.x-Ky/2,y:m.y-Yy/2},data:{task:d,childCount:h.length,doneChildCount:h.filter(g=>g.status==="complete").length,hasDependencies:d.dependsOn.length>0}}}),edges:c}},[n])}const v5="_dagContainer_js4w6_1",y5="_taskNode_js4w6_26",b5="_taskNodeBorder_js4w6_54",_5="_taskNodeContent_js4w6_60",x5="_taskNodeHeader_js4w6_70",S5="_taskNodeIcon_js4w6_77",T5="_taskNodeTitle_js4w6_82",k5="_taskNodeBadges_js4w6_90",w5="_childBadge_js4w6_95",N5="_depBadge_js4w6_107",j5="_handle_js4w6_119",C5="_emptyCta_js4w6_126",E5="_ctaDescription_js4w6_137",A5="_ctaButton_js4w6_144",tn={dagContainer:v5,taskNode:y5,taskNodeBorder:b5,taskNodeContent:_5,taskNodeHeader:x5,taskNodeIcon:S5,taskNodeTitle:T5,taskNodeBadges:k5,childBadge:w5,depBadge:N5,handle:j5,emptyCta:C5,ctaDescription:E5,ctaButton:A5};function D5({data:n}){const{task:s,childCount:i,doneChildCount:o,hasDependencies:c}=n,u=ga(s.status);return l.jsxs("div",{className:tn.taskNode,"data-task-id":s.id,"data-task-title":s.title,children:[l.jsx(e0,{type:"target",position:t0.Top,className:tn.handle}),l.jsx("div",{className:tn.taskNodeBorder,style:{backgroundColor:u.color}}),l.jsxs("div",{className:tn.taskNodeContent,children:[l.jsxs("div",{className:tn.taskNodeHeader,children:[l.jsx("span",{className:tn.taskNodeIcon,style:{color:u.color},children:u.icon}),l.jsx("span",{className:tn.taskNodeTitle,children:s.title})]}),l.jsxs("div",{className:tn.taskNodeBadges,children:[i>0&&l.jsxs("span",{className:tn.childBadge,children:[o,"/",i]}),c&&l.jsx("span",{className:tn.depBadge,children:"dep"})]})]}),l.jsx(e0,{type:"source",position:t0.Bottom,className:tn.handle})]})}const R5=iA,M5={task:D5};function O5({workspaceId:n,environmentId:s,tasks:i}){const o=St(),{resolvedThemeId:c}=qb(),u=y.useMemo(()=>i.filter(b=>b.workspaceId===n),[i,n]),{nodes:d,edges:m}=g5(u),h=y.useMemo(()=>{const b=getComputedStyle(document.documentElement),_={};for(const[S,T]of Object.entries(R5))_[S]=b.getPropertyValue(T).trim()||"#6b7a8d";return _},[c]),g=y.useCallback((b,_)=>{o(os(_.id,void 0,n,s))},[o,n,s]),v=y.useCallback(b=>{const _=b.data;return h[_.task.status]||h.pending},[h]);return u.length===0?l.jsxs("div",{className:tn.emptyCta,children:[l.jsx("button",{className:tn.ctaButton,onClick:()=>o(ei(n,void 0,s)),children:"Create Task"}),l.jsx("div",{className:tn.ctaDescription,children:"Create tasks to see the dependency graph"})]}):l.jsx("div",{className:tn.dagContainer,children:l.jsxs(nT,{nodes:d,edges:m,nodeTypes:M5,onNodeClick:g,fitView:!0,fitViewOptions:{padding:.2},minZoom:.3,maxZoom:2,children:[l.jsx(sT,{variant:aT.Dots,gap:24,size:1,color:"var(--text-disabled)"}),l.jsx(iT,{showInteractive:!1}),l.jsx(oT,{nodeColor:v,maskColor:"var(--bg-overlay)",style:{background:"var(--bg-inset)"}})]})})}function I5({tasks:n,taskStatusById:s,sessionStatusByTaskId:i}){const o=new Map;for(const u of n)if(u.parentTaskId){const d=o.get(u.parentTaskId);d?d.push(u):o.set(u.parentTaskId,[u])}const c=new Map(Py.map(u=>[u,[]]));for(const u of n){const d=nm(u.status),m=u.dependsOn.length>0&&u.dependsOn.some(T=>s.get(T)!=="complete"),h=o.get(u.id)??[],g=h.length,v=h.filter(T=>T.status==="complete").length;let b;if(d==="paused"&&i){const T=i.get(u.id);T==="idle"?b="Needs input":T==="completed"&&(b="Ready to complete")}const _={task:u,isBlocked:m,childCount:g,doneChildCount:v,pausedSubBadge:b},S=c.get(d);S?S.push(_):c.get("not_started").push(_)}for(const u of c.values())u.sort((d,m)=>d.task.sortOrder-m.task.sortOrder);return Py.map(u=>{const d=ga(u);return{status:u,label:d.label,style:d,tasks:c.get(u)??[]}})}const B5="_boardContainer_1c4y1_1",L5="_column_1c4y1_17",U5="_columnHeader_1c4y1_34",z5="_columnIcon_1c4y1_47",P5="_columnLabel_1c4y1_52",V5="_columnCount_1c4y1_57",q5="_cardList_1c4y1_67",H5="_emptyPlaceholder_1c4y1_76",G5="_card_1c4y1_67",$5="_cardHeader_1c4y1_107",F5="_cardStatusIcon_1c4y1_113",Z5="_cardTitle_1c4y1_119",K5="_cardBadges_1c4y1_127",Y5="_badge_1c4y1_134",J5="_blockedBadge_1c4y1_146",W5="_childBadge_1c4y1_151",X5="_depBadge_1c4y1_155",Q5="_parentBadge_1c4y1_159",e4="_pausedSubBadge_1c4y1_166",t4="_personaBadge_1c4y1_170",n4="_envBadge_1c4y1_174",s4="_emptyCta_1c4y1_178",a4="_ctaButton_1c4y1_188",i4="_ctaDescription_1c4y1_204",Qe={boardContainer:B5,column:L5,columnHeader:U5,columnIcon:z5,columnLabel:P5,columnCount:V5,cardList:q5,emptyPlaceholder:H5,card:G5,cardHeader:$5,cardStatusIcon:F5,cardTitle:Z5,cardBadges:K5,badge:Y5,blockedBadge:J5,childBadge:W5,depBadge:X5,parentBadge:Q5,pausedSubBadge:e4,personaBadge:t4,envBadge:n4,emptyCta:s4,ctaButton:a4,ctaDescription:i4};function o4({workspaceId:n,environmentId:s,tasks:i,sessions:o,personas:c,environments:u}){const d=St(),m=y.useMemo(()=>i.filter(_=>_.workspaceId===n),[i,n]),h=y.useMemo(()=>new Map(i.map(_=>[_.id,_.status])),[i]),g=y.useMemo(()=>new Map(m.map(_=>[_.id,_])),[m]),v=y.useMemo(()=>{const _=new Map(o.map(E=>[E.id,E])),S=new Map(c.map(E=>[E.id,E])),T=new Map(u.map(E=>[E.id,E])),N=new Map,j=new Map,w=new Map;for(const E of m)if(E.latestSessionId){const A=_.get(E.latestSessionId);if(A){if(N.set(E.id,A.endReason||A.status),A.personaId){const O=S.get(A.personaId);O&&j.set(E.id,O.name)}if(A.environmentId){const O=T.get(A.environmentId);O&&w.set(E.id,O.displayName)}}}return{sessionStatusByTaskId:N,personaNameByTaskId:j,environmentNameByTaskId:w}},[m,o,c,u]),b=y.useMemo(()=>I5({tasks:m,taskStatusById:h,sessionStatusByTaskId:v.sessionStatusByTaskId}),[m,h,v]);return m.length===0?l.jsxs("div",{className:Qe.emptyCta,"data-testid":"board-empty-cta",children:[l.jsx("button",{className:Qe.ctaButton,onClick:()=>d(ei(n,void 0,s)),children:"Create Task"}),l.jsx("div",{className:Qe.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):l.jsx("div",{className:Qe.boardContainer,"data-testid":"board-container",children:b.map(_=>l.jsxs("section",{className:Qe.column,"data-testid":`board-column-${_.status}`,"aria-label":`${_.label}, ${_.tasks.length} ${_.tasks.length===1?"task":"tasks"}`,children:[l.jsxs("div",{className:Qe.columnHeader,children:[l.jsx("span",{className:Qe.columnIcon,style:{color:_.style.color},children:_.style.icon}),l.jsx("span",{className:Qe.columnLabel,children:_.label}),l.jsx("span",{className:Qe.columnCount,"data-testid":`board-count-${_.status}`,children:_.tasks.length})]}),l.jsx("div",{className:Qe.cardList,children:_.tasks.length===0?l.jsx("div",{className:Qe.emptyPlaceholder,children:"No tasks"}):l.jsx(rs,{mode:"popLayout",children:_.tasks.map(S=>l.jsx(Rt.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:l.jsx(r4,{boardTask:S,tasksById:g,personaName:v.personaNameByTaskId.get(S.task.id),envName:v.environmentNameByTaskId.get(S.task.id),onClick:()=>d(os(S.task.id,void 0,n,s))})},S.task.id))})})]},_.status))})}function r4({boardTask:n,tasksById:s,personaName:i,envName:o,onClick:c}){const{task:u,isBlocked:d,childCount:m,doneChildCount:h,pausedSubBadge:g}=n,v=ga(u.status),b=u.parentTaskId?s.get(u.parentTaskId):void 0;return l.jsxs("div",{className:Qe.card,tabIndex:0,role:"button","data-testid":`board-card-${u.id}`,onClick:c,onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),c())},children:[l.jsxs("div",{className:Qe.cardHeader,children:[l.jsx("span",{className:Qe.cardStatusIcon,style:{color:v.color},children:v.icon}),l.jsx("span",{className:Qe.cardTitle,children:u.title})]}),l.jsxs("div",{className:Qe.cardBadges,children:[b&&l.jsx("span",{className:`${Qe.badge} ${Qe.parentBadge}`,title:b.title,children:b.title}),m>0&&l.jsxs("span",{className:`${Qe.badge} ${Qe.childBadge}`,children:[h,"/",m]}),d&&l.jsx("span",{className:`${Qe.badge} ${Qe.blockedBadge}`,children:"blocked"}),u.dependsOn.length>0&&!d&&l.jsx("span",{className:`${Qe.badge} ${Qe.depBadge}`,children:"dep"}),g&&l.jsx("span",{className:`${Qe.badge} ${Qe.pausedSubBadge}`,children:g}),i&&l.jsx("span",{className:`${Qe.badge} ${Qe.personaBadge}`,children:i}),o&&l.jsx("span",{className:`${Qe.badge} ${Qe.envBadge}`,children:o})]})]})}function om(n){const{value:s,onSave:i,validate:o,fieldId:c,activeFieldId:u,onActivate:d,enterToSave:m=!0,trimOnSave:h=!0}=n,[g,v]=y.useState(""),[b,_]=y.useState(""),S=y.useRef(!1),T=u===c,N=y.useCallback(G=>{v(G),_("")},[]),j=y.useCallback(()=>{_("")},[]),w=y.useCallback(()=>{S.current=!1,d==null||d(null),v(""),_("")},[d]),E=y.useCallback(()=>{const G=h?g.trim():g;if(o){const V=o(g);if(V){_(V);return}}const U=h?s.trim():s;if(G===U){w();return}i(G),w()},[g,s,h,o,i,w]),A=y.useCallback(()=>{S.current=!0,d==null||d(c),v(s),_("")},[c,s,d]),O=y.useCallback(G=>{if(S.current){S.current=!1;return}G.relatedTarget instanceof HTMLElement&&G.relatedTarget.dataset.editAction===c||E()},[c,E]),C=y.useCallback(G=>{G.key==="Escape"?w():G.key==="Enter"&&m&&E()},[w,m,E]),M=(()=>{if(!T)return!1;const G=h?s.trim():s;return(h?g.trim():g)!==G})();return y.useEffect(()=>{!T&&(g!==""||b!=="")&&(v(""),_(""))},[T,g,b]),{isEditing:T,draft:g,error:b,isDirty:M,startEdit:A,cancelEdit:w,save:E,setDraft:N,clearError:j,handleBlur:O,handleKeyDown:C,ignoreInitialBlurRef:S}}const l4="_editFieldWrapper_yuzty_1",c4="_editInput_yuzty_10",u4="_editTextarea_yuzty_42",d4="_editSelect_yuzty_78",f4="_editError_yuzty_111",p4="_editInputInvalid_yuzty_118",m4="_editHint_yuzty_123",h4="_unsavedDot_yuzty_132",g4="_metaValueClickable_yuzty_140",v4="_editButton_yuzty_159",y4="_metaPlaceholder_yuzty_175",b4="_worktreeToggle_yuzty_180",We={editFieldWrapper:l4,editInput:c4,editTextarea:u4,editSelect:d4,editError:f4,editInputInvalid:p4,editHint:m4,unsavedDot:h4,metaValueClickable:g4,editButton:v4,metaPlaceholder:y4,worktreeToggle:b4};function Zt(n){const{value:s,onSave:i,validate:o,mode:c="edit",fieldId:u="text",activeFieldId:d,onActivate:m,onChange:h,renderDisplay:g,placeholder:v,maxLength:b,ariaLabel:_,"data-testid":S}=n,T=y.useRef(null),N=om({value:s,onSave:i,validate:o,fieldId:u,activeFieldId:d,onActivate:m,enterToSave:!0,trimOnSave:!0});if(y.useEffect(()=>{if(N.isEditing){const w=window.setTimeout(()=>{var E;(E=T.current)==null||E.focus()},0);return()=>window.clearTimeout(w)}},[N.isEditing]),c==="create"){const w=A=>{h==null||h(A.target.value)},E=o==null?void 0:o(s);return l.jsxs("div",{className:We.editFieldWrapper,children:[l.jsx("input",{className:`${We.editInput} ${E?We.editInputInvalid:""}`,value:s,onChange:w,maxLength:b,placeholder:v,"aria-label":_,"data-testid":S?`${S}-input`:void 0}),E&&l.jsx("span",{className:We.editError,"data-testid":"edit-error",children:E})]})}if(N.isEditing)return l.jsxs("div",{className:We.editFieldWrapper,children:[l.jsx("input",{ref:T,className:`${We.editInput} ${N.error?We.editInputInvalid:""}`,value:N.draft,onChange:w=>N.setDraft(w.target.value),onBlur:N.handleBlur,onKeyDown:N.handleKeyDown,maxLength:b,placeholder:v,"aria-label":_,"data-testid":S?`${S}-input`:void 0}),N.isDirty&&l.jsx("span",{className:We.unsavedDot,title:"Unsaved changes"}),N.error&&l.jsx("span",{className:We.editError,"data-testid":"edit-error",children:N.error}),l.jsx("span",{className:We.editHint,children:"Enter to save · Esc to cancel"})]});const j=g==null?void 0:g(s);return l.jsxs("span",{role:"button",tabIndex:0,className:We.metaValueClickable,onClick:()=>N.startEdit(),onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),N.startEdit())},title:"Click to edit","aria-label":_,"data-testid":S?`${S}-button`:void 0,children:[j!==void 0?j:s?l.jsx("span",{children:s}):l.jsx("span",{className:We.metaPlaceholder,children:v||"None"}),l.jsx("span",{className:We.editButton,"aria-hidden":"true",children:"✏️"})]})}function cp(n){const{value:s,onSave:i,validate:o,mode:c="edit",fieldId:u="textarea",activeFieldId:d,onActivate:m,onChange:h,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":_}=n,S=y.useRef(null),T=om({value:s,onSave:i,validate:o,fieldId:u,activeFieldId:d,onActivate:m,enterToSave:!1,trimOnSave:!1});if(y.useEffect(()=>{if(T.isEditing){const j=window.setTimeout(()=>{var w;(w=S.current)==null||w.focus()},0);return()=>window.clearTimeout(j)}},[T.isEditing]),c==="create"){const j=E=>{h==null||h(E.target.value)},w=o==null?void 0:o(s);return l.jsxs("div",{className:We.editFieldWrapper,children:[l.jsx("textarea",{className:`${We.editTextarea} ${w?We.editInputInvalid:""}`,value:s,onChange:j,placeholder:v,"aria-label":b,"data-testid":_?`${_}-input`:void 0}),w&&l.jsx("span",{className:We.editError,"data-testid":"edit-error",children:w})]})}if(T.isEditing)return l.jsxs("div",{className:We.editFieldWrapper,children:[l.jsx("textarea",{ref:S,className:`${We.editTextarea} ${T.error?We.editInputInvalid:""}`,value:T.draft,onChange:j=>T.setDraft(j.target.value),onBlur:T.handleBlur,onKeyDown:T.handleKeyDown,title:b,"aria-label":b,"data-testid":_?`${_}-input`:void 0}),T.isDirty&&l.jsx("span",{className:We.unsavedDot,title:"Unsaved changes"}),T.error&&l.jsx("span",{className:We.editError,"data-testid":"edit-error",children:T.error}),l.jsx("span",{className:We.editHint,children:"Tab to save · Esc to cancel"})]});const N=g==null?void 0:g(s);return l.jsxs("span",{role:"button",tabIndex:0,className:We.metaValueClickable,onClick:()=>T.startEdit(),onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),T.startEdit())},title:"Click to edit","aria-label":b,"data-testid":_?`${_}-button`:void 0,children:[N!==void 0?N:s?l.jsx("span",{children:s}):l.jsx("span",{className:We.metaPlaceholder,children:v||"None"}),l.jsx("span",{className:We.editButton,"aria-hidden":"true",children:"✏️"})]})}function Cc(n){var A;const{value:s,onSave:i,mode:o="edit",options:c,fieldId:u="select",activeFieldId:d,onActivate:m,onChange:h,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":_}=n,S=y.useRef(null),T=om({value:s,onSave:i,fieldId:u,activeFieldId:d,onActivate:m,enterToSave:!1,trimOnSave:!1});y.useEffect(()=>{if(T.isEditing){const O=window.setTimeout(()=>{var C;(C=S.current)==null||C.focus()},0);return()=>window.clearTimeout(O)}},[T.isEditing]);const N=y.useCallback(O=>{const C=O.target.value;T.ignoreInitialBlurRef.current=!1,C!==s&&i(C),T.cancelEdit()},[s,i,T]),j=y.useCallback(O=>{if(T.ignoreInitialBlurRef.current){T.ignoreInitialBlurRef.current=!1;return}O.relatedTarget instanceof HTMLElement&&O.relatedTarget.dataset.editAction===u||T.cancelEdit()},[u,T]);if(o==="create")return l.jsx("select",{className:We.editSelect,value:s,onChange:O=>h==null?void 0:h(O.target.value),"aria-label":b,"data-testid":_?`${_}-select`:void 0,children:c.map(O=>l.jsx("option",{value:O.value,children:O.label},O.value))});if(T.isEditing)return l.jsx("select",{ref:S,className:We.editSelect,value:T.draft,onChange:N,onBlur:j,title:b,"aria-label":b,"data-testid":_?`${_}-select`:void 0,children:c.map(O=>l.jsx("option",{value:O.value,children:O.label},O.value))});const w=g==null?void 0:g(s),E=(A=c.find(O=>O.value===s))==null?void 0:A.label;return l.jsxs("button",{type:"button",className:We.metaValueClickable,onClick:()=>T.startEdit(),title:"Click to change","aria-label":b,"data-testid":_?`${_}-button`:void 0,children:[w!==void 0?w:E?l.jsx("span",{children:E}):l.jsx("span",{className:We.metaPlaceholder,children:v||"None"}),l.jsx("span",{className:We.editButton,"aria-hidden":"true",children:"✏️"})]})}function _4(n){const{checked:s,onChange:i,label:o,ariaLabel:c,"data-testid":u}=n;return l.jsxs("label",{className:We.worktreeToggle,"data-testid":u,children:[l.jsx("input",{type:"checkbox",checked:s,onChange:d=>i(d.target.checked),"aria-label":c}),l.jsx("span",{children:o})]})}const x4="_envRow_1e1r5_1",S4="_envDot_1e1r5_7",T4="_envDotGreen_1e1r5_14",k4="_envDotYellow_1e1r5_18",w4="_envDotRed_1e1r5_22",N4="_envDotGray_1e1r5_26",Yi={envRow:x4,envDot:S4,envDotGreen:T4,envDotYellow:k4,envDotRed:w4,envDotGray:N4};function j4(n){const s=n.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?Yi.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?Yi.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?Yi.envDotRed:Yi.envDotGray}function C4(n){const{value:s,onSave:i,environments:o,allowNone:c=!1,fieldId:u="environment",activeFieldId:d,onActivate:m,placeholder:h="No environment",ariaLabel:g="Environment","data-testid":v}=n,b=o.find(T=>T.id===s),_=[...c?[{value:"",label:"None"}]:[],...o.map(T=>({value:T.id,label:T.displayName}))],S=()=>{if(b)return l.jsxs("span",{className:Yi.envRow,children:[l.jsx("span",{className:`${Yi.envDot} ${j4(b.status)}`}),b.displayName]})};return l.jsx(Cc,{value:s,onSave:i,options:_,fieldId:u,activeFieldId:d,onActivate:m,renderDisplay:S,placeholder:h,ariaLabel:g,"data-testid":v})}function Jy(n){if(!n)return"";const s=new Date(n);if(isNaN(s.getTime()))return"";const o=Date.now()-s.getTime();if(o<0)return"just now";const c=Math.floor(o/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;const u=Math.floor(c/60);if(u<24)return`${u}h ago`;const d=Math.floor(u/24);return d<30?`${d}d ago`:s.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}const Rf=100;function E4(n){try{const s=new URL(n);return s.protocol!=="http:"&&s.protocol!=="https:"?void 0:s.toString()}catch{return}}function A4(){const{workspaceId:n,environmentId:s}=va(),i=St(),{tasks:o,environments:c,workspaces:u,personas:d,sessions:m,archiveWorkspace:h,updateWorkspace:g,usageCache:v,loadUsage:b}=pt(),[_,S]=y.useState("tasks"),[T,N]=y.useState(!1),[j,w]=y.useState(null),[E,A]=y.useState(!1),O=y.useRef(void 0),C=u.find(K=>K.id===n),M=s??(C==null?void 0:C.environmentId)??"",G=i5(n,M,u,c);Ms({key:"1"},()=>S("graph")),Ms({key:"2"},()=>S("board")),Ms({key:"3"},()=>S("tasks")),y.useEffect(()=>{const K=O.current;O.current=n,!(K===void 0||K===n)&&j!==null&&w(null)},[n,j]);const U=m.reduce((K,re)=>K+(re.costUsd??0),0);y.useEffect(()=>{n&&b("workspace",n)},[n,b,U]);const V=n?v[`workspace:${n}`]:void 0,Z=o.filter(K=>K.workspaceId===n),ee=Z.filter(K=>K.status==="complete").length,ie=Z.length,be=ie>0?Math.round(ee/ie*100):0;return l.jsxs("div",{className:L.panelContainer,children:[l.jsx(ba,{segments:G}),l.jsxs("div",{className:L.workspaceHeader,children:[l.jsx("span",{className:L.workspaceName,"data-testid":"workspace-name",children:l.jsx(Zt,{value:(C==null?void 0:C.name)||"",onSave:K=>{C&&g(C.id,{name:K})},validate:K=>{const re=K.trim();if(!re)return"Name is required";if(re.length>Rf)return`Max ${Rf} characters`},maxLength:Rf,fieldId:"name",activeFieldId:j,onActivate:w,ariaLabel:"Workspace name",renderDisplay:K=>K||n||void 0,"data-testid":"edit-name"})}),l.jsx("button",{className:L.archiveButton,onClick:()=>N(!0),title:"Archive workspace","data-testid":"archive-workspace-button",children:"Archive"})]}),l.jsxs("button",{className:L.metaToggle,onClick:()=>A(!E),"aria-expanded":!E,"aria-controls":"workspace-meta-panel","data-testid":"meta-toggle",children:[l.jsx("span",{className:`${L.metaToggleArrow} ${E?"":L.metaToggleArrowOpen}`,children:"▶"}),"Details"]}),!E&&l.jsxs("div",{className:L.workspaceMeta,"data-testid":"workspace-meta",id:"workspace-meta-panel",children:[l.jsxs("div",{className:L.metaRow,children:[l.jsx("span",{className:L.metaLabel,children:"Description"}),l.jsx("div",{className:L.metaValue,children:l.jsx(cp,{value:(C==null?void 0:C.description)||"",onSave:K=>{C&&g(C.id,{description:K})},fieldId:"description",activeFieldId:j,onActivate:w,renderDisplay:K=>K?l.jsx("span",{className:L.overviewMarkdown,children:l.jsx(up,{remarkPlugins:[dp],children:K})}):void 0,placeholder:"No description",ariaLabel:"Workspace description","data-testid":"edit-description"})})]}),l.jsxs("div",{className:L.metaRow,children:[l.jsx("span",{className:L.metaLabel,children:"Repository"}),l.jsx("div",{className:L.metaValue,children:l.jsx(Zt,{value:(C==null?void 0:C.repoUrl)||"",onSave:K=>{C&&g(C.id,{repoUrl:K})},validate:K=>{const re=K.trim();if(re&&!/^https?:\/\/.+/.test(re))return"Must be a valid http(s) URL"},fieldId:"repoUrl",activeFieldId:j,onActivate:w,renderDisplay:K=>{const re=E4(K);return re?l.jsx("a",{className:L.repoLink,href:re,target:"_blank",rel:"noopener noreferrer",onClick:I=>I.stopPropagation(),children:K}):K?l.jsx("span",{children:K}):void 0},placeholder:"No repository",ariaLabel:"Workspace repository URL","data-testid":"edit-repo"})})]}),l.jsxs("div",{className:L.metaRow,children:[l.jsx("span",{className:L.metaLabel,children:"Environment"}),l.jsx("div",{className:L.metaValue,children:l.jsx(C4,{value:(C==null?void 0:C.environmentId)||"",onSave:K=>{C&&K&&g(C.id,{environmentId:K})},environments:c,fieldId:"environmentId",activeFieldId:j,onActivate:w,placeholder:"Select environment",ariaLabel:"Workspace environment","data-testid":"edit-env"})})]}),l.jsxs("div",{className:L.metaRow,children:[l.jsx("span",{className:L.metaLabel,children:"Persona"}),l.jsx("div",{className:L.metaValue,children:l.jsx(Cc,{value:(C==null?void 0:C.defaultPersonaId)||"",onSave:K=>{C&&g(C.id,{defaultPersonaId:K})},options:[{value:"",label:"(Inherit)"},...d.map(K=>({value:K.id,label:K.name}))],fieldId:"defaultPersonaId",activeFieldId:j,onActivate:w,renderDisplay:K=>{const re=d.find(I=>I.id===K);if(re)return l.jsx("span",{children:re.name})},placeholder:(C==null?void 0:C.defaultPersonaId)||"(Inherit)",ariaLabel:"Workspace default persona","data-testid":"edit-persona"})})]}),l.jsxs("div",{className:L.metaRow,children:[l.jsx("span",{className:L.metaLabel,children:"Worktrees"}),l.jsx("div",{className:L.metaValue,children:l.jsx(_4,{checked:(C==null?void 0:C.useWorktrees)??!0,onChange:K=>{C&&g(C.id,{useWorktrees:K})},label:"Enable worktree isolation","data-testid":"worktree-toggle"})})]}),l.jsxs("div",{className:L.metaRow,children:[l.jsx("span",{className:L.metaLabel,children:"Working Dir"}),l.jsx("div",{className:L.metaValue,children:l.jsx(Zt,{value:(C==null?void 0:C.workingDirectory)||"",onSave:K=>{C&&g(C.id,{workingDirectory:K})},fieldId:"workingDirectory",activeFieldId:j,onActivate:w,placeholder:"Default (server default)",ariaLabel:"Working directory","data-testid":"edit-working-directory"})})]}),C&&l.jsxs("div",{className:L.metaTimestamps,children:[l.jsxs("span",{className:L.metaTimestamp,children:["Created ",Jy(C.createdAt)]}),C.updatedAt&&C.updatedAt!==C.createdAt&&l.jsxs("span",{className:L.metaTimestamp,children:["· Updated ",Jy(C.updatedAt)]})]})]}),ie>0&&l.jsxs("div",{className:L.progressBarContainer,"data-testid":"progress-bar",children:[l.jsx("div",{className:L.progressBar,children:l.jsx("div",{className:L.progressFill,style:{width:`${be}%`}})}),l.jsxs("span",{className:L.progressLabel,children:[ee,"/",ie]})]}),V&&V.costUsd>0&&l.jsx("div",{className:L.progressBarContainer,children:l.jsxs("span",{className:L.progressLabel,children:["Usage: ",so(V.costUsd)," (",V.sessionCount," session",V.sessionCount!==1?"s":"",")"]})}),l.jsxs("div",{className:L.tabBar,role:"tablist","aria-label":"Workspace view",children:[l.jsx("button",{role:"tab","aria-selected":_==="graph",className:`${L.tab} ${_==="graph"?L.active:""}`,onClick:()=>S("graph"),children:"Graph"}),l.jsx("button",{role:"tab","aria-selected":_==="board",className:`${L.tab} ${_==="board"?L.active:""}`,onClick:()=>S("board"),"data-testid":"board-tab",children:"Board"}),l.jsx("button",{role:"tab","aria-selected":_==="tasks",className:`${L.tab} ${_==="tasks"?L.active:""}`,onClick:()=>S("tasks"),children:"Tasks"})]}),_==="tasks"&&ie>0&&l.jsxs("div",{className:L.workspaceSummary,children:[l.jsx("span",{className:L.workspaceSummaryTitle,children:`${ee}/${ie} tasks complete`}),l.jsx("span",{className:L.workspaceSummarySubtitle,children:"Select a task or click + to create one"})]}),_==="tasks"&&ie===0&&l.jsxs("div",{className:L.emptyCta,children:[l.jsx("button",{className:L.ctaButton,onClick:()=>i(ei(n,void 0,M)),children:"Create Task"}),l.jsx("div",{className:L.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}),_==="board"&&l.jsx(o4,{workspaceId:n,environmentId:M,tasks:o,sessions:m,personas:d,environments:c}),_==="graph"&&l.jsx(O5,{workspaceId:n,environmentId:M,tasks:o}),l.jsx(Ja,{isOpen:T,title:"Archive Workspace?",description:"This will hide the workspace from the sidebar. Tasks will not be deleted.",confirmLabel:"Archive",onConfirm:()=>{C&&(h(C.id),i("/",{replace:!0})),N(!1)},onCancel:()=>N(!1)})]})}const D4="_formContent_ymnez_1",R4="_section_ymnez_13",M4="_label_ymnez_19",O4="_titleInput_ymnez_26",I4="_descriptionTextarea_ymnez_58",B4="_selectField_ymnez_94",L4="_checkboxRow_ymnez_128",U4="_checkboxLabel_ymnez_141",z4="_fieldError_ymnez_146",ut={formContent:D4,section:R4,label:M4,titleInput:O4,descriptionTextarea:I4,selectField:B4,checkboxRow:L4,checkboxLabel:U4,fieldError:z4};function P4(n,s){return{name:(n==null?void 0:n.name)??"",description:(n==null?void 0:n.description)??"",repoUrl:(n==null?void 0:n.repoUrl)??"",environmentId:(n==null?void 0:n.environmentId)??s??"",defaultPersonaId:(n==null?void 0:n.defaultPersonaId)??"",useWorktrees:(n==null?void 0:n.useWorktrees)??!0,workingDirectory:(n==null?void 0:n.workingDirectory)??""}}const V4=100;function q4({values:n,onChange:s,environments:i,personas:o,errors:c,disabled:u,autoFocusName:d}){const m=(h,g)=>{s({...n,[h]:g})};return l.jsxs("div",{className:ut.formContent,children:[l.jsxs("div",{className:ut.section,children:[l.jsx("label",{className:ut.label,htmlFor:"ws-name",children:"Name"}),l.jsx("input",{id:"ws-name",className:ut.titleInput,type:"text",value:n.name,onChange:h=>m("name",h.target.value),placeholder:"Workspace name",maxLength:V4,autoFocus:d,disabled:u,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&l.jsx("span",{className:ut.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),l.jsxs("div",{className:ut.section,children:[l.jsx("label",{className:ut.label,htmlFor:"ws-description",children:"Description"}),l.jsx("textarea",{id:"ws-description",className:ut.descriptionTextarea,value:n.description,onChange:h=>m("description",h.target.value),placeholder:"Optional description (Markdown supported)",disabled:u,"data-testid":"workspace-form-description"})]}),l.jsxs("div",{className:ut.section,children:[l.jsx("label",{className:ut.label,htmlFor:"ws-repo",children:"Repository URL"}),l.jsx("input",{id:"ws-repo",className:ut.titleInput,type:"text",value:n.repoUrl,onChange:h=>m("repoUrl",h.target.value),placeholder:"https://github.com/org/repo",disabled:u,"data-testid":"workspace-form-repo"}),(c==null?void 0:c.repoUrl)&&l.jsx("span",{className:ut.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),l.jsxs("div",{className:ut.section,children:[l.jsx("label",{className:ut.label,htmlFor:"ws-environment",children:"Environment"}),l.jsxs("select",{id:"ws-environment",className:ut.selectField,value:n.environmentId,onChange:h=>m("environmentId",h.target.value),disabled:u,"data-testid":"workspace-form-environment",children:[l.jsx("option",{value:"",children:"Select environment…"}),i.map(h=>l.jsx("option",{value:h.id,children:h.displayName||h.id},h.id))]}),(c==null?void 0:c.environmentId)&&l.jsx("span",{className:ut.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),l.jsxs("div",{className:ut.section,children:[l.jsx("label",{className:ut.label,htmlFor:"ws-persona",children:"Default Persona"}),l.jsxs("select",{id:"ws-persona",className:ut.selectField,value:n.defaultPersonaId,onChange:h=>m("defaultPersonaId",h.target.value),disabled:u,"data-testid":"workspace-form-persona",children:[l.jsx("option",{value:"",children:"(Inherit)"}),o.map(h=>l.jsx("option",{value:h.id,children:h.name},h.id))]})]}),l.jsx("div",{className:ut.section,children:l.jsxs("label",{className:ut.checkboxRow,children:[l.jsx("input",{type:"checkbox",checked:n.useWorktrees,onChange:h=>m("useWorktrees",h.target.checked),disabled:u,"data-testid":"workspace-form-worktrees"}),l.jsx("span",{className:ut.checkboxLabel,children:"Enable worktree isolation"})]})}),l.jsxs("div",{className:ut.section,children:[l.jsx("label",{className:ut.label,htmlFor:"ws-workdir",children:"Working Directory"}),l.jsx("input",{id:"ws-workdir",className:ut.titleInput,type:"text",value:n.workingDirectory,onChange:h=>m("workingDirectory",h.target.value),placeholder:"Default (server default)",disabled:u,"data-testid":"workspace-form-workdir"})]})]})}const H4="_container_cddyd_1",G4="_header_cddyd_8",$4="_headerTitle_cddyd_35",F4="_badge_cddyd_44",Z4="_headerActions_cddyd_54",K4="_body_cddyd_61",Y4="_formContent_cddyd_73",J4="_section_cddyd_85",W4="_label_cddyd_91",X4="_titleInput_cddyd_98",Q4="_descriptionTextarea_cddyd_131",eB="_parentContext_cddyd_167",tB="_parentLabel_cddyd_175",nB="_parentName_cddyd_182",sB="_personaSelect_cddyd_186",aB="_depList_cddyd_220",iB="_depItem_cddyd_226",oB="_depItemSelected_cddyd_248",rB="_noDeps_cddyd_252",lB="_btnPrimary_cddyd_258",cB="_btnGhost_cddyd_289",Be={container:H4,header:G4,headerTitle:$4,badge:F4,headerActions:Z4,body:K4,formContent:Y4,section:J4,label:W4,titleInput:X4,descriptionTextarea:Q4,parentContext:eB,parentLabel:tB,parentName:nB,personaSelect:sB,depList:aB,depItem:iB,depItemSelected:oB,noDeps:rB,btnPrimary:lB,btnGhost:cB};function uB(n){const s={};return n.name.trim()||(s.name="Name is required"),n.repoUrl.trim()&&!/^https?:\/\/.+/i.test(n.repoUrl.trim())&&(s.repoUrl="Must be a valid http(s) URL"),n.environmentId||(s.environmentId="Environment is required"),Object.keys(s).length>0?s:void 0}const dB=[{label:"Home",url:Ya},{label:"New Workspace",url:void 0}];function fB(){const[n]=bp(),s=n.get("environment")??void 0,{environments:i,personas:o,createWorkspace:c,workspaceCreating:u}=pt(),{showToast:d}=Bs(),m=St(),[h,g]=y.useState(()=>{var j;return P4(void 0,s||((j=i[0])==null?void 0:j.id))}),[v,b]=y.useState(),[_,S]=y.useState();y.useEffect(()=>{s||h.environmentId||i.length===0||g(j=>{var w;return j.environmentId?j:{...j,environmentId:((w=i[0])==null?void 0:w.id)??""}})},[i,s,h.environmentId]);const T=()=>{const j=uB(h);if(j){b(j),S(void 0);return}b(void 0),S(void 0),c(h.name.trim(),h.description,h.repoUrl.trim(),h.environmentId,h.defaultPersonaId,h.useWorktrees,h.workingDirectory,()=>{d("Workspace created","success"),m(Ya,{replace:!0})},w=>{S(w)})},N=()=>{m(s?Qi(s):Ya,{replace:!0})};return l.jsxs("div",{className:Be.container,children:[l.jsxs("div",{className:Be.header,children:[l.jsx("div",{className:Be.headerTitle,children:l.jsx(ba,{segments:dB})}),l.jsxs("div",{className:Be.headerActions,children:[l.jsx("button",{className:Be.btnGhost,onClick:N,disabled:u,"data-testid":"workspace-create-cancel",children:"Cancel"}),l.jsx("button",{className:Be.btnPrimary,onClick:T,disabled:u||!h.name.trim()||!h.environmentId,"data-testid":"workspace-create-save",children:u?l.jsx(Ax,{size:"sm",label:"Creating"}):"Create Workspace"})]})]}),l.jsxs("div",{className:Be.body,children:[l.jsx(q4,{values:h,onChange:j=>{g(j),b(void 0),S(void 0)},environments:i,personas:o,errors:v,disabled:u,autoFocusName:!0}),_&&l.jsx("div",{className:Be.error,"data-testid":"workspace-create-submit-error",children:_})]})]})}function Bx({mode:n,taskId:s,workspaceId:i,parentTaskId:o,environmentId:c,tasks:u,workspaces:d,personas:m,onCreateTask:h,onUpdateTask:g,onEditDone:v}){const{showToast:b}=Bs(),_=St(),S=n==="edit",T=S&&s?u.find(pe=>pe.id===s):void 0,N=S?(T==null?void 0:T.workspaceId)??"":i??"",[j,w]=y.useState(N),E=N||j,A=d.find(pe=>pe.id===E),O=c??(A==null?void 0:A.environmentId),C=!S&&!i,M=S?(T==null?void 0:T.parentTaskId)??"":o??"",G=M?u.find(pe=>pe.id===M):void 0,[U,V]=y.useState((T==null?void 0:T.title)??""),[Z,ee]=y.useState((T==null?void 0:T.description)??""),[ie,be]=y.useState((T==null?void 0:T.dependsOn)??[]),[K,re]=y.useState((T==null?void 0:T.defaultPersonaId)??""),[I,$]=y.useState((T==null?void 0:T.canDecompose)??!1),[Q,de]=y.useState(!1),me=y.useRef(!1);y.useEffect(()=>{S&&T&&!me.current&&(me.current=!0,V(T.title),ee(T.description),be(T.dependsOn),re(T.defaultPersonaId),$(T.canDecompose))},[S,T]);const ze=u.filter(pe=>pe.workspaceId===E&&(!S||pe.id!==s)&&pe.id!==M),je=U.trim().length>0&&(!S||T!==void 0)&&E.length>0,Ne=pe=>{be(Re=>Re.includes(pe)?Re.filter(Bt=>Bt!==pe):[...Re,pe])},Ae=()=>{!je||Q||S&&T===void 0||(S&&s?(g(s,U.trim(),Z,ie,K),b("Task updated","success"),v?v():_(os(s,void 0,E,O),{replace:!0})):(de(!0),h(E,U.trim(),Z,ie.length>0?ie:void 0,M||void 0,K,I,()=>{b("Task created","success"),_(i?Wi(i,O):"/tasks",{replace:!0})},pe=>{b(pe,"error"),de(!1)})))},ce=()=>{if(v){v();return}_(S&&s?os(s,void 0,E,O):i?Wi(i,O):"/tasks")},fe=S?"edit task":M?"child task":"new task";return l.jsxs("div",{className:Be.container,children:[l.jsxs("div",{className:Be.header,children:[l.jsxs("div",{className:Be.headerTitle,children:[l.jsx("span",{className:Be.badge,children:fe}),G&&l.jsxs("span",{className:Be.parentContext,children:[l.jsx("span",{className:Be.parentLabel,children:"Child of"}),l.jsx("span",{className:Be.parentName,children:G.title})]})]}),l.jsxs("div",{className:Be.headerActions,children:[l.jsx("button",{onClick:Ae,disabled:!je||Q,className:Be.btnPrimary,"data-testid":"task-edit-save",children:Q?"Creating…":S?"Save Changes":"Create"}),l.jsx("button",{onClick:ce,className:Be.btnGhost,children:"Cancel"})]})]}),l.jsx("div",{className:Be.body,children:l.jsxs("div",{className:Be.formContent,children:[C&&l.jsxs("div",{className:Be.section,children:[l.jsx("label",{className:Be.label,htmlFor:"task-edit-workspace",children:"Workspace"}),l.jsxs("select",{id:"task-edit-workspace",value:j,onChange:pe=>w(pe.target.value),className:Be.personaSelect,"data-testid":"task-edit-workspace",children:[l.jsx("option",{value:"",children:"Select a workspace..."}),d.map(pe=>l.jsx("option",{value:pe.id,children:pe.name},pe.id))]})]}),l.jsxs("div",{className:Be.section,children:[l.jsx("label",{className:Be.label,htmlFor:"task-edit-title",children:"Title"}),l.jsx("input",{id:"task-edit-title",type:"text",value:U,onChange:pe=>V(pe.target.value),placeholder:"Task title...",autoFocus:!0,className:Be.titleInput,"data-testid":"task-edit-title",onKeyDown:pe=>{pe.key==="Enter"&&je&&Ae()}})]}),l.jsxs("div",{className:Be.section,children:[l.jsx("label",{className:Be.label,htmlFor:"task-edit-description",children:"Description"}),l.jsx("textarea",{id:"task-edit-description",value:Z,onChange:pe=>ee(pe.target.value),placeholder:"Describe the task... (markdown supported)",className:Be.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),l.jsxs("div",{className:Be.section,children:[l.jsx("label",{className:Be.label,htmlFor:"task-edit-persona",children:"Default Persona"}),l.jsxs("select",{id:"task-edit-persona",value:K,onChange:pe=>re(pe.target.value),className:Be.personaSelect,"data-testid":"task-edit-persona",children:[l.jsx("option",{value:"",children:"(Inherit)"}),m.map(pe=>l.jsx("option",{value:pe.id,children:pe.name},pe.id))]})]}),!S&&l.jsx("div",{className:Be.section,children:l.jsxs("label",{className:Be.depItem,"data-testid":"task-edit-can-decompose",children:[l.jsx("input",{type:"checkbox",checked:I,onChange:pe=>$(pe.target.checked)}),"Can spawn subtasks"]})}),l.jsxs("div",{className:Be.section,children:[l.jsx("div",{className:Be.label,children:"Dependencies"}),ze.length===0?l.jsx("div",{className:Be.noDeps,children:"No other tasks in this workspace"}):l.jsx("div",{className:Be.depList,children:ze.map(pe=>{const Re=ie.includes(pe.id);return l.jsxs("label",{className:`${Be.depItem} ${Re?Be.depItemSelected:""}`,"data-testid":`dep-option-${pe.id}`,children:[l.jsx("input",{type:"checkbox",checked:Re,onChange:()=>Ne(pe.id)}),pe.title,l.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",pe.status,")"]})]},pe.id)})})]})]})})]})}function Wy(){const{workspaceId:n,environmentId:s}=va(),[i]=bp(),o=n??i.get("workspace")??"",c=i.get("parent")??void 0,{tasks:u,workspaces:d,personas:m,createTask:h,updateTask:g}=pt();return l.jsx(Bx,{mode:"new",workspaceId:o,parentTaskId:c,environmentId:s,tasks:u,workspaces:d,personas:m,onCreateTask:h,onUpdateTask:g})}const pB="_container_1pqxm_1",mB="_emptyState_1pqxm_8",hB="_card_1pqxm_14",gB="_cardHeader_1pqxm_34",vB="_categoryBadge_1pqxm_46",yB="_findingTitle_1pqxm_54",bB="_findingDate_1pqxm_60",_B="_findingContent_1pqxm_72",xB="_tags_1pqxm_78",SB="_tag_1pqxm_78",ts={container:pB,emptyState:mB,card:hB,cardHeader:gB,categoryBadge:vB,findingTitle:yB,findingDate:bB,findingContent:_B,tags:xB,tag:SB};function TB(n){const s=new Date(n),i=new Date,o=i.getTime()-s.getTime(),c=Math.floor(o/1e3),u=Math.floor(c/60),d=Math.floor(u/60),m=Math.floor(d/24);if(c<60)return"just now";if(u<60)return`${u}m ago`;if(d<24)return`${d}h ago`;if(m===1)return"yesterday";if(m<7)return`${m} days ago`;const h=s.getFullYear()===i.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return h?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}const Xy={architecture:{text:"var(--accent-blue)",bg:"var(--accent-blue-dim)"},api:{text:"var(--accent-green)",bg:"var(--accent-green-dim)"},bug:{text:"var(--accent-red)",bg:"var(--accent-red-dim)"},decision:{text:"var(--accent-yellow)",bg:"var(--accent-yellow-dim)"},dependency:{text:"var(--accent-purple)",bg:"var(--accent-purple-dim)"},pattern:{text:"var(--accent-cyan)",bg:"var(--accent-cyan-dim)"},general:{text:"var(--text-secondary)",bg:"var(--bg-elevated)"}};function kB({findings:n}){return n.length===0?l.jsx("div",{className:ts.emptyState,children:"No findings yet. Agents will post discoveries here."}):l.jsx("div",{className:ts.container,children:n.map((s,i)=>{const o=Xy[s.category]||Xy.general;return l.jsxs(Rt.div,{className:ts.card,initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:i*.05,duration:.2},children:[l.jsxs("div",{className:ts.cardHeader,children:[l.jsx("span",{className:ts.categoryBadge,style:{background:o.bg,color:o.text},children:s.category}),l.jsx("span",{className:ts.findingTitle,children:s.title}),l.jsx("span",{className:ts.findingDate,title:s.createdAt,children:TB(s.createdAt)})]}),l.jsx("div",{className:ts.findingContent,children:s.content.length>300?s.content.slice(0,300)+"...":s.content}),s.tags.length>0&&l.jsx("div",{className:ts.tags,children:s.tags.map(c=>l.jsx("span",{className:ts.tag,style:{color:o.text,textShadow:`0 0 8px ${o.text}`},children:c},c))})]},s.id)})})}const wB="_workpadSection_y8nj9_1",NB="_workpadLabel_y8nj9_9",jB="_workpadStatus_y8nj9_17",CB="_workpadSummary_y8nj9_23",EB="_workpadExtra_y8nj9_29",da={workpadSection:wB,workpadLabel:NB,workpadStatus:jB,workpadSummary:CB,workpadExtra:EB};function AB({workpad:n}){if(!n)return;let s;try{const i=JSON.parse(n);if(i==null||typeof i!="object"||Array.isArray(i))return;s=i}catch{return l.jsxs("div",{className:da.workpadSection,"data-testid":"workpad-panel",children:[l.jsx("div",{className:da.workpadLabel,children:"Workpad"}),l.jsx("div",{className:da.workpadExtra,children:n})]})}if(!(!s.status&&!s.summary&&!s.extra))return l.jsxs("div",{className:da.workpadSection,"data-testid":"workpad-panel",children:[l.jsx("div",{className:da.workpadLabel,children:"Workpad"}),s.status&&l.jsx("div",{className:da.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&l.jsx("div",{className:da.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&l.jsx("div",{className:da.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}function cc(n){if(!n)return"—";const s=new Date(n);return isNaN(s.getTime())?"—":s.toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function Mf(n,s){if(!n||!s)return;const i=new Date(s).getTime()-new Date(n).getTime();if(isNaN(i)||i<0)return;const o=Math.floor(i/6e4),c=Math.floor(i%6e4/1e3);if(o===0)return`${c}s`;const u=Math.floor(o/60),d=o%60;return u===0?`${o}m ${c}s`:`${u}h ${d}m`}function Qy(n){const s=n.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?L.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?L.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?L.envDotRed:L.envDotGray}function DB({status:n}){const s=ga(n),i=nA(n);return l.jsx("span",{className:`${L.statusBadge} ${L[i]??L.statusPending}`,children:s.label})}function RB({task:n,tasksById:s,environments:i,workspaces:o,taskSessions:c,selectedEnvId:u}){const{loadUsage:d,usageCache:m}=pt(),h=c.reduce((A,O)=>A+(O.costUsd??0),0);y.useEffect(()=>{d("task",n.id),n.childTaskIds.length>0&&d("task_tree",n.id)},[n.id,n.childTaskIds.length,d,h]);const g=`task:${n.id}`,v=g in m?m[g]:void 0,b=`task_tree:${n.id}`,_=n.childTaskIds.length>0&&b in m?m[b]:void 0,S=c.length>0?c[c.length-1]:void 0,T=(S==null?void 0:S.environmentId)??"",N=T?i.find(A=>A.id===T):void 0,j=o.find(A=>A.id===n.workspaceId),w=i.find(A=>A.id===u),E=n.branch&&(j!=null&&j.repoUrl)?`${j.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(n.branch)}`:void 0;return l.jsxs("div",{className:L.overviewDashboard,children:[l.jsxs("div",{className:L.overviewHero,children:[l.jsx(DB,{status:n.status}),n.branch&&l.jsx("span",{className:L.overviewBranchPill,children:E?l.jsxs("a",{href:E,target:"_blank",rel:"noreferrer noopener",className:L.branchLink,children:["🔗"," ",n.branch]}):l.jsxs("span",{children:["🔗"," ",n.branch]})})]}),typeof n.description=="string"&&n.description&&l.jsxs("div",{className:L.overviewSection,children:[l.jsx("div",{className:L.overviewLabel,children:"Description"}),l.jsx("div",{className:L.overviewMarkdown,children:l.jsx(up,{remarkPlugins:[dp],children:n.description})})]}),n.workpad&&l.jsx(AB,{workpad:n.workpad}),l.jsxs("div",{className:L.overviewSection,children:[l.jsx("div",{className:L.overviewLabel,children:"Environment"}),T&&N?l.jsxs("div",{className:L.envRow,"data-testid":"task-overview-environment",children:[l.jsx("span",{className:`${L.envDot} ${Qy(N.status)}`,title:N.status,"aria-label":`Status: ${N.status}`,role:"img"}),l.jsx("span",{className:L.overviewValue,children:N.displayName})]}):w?l.jsxs("div",{className:L.envRow,"data-testid":"task-overview-environment",children:[l.jsx("span",{className:`${L.envDot} ${Qy(w.status)}`,title:w.status,"aria-label":`Status: ${w.status}`,role:"img"}),l.jsx("span",{className:L.overviewValue,children:w.displayName}),l.jsx("span",{className:L.overviewMuted,children:"(workspace default)"})]}):l.jsx("div",{className:L.overviewMuted,children:"Set in workspace settings"})]}),l.jsxs("div",{className:L.overviewSection,"data-testid":"task-overview-dependencies",children:[l.jsx("div",{className:L.overviewLabel,children:"Dependencies"}),n.dependsOn.length===0?l.jsx("div",{className:L.overviewMuted,children:"None"}):l.jsx("div",{className:L.depList,children:n.dependsOn.map(A=>{const O=s.get(A),C=(O==null?void 0:O.status)==="complete";return l.jsxs("div",{className:`${L.depItem} ${C?L.depDone:L.depBlocked}`,children:[l.jsx("span",{children:C?"✓":"○"}),l.jsx("span",{children:(O==null?void 0:O.title)??A})]},A)})})]}),l.jsxs("div",{className:L.overviewSection,children:[l.jsx("div",{className:L.overviewLabel,children:"Timeline"}),l.jsxs("div",{className:L.timeline,children:[n.createdAt&&l.jsxs("div",{className:L.timelineRow,children:[l.jsx("span",{className:L.timelineKey,children:"Created"}),l.jsx("span",{className:L.timelineValue,children:cc(n.createdAt)})]}),n.assignedAt&&(()=>{const A=Mf(n.createdAt,n.assignedAt);return l.jsxs("div",{className:L.timelineRow,children:[l.jsx("span",{className:L.timelineKey,children:"Assigned"}),l.jsx("span",{className:L.timelineValue,children:cc(n.assignedAt)}),A!==void 0&&l.jsx("span",{className:L.timelineDelta,children:A})]})})(),n.startedAt&&(()=>{const A=Mf(n.assignedAt??n.createdAt,n.startedAt);return l.jsxs("div",{className:L.timelineRow,children:[l.jsx("span",{className:L.timelineKey,children:"Started"}),l.jsx("span",{className:L.timelineValue,children:cc(n.startedAt)}),A!==void 0&&l.jsx("span",{className:L.timelineDelta,children:A})]})})(),n.completedAt&&(()=>{const A=Mf(n.startedAt,n.completedAt);return l.jsxs("div",{className:L.timelineRow,children:[l.jsx("span",{className:L.timelineKey,children:"Completed"}),l.jsx("span",{className:L.timelineValue,children:cc(n.completedAt)}),A!==void 0&&l.jsx("span",{className:L.timelineDelta,children:A})]})})(),!n.createdAt&&!n.assignedAt&&!n.startedAt&&!n.completedAt&&l.jsx("div",{className:L.overviewMuted,children:"No timing data"})]})]}),v&&v.costUsd>0&&l.jsxs("div",{className:L.overviewSection,children:[l.jsx("div",{className:L.overviewLabel,children:"Usage"}),l.jsxs("div",{className:L.timeline,children:[l.jsxs("div",{className:L.timelineRow,children:[l.jsx("span",{className:L.timelineKey,children:"Cost"}),l.jsx("span",{className:L.timelineValue,children:so(v.costUsd)}),l.jsxs("span",{className:L.timelineDelta,children:[v.sessionCount," session",v.sessionCount!==1?"s":""]})]}),_&&_.costUsd>v.costUsd&&l.jsxs("div",{className:L.timelineRow,children:[l.jsx("span",{className:L.timelineKey,children:"Total (incl. subtasks)"}),l.jsx("span",{className:L.timelineValue,children:so(_.costUsd)}),l.jsxs("span",{className:L.timelineDelta,children:[_.sessionCount," session",_.sessionCount!==1?"s":""]})]})]})]}),n.reviewNotes&&l.jsxs("div",{className:L.overviewSection,children:[l.jsx("div",{className:L.overviewLabel,children:"Review Notes"}),l.jsx("div",{className:L.reviewNotes,children:n.reviewNotes})]})]})}function MB({task:n,sessionId:s,isBlocked:i,onStart:o,onResume:c,onStop:u,onPause:d,onDelete:m,onEdit:h}){if(n.status==="not_started")return i?l.jsxs("div",{className:L.headerActions,children:[l.jsx("button",{onClick:h,className:L.btnGhost,children:"Edit"}),l.jsx("button",{onClick:m,className:L.btnDanger,children:"Delete"})]}):l.jsxs("div",{className:L.headerActions,children:[l.jsx("button",{"data-testid":"task-header-start",onClick:o,className:L.btnPrimary,children:"Start"}),l.jsx("button",{onClick:h,className:L.btnGhost,children:"Edit"}),l.jsx("button",{onClick:m,className:L.btnDanger,children:"Delete"})]});if(n.status==="working")return l.jsxs("div",{className:L.headerActions,children:[l.jsx("button",{onClick:u,className:L.btnDanger,children:"Stop"}),l.jsx("button",{onClick:d,disabled:!s,className:L.btnGhost,children:"Pause"})]});if(n.status==="paused")return l.jsxs("div",{className:L.headerActions,children:[l.jsx("button",{onClick:u,className:L.btnPrimary,children:"Stop"}),l.jsx("button",{onClick:c,className:L.btnGhost,children:"Resume"}),l.jsx("button",{onClick:m,className:L.btnDanger,children:"Delete"})]});if(n.status==="complete")return l.jsx("div",{className:L.headerActions,children:l.jsx("button",{onClick:m,className:L.btnDanger,children:"Delete"})});if(n.status==="failed")return l.jsxs("div",{className:L.headerActions,children:[l.jsx("button",{onClick:o,className:L.btnPrimary,children:"Retry"}),l.jsx("button",{onClick:m,className:L.btnDanger,children:"Delete"})]})}function OB({taskSessions:n,selectedSessionId:s,onSelect:i}){if(!(n.length<2))return l.jsxs("div",{className:L.attemptSelector,"data-testid":"attempt-selector",children:[l.jsx("span",{className:L.attemptLabel,children:"Attempts:"}),n.map((o,c)=>{const u=o.id===s,d=o.status==="stopped"&&o.endReason==="completed"?"✓":o.status==="stopped"?"✗":o.status==="running"||o.status==="idle"?"●":"";return l.jsxs("button",{className:`${L.attemptButton} ${u?L.attemptActive:""}`,onClick:()=>i(o.id),title:`Attempt #${c+1} — ${o.status}`,"aria-label":`Attempt #${c+1}, ${o.status}`,"aria-pressed":u,"data-testid":`attempt-${c+1}`,children:["#",c+1,d&&l.jsx("span",{className:L.attemptStatus,children:d})]},o.id)})]})}function fa(){const{taskId:n,workspaceId:s,environmentId:i}=va(),o=It(),c=St(),{events:u,eventsDropped:d,tasks:m,sessions:h,environments:g,findings:v,loadSessionEvents:b,loadFindings:_,kill:S,startTask:T,stopTask:N,resumeTask:j,deleteTask:w,createTask:E,updateTask:A,workspaces:O,taskSessions:C,loadTaskSessions:M,sendInput:G,spawn:U,personas:V,provisionEnvironment:Z}=pt(),ee=y.useRef(void 0),ie=y.useRef(void 0),be=y.useRef(void 0),K=y.useRef(void 0),re=y.useRef(void 0),I=o.pathname.endsWith("/stream")?"stream":o.pathname.endsWith("/findings")?"findings":"overview",$=o.pathname.endsWith("/edit"),[Q,de]=y.useState(I),[me,ze]=y.useState(!1),[je,Ne]=y.useState(void 0),[Ae,ce]=y.useState(""),[fe,pe]=y.useState($),Re=y.useRef(I),Bt=y.useRef($),te=m.find(Me=>Me.id===n),X=(te==null?void 0:te.workspaceId)||void 0,Te=O.find(Me=>Me.id===X);y.useEffect(()=>{I!==Re.current&&(Re.current=I,I!==Q&&de(I))},[I,Q]),y.useEffect(()=>{$!==Bt.current&&(Bt.current=$,$!==fe&&pe($))},[$,fe]),y.useEffect(()=>{if(Ae===""){if(Te!=null&&Te.environmentId)ce(Te.environmentId);else if(g.length>0){const Me=g.find(Mt=>Mt.status==="connected");ce((Me==null?void 0:Me.id)??g[0].id)}}},[Ae,Te==null?void 0:Te.environmentId,g]);const un=te?C[te.id]??[]:[];let Ze;je&&un.some(Me=>Me.id===je)?Ze=je:Ze=(te==null?void 0:te.latestSessionId)||void 0;const Kn=()=>{ze(!0)},Yn=()=>{if(!te)return;w(te.id),ze(!1);const Me=i??(Te==null?void 0:Te.environmentId);c(te.workspaceId&&Me?Wi(te.workspaceId,Me):"/",{replace:!0})};y.useEffect(()=>{(te==null?void 0:te.id)!==ie.current&&(ie.current=te==null?void 0:te.id,Ne(void 0),ce(""),pe($))},[te==null?void 0:te.id,$]),y.useEffect(()=>{if(!(te!=null&&te.id))return;const Me=te.id!==K.current,Mt=te.latestSessionId!==re.current;(Me||Mt)&&(K.current=te.id,re.current=te.latestSessionId,M(te.id))},[te==null?void 0:te.id,te==null?void 0:te.latestSessionId,M]),y.useEffect(()=>{if((te==null?void 0:te.status)!==be.current){const Me=be.current===void 0;be.current=te==null?void 0:te.status;const Mt=(te==null?void 0:te.status)==="not_started"?"overview":(te==null?void 0:te.status)==="working"||(te==null?void 0:te.status)==="paused"?"stream":(te==null?void 0:te.status)==="complete"?"findings":void 0;Mt&&Mt!==Q&&!(Me&&I!=="overview")&&de(Mt)}},[te==null?void 0:te.status,Q,I]);const zn=y.useMemo(()=>new Map(m.map(Me=>[Me.id,Me])),[m]),Jn=y.useMemo(()=>{const Me=Ze?u.filter(Mt=>Mt.sessionId===Ze):[];return im(am(Me))},[u,Ze]),Tn=te?te.dependsOn.some(Me=>{const Mt=zn.get(Me);return Mt!==void 0&&Mt.status!=="complete"}):!1,Ls=y.useMemo(()=>o5(n,i,O,g,zn),[n,i,O,g,zn]);y.useEffect(()=>{Ze&&Ze!==ee.current&&(ee.current=Ze,b(Ze))},[Ze,b]),y.useEffect(()=>{Q==="findings"&&X&&_(X)},[Q,X,_]);const dn=Me=>{de(Me),c(os(n,Me==="overview"?void 0:Me,s,i))};return Ms({key:"1"},()=>dn("overview")),Ms({key:"2"},()=>dn("stream")),Ms({key:"3"},()=>dn("findings")),l.jsxs("div",{className:L.panelContainer,children:[l.jsx(ba,{segments:Ls}),l.jsxs("div",{className:L.header,children:[l.jsxs("span",{className:L.headerTitle,children:[l.jsx("span",{"data-testid":"task-title",children:(te==null?void 0:te.title)||n}),te&&l.jsx("span",{className:L.taskStatusBadge,"data-testid":"task-status",children:te.status}),(te==null?void 0:te.branch)&&l.jsx("span",{className:L.taskBranch,children:te.branch}),Tn&&l.jsx("span",{className:L.taskBlockedBadge,children:"blocked"})]}),te&&l.jsx(MB,{task:te,sessionId:Ze,isBlocked:Tn,onStart:()=>T(te.id,void 0,Ae),onResume:()=>j(te.id),onStop:()=>N(te.id),onPause:()=>Ze&&S(Ze),onDelete:Kn,onEdit:()=>pe(!0)})]}),l.jsxs("div",{className:L.tabBar,role:"tablist","aria-label":"Task view",children:[l.jsx("button",{role:"tab","aria-selected":Q==="overview",className:`${L.tab} ${Q==="overview"?L.active:""}`,onClick:()=>dn("overview"),children:"Overview"}),l.jsx("button",{role:"tab","aria-selected":Q==="stream",className:`${L.tab} ${Q==="stream"?L.active:""}`,onClick:()=>dn("stream"),children:"Stream"}),l.jsx("button",{role:"tab","aria-selected":Q==="findings",className:`${L.tab} ${Q==="findings"?L.active:""}`,onClick:()=>dn("findings"),children:"Findings"})]}),l.jsxs(rs,{mode:"wait",children:[Q==="overview"&&l.jsx(Rt.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},className:L.overviewContent,"data-testid":"task-overview",children:fe&&te?l.jsx(Bx,{mode:"edit",taskId:te.id,workspaceId:X,environmentId:i,tasks:m,workspaces:O,personas:V,onCreateTask:E,onUpdateTask:A,onEditDone:()=>{$?c(os(te.id,void 0,s,i),{replace:!0}):pe(!1)}}):te?l.jsx(RB,{task:te,tasksById:zn,environments:g,workspaces:O,taskSessions:un,selectedEnvId:Ae}):l.jsx("div",{className:L.waitingMessage,children:"No additional details"})},"overview"),Q==="stream"&&l.jsxs(Rt.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},style:{display:"flex",flexDirection:"column",flex:1,overflow:"hidden"},children:[l.jsx(OB,{taskSessions:un,selectedSessionId:Ze,onSelect:Me=>Ne(Me)}),l.jsx(sm,{events:Jn,eventsDropped:d,emptyState:!Ze&&te?Tn?l.jsx("div",{className:L.emptyCta,"data-testid":"stream-blocked-message",children:l.jsx("div",{className:L.ctaDescription,children:"This task is blocked by incomplete dependencies"})}):l.jsxs("div",{className:L.emptyCta,children:[l.jsx("button",{"data-testid":"stream-start-cta",className:L.ctaButton,onClick:()=>T(te.id,void 0,Ae),children:"Start Task"}),l.jsx("div",{className:L.ctaDescription,children:"Click to begin agent execution"})]}):Ze&&Jn.length===0?l.jsx("div",{className:L.waitingMessage,children:"Waiting for events..."}):void 0})]},"stream"),Q==="findings"&&l.jsx(Rt.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},className:L.tabContent,children:X?l.jsx(kB,{findings:v.filter(Me=>Me.workspaceId===X)}):l.jsx("div",{className:L.noContext,children:"Navigate to a task within a workspace to view findings"})},"findings")]}),(()=>{if(!te||te.status!=="working"&&te.status!=="paused")return;const Me=Ze?h.find(Mt=>Mt.id===Ze):void 0;if(!(!Me||Me.status==="stopped"))return l.jsx(jr,{mode:"send",sessionId:Me.id,environmentId:Me.environmentId,personas:V,environments:g,onSendInput:G,onSpawn:U,onStartTask:T,onProvisionEnvironment:Z})})(),te&&l.jsx(Ja,{isOpen:me,title:"Delete Task?",description:`"${te.title}" will be permanently removed.`,onConfirm:Yn,onCancel:()=>ze(!1)})]})}const IB="_container_legrg_1",BB="_header_legrg_8",LB="_headerTitle_legrg_35",UB="_badge_legrg_44",zB="_headerActions_legrg_54",PB="_body_legrg_61",VB="_formContent_legrg_73",qB="_section_legrg_85",HB="_label_legrg_91",GB="_nameInput_legrg_98",$B="_fieldInput_legrg_131",FB="_adapterSelect_legrg_164",ZB="_readOnlyValue_legrg_198",KB="_codespaceSection_legrg_204",YB="_codespaceActions_legrg_210",JB="_creatingHint_legrg_216",WB="_errorHint_legrg_222",XB="_btnPrimary_legrg_235",QB="_btnGhost_legrg_266",se={container:IB,header:BB,headerTitle:LB,badge:UB,headerActions:zB,body:PB,formContent:VB,section:qB,label:HB,nameInput:GB,fieldInput:$B,adapterSelect:FB,readOnlyValue:ZB,codespaceSection:KB,codespaceActions:YB,creatingHint:JB,errorHint:WB,btnPrimary:XB,btnGhost:QB},gc=1,vc=65535;function Of(n){if(!n.trim())return!0;const s=Number(n);return Number.isInteger(s)&&s>=gc&&s<=vc}function If(n){try{const s=JSON.parse(n);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function eL({codespaceName:n,onCodespaceNameChange:s,envName:i,onEnvNameChange:o,codespaces:c,codespaceError:u,codespaceListError:d,codespaceCreating:m,onCreateCodespace:h}){const[g,v]=y.useState("pick"),[b,_]=y.useState(""),[S,T]=y.useState("");return g==="create"?l.jsxs("div",{className:se.codespaceSection,children:[l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,children:"Repository"}),l.jsx("input",{type:"text",value:b,onChange:N=>_(N.target.value),placeholder:"owner/repo",className:se.fieldInput,"data-testid":"env-codespace-repo"})]}),l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,children:"Machine Type"}),l.jsx("input",{type:"text",value:S,onChange:N=>T(N.target.value),placeholder:"Machine type (optional)...",className:se.fieldInput,"data-testid":"env-codespace-machine"})]}),l.jsxs("div",{className:se.codespaceActions,children:[l.jsx("button",{onClick:()=>{b.trim()&&(h(b.trim(),S.trim()||void 0),v("pick"),_(""),T(""))},disabled:!b.trim(),className:se.btnPrimary,children:"Create"}),l.jsx("button",{onClick:()=>{v("pick"),_(""),T("")},className:se.btnGhost,children:"Cancel"})]})]}):l.jsx("div",{className:se.codespaceSection,children:l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,children:"Codespace"}),!d&&l.jsxs("select",{value:n,onChange:N=>{N.target.value==="__create__"?(v("create"),s("")):(s(N.target.value),N.target.value&&!i.trim()&&o(N.target.value))},disabled:m,className:se.adapterSelect,"data-testid":"env-codespace-select",children:[l.jsx("option",{value:"",children:"Select a codespace..."}),c.map(N=>l.jsxs("option",{value:N.name,children:[N.name," (",N.repository,") — ",N.state]},N.name)),l.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),m&&l.jsx("span",{className:se.creatingHint,children:"Creating codespace..."}),d&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:se.errorHint,children:d}),l.jsx("input",{type:"text",value:n,onChange:N=>s(N.target.value),placeholder:"Or enter codespace name manually...",className:se.fieldInput,"data-testid":"env-codespace-manual"})]}),u&&!d&&l.jsx("span",{className:se.errorHint,children:u})]})})}function Lx({mode:n,environmentId:s,environments:i,onAddEnvironment:o,onUpdateEnvironment:c,onListCodespaces:u,codespaces:d,codespaceError:m,codespaceListError:h,codespaceCreating:g,onCreateCodespace:v}){const{showToast:b}=Bs(),_=St(),S=n==="edit",T=S&&s?i.find(ce=>ce.id===s):void 0,[N,j]=y.useState(""),[w,E]=y.useState("local"),[A,O]=y.useState(""),[C,M]=y.useState(""),[G,U]=y.useState(""),[V,Z]=y.useState(""),[ee,ie]=y.useState(""),[be,K]=y.useState(""),[re,I]=y.useState(""),[$,Q]=y.useState(null),de=y.useCallback(()=>{const ce={};if(w==="local"){if(A.trim()&&(ce.host=A.trim()),C.trim()){const fe=Number(C);Number.isInteger(fe)&&(ce.port=fe)}}else if(w==="ssh"){if(ce.host=A.trim(),G.trim()&&(ce.user=G.trim()),C.trim()){const fe=Number(C);Number.isInteger(fe)&&(ce.sshPort=fe)}V.trim()&&(ce.identityFile=V.trim())}else w==="docker"?(ee.trim()&&(ce.image=ee.trim()),be.trim()&&(ce.repo=be.trim())):w==="codespace"&&(ce.codespaceName=re.trim());return ce},[w,A,C,G,V,ee,be,re]),me=()=>!(!N.trim()||w==="ssh"&&!A.trim()||w==="codespace"&&!re.trim()||(w==="local"||w==="ssh")&&!Of(C)),ze=()=>{me()&&(o(N.trim(),w,de()),b("Environment added successfully","success"),_(Xi,{replace:!0}))},je=()=>{_(s?Qi(s):Xi)},Ne=y.useCallback((ce,fe)=>{if(!T||!s)return;const pe=If(T.adapterConfig),Re=fe.trim();Re?pe[ce]=Re:delete pe[ce],c(s,{adapterConfig:pe})},[T,s,c]),Ae=y.useCallback((ce,fe)=>{if(!T||!s)return;const pe=If(T.adapterConfig);if(fe.trim()){const Re=Number(fe);Number.isInteger(Re)&&Re>=gc&&Re<=vc&&(pe[ce]=Re)}else delete pe[ce];c(s,{adapterConfig:pe})},[T,s,c]);if(S){if(!T)return l.jsxs("div",{className:se.container,children:[l.jsxs("div",{className:se.header,children:[l.jsx("div",{className:se.headerTitle,children:l.jsx("span",{className:se.badge,children:"edit environment"})}),l.jsx("div",{className:se.headerActions,children:l.jsx("button",{onClick:je,className:se.btnGhost,children:"Back"})})]}),l.jsx("div",{className:se.body,children:l.jsx("div",{className:se.formContent,children:l.jsx("span",{className:se.readOnlyValue,children:"Environment not found"})})})]});const ce=If(T.adapterConfig);return l.jsxs("div",{className:se.container,"data-testid":"env-edit-panel",children:[l.jsxs("div",{className:se.header,children:[l.jsx("div",{className:se.headerTitle,children:l.jsx("span",{className:se.badge,children:"edit environment"})}),l.jsx("div",{className:se.headerActions,children:l.jsx("button",{onClick:je,className:se.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),l.jsx("div",{className:se.body,children:l.jsxs("div",{className:se.formContent,children:[l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,children:"Name"}),l.jsx(Zt,{value:T.displayName,onSave:fe=>{s&&c(s,{displayName:fe})},validate:fe=>fe.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:$,onActivate:Q,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,children:"Adapter Type"}),l.jsx("span",{className:se.readOnlyValue,"data-testid":"env-edit-adapter-type",children:T.adapterType})]}),T.adapterType==="local"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,children:"Host"}),l.jsx(Zt,{value:String(ce.host??""),onSave:fe=>Ne("host",fe),mode:"edit",fieldId:"host",activeFieldId:$,onActivate:Q,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,children:"Port"}),l.jsx(Zt,{value:String(ce.port??""),onSave:fe=>Ae("port",fe),validate:fe=>Of(fe)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:$,onActivate:Q,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),T.adapterType==="ssh"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,children:"Host"}),l.jsx(Zt,{value:String(ce.host??""),onSave:fe=>Ne("host",fe),validate:fe=>fe.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:$,onActivate:Q,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,children:"User"}),l.jsx(Zt,{value:String(ce.user??""),onSave:fe=>Ne("user",fe),mode:"edit",fieldId:"user",activeFieldId:$,onActivate:Q,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,children:"SSH Port"}),l.jsx(Zt,{value:String(ce.sshPort??""),onSave:fe=>Ae("sshPort",fe),validate:fe=>Of(fe)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:$,onActivate:Q,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,children:"Identity File"}),l.jsx(Zt,{value:String(ce.identityFile??""),onSave:fe=>Ne("identityFile",fe),mode:"edit",fieldId:"identityFile",activeFieldId:$,onActivate:Q,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),T.adapterType==="docker"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,children:"Image"}),l.jsx(Zt,{value:String(ce.image??""),onSave:fe=>Ne("image",fe),mode:"edit",fieldId:"image",activeFieldId:$,onActivate:Q,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,children:"Repo"}),l.jsx(Zt,{value:String(ce.repo??""),onSave:fe=>Ne("repo",fe),mode:"edit",fieldId:"repo",activeFieldId:$,onActivate:Q,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),T.adapterType==="codespace"&&l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,children:"Codespace Name"}),l.jsx(Zt,{value:String(ce.codespaceName??""),onSave:fe=>Ne("codespaceName",fe),validate:fe=>fe.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:$,onActivate:Q,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return l.jsxs("div",{className:se.container,"data-testid":"env-create-panel",children:[l.jsxs("div",{className:se.header,children:[l.jsx("div",{className:se.headerTitle,children:l.jsx("span",{className:se.badge,children:"new environment"})}),l.jsxs("div",{className:se.headerActions,children:[l.jsx("button",{onClick:ze,disabled:!me(),className:se.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),l.jsx("button",{onClick:je,className:se.btnGhost,children:"Cancel"})]})]}),l.jsx("div",{className:se.body,children:l.jsxs("div",{className:se.formContent,children:[l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,htmlFor:"env-create-name",children:"Name"}),l.jsx("input",{id:"env-create-name",type:"text",value:N,onChange:ce=>j(ce.target.value),placeholder:"Environment name...",autoFocus:!0,className:se.nameInput,"data-testid":"env-create-name",onKeyDown:ce=>{ce.key==="Enter"&&me()&&ze()}})]}),l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),l.jsxs("select",{id:"env-create-adapter",value:w,onChange:ce=>{E(ce.target.value),ce.target.value==="codespace"&&u()},className:se.adapterSelect,"data-testid":"env-create-adapter",children:[l.jsx("option",{value:"local",children:"local"}),l.jsx("option",{value:"ssh",children:"ssh"}),l.jsx("option",{value:"docker",children:"docker"}),l.jsx("option",{value:"codespace",children:"codespace"})]})]}),w==="local"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,htmlFor:"env-create-host",children:"Host"}),l.jsx("input",{id:"env-create-host",type:"text",value:A,onChange:ce=>O(ce.target.value),placeholder:"Host (optional)...",className:se.fieldInput,"data-testid":"env-create-host"})]}),l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,htmlFor:"env-create-port",children:"Port"}),l.jsx("input",{id:"env-create-port",type:"number",min:gc,max:vc,value:C,onChange:ce=>M(ce.target.value),placeholder:"Port (optional)...",className:se.fieldInput,"data-testid":"env-create-port"})]})]}),w==="ssh"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,htmlFor:"env-create-host",children:"Host"}),l.jsx("input",{id:"env-create-host",type:"text",value:A,onChange:ce=>O(ce.target.value),placeholder:"Host (required)...",className:se.fieldInput,"data-testid":"env-create-host"})]}),l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,htmlFor:"env-create-user",children:"User"}),l.jsx("input",{id:"env-create-user",type:"text",value:G,onChange:ce=>U(ce.target.value),placeholder:"User (optional)...",className:se.fieldInput,"data-testid":"env-create-user"})]}),l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,htmlFor:"env-create-port",children:"SSH Port"}),l.jsx("input",{id:"env-create-port",type:"number",min:gc,max:vc,value:C,onChange:ce=>M(ce.target.value),placeholder:"SSH port (optional)...",className:se.fieldInput,"data-testid":"env-create-port"})]}),l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,htmlFor:"env-create-identity",children:"Identity File"}),l.jsx("input",{id:"env-create-identity",type:"text",value:V,onChange:ce=>Z(ce.target.value),placeholder:"Identity file (optional)...",className:se.fieldInput,"data-testid":"env-create-identity"})]})]}),w==="docker"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,htmlFor:"env-create-image",children:"Image"}),l.jsx("input",{id:"env-create-image",type:"text",value:ee,onChange:ce=>ie(ce.target.value),placeholder:"Image (optional)...",className:se.fieldInput,"data-testid":"env-create-image"})]}),l.jsxs("div",{className:se.section,children:[l.jsx("label",{className:se.label,htmlFor:"env-create-repo",children:"Repo"}),l.jsx("input",{id:"env-create-repo",type:"text",value:be,onChange:ce=>K(ce.target.value),placeholder:"Repo (optional)...",className:se.fieldInput,"data-testid":"env-create-repo"})]})]}),w==="codespace"&&l.jsx(eL,{codespaceName:re,onCodespaceNameChange:I,envName:N,onEnvNameChange:j,codespaces:d,codespaceError:m,codespaceListError:h,codespaceCreating:g,onCreateCodespace:v})]})})]})}function tL(){const{environments:n,addEnvironment:s,updateEnvironment:i,listCodespaces:o,codespaces:c,codespaceError:u,codespaceListError:d,codespaceCreating:m,createCodespace:h}=pt();return l.jsx(Lx,{mode:"new",environments:n,onAddEnvironment:s,onUpdateEnvironment:i,onListCodespaces:o,codespaces:c,codespaceError:u,codespaceListError:d,codespaceCreating:m,onCreateCodespace:h})}function nL(){const{environmentId:n}=va(),{environments:s,addEnvironment:i,updateEnvironment:o,listCodespaces:c,codespaces:u,codespaceError:d,codespaceListError:m,codespaceCreating:h,createCodespace:g}=pt();return l.jsx(Lx,{mode:"edit",environmentId:n,environments:s,onAddEnvironment:i,onUpdateEnvironment:o,onListCodespaces:c,codespaces:u,codespaceError:d,codespaceListError:m,codespaceCreating:h,onCreateCodespace:g})}const sL="_layout_11u79_1",aL="_content_11u79_8",iL="_tabPanel_11u79_14",br={layout:sL,content:aL,tabPanel:iL};function oL(){const n=n5();return l.jsxs("div",{className:br.layout,children:[l.jsx(ba,{segments:n}),l.jsx("div",{className:br.content,children:l.jsx(Qa,{})})]})}const rL="_container_13sb6_1",lL="_envHeader_13sb6_6",cL="_envTitleRow_13sb6_10",uL="_statusDot_13sb6_16",dL="_envName_13sb6_21",fL="_statusBadge_13sb6_27",pL="_envMeta_13sb6_33",mL="_metaTag_13sb6_39",hL="_actions_13sb6_51",gL="_provisionMessage_13sb6_59",vL="_errorMessage_13sb6_64",yL="_section_13sb6_69",bL="_sectionHeader_13sb6_73",_L="_cardList_13sb6_121",xL="_card_13sb6_121",SL="_cardHeader_13sb6_138",TL="_cardName_13sb6_144",kL="_cardActions_13sb6_149",wL="_cardDescription_13sb6_154",NL="_cardMeta_13sb6_160",jL="_repoLink_13sb6_166",CL="_empty_13sb6_174",EL="_btnPrimary_13sb6_180",AL="_btnOutline_13sb6_214",DL="_btnSmall_13sb6_241",RL="_btnDanger_13sb6_267",$e={container:rL,envHeader:lL,envTitleRow:cL,statusDot:uL,envName:dL,statusBadge:fL,envMeta:pL,metaTag:mL,actions:hL,provisionMessage:gL,errorMessage:vL,section:yL,sectionHeader:bL,cardList:_L,card:xL,cardHeader:SL,cardName:TL,cardActions:kL,cardDescription:wL,cardMeta:NL,repoLink:jL,empty:CL,btnPrimary:EL,btnOutline:AL,btnSmall:DL,btnDanger:RL},ML={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function OL(){const{environmentId:n}=va(),s=St(),{environments:i,workspaces:o,sessions:c,provisionStatus:u,provisionEnvironment:d,stopEnvironment:m,removeEnvironment:h,archiveWorkspace:g}=pt(),[v,b]=y.useState(!1),[_,S]=y.useState(!1),[T,N]=y.useState(void 0),j=i.find(ie=>ie.id===n);if(!n||!j)return l.jsx(Zn,{to:Xi,replace:!0});const w=o.filter(ie=>ie.environmentId===j.id),E=c.filter(ie=>ie.environmentId===j.id),A=E.reduce((ie,be)=>ie+(be.costUsd??0),0),O=ML[j.status]||"var(--text-tertiary)",C=j.status==="connected",M=j.status==="connecting",G=j.status==="disconnected"||j.status==="error",U=j.id in u?u[j.id]:void 0,V=()=>{h(j.id),b(!1),s(Xi,{replace:!0})},Z=()=>{S(!1),d(j.id,!0)},ee=ie=>{g(ie),N(void 0)};return l.jsxs("div",{className:$e.container,children:[l.jsx(Ja,{isOpen:v,title:"Delete Environment?",description:`"${j.displayName||j.id}" will be permanently removed along with all its data.`,onConfirm:V,onCancel:()=>b(!1)}),l.jsx(Ja,{isOpen:_,title:"Reprovision Environment?",description:"This will kill any active session and force a fresh provision cycle. The environment will be temporarily disconnected.",confirmLabel:"Reprovision",onConfirm:Z,onCancel:()=>S(!1)}),l.jsxs("div",{className:$e.envHeader,children:[l.jsxs("div",{className:$e.envTitleRow,children:[l.jsx("span",{className:$e.statusDot,style:{color:O},children:"●"}),l.jsx("h2",{className:$e.envName,children:j.displayName||j.id}),l.jsx("span",{className:$e.statusBadge,style:{color:O},children:j.status})]}),l.jsxs("div",{className:$e.envMeta,children:[l.jsxs("span",{className:$e.metaTag,children:["Adapter: ",j.adapterType]}),E.length>0&&l.jsxs("span",{className:$e.metaTag,children:[E.length," session",E.length!==1?"s":""]}),A>0&&l.jsxs("span",{className:$e.metaTag,children:["Cost: ",so(A)]})]})]}),l.jsxs("div",{className:$e.actions,children:[C&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:$e.btnPrimary,onClick:()=>s(Cb(j.id)),children:"New Chat"}),l.jsx("button",{className:$e.btnOutline,onClick:()=>m(j.id),children:"Stop"}),l.jsx("button",{className:$e.btnOutline,onClick:()=>S(!0),disabled:U!==void 0,"data-testid":"env-reprovision-btn",children:"Reprovision"})]}),G&&l.jsx("button",{className:$e.btnPrimary,onClick:()=>d(j.id),children:j.status==="error"?"Retry":"Connect"}),M&&U!==void 0&&l.jsx("span",{className:$e.provisionMessage,children:U.message}),j.status==="error"&&(U==null?void 0:U.stage)==="error"&&l.jsx("span",{className:$e.errorMessage,children:U.message}),l.jsx("button",{className:$e.btnOutline,onClick:()=>s(lw(j.id)),"data-testid":"env-edit-btn",children:"Edit Config"}),l.jsx("button",{className:$e.btnDanger,onClick:()=>b(!0),children:"Delete"})]}),l.jsxs("div",{className:$e.section,children:[l.jsxs("div",{className:$e.sectionHeader,children:[l.jsx("h3",{children:"Workspaces"}),l.jsx("button",{className:$e.btnPrimary,onClick:()=>s(`${Ab}?environment=${encodeURIComponent(j.id)}`),"data-testid":"workspace-create-button",children:"+ New Workspace"})]}),w.length===0&&l.jsx("p",{className:$e.empty,children:"No workspaces yet. Create one to get started."}),l.jsx("div",{className:$e.cardList,children:w.map(ie=>l.jsx(IL,{workspace:ie,confirmArchiveId:T,onOpen:()=>s(Wi(ie.id,j.id)),onArchive:()=>N(ie.id),onConfirmArchive:()=>ee(ie.id),onCancelArchive:()=>N(void 0)},ie.id))})]})]})}function IL({workspace:n,confirmArchiveId:s,onOpen:i,onArchive:o,onConfirmArchive:c,onCancelArchive:u}){const d=s===n.id,m=n.repoUrl&&/^https?:\/\//.test(n.repoUrl);return l.jsxs("div",{className:$e.card,"data-testid":"workspace-card",children:[l.jsxs("div",{className:$e.cardHeader,children:[l.jsx("strong",{className:$e.cardName,children:n.name}),l.jsxs("div",{className:$e.cardActions,children:[l.jsx("button",{className:$e.btnSmall,onClick:i,children:"Open"}),d?l.jsxs(l.Fragment,{children:[l.jsx("button",{className:$e.btnDanger,onClick:c,children:"Confirm"}),l.jsx("button",{className:$e.btnSmall,onClick:u,children:"Cancel"})]}):l.jsx("button",{className:$e.btnSmall,onClick:o,children:"Archive"})]})]}),n.description&&l.jsx("p",{className:$e.cardDescription,children:n.description}),n.repoUrl&&l.jsx("div",{className:$e.cardMeta,children:m?l.jsx("a",{href:n.repoUrl,target:"_blank",rel:"noopener noreferrer",className:$e.repoLink,children:n.repoUrl}):l.jsx("span",{children:n.repoUrl})})]})}const BL={credentials:"Credentials",personas:"Personas",appearance:"Appearance",about:"About",shortcuts:"Shortcuts"};function LL(){const s=It().pathname.replace(/^\/settings\/?/,"").split("/")[0],i=BL[s],o=t5(i);return l.jsxs("div",{className:br.layout,children:[l.jsx(ba,{segments:o}),l.jsx("div",{className:br.content,children:l.jsx("div",{className:br.tabPanel,children:l.jsx(Qa,{})},s)})]})}const UL="_section_1ingb_14",zL="_sectionTitle_1ingb_26",PL="_sectionDescription_1ingb_35",VL="_tokenList_1ingb_48",qL="_tokenRow_1ingb_55",HL="_tokenBadge_1ingb_68",GL="_tokenName_1ingb_83",$L="_tokenTarget_1ingb_90",FL="_deleteButton_1ingb_99",ZL="_addForm_1ingb_113",KL="_formRow_1ingb_119",YL="_input_1ingb_125",JL="_select_1ingb_155",WL="_addButton_1ingb_187",XL="_emptyStateInfo_1ingb_221",QL="_themeOptions_1ingb_229",e8="_themeOption_1ingb_229",t8="_themeOptionSelected_1ingb_254",n8="_themeOptionHeader_1ingb_259",s8="_themeOptionLabel_1ingb_266",a8="_themeOptionDesc_1ingb_273",i8="_variantToggle_1ingb_279",o8="_variantButton_1ingb_286",r8="_variantActive_1ingb_305",l8="_themeSwatches_1ingb_311",c8="_themeSwatch_1ingb_311",u8="_systemToggle_1ingb_325",d8="_systemToggleHint_1ingb_341",f8="_themeActive_1ingb_348",p8="_aboutGrid_1ingb_354",m8="_aboutItem_1ingb_360",h8="_aboutLabel_1ingb_373",g8="_aboutValue_1ingb_379",v8="_aboutDot_1ingb_387",y8="_aboutDotConnected_1ingb_394",b8="_aboutDotDisconnected_1ingb_398",he={section:UL,sectionTitle:zL,sectionDescription:PL,tokenList:VL,tokenRow:qL,tokenBadge:HL,tokenName:GL,tokenTarget:$L,deleteButton:FL,addForm:ZL,formRow:KL,input:YL,select:JL,addButton:WL,emptyStateInfo:XL,themeOptions:QL,themeOption:e8,themeOptionSelected:t8,themeOptionHeader:n8,themeOptionLabel:s8,themeOptionDesc:a8,variantToggle:i8,variantButton:o8,variantActive:r8,themeSwatches:l8,themeSwatch:c8,systemToggle:u8,systemToggleHint:d8,themeActive:f8,aboutGrid:p8,aboutItem:m8,aboutLabel:h8,aboutValue:g8,aboutDot:v8,aboutDotConnected:y8,aboutDotDisconnected:b8},_8=[{key:"claude",label:"Claude",description:"Forward Claude credentials for AI agent access.",options:[{value:"off",label:"Off"},{value:"subscription",label:"Subscription"},{value:"api_key",label:"API Key"}]},{key:"github",label:"GitHub",description:"Forward GITHUB_TOKEN and GH_TOKEN for git operations.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"copilot",label:"Copilot",description:"Forward Copilot tokens (COPILOT_GITHUB_TOKEN, CLI config).",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"codex",label:"Codex",description:"Forward OPENAI_API_KEY for Codex/OpenAI access.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"goose",label:"Goose",description:"Forward Goose config and API keys for Goose agent access.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]}];function x8({credentialProviders:n,onUpdateCredentialProviders:s}){const i=(o,c)=>{const u={...n};o==="claude"?u.claude=c:u[o]=c,s(u)};return l.jsxs("section",{className:he.section,children:[l.jsx("h3",{className:he.sectionTitle,children:"Credential Providers"}),l.jsx("p",{className:he.sectionDescription,children:"Enable providers to automatically forward credentials to environments at task start. Credentials are read fresh from the host each time."}),l.jsx("div",{className:he.tokenList,children:_8.map(o=>l.jsxs("div",{className:he.tokenRow,children:[l.jsx("span",{className:he.tokenName,children:o.label}),l.jsx("span",{className:he.tokenTarget,children:o.description}),l.jsx("select",{className:he.select,value:n[o.key],onChange:c=>i(o.key,c.target.value),children:o.options.map(c=>l.jsx("option",{value:c.value,children:c.label},c.value))})]},o.key))})]})}const S8=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function T8({tokens:n,onSetToken:s,onDeleteToken:i}){const{showToast:o}=Bs(),[c,u]=y.useState(""),[d,m]=y.useState(""),[h,g]=y.useState("env_var"),[v,b]=y.useState(""),[_,S]=y.useState(null),T=w=>{if(w.preventDefault(),!c||!d)return;const E=h==="env_var"?v||c.toUpperCase()+"_TOKEN":"";s(c,d,h,E,h==="file"?v:""),o("Token saved successfully","success"),u(""),m(""),b("")},N=w=>{S(w)},j=()=>{_&&(i(_),o("Token deleted","info")),S(null)};return l.jsxs(l.Fragment,{children:[l.jsx(Ja,{isOpen:_!==null,title:"Delete Token?",description:_?`"${_}" will be permanently removed.`:void 0,onConfirm:j,onCancel:()=>S(null)}),l.jsxs("section",{className:he.section,children:[l.jsx("h3",{className:he.sectionTitle,children:"Tokens"}),l.jsx("p",{className:he.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),n.length===0?l.jsx("div",{className:he.emptyStateInfo,children:"Add your first API token to enable service integrations."}):l.jsx("div",{className:he.tokenList,children:n.map(w=>l.jsxs("div",{className:he.tokenRow,children:[l.jsx("span",{className:he.tokenBadge,children:w.tokenType}),l.jsx("span",{className:he.tokenName,children:w.name}),l.jsx("span",{className:he.tokenTarget,children:w.tokenType==="env_var"?w.envVar:w.filePath}),l.jsx("button",{className:he.deleteButton,onClick:()=>N(w.name),title:`Delete ${w.name}`,children:"×"})]},w.name))}),l.jsxs("form",{className:he.addForm,onSubmit:T,children:[l.jsxs("div",{className:he.formRow,children:[l.jsx("input",{className:he.input,type:"text",placeholder:"Token name",value:c,onChange:w=>u(w.target.value)}),l.jsx("input",{className:he.input,type:"password",placeholder:"Value",value:d,onChange:w=>m(w.target.value)})]}),l.jsxs("div",{className:he.formRow,children:[l.jsx("select",{className:he.select,value:h,onChange:w=>g(w.target.value),children:S8.map(w=>l.jsx("option",{value:w.value,children:w.label},w.value))}),l.jsx("input",{className:he.input,type:"text",placeholder:h==="env_var"?"Env var name (e.g. API_TOKEN)":"File path (e.g. /home/user/.token)",value:v,onChange:w=>b(w.target.value)}),l.jsx("button",{className:he.addButton,type:"submit",children:"Add Token"})]})]})]})]})}function k8(){const{tokens:n,setToken:s,deleteToken:i,credentialProviders:o,updateCredentialProviders:c}=pt();return l.jsxs(l.Fragment,{children:[l.jsx(x8,{credentialProviders:o,onUpdateCredentialProviders:c}),l.jsx(T8,{tokens:n,onSetToken:s,onDeleteToken:i})]})}const w8="_container_10efq_1",N8="_header_10efq_7",j8="_form_10efq_19",C8="_formActions_10efq_87",E8="_editableSection_10efq_94",A8="_list_10efq_105",D8="_card_10efq_111",R8="_cardHeader_10efq_125",M8="_cardTitle_10efq_135",O8="_defaultBadge_10efq_141",I8="_cardActions_10efq_155",B8="_description_10efq_160",L8="_meta_10efq_166",U8="_empty_10efq_212",z8="_typeToggle_10efq_348",P8="_typeBadge_10efq_362",V8="_scriptEditor_10efq_376",q8="_optional_10efq_383",gt={container:w8,header:N8,form:j8,formActions:C8,editableSection:E8,list:A8,card:D8,cardHeader:R8,cardTitle:M8,defaultBadge:O8,cardActions:I8,description:B8,meta:L8,empty:U8,typeToggle:z8,typeBadge:P8,scriptEditor:V8,optional:q8};function H8({personas:n,appDefaultPersonaId:s,onDeletePersona:i,onSetAppDefaultPersonaId:o,onNavigateToNew:c,onNavigateToPersona:u}){const[d,m]=y.useState(null),h=d?n.find(v=>v.id===d):void 0,g=async v=>{await i(v),m(null)};return l.jsxs("div",{className:gt.container,children:[l.jsxs("div",{className:gt.header,children:[l.jsx("h2",{children:"Personas"}),l.jsx(As,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),n.length===0?l.jsx("p",{className:gt.empty,children:"No personas yet. Create one to get started."}):l.jsx("div",{className:gt.list,children:n.map(v=>{const b=s===v.id,_=v.type==="script";return l.jsxs("div",{className:gt.card,"data-testid":`persona-card-${v.id}`,onClick:()=>u(v.id),role:"button",tabIndex:0,onKeyDown:S=>{S.currentTarget===S.target&&(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),u(v.id))},children:[l.jsxs("div",{className:gt.cardHeader,children:[l.jsxs("span",{className:gt.cardTitle,children:[l.jsx("strong",{children:v.name}),l.jsx("span",{className:gt.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:_?"Script":"Agent"}),b&&l.jsx("span",{className:gt.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),l.jsxs("div",{className:gt.cardActions,onClick:S=>S.stopPropagation(),children:[!b&&l.jsx(As,{variant:"ghost",size:"sm",onClick:()=>{o(v.id).catch(()=>{})},"data-testid":`persona-set-default-${v.id}`,title:"Set as app default persona",children:"Set Default"}),l.jsx(As,{variant:"ghost",size:"sm",onClick:()=>u(v.id),children:"Edit"}),l.jsx(As,{variant:"ghost",size:"sm",onClick:()=>m(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&l.jsx("p",{className:gt.description,children:v.description}),l.jsxs("div",{className:gt.meta,children:[v.runtime&&l.jsxs("span",{children:["Runtime: ",v.runtime]}),v.model&&l.jsxs("span",{children:["Model: ",v.model]}),v.maxTurns>0&&l.jsxs("span",{children:["Max turns: ",v.maxTurns]})]})]},v.id)})}),l.jsx(Ja,{isOpen:d!==null,title:"Delete Persona?",description:`"${(h==null?void 0:h.name)??""}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:()=>{d&&g(d).catch(()=>{})},onCancel:()=>m(null)})]})}function G8(){const{personas:n,deletePersona:s,appDefaultPersonaId:i,setAppDefaultPersonaId:o}=pt(),{showToast:c}=Bs(),u=St();return l.jsx(H8,{personas:n,appDefaultPersonaId:i,onDeletePersona:async d=>{try{await s(d)}catch(m){throw console.error("Failed to delete persona",{personaId:d,error:m}),c("Failed to delete persona","error"),m}},onSetAppDefaultPersonaId:async d=>{try{await o(d)}catch(m){console.error("Failed to set app default persona ID",{personaId:d,error:m}),c("Failed to set app default persona","error")}},onNavigateToNew:()=>u(uw),onNavigateToPersona:d=>u(Eb(d))})}const $8="_container_uy08i_1",F8="_header_uy08i_7",Z8="_count_uy08i_13",K8="_presets_uy08i_18",Y8="_presetButton_uy08i_24",J8="_filterInput_uy08i_41",W8="_groups_uy08i_53",X8="_group_uy08i_53",Q8="_groupHeader_uy08i_68",eU="_groupName_uy08i_77",tU="_groupCount_uy08i_81",nU="_toolList_uy08i_87",sU="_toolItem_uy08i_95",aU="_toolName_uy08i_103",en={container:$8,header:F8,count:Z8,presets:K8,presetButton:Y8,filterInput:J8,groups:W8,group:X8,groupHeader:Q8,groupName:eU,groupCount:tU,toolList:nU,toolItem:sU,toolName:aU},iU=(()=>{const n=new Map;for(const s of rb){const i=s==="get_version_status"?"version":s.split("_")[0];n.has(i)||n.set(i,[]),n.get(i).push(s)}return[...n.entries()].sort(([s],[i])=>s.localeCompare(i)).map(([s,i])=>({group:s,tools:i.sort()}))})(),oU=[{name:"default",label:"Default",tools:lb},{name:"worker",label:"Worker",tools:gT},{name:"orchestrator",label:"Orchestrator",tools:vT},{name:"admin",label:"Admin",tools:yT}];function eb({selectedTools:n,onChange:s,disabled:i}){const[o,c]=y.useState(""),u=y.useMemo(()=>new Set(n),[n]),d=y.useCallback(v=>{if(i)return;const b=new Set(u);b.has(v)?b.delete(v):b.add(v),s([...b].sort())},[u,s,i]),m=y.useCallback((v,b)=>{if(i)return;const _=new Set(u);for(const S of v)b?_.delete(S):_.add(S);s([..._].sort())},[u,s,i]),h=y.useCallback(v=>{i||s([...v].sort())},[s,i]),g=o.toLowerCase();return l.jsxs("div",{className:en.container,"data-testid":"mcp-tool-selector",children:[l.jsx("div",{className:en.header,children:l.jsx("span",{className:en.count,children:n.length===0?`Using default (${lb.length} tools)`:`${n.length} of ${rb.size} tools selected`})}),l.jsxs("div",{className:en.presets,"data-testid":"mcp-tool-presets",children:[oU.map(v=>l.jsx("button",{type:"button",className:en.presetButton,disabled:i,onClick:()=>h(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),l.jsx("button",{type:"button",className:en.presetButton,disabled:i,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),l.jsx("input",{type:"text",className:en.filterInput,placeholder:"Filter tools...",value:o,onChange:v=>c(v.target.value),disabled:i,"data-testid":"mcp-tool-filter"}),l.jsx("div",{className:en.groups,children:iU.map(({group:v,tools:b})=>{const _=g?b.filter(T=>T.toLowerCase().includes(g)):b;if(_.length===0)return null;const S=_.every(T=>u.has(T));return l.jsxs("div",{className:en.group,"data-testid":`tool-group-${v}`,children:[l.jsxs("label",{className:en.groupHeader,children:[l.jsx("input",{type:"checkbox",checked:S,onChange:()=>m(_,S),disabled:i,"data-testid":`group-toggle-${v}`}),l.jsx("span",{className:en.groupName,children:v}),l.jsxs("span",{className:en.groupCount,children:["(",_.filter(T=>u.has(T)).length,"/",_.length,")"]})]}),l.jsx("div",{className:en.toolList,children:_.map(T=>l.jsxs("label",{className:en.toolItem,children:[l.jsx("input",{type:"checkbox",checked:u.has(T),onChange:()=>d(T),disabled:i,"data-testid":`tool-${T}`}),l.jsx("span",{className:en.toolName,children:T})]},T))})]},v)})})]})}const tb=[{value:"claude-code",label:"claude-code"},{value:"codex",label:"codex"},{value:"copilot",label:"copilot"},{value:"goose",label:"goose"},{value:"stub",label:"stub"},{value:"claude-code-acp",label:"claude-code-acp (experimental)"},{value:"codex-acp",label:"codex-acp (experimental)"},{value:"copilot-acp",label:"copilot-acp (experimental)"}],nb=[{value:"genaiscript",label:"genaiscript"}],rU="0";function sb(){const{personaId:n}=va(),s=St(),{showToast:i}=Bs(),{personas:o,createPersona:c,updatePersona:u,deletePersona:d,appDefaultPersonaId:m,setAppDefaultPersonaId:h}=pt(),g=n===void 0,v=g?void 0:o.find(_=>_.id===n);if(!g&&o.length>0&&!v)return l.jsx(Zn,{to:af,replace:!0});const b=[{label:"Settings",url:Ji},{label:"Personas",url:af},{label:g?"New Persona":(v==null?void 0:v.name)??"Persona",url:void 0}];return l.jsxs("div",{className:gt.container,children:[l.jsx(ba,{segments:b}),l.jsx(lU,{existing:v,isNew:g,appDefaultPersonaId:m,onCreatePersona:c,onUpdatePersona:u,onDeletePersona:d,onSetAppDefaultPersonaId:h,onDone:()=>{s(af)},showToast:i})]})}function lU({existing:n,isNew:s,appDefaultPersonaId:i,onCreatePersona:o,onUpdatePersona:c,onDeletePersona:u,onSetAppDefaultPersonaId:d,onDone:m,showToast:h}){const g=St(),[v,b]=y.useState((n==null?void 0:n.name)??""),[_,S]=y.useState((n==null?void 0:n.description)??""),[T,N]=y.useState((n==null?void 0:n.systemPrompt)??""),[j,w]=y.useState((n==null?void 0:n.runtime)??"claude-code"),[E,A]=y.useState((n==null?void 0:n.model)??"sonnet"),[O,C]=y.useState((n==null?void 0:n.maxTurns)??0),[M,G]=y.useState((n==null?void 0:n.type)==="script"?"script":"agent"),[U,V]=y.useState((n==null?void 0:n.script)??""),[Z,ee]=y.useState((n==null?void 0:n.allowedMcpTools)??[]),[ie,be]=y.useState(!1),[K,re]=y.useState(null),[I,$]=y.useState(!!s);y.useEffect(()=>{if(!s&&n&&!I){$(!0),b(n.name),S(n.description),N(n.systemPrompt);const X=n.type==="script"?"script":"agent";w(X==="script"?n.runtime||"genaiscript":n.runtime),A(n.model),C(n.maxTurns),G(X),V(n.script||""),ee(n.allowedMcpTools)}},[s,n,I]);const Q=X=>{G(X),X==="script"?w("genaiscript"):j==="genaiscript"&&w("claude-code")},de=!s&&n===void 0,me=v.trim().length>0&&!de&&T.trim().length>0&&(M==="script"?U.trim().length>0:!!j&&!!E),ze=s&&me,je=!s&&i===(n==null?void 0:n.id),Ne=!s&&n&&!je&&M==="agent"&&!!j&&!!E,Ae=(X,Te)=>{if(!X.trim())return`${Te} is required`},ce=X=>{if(X.preventDefault(),!(de||!me)){if(n){c(n.id,v,_,T,j,E,O,M,U).then(()=>{h("Persona updated","success"),m()},()=>{h("Failed to save persona","error")});return}o(v,_,T,j,E,O,M,U,Z).then(Te=>{h("Persona created","success"),g(Eb(Te.id),{replace:!0})},()=>{h("Failed to save persona","error")})}},fe=()=>{n&&u(n.id).then(()=>{h("Persona deleted","success"),m()},()=>{h("Failed to delete persona","error")})},pe=async(X,Te,un,Ze)=>X().then(()=>{Te(),h(un,"success")},()=>{h(Ze,"error")}),Re=(X,Te)=>{if(!n)return;const un=X==="type"?String(Te):M,Ze=X==="runtime"?String(Te):X==="type"?String(Te)==="script"?"genaiscript":j==="genaiscript"?"claude-code":j:j,Kn=X==="model"?String(Te):E,Yn=X==="maxTurns"?Number(Te):O,zn=X==="systemPrompt"?String(Te):T,Jn=X==="script"?String(Te):U;pe(()=>c(n.id,X==="name"?String(Te):v,X==="description"?String(Te):_,zn,Ze,Kn,Yn,un,Jn),()=>{if(X==="type"){const Tn=String(Te)==="script"?"script":"agent";G(Tn),w(Ze)}X==="runtime"&&w(String(Te)),X==="name"&&b(String(Te)),X==="description"&&S(String(Te)),X==="systemPrompt"&&N(String(Te)),X==="model"&&A(String(Te)),X==="maxTurns"&&C(Number(Te)),X==="script"&&V(String(Te))},"Persona updated","Failed to update persona").catch(()=>{})},Bt=X=>{ce(X)},te=()=>{n&&d(n.id).then(()=>{h("Set as app default","success")},()=>{h("Failed to set app default","error")})};return l.jsxs(l.Fragment,{children:[de?l.jsxs("div",{className:gt.form,children:[l.jsx("h3",{children:"Edit Persona"}),l.jsx("p",{children:"Loading persona..."})]}):s?l.jsxs("form",{onSubmit:Bt,className:gt.form,children:[l.jsx("h3",{children:"Create Persona"}),l.jsxs("div",{className:gt.typeToggle,"data-testid":"persona-type-toggle",children:[l.jsxs("label",{children:[l.jsx("input",{type:"radio",name:"personaType",value:"agent",checked:M==="agent",onChange:()=>Q("agent")}),"Agent"]}),l.jsxs("label",{children:[l.jsx("input",{type:"radio",name:"personaType",value:"script",checked:M==="script",onChange:()=>Q("script")}),"Script"]})]}),l.jsxs("label",{children:["Name",l.jsx("input",{type:"text",value:v,onChange:X=>b(X.target.value),placeholder:M==="script"?"e.g. Nightly Report":"e.g. Frontend Engineer",required:!0,"data-testid":"persona-detail-name"})]}),l.jsxs("label",{children:["Description",l.jsx("input",{type:"text",value:_,onChange:X=>S(X.target.value),placeholder:"Brief description...","data-testid":"persona-detail-description"})]}),l.jsxs("label",{children:["Runtime",l.jsx("select",{value:j,onChange:X=>w(X.target.value),"data-testid":"persona-runtime-select",children:(M==="script"?nb:tb).map(X=>l.jsx("option",{value:X.value,children:X.label},X.value))})]}),M==="agent"&&l.jsxs(l.Fragment,{children:[l.jsxs("label",{children:["Model",l.jsx("input",{type:"text",value:E,onChange:X=>A(X.target.value),placeholder:"e.g. sonnet","data-testid":"persona-detail-model"})]}),l.jsxs("label",{children:["Max Turns",l.jsx("input",{type:"number",value:O,onChange:X=>C(parseInt(X.target.value,10)||0),min:0,"data-testid":"persona-detail-max-turns"})]}),l.jsxs("label",{children:["System Prompt",l.jsx("textarea",{value:T,onChange:X=>N(X.target.value),placeholder:"You are a senior frontend engineer...",rows:10,required:!0,"data-testid":"persona-detail-prompt"})]})]}),M==="script"&&l.jsxs(l.Fragment,{children:[l.jsxs("label",{children:["Model ",l.jsx("span",{className:gt.optional,children:"(optional)"}),l.jsx("input",{type:"text",value:E,onChange:X=>A(X.target.value),placeholder:"e.g. sonnet (leave empty for script-only)","data-testid":"persona-detail-model"})]}),l.jsxs("label",{children:["System Prompt",l.jsx("textarea",{value:T,onChange:X=>N(X.target.value),placeholder:"Context for the script...",rows:4,required:!0,"data-testid":"persona-detail-prompt"})]}),l.jsxs("label",{children:["Script",l.jsx("textarea",{value:U,onChange:X=>V(X.target.value),placeholder:`script({ model: "openai:gpt-4o" });
|
|
490
490
|
|
|
491
491
|
const grackle = await host.mcpServer({
|
|
492
492
|
id: "grackle",
|
|
@@ -500,4 +500,4 @@ const grackle = await host.mcpServer({
|
|
|
500
500
|
url: env.vars.GRACKLE_MCP_URL,
|
|
501
501
|
});
|
|
502
502
|
|
|
503
|
-
$\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),M==="agent"&&l.jsxs("div",{children:[l.jsx("label",{children:"Allowed MCP Tools"}),l.jsx(eb,{selectedTools:Z,onChange:X=>{ee(X);const Te=X.length===0?["__clear__"]:X;pe(()=>c(n.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,Te),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!Ne&&!je&&l.jsx("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--text-tertiary)",marginTop:"var(--space-xs)"},children:"Only agent personas with a runtime and model can be set as app default."})]}):null,l.jsx(Ja,{isOpen:ie,title:"Delete Persona?",description:`"${n==null?void 0:n.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:fe,onCancel:()=>be(!1)})]})}function cU(){const{themeId:n,resolvedThemeId:s,setTheme:i,preferSystem:o,setPreferSystem:c}=qb();return l.jsxs("section",{className:he.section,children:[l.jsx("h3",{className:he.sectionTitle,children:"Appearance"}),l.jsx("p",{className:he.sectionDescription,children:"Choose how Grackle looks across the app."}),l.jsx("div",{className:he.themeOptions,children:Oc.filter(u=>!u.hidden).map(u=>{const d=!!(u.variantLightId&&u.variantDarkId),m=d?n===u.id||n===u.variantLightId||n===u.variantDarkId:n===u.id,h=d&&s===u.variantLightId;return l.jsxs("button",{type:"button",className:`${he.themeOption} ${m?he.themeOptionSelected:""}`,"aria-pressed":m,onClick:()=>i(u.id),children:[l.jsxs("span",{className:he.themeOptionHeader,children:[l.jsxs("span",{children:[l.jsx("span",{className:he.themeOptionLabel,children:u.label}),l.jsx("span",{className:he.themeOptionDesc,children:u.description})]}),d&&l.jsxs("span",{className:he.variantToggle,children:[l.jsx("span",{role:"button",tabIndex:0,className:`${he.variantButton} ${m&&h?he.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),i(u.variantLightId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),i(u.variantLightId))},"aria-label":"Light variant","aria-pressed":m&&h,children:"☼"}),l.jsx("span",{role:"button",tabIndex:0,className:`${he.variantButton} ${m&&!h?he.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),i(u.variantDarkId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),i(u.variantDarkId))},"aria-label":"Dark variant","aria-pressed":m&&!h,children:"☾"})]})]}),u.swatches&&l.jsx("span",{className:he.themeSwatches,children:u.swatches.map((g,v)=>l.jsx("span",{className:he.themeSwatch,style:{background:g}},v))})]},u.id)})}),l.jsxs("label",{className:he.systemToggle,children:[l.jsx("input",{type:"checkbox",checked:o,onChange:u=>c(u.target.checked)}),l.jsx("span",{children:"Match system light/dark preference"})]}),l.jsx("p",{className:he.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),l.jsxs("p",{className:he.themeActive,children:["Active theme: ",l.jsx("strong",{children:s})]})]})}function uU(){return l.jsx(cU,{})}function dU({connected:n,environments:s,sessions:i}){const o=s.filter(d=>d.status==="connected").length,c=s.length,u=i.filter(d=>["running","idle"].includes(d.status)).length;return l.jsxs("section",{className:he.section,"data-testid":"about-panel",children:[l.jsx("h3",{className:he.sectionTitle,children:"About"}),l.jsx("p",{className:he.sectionDescription,children:"Connection status and application information."}),l.jsxs("div",{className:he.aboutGrid,children:[l.jsxs("div",{className:he.aboutItem,children:[l.jsx("span",{className:he.aboutLabel,children:"Connection"}),l.jsxs("span",{className:he.aboutValue,children:[l.jsx("span",{className:`${he.aboutDot} ${n?he.aboutDotConnected:he.aboutDotDisconnected}`}),n?"Connected":"Disconnected"]})]}),l.jsxs("div",{className:he.aboutItem,children:[l.jsx("span",{className:he.aboutLabel,children:"Environments"}),l.jsxs("span",{className:he.aboutValue,children:[o,"/",c," connected"]})]}),l.jsxs("div",{className:he.aboutItem,children:[l.jsx("span",{className:he.aboutLabel,children:"Active Sessions"}),l.jsx("span",{className:he.aboutValue,children:u})]}),l.jsxs("div",{className:he.aboutItem,children:[l.jsx("span",{className:he.aboutLabel,children:"Version"}),l.jsx("span",{className:he.aboutValue,children:"0.83.1"})]})]})]})}function fU({currentVersion:n,latestVersion:s,updateAvailable:i,isDocker:o}){if(!i)return l.jsx(l.Fragment,{});const c=o?"docker pull ghcr.io/nick-pape/grackle:latest && docker restart grackle":`npm install -g @grackle-ai/cli@${s}`;return l.jsx("div",{"data-testid":"update-banner",children:l.jsxs(ZD,{variant:"info",dismissible:!0,children:[l.jsxs("strong",{children:["Grackle v",s]})," is available (you have v",n,")."," ","Run: ",l.jsx("code",{children:c})]})})}function pU(){const[n,s]=y.useState(void 0);return y.useEffect(()=>{let i=!1;return we.getVersionStatus({}).then(o=>{i||s({currentVersion:o.currentVersion,latestVersion:o.latestVersion,updateAvailable:o.updateAvailable,isDocker:o.isDocker})},()=>{}),()=>{i=!0}},[]),n}function mU(){const{connected:n,environments:s,sessions:i}=pt(),o=pU();return l.jsxs(l.Fragment,{children:[o&&l.jsx(fU,{currentVersion:o.currentVersion,latestVersion:o.latestVersion,updateAvailable:o.updateAvailable,isDocker:o.isDocker}),l.jsx(dU,{connected:n,environments:s,sessions:i})]})}const hU="_group_1iprv_1",gU="_groupTitle_1iprv_8",vU="_shortcutList_1iprv_17",yU="_shortcutRow_1iprv_23",bU="_keys_1iprv_36",_U="_kbd_1iprv_43",xU="_description_1iprv_60",Ha={group:hU,groupTitle:gU,shortcutList:vU,shortcutRow:yU,keys:bU,kbd:_U,description:xU},SU=[{title:"Global",shortcuts:[{keys:["?"],description:"Open keyboard shortcuts reference"},{keys:["N"],description:"Create a new task"},{keys:["Escape"],description:"Close dialog or cancel editing"}]},{title:"Task Page",shortcuts:[{keys:["1"],description:"Switch to Overview tab"},{keys:["2"],description:"Switch to Stream tab"},{keys:["3"],description:"Switch to Findings tab"}]},{title:"Workspace Page",shortcuts:[{keys:["1"],description:"Switch to Graph view"},{keys:["2"],description:"Switch to Board view"},{keys:["3"],description:"Switch to Tasks view"}]},{title:"Navigation Lists",shortcuts:[{keys:["←"],description:"Previous tab (horizontal nav)"},{keys:["→"],description:"Next tab (horizontal nav)"},{keys:["↑"],description:"Previous item (vertical nav)"},{keys:["↓"],description:"Next item (vertical nav)"},{keys:["J"],description:"Next item (alias for arrow down/right)"},{keys:["K"],description:"Previous item (alias for arrow up/left)"},{keys:["Home"],description:"Jump to first item"},{keys:["End"],description:"Jump to last item"}]},{title:"Editing",shortcuts:[{keys:["Enter"],description:"Activate / save inline edit"},{keys:["Space"],description:"Activate button or start editing"},{keys:["Escape"],description:"Cancel edit and discard changes"}]},{title:"Chat",shortcuts:[{keys:["Enter"],description:"Send message (when input is focused)"}]}];function TU(){return l.jsxs("section",{className:he.section,"data-testid":"keyboard-shortcuts-panel",children:[l.jsx("h3",{className:he.sectionTitle,children:"Keyboard Shortcuts"}),l.jsx("p",{className:he.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),SU.map(n=>l.jsxs("div",{className:Ha.group,children:[l.jsx("h4",{className:Ha.groupTitle,children:n.title}),l.jsx("div",{className:Ha.shortcutList,children:n.shortcuts.map(s=>l.jsxs("div",{className:Ha.shortcutRow,children:[l.jsx("span",{className:Ha.keys,children:s.keys.map(i=>l.jsx("kbd",{className:Ha.kbd,children:i},i))}),l.jsx("span",{className:Ha.description,children:s.description})]},s.description))})]},n.title))]})}function kU(){return l.jsx(TU,{})}const ab=ei();function wU(){const n=St();return Ms({key:"?"},()=>{n(d2)}),Ms({key:"n"},()=>{n(ab)}),Ms({key:"N"},()=>{n(ab)}),l.jsx(l.Fragment,{})}const NU="_wizard_1260s_1",jU="_container_1260s_10",CU="_stepContent_1260s_19",EU="_logoArea_1260s_28",AU="_logoImage_1260s_32",DU="_heading_1260s_41",RU="_tagline_1260s_49",MU="_subtitle_1260s_56",OU="_featureList_1260s_64",IU="_runtimeGrid_1260s_89",BU="_runtimeCard_1260s_101",LU="_runtimeName_1260s_133",UU="_runtimeDescription_1260s_139",zU="_buttonRow_1260s_144",PU="_primaryButton_1260s_151",VU="_ghostButton_1260s_185",qU="_dots_1260s_213",HU="_dot_1260s_213",rt={wizard:NU,container:jU,stepContent:CU,logoArea:EU,logoImage:AU,heading:DU,tagline:RU,subtitle:MU,featureList:OU,runtimeGrid:IU,runtimeCard:BU,runtimeName:LU,runtimeDescription:UU,buttonRow:zU,primaryButton:PU,ghostButton:VU,dots:qU,dot:HU};function GU({onNext:n}){return l.jsxs("div",{className:rt.stepContent,"data-testid":"setup-welcome",children:[l.jsx("div",{className:rt.logoArea,children:l.jsx("img",{src:"/grackle-logo.png",alt:"Grackle",className:rt.logoImage})}),l.jsx("h1",{className:rt.heading,children:"Welcome to Grackle"}),l.jsx("p",{className:rt.tagline,children:"Multi-agent orchestration for software teams"}),l.jsx("button",{type:"button",className:rt.primaryButton,onClick:n,"data-testid":"setup-get-started",children:"Get Started"})]})}function $U({onNext:n,onBack:s}){return l.jsxs("div",{className:rt.stepContent,"data-testid":"setup-about",children:[l.jsx("h2",{className:rt.heading,children:"What is Grackle?"}),l.jsxs("ul",{className:rt.featureList,children:[l.jsx("li",{children:"Run Claude, Copilot, and Codex agents side by side"}),l.jsx("li",{children:"Provision and control dev environments — SSH, Codespaces, or local"}),l.jsx("li",{children:"Organize work into workspaces with agent-executable tasks"}),l.jsx("li",{children:"Customize agent behavior with personas, tools, and MCP servers"}),l.jsx("li",{children:"Live-stream agent sessions with full terminal replay"})]}),l.jsxs("div",{className:rt.buttonRow,children:[l.jsx("button",{type:"button",className:rt.ghostButton,onClick:s,children:"Back"}),l.jsx("button",{type:"button",className:rt.primaryButton,onClick:n,"data-testid":"setup-about-next",children:"Next"})]})]})}const FU=[{id:"claude-code",name:"Claude Code",description:"Anthropic's agentic coding tool"},{id:"copilot",name:"Copilot Coding Agent",description:"GitHub's AI pair programmer"},{id:"codex",name:"Codex CLI",description:"OpenAI's coding agent"},{id:"goose",name:"Goose",description:"Block's open-source AI coding agent"}];function ZU({currentRuntime:n,onFinish:s,onBack:i,finishDisabled:o}){const[c,u]=y.useState(n||"claude-code");return y.useEffect(()=>{n&&u(n)},[n]),l.jsxs("div",{className:rt.stepContent,"data-testid":"setup-runtime",children:[l.jsx("h2",{className:rt.heading,children:"Choose Your Runtime"}),l.jsx("p",{className:rt.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),l.jsx("div",{className:rt.runtimeGrid,children:FU.map(d=>l.jsxs("button",{type:"button",className:rt.runtimeCard,"data-selected":c===d.id,"aria-pressed":c===d.id,"data-testid":`runtime-card-${d.id}`,onClick:()=>u(d.id),children:[l.jsx("span",{className:rt.runtimeName,children:d.name}),l.jsx("span",{className:rt.runtimeDescription,children:d.description})]},d.id))}),l.jsxs("div",{className:rt.buttonRow,children:[l.jsx("button",{type:"button",className:rt.ghostButton,onClick:i,children:"Back"}),l.jsx("button",{type:"button",className:rt.primaryButton,onClick:()=>s(c),disabled:o,"data-testid":"setup-finish",children:"Finish"})]})]})}const KU=3,ib={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function YU(){const{personas:n,updatePersona:s,completeOnboarding:i,onboardingCompleted:o}=pt(),c=St(),[u,d]=y.useState(0),m=n.find(g=>g.id==="claude-code"),h=y.useCallback(g=>{if(m&&g!==m.runtime){const b=ib[g]??"sonnet";s(m.id,void 0,void 0,void 0,g,b).catch(()=>{})}const v=n.find(b=>b.id===n0);if(v&&g!==v.runtime){const b=ib[g]??"sonnet";s(n0,void 0,void 0,void 0,g,b).catch(()=>{})}i(),c("/",{replace:!0})},[m,n,s,i,c]);return o===!0?l.jsx(Zn,{to:"/",replace:!0}):l.jsx("div",{className:rt.wizard,"data-testid":"setup-wizard",children:l.jsxs("div",{className:rt.container,children:[l.jsx(rs,{mode:"wait",children:l.jsxs(Rt.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[u===0&&l.jsx(GU,{onNext:()=>d(1)}),u===1&&l.jsx($U,{onNext:()=>d(2),onBack:()=>d(0)}),u===2&&l.jsx(ZU,{currentRuntime:(m==null?void 0:m.runtime)??"claude-code",onFinish:h,onBack:()=>d(1),finishDisabled:!m})]},u)}),l.jsx("div",{className:rt.dots,children:Array.from({length:KU},(g,v)=>l.jsx("span",{className:rt.dot,"data-active":v===u},v))})]})})}const JU="_root_zndgp_1",WU="_body_zndgp_7",XU="_main_zndgp_19",QU="_sidebarWrapper_zndgp_26",e7="_overlay_zndgp_51",pr={root:JU,body:WU,main:XU,sidebarWrapper:QU,overlay:e7},t7=y.lazy(()=>NT(()=>import("./KnowledgePage-DD7HmNHB.js"),__vite__mapDeps([0,1,2,3,4])).then(n=>({default:n.KnowledgePage}))),Ux=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function n7(){const{connected:n,environments:s,sessions:i,tasks:o}=pt(),c=It(),d=$b()!==void 0,[m,h]=y.useState(!1),g=y.useCallback(()=>h(v=>!v),[]);return y.useEffect(()=>{h(!1)},[c.pathname]),y.useEffect(()=>{if(!m)return;const v=b=>{b.key==="Escape"&&h(!1)};return document.addEventListener("keydown",v),()=>{document.removeEventListener("keydown",v)}},[m]),l.jsxs(l.Fragment,{children:[l.jsx(pw,{connected:n,environments:s,sessions:i,onToggleSidebar:d?g:void 0,sidebarOpen:m}),l.jsx(_w,{}),l.jsxs("div",{className:pr.body,children:[d&&l.jsx("div",{className:pr.sidebarWrapper,"data-sidebar-open":m,children:l.jsx(Cw,{})}),d&&m&&l.jsx("div",{className:pr.overlay,"data-testid":"drawer-overlay",onClick:()=>h(!1)}),l.jsxs("div",{className:pr.main,children:[l.jsx(Qa,{}),l.jsx(kD,{sessions:i,tasks:o,environments:s})]})]}),l.jsx(LD,{}),l.jsx(wU,{})]})}function s7(){const{lastSpawnedId:n,environments:s,tasks:i,connected:o,onboardingCompleted:c}=pt(),{showToast:u}=Bs();F3(s,u),J3(i,u);const d=St(),m=It();return y.useEffect(()=>{n&&!m.pathname.includes("/tasks/")&&d(jb(n),{replace:!0})},[n,d,m.pathname]),o&&c===!1?l.jsx(Zn,{to:"/setup",replace:!0}):l.jsx(xw,{children:l.jsxs("div",{className:pr.root,children:[Ux&&l.jsx(vR,{}),l.jsx(n7,{})]})})}function Bf(){const{workspaceId:n}=va(),{workspaces:s}=pt(),i=It(),o=s.find(h=>h.id===n);if(!(o!=null&&o.environmentId))return s.length===0?void 0:l.jsx(Zn,{to:"/environments",replace:!0});const c=encodeURIComponent(n),u=`/workspaces/${c}`,d=i.pathname.startsWith(u)?i.pathname.slice(u.length):"",m=`/environments/${encodeURIComponent(o.environmentId)}/workspaces/${c}${d}${i.search}${i.hash}`;return l.jsx(Zn,{to:m,replace:!0})}function a7(){return l.jsxs(Nk,{children:[l.jsx(Ce,{path:"setup",element:l.jsx(YU,{})}),l.jsxs(Ce,{element:l.jsx(s7,{}),children:[l.jsx(Ce,{index:!0,element:l.jsx(TI,{})}),l.jsx(Ce,{path:"chat",element:l.jsx(QI,{})}),l.jsx(Ce,{path:"sessions/new",element:l.jsx(r5,{})}),l.jsx(Ce,{path:"sessions/:sessionId",element:l.jsx(u5,{})}),l.jsx(Ce,{element:l.jsx(gD,{}),children:l.jsx(Ce,{path:"knowledge",element:l.jsx(y.Suspense,{fallback:l.jsx(Dx,{}),children:l.jsx(t7,{})})})}),l.jsxs(Ce,{element:l.jsx(pD,{}),children:[l.jsx(Ce,{path:"tasks",element:l.jsx(xI,{})}),l.jsx(Ce,{path:"tasks/new",element:l.jsx(Wy,{})}),l.jsx(Ce,{path:"tasks/:taskId",element:l.jsx(fa,{})}),l.jsx(Ce,{path:"tasks/:taskId/edit",element:l.jsx(fa,{})}),l.jsx(Ce,{path:"tasks/:taskId/stream",element:l.jsx(fa,{})}),l.jsx(Ce,{path:"tasks/:taskId/findings",element:l.jsx(fa,{})})]}),l.jsxs(Ce,{element:l.jsx(mD,{}),children:[l.jsx(Ce,{path:"workspaces",element:l.jsx(Zn,{to:"/environments",replace:!0})}),l.jsx(Ce,{path:"workspaces/new",element:l.jsx(fB,{})}),l.jsx(Ce,{path:"workspaces/:workspaceId",element:l.jsx(Bf,{})}),l.jsx(Ce,{path:"workspaces/:workspaceId/tasks/:taskId",element:l.jsx(Bf,{})}),l.jsx(Ce,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:l.jsx(Bf,{})}),l.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId",element:l.jsx(A4,{})}),l.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:l.jsx(Wy,{})}),l.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:l.jsx(fa,{})}),l.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:l.jsx(fa,{})}),l.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:l.jsx(fa,{})}),l.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings",element:l.jsx(fa,{})}),l.jsxs(Ce,{path:"environments",element:l.jsx(oL,{}),children:[l.jsx(Ce,{index:!0,element:l.jsx(SI,{})}),l.jsx(Ce,{path:"new",element:l.jsx(tL,{})}),l.jsx(Ce,{path:":environmentId",element:l.jsx(OL,{})}),l.jsx(Ce,{path:":environmentId/edit",element:l.jsx(nL,{})})]})]}),l.jsx(Ce,{element:l.jsx(hD,{}),children:l.jsxs(Ce,{path:"settings",element:l.jsx(LL,{}),children:[l.jsx(Ce,{index:!0,element:l.jsx(Zn,{to:"credentials",replace:!0})}),l.jsx(Ce,{path:"environments",element:l.jsx(Zn,{to:"/environments",replace:!0})}),l.jsx(Ce,{path:"credentials",element:l.jsx(k8,{})}),l.jsx(Ce,{path:"tokens",element:l.jsx(Zn,{to:"../credentials",replace:!0})}),l.jsx(Ce,{path:"personas",element:l.jsx(G8,{})}),l.jsx(Ce,{path:"personas/new",element:l.jsx(sb,{})}),l.jsx(Ce,{path:"personas/:personaId",element:l.jsx(sb,{})}),l.jsx(Ce,{path:"appearance",element:l.jsx(uU,{})}),l.jsx(Ce,{path:"shortcuts",element:l.jsx(kU,{})}),l.jsx(Ce,{path:"about",element:l.jsx(mU,{})})]})}),l.jsx(Ce,{path:"*",element:l.jsx(Zn,{to:"/",replace:!0})})]})]})}const i7=1e4;function o7(){const{onboardingCompleted:n}=pt(),[s,i]=y.useState(!1);y.useEffect(()=>{if(n!==void 0)return;const c=setTimeout(()=>i(!0),i7);return()=>clearTimeout(c)},[n]);const o=n===void 0&&!s;return l.jsx(rs,{mode:"wait",children:o?l.jsx(Rt.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:l.jsx(Dx,{})},"splash"):l.jsx(Rt.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:l.jsx(Wk,{basename:"/".replace(/\/$/,""),children:l.jsx(a7,{})})},"app")})}function r7(){const n=Ux?W2:V2;return l.jsx(sw,{children:l.jsx(Q2,{children:l.jsx(n,{children:l.jsx(o7,{})})})})}TT.createRoot(document.getElementById("root")).render(l.jsx(y.StrictMode,{children:l.jsx(r7,{})}));export{ba as B,Db as K,pt as a,jb as s,os as t,St as u};
|
|
503
|
+
$\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),M==="agent"&&l.jsxs("div",{children:[l.jsx("label",{children:"Allowed MCP Tools"}),l.jsx(eb,{selectedTools:Z,onChange:X=>{ee(X);const Te=X.length===0?["__clear__"]:X;pe(()=>c(n.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,Te),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!Ne&&!je&&l.jsx("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--text-tertiary)",marginTop:"var(--space-xs)"},children:"Only agent personas with a runtime and model can be set as app default."})]}):null,l.jsx(Ja,{isOpen:ie,title:"Delete Persona?",description:`"${n==null?void 0:n.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:fe,onCancel:()=>be(!1)})]})}function cU(){const{themeId:n,resolvedThemeId:s,setTheme:i,preferSystem:o,setPreferSystem:c}=qb();return l.jsxs("section",{className:he.section,children:[l.jsx("h3",{className:he.sectionTitle,children:"Appearance"}),l.jsx("p",{className:he.sectionDescription,children:"Choose how Grackle looks across the app."}),l.jsx("div",{className:he.themeOptions,children:Oc.filter(u=>!u.hidden).map(u=>{const d=!!(u.variantLightId&&u.variantDarkId),m=d?n===u.id||n===u.variantLightId||n===u.variantDarkId:n===u.id,h=d&&s===u.variantLightId;return l.jsxs("button",{type:"button",className:`${he.themeOption} ${m?he.themeOptionSelected:""}`,"aria-pressed":m,onClick:()=>i(u.id),children:[l.jsxs("span",{className:he.themeOptionHeader,children:[l.jsxs("span",{children:[l.jsx("span",{className:he.themeOptionLabel,children:u.label}),l.jsx("span",{className:he.themeOptionDesc,children:u.description})]}),d&&l.jsxs("span",{className:he.variantToggle,children:[l.jsx("span",{role:"button",tabIndex:0,className:`${he.variantButton} ${m&&h?he.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),i(u.variantLightId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),i(u.variantLightId))},"aria-label":"Light variant","aria-pressed":m&&h,children:"☼"}),l.jsx("span",{role:"button",tabIndex:0,className:`${he.variantButton} ${m&&!h?he.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),i(u.variantDarkId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),i(u.variantDarkId))},"aria-label":"Dark variant","aria-pressed":m&&!h,children:"☾"})]})]}),u.swatches&&l.jsx("span",{className:he.themeSwatches,children:u.swatches.map((g,v)=>l.jsx("span",{className:he.themeSwatch,style:{background:g}},v))})]},u.id)})}),l.jsxs("label",{className:he.systemToggle,children:[l.jsx("input",{type:"checkbox",checked:o,onChange:u=>c(u.target.checked)}),l.jsx("span",{children:"Match system light/dark preference"})]}),l.jsx("p",{className:he.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),l.jsxs("p",{className:he.themeActive,children:["Active theme: ",l.jsx("strong",{children:s})]})]})}function uU(){return l.jsx(cU,{})}function dU({connected:n,environments:s,sessions:i}){const o=s.filter(d=>d.status==="connected").length,c=s.length,u=i.filter(d=>["running","idle"].includes(d.status)).length;return l.jsxs("section",{className:he.section,"data-testid":"about-panel",children:[l.jsx("h3",{className:he.sectionTitle,children:"About"}),l.jsx("p",{className:he.sectionDescription,children:"Connection status and application information."}),l.jsxs("div",{className:he.aboutGrid,children:[l.jsxs("div",{className:he.aboutItem,children:[l.jsx("span",{className:he.aboutLabel,children:"Connection"}),l.jsxs("span",{className:he.aboutValue,children:[l.jsx("span",{className:`${he.aboutDot} ${n?he.aboutDotConnected:he.aboutDotDisconnected}`}),n?"Connected":"Disconnected"]})]}),l.jsxs("div",{className:he.aboutItem,children:[l.jsx("span",{className:he.aboutLabel,children:"Environments"}),l.jsxs("span",{className:he.aboutValue,children:[o,"/",c," connected"]})]}),l.jsxs("div",{className:he.aboutItem,children:[l.jsx("span",{className:he.aboutLabel,children:"Active Sessions"}),l.jsx("span",{className:he.aboutValue,children:u})]}),l.jsxs("div",{className:he.aboutItem,children:[l.jsx("span",{className:he.aboutLabel,children:"Version"}),l.jsx("span",{className:he.aboutValue,children:"0.83.2"})]})]})]})}function fU({currentVersion:n,latestVersion:s,updateAvailable:i,isDocker:o}){if(!i)return l.jsx(l.Fragment,{});const c=o?"docker pull ghcr.io/nick-pape/grackle:latest && docker restart grackle":`npm install -g @grackle-ai/cli@${s}`;return l.jsx("div",{"data-testid":"update-banner",children:l.jsxs(ZD,{variant:"info",dismissible:!0,children:[l.jsxs("strong",{children:["Grackle v",s]})," is available (you have v",n,")."," ","Run: ",l.jsx("code",{children:c})]})})}function pU(){const[n,s]=y.useState(void 0);return y.useEffect(()=>{let i=!1;return we.getVersionStatus({}).then(o=>{i||s({currentVersion:o.currentVersion,latestVersion:o.latestVersion,updateAvailable:o.updateAvailable,isDocker:o.isDocker})},()=>{}),()=>{i=!0}},[]),n}function mU(){const{connected:n,environments:s,sessions:i}=pt(),o=pU();return l.jsxs(l.Fragment,{children:[o&&l.jsx(fU,{currentVersion:o.currentVersion,latestVersion:o.latestVersion,updateAvailable:o.updateAvailable,isDocker:o.isDocker}),l.jsx(dU,{connected:n,environments:s,sessions:i})]})}const hU="_group_1iprv_1",gU="_groupTitle_1iprv_8",vU="_shortcutList_1iprv_17",yU="_shortcutRow_1iprv_23",bU="_keys_1iprv_36",_U="_kbd_1iprv_43",xU="_description_1iprv_60",Ha={group:hU,groupTitle:gU,shortcutList:vU,shortcutRow:yU,keys:bU,kbd:_U,description:xU},SU=[{title:"Global",shortcuts:[{keys:["?"],description:"Open keyboard shortcuts reference"},{keys:["N"],description:"Create a new task"},{keys:["Escape"],description:"Close dialog or cancel editing"}]},{title:"Task Page",shortcuts:[{keys:["1"],description:"Switch to Overview tab"},{keys:["2"],description:"Switch to Stream tab"},{keys:["3"],description:"Switch to Findings tab"}]},{title:"Workspace Page",shortcuts:[{keys:["1"],description:"Switch to Graph view"},{keys:["2"],description:"Switch to Board view"},{keys:["3"],description:"Switch to Tasks view"}]},{title:"Navigation Lists",shortcuts:[{keys:["←"],description:"Previous tab (horizontal nav)"},{keys:["→"],description:"Next tab (horizontal nav)"},{keys:["↑"],description:"Previous item (vertical nav)"},{keys:["↓"],description:"Next item (vertical nav)"},{keys:["J"],description:"Next item (alias for arrow down/right)"},{keys:["K"],description:"Previous item (alias for arrow up/left)"},{keys:["Home"],description:"Jump to first item"},{keys:["End"],description:"Jump to last item"}]},{title:"Editing",shortcuts:[{keys:["Enter"],description:"Activate / save inline edit"},{keys:["Space"],description:"Activate button or start editing"},{keys:["Escape"],description:"Cancel edit and discard changes"}]},{title:"Chat",shortcuts:[{keys:["Enter"],description:"Send message (when input is focused)"}]}];function TU(){return l.jsxs("section",{className:he.section,"data-testid":"keyboard-shortcuts-panel",children:[l.jsx("h3",{className:he.sectionTitle,children:"Keyboard Shortcuts"}),l.jsx("p",{className:he.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),SU.map(n=>l.jsxs("div",{className:Ha.group,children:[l.jsx("h4",{className:Ha.groupTitle,children:n.title}),l.jsx("div",{className:Ha.shortcutList,children:n.shortcuts.map(s=>l.jsxs("div",{className:Ha.shortcutRow,children:[l.jsx("span",{className:Ha.keys,children:s.keys.map(i=>l.jsx("kbd",{className:Ha.kbd,children:i},i))}),l.jsx("span",{className:Ha.description,children:s.description})]},s.description))})]},n.title))]})}function kU(){return l.jsx(TU,{})}const ab=ei();function wU(){const n=St();return Ms({key:"?"},()=>{n(dw)}),Ms({key:"n"},()=>{n(ab)}),Ms({key:"N"},()=>{n(ab)}),l.jsx(l.Fragment,{})}const NU="_wizard_1260s_1",jU="_container_1260s_10",CU="_stepContent_1260s_19",EU="_logoArea_1260s_28",AU="_logoImage_1260s_32",DU="_heading_1260s_41",RU="_tagline_1260s_49",MU="_subtitle_1260s_56",OU="_featureList_1260s_64",IU="_runtimeGrid_1260s_89",BU="_runtimeCard_1260s_101",LU="_runtimeName_1260s_133",UU="_runtimeDescription_1260s_139",zU="_buttonRow_1260s_144",PU="_primaryButton_1260s_151",VU="_ghostButton_1260s_185",qU="_dots_1260s_213",HU="_dot_1260s_213",rt={wizard:NU,container:jU,stepContent:CU,logoArea:EU,logoImage:AU,heading:DU,tagline:RU,subtitle:MU,featureList:OU,runtimeGrid:IU,runtimeCard:BU,runtimeName:LU,runtimeDescription:UU,buttonRow:zU,primaryButton:PU,ghostButton:VU,dots:qU,dot:HU};function GU({onNext:n}){return l.jsxs("div",{className:rt.stepContent,"data-testid":"setup-welcome",children:[l.jsx("div",{className:rt.logoArea,children:l.jsx("img",{src:"/grackle-logo.png",alt:"Grackle",className:rt.logoImage})}),l.jsx("h1",{className:rt.heading,children:"Welcome to Grackle"}),l.jsx("p",{className:rt.tagline,children:"Multi-agent orchestration for software teams"}),l.jsx("button",{type:"button",className:rt.primaryButton,onClick:n,"data-testid":"setup-get-started",children:"Get Started"})]})}function $U({onNext:n,onBack:s}){return l.jsxs("div",{className:rt.stepContent,"data-testid":"setup-about",children:[l.jsx("h2",{className:rt.heading,children:"What is Grackle?"}),l.jsxs("ul",{className:rt.featureList,children:[l.jsx("li",{children:"Run Claude, Copilot, and Codex agents side by side"}),l.jsx("li",{children:"Provision and control dev environments — SSH, Codespaces, or local"}),l.jsx("li",{children:"Organize work into workspaces with agent-executable tasks"}),l.jsx("li",{children:"Customize agent behavior with personas, tools, and MCP servers"}),l.jsx("li",{children:"Live-stream agent sessions with full terminal replay"})]}),l.jsxs("div",{className:rt.buttonRow,children:[l.jsx("button",{type:"button",className:rt.ghostButton,onClick:s,children:"Back"}),l.jsx("button",{type:"button",className:rt.primaryButton,onClick:n,"data-testid":"setup-about-next",children:"Next"})]})]})}const FU=[{id:"claude-code",name:"Claude Code",description:"Anthropic's agentic coding tool"},{id:"copilot",name:"Copilot Coding Agent",description:"GitHub's AI pair programmer"},{id:"codex",name:"Codex CLI",description:"OpenAI's coding agent"},{id:"goose",name:"Goose",description:"Block's open-source AI coding agent"}];function ZU({currentRuntime:n,onFinish:s,onBack:i,finishDisabled:o}){const[c,u]=y.useState(n||"claude-code");return y.useEffect(()=>{n&&u(n)},[n]),l.jsxs("div",{className:rt.stepContent,"data-testid":"setup-runtime",children:[l.jsx("h2",{className:rt.heading,children:"Choose Your Runtime"}),l.jsx("p",{className:rt.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),l.jsx("div",{className:rt.runtimeGrid,children:FU.map(d=>l.jsxs("button",{type:"button",className:rt.runtimeCard,"data-selected":c===d.id,"aria-pressed":c===d.id,"data-testid":`runtime-card-${d.id}`,onClick:()=>u(d.id),children:[l.jsx("span",{className:rt.runtimeName,children:d.name}),l.jsx("span",{className:rt.runtimeDescription,children:d.description})]},d.id))}),l.jsxs("div",{className:rt.buttonRow,children:[l.jsx("button",{type:"button",className:rt.ghostButton,onClick:i,children:"Back"}),l.jsx("button",{type:"button",className:rt.primaryButton,onClick:()=>s(c),disabled:o,"data-testid":"setup-finish",children:"Finish"})]})]})}const KU=3,ib={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function YU(){const{personas:n,updatePersona:s,completeOnboarding:i,onboardingCompleted:o}=pt(),c=St(),[u,d]=y.useState(0),m=n.find(g=>g.id==="claude-code"),h=y.useCallback(g=>{if(m&&g!==m.runtime){const b=ib[g]??"sonnet";s(m.id,void 0,void 0,void 0,g,b).catch(()=>{})}const v=n.find(b=>b.id===n0);if(v&&g!==v.runtime){const b=ib[g]??"sonnet";s(n0,void 0,void 0,void 0,g,b).catch(()=>{})}i(),c("/",{replace:!0})},[m,n,s,i,c]);return o===!0?l.jsx(Zn,{to:"/",replace:!0}):l.jsx("div",{className:rt.wizard,"data-testid":"setup-wizard",children:l.jsxs("div",{className:rt.container,children:[l.jsx(rs,{mode:"wait",children:l.jsxs(Rt.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[u===0&&l.jsx(GU,{onNext:()=>d(1)}),u===1&&l.jsx($U,{onNext:()=>d(2),onBack:()=>d(0)}),u===2&&l.jsx(ZU,{currentRuntime:(m==null?void 0:m.runtime)??"claude-code",onFinish:h,onBack:()=>d(1),finishDisabled:!m})]},u)}),l.jsx("div",{className:rt.dots,children:Array.from({length:KU},(g,v)=>l.jsx("span",{className:rt.dot,"data-active":v===u},v))})]})})}const JU="_root_zndgp_1",WU="_body_zndgp_7",XU="_main_zndgp_19",QU="_sidebarWrapper_zndgp_26",ez="_overlay_zndgp_51",pr={root:JU,body:WU,main:XU,sidebarWrapper:QU,overlay:ez},tz=y.lazy(()=>NT(()=>import("./KnowledgePage-vV_eStmC.js"),__vite__mapDeps([0,1,2,3,4])).then(n=>({default:n.KnowledgePage}))),Ux=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function nz(){const{connected:n,environments:s,sessions:i,tasks:o}=pt(),c=It(),d=$b()!==void 0,[m,h]=y.useState(!1),g=y.useCallback(()=>h(v=>!v),[]);return y.useEffect(()=>{h(!1)},[c.pathname]),y.useEffect(()=>{if(!m)return;const v=b=>{b.key==="Escape"&&h(!1)};return document.addEventListener("keydown",v),()=>{document.removeEventListener("keydown",v)}},[m]),l.jsxs(l.Fragment,{children:[l.jsx(p2,{connected:n,environments:s,sessions:i,onToggleSidebar:d?g:void 0,sidebarOpen:m}),l.jsx(_2,{}),l.jsxs("div",{className:pr.body,children:[d&&l.jsx("div",{className:pr.sidebarWrapper,"data-sidebar-open":m,children:l.jsx(C2,{})}),d&&m&&l.jsx("div",{className:pr.overlay,"data-testid":"drawer-overlay",onClick:()=>h(!1)}),l.jsxs("div",{className:pr.main,children:[l.jsx(Qa,{}),l.jsx(kD,{sessions:i,tasks:o,environments:s})]})]}),l.jsx(LD,{}),l.jsx(wU,{})]})}function sz(){const{lastSpawnedId:n,environments:s,tasks:i,connected:o,onboardingCompleted:c}=pt(),{showToast:u}=Bs();F3(s,u),J3(i,u);const d=St(),m=It();return y.useEffect(()=>{n&&!m.pathname.includes("/tasks/")&&d(jb(n),{replace:!0})},[n,d,m.pathname]),o&&c===!1?l.jsx(Zn,{to:"/setup",replace:!0}):l.jsx(x2,{children:l.jsxs("div",{className:pr.root,children:[Ux&&l.jsx(vR,{}),l.jsx(nz,{})]})})}function Bf(){const{workspaceId:n}=va(),{workspaces:s}=pt(),i=It(),o=s.find(h=>h.id===n);if(!(o!=null&&o.environmentId))return s.length===0?void 0:l.jsx(Zn,{to:"/environments",replace:!0});const c=encodeURIComponent(n),u=`/workspaces/${c}`,d=i.pathname.startsWith(u)?i.pathname.slice(u.length):"",m=`/environments/${encodeURIComponent(o.environmentId)}/workspaces/${c}${d}${i.search}${i.hash}`;return l.jsx(Zn,{to:m,replace:!0})}function az(){return l.jsxs(Nk,{children:[l.jsx(Ce,{path:"setup",element:l.jsx(YU,{})}),l.jsxs(Ce,{element:l.jsx(sz,{}),children:[l.jsx(Ce,{index:!0,element:l.jsx(TI,{})}),l.jsx(Ce,{path:"chat",element:l.jsx(QI,{})}),l.jsx(Ce,{path:"sessions/new",element:l.jsx(r5,{})}),l.jsx(Ce,{path:"sessions/:sessionId",element:l.jsx(u5,{})}),l.jsx(Ce,{element:l.jsx(gD,{}),children:l.jsx(Ce,{path:"knowledge",element:l.jsx(y.Suspense,{fallback:l.jsx(Dx,{}),children:l.jsx(tz,{})})})}),l.jsxs(Ce,{element:l.jsx(pD,{}),children:[l.jsx(Ce,{path:"tasks",element:l.jsx(xI,{})}),l.jsx(Ce,{path:"tasks/new",element:l.jsx(Wy,{})}),l.jsx(Ce,{path:"tasks/:taskId",element:l.jsx(fa,{})}),l.jsx(Ce,{path:"tasks/:taskId/edit",element:l.jsx(fa,{})}),l.jsx(Ce,{path:"tasks/:taskId/stream",element:l.jsx(fa,{})}),l.jsx(Ce,{path:"tasks/:taskId/findings",element:l.jsx(fa,{})})]}),l.jsxs(Ce,{element:l.jsx(mD,{}),children:[l.jsx(Ce,{path:"workspaces",element:l.jsx(Zn,{to:"/environments",replace:!0})}),l.jsx(Ce,{path:"workspaces/new",element:l.jsx(fB,{})}),l.jsx(Ce,{path:"workspaces/:workspaceId",element:l.jsx(Bf,{})}),l.jsx(Ce,{path:"workspaces/:workspaceId/tasks/:taskId",element:l.jsx(Bf,{})}),l.jsx(Ce,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:l.jsx(Bf,{})}),l.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId",element:l.jsx(A4,{})}),l.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:l.jsx(Wy,{})}),l.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:l.jsx(fa,{})}),l.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:l.jsx(fa,{})}),l.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:l.jsx(fa,{})}),l.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings",element:l.jsx(fa,{})}),l.jsxs(Ce,{path:"environments",element:l.jsx(oL,{}),children:[l.jsx(Ce,{index:!0,element:l.jsx(SI,{})}),l.jsx(Ce,{path:"new",element:l.jsx(tL,{})}),l.jsx(Ce,{path:":environmentId",element:l.jsx(OL,{})}),l.jsx(Ce,{path:":environmentId/edit",element:l.jsx(nL,{})})]})]}),l.jsx(Ce,{element:l.jsx(hD,{}),children:l.jsxs(Ce,{path:"settings",element:l.jsx(LL,{}),children:[l.jsx(Ce,{index:!0,element:l.jsx(Zn,{to:"credentials",replace:!0})}),l.jsx(Ce,{path:"environments",element:l.jsx(Zn,{to:"/environments",replace:!0})}),l.jsx(Ce,{path:"credentials",element:l.jsx(k8,{})}),l.jsx(Ce,{path:"tokens",element:l.jsx(Zn,{to:"../credentials",replace:!0})}),l.jsx(Ce,{path:"personas",element:l.jsx(G8,{})}),l.jsx(Ce,{path:"personas/new",element:l.jsx(sb,{})}),l.jsx(Ce,{path:"personas/:personaId",element:l.jsx(sb,{})}),l.jsx(Ce,{path:"appearance",element:l.jsx(uU,{})}),l.jsx(Ce,{path:"shortcuts",element:l.jsx(kU,{})}),l.jsx(Ce,{path:"about",element:l.jsx(mU,{})})]})}),l.jsx(Ce,{path:"*",element:l.jsx(Zn,{to:"/",replace:!0})})]})]})}const iz=1e4;function oz(){const{onboardingCompleted:n}=pt(),[s,i]=y.useState(!1);y.useEffect(()=>{if(n!==void 0)return;const c=setTimeout(()=>i(!0),iz);return()=>clearTimeout(c)},[n]);const o=n===void 0&&!s;return l.jsx(rs,{mode:"wait",children:o?l.jsx(Rt.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:l.jsx(Dx,{})},"splash"):l.jsx(Rt.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:l.jsx(Wk,{basename:"/".replace(/\/$/,""),children:l.jsx(az,{})})},"app")})}function rz(){const n=Ux?Ww:Vw;return l.jsx(s2,{children:l.jsx(Qw,{children:l.jsx(n,{children:l.jsx(oz,{})})})})}TT.createRoot(document.getElementById("root")).render(l.jsx(y.StrictMode,{children:l.jsx(rz,{})}));export{ba as B,Db as K,pt as a,jb as s,os as t,St as u};
|